PageSourceSearch

https://royallight-n1.hf.space/assets/Index-5132bde6.js

js royallight-n1.hf.space collected 2026-10-03 17:19:35 UTC 3,550,758 bytes, 13,264 lines download raw bytes

1import{n as qv}from"./index-806c9b86.js";import{B as Uf}from"./Button-a5a40815.js";import{B as gl}from"./BlockLabel-bd7b6ddd.js";import{I as Df}from"./IconButton-fa43e5dd.js";import{D as Zv}from"./Download-696bd40c.js";import{c as Qr,a as Jv,S as Vf}from"./Index-b65c66ac.js";import{F as Ya}from"./File-d0b52941.js";import{U as $v,M as eb}from"./ModifyUpload-6a3fcb74.js";import{U as tb}from"./Upload-4ace7e8f.js";import{E as nb}from"./Empty-ae6d3cf5.js";import{U as ib}from"./UploadText-a75e6f1d.js";import{default as _y}from"./Example-786d8148.js";import"./svelte/svelte.js";import"./Clear-2c7bae91.js";/* empty css                                                   */function rb(Qe,ke){for(var Ae=0;Ae<ke.length;Ae++){const v=ke[Ae];if(typeof v!="string"&&!Array.isArray(v)){for(const f in v)if(f!=="default"&&!(f in Qe)){const B=Object.getOwnPropertyDescriptor(v,f);B&&Object.defineProperty(Qe,f,B.get?B:{enumerable:!0,get:()=>v[f]})}}}return Object.freeze(Object.defineProperty(Qe,Symbol.toStringTag,{value:"Module"}))}var kf={exports:{}};(function(Qe,ke){(function(Ae,v){Qe.exports=v()})(typeof self<"u"?self:typeof Qr<"u"?Qr:Qr,function(){return function(Ae){var v={};function f(B){if(v[B])return v[B].exports;var _=v[B]={i:B,l:!1,exports:{}};return Ae[B].call(_.exports,_,_.exports,f),_.l=!0,_.exports}return f.m=Ae,f.c=v,f.d=function(B,_,x){f.o(B,_)||Object.defineProperty(B,_,{enumerable:!0,get:x})},f.r=function(B){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(B,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(B,"__esModule",{value:!0})},f.t=function(B,_){if(1&_&&(B=f(B)),8&_||4&_&&typeof B=="object"&&B&&B.__esModule)return B;var x=Object.create(null);if(f.r(x),Object.defineProperty(x,"default",{enumerable:!0,value:B}),2&_&&typeof B!="string")for(var u in B)f.d(x,u,function(M){return B[M]}.bind(null,u));return x},f.n=function(B){var _=B&&B.__esModule?function(){return B.default}:function(){return B};return f.d(_,"a",_),_},f.o=function(B,_){return Object.prototype.hasOwnProperty.call(B,_)},f.p="",f(f.s=169)}([function(Ae,v,f){f.d(v,"d",function(){return R}),f.d(v,"e",function(){return C}),f.d(v,"f",function(){return m}),f.d(v,"b",function(){return c}),f.d(v,"a",function(){return E}),f.d(v,"c",function(){return S});var B=f(14),_=f(28),x=f(44),u=f(11),M=f(74),R=function(){function g(l,h){l===void 0&&(l=0),h===void 0&&(h=0),this.x=l,this.y=h}return g.prototype.toString=function(){return"{X: "+this.x+" Y: "+this.y+"}"},g.prototype.getClassName=function(){return"Vector2"},g.prototype.getHashCode=function(){var l=0|this.x;return l=397*l^(0|this.y)},g.prototype.toArray=function(l,h){return h===void 0&&(h=0),l[h]=this.x,l[h+1]=this.y,this},g.prototype.fromArray=function(l,h){return h===void 0&&(h=0),g.FromArrayToRef(l,h,this),this},g.prototype.asArray=function(){var l=new Array;return this.toArray(l,0),l},g.prototype.copyFrom=function(l){return this.x=l.x,this.y=l.y,this},g.prototype.copyFromFloats=function(l,h){return this.x=l,this.y=h,this},g.prototype.set=function(l,h){return this.copyFromFloats(l,h)},g.prototype.add=function(l){return new g(this.x+l.x,this.y+l.y)},g.prototype.addToRef=function(l,h){return h.x=this.x+l.x,h.y=this.y+l.y,this},g.prototype.addInPlace=function(l){return this.x+=l.x,this.y+=l.y,this},g.prototype.addVector3=function(l){return new g(this.x+l.x,this.y+l.y)},g.prototype.subtract=function(l){return new g(this.x-l.x,this.y-l.y)},g.prototype.subtractToRef=function(l,h){return h.x=this.x-l.x,h.y=this.y-l.y,this},g.prototype.subtractInPlace=function(l){return this.x-=l.x,this.y-=l.y,this},g.prototype.multiplyInPlace=function(l){return this.x*=l.x,this.y*=l.y,this},g.prototype.multiply=function(l){return new g(this.x*l.x,this.y*l.y)},g.prototype.multiplyToRef=function(l,h){return h.x=this.x*l.x,h.y=this.y*l.y,this},g.prototype.multiplyByFloats=function(l,h){return new g(this.x*l,this.y*h)},g.prototype.divide=function(l){return new g(this.x/l.x,this.y/l.y)},g.prototype.divideToRef=function(l,h){return h.x=this.x/l.x,h.y=this.y/l.y,this},g.prototype.divideInPlace=function(l){return this.divideToRef(l,this)},g.prototype.negate=function(){return new g(-this.x,-this.y)},g.prototype.negateInPlace=function(){return this.x*=-1,this.y*=-1,this},g.prototype.negateToRef=function(l){return l.copyFromFloats(-1*this.x,-1*this.y)},g.prototype.scaleInPlace=function(l){return this.x*=l,this.y*=l,this},g.prototype.scale=function(l){var h=new g(0,0);return this.scaleToRef(l,h),h},g.prototype.scaleToRef=function(l,h){return h.x=this.x*l,h.y=this.y*l,this},g.prototype.scaleAndAddToRef=function(l,h){return h.x+=this.x*l,h.y+=this.y*l,this},g.prototype.equals=function(l){return l&&this.x===l.x&&this.y===l.y},g.prototype.equalsWithEpsilon=function(l,h){return h===void 0&&(h=_.a),l&&B.a.WithinEpsilon(this.x,l.x,h)&&B.a.WithinEpsilon(this.y,l.y,h)}
1,g.prototype.floor=function(){return new g(Math.floor(this.x),Math.floor(this.y))},g.prototype.fract=function(){return new g(this.x-Math.floor(this.x),this.y-Math.floor(this.y))},g.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},g.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y},g.prototype.normalize=function(){var l=this.length();return l===0||(this.x/=l,this.y/=l),this},g.prototype.clone=function(){return new g(this.x,this.y)},g.Zero=function(){return new g(0,0)},g.One=function(){return new g(1,1)},g.FromArray=function(l,h){return h===void 0&&(h=0),new g(l[h],l[h+1])},g.FromArrayToRef=function(l,h,b){b.x=l[h],b.y=l[h+1]},g.CatmullRom=function(l,h,b,T,D){var w=D*D,N=D*w;return new g(.5*(2*h.x+(-l.x+b.x)*D+(2*l.x-5*h.x+4*b.x-T.x)*w+(-l.x+3*h.x-3*b.x+T.x)*N),.5*(2*h.y+(-l.y+b.y)*D+(2*l.y-5*h.y+4*b.y-T.y)*w+(-l.y+3*h.y-3*b.y+T.y)*N))},g.Clamp=function(l,h,b){var T=l.x;T=(T=T>b.x?b.x:T)<h.x?h.x:T;var D=l.y;return new g(T,D=(D=D>b.y?b.y:D)<h.y?h.y:D)},g.Hermite=function(l,h,b,T,D){var w=D*D,N=D*w,I=2*N-3*w+1,V=-2*N+3*w,W=N-2*w+D,j=N-w;return new g(l.x*I+b.x*V+h.x*W+T.x*j,l.y*I+b.y*V+h.y*W+T.y*j)},g.Lerp=function(l,h,b){return new g(l.x+(h.x-l.x)*b,l.y+(h.y-l.y)*b)},g.Dot=function(l,h){return l.x*h.x+l.y*h.y},g.Normalize=function(l){var h=l.clone();return h.normalize(),h},g.Minimize=function(l,h){return new g(l.x<h.x?l.x:h.x,l.y<h.y?l.y:h.y)},g.Maximize=function(l,h){return new g(l.x>h.x?l.x:h.x,l.y>h.y?l.y:h.y)},g.Transform=function(l,h){var b=g.Zero();return g.TransformToRef(l,h,b),b},g.TransformToRef=function(l,h,b){var T=h.m,D=l.x*T[0]+l.y*T[4]+T[12],w=l.x*T[1]+l.y*T[5]+T[13];b.x=D,b.y=w},g.PointInTriangle=function(l,h,b,T){var D=.5*(-b.y*T.x+h.y*(-b.x+T.x)+h.x*(b.y-T.y)+b.x*T.y),w=D<0?-1:1,N=(h.y*T.x-h.x*T.y+(T.y-h.y)*l.x+(h.x-T.x)*l.y)*w,I=(h.x*b.y-h.y*b.x+(h.y-b.y)*l.x+(b.x-h.x)*l.y)*w;return N>0&&I>0&&N+I<2*D*w},g.Distance=function(l,h){return Math.sqrt(g.DistanceSquared(l,h))},g.DistanceSquared=function(l,h){var b=l.x-h.x,T=l.y-h.y;return b*b+T*T},g.Center=function(l,h){var b=l.add(h);return b.scaleInPlace(.5),b},g.DistanceOfPointFromSegment=function(l,h,b){var T=g.DistanceSquared(h,b);if(T===0)return g.Distance(l,h);var D=b.subtract(h),w=Math.max(0,Math.min(1,g.Dot(l.subtract(h),D)/T)),N=h.add(D.multiplyByFloats(w,w));return g.Distance(l,N)},g}(),C=function(){function g(l,h,b){l===void 0&&(l=0),h===void 0&&(h=0),b===void 0&&(b=0),this._isDirty=!0,this._x=l,this._y=h,this._z=b}return Object.defineProperty(g.prototype,"x",{get:function(){return this._x},set:function(l){this._x=l,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"y",{get:function(){return this._y},set:function(l){this._y=l,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"z",{get:function(){return this._z},set:function(l){this._z=l,this._isDirty=!0},enumerable:!1,configurable:!0}),g.prototype.toString=function(){return"{X: "+this._x+" Y:"+this._y+" Z:"+this._z+"}"},g.prototype.getClassName=function(){return"Vector3"},g.prototype.getHashCode=function(){var l=0|this._x;return l=397*(l=397*l^(0|this._y))^(0|this._z)},g.prototype.asArray=function(){var l=[];return this.toArray(l,0),l},g.prototype.toArray=function(l,h){return h===void 0&&(h=0),l[h]=this._x,l[h+1]=this._y,l[h+2]=this._z,this},g.prototype.fromArray=function(l,h){return h===void 0&&(h=0),g.FromArrayToRef(l,h,this),this},g.prototype.toQuaternion=function(){return c.RotationYawPitchRoll(this._y,this._x,this._z)},g.prototype.addInPlace=function(l){return this.addInPlaceFromFloats(l._x,l._y,l._z)},g.prototype.addInPlaceFromFloats=function(l,h,b){return this.x+=l,this.y+=h,this.z+=b,this},g.prototype.add=function(l){return new g(this._x+l._x,this._y+l._y,this._z+l._z)},g.prototype.addToRef=function(l,h){return h.copyFromFloats(this._x+l._x,this._y+l._y,this._z+l._z)},g.prototype.subtractInPlace=function(l){return this.x-=l._x,this.y-=l._y,this.z-=l._z,this},g.prototype.subtract=function(l){return new g(this._x-l._x,this._y-l._y,this._z-l._z)},g.prototype.subtractToRef=function(l,h){return this.subtractFromFloatsToRef(l._x,l._y,l._z,h)},g.prototype.subtractFromFloats=function(l,h,b){return new g(this._x-l,this._y-h,this._z-b)},g.prototype.subtractFromFloatsToRef=function(l,h,b,T){return T.copyFromFloats(this._x-l,this._y-h,this._z-b)},g.prototype.negate=function(){return new g(-this._x,-this._y,-this._z)},g.prototype.negateInPlace=function(){return this.x*=-1,this.y*=-1,this.z*=-1,this},g.prototype.negateToRef=function(l){return l.copyFromFloats(-1*this._x,-1*this._y,-1*this._z)},g.prototype.scaleInPlace=function(l){return this.x*=l,this.y*=l,this.z*=l,this},g.prototype.scale=function(l){return new g(this._x*l,this._y*l,this._z*l)},g.prototype.scaleToRef=function(l,h){return h.copyFromFloats(this._x*l,this._y*l,this._z*l)},g.prototype.scaleAndAddToRef=function(l,h){return h.addInPlaceFromFloats(this._x*l,this._y*l,this._z*l)},g.prototype.projectOnPlane=function(l,h){var b=g.Zero();return this.projectOnPlaneToRef(l,h,b),b},g.prototype.projectOnPlaneToRef=function(l,h,b){var T=l.normal,D=l.d,w=A.Vector3[0];this.subtractToRef(h,w),w.normalize();var N=g.Dot(w,T),I=-(g.Dot(h,T)+D)/N,V=w.scaleInPlace(I);h.addToRef(V,b)},g.prototype.equals=function(l){return l&&this._x===l._x&&this._y===l._y&&this._z===l._z},g.prototype.equalsWithEpsilon=function(l,h){return h===void 0&&(h=_.a),l&&B.a.WithinEpsilon(this._x,l._x,h)&&B.a.WithinEpsilon(this._y,l._y,h)&&B.a.WithinEpsilon(this._z,l._z,h)},g.prototype.equalsToFloats=function(l,h,b){return this._x===l&&this._y===h&&this._z===b},g.prototype.multiplyInPlace=function(l){return this.x*=l._x,this.y*=l._y,this.z*=l._z,this},g.prototype.multiply=function(l){return this.multiplyByFloats(l._x,l._y,l._z)},g.prototype.multiplyToRef=function(l,h){return h.copyFromFloats(this._x*l._x,this._y
1*l._y,this._z*l._z)},g.prototype.multiplyByFloats=function(l,h,b){return new g(this._x*l,this._y*h,this._z*b)},g.prototype.divide=function(l){return new g(this._x/l._x,this._y/l._y,this._z/l._z)},g.prototype.divideToRef=function(l,h){return h.copyFromFloats(this._x/l._x,this._y/l._y,this._z/l._z)},g.prototype.divideInPlace=function(l){return this.divideToRef(l,this)},g.prototype.minimizeInPlace=function(l){return this.minimizeInPlaceFromFloats(l._x,l._y,l._z)},g.prototype.maximizeInPlace=function(l){return this.maximizeInPlaceFromFloats(l._x,l._y,l._z)},g.prototype.minimizeInPlaceFromFloats=function(l,h,b){return l<this._x&&(this.x=l),h<this._y&&(this.y=h),b<this._z&&(this.z=b),this},g.prototype.maximizeInPlaceFromFloats=function(l,h,b){return l>this._x&&(this.x=l),h>this._y&&(this.y=h),b>this._z&&(this.z=b),this},g.prototype.isNonUniformWithinEpsilon=function(l){var h=Math.abs(this._x),b=Math.abs(this._y);if(!B.a.WithinEpsilon(h,b,l))return!0;var T=Math.abs(this._z);return!B.a.WithinEpsilon(h,T,l)||!B.a.WithinEpsilon(b,T,l)},Object.defineProperty(g.prototype,"isNonUniform",{get:function(){var l=Math.abs(this._x);return l!==Math.abs(this._y)||l!==Math.abs(this._z)},enumerable:!1,configurable:!0}),g.prototype.floor=function(){return new g(Math.floor(this._x),Math.floor(this._y),Math.floor(this._z))},g.prototype.fract=function(){return new g(this._x-Math.floor(this._x),this._y-Math.floor(this._y),this._z-Math.floor(this._z))},g.prototype.length=function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z)},g.prototype.lengthSquared=function(){return this._x*this._x+this._y*this._y+this._z*this._z},g.prototype.normalize=function(){return this.normalizeFromLength(this.length())},g.prototype.reorderInPlace=function(l){var h=this;return(l=l.toLowerCase())==="xyz"||(A.Vector3[0].copyFrom(this),["x","y","z"].forEach(function(b,T){h[b]=A.Vector3[0][l[T]]})),this},g.prototype.rotateByQuaternionToRef=function(l,h){return l.toRotationMatrix(A.Matrix[0]),g.TransformCoordinatesToRef(this,A.Matrix[0],h),h},g.prototype.rotateByQuaternionAroundPointToRef=function(l,h,b){return this.subtractToRef(h,A.Vector3[0]),A.Vector3[0].rotateByQuaternionToRef(l,A.Vector3[0]),h.addToRef(A.Vector3[0],b),b},g.prototype.cross=function(l){return g.Cross(this,l)},g.prototype.normalizeFromLength=function(l){return l===0||l===1?this:this.scaleInPlace(1/l)},g.prototype.normalizeToNew=function(){var l=new g(0,0,0);return this.normalizeToRef(l),l},g.prototype.normalizeToRef=function(l){var h=this.length();return h===0||h===1?l.copyFromFloats(this._x,this._y,this._z):this.scaleToRef(1/h,l)},g.prototype.clone=function(){return new g(this._x,this._y,this._z)},g.prototype.copyFrom=function(l){return this.copyFromFloats(l._x,l._y,l._z)},g.prototype.copyFromFloats=function(l,h,b){return this.x=l,this.y=h,this.z=b,this},g.prototype.set=function(l,h,b){return this.copyFromFloats(l,h,b)},g.prototype.setAll=function(l){return this.x=this.y=this.z=l,this},g.GetClipFactor=function(l,h,b,T){var D=g.Dot(l,b)-T;return D/(D-(g.Dot(h,b)-T))},g.GetAngleBetweenVectors=function(l,h,b){var T=l.normalizeToRef(A.Vector3[1]),D=h.normalizeToRef(A.Vector3[2]),w=g.Dot(T,D),N=A.Vector3[3];return g.CrossToRef(T,D,N),g.Dot(N,b)>0?Math.acos(w):-Math.acos(w)},g.FromArray=function(l,h){return h===void 0&&(h=0),new g(l[h],l[h+1],l[h+2])},g.FromFloatArray=function(l,h){return g.FromArray(l,h)},g.FromArrayToRef=function(l,h,b){b.x=l[h],b.y=l[h+1],b.z=l[h+2]},g.FromFloatArrayToRef=function(l,h,b){return g.FromArrayToRef(l,h,b)},g.FromFloatsToRef=function(l,h,b,T){T.copyFromFloats(l,h,b)},g.Zero=function(){return new g(0,0,0)},g.One=function(){return new g(1,1,1)},g.Up=function(){return new g(0,1,0)},Object.defineProperty(g,"UpReadOnly",{get:function(){return g._UpReadOnly},enumerable:!1,configurable:!0}),Object.defineProperty(g,"ZeroReadOnly",{get:function(){return g._ZeroReadOnly},enumerable:!1,configurable:!0}),g.Down=function(){return new g(0,-1,0)},g.Forward=function(l){return l===void 0&&(l=!1),new g(0,0,l?-1:1)},g.Backward=function(l){return l===void 0&&(l=!1),new g(0,0,l?1:-1)},g.Right=function(){return new g(1,0,0)},g.Left=function(){return new g(-1,0,0)},g.TransformCoordinates=function(l,h){var b=g.Zero();return g.TransformCoordinatesToRef(l,h,b),b},g.TransformCoordinatesToRef=function(l,h,b){g.TransformCoordinatesFromFloatsToRef(l._x,l._y,l._z,h,b)},g.TransformCoordinatesFromFloatsToRef=function(l,h,b,T,D){var w=T.m,N=l*w[0]+h*w[4]+b*w[8]+w[12],I=l*w[1]+h*w[5]+b*w[9]+w[13],V=l*w[2]+h*w[6]+b*w[10]+w[14],W=1/(l*w[3]+h*w[7]+b*w[11]+w[15]);D.x=N*W,D.y=I*W,D.z=V*W},g.TransformNormal=function(l,h){var b=g.Zero();return g.TransformNormalToRef(l,h,b),b},g.TransformNormalToRef=function(l,h,b){this.TransformNormalFromFloatsToRef(l._x,l._y,l._z,h,b)},g.TransformNormalFromFloatsToRef=function(l,h,b,T,D){var w=T.m;D.x=l*w[0]+h*w[4]+b*w[8],D.y=l*w[1]+h*w[5]+b*w[9],D.z=l*w[2]+h*w[6]+b*w[10]},g.CatmullRom=function(l,h,b,T,D){var w=D*D,N=D*w;return new g(.5*(2*h._x+(-l._x+b._x)*D+(2*l._x-5*h._x+4*b._x-T._x)*w+(-l._x+3*h._x-3*b._x+T._x)*N),.5*(2*h._y+(-l._y+b._y)*D+(2*l._y-5*h._y+4*b._y-T._y)*w+(-l._y+3*h._y-3*b._y+T._y)*N),.5*(2*h._z+(-l._z+b._z)*D+(2*l._z
1-5*h._z+4*b._z-T._z)*w+(-l._z+3*h._z-3*b._z+T._z)*N))},g.Clamp=function(l,h,b){var T=new g;return g.ClampToRef(l,h,b,T),T},g.ClampToRef=function(l,h,b,T){var D=l._x;D=(D=D>b._x?b._x:D)<h._x?h._x:D;var w=l._y;w=(w=w>b._y?b._y:w)<h._y?h._y:w;var N=l._z;N=(N=N>b._z?b._z:N)<h._z?h._z:N,T.copyFromFloats(D,w,N)},g.CheckExtends=function(l,h,b){h.minimizeInPlace(l),b.maximizeInPlace(l)},g.Hermite=function(l,h,b,T,D){var w=D*D,N=D*w,I=2*N-3*w+1,V=-2*N+3*w,W=N-2*w+D,j=N-w;return new g(l._x*I+b._x*V+h._x*W+T._x*j,l._y*I+b._y*V+h._y*W+T._y*j,l._z*I+b._z*V+h._z*W+T._z*j)},g.Lerp=function(l,h,b){var T=new g(0,0,0);return g.LerpToRef(l,h,b,T),T},g.LerpToRef=function(l,h,b,T){T.x=l._x+(h._x-l._x)*b,T.y=l._y+(h._y-l._y)*b,T.z=l._z+(h._z-l._z)*b},g.Dot=function(l,h){return l._x*h._x+l._y*h._y+l._z*h._z},g.Cross=function(l,h){var b=g.Zero();return g.CrossToRef(l,h,b),b},g.CrossToRef=function(l,h,b){var T=l._y*h._z-l._z*h._y,D=l._z*h._x-l._x*h._z,w=l._x*h._y-l._y*h._x;b.copyFromFloats(T,D,w)},g.Normalize=function(l){var h=g.Zero();return g.NormalizeToRef(l,h),h},g.NormalizeToRef=function(l,h){l.normalizeToRef(h)},g.Project=function(l,h,b,T){var D=new g;return g.ProjectToRef(l,h,b,T,D),D},g.ProjectToRef=function(l,h,b,T,D){var w=T.width,N=T.height,I=T.x,V=T.y,W=A.Matrix[1];E.FromValuesToRef(w/2,0,0,0,0,-N/2,0,0,0,0,.5,0,I+w/2,N/2+V,.5,1,W);var j=A.Matrix[0];return h.multiplyToRef(b,j),j.multiplyToRef(W,j),g.TransformCoordinatesToRef(l,j,D),D},g._UnprojectFromInvertedMatrixToRef=function(l,h,b){g.TransformCoordinatesToRef(l,h,b);var T=h.m,D=l._x*T[3]+l._y*T[7]+l._z*T[11]+T[15];B.a.WithinEpsilon(D,1)&&b.scaleInPlace(1/D)},g.UnprojectFromTransform=function(l,h,b,T,D){var w=A.Matrix[0];T.multiplyToRef(D,w),w.invert(),l.x=l._x/h*2-1,l.y=-(l._y/b*2-1);var N=new g;return g._UnprojectFromInvertedMatrixToRef(l,w,N),N},g.Unproject=function(l,h,b,T,D,w){var N=g.Zero();return g.UnprojectToRef(l,h,b,T,D,w,N),N},g.UnprojectToRef=function(l,h,b,T,D,w,N){g.UnprojectFloatsToRef(l._x,l._y,l._z,h,b,T,D,w,N)},g.UnprojectFloatsToRef=function(l,h,b,T,D,w,N,I,V){var W=A.Matrix[0];w.multiplyToRef(N,W),W.multiplyToRef(I,W),W.invert();var j=A.Vector3[0];j.x=l/T*2-1,j.y=-(h/D*2-1),j.z=2*b-1,g._UnprojectFromInvertedMatrixToRef(j,W,V)},g.Minimize=function(l,h){var b=l.clone();return b.minimizeInPlace(h),b},g.Maximize=function(l,h){var b=l.clone();return b.maximizeInPlace(h),b},g.Distance=function(l,h){return Math.sqrt(g.DistanceSquared(l,h))},g.DistanceSquared=function(l,h){var b=l._x-h._x,T=l._y-h._y,D=l._z-h._z;return b*b+T*T+D*D},g.Center=function(l,h){var b=l.add(h);return b.scaleInPlace(.5),b},g.RotationFromAxis=function(l,h,b){var T=g.Zero();return g.RotationFromAxisToRef(l,h,b,T),T},g.RotationFromAxisToRef=function(l,h,b,T){var D=A.Quaternion[0];c.RotationQuaternionFromAxisToRef(l,h,b,D),D.toEulerAnglesToRef(T)},g._UpReadOnly=g.Up(),g._ZeroReadOnly=g.Zero(),g}(),m=function(){function g(l,h,b,T){this.x=l,this.y=h,this.z=b,this.w=T}return g.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+" W:"+this.w+"}"},g.prototype.getClassName=function(){return"Vector4"},g.prototype.getHashCode=function(){var l=0|this.x;return l=397*(l=397*(l=397*l^(0|this.y))^(0|this.z))^(0|this.w)},g.prototype.asArray=function(){var l=new Array;return this.toArray(l,0),l},g.prototype.toArray=function(l,h){return h===void 0&&(h=0),l[h]=this.x,l[h+1]=this.y,l[h+2]=this.z,l[h+3]=this.w,this},g.prototype.fromArray=function(l,h){return h===void 0&&(h=0),g.FromArrayToRef(l,h,this),this},g.prototype.addInPlace=function(l){return this.x+=l.x,this.y+=l.y,this.z+=l.z,this.w+=l.w,this},g.prototype.add=function(l){return new g(this.x+l.x,this.y+l.y,this.z+l.z,this.w+l.w)},g.prototype.addToRef=function(l,h){return h.x=this.x+l.x,h.y=this.y+l.y,h.z=this.z+l.z,h.w=this.w+l.w,this},g.prototype.subtractInPlace=function(l){return this.x-=l.x,this.y-=l.y,this.z-=l.z,this.w-=l.w,this},g.prototype.subtract=function(l){return new g(this.x-l.x,this.y-l.y,this.z-l.z,this.w-l.w)},g.prototype.subtractToRef=function(l,h){return h.x=this.x-l.x,h.y=this.y-l.y,h.z=this.z-l.z,h.w=this.w-l.w,this},g.prototype.subtractFromFloats=function(l,h,b,T){return new g(this.x-l,this.y-h,this.z-b,this.w-T)},g.prototype.subtractFromFloatsToRef=function(l,h,b,T,D){return D.x=this.x-l,D.y=this.y-h,D.z=this.z-b,D.w=this.w-T,this},g.prototype.negate=function(){return new g(-this.x,-this.y,-this.z,-this.w)},g.prototype.negateInPlace=function(){return this.x*=-1,this.y*=-1,this.z*=-1,this.w*=-1,this},g.prototype.negateToRef=function(l){return l.copyFromFloats(-1*this.x,-1*this.y,-1*this.z,-1*this.w)},g.prototype.scaleInPlace=function(l){return this.x*=l,this.y*=l,this.z*=l,this.w*=l,this},g.prototype.scale=function(l){return new g(this.x*l,this.y*l,this.z*l,this.w*l)},g.prototype.scaleToRef=function(l,h){return h.x=this.x*l,h.y=this.y*l,h.z=this.z*l,h.w=this.w*l,this},g.prototype.scaleAndAddToRef=function(l,h){return h.x+=this.x*l,h.y+=this.y*l,h.z+=this.z*l,h.w+=this.w*l,this},g.prototype.equals=function(l){return l&&this.x===l.x&&this.y===l.y&&this.z===l.z&&this.w===l.w},g.prototype.equalsWithEpsilon=function(l,h){return h===void 0&&(h=_.a),l&&B.a.WithinEpsilon(this.x,l.x,h)&&B.a.WithinEpsilon(this.y,l.y,h)&&B.a.WithinEpsilon(this.z,l.z,h)&&B.a.WithinEpsilon(this.w,l.w,h)},g.prototype.equalsToFloats=function(l,h,b,T){return this.x===l&&this.y===h&&this.z===b&&this.w===T},g.prototype.multiplyInPlace=function(l){return this.x*=l.x,this.y*=l.y,this.z*=l.z,this.w*=l.w,this},g.prototype.multiply=function(l){return new g(this.x*l.x,this.y*l.y,this.z*l.z,this.w*l.w)},g.prototype.multiplyToRef=function(l,h){return h.x=this.x*l.x,h.y=this.y*l.y,h.z=this.z*l.z,h.w=this.w*l.w,this},g.prototype.multiplyByFloats=function(l,h,b,T){return new g(this.x*l,this.y*h,this.z*b,this.w*T)},g.prototype.divide=function(l){return new g(this.x/l.x,this.y/l.y,this.z/l.z,this.w/l.w)},g.prototype.divideToRef=function(l,h){return h.x=this.x/l.x,h.y=this.y/l.y,h.z=this.z/l.z,h.w=this.w/l.w,this},g.prototype.divideInPlace=function(l){return this.divideToRef(l,this)},g.prototype.minimizeInPlace=function(l){return l.x<this.x&&(this.x=l.x),l.y<this.y&&(this.y=l.y),l.z<this.z&&(this.z=l.z),l.w<this.w&&(this.w=l.w
1),this},g.prototype.maximizeInPlace=function(l){return l.x>this.x&&(this.x=l.x),l.y>this.y&&(this.y=l.y),l.z>this.z&&(this.z=l.z),l.w>this.w&&(this.w=l.w),this},g.prototype.floor=function(){return new g(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z),Math.floor(this.w))},g.prototype.fract=function(){return new g(this.x-Math.floor(this.x),this.y-Math.floor(this.y),this.z-Math.floor(this.z),this.w-Math.floor(this.w))},g.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},g.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},g.prototype.normalize=function(){var l=this.length();return l===0?this:this.scaleInPlace(1/l)},g.prototype.toVector3=function(){return new C(this.x,this.y,this.z)},g.prototype.clone=function(){return new g(this.x,this.y,this.z,this.w)},g.prototype.copyFrom=function(l){return this.x=l.x,this.y=l.y,this.z=l.z,this.w=l.w,this},g.prototype.copyFromFloats=function(l,h,b,T){return this.x=l,this.y=h,this.z=b,this.w=T,this},g.prototype.set=function(l,h,b,T){return this.copyFromFloats(l,h,b,T)},g.prototype.setAll=function(l){return this.x=this.y=this.z=this.w=l,this},g.FromArray=function(l,h){return h||(h=0),new g(l[h],l[h+1],l[h+2],l[h+3])},g.FromArrayToRef=function(l,h,b){b.x=l[h],b.y=l[h+1],b.z=l[h+2],b.w=l[h+3]},g.FromFloatArrayToRef=function(l,h,b){g.FromArrayToRef(l,h,b)},g.FromFloatsToRef=function(l,h,b,T,D){D.x=l,D.y=h,D.z=b,D.w=T},g.Zero=function(){return new g(0,0,0,0)},g.One=function(){return new g(1,1,1,1)},g.Normalize=function(l){var h=g.Zero();return g.NormalizeToRef(l,h),h},g.NormalizeToRef=function(l,h){h.copyFrom(l),h.normalize()},g.Minimize=function(l,h){var b=l.clone();return b.minimizeInPlace(h),b},g.Maximize=function(l,h){var b=l.clone();return b.maximizeInPlace(h),b},g.Distance=function(l,h){return Math.sqrt(g.DistanceSquared(l,h))},g.DistanceSquared=function(l,h){var b=l.x-h.x,T=l.y-h.y,D=l.z-h.z,w=l.w-h.w;return b*b+T*T+D*D+w*w},g.Center=function(l,h){var b=l.add(h);return b.scaleInPlace(.5),b},g.TransformNormal=function(l,h){var b=g.Zero();return g.TransformNormalToRef(l,h,b),b},g.TransformNormalToRef=function(l,h,b){var T=h.m,D=l.x*T[0]+l.y*T[4]+l.z*T[8],w=l.x*T[1]+l.y*T[5]+l.z*T[9],N=l.x*T[2]+l.y*T[6]+l.z*T[10];b.x=D,b.y=w,b.z=N,b.w=l.w},g.TransformNormalFromFloatsToRef=function(l,h,b,T,D,w){var N=D.m;w.x=l*N[0]+h*N[4]+b*N[8],w.y=l*N[1]+h*N[5]+b*N[9],w.z=l*N[2]+h*N[6]+b*N[10],w.w=T},g.FromVector3=function(l,h){return h===void 0&&(h=0),new g(l._x,l._y,l._z,h)},g}(),c=function(){function g(l,h,b,T){l===void 0&&(l=0),h===void 0&&(h=0),b===void 0&&(b=0),T===void 0&&(T=1),this._isDirty=!0,this._x=l,this._y=h,this._z=b,this._w=T}return Object.defineProperty(g.prototype,"x",{get:function(){return this._x},set:function(l){this._x=l,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"y",{get:function(){return this._y},set:function(l){this._y=l,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"z",{get:function(){return this._z},set:function(l){this._z=l,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"w",{get:function(){return this._w},set:function(l){this._w=l,this._isDirty=!0},enumerable:!1,configurable:!0}),g.prototype.toString=function(){return"{X: "+this._x+" Y:"+this._y+" Z:"+this._z+" W:"+this._w+"}"},g.prototype.getClassName=function(){return"Quaternion"},g.prototype.getHashCode=function(){var l=0|this._x;return l=397*(l=397*(l=397*l^(0|this._y))^(0|this._z))^(0|this._w)},g.prototype.asArray=function(){return[this._x,this._y,this._z,this._w]},g.prototype.equals=function(l){return l&&this._x===l._x&&this._y===l._y&&this._z===l._z&&this._w===l._w},g.prototype.equalsWithEpsilon=function(l,h){return h===void 0&&(h=_.a),l&&B.a.WithinEpsilon(this._x,l._x,h)&&B.a.WithinEpsilon(this._y,l._y,h)&&B.a.WithinEpsilon(this._z,l._z,h)&&B.a.WithinEpsilon(this._w,l._w,h)},g.prototype.clone=function(){return new g(this._x,this._y,this._z,this._w)},g.prototype.copyFrom=function(l){return this.x=l._x,this.y=l._y,this.z=l._z,this.w=l._w,this},g.prototype.copyFromFloats=function(l,h,b,T){return this.x=l,this.y=h,this.z=b,this.w=T,this},g.prototype.set=function(l,h,b,T){return this.copyFromFloats(l,h,b,T)},g.prototype.add=function(l){return new g(this._x+l._x,this._y+l._y,this._z+l._z,this._w+l._w)},g.prototype.addInPlace=function(l){return this._x+=l._x,this._y+=l._y,this._z+=l._z,this._w+=l._w,this},g.prototype.subtract=function(l){return new g(this._x-l._x,this._y-l._y,this._z-l._z,this._w-l._w)},g.prototype.scale=function(l){return new g(this._x*l,this._y*l,this._z*l,this._w*l)},g.prototype.scaleToRef=function(l,h){return h.x=this._x*l,h.y=this._y*l,h.z=this._z*l,h.w=this._w*l,this},g.prototype.scaleInPlace=function(l){return this.x*=l,this.y*=l,this.z*=l,this.w*=l,this},g.prototype.scaleAndAddToRef=function(l,h){return h.x+=this._x*l,h.y+=this._y*l,h.z+=this._z*l,h.w+=this._w*l,this},g.prototype.multiply=function(l){var h=new g(0,0,0,1);return this.multiplyToRef(l,h),h},g.prototype.multiplyToRef=function(l,h){var b=this._x*l._w+this._y*l._z-this._z*l._y+this._w*l._x,T=-this._x*l._z+this._y*l._w+this._z*l._x+this._w*l._y,D=this._x*l._y-this._y*l._x+this._z*l._w+this._w*l._z,w=-this._x*l._x-this._y*l._y-this._z*l._z+this._w*l._w;return h.copyFromFloats(b,T,D,w),this},g.prototype.multiplyInPlace=function(l){return this.multiplyToRef(l,this),this},g.prototype.conjugateToRef=function(l){return l.copyFromFloats(-this._x,-this._y,-this._z,this._w),this},g.prototype.conjugateInPlace=function(){return this.x*=-1,this.y*=-1,this.z*=-1,this},g.prototype.conjugate=function(){return new g(-this._x,-this._y,-this._z,this._w)},g.prototype.length=function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},g.prototype.normalize=function(){var l=this.length();if(l===0)return this;var h=1/l;return this.x*=h,this.y*=h,this.z*=h,this.w*=h,this},g.prototype.toEulerAngles=function(l){var h=C.Zero();return this.toEulerAnglesToRef(h),h},g.prototype.toEulerAnglesToRef=function(l){var h=this._z,b=this._x,T=this._y,D=this._w,w=D*D,N=h*h,I=b*b,V=T*T,W=T*h-b*D;return W<-.4999999?(l.y=2*Math.atan2(T,D),l.x=Math.PI/2,l.z=0):W>.4999999?(l.y=2*Math.atan2(T,D),l.x=-Math.PI/2,l.z=0):(l.z=Math.atan2(2*(b*T+h*D),-N-I+V+w),l.x=Math.asin(-2*(h*T-b*D)),l.y=Math.atan2(2*(h*b+T*D),N-I-V+w)),this},g.prototype.toRotationMatrix=function(l){return E.FromQuaternionToRef(this,l),this},g.prototype.fromRotationMatrix=function(l){return g.FromRotationMatrixToRef(l,this),this},g.FromRotationMatrix=function(l){var h=new g;return g.FromRotationMatrixToRef(l,h),h},g.FromRotationMatrixToRef=function(l,h){var b,T=l.m,D=T[0],w=T[4],N=T[8],I=T[1],V=T[5],W=T[9],j=T[2],ne=T[6],te=T[10],de=D+V+te;de>0?(b=.5/Math.sqrt(de+1),h.w=.25/b,h.x=(ne-W)*b,h.y=(N-j)*b,h.z=(I-w)*b):D>V&&D>te?(b=2*Math.sqrt(1+D-V-te),h.w=(ne-W)/b,h.x=.25*b,h.y=(w+I)/b,h.z=(N+j)/b):V>te?(b=2*Math.sqrt(1+V-D-te),h.w=(N-j)/b,h.x=(w+I)/b,h.y=.25*b,h.z=(W+ne)/b):(b=2*Math.sqrt(1+te-D-V),h.w=(I-w)/b,h.x=(N+j)/b,h.y=(W+ne)/b,h.z=.25*b)},g.Dot=function(l,h){return l._x*h._x+l._y*h._y+l._z*h._z+l._w*h._w},g.AreClose=function(l,h){return g.Dot(l,h)>=0},g.Zero=function(){return new g(0,0,0,0)},g.Inverse=function(l){return new g(-l._x,-l._y,-l._z,l._w)},g.InverseToRef=function(l,h){return h.set(-l._x,-l._y,-l._z,l._w),h},g.Identity=function(){return new g(0,0,0,1)},g.IsIdentity=function(l){return l&&l._x===0&&l._y===0&&l._z===0&&l._w===1},g.RotationAxis=function(l,h){return g.RotationAxisToRef(l,h,new g)},g.RotationAxisToRef=function(l,h,b){var T=Math.sin(h/2);return l.normalize(),b.w=Math.cos(h/2),b.x=l._x*T,b.y=l._y*T,b.z=l._z*T,b},g.FromArray=function(l,h){return h||(h=0),new g(l[h],l[h+1],l[h+2],l[h+3])},g.FromArrayToRef=function(l,h,b){b.x=l[h],b.y=l[h+1],b.z=l[h+2],b.w=l[h+3]},g.FromEulerAngles=function(l,h,b){var T=new g;return g.RotationYawPitchRollToRef(h,l,b,T),T},g.FromEulerAnglesToRef=function(l,h,b,T){return g.RotationYawPitchRollToRef(h,l,b,T),T},g.FromEulerVector=function(l){var h=new g;return g.RotationYawPitchRollToRef(l._y,l._x,l._z,h),h},g.FromEulerVectorToRef=function(l,h){return g.RotationYawPitchRollToRef(l._y,l._x,l._z,h),h},g.RotationYawPitchRoll=function(l,h,b){var T=new g;return g.RotationYawPitchRollToRef(l,h,b,T),T},g.RotationYawPitchRollToRef=function(l,h,b,T){var D=.5*b,w=.5*h,N=.5*l,I=Math.sin(D),V=Math.cos(D),W=Math.sin(w),j=Math.cos(w),ne=Math.sin(N),te=Math.cos(N);T.x=te*W*V+ne*j*I,T.y=ne*j*V-te*W*I,T.z=te*j*I-ne*W*V,T.w=te*j*V+ne*W*I},g.RotationAlphaBetaGamma=function(l,h,b){var T=new g;return g.RotationAlphaBetaGammaToRef(l,h,b,T),T},g.RotationAlphaBetaGammaToRef=function(l,h,b,T){var D=.5*(b+l),w=.5*(b-l),N=.5*h;
1T.x=Math.cos(w)*Math.sin(N),T.y=Math.sin(w)*Math.sin(N),T.z=Math.sin(D)*Math.cos(N),T.w=Math.cos(D)*Math.cos(N)},g.RotationQuaternionFromAxis=function(l,h,b){var T=new g(0,0,0,0);return g.RotationQuaternionFromAxisToRef(l,h,b,T),T},g.RotationQuaternionFromAxisToRef=function(l,h,b,T){var D=A.Matrix[0];E.FromXYZAxesToRef(l.normalize(),h.normalize(),b.normalize(),D),g.FromRotationMatrixToRef(D,T)},g.Slerp=function(l,h,b){var T=g.Identity();return g.SlerpToRef(l,h,b,T),T},g.SlerpToRef=function(l,h,b,T){var D,w,N=l._x*h._x+l._y*h._y+l._z*h._z+l._w*h._w,I=!1;if(N<0&&(I=!0,N=-N),N>.999999)w=1-b,D=I?-b:b;else{var V=Math.acos(N),W=1/Math.sin(V);w=Math.sin((1-b)*V)*W,D=I?-Math.sin(b*V)*W:Math.sin(b*V)*W}T.x=w*l._x+D*h._x,T.y=w*l._y+D*h._y,T.z=w*l._z+D*h._z,T.w=w*l._w+D*h._w},g.Hermite=function(l,h,b,T,D){var w=D*D,N=D*w,I=2*N-3*w+1,V=-2*N+3*w,W=N-2*w+D,j=N-w;return new g(l._x*I+b._x*V+h._x*W+T._x*j,l._y*I+b._y*V+h._y*W+T._y*j,l._z*I+b._z*V+h._z*W+T._z*j,l._w*I+b._w*V+h._w*W+T._w*j)},g}(),E=function(){function g(){this._isIdentity=!1,this._isIdentityDirty=!0,this._isIdentity3x2=!0,this._isIdentity3x2Dirty=!0,this.updateFlag=-1,M.a.MatrixTrackPrecisionChange&&M.a.MatrixTrackedMatrices.push(this),this._m=new M.a.MatrixCurrentType(16),this._updateIdentityStatus(!1)}return Object.defineProperty(g,"Use64Bits",{get:function(){return M.a.MatrixUse64Bits},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"m",{get:function(){return this._m},enumerable:!1,configurable:!0}),g.prototype._markAsUpdated=function(){this.updateFlag=g._updateFlagSeed++,this._isIdentity=!1,this._isIdentity3x2=!1,this._isIdentityDirty=!0,this._isIdentity3x2Dirty=!0},g.prototype._updateIdentityStatus=function(l,h,b,T){h===void 0&&(h=!1),b===void 0&&(b=!1),T===void 0&&(T=!0),this.updateFlag=g._updateFlagSeed++,this._isIdentity=l,this._isIdentity3x2=l||b,this._isIdentityDirty=!this._isIdentity&&h,this._isIdentity3x2Dirty=!this._isIdentity3x2&&T},g.prototype.isIdentity=function(){if(this._isIdentityDirty){this._isIdentityDirty=!1;var l=this._m;this._isIdentity=l[0]===1&&l[1]===0&&l[2]===0&&l[3]===0&&l[4]===0&&l[5]===1&&l[6]===0&&l[7]===0&&l[8]===0&&l[9]===0&&l[10]===1&&l[11]===0&&l[12]===0&&l[13]===0&&l[14]===0&&l[15]===1}return this._isIdentity},g.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},g.prototype.determinant=function(){if(this._isIdentity===!0)return 1;var l=this._m,h=l[0],b=l[1],T=l[2],D=l[3],w=l[4],N=l[5],I=l[6],V=l[7],W=l[8],j=l[9],ne=l[10],te=l[11],de=l[12],pe=l[13],ae=l[14],ee=l[15],K=ne*ee-ae*te,$=j*ee-pe*te,L=j*ae-pe*ne,G=W*ee-de*te,Q=W*ae-ne*de,oe=W*pe-de*j;return h*+(N*K-I*$+V*L)+b*-(w*K-I*G+V*Q)+T*+(w*$-N*G+V*oe)+D*-(w*L-N*Q+I*oe)},g.prototype.toArray=function(){return this._m},g.prototype.asArray=function(){return this._m},g.prototype.invert=function(){return this.invertToRef(this),this},g.prototype.reset=function(){return g.FromValuesToRef(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,this),this._updateIdentityStatus(!1),this},g.prototype.add=function(l){var h=new g;return this.addToRef(l,h),h},g.prototype.addToRef=function(l,h){for(var b=this._m,T=h._m,D=l.m,w=0;w<16;w++)T[w]=b[w]+D[w];return h._markAsUpdated(),this},g.prototype.addToSelf=function(l){for(var h=this._m,b=l.m,T=0;T<16;T++)h[T]+=b[T];return this._markAsUpdated(),this},g.prototype.invertToRef=function(l){if(this._isIdentity===!0)return g.IdentityToRef(l),this;var h=this._m,b=h[0],T=h[1],D=h[2],w=h[3],N=h[4],I=h[5],V=h[6],W=h[7],j=h[8],ne=h[9],te=h[10],de=h[11],pe=h[12],ae=h[13],ee=h[14],K=h[15],$=te*K-ee*de,L=ne*K-ae*de,G=ne*ee-ae*te,Q=j*K-pe*de,oe=j*ee-te*pe,re=j*ae-pe*ne,Y=+(I*$-V*L+W*G),k=-(N*$-V*Q+W*oe),H=+(N*L-I*Q+W*re),Z=-(N*G-I*oe+V*re),X=b*Y+T*k+D*H+w*Z;if(X===0)return l.copyFrom(this),this;var q=1/X,he=V*K-ee*W,ge=I*K-ae*W,me=I*ee-ae*V,_e=N*K-pe*W,be=N*ee-pe*V,Ce=N*ae-pe*I,ye=V*de-te*W,Be=I*de-ne*W,Ge=I*te-ne*V,Xe=N*de-j*W,He=N*te-j*V,We=N*ne-j*I,Ze=-(T*$-D*L+w*G),ze=+(b*$-D*Q+w*oe),it=-(b*L-T*Q+w*re),et=+(b*G-T*oe+D*re),lt=+(T*he-D*ge+w*me),ct=-(b*he
1-D*_e+w*be),mt=+(b*ge-T*_e+w*Ce),St=-(b*me-T*be+D*Ce),wt=-(T*ye-D*Be+w*Ge),It=+(b*ye-D*Xe+w*He),Pt=-(b*Be-T*Xe+w*We),Ot=+(b*Ge-T*He+D*We);return g.FromValuesToRef(Y*q,Ze*q,lt*q,wt*q,k*q,ze*q,ct*q,It*q,H*q,it*q,mt*q,Pt*q,Z*q,et*q,St*q,Ot*q,l),this},g.prototype.addAtIndex=function(l,h){return this._m[l]+=h,this._markAsUpdated(),this},g.prototype.multiplyAtIndex=function(l,h){return this._m[l]*=h,this._markAsUpdated(),this},g.prototype.setTranslationFromFloats=function(l,h,b){return this._m[12]=l,this._m[13]=h,this._m[14]=b,this._markAsUpdated(),this},g.prototype.addTranslationFromFloats=function(l,h,b){return this._m[12]+=l,this._m[13]+=h,this._m[14]+=b,this._markAsUpdated(),this},g.prototype.setTranslation=function(l){return this.setTranslationFromFloats(l._x,l._y,l._z)},g.prototype.getTranslation=function(){return new C(this._m[12],this._m[13],this._m[14])},g.prototype.getTranslationToRef=function(l){return l.x=this._m[12],l.y=this._m[13],l.z=this._m[14],this},g.prototype.removeRotationAndScaling=function(){var l=this.m;return g.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,l[12],l[13],l[14],l[15],this),this._updateIdentityStatus(l[12]===0&&l[13]===0&&l[14]===0&&l[15]===1),this},g.prototype.multiply=function(l){var h=new g;return this.multiplyToRef(l,h),h},g.prototype.copyFrom=function(l){l.copyToArray(this._m);var h=l;return this._updateIdentityStatus(h._isIdentity,h._isIdentityDirty,h._isIdentity3x2,h._isIdentity3x2Dirty),this},g.prototype.copyToArray=function(l,h){h===void 0&&(h=0);var b=this._m;return l[h]=b[0],l[h+1]=b[1],l[h+2]=b[2],l[h+3]=b[3],l[h+4]=b[4],l[h+5]=b[5],l[h+6]=b[6],l[h+7]=b[7],l[h+8]=b[8],l[h+9]=b[9],l[h+10]=b[10],l[h+11]=b[11],l[h+12]=b[12],l[h+13]=b[13],l[h+14]=b[14],l[h+15]=b[15],this},g.prototype.multiplyToRef=function(l,h){return this._isIdentity?(h.copyFrom(l),this):l._isIdentity?(h.copyFrom(this),this):(this.multiplyToArray(l,h._m,0),h._markAsUpdated(),this)},g.prototype.multiplyToArray=function(l,h,b){var T=this._m,D=l.m,w=T[0],N=T[1],I=T[2],V=T[3],W=T[4],j=T[5],ne=T[6],te=T[7],de=T[8],pe=T[9],ae=T[10],ee=T[11],K=T[12],$=T[13],L=T[14],G=T[15],Q=D[0],oe=D[1],re=D[2],Y=D[3],k=D[4],H=D[5],Z=D[6],X=D[7],q=D[8],he=D[9],ge=D[10],me=D[11],_e=D[12],be=D[13],Ce=D[14],ye=D[15];return h[b]=w*Q+N*k+I*q+V*_e,h[b+1]=w*oe+N*H+I*he+V*be,h[b+2]=w*re+N*Z+I*ge+V*Ce,h[b+3]=w*Y+N*X+I*me+V*ye,h[b+4]=W*Q+j*k+ne*q+te*_e,h[b+5]=W*oe+j*H+ne*he+te*be,h[b+6]=W*re+j*Z+ne*ge+te*Ce,h[b+7]=W*Y+j*X+ne*me+te*ye,h[b+8]=de*Q+pe*k+ae*q+ee*_e,h[b+9]=de*oe+pe*H+ae*he+ee*be,h[b+10]=de*re+pe*Z+ae*ge+ee*Ce,h[b+11]=de*Y+pe*X+ae*me+ee*ye,h[b+12]=K*Q+$*k+L*q+G*_e,h[b+13]=K*oe+$*H+L*he+G*be,h[b+14]=K*re+$*Z+L*ge+G*Ce,h[b+15]=K*Y+$*X+L*me+G*ye,this},g.prototype.equals=function(l){var h=l;if(!h)return!1;if((this._isIdentity||h._isIdentity)&&!this._isIdentityDirty&&!h._isIdentityDirty)return this._isIdentity&&h._isIdentity;var b=this.m,T=h.m;return b[0]===T[0]&&b[1]===T[1]&&b[2]===T[2]&&b[3]===T[3]&&b[4]===T[4]&&b[5]===T[5]&&b[6]===T[6]&&b[7]===T[7]&&b[8]===T[8]&&b[9]===T[9]&&b[10]===T[10]&&b[11]===T[11]&&b[12]===T[12]&&b[13]===T[13]&&b[14]===T[14]&&b[15]===T[15]},g.prototype.clone=function(){var l=new g;return l.copyFrom(this),l},g.prototype.getClassName=function(){return"Matrix"},g.prototype.getHashCode=function(){for(var l=0|this._m[0],h=1;h<16;h++)l=397*l^(0|this._m[h]);return l},g.prototype.decompose=function(l,h,b){if(this._isIdentity)return b&&b.setAll(0),l&&l.setAll(1),h&&h.copyFromFloats(0,0,0,1),!0;var T=this._m;if(b&&b.copyFromFloats(T[12],T[13],T[14]),(l=l||A.Vector3[0]).x=Math.sqrt(T[0]*T[0]+T[1]*T[1]+T[2]*T[2]),l.y=Math.sqrt(T[4]*T[4]+T[5]*T[5]+T[6]*T[6]),l.z=Math.sqrt(T[8]*T[8]+T[9]*T[9]+T[10]*T[10]),this.determinant()<=0&&(l.y*=-1),l._x===0||l._y===0||l._z===0)return h&&h.copyFromFloats(0,0,0,1),!1;if(h){var D=1/l._x,w=1/l._y,N=1/l._z;g.FromValuesToRef(T[0]*D,T[1]*D,T[2]*D,0,T[4]*w,T[5]*w,T[6]*w,0,T[8]*N,T[9]*N,T[10]*N,0,0,0,0,1,A.Matrix[0]),c.FromRotationMatrixToRef(A.Matrix[0],h)}return!0},g.prototype.getRow=function(l){if(l<0||l>3)return null;var h=4*l;return new m(this._m[h+0],this._m[h+1],this._m[h+2],this._m[h+3])},g.prototype.setRow=function(l,h){return this.setRowFromFloats(l,h.x,h.y,h.z,h.w)},g.prototype.transpose=function(){return g.Transpose(this)},g.prototype.transposeToRef=function(l){return g.TransposeToRef(this,l),this},g.prototype.setRowFromFloats=function(l,h,b,T,D){if(l<0||l>3)return this;var w=4*l;return this._m[w+0]=h,this._m[w+1]=b,this._m[w+2]=T,this._m[w+3]=D,this._markAsUpdated(),this},g.prototype.scale=function(l){var h=new g;return this.scaleToRef(l,h),h},g.prototype.scaleToRef=function(l,h){for(var b=0;b<16;b++)h._m[b]=this._m[b]*l;return h._markAsUpdated(),this},g.prototype.scaleAndAddToRef=function(l,h){for(var b=0;b<16;b++)h._m[b]+=this._m[b]*l;return h._markAsUpdated(),this},g.prototype.toNormalMatrix=function(l){var h=A.Matrix[0];this.invertToRef(h),h.transposeToRef(l);var b=l._m;g.FromValuesToRef(b[0],b[1],b[2],0,b[4],b[5],b[6],0,b[8],b[9],b[10],0,0,0,0,1,l)},g.prototype.getRotationMatrix=function(){var l=new g;return this.getRotationMatrixToRef(l),l},g.prototype.getRotationMatrixToRef=function(l){var h=A.Vector3[0];if(!this.decompose(h))return g.IdentityToRef(l),this;var b=this._m,T=1/h._x,D=1/h._y,w=1/h._z;return g.FromValuesToRef(b[0]*T,b[1]*T,b[2]*T,0,b[4]*D,b[5]*D,b[6]*D,0,b[8]*w,b[9]*w,b[10]*w,0,0,0,0,1,l),this},g.prototype.toggleModelMatrixHandInPlace=function(){var l=this._m;l[2]*=-1,l[6]*=-1,l[8]*=-1,l[9]*=-1,l[14]*=-1,this._markAsUpdated()},g.prototype.toggleProjectionMatrixHandInPlace=function(){var l=this._m;l[8]*=-1,l[9]*=-1,l[10]*=-1,l[11]*=-1,this._markAsUpdated()},g.FromArray=function(l,h){h===void 0&&(h=0);var b=new g;return g.FromArrayToRef(l,h,b),b},g.FromArrayToRef=function(l,h,b){for(var T=0;T<16;T++)b._m[T]=l[T+h];b._markAsUpdated()},g.FromFloat32ArrayToRefScaled=function(l,h,b,T){for(var D=0;D<16;D++)T._m[D]=l[D+h]*b;T._markAsUpdated()},Object.defineProperty(g,"IdentityReadOnly",{get:function(){return g._identityReadOnly}
1,enumerable:!1,configurable:!0}),g.FromValuesToRef=function(l,h,b,T,D,w,N,I,V,W,j,ne,te,de,pe,ae,ee){var K=ee._m;K[0]=l,K[1]=h,K[2]=b,K[3]=T,K[4]=D,K[5]=w,K[6]=N,K[7]=I,K[8]=V,K[9]=W,K[10]=j,K[11]=ne,K[12]=te,K[13]=de,K[14]=pe,K[15]=ae,ee._markAsUpdated()},g.FromValues=function(l,h,b,T,D,w,N,I,V,W,j,ne,te,de,pe,ae){var ee=new g,K=ee._m;return K[0]=l,K[1]=h,K[2]=b,K[3]=T,K[4]=D,K[5]=w,K[6]=N,K[7]=I,K[8]=V,K[9]=W,K[10]=j,K[11]=ne,K[12]=te,K[13]=de,K[14]=pe,K[15]=ae,ee._markAsUpdated(),ee},g.Compose=function(l,h,b){var T=new g;return g.ComposeToRef(l,h,b,T),T},g.ComposeToRef=function(l,h,b,T){var D=T._m,w=h._x,N=h._y,I=h._z,V=h._w,W=w+w,j=N+N,ne=I+I,te=w*W,de=w*j,pe=w*ne,ae=N*j,ee=N*ne,K=I*ne,$=V*W,L=V*j,G=V*ne,Q=l._x,oe=l._y,re=l._z;D[0]=(1-(ae+K))*Q,D[1]=(de+G)*Q,D[2]=(pe-L)*Q,D[3]=0,D[4]=(de-G)*oe,D[5]=(1-(te+K))*oe,D[6]=(ee+$)*oe,D[7]=0,D[8]=(pe+L)*re,D[9]=(ee-$)*re,D[10]=(1-(te+ae))*re,D[11]=0,D[12]=b._x,D[13]=b._y,D[14]=b._z,D[15]=1,T._markAsUpdated()},g.Identity=function(){var l=g.FromValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return l._updateIdentityStatus(!0),l},g.IdentityToRef=function(l){g.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,l),l._updateIdentityStatus(!0)},g.Zero=function(){var l=g.FromValues(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);return l._updateIdentityStatus(!1),l},g.RotationX=function(l){var h=new g;return g.RotationXToRef(l,h),h},g.Invert=function(l){var h=new g;return l.invertToRef(h),h},g.RotationXToRef=function(l,h){var b=Math.sin(l),T=Math.cos(l);g.FromValuesToRef(1,0,0,0,0,T,b,0,0,-b,T,0,0,0,0,1,h),h._updateIdentityStatus(T===1&&b===0)},g.RotationY=function(l){var h=new g;return g.RotationYToRef(l,h),h},g.RotationYToRef=function(l,h){var b=Math.sin(l),T=Math.cos(l);g.FromValuesToRef(T,0,-b,0,0,1,0,0,b,0,T,0,0,0,0,1,h),h._updateIdentityStatus(T===1&&b===0)},g.RotationZ=function(l){var h=new g;return g.RotationZToRef(l,h),h},g.RotationZToRef=function(l,h){var b=Math.sin(l),T=Math.cos(l);g.FromValuesToRef(T,b,0,0,-b,T,0,0,0,0,1,0,0,0,0,1,h),h._updateIdentityStatus(T===1&&b===0)},g.RotationAxis=function(l,h){var b=new g;return g.RotationAxisToRef(l,h,b),b},g.RotationAxisToRef=function(l,h,b){var T=Math.sin(-h),D=Math.cos(-h),w=1-D;l.normalize();var N=b._m;N[0]=l._x*l._x*w+D,N[1]=l._x*l._y*w-l._z*T,N[2]=l._x*l._z*w+l._y*T,N[3]=0,N[4]=l._y*l._x*w+l._z*T,N[5]=l._y*l._y*w+D,N[6]=l._y*l._z*w-l._x*T,N[7]=0,N[8]=l._z*l._x*w-l._y*T,N[9]=l._z*l._y*w+l._x*T,N[10]=l._z*l._z*w+D,N[11]=0,N[12]=0,N[13]=0,N[14]=0,N[15]=1,b._markAsUpdated()},g.RotationAlignToRef=function(l,h,b){var T=C.Cross(h,l),D=C.Dot(h,l),w=1/(1+D),N=b._m;N[0]=T._x*T._x*w+D,N[1]=T._y*T._x*w-T._z,N[2]=T._z*T._x*w+T._y,N[3]=0,N[4]=T._x*T._y*w+T._z,N[5]=T._y*T._y*w+D,N[6]=T._z*T._y*w-T._x,N[7]=0,N[8]=T._x*T._z*w-T._y,N[9]=T._y*T._z*w+T._x,N[10]=T._z*T._z*w+D,N[11]=0,N[12]=0,N[13]=0,N[14]=0,N[15]=1,b._markAsUpdated()},g.RotationYawPitchRoll=function(l,h,b){var T=new g;return g.RotationYawPitchRollToRef(l,h,b,T),T},g.RotationYawPitchRollToRef=function(l,h,b,T){c.RotationYawPitchRollToRef(l,h,b,A.Quaternion[0]),A.Quaternion[0].toRotationMatrix(T)},g.Scaling=function(l,h,b){var T=new g;return g.ScalingToRef(l,h,b,T),T},g.ScalingToRef=function(l,h,b,T){g.FromValuesToRef(l,0,0,0,0,h,0,0,0,0,b,0,0,0,0,1,T),T._updateIdentityStatus(l===1&&h===1&&b===1)},g.Translation=function(l,h,b){var T=new g;return g.TranslationToRef(l,h,b,T),T},g.TranslationToRef=function(l,h,b,T){g.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,l,h,b,1,T),T._updateIdentityStatus(l===0&&h===0&&b===0)},g.Lerp=function(l,h,b){var T=new g;return g.LerpToRef(l,h,b,T),T},g.LerpToRef=function(l,h,b,T){for(var D=T._m,w=l.m,N=h.m,I=0;I<16;I++)D[I]=w[I]*(1-b)+N[I]*b;T._markAsUpdated()},g.DecomposeLerp=function(l,h,b){var T=new g;return g.DecomposeLerpToRef(l,h,b,T),T},g.DecomposeLerpToRef=function(l,h,b,T){var D=A.Vector3[0],w=A.Quaternion[0],N=A.Vector3[1];l.decompose(D,w,N);var I=A.Vector3[2],V=A.Quaternion[1],W=A.Vector3[3];h.decompose(I,V,W);var j=A.Vector3[4];C.LerpToRef(D,I,b,j);var ne=A.Quaternion[2];c.SlerpToRef(w,V,b,ne);var te=A.Vector3[5];C.LerpToRef(N,W,b,te),g.ComposeToRef(j,ne,te,T)},g.LookAtLH=function(l,h,b){var T=new g;return g.LookAtLHToRef(l,h,b,T),T},g.LookAtLHToRef=function(l,h,b,T){var D=A.Vector3[0],w=A.Vector3[1],N=A.Vector3[2];h.subtractToRef(l,N),N.normalize(),C.CrossToRef(b,N,D);var I=D.lengthSquared();
1I===0?D.x=1:D.normalizeFromLength(Math.sqrt(I)),C.CrossToRef(N,D,w),w.normalize();var V=-C.Dot(D,l),W=-C.Dot(w,l),j=-C.Dot(N,l);g.FromValuesToRef(D._x,w._x,N._x,0,D._y,w._y,N._y,0,D._z,w._z,N._z,0,V,W,j,1,T)},g.LookAtRH=function(l,h,b){var T=new g;return g.LookAtRHToRef(l,h,b,T),T},g.LookAtRHToRef=function(l,h,b,T){var D=A.Vector3[0],w=A.Vector3[1],N=A.Vector3[2];l.subtractToRef(h,N),N.normalize(),C.CrossToRef(b,N,D);var I=D.lengthSquared();I===0?D.x=1:D.normalizeFromLength(Math.sqrt(I)),C.CrossToRef(N,D,w),w.normalize();var V=-C.Dot(D,l),W=-C.Dot(w,l),j=-C.Dot(N,l);g.FromValuesToRef(D._x,w._x,N._x,0,D._y,w._y,N._y,0,D._z,w._z,N._z,0,V,W,j,1,T)},g.OrthoLH=function(l,h,b,T){var D=new g;return g.OrthoLHToRef(l,h,b,T,D),D},g.OrthoLHToRef=function(l,h,b,T,D){var w=2/l,N=2/h,I=2/(T-b),V=-(T+b)/(T-b);g.FromValuesToRef(w,0,0,0,0,N,0,0,0,0,I,0,0,0,V,1,D),D._updateIdentityStatus(w===1&&N===1&&I===1&&V===0)},g.OrthoOffCenterLH=function(l,h,b,T,D,w){var N=new g;return g.OrthoOffCenterLHToRef(l,h,b,T,D,w,N),N},g.OrthoOffCenterLHToRef=function(l,h,b,T,D,w,N){var I=2/(h-l),V=2/(T-b),W=2/(w-D),j=-(w+D)/(w-D),ne=(l+h)/(l-h),te=(T+b)/(b-T);g.FromValuesToRef(I,0,0,0,0,V,0,0,0,0,W,0,ne,te,j,1,N),N._markAsUpdated()},g.OrthoOffCenterRH=function(l,h,b,T,D,w){var N=new g;return g.OrthoOffCenterRHToRef(l,h,b,T,D,w,N),N},g.OrthoOffCenterRHToRef=function(l,h,b,T,D,w,N){g.OrthoOffCenterLHToRef(l,h,b,T,D,w,N),N._m[10]*=-1},g.PerspectiveLH=function(l,h,b,T){var D=new g,w=2*b/l,N=2*b/h,I=(T+b)/(T-b),V=-2*T*b/(T-b);return g.FromValuesToRef(w,0,0,0,0,N,0,0,0,0,I,1,0,0,V,0,D),D._updateIdentityStatus(!1),D},g.PerspectiveFovLH=function(l,h,b,T){var D=new g;return g.PerspectiveFovLHToRef(l,h,b,T,D),D},g.PerspectiveFovLHToRef=function(l,h,b,T,D,w){w===void 0&&(w=!0);var N=b,I=T,V=1/Math.tan(.5*l),W=w?V/h:V,j=w?V:V*h,ne=(I+N)/(I-N),te=-2*I*N/(I-N);g.FromValuesToRef(W,0,0,0,0,j,0,0,0,0,ne,1,0,0,te,0,D),D._updateIdentityStatus(!1)},g.PerspectiveFovReverseLHToRef=function(l,h,b,T,D,w){w===void 0&&(w=!0);var N=1/Math.tan(.5*l),I=w?N/h:N,V=w?N:N*h;g.FromValuesToRef(I,0,0,0,0,V,0,0,0,0,-b,1,0,0,1,0,D),D._updateIdentityStatus(!1)},g.PerspectiveFovRH=function(l,h,b,T){var D=new g;return g.PerspectiveFovRHToRef(l,h,b,T,D),D},g.PerspectiveFovRHToRef=function(l,h,b,T,D,w){w===void 0&&(w=!0);var N=b,I=T,V=1/Math.tan(.5*l),W=w?V/h:V,j=w?V:V*h,ne=-(I+N)/(I-N),te=-2*I*N/(I-N);g.FromValuesToRef(W,0,0,0,0,j,0,0,0,0,ne,-1,0,0,te,0,D),D._updateIdentityStatus(!1)},g.PerspectiveFovReverseRHToRef=function(l,h,b,T,D,w){w===void 0&&(w=!0);var N=1/Math.tan(.5*l),I=w?N/h:N,V=w?N:N*h;g.FromValuesToRef(I,0,0,0,0,V,0,0,0,0,-b,-1,0,0,-1,0,D),D._updateIdentityStatus(!1)},g.PerspectiveFovWebVRToRef=function(l,h,b,T,D){D===void 0&&(D=!1);var w=D?-1:1,N=Math.tan(l.upDegrees*Math.PI/180),I=Math.tan(l.downDegrees*Math.PI/180),V=Math.tan(l.leftDegrees*Math.PI/180),W=Math.tan(l.rightDegrees*Math.PI/180),j=2/(V+W),ne=2/(N+I),te=T._m;te[0]=j,te[1]=te[2]=te[3]=te[4]=0,te[5]=ne,te[6]=te[7]=0,te[8]=(V-W)*j*.5,te[9]=-(N-I)*ne*.5,te[10]=-b/(h-b),te[11]=1*w,te[12]=te[13]=te[15]=0,te[14]=-2*b*h/(b-h),T._markAsUpdated()},g.GetFinalMatrix=function(l,h,b,T,D,w){var N=l.width,I=l.height,V=l.x,W=l.y,j=g.FromValues(N/2,0,0,0,0,-I/2,0,0,0,0,w-D,0,V+N/2,I/2+W,D,1),ne=A.Matrix[0];return h.multiplyToRef(b,ne),ne.multiplyToRef(T,ne),ne.multiply(j)},g.GetAsMatrix2x2=function(l){var h=l.m,b=[h[0],h[1],h[4],h[5]];return M.a.MatrixUse64Bits?b:new Float32Array(b)},g.GetAsMatrix3x3=function(l){var h=l.m,b=[h[0],h[1],h[2],h[4],h[5],h[6],h[8],h[9],h[10]];return M.a.MatrixUse64Bits?b:new Float32Array(b)},g.Transpose=function(l){var h=new g;return g.TransposeToRef(l,h),h},g.TransposeToRef=function(l,h){var b=h._m,T=l.m;b[0]=T[0],b[1]=T[4],b[2]=T[8],b[3]=T[12],b[4]=T[1],b[5]=T[5],b[6]=T[9],b[7]=T[13],b[8]=T[2],b[9]=T[6],b[10]=T[10],b[11]=T[14],b[12]=T[3],b[13]=T[7],b[14]=T[11],b[15]=T[15],h._updateIdentityStatus(l._isIdentity,l._isIdentityDirty)},g.Reflection=function(l){var h=new g;return g.ReflectionToRef(l,h),h},g.ReflectionToRef=function(l,h){l.normalize();var b=l.normal.x,T=l.normal.y,D=l.normal.z,w=-2*b,N=-2*T,I=-2*D;g.FromValuesToRef(w*b+1,N*b,I*b,0,w*T,N*T+1,I*T,0,w*D,N*D,I*D+1,0,w*l.d,N*l.d,I*l.d,1,h)},g.FromXYZAxesToRef=function(l,h,b,T){g.FromValuesToRef(l._x,l._y,l._z,0,h._x,h._y,h._z,0,b._x,b._y,b._z,0,0,0,0,1,T)},g.FromQuaternionToRef=function(l,h){var b=l._x*l._x,T=l._y*l._y,D=l._z*l._z,w=l._x*l._y,N=l._z*l._w,I=l._z*l._x,V=l._y*l._w,W=l._y*l._z,j=l._x*l._w;h._m[0]=1-2*(T+D),h._m[1]=2*(w+N),h._m[2]=2*(I-V),h._m[3]=0,h._m[4]=2*(w-N),h._m[5]=1-2*(D+b),h._m[6]=2*(W+j),h._m[7]=0,h._m[8]=2*(I+V),h._m[9]=2*(W-j),h._m[10]=1-2*(T+b),h._m[11]=0,h._m[12]=0,h._m[13]=0,h._m[14]=0,h._m[15]=1,h._markAsUpdated()},g._updateFlagSeed=0,g._identityReadOnly=g.Identity(),g}(),A=function(){function g(){}return g.Vector3=x.a.BuildArray(6,C.Zero),g.Matrix=x.a.BuildArray(2,E.Identity),g.Quaternion=x.a.BuildArray(3,c.Zero),g}(),S=function(){function g(){}return g.Vector2=x.a.BuildArray(3,R.Zero),g.Vector3=x.a.BuildArray(13,C.Zero),g.Vector4=x.a.BuildArray(3,m.Zero),g.Quaternion=x.a.BuildArray(2,c.Zero),g.Matrix=x.a.BuildArray(8,E.Identity),g}();u.a.RegisteredTypes["BABYLON.Vector2"]=R,u.a.RegisteredTypes["BABYLON.Vector3"]=C,u.a.RegisteredTypes["BABYLON.Vector4"]=m,u.a.RegisteredTypes["BABYLON.Matrix"]=E},function(Ae,v,f){f.d(v,"d",function(){return _}),f.d(v,"a",function(){return x}),f.d(v,"c",function(){return u}),f.d(v,"b",function(){return M}),f.d(v,"e",function(){return R}),f.d(v,"f",function(){return C});/*! *****************************************************************************
2	Copyright (c) Microsoft Corporation.
3
4	Permission to use, copy, modify, and/or distribute this software for any
5	purpose with or without fee is hereby granted.
6
7	THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8	REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9	AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10	INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11	LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12	OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13	PERFORMANCE OF THIS SOFTWARE.
14	***************************************************************************** */var B=function(m,c){return(B=Object.
14setPrototypeOf||{__proto__:[]}instanceof Array&&function(E,A){E.__proto__=A}||function(E,A){for(var S in A)Object.prototype.hasOwnProperty.call(A,S)&&(E[S]=A[S])})(m,c)};function _(m,c){if(typeof c!="function"&&c!==null)throw new TypeError("Class extends value "+String(c)+" is not a constructor or null");function E(){this.constructor=m}B(m,c),m.prototype=c===null?Object.create(c):(E.prototype=c.prototype,new E)}var x=function(){return(x=Object.assign||function(m){for(var c,E=1,A=arguments.length;E<A;E++)for(var S in c=arguments[E])Object.prototype.hasOwnProperty.call(c,S)&&(m[S]=c[S]);return m}).apply(this,arguments)};function u(m,c,E,A){var S,g=arguments.length,l=g<3?c:A===null?A=Object.getOwnPropertyDescriptor(c,E):A;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")l=Reflect.decorate(m,c,E,A);else for(var h=m.length-1;h>=0;h--)(S=m[h])&&(l=(g<3?S(l):g>3?S(c,E,l):S(c,E))||l);return g>3&&l&&Object.defineProperty(c,E,l),l}function M(m,c,E,A){return new(E||(E=Promise))(function(S,g){function l(T){try{b(A.next(T))}catch(D){g(D)}}function h(T){try{b(A.throw(T))}catch(D){g(D)}}function b(T){var D;T.done?S(T.value):(D=T.value,D instanceof E?D:new E(function(w){w(D)})).then(l,h)}b((A=A.apply(m,c||[])).next())})}function R(m,c){var E,A,S,g,l={label:0,sent:function(){if(1&S[0])throw S[1];return S[1]},trys:[],ops:[]};return g={next:h(0),throw:h(1),return:h(2)},typeof Symbol=="function"&&(g[Symbol.iterator]=function(){return this}),g;function h(b){return function(T){return function(D){if(E)throw new TypeError("Generator is already executing.");for(;l;)try{if(E=1,A&&(S=2&D[0]?A.return:D[0]?A.throw||((S=A.return)&&S.call(A),0):A.next)&&!(S=S.call(A,D[1])).done)return S;switch(A=0,S&&(D=[2&D[0],S.value]),D[0]){case 0:case 1:S=D;break;case 4:return l.label++,{value:D[1],done:!1};case 5:l.label++,A=D[1],D=[0];continue;case 7:D=l.ops.pop(),l.trys.pop();continue;default:if(S=l.trys,!((S=S.length>0&&S[S.length-1])||D[0]!==6&&D[0]!==2)){l=0;continue}if(D[0]===3&&(!S||D[1]>S[0]&&D[1]<S[3])){l.label=D[1];break}if(D[0]===6&&l.label<S[1]){l.label=S[1],S=D;break}if(S&&l.label<S[2]){l.label=S[2],l.ops.push(D);break}S[2]&&l.ops.pop(),l.trys.pop();continue}D=c.call(m,l)}catch(w){D=[6,w],A=0}finally{E=S=0}if(5&D[0])throw D[1];return{value:D[0]?D[1]:void 0,done:!0}}([b,T])}}}function C(){for(var m=0,c=0,E=arguments.length;c<E;c++)m+=arguments[c].length;var A=Array(m),S=0;for(c=0;c<E;c++)for(var g=arguments[c],l=0,h=g.length;l<h;l++,S++)A[S]=g[l];return A}},function(Ae,v,f){f.d(v,"a",function(){return B});var B=function(){function _(){}return _.ALPHA_DISABLE=0,_.ALPHA_ADD=1,_.ALPHA_COMBINE=2,_.ALPHA_SUBTRACT=3,_.ALPHA_MULTIPLY=4,_.ALPHA_MAXIMIZED=5,_.ALPHA_ONEONE=6,_.ALPHA_PREMULTIPLIED=7,_.ALPHA_PREMULTIPLIED_PORTERDUFF=8,_.ALPHA_INTERPOLATE=9,_.ALPHA_SCREENMODE=10,_.ALPHA_ONEONE_ONEONE=11,_.ALPHA_ALPHATOCOLOR=12,_.ALPHA_REVERSEONEMINUS=13,_.ALPHA_SRC_DSTONEMINUSSRCALPHA=14,_.ALPHA_ONEONE_ONEZERO=15,_.ALPHA_EXCLUSION=16,_.ALPHA_EQUATION_ADD=0,_.ALPHA_EQUATION_SUBSTRACT=1,_.ALPHA_EQUATION_REVERSE_SUBTRACT=2,_.ALPHA_EQUATION_MAX=3,_.ALPHA_EQUATION_MIN=4,_.ALPHA_EQUATION_DARKEN=5,_.DELAYLOADSTATE_NONE=0,_.DELAYLOADSTATE_LOADED=1,_.DELAYLOADSTATE_LOADING=2,_.DELAYLOADSTATE_NOTLOADED=4,_.NEVER=512,_.ALWAYS=519,_.LESS=513,_.EQUAL=514,_.LEQUAL=515,_.GREATER=516,_.GEQUAL=518,_.NOTEQUAL=517,_.KEEP=7680,_.REPLACE=7681,_.INCR=7682,_.DECR=7683,_.INVERT=5386,_.INCR_WRAP=34055,_.DECR_WRAP=34056,_.TEXTURE_CLAMP_ADDRESSMODE=0,_.TEXTURE_WRAP_ADDRESSMODE=1,_.TEXTURE_MIRROR_ADDRESSMODE=2,_.TEXTUREFORMAT_ALPHA=0,_.TEXTUREFORMAT_LUMINANCE=1,_.TEXTUREFORMAT_LUMINANCE_ALPHA=2,_.TEXTUREFORMAT_RGB=4,_.TEXTUREFORMAT_RGBA=5,_.TEXTUREFORMAT_RED=6,_.TEXTUREFORMAT_R=6,_.TEXTUREFORMAT_RG=7,_.TEXTUREFORMAT_RED_INTEGER=8,_.TEXTUREFORMAT_R_INTEGER=8,_.TEXTUREFORMAT_RG_INTEGER=9,_.TEXTUREFORMAT_RGB_INTEGER=10,_.TEXTUREFORMAT_RGBA_INTEGER=11,_.TEXTURETYPE_UNSIGNED_BYTE=0,_.TEXTURETYPE_UNSIGNED_INT=0,_.TEXTURETYPE_FLOAT=1,_.TEXTURETYPE_HALF_FLOAT=2,_.TEXTURETYPE_BYTE=3,_.TEXTURETYPE_SHORT=4,_.TEXTURETYPE_UNSIGNED_SHORT=5,_.TEXTURETYPE_INT=6,_.TEXTURETYPE_UNSIGNED_INTEGER=7,_.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=8,_.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=9,_.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=10,_.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=11,_.TEXTURETYPE_UNSIGNED_INT_24_8=12,_.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=13,_.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=14,_.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=15,_.TEXTURE_NEAREST_SAMPL
14INGMODE=1,_.TEXTURE_NEAREST_NEAREST=1,_.TEXTURE_BILINEAR_SAMPLINGMODE=2,_.TEXTURE_LINEAR_LINEAR=2,_.TEXTURE_TRILINEAR_SAMPLINGMODE=3,_.TEXTURE_LINEAR_LINEAR_MIPLINEAR=3,_.TEXTURE_NEAREST_NEAREST_MIPNEAREST=4,_.TEXTURE_NEAREST_LINEAR_MIPNEAREST=5,_.TEXTURE_NEAREST_LINEAR_MIPLINEAR=6,_.TEXTURE_NEAREST_LINEAR=7,_.TEXTURE_NEAREST_NEAREST_MIPLINEAR=8,_.TEXTURE_LINEAR_NEAREST_MIPNEAREST=9,_.TEXTURE_LINEAR_NEAREST_MIPLINEAR=10,_.TEXTURE_LINEAR_LINEAR_MIPNEAREST=11,_.TEXTURE_LINEAR_NEAREST=12,_.TEXTURE_EXPLICIT_MODE=0,_.TEXTURE_SPHERICAL_MODE=1,_.TEXTURE_PLANAR_MODE=2,_.TEXTURE_CUBIC_MODE=3,_.TEXTURE_PROJECTION_MODE=4,_.TEXTURE_SKYBOX_MODE=5,_.TEXTURE_INVCUBIC_MODE=6,_.TEXTURE_EQUIRECTANGULAR_MODE=7,_.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=8,_.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9,_.TEXTURE_FILTERING_QUALITY_OFFLINE=4096,_.TEXTURE_FILTERING_QUALITY_HIGH=64,_.TEXTURE_FILTERING_QUALITY_MEDIUM=16,_.TEXTURE_FILTERING_QUALITY_LOW=8,_.SCALEMODE_FLOOR=1,_.SCALEMODE_NEAREST=2,_.SCALEMODE_CEILING=3,_.MATERIAL_TextureDirtyFlag=1,_.MATERIAL_LightDirtyFlag=2,_.MATERIAL_FresnelDirtyFlag=4,_.MATERIAL_AttributesDirtyFlag=8,_.MATERIAL_MiscDirtyFlag=16,_.MATERIAL_PrePassDirtyFlag=32,_.MATERIAL_AllDirtyFlag=63,_.MATERIAL_TriangleFillMode=0,_.MATERIAL_WireFrameFillMode=1,_.MATERIAL_PointFillMode=2,_.MATERIAL_PointListDrawMode=3,_.MATERIAL_LineListDrawMode=4,_.MATERIAL_LineLoopDrawMode=5,_.MATERIAL_LineStripDrawMode=6,_.MATERIAL_TriangleStripDrawMode=7,_.MATERIAL_TriangleFanDrawMode=8,_.MATERIAL_ClockWiseSideOrientation=0,_.MATERIAL_CounterClockWiseSideOrientation=1,_.ACTION_NothingTrigger=0,_.ACTION_OnPickTrigger=1,_.ACTION_OnLeftPickTrigger=2,_.ACTION_OnRightPickTrigger=3,_.ACTION_OnCenterPickTrigger=4,_.ACTION_OnPickDownTrigger=5,_.ACTION_OnDoublePickTrigger=6,_.ACTION_OnPickUpTrigger=7,_.ACTION_OnPickOutTrigger=16,_.ACTION_OnLongPressTrigger=8,_.ACTION_OnPointerOverTrigger=9,_.ACTION_OnPointerOutTrigger=10,_.ACTION_OnEveryFrameTrigger=11,_.ACTION_OnIntersectionEnterTrigger=12,_.ACTION_OnIntersectionExitTrigger=13,_.ACTION_OnKeyDownTrigger=14,_.ACTION_OnKeyUpTrigger=15,_.PARTICLES_BILLBOARDMODE_Y=2,_.PARTICLES_BILLBOARDMODE_ALL=7,_.PARTICLES_BILLBOARDMODE_STRETCHED=8,_.MESHES_CULLINGSTRATEGY_STANDARD=0,_.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY=1,_.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION=2,_.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY=3,_.SCENELOADER_NO_LOGGING=0,_.SCENELOADER_MINIMAL_LOGGING=1,_.SCENELOADER_SUMMARY_LOGGING=2,_.SCENELOADER_DETAILED_LOGGING=3,_.PREPASS_IRRADIANCE_TEXTURE_TYPE=0,_.PREPASS_POSITION_TEXTURE_TYPE=1,_.PREPASS_VELOCITY_TEXTURE_TYPE=2,_.PREPASS_REFLECTIVITY_TEXTURE_TYPE=3,_.PREPASS_COLOR_TEXTURE_TYPE=4,_.PREPASS_DEPTHNORMAL_TEXTURE_TYPE=5,_.PREPASS_ALBEDO_TEXTURE_TYPE=6,_}()},function(Ae,v,f){f.d(v,"b",function(){return E}),f.d(v,"c",function(){return A}),f.d(v,"m",function(){return S}),f.d(v,"e",function(){return g}),f.d(v,"h",function(){return l}),f.d(v,"n",function(){return h}),f.d(v,"o",function(){return b}),f.d(v,"k",function(){return T}),f.d(v,"g",function(){return D}),f.d(v,"f",function(){return w}),f.d(v,"i",function(){return N}),f.d(v,"l",function(){return I}),f.d(v,"j",function(){return V}),f.d(v,"d",function(){return W}),f.d(v,"a",function(){return j});
14var B=f(37),_=f(0),x=f(21),u=f(9),M={},R={},C=function(ne,te,de){var pe=ne();B.a&&B.a.AddTagsTo(pe,te.tags);var ae=m(pe);for(var ee in ae){var K=ae[ee],$=te[ee],L=K.type;if($!=null&&ee!=="uniqueId")switch(L){case 0:case 6:case 11:pe[ee]=$;break;case 1:pe[ee]=de||$.isRenderTarget?$:$.clone();break;case 2:case 3:case 4:case 5:case 7:case 10:case 12:pe[ee]=de?$:$.clone()}}return pe};function m(ne){var te=ne.getClassName();if(R[te])return R[te];R[te]={};for(var de=R[te],pe=ne,ae=te;ae;){var ee=M[ae];for(var K in ee)de[K]=ee[K];var $=void 0,L=!1;do{if(!($=Object.getPrototypeOf(pe)).getClassName){L=!0;break}if($.getClassName()!==ae)break;pe=$}while($);if(L)break;ae=$.getClassName(),pe=$}return de}function c(ne,te){return function(de,pe){var ae=function(ee){var K=ee.getClassName();return M[K]||(M[K]={}),M[K]}(de);ae[pe]||(ae[pe]={type:ne,sourceName:te})}}function E(ne,te){return te===void 0&&(te=null),function(de,pe){return pe===void 0&&(pe=null),function(ae,ee){var K=pe||"_"+ee;Object.defineProperty(ae,ee,{get:function(){return this[K]},set:function($){this[K]!==$&&(this[K]=$,ae[de].apply(this))},enumerable:!0,configurable:!0})}}(ne,te)}function A(ne){return c(0,ne)}function S(ne){return c(1,ne)}function g(ne){return c(2,ne)}function l(ne){return c(3,ne)}function h(ne){return c(4,ne)}function b(ne){return c(5,ne)}function T(ne){return c(6,ne)}function D(ne){return c(7,ne)}function w(ne){return c(8,ne)}function N(ne){return c(9,ne)}function I(ne){return c(10,ne)}function V(ne){return c(12,ne)}function W(ne){return c(11,ne)}var j=function(){function ne(){}return ne.AppendSerializedAnimations=function(te,de){if(te.animations){de.animations=[];for(var pe=0;pe<te.animations.length;pe++){var ae=te.animations[pe];de.animations.push(ae.serialize())}}},ne.Serialize=function(te,de){de||(de={}),B.a&&(de.tags=B.a.GetTags(te));var pe=m(te);for(var ae in pe){var ee=pe[ae],K=ee.sourceName||ae,$=ee.type,L=te[ae];if(L!=null&&ae!=="uniqueId")switch($){case 0:de[K]=L;break;case 1:de[K]=L.serialize();break;case 2:de[K]=L.asArray();break;case 3:de[K]=L.serialize();break;case 4:case 5:de[K]=L.asArray();break;case 6:de[K]=L.id;break;case 7:de[K]=L.serialize();break;case 8:de[K]=L.asArray();break;case 9:de[K]=L.serialize();break;case 10:de[K]=L.asArray();break;case 11:de[K]=L.id;case 12:de[K]=L.asArray()}}return de},ne.Parse=function(te,de,pe,ae){ae===void 0&&(ae=null);var ee=te();ae||(ae=""),B.a&&B.a.AddTagsTo(ee,de.tags);var K=m(ee);for(var $ in K){var L=K[$],G=de[L.sourceName||$],Q=L.type;if(G!=null&&$!=="uniqueId"){var oe=ee;switch(Q){case 0:oe[$]=G;break;case 1:pe&&(oe[$]=ne._TextureParser(G,pe,ae));break;case 2:oe[$]=u.a.FromArray(G);break;case 3:oe[$]=ne._FresnelParametersParser(G);break;case 4:oe[$]=_.d.FromArray(G);break;case 5:oe[$]=_.e.FromArray(G);break;case 6:pe&&(oe[$]=pe.getLastMeshByID(G));break;case 7:oe[$]=ne._ColorCurvesParser(G);break;case 8:oe[$]=u.b.FromArray(G);break;case 9:oe[$]=ne._ImageProcessingConfigurationParser(G);break;case 10:oe[$]=_.b.FromArray(G);break;case 11:pe&&(oe[$]=pe.getCameraByID(G));case 12:oe[$]=_.a.FromArray(G)}}}return ee},ne.Clone=function(te,de){return C(te,de,!1)},ne.Instanciate=function(te,de){return C(te,de,!0)},ne._ImageProcessingConfigurationParser=function(te){throw x.a.WarnImport("ImageProcessingConfiguration")},ne._FresnelParametersParser=function(te){throw x.a.WarnImport("FresnelParameters")},ne._ColorCurvesParser=function(te){throw x.a.WarnImport("ColorCurves")},ne._TextureParser=function(te,de,pe){throw x.a.WarnImport("Texture")},ne}()},function(Ae,v,f){f.d(v,"a",function(){return B}),f.d(v,"b",function(){return _});var B=function(){function x(u,M,R,C,m,c,E,A){C===void 0&&(C=0),m===void 0&&(m=!1),c===void 0&&(c=!1),E===void 0&&(E=!1),this._isAlreadyOwned=!1,u.getScene?this._engine=u.getScene().getEngine():this._engine=u,this._updatable=R,this._instanced=c,this._divisor=A||1,this._data=M,this.byteStride=E?C:C*Float32Array.BYTES_PER_ELEMENT,m||this.create()}return x.prototype.createVertexBuffer=function(u,M,R,C,m,c,E){c===void 0&&(c=!1);var A=c?M:M*Float32Array.BYTES_PER_ELEMENT,S=C?c?C:C*Float32Array.BYTES_PER_ELEMENT:this.byteStride;return new _(this._engine,this,u,this._updatable,!0,S,m===void 0?this._instanced:m,A,R,void 0,void 0,!0,this._divisor||E)},x.prototype.isUpdatable=function(){return this._updatable},x.prototype.getData=function(){return this._data},x.prototype.getBuffer=function(){return this._buffer},x.prototype.getStrideSize=function(){return this.byteStride/Float32Array.BYTES_PER_ELEMENT},x.prototype.create=function(u){u===void 0&&(u=null),!u&&this._buffer||(u=u||this._data)&&(this._buffer?this._updatable&&(this._engine.updateDynamicVertexBuffer(this._buffer,u),this._data=u):this._updatable?(this._buffer=this._engine.createDynamicVertexBuffer(u),this._data=u):this._buffer=this._engine.createVertexBuffer(u))},x.prototype._rebuild=function(){this._buffer=null,this.create(this._data)},x.prototype.update=function(u){this.create(u)},x.prototype.updateDirectly=function(u,M,R,C){C===void 0&&(C=!1),this._buffer&&this._updatable&&(this._engine.updateDynamicVertexBuffer(this._buffer,u,C?M:M*Float32Array.BYTES_PER_ELEMENT,R?R*this.byteStride:void 0),this._data=null)},x.prototype._increaseReferences=function(){this._buffer&&(this._isAlreadyOwned?this._buffer.references++:this._isAlreadyOwned=!0)},x.prototype.dispose=function(){this._buffer&&this._engine._releaseBuffer(this._buffer)&&(this._buffer=null)},x}(),_=function(){function x(u,M,R,C,m,c,E,A,S,g,l,h,b,T){if(l===void 0&&(l=!1),h===void 0&&(h=!1),b===void 0&&(b=1),T===void 0&&(T=!1),M instanceof B?(this._buffer=M,this._ownsBuffer=T,T&&this._buffer._increaseReferences()):(this._buffer=new B(u,M,C,c,m,E,h),this._ownsBuffer=!0),this._kind=R,g==null){var D=this.getData();this.type=x.FLOAT,D instanceof Int8Array?this.type=x.BYTE:D instanceof Uint8Array?this.type=x.UNSIGNED_BYTE:D instanceof Int16Array?this.type=x.SHORT:D instanceof Uint16Array?this.type=x.UNSIGNED_SHORT:D instanceof Int32Array?this.type=x.INT:D instanceof Uint32Array&&(this.t
14ype=x.UNSIGNED_INT)}else this.type=g;var w=x.GetTypeByteLength(this.type);h?(this._size=S||(c?c/w:x.DeduceStride(R)),this.byteStride=c||this._buffer.byteStride||this._size*w,this.byteOffset=A||0):(this._size=S||c||x.DeduceStride(R),this.byteStride=c?c*w:this._buffer.byteStride||this._size*w,this.byteOffset=(A||0)*w),this.normalized=l,this._instanced=E!==void 0&&E,this._instanceDivisor=E?b:0}return Object.defineProperty(x.prototype,"instanceDivisor",{get:function(){return this._instanceDivisor},set:function(u){this._instanceDivisor=u,this._instanced=u!=0},enumerable:!1,configurable:!0}),x.prototype._rebuild=function(){this._buffer&&this._buffer._rebuild()},x.prototype.getKind=function(){return this._kind},x.prototype.isUpdatable=function(){return this._buffer.isUpdatable()},x.prototype.getData=function(){return this._buffer.getData()},x.prototype.getBuffer=function(){return this._buffer.getBuffer()},x.prototype.getStrideSize=function(){return this.byteStride/x.GetTypeByteLength(this.type)},x.prototype.getOffset=function(){return this.byteOffset/x.GetTypeByteLength(this.type)},x.prototype.getSize=function(){return this._size},x.prototype.getIsInstanced=function(){return this._instanced},x.prototype.getInstanceDivisor=function(){return this._instanceDivisor},x.prototype.create=function(u){this._buffer.create(u)},x.prototype.update=function(u){this._buffer.update(u)},x.prototype.updateDirectly=function(u,M,R){R===void 0&&(R=!1),this._buffer.updateDirectly(u,M,void 0,R)},x.prototype.dispose=function(){this._ownsBuffer&&this._buffer.dispose()},x.prototype.forEach=function(u,M){x.ForEach(this._buffer.getData(),this.byteOffset,this.byteStride,this._size,this.type,u,this.normalized,M)},x.DeduceStride=function(u){switch(u){case x.UVKind:case x.UV2Kind:case x.UV3Kind:case x.UV4Kind:case x.UV5Kind:case x.UV6Kind:return 2;case x.NormalKind:case x.PositionKind:return 3;case x.ColorKind:case x.MatricesIndicesKind:case x.MatricesIndicesExtraKind:case x.MatricesWeightsKind:case x.MatricesWeightsExtraKind:case x.TangentKind:return 4;default:throw new Error("Invalid kind '"+u+"'")}},x.GetTypeByteLength=function(u){switch(u){case x.BYTE:case x.UNSIGNED_BYTE:return 1;case x.SHORT:case x.UNSIGNED_SHORT:return 2;case x.INT:case x.UNSIGNED_INT:case x.FLOAT:return 4;default:throw new Error("Invalid type '"+u+"'")}},x.ForEach=function(u,M,R,C,m,c,E,A){if(u instanceof Array)for(var S=M/4,g=R/4,l=0;l<c;l+=C){for(var h=0;h<C;h++)A(u[S+h],l+h);S+=g}else{var b=u instanceof ArrayBuffer?new DataView(u):new DataView(u.buffer,u.byteOffset,u.byteLength),T=x.GetTypeByteLength(m);for(l=0;l<c;l+=C){var D=M;for(h=0;h<C;h++)A(x._GetFloatValue(b,m,D,E),l+h),D+=T;M+=R}}},x._GetFloatValue=function(u,M,R,C){switch(M){case x.BYTE:var m=u.getInt8(R);return C&&(m=Math.max(m/127,-1)),m;case x.UNSIGNED_BYTE:return m=u.getUint8(R),C&&(m/=255),m;case x.SHORT:return m=u.getInt16(R,!0),C&&(m=Math.max(m/32767,-1)),m;case x.UNSIGNED_SHORT:return m=u.getUint16(R,!0),C&&(m/=65535),m;case x.INT:return u.getInt32(R,!0);case x.UNSIGNED_INT:return u.getUint32(R,!0);case x.FLOAT:return u.getFloat32(R,!0);default:throw new Error("Invalid component type "+M)}},x.BYTE=5120,x.UNSIGNED_BYTE=5121,x.SHORT=5122,x.UNSIGNED_SHORT=5123,x.INT=5124,x.UNSIGNED_INT=5125,x.FLOAT=5126,x.PositionKind="position",x.NormalKind="normal",x.TangentKind="tangent",x.UVKind="uv",x.UV2Kind="uv2",x.UV3Kind="uv3",x.UV4Kind="uv4",x.UV5Kind="uv5",x.UV6Kind="uv6",x.ColorKind="color",x.MatricesIndicesKind="matricesIndices",x.MatricesWeightsKind="matricesWeights",x.MatricesIndicesExtraKind="matricesIndicesExtra",x.MatricesWeightsExtraKind="matricesWeightsExtra",x}()},function(Ae,v,f){f.d(v,"a",function(){return R});var B=f(6),_=f(2),x=f(38),u=f(8),M=f(128),R=function(){function C(m,c,E,A,S,g,l,h,b,T){var D,w=this;A===void 0&&(A=null),g===void 0&&(g=null),l===void 0&&(l=null),h===void 0&&(h=null),b===void 0&&(b=null),this.name=null,this.defines="",this.onCompiled=null,this.onError=null,this.onBind=null,this.uniqueId=0,this.onCompileObservable=new B.c,this.onErrorObservable=new B.c,this._onBindObservable=null,this._wasPreviouslyReady=!1,this._bonesComputationForcedToCPU=!1,this._multiTarget=!1,this._uniformBuffersNames={},this._samplers={},this._isReady=!1,this._compilationError="",this._allFallbacksProcessed=!1,this._uniforms={},this._key="",this._fallbacks=null,this._vertexSourceCode="",this._fragmentSourceCode="",this._vertexSourceCodeOverride="",this._fragmentSourceCodeOverride="",this._transformFeedbackVaryings=null,this._rawVertexSourceCode="",this._rawFragmentSourceCode="",this._pipelineContext=null,this._valueCache={},this.name=m;var N,I,V=null;if(c.attributes){var W=c;if(this._engine=E,this._attributesNames=W.attributes,this._uniformsNames=W.uniformsNames.concat(W.samplers),this._samplerList=W.samplers.slice(),this.defines=W.defines,this.onError=W.onError,this.onCompiled=W.onCompiled,this._fallbacks=W.fallbacks,this._indexParameters=W.indexParameters,this._transformFeedbackVaryings=W.transformFeedbackVaryings||null,this._multiTarget=!!W.multiTarget,W.uniformBuffersNames){this._uniformBuffersNamesList=W.uniformBuffersNames.slice();for(var j=0;j<W.uniformBuffersNames.length;j++)this._uniformBuffersNames[W.uniformBuffersNames[j]]=j}
14V=(D=W.processFinalCode)!==null&&D!==void 0?D:null}else this._engine=S,this.defines=g??"",this._uniformsNames=E.concat(A),this._samplerList=A?A.slice():[],this._attributesNames=c,this._uniformBuffersNamesList=[],this.onError=b,this.onCompiled=h,this._indexParameters=T,this._fallbacks=l;this._attributeLocationByName={},this.uniqueId=C._uniqueIdSeed++;var ne=x.a.IsWindowObjectExist()?this._engine.getHostDocument():null;m.vertexSource?N="source:"+m.vertexSource:m.vertexElement?(N=ne?ne.getElementById(m.vertexElement):null)||(N=m.vertexElement):N=m.vertex||m,m.fragmentSource?I="source:"+m.fragmentSource:m.fragmentElement?(I=ne?ne.getElementById(m.fragmentElement):null)||(I=m.fragmentElement):I=m.fragment||m;var te={defines:this.defines.split(`
15`),indexParameters:this._indexParameters,isFragment:!1,shouldUseHighPrecisionShader:this._engine._shouldUseHighPrecisionShader,processor:this._engine._shaderProcessor,supportsUniformBuffers:this._engine.supportsUniformBuffers,shadersRepository:C.ShadersRepository,includesShadersStore:C.IncludesShadersStore,version:(100*this._engine.webGLVersion).toString(),platformName:this._engine.webGLVersion>=2?"WEBGL2":"WEBGL1"};this._loadShader(N,"Vertex","",function(de){w._rawVertexSourceCode=de,w._loadShader(I,"Fragment","Pixel",function(pe){w._rawFragmentSourceCode=pe,M.a.Process(de,te,function(ae){V&&(ae=V("vertex",ae)),te.isFragment=!0,M.a.Process(pe,te,function(ee){V&&(ee=V("fragment",ee)),w._useFinalCode(ae,ee,m)},w._engine)},w._engine)})})}return Object.defineProperty(C.prototype,"onBindObservable",{get:function(){return this._onBindObservable||(this._onBindObservable=new B.c),this._onBindObservable},enumerable:!1,configurable:!0}),C.prototype._useFinalCode=function(m,c,E){if(E){var A=E.vertexElement||E.vertex||E.spectorName||E,S=E.fragmentElement||E.fragment||E.spectorName||E;this._vertexSourceCode="#define SHADER_NAME vertex:"+A+`
16`+m,this._fragmentSourceCode="#define SHADER_NAME fragment:"+S+`
17`+c}else this._vertexSourceCode=m,this._fragmentSourceCode=c;this._prepareEffect()},Object.defineProperty(C.prototype,"key",{get:function(){return this._key},enumerable:!1,configurable:!0}),C.prototype.isReady=function(){try{return this._isReadyInternal()}catch{return!1}},C.prototype._isReadyInternal=function(){return!!this._isReady||!!this._pipelineContext&&this._pipelineContext.isReady},C.prototype.getEngine=function(){return this._engine},C.prototype.getPipelineContext=function(){return this._pipelineContext},C.prototype.getAttributesNames=function(){return this._attributesNames},C.prototype.getAttributeLocation=function(m){return this._attributes[m]},C.prototype.getAttributeLocationByName=function(m){return this._attributeLocationByName[m]},C.prototype.getAttributesCount=function(){return this._attributes.length},C.prototype.getUniformIndex=function(m){return this._uniformsNames.indexOf(m)},C.prototype.getUniform=function(m){return this._uniforms[m]},C.prototype.getSamplers=function(){return this._samplerList},C.prototype.getUniformNames=function(){return this._uniformsNames},C.prototype.getUniformBuffersNames=function(){return this._uniformBuffersNamesList},C.prototype.getIndexParameters=function(){return this._indexParameters},C.prototype.getCompilationError=function(){return this._compilationError},C.prototype.allFallbacksProcessed=function(){return this._allFallbacksProcessed},C.prototype.executeWhenCompiled=function(m){var c=this;this.isReady()?m(this):(this.onCompileObservable.add(function(E){m(E)}),this._pipelineContext&&!this._pipelineContext.isAsync||setTimeout(function(){c._checkIsReady(null)},16))},C.prototype._checkIsReady=function(m){var c=this;try{if(this._isReadyInternal())return}catch(E){return void this._processCompilationErrors(E,m)}setTimeout(function(){c._checkIsReady(m)},16)},C.prototype._loadShader=function(m,c,E,A){var S;if(typeof HTMLElement<"u"&&m instanceof HTMLElement)return void A(x.a.GetDOMTextContent(m));m.substr(0,7)!=="source:"?m.substr(0,7)!=="base64:"?C.ShadersStore[m+c+"Shader"]?A(C.ShadersStore[m+c+"Shader"]):E&&C.ShadersStore[m+E+"Shader"]?A(C.ShadersStore[m+E+"Shader"]):(S=m[0]==="."||m[0]==="/"||m.indexOf("http")>-1?m:C.ShadersRepository+m,this._engine._loadFile(S+"."+c.toLowerCase()+".fx",A)):A(window.atob(m.substr(7))):A(m.substr(7))},Object.defineProperty(C.prototype,"vertexSourceCode",{get:function(){return this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?this._vertexSourceCodeOverride:this._vertexSourceCode}
17,enumerable:!1,configurable:!0}),Object.defineProperty(C.prototype,"fragmentSourceCode",{get:function(){return this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?this._fragmentSourceCodeOverride:this._fragmentSourceCode},enumerable:!1,configurable:!0}),Object.defineProperty(C.prototype,"rawVertexSourceCode",{get:function(){return this._rawVertexSourceCode},enumerable:!1,configurable:!0}),Object.defineProperty(C.prototype,"rawFragmentSourceCode",{get:function(){return this._rawFragmentSourceCode},enumerable:!1,configurable:!0}),C.prototype._rebuildProgram=function(m,c,E,A){var S=this;this._isReady=!1,this._vertexSourceCodeOverride=m,this._fragmentSourceCodeOverride=c,this.onError=function(g,l){A&&A(l)},this.onCompiled=function(){var g=S.getEngine().scenes;if(g)for(var l=0;l<g.length;l++)g[l].markAllMaterialsAsDirty(_.a.MATERIAL_AllDirtyFlag);S._pipelineContext._handlesSpectorRebuildCallback(E)},this._fallbacks=null,this._prepareEffect()},C.prototype._prepareEffect=function(){var m=this,c=this._attributesNames,E=this.defines;this._valueCache={};var A=this._pipelineContext;try{var S=this._engine;this._pipelineContext=S.createPipelineContext();var g=this._rebuildProgram.bind(this);this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?S._preparePipelineContext(this._pipelineContext,this._vertexSourceCodeOverride,this._fragmentSourceCodeOverride,!0,g,null,this._transformFeedbackVaryings):S._preparePipelineContext(this._pipelineContext,this._vertexSourceCode,this._fragmentSourceCode,!1,g,E,this._transformFeedbackVaryings),S._executeWhenRenderingStateIsCompiled(this._pipelineContext,function(){if(S.supportsUniformBuffers)for(var l in m._uniformBuffersNames)m.bindUniformBlock(l,m._uniformBuffersNames[l]);var h;if(S.getUniforms(m._pipelineContext,m._uniformsNames).forEach(function(D,w){m._uniforms[m._uniformsNames[w]]=D}),m._attributes=S.getAttributes(m._pipelineContext,c),c)for(var b=0;b<c.length;b++){var T=c[b];m._attributeLocationByName[T]=m._attributes[b]}for(h=0;h<m._samplerList.length;h++)m.getUniform(m._samplerList[h])==null&&(m._samplerList.splice(h,1),h--);m._samplerList.forEach(function(D,w){m._samplers[D]=w}),S.bindSamplers(m),m._compilationError="",m._isReady=!0,m.onCompiled&&m.onCompiled(m),m.onCompileObservable.notifyObservers(m),m.onCompileObservable.clear(),m._fallbacks&&m._fallbacks.unBindMesh(),A&&m.getEngine()._deletePipelineContext(A)}),this._pipelineContext.isAsync&&this._checkIsReady(A)}catch(l){this._processCompilationErrors(l,A)}},C.prototype._getShaderCodeAndErrorLine=function(m,c,E){var A=E?/FRAGMENT SHADER ERROR: 0:(\d+?):/:/VERTEX SHADER ERROR: 0:(\d+?):/,S=null;if(c&&m){var g=c.match(A);if(g&&g.length===2){var l=parseInt(g[1]),h=m.split(`
18`,-1);h.length>=l&&(S="Offending line ["+l+"] in "+(E?"fragment":"vertex")+" code: "+h[l-1])}}return[m,S]},C.prototype._processCompilationErrors=function(m,c){var E,A,S,g,l;c===void 0&&(c=null),this._compilationError=m.message;var h=this._attributesNames,b=this._fallbacks;if(u.a.Error("Unable to compile effect:"),u.a.Error("Uniforms: "+this._uniformsNames.map(function(N){return" "+N})),u.a.Error("Attributes: "+h.map(function(N){return" "+N})),u.a.Error(`Defines:\r
19`+this.defines),C.LogShaderCodeOnCompilationError){var T=null,D=null,w=null;!((S=this._pipelineContext)===null||S===void 0)&&S._getVertexShaderCode()&&(w=(E=this._getShaderCodeAndErrorLine(this._pipelineContext._getVertexShaderCode(),this._compilationError,!1))[0],T=E[1],w&&(u.a.Error("Vertex code:"),u.a.Error(w))),!((g=this._pipelineContext)===null||g===void 0)&&g._getFragmentShaderCode()&&(w=(A=this._getShaderCodeAndErrorLine((l=this._pipelineContext)===null||l===void 0?void 0:l._getFragmentShaderCode(),this._compilationError,!0))[0],D=A[1],w&&(u.a.Error("Fragment code:"),u.a.Error(w))),T&&u.a.Error(T),D&&u.a.Error(D)}u.a.Error("Error: "+this._compilationError),c&&(this._pipelineContext=c,this._isReady=!0,this.onError&&this.onError(this,this._compilationError),this.onErrorObservable.notifyObservers(this)),b?(this._pipelineContext=null,b.hasMoreFallbacks?(this._allFallbacksProcessed=!1,u.a.Error("Trying next fallback."),this.defines=b.reduce(this.defines,this),this._prepareEffe
19ct()):(this._allFallbacksProcessed=!0,this.onError&&this.onError(this,this._compilationError),this.onErrorObservable.notifyObservers(this),this.onErrorObservable.clear(),this._fallbacks&&this._fallbacks.unBindMesh())):this._allFallbacksProcessed=!0},Object.defineProperty(C.prototype,"isSupported",{get:function(){return this._compilationError===""},enumerable:!1,configurable:!0}),C.prototype._bindTexture=function(m,c){this._engine._bindTexture(this._samplers[m],c)},C.prototype.setTexture=function(m,c){this._engine.setTexture(this._samplers[m],this._uniforms[m],c)},C.prototype.setDepthStencilTexture=function(m,c){this._engine.setDepthStencilTexture(this._samplers[m],this._uniforms[m],c)},C.prototype.setTextureArray=function(m,c){var E=m+"Ex";if(this._samplerList.indexOf(E+"0")===-1){for(var A=this._samplerList.indexOf(m),S=1;S<c.length;S++){var g=E+(S-1).toString();this._samplerList.splice(A+S,0,g)}for(var l=0,h=0,b=this._samplerList;h<b.length;h++){var T=b[h];this._samplers[T]=l,l+=1}}this._engine.setTextureArray(this._samplers[m],this._uniforms[m],c)},C.prototype.setTextureFromPostProcess=function(m,c){this._engine.setTextureFromPostProcess(this._samplers[m],c)},C.prototype.setTextureFromPostProcessOutput=function(m,c){this._engine.setTextureFromPostProcessOutput(this._samplers[m],c)},C.prototype._cacheMatrix=function(m,c){var E=this._valueCache[m],A=c.updateFlag;return(E===void 0||E!==A)&&(this._valueCache[m]=A,!0)},C.prototype._cacheFloat2=function(m,c,E){var A=this._valueCache[m];if(!A||A.length!==2)return A=[c,E],this._valueCache[m]=A,!0;var S=!1;return A[0]!==c&&(A[0]=c,S=!0),A[1]!==E&&(A[1]=E,S=!0),S},C.prototype._cacheFloat3=function(m,c,E,A){var S=this._valueCache[m];if(!S||S.length!==3)return S=[c,E,A],this._valueCache[m]=S,!0;var g=!1;return S[0]!==c&&(S[0]=c,g=!0),S[1]!==E&&(S[1]=E,g=!0),S[2]!==A&&(S[2]=A,g=!0),g},C.prototype._cacheFloat4=function(m,c,E,A,S){var g=this._valueCache[m];if(!g||g.length!==4)return g=[c,E,A,S],this._valueCache[m]=g,!0;var l=!1;return g[0]!==c&&(g[0]=c,l=!0),g[1]!==E&&(g[1]=E,l=!0),g[2]!==A&&(g[2]=A,l=!0),g[3]!==S&&(g[3]=S,l=!0),l},C.prototype.bindUniformBuffer=function(m,c){var E=this._uniformBuffersNames[c];E!==void 0&&C._baseCache[E]!==m&&(C._baseCache[E]=m,this._engine.bindUniformBufferBase(m,E))},C.prototype.bindUniformBlock=function(m,c){this._engine.bindUniformBlock(this._pipelineContext,m,c)},C.prototype.setInt=function(m,c){var E=this._valueCache[m];return E!==void 0&&E===c||this._engine.setInt(this._uniforms[m],c)&&(this._valueCache[m]=c),this},C.prototype.setIntArray=function(m,c){return this._valueCache[m]=null,this._engine.setIntArray(this._uniforms[m],c),this},C.prototype.setIntArray2=function(m,c){return this._valueCache[m]=null,this._engine.setIntArray2(this._uniforms[m],c),this},C.prototype.setIntArray3=function(m,c){return this._valueCache[m]=null,this._engine.setIntArray3(this._uniforms[m],c),this},C.prototype.setIntArray4=function(m,c){return this._valueCache[m]=null,this._engine.setIntArray4(this._uniforms[m],c),this},C.prototype.setFloatArray=function(m,c){return this._valueCache[m]=null,this._engine.setArray(this._uniforms[m],c),this},C.prototype.setFloatArray2=function(m,c){return this._valueCache[m]=null,this._engine.setArray2(this._uniforms[m],c),this},C.prototype.setFloatArray3=function(m,c){return this._valueCache[m]=null,this._engine.setArray3(this._uniforms[m],c),this},C.prototype.setFloatArray4=function(m,c){return this._valueCache[m]=null,this._engine.setArray4(this._uniforms[m],c),this},C.prototype.setArray=function(m,c){return this._valueCache[m]=null,this._engine.setArray(this._uniforms[m],c),this},C.prototype.setArray2=function(m,c){return this._valueCache[m]=null,this._engine.setArray2(this._uniforms[m],c),this},C.prototype.setArray3=function(m,c){return this._valueCache[m]=null,this._engine.setArray3(this._uniforms[m],c),this},C.prototype.setArray4=function(m,c){return this._valueCache[m]=null,this._engine.setArray4(this._uniforms[m],c),this}
19,C.prototype.setMatrices=function(m,c){return c?(this._valueCache[m]=null,this._engine.setMatrices(this._uniforms[m],c),this):this},C.prototype.setMatrix=function(m,c){return this._cacheMatrix(m,c)&&(this._engine.setMatrices(this._uniforms[m],c.toArray())||(this._valueCache[m]=null)),this},C.prototype.setMatrix3x3=function(m,c){return this._valueCache[m]=null,this._engine.setMatrix3x3(this._uniforms[m],c),this},C.prototype.setMatrix2x2=function(m,c){return this._valueCache[m]=null,this._engine.setMatrix2x2(this._uniforms[m],c),this},C.prototype.setFloat=function(m,c){var E=this._valueCache[m];return E!==void 0&&E===c||this._engine.setFloat(this._uniforms[m],c)&&(this._valueCache[m]=c),this},C.prototype.setBool=function(m,c){var E=this._valueCache[m];return E!==void 0&&E===c||this._engine.setInt(this._uniforms[m],c?1:0)&&(this._valueCache[m]=c),this},C.prototype.setVector2=function(m,c){return this._cacheFloat2(m,c.x,c.y)&&(this._engine.setFloat2(this._uniforms[m],c.x,c.y)||(this._valueCache[m]=null)),this},C.prototype.setFloat2=function(m,c,E){return this._cacheFloat2(m,c,E)&&(this._engine.setFloat2(this._uniforms[m],c,E)||(this._valueCache[m]=null)),this},C.prototype.setVector3=function(m,c){return this._cacheFloat3(m,c.x,c.y,c.z)&&(this._engine.setFloat3(this._uniforms[m],c.x,c.y,c.z)||(this._valueCache[m]=null)),this},C.prototype.setFloat3=function(m,c,E,A){return this._cacheFloat3(m,c,E,A)&&(this._engine.setFloat3(this._uniforms[m],c,E,A)||(this._valueCache[m]=null)),this},C.prototype.setVector4=function(m,c){return this._cacheFloat4(m,c.x,c.y,c.z,c.w)&&(this._engine.setFloat4(this._uniforms[m],c.x,c.y,c.z,c.w)||(this._valueCache[m]=null)),this},C.prototype.setFloat4=function(m,c,E,A,S){return this._cacheFloat4(m,c,E,A,S)&&(this._engine.setFloat4(this._uniforms[m],c,E,A,S)||(this._valueCache[m]=null)),this},C.prototype.setColor3=function(m,c){return this._cacheFloat3(m,c.r,c.g,c.b)&&(this._engine.setFloat3(this._uniforms[m],c.r,c.g,c.b)||(this._valueCache[m]=null)),this},C.prototype.setColor4=function(m,c,E){return this._cacheFloat4(m,c.r,c.g,c.b,E)&&(this._engine.setFloat4(this._uniforms[m],c.r,c.g,c.b,E)||(this._valueCache[m]=null)),this},C.prototype.setDirectColor4=function(m,c){return this._cacheFloat4(m,c.r,c.g,c.b,c.a)&&(this._engine.setFloat4(this._uniforms[m],c.r,c.g,c.b,c.a)||(this._valueCache[m]=null)),this},C.prototype.dispose=function(){this._engine._releaseEffect(this)},C.RegisterShader=function(m,c,E){c&&(C.ShadersStore[m+"PixelShader"]=c),E&&(C.ShadersStore[m+"VertexShader"]=E)},C.ResetCache=function(){C._baseCache={}},C.ShadersRepository="src/Shaders/",C.LogShaderCodeOnCompilationError=!0,C._uniqueIdSeed=0,C._baseCache={},C.ShadersStore={},C.IncludesShadersStore={},C}()},function(Ae,v,f){f.d(v,"a",function(){return B}),f.d(v,"d",function(){return _}),f.d(v,"b",function(){return x}),f.d(v,"c",function(){return u});var B=function(){function M(R,C,m,c){C===void 0&&(C=!1),this.initalize(R,C,m,c)}return M.prototype.initalize=function(R,C,m,c){return C===void 0&&(C=!1),this.mask=R,this.skipNextObservers=C,this.target=m,this.currentTarget=c,this},M}(),_=function(M,R,C){C===void 0&&(C=null),this.callback=M,this.mask=R,this.scope=C,this._willBeUnregistered=!1,this.unregisterOnNextCall=!1},x=function(){function M(){}return M.prototype.dispose=function(){if(this._observers&&this._observables)for(var R=0;R<this._observers.length;R++)this._observables[R].remove(this._observers[R]);this._observers=null,this._observables=null},M.Watch=function(R,C,m,c){m===void 0&&(m=-1),c===void 0&&(c=null);var E=new M;E._observers=new Array,E._observables=R;for(var A=0,S=R;A<S.length;A++){var g=S[A].add(C,m,!1,c);g&&E._observers.push(g)}return E},M}(),u=function(){function M(R){this._observers=new Array,this._eventState=new B(0),R&&(this._onObserverAdded=R)}return Object.defineProperty(M.prototype,"observers",{get:function(){return this._observers},enumerable:!1,configurable:!0}),M.prototype.add=function(R,C,m,c,E){if(C===void 0&&(C=-1),m===void 0&&(m=!1),c===void 0&&(c=null),E===void 0&&(E=!1),!R)return null;var A=new _(R,C,c);return A.unregisterOnNextCall=E,m?this._observers.unshift(A):this._observers.push(A),this._onObserverAdded&&this._onObserverAdded(A),A},M.prototype.addOnce=function(R){return this.add(R,void 0,void 0,void 0,!0)},M.prototype.remove=function(R){return!!R&&this._observers.indexOf(R)!==-1&&(this._deferUnregister(R),!0)},M.prototype.removeCallback=function(R,C){for(var m=0;m<this._observers.length;m++){var c=this._observers[m];if(!c._willBeUnregistered&&c.callback===R&&(!C||C===c.scope))return this._deferUnregister(c),!0}return!1},M.prototype._deferUnregister=function(R){var C=this;R.unregisterOnNextCall=!1,R._willBeUnregistered=!0,setTimeout(function(){C._remove(R)},0)},M.prototype._remove=function(R){if(!R)return!1;var C=this._observers.indexOf(R);return C!==-1&&(this._observers.splice(C,1),!0)},M.prototype.makeObserverTopPriority=function(R){this._remove(R),this._observers.unshift(R)},M.prototype.makeObserverBottomPriority=function(R){this._remove(R),this._observers.push(R)},M.prototype.notifyObservers=function(R,C,m,c,E){if(C===void 0&&(C=-1),!this._observers.length)return!0;var A=this._eventState;A.mask=C,A.target=m,A.currentTarget=c,A.skipNextObservers=!1,A.lastReturnValue=R,A.userInfo=E;for(var S=0,g=this._observers;S<g.length;S++){var l=g[S];if(!l._willBeUnregistered&&(l.mask&C&&(l.scope?A.lastReturnValue=l.callback.apply(l.scope,[R,A]):A.lastReturnValue=l.callback(R,A),l.unregisterOnNextCall&&this._deferUnregister(l)),A.skipNextObservers))return!1}return!0}
19,M.prototype.notifyObserversWithPromise=function(R,C,m,c,E){var A=this;C===void 0&&(C=-1);var S=Promise.resolve(R);if(!this._observers.length)return S;var g=this._eventState;return g.mask=C,g.target=m,g.currentTarget=c,g.skipNextObservers=!1,g.userInfo=E,this._observers.forEach(function(l){g.skipNextObservers||l._willBeUnregistered||l.mask&C&&(S=l.scope?S.then(function(h){return g.lastReturnValue=h,l.callback.apply(l.scope,[R,g])}):S.then(function(h){return g.lastReturnValue=h,l.callback(R,g)}),l.unregisterOnNextCall&&A._deferUnregister(l))}),S.then(function(){return R})},M.prototype.notifyObserver=function(R,C,m){m===void 0&&(m=-1);var c=this._eventState;c.mask=m,c.skipNextObservers=!1,R.callback(C,c)},M.prototype.hasObservers=function(){return this._observers.length>0},M.prototype.clear=function(){this._observers=new Array,this._onObserverAdded=null},M.prototype.clone=function(){var R=new M;return R._observers=this._observers.slice(0),R},M.prototype.hasSpecificMask=function(R){R===void 0&&(R=-1);for(var C=0,m=this._observers;C<m.length;C++){var c=m[C];if(c.mask&R||c.mask===R)return!0}return!1},M}()},function(Ae,v,f){f.d(v,"b",function(){return te}),f.d(v,"c",function(){return pe}),f.d(v,"a",function(){return K});var B=f(1),_=f(6),x=f(12),u=f(41),M=f(37),R=f(0),C=f(9),m=f(29),c=f(4),E=f(16),A=f(71),S=f(31),g=f(61),l=f(43),h=f(25),b=f(68),T=f(69),D=f(2),w=f(3),N=f(8),I=f(11),V=f(21),W=f(17),j=f(149),ne=f(70),te=function(){},de=function(){this.visibleInstances={},this.batchCache=new pe,this.instancesBufferSize=2048},pe=function(){this.mustReturn=!1,this.visibleInstances=new Array,this.renderSelf=new Array,this.hardwareInstancedRendering=new Array},ae=function(){this.instancesCount=0,this.matrixBuffer=null,this.matrixBufferSize=512,this.boundingVectors=[],this.worldMatrices=null},ee=function(){this._areNormalsFrozen=!1,this._source=null,this.meshMap=null,this._preActivateId=-1,this._LODLevels=new Array,this._morphTargetManager=null},K=function($){function L(G,Q,oe,re,Y,k){Q===void 0&&(Q=null),oe===void 0&&(oe=null),re===void 0&&(re=null),k===void 0&&(k=!0);var H=$.call(this,G,Q)||this;if(H._internalMeshDataInfo=new ee,H.delayLoadState=D.a.DELAYLOADSTATE_NONE,H.instances=new Array,H._creationDataStorage=null,H._geometry=null,H._instanceDataStorage=new de,H._thinInstanceDataStorage=new ae,H._effectiveMaterial=null,H._shouldGenerateFlatShading=!1,H._originalBuilderSideOrientation=L.DEFAULTSIDE,H.overrideMaterialSideOrientation=null,Q=H.getScene(),re){if(re._geometry&&re._geometry.applyToMesh(H),u.a.DeepCopy(re,H,["name","material","skeleton","instances","parent","uniqueId","source","metadata","morphTargetManager","hasInstances","source","worldMatrixInstancedBuffer","hasLODLevels","geometry","isBlocked","areNormalsFrozen","facetNb","isFacetDataEnabled","lightSources","useBones","isAnInstance","collider","edgesRenderer","forward","up","right","absolutePosition","absoluteScaling","absoluteRotationQuaternion","isWorldMatrixFrozen","nonUniformScaling","behaviors","worldMatrixFromCache","hasThinInstances","cloneMeshMap"],["_poseMatrix"]),H._internalMeshDataInfo._source=re,Q.useClonedMeshMap&&(re._internalMeshDataInfo.meshMap||(re._internalMeshDataInfo.meshMap={}),re._internalMeshDataInfo.meshMap[H.uniqueId]=H),H._originalBuilderSideOrientation=re._originalBuilderSideOrientation,H._creationDataStorage=re._creationDataStorage,re._ranges){var Z=re._ranges;for(var G in Z)Z.hasOwnProperty(G)&&Z[G]&&H.createAnimationRange(G,Z[G].from,Z[G].to)}var X;if(re.metadata&&re.metadata.clone?H.metadata=re.metadata.clone():H.metadata=re.metadata,M.a&&M.a.HasTags(re)&&M.a.AddTagsTo(H,M.a.GetTags(re,!0)),H.setEnabled(re.isEnabled()),H.parent=re.parent,H.setPivotMatrix(re.getPivotMatrix()),H.id=G+"."+re.id,H.material=re.material,!Y)for(var q=re.getDescendants(!0),he=0;he<q.length;he++){var ge=q[he];ge.clone&&ge.clone(G+"."+ge.name,H)}if(re.morphTargetManager&&(H.morphTargetManager=re.morphTargetManager),Q.getPhysicsEngine){var me=Q.getPhysicsEngine();if(k&&me){var _e=me.getImpostorForPhysicsObject(re);_e&&(H.physicsImpostor=_e.clone(H))}}for(X=0;X<Q.particleSystems.length;X++){var be=Q.particleSystems[X];be.emitter===re&&be.clone(be.name,H)}H.refreshBoundingInfo(),H.computeWorldMatrix(!0)}return oe!==null&&(H.parent=oe),H._instanceDataStorage.hardwareInstancedRendering=H.getEngine().getCaps().instancedArrays,H}return Object(B.d)(L,$),L._GetDefaultSideOrientation=function(G){return G||L.FRONTSIDE},Object.defineProperty(L.prototype,"computeBonesUsingShaders",{get:function(){return this._internalAbstractMeshDataInfo._computeBonesUsingShaders},set:function(G){this._internalAbstractMeshDataInfo._computeBonesUsingShaders!==G&&(G&&this._internalMeshDataInfo._sourcePositions&&(this.setVerticesData(c.b.PositionKind,this._internalMeshDataInfo._sourcePositions.slice(),!0),this._internalMeshDataInfo._sourceNormals&&this.setVerticesData(c.b.NormalKind,this._internalMeshDataInfo._sourceNormals.slice(),!0)),this._internalAbstractMeshDataInfo._computeBonesUsingShaders=G,this._markSubMeshesAsAttributesDirty())}
19,enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"onBeforeRenderObservable",{get:function(){return this._internalMeshDataInfo._onBeforeRenderObservable||(this._internalMeshDataInfo._onBeforeRenderObservable=new _.c),this._internalMeshDataInfo._onBeforeRenderObservable},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"onBeforeBindObservable",{get:function(){return this._internalMeshDataInfo._onBeforeBindObservable||(this._internalMeshDataInfo._onBeforeBindObservable=new _.c),this._internalMeshDataInfo._onBeforeBindObservable},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"onAfterRenderObservable",{get:function(){return this._internalMeshDataInfo._onAfterRenderObservable||(this._internalMeshDataInfo._onAfterRenderObservable=new _.c),this._internalMeshDataInfo._onAfterRenderObservable},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"onBeforeDrawObservable",{get:function(){return this._internalMeshDataInfo._onBeforeDrawObservable||(this._internalMeshDataInfo._onBeforeDrawObservable=new _.c),this._internalMeshDataInfo._onBeforeDrawObservable},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"onBeforeDraw",{set:function(G){this._onBeforeDrawObserver&&this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver),this._onBeforeDrawObserver=this.onBeforeDrawObservable.add(G)},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"hasInstances",{get:function(){return this.instances.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"hasThinInstances",{get:function(){var G;return((G=this._thinInstanceDataStorage.instancesCount)!==null&&G!==void 0?G:0)>0},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"morphTargetManager",{get:function(){return this._internalMeshDataInfo._morphTargetManager},set:function(G){this._internalMeshDataInfo._morphTargetManager!==G&&(this._internalMeshDataInfo._morphTargetManager=G,this._syncGeometryWithMorphTargetManager())},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"source",{get:function(){return this._internalMeshDataInfo._source},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"cloneMeshMap",{get:function(){return this._internalMeshDataInfo.meshMap},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"isUnIndexed",{get:function(){return this._unIndexed},set:function(G){this._unIndexed!==G&&(this._unIndexed=G,this._markSubMeshesAsAttributesDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"worldMatrixInstancedBuffer",{get:function(){return this._instanceDataStorage.instancesData},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"manualUpdateOfWorldMatrixInstancedBuffer",{get:function(){return this._instanceDataStorage.manualUpdate},set:function(G){this._instanceDataStorage.manualUpdate=G},enumerable:!1,configurable:!0}),L.prototype.instantiateHierarchy=function(G,Q,oe){G===void 0&&(G=null);var re=!(this.getTotalVertices()>0)||Q&&Q.doNotInstantiate?this.clone("Clone of "+(this.name||this.id),G||this.parent,!0):this.createInstance("instance of "+(this.name||this.id));re&&(re.parent=G||this.parent,re.position=this.position.clone(),re.scaling=this.scaling.clone(),this.rotationQuaternion?re.rotationQuaternion=this.rotationQuaternion.clone():re.rotation=this.rotation.clone(),oe&&oe(this,re));for(var Y=0,k=this.getChildTransformNodes(!0);Y<k.length;Y++)k[Y].instantiateHierarchy(re,Q,oe);return re},L.prototype.getClassName=function(){return"Mesh"},Object.defineProperty(L.prototype,"_isMesh",{get:function(){return!0},enumerable:!1,configurable:!0}),L.prototype.toString=function(G){var Q=$.prototype.toString.call(this,G);if(Q+=", n vertices: "+this.getTotalVertices(),Q+=", parent: "+(this._waitingParentId?this._waitingParentId:this.parent?this.parent.name:"NONE"),this.animations)for(var oe=0;oe<this.animations.length;oe++)Q+=", animation[0]: "+this.animations[oe].toString(G);if(G)if(this._geometry){var re=this.getIndices(),Y=this.getVerticesData(c.b.PositionKind);Y&&re&&(Q+=", flat shading: "+(Y.length/3===re.length?"YES":"NO"))}else Q+=", flat shading: UNKNOWN";return Q},L.prototype._unBindEffect=function(){$.prototype._unBindEffect.call(this);for(var G=0,Q=this.instances;G<Q.length;G++)Q[G]._unBindEffect()},Object.defineProperty(L.prototype,"hasLODLevels",{get:function(){return this._internalMeshDataInfo._LODLevels.length>0}
19,enumerable:!1,configurable:!0}),L.prototype.getLODLevels=function(){return this._internalMeshDataInfo._LODLevels},L.prototype._sortLODLevels=function(){this._internalMeshDataInfo._LODLevels.sort(function(G,Q){return G.distance<Q.distance?1:G.distance>Q.distance?-1:0})},L.prototype.addLODLevel=function(G,Q){if(Q&&Q._masterMesh)return N.a.Warn("You cannot use a mesh as LOD level twice"),this;var oe=new j.a(G,Q);return this._internalMeshDataInfo._LODLevels.push(oe),Q&&(Q._masterMesh=this),this._sortLODLevels(),this},L.prototype.getLODLevelAtDistance=function(G){for(var Q=this._internalMeshDataInfo,oe=0;oe<Q._LODLevels.length;oe++){var re=Q._LODLevels[oe];if(re.distance===G)return re.mesh}return null},L.prototype.removeLODLevel=function(G){for(var Q=this._internalMeshDataInfo,oe=0;oe<Q._LODLevels.length;oe++)Q._LODLevels[oe].mesh===G&&(Q._LODLevels.splice(oe,1),G&&(G._masterMesh=null));return this._sortLODLevels(),this},L.prototype.getLOD=function(G,Q){var oe,re=this._internalMeshDataInfo;if(!re._LODLevels||re._LODLevels.length===0)return this;Q?oe=Q:oe=this.getBoundingInfo().boundingSphere;var Y=oe.centerWorld.subtract(G.globalPosition).length();if(re._LODLevels[re._LODLevels.length-1].distance>Y)return this.onLODLevelSelection&&this.onLODLevelSelection(Y,this,this),this;for(var k=0;k<re._LODLevels.length;k++){var H=re._LODLevels[k];if(H.distance<Y){if(H.mesh){if(H.mesh.delayLoadState===D.a.DELAYLOADSTATE_NOTLOADED)return H.mesh._checkDelayState(),this;if(H.mesh.delayLoadState===D.a.DELAYLOADSTATE_LOADING)return this;H.mesh._preActivate(),H.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache)}return this.onLODLevelSelection&&this.onLODLevelSelection(Y,this,H.mesh),H.mesh}}return this.onLODLevelSelection&&this.onLODLevelSelection(Y,this,this),this},Object.defineProperty(L.prototype,"geometry",{get:function(){return this._geometry},enumerable:!1,configurable:!0}),L.prototype.getTotalVertices=function(){return this._geometry===null||this._geometry===void 0?0:this._geometry.getTotalVertices()},L.prototype.getVerticesData=function(G,Q,oe){return this._geometry?this._geometry.getVerticesData(G,Q,oe):null},L.prototype.getVertexBuffer=function(G){return this._geometry?this._geometry.getVertexBuffer(G):null},L.prototype.isVerticesDataPresent=function(G){return this._geometry?this._geometry.isVerticesDataPresent(G):!!this._delayInfo&&this._delayInfo.indexOf(G)!==-1},L.prototype.isVertexBufferUpdatable=function(G){return this._geometry?this._geometry.isVertexBufferUpdatable(G):!!this._delayInfo&&this._delayInfo.indexOf(G)!==-1},L.prototype.getVerticesDataKinds=function(){if(!this._geometry){var G=new Array;return this._delayInfo&&this._delayInfo.forEach(function(Q){G.push(Q)}),G}return this._geometry.getVerticesDataKinds()},L.prototype.getTotalIndices=function(){return this._geometry?this._geometry.getTotalIndices():0},L.prototype.getIndices=function(G,Q){return this._geometry?this._geometry.getIndices(G,Q):[]},Object.defineProperty(L.prototype,"isBlocked",{get:function(){return this._masterMesh!==null&&this._masterMesh!==void 0},enumerable:!1,configurable:!0}),L.prototype.isReady=function(G,Q){var oe,re,Y,k,H,Z;if(G===void 0&&(G=!1),Q===void 0&&(Q=!1),this.delayLoadState===D.a.DELAYLOADSTATE_LOADING||!$.prototype.isReady.call(this,G))return!1;if(!this.subMeshes||this.subMeshes.length===0||!G)return!0;var X=this.getEngine(),q=this.getScene(),he=Q||X.getCaps().instancedArrays&&(this.instances.length>0||this.hasThinInstances);this.computeWorldMatrix();var ge=this.material||q.defaultMaterial;if(ge){if(ge._storeEffectOnSubMeshes)for(var me=0,_e=this.subMeshes;me<_e.length;me++){var be=(He=_e[me]).getMaterial();if(be){if(be._storeEffectOnSubMeshes){if(!be.isReadyForSubMesh(this,He,he))return!1}else if(!be.isReady(this,he))return!1}}else if(!ge.isReady(this,he))return!1}for(var Ce=0,ye=this.lightSources;Ce<ye.length;Ce++){var Be=ye[Ce].getShadowGenerator();if(Be&&(!(!((oe=Be.getShadowMap())===null||oe===void 0)&&oe.renderList)||!((re=Be.getShadowMap())===null||re===void 0)&&re.renderList&&((k=(Y=Be.getShadowMap())===null||Y===void 0?void 0:Y.renderList)===null||k===void 0?void 0:k.indexOf(this))!==-1))for(var Ge=0,Xe=this.subMeshes;Ge<Xe.length;Ge++){var He=Xe[Ge];
19if(!Be.isReady(He,he,(Z=(H=He.getMaterial())===null||H===void 0?void 0:H.needAlphaBlendingForMesh(this))!==null&&Z!==void 0&&Z))return!1}}for(var We=0,Ze=this._internalMeshDataInfo._LODLevels;We<Ze.length;We++){var ze=Ze[We];if(ze.mesh&&!ze.mesh.isReady(he))return!1}return!0},Object.defineProperty(L.prototype,"areNormalsFrozen",{get:function(){return this._internalMeshDataInfo._areNormalsFrozen},enumerable:!1,configurable:!0}),L.prototype.freezeNormals=function(){return this._internalMeshDataInfo._areNormalsFrozen=!0,this},L.prototype.unfreezeNormals=function(){return this._internalMeshDataInfo._areNormalsFrozen=!1,this},Object.defineProperty(L.prototype,"overridenInstanceCount",{set:function(G){this._instanceDataStorage.overridenInstanceCount=G},enumerable:!1,configurable:!0}),L.prototype._preActivate=function(){var G=this._internalMeshDataInfo,Q=this.getScene().getRenderId();return G._preActivateId===Q||(G._preActivateId=Q,this._instanceDataStorage.visibleInstances=null),this},L.prototype._preActivateForIntermediateRendering=function(G){return this._instanceDataStorage.visibleInstances&&(this._instanceDataStorage.visibleInstances.intermediateDefaultRenderId=G),this},L.prototype._registerInstanceForRenderId=function(G,Q){return this._instanceDataStorage.visibleInstances||(this._instanceDataStorage.visibleInstances={defaultRenderId:Q,selfDefaultRenderId:this._renderId}),this._instanceDataStorage.visibleInstances[Q]||(this._instanceDataStorage.previousRenderId!==void 0&&this._instanceDataStorage.isFrozen&&(this._instanceDataStorage.visibleInstances[this._instanceDataStorage.previousRenderId]=null),this._instanceDataStorage.previousRenderId=Q,this._instanceDataStorage.visibleInstances[Q]=new Array),this._instanceDataStorage.visibleInstances[Q].push(G),this},L.prototype._afterComputeWorldMatrix=function(){$.prototype._afterComputeWorldMatrix.call(this),this.hasThinInstances&&(this.doNotSyncBoundingInfo||this.thinInstanceRefreshBoundingInfo(!1))},L.prototype._postActivate=function(){this.edgesShareWithInstances&&this.edgesRenderer&&this.edgesRenderer.isEnabled&&this._renderingGroup&&(this._renderingGroup._edgesRenderers.pushNoDuplicate(this.edgesRenderer),this.edgesRenderer.customInstances.push(this.getWorldMatrix()))},L.prototype.refreshBoundingInfo=function(G){if(G===void 0&&(G=!1),this._boundingInfo&&this._boundingInfo.isLocked)return this;var Q=this.geometry?this.geometry.boundingBias:null;return this._refreshBoundingInfo(this._getPositionData(G),Q),this},L.prototype._createGlobalSubMesh=function(G){var Q=this.getTotalVertices();if(!Q||!this.getIndices())return null;if(this.subMeshes&&this.subMeshes.length>0){var oe=this.getIndices();if(!oe)return null;var re=oe.length,Y=!1;if(G)Y=!0;else for(var k=0,H=this.subMeshes;k<H.length;k++){var Z=H[k];if(Z.indexStart+Z.indexCount>re){Y=!0;break}if(Z.verticesStart+Z.verticesCount>Q){Y=!0;break}}if(!Y)return this.subMeshes[0]}return this.releaseSubMeshes(),new g.a(0,0,Q,0,this.getTotalIndices(),this)},L.prototype.subdivide=function(G){if(!(G<1)){for(var Q=this.getTotalIndices(),oe=Q/G|0,re=0;oe%3!=0;)oe++;this.releaseSubMeshes();for(var Y=0;Y<G&&!(re>=Q);Y++)g.a.CreateFromIndices(0,re,Y===G-1?Q-re:oe,this),re+=oe;this.synchronizeInstances()}},L.prototype.setVerticesData=function(G,Q,oe,re){if(oe===void 0&&(oe=!1),this._geometry)this._geometry.setVerticesData(G,Q,oe,re);else{var Y=new E.a;Y.set(Q,G);var k=this.getScene();new A.a(A.a.RandomId(),k,Y,oe,this)}return this},L.prototype.removeVerticesData=function(G){this._geometry&&this._geometry.removeVerticesData(G)},L.prototype.markVerticesDataAsUpdatable=function(G,Q){Q===void 0&&(Q=!0);var oe=this.getVertexBuffer(G);oe&&oe.isUpdatable()!==Q&&this.setVerticesData(G,this.getVerticesData(G),Q)},L.prototype.setVerticesBuffer=function(G){return this._geometry||(this._geometry=A.a.CreateGeometryForMesh(this)),this._geometry.setVerticesBuffer(G),this},L.prototype.updateVerticesData=function(G,Q,oe,re){return this._geometry?(re?(this.makeGeometryUnique(),this.updateVerticesData(G,Q,oe,!1)):this._geometry.updateVerticesData(G,Q,oe),this):this},L.prototype.updateMeshPositions=function(G,Q){Q===void 0&&(Q=!0);var oe=this.getVerticesData(c.b.PositionKind);if(!oe)return this;if(G(oe),this.updateVerticesData(c.b.PositionKind,oe,!1,!1),Q){var re=this.getIndices(),Y=this.getVerticesData(c.b.NormalKind);if(!Y)return this;E.a.ComputeNormals(oe,re,Y),this.updateVerticesData(c.b.NormalKind,Y,!1,!1)}return this},L.prototype.makeGeometryUnique=function(){if(!this._geometry)return this;if(this._geometry.meshes.length===1)return this;var G=this._geometry,Q=this._geometry.copy(A.a.RandomId());return G.releaseForMesh(this,!0),Q.applyToMesh(this),this},L.prototype.setIndices=function(G,Q,oe){if(Q===void 0&&(Q=null),oe===void 0&&(oe=!1),this._geometry)this._geometry.setIndices(G,Q,oe);else{var re=new E.a;re.indices=G;var Y=this.getScene();new A.a(A.a.RandomId(),Y,re,oe,this)}return this},L.prototype.updateIndices=function(G,Q,oe){return oe===void 0&&(oe=!1),this._geometry?(this._geometry.updateIndices(G,Q,oe),this):this},L.prototype.toLeftHanded=function(){return this._geometry?(this._geometry.toLeftHanded(),this):this},L.prototype._bind=function(G,Q,oe){if(!this._geometry)return this;var re,Y=this.getScene().getEngine();if(this._unIndexed)re=null;else switch(oe){case h.a.PointFillMode:re=null;break;case h.a.WireFrameFillMode:re=G._getLinesIndexBuffer(this.getIndices(),Y);break;default:case h.a.TriangleFillMode:re=this._geometry.getIndexBuffer()}return this._geometry._bind(Q,re),this},L.prototype._draw=function(G,Q,oe){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;this._internalMeshDataInfo._onBeforeDrawObservable&&this._internalMeshDataInfo._onBeforeDrawObservable.notifyObservers(this);var re=this.getScene().getEngine();return this._unIndexed||Q==h.a.PointFillMode?re.drawArraysType(Q,G.verticesStart,G.verticesCount,oe):Q==h.a.WireFrameFillMode?re.drawElementsType(Q,0,G._linesIndexCount,oe):re.drawElementsType(Q,G.indexStart,G.indexCount,oe),this},L.prototype.registerBeforeRender=function(G){return this.onBeforeRenderObservable.add(G),this},L.prototype.unregisterBeforeRender=function(G){return this.onBeforeRenderObservable.removeCallback(G),this},L.prototype.registerAfterRender=function(G){return this.onAfterRenderObservable.add(G),this},L.prototype.unregisterAfterRender=function(G){return this.onAfterRenderObservable.removeCallback(G),this},L.prototype._getInstancesRenderList=function(G,Q){if(Q===void 0&&(Q=!1),this._instanceDataStorage.
19isFrozen&&this._instanceDataStorage.previousBatch)return this._instanceDataStorage.previousBatch;var oe=this.getScene(),re=oe._isInIntermediateRendering(),Y=re?this._internalAbstractMeshDataInfo._onlyForInstancesIntermediate:this._internalAbstractMeshDataInfo._onlyForInstances,k=this._instanceDataStorage.batchCache;if(k.mustReturn=!1,k.renderSelf[G]=Q||!Y&&this.isEnabled()&&this.isVisible,k.visibleInstances[G]=null,this._instanceDataStorage.visibleInstances&&!Q){var H=this._instanceDataStorage.visibleInstances,Z=oe.getRenderId(),X=re?H.intermediateDefaultRenderId:H.defaultRenderId;k.visibleInstances[G]=H[Z],!k.visibleInstances[G]&&X&&(k.visibleInstances[G]=H[X])}return k.hardwareInstancedRendering[G]=!Q&&this._instanceDataStorage.hardwareInstancedRendering&&k.visibleInstances[G]!==null&&k.visibleInstances[G]!==void 0,this._instanceDataStorage.previousBatch=k,k},L.prototype._renderWithInstances=function(G,Q,oe,re,Y){var k=oe.visibleInstances[G._id];if(!k)return this;for(var H=this._instanceDataStorage,Z=H.instancesBufferSize,X=H.instancesBuffer,q=16*(k.length+1)*4;H.instancesBufferSize<q;)H.instancesBufferSize*=2;H.instancesData&&Z==H.instancesBufferSize||(H.instancesData=new Float32Array(H.instancesBufferSize/4));var he=0,ge=0,me=oe.renderSelf[G._id],_e=!X||Z!==H.instancesBufferSize;if(this._instanceDataStorage.manualUpdate||H.isFrozen&&!_e)ge=(me?1:0)+k.length;else{var be=this._effectiveMesh.getWorldMatrix();if(me&&(be.copyToArray(H.instancesData,he),he+=16,ge++),k)for(var Ce=0;Ce<k.length;Ce++)k[Ce].getWorldMatrix().copyToArray(H.instancesData,he),he+=16,ge++}return _e?(X&&X.dispose(),X=new c.a(Y,H.instancesData,!0,16,!1,!0),H.instancesBuffer=X,this.setVerticesBuffer(X.createVertexBuffer("world0",0,4)),this.setVerticesBuffer(X.createVertexBuffer("world1",4,4)),this.setVerticesBuffer(X.createVertexBuffer("world2",8,4)),this.setVerticesBuffer(X.createVertexBuffer("world3",12,4))):this._instanceDataStorage.isFrozen||X.updateDirectly(H.instancesData,0,ge),this._processInstancedBuffers(k,me),this.getScene()._activeIndices.addCount(G.indexCount*ge,!1),this._bind(G,re,Q),this._draw(G,Q,ge),Y.unbindInstanceAttributes(),this},L.prototype._renderWithThinInstances=function(G,Q,oe,re){var Y,k,H=(k=(Y=this._thinInstanceDataStorage)===null||Y===void 0?void 0:Y.instancesCount)!==null&&k!==void 0?k:0;this.getScene()._activeIndices.addCount(G.indexCount*H,!1),this._bind(G,oe,Q),this._draw(G,Q,H),re.unbindInstanceAttributes()},L.prototype._processInstancedBuffers=function(G,Q){},L.prototype._processRendering=function(G,Q,oe,re,Y,k,H,Z){var X=this.getScene(),q=X.getEngine();if(k&&Q.getRenderingMesh().hasThinInstances)return this._renderWithThinInstances(Q,re,oe,q),this;if(k)this._renderWithInstances(Q,re,Y,oe,q);else{var he=0;Y.renderSelf[Q._id]&&(H&&H(!1,G._effectiveMesh.getWorldMatrix(),Z),he++,this._draw(Q,re,this._instanceDataStorage.overridenInstanceCount));var ge=Y.visibleInstances[Q._id];if(ge){var me=ge.length;he+=me;for(var _e=0;_e<me;_e++){var be=ge[_e].getWorldMatrix();H&&H(!0,be,Z),this._draw(Q,re)}}X._activeIndices.addCount(Q.indexCount*he,!1)}return this},L.prototype._rebuild=function(){this._instanceDataStorage.instancesBuffer&&(this._instanceDataStorage.instancesBuffer.dispose(),this._instanceDataStorage.instancesBuffer=null),$.prototype._rebuild.call(this)},L.prototype._freeze=function(){if(this.subMeshes){for(var G=0;G<this.subMeshes.length;G++)this._getInstancesRenderList(G);this._effectiveMaterial=null,this._instanceDataStorage.isFrozen=!0}},L.prototype._unFreeze=function(){this._instanceDataStorage.isFrozen=!1,this._instanceDataStorage.previousBatch=null},L.prototype.render=function(G,Q,oe){var re=this.getScene();if(this._internalAbstractMeshDataInfo._isActiveIntermediate?this._internalAbstractMeshDataInfo._isActiveIntermediate=!1:this._internalAbstractMeshDataInfo._isActive=!1,this._checkOcclusionQuery())return this;var Y=this._getInstancesRenderList(G._id,!!oe);if(Y.mustReturn)return this;if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;this._internalMeshDataInfo._onBeforeRenderObservable&&this._internalMeshDataInfo._onBeforeRenderObservable.notifyObservers(this);var k,H=re.getEngine(),Z=Y.hardwareInstancedRendering[G._id]||G.getRenderingMesh().hasThinInstances,X=this._instanceDataStorage,q=G.getMaterial();if(!q)return this;if(!X.isFrozen||!this._effectiveMaterial||this._effectiveMaterial!==q){if(q._storeEffectOnSubMeshes){if(!q.isReadyForSubMesh(this,G,Z))return this}else if(!q.isReady(this,Z))return this;this._effectiveMaterial=q}Q&&H.setAlphaMode(this._effectiveMaterial.alphaMode),k=this._effectiveMaterial._storeEffectOnSubMeshes?G.effect:this._effectiveMaterial.getEffect();for(var he=0,ge=re._beforeRenderingMeshStage;he<ge.length;he++)ge[he].action(this,G,Y,k);if(!k)return this;var me,_e=oe||this._effectiveMesh;if(X.isFrozen||!this._effectiveMaterial.backFaceCulling&&this.overrideMaterialSideOrientation===null)me=X.sideOrientation;else{var be=_e._getWorldMatrixDeterminant();(me=this.overrideMaterialSideOrientation)==null&&(me=this._effectiveMaterial.sideOrientation),be<0&&(me=me===h.a.ClockWiseSideOrientation?h.a.CounterClockWiseSideOrientation:h.a.ClockWiseSideOrientation),X.sideOrientation=me}var Ce=this._effectiveMaterial._preBind(k,me);this._effectiveMaterial.forceDepthWrite&&H.setDepthWrite(!0);var ye=re.forcePointsCloud?h.a.PointFillMode:re.forceWireframe?h.a.WireFrameFillMode:this._effectiveMaterial.fillMode;this._internalMeshDataInfo._onBeforeBindObservable&&this._internalMeshDataInfo._onBeforeBindObservable.notifyObservers(this),Z||this._bind(G,k,ye);var Be=_e.getWorldMatrix();this._effectiveMaterial._storeEffectOnSubMeshes?this._effectiveMaterial.bindForSubMesh(Be,this,G):this._effectiveMaterial.bind(Be,this),!this._effectiveMaterial.backFaceCulling&&this._effectiveMaterial.separateCullingPass&&(H.setState(!0,this._effectiveMaterial.zOffset,!1,!Ce),this._processRendering(this,G,k,ye,Y,Z,this._onBeforeDraw,this._effectiveMaterial),H.setState(!0,this._effectiveMaterial.zOffset,!1,Ce)),this._processRendering(this,G,k,ye,Y,Z,this._onBeforeDraw,this._effectiveMaterial),this._effectiveMaterial.unbind();for(var Ge=0,Xe=re._afterRenderingMeshStage;Ge<Xe.length;Ge++)Xe[Ge].action(this,G,Y,k);return this._internalMeshDataInfo._onAfterRenderObservable&&this._internalMeshDataInfo._onAfterRenderObservable.notifyObservers(this),this}
19,L.prototype._onBeforeDraw=function(G,Q,oe){G&&oe&&oe.bindOnlyWorldMatrix(Q)},L.prototype.cleanMatrixWeights=function(){this.isVerticesDataPresent(c.b.MatricesWeightsKind)&&(this.isVerticesDataPresent(c.b.MatricesWeightsExtraKind)?this.normalizeSkinWeightsAndExtra():this.normalizeSkinFourWeights())},L.prototype.normalizeSkinFourWeights=function(){for(var G=this.getVerticesData(c.b.MatricesWeightsKind),Q=G.length,oe=0;oe<Q;oe+=4){var re=G[oe]+G[oe+1]+G[oe+2]+G[oe+3];if(re===0)G[oe]=1;else{var Y=1/re;G[oe]*=Y,G[oe+1]*=Y,G[oe+2]*=Y,G[oe+3]*=Y}}this.setVerticesData(c.b.MatricesWeightsKind,G)},L.prototype.normalizeSkinWeightsAndExtra=function(){for(var G=this.getVerticesData(c.b.MatricesWeightsExtraKind),Q=this.getVerticesData(c.b.MatricesWeightsKind),oe=Q.length,re=0;re<oe;re+=4){var Y=Q[re]+Q[re+1]+Q[re+2]+Q[re+3];if((Y+=G[re]+G[re+1]+G[re+2]+G[re+3])===0)Q[re]=1;else{var k=1/Y;Q[re]*=k,Q[re+1]*=k,Q[re+2]*=k,Q[re+3]*=k,G[re]*=k,G[re+1]*=k,G[re+2]*=k,G[re+3]*=k}}this.setVerticesData(c.b.MatricesWeightsKind,Q),this.setVerticesData(c.b.MatricesWeightsKind,G)},L.prototype.validateSkinning=function(){var G=this.getVerticesData(c.b.MatricesWeightsExtraKind),Q=this.getVerticesData(c.b.MatricesWeightsKind);if(Q===null||this.skeleton==null)return{skinned:!1,valid:!0,report:"not skinned"};for(var oe=Q.length,re=0,Y=0,k=0,H=0,Z=G===null?4:8,X=new Array,q=0;q<=Z;q++)X[q]=0;for(q=0;q<oe;q+=4){for(var he=Q[q],ge=he,me=ge===0?0:1,_e=1;_e<Z;_e++){var be=_e<4?Q[q+_e]:G[q+_e-4];be>he&&re++,be!==0&&me++,ge+=be,he=be}if(X[me]++,me>k&&(k=me),ge===0)Y++;else{var Ce=1/ge,ye=0;for(_e=0;_e<Z;_e++)ye+=_e<4?Math.abs(Q[q+_e]-Q[q+_e]*Ce):Math.abs(G[q+_e-4]-G[q+_e-4]*Ce);ye>.001&&H++}}var Be=this.skeleton.bones.length,Ge=this.getVerticesData(c.b.MatricesIndicesKind),Xe=this.getVerticesData(c.b.MatricesIndicesExtraKind),He=0;for(q=0;q<oe;q+=4)for(_e=0;_e<Z;_e++){var We=_e<4?Ge[q+_e]:Xe[q+_e-4];(We>=Be||We<0)&&He++}return{skinned:!0,valid:Y===0&&H===0&&He===0,report:"Number of Weights = "+oe/4+`
20Maximum influences = `+k+`
21Missing Weights = `+Y+`
22Not Sorted = `+re+`
23Not Normalized = `+H+`
24WeightCounts = [`+X+`]
25Number of bones = `+Be+`
26Bad Bone Indices = `+He}},L.prototype._checkDelayState=function(){var G=this.getScene();return this._geometry?this._geometry.load(G):this.delayLoadState===D.a.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=D.a.DELAYLOADSTATE_LOADING,this._queueLoad(G)),this},L.prototype._queueLoad=function(G){var Q=this;G._addPendingData(this);var oe=this.delayLoadingFile.indexOf(".babylonbinarymeshdata")!==-1;return x.b.LoadFile(this.delayLoadingFile,function(re){re instanceof ArrayBuffer?Q._delayLoadingFunction(re,Q):Q._delayLoadingFunction(JSON.parse(re),Q),Q.instances.forEach(function(Y){Y.refreshBoundingInfo(),Y._syncSubMeshes()}),Q.delayLoadState=D.a.DELAYLOADSTATE_LOADED,G._removePendingData(Q)},function(){},G.offlineProvider,oe),this},L.prototype.isInFrustum=function(G){return this.delayLoadState!==D.a.DELAYLOADSTATE_LOADING&&!!$.prototype.isInFrustum.call(this,G)&&(this._checkDelayState(),!0)},L.prototype.setMaterialByID=function(G){var Q,oe=this.getScene().materials;for(Q=oe.length-1;Q>-1;Q--)if(oe[Q].id===G)return this.material=oe[Q],this;var re=this.getScene().multiMaterials;for(Q=re.length-1;Q>-1;Q--)if(re[Q].id===G)return this.material=re[Q],this;return this},L.prototype.getAnimatables=function(){var G=new Array;return this.material&&G.push(this.material),this.skeleton&&G.push(this.skeleton),G},L.prototype.bakeTransformIntoVertices=function(G){if(!this.isVerticesDataPresent(c.b.PositionKind))return this;var Q=this.subMeshes.splice(0);this._resetPointsArrayCache();var oe,re=this.getVerticesData(c.b.PositionKind),Y=new Array;for(oe=0;oe<re.length;oe+=3)R.e.TransformCoordinates(R.e.FromArray(re,oe),G).toArray(Y,oe);if(this.setVerticesData(c.b.PositionKind,Y,this.getVertexBuffer(c.b.PositionKind).isUpdatable()),this.isVerticesDataPresent(c.b.NormalKind)){for(re=this.getVerticesData(c.b.NormalKind),Y=[],oe=0;oe<re.length;oe+=3)R.e.TransformNormal(R.e.FromArray(re,oe),G).normalize().toArray(Y,oe);this.setVerticesData(c.b.NormalKind,Y,this.getVertexBuffer(c.b.NormalKind).isUpdatable())}return G.m[0]*G.m[5]*G.m[10]<0&&this.flipFaces(),this.releaseSubMeshes(),this.subMeshes=Q,this},L.prototype.bakeCurrentTransformIntoVertices=function(G){return G===void 0&&(G=!0),this.bakeTransformIntoVertices(this.computeWorldMatrix(!0)),this.resetLocalMatrix(G),this},Object.defineProperty(L.prototype,"_positions",{get:function(){return this._geometry?this._geometry._positions:null}
26,enumerable:!1,configurable:!0}),L.prototype._resetPointsArrayCache=function(){return this._geometry&&this._geometry._resetPointsArrayCache(),this},L.prototype._generatePointsArray=function(){return!!this._geometry&&this._geometry._generatePointsArray()},L.prototype.clone=function(G,Q,oe,re){return G===void 0&&(G=""),Q===void 0&&(Q=null),re===void 0&&(re=!0),new L(G,this.getScene(),Q,this,oe,re)},L.prototype.dispose=function(G,Q){Q===void 0&&(Q=!1),this.morphTargetManager=null,this._geometry&&this._geometry.releaseForMesh(this,!0);var oe=this._internalMeshDataInfo;if(oe._onBeforeDrawObservable&&oe._onBeforeDrawObservable.clear(),oe._onBeforeBindObservable&&oe._onBeforeBindObservable.clear(),oe._onBeforeRenderObservable&&oe._onBeforeRenderObservable.clear(),oe._onAfterRenderObservable&&oe._onAfterRenderObservable.clear(),this._scene.useClonedMeshMap){if(oe.meshMap)for(var re in oe.meshMap)(H=oe.meshMap[re])&&(H._internalMeshDataInfo._source=null,oe.meshMap[re]=void 0);oe._source&&oe._source._internalMeshDataInfo.meshMap&&(oe._source._internalMeshDataInfo.meshMap[this.uniqueId]=void 0)}else for(var Y=0,k=this.getScene().meshes;Y<k.length;Y++){var H;(H=k[Y])._internalMeshDataInfo&&H._internalMeshDataInfo._source&&H._internalMeshDataInfo._source===this&&(H._internalMeshDataInfo._source=null)}oe._source=null,this._disposeInstanceSpecificData(),this._disposeThinInstanceSpecificData(),$.prototype.dispose.call(this,G,Q)},L.prototype._disposeInstanceSpecificData=function(){},L.prototype._disposeThinInstanceSpecificData=function(){},L.prototype.applyDisplacementMap=function(G,Q,oe,re,Y,k,H){var Z=this;H===void 0&&(H=!1);var X=this.getScene();return x.b.LoadImage(G,function(q){var he=q.width,ge=q.height,me=ne.a.CreateCanvas(he,ge).getContext("2d");me.drawImage(q,0,0);var _e=me.getImageData(0,0,he,ge).data;Z.applyDisplacementMapFromBuffer(_e,he,ge,Q,oe,Y,k,H),re&&re(Z)},function(){},X.offlineProvider),this},L.prototype.applyDisplacementMapFromBuffer=function(G,Q,oe,re,Y,k,H,Z){if(Z===void 0&&(Z=!1),!this.isVerticesDataPresent(c.b.PositionKind)||!this.isVerticesDataPresent(c.b.NormalKind)||!this.isVerticesDataPresent(c.b.UVKind))return N.a.Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing"),this;var X=this.getVerticesData(c.b.PositionKind,!0,!0),q=this.getVerticesData(c.b.NormalKind),he=this.getVerticesData(c.b.UVKind),ge=R.e.Zero(),me=R.e.Zero(),_e=R.d.Zero();k=k||R.d.Zero(),H=H||new R.d(1,1);for(var be=0;be<X.length;be+=3){R.e.FromArrayToRef(X,be,ge),R.e.FromArrayToRef(q,be,me),R.d.FromArrayToRef(he,be/3*2,_e);var Ce=4*((Math.abs(_e.x*H.x+k.x%1)*(Q-1)%Q|0)+(Math.abs(_e.y*H.y+k.y%1)*(oe-1)%oe|0)*Q),ye=.3*(G[Ce]/255)+.59*(G[Ce+1]/255)+.11*(G[Ce+2]/255);me.normalize(),me.scaleInPlace(re+(Y-re)*ye),(ge=ge.add(me)).toArray(X,be)}return E.a.ComputeNormals(X,this.getIndices(),q),Z?(this.setVerticesData(c.b.PositionKind,X),this.setVerticesData(c.b.NormalKind,q)):(this.updateVerticesData(c.b.PositionKind,X),this.updateVerticesData(c.b.NormalKind,q)),this},L.prototype.convertToFlatShadedMesh=function(){var G,Q,oe=this.getVerticesDataKinds(),re={},Y={},k={},H=!1;for(G=0;G<oe.length;G++){Q=oe[G];var Z=this.getVertexBuffer(Q);Q!==c.b.NormalKind?(re[Q]=Z,Y[Q]=re[Q].getData(),k[Q]=[]):(H=Z.isUpdatable(),oe.splice(G,1),G--)}var X,q=this.subMeshes.slice(0),he=this.getIndices(),ge=this.getTotalIndices();for(X=0;X<ge;X++){var me=he[X];for(G=0;G<oe.length;G++)for(var _e=re[Q=oe[G]].getStrideSize(),be=0;be<_e;be++)k[Q].push(Y[Q][me*_e+be])}var Ce=[],ye=k[c.b.PositionKind];for(X=0;X<ge;X+=3){he[X]=X,he[X+1]=X+1,he[X+2]=X+2;for(var Be=R.e.FromArray(ye,3*X),Ge=R.e.FromArray(ye,3*(X+1)),Xe=R.e.FromArray(ye,3*(X+2)),He=Be.subtract(Ge),We=Xe.subtract(Ge),Ze=R.e.Normalize(R.e.Cross(He,We)),ze=0;ze<3;ze++)Ce.push(Ze.x),Ce.push(Ze.y),Ce.push(Ze.z)}for(this.setIndices(he),this.setVerticesData(c.b.NormalKind,Ce,H),G=0;G<oe.length;G++)Q=oe[G],this.setVerticesData(Q,k[Q],re[Q].isUpdatable());this.releaseSubMeshes();for(var it=0;
26it<q.length;it++){var et=q[it];g.a.AddToMesh(et.materialIndex,et.indexStart,et.indexCount,et.indexStart,et.indexCount,this)}return this.synchronizeInstances(),this},L.prototype.convertToUnIndexedMesh=function(){var G,Q,oe=this.getVerticesDataKinds(),re={},Y={},k={};for(G=0;G<oe.length;G++){Q=oe[G];var H=this.getVertexBuffer(Q);re[Q]=H,Y[Q]=re[Q].getData(),k[Q]=[]}var Z,X=this.subMeshes.slice(0),q=this.getIndices(),he=this.getTotalIndices();for(Z=0;Z<he;Z++){var ge=q[Z];for(G=0;G<oe.length;G++)for(var me=re[Q=oe[G]].getStrideSize(),_e=0;_e<me;_e++)k[Q].push(Y[Q][ge*me+_e])}for(Z=0;Z<he;Z+=3)q[Z]=Z,q[Z+1]=Z+1,q[Z+2]=Z+2;for(this.setIndices(q),G=0;G<oe.length;G++)Q=oe[G],this.setVerticesData(Q,k[Q],re[Q].isUpdatable());this.releaseSubMeshes();for(var be=0;be<X.length;be++){var Ce=X[be];g.a.AddToMesh(Ce.materialIndex,Ce.indexStart,Ce.indexCount,Ce.indexStart,Ce.indexCount,this)}return this._unIndexed=!0,this.synchronizeInstances(),this},L.prototype.flipFaces=function(G){G===void 0&&(G=!1);var Q,oe,re=E.a.ExtractFromMesh(this);if(G&&this.isVerticesDataPresent(c.b.NormalKind)&&re.normals)for(Q=0;Q<re.normals.length;Q++)re.normals[Q]*=-1;if(re.indices)for(Q=0;Q<re.indices.length;Q+=3)oe=re.indices[Q+1],re.indices[Q+1]=re.indices[Q+2],re.indices[Q+2]=oe;return re.applyToMesh(this,this.isVertexBufferUpdatable(c.b.PositionKind)),this},L.prototype.increaseVertices=function(G){var Q=E.a.ExtractFromMesh(this),oe=Q.uvs,re=Q.indices,Y=Q.positions,k=Q.normals;if(re&&Y&&k&&oe){for(var H,Z,X=G+1,q=new Array,he=0;he<X+1;he++)q[he]=new Array;var ge,me=new R.e(0,0,0),_e=new R.e(0,0,0),be=new R.d(0,0),Ce=new Array,ye=new Array,Be=new Array,Ge=Y.length,Xe=oe.length;for(he=0;he<re.length;he+=3){ye[0]=re[he],ye[1]=re[he+1],ye[2]=re[he+2];for(var He=0;He<3;He++)if(H=ye[He],Z=ye[(He+1)%3],Be[H]===void 0&&Be[Z]===void 0?(Be[H]=new Array,Be[Z]=new Array):(Be[H]===void 0&&(Be[H]=new Array),Be[Z]===void 0&&(Be[Z]=new Array)),Be[H][Z]===void 0&&Be[Z][H]===void 0){Be[H][Z]=[],me.x=(Y[3*Z]-Y[3*H])/X,me.y=(Y[3*Z+1]-Y[3*H+1])/X,me.z=(Y[3*Z+2]-Y[3*H+2])/X,_e.x=(k[3*Z]-k[3*H])/X,_e.y=(k[3*Z+1]-k[3*H+1])
26/X,_e.z=(k[3*Z+2]-k[3*H+2])/X,be.x=(oe[2*Z]-oe[2*H])/X,be.y=(oe[2*Z+1]-oe[2*H+1])/X,Be[H][Z].push(H);for(var We=1;We<X;We++)Be[H][Z].push(Y.length/3),Y[Ge]=Y[3*H]+We*me.x,k[Ge++]=k[3*H]+We*_e.x,Y[Ge]=Y[3*H+1]+We*me.y,k[Ge++]=k[3*H+1]+We*_e.y,Y[Ge]=Y[3*H+2]+We*me.z,k[Ge++]=k[3*H+2]+We*_e.z,oe[Xe++]=oe[2*H]+We*be.x,oe[Xe++]=oe[2*H+1]+We*be.y;Be[H][Z].push(Z),Be[Z][H]=new Array,ge=Be[H][Z].length;for(var Ze=0;Ze<ge;Ze++)Be[Z][H][Ze]=Be[H][Z][ge-1-Ze]}for(q[0][0]=re[he],q[1][0]=Be[re[he]][re[he+1]][1],q[1][1]=Be[re[he]][re[he+2]][1],We=2;We<X;We++)for(q[We][0]=Be[re[he]][re[he+1]][We],q[We][We]=Be[re[he]][re[he+2]][We],me.x=(Y[3*q[We][We]]-Y[3*q[We][0]])/We,me.y=(Y[3*q[We][We]+1]-Y[3*q[We][0]+1])/We,me.z=(Y[3*q[We][We]+2]-Y[3*q[We][0]+2])/We,_e.x=(k[3*q[We][We]]-k[3*q[We][0]])/We,_e.y=(k[3*q[We][We]+1]-k[3*q[We][0]+1])/We,_e.z=(k[3*q[We][We]+2]-k[3*q[We][0]+2])/We,be.x=(oe[2*q[We][We]]-oe[2*q[We][0]])/We,be.y=(oe[2*q[We][We]+1]-oe[2*q[We][0]+1])/We,He=1;He<We;He++)q[We][He]=Y.length/3,Y[Ge]=Y[3*q[We][0]]+He*me.x,k[Ge++]=k[3*q[We][0]]+He*_e.x,Y[Ge]=Y[3*q[We][0]+1]+He*me.y,k[Ge++]=k[3*q[We][0]+1]+He*_e.y,Y[Ge]=Y[3*q[We][0]+2]+He*me.z,k[Ge++]=k[3*q[We][0]+2]+He*_e.z,oe[Xe++]=oe[2*q[We][0]]+He*be.x,oe[Xe++]=oe[2*q[We][0]+1]+He*be.y;for(q[X]=Be[re[he+1]][re[he+2]],Ce.push(q[0][0],q[1][0],q[1][1]),We=1;We<X;We++){for(He=0;He<We;He++)Ce.push(q[We][He],q[We+1][He],q[We+1][He+1]),Ce.push(q[We][He],q[We+1][He+1],q[We][He+1]);Ce.push(q[We][He],q[We+1][He],q[We+1][He+1])}}Q.indices=Ce,Q.applyToMesh(this,this.isVertexBufferUpdatable(c.b.PositionKind))}else N.a.Warn("VertexData contains null entries")},L.prototype.forceSharedVertices=function(){var G=E.a.ExtractFromMesh(this),Q=G.uvs,oe=G.indices,re=G.positions,Y=G.colors;if(oe===void 0||re===void 0||oe===null||re===null)N.a.Warn("VertexData contains empty entries");else{for(var k,H,Z=new Array,X=new Array,q=new Array,he=new Array,ge=new Array,me=0,_e={},be=0;be<oe.length;be+=3){H=[oe[be],oe[be+1],oe[be+2]],ge=new Array;for(var Ce=0;Ce<3;Ce++){ge[Ce]="";for(var ye=0;ye<3;ye++)Math.abs(re[3*H[Ce]+ye])<1e-8&&(re[3*H[Ce]+ye]=0),ge[Ce]+=re[3*H[Ce]+ye]+"|"}if(ge[0]!=ge[1]&&ge[0]!=ge[2]&&ge[1]!=ge[2])for(Ce=0;Ce<3;Ce++){if((k=_e[ge[Ce]])===void 0){for(_e[ge[Ce]]=me,k=me++,ye=0;ye<3;ye++)Z.push(re[3*H[Ce]+ye]);if(Y!=null)for(ye=0;ye<4;ye++)he.push(Y[4*H[Ce]+ye]);if(Q!=null)for(ye=0;ye<2;ye++)q.push(Q[2*H[Ce]+ye])}X.push(k)}}var Be=new Array;E.a.ComputeNormals(Z,X,Be),G.positions=Z,G.indices=X,G.normals=Be,Q!=null&&(G.uvs=q),Y!=null&&(G.colors=he),G.applyToMesh(this,this.isVertexBufferUpdatable(c.b.PositionKind))}},L._instancedMeshFactory=function(G,Q){throw V.a.WarnImport("InstancedMesh")},L._PhysicsImpostorParser=function(G,Q,oe){throw V.a.WarnImport("PhysicsImpostor")},L.prototype.createInstance=function(G){var Q=this.geometry;if(Q&&Q.meshes.length>1)for(var oe=0,re=Q.meshes.slice(0);oe<re.length;oe++){var Y=re[oe];Y!==this&&Y.makeGeometryUnique()}return L._instancedMeshFactory(G,this)},L.prototype.synchronizeInstances=function(){this._geometry&&this._geometry.meshes.length!==1&&this.instances.length&&this.makeGeometryUnique();for(var G=0;G<this.instances.length;G++)this.instances[G]._syncSubMeshes();return this},L.prototype.optimizeIndices=function(G){var Q=this,oe=this.getIndices(),re=this.getVerticesData(c.b.PositionKind);if(!re||!oe)return this;for(var Y=new Array,k=0;k<re.length;k+=3)Y.push(R.e.FromArray(re,k));var H=new Array;return x.a.SyncAsyncForLoop(Y.length,40,function(Z){for(var X=Y.length-1-Z,q=Y[X],he=0;he<X;++he){var ge=Y[he];if(q.equals(ge)){H[X]=he;break}}},function(){for(var Z=0;Z<oe.length;++Z)oe[Z]=H[oe[Z]]||oe[Z];var X=Q.subMeshes.slice(0);Q.setIndices(oe),Q.subMeshes=X,G&&G(Q)}),this},L.prototype.serialize=function(G){G.name=this.name,G.id=this.id,G.uniqueId=this.uniqueId,G.type=this.getClassName(),M.a&&M.a.HasTags(this)&&(G.tags=M.a.GetTags(this)),G.position=this.position.asArray(),this.rotationQuaternion?G.rotationQuaternion=this.rotationQuaternion.asArray():this.rotation&&(G.rotation=this.rotation.asArray()),G.scaling=this.scaling.asArray(),this._postMultiplyPivotMatrix?G.pivotMatrix=this.getPivotMatrix().asArray():G.localMatrix=this.getPivotMatrix().asArray(),G.isEnabled=this.isEnabled(!1),G.isVisible=this.isVisible,G.infiniteDistance=this.infiniteDistance,G.pickable=this.isPickable,G.receiveShadows=this.receiveShadows,G.billboardMode=this.billboardMode,G.visibility=this.visibility,G.checkCollisions=this.checkCollisions,G.isBlocker=this.isBlocker,G.overrideMaterialSideOrientation=this.overrideMaterialSideOrientation,this.parent&&(G.parentId=this.parent.id),G.isUnIndexed=this.isUnIndexed;var Q=this._geometry;if(Q){var oe=Q.id;G.geometryId=oe,G.subMeshes=[];for(var re=0;re<this.subMeshes.length;re++){var Y=this.subMeshes[re];G.subMeshes.push({materialIndex:Y.materialIndex,verticesStart:Y.verticesStart,verticesCount:Y.verticesCount,indexStart:Y.indexStart,indexCount:Y.indexCount})}}this.material?this.material.doNotSerialize||(G.materialId=this.material.id):this.material=null,this.morphTargetManager&&(G.morphTargetManagerId=this.morphTargetManager.uniqueId),this.skeleton&&(G.skeletonId=this.skeleton.id,G.numBoneInfluencers=this.numBoneInfluencers),this.get
26Scene()._getComponent(W.a.NAME_PHYSICSENGINE)&&(Z=this.getPhysicsImpostor())&&(G.physicsMass=Z.getParam("mass"),G.physicsFriction=Z.getParam("friction"),G.physicsRestitution=Z.getParam("mass"),G.physicsImpostor=Z.type),this.metadata&&(G.metadata=this.metadata),G.instances=[];for(var k=0;k<this.instances.length;k++){var H=this.instances[k];if(!H.doNotSerialize){var Z,X={name:H.name,id:H.id,isEnabled:H.isEnabled(!1),isVisible:H.isVisible,isPickable:H.isPickable,checkCollisions:H.checkCollisions,position:H.position.asArray(),scaling:H.scaling.asArray()};H.parent&&(X.parentId=H.parent.id),H.rotationQuaternion?X.rotationQuaternion=H.rotationQuaternion.asArray():H.rotation&&(X.rotation=H.rotation.asArray()),this.getScene()._getComponent(W.a.NAME_PHYSICSENGINE)&&(Z=H.getPhysicsImpostor())&&(X.physicsMass=Z.getParam("mass"),X.physicsFriction=Z.getParam("friction"),X.physicsRestitution=Z.getParam("mass"),X.physicsImpostor=Z.type),H.metadata&&(X.metadata=H.metadata),G.instances.push(X),w.a.AppendSerializedAnimations(H,X),X.ranges=H.serializeAnimationRanges()}}if(this._thinInstanceDataStorage.instancesCount&&this._thinInstanceDataStorage.matrixData&&(G.thinInstances={instancesCount:this._thinInstanceDataStorage.instancesCount,matrixData:x.b.SliceToArray(this._thinInstanceDataStorage.matrixData),matrixBufferSize:this._thinInstanceDataStorage.matrixBufferSize},this._userThinInstanceBuffersStorage)){var q={data:{},sizes:{},strides:{}};for(var he in this._userThinInstanceBuffersStorage.data)q.data[he]=x.b.SliceToArray(this._userThinInstanceBuffersStorage.data[he]),q.sizes[he]=this._userThinInstanceBuffersStorage.sizes[he],q.strides[he]=this._userThinInstanceBuffersStorage.strides[he];G.thinInstances.userThinInstance=q}w.a.AppendSerializedAnimations(this,G),G.ranges=this.serializeAnimationRanges(),G.layerMask=this.layerMask,G.alphaIndex=this.alphaIndex,G.hasVertexAlpha=this.hasVertexAlpha,G.overlayAlpha=this.overlayAlpha,G.overlayColor=this.overlayColor.asArray(),G.renderOverlay=this.renderOverlay,G.applyFog=this.applyFog,this.actionManager&&(G.actions=this.actionManager.serialize(this.name))},L.prototype._syncGeometryWithMorphTargetManager=function(){if(this.geometry){this._markSubMeshesAsAttributesDirty();var G=this._internalMeshDataInfo._morphTargetManager;if(G&&G.vertexCount){if(G.vertexCount!==this.getTotalVertices())return N.a.Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count."),void(this.morphTargetManager=null);for(var Q=0;Q<G.numInfluencers;Q++){var oe=G.getActiveTarget(Q),re=oe.getPositions();if(!re)return void N.a.Error("Invalid morph target. Target must have positions.");this.geometry.setVerticesData(c.b.PositionKind+Q,re,!1,3);var Y=oe.getNormals();Y&&this.geometry.setVerticesData(c.b.NormalKind+Q,Y,!1,3);var k=oe.getTangents();k&&this.geometry.setVerticesData(c.b.TangentKind+Q,k,!1,3);var H=oe.getUVs();H&&this.geometry.setVerticesData(c.b.UVKind+"_"+Q,H,!1,2)}}else for(Q=0;this.geometry.isVerticesDataPresent(c.b.PositionKind+Q);)this.geometry.removeVerticesData(c.b.PositionKind+Q),this.geometry.isVerticesDataPresent(c.b.NormalKind+Q)&&this.geometry.removeVerticesData(c.b.NormalKind+Q),this.geometry.isVerticesDataPresent(c.b.TangentKind+Q)&&this.geometry.removeVerticesData(c.b.TangentKind+Q),this.geometry.isVerticesDataPresent(c.b.UVKind+Q)&&this.geometry.removeVerticesData(c.b.UVKind+"_"+Q),Q++}},L.Parse=function(G,Q,oe){var re;if((re=G.type&&G.type==="GroundMesh"?L._GroundMeshParser(G,Q):new L(G.name,Q)).id=G.id,M.a&&M.a.AddTagsTo(re,G.tags),re.position=R.e.FromArray(G.position),G.metadata!==void 0&&(re.metadata=G.metadata),G.rotationQuaternion?re.rotationQuaternion=R.b.FromArray(G.rotationQuaternion):G.rotation&&(re.rotation=R.e.FromArray(G.rotation)),re.scaling=R.e.FromArray(G.scaling),G.localMatrix?re.setPreTransformMatrix(R.a.FromArray(G.localMatrix)):G.pivotMatrix&&re.setPivotMatrix(R.a.FromArray(G.pivotMatrix)),re.setEnabled(G.isEnabled),re.isVisible=G.isVisible,re.infiniteDistance=G.infiniteDistance,re.showBoundingBox=G.showBoundingBox,re.showSubMeshesBoundingBox=G.showSubMeshesBoundingBox,G.applyFog!==void 0&&(re.applyFog=G.applyFog),G.pickable!==void 0&&(re.isPickable=G.pickable),G.alphaIndex!==void 0&&(re.alphaIndex=G.alphaIndex),re.receiveShadows=G.receiveShadows,re.billboardMode=G.billboardMode,G.visibility!==void 0&&(re.visibility=G.visibility),re.checkCollisions=G.checkCollisions,re.overrideMaterialSideOrientation=G.overrideMaterialSideOrientation,G.isBlocker!==void 0&&(re.isBlocker=G.isBlocker),re._shouldGenerateFlatShading=G.useFlatShading,G.freezeWorldMatrix&&(re._waitingData.freezeWorldMatrix=G.freezeWorldMatrix),G.parentId&&(re._waitingParentId=G.parentId),G.actions!==void 0&&(re._waitingData.actions=G.actions),G.overlayAlpha!==void 0&&(re.overlayAlpha=G.overlayAlpha),G.overlayColor!==void 0&&(re.overlayColor=C.a.FromArray(G.overlayColor)),G.renderOverlay!==void 0&&(re.renderOverlay=G.renderOverlay),re.isUnIndexed=!!G.isUnIndexed,re.hasVertexAlpha=G.hasVertexAlpha,G.delayLoadingFile?(re.delayLoadState=D.a.DELAYLOADSTATE_NOTLOADED,re.delayLoadingFile=oe+G.delayLoadingFile,re._boundingInfo=new l.a(R.e.FromArray(G.boundingBoxMinimum),R.e.FromArray(G.boundingBoxMaximum)),G._binaryInfo&&(re._binaryInfo=G._binaryInfo),re._delayInfo=[],G.hasUVs&&re._delayInfo.push(c.b.UVKind),G.hasUVs2&&re._delayInfo.push(c.b.UV2Kind),G.hasUVs3&&re._delayInfo.push(c.b.UV3Kind),G.hasUVs4&&re._delayInfo.push(c.b.UV4Kind),G.hasUVs5&&re._delayInfo.push(c.b.UV5Kind),G.hasUVs6&&re._delayInfo.push(c.b.UV6Kind),G.hasColors&&re._delayInfo.push(c.b.ColorKind),G.hasMatricesIndices&&re._delayInfo.push(c.b.MatricesIndicesKind),G.hasMatricesWeights&&re._delayInfo.push(c.b.MatricesWeightsKind),re._delayLoadingFunction=A.a._ImportGeometry,T.a.ForceFullSceneLoadingForIncremental&&re._checkDelayState()):A.a._ImportGeometry(G,re),G.materialId?re.setMaterialByID(G.materialId):re.material=null,G.morphTargetManagerId>-1&&(re.morphTargetManager=Q.getMorphTargetManagerById(G.morphTargetManagerId)),G.skeletonId!==void 0&&G.skeletonId!==null&&(re.skeleton=Q.getLastSkeletonByID(G.skeletonId),G.numBoneInfluencers&&(re.numBoneInfluencers=G.numBoneInfluencers)),G.animations){for(var Y=0;Y<G.animations.length;Y++){var k=G.animations[Y];(q=I.a.GetClass("BABYLON.Animation"))&&re.animations.push(q.Parse(k))}m.a.ParseAnimationRanges(re,G,Q)}if(G.autoAnimate&&Q.beginAnimation(re,G.autoAnimateFrom,G.autoAnimateTo,G.autoAnimateLoop,G.autoAnimateSpeed||1),G.layerMask&&!isNaN(G.layerMask)?re.layerMask=Math.abs(parseInt(G.layerMask)):re.layerMask=268435455,G.physicsImpostor&&L._PhysicsImpostorParser(Q,re,G),G.lodMeshIds&&(re._waitingData.lods={ids:G.lodMeshIds,distances:G.lodDistances?G.lodDistances:null,coverages:G.lodCoverages?G.lodCoverages:null}),G.instances)for(var H=0;H<G.instances.length;H++){var Z=G.instances[H],X=re.createInstance(Z.name);if(Z.id&&(X.id=Z.id),M.a&&(Z.tags?M.a.AddTagsTo(X,Z.tags):M.a.AddTagsTo(X,G.tags)),X.position=R.e.FromArray(Z.position),Z.metadata!==void 0&&(X.metadata=Z.metadata),Z.parentId&&(X._waitingParentId=Z.parentId),Z.isEnabled!==void 0&&Z.isEnabled!==null&&X.setEnabled(Z.isEnabled),Z.isVisible!==void 0&&Z.isVisible!==null&&(X.isVisible=Z.isVisible),Z.isPickable!==void 0&&Z.isPickable!==null&&(X.isPickable=Z.isPickable),Z.rotationQuaternion?X.rotationQuaternion=R.b.FromArray(Z.rotationQuaternion):Z.rotation&&(X.rotation=R.e.FromArray(Z.rotation)),X.scaling=R.e.FromArray(Z.scaling),Z.checkCollisions!=null&&Z.checkCollisions!=null&&(X.checkCollisions=Z.checkCollisions),Z.pickable!=null&&Z.pickable!=null&&(X.isPickable=Z.pickable),Z.showBoundingBox!=null&&Z.showBoundingBox!=null&&(X.showBoundingBox=Z.showBoundingBox),Z.showSubMeshesBoundingBox!=null&&Z.showSubMeshesBoundingBox!=null&&(X.showSubMeshesBoundingBox=Z.showSubMeshesBoundingBox),Z.alphaIndex!=null&&Z.showSubMeshesBoundingBox!=null&&(X.alphaIndex=Z.alphaIndex),Z.physicsImpostor&&L._PhysicsImpostorParser(Q,X,Z),Z.animations){for(Y=0;Y<Z.animations.length;Y++){var q;k=Z.animations[Y],(q=I.a.GetClass("BABYLON.Animation"))&&X.animations.push(q.Parse(k))}m.a.ParseAnimationRanges(X,Z,Q),Z.autoAnimate&&Q.beginAnimation(X,Z.autoAnimateFrom,Z.autoAnimateTo,Z.autoAnimateLoop,Z.autoAnimateSpeed||1)}}if(G.thinInstances){var he=G.thinInstances;if(he.matrixData?(re.thinInstanceSetBuffer("matrix",new Float32Array(he.matrixData),16,!1),re._thinInstanceDataStorage.matrixBufferSize=he.matrixBufferSize,re._thinInstanceDataStorage.
26instancesCount=he.instancesCount):re._thinInstanceDataStorage.matrixBufferSize=he.matrixBufferSize,G.thinInstances.userThinInstance){var ge=G.thinInstances.userThinInstance;for(var me in ge.data)re.thinInstanceSetBuffer(me,new Float32Array(ge.data[me]),ge.strides[me],!1),re._userThinInstanceBuffersStorage.sizes[me]=ge.sizes[me]}}return re},L.CreateRibbon=function(G,Q,oe,re,Y,k,H,Z,X){throw V.a.WarnImport("MeshBuilder")},L.CreateDisc=function(G,Q,oe,re,Y,k){throw V.a.WarnImport("MeshBuilder")},L.CreateBox=function(G,Q,oe,re,Y){throw V.a.WarnImport("MeshBuilder")},L.CreateSphere=function(G,Q,oe,re,Y,k){throw V.a.WarnImport("MeshBuilder")},L.CreateHemisphere=function(G,Q,oe,re){throw V.a.WarnImport("MeshBuilder")},L.CreateCylinder=function(G,Q,oe,re,Y,k,H,Z,X){throw V.a.WarnImport("MeshBuilder")},L.CreateTorus=function(G,Q,oe,re,Y,k,H){throw V.a.WarnImport("MeshBuilder")},L.CreateTorusKnot=function(G,Q,oe,re,Y,k,H,Z,X,q){throw V.a.WarnImport("MeshBuilder")},L.CreateLines=function(G,Q,oe,re,Y){throw V.a.WarnImport("MeshBuilder")},L.CreateDashedLines=function(G,Q,oe,re,Y,k,H,Z){throw V.a.WarnImport("MeshBuilder")},L.CreatePolygon=function(G,Q,oe,re,Y,k,H){throw H===void 0&&(H=earcut),V.a.WarnImport("MeshBuilder")},L.ExtrudePolygon=function(G,Q,oe,re,Y,k,H,Z){throw Z===void 0&&(Z=earcut),V.a.WarnImport("MeshBuilder")},L.ExtrudeShape=function(G,Q,oe,re,Y,k,H,Z,X,q){throw V.a.WarnImport("MeshBuilder")},L.ExtrudeShapeCustom=function(G,Q,oe,re,Y,k,H,Z,X,q,he,ge){throw V.a.WarnImport("MeshBuilder")},L.CreateLathe=function(G,Q,oe,re,Y,k,H){throw V.a.WarnImport("MeshBuilder")},L.CreatePlane=function(G,Q,oe,re,Y){throw V.a.WarnImport("MeshBuilder")},L.CreateGround=function(G,Q,oe,re,Y,k){throw V.a.WarnImport("MeshBuilder")},L.CreateTiledGround=function(G,Q,oe,re,Y,k,H,Z,X){throw V.a.WarnImport("MeshBuilder")},L.CreateGroundFromHeightMap=function(G,Q,oe,re,Y,k,H,Z,X,q,he){throw V.a.WarnImport("MeshBuilder")},L.CreateTube=function(G,Q,oe,re,Y,k,H,Z,X,q){throw V.a.WarnImport("MeshBuilder")},L.CreatePolyhedron=function(G,Q,oe){throw V.a.WarnImport("MeshBuilder")},L.CreateIcoSphere=function(G,Q,oe){throw V.a.WarnImport("MeshBuilder")},L.CreateDecal=function(G,Q,oe,re,Y,k){throw V.a.WarnImport("MeshBuilder")},L.CreateCapsule=function(G,Q,oe){throw V.a.WarnImport("MeshBuilder")},L.prototype.setPositionsForCPUSkinning=function(){var G=this._internalMeshDataInfo;if(!G._sourcePositions){var Q=this.getVerticesData(c.b.PositionKind);if(!Q)return G._sourcePositions;G._sourcePositions=new Float32Array(Q),this.isVertexBufferUpdatable(c.b.PositionKind)||this.setVerticesData(c.b.PositionKind,Q,!0)}return G._sourcePositions},L.prototype.setNormalsForCPUSkinning=function(){var G=this._internalMeshDataInfo;if(!G._sourceNormals){var Q=this.getVerticesData(c.b.NormalKind);if(!Q)return G._sourceNormals;G._sourceNormals=new Float32Array(Q),this.isVertexBufferUpdatable(c.b.NormalKind)||this.setVerticesData(c.b.NormalKind,Q,!0)}return G._sourceNormals},L.prototype.applySkeleton=function(G){if(!this.geometry)return this;if(this.geometry._softwareSkinningFrameId==this.getScene().getFrameId())return this;if(this.geometry._softwareSkinningFrameId=this.getScene().getFrameId(),!this.isVerticesDataPresent(c.b.PositionKind))return this;if(!this.isVerticesDataPresent(c.b.MatricesIndicesKind))return this;if(!this.isVerticesDataPresent(c.b.MatricesWeightsKind))return this;var Q=this.isVerticesDataPresent(c.b.NormalKind),oe=this._internalMeshDataInfo;if(!oe._sourcePositions){var re=this.subMeshes.slice();this.setPositionsForCPUSkinning(),this.subMeshes=re}Q&&!oe._sourceNormals&&this.setNormalsForCPUSkinning();var Y=this.getVerticesData(c.b.PositionKind);if(!Y)return this;Y instanceof Float32Array||(Y=new Float32Array(Y));var k=this.getVerticesData(c.b.NormalKind);if(Q){if(!k)return this;k instanceof Float32Array||(k=new Float32Array(k))}var H=this.getVerticesData(c.b.MatricesIndicesKind),Z=this.getVerticesData(c.b.MatricesWeightsKind);if(!Z||!H)return this;for(var X,q=this.numBoneInfluencers>4,he=q?this.getVerticesData(c.b.MatricesIndicesExtraKind):null,ge=q?this.getVerticesData(c.b.MatricesWeightsExtraKind):null,me=G.getTransformMatrices(this),_e=R.e.Zero(),be=new R.a,Ce=new R.a,ye=0,Be=0;Be<Y.length;Be+=3,ye+=4){var Ge;for(X=0;X<4;X++)(Ge=Z[ye+X])>0&&(R.a.FromFloat32ArrayToRefScaled(me,Math.floor(16*H[ye+X]),Ge,Ce),be.addToSelf(Ce));if(q)for(X=0;X<4;X++)(Ge=ge[ye+X])>0&&(R.a.FromFloat32ArrayToRefScaled(me,Math.floor(16*he[ye+X]),Ge,Ce),be.addToSelf(Ce));R.e.TransformCoordinatesFromFloatsToRef(oe._sourcePositions[Be],oe._sourcePositions[Be+1],oe._sourcePositions[Be+2],be,_e),_e.toArray(Y,Be),Q&&(R.e.TransformNormalFromFloatsToRef(oe._sourceNormals[Be],oe._sourceNormals[Be+1],oe._sourceNormals[Be+2],be,_e),_e.toArray(k,Be)),be.reset()}return this.updateVerticesData(c.b.PositionKind,Y),Q&&this.updateVerticesData(c.b.NormalKind,k),this},L.MinMax=function(G){var Q=null,oe=null;return G.forEach(function(re){var Y=re.getBoundingInfo().boundingBox;Q&&oe?(Q.minimizeInPlace(Y.minimumWorld),oe.maximizeInPlace(Y.maximumWorld)):(Q=Y.minimumWorld,oe=Y.maximumWorld)}),Q&&oe?{min:Q,max:oe}:{min:R.e.Zero(),max:R.e.Zero()}},L.Center=function(G){var Q=G instanceof Array?L.MinMax(G):G;return R.e.Center(Q.min,Q.max)},L.MergeMeshes=function(G,Q,oe,re,Y,k){var H;if(Q===void 0&&(Q=!0),!oe){var Z=0;for(H=0;H<G.length;H++)if(G[H]&&(Z+=G[H].getTotalVertices())>=65536)return N.a.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices"),null}if(k){var X,q,he=null;Y=!1}var ge,me=new Array,_e=new Array,be=null,Ce=new Array,ye=null;for(H=0;H<G.length;H++)if(G[H]){var Be=G[H];if(Be.isAnInstance)return N.a.Warn("Cannot merge instance meshes."),null;var Ge=Be.computeWorldMatrix(!0);if((ge=E.a.ExtractFromMesh(Be,!0,!0)).transform(Ge),be?be.merge(ge,oe):(be=ge,ye=Be),Y&&Ce.push(Be.getTotalIndices()),k)if(Be.material){var Xe=Be.material;if(Xe instanceof b.a){for(q=0;q<Xe.subMaterials.length;q++)me.indexOf(Xe.subMaterials[q])<0&&me.push(Xe.subMaterials[q]);for(X=0;X<Be.subMeshes.length;X++)_e.push(me.indexOf(Xe.subMaterials[Be.subMeshes[X].materialIndex])),Ce.push(Be.subMeshes[X].indexCount)}else for(me.indexOf(Xe)<0&&me.push(Xe),X=0;X<Be.subMeshes.length;X++)_e.push(me.indexOf(Xe)),Ce.push(Be.subMeshes[X].indexCount)}else for(X=0;X<Be.subMeshes.length;X++)_e.push(0),Ce.push(Be.subMeshes[X].indexCount)}if(ye=ye,re||(re=new L(ye.name+"_merged",ye.getScene())),be.applyToMesh(re),re.checkCollisions=ye.checkCollisions,re.overrideMaterialSideOrientation=ye.overrideMaterialSideOrientation,Q)for(H=0;H<G.length;H++)G[H]&&G[H].dispose();if(Y||k){re.releaseSubMeshes(),H=0;for(var He=0;H<Ce.length;)g.a.CreateFromIndices(0,He,Ce[H],re),He+=Ce[H],H++}if(k){for((he=new b.a(ye.name+"_merged",ye.getScene())).subMaterials=me,X=0;X<re.subMeshes.length;X++)re.subMeshes[X].materialIndex=_e[X];re.material=he}else re.material=ye.material;return re}
26,L.prototype.addInstance=function(G){G._indexInSourceMeshInstanceArray=this.instances.length,this.instances.push(G)},L.prototype.removeInstance=function(G){var Q=G._indexInSourceMeshInstanceArray;if(Q!=-1){if(Q!==this.instances.length-1){var oe=this.instances[this.instances.length-1];this.instances[Q]=oe,oe._indexInSourceMeshInstanceArray=Q}G._indexInSourceMeshInstanceArray=-1,this.instances.pop()}},L.FRONTSIDE=E.a.FRONTSIDE,L.BACKSIDE=E.a.BACKSIDE,L.DOUBLESIDE=E.a.DOUBLESIDE,L.DEFAULTSIDE=E.a.DEFAULTSIDE,L.NO_CAP=0,L.CAP_START=1,L.CAP_END=2,L.CAP_ALL=3,L.NO_FLIP=0,L.FLIP_TILE=1,L.ROTATE_TILE=2,L.FLIP_ROW=3,L.ROTATE_ROW=4,L.FLIP_N_ROTATE_TILE=5,L.FLIP_N_ROTATE_ROW=6,L.CENTER=0,L.LEFT=1,L.RIGHT=2,L.TOP=3,L.BOTTOM=4,L._GroundMeshParser=function(G,Q){throw V.a.WarnImport("GroundMesh")},L}(S.a);I.a.RegisteredTypes["BABYLON.Mesh"]=K},function(Ae,v,f){f.d(v,"a",function(){return B});var B=function(){function _(){}return _._AddLogEntry=function(x){_._LogCache=x+_._LogCache,_.OnNewCacheEntry&&_.OnNewCacheEntry(x)},_._FormatMessage=function(x){var u=function(R){return R<10?"0"+R:""+R},M=new Date;return"["+u(M.getHours())+":"+u(M.getMinutes())+":"+u(M.getSeconds())+"]: "+x},_._LogDisabled=function(x){},_._LogEnabled=function(x){var u=_._FormatMessage(x);console.log("BJS - "+u);var M="<div style='color:white'>"+u+"</div><br>";_._AddLogEntry(M)},_._WarnDisabled=function(x){},_._WarnEnabled=function(x){var u=_._FormatMessage(x);console.warn("BJS - "+u);var M="<div style='color:orange'>"+u+"</div><br>";_._AddLogEntry(M)},_._ErrorDisabled=function(x){},_._ErrorEnabled=function(x){_.errorsCount++;var u=_._FormatMessage(x);console.error("BJS - "+u);var M="<div style='color:red'>"+u+"</div><br>";_._AddLogEntry(M)},Object.defineProperty(_,"LogCache",{get:function(){return _._LogCache},enumerable:!1,configurable:!0}),_.ClearLogCache=function(){_._LogCache="",_.errorsCount=0},Object.defineProperty(_,"LogLevels",{set:function(x){(x&_.MessageLogLevel)===_.MessageLogLevel?_.Log=_._LogEnabled:_.Log=_._LogDisabled,(x&_.WarningLogLevel)===_.WarningLogLevel?_.Warn=_._WarnEnabled:_.Warn=_._WarnDisabled,(x&_.ErrorLogLevel)===_.ErrorLogLevel?_.Error=_._ErrorEnabled:_.Error=_._ErrorDisabled},enumerable:!1,configurable:!0}),_.NoneLogLevel=0,_.MessageLogLevel=1,_.WarningLogLevel=2,_.ErrorLogLevel=4,_.AllLogLevel=7,_._LogCache="",_.errorsCount=0,_.Log=_._LogEnabled,_.Warn=_._WarnEnabled,_.Error=_._ErrorEnabled,_}()},function(Ae,v,f){f.d(v,"a",function(){return M}),f.d(v,"b",function(){return R}),f.d(v,"c",function(){return C});var B=f(14),_=f(28),x=f(44),u=f(11),M=function(){function m(c,E,A){c===void 0&&(c=0),E===void 0&&(E=0),A===void 0&&(A=0),this.r=c,this.g=E,this.b=A}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 c=255*this.r|0;return c=397*(c=397*c^(255*this.g|0))^(255*this.b|0)},m.prototype.toArray=function(c,E){return E===void 0&&(E=0),c[E]=this.r,c[E+1]=this.g,c[E+2]=this.b,this},m.prototype.fromArray=function(c,E){return E===void 0&&(E=0),m.FromArrayToRef(c,E,this),this},m.prototype.toColor4=function(c){return c===void 0&&(c=1),new R(this.r,this.g,this.b,c)},m.prototype.asArray=function(){var c=new Array;return this.toArray(c,0),c},m.prototype.toLuminance=function(){return .3*this.r+.59*this.g+.11*this.b},m.prototype.multiply=function(c){return new m(this.r*c.r,this.g*c.g,this.b*c.b)},m.prototype.multiplyToRef=function(c,E){return E.r=this.r*c.r,E.g=this.g*c.g,E.b=this.b*c.b,this},m.prototype.equals=function(c){return c&&this.r===c.r&&this.g===c.g&&this.b===c.b},m.prototype.equalsFloats=function(c,E,A){return this.r===c&&this.g===E&&this.b===A},m.prototype.scale=function(c){return new m(this.r*c,this.g*c,this.b*c)},m.prototype.scaleToRef=function(c,E){return E.r=this.r*c,E.g=this.g*c,E.b=this.b*c,this},m.prototype.scaleAndAddToRef=function(c,E){return E.r+=this.r*c,E.g+=this.g*c,E.b+=this.b*c,this},m.prototype.clampToRef=function(c,E,A){return c===void 0&&(c=0),E===void 0&&(E=1),A.r=B.a.Clamp(this.r,c,E),A.g=B.a.Clamp(this.g,c,E),A.b=B.a.Clamp(this.b,c,E),this},m.prototype.add=function(c){return new m(this.r+c.r,this.g+c.g,this.b+c.b)},m.prototype.addToRef=function(c,E){return E.r=this.r+c.r,E.g=this.g+c.g,E.b=this.b+c.b,this},m.prototype.subtract=function(c){return new m(this.r-c.r,this.g-c.g,this.b
26-c.b)},m.prototype.subtractToRef=function(c,E){return E.r=this.r-c.r,E.g=this.g-c.g,E.b=this.b-c.b,this},m.prototype.clone=function(){return new m(this.r,this.g,this.b)},m.prototype.copyFrom=function(c){return this.r=c.r,this.g=c.g,this.b=c.b,this},m.prototype.copyFromFloats=function(c,E,A){return this.r=c,this.g=E,this.b=A,this},m.prototype.set=function(c,E,A){return this.copyFromFloats(c,E,A)},m.prototype.toHexString=function(){var c=255*this.r|0,E=255*this.g|0,A=255*this.b|0;return"#"+B.a.ToHex(c)+B.a.ToHex(E)+B.a.ToHex(A)},m.prototype.toLinearSpace=function(){var c=new m;return this.toLinearSpaceToRef(c),c},m.prototype.toHSV=function(){var c=new m;return this.toHSVToRef(c),c},m.prototype.toHSVToRef=function(c){var E=this.r,A=this.g,S=this.b,g=Math.max(E,A,S),l=Math.min(E,A,S),h=0,b=0,T=g,D=g-l;g!==0&&(b=D/g),g!=l&&(g==E?(h=(A-S)/D,A<S&&(h+=6)):g==A?h=(S-E)/D+2:g==S&&(h=(E-A)/D+4),h*=60),c.r=h,c.g=b,c.b=T},m.prototype.toLinearSpaceToRef=function(c){return c.r=Math.pow(this.r,_.c),c.g=Math.pow(this.g,_.c),c.b=Math.pow(this.b,_.c),this},m.prototype.toGammaSpace=function(){var c=new m;return this.toGammaSpaceToRef(c),c},m.prototype.toGammaSpaceToRef=function(c){return c.r=Math.pow(this.r,_.b),c.g=Math.pow(this.g,_.b),c.b=Math.pow(this.b,_.b),this},m.HSVtoRGBToRef=function(c,E,A,S){var g=A*E,l=c/60,h=g*(1-Math.abs(l%2-1)),b=0,T=0,D=0;l>=0&&l<=1?(b=g,T=h):l>=1&&l<=2?(b=h,T=g):l>=2&&l<=3?(T=g,D=h):l>=3&&l<=4?(T=h,D=g):l>=4&&l<=5?(b=h,D=g):l>=5&&l<=6&&(b=g,D=h);var w=A-g;S.set(b+w,T+w,D+w)},m.FromHexString=function(c){if(c.substring(0,1)!=="#"||c.length!==7)return new m(0,0,0);var E=parseInt(c.substring(1,3),16),A=parseInt(c.substring(3,5),16),S=parseInt(c.substring(5,7),16);return m.FromInts(E,A,S)},m.FromArray=function(c,E){return E===void 0&&(E=0),new m(c[E],c[E+1],c[E+2])},m.FromArrayToRef=function(c,E,A){E===void 0&&(E=0),A.r=c[E],A.g=c[E+1],A.b=c[E+2]},m.FromInts=function(c,E,A){return new m(c/255,E/255,A/255)},m.Lerp=function(c,E,A){var S=new m(0,0,0);return m.LerpToRef(c,E,A,S),S},m.LerpToRef=function(c,E,A,S){S.r=c.r+(E.r-c.r)*A,S.g=c.g+(E.g-c.g)*A,S.b=c.b+(E.b-c.b)*A},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}(),R=function(){function m(c,E,A,S){c===void 0&&(c=0),E===void 0&&(E=0),A===void 0&&(A=0),S===void 0&&(S=1),this.r=c,this.g=E,this.b=A,this.a=S}return m.prototype.addInPlace=function(c){return this.r+=c.r,this.g+=c.g,this.b+=c.b,this.a+=c.a,this},m.prototype.asArray=function(){var c=new Array;return this.toArray(c,0),c},m.prototype.toArray=function(c,E){return E===void 0&&(E=0),c[E]=this.r,c[E+1]=this.g,c[E+2]=this.b,c[E+3]=this.a,this},m.prototype.fromArray=function(c,E){return E===void 0&&(E=0),m.FromArrayToRef(c,E,this),this},m.prototype.equals=function(c){return c&&this.r===c.r&&this.g===c.g&&this.b===c.b&&this.a===c.a},m.prototype.add=function(c){return new m(this.r+c.r,this.g+c.g,this.b+c.b,this.a+c.a)},m.prototype.subtract=function(c){return new m(this.r-c.r,this.g-c.g,this.b-c.b,this.a-c.a)},m.prototype.subtractToRef=function(c,E){return E.r=this.r-c.r,E.g=this.g-c.g,E.b=this.b-c.b,E.a=this.a-c.a,this},m.prototype.scale=function(c){return new m(this.r*c,this.g*c,this.b*c,this.a*c)},m.prototype.scaleToRef=function(c,E){return E.r=this.r*c,E.g=this.g*c,E.b=this.b*c,E.a=this.a*c,this},m.prototype.scaleAndAddToRef=function(c,E){return E.r+=this.r*c,E.g+=this.g*c,E.b+=this.b*c,E.a+=this.a*c,this},m.prototype.clampToRef=function(c,E,A){return c===void 0&&(c=0),E===void 0&&(E=1),A.r=B.a.Clamp(this.r,c,E),A.g=B.a.Clamp(this.g,c,E),A.b=B.a.Clamp(this.b,c,E),A.a=B.a.Clamp(this.a,c,E),this},m.prototype.multiply=function(c){return new m(this.r*c.r,this.g*c.g,this.b*c.b,this.a*c.a)},m.prototype.multiplyToRef=function(c,E){return E.r=this.r*c.r,E.g=this.g*c.g,E.b=this.b*c.b,E.a=this.a*c.a,E},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 c=255*this.r|0;return c=397*(c=397*(c=397*c^(255*this.g|0))^(255*this.b|0))^(255*this.a|0)},m.prototype.clone=function(){return new m(this.r,this.g,this.b,this.a)},m.prototype.copyFrom=function(c){return this.r=c.r,this.g=c.g,this.b=c.b,this.a=c.a,this},m.prototype.copyFromFloats=function(c,E,A,S){return this.r=c,this.g=E,this.b=A,this.a=S,this},m.prototype.set=function(c,E,A,S){return this.copyFromFloats(c,E,A,S)},m.prototype.toHexString=function(c){c===void 0&&(c=!1);var E=255*this.r|0,A=255*this.g|0,S=255*this.b|0;if(c)return"#"+B.a.ToHex(E)+B.a.ToHex(A)+B.a.ToHex(S);var g=255*this.a|0;return"#"+B.a.ToHex(E)+B.a.ToHex(A)+B.a.ToHex(S)+B.a.ToHex(g)}
26,m.prototype.toLinearSpace=function(){var c=new m;return this.toLinearSpaceToRef(c),c},m.prototype.toLinearSpaceToRef=function(c){return c.r=Math.pow(this.r,_.c),c.g=Math.pow(this.g,_.c),c.b=Math.pow(this.b,_.c),c.a=this.a,this},m.prototype.toGammaSpace=function(){var c=new m;return this.toGammaSpaceToRef(c),c},m.prototype.toGammaSpaceToRef=function(c){return c.r=Math.pow(this.r,_.b),c.g=Math.pow(this.g,_.b),c.b=Math.pow(this.b,_.b),c.a=this.a,this},m.FromHexString=function(c){if(c.substring(0,1)!=="#"||c.length!==9)return new m(0,0,0,0);var E=parseInt(c.substring(1,3),16),A=parseInt(c.substring(3,5),16),S=parseInt(c.substring(5,7),16),g=parseInt(c.substring(7,9),16);return m.FromInts(E,A,S,g)},m.Lerp=function(c,E,A){var S=new m(0,0,0,0);return m.LerpToRef(c,E,A,S),S},m.LerpToRef=function(c,E,A,S){S.r=c.r+(E.r-c.r)*A,S.g=c.g+(E.g-c.g)*A,S.b=c.b+(E.b-c.b)*A,S.a=c.a+(E.a-c.a)*A},m.FromColor3=function(c,E){return E===void 0&&(E=1),new m(c.r,c.g,c.b,E)},m.FromArray=function(c,E){return E===void 0&&(E=0),new m(c[E],c[E+1],c[E+2],c[E+3])},m.FromArrayToRef=function(c,E,A){E===void 0&&(E=0),A.r=c[E],A.g=c[E+1],A.b=c[E+2],A.a=c[E+3]},m.FromInts=function(c,E,A,S){return new m(c/255,E/255,A/255,S/255)},m.CheckColors4=function(c,E){if(c.length===3*E){for(var A=[],S=0;S<c.length;S+=3){var g=S/3*4;A[g]=c[S],A[g+1]=c[S+1],A[g+2]=c[S+2],A[g+3]=1}return A}return c},m}(),C=function(){function m(){}return m.Color3=x.a.BuildArray(3,M.Black),m.Color4=x.a.BuildArray(3,function(){return new R(0,0,0,0)}),m}();u.a.RegisteredTypes["BABYLON.Color3"]=M,u.a.RegisteredTypes["BABYLON.Color4"]=R},function(Ae,v,f){f.d(v,"a",function(){return l});var B=f(1),_=f(3),x=f(6),u=f(0),M=f(52),R=f(2),C=f(11),m=f(21),c=f(104),E=f(122),A=f(64),S=f(34),g=f(150),l=function(h){function b(T,D,w,N,I,V,W,j,ne,te,de,pe){w===void 0&&(w=!1),N===void 0&&(N=!0),I===void 0&&(I=b.TRILINEAR_SAMPLINGMODE),V===void 0&&(V=null),W===void 0&&(W=null),j===void 0&&(j=null),ne===void 0&&(ne=!1);var ae=h.call(this,D)||this;ae.url=null,ae.uOffset=0,ae.vOffset=0,ae.uScale=1,ae.vScale=1,ae.uAng=0,ae.vAng=0,ae.wAng=0,ae.uRotationCenter=.5,ae.vRotationCenter=.5,ae.wRotationCenter=.5,ae.homogeneousRotationInUVTransform=!1,ae.inspectableCustomProperties=null,ae._noMipmap=!1,ae._invertY=!1,ae._rowGenerationMatrix=null,ae._cachedTextureMatrix=null,ae._projectionModeMatrix=null,ae._t0=null,ae._t1=null,ae._t2=null,ae._cachedUOffset=-1,ae._cachedVOffset=-1,ae._cachedUScale=0,ae._cachedVScale=0,ae._cachedUAng=-1,ae._cachedVAng=-1,ae._cachedWAng=-1,ae._cachedProjectionMatrixId=-1,ae._cachedURotationCenter=-1,ae._cachedVRotationCenter=-1,ae._cachedWRotationCenter=-1,ae._cachedHomogeneousRotationInUVTransform=!1,ae._cachedCoordinatesMode=-1,ae._initialSamplingMode=b.BILINEAR_SAMPLINGMODE,ae._buffer=null,ae._deleteBuffer=!1,ae._format=null,ae._delayedOnLoad=null,ae._delayedOnError=null,ae.onLoadObservable=new x.c,ae._isBlocking=!0,ae.name=T||"",ae.url=T,ae._noMipmap=w,ae._invertY=N,ae._initialSamplingMode=I,ae._buffer=j,ae._deleteBuffer=ne,ae._mimeType=de,ae._loaderOptions=pe,te&&(ae._format=te);var ee=ae.getScene(),K=ae._getEngine();if(!K)return ae;K.onBeforeTextureInitObservable.notifyObservers(ae);var $=function(){ae._texture&&(ae._texture._invertVScale&&(ae.vScale*=-1,ae.vOffset+=1),ae._texture._cachedWrapU!==null&&(ae.wrapU=ae._texture._cachedWrapU,ae._texture._cachedWrapU=null),ae._texture._cachedWrapV!==null&&(ae.wrapV=ae._texture._cachedWrapV,ae._texture._cachedWrapV=null),ae._texture._cachedWrapR!==null&&(ae.wrapR=ae._texture._cachedWrapR,ae._texture._cachedWrapR=null)),ae.onLoadObservable.hasObservers()&&ae.onLoadObservable.notifyObservers(ae),V&&V(),!ae.isBlocking&&ee&&ee.resetCachedMaterial()};return ae.url?(ae._texture=ae._getFromCache(ae.url,w,I,N),ae._texture?ae._texture.isReady?c.a.SetImmediate(function(){return $()}):ae._texture.onLoadedObservable.add($):ee&&ee.useDelayedTextureLoading?(ae.delayLoadState=R.a.DELAYLOADSTATE_NOTLOADED,ae._delayedOnLoad=$,ae._delayedOnError=W):(ae._texture=K.createTexture(ae.url,w,N,ee,I,$,W,ae._buffer,void 0,ae._format,null,de,pe),ne&&(ae._buffer=null)),ae):(ae._delayedOnLoad=$,ae._delayedOnError=W,ae)}return Object(B.d)(b,h),Object.defineProperty(b.prototype,"noMipmap",{get:function(){return this._noMipmap}
26,enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"mimeType",{get:function(){return this._mimeType},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"isBlocking",{get:function(){return this._isBlocking},set:function(T){this._isBlocking=T},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"samplingMode",{get:function(){return this._texture?this._texture.samplingMode:this._initialSamplingMode},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"invertY",{get:function(){return this._invertY},enumerable:!1,configurable:!0}),b.prototype.updateURL=function(T,D,w){D===void 0&&(D=null),this.url&&(this.releaseInternalTexture(),this.getScene().markAllMaterialsAsDirty(R.a.MATERIAL_TextureDirtyFlag)),this.name&&!S.a.StartsWith(this.name,"data:")||(this.name=T),this.url=T,this._buffer=D,this.delayLoadState=R.a.DELAYLOADSTATE_NOTLOADED,w&&(this._delayedOnLoad=w),this.delayLoad()},b.prototype.delayLoad=function(){if(this.delayLoadState===R.a.DELAYLOADSTATE_NOTLOADED){var T=this.getScene();T&&(this.delayLoadState=R.a.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap,this.samplingMode,this._invertY),this._texture?this._delayedOnLoad&&(this._texture.isReady?c.a.SetImmediate(this._delayedOnLoad):this._texture.onLoadedObservable.add(this._delayedOnLoad)):(this._texture=T.getEngine().createTexture(this.url,this._noMipmap,this._invertY,T,this.samplingMode,this._delayedOnLoad,this._delayedOnError,this._buffer,null,this._format,null,this._mimeType,this._loaderOptions),this._deleteBuffer&&(this._buffer=null)),this._delayedOnLoad=null,this._delayedOnError=null)}},b.prototype._prepareRowForTextureGeneration=function(T,D,w,N){T*=this._cachedUScale,D*=this._cachedVScale,T-=this.uRotationCenter*this._cachedUScale,D-=this.vRotationCenter*this._cachedVScale,w-=this.wRotationCenter,u.e.TransformCoordinatesFromFloatsToRef(T,D,w,this._rowGenerationMatrix,N),N.x+=this.uRotationCenter*this._cachedUScale+this._cachedUOffset,N.y+=this.vRotationCenter*this._cachedVScale+this._cachedVOffset,N.z+=this.wRotationCenter},b.prototype.checkTransformsAreIdentical=function(T){return T!==null&&this.uOffset===T.uOffset&&this.vOffset===T.vOffset&&this.uScale===T.uScale&&this.vScale===T.vScale&&this.uAng===T.uAng&&this.vAng===T.vAng&&this.wAng===T.wAng},b.prototype.getTextureMatrix=function(T){var D=this;if(T===void 0&&(T=1),this.uOffset===this._cachedUOffset&&this.vOffset===this._cachedVOffset&&this.uScale*T===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*T,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=u.a.Zero(),this._rowGenerationMatrix=new u.a,this._t0=u.e.Zero(),this._t1=u.e.Zero(),this._t2=u.e.Zero()),u.a.RotationYawPitchRollToRef(this.vAng,this.uAng,this.wAng,this._rowGenerationMatrix),this.homogeneousRotationInUVTransform?(u.a.TranslationToRef(-this._cachedURotationCenter,-this._cachedVRotationCenter,-this._cachedWRotationCenter,u.c.Matrix[0]),u.a.TranslationToRef(this._cachedURotationCenter,this._cachedVRotationCenter,this._cachedWRotationCenter,u.c.Matrix[1]),u.a.ScalingToRef(this._cachedUScale,this._cachedVScale,0,u.c.Matrix[2]),u.a.TranslationToRef(this._cachedUOffset,this._cachedVOffset,0,u.c.Matrix[3]),u.c.Matrix[0].multiplyToRef(this._rowGenerationMatrix,this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(u.c.Matrix[1],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(u.c.Matrix[2],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(u.c.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),u.a.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 w=this.getScene();return w?(w.markAllMaterialsAsDirty(R.a.MATERIAL_TextureDirtyFlag,function(N){return N.hasTexture(D)}),this._cachedTextureMatrix):this._cachedTextureMatrix},b.prototype.getReflectionTextureMatrix=function(){var T=this,D=this.getScene();if(!D)return this._cachedTextureMatrix;if(this.uOffset===this._cachedUOffset&&this.vOffset===this._cachedVOffset&&this.uScale===this._cachedUScale&&this.vScale===this._cachedVScale&&this.coordinatesMode===this._cachedCoordinatesMode){if(this.coordinatesMode!==b.PROJECTION_MODE)return this._cachedTextureMatrix;if(this._cachedProjectionMatrixId===D.getProjectionMatrix().updateFlag)return this._cachedTextureMatrix}switch(this._cachedTextureMatrix||(this._cachedTextureMatrix=u.a.Zero()),this._projectionModeMatrix||(this._projectionModeMatrix=u.a.Zero()),this._cachedUOffset=this.uOffset,this._cachedVOffset=this.vOffset,this._cachedUScale=this.uScale,this._cachedVScale=this.vScale,this._cachedCoordinatesMode=this.coordinatesMode,this.coordinatesMode){case b.PLANAR_MODE:u.a.IdentityToRef(this._cachedTextureMatrix),this._cachedTextureMatrix[0]=this.uScale,this._cachedTextureMatrix[5]=this.vScale,this._cachedTextureMatrix[12]=this.uOffset,this._cachedTextureMatrix[13]=this.vOffset;break;case b.PROJECTION_MODE:u.a.FromValuesToRef(.5,0,0,0,0,-.5,0,0,0,0,0,0,.5,.5,1,1,this._projectionModeMatrix);var w=D.getProjectionMatrix();this._cachedProjectionMatrixId=w.updateFlag,w.multiplyToRef(this._projectionModeMatrix,this._cachedTextureMatrix);break;default:u.a.IdentityToRef(this._cachedTextureMatrix)}return D.markAllMaterialsAsDirty(R.a.MATERIAL_TextureDirtyFlag,function(N){return N.getActiveTextures().indexOf(T)!==-1}),this._cachedTextureMatrix},b.prototype.clone=function(){var T=this;return _.a.Clone(function(){return new b(T._texture?T._texture.url:null,T.getSce
26ne(),T._noMipmap,T._invertY,T.samplingMode,void 0,void 0,T._texture?T._texture._buffer:void 0)},this)},b.prototype.serialize=function(){var T=this.name;b.SerializeBuffers||S.a.StartsWith(this.name,"data:")&&(this.name=""),S.a.StartsWith(this.name,"data:")&&this.url===this.name&&(this.url="");var D=h.prototype.serialize.call(this);return D?((b.SerializeBuffers||b.ForceSerializeBuffers)&&(typeof this._buffer=="string"&&this._buffer.substr(0,5)==="data:"?(D.base64String=this._buffer,D.name=D.name.replace("data:","")):this.url&&S.a.StartsWith(this.url,"data:")&&this._buffer instanceof Uint8Array?D.base64String="data:image/png;base64,"+S.a.EncodeArrayBufferToBase64(this._buffer):b.ForceSerializeBuffers&&(D.base64String=g.a.GenerateBase64StringFromTexture(this))),D.invertY=this._invertY,D.samplingMode=this.samplingMode,this.name=T,D):null},b.prototype.getClassName=function(){return"Texture"},b.prototype.dispose=function(){h.prototype.dispose.call(this),this.onLoadObservable.clear(),this._delayedOnLoad=null,this._delayedOnError=null},b.Parse=function(T,D,w){if(T.customType){var N=E.a.Instantiate(T.customType).Parse(T,D,w);return T.samplingMode&&N.updateSamplingMode&&N._samplingMode&&N._samplingMode!==T.samplingMode&&N.updateSamplingMode(T.samplingMode),N}if(T.isCube&&!T.isRenderTarget)return b._CubeTextureParser(T,D,w);if(!T.name&&!T.isRenderTarget)return null;var I=function(){if(V&&V._texture&&(V._texture._cachedWrapU=null,V._texture._cachedWrapV=null,V._texture._cachedWrapR=null),T.samplingMode){var W=T.samplingMode;V&&V.samplingMode!==W&&V.updateSamplingMode(W)}if(V&&T.animations)for(var j=0;j<T.animations.length;j++){var ne=T.animations[j],te=C.a.GetClass("BABYLON.Animation");te&&V.animations.push(te.Parse(ne))}},V=_.a.Parse(function(){var W,j=!0;if(T.noMipmap&&(j=!1),T.mirrorPlane){var ne=b._CreateMirror(T.name,T.renderTargetSize,D,j);return ne._waitingRenderList=T.renderList,ne.mirrorPlane=A.a.FromArray(T.mirrorPlane),I(),ne}if(T.isRenderTarget){var te=null;if(T.isCube){if(D.reflectionProbes)for(var de=0;de<D.reflectionProbes.length;de++){var pe=D.reflectionProbes[de];if(pe.name===T.name)return pe.cubeTexture}}else(te=b._CreateRenderTargetTexture(T.name,T.renderTargetSize,D,j))._waitingRenderList=T.renderList;return I(),te}if(T.base64String)W=b.CreateFromBase64String(T.base64String,T.name,D,!j,T.invertY,void 0,I);else{var ae=void 0;ae=T.name&&T.name.indexOf("://")>0?T.name:w+T.name,(S.a.StartsWith(T.url,"data:")||b.UseSerializedUrlIfAny&&T.url)&&(ae=T.url),W=new b(ae,D,!j,T.invertY,void 0,I)}return W},T,D);return V},b.CreateFromBase64String=function(T,D,w,N,I,V,W,j,ne){return V===void 0&&(V=b.TRILINEAR_SAMPLINGMODE),W===void 0&&(W=null),j===void 0&&(j=null),ne===void 0&&(ne=R.a.TEXTUREFORMAT_RGBA),new b("data:"+D,w,N,I,V,W,j,T,!1,ne)},b.LoadFromDataString=function(T,D,w,N,I,V,W,j,ne,te){return N===void 0&&(N=!1),I===void 0&&(I=!1),V===void 0&&(V=!0),W===void 0&&(W=b.TRILINEAR_SAMPLINGMODE),j===void 0&&(j=null),ne===void 0&&(ne=null),te===void 0&&(te=R.a.TEXTUREFORMAT_RGBA),T.substr(0,5)!=="data:"&&(T="data:"+T),new b(T,w,I,V,W,j,ne,D,N,te)},b.SerializeBuffers=!0,b.ForceSerializeBuffers=!1,b._CubeTextureParser=function(T,D,w){throw m.a.WarnImport("CubeTexture")},b._CreateMirror=function(T,D,w,N){throw m.a.WarnImport("MirrorTexture")},b._CreateRenderTargetTexture=function(T,D,w,N){throw m.a.WarnImport("RenderTargetTexture")},b.NEAREST_SAMPLINGMODE=R.a.TEXTURE_NEAREST_SAMPLINGMODE,b.NEAREST_NEAREST_MIPLINEAR=R.a.TEXTURE_NEAREST_NEAREST_MIPLINEAR,b.BILINEAR_SAMPLINGMODE=R.a.TEXTURE_BILINEAR_SAMPLINGMODE,b.LINEAR_LINEAR_MIPNEAREST=R.a.TEXTURE_LINEAR_LINEAR_MIPNEAREST,b.TRILINEAR_SAMPLINGMODE=R.a.TEXTURE_TRILINEAR_SAMPLINGMODE,b.LINEAR_LINEAR_MIPLINEAR=R.a.TEXTURE_LINEAR_LINEAR_MIPLINEAR,b.NEAREST_NEAREST_MIPNEAREST=R.a.TEXTURE_NEAREST_NEAREST_MIPNEAREST,b.NEAREST_LINEAR_MIPNEAREST=R.a.TEXTURE_NEAREST_LINEAR_MIPNEAREST,b.NEAREST_LINEAR_MIPLINEAR=R.a.TEXTURE_NEAREST_LINEAR_MIPLINEAR,b.NEAREST_LINEAR=R.a.TEXTURE_NEAREST_LINEAR,b.NEAREST_NEAREST=R.a.TEXTURE_NEAREST_NEAREST,b.LINEAR_NEAREST_MIPNEAREST=R.a.TEXTURE_LINEAR_NEAREST_MIPNEAREST,b.LINEAR_NEAREST_MIPLINEAR=R.a.TEXTURE_LINEAR_NEAREST_MIPLINEAR,b.LINEAR_LINEAR=R.a.TEXTURE_LINEAR_LINEAR,b.LINEAR_NEAREST=R.a.TEXTURE_LINEAR_NEAREST,b.EXPLICIT_MODE=R.a.TEXTURE_EXPLICIT_MODE,b.SPHERICAL_MODE=R.a.TEXTURE_SPHERICAL_MODE,b.PLANAR_MODE=R.a.TEXTURE_PLANAR_MODE,b.CUBIC_MODE=R.a.TEXTURE_CUBIC_MODE,b.PROJECTION_MODE=R.a.TEXTURE_PROJECTION_MODE,b.SKYBOX_MODE=R.a.TEXTURE_SKYBOX_MODE,b.INVCUBIC_MODE=R.a.TEXTURE_INVCUBIC_MODE,b.EQUIRECTANGULAR_MODE=R.a.TEXTURE_EQUIRECTANGULAR_MODE,b.FIXED_EQUIRECTANGULAR_MODE=R.a.TEXTURE_FIXED_EQUIRECTANGULAR_MODE,b.FIXED_EQUIRECTANGULAR_MIRRORED_MODE=R.a.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE,b.CLAMP_ADDRESSMODE=R.a.TEXTURE_CLAMP_ADDRESSMODE,b.WRAP_ADDRESSMODE=R.a.TEXTURE_WRAP_ADDRESSMODE,b.MIRROR_ADDRESSMODE=R.a.TEXTURE_MIRROR_ADDRESSMODE,b.UseSerializedUrlIfAny=!1,Object(B.c)([Object(_.c)()],b.prototype,"url",void 0),Object(B.c)([Object(_.c)()],b.prototype,"uOffset",void 0),Object(B.c)([Object(_.c)()],b.prototype,"vOffset",void 0),Object(B.c)([Object(_.c)()],b.prototype,"uScale",void 0),Object(B.c)([Object(_.c)()],b.prototype,"vScale",void 0),Object(B.c)([Object(_.c)()],b.prototype,"uAng",void 0),Object(B.c)([Object(_.c)()],b.prototype,"vAng",void 0),Object(B.c)([Object(_.c)()],b.prototype,"wAng",void 0),Object(B.c)([Object(_.c)()],b.prototype,"uRotationCenter",void 0),Object(B.c)([Object(_.c)()],b.prototype,"vRotationCenter",void 0),Object(B.c)([Object(_.c)()],b.prototype,"wRotationCenter",void 0),Object(B.c)([Object(_.c)()],b.prototype,"homogeneousRotationInUVTransform",void 0),Object(B.c)([Object(_.c)()],b.prototype,"isBlocking",null),b}(M.a);C.a.RegisteredTypes["BABYLON.Texture"]=l,_.a._TextureParser=l.Parse},function(Ae,v,f){f.d(v,"a",function(){return B});var B=function(){function _(){}return _.GetClass=function(x){return this.RegisteredTypes&&this.RegisteredTypes[x]?this.RegisteredTypes[x]:null},_.RegisteredTypes={},_}()},function(Ae,v,f){f.d(v,"b",function(){return l}),f.d(v,"c",function(){return h}),f.d(v,"a",function(){return b});var B=f(6),_=f(38),x=f(8),u=f(41),M=f(57),R=f(21),C=f(49),m=f(22),c=f(56),E=f(145),A=f(104),S=f(122),g=f(120),l=function(){function T(){}return Object.defineProperty(T,"BaseUrl",{get:function(){return c.a.BaseUrl},set:function(D){c.a.BaseUrl=D}
26,enumerable:!1,configurable:!0}),Object.defineProperty(T,"DefaultRetryStrategy",{get:function(){return c.a.DefaultRetryStrategy},set:function(D){c.a.DefaultRetryStrategy=D},enumerable:!1,configurable:!0}),Object.defineProperty(T,"CorsBehavior",{get:function(){return c.a.CorsBehavior},set:function(D){c.a.CorsBehavior=D},enumerable:!1,configurable:!0}),Object.defineProperty(T,"UseFallbackTexture",{get:function(){return m.a.UseFallbackTexture},set:function(D){m.a.UseFallbackTexture=D},enumerable:!1,configurable:!0}),Object.defineProperty(T,"RegisteredExternalClasses",{get:function(){return S.a.RegisteredExternalClasses},set:function(D){S.a.RegisteredExternalClasses=D},enumerable:!1,configurable:!0}),Object.defineProperty(T,"fallbackTexture",{get:function(){return m.a.FallbackTexture},set:function(D){m.a.FallbackTexture=D},enumerable:!1,configurable:!0}),T.FetchToRef=function(D,w,N,I,V,W){var j=4*((Math.abs(D)*N%N|0)+(Math.abs(w)*I%I|0)*N);W.r=V[j]/255,W.g=V[j+1]/255,W.b=V[j+2]/255,W.a=V[j+3]/255},T.Mix=function(D,w,N){return D*(1-N)+w*N},T.Instantiate=function(D){return S.a.Instantiate(D)},T.Slice=function(D,w,N){return D.slice?D.slice(w,N):Array.prototype.slice.call(D,w,N)},T.SliceToArray=function(D,w,N){return Array.isArray(D)?D.slice(w,N):Array.prototype.slice.call(D,w,N)},T.SetImmediate=function(D){A.a.SetImmediate(D)},T.IsExponentOfTwo=function(D){var w=1;do w*=2;while(w<D);return w===D},T.FloatRound=function(D){return Math.fround?Math.fround(D):T._tmpFloatArray[0]=D},T.GetFilename=function(D){var w=D.lastIndexOf("/");return w<0?D:D.substring(w+1)},T.GetFolderPath=function(D,w){w===void 0&&(w=!1);var N=D.lastIndexOf("/");return N<0?w?D:"":D.substring(0,N+1)},T.ToDegrees=function(D){return 180*D/Math.PI},T.ToRadians=function(D){return D*Math.PI/180},T.MakeArray=function(D,w){return w===!0||D!==void 0&&D!=null?Array.isArray(D)?D:[D]:null},T.GetPointerPrefix=function(D){var w="pointer";return _.a.IsWindowObjectExist()&&!window.PointerEvent&&_.a.IsNavigatorAvailable()&&!navigator.pointerEnabled&&(w="mouse"),!D._badDesktopOS||D._badOS||document&&"ontouchend"in document||(w="mouse"),w},T.SetCorsBehavior=function(D,w){c.a.SetCorsBehavior(D,w)},T.CleanUrl=function(D){return D=D.replace(/#/gm,"%23")},Object.defineProperty(T,"PreprocessUrl",{get:function(){return c.a.PreprocessUrl},set:function(D){c.a.PreprocessUrl=D},enumerable:!1,configurable:!0}),T.LoadImage=function(D,w,N,I,V){return c.a.LoadImage(D,w,N,I,V)},T.LoadFile=function(D,w,N,I,V,W){return c.a.LoadFile(D,w,N,I,V,W)},T.LoadFileAsync=function(D,w){return w===void 0&&(w=!0),new Promise(function(N,I){c.a.LoadFile(D,function(V){N(V)},void 0,void 0,w,function(V,W){I(W)})})},T.LoadScript=function(D,w,N,I){if(_.a.IsWindowObjectExist()){var V=document.getElementsByTagName("head")[0],W=document.createElement("script");W.setAttribute("type","text/javascript"),W.setAttribute("src",D),I&&(W.id=I),W.onload=function(){w&&w()},W.onerror=function(j){N&&N("Unable to load script '"+D+"'",j)},V.appendChild(W)}},T.LoadScriptAsync=function(D,w){var N=this;return new Promise(function(I,V){N.LoadScript(D,function(){I()},function(W,j){V(j)})})},T.ReadFileAsDataURL=function(D,w,N){var I=new FileReader,V={onCompleteObservable:new B.c,abort:function(){return I.abort()}};return I.onloadend=function(W){V.onCompleteObservable.notifyObservers(V)},I.onload=function(W){w(W.target.result)},I.onprogress=N,I.readAsDataURL(D),V},T.ReadFile=function(D,w,N,I,V){return c.a.ReadFile(D,w,N,I,V)},T.FileAsURL=function(D){var w=new Blob([D]);return(window.URL||window.webkitURL).createObjectURL(w)},T.Format=function(D,w){return w===void 0&&(w=2),D.toFixed(w)},T.DeepCopy=function(D,w,N,I){u.a.DeepCopy(D,w,N,I)},T.IsEmpty=function(D){for(var w in D)if(D.hasOwnProperty(w))return!1;return!0},T.RegisterTopRootEvents=function(D,w){for(var N=0;N<w.length;N++){var I=w[N];D.addEventListener(I.name,I.handler,!1);try{window.parent&&window.parent.addEventListener(I.name,I.handler,!1)}catch{}}},T.UnregisterTopRootEvents=function(D,w){for(var N=0;N<w.length;N++){var I=w[N];D.removeEventListener(I.name,I.handler);try{D.parent&&D.parent.removeEventListener(I.name,I.handler)}catch{}}},T.DumpFramebuffer=function(D,w,N,I,V,W){V===void 0&&(V="image/png");for(var j=4*D,ne=w/2,te=N.readPixels(0,0,D,w),de=0;de<ne;de++)for(var pe=0;pe<j;pe++){var ae=pe+de*j,ee=pe+(w-de-1)*j,K=te[ae];te[ae]=te[ee],te[ee]=K}T._ScreenshotCanvas||(T._ScreenshotCanvas=document.createElement("canvas")),T._ScreenshotCanvas.width=D,T._ScreenshotCanvas.height=w;var $=T._ScreenshotCanvas.getContext("2d");if($){var L=$.createImageData(D,w);L.data.set(te),$.putImageData(L,0,0),T.EncodeScreenshotCanvasData(I,V,W)}},T.ToBlob=function(D,w,N){N===void 0&&(N="image/png"),D.toBlob||(D.toBlob=function(I,V,W){var j=this;setTimeout(function(){for(var ne=atob(j.toDataURL(V,W).split(",")[1]),te=ne.length,de=new Uint8Array(te),pe=0;pe<te;pe++)de[pe]=ne.charCodeAt(pe);I(new Blob([de]))})}),D.toBlob(function(I){w(I)},N)},T.EncodeScreenshotCanvasData=function(D,w,N){w===void 0&&(w="image/png"),D?D(T._ScreenshotCanvas.toDataURL(w)):this.ToBlob(T._ScreenshotCanvas,function(I){if("download"in document.createElement("a")){if(!N){var V=new Date,W=(V.getFullYear()+"-"+(V.getMonth()+1)).slice(2)+"-"+V.getDate()+"_"+V.getHours()+"-"+("0"+V.getMinutes()).slice(-2);N="screenshot_"+W+".png"}T.Download(I,N)}else{var j=URL.createObjectURL(I),ne=window.open("");if(!ne)return;var te=ne.document.createElement("img");te.onload=function(){URL.revokeObjectURL(j)},te.src=j,ne.document.body.appendChild(te)}},w)},T.Download=function(D,w){if(navigator&&navigator.msSaveBlob)navigator.msSaveBlob(D,w);else{var N=window.URL.createObjectURL(D),I=document.createElement("a");document.body.appendChild(I),I.style.display="none",I.href=N,I.download=w,I.addEventListener("click",function(){I.parentElement&&I.parentElement.removeChild(I)}),I.click(),window.URL.revokeObjectURL(N)}},T.BackCompatCameraNoPreventDefault=function(D){return typeof D[0]=="boolean"?D[0]:typeof D[1]=="boolean"&&D[1]},T.CreateScreenshot=function(D,w,N,I,V){throw R.a.WarnImport("ScreenshotTools")},T.CreateScreenshotAsync=function(D,w,N,I){throw R.a.WarnImport("ScreenshotTools")},T.CreateScreenshotUsingRenderTarget=function(D,w,N,I,V,W,j,ne){throw R.a.WarnImport("ScreenshotTools")},T.CreateScreenshotUsingRenderTargetAsync=function(D,w,N,I,V,W,j){throw R.a.WarnImport("ScreenshotTools")},T.RandomId=function(){return g.a.RandomId()},T.IsBase64=function(D){return!(D.length<5)&&D.substr(0,5)==="data:"},T.DecodeBase64=function(D){for(var w=atob(D.split(",")[1]),N=w.length,I=new Uint8Array(new ArrayBuffer(N)),V=0;V<N;V++)I[V]=w.charCodeAt(V);return I.buffer},T.GetAbsoluteUrl=function(D){var w=document.createElement("a");return w.href=D,w.href},Object.defineProperty(T,"errorsCount",{get:function(){return x.a.errorsCount}
26,enumerable:!1,configurable:!0}),T.Log=function(D){x.a.Log(D)},T.Warn=function(D){x.a.Warn(D)},T.Error=function(D){x.a.Error(D)},Object.defineProperty(T,"LogCache",{get:function(){return x.a.LogCache},enumerable:!1,configurable:!0}),T.ClearLogCache=function(){x.a.ClearLogCache()},Object.defineProperty(T,"LogLevels",{set:function(D){x.a.LogLevels=D},enumerable:!1,configurable:!0}),Object.defineProperty(T,"PerformanceLogLevel",{set:function(D){return(D&T.PerformanceUserMarkLogLevel)===T.PerformanceUserMarkLogLevel?(T.StartPerformanceCounter=T._StartUserMark,void(T.EndPerformanceCounter=T._EndUserMark)):(D&T.PerformanceConsoleLogLevel)===T.PerformanceConsoleLogLevel?(T.StartPerformanceCounter=T._StartPerformanceConsole,void(T.EndPerformanceCounter=T._EndPerformanceConsole)):(T.StartPerformanceCounter=T._StartPerformanceCounterDisabled,void(T.EndPerformanceCounter=T._EndPerformanceCounterDisabled))},enumerable:!1,configurable:!0}),T._StartPerformanceCounterDisabled=function(D,w){},T._EndPerformanceCounterDisabled=function(D,w){},T._StartUserMark=function(D,w){if(w===void 0&&(w=!0),!T._performance){if(!_.a.IsWindowObjectExist())return;T._performance=window.performance}w&&T._performance.mark&&T._performance.mark(D+"-Begin")},T._EndUserMark=function(D,w){w===void 0&&(w=!0),w&&T._performance.mark&&(T._performance.mark(D+"-End"),T._performance.measure(D,D+"-Begin",D+"-End"))},T._StartPerformanceConsole=function(D,w){w===void 0&&(w=!0),w&&(T._StartUserMark(D,w),console.time&&console.time(D))},T._EndPerformanceConsole=function(D,w){w===void 0&&(w=!0),w&&(T._EndUserMark(D,w),console.timeEnd(D))},Object.defineProperty(T,"Now",{get:function(){return M.a.Now},enumerable:!1,configurable:!0}),T.GetClassName=function(D,w){w===void 0&&(w=!1);var N=null;return!w&&D.getClassName?N=D.getClassName():(D instanceof Object&&(N=(w?D:Object.getPrototypeOf(D)).constructor.__bjsclassName__),N||(N=typeof D)),N},T.First=function(D,w){for(var N=0,I=D;N<I.length;N++){var V=I[N];if(w(V))return V}return null},T.getFullClassName=function(D,w){w===void 0&&(w=!1);var N=null,I=null;if(!w&&D.getClassName)N=D.getClassName();else{if(D instanceof Object){var V=w?D:Object.getPrototypeOf(D);N=V.constructor.__bjsclassName__,I=V.constructor.__bjsmoduleName__}N||(N=typeof D)}return N?(I!=null?I+".":"")+N:null},T.DelayAsync=function(D){return new Promise(function(w){setTimeout(function(){w()},D)})},T.IsSafari=function(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)},T.UseCustomRequestHeaders=!1,T.CustomRequestHeaders=C.a.CustomRequestHeaders,T._tmpFloatArray=new Float32Array(1),T.GetDOMTextContent=_.a.GetDOMTextContent,T.NoneLogLevel=x.a.NoneLogLevel,T.MessageLogLevel=x.a.MessageLogLevel,T.WarningLogLevel=x.a.WarningLogLevel,T.ErrorLogLevel=x.a.ErrorLogLevel,T.AllLogLevel=x.a.AllLogLevel,T.IsWindowObjectExist=_.a.IsWindowObjectExist,T.PerformanceNoneLogLevel=0,T.PerformanceUserMarkLogLevel=1,T.PerformanceConsoleLogLevel=2,T.StartPerformanceCounter=T._StartPerformanceCounterDisabled,T.EndPerformanceCounter=T._EndPerformanceCounterDisabled,T}();function h(T,D){return function(w){w.__bjsclassName__=T,w.__bjsmoduleName__=D??null}}var b=function(){function T(D,w,N,I){I===void 0&&(I=0),this.iterations=D,this.index=I-1,this._done=!1,this._fn=w,this._successCallback=N}return T.prototype.executeNext=function(){this._done||(this.index+1<this.iterations?(++this.index,this._fn(this)):this.breakLoop())},T.prototype.breakLoop=function(){this._done=!0,this._successCallback()},T.Run=function(D,w,N,I){I===void 0&&(I=0);var V=new T(D,w,N,I);return V.executeNext(),V},T.SyncAsyncForLoop=function(D,w,N,I,V,W){return W===void 0&&(W=0),T.Run(Math.ceil(D/w),function(j){V&&V()?j.breakLoop():setTimeout(function(){for(var ne=0;ne<w;++ne){var te=j.index*w+ne;if(te>=D)break;if(N(te),V&&V()){j.breakLoop();break}}j.executeNext()},W)},I)},T}();m.a.FallbackTexture="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/4QBmRXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUAAAABAAAARgEoAAMAAAABAAIAAAExAAIAAAAQAAAATgAAAAAAAABgAAAAAQAAAGAAAAABcGFpbnQubmV0IDQuMC41AP/bAEMABAIDAwMCBAMDAwQEBAQFCQYFBQUFCwgIBgkNCw0NDQsMDA4QFBEODxMPDAwSGBITFRYXFxcOERkbGRYaFBYXFv/bAEMBBAQEBQUFCgYGChYPDA8WFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFv/AABEIAQABAAMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQD
26BQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+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",E.a.Apply()},function(Ae,v,f){f.d(v,"a",function(){return S});var B=f(1),_=f(6),x=f(38),u=f(22),M=f(21),R=f(26),C=f(2),m=f(146),c=f(55),E=f(88),A=f(8),S=(f(123),f(129),f(124),function(g){function l(h,b,T,D){D===void 0&&(D=!1);var w=g.call(this,h,b,T,D)||this;if(w.enableOfflineSupport=!1,w.disableManifestCheck=!1,w.scenes=new Array,w.onNewSceneAddedObservable=new _.c,w.postProcesses=new Array,w.isPointerLock=!1,w.onResizeObservable=new _.c,w.onCanvasBlurObservable=new _.c,w.onCanvasFocusObservable=new _.c,w.onCanvasPointerOutObservable=new _.c,w.onBeginFrameObservable=new _.c,w.customAnimationFrameRequester=null,w.onEndFrameObservable=new _.c,w.onBeforeShaderCompilationObservable=new _.c,w.onAfterShaderCompilationObservable=new _.c,w._deterministicLockstep=!1,w._lockstepMaxSteps=4,w._timeStep=1/60,w._fps=60,w._deltaT
26ime=0,w._drawCalls=new c.a,w.canvasTabIndex=1,w.disablePerformanceMonitorInBackground=!1,w._performanceMonitor=new m.a,l.Instances.push(w),!h)return w;if(T=w._creationOptions,h.getContext){var N=h;if(w._onCanvasFocus=function(){w.onCanvasFocusObservable.notifyObservers(w)},w._onCanvasBlur=function(){w.onCanvasBlurObservable.notifyObservers(w)},N.addEventListener("focus",w._onCanvasFocus),N.addEventListener("blur",w._onCanvasBlur),w._onBlur=function(){w.disablePerformanceMonitorInBackground&&w._performanceMonitor.disable(),w._windowIsBackground=!0},w._onFocus=function(){w.disablePerformanceMonitorInBackground&&w._performanceMonitor.enable(),w._windowIsBackground=!1},w._onCanvasPointerOut=function(W){w.onCanvasPointerOutObservable.notifyObservers(W)},N.addEventListener("pointerout",w._onCanvasPointerOut),x.a.IsWindowObjectExist()){var I=w.getHostWindow();I.addEventListener("blur",w._onBlur),I.addEventListener("focus",w._onFocus);var V=document;w._onFullscreenChange=function(){V.fullscreen!==void 0?w.isFullscreen=V.fullscreen:V.mozFullScreen!==void 0?w.isFullscreen=V.mozFullScreen:V.webkitIsFullScreen!==void 0?w.isFullscreen=V.webkitIsFullScreen:V.msIsFullScreen!==void 0&&(w.isFullscreen=V.msIsFullScreen),w.isFullscreen&&w._pointerLockRequested&&N&&l._RequestPointerlock(N)},document.addEventListener("fullscreenchange",w._onFullscreenChange,!1),document.addEventListener("mozfullscreenchange",w._onFullscreenChange,!1),document.addEventListener("webkitfullscreenchange",w._onFullscreenChange,!1),document.addEventListener("msfullscreenchange",w._onFullscreenChange,!1),w._onPointerLockChange=function(){w.isPointerLock=V.mozPointerLockElement===N||V.webkitPointerLockElement===N||V.msPointerLockElement===N||V.pointerLockElement===N},document.addEventListener("pointerlockchange",w._onPointerLockChange,!1),document.addEventListener("mspointerlockchange",w._onPointerLockChange,!1),document.addEventListener("mozpointerlockchange",w._onPointerLockChange,!1),document.addEventListener("webkitpointerlockchange",w._onPointerLockChange,!1),!l.audioEngine&&T.audioEngine&&l.AudioEngineFactory&&(l.audioEngine=l.AudioEngineFactory(w.getRenderingCanvas()))}w._connectVREvents(),w.enableOfflineSupport=l.OfflineProviderFactory!==void 0,T.doNotHandleTouchAction||w._disableTouchAction(),w._deterministicLockstep=!!T.deterministicLockstep,w._lockstepMaxSteps=T.lockstepMaxSteps||0,w._timeStep=T.timeStep||1/60}return w._prepareVRComponent(),T.autoEnableWebVR&&w.initWebVR(),w}return Object(B.d)(l,g),Object.defineProperty(l,"NpmPackage",{get:function(){return R.a.NpmPackage},enumerable:!1,configurable:!0}),Object.defineProperty(l,"Version",{get:function(){return R.a.Version},enumerable:!1,configurable:!0}),Object.defineProperty(l,"Instances",{get:function(){return u.a.Instances},enumerable:!1,configurable:!0}),Object.defineProperty(l,"LastCreatedEngine",{get:function(){return u.a.LastCreatedEngine},enumerable:!1,configurable:!0}),Object.defineProperty(l,"LastCreatedScene",{get:function(){return u.a.LastCreatedScene},enumerable:!1,configurable:!0}),l.MarkAllMaterialsAsDirty=function(h,b){for(var T=0;T<l.Instances.length;T++)for(var D=l.Instances[T],w=0;w<D.scenes.length;w++)D.scenes[w].markAllMaterialsAsDirty(h,b)},l.DefaultLoadingScreenFactory=function(h){throw M.a.WarnImport("LoadingScreen")},Object.defineProperty(l.prototype,"_supportsHardwareTextureRescaling",{get:function(){return!!l._RescalePostProcessFactory},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"performanceMonitor",{get:function(){return this._performanceMonitor},enumerable:!1,configurable:!0}),l.prototype.getInputElement=function(){return this._renderingCanvas},l.prototype.getAspectRatio=function(h,b){b===void 0&&(b=!1);var T=h.viewport;return this.getRenderWidth(b)*T.width/(this.getRenderHeight(b)*T.height)},l.prototype.getScreenAspectRatio=function(){return this.getRenderWidth(!0)/this.getRenderHeight(!0)},l.prototype.getRenderingCanvasClientRect=function(){return this._renderingCanvas?this._renderingCanvas.getBoundingClientRect():null},l.prototype.getInputElementClientRect=function(){return this._renderingCanvas?this.getInputElement().getBoundingClientRect():null},l.prototype.isDeterministicLockStep=function(){return this._deterministicLockstep},l.prototype.getLockstepMaxSteps=function(){return this._lockstepMaxSteps},l.prototype.getTimeStep=function(){return 1e3*this._timeStep},l.prototype.generateMipMapsForCubemap=function(h,b){if(b===void 0&&(b=!0),h.generateMipMaps){var T=this._gl;this._bindTextureDirectly(T.TEXTURE_CUBE_MAP,h,!0),T.generateMipmap(T.TEXTURE_CUBE_MAP),b&&this._bindTextureDirectly(T.TEXTURE_CUBE_MAP,null)}},l.prototype.setState=function(h,b,T,D){b===void 0&&(b=0),D===void 0&&(D=!1),(this._depthCullingState.cull!==h||T)&&(this._depthCullingState.cull=h);var w=this.cullBackFaces?this._gl.BACK:this._gl.FRONT;(this._depthCullingState.cullFace!==w||T)&&(this._depthCullingState.cullFace=w),this.setZOffset(b);var N=D?this._gl.CW:this._gl.CCW;(this._depthCullingState.frontFace!==N||T)&&(this._depthCullingState.frontFace=N)},l.prototype.setZOffset=function(h){this._depthCullingState.zOffset=h},l.prototype.getZOffset=function(){return this._depthCullingState.zOffset},l.prototype.setDepthBuffer=function(h){this._depthCullingState.depthTest=h},l.prototype.getDepthWrite=function(){return this._depthCullingState.depthMask},l.prototype.setDepthWrite=function(h){this._depthCullingState.depthMask=h},l.prototype.getStencilBuffer=function(){return this._stencilState.stencilTest},l.prototype.setStencilBuffer=function(h){this._stencilState.stencilTest=h},l.prototype.getStencilMask=function(){return this._stencilState.stencilMask},l.prototype.setStencilMask=function(h){this._stencilState.stencilMask=h},l.prototype.getStencilFunction=function(){return this._stencilState.stencilFunc},l.prototype.getStencilFunctionReference=function(){return this._stencilState.stencilFuncRef},l.prototype.getStencilFunctionMask=function(){return this._stencilState.stencilFuncMask},l.prototype.setStencilFunction=function(h){this._stencilState.stencilFunc=h},l.prototype.setStencilFunctionReference=function(h){this._stencilState.stencilFuncRef=h},l.prototype.setStencilFunctionMask=function(h){this._stencilState.stencilFuncMask=h},l.prototype.getStencilOperationFail=function(){return this._stencilState.stencilOpStencilFail},l.prototype.getStencilOperationDepthFail=function(){return this._stencilState.stencilOpDepthFail},l.prototype.getStencilOperationPass=function(){return this._stencilState.stencilOpStencilDepthPass},l.prototype.setStencilOperationFail=function(h){this._stencilState.stencilOpStencilFail=h},l.prototype.setStencilOperationDepthFail=function(h){this._stencilState.stencilOpDepthFail=h},l.prototype.setStencilOperationPass=function(h){this._stencilState.stencilOpStencilDepthPass=h},l.prototype.setDitheringState=function(h){h?this._gl.enable(this._gl.DITHER):this._gl.disable(this._gl.DITHER)},l.prototype.setRasterizerState=function(h){h?this._gl.disable(this._gl.RASTERIZER_DISCARD):this._gl.enable(this._gl.RASTERIZER_DISCARD)},l.prototype.getDepthFunction=function(){return this._depthCullingState.depthFunc},l.prototype.setDepthFunction=function(h){this._depthCullingState.depthFunc=h},l.prototype.setDepthFunctionToGreater=function(){this._depthCullingState.depthFunc=this._gl.GREATER},l.prototype.setDepthFunctionToGreaterOrEqual=function(){this._depthCullingState.depthFunc=this._gl.GEQUAL},l.prototype.setDepthFunctionToLess=function(){this._depthCullingState.depthFunc=this._gl.LESS},l.prototype.setDepthFunctionToLessOrEqual=function(){this._depthCullingState.depthFunc=this._gl.LEQUAL},l.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()},l.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)},l.prototype.setDirectViewport=function(h,b,T,D){var w=this._cachedViewport;return this._cachedViewport=null,this._viewport(h,b,T,D),w},l.prototype.scissorClear=function(h,b,T,D,w){this.enableScissor(h,b,T,D),this.clear(w,!0,
26!0,!0),this.disableScissor()},l.prototype.enableScissor=function(h,b,T,D){var w=this._gl;w.enable(w.SCISSOR_TEST),w.scissor(h,b,T,D)},l.prototype.disableScissor=function(){var h=this._gl;h.disable(h.SCISSOR_TEST)},l.prototype._reportDrawCall=function(){this._drawCalls.addCount(1,!1)},l.prototype.initWebVR=function(){throw M.a.WarnImport("WebVRCamera")},l.prototype._prepareVRComponent=function(){},l.prototype._connectVREvents=function(h,b){},l.prototype._submitVRFrame=function(){},l.prototype.disableVR=function(){},l.prototype.isVRPresenting=function(){return!1},l.prototype._requestVRFrame=function(){},l.prototype._loadFileAsync=function(h,b,T){var D=this;return new Promise(function(w,N){D._loadFile(h,function(I){w(I)},void 0,b,T,function(I,V){N(V)})})},l.prototype.getVertexShaderSource=function(h){var b=this._gl.getAttachedShaders(h);return b?this._gl.getShaderSource(b[0]):null},l.prototype.getFragmentShaderSource=function(h){var b=this._gl.getAttachedShaders(h);return b?this._gl.getShaderSource(b[1]):null},l.prototype.setDepthStencilTexture=function(h,b,T){h!==void 0&&(b&&(this._boundUniforms[h]=b),T&&T.depthStencilTexture?this._setTexture(h,T,!1,!0):this._setTexture(h,null))},l.prototype.setTextureFromPostProcess=function(h,b){this._bindTexture(h,b?b._textures.data[b._currentRenderTextureInd]:null)},l.prototype.setTextureFromPostProcessOutput=function(h,b){this._bindTexture(h,b?b._outputTexture:null)},l.prototype._rebuildBuffers=function(){for(var h=0,b=this.scenes;h<b.length;h++){var T=b[h];T.resetCachedMaterial(),T._rebuildGeometries(),T._rebuildTextures()}g.prototype._rebuildBuffers.call(this)},l.prototype._renderFrame=function(){for(var h=0;h<this._activeRenderLoops.length;h++)(0,this._activeRenderLoops[h])()},l.prototype._renderLoop=function(){if(!this._contextWasLost){var h=!0;!this.renderEvenInBackground&&this._windowIsBackground&&(h=!1),h&&(this.beginFrame(),this._renderViews()||this._renderFrame(),this.endFrame())}this._activeRenderLoops.length>0?this.customAnimationFrameRequester?(this.customAnimationFrameRequester.requestID=this._queueNewFrame(this.customAnimationFrameRequester.renderFunction||this._boundRenderFunction,this.customAnimationFrameRequester),this._frameHandler=this.customAnimationFrameRequester.requestID):this.isVRPresenting()?this._requestVRFrame():this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow()):this._renderingQueueLaunched=!1},l.prototype._renderViews=function(){return!1},l.prototype.switchFullscreen=function(h){this.isFullscreen?this.exitFullscreen():this.enterFullscreen(h)},l.prototype.enterFullscreen=function(h){this.isFullscreen||(this._pointerLockRequested=h,this._renderingCanvas&&l._RequestFullscreen(this._renderingCanvas))},l.prototype.exitFullscreen=function(){this.isFullscreen&&l._ExitFullscreen()},l.prototype.enterPointerlock=function(){this._renderingCanvas&&l._RequestPointerlock(this._renderingCanvas)},l.prototype.exitPointerlock=function(){l._ExitPointerlock()},l.prototype.beginFrame=function(){this._measureFps(),this.onBeginFrameObservable.notifyObservers(this),g.prototype.beginFrame.call(this)},l.prototype.endFrame=function(){g.prototype.endFrame.call(this),this._submitVRFrame(),this.onEndFrameObservable.notifyObservers(this)},l.prototype.resize=function(){this.isVRPresenting()||g.prototype.resize.call(this)},l.prototype.setSize=function(h,b){if(!this._renderingCanvas||!g.prototype.setSize.call(this,h,b))return!1;if(this.scenes){for(var T=0;T<this.scenes.length;T++)for(var D=this.scenes[T],w=0;w<D.cameras.length;w++)D.cameras[w]._currentRenderId=0;this.onResizeObservable.hasObservers()&&this.onResizeObservable.notifyObservers(this)}return!0},l.prototype._deletePipelineContext=function(h){var b=h;b&&b.program&&b.transformFeedback&&(this.deleteTransformFeedback(b.transformFeedback),b.transformFeedback=null),g.prototype._deletePipelineContext.call(this,h)},l.prototype.createShaderProgram=function(h,b,T,D,w,N){N===void 0&&(N=null),w=w||this._gl,this.onBeforeShaderCompilationObservable.notifyObservers(this);var I=g.prototype.createShaderProgram.call(this,h,b,T,D,w,N);return this.onAfterShaderCompilationObservable.notifyObservers(this),I},l.prototype._createShaderProgram=function(h,b,T,D,w){w===void 0&&(w=null);var N=D.createProgram();if(h.program=N,!N)throw new Error("Unable to create program");if(D.attachShader(N,b),D.attachShader(N,T),this.webGLVersion>1&&w){var I=this.createTransformFeedback();this.bindTransformFeedback(I),this.setTranformFeedbackVaryings(N,w),h.transformFeedback=I}return D.linkProgram(N),this.webGLVersion>1&&w&&this.bindTransformFeedback(null),h.context=D,h.vertexShader=b,h.fragmentShader=T,h.isParallelCompiled||this._finalizePipelineContext(h),N},l.prototype._releaseTexture=function(h){g.prototype._releaseTexture.call(this,h),this.scenes.forEac
26h(function(b){b.postProcesses.forEach(function(T){T._outputTexture==h&&(T._outputTexture=null)}),b.cameras.forEach(function(T){T._postProcesses.forEach(function(D){D&&D._outputTexture==h&&(D._outputTexture=null)})})})},l.prototype._rescaleTexture=function(h,b,T,D,w){var N=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 I=this.createRenderTargetTexture({width:b.width,height:b.height},{generateMipMaps:!1,type:C.a.TEXTURETYPE_UNSIGNED_INT,samplingMode:C.a.TEXTURE_BILINEAR_SAMPLINGMODE,generateDepthBuffer:!1,generateStencilBuffer:!1});!this._rescalePostProcess&&l._RescalePostProcessFactory&&(this._rescalePostProcess=l._RescalePostProcessFactory(this)),this._rescalePostProcess.getEffect().executeWhenCompiled(function(){N._rescalePostProcess.onApply=function(W){W._bindTexture("textureSampler",h)};var V=T;V||(V=N.scenes[N.scenes.length-1]),V.postProcessManager.directRender([N._rescalePostProcess],I,!0),N._bindTextureDirectly(N._gl.TEXTURE_2D,b,!0),N._gl.copyTexImage2D(N._gl.TEXTURE_2D,0,D,0,0,b.width,b.height,0),N.unBindFramebuffer(I),N._releaseTexture(I),w&&w()})},l.prototype.getFps=function(){return this._fps},l.prototype.getDeltaTime=function(){return this._deltaTime},l.prototype._measureFps=function(){this._performanceMonitor.sampleFrame(),this._fps=this._performanceMonitor.averageFPS,this._deltaTime=this._performanceMonitor.instantaneousFrameTime||0},l.prototype._uploadImageToTexture=function(h,b,T,D){T===void 0&&(T=0),D===void 0&&(D=0);var w=this._gl,N=this._getWebGLTextureType(h.type),I=this._getInternalFormat(h.format),V=this._getRGBABufferInternalSizedFormat(h.type,I),W=h.isCube?w.TEXTURE_CUBE_MAP:w.TEXTURE_2D;this._bindTextureDirectly(W,h,!0),this._unpackFlipY(h.invertY);var j=w.TEXTURE_2D;h.isCube&&(j=w.TEXTURE_CUBE_MAP_POSITIVE_X+T),w.texImage2D(j,D,V,I,N,b),this._bindTextureDirectly(W,null,!0)},l.prototype.updateRenderTargetTextureSampleCount=function(h,b){if(this.webGLVersion<2||!h)return 1;if(h.samples===b)return b;var T=this._gl;if(b=Math.min(b,this.getCaps().maxMSAASamples),h._depthStencilBuffer&&(T.deleteRenderbuffer(h._depthStencilBuffer),h._depthStencilBuffer=null),h._MSAAFramebuffer&&(T.deleteFramebuffer(h._MSAAFramebuffer),h._MSAAFramebuffer=null),h._MSAARenderBuffer&&(T.deleteRenderbuffer(h._MSAARenderBuffer),h._MSAARenderBuffer=null),b>1&&T.renderbufferStorageMultisample){var D=T.createFramebuffer();if(!D)throw new Error("Unable to create multi sampled framebuffer");h._MSAAFramebuffer=D,this._bindUnboundFramebuffer(h._MSAAFramebuffer);var w=T.createRenderbuffer();if(!w)throw new Error("Unable to create multi sampled framebuffer");T.bindRenderbuffer(T.RENDERBUFFER,w),T.renderbufferStorageMultisample(T.RENDERBUFFER,b,this._getRGBAMultiSampleBufferFormat(h.type),h.width,h.height),T.framebufferRenderbuffer(T.FRAMEBUFFER,T.COLOR_ATTACHMENT0,T.RENDERBUFFER,w),h._MSAARenderBuffer=w}else this._bindUnboundFramebuffer(h._framebuffer);return h.samples=b,h._depthStencilBuffer=this._setupFramebufferDepthAttachments(h._generateStencilBuffer,h._generateDepthBuffer,h.width,h.height,b),this._bindUnboundFramebuffer(null),b},l.prototype.updateTextureComparisonFunction=function(h,b){if(this.webGLVersion!==1){var T=this._gl;h.isCube?(this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,h,!0),b===0?(T.texParameteri(T.TEXTURE_CUBE_MAP,T.TEXTURE_COMPARE_FUNC,C.a.LEQUAL),T.texParameteri(T.TEXTURE_CUBE_MAP,T.TEXTURE_COMPARE_MODE,T.NONE)):(T.texParameteri(T.TEXTURE_CUBE_MAP,T.TEXTURE_COMPARE_FUNC,b),T.texParameteri(T.TEXTURE_CUBE_MAP,T.TEXTURE_COMPARE_MODE,T.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)):(this._bindTextureDirectly(this._gl.TEXTURE_2D,h,!0),b===0?(T.texParameteri(T.TEXTURE_2D,T.TEXTURE_COMPARE_FUNC,C.a.LEQUAL),T.texParameteri(T.TEXTURE_2D,T.TEXTURE_COMPARE_MODE,T.NONE)):(T.texParameteri(T.TEXTURE_2D,T.TEXTURE_COMPARE_FUNC,b),T.texParameteri(T.TEXTURE_2D,T.TEXTURE_COMPARE_MODE,T.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_2D,null)),h._comparisonFunction=b}else A.a.Error("WebGL 1 does not support texture comparison.")},l.prototype.createInstancesBuffer=function(h){var b=this._gl.createBuffer();if(!b)throw new Error("Unable to create instance buffer");var T=new E.a(b);return T.capacity=h,this.bindArrayBuffer(T),this._gl.bufferData(this._gl.ARRAY_BUFFER,h,this._gl.DYNAMIC_DRAW),T},l.prototype.deleteInstancesBuffer=function(h){this._gl.deleteBuffer(h)},l.prototype._clientWaitAsync=function(h,b,T){b===void 0&&(b=0),T===void 0&&(T=10);var D=this._gl;return new Promise(function(w,N){var I=function(){var V=D.clientWaitSync(h,b,0);V!=D.WAIT_FAILED?V!=D.TIMEOUT_EXPIRED?w():setTimeout(I,T):N()};I()})},l.prototype._readPixelsAsync=function(h,b,T,D,w,N,I){if(this._webGLVersion<2)throw new Error("_readPixelsAsync only work on WebGL2+");var V=this._gl,W=V.createBuffer();V.bindBuffer(V.PIXEL_PACK_BUFFER,W),V.bufferData(V.PIXEL_PACK_BUFFER,I.byteLength,V.STREAM_READ),V.readPixels(h,b,T,D,w,N,0),V.bindBuffer(V.PIXEL_PACK_BUFFER,null);var j=V.fenceSync(V.SYNC_GPU_COMMANDS_COMPLETE,0);return j?(V.flush(),this._clientWaitAsync(j,0,10).then(function(){return V.deleteSync(j),V.bindBuffer(V.PIXEL_PACK_BUFFER,W),V.getBufferSubData(V.PIXEL_PACK_BUFFER,0,I),V.bindBuffer(V.PIXEL_PACK_BUFFER,null),V.deleteBuffer(W),I})):null},l.prototype.dispose=function(){for(this.hideLoadingUI(),this.onNewSceneAddedObservable.clear();this.postProcesses.length;
26)this.postProcesses[0].dispose();for(this._rescalePostProcess&&this._rescalePostProcess.dispose();this.scenes.length;)this.scenes[0].dispose();l.Instances.length===1&&l.audioEngine&&l.audioEngine.dispose(),this.disableVR(),x.a.IsWindowObjectExist()&&(window.removeEventListener("blur",this._onBlur),window.removeEventListener("focus",this._onFocus),this._renderingCanvas&&(this._renderingCanvas.removeEventListener("focus",this._onCanvasFocus),this._renderingCanvas.removeEventListener("blur",this._onCanvasBlur),this._renderingCanvas.removeEventListener("pointerout",this._onCanvasPointerOut)),x.a.IsDocumentAvailable()&&(document.removeEventListener("fullscreenchange",this._onFullscreenChange),document.removeEventListener("mozfullscreenchange",this._onFullscreenChange),document.removeEventListener("webkitfullscreenchange",this._onFullscreenChange),document.removeEventListener("msfullscreenchange",this._onFullscreenChange),document.removeEventListener("pointerlockchange",this._onPointerLockChange),document.removeEventListener("mspointerlockchange",this._onPointerLockChange),document.removeEventListener("mozpointerlockchange",this._onPointerLockChange),document.removeEventListener("webkitpointerlockchange",this._onPointerLockChange))),g.prototype.dispose.call(this);var h=l.Instances.indexOf(this);h>=0&&l.Instances.splice(h,1),this.onResizeObservable.clear(),this.onCanvasBlurObservable.clear(),this.onCanvasFocusObservable.clear(),this.onCanvasPointerOutObservable.clear(),this.onBeginFrameObservable.clear(),this.onEndFrameObservable.clear()},l.prototype._disableTouchAction=function(){this._renderingCanvas&&this._renderingCanvas.setAttribute&&(this._renderingCanvas.setAttribute("touch-action","none"),this._renderingCanvas.style.touchAction="none",this._renderingCanvas.style.msTouchAction="none")},l.prototype.displayLoadingUI=function(){if(x.a.IsWindowObjectExist()){var h=this.loadingScreen;h&&h.displayLoadingUI()}},l.prototype.hideLoadingUI=function(){if(x.a.IsWindowObjectExist()){var h=this._loadingScreen;h&&h.hideLoadingUI()}},Object.defineProperty(l.prototype,"loadingScreen",{get:function(){return!this._loadingScreen&&this._renderingCanvas&&(this._loadingScreen=l.DefaultLoadingScreenFactory(this._renderingCanvas)),this._loadingScreen},set:function(h){this._loadingScreen=h},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"loadingUIText",{set:function(h){this.loadingScreen.loadingUIText=h},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"loadingUIBackgroundColor",{set:function(h){this.loadingScreen.loadingUIBackgroundColor=h},enumerable:!1,configurable:!0}),l._RequestPointerlock=function(h){h.requestPointerLock=h.requestPointerLock||h.msRequestPointerLock||h.mozRequestPointerLock||h.webkitRequestPointerLock,h.requestPointerLock&&h.requestPointerLock()},l._ExitPointerlock=function(){var h=document;document.exitPointerLock=document.exitPointerLock||h.msExitPointerLock||h.mozExitPointerLock||h.webkitExitPointerLock,document.exitPointerLock&&document.exitPointerLock()},l._RequestFullscreen=function(h){var b=h.requestFullscreen||h.msRequestFullscreen||h.webkitRequestFullscreen||h.mozRequestFullScreen;b&&b.call(h)},l._ExitFullscreen=function(){var h=document;document.exitFullscreen?document.exitFullscreen():h.mozCancelFullScreen?h.mozCancelFullScreen():h.webkitCancelFullScreen?h.webkitCancelFullScreen():h.msCancelFullScreen&&h.msCancelFullScreen()},l.ALPHA_DISABLE=C.a.ALPHA_DISABLE,l.ALPHA_ADD=C.a.ALPHA_ADD,l.ALPHA_COMBINE=C.a.ALPHA_COMBINE,l.ALPHA_SUBTRACT=C.a.ALPHA_SUBTRACT,l.ALPHA_MULTIPLY=C.a.ALPHA_MULTIPLY,l.ALPHA_MAXIMIZED=C.a.ALPHA_MAXIMIZED,l.ALPHA_ONEONE=C.a.ALPHA_ONEONE,l.ALPHA_PREMULTIPLIED=C.a.ALPHA_PREMULTIPLIED,l.ALPHA_PREMULTIPLIED_PORTERDUFF=C.a.ALPHA_PREMULTIPLIED_PORTERDUFF,l.ALPHA_INTERPOLATE=C.a.ALPHA_INTERPOLATE,l.ALPHA_SCREENMODE=C.a.ALPHA_SCREENMODE,l.DELAYLOADSTATE_NONE=C.a.DELAYLOADSTATE_NONE,l.DELAYLOADSTATE_LOADED=C.a.DELAYLOADSTATE_LOADED,l.DELAYLOADSTATE_LOADING=C.a.DELAYLOADSTATE_LOADING,l.DELAYLOADSTATE_NOTLOADED=C.a.DELAYLOADSTATE_NOTLOADED,l.NEVER=C.a.NEVER,l.ALWAYS=C.a.ALWAYS,l.LESS=C.a.LESS,l.EQUAL=C.a.EQUAL,l.LEQUAL=C.a.LEQUAL,l.GREATER=C.a.GREATER,l.GEQUAL=C.a.GEQUAL,l.NOTEQUAL=C.a.NOTEQUAL,l.KEEP=C.a.KEEP,l.REPLACE=C.a.REPLACE,l.INCR=C.a.INCR,l.DECR=C.a.DECR,l.INVERT=C.a.INVERT,l.INCR_WRAP=C.a.INCR_WRAP,l.DECR_WRAP=C.a.DECR_WRAP,l.TEXTURE_CLAMP_ADDRESSMODE=C.a.TEXTURE_CLAMP_ADDRESSMODE,l.TEXTURE_WRAP_ADDRESSMODE=C.a.TEXTURE_WRAP_ADDRESSMODE,l.TEXTURE_MIRROR_ADDRESSMODE=C.a.TEXTURE_MIRROR_ADDRESSMODE,l.TEXTUREFORMAT_ALPHA=C.a.TEXTUREFORMAT_ALPHA,l.TEXTUREFORMAT_LUMINANCE=C.a.TEXTUREFORMAT_LUMINANCE,l.TEXTUREFORMAT_LUMINANCE_ALPHA=C.a.TEXTUREFORMAT_LUMINANCE_ALPHA,l.TEXTUREFORMAT_RGB=C.a.TEXTUREFORMAT_RGB,l.TEXTUREFORMAT_RGBA=C.a.TEXTUREFORMAT_RGBA,l.TEXTUREFORMAT_RED=C.a.TEXTUREFORMAT_RED,l.TEXTUREFORMAT_R=C.a.TEXTUREFORMAT_R,l.TEXTUREFORMAT_RG=C.a.TEXTUREFORMAT_RG,l.TEXTUREFORMAT_RED_INTEGER=C.a.TEXTUREFORMAT_RED_INTEGER,l.TEXTUREFORMAT_R_INTEGER=C.a.TEXTUREFORMAT_R_INTEGER,l.TEXTUREFORMAT_RG_INTEGER=C.a.TEXTUREFORMAT_RG_INTEGER,l.TEXTUREFORMAT_RGB_INTEGER=C.a.TEXTUREFORMAT_RGB_INTEGER,l.TEXTUREFORMAT_RGBA_INTEGER=C.a.TEXTUREFORMAT_RGBA_INTEGER,l.TEXTURETYPE_UNSIGNED_BYTE=C.a.TEXTURETYPE_UNSIGNED_BYTE,l.TEXTURETYPE_UNSIGNED_INT=C.a.TEXTURETYPE_UNSIGNED_INT,l.TEXTURETYPE_FLOAT=C.a.TEXTURETYPE_FLOAT,l.TEXTURETYPE_HALF_FLOAT=C.a.TEXTURETYPE_HALF_FLOAT,l.TEXTURETYPE_BYTE=C.a.TEXTURETYPE_BYTE,l.TEXTURETYPE_SHORT=C.a.TEXTURETYPE_SHORT,l.TEXTURETYPE_UNSIGNED_SHORT=C.a.TEXTURETYPE_UNSIGNED_SHORT,l.TEXTURETYPE_INT=C.a.TEXTURETYPE_INT,l.TEXTURETYPE_UNSIGNED_INTEGER=C.a.TEXTURETYPE_UNSIGNED_INTEGER,l.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=C.a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4,l.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=C.a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1,l.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=C.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5,l.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=C.a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV,l.TEXTURETYPE_UNSIGNED_INT_24_8=C.a.TEXTURETYPE_UNSIGNED_INT_24_8,l.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=C.a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV,l.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=C.a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV,l.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=C.a.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV,l.TEXTURE_NEAREST_SAMPL
26INGMODE=C.a.TEXTURE_NEAREST_SAMPLINGMODE,l.TEXTURE_BILINEAR_SAMPLINGMODE=C.a.TEXTURE_BILINEAR_SAMPLINGMODE,l.TEXTURE_TRILINEAR_SAMPLINGMODE=C.a.TEXTURE_TRILINEAR_SAMPLINGMODE,l.TEXTURE_NEAREST_NEAREST_MIPLINEAR=C.a.TEXTURE_NEAREST_NEAREST_MIPLINEAR,l.TEXTURE_LINEAR_LINEAR_MIPNEAREST=C.a.TEXTURE_LINEAR_LINEAR_MIPNEAREST,l.TEXTURE_LINEAR_LINEAR_MIPLINEAR=C.a.TEXTURE_LINEAR_LINEAR_MIPLINEAR,l.TEXTURE_NEAREST_NEAREST_MIPNEAREST=C.a.TEXTURE_NEAREST_NEAREST_MIPNEAREST,l.TEXTURE_NEAREST_LINEAR_MIPNEAREST=C.a.TEXTURE_NEAREST_LINEAR_MIPNEAREST,l.TEXTURE_NEAREST_LINEAR_MIPLINEAR=C.a.TEXTURE_NEAREST_LINEAR_MIPLINEAR,l.TEXTURE_NEAREST_LINEAR=C.a.TEXTURE_NEAREST_LINEAR,l.TEXTURE_NEAREST_NEAREST=C.a.TEXTURE_NEAREST_NEAREST,l.TEXTURE_LINEAR_NEAREST_MIPNEAREST=C.a.TEXTURE_LINEAR_NEAREST_MIPNEAREST,l.TEXTURE_LINEAR_NEAREST_MIPLINEAR=C.a.TEXTURE_LINEAR_NEAREST_MIPLINEAR,l.TEXTURE_LINEAR_LINEAR=C.a.TEXTURE_LINEAR_LINEAR,l.TEXTURE_LINEAR_NEAREST=C.a.TEXTURE_LINEAR_NEAREST,l.TEXTURE_EXPLICIT_MODE=C.a.TEXTURE_EXPLICIT_MODE,l.TEXTURE_SPHERICAL_MODE=C.a.TEXTURE_SPHERICAL_MODE,l.TEXTURE_PLANAR_MODE=C.a.TEXTURE_PLANAR_MODE,l.TEXTURE_CUBIC_MODE=C.a.TEXTURE_CUBIC_MODE,l.TEXTURE_PROJECTION_MODE=C.a.TEXTURE_PROJECTION_MODE,l.TEXTURE_SKYBOX_MODE=C.a.TEXTURE_SKYBOX_MODE,l.TEXTURE_INVCUBIC_MODE=C.a.TEXTURE_INVCUBIC_MODE,l.TEXTURE_EQUIRECTANGULAR_MODE=C.a.TEXTURE_EQUIRECTANGULAR_MODE,l.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=C.a.TEXTURE_FIXED_EQUIRECTANGULAR_MODE,l.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=C.a.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE,l.SCALEMODE_FLOOR=C.a.SCALEMODE_FLOOR,l.SCALEMODE_NEAREST=C.a.SCALEMODE_NEAREST,l.SCALEMODE_CEILING=C.a.SCALEMODE_CEILING,l._RescalePostProcessFactory=null,l}(R.a))},function(Ae,v,f){f.d(v,"a",function(){return B});var B=function(){function _(){}return _.WithinEpsilon=function(x,u,M){M===void 0&&(M=1401298e-51);var R=x-u;return-M<=R&&R<=M},_.ToHex=function(x){var u=x.toString(16);return x<=15?("0"+u).toUpperCase():u.toUpperCase()},_.Sign=function(x){return(x=+x)==0||isNaN(x)?x:x>0?1:-1},_.Clamp=function(x,u,M){return u===void 0&&(u=0),M===void 0&&(M=1),Math.min(M,Math.max(u,x))},_.Log2=function(x){return Math.log(x)*Math.LOG2E},_.Repeat=function(x,u){return x-Math.floor(x/u)*u},_.Normalize=function(x,u,M){return(x-u)/(M-u)},_.Denormalize=function(x,u,M){return x*(M-u)+u},_.DeltaAngle=function(x,u){var M=_.Repeat(u-x,360);return M>180&&(M-=360),M},_.PingPong=function(x,u){var M=_.Repeat(x,2*u);return u-Math.abs(M-u)},_.SmoothStep=function(x,u,M){var R=_.Clamp(M);return u*(R=-2*R*R*R+3*R*R)+x*(1-R)},_.MoveTowards=function(x,u,M){return Math.abs(u-x)<=M?u:x+_.Sign(u-x)*M},_.MoveTowardsAngle=function(x,u,M){var R=_.DeltaAngle(x,u),C=0;return-M<R&&R<M?C=u:(u=x+R,C=_.MoveTowards(x,u,M)),C},_.Lerp=function(x,u,M){return x+(u-x)*M},_.LerpAngle=function(x,u,M){var R=_.Repeat(u-x,360);return R>180&&(R-=360),x+R*_.Clamp(M)},_.InverseLerp=function(x,u,M){return x!=u?_.Clamp((M-x)/(u-x)):0},_.Hermite=function(x,u,M,R,C){var m=C*C,c=C*m;return x*(2*c-3*m+1)+M*(-2*c+3*m)+u*(c-2*m+C)+R*(c-m)},_.RandomRange=function(x,u){return x===u?x:Math.random()*(u-x)+x},_.RangeToPercent=function(x,u,M){return(x-u)/(M-u)},_.PercentToRange=function(x,u,M){return(M-u)*x+u},_.NormalizeRadians=function(x){return x-=_.TwoPi*Math.floor((x+Math.PI)/_.TwoPi)},_.TwoPi=2*Math.PI,_}()},function(Ae,v,f){f.d(v,"a",function(){return c});var B=f(8),_=f(20),x=f(22),u=f(4),M=f(48),R=f(2),C=f(9),m=f(119),c=function(){function E(){}return E.BindEyePosition=function(A,S,g){if(g===void 0&&(g="vEyePosition"),S._forcedViewPosition)A.setVector3(g,S._forcedViewPosition);else{var l=S.activeCamera.globalPosition;l||(l=S.activeCamera.devicePosition),A.setVector3(g,S._mirroredCameraPosition?S._mirroredCameraPosition:l)}},E.PrepareDefinesForMergedUV=function(A,S,g){S._needUVs=!0,S[g]=!0,A.getTextureMatrix().isIdentityAs3x2()?(S[g+"DIRECTUV"]=A.coordinatesIndex+1,A.coordinatesIndex===0?S.MAINUV1=!0:S.MAINUV2=!0):S[g+"DIRECTUV"]=0},E.BindTextureMatrix=function(A,S,g){var l=A.getTextureMatrix();S.updateMatrix(g+"Matrix",l)},E.GetFogState=function(A,S){return S.fogEnabled&&A.applyFog&&S.fogMode!==_.a.FOGMODE_NONE},E.PrepareDefinesForMisc=function(A,S,g,l,h,b,T){T._areMiscDirty&&(T.LOGARITHMICDEPTH=g,T.POINTSIZE=l,T.FOG=h&&this.GetFogState(A,S),T.NONUNIFORMSCALING=A.nonUniformScaling,T.ALPHATEST=b)},E.PrepareDefinesForFrameBoundValues=function(A,S,g,l,h,b){h===void 0&&(h=null),b===void 0&&(b=!1);var T,D,w,N,I,V,W=!1;T=h??(A.clipPlane!==void 0&&A.clipPlane!==null),D=h??(A.clipPlane2!==void 0&&A.clipPlane2!==null),w=h??(A.clipPlane3!==void 0&&A.clipPlane3!==null),N=h??(A.clipPlane4!==void 0&&A.clipPlane4!==null),I=h??(A.clipPlane5!==void 0&&A.clipPlane5!==null),V=h??(A.clipPlane6!==void 0&&A.clipPlane6!==null),g.CLIPPLANE!==T&&(g.CLIPPLANE=T,W=!0),g.CLIPPLANE2!==D&&(g.CLIPPLANE2=D,W=!0),g.CLIPPLANE3!==w&&(g.CLIPPLANE3=w,W=!0),g.CLIPPLANE4!==N&&(g.CLIPPLANE4=N,W=!0),g.CLIPPLANE5!==I&&(g.CLIPPLANE5=I,W=!0),g.CLIPPLANE6!==V&&(g.CLIPPLANE6=V,W=!0),g.DEPTHPREPASS!==!S.getColorWrite(
26)&&(g.DEPTHPREPASS=!g.DEPTHPREPASS,W=!0),g.INSTANCES!==l&&(g.INSTANCES=l,W=!0),g.THIN_INSTANCES!==b&&(g.THIN_INSTANCES=b,W=!0),W&&g.markAsUnprocessed()},E.PrepareDefinesForBones=function(A,S){if(A.useBones&&A.computeBonesUsingShaders&&A.skeleton){S.NUM_BONE_INFLUENCERS=A.numBoneInfluencers;var g=S.BONETEXTURE!==void 0;if(A.skeleton.isUsingTextureForMatrices&&g)S.BONETEXTURE=!0;else{S.BonesPerMesh=A.skeleton.bones.length+1,S.BONETEXTURE=!g&&void 0;var l=A.getScene().prePassRenderer;if(l&&l.enabled){var h=l.excludedSkinnedMesh.indexOf(A)===-1;S.BONES_VELOCITY_ENABLED=h}}}else S.NUM_BONE_INFLUENCERS=0,S.BonesPerMesh=0},E.PrepareDefinesForMorphTargets=function(A,S){var g=A.morphTargetManager;g?(S.MORPHTARGETS_UV=g.supportsUVs&&S.UV1,S.MORPHTARGETS_TANGENT=g.supportsTangents&&S.TANGENT,S.MORPHTARGETS_NORMAL=g.supportsNormals&&S.NORMAL,S.MORPHTARGETS=g.numInfluencers>0,S.NUM_MORPH_INFLUENCERS=g.numInfluencers):(S.MORPHTARGETS_UV=!1,S.MORPHTARGETS_TANGENT=!1,S.MORPHTARGETS_NORMAL=!1,S.MORPHTARGETS=!1,S.NUM_MORPH_INFLUENCERS=0)},E.PrepareDefinesForAttributes=function(A,S,g,l,h,b){if(h===void 0&&(h=!1),b===void 0&&(b=!0),!S._areAttributesDirty&&S._needNormals===S._normals&&S._needUVs===S._uvs)return!1;if(S._normals=S._needNormals,S._uvs=S._needUVs,S.NORMAL=S._needNormals&&A.isVerticesDataPresent(u.b.NormalKind),S._needNormals&&A.isVerticesDataPresent(u.b.TangentKind)&&(S.TANGENT=!0),S._needUVs?(S.UV1=A.isVerticesDataPresent(u.b.UVKind),S.UV2=A.isVerticesDataPresent(u.b.UV2Kind)):(S.UV1=!1,S.UV2=!1),g){var T=A.useVertexColors&&A.isVerticesDataPresent(u.b.ColorKind);S.VERTEXCOLOR=T,S.VERTEXALPHA=A.hasVertexAlpha&&T&&b}return l&&this.PrepareDefinesForBones(A,S),h&&this.PrepareDefinesForMorphTargets(A,S),!0},E.PrepareDefinesForMultiview=function(A,S){if(A.activeCamera){var g=S.MULTIVIEW;S.MULTIVIEW=A.activeCamera.outputRenderTarget!==null&&A.activeCamera.outputRenderTarget.getViewCount()>1,S.MULTIVIEW!=g&&S.markAsUnprocessed()}},E.PrepareDefinesForPrePass=function(A,S,g){var l=S.PREPASS;if(S._arePrePassDirty){var h=[{type:R.a.PREPASS_POSITION_TEXTURE_TYPE,define:"PREPASS_POSITION",index:"PREPASS_POSITION_INDEX"},{type:R.a.PREPASS_VELOCITY_TEXTURE_TYPE,define:"PREPASS_VELOCITY",index:"PREPASS_VELOCITY_INDEX"},{type:R.a.PREPASS_REFLECTIVITY_TEXTURE_TYPE,define:"PREPASS_REFLECTIVITY",index:"PREPASS_REFLECTIVITY_INDEX"},{type:R.a.PREPASS_IRRADIANCE_TEXTURE_TYPE,define:"PREPASS_IRRADIANCE",index:"PREPASS_IRRADIANCE_INDEX"},{type:R.a.PREPASS_ALBEDO_TEXTURE_TYPE,define:"PREPASS_ALBEDO",index:"PREPASS_ALBEDO_INDEX"},{type:R.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE,define:"PREPASS_DEPTHNORMAL",index:"PREPASS_DEPTHNORMAL_INDEX"}];if(A.prePassRenderer&&A.prePassRenderer.enabled&&g){S.PREPASS=!0,S.SCENE_MRT_COUNT=A.prePassRenderer.mrtCount;for(var b=0;b<h.length;b++){var T=A.prePassRenderer.getIndex(h[b].type);T!==-1?(S[h[b].define]=!0,S[h[b].index]=T):S[h[b].define]=!1}}else for(S.PREPASS=!1,b=0;b<h.length;b++)S[h[b].define]=!1;S.PREPASS!=l&&(S.markAsUnprocessed(),S.markAsImageProcessingDirty())}},E.PrepareDefinesForLight=function(A,S,g,l,h,b,T){switch(T.needNormals=!0,h["LIGHT"+l]===void 0&&(T.needRebuild=!0),h["LIGHT"+l]=!0,h["SPOTLIGHT"+l]=!1,h["HEMILIGHT"+l]=!1,h["POINTLIGHT"+l]=!1,h["DIRLIGHT"+l]=!1,g.prepareLightSpecificDefines(h,l),h["LIGHT_FALLOFF_PHYSICAL"+l]=!1,h["LIGHT_FALLOFF_GLTF"+l]=!1,h["LIGHT_FALLOFF_STANDARD"+l]=!1,g.falloffType){case M.a.FALLOFF_GLTF:h["LIGHT_FALLOFF_GLTF"+l]=!0;break;case M.a.FALLOFF_PHYSICAL:h["LIGHT_FALLOFF_PHYSICAL"+l]=!0;break;case M.a.FALLOFF_STANDARD:h["LIGHT_FALLOFF_STANDARD"+l]=!0}if(b&&!g.specular.equalsFloats(0,0,0)&&(T.specularEnabled=!0),h["SHADOW"+l]=!1,h["SHADOWCSM"+l]=!1,h["SHADOWCSMDEBUG"+l]=!1,h["SHADOWCSMNUM_CASCADES"+l]=!1,h["SHADOWCSMUSESHADOWMAXZ"+l]=!1,h["SHADOWCSMNOBLEND"+l]=!1,h["SHADOWCSM_RIGHTHANDED"+l]=!1,h["SHADOWPCF"+l]=!1,h["SHADOWPCSS"+l]=!1,h["SHADOWPOISSON"+l]=!1,h["SHADOWESM"+l]=!1,h["SHADOWCLOSEESM"+l]=!1,h["SHADOWCUBE"+l]=!1,h["SHADOWLOWQUALITY"+l]=!1,h["SHADOWMEDIUMQUALITY"+l]=!1,S&&S.receiveShadows&&A.shadowsEnabled&&g.shadowEnabled){var D=g.getShadowGenerator();if(D){var w=D.getShadowMap();w&&w.renderList&&w.renderList.length>0&&(T.shadowEnabled=!0,D.prepareDefines(h,l))}}g.lightmapMode!=M.a.LIGHTMAP_DEFAULT?(T.lightmapMode=!0,h["LIGHTMAPEXCLUDED"+l]=!0,h["LIGHTMAPNOSPECULAR"
26+l]=g.lightmapMode==M.a.LIGHTMAP_SHADOWSONLY):(h["LIGHTMAPEXCLUDED"+l]=!1,h["LIGHTMAPNOSPECULAR"+l]=!1)},E.PrepareDefinesForLights=function(A,S,g,l,h,b){if(h===void 0&&(h=4),b===void 0&&(b=!1),!g._areLightsDirty)return g._needNormals;var T=0,D={needNormals:!1,needRebuild:!1,lightmapMode:!1,shadowEnabled:!1,specularEnabled:!1};if(A.lightsEnabled&&!b)for(var w=0,N=S.lightSources;w<N.length;w++){var I=N[w];if(this.PrepareDefinesForLight(A,S,I,T,g,l,D),++T===h)break}g.SPECULARTERM=D.specularEnabled,g.SHADOWS=D.shadowEnabled;for(var V=T;V<h;V++)g["LIGHT"+V]!==void 0&&(g["LIGHT"+V]=!1,g["HEMILIGHT"+V]=!1,g["POINTLIGHT"+V]=!1,g["DIRLIGHT"+V]=!1,g["SPOTLIGHT"+V]=!1,g["SHADOW"+V]=!1,g["SHADOWCSM"+V]=!1,g["SHADOWCSMDEBUG"+V]=!1,g["SHADOWCSMNUM_CASCADES"+V]=!1,g["SHADOWCSMUSESHADOWMAXZ"+V]=!1,g["SHADOWCSMNOBLEND"+V]=!1,g["SHADOWCSM_RIGHTHANDED"+V]=!1,g["SHADOWPCF"+V]=!1,g["SHADOWPCSS"+V]=!1,g["SHADOWPOISSON"+V]=!1,g["SHADOWESM"+V]=!1,g["SHADOWCLOSEESM"+V]=!1,g["SHADOWCUBE"+V]=!1,g["SHADOWLOWQUALITY"+V]=!1,g["SHADOWMEDIUMQUALITY"+V]=!1);var W=A.getEngine().getCaps();return g.SHADOWFLOAT===void 0&&(D.needRebuild=!0),g.SHADOWFLOAT=D.shadowEnabled&&(W.textureFloatRender&&W.textureFloatLinearFiltering||W.textureHalfFloatRender&&W.textureHalfFloatLinearFiltering),g.LIGHTMAPEXCLUDED=D.lightmapMode,D.needRebuild&&g.rebuild(),D.needNormals},E.PrepareUniformsAndSamplersForLight=function(A,S,g,l,h,b){h===void 0&&(h=null),b===void 0&&(b=!1),h&&h.push("Light"+A),b||(S.push("vLightData"+A,"vLightDiffuse"+A,"vLightSpecular"+A,"vLightDirection"+A,"vLightFalloff"+A,"vLightGround"+A,"lightMatrix"+A,"shadowsInfo"+A,"depthValues"+A),g.push("shadowSampler"+A),g.push("depthSampler"+A),S.push("viewFrustumZ"+A,"cascadeBlendFactor"+A,"lightSizeUVCorrection"+A,"depthCorrection"+A,"penumbraDarkness"+A,"frustumLengths"+A),l&&(g.push("projectionLightSampler"+A),S.push("textureProjectionMatrix"+A)))},E.PrepareUniformsAndSamplersList=function(A,S,g,l){var h;l===void 0&&(l=4);var b=null;if(A.uniformsNames){var T=A;h=T.uniformsNames,b=T.uniformBuffersNames,S=T.samplers,g=T.defines,l=T.maxSimultaneousLights||0}else h=A,S||(S=[]);for(var D=0;D<l&&g["LIGHT"+D];D++)this.PrepareUniformsAndSamplersForLight(D,h,S,g["PROJECTEDLIGHTTEXTURE"+D],b);g.NUM_MORPH_INFLUENCERS&&h.push("morphTargetInfluences")},E.HandleFallbacksForShadows=function(A,S,g,l){g===void 0&&(g=4),l===void 0&&(l=0);for(var h=0,b=0;b<g&&A["LIGHT"+b];b++)b>0&&(h=l+b,S.addFallback(h,"LIGHT"+b)),A.SHADOWS||(A["SHADOW"+b]&&S.addFallback(l,"SHADOW"+b),A["SHADOWPCF"+b]&&S.addFallback(l,"SHADOWPCF"+b),A["SHADOWPCSS"+b]&&S.addFallback(l,"SHADOWPCSS"+b),A["SHADOWPOISSON"+b]&&S.addFallback(l,"SHADOWPOISSON"+b),A["SHADOWESM"+b]&&S.addFallback(l,"SHADOWESM"+b),A["SHADOWCLOSEESM"+b]&&S.addFallback(l,"SHADOWCLOSEESM"+b));return h++},E.PrepareAttributesForMorphTargetsInfluencers=function(A,S,g){this._TmpMorphInfluencers.NUM_MORPH_INFLUENCERS=g,this.PrepareAttributesForMorphTargets(A,S,this._TmpMorphInfluencers)},E.PrepareAttributesForMorphTargets=function(A,S,g){var l=g.NUM_MORPH_INFLUENCERS;if(l>0&&x.a.LastCreatedEngine)for(var h=x.a.LastCreatedEngine.getCaps().maxVertexAttribs,b=S.morphTargetManager,T=b&&b.supportsNormals&&g.NORMAL,D=b&&b.supportsTangents&&g.TANGENT,w=b&&b.supportsUVs&&g.UV1,N=0;N<l;N++)A.push(u.b.PositionKind+N),T&&A.push(u.b.NormalKind+N),D&&A.push(u.b.TangentKind+N),w&&A.push(u.b.UVKind+"_"+N),A.length>h&&B.a.Error("Cannot add more vertex attributes for mesh "+S.name)},E.PrepareAttributesForBones=function(A,S,g,l){g.NUM_BONE_INFLUENCERS>0&&(l.addCPUSkinningFallback(0,S),A.push(u.b.MatricesIndicesKind),A.push(u.b.MatricesWeightsKind),g.NUM_BONE_INFLUENCERS>4&&(A.push(u.b.MatricesIndicesExtraKind),A.push(u.b.MatricesWeightsExtraKind)))},E.PrepareAttributesForInstances=function(A,S){(S.INSTANCES||S.THIN_INSTANCES)&&this.PushAttributesForInstances(A)},E.PushAttributesForInstances=function(A){A.push("world0"),A.push("world1"),A.push("world2"),A.push("world3")},E.BindLightProperties=function(A,S,g){A.transferToEffect(S,g+"")},E.BindLight=function(A,S,g,l,h,b){b===void 0&&(b=!1),A._bindLight(S,g,l,h,b)},E.BindLights=function(A,S,g,l,h,b){h===void 0&&(h=4),b===void 0&&(b=!1);for(var T=Math.min(S.lightSources.length,h),D=0;D<T;D++){var w=S.lightSources[D];this.BindLight(w,D,A,g,typeof l=="boolean"?l:l.SPECULARTERM,b)}},E.BindFogParameters=function(A,S,g,l){l===void 0&&(l=!1),A.fogEnabled&&S.applyFog&&A.fogMode!==_.a.FOGMODE_NONE&&(g.setFloat4("vFogInfos",A.fogMode,A.fogStart,A.fogEnd,A.fogDensity),l?(A.fogColor.toLinearSpaceToRef(this._tempFogColor),g.setColor3("vFogColor",this._tempFogColor)):g.setColor3("vFogColor",A.fogColor))},E.BindBonesParameters=function(A,S,g){if(S&&A&&(A.computeBonesUsingShaders&&S._bonesComputationForcedToCPU&&(A.computeBonesUsingShaders=!1),A.useBones&&A.computeBonesUsingShaders&&A.skeleton)){var l=A.skeleton;if(l.isUsingTextureForMatrices&&S.getUniformIndex("boneTextureWidth")>-1){var h=l.getTransformMatrixTexture(A);S.setTexture("boneSampler",h),S.setFloat("boneTextureWidth",4*(l.bones.length+1))}else{var b=l.getTransformMatrices(A);
26b&&(S.setMatrices("mBones",b),g&&A.getScene().prePassRenderer&&A.getScene().prePassRenderer.getIndex(R.a.PREPASS_VELOCITY_TEXTURE_TYPE)&&(g.previousBones[A.uniqueId]&&S.setMatrices("mPreviousBones",g.previousBones[A.uniqueId]),E._CopyBonesTransformationMatrices(b,g.previousBones[A.uniqueId])))}}},E._CopyBonesTransformationMatrices=function(A,S){return S.set(A),S},E.BindMorphTargetParameters=function(A,S){var g=A.morphTargetManager;A&&g&&S.setFloatArray("morphTargetInfluences",g.influences)},E.BindLogDepth=function(A,S,g){A.LOGARITHMICDEPTH&&S.setFloat("logarithmicDepthConstant",2/(Math.log(g.activeCamera.maxZ+1)/Math.LN2))},E.BindClipPlane=function(A,S){m.a.BindClipPlane(A,S)},E._TmpMorphInfluencers={NUM_MORPH_INFLUENCERS:0},E._tempFogColor=C.a.Black(),E}()},function(Ae,v,f){f.d(v,"a",function(){return R});var B=f(0),_=f(4),x=f(21),u=f(9),M=f(8),R=function(){function C(){}return C.prototype.set=function(m,c){switch(m.length||M.a.Warn("Setting vertex data kind '"+c+"' with an empty array"),c){case _.b.PositionKind:this.positions=m;break;case _.b.NormalKind:this.normals=m;break;case _.b.TangentKind:this.tangents=m;break;case _.b.UVKind:this.uvs=m;break;case _.b.UV2Kind:this.uvs2=m;break;case _.b.UV3Kind:this.uvs3=m;break;case _.b.UV4Kind:this.uvs4=m;break;case _.b.UV5Kind:this.uvs5=m;break;case _.b.UV6Kind:this.uvs6=m;break;case _.b.ColorKind:this.colors=m;break;case _.b.MatricesIndicesKind:this.matricesIndices=m;break;case _.b.MatricesWeightsKind:this.matricesWeights=m;break;case _.b.MatricesIndicesExtraKind:this.matricesIndicesExtra=m;break;case _.b.MatricesWeightsExtraKind:this.matricesWeightsExtra=m}},C.prototype.applyToMesh=function(m,c){return this._applyTo(m,c),this},C.prototype.applyToGeometry=function(m,c){return this._applyTo(m,c),this},C.prototype.updateMesh=function(m){return this._update(m),this},C.prototype.updateGeometry=function(m){return this._update(m),this},C.prototype._applyTo=function(m,c){return c===void 0&&(c=!1),this.positions&&m.setVerticesData(_.b.PositionKind,this.positions,c),this.normals&&m.setVerticesData(_.b.NormalKind,this.normals,c),this.tangents&&m.setVerticesData(_.b.TangentKind,this.tangents,c),this.uvs&&m.setVerticesData(_.b.UVKind,this.uvs,c),this.uvs2&&m.setVerticesData(_.b.UV2Kind,this.uvs2,c),this.uvs3&&m.setVerticesData(_.b.UV3Kind,this.uvs3,c),this.uvs4&&m.setVerticesData(_.b.UV4Kind,this.uvs4,c),this.uvs5&&m.setVerticesData(_.b.UV5Kind,this.uvs5,c),this.uvs6&&m.setVerticesData(_.b.UV6Kind,this.uvs6,c),this.colors&&m.setVerticesData(_.b.ColorKind,this.colors,c),this.matricesIndices&&m.setVerticesData(_.b.MatricesIndicesKind,this.matricesIndices,c),this.matricesWeights&&m.setVerticesData(_.b.MatricesWeightsKind,this.matricesWeights,c),this.matricesIndicesExtra&&m.setVerticesData(_.b.MatricesIndicesExtraKind,this.matricesIndicesExtra,c),this.matricesWeightsExtra&&m.setVerticesData(_.b.MatricesWeightsExtraKind,this.matricesWeightsExtra,c),this.indices?m.setIndices(this.indices,null,c):m.setIndices([],null),this},C.prototype._update=function(m,c,E){return this.positions&&m.updateVerticesData(_.b.PositionKind,this.positions,c,E),this.normals&&m.updateVerticesData(_.b.NormalKind,this.normals,c,E),this.tangents&&m.updateVerticesData(_.b.TangentKind,this.tangents,c,E),this.uvs&&m.updateVerticesData(_.b.UVKind,this.uvs,c,E),this.uvs2&&m.updateVerticesData(_.b.UV2Kind,this.uvs2,c,E),this.uvs3&&m.updateVerticesData(_.b.UV3Kind,this.uvs3,c,E),this.uvs4&&m.updateVerticesData(_.b.UV4Kind,this.uvs4,c,E),this.uvs5&&m.updateVerticesData(_.b.UV5Kind,this.uvs5,c,E),this.uvs6&&m.updateVerticesData(_.b.UV6Kind,this.uvs6,c,E),this.colors&&m.updateVerticesData(_.b.ColorKind,this.colors,c,E),this.matricesIndices&&m.updateVerticesData(_.b.MatricesIndicesKind,this.matricesIndices,c,E),this.matricesWeights&&m.updateVerticesData(_.b.MatricesWeightsKind,this.matricesWeights,c,E),this.matricesIndicesExtra&&m.updateVerticesData(_.b.MatricesIndicesExtraKind,this.matricesIndicesExtra,c,E),this.matricesWeightsExtra&&m.updateVerticesData(_.b.MatricesWeightsExtraKind,this.matricesWeightsExtra,c,E),this.indices&&m.setIndices(this.indices,null),this},C.prototype.transform=function(m){var c,E=m.determinant()<0,A=B.e.Zero();if(this.positions){var S=B.e.Zero();for(c=0;c<this.positions.length;c+=3)B.e.FromArrayToRef(this.positions,c,S),B.e.TransformCoordinatesToRef(S,m,A),this.positions[c]=A.x,this.positions[c+1]=A.y,this.positions[c+2]=A.z}if(this.normals){var g=B.e.Zero();for(c=0;c<this.normals.length;c+=3)B.e.FromArrayToRef(this.normals,c,g),B.e.TransformNormalToRef(g,m,A),this.normals[c]=A.x,this.normals[c+1]=A.y,this.normals[c+2]=A.z}if(this.tangents){var l=B.f.Zero(),h=B.f.Zero();for(c=0;c<this.tangents.length;c+=4)B.f.FromArrayToRef(this.tangents,c,l),B.f.TransformNormalToRef(l,m,h),this.tangents[c]=h.x,this.tangents[c+1]=h.y,this.tangents[c+2]=h.z,this.tangents[c+3]=h.w}if(E&&this.indices)for(c=0;c<this.indices.length;c+=3){var b=this.indices[c+1];this.indices[c+1]=this.indices[c+2],this.indices[c+2]=b}return this}
26,C.prototype.merge=function(m,c){if(c===void 0&&(c=!1),this._validate(),m._validate(),!this.normals!=!m.normals||!this.tangents!=!m.tangents||!this.uvs!=!m.uvs||!this.uvs2!=!m.uvs2||!this.uvs3!=!m.uvs3||!this.uvs4!=!m.uvs4||!this.uvs5!=!m.uvs5||!this.uvs6!=!m.uvs6||!this.colors!=!m.colors||!this.matricesIndices!=!m.matricesIndices||!this.matricesWeights!=!m.matricesWeights||!this.matricesIndicesExtra!=!m.matricesIndicesExtra||!this.matricesWeightsExtra!=!m.matricesWeightsExtra)throw new Error("Cannot merge vertex data that do not have the same set of attributes");if(m.indices){this.indices||(this.indices=[]);var E=this.positions?this.positions.length/3:0;if(this.indices.BYTES_PER_ELEMENT!==void 0){var A=this.indices.length+m.indices.length,S=c||this.indices instanceof Uint32Array?new Uint32Array(A):new Uint16Array(A);S.set(this.indices);for(var g=this.indices.length,l=0;l<m.indices.length;l++)S[g+l]=m.indices[l]+E;this.indices=S}else for(l=0;l<m.indices.length;l++)this.indices.push(m.indices[l]+E)}return this.positions=this._mergeElement(this.positions,m.positions),this.normals=this._mergeElement(this.normals,m.normals),this.tangents=this._mergeElement(this.tangents,m.tangents),this.uvs=this._mergeElement(this.uvs,m.uvs),this.uvs2=this._mergeElement(this.uvs2,m.uvs2),this.uvs3=this._mergeElement(this.uvs3,m.uvs3),this.uvs4=this._mergeElement(this.uvs4,m.uvs4),this.uvs5=this._mergeElement(this.uvs5,m.uvs5),this.uvs6=this._mergeElement(this.uvs6,m.uvs6),this.colors=this._mergeElement(this.colors,m.colors),this.matricesIndices=this._mergeElement(this.matricesIndices,m.matricesIndices),this.matricesWeights=this._mergeElement(this.matricesWeights,m.matricesWeights),this.matricesIndicesExtra=this._mergeElement(this.matricesIndicesExtra,m.matricesIndicesExtra),this.matricesWeightsExtra=this._mergeElement(this.matricesWeightsExtra,m.matricesWeightsExtra),this},C.prototype._mergeElement=function(m,c){if(!m)return c;if(!c)return m;var E=c.length+m.length,A=m instanceof Float32Array,S=c instanceof Float32Array;if(A){var g=new Float32Array(E);return g.set(m),g.set(c,m.length),g}if(S){var l=m.slice(0),h=0;for(E=c.length;h<E;h++)l.push(c[h]);return l}return m.concat(c)},C.prototype._validate=function(){if(!this.positions)throw new Error("Positions are required");var m=function(A,S){var g=_.b.DeduceStride(A);if(S.length%g!=0)throw new Error("The "+A+"s array count must be a multiple of "+g);return S.length/g},c=m(_.b.PositionKind,this.positions),E=function(A,S){var g=m(A,S);if(g!==c)throw new Error("The "+A+"s element count ("+g+") does not match the positions count ("+c+")")};this.normals&&E(_.b.NormalKind,this.normals),this.tangents&&E(_.b.TangentKind,this.tangents),this.uvs&&E(_.b.UVKind,this.uvs),this.uvs2&&E(_.b.UV2Kind,this.uvs2),this.uvs3&&E(_.b.UV3Kind,this.uvs3),this.uvs4&&E(_.b.UV4Kind,this.uvs4),this.uvs5&&E(_.b.UV5Kind,this.uvs5),this.uvs6&&E(_.b.UV6Kind,this.uvs6),this.colors&&E(_.b.ColorKind,this.colors),this.matricesIndices&&E(_.b.MatricesIndicesKind,this.matricesIndices),this.matricesWeights&&E(_.b.MatricesWeightsKind,this.matricesWeights),this.matricesIndicesExtra&&E(_.b.MatricesIndicesExtraKind,this.matricesIndicesExtra),this.matricesWeightsExtra&&E(_.b.MatricesWeightsExtraKind,this.matricesWeightsExtra)},C.prototype.serialize=function(){var m=this.serialize();return this.positions&&(m.positions=this.positions),this.normals&&(m.normals=this.normals),this.tangents&&(m.tangents=this.tangents),this.uvs&&(m.uvs=this.uvs),this.uvs2&&(m.uvs2=this.uvs2),this.uvs3&&(m.uvs3=this.uvs3),this.uvs4&&(m.uvs4=this.uvs4),this.uvs5&&(m.uvs5=this.uvs5),this.uvs6&&(m.uvs6=this.uvs6),this.colors&&(m.colors=this.colors),this.matricesIndices&&(m.matricesIndices=this.matricesIndices,m.matricesIndices._isExpanded=!0),this.matricesWeights&&(m.matricesWeights=this.matricesWeights),this.matricesIndicesExtra&&(m.matricesIndicesExtra=this.matricesIndicesExtra,m.matricesIndicesExtra._isExpanded=!0),this.matricesWeightsExtra&&(m.matricesWeightsExtra=this.matricesWeightsExtra),m.indices=this.indices,m},C.ExtractFromMesh=function(m,c,E){return C._ExtractFrom(m,c,E)},C.ExtractFromGeometry=function(m,c,E){return C._ExtractFrom(m,c,E)},C._ExtractFrom=function(m,c,E){var A=new C;return m.isVerticesDataPresent(_.b.PositionKind)&&(A.positions=m.getVerticesData(_.b.PositionKind,c,E)),m.isVerticesDataPresent(_.b.NormalKind)&&(A.normals=m.getVerticesData(_.b.NormalKind,c,E)),m.isVerticesDataPresent(_.b.TangentKind)&&(A.tangents=m.getVerticesData(_.b.TangentKind,c,E)),m.isVerticesDataPresent(_.b.UVKind)&&(A.uvs=m.getVerticesData(_.b.UVKind,c,E)),m.isVerticesDataPresent(_.b.UV2Kind)&&(A.uvs2=m.getVerticesData(_.b.UV2Kind,c,E)),m.isVerticesDataPresent(_.b.UV3Kind)&&(A.uvs3=m.getVerticesData(_.b.UV3Kind,c,E)),m.isVerticesDataPresent(_.b.UV4Kind)&&(A.uvs4=m.getVerticesData(_.b.UV4Kind,c,E)),m.isVerticesDataPresent(_.b.UV5Kind)&&(A.uvs5=m.getVerticesData(_.b.UV5Kind,c,E)),m.isVerticesDataPresent(_.b.UV6Kind)&&(A.uvs6=m.getVerticesData(_.b.UV6Kind,c,E)),m.isVerticesDataPresent(_.b.ColorKind)&&(A.colors=m.getVerticesData(_.b.ColorKind,c,E)),m.isVerticesDataPresent(_.b.MatricesIndicesKind)&&(A.matricesIndices=m.getVerticesData(_.b.MatricesIndicesKind,c,E)),m.isVerticesDataPresent(_.b.MatricesWeightsKind)&&(A.matricesWeights=m.getVerticesData(_.b.MatricesWeightsKind,c,E)),m.isVerticesDataPresent(_.b.MatricesIndicesExtraKind)&&(A.matricesIndicesExtra=m.getVerticesData(_.b.MatricesIndicesExtraKind,c,E)),m.isVerticesDataPresent(_.b.MatricesWeightsExtraKind)&&(A.matricesWeightsExtra=m.getVerticesData(_.b.MatricesWeightsExtraKind,c,E)),A.indices=m.getIndices(c,E),A},C.CreateRibbon=function(m){throw x.a.WarnImport("ribbonBuilder")},C.CreateBox=function(m){throw x.a.WarnImport("boxBuilder")},C.CreateTiledBox=function(m){throw x.a.WarnImport("tiledBoxBuilder")},C.CreateTiledPlane=function(m){throw x.a.WarnImport("tiledPlaneBuilder")},C.CreateSphere=function(m){throw x.a.WarnImport("sphereBuilder")},C.CreateCylinder=function(m){throw x.a.WarnImport("cylinderBuilder")},C.CreateTorus=function(m){throw x.a.WarnImport("torusBuilder")},C.CreateLineSystem=function(m){throw x.a.WarnImport("linesBuilder")},C.CreateDashedLines=function(m){throw x.a.WarnImport("linesBuilder")},C.CreateGround=function(m){throw x.a.WarnImport("groundBuilder")},C.CreateTiledGround=function(m){throw x.a.WarnImport("groundBuilder")},C.CreateGroundFromHeightMap=function(m){throw x.a.WarnImport("groundBuilder")},C.CreatePlane=function(m){throw x.a.WarnImport("planeBuilder")},C.CreateDisc=function(m){throw x.a.WarnImport("discBuilder")},C.CreatePolygon=function(m,c,E,A,S,g,l){throw x.a.WarnImport("polygonBuilder")},C.CreateIcoSphere=function(m){throw x.a.WarnImport("icoSphereBuilder")},C.CreatePolyhedron=function(m){throw x.a.WarnImport("polyhedronBuilder")},C.CreateCapsule=function(m){throw m===void 0&&(m={orientation:B.e.Up(),subdivisions:2,tessellation:16,height:1,radius:.25,capSubdivisions:6}),x.a.WarnImport("capsuleBuilder")},C.CreateTorusKnot=function(m){throw x.a.WarnImport("torusKnotBuilder")},C.ComputeNormals=function(m,c,E,A){var S=0,g=0,l=0,h=0,b=0,T=0,D=0,w=0,N=0,I=0,V=0,W=0,j=0,ne=0,te=0,de=0,pe=0,ae=0,ee=0,K=0,$=!1,L=!1,G=!1,Q=!1,oe=1,re=0,Y=null;if(A&&($=!!A.facetNormals,L=!!A.facetPositions,G=!!A.facetPartitioning,oe=A.useRightHandedSystem===!0?-1:1,re=A.ratio||0,Q=!!A.depthSort,Y=A.distanceTo,Q)){Y===void 0&&(Y=B.e.Zero());var k=A.depthSortedFacets}var H=0,Z=0,X=0,q=0;if(G&&A&&A.bbSize){var he=0,ge=0,me=0,_e=0,be=0,Ce=0,ye=0,Be=0,Ge=0,Xe=0,He=0,We=0,Ze=0,ze=0,it=0,et=0,lt=A.bbSize.x>A.bbSize.y?A.bbSize.x:A.bbSize.y;lt=lt>A.bbSize.z?lt:A.bbSize.z,H=A.subDiv.X*re/A.bbSize.x,Z=A.subDiv.Y*re/A.bbSize.y,X=A.subDiv.Z*re/A.bbSize.z,q=A.subDiv.max*A.subDiv.max,A.facetPartitioning.length=0}for(S=0;S<m.length;S++)E[S]=0;var ct=c.length/3|0;for(S=0;S<ct;S++){if(j=(W=3*c[3*S])+1,ne=W+2,de=(te=3*c[3*S+1])+1,pe=te+2,ee=(ae=3*c[3*S+2])+1,K=ae+2,g=m[W]-m[te],l=m[j]-m[de],h=m[ne]-m[pe],b=m[ae]-m[te],T=m[ee]-m[de],w=oe*(l*(D=m[K]-m[pe])-h*T),N=oe*(h*b-g*D),I=oe*(g*T-l*b),w/=V=(V=Math.sqrt(w*w+N*N+I*I))===0?1:V,N/=V,I/=V,$&&A&&(A.facetNormals[S].x=w,A.facetNormals[S].y=N,A.facetNormals[S].z=I),L&&A&&(A.facetPositions[S].x=(m[W]+m[te]+m[ae])/3,A.facetPositions[S].y=(m[j]+m[de]+m[ee])/3,A.facetPositions[S].z=(m[ne]+m[pe]+m[K])/3),G&&A&&(he=Math.floor((A.facetPositions[S].x-A.bInfo.minimum.x*re)*H),ge=Math.floor((A.facetPositions[S].y-A.bInfo.minimum.y*re)*Z),me=Math.floor((A.facetPositions[S].z-A.bInfo.minimum.z*re)*X),_e=Math.floor((m[W]-A.bInfo.minimum.x*re)*H),be=Math.floor((m[j]-A.bInfo.minimum.y*re)*Z),Ce=Math.floor((m[ne]-A.bInfo.minimum.z*re)*X),ye=Math.floor((m[te]-A.bInfo.minimum.x*re)*H),Be=Math.floor((m[de]-A.bInfo.minimum.y*re)*Z),Ge=Math.floor((m[pe]-A.bInfo.minimum.z*re)*X),Xe=Math.floor((m[ae]-A.bInfo.minimum.x*re)*H),He=Math.floor((m[ee]-A.bInfo.minimum.y*re)*Z),We=Math.floor((m[K]-A.bInfo.minimum.z*re)*X),ze=_e+A.subDiv.max*be+q*Ce,it=ye+A.subDiv.max*Be+q*Ge,et=Xe+A.subDiv.max*He+q*We,Ze=he+A.subDiv.max*ge+q*me,A.facetPartitioning[Ze]=A.facetPartitioning[Ze]?A.facetPartitioning[Ze]:new Array,A.facetPartitioning[ze]=A.facetPartitioning[ze]?A.facetPartitioning[ze]:new Array,A.facetPartitioning[it]=A.facetPartitioning[it]?A.facetPartitioning[it]:new Array,A.facetPartitioning[et]=A.facetPartitioning[et]?A.facetPartitioning[et]:new Array,A.facetPartitioning[ze].push(S),it!=ze&&A.facetPartitioning[it].push(S),et!=it&&et!=ze&&A.facetPartitioning[et].push(S),Ze!=ze&&Ze!=it&&Ze!=et&&A.facetPartitioning[Ze].push(S)),Q&&A&&A.facetPositions){var mt=k[S];mt.ind=3*S,mt.sqDistance=B.e.DistanceSquared(A.facetPositions[S],Y)}E[W]+=w,E[j]+=N,E[ne]+=I,E[te]+=w,E[de]+=N,E[pe]+=I,E[ae]+=w,E[ee]+=N,E[K]+=I}for(S=0;S<E.length/3;S++)w=E[3*S],N=E[3*S+1],I=E[3*S+2],w/=V=(V=Math.sqrt(w*w+N*N+I*I))===0?1:V,N/=V,I/=V,E[3*S]=w,E[3*S+1]=N,E[3*S+2]=I},C._ComputeSides=function(m,c,E,A,S,g,l){var h,b,T=E.length,D=A.length;switch(m=m||C.DEFAULTSIDE){case C.FRONTSIDE:break;case C.BACKSIDE:var w;for(h=0;h<T;h+=3)w=E[h],E[h]=E[h+2],E[h+2]=w;for(b=0;b<D;b++)A[b]=-A[b];break;case C.DOUBLESIDE:for(var N=c.length,I=N/3,V=0;V<N;V++)c[N+V]=c[V];for(h=0;h<T;h+=3)E[h+T]=E[h+2]+I,E[h+1+T]=E[h+1]+I,E[h+2+T]=E[h]+I;for(b=0;b<D;b++)A[D+b]=-A[b];var W=S.length,j=0;for(j=0;j<W;j++)S[j+W]=S[j];for(g=g||new B.f(0,0,1,1),l=l||new B.f(0,0,1,1),j=0,h=0;h<W/2;h++)S[j]=g.x+(g.z-g.x)*S[j],S[j+1]=g.y+(g.w-g.y)*S[j+1],S[j+W]=l.x+(l.z-l.x)*S[j+W],S[j+W+1]=l.y+(l.w-l.y)*S[j+W+1],j+=2}},C.ImportVertexData=function(m,c){var E=new C,A=m.positions;A&&E.set(A,_.b.PositionKind);
26var S=m.normals;S&&E.set(S,_.b.NormalKind);var g=m.tangents;g&&E.set(g,_.b.TangentKind);var l=m.uvs;l&&E.set(l,_.b.UVKind);var h=m.uv2s;h&&E.set(h,_.b.UV2Kind);var b=m.uv3s;b&&E.set(b,_.b.UV3Kind);var T=m.uv4s;T&&E.set(T,_.b.UV4Kind);var D=m.uv5s;D&&E.set(D,_.b.UV5Kind);var w=m.uv6s;w&&E.set(w,_.b.UV6Kind);var N=m.colors;N&&E.set(u.b.CheckColors4(N,A.length/3),_.b.ColorKind);var I=m.matricesIndices;I&&E.set(I,_.b.MatricesIndicesKind);var V=m.matricesWeights;V&&E.set(V,_.b.MatricesWeightsKind);var W=m.indices;W&&(E.indices=W),c.setAllVerticesData(E,m.updatable)},C.FRONTSIDE=0,C.BACKSIDE=1,C.DOUBLESIDE=2,C.DEFAULTSIDE=0,C}()},function(Ae,v,f){f.d(v,"a",function(){return _}),f.d(v,"b",function(){return x});var B=f(1),_=function(){function u(){}return u.NAME_EFFECTLAYER="EffectLayer",u.NAME_LAYER="Layer",u.NAME_LENSFLARESYSTEM="LensFlareSystem",u.NAME_BOUNDINGBOXRENDERER="BoundingBoxRenderer",u.NAME_PARTICLESYSTEM="ParticleSystem",u.NAME_GAMEPAD="Gamepad",u.NAME_SIMPLIFICATIONQUEUE="SimplificationQueue",u.NAME_GEOMETRYBUFFERRENDERER="GeometryBufferRenderer",u.NAME_PREPASSRENDERER="PrePassRenderer",u.NAME_DEPTHRENDERER="DepthRenderer",u.NAME_POSTPROCESSRENDERPIPELINEMANAGER="PostProcessRenderPipelineManager",u.NAME_SPRITE="Sprite",u.NAME_SUBSURFACE="SubSurface",u.NAME_OUTLINERENDERER="Outline",u.NAME_PROCEDURALTEXTURE="ProceduralTexture",u.NAME_SHADOWGENERATOR="ShadowGenerator",u.NAME_OCTREE="Octree",u.NAME_PHYSICSENGINE="PhysicsEngine",u.NAME_AUDIO="Audio",u.STEP_ISREADYFORMESH_EFFECTLAYER=0,u.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER=0,u.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER=0,u.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER=0,u.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER=1,u.STEP_BEFORECAMERADRAW_EFFECTLAYER=0,u.STEP_BEFORECAMERADRAW_LAYER=1,u.STEP_BEFORECAMERADRAW_PREPASS=2,u.STEP_BEFORERENDERTARGETDRAW_LAYER=0,u.STEP_BEFORERENDERINGMESH_PREPASS=0,u.STEP_BEFORERENDERINGMESH_OUTLINE=1,u.STEP_AFTERRENDERINGMESH_PREPASS=0,u.STEP_AFTERRENDERINGMESH_OUTLINE=1,u.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW=0,u.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER=1,u.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE=0,u.STEP_BEFORECAMERAUPDATE_GAMEPAD=1,u.STEP_BEFORECLEAR_PROCEDURALTEXTURE=0,u.STEP_AFTERRENDERTARGETDRAW_LAYER=0,u.STEP_AFTERCAMERADRAW_EFFECTLAYER=0,u.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM=1,u.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW=2,u.STEP_AFTERCAMERADRAW_LAYER=3,u.STEP_AFTERCAMERADRAW_PREPASS=4,u.STEP_AFTERRENDER_AUDIO=0,u.STEP_GATHERRENDERTARGETS_DEPTHRENDERER=0,u.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER=1,u.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR=2,u.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER=3,u.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER=0,u.STEP_BEFORECLEARSTAGE_PREPASS=0,u.STEP_POINTERMOVE_SPRITE=0,u.STEP_POINTERDOWN_SPRITE=0,u.STEP_POINTERUP_SPRITE=0,u}(),x=function(u){function M(R){return u.apply(this,R)||this}return Object(B.d)(M,u),M.Create=function(){return Object.create(M.prototype)},M.prototype.registerStep=function(R,C,m){var c=0;for(Number.MAX_VALUE;c<this.length&&!(R<this[c].index);c++);this.splice(c,0,{index:R,component:C,action:m.bind(C)})},M.prototype.clear=function(){this.length=0},M}(Array)},function(Ae,v,f){f.d(v,"a",function(){return x}),f.d(v,"c",function(){return u}),f.d(v,"d",function(){return M}),f.d(v,"b",function(){return R});var B=f(1),_=f(0),x=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}(),u=function(C,m){this.type=C,this.event=m},M=function(C){function m(c,E,A,S){var g=C.call(this,c,E)||this;return g.ray=null,g.skipOnPointerObservable=!1,g.localPosition=new _.d(A,S),g}return Object(B.d)(m,C),m}(u),R=function(C){function m(c,E,A){var S=C.call(this,c,E)||this;return S.pickInfo=A,S}return Object(B.d)(m,C),m}(u)},function(Ae,v,f){f.d(v,"a",function(){return x});var B=f(13),_=f(2),x=function(){function u(){}return Object.defineProperty(u,"DiffuseTextureEnabled",{get:function(){return this._DiffuseTextureEnabled},set:function(M){this._DiffuseTextureEnabled!==M&&(this._DiffuseTextureEnabled=M,B.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag))}
26,enumerable:!1,configurable:!0}),Object.defineProperty(u,"DetailTextureEnabled",{get:function(){return this._DetailTextureEnabled},set:function(M){this._DetailTextureEnabled!==M&&(this._DetailTextureEnabled=M,B.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(u,"AmbientTextureEnabled",{get:function(){return this._AmbientTextureEnabled},set:function(M){this._AmbientTextureEnabled!==M&&(this._AmbientTextureEnabled=M,B.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(u,"OpacityTextureEnabled",{get:function(){return this._OpacityTextureEnabled},set:function(M){this._OpacityTextureEnabled!==M&&(this._OpacityTextureEnabled=M,B.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(u,"ReflectionTextureEnabled",{get:function(){return this._ReflectionTextureEnabled},set:function(M){this._ReflectionTextureEnabled!==M&&(this._ReflectionTextureEnabled=M,B.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(u,"EmissiveTextureEnabled",{get:function(){return this._EmissiveTextureEnabled},set:function(M){this._EmissiveTextureEnabled!==M&&(this._EmissiveTextureEnabled=M,B.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(u,"SpecularTextureEnabled",{get:function(){return this._SpecularTextureEnabled},set:function(M){this._SpecularTextureEnabled!==M&&(this._SpecularTextureEnabled=M,B.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(u,"BumpTextureEnabled",{get:function(){return this._BumpTextureEnabled},set:function(M){this._BumpTextureEnabled!==M&&(this._BumpTextureEnabled=M,B.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(u,"LightmapTextureEnabled",{get:function(){return this._LightmapTextureEnabled},set:function(M){this._LightmapTextureEnabled!==M&&(this._LightmapTextureEnabled=M,B.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(u,"RefractionTextureEnabled",{get:function(){return this._RefractionTextureEnabled},set:function(M){this._RefractionTextureEnabled!==M&&(this._RefractionTextureEnabled=M,B.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(u,"ColorGradingTextureEnabled",{get:function(){return this._ColorGradingTextureEnabled},set:function(M){this._ColorGradingTextureEnabled!==M&&(this._ColorGradingTextureEnabled=M,B.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(u,"FresnelEnabled",{get:function(){return this._FresnelEnabled},set:function(M){this._FresnelEnabled!==M&&(this._FresnelEnabled=M,B.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_FresnelDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(u,"ClearCoatTextureEnabled",{get:function(){return this._ClearCoatTextureEnabled},set:function(M){this._ClearCoatTextureEnabled!==M&&(this._ClearCoatTextureEnabled=M,B.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(u,"ClearCoatBumpTextureEnabled",{get:function(){return this._ClearCoatBumpTextureEnabled},set:function(M){this._ClearCoatBumpTextureEnabled!==M&&(this._ClearCoatBumpTextureEnabled=M,B.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(u,"ClearCoatTintTextureEnabled",{get:function(){return this._ClearCoatTintTextureEnabled},set:function(M){this._ClearCoatTintTextureEnabled!==M&&(this._ClearCoatTintTextureEnabled=M,B.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(u,"SheenTextureEnabled",{get:function(){return this._SheenTextureEnabled},set:function(M){this._SheenTextureEnabled!==M&&(this._SheenTextureEnabled=M,B.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag))}
26,enumerable:!1,configurable:!0}),Object.defineProperty(u,"AnisotropicTextureEnabled",{get:function(){return this._AnisotropicTextureEnabled},set:function(M){this._AnisotropicTextureEnabled!==M&&(this._AnisotropicTextureEnabled=M,B.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(u,"ThicknessTextureEnabled",{get:function(){return this._ThicknessTextureEnabled},set:function(M){this._ThicknessTextureEnabled!==M&&(this._ThicknessTextureEnabled=M,B.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),u._DiffuseTextureEnabled=!0,u._DetailTextureEnabled=!0,u._AmbientTextureEnabled=!0,u._OpacityTextureEnabled=!0,u._ReflectionTextureEnabled=!0,u._EmissiveTextureEnabled=!0,u._SpecularTextureEnabled=!0,u._BumpTextureEnabled=!0,u._LightmapTextureEnabled=!0,u._RefractionTextureEnabled=!0,u._ColorGradingTextureEnabled=!0,u._FresnelEnabled=!0,u._ClearCoatTextureEnabled=!0,u._ClearCoatBumpTextureEnabled=!0,u._ClearCoatTintTextureEnabled=!0,u._SheenTextureEnabled=!0,u._AnisotropicTextureEnabled=!0,u._ThicknessTextureEnabled=!0,u}()},function(Ae,v,f){f.d(v,"a",function(){return oe});var B=f(1),_=f(12),x=f(57),u=f(6),M=f(33),R=f(112),C=f(37),m=f(0),c=f(46),E=f(31),A=f(24),S=f(35),g=f(42),l=f(85),h=f(48),b=f(54),T=f(47),D=f(95),w=f(96),N=f(17),I=f(2),V=f(38),W=f(8),j=f(22),ne=f(21),te=f(18),de=f(91),pe=f(66),ae=function(){function re(){this._singleClick=!1,this._doubleClick=!1,this._hasSwiped=!1,this._ignore=!1}return Object.defineProperty(re.prototype,"singleClick",{get:function(){return this._singleClick},set:function(Y){this._singleClick=Y},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"doubleClick",{get:function(){return this._doubleClick},set:function(Y){this._doubleClick=Y},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"hasSwiped",{get:function(){return this._hasSwiped},set:function(Y){this._hasSwiped=Y},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"ignore",{get:function(){return this._ignore},set:function(Y){this._ignore=Y},enumerable:!1,configurable:!0}),re}(),ee=function(){function re(Y){this._alreadyAttached=!1,this._wheelEventName="",this._meshPickProceed=!1,this._currentPickResult=null,this._previousPickResult=null,this._totalPointersPressed=0,this._doubleClickOccured=!1,this._pointerX=0,this._pointerY=0,this._startingPointerPosition=new m.d(0,0),this._previousStartingPointerPosition=new m.d(0,0),this._startingPointerTime=0,this._previousStartingPointerTime=0,this._pointerCaptures={},this._meshUnderPointerId=[],this._keyboardIsAttached=!1,this._scene=Y}return Object.defineProperty(re.prototype,"meshUnderPointer",{get:function(){return this._pointerOverMesh},enumerable:!1,configurable:!0}),re.prototype.getMeshUnderPointerByPointerId=function(Y){return this._meshUnderPointerId[Y]},Object.defineProperty(re.prototype,"unTranslatedPointer",{get:function(){return new m.d(this._unTranslatedPointerX,this._unTranslatedPointerY)},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"pointerX",{get:function(){return this._pointerX},set:function(Y){this._pointerX=Y},enumerable:!1,configurable:!0}),Object.defineProperty(re.prototype,"pointerY",{get:function(){return this._pointerY},set:function(Y){this._pointerY=Y},enumerable:!1,configurable:!0}),re.prototype._updatePointerPosition=function(Y){var k=this._scene.getEngine().getInputElementClientRect();k&&(this._pointerX=Y.clientX-k.left,this._pointerY=Y.clientY-k.top,this._unTranslatedPointerX=this._pointerX,this._unTranslatedPointerY=this._pointerY)},re.prototype._processPointerMove=function(Y,k){var H=this._scene,Z=H.getEngine(),X=Z.getInputElement();if(X){X.tabIndex=Z.canvasTabIndex,H.doNotHandleCursors||(X.style.cursor=H.defaultCursor);var q=!!(Y&&Y.hit&&Y.pickedMesh);q?(H.setPointerOverMesh(Y.pickedMesh,k.pointerId),this._pointerOverMesh&&this._pointerOverMesh.actionManager&&this._pointerOverMesh.actionManager.hasPointerTriggers&&(H.doNotHandleCursors||(this._pointerOverMesh.actionManager.hoverCursor?X.style.cursor=this._pointerOverMesh.actionManager.hoverCurs
26or:X.style.cursor=H.hoverCursor))):H.setPointerOverMesh(null,k.pointerId);for(var he=0,ge=H._pointerMoveStage;he<ge.length;he++)Y=ge[he].action(this._unTranslatedPointerX,this._unTranslatedPointerY,Y,q,X);if(Y){var me=k.type===this._wheelEventName?te.a.POINTERWHEEL:te.a.POINTERMOVE;if(H.onPointerMove&&H.onPointerMove(k,Y,me),H.onPointerObservable.hasObservers()){var _e=new te.b(me,k,Y);this._setRayOnPointerInfo(_e),H.onPointerObservable.notifyObservers(_e,me)}}}},re.prototype._setRayOnPointerInfo=function(Y){var k=this._scene;Y.pickInfo&&!Y.pickInfo._pickingUnavailable&&(Y.pickInfo.ray||(Y.pickInfo.ray=k.createPickingRay(Y.event.offsetX,Y.event.offsetY,m.a.Identity(),k.activeCamera)))},re.prototype._checkPrePointerObservable=function(Y,k,H){var Z=this._scene,X=new te.d(H,k,this._unTranslatedPointerX,this._unTranslatedPointerY);return Y&&(X.ray=Y.ray),Z.onPrePointerObservable.notifyObservers(X,H),!!X.skipOnPointerObservable},re.prototype.simulatePointerMove=function(Y,k){var H=new PointerEvent("pointermove",k);this._checkPrePointerObservable(Y,H,te.a.POINTERMOVE)||this._processPointerMove(Y,H)},re.prototype.simulatePointerDown=function(Y,k){var H=new PointerEvent("pointerdown",k);this._checkPrePointerObservable(Y,H,te.a.POINTERDOWN)||this._processPointerDown(Y,H)},re.prototype._processPointerDown=function(Y,k){var H=this,Z=this._scene;if(Y&&Y.hit&&Y.pickedMesh){this._pickedDownMesh=Y.pickedMesh;var X=Y.pickedMesh._getActionManagerForTrigger();if(X){if(X.hasPickTriggers)switch(X.processTrigger(I.a.ACTION_OnPickDownTrigger,T.a.CreateNew(Y.pickedMesh,k)),k.button){case 0:X.processTrigger(I.a.ACTION_OnLeftPickTrigger,T.a.CreateNew(Y.pickedMesh,k));break;case 1:X.processTrigger(I.a.ACTION_OnCenterPickTrigger,T.a.CreateNew(Y.pickedMesh,k));break;case 2:X.processTrigger(I.a.ACTION_OnRightPickTrigger,T.a.CreateNew(Y.pickedMesh,k))}X.hasSpecificTrigger(I.a.ACTION_OnLongPressTrigger)&&window.setTimeout(function(){var _e=Z.pick(H._unTranslatedPointerX,H._unTranslatedPointerY,function(be){return be.isPickable&&be.isVisible&&be.isReady()&&be.actionManager&&be.actionManager.hasSpecificTrigger(I.a.ACTION_OnLongPressTrigger)&&be==H._pickedDownMesh},!1,Z.cameraToUseForPointers);_e&&_e.hit&&_e.pickedMesh&&X&&H._totalPointersPressed!==0&&Date.now()-H._startingPointerTime>re.LongPressDelay&&!H._isPointerSwiping()&&(H._startingPointerTime=0,X.processTrigger(I.a.ACTION_OnLongPressTrigger,T.a.CreateNew(_e.pickedMesh,k)))},re.LongPressDelay)}}else for(var q=0,he=Z._pointerDownStage;q<he.length;q++)Y=he[q].action(this._unTranslatedPointerX,this._unTranslatedPointerY,Y,k);if(Y){var ge=te.a.POINTERDOWN;if(Z.onPointerDown&&Z.onPointerDown(k,Y,ge),Z.onPointerObservable.hasObservers()){var me=new te.b(ge,k,Y);this._setRayOnPointerInfo(me),Z.onPointerObservable.notifyObservers(me,ge)}}},re.prototype._isPointerSwiping=function(){return Math.abs(this._startingPointerPosition.x-this._pointerX)>re.DragMovementThreshold||Math.abs(this._startingPointerPosition.y-this._pointerY)>re.DragMovementThreshold},re.prototype.simulatePointerUp=function(Y,k,H){var Z=new PointerEvent("pointerup",k),X=new ae;H?X.doubleClick=!0:X.singleClick=!0,this._checkPrePointerObservable(Y,Z,te.a.POINTERUP)||this._processPointerUp(Y,Z,X)},re.prototype._processPointerUp=function(Y,k,H){var Z=this._scene;if(Y&&Y&&Y.pickedMesh){if(this._pickedUpMesh=Y.pickedMesh,this._pickedDownMesh===this._pickedUpMesh&&(Z.onPointerPick&&Z.onPointerPick(k,Y),H.singleClick&&!H.ignore&&Z.onPointerObservable.hasObservers())){var X=te.a.POINTERPICK,q=new te.b(X,k,Y);this._setRayOnPointerInfo(q),Z.onPointerObservable.notifyObservers(q,X)}var he=Y.pickedMesh._getActionManagerForTrigger();if(he&&!H.ignore){he.processTrigger(I.a.ACTION_OnPickUpTrigger,T.a.CreateNew(Y.pickedMesh,k)),!H.hasSwiped&&H.singleClick&&he.processTrigger(I.a.ACTION_OnPickTrigger,T.a.CreateNew(Y.pickedMesh,k));var ge=Y.pickedMesh._getActionManagerForTrigger(I.a.ACTION_OnDoublePickTrigger);H.doubleClick&&ge&&ge.processTrigger(I.a.ACTION_OnDoublePickTrigger,T.a.CreateNew(Y.pickedMesh,k))}}else if(!H.ignore)for(var me=0,_e=Z._pointerUpStage;me<_e.length;me++)Y=_e[me].action(this._unTranslatedPointerX,this._unTranslatedPointerY,Y,k);if(this._pickedDownMesh&&this._pickedDownMesh!==this._pickedUpMesh){var be=this._pickedDownMesh._getActionManagerForTrigger(I.a.ACTION_OnPickOutTrigger);be&&be.processTrigger(I.a.ACTION_OnPickOutTrigger,T.a.CreateNew(this._pickedDownMesh,k))}var Ce=0;Z.onPointerObservable.hasObservers()&&(!H.ignore&&!H.hasSwiped&&(H.singleClick&&Z.onPointerObservable.hasSpecificMask(te.a.POINTERTAP)?Ce=te.a.POINTERTAP:H.doubleClick&&Z.onPointerObservable.hasSpecificMask(te.a.POINTERDOUBLETAP)&&(Ce=te.a.POINTERDOUBLETAP),Ce)&&(q=new te.b(Ce,k,Y),this._setRayOnPointerInfo(q),Z.onPointerObservable.notifyObservers(q,Ce)),H.ignore||(Ce=te.a.POINTERUP,q=new te.b(Ce,k,Y),this._setRayOnPointerInfo(q),Z.onPointerObservable.notifyObservers(q,Ce))),Z.onPointerUp&&!H.ignore&&Z.onPointerUp(k,Y,Ce)},re.prototype.isPointerCaptured=function(Y){return Y===void 0&&(Y=0),this._pointerCaptures[Y]},re.prototype.attachControl=function(Y,k,H,Z){var X=this;Y===void 0&&(Y=!0),k===void 0&&(k=!0),H===void 0&&(H=!0),Z===void 0&&(Z=null);var q=this._scene;if(Z||(Z=q.getEngine().getInputElement()),Z){this._alreadyAttached&&this.detachControl(),this._alreadyAttachedTo=Z;var he=q.getEngine();this._initActionManager=function(be,Ce){if(!X._meshPickProceed){var ye=q.pick(X._unTranslatedPointerX,X._unTranslatedPointerY,q.pointerDownPredicate,!1,q.cameraToUseForPointers);X._currentPickResult=ye,ye&&(be=ye.hit&&ye.pickedMesh?ye.pickedMesh._getActionManagerForTrigger():null),X._meshPickProceed=!0}return be},this._delayedSimpleClick=function(be,Ce,ye){(Date.now()-X._previousStartingPointerTime>re.DoubleClickDelay&&!X._doubleClickOccured||be!==X._previousButtonPressed)&&(X._doubleClickOccured=!1,Ce.singleClick=!0,Ce.ignore=!1,ye(Ce,X._currentPickResult))},this._initClickEvent=function(be,Ce,ye,Be){var Ge=new ae;X._currentPickResult=null;var Xe=null,He=be.hasSpecificMask(te.a.POINTERPICK)||Ce.hasSpecificMask(te.a.POINTERPICK)||be.hasSpecificMask(te.a.POINTERTAP)||Ce.hasSpecificMask(te.a.POINTERTAP)||be.hasSpecificMask(te.a.POINTERDOUBLETAP)||Ce.hasSpecificMask(te.a.POINTERDOUBLETAP);!He&&de.a&&(Xe=X._initActionManager(Xe,Ge))&&(He=Xe.hasPickTriggers);var We=!1;if(He){var Ze=ye.button;if(Ge.hasSwiped=X._isPointerSwiping(),!Ge.hasSwiped){var ze=!re.ExclusiveDoubleClickMode;ze||(ze=!be.hasSpecificMask(te.a.POINTERDOUBLETAP)&&!Ce.hasSpecificMask(te.a.POINTERDOUBLETAP))&&!de.a.HasSpecificTrigger(I.a.ACTION_OnDoublePickTrigger)&&(Xe=X._initActionManager(Xe,Ge))&&(ze=!Xe.hasSpecificTrigger(I.a.ACTION_OnDoublePickTrigger)),ze?(D
26ate.now()-X._previousStartingPointerTime>re.DoubleClickDelay||Ze!==X._previousButtonPressed)&&(Ge.singleClick=!0,Be(Ge,X._currentPickResult),We=!0):(X._previousDelayedSimpleClickTimeout=X._delayedSimpleClickTimeout,X._delayedSimpleClickTimeout=window.setTimeout(X._delayedSimpleClick.bind(X,Ze,Ge,Be),re.DoubleClickDelay));var it=be.hasSpecificMask(te.a.POINTERDOUBLETAP)||Ce.hasSpecificMask(te.a.POINTERDOUBLETAP);!it&&de.a.HasSpecificTrigger(I.a.ACTION_OnDoublePickTrigger)&&(Xe=X._initActionManager(Xe,Ge))&&(it=Xe.hasSpecificTrigger(I.a.ACTION_OnDoublePickTrigger)),it&&(Ze===X._previousButtonPressed&&Date.now()-X._previousStartingPointerTime<re.DoubleClickDelay&&!X._doubleClickOccured?(Ge.hasSwiped||X._isPointerSwiping()?(X._doubleClickOccured=!1,X._previousStartingPointerTime=X._startingPointerTime,X._previousStartingPointerPosition.x=X._startingPointerPosition.x,X._previousStartingPointerPosition.y=X._startingPointerPosition.y,X._previousButtonPressed=Ze,re.ExclusiveDoubleClickMode?(X._previousDelayedSimpleClickTimeout&&clearTimeout(X._previousDelayedSimpleClickTimeout),X._previousDelayedSimpleClickTimeout=X._delayedSimpleClickTimeout,Be(Ge,X._previousPickResult)):Be(Ge,X._currentPickResult)):(X._previousStartingPointerTime=0,X._doubleClickOccured=!0,Ge.doubleClick=!0,Ge.ignore=!1,re.ExclusiveDoubleClickMode&&X._previousDelayedSimpleClickTimeout&&clearTimeout(X._previousDelayedSimpleClickTimeout),X._previousDelayedSimpleClickTimeout=X._delayedSimpleClickTimeout,Be(Ge,X._currentPickResult)),We=!0):(X._doubleClickOccured=!1,X._previousStartingPointerTime=X._startingPointerTime,X._previousStartingPointerPosition.x=X._startingPointerPosition.x,X._previousStartingPointerPosition.y=X._startingPointerPosition.y,X._previousButtonPressed=Ze))}}We||Be(Ge,X._currentPickResult)},this._onPointerMove=function(be){if(be.pointerId===void 0&&(be.pointerId=0),X._updatePointerPosition(be),!X._checkPrePointerObservable(null,be,be.type===X._wheelEventName?te.a.POINTERWHEEL:te.a.POINTERMOVE)&&(q.cameraToUseForPointers||q.activeCamera)){q.pointerMovePredicate||(q.pointerMovePredicate=function(ye){return ye.isPickable&&ye.isVisible&&ye.isReady()&&ye.isEnabled()&&(ye.enablePointerMoveEvents||q.constantlyUpdateMeshUnderPointer||ye._getActionManagerForTrigger()!=null)&&(!q.cameraToUseForPointers||(q.cameraToUseForPointers.layerMask&ye.layerMask)!=0)});var Ce=q.pick(X._unTranslatedPointerX,X._unTranslatedPointerY,q.pointerMovePredicate,!1,q.cameraToUseForPointers);X._processPointerMove(Ce,be)}},this._onPointerDown=function(be){if(X._totalPointersPressed++,X._pickedDownMesh=null,X._meshPickProceed=!1,be.pointerId===void 0&&(be.pointerId=0),X._updatePointerPosition(be),q.preventDefaultOnPointerDown&&Z&&(be.preventDefault(),Z.focus()),X._startingPointerPosition.x=X._pointerX,X._startingPointerPosition.y=X._pointerY,X._startingPointerTime=Date.now(),!X._checkPrePointerObservable(null,be,te.a.POINTERDOWN)&&(q.cameraToUseForPointers||q.activeCamera)){X._pointerCaptures[be.pointerId]=!0,q.pointerDownPredicate||(q.pointerDownPredicate=function(ye){return ye.isPickable&&ye.isVisible&&ye.isReady()&&ye.isEnabled()&&(!q.cameraToUseForPointers||(q.cameraToUseForPointers.layerMask&ye.layerMask)!=0)}),X._pickedDownMesh=null;var Ce=q.pick(X._unTranslatedPointerX,X._unTranslatedPointerY,q.pointerDownPredicate,!1,q.cameraToUseForPointers);X._processPointerDown(Ce,be)}},this._onPointerUp=function(be){X._totalPointersPressed!==0&&(X._totalPointersPressed--,X._pickedUpMesh=null,X._meshPickProceed=!1,be.pointerId===void 0&&(be.pointerId=0),X._updatePointerPosition(be),q.preventDefaultOnPointerUp&&Z&&(be.preventDefault(),Z.focus()),X._initClickEvent(q.onPrePointerObservable,q.onPointerObservable,be,function(Ce,ye){q.onPrePointerObservable.hasObservers()&&!Ce.ignore&&(!Ce.hasSwiped&&(Ce.singleClick&&q.onPrePointerObservable.hasSpecificMask(te.a.POINTERTAP)&&X._checkPrePointerObservable(null,be,te.a.POINTERTAP)||Ce.doubleClick&&q.onPrePointerObservable.hasSpecificMask(te.a.POINTERDOUBLETAP)&&X._checkPrePointerObservable(null,be,te.a.POINTERDOUBLETAP))||X._checkPrePointerObservable(null,be,te.a.POINTERUP))||X._pointerCaptures[be.pointerId]&&(X._pointerCaptures[be.pointerId]=!1,(q.cameraToUseForPointers||q.activeCamera)&&(q.pointerUpPredicate||(q.pointerUpPredicate=function(Be){return Be.isPickable&&Be.isVisible&&Be.isReady()&&Be.isEnabled()&&(!q.cameraToUseForPointers||(q.cameraToUseForPointers.layerMask&Be.layerMask)!=0)}),!X._meshPickProceed&&(de.a&&de.a.HasTriggers||q.onPointerObservable.hasObservers())&&X._initActionManager(null,Ce),ye||(ye=X._currentPickResult),X._processPointerUp(ye,be,Ce),X._previousPickResult=X._currentPickResult))}))},this._onKeyDown=function(be){var Ce=pe.a.KEYDOWN;
26if(q.onPreKeyboardObservable.hasObservers()){var ye=new pe.c(Ce,be);if(q.onPreKeyboardObservable.notifyObservers(ye,Ce),ye.skipOnPointerObservable)return}q.onKeyboardObservable.hasObservers()&&(ye=new pe.b(Ce,be),q.onKeyboardObservable.notifyObservers(ye,Ce)),q.actionManager&&q.actionManager.processTrigger(I.a.ACTION_OnKeyDownTrigger,T.a.CreateNewFromScene(q,be))},this._onKeyUp=function(be){var Ce=pe.a.KEYUP;if(q.onPreKeyboardObservable.hasObservers()){var ye=new pe.c(Ce,be);if(q.onPreKeyboardObservable.notifyObservers(ye,Ce),ye.skipOnPointerObservable)return}q.onKeyboardObservable.hasObservers()&&(ye=new pe.b(Ce,be),q.onKeyboardObservable.notifyObservers(ye,Ce)),q.actionManager&&q.actionManager.processTrigger(I.a.ACTION_OnKeyUpTrigger,T.a.CreateNewFromScene(q,be))};var ge=function(){Z&&!X._keyboardIsAttached&&(Z.addEventListener("keydown",X._onKeyDown,!1),Z.addEventListener("keyup",X._onKeyUp,!1),X._keyboardIsAttached=!0)};this._onCanvasFocusObserver=he.onCanvasFocusObservable.add((document.activeElement===Z&&ge(),ge)),this._onCanvasBlurObserver=he.onCanvasBlurObservable.add(function(){Z&&(Z.removeEventListener("keydown",X._onKeyDown),Z.removeEventListener("keyup",X._onKeyUp),X._keyboardIsAttached=!1)}),ge();var me=_.b.GetPointerPrefix(he);
26if(H&&(Z.addEventListener(me+"move",this._onPointerMove,!1),this._wheelEventName="onwheel"in document.createElement("div")?"wheel":document.onmousewheel!==void 0?"mousewheel":"DOMMouseScroll",Z.addEventListener(this._wheelEventName,this._onPointerMove,!1)),k&&Z.addEventListener(me+"down",this._onPointerDown,!1),Y){var _e=q.getEngine().getHostWindow();_e&&_e.addEventListener(me+"up",this._onPointerUp,!1)}this._alreadyAttached=!0}},re.prototype.detachControl=function(){var Y=this._scene.getEngine(),k=_.b.GetPointerPrefix(Y);this._alreadyAttachedTo&&this._alreadyAttached&&(this._alreadyAttachedTo.removeEventListener(k+"move",this._onPointerMove),this._alreadyAttachedTo.removeEventListener(this._wheelEventName,this._onPointerMove),this._alreadyAttachedTo.removeEventListener(k+"down",this._onPointerDown),window.removeEventListener(k+"up",this._onPointerUp),this._onCanvasBlurObserver&&Y.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),this._onCanvasFocusObserver&&Y.onCanvasFocusObservable.remove(this._onCanvasFocusObserver),this._alreadyAttachedTo.removeEventListener("keydown",this._onKeyDown),this._alreadyAttachedTo.removeEventListener("keyup",this._onKeyUp),this._scene.doNotHandleCursors||(this._alreadyAttachedTo.style.cursor=this._scene.defaultCursor),this._alreadyAttached=!1)},re.prototype.setPointerOverMesh=function(Y,k){if(k===void 0&&(k=0),k<0&&(k=0),this._meshUnderPointerId[k]!==Y){var H,Z=this._meshUnderPointerId[k];Z&&(H=Z._getActionManagerForTrigger(I.a.ACTION_OnPointerOutTrigger))&&H.processTrigger(I.a.ACTION_OnPointerOutTrigger,T.a.CreateNew(Z,void 0,{pointerId:k})),this._meshUnderPointerId[k]=Y,this._pointerOverMesh=Y,(Z=this._meshUnderPointerId[k])&&(H=Z._getActionManagerForTrigger(I.a.ACTION_OnPointerOverTrigger))&&H.processTrigger(I.a.ACTION_OnPointerOverTrigger,T.a.CreateNew(Z,void 0,{pointerId:k}))}},re.prototype.getPointerOverMesh=function(){return this._pointerOverMesh},re.DragMovementThreshold=10,re.LongPressDelay=500,re.DoubleClickDelay=300,re.ExclusiveDoubleClickMode=!1,re}(),K=f(55),$=f(9),L=f(90),G=f(152),Q=f(56),oe=function(re){function Y(k,H){var Z=re.call(this)||this;Z._inputManager=new ee(Z),Z.cameraToUseForPointers=null,Z._isScene=!0,Z._blockEntityCollection=!1,Z.autoClear=!0,Z.autoClearDepthAndStencil=!0,Z.clearColor=new $.b(.2,.2,.3,1),Z.ambientColor=new $.a(0,0,0),Z._environmentIntensity=1,Z._forceWireframe=!1,Z._skipFrustumClipping=!1,Z._forcePointsCloud=!1,Z.animationsEnabled=!0,Z._animationPropertiesOverride=null,Z.useConstantAnimationDeltaTime=!1,Z.constantlyUpdateMeshUnderPointer=!1,Z.hoverCursor="pointer",Z.defaultCursor="",Z.doNotHandleCursors=!1,Z.preventDefaultOnPointerDown=!0,Z.preventDefaultOnPointerUp=!0,Z.metadata=null,Z.reservedDataStore=null,Z.disableOfflineSupportExceptionRules=new Array,Z.onDisposeObservable=new u.c,Z._onDisposeObserver=null,Z.onBeforeRenderObservable=new u.c,Z._onBeforeRenderObserver=null,Z.onAfterRenderObservable=new u.c,Z.onAfterRenderCameraObservable=new u.c,Z._onAfterRenderObserver=null,Z.onBeforeAnimationsObservable=new u.c,Z.onAfterAnimationsObservable=new u.c,Z.onBeforeDrawPhaseObservable=new u.c,Z.onAfterDrawPhaseObservable=new u.c,Z.onReadyObservable=new u.c,Z.onBeforeCameraRenderObservable=new u.c,Z._onBeforeCameraRenderObserver=null,Z.onAfterCameraRenderObservable=new u.c,Z._onAfterCameraRenderObserver=null,Z.onBeforeActiveMeshesEvaluationObservable=new u.c,Z.onAfterActiveMeshesEvaluationObservable=new u.c,Z.onBeforeParticlesRenderingObservable=new u.c,Z.onAfterParticlesRenderingObservable=new u.c,Z.onDataLoadedObservable=new u.c,Z.onNewCameraAddedObservable=new u.c,Z.onCameraRemovedObservable=new u.c,Z.onNewLightAddedObservable=new u.c,Z.onLightRemovedObservable=new u.c,Z.onNewGeometryAddedObservable=new u.c,Z.onGeometryRemovedObservable=new u.c,Z.onNewTransformNodeAddedObservable=new u.c,Z.onTransformNodeRemovedObservable=new u.c,Z.onNewMeshAddedObservable=new u.c,Z.onMeshRemovedObservable=new u.c,Z.onNewSkeletonAddedObservable=new u.c,Z.onSkeletonRemovedObservable=new u.c,Z.onNewMaterialAddedObservable=new u.c,Z.onNewMultiMaterialAddedObservable=new u.c,Z.onMaterialRemovedObservable=new u.c,Z.onMultiMaterialRemovedObservable=new u.c,Z.onNewTextureAddedObservable=new u.c,Z.onTextureRemovedObservable=new u.c,Z.onBeforeRenderTargetsRenderObservable=new u.c,Z.onAfterRenderTargetsRenderObservable=new u.c,Z.onBeforeStepObservable=new u.c,Z.onAfterStepObservable=new u.c,Z.onActiveCameraChanged=new u.c,Z.onBeforeRenderingGroupObservable=new u.c,Z.onAfterRenderingGroupObservable=new u.c,Z.onMeshImportedObservable=new u.c,Z.onAnimationFileImportedObservable=new u.c,Z._registeredForLateAnimationBindings=new M.b(256),Z.onPrePointerObservable=new u.c,Z.onPointerObservable=new u.c,Z.onPreKeyboardObservable=new u.c,Z.onKeyboardObservable=new u.c,Z._useRightHandedSystem=!1,Z._timeAccumulator=0,Z._currentStepId=0,Z._currentInternalStep=0,Z._fogEnabled=!0,Z._fogMode=Y.FOGMODE_NONE,Z.fogColor=new $.a(.2,.2,.3),Z.fogDensity=.1,Z.fogStart=0,Z.fogEnd=1e3,Z.prePass=!1,Z._shadowsEnabled=!0,Z._lightsEnabled=!0,Z.activeCameras=new Array,Z._texturesEnabled=!0,Z.physicsEnabled=!0,Z.particlesEnabled=!0,Z.spritesEnabled=!0,Z._skeletonsEnabled=!0,Z.lensFlaresEnabled=!0,Z.collisionsEnabled=!0,Z.gravity=new m.e(0,-9.807,0),Z.postProcessesEnabled=!0,Z.renderTargetsEnabled=!0,Z.dumpNextRenderTargets=!1,Z.customRenderTargets=new Array,Z.importedMeshesFiles=new Array,Z.probesEnabled=!0,Z._meshesForIntersections=new M.b(256),Z.proceduralTexturesEnabled=!0,Z._totalVertices=new K.a,Z._activeIndices=new K.a,Z._activeParticles=new K.a,Z._activeBones=new K.a,Z._animationTime=0,Z.animationTimeScale=1,Z._renderId=0,Z._frameId=0,Z._executeWhenReadyTimeoutId=-1,Z._intermediateRendering=!1,Z._viewUpdateFlag=-1,Z._projectionUpdateFlag=-1,Z._toBeDisposed=new Array(256),Z._activeRequests=new Array,Z._pendingData=new Array,Z._isDisposed=!1,Z.dispatchAllSubMeshesOfActiveMeshes=!1,Z._activeMeshes=new M.a(256),Z._processedMaterials=new M.a(256),Z._renderTargets=new M.b(256),Z._activeParticleSystems=new M.a(256),Z._activeSkeletons=new M.b(32),Z._softwareSkinnedMeshes=new M.b(32),Z._activeAnimatables=new Array,Z._transformMatrix=m.a.Zero(),Z.requireLightSorting=!1,Z._components=[],Z._serializableComponents=[],Z._transientComponents=[],Z._beforeCameraUpdateStage=N.b.Create(),Z._beforeClearStage=N.b.Create(),Z._gatherRenderTargetsStage=N.b.Create(),Z._gatherActiveCameraRenderTargetsStage=N.b.Create(),Z._isReadyForMeshStage=N.b.Create(),Z._beforeEvaluateActiveMeshStage=N.b.Create(),Z._evaluateSubMeshStage=N.b.Create(),Z._preActiveMeshStage=N.b.Create(),Z._cameraDrawRenderTargetStage=N.b.Create(),Z._beforeCameraDrawStage=N.b.Create(),Z._beforeRenderTargetDrawStage=N.b.Create(),Z._beforeRenderingGroupDrawStage=N.b.Create(),Z._beforeRenderingMeshStage=N.b.Create(),Z._afterRenderingMeshStage=N.b.Create(),Z._afterRenderingGroupDrawStage=N.b.Create(),Z._afterCameraDrawStage=N.b.Create(),Z._afterRenderTargetDrawStage=N.b.Create(),Z._afterRenderStage=N.b.Create(),Z._pointerMoveStage=N.b.Create(),Z._pointerDownStage=N.b.Create(),Z._pointerUpStage=N.b.Create(),Z.geometriesByUniqueId=null,Z._defaultMeshCandidates={data:[],length:0},Z._defaultSubMeshCandidates={data:[],length:0},Z._preventFreeActiveMeshesAndRenderingGroups=!1,Z._activeMeshesFrozen=!1,Z._skipEvaluateActiveMeshesCompletely=!1,Z._allowPostProcessClearColor=!0,Z.getDeterministicFrameTime=function(){return Z._engine.getTimeStep()},Z._blockMaterialDirtyMechanism=!1;var X=Object(B.a)({useGeometryUniqueIdsMap:!0,useMaterialMeshMap:!0,useClonedMeshMap:!0,virtual:!1},H);return Z._engine=k||j.a.LastCreatedEngine,X.virtual||(j.a._LastCreatedScene=Z,Z._engine.scenes.push(Z)),Z._uid=null,Z._renderingManager=new w.b(Z),D.a&&(Z.postProcessManager=new D.a(Z)),V.a.IsWindowObjectExist()&&Z.attachControl(),Z._createUbo(),g.a&&(Z._imageProcessingConfiguration=new g.a),Z.setDefaultCandidateProviders(),X.useGeometryUniqueIdsMap&&(Z.geometriesByUniqueId={}),Z.useMaterialMeshMap=X.useMaterialMeshMap,Z.useClonedMeshMap=X.useClonedMeshMap,H&&H.virtual||Z._engine.onNewSceneAddedObservable.notifyObservers(Z),Z}return Object(B.d)(Y,re),Y.DefaultMaterialFactory=function(k){throw ne.a.WarnImport("StandardMaterial")},Y.CollisionCoordinatorFactory=function(){throw ne.a.WarnImport("DefaultCollisionCoordinator")},Object.defineProperty(Y.prototype,"environmentTexture",{get:function(){return this._environmentTexture},set:function(k){this._environmentTexture!==k&&(this._environmentTexture=k,this.markAllMaterialsAsDirty(I.a.MATERIAL_TextureDirtyFlag))}
26,enumerable:!1,configurable:!0}),Object.defineProperty(Y.prototype,"environmentIntensity",{get:function(){return this._environmentIntensity},set:function(k){this._environmentIntensity!==k&&(this._environmentIntensity=k,this.markAllMaterialsAsDirty(I.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(Y.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},enumerable:!1,configurable:!0}),Object.defineProperty(Y.prototype,"forceWireframe",{get:function(){return this._forceWireframe},set:function(k){this._forceWireframe!==k&&(this._forceWireframe=k,this.markAllMaterialsAsDirty(I.a.MATERIAL_MiscDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(Y.prototype,"skipFrustumClipping",{get:function(){return this._skipFrustumClipping},set:function(k){this._skipFrustumClipping!==k&&(this._skipFrustumClipping=k)},enumerable:!1,configurable:!0}),Object.defineProperty(Y.prototype,"forcePointsCloud",{get:function(){return this._forcePointsCloud},set:function(k){this._forcePointsCloud!==k&&(this._forcePointsCloud=k,this.markAllMaterialsAsDirty(I.a.MATERIAL_MiscDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(Y.prototype,"animationPropertiesOverride",{get:function(){return this._animationPropertiesOverride},set:function(k){this._animationPropertiesOverride=k},enumerable:!1,configurable:!0}),Object.defineProperty(Y.prototype,"onDispose",{set:function(k){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(k)},enumerable:!1,configurable:!0}),Object.defineProperty(Y.prototype,"beforeRender",{set:function(k){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),k&&(this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(k))},enumerable:!1,configurable:!0}),Object.defineProperty(Y.prototype,"afterRender",{set:function(k){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),k&&(this._onAfterRenderObserver=this.onAfterRenderObservable.add(k))},enumerable:!1,configurable:!0}),Object.defineProperty(Y.prototype,"beforeCameraRender",{set:function(k){this._onBeforeCameraRenderObserver&&this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=this.onBeforeCameraRenderObservable.add(k)},enumerable:!1,configurable:!0}),Object.defineProperty(Y.prototype,"afterCameraRender",{set:function(k){this._onAfterCameraRenderObserver&&this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=this.onAfterCameraRenderObservable.add(k)},enumerable:!1,configurable:!0}),Object.defineProperty(Y.prototype,"unTranslatedPointer",{get:function(){return this._inputManager.unTranslatedPointer},enumerable:!1,configurable:!0}),Object.defineProperty(Y,"DragMovementThreshold",{get:function(){return ee.DragMovementThreshold},set:function(k){ee.DragMovementThreshold=k},enumerable:!1,configurable:!0}),Object.defineProperty(Y,"LongPressDelay",{get:function(){return ee.LongPressDelay},set:function(k){ee.LongPressDelay=k},enumerable:!1,configurable:!0}),Object.defineProperty(Y,"DoubleClickDelay",{get:function(){return ee.DoubleClickDelay},set:function(k){ee.DoubleClickDelay=k},enumerable:!1,configurable:!0}),Object.defineProperty(Y,"ExclusiveDoubleClickMode",{get:function(){return ee.ExclusiveDoubleClickMode},set:function(k){ee.ExclusiveDoubleClickMode=k},enumerable:!1,configurable:!0}),Object.defineProperty(Y.prototype,"useRightHandedSystem",{get:function(){return this._useRightHandedSystem},set:function(k){this._useRightHandedSystem!==k&&(this._useRightHandedSystem=k,this.markAllMaterialsAsDirty(I.a.MATERIAL_MiscDirtyFlag))},enumerable:!1,configurable:!0}),Y.prototype.setStepId=function(k){this._currentStepId=k},Y.prototype.getStepId=function(){return this._currentStepId},Y.prototype.getInternalStep=function(){return this._currentInternalStep},Object.defineProperty(Y.prototype,"fogEnabled",{get:function(){return this._fogEnabled},set:function(k){this._fogEnabled!==k&&(this._fogEnabled=k,this.markAllMaterialsAsDirty(I.a.MATERIAL_MiscDirtyFlag))}
26,enumerable:!1,configurable:!0}),Object.defineProperty(Y.prototype,"fogMode",{get:function(){return this._fogMode},set:function(k){this._fogMode!==k&&(this._fogMode=k,this.markAllMaterialsAsDirty(I.a.MATERIAL_MiscDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(Y.prototype,"shadowsEnabled",{get:function(){return this._shadowsEnabled},set:function(k){this._shadowsEnabled!==k&&(this._shadowsEnabled=k,this.markAllMaterialsAsDirty(I.a.MATERIAL_LightDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(Y.prototype,"lightsEnabled",{get:function(){return this._lightsEnabled},set:function(k){this._lightsEnabled!==k&&(this._lightsEnabled=k,this.markAllMaterialsAsDirty(I.a.MATERIAL_LightDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(Y.prototype,"activeCamera",{get:function(){return this._activeCamera},set:function(k){k!==this._activeCamera&&(this._activeCamera=k,this.onActiveCameraChanged.notifyObservers(this))},enumerable:!1,configurable:!0}),Object.defineProperty(Y.prototype,"defaultMaterial",{get:function(){return this._defaultMaterial||(this._defaultMaterial=Y.DefaultMaterialFactory(this)),this._defaultMaterial},set:function(k){this._defaultMaterial=k},enumerable:!1,configurable:!0}),Object.defineProperty(Y.prototype,"texturesEnabled",{get:function(){return this._texturesEnabled},set:function(k){this._texturesEnabled!==k&&(this._texturesEnabled=k,this.markAllMaterialsAsDirty(I.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(Y.prototype,"skeletonsEnabled",{get:function(){return this._skeletonsEnabled},set:function(k){this._skeletonsEnabled!==k&&(this._skeletonsEnabled=k,this.markAllMaterialsAsDirty(I.a.MATERIAL_AttributesDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(Y.prototype,"collisionCoordinator",{get:function(){return this._collisionCoordinator||(this._collisionCoordinator=Y.CollisionCoordinatorFactory(),this._collisionCoordinator.init(this)),this._collisionCoordinator},enumerable:!1,configurable:!0}),Object.defineProperty(Y.prototype,"frustumPlanes",{get:function(){return this._frustumPlanes},enumerable:!1,configurable:!0}),Y.prototype._registerTransientComponents=function(){if(this._transientComponents.length>0){for(var k=0,H=this._transientComponents;k<H.length;k++)H[k].register();this._transientComponents=[]}},Y.prototype._addComponent=function(k){this._components.push(k),this._transientComponents.push(k);var H=k;H.addFromContainer&&H.serialize&&this._serializableComponents.push(H)},Y.prototype._getComponent=function(k){for(var H=0,Z=this._components;H<Z.length;H++){var X=Z[H];if(X.name===k)return X}return null},Y.prototype.getClassName=function(){return"Scene"},Y.prototype._getDefaultMeshCandidates=function(){return this._defaultMeshCandidates.data=this.meshes,this._defaultMeshCandidates.length=this.meshes.length,this._defaultMeshCandidates},Y.prototype._getDefaultSubMeshCandidates=function(k){return this._defaultSubMeshCandidates.data=k.subMeshes,this._defaultSubMeshCandidates.length=k.subMeshes.length,this._defaultSubMeshCandidates},Y.prototype.setDefaultCandidateProviders=function(){this.getActiveMeshCandidates=this._getDefaultMeshCandidates.bind(this),this.getActiveSubMeshCandidates=this._getDefaultSubMeshCandidates.bind(this),this.getIntersectingSubMeshCandidates=this._getDefaultSubMeshCandidates.bind(this),this.getCollidingSubMeshCandidates=this._getDefaultSubMeshCandidates.bind(this)},Object.defineProperty(Y.prototype,"meshUnderPointer",{get:function(){return this._inputManager.meshUnderPointer},enumerable:!1,configurable:!0}),Object.defineProperty(Y.prototype,"pointerX",{get:function(){return this._inputManager.pointerX},set:function(k){this._inputManager.pointerX=k},enumerable:!1,configurable:!0}),Object.defineProperty(Y.prototype,"pointerY",{get:function(){return this._inputManager.pointerY},set:function(k){this._inputManager.pointerY=k},enumerable:!1,configurable:!0}),Y.prototype.getCachedMaterial=function(){return this._cachedMaterial},Y.prototype.getCachedEffect=function(){return this._cachedEffect},Y.prototype.getCachedVisibility=function(){return this._cachedVisibility},Y.prototype.isCachedMaterialInvalid=function(k,H,Z){return Z===void 0&&(Z=1),this._cachedEffect!==H||this._cachedMaterial!==k||this._cachedVisibility!==Z},Y.prototype.getEngine=function(){return this._engine},Y.prototype.getTotalVertices=function(){return this._totalVertices.current},Object.defineProperty(Y.prototype,"totalVerticesPerfCounter",{get:function(){return this._totalVertices}
26,enumerable:!1,configurable:!0}),Y.prototype.getActiveIndices=function(){return this._activeIndices.current},Object.defineProperty(Y.prototype,"totalActiveIndicesPerfCounter",{get:function(){return this._activeIndices},enumerable:!1,configurable:!0}),Y.prototype.getActiveParticles=function(){return this._activeParticles.current},Object.defineProperty(Y.prototype,"activeParticlesPerfCounter",{get:function(){return this._activeParticles},enumerable:!1,configurable:!0}),Y.prototype.getActiveBones=function(){return this._activeBones.current},Object.defineProperty(Y.prototype,"activeBonesPerfCounter",{get:function(){return this._activeBones},enumerable:!1,configurable:!0}),Y.prototype.getActiveMeshes=function(){return this._activeMeshes},Y.prototype.getAnimationRatio=function(){return this._animationRatio!==void 0?this._animationRatio:1},Y.prototype.getRenderId=function(){return this._renderId},Y.prototype.getFrameId=function(){return this._frameId},Y.prototype.incrementRenderId=function(){this._renderId++},Y.prototype._createUbo=function(){this._sceneUbo=new l.a(this._engine,void 0,!0),this._sceneUbo.addUniform("viewProjection",16),this._sceneUbo.addUniform("view",16)},Y.prototype.simulatePointerMove=function(k,H){return this._inputManager.simulatePointerMove(k,H),this},Y.prototype.simulatePointerDown=function(k,H){return this._inputManager.simulatePointerDown(k,H),this},Y.prototype.simulatePointerUp=function(k,H,Z){return this._inputManager.simulatePointerUp(k,H,Z),this},Y.prototype.isPointerCaptured=function(k){return k===void 0&&(k=0),this._inputManager.isPointerCaptured(k)},Y.prototype.attachControl=function(k,H,Z){k===void 0&&(k=!0),H===void 0&&(H=!0),Z===void 0&&(Z=!0),this._inputManager.attachControl(k,H,Z)},Y.prototype.detachControl=function(){this._inputManager.detachControl()},Y.prototype.isReady=function(){if(this._isDisposed)return!1;var k,H=this.getEngine();if(!H.areAllEffectsReady()||this._pendingData.length>0)return!1;for(k=0;k<this.meshes.length;k++){var Z=this.meshes[k];if(Z.isEnabled()&&Z.subMeshes&&Z.subMeshes.length!==0){if(!Z.isReady(!0))return!1;for(var X=Z.hasThinInstances||Z.getClassName()==="InstancedMesh"||Z.getClassName()==="InstancedLinesMesh"||H.getCaps().instancedArrays&&Z.instances.length>0,q=0,he=this._isReadyForMeshStage;q<he.length;q++)if(!he[q].action(Z,X))return!1}}for(k=0;k<this.geometries.length;k++)if(this.geometries[k].delayLoadState===I.a.DELAYLOADSTATE_LOADING)return!1;if(this.activeCameras&&this.activeCameras.length>0){for(var ge=0,me=this.activeCameras;ge<me.length;ge++)if(!me[ge].isReady(!0))return!1}else if(this.activeCamera&&!this.activeCamera.isReady(!0))return!1;for(var _e=0,be=this.particleSystems;_e<be.length;_e++)if(!be[_e].isReady())return!1;return!0},Y.prototype.resetCachedMaterial=function(){this._cachedMaterial=null,this._cachedEffect=null,this._cachedVisibility=null},Y.prototype.registerBeforeRender=function(k){this.onBeforeRenderObservable.add(k)},Y.prototype.unregisterBeforeRender=function(k){this.onBeforeRenderObservable.removeCallback(k)},Y.prototype.registerAfterRender=function(k){this.onAfterRenderObservable.add(k)},Y.prototype.unregisterAfterRender=function(k){this.onAfterRenderObservable.removeCallback(k)},Y.prototype._executeOnceBeforeRender=function(k){var H=this,Z=function(){k(),setTimeout(function(){H.unregisterBeforeRender(Z)})};this.registerBeforeRender(Z)},Y.prototype.executeOnceBeforeRender=function(k,H){var Z=this;H!==void 0?setTimeout(function(){Z._executeOnceBeforeRender(k)},H):this._executeOnceBeforeRender(k)},Y.prototype._addPendingData=function(k){this._pendingData.push(k)},Y.prototype._removePendingData=function(k){var H=this.isLoading,Z=this._pendingData.indexOf(k);Z!==-1&&this._pendingData.splice(Z,1),H&&!this.isLoading&&this.onDataLoadedObservable.notifyObservers(this)},Y.prototype.getWaitingItemsCount=function(){return this._pendingData.length},Object.defineProperty(Y.prototype,"isLoading",{get:function(){return this._pendingData.length>0},enumerable:!1,configurable:!0}),Y.prototype.executeWhenReady=function(k){var H=this;this.onReadyObservable.add(k),this._executeWhenReadyTimeoutId===-1&&(this._executeWhenReadyTimeoutId=setTimeout(function(){H._checkIsReady()},150))},Y.prototype.whenReadyAsync=function(){var k=this;return new Promise(function(H){k.executeWhenReady(function(){H()})})},Y.prototype._checkIsReady=function(){var k=this;return this._registerTransientComponents(),this.isReady()?(this.onReadyObservable.notifyObservers(this),this.onReadyObservable.clear(),void(this._executeWhenReadyTimeoutId=-1)):this._isDisposed?(this.onReadyObservable.clear(),void(this._executeWhenReadyTimeoutId=-1)):void(this._executeWhenReadyTimeoutId=setTimeout(function(){k._checkIsReady()},150))},Object.defineProperty(Y.prototype,"animatables",{get:function(){return this._activeAnimatables}
26,enumerable:!1,configurable:!0}),Y.prototype.resetLastAnimationTimeFrame=function(){this._animationTimeLast=x.a.Now},Y.prototype.getViewMatrix=function(){return this._viewMatrix},Y.prototype.getProjectionMatrix=function(){return this._projectionMatrix},Y.prototype.getTransformMatrix=function(){return this._transformMatrix},Y.prototype.setTransformMatrix=function(k,H,Z,X){this._viewUpdateFlag===k.updateFlag&&this._projectionUpdateFlag===H.updateFlag||(this._viewUpdateFlag=k.updateFlag,this._projectionUpdateFlag=H.updateFlag,this._viewMatrix=k,this._projectionMatrix=H,this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._frustumPlanes?L.a.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=L.a.GetPlanes(this._transformMatrix),this._multiviewSceneUbo&&this._multiviewSceneUbo.useUbo?this._updateMultiviewUbo(Z,X):this._sceneUbo.useUbo&&(this._sceneUbo.updateMatrix("viewProjection",this._transformMatrix),this._sceneUbo.updateMatrix("view",this._viewMatrix),this._sceneUbo.update()))},Y.prototype.getSceneUniformBuffer=function(){return this._multiviewSceneUbo?this._multiviewSceneUbo:this._sceneUbo},Y.prototype.getUniqueId=function(){return G.a.UniqueId},Y.prototype.addMesh=function(k,H){var Z=this;H===void 0&&(H=!1),this._blockEntityCollection||(this.meshes.push(k),k._resyncLightSources(),k.parent||k._addToSceneRootNodes(),this.onNewMeshAddedObservable.notifyObservers(k),H&&k.getChildMeshes().forEach(function(X){Z.addMesh(X)}))},Y.prototype.removeMesh=function(k,H){var Z=this;H===void 0&&(H=!1);var X=this.meshes.indexOf(k);return X!==-1&&(this.meshes[X]=this.meshes[this.meshes.length-1],this.meshes.pop(),k.parent||k._removeFromSceneRootNodes()),this.onMeshRemovedObservable.notifyObservers(k),H&&k.getChildMeshes().forEach(function(q){Z.removeMesh(q)}),X},Y.prototype.addTransformNode=function(k){this._blockEntityCollection||(k._indexInSceneTransformNodesArray=this.transformNodes.length,this.transformNodes.push(k),k.parent||k._addToSceneRootNodes(),this.onNewTransformNodeAddedObservable.notifyObservers(k))},Y.prototype.removeTransformNode=function(k){var H=k._indexInSceneTransformNodesArray;if(H!==-1){if(H!==this.transformNodes.length-1){var Z=this.transformNodes[this.transformNodes.length-1];this.transformNodes[H]=Z,Z._indexInSceneTransformNodesArray=H}k._indexInSceneTransformNodesArray=-1,this.transformNodes.pop(),k.parent||k._removeFromSceneRootNodes()}return this.onTransformNodeRemovedObservable.notifyObservers(k),H},Y.prototype.removeSkeleton=function(k){var H=this.skeletons.indexOf(k);return H!==-1&&(this.skeletons.splice(H,1),this.onSkeletonRemovedObservable.notifyObservers(k)),H},Y.prototype.removeMorphTargetManager=function(k){var H=this.morphTargetManagers.indexOf(k);return H!==-1&&this.morphTargetManagers.splice(H,1),H},Y.prototype.removeLight=function(k){var H=this.lights.indexOf(k);if(H!==-1){for(var Z=0,X=this.meshes;Z<X.length;Z++)X[Z]._removeLightSource(k,!1);this.lights.splice(H,1),this.sortLightsByPriority(),k.parent||k._removeFromSceneRootNodes()}return this.onLightRemovedObservable.notifyObservers(k),H},Y.prototype.removeCamera=function(k){var H=this.cameras.indexOf(k);if(H!==-1&&(this.cameras.splice(H,1),k.parent||k._removeFromSceneRootNodes()),this.activeCameras){var Z=this.activeCameras.indexOf(k);Z!==-1&&this.activeCameras.splice(Z,1)}return this.activeCamera===k&&(this.cameras.length>0?this.activeCamera=this.cameras[0]:this.activeCamera=null),this.onCameraRemovedObservable.notifyObservers(k),H},Y.prototype.removeParticleSystem=function(k){var H=this.particleSystems.indexOf(k);return H!==-1&&this.particleSystems.splice(H,1),H},Y.prototype.removeAnimation=function(k){var H=this.animations.indexOf(k);return H!==-1&&this.animations.splice(H,1),H},Y.prototype.stopAnimation=function(k,H,Z){},Y.prototype.removeAnimationGroup=function(k){var H=this.animationGroups.indexOf(k);return H!==-1&&this.animationGroups.splice(H,1),H},Y.prototype.removeMultiMaterial=function(k){var H=this.multiMaterials.indexOf(k);return H!==-1&&this.multiMaterials.splice(H,1),this.onMultiMaterialRemovedObservable.notifyObservers(k),H},Y.prototype.removeMaterial=function(k){var H=k._indexInSceneMaterialArray;
26if(H!==-1&&H<this.materials.length){if(H!==this.materials.length-1){var Z=this.materials[this.materials.length-1];this.materials[H]=Z,Z._indexInSceneMaterialArray=H}k._indexInSceneMaterialArray=-1,this.materials.pop()}return this.onMaterialRemovedObservable.notifyObservers(k),H},Y.prototype.removeActionManager=function(k){var H=this.actionManagers.indexOf(k);return H!==-1&&this.actionManagers.splice(H,1),H},Y.prototype.removeTexture=function(k){var H=this.textures.indexOf(k);return H!==-1&&this.textures.splice(H,1),this.onTextureRemovedObservable.notifyObservers(k),H},Y.prototype.addLight=function(k){if(!this._blockEntityCollection){this.lights.push(k),this.sortLightsByPriority(),k.parent||k._addToSceneRootNodes();for(var H=0,Z=this.meshes;H<Z.length;H++){var X=Z[H];X.lightSources.indexOf(k)===-1&&(X.lightSources.push(k),X._resyncLightSources())}this.onNewLightAddedObservable.notifyObservers(k)}},Y.prototype.sortLightsByPriority=function(){this.requireLightSorting&&this.lights.sort(h.a.CompareLightsPriority)},Y.prototype.addCamera=function(k){this._blockEntityCollection||(this.cameras.push(k),this.onNewCameraAddedObservable.notifyObservers(k),k.parent||k._addToSceneRootNodes())},Y.prototype.addSkeleton=function(k){this._blockEntityCollection||(this.skeletons.push(k),this.onNewSkeletonAddedObservable.notifyObservers(k))},Y.prototype.addParticleSystem=function(k){this._blockEntityCollection||this.particleSystems.push(k)},Y.prototype.addAnimation=function(k){this._blockEntityCollection||this.animations.push(k)},Y.prototype.addAnimationGroup=function(k){this._blockEntityCollection||this.animationGroups.push(k)},Y.prototype.addMultiMaterial=function(k){this._blockEntityCollection||(this.multiMaterials.push(k),this.onNewMultiMaterialAddedObservable.notifyObservers(k))},Y.prototype.addMaterial=function(k){this._blockEntityCollection||(k._indexInSceneMaterialArray=this.materials.length,this.materials.push(k),this.onNewMaterialAddedObservable.notifyObservers(k))},Y.prototype.addMorphTargetManager=function(k){this._blockEntityCollection||this.morphTargetManagers.push(k)},Y.prototype.addGeometry=function(k){this._blockEntityCollection||(this.geometriesByUniqueId&&(this.geometriesByUniqueId[k.uniqueId]=this.geometries.length),this.geometries.push(k))},Y.prototype.addActionManager=function(k){this.actionManagers.push(k)},Y.prototype.addTexture=function(k){this._blockEntityCollection||(this.textures.push(k),this.onNewTextureAddedObservable.notifyObservers(k))},Y.prototype.switchActiveCamera=function(k,H){H===void 0&&(H=!0),this._engine.getInputElement()&&(this.activeCamera&&this.activeCamera.detachControl(),this.activeCamera=k,H&&k.attachControl())},Y.prototype.setActiveCameraByID=function(k){var H=this.getCameraByID(k);return H?(this.activeCamera=H,H):null},Y.prototype.setActiveCameraByName=function(k){var H=this.getCameraByName(k);return H?(this.activeCamera=H,H):null},Y.prototype.getAnimationGroupByName=function(k){for(var H=0;H<this.animationGroups.length;H++)if(this.animationGroups[H].name===k)return this.animationGroups[H];return null},Y.prototype.getMaterialByUniqueID=function(k){for(var H=0;H<this.materials.length;H++)if(this.materials[H].uniqueId===k)return this.materials[H];return null},Y.prototype.getMaterialByID=function(k){for(var H=0;H<this.materials.length;H++)if(this.materials[H].id===k)return this.materials[H];return null},Y.prototype.getLastMaterialByID=function(k){for(var H=this.materials.length-1;H>=0;H--)if(this.materials[H].id===k)return this.materials[H];return null},Y.prototype.getMaterialByName=function(k){for(var H=0;H<this.materials.length;H++)if(this.materials[H].name===k)return this.materials[H];return null},Y.prototype.getTextureByUniqueID=function(k){for(var H=0;H<this.textures.length;H++)if(this.textures[H].uniqueId===k)return this.textures[H];return null},Y.prototype.getCameraByID=function(k){for(var H=0;H<this.cameras.length;H++)if(this.cameras[H].id===k)return this.cameras[H];return null},Y.prototype.getCameraByUniqueID=function(k){for(var H=0;H<this.cameras.length;H++)if(this.cameras[H].uniqueId===k)return this.cameras[H];return null},Y.prototype.getCameraByName=function(k){for(var H=0;H<this.cameras.length;H++)if(this.cameras[H].name===k)return this.cameras[H];return null},Y.prototype.getBoneByID=function(k){for(var H=0;H<this.skeletons.length;H++)for(var Z=this.skeletons[H],X=0;X<Z.bones.length;X++)if(Z.bones[X].id===k)return Z.bones[X];return null},Y.prototype.getBoneByName=function(k){for(var H=0;H<this.skeletons.length;H++)for(var Z=this.skeletons[H],X=0;X<Z.bones.length;X++)if(Z.bones[X].name===k)return Z.bones[X];return null},Y.prototype.getLightByName=function(k){for(var H=0;H<this.lights.length;H++)if(this.lights[H].name===k)return this.lights[H];return null},Y.prototype.getLightByID=function(k){for(var H=0;H<this.lights.length;H++)if(this.lights[H].id===k)return this.lights[H];return null},Y.prototype.getLightByUniqueID=function(k){for(var H=0;H<this.lights.length;H++)if(this.lights[H].uniqueId===k)return this.lights[H];return null},Y.prototype.getParticleSystemByID=function(k){for(var H=0;H<this.particleSystems.length;H++)if(this.particleSystems[H].id===k)return this.particleSystems[H];return null},Y.prototype.getGeometryByID=function(k){for(var H=0;H<this.geometries.length;H++)if(this.geometries[H].id===k)return this.geometries[H];return null},Y.prototype._getGeometryByUniqueID=function(k){if(this.geometriesByUniqueId){var H=this.geometriesByUniqueId[k];if(H!==void 0)return this.geometries[H]}else for(var Z=0;Z<this.geometries.length;Z++)if(this.geometries[Z].uniqueId===k)return this.geometries[Z];return null},Y.prototype.pushGeometry=function(k,H){return!(!H&&this._getGeometryByUniqueID(k.uniqueId))&&(this.addGeometry(k),this.onNewGeometryAddedObservable.notifyObservers(k),!0)},Y.prototype.removeGeometry=function(k){var H;if(this.geometriesByUniqueId){if((H=this.geometriesByUniqueId[k.uniqueId])===void 0)return!1}else if((H=this.geometries.indexOf(k))<0)return!1;if(H!==this.geometries.length-1){var Z=this.geometries[this.geometries.length-1];Z&&(this.geometries[H]=Z,this.geometriesByUniqueId&&(this.geometriesByUniqueId[Z.uniqueId]=H,this.geometriesByUniqueId[k.uniqueId]=void 0))}return this.geometries.pop(),this.onGeometryRemovedObservable.notifyObservers(k),!0},Y.prototype.getGeometries=function(){return this.geometries},Y.prototype.getMeshByID=function(k){for(var H=0;H<this.meshes.length;H++)if(this.meshes[H].id===k)return this.meshes[H];return null},Y.prototype.getMeshesByID=function(k){return this.meshes.filter(function(H){return H.id===k})},Y.prototype.getTransformNodeByID=function(k){for(var H=0;H<this.transformNodes.length;H++)if(this.transformNodes[H].id===k)return this.transformNodes[H];return null},Y.prototype.getTransformNodeByUniqueID=function(k){for(var H=0;H<this.transformNodes.length;H++)if(this.transformNodes[H].uniqueId===k)return this.transformNodes[H];return null},Y.prototype.getTransformNodesByID=function(k){return this.transformNodes.filter(function(H){return H.id===k})},Y.prototype.getMeshByUniqueID=function(k){for(var H=0;H<this.meshes.length;H++)if(this.meshes[H].uniqueId===k)return this.meshes[H];return null},Y.prototype.getLastMeshByID=function(k){for(var H=this.meshes.length-1;H>=0;H--)if(this.meshes[H].id===k)return this.meshes[H];return null},Y.prototype.getLastEntryByID=function(k){var H;for(H=this.meshes.length-1;H>=0;H--)if(this.meshes[H].id===k)return this.meshes[H];for(H=this.transformNodes.length-1;H>=0;H--)if(this.transformNodes[H].id===k)return this.transformNodes[H];for(H=this.cameras.length-1;H>=0;H--)if(this.cameras[H].id===k)return this.cameras[H];for(H=this.lights.length-1;H>=0;H--)if(this.lights[H].id===k)return this.lights[H];return null},Y.prototype.getNodeByID=function(k){var H=this.getMeshByID(k);if(H)return H;var Z=this.getTransformNodeByID(k);if(Z)return Z;var X=this.getLightByID(k);if(X)return X;var q=this.getCameraByID(k);if(q)return q;var he=this.getBoneByID(k);return he||null},Y.prototype.getNodeByName=function(k){var H=this.getMeshByName(k);if(H)return H;var Z=this.getTransformNodeByName(k);if(Z)return Z;var X=this.getLightByName(k);if(X)return X;var q=this.getCameraByName(k);if(q)return q;var he=this.getBoneByName(k);return he||null},Y.prototype.getMeshByName=function(k){for(var H=0;H<this.meshes.length;H++)if(this.meshes[H].name===k)return this.meshes[H];return null},Y.prototype.getTransformNodeByName=function(k){for(var H=0;H<this.transformNodes.length;H++)if(this.transformNodes[H].name===k)return this.transformNodes[H];return null},Y.prototype.getLastSkeletonByID=function(k){for(var H=this.skeletons.length-1;H>=0;H--)if(this.skeletons[H].id===k)return this.skeletons[H];return null},Y.prototype.getSkeletonByUniqueId=function(k){for(var H=0;H<this.skeletons.length;H++)if(this.skeletons[H].uniqueId===k)return this.skeletons[H];return null},Y.prototype.getSkeletonById=function(k){for(var H=0;H<this.skeletons.length;H++)if(this.skeletons[H].id===k)return this.skeletons[H];return null},Y.prototype.getSkeletonByName=function(k){for(var H=0;H<this.skeletons.length;H++)if(this.skeletons[H].name===k)return this.skeletons[H];return null},Y.prototype.getMorphTargetManagerById=function(k){for(var H=0;H<this.morphTargetManagers.length;H++)if(this.morphTargetManagers[H].uniqueId===k)return this.morphTargetManagers[H];return null},Y.prototype.getMorphTargetById=function(k){for(var H=0;H<this.morphTargetManagers.length;++H)for(var Z=this.morphTargetManagers[H],X=0;X<Z.numTargets;++X){var q=Z.getTarget(X);if(q.id===k)return q}return null},Y.prototype.getMorphTargetByName=function(k){for(var H=0;H<this.morphTargetManagers.length;++H)for(var Z=this.morphTargetManagers[H],X=0;X<Z.numTargets;++X){var q=Z.getTarget(X);if(q.name===k)return q}return null},Y.prototype.getPostProcessByName=function(k){for(var H=0;H<this.postProcesses.length;++H){var Z=this.postProcesses[H];if(Z.name===k)return Z}return null},Y.prototype.isActiveMesh=function(k){return this._activeMeshes.indexOf(k)!==-1},Object.defineProperty(Y.prototype,"uid",{get:function(){return this._uid||(this._uid=_.b.RandomId()),this._uid}
26,enumerable:!1,configurable:!0}),Y.prototype.addExternalData=function(k,H){return this._externalData||(this._externalData=new R.a),this._externalData.add(k,H)},Y.prototype.getExternalData=function(k){return this._externalData?this._externalData.get(k):null},Y.prototype.getOrAddExternalDataWithFactory=function(k,H){return this._externalData||(this._externalData=new R.a),this._externalData.getOrAddWithFactory(k,H)},Y.prototype.removeExternalData=function(k){return this._externalData.remove(k)},Y.prototype._evaluateSubMesh=function(k,H,Z){if(Z.hasInstances||Z.isAnInstance||this.dispatchAllSubMeshesOfActiveMeshes||this._skipFrustumClipping||H.alwaysSelectAsActiveMesh||H.subMeshes.length===1||k.isInFrustum(this._frustumPlanes)){for(var X=0,q=this._evaluateSubMeshStage;X<q.length;X++)q[X].action(H,k);var he=k.getMaterial();he!=null&&(he.hasRenderTargetTextures&&he.getRenderTargetTextures!=null&&this._processedMaterials.indexOf(he)===-1&&(this._processedMaterials.push(he),this._renderTargets.concatWithNoDuplicate(he.getRenderTargetTextures())),this._renderingManager.dispatch(k,H,he))}},Y.prototype.freeProcessedMaterials=function(){this._processedMaterials.dispose()},Object.defineProperty(Y.prototype,"blockfreeActiveMeshesAndRenderingGroups",{get:function(){return this._preventFreeActiveMeshesAndRenderingGroups},set:function(k){this._preventFreeActiveMeshesAndRenderingGroups!==k&&(k&&(this.freeActiveMeshes(),this.freeRenderingGroups()),this._preventFreeActiveMeshesAndRenderingGroups=k)},enumerable:!1,configurable:!0}),Y.prototype.freeActiveMeshes=function(){if(!this.blockfreeActiveMeshesAndRenderingGroups&&(this._activeMeshes.dispose(),this.activeCamera&&this.activeCamera._activeMeshes&&this.activeCamera._activeMeshes.dispose(),this.activeCameras))for(var k=0;k<this.activeCameras.length;k++){var H=this.activeCameras[k];H&&H._activeMeshes&&H._activeMeshes.dispose()}},Y.prototype.freeRenderingGroups=function(){if(!this.blockfreeActiveMeshesAndRenderingGroups&&(this._renderingManager&&this._renderingManager.freeRenderingGroups(),this.textures))for(var k=0;k<this.textures.length;k++){var H=this.textures[k];H&&H.renderList&&H.freeRenderingGroups()}},Y.prototype._isInIntermediateRendering=function(){return this._intermediateRendering},Y.prototype.freezeActiveMeshes=function(k,H,Z){var X=this;return k===void 0&&(k=!1),this.executeWhenReady(function(){if(X.activeCamera){X._frustumPlanes||X.setTransformMatrix(X.activeCamera.getViewMatrix(),X.activeCamera.getProjectionMatrix()),X._evaluateActiveMeshes(),X._activeMeshesFrozen=!0,X._skipEvaluateActiveMeshesCompletely=k;for(var q=0;q<X._activeMeshes.length;q++)X._activeMeshes.data[q]._freeze();H&&H()}else Z&&Z("No active camera found")}),this},Y.prototype.unfreezeActiveMeshes=function(){for(var k=0;k<this.meshes.length;k++){var H=this.meshes[k];H._internalAbstractMeshDataInfo&&(H._internalAbstractMeshDataInfo._isActive=!1)}for(k=0;k<this._activeMeshes.length;k++)this._activeMeshes.data[k]._unFreeze();return this._activeMeshesFrozen=!1,this},Y.prototype._evaluateActiveMeshes=function(){if(this._activeMeshesFrozen&&this._activeMeshes.length){if(!this._skipEvaluateActiveMeshesCompletely)for(var k=this._activeMeshes.length,H=0;H<k;H++)(me=this._activeMeshes.data[H]).computeWorldMatrix();if(this._activeParticleSystems){var Z=this._activeParticleSystems.length;for(H=0;H<Z;H++)this._activeParticleSystems.data[H].animate()}}else if(this.activeCamera){this.onBeforeActiveMeshesEvaluationObservable.notifyObservers(this),this.activeCamera._activeMeshes.reset(),this._activeMeshes.reset(),this._renderingManager.reset(),this._processedMaterials.reset(),this._activeParticleSystems.reset(),this._activeSkeletons.reset(),this._softwareSkinnedMeshes.reset();for(var X=0,q=this._beforeEvaluateActiveMeshStage;X<q.length;X++)q[X].action();var he=this.getActiveMeshCandidates(),ge=he.length;for(H=0;H<ge;H++){var me;if((me=he.data[H])._internalAbstractMeshDataInfo._currentLODIsUpToDate=!1,!me.isBlocked&&(this._totalVertices.addCount(me.getTotalVertices(),!1),me.isReady()&&me.isEnabled()&&me.scaling.lengthSquared()!==0)){me.computeWorldMatrix(),me.actionManager&&me.actionManager.hasSpecificTriggers2(I.a.ACTION_OnIntersectionEnterTrigger,I.a.ACTION_OnIntersectionExitTrigger)&&this._meshesForIntersections.pushNo
26Duplicate(me);var _e=this.customLODSelector?this.customLODSelector(me,this.activeCamera):me.getLOD(this.activeCamera);if(me._internalAbstractMeshDataInfo._currentLOD=_e,me._internalAbstractMeshDataInfo._currentLODIsUpToDate=!0,_e!=null&&(_e!==me&&_e.billboardMode!==c.a.BILLBOARDMODE_NONE&&_e.computeWorldMatrix(),me._preActivate(),me.isVisible&&me.visibility>0&&(me.layerMask&this.activeCamera.layerMask)!=0&&(this._skipFrustumClipping||me.alwaysSelectAsActiveMesh||me.isInFrustum(this._frustumPlanes)))){this._activeMeshes.push(me),this.activeCamera._activeMeshes.push(me),_e!==me&&_e._activate(this._renderId,!1);for(var be=0,Ce=this._preActiveMeshStage;be<Ce.length;be++)Ce[be].action(me);me._activate(this._renderId,!1)&&(me.isAnInstance?me._internalAbstractMeshDataInfo._actAsRegularMesh&&(_e=me):_e._internalAbstractMeshDataInfo._onlyForInstances=!1,_e._internalAbstractMeshDataInfo._isActive=!0,this._activeMesh(me,_e)),me._postActivate()}}}if(this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this),this.particlesEnabled){this.onBeforeParticlesRenderingObservable.notifyObservers(this);for(var ye=0;ye<this.particleSystems.length;ye++){var Be=this.particleSystems[ye];if(Be.isStarted()&&Be.emitter){var Ge=Be.emitter;Ge.position&&!Ge.isEnabled()||(this._activeParticleSystems.push(Be),Be.animate(),this._renderingManager.dispatchParticles(Be))}}this.onAfterParticlesRenderingObservable.notifyObservers(this)}}},Y.prototype._activeMesh=function(k,H){if(this._skeletonsEnabled&&H.skeleton!==null&&H.skeleton!==void 0&&(this._activeSkeletons.pushNoDuplicate(H.skeleton)&&H.skeleton.prepare(),H.computeBonesUsingShaders||this._softwareSkinnedMeshes.pushNoDuplicate(H)),H!=null&&H.subMeshes!==void 0&&H.subMeshes!==null&&H.subMeshes.length>0)for(var Z=this.getActiveSubMeshCandidates(H),X=Z.length,q=0;q<X;q++){var he=Z.data[q];this._evaluateSubMesh(he,H,k)}},Y.prototype.updateTransformMatrix=function(k){this.activeCamera&&this.setTransformMatrix(this.activeCamera.getViewMatrix(),this.activeCamera.getProjectionMatrix(k))},Y.prototype._bindFrameBuffer=function(){if(this.activeCamera&&this.activeCamera._multiviewTexture)this.activeCamera._multiviewTexture._bindFrameBuffer();else if(this.activeCamera&&this.activeCamera.outputRenderTarget)if(this.getEngine().getCaps().multiview&&this.activeCamera.outputRenderTarget&&this.activeCamera.outputRenderTarget.getViewCount()>1)this.activeCamera.outputRenderTarget._bindFrameBuffer();else{var k=this.activeCamera.outputRenderTarget.getInternalTexture();k?this.getEngine().bindFramebuffer(k):W.a.Error("Camera contains invalid customDefaultRenderTarget")}else this.getEngine().restoreDefaultFramebuffer()},Y.prototype._renderForCamera=function(k,H){if(!k||!k._skipRendering){var Z=this._engine;if(this._activeCamera=k,!this.activeCamera)throw new Error("Active camera not set");Z.setViewport(this.activeCamera.viewport),this.resetCachedMaterial(),this._renderId++,this.getEngine().getCaps().multiview&&k.outputRenderTarget&&k.outputRenderTarget.getViewCount()>1?this.setTransformMatrix(k._rigCameras[0].getViewMatrix(),k._rigCameras[0].getProjectionMatrix(),k._rigCameras[1].getViewMatrix(),k._rigCameras[1].getProjectionMatrix()):this.updateTransformMatrix(),this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera),this._evaluateActiveMeshes();for(var X=0;X<this._softwareSkinnedMeshes.length;X++){var q=this._softwareSkinnedMeshes.data[X];q.applySkeleton(q.skeleton)}this.onBeforeRenderTargetsRenderObservable.notifyObservers(this),k.customRenderTargets&&k.customRenderTargets.length>0&&this._renderTargets.concatWithNoDuplicate(k.customRenderTargets),H&&H.customRenderTargets&&H.customRenderTargets.length>0&&this._renderTargets.concatWithNoDuplicate(H.customRenderTargets);for(var he=0,ge=this._gatherActiveCameraRenderTargetsStage;he<ge.length;he++)ge[he].action(this._renderTargets);var me=!1;if(this.renderTargetsEnabled){if(this._intermediateRendering=!0,this._renderTargets.length>0){_.b.StartPerformanceCounter("Render targets",this._renderTargets.length>0);for(var _e=0;_e<this._renderTargets.length;_e++){var be=this._renderTargets.data[_e];if(be._shouldRender()){this._renderId++;var Ce=be.activeCamera&&be.activeCamera!==this.activeCamera;be.render(Ce,this.dumpNextRenderTargets),me=!0}}_.b.EndPerformanceCounter("Render targets",this._renderTargets.length>0),this._renderId++}for(var ye=0,Be=this._cameraDrawRenderTargetStage;ye<Be.length;ye++)me=Be[ye].action(this.activeCamera)||me;this._intermediateRendering=!1,this.activeCamera&&this.activeCamera.outputRenderTarget&&(me=!0)}me&&!this.prePass&&this._bindFrameBuffer(),this.onAfterRenderTargetsRenderObservable.notifyObservers(this),!this.postProcessManager||k._multiviewTexture||this.prePass||this.postProcessManager._prepareFrame();for(var Ge=0,Xe=this._beforeCameraDrawStage;Ge<Xe.length;Ge++)Xe[Ge].action(this.activeCamera);this.onBeforeDrawPhaseObservable.notifyObservers(this),this._renderingManager.render(null,null,!0,!0),this.onAfterDrawPhaseObservable.notifyObservers(this);for(var He=0,We=this._afterCameraDrawStage;He<We.length;He++)We[He].action(this.activeCamera);if(this.postProcessManager&&!k._multiviewTexture){var Ze=k.outputRenderTarget?k.outputRenderTarget.getInternalTexture():void 0;this.postProcessManager._finalizeFrame(k.isIntermediate,Ze)}this._renderTargets.reset(),this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera)}},Y.prototype._processSubCameras=function(k){if(k.cameraRigMode===A.a.RIG_MODE_NONE||k.outputRenderTarget&&k.outputRenderTarget.getViewCount()>1&&this.getEngine().getCaps().multiview)return this._renderForCamera(k),void this.onAfterRenderCameraObservable.notifyObservers(k);if(k._useMultiviewToSingleView)this._renderMultiviewToSingleView(k);else for(var H=0;H<k._rigCameras.length;H++)this._renderForCamera(k._rigCameras[H],k);this._activeCamera=k,this.setTransformMatrix(this._activeCamera.getViewMatrix(),this._activeCamera.getProjectionMatrix()),this.onAfterRenderCameraObservable.notifyObservers(k)},Y.prototype._checkIntersections=function(){for(var k=0;k<this._meshesForIntersections.length;k++){var H=this._meshesForIntersections.data[k];if(H.actionManager)for(var Z=0;H.actionManager&&Z<H.actionManager.actions.length;Z++){var X=H.actionManager.actions[Z];if(X.trigger===I.a.ACTION_OnIntersectionEnterTrigger||X.trigger===I.a.ACTION_OnIntersectionExitTrigger){var q=X.getTriggerParameter(),he=q instanceof E.a?q:q.mesh,ge=he.intersectsMesh(H,q.usePreciseIntersection),me=H._intersectionsInProgress.indexOf(he);ge&&me===-1?X.trigger===I.a.ACTION_OnIntersectionEnterTrigger?(X._executeCurrent(T.a.CreateNew(H,void 0,he)),H._intersectionsInProgress.push(he)):X.trigger===I.a.ACTION_OnIntersectionExitTrigger&&H._intersectionsInProgress.push(he):!ge&&me>-1&&(X.trigger===I.a.ACTION_OnIntersectionExitTrigger&&X._executeCurrent(T.a.CreateNew(H,void 0,he)),H.actionManager.hasSpecificTrigger(I.a.ACTION_OnIntersectionExitTrigger,function(_e){var be=_e instanceof E.a?_e:_e.mesh;return he===be})&&X.trigger!==I.a.ACTION_OnIntersectionExitTrigger||H._intersectionsInProgress.splice(me,1))}}}},Y.prototype._advancePhysicsEngineStep=function(k){},Y.prototype._animate=function(){},Y.prototype.animate=function(){if(this._engine.isDeterministicLockStep()){var k=Math.max(Y.MinDeltaTime,Math.min(this._engine.getDeltaTime(),Y.MaxDeltaTime))+this._timeAccumulator,H=this._engine.getTimeStep(),Z=1e3/H/1e3,X=0,q=this._engine.getLockstepMaxSteps(),he=Math.floor(k/H);for(he=Math.min(he,q);k>0&&X<he;)this.onBeforeStepObservable.notifyObservers(this),this._animationRatio=H*Z,this._animate(),this.onAfterAnimationsObservable.notifyObservers(this),this.physicsEnabled&&this._advancePhysicsEngineStep(H
26),this.onAfterStepObservable.notifyObservers(this),this._currentStepId++,X++,k-=H;this._timeAccumulator=k<0?0:k}else k=this.useConstantAnimationDeltaTime?16:Math.max(Y.MinDeltaTime,Math.min(this._engine.getDeltaTime(),Y.MaxDeltaTime)),this._animationRatio=.06*k,this._animate(),this.onAfterAnimationsObservable.notifyObservers(this),this.physicsEnabled&&this._advancePhysicsEngineStep(k)},Y.prototype.render=function(k,H){if(k===void 0&&(k=!0),H===void 0&&(H=!1),!this.isDisposed){this.onReadyObservable.hasObservers()&&this._executeWhenReadyTimeoutId===-1&&this._checkIsReady(),this._frameId++,this._registerTransientComponents(),this._activeParticles.fetchNewFrame(),this._totalVertices.fetchNewFrame(),this._activeIndices.fetchNewFrame(),this._activeBones.fetchNewFrame(),this._meshesForIntersections.reset(),this.resetCachedMaterial(),this.onBeforeAnimationsObservable.notifyObservers(this),this.actionManager&&this.actionManager.processTrigger(I.a.ACTION_OnEveryFrameTrigger),H||this.animate();for(var Z=0,X=this._beforeCameraUpdateStage;Z<X.length;Z++)X[Z].action();if(k){if(this.activeCameras&&this.activeCameras.length>0)for(var q=0;q<this.activeCameras.length;q++){var he=this.activeCameras[q];if(he.update(),he.cameraRigMode!==A.a.RIG_MODE_NONE)for(var ge=0;ge<he._rigCameras.length;ge++)he._rigCameras[ge].update()}else if(this.activeCamera&&(this.activeCamera.update(),this.activeCamera.cameraRigMode!==A.a.RIG_MODE_NONE))for(ge=0;ge<this.activeCamera._rigCameras.length;ge++)this.activeCamera._rigCameras[ge].update()}this.onBeforeRenderObservable.notifyObservers(this),this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);var me=this.getEngine(),_e=this.activeCamera;if(this.renderTargetsEnabled){_.b.StartPerformanceCounter("Custom render targets",this.customRenderTargets.length>0),this._intermediateRendering=!0;for(var be=0;be<this.customRenderTargets.length;be++){var Ce=this.customRenderTargets[be];if(Ce._shouldRender()){if(this._renderId++,this.activeCamera=Ce.activeCamera||this.activeCamera,!this.activeCamera)throw new Error("Active camera not set");me.setViewport(this.activeCamera.viewport),this.updateTransformMatrix(),Ce.render(_e!==this.activeCamera,this.dumpNextRenderTargets)}}_.b.EndPerformanceCounter("Custom render targets",this.customRenderTargets.length>0),this._intermediateRendering=!1,this._renderId++}this.activeCamera=_e,this._activeCamera&&this._activeCamera.cameraRigMode!==A.a.RIG_MODE_CUSTOM&&!this.prePass&&this._bindFrameBuffer(),this.onAfterRenderTargetsRenderObservable.notifyObservers(this);for(var ye=0,Be=this._beforeClearStage;ye<Be.length;ye++)Be[ye].action();!this.autoClearDepthAndStencil&&!this.autoClear||this.prePass||this._engine.clear(this.clearColor,this.autoClear||this.forceWireframe||this.forcePointsCloud,this.autoClearDepthAndStencil,this.autoClearDepthAndStencil);for(var Ge=0,Xe=this._gatherRenderTargetsStage;Ge<Xe.length;Ge++)Xe[Ge].action(this._renderTargets);if(this.activeCameras&&this.activeCameras.length>0)for(q=0;q<this.activeCameras.length;q++)q>0&&this._engine.clear(null,!1,!0,!0),this._processSubCameras(this.activeCameras[q]);else{if(!this.activeCamera)throw new Error("No camera defined");this._processSubCameras(this.activeCamera)}this._checkIntersections();for(var He=0,We=this._afterRenderStage;He<We.length;He++)We[He].action();if(this.afterRender&&this.afterRender(),this.onAfterRenderObservable.notifyObservers(this),this._toBeDisposed.length){for(ge=0;ge<this._toBeDisposed.length;ge++){var Ze=this._toBeDisposed[ge];Ze&&Ze.dispose()}this._toBeDisposed=[]}this.dumpNextRenderTargets&&(this.dumpNextRenderTargets=!1),this._activeBones.addCount(0,!0),this._activeIndices.addCount(0,!0),this._activeParticles.addCount(0,!0)}},Y.prototype.freezeMaterials=function(){for(var k=0;k<this.materials.length;k++)this.materials[k].freeze()},Y.prototype.unfreezeMaterials=function(){for(var k=0;k<this.materials.length;k++)this.materials[k].unfreeze()},Y.prototype.dispose=function(){this.beforeRender=null,this.afterRender=null,j.a._LastCreatedScene===this&&(j.a._LastCreatedScene=null),this.skeletons=[],this.morphTargetManagers=[],this._transientComponents=[],this._isReadyForMeshStage.clear(),this._beforeEvaluateActiveMeshStage.clear(),this._evaluateSubMeshStage.clear(),this._preActiveMeshStage.clear(),this._cameraDrawRenderTargetStage.clear(),this._beforeCameraDrawStage.clear(),this._beforeRenderTargetDrawStage.clear(),this._beforeRenderingGroupDrawStage.clear(),this._beforeRenderingMeshStage.clear(),this._afterRenderingMeshStage.clear(),this._afterRenderingGroupDrawStage.clear(),this._afterCameraDrawStage.clear(),this._afterRenderTargetDrawStage.clear(),this._afterRenderStage.clear(),this._beforeCameraUpdateStage.clear(),this._beforeClearStage.clear(),this._gatherRenderTargetsStage.clear(),this._gatherActiveCameraRenderTargetsStage.clear(),this._pointerMoveStage.clear(),this._pointerDownStage.clear(),this._pointerUpStage.clear();for(var k=0,H=this._components;k<H.length;k++)H[k].dispose();this.importedMeshesFiles=new Array,this.stopAllAnimations&&this.stopAllAnimations(),this.resetCachedMaterial(),this.activeCamera&&(this.activeCamera._activeMeshes.dispose(),this.activeCamera=null),this._activeMeshes.dispose(),this._renderingManager.dispose(),this._processedMaterials.dispose(),this._activeParticleSystems.dispose(),this._activeSkeletons.dispose(),this._softwareSkinnedMeshes.dispose(),this._renderTargets.dispose(),this._registeredForLateAnimationBindings.dispose(),this._meshesForIntersections.dispose(),this._toBeDisposed=[];for(var Z=0,X=this._activeRequests;Z<X.length;Z++)X[Z].abort();var q;if(this.onDisposeObservable.notifyObservers(this),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.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.detachControl(),this._engine.getInputElement())for(q=0;q<this.cameras.length;q++)this.cameras[q].detachControl();for(;this.animationGroups.length;)this.animationGroups[0].dispose();for(;this.lights.length;)this.lights[0].dispose();for(;this.meshes.length;)this.meshes[0].dispose(!0);for(;this.transformNodes.length;)this.transformNodes[0].dispose(!0);for(;this.cameras.length;)this.cameras[0].dispose();for(this._defaultMaterial&&this._defaultMaterial.dispose();this.multiMaterials.length;)this.multiMaterials[0].dispose();for(;this.materials.length;)this.materials[0].dispose();for(;this.particleSystems.length;)this.particleSystems[0].dispose();for(;this.postProcesses.length;
26)this.postProcesses[0].dispose();for(;this.textures.length;)this.textures[0].dispose();this._sceneUbo.dispose(),this._multiviewSceneUbo&&this._multiviewSceneUbo.dispose(),this.postProcessManager.dispose(),(q=this._engine.scenes.indexOf(this))>-1&&this._engine.scenes.splice(q,1),this._engine.wipeCaches(!0),this._isDisposed=!0},Object.defineProperty(Y.prototype,"isDisposed",{get:function(){return this._isDisposed},enumerable:!1,configurable:!0}),Y.prototype.clearCachedVertexData=function(){for(var k=0;k<this.meshes.length;k++){var H=this.meshes[k].geometry;if(H)for(var Z in H._indices=[],H._vertexBuffers)H._vertexBuffers.hasOwnProperty(Z)&&(H._vertexBuffers[Z]._buffer._data=null)}},Y.prototype.cleanCachedTextureBuffer=function(){for(var k=0,H=this.textures;k<H.length;k++){var Z=H[k];Z._buffer&&(Z._buffer=null)}},Y.prototype.getWorldExtends=function(k){var H=new m.e(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),Z=new m.e(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);return k=k||function(){return!0},this.meshes.filter(k).forEach(function(X){if(X.computeWorldMatrix(!0),X.subMeshes&&X.subMeshes.length!==0&&!X.infiniteDistance){var q=X.getBoundingInfo(),he=q.boundingBox.minimumWorld,ge=q.boundingBox.maximumWorld;m.e.CheckExtends(he,H,Z),m.e.CheckExtends(ge,H,Z)}}),{min:H,max:Z}},Y.prototype.createPickingRay=function(k,H,Z,X,q){throw ne.a.WarnImport("Ray")},Y.prototype.createPickingRayToRef=function(k,H,Z,X,q,he){throw ne.a.WarnImport("Ray")},Y.prototype.createPickingRayInCameraSpace=function(k,H,Z){throw ne.a.WarnImport("Ray")},Y.prototype.createPickingRayInCameraSpaceToRef=function(k,H,Z,X){throw ne.a.WarnImport("Ray")},Y.prototype.pick=function(k,H,Z,X,q,he){var ge=new b.a;return ge._pickingUnavailable=!0,ge},Y.prototype.pickWithBoundingInfo=function(k,H,Z,X,q){var he=new b.a;return he._pickingUnavailable=!0,he},Y.prototype.pickWithRay=function(k,H,Z,X){throw ne.a.WarnImport("Ray")},Y.prototype.multiPick=function(k,H,Z,X,q){throw ne.a.WarnImport("Ray")},Y.prototype.multiPickWithRay=function(k,H,Z){throw ne.a.WarnImport("Ray")},Y.prototype.setPointerOverMesh=function(k,H){this._inputManager.setPointerOverMesh(k,H)},Y.prototype.getPointerOverMesh=function(){return this._inputManager.getPointerOverMesh()},Y.prototype._rebuildGeometries=function(){for(var k=0,H=this.geometries;k<H.length;k++)H[k]._rebuild();for(var Z=0,X=this.meshes;Z<X.length;Z++)X[Z]._rebuild();this.postProcessManager&&this.postProcessManager._rebuild();for(var q=0,he=this._components;q<he.length;q++)he[q].rebuild();for(var ge=0,me=this.particleSystems;ge<me.length;ge++)me[ge].rebuild()},Y.prototype._rebuildTextures=function(){for(var k=0,H=this.textures;k<H.length;k++)H[k]._rebuild();this.markAllMaterialsAsDirty(I.a.MATERIAL_TextureDirtyFlag)},Y.prototype._getByTags=function(k,H,Z){if(H===void 0)return k;var X=[];for(var q in Z=Z||function(ge){},k){var he=k[q];C.a&&C.a.MatchesQuery(he,H)&&(X.push(he),Z(he))}return X},Y.prototype.getMeshesByTags=function(k,H){return this._getByTags(this.meshes,k,H)},Y.prototype.getCamerasByTags=function(k,H){return this._getByTags(this.cameras,k,H)},Y.prototype.getLightsByTags=function(k,H){return this._getByTags(this.lights,k,H)},Y.prototype.getMaterialByTags=function(k,H){return this._getByTags(this.materials,k,H).concat(this._getByTags(this.multiMaterials,k,H))},Y.prototype.getTransformNodesByTags=function(k,H){return this._getByTags(this.transformNodes,k,H)},Y.prototype.setRenderingOrder=function(k,H,Z,X){H===void 0&&(H=null),Z===void 0&&(Z=null),X===void 0&&(X=null),this._renderingManager.setRenderingOrder(k,H,Z,X)},Y.prototype.setRenderingAutoClearDepthStencil=function(k,H,Z,X){Z===void 0&&(Z=!0),X===void 0&&(X=!0),this._renderingManager.setRenderingAutoClearDepthStencil(k,H,Z,X)},Y.prototype.getAutoClearDepthStencilSetup=function(k){return this._renderingManager.getAutoClearDepthStencilSetup(k)},Object.defineProperty(Y.prototype,"blockMaterialDirtyMechanism",{get:function(){return this._blockMaterialDirtyMechanism},set:function(k){this._blockMaterialDirtyMechanism!==k&&(this._blockMaterialDirtyMechanism=k,k||this.markAllMaterialsAsDirty(I.a.MATERIAL_AllDirtyFlag))}
26,enumerable:!1,configurable:!0}),Y.prototype.markAllMaterialsAsDirty=function(k,H){if(!this._blockMaterialDirtyMechanism)for(var Z=0,X=this.materials;Z<X.length;Z++){var q=X[Z];H&&!H(q)||q.markAsDirty(k)}},Y.prototype._loadFile=function(k,H,Z,X,q,he){var ge=this,me=Q.a.LoadFile(k,H,Z,X?this.offlineProvider:void 0,q,he);return this._activeRequests.push(me),me.onCompleteObservable.add(function(_e){ge._activeRequests.splice(ge._activeRequests.indexOf(_e),1)}),me},Y.prototype._loadFileAsync=function(k,H,Z,X){var q=this;return new Promise(function(he,ge){q._loadFile(k,function(me){he(me)},H,Z,X,function(me,_e){ge(_e)})})},Y.prototype._requestFile=function(k,H,Z,X,q,he,ge){var me=this,_e=Q.a.RequestFile(k,H,Z,X?this.offlineProvider:void 0,q,he,ge);return this._activeRequests.push(_e),_e.onCompleteObservable.add(function(be){me._activeRequests.splice(me._activeRequests.indexOf(be),1)}),_e},Y.prototype._requestFileAsync=function(k,H,Z,X,q){var he=this;return new Promise(function(ge,me){he._requestFile(k,function(_e){ge(_e)},H,Z,X,function(_e){me(_e)},q)})},Y.prototype._readFile=function(k,H,Z,X,q){var he=this,ge=Q.a.ReadFile(k,H,Z,X,q);return this._activeRequests.push(ge),ge.onCompleteObservable.add(function(me){he._activeRequests.splice(he._activeRequests.indexOf(me),1)}),ge},Y.prototype._readFileAsync=function(k,H,Z){var X=this;return new Promise(function(q,he){X._readFile(k,function(ge){q(ge)},H,Z,function(ge){he(ge)})})},Y.FOGMODE_NONE=0,Y.FOGMODE_EXP=1,Y.FOGMODE_EXP2=2,Y.FOGMODE_LINEAR=3,Y.MinDeltaTime=1,Y.MaxDeltaTime=1e3,Y}(S.a)},function(Ae,v,f){f.d(v,"a",function(){return B});var B=function(){function _(){}return _.WarnImport=function(x){return x+" needs to be imported before as it contains a side-effect required by your code."},_}()},function(Ae,v,f){f.d(v,"a",function(){return B});var B=function(){function _(){}return Object.defineProperty(_,"LastCreatedEngine",{get:function(){return this.Instances.length===0?null:this.Instances[this.Instances.length-1]},enumerable:!1,configurable:!0}),Object.defineProperty(_,"LastCreatedScene",{get:function(){return this._LastCreatedScene},enumerable:!1,configurable:!0}),_.Instances=new Array,_._LastCreatedScene=null,_.UseFallbackTexture=!0,_.FallbackTexture="",_}()},function(Ae,v,f){f.d(v,"c",function(){return B}),f.d(v,"a",function(){return u}),f.d(v,"b",function(){return x});var B,_=f(0);(function(M){M[M.LOCAL=0]="LOCAL",M[M.WORLD=1]="WORLD",M[M.BONE=2]="BONE"})(B||(B={}));var x,u=function(){function M(){}return M.X=new _.e(1,0,0),M.Y=new _.e(0,1,0),M.Z=new _.e(0,0,1),M}();(function(M){M[M.X=0]="X",M[M.Y=1]="Y",M[M.Z=2]="Z"})(x||(x={}))},function(Ae,v,f){f.d(v,"a",function(){return g});var B=f(1),_=f(3),x=f(33),u=f(12),M=f(6),R=f(0),C=f(29),m=f(8),c=f(11),E=f(21),A=f(58),S=f(90),g=function(l){function h(b,T,D,w){w===void 0&&(w=!0);var N=l.call(this,b,D)||this;return N._position=R.e.Zero(),N._upVector=R.e.Up(),N.orthoLeft=null,N.orthoRight=null,N.orthoBottom=null,N.orthoTop=null,N.fov=.8,N.minZ=1,N.maxZ=1e4,N.inertia=.9,N.mode=h.PERSPECTIVE_CAMERA,N.isIntermediate=!1,N.viewport=new A.a(0,0,1,1),N.layerMask=268435455,N.fovMode=h.FOVMODE_VERTICAL_FIXED,N.cameraRigMode=h.RIG_MODE_NONE,N.customRenderTargets=new Array,N.outputRenderTarget=null,N.onViewMatrixChangedObservable=new M.c,N.onProjectionMatrixChangedObservable=new M.c,N.onAfterCheckInputsObservable=new M.c,N.onRestoreStateObservable=new M.c,N.isRigCamera=!1,N._rigCameras=new Array,N._webvrViewMatrix=R.a.Identity(),N._skipRendering=!1,N._projectionMatrix=new R.a,N._postProcesses=new Array,N._activeMeshes=new x.a(256),N._globalPosition=R.e.Zero(),N._computedViewMatrix=R.a.Identity(),N._doNotComputeProjectionMatrix=!1,N._transformMatrix=R.a.Zero(),N._refreshFrustumPlanes=!0,N._isCamera=!0,N._isLeftCamera=!1,N._isRightCamera=!1,N.getScene().addCamera(N),w&&!N.getScene().activeCamera&&(N.getScene().activeCamera=N),N.position=T,N}return Object(B.d)(h,l),Object.defineProperty(h.prototype,"position",{get:function(){return this._position},set:function(b){this._position=b},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"upVector",{get:function(){return this._upVector},set:function(b){this._upVector=b}
26,enumerable:!1,configurable:!0}),h.prototype.storeState=function(){return this._stateStored=!0,this._storedFov=this.fov,this},h.prototype._restoreStateValues=function(){return!!this._stateStored&&(this.fov=this._storedFov,!0)},h.prototype.restoreState=function(){return!!this._restoreStateValues()&&(this.onRestoreStateObservable.notifyObservers(this),!0)},h.prototype.getClassName=function(){return"Camera"},h.prototype.toString=function(b){var T="Name: "+this.name;if(T+=", type: "+this.getClassName(),this.animations)for(var D=0;D<this.animations.length;D++)T+=", animation[0]: "+this.animations[D].toString(b);return T},Object.defineProperty(h.prototype,"globalPosition",{get:function(){return this._globalPosition},enumerable:!1,configurable:!0}),h.prototype.getActiveMeshes=function(){return this._activeMeshes},h.prototype.isActiveMesh=function(b){return this._activeMeshes.indexOf(b)!==-1},h.prototype.isReady=function(b){if(b===void 0&&(b=!1),b)for(var T=0,D=this._postProcesses;T<D.length;T++){var w=D[T];if(w&&!w.isReady())return!1}return l.prototype.isReady.call(this,b)},h.prototype._initCache=function(){l.prototype._initCache.call(this),this._cache.position=new R.e(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.upVector=new R.e(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.mode=void 0,this._cache.minZ=void 0,this._cache.maxZ=void 0,this._cache.fov=void 0,this._cache.fovMode=void 0,this._cache.aspectRatio=void 0,this._cache.orthoLeft=void 0,this._cache.orthoRight=void 0,this._cache.orthoBottom=void 0,this._cache.orthoTop=void 0,this._cache.renderWidth=void 0,this._cache.renderHeight=void 0},h.prototype._updateCache=function(b){b||l.prototype._updateCache.call(this),this._cache.position.copyFrom(this.position),this._cache.upVector.copyFrom(this.upVector)},h.prototype._isSynchronized=function(){return this._isSynchronizedViewMatrix()&&this._isSynchronizedProjectionMatrix()},h.prototype._isSynchronizedViewMatrix=function(){return!!l.prototype._isSynchronized.call(this)&&this._cache.position.equals(this.position)&&this._cache.upVector.equals(this.upVector)&&this.isSynchronizedWithParent()},h.prototype._isSynchronizedProjectionMatrix=function(){var b=this._cache.mode===this.mode&&this._cache.minZ===this.minZ&&this._cache.maxZ===this.maxZ;if(!b)return!1;var T=this.getEngine();return b=this.mode===h.PERSPECTIVE_CAMERA?this._cache.fov===this.fov&&this._cache.fovMode===this.fovMode&&this._cache.aspectRatio===T.getAspectRatio(this):this._cache.orthoLeft===this.orthoLeft&&this._cache.orthoRight===this.orthoRight&&this._cache.orthoBottom===this.orthoBottom&&this._cache.orthoTop===this.orthoTop&&this._cache.renderWidth===T.getRenderWidth()&&this._cache.renderHeight===T.getRenderHeight()},h.prototype.attachControl=function(b,T){},h.prototype.detachControl=function(b){},h.prototype.update=function(){this._checkInputs(),this.cameraRigMode!==h.RIG_MODE_NONE&&this._updateRigCameras()},h.prototype._checkInputs=function(){this.onAfterCheckInputsObservable.notifyObservers(this)},Object.defineProperty(h.prototype,"rigCameras",{get:function(){return this._rigCameras},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"rigPostProcess",{get:function(){return this._rigPostProcess},enumerable:!1,configurable:!0}),h.prototype._getFirstPostProcess=function(){for(var b=0;b<this._postProcesses.length;b++)if(this._postProcesses[b]!==null)return this._postProcesses[b];return null},h.prototype._cascadePostProcessesToRigCams=function(){var b=this._getFirstPostProcess();b&&b.markTextureDirty();for(var T=0,D=this._rigCameras.length;T<D;T++){var w=this._rigCameras[T],N=w._rigPostProcess;N?(N.getEffectName()==="pass"&&(w.isIntermediate=this._postProcesses.length===0),w._postProcesses=this._postProcesses.slice(0).concat(N),N.markTextureDirty()):w._postProcesses=this._postProcesses.slice(0)}},h.prototype.attachPostProcess=function(b,T){return T===void 0&&(T=null),!b.isReusable()&&this._postProcesses.indexOf(b)>-1?(m.a.Error("You're trying to reuse a post process not defined as reusable."),0):(T==null||T<0?this._postProcesses.push(b):this._postProcesses[T]===null?this._postProcesses[T]=b:this._postProcesses.splice(T,0,b),this._cascadePostProcessesToRigCams(),this._scene.prePassRenderer&&this._scene.prePassRenderer.markAsDirty(),this._postProcesses.indexOf(b))},h.prototype.detachPostProcess=function(b){var T=this._postProcesses.indexOf(b);T!==-1&&(this._postProcesses[T]=null),this._scene.prePassRenderer&&this._scene.prePassRenderer.markAsDirty(),this._cascadePostProcessesToRigCams()},h.prototype.getWorldMatrix=function(){return this._isSynchronizedViewMatrix()||this.getViewMatrix(),this._worldMatrix},h.prototype._getViewMatrix=function(){return R.a.Identity()},h.prototype.getViewMatrix=function(b){return!b&&this._isSynchronizedViewMatrix()||(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},h.prototype.freezeProjectionMatrix=function(b){this._doNotComputeProjectionMatrix=!0,b!==void 0&&(this._projectionMatrix=b)},h.prototype.unfreezeProjectionMatrix=function(){this._doNotComputeProjectionMatrix=!1},h.prototype.getProjectionMatrix=function(b){var T,D,w,N,I,V,W,j;if(this._doNotComputeProjectionMatrix||!b&&this._isSynchronizedProjectionMatrix())return this._projectionMatrix;this._cache.mode=this.mode,this._cache.minZ=this.minZ,this._cache.maxZ=this.maxZ,this._refreshFrustumPlanes=!0;var ne=this.getEngine(),te=this.getScene();if(this.mode===h.PERSPECTIVE_CAMERA){this._cache.fov=this.fov,this._cache.fovMode=this.fovMode,this._cache.aspectRatio=ne.getAspectRatio(this),this.minZ<=0&&(this.minZ=.1);var de=ne.useReverseDepthBuffer;(te.useRightHandedSystem?de?R.a.PerspectiveFovReverseRHToRef:R.a.PerspectiveFovRHToRef:de?R.a.PerspectiveFovReverseLHToRef:R.a.PerspectiveFovLHToRef)(this.fov,ne.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===h.FOVMODE_VERTICAL_FIXED)}else{var pe=ne.getRenderWidth()/2,ae=ne.getRenderHeight()/2;te.useRightHandedSystem?R.a.OrthoOffCenterRHToRef((T=this.orthoLeft)!==null&&T!==void 0?T:-pe,(D=this.orthoRight)!==null&&D!==void 0?D:pe,(w=this.orthoBottom)!==null&&w!==void 0?w:-ae,(N=this.orthoTop)!==null&&N!==void 0?N:ae,this.minZ,this.maxZ,this._projectionMatrix):R.a.OrthoOffCenterLHToRef((I=this.orthoLeft)!==null&&I!==void 0?I:-pe,(V=this.orthoRight)!==null&&V!==void 0?V:pe,(W=this.orthoBottom)!==null&&W!==void 0?W:-ae,(j=this.orthoTop)!==null&&j!==void 0?j:ae,this.minZ,this.maxZ,this._projectionMatrix),this._cache.orthoLeft=this.orthoLeft,this._cache.orthoRight=this.orthoRight,this._cache.orthoBottom=this.orthoBottom,this._cache.orthoTop=this.orthoTop,this._cache.renderWidth=ne.getRenderWidth(),this._cache.renderHeight=ne.getRenderHeight()}return this.onProjectionMatrixChangedObservable.notifyObservers(this),this._projectionMatrix},h.prototype.getTransformationMatrix=function(){return this._computedViewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._transformMatrix},h.prototype._updateFrustumPlanes=function(){this._refreshFrustumPlanes&&(this.getTransformationMatrix(),this._frustumPlanes?S.a.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=S.a.GetPlanes(this._transformMatrix),this._refreshFrustumPlanes=!1)},h.prototype.isInFrustum=function(b,T){if(T===void 0&&(T=!1),this._updateFrustumPlanes(),T&&this.rigCameras.length>0){var D=!1;
26return this.rigCameras.forEach(function(w){w._updateFrustumPlanes(),D=D||b.isInFrustum(w._frustumPlanes)}),D}return b.isInFrustum(this._frustumPlanes)},h.prototype.isCompletelyInFrustum=function(b){return this._updateFrustumPlanes(),b.isCompletelyInFrustum(this._frustumPlanes)},h.prototype.getForwardRay=function(b,T,D){throw E.a.WarnImport("Ray")},h.prototype.getForwardRayToRef=function(b,T,D,w){throw E.a.WarnImport("Ray")},h.prototype.dispose=function(b,T){for(T===void 0&&(T=!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 D=this._rigCameras.pop();D&&D.dispose()}if(this._rigPostProcess)this._rigPostProcess.dispose(this),this._rigPostProcess=null,this._postProcesses=[];else if(this.cameraRigMode!==h.RIG_MODE_NONE)this._rigPostProcess=null,this._postProcesses=[];else for(var w=this._postProcesses.length;--w>=0;){var N=this._postProcesses[w];N&&N.dispose(this)}for(w=this.customRenderTargets.length;--w>=0;)this.customRenderTargets[w].dispose();this.customRenderTargets=[],this._activeMeshes.dispose(),l.prototype.dispose.call(this,b,T)},Object.defineProperty(h.prototype,"isLeftCamera",{get:function(){return this._isLeftCamera},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"isRightCamera",{get:function(){return this._isRightCamera},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"leftCamera",{get:function(){return this._rigCameras.length<1?null:this._rigCameras[0]},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"rightCamera",{get:function(){return this._rigCameras.length<2?null:this._rigCameras[1]},enumerable:!1,configurable:!0}),h.prototype.getLeftTarget=function(){return this._rigCameras.length<1?null:this._rigCameras[0].getTarget()},h.prototype.getRightTarget=function(){return this._rigCameras.length<2?null:this._rigCameras[1].getTarget()},h.prototype.setCameraRigMode=function(b,T){if(this.cameraRigMode!==b){for(;this._rigCameras.length>0;){var D=this._rigCameras.pop();D&&D.dispose()}if(this.cameraRigMode=b,this._cameraRigParams={},this._cameraRigParams.interaxialDistance=T.interaxialDistance||.0637,this._cameraRigParams.stereoHalfAngle=u.b.ToRadians(this._cameraRigParams.interaxialDistance/.0637),this.cameraRigMode!==h.RIG_MODE_NONE){var w=this.createRigCamera(this.name+"_L",0);w&&(w._isLeftCamera=!0);var N=this.createRigCamera(this.name+"_R",1);N&&(N._isRightCamera=!0),w&&N&&(this._rigCameras.push(w),this._rigCameras.push(N))}switch(this.cameraRigMode){case h.RIG_MODE_STEREOSCOPIC_ANAGLYPH:h._setStereoscopicAnaglyphRigMode(this);break;case h.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case h.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case h.RIG_MODE_STEREOSCOPIC_OVERUNDER:case h.RIG_MODE_STEREOSCOPIC_INTERLACED:h._setStereoscopicRigMode(this);break;case h.RIG_MODE_VR:h._setVRRigMode(this,T);break;case h.RIG_MODE_WEBVR:h._setWebVRRigMode(this,T)}this._cascadePostProcessesToRigCams(),this.update()}},h._setStereoscopicRigMode=function(b){throw"Import Cameras/RigModes/stereoscopicRigMode before using stereoscopic rig mode"},h._setStereoscopicAnaglyphRigMode=function(b){throw"Import Cameras/RigModes/stereoscopicAnaglyphRigMode before using stereoscopic anaglyph rig mode"},h._setVRRigMode=function(b,T){throw"Import Cameras/RigModes/vrRigMode before using VR rig mode"},h._setWebVRRigMode=function(b,T){throw"Import Cameras/RigModes/WebVRRigMode before using Web VR rig mode"},h.prototype._getVRProjectionMatrix=function(){return R.a.PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov,this._cameraRigParams.vrMetrics.aspectRatio,this.minZ,this.maxZ,this._cameraRigParams.vrWorkMatrix),this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix,this._projectionMatrix),this._projectionMatrix},h.prototype._updateCameraRotationMatrix=function(){},h.prototype._updateWebVRCameraRotationMatrix=function(){},h.prototype._getWebVRProjectionMatrix=function(){return R.a.Identity()},h.prototype._getWebVRViewMatrix=function(){return R.a.Identity()},h.prototype.setCameraRigParameter=function(b,T){this._cameraRigParams||(this._cameraRigParams={}),this._cameraRigParams[b]=T,b==="interaxialDistance"&&(this._cameraRigParams.stereoHalfAngle=u.b.ToRadians(T/.0637))},h.prototype.createRigCamera=function(b,T){return null},h.prototype._updateRigCameras=function(){for(var b=0;b<this._rigCameras.length;b++)this._rigCameras[b].minZ=this.minZ,this._rigCameras[b].maxZ=this.maxZ,this._rigCameras[b].fov=this.fov,this._rigCameras[b].upVector.copyFrom(this.upVector);this.cameraRigMode===h.RIG_MODE_STEREOSCOPIC_ANAGLYPH&&(this._rigCameras[0].viewport=this._rigCameras[1].viewport=this.viewport)},h.prototype._setupInputs=function(){},h.prototype.serialize=function(){var b=_.a.Serialize(this);return b.type=this.getClassName(),this.parent&&(b.parentId=this.parent.id),this.inputs&&this.inputs.serialize(b),_.a.AppendSerializedAnimations(this,b),b.ranges=this.serializeAnimationRanges(),b},h.prototype.clone=function(b){return _.a.Clone(h.GetConstructorFromName(this.getClassName(),b,this.get
26Scene(),this.interaxialDistance,this.isStereoscopicSideBySide),this)},h.prototype.getDirection=function(b){var T=R.e.Zero();return this.getDirectionToRef(b,T),T},Object.defineProperty(h.prototype,"absoluteRotation",{get:function(){var b=R.b.Zero();return this.getWorldMatrix().decompose(void 0,b),b},enumerable:!1,configurable:!0}),h.prototype.getDirectionToRef=function(b,T){R.e.TransformNormalToRef(b,this.getWorldMatrix(),T)},h.GetConstructorFromName=function(b,T,D,w,N){w===void 0&&(w=0),N===void 0&&(N=!0);var I=C.a.Construct(b,T,D,{interaxial_distance:w,isStereoscopicSideBySide:N});return I||function(){return h._createDefaultParsedCamera(T,D)}},h.prototype.computeWorldMatrix=function(){return this.getWorldMatrix()},h.Parse=function(b,T){var D=b.type,w=h.GetConstructorFromName(D,b.name,T,b.interaxial_distance,b.isStereoscopicSideBySide),N=_.a.Parse(w,b,T);if(b.parentId&&(N._waitingParentId=b.parentId),N.inputs&&(N.inputs.parse(b),N._setupInputs()),b.upVector&&(N.upVector=R.e.FromArray(b.upVector)),N.setPosition&&(N.position.copyFromFloats(0,0,0),N.setPosition(R.e.FromArray(b.position))),b.target&&N.setTarget&&N.setTarget(R.e.FromArray(b.target)),b.cameraRigMode){var I=b.interaxial_distance?{interaxialDistance:b.interaxial_distance}:{};N.setCameraRigMode(b.cameraRigMode,I)}if(b.animations){for(var V=0;V<b.animations.length;V++){var W=b.animations[V],j=c.a.GetClass("BABYLON.Animation");j&&N.animations.push(j.Parse(W))}C.a.ParseAnimationRanges(N,b,T)}return b.autoAnimate&&T.beginAnimation(N,b.autoAnimateFrom,b.autoAnimateTo,b.autoAnimateLoop,b.autoAnimateSpeed||1),N},h._createDefaultParsedCamera=function(b,T){throw E.a.WarnImport("UniversalCamera")},h.PERSPECTIVE_CAMERA=0,h.ORTHOGRAPHIC_CAMERA=1,h.FOVMODE_VERTICAL_FIXED=0,h.FOVMODE_HORIZONTAL_FIXED=1,h.RIG_MODE_NONE=0,h.RIG_MODE_STEREOSCOPIC_ANAGLYPH=10,h.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL=11,h.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED=12,h.RIG_MODE_STEREOSCOPIC_OVERUNDER=13,h.RIG_MODE_STEREOSCOPIC_INTERLACED=14,h.RIG_MODE_VR=20,h.RIG_MODE_WEBVR=21,h.RIG_MODE_CUSTOM=22,h.ForceAttachControlToAlwaysPreventDefault=!1,Object(B.c)([Object(_.o)("position")],h.prototype,"_position",void 0),Object(B.c)([Object(_.o)("upVector")],h.prototype,"_upVector",void 0),Object(B.c)([Object(_.c)()],h.prototype,"orthoLeft",void 0),Object(B.c)([Object(_.c)()],h.prototype,"orthoRight",void 0),Object(B.c)([Object(_.c)()],h.prototype,"orthoBottom",void 0),Object(B.c)([Object(_.c)()],h.prototype,"orthoTop",void 0),Object(B.c)([Object(_.c)()],h.prototype,"fov",void 0),Object(B.c)([Object(_.c)()],h.prototype,"minZ",void 0),Object(B.c)([Object(_.c)()],h.prototype,"maxZ",void 0),Object(B.c)([Object(_.c)()],h.prototype,"inertia",void 0),Object(B.c)([Object(_.c)()],h.prototype,"mode",void 0),Object(B.c)([Object(_.c)()],h.prototype,"layerMask",void 0),Object(B.c)([Object(_.c)()],h.prototype,"fovMode",void 0),Object(B.c)([Object(_.c)()],h.prototype,"cameraRigMode",void 0),Object(B.c)([Object(_.c)()],h.prototype,"interaxialDistance",void 0),Object(B.c)([Object(_.c)()],h.prototype,"isStereoscopicSideBySide",void 0),h}(C.a)},function(Ae,v,f){f.d(v,"a",function(){return A});var B=f(1),_=f(3),x=f(12),u=f(6),M=f(22),R=f(61),C=f(85),m=f(2),c=f(8),E=f(64),A=function(){function S(g,l,h){this.shadowDepthWrapper=null,this.allowShaderHotSwapping=!0,this.metadata=null,this.reservedDataStore=null,this.checkReadyOnEveryCall=!1,this.checkReadyOnlyOnce=!1,this.state="",this._alpha=1,this._backFaceCulling=!0,this.onCompiled=null,this.onError=null,this.getRenderTargetTextures=null,this.doNotSerialize=!1,this._storeEffectOnSubMeshes=!1,this.animations=null,this.onDisposeObservable=new u.c,this._onDisposeObserver=null,this._onUnBindObservable=null,this._onBindObserver=null,this._alphaMode=m.a.ALPHA_COMBINE,this._needDepthPrePass=!1,this.disableDepthWrite=!1,this.disableColorWrite=!1,this.forceDepthWrite=!1,this.depthFunction=0,this.separateCullingPass=!1,this._fogEnabled=!0,this.pointSize=1,this.zOffset=0,this._effect=null,this._useUBO=!1,this._fillMode=S.TriangleFillMode,this._cachedDepthWriteState=!1,this._cachedColorWriteState=!1,this._cachedDepthFunctionState=0,this._indexInSceneMaterialArray=-1,this.meshMap=null,this._forceAlphaTest=!1,this._transparencyMode=null,this.name=g;var b=1;for(this._scene=l||M.a.LastCreatedScene,this.id=g||x.b.RandomId();this._scene.getMaterialByID(this.id);)this.id=g+" "+b++;this.uniqueId=this._scene.getUniqueId(),this._scene.useRightHandedSystem?this.sideOrientation=S.ClockWiseSideOrientation:this.sideOrientation=S.CounterClockWiseSideOrientation,this._uniformBuffer=new C.a(this._scene.getEngine()),this._useUBO=this.getScene().getEngine().supportsUniformBuffers,h||this._scene.addMaterial(this),this._scene.useMaterialMeshMap&&(this.meshMap={})}return Object.defineProperty(S.prototype,"canRenderToMRT",{get:function(){return!1}
26,enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"alpha",{get:function(){return this._alpha},set:function(g){this._alpha!==g&&(this._alpha=g,this.markAsDirty(S.MiscDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"backFaceCulling",{get:function(){return this._backFaceCulling},set:function(g){this._backFaceCulling!==g&&(this._backFaceCulling=g,this.markAsDirty(S.TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"hasRenderTargetTextures",{get:function(){return!1},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"onDispose",{set:function(g){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(g)},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"onBindObservable",{get:function(){return this._onBindObservable||(this._onBindObservable=new u.c),this._onBindObservable},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"onBind",{set:function(g){this._onBindObserver&&this.onBindObservable.remove(this._onBindObserver),this._onBindObserver=this.onBindObservable.add(g)},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"onUnBindObservable",{get:function(){return this._onUnBindObservable||(this._onUnBindObservable=new u.c),this._onUnBindObservable},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"onEffectCreatedObservable",{get:function(){return this._onEffectCreatedObservable||(this._onEffectCreatedObservable=new u.c),this._onEffectCreatedObservable},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"alphaMode",{get:function(){return this._alphaMode},set:function(g){this._alphaMode!==g&&(this._alphaMode=g,this.markAsDirty(S.TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"needDepthPrePass",{get:function(){return this._needDepthPrePass},set:function(g){this._needDepthPrePass!==g&&(this._needDepthPrePass=g,this._needDepthPrePass&&(this.checkReadyOnEveryCall=!0))},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"fogEnabled",{get:function(){return this._fogEnabled},set:function(g){this._fogEnabled!==g&&(this._fogEnabled=g,this.markAsDirty(S.MiscDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"wireframe",{get:function(){switch(this._fillMode){case S.WireFrameFillMode:case S.LineListDrawMode:case S.LineLoopDrawMode:case S.LineStripDrawMode:return!0}return this._scene.forceWireframe},set:function(g){this.fillMode=g?S.WireFrameFillMode:S.TriangleFillMode},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"pointsCloud",{get:function(){switch(this._fillMode){case S.PointFillMode:case S.PointListDrawMode:return!0}return this._scene.forcePointsCloud},set:function(g){this.fillMode=g?S.PointFillMode:S.TriangleFillMode},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"fillMode",{get:function(){return this._fillMode},set:function(g){this._fillMode!==g&&(this._fillMode=g,this.markAsDirty(S.MiscDirtyFlag))},enumerable:!1,configurable:!0}),S.prototype.toString=function(g){return"Name: "+this.name},S.prototype.getClassName=function(){return"Material"},Object.defineProperty(S.prototype,"isFrozen",{get:function(){return this.checkReadyOnlyOnce},enumerable:!1,configurable:!0}),S.prototype.freeze=function(){this.markDirty(),this.checkReadyOnlyOnce=!0},S.prototype.unfreeze=function(){this.markDirty(),this.checkReadyOnlyOnce=!1},S.prototype.isReady=function(g,l){return!0},S.prototype.isReadyForSubMesh=function(g,l,h){return!1},S.prototype.getEffect=function(){return this._effect},S.prototype.getScene=function(){return this._scene},Object.defineProperty(S.prototype,"transparencyMode",{get:function(){return this._transparencyMode},set:function(g){this._transparencyMode!==g&&(this._transparencyMode=g,this._forceAlphaTest=g===S.MATERIAL_ALPHATESTANDBLEND,this._markAllSubMeshesAsTexturesAndMiscDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"_disableAlphaBlending",{get:function(){return this._transparencyMode===S.MATERIAL_OPAQUE||this._transparencyMode===S.MATERIAL_ALPHATEST}
26,enumerable:!1,configurable:!0}),S.prototype.needAlphaBlending=function(){return!this._disableAlphaBlending&&this.alpha<1},S.prototype.needAlphaBlendingForMesh=function(g){return!(this._disableAlphaBlending&&g.visibility>=1)&&(this.needAlphaBlending()||g.visibility<1||g.hasVertexAlpha)},S.prototype.needAlphaTesting=function(){return!!this._forceAlphaTest},S.prototype._shouldTurnAlphaTestOn=function(g){return!this.needAlphaBlendingForMesh(g)&&this.needAlphaTesting()},S.prototype.getAlphaTestTexture=function(){return null},S.prototype.markDirty=function(){for(var g=0,l=this.getScene().meshes;g<l.length;g++){var h=l[g];if(h.subMeshes)for(var b=0,T=h.subMeshes;b<T.length;b++){var D=T[b];D.getMaterial()===this&&D.effect&&(D.effect._wasPreviouslyReady=!1)}}},S.prototype._preBind=function(g,l){l===void 0&&(l=null);var h=this._scene.getEngine(),b=(l??this.sideOrientation)===S.ClockWiseSideOrientation;return h.enableEffect(g||this._effect),h.setState(this.backFaceCulling,this.zOffset,!1,b),b},S.prototype.bind=function(g,l){},S.prototype.bindForSubMesh=function(g,l,h){},S.prototype.bindOnlyWorldMatrix=function(g){},S.prototype.bindSceneUniformBuffer=function(g,l){l.bindToEffect(g,"Scene")},S.prototype.bindView=function(g){this._useUBO?this.bindSceneUniformBuffer(g,this.getScene().getSceneUniformBuffer()):g.setMatrix("view",this.getScene().getViewMatrix())},S.prototype.bindViewProjection=function(g){this._useUBO?this.bindSceneUniformBuffer(g,this.getScene().getSceneUniformBuffer()):g.setMatrix("viewProjection",this.getScene().getTransformMatrix())},S.prototype._afterBind=function(g){if(this._scene._cachedMaterial=this,this._scene._cachedVisibility=g?g.visibility:1,this._onBindObservable&&g&&this._onBindObservable.notifyObservers(g),this.disableDepthWrite){var l=this._scene.getEngine();this._cachedDepthWriteState=l.getDepthWrite(),l.setDepthWrite(!1)}this.disableColorWrite&&(l=this._scene.getEngine(),this._cachedColorWriteState=l.getColorWrite(),l.setColorWrite(!1)),this.depthFunction!==0&&(l=this._scene.getEngine(),this._cachedDepthFunctionState=l.getDepthFunction()||0,l.setDepthFunction(this.depthFunction))},S.prototype.unbind=function(){this._onUnBindObservable&&this._onUnBindObservable.notifyObservers(this),this.depthFunction!==0&&this._scene.getEngine().setDepthFunction(this._cachedDepthFunctionState),this.disableDepthWrite&&this._scene.getEngine().setDepthWrite(this._cachedDepthWriteState),this.disableColorWrite&&this._scene.getEngine().setColorWrite(this._cachedColorWriteState)},S.prototype.getActiveTextures=function(){return[]},S.prototype.hasTexture=function(g){return!1},S.prototype.clone=function(g){return null},S.prototype.getBindedMeshes=function(){var g=this;if(this.meshMap){var l=new Array;for(var h in this.meshMap){var b=this.meshMap[h];b&&l.push(b)}return l}return this._scene.meshes.filter(function(T){return T.material===g})},S.prototype.forceCompilation=function(g,l,h,b){var T=this,D=Object(B.a)({clipPlane:!1,useInstances:!1},h),w=this.getScene(),N=this.allowShaderHotSwapping;this.allowShaderHotSwapping=!1;var I=function(){if(T._scene&&T._scene.getEngine()){var V=w.clipPlane;if(D.clipPlane&&(w.clipPlane=new E.a(0,0,0,1)),T._storeEffectOnSubMeshes){var W=!0,j=null;if(g.subMeshes){var ne=new R.a(0,0,0,0,0,g,void 0,!1,!1);ne._materialDefines&&(ne._materialDefines._renderId=-1),T.isReadyForSubMesh(g,ne,D.useInstances)||(ne.effect&&ne.effect.getCompilationError()&&ne.effect.allFallbacksProcessed()?j=ne.effect.getCompilationError():(W=!1,setTimeout(I,16)))}W&&(T.allowShaderHotSwapping=N,j&&b&&b(j),l&&l(T))}else T.isReady()?(T.allowShaderHotSwapping=N,l&&l(T)):setTimeout(I,16);D.clipPlane&&(w.clipPlane=V)}};I()},S.prototype.forceCompilationAsync=function(g,l){var h=this;return new Promise(function(b,T){h.forceCompilation(g,function(){b()},l,function(D){T(D)})})},S.prototype.markAsDirty=function(g){this.getScene().blockMaterialDirtyMechanism||(S._DirtyCallbackArray.length=0,g&S.TextureDirtyFlag&&S._DirtyCallbackArray.push(S._TextureDirtyCallBack),g&S.LightDirtyFlag&&S._DirtyCallbackArray.push(S._LightsDirtyCallBack),g&S.FresnelDirtyFlag&&S._DirtyCallbackArray.push(S._FresnelDirtyCallBack),g&S.AttributesDirtyFlag&&S._DirtyCallbackArray.push(S._AttributeDirtyCallBack),g&S.MiscDirtyFlag&&S._DirtyCallbackArray.push(S._MiscDirtyCallBack),g&S.PrePassDirtyFlag&&S._DirtyCallbackArray.push(S._PrePassDirtyCallBack),S._DirtyCallbackArray.length&&this._markAllSubMeshesAsDirty(S._RunDirtyCallBacks),this.get
26Scene().resetCachedMaterial())},S.prototype._markAllSubMeshesAsDirty=function(g){if(!this.getScene().blockMaterialDirtyMechanism)for(var l=0,h=this.getScene().meshes;l<h.length;l++){var b=h[l];if(b.subMeshes)for(var T=0,D=b.subMeshes;T<D.length;T++){var w=D[T];w.getMaterial()===this&&w._materialDefines&&g(w._materialDefines)}}},S.prototype._markScenePrePassDirty=function(){if(!this.getScene().blockMaterialDirtyMechanism){var g=this.getScene().enablePrePassRenderer();g&&g.markAsDirty()}},S.prototype._markAllSubMeshesAsAllDirty=function(){this._markAllSubMeshesAsDirty(S._AllDirtyCallBack)},S.prototype._markAllSubMeshesAsImageProcessingDirty=function(){this._markAllSubMeshesAsDirty(S._ImageProcessingDirtyCallBack)},S.prototype._markAllSubMeshesAsTexturesDirty=function(){this._markAllSubMeshesAsDirty(S._TextureDirtyCallBack)},S.prototype._markAllSubMeshesAsFresnelDirty=function(){this._markAllSubMeshesAsDirty(S._FresnelDirtyCallBack)},S.prototype._markAllSubMeshesAsFresnelAndMiscDirty=function(){this._markAllSubMeshesAsDirty(S._FresnelAndMiscDirtyCallBack)},S.prototype._markAllSubMeshesAsLightsDirty=function(){this._markAllSubMeshesAsDirty(S._LightsDirtyCallBack)},S.prototype._markAllSubMeshesAsAttributesDirty=function(){this._markAllSubMeshesAsDirty(S._AttributeDirtyCallBack)},S.prototype._markAllSubMeshesAsMiscDirty=function(){this._markAllSubMeshesAsDirty(S._MiscDirtyCallBack)},S.prototype._markAllSubMeshesAsPrePassDirty=function(){this._markAllSubMeshesAsDirty(S._MiscDirtyCallBack)},S.prototype._markAllSubMeshesAsTexturesAndMiscDirty=function(){this._markAllSubMeshesAsDirty(S._TextureAndMiscDirtyCallBack)},S.prototype.setPrePassRenderer=function(g){return!1},S.prototype.dispose=function(g,l,h){var b=this.getScene();if(b.stopAnimation(this),b.freeProcessedMaterials(),b.removeMaterial(this),h!==!0)if(this.meshMap)for(var T in this.meshMap)(N=this.meshMap[T])&&(N.material=null,this.releaseVertexArrayObject(N,g));else for(var D=0,w=b.meshes;D<w.length;D++){var N;(N=w[D]).material!==this||N.sourceMesh||(N.material=null,this.releaseVertexArrayObject(N,g))}this._uniformBuffer.dispose(),g&&this._effect&&(this._storeEffectOnSubMeshes||this._effect.dispose(),this._effect=null),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this._onBindObservable&&this._onBindObservable.clear(),this._onUnBindObservable&&this._onUnBindObservable.clear(),this._onEffectCreatedObservable&&this._onEffectCreatedObservable.clear()},S.prototype.releaseVertexArrayObject=function(g,l){if(g.geometry){var h=g.geometry;if(this._storeEffectOnSubMeshes)for(var b=0,T=g.subMeshes;b<T.length;b++){var D=T[b];h._releaseVertexArrayObject(D._materialEffect),l&&D._materialEffect&&D._materialEffect.dispose()}else h._releaseVertexArrayObject(this._effect)}},S.prototype.serialize=function(){return _.a.Serialize(this)},S.Parse=function(g,l,h){if(g.customType){if(g.customType==="BABYLON.PBRMaterial"&&g.overloadedAlbedo&&(g.customType="BABYLON.LegacyPBRMaterial",!BABYLON.LegacyPBRMaterial))return c.a.Error("Your scene is trying to load a legacy version of the PBRMaterial, please, include it from the materials library."),null}else g.customType="BABYLON.StandardMaterial";return x.b.Instantiate(g.customType).Parse(g,l,h)},S.TriangleFillMode=m.a.MATERIAL_TriangleFillMode,S.WireFrameFillMode=m.a.MATERIAL_WireFrameFillMode,S.PointFillMode=m.a.MATERIAL_PointFillMode,S.PointListDrawMode=m.a.MATERIAL_PointListDrawMode,S.LineListDrawMode=m.a.MATERIAL_LineListDrawMode,S.LineLoopDrawMode=m.a.MATERIAL_LineLoopDrawMode,S.LineStripDrawMode=m.a.MATERIAL_LineStripDrawMode,S.TriangleStripDrawMode=m.a.MATERIAL_TriangleStripDrawMode,S.TriangleFanDrawMode=m.a.MATERIAL_TriangleFanDrawMode,S.ClockWiseSideOrientation=m.a.MATERIAL_ClockWiseSideOrientation,S.CounterClockWiseSideOrientation=m.a.MATERIAL_CounterClockWiseSideOrientation,S.TextureDirtyFlag=m.a.MATERIAL_TextureDirtyFlag,S.LightDirtyFlag=m.a.MATERIAL_LightDirtyFlag,S.FresnelDirtyFlag=m.a.MATERIAL_FresnelDirtyFlag,S.AttributesDirtyFlag=m.a.MATERIAL_AttributesDirtyFlag,S.MiscDirtyFlag=m.a.MATERIAL_MiscDirtyFlag,S.PrePassDirtyFlag=m.a.MATERIAL_PrePassDirtyFlag,S.AllDirtyFlag=m.a.MATERIAL_AllDirtyFlag,S.MATERIAL_OPAQUE=0,S.MATERIAL_ALPHATEST=1,S.MATERIAL_ALPHABLEND=2,S.MATERIAL_ALPHATESTANDBLEND=3,S.MATERIAL_NORMALBLENDMETHOD_WHITEOUT=0,S.MATERIAL_NORMALBLENDMETHOD_RNM=1,S._AllDirtyCallBack=function(g){return g.markAllAsDirt
26y()},S._ImageProcessingDirtyCallBack=function(g){return g.markAsImageProcessingDirty()},S._TextureDirtyCallBack=function(g){return g.markAsTexturesDirty()},S._FresnelDirtyCallBack=function(g){return g.markAsFresnelDirty()},S._MiscDirtyCallBack=function(g){return g.markAsMiscDirty()},S._PrePassDirtyCallBack=function(g){return g.markAsPrePassDirty()},S._LightsDirtyCallBack=function(g){return g.markAsLightDirty()},S._AttributeDirtyCallBack=function(g){return g.markAsAttributesDirty()},S._FresnelAndMiscDirtyCallBack=function(g){S._FresnelDirtyCallBack(g),S._MiscDirtyCallBack(g)},S._TextureAndMiscDirtyCallBack=function(g){S._TextureDirtyCallBack(g),S._MiscDirtyCallBack(g)},S._DirtyCallbackArray=[],S._RunDirtyCallBacks=function(g){for(var l=0,h=S._DirtyCallbackArray;l<h.length;l++)(0,h[l])(g)},Object(B.c)([Object(_.c)()],S.prototype,"id",void 0),Object(B.c)([Object(_.c)()],S.prototype,"uniqueId",void 0),Object(B.c)([Object(_.c)()],S.prototype,"name",void 0),Object(B.c)([Object(_.c)()],S.prototype,"checkReadyOnEveryCall",void 0),Object(B.c)([Object(_.c)()],S.prototype,"checkReadyOnlyOnce",void 0),Object(B.c)([Object(_.c)()],S.prototype,"state",void 0),Object(B.c)([Object(_.c)("alpha")],S.prototype,"_alpha",void 0),Object(B.c)([Object(_.c)("backFaceCulling")],S.prototype,"_backFaceCulling",void 0),Object(B.c)([Object(_.c)()],S.prototype,"sideOrientation",void 0),Object(B.c)([Object(_.c)("alphaMode")],S.prototype,"_alphaMode",void 0),Object(B.c)([Object(_.c)()],S.prototype,"_needDepthPrePass",void 0),Object(B.c)([Object(_.c)()],S.prototype,"disableDepthWrite",void 0),Object(B.c)([Object(_.c)()],S.prototype,"disableColorWrite",void 0),Object(B.c)([Object(_.c)()],S.prototype,"forceDepthWrite",void 0),Object(B.c)([Object(_.c)()],S.prototype,"depthFunction",void 0),Object(B.c)([Object(_.c)()],S.prototype,"separateCullingPass",void 0),Object(B.c)([Object(_.c)("fogEnabled")],S.prototype,"_fogEnabled",void 0),Object(B.c)([Object(_.c)()],S.prototype,"pointSize",void 0),Object(B.c)([Object(_.c)()],S.prototype,"zOffset",void 0),Object(B.c)([Object(_.c)()],S.prototype,"pointsCloud",null),Object(B.c)([Object(_.c)()],S.prototype,"fillMode",null),Object(B.c)([Object(_.c)()],S.prototype,"transparencyMode",null),S}()},function(Ae,v,f){f.d(v,"a",function(){return w});var B=f(22),_=f(5),x=f(21),u=f(6),M=f(141),R=f(142),C=f(143),m=f(2),c=f(27),E=f(8),A=f(38),S=function(){function N(){}return N.prototype.postProcessor=function(I,V,W,j){return j.getCaps().drawBuffersExtension||(I=I.replace(/#extension.+GL_EXT_draw_buffers.+(enable|require)/g,"")),I},N}(),g=f(118),l=f(88),h=f(144),b=f(70),T=f(74),D=function(){},w=function(){function N(I,V,W,j){var ne=this;j===void 0&&(j=!1),this.forcePOTTextures=!1,this.isFullscreen=!1,this.cullBackFaces=!0,this.renderEvenInBackground=!0,this.preventCacheWipeBetweenFrames=!1,this.validateShaderPrograms=!1,this.useReverseDepthBuffer=!1,this.disableUniformBuffers=!1,this._uniformBuffers=new Array,this._webGLVersion=1,this._windowIsBackground=!1,this._highPrecisionShadersAllowed=!0,this._badOS=!1,this._badDesktopOS=!1,this._renderingQueueLaunched=!1,this._activeRenderLoops=new Array,this.onContextLostObservable=new u.c,this.onContextRestoredObservable=new u.c,this._contextWasLost=!1,this._doNotHandleContextLost=!1,this.disableVertexArrayObjects=!1,this._colorWrite=!0,this._colorWriteChanged=!0,this._depthCullingState=new M.a,this._stencilState=new R.a,this._alphaState=new C.a,this._alphaMode=m.a.ALPHA_ADD,this._alphaEquation=m.a.ALPHA_DISABLE,this._internalTexturesCache=new Array,this._activeChannel=0,this._currentTextureChannel=-1,this._boundTexturesCache={},this._compiledEffects={},this._vertexAttribArraysEnabled=[],this._uintIndicesCurrentlySet=!1,this._currentBoundBuffer=new Array,this._currentFramebuffer=null,this._dummyFramebuffer=null,this._currentBufferPointers=new Array,this._currentInstanceLocations=new Array,this._currentInstanceBuffers=new Array,this._vaoRecordInProgress=!1,this._mustWipeVertexAttributes=!1,this._nextFreeTextureSlots=new Array,this._maxSimultaneousTextures=0,this._activeRequests=new Array,this._transformTextureUrl=null,this.hostInformation={isMobile:!1},this.premultipliedAlpha=!0,this.onBeforeTextureInitObservable=new u.c,this._viewportCached={x:0,y:0,z:0,w:0},this._unpackFlipYCached=null,this.enableUnpackFlipYCached=!0,this._getDepthStencilBuffer=function(X,q,he,ge,me,_e){var be=ne._gl,Ce=be.createRenderbuffer();return be.bindRenderbuffer(be.RENDERBUFFER,Ce),he>1&&be.renderbufferStorageMultisample?be.renderbufferStorageMultisample(be.RENDERBUFFER,he,me,X,q):be.renderbufferStorage(be.RENDERBUFFER,ge,X,q),be.framebufferRenderbuffer(be.FRAMEBUFFER,_e,be.RENDERBUFFER,Ce),be.bindRenderbuffer(be.RENDERBUFFER,null),Ce},this._boundUniforms={};var te=null;if(I){if(W=W||{},T.a.SetMatrixPrecision(!!W.useHighPrecisionMatrix),I.getContext){if(te=I,this._renderingCanvas=te,V!=null&&(W.antialias=V),W.deterministicLockstep===void 0&&(W.deterministicLockstep=!1),W.lockstepMaxSteps===void 0&&(W.lockstepMaxSteps=4),W.timeStep===void 0&&(W.timeStep=1/60),W.preserveDrawingBuffer===void 0&&(W.preserveDrawingBuffer=!1),W.audioEngine===void 0&&(W.audioEngine=!0),W.stencil===void 0&&(W.stencil=!0),W.premultipliedAlpha===!1&&(this.premultipliedAlpha=!1),W.xrCompatible===void 0&&(W.xrCompatible=!0),this._doNotHandleContextLost=!!W.doNotHandleContextLost,navigator&&navigator.userAgent){var de=navigator.userAgent;this.hostInformation.isMobile=de.indexOf("Mobile")!==-1;for(var pe=0,ae=N.ExceptionList;pe<ae.length;pe++){var ee=ae[pe],K=ee.key,$=ee.targets;if(new RegExp(K).test(de)){if(ee.capture&&ee.captureConstraint){var L=ee.capture,G=ee.captureConstraint,Q=new RegExp(L).exec(de);if(Q&&Q.length>0&&parseInt(Q[Q.length-1])>=G)continue}for(var oe=0,re=$;oe<re.length;oe++)switch(re[oe]){case"uniformBuffer":this.disableUniformBuffers=!0;break;case"vao":this.disableVertexArrayObjects=!0}}}}if(this._doNotHandleContextLost||(this._onContextLost=function(X){X.preventDefault(),ne._contextWasLost=!0,E.a.Warn("WebGL context lost."),ne.onContextLostObservable.notifyObservers(ne)},this._onContextRestored=function(){setTimeout(function(){ne._initGLContext(),ne._rebuildEffects(),ne._rebuildInternalTextures(),ne._rebuildBuffers(),ne.wipeCaches(!0),E.a.Warn("WebGL context successfully restored."),ne.onContextRestoredObservable.notifyObservers(ne),ne._contextWasLost=!1},0)},te.addEventListener("webglcontextlost",this._onContextLost,!1),te.addEventListener("webglcontextrestored",this._onContextRestored,!1),W.powerPreference="high-performance"),!W.disableWebGL2Support)try{this._gl=te.getContext("webgl2",W)||te.getContext("experimental-webgl2",W),this._gl&&(this._webGLVersion=2,this._gl.deleteQuery||(this._webGLVersion=1))}catch{}if(!this._gl){if(!te)throw new Error("The provided canvas is null or undefined.");try{this._gl=te.getContext("webgl",W)||te.getContext("experimental-webgl",W)}catch{throw new Error("WebGL not supported")}}if(!this._gl)throw new Error("WebGL not supported")}else{this._gl=I,this._renderingCanvas=this._gl.canvas,this._gl.renderbufferStorageMultisample&&(this._webGLVersion=2);var Y=this._gl.getContextAttributes();Y&&(W.stencil=Y.stencil)}this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL,this._gl.NONE),W.useHighPrecisionFloats!==void 0&&(this._highPrecisionShadersAllowed=W.useHighPrecisionFloats);var k=A.a.IsWindowObjectExist()&&window.devicePixelRatio||1,H=W.limitDeviceRatio||k;this._hardwareScalingLevel=j?1/Math.min(H,k):1,this.resize(),this._isStencilEnable=!!W.stencil,this._initGLContext();for(var Z=0;Z<this._caps.maxVertexAttribs;Z++)this._currentBufferPointers[Z]=new D;this.webGLVersion>1?this._shaderProcessor=new g.a:this._shaderProcessor=new S,this._badOS=/iPad/i.test(navigator.userAgent)||/iPhone/i.test(navigator.userAgent),this._badDesktopOS=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),this._creationOptions=W,console.log("Babylon.js v"+N.Version+" - "+this.description)}}return Object.defineProperty(N,"NpmPackage",{get:function(){return"[email protected]"}
26,enumerable:!1,configurable:!0}),Object.defineProperty(N,"Version",{get:function(){return"4.2.2"},enumerable:!1,configurable:!0}),Object.defineProperty(N.prototype,"description",{get:function(){var I="WebGL"+this.webGLVersion;return this._caps.parallelShaderCompile&&(I+=" - Parallel shader compilation"),I},enumerable:!1,configurable:!0}),Object.defineProperty(N,"ShadersRepository",{get:function(){return _.a.ShadersRepository},set:function(I){_.a.ShadersRepository=I},enumerable:!1,configurable:!0}),Object.defineProperty(N.prototype,"supportsUniformBuffers",{get:function(){return this.webGLVersion>1&&!this.disableUniformBuffers},enumerable:!1,configurable:!0}),Object.defineProperty(N.prototype,"_shouldUseHighPrecisionShader",{get:function(){return!(!this._caps.highPrecisionShaderSupported||!this._highPrecisionShadersAllowed)},enumerable:!1,configurable:!0}),Object.defineProperty(N.prototype,"needPOTTextures",{get:function(){return this._webGLVersion<2||this.forcePOTTextures},enumerable:!1,configurable:!0}),Object.defineProperty(N.prototype,"doNotHandleContextLost",{get:function(){return this._doNotHandleContextLost},set:function(I){this._doNotHandleContextLost=I},enumerable:!1,configurable:!0}),Object.defineProperty(N.prototype,"_supportsHardwareTextureRescaling",{get:function(){return!1},enumerable:!1,configurable:!0}),Object.defineProperty(N.prototype,"framebufferDimensionsObject",{set:function(I){this._framebufferDimensionsObject=I},enumerable:!1,configurable:!0}),Object.defineProperty(N.prototype,"currentViewport",{get:function(){return this._cachedViewport},enumerable:!1,configurable:!0}),Object.defineProperty(N.prototype,"emptyTexture",{get:function(){return this._emptyTexture||(this._emptyTexture=this.createRawTexture(new Uint8Array(4),1,1,m.a.TEXTUREFORMAT_RGBA,!1,!1,m.a.TEXTURE_NEAREST_SAMPLINGMODE)),this._emptyTexture},enumerable:!1,configurable:!0}),Object.defineProperty(N.prototype,"emptyTexture3D",{get:function(){return this._emptyTexture3D||(this._emptyTexture3D=this.createRawTexture3D(new Uint8Array(4),1,1,1,m.a.TEXTUREFORMAT_RGBA,!1,!1,m.a.TEXTURE_NEAREST_SAMPLINGMODE)),this._emptyTexture3D},enumerable:!1,configurable:!0}),Object.defineProperty(N.prototype,"emptyTexture2DArray",{get:function(){return this._emptyTexture2DArray||(this._emptyTexture2DArray=this.createRawTexture2DArray(new Uint8Array(4),1,1,1,m.a.TEXTUREFORMAT_RGBA,!1,!1,m.a.TEXTURE_NEAREST_SAMPLINGMODE)),this._emptyTexture2DArray},enumerable:!1,configurable:!0}),Object.defineProperty(N.prototype,"emptyCubeTexture",{get:function(){if(!this._emptyCubeTexture){var I=new Uint8Array(4),V=[I,I,I,I,I,I];this._emptyCubeTexture=this.createRawCubeTexture(V,1,m.a.TEXTUREFORMAT_RGBA,m.a.TEXTURETYPE_UNSIGNED_INT,!1,!1,m.a.TEXTURE_NEAREST_SAMPLINGMODE)}return this._emptyCubeTexture},enumerable:!1,configurable:!0}),N.prototype._rebuildInternalTextures=function(){for(var I=0,V=this._internalTexturesCache.slice();I<V.length;I++)V[I]._rebuild()},N.prototype._rebuildEffects=function(){for(var I in this._compiledEffects)this._compiledEffects[I]._prepareEffect();_.a.ResetCache()},N.prototype.areAllEffectsReady=function(){for(var I in this._compiledEffects)if(!this._compiledEffects[I].isReady())return!1;return!0},N.prototype._rebuildBuffers=function(){for(var I=0,V=this._uniformBuffers;I<V.length;I++)V[I]._rebuild()},N.prototype._initGLContext=function(){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"),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"),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"),canUseTimestampForTimerQuery:!1,drawBuffersExtension:!1,maxMSAASamples:1,colorBufferFloat:this._webGLVersion>1&&this._gl.getExtension("EXT_color_buffer_float"),textureFloat:!!(this._webGLVersion>1||this._gl.getExtension("OES_texture_float")),textureHalfFloat:!!(this._webGLVersion>1||this._gl.getExtension("OES_texture_half_float")),textureHalfFloatRen
26der:!1,textureFloatLinearFiltering:!1,textureFloatRender:!1,textureHalfFloatLinearFiltering:!1,vertexArrayObject:!1,instancedArrays:!1,textureLOD:!!(this._webGLVersion>1||this._gl.getExtension("EXT_shader_texture_lod")),blendMinMax:!1,multiview:this._gl.getExtension("OVR_multiview2"),oculusMultiview:this._gl.getExtension("OCULUS_multiview"),depthTextureExtension:!1},this._glVersion=this._gl.getParameter(this._gl.VERSION);var I=this._gl.getExtension("WEBGL_debug_renderer_info");if(I!=null&&(this._glRenderer=this._gl.getParameter(I.UNMASKED_RENDERER_WEBGL),this._glVendor=this._gl.getParameter(I.UNMASKED_VENDOR_WEBGL)),this._glVendor||(this._glVendor="Unknown vendor"),this._glRenderer||(this._glRenderer="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=this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT,this._caps.timerQuery.QUERY_COUNTER_BITS_EXT)>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._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._gl.getParameter(this._gl.MAX_SAMPLES);else{var V=this._gl.getExtension("WEBGL_draw_buffers");if(V!==null){this._caps.drawBuffersExtension=!0,this._gl.drawBuffers=V.drawBuffersWEBGL.bind(V),this._gl.DRAW_FRAMEBUFFER=this._gl.FRAMEBUFFER;for(var W=0;W<16;W++)this._gl["COLOR_ATTACHMENT"+W+"_WEBGL"]=V["COLOR_ATTACHMENT"+W+"_WEBGL"]}}if(this._webGLVersion>1)this._caps.depthTextureExtension=!0;else{var j=this._gl.getExtension("WEBGL_depth_texture");j!=null&&(this._caps.depthTextureExtension=!0,this._gl.UNSIGNED_INT_24_8=j.UNSIGNED_INT_24_8_WEBGL)}if(this.disableVertexArrayObjects)this._caps.vertexArrayObject=!1;else if(this._webGLVersion>1)this._caps.vertexArrayObject=!0;else{var ne=this._gl.getExtension("OES_vertex_array_object");ne!=null&&(this._caps.vertexArrayObject=!0,this._gl.createVertexArray=ne.createVertexArrayOES.bind(ne),this._gl.bindVertexArray=ne.bindVertexArrayOES.bind(ne),this._gl.deleteVertexArray=ne.deleteVertexArrayOES.bind(ne))}if(this._webGLVersion>1)this._caps.instancedArrays=!0;else{var te=this._gl.getExtension("ANGLE_instanced_arrays");te!=null?(this._caps.instancedArrays=!0,this._gl.drawArraysInstanced=te.drawArraysInstancedANGLE.bind(te),this._gl.drawElementsInstanced=te.drawElementsInstancedANGLE.bind(te),this._gl.vertexAttribDivisor=te.vertexAttribDivisorANGLE.bind(te)):this._caps.instancedArrays=!1}if(this._gl.getShaderPrecisionFormat){var de=this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER,this._gl.HIGH_FLOAT),pe=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.HIGH_FLOAT);de&&pe&&(this._caps.highPrecisionShaderSupported=de.precision!==0&&pe.precision!==0)}if(this._webGLVersion>1)this._caps.blendMinMax=!0;else{var ae=this._gl.getExtension("EXT_blend_minmax");ae!=null&&(this._caps.blendMinMax=!0,this._gl.MAX=ae.MAX_EXT,this._gl.MIN=ae.MIN_EXT)}this._depthCullingState.depthTest=!0,this._depthCullingState.depthFunc=this._gl.LEQUAL,this._depthCullingState.depthMask=!0,this._maxSimultaneousTextures=this._caps.maxCombinedTexturesImageUnits;for(var ee=0;ee<this._maxSimultaneousTextures;ee++)this._nextFreeTextureSlots.push(ee)},Object.defineProperty(N.prototype,"webGLVersion",{get:function(){return this._webGLVersion}
26,enumerable:!1,configurable:!0}),N.prototype.getClassName=function(){return"ThinEngine"},Object.defineProperty(N.prototype,"isStencilEnable",{get:function(){return this._isStencilEnable},enumerable:!1,configurable:!0}),N.prototype._prepareWorkingCanvas=function(){if(!this._workingCanvas){this._workingCanvas=b.a.CreateCanvas(1,1);var I=this._workingCanvas.getContext("2d");I&&(this._workingContext=I)}},N.prototype.resetTextureCache=function(){for(var I in this._boundTexturesCache)this._boundTexturesCache.hasOwnProperty(I)&&(this._boundTexturesCache[I]=null);this._currentTextureChannel=-1},N.prototype.getGlInfo=function(){return{vendor:this._glVendor,renderer:this._glRenderer,version:this._glVersion}},N.prototype.setHardwareScalingLevel=function(I){this._hardwareScalingLevel=I,this.resize()},N.prototype.getHardwareScalingLevel=function(){return this._hardwareScalingLevel},N.prototype.getLoadedTexturesCache=function(){return this._internalTexturesCache},N.prototype.getCaps=function(){return this._caps},N.prototype.stopRenderLoop=function(I){if(I){var V=this._activeRenderLoops.indexOf(I);V>=0&&this._activeRenderLoops.splice(V,1)}else this._activeRenderLoops=[]},N.prototype._renderLoop=function(){if(!this._contextWasLost){var I=!0;if(!this.renderEvenInBackground&&this._windowIsBackground&&(I=!1),I){this.beginFrame();for(var V=0;V<this._activeRenderLoops.length;V++)(0,this._activeRenderLoops[V])();this.endFrame()}}this._activeRenderLoops.length>0?this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow()):this._renderingQueueLaunched=!1},N.prototype.getRenderingCanvas=function(){return this._renderingCanvas},N.prototype.getHostWindow=function(){return A.a.IsWindowObjectExist()?this._renderingCanvas&&this._renderingCanvas.ownerDocument&&this._renderingCanvas.ownerDocument.defaultView?this._renderingCanvas.ownerDocument.defaultView:window:null},N.prototype.getRenderWidth=function(I){return I===void 0&&(I=!1),!I&&this._currentRenderTarget?this._currentRenderTarget.width:this._framebufferDimensionsObject?this._framebufferDimensionsObject.framebufferWidth:this._gl.drawingBufferWidth},N.prototype.getRenderHeight=function(I){return I===void 0&&(I=!1),!I&&this._currentRenderTarget?this._currentRenderTarget.height:this._framebufferDimensionsObject?this._framebufferDimensionsObject.framebufferHeight:this._gl.drawingBufferHeight},N.prototype._queueNewFrame=function(I,V){return N.QueueNewFrame(I,V)},N.prototype.runRenderLoop=function(I){this._activeRenderLoops.indexOf(I)===-1&&(this._activeRenderLoops.push(I),this._renderingQueueLaunched||(this._renderingQueueLaunched=!0,this._boundRenderFunction=this._renderLoop.bind(this),this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow())))},N.prototype.clear=function(I,V,W,j){j===void 0&&(j=!1),this.applyStates();var ne=0;V&&I&&(this._gl.clearColor(I.r,I.g,I.b,I.a!==void 0?I.a:1),ne|=this._gl.COLOR_BUFFER_BIT),W&&(this.useReverseDepthBuffer?(this._depthCullingState.depthFunc=this._gl.GREATER,this._gl.clearDepth(0)):this._gl.clearDepth(1),ne|=this._gl.DEPTH_BUFFER_BIT),j&&(this._gl.clearStencil(0),ne|=this._gl.STENCIL_BUFFER_BIT),this._gl.clear(ne)},N.prototype._viewport=function(I,V,W,j){I===this._viewportCached.x&&V===this._viewportCached.y&&W===this._viewportCached.z&&j===this._viewportCached.w||(this._viewportCached.x=I,this._viewportCached.y=V,this._viewportCached.z=W,this._viewportCached.w=j,this._gl.viewport(I,V,W,j))},N.prototype.setViewport=function(I,V,W){var j=V||this.getRenderWidth(),ne=W||this.getRenderHeight(),te=I.x||0,de=I.y||0;this._cachedViewport=I,this._viewport(te*j,de*ne,j*I.width,ne*I.height)},N.prototype.beginFrame=function(){},N.prototype.endFrame=function(){this._badOS&&this.flushFramebuffer()},N.prototype.resize=function(){var I,V;A.a.IsWindowObjectExist()?(I=this._renderingCanvas?this._renderingCanvas.clientWidth||this._renderingCanvas.width:window.innerWidth,V=this._renderingCanvas?this._renderingCanvas.clientHeight||this._renderingCanvas.height:window.innerHeight):(I=this._renderingCanvas?this._renderingCanvas.width:100,V=this._renderingCanvas?this._renderingCanvas.height:100),this.setSize(I/this._hardwareScalingLevel,V/this._hardwareScalingLevel)},N.prototype.setSize=function(I,V){return!!this._renderingCanvas&&(I|=0,V|=0,(this._renderingCanvas.width!==I||this._renderingCanvas.height!==V)&&(this._renderingCanvas.width=I,this._renderingCanvas.height=V,!0))},N.prototype.bindFramebuffer=function(I,V,W,j,ne,te,de){V===void 0&&(V=0),te===void 0&&(te=0),de===void 0&&(de=0),this._currentRenderTarget&&this.unBindFramebuffer(this._currentRenderTarget),this._currentRenderTarget=I,this._bindUnboundFramebuffer(I._MSAAFramebuffer?I._MSAAFramebuffer:I._framebuffer);var pe=this._gl;I.is2DArray?pe.framebufferTextureLayer(pe.FRAMEBUFFER,pe.COLOR_ATTACHMENT0,I._webGLTexture,te,de):I.isCube&&pe.framebufferTexture2D(pe.FRAMEBUFFER,pe.COLOR_ATTACHMENT0,pe.TEXTURE_CUBE_MAP_POSITIVE_X+V,I._webGLTexture,te);var ae=I._depthStencilTexture;if(ae){var ee=ae._generateStencilBuffer?pe.DEPTH_STENCIL_ATTACHMENT:pe.DEPTH_ATTACHMENT;I.is2DArray?pe.framebufferTextureLayer(pe.FRAMEBUFFER,ee,ae._webGLTexture,te,de):I.isCube?pe.framebufferTexture2D(pe.FRAMEBUFFER,ee,pe.TEXTURE_CUBE_MAP_POSITIVE_X+V,ae._webGLTexture,te):pe.framebufferTexture2D(pe.FRAMEBUFFER,ee,pe.TEXTURE_2D,ae._webGLTexture,te)}this._cachedViewport&&!ne?this.setViewport(this._cachedViewport,W,j):(W||(W=I.width,te&&(W/=Math.pow(2,te))),j||(j=I.height,te&&(j/=Math.pow(2,te))),this._viewport(0,0,W,j)),this.wipeCaches()},N.prototype._bindUnboundFramebuffer=function(I){this._currentFramebuffer!==I&&(this._gl.bindFramebuffer(this._gl.FRAMEBUFFER,I),this._currentFramebuffer=I)},N.prototype.unBindFramebuffer=function(I,V,W){V===void 0&&(V=!1),this._currentRenderTarget=null;var j=this._gl;if(I._MSAAFramebuffer){if(I._textureArray)return void this.unBindMultiColorAttachmentFramebuffer(I._textureArray,V,W);j.bindFramebuffer(j.READ_FRAMEBUFFER,I._MSAAFramebuffer),j.bindFramebuffer(j.DRAW_FRAMEBUFFER,I._framebuffer),j.blitFramebuffer(0,0,I.width,I.height,0,0,I.width,I.height,j.COLOR_BUFFER_BIT,j.NEAREST)}!I.generateMipMaps||V||I.isCube||(this._bindTextureDirectly(j.TEXTURE_2D,I,!0),j.generateMipmap(j.TEXTURE_2D),this._bindTextureDirectly(j.TEXTURE_2D,null)),W&&(I._MSAAFramebuffer&&this._bindUnboundFramebuffer(I._framebuffer),W()),this._bindUnboundFramebuffer(null)},N.prototype.flushFramebuffer=function(){this._gl.flush()},N.prototype.restoreDefaultFramebuffer=function(){this._currentRenderTarget?this.unBindFramebuffer(this._currentRenderTarget):this._bindUnboundFramebuffer(null),this._cachedViewport&&this.setViewport(this._cachedViewport),this.wipeCaches()},N.prototype._resetVertexBufferBinding=function(){this.bindArrayBuffer(null),this._cachedVertexBuffers=null},N.prototype.createVertexBuffer=function(I){return this._createVertexBuffer(I,this._gl.STATIC_DRAW)},N.prototype._createVertexBuffer=function(I,V){var W=this._gl.createBuffer();if(!W)throw new Error("Unable to create vertex buffer");var j=new l.a(W);return this.bindArrayBuffer(j),I instanceof Array?this._gl.bufferData(this._gl.ARRAY_BUFFER,new Float32Array(I),this._gl.STATIC_DRAW):this._gl.bufferData(this._gl.ARRAY_BUFFER,I,this._gl.STATIC_DRAW),this._resetVertexBufferBinding(),j.references=1,j},N.prototype.createDynamicVertexBuffer=function(I){return this._createVertexBuffer(I,this._gl.DYNAMIC_DRAW)},N.prototype._resetIndexBufferBinding=function(){this.bindIndexBuffer(null),this._cachedIndexBuffer=null},N.prototype.createIndexBuffer=function(I,V){var W=this._gl.createBuffer(),j=new l.a(W);if(!W)throw new Error("Unable to create index buffer");this.bindIndexBuffer(j);var ne=this._normalizeIndexData(I);return this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,ne,V?this._gl.DYNAMIC_DRAW:this._gl.STATIC_DRAW),this._resetIndexBufferBinding(),j.references=1,j.is32Bits=ne.BYTES_PER_ELEMENT===4,j},N.prototype._normalizeIndexData=function(I){if(I instanceof Uint16Array)return I;if(this._caps.uintIndices){if(I instanceof Uint32Array)return I;for(var V=0;V<I.length;V++)if(I[V]>=65535)return new Uint32Array(I);return new Uint16Array(I)}return new Uint16Array(I)},N.prototype.bindArrayBuffer=function(I){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.bindBuffer(I,this._gl.ARRAY_BUFFER)},N.prototype.bindUniformBlock=function(I,V,W){var j=I.program,ne=this._gl.getUniformBlockIndex(j,V);this._gl.uniformBlockBinding(j,ne,W)},N.prototype.bindIndexBuffer=function(I){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.bindBuffer(I,this._gl.ELEMENT_ARRAY_BUFFER)},N.prototype.bindBuffer=function(I,V){(this._vaoRecordInProgress||this._currentBoundBuffer[V]!==I)&&(this._gl.bindBuffer(V,I?I.underlyingResource:null),this._currentBoundBuffer[V]=I)},N.prototype.updateArrayBuffer=function(I){this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,I)},N.prototype._vertexAttribPointer=function(I,V,W,j,ne,te,de){var pe=this._currentBufferPointers[V];if(pe){var ae=!1;pe.active?(pe.buffer!==I&&(pe.buffer=I,ae=!0),pe.size!==W&&(pe.size=W,ae=!0),pe.type!==j&&(pe.type=j,ae=!0),pe.normalized!==ne&&(pe.normalized=ne,ae=!0),pe.stride!==te&&(pe.stride=te,ae=!0),pe.offset!==de&&(pe.offset=de,ae=!0)):(ae=!0,pe.active=!0,pe.index=V,pe.size=W,pe.type=j,pe.n
26ormalized=ne,pe.stride=te,pe.offset=de,pe.buffer=I),(ae||this._vaoRecordInProgress)&&(this.bindArrayBuffer(I),this._gl.vertexAttribPointer(V,W,j,ne,te,de))}},N.prototype._bindIndexBufferWithCache=function(I){I!=null&&this._cachedIndexBuffer!==I&&(this._cachedIndexBuffer=I,this.bindIndexBuffer(I),this._uintIndicesCurrentlySet=I.is32Bits)},N.prototype._bindVertexBuffersAttributes=function(I,V){var W=V.getAttributesNames();this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.unbindAllAttributes();for(var j=0;j<W.length;j++){var ne=V.getAttributeLocation(j);if(ne>=0){var te=I[W[j]];if(!te)continue;this._gl.enableVertexAttribArray(ne),this._vaoRecordInProgress||(this._vertexAttribArraysEnabled[ne]=!0);var de=te.getBuffer();de&&(this._vertexAttribPointer(de,ne,te.getSize(),te.type,te.normalized,te.byteStride,te.byteOffset),te.getIsInstanced()&&(this._gl.vertexAttribDivisor(ne,te.getInstanceDivisor()),this._vaoRecordInProgress||(this._currentInstanceLocations.push(ne),this._currentInstanceBuffers.push(de))))}}},N.prototype.recordVertexArrayObject=function(I,V,W){var j=this._gl.createVertexArray();return this._vaoRecordInProgress=!0,this._gl.bindVertexArray(j),this._mustWipeVertexAttributes=!0,this._bindVertexBuffersAttributes(I,W),this.bindIndexBuffer(V),this._vaoRecordInProgress=!1,this._gl.bindVertexArray(null),j},N.prototype.bindVertexArrayObject=function(I,V){this._cachedVertexArrayObject!==I&&(this._cachedVertexArrayObject=I,this._gl.bindVertexArray(I),this._cachedVertexBuffers=null,this._cachedIndexBuffer=null,this._uintIndicesCurrentlySet=V!=null&&V.is32Bits,this._mustWipeVertexAttributes=!0)},N.prototype.bindBuffersDirectly=function(I,V,W,j,ne){if(this._cachedVertexBuffers!==I||this._cachedEffectForVertexBuffers!==ne){this._cachedVertexBuffers=I,this._cachedEffectForVertexBuffers=ne;var te=ne.getAttributesCount();this._unbindVertexArrayObject(),this.unbindAllAttributes();for(var de=0,pe=0;pe<te;pe++)if(pe<W.length){var ae=ne.getAttributeLocation(pe);ae>=0&&(this._gl.enableVertexAttribArray(ae),this._vertexAttribArraysEnabled[ae]=!0,this._vertexAttribPointer(I,ae,W[pe],this._gl.FLOAT,!1,j,de)),de+=4*W[pe]}}this._bindIndexBufferWithCache(V)},N.prototype._unbindVertexArrayObject=function(){this._cachedVertexArrayObject&&(this._cachedVertexArrayObject=null,this._gl.bindVertexArray(null))},N.prototype.bindBuffers=function(I,V,W){this._cachedVertexBuffers===I&&this._cachedEffectForVertexBuffers===W||(this._cachedVertexBuffers=I,this._cachedEffectForVertexBuffers=W,this._bindVertexBuffersAttributes(I,W)),this._bindIndexBufferWithCache(V)},N.prototype.unbindInstanceAttributes=function(){for(var I,V=0,W=this._currentInstanceLocations.length;V<W;V++){var j=this._currentInstanceBuffers[V];I!=j&&j.references&&(I=j,this.bindArrayBuffer(j));var ne=this._currentInstanceLocations[V];this._gl.vertexAttribDivisor(ne,0)}this._currentInstanceBuffers.length=0,this._currentInstanceLocations.length=0},N.prototype.releaseVertexArrayObject=function(I){this._gl.deleteVertexArray(I)},N.prototype._releaseBuffer=function(I){return I.references--,I.references===0&&(this._deleteBuffer(I),!0)},N.prototype._deleteBuffer=function(I){this._gl.deleteBuffer(I.underlyingResource)},N.prototype.updateAndBindInstancesBuffer=function(I,V,W){if(this.bindArrayBuffer(I),V&&this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,V),W[0].index!==void 0)this.bindInstancesBuffer(I,W,!0);else for(var j=0;j<4;j++){var ne=W[j];this._vertexAttribArraysEnabled[ne]||(this._gl.enableVertexAttribArray(ne),this._vertexAttribArraysEnabled[ne]=!0),this._vertexAttribPointer(I,ne,4,this._gl.FLOAT,!1,64,16*j),this._gl.vertexAttribDivisor(ne,1),this._currentInstanceLocations.push(ne),this._currentInstanceBuffers.push(I)}},N.prototype.bindInstancesBuffer=function(I,V,W){W===void 0&&(W=!0),this.bindArrayBuffer(I);var j=0;if(W)for(var ne=0;ne<V.length;ne++)j+=4*(te=V[ne]).attributeSize;for(ne=0;ne<V.length;ne++){var te;(te=V[ne]).index===void 0&&(te.index=this._currentEffect.getAttributeLocationByName(te.attributeName)),te.index<0||(this._vertexAttribArraysEnabled[te.index]||(this._gl.enableVertexAttribArray(te.index),this._vertexAttribArraysEnabled[te.index]=!0),this._vertexAttribPointer(I,te.index,te.attributeSize,te.attributeType||this._gl.FLOAT,te.normalized||!1,j,te.offset),this._gl.vertexAttribDivisor(te.index,te.divisor===void 0?1:te.divisor),this._currentInstanceLocations.push(te.index),this._currentInstanceBuffers.push(I))}},N.prototype.disableInstanceAttributeByName=function(I){if(this._currentEffect){var V=this._currentEffect.getAttributeLocationByName(I);this.disableInstanceAttribute(V)}},N.prototype.disableInstanceAttribute=function(I){for(var V,W=!1;(V=this._currentInstanceLocations.indexOf(I))!==-1;)this._currentInstanceLocations.splice(V,1),this._currentInstanceBuffers.splice(V,1),W=!0,V=this._currentInstanceLocations.indexOf(I);W&&(this._gl.vertexAttribDivisor(I,0),this.disableAttributeByIndex(I))},N.prototype.disableAttributeByIndex=function(I){this._gl.disableVertexAttribArray(I),this._vertexAttribArraysEnabled[I]=!1,this._currentBufferPointers[I].active=!1},N.prototype.draw=function(I,V,W,j){this.drawElementsType(I?m.a.MATERIAL_TriangleFillMode:m.a.MATERIAL_WireFrameFillMode,V,W,j)},N.prototype.drawPointClouds=function(I,V,W){this.drawArraysType(m.a.MATERIAL_PointFillMode,I,V,W)},N.prototype.drawUnIndexed=function(I,V,W,j){this.drawArraysType(I?m.a.MATERIAL_TriangleFillMode:m.a.MATERIAL_WireFrameFillMode,V,W,j)},N.prototype.drawElementsType=function(I,V,W,j){this.applyStates(),this._reportDrawCall();var ne=this._drawMode(I),te=this._uintIndicesCurrentlySet?this._gl.UNSIGNED_INT:this._gl.UNSIGNED_SHORT,de=this._uintIndicesCurrentlySet?4:2;j?this._gl.drawElementsInstanced(ne,W,te,V*de,j):this._gl.drawElements(ne,W,te,V*de)},N.prototype.drawArraysType=function(I,V,W,j){this.applyStates(),this._reportDrawCall();var ne=this._drawMode(I);j?this._gl.drawArraysInstanced(ne,V,W,j):this._gl.drawArrays(ne,V,W)},N.prototype._drawMode=function(I){switch(I){case m.a.MATERIAL_TriangleFillMode:return this._gl.TRIANGLES;case m.a.MATERIAL_PointFillMode:return this._gl.POINTS;case m.a.MATERIAL_WireFrameFillMode:return this._gl.LINES;case m.a.MATERIAL_PointListDrawMode:return this._gl.POINTS;case m.a.MATERIAL_LineListDrawMode:return this._gl.LINES;case m.a.MATERIAL_LineLoopDrawMode:return this._gl.LINE_LOOP;case m.a.MATERIAL_LineStripDrawMode:return this._gl.LINE_STRIP;case m.a.MATERIAL_TriangleStripDrawMode:return this._gl.TRIANGLE_STRIP;case m.a.MATERIAL_TriangleFanDrawMode:return this._gl.TRIANGLE_FAN;default:return this._gl.TRIANGLES}},N.prototype._reportDrawCall=function(){},N.prototype._releaseEffect=function(I){this._compiledEffects[I._key]&&(delete this._compiledEffects[I._key],this._deletePipelineContext(I.getPipelineContext()))},N.prototype._deletePipelineContext=function(I){var V=I;V&&V.program&&(V.program.__SPECTOR_rebuildProgram=null,this._gl.deleteProgram(V.program))}
26,N.prototype.createEffect=function(I,V,W,j,ne,te,de,pe,ae){var ee=(I.vertexElement||I.vertex||I.vertexToken||I.vertexSource||I)+"+"+(I.fragmentElement||I.fragment||I.fragmentToken||I.fragmentSource||I)+"@"+(ne||V.defines);if(this._compiledEffects[ee]){var K=this._compiledEffects[ee];return de&&K.isReady()&&de(K),K}var $=new _.a(I,V,W,j,this,ne,te,de,pe,ae);return $._key=ee,this._compiledEffects[ee]=$,$},N._ConcatenateShader=function(I,V,W){return W===void 0&&(W=""),W+(V?V+`
27`:"")+I},N.prototype._compileShader=function(I,V,W,j){return this._compileRawShader(N._ConcatenateShader(I,W,j),V)},N.prototype._compileRawShader=function(I,V){var W=this._gl,j=W.createShader(V==="vertex"?W.VERTEX_SHADER:W.FRAGMENT_SHADER);if(!j)throw new Error("Something went wrong while compile the shader.");return W.shaderSource(j,I),W.compileShader(j),j},N.prototype._getShaderSource=function(I){return this._gl.getShaderSource(I)},N.prototype.createRawShaderProgram=function(I,V,W,j,ne){ne===void 0&&(ne=null),j=j||this._gl;var te=this._compileRawShader(V,"vertex"),de=this._compileRawShader(W,"fragment");return this._createShaderProgram(I,te,de,j,ne)},N.prototype.createShaderProgram=function(I,V,W,j,ne,te){te===void 0&&(te=null),ne=ne||this._gl;var de=this._webGLVersion>1?`#version 300 es
28#define WEBGL2 
29`:"",pe=this._compileShader(V,"vertex",j,de),ae=this._compileShader(W,"fragment",j,de);return this._createShaderProgram(I,pe,ae,ne,te)},N.prototype.createPipelineContext=function(){var I=new h.a;return I.engine=this,this._caps.parallelShaderCompile&&(I.isParallelCompiled=!0),I},N.prototype._createShaderProgram=function(I,V,W,j,ne){var te=j.createProgram();if(I.program=te,!te)throw new Error("Unable to create program");return j.attachShader(te,V),j.attachShader(te,W),j.linkProgram(te),I.context=j,I.vertexShader=V,I.fragmentShader=W,I.isParallelCompiled||this._finalizePipelineContext(I),te},N.prototype._finalizePipelineContext=function(I){var V=I.context,W=I.vertexShader,j=I.fragmentShader,ne=I.program;if(!V.getProgramParameter(ne,V.LINK_STATUS)){var te,de;if(!this._gl.getShaderParameter(W,this._gl.COMPILE_STATUS)&&(te=this._gl.getShaderInfoLog(W)))throw I.vertexCompilationError=te,new Error("VERTEX SHADER "+te);if(!this._gl.getShaderParameter(j,this._gl.COMPILE_STATUS)&&(te=this._gl.getShaderInfoLog(j)))throw I.fragmentCompilationError=te,new Error("FRAGMENT SHADER "+te);if(de=V.getProgramInfoLog(ne))throw I.programLinkError=de,new Error(de)}if(this.validateShaderPrograms&&(V.validateProgram(ne),!V.getProgramParameter(ne,V.VALIDATE_STATUS)&&(de=V.getProgramInfoLog(ne))))throw I.programValidationError=de,new Error(de);V.deleteShader(W),V.deleteShader(j),I.vertexShader=void 0,I.fragmentShader=void 0,I.onCompiled&&(I.onCompiled(),I.onCompiled=void 0)},N.prototype._preparePipelineContext=function(I,V,W,j,ne,te,de){var pe=I;pe.program=j?this.createRawShaderProgram(pe,V,W,void 0,de):this.createShaderProgram(pe,V,W,te,void 0,de),pe.program.__SPECTOR_rebuildProgram=ne},N.prototype._isRenderingStateCompiled=function(I){var V=I;return!!this._gl.getProgramParameter(V.program,this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR)&&(this._finalizePipelineContext(V),!0)},N.prototype._executeWhenRenderingStateIsCompiled=function(I,V){var W=I;if(W.isParallelCompiled){var j=W.onCompiled;W.onCompiled=j?function(){j(),V()}:V}else V()},N.prototype.getUniforms=function(I,V){for(var W=new Array,j=I,ne=0;ne<V.length;ne++)W.push(this._gl.getUniformLocation(j.program,V[ne]));return W},N.prototype.getAttributes=function(I,V){for(var W=[],j=I,ne=0;ne<V.length;ne++)try{W.push(this._gl.getAttribLocation(j.program,V[ne]))}catch{W.push(-1)}return W},N.prototype.enableEffect=function(I){I&&I!==this._currentEffect&&(this.bindSamplers(I),this._currentEffect=I,I.onBind&&I.onBind(I),I._onBindObservable&&I._onBindObservable.notifyObservers(I))},N.prototype.setInt=function(I,V){return!!I&&(this._gl.uniform1i(I,V),!0)},N.prototype.setIntArray=function(I,V){return!!I&&(this._gl.uniform1iv(I,V),!0)},N.prototype.setIntArray2=function(I,V){return!(!I||V.length%2!=0)&&(this._gl.uniform2iv(I,V),!0)},N.prototype.setIntArray3=function(I,V){return!(!I||V.length%3!=0)&&(this._gl.uniform3iv(I,V
29),!0)},N.prototype.setIntArray4=function(I,V){return!(!I||V.length%4!=0)&&(this._gl.uniform4iv(I,V),!0)},N.prototype.setArray=function(I,V){return!!I&&(this._gl.uniform1fv(I,V),!0)},N.prototype.setArray2=function(I,V){return!(!I||V.length%2!=0)&&(this._gl.uniform2fv(I,V),!0)},N.prototype.setArray3=function(I,V){return!(!I||V.length%3!=0)&&(this._gl.uniform3fv(I,V),!0)},N.prototype.setArray4=function(I,V){return!(!I||V.length%4!=0)&&(this._gl.uniform4fv(I,V),!0)},N.prototype.setMatrices=function(I,V){return!!I&&(this._gl.uniformMatrix4fv(I,!1,V),!0)},N.prototype.setMatrix3x3=function(I,V){return!!I&&(this._gl.uniformMatrix3fv(I,!1,V),!0)},N.prototype.setMatrix2x2=function(I,V){return!!I&&(this._gl.uniformMatrix2fv(I,!1,V),!0)},N.prototype.setFloat=function(I,V){return!!I&&(this._gl.uniform1f(I,V),!0)},N.prototype.setFloat2=function(I,V,W){return!!I&&(this._gl.uniform2f(I,V,W),!0)},N.prototype.setFloat3=function(I,V,W,j){return!!I&&(this._gl.uniform3f(I,V,W,j),!0)},N.prototype.setFloat4=function(I,V,W,j,ne){return!!I&&(this._gl.uniform4f(I,V,W,j,ne),!0)},N.prototype.applyStates=function(){if(this._depthCullingState.apply(this._gl),this._stencilState.apply(this._gl),this._alphaState.apply(this._gl),this._colorWriteChanged){this._colorWriteChanged=!1;var I=this._colorWrite;this._gl.colorMask(I,I,I,I)}},N.prototype.setColorWrite=function(I){I!==this._colorWrite&&(this._colorWriteChanged=!0,this._colorWrite=I)},N.prototype.getColorWrite=function(){return this._colorWrite},Object.defineProperty(N.prototype,"depthCullingState",{get:function(){return this._depthCullingState},enumerable:!1,configurable:!0}),Object.defineProperty(N.prototype,"alphaState",{get:function(){return this._alphaState},enumerable:!1,configurable:!0}),Object.defineProperty(N.prototype,"stencilState",{get:function(){return this._stencilState},enumerable:!1,configurable:!0}),N.prototype.clearInternalTexturesCache=function(){this._internalTexturesCache=[]},N.prototype.wipeCaches=function(I){this.preventCacheWipeBetweenFrames&&!I||(this._currentEffect=null,this._viewportCached.x=0,this._viewportCached.y=0,this._viewportCached.z=0,this._viewportCached.w=0,this._unbindVertexArrayObject(),I&&(this._currentProgram=null,this.resetTextureCache(),this._stencilState.reset(),this._depthCullingState.reset(),this._depthCullingState.depthFunc=this._gl.LEQUAL,this._alphaState.reset(),this._alphaMode=m.a.ALPHA_ADD,this._alphaEquation=m.a.ALPHA_DISABLE,this._colorWrite=!0,this._colorWriteChanged=!0,this._unpackFlipYCached=null,this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL,this._gl.NONE),this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),this._mustWipeVertexAttributes=!0,this.unbindAllAttributes()),this._resetVertexBufferBinding(),this._cachedIndexBuffer=null,this._cachedEffectForVertexBuffers=null,this.bindIndexBuffer(null))},N.prototype._getSamplingParameters=function(I,V){var W=this._gl,j=W.NEAREST,ne=W.NEAREST;switch(I){case m.a.TEXTURE_LINEAR_LINEAR_MIPNEAREST:j=W.LINEAR,ne=V?W.LINEAR_MIPMAP_NEAREST:W.LINEAR;break;case m.a.TEXTURE_LINEAR_LINEAR_MIPLINEAR:j=W.LINEAR,ne=V?W.LINEAR_MIPMAP_LINEAR:W.LINEAR;break;case m.a.TEXTURE_NEAREST_NEAREST_MIPLINEAR:j=W.NEAREST,ne=V?W.NEAREST_MIPMAP_LINEAR:W.NEAREST;break;case m.a.TEXTURE_NEAREST_NEAREST_MIPNEAREST:j=W.NEAREST,ne=V?W.NEAREST_MIPMAP_NEAREST:W.NEAREST;break;case m.a.TEXTURE_NEAREST_LINEAR_MIPNEAREST:j=W.NEAREST,ne=V?W.LINEAR_MIPMAP_NEAREST:W.LINEAR;break;case m.a.TEXTURE_NEAREST_LINEAR_MIPLINEAR:j=W.NEAREST,ne=V?W.LINEAR_MIPMAP_LINEAR:W.LINEAR;break;case m.a.TEXTURE_NEAREST_LINEAR:j=W.NEAREST,ne=W.LINEAR;break;case m.a.TEXTURE_NEAREST_NEAREST:j=W.NEAREST,ne=W.NEAREST;break;case m.a.TEXTURE_LINEAR_NEAREST_MIPNEAREST:j=W.LINEAR,ne=V?W.NEAREST_MIPMAP_NEAREST:W.NEAREST;break;case m.a.TEXTURE_LINEAR_NEAREST_MIPLINEAR:j=W.LINEAR,ne=V?W.NEAREST_MIPMAP_LINEAR:W.NEAREST;break;case m.a.TEXTURE_LINEAR_LINEAR:j=W.LINEAR,ne=W.LINEAR;break;case m.a.TEXTURE_LINEAR_NEAREST:j=W.LINEAR,ne=W.NEAREST}return{min:ne,mag:j}},N.prototype._createTexture=function(){var I=this._gl.createTexture();if(!I)throw new Error("Unable to create texture");return I},N.prototype.createTexture=function(I,V,W,j,ne,te,de,pe,ae,ee,K,$,L){var G=this;ne===void 0&&(ne=m.a.TEXTURE_TRILINEAR_SAMPLINGMODE),te===void 0&&(te=null),de===void 0&&(de=null),pe===void 0&&(pe=null),ae===void 0&&(ae=null),ee===void 0&&(ee=null),K===void 0&&(K=null);var Q=(I=I||"").substr(0,5)==="data:",oe=I.substr(0,5)==="blob:",re=Q&&I.indexOf(";base64,")!==-1,Y=ae||new c.a(this,c.b.Url),k=I;!this._transformTextureUrl||re||ae||pe||(I=this._transformTextureUrl(I)),k!==I&&(Y._originalUrl=k);var H=I.lastIndexOf("."),Z=K||(H>-1?I.substring(H).toLowerCase():""),X=null;Z.indexOf("?")>-1&&(Z=Z.split("?")[0]);for(var q=0,he=N._TextureLoaders;q<he.length;q++){var ge=he[q];if(ge.canLoad(Z,$)){X=ge;break}}j&&j._addPendingData(Y),Y.url=I,Y.generateMipMaps=!V,Y.samplingMode=ne,Y.invertY=W,this._doNotHandleContextLost||(Y._buffer=pe);var me=null;te&&!ae&&(me=Y.onLoadedObservable.add(te)),ae||this._internalTexturesCache.push(Y);var _e=function(ye,Be){j&&j._removePendingData(Y),I===k?(me&&Y.onLoadedObservable.remove(me),B.a.UseFallbackTexture&&G.createTexture(B.a.FallbackTexture,V,Y.invertY,j,ne,null,de,pe,Y),de&&de((ye||"Unknown error")+(B.a.UseFallbackTexture?" - Fallback texture was used":""),Be)):(E.a.Warn("Failed to load "+I+", falling back to "+k),G.createTexture(k,V,Y.invertY,j,ne,te,de,pe,Y,ee,K,$,L))};if(X){var be=function(ye){X.loadData(ye,Y,function(Be,Ge,Xe,He,We,Ze){Ze?_e("TextureLoader failed to load data"):G._prepareWebGLTexture(Y,j,Be,Ge,Y.invertY,!Xe,He,function(){return We(),!1},ne)},L)};pe?pe instanceof ArrayBuffer?be(new Uint8Array(pe)):ArrayBuffer.isView(pe)?be(pe):de&&de("Unable to load: only ArrayBuffer or ArrayBufferView is supported",null):this._loadFile(I,function(ye){return be(new 
29Uint8Array(ye))},void 0,j?j.offlineProvider:void 0,!0,function(ye,Be){_e("Unable to load "+(ye&&ye.responseURL,Be))})}else{var Ce=function(ye){oe&&!G._doNotHandleContextLost&&(Y._buffer=ye),G._prepareWebGLTexture(Y,j,ye.width,ye.height,Y.invertY,V,!1,function(Be,Ge,Xe){var He=G._gl,We=ye.width===Be&&ye.height===Ge,Ze=ee?G._getInternalFormat(ee):Z===".jpg"?He.RGB:He.RGBA;if(We)return He.texImage2D(He.TEXTURE_2D,0,Ze,Ze,He.UNSIGNED_BYTE,ye),!1;var ze=G._caps.maxTextureSize;if(ye.width>ze||ye.height>ze||!G._supportsHardwareTextureRescaling)return G._prepareWorkingCanvas(),!(!G._workingCanvas||!G._workingContext)&&(G._workingCanvas.width=Be,G._workingCanvas.height=Ge,G._workingContext.drawImage(ye,0,0,ye.width,ye.height,0,0,Be,Ge),He.texImage2D(He.TEXTURE_2D,0,Ze,Ze,He.UNSIGNED_BYTE,G._workingCanvas),Y.width=Be,Y.height=Ge,!1);var it=new c.a(G,c.b.Temp);return G._bindTextureDirectly(He.TEXTURE_2D,it,!0),He.texImage2D(He.TEXTURE_2D,0,Ze,Ze,He.UNSIGNED_BYTE,ye),G._rescaleTexture(it,Y,j,Ze,function(){G._releaseTexture(it),G._bindTextureDirectly(He.TEXTURE_2D,Y,!0),Xe()}),!0},ne)};!Q||re?pe&&(pe.decoding||pe.close)?Ce(pe):N._FileToolsLoadImage(I,Ce,_e,j?j.offlineProvider:null,$):typeof pe=="string"||pe instanceof ArrayBuffer||ArrayBuffer.isView(pe)||pe instanceof Blob?N._FileToolsLoadImage(pe,Ce,_e,j?j.offlineProvider:null,$):pe&&Ce(pe)}return Y},N._FileToolsLoadImage=function(I,V,W,j,ne){throw x.a.WarnImport("FileTools")},N.prototype._rescaleTexture=function(I,V,W,j,ne){},N.prototype.createRawTexture=function(I,V,W,j,ne,te,de,pe,ae){throw ae===void 0&&(ae=m.a.TEXTURETYPE_UNSIGNED_INT),x.a.WarnImport("Engine.RawTexture")},N.prototype.createRawCubeTexture=function(I,V,W,j,ne,te,de,pe){throw x.a.WarnImport("Engine.RawTexture")},N.prototype.createRawTexture3D=function(I,V,W,j,ne,te,de,pe,ae,ee){throw ee===void 0&&(ee=m.a.TEXTURETYPE_UNSIGNED_INT),x.a.WarnImport("Engine.RawTexture")},N.prototype.createRawTexture2DArray=function(I,V,W,j,ne,te,de,pe,ae,ee){throw ee===void 0&&(ee=m.a.TEXTURETYPE_UNSIGNED_INT),x.a.WarnImport("Engine.RawTexture")},N.prototype._unpackFlipY=function(I){this._unpackFlipYCached!==I&&(this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,I?1:0),this.enableUnpackFlipYCached&&(this._unpackFlipYCached=I))},N.prototype._getUnpackAlignement=function(){return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT)},N.prototype._getTextureTarget=function(I){return I.isCube?this._gl.TEXTURE_CUBE_MAP:I.is3D?this._gl.TEXTURE_3D:I.is2DArray||I.isMultiview?this._gl.TEXTURE_2D_ARRAY:this._gl.TEXTURE_2D},N.prototype.updateTextureSamplingMode=function(I,V,W){W===void 0&&(W=!1);var j=this._getTextureTarget(V),ne=this._getSamplingParameters(I,V.generateMipMaps||W);this._setTextureParameterInteger(j,this._gl.TEXTURE_MAG_FILTER,ne.mag,V),this._setTextureParameterInteger(j,this._gl.TEXTURE_MIN_FILTER,ne.min),W&&(V.generateMipMaps=!0,this._gl.generateMipmap(j)),this._bindTextureDirectly(j,null),V.samplingMode=I},N.prototype.updateTextureWrappingMode=function(I,V,W,j){W===void 0&&(W=null),j===void 0&&(j=null);var ne=this._getTextureTarget(I);V!==null&&(this._setTextureParameterInteger(ne,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(V),I),I._cachedWrapU=V),W!==null&&(this._setTextureParameterInteger(ne,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(W),I),I._cachedWrapV=W),(I.is2DArray||I.is3D)&&j!==null&&(this._setTextureParameterInteger(ne,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(j),I),I._cachedWrapR=j),this._bindTextureDirectly(ne,null)},N.prototype._setupDepthStencilTexture=function(I,V,W,j,ne){var te=V.width||V,de=V.height||V,pe=V.layers||0;I.baseWidth=te,I.baseHeight=de,I.width=te,I.height=de,I.is2DArray=pe>0,I.depth=pe,I.isReady=!0,I.samples=1,I.generateMipMaps=!1,I._generateDepthBuffer=!0,I._generateStencilBuffer=W,I.samplingMode=j?m.a.TEXTURE_BILINEAR_SAMPLINGMODE:m.a.TEXTURE_NEAREST_SAMPLINGMODE,I.type=m.a.TEXTURETYPE_UNSIGNED_INT,I._comparisonFunction=ne;var ae=this._gl,ee=this._getTextureTarget(I),K=this._getSamplingParameters(I.samplingMode,!1);ae.texParameteri(ee,ae.TEXTURE_MAG_FILTER,K.mag),ae.texParameteri(ee,ae.TEXTURE_MIN_FILTER,K.min),ae.texParameteri(ee,ae.TEXTURE_WRAP_S,ae.CLAMP_TO_EDGE),ae.texParameteri(ee,ae.TEXTURE_WRAP_T,ae.CLAMP_TO_EDGE),ne===0?(ae.texParameteri(ee,ae.TEXTURE_COMPARE_FUNC,m.a.LEQUAL),ae.texParameteri(ee,ae.TEXTURE_COMPARE_MODE,ae.NONE)):(ae.texParameteri(ee,ae.TEXTURE_COMPARE_FUNC,ne),ae.texParameteri(ee,ae.TEXTURE_COMPARE_MODE,ae.COMPARE_REF_TO_TEXTURE))},N.prototype._uploadCompressedDataToTextureDirectly=function(I,V,W,j,ne,te,de){te===void 0&&(te=0),de===void 0&&(de=0);
29var pe=this._gl,ae=pe.TEXTURE_2D;I.isCube&&(ae=pe.TEXTURE_CUBE_MAP_POSITIVE_X+te),this._gl.compressedTexImage2D(ae,de,V,W,j,0,ne)},N.prototype._uploadDataToTextureDirectly=function(I,V,W,j,ne,te){W===void 0&&(W=0),j===void 0&&(j=0),te===void 0&&(te=!1);var de=this._gl,pe=this._getWebGLTextureType(I.type),ae=this._getInternalFormat(I.format),ee=ne===void 0?this._getRGBABufferInternalSizedFormat(I.type,I.format):this._getInternalFormat(ne);this._unpackFlipY(I.invertY);var K=de.TEXTURE_2D;I.isCube&&(K=de.TEXTURE_CUBE_MAP_POSITIVE_X+W);var $=Math.round(Math.log(I.width)*Math.LOG2E),L=Math.round(Math.log(I.height)*Math.LOG2E),G=te?I.width:Math.pow(2,Math.max($-j,0)),Q=te?I.height:Math.pow(2,Math.max(L-j,0));de.texImage2D(K,j,ee,G,Q,0,ae,pe,V)},N.prototype.updateTextureData=function(I,V,W,j,ne,te,de,pe){de===void 0&&(de=0),pe===void 0&&(pe=0);var ae=this._gl,ee=this._getWebGLTextureType(I.type),K=this._getInternalFormat(I.format);this._unpackFlipY(I.invertY);var $=ae.TEXTURE_2D;I.isCube&&($=ae.TEXTURE_CUBE_MAP_POSITIVE_X+de),ae.texSubImage2D($,pe,W,j,ne,te,K,ee,V)},N.prototype._uploadArrayBufferViewToTexture=function(I,V,W,j){W===void 0&&(W=0),j===void 0&&(j=0);var ne=this._gl,te=I.isCube?ne.TEXTURE_CUBE_MAP:ne.TEXTURE_2D;this._bindTextureDirectly(te,I,!0),this._uploadDataToTextureDirectly(I,V,W,j),this._bindTextureDirectly(te,null,!0)},N.prototype._prepareWebGLTextureContinuation=function(I,V,W,j,ne){var te=this._gl;if(te){var de=this._getSamplingParameters(ne,!W);te.texParameteri(te.TEXTURE_2D,te.TEXTURE_MAG_FILTER,de.mag),te.texParameteri(te.TEXTURE_2D,te.TEXTURE_MIN_FILTER,de.min),W||j||te.generateMipmap(te.TEXTURE_2D),this._bindTextureDirectly(te.TEXTURE_2D,null),V&&V._removePendingData(I),I.onLoadedObservable.notifyObservers(I),I.onLoadedObservable.clear()}},N.prototype._prepareWebGLTexture=function(I,V,W,j,ne,te,de,pe,ae){var ee=this;ae===void 0&&(ae=m.a.TEXTURE_TRILINEAR_SAMPLINGMODE);var K=this.getCaps().maxTextureSize,$=Math.min(K,this.needPOTTextures?N.GetExponentOfTwo(W,K):W),L=Math.min(K,this.needPOTTextures?N.GetExponentOfTwo(j,K):j),G=this._gl;G&&(I._webGLTexture?(this._bindTextureDirectly(G.TEXTURE_2D,I,!0),this._unpackFlipY(ne===void 0||!!ne),I.baseWidth=W,I.baseHeight=j,I.width=$,I.height=L,I.isReady=!0,pe($,L,function(){ee._prepareWebGLTextureContinuation(I,V,te,de,ae)})||this._prepareWebGLTextureContinuation(I,V,te,de,ae)):V&&V._removePendingData(I))},N.prototype._setupFramebufferDepthAttachments=function(I,V,W,j,ne){ne===void 0&&(ne=1);var te=this._gl;if(I&&V)return this._getDepthStencilBuffer(W,j,ne,te.DEPTH_STENCIL,te.DEPTH24_STENCIL8,te.DEPTH_STENCIL_ATTACHMENT);if(V){var de=te.DEPTH_COMPONENT16;return this._webGLVersion>1&&(de=te.DEPTH_COMPONENT32F),this._getDepthStencilBuffer(W,j,ne,de,de,te.DEPTH_ATTACHMENT)}return I?this._getDepthStencilBuffer(W,j,ne,te.STENCIL_INDEX8,te.STENCIL_INDEX8,te.STENCIL_ATTACHMENT):null},N.prototype._releaseFramebufferObjects=function(I){var V=this._gl;I._framebuffer&&(V.deleteFramebuffer(I._framebuffer),I._framebuffer=null),I._depthStencilBuffer&&(V.deleteRenderbuffer(I._depthStencilBuffer),I._depthStencilBuffer=null),I._MSAAFramebuffer&&(V.deleteFramebuffer(I._MSAAFramebuffer),I._MSAAFramebuffer=null),I._MSAARenderBuffer&&(V.deleteRenderbuffer(I._MSAARenderBuffer),I._MSAARenderBuffer=null)},N.prototype._releaseTexture=function(I){this._releaseFramebufferObjects(I),this._deleteTexture(I._webGLTexture),this.unbindAllTextures();var V=this._internalTexturesCache.indexOf(I);V!==-1&&this._internalTexturesCache.splice(V,1),I._lodTextureHigh&&I._lodTextureHigh.dispose(),I._lodTextureMid&&I._lodTextureMid.dispose(),I._lodTextureLow&&I._lodTextureLow.dispose(),I._irradianceTexture&&I._irradianceTexture.dispose()},N.prototype._deleteTexture=function(I){this._gl.deleteTexture(I)},N.prototype._setProgram=function(I){this._currentProgram!==I&&(this._gl.useProgram(I),this._currentProgram=I)},N.prototype.bindSamplers=function(I){var V=I.getPipelineContext();this._setProgram(V.program);for(var W=I.getSamplers(),j=0;j<W.length;j++){var ne=I.getUniform(W[j]);ne&&(this._boundUniforms[j]=ne)}this._currentEffect=null},N.prototype._activateCurrentTexture=function(){this._currentTextureChannel!==this._activeChannel&&(this._gl.activeTexture(this._gl.TEXTURE0+this._activeChannel),this._currentTextureChannel=this._activeChannel)},N.prototype._bindTextureDirectly=function(I,V,W,j){W===void 0&&(W=!1),j===void 0&&(j=!1);var ne=!1,te=V&&V._associatedChannel>-1;return W&&te&&(this._activeChannel=V._associatedChannel),this._boundTexturesCache[this._activeChannel]!==V||j?(this._activateCurrentTexture(),V&&V.isMultiview?this._gl.bindTexture(I,V?V._colorTextureArray:null):this._gl.bindTexture(I,V?V._webGLTexture:null),this._boundTexturesCache[this._activeChannel]=V,V&&(V._associatedChannel=this._activeChannel)):W&&(ne=!0,this._activateCurrentTexture()),te&&!W&&this._bindSamplerUniformToChannel
29(V._associatedChannel,this._activeChannel),ne},N.prototype._bindTexture=function(I,V){if(I!==void 0){V&&(V._associatedChannel=I),this._activeChannel=I;var W=V?this._getTextureTarget(V):this._gl.TEXTURE_2D;this._bindTextureDirectly(W,V)}},N.prototype.unbindAllTextures=function(){for(var I=0;I<this._maxSimultaneousTextures;I++)this._activeChannel=I,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))},N.prototype.setTexture=function(I,V,W){I!==void 0&&(V&&(this._boundUniforms[I]=V),this._setTexture(I,W))},N.prototype._bindSamplerUniformToChannel=function(I,V){var W=this._boundUniforms[I];W&&W._currentState!==V&&(this._gl.uniform1i(W,V),W._currentState=V)},N.prototype._getTextureWrapMode=function(I){switch(I){case m.a.TEXTURE_WRAP_ADDRESSMODE:return this._gl.REPEAT;case m.a.TEXTURE_CLAMP_ADDRESSMODE:return this._gl.CLAMP_TO_EDGE;case m.a.TEXTURE_MIRROR_ADDRESSMODE:return this._gl.MIRRORED_REPEAT}return this._gl.REPEAT},N.prototype._setTexture=function(I,V,W,j){if(W===void 0&&(W=!1),j===void 0&&(j=!1),!V)return this._boundTexturesCache[I]!=null&&(this._activeChannel=I,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(V.video)this._activeChannel=I,V.update();else if(V.delayLoadState===m.a.DELAYLOADSTATE_NOTLOADED)return V.delayLoad(),!1;var ne;ne=j?V.depthStencilTexture:V.isReady()?V.getInternalTexture():V.isCube?this.emptyCubeTexture:V.is3D?this.emptyTexture3D:V.is2DArray?this.emptyTexture2DArray:this.emptyTexture,!W&&ne&&(ne._associatedChannel=I);var te=!0;this._boundTexturesCache[I]===ne&&(W||this._bindSamplerUniformToChannel(ne._associatedChannel,I),te=!1),this._activeChannel=I;var de=this._getTextureTarget(ne);if(te&&this._bindTextureDirectly(de,ne,W),ne&&!ne.isMultiview){if(ne.isCube&&ne._cachedCoordinatesMode!==V.coordinatesMode){ne._cachedCoordinatesMode=V.coordinatesMode;var pe=V.coordinatesMode!==m.a.TEXTURE_CUBIC_MODE&&V.coordinatesMode!==m.a.TEXTURE_SKYBOX_MODE?m.a.TEXTURE_WRAP_ADDRESSMODE:m.a.TEXTURE_CLAMP_ADDRESSMODE;V.wrapU=pe,V.wrapV=pe}ne._cachedWrapU!==V.wrapU&&(ne._cachedWrapU=V.wrapU,this._setTextureParameterInteger(de,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(V.wrapU),ne)),ne._cachedWrapV!==V.wrapV&&(ne._cachedWrapV=V.wrapV,this._setTextureParameterInteger(de,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(V.wrapV),ne)),ne.is3D&&ne._cachedWrapR!==V.wrapR&&(ne._cachedWrapR=V.wrapR,this._setTextureParameterInteger(de,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(V.wrapR),ne)),this._setAnisotropicLevel(de,ne,V.anisotropicFilteringLevel)}return!0},N.prototype.setTextureArray=function(I,V,W){if(I!==void 0&&V){this._textureUnits&&this._textureUnits.length===W.length||(this._textureUnits=new Int32Array(W.length));for(var j=0;j<W.length;j++){var ne=W[j].getInternalTexture();ne?(this._textureUnits[j]=I+j,ne._associatedChannel=I+j):this._textureUnits[j]=-1}this._gl.uniform1iv(V,this._textureUnits);for(var te=0;te<W.length;te++)this._setTexture(this._textureUnits[te],W[te],!0)}},N.prototype._setAnisotropicLevel=function(I,V,W){var j=this._caps.textureAnisotropicFilterExtension;V.samplingMode!==m.a.TEXTURE_LINEAR_LINEAR_MIPNEAREST&&V.samplingMode!==m.a.TEXTURE_LINEAR_LINEAR_MIPLINEAR&&V.samplingMode!==m.a.TEXTURE_LINEAR_LINEAR&&(W=1),j&&V._cachedAnisotropicFilteringLevel!==W&&(this._setTextureParameterFloat(I,j.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(W,this._caps.maxAnisotropy),V),V._cachedAnisotropicFilteringLevel=W)},N.prototype._setTextureParameterFloat=function(I,V,W,j){this._bindTextureDirectly(I,j,!0,!0),this._gl.texParameterf(I,V,W)},N.prototype._setTextureParameterInteger=function(I,V,W,j){j&&this._bindTextureDirectly(I,j,!0,!0),this._gl.texParameteri(I,V,W)},N.prototype.unbindAllAttributes=function(){if(this._mustWipeVertexAttributes){this._mustWipeVertexAttributes=!1;for(var I=0;I<this._caps.maxVertexAttribs;I++)this.disableAttributeByIndex(I)}else{I=0;for(var V=this._vertexAttribArraysEnabled.length;I<V;I++)I>=this._caps.maxVertexAttribs||!this._vertexAttribArraysEnabled[I]||this.disableAttributeByIndex(I)}},N.prototype.releaseEffects=function(){for(var I in this._compiledEffects){var V=this._compiledEffects[I].getPipelineContext();this._deletePipelineContext(V)}this._compiledEffects={}},N.prototype.dispose=function(){this.stopRenderLoop(),this.onBeforeTextureInitObservable&&this.onBeforeTextureInitObservable.clear(),this._emptyTexture&&(this._releaseTexture(this._emptyTexture),this._emptyTexture=null),this._emptyCubeTexture&&(this._releaseTexture(this._emptyCubeTexture),this._emptyCubeTexture=null),this._dummyFramebuffer&&this._gl.deleteFramebuffer(this._dummyFramebuffer),this.releaseEffects(),this.unbindAllAttributes(),this._boundUniforms=[],A.a.IsWindowObjectExist()&&this._renderingCanvas&&(this._doNotHandleContextLost||(this._renderingCanvas.removeEventListener("webglcontextlost",this._onContextLost),this._renderingCanvas.removeEventListener("webglcontextrestored",this._onContextRestored))),this._workingCanvas=null,this._workingContext=null,this._currentBufferPointers=[],this._renderingCanvas=null,this._currentProgram=null,this._boundRenderFunction=null,_.a.ResetCac
29he();for(var I=0,V=this._activeRequests;I<V.length;I++)V[I].abort()},N.prototype.attachContextLostEvent=function(I){this._renderingCanvas&&this._renderingCanvas.addEventListener("webglcontextlost",I,!1)},N.prototype.attachContextRestoredEvent=function(I){this._renderingCanvas&&this._renderingCanvas.addEventListener("webglcontextrestored",I,!1)},N.prototype.getError=function(){return this._gl.getError()},N.prototype._canRenderToFloatFramebuffer=function(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(m.a.TEXTURETYPE_FLOAT)},N.prototype._canRenderToHalfFloatFramebuffer=function(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(m.a.TEXTURETYPE_HALF_FLOAT)},N.prototype._canRenderToFramebuffer=function(I){for(var V=this._gl;V.getError()!==V.NO_ERROR;);var W=!0,j=V.createTexture();V.bindTexture(V.TEXTURE_2D,j),V.texImage2D(V.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(I),1,1,0,V.RGBA,this._getWebGLTextureType(I),null),V.texParameteri(V.TEXTURE_2D,V.TEXTURE_MIN_FILTER,V.NEAREST),V.texParameteri(V.TEXTURE_2D,V.TEXTURE_MAG_FILTER,V.NEAREST);var ne=V.createFramebuffer();V.bindFramebuffer(V.FRAMEBUFFER,ne),V.framebufferTexture2D(V.FRAMEBUFFER,V.COLOR_ATTACHMENT0,V.TEXTURE_2D,j,0);var te=V.checkFramebufferStatus(V.FRAMEBUFFER);if((W=(W=W&&te===V.FRAMEBUFFER_COMPLETE)&&V.getError()===V.NO_ERROR)&&(V.clear(V.COLOR_BUFFER_BIT),W=W&&V.getError()===V.NO_ERROR),W){V.bindFramebuffer(V.FRAMEBUFFER,null);var de=V.RGBA,pe=V.UNSIGNED_BYTE,ae=new Uint8Array(4);V.readPixels(0,0,1,1,de,pe,ae),W=W&&V.getError()===V.NO_ERROR}for(V.deleteTexture(j),V.deleteFramebuffer(ne),V.bindFramebuffer(V.FRAMEBUFFER,null);!W&&V.getError()!==V.NO_ERROR;);return W},N.prototype._getWebGLTextureType=function(I){if(this._webGLVersion===1){switch(I){case m.a.TEXTURETYPE_FLOAT:return this._gl.FLOAT;case m.a.TEXTURETYPE_HALF_FLOAT:return this._gl.HALF_FLOAT_OES;case m.a.TEXTURETYPE_UNSIGNED_BYTE:return this._gl.UNSIGNED_BYTE;case m.a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:return this._gl.UNSIGNED_SHORT_4_4_4_4;case m.a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:return this._gl.UNSIGNED_SHORT_5_5_5_1;case m.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:return this._gl.UNSIGNED_SHORT_5_6_5}return this._gl.UNSIGNED_BYTE}switch(I){case m.a.TEXTURETYPE_BYTE:return this._gl.BYTE;case m.a.TEXTURETYPE_UNSIGNED_BYTE:return this._gl.UNSIGNED_BYTE;case m.a.TEXTURETYPE_SHORT:return this._gl.SHORT;case m.a.TEXTURETYPE_UNSIGNED_SHORT:return this._gl.UNSIGNED_SHORT;case m.a.TEXTURETYPE_INT:return this._gl.INT;case m.a.TEXTURETYPE_UNSIGNED_INTEGER:return this._gl.UNSIGNED_INT;case m.a.TEXTURETYPE_FLOAT:return this._gl.FLOAT;case m.a.TEXTURETYPE_HALF_FLOAT:return this._gl.HALF_FLOAT;case m.a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:return this._gl.UNSIGNED_SHORT_4_4_4_4;case m.a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:return this._gl.UNSIGNED_SHORT_5_5_5_1;case m.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:return this._gl.UNSIGNED_SHORT_5_6_5;case m.a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:return this._gl.UNSIGNED_INT_2_10_10_10_REV;case m.a.TEXTURETYPE_UNSIGNED_INT_24_8:return this._gl.UNSIGNED_INT_24_8;case m.a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:return this._gl.UNSIGNED_INT_10F_11F_11F_REV;case m.a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:return this._gl.UNSIGNED_INT_5_9_9_9_REV;case m.a.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV}return this._gl.UNSIGNED_BYTE},N.prototype._getInternalFormat=function(I){var V=this._gl.RGBA;switch(I){case m.a.TEXTUREFORMAT_ALPHA:V=this._gl.ALPHA;break;case m.a.TEXTUREFORMAT_LUMINANCE:V=this._gl.LUMINANCE;break;case m.a.TEXTUREFORMAT_LUMINANCE_ALPHA:V=this._gl.LUMINANCE_ALPHA;break;case m.a.TEXTUREFORMAT_RED:V=this._gl.RED;break;case m.a.TEXTUREFORMAT_RG:V=this._gl.RG;break;case m.a.TEXTUREFORMAT_RGB:V=this._gl.RGB;break;case m.a.TEXTUREFORMAT_RGBA:V=this._gl.RGBA}if(this._webGLVersion>1)switch(I){case m.a.TEXTUREFORMAT_RED_INTEGER:V=this._gl.RED_INTEGER;break;case m.a.TEXTUREFORMAT_RG_INTEGER:V=this._gl.RG_INTEGER;break;case m.a.TEXTUREFORMAT_RGB_INTEGER:V=this._gl.RGB_INTEGER;break;case m.a.TEXTUREFORMAT_RGBA_INTEGER:V=this._gl.RGBA_INTEGER}return V},N.prototype._getRGBABufferInternalSizedFormat=function(I,V){if(this._webGLVersion===1){if(V!==void 0)switch(V){case m.a.TEXTUREFORMAT_ALPHA:return this._gl.ALPHA;case m.a.TEXTUREFORMAT_LUMINANCE:return this._gl.LUMINANCE;case m.a.TEXTUREFORMAT_LUMINANCE_ALPHA:return this._gl.LUMINANCE_ALPHA;case m.a.TEXTUREFORMAT_RGB:return this._gl.RGB}return this._gl.RGBA}switch(I){case m.a.TEXTURETYPE_BYTE:switch(V){case m.a.TEXTUREFORMAT_RED:return this._gl.R8_SNORM;case m.a.TEXTUREFORMAT_RG:return this._gl.RG8_SNORM;case m.a.TEXTUREFORMAT_RGB:return this._gl.RGB8_SNORM;case m.a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R8I;case m.a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG8I;case m.a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB8I;case m.a.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGBA8I;default:return this._gl.RGBA8_SNORM}case m.a.TEXTURETYPE_UNSIGNED_BYTE:switch(V){case m.a.TEXTUREFORMAT_RED:return this._gl.R8;case m.a.TEXTUREFORMAT_RG:return this._gl.RG8;case m.a.TEXTUREFORMAT_RGB:return this._gl.RGB8;case m.a.TEXTUREFORMAT_RGBA:return this._gl.RGBA8;case m.a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R8UI;case m.a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG8UI;case m.a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB8UI;case m.a.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGBA8UI;case m.a.TEXTUREFORMAT_ALPHA:return this._gl.ALPHA;case m.a.TEXTUREFORMAT_LUMINANCE:return this._gl.LUMINANCE;case m.a.TEXTUREFORMAT_LUMINANCE_ALPHA:return this._gl.LUMINANCE_ALPHA;default:return this._gl.RGBA8}case m.a.TEXTURETYPE_SHORT:switch(V){case m.a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R16I;case m.a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG16I;case m.a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB16I;case m.a.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA16I}case m.a.TEXTURETYPE_UNSIGNED_SHORT:switch(V){case m.a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R16UI;case m.a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG16UI;case m.a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB16UI;case m.a.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA16UI}case m.a.TEXTURETYPE_INT:switch(V){case m.a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R32I;case m.a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG32I;case m.a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB32I;case m.a.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA32I}case m.a.TEXTURETYPE_UNSIGNED_INTEGER:switch(V){case m.a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R32UI;case m.a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG32UI;case m.a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB32UI;case m.a.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA32UI}case m.a.TEXTURETYPE_FLOAT:switch(V){case m.a.TEXTUREFORMAT_RED:return this._gl.R32F;case m.a.TEXTUREFORMAT_RG:return this._gl.RG32F;case m.a.TEXTUREFORMAT_RGB:return this._gl.RGB32F;case m.a.TEXTUREFORMAT_RGBA:default:return this._gl.RGBA32F}case m.a.TEXTURETYPE_HALF_FLOAT:switch(V){case m.a.TEXTUREFORMAT_RED:return this._gl.R16F;case m.a.TEXTUREFORMAT_RG:return this._gl.RG16F;case m.a.TEXTUREFORMAT_RGB:return this._gl.RGB16F;case m.a.TEXTUREFORMAT_RGBA:default:return this._gl.RGBA16F}case m.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:return this._gl.RGB565;case m.a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:return this._gl.R11F_G11F_B10F;case m.a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:return this._gl.RGB9_E5;case m.a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:return this._gl.RGBA4;case m.a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:return this._gl.RGB5_A1;case m.a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:switch(V){case m.a.TEXTUREFORMAT_RGBA:return this._gl.RGB10_A2;case m.a.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGB10_A2UI;default:return this._gl.RGB10_A2}}return this._gl.RGBA8},N.prototype._getRGBAMultiSampleBufferFormat=function(I){return I===m.a.TEXTURETYPE_FLOAT?this._gl.RGBA32F:I===m.a.TEXTURETYPE_HALF_FLOAT?this._gl.RGBA16F:this._gl.RGBA8},N.prototype._loadFile=function(I,V,W,j,ne,te){var de=this,pe=N._FileToolsLoadFile(I,V,W,j,ne,te);return this._activeRequests.push(pe),pe.onCompleteObservable.add(function(ae){de._activeRequests.splice(de._activeRequests.indexOf(ae),1)}),pe},N._FileToolsLoadFile=function(I,V,W,j,ne,te){throw x.a.WarnImport("FileTools")},N.prototype.readPixels=function(I,V,W,j,ne){ne===void 0&&(ne=!0);
29var te=ne?4:3,de=ne?this._gl.RGBA:this._gl.RGB,pe=new Uint8Array(j*W*te);return this._gl.readPixels(I,V,W,j,de,this._gl.UNSIGNED_BYTE,pe),pe},Object.defineProperty(N,"IsSupported",{get:function(){return this.isSupported()},enumerable:!1,configurable:!0}),N.isSupported=function(){if(this._HasMajorPerformanceCaveat!==null)return!this._HasMajorPerformanceCaveat;if(this._IsSupported===null)try{var I=b.a.CreateCanvas(1,1),V=I.getContext("webgl")||I.getContext("experimental-webgl");this._IsSupported=V!=null&&!!window.WebGLRenderingContext}catch{this._IsSupported=!1}return this._IsSupported},Object.defineProperty(N,"HasMajorPerformanceCaveat",{get:function(){if(this._HasMajorPerformanceCaveat===null)try{var I=b.a.CreateCanvas(1,1),V=I.getContext("webgl",{failIfMajorPerformanceCaveat:!0})||I.getContext("experimental-webgl",{failIfMajorPerformanceCaveat:!0});this._HasMajorPerformanceCaveat=!V}catch{this._HasMajorPerformanceCaveat=!1}return this._HasMajorPerformanceCaveat},enumerable:!1,configurable:!0}),N.CeilingPOT=function(I){return I--,I|=I>>1,I|=I>>2,I|=I>>4,I|=I>>8,I|=I>>16,++I},N.FloorPOT=function(I){return I|=I>>1,I|=I>>2,I|=I>>4,I|=I>>8,(I|=I>>16)-(I>>1)},N.NearestPOT=function(I){var V=N.CeilingPOT(I),W=N.FloorPOT(I);return V-I>I-W?W:V},N.GetExponentOfTwo=function(I,V,W){var j;switch(W===void 0&&(W=m.a.SCALEMODE_NEAREST),W){case m.a.SCALEMODE_FLOOR:j=N.FloorPOT(I);break;case m.a.SCALEMODE_NEAREST:j=N.NearestPOT(I);break;case m.a.SCALEMODE_CEILING:default:j=N.CeilingPOT(I)}return Math.min(j,V)},N.QueueNewFrame=function(I,V){return A.a.IsWindowObjectExist()?(V||(V=window),V.requestPostAnimationFrame?V.requestPostAnimationFrame(I):V.requestAnimationFrame?V.requestAnimationFrame(I):V.msRequestAnimationFrame?V.msRequestAnimationFrame(I):V.webkitRequestAnimationFrame?V.webkitRequestAnimationFrame(I):V.mozRequestAnimationFrame?V.mozRequestAnimationFrame(I):V.oRequestAnimationFrame?V.oRequestAnimationFrame(I):window.setTimeout(I,16)):typeof requestAnimationFrame<"u"?requestAnimationFrame(I):setTimeout(I,16)},N.prototype.getHostDocument=function(){return this._renderingCanvas&&this._renderingCanvas.ownerDocument?this._renderingCanvas.ownerDocument:document},N.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"]}],N._TextureLoaders=[],N.CollisionsEpsilon=.001,N._IsSupported=null,N._HasMajorPerformanceCaveat=null,N}()},function(Ae,v,f){f.d(v,"b",function(){return B}),f.d(v,"a",function(){return R});var B,_=f(6),x=f(102),u=f(2),M=f(21);(function(C){C[C.Unknown=0]="Unknown",C[C.Url=1]="Url",C[C.Temp=2]="Temp",C[C.Raw=3]="Raw",C[C.Dynamic=4]="Dynamic",C[C.RenderTarget=5]="RenderTarget",C[C.MultiRenderTarget=6]="MultiRenderTarget",C[C.Cube=7]="Cube",C[C.CubeRaw=8]="CubeRaw",C[C.CubePrefiltered=9]="CubePrefiltered",C[C.Raw3D=10]="Raw3D",C[C.Raw2DArray=11]="Raw2DArray",C[C.Depth=12]="Depth",C[C.CubeRawRGBD=13]="CubeRawRGBD"})(B||(B={}));var R=function(){function C(m,c,E){E===void 0&&(E=!1),this.isReady=!1,this.isCube=!1,this.is3D=!1,this.is2DArray=!1,this.isMultiview=!1,this.url="",this.samplingMode=-1,this.generateMipMaps=!1,this.samples=0,this.type=-1,this.format=-1,this.onLoadedObservable=new _.c,this.width=0,this.height=0,this.depth=0,this.baseWidth=0,this.baseHeight=0,this.baseDepth=0,this.invertY=!1,this._invertVScale=!1,this._associatedChannel=-1,this._source=B.Unknown,this._buffer=null,this._bufferView=null,this._bufferViewArray=null,this._bufferViewArrayArray=null,this._size=0,this._extension="",this._files=null,this._workingCanvas=null,this._workingContext=null,this._framebuffer=null,this._depthStencilBuffer=null,this._MSAAFramebuffer=null,this._MSAARenderBuffer=null,this._attachments=null,this._textureArray=null,this._cachedCoordinatesMode=null,this._cachedWrapU=null,this._cachedWrapV=null,this._cachedWrapR=null,this._cachedAnisotropicFilteringLevel=null,this._isDisabled=!1,this._compression=null,this._generateStencilBuffer=!1,this._generateDepthBuffer=!1,this._comparisonFunction=0,this._sphericalPolynomial=null,this._lodGenerationScale=0,this._lodGenerationOffset=0,this._colorTextureArray=null,this._depthStencilTextureArray=null,this._lodTextureHigh=null,this._lodTextureMid=null,this._lodTextureLow=null,this._isRGBD=!1,this._linearSpecularLOD=!1,this._irradianceTexture=null,this._webGLTexture=null,this._references=1,this._gammaSpace=null,this._engine=m,this._source=c,E||(this._webGLTexture=m._createTexture())}return C.prototype.getEngine=function(){return this._engine},Object.defineProperty(C.prototype,"source",{get:function(){return this._source}
29,enumerable:!1,configurable:!0}),C.prototype.incrementReferences=function(){this._references++},C.prototype.updateSize=function(m,c,E){E===void 0&&(E=1),this.width=m,this.height=c,this.depth=E,this.baseWidth=m,this.baseHeight=c,this.baseDepth=E,this._size=m*c*E},C.prototype._rebuild=function(){var m,c,E=this;switch(this.isReady=!1,this._cachedCoordinatesMode=null,this._cachedWrapU=null,this._cachedWrapV=null,this._cachedAnisotropicFilteringLevel=null,this.source){case B.Temp:return;case B.Url:return void(c=this._engine.createTexture((m=this._originalUrl)!==null&&m!==void 0?m:this.url,!this.generateMipMaps,this.invertY,null,this.samplingMode,function(){c._swapAndDie(E),E.isReady=!0},null,this._buffer,void 0,this.format));case B.Raw:return(c=this._engine.createRawTexture(this._bufferView,this.baseWidth,this.baseHeight,this.format,this.generateMipMaps,this.invertY,this.samplingMode,this._compression))._swapAndDie(this),void(this.isReady=!0);case B.Raw3D:return(c=this._engine.createRawTexture3D(this._bufferView,this.baseWidth,this.baseHeight,this.baseDepth,this.format,this.generateMipMaps,this.invertY,this.samplingMode,this._compression))._swapAndDie(this),void(this.isReady=!0);case B.Raw2DArray:return(c=this._engine.createRawTexture2DArray(this._bufferView,this.baseWidth,this.baseHeight,this.baseDepth,this.format,this.generateMipMaps,this.invertY,this.samplingMode,this._compression))._swapAndDie(this),void(this.isReady=!0);case B.Dynamic:return(c=this._engine.createDynamicTexture(this.baseWidth,this.baseHeight,this.generateMipMaps,this.samplingMode))._swapAndDie(this),void this._engine.updateDynamicTexture(this,this._engine.getRenderingCanvas(),this.invertY,void 0,void 0,!0);case B.RenderTarget:var A=new x.a;if(A.generateDepthBuffer=this._generateDepthBuffer,A.generateMipMaps=this.generateMipMaps,A.generateStencilBuffer=this._generateStencilBuffer,A.samplingMode=this.samplingMode,A.type=this.type,this.isCube)c=this._engine.createRenderTargetCubeTexture(this.width,A);else{var S={width:this.width,height:this.height,layers:this.is2DArray?this.depth:void 0};c=this._engine.createRenderTargetTexture(S,A)}return c._swapAndDie(this),void(this.isReady=!0);case B.Depth:var g={bilinearFiltering:this.samplingMode!==u.a.TEXTURE_BILINEAR_SAMPLINGMODE,comparisonFunction:this._comparisonFunction,generateStencil:this._generateStencilBuffer,isCube:this.isCube},l={width:this.width,height:this.height,layers:this.is2DArray?this.depth:void 0};return(c=this._engine.createDepthStencilTexture(l,g))._swapAndDie(this),void(this.isReady=!0);case B.Cube:return void(c=this._engine.createCubeTexture(this.url,null,this._files,!this.generateMipMaps,function(){c._swapAndDie(E),E.isReady=!0},null,this.format,this._extension));case B.CubeRaw:return(c=this._engine.createRawCubeTexture(this._bufferViewArray,this.width,this.format,this.type,this.generateMipMaps,this.invertY,this.samplingMode,this._compression))._swapAndDie(this),void(this.isReady=!0);case B.CubeRawRGBD:return c=this._engine.createRawCubeTexture(null,this.width,this.format,this.type,this.generateMipMaps,this.invertY,this.samplingMode,this._compression),void C._UpdateRGBDAsync(c,this._bufferViewArrayArray,this._sphericalPolynomial,this._lodGenerationScale,this._lodGenerationOffset).then(function(){c._swapAndDie(E),E.isReady=!0});case B.CubePrefiltered:return void((c=this._engine.createPrefilteredCubeTexture(this.url,null,this._lodGenerationScale,this._lodGenerationOffset,function(h){h&&h._swapAndDie(E),E.isReady=!0},null,this.format,this._extension))._sphericalPolynomial=this._sphericalPolynomial)}},C.prototype._swapAndDie=function(m){m._webGLTexture=this._webGLTexture,m._isRGBD=this._isRGBD,this._framebuffer&&(m._framebuffer=this._framebuffer),this._depthStencilBuffer&&(m._depthStencilBuffer=this._depthStencilBuffer),m._depthStencilTexture=this._depthStencilTexture,this._lodTextureHigh&&(m._lodTextureHigh&&m._lodTextureHigh.dispose(),m._lodTextureHigh=this._lodTextureHigh),this._lodTextureMid&&(m._lodTextureMid&&m._lodTextureMid.dispose(),m._lodTextureMid=this._lodTextureMid),this._lodTextureLow&&(m._lodTextureLow&&m._lodTextureLow.dispose(),m._lodTextureLow=this._lodTextureLow),this._irradianceTexture&&(m._irradianceTexture&&m._irradianceTexture.dispose(),m._irradianceTexture=this._irradianceTexture);var c,E=this._engine.getLoadedTexturesCache();(c=E.indexOf(this))!==-1&&E.splice(c,1),(c=E.indexOf(m))===-1&&E.push(m)},C.prototype.dispose=function(){this._webGLTexture&&(this._references--,this._references===0&&(this._engine._releaseTexture(this),this._webGLTexture=null))},C._UpdateRGBDAsync=function(m,c,E,A,S){throw M.a.WarnImport("environmentTextureTools")},C}()},function(Ae,v,f){f.d(v,"b",function(){return B}),f.d(v,"c",function(){return _}),f.d(v,"a",function(){return x});var B=1/2.2,_=2.2,x=.001},function(Ae,v,f){f.d(v,"a",function(){return C});
29var B=f(1),_=f(0),x=f(3),u=f(6),M=f(22),R=f(21),C=function(){function m(c,E){E===void 0&&(E=null),this.state="",this.metadata=null,this.reservedDataStore=null,this._doNotSerialize=!1,this._isDisposed=!1,this.animations=new Array,this._ranges={},this.onReady=null,this._isEnabled=!0,this._isParentEnabled=!0,this._isReady=!0,this._currentRenderId=-1,this._parentUpdateId=-1,this._childUpdateId=-1,this._waitingParentId=null,this._cache={},this._parentNode=null,this._children=null,this._worldMatrix=_.a.Identity(),this._worldMatrixDeterminant=0,this._worldMatrixDeterminantIsDirty=!0,this._sceneRootNodesIndex=-1,this._animationPropertiesOverride=null,this._isNode=!0,this.onDisposeObservable=new u.c,this._onDisposeObserver=null,this._behaviors=new Array,this.name=c,this.id=c,this._scene=E||M.a.LastCreatedScene,this.uniqueId=this._scene.getUniqueId(),this._initCache()}return m.AddNodeConstructor=function(c,E){this._NodeConstructors[c]=E},m.Construct=function(c,E,A,S){var g=this._NodeConstructors[c];return g?g(E,A,S):null},Object.defineProperty(m.prototype,"doNotSerialize",{get:function(){return!!this._doNotSerialize||!!this._parentNode&&this._parentNode.doNotSerialize},set:function(c){this._doNotSerialize=c},enumerable:!1,configurable:!0}),m.prototype.isDisposed=function(){return this._isDisposed},Object.defineProperty(m.prototype,"parent",{get:function(){return this._parentNode},set:function(c){if(this._parentNode!==c){var E=this._parentNode;if(this._parentNode&&this._parentNode._children!==void 0&&this._parentNode._children!==null){var A=this._parentNode._children.indexOf(this);A!==-1&&this._parentNode._children.splice(A,1),c||this._isDisposed||this._addToSceneRootNodes()}this._parentNode=c,this._parentNode&&(this._parentNode._children!==void 0&&this._parentNode._children!==null||(this._parentNode._children=new Array),this._parentNode._children.push(this),E||this._removeFromSceneRootNodes()),this._syncParentEnabledState()}},enumerable:!1,configurable:!0}),m.prototype._addToSceneRootNodes=function(){this._sceneRootNodesIndex===-1&&(this._sceneRootNodesIndex=this._scene.rootNodes.length,this._scene.rootNodes.push(this))},m.prototype._removeFromSceneRootNodes=function(){if(this._sceneRootNodesIndex!==-1){var c=this._scene.rootNodes,E=c.length-1;c[this._sceneRootNodesIndex]=c[E],c[this._sceneRootNodesIndex]._sceneRootNodesIndex=this._sceneRootNodesIndex,this._scene.rootNodes.pop(),this._sceneRootNodesIndex=-1}},Object.defineProperty(m.prototype,"animationPropertiesOverride",{get:function(){return this._animationPropertiesOverride?this._animationPropertiesOverride:this._scene.animationPropertiesOverride},set:function(c){this._animationPropertiesOverride=c},enumerable:!1,configurable:!0}),m.prototype.getClassName=function(){return"Node"},Object.defineProperty(m.prototype,"onDispose",{set:function(c){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(c)},enumerable:!1,configurable:!0}),m.prototype.getScene=function(){return this._scene},m.prototype.getEngine=function(){return this._scene.getEngine()},m.prototype.addBehavior=function(c,E){var A=this;return E===void 0&&(E=!1),this._behaviors.indexOf(c)!==-1||(c.init(),this._scene.isLoading&&!E?this._scene.onDataLoadedObservable.addOnce(function(){c.attach(A)}):c.attach(this),this._behaviors.push(c)),this},m.prototype.removeBehavior=function(c){var E=this._behaviors.indexOf(c);return E===-1||(this._behaviors[E].detach(),this._behaviors.splice(E,1)),this},Object.defineProperty(m.prototype,"behaviors",{get:function(){return this._behaviors},enumerable:!1,configurable:!0}),m.prototype.getBehaviorByName=function(c){for(var E=0,A=this._behaviors;E<A.length;E++){var S=A[E];if(S.name===c)return S}return null},m.prototype.getWorldMatrix=function(){return this._currentRenderId!==this._scene.getRenderId()&&this.computeWorldMatrix(),this._worldMatrix},m.prototype._getWorldMatrixDeterminant=function(){return this._worldMatrixDeterminantIsDirty&&(this._worldMatrixDeterminantIsDirty=!1,this._worldMatrixDeterminant=this._worldMatrix.determinant()),this._worldMatrixDeterminant},Object.defineProperty(m.prototype,"worldMatrixFromCache",{get:function(){return this._worldMatrix}
29,enumerable:!1,configurable:!0}),m.prototype._initCache=function(){this._cache={},this._cache.parent=void 0},m.prototype.updateCache=function(c){!c&&this.isSynchronized()||(this._cache.parent=this.parent,this._updateCache())},m.prototype._getActionManagerForTrigger=function(c,E){return this.parent?this.parent._getActionManagerForTrigger(c,!1):null},m.prototype._updateCache=function(c){},m.prototype._isSynchronized=function(){return!0},m.prototype._markSyncedWithParent=function(){this._parentNode&&(this._parentUpdateId=this._parentNode._childUpdateId)},m.prototype.isSynchronizedWithParent=function(){return!this._parentNode||this._parentUpdateId===this._parentNode._childUpdateId&&this._parentNode.isSynchronized()},m.prototype.isSynchronized=function(){return this._cache.parent!=this._parentNode?(this._cache.parent=this._parentNode,!1):!(this._parentNode&&!this.isSynchronizedWithParent())&&this._isSynchronized()},m.prototype.isReady=function(c){return this._isReady},m.prototype.isEnabled=function(c){return c===void 0&&(c=!0),c===!1?this._isEnabled:!!this._isEnabled&&this._isParentEnabled},m.prototype._syncParentEnabledState=function(){this._isParentEnabled=!this._parentNode||this._parentNode.isEnabled(),this._children&&this._children.forEach(function(c){c._syncParentEnabledState()})},m.prototype.setEnabled=function(c){this._isEnabled=c,this._syncParentEnabledState()},m.prototype.isDescendantOf=function(c){return!!this.parent&&(this.parent===c||this.parent.isDescendantOf(c))},m.prototype._getDescendants=function(c,E,A){if(E===void 0&&(E=!1),this._children)for(var S=0;S<this._children.length;S++){var g=this._children[S];A&&!A(g)||c.push(g),E||g._getDescendants(c,!1,A)}},m.prototype.getDescendants=function(c,E){var A=new Array;return this._getDescendants(A,c,E),A},m.prototype.getChildMeshes=function(c,E){var A=[];return this._getDescendants(A,c,function(S){return(!E||E(S))&&S.cullingStrategy!==void 0}),A},m.prototype.getChildren=function(c,E){return E===void 0&&(E=!0),this.getDescendants(E,c)},m.prototype._setReady=function(c){c!==this._isReady&&(c?(this.onReady&&this.onReady(this),this._isReady=!0):this._isReady=!1)},m.prototype.getAnimationByName=function(c){for(var E=0;E<this.animations.length;E++){var A=this.animations[E];if(A.name===c)return A}return null},m.prototype.createAnimationRange=function(c,E,A){if(!this._ranges[c]){this._ranges[c]=m._AnimationRangeFactory(c,E,A);for(var S=0,g=this.animations.length;S<g;S++)this.animations[S]&&this.animations[S].createRange(c,E,A)}},m.prototype.deleteAnimationRange=function(c,E){E===void 0&&(E=!0);for(var A=0,S=this.animations.length;A<S;A++)this.animations[A]&&this.animations[A].deleteRange(c,E);this._ranges[c]=null},m.prototype.getAnimationRange=function(c){return this._ranges[c]||null},m.prototype.getAnimationRanges=function(){var c,E=[];for(c in this._ranges)E.push(this._ranges[c]);return E},m.prototype.beginAnimation=function(c,E,A,S){var g=this.getAnimationRange(c);return g?this._scene.beginAnimation(this,g.from,g.to,E,A,S):null},m.prototype.serializeAnimationRanges=function(){var c=[];for(var E in this._ranges){var A=this._ranges[E];if(A){var S={};S.name=E,S.from=A.from,S.to=A.to,c.push(S)}}return c},m.prototype.computeWorldMatrix=function(c){return this._worldMatrix||(this._worldMatrix=_.a.Identity()),this._worldMatrix},m.prototype.dispose=function(c,E){if(E===void 0&&(E=!1),this._isDisposed=!0,!c)for(var A=0,S=this.getDescendants(!0);A<S.length;A++)S[A].dispose(c,E);this.parent?this.parent=null:this._removeFromSceneRootNodes(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear();for(var g=0,l=this._behaviors;g<l.length;g++)l[g].detach();this._behaviors=[]},m.ParseAnimationRanges=function(c,E,A){if(E.ranges)for(var S=0;S<E.ranges.length;S++){var g=E.ranges[S];c.createAnimationRange(g.name,g.from,g.to)}},m.prototype.getHierarchyBoundingVectors=function(c,E){var A,S;if(c===void 0&&(c=!0),E===void 0&&(E=null),this.getScene().incrementRenderId(),this.computeWorldMatrix(!0),this.getBoundingInfo&&this.subMeshes){var g=this.getBoundingInfo();
29A=g.boundingBox.minimumWorld.clone(),S=g.boundingBox.maximumWorld.clone()}else A=new _.e(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),S=new _.e(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);if(c)for(var l=0,h=this.getDescendants(!1);l<h.length;l++){var b=h[l];if(b.computeWorldMatrix(!0),(!E||E(b))&&b.getBoundingInfo&&b.getTotalVertices()!==0){var T=b.getBoundingInfo().boundingBox,D=T.minimumWorld,w=T.maximumWorld;_.e.CheckExtends(D,A,S),_.e.CheckExtends(w,A,S)}}return{min:A,max:S}},m._AnimationRangeFactory=function(c,E,A){throw R.a.WarnImport("AnimationRange")},m._NodeConstructors={},Object(B.c)([Object(x.c)()],m.prototype,"name",void 0),Object(B.c)([Object(x.c)()],m.prototype,"id",void 0),Object(B.c)([Object(x.c)()],m.prototype,"uniqueId",void 0),Object(B.c)([Object(x.c)()],m.prototype,"state",void 0),Object(B.c)([Object(x.c)()],m.prototype,"metadata",void 0),m}()},function(Ae,v,f){f.d(v,"b",function(){return de}),f.d(v,"a",function(){return pe});var B=f(1),_=f(3),x=f(33),u=f(20),M=f(0),R=f(9),C=f(4),m=f(105),c=f(42),E=f(25),A=f(76),S=f(87),g=f(15),l=f(10),h=f(11),b=f(19),T=f(5),D=`uniform vec4 vDiffuseColor;
30#ifdef SPECULARTERM
31uniform vec4 vSpecularColor;
32#endif
33uniform vec3 vEmissiveColor;
34uniform float visibility;
35
36#ifdef DIFFUSE
37uniform vec2 vDiffuseInfos;
38#endif
39#ifdef AMBIENT
40uniform vec2 vAmbientInfos;
41#endif
42#ifdef OPACITY
43uniform vec2 vOpacityInfos;
44#endif
45#ifdef EMISSIVE
46uniform vec2 vEmissiveInfos;
47#endif
48#ifdef LIGHTMAP
49uniform vec2 vLightmapInfos;
50#endif
51#ifdef BUMP
52uniform vec3 vBumpInfos;
53uniform vec2 vTangentSpaceParams;
54#endif
55#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)
56uniform mat4 view;
57#endif
58#ifdef REFRACTION
59uniform vec4 vRefractionInfos;
60#ifndef REFRACTIONMAP_3D
61uniform mat4 refractionMatrix;
62#endif
63#ifdef REFRACTIONFRESNEL
64uniform vec4 refractionLeftColor;
65uniform vec4 refractionRightColor;
66#endif
67#endif
68#if defined(SPECULAR) && defined(SPECULARTERM)
69uniform vec2 vSpecularInfos;
70#endif
71#ifdef DIFFUSEFRESNEL
72uniform vec4 diffuseLeftColor;
73uniform vec4 diffuseRightColor;
74#endif
75#ifdef OPACITYFRESNEL
76uniform vec4 opacityParts;
77#endif
78#ifdef EMISSIVEFRESNEL
79uniform vec4 emissiveLeftColor;
80uniform vec4 emissiveRightColor;
81#endif
82
83#ifdef REFLECTION
84uniform vec2 vReflectionInfos;
85#if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION) || defined(REFLECTIONMAP_EQUIRECTANGULAR) || defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_SKYBOX)
86uniform mat4 reflectionMatrix;
87#endif
88#ifndef REFLECTIONMAP_SKYBOX
89#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)
90uniform vec3 vReflectionPosition;
91uniform vec3 vReflectionSize;
92#endif
93#endif
94#ifdef REFLECTIONFRESNEL
95uniform vec4 reflectionLeftColor;
96uniform vec4 reflectionRightColor;
97#endif
98#endif`;T.a.IncludesShadersStore.defaultFragmentDeclaration=D;var w=`layout(std140,column_major) uniform;
99uniform Material
100{
101vec4 diffuseLeftColor;
102vec4 diffuseRightColor;
103vec4 opacityParts;
104vec4 reflectionLeftColor;
105vec4 reflectionRightColor;
106vec4 refractionLeftColor;
107vec4 refractionRightColor;
108vec4 emissiveLeftColor;
109vec4 emissiveRightColor;
110vec2 vDiffuseInfos;
111vec2 vAmbientInfos;
112vec2 vOpacityInfos;
113vec2 vReflectionInfos;
114vec3 vReflectionPosition;
115vec3 vReflectionSize;
116vec2 vEmissiveInfos;
117vec2 vLightmapInfos;
118vec2 vSpecularInfos;
119vec3 vBumpInfos;
120mat4 diffuseMatrix;
121mat4 ambientMatrix;
122mat4 opacityMatrix;
123mat4 reflectionMatrix;
124mat4 emissiveMatrix;
125mat4 lightmapMatrix;
126mat4 specularMatrix;
127mat4 bumpMatrix;
128vec2 vTangentSpaceParams;
129float pointSize;
130mat4 refractionMatrix;
131vec4 vRefractionInfos;
132vec4 vSpecularColor;
133vec3 vEmissiveColor;
134float visibility;
135vec4 vDiffuseColor;
136vec4 vDetailInfos;
137mat4 detailMatrix;
138};
139uniform Scene {
140mat4 viewProjection;
141#ifdef MULTIVIEW
142mat4 viewProjectionR;
143#endif
144mat4 view;
145};
146`;T.a.IncludesShadersStore.defaultUboDeclaration=w,f(160),f(59),f(106),f(107),f(154),f(130),f(161),f(131),f(108),f(109),f(132),f(133),f(115),f(116),f(125),f(110),f(134),f(162),f(135),f(155),f(136);var N=`#include<__decl__defaultFragment>
147#if defined(BUMP) || !defined(NORMAL)
148#extension GL_OES_standard_derivatives : enable
149#endif
150#include<prePassDeclaration>[SCENE_MRT_COUNT]
151#define CUSTOM_FRAGMENT_BEGIN
152#ifdef LOGARITHMICDEPTH
153#extension GL_EXT_frag_depth : enable
154#endif
155
156#define RECIPROCAL_PI2 0.15915494
157uniform vec3 vEyePosition;
158uniform vec3 vAmbientColor;
159
160varying vec3 vPositionW;
161#ifdef NORMAL
162varying vec3 vNormalW;
163#endif
164#ifdef VERTEXCOLOR
165varying vec4 vColor;
166#endif
167#ifdef MAINUV1
168varying vec2 vMainUV1;
169#endif
170#ifdef MAINUV2
171varying vec2 vMainUV2;
172#endif
173
174#include<helperFunctions>
175
176#include<__decl__lightFragment>[0..maxSimultaneousLights]
177#include<lightsFragmentFunctions>
178#include<shadowsFragmentFunctions>
179
180#ifdef DIFFUSE
181#if DIFFUSEDIRECTUV == 1
182#define vDiffuseUV vMainUV1
183#elif DIFFUSEDIRECTUV == 2
184#define vDiffuseUV vMainUV2
185#else
186varying vec2 vDiffuseUV;
187#endif
188uniform sampler2D diffuseSampler;
189#endif
190#ifdef AMBIENT
191#if AMBIENTDIRECTUV == 1
192#define vAmbientUV vMainUV1
193#elif AMBIENTDIRECTUV == 2
194#define vAmbientUV vMainUV2
195#else
196varying vec2 vAmbientUV;
197#endif
198uniform sampler2D ambientSampler;
199#endif
200#ifdef OPACITY
201#if OPACITYDIRECTUV == 1
202#define vOpacityUV vMainUV1
203#elif OPACITYDIRECTUV == 2
204#define vOpacityUV vMainUV2
205#else
206varying vec2 vOpacityUV;
207#endif
208uniform sampler2D opacitySampler;
209#endif
210#ifdef EMISSIVE
211#if EMISSIVEDIRECTUV == 1
212#define vEmissiveUV vMainUV1
213#elif EMISSIVEDIRECTUV == 2
214#define vEmissiveUV vMainUV2
215#else
216varying vec2 vEmissiveUV;
217#endif
218uniform sampler2D emissiveSampler;
219#endif
220#ifdef LIGHTMAP
221#if LIGHTMAPDIRECTUV == 1
222#define vLightmapUV vMainUV1
223#elif LIGHTMAPDIRECTUV == 2
224#define vLightmapUV vMainUV2
225#else
226varying vec2 vLightmapUV;
227#endif
228uniform sampler2D lightmapSampler;
229#endif
230#ifdef REFRACTION
231#ifdef REFRACTIONMAP_3D
232uniform samplerCube refractionCubeSampler;
233#else
234uniform sampler2D refraction2DSampler;
235#endif
236#endif
237#if defined(SPECULAR) && defined(SPECULARTERM)
238#if SPECULARDIRECTUV == 1
239#define vSpecularUV vMainUV1
240#elif SPECULARDIRECTUV == 2
241#define vSpecularUV vMainUV2
242#else
243varying vec2 vSpecularUV;
244#endif
245uniform sampler2D specularSampler;
246#endif
247#ifdef ALPHATEST
248uniform float alphaCutOff;
249#endif
250
251#include<fresnelFunction>
252
253#ifdef REFLECTION
254#ifdef REFLECTIONMAP_3D
255uniform samplerCube reflectionCubeSampler;
256#else
257uniform sampler2D reflection2DSampler;
258#endif
259#ifdef REFLECTIONMAP_SKYBOX
260varying vec3 vPositionUVW;
261#else
262#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
263varying vec3 vDirectionW;
264#endif
265#endif
266#include<reflectionFunction>
267#endif
268#include<imageProcessingDeclaration>
269#include<imageProcessingFunctions>
270#include<bumpFragmentMainFunctions>
271#include<bumpFragmentFunctions>
272#include<clipPlaneFragmentDeclaration>
273#include<logDepthDeclaration>
274#include<fogFragmentDeclaration>
275#define CUSTOM_FRAGMENT_DEFINITIONS
276void main(void) {
277#define CUSTOM_FRAGMENT_MAIN_BEGIN
278#include<clipPlaneFragment>
279vec3 viewDirectionW=normalize(vEyePosition-vPositionW);
280
281vec4 baseColor=vec4(1.,1.,1.,1.);
282vec3 diffuseColor=vDiffuseColor.rgb;
283
284float alpha=vDiffuseColor.a;
285
286#ifdef NORMAL
287vec3 normalW=normalize(vNormalW);
288#else
289vec3 normalW=normalize(-cross(dFdx(vPositionW),dFdy(vPositionW)));
290#endif
291#include<bumpFragment>
292#ifdef TWOSIDEDLIGHTING
293normalW=gl_FrontFacing ? normalW : -normalW;
294#endif
295#ifdef DIFFUSE
296baseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);
297#if defined(ALPHATEST) && !defined(ALPHATEST_AFTERALLALPHACOMPUTATIONS)
298if (baseColor.a<alphaCutOff)
299discard;
300#endif
301#ifdef ALPHAFROMDIFFUSE
302alpha*=baseColor.a;
303#endif
304#define CUSTOM_FRAGMENT_UPDATE_ALPHA
305baseColor.rgb*=vDiffuseInfos.y;
306#endif
307#include<depthPrePass>
308#ifdef VERTEXCOLOR
309baseColor.rgb*=vColor.rgb;
310#endif
311#ifdef DETAIL
312baseColor.rgb=baseColor.rgb*2.0*mix(0.5,detailColor.r,vDetailInfos.y);
313#endif
314#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE
315
316vec3 baseAmbientColor=vec3(1.,1.,1.);
317#ifdef AMBIENT
318baseAmbientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;
319#endif
320#define CUSTOM_FRAGMENT_BEFORE_LIGHTS
321
322#ifdef SPECULARTERM
323float glossiness=vSpecularColor.a;
324vec3 specularColor=vSpecularColor.rgb;
325#ifdef SPECULAR
326vec4 specularMapColor=texture2D(specularSampler,vSpecularUV+uvOffset);
327specularColor=specularMapColor.rgb;
328#ifdef GLOSSINESS
329glossiness=glossiness*specularMapColor.a;
330#endif
331#endif
332#else
333float glossiness=0.;
334#endif
335
336vec3 diffuseBase=vec3(0.,0.,0.);
337lightingInfo info;
338#ifdef SPECULARTERM
339vec3 specularBase=vec3(0.,0.,0.);
340#endif
341float shadow=1.;
342#ifdef LIGHTMAP
343vec4 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset);
344#ifdef RGBDLIGHTMAP
345lightmapColor.rgb=fromRGBD(lightmapColor);
346#endif
347lightmapColor.rgb*=vLightmapInfos.y;
348#endif
349#include<lightFragment>[0..maxSimultaneousLights]
350
351vec4 refractionColor=vec4(0.,0.,0.,1.);
352#ifdef REFRACTION
353vec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y));
354#ifdef REFRACTIONMAP_3D
355refractionVector.y=refractionVector.y*vRefractionInfos.w;
356if (dot(refractionVector,viewDirectionW)<1.0) {
357refractionColor=textureCube(refractionCubeSampler,refractionVector);
358}
359#else
360vec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));
361vec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;
362refractionCoords.y=1.0-refractionCoords.y;
363refractionColor=texture2D(refraction2DSampler,refractionCoords);
364#endif
365#ifdef RGBDREFRACTION
366refractionColor.rgb=fromRGBD(refractionColor);
367#endif
368#ifdef IS_REFRACTION_LINEAR
369refractionColor.rgb=toGammaSpace(refractionColor.rgb);
370#endif
371refractionColor.rgb*=vRefractionInfos.x;
372#endif
373
374vec4 reflectionColor=vec4(0.,0.,0.,1.);
375#ifdef REFLECTION
376vec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);
377#ifdef REFLECTIONMAP_3D
378#ifdef ROUGHNESS
379float bias=vReflectionInfos.y;
380#ifdef SPECULARTERM
381#ifdef SPECULAR
382#ifdef GLOSSINESS
383bias*=(1.0-specularMapColor.a);
384#endif
385#endif
386#endif
387reflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias);
388#else
389reflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW);
390#endif
391#else
392vec2 coords=vReflectionUVW.xy;
393#ifdef REFLECTIONMAP_PROJECTION
394coords/=vReflectionUVW.z;
395#endif
396coords.y=1.0-coords.y;
397reflectionColor=texture2D(reflection2DSampler,coords);
398#endif
399#ifdef RGBDREFLECTION
400reflectionColor.rgb=fromRGBD(reflectionColor);
401#endif
402#ifdef IS_REFLECTION_LINEAR
403reflectionColor.rgb=toGammaSpace(reflectionColor.rgb);
404#endif
405reflectionColor.rgb*=vReflectionInfos.x;
406#ifdef REFLECTIONFRESNEL
407float reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a);
408#ifdef REFLECTIONFRESNELFROMSPECULAR
409#ifdef SPECULARTERM
410reflectionColor.rgb*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;
411#else
412reflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;
413#endif
414#else
415reflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;
416#endif
417#endif
418#endif
419#ifdef REFRACTIONFRESNEL
420float refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a);
421refractionColor.rgb*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb;
422#endif
423#ifdef OPACITY
424vec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);
425#ifdef OPACITYRGB
426opacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);
427alpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;
428#else
429alpha*=opacityMap.a*vOpacityInfos.y;
430#endif
431#endif
432#ifdef VERTEXALPHA
433alpha*=vColor.a;
434#endif
435#ifdef OPACITYFRESNEL
436float opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);
437alpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y;
438#endif
439#ifdef ALPHATEST
440#ifdef ALPHATEST_AFTERALLALPHACOMPUTATIONS
441if (alpha<alphaCutOff)
442discard;
443#endif
444#ifndef ALPHABLEND
445
446alpha=1.0;
447#endif
448#endif
449
450vec3 emissiveColor=vEmissiveColor;
451#ifdef EMISSIVE
452emissiveColor+=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb*vEmissiveInfos.y;
453#endif
454#ifdef EMISSIVEFRESNEL
455float emissiveFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,emissiveRightColor.a,emissiveLeftColor.a);
456emissiveColor*=emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*emissiveRightColor.rgb;
457#endif
458
459#ifdef DIFFUSEFRESNEL
460float diffuseFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,diffuseRightColor.a,diffuseLeftColor.a);
461diffuseBase*=diffuseLeftColor.rgb*(1.0-diffuseFresnelTerm)+diffuseFresnelTerm*diffuseRightColor.rgb;
462#endif
463
464#ifdef EMISSIVEASILLUMINATION
465vec3 finalDiffuse=clamp(diffuseBase*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;
466#else
467#ifdef LINKEMISSIVEWITHDIFFUSE
468vec3 finalDiffuse=clamp((diffuseBase+emissiveColor)*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;
469#else
470vec3 finalDiffuse=clamp(diffuseBase*diffuseColor+emissiveColor+vAmbientColor,0.0,1.0)*baseColor.rgb;
471#endif
472#endif
473#ifdef SPECULARTERM
474vec3 finalSpecular=specularBase*specularColor;
475#ifdef SPECULAROVERALPHA
476alpha=clamp(alpha+dot(finalSpecular,vec3(0.3,0.59,0.11)),0.,1.);
477#endif
478#else
479vec3 finalSpecular=vec3(0.0);
480#endif
481#ifdef REFLECTIONOVERALPHA
482alpha=clamp(alpha+dot(reflectionColor.rgb,vec3(0.3,0.59,0.11)),0.,1.);
483#endif
484
485#ifdef EMISSIVEASILLUMINATION
486vec4 color=vec4(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor.rgb+emissiveColor+refractionColor.rgb,0.0,1.0),alpha);
487#else
488vec4 color=vec4(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor.rgb+refractionColor.rgb,alpha);
489#endif
490
491#ifdef LIGHTMAP
492#ifndef LIGHTMAPEXCLUDED
493#ifdef USELIGHTMAPASSHADOWMAP
494color.rgb*=lightmapColor.rgb;
495#else
496color.rgb+=lightmapColor.rgb;
497#endif
498#endif
499#endif
500#define CUSTOM_FRAGMENT_BEFORE_FOG
501color.rgb=max(color.rgb,0.);
502#include<logDepthFragment>
503#include<fogFragment>
504
505
506#ifdef IMAGEPROCESSINGPOSTPROCESS
507color.rgb=toLinearSpace(color.rgb);
508#else
509#ifdef IMAGEPROCESSING
510color.rgb=toLinearSpace(color.rgb);
511color=applyImageProcessing(color);
512#endif
513#endif
514color.a*=visibility;
515#ifdef PREMULTIPLYALPHA
516
517color.rgb*=color.a;
518#endif
519#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR
520#ifdef PREPASS
521gl_FragData[0]=color;
522#ifdef PREPASS_POSITION
523gl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,1.0);
524#endif
525#ifdef PREPASS_VELOCITY
526vec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;
527vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;
528vec2 velocity=abs(a-b);
529velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;
530gl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,1.0);
531#endif
532#ifdef PREPASS_IRRADIANCE
533gl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(0.0,0.0,0.0,1.0);
534#endif
535#ifdef PREPASS_DEPTHNORMAL
536gl_FragData[PREPASS_DEPTHNORMAL_INDEX]=vec4(vViewPos.z,(view*vec4(normalW,0.0)).rgb);
537#endif
538#ifdef PREPASS_ALBEDO
539gl_FragData[PREPASS_ALBEDO_INDEX]=vec4(0.0,0.0,0.0,1.0);
540#endif
541#ifdef PREPASS_REFLECTIVITY
542#if defined(SPECULAR)
543gl_FragData[PREPASS_REFLECTIVITY_INDEX]=specularMapColor;
544#else
545gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(0.0,0.0,0.0,1.0);
546#endif
547#endif
548#endif
549#if !defined(PREPASS) || defined(WEBGL2)
550gl_FragColor=color;
551#endif
552}
553`;T.a.ShadersStore.defaultPixelShader=N;var I=`
554uniform mat4 viewProjection;
555uniform mat4 view;
556#ifdef DIFFUSE
557uniform mat4 diffuseMatrix;
558uniform vec2 vDiffuseInfos;
559#endif
560#ifdef AMBIENT
561uniform mat4 ambientMatrix;
562uniform vec2 vAmbientInfos;
563#endif
564#ifdef OPACITY
565uniform mat4 opacityMatrix;
566uniform vec2 vOpacityInfos;
567#endif
568#ifdef EMISSIVE
569uniform vec2 vEmissiveInfos;
570uniform mat4 emissiveMatrix;
571#endif
572#ifdef LIGHTMAP
573uniform vec2 vLightmapInfos;
574uniform mat4 lightmapMatrix;
575#endif
576#if defined(SPECULAR) && defined(SPECULARTERM)
577uniform vec2 vSpecularInfos;
578uniform mat4 specularMatrix;
579#endif
580#ifdef BUMP
581uniform vec3 vBumpInfos;
582uniform mat4 bumpMatrix;
583#endif
584#ifdef REFLECTION
585uniform mat4 reflectionMatrix;
586#endif
587#ifdef POINTSIZE
588uniform float pointSize;
589#endif
590`;T.a.IncludesShadersStore.defaultVertexDeclaration=I,f(78),f(79),f(163),f(164),f(117),f(137),f(93),f(94),f(100),f(80),f(81),f(165),f(156),f(111),f(157),f(138),T.a.IncludesShadersStore.pointCloudVertex=`#ifdef POINTSIZE
591gl_PointSize=pointSize;
592#endif`,f(158);var V=`#include<__decl__defaultVertex>
593
594#define CUSTOM_VERTEX_BEGIN
595attribute vec3 position;
596#ifdef NORMAL
597attribute vec3 normal;
598#endif
599#ifdef TANGENT
600attribute vec4 tangent;
601#endif
602#ifdef UV1
603attribute vec2 uv;
604#endif
605#ifdef UV2
606attribute vec2 uv2;
607#endif
608#ifdef VERTEXCOLOR
609attribute vec4 color;
610#endif
611#include<helperFunctions>
612#include<bonesDeclaration>
613
614#include<instancesDeclaration>
615#include<prePassVertexDeclaration>
616#ifdef MAINUV1
617varying vec2 vMainUV1;
618#endif
619#ifdef MAINUV2
620varying vec2 vMainUV2;
621#endif
622#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0
623varying vec2 vDiffuseUV;
624#endif
625#if defined(DETAIL) && DETAILDIRECTUV == 0
626varying vec2 vDetailUV;
627#endif
628#if defined(AMBIENT) && AMBIENTDIRECTUV == 0
629varying vec2 vAmbientUV;
630#endif
631#if defined(OPACITY) && OPACITYDIRECTUV == 0
632varying vec2 vOpacityUV;
633#endif
634#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0
635varying vec2 vEmissiveUV;
636#endif
637#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0
638varying vec2 vLightmapUV;
639#endif
640#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0
641varying vec2 vSpecularUV;
642#endif
643#if defined(BUMP) && BUMPDIRECTUV == 0
644varying vec2 vBumpUV;
645#endif
646
647varying vec3 vPositionW;
648#ifdef NORMAL
649varying vec3 vNormalW;
650#endif
651#ifdef VERTEXCOLOR
652varying vec4 vColor;
653#endif
654#include<bumpVertexDeclaration>
655#include<clipPlaneVertexDeclaration>
656#include<fogVertexDeclaration>
657#include<__decl__lightFragment>[0..maxSimultaneousLights]
658#include<morphTargetsVertexGlobalDeclaration>
659#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
660#ifdef REFLECTIONMAP_SKYBOX
661varying vec3 vPositionUVW;
662#endif
663#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
664varying vec3 vDirectionW;
665#endif
666#include<logDepthDeclaration>
667#define CUSTOM_VERTEX_DEFINITIONS
668void main(void) {
669#define CUSTOM_VERTEX_MAIN_BEGIN
670vec3 positionUpdated=position;
671#ifdef NORMAL
672vec3 normalUpdated=normal;
673#endif
674#ifdef TANGENT
675vec4 tangentUpdated=tangent;
676#endif
677#ifdef UV1
678vec2 uvUpdated=uv;
679#endif
680#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
681#ifdef REFLECTIONMAP_SKYBOX
682vPositionUVW=positionUpdated;
683#endif
684#define CUSTOM_VERTEX_UPDATE_POSITION
685#define CUSTOM_VERTEX_UPDATE_NORMAL
686#include<instancesVertex>
687#if defined(PREPASS) && defined(PREPASS_VELOCITY) && !defined(BONES_VELOCITY_ENABLED)
688
689vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);
690vPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0);
691#endif
692#include<bonesVertex>
693vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);
694#ifdef NORMAL
695mat3 normalWorld=mat3(finalWorld);
696#if defined(INSTANCES) && defined(THIN_INSTANCES)
697vNormalW=normalUpdated/vec3(dot(normalWorld[0],normalWorld[0]),dot(normalWorld[1],normalWorld[1]),dot(normalWorld[2],normalWorld[2]));
698vNormalW=normalize(normalWorld*vNormalW);
699#else
700#ifdef NONUNIFORMSCALING
701normalWorld=transposeMat3(inverseMat3(normalWorld));
702#endif
703vNormalW=normalize(normalWorld*normalUpdated);
704#endif
705#endif
706#define CUSTOM_VERTEX_UPDATE_WORLDPOS
707#ifdef MULTIVIEW
708if (gl_ViewID_OVR == 0u) {
709gl_Position=viewProjection*worldPos;
710} else {
711gl_Position=viewProjectionR*worldPos;
712}
713#else
714gl_Position=viewProjection*worldPos;
715#endif
716vPositionW=vec3(worldPos);
717#include<prePassVertex>
718#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
719vDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));
720#endif
721
722#ifndef UV1
723vec2 uvUpdated=vec2(0.,0.);
724#endif
725#ifndef UV2
726vec2 uv2=vec2(0.,0.);
727#endif
728#ifdef MAINUV1
729vMainUV1=uvUpdated;
730#endif
731#ifdef MAINUV2
732vMainUV2=uv2;
733#endif
734#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0
735if (vDiffuseInfos.x == 0.)
736{
737vDiffuseUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));
738}
739else
740{
741vDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
742}
743#endif
744#if defined(DETAIL) && DETAILDIRECTUV == 0
745if (vDetailInfos.x == 0.)
746{
747vDetailUV=vec2(detailMatrix*vec4(uvUpdated,1.0,0.0));
748}
749else
750{
751vDetailUV=vec2(detailMatrix*vec4(uv2,1.0,0.0));
752}
753#endif
754#if defined(AMBIENT) && AMBIENTDIRECTUV == 0
755if (vAmbientInfos.x == 0.)
756{
757vAmbientUV=vec2(ambientMatrix*vec4(uvUpdated,1.0,0.0));
758}
759else
760{
761vAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));
762}
763#endif
764#if defined(OPACITY) && OPACITYDIRECTUV == 0
765if (vOpacityInfos.x == 0.)
766{
767vOpacityUV=vec2(opacityMatrix*vec4(uvUpdated,1.0,0.0));
768}
769else
770{
771vOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));
772}
773#endif
774#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0
775if (vEmissiveInfos.x == 0.)
776{
777vEmissiveUV=vec2(emissiveMatrix*vec4(uvUpdated,1.0,0.0));
778}
779else
780{
781vEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));
782}
783#endif
784#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0
785if (vLightmapInfos.x == 0.)
786{
787vLightmapUV=vec2(lightmapMatrix*vec4(uvUpdated,1.0,0.0));
788}
789else
790{
791vLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));
792}
793#endif
794#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0
795if (vSpecularInfos.x == 0.)
796{
797vSpecularUV=vec2(specularMatrix*vec4(uvUpdated,1.0,0.0));
798}
799else
800{
801vSpecularUV=vec2(specularMatrix*vec4(uv2,1.0,0.0));
802}
803#endif
804#if defined(BUMP) && BUMPDIRECTUV == 0
805if (vBumpInfos.x == 0.)
806{
807vBumpUV=vec2(bumpMatrix*vec4(uvUpdated,1.0,0.0));
808}
809else
810{
811vBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));
812}
813#endif
814#include<bumpVertex>
815#include<clipPlaneVertex>
816#include<fogVertex>
817#include<shadowsVertex>[0..maxSimultaneousLights]
818#ifdef VERTEXCOLOR
819
820vColor=color;
821#endif
822#include<pointCloudVertex>
823#include<logDepthVertex>
824#define CUSTOM_VERTEX_MAIN_END
825}
826`;T.a.ShadersStore.defaultVertexShader=V;var W=f(2),j=f(67),ne=f(92),te={effect:null,subMesh:null},de=function(ae){function ee(){var K=ae.call(this)||this;return K.MAINUV1=!1,K.MAINUV2=!1,K.DIFFUSE=!1,K.DIFFUSEDIRECTUV=0,K.DETAIL=!1,K.DETAILDIRECTUV=0,K.DETAIL_NORMALBLENDMETHOD=0,K.AMBIENT=!1,K.AMBIENTDIRECTUV=0,K.OPACITY=!1,K.OPACITYDIRECTUV=0,K.OPACITYRGB=!1,K.REFLECTION=!1,K.EMISSIVE=!1,K.EMISSIVEDIRECTUV=0,K.SPECULAR=!1,K.SPECULARDIRECTUV=0,K.BUMP=!1,K.BUMPDIRECTUV=0,K.PARALLAX=!1,K.PARALLAXOCCLUSION=!1,K.SPECULAROVERALPHA=!1,K.CLIPPLANE=!1,K.CLIPPLANE2=!1,K.CLIPPLANE3=!1,K.CLIPPLANE4=!1,K.CLIPPLANE5=!1,K.CLIPPLANE6=!1,K.ALPHATEST=!1,K.DEPTHPREPASS=!1,K.ALPHAFROMDIFFUSE=!1,K.POINTSIZE=!1,K.FOG=!1,K.SPECULARTERM=!1,K.DIFFUSEFRESNEL=!1,K.OPACITYFRESNEL=!1,K.REFLECTIONFRESNEL=!1,K.REFRACTIONFRESNEL=!1,K.EMISSIVEFRESNEL=!1,K.FRESNEL=!1,K.NORMAL=!1,K.UV1=!1,K.UV2=!1,K.VERTEXCOLOR=!1,K.VERTEXALPHA=!1,K.NUM_BONE_INFLUENCERS=0,K.BonesPerMesh=0,K.BONETEXTURE=!1,K.BONES_VELOCITY_ENABLED=!1,K.INSTANCES=!1,K.THIN_INSTANCES=!1,K.GLOSSINESS=!1,K.ROUGHNESS=!1,K.EMISSIVEASILLUMINATION=!1,K.LINKEMISSIVEWITHDIFFUSE=!1,K.REFLECTIONFRESNELFROMSPECULAR=!1,K.LIGHTMAP=!1,K.LIGHTMAPDIRECTUV=0,K.OBJECTSPACE_NORMALMAP=!1,K.USELIGHTMAPASSHADOWMAP=!1,K.REFLECTIONMAP_3D=!1,K.REFLECTIONMAP_SPHERICAL=!1,K.REFLECTIONMAP_PLANAR=!1,K.REFLECTIONMAP_CUBIC=!1,K.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,K.REFLECTIONMAP_PROJECTION=!1,K.REFLECTIONMAP_SKYBOX=!1,K.REFLECTIONMAP_EXPLICIT=!1,K.REFLECTIONMAP_EQUIRECTANGULAR=!1,K.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,K.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,K.INVERTCUBICMAP=!1,K.LOGARITHMICDEPTH=!1,K.REFRACTION=!1,K.REFRACTIONMAP_3D=!1,K.REFLECTIONOVERALPHA=!1,K.TWOSIDEDLIGHTING=!1,K.SHADOWFLOAT=!1,K.MORPHTARGETS=!1,K.MORPHTARGETS_NORMAL=!1,K.MORPHTARGETS_TANGENT=!1,K.MORPHTARGETS_UV=!1,K.NUM_MORPH_INFLUENCERS=0,K.NONUNIFORMSCALING=!1,K.PREMULTIPLYALPHA=!1,K.ALPHATEST_AFTERALLALPHACOMPUTATIONS=!1,K.ALPHABLEND=!0,K.PREPASS=!1,K.PREPASS_IRRADIANCE=!1,K.PREPASS_IRRADIANCE_INDEX=-1,K.PREPASS_ALBEDO=!1,K.PREPASS_ALBEDO_INDEX=-1,K.PREPASS_DEPTHNORMAL=!1,K.PREPASS_DEPTHNORMAL_INDEX=-1,K.PREPASS_POSITION=!1,K.PREPASS_POSITION_INDEX=-1,K.PREPASS_VELOCITY=!1,K.PREPASS_VELOCITY_INDEX=-1,K.PREPASS_REFLECTIVITY=!1,K.PREPASS_REFLECTIVITY_INDEX=-1,K.SCENE_MRT_COUNT=0,K.RGBDLIGHTMAP=!1,K.RGBDREFLECTION=!1,K.RGBDREFRACTION=!1,K.IMAGEPROCESSING=!1,K.VIGNETTE=!1,K.VIGNETTEBLENDMODEMULTIPLY=!1,K.VIGNETTEBLENDMODEOPAQUE=!1,K.TONEMAPPING=!1,K.TONEMAPPING_ACES=!1,K.CONTRAST=!1,K.COLORCURVES=!1,K.COLORGRADING=!1,K.COLORGRADING3D=!1,K.SAMPLER3DGREENDEPTH=!1,K.SAMPLER3DBGRMAP=!1,K.IMAGEPROCESSINGPOSTPROCESS=!1,K.MULTIVIEW=!1,K.IS_REFLECTION_LINEAR=!1,K.IS_REFRACTION_LINEAR=!1,K.EXPOSURE=!1,K.rebuild(),K}return Object(B.d)(ee,ae),ee.prototype.setReflectionMode=function(K){for(var $=0,L=["REFLECTIONMAP_CUBIC","REFLECTIONMAP_EXPLICIT","REFLECTIONMAP_PLANAR","REFLECTIONMAP_PROJECTION","REFLECTIONMAP_PROJECTION","REFLECTIONMAP_SKYBOX","REFLECTIONMAP_SPHERICAL","REFLECTIONMAP_EQUIRECTANGULAR","REFLECTIONMAP_EQUIRECTANGULAR_FIXED","REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"];$<L.length;$++){var G=L[$];this[G]=G===K}},ee}(A.a),pe=function(ae){function ee(K,$){var L=ae.call(this,K,$)||this;return L._diffuseTexture=null,L._ambientTexture=null,L._opacityTexture=null,L._reflectionTexture=null,L._emissiveTexture=null,L._specularTexture=null,L._bumpTexture=null,L._lightmapTexture=null,L._refractionTexture=null,L.ambientColor=new R.a(0,0,0),L.diffuseColor=new R.a(1,1,1),L.specularColor=new R.a(1,1,1),L.emissiveColor=new R.a(0,0,0),L.specularPower=64,L._useAlphaFromDiffuseTexture=!1,L._useEmissiveAsIllumination=!1,L._linkEmissiveWithDiffuse=!1,L._useSpecularOverAlpha=!1,L._useReflectionOverAlpha=!1,L._disableLighting=!1,L._useObjectSpaceNormalMap=!1,L._useParallax=!1,L._useParallaxOcclusion=!1,L.parallaxScaleBias=.05,L._roughness=0,L.indexOfRefraction=.98,L.invertRefractionY=!0,L.alphaCutOff=.4,L._useLightmapAsShadowmap=!1,L._useReflectionFresnelFromSpecular=!1,L._useGlossinessFromSpecularMapAlpha=!1,L._maxSimultaneousLights=4,L._invertNormalMapX=!1,L._invertNormalMapY=!1,L._twoSidedLighting=!1,L.detailMap=new ne.a(L._markAllSubMeshesAsTexturesDirty.bind(L)),L._renderTargets=new x.a(16),L._worldViewProjectionMatrix=M.a.Zero(),L._globalAmbientColor=new R.a(0,0,0),L._rebuildInParallel=!1,L._attachImageProcessingConfiguration(null),L.prePassConfiguration=new m.a,L.getRenderTargetTextures=function(){return L._renderTargets.reset(),ee.ReflectionTextureEnabled&&L._reflectionTexture&&L._reflectionTexture.isRenderTarget&&L._renderTargets.push(L._reflectionTexture),ee.RefractionTextureEnabled&&L._refractionTexture&&L._refractionTexture.isRenderTarget&&L._renderTargets.push(L._refractionTexture),L._renderTargets},L}return Object(B.d)(ee,ae),Object.defineProperty(ee.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(K){this._attachImageProcessingConfiguration(K),this._markAllSubMeshesAsTexturesDirty()}
826,enumerable:!1,configurable:!0}),ee.prototype._attachImageProcessingConfiguration=function(K){var $=this;K!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration=K||this.getScene().imageProcessingConfiguration,this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add(function(){$._markAllSubMeshesAsImageProcessingDirty()})))},Object.defineProperty(ee.prototype,"cameraColorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(K){this.imageProcessingConfiguration.colorCurvesEnabled=K},enumerable:!1,configurable:!0}),Object.defineProperty(ee.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(K){this.imageProcessingConfiguration.colorGradingEnabled=K},enumerable:!1,configurable:!0}),Object.defineProperty(ee.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(K){this._imageProcessingConfiguration.toneMappingEnabled=K},enumerable:!1,configurable:!0}),Object.defineProperty(ee.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(K){this._imageProcessingConfiguration.exposure=K},enumerable:!1,configurable:!0}),Object.defineProperty(ee.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(K){this._imageProcessingConfiguration.contrast=K},enumerable:!1,configurable:!0}),Object.defineProperty(ee.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(K){this._imageProcessingConfiguration.colorGradingTexture=K},enumerable:!1,configurable:!0}),Object.defineProperty(ee.prototype,"cameraColorCurves",{get:function(){return this._imageProcessingConfiguration.colorCurves},set:function(K){this._imageProcessingConfiguration.colorCurves=K},enumerable:!1,configurable:!0}),Object.defineProperty(ee.prototype,"canRenderToMRT",{get:function(){return!0},enumerable:!1,configurable:!0}),Object.defineProperty(ee.prototype,"hasRenderTargetTextures",{get:function(){return!!(ee.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget)||!!(ee.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget)},enumerable:!1,configurable:!0}),ee.prototype.getClassName=function(){return"StandardMaterial"},Object.defineProperty(ee.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(K){this._useLogarithmicDepth=K&&this.getScene().getEngine().getCaps().fragmentDepthSupported,this._markAllSubMeshesAsMiscDirty()},enumerable:!1,configurable:!0}),ee.prototype.needAlphaBlending=function(){return!this._disableAlphaBlending&&(this.alpha<1||this._opacityTexture!=null||this._shouldUseAlphaFromDiffuseTexture()||this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled)},ee.prototype.needAlphaTesting=function(){return!!this._forceAlphaTest||this._hasAlphaChannel()&&(this._transparencyMode==null||this._transparencyMode===E.a.MATERIAL_ALPHATEST)},ee.prototype._shouldUseAlphaFromDiffuseTexture=function(){return this._diffuseTexture!=null&&this._diffuseTexture.hasAlpha&&this._useAlphaFromDiffuseTexture&&this._transparencyMode!==E.a.MATERIAL_OPAQUE},ee.prototype._hasAlphaChannel=function(){return this._diffuseTexture!=null&&this._diffuseTexture.hasAlpha||this._opacityTexture!=null},ee.prototype.getAlphaTestTexture=function(){return this._diffuseTexture},ee.prototype.isReadyForSubMesh=function(K,$,L){if(L===void 0&&(L=!1),$.effect&&this.isFrozen&&$.effect._wasPreviouslyReady)return!0;$._materialDefines||($._materialDefines=new de);var G=this.getScene(),Q=$._materialDefines;if(this._isReadyForSubMesh($))return!0;var oe=G.getEngine();if(Q._needNormals=g.a.PrepareDefinesForLights(G,K,Q,!0,this._maxSimultaneousLights,this._disableLighting),g.a.PrepareDefinesForMultiview(G,Q),g.a.PrepareDefinesForPrePass(G,Q,this.canRenderToMRT),Q._areTexturesDirty){if(Q._needUVs=!1,Q.MAINUV1=!1,Q.MAINUV2=!1,G.texturesEnabled){if(this._diffuseTexture&&ee.DiffuseTextureEnabled){if(!this._diffuseTexture.isReadyOrNotBlocking())return!1;g.a.PrepareDefinesForMergedUV(this._diffuseTexture,Q,"DIFFUSE")}else Q.DIFFUSE=!1;if(this._ambientTexture&&ee.AmbientTextureEnabled){if(!this._ambientTexture.isReadyOrNotBlocking())return!1;g.a.PrepareDefinesForMergedUV(this._ambientTexture,Q,"AMBIENT")}else Q.AMBIENT=!1;if(this._opacityTexture&&ee.OpacityTextureEnabled){if(!this._opacityTexture.isReadyOrNotBlocking())return!1;g.a.PrepareDefinesForMergedUV(this._opacityTexture,Q,"OPACITY"),Q.OPACITYRGB=this._opacityTexture.getAlphaFromRGB}else Q.OPACITY=!1;if(this._reflectionTexture&&ee.ReflectionTextureEnabled){if(!this._reflectionTexture.isReadyOrNotBlocking())return!1;switch(Q._needNormals=!0,Q.REFLECTION=!0,Q.ROUGHNESS=this._roughness>0,Q.REFLECTIONOVERALPHA=this._useReflectionOverAlpha,Q.INVERTCUBICMAP=this._reflectionTexture.coordinatesMode===l.a.INVCUBIC_MODE,Q.REFLECTIONMAP_3D=this._reflectionTexture.isCube,Q.RGBDREFLECTION=this._reflectionTexture.isRGBD,this._reflectionTexture.coordinatesMode){case l.a.EXPLICIT_MODE:Q.setReflectionMode("REFLECTIONMAP_EXPLICIT");break;case l.a.PLANAR_MODE:Q.setReflectionMode("REFLECTIONMAP_PLANAR");break;case l.a.PROJECTION_MODE:Q.setReflectionMode("REFLECTIONMAP_PROJECTION");break;case l.a.SKYBOX_MODE:Q.setReflectionMode("REFLECTIONMAP_SKYBOX");break;case l.a.SPHERICAL_MODE:Q.setReflectionMode("REFLECTIONMAP_SPHERICAL");break;case l.a.EQUIRECTANGULAR_MODE:Q.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");break;case l.a.FIXED_EQUIRECTANGULAR_MODE:Q.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");break;case l.a.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:Q.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");break;case l.a.CUBIC_MODE:case l.a.INVCUBIC_MODE:default:Q.setReflectionMode("REFLECTIONMAP_CUBIC")}Q.USE_LOCAL_REFLECTIONMAP_CUBIC=!!this._reflectionTexture.boundingBoxSize}else Q.REFLECTION=!1;if(this._emissiveTexture&&ee.EmissiveTextureEnabled){if(!this._emissiveTexture.isReadyOrNotBlocking())return!1;g.a.PrepareDefinesForMergedUV(this._emissiveTexture,Q,"EMISSIVE")}else Q.EMISSIVE=!1;if(this._lightmapTexture&&ee.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;g.a.PrepareDefinesForMergedUV(this._lightmapTexture,Q,"LIGHTMAP"),Q.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap,Q.RGBDLIGHTMAP=this._lightmapTexture.isRGBD}else Q.LIGHTMAP=!1;if(this._specularTexture&&ee.SpecularTextureEnabled){if(!this._specularTexture.isReadyOrNotBlocking())return!1;g.a.PrepareDefinesForMergedUV(this._specularTexture,Q,"SPECULAR"),Q.GLOSSINESS=this._useGlossinessFromSpecularMapAlpha}else Q.SPECULAR=!1;if(G.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&ee.BumpTextureEnabled){if(!this._bumpTexture.isReady())return!1;g.a.PrepareDefinesForMergedUV(this._bumpTexture,Q,"BUMP"),Q.PARALLAX=this._useParallax,Q.PARALLAXOCCLUSION=this._useParallaxOcclusion,Q.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap}else Q.BUMP=!1;if(this._refractionTexture&&ee.RefractionTextureEnabled){if(!this._refractionTexture.isReadyOrNotBlocking())return!1;Q._needUVs=!0,Q.REFRACTION=!0,Q.REFRACTIONMAP_3D=this._refractionTexture.isCube,Q.RGBDREFRACTION=this._refractionTexture.isRGBD}else Q.REFRACTION=!1;Q.TWOSIDEDLIGHTING=!this._backFaceCulling&&this._twoSidedLighting}else Q.DIFFUSE=!1,Q.AMBIENT=!1,Q.OPACITY=!1,Q.REFLECTION=!1,Q.EMISSIVE=!1,Q.LIGHTMAP=!1,Q.BUMP=!1,Q.REFRACTION=!1;Q.ALPHAFROMDIFFUSE=this._shouldUseAlphaFromDiffuseTexture(),Q.EMISSIVEASILLUMINATION=this._useEmissiveAsIllumination,Q.LINKEMISSIVEWITHDIFFUSE=this._linkEmissiveWithDiffuse,Q.SPECULAROVERALPHA=this._useSpecularOverAlpha,Q.PREMULTIPLYALPHA=this.alphaMode===W.a.ALPHA_PREMULTIPLIED||this.alphaMode===W.a.ALPHA_PREMULTIPLIED_PORTERDUFF,Q.ALPHATEST_AFTERALLALPHACOMPUTATIONS=this.transparencyMode!==null,Q.ALPHABLEND=this.transparencyMode===null||this.needAlphaBlendingForMesh(K)}if(!this.detailMap.isReadyForSubMesh(Q,G))return!1;if(Q._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(Q),Q.IS_REFLECTION_LINEAR=this.reflectionTexture!=null&&!this.reflectionTexture.gammaSpace,Q.IS_REFRACTION_LINEAR=this.refractionTexture!=null&&!this.refractionTexture.gammaSpace}if(Q._areFresnelDirty&&(ee.FresnelEnabled?(this._diffuseFresnelParameters||this._opacityFresnelParameters||this._emissiveFresnelParameters||this._refractionFresnelParameters||this._reflectionFresnelParameters)&&(Q.DIFFUSEFRESNEL=this._diffuseFresnelParameters&&this._diffuseFresnelParameters.isEnabled,Q.OPACITYFRESNEL=this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled,Q.REFLECTIONFRESNEL=this._reflectionFresnelParameters&&this._reflectionFresnelParameters.isEnabled,Q.REFLECTIONFRESNELFROMSPECULAR=this._useReflectionFresnelFromSpecular,Q.REFRACTIONFRESNEL=this._refractionFresnelParameters&&this._refractionFresnelParameters.isEnabled,Q.EMISSIVEFRESNEL=this._emissiveFresnelParameters&&this._emissiveFresnelParameters.isEnabled,Q._needNormals=!0,Q.FRESNEL=!0):Q.FRESNEL=!1),g.a.PrepareDefinesForMisc(K,G,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(K)||this._forceAlphaTest,Q),g.a.PrepareDefinesForAttributes(K,Q,!0,!0,!0),g.a.PrepareDefinesForFrameBoundValues(G,oe,Q,L,null,$.getRenderingMesh().hasThinInstances),this.detailMap.prepareDefines(Q,G),Q.isDirty){var re=Q._areLightsDisposed;Q.markAsProcessed();var Y=new j.a;Q.REFLECTION&&Y.addFallback(0,"REFLECTION"),Q.SPECULAR&&Y.addFallback(0,"SPECULAR"),Q.BUMP&&Y.addFallback(0,"BUMP"),Q.PARALLAX&&Y.addFallback(1,"PARALLAX"),Q.PARALLAXOCCLUSION&&Y.addFallback(0,"PARALLAXOCCLUSION"),Q.SPECULAROVERALPHA&&Y.addFallback(0,"SPECULAROVERALPHA"),Q.FOG&&Y.addFallback(1,"FOG"),Q.POINTSIZE&&Y.addFallback(0,"POINTSIZE"),Q.LOGARITHMICDEPTH&&Y.addFallback(0,"LOGARITHMICDEPTH"),g.a.HandleFallbacksForShadows(Q,Y,this._maxSimultaneousLights),Q.SPECULARTERM&&Y.addFallback(0,"SPECULARTERM"),Q.DIFFUSEFRESNEL&&Y.addFallback(1,"DIFFUSEFRESNEL"),Q.OPACITYFRESNEL&&Y.addFallback(2,"OPACITYFRESNEL"),Q.REFLECTIONFRESNEL&&Y.addFallback(3,"REFLECTIONFRESNEL"),Q.EMISSIVEFRESNEL&&Y.addFallback(4,"EMISSIVEFRESNEL"),Q.FRESNEL&&Y.addFallback(4,"FRESNEL"),Q.MULTIVIEW&&Y.addFallback(0,"MULTIVIEW");var k=[C.b.PositionKind];
826Q.NORMAL&&k.push(C.b.NormalKind),Q.UV1&&k.push(C.b.UVKind),Q.UV2&&k.push(C.b.UV2Kind),Q.VERTEXCOLOR&&k.push(C.b.ColorKind),g.a.PrepareAttributesForBones(k,K,Q,Y),g.a.PrepareAttributesForInstances(k,Q),g.a.PrepareAttributesForMorphTargets(k,K,Q);var H="default",Z=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vDiffuseColor","vSpecularColor","vEmissiveColor","visibility","vFogInfos","vFogColor","pointSize","vDiffuseInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vEmissiveInfos","vSpecularInfos","vBumpInfos","vLightmapInfos","vRefractionInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","diffuseMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","specularMatrix","bumpMatrix","normalMatrix","lightmapMatrix","refractionMatrix","diffuseLeftColor","diffuseRightColor","opacityParts","reflectionLeftColor","reflectionRightColor","emissiveLeftColor","emissiveRightColor","refractionLeftColor","refractionRightColor","vReflectionPosition","vReflectionSize","logarithmicDepthConstant","vTangentSpaceParams","alphaCutOff","boneTextureWidth"],X=["diffuseSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","specularSampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler","boneSampler"],q=["Material","Scene"];ne.a.AddUniforms(Z),ne.a.AddSamplers(X),m.a.AddUniforms(Z),m.a.AddSamplers(Z),c.a&&(c.a.PrepareUniforms(Z,Q),c.a.PrepareSamplers(X,Q)),g.a.PrepareUniformsAndSamplersList({uniformsNames:Z,uniformBuffersNames:q,samplers:X,defines:Q,maxSimultaneousLights:this._maxSimultaneousLights});var he={};this.customShaderNameResolve&&(H=this.customShaderNameResolve(H,Z,q,X,Q,k,he));var ge=Q.toString(),me=$.effect,_e=G.getEngine().createEffect(H,{attributes:k,uniformsNames:Z,uniformBuffersNames:q,samplers:X,defines:ge,fallbacks:Y,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:Q.NUM_MORPH_INFLUENCERS},processFinalCode:he.processFinalCode,multiTarget:Q.PREPASS},oe);if(_e)if(this._onEffectCreatedObservable&&(te.effect=_e,te.subMesh=$,this._onEffectCreatedObservable.notifyObservers(te)),this.allowShaderHotSwapping&&me&&!_e.isReady()){if(_e=me,this._rebuildInParallel=!0,Q.markAsUnprocessed(),re)return Q._areLightsDisposed=!0,!1}else this._rebuildInParallel=!1,G.resetCachedMaterial(),$.setEffect(_e,Q),this.buildUniformLayout()}return!(!$.effect||!$.effect.isReady())&&(Q._renderId=G.getRenderId(),$.effect._wasPreviouslyReady=!0,!0)},ee.prototype.buildUniformLayout=function(){var K=this._uniformBuffer;K.addUniform("diffuseLeftColor",4),K.addUniform("diffuseRightColor",4),K.addUniform("opacityParts",4),K.addUniform("reflectionLeftColor",4),K.addUniform("reflectionRightColor",4),K.addUniform("refractionLeftColor",4),K.addUniform("refractionRightColor",4),K.addUniform("emissiveLeftColor",4),K.addUniform("emissiveRightColor",4),K.addUniform("vDiffuseInfos",2),K.addUniform("vAmbientInfos",2),K.addUniform("vOpacityInfos",2),K.addUniform("vReflectionInfos",2),K.addUniform("vReflectionPosition",3),K.addUniform("vReflectionSize",3),K.addUniform("vEmissiveInfos",2),K.addUniform("vLightmapInfos",2),K.addUniform("vSpecularInfos",2),K.addUniform("vBumpInfos",3),K.addUniform("diffuseMatrix",16),K.addUniform("ambientMatrix",16),K.addUniform("opacityMatrix",16),K.addUniform("reflectionMatrix",16),K.addUniform("emissiveMatrix",16),K.addUniform("lightmapMatrix",16),K.addUniform("specularMatrix",16),K.addUniform("bumpMatrix",16),K.addUniform("vTangentSpaceParams",2),K.addUniform("pointSize",1),K.addUniform("refractionMatrix",16),K.addUniform("vRefractionInfos",4),K.addUniform("vSpecularColor",4),K.addUniform("vEmissiveColor",3),K.addUniform("visibility",1),K.addUniform("vDiffuseColor",4),ne.a.PrepareUniformBuffer(K),K.create()},ee.prototype.unbind=function(){if(this._activeEffect){var K=!1;this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&(this._activeEffect.setTexture("reflection2DSampler",null),K=!0),this._refractionTexture&&this._refractionTexture.isRenderTarget&&(this._activeEffect.setTexture("refraction2DSampler",null),K=!0),K&&this._markAllSubMeshesAsTexturesDirty()}ae.prototype.unbind.call(this)},ee.prototype.bindForSubMesh=function(K,$,L){var G=this.getScene(),Q=L._materialDefines;if(Q){var oe=L.effect;if(oe){this._activeEffect=oe,Q.INSTANCES&&!Q.THIN_INSTANCES||this.bindOnlyWorldMatrix(K),this.prePassConfiguration.bindForSubMesh(this._activeEffect,G,$,K,this.isFrozen),Q.OBJECTSPACE_NORMALMAP&&(K.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));var re=this._mustRebind(G,oe,$.visibility);g.a.BindBonesParameters($,oe);var Y=this._uniformBuffer;if(re){if(Y.bindToEffect(oe,"Material"),this.bindViewProjection(oe),!Y.useUbo||!this.isFrozen||!Y.isSync){if(ee.FresnelEnabled&&Q.FRESNEL&&(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled&&(Y.updateColor4("diffuseLeftColor",this.diffuseFresnelParameters.leftColor,this.diffuseFresnelParameters.power),Y.updateColor4("diffuseRightColor",this.diffuseFresnelParameters.rightColor,this.diffuseFresnelParameters.bias)),this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled&&Y.updateColor4("opacityParts",new R.a(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias),this.opacityFresnelParameters.power),this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled&&(Y.updateColor4("reflectionLeftColor",this.reflectionFresnelParameters.leftColor,this.reflectionFresnelParameters.power),Y.updateColor4("reflectionRightColor",this.reflectionFresnelParameters.rightColor,this.reflectionFresnelParameters.bias)),this.refractionFresnelParameters&&this.refractionFresnelParameters.isEnabled&&(Y.updateColor4("refractionLeftColor",this.refractionFresnelParameters.leftColor,this.refractionFresnelParameters.power),Y.updateColor4("refractionRightColor",this.refractionFresnelParameters.rightColor,this.refractionFresnelParameters.bias)),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(Y.updateColor4("emissiveLeftColor",this.emissiveFresnelParameters.leftColor,this.emissiveFresnelParameters.power),Y.updateColor4("emissiveRightColor",this.emissiveFresnelParameters.rightColor,this.emissiveFresnelParameters.bias))),G.texturesEnabled){if(this._diffuseTexture&&ee.DiffuseTextureEnabled&&(Y.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),g.a.BindTextureMatrix(this._diffuseTexture,Y,"diffuse")),this._ambientTexture&&ee.AmbientTextureEnabled&&(Y.updateFloat2("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level),g.a.BindTextureMatrix(this._ambientTexture,Y,"ambient")),this._opacityTexture&&ee.OpacityTextureEnabled&&(Y.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),g.a.BindTextureMatrix(this._opacityTexture,Y,"opacity")),this._hasAlphaChannel()&&oe.setFloat("alphaCutOff",this.alphaCutOff),this._reflectionTexture&&ee.ReflectionTextureEnabled&&(Y.updateFloat2("vReflectionInfos",this._reflectionTexture.level,this.roughness),Y.updateMatrix("reflectionMatrix",this._reflectionTexture.getReflectionTextureMatrix()),this._reflectionTexture.boundingBoxSize)){var k=this._reflectionTexture;Y.updateVector3("vReflectionPosition",k.boundingBoxPosition),Y.updateVector3("vReflectionSize",k.boundingBoxSize)}if(this._emissiveTexture&&ee.EmissiveTextureEnabled&&(Y.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),g.a.BindTextureMatrix(this._emissiveTexture,Y,"emissive")),this._lightmapTexture&&ee.LightmapTextureEnabled&&(Y.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),g.a.BindTextureMatrix(this._lightmapTexture,Y,"lightmap")),this._specularTexture&&ee.SpecularTextureEnabled&&(Y.updateFloat2("vSpecularInfos",this._specularTexture.coordinatesIndex,this._specularTexture.level),g.a.BindTextureMatrix(this._specularTexture,Y,"specular")),this._bumpTexture&&G.getEngine().getCaps().standardDerivatives&&ee.BumpTextureEnabled&&(Y.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,1/this._bumpTexture.level,this.parallaxScaleBias),g.a.BindTextureMatrix(this._bumpTexture,Y,"bump"),G._mirroredCameraPosition?Y.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):Y.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1)),this._refractionTexture&&ee.RefractionTextureEnabled){var H=1;this._refractionTexture.isCube||(Y.updateMatrix("refractionMatrix",this._refractionTexture.getReflectionTextureMatrix()),this._refractionTexture.depth&&(H=this._refractionTexture.depth)),Y.updateFloat4("vRefractionInfos",this._refractionTexture.level,this.indexOfRefraction,H,this.invertRefractionY?-1:1)}}this.pointsCloud&&Y.updateFloat("pointSize",this.pointSize),Q.SPECULARTERM&&Y.updateColor4("vSpecularColor",this.specularColor,this.specularPower),Y.updateColor3("vEmissiveColor",ee.EmissiveTextureEnabled?this.emissiveColor:R.a.BlackReadOnly),Y.updateColor4("vDiffuseColor",this.diffuseColor,this.alpha)}Y.updateFloat("visibility",$.visibility),G.texturesEnabled&&(this._diffuseTexture&&ee.DiffuseTextureEnabled&&oe.setTexture("diffuseSampler",this._diffuseTexture),this._ambientTexture&&ee.AmbientTextureEnabled&&oe.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&ee.OpacityTextureEnabled&&oe.setTexture("opacitySampler",this._opacityTexture),this._reflectionTexture&&ee.ReflectionTextureEnabled&&(this._reflectionTexture.isCube?oe.setTexture("reflectionCubeSampler",this._reflectionTexture):oe.setTexture("reflection2DSampler",this._reflectionTexture)),this._emissiveTexture&&ee.EmissiveTextureEnabled&&oe.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&ee.LightmapTextureEnabled&&oe.setTexture("lightmapSampler",this._lightmapTexture),this._specularTexture&&ee.SpecularTextureEnabled&&oe.setTexture("specularSampler",this._specularTexture),this._bumpTexture&&G.getEngine().getCaps().standardDerivatives&&ee.BumpTextureEnabled&&oe.setTexture("bumpSampler",this._bumpTexture),this._refractionTexture&&ee.RefractionTextureEnabled)&&(H=1,this._refractionTexture.isCube?oe.setTexture("refractionCubeSampler",this._refractionTexture):oe.setTexture("refraction2DSampler",this._refractionTexture)),this.detailMap.bindForSubMesh(Y,G,this.isFrozen),g.a.BindClipPlane(oe,G),G.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),g.a.BindEyePosition(oe,G),oe.setColor3("vAmbientColor",this._globalAmbientColor)}!re&&this.isFrozen||(G.lightsEnabled&&!this._disableLighting&&g.a.BindLights(G,$,oe,Q,this._maxSimultaneousLights,this._rebuildInParallel),(G.fogEnabled&&$.applyFog&&G.fogMode!==u.a.FOGMODE_NONE||this._reflectionTexture||this._refractionTexture)&&this.bindView(oe),g.a.BindFogParameters(G,$,oe),Q.NUM_MORPH_INFLUENCERS&&g.a.BindMorphTargetParameters($,oe),this.useLogarithmicDepth&&g.a.BindLogDepth(Q,oe,G),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(this._activeEffect)),Y.update(
826),this._afterBind($,this._activeEffect)}}},ee.prototype.getAnimatables=function(){var K=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&K.push(this._diffuseTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&K.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&K.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&K.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&K.push(this._emissiveTexture),this._specularTexture&&this._specularTexture.animations&&this._specularTexture.animations.length>0&&K.push(this._specularTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&K.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&K.push(this._lightmapTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&K.push(this._refractionTexture),this.detailMap.getAnimatables(K),K},ee.prototype.getActiveTextures=function(){var K=ae.prototype.getActiveTextures.call(this);return this._diffuseTexture&&K.push(this._diffuseTexture),this._ambientTexture&&K.push(this._ambientTexture),this._opacityTexture&&K.push(this._opacityTexture),this._reflectionTexture&&K.push(this._reflectionTexture),this._emissiveTexture&&K.push(this._emissiveTexture),this._specularTexture&&K.push(this._specularTexture),this._bumpTexture&&K.push(this._bumpTexture),this._lightmapTexture&&K.push(this._lightmapTexture),this._refractionTexture&&K.push(this._refractionTexture),this.detailMap.getActiveTextures(K),K},ee.prototype.hasTexture=function(K){return!!ae.prototype.hasTexture.call(this,K)||this._diffuseTexture===K||this._ambientTexture===K||this._opacityTexture===K||this._reflectionTexture===K||this._emissiveTexture===K||this._specularTexture===K||this._bumpTexture===K||this._lightmapTexture===K||this._refractionTexture===K||this.detailMap.hasTexture(K)},ee.prototype.dispose=function(K,$){var L,G,Q,oe,re,Y,k,H,Z;$&&((L=this._diffuseTexture)===null||L===void 0||L.dispose(),(G=this._ambientTexture)===null||G===void 0||G.dispose(),(Q=this._opacityTexture)===null||Q===void 0||Q.dispose(),(oe=this._reflectionTexture)===null||oe===void 0||oe.dispose(),(re=this._emissiveTexture)===null||re===void 0||re.dispose(),(Y=this._specularTexture)===null||Y===void 0||Y.dispose(),(k=this._bumpTexture)===null||k===void 0||k.dispose(),(H=this._lightmapTexture)===null||H===void 0||H.dispose(),(Z=this._refractionTexture)===null||Z===void 0||Z.dispose()),this.detailMap.dispose($),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),ae.prototype.dispose.call(this,K,$)},ee.prototype.clone=function(K){var $=this,L=_.a.Clone(function(){return new ee(K,$.getScene())},this);return L.name=K,L.id=K,L},ee.prototype.serialize=function(){return _.a.Serialize(this)},ee.Parse=function(K,$,L){return _.a.Parse(function(){return new ee(K.name,$)},K,$,L)},Object.defineProperty(ee,"DiffuseTextureEnabled",{get:function(){return b.a.DiffuseTextureEnabled},set:function(K){b.a.DiffuseTextureEnabled=K},enumerable:!1,configurable:!0}),Object.defineProperty(ee,"DetailTextureEnabled",{get:function(){return b.a.DetailTextureEnabled},set:function(K){b.a.DetailTextureEnabled=K},enumerable:!1,configurable:!0}),Object.defineProperty(ee,"AmbientTextureEnabled",{get:function(){return b.a.AmbientTextureEnabled},set:function(K){b.a.AmbientTextureEnabled=K},enumerable:!1,configurable:!0}),Object.defineProperty(ee,"OpacityTextureEnabled",{get:function(){return b.a.OpacityTextureEnabled},set:function(K){b.a.OpacityTextureEnabled=K},enumerable:!1,configurable:!0}),Object.defineProperty(ee,"ReflectionTextureEnabled",{get:function(){return b.a.ReflectionTextureEnabled},set:function(K){b.a.ReflectionTextureEnabled=K}
826,enumerable:!1,configurable:!0}),Object.defineProperty(ee,"EmissiveTextureEnabled",{get:function(){return b.a.EmissiveTextureEnabled},set:function(K){b.a.EmissiveTextureEnabled=K},enumerable:!1,configurable:!0}),Object.defineProperty(ee,"SpecularTextureEnabled",{get:function(){return b.a.SpecularTextureEnabled},set:function(K){b.a.SpecularTextureEnabled=K},enumerable:!1,configurable:!0}),Object.defineProperty(ee,"BumpTextureEnabled",{get:function(){return b.a.BumpTextureEnabled},set:function(K){b.a.BumpTextureEnabled=K},enumerable:!1,configurable:!0}),Object.defineProperty(ee,"LightmapTextureEnabled",{get:function(){return b.a.LightmapTextureEnabled},set:function(K){b.a.LightmapTextureEnabled=K},enumerable:!1,configurable:!0}),Object.defineProperty(ee,"RefractionTextureEnabled",{get:function(){return b.a.RefractionTextureEnabled},set:function(K){b.a.RefractionTextureEnabled=K},enumerable:!1,configurable:!0}),Object.defineProperty(ee,"ColorGradingTextureEnabled",{get:function(){return b.a.ColorGradingTextureEnabled},set:function(K){b.a.ColorGradingTextureEnabled=K},enumerable:!1,configurable:!0}),Object.defineProperty(ee,"FresnelEnabled",{get:function(){return b.a.FresnelEnabled},set:function(K){b.a.FresnelEnabled=K},enumerable:!1,configurable:!0}),Object(B.c)([Object(_.m)("diffuseTexture")],ee.prototype,"_diffuseTexture",void 0),Object(B.c)([Object(_.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],ee.prototype,"diffuseTexture",void 0),Object(B.c)([Object(_.m)("ambientTexture")],ee.prototype,"_ambientTexture",void 0),Object(B.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"ambientTexture",void 0),Object(B.c)([Object(_.m)("opacityTexture")],ee.prototype,"_opacityTexture",void 0),Object(B.c)([Object(_.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],ee.prototype,"opacityTexture",void 0),Object(B.c)([Object(_.m)("reflectionTexture")],ee.prototype,"_reflectionTexture",void 0),Object(B.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"reflectionTexture",void 0),Object(B.c)([Object(_.m)("emissiveTexture")],ee.prototype,"_emissiveTexture",void 0),Object(B.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"emissiveTexture",void 0),Object(B.c)([Object(_.m)("specularTexture")],ee.prototype,"_specularTexture",void 0),Object(B.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"specularTexture",void 0),Object(B.c)([Object(_.m)("bumpTexture")],ee.prototype,"_bumpTexture",void 0),Object(B.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"bumpTexture",void 0),Object(B.c)([Object(_.m)("lightmapTexture")],ee.prototype,"_lightmapTexture",void 0),Object(B.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"lightmapTexture",void 0),Object(B.c)([Object(_.m)("refractionTexture")],ee.prototype,"_refractionTexture",void 0),Object(B.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"refractionTexture",void 0),Object(B.c)([Object(_.e)("ambient")],ee.prototype,"ambientColor",void 0),Object(B.c)([Object(_.e)("diffuse")],ee.prototype,"diffuseColor",void 0),Object(B.c)([Object(_.e)("specular")],ee.prototype,"specularColor",void 0),Object(B.c)([Object(_.e)("emissive")],ee.prototype,"emissiveColor",void 0),Object(B.c)([Object(_.c)()],ee.prototype,"specularPower",void 0),Object(B.c)([Object(_.c)("useAlphaFromDiffuseTexture")],ee.prototype,"_useAlphaFromDiffuseTexture",void 0),Object(B.c)([Object(_.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],ee.prototype,"useAlphaFromDiffuseTexture",void 0),Object(B.c)([Object(_.c)("useEmissiveAsIllumination")],ee.prototype,"_useEmissiveAsIllumination",void 0),Object(B.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"useEmissiveAsIllumination",void 0),Object(B.c)([Object(_.c)("linkEmissiveWithDiffuse")],ee.prototype,"_linkEmissiveWithDiffuse",void 0),Object(B.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"linkEmissiveWithDiffuse",void 0),Object(B.c)([Object(_.c)("useSpecularOverAlpha")],ee.prototype,"_useSpecularOverAlpha",void 0),Object(B.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"useSpecularOverAlpha",void 0),Object(B.c)([Object(_.c)("useReflectionOverAlpha")],ee.prototype,"_useReflectionOverAlpha",void 0),Object(B.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"useReflectionOverAlpha",void 0),Object(B.c)([Object(_.c)("disableLighting")],ee.prototype,"_disableLighting",void 0),Object(B.c)([Object(_.b)("_markAllSubMeshesAsLightsDirt
826y")],ee.prototype,"disableLighting",void 0),Object(B.c)([Object(_.c)("useObjectSpaceNormalMap")],ee.prototype,"_useObjectSpaceNormalMap",void 0),Object(B.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"useObjectSpaceNormalMap",void 0),Object(B.c)([Object(_.c)("useParallax")],ee.prototype,"_useParallax",void 0),Object(B.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"useParallax",void 0),Object(B.c)([Object(_.c)("useParallaxOcclusion")],ee.prototype,"_useParallaxOcclusion",void 0),Object(B.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"useParallaxOcclusion",void 0),Object(B.c)([Object(_.c)()],ee.prototype,"parallaxScaleBias",void 0),Object(B.c)([Object(_.c)("roughness")],ee.prototype,"_roughness",void 0),Object(B.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"roughness",void 0),Object(B.c)([Object(_.c)()],ee.prototype,"indexOfRefraction",void 0),Object(B.c)([Object(_.c)()],ee.prototype,"invertRefractionY",void 0),Object(B.c)([Object(_.c)()],ee.prototype,"alphaCutOff",void 0),Object(B.c)([Object(_.c)("useLightmapAsShadowmap")],ee.prototype,"_useLightmapAsShadowmap",void 0),Object(B.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"useLightmapAsShadowmap",void 0),Object(B.c)([Object(_.h)("diffuseFresnelParameters")],ee.prototype,"_diffuseFresnelParameters",void 0),Object(B.c)([Object(_.b)("_markAllSubMeshesAsFresnelDirty")],ee.prototype,"diffuseFresnelParameters",void 0),Object(B.c)([Object(_.h)("opacityFresnelParameters")],ee.prototype,"_opacityFresnelParameters",void 0),Object(B.c)([Object(_.b)("_markAllSubMeshesAsFresnelAndMiscDirty")],ee.prototype,"opacityFresnelParameters",void 0),Object(B.c)([Object(_.h)("reflectionFresnelParameters")],ee.prototype,"_reflectionFresnelParameters",void 0),Object(B.c)([Object(_.b)("_markAllSubMeshesAsFresnelDirty")],ee.prototype,"reflectionFresnelParameters",void 0),Object(B.c)([Object(_.h)("refractionFresnelParameters")],ee.prototype,"_refractionFresnelParameters",void 0),Object(B.c)([Object(_.b)("_markAllSubMeshesAsFresnelDirty")],ee.prototype,"refractionFresnelParameters",void 0),Object(B.c)([Object(_.h)("emissiveFresnelParameters")],ee.prototype,"_emissiveFresnelParameters",void 0),Object(B.c)([Object(_.b)("_markAllSubMeshesAsFresnelDirty")],ee.prototype,"emissiveFresnelParameters",void 0),Object(B.c)([Object(_.c)("useReflectionFresnelFromSpecular")],ee.prototype,"_useReflectionFresnelFromSpecular",void 0),Object(B.c)([Object(_.b)("_markAllSubMeshesAsFresnelDirty")],ee.prototype,"useReflectionFresnelFromSpecular",void 0),Object(B.c)([Object(_.c)("useGlossinessFromSpecularMapAlpha")],ee.prototype,"_useGlossinessFromSpecularMapAlpha",void 0),Object(B.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"useGlossinessFromSpecularMapAlpha",void 0),Object(B.c)([Object(_.c)("maxSimultaneousLights")],ee.prototype,"_maxSimultaneousLights",void 0),Object(B.c)([Object(_.b)("_markAllSubMeshesAsLightsDirty")],ee.prototype,"maxSimultaneousLights",void 0),Object(B.c)([Object(_.c)("invertNormalMapX")],ee.prototype,"_invertNormalMapX",void 0),Object(B.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"invertNormalMapX",void 0),Object(B.c)([Object(_.c)("invertNormalMapY")],ee.prototype,"_invertNormalMapY",void 0),Object(B.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"invertNormalMapY",void 0),Object(B.c)([Object(_.c)("twoSidedLighting")],ee.prototype,"_twoSidedLighting",void 0),Object(B.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"twoSidedLighting",void 0),Object(B.c)([Object(_.c)()],ee.prototype,"useLogarithmicDepth",null),ee}(S.a);h.a.RegisteredTypes["BABYLON.StandardMaterial"]=pe,u.a.DefaultMaterialFactory=function(ae){return new pe("default material",ae)}},function(Ae,v,f){f.d(v,"a",function(){return I});var B=f(1),_=f(12),x=f(6),u=f(0),M=f(13),R=f(4),C=f(16),m=f(46),c=f(54),E=f(43),A=f(2),S=f(147),g=f(21),l=f(101),h=f(9),b=f(28),T=f(23),D=f(11),w=function(){this.facetNb=0,this.partitioningSubdivisions=10,this.partitioningBBoxRatio=1.01,this.facetDataEnabled=!1,this.facetParameters={},this.bbSize=u.e.Zero(),this.subDiv={max:1,X:1,Y:1,Z:1},this.facetDepthSort=!1,this.facetDepthSortEnabled=!1},N=function(){this._hasVertexAlpha=!1,this._useVertexColors=!0,this._numBoneInfluencers=4,this._applyFog=!0,this._receiveShadows=!1,this._facetData=new w,this._visibility=1,this._skeleton=null,this._layerMask=268435455,this._computeBonesUsingShaders=!0,this._isActive=!1,this._onlyForInstances=!1,this._isActiveIntermediate=!1,this._onlyForInstancesIntermediate=!1,this._actAsRegularMesh=!1,this._currentLOD=null,this._currentLODIsUpToDate=!1},I=function(V){function W(j,ne){ne===void 0&&(ne=null);var te=V.call(this,j,ne,!1)||this;return te._internalAbstractMeshDataInfo=new N,te.cullingStrategy=W.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY,te.onCollideObservable=new x.c,te.onCollisionPositionChangeObservable=new x.c,te.onMaterialChangedObservable=new x.c,te.definedFacingForward=!0,te._occlusionQuery=null,te._renderingGroup=null,te.alphaIndex=Number.MAX_VALUE,te.isVisible=!0,te.isPickable=!0,te.showSubMeshesBoundingBox=!1,te.isBlocker=!1,te.enablePointerMoveEvents=!1,te._renderingGroupId=0,te._material=null,te.outlineColor=h.a.Red(),te.outlineWidth=.02,te.overlayColor=h.a.Red(),te.overlayAlpha=.5,te.useOctreeForRenderingSelection=!0,te.useOctreeForPicking=!0,te.useOctreeForCollisions=!0,te.alwaysSelectAsActiveMesh=!1,te.doNotSyncBoundingInfo=!1,te.actionManager=null,te._meshCollisionData=new S.a,te.ellipsoid=new u.e(.5,1,.5),te.ellipsoidOffset=new u.e(0,0,0),te.edgesWidth=1,te.edgesColor=new h.b(1,0,0,1),te._edgesRenderer=null,te._masterMesh=null,te._boundingInfo=null,te._renderId=0,te._intersectionsInProgress=new Array,te._unIndexed=!1,te._lightSources=new Array,te._waitingData={lods:null,actions:null,freezeWorldMatrix:null},te._bonesTransformMatrices=null,te._transformMatrixTexture=null,te.onRebuildObservable=new x.c,te._onCollisionPositionChange=function(de,pe,ae){ae===void 0&&(ae=null),pe.subtractToRef(te._meshCollisionData._oldPositionForCollisions,te._meshCollisionData._diffPositionForCollisions),te._meshCollisionData._diffPositionForCollisions.length()>M.a.CollisionsEpsilon&&te.position.addInPlace(te._meshCollisionData._diffPositionForCollisions),ae&&te.onCollideObservable.notifyObservers(ae),te.onCollisionPositionChangeObservable.notifyObservers(te.position)}
826,te.getScene().addMesh(te),te._resyncLightSources(),te}return Object(B.d)(W,V),Object.defineProperty(W,"BILLBOARDMODE_NONE",{get:function(){return m.a.BILLBOARDMODE_NONE},enumerable:!1,configurable:!0}),Object.defineProperty(W,"BILLBOARDMODE_X",{get:function(){return m.a.BILLBOARDMODE_X},enumerable:!1,configurable:!0}),Object.defineProperty(W,"BILLBOARDMODE_Y",{get:function(){return m.a.BILLBOARDMODE_Y},enumerable:!1,configurable:!0}),Object.defineProperty(W,"BILLBOARDMODE_Z",{get:function(){return m.a.BILLBOARDMODE_Z},enumerable:!1,configurable:!0}),Object.defineProperty(W,"BILLBOARDMODE_ALL",{get:function(){return m.a.BILLBOARDMODE_ALL},enumerable:!1,configurable:!0}),Object.defineProperty(W,"BILLBOARDMODE_USE_POSITION",{get:function(){return m.a.BILLBOARDMODE_USE_POSITION},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"facetNb",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetNb},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"partitioningSubdivisions",{get:function(){return this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions},set:function(j){this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions=j},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"partitioningBBoxRatio",{get:function(){return this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio},set:function(j){this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio=j},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"mustDepthSortFacets",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetDepthSort},set:function(j){this._internalAbstractMeshDataInfo._facetData.facetDepthSort=j},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"facetDepthSortFrom",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom},set:function(j){this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom=j},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"isFacetDataEnabled",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetDataEnabled},enumerable:!1,configurable:!0}),W.prototype._updateNonUniformScalingState=function(j){return!!V.prototype._updateNonUniformScalingState.call(this,j)&&(this._markSubMeshesAsMiscDirty(),!0)},Object.defineProperty(W.prototype,"onCollide",{set:function(j){this._meshCollisionData._onCollideObserver&&this.onCollideObservable.remove(this._meshCollisionData._onCollideObserver),this._meshCollisionData._onCollideObserver=this.onCollideObservable.add(j)},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"onCollisionPositionChange",{set:function(j){this._meshCollisionData._onCollisionPositionChangeObserver&&this.onCollisionPositionChangeObservable.remove(this._meshCollisionData._onCollisionPositionChangeObserver),this._meshCollisionData._onCollisionPositionChangeObserver=this.onCollisionPositionChangeObservable.add(j)},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"visibility",{get:function(){return this._internalAbstractMeshDataInfo._visibility},set:function(j){this._internalAbstractMeshDataInfo._visibility!==j&&(this._internalAbstractMeshDataInfo._visibility=j,this._markSubMeshesAsMiscDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"renderingGroupId",{get:function(){return this._renderingGroupId},set:function(j){this._renderingGroupId=j},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"material",{get:function(){return this._material},set:function(j){this._material!==j&&(this._material&&this._material.meshMap&&(this._material.meshMap[this.uniqueId]=void 0),this._material=j,j&&j.meshMap&&(j.meshMap[this.uniqueId]=this),this.onMaterialChangedObservable.hasObservers()&&this.onMaterialChangedObservable.notifyObservers(this),this.subMeshes&&this._unBindEffect())},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"receiveShadows",{get:function(){return this._internalAbstractMeshDataInfo._receiveShadows},set:function(j){this._internalAbstractMeshDataInfo._receiveShadows!==j&&(this._internalAbstractMeshDataInfo._receiveShadows=j,this._markSubMeshesAsLightDirty())}
826,enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"hasVertexAlpha",{get:function(){return this._internalAbstractMeshDataInfo._hasVertexAlpha},set:function(j){this._internalAbstractMeshDataInfo._hasVertexAlpha!==j&&(this._internalAbstractMeshDataInfo._hasVertexAlpha=j,this._markSubMeshesAsAttributesDirty(),this._markSubMeshesAsMiscDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"useVertexColors",{get:function(){return this._internalAbstractMeshDataInfo._useVertexColors},set:function(j){this._internalAbstractMeshDataInfo._useVertexColors!==j&&(this._internalAbstractMeshDataInfo._useVertexColors=j,this._markSubMeshesAsAttributesDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"computeBonesUsingShaders",{get:function(){return this._internalAbstractMeshDataInfo._computeBonesUsingShaders},set:function(j){this._internalAbstractMeshDataInfo._computeBonesUsingShaders!==j&&(this._internalAbstractMeshDataInfo._computeBonesUsingShaders=j,this._markSubMeshesAsAttributesDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"numBoneInfluencers",{get:function(){return this._internalAbstractMeshDataInfo._numBoneInfluencers},set:function(j){this._internalAbstractMeshDataInfo._numBoneInfluencers!==j&&(this._internalAbstractMeshDataInfo._numBoneInfluencers=j,this._markSubMeshesAsAttributesDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"applyFog",{get:function(){return this._internalAbstractMeshDataInfo._applyFog},set:function(j){this._internalAbstractMeshDataInfo._applyFog!==j&&(this._internalAbstractMeshDataInfo._applyFog=j,this._markSubMeshesAsMiscDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"layerMask",{get:function(){return this._internalAbstractMeshDataInfo._layerMask},set:function(j){j!==this._internalAbstractMeshDataInfo._layerMask&&(this._internalAbstractMeshDataInfo._layerMask=j,this._resyncLightSources())},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"collisionMask",{get:function(){return this._meshCollisionData._collisionMask},set:function(j){this._meshCollisionData._collisionMask=isNaN(j)?-1:j},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"collisionResponse",{get:function(){return this._meshCollisionData._collisionResponse},set:function(j){this._meshCollisionData._collisionResponse=j},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"collisionGroup",{get:function(){return this._meshCollisionData._collisionGroup},set:function(j){this._meshCollisionData._collisionGroup=isNaN(j)?-1:j},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"surroundingMeshes",{get:function(){return this._meshCollisionData._surroundingMeshes},set:function(j){this._meshCollisionData._surroundingMeshes=j},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"lightSources",{get:function(){return this._lightSources},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"_positions",{get:function(){return null},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"skeleton",{get:function(){return this._internalAbstractMeshDataInfo._skeleton},set:function(j){var ne=this._internalAbstractMeshDataInfo._skeleton;ne&&ne.needInitialSkinMatrix&&ne._unregisterMeshWithPoseMatrix(this),j&&j.needInitialSkinMatrix&&j._registerMeshWithPoseMatrix(this),this._internalAbstractMeshDataInfo._skeleton=j,this._internalAbstractMeshDataInfo._skeleton||(this._bonesTransformMatrices=null),this._markSubMeshesAsAttributesDirty()},enumerable:!1,configurable:!0}),W.prototype.getClassName=function(){return"AbstractMesh"},W.prototype.toString=function(j){var ne="Name: "+this.name+", isInstance: "+(this.getClassName()!=="InstancedMesh"?"YES":"NO");ne+=", # of submeshes: "+(this.subMeshes?this.subMeshes.length:0);var te=this._internalAbstractMeshDataInfo._skeleton;return te&&(ne+=", skeleton: "+te.name),j&&(ne+=", billboard mode: "+["NONE","X","Y",null,"Z",null,null,"ALL"][this.billboardMode],ne+=", freeze wrld mat: "+(this._isWorldMatrixFrozen||this._waitingData.freezeWorldMatrix?"YES":"NO")),ne},W.prototype._getEffectiveParent=function(){return this._masterMesh&&this.billboardMode!==m.a.BILLBOARDMODE_NONE?this._masterMesh:V.prototype._getEffectiveParent.call(this)},W.prototype._getActionManagerForTrigger=function(j,ne){if(ne===void 0&&(ne=!0),this.actionManager&&(ne||this.actionManager.isRecursive)){if(!j)return this.actionManager;if(this.actionManager.hasSpecificTrigger(j))return this.actionManager}return this.parent?this.parent._getActionManagerForTrigger(j,!1):null},W.prototype._rebuild=function(){if(this.onRebuildObservable.notifyObservers(this),this._occlusionQuery&&(this._occlusionQuery=null),this.subMeshes)for(var j=0,ne=this.subMeshes;j<ne.length;j++)ne[j]._rebuild()},W.prototype._resyncLightSources=function(){this._lightSources.length=0;for(var j=0,ne=this.getScene().lights;j<ne.length;j++){var te=ne[j];te.isEnabled()&&te.canAffectMesh(this)&&this._lightSources.push(te)}this._markSubMeshesAsLightDirty()},W.prototype._resyncLightSource=function(j){var ne=j.isEnabled()&&j.canAffectMesh(this),te=this._lightSources.indexOf(j),de=!1;if(te===-1){if(!ne)return;this._lightSources.push(j)}else{if(ne)return;de=!0,this._lightSources.splice(te,1)}this._markSubMeshesAsLightDirty(de)},W.prototype._unBindEffect=function(){for(var j=0,ne=this.subMeshes;j<ne.length;j++)ne[j].setEffect(null)},W.prototype._removeLightSource=function(j,ne){var te=this._lightSources.indexOf(j);te!==-1&&(this._lightSources.splice(te,1),this._markSubMeshesAsLightDirty(ne))},W.prototype._markSubMeshesAsDirty=function(j){if(this.subMeshes)for(var ne=0,te=this.subMeshes;ne<te.length;ne++){var de=te[ne];de._materialDefines&&j(de._materialDefines)}},W.prototype._markSubMeshesAsLightDirty=function(j){j===void 0&&(j=!1),this._markSubMeshesAsDirty(function(ne){return ne.markAsLightDirty(j)})},W.prototype._markSubMeshesAsAttributesDirty=function(){this._markSubMeshesAsDirty(function(j){return j.markAsAttributesDirty()})},W.prototype._markSubMeshesAsMiscDirty=function(){this._markSubMeshesAsDirty(function(j){return j.markAsMiscDirty()})}
826,Object.defineProperty(W.prototype,"scaling",{get:function(){return this._scaling},set:function(j){this._scaling=j},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"isBlocked",{get:function(){return!1},enumerable:!1,configurable:!0}),W.prototype.getLOD=function(j){return this},W.prototype.getTotalVertices=function(){return 0},W.prototype.getTotalIndices=function(){return 0},W.prototype.getIndices=function(){return null},W.prototype.getVerticesData=function(j){return null},W.prototype.setVerticesData=function(j,ne,te,de){return this},W.prototype.updateVerticesData=function(j,ne,te,de){return this},W.prototype.setIndices=function(j,ne){return this},W.prototype.isVerticesDataPresent=function(j){return!1},W.prototype.getBoundingInfo=function(){return this._masterMesh?this._masterMesh.getBoundingInfo():(this._boundingInfo||this._updateBoundingInfo(),this._boundingInfo)},W.prototype.normalizeToUnitCube=function(j,ne,te){return j===void 0&&(j=!0),ne===void 0&&(ne=!1),V.prototype.normalizeToUnitCube.call(this,j,ne,te)},W.prototype.setBoundingInfo=function(j){return this._boundingInfo=j,this},Object.defineProperty(W.prototype,"useBones",{get:function(){return this.skeleton&&this.getScene().skeletonsEnabled&&this.isVerticesDataPresent(R.b.MatricesIndicesKind)&&this.isVerticesDataPresent(R.b.MatricesWeightsKind)},enumerable:!1,configurable:!0}),W.prototype._preActivate=function(){},W.prototype._preActivateForIntermediateRendering=function(j){},W.prototype._activate=function(j,ne){return this._renderId=j,!0},W.prototype._postActivate=function(){},W.prototype._freeze=function(){},W.prototype._unFreeze=function(){},W.prototype.getWorldMatrix=function(){return this._masterMesh&&this.billboardMode===m.a.BILLBOARDMODE_NONE?this._masterMesh.getWorldMatrix():V.prototype.getWorldMatrix.call(this)},W.prototype._getWorldMatrixDeterminant=function(){return this._masterMesh?this._masterMesh._getWorldMatrixDeterminant():V.prototype._getWorldMatrixDeterminant.call(this)},Object.defineProperty(W.prototype,"isAnInstance",{get:function(){return!1},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"hasInstances",{get:function(){return!1},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"hasThinInstances",{get:function(){return!1},enumerable:!1,configurable:!0}),W.prototype.movePOV=function(j,ne,te){return this.position.addInPlace(this.calcMovePOV(j,ne,te)),this},W.prototype.calcMovePOV=function(j,ne,te){var de=new u.a;(this.rotationQuaternion?this.rotationQuaternion:u.b.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z)).toRotationMatrix(de);var pe=u.e.Zero(),ae=this.definedFacingForward?-1:1;return u.e.TransformCoordinatesFromFloatsToRef(j*ae,ne,te*ae,de,pe),pe},W.prototype.rotatePOV=function(j,ne,te){return this.rotation.addInPlace(this.calcRotatePOV(j,ne,te)),this},W.prototype.calcRotatePOV=function(j,ne,te){var de=this.definedFacingForward?1:-1;return new u.e(j*de,ne,te*de)},W.prototype.refreshBoundingInfo=function(j){return j===void 0&&(j=!1),this._boundingInfo&&this._boundingInfo.isLocked||this._refreshBoundingInfo(this._getPositionData(j),null),this},W.prototype._refreshBoundingInfo=function(j,ne){if(j){var te=Object(l.a)(j,0,this.getTotalVertices(),ne);this._boundingInfo?this._boundingInfo.reConstruct(te.minimum,te.maximum):this._boundingInfo=new E.a(te.minimum,te.maximum)}if(this.subMeshes)for(var de=0;de<this.subMeshes.length;de++)this.subMeshes[de].refreshBoundingInfo(j);this._updateBoundingInfo()},W.prototype._getPositionData=function(j){var ne=this.getVerticesData(R.b.PositionKind);if(ne&&j&&this.skeleton){ne=_.b.Slice(ne),this._generatePointsArray();var te=this.getVerticesData(R.b.MatricesIndicesKind),de=this.getVerticesData(R.b.MatricesWeightsKind);if(de&&te){var pe=this.numBoneInfluencers>4,ae=pe?this.getVerticesData(R.b.MatricesIndicesExtraKind):null,ee=pe?this.getVerticesData(R.b.MatricesWeightsExtraKind):null;this.skeleton.prepare();for(var K=this.skeleton.getTransformMatrices(this),$=u.c.Vector3[0],L=u.c.Matrix[0],G=u.c.Matrix[1],Q=0,oe=0;oe<ne.length;oe+=3,Q+=4){var re,Y;for(L.reset(),re=0;re<4;re++)(Y=de[Q+re])>0&&(u.a.FromFloat32ArrayToRefScaled(K,Math.floor(16*te[Q+re]),Y,G),L.addToSelf(G));if(pe)for(re=0;re<4;re++)(Y=ee[Q+re])>0&&(u.a.FromFloat32ArrayToRefScaled(K,Math.floor(16*ae[Q+re]),Y,G),L.addToSelf(G));u.e.TransformCoordinatesFromFloatsToRef(ne[oe],ne[oe+1],ne[oe+2],L,$),$.toArray(ne,oe),this._positions&&this._positions[oe/3].copyFrom($)}}}return ne},W.prototype._updateBoundingInfo=function(){var j=this._effectiveMesh;return this._boundingInfo?this._boundingInfo.update(j.worldMatrixFromCache):this._boundingInfo=new E.a(this.absolutePosition,this.absolutePosition,j.worldMatrixFromCache),this._updateSubMeshesBoundingInfo(j.worldMatrixFromCache),this},W.prototype._updateSubMeshesBoundingInfo=function(j){if(!this.subMeshes)return this;for(var ne=this.subMeshes.length,te=0;te<ne;te++){var de=this.subMeshes[te];(ne>1||!de.IsGlobal)&&de.updateBoundingInfo(j)}return this},W.prototype._afterComputeWorldMatrix=function(){this.doNotSyncBoundingInfo||this._updateBoundingInfo()},Object.defineProperty(W.prototype,"_effectiveMesh",{get:function(){return this.skeleton&&this.skeleton.overrideMesh||this}
826,enumerable:!1,configurable:!0}),W.prototype.isInFrustum=function(j){return this._boundingInfo!==null&&this._boundingInfo.isInFrustum(j,this.cullingStrategy)},W.prototype.isCompletelyInFrustum=function(j){return this._boundingInfo!==null&&this._boundingInfo.isCompletelyInFrustum(j)},W.prototype.intersectsMesh=function(j,ne,te){if(ne===void 0&&(ne=!1),!this._boundingInfo||!j._boundingInfo)return!1;if(this._boundingInfo.intersects(j._boundingInfo,ne))return!0;if(te){for(var de=0,pe=this.getChildMeshes();de<pe.length;de++)if(pe[de].intersectsMesh(j,ne,!0))return!0}return!1},W.prototype.intersectsPoint=function(j){return!!this._boundingInfo&&this._boundingInfo.intersectsPoint(j)},Object.defineProperty(W.prototype,"checkCollisions",{get:function(){return this._meshCollisionData._checkCollisions},set:function(j){this._meshCollisionData._checkCollisions=j},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"collider",{get:function(){return this._meshCollisionData._collider},enumerable:!1,configurable:!0}),W.prototype.moveWithCollisions=function(j){this.getAbsolutePosition().addToRef(this.ellipsoidOffset,this._meshCollisionData._oldPositionForCollisions);var ne=this.getScene().collisionCoordinator;return this._meshCollisionData._collider||(this._meshCollisionData._collider=ne.createCollider()),this._meshCollisionData._collider._radius=this.ellipsoid,ne.getNewPosition(this._meshCollisionData._oldPositionForCollisions,j,this._meshCollisionData._collider,3,this,this._onCollisionPositionChange,this.uniqueId),this},W.prototype._collideForSubMesh=function(j,ne,te){if(this._generatePointsArray(),!this._positions)return this;if(!j._lastColliderWorldVertices||!j._lastColliderTransformMatrix.equals(ne)){j._lastColliderTransformMatrix=ne.clone(),j._lastColliderWorldVertices=[],j._trianglePlanes=[];for(var de=j.verticesStart,pe=j.verticesStart+j.verticesCount,ae=de;ae<pe;ae++)j._lastColliderWorldVertices.push(u.e.TransformCoordinates(this._positions[ae],ne))}return te._collide(j._trianglePlanes,j._lastColliderWorldVertices,this.getIndices(),j.indexStart,j.indexStart+j.indexCount,j.verticesStart,!!j.getMaterial(),this),this},W.prototype._processCollisionsForSubMeshes=function(j,ne){for(var te=this._scene.getCollidingSubMeshCandidates(this,j),de=te.length,pe=0;pe<de;pe++){var ae=te.data[pe];de>1&&!ae._checkCollision(j)||this._collideForSubMesh(ae,ne,j)}return this},W.prototype._checkCollision=function(j){if(!this._boundingInfo||!this._boundingInfo._checkCollision(j))return this;var ne=u.c.Matrix[0],te=u.c.Matrix[1];return u.a.ScalingToRef(1/j._radius.x,1/j._radius.y,1/j._radius.z,ne),this.worldMatrixFromCache.multiplyToRef(ne,te),this._processCollisionsForSubMeshes(j,te),this},W.prototype._generatePointsArray=function(){return!1},W.prototype.intersects=function(j,ne,te,de,pe,ae){var ee;de===void 0&&(de=!1),ae===void 0&&(ae=!1);var K=new c.a,$=this.getClassName()==="InstancedLinesMesh"||this.getClassName()==="LinesMesh"?this.intersectionThreshold:0,L=this._boundingInfo;if(!this.subMeshes||!L||!(ae||j.intersectsSphere(L.boundingSphere,$)&&j.intersectsBox(L.boundingBox,$)))return K;if(de)return K.hit=!ae,K.pickedMesh=ae?null:this,K.distance=ae?0:u.e.Distance(j.origin,L.boundingSphere.center),K.subMeshId=0,K;if(!this._generatePointsArray())return K;for(var G=null,Q=this._scene.getIntersectingSubMeshCandidates(this,j),oe=Q.length,re=!1,Y=0;Y<oe;Y++){var k=(H=Q.data[Y]).getMaterial();if(k&&(!((ee=this.getIndices())===null||ee===void 0)&&ee.length)&&(k.fillMode==A.a.MATERIAL_TriangleStripDrawMode||k.fillMode==A.a.MATERIAL_TriangleFillMode||k.fillMode==A.a.MATERIAL_WireFrameFillMode||k.fillMode==A.a.MATERIAL_PointFillMode)){re=!0;break}}if(!re)return K.hit=!0,K.pickedMesh=this,K.distance=u.e.Distance(j.origin,L.boundingSphere.center),K.subMeshId=-1,K;for(Y=0;Y<oe;Y++){var H=Q.data[Y];if(!(oe>1)||H.canIntersects(j)){var Z=H.intersects(j,this._positions,this.getIndices(),ne,te);if(Z&&(ne||!G||Z.distance<G.distance)&&((G=Z).subMeshId=Y,ne))break}}if(G){var X=pe??(this.skeleton&&this.skeleton.overrideMesh?this.skeleton.overrideMesh.getWorldMatrix():this.getWorldMatrix()),q=u.c.Vector3[0],he=u.c.Vector3[1];u.e.TransformCoordinatesToRef(j.origin,X,q),j.direction.scaleToRef(G.distance,he);var ge=u.e.TransformNormal(he,X).addInPlace(q);return K.hit=!0,K.distance=u.e.Distance(q,ge),K.pickedPoint=ge,K.pickedMesh=this,K.bu=G.bu||0,K.bv=G.bv||0,K.subMeshFaceId=G.faceId,K.faceId=G.faceId+Q.data[G.subMeshId].indexStart/(this.getClassName().indexOf("LinesMesh")!==-1?2:3),K.subMeshId=G.subMeshId,K}return K},W.prototype.clone=function(j,ne,te){return null},W.prototype.releaseSubMeshes=function(){if(this.subMeshes)for(;this.subMeshes.length;)this.subMeshes[0].dispose();else this.subMeshes=new Array;return this},W.prototype.dispose=function(j,ne){var te,de=this;for(ne===void 0&&(ne=!1),this._scene.useMaterialMeshMap&&this._material&&this._material.meshMap&&(this._material.meshMap[this.uniqueId]=void 0),this.get
826Scene().freeActiveMeshes(),this.getScene().freeRenderingGroups(),this.actionManager!==void 0&&this.actionManager!==null&&(this.actionManager.dispose(),this.actionManager=null),this._internalAbstractMeshDataInfo._skeleton=null,this._transformMatrixTexture&&(this._transformMatrixTexture.dispose(),this._transformMatrixTexture=null),te=0;te<this._intersectionsInProgress.length;te++){var pe=this._intersectionsInProgress[te],ae=pe._intersectionsInProgress.indexOf(this);pe._intersectionsInProgress.splice(ae,1)}this._intersectionsInProgress=[],this.getScene().lights.forEach(function(K){var $=K.includedOnlyMeshes.indexOf(de);$!==-1&&K.includedOnlyMeshes.splice($,1),($=K.excludedMeshes.indexOf(de))!==-1&&K.excludedMeshes.splice($,1);var L=K.getShadowGenerator();if(L){var G=L.getShadowMap();G&&G.renderList&&($=G.renderList.indexOf(de))!==-1&&G.renderList.splice($,1)}}),this.getClassName()==="InstancedMesh"&&this.getClassName()==="InstancedLinesMesh"||this.releaseSubMeshes();var ee=this.getScene().getEngine();if(this._occlusionQuery&&(this.isOcclusionQueryInProgress=!1,ee.deleteQuery(this._occlusionQuery),this._occlusionQuery=null),ee.wipeCaches(),this.getScene().removeMesh(this),ne&&this.material&&(this.material.getClassName()==="MultiMaterial"?this.material.dispose(!1,!0,!0):this.material.dispose(!1,!0)),!j)for(te=0;te<this.getScene().particleSystems.length;te++)this.getScene().particleSystems[te].emitter===this&&(this.getScene().particleSystems[te].dispose(),te--);this._internalAbstractMeshDataInfo._facetData.facetDataEnabled&&this.disableFacetData(),this.onAfterWorldMatrixUpdateObservable.clear(),this.onCollideObservable.clear(),this.onCollisionPositionChangeObservable.clear(),this.onRebuildObservable.clear(),V.prototype.dispose.call(this,j,ne)},W.prototype.addChild=function(j){return j.setParent(this),this},W.prototype.removeChild=function(j){return j.setParent(null),this},W.prototype._initFacetData=function(){var j=this._internalAbstractMeshDataInfo._facetData;j.facetNormals||(j.facetNormals=new Array),j.facetPositions||(j.facetPositions=new Array),j.facetPartitioning||(j.facetPartitioning=new Array),j.facetNb=this.getIndices().length/3|0,j.partitioningSubdivisions=j.partitioningSubdivisions?j.partitioningSubdivisions:10,j.partitioningBBoxRatio=j.partitioningBBoxRatio?j.partitioningBBoxRatio:1.01;for(var ne=0;ne<j.facetNb;ne++)j.facetNormals[ne]=u.e.Zero(),j.facetPositions[ne]=u.e.Zero();return j.facetDataEnabled=!0,this},W.prototype.updateFacetData=function(){var j=this._internalAbstractMeshDataInfo._facetData;j.facetDataEnabled||this._initFacetData();var ne=this.getVerticesData(R.b.PositionKind),te=this.getIndices(),de=this.getVerticesData(R.b.NormalKind),pe=this.getBoundingInfo();if(j.facetDepthSort&&!j.facetDepthSortEnabled){if(j.facetDepthSortEnabled=!0,te instanceof Uint16Array)j.depthSortedIndices=new Uint16Array(te);else if(te instanceof Uint32Array)j.depthSortedIndices=new Uint32Array(te);else{for(var ae=!1,ee=0;ee<te.length;ee++)if(te[ee]>65535){ae=!0;break}j.depthSortedIndices=ae?new Uint32Array(te):new Uint16Array(te)}if(j.facetDepthSortFunction=function(re,Y){return Y.sqDistance-re.sqDistance},!j.facetDepthSortFrom){var K=this.getScene().activeCamera;j.facetDepthSortFrom=K?K.position:u.e.Zero()}j.depthSortedFacets=[];for(var $=0;$<j.facetNb;$++){var L={ind:3*$,sqDistance:0};j.depthSortedFacets.push(L)}j.invertedMatrix=u.a.Identity(),j.facetDepthSortOrigin=u.e.Zero()}j.bbSize.x=pe.maximum.x-pe.minimum.x>b.a?pe.maximum.x-pe.minimum.x:b.a,j.bbSize.y=pe.maximum.y-pe.minimum.y>b.a?pe.maximum.y-pe.minimum.y:b.a,j.bbSize.z=pe.maximum.z-pe.minimum.z>b.a?pe.maximum.z-pe.minimum.z:b.a;var G=j.bbSize.x>j.bbSize.y?j.bbSize.x:j.bbSize.y;if(G=G>j.bbSize.z?G:j.bbSize.z,j.subDiv.max=j.partitioningSubdivisions,j.subDiv.X=Math.floor(j.subDiv.max*j.bbSize.x/G),j.subDiv.Y=Math.floor(j.subDiv.max*j.bbSize.y/G),j.subDiv.Z=Math.floor(j.subDiv.max*j.bbSize.z/G),j.subDiv.X=j.subDiv.X<1?1:j.subDiv.X,j.subDiv.Y=j.subDiv.Y<1?1:j.subDiv.Y,j.subDiv.Z=j.subDiv.Z<1?1:j.subDiv.Z,j.facetParameters.facetNormals=this.getFacetLocalNormals(),j.facetParameters.facetPositions=this.getFacetLocalPositions(),j.facetParameters.facetPartitioning=this.getFacetLocalPartitioning(),j.facetParameters.bInfo=pe,j.facetParameters.bbSize=j.bbSize,j.facetParameters.subDiv=j.subDiv,j.facetParameters.ratio=this.partitioningBBoxRatio,j.facetParameters.depthSort=j.facetDepthSort,j.facetDepthSort&&j.facetDepthSortEnabled&&(this.computeWorldMatrix(!0),this._worldMatrix.invertToRef(j.invertedMatrix),u.e.TransformCoordinatesToRef(j.facetDepthSortFrom,j.invertedMatrix,j.facetDepthSortOrigin),j.facetParameters.distanceTo=j.facetDepthSortOrigin),j.facetParameters.depthSortedFacets=j.depthSortedFacets,C.a.ComputeNormals(ne,te,de,j.facetParameters),j.facetDepthSort&&j.facetDepthSortEnabled){j.depthSortedFacets.sort(j.facetDepthSortFunction);var Q=j.depthSortedIndices.length/3|0;for($=0;$<Q;$++){var oe=j.depthSortedFacets[$].ind;j.depthSortedIndices[3*$]=te[oe],j.depthSortedIndices[3*$+1]=te[oe+1],j.depthSortedIndices[3*$+2]=te[oe+2]}this.updateIndices(j.depthSortedIndices,void 0,!0)}return this},W.prototype.getFacetLocalNormals=function(){var j=this._internalAbstractMeshDataInfo._facetData;return j.facetNormals||this.updateFacetData(),j.facetNormals},W.prototype.getFacetLocalPositions=function(){var j=this._internalAbstractMeshDataInfo._facetData;return j.facetPositions||this.updateFacetData(),j.facetPositions},W.prototype.getFacetLocalPartitioning=function(){var j=this._internalAbstractMeshDataInfo._facetData;return j.facetPartitioning||this.updateFacetData(),j.facetPartitioning},W.prototype.getFacetPosition=function(j){var ne=u.e.Zero();return this.getFacetPositionToRef(j,ne),ne},W.prototype.getFacetPositionToRef=function(j,ne){var te=this.getFacetLocalPositions()[j],de=this.getWorldMatrix();return u.e.TransformCoordinatesToRef(te,de,ne),this},W.prototype.getFacetNormal=function(j){var ne=u.e.Zero();return this.getFacetNormalToRef(j,ne),ne},W.prototype.getFacetNormalToRef=function(j,ne){var te=this.getFacetLocalNormals()[j];return u.e.TransformNormalToRef(te,this.getWorldMatrix(),ne),this},W.prototype.getFacetsAtLocalCoordinates=function(j,ne,te){var de=this.getBoundingInfo(),pe=this._internalAbstractMeshDataInfo._facetData,ae=Math.floor((j-de.minimum.x*pe.partitioningBBoxRatio)*pe.subDiv.X*pe.partitioningBBoxRatio/pe.bbSize.x),ee=Math.floor((ne-de.minimum.y*pe.partitioningBBoxRatio)*pe.subDiv.Y*pe.partitioningBBoxRatio/pe.bbSize.y),K=Math.floor((te-de.minimum.z*pe.partitioningBBoxRatio)*pe.subDiv.Z*pe.partitioningBBoxRatio/pe.bbSize.z);return ae<0||ae>pe.subDiv.max||ee<0||ee>pe.subDiv.max||K<0||K>pe.subDiv.max?null:pe.facetPartitioning[ae+pe.subDiv.max*ee+pe.subDiv.max*pe.subDiv.max*K]},W.prototype.getClosestFacetAtCoordinates=function(j,ne,te,de,pe,ae){pe===void 0&&(pe=!1),ae===void 0&&(ae=!0);var ee=this.getWorldMatrix(),K=u.c.Matrix[5];ee.invertToRef(K);var $=u.c.Vector3[8];u.e.TransformCoordinatesFromFloatsToRef(j,ne,te,K,$);var L=this.getClosestFacetAtLocalCoordinates($.x,$.y,$.z,de,pe,ae);return de&&u.e.TransformCoordinatesFromFloatsToRef(de.x,de.y,de.z,ee,de),L},W.prototype.getClosestFacetAtLocalCoordinates=function(j,ne,te,de,pe,ae){pe===void 0&&(pe=!1),ae===void 0&&(ae=!0);var ee=null,K=0,$=0,L=0,G=0,Q=0,oe=0,re=0,Y=0,k=this.getFacetLocalPositions(),H=this.getFacetLocalNormals(),Z=this.getFacetsAtLocalCoordinates(j,ne,te);if(!Z)return null;for(var X,q,he,ge=Number.MAX_VALUE,me=ge,_e=0;_e<Z.length;_e++)q=H[X=Z[_e]],G=(j-(he=k[X]).x)*q.x+(ne-he.y)*q.y+(te-he.z)*q.z,(!pe||pe&&ae&&G>=0||pe&&!ae&&G<=0)&&(G=q.x*he.x+q.y*he.y+q.z*he.z,Q=-(q.x*j+q.y*ne+q.z*te-G)/(q.x*q.x+q.y*q.y+q.z*q.z),(me=(K=(oe=j+q.x*Q)-j)*K+($=(re=ne+q.y*Q)-ne)*$+(L=(Y=te+q.z*Q
826)-te)*L)<ge&&(ge=me,ee=X,de&&(de.x=oe,de.y=re,de.z=Y)));return ee},W.prototype.getFacetDataParameters=function(){return this._internalAbstractMeshDataInfo._facetData.facetParameters},W.prototype.disableFacetData=function(){var j=this._internalAbstractMeshDataInfo._facetData;return j.facetDataEnabled&&(j.facetDataEnabled=!1,j.facetPositions=new Array,j.facetNormals=new Array,j.facetPartitioning=new Array,j.facetParameters=null,j.depthSortedIndices=new Uint32Array(0)),this},W.prototype.updateIndices=function(j,ne,te){return this},W.prototype.createNormals=function(j){var ne,te=this.getVerticesData(R.b.PositionKind),de=this.getIndices();return ne=this.isVerticesDataPresent(R.b.NormalKind)?this.getVerticesData(R.b.NormalKind):[],C.a.ComputeNormals(te,de,ne,{useRightHandedSystem:this.getScene().useRightHandedSystem}),this.setVerticesData(R.b.NormalKind,ne,j),this},W.prototype.alignWithNormal=function(j,ne){ne||(ne=T.a.Y);var te=u.c.Vector3[0],de=u.c.Vector3[1];return u.e.CrossToRef(ne,j,de),u.e.CrossToRef(j,de,te),this.rotationQuaternion?u.b.RotationQuaternionFromAxisToRef(te,j,de,this.rotationQuaternion):u.e.RotationFromAxisToRef(te,j,de,this.rotation),this},W.prototype._checkOcclusionQuery=function(){return!1},W.prototype.disableEdgesRendering=function(){throw g.a.WarnImport("EdgesRenderer")},W.prototype.enableEdgesRendering=function(j,ne,te){throw g.a.WarnImport("EdgesRenderer")},W.prototype.getConnectedParticleSystems=function(){var j=this;return this._scene.particleSystems.filter(function(ne){return ne.emitter===j})},W.OCCLUSION_TYPE_NONE=0,W.OCCLUSION_TYPE_OPTIMISTIC=1,W.OCCLUSION_TYPE_STRICT=2,W.OCCLUSION_ALGORITHM_TYPE_ACCURATE=0,W.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE=1,W.CULLINGSTRATEGY_STANDARD=A.a.MESHES_CULLINGSTRATEGY_STANDARD,W.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY=A.a.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY,W.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION=A.a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION,W.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY=A.a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY,W}(m.a);D.a.RegisteredTypes["BABYLON.AbstractMesh"]=I},function(Ae,v,f){f.d(v,"a",function(){return m});var B=f(8),_=f(44),x=f(0),u=f(31),M=f(7),R=f(50),C=f(23);M.a._PhysicsImpostorParser=function(c,E,A){return new m(E,A.physicsImpostor,{mass:A.physicsMass,friction:A.physicsFriction,restitution:A.physicsRestitution},c)};var m=function(){function c(E,A,S,g){var l=this;S===void 0&&(S={mass:0}),this.object=E,this.type=A,this._options=S,this._scene=g,this._pluginData={},this._bodyUpdateRequired=!1,this._onBeforePhysicsStepCallbacks=new Array,this._onAfterPhysicsStepCallbacks=new Array,this._onPhysicsCollideCallbacks=[],this._deltaPosition=x.e.Zero(),this._isDisposed=!1,this.soft=!1,this.segments=0,this._tmpQuat=new x.b,this._tmpQuat2=new x.b,this.beforeStep=function(){l._physicsEngine&&(l.object.translate(l._deltaPosition,-1),l._deltaRotationConjugated&&l.object.rotationQuaternion&&l.object.rotationQuaternion.multiplyToRef(l._deltaRotationConjugated,l.object.rotationQuaternion),l.object.computeWorldMatrix(!1),l.object.parent&&l.object.rotationQuaternion?(l.getParentsRotation(),l._tmpQuat.multiplyToRef(l.object.rotationQuaternion,l._tmpQuat)):l._tmpQuat.copyFrom(l.object.rotationQuaternion||new x.b),l._options.disableBidirectionalTransformation||l.object.rotationQuaternion&&l._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(l,l.object.getAbsolutePosition(),l._tmpQuat),l._onBeforePhysicsStepCallbacks.forEach(function(h){h(l)}))},this.afterStep=function(){l._physicsEngine&&(l._onAfterPhysicsStepCallbacks.forEach(function(h){h(l)}),l._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(l),l.object.parent&&l.object.rotationQuaternion&&(l.getParentsRotation(),l._tmpQuat.conjugateInPlace(),l._tmpQuat.multiplyToRef(l.object.rotationQuaternion,l.object.rotationQuaternion)),l.object.setAbsolutePosition(l.object.position),l._deltaRotation&&l.object.rotationQuaternion&&l.object.rotationQuaternion.multiplyToRef(l._deltaRotation,l.object.rotationQuaternion),l.object.translate(l._deltaPosition,1))},this.onCollideEvent=null,this.onCollide=function(h){if((l._onPhysicsCollideCallbacks.length||l.onCollideEvent)&&l._physicsEngine){var b=l._physicsEngine.getImpostorWithPhysicsBody(h.body);b&&(l.onCollideEvent&&l.onCollideEvent(l,b),l._onPhysicsCollideCallbacks.filter(function(T){return T.otherImpostors.indexOf(b)!==-1}
826).forEach(function(T){T.callback(l,b,h.point)}))}},this.object?(this.object.parent&&S.mass!==0&&B.a.Warn("A physics impostor has been created for an object which has a parent. Babylon physics currently works in local space so unexpected issues may occur."),!this._scene&&E.getScene&&(this._scene=E.getScene()),this._scene&&(this.type>100&&(this.soft=!0),this._physicsEngine=this._scene.getPhysicsEngine(),this._physicsEngine?(this.object.rotationQuaternion||(this.object.rotation?this.object.rotationQuaternion=x.b.RotationYawPitchRoll(this.object.rotation.y,this.object.rotation.x,this.object.rotation.z):this.object.rotationQuaternion=new x.b),this._options.mass=S.mass===void 0?0:S.mass,this._options.friction=S.friction===void 0?.2:S.friction,this._options.restitution=S.restitution===void 0?.2:S.restitution,this.soft&&(this._options.mass=this._options.mass>0?this._options.mass:1,this._options.pressure=S.pressure===void 0?200:S.pressure,this._options.stiffness=S.stiffness===void 0?1:S.stiffness,this._options.velocityIterations=S.velocityIterations===void 0?20:S.velocityIterations,this._options.positionIterations=S.positionIterations===void 0?20:S.positionIterations,this._options.fixedPoints=S.fixedPoints===void 0?0:S.fixedPoints,this._options.margin=S.margin===void 0?0:S.margin,this._options.damping=S.damping===void 0?0:S.damping,this._options.path=S.path===void 0?null:S.path,this._options.shape=S.shape===void 0?null:S.shape),this._joints=[],!this.object.parent||this._options.ignoreParent?this._init():this.object.parent.physicsImpostor&&B.a.Warn("You must affect impostors to children before affecting impostor to parent.")):B.a.Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors."))):B.a.Error("No object was provided. A physics object is obligatory")}return Object.defineProperty(c.prototype,"isDisposed",{get:function(){return this._isDisposed},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"mass",{get:function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getBodyMass(this):0},set:function(E){this.setMass(E)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"friction",{get:function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getBodyFriction(this):0},set:function(E){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyFriction(this,E)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"restitution",{get:function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this):0},set:function(E){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this,E)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"pressure",{get:function(){if(!this._physicsEngine)return 0;var E=this._physicsEngine.getPhysicsPlugin();return E.setBodyPressure?E.getBodyPressure(this):0},set:function(E){if(this._physicsEngine){var A=this._physicsEngine.getPhysicsPlugin();A.setBodyPressure&&A.setBodyPressure(this,E)}},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"stiffness",{get:function(){if(!this._physicsEngine)return 0;var E=this._physicsEngine.getPhysicsPlugin();return E.getBodyStiffness?E.getBodyStiffness(this):0},set:function(E){if(this._physicsEngine){var A=this._physicsEngine.getPhysicsPlugin();A.setBodyStiffness&&A.setBodyStiffness(this,E)}},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"velocityIterations",{get:function(){if(!this._physicsEngine)return 0;var E=this._physicsEngine.getPhysicsPlugin();return E.getBodyVelocityIterations?E.getBodyVelocityIterations(this):0},set:function(E){if(this._physicsEngine){var A=this._physicsEngine.getPhysicsPlugin();A.setBodyVelocityIterations&&A.setBodyVelocityIterations(this,E)}},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"positionIterations",{get:function(){if(!this._physicsEngine)return 0;var E=this._physicsEngine.getPhysicsPlugin();return E.getBodyPositionIterations?E.getBodyPositionIterations(this):0},set:function(E){if(this._physicsEngine){var A=this._physicsEngine.getPhysicsPlugin();A.setBodyPositionIterations&&A.setBodyPositionIterations(this,E)}}
826,enumerable:!1,configurable:!0}),c.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))},c.prototype._getPhysicsParent=function(){return this.object.parent instanceof u.a?this.object.parent.physicsImpostor:null},c.prototype.isBodyInitRequired=function(){return this._bodyUpdateRequired||!this._physicsBody&&!this._parent},c.prototype.setScalingUpdated=function(){this.forceUpdate()},c.prototype.forceUpdate=function(){this._init(),this.parent&&!this._options.ignoreParent&&this.parent.forceUpdate()},Object.defineProperty(c.prototype,"physicsBody",{get:function(){return this._parent&&!this._options.ignoreParent?this._parent.physicsBody:this._physicsBody},set:function(E){this._physicsBody&&this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this),this._physicsBody=E,this.resetUpdateFlags()},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"parent",{get:function(){return!this._options.ignoreParent&&this._parent?this._parent:null},set:function(E){this._parent=E},enumerable:!1,configurable:!0}),c.prototype.resetUpdateFlags=function(){this._bodyUpdateRequired=!1},c.prototype.getObjectExtendSize=function(){if(this.object.getBoundingInfo){var E=this.object.rotationQuaternion,A=this.object.scaling.clone();this.object.rotationQuaternion=c.IDENTITY_QUATERNION;var S=this.object.computeWorldMatrix&&this.object.computeWorldMatrix(!0);S&&S.decompose(A,void 0,void 0);var g=this.object.getBoundingInfo().boundingBox.extendSize.scale(2).multiplyInPlace(A);return this.object.rotationQuaternion=E,this.object.computeWorldMatrix&&this.object.computeWorldMatrix(!0),g}return c.DEFAULT_OBJECT_SIZE},c.prototype.getObjectCenter=function(){return this.object.getBoundingInfo?this.object.getBoundingInfo().boundingBox.centerWorld:this.object.position},c.prototype.getParam=function(E){return this._options[E]},c.prototype.setParam=function(E,A){this._options[E]=A,this._bodyUpdateRequired=!0},c.prototype.setMass=function(E){this.getParam("mass")!==E&&this.setParam("mass",E),this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyMass(this,E)},c.prototype.getLinearVelocity=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this):x.e.Zero()},c.prototype.setLinearVelocity=function(E){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this,E)},c.prototype.getAngularVelocity=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this):x.e.Zero()},c.prototype.setAngularVelocity=function(E){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this,E)},c.prototype.executeNativeFunction=function(E){this._physicsEngine&&E(this._physicsEngine.getPhysicsPlugin().world,this.physicsBody)},c.prototype.registerBeforePhysicsStep=function(E){this._onBeforePhysicsStepCallbacks.push(E)},c.prototype.unregisterBeforePhysicsStep=function(E){var A=this._onBeforePhysicsStepCallbacks.indexOf(E);A>-1?this._onBeforePhysicsStepCallbacks.splice(A,1):B.a.Warn("Function to remove was not found")},c.prototype.registerAfterPhysicsStep=function(E){this._onAfterPhysicsStepCallbacks.push(E)},c.prototype.unregisterAfterPhysicsStep=function(E){var A=this._onAfterPhysicsStepCallbacks.indexOf(E);A>-1?this._onAfterPhysicsStepCallbacks.splice(A,1):B.a.Warn("Function to remove was not found")},c.prototype.registerOnPhysicsCollide=function(E,A){var S=E instanceof Array?E:[E];this._onPhysicsCollideCallbacks.push({callback:A,otherImpostors:S})},c.prototype.unregisterOnPhysicsCollide=function(E,A){var S=E instanceof Array?E:[E],g=-1;this._onPhysicsCollideCallbacks.some(function(l,h){if(l.callback===A&&l.otherImpostors.length===S.length){var b=l.otherImpostors.every(function(T){return S.indexOf(T)>-1});return b&&(g=h),b}return!1})?this._onPhysicsCollideCallbacks.splice(g,1):B.a.Warn("Function to remove was not found")},c.prototype.getParentsRotation=function(){var E=this.object.parent;for(this._tmpQuat.copyFromFloats(0,0,0,1);E;)E.rotationQuaternion?this._tmpQuat2.copyFrom(E.rotationQuaternion):x.b.RotationYawPitchRollToRef(E.rotation.y,E.rotation.x,E.rotation.z,this._tmpQuat2),this._tmpQuat.multiplyToRef(this._tmpQuat2,this._tmpQuat),E=E.parent;return this._tmpQuat},c.prototype.applyForce=function(E,A){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().applyForce(this,E,A),this},c.prototype.applyImpulse=function(E,A){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().applyImpulse(this,E,A),this},c.prototype.createJoint=function(E,A,S){var g=new R.e(A,S);return this.addJoint(E,g),this},c.prototype.addJoint=function(E,A){return this._joints.push({otherImpostor:E,joint:A}),this._physicsEngine&&this._physicsEngine.addJoint(this,E,A),this},c.prototype.addAnchor=function(E,A,S,g,l){if(!this._physicsEngine)return this;var h=this._physicsEngine.getPhysicsPlugin();return h.appendAnchor?(this._physicsEngine&&h.appendAnchor(this,E,A,S,g,l),this):this},c.prototype.addHook=function(E,A,S,g){if(!this._physicsEngine)return this;var l=this._physicsEngine.getPhysicsPlugin();return l.appendAnchor?(this._physicsEngine&&l.appendHook(this,E,A,S,g),this):this},c.prototype.sleep=function(){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().sleepBody(this),this},c.prototype.wakeUp=function(){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().wakeUpBody(this),this},c.prototype.clone=function(E){return E?new c(E,this.type,this._options,this._scene):null},c.prototype.dispose=function(){var E=this;
826this._physicsEngine&&(this._joints.forEach(function(A){E._physicsEngine&&E._physicsEngine.removeJoint(E,A.otherImpostor,A.joint)}),this._physicsEngine.removeImpostor(this),this.parent&&this.parent.forceUpdate(),this._isDisposed=!0)},c.prototype.setDeltaPosition=function(E){this._deltaPosition.copyFrom(E)},c.prototype.setDeltaRotation=function(E){this._deltaRotation||(this._deltaRotation=new x.b),this._deltaRotation.copyFrom(E),this._deltaRotationConjugated=this._deltaRotation.conjugate()},c.prototype.getBoxSizeToRef=function(E){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this,E),this},c.prototype.getRadius=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getRadius(this):0},c.prototype.syncBoneWithImpostor=function(E,A,S,g,l){var h=c._tmpVecs[0],b=this.object;if(b.rotationQuaternion)if(l){var T=c._tmpQuat;b.rotationQuaternion.multiplyToRef(l,T),E.setRotationQuaternion(T,C.c.WORLD,A)}else E.setRotationQuaternion(b.rotationQuaternion,C.c.WORLD,A);h.x=0,h.y=0,h.z=0,S&&(h.x=S.x,h.y=S.y,h.z=S.z,E.getDirectionToRef(h,A,h),g==null&&(g=S.length()),h.x*=g,h.y*=g,h.z*=g),E.getParent()?(h.addInPlace(b.getAbsolutePosition()),E.setAbsolutePosition(h,A)):(A.setAbsolutePosition(b.getAbsolutePosition()),A.position.x-=h.x,A.position.y-=h.y,A.position.z-=h.z)},c.prototype.syncImpostorWithBone=function(E,A,S,g,l,h){var b=this.object;if(b.rotationQuaternion)if(l){var T=c._tmpQuat;E.getRotationQuaternionToRef(C.c.WORLD,A,T),T.multiplyToRef(l,b.rotationQuaternion)}else E.getRotationQuaternionToRef(C.c.WORLD,A,b.rotationQuaternion);var D=c._tmpVecs[0],w=c._tmpVecs[1];h||((h=c._tmpVecs[2]).x=0,h.y=1,h.z=0),E.getDirectionToRef(h,A,w),E.getAbsolutePositionToRef(A,D),g==null&&S&&(g=S.length()),g!=null&&(D.x+=w.x*g,D.y+=w.y*g,D.z+=w.z*g),b.setAbsolutePosition(D)},c.DEFAULT_OBJECT_SIZE=new x.e(1,1,1),c.IDENTITY_QUATERNION=x.b.Identity(),c._tmpVecs=_.a.BuildArray(3,x.e.Zero),c._tmpQuat=x.b.Identity(),c.NoImpostor=0,c.SphereImpostor=1,c.BoxImpostor=2,c.PlaneImpostor=3,c.MeshImpostor=4,c.CapsuleImpostor=6,c.CylinderImpostor=7,c.ParticleImpostor=8,c.HeightmapImpostor=9,c.ConvexHullImpostor=10,c.CustomImpostor=100,c.RopeImpostor=101,c.ClothImpostor=102,c.SoftbodyImpostor=103,c}()},function(Ae,v,f){f.d(v,"a",function(){return _}),f.d(v,"b",function(){return x});var B=f(1),_=function(){function u(M){this.length=0,this.data=new Array(M),this._id=u._GlobalId++}return u.prototype.push=function(M){this.data[this.length++]=M,this.length>this.data.length&&(this.data.length*=2)},u.prototype.forEach=function(M){for(var R=0;R<this.length;R++)M(this.data[R])},u.prototype.sort=function(M){this.data.sort(M)},u.prototype.reset=function(){this.length=0},u.prototype.dispose=function(){this.reset(),this.data&&(this.data.length=0,this.data=[])},u.prototype.concat=function(M){if(M.length!==0){this.length+M.length>this.data.length&&(this.data.length=2*(this.length+M.length));for(var R=0;R<M.length;R++)this.data[this.length++]=(M.data||M)[R]}},u.prototype.indexOf=function(M){var R=this.data.indexOf(M);return R>=this.length?-1:R},u.prototype.contains=function(M){return this.indexOf(M)!==-1},u._GlobalId=0,u}(),x=function(u){function M(){var R=u!==null&&u.apply(this,arguments)||this;return R._duplicateId=0,R}return Object(B.d)(M,u),M.prototype.push=function(R){u.prototype.push.call(this,R),R.__smartArrayFlags||(R.__smartArrayFlags={}),R.__smartArrayFlags[this._id]=this._duplicateId},M.prototype.pushNoDuplicate=function(R){return(!R.__smartArrayFlags||R.__smartArrayFlags[this._id]!==this._duplicateId)&&(this.push(R),!0)},M.prototype.reset=function(){u.prototype.reset.call(this),this._duplicateId++},M.prototype.concatWithNoDuplicate=function(R){if(R.length!==0){this.length+R.length>this.data.length&&(this.data.length=2*(this.length+R.length));for(var C=0;C<R.length;C++){var m=(R.data||R)[C];this.pushNoDuplicate(m)}}},M}(_)},function(Ae,v,f){f.d(v,"a",function(){return B});var B=function(){function _(){}return _.EndsWith=function(x,u){return x.indexOf(u,x.length-u.length)!==-1},_.StartsWith=function(x,u){return!!x&&x.indexOf(u)===0},_.Decode=function(x){if(typeof TextDecoder<"u")return new TextDecoder().decode(x);for(var u="",M=0;M<x.byteLength;M++)u+=String.fromCharCode(x[M]);return u},_.EncodeArrayBufferToBase64=function(x){for(var u,M,R,C,m,c,E,A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
826+/=",S="",g=0,l=ArrayBuffer.isView(x)?new Uint8Array(x.buffer,x.byteOffset,x.byteLength):new Uint8Array(x);g<l.length;)C=(u=l[g++])>>2,m=(3&u)<<4|(M=g<l.length?l[g++]:Number.NaN)>>4,c=(15&M)<<2|(R=g<l.length?l[g++]:Number.NaN)>>6,E=63&R,isNaN(M)?c=E=64:isNaN(R)&&(E=64),S+=A.charAt(C)+A.charAt(m)+A.charAt(c)+A.charAt(E);return S},_.PadNumber=function(x,u){for(var M=String(x);M.length<u;)M="0"+M;return M},_}()},function(Ae,v,f){f.d(v,"a",function(){return B});var B=function(){function _(){this.rootNodes=new Array,this.cameras=new Array,this.lights=new Array,this.meshes=new Array,this.skeletons=new Array,this.particleSystems=new Array,this.animations=[],this.animationGroups=new Array,this.multiMaterials=new Array,this.materials=new Array,this.morphTargetManagers=new Array,this.geometries=new Array,this.transformNodes=new Array,this.actionManagers=new Array,this.textures=new Array,this._environmentTexture=null,this.postProcesses=new Array}return _.AddParser=function(x,u){this._BabylonFileParsers[x]=u},_.GetParser=function(x){return this._BabylonFileParsers[x]?this._BabylonFileParsers[x]:null},_.AddIndividualParser=function(x,u){this._IndividualBabylonFileParsers[x]=u},_.GetIndividualParser=function(x){return this._IndividualBabylonFileParsers[x]?this._IndividualBabylonFileParsers[x]:null},_.Parse=function(x,u,M,R){for(var C in this._BabylonFileParsers)this._BabylonFileParsers.hasOwnProperty(C)&&this._BabylonFileParsers[C](x,u,M,R)},Object.defineProperty(_.prototype,"environmentTexture",{get:function(){return this._environmentTexture},set:function(x){this._environmentTexture=x},enumerable:!1,configurable:!0}),_.prototype.getNodes=function(){var x=new Array;return x=(x=(x=(x=x.concat(this.meshes)).concat(this.lights)).concat(this.cameras)).concat(this.transformNodes),this.skeletons.forEach(function(u){return x=x.concat(u.bones)}),x},_._BabylonFileParsers={},_._IndividualBabylonFileParsers={},_}()},function(Ae,v,f){f.d(v,"a",function(){return m});var B=f(20),_=f(6),x=f(18),u=f(22),M=f(86),R=f(0),C=f(9),m=function(){function c(E,A){var S=this;A===void 0&&(A=!0),this.originalScene=E,this._pointerCaptures={},this._lastPointerEvents={},this._sharedGizmoLight=null,this._renderCamera=null,this.pickUtilitySceneFirst=!0,this.shouldRender=!0,this.onlyCheckPointerDownEvents=!0,this.processAllEvents=!1,this.onPointerOutObservable=new _.c,this.utilityLayerScene=new B.a(E.getEngine(),{virtual:!0}),this.utilityLayerScene.useRightHandedSystem=E.useRightHandedSystem,this.utilityLayerScene._allowPostProcessClearColor=!1,this.utilityLayerScene.detachControl(),A&&(this._originalPointerObserver=E.onPrePointerObservable.add(function(g,l){if(S.utilityLayerScene.activeCamera&&(S.processAllEvents||g.type===x.a.POINTERMOVE||g.type===x.a.POINTERUP||g.type===x.a.POINTERDOWN||g.type===x.a.POINTERDOUBLETAP)){S.utilityLayerScene.pointerX=E.pointerX,S.utilityLayerScene.pointerY=E.pointerY;var h=g.event;if(E.isPointerCaptured(h.pointerId))S._pointerCaptures[h.pointerId]=!1;else{var b=g.ray?S.utilityLayerScene.pickWithRay(g.ray):S.utilityLayerScene.pick(E.pointerX,E.pointerY);if(!g.ray&&b&&(g.ray=b.ray),S.utilityLayerScene.onPrePointerObservable.notifyObservers(g),S.onlyCheckPointerDownEvents&&g.type!=x.a.POINTERDOWN)return g.ski
826pOnPointerObservable||S.utilityLayerScene.onPointerObservable.notifyObservers(new x.b(g.type,g.event,b),g.type),void(g.type===x.a.POINTERUP&&S._pointerCaptures[h.pointerId]&&(S._pointerCaptures[h.pointerId]=!1));if(S.utilityLayerScene.autoClearDepthAndStencil||S.pickUtilitySceneFirst)b&&b.hit&&(g.skipOnPointerObservable||S.utilityLayerScene.onPointerObservable.notifyObservers(new x.b(g.type,g.event,b),g.type),g.skipOnPointerObservable=!0);else{var T=g.ray?E.pickWithRay(g.ray):E.pick(E.pointerX,E.pointerY),D=g.event;T&&b&&(b.distance===0&&T.pickedMesh?S.mainSceneTrackerPredicate&&S.mainSceneTrackerPredicate(T.pickedMesh)?(S._notifyObservers(g,T,D),g.skipOnPointerObservable=!0):g.type===x.a.POINTERDOWN?S._pointerCaptures[D.pointerId]=!0:S._lastPointerEvents[D.pointerId]&&(S.onPointerOutObservable.notifyObservers(D.pointerId),delete S._lastPointerEvents[D.pointerId]):!S._pointerCaptures[D.pointerId]&&(b.distance<T.distance||T.distance===0)?(S._notifyObservers(g,b,D),g.skipOnPointerObservable||(g.skipOnPointerObservable=b.distance>0)):!S._pointerCaptures[D.pointerId]&&b.distance>T.distance&&(S.mainSceneTrackerPredicate&&S.mainSceneTrackerPredicate(T.pickedMesh)?(S._notifyObservers(g,T,D),g.skipOnPointerObservable=!0):S._lastPointerEvents[D.pointerId]&&(S.onPointerOutObservable.notifyObservers(D.pointerId),delete S._lastPointerEvents[D.pointerId])),g.type===x.a.POINTERUP&&S._pointerCaptures[D.pointerId]&&(S._pointerCaptures[D.pointerId]=!1))}}}}),this._originalPointerObserver&&E.onPrePointerObservable.makeObserverTopPriority(this._originalPointerObserver)),this.utilityLayerScene.autoClear=!1,this._afterRenderObserver=this.originalScene.onAfterCameraRenderObservable.add(function(g){S.shouldRender&&g==S.getRenderCamera()&&S.render()}),this._sceneDisposeObserver=this.originalScene.onDisposeObservable.add(function(){S.dispose()}),this._updateCamera()}return c.prototype.getRenderCamera=function(E){if(this._renderCamera)return this._renderCamera;var A=void 0;return A=this.originalScene.activeCameras&&this.originalScene.activeCameras.length>1?this.originalScene.activeCameras[this.originalScene.activeCameras.length-1]:this.originalScene.activeCamera,E&&A&&A.isRigCamera?A.rigParent:A},c.prototype.setRenderCamera=function(E){this._renderCamera=E},c.prototype._getSharedGizmoLight=function(){return this._sharedGizmoLight||(this._sharedGizmoLight=new M.a("shared gizmo light",new R.e(0,1,0),this.utilityLayerScene),this._sharedGizmoLight.intensity=2,this._sharedGizmoLight.groundColor=C.a.Gray()),this._sharedGizmoLight},Object.defineProperty(c,"DefaultUtilityLayer",{get:function(){return c._DefaultUtilityLayer==null&&(c._DefaultUtilityLayer=new c(u.a.LastCreatedScene),c._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce(function(){c._DefaultUtilityLayer=null})),c._DefaultUtilityLayer},enumerable:!1,configurable:!0}),Object.defineProperty(c,"DefaultKeepDepthUtilityLayer",{get:function(){return c._DefaultKeepDepthUtilityLayer==null&&(c._DefaultKeepDepthUtilityLayer=new c(u.a.LastCreatedScene),c._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil=!1,c._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce(function(){c._DefaultKeepDepthUtilityLayer=null})),c._DefaultKeepDepthUtilityLayer},enumerable:!1,configurable:!0}),c.prototype._notifyObservers=function(E,A,S){E.skipOnPointerObservable||(this.utilityLayerScene.onPointerObservable.notifyObservers(new x.b(E.type,E.event,A),E.type),this._lastPointerEvents[S.pointerId]=!0)},c.prototype.render=function(){if(this._updateCamera(),this.utilityLayerScene.activeCamera){var E=this.utilityLayerScene.activeCamera.getScene(),A=this.utilityLayerScene.activeCamera;A._scene=this.utilityLayerScene,A.leftCamera&&(A.leftCamera._scene=this.utilityLayerScene),A.rightCamera&&(A.rightCamera._scene=this.utilityLayerScene),this.utilityLayerScene.render(!1),A._scene=E,A.leftCamera&&(A.leftCamera._scene=E),A.rightCamera&&(A.rightCamera._scene=E)}},c.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()},c.prototype._updateCamera=function(){this.utilityLayerScene.cameraToUseForPointers=this.getRenderCamera(),this.utilityLayerScene.activeCamera=this.getRenderCamera()},c._DefaultUtilityLayer=null,c._DefaultKeepDepthUtilityLayer=null,c}()},function(Ae,v,f){f.d(v,"a",function(){return _});var B=f(139),_=function(){function x(){}return x.EnableFor=function(u){u._tags=u._tags||{},u.hasTags=function(){return x.HasTags(u)},u.addTags=function(M){return x.AddTagsTo(u,M)},u.removeTags=function(M){return x.RemoveTagsFrom(u,M)},u.matchesTagsQuery=function(M){return x.MatchesQuery(u,M)}},x.DisableFor=function(u){delete u._tags,delete u.hasTags,delete u.addTags,delete u.removeTags,delete u.matchesTagsQuery},x.HasTags=function(u){if(!u._tags)return!1;var M=u._tags;for(var R in M)if(M.hasOwnProperty(R))return!0;return!1},x.GetTags=function(u,M){if(M===void 0&&(M=!0),!u._tags)return null;if(M){var R=[];for(var C in u._tags)u._tags.hasOwnProperty(C)&&u._tags[C]===!0&&R.push(C);return R.join(" ")}return u._tags}
826,x.AddTagsTo=function(u,M){M&&typeof M=="string"&&M.split(" ").forEach(function(R,C,m){x._AddTagTo(u,R)})},x._AddTagTo=function(u,M){(M=M.trim())!==""&&M!=="true"&&M!=="false"&&(M.match(/[\s]/)||M.match(/^([!]|([|]|[&]){2})/)||(x.EnableFor(u),u._tags[M]=!0))},x.RemoveTagsFrom=function(u,M){if(x.HasTags(u)){var R=M.split(" ");for(var C in R)x._RemoveTagFrom(u,R[C])}},x._RemoveTagFrom=function(u,M){delete u._tags[M]},x.MatchesQuery=function(u,M){return M===void 0||(M===""?x.HasTags(u):B.a.Eval(M,function(R){return x.HasTags(u)&&u._tags[R]}))},x}()},function(Ae,v,f){f.d(v,"a",function(){return B});var B=function(){function _(){}return _.IsWindowObjectExist=function(){return typeof window<"u"},_.IsNavigatorAvailable=function(){return typeof navigator<"u"},_.IsDocumentAvailable=function(){return typeof document<"u"},_.GetDOMTextContent=function(x){for(var u="",M=x.firstChild;M;)M.nodeType===3&&(u+=M.textContent),M=M.nextSibling;return u},_}()},function(Ae,v,f){f.d(v,"a",function(){return C});var B=f(44),_=f(0),x=f(54),u=f(114),M=f(20),R=f(24),C=function(){function m(c,E,A){A===void 0&&(A=Number.MAX_VALUE),this.origin=c,this.direction=E,this.length=A}return m.prototype.intersectsBoxMinMax=function(c,E,A){A===void 0&&(A=0);var S,g,l,h,b=m._TmpVector3[0].copyFromFloats(c.x-A,c.y-A,c.z-A),T=m._TmpVector3[1].copyFromFloats(E.x+A,E.y+A,E.z+A),D=0,w=Number.MAX_VALUE;if(Math.abs(this.direction.x)<1e-7){if(this.origin.x<b.x||this.origin.x>T.x)return!1}else if(S=1/this.direction.x,g=(b.x-this.origin.x)*S,(l=(T.x-this.origin.x)*S)===-1/0&&(l=1/0),g>l&&(h=g,g=l,l=h),(D=Math.max(g,D))>(w=Math.min(l,w)))return!1;if(Math.abs(this.direction.y)<1e-7){if(this.origin.y<b.y||this.origin.y>T.y)return!1}else if(S=1/this.direction.y,g=(b.y-this.origin.y)*S,(l=(T.y-this.origin.y)*S)===-1/0&&(l=1/0),g>l&&(h=g,g=l,l=h),(D=Math.max(g,D))>(w=Math.min(l,w)))return!1;if(Math.abs(this.direction.z)<1e-7){if(this.origin.z<b.z||this.origin.z>T.z)return!1}else if(S=1/this.direction.z,g=(b.z-this.origin.z)*S,(l=(T.z-this.origin.z)*S)===-1/0&&(l=1/0),g>l&&(h=g,g=l,l=h),(D=Math.max(g,D))>(w=Math.min(l,w)))return!1;return!0},m.prototype.intersectsBox=function(c,E){return E===void 0&&(E=0),this.intersectsBoxMinMax(c.minimum,c.maximum,E)},m.prototype.intersectsSphere=function(c,E){E===void 0&&(E=0);var A=c.center.x-this.origin.x,S=c.center.y-this.origin.y,g=c.center.z-this.origin.z,l=A*A+S*S+g*g,h=c.radius+E,b=h*h;if(l<=b)return!0;var T=A*this.direction.x+S*this.direction.y+g*this.direction.z;return!(T<0)&&l-T*T<=b},m.prototype.intersectsTriangle=function(c,E,A){var S=m._TmpVector3[0],g=m._TmpVector3[1],l=m._TmpVector3[2],h=m._TmpVector3[3],b=m._TmpVector3[4];E.subtractToRef(c,S),A.subtractToRef(c,g),_.e.CrossToRef(this.direction,g,l);var T=_.e.Dot(S,l);if(T===0)return null;var D=1/T;this.origin.subtractToRef(c,h);var w=_.e.Dot(h,l)*D;if(w<0||w>1)return null;_.e.CrossToRef(h,S,b);var N=_.e.Dot(this.direction,b)*D;if(N<0||w+N>1)return null;var I=_.e.Dot(g,b)*D;return I>this.length?null:new u.a(1-w-N,w,I)},m.prototype.intersectsPlane=function(c){var E,A=_.e.Dot(c.normal,this.direction);if(Math.abs(A)<999999997475243e-21)return null;var S=_.e.Dot(c.normal,this.origin);return(E=(-c.d-S)/A)<0?E<-999999997475243e-21?null:0:E},m.prototype.intersectsAxis=function(c,E){switch(E===void 0&&(E=0),c){case"y":return(A=(this.origin.y-E)/this.direction.y)>0?null:new _.e(this.origin.x+this.direction.x*-A,E,this.origin.z+this.direction.z*-A);case"x":return(A=(this.origin.x-E)/this.direction.x)>0?null:new _.e(E,this.origin.y+this.direction.y*-A,this.origin.z+this.direction.z*-A);case"z":var A;return(A=(this.origin.z-E)/this.direction.z)>0?null:new _.e(this.origin.x+this.direction.x*-A,this.origin.y+this.direction.y*-A,E);default:return null}},m.prototype.intersectsMesh=function(c,E){var A=_.c.Matrix[0];return c.getWorldMatrix().invertToRef(A),this._tmpRay?m.TransformToRef(this,A,this._tmpRay):this._tmpRay=m.Transform(this,A),c.intersects(this._tmpRay,E)},m.prototype.intersectsMeshes=function(c,E,A){A?A.length=0:A=[];for(var S=0;S<c.length;S++){var g=this.intersectsMesh(c[S],E);g.hit&&A.push(g)}
826return A.sort(this._comparePickingInfo),A},m.prototype._comparePickingInfo=function(c,E){return c.distance<E.distance?-1:c.distance>E.distance?1:0},m.prototype.intersectionSegment=function(c,E,A){var S=this.origin,g=_.c.Vector3[0],l=_.c.Vector3[1],h=_.c.Vector3[2],b=_.c.Vector3[3];E.subtractToRef(c,g),this.direction.scaleToRef(m.rayl,h),S.addToRef(h,l),c.subtractToRef(S,b);var T,D,w,N,I=_.e.Dot(g,g),V=_.e.Dot(g,h),W=_.e.Dot(h,h),j=_.e.Dot(g,b),ne=_.e.Dot(h,b),te=I*W-V*V,de=te,pe=te;te<m.smallnum?(D=0,de=1,N=ne,pe=W):(N=I*ne-V*j,(D=V*ne-W*j)<0?(D=0,N=ne,pe=W):D>de&&(D=de,N=ne+V,pe=W)),N<0?(N=0,-j<0?D=0:-j>I?D=de:(D=-j,de=I)):N>pe&&(N=pe,-j+V<0?D=0:-j+V>I?D=de:(D=-j+V,de=I)),T=Math.abs(D)<m.smallnum?0:D/de,w=Math.abs(N)<m.smallnum?0:N/pe;var ae=_.c.Vector3[4];h.scaleToRef(w,ae);var ee=_.c.Vector3[5];g.scaleToRef(T,ee),ee.addInPlace(b);var K=_.c.Vector3[6];return ee.subtractToRef(ae,K),w>0&&w<=this.length&&K.lengthSquared()<A*A?ee.length():-1},m.prototype.update=function(c,E,A,S,g,l,h){return this.unprojectRayToRef(c,E,A,S,g,l,h),this},m.Zero=function(){return new m(_.e.Zero(),_.e.Zero())},m.CreateNew=function(c,E,A,S,g,l,h){return m.Zero().update(c,E,A,S,g,l,h)},m.CreateNewFromTo=function(c,E,A){A===void 0&&(A=_.a.IdentityReadOnly);var S=E.subtract(c),g=Math.sqrt(S.x*S.x+S.y*S.y+S.z*S.z);return S.normalize(),m.Transform(new m(c,S,g),A)},m.Transform=function(c,E){var A=new m(new _.e(0,0,0),new _.e(0,0,0));return m.TransformToRef(c,E,A),A},m.TransformToRef=function(c,E,A){_.e.TransformCoordinatesToRef(c.origin,E,A.origin),_.e.TransformNormalToRef(c.direction,E,A.direction),A.length=c.length;var S=A.direction,g=S.length();if(g!==0&&g!==1){var l=1/g;S.x*=l,S.y*=l,S.z*=l,A.length*=g}},m.prototype.unprojectRayToRef=function(c,E,A,S,g,l,h){var b=_.c.Matrix[0];g.multiplyToRef(l,b),b.multiplyToRef(h,b),b.invert();var T=_.c.Vector3[0];T.x=c/A*2-1,T.y=-(E/S*2-1),T.z=-1;var D=_.c.Vector3[1].copyFromFloats(T.x,T.y,1),w=_.c.Vector3[2],N=_.c.Vector3[3];_.e._UnprojectFromInvertedMatrixToRef(T,b,w),_.e._UnprojectFromInvertedMatrixToRef(D,b,N),this.origin.copyFrom(w),N.subtractToRef(w,this.direction),this.direction.normalize()},m._TmpVector3=B.a.BuildArray(6,_.e.Zero),m.smallnum=1e-8,m.rayl=1e9,m}();M.a.prototype.createPickingRay=function(m,c,E,A,S){S===void 0&&(S=!1);var g=C.Zero();return this.createPickingRayToRef(m,c,E,g,A,S),g},M.a.prototype.createPickingRayToRef=function(m,c,E,A,S,g){g===void 0&&(g=!1);var l=this.getEngine();if(!S){if(!this.activeCamera)return this;S=this.activeCamera}var h=S.viewport.toGlobal(l.getRenderWidth(),l.getRenderHeight());return m=m/l.getHardwareScalingLevel()-h.x,c=c/l.getHardwareScalingLevel()-(l.getRenderHeight()-h.y-h.height),A.update(m,c,h.width,h.height,E||_.a.IdentityReadOnly,g?_.a.IdentityReadOnly:S.getViewMatrix(),S.getProjectionMatrix()),this},M.a.prototype.createPickingRayInCameraSpace=function(m,c,E){var A=C.Zero();return this.createPickingRayInCameraSpaceToRef(m,c,A,E),A},M.a.prototype.createPickingRayInCameraSpaceToRef=function(m,c,E,A){if(!x.a)return this;var S=this.getEngine();if(!A){if(!this.activeCamera)throw new Error("Active camera not set");A=this.activeCamera}var g=A.viewport.toGlobal(S.getRenderWidth(),S.getRenderHeight()),l=_.a.Identity();return m=m/S.getHardwareScalingLevel()-g.x,c=c/S.getHardwareScalingLevel()-(S.getRenderHeight()-g.y-g.height),E.update(m,c,g.width,g.height,l,l,A.getProjectionMatrix()),this},M.a.prototype._internalPickForMesh=function(m,c,E,A,S,g,l,h){var b=c(A),T=E.intersects(b,S,l,g,A,h);return T&&T.hit?!S&&m!=null&&T.distance>=m.distance?null:T:null},M.a.prototype._internalPick=function(m,c,E,A,S){if(!x.a)return null;for(var g=null,l=0;l<this.meshes.length;l++){var h=this.meshes[l];if(c){if(!c(h))continue}else if(!h.isEnabled()||!h.isVisible||!h.isPickable)continue;var b,T=h.skeleton&&h.skeleton.overrideMesh?h.skeleton.overrideMesh.getWorldMatrix():h.getWorldMatrix();if(h.hasThinInstances&&h.thinInstanceEnablePicking){if(b=this._internalPickForMesh(g,m,h,T,!0,!0,S)){if(A)return g;for(var D=_.c.Matrix[1],w=h.thinInstanceGetWorldMatrices(),N=0;N<w.length;N++){w[N].multiplyToRef(T,D);var I=this._internalPickForMesh(g,m,h,D,E,A,S,!0);if(I&&((g=I).thinInstanceIndex=N,E))return g}}}
826else if((b=this._internalPickForMesh(g,m,h,T,E,A,S))&&(g=b,E))return g}return g||new x.a},M.a.prototype._internalMultiPick=function(m,c,E){if(!x.a)return null;for(var A=new Array,S=0;S<this.meshes.length;S++){var g=this.meshes[S];if(c){if(!c(g))continue}else if(!g.isEnabled()||!g.isVisible||!g.isPickable)continue;var l,h=g.skeleton&&g.skeleton.overrideMesh?g.skeleton.overrideMesh.getWorldMatrix():g.getWorldMatrix();if(g.hasThinInstances&&g.thinInstanceEnablePicking){if(l=this._internalPickForMesh(null,m,g,h,!0,!0,E))for(var b=_.c.Matrix[1],T=g.thinInstanceGetWorldMatrices(),D=0;D<T.length;D++){T[D].multiplyToRef(h,b);var w=this._internalPickForMesh(null,m,g,b,!1,!1,E,!0);w&&(w.thinInstanceIndex=D,A.push(w))}}else(l=this._internalPickForMesh(null,m,g,h,!1,!1,E))&&A.push(l)}return A},M.a.prototype.pickWithBoundingInfo=function(m,c,E,A,S){var g=this;if(!x.a)return null;var l=this._internalPick(function(h){return g._tempPickingRay||(g._tempPickingRay=C.Zero()),g.createPickingRayToRef(m,c,h,g._tempPickingRay,S||null),g._tempPickingRay},E,A,!0);return l&&(l.ray=this.createPickingRay(m,c,_.a.Identity(),S||null)),l},M.a.prototype.pick=function(m,c,E,A,S,g){var l=this;if(!x.a)return null;var h=this._internalPick(function(b){return l._tempPickingRay||(l._tempPickingRay=C.Zero()),l.createPickingRayToRef(m,c,b,l._tempPickingRay,S||null),l._tempPickingRay},E,A,!1,g);return h&&(h.ray=this.createPickingRay(m,c,_.a.Identity(),S||null)),h},M.a.prototype.pickWithRay=function(m,c,E,A){var S=this,g=this._internalPick(function(l){return S._pickWithRayInverseMatrix||(S._pickWithRayInverseMatrix=_.a.Identity()),l.invertToRef(S._pickWithRayInverseMatrix),S._cachedRayForTransform||(S._cachedRayForTransform=C.Zero()),C.TransformToRef(m,S._pickWithRayInverseMatrix,S._cachedRayForTransform),S._cachedRayForTransform},c,E,!1,A);return g&&(g.ray=m),g},M.a.prototype.multiPick=function(m,c,E,A,S){var g=this;return this._internalMultiPick(function(l){return g.createPickingRay(m,c,l,A||null)},E,S)},M.a.prototype.multiPickWithRay=function(m,c,E){var A=this;return this._internalMultiPick(function(S){return A._pickWithRayInverseMatrix||(A._pickWithRayInverseMatrix=_.a.Identity()),S.invertToRef(A._pickWithRayInverseMatrix),A._cachedRayForTransform||(A._cachedRayForTransform=C.Zero()),C.TransformToRef(m,A._pickWithRayInverseMatrix,A._cachedRayForTransform),A._cachedRayForTransform},c,E)},R.a.prototype.getForwardRay=function(m,c,E){return m===void 0&&(m=100),this.getForwardRayToRef(new C(_.e.Zero(),_.e.Zero(),m),m,c,E)},R.a.prototype.getForwardRayToRef=function(m,c,E,A){return c===void 0&&(c=100),E||(E=this.getWorldMatrix()),m.length=c,A?m.origin.copyFrom(A):m.origin.copyFrom(this.position),_.c.Vector3[2].set(0,0,this._scene.useRightHandedSystem?-1:1),_.e.TransformNormalToRef(_.c.Vector3[2],E,_.c.Vector3[3]),_.e.NormalizeToRef(_.c.Vector3[3],m.direction),m}},function(Ae,v,f){f.d(v,"a",function(){return R});var B=f(0),_=f(7),x=f(16),u=f(98),M=f(4);x.a.CreateLineSystem=function(C){for(var m=[],c=[],E=C.lines,A=C.colors,S=[],g=0,l=0;l<E.length;l++)for(var h=E[l],b=0;b<h.length;b++){if(c.push(h[b].x,h[b].y,h[b].z),A){var T=A[l];S.push(T[b].r,T[b].g,T[b].b,T[b].a)}b>0&&(m.push(g-1),m.push(g)),g++}var D=new x.a;return D.indices=m,D.positions=c,A&&(D.colors=S),D},x.a.CreateDashedLines=function(C){var m,c,E=C.dashSize||3,A=C.gapSize||1,S=C.dashNb||200,g=C.points,l=new Array,h=new Array,b=B.e.Zero(),T=0,D=0,w=0,N=0,I=0;for(I=0;I<g.length-1;I++)g[I+1].subtractToRef(g[I],b),T+=b.length();for(c=E*(m=T/S)/(E+A),I=0;I<g.length-1;I++){g[I+1].subtractToRef(g[I],b),D=Math.floor(b.length()/m),b.normalize();for(var V=0;V<D;V++)w=m*V,l.push(g[I].x+w*b.x,g[I].y+w*b.y,g[I].z+w*b.z),l.push(g[I].x+(w+c)*b.x,g[I].y+(w+c)*b.y,g[I].z+(w+c)*b.z),h.push(N,N+1),N+=2}var W=new x.a;return W.positions=l,W.indices=h,W},_.a.CreateLines=function(C,m,c,E,A){c===void 0&&(c=null),E===void 0&&(E=!1),A===void 0&&(A=null);var S={points:m,updatable:E,instance:A};return R.CreateLines(C,S,c)},_.a.CreateDashedLines=function(C,m,c,E,A,S,g,l){S===void 0&&(S=null);var h={points:m,dashSize:c,gapSize:E,dashNb:A,updatable:g,instance:l};return R.CreateDashedLines(C,h,S)};var R=function(){function C(){}return C.CreateLineSystem=function(m,c,E){var A=c.instance,S=c.lines,g=c.colors;if(A){var l,h,b=A.getVerticesData(M.b.PositionKind);g&&(l=A.getVerticesData(M.b.ColorKind));for(var T=0,D=0,w=0;w<S.length;w++)for(var N=S[w],I=0;I<N.length;I++)b[T]=N[I].x,b[T+1]=N[I].y,b[T+2]=N[I].z,g&&l&&(h=g[w],l[D]=h[I].r,l[D+1]=h[I].g,l[D+2]=h[I].b,l[D+3]=h[I].a,D+=4),T+=3;return A.updateVerticesData(M.b.PositionKind,b,!1,!1),g&&l&&A.updateVerticesData(M.b.ColorKind,l,!1,!1),A}var V=!!g,W=new u.b(m,E,null,void 0,void 0,V,c.useVertexAlpha);return x.a.CreateLineSystem(c).applyToMesh(W,c.updatable),W},C.CreateLines=function(m,c,E){E===void 0&&(E=null);
826var A=c.colors?[c.colors]:null;return C.CreateLineSystem(m,{lines:[c.points],updatable:c.updatable,instance:c.instance,colors:A,useVertexAlpha:c.useVertexAlpha},E)},C.CreateDashedLines=function(m,c,E){E===void 0&&(E=null);var A=c.points,S=c.instance,g=c.gapSize||1,l=c.dashSize||3;if(S)return S.updateMeshPositions(function(b){var T,D,w=B.e.Zero(),N=b.length/6,I=0,V=0,W=0,j=0,ne=0,te=0;for(ne=0;ne<A.length-1;ne++)A[ne+1].subtractToRef(A[ne],w),I+=w.length();T=I/N;var de=S._creationDataStorage.dashSize;for(D=de*T/(de+S._creationDataStorage.gapSize),ne=0;ne<A.length-1;ne++)for(A[ne+1].subtractToRef(A[ne],w),V=Math.floor(w.length()/T),w.normalize(),te=0;te<V&&j<b.length;)W=T*te,b[j]=A[ne].x+W*w.x,b[j+1]=A[ne].y+W*w.y,b[j+2]=A[ne].z+W*w.z,b[j+3]=A[ne].x+(W+D)*w.x,b[j+4]=A[ne].y+(W+D)*w.y,b[j+5]=A[ne].z+(W+D)*w.z,j+=6,te++;for(;j<b.length;)b[j]=A[ne].x,b[j+1]=A[ne].y,b[j+2]=A[ne].z,j+=3},!1),S;var h=new u.b(m,E,null,void 0,void 0,void 0,c.useVertexAlpha);return x.a.CreateDashedLines(c).applyToMesh(h,c.updatable),h._creationDataStorage=new _.b,h._creationDataStorage.dashSize=l,h._creationDataStorage.gapSize=g,h},C}()},function(Ae,v,f){f.d(v,"a",function(){return u});var B=f(34),_=f(8),x=function(M,R){return M?M.getClassName&&M.getClassName()==="Mesh"?null:M.getClassName&&M.getClassName()==="SubMesh"?M.clone(R):M.clone?M.clone():null:null},u=function(){function M(){}return M.DeepCopy=function(R,C,m,c){for(var E=0,A=function(T){var D=[];do Object.getOwnPropertyNames(T).forEach(function(w){D.indexOf(w)===-1&&D.push(w)});while(T=Object.getPrototypeOf(T));return D}(R);E<A.length;E++){var S=A[E];if((S[0]!=="_"||c&&c.indexOf(S)!==-1)&&!(B.a.EndsWith(S,"Observable")||m&&m.indexOf(S)!==-1)){var g=R[S],l=typeof g;if(l!=="function")try{if(l==="object")if(g instanceof Array){if(C[S]=[],g.length>0)if(typeof g[0]=="object")for(var h=0;h<g.length;h++){var b=x(g[h],C);C[S].indexOf(b)===-1&&C[S].push(b)}else C[S]=g.slice(0)}else C[S]=x(g,C);else C[S]=g}catch(T){_.a.Warn(T.message)}}}},M}()},function(Ae,v,f){f.d(v,"b",function(){return m}),f.d(v,"a",function(){return c});var B=f(1),_=f(3),x=f(6),u=f(12),M=f(9),R=f(76),C=f(121),m=function(E){function A(){var S=E.call(this)||this;return S.IMAGEPROCESSING=!1,S.VIGNETTE=!1,S.VIGNETTEBLENDMODEMULTIPLY=!1,S.VIGNETTEBLENDMODEOPAQUE=!1,S.TONEMAPPING=!1,S.TONEMAPPING_ACES=!1,S.CONTRAST=!1,S.COLORCURVES=!1,S.COLORGRADING=!1,S.COLORGRADING3D=!1,S.SAMPLER3DGREENDEPTH=!1,S.SAMPLER3DBGRMAP=!1,S.IMAGEPROCESSINGPOSTPROCESS=!1,S.EXPOSURE=!1,S.rebuild(),S}return Object(B.d)(A,E),A}(R.a),c=function(){function E(){this.colorCurves=new C.a,this._colorCurvesEnabled=!1,this._colorGradingEnabled=!1,this._colorGradingWithGreenDepth=!0,this._colorGradingBGR=!0,this._exposure=1,this._toneMappingEnabled=!1,this._toneMappingType=E.TONEMAPPING_STANDARD,this._contrast=1,this.vignetteStretch=0,this.vignetteCentreX=0,this.vignetteCentreY=0,this.vignetteWeight=1.5,this.vignetteColor=new M.b(0,0,0,0),this.vignetteCameraFov=.5,this._vignetteBlendMode=E.VIGNETTEMODE_MULTIPLY,this._vignetteEnabled=!1,this._applyByPostProcess=!1,this._isEnabled=!0,this.onUpdateParameters=new x.c}return Object.defineProperty(E.prototype,"colorCurvesEnabled",{get:function(){return this._colorCurvesEnabled},set:function(A){this._colorCurvesEnabled!==A&&(this._colorCurvesEnabled=A,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"colorGradingTexture",{get:function(){return this._colorGradingTexture},set:function(A){this._colorGradingTexture!==A&&(this._colorGradingTexture=A,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"colorGradingEnabled",{get:function(){return this._colorGradingEnabled},set:function(A){this._colorGradingEnabled!==A&&(this._colorGradingEnabled=A,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"colorGradingWithGreenDepth",{get:function(){return this._colorGradingWithGreenDepth},set:function(A){this._colorGradingWithGreenDepth!==A&&(this._colorGradingWithGreenDepth=A,this._updateParameters())}
826,enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"colorGradingBGR",{get:function(){return this._colorGradingBGR},set:function(A){this._colorGradingBGR!==A&&(this._colorGradingBGR=A,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"exposure",{get:function(){return this._exposure},set:function(A){this._exposure!==A&&(this._exposure=A,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"toneMappingEnabled",{get:function(){return this._toneMappingEnabled},set:function(A){this._toneMappingEnabled!==A&&(this._toneMappingEnabled=A,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"toneMappingType",{get:function(){return this._toneMappingType},set:function(A){this._toneMappingType!==A&&(this._toneMappingType=A,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"contrast",{get:function(){return this._contrast},set:function(A){this._contrast!==A&&(this._contrast=A,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"vignetteBlendMode",{get:function(){return this._vignetteBlendMode},set:function(A){this._vignetteBlendMode!==A&&(this._vignetteBlendMode=A,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"vignetteEnabled",{get:function(){return this._vignetteEnabled},set:function(A){this._vignetteEnabled!==A&&(this._vignetteEnabled=A,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"applyByPostProcess",{get:function(){return this._applyByPostProcess},set:function(A){this._applyByPostProcess!==A&&(this._applyByPostProcess=A,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(A){this._isEnabled!==A&&(this._isEnabled=A,this._updateParameters())},enumerable:!1,configurable:!0}),E.prototype._updateParameters=function(){this.onUpdateParameters.notifyObservers(this)},E.prototype.getClassName=function(){return"ImageProcessingConfiguration"},E.PrepareUniforms=function(A,S){S.EXPOSURE&&A.push("exposureLinear"),S.CONTRAST&&A.push("contrast"),S.COLORGRADING&&A.push("colorTransformSettings"),S.VIGNETTE&&(A.push("vInverseScreenSize"),A.push("vignetteSettings1"),A.push("vignetteSettings2")),S.COLORCURVES&&C.a.PrepareUniforms(A)},E.PrepareSamplers=function(A,S){S.COLORGRADING&&A.push("txColorTransform")},E.prototype.prepareDefines=function(A,S){if(S===void 0&&(S=!1),S!==this.applyByPostProcess||!this._isEnabled)return A.VIGNETTE=!1,A.TONEMAPPING=!1,A.TONEMAPPING_ACES=!1,A.CONTRAST=!1,A.EXPOSURE=!1,A.COLORCURVES=!1,A.COLORGRADING=!1,A.COLORGRADING3D=!1,A.IMAGEPROCESSING=!1,void(A.IMAGEPROCESSINGPOSTPROCESS=this.applyByPostProcess&&this._isEnabled);switch(A.VIGNETTE=this.vignetteEnabled,A.VIGNETTEBLENDMODEMULTIPLY=this.vignetteBlendMode===E._VIGNETTEMODE_MULTIPLY,A.VIGNETTEBLENDMODEOPAQUE=!A.VIGNETTEBLENDMODEMULTIPLY,A.TONEMAPPING=this.toneMappingEnabled,this._toneMappingType){case E.TONEMAPPING_ACES:A.TONEMAPPING_ACES=!0;break;default:A.TONEMAPPING_ACES=!1}A.CONTRAST=this.contrast!==1,A.EXPOSURE=this.exposure!==1,A.COLORCURVES=this.colorCurvesEnabled&&!!this.colorCurves,A.COLORGRADING=this.colorGradingEnabled&&!!this.colorGradingTexture,A.COLORGRADING?A.COLORGRADING3D=this.colorGradingTexture.is3D:A.COLORGRADING3D=!1,A.SAMPLER3DGREENDEPTH=this.colorGradingWithGreenDepth,A.SAMPLER3DBGRMAP=this.colorGradingBGR,A.IMAGEPROCESSINGPOSTPROCESS=this.applyByPostProcess,A.IMAGEPROCESSING=A.VIGNETTE||A.TONEMAPPING||A.CONTRAST||A.EXPOSURE||A.COLORCURVES||A.COLORGRADING},E.prototype.isReady=function(){return!this.colorGradingEnabled||!this.colorGradingTexture||this.colorGradingTexture.isReady()},E.prototype.bind=function(A,S){if(this._colorCurvesEnabled&&this.colorCurves&&C.a.Bind(this.colorCurves,A),this._vignetteEnabled){var g=1/A.getEngine().getRenderWidth(),l=1/A.getEngine().getRenderHeight();A.setFloat2("vInverseScreenSize",g,l);var h=S??l/g,b=Math.tan(.5*this.vignetteCameraFov),T=b*h,D=Math.sqrt(T*b);T=u.b.Mix(T,D,this.vignetteStretch),b=u.b.Mix(b,D,this.vignetteStretch),A.setFloat4("vignetteSettings1",T,b,-T*this.vignetteCentreX,-b*this.vignetteCentreY);var w=-2*this.vignetteWeight;A.setFloat4("vignetteSettings2",this.vignetteColor.r,this.vignetteColor.g,this.vignetteColor.b,w)}if(A.setFloat("exposureLinear",this.exposure),A.setFloat("contrast",this.contrast),this.colorGradingTexture){A.setTexture("txColorTransform",this.colorGradingTexture);var N=this.colorGradingTexture.getSize().height;A.setFloat4("colorTransformSettings",(N-1)/N,.5/N,N,this.colorGradingTexture.level)}},E.prototype.clone=function(){return _.a.Clone(function(){return new E},this)},E.prototype.serialize=function(){return _.a.Serialize(this)},E.Parse=function(A){return _.a.Parse(function(){return new E},A,null,null)},Object.defineProperty(E,"VIGNETTEMODE_MULTIPLY",{get:function(){return this._VIGNETTEMODE_MULTIPLY}
826,enumerable:!1,configurable:!0}),Object.defineProperty(E,"VIGNETTEMODE_OPAQUE",{get:function(){return this._VIGNETTEMODE_OPAQUE},enumerable:!1,configurable:!0}),E.TONEMAPPING_STANDARD=0,E.TONEMAPPING_ACES=1,E._VIGNETTEMODE_MULTIPLY=0,E._VIGNETTEMODE_OPAQUE=1,Object(B.c)([Object(_.g)()],E.prototype,"colorCurves",void 0),Object(B.c)([Object(_.c)()],E.prototype,"_colorCurvesEnabled",void 0),Object(B.c)([Object(_.m)("colorGradingTexture")],E.prototype,"_colorGradingTexture",void 0),Object(B.c)([Object(_.c)()],E.prototype,"_colorGradingEnabled",void 0),Object(B.c)([Object(_.c)()],E.prototype,"_colorGradingWithGreenDepth",void 0),Object(B.c)([Object(_.c)()],E.prototype,"_colorGradingBGR",void 0),Object(B.c)([Object(_.c)()],E.prototype,"_exposure",void 0),Object(B.c)([Object(_.c)()],E.prototype,"_toneMappingEnabled",void 0),Object(B.c)([Object(_.c)()],E.prototype,"_toneMappingType",void 0),Object(B.c)([Object(_.c)()],E.prototype,"_contrast",void 0),Object(B.c)([Object(_.c)()],E.prototype,"vignetteStretch",void 0),Object(B.c)([Object(_.c)()],E.prototype,"vignetteCentreX",void 0),Object(B.c)([Object(_.c)()],E.prototype,"vignetteCentreY",void 0),Object(B.c)([Object(_.c)()],E.prototype,"vignetteWeight",void 0),Object(B.c)([Object(_.f)()],E.prototype,"vignetteColor",void 0),Object(B.c)([Object(_.c)()],E.prototype,"vignetteCameraFov",void 0),Object(B.c)([Object(_.c)()],E.prototype,"_vignetteBlendMode",void 0),Object(B.c)([Object(_.c)()],E.prototype,"_vignetteEnabled",void 0),Object(B.c)([Object(_.c)()],E.prototype,"_applyByPostProcess",void 0),Object(B.c)([Object(_.c)()],E.prototype,"_isEnabled",void 0),E}();_.a._ImageProcessingConfigurationParser=c.Parse},function(Ae,v,f){f.d(v,"a",function(){return E});var B=f(44),_=f(0),x=f(2),u=f(103),M=f(113),R={min:0,max:0},C={min:0,max:0},m=function(A,S,g){var l=_.e.Dot(S.centerWorld,A),h=Math.abs(_.e.Dot(S.directions[0],A))*S.extendSize.x+Math.abs(_.e.Dot(S.directions[1],A))*S.extendSize.y+Math.abs(_.e.Dot(S.directions[2],A))*S.extendSize.z;g.min=l-h,g.max=l+h},c=function(A,S,g){return m(A,S,R),m(A,g,C),!(R.min>C.max||C.min>R.max)},E=function(){function A(S,g,l){this._isLocked=!1,this.boundingBox=new u.a(S,g,l),this.boundingSphere=new M.a(S,g,l)}return A.prototype.reConstruct=function(S,g,l){this.boundingBox.reConstruct(S,g,l),this.boundingSphere.reConstruct(S,g,l)},Object.defineProperty(A.prototype,"minimum",{get:function(){return this.boundingBox.minimum},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"maximum",{get:function(){return this.boundingBox.maximum},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"isLocked",{get:function(){return this._isLocked},set:function(S){this._isLocked=S},enumerable:!1,configurable:!0}),A.prototype.update=function(S){this._isLocked||(this.boundingBox._update(S),this.boundingSphere._update(S))},A.prototype.centerOn=function(S,g){var l=A.TmpVector3[0].copyFrom(S).subtractInPlace(g),h=A.TmpVector3[1].copyFrom(S).addInPlace(g);return this.boundingBox.reConstruct(l,h,this.boundingBox.getWorldMatrix()),this.boundingSphere.reConstruct(l,h,this.boundingBox.getWorldMatrix()),this},A.prototype.scale=function(S){return this.boundingBox.scale(S),this.boundingSphere.scale(S),this},A.prototype.isInFrustum=function(S,g){return g===void 0&&(g=x.a.MESHES_CULLINGSTRATEGY_STANDARD),!(g!==x.a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION&&g!==x.a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY||!this.boundingSphere.isCenterInFrustum(S))||!!this.boundingSphere.isInFrustum(S)&&(!(g!==x.a.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY&&g!==x.a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY)||this.boundingBox.isInFrustum(S))}
826,Object.defineProperty(A.prototype,"diagonalLength",{get:function(){var S=this.boundingBox;return S.maximumWorld.subtractToRef(S.minimumWorld,A.TmpVector3[0]).length()},enumerable:!1,configurable:!0}),A.prototype.isCompletelyInFrustum=function(S){return this.boundingBox.isCompletelyInFrustum(S)},A.prototype._checkCollision=function(S){return S._canDoCollision(this.boundingSphere.centerWorld,this.boundingSphere.radiusWorld,this.boundingBox.minimumWorld,this.boundingBox.maximumWorld)},A.prototype.intersectsPoint=function(S){return!!this.boundingSphere.centerWorld&&!!this.boundingSphere.intersectsPoint(S)&&!!this.boundingBox.intersectsPoint(S)},A.prototype.intersects=function(S,g){if(!M.a.Intersects(this.boundingSphere,S.boundingSphere)||!u.a.Intersects(this.boundingBox,S.boundingBox))return!1;if(!g)return!0;var l=this.boundingBox,h=S.boundingBox;return!!c(l.directions[0],l,h)&&!!c(l.directions[1],l,h)&&!!c(l.directions[2],l,h)&&!!c(h.directions[0],l,h)&&!!c(h.directions[1],l,h)&&!!c(h.directions[2],l,h)&&!!c(_.e.Cross(l.directions[0],h.directions[0]),l,h)&&!!c(_.e.Cross(l.directions[0],h.directions[1]),l,h)&&!!c(_.e.Cross(l.directions[0],h.directions[2]),l,h)&&!!c(_.e.Cross(l.directions[1],h.directions[0]),l,h)&&!!c(_.e.Cross(l.directions[1],h.directions[1]),l,h)&&!!c(_.e.Cross(l.directions[1],h.directions[2]),l,h)&&!!c(_.e.Cross(l.directions[2],h.directions[0]),l,h)&&!!c(_.e.Cross(l.directions[2],h.directions[1]),l,h)&&!!c(_.e.Cross(l.directions[2],h.directions[2]),l,h)},A.TmpVector3=B.a.BuildArray(2,_.e.Zero),A}()},function(Ae,v,f){f.d(v,"a",function(){return B});var B=function(){function _(){}return _.BuildArray=function(x,u){for(var M=[],R=0;R<x;++R)M.push(u());return M},_}()},function(Ae,v,f){f.d(v,"a",function(){return u});var B=f(0),_=f(7),x=f(16);x.a.CreateSphere=function(M){for(var R=M.segments||32,C=M.diameterX||M.diameter||1,m=M.diameterY||M.diameter||1,c=M.diameterZ||M.diameter||1,E=M.arc&&(M.arc<=0||M.arc>1)?1:M.arc||1,A=M.slice&&M.slice<=0?1:M.slice||1,S=M.sideOrientation===0?0:M.sideOrientation||x.a.DEFAULTSIDE,g=!!M.dedupTopBottomIndices,l=new B.e(C/2,m/2,c/2),h=2+R,b=2*h,T=[],D=[],w=[],N=[],I=0;I<=h;I++){for(var V=I/h,W=V*Math.PI*A,j=0;j<=b;j++){var ne=j/b,te=ne*Math.PI*2*E,de=B.a.RotationZ(-W),pe=B.a.RotationY(te),ae=B.e.TransformCoordinates(B.e.Up(),de),ee=B.e.TransformCoordinates(ae,pe),K=ee.multiply(l),$=ee.divide(l).normalize();D.push(K.x,K.y,K.z),w.push($.x,$.y,$.z),N.push(ne,V)}if(I>0)for(var L=D.length/3,G=L-2*(b+1);G+b+2<L;G++)g?(I>1&&(T.push(G),T.push(G+1),T.push(G+b+1)),(I<h||A<1)&&(T.push(G+b+1),T.push(G+1),T.push(G+b+2))):(T.push(G),T.push(G+1),T.push(G+b+1),T.push(G+b+1),T.push(G+1),T.push(G+b+2))}x.a._ComputeSides(S,D,T,w,N,M.frontUVs,M.backUVs);var Q=new x.a;return Q.indices=T,Q.positions=D,Q.normals=w,Q.uvs=N,Q},_.a.CreateSphere=function(M,R,C,m,c,E){var A={segments:R,diameterX:C,diameterY:C,diameterZ:C,sideOrientation:E,updatable:c};return u.CreateSphere(M,A,m)};var u=function(){function M(){}return M.CreateSphere=function(R,C,m){m===void 0&&(m=null);var c=new _.a(R,m);return C.sideOrientation=_.a._GetDefaultSideOrientation(C.sideOrientation),c._originalBuilderSideOrientation=C.sideOrientation,x.a.CreateSphere(C).applyToMesh(c,C.updatable),c},M}()},function(Ae,v,f){f.d(v,"a",function(){return C});var B=f(1),_=f(3),x=f(6),u=f(0),M=f(29),R=f(23),C=function(m){function c(E,A,S){A===void 0&&(A=null),S===void 0&&(S=!0);var g=m.call(this,E,A)||this;return g._forward=new u.e(0,0,1),g._forwardInverted=new u.e(0,0,-1),g._up=new u.e(0,1,0),g._right=new u.e(1,0,0),g._rightInverted=new u.e(-1,0,0),g._position=u.e.Zero(),g._rotation=u.e.Zero(),g._rotationQuaternion=null,g._scaling=u.e.One(),g._isDirty=!1,g._transformToBoneReferal=null,g._isAbsoluteSynced=!1,g._billboardMode=c.BILLBOARDMODE_NONE,g._preserveParentRotationForBillboard=!1,g.scalingDeterminant=1,g._infiniteDistance=!1,g.ignoreNonUniformScaling=!1,g.reIntegrateRotationIntoRotationQuaternion=!1,g._poseMatrix=null,g._localMatrix=u.a.Zero(),g._usePivotMatrix=!1,g._absolutePosition=u.e.Zero(),g._absoluteScaling=u.e.Zero(),g._absoluteRotationQuaternion=u.b.Identity(),g._pivotMatrix=u.a.Identity(),g._postMultiplyPivotMatrix=!1,g._isWorldMatrixFrozen=!1,g._indexInSceneTransformNodesArray=-1,g.onAfterWorldMatrixUpdateObservable=new x.c,g._nonUniformScaling=!1,S&&g.getScene().addTransformNode(g),g}return Object(B.d)(c,m),Object.defineProperty(c.prototype,"billboardMode",{get:function(){return this._billboardMode},set:function(E){this._billboardMode!==E&&(this._billboardMode=E)}
826,enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"preserveParentRotationForBillboard",{get:function(){return this._preserveParentRotationForBillboard},set:function(E){E!==this._preserveParentRotationForBillboard&&(this._preserveParentRotationForBillboard=E)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"infiniteDistance",{get:function(){return this._infiniteDistance},set:function(E){this._infiniteDistance!==E&&(this._infiniteDistance=E)},enumerable:!1,configurable:!0}),c.prototype.getClassName=function(){return"TransformNode"},Object.defineProperty(c.prototype,"position",{get:function(){return this._position},set:function(E){this._position=E,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(c.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(c.prototype,"scaling",{get:function(){return this._scaling},set:function(E){this._scaling=E,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(c.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(c.prototype,"forward",{get:function(){return u.e.Normalize(u.e.TransformNormal(this.getScene().useRightHandedSystem?this._forwardInverted:this._forward,this.getWorldMatrix()))},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"up",{get:function(){return u.e.Normalize(u.e.TransformNormal(this._up,this.getWorldMatrix()))},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"right",{get:function(){return u.e.Normalize(u.e.TransformNormal(this.getScene().useRightHandedSystem?this._rightInverted:this._right,this.getWorldMatrix()))},enumerable:!1,configurable:!0}),c.prototype.updatePoseMatrix=function(E){return this._poseMatrix?(this._poseMatrix.copyFrom(E),this):(this._poseMatrix=E.clone(),this)},c.prototype.getPoseMatrix=function(){return this._poseMatrix||(this._poseMatrix=u.a.Identity()),this._poseMatrix},c.prototype._isSynchronized=function(){var E=this._cache;return this.billboardMode===E.billboardMode&&this.billboardMode===c.BILLBOARDMODE_NONE&&!E.pivotMatrixUpdated&&!this.infiniteDistance&&!this.position._isDirty&&!this.scaling._isDirty&&!(this._rotationQuaternion&&this._rotationQuaternion._isDirty||this.rotation._isDirty)},c.prototype._initCache=function(){m.prototype._initCache.call(this);var E=this._cache;E.localMatrixUpdated=!1,E.billboardMode=-1,E.infiniteDistance=!1},c.prototype.markAsDirty=function(E){return this._currentRenderId=Number.MAX_VALUE,this._isDirty=!0,this},Object.defineProperty(c.prototype,"absolutePosition",{get:function(){return this._absolutePosition},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"absoluteScaling",{get:function(){return this._syncAbsoluteScalingAndRotation(),this._absoluteScaling},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"absoluteRotationQuaternion",{get:function(){return this._syncAbsoluteScalingAndRotation(),this._absoluteRotationQuaternion},enumerable:!1,configurable:!0}),c.prototype.setPreTransformMatrix=function(E){return this.setPivotMatrix(E,!1)},c.prototype.setPivotMatrix=function(E,A){return A===void 0&&(A=!0),this._pivotMatrix.copyFrom(E),this._usePivotMatrix=!this._pivotMatrix.isIdentity(),this._cache.pivotMatrixUpdated=!0,this._postMultiplyPivotMatrix=A,this._postMultiplyPivotMatrix&&(this._pivotMatrixInverse?this._pivotMatrix.invertToRef(this._pivotMatrixInverse):this._pivotMatrixInverse=u.a.Invert(this._pivotMatrix)),this},c.prototype.getPivotMatrix=function(){return this._pivotMatrix},c.prototype.instantiateHierarchy=function(E,A,S){E===void 0&&(E=null);var g=this.clone("Clone of "+(this.name||this.id),E||this.parent,!0);g&&S&&S(this,g);for(var l=0,h=this.getChildTransformNodes(!0);l<h.length;l++)h[l].instantiateHierarchy(g,A,S);return g},c.prototype.freezeWorldMatrix=function(E){return E===void 0&&(E=null),E?this._worldMatrix=E:(this._isWorldMatrixFrozen=!1,this.computeWorldMatrix(!0)),this._isDirty=!1,this._isWorldMatrixFrozen=!0,this},c.prototype.unfreezeWorldMatrix=function(){return this._isWorldMatrixFrozen=!1,this.computeWorldMatrix(!0),this},Object.defineProperty(c.prototype,"isWorldMatrixFrozen",{get:function(){return this._isWorldMatrixFrozen}
826,enumerable:!1,configurable:!0}),c.prototype.getAbsolutePosition=function(){return this.computeWorldMatrix(),this._absolutePosition},c.prototype.setAbsolutePosition=function(E){if(!E)return this;var A,S,g;if(E.x===void 0){if(arguments.length<3)return this;A=arguments[0],S=arguments[1],g=arguments[2]}else A=E.x,S=E.y,g=E.z;if(this.parent){var l=u.c.Matrix[0];this.parent.getWorldMatrix().invertToRef(l),u.e.TransformCoordinatesFromFloatsToRef(A,S,g,l,this.position)}else this.position.x=A,this.position.y=S,this.position.z=g;return this._absolutePosition.copyFrom(E),this},c.prototype.setPositionWithLocalVector=function(E){return this.computeWorldMatrix(),this.position=u.e.TransformNormal(E,this._localMatrix),this},c.prototype.getPositionExpressedInLocalSpace=function(){this.computeWorldMatrix();var E=u.c.Matrix[0];return this._localMatrix.invertToRef(E),u.e.TransformNormal(this.position,E)},c.prototype.locallyTranslate=function(E){return this.computeWorldMatrix(!0),this.position=u.e.TransformCoordinates(E,this._localMatrix),this},c.prototype.lookAt=function(E,A,S,g,l){A===void 0&&(A=0),S===void 0&&(S=0),g===void 0&&(g=0),l===void 0&&(l=R.c.LOCAL);var h=c._lookAtVectorCache,b=l===R.c.LOCAL?this.position:this.getAbsolutePosition();if(E.subtractToRef(b,h),this.setDirection(h,A,S,g),l===R.c.WORLD&&this.parent)if(this.rotationQuaternion){var T=u.c.Matrix[0];this.rotationQuaternion.toRotationMatrix(T);var D=u.c.Matrix[1];this.parent.getWorldMatrix().getRotationMatrixToRef(D),D.invert(),T.multiplyToRef(D,T),this.rotationQuaternion.fromRotationMatrix(T)}else{var w=u.c.Quaternion[0];u.b.FromEulerVectorToRef(this.rotation,w),T=u.c.Matrix[0],w.toRotationMatrix(T),D=u.c.Matrix[1],this.parent.getWorldMatrix().getRotationMatrixToRef(D),D.invert(),T.multiplyToRef(D,T),w.fromRotationMatrix(T),w.toEulerAnglesToRef(this.rotation)}return this},c.prototype.getDirection=function(E){var A=u.e.Zero();return this.getDirectionToRef(E,A),A},c.prototype.getDirectionToRef=function(E,A){return u.e.TransformNormalToRef(E,this.getWorldMatrix(),A),this},c.prototype.setDirection=function(E,A,S,g){A===void 0&&(A=0),S===void 0&&(S=0),g===void 0&&(g=0);var l=-Math.atan2(E.z,E.x)+Math.PI/2,h=Math.sqrt(E.x*E.x+E.z*E.z),b=-Math.atan2(E.y,h);return this.rotationQuaternion?u.b.RotationYawPitchRollToRef(l+A,b+S,g,this.rotationQuaternion):(this.rotation.x=b+S,this.rotation.y=l+A,this.rotation.z=g),this},c.prototype.setPivotPoint=function(E,A){A===void 0&&(A=R.c.LOCAL),this.getScene().getRenderId()==0&&this.computeWorldMatrix(!0);var S=this.getWorldMatrix();if(A==R.c.WORLD){var g=u.c.Matrix[0];S.invertToRef(g),E=u.e.TransformCoordinates(E,g)}return this.setPivotMatrix(u.a.Translation(-E.x,-E.y,-E.z),!0)},c.prototype.getPivotPoint=function(){var E=u.e.Zero();return this.getPivotPointToRef(E),E},c.prototype.getPivotPointToRef=function(E){return E.x=-this._pivotMatrix.m[12],E.y=-this._pivotMatrix.m[13],E.z=-this._pivotMatrix.m[14],this},c.prototype.getAbsolutePivotPoint=function(){var E=u.e.Zero();return this.getAbsolutePivotPointToRef(E),E},c.prototype.getAbsolutePivotPointToRef=function(E){return this.getPivotPointToRef(E),u.e.TransformCoordinatesToRef(E,this.getWorldMatrix(),E),this},c.prototype.setParent=function(E){if(!E&&!this.parent)return this;var A=u.c.Quaternion[0],S=u.c.Vector3[0],g=u.c.Vector3[1];if(E){var l=u.c.Matrix[0],h=u.c.Matrix[1];this.computeWorldMatrix(!0),E.computeWorldMatrix(!0),E.getWorldMatrix().invertToRef(h),this.getWorldMatrix().multiplyToRef(h,l),l.decompose(g,A,S)}else this.computeWorldMatrix(!0),this.getWorldMatrix().decompose(g,A,S);return this.rotationQuaternion?this.rotationQuaternion.copyFrom(A):A.toEulerAnglesToRef(this.rotation),this.scaling.copyFrom(g),this.position.copyFrom(S),this.parent=E,this},Object.defineProperty(c.prototype,"nonUniformScaling",{get:function(){return this._nonUniformScaling},enumerable:!1,configurable:!0}),c.prototype._updateNonUniformScalingState=function(E){return this._nonUniformScaling!==E&&(this._nonUniformScaling=E,!0)},c.prototype.attachToBone=function(E,A){return this._transformToBoneReferal=A,this.parent=E,E.getSkeleton().prepare(),E.getWorldMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this},c.prototype.detachFromBone=function(){return this.parent?(this.parent.getWorldMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this._transformToBoneReferal=null,this.parent=null,this):this},c.prototype.rotate=function(E,A,S){var g;if(E.normalize(),this.rotationQuaternion||(this.rotationQuaternion=this.rotation.toQuaternion(),this.rotation.setAll(0)),S&&S!==R.c.LOCAL){if(this.parent){var l=u.c.Matrix[0];this.parent.getWorldMatrix().invertToRef(l),E=u.e.TransformNormal(E,l)}(g=u.b.RotationAxisToRef(E,A,c._rotationAxisCache)).multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)}else g=u.b.RotationAxisToRef(E,A,c._rotationAxisCache),this.rotationQuaternion.multiplyToRef(g,this.rotationQuaternion);return this}
826,c.prototype.rotateAround=function(E,A,S){A.normalize(),this.rotationQuaternion||(this.rotationQuaternion=u.b.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z),this.rotation.setAll(0));var g=u.c.Vector3[0],l=u.c.Vector3[1],h=u.c.Vector3[2],b=u.c.Quaternion[0],T=u.c.Matrix[0],D=u.c.Matrix[1],w=u.c.Matrix[2],N=u.c.Matrix[3];return E.subtractToRef(this.position,g),u.a.TranslationToRef(g.x,g.y,g.z,T),u.a.TranslationToRef(-g.x,-g.y,-g.z,D),u.a.RotationAxisToRef(A,S,w),D.multiplyToRef(w,N),N.multiplyToRef(T,N),N.decompose(l,b,h),this.position.addInPlace(h),b.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion),this},c.prototype.translate=function(E,A,S){var g=E.scale(A);if(S&&S!==R.c.LOCAL)this.setAbsolutePosition(this.getAbsolutePosition().add(g));else{var l=this.getPositionExpressedInLocalSpace().add(g);this.setPositionWithLocalVector(l)}return this},c.prototype.addRotation=function(E,A,S){var g;this.rotationQuaternion?g=this.rotationQuaternion:(g=u.c.Quaternion[1],u.b.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,g));var l=u.c.Quaternion[0];return u.b.RotationYawPitchRollToRef(A,E,S,l),g.multiplyInPlace(l),this.rotationQuaternion||g.toEulerAnglesToRef(this.rotation),this},c.prototype._getEffectiveParent=function(){return this.parent},c.prototype.computeWorldMatrix=function(E){if(this._isWorldMatrixFrozen&&!this._isDirty)return this._worldMatrix;var A=this.getScene().getRenderId();if(!this._isDirty&&!E&&this.isSynchronized())return this._currentRenderId=A,this._worldMatrix;var S=this.getScene().activeCamera,g=(this._billboardMode&c.BILLBOARDMODE_USE_POSITION)!=0,l=this._billboardMode!==c.BILLBOARDMODE_NONE&&!this.preserveParentRotationForBillboard;l&&S&&g&&(this.lookAt(S.position),(this.billboardMode&c.BILLBOARDMODE_X)!==c.BILLBOARDMODE_X&&(this.rotation.x=0),(this.billboardMode&c.BILLBOARDMODE_Y)!==c.BILLBOARDMODE_Y&&(this.rotation.y=0),(this.billboardMode&c.BILLBOARDMODE_Z)!==c.BILLBOARDMODE_Z&&(this.rotation.z=0)),this._updateCache();var h=this._cache;h.pivotMatrixUpdated=!1,h.billboardMode=this.billboardMode,h.infiniteDistance=this.infiniteDistance,this._currentRenderId=A,this._childUpdateId++,this._isDirty=!1,this._position._isDirty=!1,this._rotation._isDirty=!1,this._scaling._isDirty=!1;var b,T=this._getEffectiveParent(),D=c._TmpScaling,w=this._position;if(this._infiniteDistance&&!this.parent&&S){var N=S.getWorldMatrix(),I=new u.e(N.m[12],N.m[13],N.m[14]);(w=c._TmpTranslation).copyFromFloats(this._position.x+I.x,this._position.y+I.y,this._position.z+I.z)}if(D.copyFromFloats(this._scaling.x*this.scalingDeterminant,this._scaling.y*this.scalingDeterminant,this._scaling.z*this.scalingDeterminant),this._rotationQuaternion?(this._rotationQuaternion._isDirty=!1,b=this._rotationQuaternion,this.reIntegrateRotationIntoRotationQuaternion&&this.rotation.lengthSquared()&&(this._rotationQuaternion.multiplyInPlace(u.b.RotationYawPitchRoll(this._rotation.y,this._rotation.x,this._rotation.z)),this._rotation.copyFromFloats(0,0,0))):(b=c._TmpRotation,u.b.RotationYawPitchRollToRef(this._rotation.y,this._rotation.x,this._rotation.z,b)),this._usePivotMatrix){var V=u.c.Matrix[1];u.a.ScalingToRef(D.x,D.y,D.z,V);var W=u.c.Matrix[0];b.toRotationMatrix(W),this._pivotMatrix.multiplyToRef(V,u.c.Matrix[4]),u.c.Matrix[4].multiplyToRef(W,this._localMatrix),this._postMultiplyPivotMatrix&&this._localMatrix.multiplyToRef(this._pivotMatrixInverse,this._localMatrix),this._localMatrix.addTranslationFromFloats(w.x,w.y,w.z)}else u.a.ComposeToRef(D,b,w,this._localMatrix);if(T&&T.getWorldMatrix){if(E&&T.computeWorldMatrix(),l){this._transformToBoneReferal?T.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),u.c.Matrix[7]):u.c.Matrix[7].copyFrom(T.getWorldMatrix());var j=u.c.Vector3[5],ne=u.c.Vector3[6];u.c.Matrix[7].decompose(ne,void 0,j),u.a.ScalingToRef(ne.x,ne.y,ne.z,u.c.Matrix[7]),u.c.Matrix[7].setTranslation(j),this._localMatrix.multiplyToRef(u.c.Matrix[7],this._worldMatrix)}else this._transformToBoneReferal?(this._localMatrix.multiplyToRef(T.getWorldMatrix(),u.c.Matrix[6]),u.c.Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),this._worldMatrix)):this._localMatrix.multiplyToRef(T.getWorldMatrix(),this._worldMatrix);this._markSyncedWithParent()}else this._worldMatrix.copyFrom(this._localMatrix);if(l&&S&&this.billboardMode&&!g){var te=u.c.Vector3[0];if(this._worldMatrix.getTranslationToRef(te),u.c.Matrix[1].copyFrom(S.getViewMatrix()),u.c.Matrix[1].setTranslationFromFloats(0,0,0),u.c.Matrix[1].invertToRef(u.c.Matrix[0]),(this.billboardMode&c.BILLBOARDMODE_ALL)!==c.BILLBOARDMODE_ALL){u.c.Matrix[0].decompose(void 0,u.c.Quaternion[0],void 0);var de=u.c.Vector3[1];u.c.Quaternion[0].toEulerAnglesToRef(de),(this.billboardMode&c.BILLBOARDMODE_X)!==c.BILLBOARDMODE_X&&(de.x=0),(this.billboardMode&c.BILLBOARDMODE_Y)!==c.BILLBOARDMODE_Y&&(de.y=0),(this.billboardMode&c.BILLBOARDMODE_Z)!==c.BILLBOARDMODE_Z&&(de.z=0),u.a.RotationYawPitchRollToRef(de.y,de.x,de.z,u.c.Matrix[0])}this._worldMatrix.setTranslationFromFloats(0,0,0),this._worldMatrix.multiplyToRef(u.c.Matrix[0],this._worldMatrix),this._worldMatrix.setTranslation(u.c.Vector3[0])}return this.ignoreNonUniformScaling?this._updateNonUniformScalingState(!1):this._scaling.isNonUniformWithinEpsilon(1e-6)?this._updateNonUniformScalingState(!0):T&&T._nonUniformScaling?this._updateNonUniformScalingState(T._nonUniformScaling):this._updateNonUniformScalingState(!1),this._afterComputeWorldMatrix(),this._absolutePosition.copyFromFloats(this._worldMatrix.m[12],this._worldMatrix.m[13],this._worldMatrix.m[14]),this._isAbsoluteSynced=!1,this.onAfterWorldMatrixUpdateObservable.notifyObservers(this),this._poseMatrix||(this._poseMatrix=u.a.Invert(this._worldMatrix)),this._worldMatrixDeterminantIsDirty=!0,this._worldMatrix},c.prototype.resetLocalMatrix=function(E){if(E===void 0&&(E=!0),this.computeWorldMatrix(),E)for(var A=this.getChildren(),S=0;S<A.length;++S){var g=A[S];if(g){g.computeWorldMatrix();var l=u.c.Matrix[0];g._localMatrix.multiplyToRef(this._localMatrix,l);var h=u.c.Quaternion[0];l.decompose(g.scaling,h,g.position),g.rotationQuaternion?g.rotationQuaternion=h:h.toEulerAnglesToRef(g.rotation)}}this.scaling.copyFromFloats(1,1,1),this.position.copyFromFloats(0,0,0),this.rotation.copyFromFloats(0,0,0),this.rotationQuaternion&&(this.rotationQuaternion=u.b.Identity()),this._worldMatrix=u.a.Identity()},c.prototype._afterComputeWorldMatrix=function(){},c.prototype.registerAfterWorldMatrixUpdate=function(E){return this.onAfterWorldMatrixUpdateObservable.add(E),this},c.prototype.unregisterAfterWorldMatrixUpdate=function(E){return this.onAfterWorldMatrixUpdateObservable.removeCallback(E),this},c.prototype.getPositionInCameraSpace=function(E){return E===void 0&&(E=null),E||(E=this.getScene().activeCamera),u.e.TransformCoordinates(this.getAbsolutePosition(),E.getViewMatrix())},c.prototype.getDistanceToCamera=function(E){return E===void 0&&(E=null),E||(E=this.getScene().activeCamera),this.getAbsolutePosition().subtract(E.globalPosition).length()},c.prototype.clone=function(E,A,S){var g=this,l=_.a.Clone(function(){return new c(E,g.getScene())},this);if(l.name=E,l.id=E,A&&(l.parent=A),!S)for(var h=this.getDescendants(!0),b=0;b<h.length;b++){var T=h[b];T.clone&&T.clone(E+"."+T.name,l)}return l},c.prototype.serialize=function(E){var A=_.a.Serialize(this,E);return A.type=this.getClassName(),this.parent&&(A.parentId=this.parent.id),A.localMatrix=this.getPivotMatrix().asArray(),A.isEnabled=this.isEnabled(),this.parent&&(A.parentId=this.parent.id),A},c.Parse=function(E,A,S){var g=_.a.Parse(function(){return new c(E.name,A)},E,A,S);return E.localMatrix?g.setPreTransformMatrix(u.a.FromArray(E.localMatrix)):E.pivotMatrix&&g.setPivotMatrix(u.a.FromArray(E.pivotMatrix)),g.setEnabled(E.isEnabled),E.parentId&&(g._waitingParentId=E.parentId),g},c.prototype.getChildTransformNodes=function(E,A){var S=[];return this._getDescendants(S,E,function(g){return(!A||A(g))&&g instanceof c}),S},c.prototype.dispose=function(E,A){if(A===void 0&&(A=!1),this.get
826Scene().stopAnimation(this),this.getScene().removeTransformNode(this),this.onAfterWorldMatrixUpdateObservable.clear(),E)for(var S=0,g=this.getChildTransformNodes(!0);S<g.length;S++){var l=g[S];l.parent=null,l.computeWorldMatrix(!0)}m.prototype.dispose.call(this,E,A)},c.prototype.normalizeToUnitCube=function(E,A,S){E===void 0&&(E=!0),A===void 0&&(A=!1);var g=null,l=null;A&&(this.rotationQuaternion?(l=this.rotationQuaternion.clone(),this.rotationQuaternion.copyFromFloats(0,0,0,1)):this.rotation&&(g=this.rotation.clone(),this.rotation.copyFromFloats(0,0,0)));var h=this.getHierarchyBoundingVectors(E,S),b=h.max.subtract(h.min),T=Math.max(b.x,b.y,b.z);if(T===0)return this;var D=1/T;return this.scaling.scaleInPlace(D),A&&(this.rotationQuaternion&&l?this.rotationQuaternion.copyFrom(l):this.rotation&&g&&this.rotation.copyFrom(g)),this},c.prototype._syncAbsoluteScalingAndRotation=function(){this._isAbsoluteSynced||(this._worldMatrix.decompose(this._absoluteScaling,this._absoluteRotationQuaternion),this._isAbsoluteSynced=!0)},c.BILLBOARDMODE_NONE=0,c.BILLBOARDMODE_X=1,c.BILLBOARDMODE_Y=2,c.BILLBOARDMODE_Z=4,c.BILLBOARDMODE_ALL=7,c.BILLBOARDMODE_USE_POSITION=128,c._TmpRotation=u.b.Zero(),c._TmpScaling=u.e.Zero(),c._TmpTranslation=u.e.Zero(),c._lookAtVectorCache=new u.e(0,0,0),c._rotationAxisCache=new u.b,Object(B.c)([Object(_.o)("position")],c.prototype,"_position",void 0),Object(B.c)([Object(_.o)("rotation")],c.prototype,"_rotation",void 0),Object(B.c)([Object(_.l)("rotationQuaternion")],c.prototype,"_rotationQuaternion",void 0),Object(B.c)([Object(_.o)("scaling")],c.prototype,"_scaling",void 0),Object(B.c)([Object(_.c)("billboardMode")],c.prototype,"_billboardMode",void 0),Object(B.c)([Object(_.c)()],c.prototype,"scalingDeterminant",void 0),Object(B.c)([Object(_.c)("infiniteDistance")],c.prototype,"_infiniteDistance",void 0),Object(B.c)([Object(_.c)()],c.prototype,"ignoreNonUniformScaling",void 0),Object(B.c)([Object(_.c)()],c.prototype,"reIntegrateRotationIntoRotationQuaternion",void 0),c}(M.a)},function(Ae,v,f){f.d(v,"a",function(){return B});var B=function(){function _(x,u,M,R,C,m){this.source=x,this.pointerX=u,this.pointerY=M,this.meshUnderPointer=R,this.sourceEvent=C,this.additionalData=m}return _.CreateNew=function(x,u,M){var R=x.getScene();return new _(x,R.pointerX,R.pointerY,R.meshUnderPointer||x,u,M)},_.CreateNewFromSprite=function(x,u,M,R){return new _(x,u.pointerX,u.pointerY,u.meshUnderPointer,M,R)},_.CreateNewFromScene=function(x,u){return new _(null,x.pointerX,x.pointerY,x.meshUnderPointer,u)},_.CreateNewFromPrimitive=function(x,u,M,R){return new _(x,u.x,u.y,null,M,R)},_}()},function(Ae,v,f){f.d(v,"a",function(){return m});var B=f(1),_=f(3),x=f(0),u=f(9),M=f(29),R=f(85),C=f(11),m=function(c){function E(A,S){var g=c.call(this,A,S)||this;return g.diffuse=new u.a(1,1,1),g.specular=new u.a(1,1,1),g.falloffType=E.FALLOFF_DEFAULT,g.intensity=1,g._range=Number.MAX_VALUE,g._inverseSquaredRange=0,g._photometricScale=1,g._intensityMode=E.INTENSITYMODE_AUTOMATIC,g._radius=1e-5,g.renderPriority=0,g._shadowEnabled=!0,g._excludeWithLayerMask=0,g._includeOnlyWithLayerMask=0,g._lightmapMode=0,g._excludedMeshesIds=new Array,g._includedOnlyMeshesIds=new Array,g._isLight=!0,g.getScene().addLight(g),g._uniformBuffer=new R.a(g.getSce
826ne().getEngine()),g._buildUniformLayout(),g.includedOnlyMeshes=new Array,g.excludedMeshes=new Array,g._resyncMeshes(),g}return Object(B.d)(E,c),Object.defineProperty(E.prototype,"range",{get:function(){return this._range},set:function(A){this._range=A,this._inverseSquaredRange=1/(this.range*this.range)},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"intensityMode",{get:function(){return this._intensityMode},set:function(A){this._intensityMode=A,this._computePhotometricScale()},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"radius",{get:function(){return this._radius},set:function(A){this._radius=A,this._computePhotometricScale()},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"shadowEnabled",{get:function(){return this._shadowEnabled},set:function(A){this._shadowEnabled!==A&&(this._shadowEnabled=A,this._markMeshesAsLightDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"includedOnlyMeshes",{get:function(){return this._includedOnlyMeshes},set:function(A){this._includedOnlyMeshes=A,this._hookArrayForIncludedOnly(A)},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"excludedMeshes",{get:function(){return this._excludedMeshes},set:function(A){this._excludedMeshes=A,this._hookArrayForExcluded(A)},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"excludeWithLayerMask",{get:function(){return this._excludeWithLayerMask},set:function(A){this._excludeWithLayerMask=A,this._resyncMeshes()},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"includeOnlyWithLayerMask",{get:function(){return this._includeOnlyWithLayerMask},set:function(A){this._includeOnlyWithLayerMask=A,this._resyncMeshes()},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"lightmapMode",{get:function(){return this._lightmapMode},set:function(A){this._lightmapMode!==A&&(this._lightmapMode=A,this._markMeshesAsLightDirty())},enumerable:!1,configurable:!0}),E.prototype.transferTexturesToEffect=function(A,S){return this},E.prototype._bindLight=function(A,S,g,l,h){h===void 0&&(h=!1);var b=A.toString(),T=!1;if(!h||!this._uniformBuffer._alreadyBound){if(this._uniformBuffer.bindToEffect(g,"Light"+b),this._renderId!==S.getRenderId()||!this._uniformBuffer.useUbo){this._renderId=S.getRenderId();var D=this.getScaledIntensity();this.transferToEffect(g,b),this.diffuse.scaleToRef(D,u.c.Color3[0]),this._uniformBuffer.updateColor4("vLightDiffuse",u.c.Color3[0],this.range,b),l&&(this.specular.scaleToRef(D,u.c.Color3[1]),this._uniformBuffer.updateColor4("vLightSpecular",u.c.Color3[1],this.radius,b)),T=!0}if(this.transferTexturesToEffect(g,b),S.shadowsEnabled&&this.shadowEnabled){var w=this.getShadowGenerator();w&&(w.bindShadowLight(b,g),T=!0)}T&&this._uniformBuffer.update()}},E.prototype.getClassName=function(){return"Light"},E.prototype.toString=function(A){var S="Name: "+this.name;if(S+=", type: "+["Point","Directional","Spot","Hemispheric"][this.getTypeID()],this.animations)for(var g=0;g<this.animations.length;g++)S+=", animation[0]: "+this.animations[g].toString(A);return S},E.prototype._syncParentEnabledState=function(){c.prototype._syncParentEnabledState.call(this),this.isDisposed()||this._resyncMeshes()},E.prototype.setEnabled=function(A){c.prototype.setEnabled.call(this,A),this._resyncMeshes()},E.prototype.getShadowGenerator=function(){return this._shadowGenerator},E.prototype.getAbsolutePosition=function(){return x.e.Zero()},E.prototype.canAffectMesh=function(A){return!A||!(this.includedOnlyMeshes&&this.includedOnlyMeshes.length>0&&this.includedOnlyMeshes.indexOf(A)===-1)&&!(this.excludedMeshes&&this.excludedMeshes.length>0&&this.excludedMeshes.indexOf(A)!==-1)&&(this.includeOnlyWithLayerMask===0||(this.includeOnlyWithLayerMask&A.layerMask)!=0)&&!(this.excludeWithLayerMask!==0&&this.excludeWithLayerMask&A.layerMask)},E.CompareLightsPriority=function(A,S){return A.shadowEnabled!==S.shadowEnabled?(S.shadowEnabled?1:0)-(A.shadowEnabled?1:0):S.renderPriority-A.renderPriority},E.prototype.dispose=function(A,S){S===void 0&&(S=!1),this._shadowGenerator&&(this._shadowGenerator.dispose(),this._shadowGenerator=null),this.get
826Scene().stopAnimation(this);for(var g=0,l=this.getScene().meshes;g<l.length;g++)l[g]._removeLightSource(this,!0);this._uniformBuffer.dispose(),this.getScene().removeLight(this),c.prototype.dispose.call(this,A,S)},E.prototype.getTypeID=function(){return 0},E.prototype.getScaledIntensity=function(){return this._photometricScale*this.intensity},E.prototype.clone=function(A,S){S===void 0&&(S=null);var g=E.GetConstructorFromName(this.getTypeID(),A,this.getScene());if(!g)return null;var l=_.a.Clone(g,this);return S&&(l.parent=S),l.setEnabled(this.isEnabled()),l},E.prototype.serialize=function(){var A=_.a.Serialize(this);return A.type=this.getTypeID(),this.parent&&(A.parentId=this.parent.id),this.excludedMeshes.length>0&&(A.excludedMeshesIds=[],this.excludedMeshes.forEach(function(S){A.excludedMeshesIds.push(S.id)})),this.includedOnlyMeshes.length>0&&(A.includedOnlyMeshesIds=[],this.includedOnlyMeshes.forEach(function(S){A.includedOnlyMeshesIds.push(S.id)})),_.a.AppendSerializedAnimations(this,A),A.ranges=this.serializeAnimationRanges(),A},E.GetConstructorFromName=function(A,S,g){var l=M.a.Construct("Light_Type_"+A,S,g);return l||null},E.Parse=function(A,S){var g=E.GetConstructorFromName(A.type,A.name,S);if(!g)return null;var l=_.a.Parse(g,A,S);if(A.excludedMeshesIds&&(l._excludedMeshesIds=A.excludedMeshesIds),A.includedOnlyMeshesIds&&(l._includedOnlyMeshesIds=A.includedOnlyMeshesIds),A.parentId&&(l._waitingParentId=A.parentId),A.falloffType!==void 0&&(l.falloffType=A.falloffType),A.lightmapMode!==void 0&&(l.lightmapMode=A.lightmapMode),A.animations){for(var h=0;h<A.animations.length;h++){var b=A.animations[h],T=C.a.GetClass("BABYLON.Animation");T&&l.animations.push(T.Parse(b))}M.a.ParseAnimationRanges(l,A,S)}return A.autoAnimate&&S.beginAnimation(l,A.autoAnimateFrom,A.autoAnimateTo,A.autoAnimateLoop,A.autoAnimateSpeed||1),l},E.prototype._hookArrayForExcluded=function(A){var S=this,g=A.push;A.push=function(){for(var T=[],D=0;D<arguments.length;D++)T[D]=arguments[D];for(var w=g.apply(A,T),N=0,I=T;N<I.length;N++){var V=I[N];V._resyncLightSource(S)}return w};var l=A.splice;A.splice=function(T,D){for(var w=l.apply(A,[T,D]),N=0,I=w;N<I.length;N++)I[N]._resyncLightSource(S);return w};for(var h=0,b=A;h<b.length;h++)b[h]._resyncLightSource(this)},E.prototype._hookArrayForIncludedOnly=function(A){var S=this,g=A.push;A.push=function(){for(var h=[],b=0;b<arguments.length;b++)h[b]=arguments[b];var T=g.apply(A,h);return S._resyncMeshes(),T};var l=A.splice;A.splice=function(h,b){var T=l.apply(A,[h,b]);return S._resyncMeshes(),T},this._resyncMeshes()},E.prototype._resyncMeshes=function(){for(var A=0,S=this.getScene().meshes;A<S.length;A++)S[A]._resyncLightSource(this)},E.prototype._markMeshesAsLightDirty=function(){for(var A=0,S=this.getScene().meshes;A<S.length;A++){var g=S[A];g.lightSources.indexOf(this)!==-1&&g._markSubMeshesAsLightDirty()}},E.prototype._computePhotometricScale=function(){this._photometricScale=this._getPhotometricScale(),this.getScene().resetCachedMaterial()},E.prototype._getPhotometricScale=function(){var A=0,S=this.getTypeID(),g=this.intensityMode;switch(g===E.INTENSITYMODE_AUTOMATIC&&(g=S===E.LIGHTTYPEID_DIRECTIONALLIGHT?E.INTENSITYMODE_ILLUMINANCE:E.INTENSITYMODE_LUMINOUSINTENSITY),S){case E.LIGHTTYPEID_POINTLIGHT:case E.LIGHTTYPEID_SPOTLIGHT:switch(g){case E.INTENSITYMODE_LUMINOUSPOWER:A=1/(4*Math.PI);break;case E.INTENSITYMODE_LUMINOUSINTENSITY:A=1;break;case E.INTENSITYMODE_LUMINANCE:A=this.radius*this.radius}break;case E.LIGHTTYPEID_DIRECTIONALLIGHT:switch(g){case E.INTENSITYMODE_ILLUMINANCE:A=1;break;case E.INTENSITYMODE_LUMINANCE:var l=this.radius;l=Math.max(l,.001),A=2*Math.PI*(1-Math.cos(l))}break;case E.LIGHTTYPEID_HEMISPHERICLIGHT:A=1}return A},E.prototype._reorderLightsInScene=function(){var A=this.getScene();
826this._renderPriority!=0&&(A.requireLightSorting=!0),this.getScene().sortLightsByPriority()},E.FALLOFF_DEFAULT=0,E.FALLOFF_PHYSICAL=1,E.FALLOFF_GLTF=2,E.FALLOFF_STANDARD=3,E.LIGHTMAP_DEFAULT=0,E.LIGHTMAP_SPECULAR=1,E.LIGHTMAP_SHADOWSONLY=2,E.INTENSITYMODE_AUTOMATIC=0,E.INTENSITYMODE_LUMINOUSPOWER=1,E.INTENSITYMODE_LUMINOUSINTENSITY=2,E.INTENSITYMODE_ILLUMINANCE=3,E.INTENSITYMODE_LUMINANCE=4,E.LIGHTTYPEID_POINTLIGHT=0,E.LIGHTTYPEID_DIRECTIONALLIGHT=1,E.LIGHTTYPEID_SPOTLIGHT=2,E.LIGHTTYPEID_HEMISPHERICLIGHT=3,Object(B.c)([Object(_.e)()],E.prototype,"diffuse",void 0),Object(B.c)([Object(_.e)()],E.prototype,"specular",void 0),Object(B.c)([Object(_.c)()],E.prototype,"falloffType",void 0),Object(B.c)([Object(_.c)()],E.prototype,"intensity",void 0),Object(B.c)([Object(_.c)()],E.prototype,"range",null),Object(B.c)([Object(_.c)()],E.prototype,"intensityMode",null),Object(B.c)([Object(_.c)()],E.prototype,"radius",null),Object(B.c)([Object(_.c)()],E.prototype,"_renderPriority",void 0),Object(B.c)([Object(_.b)("_reorderLightsInScene")],E.prototype,"renderPriority",void 0),Object(B.c)([Object(_.c)("shadowEnabled")],E.prototype,"_shadowEnabled",void 0),Object(B.c)([Object(_.c)("excludeWithLayerMask")],E.prototype,"_excludeWithLayerMask",void 0),Object(B.c)([Object(_.c)("includeOnlyWithLayerMask")],E.prototype,"_includeOnlyWithLayerMask",void 0),Object(B.c)([Object(_.c)("lightmapMode")],E.prototype,"_lightmapMode",void 0),E}(M.a)},function(Ae,v,f){f.d(v,"a",function(){return B});var B=function(){function _(){this._xhr=typeof _native<"u"&&_native.XMLHttpRequest?new _native.XMLHttpRequest:new XMLHttpRequest}return _.prototype._injectCustomRequestHeaders=function(){for(var x in _.CustomRequestHeaders){var u=_.CustomRequestHeaders[x];u&&this._xhr.setRequestHeader(x,u)}},Object.defineProperty(_.prototype,"onprogress",{get:function(){return this._xhr.onprogress},set:function(x){this._xhr.onprogress=x},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"readyState",{get:function(){return this._xhr.readyState},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"status",{get:function(){return this._xhr.status},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"statusText",{get:function(){return this._xhr.statusText},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"response",{get:function(){return this._xhr.response},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"responseURL",{get:function(){return this._xhr.responseURL},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"responseText",{get:function(){return this._xhr.responseText},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"responseType",{get:function(){return this._xhr.responseType},set:function(x){this._xhr.responseType=x},enumerable:!1,configurable:!0}),_.prototype.addEventListener=function(x,u,M){this._xhr.addEventListener(x,u,M)},_.prototype.removeEventListener=function(x,u,M){this._xhr.removeEventListener(x,u,M)},_.prototype.abort=function(){this._xhr.abort()},_.prototype.send=function(x){_.CustomRequestHeaders&&this._injectCustomRequestHeaders(),this._xhr.send(x)},_.prototype.open=function(x,u){for(var M=0,R=_.CustomRequestModifiers;M<R.length;M++)(0,R[M])(this._xhr,u);return u=(u=u.replace("file:http:","http:")).replace("file:https:","https:"),this._xhr.open(x,u,!0)},_.prototype.setRequestHeader=function(x,u){this._xhr.setRequestHeader(x,u)},_.prototype.getResponseHeader=function(x){return this._xhr.getResponseHeader(x)},_.CustomRequestHeaders={},_.CustomRequestModifiers=new Array,_}()},function(Ae,v,f){f.d(v,"e",function(){return _}),f.d(v,"a",function(){return x}),f.d(v,"d",function(){return u}),f.d(v,"c",function(){return M}),f.d(v,"b",function(){return R});var B=f(1),_=function(){function C(m,c){this.type=m,this.jointData=c,c.nativeParams=c.nativeParams||{}}return Object.defineProperty(C.prototype,"physicsJoint",{get:function(){return this._physicsJoint},set:function(m){this._physicsJoint,this._physicsJoint=m},enumerable:!1,configurable:!0}),Object.defineProperty(C.prototype,"physicsPlugin",{set:function(m){this._physicsPlugin=m}
826,enumerable:!1,configurable:!0}),C.prototype.executeNativeFunction=function(m){m(this._physicsPlugin.world,this._physicsJoint)},C.DistanceJoint=0,C.HingeJoint=1,C.BallAndSocketJoint=2,C.WheelJoint=3,C.SliderJoint=4,C.PrismaticJoint=5,C.UniversalJoint=6,C.Hinge2Joint=C.WheelJoint,C.PointToPointJoint=8,C.SpringJoint=9,C.LockJoint=10,C}(),x=function(C){function m(c){return C.call(this,_.DistanceJoint,c)||this}return Object(B.d)(m,C),m.prototype.updateDistance=function(c,E){this._physicsPlugin.updateDistanceJoint(this,c,E)},m}(_),u=function(C){function m(c,E){return C.call(this,c,E)||this}return Object(B.d)(m,C),m.prototype.setMotor=function(c,E){this._physicsPlugin.setMotor(this,c||0,E)},m.prototype.setLimit=function(c,E){this._physicsPlugin.setLimit(this,c,E)},m}(_),M=function(C){function m(c){return C.call(this,_.HingeJoint,c)||this}return Object(B.d)(m,C),m.prototype.setMotor=function(c,E){this._physicsPlugin.setMotor(this,c||0,E)},m.prototype.setLimit=function(c,E){this._physicsPlugin.setLimit(this,c,E)},m}(u),R=function(C){function m(c){return C.call(this,_.Hinge2Joint,c)||this}return Object(B.d)(m,C),m.prototype.setMotor=function(c,E,A){A===void 0&&(A=0),this._physicsPlugin.setMotor(this,c||0,E,A)},m.prototype.setLimit=function(c,E,A){A===void 0&&(A=0),this._physicsPlugin.setLimit(this,c,E,A)},m}(u)},function(Ae,v,f){f.d(v,"a",function(){return M});var B=f(0),_=f(7),x=f(36),u=f(18),M=function(){function R(C){var m=this;C===void 0&&(C=x.a.DefaultUtilityLayer),this.gizmoLayer=C,this._attachedMesh=null,this._attachedNode=null,this._scaleRatio=1,this._isHovered=!1,this._customMeshSet=!1,this._updateGizmoRotationToMatchAttachedMesh=!0,this.updateGizmoPositionToMatchAttachedMesh=!0,this.updateScale=!0,this._interactionsEnabled=!0,this._tempQuaternion=new B.b(0,0,0,1),this._tempVector=new B.e,this._tempVector2=new B.e,this._tempMatrix1=new B.a,this._tempMatrix2=new B.a,this._rightHandtoLeftHandMatrix=B.a.RotationY(Math.PI),this._rootMesh=new _.a("gizmoRootNode",C.utilityLayerScene),this._rootMesh.rotationQuaternion=B.b.Identity(),this._beforeRenderObserver=this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add(function(){m._update()})}return Object.defineProperty(R.prototype,"scaleRatio",{get:function(){return this._scaleRatio},set:function(C){this._scaleRatio=C},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(C){this._attachedMesh=C,C&&(this._attachedNode=C),this._rootMesh.setEnabled(!!C),this._attachedNodeChanged(C)},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"attachedNode",{get:function(){return this._attachedNode},set:function(C){this._attachedNode=C,this._attachedMesh=null,this._rootMesh.setEnabled(!!C),this._attachedNodeChanged(C)},enumerable:!1,configurable:!0}),R.prototype.setCustomMesh=function(C){if(C.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(m){m.dispose()}),C.parent=this._rootMesh,this._customMeshSet=!0},Object.defineProperty(R.prototype,"updateGizmoRotationToMatchAttachedMesh",{get:function(){return this._updateGizmoRotationToMatchAttachedMesh},set:function(C){this._updateGizmoRotationToMatchAttachedMesh=C},enumerable:!1,configurable:!0}),R.prototype._attachedNodeChanged=function(C){},R.prototype._update=function(){if(this.attachedNode){var C=this.attachedNode;if(this.attachedMesh&&(C=this.attachedMesh._effectiveMesh||this.attachedNode),this.updateGizmoPositionToMatchAttachedMesh){var m=C.getWorldMatrix().getRow(3),c=m?m.toVector3():new B.e(0,0,0);this._rootMesh.position.copyFrom(c)}if(this.updateGizmoRotationToMatchAttachedMesh?C.getWorldMatrix().decompose(void 0,this._rootMesh.rotationQuaternion):this._rootMesh.rotationQuaternion.set(0,0,0,1),this.updateScale){var E=this.gizmoLayer.utilityLayerScene.activeCamera,A=E.globalPosition;E.devicePosition&&(A=E.devicePosition),this._rootMesh.position.subtractToRef(A,this._tempVector);var S=this._tempVector.length()*this.scaleRatio;this._rootMesh.scaling.set(S,S,S),C._getWorldMatrixDeterminant()<0&&(this._rootMesh.scaling.y*=-1)}else this._rootMesh.scaling.setAll(this.scaleRatio)}},R.prototype._matrixChanged=function(){if(this._attachedNode){if(this._attachedNode._isCamera){var C,m,c=this._attachedNode;if(c.parent){var E=this._tempMatrix2;c.parent._worldMatrix.invertToRef(E),this._attachedNode._worldMatrix.multiplyToRef(E,this._tempMatrix1),C=this._tempMatrix1}else C=this._attachedNode._worldMatrix;
826if(c.getScene().useRightHandedSystem?(this._rightHandtoLeftHandMatrix.multiplyToRef(C,this._tempMatrix2),m=this._tempMatrix2):m=C,m.decompose(this._tempVector2,this._tempQuaternion,this._tempVector),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 A=this._attachedNode;A.rotation=this._tempQuaternion.toEulerAngles(),A.rotationQuaternion&&A.rotationQuaternion.copyFrom(this._tempQuaternion)}c.position.copyFrom(this._tempVector)}else if(this._attachedNode._isMesh||this._attachedNode.getClassName()==="AbstractMesh"||this._attachedNode.getClassName()==="TransformNode"||this._attachedNode.getClassName()==="InstancedMesh"){var S=this._attachedNode;if(S.parent){E=this._tempMatrix1;var g=this._tempMatrix2;S.parent.getWorldMatrix().invertToRef(E),this._attachedNode.getWorldMatrix().multiplyToRef(E,g),g.decompose(S.scaling,this._tempQuaternion,S.position)}else this._attachedNode._worldMatrix.decompose(S.scaling,this._tempQuaternion,S.position);S.billboardMode||(S.rotationQuaternion?S.rotationQuaternion.copyFrom(this._tempQuaternion):S.rotation=this._tempQuaternion.toEulerAngles())}else if(this._attachedNode.getClassName()==="Bone"){var l=this._attachedNode,h=l.getParent();if(h){var b=this._tempMatrix1,T=this._tempMatrix2;h.getWorldMatrix().invertToRef(b),l.getWorldMatrix().multiplyToRef(b,T),l.getLocalMatrix().copyFrom(T)}else l.getLocalMatrix().copyFrom(l.getWorldMatrix());l.markAsDirty()}}},R.GizmoAxisPointerObserver=function(C,m){var c=!1;return C.utilityLayerScene.onPointerObservable.add(function(E){var A,S;if(E.pickInfo){if(E.type===u.a.POINTERMOVE){if(c)return;m.forEach(function(g){var l,h;if(g.colliderMeshes&&g.gizmoMeshes){var b=((l=g.colliderMeshes)===null||l===void 0?void 0:l.indexOf((h=E?.pickInfo)===null||h===void 0?void 0:h.pickedMesh))!=-1||g.active?g.hoverMaterial:g.material;g.gizmoMeshes.forEach(function(T){T.material=b,T.color&&(T.color=b.diffuseColor)})}})}E.type===u.a.POINTERDOWN&&m.has((A=E.pickInfo.pickedMesh)===null||A===void 0?void 0:A.parent)&&(c=!0,m.get((S=E.pickInfo.pickedMesh)===null||S===void 0?void 0:S.parent).active=!0,m.forEach(function(g){var l,h,b=((l=g.colliderMeshes)===null||l===void 0?void 0:l.indexOf((h=E?.pickInfo)===null||h===void 0?void 0:h.pickedMesh))!=-1||g.active?g.hoverMaterial:g.disableMaterial;g.gizmoMeshes.forEach(function(T){T.material=b,T.color&&(T.color=b.diffuseColor)})})),E.type===u.a.POINTERUP&&m.forEach(function(g){g.active=!1,c=!1,g.gizmoMeshes.forEach(function(l){l.material=g.material,l.color&&(l.color=g.material.diffuseColor)})})}})},R.prototype.dispose=function(){this._rootMesh.dispose(),this._beforeRenderObserver&&this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver)},R}()},function(Ae,v,f){f.d(v,"a",function(){return c});var B=f(1),_=f(3),x=f(6),u=f(0),M=f(22),R=f(2),C=f(120),m=(f(56),f(77)),c=function(E){function A(S){var g=E.call(this,null)||this;return g.metadata=null,g.reservedDataStore=null,g._hasAlpha=!1,g.getAlphaFromRGB=!1,g.level=1,g.coordinatesIndex=0,g._coordinatesMode=R.a.TEXTURE_EXPLICIT_MODE,g.wrapR=R.a.TEXTURE_WRAP_ADDRESSMODE,g.anisotropicFilteringLevel=A.DEFAULT_ANISOTROPIC_FILTERING_LEVEL,g._isCube=!1,g._gammaSpace=!0,g.invertZ=!1,g.lodLevelInAlpha=!1,g.isRenderTarget=!1,g._prefiltered=!1,g.animations=new Array,g.onDisposeObservable=new x.c,g._onDisposeObserver=null,g._scene=null,g._texture=null,g._uid=null,S?A._isScene(S)?g._scene=S:g._engine=S:g._scene=M.a.LastCreatedScene,g._scene&&(g.uniqueId=g._scene.getUniqueId(),g._scene.addTexture(g),g._engine=g._scene.getEngine()),g._uid=null,g}return Object(B.d)(A,E),Object.defineProperty(A.prototype,"hasAlpha",{get:function(){return this._hasAlpha},set:function(S){this._hasAlpha!==S&&(this._hasAlpha=S,this._scene&&this._scene.markAllMaterialsAsDirty(R.a.MATERIAL_TextureDirtyFlag|R.a.MATERIAL_MiscDirtyFlag))}
826,enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"coordinatesMode",{get:function(){return this._coordinatesMode},set:function(S){this._coordinatesMode!==S&&(this._coordinatesMode=S,this._scene&&this._scene.markAllMaterialsAsDirty(R.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),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,"isCube",{get:function(){return this._texture?this._texture.isCube:this._isCube},set:function(S){this._texture?this._texture.isCube=S:this._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}),Object.defineProperty(A.prototype,"gammaSpace",{get:function(){return this._texture?(this._texture._gammaSpace===null&&(this._texture._gammaSpace=this._gammaSpace),this._texture._gammaSpace):this._gammaSpace},set:function(S){if(this._texture){if(this._texture._gammaSpace===S)return;this._texture._gammaSpace=S}else{if(this._gammaSpace===S)return;this._gammaSpace=S}this._markAllSubMeshesAsTexturesDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"isRGBD",{get:function(){return this._texture!=null&&this._texture._isRGBD},set:function(S){this._texture&&(this._texture._isRGBD=S)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"noMipmap",{get:function(){return!1},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"lodGenerationOffset",{get:function(){return this._texture?this._texture._lodGenerationOffset:0},set:function(S){this._texture&&(this._texture._lodGenerationOffset=S)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"lodGenerationScale",{get:function(){return this._texture?this._texture._lodGenerationScale:0}
826,set:function(S){this._texture&&(this._texture._lodGenerationScale=S)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"linearSpecularLOD",{get:function(){return!!this._texture&&this._texture._linearSpecularLOD},set:function(S){this._texture&&(this._texture._linearSpecularLOD=S)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"irradianceTexture",{get:function(){return this._texture?this._texture._irradianceTexture:null},set:function(S){this._texture&&(this._texture._irradianceTexture=S)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"uid",{get:function(){return this._uid||(this._uid=C.a.RandomId()),this._uid},enumerable:!1,configurable:!0}),A.prototype.toString=function(){return this.name},A.prototype.getClassName=function(){return"BaseTexture"},Object.defineProperty(A.prototype,"onDispose",{set:function(S){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(S)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"isBlocking",{get:function(){return!0},enumerable:!1,configurable:!0}),A.prototype.getScene=function(){return this._scene},A.prototype._getEngine=function(){return this._engine},A.prototype.checkTransformsAreIdentical=function(S){return S!==null},A.prototype.getTextureMatrix=function(){return u.a.IdentityReadOnly},A.prototype.getReflectionTextureMatrix=function(){return u.a.IdentityReadOnly},A.prototype.isReadyOrNotBlocking=function(){return!this.isBlocking||this.isReady()},A.prototype.scale=function(S){},Object.defineProperty(A.prototype,"canRescale",{get:function(){return!1},enumerable:!1,configurable:!0}),A.prototype._getFromCache=function(S,g,l,h){var b=this._getEngine();if(!b)return null;for(var T=b.getLoadedTexturesCache(),D=0;D<T.length;D++){var w=T[D];if(!(h!==void 0&&h!==w.invertY||w.url!==S||w.generateMipMaps!==!g||l&&l!==w.samplingMode))return w.incrementReferences(),w}return null},A.prototype._rebuild=function(){},A.prototype.clone=function(){return null},Object.defineProperty(A.prototype,"textureType",{get:function(){return this._texture&&this._texture.type!==void 0?this._texture.type:R.a.TEXTURETYPE_UNSIGNED_INT},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"textureFormat",{get:function(){return this._texture&&this._texture.format!==void 0?this._texture.format:R.a.TEXTUREFORMAT_RGBA},enumerable:!1,configurable:!0}),A.prototype._markAllSubMeshesAsTexturesDirty=function(){var S=this.getScene();S&&S.markAllMaterialsAsDirty(R.a.MATERIAL_TextureDirtyFlag)},A.prototype.readPixels=function(S,g,l){if(S===void 0&&(S=0),g===void 0&&(g=0),l===void 0&&(l=null),!this._texture)return null;var h=this.getSize(),b=h.width,T=h.height,D=this._getEngine();if(!D)return null;g!=0&&(b/=Math.pow(2,g),T/=Math.pow(2,g),b=Math.round(b),T=Math.round(T));try{return this._texture.isCube?D._readTexturePixels(this._texture,b,T,S,g,l):D._readTexturePixels(this._texture,b,T,-1,g,l)}catch{return null}},Object.defineProperty(A.prototype,"_lodTextureHigh",{get:function(){return this._texture?this._texture._lodTextureHigh:null},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"_lodTextureMid",{get:function(){return this._texture?this._texture._lodTextureMid:null},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"_lodTextureLow",{get:function(){return this._texture?this._texture._lodTextureLow:null},enumerable:!1,configurable:!0}),A.prototype.dispose=function(){if(this._scene){this._scene.stopAnimation&&this._scene.stopAnimation(this),this._scene._removePendingData(this);var S=this._scene.textures.indexOf(this);S>=0&&this._scene.textures.splice(S,1),this._scene.onTextureRemovedObservable.notifyObservers(this),this._scene=null}this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),E.prototype.dispose.call(this)},A.prototype.serialize=function(){if(!this.name)return null;var S=_.a.Serialize(this);return _.a.AppendSerializedAnimations(this,S),S},A.WhenAllReady=function(S,g){var l=S.length;if(l!==0)for(var h=0;h<S.length;h++){var b=S[h];if(b.isReady())--l==0&&g();else{var T=b.onLoadObservable;T&&T.addOnce(function(){--l==0&&g()})}}else g()},A._isScene=function(S){return S.getClassName()==="Scene"},A.DEFAULT_ANISOTROPIC_FILTERING_LEVEL=4,Object(B.c)([Object(_.c)()],A.prototype,"uniqueId",void 0),Object(B.c)([Object(_.c)()],A.prototype,"name",void 0),Object(B.c)([Object(_.c)()],A.prototype,"metadata",void 0),Object(B.c)([Object(_.c)("hasAlpha")],A.prototype,"_hasAlpha",void 0),Object(B.c)([Object(_.c)()],A.prototype,"getAlphaFromRGB",void 0),Object(B.c)([Object(_.c)()],A.prototype,"level",void 0),Object(B.c)([Object(_.c)()],A.prototype,"coordinatesIndex",void 0),Object(B.c)([Object(_.c)("coordinatesMode")],A.prototype,"_coordinatesMode",void 0),Object(B.c)([Object(_.c)()],A.prototype,"wrapU",null),Object(B.c)([Object(_.c)()],A.prototype,"wrapV",null),Object(B.c)([Object(_.c)()],A.prototype,"wrapR",void 0),Object(B.c)([Object(_.c)()],A.prototype,"anisotropicFilteringLevel",void 0),Object(B.c)([Object(_.c)()],A.prototype,"isCube",null),Object(B.c)([Object(_.c)()],A.prototype,"is3D",null),Object(B.c)([Object(_.c)()],A.prototype,"is2DArray",null),Object(B.c)([Object(_.c)()],A.prototype,"gammaSpace",null),Object(B.c)([Object(_.c)()],A.prototype,"invertZ",void 0),Object(B.c)([Object(_.c)()],A.prototype,"lodLevelInAlpha",void 0),Object(B.c)([Object(_.c)()],A.prototype,"lodGenerationOffset",null),Object(B.c)([Object(_.c)()],A.prototype,"lodGenerationScale",null),Object(B.c)([Object(_.c)()],A.prototype,"linearSpecularLOD",null),Object(B.c)([Object(_.m)()],A.prototype,"irradianceTexture",null),Object(B.c)([Object(_.c)()],A.prototype,"isRenderTarget",void 0),A}(function(){function E(A){this._wrapU=R.a.TEXTURE_WRAP_ADDRESSMODE,this._wrapV=R.a.TEXTURE_WRAP_ADDRESSMODE,this.wrapR=R.a.TEXTURE_WRAP_ADDRESSMODE,this.anisotropicFilteringLevel=4,this.delayLoadState=R.a.DELAYLOADSTATE_NONE,this._texture=null,this._engine=null,this._cachedSize=m.a.Zero(),this._cachedBaseSize=m.a.Zero(),this._texture=A,this._texture&&(this._engine=this._texture.getEngine())}return Object.defineProperty(E.prototype,"wrapU",{get:function(){return this._wrapU},set:function(A){this._wrapU=A}
826,enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"wrapV",{get:function(){return this._wrapV},set:function(A){this._wrapV=A},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"coordinatesMode",{get:function(){return 0},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"isCube",{get:function(){return!!this._texture&&this._texture.isCube},set:function(A){this._texture&&(this._texture.isCube=A)},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"is3D",{get:function(){return!!this._texture&&this._texture.is3D},set:function(A){this._texture&&(this._texture.is3D=A)},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"is2DArray",{get:function(){return!!this._texture&&this._texture.is2DArray},set:function(A){this._texture&&(this._texture.is2DArray=A)},enumerable:!1,configurable:!0}),E.prototype.getClassName=function(){return"ThinTexture"},E.prototype.isReady=function(){return this.delayLoadState===R.a.DELAYLOADSTATE_NOTLOADED?(this.delayLoad(),!1):!!this._texture&&this._texture.isReady},E.prototype.delayLoad=function(){},E.prototype.getInternalTexture=function(){return this._texture},E.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},E.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)},E.prototype.updateSamplingMode=function(A){this._texture&&this._engine&&this._engine.updateTextureSamplingMode(A,this._texture)},E.prototype.releaseInternalTexture=function(){this._texture&&(this._texture.dispose(),this._texture=null)},E.prototype.dispose=function(){this._texture&&(this.releaseInternalTexture(),this._engine=null)},E}())},function(Ae,v,f){f.d(v,"a",function(){return C});var B=f(0),_=f(9),x=f(7),u=f(16),M=f(20),R=f(23);u.a.CreateCylinder=function(m){var c=m.height||2,E=m.diameterTop===0?0:m.diameterTop||m.diameter||1,A=m.diameterBottom===0?0:m.diameterBottom||m.diameter||1;E=E||1e-5,A=A||1e-5;var S,g=m.tessellation||24,l=m.subdivisions||1,h=!!m.hasRings,b=!!m.enclose,T=m.cap===0?0:m.cap||x.a.CAP_ALL,D=m.arc&&(m.arc<=0||m.arc>1)?1:m.arc||1,w=m.sideOrientation===0?0:m.sideOrientation||u.a.DEFAULTSIDE,N=m.faceUV||new Array(3),I=m.faceColors,V=2+(1+(D!==1&&b?2:0))*(h?l:1);for(S=0;S<V;S++)I&&I[S]===void 0&&(I[S]=new _.b(1,1,1,1));for(S=0;S<V;S++)N&&N[S]===void 0&&(N[S]=new B.f(0,0,1,1));var W,j,ne,te,de,pe,ae=new Array,ee=new Array,K=new Array,$=new Array,L=new Array,G=2*Math.PI*D/g,Q=(A-E)/2/c,oe=B.e.Zero(),re=B.e.Zero(),Y=B.e.Zero(),k=B.e.Zero(),H=B.e.Zero(),Z=R.a.Y,X=1,q=1,he=0,ge=0;for(te=0;te<=l;te++)for(ne=((j=te/l)*(E-A)+A)/2,X=h&&te!==0&&te!==l?2:1,pe=0;pe<X;pe++){for(h&&(q+=pe),b&&(q+=2*pe),de=0;de<=g;de++)W=de*G,oe.x=Math.cos(-W)*ne,oe.y=-c/2+j*c,oe.z=Math.sin(-W)*ne,E===0&&te===l?(re.x=K[K.length-3*(g+1)],re.y=K[K.length-3*(g+1)+1],re.z=K[K.length-3*(g+1)+2]):(re.x=oe.x,re.z=oe.z,re.y=Math.sqrt(re.x*re.x+re.z*re.z)*Q,re.normalize()),de===0&&(Y.copyFrom(oe),k.copyFrom(re)),ee.push(oe.x,oe.y,oe.z),K.push(re.x,re.y,re.z),ge=h?he!==q?N[q].y:N[q].w:N[q].y+(N[q].w-N[q].y)*j,$.push(N[q].x+(N[q].z-N[q].x)*de/g,ge),I&&L.push(I[q].r,I[q].g,I[q].b,I[q].a);D!==1&&b&&(ee.push(oe.x,oe.y,oe.z),ee.push(0,oe.y,0),ee.push(0,oe.y,0),ee.push(Y.x,Y.y,Y.z),B.e.CrossToRef(Z,re,H),H.normalize(),K.push(H.x,H.y,H.z,H.x,H.y,H.z),B.e.CrossToRef(k,Z,H),H.normalize(),K.push(H.x,H.y,H.z,H.x,H.y,H.z),ge=h?he!==q?N[q+1].y:N[q+1].w:N[q+1].y+(N[q+1].w-N[q+1].y)*j,$.push(N[q+1].x,ge),$.push(N[q+1].z,ge),ge=h?he!==q?N[q+2].y:N[q+2].w:N[q+2].y+(N[q+2].w-N[q+2].y)*j,$.push(N[q+2].x,ge),$.push(N[q+2].z,ge),I&&(L.push(I[q+1].r,I[q+1].g,I[q+1].b,I[q+1].a),L.push(I[q+1].r,I[q+1].g,I[q+1].b,I[q+1].a),L.push(I[q+2].r,I[q+2].g,I[q+2].b,I[q+2].a),L.push(I[q+2].r,I[q+2].g,I[q+2].b,I[q+2].a))),he!==q&&(he=q)}var me=D!==1&&b?g+4:g;for(te=0,q=0;q<l;q++){var _e=0,be=0,Ce=0,ye=0;for(de=0;de<g;de++)_e=te*(me+1)+de,be=(te+1)*(me+1)+de,Ce=te*(me+1)+(de+1),ye=(te+1)*(me+1)+(de+1),ae.push(_e,be,Ce),ae.push(ye,Ce,be);D!==1&&b&&(ae.push(_e+2,be+2,Ce+2),ae.push(ye+2,Ce+2,be+2),ae.push(_e+4,be+4,Ce+4),ae.push(ye+4,Ce+4,be+4)),te=h?te+2:te+1}var Be=function(Xe){var He=Xe?E/2:A/2;if(He!==0){var We,Ze,ze,it=Xe?N[V-1]:N[0],et=null;I&&(et=Xe?I[V-1]:I[0]);var lt=ee.length/3,ct=Xe?c/2:-c/2,mt=new B.e(0,ct,0);ee.push(mt.x,mt.y,mt.z),K.push(0,Xe?1:-1,0),$.push(it.x+.5*(it.z-it.x),it.y+.5*(it.w-it.y)),et&&L.push(et.r,et.g,et.b,et.a);
826var St=new B.d(.5,.5);for(ze=0;ze<=g;ze++){We=2*Math.PI*ze*D/g;var wt=Math.cos(-We),It=Math.sin(-We);Ze=new B.e(wt*He,ct,It*He);var Pt=new B.d(wt*St.x+.5,It*St.y+.5);ee.push(Ze.x,Ze.y,Ze.z),K.push(0,Xe?1:-1,0),$.push(it.x+(it.z-it.x)*Pt.x,it.y+(it.w-it.y)*Pt.y),et&&L.push(et.r,et.g,et.b,et.a)}for(ze=0;ze<g;ze++)Xe?(ae.push(lt),ae.push(lt+(ze+2)),ae.push(lt+(ze+1))):(ae.push(lt),ae.push(lt+(ze+1)),ae.push(lt+(ze+2)))}};T!==x.a.CAP_START&&T!==x.a.CAP_ALL||Be(!1),T!==x.a.CAP_END&&T!==x.a.CAP_ALL||Be(!0),u.a._ComputeSides(w,ee,ae,K,$,m.frontUVs,m.backUVs);var Ge=new u.a;return Ge.indices=ae,Ge.positions=ee,Ge.normals=K,Ge.uvs=$,I&&(Ge.colors=L),Ge},x.a.CreateCylinder=function(m,c,E,A,S,g,l,h,b){l!==void 0&&l instanceof M.a||(l!==void 0&&(b=h||x.a.DEFAULTSIDE,h=l),l=g,g=1);var T={height:c,diameterTop:E,diameterBottom:A,tessellation:S,subdivisions:g,sideOrientation:b,updatable:h};return C.CreateCylinder(m,T,l)};var C=function(){function m(){}return m.CreateCylinder=function(c,E,A){var S=new x.a(c,A);return E.sideOrientation=x.a._GetDefaultSideOrientation(E.sideOrientation),S._originalBuilderSideOrientation=E.sideOrientation,u.a.CreateCylinder(E).applyToMesh(S,E.updatable),S},m}()},function(Ae,v,f){f.d(v,"a",function(){return x});var B=f(0),_=f(4),x=function(){function u(){this._pickingUnavailable=!1,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.originMesh=null,this.ray=null}return u.prototype.getNormal=function(M,R){if(M===void 0&&(M=!1),R===void 0&&(R=!0),!this.pickedMesh||!this.pickedMesh.isVerticesDataPresent(_.b.NormalKind))return null;var C,m=this.pickedMesh.getIndices();if(!m)return null;if(R){var c=this.pickedMesh.getVerticesData(_.b.NormalKind),E=B.e.FromArray(c,3*m[3*this.faceId]),A=B.e.FromArray(c,3*m[3*this.faceId+1]),S=B.e.FromArray(c,3*m[3*this.faceId+2]);E=E.scale(this.bu),A=A.scale(this.bv),S=S.scale(1-this.bu-this.bv),C=new B.e(E.x+A.x+S.x,E.y+A.y+S.y,E.z+A.z+S.z)}else{var g=this.pickedMesh.getVerticesData(_.b.PositionKind),l=B.e.FromArray(g,3*m[3*this.faceId]),h=B.e.FromArray(g,3*m[3*this.faceId+1]),b=B.e.FromArray(g,3*m[3*this.faceId+2]),T=l.subtract(h),D=b.subtract(h);C=B.e.Cross(T,D)}if(M){var w=this.pickedMesh.getWorldMatrix();this.pickedMesh.nonUniformScaling&&(B.c.Matrix[0].copyFrom(w),(w=B.c.Matrix[0]).setTranslationFromFloats(0,0,0),w.invert(),w.transposeToRef(B.c.Matrix[1]),w=B.c.Matrix[1]),C=B.e.TransformNormal(C,w)}return C.normalize(),C},u.prototype.getTextureCoordinates=function(){if(!this.pickedMesh||!this.pickedMesh.isVerticesDataPresent(_.b.UVKind))return null;var M=this.pickedMesh.getIndices();if(!M)return null;var R=this.pickedMesh.getVerticesData(_.b.UVKind);if(!R)return null;var C=B.d.FromArray(R,2*M[3*this.faceId]),m=B.d.FromArray(R,2*M[3*this.faceId+1]),c=B.d.FromArray(R,2*M[3*this.faceId+2]);return C=C.scale(this.bu),m=m.scale(this.bv),c=c.scale(1-this.bu-this.bv),new B.d(C.x+m.x+c.x,C.y+m.y+c.y)},u}()},function(Ae,v,f){f.d(v,"a",function(){return _});var B=f(57),_=function(){function x(){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(x.prototype,"min",{get:function(){return this._min},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"max",{get:function(){return this._max},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"average",{get:function(){return this._average},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"lastSecAverage",{get:function(){return this._lastSecAverage},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"current",{get:function(){return this._current},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"total",{get:function(){return this._totalAccumulated},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"count",{get:function(){return this._totalValueCount}
826,enumerable:!1,configurable:!0}),x.prototype.fetchNewFrame=function(){this._totalValueCount++,this._current=0,this._lastSecValueCount++},x.prototype.addCount=function(u,M){x.Enabled&&(this._current+=u,M&&this._fetchResult())},x.prototype.beginMonitoring=function(){x.Enabled&&(this._startMonitoringTime=B.a.Now)},x.prototype.endMonitoring=function(u){if(u===void 0&&(u=!0),x.Enabled){u&&this.fetchNewFrame();var M=B.a.Now;this._current=M-this._startMonitoringTime,u&&this._fetchResult()}},x.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 u=B.a.Now;u-this._lastSecTime>1e3&&(this._lastSecAverage=this._lastSecAccumulated/this._lastSecValueCount,this._lastSecTime=u,this._lastSecAccumulated=0,this._lastSecValueCount=0)},x.Enabled=!0,x}()},function(Ae,v,f){f.d(v,"b",function(){return A}),f.d(v,"d",function(){return S}),f.d(v,"c",function(){return g}),f.d(v,"a",function(){return l});var B=f(1),_=f(49),x=f(38),u=f(6),M=f(83),R=f(140),C=function(h){function b(){return h!==null&&h.apply(this,arguments)||this}return Object(B.d)(b,h),b._setPrototypeOf=Object.setPrototypeOf||function(T,D){return T.__proto__=D,T},b}(Error),m=f(34),c=f(26),E=f(128),A=function(h){function b(T,D){var w=h.call(this,T)||this;return w.name="LoadFileError",C._setPrototypeOf(w,b.prototype),D instanceof _.a?w.request=D:w.file=D,w}return Object(B.d)(b,h),b}(C),S=function(h){function b(T,D){var w=h.call(this,T)||this;return w.request=D,w.name="RequestFileError",C._setPrototypeOf(w,b.prototype),w}return Object(B.d)(b,h),b}(C),g=function(h){function b(T,D){var w=h.call(this,T)||this;return w.file=D,w.name="ReadFileError",C._setPrototypeOf(w,b.prototype),w}return Object(B.d)(b,h),b}(C),l=function(){function h(){}return h._CleanUrl=function(b){return b=b.replace(/#/gm,"%23")},h.SetCorsBehavior=function(b,T){if((!b||b.indexOf("data:")!==0)&&h.CorsBehavior)if(typeof h.CorsBehavior=="string"||this.CorsBehavior instanceof String)T.crossOrigin=h.CorsBehavior;else{var D=h.CorsBehavior(b);D&&(T.crossOrigin=D)}},h.LoadImage=function(b,T,D,w,N){var I;N===void 0&&(N="");var V=!1;if(b instanceof ArrayBuffer||ArrayBuffer.isView(b)?typeof Blob<"u"?(I=URL.createObjectURL(new Blob([b],{type:N})),V=!0):I="data:"+N+";base64,"+m.a.EncodeArrayBufferToBase64(b):b instanceof Blob?(I=URL.createObjectURL(b),V=!0):(I=h._CleanUrl(b),I=h.PreprocessUrl(b)),typeof Image>"u")return h.LoadFile(I,function(ae){createImageBitmap(new Blob([ae],{type:N})).then(function(ee){T(ee),V&&URL.revokeObjectURL(I)}).catch(function(ee){D&&D("Error while trying to load image: "+b,ee)})},void 0,w||void 0,!0,function(ae,ee){D&&D("Error while trying to load image: "+b,ee)}),null;var W=new Image;h.SetCorsBehavior(I,W);var j=function(){W.removeEventListener("load",j),W.removeEventListener("error",ne),T(W),V&&W.src&&URL.revokeObjectURL(W.src)},ne=function(ae){if(W.removeEventListener("load",j),W.removeEventListener("error",ne),D){var ee=b.toString();D("Error while trying to load image: "+(ee.length<32?ee:ee.slice(0,32)+"..."),ae)}V&&W.src&&URL.revokeObjectURL(W.src)};W.addEventListener("load",j),W.addEventListener("error",ne);var te=function(){W.src=I};if(I.substr(0,5)!=="data:"&&w&&w.enableTexturesOffline)w.open(function(){w&&w.loadImage(I,W)},te);else{if(I.indexOf("file:")!==-1){var de=decodeURIComponent(I.substring(5).toLowerCase());if(M.a.FilesToLoad[de]){try{var pe;try{pe=URL.createObjectURL(M.a.FilesToLoad[de])}catch{pe=URL.createObjectURL(M.a.FilesToLoad[de])}W.src=pe,V=!0}catch{W.src=""}return W}}te()}return W},h.ReadFile=function(b,T,D,w,N){var I=new FileReader,V={onCompleteObservable:new u.c,abort:function(){return I.abort()}};return I.onloadend=function(W){return V.onCompleteObservable.notifyObservers(V)},N&&(I.onerror=function(W){N(new g("Unable to read "+b.name,b))}),I.onload=function(W){T(W.target.result)},D&&(I.onprogress=D),w?I.readAsArrayBuffer(b):I.readAsText(b),V},h.LoadFile=function(b,T,D,w,N,I){if(b.indexOf("file:")!==-1){var V=decodeURIComponent(b.substring(5).toLowerCase());V.indexOf("./")===0&&(V=V.substring(2));var W=M.a.FilesToLoad[V];if(W)return h.ReadFile(W,T,D,N,I?function(j){return I(void 0,new A(j.message,j.file))}:void 0)}return h.RequestFile(b,function(j,ne){T(j,ne?ne.responseURL:void 0)},D,w,N,I?function(j){I(j.request,new A(j.message,j.request))}:void 0)},h.RequestFile=function(b,T,D,w,N,I,V){b=h._CleanUrl(b),b=h.PreprocessUrl(b);var W=h.BaseUrl+b,j=!1,ne={onCompleteObservable:new u.c,abort:function(){return j=!0}},te=function(){var pe=new _.a,ae=null;ne.abort=function(){j=!0,pe.readyState!==(XMLHttpRequest.DONE||4)&&pe.abort(),ae!==null&&(clearTimeout(ae),ae=null)};var ee=function(K){pe.open("GET",W),V&&V(pe),N&&(pe.responseType="arraybuffer"),D&&pe.addEventListener("progress",D);var $=function(){pe.removeEventListener("loadend",$),ne.onCompleteObservable.notifyObservers(ne),ne.onCompleteObservable.clear()};pe.addEventListener("loadend",$);var L=function(){if(!j&&pe.readyState===(XMLHttpRequest.DONE||4)){if(pe.removeEventListener("readystatechange",L),pe.status>=200&&pe.status<300||pe.status===0&&(!x.a.IsWindowObjectExist()||h.IsFileURL()))return void T(N?pe.response:pe.responseText,pe);var G=h.DefaultRetryStrategy;if(G){var Q=G(W,pe,K);if(Q!==-1)return pe.removeEventListener("loadend",$),pe=new _.a,void(ae=setTimeout(function(){return ee(K+1)},Q))}var oe=new S("Error status: "+pe.status+" "+pe.statusText+" - Unable to load "+W,pe);I&&I(oe)}};pe.addEventListener("readystatechange",L),pe.send()};ee(0)};if(w&&w.enableSceneOffline){var de=function(pe){pe&&pe.status>400?I&&I(pe):te()};w.open(function(){w&&w.loadFile(h.BaseUrl+b,function(pe){j||T(pe),ne.onCompleteObservable.notifyObservers(ne)},D?function(pe){j||D(pe)}:void 0,de,N)},de)}else te();return ne},h.IsFileURL=function(){return typeof location<"u"&&location.protocol==="file:"},h.DefaultRetryStrategy=R.a.ExponentialBackoff(),h.BaseUrl="",h.CorsBehavior="anonymous",h.PreprocessUrl=function(b){return b},h}();c.a._FileToolsLoadImage=l.LoadImage.bind(l),c.a._FileToolsLoadFile=l.LoadFile.bind(l),E.a._FileToolsLoadFile=l.LoadFile.bind(l)},function(Ae,v,f){f.d(v,"a",function(){return _});var B=f(38),_=function(){function x(){}return Object.defineProperty(x,"Now",{get:function(){return B.a.IsWindowObjectExist()&&window.performance&&window.performance.now?window.performance.now():Date.now()}
826,enumerable:!1,configurable:!0}),x}()},function(Ae,v,f){f.d(v,"a",function(){return B});var B=function(){function _(x,u,M,R){this.x=x,this.y=u,this.width=M,this.height=R}return _.prototype.toGlobal=function(x,u){return new _(this.x*x,this.y*u,this.width*x,this.height*u)},_.prototype.toGlobalToRef=function(x,u,M){return M.x=this.x*x,M.y=this.y*u,M.width=this.width*x,M.height=this.height*u,this},_.prototype.clone=function(){return new _(this.x,this.y,this.width,this.height)},_}()},function(Ae,v,f){var B="helperFunctions",_=`const float PI=3.1415926535897932384626433832795;
827const float HALF_MIN=5.96046448e-08;
828const float LinearEncodePowerApprox=2.2;
829const float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;
830const vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);
831const float Epsilon=0.0000001;
832#define saturate(x) clamp(x,0.0,1.0)
833#define absEps(x) abs(x)+Epsilon
834#define maxEps(x) max(x,Epsilon)
835#define saturateEps(x) clamp(x,Epsilon,1.0)
836mat3 transposeMat3(mat3 inMatrix) {
837vec3 i0=inMatrix[0];
838vec3 i1=inMatrix[1];
839vec3 i2=inMatrix[2];
840mat3 outMatrix=mat3(
841vec3(i0.x,i1.x,i2.x),
842vec3(i0.y,i1.y,i2.y),
843vec3(i0.z,i1.z,i2.z)
844);
845return outMatrix;
846}
847
848mat3 inverseMat3(mat3 inMatrix) {
849float a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];
850float a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];
851float a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];
852float b01=a22*a11-a12*a21;
853float b11=-a22*a10+a12*a20;
854float b21=a21*a10-a11*a20;
855float det=a00*b01+a01*b11+a02*b21;
856return mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),
857b11,(a22*a00-a02*a20),(-a12*a00+a02*a10),
858b21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;
859}
860float toLinearSpace(float color)
861{
862return pow(color,LinearEncodePowerApprox);
863}
864vec3 toLinearSpace(vec3 color)
865{
866return pow(color,vec3(LinearEncodePowerApprox));
867}
868vec4 toLinearSpace(vec4 color)
869{
870return vec4(pow(color.rgb,vec3(LinearEncodePowerApprox)),color.a);
871}
872vec3 toGammaSpace(vec3 color)
873{
874return pow(color,vec3(GammaEncodePowerApprox));
875}
876vec4 toGammaSpace(vec4 color)
877{
878return vec4(pow(color.rgb,vec3(GammaEncodePowerApprox)),color.a);
879}
880float toGammaSpace(float color)
881{
882return pow(color,GammaEncodePowerApprox);
883}
884float square(float value)
885{
886return value*value;
887}
888float pow5(float value) {
889float sq=value*value;
890return sq*sq*value;
891}
892float getLuminance(vec3 color)
893{
894return clamp(dot(color,LuminanceEncodeApprox),0.,1.);
895}
896
897float getRand(vec2 seed) {
898return fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);
899}
900float dither(vec2 seed,float varianceAmount) {
901float rand=getRand(seed);
902float dither=mix(-varianceAmount/255.0,varianceAmount/255.0,rand);
903return dither;
904}
905
906const float rgbdMaxRange=255.0;
907vec4 toRGBD(vec3 color) {
908float maxRGB=maxEps(max(color.r,max(color.g,color.b)));
909float D=max(rgbdMaxRange/maxRGB,1.);
910D=clamp(floor(D)/255.0,0.,1.);
911
912vec3 rgb=color.rgb*D;
913
914rgb=toGammaSpace(rgb);
915return vec4(rgb,D);
916}
917vec3 fromRGBD(vec4 rgbd) {
918
919rgbd.rgb=toLinearSpace(rgbd.rgb);
920
921return rgbd.rgb/rgbd.a;
922}
923`;f(5).a.IncludesShadersStore[B]=_},function(Ae,v,f){f.d(v,"a",function(){return _});var B=f(0),_=function(){function x(){}return x._RemoveAndStorePivotPoint=function(u){u&&x._PivotCached===0&&(u.getPivotPointToRef(x._OldPivotPoint),x._PivotPostMultiplyPivotMatrix=u._postMultiplyPivotMatrix,x._OldPivotPoint.equalsToFloats(0,0,0)||(u.setPivotMatrix(B.a.IdentityReadOnly),x._OldPivotPoint.subtractToRef(u.getPivotPoint(),x._PivotTranslation),x._PivotTmpVector.copyFromFloats(1,1,1),x._PivotTmpVector.subtractInPlace(u.scaling),x._PivotTmpVector.multiplyInPlace(x._PivotTranslation),u.position.addInPlace(x._PivotTmpVector))),x._PivotCached++},x._RestorePivotPoint=function(u){u&&!x._OldPivotPoint.equalsToFloats(0,0,0)&&x._PivotCached===1&&(u.setPivotPoint(x._OldPivotPoint),u._postMultiplyPivotMatrix=x._PivotPostMultiplyPivotMatrix,x._PivotTmpVector.copyFromFloats(1,1,1),x._PivotTmpVector.subtractInPlace(u.scaling),x._PivotTmpVector.multiplyInPlace(x._PivotTranslation),u.position.subtractInPlace(x._PivotTmpVector)),this._PivotCached--},x._PivotCached=0,x._OldPivotPoint=new B.e,x._PivotTranslation=new B.e,x._PivotTmpVector=new B.e,x._PivotPostMultiplyPivotMatrix=!1,x}()},function(Ae,v,f){f.d(v,"a",function(){return R});var B=f(4),_=f(114),x=f(43),u=f(2),M=f(101),R=function(){function C(m,c,E,A,S,g,l,h,b){h===void 0&&(h=!0),b===void 0&&(b=!0),this.materialIndex=m,this.verticesStart=c,this.verticesCount=E,this.indexStart=A,this.indexCount=S,this._materialDefines=null,this._materialEffect=null,this._effectOverride=null,this._linesIndexCount=0,this._linesIndexBuffer=null,this._lastColliderWorldVertices=null,this._lastColliderTransformMatrix=null,this._renderId=0,this._alphaIndex=0,this._distanceToCamera=0,this._currentMaterial=null,this._mesh=g,this._renderingMesh=l||g,b&&g.subMeshes.push(this),this._trianglePlanes=[],this._id=g.subMeshes.length-1,h&&(this.refreshBoundingInfo(),g.computeWorldMatrix(!0))}return Object.defineProperty(C.prototype,"materialDefines",{get:function(){return this._materialDefines},set:function(m){this._materialDefines=m}
923,enumerable:!1,configurable:!0}),Object.defineProperty(C.prototype,"effect",{get:function(){var m;return(m=this._effectOverride)!==null&&m!==void 0?m:this._materialEffect},enumerable:!1,configurable:!0}),C.prototype.setEffect=function(m,c){c===void 0&&(c=null),this._materialEffect!==m?(this._materialDefines=c,this._materialEffect=m):m||(this._materialDefines=null)},C.AddToMesh=function(m,c,E,A,S,g,l,h){return h===void 0&&(h=!0),new C(m,c,E,A,S,g,l,h)},Object.defineProperty(C.prototype,"IsGlobal",{get:function(){return this.verticesStart===0&&this.verticesCount===this._mesh.getTotalVertices()},enumerable:!1,configurable:!0}),C.prototype.getBoundingInfo=function(){return this.IsGlobal?this._mesh.getBoundingInfo():this._boundingInfo},C.prototype.setBoundingInfo=function(m){return this._boundingInfo=m,this},C.prototype.getMesh=function(){return this._mesh},C.prototype.getRenderingMesh=function(){return this._renderingMesh},C.prototype.getReplacementMesh=function(){return this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:null},C.prototype.getEffectiveMesh=function(){var m=this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:null;return m||this._renderingMesh},C.prototype.getMaterial=function(){var m=this._renderingMesh.material;if(m==null)return this._mesh.getScene().defaultMaterial;if(this._IsMultiMaterial(m)){var c=m.getSubMaterial(this.materialIndex);return this._currentMaterial!==c&&(this._currentMaterial=c,this._materialDefines=null),c}return m},C.prototype._IsMultiMaterial=function(m){return m.getSubMaterial!==void 0},C.prototype.refreshBoundingInfo=function(m){if(m===void 0&&(m=null),this._lastColliderWorldVertices=null,this.IsGlobal||!this._renderingMesh||!this._renderingMesh.geometry)return this;if(m||(m=this._renderingMesh.getVerticesData(B.b.PositionKind)),!m)return this._boundingInfo=this._mesh.getBoundingInfo(),this;var c,E=this._renderingMesh.getIndices();if(this.indexStart===0&&this.indexCount===E.length){var A=this._renderingMesh.getBoundingInfo();c={minimum:A.minimum.clone(),maximum:A.maximum.clone()}}else c=Object(M.b)(m,E,this.indexStart,this.indexCount,this._renderingMesh.geometry.boundingBias);return this._boundingInfo?this._boundingInfo.reConstruct(c.minimum,c.maximum):this._boundingInfo=new x.a(c.minimum,c.maximum),this},C.prototype._checkCollision=function(m){return this.getBoundingInfo()._checkCollision(m)},C.prototype.updateBoundingInfo=function(m){var c=this.getBoundingInfo();return c||(this.refreshBoundingInfo(),c=this.getBoundingInfo()),c&&c.update(m),this},C.prototype.isInFrustum=function(m){var c=this.getBoundingInfo();return!!c&&c.isInFrustum(m,this._mesh.cullingStrategy)},C.prototype.isCompletelyInFrustum=function(m){var c=this.getBoundingInfo();return!!c&&c.isCompletelyInFrustum(m)},C.prototype.render=function(m){return this._renderingMesh.render(this,m,this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:void 0),this},C.prototype._getLinesIndexBuffer=function(m,c){if(!this._linesIndexBuffer){for(var E=[],A=this.indexStart;A<this.indexStart+this.indexCount;A+=3)E.push(m[A],m[A+1],m[A+1],m[A+2],m[A+2],m[A]);this._linesIndexBuffer=c.createIndexBuffer(E),this._linesIndexCount=E.length}return this._linesIndexBuffer},C.prototype.canIntersects=function(m){var c=this.getBoundingInfo();return!!c&&m.intersectsBox(c.boundingBox)},C.prototype.intersects=function(m,c,E,A,S){var g=this.getMaterial();if(!g)return null;var l=3,h=!1;switch(g.fillMode){case u.a.MATERIAL_PointListDrawMode:case u.a.MATERIAL_LineListDrawMode:case u.a.MATERIAL_LineLoopDrawMode:case u.a.MATERIAL_LineStripDrawMode:case u.a.MATERIAL_TriangleFanDrawMode:return null;case u.a.MATERIAL_TriangleStripDrawMode:l=1,h=!0}return this._mesh.getClassName()==="InstancedLinesMesh"||this._mesh.getClassName()==="LinesMesh"?E.length?this._intersectLines(m,c,E,this._mesh.intersectionThreshold,A):this._intersectUnIndexedLines(m,c,E,this._mesh.intersectionThreshold,A):!E.length&&this._mesh._unIndexed?this._intersectUnIndexedTriangles(m,c,E,A,S):this._intersectTriangles(m,c,E,l,h,A,S)},C.prototype._intersectLines=function(m,c,E,A,S){for(var g=null,l=this.indexStart;l<this.indexStart+this.indexCount;l+=2){var h=c[E[l]],b=c[E[l+1]],T=m.intersectionSegment(h,b,A);if(!(T<0)&&(S||!g||T<g.distance)&&((g=new _.a(null,null,T)).faceId=l/2,S))break}return g},C.prototype._intersectUnIndexedLines=function(m,c,E,A,S){for(var g=null,l=this.verticesStart;l<this.verticesStart+this.verticesCount;l+=2){var h=c[l],b=c[l+1],T=m.intersectionSegment(h,b,A);if(!(T<0)&&(S||!g||T<g.distance)&&((g=new _.a(null,null,T)).faceId=l/2,S))break}return g},C.prototype._intersectTriangles=function(m,c,E,A,S,g,l){for(var h=null,b=-1,T=this.indexStart;T<this.indexStart+this.indexCount;T+=A){b++;var D=E[T],w=E[T+1],N=E[T+2];if(S&&N===4294967295)T+=2;else{var I=c[D],V=c[w],W=c[N];if(!l||l(I,V,W,m)){var j=m.intersectsTriangle(I,V,W);if(j){if(j.distance<0)continue;if((g||!h||j.distance<h.distance)&&((h=j).faceId=b,g))break}}}}return h},C.prototype._intersectUnIndexedTriangles=function(m,c,E,A,S){for(var g=null,l=this.verticesStart;l<this.verticesStart+this.verticesCount;l+=3){var h=c[l],b=c[l+1],T=c[l+2];if(!S||S(h,b,T,m)){var D=m.intersectsTriangle(h,b,T);if(D){if(D.distance<0)continue;if((A||!g||D.distance<g.distance)&&((g=D).faceId=l/3,A))break}}}return g},C.prototype._rebuild=function(){this._linesIndexBuffer&&(this._linesIndexBuffer=null)},C.prototype.clone=function(m,c){var E=new C(this.materialIndex,this.verticesStart,this.verticesCount,this.indexStart,this.indexCount,m,c,!1);if(!this.IsGlobal){var A=this.getBoundingInfo();if(!A)return E;E._boundingInfo=new x.a(A.minimum,A.maximum)}return E},C.prototype.dispose=function(){this._linesIndexBuffer&&(this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer),this._linesIndexBuffer=null);var m=this._mesh.subMeshes.indexOf(this);this._mesh.subMeshes.splice(m,1)},C.prototype.getClassName=function(){return"SubMesh"},C.CreateFromIndices=function(m,c,E,A,S){for(var g=Number.MAX_VALUE,l=-Number.MAX_VALUE,h=(S||A).getIndices(),b=c;b<c+E;b++){var T=h[b];T<g&&(g=T),T>l&&(l=T)}return new C(m,g,l-g+1,c,E,A,S)},C}()},function(Ae,v,f){f.d(v,"a",function(){return R});var B=f(1),_=f(8),x=f(10),u=f(2),M=(f(126),f(70)),R=function(C){function m(c,E,A,S,g,l,h){A===void 0&&(A=null),g===void 0&&(g=u.a.TEXTURE_TRILINEAR_SAMPLINGMODE),l===void 0&&(l=u.a.TEXTUREFORMAT_RGBA);
923var b=C.call(this,null,A,!S,h,g,void 0,void 0,void 0,void 0,l)||this;b.name=c,b.wrapU=x.a.CLAMP_ADDRESSMODE,b.wrapV=x.a.CLAMP_ADDRESSMODE,b._generateMipMaps=S;var T=b._getEngine();if(!T)return b;E.getContext?(b._canvas=E,b._texture=T.createDynamicTexture(E.width,E.height,S,g)):(b._canvas=M.a.CreateCanvas(1,1),E.width||E.width===0?b._texture=T.createDynamicTexture(E.width,E.height,S,g):b._texture=T.createDynamicTexture(E,E,S,g));var D=b.getSize();return b._canvas.width=D.width,b._canvas.height=D.height,b._context=b._canvas.getContext("2d"),b}return Object(B.d)(m,C),m.prototype.getClassName=function(){return"DynamicTexture"},Object.defineProperty(m.prototype,"canRescale",{get:function(){return!0},enumerable:!1,configurable:!0}),m.prototype._recreate=function(c){this._canvas.width=c.width,this._canvas.height=c.height,this.releaseInternalTexture(),this._texture=this._getEngine().createDynamicTexture(c.width,c.height,this._generateMipMaps,this.samplingMode)},m.prototype.scale=function(c){var E=this.getSize();E.width*=c,E.height*=c,this._recreate(E)},m.prototype.scaleTo=function(c,E){var A=this.getSize();A.width=c,A.height=E,this._recreate(A)},m.prototype.getContext=function(){return this._context},m.prototype.clear=function(){var c=this.getSize();this._context.fillRect(0,0,c.width,c.height)},m.prototype.update=function(c,E){E===void 0&&(E=!1),this._getEngine().updateDynamicTexture(this._texture,this._canvas,c===void 0||c,E,this._format||void 0)},m.prototype.drawText=function(c,E,A,S,g,l,h,b){b===void 0&&(b=!0);var T=this.getSize();if(l&&(this._context.fillStyle=l,this._context.fillRect(0,0,T.width,T.height)),this._context.font=S,E==null){var D=this._context.measureText(c);E=(T.width-D.width)/2}if(A==null){var w=parseInt(S.replace(/\D/g,""));A=T.height/2+w/3.65}this._context.fillStyle=g||"",this._context.fillText(c,E,A),b&&this.update(h)},m.prototype.clone=function(){var c=this.getScene();if(!c)return this;var E=this.getSize(),A=new m(this.name,E,c,this._generateMipMaps);return A.hasAlpha=this.hasAlpha,A.level=this.level,A.wrapU=this.wrapU,A.wrapV=this.wrapV,A},m.prototype.serialize=function(){var c=this.getScene();c&&!c.isReady()&&_.a.Warn("The scene must be ready before serializing the dynamic texture");var E=C.prototype.serialize.call(this);return this._IsCanvasElement(this._canvas)&&(E.base64String=this._canvas.toDataURL()),E.invertY=this._invertY,E.samplingMode=this.samplingMode,E},m.prototype._IsCanvasElement=function(c){return c.toDataURL!==void 0},m.prototype._rebuild=function(){this.update()},m}(x.a)},function(Ae,v,f){f.d(v,"a",function(){return M});var B=f(0),_=f(9),x=f(7),u=f(16);u.a.CreateBox=function(R){var C,m=[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23],c=[0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0],E=[],A=R.width||R.size||1,S=R.height||R.size||1,g=R.depth||R.size||1,l=R.wrap||!1,h=R.topBaseAt===void 0?1:R.topBaseAt,b=R.bottomBaseAt===void 0?0:R.bottomBaseAt,T=[2,0,3,1][h=(h+4)%4],D=[2,0,1,3][b=(b+4)%4],w=[1,-1,1,-1,-1,1,-1,1,1,1,1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,1,-1,1,-1,-1,1,-1,1,1,1,1,-1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,1,-1,1,-1,1,1,-1,1,1,1,1,-1,1,1,-1,-1,-1,-1,-1,-1,-1,1];if(l){m=[2,3,0,2,0,1,4,5,6,4,6,7,9,10,11,9,11,8,12,14,15,12,13,14],w=[-1,1,1,1,1,1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,1,1,1,1,-1,1,-1,-1,1,-1,1,-1,1,-1,-1,1,1,-1,-1,1,-1,-1,-1];for(var N=[[1,1,1],[-1,1,1],[-1,1,-1],[1,1,-1]],I=[[-1,-1,1],[1,-1,1],[1,-1,-1],[-1,-1,-1]],V=[17,18,19,16],W=[22,23,20,21];T>0;)N.unshift(N.pop()),V.unshift(V.pop()),T--;for(;D>0;)I.unshift(I.pop()),W.unshift(W.pop()),D--;N=N.flat(),I=I.flat(),w=w.concat(N).concat(I),m.push(V[0],V[2],V[3],V[0],V[1],V[2]),m.push(W[0],W[2],W[3],W[0],W[1],W[2])}var j=[A/2,S/2,g/2];C=w.reduce(function(G,Q,oe){return G.concat(Q*j[oe%3])},[]);for(var ne=R.sideOrientation===0?0:R.sideOrientation||u.a.DEFAULTSIDE,te=R.faceUV||new Array(6),de=R.faceColors,pe=[],ae=0;ae<6;ae++)te[ae]===void 0&&(te[ae]=new B.f(0,0,1,1)),de&&de[ae]===void 0&&(de[ae]=new _.b(1,1,1,1));for(var ee=0;ee<6;ee++)if(E.push(te[ee].z,te[ee].w),E.push(te[ee].x,te[ee].w),E.push(te[ee].x,te[ee].y),E.push(te[ee].z,te[ee].y),de)for(var K=0;K<4;K++)pe.push(de[ee].r,de[ee].g,de[ee].b,de[ee].a);u.a._ComputeSides(ne,C,m,c,E,R.frontUVs,R.backUVs);var $=new u.a;if($.indices=m,$.positions=C,$.normals=c,$.uvs=E,de){var L=ne===u.a.DOUBLESIDE?pe.concat(pe):pe;$.colors=L}return $},x.a.CreateBox=function(R,C,m,c,E){m===void 0&&(m=null);var A={size:C,sideOrientation:E,updatable:c};return M.CreateBox(R,A,m)};var M=function(){function R(){}return R.CreateBox=function(C,m,c){c===void 0&&(c=null);var E=new x.a(C,c);return m.sideOrientation=x.a._GetDefaultSideOrientation(m.sideOrientation),E._originalBuilderSideOrientation=m.sideOrientation,u.a.CreateBox(m).applyToMesh(E,m.updatable),E},R}()},function(Ae,v,f){f.d(v,"a",function(){return _});var B=f(0),_=function(){function x(u,M,R,C){this.normal=new B.e(u,M,R),this.d=C}return x.prototype.asArray=function(){return[this.normal.x,this.normal.y,this.normal.z,this.d]},x.prototype.clone=function(){return new x(this.normal.x,this.normal.y,this.normal.z,this.d)},x.prototype.getClassName=function(){return"Plane"},x.prototype.getHashCode=function(){var u=this.normal.getHashCode();return u=397*u^(0|this.d)},x.prototype.normalize=function(){var u=Math.sqrt(this.normal.x*this.normal.x+this.normal.y*this.normal.y+this.normal.z*this.normal.z),M=0;return u!==0&&(M=1/u),this.normal.x*=M,this.normal.y*=M,this.normal.z*=M,this.d*=M,this},x.prototype.transform=function(u){var M=x._TmpMatrix;u.invertToRef(M);var R=M.m,C=this.normal.x,m=this.normal.y,c=this.normal.z,E=this.d;return new x(C*R[0]+m*R[1]+c*R[2]+E*R[3],C*R[4]+m*R[5]+c*R[6]+E*R[7],C*R[8]+m*R[9]+c*R[10]+E*R[11],C*R[12]+m*R[13]+c*R[14]+E*R[
92315])},x.prototype.dotCoordinate=function(u){return this.normal.x*u.x+this.normal.y*u.y+this.normal.z*u.z+this.d},x.prototype.copyFromPoints=function(u,M,R){var C,m=M.x-u.x,c=M.y-u.y,E=M.z-u.z,A=R.x-u.x,S=R.y-u.y,g=R.z-u.z,l=c*g-E*S,h=E*A-m*g,b=m*S-c*A,T=Math.sqrt(l*l+h*h+b*b);return C=T!==0?1/T:0,this.normal.x=l*C,this.normal.y=h*C,this.normal.z=b*C,this.d=-(this.normal.x*u.x+this.normal.y*u.y+this.normal.z*u.z),this},x.prototype.isFrontFacingTo=function(u,M){return B.e.Dot(this.normal,u)<=M},x.prototype.signedDistanceTo=function(u){return B.e.Dot(u,this.normal)+this.d},x.FromArray=function(u){return new x(u[0],u[1],u[2],u[3])},x.FromPoints=function(u,M,R){var C=new x(0,0,0,0);return C.copyFromPoints(u,M,R),C},x.FromPositionAndNormal=function(u,M){var R=new x(0,0,0,0);return M.normalize(),R.normal=M,R.d=-(M.x*u.x+M.y*u.y+M.z*u.z),R},x.SignedDistanceToPlaneFromPositionAndNormal=function(u,M,R){var C=-(M.x*u.x+M.y*u.y+M.z*u.z);return B.e.Dot(R,M)+C},x._TmpMatrix=B.a.Identity(),x}()},function(Ae,v,f){f.d(v,"a",function(){return m});var B=f(7),_=f(20),x=f(6),u=f(0),M=f(18),R=f(39),C=f(60),m=(f(84),function(){function c(E){this._useAlternatePickedPointAboveMaxDragAngleDragSpeed=-1.1,this.maxDragAngle=0,this._useAlternatePickedPointAboveMaxDragAngle=!1,this.currentDraggingPointerID=-1,this.dragging=!1,this.dragDeltaRatio=.2,this.updateDragPlane=!0,this._debugMode=!1,this._moving=!1,this.onDragObservable=new x.c,this.onDragStartObservable=new x.c,this.onDragEndObservable=new x.c,this.moveAttached=!0,this.enabled=!0,this.startAndReleaseDragOnPointerEvents=!0,this.detachCameraControls=!0,this.useObjectOrientationForDragging=!0,this.validateDrag=function(S){return!0},this._tmpVector=new u.e(0,0,0),this._alternatePickedPoint=new u.e(0,0,0),this._worldDragAxis=new u.e(0,0,0),this._targetPosition=new u.e(0,0,0),this._attachedToElement=!1,this._startDragRay=new R.a(new u.e,new u.e),this._lastPointerRay={},this._dragDelta=new u.e,this._pointA=new u.e(0,0,0),this._pointC=new u.e(0,0,0),this._localAxis=new u.e(0,0,0),this._lookAt=new u.e(0,0,0),this._options=E||{};var A=0;if(this._options.dragAxis&&A++,this._options.dragPlaneNormal&&A++,A>1)throw"Multiple drag modes specified in dragBehavior options. Only one expected"}return Object.defineProperty(c.prototype,"options",{get:function(){return this._options},set:function(E){this._options=E},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"name",{get:function(){return"PointerDrag"},enumerable:!1,configurable:!0}),c.prototype.init=function(){},c.prototype.attach=function(E,A){var S=this;this._scene=E.getScene(),this.attachedNode=E,c._planeScene||(this._debugMode?c._planeScene=this._scene:(c._planeScene=new _.a(this._scene.getEngine(),{virtual:!0}),c._planeScene.detachControl(),this._scene.onDisposeObservable.addOnce(function(){c._planeScene.dispose(),c._planeScene=null}))),this._dragPlane=B.a.CreatePlane("pointerDragPlane",this._debugMode?1:1e4,c._planeScene,!1,B.a.DOUBLESIDE),this.lastDragPosition=new u.e(0,0,0);var g=A||function(l){return S.attachedNode==l||l.isDescendantOf(S.attachedNode)};this._pointerObserver=this._scene.onPointerObservable.add(function(l,h){if(S.enabled){if(l.type==M.a.POINTERDOWN)S.startAndReleaseDragOnPointerEvents&&!S.dragging&&l.pickInfo&&l.pickInfo.hit&&l.pickInfo.pickedMesh&&l.pickInfo.pickedPoint&&l.pickInfo.ray&&g(l.pickInfo.pickedMesh)&&S._startDrag(l.event.pointerId,l.pickInfo.ray,l.pickInfo.pickedPoint);else if(l.type==M.a.POINTERUP)S.startAndReleaseDragOnPointerEvents&&S.currentDraggingPointerID==l.event.pointerId&&S.releaseDrag();else if(l.type==M.a.POINTERMOVE){var b=l.event.pointerId;if(S.currentDraggingPointerID===c._AnyMouseID&&b!==c._AnyMouseID){var T=l.event;(T.pointerType==="mouse"||!S._scene.getEngine().hostInformation.isMobile&&T instanceof MouseEvent)&&(S._lastPointerRay[S.currentDraggingPointerID]&&(S._lastPointerRay[b]=S._lastPointerRay[S.currentDraggingPointerID],delete S._lastPointerRay[S.currentDraggingPointerID]),S.currentDraggingPointerID=b)}S._lastPointerRay[b]||(S._lastPointerRay[b]=new R.a(new u.e,new u.e)),l.pickInfo&&l.pickInfo.ray&&(S._lastPointerRay[b].origin.copyFrom(l.pickInfo.ray.origin),S._lastPointerRay[b].direction.copyFrom(l.pickInfo.ray.direction),S.currentDraggingPointerID==b&&S.dragging&&S._moveDrag(l.pickInfo.ray))}}}),this._beforeRenderObserver=this._scene.onBeforeRenderObservable.add(function(){S._moving&&S.moveAttached&&(C.a._RemoveAndStorePivotPoint(S.attachedNode),S._targetPosition.subtractToRef(S.attachedNode.absolutePosition,S._tmpVector),S._tmpVector.scaleInPlace(S.dragDeltaRatio),S.attachedNode.getAbsolutePosition().addToRef(S._tmpVector,S._tmpVector),S.validateDrag(S._tmpVector)&&S.attachedNode.setAbsolutePosition(S._tmpVector),C.a._RestorePivotPoint(S.attachedNode))})},c.prototype.releaseDrag=function(){if(this.dragging&&(this.dragging=!1,this.onDragEndObservable.notifyObservers({dragPlanePoint:this.lastDragPosition,pointerId:this.currentDraggingPointerID})),this.currentDraggingPointerID=-1,this._moving=!1,this.detachCameraControls&&this._attachedToElement&&this._scene.activeCamera&&!this._scene.activeCamera.leftCamera){
923if(this._scene.activeCamera.getClassName()==="ArcRotateCamera"){var E=this._scene.activeCamera;E.attachControl(!E.inputs||E.inputs.noPreventDefault,E._useCtrlForPanning,E._panningMouseButton)}else this._scene.activeCamera.attachControl(!this._scene.activeCamera.inputs||this._scene.activeCamera.inputs.noPreventDefault);this._attachedToElement=!1}},c.prototype.startDrag=function(E,A,S){E===void 0&&(E=c._AnyMouseID),this._startDrag(E,A,S);var g=this._lastPointerRay[E];E===c._AnyMouseID&&(g=this._lastPointerRay[Object.keys(this._lastPointerRay)[0]]),g&&this._moveDrag(g)},c.prototype._startDrag=function(E,A,S){if(this._scene.activeCamera&&!this.dragging&&this.attachedNode){C.a._RemoveAndStorePivotPoint(this.attachedNode),A?(this._startDragRay.direction.copyFrom(A.direction),this._startDragRay.origin.copyFrom(A.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,S||this._tmpVector);var g=this._pickWithRayOnDragPlane(this._startDragRay);g&&(this.dragging=!0,this.currentDraggingPointerID=E,this.lastDragPosition.copyFrom(g),this.onDragStartObservable.notifyObservers({dragPlanePoint:g,pointerId:this.currentDraggingPointerID}),this._targetPosition.copyFrom(this.attachedNode.absolutePosition),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)),C.a._RestorePivotPoint(this.attachedNode)}},c.prototype._moveDrag=function(E){this._moving=!0;var A=this._pickWithRayOnDragPlane(E);if(A){this.updateDragPlane&&this._updateDragPlanePosition(E,A);var S=0;this._options.dragAxis?(this.useObjectOrientationForDragging?u.e.TransformCoordinatesToRef(this._options.dragAxis,this.attachedNode.getWorldMatrix().getRotationMatrix(),this._worldDragAxis):this._worldDragAxis.copyFrom(this._options.dragAxis),A.subtractToRef(this.lastDragPosition,this._tmpVector),S=u.e.Dot(this._tmpVector,this._worldDragAxis),this._worldDragAxis.scaleToRef(S,this._dragDelta)):(S=this._dragDelta.length(),A.subtractToRef(this.lastDragPosition,this._dragDelta)),this._targetPosition.addInPlace(this._dragDelta),this.onDragObservable.notifyObservers({dragDistance:S,delta:this._dragDelta,dragPlanePoint:A,dragPlaneNormal:this._dragPlane.forward,pointerId:this.currentDraggingPointerID}),this.lastDragPosition.copyFrom(A)}},c.prototype._pickWithRayOnDragPlane=function(E){var A=this;if(!E)return null;var S=Math.acos(u.e.Dot(this._dragPlane.forward,E.direction));if(S>Math.PI/2&&(S=Math.PI-S),this.maxDragAngle>0&&S>this.maxDragAngle){if(this._useAlternatePickedPointAboveMaxDragAngle){this._tmpVector.copyFrom(E.direction),this.attachedNode.absolutePosition.subtractToRef(E.origin,this._alternatePickedPoint),this._alternatePickedPoint.normalize(),this._alternatePickedPoint.scaleInPlace(this._useAlternatePickedPointAboveMaxDragAngleDragSpeed*u.e.Dot(this._alternatePickedPoint,this._tmpVector)),this._tmpVector.addInPlace(this._alternatePickedPoint);var g=u.e.Dot(this._dragPlane.forward,this._tmpVector);return this._dragPlane.forward.scaleToRef(-g,this._alternatePickedPoint),this._alternatePickedPoint.addInPlace(this._tmpVector),this._alternatePickedPoint.addInPlace(this.attachedNode.absolutePosition),this._alternatePickedPoint}return null}var l=c._planeScene.pickWithRay(E,function(h){return h==A._dragPlane});return l&&l.hit&&l.pickedMesh&&l.pickedPoint?l.pickedPoint:null},c.prototype._updateDragPlanePosition=function(E,A){this._pointA.copyFrom(A),this._options.dragAxis?(this.useObjectOrientationForDragging?u.e.TransformCoordinatesToRef(this._options.dragAxis,this.attachedNode.getWorldMatrix().getRotationMatrix(),this._localAxis):this._localAxis.copyFrom(this._options.dragAxis),E.origin.subtractToRef(this._pointA,this._pointC),this._pointC.normalize(),Math.abs(u.e.Dot(this._localAxis,this._pointC))>.999?Math.abs(u.e.Dot(u.e.UpReadOnly,this._pointC))>.999?this._lookAt.copyFrom(u.e.Right()):this._lookAt.copyFrom(u.e.UpReadOnly):(u.e.CrossToRef(this._localAxis,this._pointC,this._lookAt),u.e.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?u.e.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(E.origin)),this._dragPlane.position.copyFrom(this.attachedNode.absolutePosition),this._dragPlane.computeWorldMatrix(!0)},c.prototype.detach=function(){this._pointerObserver&&this._scene.onPointerObservable.remove(this._pointerObserver),this._beforeRenderObserver&&this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver),this.releaseDrag()},c._AnyMouseID=-2,c}())},function(Ae,v,f){f.d(v,"a",function(){return _}),f.d(v,"b",function(){return x}),f.d(v,"c",function(){return u});var B=f(1),_=function(){function M(){}return M.KEYDOWN=1,M.KEYUP=2,M}(),x=function(M,R){this.type=M,this.event=R},u=function(M){function R(C,m){var c=M.call(this,C,m)||this;
923return c.type=C,c.event=m,c.skipOnPointerObservable=!1,c}return Object(B.d)(R,M),R}(x)},function(Ae,v,f){f.d(v,"a",function(){return B});var B=function(){function _(){this._defines={},this._currentRank=32,this._maxRank=-1,this._mesh=null}return _.prototype.unBindMesh=function(){this._mesh=null},_.prototype.addFallback=function(x,u){this._defines[x]||(x<this._currentRank&&(this._currentRank=x),x>this._maxRank&&(this._maxRank=x),this._defines[x]=new Array),this._defines[x].push(u)},_.prototype.addCPUSkinningFallback=function(x,u){this._mesh=u,x<this._currentRank&&(this._currentRank=x),x>this._maxRank&&(this._maxRank=x)},Object.defineProperty(_.prototype,"hasMoreFallbacks",{get:function(){return this._currentRank<=this._maxRank},enumerable:!1,configurable:!0}),_.prototype.reduce=function(x,u){if(this._mesh&&this._mesh.computeBonesUsingShaders&&this._mesh.numBoneInfluencers>0){this._mesh.computeBonesUsingShaders=!1,x=x.replace("#define NUM_BONE_INFLUENCERS "+this._mesh.numBoneInfluencers,"#define NUM_BONE_INFLUENCERS 0"),u._bonesComputationForcedToCPU=!0;for(var M=this._mesh.getScene(),R=0;R<M.meshes.length;R++){var C=M.meshes[R];if(C.material){if(C.computeBonesUsingShaders&&C.numBoneInfluencers!==0){if(C.material.getEffect()===u)C.computeBonesUsingShaders=!1;else if(C.subMeshes){for(var m=0,c=C.subMeshes;m<c.length;m++)if(c[m].effect===u){C.computeBonesUsingShaders=!1;break}}}}else!this._mesh.material&&C.computeBonesUsingShaders&&C.numBoneInfluencers>0&&(C.computeBonesUsingShaders=!1)}}else{var E=this._defines[this._currentRank];if(E)for(R=0;R<E.length;R++)x=x.replace("#define "+E[R],"");this._currentRank++}return x},_}()},function(Ae,v,f){f.d(v,"a",function(){return M});var B=f(1),_=f(25),x=f(37),u=f(11),M=function(R){function C(m,c){var E=R.call(this,m,c,!0)||this;return c.multiMaterials.push(E),E.subMaterials=new Array,E._storeEffectOnSubMeshes=!0,E}return Object(B.d)(C,R),Object.defineProperty(C.prototype,"subMaterials",{get:function(){return this._subMaterials},set:function(m){this._subMaterials=m,this._hookArray(m)},enumerable:!1,configurable:!0}),C.prototype.getChildren=function(){return this.subMaterials},C.prototype._hookArray=function(m){var c=this,E=m.push;m.push=function(){for(var S=[],g=0;g<arguments.length;g++)S[g]=arguments[g];var l=E.apply(m,S);return c._markAllSubMeshesAsTexturesDirty(),l};var A=m.splice;m.splice=function(S,g){var l=A.apply(m,[S,g]);return c._markAllSubMeshesAsTexturesDirty(),l}},C.prototype.getSubMaterial=function(m){return m<0||m>=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[m]},C.prototype.getActiveTextures=function(){var m;return(m=R.prototype.getActiveTextures.call(this)).concat.apply(m,this.subMaterials.map(function(c){return c?c.getActiveTextures():[]}))},C.prototype.hasTexture=function(m){var c;if(R.prototype.hasTexture.call(this,m))return!0;for(var E=0;E<this.subMaterials.length;E++)if(!((c=this.subMaterials[E])===null||c===void 0)&&c.hasTexture(m))return!0;return!1},C.prototype.getClassName=function(){return"MultiMaterial"},C.prototype.isReadyForSubMesh=function(m,c,E){for(var A=0;A<this.subMaterials.length;A++){var S=this.subMaterials[A];if(S){if(S._storeEffectOnSubMeshes){if(!S.isReadyForSubMesh(m,c,E))return!1;continue}if(!S.isReady(m))return!1}}return!0},C.prototype.clone=function(m,c){for(var E=new C(m,this.getScene()),A=0;A<this.subMaterials.length;A++){var S=null,g=this.subMaterials[A];S=c&&g?g.clone(m+"-"+g.name):this.subMaterials[A],E.subMaterials.push(S)}return E},C.prototype.serialize=function(){var m={};m.name=this.name,m.id=this.id,x.a&&(m.tags=x.a.GetTags(this)),m.materials=[];for(var c=0;c<this.subMaterials.length;c++){var E=this.subMaterials[c];E?m.materials.push(E.id):m.materials.push(null)}return m},C.prototype.dispose=function(m,c,E){var A=this.getScene();if(A){if(E)for(var S=0;S<this.subMaterials.length;S++){var g=this.subMaterials[S];g&&g.dispose(m,c)}(S=A.multiMaterials.indexOf(this))>=0&&A.multiMaterials.splice(S,1),R.prototype.dispose.call(this,m,c)}},C.ParseMultiMaterial=function(m,c){var E=new C(m.name,c);E.id=m.id,x.a&&x.a.AddTagsTo(E,m.tags);for(var A=0;A<m.materials.length;A++){var S=m.materials[A];S?E.subMaterials.push(c.getLastMaterialByID(S)):E.subMaterials.push(null)}return E},C}(_.a);u.a.RegisteredTypes["BABYLON.MultiMaterial"]=M},function(Ae,v,f){f.d(v,"a",function(){return _});var B=f(2),_=function(){function x(){}return Object.defineProperty(x,"ForceFullSceneLoadingForIncremental",{get:function(){return x._ForceFullSceneLoadingForIncremental},set:function(u){x._ForceFullSceneLoadingForIncremental=u}
923,enumerable:!1,configurable:!0}),Object.defineProperty(x,"ShowLoadingScreen",{get:function(){return x._ShowLoadingScreen},set:function(u){x._ShowLoadingScreen=u},enumerable:!1,configurable:!0}),Object.defineProperty(x,"loggingLevel",{get:function(){return x._loggingLevel},set:function(u){x._loggingLevel=u},enumerable:!1,configurable:!0}),Object.defineProperty(x,"CleanBoneMatrixWeights",{get:function(){return x._CleanBoneMatrixWeights},set:function(u){x._CleanBoneMatrixWeights=u},enumerable:!1,configurable:!0}),x._ForceFullSceneLoadingForIncremental=!1,x._ShowLoadingScreen=!0,x._CleanBoneMatrixWeights=!1,x._loggingLevel=B.a.SCENELOADER_NO_LOGGING,x}()},function(Ae,v,f){f.d(v,"a",function(){return B});var B=function(){function _(){}return _.CreateCanvas=function(x,u){if(typeof document>"u")return new OffscreenCanvas(x,u);var M=document.createElement("canvas");return M.width=x,M.height=u,M},_}()},function(Ae,v,f){f.d(v,"a",function(){return S});var B=f(0),_=f(9),x=f(16),u=f(4),M=f(61),R=f(69),C=f(43),m=f(2),c=f(12),E=f(37),A=f(101),S=function(){function g(l,h,b,T,D){T===void 0&&(T=!1),D===void 0&&(D=null),this.delayLoadState=m.a.DELAYLOADSTATE_NONE,this._totalVertices=0,this._isDisposed=!1,this._indexBufferIsUpdatable=!1,this._positionsCache=[],this.useBoundingInfoFromGeometry=!1,this.id=l,this.uniqueId=h.getUniqueId(),this._engine=h.getEngine(),this._meshes=[],this._scene=h,this._vertexBuffers={},this._indices=[],this._updatable=T,b?this.setAllVerticesData(b,T):(this._totalVertices=0,this._indices=[]),this._engine.getCaps().vertexArrayObject&&(this._vertexArrayObjects={}),D&&(this.applyToMesh(D),D.computeWorldMatrix(!0))}return Object.defineProperty(g.prototype,"boundingBias",{get:function(){return this._boundingBias},set:function(l){this._boundingBias?this._boundingBias.copyFrom(l):this._boundingBias=l.clone(),this._updateBoundingInfo(!0,null)},enumerable:!1,configurable:!0}),g.CreateGeometryForMesh=function(l){var h=new g(g.RandomId(),l.getScene());return h.applyToMesh(l),h},Object.defineProperty(g.prototype,"meshes",{get:function(){return this._meshes},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"extend",{get:function(){return this._extend},enumerable:!1,configurable:!0}),g.prototype.getScene=function(){return this._scene},g.prototype.getEngine=function(){return this._engine},g.prototype.isReady=function(){return this.delayLoadState===m.a.DELAYLOADSTATE_LOADED||this.delayLoadState===m.a.DELAYLOADSTATE_NONE},Object.defineProperty(g.prototype,"doNotSerialize",{get:function(){for(var l=0;l<this._meshes.length;l++)if(!this._meshes[l].doNotSerialize)return!1;return!0},enumerable:!1,configurable:!0}),g.prototype._rebuild=function(){for(var l in this._vertexArrayObjects&&(this._vertexArrayObjects={}),this._meshes.length!==0&&this._indices&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices)),this._vertexBuffers)this._vertexBuffers[l]._rebuild()},g.prototype.setAllVerticesData=function(l,h){l.applyToGeometry(this,h),this.notifyUpdate()},g.prototype.setVerticesData=function(l,h,b,T){b===void 0&&(b=!1),b&&Array.isArray(h)&&(h=new Float32Array(h));var D=new u.b(this._engine,h,l,b,this._meshes.length===0,T);this.setVerticesBuffer(D)},g.prototype.removeVerticesData=function(l){this._vertexBuffers[l]&&(this._vertexBuffers[l].dispose(),delete this._vertexBuffers[l])},g.prototype.setVerticesBuffer=function(l,h){h===void 0&&(h=null);var b=l.getKind();if(this._vertexBuffers[b]&&this._vertexBuffers[b].dispose(),this._vertexBuffers[b]=l,b===u.b.PositionKind){var T=l.getData();h!=null?this._totalVertices=h:T!=null&&(this._totalVertices=T.length/(l.byteStride/4)),this._updateExtend(T),this._resetPointsArrayCache();for(var D=this._meshes,w=D.length,N=0;N<w;N++){var I=D[N];I._boundingInfo=new C.a(this._extend.minimum,this._extend.maximum),I._createGlobalSubMesh(!1),I.computeWorldMatrix(!0)}}this.notifyUpdate(b),this._vertexArrayObjects&&(this._disposeVertexArrayObjects(),this._vertexArrayObjects={})},g.prototype.updateVerticesDataDirectly=function(l,h,b,T){T===void 0&&(T=!1);var D=this.getVertexBuffer(l);D&&(D.updateDirectly(h,b,T),this.notifyUpdate(l))},g.prototype.updateVerticesData=function(l,h,b){b===void 0&&(b=!1);var T=this.getVertexBuffer(l);T&&(T.update(h),l===u.b.PositionKind&&this._updateBoundingInfo(b,h),this.notifyUpdate(l))},g.prototype._updateBoundingInfo=function(l,h){if(l&&this._updateExtend(h),this._resetPointsArrayCache(),l)for(var b=0,T=this._meshes;b<T.length;b++){var D=T[b];
923D._boundingInfo?D._boundingInfo.reConstruct(this._extend.minimum,this._extend.maximum):D._boundingInfo=new C.a(this._extend.minimum,this._extend.maximum);for(var w=0,N=D.subMeshes;w<N.length;w++)N[w].refreshBoundingInfo()}},g.prototype._bind=function(l,h){if(l){h===void 0&&(h=this._indexBuffer);var b=this.getVertexBuffers();b&&(h==this._indexBuffer&&this._vertexArrayObjects?(this._vertexArrayObjects[l.key]||(this._vertexArrayObjects[l.key]=this._engine.recordVertexArrayObject(b,h,l)),this._engine.bindVertexArrayObject(this._vertexArrayObjects[l.key],h)):this._engine.bindBuffers(b,h,l))}},g.prototype.getTotalVertices=function(){return this.isReady()?this._totalVertices:0},g.prototype.getVerticesData=function(l,h,b){var T=this.getVertexBuffer(l);if(!T)return null;var D=T.getData();if(!D)return null;var w=T.getSize()*u.b.GetTypeByteLength(T.type),N=this._totalVertices*T.getSize();if(T.type!==u.b.FLOAT||T.byteStride!==w){var I=[];return T.forEach(N,function(te){return I.push(te)}),I}if(!(D instanceof Array||D instanceof Float32Array)||T.byteOffset!==0||D.length!==N){if(D instanceof Array){var V=T.byteOffset/4;return c.b.Slice(D,V,V+N)}if(D instanceof ArrayBuffer)return new Float32Array(D,T.byteOffset,N);if(V=D.byteOffset+T.byteOffset,b||h&&this._meshes.length!==1){var W=new Float32Array(N),j=new Float32Array(D.buffer,V,N);return W.set(j),W}var ne=V%4;return ne&&(V=Math.max(0,V-ne)),new Float32Array(D.buffer,V,N)}return b||h&&this._meshes.length!==1?c.b.Slice(D):D},g.prototype.isVertexBufferUpdatable=function(l){var h=this._vertexBuffers[l];return!!h&&h.isUpdatable()},g.prototype.getVertexBuffer=function(l){return this.isReady()?this._vertexBuffers[l]:null},g.prototype.getVertexBuffers=function(){return this.isReady()?this._vertexBuffers:null},g.prototype.isVerticesDataPresent=function(l){return this._vertexBuffers?this._vertexBuffers[l]!==void 0:!!this._delayInfo&&this._delayInfo.indexOf(l)!==-1},g.prototype.getVerticesDataKinds=function(){var l,h=[];if(!this._vertexBuffers&&this._delayInfo)for(l in this._delayInfo)h.push(l);else for(l in this._vertexBuffers)h.push(l);return h},g.prototype.updateIndices=function(l,h,b){if(b===void 0&&(b=!1),this._indexBuffer)if(this._indexBufferIsUpdatable){var T=l.length!==this._indices.length;if(b||(this._indices=l.slice()),this._engine.updateDynamicIndexBuffer(this._indexBuffer,l,h),T)for(var D=0,w=this._meshes;D<w.length;D++)w[D]._createGlobalSubMesh(!0)}else this.setIndices(l,null,!0)},g.prototype.setIndices=function(l,h,b){h===void 0&&(h=null),b===void 0&&(b=!1),this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer),this._disposeVertexArrayObjects(),this._indices=l,this._indexBufferIsUpdatable=b,this._meshes.length!==0&&this._indices&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices,b)),h!=null&&(this._totalVertices=h);for(var T=0,D=this._meshes;T<D.length;T++)D[T]._createGlobalSubMesh(!0);this.notifyUpdate()},g.prototype.getTotalIndices=function(){return this.isReady()?this._indices.length:0},g.prototype.getIndices=function(l,h){if(!this.isReady())return null;var b=this._indices;if(h||l&&this._meshes.length!==1){for(var T=b.length,D=[],w=0;w<T;w++)D.push(b[w]);return D}return b},g.prototype.getIndexBuffer=function(){return this.isReady()?this._indexBuffer:null},g.prototype._releaseVertexArrayObject=function(l){l===void 0&&(l=null),l&&this._vertexArrayObjects&&this._vertexArrayObjects[l.key]&&(this._engine.releaseVertexArrayObject(this._vertexArrayObjects[l.key]),delete this._vertexArrayObjects[l.key])},g.prototype.releaseForMesh=function(l,h){var b=this._meshes,T=b.indexOf(l);T!==-1&&(b.splice(T,1),l._geometry=null,b.length===0&&h&&this.dispose())},g.prototype.applyToMesh=function(l){if(l._geometry!==this){var h=l._geometry;h&&h.releaseForMesh(l);var b=this._meshes;l._geometry=this,this._scene.pushGeometry(this),b.push(l),this.isReady()?this._applyToMesh(l):l._boundingInfo=this._boundingInfo}},g.prototype._updateExtend=function(l){l===void 0&&(l=null),this.useBoundingInfoFromGeometry&&this._boundingInfo?this._extend={minimum:this._boundingInfo.minimum.clone(),maximum:this._boundingInfo.maximum.clone()}:(l||(l=this.getVerticesData(u.b.PositionKind)),this._extend=Object(A.a)(l,0,this._totalVertices,this.boundingBias,3))},g.prototype._applyToMesh=function(l){var h=this._meshes.length;for(var b in this._vertexBuffers){h===1&&this._vertexBuffers[b].create();var T=this._vertexBuffers[b].getBuffer();T&&(T.references=h),b===u.b.PositionKind&&(this._extend||this._updateExtend(),l._boundingInfo=new C.a(this._extend.minimum,this._extend.maximum),l._createGlobalSubMesh(!1),l._updateBoundingInfo())}h===1&&this._indices&&this._indices.length>0&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices)),this._indexBuffer&&(this._indexBuffer.references=h),l._syncGeometryWithMorphTargetManager(),l.synchronizeInstances()},g.prototype.notifyUpdate=function(l){this.onGeometryUpdated&&this.onGeometryUpdated(this,l);for(var h=0,b=this._meshes;h<b.length;h++)b[h]._markSubMeshesAsAttributesDirty()},g.prototype.load=function(l,h){this.delayLoadState!==m.a.DELAYLOADSTATE_LOADING&&(this.isReady()?h&&h():(this.delayLoadState=m.a.DELAYLOADSTATE_LOADING,this._queueLoad(l,h)))},g.prototype._queueLoad=function(l,h){var b=this;this.delayLoadingFile&&(l._addPendingData(this),l._loadFile(this.delayLoadingFile,function(T){if(b._delayLoadingFunction){b._delayLoadingFunction(JSON.parse(T),b),b.delayLoadState=m.a.DELAYLOADSTATE_LOADED,b._delayInfo=[],l._removePendingData(b);for(var D=b._meshes,w=D.length,N=0;N<w;N++)b._applyToMesh(D[N]);h&&h()}},void 0,!0))},g.prototype.toLeftHanded=function(){var l=this.getIndices(!1);if(l!=null&&l.length>0){for(var h=0;h<l.length;h+=3){var b=l[h+0];l[h+0]=l[h+2],l[h+2]=b}this.setIndices(l)}var T=this.getVerticesData(u.b.PositionKind,!1);if(T!=null&&T.length>0){for(h=0;h<T.length;h+=3)T[h+2]=-T[h+2];this.setVerticesData(u.b.PositionKind,T,!1)}var D=this.getVerticesData(u.b.NormalKind,!1);if(D!=null&&D.length>0){for(h=0;h<D.length;h+=3)D[h+2]=-D[h+2];this.setVerticesData(u.b.NormalKind,D,!1)}},g.prototype._resetPointsArrayCache=function(){this._positions=null},g.prototype._generatePointsArray=function(){if(this._positions)return!0;var l=this.getVerticesData(u.b.PositionKind);if(!l||l.length===0)return!1;for(var h=3*this._positionsCache.length,b=this._positionsCache.length;h<l.length;h+=3,++b)this._positionsCache[b]=B.e.FromArray(l,h);for(h=0,b=0;h<l.length;h+=3,++b)this._positionsCache[b].set(l[0+h],l[1+h],l[2+h]);return this._positionsCache.length=l.length/3,this._positions=this._positionsCache,!0},g.prototype.isDisposed=function(){return this._isDisposed},g.prototype._disposeVertexArrayObjects=function(){if(this._vertexArrayObjects){for(var l in this._vertexArrayObjects)this._engine.releaseVertexArrayObject(this._vertexArrayObjects[l]);this._vertexArrayObjects={}}
923},g.prototype.dispose=function(){var l,h=this._meshes,b=h.length;for(l=0;l<b;l++)this.releaseForMesh(h[l]);for(var T in this._meshes=[],this._disposeVertexArrayObjects(),this._vertexBuffers)this._vertexBuffers[T].dispose();this._vertexBuffers={},this._totalVertices=0,this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer),this._indexBuffer=null,this._indices=[],this.delayLoadState=m.a.DELAYLOADSTATE_NONE,this.delayLoadingFile=null,this._delayLoadingFunction=null,this._delayInfo=[],this._boundingInfo=null,this._scene.removeGeometry(this),this._isDisposed=!0},g.prototype.copy=function(l){var h=new x.a;h.indices=[];var b=this.getIndices();if(b)for(var T=0;T<b.length;T++)h.indices.push(b[T]);var D,w=!1,N=!1;for(D in this._vertexBuffers){var I=this.getVerticesData(D);if(I&&(I instanceof Float32Array?h.set(new Float32Array(I),D):h.set(I.slice(0),D),!N)){var V=this.getVertexBuffer(D);V&&(N=!(w=V.isUpdatable()))}}var W=new g(l,this._scene,h,w);for(D in W.delayLoadState=this.delayLoadState,W.delayLoadingFile=this.delayLoadingFile,W._delayLoadingFunction=this._delayLoadingFunction,this._delayInfo)W._delayInfo=W._delayInfo||[],W._delayInfo.push(D);return W._boundingInfo=new C.a(this._extend.minimum,this._extend.maximum),W},g.prototype.serialize=function(){var l={};return l.id=this.id,l.updatable=this._updatable,E.a&&E.a.HasTags(this)&&(l.tags=E.a.GetTags(this)),l},g.prototype.toNumberArray=function(l){return Array.isArray(l)?l:Array.prototype.slice.call(l)},g.prototype.serializeVerticeData=function(){var l=this.serialize();return this.isVerticesDataPresent(u.b.PositionKind)&&(l.positions=this.toNumberArray(this.getVerticesData(u.b.PositionKind)),this.isVertexBufferUpdatable(u.b.PositionKind)&&(l.positions._updatable=!0)),this.isVerticesDataPresent(u.b.NormalKind)&&(l.normals=this.toNumberArray(this.getVerticesData(u.b.NormalKind)),this.isVertexBufferUpdatable(u.b.NormalKind)&&(l.normals._updatable=!0)),this.isVerticesDataPresent(u.b.TangentKind)&&(l.tangets=this.toNumberArray(this.getVerticesData(u.b.TangentKind)),this.isVertexBufferUpdatable(u.b.TangentKind)&&(l.tangets._updatable=!0)),this.isVerticesDataPresent(u.b.UVKind)&&(l.uvs=this.toNumberArray(this.getVerticesData(u.b.UVKind)),this.isVertexBufferUpdatable(u.b.UVKind)&&(l.uvs._updatable=!0)),this.isVerticesDataPresent(u.b.UV2Kind)&&(l.uv2s=this.toNumberArray(this.getVerticesData(u.b.UV2Kind)),this.isVertexBufferUpdatable(u.b.UV2Kind)&&(l.uv2s._updatable=!0)),this.isVerticesDataPresent(u.b.UV3Kind)&&(l.uv3s=this.toNumberArray(this.getVerticesData(u.b.UV3Kind)),this.isVertexBufferUpdatable(u.b.UV3Kind)&&(l.uv3s._updatable=!0)),this.isVerticesDataPresent(u.b.UV4Kind)&&(l.uv4s=this.toNumberArray(this.getVerticesData(u.b.UV4Kind)),this.isVertexBufferUpdatable(u.b.UV4Kind)&&(l.uv4s._updatable=!0)),this.isVerticesDataPresent(u.b.UV5Kind)&&(l.uv5s=this.toNumberArray(this.getVerticesData(u.b.UV5Kind)),this.isVertexBufferUpdatable(u.b.UV5Kind)&&(l.uv5s._updatable=!0)),this.isVerticesDataPresent(u.b.UV6Kind)&&(l.uv6s=this.toNumberArray(this.getVerticesData(u.b.UV6Kind)),this.isVertexBufferUpdatable(u.b.UV6Kind)&&(l.uv6s._updatable=!0)),this.isVerticesDataPresent(u.b.ColorKind)&&(l.colors=this.toNumberArray(this.getVerticesData(u.b.ColorKind)),this.isVertexBufferUpdatable(u.b.ColorKind)&&(l.colors._updatable=!0)),this.isVerticesDataPresent(u.b.MatricesIndicesKind)&&(l.matricesIndices=this.toNumberArray(this.getVerticesData(u.b.MatricesIndicesKind)),l.matricesIndices._isExpanded=!0,this.isVertexBufferUpdatable(u.b.MatricesIndicesKind)&&(l.matricesIndices._updatable=!0)),this.isVerticesDataPresent(u.b.MatricesWeightsKind)&&(l.matricesWeights=this.toNumberArray(this.getVerticesData(u.b.MatricesWeightsKind)),this.isVertexBufferUpdatable(u.b.MatricesWeightsKind)&&(l.matricesWeights._updatable=!0)),l.indices=this.toNumberArray(this.getIndices()),l},g.ExtractFromMesh=function(l,h){var b=l._geometry;return b?b.copy(h):null},g.RandomId=function(){return c.b.RandomId()},g._ImportGeometry=function(l,h){var b=h.getScene(),T=l.geometryId;if(T){var D=b.getGeometryByID(T);D&&D.applyToMesh(h)}else if(l instanceof ArrayBuffer){var w=h._binaryInfo;if(w.positionsAttrDesc&&w.positionsAttrDesc.count>0){var N=new Float32Array(l,w.positionsAttrDesc.offset,w.positionsAttrDesc.count);h.setVerticesData(u.b.PositionKind,N,!1)}if(w.normalsAttrDesc&&w.normalsAttrDesc.count>0){var I=new Float32Array(l,w.normalsAttrDesc.offset,w.normalsAttrDesc.count);h.setVerticesData(u.b.NormalKind,I,!1)}if(w.tangetsAttrDesc&&w.tangetsAttrDesc.count>0){var V=new Float32Array(l,w.tangetsAttrDesc.offset,w.tangetsAttrDesc.count);h.setVerticesData(u.b.TangentKind,V,!1)}if(w.uvsAttrDesc&&w.uvsAttrDesc.count>0){var W=new Float32Array(l,w.uvsAttrDesc.offset,w.uvsAttrDesc.count);h.setVerticesData(u.b.UVKind,W,!1)}
923if(w.uvs2AttrDesc&&w.uvs2AttrDesc.count>0){var j=new Float32Array(l,w.uvs2AttrDesc.offset,w.uvs2AttrDesc.count);h.setVerticesData(u.b.UV2Kind,j,!1)}if(w.uvs3AttrDesc&&w.uvs3AttrDesc.count>0){var ne=new Float32Array(l,w.uvs3AttrDesc.offset,w.uvs3AttrDesc.count);h.setVerticesData(u.b.UV3Kind,ne,!1)}if(w.uvs4AttrDesc&&w.uvs4AttrDesc.count>0){var te=new Float32Array(l,w.uvs4AttrDesc.offset,w.uvs4AttrDesc.count);h.setVerticesData(u.b.UV4Kind,te,!1)}if(w.uvs5AttrDesc&&w.uvs5AttrDesc.count>0){var de=new Float32Array(l,w.uvs5AttrDesc.offset,w.uvs5AttrDesc.count);h.setVerticesData(u.b.UV5Kind,de,!1)}if(w.uvs6AttrDesc&&w.uvs6AttrDesc.count>0){var pe=new Float32Array(l,w.uvs6AttrDesc.offset,w.uvs6AttrDesc.count);h.setVerticesData(u.b.UV6Kind,pe,!1)}if(w.colorsAttrDesc&&w.colorsAttrDesc.count>0){var ae=new Float32Array(l,w.colorsAttrDesc.offset,w.colorsAttrDesc.count);h.setVerticesData(u.b.ColorKind,ae,!1,w.colorsAttrDesc.stride)}if(w.matricesIndicesAttrDesc&&w.matricesIndicesAttrDesc.count>0){for(var ee=new Int32Array(l,w.matricesIndicesAttrDesc.offset,w.matricesIndicesAttrDesc.count),K=[],$=0;$<ee.length;$++){var L=ee[$];K.push(255&L),K.push((65280&L)>>8),K.push((16711680&L)>>16),K.push(L>>24&255)}h.setVerticesData(u.b.MatricesIndicesKind,K,!1)}if(w.matricesIndicesExtraAttrDesc&&w.matricesIndicesExtraAttrDesc.count>0){for(ee=new Int32Array(l,w.matricesIndicesExtraAttrDesc.offset,w.matricesIndicesExtraAttrDesc.count),K=[],$=0;$<ee.length;$++)L=ee[$],K.push(255&L),K.push((65280&L)>>8),K.push((16711680&L)>>16),K.push(L>>24&255);h.setVerticesData(u.b.MatricesIndicesExtraKind,K,!1)}if(w.matricesWeightsAttrDesc&&w.matricesWeightsAttrDesc.count>0){var G=new Float32Array(l,w.matricesWeightsAttrDesc.offset,w.matricesWeightsAttrDesc.count);h.setVerticesData(u.b.MatricesWeightsKind,G,!1)}if(w.indicesAttrDesc&&w.indicesAttrDesc.count>0){var Q=new Int32Array(l,w.indicesAttrDesc.offset,w.indicesAttrDesc.count);h.setIndices(Q,null)}if(w.subMeshesAttrDesc&&w.subMeshesAttrDesc.count>0){var oe=new Int32Array(l,w.subMeshesAttrDesc.offset,5*w.subMeshesAttrDesc.count);for(h.subMeshes=[],$=0;$<w.subMeshesAttrDesc.count;$++){var re=oe[5*$+0],Y=oe[5*$+1],k=oe[5*$+2],H=oe[5*$+3],Z=oe[5*$+4];M.a.AddToMesh(re,Y,k,H,Z,h)}}}else if(l.positions&&l.normals&&l.indices){if(h.setVerticesData(u.b.PositionKind,l.positions,l.positions._updatable),h.setVerticesData(u.b.NormalKind,l.normals,l.normals._updatable),l.tangents&&h.setVerticesData(u.b.TangentKind,l.tangents,l.tangents._updatable),l.uvs&&h.setVerticesData(u.b.UVKind,l.uvs,l.uvs._updatable),l.uvs2&&h.setVerticesData(u.b.UV2Kind,l.uvs2,l.uvs2._updatable),l.uvs3&&h.setVerticesData(u.b.UV3Kind,l.uvs3,l.uvs3._updatable),l.uvs4&&h.setVerticesData(u.b.UV4Kind,l.uvs4,l.uvs4._updatable),l.uvs5&&h.setVerticesData(u.b.UV5Kind,l.uvs5,l.uvs5._updatable),l.uvs6&&h.setVerticesData(u.b.UV6Kind,l.uvs6,l.uvs6._updatable),l.colors&&h.setVerticesData(u.b.ColorKind,_.b.CheckColors4(l.colors,l.positions.length/3),l.colors._updatable),l.matricesIndices)if(l.matricesIndices._isExpanded)delete l.matricesIndices._isExpanded,h.setVerticesData(u.b.MatricesIndicesKind,l.matricesIndices,l.matricesIndices._updatable);else{for(K=[],$=0;$<l.matricesIndices.length;$++){var X=l.matricesIndices[$];K.push(255&X),K.push((65280&X)>>8),K.push((16711680&X)>>16),K.push(X>>24&255)}h.setVerticesData(u.b.MatricesIndicesKind,K,l.matricesIndices._updatable)}if(l.matricesIndicesExtra)if(l.matricesIndicesExtra._isExpanded)delete l.matricesIndices._isExpanded,h.setVerticesData(u.b.MatricesIndicesExtraKind,l.matricesIndicesExtra,l.matricesIndicesExtra._updatable);else{for(K=[],$=0;$<l.matricesIndicesExtra.length;$++)X=l.matricesIndicesExtra[$],K.push(255&X),K.push((65280&X)>>8),K.push((16711680&X)>>16),K.push(X>>24&255);h.setVerticesData(u.b.MatricesIndicesExtraKind,K,l.matricesIndicesExtra._updatable)}l.matricesWeights&&(g._CleanMatricesWeights(l,h),h.setVerticesData(u.b.MatricesWeightsKind,l.matricesWeights,l.matricesWeights._updatable)),l.matricesWeightsExtra&&h.setVerticesData(u.b.MatricesWeightsExtraKind,l.matricesWeightsExtra,l.matricesWeights._updatable),h.setIndices(l.indices,null)}if(l.subMeshes){h.subMeshes=[];for(var q=0;q<l.subMeshes.length;q++){var he=l.subMeshes[q];M.a.AddToMesh(he.materialIndex,he.verticesStart,he.verticesCount,he.indexStart,he.indexCount,h)}}h._shouldGenerateFlatShading&&(h.convertToFlatShadedMesh(),h._shouldGenerateFlatShading=!1),h.computeWorldMatrix(!0),b.onMeshImportedObservable.notifyObservers(h)},g._CleanMatricesWeights=function(l,h){if(R.a.CleanBoneMatrixWeights){var b=0;if(l.skeletonId>-1){var T=h.getScene().getLastSkeletonByID(l.skeletonId);if(T){b=T.bones.length;for(var D=h.getVerticesData(u.b.MatricesIndicesKind),w=h.getVerticesData(u.b.MatricesIndicesExtraKind),N=l.matricesWeights,I=l.matricesWeightsExtra,V=l.numBoneInfluencer,W=N.length,j=0;j<W;j+=4){for(var ne=0,te=-1,de=0;de<4;de++)ne+=pe=N[j+de],pe<.001&&te<0&&(te=de);if(I)for(de=0;de<4;de++){var pe;ne+=pe=I[j+de],pe<.001&&te<0&&(te=de+4)}if((te<0||te>V-1)&&(te=V-1),ne>.001){var ae=1/ne;for(de=0;de<4;de++)N[j+de]*=ae;if(I)for(de=0;de<4;de++)I[j+de]*=ae}else te>=4?(I[j+te-4]=1-ne,w[j+te-4]=b):(N[j+te]=1-ne,D[j+te]=b)}h.setVerticesData(u.b.MatricesIndicesKind,D),l.matricesWeightsExtra&&h.setVerticesData(u.b.MatricesIndicesExtraKind,w)}}}},g.Parse=function(l,h,b){if(h.getGeometryByID(l.id))return null;var T=new g(l.id,h,void 0,l.updatable);return E.a&&E.a.AddTagsTo(T,l.tags),l.delayLoadingFile?(T.delayLoadState=m.a.DELAYLOADSTATE_NOTLOADED,T.delayLoadingFile=b+l.delayLoadingFile,T._boundingInfo=new C.a(B.e.FromArray(l.boundingBoxMinimum),B.e.FromArray(l.boundingBoxMaximum)),T._delayInfo=[],l.hasUVs&&T._delayInfo.push(u.b.UVKind),l.hasUVs2&&T._delayInfo.push(u.b.UV2Kind),l.hasUVs3&&T._delayInfo.push(u.b.UV3Kind),l.hasUVs4&&T._delayInfo.push(u.b.UV4Kind),l.hasUVs5&&T._delayInfo.push(u.b.UV5Kind),l.hasUVs6&&T._delayInfo.push(u.b.UV6Kind),l.hasColors&&T._delayInfo.push(u.b.ColorKind),l.hasMatricesIndices&&T._delayInfo.push(u.b.MatricesIndicesKind),l.hasMatricesWeights&&T._delayInfo.push(u.b.MatricesWeightsKind),T._delayLoadingFunction=x.a.ImportVertexData):x.a.ImportVertexData(l,T),h.pushGeometry(T,!0),T},g}()},function(Ae,v,f){f.d(v,"e",function(){return B}),f.d(v,"c",function(){return M}),f.d(v,"a",function(){return R}),f.d(v,"b",function(){return C}),f.d(v,"f",function(){return m}),f.d(v,"g",function(){return c}),f.d(v,"d",function(){return E});var B,_=f(14),x=f(0),u=f(28);(function(A){A[A.CW=0]="CW",A[A.CCW=1]="CCW"})(B||(B={}));var M=function(){function A(){}return A.Interpolate=function(S,g,l,h,b){for(var T=1-3*h+3*g,D=3*h-6*g,w=3*g,N=S,I=0;I<5;I++){var V=N*N;N-=(T*(V*N)+D*V+w*N-S)*(1/(3*T*V+2*D*N+w)),N=Math.min(1,Math.max(0,N))}return 3*Math.pow(1-N,2)*N*l+3*(1-N)*Math.pow(N,2)*b+Math.pow(N,3)},A}(),R=function(){function A(S){this._radians=S,this._radians<0&&(this._radians+=2*Math.PI)}return A.prototype.degrees=function(){return 180*this._radians/Math.PI},A.prototype.radians=function(){return this._radians},A.BetweenTwoPoints=function(S,g){var l=g.subtract(S);return new A(Math.atan2(l.y,l.x))},A.FromRadians=function(S){return new A(S)},A.FromDegrees=function(S){return new A(S*Math.PI/180)},A}(),C=function(A,S,g){this.startPoint=A,this.midPoint=S,this.endPoint=g;var l=Math.pow(S.x,2)+Math.pow(S.y,2),h=(Math.pow(A.x,2)+Math.pow(A.y,2)-l)/2,b=(l-Math.pow(g.x,2)-Math.pow(g.y,2))/2,T=(A.x-S.x)*(S.y-g.y)-(S.x-g.x)*(A.y-S.y);this.centerPoint=new x.d((h*(S.y-g.y)-b*(A.y-S.y))/T,((A.x-S.x)*b-(S.x-g.x)*h)/T),this.radius=this.centerPoint.subtract(this.startPoint).length(),this.startAngle=R.BetweenTwoPoints(this.centerPoint,this.startPoint);var D=this.startAngle.degrees(),w=R.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),N=R.BetweenTwoPoints(this.centerPoint,this.endPoint).degrees();w-D>180&&(w-=360),w-D<-180&&(w+=360),N-w>180&&(N-=360),N-w<-180&&(N+=360),this.orientation=w-D<0?B.CW:B.CCW,this.angle=R.FromDegrees(this.orientation===B.CW?D-N:N-D)},m=function(){function A(S,g){this._points=new Array,this._length=0,this.closed=!1,this._points.push(new x.d(S,g))}return A.prototype.addLineTo=function(S,g){if(this.closed)return this;var l=new x.d(S,g),h=this._points[this._points.length-1];return this._points.push(l),this._length+=l.subtract(h).length(),this},A.prototype.addArcTo=function(S,g,l,h,b){if(b===void 0&&(b=36),this.closed)return this;var T=this._points[this._points.length-1],D=new x.d(S,g),w=new x.d(l,h),N=new C(T,D,w),I=N.angle.radians()/b;N.orientation===B.CW&&(I*=-1);for(var V=N.startAngle.radians()+I,W=0;W<b;W++){var j=Math.cos(V)*N.radius+N.centerPoint.x,ne=Math.sin(V)*N.radius+N.centerPoint.y;this.addLineTo(j,ne),V+=I}return this},A.prototype.close=function(){return this.closed=!0,this},A.prototype.length=function(){var S=this._length;if(this.closed){var g=this._points[this._points.length-1];S+=this._points[0].subtract(g).length()}return S},A.prototype.getPoints=function(){return this._points},A.prototype.getPointAtLengthPosition=function(S){if(S<0||S>1)return x.d.Zero();for(var g=S*this.length(),l=0,h=0;h<this._points.length;h++){var b=(h+1)%this._points.length,T=this._points[h],D=this._points[b].subtract(T),w=D.length()+l;if(g>=l&&g<=w){var N=D.normalize(),I=g-l;return new x.d(T.x+N.x*I,T.y+N.y*I)}l=w}return x.d.Zero()},A.StartingAt=function(S,g){return new A(S,g)},A}(),c=function(){function A(S,g,l,h){g===void 0&&(g=null),h===void 0&&(h=!1),this.path=S,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:x.e.Zero(),previousPointArrayIndex:0,position:0,subPosition:0,interpolateReady:!1,interpolationMatrix:x.a.Identity()};for(var b=0;b<S.length;b++)this._curve[b]=S[b].clone();this._raw=l||!1,this._alignTangentsWithPath=h,this._compute(g,h)}return A.prototype.getCurve=function(){return this._curve},A.prototype.getPoints=function(){return this._curve},A.prototype.length=function(){return this._distances[this._distances.length-1]},A.prototype.getTangents=function(){return this._tangents},A.prototype.getNormals=function(){return this._normals},A.prototype.getBinormals=function(){return this._binormals},A.prototype.getDistances=function(){return this._distances},A.prototype.getPointAt=function(S){return this._updatePointAtData(S).point},A.prototype.getTangentAt=function(S,g){return g===void 0&&(g=!1),this._updatePointAtData(S,g),g?x.e.TransformCoordinates(x.e.Forward(),this._pointAtData.interpolationMatrix):this._tangents[this._pointAtData.previousPointArrayIndex]},A.prototype.getNormalAt=function(S,g){return g===void 0&&(g=!1),this._updatePointAtData(S,g),g?x.e.TransformCoordinates(x.e.Right(),this._pointAtData.interpolationMatrix):this._normals[this._pointAtData.previousPointArrayIndex]},A.prototype.getBinormalAt=function(S,g){return g===void 0&&(g=!1),this._updatePointAtData(S,g),g?x.e.TransformCoordinates(x.e.UpReadOnly,this._pointAtData.interpolationMatrix):this._binormals[this._pointAtData.previousPointArrayIndex]},A.prototype.getDistanceAt=function(S){return this.length()*S},A.prototype.getPreviousPointIndexAt=function(S){return this._updatePointAtData(S),this._pointAtData.previousPointArrayIndex},A.prototype.getSubPositionAt=function(S){return this._updatePointAtData(S),this._pointAtData.subPosition},A.prototype.getClosestPositionTo=function(S){for(var g=Number.MAX_VALUE,l=0,h=0;h<this._curve.length-1;h++){var b=this._curve[h+0],T=this._curve[h+1].subtract(b).normalize(),D=this._distances[h+1]-this._distances[h+0],w=Math.min(Math.max(x.e.Dot(T,S.subtract(b).normalize()),0)*x.e.Distance(b,S)/D,1),N=x.e.Distance(b.add(T.scale(w*D)),S);N<g&&(g=N,l=(this._distances[h+0]+D*w)/this.length())}return l},A.prototype.slice=function(S,g){if(S===void 0&&(S=0),g===void 0&&(g=1),S<0&&(S=1- -1*S%1),g<0&&(g=1- -1*g%1),S>g){var l=S;S=g,g=l}
923var h=this.getCurve(),b=this.getPointAt(S),T=this.getPreviousPointIndexAt(S),D=this.getPointAt(g),w=this.getPreviousPointIndexAt(g)+1,N=[];return S!==0&&(T++,N.push(b)),N.push.apply(N,h.slice(T,w)),g===1&&S!==1||N.push(D),new A(N,this.getNormalAt(S),this._raw,this._alignTangentsWithPath)},A.prototype.update=function(S,g,l){g===void 0&&(g=null),l===void 0&&(l=!1);for(var h=0;h<S.length;h++)this._curve[h].x=S[h].x,this._curve[h].y=S[h].y,this._curve[h].z=S[h].z;return this._compute(g,l),this},A.prototype._compute=function(S,g){g===void 0&&(g=!1);var l=this._curve.length;if(!(l<2)){this._tangents[0]=this._getFirstNonNullVector(0),this._raw||this._tangents[0].normalize(),this._tangents[l-1]=this._curve[l-1].subtract(this._curve[l-2]),this._raw||this._tangents[l-1].normalize();var h,b,T,D,w,N=this._tangents[0],I=this._normalVector(N,S);this._normals[0]=I,this._raw||this._normals[0].normalize(),this._binormals[0]=x.e.Cross(N,this._normals[0]),this._raw||this._binormals[0].normalize(),this._distances[0]=0;for(var V=1;V<l;V++)h=this._getLastNonNullVector(V),V<l-1&&(b=this._getFirstNonNullVector(V),this._tangents[V]=g?b:h.add(b),this._tangents[V].normalize()),this._distances[V]=this._distances[V-1]+this._curve[V].subtract(this._curve[V-1]).length(),T=this._tangents[V],w=this._binormals[V-1],this._normals[V]=x.e.Cross(w,T),this._raw||(this._normals[V].length()===0?(D=this._normals[V-1],this._normals[V]=D.clone()):this._normals[V].normalize()),this._binormals[V]=x.e.Cross(T,this._normals[V]),this._raw||this._binormals[V].normalize();this._pointAtData.id=NaN}},A.prototype._getFirstNonNullVector=function(S){for(var g=1,l=this._curve[S+g].subtract(this._curve[S]);l.length()===0&&S+g+1<this._curve.length;)g++,l=this._curve[S+g].subtract(this._curve[S]);return l},A.prototype._getLastNonNullVector=function(S){for(var g=1,l=this._curve[S].subtract(this._curve[S-g]);l.length()===0&&S>g+1;)g++,l=this._curve[S].subtract(this._curve[S-g]);return l},A.prototype._normalVector=function(S,g){var l,h,b=S.length();return b===0&&(b=1),g==null?(h=_.a.WithinEpsilon(Math.abs(S.y)/b,1,u.a)?_.a.WithinEpsilon(Math.abs(S.x)/b,1,u.a)?_.a.WithinEpsilon(Math.abs(S.z)/b,1,u.a)?x.e.Zero():new x.e(0,0,1):new x.e(1,0,0):new x.e(0,-1,0),l=x.e.Cross(S,h)):(l=x.e.Cross(S,g),x.e.CrossToRef(l,S,l)),l.normalize(),l},A.prototype._updatePointAtData=function(S,g){if(g===void 0&&(g=!1),this._pointAtData.id===S)return this._pointAtData.interpolateReady||this._updateInterpolationMatrix(),this._pointAtData;this._pointAtData.id=S;var l=this.getPoints();if(S<=0)return this._setPointAtData(0,0,l[0],0,g);if(S>=1)return this._setPointAtData(1,1,l[l.length-1],l.length-1,g);for(var h,b=l[0],T=0,D=S*this.length(),w=1;w<l.length;w++){h=l[w];var N=x.e.Distance(b,h);if((T+=N)===D)return this._setPointAtData(S,1,h,w,g);if(T>D){var I=(T-D)/N,V=b.subtract(h),W=h.add(V.scaleInPlace(I));return this._setPointAtData(S,1-I,W,w-1,g)}b=h}return this._pointAtData},A.prototype._setPointAtData=function(S,g,l,h,b){return this._pointAtData.point=l,this._pointAtData.position=S,this._pointAtData.subPosition=g,this._pointAtData.previousPointArrayIndex=h,this._pointAtData.interpolateReady=b,b&&this._updateInterpolationMatrix(),this._pointAtData},A.prototype._updateInterpolationMatrix=function(){this._pointAtData.interpolationMatrix=x.a.Identity();var S=this._pointAtData.previousPointArrayIndex;if(S!==this._tangents.length-1){var g=S+1,l=this._tangents[S].clone(),h=this._normals[S].clone(),b=this._binormals[S].clone(),T=this._tangents[g].clone(),D=this._normals[g].clone(),w=this._binormals[g].clone(),N=x.b.RotationQuaternionFromAxis(h,b,l),I=x.b.RotationQuaternionFromAxis(D,w,T);x.b.Slerp(N,I,this._pointAtData.subPosition).toRotationMatrix(this._pointAtData.interpolationMatrix)}},A}(),E=function(){function A(S){this._length=0,this._points=S,this._length=this._computeLength(S)}return A.CreateQuadraticBezier=function(S,g,l,h){h=h>2?h:3;for(var b=new Array,T=function(w,N,I,V){return(1-w)*(1-w)*N+2*w*(1-w)*I+w*w*V},D=0;D<=h;D++)b.push(new x.e(T(D/h,S.x,g.x,l.x),T(D/h,S.y,g.y,l.y),T(D/h,S.z,g.z,l.z)));return new A(b)}
923,A.CreateCubicBezier=function(S,g,l,h,b){b=b>3?b:4;for(var T=new Array,D=function(N,I,V,W,j){return(1-N)*(1-N)*(1-N)*I+3*N*(1-N)*(1-N)*V+3*N*N*(1-N)*W+N*N*N*j},w=0;w<=b;w++)T.push(new x.e(D(w/b,S.x,g.x,l.x,h.x),D(w/b,S.y,g.y,l.y,h.y),D(w/b,S.z,g.z,l.z,h.z)));return new A(T)},A.CreateHermiteSpline=function(S,g,l,h,b){for(var T=new Array,D=1/b,w=0;w<=b;w++)T.push(x.e.Hermite(S,g,l,h,w*D));return new A(T)},A.CreateCatmullRomSpline=function(S,g,l){var h=new Array,b=1/g,T=0;if(l){for(var D=S.length,w=0;w<D;w++){T=0;for(var N=0;N<g;N++)h.push(x.e.CatmullRom(S[w%D],S[(w+1)%D],S[(w+2)%D],S[(w+3)%D],T)),T+=b}h.push(h[0])}else{var I=new Array;for(I.push(S[0].clone()),Array.prototype.push.apply(I,S),I.push(S[S.length-1].clone()),w=0;w<I.length-3;w++)for(T=0,N=0;N<g;N++)h.push(x.e.CatmullRom(I[w],I[w+1],I[w+2],I[w+3],T)),T+=b;w--,h.push(x.e.CatmullRom(I[w],I[w+1],I[w+2],I[w+3],T))}return new A(h)},A.prototype.getPoints=function(){return this._points},A.prototype.length=function(){return this._length},A.prototype.continue=function(S){for(var g=this._points[this._points.length-1],l=this._points.slice(),h=S.getPoints(),b=1;b<h.length;b++)l.push(h[b].subtract(h[0]).add(g));return new A(l)},A.prototype._computeLength=function(S){for(var g=0,l=1;l<S.length;l++)g+=S[l].subtract(S[l-1]).length();return g},A}()},function(Ae,v,f){f.d(v,"a",function(){return l});var B=f(1),_=f(3),x=f(0),u=f(4),M=f(10),R=f(15),C=f(25),m=f(11),c=f(9),E=f(67),A=f(49),S=f(13),g={effect:null,subMesh:null},l=function(h){function b(T,D,w,N){N===void 0&&(N={});var I=h.call(this,T,D)||this;return I._textures={},I._textureArrays={},I._floats={},I._ints={},I._floatsArrays={},I._colors3={},I._colors3Arrays={},I._colors4={},I._colors4Arrays={},I._vectors2={},I._vectors3={},I._vectors4={},I._matrices={},I._matrixArrays={},I._matrices3x3={},I._matrices2x2={},I._vectors2Arrays={},I._vectors3Arrays={},I._vectors4Arrays={},I._cachedWorldViewMatrix=new x.a,I._cachedWorldViewProjectionMatrix=new x.a,I._multiview=!1,I._shaderPath=w,I._options=Object(B.a)({needAlphaBlending:!1,needAlphaTesting:!1,attributes:["position","normal","uv"],uniforms:["worldViewProjection"],uniformBuffers:[],samplers:[],defines:[]},N),I}return Object(B.d)(b,h),Object.defineProperty(b.prototype,"shaderPath",{get:function(){return this._shaderPath},set:function(T){this._shaderPath=T},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"options",{get:function(){return this._options},enumerable:!1,configurable:!0}),b.prototype.getClassName=function(){return"ShaderMaterial"},b.prototype.needAlphaBlending=function(){return this.alpha<1||this._options.needAlphaBlending},b.prototype.needAlphaTesting=function(){return this._options.needAlphaTesting},b.prototype._checkUniform=function(T){this._options.uniforms.indexOf(T)===-1&&this._options.uniforms.push(T)},b.prototype.setTexture=function(T,D){return this._options.samplers.indexOf(T)===-1&&this._options.samplers.push(T),this._textures[T]=D,this},b.prototype.setTextureArray=function(T,D){return this._options.samplers.indexOf(T)===-1&&this._options.samplers.push(T),this._checkUniform(T),this._textureArrays[T]=D,this},b.prototype.setFloat=function(T,D){return this._checkUniform(T),this._floats[T]=D,this},b.prototype.setInt=function(T,D){return this._checkUniform(T),this._ints[T]=D,this},b.prototype.setFloats=function(T,D){return this._checkUniform(T),this._floatsArrays[T]=D,this},b.prototype.setColor3=function(T,D){return this._checkUniform(T),this._colors3[T]=D,this},b.prototype.setColor3Array=function(T,D){return this._checkUniform(T),this._colors3Arrays[T]=D.reduce(function(w,N){return N.toArray(w,w.length),w},[]),this},b.prototype.setColor4=function(T,D){return this._checkUniform(T),this._colors4[T]=D,this},b.prototype.setColor4Array=function(T,D){return this._checkUniform(T),this._colors4Arrays[T]=D.reduce(function(w,N){return N.toArray(w,w.length),w},[]),this},b.prototype.setVector2=function(T,D){return this._checkUniform(T),this._vectors2[T]=D,this},b.prototype.setVector3=function(T,D){return this._checkUniform(T),this._vectors3[T]=D,this},b.prototype.setVector4=function(T,D){return this._checkUniform(T),this._vectors4[T]=D,this}
923,b.prototype.setMatrix=function(T,D){return this._checkUniform(T),this._matrices[T]=D,this},b.prototype.setMatrices=function(T,D){this._checkUniform(T);for(var w=new Float32Array(16*D.length),N=0;N<D.length;N++)D[N].copyToArray(w,16*N);return this._matrixArrays[T]=w,this},b.prototype.setMatrix3x3=function(T,D){return this._checkUniform(T),this._matrices3x3[T]=D,this},b.prototype.setMatrix2x2=function(T,D){return this._checkUniform(T),this._matrices2x2[T]=D,this},b.prototype.setArray2=function(T,D){return this._checkUniform(T),this._vectors2Arrays[T]=D,this},b.prototype.setArray3=function(T,D){return this._checkUniform(T),this._vectors3Arrays[T]=D,this},b.prototype.setArray4=function(T,D){return this._checkUniform(T),this._vectors4Arrays[T]=D,this},b.prototype._checkCache=function(T,D){return!T||!this._effect||this._effect.defines.indexOf("#define INSTANCES")!==-1===D},b.prototype.isReadyForSubMesh=function(T,D,w){return this.isReady(T,w)},b.prototype.isReady=function(T,D){var w,N;if(this._effect&&this.isFrozen&&this._effect._wasPreviouslyReady)return!0;var I=this.getScene(),V=I.getEngine();if(!this.checkReadyOnEveryCall&&this._renderId===I.getRenderId()&&this._checkCache(T,D))return!0;var W=[],j=[],ne=new E.a;V.getCaps().multiview&&I.activeCamera&&I.activeCamera.outputRenderTarget&&I.activeCamera.outputRenderTarget.getViewCount()>1&&(this._multiview=!0,W.push("#define MULTIVIEW"),this._options.uniforms.indexOf("viewProjection")!==-1&&this._options.uniforms.push("viewProjectionR")===-1&&this._options.uniforms.push("viewProjectionR"));for(var te=0;te<this._options.defines.length;te++)W.push(this._options.defines[te]);for(te=0;te<this._options.attributes.length;te++)j.push(this._options.attributes[te]);T&&T.isVerticesDataPresent(u.b.ColorKind)&&(j.push(u.b.ColorKind),W.push("#define VERTEXCOLOR")),D&&(W.push("#define INSTANCES"),R.a.PushAttributesForInstances(j),T?.hasThinInstances&&W.push("#define THIN_INSTANCES"));var de=0;if(T&&T.useBones&&T.computeBonesUsingShaders&&T.skeleton){j.push(u.b.MatricesIndicesKind),j.push(u.b.MatricesWeightsKind),T.numBoneInfluencers>4&&(j.push(u.b.MatricesIndicesExtraKind),j.push(u.b.MatricesWeightsExtraKind));var pe=T.skeleton;de=T.numBoneInfluencers,W.push("#define NUM_BONE_INFLUENCERS "+de),ne.addCPUSkinningFallback(0,T),pe.isUsingTextureForMatrices?(W.push("#define BONETEXTURE"),this._options.uniforms.indexOf("boneTextureWidth")===-1&&this._options.uniforms.push("boneTextureWidth"),this._options.samplers.indexOf("boneSampler")===-1&&this._options.samplers.push("boneSampler")):(W.push("#define BonesPerMesh "+(pe.bones.length+1)),this._options.uniforms.indexOf("mBones")===-1&&this._options.uniforms.push("mBones"))}else W.push("#define NUM_BONE_INFLUENCERS 0");for(var ae in this._textures)if(!this._textures[ae].isReady())return!1;T&&this._shouldTurnAlphaTestOn(T)&&W.push("#define ALPHATEST");var ee=this._shaderPath,K=this._options.uniforms,$=this._options.uniformBuffers,L=this._options.samplers;this.customShaderNameResolve&&(K=K.slice(),$=$.slice(),L=L.slice(),ee=this.customShaderNameResolve(ee,K,$,L,W,j));var G=this._effect,Q=W.join(`
924`);return this._cachedDefines!==Q&&(this._cachedDefines=Q,this._effect=V.createEffect(ee,{attributes:j,uniformsNames:K,uniformBuffersNames:$,samplers:L,defines:Q,fallbacks:ne,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousMorphTargets:de}},V),this._onEffectCreatedObservable&&(g.effect=this._effect,this._onEffectCreatedObservable.notifyObservers(g))),(N=!(!((w=this._effect)===null||w===void 0)&&w.isReady()))!==null&&N!==void 0&&!N&&(G!==this._effect&&I.resetCachedMaterial(),this._renderId=I.getRenderId(),this._effect._wasPreviouslyReady=!0,!0)},b.prototype.bindOnlyWorldMatrix=function(T,D){var w=this.getScene(),N=D??this._effect;N&&(this._options.uniforms.indexOf("world")!==-1&&N.setMatrix("world",T),this._options.uniforms.indexOf("worldView")!==-1&&(T.multiplyToRef(w.getViewMatrix(),this._cachedWorldViewMatrix),N.setMatrix("worldView",this._cachedWorldViewMatrix)),this._options.uniforms.indexOf("worldViewProjection")!==-1&&(T.multiplyToRef(w.getTransformMatrix(),this._cachedWorldViewProjectionMatrix),N.setMatrix("worldViewProjection",this._cachedWorldViewProjectionMatrix)))},b.prototype.bindForSubMesh=function(T,D,w){this.bind(T,D,w._effectOverride)},b.prototype.bind=function(T,D,w){this.bindOnlyWorldMatrix(T,w);var N=w??this._effect;
924if(N&&this.getScene().getCachedMaterial()!==this){var I;for(I in this._options.uniforms.indexOf("view")!==-1&&N.setMatrix("view",this.getScene().getViewMatrix()),this._options.uniforms.indexOf("projection")!==-1&&N.setMatrix("projection",this.getScene().getProjectionMatrix()),this._options.uniforms.indexOf("viewProjection")!==-1&&(N.setMatrix("viewProjection",this.getScene().getTransformMatrix()),this._multiview&&N.setMatrix("viewProjectionR",this.getScene()._transformMatrixR)),this.getScene().activeCamera&&this._options.uniforms.indexOf("cameraPosition")!==-1&&N.setVector3("cameraPosition",this.getScene().activeCamera.globalPosition),R.a.BindBonesParameters(D,N),this._textures)N.setTexture(I,this._textures[I]);for(I in this._textureArrays)N.setTextureArray(I,this._textureArrays[I]);for(I in this._ints)N.setInt(I,this._ints[I]);for(I in this._floats)N.setFloat(I,this._floats[I]);for(I in this._floatsArrays)N.setArray(I,this._floatsArrays[I]);for(I in this._colors3)N.setColor3(I,this._colors3[I]);for(I in this._colors3Arrays)N.setArray3(I,this._colors3Arrays[I]);for(I in this._colors4){var V=this._colors4[I];N.setFloat4(I,V.r,V.g,V.b,V.a)}for(I in this._colors4Arrays)N.setArray4(I,this._colors4Arrays[I]);for(I in this._vectors2)N.setVector2(I,this._vectors2[I]);for(I in this._vectors3)N.setVector3(I,this._vectors3[I]);for(I in this._vectors4)N.setVector4(I,this._vectors4[I]);for(I in this._matrices)N.setMatrix(I,this._matrices[I]);for(I in this._matrixArrays)N.setMatrices(I,this._matrixArrays[I]);for(I in this._matrices3x3)N.setMatrix3x3(I,this._matrices3x3[I]);for(I in this._matrices2x2)N.setMatrix2x2(I,this._matrices2x2[I]);for(I in this._vectors2Arrays)N.setArray2(I,this._vectors2Arrays[I]);for(I in this._vectors3Arrays)N.setArray3(I,this._vectors3Arrays[I]);for(I in this._vectors4Arrays)N.setArray4(I,this._vectors4Arrays[I])}var W=this._effect;this._effect=N,this._afterBind(D),this._effect=W},b.prototype._afterBind=function(T){h.prototype._afterBind.call(this,T),this.getScene()._cachedEffect=this._effect},b.prototype.getActiveTextures=function(){var T=h.prototype.getActiveTextures.call(this);for(var D in this._textures)T.push(this._textures[D]);for(var D in this._textureArrays)for(var w=this._textureArrays[D],N=0;N<w.length;N++)T.push(w[N]);return T},b.prototype.hasTexture=function(T){if(h.prototype.hasTexture.call(this,T))return!0;for(var D in this._textures)if(this._textures[D]===T)return!0;for(var D in this._textureArrays)for(var w=this._textureArrays[D],N=0;N<w.length;N++)if(w[N]===T)return!0;return!1},b.prototype.clone=function(T){var D=this,w=_.a.Clone(function(){return new b(T,D.get
924Scene(),D._shaderPath,D._options)},this);for(var N in w.name=T,w.id=T,typeof w._shaderPath=="object"&&(w._shaderPath=Object(B.a)({},w._shaderPath)),this._options=Object(B.a)({},this._options),Object.keys(this._options).forEach(function(I){var V=D._options[I];Array.isArray(V)&&(D._options[I]=V.slice(0))}),this._textures)w.setTexture(N,this._textures[N]);for(var N in this._floats)w.setFloat(N,this._floats[N]);for(var N in this._floatsArrays)w.setFloats(N,this._floatsArrays[N]);for(var N in this._colors3)w.setColor3(N,this._colors3[N]);for(var N in this._colors4)w.setColor4(N,this._colors4[N]);for(var N in this._vectors2)w.setVector2(N,this._vectors2[N]);for(var N in this._vectors3)w.setVector3(N,this._vectors3[N]);for(var N in this._vectors4)w.setVector4(N,this._vectors4[N]);for(var N in this._matrices)w.setMatrix(N,this._matrices[N]);for(var N in this._matrices3x3)w.setMatrix3x3(N,this._matrices3x3[N]);for(var N in this._matrices2x2)w.setMatrix2x2(N,this._matrices2x2[N]);return w},b.prototype.dispose=function(T,D,w){if(D){var N;for(N in this._textures)this._textures[N].dispose();for(N in this._textureArrays)for(var I=this._textureArrays[N],V=0;V<I.length;V++)I[V].dispose()}this._textures={},h.prototype.dispose.call(this,T,D,w)},b.prototype.serialize=function(){var T,D=_.a.Serialize(this);for(T in D.customType="BABYLON.ShaderMaterial",D.options=this._options,D.shaderPath=this._shaderPath,D.textures={},this._textures)D.textures[T]=this._textures[T].serialize();for(T in D.textureArrays={},this._textureArrays){D.textureArrays[T]=[];for(var w=this._textureArrays[T],N=0;N<w.length;N++)D.textureArrays[T].push(w[N].serialize())}for(T in D.floats={},this._floats)D.floats[T]=this._floats[T];for(T in D.FloatArrays={},this._floatsArrays)D.FloatArrays[T]=this._floatsArrays[T];for(T in D.colors3={},this._colors3)D.colors3[T]=this._colors3[T].asArray();for(T in D.colors3Arrays={},this._colors3Arrays)D.colors3Arrays[T]=this._colors3Arrays[T];for(T in D.colors4={},this._colors4)D.colors4[T]=this._colors4[T].asArray();for(T in D.colors4Arrays={},this._colors4Arrays)D.colors4Arrays[T]=this._colors4Arrays[T];for(T in D.vectors2={},this._vectors2)D.vectors2[T]=this._vectors2[T].asArray();for(T in D.vectors3={},this._vectors3)D.vectors3[T]=this._vectors3[T].asArray();for(T in D.vectors4={},this._vectors4)D.vectors4[T]=this._vectors4[T].asArray();for(T in D.matrices={},this._matrices)D.matrices[T]=this._matrices[T].asArray();for(T in D.matrixArray={},this._matrixArrays)D.matrixArray[T]=this._matrixArrays[T];for(T in D.matrices3x3={},this._matrices3x3)D.matrices3x3[T]=this._matrices3x3[T];for(T in D.matrices2x2={},this._matrices2x2)D.matrices2x2[T]=this._matrices2x2[T];for(T in D.vectors2Arrays={},this._vectors2Arrays)D.vectors2Arrays[T]=this._vectors2Arrays[T];for(T in D.vectors3Arrays={},this._vectors3Arrays)D.vectors3Arrays[T]=this._vectors3Arrays[T];for(T in D.vectors4Arrays={},this._vectors4Arrays)D.vectors4Arrays[T]=this._vectors4Arrays[T];return D},b.Parse=function(T,D,w){var N,I=_.a.Parse(function(){return new b(T.name,D,T.shaderPath,T.options)},T,D,w);for(N in T.textures)I.setTexture(N,M.a.Parse(T.textures[N],D,w));for(N in T.textureArrays){for(var V=T.textureArrays[N],W=new Array,j=0;j<V.length;j++)W.push(M.a.Parse(V[j],D,w));I.setTextureArray(N,W)}for(N in T.floats)I.setFloat(N,T.floats[N]);for(N in T.floatsArrays)I.setFloats(N,T.floatsArrays[N]);for(N in T.colors3)I.setColor3(N,c.a.FromArray(T.colors3[N]));for(N in T.colors3Arrays){var ne=T.colors3Arrays[N].reduce(function(te,de,pe){return pe%3==0?te.push([de]):te[te.length-1].push(de),te},[]).map(function(te){return c.a.FromArray(te)});I.setColor3Array(N,ne)}for(N in T.colors4)I.setColor4(N,c.b.FromArray(T.colors4[N]));for(N in T.colors4Arrays)ne=T.colors4Arrays[N].reduce(function(te,de,pe){return pe%4==0?te.push([de]):te[te.length-1].push(de),te},[]).map(function(te){return c.b.FromArray(te)}),I.setColor4Array(N,ne);for(N in T.vectors2)I.setVector2(N,x.d.FromArray(T.vectors2[N]));for(N in T.vectors3)I.setVector3(N,x.e.FromArray(T.vectors3[N]));for(N in T.vectors4)I.setVector4(N,x.f.FromArray(T.vectors4[N]));for(N in T.matrices)I.setMatrix(N,x.a.FromArray(T.matrices[N]));for(N in T.matrixArray)I._matrixArrays[N]=new Float32Array(T.matrixArray[N]);for(N in T.matrices3x3)I.setMatrix3x3(N,T.matrices3x3[N]);for(N in T.matrices2x2)I.setMatrix2x2(N,T.matrices2x2[N]);for(N in T.vectors2Arrays)I.setArray2(N,T.vectors2Arrays[N]);for(N in T.vectors3Arrays)I.setArray3(N,T.vectors3Arrays[N]);for(N in T.vectors4Arrays)I.setArray4(N,T.vectors4Arrays[N]);return I},b.ParseFromFileAsync=function(T,D,w,N){var I=this;return N===void 0&&(N=""),new Promise(function(V,W){var j=new A.a;j.addEventListener("readystatechange",function(){if(j.readyState==4)if(j.status==200){var ne=JSON.parse(j.responseText),te=I.Parse(ne,w||S.a.LastCreatedScene,N);T&&(te.name=T),V(te)}else W("Unable to load the ShaderMaterial")}),j.open("GET",D),j.send()})},b.CreateFromSnippetAsync=function(T,D,w){var N=this;return w===void 0&&(w=""),new Promise(function(I,V){var W=new A.a;W.addEventListener("readystatechange",function(){if(W.readyState==4)if(W.status==200){var j=JSON.parse(JSON.parse(W.responseText).jsonPayload),ne=JSON.parse(j.shaderMaterial),te=N.Parse(ne,D||S.a.LastCreatedScene,w);te.snippetId=T,I(te)}else V("Unable to load the snippet "+T)}),W.open("GET",N.SnippetUrl+"/"+T.replace(/#/g,"/")),W.send()})},b.SnippetUrl="https://snippet.babylonjs.com",b}(C.a);m.a.RegisteredTypes["BABYLON.ShaderMaterial"]=l},function(Ae,v,f){f.d(v,"a",function(){return B});var B=function(){function _(){}
924return _.SetMatrixPrecision=function(x){if(_.MatrixTrackPrecisionChange=!1,x&&!_.MatrixUse64Bits&&_.MatrixTrackedMatrices)for(var u=0;u<_.MatrixTrackedMatrices.length;++u){var M=_.MatrixTrackedMatrices[u],R=M._m;M._m=new Array(16);for(var C=0;C<16;++C)M._m[C]=R[C]}_.MatrixUse64Bits=x,_.MatrixCurrentType=_.MatrixUse64Bits?Array:Float32Array,_.MatrixTrackedMatrices=null},_.MatrixUse64Bits=!1,_.MatrixTrackPrecisionChange=!0,_.MatrixCurrentType=Float32Array,_.MatrixTrackedMatrices=[],_}()},function(Ae,v,f){f.d(v,"a",function(){return S});var B=f(1),_=f(6),x=f(0),u=f(46),M=f(7),R=f(53),C=f(65),m=f(51),c=f(36),E=f(30),A=f(9),S=function(g){function l(h,b,T,D,w){var N;b===void 0&&(b=A.a.Gray()),T===void 0&&(T=c.a.DefaultUtilityLayer),D===void 0&&(D=null),w===void 0&&(w=1);var I=g.call(this,T)||this;I._pointerObserver=null,I.snapDistance=0,I.onSnapObservable=new _.c,I._isEnabled=!0,I._parent=null,I._dragging=!1,I._parent=D,I._coloredMaterial=new E.a("",T.utilityLayerScene),I._coloredMaterial.diffuseColor=b,I._coloredMaterial.specularColor=b.subtract(new A.a(.1,.1,.1)),I._hoverMaterial=new E.a("",T.utilityLayerScene),I._hoverMaterial.diffuseColor=A.a.Yellow(),I._disableMaterial=new E.a("",T.utilityLayerScene),I._disableMaterial.diffuseColor=A.a.Gray(),I._disableMaterial.alpha=.4;var V=l._CreateArrow(T.utilityLayerScene,I._coloredMaterial,w),W=l._CreateArrow(T.utilityLayerScene,I._coloredMaterial,w+4,!0);I._gizmoMesh=new M.a("",T.utilityLayerScene),I._gizmoMesh.addChild(V),I._gizmoMesh.addChild(W),I._gizmoMesh.lookAt(I._rootMesh.position.add(h)),I._gizmoMesh.scaling.scaleInPlace(1/3),I._gizmoMesh.parent=I._rootMesh;var j=0,ne=new x.e,te={snapDistance:0};I.dragBehavior=new C.a({dragAxis:h}),I.dragBehavior.moveAttached=!1,I._rootMesh.addBehavior(I.dragBehavior),I.dragBehavior.onDragObservable.add(function(ae){if(I.attachedNode){if(I.snapDistance==0)I.attachedNode.position&&I.attachedNode.position.addInPlaceFromFloats(ae.delta.x,ae.delta.y,ae.delta.z),I.attachedNode.getWorldMatrix().addTranslationFromFloats(ae.delta.x,ae.delta.y,ae.delta.z),I.attachedNode.updateCache();else if(j+=ae.dragDistance,Math.abs(j)>I.snapDistance){var ee=Math.floor(Math.abs(j)/I.snapDistance);j%=I.snapDistance,ae.delta.normalizeToRef(ne),ne.scaleInPlace(I.snapDistance*ee),I.attachedNode.getWorldMatrix().addTranslationFromFloats(ne.x,ne.y,ne.z),I.attachedNode.updateCache(),te.snapDistance=I.snapDistance*ee,I.onSnapObservable.notifyObservers(te)}I._matrixChanged()}}),I.dragBehavior.onDragStartObservable.add(function(){I._dragging=!0}),I.dragBehavior.onDragEndObservable.add(function(){I._dragging=!1});var de=T._getSharedGizmoLight();de.includedOnlyMeshes=de.includedOnlyMeshes.concat(I._rootMesh.getChildMeshes(!1));var pe={gizmoMeshes:V.getChildMeshes(),colliderMeshes:W.getChildMeshes(),material:I._coloredMaterial,hoverMaterial:I._hoverMaterial,disableMaterial:I._disableMaterial,active:!1};return(N=I._parent)===null||N===void 0||N.addToAxisCache(W,pe),I._pointerObserver=T.utilityLayerScene.onPointerObservable.add(function(ae){var ee;if(!I._customMeshSet&&(I._isHovered=pe.colliderMeshes.indexOf((ee=ae?.pickInfo)===null||ee===void 0?void 0:ee.pickedMesh)!=-1,!I._parent)){var K=I._isHovered||I._dragging?I._hoverMaterial:I._coloredMaterial;pe.gizmoMeshes.forEach(function($){$.material=K,$.color&&($.color=K.diffuseColor)})}}),I}return Object(B.d)(l,g),l._CreateArrow=function(h,b,T,D){T===void 0&&(T=1),D===void 0&&(D=!1);var w=new u.a("arrow",h),N=R.a.CreateCylinder("cylinder",{diameterTop:0,height:.075,diameterBottom:.0375*(1+(T-1)/4),tessellation:96},h),I=R.a.CreateCylinder("cylinder",{diameterTop:.005*T,height:.275,diameterBottom:.005*T,tessellation:96},h);return N.parent=w,N.material=b,N.rotation.x=Math.PI/2,N.position.z+=.3,I.parent=w,I.material=b,I.position.z+=.1375,I.rotation.x=Math.PI/2,D&&(I.visibility=0,N.visibility=0),w},l._CreateArrowInstance=function(h,b){for(var T=new u.a("arrow",h),D=0,w=b.getChildMeshes();D<w.length;D++){var N=w[D];N.createInstance(N.name).parent=T}return T},l.prototype._attachedNodeChanged=function(h){this.dragBehavior&&(this.dragBehavior.enabled=!!h)},Object.defineProperty(l.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(h){this._isEnabled=h,h?this._parent&&(this.attachedMesh=this._parent.attachedMesh,this.attachedNode=this._parent.attachedNode):(this.attachedMesh=null,this.attachedNode=null)}
924,enumerable:!1,configurable:!0}),l.prototype.dispose=function(){this.onSnapObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.dragBehavior.detach(),this._gizmoMesh&&this._gizmoMesh.dispose(),[this._coloredMaterial,this._hoverMaterial,this._disableMaterial].forEach(function(h){h&&h.dispose()}),g.prototype.dispose.call(this)},l}(m.a)},function(Ae,v,f){f.d(v,"a",function(){return B});var B=function(){function _(){this._isDirty=!0,this._areLightsDirty=!0,this._areLightsDisposed=!1,this._areAttributesDirty=!0,this._areTexturesDirty=!0,this._areFresnelDirty=!0,this._areMiscDirty=!0,this._arePrePassDirty=!0,this._areImageProcessingDirty=!0,this._normals=!1,this._uvs=!1,this._needNormals=!1,this._needUVs=!1}return Object.defineProperty(_.prototype,"isDirty",{get:function(){return this._isDirty},enumerable:!1,configurable:!0}),_.prototype.markAsProcessed=function(){this._isDirty=!1,this._areAttributesDirty=!1,this._areTexturesDirty=!1,this._areFresnelDirty=!1,this._areLightsDirty=!1,this._areLightsDisposed=!1,this._areMiscDirty=!1,this._arePrePassDirty=!1,this._areImageProcessingDirty=!1},_.prototype.markAsUnprocessed=function(){this._isDirty=!0},_.prototype.markAllAsDirty=function(){this._areTexturesDirty=!0,this._areAttributesDirty=!0,this._areLightsDirty=!0,this._areFresnelDirty=!0,this._areMiscDirty=!0,this._areImageProcessingDirty=!0,this._isDirty=!0},_.prototype.markAsImageProcessingDirty=function(){this._areImageProcessingDirty=!0,this._isDirty=!0},_.prototype.markAsLightDirty=function(x){x===void 0&&(x=!1),this._areLightsDirty=!0,this._areLightsDisposed=this._areLightsDisposed||x,this._isDirty=!0},_.prototype.markAsAttributesDirty=function(){this._areAttributesDirty=!0,this._isDirty=!0},_.prototype.markAsTexturesDirty=function(){this._areTexturesDirty=!0,this._isDirty=!0},_.prototype.markAsFresnelDirty=function(){this._areFresnelDirty=!0,this._isDirty=!0},_.prototype.markAsMiscDirty=function(){this._areMiscDirty=!0,this._isDirty=!0},_.prototype.markAsPrePassDirty=function(){this._arePrePassDirty=!0,this._isDirty=!0},_.prototype.rebuild=function(){this._keys=[];for(var x=0,u=Object.keys(this);x<u.length;x++){var M=u[x];M[0]!=="_"&&this._keys.push(M)}},_.prototype.isEqual=function(x){if(this._keys.length!==x._keys.length)return!1;for(var u=0;u<this._keys.length;u++){var M=this._keys[u];if(this[M]!==x[M])return!1}return!0},_.prototype.cloneTo=function(x){this._keys.length!==x._keys.length&&(x._keys=this._keys.slice(0));for(var u=0;u<this._keys.length;u++){var M=this._keys[u];x[M]=this[M]}},_.prototype.reset=function(){for(var x=0;x<this._keys.length;x++){var u=this._keys[x];switch(typeof this[u]){case"number":this[u]=0;break;case"string":this[u]="";break;default:this[u]=!1}}},_.prototype.toString=function(){for(var x="",u=0;u<this._keys.length;u++){var M=this._keys[u],R=this[M];switch(typeof R){case"number":case"string":x+="#define "+M+" "+R+`
925`;break;default:R&&(x+="#define "+M+`
926`)}}return x},_}()},function(Ae,v,f){f.d(v,"a",function(){return B});var B=function(){function _(x,u){this.width=x,this.height=u}return _.prototype.toString=function(){return"{W: "+this.width+", H: "+this.height+"}"},_.prototype.getClassName=function(){return"Size"},_.prototype.getHashCode=function(){var x=0|this.width;return x=397*x^(0|this.height)},_.prototype.copyFrom=function(x){this.width=x.width,this.height=x.height},_.prototype.copyFromFloats=function(x,u){return this.width=x,this.height=u,this},_.prototype.set=function(x,u){return this.copyFromFloats(x,u)},_.prototype.multiplyByFloats=function(x,u){return new _(this.width*x,this.height*u)},_.prototype.clone=function(){return new _(this.width,this.height)},_.prototype.equals=function(x){return!!x&&this.width===x.width&&this.height===x.height},Object.defineProperty(_.prototype,"surface",{get:function(){return this.width*this.height},enumerable:!1,configurable:!0}),_.Zero=function(){return new _(0,0)},_.prototype.add=function(x){return new _(this.width+x.width,this.height+x.height)},_.prototype.subtract=function(x){return new _(this.width-x.width,this.height-x.height)},_.Lerp=function(x,u,M){return new _(x.width+(u.width-x.width)*M,x.height+(u.height-x.height)*M)},_}()},function(Ae,v,f){var B="bonesDeclaration",_=`#if NUM_BONE_INFLUENCERS>0
927#ifdef BONETEXTURE
928uniform sampler2D boneSampler;
929uniform float boneTextureWidth;
930#else
931uniform mat4 mBones[BonesPerMesh];
932#ifdef BONES_VELOCITY_ENABLED
933uniform mat4 mPreviousBones[BonesPerMesh];
934#endif
935#endif
936attribute vec4 matricesIndices;
937attribute vec4 matricesWeights;
938#if NUM_BONE_INFLUENCERS>4
939attribute vec4 matricesIndicesExtra;
940attribute vec4 matricesWeightsExtra;
941#endif
942#ifdef BONETEXTURE
943#define inline
944mat4 readMatrixFromRawSampler(sampler2D smp,float index)
945{
946float offset=index*4.0;
947float dx=1.0/boneTextureWidth;
948vec4 m0=texture2D(smp,vec2(dx*(offset+0.5),0.));
949vec4 m1=texture2D(smp,vec2(dx*(offset+1.5),0.));
950vec4 m2=texture2D(smp,vec2(dx*(offset+2.5),0.));
951vec4 m3=texture2D(smp,vec2(dx*(offset+3.5),0.));
952return mat4(m0,m1,m2,m3);
953}
954#endif
955#endif`;f(5).a.IncludesShadersStore[B]=_},function(Ae,v,f){var B="instancesDeclaration",_=`#ifdef INSTANCES
956attribute vec4 world0;
957attribute vec4 world1;
958attribute vec4 world2;
959attribute vec4 world3;
960#ifdef THIN_INSTANCES
961uniform mat4 world;
962#endif
963#else
964uniform mat4 world;
965#endif`;f(5).a.IncludesShadersStore[B]=_},function(Ae,v,f){var B="instancesVertex",_=`#ifdef INSTANCES
966mat4 finalWorld=mat4(world0,world1,world2,world3);
967#ifdef THIN_INSTANCES
968finalWorld=world*finalWorld;
969#endif
970#else
971mat4 finalWorld=world;
972#endif`;f(5).a.IncludesShadersStore[B]=_},function(Ae,v,f){var B=`#if NUM_BONE_INFLUENCERS>0
973mat4 influence;
974#ifdef BONETEXTURE
975influence=readMatrixFromRawSampler(boneSampler,matricesIndices[0])*matricesWeights[0];
976#if NUM_BONE_INFLUENCERS>1
977influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[1])*matricesWeights[1];
978#endif
979#if NUM_BONE_INFLUENCERS>2
980influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[2])*matricesWeights[2];
981#endif
982#if NUM_BONE_INFLUENCERS>3
983influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[3])*matricesWeights[3];
984#endif
985#if NUM_BONE_INFLUENCERS>4
986influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[0])*matricesWeightsExtra[0];
987#endif
988#if NUM_BONE_INFLUENCERS>5
989influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[1])*matricesWeightsExtra[1];
990#endif
991#if NUM_BONE_INFLUENCERS>6
992influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[2])*matricesWeightsExtra[2];
993#endif
994#if NUM_BONE_INFLUENCERS>7
995influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[3])*matricesWeightsExtra[3];
996#endif
997#else
998influence=mBones[int(matricesIndices[0])]*matricesWeights[0];
999#if NUM_BONE_INFLUENCERS>1
1000influence+=mBones[int(matricesIndices[1])]*matricesWeights[1];
1001#endif
1002#if NUM_BONE_INFLUENCERS>2
1003influence+=mBones[int(matricesIndices[2])]*matricesWeights[2];
1004#endif
1005#if NUM_BONE_INFLUENCERS>3
1006influence+=mBones[int(matricesIndices[3])]*matricesWeights[3];
1007#endif
1008#if NUM_BONE_INFLUENCERS>4
1009influence+=mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];
1010#endif
1011#if NUM_BONE_INFLUENCERS>5
1012influence+=mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];
1013#endif
1014#if NUM_BONE_INFLUENCERS>6
1015influence+=mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];
1016#endif
1017#if NUM_BONE_INFLUENCERS>7
1018influence+=mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];
1019#endif
1020#endif
1021finalWorld=finalWorld*influence;
1022#endif`;f(5).a.IncludesShadersStore.bonesVertex=B},function(Ae,v,f){f.d(v,"a",function(){return R});var B=f(0),_=f(7),x=f(4),u=f(16),M=f(43);u.a.CreateRibbon=function(C){var m=C.pathArray,c=C.closeArray||!1,E=C.closePath||!1,A=C.invertUV||!1,S=Math.floor(m[0].length/2),g=C.offset||S;g=g>S?S:Math.floor(g);var l,h,b,T,D=C.sideOrientation===0?0:C.sideOrientation||u.a.DEFAULTSIDE,w=C.uvs,N=C.colors,I=[],V=[],W=[],j=[],ne=[],te=[],de=[],pe=[],ae=[],ee=[];if(m.length<2){var K=[],$=[];for(b=0;b<m[0].length-g;b++)K.push(m[0][b]),$.push(m[0][b+g]);m=[K,$]}var L,G,Q,oe,re,Y=0,k=E?1:0;for(l=m[0].length,h=0;h<m.length;h++){for(de[h]=0,ne[h]=[0],l=l<(G=(L=m[h]).length)?l:G,T=0;T<G;)I.push(L[T].x,L[T].y,L[T].z),T>0&&(Q=L[T].subtract(L[T-1]).length()+de[h],ne[h].push(Q),de[h]=Q),T++;E&&(T--,I.push(L[0].x,L[0].y,L[0].z),Q=L[T].subtract(L[0]).length()+de[h],ne[h].push(Q),de[h]=Q),ae[h]=G+k,ee[h]=Y,Y+=G+k}var H,Z,X=null,q=null;for(b=0;b<l+k;b++){for(pe[b]=0,te[b]=[0],h=0;h<m.length-1;h++)oe=m[h],re=m[h+1],b===l?(X=oe[0],q=re[0]):(X=oe[b],q=re[b]),Q=q.subtract(X).length()+pe[b],te[b].push(Q),pe[b]=Q;c&&q&&X&&(oe=m[h],re=m[0],b===l&&(q=re[0]),Q=q.subtract(X).length()+pe[b],pe[b]=Q)}if(w)for(h=0;h<w.length;h++)j.push(w[h].x,w[h].y);else for(h=0;h<m.length;h++)for(b=0;b<l+k;b++)H=de[h]!=0?ne[h][b]/de[h]:0,Z=pe[b]!=0?te[b][h]/pe[b]:0,A?j.push(Z,H):j.push(H,Z);for(var he=0,ge=ae[h=0]-1,me=ae[h+1]-1,_e=ge<me?ge:me,be=ee[1]-ee[0],Ce=c?ae.length:ae.length-1;he<=_e&&h<Ce;)V.push(he,he+be,he+1),V.push(he+be+1,he+1,he+be),(he+=1)===_e&&(++h===ae.length-1?(be=ee[0]-ee[h],ge=ae[h]-1,me=ae[0]-1):(be=ee[h+1]-ee[h],ge=ae[h]-1,me=ae[h+1]-1),he=ee[h],_e=ge<me?ge+he:me+he);if(u.a.ComputeNormals(I,V,W),E){var ye=0,Be=0;for(h=0;h<m.length;h++)ye=3*ee[h],Be=h+1<m.length?3*(ee[h+1]-1):W.length-3,W[ye]=.5*(W[ye]+W[Be]),W[ye+1]=.5*(W[ye+1]+W[Be+1]),W[ye+2]=.5*(W[ye+2]+W[Be+2]),W[Be]=W[ye],W[Be+1]=W[ye+1],W[Be+2]=W[ye+2]}u.a._ComputeSides(D,I,V,W,j,C.frontUVs,C.backUVs);var Ge=null;if(N){Ge=new Float32Array(4*N.length);for(var Xe=0;Xe<N.length;Xe++)Ge[4*Xe]=N[Xe].r,Ge[4*Xe+1]=N[Xe].g,Ge[4*Xe+2]=N[Xe].b,Ge[4*Xe+3]=N[Xe].a}var He=new u.a,We=new Float32Array(I),Ze=new Float32Array(W),ze=new Float32Array(j);return He.indices=V,He.positions=We,He.normals=Ze,He.uvs=ze,Ge&&He.set(Ge,x.b.ColorKind),E&&(He._idx=ee),He},_.a.CreateRibbon=function(C,m,c,E,A,S,g,l,h){return c===void 0&&(c=!1),g===void 0&&(g=!1),R.CreateRibbon(C,{pathArray:m,closeArray:c,closePath:E,offset:A,updatable:g,sideOrientation:l,instance:h},S)};var R=function(){function C(){}return C.CreateRibbon=function(m,c,E){E===void 0&&(E=null);var A=c.pathArray,S=c.closeArray,g=c.closePath,l=_.a._GetDefaultSideOrientation(c.sideOrientation),h=c.instance,b=c.updatable;if(h){var T=B.c.Vector3[0].setAll(Number.MAX_VALUE),D=B.c.Vector3[1].setAll(-Number.MAX_VALUE),w=h.getVerticesData(x.b.PositionKind);if(function(G){for(var Q=A[0].length,oe=h,re=0,Y=oe._originalBuilderSideOrientation===_.a.DOUBLESIDE?2:1,k=1;k<=Y;++k)for(var H=0;H<A.length;++H){var Z=A[H],X=Z.length;Q=Q<X?Q:X;for(var q=0;q<Q;++q){var he=Z[q];G[re]=he.x,G[re+1]=he.y,G[re+2]=he.z,T.minimizeInPlaceFromFloats(he.x,he.y,he.z),D.maximizeInPlaceFromFloats(he.x,he.y,he.z),re+=3}oe._creationDataStorage&&oe._creationDataStorage.closePath&&(he=Z[0],G[re]=he.x,G[re+1]=he.y,G[re+2]=he.z,re+=3)}}
1022(w),h._boundingInfo?h._boundingInfo.reConstruct(T,D,h._worldMatrix):h._boundingInfo=new M.a(T,D,h._worldMatrix),h.updateVerticesData(x.b.PositionKind,w,!1,!1),c.colors){for(var N=h.getVerticesData(x.b.ColorKind),I=0,V=0;I<c.colors.length;I++,V+=4){var W=c.colors[I];N[V]=W.r,N[V+1]=W.g,N[V+2]=W.b,N[V+3]=W.a}h.updateVerticesData(x.b.ColorKind,N,!1,!1)}if(c.uvs){for(var j=h.getVerticesData(x.b.UVKind),ne=0;ne<c.uvs.length;ne++)j[2*ne]=c.uvs[ne].x,j[2*ne+1]=c.uvs[ne].y;h.updateVerticesData(x.b.UVKind,j,!1,!1)}if(!h.areNormalsFrozen||h.isFacetDataEnabled){var te=h.getIndices(),de=h.getVerticesData(x.b.NormalKind),pe=h.isFacetDataEnabled?h.getFacetDataParameters():null;if(u.a.ComputeNormals(w,te,de,pe),h._creationDataStorage&&h._creationDataStorage.closePath)for(var ae=0,ee=0,K=0;K<A.length;K++)ae=3*h._creationDataStorage.idx[K],ee=K+1<A.length?3*(h._creationDataStorage.idx[K+1]-1):de.length-3,de[ae]=.5*(de[ae]+de[ee]),de[ae+1]=.5*(de[ae+1]+de[ee+1]),de[ae+2]=.5*(de[ae+2]+de[ee+2]),de[ee]=de[ae],de[ee+1]=de[ae+1],de[ee+2]=de[ae+2];h.areNormalsFrozen||h.updateVerticesData(x.b.NormalKind,de,!1,!1)}return h}var $=new _.a(m,E);$._originalBuilderSideOrientation=l,$._creationDataStorage=new _.b;var L=u.a.CreateRibbon(c);return g&&($._creationDataStorage.idx=L._idx),$._creationDataStorage.closePath=g,$._creationDataStorage.closeArray=S,L.applyToMesh($,b),$},C}()},function(Ae,v,f){f.d(v,"a",function(){return B});var B=function(){function _(){}return _.FilesToLoad={},_}()},function(Ae,v,f){f.d(v,"a",function(){return x});var B=f(7),_=f(16);_.a.CreatePlane=function(u){var M=[],R=[],C=[],m=[],c=u.width||u.size||1,E=u.height||u.size||1,A=u.sideOrientation===0?0:u.sideOrientation||_.a.DEFAULTSIDE,S=c/2,g=E/2;R.push(-S,-g,0),C.push(0,0,-1),m.push(0,0),R.push(S,-g,0),C.push(0,0,-1),m.push(1,0),R.push(S,g,0),C.push(0,0,-1),m.push(1,1),R.push(-S,g,0),C.push(0,0,-1),m.push(0,1),M.push(0),M.push(1),M.push(2),M.push(0),M.push(2),M.push(3),_.a._ComputeSides(A,R,M,C,m,u.frontUVs,u.backUVs);var l=new _.a;return l.indices=M,l.positions=R,l.normals=C,l.uvs=m,l},B.a.CreatePlane=function(u,M,R,C,m){var c={size:M,width:M,height:M,sideOrientation:m,updatable:C};return x.CreatePlane(u,c,R)};var x=function(){function u(){}return u.CreatePlane=function(M,R,C){C===void 0&&(C=null);var m=new B.a(M,C);return R.sideOrientation=B.a._GetDefaultSideOrientation(R.sideOrientation),m._originalBuilderSideOrientation=R.sideOrientation,_.a.CreatePlane(R).applyToMesh(m,R.updatable),R.sourcePlane&&(m.translate(R.sourcePlane.normal,-R.sourcePlane.d),m.setDirection(R.sourcePlane.normal.scale(-1))),m},u}()},function(Ae,v,f){f.d(v,"a",function(){return _});var B=f(8),_=(f(153),function(){function x(u,M,R){this._alreadyBound=!1,this._valueCache={},this._engine=u,this._noUBO=!u.supportsUniformBuffers,this._dynamic=R,this._data=M||[],this._uniformLocations={},this._uniformSizes={},this._uniformLocationPointer=0,this._needSync=!1,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.updateMatrix=this._updateMatrixForEffect,this.updateVector3=this._updateVector3ForEffect,this.updateVector4=this._updateVector4ForEffect,this.updateColor3=this._updateColor3ForEffect,this.updateColor4=this._updateColor4ForEffect):(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.updateMatrix=this._updateMatrixForUniform,this.updateVector3=this._updateVector3ForUniform,this.updateVector4=this._updateVector4ForUniform,this.updateColor3=this._updateColor3ForUniform,this.updateColor4=this._updateColor4ForUniform)}return Object.defineProperty(x.prototype,"useUbo",{get:function(){return!this._noUBO}
1022,enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isSync",{get:function(){return!this._needSync},enumerable:!1,configurable:!0}),x.prototype.isDynamic=function(){return this._dynamic!==void 0},x.prototype.getData=function(){return this._bufferData},x.prototype.getBuffer=function(){return this._buffer},x.prototype._fillAlignment=function(u){var M;if(M=u<=2?u:4,this._uniformLocationPointer%M!=0){var R=this._uniformLocationPointer;this._uniformLocationPointer+=M-this._uniformLocationPointer%M;for(var C=this._uniformLocationPointer-R,m=0;m<C;m++)this._data.push(0)}},x.prototype.addUniform=function(u,M){if(!this._noUBO&&this._uniformLocations[u]===void 0){var R;if(M instanceof Array)M=(R=M).length;else{M=M,R=[];for(var C=0;C<M;C++)R.push(0)}for(this._fillAlignment(M),this._uniformSizes[u]=M,this._uniformLocations[u]=this._uniformLocationPointer,this._uniformLocationPointer+=M,C=0;C<M;C++)this._data.push(R[C]);this._needSync=!0}},x.prototype.addMatrix=function(u,M){this.addUniform(u,Array.prototype.slice.call(M.toArray()))},x.prototype.addFloat2=function(u,M,R){var C=[M,R];this.addUniform(u,C)},x.prototype.addFloat3=function(u,M,R,C){var m=[M,R,C];this.addUniform(u,m)},x.prototype.addColor3=function(u,M){var R=new Array;M.toArray(R),this.addUniform(u,R)},x.prototype.addColor4=function(u,M,R){var C=new Array;M.toArray(C),C.push(R),this.addUniform(u,C)},x.prototype.addVector3=function(u,M){var R=new Array;M.toArray(R),this.addUniform(u,R)},x.prototype.addMatrix3x3=function(u){this.addUniform(u,12)},x.prototype.addMatrix2x2=function(u){this.addUniform(u,8)},x.prototype.create=function(){this._noUBO||this._buffer||(this._fillAlignment(4),this._bufferData=new Float32Array(this._data),this._rebuild(),this._needSync=!0)},x.prototype._rebuild=function(){!this._noUBO&&this._bufferData&&(this._dynamic?this._buffer=this._engine.createDynamicUniformBuffer(this._bufferData):this._buffer=this._engine.createUniformBuffer(this._bufferData))},x.prototype.update=function(){this._buffer?(this._dynamic||this._needSync)&&(this._engine.updateUniformBuffer(this._buffer,this._bufferData),this._needSync=!1):this.create()},x.prototype.updateUniform=function(u,M,R){var C=this._uniformLocations[u];if(C===void 0){if(this._buffer)return void B.a.Error("Cannot add an uniform after UBO has been created.");this.addUniform(u,R),C=this._uniformLocations[u]}if(this._buffer||this.create(),this._dynamic)for(c=0;c<R;c++)this._bufferData[C+c]=M[c];else{for(var m=!1,c=0;c<R;c++)R!==16&&this._bufferData[C+c]===M[c]||(m=!0,this._bufferData[C+c]=M[c]);this._needSync=this._needSync||m}},x.prototype._cacheMatrix=function(u,M){var R=this._valueCache[u],C=M.updateFlag;return(R===void 0||R!==C)&&(this._valueCache[u]=C,!0)},x.prototype._updateMatrix3x3ForUniform=function(u,M){for(var R=0;R<3;R++)x._tempBuffer[4*R]=M[3*R],x._tempBuffer[4*R+1]=M[3*R+1],x._tempBuffer[4*R+2]=M[3*R+2],x._tempBuffer[4*R+3]=0;this.updateUniform(u,x._tempBuffer,12)},x.prototype._updateMatrix3x3ForEffect=function(u,M){this._currentEffect.setMatrix3x3(u,M)},x.prototype._updateMatrix2x2ForEffect=function(u,M){this._currentEffect.setMatrix2x2(u,M)},x.prototype._updateMatrix2x2ForUniform=function(u,M){for(var R=0;R<2;R++)x._tempBuffer[4*R]=M[2*R],x._tempBuffer[4*R+1]=M[2*R+1],x._tempBuffer[4*R+2]=0,x._tempBuffer[4*R+3]=0;this.updateUniform(u,x._tempBuffer,8)},x.prototype._updateFloatForEffect=function(u,M){this._currentEffect.setFloat(u,M)},x.prototype._updateFloatForUniform=function(u,M){x._tempBuffer[0]=M,this.updateUniform(u,x._tempBuffer,1)},x.prototype._updateFloat2ForEffect=function(u,M,R,C){C===void 0&&(C=""),this._currentEffect.setFloat2(u+C,M,R)},x.prototype._updateFloat2ForUniform=function(u,M,R){x._tempBuffer[0]=M,x._tempBuffer[1]=R,this.updateUniform(u,x._tempBuffer,2)},x.prototype._updateFloat3ForEffect=function(u,M,R,C,m){m===void 0&&(m=""),this._currentEffect.setFloat3(u+m,M,R,C)},x.prototype._updateFloat3ForUniform=function(u,M,R,C){x._tempBuffer[0]=M,x._tempBuffer[1]=R,x._tempBuffer[2]=C,this.updateUniform(u,x._tempBuffer,3)},x.prototype._updateFloat4ForEffect=function(u,M,R,C,m,c){c===void 0&&(c=""),this._currentEffect.setFloat4(u+c,M,R,C,m)},x.prototype._updateFloat4ForUniform=function(u,M,R,C,m){x._tempBuffer[0]=M,x._tempBuffer[1]=R,x._tempBuffer[2]=C,x._tempBuffer[3]=m,this.updateUniform(u,x._tempBuffer,4)},x.prototype._updateMatrixForEffect=function(u,M){this._currentEffect.setMatr
1022ix(u,M)},x.prototype._updateMatrixForUniform=function(u,M){this._cacheMatrix(u,M)&&this.updateUniform(u,M.toArray(),16)},x.prototype._updateVector3ForEffect=function(u,M){this._currentEffect.setVector3(u,M)},x.prototype._updateVector3ForUniform=function(u,M){M.toArray(x._tempBuffer),this.updateUniform(u,x._tempBuffer,3)},x.prototype._updateVector4ForEffect=function(u,M){this._currentEffect.setVector4(u,M)},x.prototype._updateVector4ForUniform=function(u,M){M.toArray(x._tempBuffer),this.updateUniform(u,x._tempBuffer,4)},x.prototype._updateColor3ForEffect=function(u,M,R){R===void 0&&(R=""),this._currentEffect.setColor3(u+R,M)},x.prototype._updateColor3ForUniform=function(u,M){M.toArray(x._tempBuffer),this.updateUniform(u,x._tempBuffer,3)},x.prototype._updateColor4ForEffect=function(u,M,R,C){C===void 0&&(C=""),this._currentEffect.setColor4(u+C,M,R)},x.prototype._updateColor4ForUniform=function(u,M,R){M.toArray(x._tempBuffer),x._tempBuffer[3]=R,this.updateUniform(u,x._tempBuffer,4)},x.prototype.setTexture=function(u,M){this._currentEffect.setTexture(u,M)},x.prototype.updateUniformDirectly=function(u,M){this.updateUniform(u,M,M.length),this.update()},x.prototype.bindToEffect=function(u,M){this._currentEffect=u,!this._noUBO&&this._buffer&&(this._alreadyBound=!0,u.bindUniformBuffer(this._buffer,M))},x.prototype.dispose=function(){if(!this._noUBO){var u=this._engine._uniformBuffers,M=u.indexOf(this);M!==-1&&(u[M]=u[u.length-1],u.pop()),this._buffer&&this._engine._releaseBuffer(this._buffer)&&(this._buffer=null)}},x._MAX_UNIFORM_SIZE=256,x._tempBuffer=new Float32Array(x._MAX_UNIFORM_SIZE),x}())},function(Ae,v,f){f.d(v,"a",function(){return C});var B=f(1),_=f(3),x=f(0),u=f(9),M=f(29),R=f(48);M.a.AddNodeConstructor("Light_Type_3",function(m,c){return function(){return new C(m,x.e.Zero(),c)}});var C=function(m){function c(E,A,S){var g=m.call(this,E,S)||this;return g.groundColor=new u.a(0,0,0),g.direction=A||x.e.Up(),g}return Object(B.d)(c,m),c.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",4),this._uniformBuffer.addUniform("vLightGround",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},c.prototype.getClassName=function(){return"HemisphericLight"},c.prototype.setDirectionToTarget=function(E){return this.direction=x.e.Normalize(E.subtract(x.e.Zero())),this.direction},c.prototype.getShadowGenerator=function(){return null},c.prototype.transferToEffect=function(E,A){var S=x.e.Normalize(this.direction);return this._uniformBuffer.updateFloat4("vLightData",S.x,S.y,S.z,0,A),this._uniformBuffer.updateColor3("vLightGround",this.groundColor.scale(this.intensity),A),this},c.prototype.transferToNodeMaterialEffect=function(E,A){var S=x.e.Normalize(this.direction);return E.setFloat3(A,S.x,S.y,S.z),this},c.prototype.computeWorldMatrix=function(){return this._worldMatrix||(this._worldMatrix=x.a.Identity()),this._worldMatrix},c.prototype.getTypeID=function(){return R.a.LIGHTTYPEID_HEMISPHERICLIGHT},c.prototype.prepareLightSpecificDefines=function(E,A){E["HEMILIGHT"+A]=!0},Object(B.c)([Object(_.e)()],c.prototype,"groundColor",void 0),Object(B.c)([Object(_.o)()],c.prototype,"direction",void 0),c}(R.a)},function(Ae,v,f){f.d(v,"a",function(){return x});var B=f(1),_=f(0),x=function(u){function M(R,C){var m=u.call(this,R,C)||this;return m._normalMatrix=new _.a,m._storeEffectOnSubMeshes=!0,m}return Object(B.d)(M,u),M.prototype.getEffect=function(){return this._activeEffect},M.prototype.isReady=function(R,C){return!!R&&(!R.subMeshes||R.subMeshes.length===0||this.isReadyForSubMesh(R,R.subMeshes[0],C))},M.prototype._isReadyForSubMesh=function(R){var C=R._materialDefines;return!(this.checkReadyOnEveryCall||!R.effect||!C||C._renderId!==this.getScene().getRenderId())},M.prototype.bindOnlyWorldMatrix=function(R){this._activeEffect.setMatrix("world",R)},M.prototype.bindOnlyNormalMatrix=function(R){this._activeEffect.setMatrix("normalMatrix",R)},M.prototype.bind=function(R,C){C&&this.bindForSubMesh(R,C,C.subMeshes[0])},M.prototype._afterBind=function(R,C){C===void 0&&(C=null),u.prototype._afterBind.call(this,R),this.get
1022Scene()._cachedEffect=C},M.prototype._mustRebind=function(R,C,m){return m===void 0&&(m=1),R.isCachedMaterialInvalid(this,C,m)},M}(f(25).a)},function(Ae,v,f){f.d(v,"a",function(){return _});var B=f(1),_=function(x){function u(M){var R=x.call(this)||this;return R._buffer=M,R}return Object(B.d)(u,x),Object.defineProperty(u.prototype,"underlyingResource",{get:function(){return this._buffer},enumerable:!1,configurable:!0}),u}(f(89).a)},function(Ae,v,f){f.d(v,"a",function(){return B});var B=function(){function _(){this.references=0,this.capacity=0,this.is32Bits=!1}return Object.defineProperty(_.prototype,"underlyingResource",{get:function(){return null},enumerable:!1,configurable:!0}),_}()},function(Ae,v,f){f.d(v,"a",function(){return _});var B=f(64),_=function(){function x(){}return x.GetPlanes=function(u){for(var M=[],R=0;R<6;R++)M.push(new B.a(0,0,0,0));return x.GetPlanesToRef(u,M),M},x.GetNearPlaneToRef=function(u,M){var R=u.m;M.normal.x=R[3]+R[2],M.normal.y=R[7]+R[6],M.normal.z=R[11]+R[10],M.d=R[15]+R[14],M.normalize()},x.GetFarPlaneToRef=function(u,M){var R=u.m;M.normal.x=R[3]-R[2],M.normal.y=R[7]-R[6],M.normal.z=R[11]-R[10],M.d=R[15]-R[14],M.normalize()},x.GetLeftPlaneToRef=function(u,M){var R=u.m;M.normal.x=R[3]+R[0],M.normal.y=R[7]+R[4],M.normal.z=R[11]+R[8],M.d=R[15]+R[12],M.normalize()},x.GetRightPlaneToRef=function(u,M){var R=u.m;M.normal.x=R[3]-R[0],M.normal.y=R[7]-R[4],M.normal.z=R[11]-R[8],M.d=R[15]-R[12],M.normalize()},x.GetTopPlaneToRef=function(u,M){var R=u.m;M.normal.x=R[3]-R[1],M.normal.y=R[7]-R[5],M.normal.z=R[11]-R[9],M.d=R[15]-R[13],M.normalize()},x.GetBottomPlaneToRef=function(u,M){var R=u.m;M.normal.x=R[3]+R[1],M.normal.y=R[7]+R[5],M.normal.z=R[11]+R[9],M.d=R[15]+R[13],M.normalize()},x.GetPlanesToRef=function(u,M){x.GetNearPlaneToRef(u,M[0]),x.GetFarPlaneToRef(u,M[1]),x.GetLeftPlaneToRef(u,M[2]),x.GetRightPlaneToRef(u,M[3]),x.GetTopPlaneToRef(u,M[4]),x.GetBottomPlaneToRef(u,M[5])},x}()},function(Ae,v,f){f.d(v,"a",function(){return _});var B=f(2),_=function(){function x(){this.hoverCursor="",this.actions=new Array,this.isRecursive=!1}return Object.defineProperty(x,"HasTriggers",{get:function(){for(var u in x.Triggers)if(x.Triggers.hasOwnProperty(u))return!0;return!1},enumerable:!1,configurable:!0}),Object.defineProperty(x,"HasPickTriggers",{get:function(){for(var u in x.Triggers)if(x.Triggers.hasOwnProperty(u)){var M=parseInt(u);if(M>=B.a.ACTION_OnPickTrigger&&M<=B.a.ACTION_OnPickUpTrigger)return!0}return!1},enumerable:!1,configurable:!0}),x.HasSpecificTrigger=function(u){for(var M in x.Triggers)if(x.Triggers.hasOwnProperty(M)&&parseInt(M)===u)return!0;return!1},x.Triggers={},x}()},function(Ae,v,f){f.d(v,"a",function(){return R});var B=f(1),_=f(25),x=f(3),u=f(19),M=f(15),R=function(){function C(m){this._texture=null,this.diffuseBlendLevel=1,this.roughnessBlendLevel=1,this.bumpLevel=1,this._normalBlendMethod=_.a.MATERIAL_NORMALBLENDMETHOD_WHITEOUT,this._isEnabled=!1,this.isEnabled=!1,this._internalMarkAllSubMeshesAsTexturesDirty=m}return C.prototype._markAllSubMeshesAsTexturesDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty()},C.prototype.isReadyForSubMesh=function(m,c){var E=c.getEngine();return!(m._areTexturesDirty&&c.texturesEnabled&&E.getCaps().standardDerivatives&&this._texture&&u.a.DetailTextureEnabled&&!this._texture.isReady())},C.prototype.prepareDefines=function(m,c){if(this._isEnabled){m.DETAIL_NORMALBLENDMETHOD=this._normalBlendMethod;var E=c.getEngine();m._areTexturesDirty&&(E.getCaps().standardDerivatives&&this._texture&&u.a.DetailTextureEnabled&&this._isEnabled?(M.a.PrepareDefinesForMergedUV(this._texture,m,"DETAIL"),m.DETAIL_NORMALBLENDMETHOD=this._normalBlendMethod):m.DETAIL=!1)}else m.DETAIL=!1},C.prototype.bindForSubMesh=function(m,c,E){this._isEnabled&&(m.useUbo&&E&&m.isSync||this._texture&&u.a.DetailTextureEnabled&&(m.updateFloat4("vDetailInfos",this._texture.coordinatesIndex,this.diffuseBlendLevel,this.bumpLevel,this.roughnessBlendLevel),M.a.BindTextureMatrix(this._texture,m,"detail")),c.texturesEnabled&&this._texture&&u.a.DetailTextureEnabled&&m.setTexture("detailSampler",this._texture))},C.prototype.hasTexture=function(m){return this._texture===m},C.prototype.getActiveTextures=function(m){this._texture&&m.push(this._texture)},C.prototype.getAnimatables=function(m){this._texture&&this._texture.animations&&this._texture.animations.length>0&&m.push(this._texture)},C.prototype.dispose=function(m){var c;m&&((c=this._texture)===null||c===void 0||c.dispose())},C.prototype.getClassName=function(){return"DetailMap"},C.AddUniforms=function(m){m.push("vDetailInfos")},C.AddSamplers=function(m){m.push("detailSampler")},C.PrepareUniformBuffer=function(m){m.addUniform("vDetailInfos",4),m.addUniform("detailMatrix",16)},C.prototype.copyTo=function(m){x.a.Clone(function(){return m},this)},C.prototype.serialize=function(){return x.a.Serialize(this)},C.prototype.parse=function(m,c,E){var A=this;x.a.Parse(function(){return A},m,c,E)},Object(B.c)([Object(x.m)("detailTexture"),Object(x.b)("_markAllSubMeshesAsTexturesDirty")],C.prototype,"texture",void 0),Object(B.c)([Object(x.c)()],C.prototype,"diffuseBlendLevel",void 0),Object(B.c)([Object(x.c)()],C.prototype,"roughnessBlendLevel",void 0),Object(B.c)([Object(x.c)()],C.prototype,"bumpLevel",void 0),Object(B.c)([Object(x.c)(),Ob
1022ject(x.b)("_markAllSubMeshesAsTexturesDirty")],C.prototype,"normalBlendMethod",void 0),Object(B.c)([Object(x.c)(),Object(x.b)("_markAllSubMeshesAsTexturesDirty")],C.prototype,"isEnabled",void 0),C}()},function(Ae,v,f){var B="morphTargetsVertexGlobalDeclaration",_=`#ifdef MORPHTARGETS
1023uniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];
1024#endif`;f(5).a.IncludesShadersStore[B]=_},function(Ae,v,f){var B="morphTargetsVertexDeclaration",_=`#ifdef MORPHTARGETS
1025attribute vec3 position{X};
1026#ifdef MORPHTARGETS_NORMAL
1027attribute vec3 normal{X};
1028#endif
1029#ifdef MORPHTARGETS_TANGENT
1030attribute vec3 tangent{X};
1031#endif
1032#ifdef MORPHTARGETS_UV
1033attribute vec2 uv_{X};
1034#endif
1035#endif`;f(5).a.IncludesShadersStore[B]=_},function(Ae,v,f){f.d(v,"a",function(){return u});var B=f(25),_=f(4),x=f(2),u=function(){function M(R){this._vertexBuffers={},this._scene=R}return M.prototype._prepareBuffers=function(){if(!this._vertexBuffers[_.b.PositionKind]){var R=[];R.push(1,1),R.push(-1,1),R.push(-1,-1),R.push(1,-1),this._vertexBuffers[_.b.PositionKind]=new _.b(this._scene.getEngine(),R,_.b.PositionKind,!1,!1,2),this._buildIndexBuffer()}},M.prototype._buildIndexBuffer=function(){var R=[];R.push(0),R.push(1),R.push(2),R.push(0),R.push(2),R.push(3),this._indexBuffer=this._scene.getEngine().createIndexBuffer(R)},M.prototype._rebuild=function(){var R=this._vertexBuffers[_.b.PositionKind];R&&(R._rebuild(),this._buildIndexBuffer())},M.prototype._prepareFrame=function(R,C){R===void 0&&(R=null),C===void 0&&(C=null);var m=this._scene.activeCamera;return!!m&&!(!(C=C||m._postProcesses.filter(function(c){return c!=null}))||C.length===0||!this._scene.postProcessesEnabled)&&(C[0].activate(m,R,C!=null),!0)},M.prototype.directRender=function(R,C,m,c,E,A){C===void 0&&(C=null),m===void 0&&(m=!1),c===void 0&&(c=0),E===void 0&&(E=0),A===void 0&&(A=!1);for(var S=this._scene.getEngine(),g=0;g<R.length;g++){g<R.length-1?R[g+1].activate(this._scene.activeCamera,C):C?S.bindFramebuffer(C,c,void 0,void 0,m,E):A||S.restoreDefaultFramebuffer();var l=R[g],h=l.apply();h&&(l.onBeforeRenderObservable.notifyObservers(h),this._prepareBuffers(),S.bindBuffers(this._vertexBuffers,this._indexBuffer,h),S.drawElementsType(B.a.TriangleFillMode,0,6),l.onAfterRenderObservable.notifyObservers(h))}S.setDepthBuffer(!0),S.setDepthWrite(!0)},M.prototype._finalizeFrame=function(R,C,m,c,E){E===void 0&&(E=!1);var A=this._scene.activeCamera;if(A&&(c=c||A._postProcesses.filter(function(T){return T!=null})).length!==0&&this._scene.postProcessesEnabled){for(var S=this._scene.getEngine(),g=0,l=c.length;g<l;g++){var h=c[g];if(g<l-1?h._outputTexture=c[g+1].activate(A,C):C?(S.bindFramebuffer(C,m,void 0,void 0,E),h._outputTexture=C):(S.restoreDefaultFramebuffer(),h._outputTexture=null),R)break;var b=h.apply();b&&(h.onBeforeRenderObservable.notifyObservers(b),this._prepareBuffers(),S.bindBuffers(this._vertexBuffers,this._indexBuffer,b),S.drawElementsType(B.a.TriangleFillMode,0,6),h.onAfterRenderObservable.notifyObservers(b))}S.setDepthBuffer(!0),S.setDepthWrite(!0),S.setAlphaMode(x.a.ALPHA_DISABLE)}},M.prototype.dispose=function(){var R=this._vertexBuffers[_.b.PositionKind];R&&(R.dispose(),this._vertexBuffers[_.b.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null)},M}()},function(Ae,v,f){f.d(v,"a",function(){return _}),f.d(v,"b",function(){return x});var B=f(148),_=function(){},x=function(){function u(M){this._useSceneAutoClearSetup=!1,this._renderingGroups=new Array,this._autoClearDepthStencil={},this._customOpaqueSortCompareFn={},this._customAlphaTestSortCompareFn={},this._customTransparentSortCompareFn={},this._renderingGroupInfo=new _,this._scene=M;for(var R=u.MIN_RENDERINGGROUPS;R<u.MAX_RENDERINGGROUPS;R++)this._autoClearDepthStencil[R]={autoClear:!0,depth:!0,stencil:!0}}return u.prototype._clearDepthStencilBuffer=function(M,R){M===void 0&&(M=!0),R===void 0&&(R=!0),this._depthStencilBufferAlreadyCleaned||(this._scene.getEngine().clear(null,!1,M,R),this._depthStencilBufferAlreadyCleaned=!0)},u.prototype.render=function(M,R,C,m){var c=this._renderingGroupInfo;if(c.scene=this._scene,c.camera=this._scene.activeCamera,this._scene.spriteManagers&&m)for(var E=0;E<this._scene.spriteManagers.length;E++){var A=this._scene.spriteManagers[E];this.dispatchSprites(A)}for(E=u.MIN_RENDERINGGROUPS;E<u.MAX_RENDERINGGROUPS;E++){this._depthStencilBufferAlreadyCleaned=E===u.MIN_RENDERINGGROUPS;var S=this._renderingGroups[E];if(S){var g=Math.pow(2,E);if(c.renderingGroupId=E,this._scene.onBeforeRenderingGroupObservable.notifyObservers(c,g),u.AUTOCLEAR){var l=this._useSceneAutoClearSetup?this._scene.getAutoClearDepthStencilSetup(E):this._autoClearDepthStencil[E];l&&l.autoClear&&this._clearDepthStencilBuffer(l.depth,l.stencil)}for(var h=0,b=this._scene._beforeRenderingGroupDrawStage;h<b.length;h++)b[h].action(E);S.render(M,m,C,R);for(var T=0,D=this._scene._afterRenderingGroupDrawStage;T<D.length;T++)D[T].action(E);this._scene.onAfterRenderingGroupObservable.notifyObservers(c,g)}}},u.prototype.reset=function(){for(var M=u.MIN_RENDERINGGROUPS;M<u.MAX_RENDERINGGROUPS;M++){var R=this._renderingGroups[M];R&&R.prepare()}},u.prototype.dispose=function(){this.freeRenderingGroups(),this._renderingGroups.length=0,this._renderingGroupInfo=null},u.prototype.freeRenderingGroups=function(){for(var M=u.MIN_RENDERINGGROUPS;M<u.MAX_RENDERINGGROUPS;M++){var R=this._renderingGroups[M];R&&R.dispose()}},u.prototype._prepareRenderingGroup=function(M){this._renderingGroups[M]===void 0&&(this._renderingGroups[M]=new B.a(M,this._scene,this._customOpaqueSortCompareFn[M],this._customAlphaTestSortCompareFn[M],this._customTransparentSortCompareFn[M]))},u.prototype.dispatchSprites=function(M){var R=M.renderingGroupId||0;this._prepareRenderingGroup(R),this._renderingGroups[R].dispatchSprites(M)},u.prototype.dispatchParticles=function(M){var R=M.renderingGroupId||0;this._prepareRenderingGroup(R),this._renderingGroups[R].dispatchParticles(M)},u.prototype.dispatch=function(M,R,C){R===void 0&&(R=M.getMesh());var m=R.renderingGroupId||0;this._prepareRenderingGroup(m),this._renderingGroups[m].dispatch(M,R,C)},u.prototype.setRenderingOrder=function(M,R,C,m){if(R===void 0&&(R=null),C===void 0&&(C=null),m===void 0&&(m=null),this._customOpaqueSortCompareFn[M]=R,this._customAlphaTestSortCompareFn[M]=C,this._customTransparentSortCompareFn[M]=m,this._renderingGroups[M]){var c=this._renderingGroups[M];
1035c.opaqueSortCompareFn=this._customOpaqueSortCompareFn[M],c.alphaTestSortCompareFn=this._customAlphaTestSortCompareFn[M],c.transparentSortCompareFn=this._customTransparentSortCompareFn[M]}},u.prototype.setRenderingAutoClearDepthStencil=function(M,R,C,m){C===void 0&&(C=!0),m===void 0&&(m=!0),this._autoClearDepthStencil[M]={autoClear:R,depth:C,stencil:m}},u.prototype.getAutoClearDepthStencilSetup=function(M){return this._autoClearDepthStencil[M]},u.MAX_RENDERINGGROUPS=4,u.MIN_RENDERINGGROUPS=0,u.AUTOCLEAR=!0,u}()},function(Ae,v,f){f.d(v,"a",function(){return M});var B=f(0),_=f(7),x=f(82),u=f(72);_.a.ExtrudeShape=function(R,C,m,c,E,A,S,g,l,h){S===void 0&&(S=null);var b={shape:C,path:m,scale:c,rotation:E,cap:A===0?0:A||_.a.NO_CAP,sideOrientation:l,instance:h,updatable:g};return M.ExtrudeShape(R,b,S)},_.a.ExtrudeShapeCustom=function(R,C,m,c,E,A,S,g,l,h,b,T){var D={shape:C,path:m,scaleFunction:c,rotationFunction:E,ribbonCloseArray:A,ribbonClosePath:S,cap:g===0?0:g||_.a.NO_CAP,sideOrientation:b,instance:T,updatable:h};return M.ExtrudeShapeCustom(R,D,l)};var M=function(){function R(){}return R.ExtrudeShape=function(C,m,c){c===void 0&&(c=null);var E=m.path,A=m.shape,S=m.scale||1,g=m.rotation||0,l=m.cap===0?0:m.cap||_.a.NO_CAP,h=m.updatable,b=_.a._GetDefaultSideOrientation(m.sideOrientation),T=m.instance||null,D=m.invertUV||!1;return R._ExtrudeShapeGeneric(C,A,E,S,g,null,null,!1,!1,l,!1,c,!!h,b,T,D,m.frontUVs||null,m.backUVs||null)},R.ExtrudeShapeCustom=function(C,m,c){c===void 0&&(c=null);var E=m.path,A=m.shape,S=m.scaleFunction||function(){return 1},g=m.rotationFunction||function(){return 0},l=m.ribbonCloseArray||!1,h=m.ribbonClosePath||!1,b=m.cap===0?0:m.cap||_.a.NO_CAP,T=m.updatable,D=_.a._GetDefaultSideOrientation(m.sideOrientation),w=m.instance,N=m.invertUV||!1;return R._ExtrudeShapeGeneric(C,A,E,null,null,S,g,l,h,b,!0,c,!!T,D,w||null,N,m.frontUVs||null,m.backUVs||null)},R._ExtrudeShapeGeneric=function(C,m,c,E,A,S,g,l,h,b,T,D,w,N,I,V,W,j){var ne,te,de=function(ee,K,$,L,G,Q,oe,re,Y,k){for(var H=$.getTangents(),Z=$.getNormals(),X=$.getBinormals(),q=$.getDistances(),he=0,ge=k&&re?re:function(){return Q!==null?Q:0},me=k&&oe?oe:function(){return G!==null?G:1},_e=Y===_.a.NO_CAP||Y===_.a.CAP_END?0:2,be=B.c.Matrix[0],Ce=0;Ce<K.length;Ce++){for(var ye=new Array,Be=ge(Ce,q[Ce]),Ge=me(Ce,q[Ce]),Xe=0;Xe<ee.length;Xe++){B.a.RotationAxisToRef(H[Ce],he,be);var He=H[Ce].scale(ee[Xe].z).add(Z[Ce].scale(ee[Xe].x)).add(X[Ce].scale(ee[Xe].y)),We=ye[Xe]?ye[Xe]:B.e.Zero();B.e.TransformCoordinatesToRef(He,be,We),We.scaleInPlace(Ge).addInPlace(K[Ce]),ye[Xe]=We}L[_e]=ye,he+=Be,_e++}var Ze=function(ze){var it,et=Array(),lt=B.e.Zero();for(it=0;it<ze.length;it++)lt.addInPlace(ze[it]);for(lt.scaleInPlace(1/ze.length),it=0;it<ze.length;it++)et.push(lt);return et};switch(Y){case _.a.NO_CAP:break;case _.a.CAP_START:L[0]=Ze(L[2]),L[1]=L[2];break;case _.a.CAP_END:L[_e]=L[_e-1],L[_e+1]=Ze(L[_e-1]);break;case _.a.CAP_ALL:L[0]=Ze(L[2]),L[1]=L[2],L[_e]=L[_e-1],L[_e+1]=Ze(L[_e-1])}return L};if(I){var pe=I._creationDataStorage;return ne=pe.path3D.update(c),te=de(m,c,pe.path3D,pe.pathArray,E,A,S,g,pe.cap,T),I=_.a.CreateRibbon("",te,!1,!1,0,D||void 0,!1,0,I)}te=de(m,c,ne=new u.g(c),new Array,E,A,S,g,b=b<0||b>3?0:b,T);var ae=x.a.CreateRibbon(C,{pathArray:te,closeArray:l,closePath:h,updatable:w,sideOrientation:N,invertUV:V,frontUVs:W||void 0,backUVs:j||void 0},D);return ae._creationDataStorage.pathArray=te,ae._creationDataStorage.path3D=ne,ae._creationDataStorage.cap=b,ae},R}()},function(Ae,v,f){f.d(v,"b",function(){return c}),f.d(v,"a",function(){return E});var B=f(1),_=f(9),x=f(4),u=f(7),M=f(151),R=f(25),C=f(73),m=f(15),c=(f(166),f(167),function(A){function S(g,l,h,b,T,D,w){l===void 0&&(l=null),h===void 0&&(h=null),b===void 0&&(b=null);var N=A.call(this,g,l,h,b,T)||this;N.useVertexColor=D,N.useVertexAlpha=w,N.color=new _.a(1,1,1),N.alpha=1,b&&(N.color=b.color.clone(),N.alpha=b.alpha,N.useVertexColor=b.useVertexColor,N.useVertexAlpha=b.useVertexAlpha),N.intersectionThreshold=.1;var I={attributes:[x.b.PositionKind,"world0","world1","world2","world3"],uniforms:["vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","world","viewProjection"],needAlphaBlending:!0,defines:[]};return w===!1&&(I.needAlphaBlending=!1),D?(I.defines.push("#define VERTEXCOLOR"),I.attributes.push(x.b.ColorKind)):(I.uniforms.push("color"),N.color4=new _.b),N._colorShader=new C.a("colorShader",N.getScene(),"color",I),N}return Object(B.d)(S,A),S.prototype._addClipPlaneDefine=function(g){var l="#define "+g;this._colorShader.options.defines.indexOf(l)===-1&&this._colorShader.options.defines.push(l)},S.prototype._removeClipPlaneDefine=function(g){var l="#define "+g,h=this._colorShader.options.defines.indexOf(l);h!==-1&&this._colorShader.options.defines.splice(h,1)},S.prototype.isReady=function(){var g=this.getScene();return g.clipPlane?this._addClipPlaneDefine("CLIPPLANE"):this._removeClipPlaneDefine("CLIPPLANE"),g.clipPlane2?this._addClipPlaneDefine("CLIPPLANE2"):this._removeClipPlaneDefine("CLIPPLANE2"),g.clipPlane3?this._addClipPlaneDefine("CLIPPLANE3"):this._removeClipPlaneDefine("CLIPPLANE3"),g.clipPlane4?this._addClipPlaneDefine("CLIPPLANE4"):this._removeClipPlaneDefine("CLIPPLANE4"),g.clipPlane5?this._addClipPlaneDefine("CLIPPLANE5"):this._removeClipPlaneDefine("CLIPPLANE5"),g.clipPlane6?this._addClipPlaneDefine("CLIPPLANE6"):this._removeClipPlaneDefine("CLIPPLANE6"),!!this._colorShader.isReady(this)&&A.prototype.isReady.call(this)},S.prototype.getClassName=function(){return"LinesMesh"},Object.defineProperty(S.prototype,"material",{get:function(){return this._colorShader},set:function(g){}
1035,enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"checkCollisions",{get:function(){return!1},enumerable:!1,configurable:!0}),S.prototype._bind=function(g,l,h){if(!this._geometry)return this;var b=this._colorShader.getEffect(),T=this.isUnIndexed?null:this._geometry.getIndexBuffer();if(this._geometry._bind(b,T),!this.useVertexColor){var D=this.color,w=D.r,N=D.g,I=D.b;this.color4.set(w,N,I,this.alpha),this._colorShader.setColor4("color",this.color4)}return m.a.BindClipPlane(b,this.getScene()),this},S.prototype._draw=function(g,l,h){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;var b=this.getScene().getEngine();return this._unIndexed?b.drawArraysType(R.a.LineListDrawMode,g.verticesStart,g.verticesCount,h):b.drawElementsType(R.a.LineListDrawMode,g.indexStart,g.indexCount,h),this},S.prototype.dispose=function(g){this._colorShader.dispose(!1,!1,!0),A.prototype.dispose.call(this,g)},S.prototype.clone=function(g,l,h){return l===void 0&&(l=null),new S(g,this.getScene(),l,this,h)},S.prototype.createInstance=function(g){return new E(g,this)},S}(u.a)),E=function(A){function S(g,l){var h=A.call(this,g,l)||this;return h.intersectionThreshold=l.intersectionThreshold,h}return Object(B.d)(S,A),S.prototype.getClassName=function(){return"InstancedLinesMesh"},S}(M.a)},function(Ae,v,f){f.r(v),f.d(v,"AxesViewer",function(){return R}),f.d(v,"BoneAxesViewer",function(){return c}),f.d(v,"DebugLayerTab",function(){return B}),f.d(v,"DebugLayer",function(){return l}),f.d(v,"PhysicsViewer",function(){return V}),f.d(v,"RayHelper",function(){return j}),f.d(v,"SkeletonViewer",function(){return K});var B,_=f(0),x=f(30),u=f(75),M=f(9),R=function(){function $(L,G,Q,oe,re,Y){if(G===void 0&&(G=1),Q===void 0&&(Q=2),this._scaleLinesFactor=4,this._instanced=!1,this.scene=null,this.scaleLines=1,this.scaleLines=G,!oe){var k=new x.a("",L);k.disableLighting=!0,k.emissiveColor=M.a.Red().scale(.5),oe=u.a._CreateArrow(L,k)}if(!re){var H=new x.a("",L);H.disableLighting=!0,H.emissiveColor=M.a.Green().scale(.5),re=u.a._CreateArrow(L,H)}if(!Y){var Z=new x.a("",L);Z.disableLighting=!0,Z.emissiveColor=M.a.Blue().scale(.5),Y=u.a._CreateArrow(L,Z)}this._xAxis=oe,this._xAxis.scaling.setAll(this.scaleLines*this._scaleLinesFactor),this._yAxis=re,this._yAxis.scaling.setAll(this.scaleLines*this._scaleLinesFactor),this._zAxis=Y,this._zAxis.scaling.setAll(this.scaleLines*this._scaleLinesFactor),Q!=null&&($._SetRenderingGroupId(this._xAxis,Q),$._SetRenderingGroupId(this._yAxis,Q),$._SetRenderingGroupId(this._zAxis,Q)),this.scene=L,this.update(new _.e,_.e.Right(),_.e.Up(),_.e.Forward())}return Object.defineProperty($.prototype,"xAxis",{get:function(){return this._xAxis},enumerable:!1,configurable:!0}),Object.defineProperty($.prototype,"yAxis",{get:function(){return this._yAxis},enumerable:!1,configurable:!0}),Object.defineProperty($.prototype,"zAxis",{get:function(){return this._zAxis},enumerable:!1,configurable:!0}),$.prototype.update=function(L,G,Q,oe){this._xAxis.position.copyFrom(L),this._xAxis.setDirection(G),this._xAxis.scaling.setAll(this.scaleLines*this._scaleLinesFactor),this._yAxis.position.copyFrom(L),this._yAxis.setDirection(Q),this._yAxis.scaling.setAll(this.scaleLines*this._scaleLinesFactor),this._zAxis.position.copyFrom(L),this._zAxis.setDirection(oe),this._zAxis.scaling.setAll(this.scaleLines*this._scaleLinesFactor)},$.prototype.createInstance=function(){var L=u.a._CreateArrowInstance(this.scene,this._xAxis),G=u.a._CreateArrowInstance(this.scene,this._yAxis),Q=u.a._CreateArrowInstance(this.scene,this._zAxis),oe=new $(this.scene,this.scaleLines,null,L,G,Q);return oe._instanced=!0,oe},$.prototype.dispose=function(){this._xAxis&&this._xAxis.dispose(!1,!this._instanced),this._yAxis&&this._yAxis.dispose(!1,!this._instanced),this._zAxis&&this._zAxis.dispose(!1,!this._instanced),this.scene=null},$._SetRenderingGroupId=function(L,G){L.getChildMeshes().forEach(function(Q){Q.renderingGroupId=G})},$}(),C=f(1),m=f(23),c=function($){function L(G,Q,oe,re){re===void 0&&(re=1);var Y=$.call(this,G,re)||this;return Y.pos=_.e.Zero(),Y.xaxis=_.e.Zero(),Y.yaxis=_.e.Zero(),Y.zaxis=_.e.Zero(),Y.mesh=oe,Y.bone=Q,Y}return Object(C.d)(L,$),L.prototype.update=function(){if(this.mesh&&this.bone){var G=this.bone;G._markAsDirtyAndCompose(),G.getAbsolutePositionToRef(this.mesh,this.pos),G.getDirectionToRef(m.a.X,this.mesh,this.xaxis),G.getDirectionToRef(m.a.Y,this.mesh,this.yaxis),G.getDirectionToRef(m.a.Z,this.mesh,this.zaxis),$.prototype.update.call(this,this.pos,this.xaxis,this.yaxis,this.zaxis)}},L.prototype.dispose=function(){this.mesh&&(this.mesh=null,this.bone=null,$.prototype.dispose.call(this))},L}(R),E=f(12),A=f(6),S=f(20),g=f(13);
1035Object.defineProperty(S.a.prototype,"debugLayer",{get:function(){return this._debugLayer||(this._debugLayer=new l(this)),this._debugLayer},enumerable:!0,configurable:!0}),function($){$[$.Properties=0]="Properties",$[$.Debug=1]="Debug",$[$.Statistics=2]="Statistics",$[$.Tools=3]="Tools",$[$.Settings=4]="Settings"}(B||(B={}));var l=function(){function $(L){var G=this;this.BJSINSPECTOR=this._getGlobalInspector(),this._scene=L,this._scene.onDisposeObservable.add(function(){G._scene._debugLayer&&G._scene._debugLayer.hide()})}return Object.defineProperty($.prototype,"onPropertyChangedObservable",{get:function(){return this.BJSINSPECTOR&&this.BJSINSPECTOR.Inspector?this.BJSINSPECTOR.Inspector.OnPropertyChangedObservable:(this._onPropertyChangedObservable||(this._onPropertyChangedObservable=new A.c),this._onPropertyChangedObservable)},enumerable:!1,configurable:!0}),$.prototype._createInspector=function(L){if(!this.isVisible()){if(this._onPropertyChangedObservable){for(var G=0,Q=this._onPropertyChangedObservable.observers;G<Q.length;G++){var oe=Q[G];this.BJSINSPECTOR.Inspector.OnPropertyChangedObservable.add(oe)}this._onPropertyChangedObservable.clear(),this._onPropertyChangedObservable=void 0}var re=Object(C.a)({overlay:!1,showExplorer:!0,showInspector:!0,embedMode:!1,handleResize:!0,enablePopup:!0},L);this.BJSINSPECTOR=this.BJSINSPECTOR||this._getGlobalInspector(),this.BJSINSPECTOR.Inspector.Show(this._scene,re)}},$.prototype.select=function(L,G){this.BJSINSPECTOR&&(G&&(Object.prototype.toString.call(G)=="[object String]"?this.BJSINSPECTOR.Inspector.MarkLineContainerTitleForHighlighting(G):this.BJSINSPECTOR.Inspector.MarkMultipleLineContainerTitlesForHighlighting(G)),this.BJSINSPECTOR.Inspector.OnSelectionChangeObservable.notifyObservers(L))},$.prototype._getGlobalInspector=function(){return typeof INSPECTOR<"u"?INSPECTOR:typeof BABYLON<"u"&&BABYLON.Inspector!==void 0?BABYLON:void 0},$.prototype.isVisible=function(){return this.BJSINSPECTOR&&this.BJSINSPECTOR.Inspector.IsVisible},$.prototype.hide=function(){this.BJSINSPECTOR&&this.BJSINSPECTOR.Inspector.Hide()},$.prototype.setAsActiveScene=function(){this.BJSINSPECTOR&&this.BJSINSPECTOR.Inspector._SetNewScene(this._scene)},$.prototype.show=function(L){var G=this;return new Promise(function(Q,oe){if(G.BJSINSPECTOR===void 0){var re=L&&L.inspectorURL?L.inspectorURL:$.InspectorURL;E.b.LoadScript(re,function(){G._createInspector(L),Q(G)})}else G._createInspector(L),Q(G)})},$.InspectorURL="https://unpkg.com/babylonjs-inspector@"+g.a.Version+"/babylon.inspector.bundle.js",$}(),h=f(7),b=f(63),T=f(45),D=f(22),w=f(32),N=f(36),I=f(53),V=function(){function $(L){this._impostors=[],this._meshes=[],this._numMeshes=0,this._debugMeshMeshes=new Array,this._scene=L||D.a.LastCreatedScene;var G=this._scene.getPhysicsEngine();G&&(this._physicsEnginePlugin=G.getPhysicsPlugin()),this._utilityLayer=new N.a(this._scene,!1),this._utilityLayer.pickUtilitySceneFirst=!1,this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil=!0}return $.prototype._updateDebugMeshes=function(){for(var L=this._physicsEnginePlugin,G=0;G<this._numMeshes;G++){var Q=this._impostors[G];if(Q)if(Q.isDisposed)this.hideImpostor(this._impostors[G--]);else{if(Q.type===w.a.MeshImpostor)continue;var oe=this._meshes[G];oe&&L&&L.syncMeshWithImpostor(oe,Q)}}},$.prototype.showImpostor=function(L,G){if(!this._scene)return null;for(var Q=0;Q<this._numMeshes;Q++)if(this._impostors[Q]==L)return null;var oe=this._getDebugMesh(L,G);return oe&&(this._impostors[this._numMeshes]=L,this._meshes[this._numMeshes]=oe,this._numMeshes===0&&(this._renderFunction=this._updateDebugMeshes.bind(this),this._scene.registerBeforeRender(this._renderFunction)),this._numMeshes++),oe},$.prototype.hideImpostor=function(L){if(L&&this._scene&&this._utilityLayer){for(var G=!1,Q=this._utilityLayer.utilityLayerScene,oe=0;oe<this._numMeshes;oe++)if(this._impostors[oe]==L){var re=this._meshes[oe];if(!re)continue;Q.removeMesh(re),re.dispose();var Y=this._debugMeshMeshes.indexOf(re);Y>-1&&this._debugMeshMeshes.splice(Y,1),this._numMeshes--,this._numMeshes>0?(this._meshes[oe]=this._meshes[this._numMeshes],this._impostors[oe]=this._impostors[this._numMeshes],this._meshes[this._numMeshes]=null,this._impostors[this._numMeshes]=null):(this._meshes[0]=null,this._impostors[0]=null),G=!0;break}G&&this._numMeshes===0&&this._scene.unregisterBeforeRender(this._renderFunction)}},$.prototype._getDebugMaterial=function(L){return this._debugMaterial||(this._debugMaterial=new x.a("",L),this._debugMaterial.wireframe=!0,this._debugMaterial.emissiveColor=M.a.White(),this._debugMaterial.disableLighting=!0),this._debugMaterial},$.prototype._getDebugBoxMesh=function(L){return this._debugBoxMesh||(this._debugBoxMesh=b.a.CreateBox("physicsBodyBoxViewMesh",{size:1},L),this._debugBoxMesh.rotationQuaternion=_.b.Identity(),this._debugBoxMesh.material=this._getDebugMaterial(L),this._debugBoxMesh.setEnabled(!1)),this._debugBoxMesh.createInstance("physicsBodyBoxViewInstance")},$.prototype._getDebugSphereMesh=function(L){return this._debugSphereMesh||(this._debugSphereMesh=T.a.CreateSphere("physicsBodySphereViewMesh",{diameter:1},L),this._debugSphereMesh.rotationQuaternion=_.b.Identity(),this._debugSphereMesh.material=this._getDebugMaterial(L),this._debugSphereMesh.setEnabled(!1)),this._debugSphereMesh.createInstance("physicsBodyBoxViewInstance")}
1035,$.prototype._getDebugCylinderMesh=function(L){return this._debugCylinderMesh||(this._debugCylinderMesh=I.a.CreateCylinder("physicsBodyCylinderViewMesh",{diameterTop:1,diameterBottom:1,height:1},L),this._debugCylinderMesh.rotationQuaternion=_.b.Identity(),this._debugCylinderMesh.material=this._getDebugMaterial(L),this._debugCylinderMesh.setEnabled(!1)),this._debugCylinderMesh.createInstance("physicsBodyBoxViewInstance")},$.prototype._getDebugMeshMesh=function(L,G){var Q=new h.a(L.name,G,null,L);return Q.position=_.e.Zero(),Q.setParent(L),Q.material=this._getDebugMaterial(G),this._debugMeshMeshes.push(Q),Q},$.prototype._getDebugMesh=function(L,G){var Q=this;if(!this._utilityLayer||G&&G.parent&&G.parent.physicsImpostor)return null;var oe=null,re=this._utilityLayer.utilityLayerScene;switch(L.type){case w.a.BoxImpostor:oe=this._getDebugBoxMesh(re),L.getBoxSizeToRef(oe.scaling);break;case w.a.SphereImpostor:oe=this._getDebugSphereMesh(re);var Y=L.getRadius();oe.scaling.x=2*Y,oe.scaling.y=2*Y,oe.scaling.z=2*Y;break;case w.a.MeshImpostor:G&&(oe=this._getDebugMeshMesh(G,re));break;case w.a.NoImpostor:G&&G.getChildMeshes().filter(function(H){return H.physicsImpostor?1:0}).forEach(function(H){Q._getDebugBoxMesh(re).parent=H});break;
1035case w.a.CylinderImpostor:oe=this._getDebugCylinderMesh(re);var k=L.object.getBoundingInfo();oe.scaling.x=k.boundingBox.maximum.x-k.boundingBox.minimum.x,oe.scaling.y=k.boundingBox.maximum.y-k.boundingBox.minimum.y,oe.scaling.z=k.boundingBox.maximum.z-k.boundingBox.minimum.z}return oe},$.prototype.dispose=function(){for(var L=this._numMeshes,G=0;G<L;G++)this.hideImpostor(this._impostors[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)},$}(),W=f(40),j=function(){function $(L){this.ray=L}return $.CreateAndShow=function(L,G,Q){var oe=new $(L);return oe.show(G,Q),oe},$.prototype.show=function(L,G){if(!this._renderFunction&&this.ray){var Q=this.ray;this._renderFunction=this._render.bind(this),this._scene=L,this._renderPoints=[Q.origin,Q.origin.add(Q.direction.scale(Q.length))],this._renderLine=h.a.CreateLines("ray",this._renderPoints,L,!0),this._renderLine.isPickable=!1,this._renderFunction&&this._scene.registerBeforeRender(this._renderFunction)}G&&this._renderLine&&this._renderLine.color.copyFrom(G)},$.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=[])},$.prototype._render=function(){var L=this.ray;if(L){var G=this._renderPoints[1],Q=Math.min(L.length,1e6);G.copyFrom(L.direction),G.scaleInPlace(Q),G.addInPlace(L.origin),this._renderPoints[0].copyFrom(L.origin),h.a.CreateLines("ray",this._renderPoints,this._scene,!0,this._renderLine)}},$.prototype.attachToMesh=function(L,G,Q,oe){var re=this;this._attachedToMesh=L;var Y=this.ray;Y&&(Y.direction||(Y.direction=_.e.Zero()),Y.origin||(Y.origin=_.e.Zero()),oe&&(Y.length=oe),Q||(Q=_.e.Zero()),G||(G=new _.e(0,0,-1)),this._scene||(this._scene=L.getScene()),this._meshSpaceDirection?(this._meshSpaceDirection.copyFrom(G),this._meshSpaceOrigin.copyFrom(Q)):(this._meshSpaceDirection=G.clone(),this._meshSpaceOrigin=Q.clone()),this._onAfterRenderObserver||(this._onAfterRenderObserver=this._scene.onBeforeRenderObservable.add(function(){return re._updateToMesh()}),this._onAfterStepObserver=this._scene.onAfterStepObservable.add(function(){return re._updateToMesh()})),this._attachedToMesh.computeWorldMatrix(!0),this._updateToMesh())},$.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)},$.prototype._updateToMesh=function(){var L=this.ray;this._attachedToMesh&&L&&(this._attachedToMesh._isDisposed?this.detachFromMesh():(this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection,L.direction),_.e.TransformCoordinatesToRef(this._meshSpaceOrigin,this._attachedToMesh.getWorldMatrix(),L.origin)))},$.prototype.dispose=function(){this.hide(),this.detachFromMesh(),this.ray=null},$}(),ne=f(25),te=f(73),de=f(62),pe=f(4),ae=f(5),ee=f(97),K=function(){function $(L,G,Q,oe,re,Y){var k,H,Z,X,q,he,ge,me,_e,be,Ce,ye,Be,Ge;oe===void 0&&(oe=!0),re===void 0&&(re=3),Y===void 0&&(Y={}),this.skeleton=L,this.mesh=G,this.autoUpdateBonesMatrices=oe,this.renderingGroupId=re,this.options=Y,this.color=M.a.White(),this._debugLines=new Array,this._localAxes=null,this._isEnabled=!1,this._obs=null,this._scene=Q,this._ready=!1,Y.pauseAnimations=(k=Y.pauseAnimations)===null||k===void 0||k,Y.returnToRest=(H=Y.returnToRest)!==null&&H!==void 0&&H,Y.displayMode=(Z=Y.displayMode)!==null&&Z!==void 0?Z:$.DISPLAY_LINES,Y.displayOptions=(X=Y.displayOptions)!==null&&X!==void 0?X:{},Y.displayOptions.midStep=(q=Y.displayOptions.midStep)!==null&&q!==void 0?q:.235,Y.displayOptions.midStepFactor=(he=Y.displayOptions.midStepFactor)!==null&&he!==void 0?he:.155,Y.displayOptions.sphereBaseSize=(ge=Y.displayOptions.sphereBaseSize)!==null&&ge!==void 0?ge:.15,Y.displayOptions.sphereScaleUnit=(me=Y.displayOptions.sphereScaleUnit)!==null&&me!==void 0?me:2,Y.displayOptions.sphereFactor=(_e=Y.displayOptions.sphereFactor)!==null&&_e!==void 0?_e:.865,Y.displayOptions.spurFollowsChild=(be=Y.displayOptions.spurFollowsChild)!==null&&be!==void 0&&be,Y.displayOptions.showLocalAxes=(Ce=Y.displayOptions.showLocalAxes)!==null&&Ce!==void 0&&Ce,Y.displayOptions.localAxesSize=(ye=Y.displayOptions.localAxesSize)!==null&&ye!==void 0?ye:.075,Y.computeBonesUsingShaders=(Be=Y.computeBonesUsingShaders)===null||Be===void 0||Be,Y.useAllBones=(Ge=Y.useAllBones)===null||Ge===void 0||Ge;var Xe=G.getVerticesData(pe.b.MatricesIndicesKind),He=G.getVerticesData(pe.b.MatricesWeightsKind);if(this._boneIndices=new Set,!Y.useAllBones&&Xe&&He)for(var We=0;We<Xe.length;++We){var Ze=Xe[We];He[We]!==0&&this._boneIndices.add(Ze)}this._utilityLayer=new N.a(this._scene,!1),this._utilityLayer.pickUtilitySceneFirst=!1,this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil=!0;var ze=this.options.displayMode||0;ze>$.DISPLAY_SPHERE_AND_SPURS&&(ze=$.DISPLAY_LINES),this.displayMode=ze,this.update(),this._bindObs()}return $.CreateBoneWeightShader=function(L,G){var Q,oe,re,Y,k,H,Z=L.skeleton,X=(Q=L.colorBase)!==null&&Q!==void 0?Q:M.a.Black(),q=(oe=L.colorZero)!==null&&oe!==void 0?oe:M.a.Blue(
1035),he=(re=L.colorQuarter)!==null&&re!==void 0?re:M.a.Green(),ge=(Y=L.colorHalf)!==null&&Y!==void 0?Y:M.a.Yellow(),me=(k=L.colorFull)!==null&&k!==void 0?k:M.a.Red(),_e=(H=L.targetBoneIndex)!==null&&H!==void 0?H:0;ae.a.ShadersStore["boneWeights:"+Z.name+"VertexShader"]=`precision highp float;
1036
1037        attribute vec3 position;
1038        attribute vec2 uv;
1039
1040        uniform mat4 view;
1041        uniform mat4 projection;
1042        uniform mat4 worldViewProjection;
1043
1044        #include<bonesDeclaration>
1045        #if NUM_BONE_INFLUENCERS == 0
1046            attribute vec4 matricesIndices;
1047            attribute vec4 matricesWeights;
1048        #endif
1049
1050        #include<instancesDeclaration>
1051
1052        varying vec3 vColor;
1053
1054        uniform vec3 colorBase;
1055        uniform vec3 colorZero;
1056        uniform vec3 colorQuarter;
1057        uniform vec3 colorHalf;
1058        uniform vec3 colorFull;
1059
1060        uniform float targetBoneIndex;
1061
1062        void main() {
1063            vec3 positionUpdated = position;
1064
1065            #include<instancesVertex>
1066            #include<bonesVertex>
1067
1068            vec4 worldPos = finalWorld * vec4(positionUpdated, 1.0);
1069
1070            vec3 color = colorBase;
1071            float totalWeight = 0.;
1072            if(matricesIndices[0] == targetBoneIndex && matricesWeights[0] > 0.){
1073                totalWeight += matricesWeights[0];
1074            }
1075            if(matricesIndices[1] == targetBoneIndex && matricesWeights[1] > 0.){
1076                totalWeight += matricesWeights[1];
1077            }
1078            if(matricesIndices[2] == targetBoneIndex && matricesWeights[2] > 0.){
1079                totalWeight += matricesWeights[2];
1080            }
1081            if(matricesIndices[3] == targetBoneIndex && matricesWeights[3] > 0.){
1082                totalWeight += matricesWeights[3];
1083            }
1084
1085            color = mix(color, colorZero, smoothstep(0., 0.25, totalWeight));
1086            color = mix(color, colorQuarter, smoothstep(0.25, 0.5, totalWeight));
1087            color = mix(color, colorHalf, smoothstep(0.5, 0.75, totalWeight));
1088            color = mix(color, colorFull, smoothstep(0.75, 1.0, totalWeight));
1089            vColor = color;
1090
1091        gl_Position = projection * view * worldPos;
1092        }`,ae.a.ShadersStore["boneWeights:"+Z.name+"FragmentShader"]=`
1093            precision highp float;
1094            varying vec3 vPosition;
1095
1096            varying vec3 vColor;
1097
1098            void main() {
1099                vec4 color = vec4(vColor, 1.0);
1100                gl_FragColor = color;
1101            }
1102        `;var be=new te.a("boneWeight:"+Z.name,G,{vertex:"boneWeights:"+Z.name,fragment:"boneWeights:"+Z.name},{attributes:["position","normal","matricesIndices","matricesWeights"],uniforms:["world","worldView","worldViewProjection","view","projection","viewProjection","colorBase","colorZero","colorQuarter","colorHalf","colorFull","targetBoneIndex"]});return be.setColor3("colorBase",X),be.setColor3("colorZero",q),be.setColor3("colorQuarter",he),be.setColor3("colorHalf",ge),be.setColor3("colorFull",me),be.setFloat("targetBoneIndex",_e),be.getClassName=function(){return"BoneWeightShader"},be.transparencyMode=ne.a.MATERIAL_OPAQUE,be},$.CreateSkeletonMapShader=function(L,G){var Q,oe=L.skeleton,re=(Q=L.colorMap)!==null&&Q!==void 0?Q:[{color:new M.a(1,.38,.18),location:0},{color:new M.a(.59,.18,1),location:.2},{color:new M.a(.59,1,.18),location:.4},{color:new M.a(1,.87,.17),location:.6},{color:new M.a(1,.17,.42),location:.8},{color:new M.a(.17,.68,1),location:1}
1102],Y=oe.bones.length+1,k=$._CreateBoneMapColorBuffer(Y,re,G),H=new te.a("boneWeights:"+oe.name,G,{vertexSource:`precision highp float;
1103
1104            attribute vec3 position;
1105            attribute vec2 uv;
1106
1107            uniform mat4 view;
1108            uniform mat4 projection;
1109            uniform mat4 worldViewProjection;
1110            uniform float colorMap[`+4*oe.bones.length+`];
1111
1112            #include<bonesDeclaration>
1113            #if NUM_BONE_INFLUENCERS == 0
1114                attribute vec4 matricesIndices;
1115                attribute vec4 matricesWeights;
1116            #endif
1117            #include<instancesDeclaration>
1118
1119            varying vec3 vColor;
1120
1121            void main() {
1122                vec3 positionUpdated = position;
1123
1124                #include<instancesVertex>
1125                #include<bonesVertex>
1126
1127                vec3 color = vec3(0.);
1128                bool first = true;
1129
1130                for (int i = 0; i < 4; i++) {
1131                    int boneIdx = int(matricesIndices[i]);
1132                    float boneWgt = matricesWeights[i];
1133
1134                    vec3 c = vec3(colorMap[boneIdx * 4 + 0], colorMap[boneIdx * 4 + 1], colorMap[boneIdx * 4 + 2]);
1135
1136                    if (boneWgt > 0.) {
1137                        if (first) {
1138                            first = false;
1139                            color = c;
1140                        } else {
1141                            color = mix(color, c, boneWgt);
1142                        }
1143                    }
1144                }
1145
1146                vColor = color;
1147
1148                vec4 worldPos = finalWorld * vec4(positionUpdated, 1.0);
1149
1150                gl_Position = projection * view * worldPos;
1151            }`,fragmentSource:`
1152            precision highp float;
1153            varying vec3 vColor;
1154
1155            void main() {
1156                vec4 color = vec4( vColor, 1.0 );
1157                gl_FragColor = color;
1158            }
1159            `},{attributes:["position","normal","matricesIndices","matricesWeights"],uniforms:["world","worldView","worldViewProjection","view","projection","viewProjection","colorMap"]});return H.setFloats("colorMap",k),H.getClassName=function(){return"SkeletonMapShader"},H.transparencyMode=ne.a.MATERIAL_OPAQUE,H},$._CreateBoneMapColorBuffer=function(L,G,Q){var oe=new de.a("temp",{width:L,height:1},Q,!1),re=oe.getContext(),Y=re.createLinearGradient(0,0,L,0);G.forEach(function(X){Y.addColorStop(X.location,X.color.toHexString())}),re.fillStyle=Y,re.fillRect(0,0,L,1),oe.update();for(var k=[],H=re.getImageData(0,0,L,1).data,Z=0;Z<H.length;Z++)k.push(H[Z]*(1/255));return oe.dispose(),k},Object.defineProperty($.prototype,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),Object.defineProperty($.prototype,"utilityLayer",{get:function(){return this._utilityLayer},enumerable:!1,configurable:!0}),Object.defineProperty($.prototype,"isReady",{get:function(){return this._ready},enumerable:!1,configurable:!0}),Object.defineProperty($.prototype,"ready",{set:function(L){this._ready=L},enumerable:!1,configurable:!0}),Object.defineProperty($.prototype,"debugMesh",{get:function(){return this._debugMesh},set:function(L){this._debugMesh=L},enumerable:!1,configurable:!0}),Object.defineProperty($.prototype,"displayMode",{get:function(){return this.options.displayMode||$.DISPLAY_LINES},set:function(L){L>$.DISPLAY_SPHERE_AND_SPURS&&(L=$.DISPLAY_LINES),this.options.displayMode=L},enumerable:!1,configurable:!0}),$.prototype._bindObs=function(){var L=this;switch(this.displayMode){case $.DISPLAY_LINES:this._obs=this.scene.onBeforeRenderObservable.add(function(){L._displayLinesUpdate()})}},$.prototype.update=function(){switch(this.displayMode){case $.DISPLAY_LINES:this._displayLinesUpdate();break;case $.DISPLAY_SPHERES:this._buildSpheresAndSpurs(!0);break;case $.DISPLAY_SPHERE_AND_SPURS:this._buildSpheresAndSpurs(!1)}this._buildLocalAxes()},Object.defineProperty($.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(L){this.isEnabled!==L&&(this._isEnabled=L,this.debugMesh&&this.debugMesh.setEnabled(L),L&&!this._obs?this._bindObs():!L&&this._obs&&(this.scene.onBeforeRenderObservable.remove(this._obs),this._obs=null))}
1159,enumerable:!1,configurable:!0}),$.prototype._getBonePosition=function(L,G,Q,oe,re,Y){oe===void 0&&(oe=0),re===void 0&&(re=0),Y===void 0&&(Y=0);var k=_.c.Matrix[0],H=G.getParent();if(k.copyFrom(G.getLocalMatrix()),oe!==0||re!==0||Y!==0){var Z=_.c.Matrix[1];_.a.IdentityToRef(Z),Z.setTranslationFromFloats(oe,re,Y),Z.multiplyToRef(k,k)}H&&k.multiplyToRef(H.getAbsoluteTransform(),k),k.multiplyToRef(Q,k),L.x=k.m[12],L.y=k.m[13],L.z=k.m[14]},$.prototype._getLinesForBonesWithLength=function(L,G){for(var Q=L.length,oe=this.mesh._effectiveMesh.position,re=0,Y=0;Y<Q;Y++){var k=L[Y],H=this._debugLines[re];k._index!==-1&&(this._boneIndices.has(k.getIndex())||this.options.useAllBones)&&(H||(H=[_.e.Zero(),_.e.Zero()],this._debugLines[re]=H),this._getBonePosition(H[0],k,G),this._getBonePosition(H[1],k,G,0,k.length,0),H[0].subtractInPlace(oe),H[1].subtractInPlace(oe),re++)}},$.prototype._getLinesForBonesNoLength=function(L){for(var G=L.length,Q=0,oe=this.mesh._effectiveMesh,re=oe.position,Y=G-1;Y>=0;Y--){var k=L[Y],H=k.getParent();if(H&&(this._boneIndices.has(k.getIndex())||this.options.useAllBones)){var Z=this._debugLines[Q];Z||(Z=[_.e.Zero(),_.e.Zero()],this._debugLines[Q]=Z),k.getAbsolutePositionToRef(oe,Z[0]),H.getAbsolutePositionToRef(oe,Z[1]),Z[0].subtractInPlace(re),Z[1].subtractInPlace(re),Q++}}},$.prototype._revert=function(L){this.options.pauseAnimations&&(this.scene.animationsEnabled=L,this.utilityLayer.utilityLayerScene.animationsEnabled=L)},$.prototype._getAbsoluteBindPoseToRef=function(L,G){L!==null&&L._index!==-1?(this._getAbsoluteBindPoseToRef(L.getParent(),G),L.getBindPose().multiplyToRef(G,G)):G.copyFrom(_.a.Identity())},$.prototype._buildSpheresAndSpurs=function(L){var G,Q;L===void 0&&(L=!0),this._debugMesh&&(this._debugMesh.dispose(),this._debugMesh=null,this.ready=!1),this._ready=!1;var oe=(G=this.utilityLayer)===null||G===void 0?void 0:G.utilityLayerScene,re=this.skeleton.bones,Y=[],k=[],H=this.scene.animationsEnabled;try{this.options.pauseAnimations&&(this.scene.animationsEnabled=!1,oe.animationsEnabled=!1),this.options.returnToRest&&this.skeleton.returnToRest(),this.autoUpdateBonesMatrices&&this.skeleton.computeAbsoluteTransforms();for(var Z=Number.NEGATIVE_INFINITY,X=this.options.displayOptions||{},q=function(We){var Ze=re[We];if(Ze._index===-1||!he._boneIndices.has(Ze.getIndex())&&!he.options.useAllBones)return"continue";var ze=new _.a;he._getAbsoluteBindPoseToRef(Ze,ze);var it=new _.e;ze.decompose(void 0,void 0,it),Ze.children.forEach(function(It,Pt){var Ot=new _.a;It.getBindPose().multiplyToRef(ze,Ot);var on=new _.e;Ot.decompose(void 0,void 0,on);var Zt=_.e.Distance(it,on);if(Zt>Z&&(Z=Zt),!L){for(var tn=on.clone().subtract(it.clone()),De=tn.length(),Sn=tn.normalize().scale(De),nn=X.midStep||.165,An=X.midStepFactor||.215,Ue=Sn.scale(nn),Pn=ee.a.ExtrudeShapeCustom("skeletonViewer",{shape:[new _.e(1,-1,0),new _.e(1,1,0),new _.e(-1,1,0),new _.e(-1,-1,0),new _.e(1,-1,0)],path:[_.e.Zero(),Ue,Sn],scaleFunction:function(Fo){switch(Fo){case 0:case 2:return 0;case 1:return De*An}return 0},sideOrientation:h.a.DEFAULTSIDE,updatable:!1},oe),hr=Pn.getTotalVertices(),Ye=[],En=[],Zn=0;Zn<hr;Zn++)Ye.push(1,0,0,0),X.spurFollowsChild&&Zn>9?En.push(It.getIndex(),0,0,0):En.push(Ze.getIndex(),0,0,0);Pn.position=it.clone(),Pn.setVerticesData(pe.b.MatricesWeightsKind,Ye,!1),Pn.setVerticesData(pe.b.MatricesIndicesKind,En,!1),Pn.convertToFlatShadedMesh(),k.push(Pn)}});for(var et=X.sphereBaseSize||.2,lt=T.a.CreateSphere("skeletonViewer",{segments:6,diameter:et,updatable:!0},oe),ct=lt.getTotalVertices(),mt=[],St=[],wt=0;wt<ct;wt++)mt.push(1,0,0,0),St.push(Ze.getIndex(),0,0,0);lt.setVerticesData(pe.b.MatricesWeightsKind,mt,!1),lt.setVerticesData(pe.b.MatricesIndicesKind,St,!1),lt.position=it.clone(),Y.push([lt,Ze])},he=this,ge=0;ge<re.length;ge++)q(ge);var me=X.sphereScaleUnit||2,_e=X.sphereFactor||.85,be=[];for(ge=0;ge<Y.length;ge++){for(var Ce=Y[ge],ye=Ce[0],Be=Ce[1],Ge=1/(me/Z),Xe=0,He=Be;He.getParent()&&He.getParent().getIndex()!==-1;)Xe++,He=He.getParent();ye.scaling.scaleInPlace(Ge*Math.pow(_e,Xe)),be.push(ye)}this.debugMesh=h.a.MergeMeshes(be.concat(k),!0,!0),this.debugMesh&&(this.debugMesh.renderingGroupId=this.renderingGroupId,this.debugMesh.skeleton=this.skeleton,this.debugMesh.parent=this.mesh,this.debugMesh.computeBonesUsingShaders=(Q=this.options.computeBonesUsingShaders)===null||Q===void 0||Q,this.debugMesh.al
1159waysSelectAsActiveMesh=!0),this.utilityLayer._getSharedGizmoLight().intensity=.7,this._revert(H),this.ready=!0}catch(We){console.error(We),this._revert(H),this.dispose()}},$.prototype._buildLocalAxes=function(){var L;this._localAxes&&this._localAxes.dispose(),this._localAxes=null;var G=this.options.displayOptions||{};if(G.showLocalAxes){var Q=this._utilityLayer.utilityLayerScene,oe=G.localAxesSize||.075,re=[],Y=[],k=new M.b(1,0,0,1),H=new M.b(0,1,0,1),Z=new M.b(0,0,1,1),X=[],q=[];for(var he in this.skeleton.bones){var ge=this.skeleton.bones[he];if(ge._index!==-1&&(this._boneIndices.has(ge.getIndex())||this.options.useAllBones)){var me=new _.a,_e=new _.e;this._getAbsoluteBindPoseToRef(ge,me),me.decompose(void 0,void 0,_e);var be=ge.getBindPose().getRotationMatrix(),Ce=_.e.TransformCoordinates(new _.e(0+oe,0,0),be),ye=_.e.TransformCoordinates(new _.e(0,0+oe,0),be),Be=_.e.TransformCoordinates(new _.e(0,0,0+oe),be),Ge=[[_e,_e.add(Ce)],[_e,_e.add(ye)],[_e,_e.add(Be)]],Xe=[[k,k],[H,H],[Z,Z]];re.push.apply(re,Ge),Y.push.apply(Y,Xe);for(var He=0;He<6;He++)X.push(1,0,0,0),q.push(ge.getIndex(),0,0,0)}}this._localAxes=W.a.CreateLineSystem("localAxes",{lines:re,colors:Y,updatable:!0},Q),this._localAxes.setVerticesData(pe.b.MatricesWeightsKind,X,!1),this._localAxes.setVerticesData(pe.b.MatricesIndicesKind,q,!1),this._localAxes.skeleton=this.skeleton,this._localAxes.renderingGroupId=this.renderingGroupId,this._localAxes.parent=this.mesh,this._localAxes.computeBonesUsingShaders=(L=this.options.computeBonesUsingShaders)===null||L===void 0||L}},$.prototype._displayLinesUpdate=function(){if(this._utilityLayer){this.autoUpdateBonesMatrices&&this.skeleton.computeAbsoluteTransforms();var L=this.mesh._effectiveMesh;this.skeleton.bones[0].length===void 0?this._getLinesForBonesNoLength(this.skeleton.bones):this._getLinesForBonesWithLength(this.skeleton.bones,L.getWorldMatrix());var G=this._utilityLayer.utilityLayerScene;G&&(this._debugMesh?W.a.CreateLineSystem("",{lines:this._debugLines,updatable:!0,instance:this._debugMesh},G):(this._debugMesh=W.a.CreateLineSystem("",{lines:this._debugLines,updatable:!0,instance:null},G),this._debugMesh.renderingGroupId=this.renderingGroupId),this._debugMesh.position.copyFrom(this.mesh.position),this._debugMesh.color=this.color)}},$.prototype.changeDisplayMode=function(L){var G=!!this.isEnabled;this.displayMode!==L&&(this.isEnabled=!1,this._debugMesh&&(this._debugMesh.dispose(),this._debugMesh=null,this.ready=!1),this.displayMode=L,this.update(),this._bindObs(),this.isEnabled=G)},$.prototype.changeDisplayOptions=function(L,G){var Q=!!this.isEnabled;this.options.displayOptions[L]=G,this.isEnabled=!1,this._debugMesh&&(this._debugMesh.dispose(),this._debugMesh=null,this.ready=!1),this.update(),this._bindObs(),this.isEnabled=Q},$.prototype.dispose=function(){this.isEnabled=!1,this._debugMesh&&(this._debugMesh.dispose(),this._debugMesh=null),this._utilityLayer&&(this._utilityLayer.dispose(),this._utilityLayer=null),this.ready=!1},$.DISPLAY_LINES=0,$.DISPLAY_SPHERES=1,$.DISPLAY_SPHERE_AND_SPURS=2,$}()},function(Ae,v,f){var B="morphTargetsVertex",_=`#ifdef MORPHTARGETS
1160positionUpdated+=(position{X}-position)*morphTargetInfluences[{X}];
1161#ifdef MORPHTARGETS_NORMAL
1162normalUpdated+=(normal{X}-normal)*morphTargetInfluences[{X}];
1163#endif
1164#ifdef MORPHTARGETS_TANGENT
1165tangentUpdated.xyz+=(tangent{X}-tangent.xyz)*morphTargetInfluences[{X}];
1166#endif
1167#ifdef MORPHTARGETS_UV
1168uvUpdated+=(uv_{X}-uv)*morphTargetInfluences[{X}];
1169#endif
1170#endif`;f(5).a.IncludesShadersStore[B]=_},function(Ae,v,f){f.d(v,"b",function(){return _}),f.d(v,"a",function(){return x});var B=f(0);function _(u,M,R,C,m){m===void 0&&(m=null);for(var c=new B.e(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),E=new B.e(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),A=R;A<R+C;A++){var S=3*M[A],g=u[S],l=u[S+1],h=u[S+2];c.minimizeInPlaceFromFloats(g,l,h),E.maximizeInPlaceFromFloats(g,l,h)}return m&&(c.x-=c.x*m.x+m.y,c.y-=c.y*m.x+m.y,c.z-=c.z*m.x+m.y,E.x+=E.x*m.x+m.y,E.y+=E.y*m.x+m.y,E.z+=E.z*m.x+m.y),{minimum:c,maximum:E}}function x(u,M,R,C,m){C===void 0&&(C=null);var c=new B.e(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),E=new B.e(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);m||(m=3);for(var A=M,S=M*m;A<M+R;A++,S+=m){var g=u[S],l=u[S+1],h=u[S+2];c.minimizeInPlaceFromFloats(g,l,h),E.maximizeInPlaceFromFloats(g,l,h)}return C&&(c.x-=c.x*C.x+C.y,c.y-=c.y*C.x+C.y,c.z-=c.z*C.x+C.y,E.x+=E.x*C.x+C.y,E.y+=E.y*C.x+C.y,E.z+=E.z*C.x+C.y),{minimum:c,maximum:E}}},function(Ae,v,f){f.d(v,"a",function(){return B});var B=function(){}},function(Ae,v,f){f.d(v,"a",function(){return u});var B=f(44),_=f(0),x=f(28),u=function(){function M(R,C,m){this.vectors=B.a.BuildArray(8,_.e.Zero),this.center=_.e.Zero(),this.centerWorld=_.e.Zero(),this.extendSize=_.e.Zero(),this.extendSizeWorld=_.e.Zero(),this.directions=B.a.BuildArray(3,_.e.Zero),this.vectorsWorld=B.a.BuildArray(8,_.e.Zero),this.minimumWorld=_.e.Zero(),this.maximumWorld=_.e.Zero(),this.minimum=_.e.Zero(),this.maximum=_.e.Zero(),this.reConstruct(R,C,m)}return M.prototype.reConstruct=function(R,C,m){var c=R.x,E=R.y,A=R.z,S=C.x,g=C.y,l=C.z,h=this.vectors;this.minimum.copyFromFloats(c,E,A),this.maximum.copyFromFloats(S,g,l),h[0].copyFromFloats(c,E,A),h[1].copyFromFloats(S,g,l),h[2].copyFromFloats(S,E,A),h[3].copyFromFloats(c,g,A),h[4].copyFromFloats(c,E,l),h[5].copyFromFloats(S,g,A),h[6].copyFromFloats(c,g,l),h[7].copyFromFloats(S,E,l),C.addToRef(R,this.center).scaleInPlace(.5),C.subtractToRef(R,this.extendSize).scaleInPlace(.5),this._worldMatrix=m||_.a.IdentityReadOnly,this._update(this._worldMatrix)},M.prototype.scale=function(R){var C=M.TmpVector3,m=this.maximum.subtractToRef(this.minimum,C[0]),c=m.length();m.normalizeFromLength(c);var E=c*R,A=m.scaleInPlace(.5*E),S=this.center.subtractToRef(A,C[1]),g=this.center.addToRef(A,C[2]);return this.reConstruct(S,g,this._worldMatrix),this},M.prototype.getWorldMatrix=function(){return this._worldMatrix},M.prototype._update=function(R){var C=this.minimumWorld,m=this.maximumWorld,c=this.directions,E=this.vectorsWorld,A=this.vectors;if(R.isIdentity()){for(C.copyFrom(this.minimum),m.copyFrom(this.maximum),S=0;S<8;++S)E[S].copyFrom(A[S]);this.extendSizeWorld.copyFrom(this.extendSize),this.centerWorld.copyFrom(this.center)}else{C.setAll(Number.MAX_VALUE),m.setAll(-Number.MAX_VALUE);for(var S=0;S<8;++S){var g=E[S];_.e.TransformCoordinatesToRef(A[S],R,g),C.minimizeInPlace(g),m.maximizeInPlace(g)}m.subtractToRef(C,this.extendSizeWorld).scaleInPlace(.5),m.addToRef(C,this.centerWorld).scaleInPlace(.5)}_.e.FromArrayToRef(R.m,0,c[0]),_.e.FromArrayToRef(R.m,4,c[1]),_.e.FromArrayToRef(R.m,8,c[2]),this._worldMatrix=R},M.prototype.isInFrustum=function(R){return M.IsInFrustum(this.vectorsWorld,R)},M.prototype.isCompletelyInFrustum=function(R){return M.IsCompletelyInFrustum(this.vectorsWorld,R)},M.prototype.intersectsPoint=function(R){var C=this.minimumWorld,m=this.maximumWorld,c=C.x,E=C.y,A=C.z,S=m.x,g=m.y,l=m.z,h=R.x,b=R.y,T=R.z,D=-x.a;return!(S-h<D||D>h-c)&&!(g-b<D||D>b-E)&&!(l-T<D||D>T-A)},M.prototype.intersectsSphere=function(R){return M.IntersectsSphere(this.minimumWorld,this.maximumWorld,R.centerWorld,R.radiusWorld)},M.prototype.intersectsMinMax=function(R,C){var m=this.minimumWorld,c=this.maximumWorld,E=m.x,A=m.y,S=m.z,g=c.x,l=c.y,h=c.z,b=R.x,T=R.y,D=R.z,w=C.x,N=C.y,I=C.z;return!(g<b||E>w)&&!(l<T||A>N)&&!(h<D||S>I)},M.Intersects=function(R,C){return R.intersectsMinMax(C.minimumWorld,C.maximumWorld)},M.IntersectsSphere=function(R,C,m,c){var E=M.TmpVector3[0];return _.e.ClampToRef(m,R,C,E),_.e.DistanceSquared(m,E)<=c*c},M.IsCompletelyInFrustum=function(R,C){for(var m=0;m<6;++m)for(var c=C[m],E=0;E<8;++E)if(c.dotCoordinate(R[E])<0)return!1;return!0},M.IsInFrustum=function(R,C){for(var m=0;m<6;++m){for(var c=!0,E=C[m],A=0;A<8;++A)if(E.dotCoordinate(R[A])>=0){c=!1;break}if(c)return!1}return!0}
1170,M.TmpVector3=B.a.BuildArray(3,_.e.Zero),M}()},function(Ae,v,f){f.d(v,"a",function(){return _});var B=f(38),_=function(){function x(){}return x.SetImmediate=function(u){B.a.IsWindowObjectExist()&&window.setImmediate?window.setImmediate(u):setTimeout(u,1)},x}()},function(Ae,v,f){f.d(v,"a",function(){return x});var B=f(0),_=f(2),x=function(){function u(){this.previousWorldMatrices={},this.previousBones={}}return u.AddUniforms=function(M){M.push("previousWorld","previousViewProjection")},u.AddSamplers=function(M){},u.prototype.bindForSubMesh=function(M,R,C,m,c){R.prePassRenderer&&R.prePassRenderer.enabled&&R.prePassRenderer.getIndex(_.a.PREPASS_VELOCITY_TEXTURE_TYPE)!==-1&&(this.previousWorldMatrices[C.uniqueId]||(this.previousWorldMatrices[C.uniqueId]=B.a.Identity()),this.previousViewProjection||(this.previousViewProjection=R.getTransformMatrix()),M.setMatrix("previousWorld",this.previousWorldMatrices[C.uniqueId]),M.setMatrix("previousViewProjection",this.previousViewProjection),this.previousWorldMatrices[C.uniqueId]=m.clone(),this.previousViewProjection=R.getTransformMatrix().clone())},u}()},function(Ae,v,f){var B="lightFragmentDeclaration",_=`#ifdef LIGHT{X}
1171uniform vec4 vLightData{X};
1172uniform vec4 vLightDiffuse{X};
1173#ifdef SPECULARTERM
1174uniform vec4 vLightSpecular{X};
1175#else
1176vec4 vLightSpecular{X}=vec4(0.);
1177#endif
1178#ifdef SHADOW{X}
1179#ifdef SHADOWCSM{X}
1180uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];
1181uniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];
1182uniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];
1183uniform float cascadeBlendFactor{X};
1184varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];
1185varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];
1186varying vec4 vPositionFromCamera{X};
1187#if defined(SHADOWPCSS{X})
1188uniform highp sampler2DArrayShadow shadowSampler{X};
1189uniform highp sampler2DArray depthSampler{X};
1190uniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];
1191uniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];
1192uniform float penumbraDarkness{X};
1193#elif defined(SHADOWPCF{X})
1194uniform highp sampler2DArrayShadow shadowSampler{X};
1195#else
1196uniform highp sampler2DArray shadowSampler{X};
1197#endif
1198#ifdef SHADOWCSMDEBUG{X}
1199const vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]
1200(
1201vec3 ( 1.5,0.0,0.0 ),
1202vec3 ( 0.0,1.5,0.0 ),
1203vec3 ( 0.0,0.0,5.5 ),
1204vec3 ( 1.5,0.0,5.5 ),
1205vec3 ( 1.5,1.5,0.0 ),
1206vec3 ( 1.0,1.0,1.0 ),
1207vec3 ( 0.0,1.0,5.5 ),
1208vec3 ( 0.5,3.5,0.75 )
1209);
1210vec3 shadowDebug{X};
1211#endif
1212#ifdef SHADOWCSMUSESHADOWMAXZ{X}
1213int index{X}=-1;
1214#else
1215int index{X}=SHADOWCSMNUM_CASCADES{X}-1;
1216#endif
1217float diff{X}=0.;
1218#elif defined(SHADOWCUBE{X})
1219uniform samplerCube shadowSampler{X};
1220#else
1221varying vec4 vPositionFromLight{X};
1222varying float vDepthMetric{X};
1223#if defined(SHADOWPCSS{X})
1224uniform highp sampler2DShadow shadowSampler{X};
1225uniform highp sampler2D depthSampler{X};
1226#elif defined(SHADOWPCF{X})
1227uniform highp sampler2DShadow shadowSampler{X};
1228#else
1229uniform sampler2D shadowSampler{X};
1230#endif
1231uniform mat4 lightMatrix{X};
1232#endif
1233uniform vec4 shadowsInfo{X};
1234uniform vec2 depthValues{X};
1235#endif
1236#ifdef SPOTLIGHT{X}
1237uniform vec4 vLightDirection{X};
1238uniform vec4 vLightFalloff{X};
1239#elif defined(POINTLIGHT{X})
1240uniform vec4 vLightFalloff{X};
1241#elif defined(HEMILIGHT{X})
1242uniform vec3 vLightGround{X};
1243#endif
1244#ifdef PROJECTEDLIGHTTEXTURE{X}
1245uniform mat4 textureProjectionMatrix{X};
1246uniform sampler2D projectionLightSampler{X};
1247#endif
1248#endif`;f(5).a.IncludesShadersStore[B]=_},function(Ae,v,f){var B="lightUboDeclaration",_=`#ifdef LIGHT{X}
1249uniform Light{X}
1250{
1251vec4 vLightData;
1252vec4 vLightDiffuse;
1253vec4 vLightSpecular;
1254#ifdef SPOTLIGHT{X}
1255vec4 vLightDirection;
1256vec4 vLightFalloff;
1257#elif defined(POINTLIGHT{X})
1258vec4 vLightFalloff;
1259#elif defined(HEMILIGHT{X})
1260vec3 vLightGround;
1261#endif
1262vec4 shadowsInfo;
1263vec2 depthValues;
1264} light{X};
1265#ifdef PROJECTEDLIGHTTEXTURE{X}
1266uniform mat4 textureProjectionMatrix{X};
1267uniform sampler2D projectionLightSampler{X};
1268#endif
1269#ifdef SHADOW{X}
1270#ifdef SHADOWCSM{X}
1271uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];
1272uniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];
1273uniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];
1274uniform float cascadeBlendFactor{X};
1275varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];
1276varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];
1277varying vec4 vPositionFromCamera{X};
1278#if defined(SHADOWPCSS{X})
1279uniform highp sampler2DArrayShadow shadowSampler{X};
1280uniform highp sampler2DArray depthSampler{X};
1281uniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];
1282uniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];
1283uniform float penumbraDarkness{X};
1284#elif defined(SHADOWPCF{X})
1285uniform highp sampler2DArrayShadow shadowSampler{X};
1286#else
1287uniform highp sampler2DArray shadowSampler{X};
1288#endif
1289#ifdef SHADOWCSMDEBUG{X}
1290const vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]
1291(
1292vec3 ( 1.5,0.0,0.0 ),
1293vec3 ( 0.0,1.5,0.0 ),
1294vec3 ( 0.0,0.0,5.5 ),
1295vec3 ( 1.5,0.0,5.5 ),
1296vec3 ( 1.5,1.5,0.0 ),
1297vec3 ( 1.0,1.0,1.0 ),
1298vec3 ( 0.0,1.0,5.5 ),
1299vec3 ( 0.5,3.5,0.75 )
1300);
1301vec3 shadowDebug{X};
1302#endif
1303#ifdef SHADOWCSMUSESHADOWMAXZ{X}
1304int index{X}=-1;
1305#else
1306int index{X}=SHADOWCSMNUM_CASCADES{X}-1;
1307#endif
1308float diff{X}=0.;
1309#elif defined(SHADOWCUBE{X})
1310uniform samplerCube shadowSampler{X};
1311#else
1312varying vec4 vPositionFromLight{X};
1313varying float vDepthMetric{X};
1314#if defined(SHADOWPCSS{X})
1315uniform highp sampler2DShadow shadowSampler{X};
1316uniform highp sampler2D depthSampler{X};
1317#elif defined(SHADOWPCF{X})
1318uniform highp sampler2DShadow shadowSampler{X};
1319#else
1320uniform sampler2D shadowSampler{X};
1321#endif
1322uniform mat4 lightMatrix{X};
1323#endif
1324#endif
1325#endif`;f(5).a.IncludesShadersStore[B]=_},function(Ae,v,f){var B="imageProcessingDeclaration",_=`#ifdef EXPOSURE
1326uniform float exposureLinear;
1327#endif
1328#ifdef CONTRAST
1329uniform float contrast;
1330#endif
1331#ifdef VIGNETTE
1332uniform vec2 vInverseScreenSize;
1333uniform vec4 vignetteSettings1;
1334uniform vec4 vignetteSettings2;
1335#endif
1336#ifdef COLORCURVES
1337uniform vec4 vCameraColorCurveNegative;
1338uniform vec4 vCameraColorCurveNeutral;
1339uniform vec4 vCameraColorCurvePositive;
1340#endif
1341#ifdef COLORGRADING
1342#ifdef COLORGRADING3D
1343uniform highp sampler3D txColorTransform;
1344#else
1345uniform sampler2D txColorTransform;
1346#endif
1347uniform vec4 colorTransformSettings;
1348#endif`;f(5).a.IncludesShadersStore[B]=_},function(Ae,v,f){var B="imageProcessingFunctions",_=`#if defined(COLORGRADING) && !defined(COLORGRADING3D)
1349
1350#define inline
1351vec3 sampleTexture3D(sampler2D colorTransform,vec3 color,vec2 sampler3dSetting)
1352{
1353float sliceSize=2.0*sampler3dSetting.x;
1354#ifdef SAMPLER3DGREENDEPTH
1355float sliceContinuous=(color.g-sampler3dSetting.x)*sampler3dSetting.y;
1356#else
1357float sliceContinuous=(color.b-sampler3dSetting.x)*sampler3dSetting.y;
1358#endif
1359float sliceInteger=floor(sliceContinuous);
1360
1361
1362float sliceFraction=sliceContinuous-sliceInteger;
1363#ifdef SAMPLER3DGREENDEPTH
1364vec2 sliceUV=color.rb;
1365#else
1366vec2 sliceUV=color.rg;
1367#endif
1368sliceUV.x*=sliceSize;
1369sliceUV.x+=sliceInteger*sliceSize;
1370sliceUV=saturate(sliceUV);
1371vec4 slice0Color=texture2D(colorTransform,sliceUV);
1372sliceUV.x+=sliceSize;
1373sliceUV=saturate(sliceUV);
1374vec4 slice1Color=texture2D(colorTransform,sliceUV);
1375vec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction);
1376#ifdef SAMPLER3DBGRMAP
1377color.rgb=result.rgb;
1378#else
1379color.rgb=result.bgr;
1380#endif
1381return color;
1382}
1383#endif
1384#ifdef TONEMAPPING_ACES
1385
1386
1387
1388
1389
1390const mat3 ACESInputMat=mat3(
1391vec3(0.59719,0.07600,0.02840),
1392vec3(0.35458,0.90834,0.13383),
1393vec3(0.04823,0.01566,0.83777)
1394);
1395
1396const mat3 ACESOutputMat=mat3(
1397vec3( 1.60475,-0.10208,-0.00327),
1398vec3(-0.53108,1.10813,-0.07276),
1399vec3(-0.07367,-0.00605,1.07602)
1400);
1401vec3 RRTAndODTFit(vec3 v)
1402{
1403vec3 a=v*(v+0.0245786)-0.000090537;
1404vec3 b=v*(0.983729*v+0.4329510)+0.238081;
1405return a/b;
1406}
1407vec3 ACESFitted(vec3 color)
1408{
1409color=ACESInputMat*color;
1410
1411color=RRTAndODTFit(color);
1412color=ACESOutputMat*color;
1413
1414color=saturate(color);
1415return color;
1416}
1417#endif
1418vec4 applyImageProcessing(vec4 result) {
1419#ifdef EXPOSURE
1420result.rgb*=exposureLinear;
1421#endif
1422#ifdef VIGNETTE
1423
1424vec2 viewportXY=gl_FragCoord.xy*vInverseScreenSize;
1425viewportXY=viewportXY*2.0-1.0;
1426vec3 vignetteXY1=vec3(viewportXY*vignetteSettings1.xy+vignetteSettings1.zw,1.0);
1427float vignetteTerm=dot(vignetteXY1,vignetteXY1);
1428float vignette=pow(vignetteTerm,vignetteSettings2.w);
1429
1430vec3 vignetteColor=vignetteSettings2.rgb;
1431#ifdef VIGNETTEBLENDMODEMULTIPLY
1432vec3 vignetteColorMultiplier=mix(vignetteColor,vec3(1,1,1),vignette);
1433result.rgb*=vignetteColorMultiplier;
1434#endif
1435#ifdef VIGNETTEBLENDMODEOPAQUE
1436result.rgb=mix(vignetteColor,result.rgb,vignette);
1437#endif
1438#endif
1439#ifdef TONEMAPPING
1440#ifdef TONEMAPPING_ACES
1441result.rgb=ACESFitted(result.rgb);
1442#else
1443const float tonemappingCalibration=1.590579;
1444result.rgb=1.0-exp2(-tonemappingCalibration*result.rgb);
1445#endif
1446#endif
1447
1448result.rgb=toGammaSpace(result.rgb);
1449result.rgb=saturate(result.rgb);
1450#ifdef CONTRAST
1451
1452vec3 resultHighContrast=result.rgb*result.rgb*(3.0-2.0*result.rgb);
1453if (contrast<1.0) {
1454
1455result.rgb=mix(vec3(0.5,0.5,0.5),result.rgb,contrast);
1456} else {
1457
1458result.rgb=mix(result.rgb,resultHighContrast,contrast-1.0);
1459}
1460#endif
1461
1462#ifdef COLORGRADING
1463vec3 colorTransformInput=result.rgb*colorTransformSettings.xxx+colorTransformSettings.yyy;
1464#ifdef COLORGRADING3D
1465vec3 colorTransformOutput=texture(txColorTransform,colorTransformInput).rgb;
1466#else
1467vec3 colorTransformOutput=sampleTexture3D(txColorTransform,colorTransformInput,colorTransformSettings.yz).rgb;
1468#endif
1469result.rgb=mix(result.rgb,colorTransformOutput,colorTransformSettings.www);
1470#endif
1471#ifdef COLORCURVES
1472
1473float luma=getLuminance(result.rgb);
1474vec2 curveMix=clamp(vec2(luma*3.0-1.5,luma*-3.0+1.5),vec2(0.0),vec2(1.0));
1475vec4 colorCurve=vCameraColorCurveNeutral+curveMix.x*vCameraColorCurvePositive-curveMix.y*vCameraColorCurveNegative;
1476result.rgb*=colorCurve.rgb;
1477result.rgb=mix(vec3(luma),result.rgb,colorCurve.a);
1478#endif
1479return result;
1480}`;f(5).a.IncludesShadersStore[B]=_},function(Ae,v,f){var B="clipPlaneFragment",_=`#ifdef CLIPPLANE
1481if (fClipDistance>0.0)
1482{
1483discard;
1484}
1485#endif
1486#ifdef CLIPPLANE2
1487if (fClipDistance2>0.0)
1488{
1489discard;
1490}
1491#endif
1492#ifdef CLIPPLANE3
1493if (fClipDistance3>0.0)
1494{
1495discard;
1496}
1497#endif
1498#ifdef CLIPPLANE4
1499if (fClipDistance4>0.0)
1500{
1501discard;
1502}
1503#endif
1504#ifdef CLIPPLANE5
1505if (fClipDistance5>0.0)
1506{
1507discard;
1508}
1509#endif
1510#ifdef CLIPPLANE6
1511if (fClipDistance6>0.0)
1512{
1513discard;
1514}
1515#endif`;f(5).a.IncludesShadersStore[B]=_},function(Ae,v,f){var B="clipPlaneVertex",_=`#ifdef CLIPPLANE
1516fClipDistance=dot(worldPos,vClipPlane);
1517#endif
1518#ifdef CLIPPLANE2
1519fClipDistance2=dot(worldPos,vClipPlane2);
1520#endif
1521#ifdef CLIPPLANE3
1522fClipDistance3=dot(worldPos,vClipPlane3);
1523#endif
1524#ifdef CLIPPLANE4
1525fClipDistance4=dot(worldPos,vClipPlane4);
1526#endif
1527#ifdef CLIPPLANE5
1528fClipDistance5=dot(worldPos,vClipPlane5);
1529#endif
1530#ifdef CLIPPLANE6
1531fClipDistance6=dot(worldPos,vClipPlane6);
1532#endif`;f(5).a.IncludesShadersStore[B]=_},function(Ae,v,f){f.d(v,"a",function(){return B});var B=function(){function _(){this._count=0,this._data={}}return _.prototype.copyFrom=function(x){var u=this;this.clear(),x.forEach(function(M,R){return u.add(M,R)})},_.prototype.get=function(x){var u=this._data[x];if(u!==void 0)return u},_.prototype.getOrAddWithFactory=function(x,u){var M=this.get(x);return M!==void 0||(M=u(x))&&this.add(x,M),M},_.prototype.getOrAdd=function(x,u){var M=this.get(x);return M!==void 0?M:(this.add(x,u),u)},_.prototype.contains=function(x){return this._data[x]!==void 0},_.prototype.add=function(x,u){return this._data[x]===void 0&&(this._data[x]=u,++this._count,!0)},_.prototype.set=function(x,u){return this._data[x]!==void 0&&(this._data[x]=u,!0)},_.prototype.getAndRemove=function(x){var u=this.get(x);return u!==void 0?(delete this._data[x],--this._count,u):null},_.prototype.remove=function(x){return!!this.contains(x)&&(delete this._data[x],--this._count,!0)},_.prototype.clear=function(){this._data={},this._count=0},Object.defineProperty(_.prototype,"count",{get:function(){return this._count}
1532,enumerable:!1,configurable:!0}),_.prototype.forEach=function(x){for(var u in this._data)x(u,this._data[u])},_.prototype.first=function(x){for(var u in this._data){var M=x(u,this._data[u]);if(M)return M}return null},_}()},function(Ae,v,f){f.d(v,"a",function(){return x});var B=f(44),_=f(0),x=function(){function u(M,R,C){this.center=_.e.Zero(),this.centerWorld=_.e.Zero(),this.minimum=_.e.Zero(),this.maximum=_.e.Zero(),this.reConstruct(M,R,C)}return u.prototype.reConstruct=function(M,R,C){this.minimum.copyFrom(M),this.maximum.copyFrom(R);var m=_.e.Distance(M,R);R.addToRef(M,this.center).scaleInPlace(.5),this.radius=.5*m,this._update(C||_.a.IdentityReadOnly)},u.prototype.scale=function(M){var R=this.radius*M,C=u.TmpVector3,m=C[0].setAll(R),c=this.center.subtractToRef(m,C[1]),E=this.center.addToRef(m,C[2]);return this.reConstruct(c,E,this._worldMatrix),this},u.prototype.getWorldMatrix=function(){return this._worldMatrix},u.prototype._update=function(M){if(M.isIdentity())this.centerWorld.copyFrom(this.center),this.radiusWorld=this.radius;else{_.e.TransformCoordinatesToRef(this.center,M,this.centerWorld);var R=u.TmpVector3[0];_.e.TransformNormalFromFloatsToRef(1,1,1,M,R),this.radiusWorld=Math.max(Math.abs(R.x),Math.abs(R.y),Math.abs(R.z))*this.radius}},u.prototype.isInFrustum=function(M){for(var R=this.centerWorld,C=this.radiusWorld,m=0;m<6;m++)if(M[m].dotCoordinate(R)<=-C)return!1;return!0},u.prototype.isCenterInFrustum=function(M){for(var R=this.centerWorld,C=0;C<6;C++)if(M[C].dotCoordinate(R)<0)return!1;return!0},u.prototype.intersectsPoint=function(M){var R=_.e.DistanceSquared(this.centerWorld,M);return!(this.radiusWorld*this.radiusWorld<R)},u.Intersects=function(M,R){var C=_.e.DistanceSquared(M.centerWorld,R.centerWorld),m=M.radiusWorld+R.radiusWorld;return!(m*m<C)},u.TmpVector3=B.a.BuildArray(3,_.e.Zero),u}()},function(Ae,v,f){f.d(v,"a",function(){return B});var B=function(_,x,u){this.bu=_,this.bv=x,this.distance=u,this.faceId=0,this.subMeshId=0}},function(Ae,v,f){var B="clipPlaneFragmentDeclaration",_=`#ifdef CLIPPLANE
1533varying float fClipDistance;
1534#endif
1535#ifdef CLIPPLANE2
1536varying float fClipDistance2;
1537#endif
1538#ifdef CLIPPLANE3
1539varying float fClipDistance3;
1540#endif
1541#ifdef CLIPPLANE4
1542varying float fClipDistance4;
1543#endif
1544#ifdef CLIPPLANE5
1545varying float fClipDistance5;
1546#endif
1547#ifdef CLIPPLANE6
1548varying float fClipDistance6;
1549#endif`;f(5).a.IncludesShadersStore[B]=_},function(Ae,v,f){var B="logDepthDeclaration",_=`#ifdef LOGARITHMICDEPTH
1550uniform float logarithmicDepthConstant;
1551varying float vFragmentDepth;
1552#endif`;f(5).a.IncludesShadersStore[B]=_},function(Ae,v,f){var B="clipPlaneVertexDeclaration",_=`#ifdef CLIPPLANE
1553uniform vec4 vClipPlane;
1554varying float fClipDistance;
1555#endif
1556#ifdef CLIPPLANE2
1557uniform vec4 vClipPlane2;
1558varying float fClipDistance2;
1559#endif
1560#ifdef CLIPPLANE3
1561uniform vec4 vClipPlane3;
1562varying float fClipDistance3;
1563#endif
1564#ifdef CLIPPLANE4
1565uniform vec4 vClipPlane4;
1566varying float fClipDistance4;
1567#endif
1568#ifdef CLIPPLANE5
1569uniform vec4 vClipPlane5;
1570varying float fClipDistance5;
1571#endif
1572#ifdef CLIPPLANE6
1573uniform vec4 vClipPlane6;
1574varying float fClipDistance6;
1575#endif`;f(5).a.IncludesShadersStore[B]=_},function(Ae,v,f){f.d(v,"a",function(){return B});var B=function(){function _(){}return _.prototype.attributeProcessor=function(x){return x.replace("attribute","in")},_.prototype.varyingProcessor=function(x,u){return x.replace("varying",u?"in":"out")},_.prototype.postProcessor=function(x,u,M){var R=x.search(/#extension.+GL_EXT_draw_buffers.+require/)!==-1;if(x=(x=x.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("),M)x=(x=(x=(x=(x=(x=(x=x.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,(R?"":`out vec4 glFragColor;
1576`)+"void main(");else if(u.indexOf("#define MULTIVIEW")!==-1)return`#extension GL_OVR_multiview2 : require
1577layout (num_views = 2) in;
1578`+x;return x},_}()},function(Ae,v,f){f.d(v,"a",function(){return B});var B=function(){function _(){}return _.BindClipPlane=function(x,u){if(u.clipPlane){var M=u.clipPlane;x.setFloat4("vClipPlane",M.normal.x,M.normal.y,M.normal.z,M.d)}u.clipPlane2&&(M=u.clipPlane2,x.setFloat4("vClipPlane2",M.normal.x,M.normal.y,M.normal.z,M.d)),u.clipPlane3&&(M=u.clipPlane3,x.setFloat4("vClipPlane3",M.normal.x,M.normal.y,M.normal.z,M.d)),u.clipPlane4&&(M=u.clipPlane4,x.setFloat4("vClipPlane4",M.normal.x,M.normal.y,M.normal.z,M.d)),u.clipPlane5&&(M=u.clipPlane5,x.setFloat4("vClipPlane5",M.normal.x,M.normal.y,M.normal.z,M.d)),u.clipPlane6&&(M=u.clipPlane6,x.setFloat4("vClipPlane6",M.normal.x,M.normal.y,M.normal.z,M.d))},_}()},function(Ae,v,f){f.d(v,"a",function(){return B});var B=function(){function _(){}return _.RandomId=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(x){var u=16*Math.random()|0;return(x==="x"?u:3&u|8).toString(16)})},_}()},function(Ae,v,f){f.d(v,"a",function(){return u});var B=f(1),_=f(3),x=f(9),u=function(){function M(){this._dirty=!0,this._tempColor=new x.b(0,0,0,0),this._globalCurve=new x.b(0,0,0,0),this._highlightsCurve=new x.b(0,0,0,0),this._midtonesCurve=new x.b(0,0,0,0),this._shadowsCurve=new x.b(0,0,0,0),this._positiveCurve=new x.b(0,0,0,0),this._negativeCurve=new x.b(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(M.prototype,"globalHue",{get:function(){return this._globalHue},set:function(R){this._globalHue=R,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"globalDensity",{get:function(){return this._globalDensity},set:function(R){this._globalDensity=R,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"globalSaturation",{get:function(){return this._globalSaturation},set:function(R){this._globalSaturation=R,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"globalExposure",{get:function(){return this._globalExposure},set:function(R){this._globalExposure=R,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"highlightsHue",{get:function(){return this._highlightsHue},set:function(R){this._highlightsHue=R,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"highlightsDensity",{get:function(){return this._highlightsDensity},set:function(R){this._highlightsDensity=R,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"highlightsSaturation",{get:function(){return this._highlightsSaturation},set:function(R){this._highlightsSaturation=R,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"highlightsExposure",{get:function(){return this._highlightsExposure},set:function(R){this._highlightsExposure=R,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"midtonesHue",{get:function(){return this._midtonesHue},set:function(R){this._midtonesHue=R,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"midtonesDensity",{get:function(){return this._midtonesDensity},set:function(R){this._midtonesDensity=R,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"midtonesSaturation",{get:function(){return this._midtonesSaturation},set:function(R){this._midtonesSaturation=R,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"midtonesExposure",{get:function(){return this._midtonesExposure},set:function(R){this._midtonesExposure=R,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"shadowsHue",{get:function(){return this._shadowsHue}
1578,set:function(R){this._shadowsHue=R,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"shadowsDensity",{get:function(){return this._shadowsDensity},set:function(R){this._shadowsDensity=R,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"shadowsSaturation",{get:function(){return this._shadowsSaturation},set:function(R){this._shadowsSaturation=R,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"shadowsExposure",{get:function(){return this._shadowsExposure},set:function(R){this._shadowsExposure=R,this._dirty=!0},enumerable:!1,configurable:!0}),M.prototype.getClassName=function(){return"ColorCurves"},M.Bind=function(R,C,m,c,E){m===void 0&&(m="vCameraColorCurvePositive"),c===void 0&&(c="vCameraColorCurveNeutral"),E===void 0&&(E="vCameraColorCurveNegative"),R._dirty&&(R._dirty=!1,R.getColorGradingDataToRef(R._globalHue,R._globalDensity,R._globalSaturation,R._globalExposure,R._globalCurve),R.getColorGradingDataToRef(R._highlightsHue,R._highlightsDensity,R._highlightsSaturation,R._highlightsExposure,R._tempColor),R._tempColor.multiplyToRef(R._globalCurve,R._highlightsCurve),R.getColorGradingDataToRef(R._midtonesHue,R._midtonesDensity,R._midtonesSaturation,R._midtonesExposure,R._tempColor),R._tempColor.multiplyToRef(R._globalCurve,R._midtonesCurve),R.getColorGradingDataToRef(R._shadowsHue,R._shadowsDensity,R._shadowsSaturation,R._shadowsExposure,R._tempColor),R._tempColor.multiplyToRef(R._globalCurve,R._shadowsCurve),R._highlightsCurve.subtractToRef(R._midtonesCurve,R._positiveCurve),R._midtonesCurve.subtractToRef(R._shadowsCurve,R._negativeCurve)),C&&(C.setFloat4(m,R._positiveCurve.r,R._positiveCurve.g,R._positiveCurve.b,R._positiveCurve.a),C.setFloat4(c,R._midtonesCurve.r,R._midtonesCurve.g,R._midtonesCurve.b,R._midtonesCurve.a),C.setFloat4(E,R._negativeCurve.r,R._negativeCurve.g,R._negativeCurve.b,R._negativeCurve.a))},M.PrepareUniforms=function(R){R.push("vCameraColorCurveNeutral","vCameraColorCurvePositive","vCameraColorCurveNegative")},M.prototype.getColorGradingDataToRef=function(R,C,m,c,E){R!=null&&(R=M.clamp(R,0,360),C=M.clamp(C,-100,100),m=M.clamp(m,-100,100),c=M.clamp(c,-100,100),C=M.applyColorGradingSliderNonlinear(C),C*=.5,c=M.applyColorGradingSliderNonlinear(c),C<0&&(C*=-1,R=(R+180)%360),M.fromHSBToRef(R,C,50+.25*c,E),E.scaleToRef(2,E),E.a=1+.01*m)},M.applyColorGradingSliderNonlinear=function(R){R/=100;var C=Math.abs(R);return C=Math.pow(C,2),R<0&&(C*=-1),C*=100},M.fromHSBToRef=function(R,C,m,c){var E=M.clamp(R,0,360),A=M.clamp(C/100,0,1),S=M.clamp(m/100,0,1);if(A===0)c.r=S,c.g=S,c.b=S;else{E/=60;var g=Math.floor(E),l=E-g,h=S*(1-A),b=S*(1-A*l),T=S*(1-A*(1-l));switch(g){case 0:c.r=S,c.g=T,c.b=h;break;case 1:c.r=b,c.g=S,c.b=h;break;case 2:c.r=h,c.g=S,c.b=T;break;case 3:c.r=h,c.g=b,c.b=S;break;case 4:c.r=T,c.g=h,c.b=S;break;default:c.r=S,c.g=h,c.b=b}}c.a=1},M.clamp=function(R,C,m){return Math.min(Math.max(R,C),m)},M.prototype.clone=function(){return _.a.Clone(function(){return new M},this)},M.prototype.serialize=function(){return _.a.Serialize(this)},M.Parse=function(R){return _.a.Parse(function(){return new M},R,null,null)},Object(B.c)([Object(_.c)()],M.prototype,"_globalHue",void 0),Object(B.c)([Object(_.c)()],M.prototype,"_globalDensity",void 0),Object(B.c)([Object(_.c)()],M.prototype,"_globalSaturation",void 0),Object(B.c)([Object(_.c)()],M.prototype,"_globalExposure",void 0),Object(B.c)([Object(_.c)()],M.prototype,"_highlightsHue",void 0),Object(B.c)([Object(_.c)()],M.prototype,"_highlightsDensity",void 0),Object(B.c)([Object(_.c)()],M.prototype,"_highlightsSaturation",void 0),Object(B.c)([Object(_.c)()],M.prototype,"_highlightsExposure",void 0),Object(B.c)([Object(_.c)()],M.prototype,"_midtonesHue",void 0),Object(B.c)([Object(_.c)()],M.prototype,"_midtonesDensity",void 0),Object(B.c)([Object(_.c)()],M.prototype,"_midtonesSaturation",void 0),Object(B.c)([Object(_.c)()],M.prototype,"_midtonesExposure",void 0),M}();_.a._ColorCurvesParser=u.Parse},function(Ae,v,f){f.d(v,"a",function(){return x});var B=f(8),_=f(11),x=function(){function u(){}return u.Instantiate=function(M){if(this.RegisteredExternalClasses&&this.RegisteredExternalClasses[M])return this.RegisteredExternalClasses[M];var R=_.a.GetClass(M);if(R)return R;B.a.Warn(M+" not found, you may have missed an import.");for(var C=M.split("."),m=window||this,c=0,E=C.length;c<E;c++)m=m[C[c]];return typeof m!="function"?null:m},u.RegisteredExternalClasses={},u}()},function(Ae,v,f){var B=f(26),_=f(2);B.a.prototype.setAlphaConstants=function(x,u,M,R){this._alphaState.setAlphaBlendConstants(x,u,M,R)},B.a.prototype.setAlphaMode=function(x,u){if(u===void 0&&(u=!1),this._alphaMode!==x){switch(x){case _.a.ALPHA_DISABLE:this._alphaState.alphaBlend=!1;break;case _.a.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 _.a.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 _.a.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 _.a.ALPHA_ONEONE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case _.a.ALPHA_ADD:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case _.a.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 _.a.ALPHA_MULTIPLY:this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR,this._gl.ZERO,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case _.a.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 _.a.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 _.a.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 _.a.ALPHA_ONEONE_ONEONE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case _.a.ALPHA_ALPHATOCOLOR:this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_ALPHA,this._gl.ONE,this._gl.ZERO,this._gl.ZERO),this._alphaState.alphaBlend=!0;break;case _.a.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 _.a.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 _.a.ALPHA_ONEONE_ONEZERO:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ONE,this._gl.ZERO),this._alphaState.alphaBlend=!0;break;case _.a.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}u||(this.depthCullingState.depthMask=x===_.a.ALPHA_DISABLE),this._alphaMode=x}},B.a.prototype.getAlphaMode=function(){return this._alphaMode},B.a.prototype.setAlphaEquation=function(x){if(this._alphaEquation!==x){switch(x){case _.a.ALPHA_EQUATION_ADD:this._alphaState.setAlphaEquationParameters(this._gl.FUNC_ADD,this._gl.FUNC_ADD);break;case _.a.ALPHA_EQUATION_SUBSTRACT:this._alphaState.setAlphaEquationParameters(this._gl.FUNC_SUBTRACT,this._gl.FUNC_SUBTRACT);break;case _.a.ALPHA_EQUATION_REVERSE_SUBTRACT:this._alphaState.setAlphaEquationParameters(this._gl.FUNC_REVERSE_SUBTRACT,this._gl.FUNC_REVERSE_SUBTRACT);break;case _.a.ALPHA_EQUATION_MAX:this._alphaState.setAlphaEquationParameters(this._gl.MAX,this._gl.MAX);break;case _.a.ALPHA_EQUATION_MIN:this._alphaState.setAlphaEquationParameters(this._gl.MIN,this._gl.MIN);break;case _.a.ALPHA_EQUATION_DARKEN:this._alphaState.setAlphaEquationParameters(this._gl.MIN,this._gl.FUNC_ADD)}this._alphaEquation=x}},B.a.prototype.getAlphaEquation=function(){return this._alphaEquation}},function(Ae,v,f){var B=f(26);B.a.prototype.updateDynamicIndexBuffer=function(_,x,u){var M;this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER]=null,this.bindIndexBuffer(_),M=x instanceof Uint16Array||x instanceof Uint32Array?x:_.is32Bits?new Uint32Array(x):new Uint16Array(x),this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,M,this._gl.DYNAMIC_DRAW),this._resetIndexBufferBinding()},B.a.prototype.updateDynamicVertexBuffer=function(_,x,u,M){this.bindArrayBuffer(_),u===void 0&&(u=0);var R=x.length||x.byteLength;M===void 0||M>=R&&u===0?x instanceof Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,u,new Float32Array(x)
1578):this._gl.bufferSubData(this._gl.ARRAY_BUFFER,u,x):x instanceof Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,new Float32Array(x).subarray(u,u+M)):(x=x instanceof ArrayBuffer?new Uint8Array(x,u,M):new Uint8Array(x.buffer,x.byteOffset+u,M),this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,x)),this._resetVertexBufferBinding()}},function(Ae,v,f){var B="fogFragmentDeclaration",_=`#ifdef FOG
1579#define FOGMODE_NONE 0.
1580#define FOGMODE_EXP 1.
1581#define FOGMODE_EXP2 2.
1582#define FOGMODE_LINEAR 3.
1583#define E 2.71828
1584uniform vec4 vFogInfos;
1585uniform vec3 vFogColor;
1586varying vec3 vFogDistance;
1587float CalcFogFactor()
1588{
1589float fogCoeff=1.0;
1590float fogStart=vFogInfos.y;
1591float fogEnd=vFogInfos.z;
1592float fogDensity=vFogInfos.w;
1593float fogDistance=length(vFogDistance);
1594if (FOGMODE_LINEAR == vFogInfos.x)
1595{
1596fogCoeff=(fogEnd-fogDistance)/(fogEnd-fogStart);
1597}
1598else if (FOGMODE_EXP == vFogInfos.x)
1599{
1600fogCoeff=1.0/pow(E,fogDistance*fogDensity);
1601}
1602else if (FOGMODE_EXP2 == vFogInfos.x)
1603{
1604fogCoeff=1.0/pow(E,fogDistance*fogDistance*fogDensity*fogDensity);
1605}
1606return clamp(fogCoeff,0.0,1.0);
1607}
1608#endif`;f(5).a.IncludesShadersStore[B]=_},function(Ae,v,f){var B=f(26),_=f(27);B.a.prototype.createDynamicTexture=function(x,u,M,R){var C=new _.a(this,_.b.Dynamic);return C.baseWidth=x,C.baseHeight=u,M&&(x=this.needPOTTextures?B.a.GetExponentOfTwo(x,this._caps.maxTextureSize):x,u=this.needPOTTextures?B.a.GetExponentOfTwo(u,this._caps.maxTextureSize):u),C.width=x,C.height=u,C.isReady=!1,C.generateMipMaps=M,C.samplingMode=R,this.updateTextureSamplingMode(R,C),this._internalTexturesCache.push(C),C},B.a.prototype.updateDynamicTexture=function(x,u,M,R,C,m){if(R===void 0&&(R=!1),m===void 0&&(m=!1),x){var c=this._gl,E=c.TEXTURE_2D,A=this._bindTextureDirectly(E,x,!0,m);this._unpackFlipY(M===void 0?x.invertY:M),R&&c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1);var S=this._getWebGLTextureType(x.type),g=this._getInternalFormat(C||x.format),l=this._getRGBABufferInternalSizedFormat(x.type,g);c.texImage2D(E,0,l,g,S,u),x.generateMipMaps&&c.generateMipmap(E),A||this._bindTextureDirectly(E,null),R&&c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),x.isReady=!0}}},function(Ae,v,f){f.r(v),f.d(v,"AbstractScene",function(){return B.a}),f.d(v,"AbstractActionManager",function(){return _.a}),f.d(v,"Action",function(){return C}),f.d(v,"ActionEvent",function(){return m.a}),f.d(v,"ActionManager",function(){return pe}),f.d(v,"Condition",function(){return E}),f.d(v,"ValueCondition",function(){return A}),f.d(v,"PredicateCondition",function(){return S}),f.d(v,"StateCondition",function(){return g}),f.d(v,"SwitchBooleanAction",function(){return b}),f.d(v,"SetStateAction",function(){return T}),f.d(v,"SetValueAction",function(){return D}),f.d(v,"IncrementValueAction",function(){return w}),f.d(v,"PlayAnimationAction",function(){return N}),f.d(v,"StopAnimationAction",function(){return I}),f.d(v,"DoNothingAction",function(){return V}),f.d(v,"CombineAction",function(){return W}),f.d(v,"ExecuteCodeAction",function(){return j}),f.d(v,"SetParentAction",function(){return ne}),f.d(v,"PlaySoundAction",function(){return ae}),f.d(v,"StopSoundAction",function(){return ee}),f.d(v,"InterpolateValueAction",function(){return H}),f.d(v,"Animatable",function(){return Ge}),f.d(v,"_IAnimationState",function(){return Y}),f.d(v,"Animation",function(){return k}),f.d(v,"TargetedAnimation",function(){return Xe}),f.d(v,"AnimationGroup",function(){return He}),f.d(v,"AnimationPropertiesOverride",function(){return We}),f.d(v,"EasingFunction",function(){return ze}),f.d(v,"CircleEase",function(){return it}),f.d(v,"BackEase",function(){return et}),f.d(v,"BounceEase",function(){return lt}),f.d(v,"CubicEase",function(){return ct}),f.d(v,"ElasticEase",function(){return mt}),f.d(v,"ExponentialEase",function(){return St}),f.d(v,"PowerEase",function(){return wt}),f.d(v,"QuadraticEase",function(){return It}),f.d(v,"QuarticEase",function(){return Pt}),f.d(v,"QuinticEase",function(){return Ot}),f.d(v,"SineEase",function(){return on}),f.d(v,"BezierCurveEase",function(){return Zt}),f.d(v,"RuntimeAnimation",function(){return me}),f.d(v,"AnimationEvent",function(){return tn}),f.d(v,"AnimationKeyInterpolation",function(){return K}),f.d(v,"AnimationRange",function(){return G}),f.d(v,"KeepAssets",function(){return Sn}),f.d(v,"InstantiatedEntries",function(){return nn}),f.d(v,"AssetContainer",function(){return An}),f.d(v,"Analyser",function(){return Pn}),f.d(v,"AudioEngine",function(){return hr}),f.d(v,"AudioSceneComponent",function(){return Jn}),f.d(v,"Sound",function(){return Zn}),f.d(v,"SoundTrack",function(){return Fo}),f.d(v,"WeightedSound",function(){return $f}),f.d(v,"AutoRotationBehavior",function(){return El}),f.d(v,"BouncingBehavior",function(){return Sl}),f.d(v,"FramingBehavior",function(){return Al}),f.d(v,"AttachToBoxBehavior",function(){return ep}
1608),f.d(v,"FadeInOutBehavior",function(){return tp}),f.d(v,"MultiPointerScaleBehavior",function(){return np}),f.d(v,"PointerDragBehavior",function(){return bi.a}),f.d(v,"SixDofDragBehavior",function(){return Pl}),f.d(v,"Bone",function(){return Be}),f.d(v,"BoneIKController",function(){return ip}),f.d(v,"BoneLookController",function(){return rp}),f.d(v,"Skeleton",function(){return Bo}),f.d(v,"ArcRotateCameraGamepadInput",function(){return Ka}),f.d(v,"ArcRotateCameraKeyboardMoveInput",function(){return Qa}),f.d(v,"ArcRotateCameraMouseWheelInput",function(){return qa}),f.d(v,"ArcRotateCameraPointersInput",function(){return Za}),f.d(v,"ArcRotateCameraVRDeviceOrientationInput",function(){return Ja}),f.d(v,"FlyCameraKeyboardInput",function(){return $a}),f.d(v,"FlyCameraMouseInput",function(){return es}),f.d(v,"FollowCameraKeyboardMoveInput",function(){return ts}),f.d(v,"FollowCameraMouseWheelInput",function(){return ns}),f.d(v,"FollowCameraPointersInput",function(){return is}),f.d(v,"FreeCameraDeviceOrientationInput",function(){return cs}),f.d(v,"FreeCameraGamepadInput",function(){return ls}),f.d(v,"FreeCameraKeyboardMoveInput",function(){return rs}),f.d(v,"FreeCameraMouseInput",function(){return os}),f.d(v,"FreeCameraMouseWheelInput",function(){return as}),f.d(v,"FreeCameraTouchInput",function(){return ss}),f.d(v,"FreeCameraVirtualJoystickInput",function(){return hs}),f.d(v,"CameraInputTypes",function(){return un}),f.d(v,"CameraInputsManager",function(){return Jr}),f.d(v,"Camera",function(){return gt.a}),f.d(v,"TargetCamera",function(){return Ii}),f.d(v,"FreeCamera",function(){return Hn}),f.d(v,"FreeCameraInputsManager",function(){return $r}),f.d(v,"TouchCamera",function(){return ds}),f.d(v,"ArcRotateCamera",function(){return Zi}),f.d(v,"ArcRotateCameraInputsManager",function(){return Uo}),f.d(v,"DeviceOrientationCamera",function(){return Vo}),f.d(v,"FlyCamera",function(){return sp}),f.d(v,"FlyCameraInputsManager",function(){return Dl}),f.d(v,"FollowCamera",function(){return Nl}),f.d(v,"ArcFollowCamera",function(){return wl}),f.d(v,"FollowCameraInputsManager",function(){return Ll}),f.d(v,"GamepadCamera",function(){return ko}),f.d(v,"AnaglyphArcRotateCamera",function(){return Gl}),f.d(v,"AnaglyphFreeCamera",function(){return zl}),f.d(v,"AnaglyphGamepadCamera",function(){return jl}),f.d(v,"AnaglyphUniversalCamera",function(){return Hl}),f.d(v,"StereoscopicArcRotateCamera",function(){return Wl}),f.d(v,"StereoscopicFreeCamera",function(){return Xl}),f.d(v,"StereoscopicGamepadCamera",function(){return Yl}),f.d(v,"StereoscopicUniversalCamera",function(){return Kl}),f.d(v,"UniversalCamera",function(){return pr}),f.d(v,"VirtualJoysticksCamera",function(){return Ql}),f.d(v,"VRCameraMetrics",function(){return _r}),f.d(v,"VRDeviceOrientationArcRotateCamera",function(){return $l}),f.d(v,"VRDeviceOrientationFreeCamera",function(){return Go}),f.d(v,"VRDeviceOrientationGamepadCamera",function(){return eu}),f.d(v,"OnAfterEnteringVRObservableEvent",function(){return gp}),f.d(v,"VRExperienceHelper",function(){return ru}),f.d(v,"WebVRFreeCamera",function(){return jo}),f.d(v,"Collider",function(){return ou}),f.d(v,"DefaultCollisionCoordinator",function(){return au}),f.d(v,"PickingInfo",function(){return tr.a}),f.d(v,"IntersectionInfo",function(){return vp.a}),f.d(v,"_MeshCollisionData",function(){return bp.a}),f.d(v,"BoundingBox",function(){return Ts.a}),f.d(v,"BoundingInfo",function(){return Fi.a}),f.d(v,"BoundingSphere",function(){return su.a}),f.d(v,"Octree",function(){return to}),f.d(v,"OctreeBlock",function(){return cu}),f.d(v,"OctreeSceneComponent",function(){return Cs}),f.d(v,"Ray",function(){return dn.a}),f.d(v,"AxesViewer",function(){return nr.AxesViewer}),f.d(v,"BoneAxesViewer",function(){return nr.BoneAxesViewer}),f.d(v,"DebugLayerTab",function(){return nr.DebugLayerTab}),f.d(v,"DebugLayer",function(){return nr.DebugLayer}),f.d(v,"PhysicsViewer",function(){return nr.PhysicsViewer}),f.d(v,"RayHelper",function(){return nr.RayHelper}),f.d(v,"SkeletonViewer",function(){return nr.SkeletonViewer}),f.d(v,"DeviceInputSystem",function(){return lu}),f.d(v,"DeviceType",function(){return Kt}),f.d(v,"PointerInput",function(){return Es}),f.d(v,"DualShockInput",function(){return Ss}
1608),f.d(v,"XboxInput",function(){return As}),f.d(v,"SwitchInput",function(){return Ps}),f.d(v,"DeviceSource",function(){return uu}),f.d(v,"DeviceSourceManager",function(){return yp}),f.d(v,"Constants",function(){return h.a}),f.d(v,"ThinEngine",function(){return Bt.a}),f.d(v,"Engine",function(){return Ue.a}),f.d(v,"EngineStore",function(){return te.a}),f.d(v,"NullEngineOptions",function(){return hu.b}),f.d(v,"NullEngine",function(){return hu.a}),f.d(v,"_OcclusionDataStorage",function(){return fu}),f.d(v,"_forceTransformFeedbackToBundle",function(){return Tp}),f.d(v,"EngineView",function(){return Ep}),f.d(v,"WebGLPipelineContext",function(){return Ap.a}),f.d(v,"WebGL2ShaderProcessor",function(){return pu.a}),f.d(v,"NativeEngine",function(){return Op}),f.d(v,"ShaderCodeInliner",function(){return Rs}),f.d(v,"PerformanceConfigurator",function(){return Mp.a}),f.d(v,"KeyboardEventTypes",function(){return qi.a}),f.d(v,"KeyboardInfo",function(){return qi.b}),f.d(v,"KeyboardInfoPre",function(){return qi.c}),f.d(v,"PointerEventTypes",function(){return Tt.a}),f.d(v,"PointerInfoBase",function(){return Tt.c}),f.d(v,"PointerInfoPre",function(){return Tt.d}),f.d(v,"PointerInfo",function(){return Tt.b}),f.d(v,"ClipboardEventTypes",function(){return Yo}),f.d(v,"ClipboardInfo",function(){return Ip}),f.d(v,"DaydreamController",function(){return Ms}),f.d(v,"GearVRController",function(){return Is}),f.d(v,"GenericController",function(){return Ko}),f.d(v,"OculusTouchController",function(){return Ds}),f.d(v,"PoseEnabledControllerType",function(){return ei}),f.d(v,"PoseEnabledControllerHelper",function(){return Di}),f.d(v,"PoseEnabledController",function(){return fr}),f.d(v,"ViveController",function(){return vu}),f.d(v,"WebVRController",function(){return Ni}),f.d(v,"WindowsMotionController",function(){return Qo}),f.d(v,"XRWindowsMotionController",function(){return Lp}),f.d(v,"StickValues",function(){return op}),f.d(v,"Gamepad",function(){return hn}),f.d(v,"GenericPad",function(){return Ol}),f.d(v,"GamepadManager",function(){return Ul}),f.d(v,"GamepadSystemSceneComponent",function(){return Vl}),f.d(v,"Xbox360Button",function(){return Cn}),f.d(v,"Xbox360Dpad",function(){return Ji}),f.d(v,"Xbox360Pad",function(){return Fl}),f.d(v,"DualShockButton",function(){return Gn}),f.d(v,"DualShockDpad",function(){return $i}),f.d(v,"DualShockPad",function(){return Bl}),f.d(v,"AxisDragGizmo",function(){return qo.a}),f.d(v,"AxisScaleGizmo",function(){return ro}),f.d(v,"BoundingBoxGizmo",function(){return bu}),f.d(v,"Gizmo",function(){return Ln.a}),f.d(v,"GizmoManager",function(){return Np}),f.d(v,"PlaneRotationGizmo",function(){return Zo}),f.d(v,"PositionGizmo",function(){return Tu}),f.d(v,"RotationGizmo",function(){return yu}),f.d(v,"ScaleGizmo",function(){return Eu}),f.d(v,"LightGizmo",function(){return wp}),f.d(v,"CameraGizmo",function(){return Bp}),f.d(v,"PlaneDragGizmo",function(){return Jo}),f.d(v,"EnvironmentHelper",function(){return Us}),f.d(v,"PhotoDome",function(){return Qp}),f.d(v,"_forceSceneHelpersToBundle",function(){return k_}),f.d(v,"VideoDome",function(){return G_}),f.d(v,"EngineInstrumentation",function(){return z_}),f.d(v,"SceneInstrumentation",function(){return j_}),f.d(v,"_TimeToken",function(){return du}),f.d(v,"EffectLayer",function(){return fo}),f.d(v,"EffectLayerSceneComponent",function(){return Vu}),f.d(v,"GlowLayer",function(){return sa}),f.d(v,"HighlightLayer",function(){return Xs}),f.d(v,"Layer",function(){return Z_}),f.d(v,"LayerSceneComponent",function(){return Gu}),f.d(v,"LensFlare",function(){return zu}),f.d(v,"LensFlareSystem",function(){return Ys}),f.d(v,"LensFlareSystemSceneComponent",function(){return ju}),f.d(v,"Light",function(){return Ci.a}),f.d(v,"ShadowLight",function(){return $o}),f.d(v,"ShadowGenerator",function(){return Fn}),f.d(v,"CascadedShadowGenerator",function(){return Ks}),f.d(v,"ShadowGeneratorSceneComponent",function(){return qu}),f.d(v,"DirectionalLight",function(){return Ns}),f.d(v,"HemisphericLight",function(){return zo.a}),f.d(v,"PointLight",function(){return Qs}),f.d(v,"SpotLight",function(){return ws}),f.d(v,"DefaultLoadingScreen",function(){return Zu}),f.d(v,"_BabylonLoaderRegistered",function(){return mm}),f.d(v,"BabylonFileLoaderConfiguration",function(){return da}),f.d(v,"SceneLoaderAnimationGroupLoadingMode",function(){return Ai}),f.d(v,"SceneLoader",function(){return Ut}),f.d(v,"SceneLoaderFlags",function(){return Pi.a}
1608),f.d(v,"BackgroundMaterial",function(){return ao}),f.d(v,"ColorCurves",function(){return vm.a}),f.d(v,"EffectFallbacks",function(){return Er.a}),f.d(v,"Effect",function(){return je.a}),f.d(v,"FresnelParameters",function(){return lh}),f.d(v,"ImageProcessingConfigurationDefines",function(){return vn.b}),f.d(v,"ImageProcessingConfiguration",function(){return vn.a}),f.d(v,"Material",function(){return Ht.a}),f.d(v,"MaterialDefines",function(){return ta.a}),f.d(v,"ThinMaterialHelper",function(){return uh.a}),f.d(v,"MaterialHelper",function(){return tt.a}),f.d(v,"MultiMaterial",function(){return ir.a}),f.d(v,"PBRMaterialDefines",function(){return ks}),f.d(v,"PBRBaseMaterial",function(){return pn}),f.d(v,"PBRBaseSimpleMaterial",function(){return ec}),f.d(v,"PBRMaterial",function(){return lo}),f.d(v,"PBRMetallicRoughnessMaterial",function(){return hh}),f.d(v,"PBRSpecularGlossinessMaterial",function(){return dh}),f.d(v,"PushMaterial",function(){return na.a}),f.d(v,"ShaderMaterial",function(){return fa.a}),f.d(v,"StandardMaterialDefines",function(){return Ft.b}),f.d(v,"StandardMaterial",function(){return Ft.a}),f.d(v,"BaseTexture",function(){return zn.a}),f.d(v,"ColorGradingTexture",function(){return fh}),f.d(v,"CubeTexture",function(){return ni}),f.d(v,"DynamicTexture",function(){return yi.a}),f.d(v,"EquiRectangularCubeTexture",function(){return ph}),f.d(v,"HDRFiltering",function(){return th}),f.d(v,"HDRCubeTexture",function(){return la}),f.d(v,"HtmlElementTexture",function(){return bm}),f.d(v,"InternalTextureSource",function(){return xt.b}),f.d(v,"InternalTexture",function(){return xt.a}),f.d(v,"_DDSTextureLoader",function(){return xu}),f.d(v,"_ENVTextureLoader",function(){return Ru}),f.d(v,"_KTXTextureLoader",function(){return Ou}),f.d(v,"_TGATextureLoader",function(){return _h}),f.d(v,"_BasisTextureLoader",function(){return mh}),f.d(v,"MirrorTexture",function(){return Bs}),f.d(v,"MultiRenderTarget",function(){return tc}),f.d(v,"TexturePacker",function(){return Em}),f.d(v,"TexturePackerFrame",function(){return nc}),f.d(v,"CustomProceduralTexture",function(){return Am}),f.d(v,"NoiseProceduralTexture",function(){return vh}),f.d(v,"ProceduralTexture",function(){return mo}),f.d(v,"ProceduralTextureSceneComponent",function(){return gh}),f.d(v,"RawCubeTexture",function(){return Cm}),f.d(v,"RawTexture",function(){return $n}),f.d(v,"RawTexture2DArray",function(){return xm}),f.d(v,"RawTexture3D",function(){return Rm}),f.d(v,"RefractionTexture",function(){return Om}),f.d(v,"RenderTargetTexture",function(){return sn}),f.d(v,"Texture",function(){return we.a}),f.d(v,"VideoTexture",function(){return Uu}),f.d(v,"UniformBuffer",function(){return ql.a}),f.d(v,"MaterialFlags",function(){return ht.a}),f.d(v,"NodeMaterialBlockTargets",function(){return Re}),f.d(v,"NodeMaterialBlockConnectionPointTypes",function(){return le}),f.d(v,"NodeMaterialBlockConnectionPointMode",function(){return gn}),f.d(v,"NodeMaterialSystemValues",function(){return bt}),f.d(v,"NodeMaterialModes",function(){return Rn}),f.d(v,"NodeMaterialConnectionPointCompatibilityStates",function(){return oi}),f.d(v,"NodeMaterialConnectionPointDirection",function(){return bn}),f.d(v,"NodeMaterialConnectionPoint",function(){return _a}),f.d(v,"NodeMaterialBlock",function(){return pt}),f.d(v,"NodeMaterialDefines",function(){return yo}),f.d(v,"NodeMaterial",function(){return ya}),f.d(v,"VertexOutputBlock",function(){return go}),f.d(v,"BonesBlock",function(){return Sh}),f.d(v,"InstancesBlock",function(){return Ah}),f.d(v,"MorphTargetsBlock",function(){return Ph}),f.d(v,"LightInformationBlock",function(){return Ch}),f.d(v,"FragmentOutputBlock",function(){return Dr}),f.d(v,"ImageProcessingBlock",function(){return xh}),f.d(v,"PerturbNormalBlock",function(){return Rh}),f.d(v,"DiscardBlock",function(){return Oh}),f.d(v,"FrontFacingBlock",function(){return Mh}),f.d(v,"DerivativeBlock",function(){return Ih}),f.d(v,"FragCoordBlock",function(){return Dh}),f.d(v,"ScreenSizeBlock",function(){return Lh}),f.d(v,"FogBlock",function(){return Nh}),f.d(v,"LightBlock",function(){return wh}),f.d(v,"TextureBlock",function(){return Fh}),f.d(v,"ReflectionTextureBlock",function(){return Bh}),f.d(v,"CurrentScreenBlock",function(){return rc}),f.d(v,"InputBlock",function(){return At}),f.d(v,"AnimatedInputBlockTypes",function(){return ki}),f.d(v,"MultiplyBlock",function(){return ga}),f.d(v,"AddBlock",function(){return Uh}),f.d(v,"ScaleBlock",function(){return Vh}),f.d(v,"ClampBlock",function(){return kh}),f.d(v,"CrossBlock",function(){return Gh}),f.d(v,"DotBlock",function(){return zh}),f.d(v,"TransformBlock",function(){return ma}),f.d(v,"RemapBlock",function(){return cc}),f.d(v,"NormalizeBlock",function(){return jh}),f.d(v,"TrigonometryBlockOperations",function(){return rn}),f.d(v,"TrigonometryBlock",function(){return _c}),f.d(v,"ColorMergerBlock",function(){return Hh}),f.d(v,"VectorMergerBlock",function(){return vo}),f.d(v,"ColorSplitterBlock",function(){return pc}),f.d(v,"VectorSplitterBlock",function(){return Wh}),f.d(v,"LerpBlock",function(){return Xh}),f.d(v,"DivideBlock",function(){return Yh}),f.d(v,"SubtractBlock",function(){return Kh}),f.d(v,"StepBlock",function(){return Qh}
1608),f.d(v,"OneMinusBlock",function(){return vc}),f.d(v,"ViewDirectionBlock",function(){return bc}),f.d(v,"FresnelBlock",function(){return qh}),f.d(v,"MaxBlock",function(){return Zh}),f.d(v,"MinBlock",function(){return Jh}),f.d(v,"DistanceBlock",function(){return $h}),f.d(v,"LengthBlock",function(){return ed}),f.d(v,"NegateBlock",function(){return td}),f.d(v,"PowBlock",function(){return nd}),f.d(v,"RandomNumberBlock",function(){return id}),f.d(v,"ArcTan2Block",function(){return rd}),f.d(v,"SmoothStepBlock",function(){return od}),f.d(v,"ReciprocalBlock",function(){return ad}),f.d(v,"ReplaceColorBlock",function(){return sd}),f.d(v,"PosterizeBlock",function(){return cd}),f.d(v,"WaveBlockKind",function(){return rr}),f.d(v,"WaveBlock",function(){return ld}),f.d(v,"GradientBlockColorStep",function(){return Ta}),f.d(v,"GradientBlock",function(){return ud}),f.d(v,"NLerpBlock",function(){return hd}),f.d(v,"WorleyNoise3DBlock",function(){return dd}),f.d(v,"SimplexPerlin3DBlock",function(){return fd}),f.d(v,"NormalBlendBlock",function(){return pd}),f.d(v,"Rotate2dBlock",function(){return _d}),f.d(v,"ReflectBlock",function(){return md}),f.d(v,"RefractBlock",function(){return gd}),f.d(v,"DesaturateBlock",function(){return vd}),f.d(v,"PBRMetallicRoughnessBlock",function(){return bd}),f.d(v,"SheenBlock",function(){return yc}),f.d(v,"AnisotropyBlock",function(){return Tc}),f.d(v,"ReflectionBlock",function(){return Ec}),f.d(v,"ClearCoatBlock",function(){return Ea}),f.d(v,"RefractionBlock",function(){return Sc}),f.d(v,"SubSurfaceBlock",function(){return Sa}),f.d(v,"ParticleTextureBlock",function(){return oc}),f.d(v,"ParticleRampGradientBlock",function(){return ac}),f.d(v,"ParticleBlendMultiplyBlock",function(){return sc}),f.d(v,"ModBlock",function(){return yd}),f.d(v,"NodeMaterialOptimizer",function(){return Nm}),f.d(v,"PropertyTypeForEdition",function(){return Lt}),f.d(v,"editableInPropertyPage",function(){return Vt}),f.d(v,"EffectRenderer",function(){return $u}),f.d(v,"EffectWrapper",function(){return eh}),f.d(v,"ShadowDepthWrapper",function(){return Bm}),f.d(v,"Scalar",function(){return $.a}),f.d(v,"extractMinAndMaxIndexed",function(){return Td.b}),f.d(v,"extractMinAndMax",function(){return Td.a}),f.d(v,"Space",function(){return ye.c}),f.d(v,"Axis",function(){return ye.a}),f.d(v,"Coordinate",function(){return ye.b}),f.d(v,"Color3",function(){return M.a}),f.d(v,"Color4",function(){return M.b}),f.d(v,"TmpColors",function(){return M.c}),f.d(v,"ToGammaSpace",function(){return Gt.b}),f.d(v,"ToLinearSpace",function(){return Gt.c}),f.d(v,"Epsilon",function(){return Gt.a}),f.d(v,"Frustum",function(){return Jl.a}),f.d(v,"Orientation",function(){return Ze.e}),f.d(v,"BezierCurve",function(){return Ze.c}),f.d(v,"Angle",function(){return Ze.a}),f.d(v,"Arc2",function(){return Ze.b}),f.d(v,"Path2",function(){return Ze.f}),f.d(v,"Path3D",function(){return Ze.g}),f.d(v,"Curve3",function(){return Ze.d}),f.d(v,"Plane",function(){return gr.a}),f.d(v,"Size",function(){return oe.a}),f.d(v,"Vector2",function(){return u.d}),f.d(v,"Vector3",function(){return u.e}),f.d(v,"Vector4",function(){return u.f}),f.d(v,"Quaternion",function(){return u.b}),f.d(v,"Matrix",function(){return u.a}),f.d(v,"TmpVectors",function(){return u.c}),f.d(v,"PositionNormalVertex",function(){return Fs}),f.d(v,"PositionNormalTextureVertex",function(){return Fp}),f.d(v,"Viewport",function(){return Wn.a}),f.d(v,"SphericalHarmonics",function(){return xs}),f.d(v,"SphericalPolynomial",function(){return io}),f.d(v,"AbstractMesh",function(){return Dt.a}),f.d(v,"Buffer",function(){return Me.a}),f.d(v,"VertexBuffer",function(){return Me.b}),f.d(v,"DracoCompression",function(){return Vm}),f.d(v,"CSG",function(){return zm}),f.d(v,"Geometry",function(){return qs.a}),f.d(v,"GroundMesh",function(){return Wo}),f.d(v,"TrailMesh",function(){return jm}),f.d(v,"InstancedMesh",function(){return Hm.a}),f.d(v,"LinesMesh",function(){return Eo.b}),f.d(v,"InstancedLinesMesh",function(){return Eo.a}),f.d(v,"_CreationDataStorage",function(){return De.b}),f.d(v,"_InstancesBatch",function(){return De.c}),f.d(v,"Mesh",function(){return De.a}),f.d(v,"VertexData",function(){return ft.a}),f.d(v,"MeshBuilder",function(){return Ym}),f.d(v,"SimplificationSettings",function(){return Km}),f.d(v,"SimplificationQueue",function(){return xd}),f.d(v,"SimplificationType",function(){return Po}),f.d(v,"QuadraticErrorSimplification",function(){return Od}),f.d(v,"SimplicationQueueSceneComponent",function(){return Md}),f.d(v,"Polygon",function(){return Xm}),f.d(v,"PolygonMeshBuilder",function(){return Pd}),f.d(v,"SubMesh",function(){return To.a}),f.d(v,"MeshLODLevel",function(){return Jm.a}),f.d(v,"TransformNode",function(){return Tr.a}),f.d(v,"BoxBuilder",function(){return yr.a}),f.d(v,"TiledBoxBuilder",function(){return Ad}),f.d(v,"DiscBuilder",function(){return Aa}),f.d(v,"RibbonBuilder",function(){return So.a}),f.d(v,"SphereBuilder",function(){return Nn.a}),f.d(v,"HemisphereBuilder",function(){return ea}),f.d(v,"CylinderBuilder",function(){return ui.a}),f.d(v,"TorusBuilder",function(){return mr}),f.d(v,"TorusKnotBuilder",function(){return Cc}),f.d(v,"LinesBuilder",function(){return cn.a}),f.d(v,"PolygonBuilder",function(){return Ao}),f.d(v,"ShapeBuilder",function(){return ha.a}),f.d(v,"LatheBuilder",function(){return Rc}
1608),f.d(v,"PlaneBuilder",function(){return Ls.a}),f.d(v,"TiledPlaneBuilder",function(){return Cd}),f.d(v,"GroundBuilder",function(){return wi}),f.d(v,"TubeBuilder",function(){return Oc}),f.d(v,"PolyhedronBuilder",function(){return oo}),f.d(v,"IcoSphereBuilder",function(){return Mc}),f.d(v,"DecalBuilder",function(){return Ic}),f.d(v,"CapsuleBuilder",function(){return Dc}),f.d(v,"DataBuffer",function(){return _u.a}),f.d(v,"WebGLDataBuffer",function(){return $m.a}),f.d(v,"MorphTarget",function(){return nh}),f.d(v,"MorphTargetManager",function(){return ua}),f.d(v,"RecastJSPlugin",function(){return eg}),f.d(v,"RecastJSCrowd",function(){return Id}),f.d(v,"Node",function(){return Q.a}),f.d(v,"Database",function(){return Dd}),f.d(v,"BaseParticleSystem",function(){return bo}),f.d(v,"BoxParticleEmitter",function(){return Lr}),f.d(v,"ConeParticleEmitter",function(){return lc}),f.d(v,"CylinderParticleEmitter",function(){return va}),f.d(v,"CylinderDirectedParticleEmitter",function(){return uc}),f.d(v,"HemisphericParticleEmitter",function(){return hc}),f.d(v,"PointParticleEmitter",function(){return dc}),f.d(v,"SphereParticleEmitter",function(){return ba}),f.d(v,"SphereDirectedParticleEmitter",function(){return fc}),f.d(v,"CustomParticleEmitter",function(){return Nr}),f.d(v,"MeshParticleEmitter",function(){return Th}),f.d(v,"GPUParticleSystem",function(){return or}),f.d(v,"Particle",function(){return Nd}),f.d(v,"ParticleHelper",function(){return cg}),f.d(v,"ParticleSystem",function(){return ln}),f.d(v,"ParticleSystemSet",function(){return Pa}),f.d(v,"SolidParticle",function(){return wc}),f.d(v,"ModelShape",function(){return Fc}),f.d(v,"DepthSortedParticle",function(){return wd}),f.d(v,"SolidParticleVertex",function(){return Fd}),f.d(v,"SolidParticleSystem",function(){return lg}),f.d(v,"CloudPoint",function(){return Bd}),f.d(v,"PointsGroup",function(){return Ca}),f.d(v,"PointColor",function(){return yn}),f.d(v,"PointsCloudSystem",function(){return ug}),f.d(v,"SubEmitterType",function(){return wr}),f.d(v,"SubEmitter",function(){return Co}),f.d(v,"PhysicsEngine",function(){return Mr}),f.d(v,"PhysicsEngineSceneComponent",function(){return Ud}),f.d(v,"PhysicsHelper",function(){return hg}),f.d(v,"PhysicsRadialExplosionEventOptions",function(){return Br}),f.d(v,"PhysicsUpdraftEventOptions",function(){return Bc}),f.d(v,"PhysicsVortexEventOptions",function(){return Uc}),f.d(v,"PhysicsRadialImpulseFalloff",function(){return xo}),f.d(v,"PhysicsUpdraftMode",function(){return Fr}),f.d(v,"PhysicsImpostor",function(){return Ct.a}),f.d(v,"PhysicsJoint",function(){return en.e}),f.d(v,"DistanceJoint",function(){return en.a}),f.d(v,"MotorEnabledJoint",function(){return en.d}),f.d(v,"HingeJoint",function(){return en.c}),f.d(v,"Hinge2Joint",function(){return en.b}),f.d(v,"CannonJSPlugin",function(){return $s}),f.d(v,"AmmoJSPlugin",function(){return rh}),f.d(v,"OimoJSPlugin",function(){return ih}),f.d(v,"AnaglyphPostProcess",function(){return ps}),f.d(v,"BlackAndWhitePostProcess",function(){return kd}),f.d(v,"BloomEffect",function(){return Gc}),f.d(v,"BloomMergePostProcess",function(){return kc}),f.d(v,"BlurPostProcess",function(){return _n}),f.d(v,"ChromaticAberrationPostProcess",function(){return zc}),f.d(v,"CircleOfConfusionPostProcess",function(){return jc}),f.d(v,"ColorCorrectionPostProcess",function(){return Gd}),f.d(v,"ConvolutionPostProcess",function(){return zd}),f.d(v,"DepthOfFieldBlurPostProcess",function(){return xa}),f.d(v,"DepthOfFieldEffectBlurLevel",function(){return ar}),f.d(v,"DepthOfFieldEffect",function(){return Hc}),f.d(v,"DepthOfFieldMergePostProcessOptions",function(){return Sg}),f.d(v,"DepthOfFieldMergePostProcess",function(){return jd}),f.d(v,"DisplayPassPostProcess",function(){return Hd}),f.d(v,"ExtractHighlightsPostProcess",function(){return Vc}),f.d(v,"FilterPostProcess",function(){return Wd}),f.d(v,"FxaaPostProcess",function(){return Ro}),f.d(v,"GrainPostProcess",function(){return Wc}),f.d(v,"HighlightsPostProcess",function(){return Mg}),f.d(v,"ImageProcessingPostProcess",function(){return Ho}),f.d(v,"MotionBlurPostProcess",function(){return Xc}),f.d(v,"PassPostProcess",function(){return Li}
1608),f.d(v,"PassCubePostProcess",function(){return hp}),f.d(v,"PostProcess",function(){return _t}),f.d(v,"PostProcessManager",function(){return ms.a}),f.d(v,"RefractionPostProcess",function(){return Yd}),f.d(v,"DefaultRenderingPipeline",function(){return qd}),f.d(v,"LensRenderingPipeline",function(){return Vg}),f.d(v,"SSAO2RenderingPipeline",function(){return Zd}),f.d(v,"SSAORenderingPipeline",function(){return Hg}),f.d(v,"StandardRenderingPipeline",function(){return Jd}),f.d(v,"PostProcessRenderEffect",function(){return Rt}),f.d(v,"PostProcessRenderPipeline",function(){return Ur}),f.d(v,"PostProcessRenderPipelineManager",function(){return Kd}),f.d(v,"PostProcessRenderPipelineManagerSceneComponent",function(){return Qd}),f.d(v,"SharpenPostProcess",function(){return Yc}),f.d(v,"StereoscopicInterlacePostProcessI",function(){return Qg}),f.d(v,"StereoscopicInterlacePostProcess",function(){return qg}),f.d(v,"TonemappingOperator",function(){return sr}),f.d(v,"TonemapPostProcess",function(){return Jg}),f.d(v,"VolumetricLightScatteringPostProcess",function(){return $d}),f.d(v,"VRDistortionCorrectionPostProcess",function(){return _s}),f.d(v,"VRMultiviewToSingleviewPostProcess",function(){return gs}),f.d(v,"ScreenSpaceReflectionPostProcess",function(){return Kc}),f.d(v,"ScreenSpaceCurvaturePostProcess",function(){return ef}),f.d(v,"ReflectionProbe",function(){return oh}),f.d(v,"BoundingBoxRenderer",function(){return tf}),f.d(v,"DepthRenderer",function(){return ca}),f.d(v,"DepthRendererSceneComponent",function(){return nf}),f.d(v,"EdgesRenderer",function(){return Qc}),f.d(v,"LineEdgesRenderer",function(){return rf}),f.d(v,"GeometryBufferRenderer",function(){return ai}),f.d(v,"GeometryBufferRendererSceneComponent",function(){return Xd}),f.d(v,"PrePassRenderer",function(){return qc}),f.d(v,"PrePassRendererSceneComponent",function(){return of}),f.d(v,"SubSurfaceSceneComponent",function(){return sf}),f.d(v,"OutlineRenderer",function(){return cf}),f.d(v,"RenderingGroup",function(){return hv.a}),f.d(v,"RenderingGroupInfo",function(){return eo.a}),f.d(v,"RenderingManager",function(){return eo.b}),f.d(v,"UtilityLayerRenderer",function(){return xn.a}),f.d(v,"Scene",function(){return _e.a}),f.d(v,"SceneComponentConstants",function(){return st.a}),f.d(v,"Stage",function(){return st.b}),f.d(v,"Sprite",function(){return lf}),f.d(v,"SpriteManager",function(){return hf}),f.d(v,"SpriteMap",function(){return gv}),f.d(v,"SpritePackedManager",function(){return vv}),f.d(v,"SpriteSceneComponent",function(){return uf}),f.d(v,"AlphaState",function(){return bv.a}),f.d(v,"DepthCullingState",function(){return yv.a}),f.d(v,"StencilState",function(){return Tv.a}),f.d(v,"AndOrNotEvaluator",function(){return Ev.a}),f.d(v,"AssetTaskState",function(){return di}),f.d(v,"AbstractAssetTask",function(){return fi}),f.d(v,"AssetsProgressEvent",function(){return df}),f.d(v,"ContainerAssetTask",function(){return ff}),f.d(v,"MeshAssetTask",function(){return pf}),f.d(v,"TextFileAssetTask",function(){return _f}),f.d(v,"BinaryFileAssetTask",function(){return mf}),f.d(v,"ImageAssetTask",function(){return gf}),f.d(v,"TextureAssetTask",function(){return vf}),f.d(v,"CubeTextureAssetTask",function(){return bf}),f.d(v,"HDRCubeTextureAssetTask",function(){return yf}),f.d(v,"EquiRectangularCubeTextureAssetTask",function(){return Tf}),f.d(v,"AssetsManager",function(){return Sv}),f.d(v,"BasisTranscodeConfiguration",function(){return ym}),f.d(v,"BasisTools",function(){return _o}),f.d(v,"DDSTools",function(){return Ui}),f.d(v,"expandToProperty",function(){return L.b}),f.d(v,"serialize",function(){return L.c}),f.d(v,"serializeAsTexture",function(){return L.m}),f.d(v,"serializeAsColor3",function(){return L.e}),f.d(v,"serializeAsFresnelParameters",function(){return L.h}),f.d(v,"serializeAsVector2",function(){return L.n}),f.d(v,"serializeAsVector3",function(){return L.o}),f.d(v,"serializeAsMeshReference",function(){return L.k}),f.d(v,"serializeAsColorCurves",function(){return L.g}),f.d(v,"serializeAsColor4",function(){return L.f}),f.d(v,"serializeAsImageProcessingConfiguration",function(){return L.i}),f.d(v,"serializeAsQuaternion",function(){return L.l}),f.d(v,"serializeAsMatrix",function(){return L.j}),f.d(v,"serializeAsCameraReference",function(){return L.d}),f.d(v,"SerializationHelper",function(){return L.a}),f.d(v,"Deferred",function(){return Av}),f.d(v,"EnvironmentTextureTools",function(){return Si}),f.d(v,"MeshExploder",function(){return Pv}),f.d(v,"FilesInput",function(){return Cv}),f.d(v,"CubeMapToSphericalPolynomialTools",function(){return Xo}),f.d(v,"HDRTools",function(){return Ju}),f.d(v,"PanoramaToCubeMapTools",function(){return Zs}
1608),f.d(v,"KhronosTextureContainer",function(){return aa}),f.d(v,"EventState",function(){return x.a}),f.d(v,"Observer",function(){return x.d}),f.d(v,"MultiObserver",function(){return x.b}),f.d(v,"Observable",function(){return x.c}),f.d(v,"PerformanceMonitor",function(){return Ef.a}),f.d(v,"RollingAverage",function(){return Ef.b}),f.d(v,"PromisePolyfill",function(){return xv.a}),f.d(v,"SceneOptimization",function(){return pi}),f.d(v,"TextureOptimization",function(){return Ra}),f.d(v,"HardwareScalingOptimization",function(){return Jc}),f.d(v,"ShadowsOptimization",function(){return Oa}),f.d(v,"PostProcessesOptimization",function(){return Ma}),f.d(v,"LensFlaresOptimization",function(){return Ia}),f.d(v,"CustomOptimization",function(){return Sf}),f.d(v,"ParticlesOptimization",function(){return Da}),f.d(v,"RenderTargetsOptimization",function(){return $c}),f.d(v,"MergeMeshesOptimization",function(){return La}),f.d(v,"SceneOptimizerOptions",function(){return el}),f.d(v,"SceneOptimizer",function(){return Rv}),f.d(v,"SceneSerializer",function(){return nl}),f.d(v,"SmartArray",function(){return li.a}),f.d(v,"SmartArrayNoDuplicate",function(){return li.b}),f.d(v,"StringDictionary",function(){return Il.a}),f.d(v,"Tags",function(){return Ov.a}),f.d(v,"TextureTools",function(){return Mv}),f.d(v,"TGATools",function(){return pa}),f.d(v,"Tools",function(){return Ye.b}),f.d(v,"className",function(){return Ye.c}),f.d(v,"AsyncLoop",function(){return Ye.a}),f.d(v,"VideoRecorder",function(){return Iv}),f.d(v,"JoystickAxis",function(){return an}),f.d(v,"VirtualJoystick",function(){return us}),f.d(v,"WorkerPool",function(){return zs}),f.d(v,"Logger",function(){return l.a}),f.d(v,"_TypeStore",function(){return R.a}),f.d(v,"FilesInputStore",function(){return Os.a}),f.d(v,"DeepCopier",function(){return de.a}),f.d(v,"PivotTools",function(){return kn.a}),f.d(v,"PrecisionDate",function(){return be.a}),f.d(v,"ScreenshotTools",function(){return Oo}),f.d(v,"WebRequest",function(){return re.a}),f.d(v,"InspectableType",function(){return Zc}),f.d(v,"BRDFTextureTools",function(){return ia}),f.d(v,"RGBDTextureTools",function(){return Su}),f.d(v,"ColorGradient",function(){return Lc}),f.d(v,"Color3Gradient",function(){return Ld}),f.d(v,"FactorGradient",function(){return Nc}),f.d(v,"GradientHelper",function(){return On}),f.d(v,"PerfCounter",function(){return jn.a}),f.d(v,"RetryStrategy",function(){return Dv.a}),f.d(v,"CanvasGenerator",function(){return vs.a}),f.d(v,"LoadFileError",function(){return no.b}),f.d(v,"RequestFileError",function(){return no.d}),f.d(v,"ReadFileError",function(){return no.c}),f.d(v,"FileTools",function(){return no.a}),f.d(v,"StringTools",function(){return Xn.a}),f.d(v,"DataReader",function(){return Lv}),f.d(v,"MinMaxReducer",function(){return Xu}),f.d(v,"DepthReducer",function(){return Yu}),f.d(v,"DataStorage",function(){return Nv}),f.d(v,"SceneRecorder",function(){return wv}),f.d(v,"KhronosTextureContainer2",function(){return js}),f.d(v,"Trajectory",function(){return Fv}),f.d(v,"TrajectoryClassifier",function(){return Bv}),f.d(v,"TimerState",function(){return Vi}),f.d(v,"setAndStartTimer",function(){return Ws}),f.d(v,"AdvancedTimer",function(){return U_}),f.d(v,"CopyTools",function(){return Uv.a}),f.d(v,"WebXRCamera",function(){return Mu}),f.d(v,"WebXREnterExitUIButton",function(){return wu}),f.d(v,"WebXREnterExitUIOptions",function(){return B_}),f.d(v,"WebXREnterExitUI",function(){return Fu}),f.d(v,"WebXRExperienceHelper",function(){return Iu}),f.d(v,"WebXRInput",function(){return Nu}),f.d(v,"WebXRInputSource",function(){return Lu}),f.d(v,"WebXRManagedOutputCanvasOptions",function(){return bs}),f.d(v,"WebXRManagedOutputCanvas",function(){return tu}),f.d(v,"WebXRState",function(){return fn}),f.d(v,"WebXRTrackingState",function(){return er}),f.d(v,"WebXRSessionManager",function(){return ys}),f.d(v,"WebXRDefaultExperienceOptions",function(){return V_}),f.d(v,"WebXRDefaultExperience",function(){return Bu}),f.d(v,"WebXRFeatureName",function(){return ii}),f.d(v,"WebXRFeaturesManager",function(){return Yn}),f.d(v,"WebXRAbstractFeature",function(){return ri}),f.d(v,"WebXRHitTestLegacy",function(){return wa}),f.d(v,"WebXRAnchorSystem",function(){return Fa}),f.d(v,"WebXRPlaneDetector",function(){return Ba}
1608),f.d(v,"WebXRBackgroundRemover",function(){return Ua}),f.d(v,"WebXRMotionControllerTeleportation",function(){return ho}),f.d(v,"WebXRControllerPointerSelection",function(){return uo}),f.d(v,"IWebXRControllerPhysicsOptions",function(){return Gv}),f.d(v,"WebXRControllerPhysics",function(){return Va}),f.d(v,"WebXRHitTest",function(){return ka}),f.d(v,"WebXRFeaturePointSystem",function(){return Ga}),f.d(v,"WebXRHand",function(){return xf}),f.d(v,"WebXRHandTracking",function(){return za}),f.d(v,"WebXRAbstractMotionController",function(){return xr}),f.d(v,"WebXRControllerComponent",function(){return Cr}),f.d(v,"WebXRGenericTriggerMotionController",function(){return Hs}),f.d(v,"WebXRMicrosoftMixedRealityController",function(){return Rf}),f.d(v,"WebXRMotionControllerManager",function(){return wn}),f.d(v,"WebXROculusTouchMotionController",function(){return rl}),f.d(v,"WebXRHTCViveMotionController",function(){return Of}),f.d(v,"WebXRProfiledMotionController",function(){return Du});var B=f(35),_=f(91),x=f(6),u=f(0),M=f(9),R=f(11),C=function(){function r(t,e){this.triggerOptions=t,this.onBeforeExecuteObservable=new x.c,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._executeCurrent=function(t){if(this._nextActiveAction._condition){var e=this._nextActiveAction._condition,n=this._actionManager.getScene().getRenderId();if(e._evaluationId===n){if(!e._currentResult)return}else{if(e._evaluationId=n,!e.isValid())return void(e._currentResult=!1);e._currentResult=!0}}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){},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 u.d?t.x+", "+t.y:t instanceof u.e?t.x+", "+t.y+", "+t.z:t instanceof M.a?t.r+", "+t.g+", "+t.b:t instanceof M.b?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":"SceneProperties",value:t._isScene?"Scene":t.name}},r}();R.a.RegisteredTypes["BABYLON.Action"]=C;var m=f(47),c=f(1),E=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}(),A=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 Object(c.d)(t,r),Object.defineProperty(t,"IsEqual",{get:function(){return t._IsEqual},enumerable:!1,configurable:!0}),Object.defineProperty(t,"IsDifferent",{get:function(){return t._IsDifferent}
1608,enumerable:!1,configurable:!0}),Object.defineProperty(t,"IsGreater",{get:function(){return t._IsGreater},enumerable:!1,configurable:!0}),Object.defineProperty(t,"IsLesser",{get:function(){return t._IsLesser},enumerable:!1,configurable:!0}),t.prototype.isValid=function(){switch(this.operator){case t.IsGreater:return this._effectiveTarget[this._property]>this.value;case t.IsLesser:return this._effectiveTarget[this._property]<this.value;case t.IsEqual:case t.IsDifferent:var e;return e=this.value.equals?this.value.equals(this._effectiveTarget[this._property]):this.value===this._effectiveTarget[this._property],this.operator===t.IsEqual?e:!e}return!1},t.prototype.serialize=function(){return this._serialize({name:"ValueCondition",properties:[C._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:C._SerializeValueAsString(this.value)},{name:"operator",value:t.GetOperatorName(this.operator)}]})},t.GetOperatorName=function(e){switch(e){case t._IsEqual:return"IsEqual";case t._IsDifferent:return"IsDifferent";case t._IsGreater:return"IsGreater";case t._IsLesser:return"IsLesser";default:return""}},t._IsEqual=0,t._IsDifferent=1,t._IsGreater=2,t._IsLesser=3,t}(E),S=function(r){function t(e,n){var i=r.call(this,e)||this;return i.predicate=n,i}return Object(c.d)(t,r),t.prototype.isValid=function(){return this.predicate()},t}(E),g=function(r){function t(e,n,i){var o=r.call(this,e)||this;return o.value=i,o._target=n,o}return Object(c.d)(t,r),t.prototype.isValid=function(){return this._target.state===this.value},t.prototype.serialize=function(){return this._serialize({name:"StateCondition",properties:[C._GetTargetProperty(this._target),{name:"value",value:this.value}]})},t}(E);R.a.RegisteredTypes["BABYLON.ValueCondition"]=A,R.a.RegisteredTypes["BABYLON.PredicateCondition"]=S,R.a.RegisteredTypes["BABYLON.StateCondition"]=g;var l=f(8),h=f(2),b=function(r){function t(e,n,i,o){var a=r.call(this,e,o)||this;return a.propertyPath=i,a._target=a._effectiveTarget=n,a}return Object(c.d)(t,r),t.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath)},t.prototype.execute=function(){this._effectiveTarget[this._property]=!this._effectiveTarget[this._property]},t.prototype.serialize=function(e){return r.prototype._serialize.call(this,{name:"SwitchBooleanAction",properties:[C._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath}]},e)},t}(C),T=function(r){function t(e,n,i,o){var a=r.call(this,e,o)||this;return a.value=i,a._target=n,a}return Object(c.d)(t,r),t.prototype.execute=function(){this._target.state=this.value},t.prototype.serialize=function(e){return r.prototype._serialize.call(this,{name:"SetStateAction",properties:[C._GetTargetProperty(this._target),{name:"value",value:this.value}]},e)},t}(C),D=function(r){function t(e,n,i,o,a){var s=r.call(this,e,a)||this;return s.propertyPath=i,s.value=o,s._target=s._effectiveTarget=n,s}return Object(c.d)(t,r),t.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath)},t.prototype.execute=function(){this._effectiveTarget[this._property]=this.value,this._target.markAsDirty&&this._target.markAsDirty(this._property)},t.prototype.serialize=function(e){return r.prototype._serialize.call(this,{name:"SetValueAction",properties:[C._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:C._SerializeValueAsString(this.value)}]},e)},t}(C),w=function(r){function t(e,n,i,o,a){var s=r.call(this,e,a)||this;return s.propertyPath=i,s.value=o,s._target=s._effectiveTarget=n,s}return Object(c.d)(t,r),t.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath),typeof this._effectiveTarget[this._property]!="number"&&l.a.Warn("Warning: IncrementValueAction can only be used with number values")},t.prototype.execute=function(){this._effectiveTarget[this._property]+=this.value,this._target.markAsDirty&&this._target.markAsDirty(this._property)},t.prototype.serialize=function(e){return r.prototype._serialize.call(this,{name:"IncrementValueAction",properties:[C._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:C._SerializeValueAsString(this.value)}]},e)},t}(C),N=function(r){function t(e,n,i,o,a,s){var d=r.call(this,e,s)||this;return d.from=i,d.to=o,d.loop=a,d._target=n,d}return Object(c.d)(t,r),t.prototype._prepare=function(){},t.prototype.execute=function(){this._actionManager.getScene().beginAnimation(this._target,this.from,this.to,this.loop)},t.prototype.serialize=function(e){return r.prototype._serialize.call(this,{name:"PlayAnimationAction",properties:[C._GetTargetProperty(this._target),{name:"from",value:String(this.from)},{name:"to",value:String(this.to)},{name:"loop",value:C._SerializeValueAsString(this.loop)||!1}]},e)},t}(C),I=function(r){function t(e,n,i){var o=r.call(this,e,i)||this;return o._target=n,o}return Object(c.d)(t,r),t.prototype._prepare=function(){},t.prototype.execute=function(){this._actionManager.getScene().stopAnimation(this._target)},t.prototype.serialize=function(e){return r.prototype._serialize.call(this,{name:"StopAnimationAction",properties:[C._GetTargetProperty(this._target)]},e)},t}(C),V=function(r){function t(e,n){return e===void 0&&(e=h.a.ACTION_NothingTrigger),r.call(this,e,n)||this}return Object(c.d)(t,r),t.prototype.execute=function(){},t.prototype.serialize=function(e){return r.prototype._serialize.call(this,{name:"DoNothingAction",properties:[]},e)},t}(C),W=function(r){function t(e,n,i){var o=r.call(this,e,i)||this;return o.children=n,o}return Object(c.d)(t,r),t.prototype._prepare=function(){for(var e=0;e<this.children.length;e++)this.children[e]._actionManager=this._actionManager,this.children[e]._prepare()},t.prototype.execute=function(e){for(var n=0;n<this.children.length;n++)this.children[n].execute(e)},t.prototype.serialize=function(e){for(var n=r.prototype._serialize.call(this,{name:"CombineAction",properties:[],combine:[]},e),i=0;i<this.children.length;i++)n.combine.push(this.children[i].serialize(null));return n},t}(C),j=function(r){function t(e,n,i){var o=r.call(this,e,i)||this;return o.func=n,o}return Object(c.d)(t,r),t.prototype.execute=function(e){this.func(e)},t}(C),ne=function(r){function t(e,n,i,o){var a=r.call(this,e,o)||this;return a._target=n,a._parent=i,a}return Object(c.d)(t,r),t.prototype._prepare=function(){},t.prototype.execute=function(){if(this._target.parent!==this._parent){var e=this._parent.getWorldMatrix().clone();e.invert(),this._target.position=u.e.TransformCoordinates(this._target.position,e),this._target.parent=this._parent}},t.prototype.serialize=function(e){return r.prototype._serialize.call(this,{name:"SetParentAction",properties:[C._GetTargetProperty(this._target),C._GetTargetProperty(this._parent)]},e)},t}(C);R.a.RegisteredTypes["BABYLON.SetParentAction"]=ne,R.a.RegisteredTypes["BABYLON.ExecuteCodeAction"]=j,R.a.RegisteredTypes["BABYLON.DoNothingAction"]=V,R.a.RegisteredTypes["BABYLON.StopAnimationAction"]=I,R.a.RegisteredTypes["BABYLON.PlayAnimationAction"]=N,R.a.RegisteredTypes["BABYLON.IncrementValueAction"]=w,R.a.RegisteredTypes["BABYLON.SetValueAction"]=D,R.a.RegisteredTypes["BABYLON.SetStateAction"]=T,R.a.RegisteredTypes["BABYLON.SetParentAction"]=ne;var te=f(22),de=f(41),pe=function(r){function t(e){var n=r.call(this)||this;return n._scene=e||te.a.LastCreatedScene,e.actionManagers.push(n),n}return Object(c.d)(t,r),t.prototype.dispose=function(){for(var e=this._scene.actionManagers.indexOf(this),n=0;n<this.actions.length;n++){var i=this.actions[n];t.Triggers[i.trigger]--,t.Triggers[i.trigger]===0&&delete t.Triggers[i.trigger]}e>-1&&this._scene.actionManagers.splice(e,1)},t.prototype.getScene=function(){return this._scene},t.prototype.hasSpecificTriggers=function(e){for(var n=0;n<this.actions.length;n++){var i=this.actions[n];if(e.indexOf(i.trigger)>-1)return!0}return!1},t.prototype.hasSpecificTriggers2=function(e,n){for(var i=0;i<this.actions.length;i++){var o=this.actions[i];if(e==o.trigger||n==o.trigger)return!0}return!1},t.prototype.hasSpecificTrigger=function(e,n){for(var i=0;i<this.actions.length;i++){var o=this.actions[i];if(o.trigger===e&&(!n||n(o.getTriggerParameter())))return!0}return!1},Object.defineProperty(t.prototype,"hasPointerTriggers",{get:function(){for(var e=0;e<this.actions.length;e++){var n=this.actions[e];if(n.trigger>
1608=t.OnPickTrigger&&n.trigger<=t.OnPointerOutTrigger)return!0}return!1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasPickTriggers",{get:function(){for(var e=0;e<this.actions.length;e++){var n=this.actions[e];if(n.trigger>=t.OnPickTrigger&&n.trigger<=t.OnPickUpTrigger)return!0}return!1},enumerable:!1,configurable:!0}),t.prototype.registerAction=function(e){return e.trigger===t.OnEveryFrameTrigger&&this.getScene().actionManager!==this?(l.a.Warn("OnEveryFrameTrigger can only be used with scene.actionManager"),null):(this.actions.push(e),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,!0)},t.prototype.processTrigger=function(e,n){for(var i=0;i<this.actions.length;i++){var o=this.actions[i];if(o.trigger===e){if(n&&(e===t.OnKeyUpTrigger||e===t.OnKeyDownTrigger)){var a=o.getTriggerParameter();if(a&&a!==n.sourceEvent.keyCode){if(!a.toLowerCase)continue;var s=a.toLowerCase();if(s!==n.sourceEvent.key){var d=n.sourceEvent.charCode?n.sourceEvent.charCode:n.sourceEvent.keyCode;if(String.fromCharCode(d).toLowerCase()!==s)continue}}}o._executeCurrent(n)}}},t.prototype._getEffectiveTarget=function(e,n){for(var i=n.split("."),o=0;o<i.length-1;o++)e=e[i[o]];return e},t.prototype._getProperty=function(e){var n=e.split(".");return n[n.length-1]},t.prototype.serialize=function(e){for(var n={children:new Array,name:e,type:3,properties:new Array},i=0;i<this.actions.length;i++){var o={type:0,children:new Array,name:t.GetTriggerName(this.actions[i].trigger),properties:new Array},a=this.actions[i].triggerOptions;if(a&&typeof a!="number")if(a.parameter instanceof Node)o.properties.push(C._GetTargetProperty(a.parameter));else{var s={};de.a.DeepCopy(a.parameter,s,["mesh"]),a.parameter&&a.parameter.mesh&&(s._meshId=a.parameter.mesh.id),o.properties.push({name:"parameter",targetType:null,value:s})}this.actions[i].serialize(o),n.children.push(o)}return n},t.Parse=function(e,n,i){var o=new t(i);n===null?i.actionManager=o:n.actionManager=o;for(var a=function(F,z,J,ie){if(ie===null){var se=parseFloat(z);return z==="true"||z==="false"?z==="true":isNaN(se)?z:se}for(var ce=ie.split("."),ue=z.split(","),fe=0;fe<ce.length;fe++)J=J[ce[fe]];if(typeof J=="boolean")return ue[0]==="true";if(typeof J=="string")return ue[0];var ve=new Array;for(fe=0;fe<ue.length;fe++)ve.push(parseFloat(ue[fe]));return J instanceof u.e?u.e.FromArray(ve):J instanceof u.f?u.f.FromArray(ve):J instanceof M.a?M.a.FromArray(ve):J instanceof M.b?M.b.FromArray(ve):parseFloat(ue[0])},s=function(F,z,J,ie,se){if(se===void 0&&(se=null),!F.detached){var ce=new Array,ue=null,fe=null,ve=F.combine&&F.combine.length>0;if(F.type===2?ce.push(o):ce.push(z),ve){for(var Te=new Array,Oe=0;Oe<F.combine.length;Oe++)s(F.combine[Oe],t.NothingTrigger,J,ie,Te);ce.push(Te)}else for(var Pe=0;Pe<F.properties.length;Pe++){var Ee=F.properties[Pe].value,Se=F.properties[Pe].name,Le=F.properties[Pe].targetType;Se==="target"?Ee=ue=Le!==null&&Le==="SceneProperties"?i:i.getNodeByName(Ee):Se==="parent"?Ee=i.getNodeByName(Ee):Se==="sound"?i.getSoundByName&&(Ee=i.getSoundByName(Ee)):Se!=="propertyPath"?Ee=F.type===2&&Se==="operator"?A[Ee]:a(0,Ee,ue,Se==="value"?fe:null):fe=Ee,ce.push(Ee)}if(se===null?ce.push(J):ce.push(null),F.name==="InterpolateValueAction"){var xe=ce[ce.length-2];ce[ce.length-1]=xe,ce[ce.length-2]=J}var Ne=function(Fe,Ke){var nt=R.a.GetClass("BABYLON."+Fe);if(nt){var rt=Object.create(nt.prototype);return rt.constructor.apply(rt,Ke),rt}}(F.name,ce);if(Ne instanceof E&&J!==null){var Ie=new V(z,J);ie?ie.then(Ie):o.registerAction(Ie),ie=Ie}for(se===null?Ne instanceof E?(J=Ne,Ne=ie):(J=null,ie?ie.then(Ne):o.registerAction(Ne)):se.push(Ne),Pe=0;Pe<F.children.length;Pe++)s(F.children[Pe],z,J,Ne,null)}},d=0;d<e.children.length;d++){var p,y=e.children[d];if(y.properties.length>0){var P=y.properties[0].value,O=y.properties[0].targetType===null?P:i.getMeshByName(P);O._meshId&&(O.mesh=i.getMeshByID(O._meshId)),p={trigger:t[y.name],parameter:O}}else p=t[y.name];for(var U=0;
1608U<y.children.length;U++)y.detached||s(y.children[U],p,null,null)}},t.GetTriggerName=function(e){switch(e){case 0:return"NothingTrigger";case 1:return"OnPickTrigger";case 2:return"OnLeftPickTrigger";case 3:return"OnRightPickTrigger";case 4:return"OnCenterPickTrigger";case 5:return"OnPickDownTrigger";case 6:return"OnPickUpTrigger";case 7:return"OnLongPressTrigger";case 8:return"OnPointerOverTrigger";case 9:return"OnPointerOutTrigger";case 10:return"OnEveryFrameTrigger";case 11:return"OnIntersectionEnterTrigger";case 12:return"OnIntersectionExitTrigger";case 13:return"OnKeyDownTrigger";case 14:return"OnKeyUpTrigger";case 15:return"OnPickOutTrigger";default:return""}},t.NothingTrigger=h.a.ACTION_NothingTrigger,t.OnPickTrigger=h.a.ACTION_OnPickTrigger,t.OnLeftPickTrigger=h.a.ACTION_OnLeftPickTrigger,t.OnRightPickTrigger=h.a.ACTION_OnRightPickTrigger,t.OnCenterPickTrigger=h.a.ACTION_OnCenterPickTrigger,t.OnPickDownTrigger=h.a.ACTION_OnPickDownTrigger,t.OnDoublePickTrigger=h.a.ACTION_OnDoublePickTrigger,t.OnPickUpTrigger=h.a.ACTION_OnPickUpTrigger,t.OnPickOutTrigger=h.a.ACTION_OnPickOutTrigger,t.OnLongPressTrigger=h.a.ACTION_OnLongPressTrigger,t.OnPointerOverTrigger=h.a.ACTION_OnPointerOverTrigger,t.OnPointerOutTrigger=h.a.ACTION_OnPointerOutTrigger,t.OnEveryFrameTrigger=h.a.ACTION_OnEveryFrameTrigger,t.OnIntersectionEnterTrigger=h.a.ACTION_OnIntersectionEnterTrigger,t.OnIntersectionExitTrigger=h.a.ACTION_OnIntersectionExitTrigger,t.OnKeyDownTrigger=h.a.ACTION_OnKeyDownTrigger,t.OnKeyUpTrigger=15,t}(_.a),ae=function(r){function t(e,n,i){var o=r.call(this,e,i)||this;return o._sound=n,o}return Object(c.d)(t,r),t.prototype._prepare=function(){},t.prototype.execute=function(){this._sound!==void 0&&this._sound.play()},t.prototype.serialize=function(e){return r.prototype._serialize.call(this,{name:"PlaySoundAction",properties:[{name:"sound",value:this._sound.name}]},e)},t}(C),ee=function(r){function t(e,n,i){var o=r.call(this,e,i)||this;return o._sound=n,o}return Object(c.d)(t,r),t.prototype._prepare=function(){},t.prototype.execute=function(){this._sound!==void 0&&this._sound.stop()},t.prototype.serialize=function(e){return r.prototype._serialize.call(this,{name:"StopSoundAction",properties:[{name:"sound",value:this._sound.name}]},e)},t}(C);R.a.RegisteredTypes["BABYLON.PlaySoundAction"]=ee,R.a.RegisteredTypes["BABYLON.StopSoundAction"]=ee;var K,$=f(14),L=f(3);(function(r){r[r.STEP=1]="STEP"})(K||(K={}));var G=function(){function r(t,e,n){this.name=t,this.from=e,this.to=n}return r.prototype.clone=function(){return new r(this.name,this.from,this.to)},r}(),Q=f(29),oe=f(77),re=f(49),Y=function(){},k=function(){function r(t,e,n,i,o,a){this.name=t,this.targetProperty=e,this.framePerSecond=n,this.dataType=i,this.loopMode=o,this.enableBlending=a,this._runtimeAnimations=new Array,this._events=new Array,this.blendingSpeed=.01,this._ranges={},this.targetPropertyPath=e.split("."),this.dataType=i,this.loopMode=o===void 0?r.ANIMATIONLOOPMODE_CYCLE:o}return r._PrepareAnimation=function(t,e,n,i,o,a,s,d){var p=void 0;if(!isNaN(parseFloat(o))&&isFinite(o)?p=r.ANIMATIONTYPE_FLOAT:o instanceof u.b?p=r.ANIMATIONTYPE_QUATERNION:o instanceof u.e?p=r.ANIMATIONTYPE_VECTOR3:o instanceof u.d?p=r.ANIMATIONTYPE_VECTOR2:o instanceof M.a?p=r.ANIMATIONTYPE_COLOR3:o instanceof M.b?p=r.ANIMATIONTYPE_COLOR4:o instanceof oe.a&&(p=r.ANIMATIONTYPE_SIZE),p==null)return null;var y=new r(t,e,n,p,s),P=[{frame:0,value:o},{frame:i,value:a}];return y.setKeys(P),d!==void 0&&y.setEasingFunction(d),y},r.CreateAnimation=function(t,e,n,i){var o=new r(t+"Animation",t,n,e,r.ANIMATIONLOOPMODE_CONSTANT);return o.setEasingFunction(i),o},r.CreateAndStartAnimation=function(t,e,n,i,o,a,s,d,p,y){var P=r._PrepareAnimation(t,n,i,o,a,s,d,p);
1608return P?e.getScene().beginDirectAnimation(e,[P],0,o,P.loopMode===1,1,y):null},r.CreateAndStartHierarchyAnimation=function(t,e,n,i,o,a,s,d,p,y,P){var O=r._PrepareAnimation(t,i,o,a,s,d,p,y);return O?e.getScene().beginDirectHierarchyAnimation(e,n,[O],0,a,O.loopMode===1,1,P):null},r.CreateMergeAndStartAnimation=function(t,e,n,i,o,a,s,d,p,y){var P=r._PrepareAnimation(t,n,i,o,a,s,d,p);return P?(e.animations.push(P),e.getScene().beginAnimation(e,0,o,P.loopMode===1,1,y)):null},r.MakeAnimationAdditive=function(t,e,n,i,o){e===void 0&&(e=0),i===void 0&&(i=!1);var a=t;if(i&&((a=t.clone()).name=o||a.name),!a._keys.length)return a;e=e>=0?e:0;var s=0,d=a._keys[0],p=a._keys.length-1,y=a._keys[p],P={referenceValue:d.value,referencePosition:u.c.Vector3[0],referenceQuaternion:u.c.Quaternion[0],referenceScaling:u.c.Vector3[1],keyPosition:u.c.Vector3[2],keyQuaternion:u.c.Quaternion[1],keyScaling:u.c.Vector3[3]},O=!1,U=d.frame,F=y.frame;if(n){var z=a.getRange(n);z&&(U=z.from,F=z.to)}var J=d.frame===U,ie=y.frame===F;if(a._keys.length===1){var se=a._getKeyValue(a._keys[0]);P.referenceValue=se.clone?se.clone():se,O=!0}else e<=d.frame?(se=a._getKeyValue(d.value),P.referenceValue=se.clone?se.clone():se,O=!0):e>=y.frame&&(se=a._getKeyValue(y.value),P.referenceValue=se.clone?se.clone():se,O=!0);for(var ce=0;!O||!J||!ie&&ce<a._keys.length-1;){var ue=a._keys[ce],fe=a._keys[ce+1];if(!O&&e>=ue.frame&&e<=fe.frame){if(se=void 0,e===ue.frame)se=a._getKeyValue(ue.value);else if(e===fe.frame)se=a._getKeyValue(fe.value);else{var ve={key:ce,repeatCount:0,loopMode:this.ANIMATIONLOOPMODE_CONSTANT};se=a._interpolate(e,ve)}P.referenceValue=se.clone?se.clone():se,O=!0}if(!J&&U>=ue.frame&&U<=fe.frame){if(U===ue.frame)s=ce;else if(U===fe.frame)s=ce+1;else{ve={key:ce,repeatCount:0,loopMode:this.ANIMATIONLOOPMODE_CONSTANT};var Te={frame:U,value:(se=a._interpolate(U,ve)).clone?se.clone():se};a._keys.splice(ce+1,0,Te),s=ce+1}J=!0}!ie&&F>=ue.frame&&F<=fe.frame&&(F===ue.frame?p=ce:F===fe.frame?p=ce+1:(ve={key:ce,repeatCount:0,loopMode:this.ANIMATIONLOOPMODE_CONSTANT},Te={frame:F,value:(se=a._interpolate(F,ve)).clone?se.clone():se},a._keys.splice(ce+1,0,Te),p=ce+1),ie=!0),ce++}for(a.dataType===r.ANIMATIONTYPE_QUATERNION?P.referenceValue.normalize().conjugateInPlace():a.dataType===r.ANIMATIONTYPE_MATRIX&&(P.referenceValue.decompose(P.referenceScaling,P.referenceQuaternion,P.referencePosition),P.referenceQuaternion.normalize().conjugateInPlace()),ce=s;ce<=p;ce++)if(Te=a._keys[ce],!ce||a.dataType===r.ANIMATIONTYPE_FLOAT||Te.value!==d.value)switch(a.dataType){case r.ANIMATIONTYPE_MATRIX:Te.value.decompose(P.keyScaling,P.keyQuaternion,P.keyPosition),P.keyPosition.subtractInPlace(P.referencePosition),P.keyScaling.divideInPlace(P.referenceScaling),P.referenceQuaternion.multiplyToRef(P.keyQuaternion,P.keyQuaternion),u.a.ComposeToRef(P.keyScaling,P.keyQuaternion,P.keyPosition,Te.value);break;case r.ANIMATIONTYPE_QUATERNION:P.referenceValue.multiplyToRef(Te.value,Te.value);break;case r.ANIMATIONTYPE_VECTOR2:case r.ANIMATIONTYPE_VECTOR3:case r.ANIMATIONTYPE_COLOR3:case r.ANIMATIONTYPE_COLOR4:Te.value.subtractToRef(P.referenceValue,Te.value);break;case r.ANIMATIONTYPE_SIZE:Te.value.width-=P.referenceValue.width,Te.value.height-=P.referenceValue.height;break;default:Te.value-=P.referenceValue}return a},r.TransitionTo=function(t,e,n,i,o,a,s,d){if(d===void 0&&(d=null),s<=0)return n[t]=e,d&&d(),null;var p=o*(s/1e3);a.setKeys([{frame:0,value:n[t].clone?n[t].clone():n[t]},{frame:p,value:e}]),n.animations||(n.animations=[]),n.animations.push(a);var y=i.beginAnimation(n,0,p,!1);return y.onAnimationEnd=d,y},Object.defineProperty(r.prototype,"runtimeAnimations",{get:function(){return this._runtimeAnimations},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"hasRunningRuntimeAnimations",{get:function(){for(var t=0,e=this._runtimeAnimations;t<e.length;t++)if(!e[t].isStopped)return!0;return!1},enumerable:!1,configurable:!0}),r.prototype.toString=function(t){var e="Name: "+this.name+", property: "+this.targetProperty;if(e+=", datatype: "+["Float","Vector3","Quaternion","Matrix","Color3","Vector2"][this.dataType],e+=", nKeys: "+(this._keys?this._keys.length:"none"),e+=", nRanges: "+(this._ranges?Object.keys(this._ranges).length:"none"),t){e+=", Ranges: {";var n=!0;for(var i in this._ranges)n&&(e+=", ",n=!1),e+=i;e+="}"}return e},r.prototype.addEvent=function(t){this._events.push(t),this._events.sort(function(e,n){return e.frame-n.frame})},r.prototype.removeEvents=function(t){for(var e=0;e<this._events.length;e++)this._events[e].frame===t&&(this._events.splice(e,1),e--)},r.prototype.getEvents=function(){return this._events},r.prototype.createRange=function(t,e,n){this._ranges[t]||(this._ranges[t]=new G(t,e,n))},r.prototype.deleteRange=function(t,e){e===void 0&&(e=!0);var n=this._ranges[t];if(n){if(e)for(var i=n.from,o=n.to,a=this._keys.length-1;a>=0;a--)this._keys[a].frame>=i&&this._keys[a].frame<=o&&this._keys.splice(a,1);this._ranges[t]=null}},r.prototype.getRange=function(t){return this._ranges[t]},r.prototype.getKeys=function(){return this._keys},r.prototype.getHighestFrame=function(){for(var t=0,e=0,n=this._keys.length;e<n;e++)t<this._keys[e].frame&&(t=this._keys[e].frame);return t},r.prototype.getEasingFunction=function(){return this._easingFunction},r.prototype.setEasingFunction=function(t){this._easingFunction=t},r.prototype.floatInterpolateFunction=function(t,e,n){return $.a.Lerp(t,e,n)},r.prototype.floatInterpolateFunctionWithTangents=function(t,e,n,i,o){return $.a.Hermite(t,e,n,i,o)},r.prototype.quaternionInterpolateFunction=function(t,e,n){return u.b.
1608Slerp(t,e,n)},r.prototype.quaternionInterpolateFunctionWithTangents=function(t,e,n,i,o){return u.b.Hermite(t,e,n,i,o).normalize()},r.prototype.vector3InterpolateFunction=function(t,e,n){return u.e.Lerp(t,e,n)},r.prototype.vector3InterpolateFunctionWithTangents=function(t,e,n,i,o){return u.e.Hermite(t,e,n,i,o)},r.prototype.vector2InterpolateFunction=function(t,e,n){return u.d.Lerp(t,e,n)},r.prototype.vector2InterpolateFunctionWithTangents=function(t,e,n,i,o){return u.d.Hermite(t,e,n,i,o)},r.prototype.sizeInterpolateFunction=function(t,e,n){return oe.a.Lerp(t,e,n)},r.prototype.color3InterpolateFunction=function(t,e,n){return M.a.Lerp(t,e,n)},r.prototype.color4InterpolateFunction=function(t,e,n){return M.b.Lerp(t,e,n)},r.prototype._getKeyValue=function(t){return typeof t=="function"?t():t},r.prototype._interpolate=function(t,e){if(e.loopMode===r.ANIMATIONLOOPMODE_CONSTANT&&e.repeatCount>0)return e.highLimitValue.clone?e.highLimitValue.clone():e.highLimitValue;var n=this._keys;if(n.length===1)return this._getKeyValue(n[0].value);var i=e.key;if(n[i].frame>=t)for(;i-1>=0&&n[i].frame>=t;)i--;for(var o=i;o<n.length;o++){var a=n[o+1];if(a.frame>=t){e.key=o;var s=n[o],d=this._getKeyValue(s.value);if(s.interpolation===K.STEP)return d;var p=this._getKeyValue(a.value),y=s.outTangent!==void 0&&a.inTangent!==void 0,P=a.frame-s.frame,O=(t-s.frame)/P,U=this.getEasingFunction();switch(U!=null&&(O=U.ease(O)),this.dataType){case r.ANIMATIONTYPE_FLOAT:var F=y?this.floatInterpolateFunctionWithTangents(d,s.outTangent*P,p,a.inTangent*P,O):this.floatInterpolateFunction(d,p,O);switch(e.loopMode){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:return F;case r.ANIMATIONLOOPMODE_RELATIVE:return e.offsetValue*e.repeatCount+F}break;case r.ANIMATIONTYPE_QUATERNION:var z=y?this.quaternionInterpolateFunctionWithTangents(d,s.outTangent.scale(P),p,a.inTangent.scale(P),O):this.quaternionInterpolateFunction(d,p,O);switch(e.loopMode){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:return z;case r.ANIMATIONLOOPMODE_RELATIVE:return z.addInPlace(e.offsetValue.scale(e.repeatCount))}return z;case r.ANIMATIONTYPE_VECTOR3:var J=y?this.vector3InterpolateFunctionWithTangents(d,s.outTangent.scale(P),p,a.inTangent.scale(P),O):this.vector3InterpolateFunction(d,p,O);switch(e.loopMode){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:return J;case r.ANIMATIONLOOPMODE_RELATIVE:return J.add(e.offsetValue.scale(e.repeatCount))}case r.ANIMATIONTYPE_VECTOR2:var ie=y?this.vector2InterpolateFunctionWithTangents(d,s.outTangent.scale(P),p,a.inTangent.scale(P),O):this.vector2InterpolateFunction(d,p,O);switch(e.loopMode){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:return ie;case r.ANIMATIONLOOPMODE_RELATIVE:return ie.add(e.offsetValue.scale(e.repeatCount))}case r.ANIMATIONTYPE_SIZE:switch(e.loopMode){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:return this.sizeInterpolateFunction(d,p,O);case r.ANIMATIONLOOPMODE_RELATIVE:return this.sizeInterpolateFunction(d,p,O).add(e.offsetValue.scale(e.repeatCount))}case r.ANIMATIONTYPE_COLOR3:switch(e.loopMode){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:return this.color3InterpolateFunction(d,p,O);case r.ANIMATIONLOOPMODE_RELATIVE:return this.color3InterpolateFunction(d,p,O).add(e.offsetValue.scale(e.repeatCount))}case r.ANIMATIONTYPE_COLOR4:switch(e.loopMode){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:return this.color4InterpolateFunction(d,p,O);case r.ANIMATIONLOOPMODE_RELATIVE:return this.color4InterpolateFunction(d,p,O).add(e.offsetValue.scale(e.repeatCount))}case r.ANIMATIONTYPE_MATRIX:switch(e.loopMode){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:if(r.AllowMatricesInterpolation)return this.matrixInterpolateFunction(d,p,O,e.workValue);case r.ANIMATIONLOOPMODE_RELATIVE:return d}}break}}return this._getKeyValue(n[n.length-1].value)},r.prototype.matrixInterpolateFunction=function(t,e,n,i){return r.AllowMatrixDecomposeForInterpolation?i?(u.a.DecomposeLerpToRef(t,e,n,i),i):u.a.DecomposeLerp(t,e,n):i?(u.a.LerpToRef(t,e,n,i),i):u.a.Lerp(t,e,n)},r.prototype.clone=function(){var t=new r(this.name,this.targetPropertyPath.join("."),this.framePerSecond,this.dataType,this.loopMode);
1608if(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){this._keys=t.slice(0)},r.prototype.serialize=function(){var t={};t.name=this.name,t.property=this.targetProperty,t.framePerSecond=this.framePerSecond,t.dataType=this.dataType,t.loopBehavior=this.loopMode,t.enableBlending=this.enableBlending,t.blendingSpeed=this.blendingSpeed;var e=this.dataType;t.keys=[];for(var n=this.getKeys(),i=0;i<n.length;i++){var o=n[i],a={};switch(a.frame=o.frame,e){case r.ANIMATIONTYPE_FLOAT:a.values=[o.value],o.inTangent!==void 0&&a.values.push(o.inTangent),o.outTangent!==void 0&&(o.inTangent===void 0&&a.values.push(void 0),a.values.push(o.outTangent));break;case r.ANIMATIONTYPE_QUATERNION:case r.ANIMATIONTYPE_MATRIX:case r.ANIMATIONTYPE_VECTOR3:case r.ANIMATIONTYPE_COLOR3:case r.ANIMATIONTYPE_COLOR4:a.values=o.value.asArray(),o.inTangent!=null&&a.values.push(o.inTangent.asArray()),o.outTangent!=null&&(o.inTangent===void 0&&a.values.push(void 0),a.values.push(o.outTangent.asArray()))}t.keys.push(a)}for(var s in t.ranges=[],this._ranges){var d=this._ranges[s];if(d){var p={};p.name=s,p.from=d.from,p.to=d.to,t.ranges.push(p)}}return t},r._UniversalLerp=function(t,e,n){var i=t.constructor;return i.Lerp?i.Lerp(t,e,n):i.Slerp?i.Slerp(t,e,n):t.toFixed?t*(1-n)+n*e:e},r.Parse=function(t){var e,n,i=new r(t.name,t.property,t.framePerSecond,t.dataType,t.loopBehavior),o=t.dataType,a=[];for(t.enableBlending&&(i.enableBlending=t.enableBlending),t.blendingSpeed&&(i.blendingSpeed=t.blendingSpeed),n=0;n<t.keys.length;n++){var s,d,p=t.keys[n];switch(o){case r.ANIMATIONTYPE_FLOAT:e=p.values[0],p.values.length>=1&&(s=p.values[1]),p.values.length>=2&&(d=p.values[2]);break;case r.ANIMATIONTYPE_QUATERNION:if(e=u.b.FromArray(p.values),p.values.length>=8){var y=u.b.FromArray(p.values.slice(4,8));y.equals(u.b.Zero())||(s=y)}if(p.values.length>=12){var P=u.b.FromArray(p.values.slice(8,12));P.equals(u.b.Zero())||(d=P)}break;case r.ANIMATIONTYPE_MATRIX:e=u.a.FromArray(p.values);break;case r.ANIMATIONTYPE_COLOR3:e=M.a.FromArray(p.values);break;case r.ANIMATIONTYPE_COLOR4:e=M.b.FromArray(p.values);break;case r.ANIMATIONTYPE_VECTOR3:default:e=u.e.FromArray(p.values)}var O={};O.frame=p.frame,O.value=e,s!=null&&(O.inTangent=s),d!=null&&(O.outTangent=d),a.push(O)}if(i.setKeys(a),t.ranges)for(n=0;n<t.ranges.length;n++)e=t.ranges[n],i.createRange(e.name,e.from,e.to);return i},r.AppendSerializedAnimations=function(t,e){L.a.AppendSerializedAnimations(t,e)},r.ParseFromFileAsync=function(t,e){var n=this;return new Promise(function(i,o){var a=new re.a;a.addEventListener("readystatechange",function(){if(a.readyState==4)if(a.status==200){var s=JSON.parse(a.responseText);if(s.length){for(var d=new Array,p=0,y=s;p<y.length;p++){var P=y[p];d.push(n.Parse(P))}i(d)}else d=n.Parse(s),t&&(d.name=t),i(d)}else o("Unable to load the animation")}),a.open("GET",e),a.send()})},r.CreateFromSnippetAsync=function(t){var e=this;return new Promise(function(n,i){var o=new re.a;o.addEventListener("readystatechange",function(){if(o.readyState==4)if(o.status==200){var a=JSON.parse(JSON.parse(o.responseText).jsonPayload);if(a.animations){for(var s=JSON.parse(a.animations),d=new Array,p=0,y=s;p<y.length;p++){var P=y[p];d.push(e.Parse(P))}n(d)}else s=JSON.parse(a.animation),(d=e.Parse(s)).snippetId=t,n(d)}else i("Unable to load the snippet "+t)}),o.open("GET",e.SnippetUrl+"/"+t.replace(/#/g,"/")),o.send()})},r.AllowMatricesInterpolation=!1,r.AllowMatrixDecomposeForInterpolation=!0,r.SnippetUrl="https://snippet.babylonjs.com",r.ANIMATIONTYPE_FLOAT=0,r.ANIMATIONTYPE_VECTOR3=1,r.ANIMATIONTYPE_QUATERNION=2,r.ANIMATIONTYPE_MATRIX=3,r.ANIMATIONTYPE_COLOR3=4,r.ANIMATIONTYPE_COLOR4=7,r.ANIMATIONTYPE_VECTOR2=5,r.ANIMATIONTYPE_SIZE=6,r.ANIMATIONLOOPMODE_RELATIVE=0,r.ANIMATIONLOOPMODE_CYCLE=1,r.ANIMATIONLOOPMODE_CONSTANT=2,r}();R.a.RegisteredTypes["BABYLON.Animation"]=k,Q.a._AnimationRangeFactory=function(r,t,e){return new G(r,t,e)};var H=function(r){function t(e,n,i,o,a,s,d,p){a===void 0&&(a=1e3);var y=r.call(this,e,s)||this;return y.duration=1e3,y.onInterpolationDoneObservable=new x.c,y.propertyPath=i,y.value=o,y.duration=a,y.stopOtherAnimations=d,y.onInterpolationDone=p,y._target=y._effectiveTarget=n,y}return Object(c.d)(t,r),t.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath)},t.prototype.execute=function(){var e,n=this,i=this._actionManager.getScene(),o=[{frame:0,value:this._effectiveTarget[this._property]},{frame:100,value:this.value}];if(typeof this.value=="number")e=k.ANIMATIONTYPE_FLOAT;else if(this.value instanceof M.a)e=k.ANIMATIONTYPE_COLOR3;else if(this.value instanceof u.e)e=k.ANIMATIONTYPE_VECTOR3;else if(this.value instanceof u.a)e=k.ANIMATIONTYPE_MATRIX;else{if(!(this.value instanceof u.b))return void l.a.Warn("InterpolateValueAction: Unsupported type ("+typeof this.value+")");e=k.ANIMATIONTYPE_QUATERNION}var a=new k("InterpolateValueAction",this._property,1e3/this.duration*100,e,k.ANIMATIONLOOPMODE_CONSTANT);a.setKeys(o),this.stopOtherAnimations&&i.stopAnimation(this._effectiveTarget),i.beginDirectAnimation(this._effectiveTarget,[a],0,100,!1,1,function(){n.onInterpolationDoneObservable.notifyObservers(n),n.onInterpolationDone&&n.onInterpolationDone()})},t.prototype.serialize=function(e){return r.prototype._serialize.call(this,{name:"InterpolateValueAction",properties:[C._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:C._SerializeValueAsString(this.value)},{name:"duration",value:C._SerializeValueAsString(this.duration)},{name:"stopOtherAnimations",value:C._SerializeValueAsString(this.stopOtherAnimations)||!1}]},e)},t}(C);R.a.RegisteredTypes["BABYLON.InterpolateValueAction"]=H;var Z=Object.freeze(new u.b(0,0,0,0)),X=Object.freeze(u.e.Zero()),q=Object.freeze(u.d.Zero()),he=Object.freeze(oe.a.Zero()),ge=Object.freeze(M.a.Black()),me=function(){function r(t,e,n,i){var o=this;if(this._events=new Array,this._currentFrame=0,this._originalValue=new Array,this._originalBlendValue=null,this._offsetsCache={}
1608,this._highLimitsCache={},this._stopped=!1,this._blendingFactor=0,this._currentValue=null,this._currentActiveTarget=null,this._directTarget=null,this._targetPath="",this._weight=1,this._ratioOffset=0,this._previousDelay=0,this._previousRatio=0,this._targetIsArray=!1,this._animation=e,this._target=t,this._scene=n,this._host=i,this._activeTargets=[],e._runtimeAnimations.push(this),this._animationState={key:0,repeatCount:0,loopMode:this._getCorrectLoopMode()},this._animation.dataType===k.ANIMATIONTYPE_MATRIX&&(this._animationState.workValue=u.a.Zero()),this._keys=this._animation.getKeys(),this._minFrame=this._keys[0].frame,this._maxFrame=this._keys[this._keys.length-1].frame,this._minValue=this._keys[0].value,this._maxValue=this._keys[this._keys.length-1].value,this._minFrame!==0){var a={frame:0,value:this._minValue};this._keys.splice(0,0,a)}if(this._target instanceof Array){for(var s=0,d=0,p=this._target;d<p.length;d++){var y=p[d];this._preparePath(y,s),this._getOriginalValues(s),s++}this._targetIsArray=!0}else this._preparePath(this._target),this._getOriginalValues(),this._targetIsArray=!1,this._directTarget=this._activeTargets[0];var P=e.getEvents();P&&P.length>0&&P.forEach(function(O){o._events.push(O._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[n[0]],o=1;o<n.length-1;o++)i=i[n[o]];this._targetPath=n[n.length-1],this._activeTargets[e]=i}else this._targetPath=n[0],this._activeTargets[e]=t},Object.defineProperty(r.prototype,"animation",{get:function(){return this._animation},enumerable:!1,configurable:!0}),r.prototype.reset=function(t){if(t===void 0&&(t=!1),t)if(this._target instanceof Array)for(var e=0,n=0,i=this._target;n<i.length;n++){var o=i[n];this._originalValue[e]!==void 0&&this._setValue(o,this._activeTargets[e],this._originalValue[e],-1,e),e++}else this._originalValue[0]!==void 0&&this._setValue(this._target,this._directTarget,this._originalValue[0],-1,0);for(this._offsetsCache={},this._highLimitsCache={},this._currentFrame=0,this._blendingFactor=0,e=0;e<this._events.length;e++)this._events[e].isDone=!1},r.prototype.isStopped=function(){return this._stopped},r.prototype.dispose=function(){var t=this._animation.runtimeAnimations.indexOf(this);t>-1&&this._animation.runtimeAnimations.splice(t,1)},r.prototype.setValue=function(t,e){if(this._targetIsArray)for(var n=0;n<this._target.length;n++){var i=this._target[n];this._setValue(i,this._activeTargets[n],t,e,n)}else this._setValue(this._target,this._directTarget,t,e,0)},r.prototype._getOriginalValues=function(t){var e;t===void 0&&(t=0);var n=this._activeTargets[t];(e=n.getRestPose&&this._targetPath==="_matrix"?n.getRestPose():n[this._targetPath])&&e.clone?this._originalValue[t]=e.clone():this._originalValue[t]=e},r.prototype._setValue=function(t,e,n,i,o){if(this._currentActiveTarget=e,this._weight=i,this._enableBlending&&this._blendingFactor<=1){if(!this._originalBlendValue){var a=e[this._targetPath];a.clone?this._originalBlendValue=a.clone():this._originalBlendValue=a}this._originalBlendValue.m?k.AllowMatrixDecomposeForInterpolation?this._currentValue?u.a.DecomposeLerpToRef(this._originalBlendValue,n,this._blendingFactor,this._currentValue):this._currentValue=u.a.DecomposeLerp(this._originalBlendValue,n,this._blendingFactor):this._currentValue?u.a.LerpToRef(this._originalBlendValue,n,this._blendingFactor,this._currentValue):this._currentValue=u.a.Lerp(this._originalBlendValue,n,this._blendingFactor):this._currentValue=k._UniversalLerp(this._originalBlendValue,n,this._blendingFactor);var s=t&&t.animationPropertiesOverride?t.animationPropertiesOverride.blendingSpeed:this._animation.blendingSpeed;this._blendingFactor+=s}else this._currentValue=n;i!==-1?this._scene._registerTargetForLateAnimationBinding(this,this._originalValue[o]):e[this._targetPath]=this._currentValue,t.markAsDirty&&t.markAsDirty(this._animation.targetProperty)}
1608,r.prototype._getCorrectLoopMode=function(){return this._target&&this._target.animationPropertiesOverride?this._target.animationPropertiesOverride.loopMode:this._animation.loopMode},r.prototype.goToFrame=function(t){var e=this._animation.getKeys();t<e[0].frame?t=e[0].frame:t>e[e.length-1].frame&&(t=e[e.length-1].frame);var n=this._events;if(n.length)for(var i=0;i<n.length;i++)n[i].onlyOnce||(n[i].isDone=n[i].frame<t);this._currentFrame=t;var o=this._animation._interpolate(t,this._animationState);this.setValue(o,-1)},r.prototype._prepareForSpeedRatioChange=function(t){var e=this._previousDelay*(this._animation.framePerSecond*t)/1e3;this._ratioOffset=this._previousRatio-e},r.prototype.animate=function(t,e,n,i,o,a){a===void 0&&(a=-1);var s=this._animation,d=s.targetPropertyPath;if(!d||d.length<1)return this._stopped=!0,!1;var p=!0;(e<this._minFrame||e>this._maxFrame)&&(e=this._minFrame),(n<this._minFrame||n>this._maxFrame)&&(n=this._maxFrame);var y,P,O=n-e,U=t*(s.framePerSecond*o)/1e3+this._ratioOffset,F=0;if(this._previousDelay=t,this._previousRatio=U,!i&&n>=e&&U>=O)p=!1,F=s._getKeyValue(this._maxValue);else if(!i&&e>=n&&U<=O)p=!1,F=s._getKeyValue(this._minValue);else if(this._animationState.loopMode!==k.ANIMATIONLOOPMODE_CYCLE){var z=n.toString()+e.toString();if(!this._offsetsCache[z]){this._animationState.repeatCount=0,this._animationState.loopMode=k.ANIMATIONLOOPMODE_CYCLE;var J=s._interpolate(e,this._animationState),ie=s._interpolate(n,this._animationState);switch(this._animationState.loopMode=this._getCorrectLoopMode(),s.dataType){case k.ANIMATIONTYPE_FLOAT:this._offsetsCache[z]=ie-J;break;case k.ANIMATIONTYPE_QUATERNION:this._offsetsCache[z]=ie.subtract(J);break;case k.ANIMATIONTYPE_VECTOR3:this._offsetsCache[z]=ie.subtract(J);case k.ANIMATIONTYPE_VECTOR2:this._offsetsCache[z]=ie.subtract(J);case k.ANIMATIONTYPE_SIZE:this._offsetsCache[z]=ie.subtract(J);case k.ANIMATIONTYPE_COLOR3:this._offsetsCache[z]=ie.subtract(J)}this._highLimitsCache[z]=ie}F=this._highLimitsCache[z],y=this._offsetsCache[z]}if(y===void 0)switch(s.dataType){case k.ANIMATIONTYPE_FLOAT:y=0;break;case k.ANIMATIONTYPE_QUATERNION:y=Z;break;case k.ANIMATIONTYPE_VECTOR3:y=X;break;case k.ANIMATIONTYPE_VECTOR2:y=q;break;case k.ANIMATIONTYPE_SIZE:y=he;break;case k.ANIMATIONTYPE_COLOR3:y=ge}if(this._host&&this._host.syncRoot){var se=this._host.syncRoot;P=e+(n-e)*((se.masterFrame-se.fromFrame)/(se.toFrame-se.fromFrame))}else P=p&&O!==0?e+U%O:n;var ce=this._events;if((O>0&&this.currentFrame>P||O<0&&this.currentFrame<P)&&(this._onLoop(),ce.length))for(var ue=0;ue<ce.length;ue++)ce[ue].onlyOnce||(ce[ue].isDone=!1);this._currentFrame=P,this._animationState.repeatCount=O===0?0:U/O>>0,this._animationState.highLimitValue=F,this._animationState.offsetValue=y;var fe=s._interpolate(P,this._animationState);if(this.setValue(fe,a),ce.length){for(ue=0;ue<ce.length;ue++)if(O>0&&P>=ce[ue].frame&&ce[ue].frame>=e||O<0&&P<=ce[ue].frame&&ce[ue].frame<=e){var ve=ce[ue];ve.isDone||(ve.onlyOnce&&(ce.splice(ue,1),ue--),ve.isDone=!0,ve.action(P))}}return p||(this._stopped=!0),p},r}(),_e=f(20),be=f(57),Ce=f(44),ye=f(23),Be=function(r){function t(e,n,i,o,a,s,d){i===void 0&&(i=null),o===void 0&&(o=null),a===void 0&&(a=null),s===void 0&&(s=null),d===void 0&&(d=null);var p=r.call(this,e,n.getScene())||this;return p.name=e,p.children=new Array,p.animations=new Array,p._index=null,p._absoluteTransform=new u.a,p._invertedAbsoluteTransform=new u.a,p._scalingDeterminant=1,p._worldTransform=new u.a,p._needToDecompose=!0,p._needToCompose=!1,p._linkedTransformNode=null,p._waitingTransformNodeId=null,p._skeleton=n,p._localMatrix=o?o.clone():u.a.Identity(),p._restPose=a||p._localMatrix.clone(),p._bindPose=p._localMatrix.clone(),p._baseMatrix=s||p._localMatrix.clone(),p._index=d,n.bones.push(p),p.setParent(i,!1),(s||o)&&p._updateDifferenceMatrix(),p}return Object(c.d)(t,r),Object.defineProperty(t.prototype,"_matrix",{get:function(){return this._compose(),this._localMatrix},set:function(e){this._localMatrix.copyFrom(e),this._needToDecompose=!0},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"Bone"},t.prototype.getSkeleton=function(){return this._skeleton},t.prototype.getParent=function(){return this._parent},t.prototype.getChildren=function(){return this.children},t.prototype.getIndex=function(){return this._index===null?this.get
1608Skeleton().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._parent=e,this._parent&&this._parent.children.push(this),n&&this._updateDifferenceMatrix(),this.markAsDirty()}},t.prototype.getLocalMatrix=function(){return this._compose(),this._localMatrix},t.prototype.getBaseMatrix=function(){return this._baseMatrix},t.prototype.getRestPose=function(){return this._restPose},t.prototype.setRestPose=function(e){this._restPose.copyFrom(e)},t.prototype.getBindPose=function(){return this._bindPose},t.prototype.setBindPose=function(e){this._bindPose.copyFrom(e)},t.prototype.getWorldMatrix=function(){return this._worldTransform},t.prototype.returnToRest=function(){this._skeleton._numBonesWithLinkedTransformNode>0?this.updateMatrix(this._restPose,!1,!1):this.updateMatrix(this._restPose,!1,!0)},t.prototype.getInvertedAbsoluteTransform=function(){return this._invertedAbsoluteTransform},t.prototype.getAbsoluteTransform=function(){return this._absoluteTransform},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=u.e.Zero(),this._localRotation=u.b.Zero(),this._localPosition=u.e.Zero()),this._localMatrix.decompose(this._localScaling,this._localRotation,this._localPosition))},t.prototype._compose=function(){this._needToCompose&&(this._localScaling?(this._needToCompose=!1,u.a.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._baseMatrix.copyFrom(e),n&&this._updateDifferenceMatrix(),i?(this._needToCompose=!1,this._localMatrix.copyFrom(e),this._markAsDirtyAndDecompose()):this.markAsDirty()},t.prototype._updateDifferenceMatrix=function(e,n){if(n===void 0&&(n=!0),e||(e=this._baseMatrix),this._parent?e.multiplyToRef(this._parent._absoluteTransform,this._absoluteTransform):this._absoluteTransform.copyFrom(e),this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform),n)for(var i=0;i<this.children.length;i++)this.children[i]._updateDifferenceMatrix();this._scalingDeterminant=this._absoluteTransform.determinant()<0?-1:1},t.prototype.markAsDirty=function(){this._currentRenderId++,this._childUpdateId++,this._skeleton._markAsDirty()},t.prototype._markAsDirtyAndCompose=function(){this.markAsDirty(),this._needToCompose=!0},t.prototype._markAsDirtyAndDecompose=function(){this.markAsDirty(),this._needToDecompose=!0},t.prototype.translate=function(e,n,i){n===void 0&&(n=ye.c.LOCAL);var o=this.getLocalMatrix();if(n==ye.c.LOCAL)o.addAtIndex(12,e.x),o.addAtIndex(13,e.y),o.addAtIndex(14,e.z);else{var a=null;i&&(a=i.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var s=t._tmpMats[0],d=t._tmpVecs[0];this._parent?i&&a?(s.copyFrom(this._parent.getAbsoluteTransform()),s.multiplyToRef(a,s)):s.
1608copyFrom(this._parent.getAbsoluteTransform()):u.a.IdentityToRef(s),s.setTranslationFromFloats(0,0,0),s.invert(),u.e.TransformCoordinatesToRef(e,s,d),o.addAtIndex(12,d.x),o.addAtIndex(13,d.y),o.addAtIndex(14,d.z)}this._markAsDirtyAndDecompose()},t.prototype.setPosition=function(e,n,i){n===void 0&&(n=ye.c.LOCAL);var o=this.getLocalMatrix();if(n==ye.c.LOCAL)o.setTranslationFromFloats(e.x,e.y,e.z);else{var a=null;i&&(a=i.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var s=t._tmpMats[0],d=t._tmpVecs[0];this._parent?(i&&a?(s.copyFrom(this._parent.getAbsoluteTransform()),s.multiplyToRef(a,s)):s.copyFrom(this._parent.getAbsoluteTransform()),s.invert()):u.a.IdentityToRef(s),u.e.TransformCoordinatesToRef(e,s,d),o.setTranslationFromFloats(d.x,d.y,d.z)}this._markAsDirtyAndDecompose()},t.prototype.setAbsolutePosition=function(e,n){this.setPosition(e,ye.c.WORLD,n)},t.prototype.scale=function(e,n,i,o){o===void 0&&(o=!1);var a=this.getLocalMatrix(),s=t._tmpMats[0];u.a.ScalingToRef(e,n,i,s),s.multiplyToRef(a,a),s.invert();for(var d=0,p=this.children;d<p.length;d++){var y=(U=p[d]).getLocalMatrix();y.multiplyToRef(s,y),y.multiplyAtIndex(12,e),y.multiplyAtIndex(13,n),y.multiplyAtIndex(14,i),U._markAsDirtyAndDecompose()}if(this._markAsDirtyAndDecompose(),o)for(var P=0,O=this.children;P<O.length;P++){var U;(U=O[P]).scale(e,n,i,o)}},t.prototype.setScale=function(e){this._decompose(),this._localScaling.copyFrom(e),this._markAsDirtyAndCompose()},t.prototype.getScale=function(){return this._decompose(),this._localScaling},t.prototype.getScaleToRef=function(e){this._decompose(),e.copyFrom(this._localScaling)},t.prototype.setYawPitchRoll=function(e,n,i,o,a){if(o===void 0&&(o=ye.c.LOCAL),o===ye.c.LOCAL){var s=t._tmpQuat;return u.b.RotationYawPitchRollToRef(e,n,i,s),void this.setRotationQuaternion(s,o,a)}var d=t._tmpMats[0];if(this._getNegativeRotationToRef(d,a)){var p=t._tmpMats[1];u.a.RotationYawPitchRollToRef(e,n,i,p),d.multiplyToRef(p,p),this._rotateWithMatrix(p,o,a)}},t.prototype.rotate=function(e,n,i,o){i===void 0&&(i=ye.c.LOCAL);var a=t._tmpMats[0];a.setTranslationFromFloats(0,0,0),u.a.RotationAxisToRef(e,n,a),this._rotateWithMatrix(a,i,o)},t.prototype.setAxisAngle=function(e,n,i,o){if(i===void 0&&(i=ye.c.LOCAL),i===ye.c.LOCAL){var a=t._tmpQuat;return u.b.RotationAxisToRef(e,n,a),void this.setRotationQuaternion(a,i,o)}var s=t._tmpMats[0];if(this._getNegativeRotationToRef(s,o)){var d=t._tmpMats[1];u.a.RotationAxisToRef(e,n,d),s.multiplyToRef(d,d),this._rotateWithMatrix(d,i,o)}},t.prototype.setRotation=function(e,n,i){n===void 0&&(n=ye.c.LOCAL),this.setYawPitchRoll(e.y,e.x,e.z,n,i)},t.prototype.setRotationQuaternion=function(e,n,i){if(n===void 0&&(n=ye.c.LOCAL),n===ye.c.LOCAL)return this._decompose(),this._localRotation.copyFrom(e),void this._markAsDirtyAndCompose();var o=t._tmpMats[0];if(this._getNegativeRotationToRef(o,i)){var a=t._tmpMats[1];u.a.FromQuaternionToRef(e,a),o.multiplyToRef(a,a),this._rotateWithMatrix(a,n,i)}},t.prototype.setRotationMatrix=function(e,n,i){if(n===void 0&&(n=ye.c.LOCAL),n===ye.c.LOCAL){var o=t._tmpQuat;return u.b.FromRotationMatrixToRef(e,o),void this.setRotationQuaternion(o,n,i)}var a=t._tmpMats[0];if(this._getNegativeRotationToRef(a,i)){var s=t._tmpMats[1];s.copyFrom(e),a.multiplyToRef(e,s),this._rotateWithMatrix(s,n,i)}},t.prototype._rotateWithMatrix=function(e,n,i){n===void 0&&(n=ye.c.LOCAL);var o=this.getLocalMatrix(),a=o.m[12],s=o.m[13],d=o.m[14],p=this.getParent(),y=t._tmpMats[3],P=t._tmpMats[4];p&&n==ye.c.WORLD?(i?(y.copyFrom(i.getWorldMatrix()),p.getAbsoluteTransform().multiplyToRef(y,y)):y.copyFrom(p.getAbsoluteTransform()),P.copyFrom(y),P.invert(),o.multiplyToRef(y,o),o.multiplyToRef(e,o),o.multiplyToRef(P,o)):n==ye.c.WORLD&&i?(y.copyFrom(i.getWorldMatrix()),P.copyFrom(y),P.invert(),o.multiplyToRef(y,o),o.multiplyToRef(e,o),o.multiplyToRef(P,o)):o.multiplyToRef(e,o),o.setTranslationFromFloats(a,s,d),this.computeAbsoluteTransforms(),this._markAsDirtyAndDecompose()},t.prototype._getNegativeRotationToRef=function(e,n){var i=t._tmpMats[2];return e.copyFrom(this.getAbsoluteTransform()),n&&(e.multiplyToRef(n.getWorldMatrix(),e),u.a.ScalingToRef(n.scaling.x,n.scaling.y,n.scaling.z,i)),e.invert(),!isNaN(e.m[0])&&(i.multiplyAtIndex(0,this._scalingDeterminant),e.multiplyToRef(i,e),!0)},t.prototype.getPosition=function(e,n){e===void 0&&(e=ye.c.LOCAL),n===void 0&&(n=null);var i=u.e.Zero();return this.getPositionToRef(e,n,i),i},t.prototype.getPositionToRef=function(e,n,i){if(e===void 0&&(e=ye.c.LOCAL),e==ye.c.LOCAL){var o=this.getLocalMatrix();i.x=o.m[12],i.y=o.m[13],i.z=o.m[14]}else{var a=null;n&&(a=n.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var s=t._tmpMats[0];n&&a?(s.copyFrom(this.getAbsoluteTransform()),s.multiplyToRef(a,s)):s=this.getAbsoluteTransform(),i.x=s.m[12],i.y=s.m[13],i.z=s.m[14]}},t.prototype.getAbsolutePosition=function(e){e===void 0&&(e=null);var n=u.e.Zero();return this.getPositionToRef(ye.c.WORLD,e,n),n},t.prototype.getAbsolutePositionToRef=function(e,n){this.getPositionToRef(ye.c.WORLD,e,n)},t.prototype.computeAbsoluteTransforms=function(){if(this._compose(),this._parent)this._localMatrix.multiplyToRef(this._parent._absoluteTransform,this._absoluteTransform);else{this._absoluteTransform.copyFrom(this._localMatrix);var e=this._skeleton.getPoseMatrix();e&&this._absoluteTransform.multiplyToRef(e,this._absoluteTransform)}for(var n=this.children,i=n.length,o=0;o<i;o++)n[o].computeAbsoluteTransforms()}
1608,t.prototype.getDirection=function(e,n){n===void 0&&(n=null);var i=u.e.Zero();return this.getDirectionToRef(e,n,i),i},t.prototype.getDirectionToRef=function(e,n,i){n===void 0&&(n=null);var o=null;n&&(o=n.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var a=t._tmpMats[0];a.copyFrom(this.getAbsoluteTransform()),n&&o&&a.multiplyToRef(o,a),u.e.TransformNormalToRef(e,a,i),i.normalize()},t.prototype.getRotation=function(e,n){e===void 0&&(e=ye.c.LOCAL),n===void 0&&(n=null);var i=u.e.Zero();return this.getRotationToRef(e,n,i),i},t.prototype.getRotationToRef=function(e,n,i){e===void 0&&(e=ye.c.LOCAL),n===void 0&&(n=null);var o=t._tmpQuat;this.getRotationQuaternionToRef(e,n,o),o.toEulerAnglesToRef(i)},t.prototype.getRotationQuaternion=function(e,n){e===void 0&&(e=ye.c.LOCAL),n===void 0&&(n=null);var i=u.b.Identity();return this.getRotationQuaternionToRef(e,n,i),i},t.prototype.getRotationQuaternionToRef=function(e,n,i){if(e===void 0&&(e=ye.c.LOCAL),n===void 0&&(n=null),e==ye.c.LOCAL)this._decompose(),i.copyFrom(this._localRotation);else{var o=t._tmpMats[0],a=this.getAbsoluteTransform();n?a.multiplyToRef(n.getWorldMatrix(),o):o.copyFrom(a),o.multiplyAtIndex(0,this._scalingDeterminant),o.multiplyAtIndex(1,this._scalingDeterminant),o.multiplyAtIndex(2,this._scalingDeterminant),o.decompose(void 0,i,void 0)}},t.prototype.getRotationMatrix=function(e,n){e===void 0&&(e=ye.c.LOCAL);var i=u.a.Identity();return this.getRotationMatrixToRef(e,n,i),i},t.prototype.getRotationMatrixToRef=function(e,n,i){if(e===void 0&&(e=ye.c.LOCAL),e==ye.c.LOCAL)this.getLocalMatrix().getRotationMatrixToRef(i);else{var o=t._tmpMats[0],a=this.getAbsoluteTransform();n?a.multiplyToRef(n.getWorldMatrix(),o):o.copyFrom(a),o.multiplyAtIndex(0,this._scalingDeterminant),o.multiplyAtIndex(1,this._scalingDeterminant),o.multiplyAtIndex(2,this._scalingDeterminant),o.getRotationMatrixToRef(i)}}
1608,t.prototype.getAbsolutePositionFromLocal=function(e,n){n===void 0&&(n=null);var i=u.e.Zero();return this.getAbsolutePositionFromLocalToRef(e,n,i),i},t.prototype.getAbsolutePositionFromLocalToRef=function(e,n,i){n===void 0&&(n=null);var o=null;n&&(o=n.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var a=t._tmpMats[0];n&&o?(a.copyFrom(this.getAbsoluteTransform()),a.multiplyToRef(o,a)):a=this.getAbsoluteTransform(),u.e.TransformCoordinatesToRef(e,a,i)},t.prototype.getLocalPositionFromAbsolute=function(e,n){n===void 0&&(n=null);var i=u.e.Zero();return this.getLocalPositionFromAbsoluteToRef(e,n,i),i},t.prototype.getLocalPositionFromAbsoluteToRef=function(e,n,i){n===void 0&&(n=null);var o=null;n&&(o=n.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var a=t._tmpMats[0];a.copyFrom(this.getAbsoluteTransform()),n&&o&&a.multiplyToRef(o,a),a.invert(),u.e.TransformCoordinatesToRef(e,a,i)},t.prototype.setCurrentPoseAsRest=function(){this.setRestPose(this.getLocalMatrix())},t._tmpVecs=Ce.a.BuildArray(2,u.e.Zero),t._tmpQuat=u.b.Identity(),t._tmpMats=Ce.a.BuildArray(5,u.a.Identity),t}(Q.a),Ge=function(){function r(t,e,n,i,o,a,s,d,p,y){n===void 0&&(n=0),i===void 0&&(i=100),o===void 0&&(o=!1),a===void 0&&(a=1),y===void 0&&(y=!1),this.target=e,this.fromFrame=n,this.toFrame=i,this.loopAnimation=o,this.onAnimationEnd=s,this.onAnimationLoop=p,this.isAdditive=y,this._localDelayOffset=null,this._pausedDelay=null,this._runtimeAnimations=new Array,this._paused=!1,this._speedRatio=1,this._weight=-1,this._syncRoot=null,this.disposeOnEnd=!0,this.animationStarted=!1,this.onAnimationEndObservable=new x.c,this.onAnimationLoopObservable=new x.c,this._scene=t,d&&this.appendAnimations(e,d),this._speedRatio=a,t._activeAnimatables.push(this)}return Object.defineProperty(r.prototype,"syncRoot",{get:function(){return this._syncRoot},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"masterFrame",{get:function(){return this._runtimeAnimations.length===0?0:this._runtimeAnimations[0].currentFrame},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"weight",{get:function(){return this._weight},set:function(t){this._weight=t!==-1?Math.min(Math.max(t,0),1):-1},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"speedRatio",{get:function(){return this._speedRatio},set:function(t){for(var e=0;e<this._runtimeAnimations.length;e++)this._runtimeAnimations[e]._prepareForSpeedRatioChange(t);this._speedRatio=t},enumerable:!1,configurable:!0}),r.prototype.syncWith=function(t){if(this._syncRoot=t,t){var e=this._scene._activeAnimatables.indexOf(this);e>-1&&(this._scene._activeAnimatables.splice(e,1),this._scene._activeAnimatables.push(this))}return this},r.prototype.getAnimations=function(){return this._runtimeAnimations},r.prototype.appendAnimations=function(t,e){for(var n=this,i=0;i<e.length;i++){var o=e[i],a=new me(t,o,this._scene,this);a._onLoop=function(){n.onAnimationLoopObservable.notifyObservers(n),n.onAnimationLoop&&n.onAnimationLoop()},this._runtimeAnimations.push(a)}},r.prototype.getAnimationByTargetProperty=function(t){for(var e=this._runtimeAnimations,n=0;n<e.length;n++)if(e[n].animation.targetProperty===t)return e[n].animation;return null},r.prototype.getRuntimeAnimationByTargetProperty=function(t){for(var e=this._runtimeAnimations,n=0;n<e.length;n++)if(e[n].animation.targetProperty===t)return e[n];return null},r.prototype.reset=function(){for(var t=this._runtimeAnimations,e=0;e<t.length;e++)t[e].reset(!0);this._localDelayOffset=null,this._pausedDelay=null},r.prototype.enableBlending=function(t){for(var e=this._runtimeAnimations,n=0;n<e.length;n++)e[n].animation.enableBlending=!0,e[n].animation.blendingSpeed=t},r.prototype.disableBlending=function(){for(var t=this._runtimeAnimations,e=0;e<t.length;e++)t[e].animation.enableBlending=!1},r.prototype.goToFrame=function(t){var e=this._runtimeAnimations;if(e[0]){var n=e[0].animation.framePerSecond,i=e[0].currentFrame,o=this.speedRatio===0?0:(t-i)/n*1e3/this.speedRatio;this._localDelayOffset===null&&(this._localDelayOffset=0),this._localDelayOffset-=o}for(var a=0;a<e.length;a++)e[a].goToFrame(t)},r.prototype.pause=function(){this._paused||(this._paused=!0)},r.prototype.restart=function(){this._paused=!1},r.prototype._raiseOnAnimationEnd=function(){this.onAnimationEnd&&this.onAnimationEnd(),this.onAnimationEndObservable.notifyObservers(this)},r.prototype.stop=function(t,e){if(t||e){var n=this._scene._activeAnimatables.indexOf(this);if(n>-1){for(var i=(a=this._runtimeAnimations).length-1;i>=0;i--){var o=a[i];t&&o.animation.name!=t||e&&!e(o.target)||(o.dispose(),a.splice(i,1))}a.length==0&&(this._scene._activeAnimatables.splice(n,1),this._raiseOnAnimationEnd())}}else if((i=this._scene._activeAnimatables.indexOf(this))>-1){this._scene._activeAnimatables.splice(i,1);var a=this._runtimeAnimations;for(i=0;i<a.length;i++)a[i].dispose();this._raiseOnAnimationEnd()}},r.prototype.waitAsync=function(){var t=this;return new Promise(function(e,n){t.onAnimationEndObservable.add(function(){e(t)},void 0,void 0,t,!0)})},r.prototype._animate=function(t){if(this._paused)return this.animationStarted=!1,this._pausedDelay===null&&(this._pausedDelay=t),!0;if(this._localDelayOffset===null?(this._localDelayOffset=t,this._pausedDelay=null):this._pausedDelay!==null&&(this._localDelayOffset+=t-this._pausedDelay,this._pausedDelay=null),this._weight===0)return!0;var e,n=!1,i=this._runtimeAnimations;for(e=0;e<i.length;e++){var o=i[e].animate(t-this._localDelayOffset,this.fromFrame,this.toFrame,this.loopAnimation,this._speedRatio,this._weight);n=n||o}if(this.animationStarted=n,!n){if(this.disposeOnEnd)for(e=this._scene._activeAnimatables.indexOf(this),this._scene._activeAnimatables.splice(e,1),e=0;e<i.length;e++)i[e].dispose();this._raiseOnAnimationEnd(),this.disposeOnEnd&&(this.onAnimationEnd=null,this.onAnimationLoop=null,this.onAnimationLoopObservable.clear(),this.onAnimationEndObservable.clear())}return n},r}();_e.a.prototype._animate=function(){if(this.animationsEnabled){var r=be.a.Now;
1608if(!this._animationTimeLast){if(this._pendingData.length>0)return;this._animationTimeLast=r}this.deltaTime=this.useConstantAnimationDeltaTime?16:(r-this._animationTimeLast)*this.animationTimeScale,this._animationTimeLast=r;var t=this._activeAnimatables;if(t.length!==0){this._animationTime+=this.deltaTime;for(var e=this._animationTime,n=0;n<t.length;n++){var i=t[n];!i._animate(e)&&i.disposeOnEnd&&n--}this._processLateAnimationBindings()}}},_e.a.prototype.beginWeightedAnimation=function(r,t,e,n,i,o,a,s,d,p,y){n===void 0&&(n=1),o===void 0&&(o=1),y===void 0&&(y=!1);var P=this.beginAnimation(r,t,e,i,o,a,s,!1,d,p,y);return P.weight=n,P},_e.a.prototype.beginAnimation=function(r,t,e,n,i,o,a,s,d,p,y){i===void 0&&(i=1),s===void 0&&(s=!0),y===void 0&&(y=!1),t>e&&i>0&&(i*=-1),s&&this.stopAnimation(r,void 0,d),a||(a=new Ge(this,r,t,e,n,i,o,void 0,p,y));var P=!d||d(r);if(r.animations&&P&&a.appendAnimations(r,r.animations),r.getAnimatables)for(var O=r.getAnimatables(),U=0;U<O.length;U++)this.beginAnimation(O[U],t,e,n,i,o,a,s,d,p);return a.reset(),a},_e.a.prototype.beginHierarchyAnimation=function(r,t,e,n,i,o,a,s,d,p,y,P){o===void 0&&(o=1),d===void 0&&(d=!0),P===void 0&&(P=!1);var O=r.getDescendants(t),U=[];U.push(this.beginAnimation(r,e,n,i,o,a,s,d,p,void 0,P));for(var F=0,z=O;F<z.length;F++){var J=z[F];U.push(this.beginAnimation(J,e,n,i,o,a,s,d,p,void 0,P))}return U},_e.a.prototype.beginDirectAnimation=function(r,t,e,n,i,o,a,s,d){return d===void 0&&(d=!1),o===void 0&&(o=1),e>n&&o>0&&(o*=-1),new Ge(this,r,e,n,i,o,a,t,s,d)},_e.a.prototype.beginDirectHierarchyAnimation=function(r,t,e,n,i,o,a,s,d,p){p===void 0&&(p=!1);var y=r.getDescendants(t),P=[];P.push(this.beginDirectAnimation(r,e,n,i,o,a,s,d,p));for(var O=0,U=y;O<U.length;O++){var F=U[O];P.push(this.beginDirectAnimation(F,e,n,i,o,a,s,d,p))}return P},_e.a.prototype.getAnimatableByTarget=function(r){for(var t=0;t<this._activeAnimatables.length;t++)if(this._activeAnimatables[t].target===r)return this._activeAnimatables[t];return null},_e.a.prototype.getAllAnimatablesByTarget=function(r){for(var t=[],e=0;e<this._activeAnimatables.length;e++)this._activeAnimatables[e].target===r&&t.push(this._activeAnimatables[e]);return t},_e.a.prototype.stopAnimation=function(r,t,e){for(var n=0,i=this.getAllAnimatablesByTarget(r);n<i.length;n++)i[n].stop(t,e)},_e.a.prototype.stopAllAnimations=function(){if(this._activeAnimatables){for(var r=0;r<this._activeAnimatables.length;r++)this._activeAnimatables[r].stop();this._activeAnimatables=[]}for(var t=0,e=this.animationGroups;t<e.length;t++)e[t].stop()},_e.a.prototype._registerTargetForLateAnimationBinding=function(r,t){var e=r.target;this._registeredForLateAnimationBindings.pushNoDuplicate(e),e._lateAnimationHolders||(e._lateAnimationHolders={}),e._lateAnimationHolders[r.targetPath]||(e._lateAnimationHolders[r.targetPath]={totalWeight:0,totalAdditiveWeight:0,animations:[],additiveAnimations:[],originalValue:t}),r.isAdditive?(e._lateAnimationHolders[r.targetPath].additiveAnimations.push(r),e._lateAnimationHolders[r.targetPath].totalAdditiveWeight+=r.weight):(e._lateAnimationHolders[r.targetPath].animations.push(r),e._lateAnimationHolders[r.targetPath].totalWeight+=r.weight)},_e.a.prototype._processLateAnimationBindingsForMatrices=function(r){if(r.totalWeight===0&&r.totalAdditiveWeight===0)return r.originalValue;var t=1,e=u.c.Vector3[0],n=u.c.Vector3[1],i=u.c.Quaternion[0],o=0,a=r.animations[0],s=r.originalValue,d=1,p=!1;if(r.totalWeight<1)d=1-r.totalWeight,s.decompose(n,i,e);else{if(o=1,t=r.totalWeight,(d=a.weight/t)==1){if(!r.totalAdditiveWeight)return a.currentValue;p=!0}a.currentValue.decompose(n,i,e)}if(!p){n.scaleInPlace(d),e.scaleInPlace(d),i.scaleInPlace(d);for(var y=o;y<r.animations.length;y++)if((z=r.animations[y]).weight!==0){d=z.weight/t;var P=u.c.Vector3[2],O=u.c.Vector3[3],U=u.c.Quaternion[1];z.currentValue.decompose(O,U,P),O.scaleAndAddToRef(d,n),U.scaleAndAddToRef(d,i),P.scaleAndAddToRef(d,e)}}for(var F=0;F<r.additiveAnimations.length;F++){var z;(z=r.additiveAnimations[F]).weight!==0&&(P=u.c.Vector3[2],O=u.c.Vector3[3],U=u.c.Quaternion[1],z.currentValue.decompose(O,U,P),O.multiplyToRef(n,O),u.e.LerpToRef(n,O,z.weight,n),i.multiplyToRef(U,U),u.b.SlerpToRef(i,U,z.weight,i),P.scaleAndAddToRef(z.weight,e))}var J=a?a._animationState.workValue:u.c.Matrix[0].clone();return u.a.ComposeToRef(n,i,e,J),J},_e.a.prototype._processLateAnimationBindingsForQuaternions=function(r,t){if(r.totalWeight===0&&r.totalAdditiveWeight===0)return t;var e=r.animations[0],n=r.originalValue,i=t;if(r.totalWeight===0&&r.totalAdditiveWeight>0)i.copyFrom(n);else if(r.animations.length===1){if(u.b.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 d=1-r.totalWeight;s=[],(a=[]).push(n),s.push(d)}else{if(r.animations.length===2&&(u.b.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 p=0;p<r.animations.length;p++){var y=r.animations[p];a.push(y.currentValue),s.push(y.weight/o)}for(var P=0,O=0;O<a.length;)O?(P+=s[O],u.b.SlerpToRef(i,a[O],s[O]/P,i),O++):(u.b.SlerpToRef(a[O],a[O+1],s[O+1]
1608/(s[O]+s[O+1]),t),i=t,P=s[O]+s[O+1],O+=2)}for(var U=0;U<r.additiveAnimations.length;U++)(y=r.additiveAnimations[U]).weight!==0&&(i.multiplyToRef(y.currentValue,u.c.Quaternion[0]),u.b.SlerpToRef(i,u.c.Quaternion[0],y.weight,i));return i},_e.a.prototype._processLateAnimationBindings=function(){if(this._registeredForLateAnimationBindings.length){for(var r=0;r<this._registeredForLateAnimationBindings.length;r++){var t=this._registeredForLateAnimationBindings.data[r];for(var e in t._lateAnimationHolders){var n=t._lateAnimationHolders[e],i=n.animations[0],o=n.originalValue,a=k.AllowMatrixDecomposeForInterpolation&&o.m,s=t[e];if(a)s=this._processLateAnimationBindingsForMatrices(n);else if(o.w!==void 0)s=this._processLateAnimationBindingsForQuaternions(n,s||u.b.Identity());else{var d=0,p=1;if(n.totalWeight<1)s=i&&o.scale?o.scale(1-n.totalWeight):i?o*(1-n.totalWeight):o.clone?o.clone():o;else if(i){p=n.totalWeight;var y=i.weight/p;s=y!==1?i.currentValue.scale?i.currentValue.scale(y):i.currentValue*y:i.currentValue,d=1}for(var P=d;P<n.animations.length;P++)(F=(U=n.animations[P]).weight/p)&&(U.currentValue.scaleAndAddToRef?U.currentValue.scaleAndAddToRef(F,s):s+=U.currentValue*F);for(var O=0;O<n.additiveAnimations.length;O++){var U,F;(F=(U=n.additiveAnimations[O]).weight)&&(U.currentValue.scaleAndAddToRef?U.currentValue.scaleAndAddToRef(F,s):s+=U.currentValue*F)}}t[e]=s}t._lateAnimationHolders={}}this._registeredForLateAnimationBindings.reset()}},Be.prototype.copyAnimationRange=function(r,t,e,n,i){n===void 0&&(n=!1),i===void 0&&(i=null),this.animations.length===0&&(this.animations.push(new k(this.name,"_matrix",r.animations[0].framePerSecond,k.ANIMATIONTYPE_MATRIX,0)),this.animations[0].setKeys([]));var o=r.animations[0].getRange(t);if(!o)return!1;for(var a,s,d,p=o.from,y=o.to,P=r.animations[0].getKeys(),O=r.length,U=r.getParent(),F=this.getParent(),z=n&&U&&O&&this.length&&O!==this.length,J=z&&F&&U?F.length/U.length:1,ie=n&&!F&&i&&(i.x!==1||i.y!==1||i.z!==1),se=this.animations[0].getKeys(),ce=0,ue=P.length;ce<ue;ce++)(a=P[ce]).frame>=p&&a.frame<=y&&(n?(d=a.value.clone(),z?(s=d.getTranslation(),d.setTranslation(s.scaleInPlace(J))):ie&&i?(s=d.getTranslation(),d.setTranslation(s.multiplyInPlace(i))):d=a.value):d=a.value,se.push({frame:a.frame+e,value:d}));return this.animations[0].createRange(t,p+e,y+e),!0};var Xe=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}(),He=function(){function r(t,e){e===void 0&&(e=null),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.onAnimationEndObservable=new x.c,this.onAnimationLoopObservable=new x.c,this.onAnimationGroupLoopObservable=new x.c,this.onAnimationGroupEndObservable=new x.c,this.onAnimationGroupPauseObservable=new x.c,this.onAnimationGroupPlayObservable=new x.c,this._scene=e||te.a.LastCreatedScene,this.uniqueId=this._scene.getUniqueId(),this._scene.addAnimationGroup(this)}return Object.defineProperty(r.prototype,"from",{get:function(){return this._from},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"to",{get:function(){return this._to},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isStarted",{get:function(){return this._isStarted},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isPlaying",{get:function(){return this._isStarted&&!this._isPaused},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"speedRatio",{get:function(){return this._speedRatio},set:function(t){if(this._speedRatio!==t){this._speedRatio=t;for(var e=0;e<this._animatables.length;e++)this._animatables[e].speedRatio=this._speedRatio}},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"loopAnimation",{get:function(){return this._loopAnimation},set:function(t){if(this._loopAnimation!==t){this._loopAnimation=t;for(var e=0;e<this._animatables.length;e++)this._animatables[e].loopAnimation=this._loopAnimation}}
1608,enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isAdditive",{get:function(){return this._isAdditive},set:function(t){if(this._isAdditive!==t){this._isAdditive=t;for(var e=0;e<this._animatables.length;e++)this._animatables[e].isAdditive=this._isAdditive}},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"targetedAnimations",{get:function(){return this._targetedAnimations},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"animatables",{get:function(){return this._animatables},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"children",{get:function(){return this._targetedAnimations},enumerable:!1,configurable:!0}),r.prototype.addTargetedAnimation=function(t,e){var n=new Xe;n.animation=t,n.target=e;var i=t.getKeys();return this._from>i[0].frame&&(this._from=i[0].frame),this._to<i[i.length-1].frame&&(this._to=i[i.length-1].frame),this._targetedAnimations.push(n),n},r.prototype.normalize=function(t,e){t===void 0&&(t=null),e===void 0&&(e=null),t==null&&(t=this._from),e==null&&(e=this._to);for(var n=0;n<this._targetedAnimations.length;n++){var i=this._targetedAnimations[n].animation.getKeys(),o=i[0],a=i[i.length-1];if(o.frame>t){var s={frame:t,value:o.value,inTangent:o.inTangent,outTangent:o.outTangent,interpolation:o.interpolation};i.splice(0,0,s)}a.frame<e&&(s={frame:e,value:a.value,inTangent:a.inTangent,outTangent:a.outTangent,interpolation:a.interpolation},i.push(s))}return this._from=t,this._to=e,this},r.prototype._processLoop=function(t,e,n){var i=this;t.onAnimationLoop=function(){i.onAnimationLoopObservable.notifyObservers(e),i._animationLoopFlags[n]||(i._animationLoopFlags[n]=!0,i._animationLoopCount++,i._animationLoopCount===i._targetedAnimations.length&&(i.onAnimationGroupLoopObservable.notifyObservers(i),i._animationLoopCount=0,i._animationLoopFlags=[]))}},r.prototype.start=function(t,e,n,i,o){var a=this;if(t===void 0&&(t=!1),e===void 0&&(e=1),this._isStarted||this._targetedAnimations.length===0)return this;this._loopAnimation=t,this._animationLoopCount=0,this._animationLoopFlags=[];for(var s=function(){var P=d._targetedAnimations[p],O=d._scene.beginDirectAnimation(P.target,[P.animation],n!==void 0?n:d._from,i!==void 0?i:d._to,t,e,void 0,void 0,o!==void 0?o:d._isAdditive);O.onAnimationEnd=function(){a.onAnimationEndObservable.notifyObservers(P),a._checkAnimationGroupEnded(O)},d._processLoop(O,P,p),d._animatables.push(O)},d=this,p=0;p<this._targetedAnimations.length;p++)s();if(this._speedRatio=e,n!==void 0&&i!==void 0)if(n<i&&this._speedRatio<0){var y=i;i=n,n=y}else n>i&&this._speedRatio>0&&(this._speedRatio=-e);return this._isStarted=!0,this._isPaused=!1,this.onAnimationGroupPlayObservable.notifyObservers(this),this},r.prototype.pause=function(){if(!this._isStarted)return this;this._isPaused=!0;for(var t=0;t<this._animatables.length;t++)this._animatables[t].pause();return this.onAnimationGroupPauseObservable.notifyObservers(this),this},r.prototype.play=function(t){return this.isStarted&&this._animatables.length===this._targetedAnimations.length?(t!==void 0&&(this.loopAnimation=t),this.restart()):(this.stop(),this.start(t,this._speedRatio)),this._isPaused=!1,this},r.prototype.reset=function(){if(!this._isStarted)return this.play(),this.goToFrame(0),this.stop(),this;for(var t=0;t<this._animatables.length;t++)this._animatables[t].reset();return this},r.prototype.restart=function(){if(!this._isStarted)return this;for(var t=0;t<this._animatables.length;t++)this._animatables[t].restart();return this.onAnimationGroupPlayObservable.notifyObservers(this),this},r.prototype.stop=function(){if(!this._isStarted)return this;for(var t=this._animatables.slice(),e=0;e<t.length;e++)t[e].stop();return this._isStarted=!1,this},r.prototype.setWeightForAllAnimatables=function(t){for(var e=0;e<this._animatables.length;e++)this._animatables[e].weight=t;return this},r.prototype.syncAllAnimationsWith=function(t){for(var e=0;e<this._animatables.length;e++)this._animatables[e].syncWith(t);return this},r.prototype.goToFrame=function(t){if(!this._isStarted)return this;for(var e=0;e<this._animatables.length;e++)this._animatables[e].goToFrame(t);return this},r.prototype.dispose=function(){this._targetedAnimations=[],this._animatables=[];var t=this._scene.animationGroups.indexOf(this);t>-1&&this._scene.animationGroups.splice(t,1),this.onAnimationEndObservable.clear(),this.onAnimationGroupEndObservable.clear(),this.onAnimationGroupPauseObservable.clear(),this.onAnimationGroupPlayObservable.clear(),this.onAnimationLoopObservable.clear(),this.onAnimationGroupLoopObservable.clear()},r.prototype._checkAnimationGroupEnded=function(t){var e=this._animatables.indexOf(t);e>-1&&this._animatables.splice(e,1),this._animatables.length===0&&(this._isStarted=!1,this.onAnimationGroupEndObservable.notifyObservers(this))},r.prototype.clone=function(t,e){for(var n=new r(t||this.name,this._scene),i=0,o=this._targetedAnimations;i<o.length;i++){var a=o[i];n.addTargetedAnimation(a.animation.clone(),e?e(a.target):a.target)}return n},r.prototype.serialize=function(){var t={};t.name=this.name,t.from=this.from,t.to=this.to,t.targetedAnimations=[];for(var e=0;e<this.targetedAnimations.length;e++){var n=this.targetedAnimations[e];t.targetedAnimations[e]=n.serialize()}return t},r.Parse=function(t,e){for(var n=new r(t.name,e),i=0;i<t.targetedAnimations.length;i++){var o=t.targetedAnimations[i],a=k.Parse(o.animation),s=o.targetId;if(o.animation.property==="influence"){var d=e.getMorphTargetById(s);d&&n.addTargetedAnimation(a,d)}else{var p=e.getNodeByID(s);p!=null&&n.addTargetedAnimation(a,p)}}return t.from!==null&&t.to!==null&&n.normalize(t.from,t.to),n},r.MakeAnimationAdditive=function(t,e,n,i,o){e===void 0&&(e=0),i===void 0&&(i=!1);var a=t;i&&(a=t.clone(o||a.name));for(var s=a.targetedAnimations,d=0;d<s.length;d++){var p=s[d];k.MakeAnimationAdditive(p.animation,e,n)}return a.isAdditive=!0,a},r.prototype.getClassName=function(){return"AnimationGroup"},r.prototype.toString=function(t){var e="Name: "+this.name;return e+=", type: "+this.getClassName(),t&&(e+=", from: "+this._from,e+=", to: "+this._to,e+=", isStarted: "+this._isStarted,e+=", speedRatio: "+this._speedRatio,e+=", targetedAnimations length: "+this._targetedAnimations.length,e+=", animatables length: "+this._animatables),e},r}(),We=function(){this.enableBlending=!1,this.blendingSpeed=.01,this.loopMode=k.ANIMATIONLOOPMODE_CYCLE},Ze=f(72),ze=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}(),it=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return Object(c.d)(t,r),t.prototype.easeInCore=function(e){return e=Math.max(0,Math.min(1,e)),1-Math.sqrt(1-e*e)},t}(ze),et=function(r){function t(e){e===void 0&&(e=1);var n=r.call(this)||this;return n.amplitude=e,n}return Object(c.d)(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}(ze),lt=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 Object(c.d)(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,d=e*s,p=Math.log(-d*(1-i)+1)/Math.log(i),y=Math.floor(p),P=y+1,O=(1-Math.pow(i,y))/(a*s),U=.5*(O+(1-Math.pow(i,P))/(a*s)),F=e-U,z=U-O;return-Math.pow(1/i,n-y)/(z*z)*(F-z)*(F+z)},t}(ze),ct=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return Object(c.d)(t,r),t.prototype.easeInCore=function(e){return e*e*e},t}(ze),mt=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 Object(c.d)(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}(ze),St=function(r){function t(e){e===void 0&&(e=2);var n=r.call(this)||this;return n.exponent=e,n}return Object(c.d)(t,r),t.prototype.easeInCore=function(e){return this.exponent<=0?e:(Math.exp(this.exponent*e)-1)/(Math.exp(this.exponent)-1)},t}(ze),wt=function(r){function t(e){e===void 0&&(e=2);var n=r.call(this)||this;return n.power=e,n}return Object(c.d)(t,r),t.prototype.easeInCore=function(e){var n=Math.max(0,this.power);return Math.pow(e,n)},t}(ze),It=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return Object(c.d)(t,r),t.prototype.easeInCore=function(e){return e*e},t}(ze),Pt=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return Object(c.d)(t,r),t.prototype.easeInCore=function(e){return e*e*e*e},t}(ze),Ot=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return Object(c.d)(t,r),t.prototype.easeInCore=function(e){return e*e*e*e*e},t}(ze),on=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return Object(c.d)(t,r),t.prototype.easeInCore=function(e){return 1-Math.sin(1.5707963267948966*(1-e))},t}(ze),Zt=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 Object(c.d)(t,r),t.prototype.easeInCore=function(e){return Ze.c.Interpolate(e,this.x1,this.y1,this.x2,this.y2)},t}(ze),tn=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}(),De=f(7),Sn=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return Object(c.d)(t,r),t}(B.a),nn=function(){this.rootNodes=[],this.skeletons=[],this.animationGroups=[]},An=function(r){function t(e){var n=r.call(this)||this;return n._wasAddedToScene=!1,n.scene=e,n.sounds=[],n.effectLayers=[],n.layers=[],n.lensFlareSystems=[],n.proceduralTextures=[],n.reflectionProbes=[],e.onDisposeObservable.add(function(){n._wasAddedToScene||n.dispose()}),n}return Object(c.d)(t,r),t.prototype.instantiateModelsToScene=function(e,n){var i=this;n===void 0&&(n=!1);var o={},a={},s=new nn,d=[],p=[],y={doNotInstantiate:!0},P=function(O,U){if(o[O.uniqueId]=U.uniqueId,a[U.uniqueId]=U,e&&(U.name=e(O.name)),U instanceof De.a){var F=U;if(F.morphTargetManager){var z=O.morphTargetManager;F.morphTargetManager=z.clone();for(var J=0;
1608J<z.numTargets;J++){var ie=z.getTarget(J),se=F.morphTargetManager.getTarget(J);o[ie.uniqueId]=se.uniqueId,a[se.uniqueId]=se}}}};return this.transformNodes.forEach(function(O){if(!O.parent){var U=O.instantiateHierarchy(null,y,function(F,z){P(F,z)});U&&s.rootNodes.push(U)}}),this.meshes.forEach(function(O){if(!O.parent){var U=O.instantiateHierarchy(null,y,function(F,z){if(P(F,z),z.material){var J=z;if(J.material)if(n){var ie=F.material;if(p.indexOf(ie)===-1){var se=ie.clone(e?e(ie.name):"Clone of "+ie.name);if(p.push(ie),o[ie.uniqueId]=se.uniqueId,a[se.uniqueId]=se,ie.getClassName()==="MultiMaterial"){for(var ce=ie,ue=0,fe=ce.subMaterials;ue<fe.length;ue++){var ve=fe[ue];ve&&(se=ve.clone(e?e(ve.name):"Clone of "+ve.name),p.push(ve),o[ve.uniqueId]=se.uniqueId,a[se.uniqueId]=se)}ce.subMaterials=ce.subMaterials.map(function(Te){return Te&&a[o[Te.uniqueId]]})}}J.material=a[o[ie.uniqueId]]}else J.material.getClassName()==="MultiMaterial"?i.scene.multiMaterials.indexOf(J.material)===-1&&i.scene.addMultiMaterial(J.material):i.scene.materials.indexOf(J.material)===-1&&i.scene.addMaterial(J.material)}});U&&s.rootNodes.push(U)}}),this.skeletons.forEach(function(O){var U=O.clone(e?e(O.name):"Clone of "+O.name);O.overrideMesh&&(U.overrideMesh=a[o[O.overrideMesh.uniqueId]]);for(var F=0,z=i.meshes;F<z.length;F++){var J=z[F];if(J.skeleton===O&&!J.isAnInstance){if(a[o[J.uniqueId]].skeleton=U,d.indexOf(U)!==-1)continue;d.push(U);for(var ie=0,se=U.bones;ie<se.length;ie++){var ce=se[ie];ce._linkedTransformNode&&(ce._linkedTransformNode=a[o[ce._linkedTransformNode.uniqueId]])}}}s.skeletons.push(U)}),this.animationGroups.forEach(function(O){var U=O.clone(O.name,function(F){return a[o[F.uniqueId]]||F});s.animationGroups.push(U)}),s},t.prototype.addAllToScene=function(){var e=this;this._wasAddedToScene=!0,this.cameras.forEach(function(o){e.scene.addCamera(o)}),this.lights.forEach(function(o){e.scene.addLight(o)}),this.meshes.forEach(function(o){e.scene.addMesh(o)}),this.skeletons.forEach(function(o){e.scene.addSkeleton(o)}),this.animations.forEach(function(o){e.scene.addAnimation(o)}),this.animationGroups.forEach(function(o){e.scene.addAnimationGroup(o)}),this.multiMaterials.forEach(function(o){e.scene.addMultiMaterial(o)}),this.materials.forEach(function(o){e.scene.addMaterial(o)}),this.morphTargetManagers.forEach(function(o){e.scene.addMorphTargetManager(o)}),this.geometries.forEach(function(o){e.scene.addGeometry(o)}),this.transformNodes.forEach(function(o){e.scene.addTransformNode(o)}),this.actionManagers.forEach(function(o){e.scene.addActionManager(o)}),this.textures.forEach(function(o){e.scene.addTexture(o)}),this.reflectionProbes.forEach(function(o){e.scene.addReflectionProbe(o)}),this.environmentTexture&&(this.scene.environmentTexture=this.environmentTexture);for(var n=0,i=this.scene._serializableComponents;n<i.length;n++)i[n].addFromContainer(this)},t.prototype.removeAllFromScene=function(){var e=this;this._wasAddedToScene=!1,this.cameras.forEach(function(o){e.scene.removeCamera(o)}),this.lights.forEach(function(o){e.scene.removeLight(o)}),this.meshes.forEach(function(o){e.scene.removeMesh(o)}),this.skeletons.forEach(function(o){e.scene.removeSkeleton(o)}),this.animations.forEach(function(o){e.scene.removeAnimation(o)}),this.animationGroups.forEach(function(o){e.scene.removeAnimationGroup(o)}),this.multiMaterials.forEach(function(o){e.scene.removeMultiMaterial(o)}),this.materials.forEach(function(o){e.scene.removeMaterial(o)}),this.morphTargetManagers.forEach(function(o){e.scene.removeMorphTargetManager(o)}),this.geometries.forEach(function(o){e.scene.removeGeometry(o)}),this.transformNodes.forEach(function(o){e.scene.removeTransformNode(o)}),this.actionManagers.forEach(function(o){e.scene.removeActionManager(o)}),this.textures.forEach(function(o){e.scene.removeTexture(o)}),this.reflectionProbes.forEach(function(o){e.scene.removeReflectionProbe(o)}),this.environmentTexture===this.scene.environmentTexture&&(this.scene.environmentTexture=null);for(var n=0,i=this.scene._serializableComponents;n<i.length;n++)i[n].removeFromContainer(this)},t.prototype.dispose=function(){this.cameras.forEach(function(i){i.dispose()}
1608),this.cameras=[],this.lights.forEach(function(i){i.dispose()}),this.lights=[],this.meshes.forEach(function(i){i.dispose()}),this.meshes=[],this.skeletons.forEach(function(i){i.dispose()}),this.skeletons=[],this.animationGroups.forEach(function(i){i.dispose()}),this.animationGroups=[],this.multiMaterials.forEach(function(i){i.dispose()}),this.multiMaterials=[],this.materials.forEach(function(i){i.dispose()}),this.materials=[],this.geometries.forEach(function(i){i.dispose()}),this.geometries=[],this.transformNodes.forEach(function(i){i.dispose()}),this.transformNodes=[],this.actionManagers.forEach(function(i){i.dispose()}),this.actionManagers=[],this.textures.forEach(function(i){i.dispose()}),this.textures=[],this.reflectionProbes.forEach(function(i){i.dispose()}),this.reflectionProbes=[],this.environmentTexture&&(this.environmentTexture.dispose(),this.environmentTexture=null);for(var e=0,n=this.scene._serializableComponents;e<n.length;e++)n[e].removeFromContainer(this,!0)},t.prototype._moveAssets=function(e,n,i){if(e)for(var o=0,a=e;o<a.length;o++){var s=a[o],d=!0;if(i){for(var p=0,y=i;p<y.length;p++)if(s===y[p]){d=!1;break}}d&&n.push(s)}},t.prototype.moveAllFromScene=function(e){for(var n in this._wasAddedToScene=!1,e===void 0&&(e=new Sn),this)this.hasOwnProperty(n)&&(this[n]=this[n]||(n==="environmentTexture"?null:[]),this._moveAssets(this.scene[n],this[n],e[n]));this.environmentTexture=this.scene.environmentTexture,this.removeAllFromScene()},t.prototype.createRootMesh=function(){var e=new De.a("assetContainerRootMesh",this.scene);return this.meshes.forEach(function(n){n.parent||e.addChild(n)}),this.meshes.unshift(e),e},t.prototype.mergeAnimationsTo=function(e,n,i){if(e===void 0&&(e=te.a.LastCreatedScene),i===void 0&&(i=null),!e)return l.a.Error("No scene available to merge animations to"),[];var o=i||function(s){var d=null,p=s.animations.length?s.animations[0].targetProperty:"",y=s.name.split(".").join("").split("_primitive")[0];switch(p){case"position":case"rotationQuaternion":d=e.getTransformNodeByName(s.name)||e.getTransformNodeByName(y);break;case"influence":d=e.getMorphTargetByName(s.name)||e.getMorphTargetByName(y);break;default:d=e.getNodeByName(s.name)||e.getNodeByName(y)}return d};this.getNodes().forEach(function(s){var d=o(s);if(d!==null){for(var p=function(O){for(var U=0,F=d.animations.filter(function(ie){return ie.targetProperty===O.targetProperty});U<F.length;U++){var z=F[U],J=d.animations.indexOf(z,0);J>-1&&d.animations.splice(J,1)}},y=0,P=s.animations;y<P.length;y++)p(P[y]);d.animations=d.animations.concat(s.animations)}});var a=new Array;return this.animationGroups.slice().forEach(function(s){a.push(s.clone(s.name,o)),s.animatables.forEach(function(d){d.stop()})}),n.forEach(function(s){var d=o(s.target);d&&(e.beginAnimation(d,s.fromFrame,s.toFrame,s.loopAnimation,s.speedRatio,s.onAnimationEnd?s.onAnimationEnd:void 0,void 0,!0,void 0,s.onAnimationLoop?s.onAnimationLoop:void 0),e.stopAnimation(s.target))}),a},t}(B.a),Ue=f(13),Pn=function(){function r(t){this.SMOOTHING=.75,this.FFT_SIZE=512,this.BARGRAPHAMPLITUDE=256,this.DEBUGCANVASPOS={x:20,y:20},this.DEBUGCANVASSIZE={width:320,height:200},this._scene=t,this._audioEngine=Ue.a.audioEngine,this._audioEngine.canUseWebAudio&&this._audioEngine.audioContext&&(this._webAudioAnalyser=this._audioEngine.audioContext.createAnalyser(),this._webAudioAnalyser.minDecibels=-140,this._webAudioAnalyser.maxDecibels=0,this._byteFreqs=new Uint8Array(this._webAudioAnalyser.frequencyBinCount),this._byteTime=new Uint8Array(this._webAudioAnalyser.frequencyBinCount),this._floatFreqs=new Float32Array(this._webAudioAnalyser.frequencyBinCount))}return r.prototype.getFrequencyBinCount=function(){return this._audioEngine.canUseWebAudio?this._webAudioAnalyser.frequencyBinCount:0},r.prototype.getByteFrequencyData=function(){return this._audioEngine.canUseWebAudio&&(this._webAudioAnalyser.smoothingTimeConstant=this.SMOOTHING,this._webAudioAnalyser.fftSize=this.FFT_SIZE,this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs)),this._byteFreqs},r.prototype.getByteTimeDomainData=function(){return this._audioEngine.canUseWebAudio&&(this._webAudioAnalyser.smoothingTimeConstant=this.SMOOTHING,this._webAudioAnalyser.fftSize=this.FFT_SIZE,this._webAudioAnalyser.getByteTimeDomainData(this._byteTime)),this._byteTime},r.prototype.getFloatFrequencyData=function(){return this._audioEngine.canUseWebAudio&&(this._webAudioAnalyser.smoothingTimeConstant=this.SMOOTHING,this._webAudioAnalyser.fftSize=this.FFT_SIZE,this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs)),this._floatFreqs},r.prototype.drawDebugCanvas=function(){var t=this;if(this._audioEngine.canUseWebAudio&&(this._debugCanvas||(this._debugCanvas=document.createElement("canvas"),this._debugCanvas.width=this.DEBUGCANVASSIZE.width,this._debugCanvas.height=this.DEBUGCANVASSIZE.height,this._debugCanvas.style.position="absolute",this._debugCanvas.style.top=this.DEBUGCANVASPOS.y+"px",this._debugCanvas.style.left=this.DEBUGCANVASPOS.x+"px",this._debugCanvasContext=this._debugCanvas.getContext("2d"),document.body.appendChild(this._debugCanvas),this._registerFunc=function(){t.drawDebugCanvas()},this._scene.registerBeforeRender(this._registerFunc)),this._registerFunc&&this._debugCanvasContext)){var e=this.getByteFrequencyData();this._debugCanvasContext.fillStyle="rgb(0, 0, 0)",this._debugCanvasContext.fillRect(0,0,this.DEBUGCANVASSIZE.width,this.DEBUGCANVASSIZE.height);for(var n=0;n<this.getFrequencyBinCount();n++){var i=e[n]/this.BARGRAPHAMPLITUDE,o=this.DEBUGCANVASSIZE.height*i,a=this.DEBUGCANVASSIZE.height-o-1,s=this.DEBUGCANVASSIZE.width/this.getFrequencyBinCount(),d=n/this.getFrequencyBinCount()*360;this._debugCanvasContext.fillStyle="hsl("+d+", 100%, 50%)",this._debugCanvasContext.fillRect(n*s,a,s,o)}}},r.prototype.stopDebugCanvas=function(){this._debugCanvas&&(this._registerFunc&&(this._scene.unregisterBeforeRender(this._registerFunc),this._registerFunc=null),document.body.removeChild(this._debugCanvas),this._debugCanvas=null,this._debugCanvasContext=null)},r.prototype.connectAudioNodes=function(t,e){this._audioEngine.canUseWebAudio&&(t.connect(this._webAudioAnalyser),this._webAudioAnalyser.connect(e))},r.prototype.dispose=function(){this._audioEngine.canUseWebAudio&&this._webAudioAnalyser.disconnect()},r}();Ue.a.AudioEngineFactory=function(r){return new hr(r)};var hr=function(){function r(t){var e=this;t===void 0&&(t=null),this._audioContext=null,this._audioContextInitialized=!1,this._muteButton=null,this.canUseWebAudio=!1,this.WarnedWebAudioUnsupported=!1,this.isMP3supported=!1,this.isOGGsupported=!1,this.unlocked=!0,this.useCustomUnlockedButton=!1,this.onAudioUnlockedObservable=new x.c,this.onAudioLockedObservable=new x.c,this._tryToRun=!1,this._onResize=function(){e._moveButtonToTopLeft()},window.AudioContext===void 0&&window.webkitAudioContext===void 0||(window.AudioContext=window.AudioContext||window.webkitAudioContext,this.canUseWebAudio=!0);var n=document.createElement("audio");this._hostElement=t;try{n&&n.canPlayType&&(n.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/,"")||n.canPlayType("audio/mp3").replace(/^no$/,""))&&(this.isMP3supported=!0)}catch{}try{n&&n.canPlayType&&n.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")&&(this.isOGGsupported=!0)}catch{}}return Object.defineProperty(r.prototype,"audioContext",{get:function(){return this._audioContextInitialized?this.unlocked||this._muteButton||this._displayMuteButton():this._initializeAudioContext(),this._audioContext}
1608,enumerable:!1,configurable:!0}),r.prototype.lock=function(){this._triggerSuspendedState()},r.prototype.unlock=function(){this._triggerRunningState()},r.prototype._resumeAudioContext=function(){var t;return this._audioContext.resume!==void 0&&(t=this._audioContext.resume()),t||Promise.resolve()},r.prototype._initializeAudioContext=function(){try{this.canUseWebAudio&&(this._audioContext=new AudioContext,this.masterGain=this._audioContext.createGain(),this.masterGain.gain.value=1,this.masterGain.connect(this._audioContext.destination),this._audioContextInitialized=!0,this._audioContext.state==="running"&&this._triggerRunningState())}catch(t){this.canUseWebAudio=!1,l.a.Error("Web Audio: "+t.message)}},r.prototype._triggerRunningState=function(){var t=this;this._tryToRun||(this._tryToRun=!0,this._resumeAudioContext().then(function(){t._tryToRun=!1,t._muteButton&&t._hideMuteButton(),t.unlocked=!0,t.onAudioUnlockedObservable.notifyObservers(t)}).catch(function(){t._tryToRun=!1,t.unlocked=!1}))},r.prototype._triggerSuspendedState=function(){this.unlocked=!1,this.onAudioLockedObservable.notifyObservers(this),this._displayMuteButton()},r.prototype._displayMuteButton=function(){var t=this;if(!this.useCustomUnlockedButton&&!this._muteButton){this._muteButton=document.createElement("BUTTON"),this._muteButton.className="babylonUnmuteIcon",this._muteButton.id="babylonUnmuteIconBtn",this._muteButton.title="Unmute";var e=".babylonUnmuteIcon { position: absolute; left: 20px; top: 20px; height: 40px; width: 60px; background-color: rgba(51,51,51,0.7); background-image: url("+(window.SVGSVGElement?"data:image/svg+xml;charset=UTF-8,%3Csvg%20version%3D%221.1%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2239%22%20height%3D%2232%22%20viewBox%3D%220%200%2039%2032%22%3E%3Cpath%20fill%3D%22white%22%20d%3D%22M9.625%2018.938l-0.031%200.016h-4.953q-0.016%200-0.031-0.016v-12.453q0-0.016%200.031-0.016h4.953q0.031%200%200.031%200.016v12.453zM12.125%207.688l8.719-8.703v27.453l-8.719-8.719-0.016-0.047v-9.938zM23.359%207.875l1.406-1.406%204.219%204.203%204.203-4.203%201.422%201.406-4.219%204.219%204.219%204.203-1.484%201.359-4.141-4.156-4.219%204.219-1.406-1.422%204.219-4.203z%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E":"https://cdn.babylonjs.com/Assets/audio.png")+");  background-size: 80%; background-repeat:no-repeat; background-position: center; background-position-y: 4px; border: none; outline: none; transition: transform 0.125s ease-out; cursor: pointer; z-index: 9999; } .babylonUnmuteIcon:hover { transform: scale(1.05) } .babylonUnmuteIcon:active { background-color: rgba(51,51,51,1) }",n=document.createElement("style");n.appendChild(document.createTextNode(e)),document.getElementsByTagName("head")[0].appendChild(n),document.body.appendChild(this._muteButton),this._moveButtonToTopLeft(),this._muteButton.addEventListener("touchend",function(){t._triggerRunningState()},!0),this._muteButton.addEventListener("click",function(){t._triggerRunningState()},!0),window.addEventListener("resize",this._onResize)}},r.prototype._moveButtonToTopLeft=function(){this._hostElement&&this._muteButton&&(this._muteButton.style.top=this._hostElement.offsetTop+20+"px",this._muteButton.style.left=this._hostElement.offsetLeft+20+"px")},r.prototype._hideMuteButton=function(){this._muteButton&&(document.body.removeChild(this._muteButton),this._muteButton=null)},r.prototype.dispose=function(){this.canUseWebAudio&&this._audioContextInitialized&&(this._connectedAnalyser&&this._audioContext&&(this._connectedAnalyser.stopDebugCanvas(),this._connectedAnalyser.dispose(),this.masterGain.disconnect(),this.masterGain.connect(this._audioContext.destination),this._connectedAnalyser=null),this.masterGain.gain.value=1),this.WarnedWebAudioUnsupported=!1,this._hideMuteButton(),window.removeEventListener("resize",this._onResize),this.onAudioUnlockedObservable.clear(),this.onAudioLockedObservable.clear()},r.prototype.getGlobalVolume=function(){return this.canUseWebAudio&&this._audioContextInitialized?this.masterGain.gain.value:-1},r.prototype.setGlobalVolume=function(t){this.canUseWebAudio&&this._audioContextInitialized&&(this.masterGain.gain.value=t)},r.prototype.connectToAnalyser=function(t){this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas(),this.canUseWebAudio&&this._audioContextInitialized&&this._audioContext&&(this._connectedAnalyser=t,this.masterGain.disconnect(),this._connectedAnalyser.connectAudioNodes(this.masterGain,this._audioContext.destination))},r}(),Ye=f(12),En=f(21),Zn=function(){function r(t,e,n,i,o){var a,s,d,p,y=this;if(i===void 0&&(i=null),this.autoplay=!1,this.loop=!1,this.useCustomAttenuation=!1,this.isPlaying=!1,this.isPaused=!1,this.spatialSound=!1,this.refDistance=1,this.rolloffFactor=1,this.maxDistance=100,this.distanceModel="linear",this.metadata=null,this.onEndedObservable=new x.c,this._panningModel="equalpower",this._playbackRate=1,this._streaming=!1,this._startTime=0,this._startOffset=0,this._position=u.e.Zero(),this._positionInEmitterSpace=!1,this._localDirection=new u.e(1,0,0),this._volume=1,this._isReadyToPlay=!1,this._isDirectional=!1,this._coneInnerAngle=360,this._coneOuterAngle=360,this._coneOuterGain=0,this._isOutputConnected=!1,this._urlType="Unknown",this.name=t,this._scene=n,r._SceneComponentInitialization(n),this._readyToPlayCallback=i,this._customAttenuationFunction=function(J,ie,se,ce,ue){return ie<se?J*(1-ie/se):0},o&&(this.autoplay=o.autoplay||!1,this.loop=o.loop||!1,o.volume!==void 0&&(this._volume=o.volume),this.spatialSound=(a=o.spatialSound)!==null&&a!==void 0&&a,this.maxDistance=(s=o.maxDistance)!==null&&s!==void 0?s:100,this.useCustomAttenuation=(d=o.useCustomAttenuation)!==null&&d!==void 0&&d,this.rolloffFactor=o.rolloffFactor||1,this.refDistance=o.refDistance||1,this.distanceModel=o.distanceModel||"linear",this._playbackRate=o.playbackRate||1,this._streaming=(p=o.streaming)!==null&&p!==void 0&&p,this._length=o.length,this._offset=o.offset),Ue.a.audioEngine.canUseWebAudio&&Ue.a.audioEngine.audioContext){this._soundGain=Ue.a.audioEngine.audioContext.createGain(),this._soundGain.gain.value=this._volume,this._inputAudioNode=this._soundGain,this._outputAudioNode=this._soundGain,this.spatialSound&&this._createSpatialParameters(),this._scene.mainSoundTrack.addSound(this);var P=!0;if(e)try{typeof e=="string"?this._urlType="String":e instanceof ArrayBuffer?this._urlType="ArrayBuffer":e instanceof MediaStream?this._urlType="MediaStream":Array.isArray(e)&&(this._urlType="Array");var O=[],U=!1;switch(this._urlType){case"MediaStream":this._streaming=!0,this._isReadyToPlay=!0,this._streamingSource=Ue.a.audioEngine.audioContext.createMediaStreamSource(e),this.autoplay&&this.play(0,this._offset,this._length),this._readyToPlayCallback&&this._readyToPlayCallback();break;case"ArrayBuffer":e.byteLength>0&&(U=!0,this._soundLoaded(e));break;case"String":O.push(e);case"Array":O.length===0&&(O=e);for(var F=0;F<O.length;F++){var z=O[F];if(U=o&&o.skipCodecCheck||z.indexOf(".mp3",z.length-4)!==-1&&Ue.a.audioEngine.isMP3supported||z.indexOf(".ogg",z.length-4)!==-1&&Ue.a.audioEngine.isOGGsupported||z.indexOf(".wav",z.length-4)!==-1||z.indexOf(".m4a",z.length-4)!==-1||z.indexOf("blob:")!==-1){this._streaming?(this._htmlAudioElement=new Audio(z),this._htmlAudioElement.controls=!1,this._htmlAudioElement.loop=this.loop,Ye.b.SetCorsBehavior(z,this._htmlAudioElement),this._htmlAudioElement.preload="auto",this._htmlAudioElement.addEventListener("canplaythrough",function(){y._isReadyToPlay=!0,y.autoplay&&y.play(0,y._offset,y._length),y._readyToPlayCallback&&y._readyToPlayCallback()}),document.body.appendChild(this._htmlAudioElement),this._htmlAudioElement.load()):this._scene._loadFile(z,function(J){
1608y._soundLoaded(J)},void 0,!0,!0,function(J){J&&l.a.Error("XHR "+J.status+" error on: "+z+"."),l.a.Error("Sound creation aborted."),y._scene.mainSoundTrack.removeSound(y)});break}}break;default:P=!1}P?U||(this._isReadyToPlay=!0,this._readyToPlayCallback&&window.setTimeout(function(){y._readyToPlayCallback&&y._readyToPlayCallback()},1e3)):l.a.Error("Parameter must be a URL to the sound, an Array of URLs (.mp3 & .ogg) or an ArrayBuffer of the sound.")}catch{l.a.Error("Unexpected error. Sound creation aborted."),this._scene.mainSoundTrack.removeSound(this)}}else this._scene.mainSoundTrack.addSound(this),Ue.a.audioEngine.WarnedWebAudioUnsupported||(l.a.Error("Web Audio is not supported by your browser."),Ue.a.audioEngine.WarnedWebAudioUnsupported=!0),this._readyToPlayCallback&&window.setTimeout(function(){y._readyToPlayCallback&&y._readyToPlayCallback()},1e3)}return Object.defineProperty(r.prototype,"currentTime",{get:function(){if(this._htmlAudioElement)return this._htmlAudioElement.currentTime;var t=this._startOffset;return this.isPlaying&&Ue.a.audioEngine.audioContext&&(t+=Ue.a.audioEngine.audioContext.currentTime-this._startTime),t},enumerable:!1,configurable:!0}),r.prototype.dispose=function(){Ue.a.audioEngine.canUseWebAudio&&(this.isPlaying&&this.stop(),this._isReadyToPlay=!1,this.soundTrackId===-1?this._scene.mainSoundTrack.removeSound(this):this._scene.soundTracks&&this._scene.soundTracks[this.soundTrackId].removeSound(this),this._soundGain&&(this._soundGain.disconnect(),this._soundGain=null),this._soundPanner&&(this._soundPanner.disconnect(),this._soundPanner=null),this._soundSource&&(this._soundSource.disconnect(),this._soundSource=null),this._audioBuffer=null,this._htmlAudioElement&&(this._htmlAudioElement.pause(),this._htmlAudioElement.src="",document.body.removeChild(this._htmlAudioElement)),this._streamingSource&&this._streamingSource.disconnect(),this._connectedTransformNode&&this._registerFunc&&(this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._connectedTransformNode=null))},r.prototype.isReady=function(){return this._isReadyToPlay},r.prototype._soundLoaded=function(t){var e=this;Ue.a.audioEngine.audioContext&&Ue.a.audioEngine.audioContext.decodeAudioData(t,function(n){e._audioBuffer=n,e._isReadyToPlay=!0,e.autoplay&&e.play(0,e._offset,e._length),e._readyToPlayCallback&&e._readyToPlayCallback()},function(n){l.a.Error("Error while decoding audio data for: "+e.name+" / Error: "+n)})},r.prototype.setAudioBuffer=function(t){Ue.a.audioEngine.canUseWebAudio&&(this._audioBuffer=t,this._isReadyToPlay=!0)},r.prototype.updateOptions=function(t){var e,n,i,o,a,s,d,p,y;t&&(this.loop=(e=t.loop)!==null&&e!==void 0?e:this.loop,this.maxDistance=(n=t.maxDistance)!==null&&n!==void 0?n:this.maxDistance,this.useCustomAttenuation=(i=t.useCustomAttenuation)!==null&&i!==void 0?i:this.useCustomAttenuation,this.rolloffFactor=(o=t.rolloffFactor)!==null&&o!==void 0?o:this.rolloffFactor,this.refDistance=(a=t.refDistance)!==null&&a!==void 0?a:this.refDistance,this.distanceModel=(s=t.distanceModel)!==null&&s!==void 0?s:this.distanceModel,this._playbackRate=(d=t.playbackRate)!==null&&d!==void 0?d:this._playbackRate,this._length=(p=t.length)!==null&&p!==void 0?p:void 0,this._offset=(y=t.offset)!==null&&y!==void 0?y:void 0,this._updateSpatialParameters(),this.isPlaying&&(this._streaming&&this._htmlAudioElement?(this._htmlAudioElement.playbackRate=this._playbackRate,this._htmlAudioElement.loop!==this.loop&&(this._htmlAudioElement.loop=this.loop)):this._soundSource&&(this._soundSource.playbackRate.value=this._playbackRate,this._soundSource.loop!==this.loop&&(this._soundSource.loop=this.loop),this._offset!==void 0&&this._soundSource.loopStart!==this._offset&&(this._soundSource.loopStart=this._offset),this._length!==void 0&&this._length!==this._soundSource.loopEnd&&(this._soundSource.loopEnd=(0|this._offset)+this._length))))},r.prototype._createSpatialParameters=function(){Ue.a.audioEngine.canUseWebAudio&&Ue.a.audioEngine.audioContext&&(this._scene.headphone&&(this._panningModel="HRTF"),this._soundPanner=Ue.a.audioEngine.audioContext.createPanner(),this._soundPanner&&this._outputAudioNode&&(this._updateSpatialParameters(),this._soundPanner.connect(this._outputAudioNode),this._inputAudioNode=this._soundPanner))},r.prototype._updateSpatialParameters=function(){this.spatialSound&&this._soundPanner&&(this.useCustomAttenuation?(this._soundPanner.distanceModel="linear",this._soundPanner.maxDistance=Number.MAX_VALUE,this._soundPanner.refDistance=1,this._soundPanner.rolloffFactor=1,this._soundPanner.panningModel=this._panningModel):(this._soundPanner.distanceModel=this.distanceModel,this._soundPanner.maxDistance=this.maxDistance,this._soundPanner.refDistance=this.refDistance,this._soundPanner.rolloffFactor=this.rolloffFactor,this._soundPanner.panningModel=this._panningModel))},r.prototype.switchPanningModelToHRTF=function(){this._panningModel="HRTF",this._switchPanningModel()},r.prototype.switchPanningModelToEqualPower=function(){this._panningModel="equalpower",this._switchPanningModel()},r.prototype._switchPanningModel=function(){Ue.a.audioEngine.canUseWebAudio&&this.spatialSound&&this._soundPanner&&(this._soundPanner.panningModel=this._panningModel)},r.prototype.connectToSoundTrackAudioNode=function(t){Ue.a.audioEngine.canUseWebAudio&&this._outputAudioNode&&(this._isOutputConnected&&this._outputAudioNode.disconnect(),this._outputAudioNode.connect(t),this._isOutputConnected=!0)},r.prototype.setDirectionalCone=function(t,e,n){e<t?l.a.Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle."):(this._coneInnerAngle=t,this._coneOuterAngle=e,this._coneOuterGain=n,this._isDirectional=!0,this.isPlaying&&this.loop&&(this.stop(),this.play(0,this._offset,this._length)))},Object.defineProperty(r.prototype,"directionalConeInnerAngle",{get:function(){return this._coneInnerAngle},set:function(t){if(t!=this._coneInnerAngle){if(this._coneOuterAngle<t)return void l.a.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");this._coneInnerAngle=t,Ue.a.audioEngine.canUseWebAudio&&this.spatialSound&&this._soundPanner&&(this._soundPanner.coneInnerAngle=this._coneInnerAngle)}}
1608,enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"directionalConeOuterAngle",{get:function(){return this._coneOuterAngle},set:function(t){if(t!=this._coneOuterAngle){if(t<this._coneInnerAngle)return void l.a.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");this._coneOuterAngle=t,Ue.a.audioEngine.canUseWebAudio&&this.spatialSound&&this._soundPanner&&(this._soundPanner.coneOuterAngle=this._coneOuterAngle)}},enumerable:!1,configurable:!0}),r.prototype.setPosition=function(t){this._position=t,Ue.a.audioEngine.canUseWebAudio&&this.spatialSound&&this._soundPanner&&!isNaN(this._position.x)&&!isNaN(this._position.y)&&!isNaN(this._position.z)&&this._soundPanner.setPosition(this._position.x,this._position.y,this._position.z)},r.prototype.setLocalDirectionToMesh=function(t){this._localDirection=t,Ue.a.audioEngine.canUseWebAudio&&this._connectedTransformNode&&this.isPlaying&&this._updateDirection()},r.prototype._updateDirection=function(){if(this._connectedTransformNode&&this._soundPanner){var t=this._connectedTransformNode.getWorldMatrix(),e=u.e.TransformNormal(this._localDirection,t);e.normalize(),this._soundPanner.setOrientation(e.x,e.y,e.z)}},r.prototype.updateDistanceFromListener=function(){if(Ue.a.audioEngine.canUseWebAudio&&this._connectedTransformNode&&this.useCustomAttenuation&&this._soundGain&&this._scene.activeCamera){var t=this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);this._soundGain.gain.value=this._customAttenuationFunction(this._volume,t,this.maxDistance,this.refDistance,this.rolloffFactor)}},r.prototype.setAttenuationFunction=function(t){this._customAttenuationFunction=t},r.prototype.play=function(t,e,n){var i=this;if(this._isReadyToPlay&&this._scene.audioEnabled&&Ue.a.audioEngine.audioContext)try{this._startOffset<0&&(t=-this._startOffset,this._startOffset=0);var o=t?Ue.a.audioEngine.audioContext.currentTime+t:Ue.a.audioEngine.audioContext.currentTime;if(this._soundSource&&this._streamingSource||this.spatialSound&&this._soundPanner&&(isNaN(this._position.x)||isNaN(this._position.y)||isNaN(this._position.z)||this._soundPanner.setPosition(this._position.x,this._position.y,this._position.z),this._isDirectional&&(this._soundPanner.coneInnerAngle=this._coneInnerAngle,this._soundPanner.coneOuterAngle=this._coneOuterAngle,this._soundPanner.coneOuterGain=this._coneOuterGain,this._connectedTransformNode?this._updateDirection():this._soundPanner.setOrientation(this._localDirection.x,this._localDirection.y,this._localDirection.z))),this._streaming)this._streamingSource||(this._streamingSource=Ue.a.audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement),this._htmlAudioElement.onended=function(){i._onended()},this._htmlAudioElement.playbackRate=this._playbackRate),this._streamingSource.disconnect(),this._inputAudioNode&&this._streamingSource.connect(this._inputAudioNode),this._htmlAudioElement&&(a=function(){if(Ue.a.audioEngine.unlocked){var s=i._htmlAudioElement.play();s!==void 0&&s.catch(function(d){Ue.a.audioEngine.lock(),(i.loop||i.autoplay)&&Ue.a.audioEngine.onAudioUnlockedObservable.addOnce(function(){a()})})}else(i.loop||i.autoplay)&&Ue.a.audioEngine.onAudioUnlockedObservable.addOnce(function(){a()})})();else{var a=function(){if(Ue.a.audioEngine.audioContext){if(n=n||i._length,e=e||i._offset,i._soundSource){var s=i._soundSource;s.onended=function(){s.disconnect()}}if(i._soundSource=Ue.a.audioEngine.audioContext.createBufferSource(),i._soundSource&&i._inputAudioNode){i._soundSource.buffer=i._audioBuffer,i._soundSource.connect(i._inputAudioNode),i._soundSource.loop=i.loop,e!==void 0&&(i._soundSource.loopStart=e),n!==void 0&&(i._soundSource.loopEnd=(0|e)+n),i._soundSource.playbackRate.value=i._playbackRate,i._soundSource.onended=function(){i._onended()},o=t?Ue.a.audioEngine.audioContext.currentTime+t:Ue.a.audioEngine.audioContext.currentTime;var d=i.isPaused?i._startOffset%i._soundSource.buffer.duration:e||0;i._soundSource.start(o,d,i.loop?void 0:n)}}};Ue.a.audioEngine.audioContext.state==="suspended"?setTimeout(function(){Ue.a.audioEngine.audioContext.state==="suspended"?(Ue.a.audioEngine.lock(),(i.loop||i.autoplay)&&Ue.a.audioEngine.onAudioUnlockedObservable.addOnce(function(){a()})):a()},500):a()}this._startTime=o,this.isPlaying=!0,this.isPaused=!1}catch(s){l.a.Error("Error while trying to play audio: "+this.name+", "+s.message)}},r.prototype._onended=function(){this.isPlaying=!1,this._startOffset=0,this.onended&&this.onended(),this.onEndedObservable.notifyObservers(this)},r.prototype.stop=function(t){var e=this;if(this.isPlaying){if(this._streaming)this._htmlAudioElement?(this._htmlAudioElement.pause(),this._htmlAudioElement.currentTime>0&&(this._htmlAudioElement.currentTime=0)):this._streamingSource.disconnect(),this.isPlaying=!1;else if(Ue.a.audioEngine.audioContext&&this._soundSource){var n=t?Ue.a.audioEngine.audioContext.currentTime+t:Ue.a.audioEngine.audioContext.currentTime;this._soundSource.stop(n),this._soundSource.onended=function(){e.isPlaying=!1},this.isPaused||(this._startOffset=0)}}},r.prototype.pause=function(){this.isPlaying&&(this.isPaused=!0,this._streaming?this._htmlAudioElement?this._htmlAudioElement.pause():this._streamingSource.disconnect():Ue.a.audioEngine.audioContext&&(this.stop(0),this._startOffset+=Ue.a.audioEngine.audioContext.currentTime-this._startTime))},r.prototype.setVolume=function(t,e){Ue.a.audioEngine.canUseWebAudio&&this._soundGain&&(e&&Ue.a.audioEngine.audioContext?(this._soundGain.gain.cancelScheduledValues(Ue.a.audioEngine.audioContext.currentTime),this._soundGain.gain.setValueAtTime(this._soundGain.gain.value,Ue.a.audioEngine.audioContext.currentTime),this._soundGain.gain.linearRampToValueAtTime(t,Ue.a.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.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){if(this._positionInEmitterSpace)t.worldMatrixFromCache.invertToRef(u.c.Matrix[0]),this.setPosition(u.c.Matrix[0].getTranslation());else if(t.getBoundingInfo){var e=t.getBoundingInfo();this.setPosition(e.boundingSphere.centerWorld)}else this.setPosition(t.absolutePosition);Ue.a.audioEngine.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)):window.setTimeout(e,3
160800)},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.name,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,d={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 p=function(){i._isReadyToPlay?(s._audioBuffer=i.getAudioBuffer(),s._isReadyToPlay=!0,s.autoplay&&s.play(0,s._offset,s._length)):window.setTimeout(p,300)};s=new r(a,new ArrayBuffer(0),e,null,d),p()}else s=new r(a,o,e,function(){e._removePendingData(s)},d),e._addPendingData(s);if(t.position){var y=u.e.FromArray(t.position);s.setPosition(y)}if(t.isDirectional&&(s.setDirectionalCone(t.coneInnerAngle||360,t.coneOuterAngle||360,t.coneOuterGain||0),t.localDirectionToMesh)){var P=u.e.FromArray(t.localDirectionToMesh);s.setLocalDirectionToMesh(P)}if(t.connectedMeshId){var O=e.getMeshByID(t.connectedMeshId);O&&s.attachToMesh(O)}return t.metadata&&(s.metadata=t.metadata),s},r._SceneComponentInitialization=function(t){throw En.a.WarnImport("AudioSceneComponent")},r}(),Fo=function(){function r(t,e){e===void 0&&(e={}),this.id=-1,this._isInitialized=!1,this._scene=t,this.soundCollection=new Array,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(){Ue.a.audioEngine.canUseWebAudio&&Ue.a.audioEngine.audioContext&&(this._outputAudioNode=Ue.a.audioEngine.audioContext.createGain(),this._outputAudioNode.connect(Ue.a.audioEngine.masterGain),this._options&&this._options.volume&&(this._outputAudioNode.gain.value=this._options.volume),this._isInitialized=!0)},r.prototype.dispose=function(){if(Ue.a.audioEngine&&Ue.a.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){this._isInitialized||this._initializeSoundTrackAudioGraph(),Ue.a.audioEngine.canUseWebAudio&&this._outputAudioNode&&t.connectToSoundTrackAudioNode(this._outputAudioNode),t.soundTrackId&&(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){Ue.a.audioEngine.canUseWebAudio&&this._outputAudioNode&&(this._outputAudioNode.gain.value=t)},r.prototype.switchPanningModelToHRTF=function(){if(Ue.a.audioEngine.canUseWebAudio)for(var t=0;t<this.soundCollection.length;t++)this.soundCollection[t].switchPanningModelToHRTF()},r.prototype.switchPanningModelToEqualPower=function(){if(Ue.a.audioEngine.canUseWebAudio)for(var t=0;t<this.soundCollection.length;t++)this.soundCollection[t].switchPanningModelToEqualPower()},r.prototype.connectToAnalyser=function(t){this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas(),this._connectedAnalyser=t,Ue.a.audioEngine.canUseWebAudio&&this._outputAudioNode&&(this._outputAudioNode.disconnect(),this._connectedAnalyser.connectAudioNodes(this._outputAudioNode,Ue.a.audioEngine.masterGain))},r}(),st=f(17);B.a.AddParser(st.a.NAME_AUDIO,function(r,t,e,n){var i,o=[];if(e.sounds=e.sounds||[],r.sounds!==void 0&&r.sounds!==null)for(var a=0,s=r.sounds.length;a<s;a++){var d=r.sounds[a];Ue.a.audioEngine.canUseWebAudio?(d.url||(d.url=d.name),o[d.url]?e.sounds.push(Zn.Parse(d,t,n,o[d.url])):(i=Zn.Parse(d,t,n),o[d.url]=i,e.sounds.push(i))):e.sounds.push(new Zn(d.name,null,t))}o=[]}),Object.defineProperty(_e.a.prototype,"mainSoundTrack",{get:function(){var r=this._getComponent(st.a.NAME_AUDIO);return r||(r=new Jn(this),this._addComponent(r)),this._mainSoundTrack||(this._mainSoundTrack=new Fo(this,{mainTrack:!0})),this._mainSoundTrack},enumerable:!0,configurable:!0}),_e.a.prototype.getSoundByName=function(r){var t;for(t=0;t<this.mainSoundTrack.soundCollection.length;t++)if(this.mainSoundTrack.soundCollection[t].name===r)return this.mainSoundTrack.soundCollection[t];if(this.soundTracks){for(var e=0;e<this.soundTracks.length;e++)for(t=0;t<this.soundTracks[e].soundCollection.length;t++)if(this.soundTracks[e].soundCollection[t].name===r)return this.soundTracks[e].soundCollection[t]}return null},Object.defineProperty(_e.a.prototype,"audioEnabled",{get:function(){var r=this._getComponent(st.a.NAME_AUDIO);return r||(r=new Jn(this),this._addComponent(r)),r.audioEnabled},set:function(r){var t=this._getComponent(st.a.NAME_AUDIO);t||(t=new Jn(this),this._addComponent(t)),r?t.enableAudio():t.disableAudio()},enumerable:!0,configurable:!0}),Object.defineProperty(_e.a.prototype,"headphone",{get:function(){var r=this._getComponent(st.a.NAME_AUDIO);return r||(r=new Jn(this),this._addComponent(r)),r.headphone},set:function(r){var t=this._getComponent(st.a.NAME_AUDIO);t||(t=new Jn(this),this._addComponent(t)),r?t.switchAudioModeForHeadphones():t.switchAudioModeForNormalSpeakers()},enumerable:!0,configurable:!0}),Object.defineProperty(_e.a.prototype,"audioListenerPositionProvider",{get:function(){var r=this._getComponent(st.a.NAME_AUDIO);return r||(r=new Jn(this),this._addComponent(r)),r.audioListenerPositionProvider},set:function(r){var t=this._getComponent(st.a.NAME_AUDIO);if(t||(t=new Jn(this),this._addComponent(t)),typeof r!="function")throw new Error("The value passed to [Scene.audioListenerPositionProvider] must be a function that returns a Vector3");t.audioListenerPositionProvider=r},enumerable:!0,configurable:!0}),Object.defineProperty(_e.a.prototype,"audioPositioningRefreshRate",{get:function(){var r=this._getComponent(st.a.NAME_AUDIO);return r||(r=new Jn(this),this._addComponent(r)),r.audioPositioningRefreshRate},set:function(r){var t=this._getComponent(st.a.NAME_AUDIO);t||(t=new Jn(this),this._addComponent(t)),t.audioPositioningRefreshRate=r},enumerable:!0,configurable:!0});var Jn=function(){function r(t){this.name=st.a.NAME_AUDIO,this._audioEnabled=!0,this._headphone=!1,this.audioPositioningRefreshRate=500,this._audioListenerPositionProvider=null,this._cachedCameraDirection=new u.e,this._cachedCameraPosition=new u.e,this._lastCheck=0,this.scene=t,t.soundTracks=new Array,t.sounds=new Array}return Object.defineProperty(r.prototype,"audioEnabled",{get:function(){return this._audioEnabled}
1608,enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"headphone",{get:function(){return this._headphone},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"audioListenerPositionProvider",{get:function(){return this._audioListenerPositionProvider},set:function(t){this._audioListenerPositionProvider=t},enumerable:!1,configurable:!0}),r.prototype.register=function(){this.scene._afterRenderStage.registerStep(st.a.STEP_AFTERRENDER_AUDIO,this,this._afterRender)},r.prototype.rebuild=function(){},r.prototype.serialize=function(t){if(t.sounds=[],this.scene.soundTracks)for(var e=0;e<this.scene.soundTracks.length;e++)for(var n=this.scene.soundTracks[e],i=0;i<n.soundCollection.length;i++)t.sounds.push(n.soundCollection[i].serialize())},r.prototype.addFromContainer=function(t){var e=this;t.sounds&&t.sounds.forEach(function(n){n.play(),n.autoplay=!0,e.scene.mainSoundTrack.addSound(n)})},r.prototype.removeFromContainer=function(t,e){var n=this;e===void 0&&(e=!1),t.sounds&&t.sounds.forEach(function(i){i.stop(),i.autoplay=!1,n.scene.mainSoundTrack.removeSound(i),e&&i.dispose()})},r.prototype.dispose=function(){var t=this.scene;if(t._mainSoundTrack&&t.mainSoundTrack.dispose(),t.soundTracks)for(var e=0;e<t.soundTracks.length;e++)t.soundTracks[e].dispose()},r.prototype.disableAudio=function(){var t,e=this.scene;for(this._audioEnabled=!1,Ue.a.audioEngine&&Ue.a.audioEngine.audioContext&&Ue.a.audioEngine.audioContext.suspend(),t=0;t<e.mainSoundTrack.soundCollection.length;t++)e.mainSoundTrack.soundCollection[t].pause();if(e.soundTracks)for(t=0;t<e.soundTracks.length;t++)for(var n=0;n<e.soundTracks[t].soundCollection.length;n++)e.soundTracks[t].soundCollection[n].pause()},r.prototype.enableAudio=function(){var t,e=this.scene;for(this._audioEnabled=!0,Ue.a.audioEngine&&Ue.a.audioEngine.audioContext&&Ue.a.audioEngine.audioContext.resume(),t=0;t<e.mainSoundTrack.soundCollection.length;t++)e.mainSoundTrack.soundCollection[t].isPaused&&e.mainSoundTrack.soundCollection[t].play();if(e.soundTracks)for(t=0;t<e.soundTracks.length;t++)for(var n=0;n<e.soundTracks[t].soundCollection.length;n++)e.soundTracks[t].soundCollection[n].isPaused&&e.soundTracks[t].soundCollection[n].play()},r.prototype.switchAudioModeForHeadphones=function(){var t=this.scene;if(this._headphone=!0,t.mainSoundTrack.switchPanningModelToHRTF(),t.soundTracks)for(var e=0;e<t.soundTracks.length;e++)t.soundTracks[e].switchPanningModelToHRTF()},r.prototype.switchAudioModeForNormalSpeakers=function(){var t=this.scene;if(this._headphone=!1,t.mainSoundTrack.switchPanningModelToEqualPower(),t.soundTracks)for(var e=0;e<t.soundTracks.length;e++)t.soundTracks[e].switchPanningModelToEqualPower()},r.prototype._afterRender=function(){var t=be.a.Now;if(!(this._lastCheck&&t-this._lastCheck<this.audioPositioningRefreshRate)){this._lastCheck=t;var e=this.scene;if(this._audioEnabled&&e._mainSoundTrack&&e.soundTracks&&(e._mainSoundTrack.soundCollection.length!==0||e.soundTracks.length!==1)){var n=Ue.a.audioEngine;if(n&&n.audioContext){if(this._audioListenerPositionProvider){var i=this._audioListenerPositionProvider();i.x=i.x||0,i.y=i.y||0,i.z=i.z||0,n.audioContext.listener.setPosition(i.x,i.y,i.z)}else{var o;if(o=e.activeCameras&&e.activeCameras.length>0?e.activeCameras[0]:e.activeCamera){this._cachedCameraPosition.equals(o.globalPosition)||(this._cachedCameraPosition.copyFrom(o.globalPosition),n.audioContext.listener.setPosition(o.globalPosition.x,o.globalPosition.y,o.globalPosition.z)),o.rigCameras&&o.rigCameras.length>0&&(o=o.rigCameras[0]);var a=u.a.Invert(o.getViewMatrix()),s=u.e.TransformNormal(e.useRightHandedSystem?r._CameraDirectionRH:r._CameraDirectionLH,a);s.normalize(),isNaN(s.x)||isNaN(s.y)||isNaN(s.z)||this._cachedCameraDirection.equals(s)||(this._cachedCameraDirection.copyFrom(s),n.audioContext.listener.setOrientation(s.x,s.y,s.z,0,1,0))}else n.audioContext.listener.setPosition(0,0,0)}var d;for(d=0;d<e.mainSoundTrack.soundCollection.length;d++){var p=e.mainSoundTrack.soundCollection[d];p.useCustomAttenuation&&p.updateDistanceFromListener()}if(e.soundTracks)for(d=0;d<e.soundTracks.length;d++)for(var y=0;y<e.soundTracks[d].soundCollection.length;y++)(p=e.soundTracks[d].soundCollection[y]).useCustomAttenuation&&p.updateDistanceFromListener()}}}},r._CameraDirectionLH=new u.e(0,0,-1),r._CameraDirectionRH=new u.e(0,0,1),r}();Zn._SceneComponentInitialization=function(r){var t=r._getComponent(st.a.NAME_AUDIO);t||(t=new Jn(r),r._addComponent(t))};var $f=function(){function r(t,e,n){var i=this;if(this.loop=!1,this._coneInnerAngle=360,this._coneOuterAngle=360,this._volume=1,this.isPlaying=!1,this.isPaused=!1,this._sounds=[],this._weights=[],e.length!==n.length)throw new Error("Sounds length does not equal weights length");this.loop=t,this._weights=n;for(var o=0,a=0,s=n;a<s.length;a++)o+=s[a];for(var d=o>0?1/o:0,p=0;p<this._weights.length;p++)this._weights[p]*=d;this._sounds=e;for(var y=0,P=this._sounds;y<P.length;y++)P[y].onEndedObservable.add(function(){i._onended()})}return Object.defineProperty(r.prototype,"directionalConeInnerAngle",{get:function(){return this._coneInnerAngle},set:function(t){if(t!==this._coneInnerAngle){if(this._coneOuterAngle<t)return void l.a.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");this._coneInnerAngle=t;for(var e=0,n=this._sounds;e<n.length;e++)n[e].directionalConeInnerAngle=t}}
1608,enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"directionalConeOuterAngle",{get:function(){return this._coneOuterAngle},set:function(t){if(t!==this._coneOuterAngle){if(t<this._coneInnerAngle)return void l.a.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");this._coneOuterAngle=t;for(var e=0,n=this._sounds;e<n.length;e++)n[e].directionalConeOuterAngle=t}},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"volume",{get:function(){return this._volume},set:function(t){if(t!==this._volume)for(var e=0,n=this._sounds;e<n.length;e++)n[e].setVolume(t)},enumerable:!1,configurable:!0}),r.prototype._onended=function(){this._currentIndex!==void 0&&(this._sounds[this._currentIndex].autoplay=!1),this.loop&&this.isPlaying?this.play():this.isPlaying=!1},r.prototype.pause=function(){this.isPaused=!0,this._currentIndex!==void 0&&this._sounds[this._currentIndex].pause()},r.prototype.stop=function(){this.isPlaying=!1,this._currentIndex!==void 0&&this._sounds[this._currentIndex].stop()},r.prototype.play=function(t){if(!this.isPaused){this.stop();for(var e=Math.random(),n=0,i=0;i<this._weights.length;i++)if(e<=(n+=this._weights[i])){this._currentIndex=i;break}}var o=this._sounds[this._currentIndex];o.isReady()?o.play(0,this.isPaused?void 0:t):o.autoplay=!0,this.isPlaying=!0,this.isPaused=!1},r}(),Tt=f(18),El=function(){function r(){this._zoomStopsAnimation=!1,this._idleRotationSpeed=.05,this._idleRotationWaitTime=2e3,this._idleRotationSpinupTime=2e3,this._isPointerDown=!1,this._lastFrameTime=null,this._lastInteractionTime=-1/0,this._cameraRotationSpeed=0,this._lastFrameRadius=0}return Object.defineProperty(r.prototype,"name",{get:function(){return"AutoRotation"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"zoomStopsAnimation",{get:function(){return this._zoomStopsAnimation},set:function(t){this._zoomStopsAnimation=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"idleRotationSpeed",{get:function(){return this._idleRotationSpeed},set:function(t){this._idleRotationSpeed=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"idleRotationWaitTime",{get:function(){return this._idleRotationWaitTime},set:function(t){this._idleRotationWaitTime=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"idleRotationSpinupTime",{get:function(){return this._idleRotationSpinupTime},set:function(t){this._idleRotationSpinupTime=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"rotationInProgress",{get:function(){return Math.abs(this._cameraRotationSpeed)>0},enumerable:!1,configurable:!0}),r.prototype.init=function(){},r.prototype.attach=function(t){var e=this;this._attachedCamera=t;var n=this._attachedCamera.getScene();this._onPrePointerObservableObserver=n.onPrePointerObservable.add(function(i){i.type!==Tt.a.POINTERDOWN?i.type===Tt.a.POINTERUP&&(e._isPointerDown=!1):e._isPointerDown=!0}),this._onAfterCheckInputsObserver=t.onAfterCheckInputsObservable.add(function(){var i=be.a.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._userIsZooming=function(){return!!this._attachedCamera&&this._attachedCamera.inertialRadiusOffset!==0},r.prototype._shouldAnimationStopForInteraction=function(){if(!this._attachedCamera)return!1;var t=!1;return this._lastFrameRadius===this._attachedCamera.radius&&this._attachedCamera.inertialRadiusOffset!==0&&(t=!0),this._lastFrameRadius=this._attachedCamera.radius,this._zoomStopsAnimation?t:this._userIsZooming()},r.prototype._applyUserInteraction=function(){this._userIsMoving()&&!this._shouldAnimationStopForInteraction()&&(this._lastInteractionTime=be.a.Now)},r.prototype._userIsMoving=function(){return!!this._attachedCamera&&(this._attachedCamera.inertialAlphaOffset!==0||this._attachedCamera.inertialBetaOffset!==0||this._attachedCamera.inertialRadiusOffset!==0||this._attachedCamera.inertialPanningX!==0||this._attachedCamera.inertialPanningY!==0||this._isPointerDown)},r}(),Sl=function(){function r(){this.transitionDuration=450,this.lowerRadiusTransitionRange=2,this.up
1608perRadiusTransitionRange=-2,this._autoTransitionRange=!1,this._radiusIsAnimating=!1,this._radiusBounceTransition=null,this._animatables=new Array}return Object.defineProperty(r.prototype,"name",{get:function(){return"Bouncing"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"autoTransitionRange",{get:function(){return this._autoTransitionRange},set:function(t){var e=this;if(this._autoTransitionRange!==t){this._autoTransitionRange=t;var n=this._attachedCamera;n&&(t?this._onMeshTargetChangedObserver=n.onMeshTargetChangedObservable.add(function(i){if(i){i.computeWorldMatrix(!0);var o=i.getBoundingInfo().diagonalLength;e.lowerRadiusTransitionRange=.05*o,e.upperRadiusTransitionRange=.05*o}}):this._onMeshTargetChangedObserver&&n.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver))}},enumerable:!1,configurable:!0}),r.prototype.init=function(){},r.prototype.attach=function(t){var e=this;this._attachedCamera=t,this._onAfterCheckInputsObserver=t.onAfterCheckInputsObservable.add(function(){e._attachedCamera&&(e._isRadiusAtLimit(e._attachedCamera.lowerRadiusLimit)&&e._applyBoundRadiusAnimation(e.lowerRadiusTransitionRange),e._isRadiusAtLimit(e._attachedCamera.upperRadiusLimit)&&e._applyBoundRadiusAnimation(e.upperRadiusTransitionRange))})},r.prototype.detach=function(){this._attachedCamera&&(this._onAfterCheckInputsObserver&&this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._onMeshTargetChangedObserver&&this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),this._attachedCamera=null)},r.prototype._isRadiusAtLimit=function(t){return!!this._attachedCamera&&this._attachedCamera.radius===t&&!this._radiusIsAnimating},r.prototype._applyBoundRadiusAnimation=function(t){var e=this;if(this._attachedCamera){this._radiusBounceTransition||(r.EasingFunction.setEasingMode(r.EasingMode),this._radiusBounceTransition=k.CreateAnimation("radius",k.ANIMATIONTYPE_FLOAT,60,r.EasingFunction)),this._cachedWheelPrecision=this._attachedCamera.wheelPrecision,this._attachedCamera.wheelPrecision=1/0,this._attachedCamera.inertialRadiusOffset=0,this.stopAllAnimations(),this._radiusIsAnimating=!0;var n=k.TransitionTo("radius",this._attachedCamera.radius+t,this._attachedCamera,this._attachedCamera.getScene(),60,this._radiusBounceTransition,this.transitionDuration,function(){return e._clearAnimationLocks()});n&&this._animatables.push(n)}},r.prototype._clearAnimationLocks=function(){this._radiusIsAnimating=!1,this._attachedCamera&&(this._attachedCamera.wheelPrecision=this._cachedWheelPrecision)},r.prototype.stopAllAnimations=function(){for(this._attachedCamera&&(this._attachedCamera.animations=[]);this._animatables.length;)this._animatables[0].onAnimationEnd=null,this._animatables[0].stop(),this._animatables.shift()},r.EasingFunction=new et(.3),r.EasingMode=ze.EASINGMODE_EASEOUT,r}(),Al=function(){function r(){this._mode=r.FitFrustumSidesMode,this._radiusScale=1,this._positionScale=.5,this._defaultElevation=.3,this._elevationReturnTime=1500,this._elevationReturnWaitTime=1e3,this._zoomStopsAnimation=!1,this._framingTime=1500,this.autoCorrectCameraLimitsAndSensibility=!0,this._isPointerDown=!1,this._lastInteractionTime=-1/0,this._animatables=new Array,this._betaIsAnimating=!1}return Object.defineProperty(r.prototype,"name",{get:function(){return"Framing"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"mode",{get:function(){return this._mode},set:function(t){this._mode=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"radiusScale",{get:function(){return this._radiusScale},set:function(t){this._radiusScale=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"positionScale",{get:function(){return this._positionScale},set:function(t){this._positionScale=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"defaultElevation",{get:function(){return this._defaultElevation},set:function(t){this._defaultElevation=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"elevationReturnTime",{get:function(){return this._elevationReturnTime},set:function(t){this._elevationReturnTime=t}
1608,enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"elevationReturnWaitTime",{get:function(){return this._elevationReturnWaitTime},set:function(t){this._elevationReturnWaitTime=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"zoomStopsAnimation",{get:function(){return this._zoomStopsAnimation},set:function(t){this._zoomStopsAnimation=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"framingTime",{get:function(){return this._framingTime},set:function(t){this._framingTime=t},enumerable:!1,configurable:!0}),r.prototype.init=function(){},r.prototype.attach=function(t){var e=this;this._attachedCamera=t;var n=this._attachedCamera.getScene();r.EasingFunction.setEasingMode(r.EasingMode),this._onPrePointerObservableObserver=n.onPrePointerObservable.add(function(i){i.type!==Tt.a.POINTERDOWN?i.type===Tt.a.POINTERUP&&(e._isPointerDown=!1):e._isPointerDown=!0}),this._onMeshTargetChangedObserver=t.onMeshTargetChangedObservable.add(function(i){i&&e.zoomOnMesh(i)}),this._onAfterCheckInputsObserver=t.onAfterCheckInputsObservable.add(function(){e._applyUserInteraction(),e._maintainCameraAboveGround()})},r.prototype.detach=function(){if(this._attachedCamera){var t=this._attachedCamera.getScene();this._onPrePointerObservableObserver&&t.onPrePointerObservable.remove(this._onPrePointerObservableObserver),this._onAfterCheckInputsObserver&&this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._onMeshTargetChangedObserver&&this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),this._attachedCamera=null}},r.prototype.zoomOnMesh=function(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=null),t.computeWorldMatrix(!0);var i=t.getBoundingInfo().boundingBox;this.zoomOnBoundingInfo(i.minimumWorld,i.maximumWorld,e,n)},r.prototype.zoomOnMeshHierarchy=function(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=null),t.computeWorldMatrix(!0);var i=t.getHierarchyBoundingVectors(!0);this.zoomOnBoundingInfo(i.min,i.max,e,n)},r.prototype.zoomOnMeshesHierarchy=function(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=null);for(var i=new u.e(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),o=new u.e(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),a=0;a<t.length;a++){var s=t[a].getHierarchyBoundingVectors(!0);u.e.CheckExtends(s.min,i,o),u.e.CheckExtends(s.max,i,o)}this.zoomOnBoundingInfo(i,o,e,n)},r.prototype.zoomOnBoundingInfo=function(t,e,n,i){var o,a=this;if(n===void 0&&(n=!1),i===void 0&&(i=null),this._attachedCamera){var s=t.y,d=s+(e.y-s)*this._positionScale,p=e.subtract(t).scale(.5);if(n)o=new u.e(0,d,0);else{var y=t.add(p);o=new u.e(y.x,d,y.z)}this._vectorTransition||(this._vectorTransition=k.CreateAnimation("target",k.ANIMATIONTYPE_VECTOR3,60,r.EasingFunction)),this._betaIsAnimating=!0;var P=k.TransitionTo("target",o,this._attachedCamera,this._attachedCamera.getScene(),60,this._vectorTransition,this._framingTime);P&&this._animatables.push(P);var O=0;if(this._mode===r.FitFrustumSidesMode){var U=this._calculateLowerRadiusFromModelBoundingSphere(t,e);this.autoCorrectCameraLimitsAndSensibility&&(this._attachedCamera.lowerRadiusLimit=p.length()+this._attachedCamera.minZ),O=U}else this._mode===r.IgnoreBoundsSizeMode&&(O=this._calculateLowerRadiusFromModelBoundingSphere(t,e),this.autoCorrectCameraLimitsAndSensibility&&this._attachedCamera.lowerRadiusLimit===null&&(this._attachedCamera.lowerRadiusLimit=this._attachedCamera.minZ));if(this.autoCorrectCameraLimitsAndSensibility){var F=e.subtract(t).length();this._attachedCamera.panningSensibility=5e3/F,this._attachedCamera.wheelPrecision=100/O}this._radiusTransition||(this._radiusTransition=k.CreateAnimation("radius",k.ANIMATIONTYPE_FLOAT,60,r.EasingFunction)),(P=k.TransitionTo("radius",O,this._attachedCamera,this._attachedCamera.getScene(),60,this._radiusTransition,this._framingTime,function(){a.stopAllAnimations(),i&&i(),a._attachedCamera&&a._attachedCamera.useInputToRestoreState&&a._attachedCamera.storeState()}))&&this._animatables.push(P)}},r.prototype._calculateLowerRadiusFromModelBoundingSphere=function(t,e){var n=e.subtract(t).length(),i=this._getFrustumSlope(),o=.5*n*this._radiusScale,a=o*Math.sqrt(1+1/(i.x*i.x)),s=o*Math.sqrt(1+1/(i.y*i.y)),d=Math.max(a,s),p=this._attachedCamera;return p?(p.lowerRadiusLimit&&this._mode===r.IgnoreBoundsSizeMode&&(d=d<p.lowerRadiusLimit?p.lowerRadiusLimit:d),p.up
1608perRadiusLimit&&(d=d>p.upperRadiusLimit?p.upperRadiusLimit:d),d):0},r.prototype._maintainCameraAboveGround=function(){var t=this;if(!(this._elevationReturnTime<0)){var e=be.a.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=k.CreateAnimation("beta",k.ANIMATIONTYPE_FLOAT,60,r.EasingFunction));var o=k.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._getFrustumSlope=function(){var t=this._attachedCamera;if(!t)return u.d.Zero();var e=t.getScene().getEngine().getAspectRatio(t),n=Math.tan(t.fov/2),i=n*e;return new u.d(i,n)},r.prototype._clearAnimationLocks=function(){this._betaIsAnimating=!1},r.prototype._applyUserInteraction=function(){this.isUserIsMoving&&(this._lastInteractionTime=be.a.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()}
1608,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 St,r.EasingMode=ze.EASINGMODE_EASEINOUT,r.IgnoreBoundsSizeMode=0,r.FitFrustumSidesMode=1,r}(),dr=function(r,t,e,n){t===void 0&&(t=new u.e),e===void 0&&(e=0),n===void 0&&(n=!1),this.direction=r,this.rotatedDirection=t,this.diff=e,this.ignore=n},ep=function(){function r(t){this.ui=t,this.name="AttachToBoxBehavior",this.distanceAwayFromFace=.15,this.distanceAwayFromBottomOfFace=.15,this._faceVectors=[new dr(u.e.Up()),new dr(u.e.Down()),new dr(u.e.Left()),new dr(u.e.Right()),new dr(u.e.Forward()),new dr(u.e.Forward().scaleInPlace(-1))],this._tmpMatrix=new u.a,this._tmpVector=new u.e,this._zeroVector=u.e.Zero(),this._lookAtTmpMatrix=new u.a}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=u.b.RotationYawPitchRoll(e._target.rotation.y,e._target.rotation.x,e._target.rotation.z)),e._target.rotationQuaternion.toRotationMatrix(e._tmpMatrix),u.e.TransformCoordinatesToRef(n.direction,e._tmpMatrix,n.rotatedDirection),n.diff=u.e.GetAngleBetweenVectors(n.rotatedDirection,t,u.e.Cross(n.rotatedDirection,t))}),this._faceVectors.reduce(function(n,i){return n.ignore?i:i.ignore||n.diff<i.diff?n:i},this._faceVectors[0])},r.prototype._lookAtToRef=function(t,e,n){e===void 0&&(e=new u.e(0,1,0)),u.a.LookAtLHToRef(this._zeroVector,t,e,this._lookAtTmpMatrix),this._lookAtTmpMatrix.invert(),u.b.FromRotationMatrixToRef(this._lookAtTmpMatrix,n)},r.prototype.attach=function(t){var e=this;this._target=t,this._scene=this._target.getScene(),this._onRenderObserver=this._scene.onBeforeRenderObservable.add(function(){if(e._scene.activeCamera){var n=e._scene.activeCamera.position;e._scene.activeCamera.devicePosition&&(n=e._scene.activeCamera.devicePosition);var i=e._closestFace(n.subtract(t.position));e._scene.activeCamera.leftCamera?e._scene.activeCamera.leftCamera.computeWorldMatrix().getRotationMatrixToRef(e._tmpMatrix):e._scene.activeCamera.computeWorldMatrix().getRotationMatrixToRef(e._tmpMatrix),u.e.TransformCoordinatesToRef(u.e.Up(),e._tmpMatrix,e._tmpVector),e._faceVectors.forEach(function(a){i.direction.x&&a.direction.x&&(a.ignore=!0),i.direction.y&&a.direction.y&&(a.ignore=!0),i.direction.z&&a.direction.z&&(a.ignore=!0)});var o=e._closestFace(e._tmpVector);e._faceVectors.forEach(function(a){a.ignore=!1}),e.ui.position.copyFrom(t.position),i.direction.x&&(i.rotatedDirection.scaleToRef(t.scaling.x/2+e.distanceAwayFromFace,e._tmpVector),e.ui.position.addInPlace(e._tmpVector)),i.direction.y&&(i.rotatedDirection.scaleToRef(t.scaling.y/2+e.distanceAwayFromFace,e._tmpVector),e.ui.position.addInPlace(e._tmpVector)),i.direction.z&&(i.rotatedDirection.scaleToRef(t.scaling.z/2+e.distanceAwayFromFace,e._tmpVector),e.ui.position.addInPlace(e._tmpVector)),e.ui.rotationQuaternion||(e.ui.rotationQuaternion=u.b.RotationYawPitchRoll(e.ui.rotation.y,e.ui.rotation.x,e.ui.rotation.z)),i.rotatedDirection.scaleToRef(-1,e._tmpVector),e._lookAtToRef(e._tmpVector,o.rotatedDirection,e.ui.rotationQuaternion),o.direction.x&&e.ui.up.scaleToRef(e.distanceAwayFromBottomOfFace-t.scaling.x/2,e._tmpVector),o.direction.y&&e.ui.up.scaleToRef(e.distanceAwayFromBottomOfFace-t.scaling.y/2,e._tmpVector),o.direction.z&&e.ui.up.scaleToRef(e.distanceAwayFromBottomOfFace-t.scaling.z/2,e._tmpVector),e.ui.position.addInPlace(e._tmpVector)}})},r.prototype.detach=function(){this._scene.onBeforeRenderObservable.remove(this._onRenderObserver)},r}(),tp=function(){function r(){var t=this;this.delay=0,this.fadeInTime=300,this._millisecondsPerFrame=1e3/60,this._hovered=!1,this._hoverValue=0,this._ownerNode=null,this._update=function(){if(t._ownerNode){if(t._hoverValue+=t._hovered?t._millisecondsPerFrame:-t._millisecondsPerFrame,t._setAllVisibility(t._ownerNode,(t._hoverValue-t.delay)/t.fadeInTime),t._ownerNode.visibility>1)return t._setAllVisibility(t._ownerNode,1),void(t._hoverValue=t.fadeInTime+t.delay);if(t._ownerNode.visibility<0&&(t._setAllVisibility(t._ownerNode,0),t._hoverValue<0))return void(t._hoverValue=0);setTimeout(t._update,t._millisecondsPerFrame)}}}return Object.defineProperty(r.prototype,"name",{get:function(){return"FadeInOut"}
1608,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){this._hovered=t,this._update()},r.prototype._setAllVisibility=function(t,e){var n=this;t.visibility=e,t.getChildMeshes().forEach(function(i){n._setAllVisibility(i,e)})},r}(),bi=f(65),np=function(){function r(){this._startDistance=0,this._initialScale=new u.e(0,0,0),this._targetScale=new u.e(0,0,0),this._sceneRenderObserver=null,this._dragBehaviorA=new bi.a({}),this._dragBehaviorA.moveAttached=!1,this._dragBehaviorB=new bi.a({}),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(n){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(n){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}(),Dt=f(31),gt=f(24),kn=f(60),Pl=function(){function r(){this._sceneRenderObserver=null,this._targetPosition=new u.e(0,0,0),this._moving=!1,this._startingOrientation=new u.b,this._attachedToElement=!1,this.zDragFactor=3,this.rotateDraggedObject=!0,this.dragging=!1,this.dragDeltaRatio=.2,this.currentDraggingPointerID=-1,this.detachCameraControls=!0,this.onDragStartObservable=new x.c,this.onDragObservable=new x.c,this.onDragEndObservable=new x.c}return Object.defineProperty(r.prototype,"name",{get:function(){return"SixDofDrag"},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.attach=function(t){var e=this;this._ownerNode=t,this._scene=this._ownerNode.getScene(),r._virtualScene||(r._virtualScene=new _e.a(this._scene.getEngine(),{virtual:!0}),r._virtualScene.detachControl(),this._scene.getEngine().scenes.pop());var n=null,i=new u.e(0,0,0);this._virtualOriginMesh=new Dt.a("",r._virtualScene),this._virtualOriginMesh.rotationQuaternion=new u.b,this._virtualDragMesh=new Dt.a("",r._virtualScene),this._virtualDragMesh.rotationQuaternion=new u.b,this._pointerObserver=this._scene.onPointerObservable.add(function(a,s){if(a.type==Tt.a.POINTERDOWN){if(!e.dragging&&a.pickInfo&&a.pickInfo.hit&&a.pickInfo.pickedMesh&&a.pickInfo.ray&&(O=a.pickInfo.pickedMesh,e._ownerNode==O||O.isDescendantOf(e._ownerNode))){e._pointerCamera&&e._pointerCamera.cameraRigMode==gt.a.RIG_MODE_NONE&&a.pickInfo.ray.origin.copyFrom(e._pointerCamera.globalPosition),n=e._ownerNode,kn.a._RemoveAndStorePivotPoint(n),i.copyFrom(a.pickInfo.ray.origin),e._virtualOriginMesh.position.copyFrom(a.pickInfo.ray.origin),e._virtualOriginMesh.lookAt(a.pickInfo.ray.origin.add(a.pickInfo.ray.direction)),e._virtualOriginMesh.removeChild(e._virtualDragMesh),n.computeWorldMatrix(),e._virtualDragMesh.position.copyFrom(n.absolutePosition),n.rotationQuaternion||(n.rotationQuaternion=u.b.RotationYawPitchRoll(n.rotation.y,n.rotation.x,n.rotation.z));var d=n.parent;n.setParent(null),e._virtualDragMesh.rotationQuaternion.copyFrom(n.rotationQuaternion),n.setParent(d),e._virtualOriginMesh.addChild(e._virtualDragMesh),e._targetPosition.copyFrom(e._virtualDragMesh.absolutePosition),e.dragging=!0,e.currentDraggingPointerID=a.event.pointerId,e.detachCameraControls&&e._pointerCamera&&!e._pointerCamera.leftCamera&&(e._pointerCamera.inputs.attachedToElement?(e._pointerCamera.detachControl(),e._attachedToElement=!0):e._attachedToElement=!1),kn.a._RestorePivotPoint(n),e.onDragStartObservable.notifyObservers({})}}else if(a.type==Tt.a.POINTERUP||a.type==Tt.a.POINTERDOUBLETAP)e.currentDraggingPointerID==a.event.pointerId&&(e.dragging=!1,e._moving=!1,e.currentDraggingPointerID=-1,n=null,e._virtualOriginMesh.removeChild(e._virtualDragMesh),e.detachCameraControls&&e._attachedToElement&&e._pointerCamera&&!e._pointerCamera.leftCamera&&(e._pointerCamera.attachControl(!0),e._attachedToElement=!1),e.onDragEndObservable.notifyObservers({}));else if(a.type==Tt.a.POINTERMOVE&&e.currentDraggingPointerID==a.event.pointerId&&e.dragging&&a.pickInfo&&a.pickInfo.ray&&n){var p=e.zDragFactor;e._pointerCamera&&e._pointerCamera.cameraRigMode==gt.a.RIG_MODE_NONE&&(a.pickInfo.ray.origin.copyFrom(e._pointerCamera.globalPosition),p=0);var y=a.pickInfo.ray.origin.subtract(i);i.copyFrom(a.pickInfo.ray.origin);var P=-u.e.Dot(y,a.pickInfo.ray.direction);e._virtualOriginMesh.addChild(e._virtualDragMesh),e._virtualDragMesh.position.z-=e._virtualDragMesh.position.z<1?P*e.zDragFactor:P*p*e._virtualDragMesh.position.z,e._virtualDragMesh.position.z<0&&(e._virtualDragMesh.position.z=0),e._virtualOriginMesh.position.copyFrom(a.pickInfo.ray.origin),e._virtualOriginMesh.lookAt(a.pickInfo.ray.origin.add(a.pickInfo.ray.direction)),e._virtualOriginMesh.removeChild(e._virtualDragMesh),e._targetPosition.copyFrom(e._virtualDragMesh.absolutePosition),n.parent&&u.e.TransformCoordinatesToRef(e._targetPosition,u.a.Invert(n.parent.getWorldMatrix()),e._targetPosition),e._mov
1608ing||e._startingOrientation.copyFrom(e._virtualDragMesh.rotationQuaternion),e._moving=!0}var O});var o=new u.b;this._sceneRenderObserver=t.getScene().onBeforeRenderObservable.add(function(){if(e.dragging&&e._moving&&n){if(kn.a._RemoveAndStorePivotPoint(n),n.position.addInPlace(e._targetPosition.subtract(n.position).scale(e.dragDeltaRatio)),e.rotateDraggedObject){o.copyFrom(e._startingOrientation),o.x=-o.x,o.y=-o.y,o.z=-o.z,e._virtualDragMesh.rotationQuaternion.multiplyToRef(o,o),u.b.RotationYawPitchRollToRef(o.toEulerAngles("xyz").y,0,0,o),o.multiplyToRef(e._startingOrientation,o);var a=n.parent;(!a||a.scaling&&!a.scaling.isNonUniformWithinEpsilon(.001))&&(n.setParent(null),u.b.SlerpToRef(n.rotationQuaternion,o,e.dragDeltaRatio,n.rotationQuaternion),n.setParent(a))}kn.a._RestorePivotPoint(n),e.onDragObservable.notifyObservers()}})},r.prototype.detach=function(){this._scene&&(this.detachCameraControls&&this._attachedToElement&&this._pointerCamera&&!this._pointerCamera.leftCamera&&(this._pointerCamera.attachControl(!0),this._attachedToElement=!1),this._scene.onPointerObservable.remove(this._pointerObserver)),this._ownerNode&&this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver),this._virtualOriginMesh&&this._virtualOriginMesh.dispose(),this._virtualDragMesh&&this._virtualDragMesh.dispose(),this.onDragEndObservable.clear(),this.onDragObservable.clear(),this.onDragStartObservable.clear()},r}(),ip=function(){function r(t,e,n){if(this.targetPosition=u.e.Zero(),this.poleTargetPosition=u.e.Zero(),this.poleTargetLocalOffset=u.e.Zero(),this.poleAngle=0,this.slerpAmount=1,this._bone1Quat=u.b.Identity(),this._bone1Mat=u.a.Identity(),this._bone2Ang=Math.PI,this._maxAngle=Math.PI,this._rightHandedSystem=!1,this._bendAxis=u.e.Right(),this._slerping=!1,this._adjustRoll=0,this._bone2=e,this._bone1=e.getParent(),this._bone1){this.mesh=t;var i=e.getPosition();if(e.getAbsoluteTransform().determinant()>0&&(this._rightHandedSystem=!0,this._bendAxis.x=0,this._bendAxis.y=0,this._bendAxis.z=-1,i.x>i.y&&i.x>i.z&&(this._adjustRoll=.5*Math.PI,this._bendAxis.z=1)),this._bone1.length){var o=this._bone1.getScale(),a=this._bone2.getScale();this._bone1Length=this._bone1.length*o.y*this.mesh.scaling.y,this._bone2Length=this._bone2.length*a.y*this.mesh.scaling.y}else if(this._bone1.children[0]){t.computeWorldMatrix(!0);var s=this._bone2.children[0].getAbsolutePosition(t),d=this._bone2.getAbsolutePosition(t),p=this._bone1.getAbsolutePosition(t);this._bone1Length=u.e.Distance(s,d),this._bone2Length=u.e.Distance(d,p)}this._bone1.getRotationMatrixToRef(ye.c.WORLD,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(){var t=this._bone1;if(t){var e=this.targetPosition,n=this.poleTargetPosition,i=r._tmpMats[0],o=r._tmpMats[1];this.targetMesh&&e.copyFrom(this.targetMesh.getAbsolutePosition()),this.poleTargetBone?this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset,this.mesh,n):this.poleTargetMesh&&u.e.TransformCoordinatesToRef(this.poleTargetLocalOffset,this.poleTargetMesh.getWorldMatrix(),n);var a=r._tmpVecs[0],s=r._tmpVecs[1],d=r._tmpVecs[2],p=r._tmpVecs[3],y=r._tmpVecs[4],P=r._tmpQuat;t.getAbsolutePositionToRef(this.mesh,a),n.subtractToRef(a,y),y.x==0&&y.y==0&&y.z==0?y.y=1:y.normalize(),e.subtractToRef(a,p),p.normalize(),u.e.CrossToRef(p,y,s),s.normalize(),u.e.CrossToRef(p,s,d),d.normalize(),u.a.FromXYZAxesToRef(d,p,s,i);var O=this._bone1Length,U=this._bone2Length,F=u.e.Distance(a,e);this._maxReach>0&&(F=Math.min(this._maxReach,F));var z=(U*U+F*F-O*O)/(2*U*F),J=(F*F+O*O-U*U)/(2*F*O);z>1&&(z=1),J>1&&(J=1),z<-1&&(z=-1),J<-1&&(J=-1);var ie=Math.acos(z),se=Math.acos(J),ce=-ie-se;if(this._rightHandedSystem)u.a.RotationYawPitchRollToRef(0,0,this._adjustRoll,o),o.multiplyToRef(i,i),u.a.RotationAxisToRef(this._bendAxis,se,o),o.multiplyToRef(i,i);else{var ue=r._tmpVecs[5];ue.copyFrom(this._bendAxis),ue.x*=-1,u.a.RotationAxisToRef(ue,-se,o),o.multiplyToRef(i,i)}this.poleAngle&&(u.a.RotationAxisToRef(p,this.poleAngle,o),i.multiplyToRef(o,i)),this._bone1&&(this.slerpAmount<1?(this._slerping||u.b.FromRotationMatrixToRef(this._bone1Mat,this._bone1Quat),u.b.FromRotationMatrixToRef(i,P),u.b.SlerpToRef(this._bone1Quat,P,this.slerpAmount,this._bone1Quat),
1608ce=this._bone2Ang*(1-this.slerpAmount)+ce*this.slerpAmount,this._bone1.setRotationQuaternion(this._bone1Quat,ye.c.WORLD,this.mesh),this._slerping=!0):(this._bone1.setRotationMatrix(i,ye.c.WORLD,this.mesh),this._bone1Mat.copyFrom(i),this._slerping=!1)),this._bone2.setAxisAngle(this._bendAxis,ce,ye.c.LOCAL),this._bone2Ang=ce}},r._tmpVecs=[u.e.Zero(),u.e.Zero(),u.e.Zero(),u.e.Zero(),u.e.Zero(),u.e.Zero()],r._tmpQuat=u.b.Identity(),r._tmpMats=[u.a.Identity(),u.a.Identity()],r}(),rp=function(){function r(t,e,n,i){if(this.upAxis=u.e.Up(),this.upAxisSpace=ye.c.LOCAL,this.adjustYaw=0,this.adjustPitch=0,this.adjustRoll=0,this.slerpAmount=1,this._boneQuat=u.b.Identity(),this._slerping=!1,this._firstFrameSkipped=!1,this._fowardAxis=u.e.Forward(),this.mesh=t,this.bone=e,this.target=n,i&&(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=ye.a.Y,a=ye.a.X;i.yawAxis!=null&&(o=i.yawAxis.clone()).normalize(),i.pitchAxis!=null&&(a=i.pitchAxis.clone()).normalize();var s=u.e.Cross(a,o);this._transformYawPitch=u.a.Identity(),u.a.FromXYZAxesToRef(a,o,s,this._transformYawPitch),this._transformYawPitchInv=this._transformYawPitch.clone(),this._transformYawPitch.invert()}e.getParent()||this.upAxisSpace!=ye.c.BONE||(this.upAxisSpace=ye.c.LOCAL)}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(),d=r._tmpVecs[1];d.copyFrom(this.upAxis),this.upAxisSpace==ye.c.BONE&&s?(this._transformYawPitch&&u.e.TransformCoordinatesToRef(d,this._transformYawPitchInv,d),s.getDirectionToRef(d,this.mesh,d)):this.upAxisSpace==ye.c.LOCAL&&(a.getDirectionToRef(d,d),a.scaling.x==1&&a.scaling.y==1&&a.scaling.z==1||d.normalize());var p=!1,y=!1;if(this._maxYaw==Math.PI&&this._minYaw==-Math.PI||(p=!0),this._maxPitch==Math.PI&&this._minPitch==-Math.PI||(y=!0),p||y){var P=r._tmpMats[2],O=r._tmpMats[3];if(this.upAxisSpace==ye.c.BONE&&d.y==1&&s)s.getRotationMatrixToRef(ye.c.WORLD,this.mesh,P);else if(this.upAxisSpace!=ye.c.LOCAL||d.y!=1||s){(F=r._tmpVecs[2]).copyFrom(this._fowardAxis),this._transformYawPitch&&u.e.TransformCoordinatesToRef(F,this._transformYawPitchInv,F),s?s.getDirectionToRef(F,this.mesh,F):a.getDirectionToRef(F,F);var U=u.e.Cross(d,F);U.normalize();var F=u.e.Cross(U,d);u.a.FromXYZAxesToRef(U,d,F,P)}else P.copyFrom(a.getWorldMatrix());P.invertToRef(O);var z=null;if(y){var J=r._tmpVecs[3];n.subtractToRef(e,J),u.e.TransformCoordinatesToRef(J,O,J),z=Math.sqrt(J.x*J.x+J.z*J.z);var ie=Math.atan2(J.y,z),se=ie;ie>this._maxPitch?(J.y=this._maxPitchTan*z,se=this._maxPitch):ie<this._minPitch&&(J.y=this._minPitchTan*z,se=this._minPitch),ie!=se&&(u.e.TransformCoordinatesToRef(J,P,J),J.addInPlace(e),n=J)}if(p){J=r._tmpVecs[4],n.subtractToRef(e,J),u.e.TransformCoordinatesToRef(J,O,J);var ce=Math.atan2(J.x,J.z),ue=ce;if((ce>this._maxYaw||ce<this._minYaw)&&(z==null&&(z=Math.sqrt(J.x*J.x+J.z*J.z)),this._yawRange>Math.PI?this._isAngleBetween(ce,this._maxYaw,this._midYawConstraint)?(J.z=this._maxYawCos*z,J.x=this._maxYawSin*z,ue=this._maxYaw):this._isAngleBetween(ce,this._midYawConstraint,this._minYaw)&&(J.z=this._minYawCos*z,J.x=this._minYawSin*z,ue=this._minYaw):ce>this._maxYaw?(J.z=this._maxYawCos*z,J.x=this._maxYawSin*z,ue=this._maxYaw):ce<this._minYaw&&(J.z=this._minYawCos*z,J.x=this._minYawSin*z,ue=this._minYaw)),this._slerping&&this._yawRange>Math.PI){var fe=r._tmpVecs[8];fe.copyFrom(ye.a.Z),this._transformYawPitch&&u.e.TransformCoordinatesToRef(fe,this._transformYawPitchInv,fe);var ve=r._tmpMats[4];this._boneQuat.toRotationMatrix(ve),this.mesh.getWorldMatrix().multiplyToRef(ve,ve),u.e.TransformCoordinatesToRef(fe,ve,fe),u.e.TransformCoordinatesToRef(fe,O,fe);var Te=Math.atan2(fe.x,fe.z);
1608if(this._getAngleBetween(Te,ce)>this._getAngleBetween(Te,this._midYawConstraint)){z==null&&(z=Math.sqrt(J.x*J.x+J.z*J.z));var Oe=this._getAngleBetween(Te,this._maxYaw);this._getAngleBetween(Te,this._minYaw)<Oe?(ue=Te+.75*Math.PI,J.z=Math.cos(ue)*z,J.x=Math.sin(ue)*z):(ue=Te-.75*Math.PI,J.z=Math.cos(ue)*z,J.x=Math.sin(ue)*z)}}ce!=ue&&(u.e.TransformCoordinatesToRef(J,P,J),J.addInPlace(e),n=J)}}var Pe=r._tmpVecs[5],Ee=r._tmpVecs[6],Se=r._tmpVecs[7],Le=r._tmpQuat;n.subtractToRef(e,Pe),Pe.normalize(),u.e.CrossToRef(d,Pe,Ee),Ee.normalize(),u.e.CrossToRef(Pe,Ee,Se),Se.normalize(),u.a.FromXYZAxesToRef(Ee,Se,Pe,i),Ee.x===0&&Ee.y===0&&Ee.z===0||Se.x===0&&Se.y===0&&Se.z===0||Pe.x===0&&Pe.y===0&&Pe.z===0||((this.adjustYaw||this.adjustPitch||this.adjustRoll)&&(u.a.RotationYawPitchRollToRef(this.adjustYaw,this.adjustPitch,this.adjustRoll,o),o.multiplyToRef(i,i)),this.slerpAmount<1?(this._slerping||this.bone.getRotationQuaternionToRef(ye.c.WORLD,this.mesh,this._boneQuat),this._transformYawPitch&&this._transformYawPitch.multiplyToRef(i,i),u.b.FromRotationMatrixToRef(i,Le),u.b.SlerpToRef(this._boneQuat,Le,this.slerpAmount,this._boneQuat),this.bone.setRotationQuaternion(this._boneQuat,ye.c.WORLD,this.mesh),this._slerping=!0):(this._transformYawPitch&&this._transformYawPitch.multiplyToRef(i,i),this.bone.setRotationMatrix(i,ye.c.WORLD,this.mesh),this._slerping=!1))}},r.prototype._getAngleDiff=function(t,e){var n=e-t;return(n%=2*Math.PI)>Math.PI?n-=2*Math.PI:n<-Math.PI&&(n+=2*Math.PI),n},r.prototype._getAngleBetween=function(t,e){var n=0;return(n=(t=(t%=2*Math.PI)<0?t+2*Math.PI:t)<(e=(e%=2*Math.PI)<0?e+2*Math.PI:e)?e-t:t-e)>Math.PI&&(n=2*Math.PI-n),n},r.prototype._isAngleBetween=function(t,e,n){if(t=(t%=2*Math.PI)<0?t+2*Math.PI:t,(e=(e%=2*Math.PI)<0?e+2*Math.PI:e)<(n=(n%=2*Math.PI)<0?n+2*Math.PI:n)){if(t>e&&t<n)return!0}else if(t>n&&t<e)return!0;return!1},r._tmpVecs=Ce.a.BuildArray(10,u.e.Zero),r._tmpQuat=u.b.Identity(),r._tmpMats=Ce.a.BuildArray(5,u.a.Identity),r}(),we=f(10),xt=f(27),Bt=f(26);function Cl(r,t,e,n){var i;i=n===h.a.TEXTURETYPE_FLOAT?new Float32Array(t*e*4):new Uint32Array(t*e*4);for(var o=0;o<t;o++)for(var a=0;a<e;a++){var s=3*(a*t+o),d=4*(a*t+o);i[d+0]=r[s+0],i[d+1]=r[s+1],i[d+2]=r[s+2],i[d+3]=1}return i}function xl(r){return function(t,e,n,i,o,a,s,d,p,y){p===void 0&&(p=null),y===void 0&&(y=h.a.TEXTURETYPE_UNSIGNED_INT);var P=r?this._gl.TEXTURE_3D:this._gl.TEXTURE_2D_ARRAY,O=r?xt.b.Raw3D:xt.b.Raw2DArray,U=new xt.a(this,O);U.baseWidth=e,U.baseHeight=n,U.baseDepth=i,U.width=e,U.height=n,U.depth=i,U.format=o,U.type=y,U.generateMipMaps=a,U.samplingMode=d,r?U.is3D=!0:U.is2DArray=!0,this._doNotHandleContextLost||(U._bufferView=t),r?this.updateRawTexture3D(U,t,o,s,p,y):this.updateRawTexture2DArray(U,t,o,s,p,y),this._bindTextureDirectly(P,U,!0);var F=this._getSamplingParameters(d,a);return this._gl.texParameteri(P,this._gl.TEXTURE_MAG_FILTER,F.mag),this._gl.texParameteri(P,this._gl.TEXTURE_MIN_FILTER,F.min),a&&this._gl.generateMipmap(P),this._bindTextureDirectly(P,null),this._internalTexturesCache.push(U),U}}function Rl(r){return function(t,e,n,i,o,a){o===void 0&&(o=null),a===void 0&&(a=h.a.TEXTURETYPE_UNSIGNED_INT);var s=r?this._gl.TEXTURE_3D:this._gl.TEXTURE_2D_ARRAY,d=this._getWebGLTextureType(a),p=this._getInternalFormat(n),y=this._getRGBABufferInternalSizedFormat(a,n);this._bindTextureDirectly(s,t,!0),this._unpackFlipY(i===void 0||!!i),this._doNotHandleContextLost||(t._bufferView=e,t.format=n,t.invertY=i,t._compression=o),t.width%4!=0&&this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT,1),o&&e?this._gl.compressedTexImage3D(s,0,this.getCaps().s3tc[o],t.width,t.height,t.depth,0,e):this._gl.texImage3D(s,0,y,t.width,t.height,t.depth,0,p,d,e),t.generateMipMaps&&this._gl.generateMipmap(s),this._bindTextureDirectly(s,null),t.isReady=!0}}Bt.a.prototype.updateRawTexture=function(r,t,e,n,i,o){if(i===void 0&&(i=null),o===void 0&&(o=h.a.TEXTURETYPE_UNSIGNED_INT),r){var a=this._getRGBABufferInternalSizedFormat(o,e),s=this._getInternalFormat(e),d=this._getWebGLTextureType(o);this._bindTextureDirectly(this._gl.TEXTURE_2D,r,!0),this._unpackFlipY(n===void 0||!!n),this._doNotHandleContextLost||(r._bufferView=t,r.format=e,r.type=o,r.invertY=n,r._compression=i),r.width%4!=0&&this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT,1),i&&t?this._gl.compressedTexImage2D(this._gl.TEXTURE_2D,0,this.getCaps().s3tc[i],r.width,r.height,0,t):this._gl.texImage2D(this._gl.TEXTURE_2D,0,a,r.width,r.height,0,s,d,t),r.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),r.isReady=!0}},Bt.a.prototype.createRawTexture=function(r,t,e,n,i,o,a,s,d){s===void 0&&(s=null),d===void 0&&(d=h.a.TEXTURETYPE_UNSIGNED_INT);var p=new xt.a(this,xt.b.Raw);p.baseWidth=t,p.baseHeight=e,p.width=t,p.height=e,p.format=n,p.generateMipMaps=i,p.samplingMode=a,p.invertY=o,p._compression=s,p.type=d,this._doNotHandleContextLost||(p._bufferView=r),this.updateRawTexture(p,r,n,o,s,d),this._bindTextureDirectly(this._gl.TEXTURE_2D,p,!0);var y=this._getSamplingParameters(a,i);return this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,y.mag),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,y.min),i&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._internalTexturesCache.push(p),p},Bt.a.prototype.createRawCubeTexture=function(r,t,e,n,i,o,a,s){s===void 0&&(s=null);var d=this._gl,p=new xt.a(this,xt.b.CubeRaw);p.isCube=!0,p.format=e,p.type=n,this._doNotHandleContextLost||(p._bufferViewArray=r);var y=this._getWebGLTextureType(n),P=this._getInternalFormat(e);P===d.RGB&&(P=d.RGBA),y!==d.FLOAT||this._caps.textureFloatLinearFiltering?y!==this._gl.HALF_FLOAT_OES||this._caps.textureHalfFloatLinearFiltering?y!==d.FLOAT||this._caps.textureFloatRen
1608der?y!==d.HALF_FLOAT||this._caps.colorBufferFloat||(i=!1,l.a.Warn("Render to half float textures is not supported. Mipmap generation forced to false.")):(i=!1,l.a.Warn("Render to float textures is not supported. Mipmap generation forced to false.")):(i=!1,a=h.a.TEXTURE_NEAREST_SAMPLINGMODE,l.a.Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")):(i=!1,a=h.a.TEXTURE_NEAREST_SAMPLINGMODE,l.a.Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively."));var O=t,U=O;p.width=O,p.height=U,!this.needPOTTextures||Ye.b.IsExponentOfTwo(p.width)&&Ye.b.IsExponentOfTwo(p.height)||(i=!1),r&&this.updateRawCubeTexture(p,r,e,n,o,s),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,p,!0),r&&i&&this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);var F=this._getSamplingParameters(a,i);return d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_MAG_FILTER,F.mag),d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_MIN_FILTER,F.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),this._bindTextureDirectly(d.TEXTURE_CUBE_MAP,null),p.generateMipMaps=i,p},Bt.a.prototype.updateRawCubeTexture=function(r,t,e,n,i,o,a){o===void 0&&(o=null),a===void 0&&(a=0),r._bufferViewArray=t,r.format=e,r.type=n,r.invertY=i,r._compression=o;var s=this._gl,d=this._getWebGLTextureType(n),p=this._getInternalFormat(e),y=this._getRGBABufferInternalSizedFormat(n),P=!1;p===s.RGB&&(p=s.RGBA,P=!0),this._bindTextureDirectly(s.TEXTURE_CUBE_MAP,r,!0),this._unpackFlipY(i===void 0||!!i),r.width%4!=0&&s.pixelStorei(s.UNPACK_ALIGNMENT,1);for(var O=0;O<6;O++){var U=t[O];o?s.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+O,a,this.getCaps().s3tc[o],r.width,r.height,0,U):(P&&(U=Cl(U,r.width,r.height,n)),s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+O,a,y,r.width,r.height,0,p,d,U))}(!this.needPOTTextures||Ye.b.IsExponentOfTwo(r.width)&&Ye.b.IsExponentOfTwo(r.height))&&r.generateMipMaps&&a===0&&this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),r.isReady=!0},Bt.a.prototype.createRawCubeTextureFromUrl=function(r,t,e,n,i,o,a,s,d,p,y,P){var O=this;d===void 0&&(d=null),p===void 0&&(p=null),y===void 0&&(y=h.a.TEXTURE_TRILINEAR_SAMPLINGMODE),P===void 0&&(P=!1);var U=this._gl,F=this.createRawCubeTexture(null,e,n,i,!o,P,y,null);return t?._addPendingData(F),F.url=r,this._internalTexturesCache.push(F),this._loadFile(r,function(z){(function(J){var ie=F.width,se=a(J);if(se){if(s){var ce=O._getWebGLTextureType(i),ue=O._getInternalFormat(n),fe=O._getRGBABufferInternalSizedFormat(i),ve=!1;ue===U.RGB&&(ue=U.RGBA,ve=!0),O._bindTextureDirectly(U.TEXTURE_CUBE_MAP,F,!0),O._unpackFlipY(!1);for(var Te=s(se),Oe=0;Oe<Te.length;Oe++)for(var Pe=ie>>Oe,Ee=0;Ee<6;Ee++){var Se=Te[Oe][Ee];ve&&(Se=Cl(Se,Pe,Pe,i)),U.texImage2D(Ee,Oe,fe,Pe,Pe,0,ue,ce,Se)}O._bindTextureDirectly(U.TEXTURE_CUBE_MAP,null)}else O.updateRawCubeTexture(F,se,n,i,P);F.isReady=!0,t?._removePendingData(F),d&&d()}})(z)},void 0,t?.offlineProvider,!0,function(z,J){t?._removePendingData(F),p&&z&&p(z.status+" "+z.statusText,J)}),F},Bt.a.prototype.createRawTexture2DArray=xl(!1),Bt.a.prototype.createRawTexture3D=xl(!0),Bt.a.prototype.updateRawTexture2DArray=Rl(!1),Bt.a.prototype.updateRawTexture3D=Rl(!0);var $n=function(r){function t(e,n,i,o,a,s,d,p,y){s===void 0&&(s=!0),d===void 0&&(d=!1),p===void 0&&(p=h.a.TEXTURE_TRILINEAR_SAMPLINGMODE),y===void 0&&(y=h.a.TEXTURETYPE_UNSIGNED_INT);var P=r.call(this,null,a,!s,d)||this;return P.format=o,P._engine&&(P._texture=P._engine.createRawTexture(e,n,i,o,s,d,p,null,y),P.wrapU=we.a.CLAMP_ADDRESSMODE,P.wrapV=we.a.CLAMP_ADDRESSMODE),P}return Object(c.d)(t,r),t.prototype.update=function(e){this._getEngine().updateRawTexture(this._texture,e,this._texture.format,this._texture.invertY,null,this._texture.type)},t.CreateLuminanceTexture=function(e,n,i,o,a,s,d){return a===void 0&&(a=!0),s===void 0&&(s=!1),d===void 0&&(d=h.a.TEXTURE_TRILINEAR_SAMPLINGMODE),new t(e,n,i,h.a.TEXTUREFORMAT_LUMINANCE,o,a,s,d)},t.CreateLuminanceAlphaTexture=function(e,n,i,o,a,s,d){return a===void 0&&(a=!0),s===void 0&&(s=!1),d===void 0&&(d=h.a.TEXTURE_TRILINEAR_SAMPLINGMODE),new t(e,n,i,h.a.TEXTUREFORMAT_LUMINANCE_ALPHA,o,a,s,d)},t.CreateAlphaTexture=function(e,n,i,o,a,s,d){return a===void 0&&(a=!0),s===void 0&&(s=!1),d===void 0&&(d=h.a.TEXTURE_TRILINEAR_SAMPLINGMODE),new t(e,n,i,h.a.TEXTUREFORMAT_ALPHA,o,a,s,d)},t.CreateRGBTexture=function(e,n,i,o,a,s,d,p){return a===void 0&&(a=!0),s===void 0&&(s=!1),d===void 0&&(d=h.a.TEXTURE_TRILINEAR_SAMPLINGMODE),p===void 0&&(p=h.a.TEXTURETYPE_UNSIGNED_INT),new t(e,n,i,h.a.TEXTUREFORMAT_RGB,o,a,s,d,p)},t.CreateRGBATexture=function(e,n,i,o,a,s,d,p){return a===void 0&&(a=!0),s===void 0&&(s=!1),d===void 0&&(d=h.a.TEXTURE_TRILINEAR_SAMPLINGMODE),p===void 0&&(p=h.a.TEXTURETYPE_UNSIGNED_INT),new t(e,n,i,h.a.TEXTUREFORMAT_RGBA,o,a,s,d,p)},t.CreateRTexture=function(e,n,i,o,a,s,d,p){return a===void 0&&(a=!0),s===void 0&&(s=!1),d===void 0&&(d=we.a.TRILINEAR_SAMPLINGMODE),p===void 0&&(p=h.a.TEXTURETYPE_FLOAT),new t(e,n,i,h.a.TEXTUREFORMAT_R,o,a,s,d,p)},t}(we.a),Bo=function(){function r(t,e,n){this.name=t,this.id=e,this.bones=new Array,this.needInitialSkinMatrix=!1,this.overrideMesh=null,this._isDirty=!0,this._meshesWithPoseMatr
1608ix=new Array,this._identity=u.a.Identity(),this._ranges={},this._lastAbsoluteTransformsUpdateId=-1,this._canUseTextureForBones=!1,this._uniqueId=0,this._numBonesWithLinkedTransformNode=0,this._hasWaitingData=null,this._waitingOverrideMeshId=null,this.doNotSerialize=!1,this._useTextureToStoreBoneMatrices=!0,this._animationPropertiesOverride=null,this.onBeforeComputeObservable=new x.c,this.bones=[],this._scene=n||te.a.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){return this.needInitialSkinMatrix&&t._bonesTransformMatrices?t._bonesTransformMatrices:(this._transformMatrices||this.prepare(),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: "+this.name+", nBones: "+this.bones.length;if(e+=", nAnimationRanges: "+(this._ranges?Object.keys(this._ranges).length:"none"),t){e+=", Ranges: {";var n=!0;for(var i in this._ranges)n&&(e+=", ",n=!1),e+=i;e+="}"}return e},r.prototype.getBoneIndexByName=function(t){for(var e=0,n=this.bones.length;e<n;e++)if(this.bones[e].name===t)return e;return-1},r.prototype.createAnimationRange=function(t,e,n){if(!this._ranges[t]){this._ranges[t]=new G(t,e,n);for(var i=0,o=this.bones.length;i<o;i++)this.bones[i].animations[0]&&this.bones[i].animations[0].createRange(t,e,n)}},r.prototype.deleteAnimationRange=function(t,e){e===void 0&&(e=!0);for(var n=0,i=this.bones.length;n<i;n++)this.bones[n].animations[0]&&this.bones[n].animations[0].deleteRange(t,e);this._ranges[t]=null},r.prototype.getAnimationRange=function(t){return this._ranges[t]||null},r.prototype.getAnimationRanges=function(){var t,e=[];for(t in this._ranges)e.push(this._ranges[t]);return e},r.prototype.copyAnimationRange=function(t,e,n){if(n===void 0&&(n=!1),this._ranges[e]||!t.getAnimationRange(e))return!1;var i,o,a=!0,s=this._getHighestAnimationFrame()+1,d={},p=t.bones;for(o=0,i=p.length;o<i;o++)d[p[o].name]=p[o];this.bones.length!==p.length&&(l.a.Warn("copyAnimationRange: this rig has "+this.bones.length+" bones, while source as "+p.length),a=!1);var y=n&&this.dimensionsAtRest&&t.dimensionsAtRest?this.dimensionsAtRest.divide(t.dimensionsAtRest):null;for(o=0,i=this.bones.length;o<i;o++){var P=this.bones[o].name,O=d[P];O?a=a&&this.bones[o].copyAnimationRange(O,e,s,n,y):(l.a.Warn("copyAnimationRange: not same rig, missing source bone "+P),a=!1)}var U=t.getAnimationRange(e);return U&&(this._ranges[e]=new G(e,U.from+s,U.to+s)),a},r.prototype.returnToRest=function(){for(var t=u.c.Vector3[0],e=u.c.Quaternion[0],n=u.c.Vector3[1],i=0;i<this.bones.length;i++){var o=this.bones[i];o._index!==-1&&(o.returnToRest(),o._linkedTransformNode&&(o.getRestPose().decompose(t,e,n),o._linkedTransformNode.position=n.clone(),o._linkedTransformNode.rotationQuaternion=e.clone(),o._linkedTransformNode.scaling=t.clone()))}},r.prototype._getHighestAnimationFrame=function(){for(var t=0,e=0,n=this.bones.length;e<n;e++)if(this.bones[e].animations[0]){var i=this.bones[e].animations[0].getHighestFrame();t<i&&(t=i)}return t},r.prototype.beginAnimation=function(t,e,n,i){var o=this.getAnimationRange(t);return o?this._scene.beginAnimation(this,o.from,o.to,e,n,i):null},r.MakeAnimationAdditive=function(t,e,n){e===void 0&&(e=0);var i=t.getAnimationRange(n);if(!i)return null;for(var o=t._scene.getAllAnimatablesByTarget(t),a=null,s=0;s<o.length;s++){var d=o[s];if(d.fromFrame===i?.from&&d.toFrame===i?.to){a=d;break}}var p=t.getAnimatables();for(s=0;s<p.length;s++){var y=p[s].animations;if(y)for(var P=0;P<y.length;P++)k.MakeAnimationAdditive(y[P],e,n)}return a&&(a.isAdditive=!0),t},r.prototype._markAsDirty=function(){this._isDirty=!0}
1608,r.prototype._registerMeshWithPoseMatrix=function(t){this._meshesWithPoseMatrix.push(t)},r.prototype._unregisterMeshWithPoseMatrix=function(t){var e=this._meshesWithPoseMatrix.indexOf(t);e>-1&&this._meshesWithPoseMatrix.splice(e,1)},r.prototype._computeTransformMatrices=function(t,e){this.onBeforeComputeObservable.notifyObservers(this);for(var n=0;n<this.bones.length;n++){var i=this.bones[n];i._childUpdateId++;var o=i.getParent();if(o?i.getLocalMatrix().multiplyToRef(o.getWorldMatrix(),i.getWorldMatrix()):e?i.getLocalMatrix().multiplyToRef(e,i.getWorldMatrix()):i.getWorldMatrix().copyFrom(i.getLocalMatrix()),i._index!==-1){var a=i._index===null?n:i._index;i.getInvertedAbsoluteTransform().multiplyToArray(i.getWorldMatrix(),t,16*a)}}this._identity.copyToArray(t,16*this.bones.length)},r.prototype.prepare=function(){if(this._numBonesWithLinkedTransformNode>0)for(var t=0,e=this.bones;t<e.length;t++){var n=e[t];n._linkedTransformNode&&(n._linkedTransformNode.computeWorldMatrix(),n._matrix=n._linkedTransformNode._localMatrix,n.markAsDirty())}if(this._isDirty){if(this.needInitialSkinMatrix)for(var i=0;i<this._meshesWithPoseMatrix.length;i++){var o=this._meshesWithPoseMatrix[i],a=o.getPoseMatrix();if(o._bonesTransformMatrices&&o._bonesTransformMatrices.length===16*(this.bones.length+1)||(o._bonesTransformMatrices=new Float32Array(16*(this.bones.length+1))),this._synchronizedWithMesh!==o){this._synchronizedWithMesh=o;for(var s=0;s<this.bones.length;s++){var d=this.bones[s];d.getParent()||(d.getBaseMatrix().multiplyToRef(a,u.c.Matrix[1]),d._updateDifferenceMatrix(u.c.Matrix[1]))}if(this.isUsingTextureForMatrices){var p=4*(this.bones.length+1);o._transformMatrixTexture&&o._transformMatrixTexture.getSize().width===p||(o._transformMatrixTexture&&o._transformMatrixTexture.dispose(),o._transformMatrixTexture=$n.CreateRGBATexture(o._bonesTransformMatrices,4*(this.bones.length+1),1,this._scene,!1,!1,h.a.TEXTURE_NEAREST_SAMPLINGMODE,h.a.TEXTURETYPE_FLOAT))}}this._computeTransformMatrices(o._bonesTransformMatrices,a),this.isUsingTextureForMatrices&&o._transformMatrixTexture&&o._transformMatrixTexture.update(o._bonesTransformMatrices)}else this._transformMatrices&&this._transformMatrices.length===16*(this.bones.length+1)||(this._transformMatrices=new Float32Array(16*(this.bones.length+1)),this.isUsingTextureForMatrices&&(this._transformMatrixTexture&&this._transformMatrixTexture.dispose(),this._transformMatrixTexture=$n.CreateRGBATexture(this._transformMatrices,4*(this.bones.length+1),1,this._scene,!1,!1,h.a.TEXTURE_NEAREST_SAMPLINGMODE,h.a.TEXTURETYPE_FLOAT))),this._computeTransformMatrices(this._transformMatrices,null),this.isUsingTextureForMatrices&&this._transformMatrixTexture&&this._transformMatrixTexture.update(this._transformMatrices);this._isDirty=!1,this._scene._activeBones.addCount(this.bones.length,!1)}},r.prototype.getAnimatables=function(){if(!this._animatables||this._animatables.length!==this.bones.length){this._animatables=[];for(var t=0;t<this.bones.length;t++)this._animatables.push(this.bones[t])}return this._animatables},r.prototype.clone=function(t,e){var n=new r(t,e||t,this._scene);n.needInitialSkinMatrix=this.needInitialSkinMatrix,n.overrideMesh=this.overrideMesh;for(var i=0;i<this.bones.length;i++){var o=this.bones[i],a=null,s=o.getParent();if(s){var d=this.bones.indexOf(s);a=n.bones[d]}var p=new Be(o.name,n,a,o.getBaseMatrix().clone(),o.getRestPose().clone());p._index=o._index,o._linkedTransformNode&&p.linkTransformNode(o._linkedTransformNode),de.a.DeepCopy(o.animations,p.animations)}if(this._ranges)for(var y in n._ranges={},this._ranges){var P=this._ranges[y];P&&(n._ranges[y]=P.clone())}return this._isDirty=!0,n},r.prototype.enableBlending=function(t){t===void 0&&(t=.01),this.bones.forEach(function(e){e.animations.forEach(function(n){n.enableBlending=!0,n.blendingSpeed=t})})},r.prototype.dispose=function(){this._meshesWithPoseMatrix=[],this.getScene().stopAnimation(this),this.getScene().removeSkeleton(this),this._transformMatrixTexture&&(this._transformMatrixTexture.dispose(),this._transformMatrixTexture=null)},r.prototype.serialize=function(){var t,e,n={};n.name=this.name,n.id=this.id,this.dimensionsAtRest&&(n.dimensionsAtRest=this.dimensionsAtRest.asArray()),n.bones=[],n.needInitialSkinMatrix=this.needInitialSkinMatrix,n.overrideMeshId=(t=this.overrideMesh)===null||t===void 0?void 0:t.id;for(var i=0;i<this.bones.length;i++){var o=this.bones[i],a=o.getParent(),s={parentBoneIndex:a?this.bones.indexOf(a):-1,index:o.getIndex(),name:o.name,matrix:o.getBaseMatrix().toArray(),rest:o.getRestPose().toArray(),linkedTransformNodeId:(e=o.getTransformNode())===null||e===void 0?void 0:e.id};for(var d in n.bones.push(s),o.length&&(s.length=o.length),o.metadata&&(s.metadata=o.metadata),o.animations&&o.animations.length>0&&(s.animation=o.animations[0].serialize()),n.ranges=[],this._ranges){var p=this._ranges[d];if(p){var y={};y.name=d,y.from=p.from,y.to=p.to,n.ranges.push(y)}}}return n},r.Parse=function(t,e){var n,i=new r(t.name,t.id,e);for(t.dimensionsAtRest&&(i.dimensionsAtRest=u.e.FromArray(t.dimensionsAtRest)),i.needInitialSkinMatrix=t.needInitialSkinMatrix,t.overrideMeshId&&(i._hasWaitingData=!0,i._waitingOverrideMeshId=t.overrideMeshId),n=0;n<t.bones.length;n++){var o=t.bones[n],a=t.bones[n].index,s=null;o.parentBoneIndex>-1&&(s=i.bones[o.parentBoneIndex]);var d=o.rest?u.a.FromArray(o.rest):null,p=new Be(o.name,i,s,u.a.FromArray(o.matrix),d,null,a);o.id!==void 0&&o.id!==null&&(p.id=o.id),o.length&&(p.length=o.length),o.metadata&&(p.metadata=o.metadata),o.animation&&p.animations.push(k.Parse(o.animation)),o.linkedTransformNodeId!==void 0&&o.linkedTransformNodeId!==null&&(i._hasWaitingData=!0,p._waitingTransformNodeId=o.linkedTransformNodeId)}if(t.ranges)for(n=0;n<t.ranges.length;n++){var y=t.ranges[n];i.createAnimationRange(y.name,y.from,y.to)}return i},r.prototype.computeAbsoluteTransforms=function(t){t===void 0&&(t=!1);var e=this._scene.getRenderId();(this._lastAbsoluteTransformsUpdateId!=e||t)&&(this.bones[0].computeAbsoluteTransforms(),this._lastAbsoluteTransformsUpdateId=e)},r.prototype.getPoseMatrix=function(){var t=null;
1608return this._meshesWithPoseMatrix.length>0&&(t=this._meshesWithPoseMatrix[0].getPoseMatrix()),t},r.prototype.sortBones=function(){for(var t=new Array,e=new Array(this.bones.length),n=0;n<this.bones.length;n++)this._sortBones(n,t,e);this.bones=t},r.prototype._sortBones=function(t,e,n){if(!n[t]){n[t]=!0;var i=this.bones[t];i._index===void 0&&(i._index=t);var o=i.getParent();o&&this._sortBones(this.bones.indexOf(o),e,n),e.push(i)}},r.prototype.setCurrentPoseAsRest=function(){this.bones.forEach(function(t){t.setCurrentPoseAsRest()})},r}(),un={},Jr=function(){function r(t){this.attachedToElement=!1,this.attached={},this.camera=t,this.checkInputs=function(){}}return r.prototype.add=function(t){var e=t.getSimpleName();this.attached[e]?l.a.Warn("camera input of type "+e+" already exists on camera"):(this.attached[e]=t,t.camera=this.camera,t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t))),this.attachedToElement&&t.attachControl())},r.prototype.remove=function(t){for(var e in this.attached){var n=this.attached[e];n===t&&(n.detachControl(),n.camera=null,delete this.attached[e],this.rebuildInputCheck())}},r.prototype.removeByType=function(t){for(var e in this.attached){var n=this.attached[e];n.getClassName()===t&&(n.detachControl(),n.camera=null,delete this.attached[e],this.rebuildInputCheck())}},r.prototype._addCheckInputs=function(t){var e=this.checkInputs;return function(){e(),t()}},r.prototype.attachInput=function(t){this.attachedToElement&&t.attachControl(this.noPreventDefault)},r.prototype.attachElement=function(t){if(t===void 0&&(t=!1),!this.attachedToElement)for(var e in t=!gt.a.ForceAttachControlToAlwaysPreventDefault&&t,this.attachedToElement=!0,this.noPreventDefault=t,this.attached)this.attached[e].attachControl(t)},r.prototype.detachElement=function(t){for(var e in t===void 0&&(t=!1),this.attached)this.attached[e].detachControl(),t&&(this.attached[e].camera=null);this.attachedToElement=!1},r.prototype.rebuildInputCheck=function(){for(var t in this.checkInputs=function(){},this.attached){var e=this.attached[t];e.checkInputs&&(this.checkInputs=this._addCheckInputs(e.checkInputs.bind(e)))}},r.prototype.clear=function(){this.attachedToElement&&this.detachElement(!0),this.attached={},this.attachedToElement=!1,this.checkInputs=function(){}},r.prototype.serialize=function(t){var e={};for(var n in this.attached){var i=this.attached[n],o=L.a.Serialize(i);e[i.getClassName()]=o}t.inputsmgr=e},r.prototype.parse=function(t){var e=t.inputsmgr;if(e){for(var n in this.clear(),e)if(a=un[n]){var i=e[n],o=L.a.Parse(function(){return new a},i,null);this.add(o)}}else for(var n in this.attached){var a;(a=un[this.attached[n].getClassName()])&&(o=L.a.Parse(function(){return new a},t,null),this.remove(this.attached[n]),this.add(o))}},r}(),op=function(r,t){this.x=r,this.y=t},hn=function(){function r(t,e,n,i,o,a,s){i===void 0&&(i=0),o===void 0&&(o=1),a===void 0&&(a=2),s===void 0&&(s=3),this.id=t,this.index=e,this.browserGamepad=n,this._leftStick={x:0,y:0},this._rightStick={x:0,y:0},this._isConnected=!0,this._invertLeftStickY=!1,this.type=r.GAMEPAD,this._leftStickAxisX=i,this._leftStickAxisY=o,this._rightStickAxisX=a,this._rightStickAxisY=s,this.browserGamepad.axes.length>=2&&(this._leftStick={x:this.browserGamepad.axes[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]}),this.browserGamepad.axes.length>=4&&(this._rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})}return Object.defineProperty(r.prototype,"isConnected",{get:function(){return this._isConnected},enumerable:!1,configurable:!0}),r.prototype.onleftstickchanged=function(t){this._onleftstickchanged=t},r.prototype.onrightstickchanged=function(t){this._onrightstickchanged=t},Object.defineProperty(r.prototype,"leftStick",{get:function(){return this._leftStick},set:function(t){!this._onleftstickchanged||this._leftStick.x===t.x&&this._leftStick.y===t.y||this._onleftstickchanged(t),this._leftStick=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"rightStick",{get:function(){return this._rightStick},set:function(t){!this._onrightstickchanged||this._rightStick.x===t.x&&this._rightStick.y===t.y||this._onrightstickchanged(t),this._rightStick=t}
1608,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}(),Ol=function(r){function t(e,n,i){var o=r.call(this,e,n,i)||this;return o.onButtonDownObservable=new x.c,o.onButtonUpObservable=new x.c,o.type=hn.GENERIC,o._buttons=new Array(i.buttons.length),o}return Object(c.d)(t,r),t.prototype.onbuttondown=function(e){this._onbuttondown=e},t.prototype.onbuttonup=function(e){this._onbuttonup=e},t.prototype._setButtonValue=function(e,n,i){return e!==n&&(e===1&&(this._onbuttondown&&this._onbuttondown(i),this.onButtonDownObservable.notifyObservers(i)),e===0&&(this._onbuttonup&&this._onbuttonup(i),this.onButtonUpObservable.notifyObservers(i))),e},t.prototype.update=function(){r.prototype.update.call(this);for(var e=0;e<this._buttons.length;e++)this._buttons[e]=this._setButtonValue(this.browserGamepad.buttons[e].value,this._buttons[e],e)},t.prototype.dispose=function(){r.prototype.dispose.call(this),this.onButtonDownObservable.clear(),this.onButtonUpObservable.clear()},t}(hn),Ka=function(){function r(){this.gamepadRotationSensibility=80,this.gamepadMoveSensibility=40,this._yAxisScale=1}return Object.defineProperty(r.prototype,"invertYAxis",{get:function(){return this._yAxisScale!==1},set:function(t){this._yAxisScale=t?-1:1},enumerable:!1,configurable:!0}),r.prototype.attachControl=function(){var t=this,e=this.camera.getScene().gamepadManager;this._onGamepadConnectedObserver=e.onGamepadConnectedObservable.add(function(n){n.type!==hn.POSE_ENABLED&&(t.gamepad&&n.type!==hn.XBOX||(t.gamepad=n))}),this._onGamepadDisconnectedObserver=e.onGamepadDisconnectedObservable.add(function(n){t.gamepad===n&&(t.gamepad=null)}),this.gamepad=e.getGamepadByType(hn.XBOX)},r.prototype.detachControl=function(t){this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver),this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver),this.gamepad=null},r.prototype.checkInputs=function(){if(this.gamepad){var t=this.camera,e=this.gamepad.rightStick;if(e){if(e.x!=0){var n=e.x/this.gamepadRotationSensibility;n!=0&&Math.abs(n)>.005&&(t.inertialAlphaOffset+=n)}if(e.y!=0){var i=e.y/this.gamepadRotationSensibility*this._yAxisScale;i!=0&&Math.abs(i)>.005&&(t.inertialBetaOffset+=i)}}var o=this.gamepad.leftStick;if(o&&o.y!=0){var a=o.y/this.gamepadMoveSensibility;a!=0&&Math.abs(a)>.005&&(this.camera.inertialRadiusOffset-=a)}}},r.prototype.getClassName=function(){return"ArcRotateCameraGamepadInput"},r.prototype.getSimpleName=function(){return"gamepad"},Object(c.c)([Object(L.c)()],r.prototype,"gamepadRotationSensibility",void 0),Object(c.c)([Object(L.c)()],r.prototype,"gamepadMoveSensibility",void 0),r}();un.ArcRotateCameraGamepadInput=Ka;var qi=f(66),Qa=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=Ye.b.BackCompatCameraNoPreventDefault(arguments),this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add(function(){e._keys=[]}),this._onKeyboardObserver=this._scene.onKeyboardObservable.add(function(n){var i,o=n.event;o.metaKey||(n.type===qi.a.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.
1608keyCode)===-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(t){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=[]},r.prototype.checkInputs=function(){if(this._onKeyboardObserver)for(var t=this.camera,e=0;e<this._keys.length;e++){var n=this._keys[e];this.keysLeft.indexOf(n)!==-1?this._ctrlPressed&&this.camera._useCtrlForPanning?t.inertialPanningX-=1/this.panningSensibility:t.inertialAlphaOffset-=this.angularSpeed:this.keysUp.indexOf(n)!==-1?this._ctrlPressed&&this.camera._useCtrlForPanning?t.inertialPanningY+=1/this.panningSensibility:this._altPressed&&this.useAltToZoom?t.inertialRadiusOffset+=1/this.zoomingSensibility:t.inertialBetaOffset-=this.angularSpeed:this.keysRight.indexOf(n)!==-1?this._ctrlPressed&&this.camera._useCtrlForPanning?t.inertialPanningX+=1/this.panningSensibility:t.inertialAlphaOffset+=this.angularSpeed:this.keysDown.indexOf(n)!==-1?this._ctrlPressed&&this.camera._useCtrlForPanning?t.inertialPanningY-=1/this.panningSensibility:this._altPressed&&this.useAltToZoom?t.inertialRadiusOffset-=1/this.zoomingSensibility:t.inertialBetaOffset+=this.angularSpeed:this.keysReset.indexOf(n)!==-1&&t.useInputToRestoreState&&t.restoreState()}},r.prototype.getClassName=function(){return"ArcRotateCameraKeyboardMoveInput"},r.prototype.getSimpleName=function(){return"keyboard"}
1608,Object(c.c)([Object(L.c)()],r.prototype,"keysUp",void 0),Object(c.c)([Object(L.c)()],r.prototype,"keysDown",void 0),Object(c.c)([Object(L.c)()],r.prototype,"keysLeft",void 0),Object(c.c)([Object(L.c)()],r.prototype,"keysRight",void 0),Object(c.c)([Object(L.c)()],r.prototype,"keysReset",void 0),Object(c.c)([Object(L.c)()],r.prototype,"panningSensibility",void 0),Object(c.c)([Object(L.c)()],r.prototype,"zoomingSensibility",void 0),Object(c.c)([Object(L.c)()],r.prototype,"useAltToZoom",void 0),Object(c.c)([Object(L.c)()],r.prototype,"angularSpeed",void 0),r}();un.ArcRotateCameraKeyboardMoveInput=Qa;var qa=function(){function r(){this.wheelPrecision=3,this.wheelDeltaPercentage=0}return r.prototype.computeDeltaFromMouseWheelLegacyEvent=function(t,e){var n=.01*t*this.wheelDeltaPercentage*e;return t>0?n/(1+this.wheelDeltaPercentage):n*(1+this.wheelDeltaPercentage)},r.prototype.attachControl=function(t){var e=this;t=Ye.b.BackCompatCameraNoPreventDefault(arguments),this._wheel=function(n,i){if(n.type===Tt.a.POINTERWHEEL){var o=n.event,a=0,s=o,d=0;if(d=s.wheelDelta?s.wheelDelta:60*-(o.deltaY||o.detail),e.wheelDeltaPercentage){if((a=e.computeDeltaFromMouseWheelLegacyEvent(d,e.camera.radius))>0){for(var p=e.camera.radius,y=e.camera.inertialRadiusOffset+a,P=0;P<20&&Math.abs(y)>.001;P++)p-=y,y*=e.camera.inertia;p=$.a.Clamp(p,0,Number.MAX_VALUE),a=e.computeDeltaFromMouseWheelLegacyEvent(d,p)}}else a=d/(40*e.wheelPrecision);a&&(e.camera.inertialRadiusOffset+=a),o.preventDefault&&(t||o.preventDefault())}},this._observer=this.camera.getScene().onPointerObservable.add(this._wheel,Tt.a.POINTERWHEEL)},r.prototype.detachControl=function(t){this._observer&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,this._wheel=null)},r.prototype.getClassName=function(){return"ArcRotateCameraMouseWheelInput"},r.prototype.getSimpleName=function(){return"mousewheel"},Object(c.c)([Object(L.c)()],r.prototype,"wheelPrecision",void 0),Object(c.c)([Object(L.c)()],r.prototype,"wheelDeltaPercentage",void 0),r}();un.ArcRotateCameraMouseWheelInput=qa;var Ml=function(){function r(){this.buttons=[0,1,2]}return r.prototype.attachControl=function(t){var e=this;t=Ye.b.BackCompatCameraNoPreventDefault(arguments);var n=this.camera.getEngine(),i=n.getInputElement(),o=0,a=null;this.pointA=null,this.pointB=null,this._altKey=!1,this._ctrlKey=!1,this._metaKey=!1,this._shiftKey=!1,this._buttonsPressed=0,this._pointerInput=function(d,p){var y=d.event,P=y.pointerType==="touch";if(!n.isInVRExclusivePointerMode&&(d.type===Tt.a.POINTERMOVE||e.buttons.indexOf(y.button)!==-1)){var O=y.srcElement||y.target;if(e._altKey=y.altKey,e._ctrlKey=y.ctrlKey,e._metaKey=y.metaKey,e._shiftKey=y.shiftKey,e._buttonsPressed=y.buttons,n.isPointerLock){var U=y.movementX||y.mozMovementX||y.webkitMovementX||y.msMovementX||0,F=y.movementY||y.mozMovementY||y.webkitMovementY||y.msMovementY||0;e.onTouch(null,U,F),e.pointA=null,e.pointB=null}else if(d.type===Tt.a.POINTERDOWN&&O){try{O.setPointerCapture(y.pointerId)}catch{}e.pointA===null?e.pointA={x:y.clientX,y:y.clientY,pointerId:y.pointerId,type:y.pointerType}:e.pointB===null&&(e.pointB={x:y.clientX,y:y.clientY,pointerId:y.pointerId,type:y.pointerType}),e.onButtonDown(y),t||(y.preventDefault(),i&&i.focus())}else if(d.type===Tt.a.POINTERDOUBLETAP)e.onDoubleTap(y.pointerType);else if(d.type===Tt.a.POINTERUP&&O){try{O.releasePointerCapture(y.pointerId)}catch{}P||(e.pointB=null),n._badOS?e.pointA=e.pointB=null:e.pointB&&e.pointA&&e.pointA.pointerId==y.pointerId?(e.pointA=e.pointB,e.pointB=null):e.pointA&&e.pointB&&e.pointB.pointerId==y.pointerId?e.pointB=null:e.pointA=e.pointB=null,(o!==0||a)&&(e.onMultiTouch(e.pointA,e.pointB,o,0,a,null),o=0,a=null),e.onButtonUp(y),t||y.preventDefault()}else if(d.type===Tt.a.POINTERMOVE){if(t||y.preventDefault(),e.pointA&&e.pointB===null)U=y.clientX-e.pointA.x,F=y.clientY-e.pointA.y,e.onTouch(e.pointA,U,F),e.pointA.x=y.clientX,e.pointA.y=y.clientY;else if(e.pointA&&e.pointB){var z=e.pointA.pointerId===y.pointerId?e.pointA:e.pointB;z.x=y.clientX,z.y=y.clientY;var J=e.pointA.x-e.pointB.x,ie=e.pointA.y-e.pointB.y,se=J*J+ie*ie,ce={x:(e.pointA.x+e.pointB.x)/2,y:(e.pointA.y+e.pointB.y)/2,pointerId:y.pointerId,type:d.type};e.onMultiTouch(e.pointA,e.pointB,o,se,a,ce),a=ce,o=se}}}},this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,Tt.a.POINTERDOWN|Tt.a.POINTERUP|Tt.a.POINTERMOVE),this._onLostFocus=function(){e.pointA=e.pointB=null,o=0,a=null,e.onLostFocus()},i&&i.addEventListener("contextmenu",this.onContextMenu.bind(this),!1);var s=this.camera.getScene().getEngine().getHostWindow();s&&Ye.b.RegisterTopRootEvents(s,[{name:"blur",handler:this._onLostFocus}])},r.prototype.detachControl=function(t){if(this._onLostFocus){var e=this.camera.getScene().getEngine().getHostWindow();e&&Ye.b.UnregisterTopRootEvents(e,[{name:"blur",handler:this._onLostFocus}])}if(this._observer){if(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,this.onContextMenu){var n=this.camera.getScene().getEngine().getInputElement();n&&n.removeEventListener("contextmenu",this.onContextMenu)}this._onLostFocus=null}this._altKey=!1,this._ctrlKey=!1,this._metaKey=!1,this._shiftKey=!1,this._buttonsPressed=0},r.prototype.getClassName=function(){return"BaseCameraPointersInput"},r.prototype.getSimpleName=function(){return"pointers"},r.prototype.onDoubleTap=function(t){},r.prototype.onTouch=function(t,e,n){},r.prototype.onMultiTouch=function(t,e,n,i,o,a){},r.prototype.onContextMenu=function(t){t.preventDefault()},r.prototype.onButtonDown=function(t){},r.prototype.onButtonUp=function(t){},r.prototype.onLostFocus=function(){},Object(c.c)([Object(L.c)()],r.prototype,"buttons",void 0),r}(),Za=function(r){function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.buttons=[0,1,2],e.angularSensibilityX=1e3,e.angularSensibilityY=1e3,e.pinchPrecision=12,e.pinchDeltaPercentage=0,e.useNaturalPinchZoom=!1,e.panningSensibility=1e3,e.multiTouchPanning=!0,e.multiTouchPanAndZoom=!0,e.pinchInwards=!0,e._isPanClick=!1,e._twoFingerActivityCount=0,e._isPinching=!1,e}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"ArcRotateCameraPointersInput"},t.prototype.onTouch=function(e,n,i){this.panningSensibility!==0&&(this._ctrlKey&&this.camera._useCtrlForPanning||this._isPanClick)?(this.camera.inertialPanningX+=-n/this.panningSensibility,this.camera.inertialPanningY+=i/this.panningSensibility):(this.camera.inertialAlphaOffset-=n/this.angularSensibilityX,this.camera.inertialBetaOffset-=i/this.angularSensibilityY)},t.prototype.onDoubleTap=function(e){this.camera.useInputToRestoreState&&this.camera.restoreState()}
1608,t.prototype.onMultiTouch=function(e,n,i,o,a,s){if(!(i===0&&a===null||o===0&&s===null)){var d=this.pinchInwards?1:-1;if(this.multiTouchPanAndZoom){if(this.useNaturalPinchZoom?this.camera.radius=this.camera.radius*Math.sqrt(i)/Math.sqrt(o):this.pinchDeltaPercentage?this.camera.inertialRadiusOffset+=.001*(o-i)*this.camera.radius*this.pinchDeltaPercentage:this.camera.inertialRadiusOffset+=(o-i)/(this.pinchPrecision*d*(this.angularSensibilityX+this.angularSensibilityY)/2),this.panningSensibility!==0&&a&&s){var p=s.x-a.x,y=s.y-a.y;this.camera.inertialPanningX+=-p/this.panningSensibility,this.camera.inertialPanningY+=y/this.panningSensibility}}else{this._twoFingerActivityCount++;var P=Math.sqrt(i),O=Math.sqrt(o);this._isPinching||this._twoFingerActivityCount<20&&Math.abs(O-P)>this.camera.pinchToPanMaxDistance?(this.pinchDeltaPercentage?this.camera.inertialRadiusOffset+=.001*(o-i)*this.camera.radius*this.pinchDeltaPercentage:this.camera.inertialRadiusOffset+=(o-i)/(this.pinchPrecision*d*(this.angularSensibilityX+this.angularSensibilityY)/2),this._isPinching=!0):this.panningSensibility!==0&&this.multiTouchPanning&&s&&a&&(p=s.x-a.x,y=s.y-a.y,this.camera.inertialPanningX+=-p/this.panningSensibility,this.camera.inertialPanningY+=y/this.panningSensibility)}}},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},Object(c.c)([Object(L.c)()],t.prototype,"buttons",void 0),Object(c.c)([Object(L.c)()],t.prototype,"angularSensibilityX",void 0),Object(c.c)([Object(L.c)()],t.prototype,"angularSensibilityY",void 0),Object(c.c)([Object(L.c)()],t.prototype,"pinchPrecision",void 0),Object(c.c)([Object(L.c)()],t.prototype,"pinchDeltaPercentage",void 0),Object(c.c)([Object(L.c)()],t.prototype,"useNaturalPinchZoom",void 0),Object(c.c)([Object(L.c)()],t.prototype,"panningSensibility",void 0),Object(c.c)([Object(L.c)()],t.prototype,"multiTouchPanning",void 0),Object(c.c)([Object(L.c)()],t.prototype,"multiTouchPanAndZoom",void 0),t}(Ml);un.ArcRotateCameraPointersInput=Za;var Uo=function(r){function t(e){return r.call(this,e)||this}return Object(c.d)(t,r),t.prototype.addMouseWheel=function(){return this.add(new qa),this},t.prototype.addPointers=function(){return this.add(new Za),this},t.prototype.addKeyboard=function(){return this.add(new Qa),this},t}(Jr);Uo.prototype.addVRDeviceOrientation=function(){return this.add(new Ja),this};var Ja=function(){function r(){this.alphaCorrection=1,this.gammaCorrection=1,this._alpha=0,this._gamma=0,this._dirty=!1,this._deviceOrientationHandler=this._onOrientationEvent.bind(this)}return r.prototype.attachControl=function(t){var e=this;t=Ye.b.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):Ye.b.Warn("Permission not granted.")}).catch(function(i){Ye.b.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(t){window.removeEventListener("deviceorientation",this._deviceOrientationHandler)},r.prototype.getClassName=function(){return"ArcRotateCameraVRDeviceOrientationInput"},r.prototype.getSimpleName=function(){return"VRDeviceOrientation"},r}();un.ArcRotateCameraVRDeviceOrientationInput=Ja;var $a=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=Ye.b.BackCompatCameraNoPreventDefault(arguments),this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add(function(){e._keys=[]}),this._onKeyboardObserver=this._scene.onKeyboardObservable.add(function(n){var i,o=n.event;
1608n.type===qi.a.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(t){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=[]},r.prototype.getClassName=function(){return"FlyCameraKeyboardInput"},r.prototype._onLostFocus=function(t){this._keys=[]},r.prototype.getSimpleName=function(){return"keyboard"},r.prototype.checkInputs=function(){if(this._onKeyboardObserver)for(var t=this.camera,e=0;e<this._keys.length;e++){var n=this._keys[e],i=t._computeLocalCameraSpeed();this.keysForward.indexOf(n)!==-1?t._localDirection.copyFromFloats(0,0,i):this.keysBackward.indexOf(n)!==-1?t._localDirection.copyFromFloats(0,0,-i):this.keysUp.indexOf(n)!==-1?t._localDirection.copyFromFloats(0,i,0):this.keysDown.indexOf(n)!==-1?t._localDirection.copyFromFloats(0,-i,0):this.keysRight.indexOf(n)!==-1?t._localDirection.copyFromFloats(i,0,0):this.keysLeft.indexOf(n)!==-1&&t._localDirection.copyFromFloats(-i,0,0),t.getScene().useRightHandedSystem&&(t._localDirection.z*=-1),t.getViewMatrix().invertToRef(t._cameraTransformMatrix),u.e.TransformNormalToRef(t._localDirection,t._cameraTransformMatrix,t._transformedDirection),t.cameraDirection.addInPlace(t._transformedDirection)}},Object(c.c)([Object(L.c)()],r.prototype,"keysForward",void 0),Object(c.c)([Object(L.c)()],r.prototype,"keysBackward",void 0),Object(c.c)([Object(L.c)()],r.prototype,"keysU
1608p",void 0),Object(c.c)([Object(L.c)()],r.prototype,"keysDown",void 0),Object(c.c)([Object(L.c)()],r.prototype,"keysRight",void 0),Object(c.c)([Object(L.c)()],r.prototype,"keysLeft",void 0),r}();un.FlyCameraKeyboardInput=$a;var es=function(){function r(t){this.buttons=[0,1,2],this.buttonsYaw=[-1,0,1],this.buttonsPitch=[-1,0,1],this.buttonsRoll=[2],this.activeButton=-1,this.angularSensibility=1e3,this.previousPosition=null}return r.prototype.attachControl=function(t){var e=this;t=Ye.b.BackCompatCameraNoPreventDefault(arguments),this.noPreventDefault=t,this._observer=this.camera.getScene().onPointerObservable.add(function(n,i){e._pointerInput(n,i)},Tt.a.POINTERDOWN|Tt.a.POINTERUP|Tt.a.POINTERMOVE),this._rollObserver=this.camera.getScene().onBeforeRenderObservable.add(function(){e.camera.rollCorrect&&e.camera.restoreRoll(e.camera.rollCorrect)})},r.prototype.detachControl=function(t){this._observer&&(this.camera.getScene().onPointerObservable.remove(this._observer),this.camera.getScene().onBeforeRenderObservable.remove(this._rollObserver),this._observer=null,this._rollObserver=null,this.previousPosition=null,this.noPreventDefault=void 0)},r.prototype.getClassName=function(){return"FlyCameraMouseInput"},r.prototype.getSimpleName=function(){return"mouse"},r.prototype._pointerInput=function(t,e){var n=t.event,i=this.camera.getEngine();if(!i.isInVRExclusivePointerMode&&(this.touchEnabled||n.pointerType!=="touch")&&(t.type===Tt.a.POINTERMOVE||this.buttons.indexOf(n.button)!==-1)){var o=n.srcElement||n.target;if(t.type===Tt.a.POINTERDOWN&&o){try{o.setPointerCapture(n.pointerId)}catch{}this.previousPosition={x:n.clientX,y:n.clientY},this.activeButton=n.button,this.noPreventDefault||(n.preventDefault(),this.element.focus()),i.isPointerLock&&this._onMouseMove(t.event)}else if(t.type===Tt.a.POINTERUP&&o){try{o.releasePointerCapture(n.pointerId)}catch{}this.activeButton=-1,this.previousPosition=null,this.noPreventDefault||n.preventDefault()}else if(t.type===Tt.a.POINTERMOVE){if(!this.previousPosition)return void(i.isPointerLock&&this._onMouseMove(t.event));var a=n.clientX-this.previousPosition.x,s=n.clientY-this.previousPosition.y;this.rotateCamera(a,s),this.previousPosition={x:n.clientX,y:n.clientY},this.noPreventDefault||n.preventDefault()}}},r.prototype._onMouseMove=function(t){var e=this.camera.getEngine();if(e.isPointerLock&&!e.isInVRExclusivePointerMode){var n=t.movementX||t.mozMovementX||t.webkitMovementX||t.msMovementX||0,i=t.movementY||t.mozMovementY||t.webkitMovementY||t.msMovementY||0;this.rotateCamera(n,i),this.previousPosition=null,this.noPreventDefault||t.preventDefault()}},r.prototype.rotateCamera=function(t,e){var n=this,i=this.camera;this.camera.getScene().useRightHandedSystem&&(t*=-1),i.parent&&i.parent._getWorldMatrixDeterminant()<0&&(t*=-1);var o,a=t/this.angularSensibility,s=e/this.angularSensibility,d=u.b.RotationYawPitchRoll(i.rotation.y,i.rotation.x,i.rotation.z);if(this.buttonsPitch.some(function(P){return P===n.activeButton})&&(o=u.b.RotationAxis(ye.a.X,s),d.multiplyInPlace(o)),this.buttonsYaw.some(function(P){return P===n.activeButton})){o=u.b.RotationAxis(ye.a.Y,a),d.multiplyInPlace(o);var p=i.bankedTurnLimit+i._trackRoll;if(i.bankedTurn&&-p<i.rotation.z&&i.rotation.z<p){var y=i.bankedTurnMultiplier*-a;o=u.b.RotationAxis(ye.a.Z,y),d.multiplyInPlace(o)}}this.buttonsRoll.some(function(P){return P===n.activeButton})&&(o=u.b.RotationAxis(ye.a.Z,-a),i._trackRoll-=a,d.multiplyInPlace(o)),d.toEulerAnglesToRef(i.rotation)},Object(c.c)([Object(L.c)()],r.prototype,"buttons",void 0),Object(c.c)([Object(L.c)()],r.prototype,"angularSensibility",void 0),r}();un.FlyCameraMouseInput=es;var ts=function(){function r(){this.keysHeightOffsetIncr=[38],this.keysHeightOffsetDecr=[40],this.keysHeightOffsetModifierAlt=!1,this.keysHeightOffsetModifierCtrl=!1,this.keysHeightOffsetModifierShift=!1,this.keysRotationOffsetIncr=[37],this.keysRotationOffsetDecr=[39],this.keysRotationOffsetModifierAlt=!1,this.keysRotationOffsetModifierCtrl=!1,this.keysRotationOffsetModifierShift=!1,this.keysRadiusIncr=[40],this.keysRadiusDecr=[38],this.keysRadiusModifierAlt=!0,this.keysRadiusModifierCtrl=!1,this.keysRadiusModifierShift=!1,this.heightSensibility=1,this.rotationSe
1608nsibility=1,this.radiusSensibility=1,this._keys=new Array}return r.prototype.attachControl=function(t){var e=this;t=Ye.b.BackCompatCameraNoPreventDefault(arguments),this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add(function(){e._keys=[]}),this._onKeyboardObserver=this._scene.onKeyboardObservable.add(function(n){var i,o=n.event;o.metaKey||(n.type===qi.a.KEYDOWN?(e._ctrlPressed=o.ctrlKey,e._altPressed=o.altKey,e._shiftPressed=o.shiftKey,(e.keysHeightOffsetIncr.indexOf(o.keyCode)!==-1||e.keysHeightOffsetDecr.indexOf(o.keyCode)!==-1||e.keysRotationOffsetIncr.indexOf(o.keyCode)!==-1||e.keysRotationOffsetDecr.indexOf(o.keyCode)!==-1||e.keysRadiusIncr.indexOf(o.keyCode)!==-1||e.keysRadiusDecr.indexOf(o.keyCode)!==-1)&&((i=e._keys.indexOf(o.keyCode))===-1&&e._keys.push(o.keyCode),o.preventDefault&&(t||o.preventDefault()))):e.keysHeightOffsetIncr.indexOf(o.keyCode)===-1&&e.keysHeightOffsetDecr.indexOf(o.keyCode)===-1&&e.keysRotationOffsetIncr.indexOf(o.keyCode)===-1&&e.keysRotationOffsetDecr.indexOf(o.keyCode)===-1&&e.keysRadiusIncr.indexOf(o.keyCode)===-1&&e.keysRadiusDecr.indexOf(o.keyCode)===-1||((i=e._keys.indexOf(o.keyCode))>=0&&e._keys.splice(i,1),o.preventDefault&&(t||o.preventDefault())))}
1608))},r.prototype.detachControl=function(t){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=[]},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},Object(c.c)([Object(L.c)()],r.prototype,"keysHeightOffsetIncr",void 0),Object(c.c)([Object(L.c)()],r.prototype,"keysHeightOffsetDecr",void 0),Object(c.c)([Object(L.c)()],r.prototype,"keysHeightOffsetModifierAlt",void 0),Object(c.c)([Object(L.c)()],r.prototype,"keysHeightOffsetModifierCtrl",void 0),Object(c.c)([Object(L.c)()],r.prototype,"keysHeightOffsetModifierShift",void 0),Object(c.c)([Object(L.c)()],r.prototype,"keysRotationOffsetIncr",void 0),Object(c.c)([Object(L.c)()],r.prototype,"keysRotationOffsetDecr",void 0),Object(c.c)([Object(L.c)()],r.prototype,"keysRotationOffsetModifierAlt",void 0),Object(c.c)([Object(L.c)()],r.prototype,"keysRotationOffsetModifierCtrl",void 0),Object(c.c)([Object(L.c)()],r.prototype,"keysRotationOffsetModifierShift",void 0),Object(c.c)([Object(L.c)()],r.prototype,"keysRadiusIncr",void 0),Object(c.c)([Object(L.c)()],r.prototype,"keysRadiusDecr",void 0),Object(c.c)([Object(L.c)()],r.prototype,"keysRadiusModifierAlt",void 0),Object(c.c)([Object(L.c)()],r.prototype,"keysRadiusModifierCtrl",void 0),Object(c.c)([Object(L.c)()],r.prototype,"keysRadiusModifierShift",void 0),Object(c.c)([Object(L.c)()],r.prototype,"heightSensibility",void 0),Object(c.c)([Object(L.c)()],r.prototype,"rotationSensibility",void 0),Object(c.c)([Object(L.c)()],r.prototype,"radiusSensibility",void 0),r}();un.FollowCameraKeyboardMoveInput=ts;var ns=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=Ye.b.BackCompatCameraNoPreventDefault(arguments),this._wheel=function(n,i){if(n.type===Tt.a.POINTERWHEEL){var o=n.event,a=0,s=Math.max(-1,Math.min(1,o.deltaY||o.wheelDelta||-o.detail));e.wheelDeltaPercentage?(console.assert(e.axisControlRadius+e.axisControlHeight+e.axisControlRotation<=1,"wheelDeltaPercentage only usable when mouse wheel controlls ONE axis. Currently enabled: axisControlRadius: "+e.axisControlRadius+", axisControlHeightOffset: "+e.axisControlHeight+", axisControlRotationOffset: "+e.axisControlRotation),e.axisControlRadius?a=.01*s*e.wheelDeltaPercentage*e.camera.radius:e.axisControlHeight?a=.01*s*e.wheelDeltaPercentage*e.camera.heightOffset:e.axisControlRotation&&(a=.01*s*e.wheelDeltaPercentage*e.camera.rotationOffset)):a=s*e.wheelPrecision,a&&(e.axisControlRadius?e.camera.radius+=a:e.axisControlHeight?e.camera.heightOffset-=a:e.axisControlRotation&&(e.camera.rotationOffset-=a)),o.preventDefault&&(t||o.preventDefault())}},this._observer=this.camera.getScene().onPointerObservable.add(this._wheel,Tt.a.POINTERWHEEL)},r.prototype.detachControl=function(t){this._observer&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,this._wheel=null)},r.prototype.getClassName=function(){return"ArcRotateCameraMouseWheelInput"},r.prototype.getSimpleName=function(){return"mousewheel"},Object(c.c)([Object(L.c)()],r.prototype,"axisControlRadius",void 0),Object(c.c)([Object(L.c)()],r.prototype,"axisControlHeight",void 0),Object(c.c)([Object(L.c)()],r.prototype,"axisControlRotation",void 0),Object(c.c)([Object(L.c)()],r.prototype,"wheelPrecision",void 0),Object(c.c)([Object(L.c)()],r.prototype,"wheelDeltaPercentage",void 0),r}();un.FollowCameraMouseWheelInput=ns;var is=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 Object(c.d)(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)}
1608,t.prototype.onMultiTouch=function(e,n,i,o,a,s){if(!(i===0&&a===null||o===0&&s===null)){var d=(o-i)/(this.pinchPrecision*(this.angularSensibilityX+this.angularSensibilityY)/2);this.pinchDeltaPercentage?(d*=.01*this.pinchDeltaPercentage,this.axisPinchControlRotation&&(this.camera.rotationOffset+=d*this.camera.rotationOffset),this.axisPinchControlHeight&&(this.camera.heightOffset+=d*this.camera.heightOffset),this.axisPinchControlRadius&&(this.camera.radius-=d*this.camera.radius)):(this.axisPinchControlRotation&&(this.camera.rotationOffset+=d),this.axisPinchControlHeight&&(this.camera.heightOffset+=d),this.axisPinchControlRadius&&(this.camera.radius-=d))}},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: ";console.assert(this.axisXControlRotation+this.axisXControlHeight+this.axisXControlRadius<=1,e+"axisXControlRotation: "+this.axisXControlRotation+", axisXControlHeight: "+this.axisXControlHeight+", axisXControlRadius: "+this.axisXControlRadius),console.assert(this.axisYControlRotation+this.axisYControlHeight+this.axisYControlRadius<=1,e+"axisYControlRotation: "+this.axisYControlRotation+", axisYControlHeight: "+this.axisYControlHeight+", axisYControlRadius: "+this.axisYControlRadius),console.assert(this.axisPinchControlRotation+this.axisPinchControlHeight+this.axisPinchControlRadius<=1,e+"axisPinchControlRotation: "+this.axisPinchControlRotation+", axisPinchControlHeight: "+this.axisPinchControlHeight+", axisPinchControlRadius: "+this.axisPinchControlRadius)}},Object(c.c)([Object(L.c)()],t.prototype,"angularSensibilityX",void 0),Object(c.c)([Object(L.c)()],t.prototype,"angularSensibilityY",void 0),Object(c.c)([Object(L.c)()],t.prototype,"pinchPrecision",void 0),Object(c.c)([Object(L.c)()],t.prototype,"pinchDeltaPercentage",void 0),Object(c.c)([Object(L.c)()],t.prototype,"axisXControlRadius",void 0),Object(c.c)([Object(L.c)()],t.prototype,"axisXControlHeight",void 0),Object(c.c)([Object(L.c)()],t.prototype,"axisXControlRotation",void 0),Object(c.c)([Object(L.c)()],t.prototype,"axisYControlRadius",void 0),Object(c.c)([Object(L.c)()],t.prototype,"axisYControlHeight",void 0),Object(c.c)([Object(L.c)()],t.prototype,"axisYControlRotation",void 0),Object(c.c)([Object(L.c)()],t.prototype,"axisPinchControlRadius",void 0),Object(c.c)([Object(L.c)()],t.prototype,"axisPinchControlHeight",void 0),Object(c.c)([Object(L.c)()],t.prototype,"axisPinchControlRotation",void 0),t}(Ml);un.FollowCameraPointersInput=is;var rs=function(){function r(){this.keysUp=[38],this.keysUpward=[33],this.keysDown=[40],this.keysDownward=[34],this.keysLeft=[37],this.keysRight=[39],this._keys=new Array}return r.prototype.attachControl=function(t){var e=this;t=Ye.b.BackCompatCameraNoPreventDefault(arguments),this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add(function(){e._keys=[]}),this._onKeyboardObserver=this._scene.onKeyboardObservable.add(function(n){var i,o=n.event;o.metaKey||(n.type===qi.a.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||((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||((i=e._keys.indexOf(o.keyCode))>=0&&e._keys.splice(i,1),t||o.preventDefault()))}))},r.prototype.detachControl=function(t){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=[]},r.prototype.checkInputs=function(){if(this._onKeyboardObserver)for(var t=this.camera,e=0;e<this._keys.length;e++){var n=this._keys[e],i=t._computeLocalCameraSpeed();this.keysLeft.indexOf(n)!==-1?t._localDirection.copyFromFloats(-i,0,0):this.keysUp.indexOf(n)!==-1?t._localDirection.copyFromFloats(0,0,i):this.keysRight.indexOf(n)!==-1?t._localDirection.copyFromFloats(i,0,0):this.keysDown.indexOf(n)!==-1?t._localDirection.copyFromFloats(0,0,-i):this.keysUpward.indexOf(n)!==-1?t._localDirection.copyFromFloats(0,i,0):this.keysDownward.indexOf(n)!==-1&&t._localDirection.copyFromFloats(0,-i,0),t.getScene().useRightHandedSystem&&(t._localDirection.z*=-1),t.getViewMatrix().invertToRef(t._cameraTransformMatrix),u.e.TransformNormalToRef(t._localDirection,t._cameraTransformMatrix,t._transformedDirection),t.cameraDirection.addInPlace(t._transformedDirection)}},r.prototype.getClassName=function(){return"FreeCameraKeyboardMoveInput"},r.prototype._onLostFocus=function(){this._keys=[]},r.prototype.getSimpleName=function(){return"keyboard"}
1608,Object(c.c)([Object(L.c)()],r.prototype,"keysUp",void 0),Object(c.c)([Object(L.c)()],r.prototype,"keysUpward",void 0),Object(c.c)([Object(L.c)()],r.prototype,"keysDown",void 0),Object(c.c)([Object(L.c)()],r.prototype,"keysDownward",void 0),Object(c.c)([Object(L.c)()],r.prototype,"keysLeft",void 0),Object(c.c)([Object(L.c)()],r.prototype,"keysRight",void 0),r}();un.FreeCameraKeyboardMoveInput=rs;var os=function(){function r(t){t===void 0&&(t=!0),this.touchEnabled=t,this.buttons=[0,1,2],this.angularSensibility=2e3,this.previousPosition=null,this.onPointerMovedObservable=new x.c,this._allowCameraRotation=!0}return r.prototype.attachControl=function(t){var e=this;t=Ye.b.BackCompatCameraNoPreventDefault(arguments);var n=this.camera.getEngine(),i=n.getInputElement();this._pointerInput||(this._pointerInput=function(o){var a=o.event;if(!n.isInVRExclusivePointerMode&&(e.touchEnabled||a.pointerType!=="touch")&&(o.type===Tt.a.POINTERMOVE||e.buttons.indexOf(a.button)!==-1)){var s=a.srcElement||a.target;if(o.type===Tt.a.POINTERDOWN&&s){try{s.setPointerCapture(a.pointerId)}catch{}e.previousPosition={x:a.clientX,y:a.clientY},t||(a.preventDefault(),i&&i.focus()),n.isPointerLock&&e._onMouseMove&&e._onMouseMove(o.event)}else if(o.type===Tt.a.POINTERUP&&s){try{s.releasePointerCapture(a.pointerId)}catch{}e.previousPosition=null,t||a.preventDefault()}else if(o.type===Tt.a.POINTERMOVE){if(!e.previousPosition)return void(n.isPointerLock&&e._onMouseMove&&e._onMouseMove(o.event));var d=a.clientX-e.previousPosition.x,p=a.clientY-e.previousPosition.y;e.camera.getScene().useRightHandedSystem&&(d*=-1),e.camera.parent&&e.camera.parent._getWorldMatrixDeterminant()<0&&(d*=-1),e._allowCameraRotation&&(e.camera.cameraRotation.y+=d/e.angularSensibility,e.camera.cameraRotation.x+=p/e.angularSensibility),e.onPointerMovedObservable.notifyObservers({offsetX:d,offsetY:p}),e.previousPosition={x:a.clientX,y:a.clientY},t||a.preventDefault()}}}),this._onMouseMove=function(o){if(n.isPointerLock&&!n.isInVRExclusivePointerMode){var a=o.movementX||o.mozMovementX||o.webkitMovementX||o.msMovementX||0;e.camera.getScene().useRightHandedSystem&&(a*=-1),e.camera.parent&&e.camera.parent._getWorldMatrixDeterminant()<0&&(a*=-1),e.camera.cameraRotation.y+=a/e.angularSensibility;var s=o.movementY||o.mozMovementY||o.webkitMovementY||o.msMovementY||0;e.camera.cameraRotation.x+=s/e.angularSensibility,e.previousPosition=null,t||o.preventDefault()}},this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,Tt.a.POINTERDOWN|Tt.a.POINTERUP|Tt.a.POINTERMOVE),i&&i.addEventListener("contextmenu",this.onContextMenu.bind(this),!1)},r.prototype.onContextMenu=function(t){t.preventDefault()},r.prototype.detachControl=function(t){if(this._observer){if(this.camera.getScene().onPointerObservable.remove(this._observer),this.onContextMenu){var e=this.camera.getEngine().getInputElement();e&&e.removeEventListener("contextmenu",this.onContextMenu)}this.onPointerMovedObservable&&this.onPointerMovedObservable.clear(),this._observer=null,this._onMouseMove=null,this.previousPosition=null}},r.prototype.getClassName=function(){return"FreeCameraMouseInput"},r.prototype.getSimpleName=function(){return"mouse"},Object(c.c)([Object(L.c)()],r.prototype,"buttons",void 0),Object(c.c)([Object(L.c)()],r.prototype,"angularSensibility",void 0),r}();un.FreeCameraMouseInput=os;var kt,ap=function(){function r(){this.wheelPrecisionX=3,this.wheelPrecisionY=3,this.wheelPrecisionZ=3,this.onChangedObservable=new x.c,this._wheelDeltaX=0,this._wheelDeltaY=0,this._wheelDeltaZ=0,this._ffMultiplier=12,this._normalize=120}return r.prototype.attachControl=function(t){var e=this;t=Ye.b.BackCompatCameraNoPreventDefault(arguments),this._wheel=function(n){if(n.type===Tt.a.POINTERWHEEL){var i=n.event,o=i.deltaMode===WheelEvent.DOM_DELTA_LINE?e._ffMultiplier:1;i.deltaY!==void 0?(e._wheelDeltaX+=e.wheelPrecisionX*o*i.deltaX/e._normalize,e._wheelDeltaY-=e.wheelPrecisionY*o*i.deltaY/e._normalize,e._wheelDeltaZ+=e.wheelPrecisionZ*o*i.deltaZ/e._normalize):i.wheelDeltaY!==void 0?(e._wheelDeltaX+=e.wheelPrecisionX*o*i.wheelDeltaX/e._normalize,e._wheelDeltaY-=e.wheelPrecisionY*o*i.wheelDeltaY/e._normalize,e._wheelDeltaZ+=e.wheelPrecisionZ*o*i.wheelDeltaZ/e._normalize):i.wheelDelta&&(e._wheelDeltaY-=e.wheelPrecisionY*i.wheelDelta/e._normalize),i.preventDefault&&(t||i.preventDefault())}},this._observer=this.camera.getScene().onPointerObservable.add(this._wheel,Tt.a.POINTERWHEEL)},r.prototype.detachControl=function(t){this._observer&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,this._wheel=null),this.onChangedObservable&&this.onChangedObservable.clear()},r.prototype.checkInputs=function(){this.onChangedObservable.notifyObservers({wheelDeltaX:this._wheelDeltaX,wheelDeltaY:this._wheelDeltaY,wheelDeltaZ:this._wheelDeltaZ}),this._wheelDeltaX=0,this._wheelDeltaY=0,this._wheelDeltaZ=0},r.prototype.getClassName=function(){return"BaseCameraMouseWheelInput"},r.prototype.getSimpleName=function(){return"mousewheel"},Object(c.c)([Object(L.c)()],r.prototype,"wheelPrecisionX",void 0),Object(c.c)([Object(L.c)()],r.prototype,"wheelPrecisionY",void 0),Object(c.c)([Object(L.c)()],r.prototype,"wheelPrecisionZ",void 0),r}();(function(r){r[r.MoveRelative=0]="MoveRelative",r[r.RotateRelative=1]="RotateRelative",r[r.MoveScene=2]="MoveScene"})(kt||(kt={}));var as=function(r){function t(){var e=r!==null&&r.apply(this,arguments)||this;return e._moveRelative=u.e.Zero(),e._rotateRelative=u.e.Zero(),e._moveScene=u.e.Zero(),e._wheelXAction=kt.MoveRelative,e._wheelXActionCoordinate=ye.b.X,e._wheelYAction=kt.MoveRelative,e._wheelYActionCoordinate=ye.b.Z,e._wheelZAction=null,e._wheelZActionCoordinate=null,e}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"FreeCameraMouseWheelInput"},Object.defineProperty(t.prototype,"wheelXMoveRelative",{get:function(){return this._wheelXAction!==kt.MoveRelative?null:this._wheelXActionCoordinate},set:function(e){e===null&&this._wheelXAction!==kt.MoveRelative||(this._wheelXAction=kt.MoveRelative,this._wheelXActionCoordinate=e)}
1608,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wheelYMoveRelative",{get:function(){return this._wheelYAction!==kt.MoveRelative?null:this._wheelYActionCoordinate},set:function(e){e===null&&this._wheelYAction!==kt.MoveRelative||(this._wheelYAction=kt.MoveRelative,this._wheelYActionCoordinate=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wheelZMoveRelative",{get:function(){return this._wheelZAction!==kt.MoveRelative?null:this._wheelZActionCoordinate},set:function(e){e===null&&this._wheelZAction!==kt.MoveRelative||(this._wheelZAction=kt.MoveRelative,this._wheelZActionCoordinate=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wheelXRotateRelative",{get:function(){return this._wheelXAction!==kt.RotateRelative?null:this._wheelXActionCoordinate},set:function(e){e===null&&this._wheelXAction!==kt.RotateRelative||(this._wheelXAction=kt.RotateRelative,this._wheelXActionCoordinate=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wheelYRotateRelative",{get:function(){return this._wheelYAction!==kt.RotateRelative?null:this._wheelYActionCoordinate},set:function(e){e===null&&this._wheelYAction!==kt.RotateRelative||(this._wheelYAction=kt.RotateRelative,this._wheelYActionCoordinate=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wheelZRotateRelative",{get:function(){return this._wheelZAction!==kt.RotateRelative?null:this._wheelZActionCoordinate},set:function(e){e===null&&this._wheelZAction!==kt.RotateRelative||(this._wheelZAction=kt.RotateRelative,this._wheelZActionCoordinate=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wheelXMoveScene",{get:function(){return this._wheelXAction!==kt.MoveScene?null:this._wheelXActionCoordinate},set:function(e){e===null&&this._wheelXAction!==kt.MoveScene||(this._wheelXAction=kt.MoveScene,this._wheelXActionCoordinate=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wheelYMoveScene",{get:function(){return this._wheelYAction!==kt.MoveScene?null:this._wheelYActionCoordinate},set:function(e){e===null&&this._wheelYAction!==kt.MoveScene||(this._wheelYAction=kt.MoveScene,this._wheelYActionCoordinate=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wheelZMoveScene",{get:function(){return this._wheelZAction!==kt.MoveScene?null:this._wheelZActionCoordinate},set:function(e){e===null&&this._wheelZAction!==kt.MoveScene||(this._wheelZAction=kt.MoveScene,this._wheelZActionCoordinate=e)},enumerable:!1,configurable:!0}),t.prototype.checkInputs=function(){if(this._wheelDeltaX!==0||this._wheelDeltaY!==0||this._wheelDeltaZ!=0){this._moveRelative.setAll(0),this._rotateRelative.setAll(0),this._moveScene.setAll(0),this._updateCamera(),this.camera.getScene().useRightHandedSystem&&(this._moveRelative.z*=-1);var e=u.a.Zero();this.camera.getViewMatrix().invertToRef(e);var n=u.e.Zero();u.e.TransformNormalToRef(this._moveRelative,e,n),this.camera.cameraRotation.x+=this._rotateRelative.x/200,this.camera.cameraRotation.y+=this._rotateRelative.y/200,this.camera.cameraDirection.addInPlace(n),this.camera.cameraDirection.addInPlace(this._moveScene),r.prototype.checkInputs.call(this)}},t.prototype._updateCamera=function(){var e=this._moveRelative,n=this._rotateRelative,i=this._moveScene,o=function(a,s,d){if(a!==0&&s!==null&&d!==null){var p=null;switch(s){case kt.MoveRelative:p=e;break;case kt.RotateRelative:p=n;break;case kt.MoveScene:p=i}switch(d){case ye.b.X:p.set(a,0,0);break;case ye.b.Y:p.set(0,a,0);break;case ye.b.Z:p.set(0,0,a)}}};o(this._wheelDeltaX,this._wheelXAction,this._wheelXActionCoordinate),o(this._wheelDeltaY,this._wheelYAction,this._wheelYActionCoordinate),o(this._wheelDeltaZ,this._wheelZAction,this._wheelZActionCoordinate)},Object(c.c)([Object(L.c)()],t.prototype,"wheelXMoveRelative",null),Object(c.c)([Object(L.c)()],t.prototype,"wheelYMoveRelative",null),Object(c.c)([Object(L.c)()],t.prototype,"wheelZMoveRelative",null),Object(c.c)([Object(L.c)()],t.prototype,"wheelXRotateRelative",null),Object(c.c)([Object(L.c)()],t.prototype,"wheelYRotateRelative",null),Object(c.c)([Object(L.c)()],t.prototype,"wheelZRotateRelative",null),Object(c.c)([Object(L.c)()],t.prototype,"wheelXMoveScene",null),Object(c.c)([Object(L.c)()],t.prototype,"wheelYMoveScene",null),Object(c.c)([Object(L.c)()],t.prototype,"wheelZMoveScene",null),t}(ap);un.FreeCameraMouseWheelInput=as;var ss=function(){function r(t){t===void 0&&(t=!1),this.allowMouse=t,this.touchAngularSensibility=2e5,this.touchMoveSensibility=250,this._offsetX=null,this._offsetY=null,this._pointerPressed=new Array}return r.prototype.attachControl=function(t){var e=this;t=Ye.b.BackCompatCameraNoPreventDefault(arguments);var n=null;if(this._pointerInput===void 0&&(this._onLostFocus=function(){e._offsetX=null,e._offsetY=null},this._pointerInput=function(a){var s=a.event,d=!e.camera.getEngine().hostInformation.isMobile&&s instanceof MouseEvent;if(e.allowMouse||s.pointerType!=="mouse"&&!d){if(a.type===Tt.a.POINTERDOWN){if(t||s.preventDefault(),e._pointerPressed.push(s.pointerId),e._pointerPressed.length!==1)return;n={x:s.clientX,y:s.clientY}}else if(a.type===Tt.a.POINTERUP){if(t||s.preventDefault(),(p=e._pointerPressed.indexOf(s.pointerId))===-1||(e._pointerPressed.splice(p,1),p!=0))return;n=null,e._offsetX=null,e._offsetY=null}else if(a.type===Tt.a.POINTERMOVE){if(t||s.preventDefault(),!n)return;var p;if((p=e._pointerPressed.indexOf(s.pointerId))!=0)return;e._offsetX=s.clientX-n.x,e._offsetY=-(s.clientY-n.y)}}}),this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,Tt.a.POINTERDOWN|Tt.a.POINTERUP|Tt.a.POINTERMOVE),this._onLostFocus){var i=this.camera.getEngine(),o=i.getInputElement();o&&o.addEventListener("blur",this._onLostFocus)}},r.prototype.detachControl=function(t){if(this._pointerInput){if(this._observer&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null),this._onLostFocus){var e=this.camera.getEngine().getInputElement();e&&e.removeEventListener("blur",this._onLostFocus),this._onLostFocus=null}this._pointerPressed=[],this._offsetX=null,this._offsetY=null}},r.prototype.checkInputs=function(){if(this._offsetX!==null&&this._offsetY!==null&&(this._offsetX!==0||this._offsetY!==0)){var t=this.camera;if(t.cameraRotation.y=this._offsetX/this.touchAngularSensibility,this._pointerPressed.length>1)t.cameraRotation.x=-this._offsetY/this.touchAngularSensibility;else{var e=t._computeLocalCameraSpeed(),n=new u.e(0,0,e*this._offsetY/this.touchMoveSensibility);u.a.RotationYawPitchRollToRef(t.rotation.y,t.rotation.x,0,t._cameraRotationMatrix),t.cameraDirection.addInPlace(u.e.TransformCoordinates(n,t._
1608cameraRotationMatrix))}}},r.prototype.getClassName=function(){return"FreeCameraTouchInput"},r.prototype.getSimpleName=function(){return"touch"},Object(c.c)([Object(L.c)()],r.prototype,"touchAngularSensibility",void 0),Object(c.c)([Object(L.c)()],r.prototype,"touchMoveSensibility",void 0),r}();un.FreeCameraTouchInput=ss;var $r=function(r){function t(e){var n=r.call(this,e)||this;return n._mouseInput=null,n._mouseWheelInput=null,n}return Object(c.d)(t,r),t.prototype.addKeyboard=function(){return this.add(new rs),this},t.prototype.addMouse=function(e){return e===void 0&&(e=!0),this._mouseInput||(this._mouseInput=new os(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 as,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 ss),this},t.prototype.clear=function(){r.prototype.clear.call(this),this._mouseInput=null},t}(Jr);$r.prototype.addDeviceOrientation=function(){return this._deviceOrientationInput||(this._deviceOrientationInput=new cs,this.add(this._deviceOrientationInput)),this};var cs=function(){function r(){var t=this;this._screenOrientationAngle=0,this._screenQuaternion=new u.b,this._alpha=0,this._beta=0,this._gamma=0,this._onDeviceOrientationChangedObservable=new x.c,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=-Ye.b.ToRadians(t._screenOrientationAngle/2),t._screenQuaternion.copyFromFloats(0,Math.sin(t._screenOrientationAngle),0,Math.cos(t._screenOrientationAngle))},this._deviceOrientation=function(e){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._constantTranform=new u.b(-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):Ye.b.Warn("Permission not granted.")}).catch(function(a){Ye.b.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 u.b),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():Ye.b.Warn("Permission not granted.")}).catch(function(i){Ye.b.Error(i)}):n()}},r.prototype.detachControl=function(t){window.removeEventListener("orientationchange",this._orientationChanged),window.removeEventListener("deviceorientation",this._deviceOrientation),this._alpha=0},r.prototype.checkInputs=function(){this._alpha&&(u.b.RotationYawPitchRollToRef(Ye.b.ToRadians(this._alpha),Ye.b.ToRadians(this._beta),-Ye.b.ToRadians(this._gamma),this.camera.rotationQuaternion),this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion),this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform),this._camera.rotationQuaternion.z*=-1,this._camera.rotationQuaternion.w*=-1)},r.prototype.getClassName=function(){return"FreeCameraDeviceOrientationInput"},r.prototype.getSimpleName=function(){return"deviceOrientation"},r}();un.FreeCameraDeviceOrientationInput=cs;var ls=function(){function r(){this.gamepadAngularSensibility=200,this.gamepadMoveSensibility=40,this._yAxisScale=1,this._cameraTransform=u.a.Identity(),this._deltaTransform=u.e.Zero(),this._vector3=u.e.Zero(),this._vector2=u.d.Zero()}return Object.defineProperty(r.prototype,"invertYAxis",{get:function(){return this._yAxisScale!==1},set:function(t){this._yAxisScale=t?-1:1}
1608,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!==hn.POSE_ENABLED&&(t.gamepad&&n.type!==hn.XBOX||(t.gamepad=n))}),this._onGamepadDisconnectedObserver=e.onGamepadDisconnectedObservable.add(function(n){t.gamepad===n&&(t.gamepad=null)}),this.gamepad=e.getGamepadByType(hn.XBOX),!this.gamepad&&e.gamepads.length&&(this.gamepad=e.gamepads[0])},r.prototype.detachControl=function(t){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,n=e.x/this.gamepadMoveSensibility,i=e.y/this.gamepadMoveSensibility;e.x=Math.abs(n)>.005?0+n:0,e.y=Math.abs(i)>.005?0+i:0;var o=this.gamepad.rightStick;if(o){var a=o.x/this.gamepadAngularSensibility,s=o.y/this.gamepadAngularSensibility*this._yAxisScale;o.x=Math.abs(a)>.001?0+a:0,o.y=Math.abs(s)>.001?0+s:0}else o={x:0,y:0};t.rotationQuaternion?t.rotationQuaternion.toRotationMatrix(this._cameraTransform):u.a.RotationYawPitchRollToRef(t.rotation.y,t.rotation.x,0,this._cameraTransform);var d=50*t._computeLocalCameraSpeed();this._vector3.copyFromFloats(e.x*d,0,-e.y*d),u.e.TransformCoordinatesToRef(this._vector3,this._cameraTransform,this._deltaTransform),t.cameraDirection.addInPlace(this._deltaTransform),this._vector2.copyFromFloats(o.y,o.x),t.cameraRotation.addInPlace(this._vector2)}},r.prototype.getClassName=function(){return"FreeCameraGamepadInput"},r.prototype.getSimpleName=function(){return"gamepad"},Object(c.c)([Object(L.c)()],r.prototype,"gamepadAngularSensibility",void 0),Object(c.c)([Object(L.c)()],r.prototype,"gamepadMoveSensibility",void 0),r}();un.FreeCameraGamepadInput=ls;var an,Il=f(112);(function(r){r[r.X=0]="X",r[r.Y=1]="Y",r[r.Z=2]="Z"})(an||(an={}));var us=function(){function r(t,e){var n=this,i=Object(c.a)(Object(c.a)({},r._GetDefaultOptions()),e);if(this._leftJoystick=!!t,r._globalJoystickIndex++,this._axisTargetedByLeftAndRight=an.X,this._axisTargetedByUpAndDown=an.Y,this.reverseLeftRight=!1,this.reverseUpDown=!1,this._touches=new Il.a,this.deltaPosition=u.e.Zero(),this._joystickSensibility=25,this._inversedSensibility=1/(this._joystickSensibility/1e3),this._onResize=function(a){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.msTouchAction="none",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 u.d(0,0),this._joystickPreviousPointerPos=new u.d(0,0),this._joystickPointerStartPos=new u.d(0,0),this._deltaJoystickVector=new u.d(0,0),this._onPointerDownHandlerRef=function(a){n._onPointerDown(a)},this._onPointerMoveHandlerRef=function(a){n._onPointerMove(a)},this._onPointerUpHandlerRef=function(a){n._onPointerUp(a)},r.Canvas.addEventListener("pointerdown",this._onPointerDownHandlerRef,!1),r.Canvas.addEventListener("pointermove",this._onPointerMoveHandlerRef,!1),r.Canvas.addEventListener("pointerup",this._onPointerUpHandlerRef,!1),r.Canvas.addEventListener("pointerout",this._onPointerUpHandlerRef,!1),r.Canvas.addEventListener("contextmenu",function(a){a.preventDefault()},!1),requestAnimationFrame(function(){n._drawVirtualJoystick()})}return r._GetDefaultOptions=function(){return{puckSize:40,containerSize:60,color:"cyan",puckImage:void 0,containerImage:void 0,position:void 0,alwaysVisible:!1,limitToContainer:!1}},r.prototype.setJoystickSensibility=function(t){this._joystickSensibility=t,this._inversedSensibility=1/(this._joystickSensibility/1e3)},r.prototype._onPointerDown=function(t){t.preventDefault(),(this._leftJoystick===!0?t.clientX<r.halfWidth:t.clientX>r.halfWidth)&&this._joystickPointerID<0?(this._joystickPointerID=t.pointerId,this._joystickPosition?(this._joystickPointerStartPos=this._joystickPosition.clone(),this._joystickPointerPos=this._joystickPosition.clone(),this._joystickPreviousPointerPos=this._joystickPosition.clone(),this._onPointerMove(t)):(this._joystickPointerStartPos.x=t.clientX,this._joystickPointerStartPos.y=t.clientY,this._joystickPointerPos=this._joystickPointerStartPos.clone(),this._joystickPreviousPointerPos=this._joystickPointerStartPos.clone()),this._deltaJoystickVector.x=0,this._deltaJoystickVector.y=0,this.pressed=!0,this._touches.add(t.pointerId.toString(),t)):r._globalJoystickIndex<2&&this._action&&(this._action(),this._touches.add(t.pointerId.toString(),{x:t.clientX,y:t.clientY,prevX:t.clientX,prevY:t.clientY}))},r.prototype._onPointerMove=function(t){if(this._joystickPointerID==t.pointerId){if(this.limitToContainer){var e=new u.d(t.clientX-this._joystickPointerStartPos.x,t.clientY-this._joystickPointerStartPos.y),n=e.length();n>this.containerSize&&e.scaleInPlace(this.containerSize/n),this._joystickPointerPos.x=this._joystickPointerStartPos.x+e.x,this._joystickPointerPos.y=this._joystickPointerStartPos.y+e.y}else this._joystickPointerPos.x=t.clientX,this._joystickPointerPos.y=t.clientY;this._deltaJoystickVector=this._joystickPointerPos.clone(),this._deltaJoystickVector=this._deltaJoystickVector.subtract(this._joystickPointerStartPos),0<r._alwaysVisibleSticks&&(this._leftJoystick?this._joystickPointerPos.x=Math.min(r.halfWidth,this._joystickPointerPos.x):this._joystickPointerPos.x=Math.max(r.halfWidth,this._joystickPointerPos.x));var i=(this.reverseLeftRight?-1:1)*this._deltaJoystickVector.x/this._inversedSensibility;switch(this._axisTargetedByLeftAndRight){case an.X:this.deltaPosition.x=Math.min(1,Math.max(-1,i));break;case an.Y:this.deltaPosition.y=Math.min(1,Math.max(-1,i));break;case an.Z:this.deltaPosition.z=Math.min(1,Math.max(-1,i))}var o=(this.reverseUpDown?1:-1)*this._deltaJoystickVector.y/this._inversedSensibility;switch(this._axisTargetedByUpAndDown){case an.X:this.deltaPosition.x=Math.min(1,Math.max(-1,o));break;case an.Y:this.deltaPosition.y=Math.min(1,Math.max(-1,o));break;case an.Z:this.deltaPosition.z=Math.min(1,Math.max(-1,o))}}else{var a=this._touches.get(t.pointerId.toString());a&&(a.x=t.clientX,a.y=t.clientY)}},r.prototype._onPointerUp=function(t){if(this._joystickPointerID==t.pointerId)this._clearPreviousDraw(),this._joystickPointerID=-1,this.pressed=!1;else{var e=this._touches.get(t.pointerId.toString());e&&r.vjCanvasContext.clearRect(e.prevX-44,e.prevY-44,88,88)}this._deltaJoystickVector.x=0,this._deltaJoystickVector.y=0,this._touches.remove(t.pointerId.toString())},r.prototype.setJoystickColor=function(t){this._joystickColor=t},Object.defineProperty(r.prototype,"containerSize",{get:function(){return this._joystickContainerSize},set:function(t){this._joystickContainerSize=t,this._clearContainerSize=~~(2.1*this._joystickContainerSize),this._clearContainerSizeOffset=~~(this._clearContainerSize/2)}
1608,enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"puckSize",{get:function(){return this._joystickPuckSize},set:function(t){this._joystickPuckSize=t,this._clearPuckSize=~~(2.1*this._joystickPuckSize),this._clearPuckSizeOffset=~~(this._clearPuckSize/2)},enumerable:!1,configurable:!0}),r.prototype.clearPosition=function(){this.alwaysVisible=!1,this._joystickPosition=null},Object.defineProperty(r.prototype,"alwaysVisible",{get:function(){return this._alwaysVisible},set:function(t){this._alwaysVisible!==t&&(t&&this._joystickPosition?(r._alwaysVisibleSticks++,this._alwaysVisible=!0):(r._alwaysVisibleSticks--,this._alwaysVisible=!1))},enumerable:!1,configurable:!0}),r.prototype.setPosition=function(t,e){this._joystickPointerStartPos&&this._clearPreviousDraw(),this._joystickPosition=new u.d(t,e)},r.prototype.setActionOnTouch=function(t){this._action=t},r.prototype.setAxisForLeftRight=function(t){switch(t){case an.X:case an.Y:case an.Z:this._axisTargetedByLeftAndRight=t;break;default:this._axisTargetedByLeftAndRight=an.X}},r.prototype.setAxisForUpDown=function(t){switch(t){case an.X:case an.Y:case an.Z:this._axisTargetedByUpAndDown=t;break;default:this._axisTargetedByUpAndDown=an.Y}},r.prototype._clearPreviousDraw=function(){var t=this._joystickPosition||this._joystickPointerStartPos;r.vjCanvasContext.clearRect(t.x-this._clearContainerSizeOffset,t.y-this._clearContainerSizeOffset,this._clearContainerSize,this._clearContainerSize),r.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x-this._clearPuckSizeOffset,this._joystickPreviousPointerPos.y-this._clearPuckSizeOffset,this._clearPuckSize,this._clearPuckSize)},r.prototype.setContainerImage=function(t){var e=this,n=new Image;n.src=t,n.onload=function(){return e._containerImage=n}},r.prototype.setPuckImage=function(t){var e=this,n=new Image;n.src=t,n.onload=function(){return e._puckImage=n}},r.prototype._drawContainer=function(){var t=this._joystickPosition||this._joystickPointerStartPos;this._clearPreviousDraw(),this._containerImage?r.vjCanvasContext.drawImage(this._containerImage,t.x-this.containerSize,t.y-this.containerSize,2*this.containerSize,2*this.containerSize):(r.vjCanvasContext.beginPath(),r.vjCanvasContext.strokeStyle=this._joystickColor,r.vjCanvasContext.lineWidth=2,r.vjCanvasContext.arc(t.x,t.y,this.containerSize,0,2*Math.PI,!0),r.vjCanvasContext.stroke(),r.vjCanvasContext.closePath(),r.vjCanvasContext.beginPath(),r.vjCanvasContext.lineWidth=6,r.vjCanvasContext.strokeStyle=this._joystickColor,r.vjCanvasContext.arc(t.x,t.y,this.puckSize,0,2*Math.PI,!0),r.vjCanvasContext.stroke(),r.vjCanvasContext.closePath())},r.prototype._drawPuck=function(){this._puckImage?r.vjCanvasContext.drawImage(this._puckImage,this._joystickPointerPos.x-this.puckSize,this._joystickPointerPos.y-this.puckSize,2*this.puckSize,2*this.puckSize):(r.vjCanvasContext.beginPath(),r.vjCanvasContext.strokeStyle=this._joystickColor,r.vjCanvasContext.lineWidth=2,r.vjCanvasContext.arc(this._joystickPointerPos.x,this._joystickPointerPos.y,this.puckSize,0,2*Math.PI,!0),r.vjCanvasContext.stroke(),r.vjCanvasContext.closePath())},r.prototype._drawVirtualJoystick=function(){var t=this;this.alwaysVisible&&this._drawContainer(),this.pressed&&this._touches.forEach(function(e,n){
1608n.pointerId===t._joystickPointerID?(t.alwaysVisible||t._drawContainer(),t._drawPuck(),t._joystickPreviousPointerPos=t._joystickPointerPos.clone()):(r.vjCanvasContext.clearRect(n.prevX-44,n.prevY-44,88,88),r.vjCanvasContext.beginPath(),r.vjCanvasContext.fillStyle="white",r.vjCanvasContext.beginPath(),r.vjCanvasContext.strokeStyle="red",r.vjCanvasContext.lineWidth=6,r.vjCanvasContext.arc(n.x,n.y,40,0,2*Math.PI,!0),r.vjCanvasContext.stroke(),r.vjCanvasContext.closePath(),n.prevX=n.x,n.prevY=n.y)}),requestAnimationFrame(function(){t._drawVirtualJoystick()})},r.prototype.releaseCanvas=function(){r.Canvas&&(r.Canvas.removeEventListener("pointerdown",this._onPointerDownHandlerRef),r.Canvas.removeEventListener("pointermove",this._onPointerMoveHandlerRef),r.Canvas.removeEventListener("pointerup",this._onPointerUpHandlerRef),r.Canvas.removeEventListener("pointerout",this._onPointerUpHandlerRef),window.removeEventListener("resize",this._onResize),document.body.removeChild(r.Canvas),r.Canvas=null)},r._globalJoystickIndex=0,r._alwaysVisibleSticks=0,r}();$r.prototype.addVirtualJoystick=function(){return this.add(new hs),this};var hs=function(){function r(){}return r.prototype.getLeftJoystick=function(){return this._leftjoystick},r.prototype.getRightJoystick=function(){return this._rightjoystick},r.prototype.checkInputs=function(){if(this._leftjoystick){var t=this.camera,e=50*t._computeLocalCameraSpeed(),n=u.a.RotationYawPitchRoll(t.rotation.y,t.rotation.x,0),i=u.e.TransformCoordinates(new u.e(this._leftjoystick.deltaPosition.x*e,this._leftjoystick.deltaPosition.y*e,this._leftjoystick.deltaPosition.z*e),n);t.cameraDirection=t.cameraDirection.add(i),t.cameraRotation=t.cameraRotation.addVector3(this._rightjoystick.deltaPosition),this._leftjoystick.pressed||(this._leftjoystick.deltaPosition=this._leftjoystick.deltaPosition.scale(.9)),this._rightjoystick.pressed||(this._rightjoystick.deltaPosition=this._rightjoystick.deltaPosition.scale(.9))}},r.prototype.attachControl=function(){this._leftjoystick=new us(!0),this._leftjoystick.setAxisForUpDown(an.Z),this._leftjoystick.setAxisForLeftRight(an.X),this._leftjoystick.setJoystickSensibility(.15),this._rightjoystick=new us(!1),this._rightjoystick.setAxisForUpDown(an.X),this._rightjoystick.setAxisForLeftRight(an.Y),this._rightjoystick.reverseUpDown=!0,this._rightjoystick.setJoystickSensibility(.05),this._rightjoystick.setJoystickColor("yellow")},r.prototype.detachControl=function(t){this._leftjoystick.releaseCanvas(),this._rightjoystick.releaseCanvas()},r.prototype.getClassName=function(){return"FreeCameraVirtualJoystickInput"},r.prototype.getSimpleName=function(){return"virtualJoystick"},r}();un.FreeCameraVirtualJoystickInput=hs;var Gt=f(28),Ii=function(r){function t(e,n,i,o){o===void 0&&(o=!0);var a=r.call(this,e,n,i,o)||this;return a._tmpUpVector=u.e.Zero(),a._tmpTargetVector=u.e.Zero(),a.cameraDirection=new u.e(0,0,0),a.cameraRotation=new u.d(0,0),a.ignoreParentScaling=!1,a.updateUpVectorFromRotation=!1,a._tmpQuaternion=new u.b,a.rotation=new u.e(0,0,0),a.speed=2,a.noRotationConstraint=!1,a.invertRotation=!1,a.inverseRotationSpeed=.2,a.lockedTarget=null,a._currentTarget=u.e.Zero(),a._initialFocalDistance=1,a._viewMatrix=u.a.Zero(),a._camMatrix=u.a.Zero(),a._cameraTransformMatrix=u.a.Zero(),a._cameraRotationMatrix=u.a.Zero(),a._referencePoint=new u.e(0,0,1),a._transformedReferencePoint=u.e.Zero(),a._defaultUp=u.e.Up(),a._cachedRotationZ=0,a._cachedQuaternionRotationZ=0,a}return Object(c.d)(t,r),t.prototype.getFrontPosition=function(e){this.getWorldMatrix();var n=this.getTarget().subtract(this.position);return n.normalize(),n.scaleInPlace(e),this.globalPosition.add(n)},t.prototype._getLockedTargetPosition=function(){return this.lockedTarget?(this.lockedTarget.absolutePosition&&this.lockedTarget.computeWorldMatrix(),this.lockedTarget.absolutePosition||this.lockedTarget):null},t.prototype.storeState=function(){return this._storedPosition=this.position.clone(),this._storedRotation=this.rotation.clone(),this.rotationQuaternion&&(this._storedRotationQuaternion=this.rotationQuaternion.clone()),r.prototype.storeState.call(this)},t.prototype._restoreStateValues=function(){return!!r.prototype._restoreStateValues.call(this)&&(this.position=this._storedPosition.clone(),this.rotation=this._storedRotation.clone(),this.rotationQuaternion&&(this.rotationQuaternion=this._storedRotationQuaternion.clone()),this.cameraDirection.copyFromFloats(0,0,0),this.cameraRotation.copyFromFloats(0,0),!0)},t.prototype._initCache=function(){r.prototype._initCache.call(this),this._cache.lockedTarget=new u.e(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotation=new u.e(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotationQuaternion=new u.b(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)},t.prototype._updateCache=function(e){e||r.prototype._updateCache.call(this);var n=this._getLockedTargetPosition();n?this._cache.lockedTarget?this._cache.lockedTarget.copyFrom(n):this._cache.lockedTarget=n.clone():this._cache.lockedTarget=null,this._cache.rotation.copyFrom(this.rotation),this.rotationQuaternion&&this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion)},t.prototype._isSynchronizedViewMatrix=function(){if(!r.prototype._isSynchronizedViewMatrix.call(this))return!1;var e=this._getLockedTargetPosition();return(this._cache.lockedTarget?this._cache.lockedTarget.equals(e):!e)&&(this.rotationQuaternion?this.rotationQuaternion.equals(this._cache.rotationQuaternion):this._cache.rotation.equals(this.rotation))},t.prototype._computeLocalCameraSpeed=function(){var e=this.getEngine();return this.speed*Math.sqrt(e.getDeltaTime()/(100*e.getFps()))},t.prototype.setTarget=function(e){this.upVector.normalize(),this._initialFocalDistance=e.subtract(this.position).length(),this.position.z===e.z&&(this.position.z+=Gt.a),this._referencePoint.normalize().scaleInPlace(this._initialFocalDistance),u.a.LookAtLHToRef(this.position,e,this._defaultUp,this._camMatrix),this._camMatrix.invert(),this.rotation.x=Math.atan(this._camMatrix.m[6]/this._camMatrix.m[10]);var n=e.subtract(this.position);n.x>=0?this.rotation.y=-Math.atan(n.z/n.x)+Math.PI/2:this.rotation.y=-Math.atan(n.z/n.x)-Math.PI/2,this.rotation.z=0,isNaN(this.rotation.x)&&(this.rotation.x=0),isNaN(this.rotation.y)&&(this.rotation.y=0),isNaN(this.rotation.z)&&(this.rotation.z=0),this.rotationQuaternion&&u.b.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)}
1608,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(u.c.Matrix[0]),u.e.TransformNormalToRef(this.cameraDirection,u.c.Matrix[0],u.c.Vector3[0]),void this.position.addInPlace(u.c.Vector3[0]);this.position.addInPlace(this.cameraDirection)},t.prototype._checkInputs=function(){var e=this.invertRotation?-this.inverseRotationSpeed:1,n=this._decideIfNeedsToMove(),i=Math.abs(this.cameraRotation.x)>0||Math.abs(this.cameraRotation.y)>0;n&&this._updatePosition(),i&&(this.rotationQuaternion&&this.rotationQuaternion.toEulerAnglesToRef(this.rotation),this.rotation.x+=this.cameraRotation.x*e,this.rotation.y+=this.cameraRotation.y*e,!this.noRotationConstraint&&(this.rotation.x>1.570796&&(this.rotation.x=1.570796),this.rotation.x<-1.570796&&(this.rotation.x=-1.570796)),this.rotationQuaternion&&this.rotation.lengthSquared()&&u.b.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)),n&&(Math.abs(this.cameraDirection.x)<this.speed*Gt.a&&(this.cameraDirection.x=0),Math.abs(this.cameraDirection.y)<this.speed*Gt.a&&(this.cameraDirection.y=0),Math.abs(this.cameraDirection.z)<this.speed*Gt.a&&(this.cameraDirection.z=0),this.cameraDirection.scaleInPlace(this.inertia)),i&&(Math.abs(this.cameraRotation.x)<this.speed*Gt.a&&(this.cameraRotation.x=0),Math.abs(this.cameraRotation.y)<this.speed*Gt.a&&(this.cameraRotation.y=0),this.cameraRotation.scaleInPlace(this.inertia)),r.prototype._checkInputs.call(this)},t.prototype._updateCameraRotationMatrix=function(){this.rotationQuaternion?this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix):u.a.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this._cameraRotationMatrix)},t.prototype._rotateUpVectorWithCameraRotationMatrix=function(){return u.e.TransformNormalToRef(this._defaultUp,this._cameraRotationMatrix,this.upVector),this},t.prototype._getViewMatrix=function(){return this.lockedTarget&&this.setTarget(this._getLockedTargetPosition()),this._updateCameraRotationMatrix(),this.rotationQuaternion&&this._cachedQuaternionRotationZ!=this.rotationQuaternion.z?(this._rotateUpVectorWithCameraRotationMatrix(),this._cachedQuaternionRotationZ=this.rotationQuaternion.z):this._cachedRotationZ!=this.rotation.z&&(this._rotateUpVectorWithCameraRotationMatrix(),this._cachedRotationZ=this.rotation.z),u.e.TransformCoordinatesToRef(this._referencePoint,this._cameraRotationMatrix,this._transformedReferencePoint),this.position.addToRef(this._transformedReferencePoint,this._currentTarget),this.updateUpVectorFromRotation&&(this.rotationQuaternion?ye.a.Y.rotateByQuaternionToRef(this.rotationQuaternion,this.upVector):(u.b.FromEulerVectorToRef(this.rotation,this._tmpQuaternion),ye.a.Y.rotateByQuaternionToRef(this._tmpQuaternion,this.upVector))),this._computeViewMatrix(this.position,this._currentTarget,this.upVector),this._viewMatrix},t.prototype._computeViewMatrix=function(e,n,i){if(this.ignoreParentScaling){if(this.parent){var o=this.parent.getWorldMatrix();u.e.TransformCoordinatesToRef(e,o,this._globalPosition),u.e.TransformCoordinatesToRef(n,o,this._tmpTargetVector),u.e.TransformNormalToRef(i,o,this._tmpUpVector),this._markSyncedWithParent()}else this._globalPosition.copyFrom(e),this._tmpTargetVector.copyFrom(n),this._tmpUpVector.copyFrom(i);this.getScene().useRightHandedSystem?u.a.LookAtRHToRef(this._globalPosition,this._tmpTargetVector,this._tmpUpVector,this._viewMatrix):u.a.LookAtLHToRef(this._globalPosition,this._tmpTargetVector,this._tmpUpVector,this._viewMatrix)}else this.getScene().useRightHandedSystem?u.a.LookAtRHToRef(e,n,i,this._viewMatrix):u.a.LookAtLHToRef(e,n,i,this._viewMatrix),this.parent?(o=this.parent.getWorldMatrix(),this._viewMatrix.invert(),this._viewMatrix.multiplyToRef(o,this._viewMatrix),this._viewMatrix.getTranslationToRef(this._globalPosition),this._viewMatrix.invert(),this._markSyncedWithParent()):this._globalPosition.copyFrom(e)},t.prototype.createRigCamera=function(e,n){if(this.cameraRigMode!==gt.a.RIG_MODE_NONE){var i=new t(e,this.position.clone(),this.get
1608Scene());return i.isRigCamera=!0,i.rigParent=this,this.cameraRigMode!==gt.a.RIG_MODE_VR&&this.cameraRigMode!==gt.a.RIG_MODE_WEBVR||(this.rotationQuaternion||(this.rotationQuaternion=new u.b),i._cameraRigParams={},i.rotationQuaternion=new u.b),i}return null},t.prototype._updateRigCameras=function(){var e=this._rigCameras[0],n=this._rigCameras[1];switch(this.computeWorldMatrix(),this.cameraRigMode){case gt.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case gt.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case gt.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case gt.a.RIG_MODE_STEREOSCOPIC_OVERUNDER:case gt.a.RIG_MODE_STEREOSCOPIC_INTERLACED:var i=this.cameraRigMode===gt.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED?1:-1,o=this.cameraRigMode===gt.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED?-1:1;this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle*i,e),this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle*o,n);break;case gt.a.RIG_MODE_VR:e.rotationQuaternion?(e.rotationQuaternion.copyFrom(this.rotationQuaternion),n.rotationQuaternion.copyFrom(this.rotationQuaternion)):(e.rotation.copyFrom(this.rotation),n.rotation.copyFrom(this.rotation)),e.position.copyFrom(this.position),n.position.copyFrom(this.position)}r.prototype._updateRigCameras.call(this)},t.prototype._getRigCamPositionAndTarget=function(e,n){this.getTarget().subtractToRef(this.position,t._TargetFocalPoint),t._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);var i=t._TargetFocalPoint.addInPlace(this.position);u.a.TranslationToRef(-i.x,-i.y,-i.z,t._TargetTransformMatrix),t._TargetTransformMatrix.multiplyToRef(u.a.RotationAxis(n.upVector,e),t._RigCamTransformMatrix),u.a.TranslationToRef(i.x,i.y,i.z,t._TargetTransformMatrix),t._RigCamTransformMatrix.multiplyToRef(t._TargetTransformMatrix,t._RigCamTransformMatrix),u.e.TransformCoordinatesToRef(this.position,t._RigCamTransformMatrix,n.position),n.setTarget(i)},t.prototype.getClassName=function(){return"TargetCamera"},t._RigCamTransformMatrix=new u.a,t._TargetTransformMatrix=new u.a,t._TargetFocalPoint=new u.e,Object(c.c)([Object(L.o)()],t.prototype,"rotation",void 0),Object(c.c)([Object(L.c)()],t.prototype,"speed",void 0),Object(c.c)([Object(L.k)("lockedTargetId")],t.prototype,"lockedTarget",void 0),t}(gt.a),Hn=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 u.e(.5,1,.5),a.ellipsoidOffset=new u.e(0,0,0),a.checkCollisions=!1,a.applyGravity=!1,a._needMoveForGravity=!1,a._oldPosition=u.e.Zero(),a._diffPosition=u.e.Zero(),a._newPosition=u.e.Zero(),a._collisionMask=-1,a._onCollisionPositionChange=function(s,d,p){p===void 0&&(p=null);var y;y=d,a._newPosition.copyFrom(y),a._newPosition.subtractToRef(a._oldPosition,a._diffPosition),a._diffPosition.length()>Ue.a.CollisionsEpsilon&&(a.position.addInPlace(a._diffPosition),a.onCollide&&p&&a.onCollide(p))},a.inputs=new $r(a),a.inputs.addKeyboard().addMouse(),a}return Object(c.d)(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}
1608),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}
1608),t.prototype.attachControl=function(e,n){n=Ye.b.BackCompatCameraNoPreventDefault(arguments),this.inputs.attachElement(n)},t.prototype.detachControl=function(e){this.inputs.detachElement(),this.cameraDirection=new u.e(0,0,0),this.cameraRotation=new u.d(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?u.e.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=u.e.Zero(),this._transformedDirection=u.e.Zero()),this.inputs.checkInputs(),r.prototype._checkInputs.call(this)},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"},Object(c.c)([Object(L.o)()],t.prototype,"ellipsoid",void 0),Object(c.c)([Object(L.o)()],t.prototype,"ellipsoidOffset",void 0),Object(c.c)([Object(L.c)()],t.prototype,"checkCollisions",void 0),Object(c.c)([Object(L.c)()],t.prototype,"applyGravity",void 0),t}(Ii);Q.a.AddNodeConstructor("TouchCamera",function(r,t){return function(){return new ds(r,u.e.Zero(),t)}});var ds=function(r){function t(e,n,i){var o=r.call(this,e,n,i)||this;return o.inputs.addTouch(),o._setupInputs(),o}return Object(c.d)(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=!1:e.allowMouse=!0},t}(Hn);Q.a.AddNodeConstructor("ArcRotateCamera",function(r,t){return function(){return new Zi(r,0,0,1,u.e.Zero(),t)}});var Zi=function(r){function t(e,n,i,o,a,s,d){d===void 0&&(d=!0);var p=r.call(this,e,u.e.Zero(),s,d)||this;return p.inertialAlphaOffset=0,p.inertialBetaOffset=0,p.inertialRadiusOffset=0,p.lowerAlphaLimit=null,p.upperAlphaLimit=null,p.lowerBetaLimit=.01,p.upperBetaLimit=Math.PI-.01,p.lowerRadiusLimit=null,p.upperRadiusLimit=null,p.inertialPanningX=0,p.inertialPanningY=0,p.pinchToPanMaxDistance=20,p.panningDistanceLimit=null,p.panningOriginTarget=u.e.Zero(),p.panningInertia=.9,p.zoomOnFactor=1,p.targetScreenOffset=u.d.Zero(),p.allowUpsideDown=!0,p.useInputToRestoreState=!0,p._viewMatrix=new u.a,p.panningAxis=new u.e(1,1,0),p.onMeshTargetChangedObservable=new x.c,p.checkCollisions=!1,p.collisionRadius=new u.e(.5,.5,.5),p._previousPosition=u.e.Zero(),p._collisionVelocity=u.e.Zero(),p._newPosition=u.e.Zero(),p._computationVector=u.e.Zero(),p._onCollisionPositionChange=function(y,P,O){O===void 0&&(O=null),O?(p.setPosition(P),p.onCollide&&p.onCollide(O)):p._previousPosition.copyFrom(p._position);
1608var U=Math.cos(p.alpha),F=Math.sin(p.alpha),z=Math.cos(p.beta),J=Math.sin(p.beta);J===0&&(J=1e-4);var ie=p._getTargetPosition();p._computationVector.copyFromFloats(p.radius*U*J,p.radius*z,p.radius*F*J),ie.addToRef(p._computationVector,p._newPosition),p._position.copyFrom(p._newPosition);var se=p.upVector;p.allowUpsideDown&&p.beta<0&&(se=(se=se.clone()).negate()),p._computeViewMatrix(p._position,ie,se),p._viewMatrix.addAtIndex(12,p.targetScreenOffset.x),p._viewMatrix.addAtIndex(13,p.targetScreenOffset.y),p._collisionTriggered=!1},p._target=u.e.Zero(),a&&p.setTarget(a),p.alpha=n,p.beta=i,p.radius=o,p.getViewMatrix(),p.inputs=new Uo(p),p.inputs.addKeyboard().addMouseWheel().addPointers(),p}return Object(c.d)(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,"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 u.a,this._upToYMatrix=new u.a,this._upVector=u.e.Zero()),e.normalize(),this._upVector.copyFrom(e),this.setMatUp()},enumerable:!1,configurable:!0}),t.prototype.setMatUp=function(){u.a.RotationAlignToRef(u.e.UpReadOnly,this._upVector,this._YToUpMatrix),u.a.RotationAlignToRef(this._upVector,u.e.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}
1608),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,"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 Sl,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 Al,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 El,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 u.e(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=u.d.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.absolutePosition;this._targetBoundingCenter?e.addToRef(this._targetBoundingCenter,this._target):this._target.copyFrom(e)}var n=this._getLockedTargetPosition();return n||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!!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.radiu
1608s===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),n=Ye.b.BackCompatCameraNoPreventDefault(arguments),this._useCtrlForPanning=i,this._panningMouseButton=o,typeof arguments[0]=="boolean"&&(arguments.length>1&&(this._useCtrlForPanning=arguments[1]),arguments.length>2&&(this._panningMouseButton=arguments[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(e){this.inputs.detachElement(),this._reset&&this._reset()},t.prototype._checkInputs=function(){if(!this._collisionTriggered){if(this.inputs.checkInputs(),this.inertialAlphaOffset!==0||this.inertialBetaOffset!==0||this.inertialRadiusOffset!==0){var e=this.inertialAlphaOffset;this.beta<=0&&(e*=-1),this.getScene().useRightHandedSystem&&(e*=-1),this.parent&&this.parent._getWorldMatrixDeterminant()<0&&(e*=-1),this.alpha+=e,this.beta+=this.inertialBetaOffset,this.radius-=this.inertialRadiusOffset,this.inertialAlphaOffset*=this.inertia,this.inertialBetaOffset*=this.inertia,this.inertialRadiusOffset*=this.inertia,Math.abs(this.inertialAlphaOffset)<Gt.a&&(this.inertialAlphaOffset=0),Math.abs(this.inertialBetaOffset)<Gt.a&&(this.inertialBetaOffset=0),Math.abs(this.inertialRadiusOffset)<this.speed*Gt.a&&(this.inertialRadiusOffset=0)}(this.inertialPanningX!==0||this.inertialPanningY!==0)&&(this._localDirection||(this._localDirection=u.e.Zero(),this._transformedDirection=u.e.Zero()),this._localDirection.copyFromFloats(this.inertialPanningX,this.inertialPanningY,this.inertialPanningY),this._localDirection.multiplyInPlace(this.panningAxis),this._viewMatrix.invertToRef(this._cameraTransformMatrix),u.e.TransformNormalToRef(this._localDirection,this._cameraTransformMatrix,this._transformedDirection),this.panningAxis.y||(this._transformedDirection.y=0),!this._targetHost&&(this.panningDistanceLimit?(this._transformedDirection.addInPlace(this._target),u.e.DistanceSquared(this._transformedDirection,this.panningOriginTarget)<=this.panningDistanceLimit*this.panningDistanceLimit&&this._target.copyFrom(this._transformedDirection)):this._target.addInPlace(this._transformedDirection)),this.inertialPanningX*=this.panningInertia,this.inertialPanningY*=this.panningInertia,Math.abs(this.inertialPanningX)<this.speed*Gt.a&&(this.inertialPanningX=0),Math.abs(this.inertialPanningY)<this.speed*Gt.a&&(this.inertialPanningY=0)),this._checkLimits(),r.prototype._checkInputs.call(this)}},t.prototype._checkLimits=function(){this.lowerBetaLimit===null||this.lowerBetaLimit===void 0?this.allowUpsideDown&&this.beta>Math.PI&&(this.beta=this.beta-2*Math.PI):this.beta<this.lowerBetaLimit&&(this.beta=this.lowerBetaLimit),this.upperBetaLimit===null||this.upperBetaLimit===void 0?this.allowUpsideDown&&this.beta<-Math.PI&&(this.beta=this.beta+2*Math.PI):this.beta>this.upperBetaLimit&&(this.beta=this.upperBetaLimit),this.lowerAlphaLimit!==null&&this.alpha<this.lowerAlphaLimit&&(this.alpha=this.lowerAlphaLimit),this.upperAlphaLimit!==null&&this.alpha>this.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),this.lowerRadiusLimit!==null&&this.radius<this.lowerRadiusLimit&&(this.radius=this.lowerRadiusLimit,this.inertialRadiusOffset=0),this.upperRadiusLimit!==null&&this.radius>this.upperRadiusLimit&&(this.radius=this.upperRadiusLimit,this.inertialRadiusOffset=0)},t.prototype.rebuildAnglesAndRadius=function(){this._position.subtractToRef(this._getTargetPosition(),this._computationVector),this._upVector.x===0&&this._upVector.y===1&&this._upVector.z===0||u.e.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){if(n===void 0&&(n=!1),i===void 0&&(i=!1),e.getBoundingInfo)this._targetBoundingCenter=n?e.getBoundingInfo().boundingBox.centerWorld.clone():null,e.computeWorldMatrix(),this._targetHost=e,this._target=this._getTargetPosition(),this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);else{var o=e,a=this._getTargetPosition();if(a&&!i&&a.equals(o))return;this._targetHost=null,this._target=o,this._targetBoundingCenter=null,this.onMeshTargetChangedObservable.notifyObservers(null)}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||u.e.TransformCoordinatesToRef(this._computationVector,this._YToUpMatrix,this._computationVector),a.addToRef(this._computationVector,this._newPosition),this.get
1608Scene().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 d=this.upVector;this.allowUpsideDown&&o<0&&(d=d.negate()),this._computeViewMatrix(this._position,a,d),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=De.a.MinMax(e),o=u.e.Distance(i.min,i.max);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.get
1608Scene().meshes;i=De.a.MinMax(a),o=u.e.Distance(i.min,i.max)}else i=e,o=e.distance;this._target=De.a.Center(i),n||(this.maxZ=2*o)},t.prototype.createRigCamera=function(e,n){var i=0;switch(this.cameraRigMode){case gt.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case gt.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case gt.a.RIG_MODE_STEREOSCOPIC_OVERUNDER:case gt.a.RIG_MODE_STEREOSCOPIC_INTERLACED:case gt.a.RIG_MODE_VR:i=this._cameraRigParams.stereoHalfAngle*(n===0?1:-1);break;case gt.a.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},t.prototype._updateRigCameras=function(){var e=this._rigCameras[0],n=this._rigCameras[1];switch(e.beta=n.beta=this.beta,this.cameraRigMode){case gt.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case gt.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case gt.a.RIG_MODE_STEREOSCOPIC_OVERUNDER:case gt.a.RIG_MODE_STEREOSCOPIC_INTERLACED:case gt.a.RIG_MODE_VR:e.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,n.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle;break;case gt.a.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.dispose=function(){this.inputs.clear(),r.prototype.dispose.call(this)},t.prototype.getClassName=function(){return"ArcRotateCamera"},Object(c.c)([Object(L.c)()],t.prototype,"alpha",void 0),Object(c.c)([Object(L.c)()],t.prototype,"beta",void 0),Object(c.c)([Object(L.c)()],t.prototype,"radius",void 0),Object(c.c)([Object(L.o)("target")],t.prototype,"_target",void 0),Object(c.c)([Object(L.c)()],t.prototype,"inertialAlphaOffset",void 0),Object(c.c)([Object(L.c)()],t.prototype,"inertialBetaOffset",void 0),Object(c.c)([Object(L.c)()],t.prototype,"inertialRadiusOffset",void 0),Object(c.c)([Object(L.c)()],t.prototype,"lowerAlphaLimit",void 0),Object(c.c)([Object(L.c)()],t.prototype,"upperAlphaLimit",void 0),Object(c.c)([Object(L.c)()],t.prototype,"lowerBetaLimit",void 0),Object(c.c)([Object(L.c)()],t.prototype,"upperBetaLimit",void 0),Object(c.c)([Object(L.c)()],t.prototype,"lowerRadiusLimit",void 0),Object(c.c)([Object(L.c)()],t.prototype,"upperRadiusLimit",void 0),Object(c.c)([Object(L.c)()],t.prototype,"inertialPanningX",void 0),Object(c.c)([Object(L.c)()],t.prototype,"inertialPanningY",void 0),Object(c.c)([Object(L.c)()],t.prototype,"pinchToPanMaxDistance",void 0),Object(c.c)([Object(L.c)()],t.prototype,"panningDistanceLimit",void 0),Object(c.c)([Object(L.o)()],t.prototype,"panningOriginTarget",void 0),Object(c.c)([Object(L.c)()],t.prototype,"panningInertia",void 0),Object(c.c)([Object(L.c)()],t.prototype,"zoomOnFactor",void 0),Object(c.c)([Object(L.c)()],t.prototype,"targetScreenOffset",void 0),Object(c.c)([Object(L.c)()],t.prototype,"allowUpsideDown",void 0),Object(c.c)([Object(L.c)()],t.prototype,"useInputToRestoreState",void 0),t}(Ii);Q.a.AddNodeConstructor("DeviceOrientationCamera",function(r,t){return function(){return new Vo(r,u.e.Zero(),t)}});var Vo=function(r){function t(e,n,i){var o=r.call(this,e,n,i)||this;return o._tmpDragQuaternion=new u.b,o._disablePointerInputWhenUsingDeviceOrientation=!0,o._dragFactor=0,o._quaternionCache=new u.b,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 u.b),u.b.FromEulerAnglesToRef(0,a.offsetX*o._dragFactor,0,o._tmpDragQuaternion),o._initialQuaternion.multiplyToRef(o._tmpDragQuaternion,o._initialQuaternion))}))}),o}return Object(c.d)(t,r),Object.defineProperty(t.prototype,"disablePointerInputWhenUsingDeviceOrientation",{get:function(){return this._disablePointerInputWhenUsingDeviceOrientation},set:function(e){this._disablePointerInputWhenUsingDeviceOrientation=e}
1608,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=ye.a.Y),this.rotationQuaternion&&(this._initialQuaternion||(this._initialQuaternion=new u.b),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}(Hn),Dl=function(r){function t(e){return r.call(this,e)||this}return Object(c.d)(t,r),t.prototype.addKeyboard=function(){return this.add(new $a),this},t.prototype.addMouse=function(e){return e===void 0&&(e=!0),this.add(new es(e)),this},t}(Jr),sp=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 u.e(1,1,1),a.ellipsoidOffset=new u.e(0,0,0),a.checkCollisions=!1,a.applyGravity=!1,a.cameraDirection=u.e.Zero(),a._trackRoll=0,a.rollCorrect=100,a.bankedTurn=!1,a.bankedTurnLimit=Math.PI/2,a.bankedTurnMultiplier=1,a._needMoveForGravity=!1,a._oldPosition=u.e.Zero(),a._diffPosition=u.e.Zero(),a._newPosition=u.e.Zero(),a._collisionMask=-1,a._onCollisionPositionChange=function(s,d,p){p===void 0&&(p=null);var y;y=d,a._newPosition.copyFrom(y),a._newPosition.subtractToRef(a._oldPosition,a._diffPosition),a._diffPosition.length()>Ue.a.CollisionsEpsilon&&(a.position.addInPlace(a._diffPosition),a.onCollide&&p&&a.onCollide(p))},a.inputs=new Dl(a),a.inputs.addKeyboard().addMouse(),a}return Object(c.d)(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}
1608),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=Ye.b.BackCompatCameraNoPreventDefault(arguments),this.inputs.attachElement(n)},t.prototype.detachControl=function(){this.inputs.detachElement(),this.cameraDirection=new u.e(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?u.e.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=u.e.Zero(),this._transformedDirection=u.e.Zero()),this.inputs.checkInputs(),r.prototype._checkInputs.call(this)},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"},Object(c.c)([Object(L.o)()],t.prototype,"ellipsoid",void 0),Object(c.c)([Object(L.o)()],t.prototype,"ellipsoidOffset",void 0),Object(c.c)([Object(L.c)()],t.prototype,"checkCollisions",void 0),Object(c.c)([Object(L.c)()],t.prototype,"applyGravity",void 0),t}(Ii),Ll=function(r){function t(e){return r.call(this,e)||this}return Object(c.d)(t,r),t.prototype.addKeyboard=function(){return this.add(new ts),this},t.prototype.addMouseWheel=function(){return this.add(new ns),this},t.prototype.addPointers=function(){return this.add(new is),this},t.prototype.addVRDeviceOrientation=function(){return console.warn("DeviceOrientation support not yet implemented for FollowCamera."),this},t}(Jr);Q.a.AddNodeConstructor("FollowCamera",function(r,t){return function(){return new Nl(r,u.e.Zero(),t)}}),Q.a.AddNodeConstructor("ArcFollowCamera",function(r,t){return function(){return new wl(r,0,0,1,null,t)}});var ei,Nl=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.lowerHe
1608ightOffsetLimit=null,a.upperHeightOffsetLimit=null,a.cameraAcceleration=.05,a.maxCameraSpeed=20,a.lockedTarget=o,a.inputs=new Ll(a),a.inputs.addKeyboard().addMouseWheel().addPointers(),a}return Object(c.d)(t,r),t.prototype._follow=function(e){if(e){var n;if(e.rotationQuaternion){var i=new u.a;e.rotationQuaternion.toRotationMatrix(i),n=Math.atan2(i.m[8],i.m[10])}else n=e.rotation.y;var o=Ye.b.ToRadians(this.rotationOffset)+n,a=e.getAbsolutePosition(),s=a.x+Math.sin(o)*this.radius,d=a.z+Math.cos(o)*this.radius,p=s-this.position.x,y=a.y+this.heightOffset-this.position.y,P=d-this.position.z,O=p*this.cameraAcceleration*2,U=y*this.cameraAcceleration,F=P*this.cameraAcceleration*2;(O>this.maxCameraSpeed||O<-this.maxCameraSpeed)&&(O=O<1?-this.maxCameraSpeed:this.maxCameraSpeed),(U>this.maxCameraSpeed||U<-this.maxCameraSpeed)&&(U=U<1?-this.maxCameraSpeed:this.maxCameraSpeed),(F>this.maxCameraSpeed||F<-this.maxCameraSpeed)&&(F=F<1?-this.maxCameraSpeed:this.maxCameraSpeed),this.position=new u.e(this.position.x+O,this.position.y+U,this.position.z+F),this.setTarget(a)}}
1608,t.prototype.attachControl=function(e,n){n=Ye.b.BackCompatCameraNoPreventDefault(arguments),this.inputs.attachElement(n),this._reset=function(){}},t.prototype.detachControl=function(e){this.inputs.detachElement(),this._reset&&this._reset()},t.prototype._checkInputs=function(){this.inputs.checkInputs(),this._checkLimits(),r.prototype._checkInputs.call(this),this.lockedTarget&&this._follow(this.lockedTarget)},t.prototype._checkLimits=function(){this.lowerRadiusLimit!==null&&this.radius<this.lowerRadiusLimit&&(this.radius=this.lowerRadiusLimit),this.upperRadiusLimit!==null&&this.radius>this.upperRadiusLimit&&(this.radius=this.upperRadiusLimit),this.lowerHeightOffsetLimit!==null&&this.heightOffset<this.lowerHeightOffsetLimit&&(this.heightOffset=this.lowerHeightOffsetLimit),this.upperHeightOffsetLimit!==null&&this.heightOffset>this.upperHeightOffsetLimit&&(this.heightOffset=this.upperHeightOffsetLimit),this.lowerRotationOffsetLimit!==null&&this.rotationOffset<this.lowerRotationOffsetLimit&&(this.rotationOffset=this.lowerRotationOffsetLimit),this.upperRotationOffsetLimit!==null&&this.rotationOffset>this.upperRotationOffsetLimit&&(this.rotationOffset=this.upperRotationOffsetLimit)},t.prototype.getClassName=function(){return"FollowCamera"},Object(c.c)([Object(L.c)()],t.prototype,"radius",void 0),Object(c.c)([Object(L.c)()],t.prototype,"lowerRadiusLimit",void 0),Object(c.c)([Object(L.c)()],t.prototype,"upperRadiusLimit",void 0),Object(c.c)([Object(L.c)()],t.prototype,"rotationOffset",void 0),Object(c.c)([Object(L.c)()],t.prototype,"lowerRotationOffsetLimit",void 0),Object(c.c)([Object(L.c)()],t.prototype,"upperRotationOffsetLimit",void 0),Object(c.c)([Object(L.c)()],t.prototype,"heightOffset",void 0),Object(c.c)([Object(L.c)()],t.prototype,"lowerHeightOffsetLimit",void 0),Object(c.c)([Object(L.c)()],t.prototype,"upperHeightOffsetLimit",void 0),Object(c.c)([Object(L.c)()],t.prototype,"cameraAcceleration",void 0),Object(c.c)([Object(L.c)()],t.prototype,"maxCameraSpeed",void 0),Object(c.c)([Object(L.k)("lockedTargetId")],t.prototype,"lockedTarget",void 0),t}(Ii),wl=function(r){function t(e,n,i,o,a,s){var d=r.call(this,e,u.e.Zero(),s)||this;return d.alpha=n,d.beta=i,d.radius=o,d._cartesianCoordinates=u.e.Zero(),d._meshTarget=a,d._follow(),d}return Object(c.d)(t,r),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}(Ii),fs=f(38),dn=f(39);(function(r){r[r.VIVE=0]="VIVE",r[r.OCULUS=1]="OCULUS",r[r.WINDOWS=2]="WINDOWS",r[r.GEAR_VR=3]="GEAR_VR",r[r.DAYDREAM=4]="DAYDREAM",r[r.GENERIC=5]="GENERIC"})(ei||(ei={}));var Cn,Ji,Di=function(){function r(){}return r.InitiateController=function(t){for(var e=0,n=this._ControllerFactories;e<n.length;e++){var i=n[e];if(i.canCreate(t))return i.create(t)}if(this._DefaultControllerFactory)return this._DefaultControllerFactory(t);throw"The type of gamepad you are trying to load needs to be imported first or is not supported."},r._ControllerFactories=[],r._DefaultControllerFactory=null,r}(),fr=function(r){function t(e){var n=r.call(this,e.id,e.index,e)||this;return n.isXR=!1,n._deviceRoomPosition=u.e.Zero(),n._deviceRoomRotationQuaternion=new u.b,n.devicePosition=u.e.Zero(),n.deviceRotationQuaternion=new u.b,n.deviceScaleFactor=1,n._trackPosition=!0,n._maxRotationDistFromHeadset=Math.PI/5,n._draggedRoomRotation=0,n._leftHandSystemQuaternion=new u.b,n._deviceToWorld=u.a.Identity(),n._pointingPoseNode=null,n._workingMatrix=u.a.Identity(),n._meshAttachedObservable=new x.c,n.type=hn.POSE_ENABLED,n.controllerType=ei.GENERIC,n.position=u.e.Zero(),n.rotationQuaternion=new u.b,n._calculatedPosition=u.e.Zero(),n._calculatedRotation=new u.b,u.b.RotationYawPitchRollToRef(Math.PI,0,0,n._leftHandSystemQuaternion),n}return Object(c.d)(t,r),t.prototype._disableTrackPosition=function(e){this._trackPosition&&(this._calculatedPosition.copyFrom(e),this._trackPosition=!1)},t.prototype.update=function(){r.prototype.update.call(this),this._updatePoseAndMesh()},t.prototype._updatePoseAndMesh=function(){if(!this.isXR){var e=this.browserGamepad.pose;if(this.updateFromDevice(e),!this._trackPosition&&te.a.LastCreatedScene&&te.a.LastCreatedScene.activeCamera&&te.a.LastCreatedScene.activeCamera.devicePosition&&((n=te.a.LastCreatedScene.activeCamera)._computeDevicePosition(),this._deviceToWorld.setTranslation(n.devicePosition),n.deviceRotationQuaternion)){var n;(n=n)._deviceRoomRotationQuaternion.toEulerAnglesToRef(u.c.Vector3[0]);var i=Math.atan2(Math.sin(u.c.Vector3[0].y-this._draggedRoomRotation),Math.cos(u.c.Vector3[0].y-this._draggedRoomRotation));if(Math.abs(i)>this._maxRotationDistFromHeadset){var o=i-(i<0?-this._maxRotationDistFromHeadset:this._maxRotationDistFromHeadset);this._draggedRoomRotation+=o;var a=Math.sin(-o),s=Math.cos(-o);this._calculatedPosition.x=this._calculatedPosition.x*s-this._calculatedPosition.z*a,this._calculatedPosition.z=this._calculatedPosition.x*a+this._calculatedPosition.z*s}}u.e.TransformCoordinatesToRef(this._calculatedPosition,this._deviceToWorld,this.devicePosition),this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix),u.b.FromRotationMatrixToRef(this._workingMatrix,this.deviceRotationQuaternion),this.deviceRotationQuaternion.multiplyInPlace(this._calculatedRotation),this._mesh&&(this._mesh.position.copyFrom(this.devicePosition),this._mesh.rotationQuaternion&&this._mesh.rotationQuaternion.copyFrom(this.deviceRotationQuaternion))}},t.prototype.updateFromDevice=function(e){if(!this.isXR&&e){this.rawPose=e,e.position&&(this._deviceRoomPosition.copyFromFloats(e.position[0],e.position[1],-e.position[2]),this._mesh&&this._mesh.getScene().useRightHandedSystem&&(this._deviceRoomPosition.z*=-1),this._trackPosition&&this._deviceRoomPosition.scaleToRef(this.deviceScaleFactor,this._calculatedPosition),this._calculatedPosition.addInPlace(this.position));var n=this.rawPose;e.orientation&&n.orientation&&n.orientation.length===4&&(this._deviceRoomRotationQuaternion.copyFromFloats(n.orientation[0],n.orientation[1],-n.orientation[2],-n.orientation[3]),this._mesh&&(this._mesh.getScene().useRightHandedSystem?(this._deviceRoomRotationQuaternion.z*=-1,this._deviceRoomRotationQuaternion.w*=-1):this._deviceRoomRotationQuaternion.multiplyToRef(this._leftHandSystemQuaternion,this._deviceRoomRotationQuaternion)),this._deviceRoomRotationQuaternion.multiplyToRef(this.rotationQuaternion,this._calculatedRotation))}},t.prototype.attachToMesh=function(e){if(this._mesh&&(this._mesh.parent=null),this._mesh=e,this._poseControlledCamera&&(this._mesh.parent=this._poseControlledCamera),this._mesh.rotationQuaternion||(this._mesh.rotationQuaternion=new u.b),
1608!this.isXR&&(this._updatePoseAndMesh(),this._pointingPoseNode)){for(var n=[],i=this._pointingPoseNode;i.parent;)n.push(i.parent),i=i.parent;n.reverse().forEach(function(o){o.computeWorldMatrix(!0)})}this._meshAttachedObservable.notifyObservers(e)},t.prototype.attachToPoseControlledCamera=function(e){this._poseControlledCamera=e,this._mesh&&(this._mesh.parent=this._poseControlledCamera)},t.prototype.dispose=function(){this._mesh&&this._mesh.dispose(),this._mesh=null,r.prototype.dispose.call(this)},Object.defineProperty(t.prototype,"mesh",{get:function(){return this._mesh},enumerable:!1,configurable:!0}),t.prototype.getForwardRay=function(e){if(e===void 0&&(e=100),!this.mesh)return new dn.a(u.e.Zero(),new u.e(0,0,1),e);var n=this._pointingPoseNode?this._pointingPoseNode.getWorldMatrix():this.mesh.getWorldMatrix(),i=n.getTranslation(),o=new u.e(0,0,-1),a=u.e.TransformNormal(o,n),s=u.e.Normalize(a);return new dn.a(i,s,e)},t.POINTING_POSE="POINTING_POSE",t}(hn);(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"})(Cn||(Cn={})),function(r){r[r.Up=12]="Up",r[r.Down=13]="Down",r[r.Left=14]="Left",r[r.Right=15]="Right"}(Ji||(Ji={}));var Gn,$i,Fl=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 x.c,a.onButtonUpObservable=new x.c,a.onPadDownObservable=new x.c,a.onPadUpObservable=new x.c,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=hn.XBOX,a._isXboxOnePad=o,a}return Object(c.d)(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,Cn.A)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonB",{get:function(){return this._buttonB},set:function(e){this._buttonB=this._setButtonValue(e,this._buttonB,Cn.B)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonX",{get:function(){return this._buttonX},set:function(e){this._buttonX=this._setButtonValue(e,this._buttonX,Cn.X)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonY",{get:function(){return this._buttonY},set:function(e){this._buttonY=this._setButtonValue(e,this._buttonY,Cn.Y)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonStart",{get:function(){return this._buttonStart},set:function(e){this._buttonStart=this._setButtonValue(e,this._buttonStart,Cn.Start)}
1608,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonBack",{get:function(){return this._buttonBack},set:function(e){this._buttonBack=this._setButtonValue(e,this._buttonBack,Cn.Back)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonLB",{get:function(){return this._buttonLB},set:function(e){this._buttonLB=this._setButtonValue(e,this._buttonLB,Cn.LB)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonRB",{get:function(){return this._buttonRB},set:function(e){this._buttonRB=this._setButtonValue(e,this._buttonRB,Cn.RB)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonLeftStick",{get:function(){return this._buttonLeftStick},set:function(e){this._buttonLeftStick=this._setButtonValue(e,this._buttonLeftStick,Cn.LeftStick)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonRightStick",{get:function(){return this._buttonRightStick},set:function(e){this._buttonRightStick=this._setButtonValue(e,this._buttonRightStick,Cn.RightStick)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadUp",{get:function(){return this._dPadUp},set:function(e){this._dPadUp=this._setDPadValue(e,this._dPadUp,Ji.Up)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadDown",{get:function(){return this._dPadDown},set:function(e){this._dPadDown=this._setDPadValue(e,this._dPadDown,Ji.Down)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadLeft",{get:function(){return this._dPadLeft},set:function(e){this._dPadLeft=this._setDPadValue(e,this._dPadLeft,Ji.Left)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadRight",{get:function(){return this._dPadRight},set:function(e){this._dPadRight=this._setDPadValue(e,this._dPadRight,Ji.Right)},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}(hn);(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"})(Gn||(Gn={})),function(r){r[r.Up=12]="Up",r[r.Down=13]="Down",r[r.Left=14]="Left",r[r.Right=15]="Right"}($i||($i={}));var Bl=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 x.c,o.onButtonUpObservable=new x.c,o.onPadDownObservable=new x.c,o.onPadUpObservable=new x.c,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=hn.DUALSHOCK,o}return Object(c.d)(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}
1608,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,Gn.Cross)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonCircle",{get:function(){return this._buttonCircle},set:function(e){this._buttonCircle=this._setButtonValue(e,this._buttonCircle,Gn.Circle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonSquare",{get:function(){return this._buttonSquare},set:function(e){this._buttonSquare=this._setButtonValue(e,this._buttonSquare,Gn.Square)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonTriangle",{get:function(){return this._buttonTriangle},set:function(e){this._buttonTriangle=this._setButtonValue(e,this._buttonTriangle,Gn.Triangle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonOptions",{get:function(){return this._buttonOptions},set:function(e){this._buttonOptions=this._setButtonValue(e,this._buttonOptions,Gn.Options)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonShare",{get:function(){return this._buttonShare},set:function(e){this._buttonShare=this._setButtonValue(e,this._buttonShare,Gn.Share)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonL1",{get:function(){return this._buttonL1},set:function(e){this._buttonL1=this._setButtonValue(e,this._buttonL1,Gn.L1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonR1",{get:function(){return this._buttonR1},set:function(e){this._buttonR1=this._setButtonValue(e,this._buttonR1,Gn.R1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonLeftStick",{get:function(){return this._buttonLeftStick},set:function(e){this._buttonLeftStick=this._setButtonValue(e,this._buttonLeftStick,Gn.LeftStick)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonRightStick",{get:function(){return this._buttonRightStick},set:function(e){this._buttonRightStick=this._setButtonValue(e,this._buttonRightStick,Gn.RightStick)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadUp",{get:function(){return this._dPadUp},set:function(e){this._dPadUp=this._setDPadValue(e,this._dPadUp,$i.Up)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadDown",{get:function(){return this._dPadDown},set:function(e){this._dPadDown=this._setDPadValue(e,this._dPadDown,$i.Down)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadLeft",{get:function(){return this._dPadLeft},set:function(e){this._dPadLeft=this._setDPadValue(e,this._dPadLeft,$i.Left)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadRight",{get:function(){return this._dPadRight},set:function(e){this._dPadRight=this._setDPadValue(e,this._dPadRight,$i.Right)},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}(hn),Ul=function(){function r(t){var e=this;if(this._scene=t,this._babylonGamepads=[],this._oneGamepadConnected=!1,this._isMonitoring=!1,this.onGamepadDisconnectedObservable=new x.c,fs.a.IsWindowObjectExist()?(this._gamepadEventSupported="GamepadEvent"in window,this._gamepadSupport=navigator.getGamepads||navigator.webkitGetGamepads||navigator.msGetGamepads||navigator.webkitGamepads):this._gamepadEventSupported=!1,this.onGamepadConnectedObservable=new x.c(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}
1608,enumerable:!1,configurable:!0}),r.prototype.getGamepadByType=function(t){t===void 0&&(t=hn.XBOX);for(var e=0,n=this._babylonGamepads;e<n.length;e++){var i=n[e];if(i&&i.type===t)return i}return null},r.prototype.dispose=function(){this._gamepadEventSupported&&(this._onGamepadConnectedEvent&&window.removeEventListener("gamepadconnected",this._onGamepadConnectedEvent),this._onGamepadDisconnectedEvent&&window.removeEventListener("gamepaddisconnected",this._onGamepadDisconnectedEvent),this._onGamepadConnectedEvent=null,this._onGamepadDisconnectedEvent=null),this._babylonGamepads.forEach(function(t){t.dispose()}),this.onGamepadConnectedObservable.clear(),this.onGamepadDisconnectedObservable.clear(),this._oneGamepadConnected=!1,this._stopMonitoringGamepads(),this._babylonGamepads=[]},r.prototype._addNewGamepad=function(t){var e;this._oneGamepadConnected||(this._oneGamepadConnected=!0);var n=t.id.search("054c")!==-1,i=t.id.search("Xbox One")!==-1;return e=i||t.id.search("Xbox 360")!==-1||t.id.search("xinput")!==-1?new Fl(t.id,t.index,t,i):n?new Bl(t.id,t.index,t):t.pose?Di.InitiateController(t):new Ol(t.id,t.index,t),this._babylonGamepads[e.index]=e,e},r.prototype._startMonitoringGamepads=function(){this._isMonitoring||(this._isMonitoring=!0,this._scene||this._checkGamepadsStatus())},r.prototype._stopMonitoringGamepads=function(){this._isMonitoring=!1},r.prototype._checkGamepadsStatus=function(){var t=this;for(var e in this._updateGamepadObjects(),this._babylonGamepads){var n=this._babylonGamepads[e];n&&n.isConnected&&n.update()}this._isMonitoring&&!this._scene&&Ue.a.QueueNewFrame(function(){t._checkGamepadsStatus()})},r.prototype._updateGamepadObjects=function(){for(var t=navigator.getGamepads?navigator.getGamepads():navigator.webkitGetGamepads?navigator.webkitGetGamepads():[],e=0;e<t.length;e++){var n=t[e];if(n)if(this._babylonGamepads[n.index])this._babylonGamepads[e].browserGamepad=n,this._babylonGamepads[e].isConnected||(this._babylonGamepads[e]._isConnected=!0,this.onGamepadConnectedObservable.notifyObservers(this._babylonGamepads[e]));else{var i=this._addNewGamepad(n);this.onGamepadConnectedObservable.notifyObservers(i)}}},r}();Object.defineProperty(_e.a.prototype,"gamepadManager",{get:function(){if(!this._gamepadManager){this._gamepadManager=new Ul(this);var r=this._getComponent(st.a.NAME_GAMEPAD);r||(r=new Vl(this),this._addComponent(r))}return this._gamepadManager},enumerable:!0,configurable:!0}),$r.prototype.addGamepad=function(){return this.add(new ls),this},Uo.prototype.addGamepad=function(){return this.add(new Ka),this};var Vl=function(){function r(t){this.name=st.a.NAME_GAMEPAD,this.scene=t}return r.prototype.register=function(){this.scene._beforeCameraUpdateStage.registerStep(st.a.STEP_BEFORECAMERAUPDATE_GAMEPAD,this,this._beforeCameraUpdate)},r.prototype.rebuild=function(){},r.prototype.dispose=function(){var t=this.scene._gamepadManager;t&&(t.dispose(),this.scene._gamepadManager=null)},r.prototype._beforeCameraUpdate=function(){var t=this.scene._gamepadManager;t&&t._isMonitoring&&t._checkGamepadsStatus()},r}();Q.a.AddNodeConstructor("FreeCamera",function(r,t){return function(){return new pr(r,u.e.Zero(),t)}});var pr=function(r){function t(e,n,i){var o=r.call(this,e,n,i)||this;return o.inputs.addGamepad(),o}return Object(c.d)(t,r),Object.defineProperty(t.prototype,"gamepadAngularSensibility",{get:function(){var e=this.inputs.attached.gamepad;return e?e.gamepadAngularSensibility:0},set:function(e){var n=this.inputs.attached.gamepad;n&&(n.gamepadAngularSensibility=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"gamepadMoveSensibility",{get:function(){var e=this.inputs.attached.gamepad;return e?e.gamepadMoveSensibility:0},set:function(e){var n=this.inputs.attached.gamepad;n&&(n.gamepadMoveSensibility=e)},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"UniversalCamera"},t}(ds);gt.a._createDefaultParsedCamera=function(r,t){return new pr(r,u.e.Zero(),t)},Q.a.AddNodeConstructor("GamepadCamera",function(r,t){return function(){return new ko(r,u.e.Zero(),t)}});var ko=function(r){function t(e,n,i){return r.call(this,e,n,i)||this}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"GamepadCamera"},t}(pr),li=f(33),je=f(5),cp=`
1609attribute vec2 position;
1610uniform vec2 scale;
1611
1612varying vec2 vUV;
1613const vec2 madd=vec2(0.5,0.5);
1614void main(void) {
1615vUV=(position*madd+madd)*scale;
1616gl_Position=vec4(position,0.0,1.0);
1617}`;je.a.ShadersStore.postprocessVertexShader=cp;var kl=f(102);Bt.a.prototype.createRenderTargetTexture=function(r,t){var e=new kl.a;t!==void 0&&typeof t=="object"?(e.generateMipMaps=t.generateMipMaps,e.generateDepthBuffer=!!t.generateDepthBuffer,e.generateStencilBuffer=!!t.generateStencilBuffer,e.type=t.type===void 0?h.a.TEXTURETYPE_UNSIGNED_INT:t.type,e.samplingMode=t.samplingMode===void 0?h.a.TEXTURE_TRILINEAR_SAMPLINGMODE:t.samplingMode,e.format=t.format===void 0?h.a.TEXTUREFORMAT_RGBA:t.format):(e.generateMipMaps=t,e.generateDepthBuffer=!0,e.generateStencilBuffer=!1,e.type=h.a.TEXTURETYPE_UNSIGNED_INT,e.samplingMode=h.a.TEXTURE_TRILINEAR_SAMPLINGMODE,e.format=h.a.TEXTUREFORMAT_RGBA),(e.type!==h.a.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(e.type!==h.a.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(e.samplingMode=h.a.TEXTURE_NEAREST_SAMPL
1617INGMODE),e.type!==h.a.TEXTURETYPE_FLOAT||this._caps.textureFloat||(e.type=h.a.TEXTURETYPE_UNSIGNED_INT,l.a.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type"));var n=this._gl,i=new xt.a(this,xt.b.RenderTarget),o=r.width||r,a=r.height||r,s=r.layers||0,d=this._getSamplingParameters(e.samplingMode,!!e.generateMipMaps),p=s!==0?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D,y=this._getRGBABufferInternalSizedFormat(e.type,e.format),P=this._getInternalFormat(e.format),O=this._getWebGLTextureType(e.type);this._bindTextureDirectly(p,i),s!==0?(i.is2DArray=!0,n.texImage3D(p,0,y,o,a,s,0,P,O,null)):n.texImage2D(p,0,y,o,a,0,P,O,null),n.texParameteri(p,n.TEXTURE_MAG_FILTER,d.mag),n.texParameteri(p,n.TEXTURE_MIN_FILTER,d.min),n.texParameteri(p,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(p,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),e.generateMipMaps&&this._gl.generateMipmap(p),this._bindTextureDirectly(p,null);var U=this._currentFramebuffer,F=n.createFramebuffer();return this._bindUnboundFramebuffer(F),i._depthStencilBuffer=this._setupFramebufferDepthAttachments(!!e.generateStencilBuffer,e.generateDepthBuffer,o,a),i.is2DArray||n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,i._webGLTexture,0),this._bindUnboundFramebuffer(U),i._framebuffer=F,i.baseWidth=o,i.baseHeight=a,i.width=o,i.height=a,i.depth=s,i.isReady=!0,i.samples=1,i.generateMipMaps=!!e.generateMipMaps,i.samplingMode=e.samplingMode,i.type=e.type,i.format=e.format,i._generateDepthBuffer=e.generateDepthBuffer,i._generateStencilBuffer=!!e.generateStencilBuffer,this._internalTexturesCache.push(i),i},Bt.a.prototype.createDepthStencilTexture=function(r,t){if(t.isCube){var e=r.width||r;return this._createDepthStencilCubeTexture(e,t)}return this._createDepthStencilTexture(r,t)},Bt.a.prototype._createDepthStencilTexture=function(r,t){var e=this._gl,n=r.layers||0,i=n!==0?e.TEXTURE_2D_ARRAY:e.TEXTURE_2D,o=new xt.a(this,xt.b.Depth);if(!this._caps.depthTextureExtension)return l.a.Error("Depth texture is not supported by your browser or hardware."),o;var a=Object(c.a)({bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1},t);this._bindTextureDirectly(i,o,!0),this._setupDepthStencilTexture(o,r,a.generateStencil,a.bilinearFiltering,a.comparisonFunction);var s=a.generateStencil?e.UNSIGNED_INT_24_8:e.UNSIGNED_INT,d=a.generateStencil?e.DEPTH_STENCIL:e.DEPTH_COMPONENT,p=d;return this.webGLVersion>1&&(p=a.generateStencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24),o.is2DArray?e.texImage3D(i,0,p,o.width,o.height,n,0,d,s,null):e.texImage2D(i,0,p,o.width,o.height,0,d,s,null),this._bindTextureDirectly(i,null),o};var _t=function(){function r(t,e,n,i,o,a,s,d,p,y,P,O,U,F,z){s===void 0&&(s=h.a.TEXTURE_NEAREST_SAMPLINGMODE),y===void 0&&(y=null),P===void 0&&(P=h.a.TEXTURETYPE_UNSIGNED_INT),O===void 0&&(O="postprocess"),F===void 0&&(F=!1),z===void 0&&(z=h.a.TEXTUREFORMAT_RGBA),this.width=-1,this.height=-1,this.nodeMaterialSource=null,this._outputTexture=null,this.autoClear=!0,this.alphaMode=h.a.ALPHA_DISABLE,this.animations=new Array,this.enablePixelPerfectMode=!1,this.forceFullscreenViewport=!0,this.scaleMode=h.a.SCALEMODE_FLOOR,this.alwaysForcePOT=!1,this._samples=1,this.adaptScaleToCurrentViewport=!1,this._reusable=!1,this._textures=new li.a(2),this._currentRenderTextureInd=0,this._scaleRatio=new u.d(1,1),this._texelSize=u.d.Zero(),this.onActivateObservable=new x.c,this.onSizeChangedObservable=new x.c,this.onApplyObservable=new x.c,this.onBeforeRenderObservable=new x.c,this.onAfterRenderObservable=new x.c,this.name=t,a!=null?(this._camera=a,this._scene=a.getScene(),a.attachPostProcess(this),this._engine=this._scene.getEngine(),this._scene.postProcesses.push(this),this.uniqueId=this._scene.getUniqueId()):d&&(this._engine=d,this._engine.postProcesses.push(this)),this._options=o,this.renderTargetSamplingMode=s||h.a.TEXTURE_NEAREST_SAMPLINGMODE,this._reusable=p||!1,this._textureType=P,this._textureFormat=z,this._samplers=i||[],this._samplers.push("textureSampler"),this._fragmentUrl=e,this._vertexUrl=O,this._parameters=n||[],this._parameters.push("scale"),this._indexParameters=U,F||this.updateEffect(y)}return Object.defineProperty(r.prototype,"samples",{get:function(){return this._samples},set:function(t){var e=this;this._samples=Math.min(t,this._engine.getCaps().maxMSAASamples),this._textures.forEac
1617h(function(n){n.samples!==e._samples&&e._engine.updateRenderTargetTextureSampleCount(n,e._samples)})},enumerable:!1,configurable:!0}),r.prototype.getEffectName=function(){return this._fragmentUrl},Object.defineProperty(r.prototype,"onActivate",{set:function(t){this._onActivateObserver&&this.onActivateObservable.remove(this._onActivateObserver),t&&(this._onActivateObserver=this.onActivateObservable.add(t))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onSizeChanged",{set:function(t){this._onSizeChangedObserver&&this.onSizeChangedObservable.remove(this._onSizeChangedObserver),this._onSizeChangedObserver=this.onSizeChangedObservable.add(t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onApply",{set:function(t){this._onApplyObserver&&this.onApplyObservable.remove(this._onApplyObserver),this._onApplyObserver=this.onApplyObservable.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,"inputTexture",{get:function(){return this._textures.data[this._currentRenderTextureInd]},set:function(t){this._forcedOutputTexture=t},enumerable:!1,configurable:!0}),r.prototype.restoreDefaultInputTexture=function(){this._forcedOutputTexture=null},r.prototype.getCamera=function(){return this._camera},Object.defineProperty(r.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}),r.prototype.getClassName=function(){return"PostProcess"},r.prototype.getEngine=function(){return this._engine},r.prototype.getEffect=function(){return this._effect},r.prototype.shareOutputWith=function(t){return this._disposeTextures(),this._shareOutputWithPostProcess=t,this},r.prototype.useOwnOutput=function(){this._textures.length==0&&(this._textures=new li.a(2)),this._shareOutputWithPostProcess=null},r.prototype.updateEffect=function(t,e,n,i,o,a,s,d){t===void 0&&(t=null),e===void 0&&(e=null),n===void 0&&(n=null),this._effect=this._engine.createEffect({vertex:s??this._vertexUrl,fragment:d??this._fragmentUrl},["position"],e||this._parameters,n||this._samplers,t!==null?t:"",void 0,o,a,i||this._indexParameters)},r.prototype.isReusable=function(){return this._reusable},r.prototype.markTextureDirty=function(){this.width=-1},r.prototype.activate=function(t,e,n){var i=this;e===void 0&&(e=null);var o=(t=t||this._camera).getScene(),a=o.getEngine(),s=a.getCaps().maxTextureSize,d=(e?e.width:this._engine.getRenderWidth(!0))*this._options|0,p=(e?e.height:this._engine.getRenderHeight(!0))*this._options|0,y=t.parent;!y||y.leftCamera!=t&&y.rightCamera!=t||(d/=2);var P,O=this._options.width||d,U=this._options.height||p,F=this.renderTargetSamplingMode!==h.a.TEXTURE_NEAREST_LINEAR&&this.renderTargetSamplingMode!==h.a.TEXTURE_NEAREST_NEAREST&&this.renderTargetSamplingMode!==h.a.TEXTURE_LINEAR_LINEAR;if(!this._shareOutputWithPostProcess&&!this._forcedOutputTexture){if(this.adaptScaleToCurrentViewport){var z=a.currentViewport;z&&(O*=z.width,U*=z.height)}if((F||this.alwaysForcePOT)&&(this._options.width||(O=a.needPOTTextures?Ue.a.GetExponentOfTwo(O,s,this.scaleMode):O),this._options.height||(U=a.needPOTTextures?Ue.a.GetExponentOfTwo(U,s,this.scaleMode):U)),this.width!==O||this.height!==U){if(this._textures.length>0){for(var J=0;J<this._textures.length;J++)this._engine._releaseTexture(this._textures.data[J]);this._textures.reset()}this.width=O,this.height=U;var ie={width:this.width,height:this.height},se={generateMipMaps:F,generateDepthBuffer:n||t._postProcesses.indexOf(this)===0,generateStencilBuffer:(n||t._postProcesses.indexOf(this)===0)&&this._engine.isStencilEnable,samplingMode:this.renderTargetSamplingMode,type:this._textureType,format:this._textureFormat};this._textures.push(this._engine.createRenderTargetTexture(ie,se)),this._reusable&&this._textures.push(this._engine.createRenderTargetTexture(ie,se)),this._texelSize.copyFromFloats(1/this.width,1/this.height),this.onSizeChangedObservable.notifyObservers(this)}
1617this._textures.forEach(function(ce){ce.samples!==i.samples&&i._engine.updateRenderTargetTextureSampleCount(ce,i.samples)})}return this._shareOutputWithPostProcess?P=this._shareOutputWithPostProcess.inputTexture:this._forcedOutputTexture?(P=this._forcedOutputTexture,this.width=this._forcedOutputTexture.width,this.height=this._forcedOutputTexture.height):P=this.inputTexture,this.enablePixelPerfectMode?(this._scaleRatio.copyFromFloats(d/O,p/U),this._engine.bindFramebuffer(P,0,d,p,this.forceFullscreenViewport)):(this._scaleRatio.copyFromFloats(1,1),this._engine.bindFramebuffer(P,0,void 0,void 0,this.forceFullscreenViewport)),this.onActivateObservable.notifyObservers(t),this.autoClear&&this.alphaMode===h.a.ALPHA_DISABLE&&this._engine.clear(this.clearColor?this.clearColor:o.clearColor,o._allowPostProcessClearColor,!0,!0),this._reusable&&(this._currentRenderTextureInd=(this._currentRenderTextureInd+1)%2),P},Object.defineProperty(r.prototype,"isSupported",{get:function(){return this._effect.isSupported},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"aspectRatio",{get:function(){return this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.aspectRatio:this._forcedOutputTexture?this._forcedOutputTexture.width/this._forcedOutputTexture.height:this.width/this.height},enumerable:!1,configurable:!0}),r.prototype.isReady=function(){return this._effect&&this._effect.isReady()},r.prototype.apply=function(){return this._effect&&this._effect.isReady()?(this._engine.enableEffect(this._effect),this._engine.setState(!1),this._engine.setDepthBuffer(!1),this._engine.setDepthWrite(!1),this._engine.setAlphaMode(this.alphaMode),this.alphaConstants&&this.getEngine().setAlphaConstants(this.alphaConstants.r,this.alphaConstants.g,this.alphaConstants.b,this.alphaConstants.a),t=this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.inputTexture:this._forcedOutputTexture?this._forcedOutputTexture:this.inputTexture,this._effect._bindTexture("textureSampler",t),this._effect.setVector2("scale",this._scaleRatio),this.onApplyObservable.notifyObservers(this._effect),this._effect):null;var t},r.prototype._disposeTextures=function(){if(!this._shareOutputWithPostProcess&&!this._forcedOutputTexture){if(this._textures.length>0)for(var t=0;t<this._textures.length;t++)this._engine._releaseTexture(this._textures.data[t]);this._textures.dispose()}},r.prototype.setPrePassRenderer=function(t){return!!this._prePassEffectConfiguration&&(this._prePassEffectConfiguration=t.addEffectConfiguration(this._prePassEffectConfiguration),this._prePassEffectConfiguration.enabled=!0,!0)},r.prototype.dispose=function(t){var e;if(t=t||this._camera,this._disposeTextures(),this._scene&&(e=this._scene.postProcesses.indexOf(this))!==-1&&this._scene.postProcesses.splice(e,1),(e=this._engine.postProcesses.indexOf(this))!==-1&&this._engine.postProcesses.splice(e,1),t){if(t.detachPostProcess(this),(e=t._postProcesses.indexOf(this))===0&&t._postProcesses.length>0){var n=this._camera._getFirstPostProcess();n&&n.markTextureDirty()}this.onActivateObservable.clear(),this.onAfterRenderObservable.clear(),this.onApplyObservable.clear(),this.onBeforeRenderObservable.clear(),this.onSizeChangedObservable.clear()}},r.prototype.serialize=function(){var t=L.a.Serialize(this);return t.customType="BABYLON."+this.getClassName(),t.cameraId=this.getCamera().id,t.reusable=this._reusable,t.options=this._options,t.textureType=this._textureType,t},r.Parse=function(t,e,n){var i=R.a.GetClass(t.customType);if(!i||!i._Parse)return null;var o=e.getCameraByID(t.cameraId);return o?i._Parse(t,o,e,n):null},Object(c.c)([Object(L.c)()],r.prototype,"uniqueId",void 0),Object(c.c)([Object(L.c)()],r.prototype,"name",void 0),Object(c.c)([Object(L.c)()],r.prototype,"width",void 0),Object(c.c)([Object(L.c)()],r.prototype,"height",void 0),Object(c.c)([Object(L.c)()],r.prototype,"renderTargetSamplingMode",void 0),Object(c.c)([Object(L.f)()],r.prototype,"clearColor",void 0),Object(c.c)([Object(L.c)()],r.prototype,"autoClear",void 0),Object(c.c)([Object(L.c)()],r.prototype,"alphaMode",void 0),Object(c.c)([Object(L.c)()],r.prototype,"alphaConstants",void 0),Object(c.c)([Object(L.c)()],r.prototype,"enablePixelPerfectMode",void 0),Object(c.c)([Object(L.c)()],r.prototype,"forceFullscreenViewport",void 0),Object(c.c)([Object(L.c)()],r.prototype,"scaleMode",void 0),Object(c.c)([Object(L.c)()],r.prototype,"alwaysForcePOT",void 0),Object(c.c)([Object(L.c)("samples")],r.prototype,"_samples",void 0),Object(c.c)([Object(L.c)()],r.prototype,"adaptScaleToCurrentViewport",void 0),r}();R.a.RegisteredTypes["BABYLON.PostProcess"]=_t;var lp=`
1618varying vec2 vUV;
1619uniform sampler2D textureSampler;
1620void main(void)
1621{
1622gl_FragColor=texture2D(textureSampler,vUV);
1623}`;je.a.ShadersStore.passPixelShader=lp;var up=`
1624varying vec2 vUV;
1625uniform samplerCube textureSampler;
1626void main(void)
1627{
1628vec2 uv=vUV*2.0-1.0;
1629#ifdef POSITIVEX
1630gl_FragColor=textureCube(textureSampler,vec3(1.001,uv.y,uv.x));
1631#endif
1632#ifdef NEGATIVEX
1633gl_FragColor=textureCube(textureSampler,vec3(-1.001,uv.y,uv.x));
1634#endif
1635#ifdef POSITIVEY
1636gl_FragColor=textureCube(textureSampler,vec3(uv.y,1.001,uv.x));
1637#endif
1638#ifdef NEGATIVEY
1639gl_FragColor=textureCube(textureSampler,vec3(uv.y,-1.001,uv.x));
1640#endif
1641#ifdef POSITIVEZ
1642gl_FragColor=textureCube(textureSampler,vec3(uv,1.001));
1643#endif
1644#ifdef NEGATIVEZ
1645gl_FragColor=textureCube(textureSampler,vec3(uv,-1.001));
1646#endif
1647}`;je.a.ShadersStore.passCubePixelShader=up;var Li=function(r){function t(e,n,i,o,a,s,d,p){return i===void 0&&(i=null),d===void 0&&(d=h.a.TEXTURETYPE_UNSIGNED_INT),p===void 0&&(p=!1),r.call(this,e,"pass",null,null,n,i,o,a,s,void 0,d,void 0,null,p)||this}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"PassPostProcess"},t._Parse=function(e,n,i,o){return L.a.Parse(function(){return new t(e.name,e.options,n,e.renderTargetSamplingMode,i.getEngine(),e.reusable)},e,i,o)},t}(_t);R.a.RegisteredTypes["BABYLON.PassPostProcess"]=Li;var hp=function(r){function t(e,n,i,o,a,s,d,p){i===void 0&&(i=null),d===void 0&&(d=h.a.TEXTURETYPE_UNSIGNED_INT),p===void 0&&(p=!1);var y=r.call(this,e,"passCube",null,null,n,i,o,a,s,"#define POSITIVEX",d,void 0,null,p)||this;return y._face=0,y}return Object(c.d)(t,r),Object.defineProperty(t.prototype,"face",{get:function(){return this._face},set:function(e){if(!(e<0||e>5))switch(this._face=e,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")}}
1647,enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"PassCubePostProcess"},t._Parse=function(e,n,i,o){return L.a.Parse(function(){return new t(e.name,e.options,n,e.renderTargetSamplingMode,i.getEngine(),e.reusable)},e,i,o)},t}(_t);Ue.a._RescalePostProcessFactory=function(r){return new Li("rescale",1,null,h.a.TEXTURE_BILINEAR_SAMPLINGMODE,r,!1,h.a.TEXTURETYPE_UNSIGNED_INT)};var dp=`
1648varying vec2 vUV;
1649uniform sampler2D textureSampler;
1650uniform sampler2D leftSampler;
1651void main(void)
1652{
1653vec4 leftFrag=texture2D(leftSampler,vUV);
1654leftFrag=vec4(1.0,leftFrag.g,leftFrag.b,1.0);
1655vec4 rightFrag=texture2D(textureSampler,vUV);
1656rightFrag=vec4(rightFrag.r,1.0,1.0,1.0);
1657gl_FragColor=vec4(rightFrag.rgb*leftFrag.rgb,1.0);
1658}`;je.a.ShadersStore.anaglyphPixelShader=dp;var ps=function(r){function t(e,n,i,o,a,s){var d=r.call(this,e,"anaglyph",null,["leftSampler"],n,i[1],o,a,s)||this;return d._passedProcess=i[0]._rigPostProcess,d.onApplyObservable.add(function(p){p.setTextureFromPostProcess("leftSampler",d._passedProcess)}),d}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"AnaglyphPostProcess"},t}(_t);R.a.RegisteredTypes["BABYLON.AnaglyphPostProcess"]=ps,gt.a._setStereoscopicAnaglyphRigMode=function(r){r._rigCameras[0]._rigPostProcess=new Li(r.name+"_passthru",1,r._rigCameras[0]),r._rigCameras[1]._rigPostProcess=new ps(r.name+"_anaglyph",1,r._rigCameras)},Q.a.AddNodeConstructor("AnaglyphArcRotateCamera",function(r,t,e){return function(){return new Gl(r,0,0,1,u.e.Zero(),e.interaxial_distance,t)}});var Gl=function(r){function t(e,n,i,o,a,s,d){var p=r.call(this,e,n,i,o,a,d)||this;return p.interaxialDistance=s,p.setCameraRigMode(gt.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:s}),p}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"AnaglyphArcRotateCamera"},t}(Zi);Q.a.AddNodeConstructor("AnaglyphFreeCamera",function(r,t,e){return function(){return new zl(r,u.e.Zero(),e.interaxial_distance,t)}});var zl=function(r){function t(e,n,i,o){var a=r.call(this,e,n,o)||this;return a.interaxialDistance=i,a.setCameraRigMode(gt.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:i}),a}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"AnaglyphFreeCamera"},t}(Hn);Q.a.AddNodeConstructor("AnaglyphGamepadCamera",function(r,t,e){return function(){return new jl(r,u.e.Zero(),e.interaxial_distance,t)}});var jl=function(r){function t(e,n,i,o){var a=r.call(this,e,n,o)||this;return a.interaxialDistance=i,a.setCameraRigMode(gt.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:i}),a}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"AnaglyphGamepadCamera"},t}(ko);Q.a.AddNodeConstructor("AnaglyphUniversalCamera",function(r,t,e){return function(){return new Hl(r,u.e.Zero(),e.interaxial_distance,t)}});var Hl=function(r){function t(e,n,i,o){var a=r.call(this,e,n,o)||this;return a.interaxialDistance=i,a.setCameraRigMode(gt.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:i}),a}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"AnaglyphUniversalCamera"},t}(pr),Wn=f(58);gt.a._setStereoscopicRigMode=function(r){var t=r.cameraRigMode===gt.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL||r.cameraRigMode===gt.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED,e=r.cameraRigMode===gt.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;r._rigCameras[e?1:0].viewport=new Wn.a(0,0,t?.5:1,t?1:.5),r._rigCameras[e?0:1].viewport=new Wn.a(t?.5:0,t?0:.5,t?.5:1,t?1:.5)},Q.a.AddNodeConstructor("StereoscopicArcRotateCamera",function(r,t,e){return function(){return new Wl(r,0,0,1,u.e.Zero(),e.interaxial_distance,e.isStereoscopicSideBySide,t)}});var Wl=function(r){function t(e,n,i,o,a,s,d,p){var y=r.call(this,e,n,i,o,a,p)||this;return y.interaxialDistance=s,y.isStereoscopicSideBySide=d,y.setCameraRigMode(d?gt.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:gt.a.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:s}),y}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"StereoscopicArcRotateCamera"},t}(Zi);Q.a.AddNodeConstructor("StereoscopicFreeCamera",function(r,t,e){return function(){return new Xl(r,u.e.Zero(),e.interaxial_distance,e.isStereoscopicSideBySide,t)}});var Xl=function(r){function t(e,n,i,o,a){var s=r.call(this,e,n,a)||this;return s.interaxialDistance=i,s.isStereoscopicSideBySide=o,s.setCameraRigMode(o?gt.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:gt.a.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:i}),s}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"StereoscopicFreeCamera"},t}(Hn);Q.a.AddNodeConstructor("StereoscopicGamepadCamera",function(r,t,e){return function(){return new Yl(r,u.e.Zero(),e.interaxial_distance,e.isStereoscopicSideBySide,t)}});var Yl=function(r){function t(e,n,i,o,a){var s=r.call(this,e,n,a)||this;return s.interaxialDistance=i,s.isStereoscopicSideBySide=o,s.setCameraRigMode(o?gt.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:gt.a.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:i}),s}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"StereoscopicGamepadCamera"},t}(ko);Q.a.AddNodeConstructor("StereoscopicFreeCamera",function(r,t,e){return function(){return new Kl(r,u.e.Zero(),e.interaxial_distance,e.isStereoscopicSideBySide,t)}});var Kl=function(r){function t(e,n,i,o,a){var s=r.call(this,e,n,a)||this;return s.interaxialDistance=i,s.isStereoscopicSideBySide=o,s.setCameraRigMode(o?gt.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:gt.a.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:i}),s}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"StereoscopicUniversalCamera"},t}(pr);Q.a.AddNodeConstructor("VirtualJoysticksCamera",function(r,t){return function(){return new Ql(r,u.e.Zero(),t)}});var Ql=function(r){function t(e,n,i){var o=r.call(this,e,n,i)||this;return o.inputs.addVirtualJoystick(),o}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"VirtualJoysticksCamera"},t}(Hn),_r=function(){function r(){this.compensateDistortion=!0,this.multiviewEnabled=!1}
1658return Object.defineProperty(r.prototype,"aspectRatio",{get:function(){return this.hResolution/(2*this.vResolution)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"aspectRatioFov",{get:function(){return 2*Math.atan(this.postProcessScaleFactor*this.vScreenSize/(2*this.eyeToScreenDistance))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"leftHMatrix",{get:function(){var t=4*(this.hScreenSize/4-this.lensSeparationDistance/2)/this.hScreenSize;return u.a.Translation(t,0,0)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"rightHMatrix",{get:function(){var t=4*(this.hScreenSize/4-this.lensSeparationDistance/2)/this.hScreenSize;return u.a.Translation(-t,0,0)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"leftPreViewMatrix",{get:function(){return u.a.Translation(.5*this.interpupillaryDistance,0,0)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"rightPreViewMatrix",{get:function(){return u.a.Translation(-.5*this.interpupillaryDistance,0,0)},enumerable:!1,configurable:!0}),r.GetDefault=function(){var t=new r;return t.hResolution=1280,t.vResolution=800,t.hScreenSize=.149759993,t.vScreenSize=.0935999975,t.vScreenCenter=.0467999987,t.eyeToScreenDistance=.0410000011,t.lensSeparationDistance=.063500002,t.interpupillaryDistance=.064000003,t.distortionK=[1,.219999999,.239999995,0],t.chromaAbCorrection=[.995999992,-.00400000019,1.01400006,0],t.postProcessScaleFactor=1.714605507808412,t.lensCenterOffset=.151976421,t},r}(),fp=`
1659varying vec2 vUV;
1660uniform sampler2D textureSampler;
1661uniform vec2 LensCenter;
1662uniform vec2 Scale;
1663uniform vec2 ScaleIn;
1664uniform vec4 HmdWarpParam;
1665vec2 HmdWarp(vec2 in01) {
1666vec2 theta=(in01-LensCenter)*ScaleIn;
1667float rSq=theta.x*theta.x+theta.y*theta.y;
1668vec2 rvector=theta*(HmdWarpParam.x+HmdWarpParam.y*rSq+HmdWarpParam.z*rSq*rSq+HmdWarpParam.w*rSq*rSq*rSq);
1669return LensCenter+Scale*rvector;
1670}
1671void main(void)
1672{
1673vec2 tc=HmdWarp(vUV);
1674if (tc.x <0.0 || tc.x>1.0 || tc.y<0.0 || tc.y>1.0)
1675gl_FragColor=vec4(0.0,0.0,0.0,0.0);
1676else{
1677gl_FragColor=texture2D(textureSampler,tc);
1678}
1679}`;je.a.ShadersStore.vrDistortionCorrectionPixelShader=fp;var _s=function(r){function t(e,n,i,o){var a=r.call(this,e,"vrDistortionCorrection",["LensCenter","Scale","ScaleIn","HmdWarpParam"],null,o.postProcessScaleFactor,n,we.a.BILINEAR_SAMPLINGMODE)||this;return a._isRightEye=i,a._distortionFactors=o.distortionK,a._postProcessScaleFactor=o.postProcessScaleFactor,a._lensCenterOffset=o.lensCenterOffset,a.adaptScaleToCurrentViewport=!0,a.onSizeChangedObservable.add(function(){a._scaleIn=new u.d(2,2/a.aspectRatio),a._scaleFactor=new u.d(1/a._postProcessScaleFactor*.5,1/a._postProcessScaleFactor*.5*a.aspectRatio),a._lensCenter=new u.d(a._isRightEye?.5-.5*a._lensCenterOffset:.5+.5*a._lensCenterOffset,.5)}),a.onApplyObservable.add(function(s){s.setFloat2("LensCenter",a._lensCenter.x,a._lensCenter.y),s.setFloat2("Scale",a._scaleFactor.x,a._scaleFactor.y),s.setFloat2("ScaleIn",a._scaleIn.x,a._scaleIn.y),s.setFloat4("HmdWarpParam",a._distortionFactors[0],a._distortionFactors[1],a._distortionFactors[2],a._distortionFactors[3])}),a}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"VRDistortionCorrectionPostProcess"},t}(_t),pp=`precision mediump sampler2DArray;
1680varying vec2 vUV;
1681uniform sampler2DArray multiviewSampler;
1682uniform int imageIndex;
1683void main(void)
1684{
1685gl_FragColor=texture(multiviewSampler,vec3(vUV,imageIndex));
1686}`;je.a.ShadersStore.vrMultiviewToSingleviewPixelShader=pp;var ql=f(85),ms=f(95),eo=f(96);Bt.a.prototype.createRenderTargetCubeTexture=function(r,t){var e=Object(c.a)({generateMipMaps:!0,generateDepthBuffer:!0,generateStencilBuffer:!1,type:h.a.TEXTURETYPE_UNSIGNED_INT,samplingMode:h.a.TEXTURE_TRILINEAR_SAMPLINGMODE,format:h.a.TEXTUREFORMAT_RGBA},t);e.generateStencilBuffer=e.generateDepthBuffer&&e.generateStencilBuffer,(e.type!==h.a.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(e.type!==h.a.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(e.samplingMode=h.a.TEXTURE_NEAREST_SAMPLINGMODE);var n=this._gl,i=new xt.a(this,xt.b.RenderTarget);this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,i,!0);var o=this._getSamplingParameters(e.samplingMode,e.generateMipMaps);e.type!==h.a.TEXTURETYPE_FLOAT||this._caps.textureFloat||(e.type=h.a.TEXTURETYPE_UNSIGNED_INT,l.a.Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type")),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MAG_FILTER,o.mag),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MIN_FILTER,o.min),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE);for(var a=0;a<6;a++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+a,0,this._getRGBABufferInternalSizedFormat(e.type,e.format),r,r,0,this._getInternalFormat(e.format),this._getWebGLTextureType(e.type),null);var s=n.createFramebuffer();return this._bindUnboundFramebuffer(s),i._depthStencilBuffer=this._setupFramebufferDepthAttachments(e.generateStencilBuffer,e.generateDepthBuffer,r,r),e.generateMipMaps&&n.generateMipmap(n.TEXTURE_CUBE_MAP),this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,null),this._bindUnboundFramebuffer(null),i._framebuffer=s,i.width=r,i.height=r,i.isReady=!0,i.isCube=!0,i.samples=1,i.generateMipMaps=e.generateMipMaps,i.samplingMode=e.samplingMode,i.type=e.type,i.format=e.format,i._generateDepthBuffer=e.generateDepthBuffer,i._generateStencilBuffer=e.generateStencilBuffer,this._internalTexturesCache.push(i),i};var sn=function(r){function t(e,n,i,o,a,s,d,p,y,P,O,U,F){a===void 0&&(a=!0),s===void 0&&(s=h.a.TEXTURETYPE_UNSIGNED_INT),d===void 0&&(d=!1),p===void 0&&(p=we.a.TRILINEAR_SAMPLINGMODE),y===void 0&&(y=!0),P===void 0&&(P=!1),O===void 0&&(O=!1),U===void 0&&(U=h.a.TEXTUREFORMAT_RGBA),F===void 0&&(F=!1);var z=r.call(this,null,i,!o)||this;return z.renderParticles=!0,z.renderSprites=!1,z.ignoreCameraViewport=!1,z.onBeforeBindObservable=new x.c,z.onAfterUnbindObservable=new x.c,z.onBeforeRenderObservable=new x.c,z.onAfterRenderObservable=new x.c,z.onClearObservable=new x.c,z.onResizeObservable=new x.c,z._currentRefresh
1686Id=-1,z._refreshRate=1,z._samples=1,z.boundingBoxPosition=u.e.Zero(),(i=z.getScene())&&(z._coordinatesMode=we.a.PROJECTION_MODE,z.renderList=new Array,z.name=e,z.isRenderTarget=!0,z._initialSizeParameter=n,z._processSizeParameter(n),z._resizeObserver=z.getScene().getEngine().onResizeObservable.add(function(){}),z._generateMipMaps=!!o,z._doNotChangeAspectRatio=a,z._renderingManager=new eo.b(i),z._renderingManager._useSceneAutoClearSetup=!0,O||(z._renderTargetOptions={generateMipMaps:o,type:s,format:U,samplingMode:p,generateDepthBuffer:y,generateStencilBuffer:P},p===we.a.NEAREST_SAMPLINGMODE&&(z.wrapU=we.a.CLAMP_ADDRESSMODE,z.wrapV=we.a.CLAMP_ADDRESSMODE),F||(d?(z._texture=i.getEngine().createRenderTargetCubeTexture(z.getRenderSize(),z._renderTargetOptions),z.coordinatesMode=we.a.INVCUBIC_MODE,z._textureMatrix=u.a.Identity()):z._texture=i.getEngine().createRenderTargetTexture(z._size,z._renderTargetOptions)))),z}return Object(c.d)(t,r),Object.defineProperty(t.prototype,"renderList",{get:function(){return this._renderList},set:function(e){this._renderList=e,this._renderList&&this._hookArray(this._renderList)},enumerable:!1,configurable:!0}),t.prototype._hookArray=function(e){var n=this,i=e.push;e.push=function(){for(var a=[],s=0;s<arguments.length;s++)a[s]=arguments[s];var d=e.length===0,p=i.apply(e,a);return d&&n.getScene()&&n.getScene().meshes.forEach(function(y){y._markSubMeshesAsLightDirty()}),p};var o=e.splice;e.splice=function(a,s){var d=o.apply(e,[a,s]);return e.length===0&&n.getScene().meshes.forEach(function(p){p._markSubMeshesAsLightDirty()}),d}},Object.defineProperty(t.prototype,"onAfterUnbind",{set:function(e){this._onAfterUnbindObserver&&this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),this._onAfterUnbindObserver=this.onAfterUnbindObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onClear",{set:function(e){this._onClearObserver&&this.onClearObservable.remove(this._onClearObserver),this._onClearObserver=this.onClearObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"renderTargetOptions",{get:function(){return this._renderTargetOptions},enumerable:!1,configurable:!0}),t.prototype._onRatioRescale=function(){this._sizeRatio&&this.resize(this._initialSizeParameter)},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(h.a.MATERIAL_TextureDirtyFlag)}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthStencilTexture",{get:function(){var e;return((e=this.getInternalTexture())===null||e===void 0?void 0:e._depthStencilTexture)||null},enumerable:!1,configurable:!0}),t.prototype.createDepthStencilTexture=function(e,n,i){e===void 0&&(e=0),n===void 0&&(n=!0),i===void 0&&(i=!1);var o=this.getInternalTexture();if(this.getScene()&&o){var a=this.getScene().getEngine();o._depthStencilTexture=a.createDepthStencilTexture(this._size,{bilinearFiltering:n,comparisonFunction:e,generateStencil:i,isCube:this.isCube})}},t.prototype._processSizeParameter=function(e){if(e.ratio){this._sizeRatio=e.ratio;var n=this._getEngine();this._size={width:this._bestReflectionRenderTargetDimension(n.getRenderWidth(),this._sizeRatio),height:this._bestReflectionRenderTargetDimension(n.getRenderHeight(),this._sizeRatio)}}else this._size=e},Object.defineProperty(t.prototype,"samples",{get:function(){return this._samples},set:function(e){if(this._samples!==e){var n=this.getScene();n&&(this._samples=n.getEngine().updateRenderTargetTextureSampleCount(this._texture,e))}}
1686,enumerable:!1,configurable:!0}),t.prototype.resetRefreshCounter=function(){this._currentRefreshId=-1},Object.defineProperty(t.prototype,"refreshRate",{get:function(){return this._refreshRate},set:function(e){this._refreshRate=e,this.resetRefreshCounter()},enumerable:!1,configurable:!0}),t.prototype.addPostProcess=function(e){if(!this._postProcessManager){var n=this.getScene();if(!n)return;this._postProcessManager=new ms.a(n),this._postProcesses=new Array}this._postProcesses.push(e),this._postProcesses[0].autoClear=!1},t.prototype.clearPostProcesses=function(e){if(e===void 0&&(e=!1),this._postProcesses){if(e)for(var n=0,i=this._postProcesses;n<i.length;n++)i[n].dispose();this._postProcesses=[]}},t.prototype.removePostProcess=function(e){if(this._postProcesses){var n=this._postProcesses.indexOf(e);n!==-1&&(this._postProcesses.splice(n,1),this._postProcesses.length>0&&(this._postProcesses[0].autoClear=!1))}},t.prototype._shouldRender=function(){return this._currentRefreshId===-1||this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,!0):(this._currentRefreshId++,!1)},t.prototype.getRenderSize=function(){return this.getRenderWidth()},t.prototype.getRenderWidth=function(){return this._size.width?this._size.width:this._size},t.prototype.getRenderHeight=function(){return this._size.width?this._size.height:this._size},t.prototype.getRenderLayers=function(){var e=this._size.layers;return e||0},Object.defineProperty(t.prototype,"canRescale",{get:function(){return!0},enumerable:!1,configurable:!0}),t.prototype.scale=function(e){var n=Math.max(1,this.getRenderSize()*e);this.resize(n)},t.prototype.getReflectionTextureMatrix=function(){return this.isCube?this._textureMatrix:r.prototype.getReflectionTextureMatrix.call(this)},t.prototype.resize=function(e){var n=this.isCube;this.releaseInternalTexture();var i=this.getScene();i&&(this._processSizeParameter(e),this._texture=n?i.getEngine().createRenderTargetCubeTexture(this.getRenderSize(),this._renderTargetOptions):i.getEngine().createRenderTargetTexture(this._size,this._renderTargetOptions),this.onResizeObservable.hasObservers()&&this.onResizeObservable.notifyObservers(this))},t.prototype.render=function(e,n){if(e===void 0&&(e=!1),n===void 0&&(n=!1),p=this.getScene()){var i,o=p.getEngine();if(this.useCameraPostProcesses!==void 0&&(e=this.useCameraPostProcesses),this._waitingRenderList){this.renderList=[];for(var a=0;a<this._waitingRenderList.length;a++){var s=this._waitingRenderList[a],d=p.getMeshByID(s);d&&this.renderList.push(d)}this._waitingRenderList=void 0}if(this.renderListPredicate){var p;if(this.renderList?this.renderList.length=0:this.renderList=[],!(p=this.getScene()))return;var y=p.meshes;for(a=0;a<y.length;a++){var P=y[a];this.renderListPredicate(P)&&this.renderList.push(P)}}if(this.onBeforeBindObservable.notifyObservers(this),this.activeCamera?(i=this.activeCamera,o.setViewport(this.activeCamera.viewport,this.getRenderWidth(),this.getRenderHeight()),this.activeCamera!==p.activeCamera&&p.setTransformMatrix(this.activeCamera.getViewMatrix(),this.activeCamera.getProjectionMatrix(!0))):(i=p.activeCamera)&&o.setViewport(i.viewport,this.getRenderWidth(),this.getRenderHeight()),this._defaultRenderListPrepared=!1,this.is2DArray)for(var O=0;O<this.getRenderLayers();O++)this.renderToTarget(0,e,n,O,i),p.incrementRenderId(),p.resetCachedMaterial();else if(this.isCube)for(var U=0;U<6;U++)this.renderToTarget(U,e,n,void 0,i),p.incrementRenderId(),p.resetCachedMaterial();else this.renderToTarget(0,e,n,void 0,i);this.onAfterUnbindObservable.notifyObservers(this),p.activeCamera&&((p.getEngine().scenes.length>1||this.activeCamera&&this.activeCamera!==p.activeCamera)&&p.setTransformMatrix(p.activeCamera.getViewMatrix(),p.activeCamera.getProjectionMatrix(!0)),o.setViewport(p.activeCamera.viewport)),p.resetCachedMaterial()}},t.prototype._bestReflectionRenderTargetDimension=function(e,n){var i=e*n,o=Ue.a.NearestPOT(i+16384/(128+i));return Math.min(Ue.a.FloorPOT(e),o)},t.prototype._prepareRenderingManager=function(e,n,i,o){var a=this.getScene();if(a){this._renderingManager.reset();for(var s=a.getRenderId(),d=0;d<n;d++){var p=e[d];if(p&&!p.isBlocked){if(this.customIsReadyFunction){if(!this.customIsReadyFunction(p,this.refreshRate)){this.resetRefreshCounter();continue}}else if(!p.isReady(this.refreshRate===0)){this.resetRefreshCounter();continue}if(!p._internalAbstractMeshDataInfo._currentLODIsUpToDate&&a.activeCamera&&(p._internalAbstractMeshDataInfo._currentLOD=a.customLODSelector?a.customLODSelector(p,a.activeCamera):p.getLOD(a.activeCamera),p._internalAbstractMeshDataInfo._currentLODIsUpToDate=!0),!p._internalAbstractMeshDataInfo._currentLOD)continue;var y=p._internalAbstractMeshDataInfo._currentLOD;y._preActivateForIntermediateRendering(s);var P=void 0;if(P=!(!o||!i)&&(p.layerMask&i.layerMask)==0,p.isEnabled()&&p.isVisible&&p.subMeshes&&!P&&(y!==p&&y._activate(s,!0),p._activate(s,!0)&&p.subMeshes.length)){p.isAnInstance?p._internalAbstractMeshDataInfo._actAsRegularMesh&&(y=p):y._internalAbstractMeshDataInfo._onlyForInstancesIntermediate=!1,y._internalAbstractMeshDataInfo._isActiveIntermediate=!0;for(var O=0;O<y.subMeshes.length;O++){var U=y.subMeshes[O];this._renderingManager.dispatch(U,y)}}}}for(var F=0;F<a.particleSystems.length;F++){var z=a.particleSystems[F],J=z.emitter;z.isStarted()&&J&&J.position&&J.isEnabled()&&e.indexOf(J)>=0&&this._renderingManager.dispatchParticles(z)}}},t.prototype._bindFrameBuffer=function(e,n){e===void 0&&(e=0),n===void 0&&(n=0);var i=this.getScene();if(i){var o=i.getEngine();this._texture&&o.bindFramebuffer(this._texture,this.isCube?e:void 0,void 0,void 0,this.ignoreCameraViewport,0,n)}},t.prototype.unbindFrameBuffer=function(e,n){var i=this;this._texture&&e.unBindFramebuffer(this._texture,this.isCube,function(){i.onAfterRenderObservable.notifyObservers(n)})},t.prototype.renderToTarget=function(e,n,i,o,a){o===void 0&&(o=0),a===void 0&&(a=null);var s=this.getScene();if(s){var d=s.getEngine();if(this._texture){this._postProcessManager?this._postProcessManager._prepareFrame(this._texture,this._postProcesses):n&&s.postProcessManager._prepareFrame(this._texture)||this._bindFrameBuffer(e,o),this.is2DArray?this.onBeforeRenderObservable.notifyObservers(o):this.onBeforeRenderObservable.notifyObservers(e);var p=null,y=this.renderList?this.renderList:s.getActiveMeshes().data,P=this.renderList?this.renderList.length:s.getActiveMeshes().length;this.getCustomRenderList&&(p=this.getCustomRenderList(this.is2DArray?o:e,y,P)),p?this._prepareRenderingManager(p,p.length,a,!1):(this._defaultRenderListPrepared||(this._prepareRenderingManager(y,P,a,!this.renderList),this._defaultRenderListPrepared=!0),p=y),this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(d):d.clear(this.clearColor||s.clearColor,!0,!0,!0),this._doNotChangeAspectRatio||s.updateTransformMatrix(!0);for(var O=0,U=s._beforeRenderTargetDrawStage;O<U.length;O++)U[O].action(this);this._renderingManager.render(this.customRenderFunction,p,this.renderParticles,this.renderSprites);for(var F=0,z=s._afterRenderTargetDrawStage;F<z.length;F++)z[F].action(this);this._postProcessManager?this._postProcessManager._finalizeFrame(!1,this._texture,e,this._postProcesses,this.ignoreCameraViewport):n&&s.postProcessManager._finalizeFrame(!1,this._texture,e),this._doNotChangeAspectRatio||s.updateTransformMatrix(!0),i&&Ye.b.DumpFramebuffer(this.getRenderWidth(),this.getRenderHeight(),d),this.isCube&&e!==5?this.onAfterRenderObservable.notifyObservers(e):(this.isCube&&e===5&&d.generateMipMapsForCubemap(this._texture),this.unbindFrameBuffer(d,e))}}},t.prototype.setRenderingOrder=function(e,n,i,o){n===void 0&&(n=null),i===void 0&&(i=null),o===void 0&&(o=null),this._renderingManager.setRenderingOrder(e,n,i,o)},t.prototype.setRenderingAutoClearDepthStencil=function(e,n){this._renderingManager.setRenderingAutoClearDepthStencil(e,n),this._renderingManager._useSceneAutoClearSetup=!1},t.prototype.clone=function(){var e=this.getSize(),n=new t(this.name,e,this.get
1686Scene(),this._renderTargetOptions.generateMipMaps,this._doNotChangeAspectRatio,this._renderTargetOptions.type,this.isCube,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer,this._renderTargetOptions.generateStencilBuffer);return n.hasAlpha=this.hasAlpha,n.level=this.level,n.coordinatesMode=this.coordinatesMode,this.renderList&&(n.renderList=this.renderList.slice(0)),n},t.prototype.serialize=function(){if(!this.name)return null;var e=r.prototype.serialize.call(this);if(e.renderTargetSize=this.getRenderSize(),e.renderList=[],this.renderList)for(var n=0;n<this.renderList.length;n++)e.renderList.push(this.renderList[n].id);return e},t.prototype.disposeFramebufferObjects=function(){var e=this.getInternalTexture(),n=this.getScene();e&&n&&n.getEngine()._releaseFramebufferObjects(e)},t.prototype.dispose=function(){this.onResizeObservable.clear(),this.onClearObservable.clear(),this.onAfterRenderObservable.clear(),this.onAfterUnbindObservable.clear(),this.onBeforeBindObservable.clear(),this.onBeforeRenderObservable.clear(),this._postProcessManager&&(this._postProcessManager.dispose(),this._postProcessManager=null),this.clearPostProcesses(!0),this._resizeObserver&&(this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver),this._resizeObserver=null),this.renderList=null;var e=this.getScene();if(e){var n=e.customRenderTargets.indexOf(this);n>=0&&e.customRenderTargets.splice(n,1);for(var i=0,o=e.cameras;i<o.length;i++){var a=o[i];(n=a.customRenderTargets.indexOf(this))>=0&&a.customRenderTargets.splice(n,1)}this.depthStencilTexture&&this.getScene().getEngine()._releaseTexture(this.depthStencilTexture),r.prototype.dispose.call(this)}},t.prototype._rebuild=function(){this.refreshRate===t.REFRESHRATE_RENDER_ONCE&&(this.refreshRate=t.REFRESHRATE_RENDER_ONCE),this._postProcessManager&&this._postProcessManager._rebuild()},t.prototype.freeRenderingGroups=function(){this._renderingManager&&this._renderingManager.freeRenderingGroups()},t.prototype.getViewCount=function(){return 1},t.REFRESHRATE_RENDER_ONCE=0,t.REFRESHRATE_RENDER_ONEVERYFRAME=1,t.REFRESHRATE_RENDER_ONEVERYTWOFRAMES=2,t}(we.a);we.a._CreateRenderTargetTexture=function(r,t,e,n){return new sn(r,t,e,n)};var Zl=function(r){function t(e,n){n===void 0&&(n=512);var i=r.call(this,"multiview rtt",n,e,!1,!0,xt.b.Unknown,!1,void 0,!1,!1,!0,void 0,!0)||this,o=e.getEngine().createMultiviewRenderTargetTexture(i.getRenderWidth(),i.getRenderHeight());return o.isMultiview=!0,o.format=h.a.TEXTUREFORMAT_RGBA,i._texture=o,i.samples=i._getEngine().getCaps().maxSamples||i.samples,i}return Object(c.d)(t,r),t.prototype._bindFrameBuffer=function(e){this._texture&&this.getScene().getEngine().bindMultiviewFramebuffer(this._texture)},t.prototype.getViewCount=function(){return 2},t}(sn),Jl=f(90);Ue.a.prototype.createMultiviewRenderTargetTexture=function(r,t){var e=this._gl;if(!this.getCaps().multiview)throw"Multiview is not supported";var n=new xt.a(this,xt.b.Unknown,!0);return n.width=r,n.height=t,n._framebuffer=e.createFramebuffer(),n._colorTextureArray=e.createTexture(),e.bindTexture(e.TEXTURE_2D_ARRAY,n._colorTextureArray),e.texStorage3D(e.TEXTURE_2D_ARRAY,1,e.RGBA8,r,t,2),n._depthStencilTextureArray=e.createTexture(),e.bindTexture(e.TEXTURE_2D_ARRAY,n._depthStencilTextureArray),e.texStorage3D(e.TEXTURE_2D_ARRAY,1,e.DEPTH32F_STENCIL8,r,t,2),n.isReady=!0,n},Ue.a.prototype.bindMultiviewFramebuffer=function(r){var t=this._gl,e=this.getCaps().oculusMultiview||this.getCaps().multiview;if(this.bindFramebuffer(r,void 0,void 0,void 0,!0),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,r._framebuffer),!r._colorTextureArray||!r._depthStencilTextureArray)throw"Invalid multiview frame buffer";this.getCaps().oculusMultiview?(e.framebufferTextureMultisampleMultiviewOVR(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,r._colorTextureArray,0,r.samples,0,2),e.framebufferTextureMultisampleMultiviewOVR(t.DRAW_FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,r._depthStencilTextureArray,0,r.samples,0,2)):(e.framebufferTextureMultiviewOVR(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,r._colorTextureArray,0,0,2),e.framebufferTextureMultiviewOVR(t.DRAW_FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,r._depthStencilTextureArray,0,0,2))},gt.a.prototype._useMultiviewToSingleView=!1,gt.a.prototype._multiviewTexture=null,gt.a.prototype._resizeOrCreateMultiviewTexture=function(r,t){this._multiviewTexture?this._multiviewTexture.getRenderWidth()==r&&this._multiviewTexture.getRenderHeight()==t||(this._multiviewTexture.dispose(),this._multiviewTexture=new Zl(this.getScene(),{width:r,height:t})):this._multiviewTexture=new Zl(this.getScene(),{width:r,height:t})},_e.a.prototype._transformMatrixR=u.a.Zero(),_e.a.prototype._multiviewSceneUbo=null,_e.a.prototype._createMultiviewUbo=function(){this._multiviewSceneUbo=new ql.a(this.getEngine(),void 0,!0),this._multiviewSceneUbo.addUniform("viewProjection",16),this._multiviewSceneUbo.addUniform("viewProjectionR",16),this._multiviewSceneUbo.addUniform("view",16)},_e.a.prototype._updateMultiviewUbo=function(r,t){r&&t&&r.multiplyToRef(t,this._transformMatrixR),r&&t&&(r.multiplyToRef(t,u.c.Matrix[0]),Jl.a.GetRightPlaneToRef(u.c.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.update())},_e.a.prototype._renderMultiviewToSingleView=function(r){r._resizeOrCreateMultiviewTexture(r._rigPostProcess&&r._rigPostProcess&&r._rigPostProcess.width>0?r._rigPostProcess.width:this.getEngine().getRenderWidth(!0),r._rigPostProcess&&r._rigPostProcess&&r._rigPostProcess.height>0?r._rigPostProcess.height:this.getEngine().getRenderHeight(!0)),this._multiviewSceneUbo||this._createMultiviewUbo(),r.outputRenderTarget=r._multiviewTexture,this._renderForCamera(r),r.outputRenderTarget=null;for(var t=0;t<r._rigCameras.length;t++){var e=this.getEngine();this._activeCamera=r._rigCameras[t],e.setViewport(this._activeCamera.viewport),this.postProcessManager&&(this.postProcessManager._prepareFrame(),this.postProcessManager._finalizeFrame(this._activeCamera.isIntermediate))}};var gs=function(r){function t(e,n,i){var o=r.call(this,e,"vrMultiviewToSingleview",["imageIndex"],["multiviewSampler"],i,n,we.a.BILINEAR_SAMPLINGMODE)||this;return o.onSizeChangedObservable.add(function(){}),o.onApplyObservable.add(function(a){n._scene.activeCamera&&n._scene.activeCamera.isLeftCamera?a.setInt("imageIndex",0):a.setInt("imageIndex",1),a.setTexture("multiviewSampler",n._multiviewTexture)}),o}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"VRMultiviewToSingleviewPostProcess"},t}(_t);gt.a._setVRRigMode=function(r,t){var e=t.vrCameraMetrics||_r.GetDefault();r._rigCameras[0]._cameraRigParams.vrMetrics=e,r._rigCameras[0].viewport=new Wn.a(0,0,.5,1),r._rigCameras[0]._cameraRigParams.vrWorkMatrix=new u.a,r._rigCameras[0]._cameraRigParams.vrHMatrix=e.leftHMatrix,r._rigCameras[0]._cameraRigParams.vrPreViewMatrix=e.leftPreViewMatrix,r._rigCameras[0].getProjectionMatrix=r._rigCameras[0]._getVRProjectionMatrix,r._rigCameras[1]._cameraRigParams.vrMetrics=e,r._rigCameras[1].viewport=new Wn.a(.5,0,.5,1),r._rigCameras[1]._cameraRigParams.vrWorkMatrix=new u.a,r._rigCameras[1]._cameraRigParams.vrHMatrix=e.rightHMatrix,r._rigCameras[1]._cameraRigParams.vrPreViewMatrix=e.rightPreViewMatrix,r._rigCameras[1].getProjectionMatrix=r._rigCameras[1]._getVRProjectionMatrix,e.multiviewEnabled&&(r.getSce
1686ne().getEngine().getCaps().multiview?(r._useMultiviewToSingleView=!0,r._rigPostProcess=new gs("VRMultiviewToSingleview",r,e.postProcessScaleFactor)):(l.a.Warn("Multiview is not supported, falling back to standard rendering"),e.multiviewEnabled=!1)),e.compensateDistortion&&(r._rigCameras[0]._rigPostProcess=new _s("VR_Distort_Compensation_Left",r._rigCameras[0],!1,e),r._rigCameras[1]._rigPostProcess=new _s("VR_Distort_Compensation_Right",r._rigCameras[1],!0,e))},Q.a.AddNodeConstructor("VRDeviceOrientationFreeCamera",function(r,t){return function(){return new $l(r,0,0,1,u.e.Zero(),t)}});var $l=function(r){function t(e,n,i,o,a,s,d,p){d===void 0&&(d=!0),p===void 0&&(p=_r.GetDefault());var y=r.call(this,e,n,i,o,a,s)||this;return p.compensateDistortion=d,y.setCameraRigMode(gt.a.RIG_MODE_VR,{vrCameraMetrics:p}),y.inputs.addVRDeviceOrientation(),y}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"VRDeviceOrientationArcRotateCamera"},t}(Zi);Q.a.AddNodeConstructor("VRDeviceOrientationFreeCamera",function(r,t){return function(){return new Go(r,u.e.Zero(),t)}});var Go=function(r){function t(e,n,i,o,a){o===void 0&&(o=!0),a===void 0&&(a=_r.GetDefault());var s=r.call(this,e,n,i)||this;return a.compensateDistortion=o,s.setCameraRigMode(gt.a.RIG_MODE_VR,{vrCameraMetrics:a}),s}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"VRDeviceOrientationFreeCamera"},t}(Vo);Q.a.AddNodeConstructor("VRDeviceOrientationGamepadCamera",function(r,t){return function(){return new eu(r,u.e.Zero(),t)}});var eu=function(r){function t(e,n,i,o,a){o===void 0&&(o=!0),a===void 0&&(a=_r.GetDefault());var s=r.call(this,e,n,i,o,a)||this;return s.inputs.addGamepad(),s}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"VRDeviceOrientationGamepadCamera"},t}(Go),zo=f(86);gt.a._setWebVRRigMode=function(r,t){if(t.vrDisplay){var e=t.vrDisplay.getEyeParameters("left"),n=t.vrDisplay.getEyeParameters("right");r._rigCameras[0].viewport=new Wn.a(0,0,.5,1),r._rigCameras[0].setCameraRigParameter("left",!0),r._rigCameras[0].setCameraRigParameter("specs",t.specs),r._rigCameras[0].setCameraRigParameter("eyeParameters",e),r._rigCameras[0].setCameraRigParameter("frameData",t.frameData),r._rigCameras[0].setCameraRigParameter("parentCamera",t.parentCamera),r._rigCameras[0]._cameraRigParams.vrWorkMatrix=new u.a,r._rigCameras[0].getProjectionMatrix=r._getWebVRProjectionMatrix,r._rigCameras[0].parent=r,r._rigCameras[0]._getViewMatrix=r._getWebVRViewMatrix,r._rigCameras[1].viewport=new Wn.a(.5,0,.5,1),r._rigCameras[1].setCameraRigParameter("eyeParameters",n),r._rigCameras[1].setCameraRigParameter("specs",t.specs),r._rigCameras[1].setCameraRigParameter("frameData",t.frameData),r._rigCameras[1].setCameraRigParameter("parentCamera",t.parentCamera),r._rigCameras[1]._cameraRigParams.vrWorkMatrix=new u.a,r._rigCameras[1].getProjectionMatrix=r._getWebVRProjectionMatrix,r._rigCameras[1].parent=r,r._rigCameras[1]._getViewMatrix=r._getWebVRViewMatrix}},Object.defineProperty(Ue.a.prototype,"isInVRExclusivePointerMode",{get:function(){return this._vrExclusivePointerMode},enumerable:!0,configurable:!0}),Ue.a.prototype._prepareVRComponent=function(){this._vrSupported=!1,this._vrExclusivePointerMode=!1,this.onVRDisplayChangedObservable=new x.c,this.onVRRequestPresentComplete=new x.c,this.onVRRequestPresentStart=new x.c},Ue.a.prototype.isVRDevicePresent=function(){return!!this._vrDisplay},Ue.a.prototype.getVRDevice=function(){return this._vrDisplay},Ue.a.prototype.initWebVR=function(){return this.initWebVRAsync(),this.onVRDisplayChangedObservable},Ue.a.prototype.initWebVRAsync=function(){var r=this,t=function(){var n={vrDisplay:r._vrDisplay,vrSupported:r._vrSupported};r.onVRDisplayChangedObservable.notifyObservers(n),r._webVRInitPromise=new Promise(function(i){i(n)})};if(!this._onVrDisplayConnect){this._onVrDisplayConnect=function(n){r._vrDisplay=n.display,t()},this._onVrDisplayDisconnect=function(){r._vrDisplay.cancelAnimationFrame(r._frameHandler),r._vrDisplay=void 0,r._frameHandler=Ue.a.QueueNewFrame(r._boundRenderFunction),t()},this._onVrDisplayPresentChange=function(){r._vrExclusivePointerMode=r._vrDisplay&&r._vrDisplay.isPresenting};var e=this.getHostWindow();e&&(e.addEventListener("vrdisplayconnect",this._onVrDisplayConnect),e.addEventListener("vrdisplaydisconnect",this._onVrDisplayDisconnect),e.addEventListener("vrdisplaypresentchange",this._onVrDisplayPresentChange))}return this._webVRInitPromise=this._webVRInitPromise||this._getVRDisplaysAsync(),this._webVRInitPromise.then(t),this._webVRInitPromise},Ue.a.prototype._getVRDisplaysAsync=function(){var r=this;
1686return new Promise(function(t){navigator.getVRDisplays?navigator.getVRDisplays().then(function(e){r._vrSupported=!0,r._vrDisplay=e[0],t({vrDisplay:r._vrDisplay,vrSupported:r._vrSupported})}):(r._vrDisplay=void 0,r._vrSupported=!1,t({vrDisplay:r._vrDisplay,vrSupported:r._vrSupported}))})},Ue.a.prototype.enableVR=function(r){var t=this;if(this._vrDisplay&&!this._vrDisplay.isPresenting){this.onVRRequestPresentStart.notifyObservers(this);var e={highRefreshRate:!!this.vrPresentationAttributes&&this.vrPresentationAttributes.highRefreshRate,foveationLevel:this.vrPresentationAttributes?this.vrPresentationAttributes.foveationLevel:1,multiview:(this.getCaps().multiview||this.getCaps().oculusMultiview)&&r.useMultiview};this._vrDisplay.requestPresent([Object(c.a)({source:this.getRenderingCanvas(),attributes:e},e)]).then(function(){t.onVRRequestPresentComplete.notifyObservers(!0),t._onVRFullScreenTriggered()}).catch(function(){t.onVRRequestPresentComplete.notifyObservers(!1)})}},Ue.a.prototype._onVRFullScreenTriggered=function(){if(this._vrDisplay&&this._vrDisplay.isPresenting){this._oldSize=new oe.a(this.getRenderWidth(),this.getRenderHeight()),this._oldHardwareScaleFactor=this.getHardwareScalingLevel();var r=this._vrDisplay.getEyeParameters("left");this.setHardwareScalingLevel(1),this.setSize(2*r.renderWidth,r.renderHeight)}else this.setHardwareScalingLevel(this._oldHardwareScaleFactor),this.setSize(this._oldSize.width,this._oldSize.height)},Ue.a.prototype.disableVR=function(){var r=this;this._vrDisplay&&this._vrDisplay.isPresenting&&this._vrDisplay.exitPresent().then(function(){return r._onVRFullScreenTriggered()}).catch(function(){return r._onVRFullScreenTriggered()}),fs.a.IsWindowObjectExist()&&(window.removeEventListener("vrdisplaypointerrestricted",this._onVRDisplayPointerRestricted),window.removeEventListener("vrdisplaypointerunrestricted",this._onVRDisplayPointerUnrestricted),this._onVrDisplayConnect&&(window.removeEventListener("vrdisplayconnect",this._onVrDisplayConnect),this._onVrDisplayDisconnect&&window.removeEventListener("vrdisplaydisconnect",this._onVrDisplayDisconnect),this._onVrDisplayPresentChange&&window.removeEventListener("vrdisplaypresentchange",this._onVrDisplayPresentChange),this._onVrDisplayConnect=null,this._onVrDisplayDisconnect=null))},Ue.a.prototype._connectVREvents=function(r,t){var e=this;if(this._onVRDisplayPointerRestricted=function(){r&&r.requestPointerLock()},this._onVRDisplayPointerUnrestricted=function(){if(t)t.exitPointerLock&&t.exitPointerLock();else{var i=e.getHostWindow();i.document&&i.document.exitPointerLock&&i.document.exitPointerLock()}},fs.a.IsWindowObjectExist()){var n=this.getHostWindow();n.addEventListener("vrdisplaypointerrestricted",this._onVRDisplayPointerRestricted,!1),n.addEventListener("vrdisplaypointerunrestricted",this._onVRDisplayPointerUnrestricted,!1)}},Ue.a.prototype._submitVRFrame=function(){if(this._vrDisplay&&this._vrDisplay.isPresenting)try{this._vrDisplay.submitFrame()}catch(r){Ye.b.Warn("webVR submitFrame has had an unexpected failure: "+r)}},Ue.a.prototype.isVRPresenting=function(){return this._vrDisplay&&this._vrDisplay.isPresenting},Ue.a.prototype._requestVRFrame=function(){this._frameHandler=Ue.a.QueueNewFrame(this._boundRenderFunction,this._vrDisplay)},Q.a.AddNodeConstructor("WebVRFreeCamera",function(r,t){return function(){return new jo(r,u.e.Zero(),t)}}),Q.a.AddNodeConstructor("WebVRGamepadCamera",function(r,t){return function(){return new jo(r,u.e.Zero(),t)}});var jo=function(r){function t(e,n,i,o){o===void 0&&(o={});var a=r.call(this,e,n,i)||this;a.webVROptions=o,a._vrDevice=null,a.rawPose=null,a._specsVersion="1.1",a._attached=!1,a._descendants=[],a._deviceRoomPosition=u.e.Zero(),a._deviceRoomRotationQuaternion=u.b.Identity(),a._standingMatrix=null,a.devicePosition=u.e.Zero(),a.deviceRotationQuaternion=u.b.Identity(),a.deviceScaleFactor=1,a._deviceToWorld=u.a.Identity(),a._worldToDevice=u.a.Identity(),a.controllers=[],a.onControllersAttachedObservable=new x.c,a.onControllerMeshLoadedObservable=new x.c,a.onPoseUpdatedFromDeviceObservable=new x.c,a._poseSet=!1,a.rigParenting=!0,a._defaultHeight=void 0,a._detachIfAttached=function(){var d=a.getEngine().getVRDevice();d&&!d.isPresenting&&a.detachControl()},a._workingVector=u.e.Zero(),a._oneVector=u.e.One(),a._workingMatrix=u.a.Identity(),a._tmpMatrix=new u.a,a._cache.position=u.e.Zero(),o.defaultHeight&&(a._defaultHeight=o.defaultHeight,a.position.y=a._defaultHeight),a.minZ=.1,arguments.length===5&&(a.webVROptions=arguments[4]),a.webVROptions.trackPosition==null&&(a.webVROptions.trackPosition=!0),a.webVROptions.controllerMeshes==null&&(a.webVROptions.controllerMeshes=!0),a.webVROptions.defaultLightingOnControllers==null&&(a.webVROptions.defaultLightingOnControllers=!0),a.rotationQuaternion=new u.b,a.webVROptions&&a.webVROptions.positionScale&&(a.deviceScaleFactor=a.webVROptions.positionScale);var s=a.getEngine();return a._onVREnabled=function(d){d&&a.initControllers()},s.onVRRequestPresentComplete.add(a._onVREnabled),s.initWebVR().add(function(d){d.vrDisplay&&a._vrDevice!==d.vrDisplay&&(a._vrDevice=d.vrDisplay,a.setCameraRigMode(gt.a.RIG_MODE_WEBVR,{parentCamera:a,vrDisplay:a._vrDevice,frameData:a._frameData,specs:a._specsVersion}),a._attached&&a.getEngine().enableVR(a.webVROptions))}),typeof VRFrameData<"u"&&(a._frameData=new VRFrameData),o.useMultiview&&(a.getScene().getEngine().getCaps().multiview?(a._useMultiviewToSingleView=!0,a._rigPostProcess=new gs("VRMultiviewToSingleview",a,1)):(l.a.Warn("Multiview is not supported, falling back to standard rendering"),a._useMultiviewToSingleView=!1)),i.onBeforeCameraRenderObservable.add(function(d){d.parent===a&&a.rigParenting&&(a._descendants=a.getDescendants(!0,function(p){var y=a.controllers.some(function(O){return O._mesh===p}),P=a._rigCameras.indexOf(p)!==-1;return!y&&!P}
1686),a._descendants.forEach(function(p){p.parent=d}))}),i.onAfterCameraRenderObservable.add(function(d){d.parent===a&&a.rigParenting&&a._descendants.forEach(function(p){p.parent=a})}),a}return Object(c.d)(t,r),t.prototype.deviceDistanceToRoomGround=function(){return this._standingMatrix?(this._standingMatrix.getTranslationToRef(this._workingVector),this._deviceRoomPosition.y+this._workingVector.y):this._defaultHeight||0},t.prototype.useStandingMatrix=function(e){var n=this;e===void 0&&(e=function(i){}),this.getEngine().initWebVRAsync().then(function(i){i.vrDisplay&&i.vrDisplay.stageParameters&&i.vrDisplay.stageParameters.sittingToStandingTransform&&n.webVROptions.trackPosition?(n._standingMatrix=new u.a,u.a.FromFloat32ArrayToRefScaled(i.vrDisplay.stageParameters.sittingToStandingTransform,0,1,n._standingMatrix),n.getScene().useRightHandedSystem||n._standingMatrix&&n._standingMatrix.toggleModelMatrixHandInPlace(),e(!0)):e(!1)})},t.prototype.useStandingMatrixAsync=function(){var e=this;return new Promise(function(n){e.useStandingMatrix(function(i){n(i)})})},t.prototype.dispose=function(){this._detachIfAttached(),this.getEngine().onVRRequestPresentComplete.removeCallback(this._onVREnabled),this._updateCacheWhenTrackingDisabledObserver&&this._scene.onBeforeRenderObservable.remove(this._updateCacheWhenTrackingDisabledObserver),r.prototype.dispose.call(this)},t.prototype.getControllerByName=function(e){for(var n=0,i=this.controllers;n<i.length;n++){var o=i[n];if(o.hand===e)return o}return null},Object.defineProperty(t.prototype,"leftController",{get:function(){return this._leftController||(this._leftController=this.getControllerByName("left")),this._leftController},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rightController",{get:function(){return this._rightController||(this._rightController=this.getControllerByName("right")),this._rightController},enumerable:!1,configurable:!0}),t.prototype.getForwardRay=function(e){return e===void 0&&(e=100),this.leftCamera?r.prototype.getForwardRay.call(this,e,this.leftCamera.getWorldMatrix(),this.leftCamera.globalPosition):r.prototype.getForwardRay.call(this,e)},t.prototype._checkInputs=function(){this._vrDevice&&this._vrDevice.isPresenting&&(this._vrDevice.getFrameData(this._frameData),this.updateFromDevice(this._frameData.pose)),r.prototype._checkInputs.call(this)},t.prototype.updateFromDevice=function(e){e&&e.orientation&&e.orientation.length===4&&(this.rawPose=e,this._deviceRoomRotationQuaternion.copyFromFloats(e.orientation[0],e.orientation[1],-e.orientation[2],-e.orientation[3]),this.getScene().useRightHandedSystem&&(this._deviceRoomRotationQuaternion.z*=-1,this._deviceRoomRotationQuaternion.w*=-1),this.webVROptions.trackPosition&&this.rawPose.position&&(this._deviceRoomPosition.copyFromFloats(this.rawPose.position[0],this.rawPose.position[1],-this.rawPose.position[2]),this.get
1686Scene().useRightHandedSystem&&(this._deviceRoomPosition.z*=-1)),this._poseSet=!0)},t.prototype.attachControl=function(e){e=Ye.b.BackCompatCameraNoPreventDefault(arguments),r.prototype.attachControl.call(this,e),this._attached=!0,e=!gt.a.ForceAttachControlToAlwaysPreventDefault&&e,this._vrDevice&&this.getEngine().enableVR(this.webVROptions);var n=this._scene.getEngine().getHostWindow();n&&n.addEventListener("vrdisplaypresentchange",this._detachIfAttached)},t.prototype.detachControl=function(e){this.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver),this.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver),r.prototype.detachControl.call(this),this._attached=!1,this.getEngine().disableVR(),window.removeEventListener("vrdisplaypresentchange",this._detachIfAttached)},t.prototype.getClassName=function(){return"WebVRFreeCamera"},t.prototype.resetToCurrentRotation=function(){this._vrDevice.resetPose()},t.prototype._updateRigCameras=function(){var e=this._rigCameras[0],n=this._rigCameras[1];e.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion),n.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion),e.position.copyFrom(this._deviceRoomPosition),n.position.copyFrom(this._deviceRoomPosition)}
1686,t.prototype._correctPositionIfNotTrackPosition=function(e,n){n===void 0&&(n=!1),this.rawPose&&this.rawPose.position&&!this.webVROptions.trackPosition&&(u.a.TranslationToRef(this.rawPose.position[0],this.rawPose.position[1],-this.rawPose.position[2],this._tmpMatrix),n||this._tmpMatrix.invert(),this._tmpMatrix.multiplyToRef(e,e))},t.prototype._updateCache=function(e){var n=this;this.rotationQuaternion.equals(this._cache.rotationQuaternion)&&this.position.equals(this._cache.position)||(this.updateCacheCalled||(this.updateCacheCalled=!0,this.update()),this.rotationQuaternion.toRotationMatrix(this._workingMatrix),u.e.TransformCoordinatesToRef(this._deviceRoomPosition,this._workingMatrix,this._workingVector),this.devicePosition.subtractToRef(this._workingVector,this._workingVector),u.a.ComposeToRef(this._oneVector,this.rotationQuaternion,this._workingVector,this._deviceToWorld),this._deviceToWorld.getTranslationToRef(this._workingVector),this._workingVector.addInPlace(this.position),this._workingVector.subtractInPlace(this._cache.position),this._deviceToWorld.setTranslation(this._workingVector),this._deviceToWorld.invertToRef(this._worldToDevice),this.controllers.forEach(function(i){i._deviceToWorld.copyFrom(n._deviceToWorld),n._correctPositionIfNotTrackPosition(i._deviceToWorld),i.update()})),e||r.prototype._updateCache.call(this),this.updateCacheCalled=!1},t.prototype._computeDevicePosition=function(){u.e.TransformCoordinatesToRef(this._deviceRoomPosition,this._deviceToWorld,this.devicePosition)},t.prototype.update=function(){this._computeDevicePosition(),u.a.FromQuaternionToRef(this._deviceRoomRotationQuaternion,this._workingMatrix),this._workingMatrix.multiplyToRef(this._deviceToWorld,this._workingMatrix),u.b.FromRotationMatrixToRef(this._workingMatrix,this.deviceRotationQuaternion),this._poseSet&&this.onPoseUpdatedFromDeviceObservable.notifyObservers(null),r.prototype.update.call(this)},t.prototype._getViewMatrix=function(){return u.a.Identity()},t.prototype._getWebVRViewMatrix=function(){var e=this._cameraRigParams.parentCamera;e._updateCache();var n=this._cameraRigParams.left?this._cameraRigParams.frameData.leftViewMatrix:this._cameraRigParams.frameData.rightViewMatrix;return u.a.FromArrayToRef(n,0,this._webvrViewMatrix),this.getScene().useRightHandedSystem||this._webvrViewMatrix.toggleModelMatrixHandInPlace(),this._webvrViewMatrix.getRotationMatrixToRef(this._cameraRotationMatrix),u.e.TransformCoordinatesToRef(this._referencePoint,this._cameraRotationMatrix,this._transformedReferencePoint),this.position.addToRef(this._transformedReferencePoint,this._currentTarget),e.deviceScaleFactor!==1&&(this._webvrViewMatrix.invert(),e.deviceScaleFactor&&(this._webvrViewMatrix.multiplyAtIndex(12,e.deviceScaleFactor),this._webvrViewMatrix.multiplyAtIndex(13,e.deviceScaleFactor),this._webvrViewMatrix.multiplyAtIndex(14,e.deviceScaleFactor)),this._webvrViewMatrix.invert()),e._correctPositionIfNotTrackPosition(this._webvrViewMatrix,!0),e._worldToDevice.multiplyToRef(this._webvrViewMatrix,this._webvrViewMatrix),this._workingMatrix=this._workingMatrix||u.a.Identity(),this._webvrViewMatrix.invertToRef(this._workingMatrix),this._workingMatrix.multiplyToRef(e.getWorldMatrix(),this._workingMatrix),this._workingMatrix.getTranslationToRef(this._globalPosition),this._markSyncedWithParent(),this._webvrViewMatrix},t.prototype._getWebVRProjectionMatrix=function(){var e=this.parent;e._vrDevice.depthNear=e.minZ,e._vrDevice.depthFar=e.maxZ;var n=this._cameraRigParams.left?this._cameraRigParams.frameData.leftProjectionMatrix:this._cameraRigParams.frameData.rightProjectionMatrix;return u.a.FromArrayToRef(n,0,this._projectionMatrix),this.getScene().useRightHandedSystem||this._projectionMatrix.toggleProjectionMatrixHandInPlace(),this._projectionMatrix},t.prototype.initControllers=function(){var e=this;this.controllers=[];var n=this.getScene().gamepadManager;this._onGamepadDisconnectedObserver=n.onGamepadDisconnectedObservable.add(function(i){if(i.type===hn.POSE_ENABLED){var o=i;o.defaultModel&&o.defaultModel.setEnabled(!1),o.hand==="right"&&(e._rightController=null),o.hand==="left"&&(e._leftController=null);var a=e.controllers.indexOf(o);a!==-1&&e.controllers.splice(a,1)}}),this._onGamepadConnectedObserver=n.onGamepadConnectedObservable.add(function(i){if(i.type===hn.POSE_ENABLED){var o=i;if(e.webVROptions.trackPosition||(o._disableTrackPosition(new u.e(o.hand=="left"?-.15:.15,-.5,.25)),e._updateCacheWhenTrackingDisabledObserver||(e._updateCacheWhenTrackingDisabledObserver=e._scene.onBeforeRenderObservable.add(function(){e._updateCache()}))),o.deviceScaleFactor=e.deviceScaleFactor,o._deviceToWorld.copyFrom(e._deviceToWorld),e._correctPositionIfNotTrackPosition(o._deviceToWorld),e.webVROptions.controllerMeshes&&(o.defaultModel?o.defaultModel.setEnabled(!0):o.initControllerMesh(e.getScene(),function(d){if(d.scaling.scaleInPlace(e.deviceScaleFactor),e.onControllerMeshLoadedObservable.notifyObservers(o),e.webVROptions.defaultLightingOnControllers){e._lightOnControllers||(e._lightOnControllers=new zo.a("vrControllersLight",new u.e(0,1,0),e.getSce
1686ne()));var p=function(y,P){var O=y.getChildren();O&&O.length!==0&&O.forEach(function(U){P.includedOnlyMeshes.push(U),p(U,P)})};e._lightOnControllers.includedOnlyMeshes.push(d),p(d,e._lightOnControllers)}})),o.attachToPoseControlledCamera(e),e.controllers.indexOf(o)===-1){e.controllers.push(o);for(var a=!1,s=0;s<e.controllers.length;s++)e.controllers[s].controllerType===ei.VIVE&&(a?e.controllers[s].hand="right":(a=!0,e.controllers[s].hand="left"));e.controllers.length>=2&&e.onControllersAttachedObservable.notifyObservers(e.controllers)}}})},t}(Hn),Ni=function(r){function t(e){var n=r.call(this,e)||this;return n.onTriggerStateChangedObservable=new x.c,n.onMainButtonStateChangedObservable=new x.c,n.onSecondaryButtonStateChangedObservable=new x.c,n.onPadStateChangedObservable=new x.c,n.onPadValuesChangedObservable=new x.c,n.pad={x:0,y:0},n._changes={pressChanged:!1,touchChanged:!1,valueChanged:!1,changed:!1},n._buttons=new Array(e.buttons.length),n.hand=e.hand,n}return Object(c.d)(t,r),t.prototype.onButtonStateChange=function(e){this._onButtonStateChange=e},Object.defineProperty(t.prototype,"defaultModel",{get:function(){return this._defaultModel},enumerable:!1,configurable:!0}),t.prototype.update=function(){r.prototype.update.call(this);for(var e=0;e<this._buttons.length;e++)this._setButtonValue(this.browserGamepad.buttons[e],this._buttons[e],e);this.leftStick.x===this.pad.x&&this.leftStick.y===this.pad.y||(this.pad.x=this.leftStick.x,this.pad.y=this.leftStick.y,this.onPadValuesChangedObservable.notifyObservers(this.pad))},t.prototype._setButtonValue=function(e,n,i){e||(e={pressed:!1,touched:!1,value:0}),n?(this._checkChanges(e,n),this._changes.changed&&(this._onButtonStateChange&&this._onButtonStateChange(this.index,i,e),this._handleButtonChange(i,e,this._changes)),this._buttons[i].pressed=e.pressed,this._buttons[i].touched=e.touched,this._buttons[i].value=e.value<1e-8?0:e.value):this._buttons[i]={pressed:e.pressed,touched:e.touched,value:e.value}},t.prototype._checkChanges=function(e,n){return this._changes.pressChanged=e.pressed!==n.pressed,this._changes.touchChanged=e.touched!==n.touched,this._changes.valueChanged=e.value!==n.value,this._changes.changed=this._changes.pressChanged||this._changes.touchChanged||this._changes.valueChanged,this._changes},t.prototype.dispose=function(){r.prototype.dispose.call(this),this._defaultModel=null,this.onTriggerStateChangedObservable.clear(),this.onMainButtonStateChangedObservable.clear(),this.onSecondaryButtonStateChangedObservable.clear(),this.onPadStateChangedObservable.clear(),this.onPadValuesChangedObservable.clear()},t}(fr),vn=f(42),Ft=f(30),yi=f(62),_p=(f(108),f(59),f(109),`
1687varying vec2 vUV;
1688uniform sampler2D textureSampler;
1689#include<imageProcessingDeclaration>
1690#include<helperFunctions>
1691#include<imageProcessingFunctions>
1692void main(void)
1693{
1694vec4 result=texture2D(textureSampler,vUV);
1695#ifdef IMAGEPROCESSING
1696#ifndef FROMLINEARSPACE
1697
1698result.rgb=toLinearSpace(result.rgb);
1699#endif
1700result=applyImageProcessing(result);
1701#else
1702
1703#ifdef FROMLINEARSPACE
1704result=applyImageProcessing(result);
1705#endif
1706#endif
1707gl_FragColor=result;
1708}`);je.a.ShadersStore.imageProcessingPixelShader=_p;var Ho=function(r){function t(e,n,i,o,a,s,d,p){i===void 0&&(i=null),d===void 0&&(d=h.a.TEXTURETYPE_UNSIGNED_INT);var y=r.call(this,e,"imageProcessing",[],[],n,i,o,a,s,null,d,"postprocess",null,!0)||this;return y._fromLinearSpace=!0,y._defines={IMAGEPROCESSING:!1,VIGNETTE:!1,VIGNETTEBLENDMODEMULTIPLY:!1,VIGNETTEBLENDMODEOPAQUE:!1,TONEMAPPING:!1,TONEMAPPING_ACES:!1,CONTRAST:!1,COLORCURVES:!1,COLORGRADING:!1,COLORGRADING3D:!1,FROMLINEARSPACE:!1,SAMPLER3DGREENDEPTH:!1,SAMPLER3DBGRMAP:!1,IMAGEPROCESSINGPOSTPROCESS:!1,EXPOSURE:!1},p?(p.applyByPostProcess=!0,y._attachImageProcessingConfiguration(p,!0),y.fromLinearSpace=!1):(y._attachImageProcessingConfiguration(null,!0),y.imageProcessingConfiguration.applyByPostProcess=!0),y.onApply=function(P){y.imageProcessingConfiguration.bind(P,y.aspectRatio)},y}return Object(c.d)(t,r),Object.defineProperty(t.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){e.applyByPostProcess=!0,this._attachImageProcessingConfiguration(e)}
1708,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 d=a.scenes;o=d[d.length-1]}else o=te.a.LastCreatedScene;this._imageProcessingConfiguration=o?o.imageProcessingConfiguration:new vn.a}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.vignetteCentreX},set:function(e){this.imageProcessingConfiguration.vignetteCentreX=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteCentreY",{get:function(){return this.imageProcessingConfiguration.vignetteCentreY},set:function(e){this.imageProcessingConfiguration.vignetteCentreY=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}
1708,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,"fromLinearSpace",{get:function(){return this._fromLinearSpace},set:function(e){this._fromLinearSpace!==e&&(this._fromLinearSpace=e,this._updateParameters())},enumerable:!1,configurable:!0}),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)this._defines[n]&&(e+="#define "+n+`;\r
1709`);var i=["textureSampler"],o=["scale"];vn.a&&(vn.a.PrepareSamplers(i,this._defines),vn.a.PrepareUniforms(o,this._defines)),this.updateEffect(e,o,i)},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)},Object(c.c)([Object(L.c)()],t.prototype,"_fromLinearSpace",void 0),t}(_t),ft=f(16),Me=f(4);De.a._GroundMeshParser=function(r,t){return Wo.Parse(r,t)};var Wo=function(r){function t(e,n){var i=r.call(this,e,n)||this;return i.generateOctree=!1,i}return Object(c.d)(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}
1709),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=u.c.Matrix[5];i.invertToRef(o);var a=u.c.Vector3[8];if(u.e.TransformCoordinatesFromFloatsToRef(e,0,n,o,a),e=a.x,n=a.z,e<this._minX||e>this._maxX||n<this._minZ||n>this._maxZ)return this.position.y;this._heightQuads&&this._heightQuads.length!=0||(this._initHeightQuads(),this._computeHeightQuads());var s=this._getFacetAt(e,n),d=-(s.x*e+s.z*n+s.w)/s.y;return u.e.TransformCoordinatesFromFloatsToRef(0,d,0,i,a),a.y},t.prototype.getNormalAtCoordinates=function(e,n){var i=new u.e(0,1,0);return this.getNormalAtCoordinatesToRef(e,n,i),i},t.prototype.getNormalAtCoordinatesToRef=function(e,n,i){var o=this.getWorldMatrix(),a=u.c.Matrix[5];o.invertToRef(a);var s=u.c.Vector3[8];if(u.e.TransformCoordinatesFromFloatsToRef(e,0,n,a,s),e=s.x,n=s.z,e<this._minX||e>this._maxX||n<this._minZ||n>this._maxZ)return this;this._heightQuads&&this._heightQuads.length!=0||(this._initHeightQuads(),this._computeHeightQuads());var d=this._getFacetAt(e,n);return u.e.TransformNormalFromFloatsToRef(d.x,d.y,d.z,o,i),this},t.prototype.updateCoordinateHeights=function(){return this._heightQuads&&this._heightQuads.length!=0||this._initHeightQuads(),this._computeHeightQuads(),this},t.prototype._getFacetAt=function(e,n){var i=Math.floor((e+this._maxX)*this._subdivisionsX/this._width),o=Math.floor(-(n+this._maxZ)*this._subdivisionsY/this._height+this._subdivisionsY),a=this._heightQuads[o*this._subdivisionsX+i];return n<a.slope.x*e+a.slope.y?a.facet1:a.facet2},t.prototype._initHeightQuads=function(){var e=this._subdivisionsX,n=this._subdivisionsY;this._heightQuads=new Array;for(var i=0;i<n;i++)for(var o=0;o<e;o++){var a={slope:u.d.Zero(),facet1:new u.f(0,0,0,0),facet2:new u.f(0,0,0,0)};this._heightQuads[i*e+o]=a}return this},t.prototype._computeHeightQuads=function(){var e=this.getVerticesData(Me.b.PositionKind);if(!e)return this;for(var n=u.c.Vector3[3],i=u.c.Vector3[2],o=u.c.Vector3[1],a=u.c.Vector3[0],s=u.c.Vector3[4],d=u.c.Vector3[5],p=u.c.Vector3[6],y=u.c.Vector3[7],P=u.c.Vector3[8],O=0,U=0,F=0,z=0,J=0,ie=0,se=0,ce=this._subdivisionsX,ue=this._subdivisionsY,fe=0;fe<ue;fe++)for(var ve=0;ve<ce;ve++){O=3*ve,U=fe*(ce+1)*3,F=(fe+1)*(ce+1)*3,n.x=e[U+O],n.y=e[U+O+1],n.z=e[U+O+2],i.x=e[U+O+3],i.y=e[U+O+4],i.z=e[U+O+5],o.x=e[F+O],o.y=e[F+O+1],o.z=e[F+O+2],a.x=e[F+O+3],a.y=e[F+O+4],a.z=e[F+O+5],z=(a.z-n.z)/(a.x-n.x),J=n.z-z*n.x,i.subtractToRef(n,s),o.subtractToRef(n,d),a.subtractToRef(n,p),u.e.CrossToRef(p,d,y),u.e.CrossToRef(s,p,P),y.normalize(),P.normalize(),ie=-(y.x*n.x+y.y*n.y+y.z*n.z),se=-(P.x*i.x+P.y*i.y+P.z*i.z);var Te=this._heightQuads[fe*ce+ve];Te.slope.copyFromFloats(z,J),Te.facet1.copyFromFloats(y.x,y.y,y.z,ie),Te.facet2.copyFromFloats(P.x,P.y,P.z,se)}return this},t.prototype.serialize=function(e){r.prototype.serialize.call(this,e),e.subdivisionsX=this._subdivisionsX,e.subdivisionsY=this._subdivisionsY,e.minX=this._minX,e.maxX=this._maxX,e.minZ=this._minZ,e.maxZ=this._maxZ,e.width=this._width,e.height=this._height},t.Parse=function(e,n){var i=new t(e.name,n);return i._subdivisionsX=e.subdivisionsX||1,i._subdivisionsY=e.subdivisionsY||1,i._minX=e.minX,i._maxX=e.maxX,i._minZ=e.minZ,i._maxZ=e.maxZ,i._width=e.width,i._height=e.height,i},t}(De.a),vs=f(70);ft.a.CreateGround=function(r){var t,e,n=[],i=[],o=[],a=[],s=r.width||1,d=r.height||1,p=r.subdivisionsX||r.subdivisions||1,y=r.subdivisionsY||r.subdivisions||1;for(t=0;t<=y;t++)for(e=0;e<=p;e++){var P=new u.e(e*s/p-s/2,0,(y-t)*d/y-d/2),O=new u.e(0,1,0);i.push(P.x,P.y,P.z),o.push(O.x,O.y,O.z),a.push(e/p,1-t/y)}for(t=0;t<y;t++)for(e=0;e<p;e++)n.push(e+1+(t+1)*(p+1)),n.push(e+1+t*(p+1)),n.push(e+t*(p+1)),n.push(e+(t+1)*(p+1)),n.push(e+1+(t+1)*(p+1)),n.push(e+t*(p+1));var U=new ft.a;return U.indices=n,U.positions=i,U.normals=o,U.uvs=a,U},ft.a.CreateTiledGround=function(r){var t,e,n,i,o=r.xmin!==void 0&&r.xmin!==null?r.xmin:-1,a=r.zmin!==void 0&&r.zmin!==null?r.zmin:-1,s=r.xmax!==void 0&&r.xmax!==null?r.xmax:1,d=r.zmax!==void 0&&r.zmax!==null?r.zmax:1,p=r.subdivisions||{w:1,h:1},y=r.precision||{w:1,h:1},P=new Array,O=new Array,U=new Array,F=new Array;p.h=p.h<1?1:p.h,p.w=p.w<1?1:p.w,y.w=y.w<1?1:y.w,y.h=y.h<1?1:y.h;var z=(s-o)/p.w,J=(d-a)/p.h;function ie(ce,ue,fe,ve){var Te=O.length/3,Oe=y.w+1;for(t=0;t<y.h;t++)for(e=0;e<y.w;e++){var Pe=[Te+e+t*Oe,Te+(e+1)+t*Oe,Te+(e+1)+(t+1)*Oe,Te+e+(t+1)*Oe];P.push(Pe[1]),P.push(Pe[2]),P.push(Pe[3]),P.push(Pe[0]),P.push(Pe[1]),P.push(Pe[3])}var Ee=u.e.Zero(),Se=new u.e(0,1,0);for(t=0;t<=y.h;t++)for(Ee.z=t*(ve-ue)/y.h+ue,e=0;e<=y.w;e++)Ee.x=e*(fe-ce)/y.w+ce,Ee.y=0,O.push(Ee.x,Ee.y,Ee.z),U.push(Se.x,Se.y,Se.z),F.push(e/y.w,t/y.h)}for(n=0;n<p.h;n++)for(i=0;i<p.w;i++)ie(o+i*z,a+n*J,o+(i+1)*z,a+(n+1)*J);var se=new ft.a;return se.indices=P,se.positions=O,se.normals=U,se.uvs=F,se},ft.a.CreateGroundFromHeightMap=function(r){var t,e,n=[],i=[],o=[],a=[],s=r.colorFilter||new M.a(.3,.59,.11),d=r.alphaFilter||0,p=!1;if(r.minHeight>r.maxHeight){p=!0;var y=r.maxHeight;r.maxHeight=r.minHeight,r.minHeight=y}for(t=0;t<=r.subdivisions;t++)for(e=0;e<=r.subdivisions;e++){var P=new u.e(e*r.width/r.subdivisions-r.width/2,0,(r.subdivisions-t)*r.height/r.subdivisions-r.height/2),O=4*(((P.x+r.width/2)/r.width*(r.bufferWidth-1)|0)+((1-(P.z+r.height/2)/r.height)*(r.bufferHeight-1)|0)*r.bufferWidth),U=r.buffer[O]/255,F=r.buffer[O+1]/255,z=r.buffer[O+2]/255,J=r.buffer[O+3]/255;p&&(U=1-U,F=1-F,z=1-z);var ie=U*s.r+F*s.g+z*s.b;P.y=J>=d?r.minHeight+(r.maxHeight-r.minHeight)*ie:r.minHeight-Gt.a,i.push(P.x,P.y,P.z),o.push(0,0,0),a.push(e/r.subdivisions,1-t/r.subdivisions)}for(t=0;t<r.subdivisions;t++)for(e=0;e<r.subdivisions;e++){var se=e+1+(t+1)*(r.subdivisions+1),ce=e+1+t*(r.subdivisions+1),ue=e+t*(r.subdivisions+1),fe=e+(t+1)*(r.subdivisions+1),ve=i[3*se+1]>=r.minHeight,Te=i[3*ce+1]>=r.minHeight,Oe=i[3*ue+1]>=r.minHeight;ve&&Te&&Oe&&(n.push(se),n.push(ce),n.push(ue)),i[3*fe+1]>=r.minHeight&&ve&&Oe&&(n.push(fe),n.push(se),n.push(ue))}ft.a.ComputeNormals(i,n,o);var Pe=new ft.a;return Pe.indices=n,Pe.positions=i,Pe.normals=o,Pe.uvs=a,Pe},De.a.CreateGround=function(r,t,e,n,i,o){var a={width:t,height:e,subdivisions:n,updatable:o};return wi.CreateGround(r,a,i)},De.a.CreateTiledGround=function(r,t,e,n,i,o,a,s,d){var p={xmin:t,zmin:e,xmax:n,zmax:i,subdivisions:o,precision:a,updatable:d};return wi.CreateTiledGround(r,p,s)},De.a.CreateGroundFromHeightMap=function(r,t,e,n,i,o,a,s,d,p,y){var P={width:e,height:n,subdivisions:i,minHeight:o,maxHeight:a,updatable:d,onReady:p,alphaFilter:y};return wi.CreateGroundFromHeightMap(r,t,P,s)};var wi=function(){function r(){}return r.CreateGround=function(t,e,n){var i=new Wo(t,n);return i._setReady(!1),i._subdivisionsX=e.subdivisionsX||e.subdivisions||1,i._subdivisionsY=e.subdivisionsY||e.subdivisions||1,i._width=e.width||1,i._height=e.height||1,i._maxX=i._width/2,i._maxZ=i._height/2,i._minX=-i._maxX,i._minZ=-i._maxZ,ft.a.CreateGround(e).applyToMesh(i,e.updatable),i._setReady(!0),i},r.CreateTiledGround=function(t,e,n){n===void 0&&(n=null);var i=new De.a(t,n);return ft.a.CreateTiledGround(e).applyToMesh(i,e.updatable),i},r.CreateGroundFromHeightMap=function(t,e,n,i){i===void 0&&(i=null);var o=n.width||10,a=n.height||10,s=n.subdivisions||1,d=n.minHeight||0,p=n.maxHeight||1,y=n.colorFilter||new M.a(.3,.59,.11),P=n.alphaFilter||0,O=n.updatable,U=n.onReady;i=i||te.a.LastCreatedScene;var F=new Wo(t,i);return F._subdivisionsX=s,F._subdivisionsY=s,F._width=o,F._height=a,F._maxX=F._width/2,F._maxZ=F._height/2,F._minX=-F._maxX,F._minZ=-F._maxZ,F._setReady(!1),Ye.b.LoadImage(e,function(z){var J=z.width,ie=z.height,se=vs.a.CreateCanvas(J,ie).getContext("2d");if(!se)throw new Error("Unable to get 2d context for CreateGroundFromHeightMap");if(!i.isDisposed){se.drawImage(z,0,0);var ce=se.getImageData(0,0,J,ie).data;ft.a.CreateGroundFromHeightMap({width:o,height:a,subdivisions:s,minHeight:d,maxHeight:p,colorFilter:y,buffer:ce,bufferWidth:J,bufferHeight:ie,alphaFilter:P}).applyToMesh(F,O),U&&U(F),F._setReady(!0)}},function(){},i.offlineProvider),F},r}();ft.a.CreateTorus=function(r){for(var t=[],e=[],n=[],i=[],o=r.diameter||1,a=r.thickness||.5,s=r.tessellation||16,d=r.sideOrientation===0?0:r.sideOrientation||ft.a.DEFAULTSIDE,p=s+1,y=0;y<=s;y++)for(var P=y/s,O=y*Math.PI*2/s-Math.PI/2,U=u.a.Translation(o/2,0,0).multiply(u.a.RotationY(O)),F=0;F<=s;F++){var z=1-F/s,J=F*Math.PI*2/s+Math.PI,ie=Math.cos(J),se=Math.sin(J),ce=new u.e(ie,se,0),ue=ce.scale(a/2),fe=new u.d(P,z);ue=u.e.TransformCoordinates(ue,U),ce=u.e.TransformNormal(ce,U),e.push(ue.x,ue.y,ue.z),n.push(ce.x,ce.y,ce.z),i.push(fe.x,fe.y
1709);var ve=(y+1)%p,Te=(F+1)%p;t.push(y*p+F),t.push(y*p+Te),t.push(ve*p+F),t.push(y*p+Te),t.push(ve*p+Te),t.push(ve*p+F)}ft.a._ComputeSides(d,e,t,n,i,r.frontUVs,r.backUVs);var Oe=new ft.a;return Oe.indices=t,Oe.positions=e,Oe.normals=n,Oe.uvs=i,Oe},De.a.CreateTorus=function(r,t,e,n,i,o,a){var s={diameter:t,thickness:e,tessellation:n,sideOrientation:a,updatable:o};return mr.CreateTorus(r,s,i)};var fn,er,mr=function(){function r(){}return r.CreateTorus=function(t,e,n){var i=new De.a(t,n);return e.sideOrientation=De.a._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,ft.a.CreateTorus(e).applyToMesh(i,e.updatable),i},r}(),ui=f(53),bs=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,multiview:!1,framebufferScaleFactor:1},e.newCanvasCssStyle="position:absolute; bottom:0px;right:0px;z-index:10;width:90%;height:100%;background-color: #000000;",e},r}(),tu=function(){function r(t,e){var n=this;if(e===void 0&&(e=bs.GetDefaults()),this._options=e,this._canvas=null,this.xrLayer=null,this.onXRLayerInitObservable=new x.c,this._engine=t.sce
1709ne.getEngine(),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()})}return r.prototype.dispose=function(){this._removeCanvas(),this._setManagedOutputCanvas(null)},r.prototype.initializeXRLayerAsync=function(t){var e=this,n=function(){var i=new XRWebGLLayer(t,e.canvasContext,e._options.canvasOptions);return e.onXRLayerInitObservable.notifyObservers(i),i};return this.canvasContext.makeXRCompatible?this.canvasContext.makeXRCompatible().then(function(){return e.xrLayer=n(),e.xrLayer}):(this.xrLayer=n(),Promise.resolve(this.xrLayer))},r.prototype._addCanvas=function(){var t=this;this._canvas&&this._canvas!==this._engine.getRenderingCanvas()&&document.body.appendChild(this._canvas),this.xrLayer?this._setCanvasSize(!0):this.onXRLayerInitObservable.addOnce(function(e){t._setCanvasSize(!0,e)})},r.prototype._removeCanvas=function(){this._canvas&&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.xrLayer),this._canvas&&(t?e&&(this._canvas!==this._engine.getRenderingCanvas()?(this._canvas.style.width=e.framebufferWidth+"px",this._canvas.style.height=e.framebufferHeight+"px"):this._engine.setSize(e.framebufferWidth,e.framebufferHeight)):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}(),ys=function(){function r(t){this.scene=t,this._sessionEnded=!1,this.baseLayer=null,this.currentTimestamp=-1,this.defaultHeightCompensation=1.7,this.onXRFrameObservable=new x.c,this.onXRReferenceSpaceChanged=new x.c,this.onXRSessionEnded=new x.c,this.onXRSessionInit=new x.c}return 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}),r.prototype.dispose=function(){this._sessionEnded||this.exitXRAsync(),this.onXRFrameObservable.clear(),this.onXRSessionEnded.clear(),this.onXRReferenceSpaceChanged.clear(),this.onXRSessionInit.clear()},r.prototype.exitXRAsync=function(){return this.session&&!this._sessionEnded?(this._sessionEnded=!0,this.session.end().catch(function(t){l.a.Warn("Could not end XR session.")})):Promise.resolve()},r.prototype.getRenderTargetTextureForEye=function(t){return this._rttProvider.getRenderTargetForEye(t)},r.prototype.getWebXRRenderTarget=function(t){var e=this.scene.getEngine();return this._xrNavigator.xr.native?this._xrNavigator.xr.getWebXRRenderTarget(e):((t=t||bs.GetDefaults(e)).canvasElement=e.getRenderingCanvas()||void 0,new tu(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.onXRSessionInit.notifyObservers(i),n._sessionEnded=!1,n.session.addEventListener("end",function(){var o=n.scene.getEngine();n._sessionEnded=!0,n._rttProvider=null,o.framebufferDimensionsObject=null,o.restoreDefaultFramebuffer(),o.customAnimationFrameRequester=null,n.onXRSessionEnded.notifyObservers(null),o._renderLoop()},{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=this,e=this.scene.getEngine();if(e.customAnimationFrameRequester={requestAnimationFrame:this.session.requestAnimationFrame.bind(this.session),renderFunction:function(i,o){t._sessionEnded||(t.currentFrame=o,t.currentTimestamp=i,o&&(e.framebufferDimensionsObject=t.baseLayer,t.onXRFrameObservable.notifyObservers(o),e._renderLoop(),e.framebufferDimensionsObject=null))}},this._xrNavigator.xr.native)this._rttProvider=this._xrNavigator.xr.getNativeRenderTargetProvider(this.session,this._createRenderTargetTexture.bind(this));else{var n=this._createRenderTargetTexture(this.baseLayer.framebufferWidth,this.baseLayer.framebufferHeight,this.baseLayer.framebuffer);this._rttProvider={getRenderTargetForEye:function(){return n}},e.framebufferDimensionsObject=this.baseLayer}typeof window<"u"&&window.cancelAnimationFrame&&window.cancelAnimationFrame(e._frameHandler),e._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 l.a.Error("XR.requestReferenceSpace failed for the following reason: "),l.a.Error(n),l.a.Log('Defaulting to universally-supported "viewer" reference space type.'),e.session.requestReferenceSpace("viewer").then(function(i){var o=new XRRigidTransform({x:0,y:-e.defaultHeight
1709Compensation,z:0});return i.getOffsetReferenceSpace(o)},function(i){throw l.a.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.referenceSpace})},r.prototype.updateRenderStateAsync=function(t){return t.baseLayer&&(this.baseLayer=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 l.a.Warn(n),Promise.resolve(!1)}):Promise.resolve(!1)},r.prototype._createRenderTargetTexture=function(t,e,n){n===void 0&&(n=null);var i=new xt.a(this.scene.getEngine(),xt.b.Unknown,!0);i.width=t,i.height=e,i._framebuffer=n;var o=new sn("XR renderTargetTexture",{width:t,height:e},this.scene,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,!0);return o._texture=i,o},r}();(function(r){r[r.ENTERING_XR=0]="ENTERING_XR",r[r.EXITING_XR=1]="EXITING_XR",r[r.IN_XR=2]="IN_XR",r[r.NOT_IN_XR=3]="NOT_IN_XR"})(fn||(fn={})),function(r){r[r.NOT_TRACKING=0]="NOT_TRACKING",r[r.TRACKING_LOST=1]="TRACKING_LOST",r[r.TRACKING=2]="TRACKING"}(er||(er={}));var ti,nu=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=De.a.CreateTorus("gazeTracker",.0035,.0025,20,t,!1),this._gazeTracker.bakeCurrentTransformIntoVertices(),this._gazeTracker.isPickable=!1,this._gazeTracker.isVisible=!1;var n=new Ft.a("targetMat",t);n.specularColor=M.a.Black(),n.emissiveColor=new M.a(.7,.7,.7),n.backFaceCulling=!1,this._gazeTracker.material=n}}return r.prototype._getForwardRay=function(t){return new dn.a(u.e.Zero(),new u.e(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}(),mp=function(r){function t(e,n,i){var o=r.call(this,n,i)||this;o.webVRController=e,o._laserPointer=De.a.CreateCylinder("laserPointer",1,.004,2e-4,20,1,n,!1);var a=new Ft.a("laserPointerMat",n);if(a.emissiveColor=new M.a(.7,.7,.7),a.alpha=.6,o._laserPointer.material=a,o._laserPointer.rotation.x=Math.PI/2,o._laserPointer.position.z=-.5,o._laserPointer.isVisible=!1,o._laserPointer.isPickable=!1,!e.mesh){var s=new De.a("preloadControllerMesh",n),d=new De.a(fr.POINTING_POSE,n);d.rotation.x=-.7,s.addChild(d),e.attachToMesh(s)}return o._setLaserPointerParent(e.mesh),o._meshAttachedObserver=e._meshAttachedObservable.add(function(p){o._setLaserPointerParent(p)}),o}return Object(c.d)(t,r),t.prototype._getForwardRay=function(e){return this.webVRController.getForwardRay(e)},t.prototype._activatePointer=function(){r.prototype._activatePointer.call(this),this._laserPointer.isVisible=!0},t.prototype._deactivatePointer=function(){r.prototype._deactivatePointer.call(this),this._laserPointer.isVisible=!1},t.prototype._setLaserPointerColor=function(e){this._laserPointer.material.emissiveColor=e},t.prototype._setLaserPointerLightingDisabled=function(e){this._laserPointer.material.disableLighting=e},t.prototype._setLaserPointerParent=function(e){var n=function(s){s.isPickable=!1,s.getChildMeshes().forEac
1709h(function(d){n(d)})};n(e);var i=e.getChildren(void 0,!1),o=e;this.webVRController._pointingPoseNode=null;for(var a=0;a<i.length;a++)if(i[a].name&&i[a].name.indexOf(fr.POINTING_POSE)>=0){o=i[a],this.webVRController._pointingPoseNode=o;break}this._laserPointer.parent=o},t.prototype._updatePointerDistance=function(e){e===void 0&&(e=100),this._laserPointer.scaling.y=e,this._laserPointer.position.z=-e/2},t.prototype.dispose=function(){r.prototype.dispose.call(this),this._laserPointer.dispose(),this._meshAttachedObserver&&this.webVRController._meshAttachedObservable.remove(this._meshAttachedObserver)},t}(nu),iu=function(r){function t(e,n){var i=r.call(this,n)||this;return i.getCamera=e,i}return Object(c.d)(t,r),t.prototype._getForwardRay=function(e){var n=this.getCamera();return n?n.getForwardRay(e):new dn.a(u.e.Zero(),u.e.Forward())},t}(nu),gp=function(){},ru=function(){function r(t,e){var n=this;if(e===void 0&&(e={}),this.webVROptions=e,this._webVRsupported=!1,this._webVRready=!1,this._webVRrequesting=!1,this._webVRpresenting=!1,this._fullscreenVRpresenting=!1,this.enableGazeEvenWhenNoPointerLock=!1,this.exitVROnDoubleTap=!0,this.onEnteringVRObservable=new x.c,this.onAfterEnteringVRObservable=new x.c,this.onExitingVRObservable=new x.c,this.onControllerMeshLoadedObservable=new x.c,this._useCustomVRButton=!1,this._teleportationRequested=!1,this._teleportActive=!1,this._floorMeshesCollection=[],this._teleportationMode=r.TELEPORTATIONMODE_CONSTANTTIME,this._teleportationTime=122,this._teleportationSpeed=20,this._rotationAllowed=!0,this._teleportBackwardsVector=new u.e(0,-1,-1),this._isDefaultTeleportationTarget=!0,this._teleportationFillColor="#444444",this._teleportationBorderColor="#FFFFFF",this._rotationAngle=0,this._haloCenter=new u.e(0,0,0),this._padSensibilityUp=.65,this._padSensibilityDown=.35,this._leftController=null,this._rightController=null,this._gazeColor=new M.a(.7,.7,.7),this._laserColor=new M.a(.7,.7,.7),this._pickedLaserColor=new M.a(.2,.2,1),this._pickedGazeColor=new M.a(0,0,1),this.onNewMeshSelected=new x.c,this.onMeshSelectedWithController=new x.c,this.onNewMeshPicked=new x.c,this.onBeforeCameraTeleport=new x.c,this.onAfterCameraTeleport=new x.c,this.onSelectedMeshUnselected=new x.c,this.teleportationEnabled=!0,this._teleportationInitialized=!1,this._interactionsEnabled=!1,this._interactionsRequested=!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(),n._fullscreenVRpresenting&&n._webVRready&&n.exitVR()},this._onFullscreenChange=function(){var o=document;o.fullscreen!==void 0?n._fullscreenVRpresenting=document.fullscreen:o.mozFullScreen!==void 0?n._fullscreenVRpresenting=o.mozFullScreen:o.webkitIsFullScreen!==void 0?n._fullscreenVRpresenting=o.webkitIsFullScreen:o.msIsFullScreen!==void 0?n._fullscreenVRpresenting=o.msIsFullScreen:document.msFullscreenElement!==void 0&&(n._fullscreenVRpresenting=document.msFullscreenElement),!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._leftController&&n._leftController._activePointer&&n._castRayAndSelectObject(n._leftController),n._rightController&&n._rightController._activePointer&&n._castRayAndSelectObject(n._rightController),n._noControllerIsActive&&(n._scene.getEngine().isPointerLock||n.enableGazeEvenWhenNoPointerLock)?n._castRayAndSelectObject(n._cameraGazer):n._cameraGazer._gazeTracker.isVisible=!1},this._onNewGamepadConnected=function(o){if(o.type!==hn.POSE_ENABLED)o.leftStick&&o.onleftstickchanged(function(d){n._teleportationInitialized&&n.teleportationEnabled&&(!n._leftController&&!n._rightController||n._leftController&&!n._leftController._activePointer&&n._rightController&&!n._rightController._activePointer)&&(n._checkTeleportWithRay(d,n._cameraGazer),n._checkTeleportBackwards(d,n._cameraGazer))}),o.rightStick&&o.onrightstickchanged(function(d){n._teleportationInitialized&&n._checkRotate(d,n._cameraGazer)}),o.type===hn.XBOX&&(o.onbuttondown(function(d){n._interactionsEnabled&&d===Cn.A&&n._cameraGazer._selectionPointerDown()}),o.onbuttonup(function(d){n._interactionsEnabled&&d===Cn.A&&n._cameraGazer._selectionPointerUp()}));else{var a=o,s=new mp(a,n._scene,n._cameraGazer._gazeTracker);a.hand==="right"||n._leftController&&n._leftController.webVRController!=a?n._rightController=s:n._leftController=s,n._tryEnableInteractionOnController(s)}},this._tryEnableInteractionOnController=function(o){n._interactionsRequested&&!o._interactionsEnabled&&n._enableInteractionOnController(o),n._teleportationRequested&&!o._teleportationEnabled&&n._enableTeleportationOnController(o)},this._onNewGamepadDisconnected=function(o){o instanceof Ni&&(o.hand==="left"&&n._leftController!=null&&(n._leftController.dispose(),n._leftController=null),o.hand==="right"&&n._rightController!=null&&(n._rightController.dispose(),n._rightController=null))},this._workingVector=u.e.Zero(),this._workingQuaternion=u.b.Identity(),this._workingMatrix=u.a.Identity(),this._scene=t,this._inputElement=t.getEngine().getInputElement(),"getVRDisplays"in navigator||(e.useXR=!0),e.createFallbackVRDeviceOrientationFreeCamera===void 0&&(e.createFallbackVRDeviceOrientationFreeCamera=!0),e.createDeviceOrientationCamera===void 0&&(e.createDeviceOrientationCamera=!0),e.laserToggle===void 0&&(e.laserToggle=!0),e.defaultHeight===void 0&&(e.defaultHeight=1.7),e.useCustomVRButton&&(this._useCustomVRButton=!0,e.customVRButton&&(this._btnVR=e.customVRButton)),e.rayLength&&(this._rayLength=e.rayLength),this._defaultHeight=e.defaultHeight,e.positionScale&&(this._rayLength*=e.positionScale,this._defaultHeight*=e.positionScale),this._hasEnteredVR=!1,this._scene.activeCamera?this._position=this._scene.activeCamera.position.clone():this._position=new u.e(0,this._defaultHeight,0),e.createDeviceOrientationCamera||!this._scene.activeCamera){
1709if(this._deviceOrientationCamera=new Vo("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 Ii&&this._scene.activeCamera.rotation)){var i=this._scene.activeCamera;i.rotationQuaternion?this._deviceOrientationCamera.rotationQuaternion.copyFrom(i.rotationQuaternion):this._deviceOrientationCamera.rotationQuaternion.copyFrom(u.b.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?ys.IsSessionSupportedAsync("immersive-vr").then(function(o){o?(l.a.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 iu(function(){return n.xr.baseExperience.camera},t),n.xr.baseExperience.onStateChangedObservable.add(function(s){switch(s){case fn.ENTERING_XR:n.onEnteringVRObservable.notifyObservers(n),n._interactionsEnabled||n.xr.pointerSelection.detach(),n.xr.pointerSelection.displayLaserPointer=n._displayLaserPointer;break;case fn.EXITING_XR:n.onExitingVRObservable.notifyObservers(n),n._scene.getEngine().resize();break;case fn.IN_XR:n._hasEnteredVR=!0;break;case fn.NOT_IN_XR: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,"onControllerMeshLoaded",{get:function(){return this.onControllerMeshLoadedObservable},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._leftController&&this._leftController._gazeTracker&&this._leftController._gazeTracker.dispose(),this._rightController&&this._rightController._gazeTracker&&this._rightController._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",this._leftController&&(this._leftController._gazeTracker=this._cameraGazer._gazeTracker.clone("gazeTracker")),this._rightController&&(this._rightController._gazeTracker=this._cameraGazer._gazeTracker.clone("gazeTracker")))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"leftControllerGazeTrackerMesh",{get:function(){return this._leftController?this._leftController._gazeTracker:null},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"rightControllerGazeTrackerMesh",{get:function(){return this._rightController?this._rightController._gazeTracker:null},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,this._leftController&&(this._leftController._gazeTracker.isVisible=!1),this._rightController&&(this._rightController._gazeTracker.isVisible=!1))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"displayLaserPointer",{get:function(){return this._displayLaserPointer},set:function(t){this._displayLaserPointer=t,t?(this._rightController&&this._rightController._activatePointer(),this._leftController&&this._leftController._activatePointer()):(this._rightController&&(this._rightController._deactivatePointer(),this._rightController._gazeTracker.isVisible=!1),this._leftController&&(this._leftController._deactivatePointer(),this._leftController._gazeTracker.isVisible=!1))}
1709,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._webVRready?this._webVRCamera:this._scene.activeCamera},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"webVRCamera",{get:function(){return this._webVRCamera},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||this._leftController!==null&&this._leftController._teleportationRequestInitiated||this._rightController!==null&&this._rightController._teleportationRequestInitiated},enumerable:!1,configurable:!0}),r.prototype.completeVRInit=function(t,e){var n=this;if(this.xrTestDone=!0,e.createFallbackVRDeviceOrientationFreeCamera&&(e.useMultiview&&(e.vrDeviceOrientationCameraMetrics||(e.vrDeviceOrientationCameraMetrics=_r.GetDefault()),e.vrDeviceOrientationCameraMetrics.multiviewEnabled=!0),this._vrDeviceOrientationCamera=new Go("VRDeviceOrientationVRHelper",this._position,this._scene,!0,e.vrDeviceOrientationCameraMetrics),this._vrDeviceOrientationCamera.angularSensibility=Number.MAX_VALUE),this._webVRCamera=new jo("WebVRHelper",this._position,this._scene,e),this._webVRCamera.useStandingMatrix(),this._cameraGazer=new iu(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._scene.getEngine().disableVR():n.enterVR()});var a=this._scene.getEngine().getHostWindow();a&&(a.addEventListener("resize",this._onResize),document.addEventListener("fullscreenchange",this._onFullscreenChange,!1),document.addEventListener("mozfullscreenchange",this._onFullscreenChange,!1),document.addEventListener("webkitfullscreenchange",this._onFullscreenChange,!1),document.addEventListener("msfullscreenchange",this._onFullscreenChange,!1),document.onmsfullscreenchange=this._onFullscreenChange,e.createFallbackVRDeviceOrientationFreeCamera?this.displayVRButton():this._scene.getEngine().onVRDisplayChangedObservable.add(function(s){s.vrDisplay&&n.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())},Tt.a.POINTERDOUBLETAP,!1),this._onVRDisplayChanged=function(s){return n.onVRDisplayChanged(s)},this._onVrDisplayPresentChange=function(){return n.onVrDisplayPresentChange()},this._onVRRequestPresentStart=function(){n._webVRrequesting=!0,n.updateButtonVisibility()},this._onVRRequestPresentComplete=function(){n._webVRrequesting=!1,n.updateButtonVisibility()},t.getEngine().onVRDisplayChangedObservable.add(this._onVRDisplayChanged),t.getEngine().onVRRequestPresentStart.add(this._onVRRequestPresentStart),t.getEngine().onVRRequestPresentComplete.add(this._onVRRequestPresentComplete),a.addEventListener("vrdisplaypresentchange",this._onVrDisplayPresentChange),t.onDisposeObservable.add(function(){n.dispose()}),this._webVRCamera.onControllerMeshLoadedObservable.add(function(s){return n._onDefaultMeshLoaded(s)}),this._scene.gamepadManager.onGamepadConnectedObservable.add(this._onNewGamepadConnected),this._scene.gamepadManager.onGamepadDisconnectedObservable.add(this._onNewGamepadDisconnected),this.updateButtonVisibility(),this._circleEase=new it,this._circleEase.setEasingMode(ze.EASINGMODE_EASEINOUT),this._teleportationEasing=this._circleEase,t.onPointerObservable.add(function(s){n._interactionsEnabled&&t.activeCamera===n.vrDeviceOrientationCamera&&s.event.pointerType==="mouse"&&(s.type===Tt.a.POINTERDOWN?n._cameraGazer._selectionPointerDown():s.type===Tt.a.POINTERUP&&n._cameraGazer._selectionPointerUp())}),this.webVROptions.floorMeshes&&this.enableTeleportation({floorMeshes:this.webVROptions.floorMeshes}))},r.prototype._onDefaultMeshLoaded=function(t){this._leftController&&this._leftController.webVRController==t&&t.mesh&&this._leftController._setLaserPointerParent(t.mesh),this._rightController&&this._rightController.webVRController==t&&t.mesh&&this._rightController._setLaserPointerParent(t.mesh);try{this.onControllerMeshLoadedObservable.notifyObservers(t)}catch(e){l.a.Warn("Error in your custom logic onControllerMeshLoaded: "+e)}},Object.defineProperty(r.prototype,"isInVRMode",{get:function(){return this.xr&&this.webVROptions.useXR&&this.xr.baseExperience.state===fn.IN_XR||this._webVRpresenting||this._fullscreenVRpresenting}
1709,enumerable:!1,configurable:!0}),r.prototype.onVrDisplayPresentChange=function(){var t=this._scene.getEngine().getVRDevice();if(t){var e=this._webVRpresenting;this._webVRpresenting=t.isPresenting,e&&!this._webVRpresenting&&this.exitVR()}else l.a.Warn("Detected VRDisplayPresentChange on an unknown VRDisplay. Did you can enterVR on the vrExperienceHelper?");this.updateButtonVisibility()},r.prototype.onVRDisplayChanged=function(t){this._webVRsupported=t.vrSupported,this._webVRready=!!t.vrDisplay,this._webVRpresenting=t.vrDisplay&&t.vrDisplay.isPresenting,this.updateButtonVisibility()},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":(this._webVRready&&(this._btnVR.className+=" vrdisplayready"),this._webVRsupported&&(this._btnVR.className+=" vrdisplaysupported"),this._webVRrequesting&&(this._btnVR.className+=" vrdisplayrequesting")))},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(o){l.a.Warn("Error in your custom logic onEnteringVR: "+o)}if(this._scene.activeCamera){if(this._position=this._scene.activeCamera.position.clone(),this.vrDeviceOrientationCamera&&(this.vrDeviceOrientationCamera.rotation=u.b.FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles(),this.vrDeviceOrientationCamera.angularSensibility=2e3),this.webVRCamera){var e=this.webVRCamera.deviceRotationQuaternion.toEulerAngles().y,n=u.b.FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles().y-e,i=this.webVRCamera.rotationQuaternion.toEulerAngles().y;this.webVRCamera.rotationQuaternion=u.b.FromEulerAngles(0,i+n,0)}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._webVRrequesting||(this._webVRready?this._webVRpresenting||(this._scene.getEngine().onVRRequestPresentComplete.addOnce(function(o){t.onAfterEnteringVRObservable.notifyObservers({success:o})}),this._webVRCamera.position=this._position,this._scene.activeCamera=this._webVRCamera):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._displayLaserPointer&&[this._leftController,this._rightController].forEach(function(o){o&&o._activatePointer()}),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(e){l.a.Warn("Error in your custom logic onExitingVR: "+e)}this._webVRpresenting&&this._scene.getEngine().disableVR(),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._leftController&&(this._leftController._gazeTracker.isVisible=!1),this._rightController&&(this._rightController._gazeTracker.isVisible=!1)),this._scene.getEngine().resize(),[this._leftController,this._rightController].forEach(function(e){e&&e._deactivatePointer()}),this._hasEnteredVR=!1;var t=this._scene.getEngine();t._onVrDisplayPresentChange&&t._onVrDisplayPresentChange()}},Object.defineProperty(r.prototype,"position",{get:function(){return this._position},set:function(t){this._position=t,this._scene.activeCamera&&(this._scene.activeCamera.position=t)}
1709,enumerable:!1,configurable:!0}),r.prototype.enableInteractions=function(){var t=this;if(!this._interactionsEnabled){if(this._interactionsRequested=!0,this.xr)return void(this.xr.baseExperience.state===fn.IN_XR&&this.xr.pointerSelection.attach());this._leftController&&this._enableInteractionOnController(this._leftController),this._rightController&&this._enableInteractionOnController(this._rightController),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}},Object.defineProperty(r.prototype,"_noControllerIsActive",{get:function(){return!(this._leftController&&this._leftController._activePointer||this._rightController&&this._rightController._activePointer)},enumerable:!1,configurable:!0}),r.prototype._isTeleportationFloor=function(t){for(var e=0;e<this._floorMeshesCollection.length;e++)if(this._floorMeshesCollection[e].id===t.id)return!0;return!(!this._floorMeshName||t.name!==this._floorMeshName)},r.prototype.addFloorMesh=function(t){this._floorMeshesCollection&&(this._floorMeshesCollection.indexOf(t)>-1||this._floorMeshesCollection.push(t))},r.prototype.removeFloorMesh=function(t){if(this._floorMeshesCollection){var e=this._floorMeshesCollection.indexOf(t);e!==-1&&this._floorMeshesCollection.splice(e,1)}},r.prototype.enableTeleportation=function(t){var e=this;if(t===void 0&&(t={}),!this._teleportationInitialized){if(this._teleportationRequested=!0,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),this._leftController!=null&&this._enableTeleportationOnController(this._leftController),this._rightController!=null&&this._enableTeleportationOnController(this._rightController);var a=new vn.a;a.vignetteColor=new M.b(0,0,0,0),a.vignetteEnabled=!0,this._postProcessMove=new Ho("postProcessMove",1,this._webVRCamera,void 0,void 0,void 0,void 0,a),this._webVRCamera.detachPostProcess(this._postProcessMove),this._teleportationInitialized=!0,this._isDefaultTeleportationTarget&&(this._createTeleportationCircles(),this._teleportationTarget.scaling.scaleInPlace(this._webVRCamera.deviceScaleFactor))}},r.prototype._enableInteractionOnController=function(t){var e=this;t.webVRController.mesh&&(t._interactionsEnabled=!0,this.isInVRMode&&this._displayLaserPointer&&t._activatePointer(),this.webVROptions.laserToggle&&t.webVRController.onMainButtonStateChangedObservable.add(function(n){e._displayLaserPointer&&n.value===1&&(t._activePointer?t._deactivatePointer():t._activatePointer(),e.displayGaze&&(t._gazeTracker.isVisible=t._activePointer))}),t.webVRController.onTriggerStateChangedObservable.add(function(n){var i=t;e._noControllerIsActive&&(i=e._cameraGazer),i._pointerDownOnMeshAsked?n.value<e._padSensibilityDown&&i._selectionPointerUp():n.value>e._padSensibilityUp&&i._selectionPointerDown()}))},r.prototype._checkTeleportWithRay=function(t,e){this._teleportationRequestInitiated&&!e._teleportationRequestInitiated||(e._teleportationRequestInitiated?Math.sqrt(t.y*t.y+t.x*t.x)<this._padSensibilityDown&&(this._teleportActive&&this.teleportCamera(this._haloCenter),e._teleportationRequestInitiated=!1):t.y<-this._padSensibilityUp&&e._dpadPressed&&(e._activatePointer(),e._teleportationRequestInitiated=!0))},r.prototype._checkRotate=function(t,e){e._teleportationRequestInitiated||(e._rotationLeftAsked?t.x>-this._padSensibilityDown&&(e._rotationLeftAsked=!1):t.x<-this._padSensibilityUp&&e._dpadPressed&&(e._rotationLeftAsked=!0,this._rotationAllowed&&this._rotateCamera(!1)),e._rotationRightAsked?t.x<this._padSensibilityDown&&(e._rotationRightAsked=!1):t.x>this._padSensibilityUp&&e._dpadPressed&&(e._rotationRightAsked=!0,this._rotationAllowed&&this._rotateCamera(!0)))},r.prototype._checkTeleportBackwards=function(t,e){if(!e._teleportationRequestInitiated)if(t.y>this._padSensibilityUp&&e._dpadPressed){if(!e._teleportationBackRequestInitiated){if(!this.currentVRCamera)return;var n=u.b.FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix()),i=this.currentVRCamera.position;this.currentVRCamera.devicePosition&&this.currentVRCamera.deviceRotationQuaternion&&(n=this.currentVRCamera.deviceRotationQuaternion,i=this.currentVRCamera.devicePosition),n.toEulerAnglesToRef(this._workingVector),this._workingVector.z=0,this._workingVector.x=0,u.b.RotationYawPitchRollToRef(this._workingVector.y,this._workingVector.x,this._workingVector.z,this._workingQuaternion),this._workingQuaternion.toRotationMatrix(this._workingMatrix),u.e.TransformCoordinatesToRef(this._teleportBackwardsVector,this._workingMatrix,this._workingVector);var o=new dn.a(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._enableTeleportationOnController=function(t){var e=this;t.webVRController.mesh&&(t._interactionsEnabled||this._enableInteractionOnController(t),t._interactionsEnabled=!0,t._teleportationEnabled=!0,t.webVRController.controllerType===ei.VIVE&&(t._dpadPressed=!1,t.webVRController.onPadStateChangedObservable.add(function(n){t._dpadPressed=n.pressed,t._dpadPressed||(t._rotationLeftAsked=!1,t._rotationRightAsked=!1,t._teleportationBackRequestInitiated=!1)})),t.webVRController.onPadValuesChangedObservable.add(function(n){e.teleportationEnabled&&(e._checkTeleportBackwards(n,t),e._checkTeleportWithRay(n,t)),e._checkRotate(n,t)}))},r.prototype._createTeleportationCircles=function(){this._teleportationTarget=De.a.CreateGround("teleportationTarget",2,2,2,this._scene),this._teleportationTarget.isPickable=!1;var t=new yi.a("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(
1709);var n=new Ft.a("TextPlaneMaterial",this._scene);n.diffuseTexture=t,this._teleportationTarget.material=n;var i=De.a.CreateTorus("torusTeleportation",.75,.1,25,this._scene,!1);i.isPickable=!1,i.parent=this._teleportationTarget;var o=new k("animationInnerCircle","position.y",30,k.ANIMATIONTYPE_FLOAT,k.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 on;s.setEasingMode(ze.EASINGMODE_EASEINOUT),o.setEasingFunction(s),i.animations=[],i.animations.push(o),this._scene.beginAnimation(i,0,60,!0),this._hideTeleportationTarget()},r.prototype._displayTeleportationTarget=function(){this._teleportActive=!0,this._teleportationInitialized&&(this._teleportationTarget.isVisible=!0,this._isDefaultTeleportationTarget&&(this._teleportationTarget.getChildren()[0].isVisible=!0))},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){var e=this;if(this.currentVRCamera instanceof Hn){t?this._rotationAngle++:this._rotationAngle--,this.currentVRCamera.animations=[];var n=u.b.FromRotationMatrix(u.a.RotationY(Math.PI/4*this._rotationAngle)),i=new k("animationRotation","rotationQuaternion",90,k.ANIMATIONTYPE_QUATERNION,k.ANIMATIONLOOPMODE_CONSTANT),o=[];o.push({frame:0,value:this.currentVRCamera.rotationQuaternion}),o.push({frame:6,value:n}),i.setKeys(o),i.setEasingFunction(this._circleEase),this.currentVRCamera.animations.push(i),this._postProcessMove.animations=[];var a=new k("animationPP","vignetteWeight",90,k.ANIMATIONTYPE_FLOAT,k.ANIMATIONLOOPMODE_CONSTANT),s=[];s.push({frame:0,value:0}),s.push({frame:3,value:4}),s.push({frame:6,value:0}),a.setKeys(s),a.setEasingFunction(this._circleEase),this._postProcessMove.animations.push(a);var d=new k("animationPP2","vignetteStretch",90,k.ANIMATIONTYPE_FLOAT,k.ANIMATIONLOOPMODE_CONSTANT),p=[];p.push({frame:0,value:0}),p.push({frame:3,value:10}),p.push({frame:6,value:0}),d.setKeys(p),d.setEasingFunction(this._circleEase),this._postProcessMove.animations.push(d),this._postProcessMove.imageProcessingConfiguration.vignetteWeight=0,this._postProcessMove.imageProcessingConfiguration.vignetteStretch=0,this._postProcessMove.samples=4,this._webVRCamera.attachPostProcess(this._postProcessMove),this._scene.beginAnimation(this._postProcessMove,0,6,!1,1,function(){e._webVRCamera.detachPostProcess(e._postProcessMove)}),this._scene.beginAnimation(this.currentVRCamera,0,6,!1,1)}},r.prototype._moveTeleportationSelectorTo=function(t,e,n){if(t.pickedPoint){e._teleportationRequestInitiated&&(this._displayTeleportationTarget(),this._haloCenter.copyFrom(t.pickedPoint),this._teleportationTarget.position.copyFrom(t.pickedPoint));var i=this._convertNormalToDirectionOfRay(t.getNormal(!0,!1),n);if(i){var o=u.e.Cross(ye.a.Y,i),a=u.e.Cross(i,o);u.e.RotationFromAxisToRef(a,i,o,this._teleportationTarget.rotation)}this._teleportationTarget.position.y+=.1}},r.prototype.teleportCamera=function(t){var e=this;if(this.currentVRCamera instanceof Hn){this.webVRCamera.leftCamera?(this._workingVector.copyFrom(this.webVRCamera.leftCamera.globalPosition),this._workingVector.subtractInPlace(this.webVRCamera.position),t.subtractToRef(this._workingVector,this._workingVector)):this._workingVector.copyFrom(t),this.isInVRMode?this._workingVector.y+=this.webVRCamera.deviceDistanceToRoomGround()*this._webVRCamera.deviceScaleFactor:this._workingVector.y+=this._defaultHeight,this.onBeforeCameraTeleport.notifyObservers(this._workingVector);var n,i;if(this._teleportationMode==r.TELEPORTATIONMODE_CONSTANTSPEED){i=90;var o=u.e.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 k("animationCameraTeleportation","position",90,k.ANIMATIONTYPE_VECTOR3,k.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 d=Math.round(i/2),p=new k("animationPP","vignetteWeight",90,k.ANIMATIONTYPE_FLOAT,k.ANIMATIONLOOPMODE_CONSTANT),y=[];y.push({frame:0,value:0}),y.push({frame:d,value:8}),y.push({frame:i,value:0}),p.setKeys(y),this._postProcessMove.animations.push(p);var P=new k("animationPP2","vignetteStretch",90,k.ANIMATIONTYPE_FLOAT,k.ANIMATIONLOOPMODE_CONSTANT),O=[];O.push({frame:0,value:0}),O.push({frame:d,value:10}),O.push({frame:i,value:0}),P.setKeys(O),this._postProcessMove.animations.push(P),this._postProcessMove.imageProcessingConfiguration.vignetteWeight=0,this._postProcessMove.imageProcessingConfiguration.vignetteStretch=0,this._webVRCamera.attachPostProcess(this._postProcessMove),this._scene.beginAnimation(this._postProcessMove,0,i,!1,n,function(){e._webVRCamera.detachPostProcess(e._postProcessMove)}),this._scene.beginAnimation(this.currentVRCamera,0,i,!1,n,function(){e.onAfterCameraTeleport.notifyObservers(e._workingVector)}),this._hideTeleportationTarget()}},r.prototype._convertNormalToDirectionOfRay=function(t,e){return t&&Math.acos(u.e.Dot(t,e.direction))<Math.PI/2&&t.scaleInPlace(-1),t},r.prototype._castRayAndSelectObject=function(t){if(this.currentVRCamera instanceof Hn){var e=t._getForwardRay(this._rayLength),n=this._scene.pickWithRay(e,this._raySelectionPredicate);if(n&&(t._laserPointer&&(n.originMesh=t._laserPointer.parent),this._scene.simulatePointerMove(n,{pointerId:t._id})),t._currentHit=n,n&&n.pickedPoint){if(this._displayGaze){var i=1;t._gazeTracker.isVisible=!0,t._isActionableMesh&&(i=3),this.updateGazeTrackerScale&&(t._gazeTracker.scaling.x=n.distance*i,t._gazeTracker.scaling.y=n.distance*i,t._gazeTracker.scaling.z=n.distance*i);var o=this._convertNormalToDirectionOfRay(n.getNormal(),e);if(o){var a=u.e.Cross(ye.a.Y,o),s=u.e.Cross(o,a);u.e.RotationFromAxisToRef(s,o,a,t._gazeTracker.rotation)}t._gazeTracker.position.copyFrom(n.pickedPoint),t._gazeTracker.position.x<0?t._gazeTracker.position.x+=.002:t._gazeTracker.position.x-=.002,t._gazeTracker.position.y<0?t._gazeTracker.position.y+=.002:t._gazeTracker.position.y-=.002,t._gazeTracker.position.z<0?t._gazeTracker.position.z+=.002:t._gazeTracker.position.z-=.002}t._updatePointerDistance(n.distance)}else t._updatePointerDistance(),t._gazeTracker.isVisible=!1;
1709if(n&&n.pickedMesh){if(this._teleportationInitialized&&this._isTeleportationFloor(n.pickedMesh)&&n.pickedPoint)return t._currentMeshSelected&&!this._isTeleportationFloor(t._currentMeshSelected)&&this._notifySelectedMeshUnselected(t._currentMeshSelected),t._currentMeshSelected=null,void(t._teleportationRequestInitiated&&this._moveTeleportationSelectorTo(n,t,e));if(n.pickedMesh!==t._currentMeshSelected)if(this.meshSelectionPredicate(n.pickedMesh)){this.onNewMeshPicked.notifyObservers(n),t._currentMeshSelected=n.pickedMesh,n.pickedMesh.isPickable&&n.pickedMesh.actionManager?(this.changeGazeColor(this._pickedGazeColor),this.changeLaserColor(this._pickedLaserColor),t._isActionableMesh=!0):(this.changeGazeColor(this._gazeColor),this.changeLaserColor(this._laserColor),t._isActionableMesh=!1);try{this.onNewMeshSelected.notifyObservers(n.pickedMesh);var d=t;d.webVRController&&this.onMeshSelectedWithController.notifyObservers({mesh:n.pickedMesh,controller:d.webVRController})}catch(p){l.a.Warn("Error while raising onNewMeshSelected or onMeshSelectedWithController: "+p)}}else this._notifySelectedMeshUnselected(t._currentMeshSelected),t._currentMeshSelected=null,this.changeGazeColor(this._gazeColor),this.changeLaserColor(this._laserColor)}else this._notifySelectedMeshUnselected(t._currentMeshSelected),t._currentMeshSelected=null,this.changeGazeColor(this._gazeColor),this.changeLaserColor(this._laserColor)}},r.prototype._notifySelectedMeshUnselected=function(t){t&&this.onSelectedMeshUnselected.notifyObservers(t)},r.prototype.setLaserColor=function(t,e){e===void 0&&(e=this._pickedLaserColor),this._laserColor=t,this._pickedLaserColor=e},r.prototype.setLaserLightingState=function(t){t===void 0&&(t=!0),this._leftController&&this._leftController._setLaserPointerLightingDisabled(!t),this._rightController&&this._rightController._setLaserPointerLightingDisabled(!t)},r.prototype.setGazeColor=function(t,e){e===void 0&&(e=this._pickedGazeColor),this._gazeColor=t,this._pickedGazeColor=e},r.prototype.changeLaserColor=function(t){this.updateControllerLaserColor&&(this._leftController&&this._leftController._setLaserPointerColor(t),this._rightController&&this._rightController._setLaserPointerColor(t))},r.prototype.changeGazeColor=function(t){this.updateGazeTrackerColor&&this._cameraGazer._gazeTracker.material&&(this._cameraGazer._gazeTracker.material.emissiveColor=t,this._leftController&&(this._leftController._gazeTracker.material.emissiveColor=t),this._rightController&&(this._rightController._gazeTracker.material.emissiveColor=t))},r.prototype.dispose=function(){this.isInVRMode&&this.exitVR(),this._postProcessMove&&this._postProcessMove.dispose(),this._webVRCamera&&this._webVRCamera.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._leftController&&this._leftController.dispose(),this._rightController&&this._rightController.dispose(),this._teleportationTarget&&this._teleportationTarget.dispose(),this.xr&&this.xr.dispose(),this._floorMeshesCollection=[],document.removeEventListener("keydown",this._onKeyDown),window.removeEventListener("vrdisplaypresentchange",this._onVrDisplayPresentChange),window.removeEventListener("resize",this._onResize),document.removeEventListener("fullscreenchange",this._onFullscreenChange),document.removeEventListener("mozfullscreenchange",this._onFullscreenChange),document.removeEventListener("webkitfullscreenchange",this._onFullscreenChange),document.removeEventListener("msfullscreenchange",this._onFullscreenChange),document.onmsfullscreenchange=null,this._scene.getEngine().onVRDisplayChangedObservable.removeCallback(this._onVRDisplayChanged),this._scene.getEngine().onVRRequestPresentStart.removeCallback(this._onVRRequestPresentStart),this._scene.getEngine().onVRRequestPresentComplete.removeCallback(this._onVRRequestPresentComplete),window.removeEventListener("vrdisplaypresentchange",this._onVrDisplayPresentChange),this._scene.gamepadManager.onGamepadConnectedObservable.removeCallback(this._onNewGamepadConnected),this._scene.gamepadManager.onGamepadDisconnectedObservable.removeCallback(this._onNewGamepadDisconnected),this._scene.unregisterBeforeRender(this.beforeRender)},r.prototype.getClassName=function(){return"VRExperienceHelper"},r.TELEPORTATIONMODE_CONSTANTTIME=0,r.TELEPORTATIONMODE_CONSTANTSPEED=1,r}(),gr=f(64),vr=(ti={root:0,found:!1},function(r,t,e,n){ti.root=0,ti.found=!1;var i=t*t-4*r*e;if(i<0)return ti;var o=Math.sqrt(i),a=(-t-o)/(2*r),s=(-t+o)/(2*r);if(a>s){var d=s;s=a,a=d}return a>0&&a<n?(ti.root=a,ti.found=!0,ti):(s>0&&s<n&&(ti.root=s,ti.found=!0),ti)}),ou=function(){function r(){this._collisionPoint=u.e.Zero(),this._planeIntersectionPoint=u.e.Zero(),this._tempVector=u.e.Zero(),this._tempVector2=u.e.Zero(),this._tempVector3=u.e.Zero(),this._tempVector4=u.e.Zero(),this._edge=u.e.Zero(),this._baseToVertex=u.e.Zero(),this._destinationPoint=u.e.Zero(),this._slidePlaneNormal=u.e.Zero(),this._displacementVector=u.e.Zero(),this._radius=u.e.One(),this._retry=0,this._basePointWorld=u.e.Zero(),this._velocityWorld=u.e.Zero(),this._normalizedVelocity=u.e.Zero(),this._collisionMask=-1}return Object.defineProperty(r.prototype,"collisionMask",{get:function(){return this._collisionMask},set:function(t){this._collisionMask=isNaN(t)?-1:t}
1709,enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"slidePlaneNormal",{get:function(){return this._slidePlaneNormal},enumerable:!1,configurable:!0}),r.prototype._initialize=function(t,e,n){this._velocity=e,u.e.NormalizeToRef(e,this._normalizedVelocity),this._basePoint=t,t.multiplyToRef(this._radius,this._basePointWorld),e.multiplyToRef(this._radius,this._velocityWorld),this._velocityWorldLength=this._velocityWorld.length(),this._epsilon=n,this.collisionFound=!1},r.prototype._checkPointInTriangle=function(t,e,n,i,o){e.subtractToRef(t,this._tempVector),n.subtractToRef(t,this._tempVector2),u.e.CrossToRef(this._tempVector,this._tempVector2,this._tempVector4);var a=u.e.Dot(this._tempVector4,o);return!(a<0)&&(i.subtractToRef(t,this._tempVector3),u.e.CrossToRef(this._tempVector2,this._tempVector3,this._tempVector4),!((a=u.e.Dot(this._tempVector4,o))<0)&&(u.e.CrossToRef(this._tempVector3,this._tempVector,this._tempVector4),(a=u.e.Dot(this._tempVector4,o))>=0))},r.prototype._canDoCollision=function(t,e,n,i){var o=u.e.Distance(this._basePointWorld,t),a=Math.max(this._radius.x,this._radius.y,this._radius.z);return!(o>this._velocityWorldLength+a+e)&&!!function(s,d,p,y){return!(s.x>p.x+y)&&!(p.x-y>d.x)&&!(s.y>p.y+y)&&!(p.y-y>d.y)&&!(s.z>p.z+y)&&!(p.z-y>d.z)}(n,i,this._basePointWorld,this._velocityWorldLength+a)},r.prototype._testTriangle=function(t,e,n,i,o,a,s){var d,p=!1;e||(e=[]),e[t]||(e[t]=new gr.a(0,0,0,0),e[t].copyFromPoints(n,i,o));var y=e[t];if(a||y.isFrontFacingTo(this._normalizedVelocity,0)){var P=y.signedDistanceTo(this._basePoint),O=u.e.Dot(y.normal,this._velocity);if(O==0){if(Math.abs(P)>=1)return;p=!0,d=0}else{var U=(1-P)/O;if((d=(-1-P)/O)>U){var F=U;U=d,d=F}if(d>1||U<0)return;d<0&&(d=0),d>1&&(d=1)}this._collisionPoint.copyFromFloats(0,0,0);var z=!1,J=1;if(p||(this._basePoint.subtractToRef(y.normal,this._planeIntersectionPoint),this._velocity.scaleToRef(d,this._tempVector),this._planeIntersectionPoint.addInPlace(this._tempVector),this._checkPointInTriangle(this._planeIntersectionPoint,n,i,o,y.normal)&&(z=!0,J=d,this._collisionPoint.copyFrom(this._planeIntersectionPoint))),!z){var ie=this._velocity.lengthSquared(),se=ie;this._basePoint.subtractToRef(n,this._tempVector);var ce=2*u.e.Dot(this._velocity,this._tempVector),ue=this._tempVector.lengthSquared()-1,fe=vr(se,ce,ue,J);fe.found&&(J=fe.root,z=!0,this._collisionPoint.copyFrom(n)),this._basePoint.subtractToRef(i,this._tempVector),ce=2*u.e.Dot(this._velocity,this._tempVector),ue=this._tempVector.lengthSquared()-1,(fe=vr(se,ce,ue,J)).found&&(J=fe.root,z=!0,this._collisionPoint.copyFrom(i)),this._basePoint.subtractToRef(o,this._tempVector),ce=2*u.e.Dot(this._velocity,this._tempVector),ue=this._tempVector.lengthSquared()-1,(fe=vr(se,ce,ue,J)).found&&(J=fe.root,z=!0,this._collisionPoint.copyFrom(o)),i.subtractToRef(n,this._edge),n.subtractToRef(this._basePoint,this._baseToVertex);var ve=this._edge.lengthSquared(),Te=u.e.Dot(this._edge,this._velocity),Oe=u.e.Dot(this._edge,this._baseToVertex);if(se=ve*-ie+Te*Te,ce=ve*(2*u.e.Dot(this._velocity,this._baseToVertex))-2*Te*Oe,ue=ve*(1-this._baseToVertex.lengthSquared())+Oe*Oe,(fe=vr(se,ce,ue,J)).found){var Pe=(Te*fe.root-Oe)/ve;Pe>=0&&Pe<=1&&(J=fe.root,z=!0,this._edge.scaleInPlace(Pe),n.addToRef(this._edge,this._collisionPoint))}o.subtractToRef(i,this._edge),i.subtractToRef(this._basePoint,this._baseToVertex),ve=this._edge.lengthSquared(),Te=u.e.Dot(this._edge,this._velocity),Oe=u.e.Dot(this._edge,this._baseToVertex),se=ve*-ie+Te*Te,ce=ve*(2*u.e.Dot(this._velocity,this._baseToVertex))-2*Te*Oe,ue=ve*(1-this._baseToVertex.lengthSquared())+Oe*Oe,(fe=vr(se,ce,ue,J)).found&&(Pe=(Te*fe.root-Oe)/ve)>=0&&Pe<=1&&(J=fe.root,z=!0,this._edge.scaleInPlace(Pe),i.addToRef(this._edge,this._collisionPoint)),n.subtractToRef(o,this._edge),o.subtractToRef(this._basePoint,this._baseToVertex),ve=this._edge.lengthSquared(),Te=u.e.Dot(this._edge,this._velocity),Oe=u.e.Dot(this._edge,this._baseToVertex),se=ve*-ie+Te*Te,ce=ve*(2*u.e.Dot(this._velocity,this._baseToVertex))-2*Te*Oe,ue=ve*(1-this._baseToVertex.lengthSquared())+Oe*Oe,(fe=vr(se,ce,ue,J)).found&&(Pe=(Te*fe.root-Oe)/ve)>=0&&Pe<=1&&(J=fe.root,z=!0,this._edge.scaleInPlace(Pe),o.addToRef(this._edge,this._collisionPoint))}if(z){var Ee=J*this._velocity.length();(!this.collisionFound||Ee<this._nearestDistance)&&(s.collisionResponse&&(this.intersectionPoint?this.intersectionPoint.copyFrom(this._collisionPoint):this.intersectionPoint=this._collisionPoint.clone(),this._nearestDistance=Ee,this.collisionFound=!0),this.collidedMesh=s)}}},r.prototype._collide=function(t,e,n,i,o,a,s,d){if(n&&n.length!==0)for(p=i;p<o;p+=3)y=e[n[p]-a],P=e[n[p+1]-a],O=e[n[p+2]-a],this._testTriangle(p,t,O,P,y,s,d);else for(var p=0;p<e.length;p+=3){var y=e[p],P=e[p+1],O=e[p+2];this._testTriangle(p,t,O,P,y,s,d)}},r.prototype._getResponse=function(t,e){t.addToRef(e,this._destinationPoint),e.scaleInPlace(this._nearestDistance/e.length()),this._basePoint.addToRef(e,t),t.subtractToRef(this.intersectionPoint,this._slidePlaneNormal),this._slidePlaneNormal.normalize(),this._slidePlaneNormal.scaleToRef(this._epsilon,this._displacementVector),t.addInPlace(this._displacementVector),this.intersectionPoint.addInPlace(this._displacementVector),this._slidePlaneNormal.scaleInPlace(gr.a.SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint,this._slidePlaneNormal,this._destinationPoint)),this._destinationPoint.subtractInPlace(this._slidePlaneNormal),this._destinationPoint.subtractToRef(this.intersectionPoint,e)},r}(),au=function(){function r(){this._scaledPosition=u.e.Zero(),this._scaledVelocity=u.e.Zero(),this._finalPosition=u.e.Zero()}return r.prototype.getNewPosition=function(t,e,n,i,o,a,s){t.divideToRef(n._radius,this._scaledPosition),e.divideToRef(n._radius,this._scaledVelocity),n.collidedMesh=null,n._retry=0,n._initialVelocity=this._scaledVelocity,n._initialPosition=this._scaledPosition,this._collideWithWorld(this._scaledPosition,this._scaledVelocity,n,i,this._finalPosition,o),this._finalPosition.multiplyInPlace(n._radius),a(s,this._finalPosition,n.collidedMesh)},r.prototype.createCollider=function(){return new ou},r.prototype.init=function(t){this._scene=t},r.prototype._collideWithWorld=function(t,e,n,i,o,a){a===void 0&&(a=null);var s=10*Ue.a.CollisionsEpsilon;if(n._retry>=i)o.copyFrom(t);else{var d=a?a.collisionMask:n.collisionMask;n._initialize(t,e,s);for(var p=a&&a.surroundingMeshes||this._scene.meshes,y=0;y<p.length;y++){var P=p[y];P.isEnabled()&&P.checkCollisions&&P.subMeshes&&P!==a&&d&P.collisionGroup&&P._
1709checkCollision(n)}n.collisionFound?(e.x===0&&e.y===0&&e.z===0||n._getResponse(t,e),e.length()<=s?o.copyFrom(t):(n._retry++,this._collideWithWorld(t,e,n,i,o,a))):t.addToRef(e,o)}},r}();_e.a.CollisionCoordinatorFactory=function(){return new au};var tr=f(54),vp=f(114),bp=f(147),Ts=f(103),Fi=f(43),su=f(113),cu=function(){function r(t,e,n,i,o,a){this.entries=new Array,this._boundingVectors=new Array,this._capacity=n,this._depth=i,this._maxDepth=o,this._creationFunc=a,this._minPoint=t,this._maxPoint=e,this._boundingVectors.push(t.clone()),this._boundingVectors.push(e.clone()),this._boundingVectors.push(t.clone()),this._boundingVectors[2].x=e.x,this._boundingVectors.push(t.clone()),this._boundingVectors[3].y=e.y,this._boundingVectors.push(t.clone()),this._boundingVectors[4].z=e.z,this._boundingVectors.push(e.clone()),this._boundingVectors[5].z=t.z,this._boundingVectors.push(e.clone()),this._boundingVectors[6].x=t.x,this._boundingVectors.push(e.clone()),this._boundingVectors[7].y=t.y}return Object.defineProperty(r.prototype,"capacity",{get:function(){return this._capacity},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"minPoint",{get:function(){return this._minPoint},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"maxPoint",{get:function(){return this._maxPoint},enumerable:!1,configurable:!0}),r.prototype.addEntry=function(t){if(this.blocks)for(var e=0;e<this.blocks.length;e++)this.blocks[e].addEntry(t);else this._creationFunc(t,this),this.entries.length>this.capacity&&this._depth<this._maxDepth&&this.createInnerBlocks()},r.prototype.removeEntry=function(t){if(this.blocks)for(var e=0;e<this.blocks.length;e++)this.blocks[e].removeEntry(t);else{var n=this.entries.indexOf(t);n>-1&&this.entries.splice(n,1)}},r.prototype.addEntries=function(t){for(var e=0;e<t.length;e++){var n=t[e];this.addEntry(n)}},r.prototype.select=function(t,e,n){if(Ts.a.IsInFrustum(this._boundingVectors,t)){if(this.blocks){for(var i=0;i<this.blocks.length;i++)this.blocks[i].select(t,e,n);return}n?e.concat(this.entries):e.concatWithNoDuplicate(this.entries)}},r.prototype.intersects=function(t,e,n,i){if(Ts.a.IntersectsSphere(this._minPoint,this._maxPoint,t,e)){if(this.blocks){for(var o=0;o<this.blocks.length;o++)this.blocks[o].intersects(t,e,n,i);return}i?n.concat(this.entries):n.concatWithNoDuplicate(this.entries)}},r.prototype.intersectsRay=function(t,e){if(t.intersectsBoxMinMax(this._minPoint,this._maxPoint)){if(this.blocks){for(var n=0;n<this.blocks.length;n++)this.blocks[n].intersectsRay(t,e);return}e.concatWithNoDuplicate(this.entries)}},r.prototype.createInnerBlocks=function(){r._CreateBlocks(this._minPoint,this._maxPoint,this.entries,this._capacity,this._depth,this._maxDepth,this,this._creationFunc)},r._CreateBlocks=function(t,e,n,i,o,a,s,d){s.blocks=new Array;for(var p=new u.e((e.x-t.x)/2,(e.y-t.y)/2,(e.z-t.z)/2),y=0;y<2;y++)for(var P=0;P<2;P++)for(var O=0;O<2;O++){var U=new r(t.add(p.multiplyByFloats(y,P,O)),t.add(p.multiplyByFloats(y+1,P+1,O+1)),i,o+1,a,d);U.addEntries(n),s.blocks.push(U)}},r}(),to=function(){function r(t,e,n){n===void 0&&(n=2),this.maxDepth=n,this.dynamicContent=new Array,this._maxBlockCapacity=e||64,this._selectionContent=new li.b(1024),this._creationFunc=t}return r.prototype.update=function(t,e,n){cu._CreateBlocks(t,e,n,this._maxBlockCapacity,0,this.maxDepth,this,this._creationFunc)},r.prototype.addMesh=function(t){for(var e=0;e<this.blocks.length;e++)this.blocks[e].addEntry(t)},r.prototype.removeMesh=function(t){for(var e=0;e<this.blocks.length;e++)this.blocks[e].removeEntry(t)},r.prototype.select=function(t,e){this._selectionContent.reset();for(var n=0;n<this.blocks.length;n++)this.blocks[n].select(t,this._selectionContent,e);return e?this._selectionContent.concat(this.dynamicContent):this._selectionContent.concatWithNoDuplicate(this.dynamicContent),this._selectionContent},r.prototype.intersects=function(t,e,n){this._selectionContent.reset();for(var i=0;i<this.blocks.length;i++)this.blocks[i].intersects(t,e,this._selectionContent,n);return n?this._selectionContent.concat(this.dynamicContent):this._selectionContent.concatWithNoDuplicate(this.dynamicContent),this._selectionContent},r.prototype.intersectsRay=function(t){this._selectionContent.reset();for(var e=0;e<this.blocks.length;e++)this.blocks[e].intersectsRay(t,this._selectionContent);return this._selectionContent.concatWithNoDuplicate(this.dynamicContent),this._selectionContent},r.CreationFuncForMeshes=function(t,e){var n=t.getBoundingInfo();!t.isBlocked&&n.boundingBox.intersectsMinMax(e.minPoint,e.maxPoint)&&e.entries.push(t)},r.CreationFuncForSubMeshes=function(t,e){t.getBoundingInfo().boundingBox.intersectsMinMax(e.minPoint,e.maxPoint)&&e.entries.push(t)},r}();
1709_e.a.prototype.createOrUpdateSelectionOctree=function(r,t){r===void 0&&(r=64),t===void 0&&(t=2);var e=this._getComponent(st.a.NAME_OCTREE);e||(e=new Cs(this),this._addComponent(e)),this._selectionOctree||(this._selectionOctree=new to(to.CreationFuncForMeshes,r,t));var n=this.getWorldExtends();return this._selectionOctree.update(n.min,n.max,this.meshes),this._selectionOctree},Object.defineProperty(_e.a.prototype,"selectionOctree",{get:function(){return this._selectionOctree},enumerable:!0,configurable:!0}),Dt.a.prototype.createOrUpdateSubmeshesOctree=function(r,t){r===void 0&&(r=64),t===void 0&&(t=2);var e=this.getScene(),n=e._getComponent(st.a.NAME_OCTREE);n||(n=new Cs(e),e._addComponent(n)),this._submeshesOctree||(this._submeshesOctree=new to(to.CreationFuncForSubMeshes,r,t)),this.computeWorldMatrix(!0);var i=this.getBoundingInfo().boundingBox;return this._submeshesOctree.update(i.minimumWorld,i.maximumWorld,this.subMeshes),this._submeshesOctree};var Kt,Es,Ss,As,Ps,Cs=function(){function r(t){this.name=st.a.NAME_OCTREE,this.checksIsEnabled=!0,this._tempRay=new dn.a(u.e.Zero(),new u.e(1,1,1)),this.scene=t,this.scene.getActiveMeshCandidates=this.getActiveMeshCandidates.bind(this),this.scene.getActiveSubMeshCandidates=this.getActiveSubMeshCandidates.bind(this),this.scene.getCollidingSubMeshCandidates=this.getCollidingSubMeshCandidates.bind(this),this.scene.getIntersectingSubMeshCandidates=this.getIntersectingSubMeshCandidates.bind(this)}return r.prototype.register=function(){var t=this;this.scene.onMeshRemovedObservable.add(function(e){var n=t.scene.selectionO
1709ctree;if(n!=null){var i=n.dynamicContent.indexOf(e);i!==-1&&n.dynamicContent.splice(i,1)}}),this.scene.onMeshImportedObservable.add(function(e){var n=t.scene.selectionOctree;n?.addMesh(e)})},r.prototype.getActiveMeshCandidates=function(){return this.scene._selectionOctree?this.scene._selectionOctree.select(this.scene.frustumPlanes):this.scene._getDefaultMeshCandidates()},r.prototype.getActiveSubMeshCandidates=function(t){return t._submeshesOctree&&t.useOctreeForRenderingSelection?t._submeshesOctree.select(this.scene.frustumPlanes):this.scene._getDefaultSubMeshCandidates(t)},r.prototype.getIntersectingSubMeshCandidates=function(t,e){return t._submeshesOctree&&t.useOctreeForPicking?(dn.a.TransformToRef(e,t.getWorldMatrix(),this._tempRay),t._submeshesOctree.intersectsRay(this._tempRay)):this.scene._getDefaultSubMeshCandidates(t)},r.prototype.getCollidingSubMeshCandidates=function(t,e){if(t._submeshesOctree&&t.useOctreeForCollisions){var n=e._velocityWorldLength+Math.max(e._radius.x,e._radius.y,e._radius.z);return t._submeshesOctree.intersects(e._basePointWorld,n)}return this.scene._getDefaultSubMeshCandidates(t)},r.prototype.rebuild=function(){},r.prototype.dispose=function(){},r}(),nr=f(99);(function(r){r[r.Generic=0]="Generic",r[r.Keyboard=1]="Keyboard",r[r.Mouse=2]="Mouse",r[r.Touch=3]="Touch",r[r.DualShock=4]="DualShock",r[r.Xbox=5]="Xbox",r[r.Switch=6]="Switch"})(Kt||(Kt={})),function(r){r[r.Horizontal=0]="Horizontal",r[r.Vertical=1]="Vertical",r[r.LeftClick=2]="LeftClick",r[r.MiddleClick=3]="MiddleClick",r[r.RightClick=4]="RightClick",r[r.BrowserBack=5]="BrowserBack",r[r.BrowserForward=6]="BrowserForward"}(Es||(Es={})),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.L2=6]="L2",r[r.R2=7]="R2",r[r.Share=8]="Share",r[r.Options=9]="Options",r[r.L3=10]="L3",r[r.R3=11]="R3",r[r.DPadUp=12]="DPadUp",r[r.DPadDown=13]="DPadDown",r[r.DPadLeft=14]="DPadLeft",r[r.DPadRight=15]="DPadRight",r[r.Home=16]="Home",r[r.TouchPad=17]="TouchPad",r[r.LStickXAxis=18]="LStickXAxis",r[r.LStickYAxis=19]="LStickYAxis",r[r.RStickXAxis=20]="RStickXAxis",r[r.RStickYAxis=21]="RStickYAxis"}(Ss||(Ss={})),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.LT=6]="LT",r[r.RT=7]="RT",r[r.Back=8]="Back",r[r.Start=9]="Start",r[r.LS=10]="LS",r[r.RS=11]="RS",r[r.DPadUp=12]="DPadUp",r[r.DPadDown=13]="DPadDown",r[r.DPadLeft=14]="DPadLeft",r[r.DPadRight=15]="DPadRight",r[r.Home=16]="Home",r[r.LStickXAxis=17]="LStickXAxis",r[r.LStickYAxis=18]="LStickYAxis",r[r.RStickXAxis=19]="RStickXAxis",r[r.RStickYAxis=20]="RStickYAxis"}(As||(As={})),function(r){r[r.B=0]="B",r[r.A=1]="A",r[r.Y=2]="Y",r[r.X=3]="X",r[r.L=4]="L",r[r.R=5]="R",r[r.ZL=6]="ZL",r[r.ZR=7]="ZR",r[r.Minus=8]="Minus",r[r.Plus=9]="Plus",r[r.LS=10]="LS",r[r.RS=11]="RS",r[r.DPadUp=12]="DPadUp",r[r.DPadDown=13]="DPadDown",r[r.DPadLeft=14]="DPadLeft",r[r.DPadRight=15]="DPadRight",r[r.Home=16]="Home",r[r.Capture=17]="Capture",r[r.LStickXAxis=18]="LStickXAxis",r[r.LStickYAxis=19]="LStickYAxis",r[r.RStickXAxis=20]="RStickXAxis",r[r.RStickYAxis=21]="RStickYAxis"}(Ps||(Ps={}));var lu=function(){function r(t){this.onDeviceDisconnected=function(){},this._inputs=[],this._keyboardActive=!1,this._pointerActive=!1,this._keyboardDownEvent=function(n){},this._keyboardUpEvent=function(n){},this._pointerMoveEvent=function(n){},this._pointerDownEvent=function(n){},this._pointerUpEvent=function(n){},this._gamepadConnectedEvent=function(n){},this._gamepadDisconnectedEvent=function(n){},this._onDeviceConnected=function(){};var e=t.getInputElement();e&&(this._elementToAttachTo=e,this._handleKeyActions(),this._handlePointerActions(),this._handleGamepadActions(),this._checkForConnectedDevices())}return Object.defineProperty(r.prototype,"onDeviceConnected",{get:function(){return this._onDeviceConnected},set:function(t){this._onDeviceConnected=t;for(var e=0;e<this._inputs.length;e++)if(this._inputs[e])for(var n=0;n<this._inputs[e].length;n++)this._inputs[e][n]&&this._onDeviceConnected(e,n)}
1709,enumerable:!1,configurable:!0}),r.Create=function(t){return typeof _native<"u"&&_native.DeviceInputSystem?new _native.DeviceInputSystem(t):new r(t)},r.prototype.pollInput=function(t,e,n){var i=this._inputs[t][e];if(!i)throw"Unable to find device "+Kt[t];if(this._updateDevice(t,e,n),i[n]===void 0)throw"Unable to find input "+n+" for device "+Kt[t]+" in slot "+e;return i[n]},r.prototype.dispose=function(){this._keyboardActive&&(window.removeEventListener("keydown",this._keyboardDownEvent),window.removeEventListener("keyup",this._keyboardUpEvent)),this._pointerActive&&(this._elementToAttachTo.removeEventListener("pointermove",this._pointerMoveEvent),this._elementToAttachTo.removeEventListener("pointerdown",this._pointerDownEvent),this._elementToAttachTo.removeEventListener("pointerup",this._pointerUpEvent)),window.removeEventListener("gamepadconnected",this._gamepadConnectedEvent),window.removeEventListener("gamepaddisconnected",this._gamepadDisconnectedEvent)},r.prototype._checkForConnectedDevices=function(){for(var t=0,e=navigator.getGamepads();t<e.length;t++){var n=e[t];n&&this._addGamePad(n)}matchMedia("(pointer:fine)").matches&&this._addPointerDevice(Kt.Mouse,0,0,0)},r.prototype._addGamePad=function(t){var e=this._getGamepadDeviceType(t.id),n=t.index;this._registerDevice(e,n,t.buttons.length+t.axes.length),this._gamepads=this._gamepads||new Array(t.index+1),this._gamepads[n]=e},r.prototype._addPointerDevice=function(t,e,n,i){this._pointerActive=!0,this._registerDevice(t,e,r._MAX_POINTER_INPUTS);var o=this._inputs[t][e];o[0]=n,o[1]=i},r.prototype._registerDevice=function(t,e,n){if(this._inputs[t]||(this._inputs[t]=[]),!this._inputs[t][e]){for(var i=new Array(n),o=0;o<n;o++)i[o]=0;this._inputs[t][e]=i,this.onDeviceConnected(t,e)}},r.prototype._unregisterDevice=function(t,e){this._inputs[t][e]&&(delete this._inputs[t][e],this.onDeviceDisconnected(t,e))},r.prototype._handleKeyActions=function(){var t=this;this._keyboardDownEvent=function(e){t._keyboardActive||(t._keyboardActive=!0,t._registerDevice(Kt.Keyboard,0,r._MAX_KEYCODES));var n=t._inputs[Kt.Keyboard][0];n&&(t.onInputChanged&&t.onInputChanged(Kt.Keyboard,0,e.keyCode,n[e.keyCode],1),n[e.keyCode]=1)},this._keyboardUpEvent=function(e){var n=t._inputs[Kt.Keyboard][0];n&&(t.onInputChanged&&t.onInputChanged(Kt.Keyboard,0,e.keyCode,n[e.keyCode],0),n[e.keyCode]=0)},window.addEventListener("keydown",this._keyboardDownEvent),window.addEventListener("keyup",this._keyboardUpEvent)},r.prototype._handlePointerActions=function(){var t=this;this._pointerMoveEvent=function(e){var n=e.pointerType=="mouse"?Kt.Mouse:Kt.Touch,i=e.pointerType=="mouse"?0:e.pointerId;t._inputs[n]||(t._inputs[n]=[]),t._inputs[n][i]||t._addPointerDevice(n,i,e.clientX,e.clientY);var o=t._inputs[n][i];o&&(t.onInputChanged&&(t.onInputChanged(n,i,0,o[0],e.clientX),t.onInputChanged(n,i,1,o[1],e.clientY)),o[0]=e.clientX,o[1]=e.clientY)},this._pointerDownEvent=function(e){var n=e.pointerType=="mouse"?Kt.Mouse:Kt.Touch,i=e.pointerType=="mouse"?0:e.pointerId;t._inputs[n]||(t._inputs[n]=[]),t._inputs[n][i]||t._addPointerDevice(n,i,e.clientX,e.clientY);var o=t._inputs[n][i];o&&(t.onInputChanged&&(t.onInputChanged(n,i,0,o[0],e.clientX),t.onInputChanged(n,i,1,o[1],e.clientY),t.onInputChanged(n,i,e.button+2,o[e.button+2],1)),o[0]=e.clientX,o[1]=e.clientY,o[e.button+2]=1)},this._pointerUpEvent=function(e){var n=e.pointerType=="mouse"?Kt.Mouse:Kt.Touch,i=e.pointerType=="mouse"?0:e.pointerId,o=t._inputs[n][i];o&&(t.onInputChanged&&t.onInputChanged(n,i,e.button+2,o[e.button+2],0),o[0]=e.clientX,o[1]=e.clientY,o[e.button+2]=0),e.pointerType!="mouse"&&t._unregisterDevice(n,i)},this._elementToAttachTo.addEventListener("pointermove",this._pointerMoveEvent),this._elementToAttachTo.addEventListener("pointerdown",this._pointerDownEvent),this._elementToAttachTo.addEventListener("pointerup",this._pointerUpEvent)},r.prototype._handleGamepadActions=function(){var t=this;this._gamepadConnectedEvent=function(e){t._addGamePad(e.gamepad)},this._gamepadDisconnectedEvent=function(e){if(t._gamepads){var n=t._getGamepadDeviceType(e.gamepad.id),i=e.gamepad.index;t._unregisterDevice(n,i),delete t._gamepads[i]}},window.addEventListener("gamepadconnected",this._gamepadConnectedEvent),window.addEventListener("gamepaddisconnected",this._gamepadDisconnectedEvent)},r.prototype._updateDevice=function(t,e,n){var i=navigator.getGamepads()[e];if(i&&t==this._gamepads[e]){var o=this._inputs[t][e];n>=i.buttons.length?o[n]=i.axes[n-i.buttons.length].valueOf():o[n]=i.buttons[n].value}},r.prototype._getGamepadDeviceType=function(t){return t.indexOf("054c")!==-1?Kt.DualShock:t.indexOf("Xbox One")!==-1||t.search("Xbox 360")!==-1||t.search("xinput")!==-1?Kt.Xbox:t.indexOf("057e")!==-1?Kt.Switch:Kt.Generic},r._MAX_KEYCODES=255,r._MAX_POINTER_INPUTS=7,r}(),uu=function(){function r(t,e,n){n===void 0&&(n=0),this.deviceType=e,this.deviceSlot=n,this.onInputChangedObservable=new x.c,this._deviceInputSystem=t}return r.prototype.getInput=function(t){return this._deviceInputSystem.pollInput(this.deviceType,this.deviceSlot,t)},r}(),yp=function(){function r(t){var e=this;this.onDeviceConnectedObservable=new x.c(function(i){e.getDevices().forEac
1709h(function(o){e.onDeviceConnectedObservable.notifyObserver(i,o)})}),this.onDeviceDisconnectedObservable=new x.c;var n=Object.keys(Kt).length/2;this._devices=new Array(n),this._firstDevice=new Array(n),this._deviceInputSystem=lu.Create(t),this._deviceInputSystem.onDeviceConnected=function(i,o){e._addDevice(i,o),e.onDeviceConnectedObservable.notifyObservers(e.getDeviceSource(i,o))},this._deviceInputSystem.onDeviceDisconnected=function(i,o){var a=e.getDeviceSource(i,o);e._removeDevice(i,o),e.onDeviceDisconnectedObservable.notifyObservers(a)},this._deviceInputSystem.onInputChanged||(this._deviceInputSystem.onInputChanged=function(i,o,a,s,d){var p;(p=e.getDeviceSource(i,o))===null||p===void 0||p.onInputChangedObservable.notifyObservers({inputIndex:a,previousState:s,currentState:d})})}return r.prototype.getDeviceSource=function(t,e){if(e===void 0){if(this._firstDevice[t]===void 0)return null;e=this._firstDevice[t]}return this._devices[t]&&this._devices[t][e]!==void 0?this._devices[t][e]:null},r.prototype.getDeviceSources=function(t){return this._devices[t].filter(function(e){return!!e})},r.prototype.getDevices=function(){var t=new Array;return this._devices.forEach(function(e){t.push.apply(t,e)}),t},r.prototype.dispose=function(){this.onDeviceConnectedObservable.clear(),this.onDeviceDisconnectedObservable.clear(),this._deviceInputSystem.dispose()},r.prototype._addDevice=function(t,e){this._devices[t]||(this._devices[t]=new Array),this._devices[t][e]||(this._devices[t][e]=new uu(this._deviceInputSystem,t,e),this._updateFirstDevices(t))},r.prototype._removeDevice=function(t,e){delete this._devices[t][e],this._updateFirstDevices(t)},r.prototype._updateFirstDevices=function(t){switch(t){case Kt.Keyboard:case Kt.Mouse:this._firstDevice[t]=0;break;case Kt.Touch:case Kt.DualShock:case Kt.Xbox:case Kt.Switch:case Kt.Generic:var e=this._devices[t];delete this._firstDevice[t];for(var n=0;n<e.length;n++)if(e[n]){this._firstDevice[t]=n;break}}},r}(),hu=f(168),du=(f(123),function(){this._timeElapsedQueryEnded=!1}),fu=function(){this.occlusionInternalRetryCounter=0,this.isOcclusionQueryInProgress=!1,this.isOccluded=!1,this.occlusionRetryCount=-1,this.occlusionType=Dt.a.OCCLUSION_TYPE_NONE,this.occlusionQueryAlgorithmType=Dt.a.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE};Ue.a.prototype.createQuery=function(){return this._gl.createQuery()},Ue.a.prototype.deleteQuery=function(r){return this._gl.deleteQuery(r),this},Ue.a.prototype.isQueryResultAvailable=function(r){return this._gl.getQueryParameter(r,this._gl.QUERY_RESULT_AVAILABLE)},Ue.a.prototype.getQueryResult=function(r){return this._gl.getQueryParameter(r,this._gl.QUERY_RESULT)},Ue.a.prototype.beginOcclusionQuery=function(r,t){var e=this._getGlAlgorithmType(r);return this._gl.beginQuery(e,t),this},Ue.a.prototype.endOcclusionQuery=function(r){var t=this._getGlAlgorithmType(r);return this._gl.endQuery(t),this},Ue.a.prototype._createTimeQuery=function(){var r=this.getCaps().timerQuery;return r.createQueryEXT?r.createQueryEXT():this.createQuery()},Ue.a.prototype._deleteTimeQuery=function(r){var t=this.getCaps().timerQuery;t.deleteQueryEXT?t.deleteQueryEXT(r):this.deleteQuery(r)},Ue.a.prototype._getTimeQueryResult=function(r){var t=this.getCaps().timerQuery;return t.getQueryObjectEXT?t.getQueryObjectEXT(r,t.QUERY_RESULT_EXT):this.getQueryResult(r)},Ue.a.prototype._getTimeQueryAvailability=function(r){var t=this.getCaps().timerQuery;return t.getQueryObjectEXT?t.getQueryObjectEXT(r,t.QUERY_RESULT_AVAILABLE_EXT):this.isQueryResultAvailable(r)},Ue.a.prototype.startTimeQuery=function(){var r=this.getCaps(),t=r.timerQuery;if(!t)return null;var e=new du;if(this._gl.getParameter(t.GPU_DISJOINT_EXT),r.canUseTimestampForTimerQuery)e._startTimeQuery=this._createTimeQuery(),t.queryCounterEXT(e._startTimeQuery,t.TIMESTAMP_EXT);else{if(this._currentNonTimestampToken)return this._currentNonTimestampToken;e._timeElapsedQuery=this._createTimeQuery(),t.beginQueryEXT?t.beginQueryEXT(t.TIME_ELAPSED_EXT,e._timeElapsedQuery):this._gl.beginQuery(t.TIME_ELAPSED_EXT,e._timeElapsedQuery),this._currentNonTimestampToken=e}return e},Ue.a.prototype.endTimeQuery=function(r){var t=this.getCaps(),e=t.timerQuery;if(!e||!r)return-1;if(t.canUseTimestampForTimerQuery){if(!r._startTimeQuery)return-1;r._endTimeQuery||(r._endTimeQuery=this._createTimeQuery(),e.queryCounterEXT(r._endTimeQuery,e.TIMESTAMP_EXT))}else if(!r._timeElapsedQueryEnded){if(!r._timeElapsedQuery)return-1;e.endQueryEXT?e.endQueryEXT(e.TIME_ELAPSED_EXT):this._gl.endQuery(e.TIME_ELAPSED_EXT),r._timeElapsedQueryEnded=!0}var n=this._gl.getParameter(e.GPU_DISJOINT_EXT),i=!1;if(r._endTimeQuery?i=this._getTimeQueryAvailability(r._endTimeQuery):r._timeElapsedQuery&&(i=this._getTimeQueryAvailability(r._timeElapsedQuery)),i&&!n){var o=0;if(t.canUseTimestampForTimerQuery){if(!r._startTimeQuery||!r._endTimeQuery)return-1;var a=this._getTimeQueryResult(r._startTimeQuery);o=this._getTimeQueryResult(r._endTimeQuery)-a,this._deleteTimeQuery(r._startTimeQuery),this._deleteTimeQuery(r._endTimeQuery),r._startTimeQuery=null,r._endTimeQuery=null}else{if(!r._timeElapsedQuery)return-1;o=this._getTimeQueryResult(r._timeElapsedQuery),this._deleteTimeQuery(r._timeElapsedQuery),r._timeElapsedQuery=null,r._timeElapsedQueryEnded=!1,this._currentNonTimestampToken=null}return o}return-1},Ue.a.prototype._getGlAlgorithmType=function(r){return r===Dt.a.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE?this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE:this._gl.ANY_SAMPLES_PASSED},Object.defineProperty(Dt.a.prototype,"isOcclusionQueryInProgress",{get:function(){return this._occlusionDataStorage.
1709isOcclusionQueryInProgress},set:function(r){this._occlusionDataStorage.isOcclusionQueryInProgress=r},enumerable:!1,configurable:!0}),Object.defineProperty(Dt.a.prototype,"_occlusionDataStorage",{get:function(){return this.__occlusionDataStorage||(this.__occlusionDataStorage=new fu),this.__occlusionDataStorage},enumerable:!1,configurable:!0}),Object.defineProperty(Dt.a.prototype,"isOccluded",{get:function(){return this._occlusionDataStorage.isOccluded},set:function(r){this._occlusionDataStorage.isOccluded=r},enumerable:!0,configurable:!0}),Object.defineProperty(Dt.a.prototype,"occlusionQueryAlgorithmType",{get:function(){return this._occlusionDataStorage.occlusionQueryAlgorithmType},set:function(r){this._occlusionDataStorage.occlusionQueryAlgorithmType=r},enumerable:!0,configurable:!0}),Object.defineProperty(Dt.a.prototype,"occlusionType",{get:function(){return this._occlusionDataStorage.occlusionType},set:function(r){this._occlusionDataStorage.occlusionType=r},enumerable:!0,configurable:!0}),Object.defineProperty(Dt.a.prototype,"occlusionRetryCount",{get:function(){return this._occlusionDataStorage.occlusionRetryCount},set:function(r){this._occlusionDataStorage.occlusionRetryCount=r},enumerable:!0,configurable:!0}),Dt.a.prototype._checkOcclusionQuery=function(){var r=this._occlusionDataStorage;
1709if(r.occlusionType===Dt.a.OCCLUSION_TYPE_NONE)return r.isOccluded=!1,!1;var t=this.getEngine();if(t.webGLVersion<2||!t.isQueryResultAvailable)return r.isOccluded=!1,!1;if(this.isOcclusionQueryInProgress&&this._occlusionQuery)if(t.isQueryResultAvailable(this._occlusionQuery)){var e=t.getQueryResult(this._occlusionQuery);r.isOcclusionQueryInProgress=!1,r.occlusionInternalRetryCounter=0,r.isOccluded=e!==1}else{if(r.occlusionInternalRetryCounter++,!(r.occlusionRetryCount!==-1&&r.occlusionInternalRetryCounter>r.occlusionRetryCount))return!1;r.isOcclusionQueryInProgress=!1,r.occlusionInternalRetryCounter=0,r.isOccluded=r.occlusionType!==Dt.a.OCCLUSION_TYPE_OPTIMISTIC&&r.isOccluded}var n=this.getScene();if(n.getBoundingBoxRenderer){var i=n.getBoundingBoxRenderer();this._occlusionQuery||(this._occlusionQuery=t.createQuery()),t.beginOcclusionQuery(r.occlusionQueryAlgorithmType,this._occlusionQuery),i.renderOcclusionBoundingBox(this),t.endOcclusionQuery(r.occlusionQueryAlgorithmType),this._occlusionDataStorage.isOcclusionQueryInProgress=!0}
1709return r.isOccluded};var Tp=!0;Ue.a.prototype.createTransformFeedback=function(){return this._gl.createTransformFeedback()},Ue.a.prototype.deleteTransformFeedback=function(r){this._gl.deleteTransformFeedback(r)},Ue.a.prototype.bindTransformFeedback=function(r){this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK,r)},Ue.a.prototype.beginTransformFeedback=function(r){r===void 0&&(r=!0),this._gl.beginTransformFeedback(r?this._gl.POINTS:this._gl.TRIANGLES)},Ue.a.prototype.endTransformFeedback=function(){this._gl.endTransformFeedback()},Ue.a.prototype.setTranformFeedbackVaryings=function(r,t){this._gl.transformFeedbackVaryings(r,t,this._gl.INTERLEAVED_ATTRIBS)},Ue.a.prototype.bindTransformFeedbackBuffer=function(r){this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER,0,r?r.underlyingResource:null)},f(126),Bt.a.prototype.updateVideoTexture=function(r,t,e){if(r&&!r._isDisabled){var n=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,this._gl.RGBA,this._gl.RGBA,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,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,t);else{if(!r._workingCanvas){r._workingCanvas=vs.a.CreateCanvas(r.width,r.height);var i=r._workingCanvas.getContext("2d");if(!i)throw new Error("Unable to get 2d context");r._workingContext=i,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,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,r._workingCanvas)}r.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),n||this._bindTextureDirectly(this._gl.TEXTURE_2D,null),r.isReady=!0}catch{r._isDisabled=!0}}},Bt.a.prototype.restoreSingleAttachment=function(){var r=this._gl;this.bindAttachments([r.BACK])},Bt.a.prototype.buildTextureLayout=function(r){for(var t=this._gl,e=[],n=0;n<r.length;n++)r[n]?e.push(t["COLOR_ATTACHMENT"+n]):e.push(t.NONE);return e},Bt.a.prototype.bindAttachments=function(r){this._gl.drawBuffers(r)},Bt.a.prototype.unBindMultiColorAttachmentFramebuffer=function(r,t,e){t===void 0&&(t=!1),this._currentRenderTarget=null;var n=this._gl,i=r[0]._attachments,o=i.length;if(r[0]._MSAAFramebuffer){n.bindFramebuffer(n.READ_FRAMEBUFFER,r[0]._MSAAFramebuffer),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,r[0]._framebuffer);for(var a=0;a<o;a++){for(var s=r[a],d=0;d<o;d++)i[d]=n.NONE;i[a]=n[this.webGLVersion>1?"COLOR_ATTACHMENT"+a:"COLOR_ATTACHMENT"+a+"_WEBGL"],n.readBuffer(i[a]),n.drawBuffers(i),n.blitFramebuffer(0,0,s.width,s.height,0,0,s.width,s.height,n.COLOR_BUFFER_BIT,n.NEAREST)}for(a=0;a<o;a++)i[a]=n[this.webGLVersion>1?"COLOR_ATTACHMENT"+a:"COLOR_ATTACHMENT"+a+"_WEBGL"];n.drawBuffers(i)}for(a=0;a<o;a++)!(s=r[a]).generateMipMaps||t||s.isCube||(this._bindTextureDirectly(n.TEXTURE_2D,s,!0),n.generateMipmap(n.TEXTURE_2D),this._bindTextureDirectly(n.TEXTURE_2D,null));e&&(r[0]._MSAAFramebuffer&&this._bindUnboundFramebuffer(r[0]._framebuffer),e()),this._bindUnboundFramebuffer(null)},Bt.a.prototype.createMultipleRenderTarget=function(r,t){var e=!1,n=!0,i=!1,o=!1,a=1,s=h.a.TEXTURETYPE_UNSIGNED_INT,d=h.a.TEXTURE_TRILINEAR_SAMPLINGMODE,p=new Array,y=new Array;t!==void 0&&(e=t.generateMipMaps!==void 0&&t.generateMipMaps,n=t.generateDepthBuffer===void 0||t.generateDepthBuffer,i=t.generateStencilBuffer!==void 0&&t.generateStencilBuffer,o=t.generateDepthTexture!==void 0&&t.generateDepthTexture,a=t.textureCount||1,t.types&&(p=t.types),t.samplingModes&&(y=t.samplingModes));var P=this._gl,O=P.createFramebuffer();this._bindUnboundFramebuffer(O);for(var U=r.width||r,F=r.height||r,z=[],J=[],ie=this._setupFramebufferDepthAttachments(i,n,U,F),se=0;se<a;se++){var ce=y[se]||d,ue=p[se]||s;(ue!==h.a.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(ue!==h.a.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(ce=h.a.TEXTURE_NEAREST_SAMPL
1709INGMODE);var fe=this._getSamplingParameters(ce,e);ue!==h.a.TEXTURETYPE_FLOAT||this._caps.textureFloat||(ue=h.a.TEXTURETYPE_UNSIGNED_INT,l.a.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type"));var ve=new xt.a(this,xt.b.MultiRenderTarget),Te=P[this.webGLVersion>1?"COLOR_ATTACHMENT"+se:"COLOR_ATTACHMENT"+se+"_WEBGL"];z.push(ve),J.push(Te),P.activeTexture(P["TEXTURE"+se]),P.bindTexture(P.TEXTURE_2D,ve._webGLTexture),P.texParameteri(P.TEXTURE_2D,P.TEXTURE_MAG_FILTER,fe.mag),P.texParameteri(P.TEXTURE_2D,P.TEXTURE_MIN_FILTER,fe.min),P.texParameteri(P.TEXTURE_2D,P.TEXTURE_WRAP_S,P.CLAMP_TO_EDGE),P.texParameteri(P.TEXTURE_2D,P.TEXTURE_WRAP_T,P.CLAMP_TO_EDGE),P.texImage2D(P.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(ue),U,F,0,P.RGBA,this._getWebGLTextureType(ue),null),P.framebufferTexture2D(P.DRAW_FRAMEBUFFER,Te,P.TEXTURE_2D,ve._webGLTexture,0),e&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(P.TEXTURE_2D,null),ve._framebuffer=O,ve._depthStencilBuffer=ie,ve.baseWidth=U,ve.baseHeight=F,ve.width=U,ve.height=F,ve.isReady=!0,ve.samples=1,ve.generateMipMaps=e,ve.samplingMode=ce,ve.type=ue,ve._generateDepthBuffer=n,ve._generateStencilBuffer=i,ve._attachments=J,ve._textureArray=z,this._internalTexturesCache.push(ve)}if(o&&this._caps.depthTextureExtension){var Oe=new xt.a(this,xt.b.MultiRenderTarget);P.activeTexture(P.TEXTURE0),P.bindTexture(P.TEXTURE_2D,Oe._webGLTexture),P.texParameteri(P.TEXTURE_2D,P.TEXTURE_MAG_FILTER,P.NEAREST),P.texParameteri(P.TEXTURE_2D,P.TEXTURE_MIN_FILTER,P.NEAREST),P.texParameteri(P.TEXTURE_2D,P.TEXTURE_WRAP_S,P.CLAMP_TO_EDGE),P.texParameteri(P.TEXTURE_2D,P.TEXTURE_WRAP_T,P.CLAMP_TO_EDGE),P.texImage2D(P.TEXTURE_2D,0,this.webGLVersion<2?P.DEPTH_COMPONENT:P.DEPTH_COMPONENT16,U,F,0,P.DEPTH_COMPONENT,P.UNSIGNED_SHORT,null),P.framebufferTexture2D(P.FRAMEBUFFER,P.DEPTH_ATTACHMENT,P.TEXTURE_2D,Oe._webGLTexture,0),Oe._framebuffer=O,Oe.baseWidth=U,Oe.baseHeight=F,Oe.width=U,Oe.height=F,Oe.isReady=!0,Oe.samples=1,Oe.generateMipMaps=e,Oe.samplingMode=P.NEAREST,Oe._generateDepthBuffer=n,Oe._generateStencilBuffer=i,z.push(Oe),this._internalTexturesCache.push(Oe)}return P.drawBuffers(J),this._bindUnboundFramebuffer(null),this.resetTextureCache(),z},Bt.a.prototype.updateMultipleRenderTargetTextureSampleCount=function(r,t){if(this.webGLVersion<2||!r)return 1;if(r[0].samples===t)return t;var e=r[0]._attachments.length;if(e===0)return 1;var n=this._gl;t=Math.min(t,this.getCaps().maxMSAASamples),r[0]._depthStencilBuffer&&(n.deleteRenderbuffer(r[0]._depthStencilBuffer),r[0]._depthStencilBuffer=null),r[0]._MSAAFramebuffer&&(n.deleteFramebuffer(r[0]._MSAAFramebuffer),r[0]._MSAAFramebuffer=null);for(var i=0;i<e;i++)r[i]._MSAARenderBuffer&&(n.deleteRenderbuffer(r[i]._MSAARenderBuffer),r[i]._MSAARenderBuffer=null);if(t>1&&n.renderbufferStorageMultisample){var o=n.createFramebuffer();if(!o)throw new Error("Unable to create multi sampled framebuffer");this._bindUnboundFramebuffer(o);var a=this._setupFramebufferDepthAttachments(r[0]._generateStencilBuffer,r[0]._generateDepthBuffer,r[0].width,r[0].height,t),s=[];for(i=0;i<e;i++){var d=r[i],p=n[this.webGLVersion>1?"COLOR_ATTACHMENT"+i:"COLOR_ATTACHMENT"+i+"_WEBGL"],y=n.createRenderbuffer();if(!y)throw new Error("Unable to create multi sampled framebuffer");n.bindRenderbuffer(n.RENDERBUFFER,y),n.renderbufferStorageMultisample(n.RENDERBUFFER,t,this._getRGBAMultiSampleBufferFormat(d.type),d.width,d.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,p,n.RENDERBUFFER,y),d._MSAAFramebuffer=o,d._MSAARenderBuffer=y,d.samples=t,d._depthStencilBuffer=a,n.bindRenderbuffer(n.RENDERBUFFER,null),s.push(p)}n.drawBuffers(s)}else this._bindUnboundFramebuffer(r[0]._framebuffer);return this._bindUnboundFramebuffer(null),t};var no=f(56);Bt.a.prototype._createDepthStencilCubeTexture=function(r,t){var e=new xt.a(this,xt.b.Unknown);if(e.isCube=!0,this.webGLVersion===1)return l.a.Error("Depth cube texture is not supported by WebGL 1."),e;var n=Object(c.a)({bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1},t),i=this._gl;this._bindTextureDirectly(i.TEXTURE_CUBE_MAP,e,!0),this._setupDepthStencilTexture(e,r,n.generateStencil,n.bilinearFiltering,n.comparisonFunction);for(var o=0;o<6;o++)n.generateStencil?i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+o,0,i.DEPTH24_STENCIL8,r,r,0,i.DEPTH_STENCIL,i.UNSIGNED_INT_24_8,null):i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+o,0,i.DEPTH_COMPONENT24,r,r,0,i.DEPTH_COMPONENT,i.UNSIGNED_INT,null);return this._bindTextureDirectly(i.TEXTURE_CUBE_MAP,null),e},Bt.a.prototype._partialLoadFile=function(r,t,e,n,i){i===void 0&&(i=null),this._loadFile(r,function(o){e[t]=o,e._internalCount++,e._internalCount===6&&n(e)},void 0,void 0,!0,function(o,a){i&&o&&i(o.status+" "+o.statusText,a)})},Bt.a.prototype._cascadeLoadFiles=function(r,t,e,n){n===void 0&&(n=null);var i=[];i._internalCount=0;for(var o=0;o<6;o++)this._partialLoadFile(e[o],o,i,t,n)},Bt.a.prototype._cascadeLoadImgs=function(r,t,e,n,i){n===void 0&&(n=null);var o=[];o._internalCount=0;for(var a=0;a<6;a++)this._partialLoadImg(e[a],a,o,r,t,n,i)},Bt.a.prototype._partialLoadImg=function(r,t,e,n,i,o,a){var s;o===void 0&&(o=null),s=no.a.LoadImage(r,function(){s&&(e[t]=s,e._internalCount++,n&&n._removePendingData(s)),e._internalCount===6&&i(e)},function(d,p){n&&n._removePendingData(s),o&&o(d,p)},n?n.offlineProvider:null,a),n&&s&&n._addPendingData(s)}
1709,Bt.a.prototype._setCubeMapTextureParams=function(r,t){var e=this._gl;e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MIN_FILTER,t?e.LINEAR_MIPMAP_LINEAR:e.LINEAR),e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),r.samplingMode=t?h.a.TEXTURE_TRILINEAR_SAMPLINGMODE:h.a.TEXTURE_LINEAR_LINEAR,this._bindTextureDirectly(e.TEXTURE_CUBE_MAP,null)},Bt.a.prototype.createCubeTexture=function(r,t,e,n,i,o,a,s,d,p,y,P,O){var U=this;i===void 0&&(i=null),o===void 0&&(o=null),s===void 0&&(s=null),d===void 0&&(d=!1),p===void 0&&(p=0),y===void 0&&(y=0),P===void 0&&(P=null);var F=this._gl,z=P||new xt.a(this,xt.b.Cube);z.isCube=!0,z.url=r,z.generateMipMaps=!n,z._lodGenerationScale=p,z._lodGenerationOffset=y,this._doNotHandleContextLost||(z._extension=s,z._files=e);var J=r;this._transformTextureUrl&&!P&&(r=this._transformTextureUrl(r));for(var ie=r.lastIndexOf("."),se=s||(ie>-1?r.substring(ie).toLowerCase():""),ce=null,ue=0,fe=Bt.a._TextureLoaders;ue<fe.length;ue++){var ve=fe[ue];if(ve.canLoad(se)){ce=ve;break}}if(ce){var Te=function(Oe){U._bindTextureDirectly(F.TEXTURE_CUBE_MAP,z,!0),ce.loadCubeData(Oe,z,d,i,o)};e&&e.length===6?ce.supportCascades?this._cascadeLoadFiles(t,function(Oe){return Te(Oe.map(function(Pe){return new Uint8Array(Pe)}))},e,o):o?o("Textures type does not support cascades."):l.a.Warn("Texture loader does not support cascades."):this._loadFile(r,function(Oe){return Te(new Uint8Array(Oe))},void 0,void 0,!0,function(Oe,Pe){r===J?o&&Oe&&o(Oe.status+" "+Oe.statusText,Pe):(l.a.Warn("Failed to load "+r+", falling back to the "+J),U.createCubeTexture(J,t,e,n,i,o,a,s,d,p,y,z,O))})}else{if(!e)throw new Error("Cannot load cubemap because files were not defined");this._cascadeLoadImgs(t,function(Oe){var Pe=U.needPOTTextures?Bt.a.GetExponentOfTwo(Oe[0].width,U._caps.maxCubemapTextureSize):Oe[0].width,Ee=Pe,Se=[F.TEXTURE_CUBE_MAP_POSITIVE_X,F.TEXTURE_CUBE_MAP_POSITIVE_Y,F.TEXTURE_CUBE_MAP_POSITIVE_Z,F.TEXTURE_CUBE_MAP_NEGATIVE_X,F.TEXTURE_CUBE_MAP_NEGATIVE_Y,F.TEXTURE_CUBE_MAP_NEGATIVE_Z];U._bindTextureDirectly(F.TEXTURE_CUBE_MAP,z,!0),U._unpackFlipY(!1);for(var Le=a?U._getInternalFormat(a):U._gl.RGBA,xe=0;xe<Se.length;xe++)if(Oe[xe].width!==Pe||Oe[xe].height!==Ee){if(U._prepareWorkingCanvas(),!U._workingCanvas||!U._workingContext)return void l.a.Warn("Cannot create canvas to resize texture.");U._workingCanvas.width=Pe,U._workingCanvas.height=Ee,U._workingContext.drawImage(Oe[xe],0,0,Oe[xe].width,Oe[xe].height,0,0,Pe,Ee),F.texImage2D(Se[xe],0,Le,Le,F.UNSIGNED_BYTE,U._workingCanvas)}else F.texImage2D(Se[xe],0,Le,Le,F.UNSIGNED_BYTE,Oe[xe]);n||F.generateMipmap(F.TEXTURE_CUBE_MAP),U._setCubeMapTextureParams(z,!n),z.width=Pe,z.height=Ee,z.isReady=!0,a&&(z.format=a),z.onLoadedObservable.notifyObservers(z),z.onLoadedObservable.clear(),i&&i()},e,o)}return this._internalTexturesCache.push(z),z},f(153),f(124);var Ep=function(){};Ue.a.prototype.getInputElement=function(){return this.inputElement||this.getRenderingCanvas()},Ue.a.prototype.registerView=function(r,t){var e=this;this.views||(this.views=[]);for(var n=0,i=this.views;n<i.length;n++){var o=i[n];if(o.target===r)return o}var a=this.getRenderingCanvas();a&&(r.width=a.width,r.height=a.height);var s={target:r,camera:t};return this.views.push(s),t&&t.onDisposeObservable.add(function(){e.unRegisterView(r)}),s},Ue.a.prototype.unRegisterView=function(r){if(!this.views)return this;for(var t=0,e=this.views;t<e.length;t++){var n=e[t];if(n.target===r){var i=this.views.indexOf(n);i!==-1&&this.views.splice(i,1);break}}return this},Ue.a.prototype._renderViews=function(){if(!this.views)return!1;var r=this.getRenderingCanvas();if(!r)return!1;for(var t=0,e=this.views;t<e.length;t++){var n=e[t],i=n.target,o=i.getContext("2d");if(o){var a=n.camera,s=null,d=null;if(a){if((d=a.getScene()).activeCameras&&d.activeCameras.length)continue;this.activeView=n,s=d.activeCamera,d.activeCamera=a}var p=i.width!==i.clientWidth||i.height!==i.clientHeight;if(i.clientWidth&&i.clientHeight&&p&&(i.width=i.clientWidth,i.height=i.clientHeight,r.width=i.clientWidth,r.height=i.clientHeight,this.resize()),!r.width||!r.height)return!1;this._renderFrame(),o.drawImage(r,0,0),s&&d&&(d.activeCamera=s)}}return this.activeView=null,!0},f(129);function Sp(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}Object.defineProperty(Ue.a.prototype,"texturesSupported",{get:function(){var r=new Array;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(Ue.a.prototype,"textureFormatInUse",{get:function(){return this._textureFormatInUse||null},enumerable:!0,configurable:!0}),Ue.a.prototype.setCompressedTextureExclusions=function(r){this._excludedCompressedTextures=r},Ue.a.prototype.setTextureFormatToUse=function(r){for(var t=this.texturesSupported,e=0,n=t.length;e<n;e++)for(var i=0,o=r.length;i<o;i++)if(t[e]===r[i].toLowerCase())return this._transformTextureUrl=Sp.bind(this),this._textureFormatInUse=t[e];return this._textureFormatInUse="",this._transformTextureUrl=null,null};var Ap=f(144),pu=f(118),_u=f(89),hi=[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))],Pp=[function(r){return 1},function(r){return r.y},function(r){return r.z},function(r){return r.x},function(r){return r.x*r.y},function(r){return r.y*r.z},function(r){return 3*r.z*r.z-1},function(r){return r.x*r.z},function(r){return r.x*r.x-r.y*r.y}],Ti=function(r,t){return hi[r]*Pp[r](t)},Ei=[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],xs=function(){function r(){this.preScaled=!1,this.l00=u.e.Zero(),this.l1_1=u.e.Zero(),this.l10=u.e.Zero(),this.l11=u.e.Zero(),this.l2_2=u.e.Zero(),this.l2_1=u.e.Zero(),this.l20=u.e.Zero(),this.l21=u.e.Zero(),this.l22=u.e.Zero()}return r.prototype.addLight=function(t,e,n){var i=new u.e(e.r,e.g,e.b).scale(n);this.l00=this.l00.add(i.scale(Ti(0,t))),this.l1_1=this.l1_1.add(i.scale(Ti(1,t))),this.l10=this.l10.add(i.scale(Ti(2,t))),this.l11=this.l11.add(i.scale(Ti(3,t))),this.l2_2=this.l2_2.add(i.scale(Ti(4,t))),this.l2_1=this.l2_1.add(i.scale(Ti(5,t))),this.l20=this.l20.add(i.scale(Ti(6,t))),this.l21=this.l21.add(i.scale(Ti(7,t))),this.l22=this.l22.add(i.scale(Ti(8,t)))},r.prototype.scaleInPlace=function(t){this.l00.scaleInPlace(t),this.l1_1.scaleInPlace(t),this.l10.scaleInPlace(t),this.l11.scaleInPlace(t),this.l2_2.scaleInPlace(t),this.l2_1.scaleInPlace(t),this.l20.scaleInPlace(t),this.l21.scaleInPlace(t),this.l22.scaleInPlace(t)},r.prototype.convertIncidentRadianceToIrradiance=function(){this.l00.scaleInPlace(Ei[0]),this.l1_1.scaleInPlace(Ei[1]),this.l10.scaleInPlace(Ei[2]),this.l11.scaleInPlace(Ei[3]),this.l2_2.scaleInPlace(Ei[4]),this.l2_1.scaleInPlace(Ei[5]),this.l20.scaleInPlace(Ei[6]),this.l21.scaleInPlace(Ei[7]),this.l22.scaleInPlace(Ei[8])}
1709,r.prototype.convertIrradianceToLambertianRadiance=function(){this.scaleInPlace(1/Math.PI)},r.prototype.preScaleForRendering=function(){this.preScaled=!0,this.l00.scaleInPlace(hi[0]),this.l1_1.scaleInPlace(hi[1]),this.l10.scaleInPlace(hi[2]),this.l11.scaleInPlace(hi[3]),this.l2_2.scaleInPlace(hi[4]),this.l2_1.scaleInPlace(hi[5]),this.l20.scaleInPlace(hi[6]),this.l21.scaleInPlace(hi[7]),this.l22.scaleInPlace(hi[8])},r.FromArray=function(t){var e=new r;return u.e.FromArrayToRef(t[0],0,e.l00),u.e.FromArrayToRef(t[1],0,e.l1_1),u.e.FromArrayToRef(t[2],0,e.l10),u.e.FromArrayToRef(t[3],0,e.l11),u.e.FromArrayToRef(t[4],0,e.l2_2),u.e.FromArrayToRef(t[5],0,e.l2_1),u.e.FromArrayToRef(t[6],0,e.l20),u.e.FromArrayToRef(t[7],0,e.l21),u.e.FromArrayToRef(t[8],0,e.l22),e},r.FromPolynomial=function(t){var e=new r;return e.l00=t.xx.scale(.376127).add(t.yy.scale(.376127)).add(t.zz.scale(.376126)),e.l1_1=t.y.scale(.977204),e.l10=t.z.scale(.977204),e.l11=t.x.scale(.977204),e.l2_2=t.xy.scale(1.16538),e.l2_1=t.yz.scale(1.16538),e.l20=t.zz.scale(1.34567).subtract(t.xx.scale(.672834)).subtract(t.yy.scale(.672834)),e.l21=t.zx.scale(1.16538),e.l22=t.xx.scale(1.16538).subtract(t.yy.scale(1.16538)),e.l1_1.scaleInPlace(-1),e.l11.scaleInPlace(-1),e.l2_1.scaleInPlace(-1),e.l21.scaleInPlace(-1),e.scaleInPlace(Math.PI),e},r}(),io=function(){function r(){this.x=u.e.Zero(),this.y=u.e.Zero(),this.z=u.e.Zero(),this.xx=u.e.Zero(),this.yy=u.e.Zero(),this.zz=u.e.Zero(),this.xy=u.e.Zero(),this.yz=u.e.Zero(),this.zx=u.e.Zero()}return Object.defineProperty(r.prototype,"preScaledHarmonics",{get:function(){return this._harmonics||(this._harmonics=xs.FromPolynomial(this)),this._harmonics.preScaled||this._harmonics.preScaleForRendering(),this._harmonics},enumerable:!1,configurable:!0}),r.prototype.addAmbient=function(t){var e=new u.e(t.r,t.g,t.b);this.xx=this.xx.add(e),this.yy=this.yy.add(e),this.zz=this.zz.add(e)},r.prototype.scaleInPlace=function(t){this.x.scaleInPlace(t),this.y.scaleInPlace(t),this.z.scaleInPlace(t),this.xx.scaleInPlace(t),this.yy.scaleInPlace(t),this.zz.scaleInPlace(t),this.yz.scaleInPlace(t),this.zx.scaleInPlace(t),this.xy.scaleInPlace(t)},r.FromHarmonics=function(t){var e=new r;return e._harmonics=t,e.x=t.l11.scale(1.02333).scale(-1),e.y=t.l1_1.scale(1.02333).scale(-1),e.z=t.l10.scale(1.02333),e.xx=t.l00.scale(.886277).subtract(t.l20.scale(.247708)).add(t.l22.scale(.429043)),e.yy=t.l00.scale(.886277).subtract(t.l20.scale(.247708)).subtract(t.l22.scale(.429043)),e.zz=t.l00.scale(.886277).add(t.l20.scale(.495417)),e.yz=t.l2_1.scale(.858086).scale(-1),e.zx=t.l21.scale(.858086).scale(-1),e.xy=t.l2_2.scale(.858086),e.scaleInPlace(1/Math.PI),e},r.FromArray=function(t){var e=new r;return u.e.FromArrayToRef(t[0],0,e.x),u.e.FromArrayToRef(t[1],0,e.y),u.e.FromArrayToRef(t[2],0,e.z),u.e.FromArrayToRef(t[3],0,e.xx),u.e.FromArrayToRef(t[4],0,e.yy),u.e.FromArrayToRef(t[5],0,e.zz),u.e.FromArrayToRef(t[6],0,e.yz),u.e.FromArrayToRef(t[7],0,e.zx),u.e.FromArrayToRef(t[8],0,e.xy),e},r}(),zn=f(52),br=function(r,t,e,n){this.name=r,this.worldAxisForNormal=t,this.worldAxisForFileX=e,this.worldAxisForFileY=n},Xo=function(){function r(){}return r.ConvertCubeMapTextureToSphericalPolynomial=function(t){if(!t.isCube)return null;var e,n,i=t.getSize().width,o=t.readPixels(0),a=t.readPixels(1);t.isRenderTarget?(e=t.readPixels(3),n=t.readPixels(2)):(e=t.readPixels(2),n=t.readPixels(3));var s=t.readPixels(4),d=t.readPixels(5),p=t.gammaSpace,y=h.a.TEXTUREFORMAT_RGBA,P=h.a.TEXTURETYPE_UNSIGNED_INT;t.textureType!=h.a.TEXTURETYPE_FLOAT&&t.textureType!=h.a.TEXTURETYPE_HALF_FLOAT||(P=h.a.TEXTURETYPE_FLOAT);var O={size:i,right:o,left:a,up:e,down:n,front:s,back:d,format:y,type:P,gammaSpace:p};return this.ConvertCubeMapToSphericalPolynomial(O)},r.ConvertCubeMapToSphericalPolynomial=function(t){for(var e=new xs,n=0,i=2/t.size,o=i,a=.5*i-1,s=0;s<6;s++)for(var d=this.FileFaces[s],p=t[d.name],y=a,P=t.format===h.a.TEXTUREFORMAT_RGBA?4:3,O=0;O<t.size;O++){for(var U=a,F=0;F<t.size;F++){var z=d.worldAxisForFileX.scale(U).add(d.worldAxisForFileY.scale(y)).add(d.worldAxisForNormal);z.normalize();var J=Math.pow(1+U*U+y*y,-1.5),ie=p[O*t.size*P+F*P+0],se=p[O*t.size*P+F*P+1],ce=p[O*t.size*P+F*P+2];isNaN(ie)&&(ie=0),isNaN(se)&&(se=0),isNaN(ce)&&(ce=0),t.type===h.a.TEXTURETYPE_UNSIGNED_INT&&(ie/=255,se/=255,ce/=255),t.gammaSpace&&(ie=Math.pow($.a.Clamp(ie),Gt.c),se=Math.pow($.a.Clamp(se),Gt.c),ce=Math.pow($.a.Clamp(ce),Gt.c)),ie=$.a.Clamp(ie,0,4096),se=$.a.Clamp(se,0,4096),ce=$.a.Clamp(ce,0,4096);var ue=new M.a(ie,se,ce);e.addLight(z,ue,J),n+=J,U+=i}y+=o}var fe=6*(4*Math.PI)/6/n;return e.scaleInPlace(fe),e.convertIncidentRadianceToIrradiance(),e.convertIrradianceToLambert
1709ianRadiance(),io.FromHarmonics(e)},r.FileFaces=[new br("right",new u.e(1,0,0),new u.e(0,0,-1),new u.e(0,-1,0)),new br("left",new u.e(-1,0,0),new u.e(0,0,1),new u.e(0,-1,0)),new br("up",new u.e(0,1,0),new u.e(1,0,0),new u.e(0,0,1)),new br("down",new u.e(0,-1,0),new u.e(1,0,0),new u.e(0,0,-1)),new br("front",new u.e(0,0,1),new u.e(1,0,0),new u.e(0,-1,0)),new br("back",new u.e(0,0,-1),new u.e(-1,0,0),new u.e(0,-1,0))],r}();Object.defineProperty(zn.a.prototype,"sphericalPolynomial",{get:function(){if(this._texture){if(this._texture._sphericalPolynomial)return this._texture._sphericalPolynomial;if(this._texture.isReady)return this._texture._sphericalPolynomial=Xo.ConvertCubeMapTextureToSphericalPolynomial(this),this._texture._sphericalPolynomial}return null},set:function(r){this._texture&&(this._texture._sphericalPolynomial=r)},enumerable:!0,configurable:!0});var Cp=`
1710varying vec2 vUV;
1711uniform sampler2D textureSampler;
1712#include<helperFunctions>
1713void main(void)
1714{
1715gl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);
1716}`;je.a.ShadersStore.rgbdEncodePixelShader=Cp;var xp=`
1717varying vec2 vUV;
1718uniform sampler2D textureSampler;
1719#include<helperFunctions>
1720void main(void)
1721{
1722gl_FragColor=vec4(fromRGBD(texture2D(textureSampler,vUV)),1.0);
1723}`;je.a.ShadersStore.rgbdDecodePixelShader=xp;var Si=function(){function r(){}return r.GetEnvInfo=function(t){for(var e=new DataView(t.buffer,t.byteOffset,t.byteLength),n=0,i=0;i<r._MagicBytes.length;i++)if(e.getUint8(n++)!==r._MagicBytes[i])return l.a.Error("Not a babylon environment map"),null;for(var o="",a=0;a=e.getUint8(n++);)o+=String.fromCharCode(a);var s=JSON.parse(o);return s.specular&&(s.specular.specularDataPosition=n,s.specular.lodGenerationScale=s.specular.lodGenerationScale||.8),s},r.CreateEnvTextureAsync=function(t){var e=this,n=t.getInternalTexture();if(!n)return Promise.reject("The cube texture is invalid.");var i=n.getEngine();if(i&&i.premultipliedAlpha)return Promise.reject("Env texture can only be created when the engine is created with the premultipliedAlpha option set to false.");if(t.textureType===h.a.TEXTURETYPE_UNSIGNED_INT)return Promise.reject("The cube texture should allow HDR (Full Float or Half Float).");var o=i.getRenderingCanvas();if(!o)return Promise.reject("Env texture can only be created when the engine is associated to a canvas.");var a=h.a.TEXTURETYPE_FLOAT;if(!i.getCaps().textureFloatRender&&(a=h.a.TEXTURETYPE_HALF_FLOAT,!i.getCaps().textureHalfFloatRender))return Promise.reject("Env texture can only be created when the browser supports half float or full float rendering.");var s=n.width,d=new _e.a(i),p={},y=[],P=$.a.Log2(n.width);P=Math.round(P);for(var O=function(F){for(var z=Math.pow(2,P-F),J=function(se){var ce=t.readPixels(se,F),ue=i.createRawTexture(ce,z,z,h.a.TEXTUREFORMAT_RGBA,!1,!1,h.a.TEXTURE_NEAREST_SAMPLINGMODE,null,a),fe=new Promise(function(ve,Te){var Oe=new _t("rgbdEncode","rgbdEncode",null,null,1,null,h.a.TEXTURE_NEAREST_SAMPLINGMODE,i,!1,void 0,h.a.TEXTURETYPE_UNSIGNED_INT,void 0,null,!1);Oe.getEffect().executeWhenCompiled(function(){Oe.onApply=function(Se){Se._bindTexture("textureSampler",ue)};var Pe=i.getRenderWidth(),Ee=i.getRenderHeight();i.setSize(z,z),d.postProcessManager.directRender([Oe],null),Ye.b.ToBlob(o,function(Se){var Le=new FileReader;Le.onload=function(xe){var Ne=xe.target.result;p[6*F+se]=Ne,ve()},Le.readAsArrayBuffer(Se)}),i.setSize(Pe,Ee)})});y.push(fe)},ie=0;ie<6;ie++)J(ie)},U=0;U<=P;U++)O(U);return Promise.all(y).then(function(){d.dispose();for(var F={version:1,width:s,irradiance:e._CreateEnvTextureIrradiance(t),specular:{mipmaps:[],lodGenerationScale:t.lodGenerationScale}},z=0,J=0;J<=P;J++)for(var ie=0;ie<6;ie++){var se=p[6*J+ie].byteLength;F.specular.mipmaps.push({length:se,position:z}),z+=se}for(var ce=JSON.stringify(F),ue=new ArrayBuffer(ce.length+1),fe=new Uint8Array(ue),ve=(J=0,ce.length);J<ve;J++)fe[J]=ce.charCodeAt(J);fe[ce.length]=0;var Te=r._MagicBytes.length+z+ue.byteLength,Oe=new ArrayBuffer(Te),Pe=new Uint8Array(Oe),Ee=new DataView(Oe),Se=0;for(J=0;J<r._MagicBytes.length;J++)Ee.setUint8(Se++,r._MagicBytes[J]);for(Pe.set(new Uint8Array(ue),Se),Se+=ue.byteLength,J=0;J<=P;J++)for(ie=0;ie<6;ie++){var Le=p[6*J+ie];Pe.set(new Uint8Array(Le),Se),Se+=Le.byteLength}return Oe})},r._CreateEnvTextureIrradiance=function(t){var e=t.sphericalPolynomial;return e==null?null:{x:[e.x.x,e.x.y,e.x.z],y:[e.y.x,e.y.y,e.y.z],z:[e.z.x,e.z.y,e.z.z],xx:[e.xx.x,e.xx.y,e.xx.z],yy:[e.yy.x,e.yy.y,e.yy.z],zz:[e.zz.x,e.zz.y,e.zz.z],yz:[e.yz.x,e.yz.y,e.yz.z],zx:[e.zx.x,e.zx.y,e.zx.z],xy:[e.xy.x,e.xy.y,e.xy.z]}},r.CreateImageDataArrayBufferViews=function(t,e){if(e.version!==1)throw new Error('Unsupported babylon environment map version "'+e.version+'"');var n=e.specular,i=$.a.Log2(e.width);if(i=Math.round(i)+1,n.mipmaps.length!==6*i)throw new Error('Unsupported specular mipmaps number "'+n.mipmaps.length+'"');for(var o=new Array(i),a=0;a<i;a++){o[a]=new Array(6);for(var s=0;s<6;s++){var d=n.mipmaps[6*a+s];o[a][s]=new Uint8Array(t.buffer,t.byteOffset+n.specularDataPosition+d.position,d.length)}}return o},r.UploadEnvLevelsAsync=function(t,e,n){if(n.version!==1)throw new Error('Unsupported babylon environment map version "'+n.version+'"');var i=n.specular;if(!i)return Promise.resolve();t._lodGenerationScale=i.lodGenerationScale;var o=r.CreateImageDataArrayBufferViews(e,n);return r.UploadLevelsAsync(t,o)},r._OnImageReadyAsync=function(t,e,n,i,o,a,s,d,p,y,P){return new Promise(function(O,U){if(n){var F=e.createTexture(null,!0,!0,null,h.a.TEXTURE_NEAREST_SAMPL
1723INGMODE,null,function(J){U(J)},t);i.getEffect().executeWhenCompiled(function(){i.onApply=function(J){J._bindTexture("textureSampler",F),J.setFloat2("scale",1,1)},e.scenes[0].postProcessManager.directRender([i],y,!0,a,s),e.restoreDefaultFramebuffer(),F.dispose(),URL.revokeObjectURL(o),O()})}else{if(e._uploadImageToTexture(P,t,a,s),d){var z=p[s];z&&e._uploadImageToTexture(z._texture,t,a,0)}O()}})},r.UploadLevelsAsync=function(t,e){var n=this;if(!Ye.b.IsExponentOfTwo(t.width))throw new Error("Texture size must be a power of two");var i=Math.round($.a.Log2(t.width))+1,o=t.getEngine(),a=!1,s=!1,d=null,p=null,y=null,P=o.getCaps();if(t.format=h.a.TEXTUREFORMAT_RGBA,t.type=h.a.TEXTURETYPE_UNSIGNED_INT,t.generateMipMaps=!0,t._cachedAnisotropicFilteringLevel=null,o.updateTextureSamplingMode(h.a.TEXTURE_TRILINEAR_SAMPLINGMODE,t),P.textureLOD?o.webGLVersion<2?a=!1:P.textureHalfFloatRender&&P.textureHalfFloatLinearFiltering?(a=!0,t.type=h.a.TEXTURETYPE_HALF_FLOAT):P.textureFloatRender&&P.textureFloatLinearFiltering&&(a=!0,t.type=h.a.TEXTURETYPE_FLOAT):(a=!1,s=!0,y={}),a)d=new _t("rgbdDecode","rgbdDecode",null,null,1,null,h.a.TEXTURE_TRILINEAR_SAMPLINGMODE,o,!1,void 0,t.type,void 0,null,!1),t._isRGBD=!1,t.invertY=!1,p=o.createRenderTargetCubeTexture(t.width,{generateDepthBuffer:!1,generateMipMaps:!0,generateStencilBuffer:!1,samplingMode:h.a.TEXTURE_TRILINEAR_SAMPLINGMODE,type:t.type,format:h.a.TEXTUREFORMAT_RGBA});else if(t._isRGBD=!0,t.invertY=!0,s)for(var O=t._lodGenerationScale,U=t._lodGenerationOffset,F=0;F<3;F++){var z=(i-1)*O+U,J=U+(z-U)*(1-F/2),ie=Math.round(Math.min(Math.max(J,0),z)),se=new xt.a(o,xt.b.Temp);se.isCube=!0,se.invertY=!0,se.generateMipMaps=!1,o.updateTextureSamplingMode(h.a.TEXTURE_LINEAR_LINEAR,se);var ce=new zn.a(null);switch(ce.isCube=!0,ce._texture=se,y[ie]=ce,F){case 0:t._lodTextureLow=ce;break;case 1:t._lodTextureMid=ce;break;case 2:t._lodTextureHigh=ce}}var ue=[],fe=function(Ee){for(var Se=function(xe){var Ne=e[Ee][xe],Ie=new Blob([Ne],{type:"image/png"}),Fe=URL.createObjectURL(Ie),Ke=void 0;if(typeof Image>"u")Ke=createImageBitmap(Ie).then(function(rt){return n._OnImageReadyAsync(rt,o,a,d,Fe,xe,Ee,s,y,p,t)});else{var nt=new Image;nt.src=Fe,Ke=new Promise(function(rt,ut){nt.onload=function(){n._OnImageReadyAsync(nt,o,a,d,Fe,xe,Ee,s,y,p,t).then(function(){return rt()}).catch(function(qe){ut(qe)})},nt.onerror=function(qe){ut(qe)}})}ue.push(Ke)},Le=0;Le<6;Le++)Se(Le)};for(F=0;F<e.length;F++)fe(F);if(e.length<i){var ve=void 0,Te=Math.pow(2,i-1-e.length),Oe=Te*Te*4;switch(t.type){case h.a.TEXTURETYPE_UNSIGNED_INT:ve=new Uint8Array(Oe);break;case h.a.TEXTURETYPE_HALF_FLOAT:ve=new Uint16Array(Oe);break;case h.a.TEXTURETYPE_FLOAT:ve=new Float32Array(Oe)}for(F=e.length;F<i;F++)for(var Pe=0;Pe<6;Pe++)o._uploadArrayBufferViewToTexture(t,ve,Pe,F)}return Promise.all(ue).then(function(){p&&(o._releaseFramebufferObjects(p),o._releaseTexture(t),p._swapAndDie(t)),d&&d.dispose(),s&&(t._lodTextureHigh&&t._lodTextureHigh._texture&&(t._lodTextureHigh._texture.isReady=!0),t._lodTextureMid&&t._lodTextureMid._texture&&(t._lodTextureMid._texture.isReady=!0),t._lodTextureLow&&t._lodTextureLow._texture&&(t._lodTextureLow._texture.isReady=!0))})},r.UploadEnvSpherical=function(t,e){e.version!==1&&l.a.Warn('Unsupported babylon environment map version "'+e.version+'"');var n=e.irradiance;if(n){var i=new io;u.e.FromArrayToRef(n.x,0,i.x),u.e.FromArrayToRef(n.y,0,i.y),u.e.FromArrayToRef(n.z,0,i.z),u.e.FromArrayToRef(n.xx,0,i.xx),u.e.FromArrayToRef(n.yy,0,i.yy),u.e.FromArrayToRef(n.zz,0,i.zz),u.e.FromArrayToRef(n.yz,0,i.yz),u.e.FromArrayToRef(n.zx,0,i.zx),u.e.FromArrayToRef(n.xy,0,i.xy),t._sphericalPolynomial=i}},r._UpdateRGBDAsync=function(t,e,n,i,o){return t._source=xt.b.CubeRawRGBD,t._bufferViewArrayArray=e,t._lodGenerationScale=i,t._lodGenerationOffset=o,t._sphericalPolynomial=n,r.UploadLevelsAsync(t,e).then(function(){t.isReady=!0})},r._MagicBytes=[134,22,135,150,246,214,150,54],r}();xt.a._UpdateRGBDAsync=Si._UpdateRGBDAsync;var Ai,Rs=function(){function r(t,e){e===void 0&&(e=20),this.debug=!1,this._sourceCode=t,this._numMaxIterations=e,this._functionDescr=[],this.inlineToken="#define inline"}return Object.defineProperty(r.prototype,"code",{get:function(){return this._sourceCode}
1723,enumerable:!1,configurable:!0}),r.prototype.processCode=function(){this.debug&&console.log("Start inlining process (code size="+this._sourceCode.length+")..."),this._collectFunctions(),this._processInlining(this._numMaxIterations),this.debug&&console.log("End of inlining process.")},r.prototype._collectFunctions=function(){for(var t=0;t<this._sourceCode.length;){var e=this._sourceCode.indexOf(this.inlineToken,t);if(e<0)break;var n=this._sourceCode.indexOf("(",e+this.inlineToken.length);if(n<0)this.debug&&console.warn("Could not find the opening parenthesis after the token. startIndex="+t),t=e+this.inlineToken.length;else{var i=r._RegexpFindFunctionNameAndType.exec(this._sourceCode.substring(e+this.inlineToken.length,n));if(i){var o=[i[3],i[4]],a=o[0],s=o[1],d=this._extractBetweenMarkers("(",")",this._sourceCode,n);if(d<0)this.debug&&console.warn("Could not extract the parameters the function '"+s+"' (type="+a+"). funcParamsStartIndex="+n),t=e+this.inlineToken.length;else{var p=this._sourceCode.substring(n+1,d),y=this._skipWhitespaces(this._sourceCode,d+1);if(y!==this._sourceCode.length){var P=this._extractBetweenMarkers("{","}",this._sourceCode,y);if(P<0)this.debug&&console.warn("Could not extract the body of the function '"+s+"' (type="+a+"). funcBodyStartIndex="+y),t=e+this.inlineToken.length;else{for(var O=this._sourceCode.substring(y,P+1),U=this._removeComments(p).split(","),F=[],z=0;z<U.length;++z){var J=U[z].trim(),ie=J.lastIndexOf(" ");ie>=0&&F.push(J.substring(ie+1))}a!=="void"&&F.push("return"),this._functionDescr.push({name:s,type:a,parameters:F,body:O,callIndex:0}),t=P+1;var se=e>0?this._sourceCode.substring(0,e):"",ce=P+1<this._sourceCode.length-1?this._sourceCode.substring(P+1):"";this._sourceCode=se+ce,t-=P+1-e}}else this.debug&&console.warn("Could not extract the body of the function '"+s+"' (type="+a+"). funcParamsEndIndex="+d),t=e+this.inlineToken.length}}else this.debug&&console.warn("Could not extract the name/type of the function from: "+this._sourceCode.substring(e+this.inlineToken.length,n)),t=e+this.inlineToken.length}}this.debug&&console.log("Collect functions: "+this._functionDescr.length+" functions found. functionDescr=",this._functionDescr)},r.prototype._processInlining=function(t){for(t===void 0&&(t=20);t-->=0&&this._replaceFunctionCallsByCode(););return this.debug&&console.log("numMaxIterations is "+t+" after inlining process"),t>=0},r.prototype._extractBetweenMarkers=function(t,e,n,i){for(var o=i,a=0,s="";o<n.length;){var d=n.charAt(o);if(s)d===s?s==='"'||s==="'"?n.charAt(o-1)!=="\\"&&(s=""):s="":s==="*/"&&d==="*"&&o+1<n.length&&(n.charAt(o+1)==="/"&&(s=""),s===""&&o++);else switch(d){case t:a++;break;case e:a--;break;case'"':case"'":case"`":s=d;break;case"/":if(o+1<n.length){var p=n.charAt(o+1);p==="/"?s=`
1724`:p==="*"&&(s="*/")}}if(o++,a===0)break}return a===0?o-1:-1},r.prototype._skipWhitespaces=function(t,e){for(;e<t.length;){var n=t[e];if(n!==" "&&n!==`
1725`&&n!=="\r"&&n!=="	"&&n!==`
1726`&&n!==" ")break;e++}return e},r.prototype._removeComments=function(t){for(var e=0,n="",i=!1,o=[];e<t.length;){var a=t.charAt(e);if(n)a===n?n==='"'||n==="'"?(t.charAt(e-1)!=="\\"&&(n=""),o.push(a)):(n="",i=!1):n==="*/"&&a==="*"&&e+1<t.length?(t.charAt(e+1)==="/"&&(n=""),n===""&&(i=!1,e++)):i||o.push(a);else{switch(a){case'"':case"'":case"`":n=a;break;case"/":if(e+1<t.length){var s=t.charAt(e+1);s==="/"?(n=`
1727`,i=!0):s==="*"&&(n="*/",i=!0)}}i||o.push(a)}e++}return o.join("")},r.prototype._replaceFunctionCallsByCode=function(){for(var t=!1,e=0,n=this._functionDescr;e<n.length;e++)for(var i=n[e],o=i.name,a=i.type,s=i.parameters,d=i.body,p=0;p<this._sourceCode.length;){var y=this._sourceCode.indexOf(o,p);if(y<0)break;var P=this._skipWhitespaces(this._sourceCode,y+o.length);if(P!==this._sourceCode.length&&this._sourceCode.charAt(P)==="("){var O=this._extractBetweenMarkers("(",")",this._sourceCode,P);if(O<0)this.debug&&console.warn("Could not extract the parameters of the function call. Function '"+o+"' (type="+a+"). callParamsStartIndex="+P),p=y+o.length;else{for(var U=this._sourceCode.substring(P+1,O),F=this._removeComments(U).split(","),z=[],J=0;J<F.length;++J){var ie=F[J].trim();z.push(ie)}var se=a!=="void"?o+"_"+i.callIndex++:null;if(se&&z.push(se+" ="),z.length===s.length){p=O+1;var ce=this._replaceNames(d,s,z),ue=y>0?this._sourceCode.substring(0,y):"",fe=O+1<this._sourceCode.length-1?this._sourceCode.substring(O+1):"";if(se){var ve=this._findBackward(this._sourceCode,y-1,`
1728`);ue=this._sourceCode.substring(0,ve+1);var Te=this._sourceCode.substring(ve+1,y);this._sourceCode=ue+a+" "+se+`;
1729`+ce+`
1730`+Te+se+fe,this.debug&&console.log("Replace function call by code. Function '"+o+"' (type="+
1730a+"). injectDeclarationIndex="+ve)}else this._sourceCode=ue+ce+fe,p+=ce.length-(O+1-y),this.debug&&console.log("Replace function call by code. Function '"+o+"' (type="+a+"). functionCallIndex="+y);t=!0}else this.debug&&console.warn("Invalid function call: not the same number of parameters for the call than the number expected by the function. Function '"+o+"' (type="+a+"). function parameters="+s+", call parameters="+z),p=y+o.length}}else p=y+o.length}return t},r.prototype._findBackward=function(t,e,n){for(;e>=0&&t.charAt(e)!==n;)e--;return e},r.prototype._escapeRegExp=function(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")},r.prototype._replaceNames=function(t,e,n){for(var i=0;i<e.length;++i){var o=new RegExp(this._escapeRegExp(e[i]),"g"),a=n[i];t=t.replace(o,a)}return t},r._RegexpFindFunctionNameAndType=/((\s+?)(\w+)\s+(\w+)\s*?)$/,r}(),Rp=function(){function r(){this.isAsync=!1,this.isReady=!1}return r.prototype._getVertexShaderCode=function(){return null},r.prototype._getFragmentShaderCode=function(){return null},r.prototype._handlesSpectorRebuildCallback=function(t){throw new Error("Not implemented")},r}(),mu=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return Object(c.d)(t,r),t}(_u.a),gu=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return Object(c.d)(t,r),t.prototype.getInternalTexture=function(){return this},t.prototype.getViewCount=function(){return 1},t}(xt.a),Op=function(r){function t(){var e=r.call(this,null)||this;return e._native=new _native.Engine,e.INVALID_HANDLE=65535,e._boundBuffersVertexArray=null,e._currentDepthTest=e._native.DEPTH_TEST_LEQUAL,e._webGLVersion=2,e.disableUniformBuffers=!0,e._caps={maxTexturesImageUnits:16,maxVertexTextureImageUnits:16,maxCombinedTexturesImageUnits:32,maxTextureSize:512,maxCubemapTextureSize:512,maxRenderTextureSize:512,maxVertexAttribs:16,maxVaryingVectors:16,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,textureFloat:!1,textureFloatLinearFiltering:!1,textureFloatRender:!1,textureHalfFloat:!1,textureHalfFloatLinearFiltering:!1,textureHalfFloatRender:!1,textureLOD:!0,drawBuffersExtension:!1,depthTextureExtension:!1,vertexArrayObject:!0,instancedArrays:!1,canUseTimestampForTimerQuery:!1,blendMinMax:!1,maxMSAASamples:1},Ye.b.Log("Babylon Native (v"+Ue.a.Version+") launched"),Ye.b.LoadScript=function(n,i,o,a){Ye.b.LoadFile(n,function(s){Function(s).apply(null),i&&i()},void 0,void 0,!1,function(s,d){o&&o("LoadScript Error",d)})},typeof URL>"u"&&(window.URL={createObjectURL:function(){},revokeObjectURL:function(){}}),typeof Blob>"u"&&(window.Blob=function(){}),e._shaderProcessor=new pu.a,e}return Object(c.d)(t,r),t.prototype.getHardwareScalingLevel=function(){return 1},t.prototype.dispose=function(){r.prototype.dispose.call(this),this._boundBuffersVertexArray&&this._native.deleteVertexArray(this._boundBuffersVertexArray),this._native.dispose()},t.prototype._queueNewFrame=function(e,n){return n.requestAnimationFrame&&n!==window?n.requestAnimationFrame(e):this._native.requestAnimationFrame(e),0},t.prototype._bindUnboundFramebuffer=function(e){this._currentFramebuffer!==e&&(this._currentFramebuffer&&this._native.unbindFramebuffer(this._currentFramebuffer),e&&this._native.bindFramebuffer(e),this._currentFramebuffer=e)},t.prototype.getHostDocument=function(){return null},t.prototype.clear=function(e,n,i,o){o===void 0&&(o=!1);var a=0;n&&e&&(this._native.clearColor(e.r,e.g,e.b,e.a!==void 0?e.a:1),a|=this._native.CLEAR_FLAG_COLOR),i&&(this._native.clearDepth(1),a|=this._native.CLEAR_FLAG_DEPTH),o&&(this._native.clearStencil(0),a|=this._native.CLEAR_FLAG_STENCIL),this._native.clear(a)},t.prototype.createIndexBuffer=function(e,n){var i=this._normalizeIndexData(e),o=new mu;if(o.references=1,o.is32Bits=i.BYTES_PER_ELEMENT===4,i.length){if(o.nativeIndexBuffer=this._native.createIndexBuffer(i,n!=null&&n),o.nativeVertexBuffer===this.INVALID_HANDLE)throw new Error("Could not create a native index buffer.")}else o.nativeVertexBuffer=this.INVALID_HANDLE;return o},t.prototype.createVertexBuffer=function(e,n){var i=new mu;if(i.references=1,i.nativeVertexBuffer=this._native.createVertexBuffer(ArrayBuffer.isView(e)?e:new Float32Array(e),n!=null&&n),i.nativeVertexBuffer===this.INVALID_HANDLE)throw new Error("Could not create a native vertex buffer.");return i},t.prototype._recordVertexArrayObject=function(e,n,i,o){i&&this._native.re
1730cordIndexBuffer(e,i.nativeIndexBuffer);for(var a=o.getAttributesNames(),s=0;s<a.length;s++){var d=o.getAttributeLocation(s);if(d>=0){var p=n[a[s]];if(p){var y=p.getBuffer();y&&this._native.recordVertexBuffer(e,y.nativeVertexBuffer,d,p.byteOffset,p.byteStride,p.getSize(),this._getNativeAttribType(p.type),p.normalized)}}}},t.prototype.bindBuffers=function(e,n,i){this._boundBuffersVertexArray&&this._native.deleteVertexArray(this._boundBuffersVertexArray),this._boundBuffersVertexArray=this._native.createVertexArray(),this._recordVertexArrayObject(this._boundBuffersVertexArray,e,n,i),this._native.bindVertexArray(this._boundBuffersVertexArray)},t.prototype.recordVertexArrayObject=function(e,n,i){var o=this._native.createVertexArray();return this._recordVertexArrayObject(o,e,n,i),o},t.prototype.bindVertexArrayObject=function(e){this._native.bindVertexArray(e)},t.prototype.releaseVertexArrayObject=function(e){this._native.deleteVertexArray(e)},t.prototype.getAttributes=function(e,n){var i=e;return this._native.getAttributes(i.nativeProgram,n)},t.prototype.drawElementsType=function(e,n,i,o){this._drawCalls.addCount(1,!1),this._native.drawIndexed(e,n,i)},t.prototype.drawArraysType=function(e,n,i,o){this._drawCalls.addCount(1,!1),this._native.draw(e,n,i)},t.prototype.createPipelineContext=function(){return new Rp},t.prototype._preparePipelineContext=function(e,n,i,o,a,s,d){var p=e;p.nativeProgram=o?this.createRawShaderProgram(e,n,i,void 0,d):this.createShaderProgram(e,n,i,s,void 0,d)},t.prototype._isRenderingStateCompiled=function(e){return!0},t.prototype._executeWhenRenderingStateIsCompiled=function(e,n){
1730n()},t.prototype.createRawShaderProgram=function(e,n,i,o,a){throw new Error("Not Supported")},t.prototype.createShaderProgram=function(e,n,i,o,a,s){this.onBeforeShaderCompilationObservable.notifyObservers(this);var d=new Rs(n);d.processCode(),n=d.code;var p=new Rs(i);p.processCode(),i=p.code,n=Bt.a._ConcatenateShader(n,o),i=Bt.a._ConcatenateShader(i,o);var y=this._native.createProgram(n,i);return this.onAfterShaderCompilationObservable.notifyObservers(this),y},t.prototype._setProgram=function(e){this._currentProgram!==e&&(this._native.setProgram(e),this._currentProgram=e)},t.prototype._releaseEffect=function(e){},t.prototype._deletePipelineContext=function(e){},t.prototype.getUniforms=function(e,n){var i=e;return this._native.getUniforms(i.nativeProgram,n)},t.prototype.bindUniformBlock=function(e,n,i){throw new Error("Not Implemented")},t.prototype.bindSamplers=function(e){var n=e.getPipelineContext();this._setProgram(n.nativeProgram);for(var i=e.getSamplers(),o=0;o<i.length;o++){var a=e.getUniform(i[o]);a&&(this._boundUniforms[o]=a)}this._currentEffect=null}
1730,t.prototype.setMatrix=function(e,n){e&&this._native.setMatrix(e,n.toArray())},t.prototype.getRenderWidth=function(e){return e===void 0&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.width:this._native.getRenderWidth()},t.prototype.getRenderHeight=function(e){return e===void 0&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.height:this._native.getRenderHeight()},t.prototype.setViewport=function(e,n,i){this._cachedViewport=e,this._native.setViewPort(e.x,e.y,e.width,e.height)},t.prototype.setState=function(e,n,i,o){n===void 0&&(n=0),o===void 0&&(o=!1),this._native.setState(e,n,o)},t.prototype.setZOffset=function(e){this._native.setZOffset(e)},t.prototype.getZOffset=function(){return this._native.getZOffset()},t.prototype.setDepthBuffer=function(e){this._native.setDepthTest(e?this._currentDepthTest:this._native.DEPTH_TEST_ALWAYS)},t.prototype.getDepthWrite=function(){return this._native.getDepthWrite()},t.prototype.setDepthFunctionToGreater=function(){this._currentDepthTest=this._native.DEPTH_TEST_GREATER,this._native.setDepthTest(this._currentDepthTest)},t.prototype.setDepthFunctionToGreaterOrEqual=function(){this._currentDepthTest=this._native.DEPTH_TEST_GEQUAL,this._native.setDepthTest(this._currentDepthTest)},t.prototype.setDepthFunctionToLess=function(){this._currentDepthTest=this._native.DEPTH_TEST_LESS,this._native.setDepthTest(this._currentDepthTest)},t.prototype.setDepthFunctionToLessOrEqual=function(){this._currentDepthTest=this._native.DEPTH_TEST_LEQUAL,this._native.setDepthTest(this._currentDepthTest)},t.prototype.setDepthWrite=function(e){this._native.setDepthWrite(e)},t.prototype.setColorWrite=function(e){this._native.setColorWrite(e),this._colorWrite=e},t.prototype.getColorWrite=function(){return this._colorWrite},t.prototype.setAlphaConstants=function(e,n,i,o){throw new Error("Setting alpha blend constant color not yet implemented.")}
1730,t.prototype.setAlphaMode=function(e,n){n===void 0&&(n=!1),this._alphaMode!==e&&(e=this._getNativeAlphaMode(e),this._native.setBlendMode(e),n||this.setDepthWrite(e===h.a.ALPHA_DISABLE),this._alphaMode=e)},t.prototype.getAlphaMode=function(){return this._alphaMode},t.prototype.setInt=function(e,n){return!!e&&(this._native.setInt(e,n),!0)},t.prototype.setIntArray=function(e,n){return!!e&&(this._native.setIntArray(e,n),!0)},t.prototype.setIntArray2=function(e,n){return!!e&&(this._native.setIntArray2(e,n),!0)},t.prototype.setIntArray3=function(e,n){return!!e&&(this._native.setIntArray3(e,n),!0)},t.prototype.setIntArray4=function(e,n){return!!e&&(this._native.setIntArray4(e,n),!0)},t.prototype.setFloatArray=function(e,n){return!!e&&(this._native.setFloatArray(e,n),!0)},t.prototype.setFloatArray2=function(e,n){return!!e&&(this._native.setFloatArray2(e,n),!0)},t.prototype.setFloatArray3=function(e,n){return!!e&&(this._native.setFloatArray3(e,n),!0)},t.prototype.setFloatArray4=function(e,n){return!!e&&(this._native.setFloatArray4(e,n),!0)},t.prototype.setArray=function(e,n){return!!e&&(this._native.setFloatArray(e,n),!0)},t.prototype.setArray2=function(e,n){return!!e&&(this._native.setFloatArray2(e,n),!0)},t.prototype.setArray3=function(e,n){return!!e&&(this._native.setFloatArray3(e,n),!0)},t.prototype.setArray4=function(e,n){return!!e&&(this._native.setFloatArray4(e,n),!0)}
1730,t.prototype.setMatrices=function(e,n){return!!e&&(this._native.setMatrices(e,n),!0)},t.prototype.setMatrix3x3=function(e,n){return!!e&&(this._native.setMatrix3x3(e,n),!0)},t.prototype.setMatrix2x2=function(e,n){return!!e&&(this._native.setMatrix2x2(e,n),!0)},t.prototype.setFloat=function(e,n){return!!e&&(this._native.setFloat(e,n),!0)},t.prototype.setFloat2=function(e,n,i){return!!e&&(this._native.setFloat2(e,n,i),!0)},t.prototype.setFloat3=function(e,n,i,o){return!!e&&(this._native.setFloat3(e,n,i,o),!0)},t.prototype.setFloat4=function(e,n,i,o,a){return!!e&&(this._native.setFloat4(e,n,i,o,a),!0)},t.prototype.setColor3=function(e,n){return!!e&&(this._native.setFloat3(e,n.r,n.g,n.b),!0)},t.prototype.setColor4=function(e,n,i){return!!e&&(this._native.setFloat4(e,n.r,n.g,n.b,i),!0)},t.prototype.wipeCaches=function(e){this.preventCacheWipeBetweenFrames||(this.resetTextureCache(),this._currentEffect=null,e&&(this._currentProgram=null,this._stencilState.reset(),this._depthCullingState.reset(),this._alphaState.reset()),this._cachedVertexBuffers=null,this._cachedIndexBuffer=null,this._cachedEffectForVertexBuffers=null)},t.prototype._createTexture=function(){return this._native.createTexture()},t.prototype._deleteTexture=function(e){this._native.deleteTexture(e)},t.prototype.updateDynamicTexture=function(e,n,i,o,a){this.createTexture("data:my_image_name",!0,i,null,we.a.BILINEAR_SAMPLINGMODE,void 0,void 0,"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYSURBVChTY/z//z8DPsAEpXGC4aCAgQEAGGMDDWwwgqsAAAAASUVORK5CYII=",e,t.TEXTUREFORMAT_RGBA,null,void 0)},t.prototype.createTexture=function(e,n,i,o,a,s,d,p,y,P,O,U,F){var z=this;a===void 0&&(a=h.a.TEXTURE_TRILINEAR_SAMPLINGMODE),s===void 0&&(s=null),d===void 0&&(d=null),p===void 0&&(p=null),y===void 0&&(y=null),P===void 0&&(P=null),O===void 0&&(O=null);var J=(e=e||"").substr(0,5)==="data:",ie=J&&e.indexOf(";base64,")!==-1,se=y||new xt.a(this,xt.b.Url),ce=e;!this._transformTextureUrl||ie||y||p||(e=this._transformTextureUrl(e));for(var ue=e.lastIndexOf("."),fe=O||(ue>-1?e.substring(ue).toLowerCase():""),ve=null,Te=0,Oe=Ue.a._TextureLoaders;Te<Oe.length;Te++){var Pe=Oe[Te];if(Pe.canLoad(fe)){ve=Pe;break}}o&&o._addPendingData(se),se.url=e,se.generateMipMaps=!n,se.samplingMode=a,se.invertY=i,this.doNotHandleContextLost||(se._buffer=p);var Ee=null;if(s&&!y&&(Ee=se.onLoadedObservable.add(s)),y||this._internalTexturesCache.push(se),ve)throw new Error("Loading textures from IInternalTextureLoader not yet implemented.");var Se=function(Le){var xe=se._webGLTexture;xe?z._native.loadTexture(xe,Le,!n,i,function(){se.baseWidth=z._native.getTextureWidth(xe),se.baseHeight=z._native.getTextureHeight(xe),se.width=se.baseWidth,se.height=se.baseHeight,se.isReady=!0;var Ne=z._getNativeSamplingMode(a);z._native.setTextureSampling(xe,Ne),o&&o._removePendingData(se),se.onLoadedObservable.notifyObservers(se),se.onLoadedObservable.clear()},function(){throw new Error("Could not load a native texture.")}):o&&o._removePendingData(se)};if(J)if(p instanceof ArrayBuffer)Se(new Uint8Array(p));else if(ArrayBuffer.isView(p))Se(p);else{if(typeof p!="string")throw new Error("Unsupported buffer type");Se(new Uint8Array(Ye.b.DecodeBase64(p)))}else ie?Se(new Uint8Array(Ye.b.DecodeBase64(e))):this._loadFile(e,function(Le){return Se(new Uint8Array(Le))},void 0,void 0,!0,function(Le,xe){(function(Ne,Ie){o&&o._removePendingData(se),e===ce?(Ee&&se.onLoadedObservable.remove(Ee),te.a.UseFallbackTexture&&z.createTexture(te.a.FallbackTexture,n,se.invertY,o,a,null,d,p,se),d&&d((Ne||"Unknown error")+(te.a.UseFallbackTexture?" - Fallback texture was used":""),Ie)):(l.a.Warn("Failed to load "+e+", falling back to "+ce),z.createTexture(ce,n,se.invertY,o,a,s,d,p,se,P,O,U,F))})("Unable to load "+(Le&&Le.responseURL,xe))});return se},t.prototype._createDepthStencilTexture=function(e,n){var i=new gu(this,xt.b.Depth),o=e.width||e,a=e.height||e,s=this._native.createDepthTexture(i._webGLTexture,o,a);return i._framebuffer=s,i},t.prototype._releaseFramebufferObjects=function(e){},t.prototype.createCubeTexture=function(e,n,i,o,a,s,d,p,y,P,O,U){var F=this;a===void 0&&(a=null),s===void 0&&(s=null),p===void 0&&(p=null),P===void 0&&(P=0),O===void 0&&(O=0),U===void 0&&(U=null);var z=U||new xt.a(this,xt.b.Cube);z.isCube=!0,z.url=e,z.generateMipMaps=!o,z._lodGenerationScale=P,z._lodGenerationOffset=O,this._doNotHandleContextLost||(z._extension=p,z._files=i);var J=e.lastIndexOf(".");if((p||(J>
1730-1?e.substring(J).toLowerCase():""))===".env"){if(i&&i.length===6)throw new Error("Multi-file loading not allowed on env files.");this._loadFile(e,function(se){return function(ce){var ue=Si.GetEnvInfo(ce);if(z.width=ue.width,z.height=ue.width,Si.UploadEnvSpherical(z,ue),ue.version!==1)throw new Error('Unsupported babylon environment map version "'+ue.version+'"');var fe=ue.specular;if(!fe)throw new Error("Nothing else parsed so far");z._lodGenerationScale=fe.lodGenerationScale;var ve=Si.CreateImageDataArrayBufferViews(ce,ue);z.format=h.a.TEXTUREFORMAT_RGBA,z.type=h.a.TEXTURETYPE_UNSIGNED_INT,z.generateMipMaps=!0,z.getEngine().updateTextureSamplingMode(we.a.TRILINEAR_SAMPLINGMODE,z),z._isRGBD=!0,z.invertY=!0,F._native.loadCubeTextureWithMips(z._webGLTexture,ve,function(){z.isReady=!0,a&&a()},function(){throw new Error("Could not load a native cube texture.")})}(new Uint8Array(se))},void 0,void 0,!0,function(se,ce){s&&se&&s(se.status+" "+se.statusText,ce)})}else{if(!i||i.length!==6)throw new Error("Cannot load cubemap because 6 files were not defined");var ie=[i[0],i[3],i[1],i[4],i[2],i[5]];Promise.all(ie.map(function(se){return Ye.b.LoadFileAsync(se).then(function(ce){return new Uint8Array(ce)})})).then(function(se){return new Promise(function(ce,ue){F._native.loadCubeTexture(z._webGLTexture,se,!o,ce,ue)})}).then(function(){z.isReady=!0,a&&a()},function(se){s&&s("Failed to load cubemap: "+se.message,se)})}return this._internalTexturesCache.push(z),z},t.prototype.createRenderTargetTexture=function(e,n){var i=new kl.a;n!==void 0&&typeof n=="object"?(i.generateMipMaps=n.generateMipMaps,i.generateDepthBuffer=n.generateDepthBuffer===void 0||n.generateDepthBuffer,i.generateStencilBuffer=i.generateDepthBuffer&&n.generateStencilBuffer,i.type=n.type===void 0?h.a.TEXTURETYPE_UNSIGNED_INT:n.type,i.samplingMode=n.samplingMode===void 0?h.a.TEXTURE_TRILINEAR_SAMPLINGMODE:n.samplingMode,i.format=n.format===void 0?h.a.TEXTUREFORMAT_RGBA:n.format):(i.generateMipMaps=n,i.generateDepthBuffer=!0,i.generateStencilBuffer=!1,i.type=h.a.TEXTURETYPE_UNSIGNED_INT,i.samplingMode=h.a.TEXTURE_TRILINEAR_SAMPLINGMODE,i.format=h.a.TEXTUREFORMAT_RGBA),(i.type!==h.a.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(i.type!==h.a.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(i.samplingMode=h.a.TEXTURE_NEAREST_SAMPLINGMODE);var o=new gu(this,xt.b.RenderTarget),a=e.width||e,s=e.height||e;i.type!==h.a.TEXTURETYPE_FLOAT||this._caps.textureFloat||(i.type=h.a.TEXTURETYPE_UNSIGNED_INT,l.a.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type"));var d=this._native.createFramebuffer(o._webGLTexture,a,s,this._getNativeTextureFormat(i.format,i.type),i.samplingMode,!!i.generateStencilBuffer,i.generateDepthBuffer,!!i.generateMipMaps);return o._framebuffer=d,o.baseWidth=a,o.baseHeight=s,o.width=a,o.height=s,o.isReady=!0,o.samples=1,o.generateMipMaps=!!i.generateMipMaps,o.samplingMode=i.samplingMode,o.type=i.type,o.format=i.format,o._generateDepthBuffer=i.generateDepthBuffer,o._generateStencilBuffer=!!i.generateStencilBuffer,this._internalTexturesCache.push(o),o},t.prototype.updateTextureSamplingMode=function(e,n){if(n._webGLTexture){var i=this._getNativeSamplingMode(e);this._native.setTextureSampling(n._webGLTexture,i)}n.samplingMode=e},t.prototype.bindFramebuffer=function(e,n,i,o,a){if(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.");e._depthStencilTexture?this._bindUnboundFramebuffer(e._depthStencilTexture._framebuffer):this._bindUnboundFramebuffer(e._framebuffer)},t.prototype.unBindFramebuffer=function(e,n,i){n===void 0&&(n=!1),n&&l.a.Warn("Disabling mipmap generation not yet supported in NativeEngine. Ignoring."),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._native.updateDynamicIndexBuffer(o.nativeIndexBuffer,a,i)},t.prototype.updateDynamicVertexBuffer=function(e,n,i,o){var a=e,s=ArrayBuffer.isView(n)?n:new Float32Array(n);this._native.updateDynamicVertexBuffer(a.nativeVertexBuffer,s,i??0,o??s.byteLength)},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._native.setTexture(s,null)),!1;if(n.video)this._activeChannel=e,n.update();else if(n.delayLoadState===h.a.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._webGLTexture)&&(this._native.setTextureWrapMode(a._webGLTexture,this._getAddressMode(n.wrapU),this._getAddressMode(n.wrapV),this._getAddressMode(n.wrapR)),this._updateAnisotropicLevel(n),this._native.setTexture(s,a._webGLTexture),!0)},t.prototype._updateAnisotropicLevel=function(e){var n=e.getInternalTexture(),i=e.anisotropicFilteringLevel;n&&n._webGLTexture&&n._cachedAnisotropicFilteringLevel!==i&&(this._native.setTextureAnisotropicLevel(n._webGLTexture,i),n._cachedAnisotropicFilteringLevel=i)},t.prototype._getAddressMode=function(e){switch(e){case h.a.TEXTURE_WRAP_ADDRESSMODE:return this._native.ADDRESS_MODE_WRAP;case h.a.TEXTURE_CLAMP_ADDRESSMODE:return this._native.ADDRESS_MODE_CLAMP;case h.a.TEXTURE_MIRROR_ADDRESSMODE:return this._native.ADDRESS_MODE_MIRROR;default:throw new Error("Unexpected wrap mode: "+e+".")}},t.prototype._bindTexture=function(e,n){var i=this._boundUniforms[e];i&&this._native.setTexture(i,n._webGLTexture)},t.prototype._deleteBuffer=function(e){e.nativeIndexBuffer&&(this._native.deleteIndexBuffer(e.nativeIndexBuffer),delete e.nativeIndexBuffer),e.nativeVertexBuffer&&(this._native.deleteVertexBuffer(e.nativeVertexBuffer),delete e.nativeVertexBuffer)},t.prototype.releaseEffects=function(){},t.prototype._uploadCompressedDataToTextureDirectly=function(e,n,i,o,a,s,d){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._getNativeSamplingMode=function(e){switch(e){case h.a.TEXTURE_NEAREST_NEAREST:return this._native.TEXTURE_NEAREST_NEAREST;case h.a.TEXTURE_LINEAR_LINEAR:return this._native.TEXTURE_LINEAR_LINEAR;case h.a.TEXTURE_LINEAR_LINEAR_MIPLINEAR:return this._native.TEXTURE_LINEAR_LINEAR_MIPLINEAR;case h.a.TEXTURE_NEAREST_NEAREST_MIPNEAREST:return this._native.TEXTURE_NEAREST_NEAREST_MIPNEAREST;case h.a.TEXTURE_NEAREST_LINEAR_MIPNEAREST:return this._native.TEXTURE_NEAREST_LINEAR_MIPNEAREST;case h.a.TEXTURE_NEAREST_LINEAR_MIPLINEAR:return this._native.TEXTURE_NEAREST_LINEAR_MIPLINEAR;case h.a.TEXTURE_NEAREST_LINEAR:return this._native.TEXTURE_NEAREST_LINEAR;case h.a.TEXTURE_NEAREST_NEAREST_MIPLINEAR:return this._native.TEXTURE_NEAREST_NEAREST_MIPLINEAR;case h.a.TEXTURE_LINEAR_NEAREST_MIPNEAREST:return this._native.TEXTURE_LINEAR_NEAREST_MIPNEAREST;case h.a.TEXTURE_LINEAR_NEAREST_MIPLINEAR:return this._native.TEXTURE_LINEAR_NEAREST_MIPLINEAR;case h.a.TEXTURE_LINEAR_LINEAR_MIPNEAREST:return this._native.TEXTURE_LINEAR_LINEAR_MIPNEAREST;case h.a.TEXTURE_LINEAR_NEAREST:return this._native.TEXTURE_LINEAR_NEAREST;default:throw new Error("Unsupported sampling mode: "+e+".")}},t.prototype._getNativeTextureFormat=function(e,n){if(e==h.a.TEXTUREFORMAT_RGBA&&n==h.a.TEXTURETYPE_UNSIGNED_INT)return this._native.TEXTURE_FORMAT_RGBA8;if(e==h.a.TEXTUREFORMAT_RGBA&&n==h.a.TEXTURETYPE_FLOAT)return this._native.TEXTURE_FORMAT_RGBA32F;throw new Error("Unsupported texture format or type: format "+e+", type "+n+".")},t.prototype._getNativeAlphaMode=function(e){switch(e){case h.a.ALPHA_DISABLE:return this._native.ALPHA_DISABLE;case h.a.ALPHA_ADD:return this._native.ALPHA_ADD;case h.a.ALPHA_COMBINE:return this._native.ALPHA_COMBINE;case h.a.ALPHA_SUBTRACT:return this._native.ALPHA_SUBTRACT;case h.a.ALPHA_MULTIPLY:return this._native.ALPHA_MULTIPLY;case h.a.ALPHA_MAXIMIZED:return this._native.ALPHA_MAXIMIZED;case h.a.ALPHA_ONEONE:return this._native.ALPHA_ONEONE;case h.a.ALPHA_PREMULTIPLIED:return this._native.ALPHA_PREMULTIPLIED;case h.a.ALPHA_PREMULTIPLIED_PORTERDUFF:return this._native.ALPHA_PREMULTIPLIED_PORTERDUFF;case h.a.ALPHA_INTERPOLATE:return this._native.ALPHA_INTERPOLATE;case h.a.ALPHA_SCREENMODE:return this._native.ALPHA_SCREENMODE;default:throw new Error("Unsupported alpha mode: "+e+".")}},t.prototype._getNativeAttribType=function(e){switch(e){case Me.b.UNSIGNED_BYTE:return this._native.ATTRIB_TYPE_UINT8;case Me.b.SHORT:return this._native.ATTRIB_TYPE_INT16;case Me.b.FLOAT:return this._native.ATTRIB_TYPE_FLOAT;default:throw new Error("Unsupported attribute type: "+e+".")}},t}(Ue.a),Mp=f(74),Yo=function(){function r(){}return r.COPY=1,r.CUT=2,r.PASTE=3,r}(),Ip=function(){function r(t,e){this.type=t,this.event=e}return r.GetTypeFromCharacter=function(t){switch(t){case 67:return Yo.COPY;case 86:return Yo.PASTE;case 88:return Yo.CUT;default:return-1}},r}(),Os=f(83),Pi=f(69);(function(r){r[r.Clean=0]="Clean",r[r.Stop=1]="Stop",r[r.Sync=2]="Sync",r[r.NoSync=3]="NoSync"})(Ai||(Ai={}));var Ut=function(){function r(){}return Object.defineProperty(r,"ForceFullSceneLoadingForIncremental",{get:function(){return Pi.a.ForceFullSceneLoadingForIncremental},set:function(t){Pi.a.ForceFullSceneLoadingForIncremental=t}
1730,enumerable:!1,configurable:!0}),Object.defineProperty(r,"ShowLoadingScreen",{get:function(){return Pi.a.ShowLoadingScreen},set:function(t){Pi.a.ShowLoadingScreen=t},enumerable:!1,configurable:!0}),Object.defineProperty(r,"loggingLevel",{get:function(){return Pi.a.loggingLevel},set:function(t){Pi.a.loggingLevel=t},enumerable:!1,configurable:!0}),Object.defineProperty(r,"CleanBoneMatrixWeights",{get:function(){return Pi.a.CleanBoneMatrixWeights},set:function(t){Pi.a.CleanBoneMatrixWeights=t},enumerable:!1,configurable:!0}),r.GetDefaultPlugin=function(){return r._registeredPlugins[".babylon"]},r._GetPluginForExtension=function(t){var e=r._registeredPlugins[t];return e||(l.a.Warn("Unable to find a plugin to load "+t+" files. Trying to use .babylon default plugin. To load from a specific filetype (eg. gltf) see: https://doc.babylonjs.com/how_to/load_from_any_file_type"),r.GetDefaultPlugin())},r._GetPluginForDirectLoad=function(t){for(var e in r._registeredPlugins){var n=r._registeredPlugins[e].plugin;if(n.canDirectLoad&&n.canDirectLoad(t))return r._registeredPlugins[e]}return r.GetDefaultPlugin()},r._GetPluginForFilename=function(t){var e=t.indexOf("?");
1730e!==-1&&(t=t.substring(0,e));var n=t.lastIndexOf("."),i=t.substring(n,t.length).toLowerCase();return r._GetPluginForExtension(i)},r._GetDirectLoad=function(t){return t.substr(0,5)==="data:"?t.substr(5):null},r._LoadData=function(t,e,n,i,o,a,s){var d,p=r._GetDirectLoad(t.name),y=s?r._GetPluginForExtension(s):p?r._GetPluginForDirectLoad(t.name):r._GetPluginForFilename(t.name);if(!(d=y.plugin.createPlugin!==void 0?y.plugin.createPlugin():y.plugin))throw"The loader plugin corresponding to the file type you are trying to load has not been found. If using es6, please import the plugin you wish to use before.";if(r.OnPluginActivatedObservable.notifyObservers(d),p){if(d.directLoad){var P=d.directLoad(e,p);P.then?P.then(function(Pe){n(d,Pe)}).catch(function(Pe){o("Error in directLoad of _loadData: "+Pe,Pe)}):n(d,P)}else n(d,p);return d}var O=y.isBinary,U=function(Pe,Ee){e.isDisposed?o("Scene has been disposed"):n(d,Pe,Ee)},F=null,z=!1,J=d.onDisposeObservable;J&&J.add(function(){z=!0,F&&(F.abort(),F=null),a()});var ie=function(){if(!z){var Pe=function(Se,Le){U(Se,Le?Le.responseURL:void 0)},Ee=function(Se){o(Se.message,Se)};F=d.requestFile?d.requestFile(e,t.url,Pe,i,O,Ee):e._requestFile(t.url,Pe,i,!0,O,Ee)}},se=t.file||Os.a.FilesToLoad[t.name.toLowerCase()];if(t.rootUrl.indexOf("file:")===-1||t.rootUrl.indexOf("file:")!==-1&&!se){var ce=e.getEngine(),ue=ce.enableOfflineSupport;if(ue){for(var fe=!1,ve=0,Te=e.disableOfflineSupportExceptionRules;ve<Te.length;ve++)if(Te[ve].test(t.url)){fe=!0;break}ue=!fe}ue&&Ue.a.OfflineProviderFactory?e.offlineProvider=Ue.a.OfflineProviderFactory(t.url,ie,ce.disableManifestCheck):ie()}else if(se){var Oe=function(Pe){o(Pe.message,Pe)};F=d.readFile?d.readFile(e,se,U,i,O,Oe):e._readFile(se,U,i,O,Oe)}else o("Unable to find file named "+t.name);return d},r._GetFileInfo=function(t,e){var n,i,o=null;if(e)if(e.name){var a=e;n=t+a.name,i=a.name,o=a}else{var s=e;if(s.substr(0,1)==="/")return Ye.b.Error("Wrong sceneFilename parameter"),null;n=t+s,i=s}else n=t,i=Ye.b.GetFilename(t),t=Ye.b.GetFolderPath(t);return{url:n,rootUrl:t,name:i,file:o}},r.GetPluginForExtension=function(t){return r._GetPluginForExtension(t).plugin},r.IsPluginForExtensionAvailable=function(t){return!!r._registeredPlugins[t]},r.RegisterPlugin=function(t){if(typeof t.extensions=="string"){var e=t.extensions;r._registeredPlugins[e.toLowerCase()]={plugin:t,isBinary:!1}}else{var n=t.extensions;Object.keys(n).forEach(function(i){r._registeredPlugins[i.toLowerCase()]={plugin:t,isBinary:n[i].isBinary}})}},r.ImportMesh=function(t,e,n,i,o,a,s,d){if(n===void 0&&(n=""),i===void 0&&(i=te.a.LastCreatedScene),o===void 0&&(o=null),a===void 0&&(a=null),s===void 0&&(s=null),d===void 0&&(d=null),!i)return l.a.Error("No scene available to import mesh to"),null;var p=r._GetFileInfo(e,n);if(!p)return null;var y={};i._addPendingData(y);var P=function(){i._removePendingData(y)},O=function(z,J){var ie="Unable to import meshes from "+p.url+": "+z;s?s(i,ie,J):l.a.Error(ie),P()},U=a?function(z){try{a(z)}catch(J){O("Error in onProgress callback: "+J,J)}}:void 0,F=function(z,J,ie,se,ce,ue,fe){if(i.importedMeshesFiles.push(p.url),o)try{o(z,J,ie,se,ce,ue,fe)}catch(ve){O("Error in onSuccess callback: "+ve,ve)}i._removePendingData(y)};return r._LoadData(p,i,function(z,J,ie){if(z.rewriteRootURL&&(p.rootUrl=z.rewriteRootURL(p.rootUrl,ie)),z.importMesh){var se=z,ce=new Array,ue=new Array,fe=new Array;if(!se.importMesh(t,i,J,p.rootUrl,ce,ue,fe,O))return;i.loadingPluginName=z.name,F(ce,ue,fe,[],[],[],[])}else z.importMeshAsync(t,i,J,p.rootUrl,U,p.name).then(function(ve){i.loadingPluginName=z.name,F(ve.meshes,ve.particleSystems,ve.skeletons,ve.animationGroups,ve.transformNodes,ve.geometries,ve.lights)}).catch(function(ve){O(ve.message,ve)})},U,O,P,d)},r.ImportMeshAsync=function(t,e,n,i,o,a){return n===void 0&&(n=""),i===void 0&&(i=te.a.LastCreatedScene),o===void 0&&(o=null),a===void 0&&(a=null),new Promise(function(s,d){r.ImportMesh(t,e,n,i,function(p,y,P,O,U,F,z){s({meshes:p,particleSystems:y,skeletons:P,animationGroups:O,transformNodes:U,geometries:F,lights:z})},o,function(p,y,P){d(P||new Error(y))},a)})},r.Load=function(t,e,n,i,o,a,s){return e===void 0&&(e=""),n===void 0&&(n=te.a.LastCreatedEngine),i===void 0&&(i=null),o===void 0&&(o=null),a===void 0&&(a=null),s===void 0&&(s=null),n?r.Append(t,e,new _e.a(n),i,o,a,s):(Ye.b.Error("No engine available"),null)},r.LoadAsync=function(t,e,n,i,o){return e===void 0&&(e=""),n===void 0&&(n=te.a.LastCreatedEngine),i===void 0&&(i=null),o===void 0&&(o=null),new Promise(function(a,s){r.Load(t,e,n,function(d){a(d)},i,function(d,p,y){s(y||new Error(p))},o)})},r.Append=function(t,e,n,i,o,a,s){var d=this;if(e===void 0&&(e=""),n===void 0&&(n=te.a.LastCreatedScene),i===void 0&&(i=null),o===void 0&&(o=null),a===void 0&&(a=null),s===void 0&&(s=null),!n)return l.a.Error("No scene available to append to"),null;var p=r._GetFileInfo(t,e);if(!p)return null;r.ShowLoadingScreen&&!this._showingLoadingScreen&&(this._showingLoadingScreen=!0,n.getEngine().displayLoadingUI(),n.executeWhenReady(function(){n.getEngine().hideLoadingUI(),d._showingLoadingScreen=!1}));var y={};n._addPendingData(y);var P=function(){n._removePendingData(y)},O=function(z,J){var ie="Unable to load from "+p.url+(z?": "+z:"");a?a(n,ie,J):l.a.Error(ie),P()},U=o?function(z){try{o(z)}catch(J){O("Error in onProgress callback",J)}}:void 0,F=function(){if(i)try{i(n)}catch(z){O("Error in onSuccess callback",z)}n._removePendingData(y)};return r._LoadData(p,n,function(z,J){if(z.load){if(!z.load(n,J,p.rootUrl,O))return;n.loadingPluginName=z.name,F()}else z.loadAsync(n,J,p.rootUrl,U,p.name).then(function(){n.loadingPluginName=z.name,F()}).catch(function(ie){O(ie.message,ie)})},U,O,P,s)},r.AppendAsync=function(t,e,n,i,o){return e===void 0&&(e=""),n===void 0&&(n=te.a.LastCreatedScene),i===void 0&&(i=null),o===void 0&&(o=null),new Promise(function(a,s){r.Append(t,e,n,function(d){a(d)},i,function(d,p,y){s(y||new Error(p))},o)})}
1730,r.LoadAssetContainer=function(t,e,n,i,o,a,s){if(e===void 0&&(e=""),n===void 0&&(n=te.a.LastCreatedScene),i===void 0&&(i=null),o===void 0&&(o=null),a===void 0&&(a=null),s===void 0&&(s=null),!n)return l.a.Error("No scene available to load asset container to"),null;var d=r._GetFileInfo(t,e);if(!d)return null;var p={};n._addPendingData(p);var y=function(){n._removePendingData(p)},P=function(F,z){var J="Unable to load assets from "+d.url+(F?": "+F:"");z&&z.message&&(J+=" ("+z.message+")"),a?a(n,J,z):l.a.Error(J),y()},O=o?function(F){try{o(F)}catch(z){P("Error in onProgress callback",z)}}:void 0,U=function(F){if(i)try{i(F)}catch(z){P("Error in onSuccess callback",z)}n._removePendingData(p)};return r._LoadData(d,n,function(F,z){if(F.loadAssetContainer){var J=F.loadAssetContainer(n,z,d.rootUrl,P);if(!J)return;n.loadingPluginName=F.name,U(J)}else F.loadAssetContainerAsync?F.loadAssetContainerAsync(n,z,d.rootUrl,O,d.name).then(function(ie){n.loadingPluginName=F.name,U(ie)}).catch(function(ie){P(ie.message,ie)}):P("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.")},O,P,y,s)},r.LoadAssetContainerAsync=function(t,e,n,i,o){return e===void 0&&(e=""),n===void 0&&(n=te.a.LastCreatedScene),i===void 0&&(i=null),o===void 0&&(o=null),new Promise(function(a,s){r.LoadAssetContainer(t,e,n,function(d){a(d)},i,function(d,p,y){s(y||new Error(p))},o)})},r.ImportAnimations=function(t,e,n,i,o,a,s,d,p,y){if(e===void 0&&(e=""),n===void 0&&(n=te.a.LastCreatedScene),i===void 0&&(i=!0),o===void 0&&(o=Ai.Clean),a===void 0&&(a=null),s===void 0&&(s=null),d===void 0&&(d=null),p===void 0&&(p=null),y===void 0&&(y=null),n){if(i){for(var P=0,O=n.animatables;P<O.length;P++)O[P].reset();n.stopAllAnimations(),n.animationGroups.slice().forEach(function(F){F.dispose()}),n.getNodes().forEach(function(F){F.animations&&(F.animations=[])})}else switch(o){case Ai.Clean:n.animationGroups.slice().forEach(function(F){F.dispose()});break;case Ai.Stop:n.animationGroups.forEach(function(F){F.stop()});break;case Ai.Sync:n.animationGroups.forEach(function(F){F.reset(),F.restart()});break;case Ai.NoSync:break;default:return void l.a.Error("Unknown animation group loading mode value '"+o+"'")}var U=n.animatables.length;this.LoadAssetContainer(t,e,n,function(F){F.mergeAnimationsTo(n,n.animatables.slice(U),a),F.dispose(),n.onAnimationFileImportedObservable.notifyObservers(n),s&&s(n)},d,p,y)}else l.a.Error("No scene available to load animations to")},r.ImportAnimationsAsync=function(t,e,n,i,o,a,s,d,p,y){return e===void 0&&(e=""),n===void 0&&(n=te.a.LastCreatedScene),i===void 0&&(i=!0),o===void 0&&(o=Ai.Clean),a===void 0&&(a=null),d===void 0&&(d=null),y===void 0&&(y=null),new Promise(function(P,O){r.ImportAnimations(t,e,n,i,o,a,function(U){P(U)},d,function(U,F,z){O(z||new Error(F))},y)})},r.NO_LOGGING=h.a.SCENELOADER_NO_LOGGING,r.MINIMAL_LOGGING=h.a.SCENELOADER_MINIMAL_LOGGING,r.SUMMARY_LOGGING=h.a.SCENELOADER_SUMMARY_LOGGING,r.DETAILED_LOGGING=h.a.SCENELOADER_DETAILED_LOGGING,r.OnPluginActivatedObservable=new x.c,r._registeredPlugins={},r._showingLoadingScreen=!1,r}(),Ms=function(r){function t(e){var n=r.call(this,e)||this;return n.controllerType=ei.DAYDREAM,n}return Object(c.d)(t,r),t.prototype.initControllerMesh=function(e,n){var i=this;Ut.ImportMesh("",t.MODEL_BASE_URL,t.MODEL_FILENAME,e,function(o){i._defaultModel=o[1],i.attachToMesh(i._defaultModel),n&&n(i._defaultModel)})},t.prototype._handleButtonChange=function(e,n,i){if(e===0){var o=this.onTriggerStateChangedObservable;o&&o.notifyObservers(n)}else l.a.Warn("Unrecognized Daydream button index: "+e)},t.MODEL_BASE_URL="https://controllers.babylonjs.com/generic/",t.MODEL_FILENAME="generic.babylon",t.GAMEPAD_ID_PREFIX="Daydream",t}(Ni);Di._ControllerFactories.push({canCreate:function(r){return r.id.indexOf(Ms.GAMEPAD_ID_PREFIX)===0},create:function(r){return new Ms(r)}});var Is=function(r){function t(e){var n=r.call(this,e)||this;return n._buttonIndexToObservableNameMap=["onPadStateChangedObservable","onTriggerStateChangedObservable"],n.controllerType=ei.GEAR_VR,n._calculatedPosition=new u.e(n.hand=="left"?-.15:.15,-.5,.25),n._disableTrackPosition(n._calculatedPosition),n}return Object(c.d)(t,r),t.prototype.initControllerMesh=function(e,n){var i=this;Ut.ImportMesh("",t.MODEL_BASE_URL,t.MODEL_FILENAME,e,function(o){var a=new De.a("",e);o[1].parent=a,o[1].position.z=-.15,i._defaultModel=a,i.attachToMesh(i._defaultModel),n&&n(i._defaultModel)})},t.prototype._handleButtonChange=function(e,n,i){if(e<this._buttonIndexToObservableNameMap.length){var o=this[this._buttonIndexToObservableNameMap[e]];o&&o.notifyObservers(n)}},t.MODEL_BASE_URL="https://controllers.babylonjs.com/generic/",t.MODEL_FILENAME="generic.babylon",t.GAMEPAD_ID_PREFIX="Gear VR",t}(Ni);Di._ControllerFactories.push({canCreate:function(r){return r.id.indexOf(Is.GAMEPAD_ID_PREFIX)===0||r.id.indexOf("Oculus Go")!==-1||r.id.indexOf("Vive Focus")!==-1},create:function(r){return new Is(r)}});var Ko=function(r){function t(e){return r.call(this,e)||this}return Object(c.d)(t,r),t.prototype.initControllerMesh=function(e,n){var i=this;Ut.ImportMesh("",t.MODEL_BASE_URL,t.MODEL_FILENAME,e,function(o){i._defaultModel=o[1],i.attachToMesh(i._defaultModel),n&&n(i._defaultModel)})},t.prototype._handleButtonChange=function(e,n,i){console.log("Button i
1730d: "+e+"state: "),console.dir(n)},t.MODEL_BASE_URL="https://controllers.babylonjs.com/generic/",t.MODEL_FILENAME="generic.babylon",t}(Ni);Di._DefaultControllerFactory=function(r){return new Ko(r)};var Ds=function(r){function t(e){var n=r.call(this,e)||this;return n.onSecondaryTriggerStateChangedObservable=new x.c,n.onThumbRestChangedObservable=new x.c,n.controllerType=ei.OCULUS,n}return Object(c.d)(t,r),t.prototype.initControllerMesh=function(e,n){var i,o=this;i=this.hand==="left"?t.MODEL_LEFT_FILENAME:t.MODEL_RIGHT_FILENAME,Ut.ImportMesh("",t._IsQuest?t.QUEST_MODEL_BASE_URL:t.MODEL_BASE_URL,i,e,function(a){o._defaultModel=t._IsQuest?a[0]:a[1],o.attachToMesh(o._defaultModel),n&&n(o._defaultModel)})},Object.defineProperty(t.prototype,"onAButtonStateChangedObservable",{get:function(){if(this.hand==="right")return this.onMainButtonStateChangedObservable;throw new Error("No A button on left hand")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onBButtonStateChangedObservable",{get:function(){if(this.hand==="right")return this.onSecondaryButtonStateChangedObservable;throw new Error("No B button on left hand")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onXButtonStateChangedObservable",{get:function(){if(this.hand==="left")return this.onMainButtonStateChangedObservable;throw new Error("No X button on right hand")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onYButtonStateChangedObservable",{get:function(){if(this.hand==="left")return this.onSecondaryButtonStateChangedObservable;throw new Error("No Y button on right hand")},enumerable:!1,configurable:!0}),t.prototype._handleButtonChange=function(e,n,i){var o=n,a=this.hand==="right"?-1:1;switch(e){case 0:return void this.onPadStateChangedObservable.notifyObservers(o);case 1:return!t._IsQuest&&this._defaultModel&&(this._defaultModel.getChildren()[3].rotation.x=.2*-o.value,this._defaultModel.getChildren()[3].position.y=.005*-o.value,this._defaultModel.getChildren()[3].position.z=.005*-o.value),void this.onTriggerStateChangedObservable.notifyObservers(o);case 2:return!t._IsQuest&&this._defaultModel&&(this._defaultModel.getChildren()[4].position.x=a*o.value*.0035),void this.onSecondaryTriggerStateChangedObservable.notifyObservers(o);case 3:return!t._IsQuest&&this._defaultModel&&(o.pressed?this._defaultModel.getChildren()[1].position.y=-.001:this._defaultModel.getChildren()[1].position.y=0),void this.onMainButtonStateChangedObservable.notifyObservers(o);case 4:return!t._IsQuest&&this._defaultModel&&(o.pressed?this._defaultModel.getChildren()[2].position.y=-.001:this._defaultModel.getChildren()[2].position.y=0),void this.onSecondaryButtonStateChangedObservable.notifyObservers(o);case 5:return void this.onThumbRestChangedObservable.notifyObservers(o)}},t.MODEL_BASE_URL="https://controllers.babylonjs.com/oculus/",t.MODEL_LEFT_FILENAME="left.babylon",t.MODEL_RIGHT_FILENAME="right.babylon",t.QUEST_MODEL_BASE_URL="https://controllers.babylonjs.com/oculusQuest/",t._IsQuest=!1,t}(Ni);Di._ControllerFactories.push({canCreate:function(r){return Ue.a.LastCreatedEngine&&Ue.a.LastCreatedEngine._vrDisplay&&Ue.a.LastCreatedEngine._vrDisplay.displayName==="Oculus Quest"&&(Ds._IsQuest=!0),r.id.indexOf("Oculus Touch")!==-1},create:function(r){return new Ds(r)}});var vu=function(r){function t(e){var n=r.call(this,e)||this;return n.controllerType=ei.VIVE,n._invertLeftStickY=!0,n}return Object(c.d)(t,r),t.prototype.initControllerMesh=function(e,n){var i=this;Ut.ImportMesh("",t.MODEL_BASE_URL,t.MODEL_FILENAME,e,function(o){i._defaultModel=o[1],i.attachToMesh(i._defaultModel),n&&n(i._defaultModel)})},Object.defineProperty(t.prototype,"onLeftButtonStateChangedObservable",{get:function(){return this.onMainButtonStateChangedObservable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onRightButtonStateChangedObservable",{get:function(){return this.onMainButtonStateChangedObservable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onMenuButtonStateChangedObservable",{get:function(){return this.onSecondaryButtonStateChangedObservable}
1730,enumerable:!1,configurable:!0}),t.prototype._handleButtonChange=function(e,n,i){var o=n;switch(e){case 0:return void this.onPadStateChangedObservable.notifyObservers(o);case 1:return this._defaultModel&&(this._defaultModel.getChildren()[6].rotation.x=.15*-o.value),void this.onTriggerStateChangedObservable.notifyObservers(o);case 2:return void this.onMainButtonStateChangedObservable.notifyObservers(o);case 3:return this._defaultModel&&(o.pressed?this._defaultModel.getChildren()[2].position.y=-.001:this._defaultModel.getChildren()[2].position.y=0),void this.onSecondaryButtonStateChangedObservable.notifyObservers(o)}},t.MODEL_BASE_URL="https://controllers.babylonjs.com/vive/",t.MODEL_FILENAME="wand.babylon",t}(Ni);Di._ControllerFactories.push({canCreate:function(r){return r.id.toLowerCase().indexOf("openvr")!==-1},create:function(r){return new vu(r)}});var Dp=function(){this.buttonMeshes={},this.axisMeshes={}},Qo=function(r){function t(e){var n=r.call(this,e)||this;return n._mapping={buttons:["thumbstick","trigger","grip","menu","trackpad"],buttonMeshNames:{trigger:"SELECT",menu:"MENU",grip:"GRASP",thumbstick:"THUMBSTICK_PRESS",trackpad:"TOUCHPAD_PRESS"},buttonObservableNames:{trigger:"onTriggerStateChangedObservable",menu:"onSecondaryButtonStateChangedObservable",grip:"onMainButtonStateChangedObservable",thumbstick:"onPadStateChangedObservable",trackpad:"onTrackpadChangedObservable"},axisMeshNames:["THUMBSTICK_X","THUMBSTICK_Y","TOUCHPAD_TOUCH_X","TOUCHPAD_TOUCH_Y"],pointingPoseMeshName:fr.POINTING_POSE},n.onTrackpadChangedObservable=new x.c,n.onTrackpadValuesChangedObservable=new x.c,n.trackpad={x:0,y:0},n.controllerType=ei.WINDOWS,n._loadedMeshInfo=null,n}return Object(c.d)(t,r),Object.defineProperty(t.prototype,"onTriggerButtonStateChangedObservable",{get:function(){return this.onTriggerStateChangedObservable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onMenuButtonStateChangedObservable",{get:function(){return this.onSecondaryButtonStateChangedObservable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onGripButtonStateChangedObservable",{get:function(){return this.onMainButtonStateChangedObservable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onThumbstickButtonStateChangedObservable",{get:function(){return this.onPadStateChangedObservable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onTouchpadButtonStateChangedObservable",{get:function(){return this.onTrackpadChangedObservable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onTouchpadValuesChangedObservable",{get:function(){return this.onTrackpadValuesChangedObservable},enumerable:!1,configurable:!0}),t.prototype._updateTrackpad=function(){!this.browserGamepad.axes||this.browserGamepad.axes[2]==this.trackpad.x&&this.browserGamepad.axes[3]==this.trackpad.y||(this.trackpad.x=this.browserGamepad.axes[this._mapping.axisMeshNames.indexOf("TOUCHPAD_TOUCH_X")],this.trackpad.y=this.browserGamepad.axes[this._mapping.axisMeshNames.indexOf("TOUCHPAD_TOUCH_Y")],this.onTrackpadValuesChangedObservable.notifyObservers(this.trackpad))},t.prototype.update=function(){if(r.prototype.update.call(this),this.browserGamepad.axes&&(this._updateTrackpad(),this._loadedMeshInfo))for(var e=0;e<this._mapping.axisMeshNames.length;e++)this._lerpAxisTransform(e,this.browserGamepad.axes[e])},t.prototype._handleButtonChange=function(e,n,i){var o=this._mapping.buttons[e];if(o){this._updateTrackpad();var a=this[this._mapping.buttonObservableNames[o]];a&&a.notifyObservers(n),this._lerpButtonTransform(o,n.value)}},t.prototype._lerpButtonTransform=function(e,n){if(this._loadedMeshInfo){var i=this._loadedMeshInfo.buttonMeshes[e];i&&i.unpressed.rotationQuaternion&&i.pressed.rotationQuaternion&&i.value.rotationQuaternion&&(u.b.SlerpToRef(i.unpressed.rotationQuaternion,i.pressed.rotationQuaternion,n,i.value.rotationQuaternion),u.e.LerpToRef(i.unpressed.position,i.pressed.position,n,i.value.position))}},t.prototype._lerpAxisTransform=function(e,n){if(this._loadedMeshInfo){var i=this._loadedMeshInfo.axisMeshes[e];if(i&&i.min.rotationQuaternion&&i.max.rotationQuaternion&&i.value.rotationQuaternion){var o=.5*n+.5;u.b.SlerpToRef(i.min.rotationQuaternion,i.max.rotationQuaternion,o,i.value.rotationQuaternion),u.e.LerpToRef(i.min.position,i.max.position,o,i.value.position)}}},t.prototype.initControllerMesh=function(e,n,i){var o,a,s=this;if(i===void 0&&(i=!1),Ut.IsPluginForExtensionAvailable(".glb")){var d="default";if(this.id&&!i){var p=this.id.match(t.GAMEPAD_ID_PATTERN);d=p&&p[0]||d}a=this.hand==="left"?t.MODEL_LEFT_FILENAME:t.MODEL_RIGHT_FILENAME,o=t.MODEL_BASE_URL+d+"/"}else l.a.Warn("You need to reference GLTF loader to load Windows Motion Controllers model. Falling back to generic models"),o=Ko.MODEL_BASE_URL,a=Ko.MODEL_FILENAME;Ut.ImportMesh("",o,a,e,function(y){s._loadedMeshInfo=s.processModel(e,y),s._loadedMeshInfo&&(s._defaultModel=s._loadedMeshInfo.rootNode,s.attachToMesh(s._defaultModel),n&&n(s._defaultModel))},null,function(y,P){l.a.Log(P),l.a.Warn("Failed to retrieve controller model from the remote server: "+o+a),i||s.initControllerMesh(y,n,!0)})},t.prototype.processModel=function(e,n){for(var i=null,o=new De.a(this.id+" "+this.hand,e),a=null,s=0;s<n.length;s++){var d=n[s];if(!d.parent){d.isPickable=!1,a=d;break}}return a?(a.setParent(o),i=this.createMeshInfo(o)):l.a.Warn("Could not find root node in model file."),i},t.prototype.createMeshInfo=function(e){var n,i=new Dp;for(i.rootNode=e,i.buttonMeshes={},i.axisMeshes={},n=0;n<this._mapping.buttons.length;n++){var o=this._mapping.buttonMeshNames[this._mapping.buttons[n]];if(o){var a=P(e,o);if(a){var s={index:n,value:O(a,"VALUE"),pressed:O(a,"PRESSED"),unpressed:O(a,"UNPRESSED")};s.value&&s.pressed&&s.unpressed?i.buttonMeshes[this._mapping.buttons[n]]=s:l.a.Warn("Missing button submesh under mesh with name: "+o+"(VALUE: "+!!s.value+", PRESSED: "+!!s.pressed+", UNPRESSED:"+!!s.unpressed+")")}else l.a.Warn("Missing button mesh with name: "+o)}else l.a.Log("Skipping unknown button at index: "+n+" with mapped name: "+this._mapping.buttons[n])}for(n=0;n<this._mapping.axisMeshNames.length;n++){var d=this._mapping.axisMeshNames[n];if(d){var p=P(e,d);if(p){var y={index:n,value:O(p,"VALUE"),min:O(p,"MIN"),max:O(p,"MAX")}
1730;y.value&&y.min&&y.max?i.axisMeshes[n]=y:l.a.Warn("Missing axis submesh under mesh with name: "+d+"(VALUE: "+!!y.value+", MIN: "+!!y.min+", MAX:"+!!y.max+")")}else l.a.Warn("Missing axis mesh with name: "+d)}else l.a.Log("Skipping unknown axis at index: "+n)}return i.pointingPoseNode=P(e,this._mapping.pointingPoseMeshName),i.pointingPoseNode?this._pointingPoseNode=i.pointingPoseNode:l.a.Warn("Missing pointing pose mesh with name: "+this._mapping.pointingPoseMeshName),i;function P(U,F){return U.getChildren(function(z){return z.name===F},!1)[0]}function O(U,F){return U.getChildren(function(z){return z.name==F},!0)[0]}},t.prototype.getForwardRay=function(e){if(e===void 0&&(e=100),!this._loadedMeshInfo||!this._loadedMeshInfo.pointingPoseNode)return r.prototype.getForwardRay.call(this,e);var n=this._loadedMeshInfo.pointingPoseNode.getWorldMatrix(),i=n.getTranslation(),o=new u.e(0,0,-1),a=u.e.TransformNormal(o,n),s=u.e.Normalize(a);return new dn.a(i,s,e)},t.prototype.dispose=function(){r.prototype.dispose.call(this),this.onTrackpadChangedObservable.clear(),this.onTrackpadValuesChangedObservable.clear()},t.MODEL_BASE_URL="https://controllers.babylonjs.com/microsoft/",t.MODEL_LEFT_FILENAME="left.glb",t.MODEL_RIGHT_FILENAME="right.glb",t.GAMEPAD_ID_PREFIX="Spatial Controller (Spatial Interaction Source) ",t.GAMEPAD_ID_PATTERN=/([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/,t}(Ni),Lp=function(r){function t(e){var n=r.call(this,e)||this;return n._mapping={buttons:["trigger","grip","trackpad","thumbstick","menu"],buttonMeshNames:{trigger:"SELECT",menu:"MENU",grip:"GRASP",thumbstick:"THUMBSTICK_PRESS",trackpad:"TOUCHPAD_PRESS"},buttonObservableNames:{trigger:"onTriggerStateChangedObservable",menu:"onSecondaryButtonStateChangedObservable",grip:"onMainButtonStateChangedObservable",thumbstick:"onThumbstickStateChangedObservable",trackpad:"onTrackpadChangedObservable"}
1730,axisMeshNames:["TOUCHPAD_TOUCH_X","TOUCHPAD_TOUCH_Y","THUMBSTICK_X","THUMBSTICK_Y"],pointingPoseMeshName:fr.POINTING_POSE},n.thumbstickValues={x:0,y:0},n.onThumbstickStateChangedObservable=new x.c,n.onThumbstickValuesChangedObservable=new x.c,n.onTrackpadChangedObservable=n.onPadStateChangedObservable,n.onTrackpadValuesChangedObservable=n.onPadValuesChangedObservable,n}return Object(c.d)(t,r),Object.defineProperty(t.prototype,"onThumbstickButtonStateChangedObservable",{get:function(){return this.onThumbstickStateChangedObservable},enumerable:!1,configurable:!0}),t.prototype._updateTrackpad=function(){!this.browserGamepad.axes||this.browserGamepad.axes[2]==this.thumbstickValues.x&&this.browserGamepad.axes[3]==this.thumbstickValues.y||(this.trackpad.x=this.browserGamepad.axes[2],this.trackpad.y=this.browserGamepad.axes[3],this.onThumbstickValuesChangedObservable.notifyObservers(this.trackpad))},t.prototype.dispose=function(){r.prototype.dispose.call(this),this.onThumbstickStateChangedObservable.clear(),this.onThumbstickValuesChangedObservable.clear()},t}(Qo);Di._ControllerFactories.push({canCreate:function(r){return r.id.indexOf(Qo.GAMEPAD_ID_PREFIX)===0},create:function(r){return new Qo(r)}});var qo=f(75),yr=f(63),Ln=f(51),xn=f(36),ro=function(r){function t(e,n,i,o,a){var s,d,p,y,P,O,U;n===void 0&&(n=M.a.Gray()),i===void 0&&(i=xn.a.DefaultUtilityLayer),o===void 0&&(o=null),a===void 0&&(a=1);var F=r.call(this,i)||this;F._pointerObserver=null,F.snapDistance=0,F.onSnapObservable=new x.c,F.uniformScaling=!1,F.sensitivity=1,F._isEnabled=!0,F._parent=null,F._dragging=!1,F._tmpVector=new u.e,F._tmpMatrix=new u.a,F._tmpMatrix2=new u.a,F._parent=o,F._coloredMaterial=new Ft.a("",i.utilityLayerScene),F._coloredMaterial.diffuseColor=n,F._coloredMaterial.specularColor=n.subtract(new M.a(.1,.1,.1)),F._hoverMaterial=new Ft.a("",i.utilityLayerScene),F._hoverMaterial.diffuseColor=M.a.Yellow(),F._disableMaterial=new Ft.a("",i.utilityLayerScene),F._disableMaterial.diffuseColor=M.a.Gray(),F._disableMaterial.alpha=.4,F._gizmoMesh=new De.a("axis",i.utilityLayerScene);var z=F._createGizmoMesh(F._gizmoMesh,a),J=z.arrowMesh,ie=z.arrowTail,se=F._createGizmoMesh(F._gizmoMesh,a+4,!0);F._gizmoMesh.lookAt(F._rootMesh.position.add(e)),F._rootMesh.addChild(F._gizmoMesh),F._gizmoMesh.scaling.scaleInPlace(1/3);var ce=J.position.clone(),ue=ie.position.clone(),fe=ie.scaling.clone(),ve=function(xe){var Ne=xe*(3/F._rootMesh.scaling.length())*6;J.position.z+=Ne/3.5,ie.scaling.y+=Ne,ie.position.z=J.position.z/2},Te=function(){J.position.set(ce.x,ce.y,ce.z),ie.position.set(ue.x,ue.y,ue.z),ie.scaling.set(fe.x,fe.y,fe.z),F._dragging=!1};F.dragBehavior=new bi.a({dragAxis:e}),F.dragBehavior.moveAttached=!1,F._rootMesh.addBehavior(F.dragBehavior);var Oe=0,Pe=new u.e,Ee={snapDistance:0};F.dragBehavior.onDragObservable.add(function(xe){if(F.attachedNode){var Ne=F.sensitivity*xe.dragDistance*(3*F.scaleRatio/F._rootMesh.scaling.length()),Ie=!1,Fe=0;F.uniformScaling?(F.attachedNode.getWorldMatrix().decompose(Pe),Pe.normalize(),Pe.y<0&&Pe.scaleInPlace(-1)):Pe.copyFrom(e),F.snapDistance==0?Pe.scaleToRef(Ne,Pe):(Oe+=Ne,Math.abs(Oe)>F.snapDistance?(Fe=Math.floor(Math.abs(Oe)/F.snapDistance),Oe<0&&(Fe*=-1),Oe%=F.snapDistance,Pe.scaleToRef(F.snapDistance*Fe,Pe),Ie=!0):Pe.scaleInPlace(0)),u.a.ScalingToRef(1+Pe.x,1+Pe.y,1+Pe.z,F._tmpMatrix2),F._tmpMatrix2.multiplyToRef(F.attachedNode.getWorldMatrix(),F._tmpMatrix),F._tmpMatrix.decompose(F._tmpVector),Math.abs(F._tmpVector.x)<1e5&&Math.abs(F._tmpVector.y)<1e5&&Math.abs(F._tmpVector.z)<1e5&&F.attachedNode.getWorldMatrix().copyFrom(F._tmpMatrix),Ie&&(Ee.snapDistance=F.snapDistance*Fe,F.onSnapObservable.notifyObservers(Ee)),F._matrixChanged()}}),F.dragBehavior.onDragStartObservable.add(function(){F._dragging=!0}),F.dragBehavior.onDragObservable.add(function(xe){return ve(xe.dragDistance)}),F.dragBehavior.onDragEndObservable.add(Te),(p=(d=(s=o?.uniformScaleGizmo)===null||s===void 0?void 0:s.dragBehavior)===null||d===void 0?void 0:d.onDragObservable)===null||p===void 0||p.add(function(xe){return ve(xe.delta.y)}),(O=(P=(y=o?.uniformScaleGizmo)===null||y===void 0?void 0:y.dragBehavior)===null||P===void 0?void 0:P.onDragEndObservable)===null||O===void 0||O.add(Te);var Se={gizmoMeshes:[J,ie],colliderMeshes:[se.arrowMesh,se.arrowTail],material:F._coloredMaterial,hoverMaterial:F._hoverMaterial,disableMaterial:F._disableMaterial,active:!1};(U=F._parent)===null||U===void 0||U.addToAxisCache(F._gizmoMesh,Se),F._pointerObserver=i.utilityLayerScene.onPointerObservable.add(function(xe){var Ne;if(!F._customMeshSet&&(F._isHovered=Se.colliderMeshes.indexOf((Ne=xe?.pickInfo)===null||Ne===void 0?void 0:Ne.pickedMesh)!=-1,!F._parent)){var Ie=F._isHovered||F._dragging?F._hoverMaterial:F._coloredMaterial;
1730Se.gizmoMeshes.forEach(function(Fe){Fe.material=Ie,Fe.color&&(Fe.color=Ie.diffuseColor)})}});var Le=i._getSharedGizmoLight();return Le.includedOnlyMeshes=Le.includedOnlyMeshes.concat(F._rootMesh.getChildMeshes()),F}return Object(c.d)(t,r),t.prototype._createGizmoMesh=function(e,n,i){i===void 0&&(i=!1);var o=yr.a.CreateBox("yPosMesh",{size:.4*(1+(n-1)/4)},this.gizmoLayer.utilityLayerScene),a=ui.a.CreateCylinder("cylinder",{diameterTop:.005*n,height:.275,diameterBottom:.005*n,tessellation:96},this.gizmoLayer.utilityLayerScene);return o.scaling.scaleInPlace(.1),o.material=this._coloredMaterial,o.rotation.x=Math.PI/2,o.position.z+=.3,a.material=this._coloredMaterial,a.position.z+=.1375,a.rotation.x=Math.PI/2,i&&(o.visibility=0,a.visibility=0),e.addChild(o),e.addChild(a),{arrowMesh:o,arrowTail:a}},t.prototype._attachedNodeChanged=function(e){this.dragBehavior&&(this.dragBehavior.enabled=!!e)},Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled=e,e?this._parent&&(this.attachedMesh=this._parent.attachedMesh,this.attachedNode=this._parent.attachedNode):(this.attachedMesh=null,this.attachedNode=null)},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){this.onSnapObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.dragBehavior.detach(),this._gizmoMesh&&this._gizmoMesh.dispose(),[this._coloredMaterial,this._hoverMaterial,this._disableMaterial].forEach(function(e){e&&e.dispose()}),r.prototype.dispose.call(this)},t.prototype.setCustomMesh=function(e,n){var i=this;n===void 0&&(n=!1),r.prototype.setCustomMesh.call(this,e),n&&(this._rootMesh.getChildMeshes().forEach(function(o){o.material=i._coloredMaterial,o.color&&(o.color=i._coloredMaterial.diffuseColor)}),this._customMeshSet=!1)},t}(Ln.a),Nn=f(45),cn=f(40),bu=function(r){function t(e,n){e===void 0&&(e=M.a.Gray()),n===void 0&&(n=xn.a.DefaultKeepDepthUtilityLayer);var i=r.call(this,n)||this;i._boundingDimensions=new u.e(1,1,1),i._renderObserver=null,i._pointerObserver=null,i._scaleDragSpeed=.2,i._tmpQuaternion=new u.b,i._tmpVector=new u.e(0,0,0),i._tmpRotationMatrix=new u.a,i.ignoreChildren=!1,i.includeChildPredicate=null,i.rotationSphereSize=.1,i.scaleBoxSize=.1,i.fixedDragMeshScreenSize=!1,i.fixedDragMeshBoundsSize=!1,i.fixedDragMeshScreenSizeDistanceFactor=10,i.onDragStartObservable=new x.c,i.onScaleBoxDragObservable=new x.c,i.onScaleBoxDragEndObservable=new x.c,i.onRotationSphereDragObservable=new x.c,i.onRotationSphereDragEndObservable=new x.c,i.scalePivot=null,i._existingMeshScale=new u.e,i._dragMesh=null,i.pointerDragBehavior=new bi.a,i.updateScale=!1,i._anchorMesh=new Dt.a("anchor",n.utilityLayerScene),i.coloredMaterial=new Ft.a("",n.utilityLayerScene),i.coloredMaterial.disableLighting=!0,i.hoverColoredMaterial=new Ft.a("",n.utilityLayerScene),i.hoverColoredMaterial.disableLighting=!0,i._lineBoundingBox=new Dt.a("",n.utilityLayerScene),i._lineBoundingBox.rotationQuaternion=new u.b;var o=[];o.push(cn.a.CreateLines("lines",{points:[new u.e(0,0,0),new u.e(i._boundingDimensions.x,0,0)]},n.utilityLayerScene)),o.push(cn.a.CreateLines("lines",{points:[new u.e(0,0,0),new u.e(0,i._boundingDimensions.y,0)]},n.utilityLayerScene)),o.push(cn.a.CreateLines("lines",{points:[new u.e(0,0,0),new u.e(0,0,i._boundingDimensions.z)]},n.utilityLayerScene)),o.push(cn.a.CreateLines("lines",{points:[new u.e(i._boundingDimensions.x,0,0),new u.e(i._boundingDimensions.x,i._boundingDimensions.y,0)]},n.utilityLayerScene)),o.push(cn.a.CreateLines("lines",{points:[new u.e(i._boundingDimensions.x,0,0),new u.e(i._boundingDimensions.x,0,i._boundingDimensions.z)]},n.utilityLayerScene)),o.push(cn.a.CreateLines("lines",{points:[new u.e(0,i._boundingDimensions.y,0),new u.e(i._boundingDimensions.x,i._boundingDimensions.y,0)]},n.utilityLayerScene)),o.push(cn.a.CreateLines("lines",{points:[new u.e(0,i._boundingDimensions.y,0),new u.e(0,i._boundingDimensions.y,i._boundingDimensions.z)]},n.utilityLayerScene)),o.push(cn.a.CreateLines("lines",{points:[new u.e(0,0,i._boundingDimensions.z),new u.e(i._boundingDimensions.x,0,i._boundingDimensions.z)]},n.utilityLayerScene)),o.push(cn.a.CreateLines("lines",{points:[new u.e(0,0,i._boundingDimensions.z),new u.e(0,i._boundingDimensions.y,i._boundingDimensions.z)]},n.utilityLayerScene)),o.push(cn.a.CreateLines("lines",{points:[new u.e(i._boundingDimensions.x,i._boundingDimensions.y,i._boundingDimensions.z),new u.e(0,i._boundingDimensions.y,i._boundingDimensions.z)]},n.utilityLayerScene)),o.push(cn.a.CreateLines("lines",{points:[new u.e(i._boundingDimensions.x,i._boundingDimensions.y,i._boundingDimensions.z),new u.e(i._boundingDimensions.x,0,i._boundingDimensions.z)]},n.utilityLayerScene)),o.push(cn.a.CreateLines("lines",{points:[new u.e(i._boundingDimensions.x,i._boundingDimensions.y,i._boundingDimensions.z),new u.e(i._boundingDimensions.x,i._boundingDimensions.y,0)]},n.utilityLayerScene)),o.forEach(function(J){J.color=e,J.position.addInPlace(new u.e(-i._boundingDimensions.x/2,-i._boundingDimensions.y/2,-i._boundingDimensions.z/2)),J.isPickable=!1,i._lineBoundingBox.addChild(J)}),i._rootMesh.addChild(i._lineBoundingBox),i.setColor(e),i._rotateSpheresParent=new Dt.a("",n.utilityLayerScene),i._rotateSpheresParent.rotationQuaternion=new u.b;for(var a=function(J){var ie=Nn.a.CreateSphere("",{diameter:1},n.utilityLayerScene);ie.rotationQuaternion=new u.b,ie.material=s.coloredMaterial,(P=new bi.a({})).moveAttached=!1,P.updateDragPlane=!1,ie.addBehavior(P);var se=new u.e(1,0,0),ce=0;P.onDragStartObservable.add(function(){se.copyFrom(ie.forward),ce=0}
1730),P.onDragObservable.add(function(ue){if(i.onRotationSphereDragObservable.notifyObservers({}),i.attachedMesh){var fe=i.attachedMesh.parent;if(fe&&fe.scaling&&fe.scaling.isNonUniformWithinEpsilon(.001))return void l.a.Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");kn.a._RemoveAndStorePivotPoint(i.attachedMesh);var ve=se,Te=ue.dragPlaneNormal.scale(u.e.Dot(ue.dragPlaneNormal,ve)),Oe=ve.subtract(Te).normalizeToNew(),Pe=u.e.Dot(Oe,ue.delta)<0?Math.abs(ue.delta.length()):-Math.abs(ue.delta.length());Pe=Pe/i._boundingDimensions.length()*i._anchorMesh.scaling.length(),i.attachedMesh.rotationQuaternion||(i.attachedMesh.rotationQuaternion=u.b.RotationYawPitchRoll(i.attachedMesh.rotation.y,i.attachedMesh.rotation.x,i.attachedMesh.rotation.z)),i._anchorMesh.rotationQuaternion||(i._anchorMesh.rotationQuaternion=u.b.RotationYawPitchRoll(i._anchorMesh.rotation.y,i._anchorMesh.rotation.x,i._anchorMesh.rotation.z)),ce+=Pe,Math.abs(ce)<=2*Math.PI&&(J>=8?u.b.RotationYawPitchRollToRef(0,0,Pe,i._tmpQuaternion):J>=4?u.b.RotationYawPitchRollToRef(Pe,0,0,i._tmpQuaternion):u.b.RotationYawPitchRollToRef(0,Pe,0,i._tmpQuaternion),i._anchorMesh.addChild(i.attachedMesh),i._anchorMesh.rotationQuaternion.multiplyToRef(i._tmpQuaternion,i._anchorMesh.rotationQuaternion),i._anchorMesh.removeChild(i.attachedMesh),i.attachedMesh.setParent(fe)),i.updateBoundingBox(),kn.a._RestorePivotPoint(i.attachedMesh)}i._updateDummy()}),P.onDragStartObservable.add(function(){i.onDragStartObservable.notifyObservers({}),i._selectNode(ie)}),P.onDragEndObservable.add(function(){i.onRotationSphereDragEndObservable.notifyObservers({}),i._selectNode(null),i._updateDummy()}),s._rotateSpheresParent.addChild(ie)},s=this,d=0;d<12;d++)a(d);i._rootMesh.addChild(i._rotateSpheresParent),i._scaleBoxesParent=new Dt.a("",n.utilityLayerScene),i._scaleBoxesParent.rotationQuaternion=new u.b;for(var p=0;p<3;p++)for(var y=0;y<3;y++)for(var P,O=function(){var J=(p===1?1:0)+(y===1?1:0)+(F===1?1:0);if(J===1||J===3)return"continue";var ie=yr.a.CreateBox("",{size:1},n.utilityLayerScene);ie.material=U.coloredMaterial,ie.metadata=J===2;var se=new u.e(p-1,y-1,F-1).normalize();(P=new bi.a({dragAxis:se})).updateDragPlane=!1,P.moveAttached=!1,ie.addBehavior(P),P.onDragObservable.add(function(ce){if(i.onScaleBoxDragObservable.notifyObservers({}),i.attachedMesh){var ue=i.attachedMesh.parent;if(ue&&ue.scaling&&ue.scaling.isNonUniformWithinEpsilon(.001))return void l.a.Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");kn.a._RemoveAndStorePivotPoint(i.attachedMesh);var fe=ce.dragDistance/i._boundingDimensions.length()*i._anchorMesh.scaling.length(),ve=new u.e(fe,fe,fe);J===2&&(ve.x*=Math.abs(se.x),ve.y*=Math.abs(se.y),ve.z*=Math.abs(se.z)),ve.scaleInPlace(i._scaleDragSpeed),i.updateBoundingBox(),i.scalePivot?(i.attachedMesh.getWorldMatrix().getRotationMatrixToRef(i._tmpRotationMatrix),i._boundingDimensions.scaleToRef(.5,i._tmpVector),u.e.TransformCoordinatesToRef(i._tmpVector,i._tmpRotationMatrix,i._tmpVector),i._anchorMesh.position.subtractInPlace(i._tmpVector),i._boundingDimensions.multiplyToRef(i.scalePivot,i._tmpVector),u.e.TransformCoordinatesToRef(i._tmpVector,i._tmpRotationMatrix,i._tmpVector),i._anchorMesh.position.addInPlace(i._tmpVector)):(ie.absolutePosition.subtractToRef(i._anchorMesh.position,i._tmpVector),i._anchorMesh.position.subtractInPlace(i._tmpVector)),i._anchorMesh.addChild(i.attachedMesh),i._anchorMesh.scaling.addInPlace(ve),(i._anchorMesh.scaling.x<0||i._anchorMesh.scaling.y<0||i._anchorMesh.scaling.z<0)&&i._anchorMesh.scaling.subtractInPlace(ve),i._anchorMesh.removeChild(i.attachedMesh),i.attachedMesh.setParent(ue),kn.a._RestorePivotPoint(i.attachedMesh)}i._updateDummy()}),P.onDragStartObservable.add(function(){i.onDragStartObservable.notifyObservers({}),i._selectNode(ie)}),P.onDragEndObservable.add(function(){i.onScaleBoxDragEndObservable.notifyObservers({}),i._selectNode(null),i._updateDummy()}),U._scaleBoxesParent.addChild(ie)},U=this,F=0;F<3;F++)O();i._rootMesh.addChild(i._scaleBoxesParent);var z=new Array;return i._pointerObserver=n.utilityLayerScene.onPointerObservable.add(function(J){z[J.event.pointerId]?J.pickInfo&&J.pickInfo.pickedMesh!=z[J.event.pointerId]&&(z[J.event.pointerId].material=i.coloredMaterial,delete z[J.event.pointerId]):i._rotateSpheresParent.getChildMeshes().concat(i._scaleBoxesParent.getChildMeshes()).forEac
1730h(function(ie){J.pickInfo&&J.pickInfo.pickedMesh==ie&&(z[J.event.pointerId]=ie,ie.material=i.hoverColoredMaterial)})}),i._renderObserver=i.gizmoLayer.originalScene.onBeforeRenderObservable.add(function(){i.attachedMesh&&!i._existingMeshScale.equals(i.attachedMesh.scaling)?i.updateBoundingBox():(i.fixedDragMeshScreenSize||i.fixedDragMeshBoundsSize)&&(i._updateRotationSpheres(),i._updateScaleBoxes()),i._dragMesh&&i.attachedMesh&&i.pointerDragBehavior.dragging&&(i._lineBoundingBox.position.rotateByQuaternionToRef(i._rootMesh.rotationQuaternion,i._tmpVector),i.attachedMesh.setAbsolutePosition(i._dragMesh.position.add(i._tmpVector.scale(-1))))}),i.updateBoundingBox(),i}return Object(c.d)(t,r),t.prototype.setColor=function(e){this.coloredMaterial.emissiveColor=e,this.hoverColoredMaterial.emissiveColor=e.clone().add(new M.a(.3,.3,.3)),this._lineBoundingBox.getChildren().forEach(function(n){n.color&&(n.color=e)})},t.prototype._attachedNodeChanged=function(e){var n=this;if(e){kn.a._RemoveAndStorePivotPoint(e);var i=e.parent;this._anchorMesh.addChild(e),this._anchorMesh.removeChild(e),e.setParent(i),kn.a._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._rotateSpheresParent.getChildMeshes().concat(this._scaleBoxesParent.getChildMeshes()).forEach(function(n){n.isVisible=!e||n==e})},t.prototype.updateBoundingBox=function(){if(this.attachedMesh){kn.a._RemoveAndStorePivotPoint(this.attachedMesh);var e=this.attachedMesh.parent;this.attachedMesh.setParent(null);var n=null;this.attachedMesh.skeleton&&(n=this.attachedMesh.skeleton.overrideMesh,this.attachedMesh.skeleton.overrideMesh=null),this._update(),this.attachedMesh.rotationQuaternion||(this.attachedMesh.rotationQuaternion=u.b.RotationYawPitchRoll(this.attachedMesh.rotation.y,this.attachedMesh.rotation.x,this.attachedMesh.rotation.z)),this._anchorMesh.rotationQuaternion||(this._anchorMesh.rotationQuaternion=u.b.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 i=this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren,this.includeChildPredicate);i.max.subtractToRef(i.min,this._boundingDimensions),this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions),this._lineBoundingBox.position.set((i.max.x+i.min.x)/2,(i.max.y+i.min.y)/2,(i.max.z+i.min.z)/2),this._rotateSpheresParent.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.attachedMesh.skeleton&&(this.attachedMesh.skeleton.overrideMesh=n)}this._updateRotationSpheres(),this._updateScaleBoxes(),this.attachedMesh&&(this._existingMeshScale.copyFrom(this.attachedMesh.scaling),kn.a._RestorePivotPoint(this.attachedMesh))},t.prototype._updateRotationSpheres=function(){for(var e=this._rotateSpheresParent.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;if(n==0&&(e[a].position.set(this._boundingDimensions.x/2,this._boundingDimensions.y*i,this._boundingDimensions.z*o),e[a].position.addInPlace(new u.e(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),e[a].lookAt(u.e.Cross(e[a].position.normalizeToNew(),u.e.Right()).normalizeToNew().add(e[a].position))),n==1&&(e[a].position.set(this._boundingDimensions.x*i,this._boundingDimensions.y/2,this._boundingDimensions.z*o),e[a].position.addInPlace(new u.e(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),e[a].lookAt(u.e.Cross(e[a].position.normalizeToNew(),u.e.Up()).normalizeToNew().add(e[a].position))),n==2&&(e[a].position.set(this._boundingDimensions.x*i,this._boundingDimensions.y*o,this._boundingDimensions.z/2),e[a].position.addInPlace(new u.e(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),e[a].lookAt(u.e.Cross(e[a].position.normalizeToNew(),u.e.Forward()).normalizeToNew().add(e[a].position))),this.fixedDragMeshScreenSize&&this.gizmoLayer.utilityLayerScene.activeCamera){e[a].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position,this._tmpVector);var s=this.rotationSphereSize*this._tmpVector.length()/this.fixedDragMeshScreenSizeDistanceFactor;e[a].scaling.set(s,s,s)}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);
1730if(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 u.e(-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.position,this._tmpVector);var d=this.scaleBoxSize*this._tmpVector.length()/this.fixedDragMeshScreenSizeDistanceFactor;e[n].scaling.set(d,d,d)}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._rotateSpheresParent.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)})}
1730,t.prototype.setEnabledScaling=function(e,n){n===void 0&&(n=!1),this._scaleBoxesParent.getChildMeshes().forEach(function(i,o){var a=e;n&&i.metadata===!0&&(a=!1),i.setEnabled(a)})},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=De.a.CreateBox("dummy",1,this.gizmoLayer.utilityLayerScene),this._dragMesh.visibility=0,this._dragMesh.rotationQuaternion=new u.b,this.pointerDragBehavior.useObjectOrientationForDragging=!1,this._dragMesh.addBehavior(this.pointerDragBehavior)},t.prototype.dispose=function(){this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver),this._lineBoundingBox.dispose(),this._rotateSpheresParent.dispose(),this._scaleBoxesParent.dispose(),this._dragMesh&&this._dragMesh.dispose(),r.prototype.dispose.call(this)},t.MakeNotPickableAndWrapInBoundingBox=function(e){var n=function(d){d.isPickable=!1,d.getChildMeshes().forEach(function(p){n(p)})};n(e),e.rotationQuaternion||(e.rotationQuaternion=u.b.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=yr.a.CreateBox("box",{size:1},e.getScene()),s=e.getHierarchyBoundingVectors();return s.max.subtractToRef(s.min,a.scaling),a.scaling.y===0&&(a.scaling.y=Gt.a),a.scaling.x===0&&(a.scaling.x=Gt.a),a.scaling.z===0&&(a.scaling.z=Gt.a),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(e){l.a.Error("Custom meshes are not supported on this gizmo")},t}(Ln.a),Zo=function(r){function t(e,n,i,o,a,s,d){var p;n===void 0&&(n=M.a.Gray()),i===void 0&&(i=xn.a.DefaultUtilityLayer),o===void 0&&(o=32),a===void 0&&(a=null),d===void 0&&(d=1);var y=r.call(this,i)||this;y._pointerObserver=null,y.snapDistance=0,y.onSnapObservable=new x.c,y._isEnabled=!0,y._parent=null,y._dragging=!1,y._parent=a,y._coloredMaterial=new Ft.a("",i.utilityLayerScene),y._coloredMaterial.diffuseColor=n,y._coloredMaterial.specularColor=n.subtract(new M.a(.1,.1,.1)),y._hoverMaterial=new Ft.a("",i.utilityLayerScene),y._hoverMaterial.diffuseColor=M.a.Yellow(),y._disableMaterial=new Ft.a("",i.utilityLayerScene),y._disableMaterial.diffuseColor=M.a.Gray(),y._disableMaterial.alpha=.4,y._gizmoMesh=new De.a("",i.utilityLayerScene);var P=y._createGizmoMesh(y._gizmoMesh,d,o),O=P.rotationMesh,U=P.collider,F=[];y._rotationCircle=y.setupRotationCircle(F,y._gizmoMesh),y._gizmoMesh.lookAt(y._rootMesh.position.add(e)),y._rootMesh.addChild(y._gizmoMesh),y._gizmoMesh.scaling.scaleInPlace(1/3),y.dragBehavior=new bi.a({dragPlaneNormal:e}),y.dragBehavior.moveAttached=!1,y.dragBehavior.maxDragAngle=9*Math.PI/20,y.dragBehavior._useAlternatePickedPointAboveMaxDragAngle=!0,y._rootMesh.addBehavior(y.dragBehavior);var z=0,J=new u.e,ie=new u.e,se=new u.a,ce=new u.e,ue=new u.e;y.dragBehavior.onDragStartObservable.add(function(Se){if(y.attachedNode){J.copyFrom(Se.dragPlanePoint);var Le=new u.e(0,0,1),xe=y._rotationCircle.getDirection(Le);xe.normalize(),y._gizmoMesh.removeChild(y._rotationCircle),J.copyFrom(Se.dragPlanePoint),ie=Se.dragPlanePoint;var Ne=y._rotationCircle.getAbsolutePosition().clone(),Ie=y._rotationCircle.getAbsolutePosition().clone().addInPlace(xe),Fe=Se.dragPlanePoint,Ke=u.e.GetAngleBetweenVectors(Ie.subtract(Ne),Fe.subtract(Ne),y._rotationCircle.up);y._rotationCircle.addRotation(0,Ke,0),y._dragging=!0}}),y.dragBehavior.onDragEndObservable.add(function(){z=0,y.updateRotationCircle(y._rotationCircle,F,z,ie),y._gizmoMesh.addChild(y._rotationCircle),y._dragging=!1});var fe={snapDistance:0},ve=0,Te=new u.a,Oe=new u.b;y.dragBehavior.onDragObservable.add(function(Se){if(y.attachedNode){var Le=new u.e(1,1,1),xe=new u.b(0,0,0,1),Ne=new u.e(0,0,0);y.attachedNode.getWorldMatrix().decompose(Le,xe,Ne);var Ie=Se.dragPlanePoint.subtract(Ne).normalize(),Fe=J.subtract(Ne).normalize(),Ke=u.e.Cross(Ie,Fe),nt=u.e.Dot(Ie,Fe),rt=Math.atan2(Ke.length(),nt);ce.copyFrom(e),ue.copyFrom(e),y.updateGizmoRotationToMatchAttachedMesh&&(xe.toRotationMatrix(se),ue=u.e.TransformCoordinates(ce,se));var ut=!1;if(i.utilityLayerScene.activeCamera){var qe=i.utilityLayerScene.activeCamera.position.subtract(Ne);u.e.Dot(qe,ue)>0&&(ce.scaleInPlace(-1),ue.scaleInPlace(-1),ut=!0)}u.e.Dot(ue,Ke)>0&&(rt=-rt);var at=!1;if(y.snapDistance!=0)if(ve+=rt,Math.abs(ve)>y.snapDistance){var ot=Math.floor(Math.abs(ve)/y.snapDistance);
1730ve<0&&(ot*=-1),ve%=y.snapDistance,rt=y.snapDistance*ot,at=!0}else rt=0;z+=ut?-rt:rt,y.updateRotationCircle(y._rotationCircle,F,z,ie);var Je=Math.sin(rt/2);if(Oe.set(ce.x*Je,ce.y*Je,ce.z*Je,Math.cos(rt/2)),Te.determinant()>0){var dt=new u.e;Oe.toEulerAnglesToRef(dt),u.b.RotationYawPitchRollToRef(dt.y,-dt.x,-dt.z,Oe)}y.updateGizmoRotationToMatchAttachedMesh?xe.multiplyToRef(Oe,xe):Oe.multiplyToRef(xe,xe),y.attachedNode.getWorldMatrix().copyFrom(u.a.Compose(Le,xe,Ne)),J.copyFrom(Se.dragPlanePoint),at&&(fe.snapDistance=rt,y.onSnapObservable.notifyObservers(fe)),y._matrixChanged()}});var Pe=i._getSharedGizmoLight();Pe.includedOnlyMeshes=Pe.includedOnlyMeshes.concat(y._rootMesh.getChildMeshes(!1));var Ee={colliderMeshes:[U],gizmoMeshes:[O],material:y._coloredMaterial,hoverMaterial:y._hoverMaterial,disableMaterial:y._disableMaterial,active:!1};return(p=y._parent)===null||p===void 0||p.addToAxisCache(y._gizmoMesh,Ee),y._pointerObserver=i.utilityLayerScene.onPointerObservable.add(function(Se){var Le;if(!y._customMeshSet&&(y._isHovered=Ee.colliderMeshes.indexOf((Le=Se?.pickInfo)===null||Le===void 0?void 0:Le.pickedMesh)!=-1,!y._parent)){var xe=y._isHovered||y._dragging?y._hoverMaterial:y._coloredMaterial;Ee.gizmoMeshes.forEach(function(Ne){Ne.material=xe,Ne.color&&(Ne.color=xe.diffuseColor)})}}),y}return Object(c.d)(t,r),t.prototype._createGizmoMesh=function(e,n,i){var o=De.a.CreateTorus("ignore",.6,.03*n,i,this.gizmoLayer.utilityLayerScene);o.visibility=0;var a=De.a.CreateTorus("",.6,.005*n,i,this.gizmoLayer.utilityLayerScene);return a.material=this._coloredMaterial,a.rotation.x=Math.PI/2,o.rotation.x=Math.PI/2,e.addChild(a),e.addChild(o),{rotationMesh:a,collider:o}},t.prototype._attachedNodeChanged=function(e){this.dragBehavior&&(this.dragBehavior.enabled=!!e)},t.prototype.setupRotationCircle=function(e,n){for(var i=t._CircleConstants.pi2/t._CircleConstants.tessellation,o=-Math.PI/2;o<Math.PI/2-1.5;o+=i/2){for(var a=[],s=0;s<t._CircleConstants.pi2*t._CircleConstants.rotationCircleRange+.01;s+=i)if(s<0){var d=t._CircleConstants.radius*Math.sin(s)*Math.cos(o),p=t._CircleConstants.radius*Math.cos(s)*Math.cos(o);a.push(new u.e(d,0,p))}else a.push(new u.e(0,0,0));e.push(a)}var y=new Ft.a("",this.gizmoLayer.utilityLayerScene);y.diffuseColor=M.a.Yellow(),y.backFaceCulling=!1;var P=De.a.CreateRibbon("rotationCircle",e,!1,!1,0,this.gizmoLayer.utilityLayerScene,!0);return P.material=y,P.material.alpha=.25,P.rotation.x=Math.PI/2,n.addChild(P),P},t.prototype.updateRotationPath=function(e,n){for(var i=t._CircleConstants.pi2/t._CircleConstants.tessellation,o=0,a=-Math.PI/2;a<Math.PI/2-1.5;a+=i/2){var s=e[o];if(s)for(var d=0,p=0;p<t._CircleConstants.pi2*t._CircleConstants.rotationCircleRange+.01;p+=i){if(s[d])if(p<Math.abs(n)){var y=n>0?p:-1*p,P=n>0?a:-1*a;s[d].set(t._CircleConstants.radius*Math.sin(y)*Math.cos(P),0,t._CircleConstants.radius*Math.cos(y)*Math.cos(P))}else s[d].set(0,0,0);d++}o++}},t.prototype.updateRotationCircle=function(e,n,i,o){this.updateRotationPath(n,i),De.a.CreateRibbon("rotationCircle",n,!1,!1,0,this.gizmoLayer.utilityLayerScene,void 0,void 0,e.geometry?e:void 0)},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._rotationCircle&&this._rotationCircle.dispose(),[this._coloredMaterial,this._hoverMaterial,this._disableMaterial].forEach(function(e){e&&e.dispose()}),r.prototype.dispose.call(this)},t._CircleConstants={radius:.3,pi2:2*Math.PI,tessellation:70,rotationCircleRange:4},t}(Ln.a),yu=function(r){function t(e,n,i,o,a){e===void 0&&(e=xn.a.DefaultUtilityLayer),n===void 0&&(n=32),i===void 0&&(i=!1),o===void 0&&(o=1);var s=r.call(this,e)||this;return s.onDragStartObservable=new x.c,s.onDragEndObservable=new x.c,s._observables=[],s._gizmoAxisCache=new Map,s.xGizmo=new Zo(new u.e(1,0,0),M.a.Red().scale(.5),e,n,s,i,o),s.yGizmo=new Zo(new u.e(0,1,0),M.a.Green().scale(.5),e,n,s,i,o),s.zGizmo=new Zo(new u.e(0,0,1),M.a.Blue(
1730).scale(.5),e,n,s,i,o),[s.xGizmo,s.yGizmo,s.zGizmo].forEach(function(d){d.dragBehavior.onDragStartObservable.add(function(){s.onDragStartObservable.notifyObservers({})}),d.dragBehavior.onDragEndObservable.add(function(){s.onDragEndObservable.notifyObservers({})})}),s.attachedMesh=null,s.attachedNode=null,a?a.addToAxisCache(s._gizmoAxisCache):Ln.a.GizmoAxisPointerObserver(e,s._gizmoAxisCache),s}return Object(c.d)(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&&console.log("Rotation Gizmo will not work with transforms in billboard mode.")},Object.defineProperty(t.prototype,"isHovered",{get:function(){var e=!1;return[this.xGizmo,this.yGizmo,this.zGizmo].forEach(function(n){e=e||n.isHovered}),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,"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}),t.prototype.addToAxisCache=function(e,n){this._gizmoAxisCache.set(e,n)},t.prototype.dispose=function(){var e=this;this.xGizmo.dispose(),this.yGizmo.dispose(),this.zGizmo.dispose(),this.onDragStartObservable.clear(),this.onDragEndObservable.clear(),this._observables.forEach(function(n){e.gizmoLayer.utilityLayerScene.onPointerObservable.remove(n)})},t.prototype.setCustomMesh=function(e){l.a.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}(Ln.a),Tr=f(46),Ls=f(84),Jo=function(r){function t(e,n,i,o){var a;n===void 0&&(n=M.a.Gray()),i===void 0&&(i=xn.a.DefaultUtilityLayer),o===void 0&&(o=null);var s=r.call(this,i)||this;s._pointerObserver=null,s.snapDistance=0,s.onSnapObservable=new x.c,s._isEnabled=!1,s._parent=null,s._dragging=!1,s._parent=o,s._coloredMaterial=new Ft.a("",i.utilityLayerScene),s._coloredMaterial.diffuseColor=n,s._coloredMaterial.specularColor=n.subtract(new M.a(.1,.1,.1)),s._hoverMaterial=new Ft.a("",i.utilityLayerScene),s._hoverMaterial.diffuseColor=M.a.Yellow(),s._disableMaterial=new Ft.a("",i.utilityLayerScene),s._disableMaterial.diffuseColor=M.a.Gray(),s._disableMaterial.alpha=.4,s._gizmoMesh=t._CreatePlane(i.utilityLayerScene,s._coloredMaterial),s._gizmoMesh.lookAt(s._rootMesh.position.add(e)),s._gizmoMesh.scaling.scaleInPlace(1/3),s._gizmoMesh.parent=s._rootMesh;var d=0,p=new u.e,y={snapDistance:0};s.dragBehavior=new bi.a({dragPlaneNormal:e}),s.dragBehavior.moveAttached=!1,s._rootMesh.addBehavior(s.dragBehavior),s.dragBehavior.onDragObservable.add(function(U){if(s.attachedNode){if(s.snapDistance==0)s.attachedNode.getWorldMatrix().addTranslationFromFloats(U.delta.x,U.delta.y,U.delta.z);else if(d+=U.dragDistance,Math.abs(d)>s.snapDistance){var F=Math.floor(Math.abs(d)/s.snapDistance);d%=s.snapDistance,U.delta.normalizeToRef(p),p.scaleInPlace(s.snapDistance*F),s.attachedNode.getWorldMatrix().addTranslationFromFloats(p.x,p.y,p.z),y.snapDistance=s.snapDistance*F,s.onSnapObservable.notifyObservers(y)}s._matrixChanged()}}),s.dragBehavior.onDragStartObservable.add(function(){s._dragging=!0}),s.dragBehavior.onDragEndObservable.add(function(){s._dragging=!1});var P=i._getSharedGizmoLight();P.includedOnlyMeshes=P.includedOnlyMeshes.concat(s._rootMesh.getChildMeshes(!1));var O={gizmoMeshes:s._gizmoMesh.getChildMeshes(),colliderMeshes:s._gizmoMesh.getChildMeshes(),material:s._c
1730oloredMaterial,hoverMaterial:s._hoverMaterial,disableMaterial:s._disableMaterial,active:!1};return(a=s._parent)===null||a===void 0||a.addToAxisCache(s._gizmoMesh,O),s._pointerObserver=i.utilityLayerScene.onPointerObservable.add(function(U){var F;if(!s._customMeshSet&&(s._isHovered=O.colliderMeshes.indexOf((F=U?.pickInfo)===null||F===void 0?void 0:F.pickedMesh)!=-1,!s._parent)){var z=s._isHovered||s._dragging?s._hoverMaterial:s._coloredMaterial;O.gizmoMeshes.forEach(function(J){J.material=z})}}),s}return Object(c.d)(t,r),t._CreatePlane=function(e,n){var i=new Tr.a("plane",e),o=Ls.a.CreatePlane("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}(Ln.a),Tu=function(r){function t(e,n,i){e===void 0&&(e=xn.a.DefaultUtilityLayer),n===void 0&&(n=1);var o=r.call(this,e)||this;return o._meshAttached=null,o._nodeAttached=null,o._observables=[],o._gizmoAxisCache=new Map,o.onDragStartObservable=new x.c,o.onDragEndObservable=new x.c,o._planarGizmoEnabled=!1,o.xGizmo=new qo.a(new u.e(1,0,0),M.a.Red().scale(.5),e,o,n),o.yGizmo=new qo.a(new u.e(0,1,0),M.a.Green().scale(.5),e,o,n),o.zGizmo=new qo.a(new u.e(0,0,1),M.a.Blue().scale(.5),e,o,n),o.xPlaneGizmo=new Jo(new u.e(1,0,0),M.a.Red().scale(.5),o.gizmoLayer,o),o.yPlaneGizmo=new Jo(new u.e(0,1,0),M.a.Green().scale(.5),o.gizmoLayer,o),o.zPlaneGizmo=new Jo(new u.e(0,0,1),M.a.Blue().scale(.5),o.gizmoLayer,o),[o.xGizmo,o.yGizmo,o.zGizmo,o.xPlaneGizmo,o.yPlaneGizmo,o.zPlaneGizmo].forEach(function(a){a.dragBehavior.onDragStartObservable.add(function(){o.onDragStartObservable.notifyObservers({})}),a.dragBehavior.onDragEndObservable.add(function(){o.onDragEndObservable.notifyObservers({})})}),o.attachedMesh=null,i?i.addToAxisCache(o._gizmoAxisCache):Ln.a.GizmoAxisPointerObserver(e,o._gizmoAxisCache),o}return Object(c.d)(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=null,[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(){var e=!1;return[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach(function(n){e=e||n.isHovered}),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,"updateGizmoRotationToMatchAttachedMesh",{get:function(){return this._updateGizmoRotationToMatchAttachedMesh},set:function(e){this._updateGizmoRotationToMatchAttachedMesh=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEac
1730h(function(n){n&&(n.updateGizmoRotationToMatchAttachedMesh=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.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.onDragEndObservable.clear()},t.prototype.setCustomMesh=function(e){l.a.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}(Ln.a);ft.a.CreatePolyhedron=function(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,-.9
173069981],[-.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,d=r.type&&(r.type<0||r.type>=t.length)?0:r.type||0,p=r.size,y=r.sizeX||p||1,P=r.sizeY||p||1,O=r.sizeZ||p||1,U=r.custom||t[d],F=U.face.length,z=r.faceUV||new Array(F),J=r.faceColors,ie=r.flat===void 0||r.flat,se=r.sideOrientation===0?0:r.sideOrientation||ft.a.DEFAULTSIDE,ce=new Array,ue=new Array,fe=new Array,ve=new Array,Te=new Array,Oe=0,Pe=0,Ee=new Array,Se=0,Le=0;if(ie)for(Le=0;Le<F;Le++)J&&J[Le]===void 0&&(J[Le]=new M.b(1,1,1,1)),z&&z[Le]===void 0&&(z[Le]=new u.f(0,0,1,1));if(ie)for(Le=0;Le<F;Le++){var xe=U.face[Le].length;for(i=2*Math.PI/xe,o=.5*Math.tan(i/2),a=.5,Se=0;Se<xe;Se++)ce.push(U.vertex[U.face[Le][Se]][0]*y,U.vertex[U.face[Le][Se]][1]*P,U.vertex[U.face[Le][Se]][2]*O),Ee.push(Oe),Oe++,e=z[Le].x+(z[Le].z-z[Le].x)*(.5+o),n=z[Le].y+(z[Le].w-z[Le].y)*(a-.5),ve.push(e,n),s=o*Math.cos(i)-a*Math.sin(i),a=o*Math.sin(i)+a*Math.cos(i),o=s,J&&Te.push(J[Le].r,J[Le].g,J[Le].b,J[Le].a);for(Se=0;Se<xe-2;Se++)ue.push(Ee[0+Pe],Ee[Se+2+Pe],Ee[Se+1+Pe]);Pe+=xe}else{for(Se=0;Se<U.vertex.length;Se++)ce.push(U.vertex[Se][0]*y,U.vertex[Se][1]*P,U.vertex[Se][2]*O),ve.push(0,0);for(Le=0;Le<F;Le++)for(Se=0;Se<U.face[Le].length-2;Se++)ue.push(U.face[Le][0],U.face[Le][Se+2],U.face[Le][Se+1])}ft.a.ComputeNormals(ce,ue,fe),ft.a._ComputeSides(se,ce,ue,fe,ve,r.frontUVs,r.backUVs);var Ne=new ft.a;return Ne.positions=ce,Ne.indices=ue,Ne.normals=fe,Ne.uvs=ve,J&&ie&&(Ne.colors=Te),Ne},De.a.CreatePolyhedron=function(r,t,e){return oo.CreatePolyhedron(r,t,e)};var oo=function(){function r(){}return r.CreatePolyhedron=function(t,e,n){n===void 0&&(n=null);var i=new De.a(t,n);return e.sideOrientation=De.a._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,ft.a.CreatePolyhedron(e).applyToMesh(i,e.updatable),i},r}(),Eu=function(r){function t(e,n,i){e===void 0&&(e=xn.a.DefaultUtilityLayer),n===void 0&&(n=1);var o=r.call(this,e)||this;return o._meshAttached=null,o._nodeAttached=null,o._sensitivity=1,o._observables=[],o._gizmoAxisCache=new Map,o.onDragStartObservable=new x.c,o.onDragEndObservable=new x.c,o.uniformScaleGizmo=o._createUniformScaleMesh(),o.xGizmo=new ro(new u.e(1,0,0),M.a.Red().scale(.5),e,o,n),o.yGizmo=new ro(new u.e(0,1,0),M.a.Green().scale(.5),e,o,n),o.zGizmo=new ro(new u.e(0,0,1),M.a.Blue().scale(.5),e,o,n),[o.xGizmo,o.yGizmo,o.zGizmo,o.uniformScaleGizmo].forEach(function(a){a.dragBehavior.onDragStartObservable.add(function(){o.onDragStartObservable.notifyObservers({})}),a.dragBehavior.onDragEndObservable.add(function(){o.onDragEndObservable.notifyObservers({})})}),o.attachedMesh=null,o.attachedNode=null,i?i.addToAxisCache(o._gizmoAxisCache):Ln.a.GizmoAxisPointerObserver(e,o._gizmoAxisCache),o}return Object(c.d)(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.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})}
1730,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isHovered",{get:function(){var e=!1;return[this.xGizmo,this.yGizmo,this.zGizmo].forEach(function(n){e=e||n.isHovered}),e},enumerable:!1,configurable:!0}),t.prototype._createUniformScaleMesh=function(){this._coloredMaterial=new Ft.a("",this.gizmoLayer.utilityLayerScene),this._coloredMaterial.diffuseColor=M.a.Gray(),this._hoverMaterial=new Ft.a("",this.gizmoLayer.utilityLayerScene),this._hoverMaterial.diffuseColor=M.a.Yellow(),this._disableMaterial=new Ft.a("",this.gizmoLayer.utilityLayerScene),this._disableMaterial.diffuseColor=M.a.Gray(),this._disableMaterial.alpha=.4;var e=new ro(new u.e(0,1,0),M.a.Gray().scale(.5),this.gizmoLayer,this);e.updateGizmoRotationToMatchAttachedMesh=!1,e.uniformScaling=!0,this._uniformScalingMesh=oo.CreatePolyhedron("uniform",{type:1},e.gizmoLayer.utilityLayerScene),this._uniformScalingMesh.scaling.scaleInPlace(.01),this._uniformScalingMesh.visibility=0,this._octahedron=oo.CreatePolyhedron("",{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._uniformScalingMesh],material:this._coloredMaterial,hoverMaterial:this._hoverMaterial,disableMaterial:this._disableMaterial,active:!1};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)})):l.a.Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported.")},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,"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.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.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}(Ln.a),Np=function(){function r(t,e,n,i){e===void 0&&(e=1),n===void 0&&(n=xn.a.DefaultUtilityLayer),i===void 0&&(i=xn.a.DefaultKeepDepthUtilityLayer),this.scene=t,this.clearGizmoOnEmptyPointerEvent=!1,this.onAttachedToMeshObservable=new x.c,this.onAttachedToNodeObservable=new x.c,this._gizmosEnabled={positionGizmo:!1,rotationGizmo:!1,scaleGizmo:!1,boundingBoxGizmo:!1},this._pointerObservers=[],this._attachedMesh=null,this._attachedNode=null,this._boundingBoxColor=M.a.FromHexString("#0984e3"),this._thickness=1,this._gizmoAxisCache=new Map,this.boundingBoxDragBehavior=new Pl,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=Ln.a.GizmoAxisPointerObserver(this._defaultUtilityLayer,this._gizmoAxisCache);this._pointerObservers=[o,a]}return Object.defineProperty(r.prototype,"keepDepthUtilityLayer",{get:function(){return this._defaultKeepDepthUtilityLayer}
1730,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}),r.prototype._attachToMeshPointerObserver=function(t){var e=this;return t.onPointerObservable.add(function(n){if(e.usePointerToAttachGizmos&&n.type==Tt.a.POINTERDOWN)if(n.pickInfo&&n.pickInfo.pickedMesh){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 Dt.a?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 Tu(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},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 yu(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},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 Eu(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},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 bu(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}
1730,enumerable:!1,configurable:!0}),r.prototype.addToAxisCache=function(t){var e=this;t.size>0&&t.forEach(function(n,i){e._gizmoAxisCache.set(i,n)})},r.prototype.dispose=function(){var t=this;for(var e in this._pointerObservers.forEach(function(i){t.scene.onPointerObservable.remove(i)}),this.gizmos){var n=this.gizmos[e];n&&n.dispose()}this._defaultKeepDepthUtilityLayer.dispose(),this._defaultUtilityLayer.dispose(),this.boundingBoxDragBehavior.detach(),this.onAttachedToMeshObservable.clear()},r}(),Ci=f(48),$o=function(r){function t(){var e=r!==null&&r.apply(this,arguments)||this;return e._needProjectionMatrixCompute=!0,e}return Object(c.d)(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=u.e.Zero()),u.e.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),this.transformedPosition),this.direction&&(this.transformedDirection||(this.transformedDirection=u.e.Zero()),u.e.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=u.e.Normalize(e.subtract(this.position)),this.direction},t.prototype.getRotation=function(){this.direction.normalize();var e=u.e.Cross(this.direction,ye.a.Y),n=u.e.Cross(e,this.direction);return u.e.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=u.e.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=u.a.Identity()),u.a.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},Object(c.c)([Object(L.o)()],t.prototype,"position",null),Object(c.c)([Object(L.o)()],t.prototype,"direction",null),Object(c.c)([Object(L.c)()],t.prototype,"shadowMinZ",null),Object(c.c)([Object(L.c)()],t.prototype,"shadowMaxZ",null),t}(Ci.a);Q.a.AddNodeConstructor("Light_Type_1",function(r,t){return function(){return new Ns(r,u.e.Zero(),t)}});var Ns=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 Object(c.d)(t,r),Object.defineProperty(t.prototype,"shadowFrustumSize",{get:function(){return this._shadowFrustumSize},set:function(e){this._shadowFrustumSize=e,this.forceProjectionMatrixCompute()}
1730,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}),t.prototype.getClassName=function(){return"DirectionalLight"},t.prototype.getTypeID=function(){return Ci.a.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&&u.a.OrthoLHToRef(this.shadowFrustumSize,this.shadowFrustumSize,this.shadowMinZ!==void 0?this.shadowMinZ:n.minZ,this.shadowMaxZ!==void 0?this.shadowMaxZ:n.maxZ,e)},t.prototype._setDefaultAutoExtendShadowProjectionMatrix=function(e,n,i){var o=this.getScene().activeCamera;if(o){if(this.autoUpdateExtends||this._orthoLeft===Number.MAX_VALUE){var a=u.e.Zero();this._orthoLeft=Number.MAX_VALUE,this._orthoRight=Number.MIN_VALUE,this._orthoTop=Number.MIN_VALUE,this._orthoBottom=Number.MAX_VALUE;for(var s=Number.MAX_VALUE,d=Number.MIN_VALUE,p=0;p<i.length;p++){var y=i[p];if(y)for(var P=y.getBoundingInfo().boundingBox,O=0;O<P.vectorsWorld.length;O++)u.e.TransformCoordinatesToRef(P.vectorsWorld[O],n,a),a.x<this._orthoLeft&&(this._orthoLeft=a.x),a.y<this._orthoBottom&&(this._orthoBottom=a.y),a.x>this._orthoRight&&(this._orthoRight=a.x),a.y>this._orthoTop&&(this._orthoTop=a.y),this.autoCalcShadowZBounds&&(a.z<s&&(s=a.z),a.z>d&&(d=a.z))}this.autoCalcShadowZBounds&&(this._shadowMinZ=s,this._shadowMaxZ=d)}var U=this._orthoRight-this._orthoLeft,F=this._orthoTop-this._orthoBottom;u.a.OrthoOffCenterLHToRef(this._orthoLeft-U*this.shadowOrthoScale,this._orthoRight+U*this.shadowOrthoScale,this._orthoBottom-F*this.shadowOrthoScale,this._orthoTop+F*this.shadowOrthoScale,this.shadowMinZ!==void 0?this.shadowMinZ:o.minZ,this.shadowMaxZ!==void 0?this.shadowMaxZ:o.maxZ,e)}},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){return 1},t.prototype.getDepthMaxZ=function(e){return 1},t.prototype.prepareLightSpecificDefines=function(e,n){e["DIRLIGHT"+n]=!0},Object(c.c)([Object(L.c)()],t.prototype,"shadowFrustumSize",null),Object(c.c)([Object(L.c)()],t.prototype,"shadowOrthoScale",null),Object(c.c)([Object(L.c)()],t.prototype,"autoUpdateExtends",void 0),Object(c.c)([Object(L.c)()],t.prototype,"autoCalcShadowZBounds",void 0),t}($o);De.a.CreateHemisphere=function(r,t,e,n){var i={segments:t,diameter:e};return ea.CreateHemisphere(r,i,n)};var ea=function(){function r(){}return r.CreateHemisphere=function(t,e,n){e.diameter||(e.diameter=1),e.segments||(e.segments=16);var i=Nn.a.CreateSphere("",{slice:.5,diameter:e.diameter,segments:e.segments},n),o=De.a.CreateDisc("",e.diameter/2,3*e.segments+(4-e.segments),n);o.rotation.x=-Math.PI/2,o.parent=i;var a=De.a.MergeMeshes([o,i],!0);return a.name=t,a},r}();Q.a.AddNodeConstructor("Light_Type_2",function(r,t){return function(){return new ws(r,u.e.Zero(),u.e.Zero(),0,0,t)}});var ws=function(r){function t(e,n,i,o,a,s){var d=r.call(this,e,s)||this;return d._innerAngle=0,d._projectionTextureMatrix=u.a.Zero(),d._projectionTextureLightNear=1e-6,d._projectionTextureLightFar=1e3,d._projectionTextureUpDirection=u.e.Up(),d._projectionTextureViewLightDirty=!0,d._projectionTextureProjectionLightDirty=!0,d._projectionTextureDirty=!0,d._projectionTextureViewTargetVector=u.e.Zero(),d._projectionTextureViewLightMatrix=u.a.Zero(),d._projectionTextureProjectionLightMatrix=u.a.Zero(),d._projectionTextureScalingMatrix=u.a.FromValues(.5,0,0,0,0,.5,0,0,0,0,.5,0,.5,.5,.5,1),d.position=n,d.direction=i,d.angle=o,d.exponent=a,d}return Object(c.d)(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()}
1730,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},t.prototype.getClassName=function(){return"SpotLight"},t.prototype.getTypeID=function(){return Ci.a.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;u.a.PerspectiveFovLHToRef(a,1,this.getDepthMinZ(o),this.getDepthMaxZ(o),e)}},t.prototype._computeProjectionTextureViewLightMatrix=function(){this._projectionTextureViewLightDirty=!1,this._projectionTextureDirty=!0,this.position.addToRef(this.direction,this._projectionTextureViewTargetVector),u.a.LookAtLHToRef(this.position,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);u.a.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 we.a){var e=this._projectionTexture.uScale/2,n=this._projectionTexture.vScale/2;u.a.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.setMatr
1730ix("textureProjectionMatrix"+n,this._projectionTextureMatrix),e.setTexture("projectionLightSampler"+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=u.e.Normalize(this.transformedDirection)):(this._uniformBuffer.updateFloat4("vLightData",this.position.x,this.position.y,this.position.z,this.exponent,n),i=u.e.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()?u.e.Normalize(this.transformedDirection):u.e.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.prepareLightSpecificDefines=function(e,n){e["SPOTLIGHT"+n]=!0,e["PROJECTEDLIGHTTEXTURE"+n]=!(!this.projectionTexture||!this.projectionTexture.isReady())},Object(c.c)([Object(L.c)()],t.prototype,"angle",null),Object(c.c)([Object(L.c)()],t.prototype,"innerAngle",null),Object(c.c)([Object(L.c)()],t.prototype,"shadowAngleScale",null),Object(c.c)([Object(L.c)()],t.prototype,"exponent",void 0),Object(c.c)([Object(L.c)()],t.prototype,"projectionTextureLightNear",null),Object(c.c)([Object(L.c)()],t.prototype,"projectionTextureLightFar",null),Object(c.c)([Object(L.c)()],t.prototype,"projectionTextureUpDirection",null),Object(c.c)([Object(L.m)("projectedLightTexture")],t.prototype,"_projectionTexture",void 0),t}($o),wp=function(r){function t(e){e===void 0&&(e=xn.a.DefaultUtilityLayer);var n=r.call(this,e)||this;return n._cachedPosition=new u.e,n._cachedForward=new u.e(0,0,1),n._pointerObserver=null,n.onClickedObservable=new x.c,n._light=null,n.attachedMesh=new Dt.a("",n.gizmoLayer.utilityLayerScene),n._attachedMeshParent=new Tr.a("parent",n.gizmoLayer.utilityLayerScene),n.attachedMesh.parent=n._attachedMeshParent,n._material=new Ft.a("light",n.gizmoLayer.utilityLayerScene),n._material.diffuseColor=new M.a(.5,.5,.5),n._material.specularColor=new M.a(.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))},Tt.a.POINTERDOWN),n}return Object(c.d)(t,r),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(),e instanceof zo.a?this._lightMesh=t._CreateHemisphericLightMesh(this.gizmoLayer.utilityLayerScene):this._lightMesh=e instanceof Ns?t._CreateDirectionalLightMesh(this.gizmoLayer.utilityLayerScene):e instanceof ws?t._CreateSpotLightMesh(this.gizmoLayer.utilityLayerScene):t._CreatePointLightMesh(this.gizmoLayer.utilityLayerScene),this._lightMesh.getChildMeshes(!1).forEach(function(o){o.material=n._material}),this._lightMesh.parent=this._rootMesh;var i=this.gizmoLayer._getSharedGizmoLight();i.includedOnlyMeshes=i.includedOnlyMeshes.concat(this._lightMesh.getChildMeshes(!1)),this._lightMesh.rotationQuaternion=new u.b,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),this._cachedForward.copyFrom(this.attachedMesh.forward)),this._update()}}
1730,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._light&&(this._light.parent&&this._attachedMeshParent.freezeWorldMatrix(this._light.parent.getWorldMatrix()),this._light.position&&(this.attachedMesh.position.equals(this._cachedPosition)?(this.attachedMesh.position.copyFrom(this._light.position),this.attachedMesh.computeWorldMatrix(!0),this._cachedPosition.copyFrom(this.attachedMesh.position)):(this._light.position.copyFrom(this.attachedMesh.position),this._cachedPosition.copyFrom(this.attachedMesh.position))),this._light.direction&&(u.e.DistanceSquared(this.attachedMesh.forward,this._cachedForward)>1e-4?(this._light.direction.copyFrom(this.attachedMesh.forward),this._cachedForward.copyFrom(this.attachedMesh.forward)):u.e.DistanceSquared(this.attachedMesh.forward,this._light.direction)>1e-4&&(this.attachedMesh.setDirection(this._light.direction),this.attachedMesh.computeWorldMatrix(!0),this._cachedForward.copyFrom(this.attachedMesh.forward))))},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 De.a("hemisphereLight",e),i=ea.CreateHemisphere(n.name,{segments:10,diameter:1},e);i.position.z=-.15,i.rotation.x=Math.PI/2,i.parent=n;var o=this._CreateLightLines(3,e);return o.parent=n,o.position.z,n.scaling.scaleInPlace(t._Scale),n.rotation.x=Math.PI/2,n},t._CreatePointLightMesh=function(e){var n=new De.a("pointLight",e),i=Nn.a.CreateSphere(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 De.a("spotLight",e);Nn.a.CreateSphere(n.name,{segments:10,diameter:1},e).parent=n;var i=ea.CreateHemisphere(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 De.a("directionalLight",e),i=new De.a(n.name,e);i.parent=n,Nn.a.CreateSphere(n.name,{diameter:1.2,segments:10},e).parent=i;var o=De.a.CreateCylinder(n.name,6,.3,.3,6,1,e);o.parent=i,(a=o.clone(n.name)).scaling.y=.5,a.position.x+=1.25,(s=o.clone(n.name)).scaling.y=.5,s.position.x+=-1.25;var a,s,d=De.a.CreateCylinder(n.name,1,0,.6,6,1,e);return d.position.y+=3,d.parent=i,(a=d.clone(n.name)).position.y=1.5,a.position.x+=1.25,(s=d.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 De.a("root",n);i.rotation.x=Math.PI/2;var o=new De.a("linePivot",n);o.parent=i;var a=De.a.CreateCylinder("line",2,.2,.3,6,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++)(d=o.clone("lineParentClone")).rotation.z=Math.PI/4,d.rotation.y=Math.PI/2+Math.PI/2*s,d.getChildMeshes()[0].scaling.y=.5,d.getChildMeshes()[0].scaling.x=d.getChildMeshes()[0].scaling.z=.8,d.getChildMeshes()[0].position.y=d.getChildMeshes()[0].scaling.y/2+1.2;if(e<3)return i;for(s=0;s<4;s++)(d=o.clone("linePivotClone")).rotation.z=Math.PI/2,d.rotation.y=Math.PI/2*s;if(e<4)return i;for(s=0;s<4;s++){var d;(d=o.clone("linePivotClone")).rotation.z=Math.PI+Math.PI/4,d.rotation.y=Math.PI/2+Math.PI/2*s,d.getChildMeshes()[0].scaling.y=.5,d.getChildMeshes()[0].scaling.x=d.getChildMeshes()[0].scaling.z=.8,d.getChildMeshes()[0].position.y=d.getChildMeshes()[0].scaling.y/2+1.2}return e<5||((d=o.clone("linePivotClone")).rotation.z=Math.PI),i},t}(Ln.a),Fs=function(){function r(t,e){t===void 0&&(t=u.e.Zero()),e===void 0&&(e=u.e.Up()),this.position=t,this.normal=e}return r.prototype.clone=function(){return new r(this.position.clone(),this.normal.clone())},r}(),Fp=function(){function r(t,e,n){t===void 0&&(t=u.e.Zero()),e===void 0&&(e=u.e.Up()),n===void 0&&(n=u.d.Zero()),this.position=t,this.normal=e,this.uv=n}return r.prototype.clone=function(){return new r(this.position.clone(),this.normal.clone(),this.uv.clone())},r}(),Bp=function(r){function t(e){e===void 0&&(e=xn.a.DefaultUtilityLayer);var n=r.call(this,e)||this;return n._pointerObserver=null,n.onClickedObservable=new x.c,n._camera=null,n._invProjection=new u.a,n._material=new Ft.a("cameraGizmoMaterial",n.gizmoLayer.utilityLayerScene),n._material.diffuseColor=new M.a(.5,.5,.5),n._material.specularColor=new M.a(.1,.1,.1),n._pointerObserver=e.utilityLayerScene.onPointerObservable.add(function(i){n._c
1730amera&&(n._isHovered=!(!i.pickInfo||n._rootMesh.getChildMeshes().indexOf(i.pickInfo.pickedMesh)==-1),n._isHovered&&i.event.button===0&&n.onClickedObservable.notifyObservers(n._camera))},Tt.a.POINTERDOWN),n}return Object(c.d)(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=this;if(this._camera=e,this.attachedNode=e,e){this._cameraMesh&&this._cameraMesh.dispose(),this._cameraLinesMesh&&this._cameraLinesMesh.dispose(),this._cameraMesh=t._CreateCameraMesh(this.gizmoLayer.utilityLayerScene),this._cameraLinesMesh=t._CreateCameraFrustum(this.gizmoLayer.utilityLayerScene),this._cameraMesh.getChildMeshes(!1).forEach(function(o){o.material=n._material}),this._cameraMesh.parent=this._rootMesh,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 i=this.gizmoLayer._getSharedGizmoLight();i.includedOnlyMeshes=i.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.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 De.a("rootCameraGizmo",e),i=new De.a(n.name,e);i.parent=n,yr.a.CreateBox(n.name,{width:1,height:.8,depth:.5},e).parent=i;var o=ui.a.CreateCylinder(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=ui.a.CreateCylinder(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=ui.a.CreateCylinder(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){var n=new De.a("rootCameraGizmo",e),i=new De.a(n.name,e);i.parent=n;for(var o=0;o<4;o+=2)for(var a=0;a<4;a+=2){var s;(s=cn.a.CreateLines("lines",{points:[new u.e(-1+a,-1+o,-1),new u.e(-1+a,-1+o,1)]},e)).parent=i,s.alwaysSelectAsActiveMesh=!0,s.isPickable=!1,(s=cn.a.CreateLines("lines",{points:[new u.e(-1,-1+a,-1+o),new u.e(1,-1+a,-1+o)]},e)).parent=i,s.alwaysSelectAsActiveMesh=!0,s.isPickable=!1,(s=cn.a.CreateLines("lines",{points:[new u.e(-1+a,-1,-1+o),new u.e(-1+a,1,-1+o)]},e)).parent=i,s.alwaysSelectAsActiveMesh=!0,s.isPickable=!1}return n},t._Scale=.05,t}(Ln.a);je.a.IncludesShadersStore.kernelBlurVaryingDeclaration="varying vec2 sampleCoord{X};";var Up=`vec4 pack(float depth)
1731{
1732const vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);
1733const vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);
1734vec4 res=fract(depth*bit_shift);
1735res-=res.xxyz*bit_mask;
1736return res;
1737}
1738float unpack(vec4 color)
1739{
1740const vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);
1741return dot(color,bit_shift);
1742}`;je.a.IncludesShadersStore.packingFunctions=Up;var Vp=`#ifdef DOF
1743factor=sampleCoC(sampleCoord{X});
1744computedWeight=KERNEL_WEIGHT{X}*factor;
1745sumOfWeights+=computedWeight;
1746#else
1747computedWeight=KERNEL_WEIGHT{X};
1748#endif
1749#ifdef PACKEDFLOAT
1750blend+=unpack(texture2D(textureSampler,sampleCoord{X}))*computedWeight;
1751#else
1752blend+=texture2D(textureSampler,sampleCoord{X})*computedWeight;
1753#endif`;je.a.IncludesShadersStore.kernelBlurFragment=Vp;var kp=`#ifdef DOF
1754factor=sampleCoC(sampleCenter+delta*KERNEL_DEP_OFFSET{X});
1755computedWeight=KERNEL_DEP_WEIGHT{X}*factor;
1756sumOfWeights+=computedWeight;
1757#else
1758computedWeight=KERNEL_DEP_WEIGHT{X};
1759#endif
1760#ifdef PACKEDFLOAT
1761blend+=unpack(texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X}))*computedWeight;
1762#else
1763blend+=texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X})*computedWeight;
1764#endif`;je.a.IncludesShadersStore.kernelBlurFragment2=kp;var Gp=`
1765uniform sampler2D textureSampler;
1766uniform vec2 delta;
1767
1768varying vec2 sampleCenter;
1769#ifdef DOF
1770uniform sampler2D circleOfConfusionSampler;
1771uniform vec2 cameraMinMaxZ;
1772float sampleDistance(const in vec2 offset) {
1773float depth=texture2D(circleOfConfusionSampler,offset).g;
1774return cameraMinMaxZ.x+(cameraMinMaxZ.y-cameraMinMaxZ.x)*depth;
1775}
1776float sampleCoC(const in vec2 offset) {
1777float coc=texture2D(circleOfConfusionSampler,offset).r;
1778return coc;
1779}
1780#endif
1781#include<kernelBlurVaryingDeclaration>[0..varyingCount]
1782#ifdef PACKEDFLOAT
1783#include<packingFunctions>
1784#endif
1785void main(void)
1786{
1787float computedWeight=0.0;
1788#ifdef PACKEDFLOAT
1789float blend=0.;
1790#else
1791vec4 blend=vec4(0.);
1792#endif
1793#ifdef DOF
1794float sumOfWeights=CENTER_WEIGHT;
1795float factor=0.0;
1796
1797#ifdef PACKEDFLOAT
1798blend+=unpack(texture2D(textureSampler,sampleCenter))*CENTER_WEIGHT;
1799#else
1800blend+=texture2D(textureSampler,sampleCenter)*CENTER_WEIGHT;
1801#endif
1802#endif
1803#include<kernelBlurFragment>[0..varyingCount]
1804#include<kernelBlurFragment2>[0..depCount]
1805#ifdef PACKEDFLOAT
1806gl_FragColor=pack(blend);
1807#else
1808gl_FragColor=blend;
1809#endif
1810#ifdef DOF
1811gl_FragColor/=sumOfWeights;
1812#endif
1813}`;je.a.ShadersStore.kernelBlurPixelShader=Gp,je.a.IncludesShadersStore.kernelBlurVertex="sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";var zp=`
1814attribute vec2 position;
1815
1816uniform vec2 delta;
1817
1818varying vec2 sampleCenter;
1819#include<kernelBlurVaryingDeclaration>[0..varyingCount]
1820const vec2 madd=vec2(0.5,0.5);
1821void main(void) {
1822sampleCenter=(position*madd+madd);
1823#include<kernelBlurVertex>[0..varyingCount]
1824gl_Position=vec4(position,0.0,1.0);
1825}`;je.a.ShadersStore.kernelBlurVertexShader=zp;var _n=function(r){function t(e,n,i,o,a,s,d,p,y,P,O){s===void 0&&(s=we.a.BILINEAR_SAMPLINGMODE),y===void 0&&(y=h.a.TEXTURETYPE_UNSIGNED_INT),P===void 0&&(P=""),O===void 0&&(O=!1);var U=r.call(this,e,"kernelBlur",["delta","direction","cameraMinMaxZ"],["circleOfConfusionSampler"],o,a,s,d,p,null,y,"kernelBlur",{varyingCount:0,depCount:0},!0)||this;return U.blockCompilation=O,U._packedFloat=!1,U._staticDefines="",U._staticDefines=P,U.direction=n,U.onApplyObservable.add(function(F){U._outputTexture?F.setFloat2("delta",1/U._outputTexture.width*U.direction.x,
18251/U._outputTexture.height*U.direction.y):F.setFloat2("delta",1/U.width*U.direction.x,1/U.height*U.direction.y)}),U.kernel=i,U}return Object(c.d)(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.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=[],d=0,p=0;p<i;p++){var y=p/(i-1),P=this._gaussianWeight(2*y-1);a[p]=p-o,s[p]=P,d+=P}for(p=0;p<s.length;p++)s[p]/=d;var O=[],U=[],F=[];for(p=0;p<=o;p+=2){var z=Math.min(p+1,Math.floor(o));if(p===z)F.push({o:a[p],w:s[p]});else{var J=z===o,ie=s[p]+s[z]*(J?.5:1),se=a[p]+1/(1+s[p]/s[z]);se===0?(F.push({o:a[p],w:s[p]}),F.push({o:a[p+1],w:s[p+1]})):(F.push({o:se,w:ie}),F.push({o:-se,w:ie}))}}for(p=0;p<F.length;p++)U[p]=F[p].o,O[p]=F[p].w;a=U,s=O;var ce=this.getEngine().getCaps().maxVaryingVectors,ue=Math.max(ce,0)-1,fe=Math.min(a.length,ue),ve="";for(ve+=this._staticDefines,this._staticDefines.indexOf("DOF")!=-1&&(ve+="#define CENTER_WEIGHT "+this._glslFloat(s[fe-1])+`\r
1826`,fe--),p=0;p<fe;p++)ve+="#define KERNEL_OFFSET"+p+" "+this._glslFloat(a[p])+`\r
1827`,ve+="#define KERNEL_WEIGHT"+p+" "+this._glslFloat(s[p])+`\r
1828`;var Te=0;for(p=ue;p<a.length;p++)ve+="#define KERNEL_DEP_OFFSET"+Te+" "+this._glslFloat(a[p])+`\r
1829`,ve+="#define KERNEL_DEP_WEIGHT"+Te+" "+this._glslFloat(s[p])+`\r
1830`,Te++;this.packedFloat&&(ve+="#define PACKEDFLOAT 1"),this.blockCompilation=!1,r.prototype.updateEffect.call(this,ve,null,null,{varyingCount:fe,depCount:Te},e,n)},t.prototype._nearestBestKernel=function(e){for(var n=Math.round(e),i=0,o=[n,n-1,n+1,n-2,n+2];i<o.length;i++){var a=o[i];if(a%2!=0&&Math.floor(a/2)%2==0&&a>0)return Math.max(a,3)}return Math.max(n,3)},t.prototype._gaussianWeight=function(e){var n=-e*e/.2222222222222222;return 1/(Math.sqrt(2*Math.PI)*(1/3))*Math.exp(n)},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 L.a.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)},Object(c.c)([Object(L.c)("kernel")],t.prototype,"_kernel",void 0),Object(c.c)([Object(L.c)("packedFloat")],t.prototype,"_packedFloat",void 0),Object(c.c)([Object(L.n)()],t.prototype,"direction",void 0),t}(_t);R.a.RegisteredTypes["BABYLON.BlurPostProcess"]=_n;var Bs=function(r){function t(e,n,i,o,a,s,d){a===void 0&&(a=h.a.TEXTURETYPE_UNSIGNED_INT),s===void 0&&(s=we.a.BILINEAR_SAMPLINGMODE),d===void 0&&(d=!0);var p=r.call(this,e,n,i,o,!0,a,!1,s,d)||this;return p.scene=i,p.mirrorPlane=new gr.a(0,1,0,1),p._transformMatrix=u.a.Zero(),p._mirrorMatrix=u.a.Zero(),p._adaptiveBlurKernel=0,p._blurKernelX=0,p._blurKernelY=0,p._blurRatio=1,p.ignoreCameraViewport=!0,p._updateGammaSpace(),p._imageProcessingConfigChangeObserver=i.imageProcessingConfiguration.onUpdateParameters.add(function(){p._updateGammaSpace}),p.onBeforeRenderObservable.add(function(){u.a.ReflectionToRef(p.mirrorPlane,p._mirrorMatrix),p._savedViewMatrix=i.getViewMatrix(),p._mirrorMatrix.multiplyToRef(p._savedViewMatrix,p._transformMatrix),i.setTransformMatrix(p._transformMatrix,i.getProjectionMatrix()),i.clipPlane=p.mirrorPlane,i.getEngine().cullBackFaces=!1,i._mirroredCameraPosition=u.e.TransformCoordinates(i.activeCamera.globalPosition,p._mirrorMatrix)}),p.onAfterRenderObservable.add(function(){i.setTransformMatrix(p._savedViewMatrix,i.getProjectionMatrix()),i.getEngine().cullBackFaces=!0,i._mirroredCameraPosition=null,i.clipPlane=null}),p}return Object(c.d)(t,r),Object.defineProperty(t.prototype,"blurRatio",{get:function(){return this._blurRatio},set:function(e){this._blurRatio!==e&&(this._blurRatio=e,this._preparePostProcesses())}
1830,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(){this.gammaSpace=!this.scene.imageProcessingConfiguration.isEnabled||!this.scene.imageProcessingConfiguration.applyByPostProcess},t.prototype._preparePostProcesses=function(){if(this.clearPostProcesses(!0),this._blurKernelX&&this._blurKernelY){var e=this.getScene().getEngine(),n=e.getCaps().textureFloatRender?h.a.TEXTURETYPE_FLOAT:h.a.TEXTURETYPE_HALF_FLOAT;this._blurX=new _n("horizontal blur",new u.d(1,0),this._blurKernelX,this._blurRatio,null,we.a.BILINEAR_SAMPLINGMODE,e,!1,n),this._blurX.autoClear=!1,this._blurRatio===1&&this.samples<2&&this._texture?this._blurX.inputTexture=this._texture:this._blurX.alwaysForcePOT=!0,this._blurY=new _n("vertical blur",new u.d(0,1),this._blurKernelY,this._blurRatio,null,we.a.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(){r.prototype.dispose.call(this),this.scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver)},t}(sn);we.a._CreateMirror=function(r,t,e,n){return new Bs(r,t,e,n)};var Xn=f(34),ni=function(r){function t(e,n,i,o,a,s,d,p,y,P,O,U,F,z){var J;i===void 0&&(i=null),o===void 0&&(o=!1),a===void 0&&(a=null),s===void 0&&(s=null),d===void 0&&(d=null),p===void 0&&(p=h.a.TEXTUREFORMAT_RGBA),y===void 0&&(y=!1),P===void 0&&(P=null),O===void 0&&(O=!1),U===void 0&&(U=.8),F===void 0&&(F=0);var ie=r.call(this,n)||this;if(ie.onLoadObservable=new x.c,ie.boundingBoxPosition=u.e.Zero(),ie._rotationY=0,ie._files=null,ie._forcedExtension=null,ie._extensions=null,ie.name=e,ie.url=e,ie._noMipmap=o,ie.hasAlpha=!1,ie._format=p,ie.isCube=!0,ie._textureMatrix=u.a.Identity(),ie._createPolynomials=O,ie.coordinatesMode=we.a.CUBIC_MODE,ie._extensions=i,ie._files=a,ie._forcedExtension=P,ie._loaderOptions=z,!e&&!a)return ie;var se=e.lastIndexOf("."),ce=P||(se>-1?e.substring(se).toLowerCase():""),ue=ce===".dds",fe=ce===".env";if(fe?(ie.gammaSpace=!1,ie._prefiltered=!1,ie.anisotropicFilteringLevel=1):(ie._prefiltered=y,y&&(ie.gammaSpace=!1,ie.anisotropicFilteringLevel=1)),ie._texture=ie._getFromCache(e,o),!a&&(fe||ue||i||(i=["_px.jpg","_py.jpg","_pz.jpg","_nx.jpg","_ny.jpg","_nz.jpg"]),a=[],i))for(var ve=0;ve<i.length;ve++)a.push(e+i[ve]);ie._files=a;var Te=function(){ie.onLoadObservable.notifyObservers(ie),s&&s()};if(ie._texture)ie._texture.isReady?Ye.b.SetImmediate(function(){return Te()}):ie._texture.onLoadedObservable.add(function(){return Te()});else{var Oe=ie.getScene();Oe?.useDelayedTextureLoading?ie.delayLoadState=h.a.DELAYLOADSTATE_NOTLOADED:(ie._texture=y?ie._getEngine().createPrefilteredCubeTexture(e,Oe,U,F,s,d,p,P,ie._createPolynomials):ie._getEngine().createCubeTexture(e,Oe,a,o,s,d,ie._format,P,!1,U,F,null,z),(J=ie._texture)===null||J===void 0||J.onLoadedObservable.add(function(){return ie.onLoadObservable.notifyObservers(ie)}))}return ie}return Object(c.d)(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(h.a.MATERIAL_TextureDirtyFlag)}}
1830,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotationY",{get:function(){return this._rotationY},set:function(e){this._rotationY=e,this.setReflectionTextureMatrix(u.a.RotationY(this._rotationY))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"noMipmap",{get:function(){return this._noMipmap},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){var a;o===void 0&&(o=!1),this.url&&(this.releaseInternalTexture(),(a=this.getScene())===null||a===void 0||a.markAllMaterialsAsDirty(h.a.MATERIAL_TextureDirtyFlag)),this.name&&!Xn.a.StartsWith(this.name,"data:")||(this.name=e),this.url=e,this.delayLoadState=h.a.DELAYLOADSTATE_NOTLOADED,this._prefiltered=o,this._prefiltered&&(this.gammaSpace=!1,this.anisotropicFilteringLevel=1),this._forcedExtension=n||null,i&&(this._delayedOnLoad=i),this.delayLoad(n)},t.prototype.delayLoad=function(e){var n,i=this;if(this.delayLoadState===h.a.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=h.a.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap),!this._texture)){var o=this.getScene();this._prefiltered?this._texture=this._getEngine().createPrefilteredCubeTexture(this.url,o,.8,0,this._delayedOnLoad,void 0,this._format,e,this._createPolynomials):this._texture=this._getEngine().createCubeTexture(this.url,o,this._files,this._noMipmap,this._delayedOnLoad,null,this._format,e,!1,0,0,null,this._loaderOptions),(n=this._texture)===null||n===void 0||n.onLoadedObservable.add(function(){return i.onLoadObservable.notifyObservers(i)})}},t.prototype.getReflectionTextureMatrix=function(){return this._textureMatrix},t.prototype.setReflectionTextureMatrix=function(e){var n,i=this;e.updateFlag!==this._textureMatrix.updateFlag&&(e.isIdentity()!==this._textureMatrix.isIdentity()&&((n=this.getScene())===null||n===void 0||n.markAllMaterialsAsDirty(h.a.MATERIAL_TextureDirtyFlag,function(o){return o.getActiveTextures().indexOf(i)!==-1})),this._textureMatrix=e)},t.Parse=function(e,n,i){var o=L.a.Parse(function(){var p=!1;return e.prefiltered&&(p=e.prefiltered),new t(i+e.name,n,e.extensions,!1,e.files||null,null,null,void 0,p,e.forcedExtension)},e,n);if(e.boundingBoxPosition&&(o.boundingBoxPosition=u.e.FromArray(e.boundingBoxPosition)),e.boundingBoxSize&&(o.boundingBoxSize=u.e.FromArray(e.boundingBoxSize)),e.animations)for(var a=0;a<e.animations.length;a++){var s=e.animations[a],d=R.a.GetClass("BABYLON.Animation");d&&o.animations.push(d.Parse(s))}return o},t.prototype.clone=function(){var e=this,n=0,i=L.a.Clone(function(){var o=new t(e.url,e.getScene()||e._getEngine(),e._extensions,e._noMipmap,e._files);return n=o.uniqueId,o},this);return i.uniqueId=n,i},Object(c.c)([Object(L.c)()],t.prototype,"url",void 0),Object(c.c)([Object(L.c)("rotationY")],t.prototype,"rotationY",null),Object(c.c)([Object(L.c)("files")],t.prototype,"_files",void 0),Object(c.c)([Object(L.c)("forcedExtension")],t.prototype,"_forcedExtension",void 0),Object(c.c)([Object(L.c)("extensions")],t.prototype,"_extensions",void 0),Object(c.c)([Object(L.j)("textureMatrix")],t.prototype,"_textureMatrix",void 0),t}(zn.a);we.a._CubeTextureParser=ni.Parse,R.a.RegisteredTypes["BABYLON.CubeTexture"]=ni;var tt=f(15),ta=f(76),na=f(87),ht=f(19),jp=` uniform vec4 vPrimaryColor;
1831#ifdef USEHIGHLIGHTANDSHADOWCOLORS
1832uniform vec4 vPrimaryColorShadow;
1833#endif
1834uniform float shadowLevel;
1835uniform float alpha;
1836#ifdef DIFFUSE
1837uniform vec2 vDiffuseInfos;
1838#endif
1839#ifdef REFLECTION
1840uniform vec2 vReflectionInfos;
1841uniform mat4 reflectionMatrix;
1842uniform vec3 vReflectionMicrosurfaceInfos;
1843#endif
1844#if defined(REFLECTIONFRESNEL) || defined(OPACITYFRESNEL)
1845uniform vec3 vBackgroundCenter;
1846#endif
1847#ifdef REFLECTIONFRESNEL
1848uniform vec4 vReflectionControl;
1849#endif
1850#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)
1851uniform mat4 view;
1852#endif`;je.a.IncludesShadersStore.backgroundFragmentDeclaration=jp;var Hp=`layout(std140,column_major) uniform;
1853uniform Material
1854{
1855uniform vec4 vPrimaryColor;
1856uniform vec4 vPrimaryColorShadow;
1857uniform vec2 vDiffuseInfos;
1858uniform vec2 vReflectionInfos;
1859uniform mat4 diffuseMatrix;
1860uniform mat4 reflectionMatrix;
1861uniform vec3 vReflectionMicrosurfaceInfos;
1862uniform float fFovMultiplier;
1863uniform float pointSize;
1864uniform float shadowLevel;
1865uniform float alpha;
1866#if defined(REFLECTIONFRESNEL) || defined(OPACITYFRESNEL)
1867uniform vec3 vBackgroundCenter;
1868#endif
1869#ifdef REFLECTIONFRESNEL
1870uniform vec4 vReflectionControl;
1871#endif
1872};
1873uniform Scene {
1874mat4 viewProjection;
1875#ifdef MULTIVIEW
1876mat4 viewProjectionR;
1877#endif
1878mat4 view;
1879};`;je.a.IncludesShadersStore.backgroundUboDeclaration=Hp,f(131),f(106),f(107),f(154),f(130),f(115),f(125),f(110),f(135),f(136);var Wp=`#ifdef TEXTURELODSUPPORT
1880#extension GL_EXT_shader_texture_lod : enable
1881#endif
1882precision highp float;
1883#include<__decl__backgroundFragment>
1884#define RECIPROCAL_PI2 0.15915494
1885
1886uniform vec3 vEyePosition;
1887
1888varying vec3 vPositionW;
1889#ifdef MAINUV1
1890varying vec2 vMainUV1;
1891#endif
1892#ifdef MAINUV2
1893varying vec2 vMainUV2;
1894#endif
1895#ifdef NORMAL
1896varying vec3 vNormalW;
1897#endif
1898#ifdef DIFFUSE
1899#if DIFFUSEDIRECTUV == 1
1900#define vDiffuseUV vMainUV1
1901#elif DIFFUSEDIRECTUV == 2
1902#define vDiffuseUV vMainUV2
1903#else
1904varying vec2 vDiffuseUV;
1905#endif
1906uniform sampler2D diffuseSampler;
1907#endif
1908
1909#ifdef REFLECTION
1910#ifdef REFLECTIONMAP_3D
1911#define sampleReflection(s,c) textureCube(s,c)
1912uniform samplerCube reflectionSampler;
1913#ifdef TEXTURELODSUPPORT
1914#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)
1915#else
1916uniform samplerCube reflectionSamplerLow;
1917uniform samplerCube reflectionSamplerHigh;
1918#endif
1919#else
1920#define sampleReflection(s,c) texture2D(s,c)
1921uniform sampler2D reflectionSampler;
1922#ifdef TEXTURELODSUPPORT
1923#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)
1924#else
1925uniform samplerCube reflectionSamplerLow;
1926uniform samplerCube reflectionSamplerHigh;
1927#endif
1928#endif
1929#ifdef REFLECTIONMAP_SKYBOX
1930varying vec3 vPositionUVW;
1931#else
1932#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
1933varying vec3 vDirectionW;
1934#endif
1935#endif
1936#include<reflectionFunction>
1937#endif
1938
1939#ifndef FROMLINEARSPACE
1940#define FROMLINEARSPACE;
1941#endif
1942
1943#ifndef SHADOWONLY
1944#define SHADOWONLY;
1945#endif
1946#include<imageProcessingDeclaration>
1947
1948#include<__decl__lightFragment>[0..maxSimultaneousLights]
1949#include<helperFunctions>
1950#include<lightsFragmentFunctions>
1951#include<shadowsFragmentFunctions>
1952#include<imageProcessingFunctions>
1953#include<clipPlaneFragmentDeclaration>
1954
1955#include<fogFragmentDeclaration>
1956#ifdef REFLECTIONFRESNEL
1957#define FRESNEL_MAXIMUM_ON_ROUGH 0.25
1958vec3 fresnelSchlickEnvironmentGGX(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)
1959{
1960
1961float weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);
1962return reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));
1963}
1964#endif
1965void main(void) {
1966#include<clipPlaneFragment>
1967vec3 viewDirectionW=normalize(vEyePosition-vPositionW);
1968
1969#ifdef NORMAL
1970vec3 normalW=normalize(vNormalW);
1971#else
1972vec3 normalW=vec3(0.0,1.0,0.0);
1973#endif
1974
1975float shadow=1.;
1976float globalShadow=0.;
1977float shadowLightCount=0.;
1978#include<lightFragment>[0..maxSimultaneousLights]
1979#ifdef SHADOWINUSE
1980globalShadow/=shadowLightCount;
1981#else
1982globalShadow=1.0;
1983#endif
1984#ifndef BACKMAT_SHADOWONLY
1985
1986vec4 reflectionColor=vec4(1.,1.,1.,1.);
1987#ifdef REFLECTION
1988vec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);
1989#ifdef REFLECTIONMAP_OPPOSITEZ
1990reflectionVector.z*=-1.0;
1991#endif
1992
1993#ifdef REFLECTIONMAP_3D
1994vec3 reflectionCoords=reflectionVector;
1995#else
1996vec2 reflectionCoords=reflectionVector.xy;
1997#ifdef REFLECTIONMAP_PROJECTION
1998reflectionCoords/=reflectionVector.z;
1999#endif
2000reflectionCoords.y=1.0-reflectionCoords.y;
2001#endif
2002#ifdef REFLECTIONBLUR
2003float reflectionLOD=vReflectionInfos.y;
2004#ifdef TEXTURELODSUPPORT
2005
2006reflectionLOD=reflectionLOD*log2(vReflectionMicrosurfaceInfos.x)*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;
2007reflectionColor=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);
2008#else
2009float lodReflectionNormalized=saturate(reflectionLOD);
2010float lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;
2011vec4 reflectionSpecularMid=sampleReflection(reflectionSampler,reflectionCoords);
2012if(lodReflectionNormalizedDoubled<1.0){
2013reflectionColor=mix(
2014sampleReflection(reflectionSamplerHigh,reflectionCoords),
2015reflectionSpecularMid,
2016lodReflectionNormalizedDoubled
2017);
2018} else {
2019reflectionColor=mix(
2020reflectionSpecularMid,
2021sampleReflection(reflectionSamplerLow,reflectionCoords),
2022lodReflectionNormalizedDoubled-1.0
2023);
2024}
2025#endif
2026#else
2027vec4 reflectionSample=sampleReflection(reflectionSampler,reflectionCoords);
2028reflectionColor=reflectionSample;
2029#endif
2030#ifdef RGBDREFLECTION
2031reflectionColor.rgb=fromRGBD(reflectionColor);
2032#endif
2033#ifdef GAMMAREFLECTION
2034reflectionColor.rgb=toLinearSpace(reflectionColor.rgb);
2035#endif
2036#ifdef REFLECTIONBGR
2037reflectionColor.rgb=reflectionColor.bgr;
2038#endif
2039
2040reflectionColor.rgb*=vReflectionInfos.x;
2041#endif
2042
2043vec3 diffuseColor=vec3(1.,1.,1.);
2044float finalAlpha=alpha;
2045#ifdef DIFFUSE
2046vec4 diffuseMap=texture2D(diffuseSampler,vDiffuseUV);
2047#ifdef GAMMADIFFUSE
2048diffuseMap.rgb=toLinearSpace(diffuseMap.rgb);
2049#endif
2050
2051diffuseMap.rgb*=vDiffuseInfos.y;
2052#ifdef DIFFUSEHASALPHA
2053finalAlpha*=diffuseMap.a;
2054#endif
2055diffuseColor=diffuseMap.rgb;
2056#endif
2057
2058#ifdef REFLECTIONFRESNEL
2059vec3 colorBase=diffuseColor;
2060#else
2061vec3 colorBase=reflectionColor.rgb*diffuseColor;
2062#endif
2063colorBase=max(colorBase,0.0);
2064
2065#ifdef USERGBCOLOR
2066vec3 finalColor=colorBase;
2067#else
2068#ifdef USEHIGHLIGHTANDSHADOWCOLORS
2069vec3 mainColor=mix(vPrimaryColorShadow.rgb,vPrimaryColor.rgb,colorBase);
2070#else
2071vec3 mainColor=vPrimaryColor.rgb;
2072#endif
2073vec3 finalColor=colorBase*mainColor;
2074#endif
2075
2076#ifdef REFLECTIONFRESNEL
2077vec3 reflectionAmount=vReflectionControl.xxx;
2078vec3 reflectionReflectance0=vReflectionControl.yyy;
2079vec3 reflectionReflectance90=vReflectionControl.zzz;
2080float VdotN=dot(normalize(vEyePosition),normalW);
2081vec3 planarReflectionFresnel=fresnelSchlickEnvironmentGGX(saturate(VdotN),reflectionReflectance0,reflectionReflectance90,1.0);
2082reflectionAmount*=planarReflectionFresnel;
2083#ifdef REFLECTIONFALLOFF
2084float reflectionDistanceFalloff=1.0-saturate(length(vPositionW.xyz-vBackgroun
2084dCenter)*vReflectionControl.w);
2085reflectionDistanceFalloff*=reflectionDistanceFalloff;
2086reflectionAmount*=reflectionDistanceFalloff;
2087#endif
2088finalColor=mix(finalColor,reflectionColor.rgb,saturate(reflectionAmount));
2089#endif
2090#ifdef OPACITYFRESNEL
2091float viewAngleToFloor=dot(normalW,normalize(vEyePosition-vBackgroundCenter));
2092
2093const float startAngle=0.1;
2094float fadeFactor=saturate(viewAngleToFloor/startAngle);
2095finalAlpha*=fadeFactor*fadeFactor;
2096#endif
2097
2098#ifdef SHADOWINUSE
2099finalColor=mix(finalColor*shadowLevel,finalColor,globalShadow);
2100#endif
2101
2102vec4 color=vec4(finalColor,finalAlpha);
2103#else
2104vec4 color=vec4(vPrimaryColor.rgb,(1.0-clamp(globalShadow,0.,1.))*alpha);
2105#endif
2106#include<fogFragment>
2107#ifdef IMAGEPROCESSINGPOSTPROCESS
2108
2109
2110color.rgb=clamp(color.rgb,0.,30.0);
2111#else
2112
2113color=applyImageProcessing(color);
2114#endif
2115#ifdef PREMULTIPLYALPHA
2116
2117color.rgb*=color.a;
2118#endif
2119#ifdef NOISE
2120color.rgb+=dither(vPositionW.xy,0.5);
2121color=max(color,0.0);
2122#endif
2123gl_FragColor=color;
2124}
2125`;je.a.ShadersStore.backgroundPixelShader=Wp;var Xp=`uniform mat4 view;
2126uniform mat4 viewProjection;
2127uniform float shadowLevel;
2128#ifdef DIFFUSE
2129uniform mat4 diffuseMatrix;
2130uniform vec2 vDiffuseInfos;
2131#endif
2132#ifdef REFLECTION
2133uniform vec2 vReflectionInfos;
2134uniform mat4 reflectionMatrix;
2135uniform vec3 vReflectionMicrosurfaceInfos;
2136uniform float fFovMultiplier;
2137#endif
2138#ifdef POINTSIZE
2139uniform float pointSize;
2140#endif`;je.a.IncludesShadersStore.backgroundVertexDeclaration=Xp,f(78),f(79),f(117),f(137),f(80),f(81),f(111),f(157),f(138);var Yp=`precision highp float;
2141#include<__decl__backgroundVertex>
2142#include<helperFunctions>
2143
2144attribute vec3 position;
2145#ifdef NORMAL
2146attribute vec3 normal;
2147#endif
2148#include<bonesDeclaration>
2149
2150#include<instancesDeclaration>
2151
2152varying vec3 vPositionW;
2153#ifdef NORMAL
2154varying vec3 vNormalW;
2155#endif
2156#ifdef UV1
2157attribute vec2 uv;
2158#endif
2159#ifdef UV2
2160attribute vec2 uv2;
2161#endif
2162#ifdef MAINUV1
2163varying vec2 vMainUV1;
2164#endif
2165#ifdef MAINUV2
2166varying vec2 vMainUV2;
2167#endif
2168#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0
2169varying vec2 vDiffuseUV;
2170#endif
2171#include<clipPlaneVertexDeclaration>
2172#include<fogVertexDeclaration>
2173#include<__decl__lightFragment>[0..maxSimultaneousLights]
2174#ifdef REFLECTIONMAP_SKYBOX
2175varying vec3 vPositionUVW;
2176#endif
2177#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
2178varying vec3 vDirectionW;
2179#endif
2180void main(void) {
2181#ifdef REFLECTIONMAP_SKYBOX
2182vPositionUVW=position;
2183#endif
2184#include<instancesVertex>
2185#include<bonesVertex>
2186#ifdef MULTIVIEW
2187if (gl_ViewID_OVR == 0u) {
2188gl_Position=viewProjection*finalWorld*vec4(position,1.0);
2189} else {
2190gl_Position=viewProjectionR*finalWorld*vec4(position,1.0);
2191}
2192#else
2193gl_Position=viewProjection*finalWorld*vec4(position,1.0);
2194#endif
2195vec4 worldPos=finalWorld*vec4(position,1.0);
2196vPositionW=vec3(worldPos);
2197#ifdef NORMAL
2198mat3 normalWorld=mat3(finalWorld);
2199#ifdef NONUNIFORMSCALING
2200normalWorld=transposeMat3(inverseMat3(normalWorld));
2201#endif
2202vNormalW=normalize(normalWorld*normal);
2203#endif
2204#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
2205vDirectionW=normalize(vec3(finalWorld*vec4(position,0.0)));
2206#ifdef EQUIRECTANGULAR_RELFECTION_FOV
2207mat3 screenToWorld=inverseMat3(mat3(finalWorld*viewProjection));
2208vec3 segment=mix(vDirectionW,screenToWorld*vec3(0.0,0.0,1.0),abs(fFovMultiplier-1.0));
2209if (fFovMultiplier<=1.0) {
2210vDirectionW=normalize(segment);
2211} else {
2212vDirectionW=normalize(vDirectionW+(vDirectionW-segment));
2213}
2214#endif
2215#endif
2216#ifndef UV1
2217vec2 uv=vec2(0.,0.);
2218#endif
2219#ifndef UV2
2220vec2 uv2=vec2(0.,0.);
2221#endif
2222#ifdef MAINUV1
2223vMainUV1=uv;
2224#endif
2225#ifdef MAINUV2
2226vMainUV2=uv2;
2227#endif
2228#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0
2229if (vDiffuseInfos.x == 0.)
2230{
2231vDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));
2232}
2233else
2234{
2235vDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
2236}
2237#endif
2238
2239#include<clipPlaneVertex>
2240
2241#include<fogVertex>
2242
2243#include<shadowsVertex>[0..maxSimultaneousLights]
2244
2245#ifdef VERTEXCOLOR
2246vColor=color;
2247#endif
2248
2249#ifdef POINTSIZE
2250gl_PointSize=pointSize;
2251#endif
2252}
2253`;je.a.ShadersStore.backgroundVertexShader=Yp;var Er=f(67),Kp=function(r){function t(){var e=r.call(this)||this;
2253return e.DIFFUSE=!1,e.DIFFUSEDIRECTUV=0,e.GAMMADIFFUSE=!1,e.DIFFUSEHASALPHA=!1,e.OPACITYFRESNEL=!1,e.REFLECTIONBLUR=!1,e.REFLECTIONFRESNEL=!1,e.REFLECTIONFALLOFF=!1,e.TEXTURELODSUPPORT=!1,e.PREMULTIPLYALPHA=!1,e.USERGBCOLOR=!1,e.USEHIGHLIGHTANDSHADOWCOLORS=!1,e.BACKMAT_SHADOWONLY=!1,e.NOISE=!1,e.REFLECTIONBGR=!1,e.IMAGEPROCESSING=!1,e.VIGNETTE=!1,e.VIGNETTEBLENDMODEMULTIPLY=!1,e.VIGNETTEBLENDMODEOPAQUE=!1,e.TONEMAPPING=!1,e.TONEMAPPING_ACES=!1,e.CONTRAST=!1,e.COLORCURVES=!1,e.COLORGRADING=!1,e.COLORGRADING3D=!1,e.SAMPLER3DGREENDEPTH=!1,e.SAMPLER3DBGRMAP=!1,e.IMAGEPROCESSINGPOSTPROCESS=!1,e.EXPOSURE=!1,e.MULTIVIEW=!1,e.REFLECTION=!1,e.REFLECTIONMAP_3D=!1,e.REFLECTIONMAP_SPHERICAL=!1,e.REFLECTIONMAP_PLANAR=!1,e.REFLECTIONMAP_CUBIC=!1,e.REFLECTIONMAP_PROJECTION=!1,e.REFLECTIONMAP_SKYBOX=!1,e.REFLECTIONMAP_EXPLICIT=!1,e.REFLECTIONMAP_EQUIRECTANGULAR=!1,e.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,e.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,e.INVERTCUBICMAP=!1,e.REFLECTIONMAP_OPPOSITEZ=!1,e.LODINREFLECTIONALPHA=!1,e.GAMMAREFLECTION=!1,e.RGBDREFLECTION=!1,e.EQUIRECTANGULAR_RELFECTION_FOV=!1,e.MAINUV1=!1,e.MAINUV2=!1,e.UV1=!1,e.UV2=!1,e.CLIPPLANE=!1,e.CLIPPLANE2=!1,e.CLIPPLANE3=!1,e.CLIPPLANE4=!1,e.CLIPPLANE5=!1,e.CLIPPLANE6=!1,e.POINTSIZE=!1,e.FOG=!1,e.NORMAL=!1,e.NUM_BONE_INFLUENCERS=0,e.BonesPerMesh=0,e.INSTANCES=!1,e.SHADOWFLOAT=!1,e.rebuild(),e}return Object(c.d)(t,r),t}(ta.a),ao=function(r){function t(e,n){var i=r.call(this,e,n)||this;return i.primaryColor=M.a.White(),i._primaryColorShadowLevel=0,i._primaryColorHighlightLevel=0,i.reflectionTexture=null,i.reflectionBlur=0,i.diffuseTexture=null,i._shadowLights=null,i.shadowLights=null,i.shadowLevel=0,i.sceneCenter=u.e.Zero(),i.opacityFresnel=!0,i.reflectionFresnel=!1,i.reflectionFalloffDistance=0,i.reflectionAmount=1,i.reflectionReflectance0=.05,i.reflectionReflectance90=.5,i.useRGBColor=!0,i.enableNoise=!1,i._fovMultiplier=1,i.useEquirectangularFOV=!1,i._maxSimultaneousLights=4,i.maxSimultaneousLights=4,i._shadowOnly=!1,i.shadowOnly=!1,i._imageProcessingObserver=null,i.switchToBGR=!1,i._renderTargets=new li.a(16),i._reflectionControls=u.f.Zero(),i._white=M.a.White(),i._primaryShadowColor=M.a.Black(),i._primaryHighlightColor=M.a.Black(),i._attachImageProcessingConfiguration(null),i.getRenderTargetTextures=function(){return i._renderTargets.reset(),i._diffuseTexture&&i._diffuseTexture.isRenderTarget&&i._renderTargets.push(i._diffuseTexture),i._reflectionTexture&&i._reflectionTexture.isRenderTarget&&i._renderTargets.push(i._reflectionTexture),i._renderTargets},i}return Object(c.d)(t,r),Object.defineProperty(t.prototype,"_perceptualColor",{get:function(){return this.__perceptualColor},set:function(e){this.__perceptualColor=e,this._computePrimaryColorFromPerceptualColor(),this._markAllSubMeshesAsLightsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"primaryColorShadowLevel",{get:function(){return this._primaryColorShadowLevel},set:function(e){this._primaryColorShadowLevel=e,this._computePrimaryColors(),this._markAllSubMeshesAsLightsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"primaryColorHighlightLevel",{get:function(){return this._primaryColorHighlightLevel},set:function(e){this._primaryColorHighlightLevel=e,this._computePrimaryColors(),this._markAllSubMeshesAsLightsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"reflectionStandardFresnelWeight",{set:function(e){var n=e;n<.5?(n*=2,this.reflectionReflectance0=t.StandardReflectance0*n,this.reflectionReflectance90=t.StandardReflectance90*n):(n=2*n-1,this.reflectionReflectance0=t.StandardReflectance0+(1-t.StandardReflectance0)*n,this.reflectionReflectance90=t.StandardReflectance90+(1-t.StandardReflectance90)*n)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fovMultiplier",{get:function(){return this._fovMultiplier},set:function(e){isNaN(e)&&(e=1),this._fovMultiplier=Math.max(0,Math.min(2,e))},enumerable:!1,configurable:!0}),t.prototype._attachImageProcessingConfiguration=function(e){var n=this;e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration=e||this.get
2253Scene().imageProcessingConfiguration,this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add(function(){n._computePrimaryColorFromPerceptualColor(),n._markAllSubMeshesAsImageProcessingDirty()})))},Object.defineProperty(t.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this.imageProcessingConfiguration.colorGradingTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorCurves",{get:function(){return this.imageProcessingConfiguration.colorCurves},set:function(e){this.imageProcessingConfiguration.colorCurves=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasRenderTargetTextures",{get:function(){return!(!this._diffuseTexture||!this._diffuseTexture.isRenderTarget)||!(!this._reflectionTexture||!this._reflectionTexture.isRenderTarget)},enumerable:!1,configurable:!0}),t.prototype.needAlphaTesting=function(){return!0},t.prototype.needAlphaBlending=function(){return this.alpha<1||this._diffuseTexture!=null&&this._diffuseTexture.hasAlpha||this._shadowOnly},t.prototype.isReadyForSubMesh=function(e,n,i){var o=this;if(i===void 0&&(i=!1),n.effect&&this.isFrozen&&n.effect._wasPreviouslyReady)return!0;n._materialDefines||(n._materialDefines=new Kp);var a=this.getScene(),s=n._materialDefines;if(this._isReadyForSubMesh(n))return!0;var d=a.getEngine();if(tt.a.PrepareDefinesForLights(a,e,s,!1,this._maxSimultaneousLights),s._needNormals=!0,tt.a.PrepareDefinesForMultiview(a,s),s._areTexturesDirty){if(s._needUVs=!1,a.texturesEnabled){if(a.getEngine().getCaps().textureLOD&&(s.TEXTURELODSUPPORT=!0),this._diffuseTexture&&ht.a.DiffuseTextureEnabled){if(!this._diffuseTexture.isReadyOrNotBlocking())return!1;tt.a.PrepareDefinesForMergedUV(this._diffuseTexture,s,"DIFFUSE"),s.DIFFUSEHASALPHA=this._diffuseTexture.hasAlpha,s.GAMMADIFFUSE=this._diffuseTexture.gammaSpace,s.OPACITYFRESNEL=this._opacityFresnel}else s.DIFFUSE=!1,s.DIFFUSEHASALPHA=!1,s.GAMMADIFFUSE=!1,s.OPACITYFRESNEL=!1;var p=this._reflectionTexture;if(p&&ht.a.ReflectionTextureEnabled){if(!p.isReadyOrNotBlocking())return!1;switch(s.REFLECTION=!0,s.GAMMAREFLECTION=p.gammaSpace,s.RGBDREFLECTION=p.isRGBD,s.REFLECTIONBLUR=this._reflectionBlur>0,s.REFLECTIONMAP_OPPOSITEZ=this.getScene().useRightHandedSystem?!p.invertZ:p.invertZ,s.LODINREFLECTIONALPHA=p.lodLevelInAlpha,s.EQUIRECTANGULAR_RELFECTION_FOV=this.useEquirectangularFOV,s.REFLECTIONBGR=this.switchToBGR,p.coordinatesMode===we.a.INVCUBIC_MODE&&(s.INVERTCUBICMAP=!0),s.REFLECTIONMAP_3D=p.isCube,p.coordinatesMode){case we.a.EXPLICIT_MODE:s.REFLECTIONMAP_EXPLICIT=!0;break;case we.a.PLANAR_MODE:s.REFLECTIONMAP_PLANAR=!0;break;case we.a.PROJECTION_MODE:s.REFLECTIONMAP_PROJECTION=!0;break;case we.a.SKYBOX_MODE:s.REFLECTIONMAP_SKYBOX=!0;break;case we.a.SPHERICAL_MODE:s.REFLECTIONMAP_SPHERICAL=!0;break;case we.a.EQUIRECTANGULAR_MODE:s.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case we.a.FIXED_EQUIRECTANGULAR_MODE:s.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case we.a.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:s.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0;break;case we.a.CUBIC_MODE:case we.a.INVCUBIC_MODE:default:s.REFLECTIONMAP_CUBIC=!0}this.reflectionFresnel?(s.REFLECTIONFRESNEL=!0,s.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):(s.REFLECTIONFRESNEL=!1,s.REFLECTIONFALLOFF=!1)}else s.REFLECTION=!1,s.REFLECTIONFRESNEL=!1,s.REFLECTIONFALLOFF=!1,s.REFLECTIONBLUR=!1,s.REFLECTIONMAP_3D=!1,s.REFLECTIONMAP_SPHERICAL=!1,s.REFLECTIONMAP_PLANAR=!1,s.REFLECTIONMAP_CUBIC=!1,s.REFLECTIONMAP_PROJECTION=!1,s.REFLECTIONMAP_SKYBOX=!1,s.REFLECTIONMAP_EXPLICIT=!1,s.REFLECTIONMAP_EQUIRECTANGULAR=!1,s.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,s.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,s.INVERTCUBICMAP=!1,s.REFLECTIONMAP_OPPOSITEZ=!1,s.LODINREFLECTIONALPHA=!1,s.GAMMAREFLECTION=!1,s.RGBDREFLECTION=!1}s.PREMULTIPLYALPHA=this.alphaMode===h.a.ALPHA_PREMULTIPLIED||this.alphaMode===h.a.ALPHA_PREMULTIPLIED_PORTERDUFF,s.USERGBCOLOR=this._useRGBColor,s.NOISE=this._enableNoise}
2253if(s._areLightsDirty&&(s.USEHIGHLIGHTANDSHADOWCOLORS=!this._useRGBColor&&(this._primaryColorShadowLevel!==0||this._primaryColorHighlightLevel!==0),s.BACKMAT_SHADOWONLY=this._shadowOnly),s._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(s)}if(tt.a.PrepareDefinesForMisc(e,a,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),s),tt.a.PrepareDefinesForFrameBoundValues(a,d,s,i,null,n.getRenderingMesh().hasThinInstances),tt.a.PrepareDefinesForAttributes(e,s,!1,!0,!1)&&e&&(a.getEngine().getCaps().standardDerivatives||e.isVerticesDataPresent(Me.b.NormalKind)||(e.createNormals(!0),l.a.Warn("BackgroundMaterial: Normals have been created for the mesh: "+e.name))),s.isDirty){s.markAsProcessed(),a.resetCachedMaterial();var y=new Er.a;s.FOG&&y.addFallback(0,"FOG"),s.POINTSIZE&&y.addFallback(1,"POINTSIZE"),s.MULTIVIEW&&y.addFallback(0,"MULTIVIEW"),tt.a.HandleFallbacksForShadows(s,y,this._maxSimultaneousLights);var P=[Me.b.PositionKind];s.NORMAL&&P.push(Me.b.NormalKind),s.UV1&&P.push(Me.b.UVKind),s.UV2&&P.push(Me.b.UV2Kind),tt.a.PrepareAttributesForBones(P,e,s,y),tt.a.PrepareAttributesForInstances(P,s);var O=["world","view","viewProjection","vEyePosition","vLightsType","vFogInfos","vFogColor","pointSize","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","mBones","vPrimaryColor","vPrimaryColorShadow","vReflectionInfos","reflectionMatrix","vReflectionMicrosurfaceInfos","fFovMultiplier","shadowLevel","alpha","vBackgroundCenter","vReflectionControl","vDiffuseInfos","diffuseMatrix"],U=["diffuseSampler","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh"],F=["Material","Scene"];vn.a&&(vn.a.PrepareUniforms(O,s),vn.a.PrepareSamplers(U,s)),tt.a.PrepareUniformsAndSamplersList({uniformsNames:O,uniformBuffersNames:F,samplers:U,defines:s,maxSimultaneousLights:this._maxSimultaneousLights});var z=s.toString();n.setEffect(a.getEngine().createEffect("background",{attributes:P,uniformsNames:O,uniformBuffersNames:F,samplers:U,defines:z,fallbacks:y,onCompiled:function(J){o.onCompiled&&o.onCompiled(J),o.bindSceneUniformBuffer(J,a.getSceneUniformBuffer())},onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights}},d),s),this.buildUniformLayout()}return!(!n.effect||!n.effect.isReady())&&(s._renderId=a.getRenderId(),n.effect._wasPreviouslyReady=!0,!0)},t.prototype._computePrimaryColorFromPerceptualColor=function(){this.__perceptualColor&&(this._primaryColor.copyFrom(this.__perceptualColor),this._primaryColor.toLinearSpaceToRef(this._primaryColor),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("vBackgroun
2253dCenter",3),this._uniformBuffer.addUniform("vReflectionControl",4),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),tt.a.BindBonesParameters(n,this._activeEffect);var d=this._mustRebind(o,s,n.visibility);if(d){this._uniformBuffer.bindToEffect(s,"Material"),this.bindViewProjection(s);var p=this._reflectionTexture;this._uniformBuffer.useUbo&&this.isFrozen&&this._uniformBuffer.isSync||(o.texturesEnabled&&(this._diffuseTexture&&ht.a.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),tt.a.BindTextureMatrix(this._diffuseTexture,this._uniformBuffer,"diffuse")),p&&ht.a.ReflectionTextureEnabled&&(this._uniformBuffer.updateMatrix("reflectionMatrix",p.getReflectionTextureMatrix()),this._uniformBuffer.updateFloat2("vReflectionInfos",p.level,this._reflectionBlur),this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos",p.getSize().width,p.lodGenerationScale,p.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&&ht.a.DiffuseTextureEnabled&&this._uniformBuffer.setTexture("diffuseSampler",this._diffuseTexture),p&&ht.a.ReflectionTextureEnabled&&(a.REFLECTIONBLUR&&a.TEXTURELODSUPPORT?this._uniformBuffer.setTexture("reflectionSampler",p):a.REFLECTIONBLUR?(this._uniformBuffer.setTexture("reflectionSampler",p._lodTextureMid||p),this._uniformBuffer.setTexture("reflectionSamplerLow",p._lodTextureLow||p),this._uniformBuffer.setTexture("reflectionSamplerHigh",p._lodTextureHigh||p)):this._uniformBuffer.setTexture("reflectionSampler",p),a.REFLECTIONFRESNEL&&(this._uniformBuffer.updateFloat3("vBackgroun
2253dCenter",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)))),tt.a.BindClipPlane(this._activeEffect,o),tt.a.BindEyePosition(s,o)}!d&&this.isFrozen||(o.lightsEnabled&&tt.a.BindLights(o,n,this._activeEffect,a,this._maxSimultaneousLights,!1),this.bindView(s),tt.a.BindFogParameters(o,n,this._activeEffect,!0),this._imageProcessingConfiguration&&this._imageProcessingConfiguration.bind(this._activeEffect)),this._uniformBuffer.update(),this._afterBind(n,this._activeEffect)}}},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 L.a.Clone(function(){return new t(e,n.getScene())},this)},t.prototype.serialize=function(){var e=L.a.Serialize(this);
2253return e.customType="BABYLON.BackgroundMaterial",e},t.prototype.getClassName=function(){return"BackgroundMaterial"},t.Parse=function(e,n,i){return L.a.Parse(function(){return new t(e.name,n)},e,n,i)},t.StandardReflectance0=.05,t.StandardReflectance90=.5,Object(c.c)([Object(L.e)()],t.prototype,"_primaryColor",void 0),Object(c.c)([Object(L.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"primaryColor",void 0),Object(c.c)([Object(L.e)()],t.prototype,"__perceptualColor",void 0),Object(c.c)([Object(L.c)()],t.prototype,"_primaryColorShadowLevel",void 0),Object(c.c)([Object(L.c)()],t.prototype,"_primaryColorHighlightLevel",void 0),Object(c.c)([Object(L.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"primaryColorHighlightLevel",null),Object(c.c)([Object(L.m)()],t.prototype,"_reflectionTexture",void 0),Object(c.c)([Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),Object(c.c)([Object(L.c)()],t.prototype,"_reflectionBlur",void 0),Object(c.c)([Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionBlur",void 0),Object(c.c)([Object(L.m)()],t.prototype,"_diffuseTexture",void 0),Object(c.c)([Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"diffuseTexture",void 0),Object(c.c)([Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"shadowLights",void 0),Object(c.c)([Object(L.c)()],t.prototype,"_shadowLevel",void 0),Object(c.c)([Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"shadowLevel",void 0),Object(c.c)([Object(L.o)()],t.prototype,"_sceneCenter",void 0),Object(c.c)([Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"sceneCenter",void 0),Object(c.c)([Object(L.c)()],t.prototype,"_opacityFresnel",void 0),Object(c.c)([Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"opacityFresnel",void 0),Object(c.c)([Object(L.c)()],t.prototype,"_reflectionFresnel",void 0),Object(c.c)([Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionFresnel",void 0),Object(c.c)([Object(L.c)()],t.prototype,"_reflectionFalloffDistance",void 0),Object(c.c)([Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionFalloffDistance",void 0),Object(c.c)([Object(L.c)()],t.prototype,"_reflectionAmount",void 0),Object(c.c)([Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionAmount",void 0),Object(c.c)([Object(L.c)()],t.prototype,"_reflectionReflectance0",void 0),Object(c.c)([Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionReflectance0",void 0),Object(c.c)([Object(L.c)()],t.prototype,"_reflectionReflectance90",void 0),Object(c.c)([Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionReflectance90",void 0),Object(c.c)([Object(L.c)()],t.prototype,"_useRGBColor",void 0),Object(c.c)([Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRGBColor",void 0),Object(c.c)([Object(L.c)()],t.prototype,"_enableNoise",void 0),Object(c.c)([Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"enableNoise",void 0),Object(c.c)([Object(L.c)()],t.prototype,"_maxSimultaneousLights",void 0),Object(c.c)([Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"maxSimultaneousLights",void 0),Object(c.c)([Object(L.c)()],t.prototype,"_shadowOnly",void 0),Object(c.c)([Object(L.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"shadowOnly",void 0),Object(c.c)([Object(L.i)()],t.prototype,"_imageProcessingConfiguration",void 0),t}(na.a);
2253R.a.RegisteredTypes["BABYLON.BackgroundMaterial"]=ao;var Us=function(){function r(t,e){var n=this;this._errorHandler=function(i,o){n.onErrorObservable.notifyObservers({message:i,exception:o})},this._options=Object(c.a)(Object(c.a)({},r._getDefaultOptions()),t),this._scene=e,this.onErrorObservable=new x.c,this._setupBackground(),this._setupImageProcessing()}return r._getDefaultOptions=function(){return{createGround:!0,groundSize:15,groundTexture:this._groundTextureCDNUrl,groundColor:new M.a(.2,.2,.3).toLinearSpace().scale(3),groundOpacity:.9,enableGroundShadow:!0,groundShadowLevel:.5,enableGroundMirror:!1,groundMirrorSizeRatio:.3,groundMirrorBlurKernel:64,groundMirrorAmount:1,groundMirrorFresnelWeight:1,groundMirrorFallOffDistance:0,groundMirrorTextureType:h.a.TEXTURETYPE_UNSIGNED_INT,groundYBias:1e-5,createSkybox:!0,skyboxSize:20,skyboxTexture:this._skyboxTextureCDNUrl,skyboxColor:new M.a(.2,.2,.3).toLinearSpace().scale(3),backgroundYRotation:0,sizeAuto:!0,rootPosition:u.e.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=Object(c.a)(Object(c.a)({},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 M.b(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 zn.a)this._scene.environmentTexture=this._options.environmentTexture;else{var t=ni.CreateFromPrefilteredData(this._options.environmentTexture,this._scene);this._scene.environmentTexture=t}}
2253,r.prototype._setupBackground=function(){this._rootMesh||(this._rootMesh=new De.a("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(d){return d!==t._ground&&d!==t._rootMesh&&d!==t._skybox}),a=o.max.subtract(o.min);if(this._options.sizeAuto){this._scene.activeCamera instanceof Zi&&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=De.a.CreatePlane("BackgroundPlane",t.groundSize,this._scene),this._ground.rotation.x=Math.PI/2,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 ao("BackgroundPlaneMaterial",this._scene)),this._groundMaterial.alpha=this._options.groundOpacity,this._groundMaterial.alphaMode=h.a.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 zn.a?this._groundMaterial.diffuseTexture=this._options.groundTexture:(this._groundTexture=new we.a(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=we.a.CLAMP_ADDRESSMODE;
2253if(!this._groundMirror&&(this._groundMirror=new Bs("BackgroundPlaneMirrorTexture",{ratio:this._options.groundMirrorSizeRatio},this._scene,!1,this._options.groundMirrorTextureType,we.a.BILINEAR_SAMPLINGMODE,!0),this._groundMirror.mirrorPlane=new gr.a(0,-1,0,t.rootPosition.y),this._groundMirror.anisotropicFilteringLevel=1,this._groundMirror.wrapU=e,this._groundMirror.wrapV=e,this._groundMirror.gammaSpace=!1,this._groundMirror.renderList))for(var n=0;n<this._scene.meshes.length;n++){var i=this._scene.meshes[n];i!==this._ground&&i!==this._skybox&&i!==this._rootMesh&&this._groundMirror.renderList.push(i)}this._groundMirror.clearColor=new M.b(this._options.groundColor.r,this._options.groundColor.g,this._options.groundColor.b,1),this._groundMirror.adaptiveBlurKernel=this._options.groundMirrorBlurKernel},r.prototype._setupMirrorInGroundMaterial=function(){this._groundMaterial&&(this._groundMaterial.reflectionTexture=this._groundMirror,this._groundMaterial.reflectionFresnel=!0,this._groundMaterial.reflectionAmount=this._options.groundMirrorAmount,this._groundMaterial.reflectionStandardFresnelWeight=this._options.groundMirrorFresnelWeight,this._groundMaterial.reflectionFalloffDistance=this._options.groundMirrorFallOffDistance)},r.prototype._setupSkybox=function(t){var e=this;this._skybox&&!this._skybox.isDisposed()||(this._skybox=De.a.CreateBox("BackgroundSkybox",t.skyboxSize,this._scene,void 0,De.a.BACKSIDE),this._skybox.onDisposeObservable.add(function(){e._skybox=null})),this._skybox.parent=this._rootMesh},r.prototype._setupSkyboxMaterial=function(){this._skybox&&(this._skyboxMaterial||(this._skyboxMaterial=new ao("BackgroundSkyboxMaterial",this._scene)),this._skyboxMaterial.useRGBColor=!1,this._skyboxMaterial.primaryColor=this._options.skyboxColor,this._skyboxMaterial.enableNoise=!0,this._skybox.material=this._skyboxMaterial)},r.prototype._setupSkyboxReflectionTexture=function(){this._skyboxMaterial&&(this._skyboxTexture||(this._options.skyboxTexture instanceof zn.a?this._skyboxMaterial.reflectionTexture=this._options.skyboxTexture:(this._skyboxTexture=new ni(this._options.skyboxTexture,this._scene,void 0,void 0,void 0,void 0,this._errorHandler),this._skyboxTexture.coordinatesMode=we.a.SKYBOX_MODE,this._skyboxTexture.gammaSpace=!1,this._skyboxMaterial.reflectionTexture=this._skyboxTexture)))},r.prototype.dispose=function(){this._groundMaterial&&this._groundMaterial.dispose(!0,!0),this._skyboxMaterial&&this._skyboxMaterial.dispose(!0,!0),this._rootMesh.dispose(!1)},r._groundTextureCDNUrl="https://assets.babylonjs.com/environments/backgroundGround.png",r._skyboxTextureCDNUrl="https://assets.babylonjs.com/environments/backgroundSkybox.dds",r._environmentTextureCDNUrl="https://assets.babylonjs.com/environments/environmentSpecular.env",r}(),Bi=function(r){function t(e,n,i,o,a){a===void 0&&(a=null);var s=r.call(this,e,o)||this;s.onError=a,s._halfDome=!1,s._crossEye=!1,s._useDirectMapping=!1,s._textureMode=t.MODE_MONOSCOPIC,s._onBeforeCameraRenderObserver=null,s.onLoadErrorObservable=new x.c,o=s.getScene(),e=e||"textureDome",i.resolution=0|Math.abs(i.resolution)||32,i.clickToPlay=!!i.clickToPlay,i.autoPlay=i.autoPlay===void 0||!!i.autoPlay,i.loop=i.loop===void 0||!!i.loop,i.size=Math.abs(i.size)||(o.activeCamera?.48*o.activeCamera.maxZ:1e3),i.useDirectMapping===void 0?s._useDirectMapping=!0:s._useDirectMapping=i.useDirectMapping,i.faceForward===void 0&&(i.faceForward=!0),s._setReady(!1),s._mesh=De.a.CreateSphere(e+"_mesh",i.resolution,i.size,o,!1,De.a.BACKSIDE);var d=s._material=new ao(e+"_material",o);d.useEquirectangularFOV=!0,d.fovMultiplier=1,d.opacityFresnel=!1;var p=s._initTexture(n,o,i);if(s.texture=p,s._mesh.material=d,s._mesh.parent=s,s._halfDomeMask=Nn.a.CreateSphere("",{slice:.5,diameter:.98*i.size,segments:2*i.resolution,sideOrientation:De.a.BACKSIDE},o),s._halfDomeMask.rotate(ye.a.X,-Math.PI/2),s._halfDomeMask.parent=s._mesh,s._halfDome=!!i.halfDomeMode,s._halfDomeMask.setEnabled(s._halfDome),s._crossEye=!!i.crossEyeMode,s._texture.anisotropicFilteringLevel=1,s._texture.onLoadObservable.addOnce(function(){s._setReady(!0)}),i.faceForward&&o.activeCamera){var y=o.activeCamera,P=u.e.Forward(),O=u.e.TransformNormal(P,y.getViewMatrix());O.normalize(),s.rotation.y=Math.acos(u.e.Dot(P,O))}return s._changeTextureMode(s._textureMode),s}return Object(c.d)(t,r),Object.defineProperty(t.prototype,"texture",{get:function(){return this._texture},set:function(e){this._texture!==e&&(this._texture=e,this._useDirectMapping?(this._texture.wrapU=we.a.CLAMP_ADDRESSMODE,this._texture.wrapV=we.a.CLAMP_ADDRESSMODE,this._material.diffuseTexture=this._texture):(this._texture.coordinatesMode=we.a.FIXED_EQUIRECTANGULAR_MIRRORED_MODE,this._texture.wrapV=we.a.CLAMP_ADDRESSMODE,this._material.reflectionTexture=this._texture),this._changeTextureMode(this._textureMode))}
2253,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"mesh",{get:function(){return this._mesh},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fovMultiplier",{get:function(){return this._material.fovMultiplier},set:function(e){this._material.fovMultiplier=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textureMode",{get:function(){return this._textureMode},set:function(e){this._textureMode!==e&&this._changeTextureMode(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"halfDome",{get:function(){return this._halfDome},set:function(e){this._halfDome=e,this._halfDomeMask.setEnabled(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"crossEye",{get:function(){return this._crossEye},set:function(e){this._crossEye=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"material",{get:function(){return this._material},enumerable:!1,configurable:!0}),t.prototype._changeTextureMode=function(e){var n=this;switch(this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._textureMode=e,this._texture.uScale=1,this._texture.vScale=1,this._texture.uOffset=0,this._texture.vOffset=0,this._texture.vAng=0,e){case t.MODE_MONOSCOPIC:this._halfDome&&(this._texture.uScale=2,this._texture.uOffset=-1);break;case t.MODE_SIDEBYSIDE:this._texture.uScale=this._halfDome?.99999:.5;var i=this._halfDome?0:.5,o=this._halfDome?-.5:0;this._onBeforeCameraRenderObserver=this._scene.onBeforeCameraRenderObservable.add(function(a){var s=a.isRightCamera;n._crossEye&&(s=!s),n._texture.uOffset=s?i:o});break;case t.MODE_TOPBOTTOM:this._texture.vScale=this._halfDome?.99999:.5,this._onBeforeCameraRenderObserver=this._scene.onBeforeCameraRenderObservable.add(function(a){var s=a.isRightCamera;n._crossEye&&(s=!s),n._texture.vOffset=s?.5:0})}}
2253,t.prototype.dispose=function(e,n){n===void 0&&(n=!1),this._texture.dispose(),this._mesh.dispose(),this._material.dispose(),this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this.onLoadErrorObservable.clear(),r.prototype.dispose.call(this,e,n)},t.MODE_MONOSCOPIC=0,t.MODE_TOPBOTTOM=1,t.MODE_SIDEBYSIDE=2,t}(Tr.a),Qp=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return Object(c.d)(t,r),Object.defineProperty(t.prototype,"photoTexture",{get:function(){return this.texture},set:function(e){this.texture=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"imageMode",{get:function(){return this.textureMode},set:function(e){this.textureMode=e},enumerable:!1,configurable:!0}),t.prototype._initTexture=function(e,n,i){var o=this;return new we.a(e,n,!i.generateMipMaps,!this._useDirectMapping,void 0,void 0,function(a,s){o.onLoadErrorObservable.notifyObservers(a||"Unknown error occured"),o.onError&&o.onError(a,s)})},t.MODE_MONOSCOPIC=Bi.MODE_MONOSCOPIC,t.MODE_TOPBOTTOM=Bi.MODE_TOPBOTTOM,t.MODE_SIDEBYSIDE=Bi.MODE_SIDEBYSIDE,t}(Bi),Su=function(){function r(){}return r.ExpandRGBDTexture=function(t){var e=t._texture;if(e&&t.isRGBD){var n=e.getEngine(),i=n.getCaps(),o=!1;i.textureHalfFloatRender&&i.textureHalfFloatLinearFiltering?(o=!0,e.type=h.a.TEXTURETYPE_HALF_FLOAT):i.textureFloatRender&&i.textureFloatLinearFiltering&&(o=!0,e.type=h.a.TEXTURETYPE_FLOAT),o&&(e.isReady=!1,e._isRGBD=!1,e.invertY=!1),t.onLoadObservable.addOnce(function(){if(o){var a=new _t("rgbdDecode","rgbdDecode",null,null,1,null,h.a.TEXTURE_TRILINEAR_SAMPLINGMODE,n,!1,void 0,e.type,void 0,null,!1),s=n.createRenderTargetTexture(e.width,{generateDepthBuffer:!1,generateMipMaps:!1,generateStencilBuffer:!1,samplingMode:e.samplingMode,type:e.type,format:h.a.TEXTUREFORMAT_RGBA});a.getEffect().executeWhenCompiled(function(){a.onApply=function(d){d._bindTexture("textureSampler",e),d.setFloat2("scale",1,1)},t.getScene().postProcessManager.directRender([a],s,!0),n.restoreDefaultFramebuffer(),n._releaseTexture(e),n._releaseFramebufferObjects(s),a&&a.dispose(),s._swapAndDie(e),e.isReady=!0})}})}},r}(),ia=function(){function r(){}return r.GetEnvironmentBRDFTexture=function(t){if(!t.environmentBRDFTexture){var e=t.useDelayedTextureLoading;t.useDelayedTextureLoading=!1;var n=t._blockEntityCollection;t._blockEntityCollection=!1;var i=we.a.CreateFromBase64String(this._environmentBRDFBase64Texture,"EnvironmentBRDFTexture"+this._instanceNumber++,t,!0,!1,we.a.BILINEAR_SAMPLINGMODE);t._blockEntityCollection=n;var o=t.getEngine().getLoadedTexturesCache(),a=o.indexOf(i.getInternalTexture());a!==-1&&o.splice(a,1),i.isRGBD=!0,i.wrapU=we.a.CLAMP_ADDRESSMODE,i.wrapV=we.a.CLAMP_ADDRESSMODE,t.environmentBRDFTexture=i,t.useDelayedTextureLoading=e,Su.ExpandRGBDTexture(i)}return t.environmentBRDFTexture},r._instanceNumber=0,r._environmentBRDFBase64Texture
vendor: 31,353 bytes, line 2253
2253="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAgAElEQVR42u29yY5tWXIlZnbuiSaTbZFUkZRKrCKhElASQA0EoQABgn6hJvoXzfUP+gP9hWb6Bg00IgRoQJaKqUxmZmTEe8/v0uB2u7Fm2T7HIyIrnz88uPvt3f2a2WrMbOvf/u3PvvzP/sUf/N6//i8vf/lv/3v5H//d//Sb//Uq/5u8yf8hV/m/5Cp/L1f5hVzlG7nKJ7mKyJuIXN/hPwqXI/g++zq6rPI5u8z+WqfLre+zy7PrVv9L8brsMiGvk8XLmM/sdfHXal4e3ad6GXPdyu2ij8u/+uv/5cuf/OSLfdtEfvUr+dnf/d0X//t3H/7bf/hP//N/928h/0Yg/4VA/kogfyGQP5Wr/IFAvhbIlwK5CGQTPP+9z5uPeePJSW+yo2+s/GtN30Rnv1E+f5zxof9R/lSXv/nr//mrr3+i+5dfyX7ZZQP07Tffys//8R/l/9TtX7790T/7r/8G8pdy+/8XAvnnAvkzgfwzgfyxQP5AIL8vkJ8K5KsmMVzu1U7p5PA5AXxOAJ8TwPf7sX/51ZeXfcemqnp9w/W77/S7X/6T/vzf/7383RWCX3/z05/9i3/13/0PX//eX/2FyP8tIv+PiPy9iPy/IvIzEfm5iPxCRH4lIt/c/393//9BRD6KyKf7f488fP74/PH544dJAF9cLl98IZfLBZtuqterXr/7Dt9982v95S9+Lv+gF/3i7Spv/8lf/vnf/vGf/dF/JfKnIvLnIvLvReQ/NEngn0TklyLy6/v/34jIt00iGJOBlxAsdvv54/PH5493SQCXy9t2ueh2ueimKorrFbjq9eNH+fDtb+TXv/ol/vHyhX4Fxfbx7euPf/Lnf/PfiPyeiPyhiPxxkwB+fk8AvxzQgJcIrGTwFsiAEXH4/PH54/PHUgLY7whgu2C7bLqpQgHB2xvePn6SDx8+6G9+84384vKF/IPu8iVU9Y/+7C/+jWxffiHytYj8VER+X0T+oEEBvxqQwCMJeIngo5EI3goIwVMIPn98/vj8ESaAbbtu2ybbvl8u2ybbdtluSECA65u8ffqIDx8+6G++/VZ/efkV/sO261dQXP7wT/7kX8vl8qXIFyLylbySwe/dE0CLAr65B/9vGn0gQwRMMqgmhM/J4fPH548eAezbZd/lsm3YtssNAYiqiogAAkCvb5/k46cP8u2HD/rrb7+R/2/b9Wu9yJe//8d/9Ney6S5yEZFdRL68/38khG/uKOCnAwoYkcCoEXwkEgGDDq7CeQfyOTl8/vhd1QCum26ybZtu2yabbrKpQvXue1yvuF6v+vbpTT5+/CDffviAX1++1V9sO77WXb/66R/+4V/dgkbllQi+aBLBV/dE8LWRALwkYCWCNyMZXElkwLTMeMkga/P4/PH547ccAVwuctkvdxSw6bbdtYDbTfSZBN7e8PHTR/3u4wf55vKd/nL7DX6mu3791U9//5+/gkNFZGuSgZUQvnKowKgLWLTAQgRtEniTuEfwaELw0MJvf3LQzynud+53uG+X6y3gN9kul+2y6XVT1U27JCDAFVc8ksAn/e7jR/nN5YP+avtWfq6Xy9f7Vz/9w1dgRYngiyYhfNkkgzYBWHTg44AEMmqQUYQKOmDaiCIa8TmsfmzB+DnZDQjgcpGLbti2y3bZHjRAdRMVvb/dcYU8kcDbPQlsH/CrbddfbF98+RPZfvLFnAQeieCRDC5DMvju/vmD4JkEvjRQgKULeGggowdHkAHTYxihg89vu88I5UeGAPSOAFTlrgPopiqbKPSmCKreUoAAkCcSePukHz590m8vH+WbD9/JP335k6/+tA86KxFchv8jMvhiogE4JQm8XhfKqOAqx5qRPyeGzx8/cgSwbXcUoLJtim27C4Oi93+4v6VxQwKAvl2v+Hj9pB8+fZJvt4/yzfbF9lPdv/wJnsE2BogmyeCRED40tGFvksIXiSbgiYSRRpDNDZ6BDI6ghM+J4fPHeyKAO+zX7cb9t4tedMMNAQju5V+f1uAtBSiu1zsduMrHy5t8ePsk3376KN98sX/xE5FPAnm7/782o0DiUINXMkCXCB7/P94/e87AWUmARQWVvgMuKej9t1RLBp+Tw+ePgwngsutFFdu26WXbbl+rSvdfbnqAiuA23QcBgCugV1zl7e1NPm5v+LC96XfbJ/1W9y++fgXjA3bDYXV+MuhRwSPwL3JLMFYC+HS/LU8HYrGwIhwyNOF12SvgM4SgztdifP85MXz+KGsA2C6X7aJ6bXSAOwrY5OYIqGy3d5uq4P5GhABXuV6veLvRAf10fZMPb2/y3b7vX7+g+9v98/WOBq7GG7RNAlYy+Dgkhhb+Xxp0sE8IAC4SGAP/TbgVJK/PoJPBnAiwPKxsXfbbnRg+i3s/JAK4Q/4b9NfLtomBAqCickMBjy7BuywAUVyv8na94tMjCVzf9KNcLl/0SeA6oAEYb1i9g+FtSALb/bKL8/+t+wxXFMyswqiHoK4ToIgKqslgpg1qUC0QoYbvJZg/B/q5v4szHmPX7YEAsD0CX25OwEUVm9xag1+agKg+nxQArnKjAtDr9U0+Xd/k4/UqH7bL5YsewrcBBiMJZPRAp6TwQgWfjM9vgRbgUYGL8AvLWH2gqhesCokeUmCSwPsnhs8fP2YNYMO2XeSmAWxy2VQaXeDmDIhApf33rD4PTUCuV+DtCn27XuXT5ir8VmCJ2G5BpBM8/r/dEcJb8/0lEQMtJHA5TAlqNuLRhJChhEpSqFabH3di+G1AGj+W1/dyAR4IYJNNnuLf6+tWC9CHHiAtFhAIFLjK2/Uqn65X+SS67aK+3QeTDoy/IG2ogQ7fb/dAtz5vBgrYGqrwNtCHsVfgIvwK07OTQBURVNCBFpKCOjqCHn5L/67TgTN+fpySAC56nwSUi256kXsSuFGAVyLoUIDo8/Pz7fdoErr/v17lk162HbgHvFpIYDfoAJJfW4sGPjkU4VNAF8ZEcLmLhdc7kljdY1y1Dq9yLiI4IiRqcLujb138KIPn80ejATwRwIbtBvn1cqv+2J78/5EI5N4cJA8qIPcmwRsKAHDF9WYP6mV7VmrgLuTpxYTcMEW0LAmoQxFsuvAI8tv/a/C5fV2ZMMiKg++FCM7RDPRu8ebWY7VG6VJi+Bzk35MI2LsAckMAgwvQ0gC5DQjd3ABg2HQLAPpEAlZ1Bu7VV7MGHDFRAbo3VKsTbAY9sPWC/uvx86gBbDK3D1eEQS8pbAeSgSwmhepnJb6uBv/o/PzHLzxWA/X7TH77De5j6AGQi6o0CUGfCOD2X7cXAlCFQABtEsGLDtxuOyQB2UTQBKZe5GUPXgkUYCUAbZJRhBDeuq8xBf+bgwbehDm+BFQi2IJksOocvA8ysIMfxluVcRsY/eB3JzH8GFDAXQO48X/dcIf9jyDHptIigDsFkEe066tBSETQUYF7ElDdYEBytN4+rk9UcBPfrKaZqFHWcw3i4J8/X4ev2//bSXqAhwTay6OEIPLD2Ipt8OtAGzxkwLw9WVFRjTc/qC6H3+YK/b1oAA0KuOizHfieCLaHHiAb5NYTIC9EMEbZrVEQt1xwhVy1UfBh8PUOquMizwaap3tQXfY5B//tea/NZdfhsvbz+PURQTDSGWB87VX/7WSd4KxjUqrIgE0IUkoKGnhIvwvawpGf6eECXJ7tv4qbA7DJgwpsKthEmmYgfaAAffYF3HLxo0vwNjJ0SwRWMG4db4eh1gPNm18vQ+us/0eGmxDemu/fnM/X4evq/8342ksGHgLY5LyT/zg0wM8lcMjgGFXwqIOVFJBQw99eCvF9oZL9Mfl3QwAvIXDsBRC9R+fz8x0FPBLB0xJEpwUobrfAkARgIAF41h3wQgP6QAmX5E/7eI43IxGwwf/moIkRyWRJQIPgt9CA9b39nzt4bYUWjAlCjWDPgv8IEjgLJfzuaAsrv9VdVG4OwOXW/fdoA35qAdL0BDwvf6AAUVHd8LIEu94A3K+Q+2YxaB84MOH62P//qoo38fCRDERE2zf0JfmDa+MieElAjcDPKz+mRKCOtdgGtXaBjgNJ4H2owSpNeAW/rRH4CaHSpMwnBYYycjgSJwfie9CR6mPu20Uv8kABF206AvXlBMiIBPSlB9wjBW1fwEuSb94296VCqgMaGCt/G1BbExi3IG+r3a3J6P48Gv/J0YmEYoiGY7V/SxwFCwGoE/xa0AJ0CEiV9QPCJb1OJ5F1VTjEY2/MO9AEJvj1BJTQpqLfTlGwjABuzT962e4IoKnyrdh3+/6mzDVJ4PHOxj0JqGKoy20+wBMN6D1gLWi9NQHfVP5MEEPzjGYy8BMAOnTAJgEr8HUIejRo5xrA5xkR5AngmiSHs+zDDAmMgWzTg55GSJEmHE8IvWPAoYTfhWak/Wn/bQ0CGLSAjv83SUEfKp5q24LXuQICpzrjrgWoza8xVE00CQCORdhMJuTUT/rjuls0gO4Iby8BIEgK6gS7BsGuTtDrScH/fR68biUHNVGBnxjeNyHEvQe/ve3LZQqgG3rof6cEclsNflG9J4KtaQ8WHcVBHS1BtHE4QP9OBMS98mpbKTeDW7dJwRsnHpMBTFJpV4I+b0kY/NqInVFSyBLANbnMSgBM8F+Fqfxq/h657/Up+GaBnwV9hRqc9bZ/vA6vu+T9E8KPJWns94UfTeCj2QXwCHS9dNL8Xf3Ho/rfewSeFODGDV69AU0y6NFAE1DP3qK++rdB7/1HRxf86gT376zOr99T/h/ioBiXWQkgQgVeIrCC/WomhDmQK+hASI2ARQZKooHMLdCJwGEBBXC3+uERwg+VOHZ9ioAt9H80AI06wGgJ3nQA3BoCut6AhxYwgcPOFnxuFnrphk+NIKIGrWPQtgz3b0i7Y6D5rs1GKqTop0nQX52vmQC4BkjA+r4a7Kx9WLENGeegkhSETBCrNXIMdi/444Rw1n6E96ry7OPuj8UfLxtQ78NA2iSBbg7gIiIbdDLsb5agPhLC3RkYKv8NDbS2YGsatNRAG2oQwf9ZIOydgy1MAzBkAw8UwEEIDzSAqdPQ6za0PkeJAMH3Z0wXniUSZoHvBXU2mcjQgv56TedIKglCpIoQfgwCIjOytd8WgN0bfxoR8Fn9Gx0Aj5Zgq0lIZbsH/ibSJoFnS+C98g9ooHEELI3gliy25yONIiE6pb0NfBlyNEYyENoodkKwgl6I6s8kARgJ4ZoEfuYWHLEJa0LhSBXm7kImGeSfVdoJ1DO2G7WXsehAptupSOoyrCSF904k+6vt98X/ZcM98Hsd4JYIXhQAIg3/f9AAUYhsLQKAtkHVBnzjCKhOoYl2ym+iBtvzDzQ2DLXJ4PUmbJHAVnBQX4jkxfvHhNDqAdHXGQJgv0aSDGItgOseHIU+K9hXnIJzkoGlEKzNHagTdJ6VWEUH4iCKH4fd2AwDPaYBm4Wgng4gQ9V/CoGiuNmD04AQtNGMGzSAAQ2I2pzfogY9LRh7BrbOh4+D30sAencljFu2CUFrwY8UAWRfWwGvVOVfbx2uIILM0pwDv082dUTw8hYs8L+uIWiHGpWgClnAa1lMPJogovvvbePPs/q3Xr++kgCsfgB5oQF9WYKPJqEn6G+OE3i5AqouF59FQOmahQC8rlPLj38kg1c2f30vw+XaoIX24/pMGIgSBoZqoH3wo0sIIGlA9PWcCPrAtpPB8eBf6x1o6cHra+2+tpIFP4PgBfxZtZUJfo4qxELT948D9ucK8Mt9+ccjIQw6QJcEbrD/1g340ATuDgDkFfx6twSf1f9xvuBECYxq/7ythQQGm+5JDx6Brw4CkMGT3wgscCUoQ4sU2t6DR2ciBjTgtcpenQoZVX9NuL4Owc+dVaDursYVkVALX+shjSBKBuvCYDUZjE5BdNkxdHAUBexyHwB6NP7Iyw7sxUDViwge1t+mz8B/LAvVx/c3PeBBCToB8IUGOgqA3iV4yUg6UAOxaUFHDx6CYS8SorMOue0CCJGAf5YfRhoAI+A1CvwxqNkAY5yAIx2EQmkFfeWOXi+nEdSQQA0ZHMEItiagJArQxDXIrj8nCfQi4HZPAttrIahso9oPQ/2/JwV5JQU8zw+7I4D7/sBn4EO6rjw0FR+i3Z9fHtahzsFvJgM0X+tmVH5vaYiNDGAigewAz+gyNLThnjCURQFR1b9d3lZvnVqmj9mEPDKIUIC4KCCjBXywS4N+otp/Hk3QVthOkwEKlV9PQwXjT7s/zwF4Qf9toAAzFdjuaEB6S7D1//U5FIQu2MevO0rQQH8ZmoXE6B/IkgE60XCjVoq8gt2iCG0S8L5GdxkM1cGsfsCMArSCAnrr7dzAZxCEEpepvB8tqHJ/q+bmJGGts/AcAXFOMMeTwC7Pw0B6CtCtA2vWgonqBQJFSwH0JQK29OB2kvgj2HHXAoyeAIsCQO0kMNECAhFMqCBf8mElAkyBbX1tJQP2RJ/ha0gpAfS9l+/5n00CkrQpq0MZbOdAuxmMvHswog62jZj7BnYQe19b14kxNq2D/ehX/p68HEcF+x3yP7z/V/A/q/5DA3i5A/dzA5pdgbKp3v3/wQF4Bb70WkCTHGRAA6+KL0bFl6FJaFw0ImZwm6igSwbbwPn9RMBWf3sN2JgA/BVh/Rg0kQBgePf6HglAHLFQwqQQOwDjbdVxNZjR4iM6Qa3WxwvNxh0JFb3g/WzFQQS8b/ttKcDWoABtUMAd8j9hf0MB2uDXhzX4CHj03L9DBU3Qjz0C0l4mLSLQPicOOwZoVCB6P6dA7nDbGkVuxcNr8PU2JQO4wX5trEqmccZaHU4q8oCDFOpzAnOwqyMIMktNNNAHouDGxO37DgArQZzlmp/14W1QlqHTMaIIx7SCx0+5yza7AKJ3IXBrNAHVDcMZAU/BT/vgv/ULPOA+XiLggAREDF2g0ci6xNDRglegd7P7TWWH5oJfayliEg7bScQRBVgI4Ookg/F6rvpLWP29swREqA3CaG8/FpKqS8DTAV4TiBqIqtxfzaQRLys5I0XEFIFrPbZRQb+16Fgi2LvJv8EFUPW1gGfQv1T/F/d/HBnccP7rAwnIIyHI4ArgWeGbU4eHy6Tx/EeTZIb5bo/BsMBjmjBE08f/RB0PHYBd9eVRAGY7cHRwiBf8WeCPHY1bgBTa9xKTELzEkQX9CPtl0gJiqsAmCT7I8xbjivh3JGFI+D2nBcSJQJ8agDX+O9iBL7UfG4bzAkcaICrbtYHz1ycSmGmAjJfL3CMgT3tQpmrfB7gxSzC1DnvdhQMieG47u75+kTouKNkM8c/+vq/Q7ZYjO/hhVvRq8F/9gGfhP8aqE9EIdR6LTwJ1h0BItyDqB8iFwuNqASscRnYioxOg9ApvnYA35f8e9Ohbfe8J4rknoFkO0lmA2gmAG0YK0DkB4ieEjiLoMD8wBzom27ANZkzIoU8EMHk/uo1mzeVoEoRWKn8L/62EYAX/lsB7D/LXg74uAMr9oGivJ0CNJCGD6i9DhZdQF+gtOp4S+NODRzsDVbhdgv4BqTMNyIL9SCKwL9/FGPp5oQKxIf8A/UX6r231H7YIqLML0Ae2GtrADOvRQH5b/MPE9dt9BGLNG8jVTAQvIaK5TtvvvWQgDvyXIClUA78S9Nfg7VtIBlO7cbsEYkQDMot+ygQ7QwmOawTHnAM2XUSnJvPIYRYMmYPS+sv3J+cfP3d04JYIXsF/EwMbBKB9Q9AY+BiSwFj9mzrSXmcJhFPVHySTbgHJCPvRQ/z7G/SVUETsg0ZF+i3CRoCjhf7y1A9mOiDD7TwdwEoEXjLwAv+avLE2B7Jnb+OqDpBoAchoQJskxKnss0vu7Q2YhcDv4ySeLOg9GsCKiUIihP7yfW7zbTsBh0TQfN0iAWn9f72Z56/Ax9P7j5OAH/Qvv3/QxKfk0DgDuP+R3USg3bzBC7bO/QT9Eeh9QvDPG7glBQzJwK740lAFFgFk8P88CqDGAa223YckWYhr+c0BPdwetl2ocnsfzePAWcVnnAIp6gDVhDLyfV4nqFEDPxHsbWD3k4BDkN+pARqKMLYBPzYEvxp9xmCHQQdgWH/9EtH2TIFpu3AH/cdGydv1j0TQbRrq+D/mLcX3ZACZ15bF378CG0My6Kq/zoGOQwhASDFwFbxyNGBuSxbCEhQ/uEPe/6gAERWQObCVVfjPpQX+rexxYhYFxIkgpgX7Y/vPs+Pvxf9vwt8kAs7i32t3QCP+3SPaTwIytQXP38u0PESm+YER+o9B3vr8mETAUfDrEkPI80ck0FZ0dXh9U+HRbhey0cAc2H7A4y4egoD6y8JfkBiigLdFP8v2W00E8deT2IeAKujZ/QAVKpAtKI20gLWksHedfgPcb+0+NEHefd9vB9rayi8h7J91gBbaw20MsnWAF5xHkyDUCOoXp+yrOwwxcKj0aL6fFppaaKDv6OpHR5sgx5BAlK/+fYhuP1D196o8e7lFBaKqv5YIMnFQpd0FGVR35RJCnCDaABaXBtgbiSwtICMtalKC+1JQ6bx/PLcDPQL91QFodQNKpwOgF/9eqcBxBBqRcKAAVk+ArQOMx1RYGgB6naDhlK+uQQwJYx4meQbxtNnYQwMjt/d4f3M9ZE4UOld1LAh99fbfzOxiEkKFCkTJIUIMUeVnJ/9sDt8/e1NEJOi9oVHDGYhgnSLss9DX2IAqw1zALUncKcDr0FB5NP+0cBQNrEezDiyiADPkt9qGpwoPdL0AGPx/NOKeyf3b9WJNdfcFv6bKd2cLMJVfJ6Y3B6wB9WFUfWWEwKMfGiQL+3bz9XGQz2EHKhF41GCtZyDi/gUCsNhYoAr3UNJ58YidHKqnMb/6AB5J4N73/4L+t7mAkeeP3P+1LNSB/l0SkMEd8DcEuUlguEw6t2AU/PCE/q++Akw6QFf1u6SBrj1ZnnhG50AfkoGIdf7gJv1KcSfgzWWkQ9U33Z3tHXYASKJ9e/YhU90rvD+q9Ej69/wxYJVs506Eg/r3DkMDzEdDBRGgcZay49XihLA30P+l8N+hf1f57/0AoxbQbwYaan/rBMirE9Dk+sBzTkC8JNDEUlv5McB8PP19Y01Gayep+hC/2zvQ/2HGLAurowsNGlA1cnqGGzeH5weiYLZm7h3QQC4O2tXdhvMMk1ZS5ebpgI8eMrPvPGkwaxayk8Yc6PMOBPEdC1XZ+2UfbfOPtxLMQQAG9BcZFoF0gp/RKjxe7+oAw9T7ZPWhgedodgz0gf5KBtrtIZhQAZpAV1Bi36w6t98qVfH7hqGI318lLCjLCUFlxRHwqYEH9a2qb4XjWvDT7kBwfbZA5P0+PNuRuW1yf4yNQH3zzwv6b70QOJ0G9OT/dhoYRUGT15uQH/71MjQLtQlxfDuiCXrtM+SkA+icQdH6sU/xz7Ze7FlubV4TpoTQ2osdpaEjtqADmEU7OkBEFoLeC3IWFFeswJXKXzkboNL+wzcFHU8hTGKIboO7CLi1/P+5F+gydQhuvRbwEgxvtACmANikhLTbj0gCYk8KdlYgmj+4Ymaod7TwahwadICuX0Cm2fE5iNHPK0x/CDV66Kyg1MnqjNFBnhBoLQCgUULfaVe5nq/6EQWY67bXCszUb+7232fVPz51iGB12owK9peyP1T4raMFF/OEYJP792mgXYfZ04GHMAhBkCSmSj+dKqRPgVFGHbpLEGMiGFeQWfSgrY52VxaeDUPSNJI0P7NoisG729HHl78z6hxfs9rV3m4JjgM/lsui2qmThjCfDFSb+I9vwUqG5wwL55U7C+6ot8B+7N2o6r3q37T9trfpjgmTvv7PSQATLLeRAOZhIJHBQfDQQJPBdUwEbVW3+L08EcEE/9G4ANrCeWcnPKRHDupbNynMx5AA9IRYLmrc/YLSiD5EaEBS/s/TgnU9ILcH19n+CpHwegLejx7Mn/d25fdN+e9U/1vgb7bqf08MOtf8EXxaoh+GY8L6gDfhvs4i6HQ7seYI2sv1GchdMsBIG3xlvxcCRzdgCPTn+6q/TW00VE8Q9FaFv+R2VlOM1vm/hhjhDCdgNflVKME5B47I9xT8z0YgPAJ8myb/LqHy36j/Mwqw9AALxuO1JVjiuQAYLcFzIhiEPe05fk8tRjGw7yWQbsfuLAT2VqOId1osnr0F49VM8INACPHDoBz4B5mqqSnUgyh3ArjXxfQH5BbgUS8gP7aU+w0zHD9GGD0CGHf+P1p/DeivlhU4BbxR9a2kYFR58YaDZCUR2P0DMmgED2eg77puegy6PgDphEB0CwlG/i9d+/Hs34pBEQrBn0W51mqGnJAk3ACCHeiqkQ1XFQA5AlKH7Lk8yJKWY3/nym14h2C3JvxeMwD9ZVMz0BPMi1n1RbKl1cYhIVblF3G0ATsRiCMUvoK9//OgcwYMoe+ZKOLlC6/Xk50br9NFz9fanqA8UIYSpCwlBO4kHc4WLLBfBHVaKwKgLQjmP4Un61Vq+3s7Bsyi0WztmLjJwJwFeE0I2vD/1Q6MVwefxfUf32skCPbCnxQqf+QMPEUDHZ7vGeyj020JgkPXXwsldA7SYR1RE3h94NvNtugswcgxXEkIcBPCGZ1rmrgDC0A4K88nm2fn/eTnpQtWyZfybRoK8Dro4zYDIMGsf7saTBzvX0SMbkAD6o9CYbsfMK38cJKD9l2FJt9/VGs0h5Gib33pxMKWNsigFUh3G2un+/N1WUglI/EEx8fq27vUNnwsiOoKecL7kQS8VnWAGCFUgn6dBtQhv40CmIYggwK0uwDHRGAuBXVdfwzHUjZzATLMAoyJ4FmBhzaWBlrHld9CCWpPHRqofBqMReMGTJ78q9rDes1Tv7/0m0v0AFHXNR6P6g30SHivin7V1BOhh3iWPwvps/yE836L2XiwnUT8x2iHgfqhnwn667QHEE8oLQjEvtEW7GYBZDrDVkwNIO4G5GiBDf9fGoFM6n+vbEtzXwP6u9AduaWnGYSLAlVdl/AU+ikrSeEIKgwdaZ4AACAASURBVKj4/wtgHcHtdO2nWKcBkPfxcvnNQvsj2Me9f02r76T8q0IBn9OLKfz1HX8yVXQYGoAB/2UeBQ5/5kCL6+H/OGGoRnLSwdd3oH8r7KkGTbgIxEwVWvnF8KOpHnyzfF9Jod5Px+IF1h8owyitDw/XEgRb5bPqbt1uvn7qBIQ16vtS/u+DP3cR7CH0WWJgd5mTJKYgNzoGjQrfvu99NDBC+bnyW1x/qhTatv2OaMKgJWPvv5kwnMgxHYGFRtJW8VMl3uP+MgoqSZyWFKr7+KIDw1d6+IiOgZI4+d5iYL3imzbgyO+tph9t2oSBxOM3ugHtPoFZ1LM0hF4kXNEBssvVgPdjdXZWK7uKvyS3q1Xb1WQwtVDqSUggq+Vw3t56JA2cz7PXOwGNW1ecwxPhfe3QEUsDsFaAz8jg0nf+iZMAHNg/XSazDuC18Iq1HBRrOsAQ8NLB+16g614jmuSgs3bROxE55D+WDDQNA4ivdMJ9M1b309UqknaDU8ObV9/PwmMPATvTMAxpABLBzugUtV9bLdhNDQA+7B9tQJ06/7QNDHGSwtgZOCIA47InIoDdROQGtt0U1HI3GaoUnCnC/rzBMQJteN17+VaAzYNA7e+PFqHQUyXPUYB7iQYa5ZFjq1Zqpx8Uqu/XT7+6BWC1Xaj0GlBIwMoHu7UzcI/6/Acb8KIq+hzmGWmAYnADrIpvKP7TZeLaf0LAeQkGgebbq9FToI44p654F47tekKkI0L5PQNZPsDwPBpy/ni+wKMN76Vav4+2cFZFf8+JwAraMt0DFB7beA/u4Zz/a+RXx0M/ct4/jwaNAS8G17eSwmta0Fhx0VRxJkHMivso+onMXr+YwdWKbgioy1jp4x4AzIKg5lEA7wvHEYCRmdx11TAuT6lDLVl4KvXkAET9P4RT8H2u+lg9EPQIpw+/NpJ7RwE8HaDv/Mu4f3OdNkq/EfAiEiOANjEALvcWL9gfFV4NZbgbQc6qPky4Pm35QZxtH1f4j+P/jXuaYPcWwIEH/fmEPBoAO4m4LGxV3txOQqDU+dXgey+UwSzuqP++uImO/u/6ogCb7wTc1n61sL+vZi87rxnrNas+giTg6QLzaUCjIp6JfhwtGI7AjBBB9JjDY4ePYVR6ZPgN4owVv6Q2N5hhVHwNeYrM+w6dN6K1sMHZm/Ce7bHe3dzKr1xw1w4JrSQMZtgnoQHlr18fzunAszD4qurNUg/TDqzx/lfCaO6t4tACMUQ6P6htWjDPC1hCoZ8kpODzJ70MUR9AODcgwyqyPhmE+wfHYB/hvSqt6qeXUShhXH+d9SR8DzrDaZZdpSp/HxqLMQuATgDU/qDPRgOIeT8cvz/h/XC6BtE7ACLOWPE0KIS4UUjmZaJ2grBphiWgT41BUVWZfP3AnEIT6OrfoF122l2rMycBoU5i/OXoUZ4/aglsXwLzHNU++FVF3qikOj5HXm2PBitT1WuvJRAB+6O//W0/PY8vQH5IrAsMs/WuVmAdHBrQgrbOxJShXwRSsu08h8JMBpo0+aDTALwV4tbswgzHrftG/dJKIAQb5h9KCssWIMeto+GYqG12/HWGjx8kzqNJaa0noMWOr2KwW01AMwJoNvhMQda2/RKQP/3ecABM3g9uD6BY68Ntz9+nDOMb5iV+hIE+dP/Zs/wwJhJ9mgBnohBuStABUXjugF3hkXF9ZZJAjefKdHZCc389LoStKvIl7QIEb1d9RyciQgFDI9Cjyccc/23Aam7/PZJBhgDgin5CtQvbCzX8ip9YgIFtOAt+w0owp/hOiCWgEGbVHuYjRigPGR/YOnEoqPDoV5z5YqB3mRq2ox5ICmSSgAP1Ne+XV2NE+/vuFbCTRADxtS70VRBCjgBk2OyDUQiUgfl77b7DwaHm2rAZ7osRSOOUoHgKfNBSLI767+oDYrfwZvqChSpGfj3pFwZFsCJg2jeIQQBUiyI4WgD68ww4qO8khuWkkIuDrxWv2nv+UTBpJYiPd0KemTA8qqFiuUF1jWS3BoG6pADJq751JqBI0wvAVPyMQvjcX1zbELltKK+zBiXRFiRxG+b7q3M9xuLdzR8g0gCGNzSM5gNYfqGO9CBT8OHct6oB3KsSDBisUnwsFuISQaRHxDSv0vptt2oeLHMERfRn/FG/Cx01EpgIQG8LP+/i37PKw53xn6sYCM4/JwSRrCnIeB1ZkLsawDhaPKv/njU3wnZ/dBdGE8+YTHSG8+ofGgIjsC19YnwdM/KAnTSsqj6ig7uGgIPw3nYFzhhIIvriAxFP9CQd4HSlnzgxONIdrE7A8ZDPx9fjib8ifgegNIliRgdx95+E1T7+3nQVNNhEzDgGA3T2rEDLduwtPpuuouPcs8swwXFjdTaMKt+jA5gUAQPcf95KJQxYU0cYxEDvsBSmYuukp7AwnqniC9Afa5z8vboI68ImT0t26CvwBzSggkj447r9IojvCn7U92J/Hw0QSdwZKNNjxPCfSxRqnATkdwpOwh88oc4J8KTSm/wdbZjrc+4iFP8YO0/5JJDCfaijK5xVXevqfg6zGRrQf83chvX4aRfAE//6vv5+6490U4ADdO7QgM/5bcHP/n4OtCQhBEFeDWSvos8DPq8/IwzLzjpa8/U6MMSkBklDm8e0mn3QIY7XG1Om8wzN48y7HwhOK3P0/ZwUQHHv4psbdoVeb9VlAjChBCdtDDpOKTh9ZfcagOYq31RFjN4/gwBYzp8lAwYNwBELhZoxECeZxMlAzWGdCRV0fQWGHo8+8Kx+AAxnCIzowAxy9KvNepWfsfp4RR9kUrD88CPVTuXRybhqqTHcnxEGndsgub1Gdug8yz9fHt3Hpl57x/mfCOC29FOSQ7/noAZR5W3Ob24UMpuPYAYiQrQgk1gnFoUIKr4vKFpV15pHUJO3Y5rfH3UFHU4bGkU+NKJ9f2hJyOMxDBDpjAgwiYqvk5TqNl9EH2Arb6fA3yaA4cBtPWewhkEcIQJBlGzYp6zRmr1v+e3Fv27xpzvyI44NGDkCIi7CGNV9Dw0M8NtHC2vUwHINumCGNG8erxOwtQINsW88Tlwdoc+F85nI559ngEDpt2F/Uu3hiXYrkN/pBFS26hYDAkFgErMK67y9mGBA3L5ore5izf8b3n805MOq/t7XU4WHv1DUF/5gugCSOAIW/59uMwl6CHWAib8bvfxWl9/rBGEMTTwDfG+ezEYG4yk6FvRPuPwE+wvc39IRjENWM+/cm5b0W4Pf4WuKUnw/vD6eDbB1ETs5vl77Dhnm/51g6wPWwQAqxnivgQaeS3gy/u/1H4hpTPrIgHAN0mSgXUX13YP5PMIuQAfBr/f70cdeE+QoCX3i8nFMLcAjInBoAIYqt1LhC1WdtvmSab28AYffaeivCB+ohdYQgfUa/WS4ToMsNLHLc9nnvPZLwn1/EefPVf+U/xvnCVSEQEkEQEnEQJO7S7RvYDxNeNYKrG7DKMhtsQ8cMmhgPKKKj+F7CiHYFR5KIIPxOmg5IVAtu3ACQSPh7CzUQOgAej5CWEkIe3vgxz0ROGO//qYfz/dnLT+ZxDr4QW0eNCJBorCFOVC312Ec2TiY5Bk0cAaQmiA1VH1MOwDHQ0kHdEDDf+2UTWhS4Z8diQMicLx8MLBfverLcP/jQzF0P8EJj5+NGK9RCz755S6F/f1+X/gxeP+Wsedv+vF8/54aSPJYFjIQd624MDz/UDLQnr8HU3ztKHRf8Qeno1vyAQJBaLcMtTV3cvgP56COCqd/QP9xLgBkH4BxO13n4hNUDtACC6G1S3zqooZ6Ba4lp/zcAFb7iERKQwQcF39IFJjdXECGADw0IE4gg674pYAnk4HoHPx54tD5daO5vxrugSkMjgiiqc7TVKAT6AT8R4ckbHEQCYR/IZBxJgA+XZjsR7vaoRpIxWqeqfXuGC2CxwudicwePEB1kNkaZCuwyF0DuKv/4sz9mzP/Qxdg3BDkBTMC8Q+loD6UGBzx0Kz6eAX/KArOQTlPHFoI4vVtf4rNuLrca9edRn4xBP7k8w+9AgZCgBfEUZWfEs8iFNZ3UO7TqmkjCO/rWdgco/yIqHcQWaC2EGTzgz5y/iXQAvyx3riyxxV/JeBriaGB9OrTA5g9/eokM+37GszqfA/UZk9iW5UnCtBqBl3XoNN6Ag/+zy6A5evPAp+TIFDn15gQw9rjrOzFX0s2JBVAxa/nP1a6AsNWYGjPNGPLTQgBsNUFvOA3Ht9o/rGDN0tWOCcxJGp+f7++kkP7PxcGv1+GjkaLt/fawpwwerQxBJNW4b+PJsYEgiAYYdEAGIlDNaAbRkIgK3ut0jKByp+8yz23X6GttmBmjwDvChgiYLP5V/zhH6/110sGcKo5CkggCngxnIPoPja0j2B+1BRkiYJiviaLJqghDI63G2nAgAxMCuDdnoD0wIQm+urMB3VuAwbBrFGgGgnhAFqg9+ujKsLxB3qGCQNEEtPinIQlAj4WgIw7/iXc9V/x/yUWFs2KH504bAh4aYWf4TrTLGTy9YbftyLeVOWNfYNyt/ji29mQnqMAltU3ioTtbX343yv/1u0YPUBz6zB702tQucnX0gWaFh6DgPdmhXaapGotw0SFz1qDiTMdd8h45HfcqCPRUhA3+NmKz1l9teCPaMd4urGaewRitNBDdahR5c3AfQmDCFT9vmtQEwqAYXX4XI2n23Z9B/Yb1FL+LWox6wHGbZSo6FR1LzyG+3hriSZvWT6jfXhl2cmQZJDrAbuYAqAHo1GA/EOgD8eGcU7A8eDvH4fQBuAhBL/Zp/vamPTrRENDGLTV/7E1WEPLDlP/PwzU4YhusIMUgfIPAr6Dhv5R4y2r8ldFwiFoYHnmr8TAHbhRQSZOctH598ZYhqt6wP7q/ouqe77RJxvzFYaji/z4vna4v5cUMDXqDAJ5ytktqtBDckyjvJg04hl16LB0xFfyMfD77PZjErGQRRjYIfSvoAXntks0ok8MsUC4KARWnYPlJBeIgLeFrUgDOHYCag0/XNAbWgRwQuLAsaQwIhC1g7+jCNKuT38JfnYSyTi+QQEwwHeT4/dWHYxJPxfOj5oAnRQqgU3YgGZSOaDyK3n/qkDYBKptzR3oD6B4fyRKjp2AzSl80YR/3P+/1vBjX18Jbu+YsrMRgbqPP8zrDLTAaupphfeZtyPs9BPztpLSBZjowF3woYRwBwOWaqbev15b7X4RWsiqYiY6ZkFEIoUwUA2OrkeEQE8HYNyD/rl3m88jCGgO/nPW3xy8x4Q/HBcM1dYg5q8N+B/SBSYhtD0EY1PRGLDoKIBHF3yLz4H/gSYQJRETgqeB2d4vC8L2NVnQn4PoVJJAcP0inahAfdXVI8CFszjRagCTtRdV7Sr895NBpRKXIT64RMFw/iw5eChhEvmmyUIH+k+Qu3cLzOAN6ILlFvgWnx3YWFDz0f38ze9GlfP6UQ3ojEY0gtqRIEbA5/WgQFhsEuIeL75uTzvqHktAWfj/OD6sQXssROcGiRgFn0QVkld7OznMDT7CJKzhMIqxW9B+LCOQdH4uyxIcE49VTSeLj0wKjzcp2oDXQA8YoDEGBLMW0BJw+eAxXejPV/IXd59/tp5rVyYXDw5BlRetSpQAcvgfOwVM8ObzBq/AQ2wX4lwkQV3vNhYFfn2LFgaoDU1ogqsfqGkJYmrj9Tr22KQwBLzbLuzDeA9yzyJjVRfwegWq0H+FThDPA6ZhZwX2M2Kh4waovCzAWJTzD/qY00c+6PM8coz08VNqglzx54LfHuTJK7z2rwX35ABLg1DzsZ7Qv7l/f2yXDlbf4C/irg0MJ0aCuD0wP74MrxfdFlX7tq+vtRdCpvt599EG9Yz3V+P+Oj/n4zLruZHcJ7oMt/MNp9eD6HEeFb6/TMfbWo85Pb79HJo8t3371/PuIAZqMvjPC34nVV6ZB4hEuA7AzA5cfU0y2n6ux89D/35/n2/vWY5Bf0qwf3tPLISO1Tap9qzFB6eap/beqI94NCCbGwgqOItY3CGl446CaQ8i2Q9g0AvmgJOnBoAA0gu17tsKtKS7D4udgCYERy2QIceCX/P7mBW+g/7D9S6Mn50CS0eAoQPDcBjopIA5+EcxEjLweRjXq0UbLIjcBxsGx2IZvlf0ATjz/6qypAmY7bhrk4ahsIis6ccXKHdueAfUgk+RWPCLh42c6zEeKyJpRTdRAOqBbl/Wq/uT+q+Fx3FoTIuCzc6+hN8j4veGjuAnhSE5gKnco3A3XwYlq2sq+lmP4yEOpqEoG0M+mGDYuYT0pKCFHgLHKt3T7T9p8GcWH+n1UwGa8X6kQt2x4CeqPexegT6o/Z4Cr313PHdgrsS2ZReLfpKIf+IMFnmVmwxQ9AhithYT73+p2s+JIVfrjwiHnpAZrSsr9CMstQXP1+1+510N/q8E/YoekMN9OMFvi5LvkRDsy9rgFCOoPdpgaQIWBZjf5KCSQszZJ1ivTvLokpen6tsJAVND0NFqb6GUGg2Im4Dyx9Pn7/0dm4pADAslJzTv+dKNrAPQ0wyySm7bj1RQgbAXsRa4R+mBJzpaQmHLmy0BLoL+Nh2ZRca8uUc6P37k97n451fvTieAE8BdZ2ItqFEK6oOJIYPsiU4woo140Oh+H/UC++gatHYcOFT+2y3AYvD1rM/fpxdUcsAi70c0OxAEP45X/hymE9XeoC0zfYhbcqfbhs09HpwnKMDR6g0mmYyKth/UcLl9ITGQ8N1S6s+gA1HvQCc2pluPvN2Br8SyZyfyxPP/VhCi1L1HWX2CQCuAE8TIq/sBYdANZmTIwqq0sb0HIzhhugBeUpBZLFyA8y+EErsBUYDZHYN9QAAooQwOws+uQlhdESSSqk5Qsh8LSYI6LDS1AbmOvLlRBqQIeITvM36+TP63VfE5hFClCTr9zEyVFwS3STQBy66DMHB+PJWIrfgGnYBx2dTboPa2X49GaBVlePA7CFx4iaGi4ns0aLVjMGvtPTDtmO4XEE8E5Kb/8qYai+NHl60LgAICcUCoJPVeiYG6Pxw/X9VFNVbFn9FNPzXoIRDTyzcpREYB5Fm1EQQn3KRi9wKApR8Tz48SwxnV3qM0q7ZhpdKvr0zfY+gO4oQf+EGPFYW/Xf5hwWsUgxiBbShGoGIx+D2eH1h2EeR3UQMH4zMaUKr4033nzkSkfQADelFbLOQCalxdxvN8mInhPas9bxtGJw29Fx3Y8429MAS0fL33Oeo7qFZeiToCC3B/VSNYuU0fgDnkhxGgMFdxiYEY7MYel+OHPH30IMeVFK1C79l+QdXVpFqHlMAXEf3EYDyfkkGdNvJ8f3RAXU0jpgM7jMNA5yCrtfzOicKG/M9bgEkEjqqPPDEcDfqVwGZv6zcO9avDfOhf4OmLFd9OLBHHdxp51HvOBlnAoQksYjASA1xnIhPsapTCPjbsGB2YevpPpgM73EYeSYIftgPgte6CWesVBB9QEgfnWYMgoeC8ql69bWoRIqYHvSIv/u26bj/jdqZ9KSGk74JRo6QS9PuTiSHm6Z62kLUGH0UO4rwWrhtRETkR4iKRdI8giJ2D2nUCMjsA0TXiVDb98NAf/rCMlajA9wesWHZrAe1dlwRyVI2jx4KkyUHSx7YDe6YD4tOC6XW01puEdAJwaEJzf1uATHi6ZlSCpBQscsh6C1xRcWEG4bCFeKcAVhVlDu54JQIkTT21hptIT/Afk0kMcS9BKfjBJozcDXCrtgbWXxbMAw3INQIxtQJPAGwXmYaBbYh4SCsuKwLOAQ5awKskCMmRg8P3xwlBfbosQaDqyZqBkyQe1CLQACoTgN4qbyHsPwkTiF2pYaj6MAXBmUosQHnUEYCsBL3MW39SNKMJ5PfoBsT33DVJCEbFnBCMOkHfvj6Xq8uw+dgRIhGgAiUqf5QgKDFyhe8nnYrlqn9sG1GoAfirubygX4H+8IM1CmQrMFAJ5ExzKIp54nPoVU2Auh6eBShDlTV4u5c4HE/fVvjFrsII0Ik6QX+Iq68jB19ziLoKC27FYe0gC+j1RSS+BgB7AvAM3m8HLdy5fV60C8RMVuhD1ieQB32MCCq0QPJuvuw5IHF/geMKwOPdpmsxBwVEfGEOgeincJqNmuSFIPhPq/xM81CWIIi+gCFBqDX3QPYd2OcCRo6GZBoA3AM+00aesAOQ7/2Pe/vBCXoguD4OBD1WfPwClzcui12AuH+gC0gEwW72KfjBCQRBr05D0IQc7N8PzOCMehPWK384MPVDJQim7yDdoiRTItzzFV/ZOX9sYFetP0fsQzb6O7wOoFjxk89YoQXv+BmSN+yYHYO+BsDRAXHhuJXsEFbdIEGZQWUkNVNzGA9NZUVBIQL7jASR0AclE4Pb7JN3BO72mG92+o8UG3nybj+mASh0FsLKn9GPxDrEcS2Au35BzHO1BksriIJdpqWjKR1wlpR4fN977rZqI+XbYjYDgVDpcYQalOYKMiuQbB3G6Pu/HlMbi9a0EMkksXtjvvXTfgMKAEZRN/i/O7yD8Da2S2Bdh3ICWfp8yuMkYl5a4df4vVWt4UF0yyqEnaT6swYyWB8/j111Y1ERS9oB0SLMtBGDEBD1PEHwtdjUEAHnqmoHU4wCDAoAS+lHwtu9eQLUAgmxVvAuMB9cELMV3m8EUtcBYYI9nkNIEEJYrQeUHfnzzRyC39j8CgSkir/E0P2odnAmAqDnDIhqrtV9BDNS2POjv/0pwKr6z1h/PMz3uf9ykFYq9TtoAXSwpz0HljdvBCVAPY6t7osv6gFhMpkX13rcfXQMIpuTsfTibkfOPRAC2meLRipI4mDPwMD5x+v3+Ey+qEfACwoUEkKQSMZxYJDz9R68PyP43yvo2aYf881rNQbZgRU/jp80QnW/hdXqJxMvCFxXQSNHpE8QiF4XI+wFfQcw7VL2Md7RRajsKgh2D+6SLAKPF356+/7yXYBTUgFy/38StUjFHweD+iiHh8/LV/i/TSvGk4L5x7F6AsIKbgb4C0YjgdGRIToGUx7cgS3JKP8pRcgak95BJGQbjaJdBYQ1qHYnYHL8F45QgHx2gLMQ2cDxBD/4SeR0LSDi5XzPQNjM4ySE/HGG6g+ugltLNSARn281BPtNO72eJLjdX4ITSEgpQvJYFEUg24f1qAYQNQdxx6Q/RcB85j9f+03zf2QV33IDPHegNgPABTfqFR8cZK9TA7/ll0EQbUUHW8Gr1d+MSadia+LRHwhunv87yWoJ3h/pRDwJAbDNQQFd2P2mH4kP/wDT/ZeN3CK3+ZjvgVpw4r20AMafb58j4N1UMknuj6iCx883PU9g2VHVH5JX2eEcPghSgRBCKPzK0Q3fknwPN0Hk0CyC0zBkz//7duEetgFjVtypASDI4CsknYJgYDhqsBxxy29+eyxrAZX75EEf8f+CkOcijMDDHx4ASYGGu8WHgPwpHJc0qOG8FgFTuVk0cRZVePFwHEIUEu8xSHoL5qWg4I7/HgOKXe2dcnu2SSdCGIDTA+AcxY1zYL6Q6AAFu+/1GvjKPSeEoJV3NiM4Dz9C6oWkEav+NWjPWXNOIkKgNTi2I8LeBgaZHJxqrC4oNXoB9pzzMws/OW3ghSyQJgjbygOVEDhoj4nHLld8HPD6UUMFVLIgKrTL7cFoBRLQgEdXIseZ2/HhFPKbk4d5tYWwwR0nIFQSD2P5gQhs6meVfB+Bkyz2fOIvX/zxqsSODuAGIOLtPNnmIPCrv6Kqvgz3q4tCwNl9lWYfnsdHj2HTgQw5IBHwULmfSu1jEV3gDFSxTBmqSEVqiYK2IkWcRiAkwV/cyW9YhqHXDw9dkNQAcO6HFNJT7oChfrPUYc3KY17zAd+evAwF2w5SCKLV4EuCEKsKfjBVWHu9Q9Arh4CoBqEMWYBsNX7YgKP/69uC3M7/mOOz232QT+ox4iCyJGEFP4oBHd+GVvXBwX35nqp7qeIbV6L6tdZub3ueJ+gBIKgC6S5gOQFxDoGr+Bv2nzqbknd7ph/EmXzO0o+kZdc/wqvQkAOUffVMzKtYgx5Vob1/+HAfCdzHSiXHenX35/2JTr3KZ9Ruj2lYiMhLIFoNyMq9hFroeYMTE0bSLbhb4l3YlFPa6hMd2jk8dmrDgdQCnC4/+ANFlYTB6ATlx2GDGXP1rvL+SnWHw+cJes5/rRWt4H2pw9GklD4uSMpwasIQiaYR92gIyFX5S8dtRZt/nCAH48VXW3hRE/HKOsGquj8EM85Q9cfeAV4XwNGAlmIFIwPYrfLKuxV476RRetzcdeAsRSZhiHizCKEIOHn3EMOWy5X4uIJnXX6sFiBFLaBm/THOQAkVJK9j6TKwiSDTBWpwHkSPQJX7U959uAkoaTUuug6oQCBz1Zlxm0OJSIoIw04M+7zCGuYiznCfHww9AN6Ir+HXA7lfn2oBSJ2FOOh8SzINfmcAyITq8JX/sOMPx6A9LeYtVfwgCBZhdu25OB9/XmWWNPUEPD5dUuJ68wd1AqD2+w1PI9KxE9BW5t3z/igdYGWiL7L+wPv9jgVY8f0ZcbCKCuLAHN+c5wa69Zpr0J9t2KnpAGzyiAIPiFalJ8/xXrrA6Y+/8NoDnWCPNwFJzf5DpVkHte8hx76P+HU1+HEytEeSEIzAsu5r6wPJGu6oLz8VrKofXLce+ywIHhNa/Dmw8LrptWXZ4NKZm4pr/QQ7Qk8ehMrPtAF7PQCD309QgRgRZMKgAbFREAfBBXNalbHA9cEHMo4IgIUuPjjBWEUFEQpYTkhVO43eRiynJw9Jjj8TOUIlJExK+0wA4gWgQvcFBHAc7P4/u78/Ff4CC5ATB3P3oUwFClYgcALcxzp/B9Ez4DUV8RjBbsCBrMH4dLNwIDaCGhA6o3pXksdBvYBsktrXDgNJKAFy1Z+ZGIy5NXgXoBT8a3ZgVSPIUAMV6DjLxhsV8wX4n4ibbONObHNyCr8Z4FinNFjg8ziiF5zSV8A99u7Zdf5OisvVaAAAG3VJREFU/kIPAJLWX3hUIFD6o7MD4WkHIMXBk4IftSrPNBJVk0OoC7ice8HGS8XBKDoz/YFBLaQi392lGpCMJfhD9xVkx5Xbj73P9V4m1j0v73x9FjDDPlYvATkgFAVWcdNvJBamliOjAwRV0EpeRymAe717kMYRyy/j5FwFBX0fP7Dyx8gq8wn2ZXi8GfGYR+lFcGJSxa3Y84WgzBHetlU4cvKY44Ps4iP9fsgsPGEhQTAcHqwwGCj61SoPexKwasXFqtxq8qhD9SixoBBYcJEDNzmIoi3J7QkoJActVHocTVpPBCDhElAvMDK1PT/Sq3DwB/ygmyB9GNhYDH4so4Foy48kkPtZfZEv1PQTxYpyX0EI3Bu+/5krcN8fgwVdwWu2JNVNWAk+PcOOPMNdGFyAZ5Aj6gicgzNfwuHZg0HrLxBWfjSRl88fVCo/apX/IBrIvf65ZxtEoK9Bec4KZIPLe76osQns46NwW0pUPCPAyMc4A/KXOwZzFLGbAqD5xhhbgBcWfoJBAlarcCSQgdQJ+Movnih4gjZQTw51rz588y/ZgxVUEAQ8soCfX8OR26JwujCLGFAMsOjnwGrlPuQw9D/PPv8BYVR7pG/eeFtQpsLzR2KFI8SwKj9KlX++HeLOPuSBKrKeHBi7L4b+Kx184+ptAp4Trcscv69oARVYzWgaK01H1X0K3zNSmARKtxXYHvwJuT+8gLGGWgpHcWOmBeljFB2Ckg6wiAYOqfxEK3GMCAj6kIiTWdCBCXhkjUKMgJcLk271N9uLSbtvvK0S69OXAvoA5z94VsFubbmZvx4QAnXgBnJxENyQjy38wef81uPhxMpPJIQzr5ckuUTKe0wZyN57iFTWga8GvCwlh5UqvYgmaNV9XSxEVWs40kkosFwA70RgNOu8mLZfR6wDiwRa35y7j08NksqPQhcfkRBK/J8R75Iz+9C8gJpqzwiIeZII3QnYOkJWbVEI5jNuA+o2BwK82ifwnpSgHwaC+GNAdmW2VXfC+vPu6wR6lBj84C9WfvivZyUhZMJlJhjSukDlFJ3g4AvGJfC1iEpQJ/CaEd7G9wds7p71+odruKrHip/C7RdsxeVjzIxhoNkFGOW/+sk/YVAGtltfzZAIfzix8gcHhZCXpcGN2u69qWqD9OlRFAy7x2fQBhHUiETB+DocqvArYt98f+AEAXApsEmEcNLC0t2uPHCqPQIXwHYDfI4/9+8LMpchqr5HK39MJSrBXwnutNqjovjHFdq+fcHLp7YLR4mGgduW5hFpAXUoL4cTTuW5HJSkB5PC0S7A+8c+837DyoM1J9iv/po/o3BunlDqPjOSO/YbLFd+FGy9sxKFeT8b+nLNPrkAyD53FtT27yUS32yqUaEGTMBiASGcZ0FmK8nWxbvjC1q6WQC4VdWdAcBY8eFoAzIrC0b7Wt8wlPcIdE1FhUWeKU1Igv8Q/0dl4k/NnYSxdlDon8diUDeuQB4c8XVzcahRgyyZmNC+LAgeCfSVALde8/t1DCYawNoePGT83wlOpFUdOZKwxn89OsMEf0X8CxJCBN/dwKbFwkSMgx0ACJJDJD4iC1JEYh6XcEqVHpx4+J4I4UiAl26r5x64sttvSlAn3LBuQCz6edU8C+J5epBrC4YP52EFDgHrCw1B0eU9bOaTgh3wmYvQV3Oqqcf53XnVNXUBELX1xtSgFrirlII5d3HFulxBCNEfZx0h7K2f34XwdHpuYQcguN189Ow/nPXclaUcqMH5leCXjKOjbv3F0a7i2ZaRHmBe5zwnhA9S736ZC8AH8LHkg/T5znYgmES1dtuzGo92qwHIquiWX+4KgVLd8utv9Ml1BQNhEJW/FOgweiTguCUoQHkEwYhjfQIgm8eAzPKzHqAG5xGiiPyxeGRRaYetUpDVpHVC1T9bHGyaknb/TQTnuG7rDYwYCUT7/cMjtILzA+Go/FPw581F/mWeTkDuBsBCAK8ki+A29nMzPn4Rzjv6QV7xWW4fzQFUxb9jQQ1qc28kMi4mDl1NBr4usIsz5ltZqNm7AeJXfuTHd7nioLEyPBISU+8/tP1AC4Il/n+YGmjg2NiBRdl6yCw//zG5ph7bqaBuz8B4VMU/TqSsNPbwCeZA1cdxyG9SgKzRZPL+GXFOiH1/SFZ9wX8M3zUgvH8a4rMBjZj/h1W9MrwTiN6MlsCKiI4gycBzgV/xUaQGjGDHwHiYi0VIzeEAasCpNuL76AC7BIEl7i4AIxnAfoMxk35eJbZ68wWEUChs8IPz/EEE9BkUoNA4RCWSLJkY1h0Y/dG9bVCtUVPe7QRhtStXG4nOECDfUxc4Uw/Ik8JkA9o9+a83IrfHH11EdFUWc4phNgVFWkPsIHBnCvCCYBSgqEN9qtoXuwHhByYoJJA7BxIkkRwpDGgAHo+vQ3ZGOwCFJCJKUAx4MBpFZWvReeLgtBBkDDQu2OJxXa7SE/P4ZiUPHABjY1DsFIhPAaygWewiXK72hHjow/k8gCL6gKES8qcDZ7A+EhYlWCPGCX1wXIwzkQEKt8cP6iqkC0FEhFj/ZYtvXCtwuBLcDT5wXN+9H6ZEIkTwV/x/s78fXFX3siWHEKrC3tw7EFZ31Ll7ttknQyEMGgAqCaVe1bGk8r8nFWCQQR0h7CY0dsU/mIeIuA1AGCo02Q0YVXxub36sG1Qgfo0CBBUXxap+ECFEycQVyViBEBFPt14TK9rZHB9EwMG7DPXOv0OVHkdtx7OSCXfb3av4CFZGTwQBwT7/hKPHE4PzpJ4L4+FM9r1n8B+B+9R9I4Fu9brYUZgCunZWNxdQgIs8mASBQ4F8hJpEiaf4GPihk8FdAxin/kybjZjTj+mAQy6ihZ9whDvHAWB6BKrBXQr+5SBfqPaINwiz12UIwoTmbPACZY/fshBBBKNlW8ZCHwH/cVKSOZMm4Mxk4OwE9JeB+EFkn1IzcPQoiSB4vGgNeJSoik1A7m0TCmE/HrggB+/1M12C1Z18ACGoIeH1pH2IhAqFWgBq+kDFEWAvA3X8tpW0cnSD5WAOriOHhnYraF1eLTkS8P/QsHUBdtMPnOrMaANJE9AZiaKWII5Ue/8PTHn/UcCSTgIF2xN4zdmAQYIAKeBFl6FiO0aKfq5jcImHfPwTxcEdRmD3LcFoAva1Hdjm9UgGggI9YOoPkOBYLsT8HlG3nucMDGkOOJ8CkNOELdSO7D5qqAeJYBb2GpABgRi2gxLITgrOQ9C937HgB+0i7MeRx3gfPWCXLtgbLJAu/gCFBPzRX8eADJqCvA3FViC/BlOQC4LZyrBq8BdQAOUKoKjqR7v7EFfVFMojPgEoSlJesNIePyLHwW9NRgq7E6HvUN8A0yj0wyWDHRZ3J2A1jHdMyu3hCGwSDwdRir7h9VP7AKLgPoMCgKziOFLtrUm8aIFHlgxYfz8WBYUU55iAXauo+evJaIK/NTgRJM9sUcZRzcCnMdNKMJc7usnAyrpxHYkTRHK+n1HxS01LheAHqRWwKIDqLvQC0+PupHZgBawfVGsiniTVHwZHRqbUI/D4Cd+ftgyLAR1ehkIiqaKFw7MJEwUIuK5zsu4svoFYCFKgBJZACBuppOId2RDkPZas8H9kULcA9a0KTCQDGtpnzT+RMJiOGseHl4BQ1C29AWUXIIf/OIwwqoNEK3SCuA7FRiBrE9B4/PcrGJ1OQNj83F4Xbol/TgVHfMiIZLAdcaVkgh8sLrd+liNQH/FqsNTfj15m1J0X+ffZuq/gTY7QnvIfJz6UzBJLs83ItQpt3RfZz5iuGfNPajpngUm0R8DoA5jDlzsOTAwZjzsC3Jjxg7H914PjlcskGdghgx9HG4OOQH34uwQyzz61/0qiYNQjXxECuWYbGM/DrjtPH/Mw/K+gBLLSA+cEfPr4MroArzcDuybbr8Zc72i2UnzeHnTgzD4Ug78SzIvCoARVOQxaFFR3TzWnkkHUVFShEuqKxZnKz4p4YYcf8ZhYhuu8wFgSHcuuwCJagI4bgchJQK/qe9c/RT6nGcg6KGREJpb+MI0EY/b0jcsni3AJBeCQNsBOFVYoApcM2Aom4VFgIRdHpeIG8D3YaxBD+qCiQ+rBOSVnci8hzkAG1t/pgHA4uwDzmu8xFKkkkIqCfkIRs204r/hiDgutoAAcowBMZ9+KS0CcXVBOHCvJw2jMQSJyeoeExF2DuTuRcuWAo9sefyUQ6/oBaIjPtiRH1KvQKvygAHb171d+vc4GRMDPoxN/kL5pwlVh1mBQ1quQJAJ5j0TgOAis+h8d3mnC8xTKE34+8sDNjyVXE6nFMN+H39TQDmocHScENvN74LoGScGU4f7g6IG3n3C3qnG6JBS+Z5tHOOzRYQx+u7MZmAl0OSsRLAS/VIKfRAWU92+12aaVPksGDBWQuCMvgNy2M2Mt8EwqbjosZAec5xLEAmXmcFTHiOWARWglpNpjdEtBQRxJJU5VL5/7F1X86XntXgUK4q+KggsUoIIK8oA+kgy4+zLaACqQGTVOX6MBWdehL6BxHn+tlyBMDGAqufd7WOX5WTJwKYDfXJJP2GXDPk7Tj5Ed7BOG7DMFaBRAJgI/+H2Ngeb2SKb0zkoGlQBHkefDr7xMA5HZeJPtKIzyApI9gmnPgf1c3mulfhe0gFekDCdNFnrOwi4Gs6eTACNjB+Uegcgojog4V25P8bctRYY6RL8AJklE9ACFAGZdBEahd4d4CmghFhbzcwaXYH5qTlS6DY+KfNH5Avzjo2JJ0poDkSCMxLn73H/eB+ifvgvyIFCWAji7BWC8hd0qj0FziMdrS70BlVbgamIgcmotGZDNPwm0L9l5iHv7WRoAFx57ScFS2r2iwot8oKu8l+TOCOg2mZ2nFdjTgOFQENzKkJ8OjEnsE8f6AzyXwT6MNF3RDRnuj0Lwo6wTlBMDIyqaz6G+RiLJMg/KUrQV/rh9uH0tWduwoxmky0kSMQ+rnXxZsGadgnxfgk1pCnsIsGYltvfdzTOBIclIsN8MLAGcz5gBwj94AE8DuC9Molip/JGwB57nRyJiyD3pyk6q5ij+3TzRLohcqyqCEQBTepF15+WVmW8SEr5jMUUkx3oMIsrH3ndwAQganKzyMpOJNxMQooGBYwcByw7axIhgPRGEr6GSGJhkAELoQ1YRg+dPeD5IIRDIqq5PA2Jh0Rq0YcS8XBi0ghGRFpCtWTdum5+yLOsQf2EuYY8AfnbQZDgCjHxBSKwTGpt8QCIDVH3/4H5OwEvldhliINwAFLsEyyIfGKV+vm3eEehVqKTdNxtDiPoLHCRiuwTJxCECxMDqDjTvZ63KaPKvRgV2i/F3ohm88V8LN8hgJcXD5pVGIPPNn9EBqSQC0I4AMxBUcQNCkarkFgSn/oCs9GCVep4eUG5BRAOcQOCWlGSc3If0IFqRfURQGRrKewPKEJ9sLnIowKCcw+f48N6UHjqYtgInaCCkBbPSj8VEkCr2g8U43wY1xX/BNkwreQrzg+oaJghOCGTU8RBxuIp6VFOGoEXgEsBLIgV6gBgxoLSI5CgiYNT+GBHsU01GthrceiMUtv9KgAYktgVNeGrBbtiOQVi9x8WjiAW7UNUnm4Vet7WtsFgDCDYEwQ/EVL1PnQf/xCDLTowTh4c4HPRDoQaiwhKIAae4B7xgCBydI/CDPOrevK0FR4p6w3VfoXgQiB3T1N8Y1PCD0X19JqcHGfzB5WkQE4p/kdeXBcEVUXEIFqSij82lMyrWq/7c+LFHA7z5/dwOHHg8s/Y8C2CmhbmALtare+4UWLfb25BmXABKABTniC8gRAP2yvDAiUAsElnrxFzITQa/sAFecAOY7zPV/8jMQHSbWAiUPGkQNABhw85xrSCv+mMSzFR8+7mjw01A8f4F8S/td4jnDHYxpT8/OEyV3gz2+GTfdAeAszswfJNGlQhEIjB0Bls0BKn4Iw7WKu9f1gmSagmvqleEwJwnZwjO7npz1HdCJ1hS/mlBcRXyF3i/M7NxqJFoeH27z7nnJaBmpUZKHsTbGUc1ALEoIGsGYl9ixS50gjAT/VhB8IzvGTrBVfWEz1MzAkRFTtecW731VdjNQPukVdhdn0Y8d/a7WYH6i/TBPBzUFwAlHwtGHOQISrgb1AMUgDETTA3+THAdeRJhg59V/Ektofa9I8wxVICkC7QQSAd2O3cftzPzdMK6aA4iZI4ILfYRbb9RgqICt2AxVnYZ4kkBvHOBxT/zN9ybHx/f5Ql2fkGCX6ANm6F8WCfqAS+Eq5AGcHJd2IFHagTMHAAj+mWBnDXuc81CjhsAi5dL2K8QCYI1aJ/PJtSSxEFXASv7C2I3ZB9/a0j/7nDn/j1pHsz9Jr8fNpxPBUAUUYD4wz5GBlmyAiORjtAIGDFwzSUwqiNZ1d1tPiB7/Q9VeI9KeJU16/knkEeQJEALjY4rkp74fCZiMDSA/PgvT/aT2gYgp5E/P29AKBQAo6TRth5T4VesQFb0i4K7RA2MZpgyFXCEQHCOixuYMPgy2L7+45ezSSKt2oUkURlpXkEMOLSiXPuDQZjk63N5bmzOSxQdLHX7AhwUEA0BAeQPJIQzkAuFlOK/GtyLdiGDKEBdllQ7YouxV2Xdwza9So4Kp5Z0yAgUhTlJgFzSFrznIHYIwKcCu2/L3LsCg6UI1b1/CA+ApIV5/32HqOIjdQusE4azip5Wc1b0q/QGIAlaWEJbXP3r/L+AEipw/+BtkQVY9fIM2i/ZhgVEgJO6DZ1ksVtlYdoQAPhVO0oKmYBmnAYco4DRCRB3TwCziptaE0auER9/VzRqKNOEYINOQg2m1l9GpGNQAhh1v6UmxNQh2M4+LmlUzll0OTjYQOaGlZAEMCrdhmBphaMBwBADrSQQc3//He8KgFETT7p6BHnjj2X9EXsDjrgBS6ihoAmcSQVYmE4JgYWFpp1waAQRoqDzxDhU+HxSnZHz/9JEY6Y5MJA+cwoWrt99+U3Mc/9g/NQTFaigAEtwB1yBzwzucZSX7RZEILhR1d5GDCsBLVUdIQvsldZfEJt5i/MHx2hGJZFkVVyK242iFeh58oBUFqIQbkfp2DV2X0CkAYgv1sU+P+I/HmBu8nErugdRnUWhfp+A/ddlbEH3uQlBsNobUEMHasK1HOYn8BEEvCUaiuigXRIKj+sGOPA4KAWz9/s7WxcgB4+a6/fI2osEwv4yOENAiPf+wQhbc/5f0gGisWuQaRFmGoIqguARWsBQgTTocDLMT5OJUQnhqdCEig+/EShKSEgTVV0MBMnz04BcshPnLk/+OaV0/dwKzB4QUt1NB6uTDfGOP+cNm9mEsBAFiM7AQh9AKVEU75vy68jeOxrUC4mDEuYO0oLqoSdHaEF2eXYYSm0V+oEOwpLmYFOF3Z4CmAeBTIGueiIw2xoKPzDBJVBXQ5g5O8/twwA+QguIjJt3+g0NQEcDfUXgO5gsqlTBLkQLdl86K3CWneitQ8sg/5oWAUJP2C3V3RoEyji5n4b9lB4t9pz2CA+cAFn1Z9I/uzYsU/ELtEBOCHYQQqGcFejV+yeuRJX31zsKV5IGjway9z6PLDxKwNEPsBuOEiqw57jGgOtZ1Y++T50AuMFl7hPIbhskiOwsATtRoc7rS7dXrpcgrMCGJca6ELJo+Y0be0BW5ZKGcFz4y8W9BduwcDnK9iO5fagsKpp9ANnvDPxeP8THNyIVFo1AMas8Qk5v2Ytm0LCCYAXqn+wQsPTBh/5Bcnne14Os3uCQt28vsK1WUESJFviBgAW//3u9PLxusXchcCR2WsNzv/ImvgZzzkUByDUAIrjTvmSHAowpJBQE4SUlxMxnARlQbIqkArVAJ6pBBvELCCKlkyCDAP45BYfEPfcUpfMch3Vn4bheYK4E66BxAxHSVd5INgEPgU/NBCDfNQ8Ho1CoINAPQAW/QT8OCIZlNFCB84XhoDChFByHGjx35v9BLgyhmojqHYb5QYXnuAecvua0hZe6BV9f7v4ibvgvamrmAc1TmaEir0LQ9h97eYAYVoM/nWA60i8Q3Ifezha9BqaaL3zvqd6IAuwwLSCCuCLuJWch4h30giPtyiAphKEBcCu9BV5wwzkMxID8rhMwdwMhcSFgrBT3RUTQboAUg3+p+Qe1IGarOioVnazmefV3lHpwA0AcLWCahUiXwePHWJsP+GH1gnp/we5KfOhJAbsj0H/BIEb04TbrTPsAyb2LLu93KwfCvn5PLAwrOXAa72eEQRo1CNdw5IprsAZ3hApy9zlcITG2vpCihsRSYxNS+J4vdBZ6B52eqRcQ/QXmSjAWSfa/5GA5qEg4iJFtm624AqXLrSA2gx8p1Mdqcghv41S0lSp/xAYs9gakQc4Ie2RTUYwYgt748mV+FU1Xgp14eW3XYZ6cdqGTNHwHICTwEeTPl0jEZwIgP9gDEaogeg5IHWCF+1eoAhvEKPB/EAeTRsM/pSAP5wjWEUMM1/NJRhwJbpJSgK7S7zF3EOsI5jBQBK9DV80Z8Y0COzvmWzJXgDl40KEC6cqvqgi4OB5cpgLFYK/1CvDiItXqC6/S87wfAUfPtxqfGNzlYaOjlf1IsHPPvffHgDAoEeEST4ZLZUd/RSo91/BjXY5ggWgQ4In3fyj4mUqPrInHOCLKO3wUwRsfyXpt1nEIRLrqcWeTuk7bigsbid1zD4iDRQtnIdQsyIXnFCn1I9D7ADgxEhOvR5AJosoUbu1FkJyYCi9OhQERoIx+4AX/YqUXQhtYEwKN4Cy1HntLMmtaAQpqfrT/UCoLSxeswjA5UWPPi0mjajUWxMTdVusNvt/ChMdmILK5IRMFu90BMEzFYHdg2GAgeYVHMMJIBTA7EFTx/5fpgTFXz9w/en0ZjD8kCDoKPNGwlB01BmoWQbh+AxR689mBponGJOr9OwmMu3dtJ/ylW1Tik4ElUPmR9RqII+pVhD9ychABMQ51gOIZg+/G+5mGIzLB1JJC5WhzYjhJ7IWmLDpA8jzsAafUPkB2WnFBF4iSxkq1ty7f25rv/+EQLOxs2oUdTSA9HIR9swdBlCcFe9owPC3XWDDC0ISVzsEVbSCF/sWdA5Fu4HJqankp2SeQCYYrImNalfmhpVxYrGkUS4LeSUjg8dD7+D7w/ybIfy7vlB9/HJ978zr7/45Qgajzj+4EjIK/ULHPRAOlKr/aG0AFcqCyu0GcW45Igh6JMJmhA49/U+cEssHNJhtXDC1MOya3j/sAiAGcrEtqtgjBD6wEzSDc7D8o6C8rIqAZyPk+NQoNLAZ1hR64Yl1FBY648smUYKnSg1Xwk/0DyRyArByMUobyByhCcPnOaPyoegREFS4jNfYAw+IHCjdC1J2WDZBke/OyN85J24WiXwDYPoJyYuCD238ulvuzwt6KgHf0shWKsqCFFGjB/w8HU8eeTED9wAAAAABJRU5ErkJggg=="
2253,r}(),Sr=function(){function r(t){this._isEnabled=!1,this.isEnabled=!1,this.intensity=1,this.roughness=0,this._indexOfRefraction=r._DefaultIndexOfRefraction,this.indexOfRefraction=r._DefaultIndexOfRefraction,this._texture=null,this.texture=null,this._useRoughnessFromMainTexture=!0,this.useRoughnessFromMainTexture=!0,this._textureRoughness=null,this.textureRoughness=null,this._remapF0OnInterfaceChange=!0,this.remapF0OnInterfaceChange=!0,this._bumpTexture=null,this.bumpTexture=null,this._isTintEnabled=!1,this.isTintEnabled=!1,this.tintColor=M.a.White(),this.tintColorAtDistance=1,this.tintThickness=1,this._tintTexture=null,this.tintTexture=null,this._internalMarkAllSubMeshesAsTexturesDirty=t}return r.prototype._markAllSubMeshesAsTexturesDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty()},r.prototype.isReadyForSubMesh=function(t,e,n,i){return!(t._areTexturesDirty&&e.texturesEnabled&&(this._texture&&ht.a.ClearCoatTextureEnabled&&!this._texture.isReadyOrNotBlocking()||this._textureRoughness&&ht.a.ClearCoatTextureEnabled&&!this._textureRoughness.isReadyOrNotBlocking()||n.getCaps().standardDerivatives&&this._bumpTexture&&ht.a.ClearCoatBumpTextureEnabled&&!i&&!this._bumpTexture.isReady()||this._isTintEnabled&&this._tintTexture&&ht.a.ClearCoatTintTextureEnabled&&!this._tintTexture.isReadyOrNotBlocking()))},r.prototype.prepareDefines=function(t,e){var n;this._isEnabled?(t.CLEARCOAT=!0,t.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE=this._useRoughnessFromMainTexture,t.CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL=this._texture!==null&&this._texture._texture===((n=this._textureRoughness)===null||n===void 0?void 0:n._texture)&&this._texture.checkTransformsAreIdentical(this._textureRoughness),t.CLEARCOAT_REMAP_F0=this._remapF0OnInterfaceChange,t._areTexturesDirty&&e.texturesEnabled&&(this._texture&&ht.a.ClearCoatTextureEnabled?tt.a.PrepareDefinesForMergedUV(this._texture,t,"CLEARCOAT_TEXTURE"):t.CLEARCOAT_TEXTURE=!1,this._textureRoughness&&ht.a.ClearCoatTextureEnabled?tt.a.PrepareDefinesForMergedUV(this._textureRoughness,t,"CLEARCOAT_TEXTURE_ROUGHNESS"):t.CLEARCOAT_TEXTURE_ROUGHNESS=!1,this._bumpTexture&&ht.a.ClearCoatBumpTextureEnabled?tt.a.PrepareDefinesForMergedUV(this._bumpTexture,t,"CLEARCOAT_BUMP"):t.CLEARCOAT_BUMP=!1,t.CLEARCOAT_DEFAULTIOR=this._indexOfRefraction===r._DefaultIndexOfRefraction,this._isTintEnabled?(t.CLEARCOAT_TINT=!0,this._tintTexture&&ht.a.ClearCoatTintTextureEnabled?tt.a.PrepareDefinesForMergedUV(this._tintTexture,t,"CLEARCOAT_TINT_TEXTURE"):t.CLEARCOAT_TINT_TEXTURE=!1):(t.CLEARCOAT_TINT=!1,t.CLEARCOAT_TINT_TEXTURE=!1))):(t.CLEARCOAT=!1,t.CLEARCOAT_TEXTURE=!1,t.CLEARCOAT_TEXTURE_ROUGHNESS=!1,t.CLEARCOAT_BUMP=!1,t.CLEARCOAT_TINT=!1,t.CLEARCOAT_TINT_TEXTURE=!1,t.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE=!1,t.CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL=!1)},r.prototype.bindForSubMesh=function(t,e,n,i,o,a,s,d){var p,y,P,O,U,F,z,J,ie=d._materialDefines,se=ie.CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL;if(!t.useUbo||!o||!t.isSync){se&&ht.a.ClearCoatTextureEnabled?(t.updateFloat4("vClearCoatInfos",this._texture.coordinatesIndex,this._texture.level,-1,-1),tt.a.BindTextureMatrix(this._texture,t,"clearCoat")):(this._texture||this._textureRoughness)&&ht.a.ClearCoatTextureEnabled&&(t.updateFloat4("vClearCoatInfos",(y=(p=this._texture)===null||p===void 0?void 0:p.coordinatesIndex)!==null&&y!==void 0?y:0,(O=(P=this._texture)===null||P===void 0?void 0:P.level)!==null&&O!==void 0?O:0,(F=(U=this._textureRoughness)===null||U===void 0?void 0:U.coordinatesIndex)!==null&&F!==void 0?F:0,(J=(z=this._textureRoughness)===null||z===void 0?void 0:z.level)!==null&&J!==void 0?J:0),this._texture&&tt.a.BindTextureMatrix(this._texture,t,"clearCoat"),!this._textureRoughness||se||ie.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE||tt.a.BindTextureMatrix(this._textureRoughness,t,"clearCoatRoughness")),this._bumpTexture&&n.getCaps().standardDerivatives&&ht.a.ClearCoatTextureEnabled&&!i&&(t.updateFloat2("vClearCoatBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level),tt.a.BindTextureMatrix(this._bumpTexture,t,"clearCoatBump"),e._mirroredCameraPosition?t.updateFloat2("vClearCoatTangentSpaceParams",a?1:-1,s?1:-1):t.updateFloat2("vClearCoatTangentSpaceParams",a?-1:1,s?-1:1)),this._tintTexture&&ht.a.ClearCoatTintTextureEnabled&&(t.updateFloat2("vClearCoatTintInfos",this._tintTexture.coordinatesIndex,this._tintTexture.level),tt.a.BindTextureMatrix(this._tintTexture,t,"clearCoatTint")),t.updateFloat2("vClearCoatParams",this.intensity,this.roughness);var ce=1-this._indexOfRefraction,ue=1+this._indexOfRefraction,fe=Math.pow(-ce/ue,2),ve=1/this._indexOfRefraction;t.updateFloat4("vClearCoatRefractionParams",fe,ve,ce,ue),this._isTintEnabled&&(t.updateFloat4("vClearCoatTintParams",this.tintColor.r,this.tintColor.g,this.tintColor.b,Math.max(1e-5,this.tintThickness)),t.updateFloat("clearCoatColorAtDistance",Math.max(1e-5,this.tintColorAtDistance)))}e.texturesEnabled&&(this._texture&&ht.a.ClearCoatTextureEnabled&&t.setTexture("clearCoatSampler",this._texture),this._textureRoughness&&!se&&!ie.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE&&ht.a.ClearCoatTextureEnabled&&t.setTexture("clearCoatRoughnessSampler",this._textureRoughness),this._bumpTexture&&n.getCaps().standardDerivatives&&ht.a.ClearCoatBumpTextureEnabled&&!i&&t.setTexture("clearCoatBumpSampler",this._bumpTexture),this._isTintEnabled&&this._tintTexture&&ht.a.ClearCoatTintTextureEnabled&&t.setTexture("clearCoatTintSampler",this._tintTexture))},r.prototype.hasTexture=function(t){return this._texture===t||this._textureRoughness===t||this._bumpTexture===t||this._tintTexture===t},r.prototype.getActiveTextures=function(t){this._texture&&t.push(this._texture),this._textureRoughness&&t.push(this._textureRoughness),this._bumpTexture&&t.push(this._bumpTexture),this._tintTexture&&t.push(this._tintTexture)},r.prototype.getAnimatables=function(t){this._texture&&this._texture.animations&&this._texture.animations.length>0&&t.push(this._texture),this._textureRoughness&&this._textureRoughness.animations&&this._textureRoughness.animations.length>0&&t.push(this._textureRoughness),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&t.push(this._bumpTexture),this._tintTexture&&this._tintTexture.animations&&this._tintTexture.animations.length>0&&t.push(this._tintTexture)},r.prototype.dispose=function(t){var e,n,i,o;t&&((e=this._texture)===null||e===void 0||e.dispose(),(n=this._textureRoughness)===null||n===void 0||n.dispose(),(i=this._bumpTexture)===null||i===void 0||i.dispose(),(o=this._tintTexture)===null||o===void 0||o.dispose())},r.prototype.getClassName=function(){return"PBRClearCoatConfiguration"},r.AddFallbacks=function(t,e,n){return t.CLEARCOAT_BUMP&&e.addFallback(n++,"CLEARCOAT_BUMP"),t.CLEARCOAT_TINT&&e.addFallback(n++,"CLEARCOAT_TINT"),t.CLEARCOAT&&e.addFallback(n++,"CLEARCOAT"),n},r.AddUniforms=function(t){t.push("vClearCoatTangentSpaceParams","vClearCoatParams","vClearCoatRefractionParams","vClearCoatTintParams","clearCoatColorAtDistance","clearCoatMatrix","clearCoatRoughnessMatrix","clearCoatBumpMatrix","clearCoatTintMatrix","vClearCoatInfos","vClearCoatBumpInfos","vClearCoatTintInfos")},r.AddSamplers=function(t){t.push("clearCoatSampler","clearCoatRoughnessSampler","clearCoatBumpSampler","clearCoatTintSampler")},r.PrepareUniformBuffer=function(t){t.addUniform("vClearCoatParams",2),t.addUniform("vClearCoatRefractionParams",4),t.addUniform("vClearCoatInfos",4),t.addUniform("clearCoatMatrix",16),t.addUniform("clearCoatRoughnessMatrix",16),t.addUniform("vClearCoatBumpInfos",2),t.addUniform("vClearCoatTangentSpaceParams",2),t.addUniform("clearCoatBumpMatrix",16),t.addUniform("vClearCoatTintParams",4),t.addUniform("clearCoatColorAtDistance",1),t.addUniform("vClearCoatTintInfos",2),t.addUniform("clearCoatTintMatrix",16)},r.prototype.copyTo=function(t){L.a.Clone(function(){return t},this)},r.prototype.serialize=function(){return L.a.Serialize(this)},r.prototype.parse=function(t,e,n){var i=this;L.a.Parse(function(){return i},t,e,n)}
2253,r._DefaultIndexOfRefraction=1.5,Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],r.prototype,"isEnabled",void 0),Object(c.c)([Object(L.c)()],r.prototype,"intensity",void 0),Object(c.c)([Object(L.c)()],r.prototype,"roughness",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],r.prototype,"indexOfRefraction",void 0),Object(c.c)([Object(L.m)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],r.prototype,"texture",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useRoughnessFromMainTexture",void 0),Object(c.c)([Object(L.m)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],r.prototype,"textureRoughness",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],r.prototype,"remapF0OnInterfaceChange",void 0),Object(c.c)([Object(L.m)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],r.prototype,"bumpTexture",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],r.prototype,"isTintEnabled",void 0),Object(c.c)([Object(L.e)()],r.prototype,"tintColor",void 0),Object(c.c)([Object(L.c)()],r.prototype,"tintColorAtDistance",void 0),Object(c.c)([Object(L.c)()],r.prototype,"tintThickness",void 0),Object(c.c)([Object(L.m)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],r.prototype,"tintTexture",void 0),r}(),Ar=function(){function r(t){this._isEnabled=!1,this.isEnabled=!1,this.intensity=1,this.direction=new u.d(1,0),this._texture=null,this.texture=null,this._internalMarkAllSubMeshesAsTexturesDirty=t}return r.prototype._markAllSubMeshesAsTexturesDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty()},r.prototype.isReadyForSubMesh=function(t,e){return!(t._areTexturesDirty&&e.texturesEnabled&&this._texture&&ht.a.AnisotropicTextureEnabled&&!this._texture.isReadyOrNotBlocking())},r.prototype.prepareDefines=function(t,e,n){this._isEnabled?(t.ANISOTROPIC=this._isEnabled,this._isEnabled&&!e.isVerticesDataPresent(Me.b.TangentKind)&&(t._needUVs=!0,t.MAINUV1=!0),t._areTexturesDirty&&n.texturesEnabled&&(this._texture&&ht.a.AnisotropicTextureEnabled?tt.a.PrepareDefinesForMergedUV(this._texture,t,"ANISOTROPIC_TEXTURE"):t.ANISOTROPIC_TEXTURE=!1)):(t.ANISOTROPIC=!1,t.ANISOTROPIC_TEXTURE=!1)},r.prototype.bindForSubMesh=function(t,e,n){t.useUbo&&n&&t.isSync||(this._texture&&ht.a.AnisotropicTextureEnabled&&(t.updateFloat2("vAnisotropyInfos",this._texture.coordinatesIndex,this._texture.level),tt.a.BindTextureMatrix(this._texture,t,"anisotropy")),t.updateFloat3("vAnisotropy",this.direction.x,this.direction.y,this.intensity)),e.texturesEnabled&&this._texture&&ht.a.AnisotropicTextureEnabled&&t.setTexture("anisotropySampler",this._texture)},r.prototype.hasTexture=function(t){return this._texture===t},r.prototype.getActiveTextures=function(t){this._texture&&t.push(this._texture)},r.prototype.getAnimatables=function(t){this._texture&&this._texture.animations&&this._texture.animations.length>0&&t.push(this._texture)},r.prototype.dispose=function(t){t&&this._texture&&this._texture.dispose()},r.prototype.getClassName=function(){return"PBRAnisotropicConfiguration"},r.AddFallbacks=function(t,e,n){return t.ANISOTROPIC&&e.addFallback(n++,"ANISOTROPIC"),n},r.AddUniforms=function(t){t.push("vAnisotropy","vAnisotropyInfos","anisotropyMatrix")},r.PrepareUniformBuffer=function(t){t.addUniform("vAnisotropy",3),t.addUniform("vAnisotropyInfos",2),t.addUniform("anisotropyMatrix",16)},r.AddSamplers=function(t){t.push("anisotropySampler")},r.prototype.copyTo=function(t){L.a.Clone(function(){return t},this)},r.prototype.serialize=function(){return L.a.Serialize(this)},r.prototype.parse=function(t,e,n){var i=this;L.a.Parse(function(){return i},t,e,n)},Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],r.prototype,"isEnabled",void 0),Object(c.c)([Object(L.c)()],r.prototype,"intensity",void 0),Object(c.c)([Object(L.n)()],r.prototype,"direction",void 0),Object(c.c)([Object(L.m)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],r.prototype,"texture",void 0),r}(),qp=function(){function r(t){this._useEnergyConservation=r.DEFAULT_USE_ENERGY_CONSERVATION,this.useEnergyConservation=r.DEFAULT_USE_ENERGY_CONSERVATION,this._useSmithVisibilityHeightCorrelated=r.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,this.useSmithVisibilityHeightCorrelated=r.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,this._useSphericalHarmonics=r.DEFAULT_USE_SPHERICAL_HARMONICS,this.useSphericalHarmonics=r.DEFAULT_USE_SPHERICAL_HARMONICS,this._useSpecularGlossinessInputEnergyConservation=r.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,this.useSpecularGlossinessInputEnergyConservation=r.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,this._internalMarkAllSubMeshesAsMiscDirty=t}return r.prototype._markAllSubMeshesAsMiscDirty=function(){this._internalMarkAllSubMeshesAsMiscDirty()},r.prototype.prepareDefines=function(t){t.BRDF_V_HEIGHT_CORRELATED=this._useSmithVisibilityHeightCorrelated,t.MS_BRDF_ENERGY_CONSERVATION=this._useEnergyConservation&&this._useSmithVisibilityHeightCorrelated,t.SPHERICAL_HARMONICS=this._useSphericalHarmonics,t.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION=this._useSpecularGlossinessInputEnergyConservation},r.prototype.getClassName=function(){return"PBRBRDFConfiguration"},r.prototype.copyTo=function(t){L.a.Clone(function(){return t},this)},r.prototype.serialize=function(){return L.a.Serialize(this)},r.prototype.parse=function(t,e,n){var i=this;L.a.Parse(function(){return i},t,e,n)},r.DEFAULT_USE_ENERGY_CONSERVATION=!0,r.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED=!0,r.DEFAULT_USE_SPHERICAL_HARMONICS=!0,r.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION=!0,Object(c.c)([Object(L.c)(),Ob
2253ject(L.b)("_markAllSubMeshesAsMiscDirty")],r.prototype,"useEnergyConservation",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsMiscDirty")],r.prototype,"useSmithVisibilityHeightCorrelated",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsMiscDirty")],r.prototype,"useSphericalHarmonics",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsMiscDirty")],r.prototype,"useSpecularGlossinessInputEnergyConservation",void 0),r}(),so=function(){function r(t){this._isEnabled=!1,this.isEnabled=!1,this._linkSheenWithAlbedo=!1,this.linkSheenWithAlbedo=!1,this.intensity=1,this.color=M.a.White(),this._texture=null,this.texture=null,this._useRoughnessFromMainTexture=!0,this.useRoughnessFromMainTexture=!0,this._roughness=null,this.roughness=null,this._textureRoughness=null,this.textureRoughness=null,this._albedoScaling=!1,this.albedoScaling=!1,this._internalMarkAllSubMeshesAsTexturesDirty=t}return r.prototype._markAllSubMeshesAsTexturesDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty()},r.prototype.isReadyForSubMesh=function(t,e){return!(t._areTexturesDirty&&e.texturesEnabled&&(this._texture&&ht.a.SheenTextureEnabled&&!this._texture.isReadyOrNotBlocking()||this._textureRoughness&&ht.a.SheenTextureEnabled&&!this._textureRoughness.isReadyOrNotBlocking()))},r.prototype.prepareDefines=function(t,e){var n;this._isEnabled?(t.SHEEN=this._isEnabled,t.SHEEN_LINKWITHALBEDO=this._linkSheenWithAlbedo,t.SHEEN_ROUGHNESS=this._roughness!==null,t.SHEEN_ALBEDOSCALING=this._albedoScaling,t.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE=this._useRoughnessFromMainTexture,t.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL=this._texture!==null&&this._texture._texture===((n=this._textureRoughness)===null||n===void 0?void 0:n._texture)&&this._texture.checkTransformsAreIdentical(this._textureRoughness),t._areTexturesDirty&&e.texturesEnabled&&(this._texture&&ht.a.SheenTextureEnabled?tt.a.PrepareDefinesForMergedUV(this._texture,t,"SHEEN_TEXTURE"):t.SHEEN_TEXTURE=!1,this._textureRoughness&&ht.a.SheenTextureEnabled?tt.a.PrepareDefinesForMergedUV(this._textureRoughness,t,"SHEEN_TEXTURE_ROUGHNESS"):t.SHEEN_TEXTURE_ROUGHNESS=!1)):(t.SHEEN=!1,t.SHEEN_TEXTURE=!1,t.SHEEN_TEXTURE_ROUGHNESS=!1,t.SHEEN_LINKWITHALBEDO=!1,t.SHEEN_ROUGHNESS=!1,t.SHEEN_ALBEDOSCALING=!1,t.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE=!1,t.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL=!1)},r.prototype.bindForSubMesh=function(t,e,n,i){var o,a,s,d,p,y,P,O,U=i._materialDefines,F=U.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL;t.useUbo&&n&&t.isSync||(F&&ht.a.SheenTextureEnabled?(t.updateFloat4("vSheenInfos",this._texture.coordinatesIndex,this._texture.level,-1,-1),tt.a.BindTextureMatrix(this._texture,t,"sheen")):(this._texture||this._textureRoughness)&&ht.a.SheenTextureEnabled&&(t.updateFloat4("vSheenInfos",(a=(o=this._texture)===null||o===void 0?void 0:o.coordinatesIndex)!==null&&a!==void 0?a:0,(d=(s=this._texture)===null||s===void 0?void 0:s.level)!==null&&d!==void 0?d:0,(y=(p=this._textureRoughness)===null||p===void 0?void 0:p.coordinatesIndex)!==null&&y!==void 0?y:0,(O=(P=this._textureRoughness)===null||P===void 0?void 0:P.level)!==null&&O!==void 0?O:0),this._texture&&tt.a.BindTextureMatrix(this._texture,t,"sheen"),!this._textureRoughness||F||U.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE||tt.a.BindTextureMatrix(this._textureRoughness,t,"sheenRoughness")),t.updateFloat4("vSheenColor",this.color.r,this.color.g,this.color.b,this.intensity),this._roughness!==null&&t.updateFloat("vSheenRoughness",this._roughness)),e.texturesEnabled&&(this._texture&&ht.a.SheenTextureEnabled&&t.setTexture("sheenSampler",this._texture),this._textureRoughness&&!F&&!U.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE&&ht.a.SheenTextureEnabled&&t.setTexture("sheenRoughnessSampler",this._textureRoughness))},r.prototype.hasTexture=function(t){return this._texture===t||this._textureRoughness===t},r.prototype.getActiveTextures=function(t){this._texture&&t.push(this._texture),this._textureRoughness&&t.push(this._textureRoughness)},r.prototype.getAnimatables=function(t){this._texture&&this._texture.animations&&this._texture.animations.length>0&&t.push(this._texture),this._textureRoughness&&this._textureRoughness.animations&&this._textureRoughness.animations.length>0&&t.push(this._textureRoughness)},r.prototype.dispose=function(t){var e,n;t&&((e=this._texture)===null||e===void 0||e.dispose(),(n=this._textureRoughness)===null||n===void 0||n.dispose())},r.prototype.getClassName=function(){return"PBRSheenConfiguration"},r.AddFallbacks=function(t,e,n){return t.SHEEN&&e.addFallback(n++,"SHEEN"),n},r.AddUniforms=function(t){t.push("vSheenColor","vSheenRoughness","vSheenInfos","sheenMatrix","sheenRoughnessMatrix")},r.PrepareUniformBuffer=function(t){t.addUniform("vSheenColor",4),t.addUniform("vSheenRoughness",1),t.addUniform("vSheenInfos",4),t.addUniform("sheenMatrix",16),t.addUniform("sheenRoughnessMatrix",16)},r.AddSamplers=function(t){t.push("sheenSampler"),t.push("sheenRoughnessSampler")},r.prototype.copyTo=function(t){L.a.Clone(function(){return t},this)},r.prototype.serialize=function(){return L.a.Serialize(this)},r.prototype.parse=function(t,e,n){var i=this;L.a.Parse(function(){return i},t,e,n)}
2253,Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],r.prototype,"isEnabled",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],r.prototype,"linkSheenWithAlbedo",void 0),Object(c.c)([Object(L.c)()],r.prototype,"intensity",void 0),Object(c.c)([Object(L.e)()],r.prototype,"color",void 0),Object(c.c)([Object(L.m)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],r.prototype,"texture",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useRoughnessFromMainTexture",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],r.prototype,"roughness",void 0),Object(c.c)([Object(L.m)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],r.prototype,"textureRoughness",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],r.prototype,"albedoScaling",void 0),r}(),co=function(){function r(t,e,n){this._isRefractionEnabled=!1,this.isRefractionEnabled=!1,this._isTranslucencyEnabled=!1,this.isTranslucencyEnabled=!1,this._isScatteringEnabled=!1,this.isScatteringEnabled=!1,this._scatteringDiffusionProfileIndex=0,this.refractionIntensity=1,this.translucencyIntensity=1,this.useAlbedoToTintRefraction=!1,this._thicknessTexture=null,this.thicknessTexture=null,this._refractionTexture=null,this.refractionTexture=null,this._indexOfRefraction=1.5,this.indexOfRefraction=1.5,this._volumeIndexOfRefraction=-1,this._invertRefractionY=!1,this.invertRefractionY=!1,this._linkRefractionWithTransparency=!1,this.linkRefractionWithTransparency=!1,this.minimumThickness=0,this.maximumThickness=1,this.tintColor=M.a.White(),this.tintColorAtDistance=1,this.diffusionDistance=M.a.White(),this._useMaskFromThicknessTexture=!1,this.useMaskFromThicknessTexture=!1,this._useMaskFromThicknessTextureGltf=!1,this.useMaskFromThicknessTextureGltf=!1,this._internalMarkAllSubMeshesAsTexturesDirty=t,this._internalMarkScenePrePassDirty=e,this._scene=n}return Object.defineProperty(r.prototype,"scatteringDiffusionProfile",{get:function(){return this._scene.subSurfaceConfiguration?this._scene.subSurfaceConfiguration.ssDiffusionProfileColors[this._scatteringDiffusionProfileIndex]:null},set:function(t){this._scene.enableSubSurfaceForPrePass()&&t&&(this._scatteringDiffusionProfileIndex=this._scene.subSurfaceConfiguration.addDiffusionProfile(t))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"volumeIndexOfRefraction",{get:function(){return this._volumeIndexOfRefraction>=1?this._volumeIndexOfRefraction:this._indexOfRefraction},set:function(t){this._volumeIndexOfRefraction=t>=1?t:-1},enumerable:!1,configurable:!0}),r.prototype._markAllSubMeshesAsTexturesDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty()},r.prototype._markScenePrePassDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty(),this._internalMarkScenePrePassDirty()},r.prototype.isReadyForSubMesh=function(t,e){if(t._areTexturesDirty&&e.texturesEnabled){if(this._thicknessTexture&&ht.a.ThicknessTextureEnabled&&!this._thicknessTexture.isReadyOrNotBlocking())return!1;var n=this._getRefractionTexture(e);if(n&&ht.a.RefractionTextureEnabled&&!n.isReadyOrNotBlocking())return!1}return!0},r.prototype.prepareDefines=function(t,e){if(t._areTexturesDirty&&(t.SUBSURFACE=!1,t.SS_TRANSLUCENCY=this._isTranslucencyEnabled,t.SS_SCATTERING=this._isScatteringEnabled,t.SS_THICKNESSANDMASK_TEXTURE=!1,t.SS_MASK_FROM_THICKNESS_TEXTURE=!1,t.SS_MASK_FROM_THICKNESS_TEXTURE_GLTF=!1,t.SS_REFRACTION=!1,t.SS_REFRACTIONMAP_3D=!1,t.SS_GAMMAREFRACTION=!1,t.SS_RGBDREFRACTION=!1,t.SS_LINEARSPECULARREFRACTION=!1,t.SS_REFRACTIONMAP_OPPOSITEZ=!1,t.SS_LODINREFRACTIONALPHA=!1,t.SS_LINKREFRACTIONTOTRANSPARENCY=!1,t.SS_ALBEDOFORREFRACTIONTINT=!1,(this._isRefractionEnabled||this._isTranslucencyEnabled||this._isScatteringEnabled)&&(t.SUBSURFACE=!0,t._areTexturesDirty&&e.texturesEnabled&&this._thicknessTexture&&ht.a.ThicknessTextureEnabled&&tt.a.PrepareDefinesForMergedUV(this._thicknessTexture,t,"SS_THICKNESSANDMASK_TEXTURE"),t.SS_MASK_FROM_THICKNESS_TEXTURE=this._useMaskFromThicknessTexture,t.SS_MASK_FROM_THICKNESS_TEXTURE_GLTF=this._useMaskFromThicknessTextureGltf),this._isRefractionEnabled&&e.texturesEnabled)){var n=this._getRefractionTexture(e);n&&ht.a.RefractionTextureEnabled&&(t.SS_REFRACTION=!0,t.SS_REFRACTIONMAP_3D=n.isCube,t.SS_GAMMAREFRACTION=n.gammaSpace,t.SS_RGBDREFRACTION=n.isRGBD,t.SS_LINEARSPECULARREFRACTION=n.linearSpecularLOD,t.SS_REFRACTIONMAP_OPPOSITEZ=n.invertZ,t.SS_LODINREFRACTIONALPHA=n.lodLevelInAlpha,t.SS_LINKREFRACTIONTOTRANSPARENCY=this._linkRefractionWithTransparency,t.SS_ALBEDOFORREFRACTIONTINT=this.useAlbedoToTintRefraction)}},r.prototype.bindForSubMesh=function(t,e,n,i,o,a){var s=this._getRefractionTexture(e);
2253if(!t.useUbo||!i||!t.isSync){if(this._thicknessTexture&&ht.a.ThicknessTextureEnabled&&(t.updateFloat2("vThicknessInfos",this._thicknessTexture.coordinatesIndex,this._thicknessTexture.level),tt.a.BindTextureMatrix(this._thicknessTexture,t,"thickness")),t.updateFloat2("vThicknessParam",this.minimumThickness,this.maximumThickness-this.minimumThickness),s&&ht.a.RefractionTextureEnabled){t.updateMatrix("refractionMatrix",s.getReflectionTextureMatrix());var d=1;s.isCube||s.depth&&(d=s.depth);var p=s.getSize().width,y=this.volumeIndexOfRefraction;t.updateFloat4("vRefractionInfos",s.level,1/y,d,this._invertRefractionY?-1:1),t.updateFloat3("vRefractionMicrosurfaceInfos",p,s.lodGenerationScale,s.lodGenerationOffset),a&&t.updateFloat2("vRefractionFilteringInfo",p,$.a.Log2(p))}this.isScatteringEnabled&&t.updateFloat("scatteringDiffusionProfile",this._scatteringDiffusionProfileIndex),t.updateColor3("vDiffusionDistance",this.diffusionDistance),t.updateFloat4("vTintColor",this.tintColor.r,this.tintColor.g,this.tintColor.b,this.tintColorAtDistance),t.updateFloat3("vSubSurfaceIntensity",this.refractionIntensity,this.translucencyIntensity,0)}e.texturesEnabled&&(this._thicknessTexture&&ht.a.ThicknessTextureEnabled&&t.setTexture("thicknessSampler",this._thicknessTexture),s&&ht.a.RefractionTextureEnabled&&(o?t.setTexture("refractionSampler",s):(t.setTexture("refractionSampler",s._lodTextureMid||s),t.setTexture("refractionSamplerLow",s._lodTextureLow||s),t.setTexture("refractionSamplerHigh",s._lodTextureHigh||s))))},r.prototype.unbind=function(t){return!(!this._refractionTexture||!this._refractionTexture.isRenderTarget)&&(t.setTexture("refractionSampler",null),!0)},r.prototype._getRefractionTexture=function(t){return this._refractionTexture?this._refractionTexture:this._isRefractionEnabled?t.environmentTexture:null},Object.defineProperty(r.prototype,"disableAlphaBlending",{get:function(){return this.isRefractionEnabled&&this._linkRefractionWithTransparency},enumerable:!1,configurable:!0}),r.prototype.fillRenderTargetTextures=function(t){ht.a.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget&&t.push(this._refractionTexture)},r.prototype.hasTexture=function(t){return this._thicknessTexture===t||this._refractionTexture===t},r.prototype.hasRenderTargetTextures=function(){return!!(ht.a.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget)},r.prototype.getActiveTextures=function(t){this._thicknessTexture&&t.push(this._thicknessTexture),this._refractionTexture&&t.push(this._refractionTexture)},r.prototype.getAnimatables=function(t){this._thicknessTexture&&this._thicknessTexture.animations&&this._thicknessTexture.animations.length>0&&t.push(this._thicknessTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&t.push(this._refractionTexture)},r.prototype.dispose=function(t){t&&(this._thicknessTexture&&this._thicknessTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose())},r.prototype.getClassName=function(){return"PBRSubSurfaceConfiguration"},r.AddFallbacks=function(t,e,n){return t.SS_SCATTERING&&e.addFallback(n++,"SS_SCATTERING"),t.SS_TRANSLUCENCY&&e.addFallback(n++,"SS_TRANSLUCENCY"),n},r.AddUniforms=function(t){t.push("vDiffusionDistance","vTintColor","vSubSurfaceIntensity","vRefractionMicrosurfaceInfos","vRefractionFilteringInfo","vRefractionInfos","vThicknessInfos","vThicknessParam","refractionMatrix","thicknessMatrix","scatteringDiffusionProfile")},r.AddSamplers=function(t){t.push("thicknessSampler","refractionSampler","refractionSamplerLow","refractionSamplerHigh")},r.PrepareUniformBuffer=function(t){t.addUniform("vRefractionMicrosurfaceInfos",3),t.addUniform("vRefractionFilteringInfo",2),t.addUniform("vRefractionInfos",4),t.addUniform("refractionMatrix",16),t.addUniform("vThicknessInfos",2),t.addUniform("thicknessMatrix",16),t.addUniform("vThicknessParam",2),t.addUniform("vDiffusionDistance",3),t.addUniform("vTintColor",4),t.addUniform("vSubSurfaceIntensity",3),t.addUniform("scatteringDiffusionProfile",1)},r.prototype.copyTo=function(t){L.a.Clone(function(){return t},this)},r.prototype.serialize=function(){return L.a.Serialize(this)},r.prototype.parse=function(t,e,n){var i=this;L.a.Parse(function(){return i},t,e,n)}
2253,Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],r.prototype,"isRefractionEnabled",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],r.prototype,"isTranslucencyEnabled",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markScenePrePassDirty")],r.prototype,"isScatteringEnabled",void 0),Object(c.c)([Object(L.c)()],r.prototype,"_scatteringDiffusionProfileIndex",void 0),Object(c.c)([Object(L.c)()],r.prototype,"refractionIntensity",void 0),Object(c.c)([Object(L.c)()],r.prototype,"translucencyIntensity",void 0),Object(c.c)([Object(L.c)()],r.prototype,"useAlbedoToTintRefraction",void 0),Object(c.c)([Object(L.m)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],r.prototype,"thicknessTexture",void 0),Object(c.c)([Object(L.m)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],r.prototype,"refractionTexture",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],r.prototype,"indexOfRefraction",void 0),Object(c.c)([Object(L.c)()],r.prototype,"_volumeIndexOfRefraction",void 0),Object(c.c)([Object(L.b)("_markAllSubMeshesAsTexturesDirty")],r.prototype,"volumeIndexOfRefraction",null),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],r.prototype,"invertRefractionY",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],r.prototype,"linkRefractionWithTransparency",void 0),Object(c.c)([Object(L.c)()],r.prototype,"minimumThickness",void 0),Object(c.c)([Object(L.c)()],r.prototype,"maximumThickness",void 0),Object(c.c)([Object(L.e)()],r.prototype,"tintColor",void 0),Object(c.c)([Object(L.c)()],r.prototype,"tintColorAtDistance",void 0),Object(c.c)([Object(L.e)()],r.prototype,"diffusionDistance",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useMaskFromThicknessTexture",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useMaskFromThicknessTextureGltf",void 0),r}(),Vs=f(105),Ht=f(25),Zp=(f(160),`uniform vec3 vReflectionColor;
2254uniform vec4 vAlbedoColor;
2255
2256uniform vec4 vLightingIntensity;
2257uniform vec4 vReflectivityColor;
2258uniform vec4 vMetallicReflectanceFactors;
2259uniform vec3 vEmissiveColor;
2260uniform float visibility;
2261
2262#ifdef ALBEDO
2263uniform vec2 vAlbedoInfos;
2264#endif
2265#ifdef AMBIENT
2266uniform vec4 vAmbientInfos;
2267#endif
2268#ifdef BUMP
2269uniform vec3 vBumpInfos;
2270uniform vec2 vTangentSpaceParams;
2271#endif
2272#ifdef OPACITY
2273uniform vec2 vOpacityInfos;
2274#endif
2275#ifdef EMISSIVE
2276uniform vec2 vEmissiveInfos;
2277#endif
2278#ifdef LIGHTMAP
2279uniform vec2 vLightmapInfos;
2280#endif
2281#ifdef REFLECTIVITY
2282uniform vec3 vReflectivityInfos;
2283#endif
2284#ifdef MICROSURFACEMAP
2285uniform vec2 vMicroSurfaceSamplerInfos;
2286#endif
2287
2288#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(SS_REFRACTION)
2289uniform mat4 view;
2290#endif
2291
2292#ifdef REFLECTION
2293uniform vec2 vReflectionInfos;
2294#ifdef REALTIME_FILTERING
2295uniform vec2 vReflectionFilteringInfo;
2296#endif
2297uniform mat4 reflectionMatrix;
2298uniform vec3 vReflectionMicrosurfaceInfos;
2299#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)
2300uniform vec3 vReflectionPosition;
2301uniform vec3 vReflectionSize;
2302#endif
2303#endif
2304
2305#ifdef CLEARCOAT
2306uniform vec2 vClearCoatParams;
2307uniform vec4 vClearCoatRefractionParams;
2308#if defined(CLEARCOAT_TEXTURE) || defined(CLEARCOAT_TEXTURE_ROUGHNESS)
2309uniform vec4 vClearCoatInfos;
2310#endif
2311#ifdef CLEARCOAT_TEXTURE
2312uniform mat4 clearCoatMatrix;
2313#endif
2314#ifdef CLEARCOAT_TEXTURE_ROUGHNESS
2315uniform mat4 clearCoatRoughnessMatrix;
2316#endif
2317#ifdef CLEARCOAT_BUMP
2318uniform vec2 vClearCoatBumpInfos;
2319uniform vec2 vClearCoatTangentSpaceParams;
2320uniform mat4 clearCoatBumpMatrix;
2321#endif
2322#ifdef CLEARCOAT_TINT
2323uniform vec4 vClearCoatTintParams;
2324uniform float clearCoatColorAtDistance;
2325#ifdef CLEARCOAT_TINT_TEXTURE
2326uniform vec2 vClearCoatTintInfos;
2327uniform mat4 clearCoatTintMatrix;
2328#endif
2329#endif
2330#endif
2331
2332#ifdef ANISOTROPIC
2333uniform vec3 vAnisotropy;
2334#ifdef ANISOTROPIC_TEXTURE
2335uniform vec2 vAnisotropyInfos;
2336uniform mat4 anisotropyMatrix;
2337#endif
2338#endif
2339
2340#ifdef SHEEN
2341uniform vec4 vSheenColor;
2342#ifdef SHEEN_ROUGHNESS
2343uniform float vSheenRoughness;
2344#endif
2345#if defined(SHEEN_TEXTURE) || defined(SHEEN_TEXTURE_ROUGHNESS)
2346uniform vec4 vSheenInfos;
2347#endif
2348#ifdef SHEEN_TEXTURE
2349uniform mat4 sheenMatrix;
2350#endif
2351#ifdef SHEEN_TEXTURE_ROUGHNESS
2352uniform mat4 sheenRoughnessMatrix;
2353#endif
2354#endif
2355
2356#ifdef SUBSURFACE
2357#ifdef SS_REFRACTION
2358uniform vec3 vRefractionMicrosurfaceInfos;
2359uniform vec4 vRefractionInfos;
2360uniform mat4 refractionMatrix;
2361#ifdef REALTIME_FILTERING
2362uniform vec2 vRefractionFilteringInfo;
2363#endif
2364#endif
2365#ifdef SS_THICKNESSANDMASK_TEXTURE
2366uniform vec2 vThicknessInfos;
2367uniform mat4 thicknessMatrix;
2368#endif
2369uniform vec2 vThicknessParam;
2370uniform vec3 vDiffusionDistance;
2371uniform vec4 vTintColor;
2372uniform vec3 vSubSurfaceIntensity;
2373#endif
2374#ifdef PREPASS
2375#ifdef PREPASS_IRRADIANCE
2376uniform float scatteringDiffusionProfile;
2377#endif
2378#endif`);je.a.IncludesShadersStore.pbrFragmentDeclaration=Zp;var Jp=`layout(std140,column_major) uniform;
2379uniform Material
2380{
2381uniform vec2 vAlbedoInfos;
2382uniform vec4 vAmbientInfos;
2383uniform vec2 vOpacityInfos;
2384uniform vec2 vEmissiveInfos;
2385uniform vec2 vLightmapInfos;
2386uniform vec3 vReflectivityInfos;
2387uniform vec2 vMicroSurfaceSamplerInfos;
2388uniform vec2 vReflectionInfos;
2389uniform vec2 vReflectionFilteringInfo;
2390uniform vec3 vReflectionPosition;
2391uniform vec3 vReflectionSize;
2392uniform vec3 vBumpInfos;
2393uniform mat4 albedoMatrix;
2394uniform mat4 ambientMatrix;
2395uniform mat4 opacityMatrix;
2396uniform mat4 emissiveMatrix;
2397uniform mat4 lightmapMatrix;
2398uniform mat4 reflectivityMatrix;
2399uniform mat4 microSurfaceSamplerMatrix;
2400uniform mat4 bumpMatrix;
2401uniform vec2 vTangentSpaceParams;
2402uniform mat4 reflectionMatrix;
2403uniform vec3 vReflectionColor;
2404uniform vec4 vAlbedoColor;
2405uniform vec4 vLightingIntensity;
2406uniform vec3 vReflectionMicrosurfaceInfos;
2407uniform float pointSize;
2408uniform vec4 vReflectivityColor;
2409uniform vec3 vEmissiveColor;
2410uniform float visibility;
2411uniform vec4 vMetallicReflectanceFactors;
2412uniform vec2 vMetallicReflectanceInfos;
2413uniform mat4 metallicReflectanceMatrix;
2414uniform vec2 vClearCoatParams;
2415uniform vec4 vClearCoatRefractionParams;
2416uniform vec4 vClearCoatInfos;
2417uniform mat4 clearCoatMatrix;
2418uniform mat4 clearCoatRoughnessMatrix;
2419uniform vec2 vClearCoatBumpInfos;
2420uniform vec2 vClearCoatTangentSpaceParams;
2421uniform mat4 clearCoatBumpMatrix;
2422uniform vec4 vClearCoatTintParams;
2423uniform float clearCoatColorAtDistance;
2424uniform vec2 vClearCoatTintInfos;
2425uniform mat4 clearCoatTintMatrix;
2426uniform vec3 vAnisotropy;
2427uniform vec2 vAnisotropyInfos;
2428uniform mat4 anisotropyMatrix;
2429uniform vec4 vSheenColor;
2430uniform float vSheenRoughness;
2431uniform vec4 vSheenInfos;
2432uniform mat4 sheenMatrix;
2433uniform mat4 sheenRoughnessMatrix;
2434uniform vec3 vRefractionMicrosurfaceInfos;
2435uniform vec2 vRefractionFilteringInfo;
2436uniform vec4 vRefractionInfos;
2437uniform mat4 refractionMatrix;
2438uniform vec2 vThicknessInfos;
2439uniform mat4 thicknessMatrix;
2440uniform vec2 vThicknessParam;
2441uniform vec3 vDiffusionDistance;
2442uniform vec4 vTintColor;
2443uniform vec3 vSubSurfaceIntensity;
2444uniform float scatteringDiffusionProfile;
2445uniform vec4 vDetailInfos;
2446uniform mat4 detailMatrix;
2447};
2448uniform Scene {
2449mat4 viewProjection;
2450#ifdef MULTIVIEW
2451mat4 viewProjectionR;
2452#endif
2453mat4 view;
2454};`;je.a.IncludesShadersStore.pbrUboDeclaration=Jp;var $p=`uniform vec4 vEyePosition;
2455uniform vec3 vAmbientColor;
2456uniform vec4 vCameraInfos;
2457
2458varying vec3 vPositionW;
2459#if DEBUGMODE>0
2460uniform vec2 vDebugMode;
2461varying vec4 vClipSpacePosition;
2462#endif
2463#ifdef MAINUV1
2464varying vec2 vMainUV1;
2465#endif
2466#ifdef MAINUV2
2467varying vec2 vMainUV2;
2468#endif
2469#ifdef NORMAL
2470varying vec3 vNormalW;
2471#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
2472varying vec3 vEnvironmentIrradiance;
2473#endif
2474#endif
2475#ifdef VERTEXCOLOR
2476varying vec4 vColor;
2477#endif`;je.a.IncludesShadersStore.pbrFragmentExtraDeclaration=$p;var e_=`#ifdef ALBEDO
2478#if ALBEDODIRECTUV == 1
2479#define vAlbedoUV vMainUV1
2480#elif ALBEDODIRECTUV == 2
2481#define vAlbedoUV vMainUV2
2482#else
2483varying vec2 vAlbedoUV;
2484#endif
2485uniform sampler2D albedoSampler;
2486#endif
2487#ifdef AMBIENT
2488#if AMBIENTDIRECTUV == 1
2489#define vAmbientUV vMainUV1
2490#elif AMBIENTDIRECTUV == 2
2491#define vAmbientUV vMainUV2
2492#else
2493varying vec2 vAmbientUV;
2494#endif
2495uniform sampler2D ambientSampler;
2496#endif
2497#ifdef OPACITY
2498#if OPACITYDIRECTUV == 1
2499#define vOpacityUV vMainUV1
2500#elif OPACITYDIRECTUV == 2
2501#define vOpacityUV vMainUV2
2502#else
2503varying vec2 vOpacityUV;
2504#endif
2505uniform sampler2D opacitySampler;
2506#endif
2507#ifdef EMISSIVE
2508#if EMISSIVEDIRECTUV == 1
2509#define vEmissiveUV vMainUV1
2510#elif EMISSIVEDIRECTUV == 2
2511#define vEmissiveUV vMainUV2
2512#else
2513varying vec2 vEmissiveUV;
2514#endif
2515uniform sampler2D emissiveSampler;
2516#endif
2517#ifdef LIGHTMAP
2518#if LIGHTMAPDIRECTUV == 1
2519#define vLightmapUV vMainUV1
2520#elif LIGHTMAPDIRECTUV == 2
2521#define vLightmapUV vMainUV2
2522#else
2523varying vec2 vLightmapUV;
2524#endif
2525uniform sampler2D lightmapSampler;
2526#endif
2527#ifdef REFLECTIVITY
2528#if REFLECTIVITYDIRECTUV == 1
2529#define vReflectivityUV vMainUV1
2530#elif REFLECTIVITYDIRECTUV == 2
2531#define vReflectivityUV vMainUV2
2532#else
2533varying vec2 vReflectivityUV;
2534#endif
2535uniform sampler2D reflectivitySampler;
2536#endif
2537#ifdef MICROSURFACEMAP
2538#if MICROSURFACEMAPDIRECTUV == 1
2539#define vMicroSurfaceSamplerUV vMainUV1
2540#elif MICROSURFACEMAPDIRECTUV == 2
2541#define vMicroSurfaceSamplerUV vMainUV2
2542#else
2543varying vec2 vMicroSurfaceSamplerUV;
2544#endif
2545uniform sampler2D microSurfaceSampler;
2546#endif
2547#ifdef METALLIC_REFLECTANCE
2548#if METALLIC_REFLECTANCEDIRECTUV == 1
2549#define vMetallicReflectanceUV vMainUV1
2550#elif METALLIC_REFLECTANCEDIRECTUV == 2
2551#define vMetallicReflectanceUV vMainUV2
2552#else
2553varying vec2 vMetallicReflectanceUV;
2554#endif
2555uniform sampler2D metallicReflectanceSampler;
2556#endif
2557#ifdef CLEARCOAT
2558#if defined(CLEARCOAT_TEXTURE)
2559#if CLEARCOAT_TEXTUREDIRECTUV == 1
2560#define vClearCoatUV vMainUV1
2561#elif CLEARCOAT_TEXTUREDIRECTUV == 2
2562#define vClearCoatUV vMainUV2
2563#else
2564varying vec2 vClearCoatUV;
2565#endif
2566#endif
2567#if defined(CLEARCOAT_TEXTURE_ROUGHNESS)
2568#if CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV == 1
2569#define vClearCoatRoughnessUV vMainUV1
2570#elif CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV == 2
2571#define vClearCoatRoughnessUV vMainUV2
2572#else
2573varying vec2 vClearCoatRoughnessUV;
2574#endif
2575#endif
2576#ifdef CLEARCOAT_TEXTURE
2577uniform sampler2D clearCoatSampler;
2578#endif
2579#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL)
2580uniform sampler2D clearCoatRoughnessSampler;
2581#endif
2582#ifdef CLEARCOAT_BUMP
2583#if CLEARCOAT_BUMPDIRECTUV == 1
2584#define vClearCoatBumpUV vMainUV1
2585#elif CLEARCOAT_BUMPDIRECTUV == 2
2586#define vClearCoatBumpUV vMainUV2
2587#else
2588varying vec2 vClearCoatBumpUV;
2589#endif
2590uniform sampler2D clearCoatBumpSampler;
2591#endif
2592#ifdef CLEARCOAT_TINT_TEXTURE
2593#if CLEARCOAT_TINT_TEXTUREDIRECTUV == 1
2594#define vClearCoatTintUV vMainUV1
2595#elif CLEARCOAT_TINT_TEXTUREDIRECTUV == 2
2596#define vClearCoatTintUV vMainUV2
2597#else
2598varying vec2 vClearCoatTintUV;
2599#endif
2600uniform sampler2D clearCoatTintSampler;
2601#endif
2602#endif
2603#ifdef SHEEN
2604#ifdef SHEEN_TEXTURE
2605#if SHEEN_TEXTUREDIRECTUV == 1
2606#define vSheenUV vMainUV1
2607#elif SHEEN_TEXTUREDIRECTUV == 2
2608#define vSheenUV vMainUV2
2609#else
2610varying vec2 vSheenUV;
2611#endif
2612#endif
2613#ifdef SHEEN_TEXTURE_ROUGHNESS
2614#if SHEEN_TEXTURE_ROUGHNESSDIRECTUV == 1
2615#define vSheenRoughnessUV vMainUV1
2616#elif SHEEN_TEXTURE_ROUGHNESSDIRECTUV == 2
2617#define vSheenRoughnessUV vMainUV2
2618#else
2619varying vec2 vSheenRoughnessUV;
2620#endif
2621#endif
2622#ifdef SHEEN_TEXTURE
2623uniform sampler2D sheenSampler;
2624#endif
2625#if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL)
2626uniform sampler2D sheenRoughnessSampler;
2627#endif
2628#endif
2629#ifdef ANISOTROPIC
2630#ifdef ANISOTROPIC_TEXTURE
2631#if ANISOTROPIC_TEXTUREDIRECTUV == 1
2632#define vAnisotropyUV vMainUV1
2633#elif ANISOTROPIC_TEXTUREDIRECTUV == 2
2634#define vAnisotropyUV vMainUV2
2635#else
2636varying vec2 vAnisotropyUV;
2637#endif
2638uniform sampler2D anisotropySampler;
2639#endif
2640#endif
2641
2642#ifdef REFLECTION
2643#ifdef REFLECTIONMAP_3D
2644#define sampleReflection(s,c) textureCube(s,c)
2645uniform samplerCube reflectionSampler;
2646#ifdef LODBASEDMICROSFURACE
2647#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)
2648#else
2649uniform samplerCube reflectionSamplerLow;
2650uniform samplerCube reflectionSamplerHigh;
2651#endif
2652#ifdef USEIRRADIANCEMAP
2653uniform samplerCube irradianceSampler;
2654#endif
2655#else
2656#define sampleReflection(s,c) texture2D(s,c)
2657uniform sampler2D reflectionSampler;
2658#ifdef LODBASEDMICROSFURACE
2659#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)
2660#else
2661uniform sampler2D reflectionSamplerLow;
2662uniform sampler2D reflectionSamplerHigh;
2663#endif
2664#ifdef USEIRRADIANCEMAP
2665uniform sampler2D irradianceSampler;
2666#endif
2667#endif
2668#ifdef REFLECTIONMAP_SKYBOX
2669varying vec3 vPositionUVW;
2670#else
2671#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
2672varying vec3 vDirectionW;
2673#endif
2674#endif
2675#endif
2676#ifdef ENVIRONMENTBRDF
2677uniform sampler2D environmentBrdfSampler;
2678#endif
2679
2680#ifdef SUBSURFACE
2681#ifdef SS_REFRACTION
2682#ifdef SS_REFRACTIONMAP_3D
2683#define sampleRefraction(s,c) textureCube(s,c)
2684uniform samplerCube refractionSampler;
2685#ifdef LODBASEDMICROSFURACE
2686#define sampleRefractionLod(s,c,l) textureCubeLodEXT(s,c,l)
2687#else
2688uniform samplerCube refractionSamplerLow;
2689uniform samplerCube refractionSamplerHigh;
2690#endif
2691#else
2692#define sampleRefraction(s,c) texture2D(s,c)
2693uniform sampler2D refractionSampler;
2694#ifdef LODBASEDMICROSFURACE
2695#define sampleRefractionLod(s,c,l) texture2DLodEXT(s,c,l)
2696#else
2697uniform sampler2D refractionSamplerLow;
2698uniform sampler2D refractionSamplerHigh;
2699#endif
2700#endif
2701#endif
2702#ifdef SS_THICKNESSANDMASK_TEXTURE
2703#if SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 1
2704#define vThicknessUV vMainUV1
2705#elif SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 2
2706#define vThicknessUV vMainUV2
2707#else
2708varying vec2 vThicknessUV;
2709#endif
2710uniform sampler2D thicknessSampler;
2711#endif
2712#endif`;je.a.IncludesShadersStore.pbrFragmentSamplersDeclaration=e_,f(116),je.a.IncludesShadersStore.subSurfaceScatteringFunctions=`bool testLightingForSSS(float diffusionProfile)
2713{
2714return diffusionProfile<1.;
2715}`;var t_=`
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744vec3 hemisphereCosSample(vec2 u) {
2745
2746float phi=2.*PI*u.x;
2747float cosTheta2=1.-u.y;
2748float cosTheta=sqrt(cosTheta2);
2749float sinTheta=sqrt(1.-cosTheta2);
2750return vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);
2751}
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789vec3 hemisphereImportanceSampleDggx(vec2 u,float a) {
2790
2791float phi=2.*PI*u.x;
2792
2793float cosTheta2=(1.-u.y)/(1.+(a+1.)*((a-1.)*u.y));
2794float cosTheta=sqrt(cosTheta2);
2795float sinTheta=sqrt(1.-cosTheta2);
2796return vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);
2797}
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855vec3 hemisphereImportanceSampleDCharlie(vec2 u,float a) {
2856
2857float phi=2.*PI*u.x;
2858float sinTheta=pow(u.y,a/(2.*a+1.));
2859float cosTheta=sqrt(1.-sinTheta*sinTheta);
2860return vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);
2861}`;je.a.IncludesShadersStore.importanceSampling=t_;var n_=`
2862#define RECIPROCAL_PI2 0.15915494
2863#define RECIPROCAL_PI 0.31830988618
2864
2865#define MINIMUMVARIANCE 0.0005
2866float convertRoughnessToAverageSlope(float roughness)
2867{
2868
2869return square(roughness)+MINIMUMVARIANCE;
2870}
2871float fresnelGrazingReflectance(float reflectance0) {
2872
2873
2874float reflectance90=saturate(reflectance0*25.0);
2875return reflectance90;
2876}
2877vec2 getAARoughnessFactors(vec3 normalVector) {
2878#ifdef SPECULARAA
2879vec3 nDfdx=dFdx(normalVector.xyz);
2880vec3 nDfdy=dFdy(normalVector.xyz);
2881float slopeSquare=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy));
2882
2883float geometricRoughnessFactor=pow(saturate(slopeSquare),0.333);
2884
2885float geometricAlphaGFactor=sqrt(slopeSquare);
2886
2887geometricAlphaGFactor*=0.75;
2888return vec2(geometricRoughnessFactor,geometricAlphaGFactor);
2889#else
2890return vec2(0.);
2891#endif
2892}
2893#ifdef ANISOTROPIC
2894
2895
2896vec2 getAnisotropicRoughness(float alphaG,float anisotropy) {
2897float alphaT=max(alphaG*(1.0+anisotropy),MINIMUMVARIANCE);
2898float alphaB=max(alphaG*(1.0-anisotropy),MINIMUMVARIANCE);
2899return vec2(alphaT,alphaB);
2900}
2901
2902
2903vec3 getAnisotropicBentNormals(const vec3 T,const vec3 B,const vec3 N,const vec3 V,float anisotropy) {
2904vec3 anisotropicFrameDirection=anisotropy>=0.0 ? B : T;
2905vec3 anisotropicFrameTangent=cross(normalize(anisotropicFrameDirection),V);
2906vec3 anisotropicFrameNormal=cross(anisotropicFrameTangent,anisotropicFrameDirection);
2907vec3 anisotropicNormal=normalize(mix(N,anisotropicFrameNormal,abs(anisotropy)));
2908return anisotropicNormal;
2909
2910}
2911#endif
2912#if defined(CLEARCOAT) || defined(SS_REFRACTION)
2913
2914
2915
2916vec3 cocaLambert(vec3 alpha,float distance) {
2917return exp(-alpha*distance);
2918}
2919
2920vec3 cocaLambert(float NdotVRefract,float NdotLRefract,vec3 alpha,float thickness) {
2921return cocaLambert(alpha,(thickness*((NdotLRefract+NdotVRefract)/(NdotLRefract*NdotVRefract))));
2922}
2923
2924vec3 computeColorAtDistanceInMedia(vec3 color,float distance) {
2925return -log(color)/distance;
2926}
2927vec3 computeClearCoatAbsorption(float NdotVRefract,float NdotLRefract,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {
2928vec3 clearCoatAbsorption=mix(vec3(1.0),
2929cocaLambert(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness),
2930clearCoatIntensity);
2931return clearCoatAbsorption;
2932}
2933#endif
2934
2935
2936
2937
2938#ifdef MICROSURFACEAUTOMATIC
2939float computeDefaultMicroSurface(float microSurface,vec3 reflectivityColor)
2940{
2941const float kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95;
2942float reflectivityLuminance=getLuminance(reflectivityColor);
2943float reflectivityLuma=sqrt(reflectivityLuminance);
2944microSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;
2945return microSurface;
2946}
2947#endif`;je.a.IncludesShadersStore.pbrHelperFunctions=n_;var i_=`#ifdef USESPHERICALFROMREFLECTIONMAP
2948#ifdef SPHERICAL_HARMONICS
2949uniform vec3 vSphericalL00;
2950uniform vec3 vSphericalL1_1;
2951uniform vec3 vSphericalL10;
2952uniform vec3 vSphericalL11;
2953uniform vec3 vSphericalL2_2;
2954uniform vec3 vSphericalL2_1;
2955uniform vec3 vSphericalL20;
2956uniform vec3 vSphericalL21;
2957uniform vec3 vSphericalL22;
2958
2959
2960
2961
2962
2963
2964
2965vec3 computeEnvironmentIrradiance(vec3 normal) {
2966return vSphericalL00
2967+vSphericalL1_1*(normal.y)
2968+vSphericalL10*(normal.z)
2969+vSphericalL11*(normal.x)
2970+vSphericalL2_2*(normal.y*normal.x)
2971+vSphericalL2_1*(normal.y*normal.z)
2972+vSphericalL20*((3.0*normal.z*normal.z)-1.0)
2973+vSphericalL21*(normal.z*normal.x)
2974+vSphericalL22*(normal.x*normal.x-(normal.y*normal.y));
2975}
2976#else
2977uniform vec3 vSphericalX;
2978uniform vec3 vSphericalY;
2979uniform vec3 vSphericalZ;
2980uniform vec3 vSphericalXX_ZZ;
2981uniform vec3 vSphericalYY_ZZ;
2982uniform vec3 vSphericalZZ;
2983uniform vec3 vSphericalXY;
2984uniform vec3 vSphericalYZ;
2985uniform vec3 vSphericalZX;
2986
2987vec3 computeEnvironmentIrradiance(vec3 normal) {
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997float Nx=normal.x;
2998float Ny=normal.y;
2999float Nz=normal.z;
3000vec3 C1=vSphericalZZ.rgb;
3001vec3 Cx=vSphericalX.rgb;
3002vec3 Cy=vSphericalY.rgb;
3003vec3 Cz=vSphericalZ.rgb;
3004vec3 Cxx_zz=vSphericalXX_ZZ.rgb;
3005vec3 Cyy_zz=vSphericalYY_ZZ.rgb;
3006vec3 Cxy=vSphericalXY.rgb;
3007vec3 Cyz=vSphericalYZ.rgb;
3008vec3 Czx=vSphericalZX.rgb;
3009vec3 a1=Cyy_zz*Ny+Cy;
3010vec3 a2=Cyz*Nz+a1;
3011vec3 b1=Czx*Nz+Cx;
3012vec3 b2=Cxy*Ny+b1;
3013vec3 b3=Cxx_zz*Nx+b2;
3014vec3 t1=Cz*Nz+C1;
3015vec3 t2=a2*Ny+t1;
3016vec3 t3=b3*Nx+t2;
3017return t3;
3018}
3019#endif
3020#endif`;je.a.IncludesShadersStore.harmonicsFunctions=i_;var r_=`
3021struct preLightingInfo
3022{
3023
3024vec3 lightOffset;
3025float lightDistanceSquared;
3026float lightDistance;
3027
3028float attenuation;
3029
3030vec3 L;
3031vec3 H;
3032float NdotV;
3033float NdotLUnclamped;
3034float NdotL;
3035float VdotH;
3036float roughness;
3037};
3038preLightingInfo computePointAndSpotPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {
3039preLightingInfo result;
3040
3041result.lightOffset=lightData.xyz-vPositionW;
3042result.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);
3043
3044result.lightDistance=sqrt(result.lightDistanceSquared);
3045
3046result.L=normalize(result.lightOffset);
3047result.H=normalize(V+result.L);
3048result.VdotH=saturate(dot(V,result.H));
3049result.NdotLUnclamped=dot(N,result.L);
3050result.NdotL=saturateEps(result.NdotLUnclamped);
3051return result;
3052}
3053preLightingInfo computeDirectionalPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {
3054preLightingInfo result;
3055
3056result.lightDistance=length(-lightData.xyz);
3057
3058result.L=normalize(-lightData.xyz);
3059result.H=normalize(V+result.L);
3060result.VdotH=saturate(dot(V,result.H));
3061result.NdotLUnclamped=dot(N,result.L);
3062result.NdotL=saturateEps(result.NdotLUnclamped);
3063return result;
3064}
3065preLightingInfo computeHemisphericPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {
3066preLightingInfo result;
3067
3068
3069result.NdotL=dot(N,lightData.xyz)*0.5+0.5;
3070result.NdotL=saturateEps(result.NdotL);
3071result.NdotLUnclamped=result.NdotL;
3072#ifdef SPECULARTERM
3073result.L=normalize(lightData.xyz);
3074result.H=normalize(V+result.L);
3075result.VdotH=saturate(dot(V,result.H));
3076#endif
3077return result;
3078}`;je.a.IncludesShadersStore.pbrDirectLightingSetupFunctions=r_;var o_=`float computeDistanceLightFalloff_Standard(vec3 lightOffset,float range)
3079{
3080return max(0.,1.0-length(lightOffset)/range);
3081}
3082float computeDistanceLightFalloff_Physical(float lightDistanceSquared)
3083{
3084return 1.0/maxEps(lightDistanceSquared);
3085}
3086float computeDistanceLightFalloff_GLTF(float lightDistanceSquared,float inverseSquaredRange)
3087{
3088float lightDistanceFalloff=1.0/maxEps(lightDistanceSquared);
3089float factor=lightDistanceSquared*inverseSquaredRange;
3090float attenuation=saturate(1.0-factor*factor);
3091attenuation*=attenuation;
3092
3093lightDistanceFalloff*=attenuation;
3094return lightDistanceFalloff;
3095}
3096float computeDistanceLightFalloff(vec3 lightOffset,float lightDistanceSquared,float range,float inverseSquaredRange)
3097{
3098#ifdef USEPHYSICALLIGHTFALLOFF
3099return computeDistanceLightFalloff_Physical(lightDistanceSquared);
3100#elif defined(USEGLTFLIGHTFALLOFF)
3101return computeDistanceLightFalloff_GLTF(lightDistanceSquared,inverseSquaredRange);
3102#else
3103return computeDistanceLightFalloff_Standard(lightOffset,range);
3104#endif
3105}
3106float computeDirectionalLightFalloff_Standard(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent)
3107{
3108float falloff=0.0;
3109float cosAngle=maxEps(dot(-lightDirection,directionToLightCenterW));
3110if (cosAngle>=cosHalfAngle)
3111{
3112falloff=max(0.,pow(cosAngle,exponent));
3113}
3114return falloff;
3115}
3116float computeDirectionalLightFalloff_Physical(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle)
3117{
3118const float kMinusLog2ConeAngleIntensityRatio=6.64385618977;
3119
3120
3121
3122
3123
3124float concentrationKappa=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);
3125
3126
3127vec4 lightDirectionSpreadSG=vec4(-lightDirection*concentrationKappa,-concentrationKappa);
3128float falloff=exp2(dot(vec4(directionToLightCenterW,1.0),lightDirectionSpreadSG));
3129return falloff;
3130}
3131float computeDirectionalLightFalloff_GLTF(vec3 lightDirection,vec3 directionToLightCenterW,float lightAngleScale,float lightAngleOffset)
3132{
3133
3134
3135
3136float cd=dot(-lightDirection,directionToLightCenterW);
3137float falloff=saturate(cd*lightAngleScale+lightAngleOffset);
3138
3139falloff*=falloff;
3140return falloff;
3141}
3142float computeDirectionalLightFalloff(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent,float lightAngleScale,float lightAngleOffset)
3143{
3144#ifdef USEPHYSICALLIGHTFALLOFF
3145return computeDirectionalLightFalloff_Physical(lightDirection,directionToLightCenterW,cosHalfAngle);
3146#elif defined(USEGLTFLIGHTFALLOFF)
3147return computeDirectionalLightFalloff_GLTF(lightDirection,directionToLightCenterW,lightAngleScale,lightAngleOffset);
3148#else
3149return computeDirectionalLightFalloff_Standard(lightDirection,directionToLightCenterW,cosHalfAngle,exponent);
3150#endif
3151}`;je.a.IncludesShadersStore.pbrDirectLightingFalloffFunctions=o_;var a_=`
3152#define FRESNEL_MAXIMUM_ON_ROUGH 0.25
3153
3154
3155
3156
3157#ifdef MS_BRDF_ENERGY_CONSERVATION
3158
3159
3160vec3 getEnergyConservationFactor(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {
3161return 1.0+specularEnvironmentR0*(1.0/environmentBrdf.y-1.0);
3162}
3163#endif
3164#ifdef ENVIRONMENTBRDF
3165vec3 getBRDFLookup(float NdotV,float perceptualRoughness) {
3166
3167vec2 UV=vec2(NdotV,perceptualRoughness);
3168
3169vec4 brdfLookup=texture2D(environmentBrdfSampler,UV);
3170#ifdef ENVIRONMENTBRDF_RGBD
3171brdfLookup.rgb=fromRGBD(brdfLookup.rgba);
3172#endif
3173return brdfLookup.rgb;
3174}
3175vec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,const vec3 specularEnvironmentR90,const vec3 environmentBrdf) {
3176#ifdef BRDF_V_HEIGHT_CORRELATED
3177vec3 reflectance=(specularEnvironmentR90-specularEnvironmentR0)*environmentBrdf.x+specularEnvironmentR0*environmentBrdf.y;
3178
3179#else
3180vec3 reflectance=specularEnvironmentR0*environmentBrdf.x+specularEnvironmentR90*environmentBrdf.y;
3181#endif
3182return reflectance;
3183}
3184vec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {
3185#ifdef BRDF_V_HEIGHT_CORRELATED
3186vec3 reflectance=mix(environmentBrdf.xxx,environmentBrdf.yyy,specularEnvironmentR0);
3187#else
3188vec3 reflectance=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;
3189#endif
3190return reflectance;
3191}
3192#endif
3193
3194#if !defined(ENVIRONMENTBRDF) || defined(REFLECTIONMAP_SKYBOX) || defined(ALPHAFRESNEL)
3195vec3 getReflectanceFromAnalyticalBRDFLookup_Jones(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)
3196{
3197
3198float weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);
3199return reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));
3200}
3201#endif
3202#if defined(SHEEN) && defined(ENVIRONMENTBRDF)
3203
3204vec3 getSheenReflectanceFromBRDFLookup(const vec3 reflectance0,const vec3 environmentBrdf) {
3205vec3 sheenEnvironmentReflectance=reflectance0*environmentBrdf.b;
3206return sheenEnvironmentReflectance;
3207}
3208#endif
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233vec3 fresnelSchlickGGX(float VdotH,vec3 reflectance0,vec3 reflectance90)
3234{
3235return reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);
3236}
3237float fresnelSchlickGGX(float VdotH,float reflectance0,float reflectance90)
3238{
3239return reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);
3240}
3241#ifdef CLEARCOAT
3242
3243
3244
3245
3246
3247vec3 getR0RemappedForClearCoat(vec3 f0) {
3248#ifdef CLEARCOAT_DEFAULTIOR
3249#ifdef MOBILE
3250return saturate(f0*(f0*0.526868+0.529324)-0.0482256);
3251#else
3252return saturate(f0*(f0*(0.941892-0.263008*f0)+0.346479)-0.0285998);
3253#endif
3254#else
3255vec3 s=sqrt(f0);
3256vec3 t=(vClearCoatRefractionParams.z+vClearCoatRefractionParams.w*s)/(vClearCoatRefractionParams.w+vClearCoatRefractionParams.z*s);
3257return t*t;
3258#endif
3259}
3260#endif
3261
3262
3263
3264
3265
3266
3267float normalDistributionFunction_TrowbridgeReitzGGX(float NdotH,float alphaG)
3268{
3269
3270
3271
3272float a2=square(alphaG);
3273float d=NdotH*NdotH*(a2-1.0)+1.0;
3274return a2/(PI*d*d);
3275}
3276#ifdef SHEEN
3277
3278
3279float normalDistributionFunction_CharlieSheen(float NdotH,float alphaG)
3280{
3281float invR=1./alphaG;
3282float cos2h=NdotH*NdotH;
3283float sin2h=1.-cos2h;
3284return (2.+invR)*pow(sin2h,invR*.5)/(2.*PI);
3285}
3286#endif
3287#ifdef ANISOTROPIC
3288
3289
3290float normalDistributionFunction_BurleyGGX_Anisotropic(float NdotH,float TdotH,float BdotH,const vec2 alphaTB) {
3291float a2=alphaTB.x*alphaTB.y;
3292vec3 v=vec3(alphaTB.y*TdotH,alphaTB.x*BdotH,a2*NdotH);
3293float v2=dot(v,v);
3294float w2=a2/v2;
3295return a2*w2*w2*RECIPROCAL_PI;
3296}
3297#endif
3298
3299
3300
3301
3302#ifdef BRDF_V_HEIGHT_CORRELATED
3303
3304
3305
3306float smithVisibility_GGXCorrelated(float NdotL,float NdotV,float alphaG) {
3307#ifdef MOBILE
3308
3309float GGXV=NdotL*(NdotV*(1.0-alphaG)+alphaG);
3310float GGXL=NdotV*(NdotL*(1.0-alphaG)+alphaG);
3311return 0.5/(GGXV+GGXL);
3312#else
3313float a2=alphaG*alphaG;
3314float GGXV=NdotL*sqrt(NdotV*(NdotV-a2*NdotV)+a2);
3315float GGXL=NdotV*sqrt(NdotL*(NdotL-a2*NdotL)+a2);
3316return 0.5/(GGXV+GGXL);
3317#endif
3318}
3319#else
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335float smithVisibilityG1_TrowbridgeReitzGGXFast(float dot,float alphaG)
3336{
3337#ifdef MOBILE
3338
3339return 1.0/(dot+alphaG+(1.0-alphaG)*dot ));
3340#else
3341float alphaSquared=alphaG*alphaG;
3342return 1.0/(dot+sqrt(alphaSquared+(1.0-alphaSquared)*dot*dot));
3343#endif
3344}
3345float smithVisibility_TrowbridgeReitzGGXFast(float NdotL,float NdotV,float alphaG)
3346{
3347float visibility=smithVisibilityG1_TrowbridgeReitzGGXFast(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGXFast(NdotV,alphaG);
3348
3349return visibility;
3350}
3351#endif
3352#ifdef ANISOTROPIC
3353
3354
3355float smithVisibility_GGXCorrelated_Anisotropic(float NdotL,float NdotV,float TdotV,float BdotV,float TdotL,float BdotL,const vec2 alphaTB) {
3356float lambdaV=NdotL*length(vec3(alphaTB.x*TdotV,alphaTB.y*BdotV,NdotV));
3357float lambdaL=NdotV*length(vec3(alphaTB.x*TdotL,alphaTB.y*BdotL,NdotL));
3358float v=0.5/(lambdaV+lambdaL);
3359return v;
3360}
3361#endif
3362#ifdef CLEARCOAT
3363float visibility_Kelemen(float VdotH) {
3364
3365
3366
3367return 0.25/(VdotH*VdotH);
3368}
3369#endif
3370#ifdef SHEEN
3371
3372
3373
3374float visibility_Ashikhmin(float NdotL,float NdotV)
3375{
3376return 1./(4.*(NdotL+NdotV-NdotL*NdotV));
3377}
3378
3379#endif
3380
3381
3382
3383
3384
3385
3386
3387float diffuseBRDF_Burley(float NdotL,float NdotV,float VdotH,float roughness) {
3388
3389
3390float diffuseFresnelNV=pow5(saturateEps(1.0-NdotL));
3391float diffuseFresnelNL=pow5(saturateEps(1.0-NdotV));
3392float diffuseFresnel90=0.5+2.0*VdotH*VdotH*roughness;
3393float fresnel =
3394(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) *
3395(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);
3396return fresnel/PI;
3397}
3398#ifdef SS_TRANSLUCENCY
3399
3400
3401vec3 transmittanceBRDF_Burley(const vec3 tintColor,const vec3 diffusionDistance,float thickness) {
3402vec3 S=1./maxEps(diffusionDistance);
3403vec3 temp=exp((-0.333333333*thickness)*S);
3404return tintColor.rgb*0.25*(temp*temp*temp+3.0*temp);
3405}
3406
3407
3408float computeWrappedDiffuseNdotL(float NdotL,float w) {
3409float t=1.0+w;
3410float invt2=1.0/square(t);
3411return saturate((NdotL+w)*invt2);
3412}
3413#endif
3414`;je.a.IncludesShadersStore.pbrBRDFFunctions=a_;var s_=`#ifdef NUM_SAMPLES
3415#if NUM_SAMPLES>0
3416#ifdef WEBGL2
3417
3418
3419float radicalInverse_VdC(uint bits)
3420{
3421bits=(bits << 16u) | (bits >> 16u);
3422bits=((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
3423bits=((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
3424bits=((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
3425bits=((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
3426return float(bits)*2.3283064365386963e-10;
3427}
3428vec2 hammersley(uint i,uint N)
3429{
3430return vec2(float(i)/float(N),radicalInverse_VdC(i));
3431}
3432#else
3433float vanDerCorpus(int n,int base)
3434{
3435float invBase=1.0/float(base);
3436float denom=1.0;
3437float result=0.0;
3438for(int i=0; i<32; ++i)
3439{
3440if(n>0)
3441{
3442denom=mod(float(n),2.0);
3443result+=denom*invBase;
3444invBase=invBase/2.0;
3445n=int(float(n)/2.0);
3446}
3447}
3448return result;
3449}
3450vec2 hammersley(int i,int N)
3451{
3452return vec2(float(i)/float(N),vanDerCorpus(i,2));
3453}
3454#endif
3455float log4(float x) {
3456return log2(x)/2.;
3457}
3458const float NUM_SAMPLES_FLOAT=float(NUM_SAMPLES);
3459const float NUM_SAMPLES_FLOAT_INVERSED=1./NUM_SAMPLES_FLOAT;
3460const float K=4.;
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576#define inline
3577vec3 irradiance(samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)
3578{
3579vec3 n=normalize(inputN);
3580vec3 result=vec3(0.0);
3581vec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);
3582tangent=normalize(cross(tangent,n));
3583vec3 bitangent=cross(n,tangent);
3584mat3 tbn=mat3(tangent,bitangent,n);
3585float maxLevel=filteringInfo.y;
3586float dim0=filteringInfo.x;
3587float omegaP=(4.*PI)/(6.*dim0*dim0);
3588#ifdef WEBGL2
3589for(uint i=0u; i<NUM_SAMPLES; ++i)
3590#else
3591for(int i=0; i<NUM_SAMPLES; ++i)
3592#endif
3593{
3594vec2 Xi=hammersley(i,NUM_SAMPLES);
3595vec3 Ls=hemisphereCosSample(Xi);
3596Ls=normalize(Ls);
3597vec3 Ns=vec3(0.,0.,1.);
3598float NoL=dot(Ns,Ls);
3599if (NoL>0.) {
3600float pdf_inversed=PI/NoL;
3601float omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;
3602float l=log4(omegaS)-log4(omegaP)+log4(K);
3603float mipLevel=clamp(l,0.0,maxLevel);
3604vec3 c=textureCubeLodEXT(inputTexture,tbn*Ls,mipLevel).rgb;
3605#ifdef GAMMA_INPUT
3606c=toLinearSpace(c);
3607#endif
3608result+=c;
3609}
3610}
3611result=result*NUM_SAMPLES_FLOAT_INVERSED;
3612return result;
3613}
3614#define inline
3615vec3 radiance(float alphaG,samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)
3616{
3617vec3 n=normalize(inputN);
3618if (alphaG == 0.) {
3619vec3 c=textureCube(inputTexture,n).rgb;
3620#ifdef GAMMA_INPUT
3621c=toLinearSpace(c);
3622#endif
3623return c;
3624}
3625vec3 result=vec3(0.);
3626vec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);
3627tangent=normalize(cross(tangent,n));
3628vec3 bitangent=cross(n,tangent);
3629mat3 tbn=mat3(tangent,bitangent,n);
3630float maxLevel=filteringInfo.y;
3631float dim0=filteringInfo.x;
3632float omegaP=(4.*PI)/(6.*dim0*dim0);
3633float weight=0.;
3634#ifdef WEBGL2
3635for(uint i=0u; i<NUM_SAMPLES; ++i)
3636#else
3637for(int i=0; i<NUM_SAMPLES; ++i)
3638#endif
3639{
3640vec2 Xi=hammersley(i,NUM_SAMPLES);
3641vec3 H=hemisphereImportanceSampleDggx(Xi,alphaG);
3642float NoV=1.;
3643float NoH=H.z;
3644float NoH2=H.z*H.z;
3645float NoL=2.*NoH2-1.;
3646vec3 L=vec3(2.*NoH*H.x,2.*NoH*H.y,NoL);
3647L=normalize(L);
3648if (NoL>0.) {
3649float pdf_inversed=4./normalDistributionFunction_TrowbridgeReitzGGX(NoH,alphaG);
3650float omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;
3651float l=log4(omegaS)-log4(omegaP)+log4(K);
3652float mipLevel=clamp(float(l),0.0,maxLevel);
3653weight+=NoL;
3654vec3 c=textureCubeLodEXT(inputTexture,tbn*L,mipLevel).rgb;
3655#ifdef GAMMA_INPUT
3656c=toLinearSpace(c);
3657#endif
3658result+=c*NoL;
3659}
3660}
3661result=result/weight;
3662return result;
3663}
3664#endif
3665#endif`;je.a.IncludesShadersStore.hdrFilteringFunctions=s_;var c_=`#define CLEARCOATREFLECTANCE90 1.0
3666
3667struct lightingInfo
3668{
3669vec3 diffuse;
3670#ifdef SPECULARTERM
3671vec3 specular;
3672#endif
3673#ifdef CLEARCOAT
3674
3675
3676vec4 clearCoat;
3677#endif
3678#ifdef SHEEN
3679vec3 sheen;
3680#endif
3681};
3682
3683float adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance) {
3684#if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF)
3685
3686float lightRoughness=lightRadius/lightDistance;
3687
3688float totalRoughness=saturate(lightRoughness+roughness);
3689return totalRoughness;
3690#else
3691return roughness;
3692#endif
3693}
3694vec3 computeHemisphericDiffuseLighting(preLightingInfo info,vec3 lightColor,vec3 groundColor) {
3695return mix(groundColor,lightColor,info.NdotL);
3696}
3697vec3 computeDiffuseLighting(preLightingInfo info,vec3 lightColor) {
3698float diffuseTerm=diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.roughness);
3699return diffuseTerm*info.attenuation*info.NdotL*lightColor;
3700}
3701#define inline
3702vec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){
3703vec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);
3704strq/=strq.w;
3705vec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;
3706return toLinearSpace(textureColor);
3707}
3708#ifdef SS_TRANSLUCENCY
3709vec3 computeDiffuseAndTransmittedLighting(preLightingInfo info,vec3 lightColor,vec3 transmittance) {
3710float NdotL=absEps(info.NdotLUnclamped);
3711
3712float wrapNdotL=computeWrappedDiffuseNdotL(NdotL,0.02);
3713
3714float trAdapt=step(0.,info.NdotLUnclamped);
3715vec3 transmittanceNdotL=mix(transmittance*wrapNdotL,vec3(wrapNdotL),trAdapt);
3716float diffuseTerm=diffuseBRDF_Burley(NdotL,info.NdotV,info.VdotH,info.roughness);
3717return diffuseTerm*transmittanceNdotL*info.attenuation*lightColor;
3718}
3719#endif
3720#ifdef SPECULARTERM
3721vec3 computeSpecularLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {
3722float NdotH=saturateEps(dot(N,info.H));
3723float roughness=max(info.roughness,geometricRoughnessFactor);
3724float alphaG=convertRoughnessToAverageSlope(roughness);
3725vec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);
3726float distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);
3727#ifdef BRDF_V_HEIGHT_CORRELATED
3728float smithVisibility=smithVisibility_GGXCorrelated(info.NdotL,info.NdotV,alphaG);
3729#else
3730float smithVisibility=smithVisibility_TrowbridgeReitzGGXFast(info.NdotL,info.NdotV,alphaG);
3731#endif
3732vec3 specTerm=fresnel*distribution*smithVisibility;
3733return specTerm*info.attenuation*info.NdotL*lightColor;
3734}
3735#endif
3736#ifdef ANISOTROPIC
3737vec3 computeAnisotropicSpecularLighting(preLightingInfo info,vec3 V,vec3 N,vec3 T,vec3 B,float anisotropy,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {
3738float NdotH=saturateEps(dot(N,info.H));
3739float TdotH=dot(T,info.H);
3740float BdotH=dot(B,info.H);
3741float TdotV=dot(T,V);
3742float BdotV=dot(B,V);
3743float TdotL=dot(T,info.L);
3744float BdotL=dot(B,info.L);
3745float alphaG=convertRoughnessToAverageSlope(info.roughness);
3746vec2 alphaTB=getAnisotropicRoughness(alphaG,anisotropy);
3747alphaTB=max(alphaTB,square(geometricRoughnessFactor));
3748vec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);
3749float distribution=normalDistributionFunction_BurleyGGX_Anisotropic(NdotH,TdotH,BdotH,alphaTB);
3750float smithVisibility=smithVisibility_GGXCorrelated_Anisotropic(info.NdotL,info.NdotV,TdotV,BdotV,TdotL,BdotL,alphaTB);
3751vec3 specTerm=fresnel*distribution*smithVisibility;
3752return specTerm*info.attenuation*info.NdotL*lightColor;
3753}
3754#endif
3755#ifdef CLEARCOAT
3756vec4 computeClearCoatLighting(preLightingInfo info,vec3 Ncc,float geometricRoughnessFactor,float clearCoatIntensity,vec3 lightColor) {
3757float NccdotL=saturateEps(dot(Ncc,info.L));
3758float NccdotH=saturateEps(dot(Ncc,info.H));
3759float clearCoatRoughness=max(info.roughness,geometricRoughnessFactor);
3760float alphaG=convertRoughnessToAverageSlope(clearCoatRoughness);
3761float fresnel=fresnelSchlickGGX(info.VdotH,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);
3762fresnel*=clearCoatIntensity;
3763float distribution=normalDistributionFunction_TrowbridgeReitzGGX(NccdotH,alphaG);
3764float kelemenVisibility=visibility_Kelemen(info.VdotH);
3765float clearCoatTerm=fresnel*distribution*kelemenVisibility;
3766return vec4(
3767clearCoatTerm*info.attenuation*NccdotL*lightColor,
37681.0-fresnel
3769);
3770}
3771vec3 computeClearCoatLightingAbsorption(float NdotVRefract,vec3 L,vec3 Ncc,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {
3772vec3 LRefract=-refract(L,Ncc,vClearCoatRefractionParams.y);
3773float NdotLRefract=saturateEps(dot(Ncc,LRefract));
3774vec3 absorption=computeClearCoatAbsorption(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);
3775return absorption;
3776}
3777#endif
3778#ifdef SHEEN
3779vec3 computeSheenLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {
3780float NdotH=saturateEps(dot(N,info.H));
3781float roughness=max(info.roughness,geometricRoughnessFactor);
3782float alphaG=convertRoughnessToAverageSlope(roughness);
3783
3784
3785float fresnel=1.;
3786float distribution=normalDistributionFunction_CharlieSheen(NdotH,alphaG);
3787
3788float visibility=visibility_Ashikhmin(info.NdotL,info.NdotV);
3789
3790float sheenTerm=fresnel*distribution*visibility;
3791return sheenTerm*info.attenuation*info.NdotL*lightColor;
3792}
3793#endif
3794`;je.a.IncludesShadersStore.pbrDirectLightingFunctions=c_;var l_=`#if defined(REFLECTION) || defined(SS_REFRACTION)
3795float getLodFromAlphaG(float cubeMapDimensionPixels,float microsurfaceAverageSlope) {
3796float microsurfaceAverageSlopeTexels=cubeMapDimensionPixels*microsurfaceAverageSlope;
3797float lod=log2(microsurfaceAverageSlopeTexels);
3798return lod;
3799}
3800float getLinearLodFromRoughness(float cubeMapDimensionPixels,float roughness) {
3801float lod=log2(cubeMapDimensionPixels)*roughness;
3802return lod;
3803}
3804#endif
3805#if defined(ENVIRONMENTBRDF) && defined(RADIANCEOCCLUSION)
3806float environmentRadianceOcclusion(float ambientOcclusion,float NdotVUnclamped) {
3807
3808
3809float temp=NdotVUnclamped+ambientOcclusion;
3810return saturate(square(temp)-1.0+ambientOcclusion);
3811}
3812#endif
3813#if defined(ENVIRONMENTBRDF) && defined(HORIZONOCCLUSION)
3814float environmentHorizonOcclusion(vec3 view,vec3 normal,vec3 geometricNormal) {
3815
3816vec3 reflection=reflect(view,normal);
3817float temp=saturate(1.0+1.1*dot(reflection,geometricNormal));
3818return square(temp);
3819}
3820#endif
3821
3822
3823
3824
3825#if defined(LODINREFLECTIONALPHA) || defined(SS_LODINREFRACTIONALPHA)
3826
3827
3828#define UNPACK_LOD(x) (1.0-x)*255.0
3829float getLodFromAlphaG(float cubeMapDimensionPixels,float alphaG,float NdotV) {
3830float microsurfaceAverageSlope=alphaG;
3831
3832
3833
3834
3835
3836
3837microsurfaceAverageSlope*=sqrt(abs(NdotV));
3838return getLodFromAlphaG(cubeMapDimensionPixels,microsurfaceAverageSlope);
3839}
3840#endif`;je.a.IncludesShadersStore.pbrIBLFunctions=l_,f(132),f(133);var u_=`struct albedoOpacityOutParams
3841{
3842vec3 surfaceAlbedo;
3843float alpha;
3844};
3845#define pbr_inline
3846void albedoOpacityBlock(
3847const in vec4 vAlbedoColor,
3848#ifdef ALBEDO
3849const in vec4 albedoTexture,
3850const in vec2 albedoInfos,
3851#endif
3852#ifdef OPACITY
3853const in vec4 opacityMap,
3854const in vec2 vOpacityInfos,
3855#endif
3856#ifdef DETAIL
3857const in vec4 detailColor,
3858const in vec4 vDetailInfos,
3859#endif
3860out albedoOpacityOutParams outParams
3861)
3862{
3863
3864vec3 surfaceAlbedo=vAlbedoColor.rgb;
3865float alpha=vAlbedoColor.a;
3866#ifdef ALBEDO
3867#if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)
3868alpha*=albedoTexture.a;
3869#endif
3870#ifdef GAMMAALBEDO
3871surfaceAlbedo*=toLinearSpace(albedoTexture.rgb);
3872#else
3873surfaceAlbedo*=albedoTexture.rgb;
3874#endif
3875surfaceAlbedo*=albedoInfos.y;
3876#endif
3877#ifdef VERTEXCOLOR
3878surfaceAlbedo*=vColor.rgb;
3879#endif
3880#ifdef DETAIL
3881float detailAlbedo=2.0*mix(0.5,detailColor.r,vDetailInfos.y);
3882surfaceAlbedo.rgb=surfaceAlbedo.rgb*detailAlbedo*detailAlbedo;
3883#endif
3884#define CUSTOM_FRAGMENT_UPDATE_ALBEDO
3885
3886#ifdef OPACITY
3887#ifdef OPACITYRGB
3888alpha=getLuminance(opacityMap.rgb);
3889#else
3890alpha*=opacityMap.a;
3891#endif
3892alpha*=vOpacityInfos.y;
3893#endif
3894#ifdef VERTEXALPHA
3895alpha*=vColor.a;
3896#endif
3897#if !defined(SS_LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)
3898#ifdef ALPHATEST
3899if (alpha<ALPHATESTVALUE)
3900discard;
3901#ifndef ALPHABLEND
3902
3903alpha=1.0;
3904#endif
3905#endif
3906#endif
3907outParams.surfaceAlbedo=surfaceAlbedo;
3908outParams.alpha=alpha;
3909}
3910`;je.a.IncludesShadersStore.pbrBlockAlbedoOpacity=u_;var h_=`struct reflectivityOutParams
3911{
3912float microSurface;
3913float roughness;
3914vec3 surfaceReflectivityColor;
3915#ifdef METALLICWORKFLOW
3916vec3 surfaceAlbedo;
3917#endif
3918#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
3919vec3 ambientOcclusionColor;
3920#endif
3921#if DEBUGMODE>0
3922vec4 surfaceMetallicColorMap;
3923vec4 surfaceReflectivityColorMap;
3924vec2 metallicRoughness;
3925vec3 metallicF0;
3926#endif
3927};
3928#define pbr_inline
3929void reflectivityBlock(
3930const in vec4 vReflectivityColor,
3931#ifdef METALLICWORKFLOW
3932const in vec3 surfaceAlbedo,
3933const in vec4 metallicReflectanceFactors,
3934#endif
3935#ifdef REFLECTIVITY
3936const in vec3 reflectivityInfos,
3937const in vec4 surfaceMetallicOrReflectivityColorMap,
3938#endif
3939#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
3940const in vec3 ambientOcclusionColorIn,
3941#endif
3942#ifdef MICROSURFACEMAP
3943const in vec4 microSurfaceTexel,
3944#endif
3945#ifdef DETAIL
3946const in vec4 detailColor,
3947const in vec4 vDetailInfos,
3948#endif
3949out reflectivityOutParams outParams
3950)
3951{
3952float microSurface=vReflectivityColor.a;
3953vec3 surfaceReflectivityColor=vReflectivityColor.rgb;
3954#ifdef METALLICWORKFLOW
3955vec2 metallicRoughness=surfaceReflectivityColor.rg;
3956#ifdef REFLECTIVITY
3957#if DEBUGMODE>0
3958outParams.surfaceMetallicColorMap=surfaceMetallicOrReflectivityColorMap;
3959#endif
3960#ifdef AOSTOREINMETALMAPRED
3961vec3 aoStoreInMetalMap=vec3(surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r);
3962outParams.ambientOcclusionColor=mix(ambientOcclusionColorIn,aoStoreInMetalMap,reflectivityInfos.z);
3963#endif
3964#ifdef METALLNESSSTOREINMETALMAPBLUE
3965metallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.b;
3966#else
3967metallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.r;
3968#endif
3969#ifdef ROUGHNESSSTOREINMETALMAPALPHA
3970metallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.a;
3971#else
3972#ifdef ROUGHNESSSTOREINMETALMAPGREEN
3973metallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.g;
3974#endif
3975#endif
3976#endif
3977#ifdef DETAIL
3978float detailRoughness=mix(0.5,detailColor.b,vDetailInfos.w);
3979float loLerp=mix(0.,metallicRoughness.g,detailRoughness*2.);
3980float hiLerp=mix(metallicRoughness.g,1.,(detailRoughness-0.5)*2.);
3981metallicRoughness.g=mix(loLerp,hiLerp,step(detailRoughness,0.5));
3982#endif
3983#ifdef MICROSURFACEMAP
3984metallicRoughness.g*=microSurfaceTexel.r;
3985#endif
3986#if DEBUGMODE>0
3987outParams.metallicRoughness=metallicRoughness;
3988#endif
3989#define CUSTOM_FRAGMENT_UPDATE_METALLICROUGHNESS
3990
3991microSurface=1.0-metallicRoughness.g;
3992
3993vec3 baseColor=surfaceAlbedo;
3994#ifdef FROSTBITE_REFLECTANCE
3995
3996
3997
3998
3999
4000
4001outParams.surfaceAlbedo=baseColor.rgb*(1.0-metallicRoughness.r);
4002
4003surfaceReflectivityColor=mix(0.16*reflectance*reflectance,baseColor,metallicRoughness.r);
4004#else
4005vec3 metallicF0=metallicReflectanceFactors.rgb;
4006#if DEBUGMODE>0
4007outParams.metallicF0=metallicF0;
4008#endif
4009
4010outParams.surfaceAlbedo=mix(baseColor.rgb*(1.0-metallicF0),vec3(0.,0.,0.),metallicRoughness.r);
4011
4012surfaceReflectivityColor=mix(metallicF0,baseColor,metallicRoughness.r);
4013#endif
4014#else
4015#ifdef REFLECTIVITY
4016surfaceReflectivityColor*=surfaceMetallicOrReflectivityColorMap.rgb;
4017#if DEBUGMODE>0
4018outParams.surfaceReflectivityColorMap=surfaceMetallicOrReflectivityColorMap;
4019#endif
4020#ifdef MICROSURFACEFROMREFLECTIVITYMAP
4021microSurface*=surfaceMetallicOrReflectivityColorMap.a;
4022microSurface*=reflectivityInfos.z;
4023#else
4024#ifdef MICROSURFACEAUTOMATIC
4025microSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);
4026#endif
4027#ifdef MICROSURFACEMAP
4028microSurface*=microSurfaceTexel.r;
4029#endif
4030#define CUSTOM_FRAGMENT_UPDATE_MICROSURFACE
4031#endif
4032#endif
4033#endif
4034
4035microSurface=saturate(microSurface);
4036
4037float roughness=1.-microSurface;
4038outParams.microSurface=microSurface;
4039outParams.roughness=roughness;
4040outParams.surfaceReflectivityColor=surfaceReflectivityColor;
4041}
4042`;je.a.IncludesShadersStore.pbrBlockReflectivity=h_;var d_=`struct ambientOcclusionOutParams
4043{
4044vec3 ambientOcclusionColor;
4045#if DEBUGMODE>0
4046vec3 ambientOcclusionColorMap;
4047#endif
4048};
4049#define pbr_inline
4050void ambientOcclusionBlock(
4051#ifdef AMBIENT
4052const in vec3 ambientOcclusionColorMap_,
4053const in vec4 vAmbientInfos,
4054#endif
4055out ambientOcclusionOutParams outParams
4056)
4057{
4058vec3 ambientOcclusionColor=vec3(1.,1.,1.);
4059#ifdef AMBIENT
4060vec3 ambientOcclusionColorMap=ambientOcclusionColorMap_*vAmbientInfos.y;
4061#ifdef AMBIENTINGRAYSCALE
4062ambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);
4063#endif
4064ambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);
4065#if DEBUGMODE>0
4066outParams.ambientOcclusionColorMap=ambientOcclusionColorMap;
4067#endif
4068#endif
4069outParams.ambientOcclusionColor=ambientOcclusionColor;
4070}
4071`;je.a.IncludesShadersStore.pbrBlockAmbientOcclusion=d_;var f_=`#ifdef ALPHAFRESNEL
4072#if defined(ALPHATEST) || defined(ALPHABLEND)
4073struct alphaFresnelOutParams
4074{
4075float alpha;
4076};
4077#define pbr_inline
4078void alphaFresnelBlock(
4079const in vec3 normalW,
4080const in vec3 viewDirectionW,
4081const in float alpha,
4082const in float microSurface,
4083out alphaFresnelOutParams outParams
4084)
4085{
4086
4087
4088
4089float opacityPerceptual=alpha;
4090#ifdef LINEARALPHAFRESNEL
4091float opacity0=opacityPerceptual;
4092#else
4093float opacity0=opacityPerceptual*opacityPerceptual;
4094#endif
4095float opacity90=fresnelGrazingReflectance(opacity0);
4096vec3 normalForward=faceforward(normalW,-viewDirectionW,normalW);
4097
4098outParams.alpha=getReflectanceFromAnalyticalBRDFLookup_Jones(saturate(dot(viewDirectionW,normalForward)),vec3(opacity0),vec3(opacity90),sqrt(microSurface)).x;
4099#ifdef ALPHATEST
4100if (outParams.alpha<ALPHATESTVALUE)
4101discard;
4102#ifndef ALPHABLEND
4103
4104outParams.alpha=1.0;
4105#endif
4106#endif
4107}
4108#endif
4109#endif
4110`;je.a.IncludesShadersStore.pbrBlockAlphaFresnel=f_;var p_=`#ifdef ANISOTROPIC
4111struct anisotropicOutParams
4112{
4113float anisotropy;
4114vec3 anisotropicTangent;
4115vec3 anisotropicBitangent;
4116vec3 anisotropicNormal;
4117#if DEBUGMODE>0
4118vec3 anisotropyMapData;
4119#endif
4120};
4121#define pbr_inline
4122void anisotropicBlock(
4123const in vec3 vAnisotropy,
4124#ifdef ANISOTROPIC_TEXTURE
4125const in vec3 anisotropyMapData,
4126#endif
4127const in mat3 TBN,
4128const in vec3 normalW,
4129const in vec3 viewDirectionW,
4130out anisotropicOutParams outParams
4131)
4132{
4133float anisotropy=vAnisotropy.b;
4134vec3 anisotropyDirection=vec3(vAnisotropy.xy,0.);
4135#ifdef ANISOTROPIC_TEXTURE
4136anisotropy*=anisotropyMapData.b;
4137anisotropyDirection.rg*=anisotropyMapData.rg*2.0-1.0;
4138#if DEBUGMODE>0
4139outParams.anisotropyMapData=anisotropyMapData;
4140#endif
4141#endif
4142mat3 anisoTBN=mat3(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2]));
4143vec3 anisotropicTangent=normalize(anisoTBN*anisotropyDirection);
4144vec3 anisotropicBitangent=normalize(cross(anisoTBN[2],anisotropicTangent));
4145outParams.anisotropy=anisotropy;
4146outParams.anisotropicTangent=anisotropicTangent;
4147outParams.anisotropicBitangent=anisotropicBitangent;
4148outParams.anisotropicNormal=getAnisotropicBentNormals(anisotropicTangent,anisotropicBitangent,normalW,viewDirectionW,anisotropy);
4149}
4150#endif
4151`;je.a.IncludesShadersStore.pbrBlockAnisotropic=p_;var __=`#ifdef REFLECTION
4152struct reflectionOutParams
4153{
4154vec4 environmentRadiance;
4155vec3 environmentIrradiance;
4156#ifdef REFLECTIONMAP_3D
4157vec3 reflectionCoords;
4158#else
4159vec2 reflectionCoords;
4160#endif
4161#ifdef SS_TRANSLUCENCY
4162#ifdef USESPHERICALFROMREFLECTIONMAP
4163#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
4164vec3 irradianceVector;
4165#endif
4166#endif
4167#endif
4168};
4169#define pbr_inline
4170void createReflectionCoords(
4171const in vec3 vPositionW,
4172const in vec3 normalW,
4173#ifdef ANISOTROPIC
4174const in anisotropicOutParams anisotropicOut,
4175#endif
4176#ifdef REFLECTIONMAP_3D
4177out vec3 reflectionCoords
4178#else
4179out vec2 reflectionCoords
4180#endif
4181)
4182{
4183#ifdef ANISOTROPIC
4184vec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),anisotropicOut.anisotropicNormal);
4185#else
4186vec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);
4187#endif
4188#ifdef REFLECTIONMAP_OPPOSITEZ
4189reflectionVector.z*=-1.0;
4190#endif
4191
4192#ifdef REFLECTIONMAP_3D
4193reflectionCoords=reflectionVector;
4194#else
4195reflectionCoords=reflectionVector.xy;
4196#ifdef REFLECTIONMAP_PROJECTION
4197reflectionCoords/=reflectionVector.z;
4198#endif
4199reflectionCoords.y=1.0-reflectionCoords.y;
4200#endif
4201}
4202#define pbr_inline
4203#define inline
4204void sampleReflectionTexture(
4205const in float alphaG,
4206const in vec3 vReflectionMicrosurfaceInfos,
4207const in vec2 vReflectionInfos,
4208const in vec3 vReflectionColor,
4209#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
4210const in float NdotVUnclamped,
4211#endif
4212#ifdef LINEARSPECULARREFLECTION
4213const in float roughness,
4214#endif
4215#ifdef REFLECTIONMAP_3D
4216const in samplerCube reflectionSampler,
4217const vec3 reflectionCoords,
4218#else
4219const in sampler2D reflectionSampler,
4220const vec2 reflectionCoords,
4221#endif
4222#ifndef LODBASEDMICROSFURACE
4223#ifdef REFLECTIONMAP_3D
4224const in samplerCube reflectionSamplerLow,
4225const in samplerCube reflectionSamplerHigh,
4226#else
4227const in sampler2D reflectionSamplerLow,
4228const in sampler2D reflectionSamplerHigh,
4229#endif
4230#endif
4231#ifdef REALTIME_FILTERING
4232const in vec2 vReflectionFilteringInfo,
4233#endif
4234out vec4 environmentRadiance
4235)
4236{
4237
4238#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
4239float reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);
4240#elif defined(LINEARSPECULARREFLECTION)
4241float reflectionLOD=getLinearLodFromRoughness(vReflectionMicrosurfaceInfos.x,roughness);
4242#else
4243float reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG);
4244#endif
4245#ifdef LODBASEDMICROSFURACE
4246
4247reflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;
4248#ifdef LODINREFLECTIONALPHA
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258float automaticReflectionLOD=UNPACK_LOD(sampleReflection(reflectionSampler,reflectionCoords).a);
4259float requestedReflectionLOD=max(automaticReflectionLOD,reflectionLOD);
4260#else
4261float requestedReflectionLOD=reflectionLOD;
4262#endif
4263#ifdef REALTIME_FILTERING
4264environmentRadiance=vec4(radiance(alphaG,reflectionSampler,reflectionCoords,vReflectionFilteringInfo),1.0);
4265#else
4266environmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);
4267#endif
4268#else
4269float lodReflectionNormalized=saturate(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x));
4270float lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;
4271vec4 environmentMid=sampleReflection(reflectionSampler,reflectionCoords);
4272if (lodReflectionNormalizedDoubled<1.0){
4273environmentRadiance=mix(
4274sampleReflection(reflectionSamplerHigh,reflectionCoords),
4275environmentMid,
4276lodReflectionNormalizedDoubled
4277);
4278} else {
4279environmentRadiance=mix(
4280environmentMid,
4281sampleReflection(reflectionSamplerLow,reflectionCoords),
4282lodReflectionNormalizedDoubled-1.0
4283);
4284}
4285#endif
4286#ifdef RGBDREFLECTION
4287environmentRadiance.rgb=fromRGBD(environmentRadiance);
4288#endif
4289#ifdef GAMMAREFLECTION
4290environmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb);
4291#endif
4292
4293environmentRadiance.rgb*=vReflectionInfos.x;
4294environmentRadiance.rgb*=vReflectionColor.rgb;
4295}
4296#define pbr_inline
4297#define inline
4298void reflectionBlock(
4299const in vec3 vPositionW,
4300const in vec3 normalW,
4301const in float alphaG,
4302const in vec3 vReflectionMicrosurfaceInfos,
4303const in vec2 vReflectionInfos,
4304const in vec3 vReflectionColor,
4305#ifdef ANISOTROPIC
4306const in anisotropicOutParams anisotropicOut,
4307#endif
4308#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
4309const in float NdotVUnclamped,
4310#endif
4311#ifdef LINEARSPECULARREFLECTION
4312const in float roughness,
4313#endif
4314#ifdef REFLECTIONMAP_3D
4315const in samplerCube reflectionSampler,
4316#else
4317const in sampler2D reflectionSampler,
4318#endif
4319#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
4320const in vec3 vEnvironmentIrradiance,
4321#endif
4322#ifdef USESPHERICALFROMREFLECTIONMAP
4323#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
4324const in mat4 reflectionMatrix,
4325#endif
4326#endif
4327#ifdef USEIRRADIANCEMAP
4328#ifdef REFLECTIONMAP_3D
4329const in samplerCube irradianceSampler,
4330#else
4331const in sampler2D irradianceSampler,
4332#endif
4333#endif
4334#ifndef LODBASEDMICROSFURACE
4335#ifdef REFLECTIONMAP_3D
4336const in samplerCube reflectionSamplerLow,
4337const in samplerCube reflectionSamplerHigh,
4338#else
4339const in sampler2D reflectionSamplerLow,
4340const in sampler2D reflectionSamplerHigh,
4341#endif
4342#endif
4343#ifdef REALTIME_FILTERING
4344const in vec2 vReflectionFilteringInfo,
4345#endif
4346out reflectionOutParams outParams
4347)
4348{
4349
4350vec4 environmentRadiance=vec4(0.,0.,0.,0.);
4351#ifdef REFLECTIONMAP_3D
4352vec3 reflectionCoords=vec3(0.);
4353#else
4354vec2 reflectionCoords=vec2(0.);
4355#endif
4356createReflectionCoords(
4357vPositionW,
4358normalW,
4359#ifdef ANISOTROPIC
4360anisotropicOut,
4361#endif
4362reflectionCoords
4363);
4364sampleReflectionTexture(
4365alphaG,
4366vReflectionMicrosurfaceInfos,
4367vReflectionInfos,
4368vReflectionColor,
4369#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
4370NdotVUnclamped,
4371#endif
4372#ifdef LINEARSPECULARREFLECTION
4373roughness,
4374#endif
4375#ifdef REFLECTIONMAP_3D
4376reflectionSampler,
4377reflectionCoords,
4378#else
4379reflectionSampler,
4380reflectionCoords,
4381#endif
4382#ifndef LODBASEDMICROSFURACE
4383reflectionSamplerLow,
4384reflectionSamplerHigh,
4385#endif
4386#ifdef REALTIME_FILTERING
4387vReflectionFilteringInfo,
4388#endif
4389environmentRadiance
4390);
4391
4392vec3 environmentIrradiance=vec3(0.,0.,0.);
4393#ifdef USESPHERICALFROMREFLECTIONMAP
4394#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
4395environmentIrradiance=vEnvironmentIrradiance;
4396#else
4397#ifdef ANISOTROPIC
4398vec3 irradianceVector=vec3(reflectionMatrix*vec4(anisotropicOut.anisotropicNormal,0)).xyz;
4399#else
4400vec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;
4401#endif
4402#ifdef REFLECTIONMAP_OPPOSITEZ
4403irradianceVector.z*=-1.0;
4404#endif
4405#ifdef INVERTCUBICMAP
4406irradianceVector.y*=-1.0;
4407#endif
4408#if defined(REALTIME_FILTERING)
4409environmentIrradiance=irradiance(reflectionSampler,irradianceVector,vReflectionFilteringInfo);
4410#else
4411environmentIrradiance=computeEnvironmentIrradiance(irradianceVector);
4412#endif
4413#ifdef SS_TRANSLUCENCY
4414outParams.irradianceVector=irradianceVector;
4415#endif
4416#endif
4417#elif defined(USEIRRADIANCEMAP)
4418vec4 environmentIrradiance4=sampleReflection(irradianceSampler,reflectionCoords);
4419environmentIrradiance=environmentIrradiance4.rgb;
4420#ifdef RGBDREFLECTION
4421environmentIrradiance.rgb=fromRGBD(environmentIrradiance4);
4422#endif
4423#ifdef GAMMAREFLECTION
4424environmentIrradiance.rgb=toLinearSpace(environmentIrradiance.rgb);
4425#endif
4426#endif
4427environmentIrradiance*=vReflectionColor.rgb;
4428outParams.environmentRadiance=environmentRadiance;
4429outParams.environmentIrradiance=environmentIrradiance;
4430outParams.reflectionCoords=reflectionCoords;
4431}
4432#endif
4433`;je.a.IncludesShadersStore.pbrBlockReflection=__;var m_=`#ifdef SHEEN
4434struct sheenOutParams
4435{
4436float sheenIntensity;
4437vec3 sheenColor;
4438float sheenRoughness;
4439#ifdef SHEEN_LINKWITHALBEDO
4440vec3 surfaceAlbedo;
4441#endif
4442#if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
4443float sheenAlbedoScaling;
4444#endif
4445#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
4446vec3 finalSheenRadianceScaled;
4447#endif
4448#if DEBUGMODE>0
4449vec4 sheenMapData;
4450vec3 sheenEnvironmentReflectance;
4451#endif
4452};
4453#define pbr_inline
4454#define inline
4455void sheenBlock(
4456const in vec4 vSheenColor,
4457#ifdef SHEEN_ROUGHNESS
4458const in float vSheenRoughness,
4459#if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
4460const in vec4 sheenMapRoughnessData,
4461#endif
4462#endif
4463const in float roughness,
4464#ifdef SHEEN_TEXTURE
4465const in vec4 sheenMapData,
4466#endif
4467const in float reflectance,
4468#ifdef SHEEN_LINKWITHALBEDO
4469const in vec3 baseColor,
4470const in vec3 surfaceAlbedo,
4471#endif
4472#ifdef ENVIRONMENTBRDF
4473const in float NdotV,
4474const in vec3 environmentBrdf,
4475#endif
4476#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
4477const in vec2 AARoughnessFactors,
4478const in vec3 vReflectionMicrosurfaceInfos,
4479const in vec2 vReflectionInfos,
4480const in vec3 vReflectionColor,
4481const in vec4 vLightingIntensity,
4482#ifdef REFLECTIONMAP_3D
4483const in samplerCube reflectionSampler,
4484const in vec3 reflectionCoords,
4485#else
4486const in sampler2D reflectionSampler,
4487const in vec2 reflectionCoords,
4488#endif
4489const in float NdotVUnclamped,
4490#ifndef LODBASEDMICROSFURACE
4491#ifdef REFLECTIONMAP_3D
4492const in samplerCube reflectionSamplerLow,
4493const in samplerCube reflectionSamplerHigh,
4494#else
4495const in sampler2D reflectionSamplerLow,
4496const in sampler2D reflectionSamplerHigh,
4497#endif
4498#endif
4499#ifdef REALTIME_FILTERING
4500const in vec2 vReflectionFilteringInfo,
4501#endif
4502#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
4503const in float seo,
4504#endif
4505#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
4506const in float eho,
4507#endif
4508#endif
4509out sheenOutParams outParams
4510)
4511{
4512float sheenIntensity=vSheenColor.a;
4513#ifdef SHEEN_TEXTURE
4514#if DEBUGMODE>0
4515outParams.sheenMapData=sheenMapData;
4516#endif
4517#endif
4518#ifdef SHEEN_LINKWITHALBEDO
4519float sheenFactor=pow5(1.0-sheenIntensity);
4520vec3 sheenColor=baseColor.rgb*(1.0-sheenFactor);
4521float sheenRoughness=sheenIntensity;
4522outParams.surfaceAlbedo=surfaceAlbedo*sheenFactor;
4523#ifdef SHEEN_TEXTURE
4524sheenIntensity*=sheenMapData.a;
4525#endif
4526#else
4527vec3 sheenColor=vSheenColor.rgb;
4528#ifdef SHEEN_TEXTURE
4529sheenColor.rgb*=sheenMapData.rgb;
4530#endif
4531#ifdef SHEEN_ROUGHNESS
4532float sheenRoughness=vSheenRoughness;
4533#ifdef SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE
4534#if defined(SHEEN_TEXTURE)
4535sheenRoughness*=sheenMapData.a;
4536#endif
4537#elif defined(SHEEN_TEXTURE_ROUGHNESS)
4538#ifdef SHEEN_TEXTURE_ROUGHNESS_IDENTICAL
4539sheenRoughness*=sheenMapData.a;
4540#else
4541sheenRoughness*=sheenMapRoughnessData.a;
4542#endif
4543#endif
4544#else
4545float sheenRoughness=roughness;
4546#ifdef SHEEN_TEXTURE
4547sheenIntensity*=sheenMapData.a;
4548#endif
4549#endif
4550
4551#if !defined(SHEEN_ALBEDOSCALING)
4552sheenIntensity*=(1.-reflectance);
4553#endif
4554
4555sheenColor*=sheenIntensity;
4556#endif
4557
4558#ifdef ENVIRONMENTBRDF
4559
4560#ifdef SHEEN_ROUGHNESS
4561vec3 environmentSheenBrdf=getBRDFLookup(NdotV,sheenRoughness);
4562#else
4563vec3 environmentSheenBrdf=environmentBrdf;
4564#endif
4565
4566#endif
4567#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
4568float sheenAlphaG=convertRoughnessToAverageSlope(sheenRoughness);
4569#ifdef SPECULARAA
4570
4571sheenAlphaG+=AARoughnessFactors.y;
4572#endif
4573vec4 environmentSheenRadiance=vec4(0.,0.,0.,0.);
4574sampleReflectionTexture(
4575sheenAlphaG,
4576vReflectionMicrosurfaceInfos,
4577vReflectionInfos,
4578vReflectionColor,
4579#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
4580NdotVUnclamped,
4581#endif
4582#ifdef LINEARSPECULARREFLECTION
4583sheenRoughness,
4584#endif
4585reflectionSampler,
4586reflectionCoords,
4587#ifndef LODBASEDMICROSFURACE
4588reflectionSamplerLow,
4589reflectionSamplerHigh,
4590#endif
4591#ifdef REALTIME_FILTERING
4592vReflectionFilteringInfo,
4593#endif
4594environmentSheenRadiance
4595);
4596vec3 sheenEnvironmentReflectance=getSheenReflectanceFromBRDFLookup(sheenColor,environmentSheenBrdf);
4597#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
4598sheenEnvironmentReflectance*=seo;
4599#endif
4600#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
4601sheenEnvironmentReflectance*=eho;
4602#endif
4603#if DEBUGMODE>0
4604outParams.sheenEnvironmentReflectance=sheenEnvironmentReflectance;
4605#endif
4606outParams.finalSheenRadianceScaled=
4607environmentSheenRadiance.rgb *
4608sheenEnvironmentReflectance *
4609vLightingIntensity.z;
4610
4611
4612
4613
4614
4615#endif
4616#if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
4617
4618
4619
4620outParams.sheenAlbedoScaling=1.0-sheenIntensity*max(max(sheenColor.r,sheenColor.g),sheenColor.b)*environmentSheenBrdf.b;
4621#endif
4622
4623outParams.sheenIntensity=sheenIntensity;
4624outParams.sheenColor=sheenColor;
4625outParams.sheenRoughness=sheenRoughness;
4626}
4627#endif
4628`;je.a.IncludesShadersStore.pbrBlockSheen=m_;var g_=`struct clearcoatOutParams
4629{
4630vec3 specularEnvironmentR0;
4631float conservationFactor;
4632vec3 clearCoatNormalW;
4633vec2 clearCoatAARoughnessFactors;
4634float clearCoatIntensity;
4635float clearCoatRoughness;
4636#ifdef REFLECTION
4637vec3 finalClearCoatRadianceScaled;
4638#endif
4639#ifdef CLEARCOAT_TINT
4640vec3 absorption;
4641float clearCoatNdotVRefract;
4642vec3 clearCoatColor;
4643float clearCoatThickness;
4644#endif
4645#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
4646vec3 energyConservationFactorClearCoat;
4647#endif
4648#if DEBUGMODE>0
4649mat3 TBNClearCoat;
4650vec2 clearCoatMapData;
4651vec4 clearCoatTintMapData;
4652vec4 environmentClearCoatRadiance;
4653float clearCoatNdotV;
4654vec3 clearCoatEnvironmentReflectance;
4655#endif
4656};
4657#ifdef CLEARCOAT
4658#define pbr_inline
4659#define inline
4660void clearcoatBlock(
4661const in vec3 vPositionW,
4662const in vec3 geometricNormalW,
4663const in vec3 viewDirectionW,
4664const in vec2 vClearCoatParams,
4665#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
4666const in vec4 clearCoatMapRoughnessData,
4667#endif
4668const in vec3 specularEnvironmentR0,
4669#ifdef CLEARCOAT_TEXTURE
4670const in vec2 clearCoatMapData,
4671#endif
4672#ifdef CLEARCOAT_TINT
4673const in vec4 vClearCoatTintParams,
4674const in float clearCoatColorAtDistance,
4675const in vec4 vClearCoatRefractionParams,
4676#ifdef CLEARCOAT_TINT_TEXTURE
4677const in vec4 clearCoatTintMapData,
4678#endif
4679#endif
4680#ifdef CLEARCOAT_BUMP
4681const in vec2 vClearCoatBumpInfos,
4682const in vec4 clearCoatBumpMapData,
4683const in vec2 vClearCoatBumpUV,
4684#if defined(TANGENT) && defined(NORMAL)
4685const in mat3 vTBN,
4686#else
4687const in vec2 vClearCoatTangentSpaceParams,
4688#endif
4689#ifdef OBJECTSPACE_NORMALMAP
4690const in mat4 normalMatrix,
4691#endif
4692#endif
4693#if defined(FORCENORMALFORWARD) && defined(NORMAL)
4694const in vec3 faceNormal,
4695#endif
4696#ifdef REFLECTION
4697const in vec3 vReflectionMicrosurfaceInfos,
4698const in vec2 vReflectionInfos,
4699const in vec3 vReflectionColor,
4700const in vec4 vLightingIntensity,
4701#ifdef REFLECTIONMAP_3D
4702const in samplerCube reflectionSampler,
4703#else
4704const in sampler2D reflectionSampler,
4705#endif
4706#ifndef LODBASEDMICROSFURACE
4707#ifdef REFLECTIONMAP_3D
4708const in samplerCube reflectionSamplerLow,
4709const in samplerCube reflectionSamplerHigh,
4710#else
4711const in sampler2D reflectionSamplerLow,
4712const in sampler2D reflectionSamplerHigh,
4713#endif
4714#endif
4715#ifdef REALTIME_FILTERING
4716const in vec2 vReflectionFilteringInfo,
4717#endif
4718#endif
4719#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
4720#ifdef RADIANCEOCCLUSION
4721const in float ambientMonochrome,
4722#endif
4723#endif
4724out clearcoatOutParams outParams
4725)
4726{
4727
4728float clearCoatIntensity=vClearCoatParams.x;
4729float clearCoatRoughness=vClearCoatParams.y;
4730#ifdef CLEARCOAT_TEXTURE
4731clearCoatIntensity*=clearCoatMapData.x;
4732#ifdef CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE
4733clearCoatRoughness*=clearCoatMapData.y;
4734#endif
4735#if DEBUGMODE>0
4736outParams.clearCoatMapData=clearCoatMapData;
4737#endif
4738#endif
4739#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
4740#ifdef CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL
4741clearCoatRoughness*=clearCoatMapData.y;
4742#else
4743clearCoatRoughness*=clearCoatMapRoughnessData.y;
4744#endif
4745#endif
4746outParams.clearCoatIntensity=clearCoatIntensity;
4747outParams.clearCoatRoughness=clearCoatRoughness;
4748#ifdef CLEARCOAT_TINT
4749vec3 clearCoatColor=vClearCoatTintParams.rgb;
4750float clearCoatThickness=vClearCoatTintParams.a;
4751#ifdef CLEARCOAT_TINT_TEXTURE
4752clearCoatColor*=clearCoatTintMapData.rgb;
4753clearCoatThickness*=clearCoatTintMapData.a;
4754#if DEBUGMODE>0
4755outParams.clearCoatTintMapData=clearCoatTintMapData;
4756#endif
4757#endif
4758outParams.clearCoatColor=computeColorAtDistanceInMedia(clearCoatColor,clearCoatColorAtDistance);
4759outParams.clearCoatThickness=clearCoatThickness;
4760#endif
4761
4762
4763
4764
4765#ifdef CLEARCOAT_REMAP_F0
4766vec3 specularEnvironmentR0Updated=getR0RemappedForClearCoat(specularEnvironmentR0);
4767#else
4768vec3 specularEnvironmentR0Updated=specularEnvironmentR0;
4769#endif
4770outParams.specularEnvironmentR0=mix(specularEnvironmentR0,specularEnvironmentR0Updated,clearCoatIntensity);
4771
4772vec3 clearCoatNormalW=geometricNormalW;
4773#ifdef CLEARCOAT_BUMP
4774#ifdef NORMALXYSCALE
4775float clearCoatNormalScale=1.0;
4776#else
4777float clearCoatNormalScale=vClearCoatBumpInfos.y;
4778#endif
4779#if defined(TANGENT) && defined(NORMAL)
4780mat3 TBNClearCoat=vTBN;
4781#else
4782mat3 TBNClearCoat=cotangent_frame(clearCoatNormalW*clearCoatNormalScale,vPositionW,vClearCoatBumpUV,vClearCoatTangentSpaceParams);
4783#endif
4784#if DEBUGMODE>0
4785outParams.TBNClearCoat=TBNClearCoat;
4786#endif
4787#ifdef OBJECTSPACE_NORMALMAP
4788clearCoatNormalW=normalize(clearCoatBumpMapData.xyz*2.0-1.0);
4789clearCoatNormalW=normalize(mat3(normalMatrix)*clearCoatNormalW);
4790#else
4791clearCoatNormalW=perturbNormal(TBNClearCoat,clearCoatBumpMapData.xyz,vClearCoatBumpInfos.y);
4792#endif
4793#endif
4794#if defined(FORCENORMALFORWARD) && defined(NORMAL)
4795clearCoatNormalW*=sign(dot(clearCoatNormalW,faceNormal));
4796#endif
4797#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
4798clearCoatNormalW=gl_FrontFacing ? clearCoatNormalW : -clearCoatNormalW;
4799#endif
4800outParams.clearCoatNormalW=clearCoatNormalW;
4801
4802outParams.clearCoatAARoughnessFactors=getAARoughnessFactors(clearCoatNormalW.xyz);
4803
4804float clearCoatNdotVUnclamped=dot(clearCoatNormalW,viewDirectionW);
4805
4806float clearCoatNdotV=absEps(clearCoatNdotVUnclamped);
4807#if DEBUGMODE>0
4808outParams.clearCoatNdotV=clearCoatNdotV;
4809#endif
4810#ifdef CLEARCOAT_TINT
4811
4812vec3 clearCoatVRefract=-refract(vPositionW,clearCoatNormalW,vClearCoatRefractionParams.y);
4813
4814outParams.clearCoatNdotVRefract=absEps(dot(clearCoatNormalW,clearCoatVRefract));
4815#endif
4816#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
4817
4818vec3 environmentClearCoatBrdf=getBRDFLookup(clearCoatNdotV,clearCoatRoughness);
4819#endif
4820
4821#if defined(REFLECTION)
4822float clearCoatAlphaG=convertRoughnessToAverageSlope(clearCoatRoughness);
4823#ifdef SPECULARAA
4824
4825clearCoatAlphaG+=outParams.clearCoatAARoughnessFactors.y;
4826#endif
4827vec4 environmentClearCoatRadiance=vec4(0.,0.,0.,0.);
4828vec3 clearCoatReflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),clearCoatNormalW);
4829#ifdef REFLECTIONMAP_OPPOSITEZ
4830clearCoatReflectionVector.z*=-1.0;
4831#endif
4832
4833#ifdef REFLECTIONMAP_3D
4834vec3 clearCoatReflectionCoords=clearCoatReflectionVector;
4835#else
4836vec2 clearCoatReflectionCoords=clearCoatReflectionVector.xy;
4837#ifdef REFLECTIONMAP_PROJECTION
4838clearCoatReflectionCoords/=clearCoatReflectionVector.z;
4839#endif
4840clearCoatReflectionCoords.y=1.0-clearCoatReflectionCoords.y;
4841#endif
4842sampleReflectionTexture(
4843clearCoatAlphaG,
4844vReflectionMicrosurfaceInfos,
4845vReflectionInfos,
4846vReflectionColor,
4847#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
4848clearCoatNdotVUnclamped,
4849#endif
4850#ifdef LINEARSPECULARREFLECTION
4851clearCoatRoughness,
4852#endif
4853reflectionSampler,
4854clearCoatReflectionCoords,
4855#ifndef LODBASEDMICROSFURACE
4856reflectionSamplerLow,
4857reflectionSamplerHigh,
4858#endif
4859#ifdef REALTIME_FILTERING
4860vReflectionFilteringInfo,
4861#endif
4862environmentClearCoatRadiance
4863);
4864#if DEBUGMODE>0
4865outParams.environmentClearCoatRadiance=environmentClearCoatRadiance;
4866#endif
4867
4868#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
4869vec3 clearCoatEnvironmentReflectance=getReflectanceFromBRDFLookup(vec3(vClearCoatRefractionParams.x),environmentClearCoatBrdf);
4870#ifdef RADIANCEOCCLUSION
4871float clearCoatSeo=environmentRadianceOcclusion(ambientMonochrome,clearCoatNdotVUnclamped);
4872clearCoatEnvironmentReflectance*=clearCoatSeo;
4873#endif
4874#ifdef HORIZONOCCLUSION
4875#ifdef BUMP
4876#ifdef REFLECTIONMAP_3D
4877float clearCoatEho=environmentHorizonOcclusion(-viewDirectionW,clearCoatNormalW,geometricNormalW);
4878clearCoatEnvironmentReflectance*=clearCoatEho;
4879#endif
4880#endif
4881#endif
4882#else
4883
4884vec3 clearCoatEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(clearCoatNdotV,vec3(1.),vec3(1.),sqrt(1.-clearCoatRoughness));
4885#endif
4886clearCoatEnvironmentReflectance*=clearCoatIntensity;
4887#if DEBUGMODE>0
4888outParams.clearCoatEnvironmentReflectance=clearCoatEnvironmentReflectance;
4889#endif
4890outParams.finalClearCoatRadianceScaled=
4891environmentClearCoatRadiance.rgb *
4892clearCoatEnvironmentReflectance *
4893vLightingIntensity.z;
4894#endif
4895#if defined(CLEARCOAT_TINT)
4896
4897outParams.absorption=computeClearCoatAbsorption(outParams.clearCoatNdotVRefract,outParams.clearCoatNdotVRefract,outParams.clearCoatColor,clearCoatThickness,clearCoatIntensity);
4898#endif
4899
4900float fresnelIBLClearCoat=fresnelSchlickGGX(clearCoatNdotV,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);
4901fresnelIBLClearCoat*=clearCoatIntensity;
4902outParams.conservationFactor=(1.-fresnelIBLClearCoat);
4903#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
4904outParams.energyConservationFactorClearCoat=getEnergyConservationFactor(outParams.specularEnvironmentR0,environmentClearCoatBrdf);
4905#endif
4906}
4907#endif
4908`;je.a.IncludesShadersStore.pbrBlockClearcoat=g_;var v_=`struct subSurfaceOutParams
4909{
4910vec3 specularEnvironmentReflectance;
4911#ifdef SS_REFRACTION
4912vec3 finalRefraction;
4913vec3 surfaceAlbedo;
4914#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
4915float alpha;
4916#endif
4917#ifdef REFLECTION
4918float refractionFactorForIrradiance;
4919#endif
4920#endif
4921#ifdef SS_TRANSLUCENCY
4922vec3 transmittance;
4923float translucencyIntensity;
4924#ifdef REFLECTION
4925vec3 refractionIrradiance;
4926#endif
4927#endif
4928#if DEBUGMODE>0
4929vec4 thicknessMap;
4930vec4 environmentRefraction;
4931vec3 refractionTransmittance;
4932#endif
4933};
4934#ifdef SUBSURFACE
4935#define pbr_inline
4936#define inline
4937void subSurfaceBlock(
4938const in vec3 vSubSurfaceIntensity,
4939const in vec2 vThicknessParam,
4940const in vec4 vTintColor,
4941const in vec3 normalW,
4942const in vec3 specularEnvironmentReflectance,
4943#ifdef SS_THICKNESSANDMASK_TEXTURE
4944const in vec4 thicknessMap,
4945#endif
4946#ifdef REFLECTION
4947#ifdef SS_TRANSLUCENCY
4948const in mat4 reflectionMatrix,
4949#ifdef USESPHERICALFROMREFLECTIONMAP
4950#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
4951const in vec3 irradianceVector_,
4952#endif
4953#if defined(REALTIME_FILTERING)
4954const in samplerCube reflectionSampler,
4955const in vec2 vReflectionFilteringInfo,
4956#endif
4957#endif
4958#ifdef USEIRRADIANCEMAP
4959#ifdef REFLECTIONMAP_3D
4960const in samplerCube irradianceSampler,
4961#else
4962const in sampler2D irradianceSampler,
4963#endif
4964#endif
4965#endif
4966#endif
4967#ifdef SS_REFRACTION
4968const in vec3 vPositionW,
4969const in vec3 viewDirectionW,
4970const in mat4 view,
4971const in vec3 surfaceAlbedo,
4972const in vec4 vRefractionInfos,
4973const in mat4 refractionMatrix,
4974const in vec3 vRefractionMicrosurfaceInfos,
4975const in vec4 vLightingIntensity,
4976#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
4977const in float alpha,
4978#endif
4979#ifdef SS_LODINREFRACTIONALPHA
4980const in float NdotVUnclamped,
4981#endif
4982#ifdef SS_LINEARSPECULARREFRACTION
4983const in float roughness,
4984#else
4985const in float alphaG,
4986#endif
4987#ifdef SS_REFRACTIONMAP_3D
4988const in samplerCube refractionSampler,
4989#ifndef LODBASEDMICROSFURACE
4990const in samplerCube refractionSamplerLow,
4991const in samplerCube refractionSamplerHigh,
4992#endif
4993#else
4994const in sampler2D refractionSampler,
4995#ifndef LODBASEDMICROSFURACE
4996const in sampler2D refractionSamplerLow,
4997const in sampler2D refractionSamplerHigh,
4998#endif
4999#endif
5000#ifdef ANISOTROPIC
5001const in anisotropicOutParams anisotropicOut,
5002#endif
5003#ifdef REALTIME_FILTERING
5004const in vec2 vRefractionFilteringInfo,
5005#endif
5006#endif
5007#ifdef SS_TRANSLUCENCY
5008const in vec3 vDiffusionDistance,
5009#endif
5010out subSurfaceOutParams outParams
5011)
5012{
5013outParams.specularEnvironmentReflectance=specularEnvironmentReflectance;
5014
5015
5016
5017#ifdef SS_REFRACTION
5018float refractionIntensity=vSubSurfaceIntensity.x;
5019#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
5020refractionIntensity*=(1.0-alpha);
5021
5022outParams.alpha=1.0;
5023#endif
5024#endif
5025#ifdef SS_TRANSLUCENCY
5026float translucencyIntensity=vSubSurfaceIntensity.y;
5027#endif
5028#ifdef SS_THICKNESSANDMASK_TEXTURE
5029float thickness=thicknessMap.r*vThicknessParam.y+vThicknessParam.x;
5030#if DEBUGMODE>0
5031outParams.thicknessMap=thicknessMap;
5032#endif
5033#ifdef SS_MASK_FROM_THICKNESS_TEXTURE
5034#ifdef SS_REFRACTION
5035refractionIntensity*=thicknessMap.g;
5036#endif
5037#ifdef SS_TRANSLUCENCY
5038translucencyIntensity*=thicknessMap.b;
5039#endif
5040#elif defined(SS_MASK_FROM_THICKNESS_TEXTURE_GLTF)
5041#ifdef SS_REFRACTION
5042refractionIntensity*=thicknessMap.r;
5043#elif defined(SS_TRANSLUCENCY)
5044translucencyIntensity*=thicknessMap.r;
5045#endif
5046thickness=thicknessMap.g*vThicknessParam.y+vThicknessParam.x;
5047#endif
5048#else
5049float thickness=vThicknessParam.y;
5050#endif
5051
5052
5053
5054#ifdef SS_TRANSLUCENCY
5055thickness=maxEps(thickness);
5056vec3 transmittance=transmittanceBRDF_Burley(vTintColor.rgb,vDiffusionDistance,thickness);
5057transmittance*=translucencyIntensity;
5058outParams.transmittance=transmittance;
5059outParams.translucencyIntensity=translucencyIntensity;
5060#endif
5061
5062
5063
5064#ifdef SS_REFRACTION
5065vec4 environmentRefraction=vec4(0.,0.,0.,0.);
5066#ifdef ANISOTROPIC
5067vec3 refractionVector=refract(-viewDirectionW,anisotropicOut.anisotropicNormal,vRefractionInfos.y);
5068#else
5069vec3 refractionVector=refract(-viewDirectionW,normalW,vRefractionInfos.y);
5070#endif
5071#ifdef SS_REFRACTIONMAP_OPPOSITEZ
5072refractionVector.z*=-1.0;
5073#endif
5074
5075#ifdef SS_REFRACTIONMAP_3D
5076refractionVector.y=refractionVector.y*vRefractionInfos.w;
5077vec3 refractionCoords=refractionVector;
5078refractionCoords=vec3(refractionMatrix*vec4(refractionCoords,0));
5079#else
5080vec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));
5081vec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;
5082refractionCoords.y=1.0-refractionCoords.y;
5083#endif
5084#ifdef SS_LODINREFRACTIONALPHA
5085float refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);
5086#elif defined(SS_LINEARSPECULARREFRACTION)
5087float refractionLOD=getLinearLodFromRoughness(vRefractionMicrosurfaceInfos.x,roughness);
5088#else
5089float refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG);
5090#endif
5091#ifdef LODBASEDMICROSFURACE
5092
5093refractionLOD=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z;
5094#ifdef SS_LODINREFRACTIONALPHA
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104float automaticRefractionLOD=UNPACK_LOD(sampleRefraction(refractionSampler,refractionCoords).a);
5105float requestedRefractionLOD=max(automaticRefractionLOD,refractionLOD);
5106#else
5107float requestedRefractionLOD=refractionLOD;
5108#endif
5109#ifdef REALTIME_FILTERING
5110environmentRefraction=vec4(radiance(alphaG,refractionSampler,refractionCoords,vRefractionFilteringInfo),1.0);
5111#else
5112environmentRefraction=sampleRefr
5112actionLod(refractionSampler,refractionCoords,requestedRefractionLOD);
5113#endif
5114#else
5115float lodRefractionNormalized=saturate(refractionLOD/log2(vRefractionMicrosurfaceInfos.x));
5116float lodRefractionNormalizedDoubled=lodRefractionNormalized*2.0;
5117vec4 environmentRefractionMid=sampleRefraction(refractionSampler,refractionCoords);
5118if (lodRefractionNormalizedDoubled<1.0){
5119environmentRefraction=mix(
5120sampleRefraction(refractionSamplerHigh,refractionCoords),
5121environmentRefractionMid,
5122lodRefractionNormalizedDoubled
5123);
5124} else {
5125environmentRefraction=mix(
5126environmentRefractionMid,
5127sampleRefraction(refractionSamplerLow,refractionCoords),
5128lodRefractionNormalizedDoubled-1.0
5129);
5130}
5131#endif
5132#ifdef SS_RGBDREFRACTION
5133environmentRefraction.rgb=fromRGBD(environmentRefraction);
5134#endif
5135#ifdef SS_GAMMAREFRACTION
5136environmentRefraction.rgb=toLinearSpace(environmentRefraction.rgb);
5137#endif
5138
5139environmentRefraction.rgb*=vRefractionInfos.x;
5140#endif
5141
5142
5143
5144#ifdef SS_REFRACTION
5145vec3 refractionTransmittance=vec3(refractionIntensity);
5146#ifdef SS_THICKNESSANDMASK_TEXTURE
5147vec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);
5148
5149
5150
5151
5152
5153refractionTransmittance*=cocaLambert(volumeAlbedo,thickness);
5154#elif defined(SS_LINKREFRACTIONTOTRANSPARENCY)
5155
5156float maxChannel=max(max(surfaceAlbedo.r,surfaceAlbedo.g),surfaceAlbedo.b);
5157vec3 volumeAlbedo=saturate(maxChannel*surfaceAlbedo);
5158
5159environmentRefraction.rgb*=volumeAlbedo;
5160#else
5161
5162vec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);
5163refractionTransmittance*=cocaLambert(volumeAlbedo,vThicknessParam.y);
5164#endif
5165#ifdef SS_ALBEDOFORREFRACTIONTINT
5166
5167environmentRefraction.rgb*=surfaceAlbedo.rgb;
5168#endif
5169
5170outParams.surfaceAlbedo=surfaceAlbedo*(1.-refractionIntensity);
5171#ifdef REFLECTION
5172
5173outParams.refractionFactorForIrradiance=(1.-refractionIntensity);
5174
5175#endif
5176
5177vec3 bounceSpecularEnvironmentReflectance=(2.0*specularEnvironmentReflectance)/(1.0+specularEnvironmentReflectance);
5178outParams.specularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,specularEnvironmentReflectance,refractionIntensity);
5179
5180refractionTransmittance*=1.0-outParams.specularEnvironmentReflectance;
5181#if DEBUGMODE>0
5182outParams.refractionTransmittance=refractionTransmittance;
5183#endif
5184outParams.finalRefraction=environmentRefraction.rgb*refractionTransmittance*vLightingIntensity.z;
5185#if DEBUGMODE>0
5186outParams.environmentRefraction=environmentRefraction;
5187#endif
5188#endif
5189
5190
5191
5192#if defined(REFLECTION) && defined(SS_TRANSLUCENCY)
5193#if defined(NORMAL) && defined(USESPHERICALINVERTEX) || !defined(USESPHERICALFROMREFLECTIONMAP)
5194vec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;
5195#ifdef REFLECTIONMAP_OPPOSITEZ
5196irradianceVector.z*=-1.0;
5197#endif
5198#ifdef INVERTCUBICMAP
5199irradianceVector.y*=-1.0;
5200#endif
5201#else
5202vec3 irradianceVector=irradianceVector_;
5203#endif
5204#if defined(USESPHERICALFROMREFLECTIONMAP)
5205#if defined(REALTIME_FILTERING)
5206vec3 refractionIrradiance=irradiance(reflectionSampler,-irradianceVector,vReflectionFilteringInfo);
5207#else
5208vec3 refractionIrradiance=computeEnvironmentIrradiance(-irradianceVector);
5209#endif
5210#elif defined(USEIRRADIANCEMAP)
5211#ifdef REFLECTIONMAP_3D
5212vec3 irradianceCoords=irradianceVector;
5213#else
5214vec2 irradianceCoords=irradianceVector.xy;
5215#ifdef REFLECTIONMAP_PROJECTION
5216irradianceCoords/=irradianceVector.z;
5217#endif
5218irradianceCoords.y=1.0-irradianceCoords.y;
5219#endif
5220vec4 refractionIrradiance=sampleReflection(irradianceSampler,-irradianceCoords);
5221#ifdef RGBDREFLECTION
5222refractionIrradiance.rgb=fromRGBD(refractionIrradiance);
5223#endif
5224#ifdef GAMMAREFLECTION
5225refractionIrradiance.rgb=toLinearSpace(refractionIrradiance.rgb);
5226#endif
5227#else
5228vec4 refractionIrradiance=vec4(0.);
5229#endif
5230refractionIrradiance.rgb*=transmittance;
5231outParams.refractionIrradiance=refractionIrradiance.rgb;
5232#endif
5233}
5234#endif
5235`;je.a.IncludesShadersStore.pbrBlockSubSurface=v_;var b_=`vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);
5236#ifdef NORMAL
5237vec3 normalW=normalize(vNormalW);
5238#else
5239vec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;
5240#endif
5241vec3 geometricNormalW=normalW;
5242#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
5243geometricNormalW=gl_FrontFacing ? geometricNormalW : -geometricNormalW;
5244#endif
5245`;je.a.IncludesShadersStore.pbrBlockNormalGeometric=b_,f(134);var y_=`#if defined(FORCENORMALFORWARD) && defined(NORMAL)
5246vec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;
5247#if defined(TWOSIDEDLIGHTING)
5248faceNormal=gl_FrontFacing ? faceNormal : -faceNormal;
5249#endif
5250normalW*=sign(dot(normalW,faceNormal));
5251#endif
5252#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
5253normalW=gl_FrontFacing ? normalW : -normalW;
5254#endif
5255`;je.a.IncludesShadersStore.pbrBlockNormalFinal=y_,f(162);var T_=`#ifdef LIGHTMAP
5256vec4 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset);
5257#ifdef RGBDLIGHTMAP
5258lightmapColor.rgb=fromRGBD(lightmapColor);
5259#endif
5260#ifdef GAMMALIGHTMAP
5261lightmapColor.rgb=toLinearSpace(lightmapColor.rgb);
5262#endif
5263lightmapColor.rgb*=vLightmapInfos.y;
5264#endif
5265`;je.a.IncludesShadersStore.pbrBlockLightmapInit=T_;var E_=`float NdotVUnclamped=dot(normalW,viewDirectionW);
5266
5267float NdotV=absEps(NdotVUnclamped);
5268float alphaG=convertRoughnessToAverageSlope(roughness);
5269vec2 AARoughnessFactors=getAARoughnessFactors(normalW.xyz);
5270#ifdef SPECULARAA
5271
5272alphaG+=AARoughnessFactors.y;
5273#endif
5274#if defined(ENVIRONMENTBRDF)
5275
5276vec3 environmentBrdf=getBRDFLookup(NdotV,roughness);
5277#endif
5278#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
5279#ifdef RADIANCEOCCLUSION
5280#ifdef AMBIENTINGRAYSCALE
5281float ambientMonochrome=aoOut.ambientOcclusionColor.r;
5282#else
5283float ambientMonochrome=getLuminance(aoOut.ambientOcclusionColor);
5284#endif
5285float seo=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);
5286#endif
5287#ifdef HORIZONOCCLUSION
5288#ifdef BUMP
5289#ifdef REFLECTIONMAP_3D
5290float eho=environmentHorizonOcclusion(-viewDirectionW,normalW,geometricNormalW);
5291#endif
5292#endif
5293#endif
5294#endif
5295`;je.a.IncludesShadersStore.pbrBlockGeometryInfo=E_;var S_=`float reflectance=max(max(reflectivityOut.surfaceReflectivityColor.r,reflectivityOut.surfaceReflectivityColor.g),reflectivityOut.surfaceReflectivityColor.b);
5296vec3 specularEnvironmentR0=reflectivityOut.surfaceReflectivityColor.rgb;
5297#ifdef METALLICWORKFLOW
5298vec3 specularEnvironmentR90=vec3(metallicReflectanceFactors.a);
5299#else
5300vec3 specularEnvironmentR90=vec3(1.0,1.0,1.0);
5301#endif
5302
5303#ifdef ALPHAFRESNEL
5304float reflectance90=fresnelGrazingReflectance(reflectance);
5305specularEnvironmentR90=specularEnvironmentR90*reflectance90;
5306#endif
5307`;je.a.IncludesShadersStore.pbrBlockReflectance0=S_;var A_=`#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
5308vec3 specularEnvironmentReflectance=getReflectanceFromBRDFLookup(clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,environmentBrdf);
5309#ifdef RADIANCEOCCLUSION
5310specularEnvironmentReflectance*=seo;
5311#endif
5312#ifdef HORIZONOCCLUSION
5313#ifdef BUMP
5314#ifdef REFLECTIONMAP_3D
5315specularEnvironmentReflectance*=eho;
5316#endif
5317#endif
5318#endif
5319#else
5320
5321vec3 specularEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(NdotV,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));
5322#endif
5323#ifdef CLEARCOAT
5324specularEnvironmentReflectance*=clearcoatOut.conservationFactor;
5325#if defined(CLEARCOAT_TINT)
5326specularEnvironmentReflectance*=clearcoatOut.absorption;
5327#endif
5328#endif
5329`;je.a.IncludesShadersStore.pbrBlockReflectance=A_;var P_=`vec3 diffuseBase=vec3(0.,0.,0.);
5330#ifdef SPECULARTERM
5331vec3 specularBase=vec3(0.,0.,0.);
5332#endif
5333#ifdef CLEARCOAT
5334vec3 clearCoatBase=vec3(0.,0.,0.);
5335#endif
5336#ifdef SHEEN
5337vec3 sheenBase=vec3(0.,0.,0.);
5338#endif
5339
5340preLightingInfo preInfo;
5341lightingInfo info;
5342float shadow=1.;
5343#if defined(CLEARCOAT) && defined(CLEARCOAT_TINT)
5344vec3 absorption=vec3(0.);
5345#endif
5346`;je.a.IncludesShadersStore.pbrBlockDirectLighting=P_;var C_=`
5347
5348
5349
5350#if defined(ENVIRONMENTBRDF)
5351#ifdef MS_BRDF_ENERGY_CONSERVATION
5352vec3 energyConservationFactor=getEnergyConservationFactor(clearcoatOut.specularEnvironmentR0,environmentBrdf);
5353#endif
5354#endif
5355#ifndef METALLICWORKFLOW
5356#ifdef SPECULAR_GLOSSINESS_ENERGY_CONSERVATION
5357surfaceAlbedo.rgb=(1.-reflectance)*surfaceAlbedo.rgb;
5358#endif
5359#endif
5360#if defined(SHEEN) && defined(SHEEN_ALBEDOSCALING) && defined(ENVIRONMENTBRDF)
5361surfaceAlbedo.rgb=sheenOut.sheenAlbedoScaling*surfaceAlbedo.rgb;
5362#endif
5363
5364#ifdef REFLECTION
5365vec3 finalIrradiance=reflectionOut.environmentIrradiance;
5366#if defined(CLEARCOAT)
5367finalIrradiance*=clearcoatOut.conservationFactor;
5368#if defined(CLEARCOAT_TINT)
5369finalIrradiance*=clearcoatOut.absorption;
5370#endif
5371#endif
5372#if defined(SS_REFRACTION)
5373finalIrradiance*=subSurfaceOut.refractionFactorForIrradiance;
5374#endif
5375#if defined(SS_TRANSLUCENCY)
5376finalIrradiance*=(1.0-subSurfaceOut.translucencyIntensity);
5377finalIrradiance+=subSurfaceOut.refractionIrradiance;
5378#endif
5379finalIrradiance*=surfaceAlbedo.rgb;
5380finalIrradiance*=vLightingIntensity.z;
5381finalIrradiance*=aoOut.ambientOcclusionColor;
5382#endif
5383
5384#ifdef SPECULARTERM
5385vec3 finalSpecular=specularBase;
5386finalSpecular=max(finalSpecular,0.0);
5387vec3 finalSpecularScaled=finalSpecular*vLightingIntensity.x*vLightingIntensity.w;
5388#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
5389finalSpecularScaled*=energyConservationFactor;
5390#endif
5391#if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
5392finalSpecularScaled*=sheenOut.sheenAlbedoScaling;
5393#endif
5394#endif
5395
5396#ifdef REFLECTION
5397vec3 finalRadiance=reflectionOut.environmentRadiance.rgb;
5398finalRadiance*=subSurfaceOut.specularEnvironmentReflectance;
5399vec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z;
5400#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
5401finalRadianceScaled*=energyConservationFactor;
5402#endif
5403#if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
5404finalRadianceScaled*=sheenOut.sheenAlbedoScaling;
5405#endif
5406#endif
5407
5408#ifdef SHEEN
5409vec3 finalSheen=sheenBase*sheenOut.sheenColor;
5410finalSheen=max(finalSheen,0.0);
5411vec3 finalSheenScaled=finalSheen*vLightingIntensity.x*vLightingIntensity.w;
5412#if defined(CLEARCOAT) && defined(REFLECTION) && defined(ENVIRONMENTBRDF)
5413sheenOut.finalSheenRadianceScaled*=clearcoatOut.conservationFactor;
5414#if defined(CLEARCOAT_TINT)
5415sheenOut.finalSheenRadianceScaled*=clearcoatOut.absorption;
5416#endif
5417#endif
5418#endif
5419
5420#ifdef CLEARCOAT
5421vec3 finalClearCoat=clearCoatBase;
5422finalClearCoat=max(finalClearCoat,0.0);
5423vec3 finalClearCoatScaled=finalClearCoat*vLightingIntensity.x*vLightingIntensity.w;
5424#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
5425finalClearCoatScaled*=clearcoatOut.energyConservationFactorClearCoat;
5426#endif
5427#ifdef SS_REFRACTION
5428subSurfaceOut.finalRefraction*=clearcoatOut.conservationFactor;
5429#ifdef CLEARCOAT_TINT
5430subSurfaceOut.finalRefraction*=clearcoatOut.absorption;
5431#endif
5432#endif
5433#endif
5434
5435#ifdef ALPHABLEND
5436float luminanceOverAlpha=0.0;
5437#if defined(REFLECTION) && defined(RADIANCEOVERALPHA)
5438luminanceOverAlpha+=getLuminance(finalRadianceScaled);
5439#if defined(CLEARCOAT)
5440luminanceOverAlpha+=getLuminance(clearcoatOut.finalClearCoatRadianceScaled);
5441#endif
5442#endif
5443#if defined(SPECULARTERM) && defined(SPECULAROVERALPHA)
5444luminanceOverAlpha+=getLuminance(finalSpecularScaled);
5445#endif
5446#if defined(CLEARCOAT) && defined(CLEARCOATOVERALPHA)
5447luminanceOverAlpha+=getLuminance(finalClearCoatScaled);
5448#endif
5449#if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA) || defined(CLEARCOATOVERALPHA)
5450alpha=saturate(alpha+luminanceOverAlpha*luminanceOverAlpha);
5451#endif
5452#endif
5453`;je.a.IncludesShadersStore.pbrBlockFinalLitComponents=C_;var x_=`
5454vec3 finalDiffuse=diffuseBase;
5455finalDiffuse*=surfaceAlbedo.rgb;
5456finalDiffuse=max(finalDiffuse,0.0);
5457finalDiffuse*=vLightingIntensity.x;
5458
5459vec3 finalAmbient=vAmbientColor;
5460finalAmbient*=surfaceAlbedo.rgb;
5461
5462vec3 finalEmissive=vEmissiveColor;
5463#ifdef EMISSIVE
5464vec3 emissiveColorTex=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb;
5465finalEmissive*=toLinearSpace(emissiveColorTex.rgb);
5466finalEmissive*=vEmissiveInfos.y;
5467#endif
5468finalEmissive*=vLightingIntensity.y;
5469
5470#ifdef AMBIENT
5471vec3 ambientOcclusionForDirectDiffuse=mix(vec3(1.),aoOut.ambientOcclusionColor,vAmbientInfos.w);
5472#else
5473vec3 ambientOcclusionForDirectDiffuse=aoOut.ambientOcclusionColor;
5474#endif
5475finalAmbient*=aoOut.ambientOcclusionColor;
5476finalDiffuse*=ambientOcclusionForDirectDiffuse;
5477`;je.a.IncludesShadersStore.pbrBlockFinalUnlitComponents=x_;var R_=`vec4 finalColor=vec4(
5478finalAmbient +
5479finalDiffuse +
5480#ifndef UNLIT
5481#ifdef REFLECTION
5482finalIrradiance +
5483#endif
5484#ifdef SPECULARTERM
5485finalSpecularScaled +
5486#endif
5487#ifdef SHEEN
5488finalSheenScaled +
5489#endif
5490#ifdef CLEARCOAT
5491finalClearCoatScaled +
5492#endif
5493#ifdef REFLECTION
5494finalRadianceScaled +
5495#if defined(SHEEN) && defined(ENVIRONMENTBRDF)
5496sheenOut.finalSheenRadianceScaled +
5497#endif
5498#ifdef CLEARCOAT
5499clearcoatOut.finalClearCoatRadianceScaled +
5500#endif
5501#endif
5502#ifdef SS_REFRACTION
5503subSurfaceOut.finalRefraction +
5504#endif
5505#endif
5506finalEmissive,
5507alpha);
5508
5509#ifdef LIGHTMAP
5510#ifndef LIGHTMAPEXCLUDED
5511#ifdef USELIGHTMAPASSHADOWMAP
5512finalColor.rgb*=lightmapColor.rgb;
5513#else
5514finalColor.rgb+=lightmapColor.rgb;
5515#endif
5516#endif
5517#endif
5518#define CUSTOM_FRAGMENT_BEFORE_FOG
5519
5520finalColor=max(finalColor,0.0);
5521`;je.a.IncludesShadersStore.pbrBlockFinalColorComposition=R_,f(155);var O_=`#ifdef IMAGEPROCESSINGPOSTPROCESS
5522
5523
5524finalColor.rgb=clamp(finalColor.rgb,0.,30.0);
5525#else
5526
5527finalColor=applyImageProcessing(finalColor);
5528#endif
5529finalColor.a*=visibility;
5530#ifdef PREMULTIPLYALPHA
5531
5532finalColor.rgb*=finalColor.a;
5533#endif
5534`;je.a.IncludesShadersStore.pbrBlockImageProcessing=O_;var M_=`#if DEBUGMODE>0
5535if (vClipSpacePosition.x/vClipSpacePosition.w>=vDebugMode.x) {
5536
5537#if DEBUGMODE == 1
5538gl_FragColor.rgb=vPositionW.rgb;
5539#define DEBUGMODE_NORMALIZE
5540#elif DEBUGMODE == 2 && defined(NORMAL)
5541gl_FragColor.rgb=vNormalW.rgb;
5542#define DEBUGMODE_NORMALIZE
5543#elif DEBUGMODE == 3 && defined(BUMP) || DEBUGMODE == 3 && defined(PARALLAX) || DEBUGMODE == 3 && defined(ANISOTROPIC)
5544
5545gl_FragColor.rgb=TBN[0];
5546#define DEBUGMODE_NORMALIZE
5547#elif DEBUGMODE == 4 && defined(BUMP) || DEBUGMODE == 4 && defined(PARALLAX) || DEBUGMODE == 4 && defined(ANISOTROPIC)
5548
5549gl_FragColor.rgb=TBN[1];
5550#define DEBUGMODE_NORMALIZE
5551#elif DEBUGMODE == 5
5552
5553gl_FragColor.rgb=normalW;
5554#define DEBUGMODE_NORMALIZE
5555#elif DEBUGMODE == 6 && defined(MAINUV1)
5556gl_FragColor.rgb=vec3(vMainUV1,0.0);
5557#elif DEBUGMODE == 7 && defined(MAINUV2)
5558gl_FragColor.rgb=vec3(vMainUV2,0.0);
5559#elif DEBUGMODE == 8 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)
5560
5561gl_FragColor.rgb=clearcoatOut.TBNClearCoat[0];
5562#define DEBUGMODE_NORMALIZE
5563#elif DEBUGMODE == 9 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)
5564
5565gl_FragColor.rgb=clearcoatOut.TBNClearCoat[1];
5566#define DEBUGMODE_NORMALIZE
5567#elif DEBUGMODE == 10 && defined(CLEARCOAT)
5568
5569gl_FragColor.rgb=clearcoatOut.clearCoatNormalW;
5570#define DEBUGMODE_NORMALIZE
5571#elif DEBUGMODE == 11 && defined(ANISOTROPIC)
5572gl_FragColor.rgb=anisotropicOut.anisotropicNormal;
5573#define DEBUGMODE_NORMALIZE
5574#elif DEBUGMODE == 12 && defined(ANISOTROPIC)
5575gl_FragColor.rgb=anisotropicOut.anisotropicTangent;
5576#define DEBUGMODE_NORMALIZE
5577#elif DEBUGMODE == 13 && defined(ANISOTROPIC)
5578gl_FragColor.rgb=anisotropicOut.anisotropicBitangent;
5579#define DEBUGMODE_NORMALIZE
5580
5581#elif DEBUGMODE == 20 && defined(ALBEDO)
5582gl_FragColor.rgb=albedoTexture.rgb;
5583#elif DEBUGMODE == 21 && defined(AMBIENT)
5584gl_FragColor.rgb=aoOut.ambientOcclusionColorMap.rgb;
5585#elif DEBUGMODE == 22 && defined(OPACITY)
5586gl_FragColor.rgb=opacityMap.rgb;
5587#elif DEBUGMODE == 23 && defined(EMISSIVE)
5588gl_FragColor.rgb=emissiveColorTex.rgb;
5589#define DEBUGMODE_GAMMA
5590#elif DEBUGMODE == 24 && defined(LIGHTMAP)
5591gl_FragColor.rgb=lightmapColor.rgb;
5592#define DEBUGMODE_GAMMA
5593#elif DEBUGMODE == 25 && defined(REFLECTIVITY) && defined(METALLICWORKFLOW)
5594gl_FragColor.rgb=reflectivityOut.surfaceMetallicColorMap.rgb;
5595#elif DEBUGMODE == 26 && defined(REFLECTIVITY) && !defined(METALLICWORKFLOW)
5596gl_FragColor.rgb=reflectivityOut.surfaceReflectivityColorMap.rgb;
5597#define DEBUGMODE_GAMMA
5598#elif DEBUGMODE == 27 && defined(CLEARCOAT) && defined(CLEARCOAT_TEXTURE)
5599gl_FragColor.rgb=vec3(clearcoatOut.clearCoatMapData.rg,0.0);
5600#elif DEBUGMODE == 28 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
5601gl_FragColor.rgb=clearcoatOut.clearCoatTintMapData.rgb;
5602#elif DEBUGMODE == 29 && defined(SHEEN) && defined(SHEEN_TEXTURE)
5603gl_FragColor.rgb=sheenOut.sheenMapData.rgb;
5604#elif DEBUGMODE == 30 && defined(ANISOTROPIC) && defined(ANISOTROPIC_TEXTURE)
5605gl_FragColor.rgb=anisotropicOut.anisotropyMapData.rgb;
5606#elif DEBUGMODE == 31 && defined(SUBSURFACE) && defined(SS_THICKNESSANDMASK_TEXTURE)
5607gl_FragColor.rgb=subSurfaceOut.thicknessMap.rgb;
5608
5609#elif DEBUGMODE == 40 && defined(SS_REFRACTION)
5610
5611gl_FragColor.rgb=subSurfaceOut.environmentRefraction.rgb;
5612#define DEBUGMODE_GAMMA
5613#elif DEBUGMODE == 41 && defined(REFLECTION)
5614gl_FragColor.rgb=reflectionOut.environmentRadiance.rgb;
5615#define DEBUGMODE_GAMMA
5616#elif DEBUGMODE == 42 && defined(CLEARCOAT) && defined(REFLECTION)
5617gl_FragColor.rgb=clearcoatOut.environmentClearCoatRadiance.rgb;
5618#define DEBUGMODE_GAMMA
5619
5620#elif DEBUGMODE == 50
5621gl_FragColor.rgb=diffuseBase.rgb;
5622#define DEBUGMODE_GAMMA
5623#elif DEBUGMODE == 51 && defined(SPECULARTERM)
5624gl_FragColor.rgb=specularBase.rgb;
5625#define DEBUGMODE_GAMMA
5626#elif DEBUGMODE == 52 && defined(CLEARCOAT)
5627gl_FragColor.rgb=clearCoatBase.rgb;
5628#define DEBUGMODE_GAMMA
5629#elif DEBUGMODE == 53 && defined(SHEEN)
5630gl_FragColor.rgb=sheenBase.rgb;
5631#define DEBUGMODE_GAMMA
5632#elif DEBUGMODE == 54 && defined(REFLECTION)
5633gl_FragColor.rgb=reflectionOut.environmentIrradiance.rgb;
5634#define DEBUGMODE_GAMMA
5635
5636#elif DEBUGMODE == 60
5637gl_FragColor.rgb=surfaceAlbedo.rgb;
5638#define DEBUGMODE_GAMMA
5639#elif DEBUGMODE == 61
5640gl_FragColor.rgb=clearcoatOut.specularEnvironmentR0;
5641#define DEBUGMODE_GAMMA
5642#elif DEBUGMODE == 62 && defined(METALLICWORKFLOW)
5643gl_FragColor.rgb=vec3(reflectivityOut.metallicRoughness.r);
5644#elif DEBUGMODE == 71 && defined(METALLICWORKFLOW)
5645gl_FragColor.rgb=reflectivityOut.metallicF0;
5646#elif DEBUGMODE == 63
5647gl_FragColor.rgb=vec3(roughness);
5648#elif DEBUGMODE == 64
5649gl_FragColor.rgb=vec3(alphaG);
5650#elif DEBUGMODE == 65
5651gl_FragColor.rgb=vec3(NdotV);
5652#elif DEBUGMODE == 66 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT)
5653gl_FragColor.rgb=clearcoatOut.clearCoatColor.rgb;
5654#define DEBUGMODE_GAMMA
5655#elif DEBUGMODE == 67 && defined(CLEARCOAT)
5656gl_FragColor.rgb=vec3(clearcoatOut.clearCoatRoughness);
5657#elif DEBUGMODE == 68 && defined(CLEARCOAT)
5658gl_FragColor.rgb=vec3(clearcoatOut.clearCoatNdotV);
5659#elif DEBUGMODE == 69 && defined(SUBSURFACE) && defined(SS_TRANSLUCENCY)
5660gl_FragColor.rgb=subSurfaceOut.transmittance;
5661#elif DEBUGMODE == 70 && defined(SUBSURFACE) && defined(SS_REFRACTION)
5662gl_FragColor.rgb=subSurfaceOut.refractionTransmittance;
5663
5664#elif DEBUGMODE == 80 && defined(RADIANCEOCCLUSION)
5665gl_FragColor.rgb=vec3(seo);
5666#elif DEBUGMODE == 81 && defined(HORIZONOCCLUSION)
5667gl_FragColor.rgb=vec3(eho);
5668#elif DEBUGMODE == 82 && defined(MS_BRDF_ENERGY_CONSERVATION)
5669gl_FragColor.rgb=vec3(energyConservationFactor);
5670#elif DEBUGMODE == 83 && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
5671gl_FragColor.rgb=specularEnvironmentReflectance;
5672#define DEBUGMODE_GAMMA
5673#elif DEBUGMODE == 84 && defined(CLEARCOAT) && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
5674gl_FragColor.rgb=clearcoatOut.clearCoatEnvironmentReflectance;
5675#define DEBUGMODE_GAMMA
5676#elif DEBUGMODE == 85 && defined(SHEEN) && defined(REFLECTION)
5677gl_FragColor.rgb=sheenOut.sheenEnvironmentReflectance;
5678#define DEBUGMODE_GAMMA
5679#elif DEBUGMODE == 86 && defined(ALPHABLEND)
5680gl_FragColor.rgb=vec3(luminanceOverAlpha);
5681#elif DEBUGMODE == 87
5682gl_FragColor.rgb=vec3(alpha);
5683#endif
5684gl_FragColor.rgb*=vDebugMode.y;
5685#ifdef DEBUGMODE_NORMALIZE
5686gl_FragColor.rgb=normalize(gl_FragColor.rgb)*0.5+0.5;
5687#endif
5688#ifdef DEBUGMODE_GAMMA
5689gl_FragColor.rgb=toGammaSpace(gl_FragColor.rgb);
5690#endif
5691gl_FragColor.a=1.0;
5692#ifdef PREPASS
5693gl_FragData[0]=toLinearSpace(gl_FragColor);
5694gl_FragData[1]=vec4(0.,0.,0.,0.);
5695#endif
5696return;
5697}
5698#endif`;je.a.IncludesShadersStore.pbrDebug=M_;var I_=`#if defined(BUMP) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)
5699#extension GL_OES_standard_derivatives : enable
5700#endif
5701#ifdef LODBASEDMICROSFURACE
5702#extension GL_EXT_shader_texture_lod : enable
5703#endif
5704#define CUSTOM_FRAGMENT_BEGIN
5705#ifdef LOGARITHMICDEPTH
5706#extension GL_EXT_frag_depth : enable
5707#endif
5708#include<prePassDeclaration>[SCENE_MRT_COUNT]
5709precision highp float;
5710
5711#ifndef FROMLINEARSPACE
5712#define FROMLINEARSPACE
5713#endif
5714
5715#include<__decl__pbrFragment>
5716#include<pbrFragmentExtraDeclaration>
5717#include<__decl__lightFragment>[0..maxSimultaneousLights]
5718#include<pbrFragmentSamplersDeclaration>
5719#include<imageProcessingDeclaration>
5720#include<clipPlaneFragmentDeclaration>
5721#include<logDepthDeclaration>
5722#include<fogFragmentDeclaration>
5723
5724#include<helperFunctions>
5725#include<subSurfaceScatteringFunctions>
5726#include<importanceSampling>
5727#include<pbrHelperFunctions>
5728#include<imageProcessingFunctions>
5729#include<shadowsFragmentFunctions>
5730#include<harmonicsFunctions>
5731#include<pbrDirectLightingSetupFunctions>
5732#include<pbrDirectLightingFalloffFunctions>
5733#include<pbrBRDFFunctions>
5734#include<hdrFilteringFunctions>
5735#include<pbrDirectLightingFunctions>
5736#include<pbrIBLFunctions>
5737#include<bumpFragmentMainFunctions>
5738#include<bumpFragmentFunctions>
5739#ifdef REFLECTION
5740#include<reflectionFunction>
5741#endif
5742#define CUSTOM_FRAGMENT_DEFINITIONS
5743#include<pbrBlockAlbedoOpacity>
5744#include<pbrBlockReflectivity>
5745#include<pbrBlockAmbientOcclusion>
5746#include<pbrBlockAlphaFresnel>
5747#include<pbrBlockAnisotropic>
5748#include<pbrBlockReflection>
5749#include<pbrBlockSheen>
5750#include<pbrBlockClearcoat>
5751#include<pbrBlockSubSurface>
5752
5753void main(void) {
5754#define CUSTOM_FRAGMENT_MAIN_BEGIN
5755#include<clipPlaneFragment>
5756
5757#include<pbrBlockNormalGeometric>
5758#include<bumpFragment>
5759#include<pbrBlockNormalFinal>
5760
5761albedoOpacityOutParams albedoOpacityOut;
5762#ifdef ALBEDO
5763vec4 albedoTexture=texture2D(albedoSampler,vAlbedoUV+uvOffset);
5764#endif
5765#ifdef OPACITY
5766vec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);
5767#endif
5768albedoOpacityBlock(
5769vAlbedoColor,
5770#ifdef ALBEDO
5771albedoTexture,
5772vAlbedoInfos,
5773#endif
5774#ifdef OPACITY
5775opacityMap,
5776vOpacityInfos,
5777#endif
5778#ifdef DETAIL
5779detailColor,
5780vDetailInfos,
5781#endif
5782albedoOpacityOut
5783);
5784vec3 surfaceAlbedo=albedoOpacityOut.surfaceAlbedo;
5785float alpha=albedoOpacityOut.alpha;
5786#define CUSTOM_FRAGMENT_UPDATE_ALPHA
5787#include<depthPrePass>
5788#define CUSTOM_FRAGMENT_BEFORE_LIGHTS
5789
5790ambientOcclusionOutParams aoOut;
5791#ifdef AMBIENT
5792vec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb;
5793#endif
5794ambientOcclusionBlock(
5795#ifdef AMBIENT
5796ambientOcclusionColorMap,
5797vAmbientInfos,
5798#endif
5799aoOut
5800);
5801#include<pbrBlockLightmapInit>
5802#ifdef UNLIT
5803vec3 diffuseBase=vec3(1.,1.,1.);
5804#else
5805
5806vec3 baseColor=surfaceAlbedo;
5807reflectivityOutParams reflectivityOut;
5808#if defined(REFLECTIVITY)
5809vec4 surfaceMetallicOrReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);
5810vec4 baseReflectivity=surfaceMetallicOrReflectivityColorMap;
5811#ifndef METALLICWORKFLOW
5812surfaceMetallicOrReflectivityColorMap=toLinearSpace(surfaceMetallicOrReflectivityColorMap);
5813surfaceMetallicOrReflectivityColorMap.rgb*=vReflectivityInfos.y;
5814#endif
5815#endif
5816#if defined(MICROSURFACEMAP)
5817vec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;
5818#endif
5819#ifdef METALLICWORKFLOW
5820vec4 metallicReflectanceFactors=vMetallicReflectanceFactors;
5821#ifdef METALLIC_REFLECTANCE
5822vec4 metallicReflectanceFactorsMap=texture2D(metallicReflectanceSampler,vMetallicReflectanceUV+uvOffset);
5823metallicReflectanceFactorsMap=toLinearSpace(metallicReflectanceFactorsMap);
5824metallicReflectanceFactors*=metallicReflectanceFactorsMap;
5825#endif
5826#endif
5827reflectivityBlock(
5828vReflectivityColor,
5829#ifdef METALLICWORKFLOW
5830surfaceAlbedo,
5831metallicReflectanceFactors,
5832#endif
5833#ifdef REFLECTIVITY
5834vReflectivityInfos,
5835surfaceMetallicOrReflectivityColorMap,
5836#endif
5837#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
5838aoOut.ambientOcclusionColor,
5839#endif
5840#ifdef MICROSURFACEMAP
5841microSurfaceTexel,
5842#endif
5843#ifdef DETAIL
5844detailColor,
5845vDetailInfos,
5846#endif
5847reflectivityOut
5848);
5849float microSurface=reflectivityOut.microSurface;
5850float roughness=reflectivityOut.roughness;
5851#ifdef METALLICWORKFLOW
5852surfaceAlbedo=reflectivityOut.surfaceAlbedo;
5853#endif
5854#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
5855aoOut.ambientOcclusionColor=reflectivityOut.ambientOcclusionColor;
5856#endif
5857
5858#ifdef ALPHAFRESNEL
5859#if defined(ALPHATEST) || defined(ALPHABLEND)
5860alphaFresnelOutParams alphaFresnelOut;
5861alphaFresnelBlock(
5862normalW,
5863viewDirectionW,
5864alpha,
5865microSurface,
5866alphaFresnelOut
5867);
5868alpha=alphaFresnelOut.alpha;
5869#endif
5870#endif
5871
5872#include<pbrBlockGeometryInfo>
5873
5874#ifdef ANISOTROPIC
5875anisotropicOutParams anisotropicOut;
5876#ifdef ANISOTROPIC_TEXTURE
5877vec3 anisotropyMapData=texture2D(anisotropySampler,vAnisotropyUV+uvOffset).rgb*vAnisotropyInfos.y;
5878#endif
5879anisotropicBlock(
5880vAnisotropy,
5881#ifdef ANISOTROPIC_TEXTURE
5882anisotropyMapData,
5883#endif
5884TBN,
5885normalW,
5886viewDirectionW,
5887anisotropicOut
5888);
5889#endif
5890
5891#ifdef REFLECTION
5892reflectionOutParams reflectionOut;
5893reflectionBlock(
5894vPositionW,
5895normalW,
5896alphaG,
5897vReflectionMicrosurfaceInfos,
5898vReflectionInfos,
5899vReflectionColor,
5900#ifdef ANISOTROPIC
5901anisotropicOut,
5902#endif
5903#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
5904NdotVUnclamped,
5905#endif
5906#ifdef LINEARSPECULARREFLECTION
5907roughness,
5908#endif
5909reflectionSampler,
5910#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
5911vEnvironmentIrradiance,
5912#endif
5913#ifdef USESPHERICALFROMREFLECTIONMAP
5914#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
5915reflectionMatrix,
5916#endif
5917#endif
5918#ifdef USEIRRADIANCEMAP
5919irradianceSampler,
5920#endif
5921#ifndef LODBASEDMICROSFURACE
5922reflectionSamplerLow,
5923reflectionSamplerHigh,
5924#endif
5925#ifdef REALTIME_FILTERING
5926vReflectionFilteringInfo,
5927#endif
5928reflectionOut
5929);
5930#endif
5931
5932#include<pbrBlockReflectance0>
5933
5934#ifdef SHEEN
5935sheenOutParams sheenOut;
5936#ifdef SHEEN_TEXTURE
5937vec4 sheenMapData=toLinearSpace(texture2D(sheenSampler,vSheenUV+uvOffset))*vSheenInfos.y;
5938#endif
5939#if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
5940vec4 sheenMapRoughnessData=texture2D(sheenRoughnessSampler,vSheenRoughnessUV+uvOffset)*vSheenInfos.w;
5941#endif
5942sheenBlock(
5943vSheenColor,
5944#ifdef SHEEN_ROUGHNESS
5945vSheenRoughness,
5946#if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
5947sheenMapRoughnessData,
5948#endif
5949#endif
5950roughness,
5951#ifdef SHEEN_TEXTURE
5952sheenMapData,
5953#endif
5954reflectance,
5955#ifdef SHEEN_LINKWITHALBEDO
5956baseColor,
5957surfaceAlbedo,
5958#endif
5959#ifdef ENVIRONMENTBRDF
5960NdotV,
5961environmentBrdf,
5962#endif
5963#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
5964AARoughnessFactors,
5965vReflectionMicrosurfaceInfos,
5966vReflectionInfos,
5967vReflectionColor,
5968vLightingIntensity,
5969reflectionSampler,
5970reflectionOut.reflectionCoords,
5971NdotVUnclamped,
5972#ifndef LODBASEDMICROSFURACE
5973reflectionSamplerLow,
5974reflectionSamplerHigh,
5975#endif
5976#ifdef REALTIME_FILTERING
5977vReflectionFilteringInfo,
5978#endif
5979#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
5980seo,
5981#endif
5982#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
5983eho,
5984#endif
5985#endif
5986sheenOut
5987);
5988#ifdef SHEEN_LINKWITHALBEDO
5989surfaceAlbedo=sheenOut.surfaceAlbedo;
5990#endif
5991#endif
5992
5993clearcoatOutParams clearcoatOut;
5994#ifdef CLEARCOAT
5995#ifdef CLEARCOAT_TEXTURE
5996vec2 clearCoatMapData=texture2D(clearCoatSampler,vClearCoatUV+uvOffset).rg*vClearCoatInfos.y;
5997#endif
5998#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
5999vec4 clearCoatMapRoughnessData=texture2D(clearCoatRoughnessSampler,vClearCoatRoughnessUV+uvOffset)*vClearCoatInfos.w;
6000#endif
6001#if defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
6002vec4 clearCoatTintMapData=toLinearSpace(texture2D(clearCoatTintSampler,vClearCoatTintUV+uvOffset));
6003#endif
6004#ifdef CLEARCOAT_BUMP
6005vec4 clearCoatBumpMapData=texture2D(clearCoatBumpSampler,vClearCoatBumpUV+uvOffset);
6006#endif
6007clearcoatBlock(
6008vPositionW,
6009geometricNormalW,
6010viewDirectionW,
6011vClearCoatParams,
6012#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
6013clearCoatMapRoughnessData,
6014#endif
6015specularEnvironmentR0,
6016#ifdef CLEARCOAT_TEXTURE
6017clearCoatMapData,
6018#endif
6019#ifdef CLEARCOAT_TINT
6020vClearCoatTintParams,
6021clearCoatColorAtDistance,
6022vClearCoatRefractionParams,
6023#ifdef CLEARCOAT_TINT_TEXTURE
6024clearCoatTintMapData,
6025#endif
6026#endif
6027#ifdef CLEARCOAT_BUMP
6028vClearCoatBumpInfos,
6029clearCoatBumpMapData,
6030vClearCoatBumpUV,
6031#if defined(TANGENT) && defined(NORMAL)
6032vTBN,
6033#else
6034vClearCoatTangentSpaceParams,
6035#endif
6036#ifdef OBJECTSPACE_NORMALMAP
6037normalMatrix,
6038#endif
6039#endif
6040#if defined(FORCENORMALFORWARD) && defined(NORMAL)
6041faceNormal,
6042#endif
6043#ifdef REFLECTION
6044vReflectionMicrosurfaceInfos,
6045vReflectionInfos,
6046vReflectionColor,
6047vLightingIntensity,
6048reflectionSampler,
6049#ifndef LODBASEDMICROSFURACE
6050reflectionSamplerLow,
6051reflectionSamplerHigh,
6052#endif
6053#ifdef REALTIME_FILTERING
6054vReflectionFilteringInfo,
6055#endif
6056#endif
6057#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
6058#ifdef RADIANCEOCCLUSION
6059ambientMonochrome,
6060#endif
6061#endif
6062clearcoatOut
6063);
6064#else
6065clearcoatOut.specularEnvironmentR0=specularEnvironmentR0;
6066#endif
6067
6068#include<pbrBlockReflectance>
6069
6070subSurfaceOutParams subSurfaceOut;
6071#ifdef SUBSURFACE
6072#ifdef SS_THICKNESSANDMASK_TEXTURE
6073vec4 thicknessMap=texture2D(thicknessSampler,vThicknessUV+uvOffset);
6074#endif
6075subSurfaceBlock(
6076vSubSurfaceIntensity,
6077vThicknessParam,
6078vTintColor,
6079normalW,
6080specularEnvironmentReflectance,
6081#ifdef SS_THICKNESSANDMASK_TEXTURE
6082thicknessMap,
6083#endif
6084#ifdef REFLECTION
6085#ifdef SS_TRANSLUCENCY
6086reflectionMatrix,
6087#ifdef USESPHERICALFROMREFLECTIONMAP
6088#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
6089reflectionOut.irradianceVector,
6090#endif
6091#if defined(REALTIME_FILTERING)
6092reflectionSampler,
6093vReflectionFilteringInfo,
6094#endif
6095#endif
6096#ifdef USEIRRADIANCEMAP
6097irradianceSampler,
6098#endif
6099#endif
6100#endif
6101#ifdef SS_REFRACTION
6102vPositionW,
6103viewDirectionW,
6104view,
6105surfaceAlbedo,
6106vRefractionInfos,
6107refractionMatrix,
6108vRefractionMicrosurfaceInfos,
6109vLightingIntensity,
6110#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
6111alpha,
6112#endif
6113#ifdef SS_LODINREFRACTIONALPHA
6114NdotVUnclamped,
6115#endif
6116#ifdef SS_LINEARSPECULARREFRACTION
6117roughness,
6118#else
6119alphaG,
6120#endif
6121refractionSampler,
6122#ifndef LODBASEDMICROSFURACE
6123refractionSamplerLow,
6124refractionSamplerHigh,
6125#endif
6126#ifdef ANISOTROPIC
6127anisotropicOut,
6128#endif
6129#ifdef REALTIME_FILTERING
6130vRefractionFilteringInfo,
6131#endif
6132#endif
6133#ifdef SS_TRANSLUCENCY
6134vDiffusionDistance,
6135#endif
6136subSurfaceOut
6137);
6138#ifdef SS_REFRACTION
6139surfaceAlbedo=subSurfaceOut.surfaceAlbedo;
6140#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
6141alpha=subSurfaceOut.alpha;
6142#endif
6143#endif
6144#else
6145subSurfaceOut.specularEnvironmentReflectance=specularEnvironmentReflectance;
6146#endif
6147
6148#include<pbrBlockDirectLighting>
6149#include<lightFragment>[0..maxSimultaneousLights]
6150
6151#include<pbrBlockFinalLitComponents>
6152#endif
6153#include<pbrBlockFinalUnlitComponents>
6154#include<pbrBlockFinalColorComposition>
6155#include<logDepthFragment>
6156#include<fogFragment>(color,finalColor)
6157#include<pbrBlockImageProcessing>
6158#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR
6159#ifdef PREPASS
6160#ifdef PREPASS_POSITION
6161gl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,1.0);
6162#endif
6163#ifdef PREPASS_VELOCITY
6164vec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;
6165vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;
6166vec2 velocity=abs(a-b);
6167velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;
6168gl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,1.0);
6169#endif
6170#ifdef PREPASS_IRRADIANCE
6171vec3 irradiance=finalDiffuse;
6172#ifndef UNLIT
6173#ifdef REFLECTION
6174irradiance+=finalIrradiance;
6175#endif
6176#endif
6177vec3 sqAlbedo=sqrt(surfaceAlbedo);
6178#ifdef SS_SCATTERING
6179gl_FragData[0]=vec4(finalColor.rgb-irradiance,finalColor.a);
6180irradiance/=sqAlbedo;
6181#else
6182gl_FragData[0]=finalColor;
6183float scatteringDiffusionProfile=255.;
6184#endif
6185gl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(irradiance,scatteringDiffusionProfile/255.);
6186#else
6187gl_FragData[0]=vec4(finalColor.rgb,finalColor.a);
6188#endif
6189#ifdef PREPASS_DEPTHNORMAL
6190gl_FragData[PREPASS_DEPTHNORMAL_INDEX]=vec4(vViewPos.z,(view*vec4(normalW,0.0)).rgb);
6191#endif
6192#ifdef PREPASS_ALBEDO
6193gl_FragData[PREPASS_ALBEDO_INDEX]=vec4(sqAlbedo,1.0);
6194#endif
6195#ifdef PREPASS_REFLECTIVITY
6196#if defined(REFLECTIVITY)
6197gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(baseReflectivity.rgb,1.0);
6198#else
6199gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(0.0,0.0,0.0,1.0);
6200#endif
6201#endif
6202#endif
6203#if !defined(PREPASS) || defined(WEBGL2)
6204gl_FragColor=finalColor;
6205#endif
6206#include<pbrDebug>
6207}
6208`;je.a.ShadersStore.pbrPixelShader=I_;var D_=`uniform mat4 view;
6209uniform mat4 viewProjection;
6210#ifdef ALBEDO
6211uniform mat4 albedoMatrix;
6212uniform vec2 vAlbedoInfos;
6213#endif
6214#ifdef AMBIENT
6215uniform mat4 ambientMatrix;
6216uniform vec4 vAmbientInfos;
6217#endif
6218#ifdef OPACITY
6219uniform mat4 opacityMatrix;
6220uniform vec2 vOpacityInfos;
6221#endif
6222#ifdef EMISSIVE
6223uniform vec2 vEmissiveInfos;
6224uniform mat4 emissiveMatrix;
6225#endif
6226#ifdef LIGHTMAP
6227uniform vec2 vLightmapInfos;
6228uniform mat4 lightmapMatrix;
6229#endif
6230#ifdef REFLECTIVITY
6231uniform vec3 vReflectivityInfos;
6232uniform mat4 reflectivityMatrix;
6233#endif
6234#ifdef METALLIC_REFLECTANCE
6235uniform vec2 vMetallicReflectanceInfos;
6236uniform mat4 metallicReflectanceMatrix;
6237#endif
6238#ifdef MICROSURFACEMAP
6239uniform vec2 vMicroSurfaceSamplerInfos;
6240uniform mat4 microSurfaceSamplerMatrix;
6241#endif
6242#ifdef BUMP
6243uniform vec3 vBumpInfos;
6244uniform mat4 bumpMatrix;
6245#endif
6246#ifdef POINTSIZE
6247uniform float pointSize;
6248#endif
6249
6250#ifdef REFLECTION
6251uniform vec2 vReflectionInfos;
6252uniform mat4 reflectionMatrix;
6253#endif
6254
6255#ifdef CLEARCOAT
6256#if defined(CLEARCOAT_TEXTURE) || defined(CLEARCOAT_TEXTURE_ROUGHNESS)
6257uniform vec4 vClearCoatInfos;
6258#endif
6259#ifdef CLEARCOAT_TEXTURE
6260uniform mat4 clearCoatMatrix;
6261#endif
6262#ifdef CLEARCOAT_TEXTURE_ROUGHNESS
6263uniform mat4 clearCoatRoughnessMatrix;
6264#endif
6265#ifdef CLEARCOAT_BUMP
6266uniform vec2 vClearCoatBumpInfos;
6267uniform mat4 clearCoatBumpMatrix;
6268#endif
6269#ifdef CLEARCOAT_TINT_TEXTURE
6270uniform vec2 vClearCoatTintInfos;
6271uniform mat4 clearCoatTintMatrix;
6272#endif
6273#endif
6274
6275#ifdef ANISOTROPIC
6276#ifdef ANISOTROPIC_TEXTURE
6277uniform vec2 vAnisotropyInfos;
6278uniform mat4 anisotropyMatrix;
6279#endif
6280#endif
6281
6282#ifdef SHEEN
6283#if defined(SHEEN_TEXTURE) || defined(SHEEN_TEXTURE_ROUGHNESS)
6284uniform vec4 vSheenInfos;
6285#endif
6286#ifdef SHEEN_TEXTURE
6287uniform mat4 sheenMatrix;
6288#endif
6289#ifdef SHEEN_TEXTURE_ROUGHNESS
6290uniform mat4 sheenRoughnessMatrix;
6291#endif
6292#endif
6293
6294#ifdef SUBSURFACE
6295#ifdef SS_REFRACTION
6296uniform vec4 vRefractionInfos;
6297uniform mat4 refractionMatrix;
6298#endif
6299#ifdef SS_THICKNESSANDMASK_TEXTURE
6300uniform vec2 vThicknessInfos;
6301uniform mat4 thicknessMatrix;
6302#endif
6303#endif
6304`;je.a.IncludesShadersStore.pbrVertexDeclaration=D_,f(163),f(164),f(93),f(94),f(100),f(165),f(156),f(158);var L_=`precision highp float;
6305#include<__decl__pbrVertex>
6306#define CUSTOM_VERTEX_BEGIN
6307
6308attribute vec3 position;
6309#ifdef NORMAL
6310attribute vec3 normal;
6311#endif
6312#ifdef TANGENT
6313attribute vec4 tangent;
6314#endif
6315#ifdef UV1
6316attribute vec2 uv;
6317#endif
6318#ifdef UV2
6319attribute vec2 uv2;
6320#endif
6321#ifdef MAINUV1
6322varying vec2 vMainUV1;
6323#endif
6324#ifdef MAINUV2
6325varying vec2 vMainUV2;
6326#endif
6327#ifdef VERTEXCOLOR
6328attribute vec4 color;
6329#endif
6330#include<helperFunctions>
6331#include<bonesDeclaration>
6332
6333#include<instancesDeclaration>
6334#include<prePassVertexDeclaration>
6335#if defined(ALBEDO) && ALBEDODIRECTUV == 0
6336varying vec2 vAlbedoUV;
6337#endif
6338#if defined(DETAIL) && DETAILDIRECTUV == 0
6339varying vec2 vDetailUV;
6340#endif
6341#if defined(AMBIENT) && AMBIENTDIRECTUV == 0
6342varying vec2 vAmbientUV;
6343#endif
6344#if defined(OPACITY) && OPACITYDIRECTUV == 0
6345varying vec2 vOpacityUV;
6346#endif
6347#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0
6348varying vec2 vEmissiveUV;
6349#endif
6350#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0
6351varying vec2 vLightmapUV;
6352#endif
6353#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0
6354varying vec2 vReflectivityUV;
6355#endif
6356#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0
6357varying vec2 vMicroSurfaceSamplerUV;
6358#endif
6359#if defined(METALLIC_REFLECTANCE) && METALLIC_REFLECTANCEDIRECTUV == 0
6360varying vec2 vMetallicReflectanceUV;
6361#endif
6362#if defined(BUMP) && BUMPDIRECTUV == 0
6363varying vec2 vBumpUV;
6364#endif
6365#ifdef CLEARCOAT
6366#if defined(CLEARCOAT_TEXTURE) && CLEARCOAT_TEXTUREDIRECTUV == 0
6367varying vec2 vClearCoatUV;
6368#endif
6369#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV == 0
6370varying vec2 vClearCoatRoughnessUV;
6371#endif
6372#if defined(CLEARCOAT_BUMP) && CLEARCOAT_BUMPDIRECTUV == 0
6373varying vec2 vClearCoatBumpUV;
6374#endif
6375#if defined(CLEARCOAT_TINT_TEXTURE) && CLEARCOAT_TINT_TEXTUREDIRECTUV == 0
6376varying vec2 vClearCoatTintUV;
6377#endif
6378#endif
6379#ifdef SHEEN
6380#if defined(SHEEN_TEXTURE) && SHEEN_TEXTUREDIRECTUV == 0
6381varying vec2 vSheenUV;
6382#endif
6383#if defined(SHEEN_TEXTURE_ROUGHNESS) && SHEEN_TEXTURE_ROUGHNESSDIRECTUV == 0
6384varying vec2 vSheenRoughnessUV;
6385#endif
6386#endif
6387#ifdef ANISOTROPIC
6388#if defined(ANISOTROPIC_TEXTURE) && ANISOTROPIC_TEXTUREDIRECTUV == 0
6389varying vec2 vAnisotropyUV;
6390#endif
6391#endif
6392#ifdef SUBSURFACE
6393#if defined(SS_THICKNESSANDMASK_TEXTURE) && SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 0
6394varying vec2 vThicknessUV;
6395#endif
6396#endif
6397
6398varying vec3 vPositionW;
6399#if DEBUGMODE>0
6400varying vec4 vClipSpacePosition;
6401#endif
6402#ifdef NORMAL
6403varying vec3 vNormalW;
6404#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
6405varying vec3 vEnvironmentIrradiance;
6406#include<harmonicsFunctions>
6407#endif
6408#endif
6409#ifdef VERTEXCOLOR
6410varying vec4 vColor;
6411#endif
6412#include<bumpVertexDeclaration>
6413#include<clipPlaneVertexDeclaration>
6414#include<fogVertexDeclaration>
6415#include<__decl__lightFragment>[0..maxSimultaneousLights]
6416#include<morphTargetsVertexGlobalDeclaration>
6417#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
6418#ifdef REFLECTIONMAP_SKYBOX
6419varying vec3 vPositionUVW;
6420#endif
6421#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
6422varying vec3 vDirectionW;
6423#endif
6424#include<logDepthDeclaration>
6425#define CUSTOM_VERTEX_DEFINITIONS
6426void main(void) {
6427#define CUSTOM_VERTEX_MAIN_BEGIN
6428vec3 positionUpdated=position;
6429#ifdef NORMAL
6430vec3 normalUpdated=normal;
6431#endif
6432#ifdef TANGENT
6433vec4 tangentUpdated=tangent;
6434#endif
6435#ifdef UV1
6436vec2 uvUpdated=uv;
6437#endif
6438#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
6439#ifdef REFLECTIONMAP_SKYBOX
6440vPositionUVW=positionUpdated;
6441#endif
6442#define CUSTOM_VERTEX_UPDATE_POSITION
6443#define CUSTOM_VERTEX_UPDATE_NORMAL
6444#include<instancesVertex>
6445#if defined(PREPASS) && defined(PREPASS_VELOCITY) && !defined(BONES_VELOCITY_ENABLED)
6446
6447vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,
64471.0);
6448vPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0);
6449#endif
6450#include<bonesVertex>
6451vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);
6452vPositionW=vec3(worldPos);
6453#include<prePassVertex>
6454#ifdef NORMAL
6455mat3 normalWorld=mat3(finalWorld);
6456#if defined(INSTANCES) && defined(THIN_INSTANCES)
6457vNormalW=normalUpdated/vec3(dot(normalWorld[0],normalWorld[0]),dot(normalWorld[1],normalWorld[1]),dot(normalWorld[2],normalWorld[2]));
6458vNormalW=normalize(normalWorld*vNormalW);
6459#else
6460#ifdef NONUNIFORMSCALING
6461normalWorld=transposeMat3(inverseMat3(normalWorld));
6462#endif
6463vNormalW=normalize(normalWorld*normalUpdated);
6464#endif
6465#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
6466vec3 reflectionVector=vec3(reflectionMatrix*vec4(vNormalW,0)).xyz;
6467#ifdef REFLECTIONMAP_OPPOSITEZ
6468reflectionVector.z*=-1.0;
6469#endif
6470vEnvironmentIrradiance=computeEnvironmentIrradiance(reflectionVector);
6471#endif
6472#endif
6473#define CUSTOM_VERTEX_UPDATE_WORLDPOS
6474#ifdef MULTIVIEW
6475if (gl_ViewID_OVR == 0u) {
6476gl_Position=viewProjection*worldPos;
6477} else {
6478gl_Position=viewProjectionR*worldPos;
6479}
6480#else
6481gl_Position=viewProjection*worldPos;
6482#endif
6483#if DEBUGMODE>0
6484vClipSpacePosition=gl_Position;
6485#endif
6486#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
6487vDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));
6488#endif
6489
6490#ifndef UV1
6491vec2 uvUpdated=vec2(0.,0.);
6492#endif
6493#ifndef UV2
6494vec2 uv2=vec2(0.,0.);
6495#endif
6496#ifdef MAINUV1
6497vMainUV1=uvUpdated;
6498#endif
6499#ifdef MAINUV2
6500vMainUV2=uv2;
6501#endif
6502#if defined(ALBEDO) && ALBEDODIRECTUV == 0
6503if (vAlbedoInfos.x == 0.)
6504{
6505vAlbedoUV=vec2(albedoMatrix*vec4(uvUpdated,1.0,0.0));
6506}
6507else
6508{
6509vAlbedoUV=vec2(albedoMatrix*vec4(uv2,1.0,0.0));
6510}
6511#endif
6512#if defined(DETAIL) && DETAILDIRECTUV == 0
6513if (vDetailInfos.x == 0.)
6514{
6515vDetailUV=vec2(detailMatrix*vec4(uvUpdated,1.0,0.0));
6516}
6517else
6518{
6519vDetailUV=vec2(detailMatrix*vec4(uv2,1.0,0.0));
6520}
6521#endif
6522#if defined(AMBIENT) && AMBIENTDIRECTUV == 0
6523if (vAmbientInfos.x == 0.)
6524{
6525vAmbientUV=vec2(ambientMatrix*vec4(uvUpdated,1.0,0.0));
6526}
6527else
6528{
6529vAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));
6530}
6531#endif
6532#if defined(OPACITY) && OPACITYDIRECTUV == 0
6533if (vOpacityInfos.x == 0.)
6534{
6535vOpacityUV=vec2(opacityMatrix*vec4(uvUpdated,1.0,0.0));
6536}
6537else
6538{
6539vOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));
6540}
6541#endif
6542#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0
6543if (vEmissiveInfos.x == 0.)
6544{
6545vEmissiveUV=vec2(emissiveMatrix*vec4(uvUpdated,1.0,0.0));
6546}
6547else
6548{
6549vEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));
6550}
6551#endif
6552#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0
6553if (vLightmapInfos.x == 0.)
6554{
6555vLightmapUV=vec2(lightmapMatrix*vec4(uvUpdated,1.0,0.0));
6556}
6557else
6558{
6559vLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));
6560}
6561#endif
6562#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0
6563if (vReflectivityInfos.x == 0.)
6564{
6565vReflectivityUV=vec2(reflectivityMatrix*vec4(uvUpdated,1.0,0.0));
6566}
6567else
6568{
6569vReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));
6570}
6571#endif
6572#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0
6573if (vMicroSurfaceSamplerInfos.x == 0.)
6574{
6575vMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uvUpdated,1.0,0.0));
6576}
6577else
6578{
6579vMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv2,1.0,0.0));
6580}
6581#endif
6582#if defined(METALLIC_REFLECTANCE) && METALLIC_REFLECTANCEDIRECTUV == 0
6583if (vMetallicReflectanceInfos.x == 0.)
6584{
6585vMetallicReflectanceUV=vec2(metallicReflectanceMatrix*vec4(uvUpdated,1.0,0.0));
6586}
6587else
6588{
6589vMetallicReflectanceUV=vec2(metallicReflectanceMatrix*vec4(uv2,1.0,0.0));
6590}
6591#endif
6592#if defined(BUMP) && BUMPDIRECTUV == 0
6593if (vBumpInfos.x == 0.)
6594{
6595vBumpUV=vec2(bumpMatrix*vec4(uvUpdated,1.0,0.0));
6596}
6597else
6598{
6599vBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));
6600}
6601#endif
6602#ifdef CLEARCOAT
6603#if defined(CLEARCOAT_TEXTURE) && CLEARCOAT_TEXTUREDIRECTUV == 0
6604if (vClearCoatInfos.x == 0.)
6605{
6606vClearCoatUV=vec2(clearCoatMatrix*vec4(uvUpdated,1.0,0.0));
6607}
6608else
6609{
6610vClearCoatUV=vec2(clearCoatMatrix*vec4(uv2,1.0,0.0));
6611}
6612#endif
6613#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV == 0
6614if (vClearCoatInfos.z == 0.)
6615{
6616vClearCoatRoughnessUV=vec2(clearCoatRoughnessMatrix*vec4(uvUpdated,1.0,0.0));
6617}
6618else
6619{
6620vClearCoatRoughnessUV=vec2(clearCoatRoughnessMatrix*vec4(uv2,1.0,0.0
6620));
6621}
6622#endif
6623#if defined(CLEARCOAT_BUMP) && CLEARCOAT_BUMPDIRECTUV == 0
6624if (vClearCoatBumpInfos.x == 0.)
6625{
6626vClearCoatBumpUV=vec2(clearCoatBumpMatrix*vec4(uvUpdated,1.0,0.0));
6627}
6628else
6629{
6630vClearCoatBumpUV=vec2(clearCoatBumpMatrix*vec4(uv2,1.0,0.0));
6631}
6632#endif
6633#if defined(CLEARCOAT_TINT_TEXTURE) && CLEARCOAT_TINT_TEXTUREDIRECTUV == 0
6634if (vClearCoatTintInfos.x == 0.)
6635{
6636vClearCoatTintUV=vec2(clearCoatTintMatrix*vec4(uvUpdated,1.0,0.0));
6637}
6638else
6639{
6640vClearCoatTintUV=vec2(clearCoatTintMatrix*vec4(uv2,1.0,0.0));
6641}
6642#endif
6643#endif
6644#ifdef SHEEN
6645#if defined(SHEEN_TEXTURE) && SHEEN_TEXTUREDIRECTUV == 0
6646if (vSheenInfos.x == 0.)
6647{
6648vSheenUV=vec2(sheenMatrix*vec4(uvUpdated,1.0,0.0));
6649}
6650else
6651{
6652vSheenUV=vec2(sheenMatrix*vec4(uv2,1.0,0.0));
6653}
6654#endif
6655#if defined(SHEEN_TEXTURE_ROUGHNESS) && SHEEN_TEXTURE_ROUGHNESSDIRECTUV == 0
6656if (vSheenInfos.z == 0.)
6657{
6658vSheenRoughnessUV=vec2(sheenRoughnessMatrix*vec4(uvUpdated,1.0,0.0));
6659}
6660else
6661{
6662vSheenRoughnessUV=vec2(sheenRoughnessMatrix*vec4(uv2,1.0,0.0));
6663}
6664#endif
6665#endif
6666#ifdef ANISOTROPIC
6667#if defined(ANISOTROPIC_TEXTURE) && ANISOTROPIC_TEXTUREDIRECTUV == 0
6668if (vAnisotropyInfos.x == 0.)
6669{
6670vAnisotropyUV=vec2(anisotropyMatrix*vec4(uvUpdated,1.0,0.0));
6671}
6672else
6673{
6674vAnisotropyUV=vec2(anisotropyMatrix*vec4(uv2,1.0,0.0));
6675}
6676#endif
6677#endif
6678#ifdef SUBSURFACE
6679#if defined(SS_THICKNESSANDMASK_TEXTURE) && SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 0
6680if (vThicknessInfos.x == 0.)
6681{
6682vThicknessUV=vec2(thicknessMatrix*vec4(uvUpdated,1.0,0.0));
6683}
6684else
6685{
6686vThicknessUV=vec2(thicknessMatrix*vec4(uv2,1.0,0.0));
6687}
6688#endif
6689#endif
6690
6691#include<bumpVertex>
6692
6693#include<clipPlaneVertex>
6694
6695#include<fogVertex>
6696
6697#include<shadowsVertex>[0..maxSimultaneousLights]
6698
6699#ifdef VERTEXCOLOR
6700vColor=color;
6701#endif
6702
6703#ifdef POINTSIZE
6704gl_PointSize=pointSize;
6705#endif
6706
6707#include<logDepthVertex>
6708#define CUSTOM_VERTEX_MAIN_END
6709}`;je.a.ShadersStore.pbrVertexShader=L_;var ra=f(92),Pr={effect:null,subMesh:null},ks=function(r){function t(){var e=r.call(this)||this;return e.PBR=!0,e.NUM_SAMPLES="0",e.REALTIME_FILTERING=!1,e.MAINUV1=!1,e.MAINUV2=!1,e.UV1=!1,e.UV2=!1,e.ALBEDO=!1,e.GAMMAALBEDO=!1,e.ALBEDODIRECTUV=0,e.VERTEXCOLOR=!1,e.DETAIL=!1,e.DETAILDIRECTUV=0,e.DETAIL_NORMALBLENDMETHOD=0,e.AMBIENT=!1,e.AMBIENTDIRECTUV=0,e.AMBIENTINGRAYSCALE=!1,e.OPACITY=!1,e.VERTEXALPHA=!1,e.OPACITYDIRECTUV=0,e.OPACITYRGB=!1,e.ALPHATEST=!1,e.DEPTHPREPASS=!1,e.ALPHABLEND=!1,e.ALPHAFROMALBEDO=!1,e.ALPHATESTVALUE="0.5",e.SPECULAROVERALPHA=!1,e.RADIANCEOVERALPHA=!1,e.ALPHAFRESNEL=!1,e.LINEARALPHAFRESNEL=!1,e.PREMULTIPLYALPHA=!1,e.EMISSIVE=!1,e.EMISSIVEDIRECTUV=0,e.REFLECTIVITY=!1,e.REFLECTIVITYDIRECTUV=0,e.SPECULARTERM=!1,e.MICROSURFACEFROMREFLECTIVITYMAP=!1,e.MICROSURFACEAUTOMATIC=!1,e.LODBASEDMICROSFURACE=!1,e.MICROSURFACEMAP=!1,e.MICROSURFACEMAPDIRECTUV=0,e.METALLICWORKFLOW=!1,e.ROUGHNESSSTOREINMETALMAPALPHA=!1,e.ROUGHNESSSTOREINMETALMAPGREEN=!1,e.METALLNESSSTOREINMETALMAPBLUE=!1,e.AOSTOREINMETALMAPRED=!1,e.METALLIC_REFLECTANCE=!1,e.METALLIC_REFLECTANCEDIRECTUV=0,e.ENVIRONMENTBRDF=!1,e.ENVIRONMENTBRDF_RGBD=!1,e.NORMAL=!1,e.TANGENT=!1,e.BUMP=!1,e.BUMPDIRECTUV=0,e.OBJECTSPACE_NORMALMAP=!1,e.PARALLAX=!1,e.PARALLAXOCCLUSION=!1,e.NORMALXYSCALE=!0,e.LIGHTMAP=!1,e.LIGHTMAPDIRECTUV=0,e.USELIGHTMAPASSHADOWMAP=!1,e.GAMMALIGHTMAP=!1,e.RGBDLIGHTMAP=!1,e.REFLECTION=!1,e.REFLECTIONMAP_3D=!1,e.REFLECTIONMAP_SPHERICAL=!1,e.REFLECTIONMAP_PLANAR=!1,e.REFLECTIONMAP_CUBIC=!1,e.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,e.REFLECTIONMAP_PROJECTION=!1,e.REFLECTIONMAP_SKYBOX=!1,e.REFLECTIONMAP_EXPLICIT=!1,e.REFLECTIONMAP_EQUIRECTANGULAR=!1,e.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,e.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,e.INVERTCUBICMAP=!1,e.USESPHERICALFROMREFLECTIONMAP=!1,e.USEIRRADIANCEMAP=!1,e.SPHERICAL_HARMONICS=!1,e.USESPHERICALINVERTEX=!1,e.REFLECTIONMAP_OPPOSITEZ=!1,e.LODINREFLECTIONALPHA=!1,e.GAMMAREFLECTION=!1,e.RGBDREFLECTION=!1,e.LINEARSPECULARREFLECTION=!1,e.RADIANCEOCCLUSION=!1,e.HORIZONOCCLUSION=!1,e.INSTANCES=!1,e.THIN_INSTANCES=!1,e.PREPASS=!1,e.PREPASS_IRRADIANCE=!1,e.PREPASS_IRRADIANCE_INDEX=-1,e.PREPASS_ALBEDO=!1,e.PREPASS_ALBEDO_INDEX=-1,e.PREPASS_DEPTHNORMAL=!1,e.PREPASS_DEPTHNORMAL_INDEX=-1,e.PREPASS_POSITION=!1,e.PREPASS_POSITION_INDEX=-1,e.PREPASS_VELOCITY=!1,e.PREPASS_VELOCITY_INDEX=-1,e.PREPASS_REFLECTIVITY=!1,e.PREPASS_REFLECTIVITY_INDEX=-1,e.SCENE_MRT_COUNT=0,e.NUM_BONE_INFLUENCERS=0,e.BonesPerMesh=0,e.BONETEXTURE=!1,e.BONES_VELOCITY_ENABLED=!1,e.NONUNIFORMSCALING=!1,e.MORPHTARGETS=!1,e.MORPHTARGETS_NORMAL=!1,e.MORPHTARGETS_TANGENT=!1,e.MORPHTARGETS_
6709UV=!1,e.NUM_MORPH_INFLUENCERS=0,e.IMAGEPROCESSING=!1,e.VIGNETTE=!1,e.VIGNETTEBLENDMODEMULTIPLY=!1,e.VIGNETTEBLENDMODEOPAQUE=!1,e.TONEMAPPING=!1,e.TONEMAPPING_ACES=!1,e.CONTRAST=!1,e.COLORCURVES=!1,e.COLORGRADING=!1,e.COLORGRADING3D=!1,e.SAMPLER3DGREENDEPTH=!1,e.SAMPLER3DBGRMAP=!1,e.IMAGEPROCESSINGPOSTPROCESS=!1,e.EXPOSURE=!1,e.MULTIVIEW=!1,e.USEPHYSICALLIGHTFALLOFF=!1,e.USEGLTFLIGHTFALLOFF=!1,e.TWOSIDEDLIGHTING=!1,e.SHADOWFLOAT=!1,e.CLIPPLANE=!1,e.CLIPPLANE2=!1,e.CLIPPLANE3=!1,e.CLIPPLANE4=!1,e.CLIPPLANE5=!1,e.CLIPPLANE6=!1,e.POINTSIZE=!1,e.FOG=!1,e.LOGARITHMICDEPTH=!1,e.FORCENORMALFORWARD=!1,e.SPECULARAA=!1,e.CLEARCOAT=!1,e.CLEARCOAT_DEFAULTIOR=!1,e.CLEARCOAT_TEXTURE=!1,e.CLEARCOAT_TEXTURE_ROUGHNESS=!1,e.CLEARCOAT_TEXTUREDIRECTUV=0,e.CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV=0,e.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE=!1,e.CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL=!1,e.CLEARCOAT_BUMP=!1,e.CLEARCOAT_BUMPDIRECTUV=0,e.CLEARCOAT_REMAP_F0=!0,e.CLEARCOAT_TINT=!1,e.CLEARCOAT_TINT_TEXTURE=!1,e.CLEARCOAT_TINT_TEXTUREDIRECTUV=0,e.ANISOTROPIC=!1,e.ANISOTROPIC_TEXTURE=!1,e.ANISOTROPIC_TEXTUREDIRECTUV=0,e.BRDF_V_HEIGHT_CORRELATED=!1,e.MS_BRDF_ENERGY_CONSERVATION=!1,e.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION=!1,e.SHEEN=!1,e.SHEEN_TEXTURE=!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.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL=!1,e.SUBSURFACE=!1,e.SS_REFRACTION=!1,e.SS_TRANSLUCENCY=!1,e.SS_SCATTERING=!1,e.SS_THICKNESSANDMASK_TEXTURE=!1,e.SS_THICKNESSANDMASK_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_MASK_FROM_THICKNESS_TEXTURE=!1,e.SS_MASK_FROM_THICKNESS_TEXTURE_GLTF=!1,e.UNLIT=!1,e.DEBUGMODE=0,e.rebuild(),e}return Object(c.d)(t,r),t.prototype.reset=function(){r.prototype.reset.call(this),this.ALPHATESTVALUE="0.5",this.PBR=!0},t}(ta.a),pn=function(r){function t(e,n){var i=r.call(this,e,n)||this;return i._directIntensity=1,i._emissiveIntensity=1,i._environmentIntensity=1,i._specularIntensity=1,i._lightingInfos=new u.f(i._directIntensity,i._emissiveIntensity,i._environmentIntensity,i._specularIntensity),i._disableBumpMap=!1,i._albedoTexture=null,i._ambientTexture=null,i._ambientTextureStrength=1,i._ambientTextureImpactOnAnalyticalLights=t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,i._opacityTexture=null,i._reflectionTexture=null,i._emissiveTexture=null,i._reflectivityTexture=null,i._metallicTexture=null,i._metallic=null,i._roughness=null,i._metallicF0Factor=1,i._metallicReflectanceColor=M.a.White(),i._metallicReflectanceTexture=null,i._microSurfaceTexture=null,i._bumpTexture=null,i._lightmapTexture=null,i._ambientColor=new M.a(0,0,0),i._albedoColor=new M.a(1,1,1),i._reflectivityColor=new M.a(1,1,1),i._reflectionColor=new M.a(1,1,1),i._emissiveColor=new M.a(0,0,0),i._microSurface=.9,i._useLightmapAsShadowmap=!1,i._useHorizonOcclusion=!0,i._useRadianceOcclusion=!0,i._useAlphaFromAlbedoTexture=!1,i._useSpecularOverAlpha=!0,i._useMicroSurfaceFromReflectivityMapAlpha=!1,i._useRoughnessFromMetallicTextureAlpha=!0,i._useRoughnessFromMetallicTextureGreen=!1,i._useMetallnessFromMetallicTextureBlue=!1,i._useAmbientOcclusionFromMetallicTextureRed=!1,i._useAmbientInGrayScale=!1,i._useAutoMicroSurfaceFromReflectivityMap=!1,i._lightFalloff=t.LIGHTFALLOFF_PHYSICAL,i._useRadianceOverAlpha=!0,i._useObjectSpaceNormalMap=!1,i._useParallax=!1,i._useParallaxOcclusion=!1,i._parallaxScaleBias=.05,i._disableLighting=!1,i._maxSimultaneousLights=4,i._invertNormalMapX=!1,i._invertNormalMapY=!1,i._twoSidedLighting=!1,i._alph
6709aCutOff=.4,i._forceAlphaTest=!1,i._useAlphaFresnel=!1,i._useLinearAlphaFresnel=!1,i._environmentBRDFTexture=null,i._forceIrradianceInFragment=!1,i._realTimeFiltering=!1,i._realTimeFilteringQuality=h.a.TEXTURE_FILTERING_QUALITY_LOW,i._forceNormalForward=!1,i._enableSpecularAntiAliasing=!1,i._imageProcessingObserver=null,i._renderTargets=new li.a(16),i._globalAmbientColor=new M.a(0,0,0),i._useLogarithmicDepth=!1,i._unlit=!1,i._debugMode=0,i.debugMode=0,i.debugLimit=-1,i.debugFactor=1,i.clearCoat=new Sr(i._markAllSubMeshesAsTexturesDirty.bind(i)),i.anisotropy=new Ar(i._markAllSubMeshesAsTexturesDirty.bind(i)),i.brdf=new qp(i._markAllSubMeshesAsMiscDirty.bind(i)),i.sheen=new so(i._markAllSubMeshesAsTexturesDirty.bind(i)),i.detailMap=new ra.a(i._markAllSubMeshesAsTexturesDirty.bind(i)),i._rebuildInParallel=!1,i._attachImageProcessingConfiguration(null),i.getRenderTargetTextures=function(){return i._renderTargets.reset(),ht.a.ReflectionTextureEnabled&&i._reflectionTexture&&i._reflectionTexture.isRenderTarget&&i._renderTargets.push(i._reflectionTexture),i.subSurface.fillRenderTargetTextures(i._renderTargets),i._renderTargets},i._environmentBRDFTexture=ia.GetEnvironmentBRDFTexture(n),i.subSurface=new co(i._markAllSubMeshesAsTexturesDirty.bind(i),i._markScenePrePassDirty.bind(i),n),i.prePassConfiguration=new Vs.a,i}return Object(c.d)(t,r),Object.defineProperty(t.prototype,"realTimeFiltering",{get:function(){return this._realTimeFiltering},set:function(e){this._realTimeFiltering=e,this.markAsDirty(h.a.MATERIAL_TextureDirtyFlag)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"realTimeFilteringQuality",{get:function(){return this._realTimeFilteringQuality},set:function(e){this._realTimeFilteringQuality=e,this.markAsDirty(h.a.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.get
6709Scene().imageProcessingConfiguration,this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add(function(){n._markAllSubMeshesAsImageProcessingDirty()})))},Object.defineProperty(t.prototype,"hasRenderTargetTextures",{get:function(){return!!(ht.a.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget)||this.subSurface.hasRenderTargetTextures()},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"PBRBaseMaterial"},Object.defineProperty(t.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(e){this._useLogarithmicDepth=e&&this.getScene().getEngine().getCaps().fragmentDepthSupported},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_disableAlphaBlending",{get:function(){return this.subSurface.disableAlphaBlending||this._transparencyMode===t.PBRMATERIAL_OPAQUE||this._transparencyMode===t.PBRMATERIAL_ALPHATEST},enumerable:!1,configurable:!0}),t.prototype.needAlphaBlending=function(){return!this._disableAlphaBlending&&(this.alpha<1||this._opacityTexture!=null||this._shouldUseAlphaFromAlbedoTexture())},t.prototype.needAlphaTesting=function(){return!!this._forceAlphaTest||!this.subSurface.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){if(n.effect&&this.isFrozen&&n.effect._wasPreviouslyReady)return!0;n._materialDefines||(n._materialDefines=new ks);var o=n._materialDefines;if(this._isReadyForSubMesh(n))return!0;var a=this.getScene(),s=a.getEngine();if(o._areTexturesDirty&&a.texturesEnabled){if(this._albedoTexture&&ht.a.DiffuseTextureEnabled&&!this._albedoTexture.isReadyOrNotBlocking()||this._ambientTexture&&ht.a.AmbientTextureEnabled&&!this._ambientTexture.isReadyOrNotBlocking()||this._opacityTexture&&ht.a.OpacityTextureEnabled&&!this._opacityTexture.isReadyOrNotBlocking())return!1;var d=this._getReflectionTexture();if(d&&ht.a.ReflectionTextureEnabled&&(!d.isReadyOrNotBlocking()||d.irradianceTexture&&!d.irradianceTexture.isReadyOrNotBlocking())||this._lightmapTexture&&ht.a.LightmapTextureEnabled&&!this._lightmapTexture.isReadyOrNotBlocking()||this._emissiveTexture&&ht.a.EmissiveTextureEnabled&&!this._emissiveTexture.isReadyOrNotBlocking())return!1;if(ht.a.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._microSurfaceTexture&&!this._microSurfaceTexture.isReadyOrNotBlocking())return!1}if(s.getCaps().standardDerivatives&&this._bumpTexture&&ht.a.BumpTextureEnabled&&!this._disableBumpMap&&!this._bumpTexture.isReady()||this._environmentBRDFTexture&&ht.a.ReflectionTextureEnabled&&!this._environmentBRDFTexture.isReady())return!1}if(!(this.subSurface.isReadyForSubMesh(o,a)&&this.clearCoat.isReadyForSubMesh(o,a,s,this._disableBumpMap)&&this.sheen.isReadyForSubMesh(o,a)&&this.anisotropy.isReadyForSubMesh(o,a)&&this.detailMap.isReadyForSubMesh(o,a))||o._areImageProcessingDirty&&this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.isReady())return!1;s.getCaps().standardDerivatives||e.isVerticesDataPresent(Me.b.NormalKind)||(e.createNormals(!0),l.a.Warn("PBRMaterial: Normals have been created for the mesh: "+e.name));var p=n.effect,y=o._areLightsDisposed,P=this._prepareEffect(e,o,this.onCompiled,this.onError,i,null,n.getRenderingMesh().hasThinInstances);if(P)if(this._onEffectCreatedObservable&&(Pr.effect=P,Pr.subMesh=n,this._onEffectCreatedObservable.notifyObservers(Pr)),this.allowShaderHotSwapping&&p&&!P.isReady()){if
6709(P=p,this._rebuildInParallel=!0,o.markAsUnprocessed(),y)return o._areLightsDisposed=!0,!1}else this._rebuildInParallel=!1,a.resetCachedMaterial(),n.setEffect(P,o),this.buildUniformLayout();return!(!n.effect||!n.effect.isReady())&&(o._renderId=a.getRenderId(),n.effect._wasPreviouslyReady=!0,!0)},t.prototype.isMetallicWorkflow=function(){return!(this._metallic==null&&this._roughness==null&&!this._metallicTexture)},t.prototype._prepareEffect=function(e,n,i,o,a,s,d){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,d),!n.isDirty)return null;n.markAsProcessed();var p=this.getScene().getEngine(),y=new Er.a,P=0;n.USESPHERICALINVERTEX&&y.addFallback(P++,"USESPHERICALINVERTEX"),n.FOG&&y.addFallback(P,"FOG"),n.SPECULARAA&&y.addFallback(P,"SPECULARAA"),n.POINTSIZE&&y.addFallback(P,"POINTSIZE"),n.LOGARITHMICDEPTH&&y.addFallback(P,"LOGARITHMICDEPTH"),n.PARALLAX&&y.addFallback(P,"PARALLAX"),n.PARALLAXOCCLUSION&&y.addFallback(P++,"PARALLAXOCCLUSION"),P=Ar.AddFallbacks(n,y,P),P=Ar.AddFallbacks(n,y,P),P=co.AddFallbacks(n,y,P),P=so.AddFallbacks(n,y,P),n.ENVIRONMENTBRDF&&y.addFallback(P++,"ENVIRONMENTBRDF"),n.TANGENT&&y.addFallback(P++,"TANGENT"),n.BUMP&&y.addFallback(P++,"BUMP"),P=tt.a.HandleFallbacksForShadows(n,y,this._maxSimultaneousLights,P++),n.SPECULARTERM&&y.addFallback(P++,"SPECULARTERM"),n.USESPHERICALFROMREFLECTIONMAP&&y.addFallback(P++,"USESPHERICALFROMREFLECTIONMAP"),n.USEIRRADIANCEMAP&&y.addFallback(P++,"USEIRRADIANCEMAP"),n.LIGHTMAP&&y.addFallback(P++,"LIGHTMAP"),n.NORMAL&&y.addFallback(P++,"NORMAL"),n.AMBIENT&&y.addFallback(P++,"AMBIENT"),n.EMISSIVE&&y.addFallback(P++,"EMISSIVE"),n.VERTEXCOLOR&&y.addFallback(P++,"VERTEXCOLOR"),n.MORPHTARGETS&&y.addFallback(P++,"MORPHTARGETS"),n.MULTIVIEW&&y.addFallback(0,"MULTIVIEW");var O=[Me.b.PositionKind];n.NORMAL&&O.push(Me.b.NormalKind),n.TANGENT&&O.push(Me.b.TangentKind),n.UV1&&O.push(Me.b.UVKind),n.UV2&&O.push(Me.b.UV2Kind),n.VERTEXCOLOR&&O.push(Me.b.ColorKind),tt.a.PrepareAttributesForBones(O,e,n,y),tt.a.PrepareAttributesForInstances(O,n),tt.a.PrepareAttributesForMorphTargets(O,e,n);var U="pbr",F=["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","vMicroSurfaceSamplerInfos","vBumpInfos","vLightmapInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","albedoMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","reflectivityMatrix","normalMatrix","microSurfaceSamplerMatrix","bumpMatrix","lightmapMatrix","metallicReflectanceMatrix","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"],z=["albedoSampler","reflectivitySampler","ambientSampler","emissiveSampler","bumpSampler","lightmapSampler","opacitySampler","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh","irradianceSampler","microSurfaceSampler","environmentBrdfSampler","boneSampler","metallicReflectanceSampler"],J=["Material","Scene"];ra.a.AddUniforms(F),ra.a.AddSamplers(z),co.AddUniforms(F),co.AddSamplers(z),Sr.AddUniforms(F),Sr.AddSamplers(z),Ar.AddUniforms(F),Ar.AddSamplers(z),so.AddUniforms(F),so.AddSamplers(z),Vs.a.AddUniforms(F),Vs.a.AddSamplers(F),vn.a&&(vn.a.PrepareUniforms(F,n),vn.a.PrepareSamplers(z,n)),tt.a.PrepareUniformsAndSamplersList({uniformsNames:F,uniformBuffersNames:J,samplers:z,defines:n,maxSimultaneousLights:this._maxSimultaneousLights});var ie={};this.customShaderNameResolve&&(U=this.customShaderNameResolve(U,F,J,z,n,O,ie));var se=n.toString();
6709return p.createEffect(U,{attributes:O,uniformsNames:F,uniformBuffersNames:J,samplers:z,defines:se,fallbacks:y,onCompiled:i,onError:o,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:n.NUM_MORPH_INFLUENCERS},processFinalCode:ie.processFinalCode,multiTarget:n.PREPASS},p)},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(),d=s.getEngine();if(tt.a.PrepareDefinesForLights(s,e,n,!0,this._maxSimultaneousLights,this._disableLighting),n._needNormals=!0,tt.a.PrepareDefinesForMultiview(s,n),tt.a.PrepareDefinesForPrePass(s,n,this.canRenderToMRT),n.METALLICWORKFLOW=this.isMetallicWorkflow(),n._areTexturesDirty){if(n._needUVs=!1,s.texturesEnabled){s.getEngine().getCaps().textureLOD&&(n.LODBASEDMICROSFURACE=!0),this._albedoTexture&&ht.a.DiffuseTextureEnabled?(tt.a.PrepareDefinesForMergedUV(this._albedoTexture,n,"ALBEDO"),n.GAMMAALBEDO=this._albedoTexture.gammaSpace):n.ALBEDO=!1,this._ambientTexture&&ht.a.AmbientTextureEnabled?(tt.a.PrepareDefinesForMergedUV(this._ambientTexture,n,"AMBIENT"),n.AMBIENTINGRAYSCALE=this._useAmbientInGrayScale):n.AMBIENT=!1,this._opacityTexture&&ht.a.OpacityTextureEnabled?(tt.a.PrepareDefinesForMergedUV(this._opacityTexture,n,"OPACITY"),n.OPACITYRGB=this._opacityTexture.getAlphaFromRGB):n.OPACITY=!1;var p=this._getReflectionTexture();if(p&&ht.a.ReflectionTextureEnabled){switch(n.REFLECTION=!0,n.GAMMAREFLECTION=p.gammaSpace,n.RGBDREFLECTION=p.isRGBD,n.REFLECTIONMAP_OPPOSITEZ=this.getScene().useRightHandedSystem?!p.invertZ:p.invertZ,n.LODINREFLECTIONALPHA=p.lodLevelInAlpha,n.LINEARSPECULARREFLECTION=p.linearSpecularLOD,this.realTimeFiltering&&this.realTimeFilteringQuality>0?(n.NUM_SAMPLES=""+this.realTimeFilteringQuality,d.webGLVersion>1&&(n.NUM_SAMPLES=n.NUM_SAMPLES+"u"),n.REALTIME_FILTERING=!0):n.REALTIME_FILTERING=!1,p.coordinatesMode===we.a.INVCUBIC_MODE&&(n.INVERTCUBICMAP=!0),n.REFLECTIONMAP_3D=p.isCube,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,p.coordinatesMode){case we.a.EXPLICIT_MODE:n.REFLECTIONMAP_EXPLICIT=!0;break;case we.a.PLANAR_MODE:n.REFLECTIONMAP_PLANAR=!0;break;case we.a.PROJECTION_MODE:n.REFLECTIONMAP_PROJECTION=!0;break;case we.a.SKYBOX_MODE:n.REFLECTIONMAP_SKYBOX=!0;break;case we.a.SPHERICAL_MODE:n.REFLECTIONMAP_SPHERICAL=!0;break;case we.a.EQUIRECTANGULAR_MODE:n.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case we.a.FIXED_EQUIRECTANGULAR_MODE:n.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case we.a.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:n.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0;break;case we.a.CUBIC_MODE:case we.a.INVCUBIC_MODE:default:n.REFLECTIONMAP_CUBIC=!0,n.USE_LOCAL_REFLECTIONMAP_CUBIC=!!p.boundingBoxSize}p.coordinatesMode!==we.a.SKYBOX_MODE&&(p.irradianceTexture?(n.USEIRRADIANCEMAP=!0,n.USESPHERICALFROMREFLECTIONMAP=!1):p.isCube&&(n.USESPHERICALFROMREFLECTIONMAP=!0,n.USEIRRADIANCEMAP=!1,this._forceIrradianceInFragment||this.realTimeFiltering||s.getEngine().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&&ht.a.LightmapTextureEnabled?(tt.a.PrepareDefinesForMergedUV(this._lightmapTexture,n,"LIGHTMAP"),n.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap,n.GAMMALIGHTMAP=this._lightmapTexture.gammaSpace,n.RGBDLIGHTMAP=this._lightmapTexture.isRGBD):n.LIGHTMAP=!1,this._emissiveTexture&&ht.a.EmissiveTextureEnabled?tt.a.PrepareDefinesForMergedUV(this._emissiveTexture,n,"EMISSIVE"):n.EMISSIVE=!1,ht.a.SpecularTextureEnabled?(this._metallicTexture?(tt.a.PrepareDefinesForMergedUV(this._metallicTexture,n,"REFLECTIVITY"),n.ROUGHNESSSTOREINMETALMAPALPHA=this._useRoughnessFromMetallicTextureAlpha,n.ROUGHNESSSTOREINMETALMAPGREEN=!this._useRoughnessFromMetallicTextureAlpha&&this._useRoughnessFromMetallicTextureGreen,n.METALLNESSSTOREINMETALMAPBLUE=this._useMetallnessFromMetallicTextureBlue,n.AOSTOREINMETALMAPRED=this._useAmbientOcclusionFromMetallicTextureRed):this._reflectivityTexture?(tt.a.PrepareDefinesForMergedUV(this._reflectivityTexture,n,"REFLECTIVITY"),n.MICROSURFACEFROMREFLECTIVITYMAP=this._useMicroSurfaceFromReflectivityMapAlpha,n.MICROSURFACEAUTOMATIC=this._useAutoMicroSurfaceFromReflectivityMap):n.REFLECTIVITY=!1,this._metallicReflectanceTexture?tt.a.PrepareDefinesForMergedUV(this._metallicReflectanceTexture,n,"METALLIC_REFLECTANCE"):n.METALLIC_REFLECTANCE=!1,this._microSurfaceTexture?tt.a.PrepareDefinesForMergedUV(this._microSurfaceTexture,n,"MICROSURFACEMAP"):n.MICROSURFACEMAP=!1):(n.REFLECTIVITY=!1,n.MICROSURFACEMAP=!1),s.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&ht.a.BumpTextureEnabled&&!this._disableBumpMap?(tt.a.PrepareDefinesForMergedUV(this._bumpTexture,n,"BUMP"),this._useParallax&&this._albedoTexture&&ht.a.DiffuseTextureEnabled?(n.PARALLAX=!0,n.PARALLAXOCCLUSION=!!this._useParallaxOcclusion):n.PARALLAX=!1,n.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap):n.BUMP=!1,this._environmentBRDFTexture&&ht.a.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.USEPHYSICALLIGHTFA
6709LLOFF=!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=s.getEngine().getCaps().standardDerivatives&&this._enableSpecularAntiAliasing}(n._areTexturesDirty||n._areMiscDirty)&&(n.ALPHATESTVALUE=this._alphaCutOff+(this._alphaCutOff%1==0?".":""),n.PREMULTIPLYALPHA=this.alphaMode===h.a.ALPHA_PREMULTIPLIED||this.alphaMode===h.a.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&&(tt.a.PrepareDefinesForMisc(e,s,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e)||this._forceAlphaTest,n),n.UNLIT=this._unlit||(this.pointsCloud||this.wireframe)&&!e.isVerticesDataPresent(Me.b.NormalKind),n.DEBUGMODE=this._debugMode),this.detailMap.prepareDefines(n,s),this.subSurface.prepareDefines(n,s),this.clearCoat.prepareDefines(n,s),this.anisotropy.prepareDefines(n,e,s),this.brdf.prepareDefines(n),this.sheen.prepareDefines(n,s),tt.a.PrepareDefinesForFrameBoundValues(s,d,n,!!i,o,a),tt.a.PrepareDefinesForAttributes(e,n,!0,!0,!0,this._transparencyMode!==t.PBRMATERIAL_OPAQUE)},t.prototype.forceCompilation=function(e,n,i){var o=this,a=Object(c.a)({clipPlane:!1,useInstances:!1},i),s=new ks,d=this._prepareEffect(e,s,void 0,void 0,a.useInstances,a.clipPlane,e.hasThinInstances);this._onEffectCreatedObservable&&(Pr.effect=d,Pr.subMesh=null,this._onEffectCreatedObservable.notifyObservers(Pr)),d.isReady()?n&&n(this):d.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("visibility",1),e.addUniform("vMetallicReflectanceFactors",4),e.addUniform("vMetallicReflectanceInfos",2),e.addUniform("metallicReflectanceMatrix",16),Sr.PrepareUniformBuffer(e),Ar.PrepareUniformBuffer(e),so.PrepareUniformBuffer(e),co.PrepareUniformBuffer(e),ra.a.PrepareUniformBuffer(e),e.create()},t.prototype.unbind=function(){if(this._activeEffect){var e=!1;this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&(this._activeEffect.setTexture("reflection2DSampler",null),e=!0),this.subSurface.unbind(this._activeEffect)&&(e=!0),e&&this._markAllSubMeshesAsTexturesDirty()}r.prototype.unbind.call(this)},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,a.INSTANCES&&!a.THIN_INSTANCES||this.bindOnlyWorldMatrix(e),this.prePassConfiguration.bindForSubMesh(this._activeEffect,o,n,e,this.isFrozen),a.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));var d=this._mustRebind(o,s,n.visibility);tt.a.BindBonesParameters(n,this._activeEffect,this.prePassConfiguration);var p=null,y=this._uniformBuffer;if(d){var P=o.getEngine();if(y.bindToEffect(s,"Material"),this.bindViewProjection(s),p=this._getReflectionTexture(),!y.useUbo||!this.isFrozen||!y.isSync){if(o.texturesEnabled){if(this._albedoTexture&&ht.a.DiffuseTextureEnabled&&(y.updateFloat2("vAlbedoInfos",this._albedoTexture.coordinatesIndex,this._albedoTexture.level),tt.a.BindTextureMatrix(this._albedoTexture,y,"albedo")),this._ambientTexture&&ht.a.AmbientTextureEnabled&&(y.updateFloat4("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level,this._ambientTextureStrength,this._ambientTextureImpactOnAnalyticalLights),tt.a.BindTextureMatrix(this._ambientTexture,y,"ambient")),this._opacityTexture&&ht.a.OpacityTextureEnabled&&(y.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),tt.a.BindTextureMatrix(this._opacityTexture,y,"opacity")),p&&ht.a.ReflectionTextureEnabled){if(y.updateMatrix("reflectionMatrix",p.getReflectionTextureMatrix()),y.updateFloat2("vReflectionInfos",p.level,0),p.boundingBoxSize){var O=p;y.updateVector3("vReflectionPosition",O.boundingBoxPosition),y.updateVector3("vReflectionSize",O.boundingBoxSize)}if(this.realTimeFiltering){var U=p.getSize().width;y.updateFloat2("vReflectionFilteringInfo",U,$.a.Log2(U))}if(!a.USEIRRADIANCEMAP){var F=p.sphericalPolynomial;if(a.USESPHERICALFROMREFLECTIONMAP&&F)if(a.SPHERICAL_HARMONICS){var z=F.preScaledHarmonics;this._activeEffect.setVector3("vSphericalL00",z.l00),this._activeEffect.setVector3("vSphericalL1_1",z.l1_1),this._activeEffect.setVector3("vSphericalL10",z.l10),this._activeEffect.setVector3("vSphericalL11",z.l11),this._activeEffect.setVector3("vSphericalL2_2",z.l2_2),this._activeEffect.setVector3("vSphericalL2_1",z.l2_1),this._activeEffect.setVector3("vSphericalL20",z.l20),this._activeEffect.setVector3("vSphericalL21",z.l21),this._activeEffect.setVector3("vSphericalL22",z.l22)}else this._activeEffect.setFloat3("vSphericalX",F.x.x,F.x.y,F.x.z),this._activeEffect.setFloat3("vSphericalY",F.y.x,F.y.y,F.y.z),this._activeEffect.setFloat3("vSphericalZ",F.z.x,F.z.y,F.z.z),this._activeEffect.setFloat3("vSphericalXX_ZZ",F.xx.x-F.zz.x,F.xx.y-F.zz.y,F.xx.z-F.zz.z),this._activeEffect.setFloat3("vSphericalYY_ZZ",F.yy.x-F.zz.x,F.yy.y-F.zz.y,F.yy.z-F.zz.z),this._activeEffect.setFloat3("vSphericalZZ",F.zz.x,F.zz.y,F.zz.z),this._activeEffect.setFloat3("vSphericalXY",F.xy.x,F.xy.y,F.xy.z),this._activeEffect.setFloat3("vSphericalYZ",F.yz.x,F.yz.y,F.yz.z),this._activeEffect.setFloat3("vSphericalZX",F.zx.x,F.zx.y,F.zx.z)}y.updateFloat3("vReflectionMicrosurfaceInfos",p.getSize().width,p.lodGenerationScale,p.lodGenerationOffset)}this._emissiveTexture&&ht.a.EmissiveTextureEnabled&&(y.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),tt.a.BindTextureMatrix(this._emissiveTexture,y,"emissive")),this._lightmapTexture&&ht.a.LightmapTextureEnabled&&(y.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),tt.a.BindTextureMatrix(this._lightmapTexture,y,"lightmap")),ht.a.SpecularTextureEnabled&&(this._metallicTexture?(y.updateFloat3("vReflectivityInfos",this._metallicTexture.coordinatesIndex,this._metallicTexture.level,this._ambientTextureStrength),tt.a.BindTextureMatrix(this._metallicTexture,y,"reflectivity")):this._reflectivityTexture&&(y.updateFloat3("vReflectivityInfos",this._reflectivityTexture.coordinatesIndex,this._reflectivityTexture.level,1),tt.a.BindTextureMatrix(this._reflectivityTexture,y,"reflectivity")),this._metallicReflectanceTexture&&(y.updateFloat2("vMetallicReflectanceInfos",this._metallicReflectanceTexture.coordinatesIndex,this._metallicReflectanceTexture.level),tt.a.BindTextureMatrix(this._metallicReflectanceTexture,y,"metallicReflectance")),this._microSurfaceTexture&&(y.updateFloat2("vMicroSurfaceSamplerInfos",this._microSurfaceTexture.coordinatesIndex,this._microSurfaceTexture.level),tt.a.BindTextureMatrix(this._microSurfaceTexture,y,"microSurfaceSampler"))),this._bumpTexture&&P.getCaps().standardDerivatives&&ht.a.BumpTextureEnabled&&!this._disableBumpMap&&(y.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level,this._parallaxScaleBias),tt.a.BindTextureMatrix(this._bumpTexture,y,"bump"),o._mirroredCameraPosition?y.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):y.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1))}if(this.pointsCloud&&y.updateFloat("pointSize",this.pointSize),a.METALLICWORKFLOW){M.c.Color3[0].r=this._metallic===void 0||this._metallic===null?1:this._metallic,M.c.Color3[0].g=this._roughness===void 0||this._roughness===null?1:this._roughness,y.updateColor4("vReflectivityColor",M.c.Color3[0],1);var J=this.subSurface.indexOfRefraction,ie=Math.pow((J-1)/(J+1),2);this._metallicReflectanceColor.scaleToRef(ie*this._metallicF0Factor,M.c.Color3[0]);var se=this._metallicF0Factor;y.updateColor4("vMetallicReflectanceFactors",M.c.Color3[0],se)}else y.updateColor4("vReflectivityColor",this._reflectivityColor,this._microSurface);y.updateColor3("vEmissiveColor",ht.a.EmissiveTextureEnabled?this._emissiveColor:M.a.BlackReadOnly),y.updateColor3("vReflectionColor",this._reflectionColor),!a.SS_REFRACTION&&this.subSurface.linkRefractionWithTransparency?y.updateColor4("vAlbedoColor",this._albedoColor,1):y.updateColor4("vAlbedoColor",this._albedoColor,this.alpha),this._lightingInfos.x=this._directIntensity,this._lightingInfos.y=this._emissiveIntensity,this._lightingInfos.z=this._environmentIntensity*o.environmentIntensity,this._lightingInfos.w=this._specularIntensity,y.updateVector4("vLightingIntensity",this._lightingInfos)}y.updateFloat("visibility",n.visibility),o.texturesEnabled&&(this._albedoTexture&&ht.a.DiffuseTextureEnabled&&y.setTexture("albedoSampler",this._albedoTexture),this._ambientTexture&&ht.a.AmbientTextureEnabled&&y.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&ht.a.OpacityTextureEnabled&&y.setTexture("opacitySampler",this._opacityTexture),p&&ht.a.ReflectionTextureEnabled&&(a.LODBASEDMICROSFURACE?y.setTexture("reflectionSampler",p):(y.setTexture("reflectionSampler",p._lodTextureMid||p),y.setTexture("reflectionSamplerLow",p._lodTextureLow||p),y.setTexture("reflectionSamplerHigh",p._lodTextureHigh||p)),a.USEIRRADIANCEMAP&&y.setTexture("irradianceSampler",p.irradianceTexture)),a.ENVIRONMENTBRDF&&y.setTexture("environmentBrdfSampler",this._environmentBRDFTexture),this._emissiveTexture&&ht.a.EmissiveTextureEnabled&&y.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&ht.a.LightmapTextureEnabled&&y.setTexture("lightmapSampler",this._lightmapTexture),ht.a.SpecularTextureEnabled&&(this._metallicTexture?y.setTexture("reflectivitySampler",this._metallicTexture):this._reflectivityTexture&&y.setTexture("reflectivitySampler",this._reflectivityTexture),this._metallicReflectanceTexture&&y.setTexture("metallicReflectanceSampler",this._metallicReflectanceTexture),this._microSurfaceTexture&&y.setTexture("microSurfaceSampler",this._microSurfaceTexture)),this._bumpTexture&&P.getCaps().standardDerivatives&&ht.a.BumpTextureEnabled&&!this._disableBumpMap&&y.setTexture("bumpSampler",this._bumpTexture)),this.detailMap.bindForSubMesh(y,o,this.isFrozen),this.subSurface.bindForSubMesh(y,o,P,this.isFrozen,a.LODBASEDMICROSFURACE,this.realTimeFiltering),this.clearCoat.bindForSubMesh(y,o,P,this._disableBumpMap,this.isFrozen,this._invertNormalMapX,this._invertNormalMapY,i),this.anisotropy.bindForSubMesh(y,o,this.isFrozen),this.sheen.bindForSubMesh(y,o,this.isFrozen,i),tt.a.BindClipPlane(this._activeEffect,o),o.ambientColor.multiplyToRef(this._ambientColor,this._globalAmbientColor);var ce=o._forcedViewPosition?o._forcedViewPosition:o._mirroredCameraPosition?o._mirroredCameraPosition:o.activeCamera.globalPosition,ue=o.useRightHandedSystem===(o._mirroredCameraPosition!=null);s.setFloat4("vEyePosition",ce.x,ce.y,ce.z,ue?-1:1),s.setColor3("vAmbientColor",this._globalAmbientColor),s.setFloat2("vDebugMode",this.debugLimit,this.debugFactor)}!d&&this.isFrozen||(o.lightsEnabled&&!this._disableLighting&&tt.a.BindLights(o,n,this._activeEffect,a,this._maxSimultaneousLights,this._rebuildInParallel),(o.fogEnabled&&n.applyFog&&o.fogMode!==_e.a.FOGMODE_NONE||p)&&this.bindView(s),tt.a.BindFogParameters(o,n,this._activeEffect,!0),a.NUM_MORPH_INFLUENCERS&&tt.a.BindMorphTargetParameters(n,this._activeEffect),this._imageProcessingConfiguration.bind(this._activeEffect),tt.a.BindLogDepth(a,this._activeEffect,o)),y.update(),this._afterBind(n,this._activeEffect)}}},t.prototype.getAnimatables=function(){var e=[];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.detailMap.getAnimatables(e),this.subSurface.getAnimatables(e),this.clearCoat.getAnimatables(e),this.sheen.getAnimatables(e),this.anisotropy.getAnimatables(e),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._microSurfaceTexture&&e.push(this._microSurfaceTexture),this._bumpTexture&&e.push(this._bumpTexture),this._lightmapTexture&&e.push(this._lightmapTexture),this.detailMap.getActiveTextures(e),this.subSurface.getActiveTextures(e),this.clearCoat.getActiveTextures(e),this.sheen.getActiveTextures(e),this.anisotropy.getActiveTextures(e),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._reflectivityTexture===e||this._metallicTexture===e||this._metallicReflectanceTexture===e||this._microSurfaceTexture===e||this._bumpTexture===e||this._lightmapTexture===e||this.detailMap.hasTexture(e)||this.subSurface.hasTexture(e)||this.clearCoat.hasTexture(e)||this.sheen.hasTexture(e)||this.anisotropy.hasTexture(e)},t.prototype.setPrePassRenderer=function(e){if(this.subSurface.isScatteringEnabled){var n=this.getScene().enableSubSurfaceForPrePass();return n&&(n.enabled=!0),!0}return!1},t.prototype.dispose=function(e,n){var i,o,a,s,d,p,y,P,O,U,F;
6709n&&(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(),(d=this._emissiveTexture)===null||d===void 0||d.dispose(),(p=this._metallicTexture)===null||p===void 0||p.dispose(),(y=this._reflectivityTexture)===null||y===void 0||y.dispose(),(P=this._bumpTexture)===null||P===void 0||P.dispose(),(O=this._lightmapTexture)===null||O===void 0||O.dispose(),(U=this._metallicReflectanceTexture)===null||U===void 0||U.dispose(),(F=this._microSurfaceTexture)===null||F===void 0||F.dispose()),this.detailMap.dispose(n),this.subSurface.dispose(n),this.clearCoat.dispose(n),this.sheen.dispose(n),this.anisotropy.dispose(n),this._renderTargets.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),r.prototype.dispose.call(this,e,n)},t.PBRMATERIAL_OPAQUE=Ht.a.MATERIAL_OPAQUE,t.PBRMATERIAL_ALPHATEST=Ht.a.MATERIAL_ALPHATEST,t.PBRMATERIAL_ALPHABLEND=Ht.a.MATERIAL_ALPHABLEND,t.PBRMATERIAL_ALPHATESTANDBLEND=Ht.a.MATERIAL_ALPHATESTANDBLEND,t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=0,t.LIGHTFALLOFF_PHYSICAL=0,t.LIGHTFALLOFF_GLTF=1,t.LIGHTFALLOFF_STANDARD=2,Object(c.c)([Object(L.i)()],t.prototype,"_imageProcessingConfiguration",void 0),Object(c.c)([Object(L.b)("_markAllSubMeshesAsMiscDirty")],t.prototype,"debugMode",void 0),Object(c.c)([Object(L.c)()],t.prototype,"useLogarithmicDepth",null),t}(na.a),lo=function(r){function t(e,n){var i=r.call(this,e,n)||this;return i.directIntensity=1,i.emissiveIntensity=1,i.environmentIntensity=1,i.specularIntensity=1,i.disableBumpMap=!1,i.ambientTextureStrength=1,i.ambientTextureImpactOnAnalyticalLights=t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,i.metallicF0Factor=1,i.metallicReflectanceColor=M.a.White(),i.ambientColor=new M.a(0,0,0),i.albedoColor=new M.a(1,1,1),i.reflectivityColor=new M.a(1,1,1),i.reflectionColor=new M.a(1,1,1),i.emissiveColor=new M.a(0,0,0),i.microSurface=1,i.useLightmapAsShadowmap=!1,i.useAlphaFromAlbedoTexture=!1,i.forceAlphaTest=!1,i.alphaCutOff=.4,i.useSpecularOverAlpha=!0,i.useMicroSurfaceFromReflectivityMapAlpha=!1,i.useRoughnessFromMetallicTextureAlpha=!0,i.useRoughnessFromMetallicTextureGreen=!1,i.useMetallnessFromMetallicTextureBlue=!1,i.useAmbientOcclusionFromMetallicTextureRed=!1,i.useAmbientInGrayScale=!1,i.useAutoMicroSurfaceFromReflectivityMap=!1,i.useRadianceOverAlpha=!0,i.useObjectSpaceNormalMap=!1,i.useParallax=!1,i.useParallaxOcclusion=!1,i.parallaxScaleBias=.05,i.disableLighting=!1,i.forceIrradianceInFragment=!1,i.maxSimultaneousLights=4,i.invertNormalMapX=!1,i.invertNormalMapY=!1,i.twoSidedLighting=!1,i.useAlphaFresnel=!1,i.useLinearAlphaFresnel=!1,i.environmentBRDFTexture=null,i.forceNormalForward=!1,i.enableSpecularAntiAliasing=!1,i.useHorizonOcclusion=!0,i.useRadianceOcclusion=!0,i.unlit=!1,i._environmentBRDFTexture=ia.GetEnvironmentBRDFTexture(n),i}return Object(c.d)(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)}
6709,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"usePhysicalLightFalloff",{get:function(){return this._lightFalloff===pn.LIGHTFALLOFF_PHYSICAL},set:function(e){e!==this.usePhysicalLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),this._lightFalloff=e?pn.LIGHTFALLOFF_PHYSICAL:pn.LIGHTFALLOFF_STANDARD)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useGLTFLightFalloff",{get:function(){return this._lightFalloff===pn.LIGHTFALLOFF_GLTF},set:function(e){e!==this.useGLTFLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),this._lightFalloff=e?pn.LIGHTFALLOFF_GLTF:pn.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){var n=this,i=L.a.Clone(function(){return new t(e,n.getScene())},this);return i.id=e,i.name=e,this.clearCoat.copyTo(i.clearCoat),this.anisotropy.copyTo(i.anisotropy),this.brdf.copyTo(i.brdf),this.sheen.copyTo(i.sheen),this.subSurface.copyTo(i.subSurface),i},t.prototype.serialize=function(){var e=L.a.Serialize(this);return e.customType="BABYLON.PBRMaterial",e.clearCoat=this.clearCoat.serialize(),e.anisotropy=this.anisotropy.serialize(),e.brdf=this.brdf.serialize(),e.sheen=this.sheen.serialize(),e.subSurface=this.subSurface.serialize(),e},t.Parse=function(e,n,i){var o=L.a.Parse(function(){return new t(e.name,n)},e,n,i);return e.clearCoat&&o.clearCoat.parse(e.clearCoat,n,i),e.anisotropy&&o.anisotropy.parse(e.anisotropy,n,i),e.brdf&&o.brdf.parse(e.brdf,n,i),e.sheen&&o.sheen.parse(e.sheen,n,i),e.subSurface&&o.subSurface.parse(e.subSurface,n,i),o},t.PBRMATERIAL_OPAQUE=pn.PBRMATERIAL_OPAQUE,t.PBRMATERIAL_ALPHATEST=pn.PBRMATERIAL_ALPHATEST,t.PBRMATERIAL_ALPHABLEND=pn.PBRMATERIAL_ALPHABLEND,t.PBRMATERIAL_ALPHATESTANDBLEND=pn.PBRMATERIAL_ALPHATESTANDBLEND,t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=pn.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"directIntensity",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveIntensity",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"environmentIntensity",void 0),Object(c.c)([Object(L.c)(),Ob
6709ject(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"specularIntensity",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"disableBumpMap",void 0),Object(c.c)([Object(L.m)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoTexture",void 0),Object(c.c)([Object(L.m)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTexture",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTextureStrength",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTextureImpactOnAnalyticalLights",void 0),Object(c.c)([Object(L.m)(),Object(L.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"opacityTexture",void 0),Object(c.c)([Object(L.m)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),Object(c.c)([Object(L.m)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveTexture",void 0),Object(c.c)([Object(L.m)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityTexture",void 0),Object(c.c)([Object(L.m)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicTexture",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallic",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicF0Factor",void 0),Object(c.c)([Object(L.e)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicReflectanceColor",void 0),Object(c.c)([Object(L.m)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicReflectanceTexture",void 0),Object(c.c)([Object(L.m)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurfaceTexture",void 0),Object(c.c)([Object(L.m)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),Object(c.c)([Object(L.m)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty",null)],t.prototype,"lightmapTexture",void 0),Object(c.c)([Object(L.e)("ambient"),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientColor",void 0),Object(c.c)([Object(L.e)("albedo"),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoColor",void 0),Object(c.c)([Object(L.e)("reflectivity"),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityColor",void 0),Object(c.c)([Object(L.e)("reflection"),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionColor",void 0),Object(c.c)([Object(L.e)("emissive"),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveColor",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurface",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLightmapAsShadowmap",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"useAlphaFromAlbedoTexture",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"forceAlphaTest",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"alphaCutOff",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useSpecularOverAlpha",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMicroSurfaceFromReflectivityMapAlpha",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureAlpha",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureGreen",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMetallnessFromMetallicTextureBlue",void 0),Object(c.c)([Object(L.c)(),Ob
6709ject(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientOcclusionFromMetallicTextureRed",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientInGrayScale",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAutoMicroSurfaceFromReflectivityMap",void 0),Object(c.c)([Object(L.c)()],t.prototype,"usePhysicalLightFalloff",null),Object(c.c)([Object(L.c)()],t.prototype,"useGLTFLightFalloff",null),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRadianceOverAlpha",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useObjectSpaceNormalMap",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallax",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallaxOcclusion",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"parallaxScaleBias",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceIrradianceInFragment",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapX",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapY",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"twoSidedLighting",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAlphaFresnel",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLinearAlphaFresnel",void 0),Object(c.c)([Object(L.m)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"environmentBRDFTexture",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceNormalForward",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"enableSpecularAntiAliasing",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useHorizonOcclusion",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRadianceOcclusion",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsMiscDirty")],t.prototype,"unlit",void 0),t}(pn);R.a.RegisteredTypes["BABYLON.PBRMaterial"]=lo;function oa(r){return r.charCodeAt(0)+(r.charCodeAt(1)<<8)+(r.charCodeAt(2)<<16)+(r.charCodeAt(3)<<24)}var Au=oa("DXT1"),Pu=oa("DXT3"),Cu=oa("DXT5"),Gs=oa("DX10"),Ui=function(){function r(){}return r.GetDDSInfo=function(t){var e=new Int32Array(t.buffer,t.byteOffset,31),n=new Int32Array(t.buffer,t.byteOffset,35),i=1;131072&e[2]&&(i=Math.max(1,e[7]));var o=e[21],a=o===Gs?n[32]:0,s=h.a.TEXTURETYPE_UNSIGNED_INT;switch(o){case 113:s=h.a.TEXTURETYPE_HALF_FLOAT;break;case 116:s=h.a.TEXTURETYPE_FLOAT;break;case Gs:if(a===10){s=h.a.TEXTURETYPE_HALF_FLOAT;break}if(a===2){s=h.a.TEXTURETYPE_FLOAT;break}}return{width:e[4],height:e[3],mipmapCount:i,isFourCC:(4&e[20])==4,isRGB:(64&e[20])==64,isLuminance:(131072&e[20])==131072,isCube:(512&e[28])==512,isCompressed:o===Au||o===Pu||o===Cu,dxgiFormat:a,textureType:s}},r._ToHalfFloat=function(t){r._FloatView||(r._FloatView=new Float32Array(1),r._Int32View=new Int32Array(r._FloatView.buffer)),r._FloatView[0]=t;var e=r._Int32View[0],n=e>>16&32768,i=e>>12&2047,o=e>>23&255;return o<103?n:o>142?(n|=31744,n|=(o==255?0:1)&&8388607&e):o<113?n|=((i|=2048)>>114-o)+(i>>113-o&1):(n|=o-112<<10|i>>1,n+=1&i)},r._FromHalfFloat=function(t){var e=(32768&t)>>15,n=(31744&t)>>10,i=1023&t;return n===0?(e?-1:1)*Math.pow(2,-14)*(i/Math.pow(2,10)):n==31?i?NaN:1/0*(e?-1:1):(e?-1:1)*Math.pow(2,n-15)*(1+i/Math.pow(2,10))},r._GetHalfFloatAsFloatRGBAArrayBuffer=function(t,e,n,i,o,a){for(var s=new Float32Array(i),d=new Uint16Array(o,n),p=0,y=0;y<e;y++)for(var P=0;P<t;P++){var O=4*(P+y*t);s[p]=r._FromHalfFloat(d[O]),s[p+1]=r._FromHalfFloat(d[O+1]),s[p+2]=r._FromHalfFloat(d[O+2]),r.StoreLODInAlphaChannel?s[p+3]=a:s[p+3]=r._FromHalfFloat(d[O+3]),p+=4}return s},r._GetHalfFloatRGBAArrayBuffer=function(t,e,n,i,o,a){if(r.StoreLODInAlphaChannel){for(var s=new Uint16Array(i),d=new Uint16Array(o,n),p=0,y=0;y<e;y++)for(var P=0;P<t;P++){var O=4*(P+y*t);s[p]=d[O],s[p+1]=d[O+1],s[p+2]=d[O+2],s[p+3]=r._ToHalfFloat(a),p+=4}return s}return new Uint16Array(o,n,i)},r._GetFloatRGBAArrayBuffer=function(t,e,n,i,o,a){if(r.StoreLODInAlphaChannel){for(var s=new Float32Array(i),d=new Float32Array(o,n),p=0,y=0;y<e;y++)for(var P=0;P<t;P++){var O=4*(P+y*t);s[p]=d[O],s[p+1]=d[O+1],s[p+2]=d[O+2],s[p+3]=a,p+=4}return s}return new Float32Array(o,n,i)},r._GetFloatAsUIntRGBAArrayBuffer=function(t,e,n,i,o,a){for(var s=new Uint8Array(i),d=new Float32Array(o,n),p=0,y=0;y<e;y++)for(var P=0;P<t;P++){var O=4*(P+y*t);s[p]=255*$.a.Clamp(d[O]),s[p+1]=255*$.a.Clamp(d[O+1]),s[p+2]=255*$.a.Clamp(d[O+2]),r.StoreLODInAlphaChannel?s[p+3]=a:s[p+3]=255*$.a.Clamp(d[O+3]),p+=4}return s},r._GetHalfFloatAsUIntRGBAArrayBuffer=function(t,e,n,i,o,a){for(var s=new Uint8Array(i),d=new Uint16Array(o,n),p=0,y=0;y<e;y++)for(var P=0;P<t;P++){var O=4*(P+y*t);s[p]=255*$.a.Clamp(r._FromHalfFloat(d[O])),s[p+1]=255*$.a.Clamp(r._FromHalfFloat(d[O+1])),s[p+2]=255*$.a.Clamp(r._FromHalfFloat(d[O+2])),r.StoreLODInAlphaChannel?s[p+3]=a:s[p+3]=255*$.a.Clamp(r._FromHalfFloat(d[O+3])),p+=4}return s},r._GetRGBAArrayBuffer=function(t,e,n,i,o,a,s,d,p){for(var y=new Uint8Array(i),P=new Uint8Array(o,n),O=0,U=0;U<e;U++)for(var F=0;F<t;F++){var z=4*(F+U*t);y[O]=P[z+a],y[O+1]=P[z+s],y[O+2]=P[z+d],y[O+3]=P[z+p],O+=4}return y},r._ExtractLongWordOrder=function(t){return t===0||t===255||t===-16777216?0:1+r._ExtractLongWordOrder(t>>8)},r._GetRGBArrayBuffer=function(t,e,n,i,o,a,s,d){for(var p=new Uint8Array(i),y=new Uint8Array(o,n),P=0,O=0;O<e;O++)for(var U=0;U<t;U++){var F=3*(U+O*t);p[P]=y[F+a],p[P+1]=y[F+s],p[P+2]=y[F+d],P+=3}return p},r._GetLuminanceArrayBuffer=function(t,e,n,i,o){for(var a=new Uint8Array(i),s=new Uint8Array(o,n),d=0,p=0;p<e;p++)for(var y=0;y<t;y++){var P=y+p*t;a[d]=s[P],d++}return a},r.UploadDDSLevels=function(t,e,n,i,o,a,s,d){s===void 0&&(s=-1);var p=null;i.sphericalPolynomial&&(p=new Array);var y,P,O,U,F,z,J,ie=t.getCaps().s3tc,se=new Int32Array(n.buffer,n.byteOffset,31),ce=0,ue=0,fe=1;if(se[0]===542327876)if(i.isFourCC||i.isRGB||i.isLuminance)if(!i.isCompressed||ie){var ve=se[22];U=se[1]+4;var Te,Oe=!1;if(i.isFourCC)switch(y=se[21]){case Au:fe=8,ue=ie.COMPRESSED_RGBA_S3TC_DXT1_EXT;break;case Pu:fe=16,ue=ie.COMPRESSED_RGBA_S3TC_DXT3_EXT;break;case Cu:fe=16,ue=ie.COMPRESSED_RGBA_S3TC_DXT5_EXT;break;case 113:case 116:Oe=!0;break;case Gs:U+=20;var Pe=!1;switch(i.dxgiFormat){case 10:case 2:Oe=!0,Pe=!0;break;case 88:i.isRGB=!0,i.isFourCC=!1,ve=32,Pe=!0}if(Pe)break;default:return void console.error("Unsupported FourCC code:",(Te=y,String.fromCharCode(255&Te,Te>>8&255,Te>>
670916&255,Te>>24&255)))}var Ee=r._ExtractLongWordOrder(se[23]),Se=r._ExtractLongWordOrder(se[24]),Le=r._ExtractLongWordOrder(se[25]),xe=r._ExtractLongWordOrder(se[26]);Oe&&(ue=t._getRGBABufferInternalSizedFormat(i.textureType)),z=1,131072&se[2]&&o!==!1&&(z=Math.max(1,se[7]));for(var Ne=d||0;Ne<a;Ne++){for(P=se[4],O=se[3],J=0;J<z;++J){if(s===-1||s===J){var Ie=s===-1?J:0;if(!i.isCompressed&&i.isFourCC){e.format=h.a.TEXTUREFORMAT_RGBA,ce=P*O*4;var Fe=null;t._badOS||t._badDesktopOS||!t.getCaps().textureHalfFloat&&!t.getCaps().textureFloat?(ve===128?(Fe=r._GetFloatAsUIntRGBAArrayBuffer(P,O,n.byteOffset+U,ce,n.buffer,Ie),p&&Ie==0&&p.push(r._GetFloatRGBAArrayBuffer(P,O,n.byteOffset+U,ce,n.buffer,Ie))):ve===64&&(Fe=r._GetHalfFloatAsUIntRGBAArrayBuffer(P,O,n.byteOffset+U,ce,n.buffer,Ie),p&&Ie==0&&p.push(r._GetHalfFloatAsFloatRGBAArrayBuffer(P,O,n.byteOffset+U,ce,n.buffer,Ie))),e.type=h.a.TEXTURETYPE_UNSIGNED_INT):ve===128?(e.type=h.a.TEXTURETYPE_FLOAT,Fe=r._GetFloatRGBAArrayBuffer(P,O,n.byteOffset+U,ce,n.buffer,Ie),p&&Ie==0&&p.push(Fe)):ve!==64||t.getCaps().textureHalfFloat?(e.type=h.a.TEXTURETYPE_HALF_FLOAT,Fe=r._GetHalfFloatRGBAArrayBuffer(P,O,n.byteOffset+U,ce,n.buffer,Ie),p&&Ie==0&&p.push(r._GetHalfFloatAsFloatRGBAArrayBuffer(P,O,U,ce,n.buffer,Ie))):(e.type=h.a.TEXTURETYPE_FLOAT,Fe=r._GetHalfFloatAsFloatRGBAArrayBuffer(P,O,n.byteOffset+U,ce,n.buffer,Ie),p&&Ie==0&&p.push(Fe)),Fe&&t._uploadDataToTextureDirectly(e,Fe,Ne,Ie)}else if(i.isRGB)e.type=h.a.TEXTURETYPE_UNSIGNED_INT,ve===24?(e.format=h.a.TEXTUREFORMAT_RGB,ce=P*O*3,F=r._GetRGBArrayBuffer(P,O,n.byteOffset+U,ce,n.buffer,Ee,Se,Le),t._uploadDataToTextureDirectly(e,F,Ne,Ie)):(e.format=h.a.TEXTUREFORMAT_RGBA,ce=P*O*4,F=r._GetRGBAArrayBuffer(P,O,n.byteOffset+U,ce,n.buffer,Ee,Se,Le,xe),t._uploadDataToTextureDirectly(e,F,Ne,Ie));else if(i.isLuminance){var Ke=t._getUnpackAlignement(),nt=P;ce=Math.floor((P+Ke-1)/Ke)*Ke*(O-1)+nt,F=r._GetLuminanceArrayBuffer(P,O,n.byteOffset+U,ce,n.buffer),e.format=h.a.TEXTUREFORMAT_LUMINANCE,e.type=h.a.TEXTURETYPE_UNSIGNED_INT,t._uploadDataToTextureDirectly(e,F,Ne,Ie)}else ce=Math.max(4,P)/4*Math.max(4,O)/4*fe,F=new Uint8Array(n.buffer,n.byteOffset+U,ce),e.type=h.a.TEXTURETYPE_UNSIGNED_INT,t._uploadCompressedDataToTextureDirectly(e,ue,P,O,F,Ne,Ie)}U+=ve?P*O*(ve/8):ce,P*=.5,O*=.5,P=Math.max(1,P),O=Math.max(1,O)}if(d!==void 0)break}p&&p.length>0?i.sphericalPolynomial=Xo.ConvertCubeMapToSphericalPolynomial({size:se[4],right:p[0],left:p[1],up:p[2],down:p[3],front:p[4],back:p[5],format:h.a.TEXTUREFORMAT_RGBA,type:h.a.TEXTURETYPE_FLOAT,gammaSpace:!1}):i.sphericalPolynomial=void 0}else l.a.Error("Compressed textures are not supported on this platform.");else l.a.Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");else l.a.Error("Invalid magic number in DDS header")},r.StoreLODInAlphaChannel=!1,r}();Bt.a.prototype.createPrefilteredCubeTexture=function(r,t,e,n,i,o,a,s,d){var p=this;return i===void 0&&(i=null),o===void 0&&(o=null),s===void 0&&(s=null),d===void 0&&(d=!0),this.createCubeTexture(r,t,null,!1,function(y){if(y){var P=y.texture;if(d?y.info.sphericalPolynomial&&(P._sphericalPolynomial=y.info.sphericalPolynomial):P._sphericalPolynomial=new io,P._source=xt.b.CubePrefiltered,p.getCaps().textureLOD)i&&i(P);else{var O=p._gl,U=y.width;if(U){for(var F=[],z=0;z<3;z++){var J=1-z/2,ie=n,se=$.a.Log2(U)*e+n,ce=ie+(se-ie)*J,ue=Math.round(Math.min(Math.max(ce,0),se)),fe=new xt.a(p,xt.b.Temp);if(fe.type=P.type,fe.format=P.format,fe.width=Math.pow(2,Math.max($.a.Log2(U)-ue,0)),fe.height=fe.width,fe.isCube=!0,p._bindTextureDirectly(O.TEXTURE_CUBE_MAP,fe,!0),fe.samplingMode=h.a.TEXTURE_LINEAR_LINEAR,O.texParameteri(O.TEXTURE_CUBE_MAP,O.TEXTURE_MAG_FILTER,O.LINEAR),O.texParameteri(O.TEXTURE_CUBE_MAP,O.TEXTURE_MIN_FILTER,O.LINEAR),O.texParameteri(O.TEXTURE_CUBE_MAP,O.TEXTURE_WRAP_S,O.CLAMP_TO_EDGE),O.texParameteri(O.TEXTURE_CUBE_MAP,O.TEXTURE_WRAP_T,O.CLAMP_TO_EDGE),y.isDDS){var ve=y.info,Te=y.data;p._unpackFlipY(ve.isCompressed),Ui.UploadDDSLevels(p,fe,Te,ve,!0,6,ue)}else l.a.Warn("DDS is the only prefiltered cube map supported so far.");p._bindTextureDirectly(O.TEXTURE_CUBE_MAP,null);var Oe=new zn.a(t);Oe.isCube=!0,Oe._texture=fe,fe.isReady=!0,F.push(Oe)}P._lodTextureHigh=F[2],P._lodTextureMid=F[1],P._lodTextureLow=F[0],i&&i(P)}}}else i&&i(null)},o,a,s,d,e,n)};var xu=function(){function r(){this.supportCascades=!0}return r.prototype.canLoad=function(t){return Xn.a.EndsWith(t,".dds")},r.prototype.loadCubeData=function(t,e,n,i,o){var a,s=e.getEngine(),d=!1;if(Array.isArray(t))for(var p=0;p<t.length;p++){var y=t[p];a=Ui.GetDDSInfo(y),e.width=a.width,e.height=a.height,d=(a.isRGB||a.isLuminance||a.mipmapCount>1)&&e.generateMipMaps,s._unpackFlipY(a.isCompressed),Ui.UploadDDSLevels(s,e,y,a,d,6,-1,p),a.isFourCC||a.mipmapCount!==1||s.generateMipMapsForCubemap(e)}else{var P=t;a=Ui.GetDDSInfo(P),e.width=a.width,e.height=a.height,n&&(a.sphericalPolynomial=new io),d=(a.isRGB||a.isLuminance||a.mipmapCount>1)&&e.generateMipMaps,s._unpackFlipY(a.isCompressed),Ui.UploadDDSLevels(s,e,P,a,d,6),a.isFourCC||a.mipmapCount!==1||s.generateMipMapsForCubemap(e,!1)}
6709s._setCubeMapTextureParams(e,d),e.isReady=!0,e.onLoadedObservable.notifyObservers(e),e.onLoadedObservable.clear(),i&&i({isDDS:!0,width:e.width,info:a,data:t,texture:e})},r.prototype.loadData=function(t,e,n){var i=Ui.GetDDSInfo(t),o=(i.isRGB||i.isLuminance||i.mipmapCount>1)&&e.generateMipMaps&&i.width>>i.mipmapCount-1==1;n(i.width,i.height,o,i.isFourCC,function(){Ui.UploadDDSLevels(e.getEngine(),e,t,i,o,1)})},r}();Ue.a._TextureLoaders.push(new xu);var Ru=function(){function r(){this.supportCascades=!1}return r.prototype.canLoad=function(t){return Xn.a.EndsWith(t,".env")},r.prototype.loadCubeData=function(t,e,n,i,o){if(!Array.isArray(t)){var a=Si.GetEnvInfo(t);a?(e.width=a.width,e.height=a.width,Si.UploadEnvSpherical(e,a),Si.UploadEnvLevelsAsync(e,t,a).then(function(){e.isReady=!0,e.onLoadedObservable.notifyObservers(e),e.onLoadedObservable.clear(),i&&i()})):o&&o("Can not parse the environment file",null)}},r.prototype.loadData=function(t,e,n){throw".env not supported in 2d."},r}();Ue.a._TextureLoaders.push(new Ru);var aa=function(){function r(t,e,n,i){if(this.data=t,this.isInvalid=!1,!r.IsValid(t))return this.isInvalid=!0,void l.a.Error("texture missing KTX identifier");var o=Uint32Array.BYTES_PER_ELEMENT,a=new DataView(this.data.buffer,this.data.byteOffset+12,13*o),s=a.getUint32(0,!0)===67305985;this.glType=a.getUint32(1*o,s),this.glTypeSize=a.getUint32(2*o,s),this.glFormat=a.getUint32(3*o,s),this.glInternalFormat=a.getUint32(4*o,s),this.glBaseInternalFormat=a.getUint32(5*o,s),this.pixelWidth=a.getUint32(6*o,s),this.pixelHeight=a.getUint32(7*o,s),this.pixelDepth=a.getUint32(8*o,s),this.numberOfArrayElements=a.getUint32(9*o,s),this.numberOfFaces=a.getUint32(10*o,s),this.numberOfMipmapLevels=a.getUint32(11*o,s),this.bytesOfKeyValueData=a.getUint32(12*o,s),this.glType===0?(this.numberOfMipmapLevels=Math.max(1,this.numberOfMipmapLevels),this.pixelHeight!==0&&this.pixelDepth===0?this.numberOfArrayElements===0?this.numberOfFaces===e?this.loadType=r.COMPRESSED_2D:l.a.Error("number of faces expected"+e+", but found "+this.numberOfFaces):l.a.Error("texture arrays not currently supported"):l.a.Error("only 2D textures currently supported")):l.a.Error("only compressed formats currently supported")}return r.prototype.uploadLevels=function(t,e){switch(this.loadType){case r.COMPRESSED_2D:this._upload2DCompressedLevels(t,e);break;case r.TEX_2D:case r.COMPRESSED_3D:case r.TEX_3D:}},r.prototype._upload2DCompressedLevels=function(t,e){for(var n=r.HEADER_LEN+this.bytesOfKeyValueData,i=this.pixelWidth,o=this.pixelHeight,a=e?this.numberOfMipmapLevels:1,s=0;s<a;s++){var d=new Int32Array(this.data.buffer,this.data.byteOffset+n,1)[0];n+=4;for(var p=0;p<this.numberOfFaces;p++){var y=new Uint8Array(this.data.buffer,this.data.byteOffset+n,d);t.getEngine()._uploadCompressedDataToTextureDirectly(t,this.glInternalFormat,i,o,y,p,s),n+=d,n+=3-(d+3)%4}i=Math.max(1,.5*i),o=Math.max(1,.5*o)}},r.IsValid=function(t){if(t.byteLength>=12){var e=new Uint8Array(t.buffer,t.byteOffset,12);if(e[0]===171&&e[1]===75&&e[2]===84&&e[3]===88&&e[4]===32&&e[5]===49&&e[6]===49&&e[7]===187&&e[8]===13&&e[9]===10&&e[10]===26&&e[11]===10)return!0}return!1},r.HEADER_LEN=64,r.COMPRESSED_2D=0,r.COMPRESSED_3D=1,r.TEX_2D=2,r.TEX_3D=3,r}(),zs=function(){function r(t){this._pendingActions=new Array,this._workerInfos=t.map(function(e){return{worker:e,active:!1}})}return r.prototype.dispose=function(){for(var t=0,e=this._workerInfos;t<e.length;t++)e[t].worker.terminate();this._workerInfos=[],this._pendingActions=[]},r.prototype.push=function(t){for(var e=0,n=this._workerInfos;e<n.length;e++){var i=n[e];if(!i.active)return void this._execute(i,t)}this._pendingActions.push(t)},r.prototype._execute=function(t,e){var n=this;t.active=!0,e(t.worker,function(){t.active=!1;var i=n._pendingActions.shift();i&&n._execute(t,i)})},r}(),js=function(){function r(t,e){e===void 0&&(e=r.DefaultNumWorkers),this._engine=t,r._Initialized||r._CreateWorkerPool(e)}return r.GetDefaultNumWorkers=function(){return typeof navigator=="object"&&navigator.hardwareConcurrency?Math.min(Math.floor(.5*navigator.hardwareConcurrency),4):1},r._CreateWorkerPool=function(t){this._Initialized=!0,t&&typeof Worker=="function"?r._WorkerPoolPromise=new Promise(function(e){for(var n="("+N_+")()",i=URL.createObjectURL(new Blob([n],{type:"application/javascript"})),o=new Array(t),a=0;a<o.length;a++)o[a]=new Promise(function(s,d){var p=new Worker(i),y=function(O){p.removeEventListener("error",y),p.removeEventListener("message",P),d(O)},P=function(O){O.data.action==="init"&&(p.removeEventListener("error",y),p.removeEventListener("message",P),s(p))};p.addEventListener("error",y),p.addEventListener("message",P),p.postMessage({action:"init",urls:r.URLConfig})});Promise.all(o).then(function(s){e(new zs(s))})}):(KTX2DECODER.MSCTranscoder.UseFromWorkerThread=!1,KTX2DECODER.WASMMemoryManager.LoadBinariesFromCurrentThread=!0)},r.prototype.uploadAsync=function(t,e,n){var i=this,o=this._engine.getCaps(),a={astc:!!o.astc,bptc:!!o.bptc,s3tc:!!o.s3tc,pvrtc:!!o.pvrtc,etc2:!!o.etc2,etc1:!!o.etc1};return r._WorkerPoolPromise?r._WorkerPoolPromise.then(function(s){return new Promise(function(d,p){s.push(function(y,P){var O=function(F){y.removeEventListener("error",O),y.removeEventListener("message",U),p(F),P()},U=function(F){if(F.data.action==="decoded"){if(y.removeEventListener("error",O),y.removeEventListener("message",U),F.data.success)try{i._createTexture(F.data.decodedData,e,n),d()}catch(z){p({message:z})}else p({message:F.data.msg});P()}};y.addEventListener("error",O),y.addEventListener("message",U),y.postMessage({action:"decode",data:t,caps:a,options:n})})})}):new Promise(function(s,d){r._Ktx2Decoder||(r._Ktx2Decoder=new KTX2DECODER.KTX2Decoder),r._Ktx2Decoder.decode(t,o).then(function(p){i._createTexture(p,e),s()}).catch(function(p){d({message:p})})})},r.prototype.dispose=function(){r._WorkerPoolPromise&&r._WorkerPoolPromise.then(function(t){t.dispose()}),delete r._WorkerPoolPromise},r.prototype._createTexture=function(t,e,n){if(this._engine._bindTextureDirectly(this._engine._gl.TEXTURE_2D,e),n&&(n.transcodedFormat=t.transcodedFormat,n.isInGammaSpace=t.isInGammaSpace,n.transcoderName=t.transcoderName),t.transcodedFormat===32856?(e.type=h.a.TEXTURETYPE_UNSIGNED_BYTE,e.format=h.a.TEXTUREFORMAT_RGBA):e.format=t.transcodedFormat,e._gammaSpace=t.isInGammaSpace,t.errors)throw new Error("KTX2 container - could not transcode the data. "+t.errors);for(var i=0;i<t.mipmaps.length;++i){var o=t.mipmaps[i];if(!o||!o.data)throw new Error("KTX2 container - could not transcode one of the image");t.transcodedFormat===32856?(e.width=o.width,e.height=o.height,this._engine._uploadDataToTextureDirectly(e,o.data,0,i,void 0,!0)):this._engine._uploadCompressedDataToTextureDirectly(e,t.transcodedFormat,o.width,o.height,o.data,0,i)}e.width=t.mipmaps[0].width,e.height=t.mipmaps[0].height,e.generateMipMaps=t.mipmaps.length>1,e.isReady=!0,this._engine._bindTextureDirectly(this._engine._gl.TEXTURE_2D,null)},r.IsValid=function(t){if(t.byteLength>=12){var e=new Uint8Array(t.buffer,t.byteOffset,12);if(e[0]===171&&e[1]===75&&e[2]===84&&e[3]===88&&e[4]===32&&e[5]===50&&e[6]===48&&e[7]===187&&e[8]===13&&e[9]===10&&e[10
6709]===26&&e[11]===10)return!0}return!1},r.URLConfig={jsDecoderModule:"https://preview.babylonjs.com/babylon.ktx2Decoder.js",wasmUASTCToASTC:null,wasmUASTCToBC7:null,wasmUASTCToRGBA_UNORM:null,wasmUASTCToRGBA_SRGB:null,jsMSCTranscoder:null,wasmMSCTranscoder:null},r.DefaultNumWorkers=r.GetDefaultNumWorkers(),r}();function N_(){var r;onmessage=function(t){switch(t.data.action){case"init":var e=t.data.urls;importScripts(e.jsDecoderModule),e.wasmUASTCToASTC!==null&&(KTX2DECODER.LiteTranscoder_UASTC_ASTC.WasmModuleURL=e.wasmUASTCToASTC),e.wasmUASTCToBC7!==null&&(KTX2DECODER.LiteTranscoder_UASTC_BC7.WasmModuleURL=e.wasmUASTCToBC7),e.wasmUASTCToRGBA_UNORM!==null&&(KTX2DECODER.LiteTranscoder_UASTC_RGBA_UNORM.WasmModuleURL=e.wasmUASTCToRGBA_UNORM),e.wasmUASTCToRGBA_SRGB!==null&&(KTX2DECODER.LiteTranscoder_UASTC_RGBA_SRGB.WasmModuleURL=e.wasmUASTCToRGBA_SRGB),e.jsMSCTranscoder!==null&&(KTX2DECODER.MSCTranscoder.JSModuleURL=e.jsMSCTranscoder),e.wasmMSCTranscoder!==null&&(KTX2DECODER.MSCTranscoder.WasmModuleURL=e.wasmMSCTranscoder),r=new KTX2DECODER.KTX2Decoder,postMessage({action:"init"});break;case"decode":r.decode(t.data.data,t.data.caps,t.data.options).then(function(n){for(var i=[],o=0;o<n.mipmaps.length;++o){var a=n.mipmaps[o];a&&a.data&&i.push(a.data.buffer)}postMessage({action:"decoded",success:!0,decodedData:n},i)}).catch(function(n){postMessage({action:"decoded",success:!1,msg:n})})}}}var Ou=function(){function r(){this.supportCascades=!1}return r.prototype.canLoad=function(t,e){return Xn.a.EndsWith(t,".ktx")||Xn.a.EndsWith(t,".ktx2")||e==="image/ktx"||e==="image/ktx2"},r.prototype.loadCubeData=function(t,e,n,i,o){if(!Array.isArray(t)){e._invertVScale=!e.invertY;var a=e.getEngine(),s=new aa(t,6),d=s.numberOfMipmapLevels>1&&e.generateMipMaps;a._unpackFlipY(!0),s.uploadLevels(e,e.generateMipMaps),e.width=s.pixelWidth,e.height=s.pixelHeight,a._setCubeMapTextureParams(e,d),e.isReady=!0,e.onLoadedObservable.notifyObservers(e),e.onLoadedObservable.clear(),i&&i()}},r.prototype.loadData=function(t,e,n,i){if(aa.IsValid(t)){e._invertVScale=!e.invertY;var o=new aa(t,1);n(o.pixelWidth,o.pixelHeight,e.generateMipMaps,!0,function(){o.uploadLevels(e,e.generateMipMaps)},o.isInvalid)}else js.IsValid(t)?new js(e.getEngine()).uploadAsync(t,e,i).then(function(){n(e.width,e.height,e.generateMipMaps,!0,function(){},!1)},function(a){l.a.Warn("Failed to load KTX2 texture data: "+a.message),n(0,0,!1,!1,function(){},!0)}):(l.a.Error("texture missing KTX identifier"),n(0,0,!1,!1,function(){},!0))},r}();Ue.a._TextureLoaders.unshift(new Ou);var Mu=function(r){function t(e,n,i){var o=r.call(this,e,u.e.Zero(),n)||this;return o._xrSessionManager=i,o._firstFrame=!1,o._referenceQuaternion=u.b.Identity(),o._referencedPosition=new u.e,o._xrInvPositionCache=new u.e,o._xrInvQuaternionCache=u.b.Identity(),o._trackingState=er.NOT_TRACKING,o.onBeforeCameraTeleport=new x.c,o.onAfterCameraTeleport=new x.c,o.onTrackingStateChanged=new x.c,o.compensateOnFirstFrame=!0,o._rotate180=new u.b(0,1,0,0),o.minZ=.1,o.rotationQuaternion=new u.b,o.cameraRigMode=gt.a.RIG_MODE_CUSTOM,o.updateUpVectorFromRotation=!0,o._updateNumberOfRigCameras(1),o.freezeProjectionMatrix(),o._xrSessionManager.onXRSessionInit.add(function(){o._referencedPosition.copyFromFloats(0,0,0),o._referenceQuaternion.copyFromFloats(0,0,0,1),o._firstFrame=o.compensateOnFirstFrame}),o._xrSessionManager.onXRFrameObservable.add(function(a){o._firstFrame&&o._updateFromXRSession(),o._updateReferenceSpace(),o._updateFromXRSession()},void 0,!0),o}return Object(c.d)(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:0},enumerable:!1,configurable:!0}),t.prototype._updateForDualEyeDebugging=function(){this._updateNumberOfRigCameras(2),this.rigCameras[0].viewport=new Wn.a(0,0,.5,1),this.rigCameras[0].outputRenderTarget=null,this.rigCameras[1].viewport=new Wn.a(.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,u.b.FromEulerAnglesToRef(0,this.rotationQuaternion.toEulerAngles().y,0,this.rotationQuaternion),this._firstFrame=!0,n&&this._xrSessionManager.resetReferenceSpace())},t.prototype.getClassName=function(){return"WebXRCamera"},t.prototype._updateFromXRSession=function(){var e=this,n=this._xrSessionManager.currentFrame&&this._xrSessionManager.currentFrame.getViewerPose(this._xrSessionManager.referenceSpace);if(n){var i=n.emulatedPosition?er.TRACKING_LOST:er.TRACKING;if(this._setTrackingState(i),n.transform){var o=n.transform.position;this._referencedPosition.set(o.x,o.y,o.z);var a=n.transform.orientation;this._referenceQuaternion.set(a.x,a.y,a.z,a.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,d){var p=e.rigCameras[d];p.isLeftCamera||p.isRightCamera||(s.eye==="right"?p._isRightCamera=!0:s.eye==="left"&&(p._isLeftCamera=!0));var y=s.transform.position,P=s.transform.orientation;if(p.position.set(y.x,y.y,y.z),p.rotationQuaternion.set(P.x,P.y,P.z,P.w),e._scene.useRightHandedSystem?p.rotationQuaternion.multiplyInPlace(e._rotate180):(p.position.z*=-1,p.rotationQuaternion.z*=-1,p.rotationQuaternion.w*=-1),u.a.FromFloat32ArrayToRefScaled(s.projectionMatrix,0,1,p._projectionMatrix),e._scene.useRightHandedSystem||p._projectionMatrix.toggleProjectionMatrixHandInPlace(),d===0&&e._projectionMatrix.copyFrom(p._projectionMatrix),e._xrSessionManager.session.renderState.baseLayer){var O=e._xrSessionManager.session.renderState.baseLayer.getViewport(s),U=e._xrSessionManager.session.renderState.baseLayer.framebufferWidth,F=e._xrSessionManager.session.renderState.baseLayer.framebufferHeight;p.viewport.width=O.width/U,p.viewport.height=O.height/F,p.viewport.x=O.x/U,p.viewport.y=O.y/F}p.outputRenderTarget=e._xrSessionManager.getRenderTargetTextureForEye(s.eye)})}else this._setTrackingState(er.NOT_TRACKING)},t.prototype._updateNumberOfRigCameras=function(e){for(e===void 0&&(e=1);this.rigCameras.length<e;){var n=new Ii("XR-RigCamera: "+this.rigCameras.length,u.e.Zero(),this.get
6709Scene());n.minZ=.1,n.rotationQuaternion=new u.b,n.updateUpVectorFromRotation=!0,n.isRigCamera=!0,n.rigParent=this,n.freezeProjectionMatrix(),this.rigCameras.push(n)}for(;this.rigCameras.length>e;){var i=this.rigCameras.pop();i&&i.dispose()}},t.prototype._updateReferenceSpace=function(){this.position.equals(this._referencedPosition)&&this.rotationQuaternion.equals(this._referenceQuaternion)||(this.position.subtractToRef(this._referencedPosition,this._referencedPosition),this._referenceQuaternion.conjugateInPlace(),this._referenceQuaternion.multiplyToRef(this.rotationQuaternion,this._referenceQuaternion),this._updateReferenceSpaceOffset(this._referencedPosition,this._referenceQuaternion.normalize()))},t.prototype._updateReferenceSpaceOffset=function(e,n,i){if(i===void 0&&(i=!1),this._xrSessionManager.referenceSpace&&this._xrSessionManager.currentFrame){this._xrInvPositionCache.copyFrom(e),n?this._xrInvQuaternionCache.copyFrom(n):this._xrInvQuaternionCache.copyFromFloats(0,0,0,1),this._scene.useRightHandedSystem||(this._xrInvPositionCache.z*=-1,this._xrInvQuaternionCache.z*=-1,this._xrInvQuaternionCache.w*=-1),this._xrInvPositionCache.negateInPlace(),this._xrInvQuaternionCache.conjugateInPlace(),this._xrInvPositionCache.rotateByQuaternionToRef(this._xrInvQuaternionCache,this._xrInvPositionCache),i&&(this._xrInvPositionCache.y=0);var o=new XRRigidTransform({x:this._xrInvPositionCache.x,y:this._xrInvPositionCache.y,z:this._xrInvPositionCache.z},{x:this._xrInvQuaternionCache.x,y:this._xrInvQuaternionCache.y,z:this._xrInvQuaternionCache.z,w:this._xrInvQuaternionCache.w}),a=this._xrSessionManager.referenceSpace.getOffsetReferenceSpace(o),s=this._xrSessionManager.currentFrame&&this._xrSessionManager.currentFrame.getViewerPose(a);if(s){var d=new u.e(s.transform.position.x,s.transform.position.y,s.transform.position.z);this._scene.useRightHandedSystem||(d.z*=-1),this.position.subtractToRef(d,d),this._scene.useRightHandedSystem||(d.z*=-1),d.negateInPlace();var p=new XRRigidTransform({x:d.x,y:d.y,z:d.z});this._xrSessionManager.referenceSpace=a.getOffsetReferenceSpace(p)}}},t}(Hn),ii=function(){function r(){}return r.ANCHOR_SYSTEM="xr-anchor-system",r.BACKGROUND_REMOVER="xr-background-remover",r.HIT_TEST="xr-hit-test",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}(),Yn=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()},r.prototype.detachFeature=function(t){var e=this._features[t];e&&e.featureImplementation.attached&&e.featureImplementation.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(),!0)},r.prototype.dispose=function(){var t=this;
6709this.getEnabledFeatures().forEach(function(e){t.disableFeature(e),t._features[e].featureImplementation.dispose()})},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,d=0;if(typeof e=="string"){if(!e)throw new Error("Error in provided version - "+s+" ("+e+")");if((d=e==="stable"?r.GetStableVersionOfFeature(s):e==="latest"?r.GetLatestVersionOfFeature(s):+e)===-1||isNaN(d))throw new Error("feature not found - "+s+" ("+e+")")}else d=e;var p=this._features[s],y=r.ConstructFeature(s,d,this._xrSessionManager,n);if(!y)throw new Error("feature not found - "+s);p&&this.disableFeature(s);var P=y();if(P.dependsOn&&!P.dependsOn.every(function(O){return!!a._features[O]}))throw new Error("Dependant features missing. Make sure the following features are enabled - "+P.dependsOn.join(", "));if(P.isCompatible())return this._features[s]={featureImplementation:P,enabled:!0,version:d,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 Ye.b.Warn("Feature "+s+" not compatible with the current environment/browser and was not enabled."),P},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){var e=this;return this.getEnabledFeatures().forEach(function(n){var i=e._features[n],o=i.featureImplementation.xrNativeFeatureName;o&&(i.required?(t.requiredFeatures=t.requiredFeatures||[],t.requiredFeatures.indexOf(o)===-1&&t.requiredFeatures.push(o)):(t.optionalFeatures=t.optionalFeatures||[],t.optionalFeatures.indexOf(o)===-1&&t.optionalFeatures.push(o)))}),t},r._AvailableFeatures={},r}(),Iu=function(){function r(t){var e=this;this.scene=t,this._nonVRCamera=null,this._originalSceneAutoClear=!0,this._supported=!1,this.onInitialXRPoseSetObservable=new x.c,this.onStateChangedObservable=new x.c,this.state=fn.NOT_IN_XR,this.sessionManager=new ys(t),this.camera=new Mu("",t,this.sessionManager),this.featuresManager=new Yn(this.sessionManager),t.onDisposeObservable.add(function(){e.exitXRAsync()})}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(fn.NOT_IN_XR),e.dispose(),n})},r.prototype.dispose=function(){this.camera.dispose(),this.onStateChangedObservable.clear(),this.onInitialXRPoseSetObservable.clear(),this.sessionManager.dispose(),this._nonVRCamera&&(this.scene.activeCamera=this._nonVRCamera)},r.prototype.enterXRAsync=function(t,e,n,i){var o=this;if(n===void 0&&(n=this.sessionManager.getWebXRRenderTarget()),i===void 0&&(i={}),!this._supported)throw"WebXR not supported in this browser or environment";return this._setState(fn.ENTERING_XR),e!=="viewer"&&e!=="local"&&(i.optionalFeatures=i.optionalFeatures||[],i.optionalFeatures.push(e)),this.featuresManager.extendXRSessionInitObject(i),t==="immersive-ar"&&e!=="unbounded"&&l.a.Warn("We recommend using 'unbounded' reference space type when using 'immersive-ar' session mode"),this.sessionManager.initializeSessionAsync(t,i).then(function(){return o.sessionManager.setReferenceSpaceTypeAsync(e)}).then(function(){return n.initializeXRLayerAsync(o.sessionManager.session)}).then(function(){return o.sessionManager.updateRenderStateAsync({depthFar:o.camera.maxZ,depthNear:o.camera.minZ,baseLayer:n.xrLayer})}).then(function(){return o.sessionManager.runXRRenderLoop(),o._originalSceneAutoClear=o.scene.autoClear,o._nonVRCamera=o.scene.activeCamera,o.scene.activeCamera=o.camera,t!=="immersive-ar"?o._nonXRToXRCamera():(o.scene.autoClear=!1,o.camera.compensateOnFirstFrame=!1),o.sessionManager.onXRSessionEnded.addOnce(function(){o.camera.rigCameras.forEach(function(a){a.outputRenderTarget=null}),o.scene.autoClear=o._originalSceneAutoClear,o.scene.activeCamera=o._nonVRCamera,t!=="immersive-ar"&&o.camera.compensateOnFirstFrame&&(o._nonVRCamera.setPosition?o._nonVRCamera.setPosition(o.camera.position):o._nonVRCamera.position.copyFrom(o.camera.position)),o._setState(fn.NOT_IN_XR)}),o.sessionManager.onXRFrameObservable.addOnce(function(){o._setState(fn.IN_XR)}),o.sessionManager}).catch(function(a){throw console.log(a),console.log(a.message),o._setState(fn.NOT_IN_XR),a})},r.prototype.exitXRAsync=function(){return this.state!==fn.IN_XR?Promise.resolve():(this._setState(fn.EXITING_XR),this.sessionManager.exitXRAsync())},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}(),Cr=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 x.c,this.onButtonStateChangedObservable=new x.c}return Object.defineProperty(r.prototype,"axes",{get:function(){return this._axes}
6709,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}(),xr=function(){function r(t,e,n,i,o){var a=this;this.scene=t,this.layout=e,this.gamepadObject=n,this.handedness=i,this._initComponent=function(s){if(s){var d=a.layout.components[s],p=d.type,y=d.gamepadIndices.button,P=[];d.gamepadIndices.xAxis!==void 0&&d.gamepadIndices.yAxis!==void 0&&P.push(d.gamepadIndices.xAxis,d.gamepadIndices.yAxis),a.components[s]=new Cr(s,p,y,P)}},this._modelReady=!1,this.components={},this.disableAnimation=!1,this.onModelLoadedObservable=new x.c,e.components&&Object.keys(e.components).forEach(this._initComponent)}return r.prototype.dispose=function(){var t=this;this.getComponentIds().forEach(function(e){return t.getComponent(e).dispose()}),this.rootMesh&&this.rootMesh.dispose()},r.prototype.getAllComponentsOfType=function(t){var e=this;return this.getComponentIds().map(function(n){return e.components[n]}).filter(function(n){return n.type===t})},r.prototype.getComponent=function(t){return this.components[t]},r.prototype.getComponentIds=function(){return Object.keys(this.components)},r.prototype.getComponentOfType=function(t){return this.getAllComponentsOfType(t)[0]||null},r.prototype.getMainComponent=function(){return this.getComponent(this.layout.selectComponentId)},r.prototype.loadModel=function(){return Object(c.b)(this,void 0,void 0,function(){var t,e,n=this;return Object(c.e)(this,function(i){return t=!this._getModelLoadingConstraints(),e=this._getGenericFilenameAndPath(),t?l.a.Warn("Falling back to generic models"):e=this._getFilenameAndPath(),[2,new Promise(function(o,a){Ut.ImportMesh("",e.path,e.filename,n.scene,function(s){t?n._getGenericParentMesh(s):n._setRootMesh(s),n._processLoadedModel(s),n._modelReady=!0,n.onModelLoadedObservable.notifyObservers(n),o(!0)},null,function(s,d){l.a.Log(d),l.a.Warn("Failed to retrieve controller model of type "+n.profileId+" from the remote server: "+e.path+e.filename),a(d)})})]})})},r.prototype.updateFromXRFrame=function(t){var e=this;
6709this.getComponentIds().forEach(function(n){return e.getComponent(n).update(e.gamepadObject)}),this.updateModel(t)},Object.defineProperty(r.prototype,"handness",{get:function(){return this.handedness},enumerable:!1,configurable:!0}),r.prototype.pulse=function(t,e,n){return n===void 0&&(n=0),this.gamepadObject.hapticActuators&&this.gamepadObject.hapticActuators[n]?this.gamepadObject.hapticActuators[n].pulse(t,e):Promise.resolve(!1)},r.prototype._getChildByName=function(t,e){return t.getChildren(function(n){return n.name===e},!1)[0]},r.prototype._getImmediateChildByName=function(t,e){return t.getChildren(function(n){return n.name==e},!0)[0]},r.prototype._lerpTransform=function(t,e,n){if(t.minMesh&&t.maxMesh&&t.valueMesh&&t.minMesh.rotationQuaternion&&t.maxMesh.rotationQuaternion&&t.valueMesh.rotationQuaternion){var i=n?.5*e+.5:e;u.b.SlerpToRef(t.minMesh.rotationQuaternion,t.maxMesh.rotationQuaternion,i,t.valueMesh.rotationQuaternion),u.e.LerpToRef(t.minMesh.position,t.maxMesh.position,i,t.valueMesh.position)}},r.prototype.updateModel=function(t){this._modelReady&&this._updateModel(t)},r.prototype._getGenericFilenameAndPath=function(){return{filename:"generic.babylon",path:"https://controllers.babylonjs.com/generic/"}},r.prototype._getGenericParentMesh=function(t){var e=this;this.rootMesh=new De.a(this.profileId+" "+this.handedness,this.scene),t.forEach(function(n){n.parent||(n.isPickable=!1,n.setParent(e.rootMesh))}),this.rootMesh.rotationQuaternion=u.b.FromEulerAngles(0,Math.PI,0)},r}(),Hs=function(r){function t(e,n,i){var o=r.call(this,e,w_[i],n,i)||this;return o.profileId=t.ProfileId,o}return Object(c.d)(t,r),t.prototype._getFilenameAndPath=function(){return{filename:"generic.babylon",path:"https://controllers.babylonjs.com/generic/"}},t.prototype._getModelLoadingConstraints=function(){return!0},t.prototype._processLoadedModel=function(e){},t.prototype._setRootMesh=function(e){var n=this;this.rootMesh=new De.a(this.profileId+" "+this.handedness,this.scene),e.forEach(function(i){i.isPickable=!1,i.parent||i.setParent(n.rootMesh)}),this.rootMesh.rotationQuaternion=u.b.FromEulerAngles(0,Math.PI,0)},t.prototype._updateModel=function(){},t.ProfileId="generic-trigger",t}(xr),w_={left:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"generic-trigger-left",assetPath:"left.glb"},right:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"generic-trigger-right",assetPath:"right.glb"},none:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"generic-trigger-none",assetPath:"none.glb"}},Du=function(r){function t(e,n,i,o){var a=r.call(this,e,i.layouts[n.handedness||"none"],n.gamepad,n.handedness)||this;return a._repositoryUrl=o,a._buttonMeshMapping={},a._touchDots={},a.profileId=i.profileId,a}return Object(c.d)(t,r),t.prototype.dispose=function(){var e=this;r.prototype.dispose.call(this),Object.keys(this._touchDots).forEach(function(n){e._touchDots[n].dispose()})},t.prototype._getFilenameAndPath=function(){return{filename:this.layout.assetPath,path:this._repositoryUrl+"/profiles/"+this.profileId+"/"}},t.prototype._getModelLoadingConstraints=function(){var e=Ut.IsPluginForExtensionAvailable(".glb");return e||l.a.Warn("glTF / glb loaded was not registered, using generic controller instead"),e},t.prototype._processLoadedModel=function(e){var n=this;this.getComponentIds().forEach(function(i){var o=n.layout.components[i];n._buttonMeshMapping[i]={mainMesh:n._getChildByName(n.rootMesh,o.rootNodeName),states:{}},Object.keys(o.visualResponses).forEach(function(a){var s=o.visualResponses[a];if(s.valueNodeProperty==="transform")n._buttonMeshMapping[i].states[a]={valueMesh:n._getChildByName(n.rootMesh,s.valueNodeName),minMesh:n._getChildByName(n.rootMesh,s.minNodeName),maxMesh:n._getChildByName(n.rootMesh,s.maxNodeName)};else{var d=o.type===Cr.TOUCHPAD_TYPE&&o.touchPointNodeName?o.touchPointNodeName:s.valueNodeName;if(n._buttonMeshMapping[i].states[a]={valueMesh:n._getChildByName(n.rootMesh,d)},o.type===Cr.TOUCHPAD_TYPE&&!n._touchDots[a]){var p=Nn.a.CreateSphere(a+"dot",{diameter:.0015,segments:8},n.scene);p.material=new Ft.a(a+"mat",n.scene),p.material.diffuseColor=M.a.Red(),p.parent=n._buttonMeshMapping[i].states[a].valueMesh||null,p.isVisible=!1,n._touchDots[a]=p}}})})},t.prototype._setRootMesh=function(e){var n;this.rootMesh=new De.a(this.profileId+"-"+this.handedness,this.scene),this.rootMesh.isPickable=!1;for(var i=0;i<e.length;i++){var o=e[i];o.isPickable=!1,o.parent||(n=o)}n&&n.setParent(this.rootMesh),this.scene.useRightHandedSystem||this.rootMesh.rotate(ye.a.Y,Math.PI,ye.c.WORLD)},t.prototype._updateModel=function(e){var n=this;
6709this.disableAnimation||this.getComponentIds().forEach(function(i){var o=n.getComponent(i);if(o.hasChanges){var a=n._buttonMeshMapping[i],s=n.layout.components[i];Object.keys(s.visualResponses).forEach(function(d){var p=s.visualResponses[d],y=o.value;if(p.componentProperty==="xAxis"?y=o.axes.x:p.componentProperty==="yAxis"&&(y=o.axes.y),p.valueNodeProperty==="transform")n._lerpTransform(a.states[d],y,p.componentProperty!=="button");else{var P=a.states[d].valueMesh;P&&(P.isVisible=o.touched||o.pressed),n._touchDots[d]&&(n._touchDots[d].isVisible=o.touched||o.pressed)}})}})},t}(xr),wn=function(){function r(){}return r.ClearProfilesCache=function(){this._ProfilesList=null,this._ProfileLoadingPromises={}},r.DefaultFallbacks=function(){this.RegisterFallbacksForProfileId("google-daydream",["generic-touchpad"]),this.RegisterFallbacksForProfileId("htc-vive-focus",["generic-trigger-touchpad"]),this.RegisterFallbacksForProfileId("htc-vive",["generic-trigger-squeeze-touchpad"]),this.RegisterFallbacksForProfileId("magicleap-one",["generic-trigger-squeeze-touchpad"]),this.RegisterFallbacksForProfileId("windows-mixed-reality",["generic-trigger-squeeze-touchpad-thumbstick"]),this.RegisterFallbacksForProfileId("microsoft-mixed-reality",["windows-mixed-reality","generic-trigger-squeeze-touchpad-thumbstick"]),this.RegisterFallbacksForProfileId("oculus-go",["generic-trigger-touchpad"]),this.RegisterFallbacksForProfileId("oculus-touch-v2",["oculus-touch","generic-trigger-squeeze-thumbstick"]),this.RegisterFallbacksForProfileId("oculus-touch",["generic-trigger-squeeze-thumbstick"]),this.RegisterFallbacksForProfileId("samsung-gearvr",["windows-mixed-reality","generic-trigger-squeeze-touchpad-thumbstick"]),this.RegisterFallbacksForProfileId("samsung-odyssey",["generic-touchpad"]),this.RegisterFallbacksForProfileId("valve-index",["generic-trigger-squeeze-touchpad-thumbstick"])},r.FindFallbackWithProfileId=function(t){var e=this._Fallbacks[t]||[];return e.unshift(t),e},r.GetMotionControllerWithXRInput=function(t,e,n){var i=this,o=[];if(n&&o.push(n),o.push.apply(o,t.profiles||[]),o.length&&!o[0]&&o.pop(),t.gamepad&&t.gamepad.id)switch(t.gamepad.id){case(t.gamepad.id.match(/oculus touch/gi)?t.gamepad.id:void 0):o.push("oculus-touch-v2")}var a=o.indexOf("windows-mixed-reality");if(a!==-1&&o.splice(a,0,"microsoft-mixed-reality"),o.length||o.push("generic-trigger"),this.UseOnlineRepository){var s=this.PrioritizeOnlineRepository?this._LoadProfileFromRepository:this._LoadProfilesFromAvailableControllers,d=this.PrioritizeOnlineRepository?this._LoadProfilesFromAvailableControllers:this._LoadProfileFromRepository;return s.call(this,o,t,e).catch(function(){return d.call(i,o,t,e)})}return this._LoadProfilesFromAvailableControllers(o,t,e)},r.RegisterController=function(t,e){this._AvailableControllers[t]=e},r.RegisterFallbacksForProfileId=function(t,e){var n;this._Fallbacks[t]?(n=this._Fallbacks[t]).push.apply(n,e):this._Fallbacks[t]=e},r.UpdateProfilesList=function(){return this._ProfilesList=Ye.b.LoadFileAsync(this.BaseRepositoryUrl+"/profiles/profilesList.json",!1).then(function(t){return JSON.parse(t.toString())}),this._ProfilesList},r._LoadProfileFromRepository=function(t,e,n){var i=this;return Promise.resolve().then(function(){return i._ProfilesList?i._ProfilesList:i.UpdateProfilesList()}).then(function(o){for(var a=0;a<t.length;++a)if(t[a]&&o[t[a]])return t[a];throw new Error("neither controller "+t[0]+" nor all fallbacks were found in the repository,")}).then(function(o){return i._ProfileLoadingPromises[o]||(i._ProfileLoadingPromises[o]=Ye.b.LoadFileAsync(i.BaseRepositoryUrl+"/profiles/"+o+"/profile.json",!1).then(function(a){return JSON.parse(a)})),i._ProfileLoadingPromises[o]}).then(function(o){return new Du(n,e,o,i.BaseRepositoryUrl)})},r._LoadProfilesFromAvailableControllers=function(t,e,n){for(var i=0;i<t.length;++i)if(t[i])for(var o=this.FindFallbackWithProfileId(t[i]),a=0;a<o.length;++a){var s=this._AvailableControllers[o[a]];if(s)return Promise.resolve(s(e,n))}throw new Error("no controller requested was found in the available controllers list")},r._AvailableControllers={},r._Fallbacks={},r._ProfileLoadingPromises={},r.BaseRepositoryUrl="https://immersive-web.github.io/webxr-input-profiles/packages/viewer/dist",r.PrioritizeOnlineRepository=!0,r.UseOnlineRepository=!0,r}();wn.RegisterController(Hs.ProfileId,function(r,t){return new Hs(t,r.gamepad,r.handedness)}),wn.DefaultFallbacks();var F_=0,Lu=function(){function r(t,e,n){var i=this;n===void 0&&(n={}),this._scene=t,this.inputSource=e,this._options=n,this._tmpVector=new u.e,this._disposed=!1,this.onDisposeObservable=new x.c,this.onMeshLoadedObservable=new x.c,this.onMotionControllerInitObservable=new x.c,this._uniqueId="controller-"+F_+++"-"+e.targetRayMode+"-"+e.handedness,this.pointer=new Dt.a(this._uniqueId+"-pointer",t),this.pointer.rotationQuaternion=new u.b,this.inputSource.gripSpace&&(this.grip=new Dt.a(this._uniqueId+"-grip",this._scene),this.grip.rotationQuaternion=new u.b),this._tmpVector.set(0,0,this._scene.useRightHandedSystem?-1:1),this.inputSource.gamepad&&wn.GetMotionControllerWithXRInput(e,t,this._options.forceControllerProfile).then(function(o){i.motionController=o,i.onMotionControllerInitObservable.notifyObservers(o),i._options.doNotLoadControllerMesh||i.motionController.loadModel().then(function(a){var s;a&&i.motionController&&i.motionController.rootMesh&&(i._options.renderingGroupId&&(i.motionController.rootMesh.renderingGroupId=i._options.renderingGroupId,i.motionController.rootMesh.getChildMeshes(!1).forEac
6709h(function(d){return d.renderingGroupId=i._options.renderingGroupId})),i.onMeshLoadedObservable.notifyObservers(i.motionController.rootMesh),i.motionController.rootMesh.parent=i.grip||i.pointer,i.motionController.disableAnimation=!!i._options.disableMotionControllerAnimation),i._disposed&&((s=i.motionController)===null||s===void 0||s.dispose())})},function(){Ye.b.Warn("Could not find a matching motion controller for the registered input source")})}return Object.defineProperty(r.prototype,"uniqueId",{get:function(){return this._uniqueId},enumerable:!1,configurable:!0}),r.prototype.dispose=function(){this.grip&&this.grip.dispose(),this.motionController&&this.motionController.dispose(),this.pointer.dispose(),this.onMotionControllerInitObservable.clear(),this.onMeshLoadedObservable.clear(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this._disposed=!0},r.prototype.getWorldPointerRayToRef=function(t,e){e===void 0&&(e=!1);var n=e&&this.grip?this.grip:this.pointer;u.e.TransformNormalToRef(this._tmpVector,n.getWorldMatrix(),t.direction),t.direction.normalize(),t.origin.copyFrom(n.absolutePosition),t.length=1e3},r.prototype.updateFromXRFrame=function(t,e){var n=t.getPose(this.inputSource.targetRaySpace,e);if(n){var i=n.transform.position;this.pointer.position.set(i.x,i.y,i.z);var o=n.transform.orientation;this.pointer.rotationQuaternion.set(o.x,o.y,o.z,o.w),this._scene.useRightHandedSystem||(this.pointer.position.z*=-1,this.pointer.rotationQuaternion.z*=-1,this.pointer.rotationQuaternion.w*=-1)}if(this.inputSource.gripSpace&&this.grip){var a=t.getPose(this.inputSource.gripSpace,e);if(a){i=a.transform.position;var s=a.transform.orientation;this.grip.position.set(i.x,i.y,i.z),this.grip.rotationQuaternion.set(s.x,s.y,s.z,s.w),this._scene.useRightHandedSystem||(this.grip.position.z*=-1,this.grip.rotationQuaternion.z*=-1,this.grip.rotationQuaternion.w*=-1)}}this.motionController&&this.motionController.updateFromXRFrame(t)},r}(),Nu=function(){function r(t,e,n){var i=this;if(n===void 0&&(n={}),this.xrSessionManager=t,this.xrCamera=e,this.options=n,this.controllers=[],this.onControllerAddedObservable=new x.c,this.onControllerRemovedObservable=new x.c,this._onInputSourcesChange=function(o){i._addAndRemoveControllers(o.added,o.removed)},this._sessionEndedObserver=this.xrSessionManager.onXRSessionEnded.add(function(){i._addAndRemoveControllers([],i.controllers.map(function(o){return o.inputSource}))}),this._sessionInitObserver=this.xrSessionManager.onXRSessionInit.add(function(o){o.addEventListener("inputsourceschange",i._onInputSourcesChange)}),this._frameObserver=this.xrSessionManager.onXRFrameObservable.add(function(o){i.controllers.forEach(function(a){a.updateFromXRFrame(o,i.xrSessionManager.referenceSpace)})}),this.options.customControllersRepositoryURL&&(wn.BaseRepositoryUrl=this.options.customControllersRepositoryURL),wn.UseOnlineRepository=!this.options.disableOnlineControllerRepository,wn.UseOnlineRepository)try{wn.UpdateProfilesList().catch(function(){wn.UseOnlineRepository=!1})}catch{wn.UseOnlineRepository=!1}}return r.prototype._addAndRemoveControllers=function(t,e){for(var n=this,i=this.controllers.map(function(P){return P.inputSource}),o=0,a=t;o<a.length;o++){var s=a[o];if(i.indexOf(s)===-1){var d=new Lu(this.xrSessionManager.scene,s,Object(c.a)(Object(c.a)({},this.options.controllerOptions||{}),{forceControllerProfile:this.options.forceInputProfile,doNotLoadControllerMesh:this.options.doNotLoadControllerMeshes,disableMotionControllerAnimation:this.options.disableControllerAnimation}));this.controllers.push(d),this.onControllerAddedObservable.notifyObservers(d)}}var p=[],y=[];this.controllers.forEach(function(P){e.indexOf(P.inputSource)===-1?p.push(P):y.push(P)}),this.controllers=p,y.forEach(function(P){n.onControllerRemovedObservable.notifyObservers(P),P.dispose()})},r.prototype.dispose=function(){this.controllers.forEach(function(t){t.dispose()}),this.xrSessionManager.onXRFrameObservable.remove(this._frameObserver),this.xrSessionManager.onXRSessionInit.remove(this._sessionInitObserver),this.xrSessionManager.onXRSessionEnded.remove(this._sessionEndedObserver),this.onControllerAddedObservable.clear(),this.onControllerRemovedObservable.clear()},r}(),ri=function(){function r(t){this._xrSessionManager=t,this._attached=!1,this._removeOnDetach=[],this.isDisposed=!1,this.disableAutoAttach=!1,this.xrNativeFeatureName=""}return Object.defineProperty(r.prototype,"attached",{get:function(){return this._attached}
6709,enumerable:!1,configurable:!0}),r.prototype.attach=function(t){var e=this;if(this.isDisposed)return!1;if(t)this.attached&&this.detach();else if(this.attached)return!1;return this._attached=!0,this._addNewAttachObserver(this._xrSessionManager.onXRFrameObservable,function(n){return e._onXRFrame(n)}),!0},r.prototype.detach=function(){return this._attached?(this._attached=!1,this._removeOnDetach.forEach(function(t){t.observable.remove(t.observer)}),!0):(this.disableAutoAttach=!0,!1)},r.prototype.dispose=function(){this.detach(),this.isDisposed=!0},r.prototype.isCompatible=function(){return!0},r.prototype._addNewAttachObserver=function(t,e){this._removeOnDetach.push({observable:t,observer:t.add(e)})},r}(),uo=function(r){function t(e,n){var i=r.call(this,e)||this;return i._options=n,i._attachController=function(o){if(!i._controllers[o.uniqueId]){var a=i._generateNewMeshPair(o.pointer),s=a.laserPointer,d=a.selectionMesh;switch(i._controllers[o.uniqueId]={xrController:o,laserPointer:s,selectionMesh:d,meshUnderPointer:null,pick:null,tmpRay:new dn.a(new u.e,new u.e),id:t._idCounter++},i._attachedController?!i._options.enablePointerSelectionOnAllControllers&&i._options.preferredHandedness&&o.inputSource.handedness===i._options.preferredHandedness&&(i._attachedController=o.uniqueId):i._options.enablePointerSelectionOnAllControllers||(i._attachedController=o.uniqueId),o.inputSource.targetRayMode){case"tracked-pointer":return i._attachTrackedPointerRayMode(o);case"gaze":return i._attachGazeMode(o);case"screen":return i._attachScreenRayMode(o)}}},i._controllers={},i._tmpVectorForPickCompare=new u.e,i.disablePointerLighting=!0,i.disableSelectionMeshLighting=!0,i.displayLaserPointer=!0,i.displaySelectionMesh=!0,i.laserPointerPickedColor=new M.a(.9,.9,.9),i.laserPointerDefaultColor=new M.a(.7,.7,.7),i.selectionMeshDefaultColor=new M.a(.8,.8,.8),i.selectionMeshPickedColor=new M.a(.3,.3,1),i._identityMatrix=u.a.Identity(),i._screenCoordinatesRef=u.e.Zero(),i._viewportRef=new Wn.a(0,0,0,0),i._scene=i._xrSessionManager.scene,i}return Object(c.d)(t,r),t.prototype.attach=function(){var e=this;if(!r.prototype.attach.call(this))return!1;if(this._options.xrInput.controllers.forEach(this._attachController),this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable,this._attachController),this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable,function(s){e._detachController(s.uniqueId)}),this._scene.constantlyUpdateMeshUnderPointer=!0,this._options.gazeCamera){var n=this._options.gazeCamera,i=this._generateNewMeshPair(n),o=i.laserPointer,a=i.selectionMesh;this._controllers.camera={webXRCamera:n,laserPointer:o,selectionMesh:a,meshUnderPointer:null,pick:null,tmpRay:new dn.a(new u.e,new u.e),id:t._idCounter++},this._attachGazeMode()}return!0},t.prototype.detach=function(){var e=this;return!!r.prototype.detach.call(this)&&(Object.keys(this._controllers).forEach(function(n){e._detachController(n)}),!0)},t.prototype.getMeshUnderPointer=function(e){return this._controllers[e]?this._controllers[e].meshUnderPointer:null},t.prototype.getXRControllerByPointerId=function(e){for(var n=Object.keys(this._controllers),i=0;i<n.length;++i)if(this._controllers[n[i]].id===e)return this._controllers[n[i]].xrController||null;return null},t.prototype._onXRFrame=function(e){var n=this;Object.keys(this._controllers).forEach(function(i){var o,a=n._controllers[i];if(!n._options.enablePointerSelectionOnAllControllers&&i!==n._attachedController)return a.selectionMesh.isVisible=!1,a.laserPointer.isVisible=!1,void(a.pick=null);if(a.laserPointer.isVisible=n.displayLaserPointer,a.xrController)o=a.xrController.pointer.position,a.xrController.getWorldPointerRayToRef(a.tmpRay);else{if(!a.webXRCamera)return;o=a.webXRCamera.position,a.webXRCamera.getForwardRayToRef(a.tmpRay)}if(n._options.maxPointerDistance&&(a.tmpRay.length=n._options.maxPointerDistance),!n._options.disableScenePointerVectorUpdate&&o){var s=n._xrSessionManager.scene,d=n._options.xrInput.xrCamera;d&&(d.viewport.toGlobalToRef(s.getEngine().getRenderWidth(),s.getEngine().getRenderHeight(),n._viewportRef),u.e.ProjectToRef(o,n._identityMatrix,s.getTransformMatrix(),n._viewportRef,n._screenCoordinatesRef),s.pointerX=n._screenCoordinatesRef.x,s.pointerY=n._screenCoordinatesRef.y)}a.pick=n._scene.pickWithRay(a.tmpRay,n._scene.pointerMovePredicate||n.raySelectionPredicate);var p=a.pick;if(p&&p.pickedPoint&&p.hit){n._updatePointerDistance(a.laserPointer,p.distance),a.selectionMesh.position.copyFrom(p.pickedPoint),a.selectionMesh.scaling.x=Math.sqrt(p.distance),a.selectionMesh.scaling.y=Math.sqrt(p.distance),a.selectionMesh.scaling.z=M
6709ath.sqrt(p.distance);var y=n._convertNormalToDirectionOfRay(p.getNormal(!0),a.tmpRay);if(a.selectionMesh.position.copyFrom(p.pickedPoint),y){var P=u.e.Cross(ye.a.Y,y),O=u.e.Cross(y,P);u.e.RotationFromAxisToRef(O,y,P,a.selectionMesh.rotation),a.selectionMesh.position.addInPlace(y.scale(.001))}a.selectionMesh.isVisible=n.displaySelectionMesh,a.meshUnderPointer=p.pickedMesh}else a.selectionMesh.isVisible=!1,n._updatePointerDistance(a.laserPointer,1),a.meshUnderPointer=null})},t.prototype._attachGazeMode=function(e){var n=this,i=this._controllers[e&&e.uniqueId||"camera"],o=this._options.timeToSelect||3e3,a=this._options.useUtilityLayer?this._options.customUtilityLayerScene||xn.a.DefaultUtilityLayer.utilityLayerScene:this._scene,s=new tr.a,d=mr.CreateTorus("selection",{diameter:.0525,thickness:.015,tessellation:20},a);d.isVisible=!1,d.isPickable=!1,d.parent=i.selectionMesh;var p=0,y=!1;i.onFrameObserver=this._xrSessionManager.onXRFrameObservable.add(function(){if(i.pick){if(i.laserPointer.material.alpha=0,d.isVisible=!1,i.pick.hit)if(n._pickingMoved(s,i.pick))y&&(n._options.disablePointerUpOnTouchOut||n._scene.simulatePointerUp(i.pick,{pointerId:i.id})),y=!1,p=0;else if(p>o/10&&(d.isVisible=!0),(p+=n._scene.getEngine().getDeltaTime())>=o)n._scene.simulatePointerDown(i.pick,{pointerId:i.id}),y=!0,n._options.disablePointerUpOnTouchOut&&n._scene.simulatePointerUp(i.pick,{pointerId:i.id}),d.isVisible=!1;else{var P=1-p/o;d.scaling.set(P,P,P)}else y=!1,p=0;n._scene.simulatePointerMove(i.pick,{pointerId:i.id}),s=i.pick}}),this._options.renderingGroupId!==void 0&&(d.renderingGroupId=this._options.renderingGroupId),e&&e.onDisposeObservable.addOnce(function(){i.pick&&!n._options.disablePointerUpOnTouchOut&&y&&n._scene.simulatePointerUp(i.pick,{pointerId:i.id}),d.dispose()})},t.prototype._attachScreenRayMode=function(e){var n=this,i=this._controllers[e.uniqueId],o=!1;i.onFrameObserver=this._xrSessionManager.onXRFrameObservable.add(function(){!i.pick||n._options.disablePointerUpOnTouchOut&&o||(o?n._scene.simulatePointerMove(i.pick,{pointerId:i.id}):(n._scene.simulatePointerDown(i.pick,{pointerId:i.id}),o=!0,n._options.disablePointerUpOnTouchOut&&n._scene.simulatePointerUp(i.pick,{pointerId:i.id})))}),e.onDisposeObservable.addOnce(function(){i.pick&&o&&!n._options.disablePointerUpOnTouchOut&&n._scene.simulatePointerUp(i.pick,{pointerId:i.id})})},t.prototype._attachTrackedPointerRayMode=function(e){var n=this,i=this._controllers[e.uniqueId];if(this._options.forceGazeMode)return this._attachGazeMode(e);if(i.onFrameObserver=this._xrSessionManager.onXRFrameObservable.add(function(){i.laserPointer.material.disableLighting=n.disablePointerLighting,i.selectionMesh.material.disableLighting=n.disableSelectionMeshLighting,i.pick&&n._scene.simulatePointerMove(i.pick,{pointerId:i.id})}),e.inputSource.gamepad){var o=function(d){n._options.overrideButtonId&&(i.selectionComponent=d.getComponent(n._options.overrideButtonId)),i.selectionComponent||(i.selectionComponent=d.getMainComponent()),i.onButtonChangedObserver=i.selectionComponent.onButtonStateChangedObservable.add(function(p){if(p.changes.pressed){var y=p.changes.pressed.current;i.pick?(n._options.enablePointerSelectionOnAllControllers||e.uniqueId===n._attachedController)&&(y?(n._scene.simulatePointerDown(i.pick,{pointerId:i.id}),i.selectionMesh.material.emissiveColor=n.selectionMeshPickedColor,i.laserPointer.material.emissiveColor=n.laserPointerPickedColor):(n._scene.simulatePointerUp(i.pick,{pointerId:i.id}),i.selectionMesh.material.emissiveColor=n.selectionMeshDefaultColor,i.laserPointer.material.emissiveColor=n.laserPointerDefaultColor)):!y||n._options.enablePointerSelectionOnAllControllers||n._options.disableSwitchOnClick||(n._attachedController=e.uniqueId)}})};e.motionController?o(e.motionController):e.onMotionControllerInitObservable.add(o)}else{var a=function(d){i.xrController&&d.inputSource===i.xrController.inputSource&&i.pick&&(n._scene.simulatePointerDown(i.pick,{pointerId:i.id}),i.selectionMesh.material.emissiveColor=n.selectionMeshPickedColor,i.laserPointer.material.emissiveColor=n.laserPointerP
6709ickedColor)},s=function(d){i.xrController&&d.inputSource===i.xrController.inputSource&&i.pick&&(n._scene.simulatePointerUp(i.pick,{pointerId:i.id}),i.selectionMesh.material.emissiveColor=n.selectionMeshDefaultColor,i.laserPointer.material.emissiveColor=n.laserPointerDefaultColor)};i.eventListeners={selectend:s,selectstart:a},this._xrSessionManager.session.addEventListener("selectstart",a),this._xrSessionManager.session.addEventListener("selectend",s)}},t.prototype._convertNormalToDirectionOfRay=function(e,n){return e&&Math.acos(u.e.Dot(e,n.direction))<Math.PI/2&&e.scaleInPlace(-1),e},t.prototype._detachController=function(e){var n=this,i=this._controllers[e];if(i&&(i.selectionComponent&&i.onButtonChangedObserver&&i.selectionComponent.onButtonStateChangedObservable.remove(i.onButtonChangedObserver),i.onFrameObserver&&this._xrSessionManager.onXRFrameObservable.remove(i.onFrameObserver),i.eventListeners&&Object.keys(i.eventListeners).forEach(function(a){var s=i.eventListeners&&i.eventListeners[a];s&&n._xrSessionManager.session.removeEventListener(a,s)}),i.selectionMesh.dispose(),i.laserPointer.dispose(),delete this._controllers[e],this._attachedController===e)){var o=Object.keys(this._controllers);o.length?this._attachedController=o[0]:this._attachedController=""}},t.prototype._generateNewMeshPair=function(e){var n=this._options.useUtilityLayer?this._options.customUtilityLayerScene||xn.a.DefaultUtilityLayer.utilityLayerScene:this._scene,i=ui.a.CreateCylinder("laserPointer",{height:1,diameterTop:2e-4,diameterBottom:.004,tessellation:20,subdivisions:1},n);i.parent=e;var o=new Ft.a("laserPointerMat",n);o.emissiveColor=this.laserPointerDefaultColor,o.alpha=.7,i.material=o,i.rotation.x=Math.PI/2,this._updatePointerDistance(i,1),i.isPickable=!1;var a=mr.CreateTorus("gazeTracker",{diameter:.0105,thickness:.0075,tessellation:20},n);a.bakeCurrentTransformIntoVertices(),a.isPickable=!1,a.isVisible=!1;var s=new Ft.a("targetMat",n);return s.specularColor=M.a.Black(),s.emissiveColor=this.selectionMeshDefaultColor,s.backFaceCulling=!1,a.material=s,this._options.renderingGroupId!==void 0&&(i.renderingGroupId=this._options.renderingGroupId,a.renderingGroupId=this._options.renderingGroupId),{laserPointer:i,selectionMesh:a}},t.prototype._pickingMoved=function(e,n){var i;if(!e.hit||!n.hit||!(e.pickedMesh&&e.pickedPoint&&n.pickedMesh&&n.pickedPoint)||e.pickedMesh!==n.pickedMesh)return!0;(i=e.pickedPoint)===null||i===void 0||i.subtractToRef(n.pickedPoint,this._tmpVectorForPickCompare),this._tmpVectorForPickCompare.set(Math.abs(this._tmpVectorForPickCompare.x),Math.abs(this._tmpVectorForPickCompare.y),Math.abs(this._tmpVectorForPickCompare.z));var o=.01*(this._options.gazeModePointerMovedFactor||1)*n.distance;return this._tmpVectorForPickCompare.length()>o}
6709,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},Object.defineProperty(t.prototype,"lasterPointerDefaultColor",{get:function(){return this.laserPointerDefaultColor},enumerable:!1,configurable:!0}),t._idCounter=200,t.Name=ii.POINTER_SELECTION,t.Version=1,t}(ri);Yn.AddWebXRFeature(uo.Name,function(r,t){return function(){return new uo(r,t)}},uo.Version,!0);var Vi,wu=function(){function r(t,e,n){this.element=t,this.sessionMode=e,this.referenceSpaceType=n}return r.prototype.update=function(t){},r}(),B_=function(){},Fu=function(){function r(t,e){var n=this;if(this.scene=t,this.options=e,this._activeButton=null,this._buttons=[],this.activeButtonChangedObservable=new x.c,this.overlay=document.createElement("div"),this.overlay.classList.add("xr-button-overlay"),this.overlay.style.cssText="z-index:11;position: absolute; right: 20px;bottom: 50px;",typeof window<"u"&&window.location&&window.location.protocol==="http:"&&Ye.b.Warn("WebXR can only be served over HTTPS"),e.customButtons)this._buttons=e.customButtons;else{var i=e.sessionMode||"immersive-vr",o=e.referenceSpaceType||"local-floor",a=".babylonVRicon { color: #868686; border-color: #868686; border-style: solid; margin-left: 10px; height: 50px; width: 80px; background-color: rgba(51,51,51,0.7); background-image: url("+(typeof SVGSVGElement>"u"?"https://cdn.babylonjs.com/Assets/vrButton.png":"data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%222048%22%20height%3D%221152%22%20viewBox%3D%220%200%202048%201152%22%20version%3D%221.1%22%3E%3Cpath%20transform%3D%22rotate%28180%201024%2C576.0000000000001%29%22%20d%3D%22m1109%2C896q17%2C0%2030%2C-12t13%2C-30t-12.5%2C-30.5t-30.5%2C-12.5l-170%2C0q-18%2C0%20-30.5%2C12.5t-12.5%2C30.5t13%2C30t30%2C12l170%2C0zm-85%2C256q59%2C0%20132.5%2C-1.5t154.5%2C-5.5t164.5%2C-11.5t163%2C-20t150%2C-30t124.5%2C-41.5q23%2C-11%2042%2C-24t38%2C-30q27%2C-25%2041%2C-61.5t14%2C-72.5l0%2C-257q0%2C-123%20-47%2C-232t-128%2C-190t-190%2C-128t-232%2C-47l-81%2C0q-37%2C0%20-68.5%2C14t-60.5%2C34.5t-55.5%2C45t-53%2C45t-53%2C34.5t-55.5%2C14t-55.5%2C-14t-53%2C-34.5t-53%2C-45t-55.5%2C-45t-60.5%2C-34.5t-68.5%2C-14l-81%2C0q-123%2C0%20-232%2C47t-190%2C128t-128%2C190t-47%2C232l0%2C257q0%2C68%2038%2C115t97%2C73q54%2C24%20124.5%2C41.5t150%2C30t163%2C20t164.5%2C11.5t154.5%2C5.5t132.5%2C1.5zm939%2C-298q0%2C39%20-24.5%2C67t-58.5%2C42q-54%2C23%20-122%2C39.5t-143.5%2C28t-155.5%2C19t-157%2C11t-148.5%2C5t-129.5%2C1.5q-59%2C0%20-130%2C-1.5t-148%2C-5t-157%2C-11t-155.5%2C-19t-143.5%2C-28t-122%2C-39.5q-34%2C-14%20-58.5%2C-42t-24.5%2C-67l0%2C-257q0%2C-106%2040.5%2C-199t110%2C-162.5t162.5%2C-109.5t199%2C-40l81%2C0q27%2C0%2052%2C14t50%2C34.5t51%2C44.5t55.5%2C44.5t63.5%2C34.5t74%2C14t74%2C-14t63.5%2C-34.5t55.5%2C-44.5t51%2C-44.5t50%2C-34.5t52%2C-14l14%2C0q37%2C0%2070%2C0.5t64.5%2C4.5t63.5%2C12t68%2C23q71%2C30%20128.5%2C78.5t98.5%2C110t63.5%2C133.5t22.5%2C149l0%2C257z%22%20fill%3D%22white%22%20/%3E%3C/svg%3E%0A")+"); background-size: 80%; background-repeat:no-repeat; background-position: center; border: none; outline: none; transition: transform 0.125s ease-out } .babylonVRicon:hover { transform: scale(1.05) } .babylonVRicon:active {background-color: rgba(51,51,51,1) } .babylonVRicon:focus {background-color: rgba(51,51,51,1) }";a+='.babylonVRicon.vrdisplaypresenting { background-image: none;} .vrdisplaypresenting::after { content: "EXIT"} .xr-error::after { content: "ERROR"}';var s=document.createElement("style");s.appendChild(document.createTextNode(a)),document.getElementsByTagName("head")[0].appendChild(s);var d=document.createElement("button");d.className="babylonVRicon",d.title=i+" - "+o,this._buttons.push(new wu(d,i,o)),this._buttons[this._buttons.length-1].update=function(y){this.element.style.display=y===null||y===this?"":"none",d.className="babylonVRicon"+(y===this?" vrdisplaypresenting":"")},this._updateButtons(null)}var p=t.getEngine().getInputElement();p&&p.parentNode&&(p.parentNode.appendChild(this.overlay),t.onDisposeObservable.addOnce(function(){n.dispose()}))}return r.CreateAsync=function(t,e,n){var i=this,o=new r(t,n),a=o._buttons.map(function(s){return e.sessionManager.isSessionSupportedAsync(s.sessionMode)});return e.onStateChangedObservable.add(function(s){s==fn.NOT_IN_XR&&o._updateButtons(null)}
6709),Promise.all(a).then(function(s){return s.forEach(function(d,p){d?(o.overlay.appendChild(o._buttons[p].element),o._buttons[p].element.onclick=function(){return Object(c.b)(i,void 0,void 0,function(){var y,P,O;return Object(c.e)(this,function(U){switch(U.label){case 0:return e.state!=fn.IN_XR?[3,2]:[4,e.exitXRAsync()];case 1:return U.sent(),o._updateButtons(null),[3,6];case 2:if(e.state!=fn.NOT_IN_XR)return[3,6];if(!n.renderTarget)return[3,6];U.label=3;case 3:return U.trys.push([3,5,,6]),[4,e.enterXRAsync(o._buttons[p].sessionMode,o._buttons[p].referenceSpaceType,n.renderTarget,{optionalFeatures:n.optionalFeatures,requiredFeatures:n.requiredFeatures})];case 4:return U.sent(),o._updateButtons(o._buttons[p]),[3,6];case 5:return y=U.sent(),o._updateButtons(null),P=o._buttons[p].element,O=P.title,P.title="Error entering XR session : "+O,P.classList.add("xr-error"),n.onError&&n.onError(y),[3,6];case 6:return[2]}})})}):Ye.b.Warn('Session mode "'+o._buttons[p].sessionMode+'" not supported in browser')}),o})},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()},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 Ws(r){var t,e=0,n=Date.now();r.observableParameters=(t=r.observableParameters)!==null&&t!==void 0?t:{};var i=r.contextObservable.add(function(o){var a=Date.now(),s={startTime:n,currentTime:a,deltaTime:e=a-n,completeRate:e/r.timeout,payload:o};r.onTick&&r.onTick(s),r.breakCondition&&r.breakCondition()&&(r.contextObservable.remove(i),r.onAborted&&r.onAborted(s)),e>=r.timeout&&(r.contextObservable.remove(i),r.onEnded&&r.onEnded(s))},r.observableParameters.mask,r.observableParameters.insertFirst,r.observableParameters.scope);return i}(function(r){r[r.INIT=0]="INIT",r[r.STARTED=1]="STARTED",r[r.ENDED=2]="ENDED"})(Vi||(Vi={}));var U_=function(){function r(t){var e,n,i=this;this.onEachCountObservable=new x.c,this.onTimerAbortedObservable=new x.c,this.onTimerEndedObservable=new x.c,this.onStateChangedObservable=new x.c,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},d=i._breakOnNextTick||i._breakCondition(s);d||i._timer>=i._timeToEnd?i._stop(s,d):i.onEachCountObservable.notifyObservers(s)},this._setState(Vi.INIT),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},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===Vi.STARTED)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(Vi.STARTED)},r.prototype.stop=function(){this._state===Vi.STARTED&&(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(Vi.ENDED),e?this.onTimerAbortedObservable.notifyObservers(t):this.onTimerEndedObservable.notifyObservers(t)},r}(),ho=function(r){function t(e,n){var i=r.call(this,e)||this;return i._options=n,i._controllers={},i._snappedToPoint=!1,i._tmpRay=new dn.a(new u.e,new u.e),i._tmpVector=new u.e,i._tmpQuaternion=new u.b,i.backwardsMovementEnabled=!0,i.backwardsTeleportationDistance=.7,i.parabolicCheckRadius=5,i.parabolicRayEnabled=!0,i.straightRayEnabled=!0,i.rotationAngle=Math.PI/8,i._rotationEnabled=!0,i._attachController=function(o){if
6709(!(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}};var a=i._controllers[o.uniqueId];if(a.xrController.inputSource.targetRayMode==="tracked-pointer"&&a.xrController.inputSource.gamepad){var s=function(){if(o.motionController){var d=o.motionController.getComponentOfType(Cr.THUMBSTICK_TYPE)||o.motionController.getComponentOfType(Cr.TOUCHPAD_TYPE);if(!d||i._options.useMainComponentOnly){var p=o.motionController.getMainComponent();if(!p)return;a.teleportationComponent=p,a.onButtonChangedObserver=p.onButtonStateChangedObservable.add(function(){p.changes.pressed&&(p.changes.pressed.current?(a.teleportationState.forward=!0,i._currentTeleportationControllerId=a.xrController.uniqueId,a.teleportationState.baseRotation=i._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y,a.teleportationState.currentRotation=0,Ws({timeout:i._options.timeToTeleport||3e3,contextObservable:i._xrSessionManager.onXRFrameObservable,breakCondition:function(){return!p.pressed},onEnded:function(){i._currentTeleportationControllerId===a.xrController.uniqueId&&a.teleportationState.forward&&i._teleportForward(o.uniqueId)}})):(a.teleportationState.forward=!1,i._currentTeleportationControllerId=""))})}else a.teleportationComponent=d,a.onAxisChangedObserver=d.onAxisValueChangedObservable.add(function(y){if(y.y<=.7&&a.teleportationState.backwards&&(a.teleportationState.backwards=!1),y.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,u.b.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(U){return i._floorMeshes.indexOf(U)!==-1});P&&P.pickedPoint&&(i._options.xrInput.xrCamera.position.x=P.pickedPoint.x,i._options.xrInput.xrCamera.position.z=P.pickedPoint.z)}if(y.y<-.7&&!i._currentTeleportationControllerId&&!a.teleportationState.rotating&&(a.teleportationState.forward=!0,i._currentTeleportationControllerId=a.xrController.uniqueId,a.teleportationState.baseRotation=i._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y),y.x){if(a.teleportationState.forward)i._currentTeleportationControllerId===a.xrController.uniqueId&&(i.rotationEnabled?setTimeout(function(){a.teleportationState.currentRotation=Math.atan2(y.x,y.y*(i._xrSessionManager.scene.useRightHandedSystem?1:-1))}):a.teleportationState.currentRotation=0);else if(!a.teleportationState.rotating&&Math.abs(y.x)>.7){a.teleportationState.rotating=!0;var O=i.rotationAngle*(y.x>0?1:-1)*(i._xrSessionManager.scene.useRightHandedSystem?-1:1);i._options.xrInput.xrCamera.rotationQuaternion.multiplyInPlace(u.b.FromEulerAngles(0,O,0))}}else a.teleportationState.rotating=!1;y.x===0&&y.y===0&&a.teleportationState.forward&&i._teleportForward(o.uniqueId)})}};o.motionController?s():o.onMotionControllerInitObservable.addOnce(function(){s()})}else i._xrSessionManager.scene.onPointerObservable.add(function(d){d.type===Tt.a.POINTERDOWN?(a.teleportationState.forward=!0,i._currentTeleportationControllerId=a.xrController.uniqueId,a.teleportationState.baseRotation=i._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y,a.teleportationState.currentRotation=0,Ws({timeout:i._options.timeToTeleport||3e3,contextObservable:i._xrSessionManager.onXRFrameObservable,onEnded:function(){i._currentTeleportationControllerId===a.xrController.uniqueId&&a.teleportationState.forward&&i._teleportForward(o.uniqueId)}})):d.type===Tt.a.POINTERUP&&(a.teleportationState.forward=!1,i._currentTeleportationControllerId="")})}},i._options.teleportationTargetMesh||i._createDefaultTargetMesh(),i._floorMeshes=i._options.floorMeshes||[],i._snapToPositions=i._options.snapPositions||[],i._setTargetMeshVisibility(!1),i}return Object(c.d)(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)}}
6709,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.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)},t.prototype.removeFloorMesh=function(e){var n=this._floorMeshes.indexOf(e);n!==-1&&this._floorMeshes.splice(n,1)},t.prototype.removeFloorMeshByName=function(e){var n=this._xrSessionManager.scene.getMeshByName(e);n&&this.removeFloorMesh(n)},t.prototype.removeSnapPoint=function(e){var n=this._snapToPositions.indexOf(e);if(n===-1){for(var i=0;i<this._snapToPositions.length;++i)if(this._snapToPositions[i].equals(e)){n=i;break}}return n!==-1&&(this._snapToPositions.splice(n,1),!0)},t.prototype.setSelectionFeature=function(e){this._selectionFeature=e},t.prototype._onXRFrame=function(e){var n=this,i=this._xrSessionManager.currentFrame,o=this._xrSessionManager.scene;if(this.attach&&i){var a=this._options.teleportationTargetMesh;if(this._currentTeleportationControllerId){if(!a)return;a.rotationQuaternion=a.rotationQuaternion||new u.b;var s=this._controllers[this._currentTeleportationControllerId];if(s&&s.teleportationState.forward){u.b.RotationYawPitchRollToRef(s.teleportationState.currentRotation+s.teleportationState.baseRotation,0,0,a.rotationQuaternion);var d=!1;if(s.xrController.getWorldPointerRayToRef(this._tmpRay),this.straightRayEnabled){if((p=o.pickWithRay(this._tmpRay,function(U){if(n._options.pickBlockerMeshes&&n._options.pickBlockerMeshes.indexOf(U)!==-1)return!0;var F=n._floorMeshes.indexOf(U);return F!==-1&&n._floorMeshes[F].absolutePosition.y<n._options.xrInput.xrCamera.position.y}))&&p.pickedMesh&&this._options.pickBlockerMeshes&&this._options.pickBlockerMeshes.indexOf(p.pickedMesh)!==-1)return;p&&p.pickedPoint&&(d=!0,this._setTargetMeshPosition(p.pickedPoint),this._setTargetMeshVisibility(!0),this._showParabolicPath(p))}if(this.parabolicRayEnabled&&!d){var p,y=s.xrController.pointer.rotationQuaternion.toEulerAngles().x,P=Math.PI/2-Math.abs(y)+1,O=this.parabolicCheckRadius*P;if(this._tmpRay.origin.addToRef(this._tmpRay.direction.scale(2*O),this._tmpVector),this._tmpVector.y=this._tmpRay.origin.y,this._tmpRay.origin.addInPlace(this._tmpRay.direction.scale(O)),this._tmpVector.subtractToRef(this._tmpRay.origin,this._tmpRay.direction),this._tmpRay.direction.normalize(),(p=o.pickWithRay(this._tmpRay,function(U){return!(!n._options.pickBlockerMeshes||n._options.pickBlockerMeshes.indexOf(U)===-1)||n._floorMeshes.indexOf(U)!==-1}))&&p.pickedMesh&&this._options.pickBlockerMeshes&&this._options.pickBlockerMeshes.indexOf(p.pickedMesh)!==-1)return;p&&p.pickedPoint&&(d=!0,this._setTargetMeshPosition(p.pickedPoint),this._setTargetMeshVisibility(!0),this._showParabolicPath(p))}this._setTargetMeshVisibility(d)}else this._setTargetMeshVisibility(!1)}else this._setTargetMeshVisibility(!1)}},t.prototype._createDefaultTargetMesh=function(){this._options.defaultTargetMeshOptions=this._options.defaultTargetMeshOptions||{};var e=this._options.useUtilityLayer?this._options.customUtilityLayerScene||xn.a.DefaultUtilityLayer.utilityLayerScene:this._xrSessionManager.scene,n=wi.CreateGround("teleportationTarget",{width:2,height:2,subdivisions:2},e);n.isPickable=!1;var i=new yi.a("teleportationPlaneDynamicTexture",512,e,!0);i.hasAlpha=!0;var o=i.getContext();o.beginPath(),o.arc(256,256,200,0,2*Math.PI,!1),o.fillStyle=this._options.defaultTargetMeshOptions.teleportationFillColor||"#444444",o.fill(),o.lineWidth=10,o.strokeStyle=this._options.defaultTargetMeshOptions.teleportationBorderColor||"#FFFFFF",o.stroke(),o.closePath(),i.update();var a=new Ft.a("teleportationPlaneMaterial",e);a.diffuseTexture=i,n.material=a;var s=mr.CreateTorus("torusTeleportation",{diameter:.75,thickness:.1,tessellation:20},e);if(s.isPickable=!1,s.parent=n,!this._options.defaultTargetMeshOptions.disableAnimation){var d=new k("animationInnerCircle","position.y",30,k.ANIMATIONTYPE_FLOAT,k.ANIMATIONLOOPMODE_CYCLE),p=[];p.push({frame:0,value:0}),p.push({frame:30,value:.4}),p.push({frame:60,value:0}),d.setKeys(p);var y=new on;y.setEasingMode(ze.EASINGMODE_EASEINOUT),d.setEasingFunction(y),s.animations=[],s.animations.push(d),e.beginAnimation(s,0,60,!0)}var P=ui.a.CreateCylinder("rotationCone",{diameterTop:0,tessellation:4},e);if(P.isPickable=!1,P.scaling.set(.5,.12,.2),P.rotate(ye.a.X,Math.PI/2),P.position.z=.6,P.parent=s,this._options.defaultTargetMeshOptions.torusArrowMaterial)s.material=this._options.defaultTargetMeshOptions.torusArrowMaterial,P.material=this._options.defaultTargetMeshOptions.torusArrowMaterial;else{var O=new Ft.a("torusConsMat",e);O.disableLighting=!!this._options.defaultTargetMeshOptions.disableLighting,O.disableLighting?O.emissiveColor=new M.a(.3,.3,1):O.diffuseColor=new M.a(.3,.3,1),O.alpha=.9,s.material=O,P.material=O,this._teleportationRingMaterial=O}this._options.renderingGroupId!==void 0&&(n.renderingGroupId=this._options.renderingGroupId,s.renderingGroupId=this._options.renderingGroupId,P.renderingGroupId=this._options.renderingGroupId),this._options.teleportationTargetMesh=n},t.prototype._detachController=function(e){var n=this._controllers[e];n&&(n.teleportationComponent&&(n.onAxisChangedObserver&&n.teleportationComponent.onAxisValueChangedObservable.remove(n.onAxisChangedObserver),n.onButtonChangedObserver&&n.teleportationComponent.onButtonStateChangedObservable.remove(n.onButtonChangedObserver)),delete this._controllers[e])}
6709,t.prototype._findClosestSnapPointWithRadius=function(e,n){n===void 0&&(n=this._options.snapToPositionRadius||.8);var i=null,o=Number.MAX_VALUE;if(this._snapToPositions.length){var a=n*n;this._snapToPositions.forEach(function(s){var d=u.e.DistanceSquared(s,e);d<=a&&d<o&&(o=d,i=s)})}return i},t.prototype._setTargetMeshPosition=function(e){if(this._options.teleportationTargetMesh){var n=this._findClosestSnapPointWithRadius(e);this._snappedToPoint=!!n,this.snapPointsOnly&&!this._snappedToPoint&&this._teleportationRingMaterial?this._teleportationRingMaterial.diffuseColor.set(1,.3,.3):this.snapPointsOnly&&this._snappedToPoint&&this._teleportationRingMaterial&&this._teleportationRingMaterial.diffuseColor.set(.3,.3,1),this._options.teleportationTargetMesh.position.copyFrom(n||e),this._options.teleportationTargetMesh.position.y+=.01}},t.prototype._setTargetMeshVisibility=function(e){this._options.teleportationTargetMesh&&this._options.teleportationTargetMesh.isVisible!==e&&(this._options.teleportationTargetMesh.isVisible=e,this._options.teleportationTargetMesh.getChildren(void 0,!1).forEach(function(n){n.isVisible=e}),e?this._selectionFeature&&this._selectionFeature.detach():(this._quadraticBezierCurve&&(this._quadraticBezierCurve.dispose(),this._quadraticBezierCurve=null),this._selectionFeature&&this._selectionFeature.attach()))},t.prototype._showParabolicPath=function(e){if(e.pickedPoint){var n=this._controllers[this._currentTeleportationControllerId],i=Ze.d.CreateQuadraticBezier(n.xrController.pointer.absolutePosition,e.ray.origin,e.pickedPoint,25);this._options.generateRayPathMesh?this._quadraticBezierCurve=this._options.generateRayPathMesh(i.getPoints()):this._quadraticBezierCurve=cn.a.CreateLines("teleportation path line",{points:i.getPoints(),instance:this._quadraticBezierCurve,updatable:!0}),this._quadraticBezierCurve.isPickable=!1}},t.prototype._teleportForward=function(e){var n=this._controllers[e];if(n&&n.teleportationState.forward&&(n.teleportationState.forward=!1,this._currentTeleportationControllerId="",(!this.snapPointsOnly||this._snappedToPoint)&&this._options.teleportationTargetMesh&&this._options.teleportationTargetMesh.isVisible)){var i=this._options.xrInput.xrCamera.realWorldHeight;this._options.xrInput.xrCamera.onBeforeCameraTeleport.notifyObservers(this._options.xrInput.xrCamera.position),this._options.xrInput.xrCamera.position.copyFrom(this._options.teleportationTargetMesh.position),this._options.xrInput.xrCamera.position.y+=i,this._options.xrInput.xrCamera.rotationQuaternion.multiplyInPlace(u.b.FromEulerAngles(0,n.teleportationState.currentRotation-(this._xrSessionManager.scene.useRightHandedSystem?Math.PI:0),0)),this._options.xrInput.xrCamera.onAfterCameraTeleport.notifyObservers(this._options.xrInput.xrCamera.position)}},t.Name=ii.TELEPORTATION,t.Version=1,t}(ri);Yn.AddWebXRFeature(ho.Name,function(r,t){return function(){return new ho(r,t)}},ho.Version,!0);var V_=function(){},Bu=function(){function r(){}return r.CreateAsync=function(t,e){e===void 0&&(e={});var n=new r;
6709return Iu.CreateAsync(t).then(function(i){if(n.baseExperience=i,e.ignoreNativeCameraTransformation&&(n.baseExperience.camera.compensateOnFirstFrame=!1),n.input=new Nu(i.sessionManager,i.camera,Object(c.a)({controllerOptions:{renderingGroupId:e.renderingGroupId}},e.inputOptions||{})),n.pointerSelection=n.baseExperience.featuresManager.enableFeature(uo.Name,e.useStablePlugins?"stable":"latest",{xrInput:n.input,renderingGroupId:e.renderingGroupId}),e.disableTeleportation||(n.teleportation=n.baseExperience.featuresManager.enableFeature(ho.Name,e.useStablePlugins?"stable":"latest",{floorMeshes:e.floorMeshes,xrInput:n.input,renderingGroupId:e.renderingGroupId}),n.teleportation.setSelectionFeature(n.pointerSelection)),n.renderTarget=n.baseExperience.sessionManager.getWebXRRenderTarget(e.outputCanvasOptions),!e.disableDefaultUI){var o=Object(c.a)({renderTarget:n.renderTarget},e.uiOptions||{});return e.optionalFeatures&&(typeof e.optionalFeatures=="boolean"?o.optionalFeatures=["hit-test","anchors","plane-detection","hand-tracking"]:o.optionalFeatures=e.optionalFeatures),Fu.CreateAsync(t,n.baseExperience,o).then(function(a){n.enterExitUI=a})}}).then(function(){return n}).catch(function(i){return l.a.Error("Error initializing XR"),l.a.Error(i),n})},r.prototype.dispose=function(){this.baseExperience&&this.baseExperience.dispose(),this.input&&this.input.dispose(),this.enterExitUI&&this.enterExitUI.dispose(),this.renderTarget&&this.renderTarget.dispose()},r}(),k_=!0;_e.a.prototype.createDefaultLight=function(r){if(r===void 0&&(r=!1),r&&this.lights)for(var t=0;t<this.lights.length;t++)this.lights[t].dispose();this.lights.length===0&&new zo.a("default light",u.e.Up(),this)},_e.a.prototype.createDefaultCamera=function(r,t,e){if(r===void 0&&(r=!1),t===void 0&&(t=!1),e===void 0&&(e=!1),t&&this.activeCamera&&(this.activeCamera.dispose(),this.activeCamera=null),!this.activeCamera){var n,i=this.getWorldExtends(function(P){return P.isVisible&&P.isEnabled()}),o=i.max.subtract(i.min),a=i.min.add(o.scale(.5)),s=1.5*o.length();if(isFinite(s)||(s=1,a.copyFromFloats(0,0,0)),r){var d=new Zi("default camera",-Math.PI/2,Math.PI/2,s,a,this);d.lowerRadiusLimit=.01*s,d.wheelPrecision=100/s,n=d}else{var p=new Hn("default camera",new u.e(a.x,a.y,-s),this);p.setTarget(a),n=p}n.minZ=.01*s,n.maxZ=1e3*s,n.speed=.2*s,this.activeCamera=n;var y=this.getEngine().getInputElement();e&&y&&n.attachControl()}},_e.a.prototype.createDefaultCameraOrLight=function(r,t,e){r===void 0&&(r=!1),t===void 0&&(t=!1),e===void 0&&(e=!1),this.createDefaultLight(t),this.createDefaultCamera(r,t,e)},_e.a.prototype.createDefaultSkybox=function(r,t,e,n,i){if(t===void 0&&(t=!1),e===void 0&&(e=1e3),n===void 0&&(n=0),i===void 0&&(i=!0),!r)return l.a.Warn("Can not create default skybox without environment texture."),null;i&&r&&(this.environmentTexture=r);var o=De.a.CreateBox("hdrSkyBox",e,this);if(t){var a=new lo("skyBox",this);a.backFaceCulling=!1,a.reflectionTexture=r.clone(),a.reflectionTexture&&(a.reflectionTexture.coordinatesMode=we.a.SKYBOX_MODE),a.microSurface=1-n,a.disableLighting=!0,a.twoSidedLighting=!0,o.infiniteDistance=!0,o.material=a}else{var s=new Ft.a("skyBox",this);s.backFaceCulling=!1,s.reflectionTexture=r.clone(),s.reflectionTexture&&(s.reflectionTexture.coordinatesMode=we.a.SKYBOX_MODE),s.disableLighting=!0,o.infiniteDistance=!0,o.material=s}return o.isPickable=!1,o},_e.a.prototype.createDefaultEnvironment=function(r){return Us?new Us(r,this):null},_e.a.prototype.createDefaultVRExperience=function(r){return r===void 0&&(r={}),new ru(this,r)},_e.a.prototype.createDefaultXRExperienceAsync=function(r){return r===void 0&&(r={}),Bu.CreateAsync(this,r).then(function(t){return t})};var Uu=function(r){function t(e,n,i,o,a,s,d){o===void 0&&(o=!1),a===void 0&&(a=!1),s===void 0&&(s=we.a.TRILINEAR_SAMPLINGMODE),d===void 0&&(d={autoPlay:!0,loop:!0,autoUpdateTexture:!0});var p=r.call(this,null,i,!o,a)||this;p._onUserActionRequestedObservable=null,p._stillImageCaptured=!1,p._displayingPosterTexture=!1,p._frameId=-1,p._currentSrc=null,p._createInternalTexture=function(){if(p._texture!=null){if(!p._displayingPosterTexture)return;p._texture.dispose(),p._displayingPosterTexture=!1}if(!p._getEngine().needPOTTextures||Ye.b.IsExponentOfTwo(p.video.videoWidth)&&Ye.b.IsExponentOfTwo(p.video.videoHeight)?(p.wrapU=we.a.WRAP_ADDRESSMODE,p.wrapV=we.a.WRAP_ADDRESSMODE):(p.wrapU=we.a.CLAMP_ADDRESSMODE,p.wrapV=we.a.CLAMP_ADDRESSMODE,p._generateMipMaps=!1),p._texture=p._getEngine().createDynamicTexture(p.video.videoWidth,p.video.videoHeight,p._generateMipMaps,p.samplingMode),p.video.autoplay||p._settings.poster)p._texture.isReady=!0,p._updateInternalTexture(),p.onLoadObservable.hasObservers()&&p.onLoadObservable.notifyObservers(p);else{var P=p.video.onplaying,O=!1,U=p.video.muted;p.video.muted=!0,p.video.onplaying=function(){p.video.muted=U,p.video.onplaying=P,p._texture.isReady=!0,p._updateInternalTexture(),O||p.video.pause(),p.onLoadObservable.hasObservers()&&p.onLoadObservable.notifyObservers(p)};var F=p.video.play();F?F.then(function(){}).catch(function(){O=!0,p._onUserActionRequestedObservable&&p._onUserActionRequestedObservable.hasObservers()&&p._onUserActionRequestedObservable.notifyObservers(p)}):(p.video.onplaying=P,p._texture.isReady=!0,p._updateInternalTexture(),p.onLoadObservable.hasObservers()&&p.onLoadObservable.notifyObservers(p))}},p.reset=function(){p._texture!=null&&(p._displayingPosterTexture||(p._texture.dispose(),p._texture=null))},p._updateInternalTexture=function(){if(p._texture!=null&&p._texture.isReady&&!(p.video.readyState<p.video.HAVE_CURRENT_DATA||p._displayingPosterTexture)){var P=p.getScene().getFrameId();p._frameId!==P&&(p._frameId=P,p._getEngine().updateVideoTexture(p._texture,p.video,p._invertY))}},p._generateMipMaps=o,p._initialSamplingMode=s,p.autoUpdateTexture=d.autoUpdateTexture,p._currentSrc=n,p.name=e||p._getName(n),p.video=p._getVideo(n),p._settings=d,d.poster&&(p.video.poster=d.poster),d.autoPlay!==void 0&&(p.video.autoplay=d.autoPlay),d.loop!==void 0&&(p.video.loop=d.loop),d.muted!==void 0&&(p.video.muted=d.muted),p.video.setAttribute("playsinline",""),p.video.addEventListener("paused",p._updateInternalTexture),p.video.addEventListener("seeked",p._updateInternalTexture),p.video.addEventListener("emptied",p.reset),p._createInternalTextureOnEvent=d.poster&&!d.autoPlay?"play":"canplay",p.video.addEventListener(p._createInternalTextureOnEvent,p._createInternalTexture),d.autoPlay&&p.video.play();var y=p.video.readyState>=p.video.HAVE_CURRENT_DATA;
6709return!d.poster||d.autoPlay&&y?y&&p._createInternalTexture():(p._texture=p._getEngine().createTexture(d.poster,!1,!p.invertY,i),p._displayingPosterTexture=!0),p}return Object(c.d)(t,r),Object.defineProperty(t.prototype,"onUserActionRequestedObservable",{get:function(){return this._onUserActionRequestedObservable||(this._onUserActionRequestedObservable=new x.c),this._onUserActionRequestedObservable},enumerable:!1,configurable:!0}),t.prototype._getName=function(e){return e instanceof HTMLVideoElement?e.currentSrc:typeof e=="object"?e.toString():e},t.prototype._getVideo=function(e){if(e instanceof HTMLVideoElement)return Ye.b.SetCorsBehavior(e.currentSrc,e),e;var n=document.createElement("video");return typeof e=="string"?(Ye.b.SetCorsBehavior(e,n),n.src=e):(Ye.b.SetCorsBehavior(e[0],n),e.forEach(function(i){var o=document.createElement("source");o.src=i,n.appendChild(o)})),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()))},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(){r.prototype.dispose.call(this),this._currentSrc=null,this._onUserActionRequestedObservable&&(this._onUserActionRequestedObservable.clear(),this._onUserActionRequestedObservable=null),this.video.removeEventListener(this._createInternalTextureOnEvent,this._createInternalTexture),this.video.removeEventListener("paused",this._updateInternalTexture),this.video.removeEventListener("seeked",this._updateInternalTexture),this.video.removeEventListener("emptied",this.reset),this.video.pause()},t.CreateFromStreamAsync=function(e,n){var i=document.createElement("video");return e.getEngine()._badOS&&(document.body.appendChild(i),i.style.transform="scale(0.0001, 0.0001)",i.style.opacity="0",i.style.position="fixed",i.style.bottom="0px",i.style.right="0px"),i.setAttribute("autoplay",""),i.setAttribute("muted","true"),i.setAttribute("playsinline",""),i.muted=!0,i.mozSrcObject!==void 0?i.mozSrcObject=n:typeof i.srcObject=="object"?i.srcObject=n:(window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,i.src=window.URL&&window.URL.createObjectURL(n)),new Promise(function(o){var a=function(){o(new t("video",i,e,!0,!0)),i.removeEventListener("playing",a)};i.addEventListener("playing",a),i.play()})},t.CreateFromWebCamAsync=function(e,n,i){var o,a=this;return i===void 0&&(i=!1),n&&n.deviceId&&(o={exact:n.deviceId}),navigator.mediaDevices?navigator.mediaDevices.getUserMedia({video:n,audio:i}).then(function(s){return a.CreateFromStreamAsync(e,s)}):(navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia,navigator.getUserMedia&&navigator.getUserMedia({video:{deviceId:o,width:{min:n&&n.minWidth||256,max:n&&n.maxWidth||640},height:{min:n&&n.minHeight||256,max:n&&n.maxHeight||480}},audio:i},function(s){return a.CreateFromStreamAsync(e,s)},function(s){l.a.Error(s.name)}),Promise.reject("No support for userMedia on this device"))},t.CreateFromWebCam=function(e,n,i,o){o===void 0&&(o=!1),this.CreateFromWebCamAsync(e,i,o).then(function(a){n&&n(a)}).catch(function(a){l.a.Error(a.name)})},t}(we.a),G_=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return Object(c.d)(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 Uu((this.name||"videoDome")+"_texture",e,n,i.generateMipMaps,this._useDirectMapping,we.a.TRILINEAR_SAMPLINGMODE,a);return i.clickToPlay&&(n.onPointerUp=function(){o._texture.video.play()}),s},t.MODE_MONOSCOPIC=Bi.MODE_MONOSCOPIC,t.MODE_TOPBOTTOM=Bi.MODE_TOPBOTTOM,t.MODE_SIDEBYSIDE=Bi.MODE_SIDEBYSIDE,t}(Bi),jn=f(55),z_=function(){function r(t){this.engine=t,this._captureGPUFrameTime=!1,this._gpuFrameTime=new jn.a,this._captureShaderCompilationTime=!1,this._shaderCompilationTime=new jn.a,this._onBeginFrameObserver=null,this._onEndFrameObserver=null,this._onBeforeShaderCompilationObserver=null,this._onAfterShaderCompilationObserver=null}return Object.defineProperty(r.prototype,"gpuFrameTimeCounter",{get:function(){return this._gpuFrameTime}
6709,enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"captureGPUFrameTime",{get:function(){return this._captureGPUFrameTime},set:function(t){var e=this;t!==this._captureGPUFrameTime&&(this._captureGPUFrameTime=t,t?(this._onBeginFrameObserver=this.engine.onBeginFrameObservable.add(function(){e._gpuFrameTimeToken||(e._gpuFrameTimeToken=e.engine.startTimeQuery())}),this._onEndFrameObserver=this.engine.onEndFrameObservable.add(function(){if(e._gpuFrameTimeToken){var n=e.engine.endTimeQuery(e._gpuFrameTimeToken);n>-1&&(e._gpuFrameTimeToken=null,e._gpuFrameTime.fetchNewFrame(),e._gpuFrameTime.addCount(n,!0))}})):(this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver),this._onBeginFrameObserver=null,this.engine.onEndFrameObservable.remove(this._onEndFrameObserver),this._onEndFrameObserver=null))},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}(),j_=function(){function r(t){var e=this;this.scene=t,this._captureActiveMeshesEvaluationTime=!1,this._activeMeshesEvaluationTime=new jn.a,this._captureRenderTargetsRenderTime=!1,this._renderTargetsRenderTime=new jn.a,this._captureFrameTime=!1,this._frameTime=new jn.a,this._captureRenderTime=!1,this._renderTime=new jn.a,this._captureInterFrameTime=!1,this._interFrameTime=new jn.a,this._captureParticlesRenderTime=!1,this._particlesRenderTime=new jn.a,this._captureSpritesRenderTime=!1,this._spritesRenderTime=new jn.a,this._capturePhysicsTime=!1,this._physicsTime=new jn.a,this._captureAnimationsTime=!1,this._animationsTime=new jn.a,this._captureCameraRenderTime=!1,this._cameraRenderTime=new jn.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&&(Ye.b.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.scene.getEngine()._drawCalls.fetchNewFrame()}),this._onAfterRenderObserver=t.onAfterRenderObservable.add(function(){e._captureFrameTime&&(Ye.b.EndPerformanceCounter("Scene rendering"),e._frameTime.endMonitoring()),e._captureRen
6709derTime&&e._renderTime.endMonitoring(!1),e._captureInterFrameTime&&e._interFrameTime.beginMonitoring()})}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(){Ye.b.StartPerformanceCounter("Active meshes evaluation"),e._activeMeshesEvaluationTime.beginMonitoring()}),this._onAfterActiveMeshesEvaluationObserver=this.scene.onAfterActiveMeshesEvaluationObservable.add(function(){Ye.b.EndPerformanceCounter("Active meshes evaluation"),e._activeMeshesEvaluationTime.endMonitoring()})):(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(){Ye.b.StartPerformanceCounter("Render targets rendering"),e._renderTargetsRenderTime.beginMonitoring()}),this._onAfterRenderTargetsRenderObserver=this.scene.onAfterRenderTargetsRenderObservable.add(function(){Ye.b.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(){Ye.b.StartPerformanceCounter("Particles"),e._particlesRenderTime.beginMonitoring()}),this._onAfterParticlesRenderingObserver=this.scene.onAfterParticlesRenderingObservable.add(function(){Ye.b.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(){Ye.b.StartPerformanceCounter("Sprites"),e._spritesRenderTime.beginMonitoring()}),this._onAfterSpritesRenderingObserver=this.scene.onAfterSpritesRenderingObservable.add(function(){Ye.b.EndPerformanceCounter("Sprites"),e._spritesRenderTime.endMonitoring(!1)})):(this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver),this._onBeforeSpritesRenderingObserver=null,this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver),this._onAfterSpritesRenderingObserver=null)))}
6709,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(){Ye.b.StartPerformanceCounter("Physics"),e._physicsTime.beginMonitoring()}),this._onAfterPhysicsObserver=this.scene.onAfterPhysicsObservable.add(function(){Ye.b.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(),Ye.b.StartPerformanceCounter("Main render")}),this._onAfterDrawPhaseObserver=this.scene.onAfterDrawPhaseObservable.add(function(){e._renderTime.endMonitoring(!1),Ye.b.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(),Ye.b.StartPerformanceCounter("Rendering camera "+n.name)}),this._onAfterCameraRenderObserver=this.scene.onAfterCameraRenderObservable.add(function(n){e._cameraRenderTime.endMonitoring(!1),Ye.b.EndPerformanceCounter("Rendering camera "+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}
6709,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}(),H_=`#ifdef DIFFUSE
6710varying vec2 vUVDiffuse;
6711uniform sampler2D diffuseSampler;
6712#endif
6713#ifdef OPACITY
6714varying vec2 vUVOpacity;
6715uniform sampler2D opacitySampler;
6716uniform float opacityIntensity;
6717#endif
6718#ifdef EMISSIVE
6719varying vec2 vUVEmissive;
6720uniform sampler2D emissiveSampler;
6721#endif
6722#ifdef VERTEXALPHA
6723varying vec4 vColor;
6724#endif
6725uniform vec4 glowColor;
6726void main(void)
6727{
6728vec4 finalColor=glowColor;
6729
6730#ifdef DIFFUSE
6731vec4 albedoTexture=texture2D(diffuseSampler,vUVDiffuse);
6732#ifdef GLOW
6733
6734finalColor.a*=albedoTexture.a;
6735#endif
6736#ifdef HIGHLIGHT
6737
6738finalColor.a=albedoTexture.a;
6739#endif
6740#endif
6741#ifdef OPACITY
6742vec4 opacityMap=texture2D(opacitySampler,vUVOpacity);
6743#ifdef OPACITYRGB
6744finalColor.a*=getLuminance(opacityMap.rgb);
6745#else
6746finalColor.a*=opacityMap.a;
6747#endif
6748finalColor.a*=opacityIntensity;
6749#endif
6750#ifdef VERTEXALPHA
6751finalColor.a*=vColor.a;
6752#endif
6753#ifdef ALPHATEST
6754if (finalColor.a<ALPHATESTVALUE)
6755discard;
6756#endif
6757#ifdef EMISSIVE
6758gl_FragColor=texture2D(emissiveSampler,vUVEmissive)*finalColor;
6759#else
6760gl_FragColor=finalColor;
6761#endif
6762#ifdef HIGHLIGHT
6763
6764gl_FragColor.a=glowColor.a;
6765#endif
6766}`;je.a.ShadersStore.glowMapGenerationPixelShader=H_;var W_=`
6767attribute vec3 position;
6768#include<bonesDeclaration>
6769#include<morphTargetsVertexGlobalDeclaration>
6770#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
6771
6772#include<instancesDeclaration>
6773uniform mat4 viewProjection;
6774varying vec4 vPosition;
6775#ifdef UV1
6776attribute vec2 uv;
6777#endif
6778#ifdef UV2
6779attribute vec2 uv2;
6780#endif
6781#ifdef DIFFUSE
6782varying vec2 vUVDiffuse;
6783uniform mat4 diffuseMatrix;
6784#endif
6785#ifdef OPACITY
6786varying vec2 vUVOpacity;
6787uniform mat4 opacityMatrix;
6788#endif
6789#ifdef EMISSIVE
6790varying vec2 vUVEmissive;
6791uniform mat4 emissiveMatrix;
6792#endif
6793#ifdef VERTEXALPHA
6794attribute vec4 color;
6795varying vec4 vColor;
6796#endif
6797void main(void)
6798{
6799vec3 positionUpdated=position;
6800#ifdef UV1
6801vec2 uvUpdated=uv;
6802#endif
6803#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
6804#include<instancesVertex>
6805#include<bonesVertex>
6806#ifdef CUBEMAP
6807vPosition=finalWorld*vec4(positionUpdated,1.0);
6808gl_Position=viewProjection*finalWorld*vec4(position,1.0);
6809#else
6810vPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);
6811gl_Position=vPosition;
6812#endif
6813#ifdef DIFFUSE
6814#ifdef DIFFUSEUV1
6815vUVDiffuse=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));
6816#endif
6817#ifdef DIFFUSEUV2
6818vUVDiffuse=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
6819#endif
6820#endif
6821#ifdef OPACITY
6822#ifdef OPACITYUV1
6823vUVOpacity=vec2(opacityMatrix*vec4(uvUpdated,1.0,0.0));
6824#endif
6825#ifdef OPACITYUV2
6826vUVOpacity=vec2(opacityMatrix*vec4(uv2,1.0,0.0));
6827#endif
6828#endif
6829#ifdef EMISSIVE
6830#ifdef EMISSIVEUV1
6831vUVEmissive=vec2(emissiveMatrix*vec4(uvUpdated,1.0,0.0));
6832#endif
6833#ifdef EMISSIVEUV2
6834vUVEmissive=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));
6835#endif
6836#endif
6837#ifdef VERTEXALPHA
6838vColor=color;
6839#endif
6840}`;je.a.ShadersStore.glowMapGenerationVertexShader=W_;var fo=function(){function r(t,e){this._vertexBuffers={},this._maxSize=0,this._mainTextureDesiredSize={width:0,height:0},this._shouldRender=!0,this._postProcesses=[],this._textures=[],this._emissiveTextureAndColor={texture:null,color:new M.b},this.neutralColor=new M.b,this.isEnabled=!0,this.disableBoundingBoxesFromEffectLayer=!1,this.onDisposeObservable=new x.c,this.onBeforeRenderMainTextureObservable=new x.c,this.onBeforeComposeObservable=new x.c,this.onBeforeRenderMeshToEffect=new x.c,this.onAfterRenderMeshToEffect=new x.c,this.onAfterComposeObservable=new x.c,this.onSizeChangedObservable=new x.c,this.name=t,this._scene=e||te.a.LastCreatedScene,r._SceneComponentInitialization(this._scene),this._engine=this._scene.getEngine(),this._maxSize=this._engine.getCaps().maxTextureSize,this._scene.effectLayers.push(this),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}),r.prototype._init=function(t){this._effectLayerOptions=Object(c.a)({mainTextureRatio:.5,alphaBlendingMode:h.a.ALPHA_COMBINE,camera:null,renderingGroupId:-1},t),this._setMainTextureSize(),this._createMainTexture(),this._createTextureAndPostProcesses(),this._mergeEffect=this._createMergeEffect()},r.prototype._generateIndexBuffer=function(){var t=[];t.push(0),t.push(1),t.push(2),t.push(0),t.push(2),t.push(3),this._indexBuffer=this._engine.createIndexBuffer(t)},r.prototype._generateVertexBuffer=function(){var t=[];t.push(1,1),t.push(-1,1),t.push(-1,-1),t.push(1,-1);var e=new Me.b(this._engine,t,Me.b.PositionKind,!1,!1,2);this._vertexBuffers[Me.b.PositionKind]=e},r.prototype._setMainTextureSize=function(){this._effectLayerOptions.mainTextureFixedSize?(this._mainTextureDesiredSize.width=this._effectLayerOptions.mainTextureFixedSize,this._mainTextureDesiredSize.height=this._effectLayerOptions.mainTextureFixedSize):(this._mainTextureDesiredSize.width=this._engine.getRenderWidth()*this._effectLayerOptions.mainTextureRatio,this._mainTextureDesiredSize.height=this._engine.getRenderHeight()*this._effectLayerOptions.mainTextureRatio,this._mainTextureDesiredSize.width=this._engine.needPOTTextures?Ue.a.GetExponentOfTwo(this._mainTextureDesiredSize.width,this._maxSize):this._mainTextureDesiredSize.width,this._mainTextureDesiredSize.height=this._engine.needPOTTextures?Ue.a.GetExponentOfTwo(this._mainTextureDesiredSize.height,this._maxSize):this._mainTextureDesiredSize.height),this._mainTextureDesiredSize.width=Math.floor(this._mainTextureDesiredSize.width),this._mainTextureDesiredSize.height=Math.floor(this._mainTextureDesiredSize.height)},r.prototype._createMainTexture=function(){var t=this;this._mainTexture=new sn("HighlightLayerMainRTT",{width:this._mainTextureDesiredSize.width,height:this._mainTextureDesiredSize.height},this._scene,!1,!0,h.a.TEXTURETYPE_UNSIGNED_INT),this._mainTexture.activeCamera=this._effectLayerOptions.camera,this._mainTexture.wrapU=we.a.CLAMP_ADDRESSMODE,this._mainTexture.wrapV=we.a.CLAMP_ADDRESSMODE,this._mainTexture.anisotropicFilteringLevel=1,this._mainTexture.updateSamplingMode(we.a.BILINEAR_SAMPLINGMODE),this._mainTexture.renderParticles=!1,this._mainTexture.renderList=null,this._mainTexture.ignoreCameraViewport=!0,this._mainTexture.customRenderFunction=function(n,i,o,a){var s;t.onBeforeRenderMainTextureObservable.notifyObservers(t);var d=t._scene.getEngine();if(a.length){for(d.setColorWrite(!1),s=0;s<a.length;s++)t._renderSubMesh(a.data[s]);d.setColorWrite(!0)}for(s=0;s<n.length;s++)t._renderSubMesh(n.data[s]);for(s=0;s<i.length;s++)t._renderSubMesh(i.data[s]);var p=d.getAlphaMode();for(s=0;s<o.length;s++)t._renderSubMesh(o.data[s],!0);d.setAlphaMode(p)},this._mainTexture.onClearObservable.add(function(n){n.clear(t.neutralColor,!0,!0,!0)});var e=this._scene.getBoundingBoxRenderer().enabled;this._mainTexture.onBeforeBindObservable.add(function(){t._scene.getBoundingBoxRenderer().enabled=!t.disableBoundingBoxesFromEffectLayer&&e}),this._mainTexture.onAfterUnbindObservable.add(function(){t._scene.getBoundingBoxRenderer().enabled=e})},r.prototype._addCustomEffectDefines=function(t){},r.prototype._isReady=function(t,e,n){var i=t.getMaterial();
6840if(!i||!i.isReadyForSubMesh(t.getMesh(),t,e))return!1;var o=[],a=[Me.b.PositionKind],s=t.getMesh(),d=!1,p=!1;if(i){var y=i.needAlphaTesting(),P=i.getAlphaTestTexture(),O=P&&P.hasAlpha&&(i.useAlphaFromDiffuseTexture||i._useAlphaFromAlbedoTexture);P&&(y||O)&&(o.push("#define DIFFUSE"),s.isVerticesDataPresent(Me.b.UV2Kind)&&P.coordinatesIndex===1?(o.push("#define DIFFUSEUV2"),p=!0):s.isVerticesDataPresent(Me.b.UVKind)&&(o.push("#define DIFFUSEUV1"),d=!0),y&&(o.push("#define ALPHATEST"),o.push("#define ALPHATESTVALUE 0.4")));var U=i.opacityTexture;U&&(o.push("#define OPACITY"),s.isVerticesDataPresent(Me.b.UV2Kind)&&U.coordinatesIndex===1?(o.push("#define OPACITYUV2"),p=!0):s.isVerticesDataPresent(Me.b.UVKind)&&(o.push("#define OPACITYUV1"),d=!0))}n&&(o.push("#define EMISSIVE"),s.isVerticesDataPresent(Me.b.UV2Kind)&&n.coordinatesIndex===1?(o.push("#define EMISSIVEUV2"),p=!0):s.isVerticesDataPresent(Me.b.UVKind)&&(o.push("#define EMISSIVEUV1"),d=!0)),s.isVerticesDataPresent(Me.b.ColorKind)&&s.hasVertexAlpha&&(a.push(Me.b.ColorKind),o.push("#define VERTEXALPHA")),d&&(a.push(Me.b.UVKind),o.push("#define UV1")),p&&(a.push(Me.b.UV2Kind),o.push("#define UV2"));var F=new Er.a;if(s.useBones&&s.computeBonesUsingShaders){a.push(Me.b.MatricesIndicesKind),a.push(Me.b.MatricesWeightsKind),s.numBoneInfluencers>4&&(a.push(Me.b.MatricesIndicesExtraKind),a.push(Me.b.MatricesWeightsExtraKind)),o.push("#define NUM_BONE_INFLUENCERS "+s.numBoneInfluencers);var z=s.skeleton;z&&z.isUsingTextureForMatrices?o.push("#define BONETEXTURE"):o.push("#define BonesPerMesh "+(z?z.bones.length+1:0)),s.numBoneInfluencers>0&&F.addCPUSkinningFallback(0,s)}else o.push("#define NUM_BONE_INFLUENCERS 0");var J=s.morphTargetManager,ie=0;J&&J.numInfluencers>0&&(o.push("#define MORPHTARGETS"),ie=J.numInfluencers,o.push("#define NUM_MORPH_INFLUENCERS "+ie),tt.a.PrepareAttributesForMorphTargetsInfluencers(a,s,ie)),e&&(o.push("#define INSTANCES"),tt.a.PushAttributesForInstances(a),t.getRenderingMesh().hasThinInstances&&o.push("#define THIN_INSTANCES")),this._addCustomEffectDefines(o);var se=o.join(`
6841`);return this._cachedDefines!==se&&(this._cachedDefines=se,this._effectLayerMapGenerationEffect=this._scene.getEngine().createEffect("glowMapGeneration",a,["world","mBones","viewProjection","glowColor","morphTargetInfluences","boneTextureWidth","diffuseMatrix","emissiveMatrix","opacityMatrix","opacityIntensity"],["diffuseSampler","emissiveSampler","opacitySampler","boneSampler"],se,F,void 0,void 0,{maxSimultaneousMorphTargets:ie})),this._effectLayerMapGenerationEffect.isReady()},r.prototype.render=function(){var t=this._mergeEffect;if(t.isReady()){for(var e=0;e<this._postProcesses.length;e++)if(!this._postProcesses[e].isReady())return;var n=this._scene.getEngine();this.onBeforeComposeObservable.notifyObservers(this),n.enableEffect(t),n.setState(!1),n.bindBuffers(this._vertexBuffers,this._indexBuffer,t);var i=n.getAlphaMode();n.setAlphaMode(this._effectLayerOptions.alphaBlendingMode),this._internalRender(t),n.setAlphaMode(i),this.onAfterComposeObservable.notifyObservers(this);var o=this._mainTexture.getSize();this._setMainTextureSize(),o.width===this._mainTextureDesiredSize.width&&o.height===this._mainTextureDesiredSize.height||(this.onSizeChangedObservable.notifyObservers(this),this._disposeTextureAndPostProcesses(),this._createMainTexture(),this._createTextureAndPostProcesses())}},r.prototype.hasMesh=function(t){return this.renderingGroupId===-1||t.renderingGroupId===this.renderingGroupId},r.prototype.shouldRender=function(){return this.isEnabled&&this._shouldRender},r.prototype._shouldRenderMesh=function(t){return!0},r.prototype._canRenderMesh=function(t,e){return!e.needAlphaBlendingForMesh(t)},r.prototype._shouldRenderEmissiveTextureForMesh=function(){return!0},r.prototype._renderSubMesh=function(t,e){var n,i=this;if(e===void 0&&(e=!1),this.shouldRender()){var o=t.getMaterial(),a=t.getMesh(),s=t.getReplacementMesh(),d=t.getRenderingMesh(),p=t.getEffectiveMesh(),y=this._scene,P=y.getEngine();if(p._internalAbstractMeshDataInfo._isActiveIntermediate=!1,o&&this._canRenderMesh(d,o)){var O=(n=d.overrideMaterialSideOrientation)!==null&&n!==void 0?n:o.sideOrientation;d._getWorldMatrixDeterminant()<0&&(O=O===Ht.a.ClockWiseSideOrientation?Ht.a.CounterClockWiseSideOrientation:Ht.a.ClockWiseSideOrientation);var U=O===Ht.a.ClockWiseSideOrientation;P.setState(o.backFaceCulling,o.zOffset,void 0,U);var F=d._getInstancesRenderList(t._id,!!s);if(!F.mustReturn&&this._shouldRenderMesh(d)){var z=F.hardwareInstancedRendering[t._id]||d.hasThinInstances;
6841if(this._setEmissiveTextureAndColor(d,t,o),this.onBeforeRenderMeshToEffect.notifyObservers(a),this._useMeshMaterial(d))d.render(t,z,s||void 0);else if(this._isReady(t,z,this._emissiveTextureAndColor.texture)){P.enableEffect(this._effectLayerMapGenerationEffect),d._bind(t,this._effectLayerMapGenerationEffect,Ht.a.TriangleFillMode),this._effectLayerMapGenerationEffect.setMatrix("viewProjection",y.getTransformMatrix()),this._effectLayerMapGenerationEffect.setMatrix("world",p.getWorldMatrix()),this._effectLayerMapGenerationEffect.setFloat4("glowColor",this._emissiveTextureAndColor.color.r,this._emissiveTextureAndColor.color.g,this._emissiveTextureAndColor.color.b,this._emissiveTextureAndColor.color.a);var J=o.needAlphaTesting(),ie=o.getAlphaTestTexture(),se=ie&&ie.hasAlpha&&(o.useAlphaFromDiffuseTexture||o._useAlphaFromAlbedoTexture);ie&&(J||se)&&(this._effectLayerMapGenerationEffect.setTexture("diffuseSampler",ie),(ce=ie.getTextureMatrix())&&this._effectLayerMapGenerationEffect.setMatrix("diffuseMatrix",ce));var ce,ue=o.opacityTexture;if(ue&&(this._effectLayerMapGenerationEffect.setTexture("opacitySampler",ue),this._effectLayerMapGenerationEffect.setFloat("opacityIntensity",ue.level),(ce=ue.getTextureMatrix())&&this._effectLayerMapGenerationEffect.setMatrix("opacityMatrix",ce)),this._emissiveTextureAndColor.texture&&(this._effectLayerMapGenerationEffect.setTexture("emissiveSampler",this._emissiveTextureAndColor.texture),this._effectLayerMapGenerationEffect.setMatrix("emissiveMatrix",this._emissiveTextureAndColor.texture.getTextureMatrix())),d.useBones&&d.computeBonesUsingShaders&&d.skeleton){var fe=d.skeleton;if(fe.isUsingTextureForMatrices){var ve=fe.getTransformMatrixTexture(d);if(!ve)return;this._effectLayerMapGenerationEffect.setTexture("boneSampler",ve),this._effectLayerMapGenerationEffect.setFloat("boneTextureWidth",4*(fe.bones.length+1))}else this._effectLayerMapGenerationEffect.setMatrices("mBones",fe.getTransformMatrices(d))}tt.a.BindMorphTargetParameters(d,this._effectLayerMapGenerationEffect),e&&P.setAlphaMode(o.alphaMode),d._processRendering(p,t,this._effectLayerMapGenerationEffect,o.fillMode,F,z,function(Te,Oe){return i._effectLayerMapGenerationEffect.setMatrix("world",Oe)})}else this._mainTexture.resetRefreshCounter();this.onAfterRenderMeshToEffect.notifyObservers(a)}}}},r.prototype._useMeshMaterial=function(t){return!1},r.prototype._rebuild=function(){var t=this._vertexBuffers[Me.b.PositionKind];t&&t._rebuild(),this._generateIndexBuffer()},r.prototype._disposeTextureAndPostProcesses=function(){this._mainTexture.dispose();for(var t=0;t<this._postProcesses.length;t++)this._postProcesses[t]&&this._postProcesses[t].dispose();for(this._postProcesses=[],t=0;t<this._textures.length;t++)this._textures[t]&&this._textures[t].dispose();this._textures=[]},r.prototype.dispose=function(){var t=this._vertexBuffers[Me.b.PositionKind];t&&(t.dispose(),this._vertexBuffers[Me.b.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this._disposeTextureAndPostProcesses();var e=this._scene.effectLayers.indexOf(this,0);e>-1&&this._scene.effectLayers.splice(e,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 Ye.b.Instantiate(t.customType).Parse(t,e,n)},r._SceneComponentInitialization=function(t){throw En.a.WarnImport("EffectLayerSceneComponent")},Object(c.c)([Object(L.c)()],r.prototype,"name",void 0),Object(c.c)([Object(L.f)()],r.prototype,"neutralColor",void 0),Object(c.c)([Object(L.c)()],r.prototype,"isEnabled",void 0),Object(c.c)([Object(L.d)()],r.prototype,"camera",null),Object(c.c)([Object(L.c)()],r.prototype,"renderingGroupId",null),Object(c.c)([Object(L.c)()],r.prototype,"disableBoundingBoxesFromEffectLayer",void 0),r}();B.a.AddParser(st.a.NAME_EFFECTLAYER,function(r,t,e,n){if(r.effectLayers){e.effectLayers||(e.effectLayers=new Array);for(var i=0;i<r.effectLayers.length;i++){var o=fo.Parse(r.effectLayers[i],t,n);e.effectLayers.push(o)}}}),B.a.prototype.removeEffectLayer=function(r){var t=this.effectLayers.indexOf(r);return t!==-1&&this.effectLayers.splice(t,1),t},B.a.prototype.addEffectLayer=function(r){this.effectLayers.push(r)};var Vu=function(){function r(t){this.name=st.a.NAME_EFFECTLAYER,this._renderEffects=!1,this._needStencil=!1,this._previousStencilState=!1,this.scene=t,this._engine=t.getEngine(),t.effectLayers=new Array}return r.prototype.register=function(){this.scene._isReadyForMeshStage.registerStep(st.a.STEP_ISREADYFORMESH_EFFECTLAYER,this,this._isReadyForMesh),this.scene._cameraDrawRenderTargetStage.registerStep(st.a.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER,this,this._renderMainTexture),this.scene._beforeCameraDrawStage.registerStep(st.a.STEP_BEFORECAMERADRAW_EFFECTLAYER,this,this._setStencil),this.scene._afterRenderingGroupDrawStage.registerStep(st.a.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW,this,this._drawRenderingGroup),this.scene._afterCameraDrawStage.registerStep(st.a.STEP_AFTERCAMERADRAW_EFFECTLAYER,this,this._setStencilBack),this.scene._afterCameraDrawStage.registerStep(st.a.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW,this,this._drawCamera)},r.prototype.rebuild=function(){for(var t=0,e=this.scene.effectLayers;t<e.length;t++)e[t]._rebuild()},r.prototype.serialize=function(t){t.effectLayers=[];for(var e=0,n=this.scene.effectLayers;e<n.length;e++){var i=n[e];i.serialize&&t.effectLayers.push(i.serialize())}},r.prototype.addFromContainer=function(t){var e=this;
6841t.effectLayers&&t.effectLayers.forEach(function(n){e.scene.addEffectLayer(n)})},r.prototype.removeFromContainer=function(t,e){var n=this;t.effectLayers&&t.effectLayers.forEach(function(i){n.scene.removeEffectLayer(i),e&&i.dispose()})},r.prototype.dispose=function(){for(var t=this.scene.effectLayers;t.length;)t[0].dispose()},r.prototype._isReadyForMesh=function(t,e){for(var n=0,i=this.scene.effectLayers;n<i.length;n++){var o=i[n];if(o.hasMesh(t))for(var a=0,s=t.subMeshes;a<s.length;a++){var d=s[a];if(!o.isReady(d,e))return!1}}return!0},r.prototype._renderMainTexture=function(t){this._renderEffects=!1,this._needStencil=!1;var e=!1,n=this.scene.effectLayers;if(n&&n.length>0){this._previousStencilState=this._engine.getStencilBuffer();for(var i=0,o=n;i<o.length;i++){var a=o[i];if(a.shouldRender()&&(!a.camera||a.camera.cameraRigMode===gt.a.RIG_MODE_NONE&&t===a.camera||a.camera.cameraRigMode!==gt.a.RIG_MODE_NONE&&a.camera._rigCameras.indexOf(t)>-1)){this._renderEffects=!0,this._needStencil=this._needStencil||a.needStencil();var s=a._mainTexture;s._shouldRender()&&(this.scene.incrementRenderId(),s.render(!1,!1),e=!0)}}this.scene.incrementRenderId()}return e},r.prototype._setStencil=function(){this._needStencil&&this._engine.setStencilBuffer(!0)},r.prototype._setStencilBack=function(){this._needStencil&&this._engine.setStencilBuffer(this._previousStencilState)},r.prototype._draw=function(t){if(this._renderEffects){this._engine.setDepthBuffer(!1);for(var e=this.scene.effectLayers,n=0;n<e.length;n++){var i=e[n];i.renderingGroupId===t&&i.shouldRender()&&i.render()}this._engine.setDepthBuffer(!0)}},r.prototype._drawCamera=function(){this._renderEffects&&this._draw(-1)},r.prototype._drawRenderingGroup=function(t){!this.scene._isInIntermediateRendering()&&this._renderEffects&&this._draw(t)},r}();fo._SceneComponentInitialization=function(r){var t=r._getComponent(st.a.NAME_EFFECTLAYER);t||(t=new Vu(r),r._addComponent(t))};var X_=`
6842varying vec2 vUV;
6843uniform sampler2D textureSampler;
6844#ifdef EMISSIVE
6845uniform sampler2D textureSampler2;
6846#endif
6847
6848uniform float offset;
6849void main(void) {
6850vec4 baseColor=texture2D(textureSampler,vUV);
6851#ifdef EMISSIVE
6852baseColor+=texture2D(textureSampler2,vUV);
6853baseColor*=offset;
6854#else
6855baseColor.a=abs(offset-baseColor.a);
6856#ifdef STROKE
6857float alpha=smoothstep(.0,.1,baseColor.a);
6858baseColor.a=alpha;
6859baseColor.rgb=baseColor.rgb*alpha;
6860#endif
6861#endif
6862gl_FragColor=baseColor;
6863}`;je.a.ShadersStore.glowMapMergePixelShader=X_;var Y_=`
6864attribute vec2 position;
6865
6866varying vec2 vUV;
6867const vec2 madd=vec2(0.5,0.5);
6868void main(void) {
6869vUV=position*madd+madd;
6870gl_Position=vec4(position,0.0,1.0);
6871}`;je.a.ShadersStore.glowMapMergeVertexShader=Y_,B.a.prototype.getGlowLayerByName=function(r){for(var t=0;t<this.effectLayers.length;t++)if(this.effectLayers[t].name===r&&this.effectLayers[t].getEffectName()===sa.EffectName)return this.effectLayers[t];return null};var sa=function(r){function t(e,n,i){var o=r.call(this,e,n)||this;return o._intensity=1,o._includedOnlyMeshes=[],o._excludedMeshes=[],o._meshesUsingTheirOwnMaterials=[],o.neutralColor=new M.b(0,0,0,1),o._options=Object(c.a)({mainTextureRatio:t.DefaultTextureRatio,blurKernelSize:32,mainTextureFixedSize:void 0,camera:null,mainTextureSamples:1,renderingGroupId:-1},i),o._init({alphaBlendingMode:h.a.ALPHA_ADD,camera:o._options.camera,mainTextureFixedSize:o._options.mainTextureFixedSize,mainTextureRatio:o._options.mainTextureRatio,renderingGroupId:o._options.renderingGroupId}),o}return Object(c.d)(t,r),Object.defineProperty(t.prototype,"blurKernelSize",{get:function(){return this._horizontalBlurPostprocess1.kernel},set:function(e){this._horizontalBlurPostprocess1.kernel=e,this._verticalBlurPostprocess1.kernel=e,this._horizontalBlurPostprocess2.kernel=e,this._verticalBlurPostprocess2.kernel=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"intensity",{get:function(){return this._intensity},set:function(e){this._intensity=e},enumerable:!1,configurable:!0}),t.prototype.getEffectName=function(){return t.EffectName},t.prototype._createMergeEffect=function(){return this._engine.createEffe
6871ct("glowMapMerge",[Me.b.PositionKind],["offset"],["textureSampler","textureSampler2"],`#define EMISSIVE 
6872`)},t.prototype._createTextureAndPostProcesses=function(){var e=this,n=this._mainTextureDesiredSize.width,i=this._mainTextureDesiredSize.height;n=this._engine.needPOTTextures?Ue.a.GetExponentOfTwo(n,this._maxSize):n,i=this._engine.needPOTTextures?Ue.a.GetExponentOfTwo(i,this._maxSize):i;var o=0;o=this._engine.getCaps().textureHalfFloatRender?h.a.TEXTURETYPE_HALF_FLOAT:h.a.TEXTURETYPE_UNSIGNED_INT,this._blurTexture1=new sn("GlowLayerBlurRTT",{width:n,height:i},this._scene,!1,!0,o),this._blurTexture1.wrapU=we.a.CLAMP_ADDRESSMODE,this._blurTexture1.wrapV=we.a.CLAMP_ADDRESSMODE,this._blurTexture1.updateSamplingMode(we.a.BILINEAR_SAMPLINGMODE),this._blurTexture1.renderParticles=!1,this._blurTexture1.ignoreCameraViewport=!0;var a=Math.floor(n/2),s=Math.floor(i/2);this._blurTexture2=new sn("GlowLayerBlurRTT2",{width:a,height:s},this._scene,!1,!0,o),this._blurTexture2.wrapU=we.a.CLAMP_ADDRESSMODE,this._blurTexture2.wrapV=we.a.CLAMP_ADDRESSMODE,this._blurTexture2.updateSamplingMode(we.a.BILINEAR_SAMPLINGMODE),this._blurTexture2.renderParticles=!1,this._blurTexture2.ignoreCameraViewport=!0,this._textures=[this._blurTexture1,this._blurTexture2],this._horizontalBlurPostprocess1=new _n("GlowLayerHBP1",new u.d(1,0),this._options.blurKernelSize/2,{width:n,height:i},null,we.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,o),this._horizontalBlurPostprocess1.width=n,this._horizontalBlurPostprocess1.height=i,this._horizontalBlurPostprocess1.onApplyObservable.add(function(d){d.setTexture("textureSampler",e._mainTexture)}),this._verticalBlurPostprocess1=new _n("GlowLayerVBP1",new u.d(0,1),this._options.blurKernelSize/2,{width:n,height:i},null,we.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,o),this._horizontalBlurPostprocess2=new _n("GlowLayerHBP2",new u.d(1,0),this._options.blurKernelSize/2,{width:a,height:s},null,we.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,o),this._horizontalBlurPostprocess2.width=a,this._horizontalBlurPostprocess2.height=s,this._horizontalBlurPostprocess2.onApplyObservable.add(function(d){d.setTexture("textureSampler",e._blurTexture1)}),this._verticalBlurPostprocess2=new _n("GlowLayerVBP2",new u.d(0,1),this._options.blurKernelSize/2,{width:a,height:s},null,we.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,o),this._postProcesses=[this._horizontalBlurPostprocess1,this._verticalBlurPostprocess1,this._horizontalBlurPostprocess2,this._verticalBlurPostprocess2],this._postProcesses1=[this._horizontalBlurPostprocess1,this._verticalBlurPostprocess1],this._postProcesses2=[this._horizontalBlurPostprocess2,this._verticalBlurPostprocess2],this._mainTexture.samples=this._options.mainTextureSamples,this._mainTexture.onAfterUnbindObservable.add(function(){var d=e._blurTexture1.getInternalTexture();if(d){e._scene.postProcessManager.directRender(e._postProcesses1,d,!0);var p=e._blurTexture2.getInternalTexture();p&&e._scene.postProcessManager.directRender(e._postProcesses2,p,!0),e._engine.unBindFramebuffer(p??d,!0)}}),this._postProcesses.map(function(d){d.autoClear=!1})},t.prototype.isReady=function(e,n){var i=e.getMaterial(),o=e.getRenderingMesh();if(!i||!o)return!1;var a=i.emissiveTexture;return r.prototype._isReady.call(this,e,n,a)},t.prototype.needStencil=function(){return!1},t.prototype._canRenderMesh=function(e,n){return!0},t.prototype._internalRender=function(e){e.setTexture("textureSampler",this._blurTexture1),e.setTexture("textureSampler2",this._blurTexture2),e.setFloat("offset",this._intensity);var n=this._engine,i=n.getStencilBuffer();n.setStencilBuffer(!1),n.drawElementsType(Ht.a.TriangleFillMode,0,6),n.setStencilBuffer(i)},t.prototype._setEmissiveTextureAndColor=function(e,n,i){var o=1;this.customEmissiveTextureSelector?this._emissiveTextureAndColor.texture=this.customEmissiveTextureSelector(e,n,i):i?(this._emissiveTextureAndColor.texture=i.emissiveTexture,this._emissiveTextureAndColor.texture&&(o=this._emissiveTextureAndColor.texture.level)):this._emissiveTextureAndColor.texture=null,this.customEmissiveColorSelector?this.customEmissiveColorSelector(e,n,i,this._emissiveTextureAndColor.color):i.emissiveColor?this._emissiveTextureAndColor.color.set(i.emissiveColor.r*o,i.emissiveColor.g*o,i.emissiveColor.b*o,i.alpha):this._emissiveTextureAndColor.color.set(this.neutralColor.r,this.neutralColor.g,this.neutralColor.b,this.neutralColor.a)},t.prototype._shouldRenderMesh=function(e){return this.hasMesh(e)},t.prototype._addCustomEffectDefines=function(e){e.push("#define GLOW")},t.prototype.addExcludedMesh=function(e){this._excludedMeshes.indexOf(e.uniqueId)===-1&&this._excludedMeshes.push(e.uniqueId)},t.prototype.removeExcludedMesh=function(e){var n=this._excludedMeshes.indexOf(e.uniqueId);n!==-1&&this._excludedMeshes.splice(n,1)},t.prototype.addIncludedOnlyMesh=function(e){this._includedOnlyMeshes.indexOf(e.uniqueId)===-1&&this._includedOnlyMeshes.push(e.uniqueId)},t.prototype.removeIncludedOnlyMesh=function(e){var n=this._includedOnlyMeshes.indexOf(e.uniqueId);n!==-1&&this._includedOnlyMeshes.splice(n,1)},t.prototype.hasMesh=function(e){return!!r.prototype.hasMesh.call(this,e)&&(this._includedOnlyMeshes.length?this._includedOnlyMeshes.indexOf(e.uniqueId)!==-1:!this._excludedMeshes.length||this._excludedMeshes.indexOf(e.uniqueId)===-1)},t.prototype._useMeshMaterial=function(e){return this._meshesUsingTheirOwnMaterials.length!=0&&this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId)>-1},t.prototype.referenceMeshToUseItsOwnMaterial=function(e){this._meshesUsingTheirOwnMaterials.push(e.uniqueId)},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)},t.prototype._disposeMesh=function(e){this.removeIncludedOnlyMesh(e),this.removeExcludedMesh(e)},t.prototype.getClassName=function(){return"GlowLayer"},t.prototype.serialize=function(){var e,n=L.a.Serialize(this);if(n.customType="BABYLON.GlowLayer",n.includedMeshes=[],this._includedOnlyMeshes.length)for(e=0;e<this._includedOnlyMeshes.length;e++)(i=this._scene.getMeshByUniqueID(this._includedOnlyMeshes[e]))&&n.includedMeshes.push(i.id);if(n.excludedMeshes=[],this._excludedMeshes.length)for(e=0;e<this._excludedMeshes.length;e++){var i;(i=this._scene.getMeshByUniqueID(this._excludedMeshes[e]))&&n.excludedMeshes.push(i.id)}return n},t.Parse=function(e,n,i){var o,a=L.a.Parse(function(){return new t(e.name,n,e.options)},e,n,i);for(o=0;o<e.excludedMeshes.length;o++)(s=n.getMeshByID(e.excludedMeshes[o]))&&a.addExcludedMesh(s);for(o=0;o<e.includedMeshes.length;o++){var s;(s=n.getMeshByID(e.includedMeshes[o]))&&a.addIncludedOnlyMesh(s)}return a},t.EffectName="GlowLayer",t.DefaultBlurKernelSize=32,t.DefaultTextureRatio=.5,Object(c.c)([Object(L.c)()],t.prototype,"blurKernelSize",null),Object(c.c)([Object(L.c)()],t.prototype,"intensity",null),Object(c.c)([Object(L.c)("options")],t.prototype,"_options",void 0),t}(fo);R.a.RegisteredTypes["BABYLON.GlowLayer"]=sa;var K_=`
6873varying vec2 vUV;
6874uniform sampler2D textureSampler;
6875
6876uniform vec2 screenSize;
6877uniform vec2 direction;
6878uniform float blurWidth;
6879
6880float getLuminance(vec3 color)
6881{
6882return dot(color,vec3(0.2126,0.7152,0.0722));
6883}
6884void main(void)
6885{
6886float weights[7];
6887weights[0]=0.05;
6888weights[1]=0.1;
6889weights[2]=0.2;
6890weights[3]=0.3;
6891weights[4]=0.2;
6892weights[5]=0.1;
6893weights[6]=0.05;
6894vec2 texelSize=vec2(1.0/screenSize.x,1.0/screenSize.y);
6895vec2 texelStep=texelSize*direction*blurWidth;
6896vec2 start=vUV-3.0*texelStep;
6897vec4 baseColor=vec4(0.,0.,0.,0.);
6898vec2 texelOffset=vec2(0.,0.);
6899for (int i=0; i<7; i++)
6900{
6901
6902vec4 texel=texture2D(textureSampler,start+texelOffset);
6903baseColor.a+=texel.a*weights[i];
6904
6905float luminance=getLuminance(baseColor.rgb);
6906float luminanceTexel=getLuminance(texel.rgb);
6907float choice=step(luminanceTexel,luminance);
6908baseColor.rgb=choice*baseColor.rgb+(1.0-choice)*texel.rgb;
6909texelOffset+=texelStep;
6910}
6911gl_FragColor=baseColor;
6912}`;je.a.ShadersStore.glowBlurPostProcessPixelShader=K_,B.a.prototype.getHighlightLayerByName=function(r){for(var t=0;t<this.effectLayers.length;t++)if(this.effectLayers[t].name===r&&this.effectLayers[t].getEffectName()===Xs.EffectName)return this.effectLayers[t];return null};var ku=function(r){function t(e,n,i,o,a,s,d,p){s===void 0&&(s=we.a.BILINEAR_SAMPLINGMODE);var y=r.call(this,e,"glowBlurPostProcess",["screenSize","direction","blurWidth"],null,o,a,s,d,p)||this;return y.direction=n,y.kernel=i,y.onApplyObservable.add(function(P){P.setFloat2("screenSize",y.width,y.height),P.setVector2("direction",y.direction),P.setFloat("blurWidth",y.kernel)}),y}return Object(c.d)(t,r),t}(_t),Xs=function(r){function t(e,n,i){var o=r.call(this,e,n)||this;return o.name=e,o.innerGlow=!0,o.outerGlow=!0,o.onBeforeBlurObservable=new x.c,o.onAfterBlurObservable=new x.c,o._instanceGlowingMeshStencilReference=t.GlowingMeshStencilReference++,o._meshes={},o._excludedMeshes={},o.neutralColor=t.NeutralColor,o._engine.isStencilEnable||l.a.Warn("Rendering the Highlight Layer requires the stencil to be active on the canvas. var engine = new Engine(canvas, antialias, { stencil: true }"),o._options=Object(c.a)({mainTextureRatio:.5,blurTextureSizeRatio:.5,blurHorizontalSize:1,blurVerticalSize:1,alphaBlendingMode:h.a.ALPHA_COMBINE,camera:null,renderingGroupId:-1},i),o._init({alphaBlendingMode:o._options.alphaBlendingMode,camera:o._options.camera,mainTextureFixedSize:o._options.mainTextureFixedSize,mainTextureRatio:o._options.mainTextureRatio,renderingGroupId:o._options.renderingGroupId}),o._shouldRender=!1,o}return Object(c.d)(t,r),Object.defineProperty(t.prototype,"blurHorizontalSize",{get:function(){return this._horizontalBlurPostprocess.kernel},set:function(e){this._horizontalBlurPostprocess.kernel=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blurVerticalSize",{get:function(){return this._verticalBlurPostprocess.kernel},set:function(e){this._verticalBlurPostprocess.kernel=e},enumerable:!1,configurable:!0}),t.prototype.getEffectName=function(){return t.EffectName},t.prototype._createMergeEffect=function(){return this._engine.createEffect("glowMapMerge",[Me.b.PositionKind],["offset"],["textureSampler"],this._options.isStroke?`#define STROKE 
6913`:void 0)},t.prototype._createTextureAndPostProcesses=function(){var e=this,n=this._mainTextureDesiredSize.width*this._options.blurTextureSizeRatio,i=this._mainTextureDesiredSize.height*this._options.blurTextureSizeRatio;n=this._engine.needPOTTextures?Ue.a.GetExponentOfTwo(n,this._maxSize):n,i=this._engine.needPOTTextures?Ue.a.GetExponentOfTwo(i,this._maxSize):i;var o=0;o=this._engine.getCaps().textureHalfFloatRender?h.a.TEXTURETYPE_HALF_FLOAT:h.a.TEXTURETYPE_UNSIGNED_INT,this._blurTexture=new sn("HighlightLayerBlurRTT",{width:n,height:i},this._scene,!1,!0,o),this._blurTexture.wrapU=we.a.CLAMP_ADDRESSMODE,this._blurTexture.wrapV=we.a.CLAMP_ADDRESSMODE,this._blurTexture.anisotropicFilteringLevel=16,this._blurTexture.updateSamplingMode(we.a.TRILINEAR_SAMPLINGMODE),this._blurTexture.renderParticles=!1,this._blurTexture.ignoreCameraViewport=!0,this._textures=[this._blurTexture],this._options.alphaBlendingMode===h.a.ALPHA_COMBINE?(this._downSamplePostprocess=new Li("HighlightLayerPPP",this._options.blurTextureSizeRatio,null,we.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine()),this._downSamplePostprocess.onApplyObservable.add(function(a){a.setTexture("textureSampler",e._mainTexture)}),this._horizontalBlurPostprocess=new ku("HighlightLayerHBP",new u.d(1,0),this._options.blurHorizontalSize,1,null,we.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine()),this._horizontalBlurPostprocess.onApplyObservable.add(function(a){a.setFloat2("screenSize",n,i)}),this._verticalBlurPostprocess=new ku("HighlightLayerVBP",new u.d(0,1),this._options.blurVerticalSize,1,null,we.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine()),this._verticalBlurPostprocess.onApplyObservable.add(function(a){a.setFloat2("screenSize",n,i)}),this._postProcesses=[this._downSamplePostprocess,this._horizontalBlurPostprocess,this._verticalBlurPostprocess]):(this._horizontalBlurPostprocess=new _n("HighlightLayerHBP",new u.d(1,0),this._options.blurHorizontalSize/2,{width:n,height:i},null,we.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,o),this._horizontalBlurPostprocess.width=n,this._horizontalBlurPostprocess.height=i,this._horizontalBlurPostprocess.onApplyObservable.add(function(a){a.setTexture("textureSampler",e._mainTexture)}),this._verticalBlurPostprocess=new _n("HighlightLayerVBP",new u.d(0,1),this._options.blurVerticalSize/2,{width:n,height:i},null,we.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,o),this._postProcesses=[this._horizontalBlurPostprocess,this._verticalBlurPostprocess]),this._mainTexture.onAfterUnbindObservable.add(function(){e.onBeforeBlurObservable.notifyObservers(e);var a=e._blurTexture.getInternalTexture();a&&(e._scene.postProcessManager.directRender(e._postProcesses,a,!0),e._engine.unBindFramebuffer(a,!0)),e.onAfterBlurObservable.notifyObservers(e)}),this._postProcesses.map(function(a){a.autoClear=!1})},t.prototype.needStencil=function(){return!0},t.prototype.isReady=function(e,n){var i=e.getMaterial(),o=e.getRenderingMesh();if(!i||!o||!this._meshes)return!1;var a=null,s=this._meshes[o.uniqueId];return s&&s.glowEmissiveOnly&&i&&(a=i.emissiveTexture),r.prototype._isReady.call(this,e,n,a)},t.prototype._internalRender=function(e){e.setTexture("textureSampler",this._blurTexture);var n=this._engine;n.cacheStencilState(),n.setStencilOperationPass(h.a.REPLACE),n.setStencilOperationFail(h.a.KEEP),n.setStencilOperationDepthFail(h.a.KEEP),n.setStencilMask(0),n.setStencilBuffer(!0),n.setStencilFunctionReference(this._instanceGlowingMeshStencilReference),this.outerGlow&&(e.setFloat("offset",0),n.setStencilFunction(h.a.NOTEQUAL),n.drawElementsType(Ht.a.TriangleFillMode,0,6)),this.innerGlow&&(e.setFloat("offset",1),n.setStencilFunction(h.a.EQUAL),n.drawElementsType(Ht.a.TriangleFillMode,0,6)),n.restoreStencilState()},t.prototype.shouldRender=function(){return!!r.prototype.shouldRender.call(this)&&!!this._meshes},t.prototype._shouldRenderMesh=function(e){return(!this._excludedMeshes||!this._excludedMeshes[e.uniqueId])&&!!r.prototype.hasMesh.call(this,e)},t.prototype._canRenderMesh=function(e,n){return!0},t.prototype._addCustomEffectDefines=function(e){e.push("#define HIGHLIGHT")},t.prototype._setEmissiveTextureAndColor=function(e,n,i){var o=this._meshes[e.uniqueId];o?this._emissiveTextureAndColor.color.set(o.color.r,o.color.g,o.color.b,1):this._emissiveTextureAndColor.color.set(this.neutralColor.r,this.neutralColor.g,this.neutralColor.b,this.neutralColor.a),o&&o.glowEmissiveOnly&&i?(this._emissiveTextureAndColor.texture=i.emissiveTexture,this._emissiveTextureAndColor.color.set(1,1,1,1)):this._emissiveTextureAndColor.texture=null},t.prototype.addExcludedMesh=function(e){this._excludedMeshes&&(this._excludedMeshes[e.uniqueId]||(this._excludedMeshes[e.uniqueId]={mesh:e,beforeBind:e.onBeforeBindObservable.add(function(n){n.getEngine().setStencilBuffer(!1)}),afterRender:e.onAfterRenderObservable.add(function(n){n.getEngine().setStencilBuffer(!0)})}))},t.prototype.removeExcludedMesh=function(e){if(this._excludedMeshes){var n=this._excludedMeshes[e.uniqueId];n&&(n.beforeBind&&e.onBeforeBindObservable.remove(n.beforeBind),n.afterRender&&e.onAfterRenderObservable.remove(n.afterRender)),this._excludedMeshes[e.uniqueId]=null}},t.prototype.hasMesh=function(e){return!!this._meshes&&!!r.prototype.hasMesh.call(this,e)&&this._meshes[e.uniqueId]!==void 0&&this._meshes[e.uniqueId]!==null},t.prototype.addMesh=function(e,n,i){var o=this;if(i===void 0&&(i=!1),this._meshes){var a=this._meshes[e.uniqueId];a?a.color=n:(this._meshes[e.uniqueId]={mesh:e,color:n,observerHighlight:e.onBeforeBindObservable.add(function(s){o.isEnabled&&(o._excludedMeshes&&o._excludedMeshes[s.uniqueId]?o._defaultStencilReference(s):s.getScene().getEngine().setStencilFunctionReference(o._instanceGlowingMeshStencilReference))}),observerDefault:e.onAfterRenderObservable.add(function(s){o.isEnabled&&o._defaultStencilReference(s)}),glowEmissiveOnly:i},e.onDisposeObservable.add(function(){o._disposeMesh(e)})),this._shouldRender=!0}},t.prototype.removeMesh=function(e){if(this._meshes){var n=this._meshes[e.uniqueId];for(var i in n&&(n.observerHighlight&&e.onBeforeBindObservable.remove(n.observerHighlight),n.observerDefault&&e.onAfterRenderObservable.remove(n.observerDefault),delete this._meshes[e.uniqueId]),this._shouldRender=!1,this._meshes)if(this._meshes[i]){this._shouldRender=!0;break}}},t.prototype.removeAllMeshes=function(){if(this._meshes){for(var e in this._meshes)if(this._meshes.hasOwnProperty(e)){var n=this._meshes[e];n&&this.removeMesh(n.mesh)}}}
6913,t.prototype._defaultStencilReference=function(e){e.getScene().getEngine().setStencilFunctionReference(t.NormalMeshStencilReference)},t.prototype._disposeMesh=function(e){this.removeMesh(e),this.removeExcludedMesh(e)},t.prototype.dispose=function(){if(this._meshes){for(var e in this._meshes)(n=this._meshes[e])&&n.mesh&&(n.observerHighlight&&n.mesh.onBeforeBindObservable.remove(n.observerHighlight),n.observerDefault&&n.mesh.onAfterRenderObservable.remove(n.observerDefault));this._meshes=null}if(this._excludedMeshes){for(var e in this._excludedMeshes){var n;(n=this._excludedMeshes[e])&&(n.beforeBind&&n.mesh.onBeforeBindObservable.remove(n.beforeBind),n.afterRender&&n.mesh.onAfterRenderObservable.remove(n.afterRender))}this._excludedMeshes=null}r.prototype.dispose.call(this)},t.prototype.getClassName=function(){return"HighlightLayer"},t.prototype.serialize=function(){var e=L.a.Serialize(this);if(e.customType="BABYLON.HighlightLayer",e.meshes=[],this._meshes)for(var n in this._meshes){var i=this._meshes[n];i&&e.meshes.push({glowEmissiveOnly:i.glowEmissiveOnly,color:i.color.asArray(),meshId:i.mesh.id})}if(e.excludedMeshes=[],this._excludedMeshes)for(var o in this._excludedMeshes){var a=this._excludedMeshes[o];a&&e.excludedMeshes.push(a.mesh.id)}return e},t.Parse=function(e,n,i){var o,a=L.a.Parse(function(){return new t(e.name,n,e.options)},e,n,i);for(o=0;o<e.excludedMeshes.length;o++)(s=n.getMeshByID(e.excludedMeshes[o]))&&a.addExcludedMesh(s);for(o=0;o<e.meshes.length;o++){var s,d=e.meshes[o];(s=n.getMeshByID(d.meshId))&&a.addMesh(s,M.a.FromArray(d.color),d.glowEmissiveOnly)}return a},t.EffectName="HighlightLayer",t.NeutralColor=new M.b(0,0,0,0),t.GlowingMeshStencilReference=2,t.NormalMeshStencilReference=1,Object(c.c)([Object(L.c)()],t.prototype,"innerGlow",void 0),Object(c.c)([Object(L.c)()],t.prototype,"outerGlow",void 0),Object(c.c)([Object(L.c)()],t.prototype,"blurHorizontalSize",null),Object(c.c)([Object(L.c)()],t.prototype,"blurVerticalSize",null),Object(c.c)([Object(L.c)("options")],t.prototype,"_options",void 0),t}(fo);R.a.RegisteredTypes["BABYLON.HighlightLayer"]=Xs;var Gu=function(){function r(t){this.name=st.a.NAME_LAYER,this.scene=t,this._engine=t.getEngine(),t.layers=new Array}return r.prototype.register=function(){this.scene._beforeCameraDrawStage.registerStep(st.a.STEP_BEFORECAMERADRAW_LAYER,this,this._drawCameraBackground),this.scene._afterCameraDrawStage.registerStep(st.a.STEP_AFTERCAMERADRAW_LAYER,this,this._drawCameraForeground),this.scene._beforeRenderTargetDrawStage.registerStep(st.a.STEP_BEFORERENDERTARGETDRAW_LAYER,this,this._drawRenderTargetBackground),this.scene._afterRenderTargetDrawStage.registerStep(st.a.STEP_AFTERRENDERTARGETDRAW_LAYER,this,this._drawRenderTargetForeground)},r.prototype.rebuild=function(){for(var t=0,e=this.scene.layers;t<e.length;t++)e[t]._rebuild()},r.prototype.dispose=function(){for(var t=this.scene.layers;t.length;)t[0].dispose()},r.prototype._draw=function(t){var e=this.scene.layers;if(e.length){this._engine.setDepthBuffer(!1);for(var n=0,i=e;n<i.length;n++){var o=i[n];t(o)&&o.render()}this._engine.setDepthBuffer(!0)}},r.prototype._drawCameraPredicate=function(t,e,n){return!t.renderOnlyInRenderTargetTextures&&t.isBackground===e&&(t.layerMask&n)!=0},r.prototype._drawCameraBackground=function(t){var e=this;this._draw(function(n){return e._drawCameraPredicate(n,!0,t.layerMask)})},r.prototype._drawCameraForeground=function(t){var e=this;this._draw(function(n){return e._drawCameraPredicate(n,!1,t.layerMask)})},r.prototype._drawRenderTargetPredicate=function(t,e,n,i){return t.renderTargetTextures.length>0&&t.isBackground===e&&t.renderTargetTextures.indexOf(i)>-1&&(t.layerMask&n)!=0},r.prototype._drawRenderTargetBackground=function(t){var e=this;this._draw(function(n){return e._drawRenderTargetPredicate(n,!0,e.scene.activeCamera.layerMask,t)})},r.prototype._drawRenderTargetForeground=function(t){var e=this;this._draw(function(n){return e._drawRenderTargetPredicate(n,!1,e.scene.activeCamera.layerMask,t)})},r.prototype.addFromContainer=function(t){var e=this;
6913t.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}(),Q_=`
6914varying vec2 vUV;
6915uniform sampler2D textureSampler;
6916
6917uniform vec4 color;
6918
6919#include<helperFunctions>
6920void main(void) {
6921vec4 baseColor=texture2D(textureSampler,vUV);
6922#ifdef LINEAR
6923baseColor.rgb=toGammaSpace(baseColor.rgb);
6924#endif
6925#ifdef ALPHATEST
6926if (baseColor.a<0.4)
6927discard;
6928#endif
6929gl_FragColor=baseColor*color;
6930}`;je.a.ShadersStore.layerPixelShader=Q_;var q_=`
6931attribute vec2 position;
6932
6933uniform vec2 scale;
6934uniform vec2 offset;
6935uniform mat4 textureMatrix;
6936
6937varying vec2 vUV;
6938const vec2 madd=vec2(0.5,0.5);
6939void main(void) {
6940vec2 shiftedPosition=position*scale+offset;
6941vUV=vec2(textureMatrix*vec4(shiftedPosition*madd+madd,1.0,0.0));
6942gl_Position=vec4(shiftedPosition,0.0,1.0);
6943}`;je.a.ShadersStore.layerVertexShader=q_;var Z_=function(){function r(t,e,n,i,o){this.name=t,this.scale=new u.d(1,1),this.offset=new u.d(0,0),this.alphaBlendingMode=h.a.ALPHA_COMBINE,this.layerMask=268435455,this.renderTargetTextures=[],this.renderOnlyInRenderTargetTextures=!1,this._vertexBuffers={},this.onDisposeObservable=new x.c,this.onBeforeRenderObservable=new x.c,this.onAfterRenderObservable=new x.c,this.texture=e?new we.a(e,n,!0):null,this.isBackground=i===void 0||i,this.color=o===void 0?new M.b(1,1,1,1):o,this._scene=n||te.a.LastCreatedScene;var a=this._scene._getComponent(st.a.NAME_LAYER);a||(a=new Gu(this._scene),this._scene._addComponent(a)),this._scene.layers.push(this);var s=this._scene.getEngine(),d=[];d.push(1,1),d.push(-1,1),d.push(-1,-1),d.push(1,-1);var p=new Me.b(s,d,Me.b.PositionKind,!1,!1,2);this._vertexBuffers[Me.b.PositionKind]=p,this._createIndexBuffer()}return Object.defineProperty(r.prototype,"onDispose",{set:function(t){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"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}),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[Me.b.PositionKind];t&&t._rebuild(),this._createIndexBuffer()},r.prototype.render=function(){var t=this._scene.getEngine(),e="";this.alphaTest&&(e="#define ALPHATEST"),this.texture&&!this.texture.gammaSpace&&(e+=`\r
6944#define LINEAR`),this._previousDefines!==e&&(this._previousDefines=e,this._effect=t.createEffect("layer",[Me.b.PositionKind],["textureMatrix","color","scale","offset"],["textureSampler"],e));var n=this._effect;n&&n.isReady()&&this.texture&&this.texture.isReady()&&(t=this._scene.getEngine(),this.onBeforeRenderObservable.notifyObservers(this),t.enableEffect(n),t.setState(!1),n.setTexture("textureSampler",this.texture),n.setMatrix("textureMatrix",this.texture.getTextureMatrix()),n.setFloat4("color",this.color.r,this.color.g,this.color.b,this.color.a),n.setVector2("offset",this.offset),n.setVector2("scale",this.scale),t.bindBuffers(this._vertexBuffers,this._indexBuffer,n),this.alphaTest?t.drawElementsType(Ht.a.TriangleFillMode,0,6):(t.setAlphaMode(this.alphaBlendingMode),t.drawElementsType(Ht.a.TriangleFillMode,0,6),t.setAlphaMode(h.a.ALPHA_DISABLE)),this.onAfterRenderObservable.notifyObservers(this))},r.prototype.dispose=function(){var t=this._vertexBuffers[Me.b.PositionKind];t&&(t.dispose(),this._vertexBuffers[Me.b.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}(),zu=function(){function r(t,e,n,i,o){this.size=t,this.position=e,this.alphaMode=h.a.ALPHA_ONEONE,this.color=n||new M.a(1,1,1),this.texture=i?new we.a(i,o.getScene(),!0):null,this._system=o,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}(),J_=`
6945varying vec2 vUV;
6946uniform sampler2D textureSampler;
6947
6948uniform vec4 color;
6949void main(void) {
6950vec4 baseColor=texture2D(textureSampler,vUV);
6951gl_FragColor=baseColor*color;
6952}`;je.a.ShadersStore.lensFlarePixelShader=J_;var $_=`
6953attribute vec2 position;
6954
6955uniform mat4 viewportMatrix;
6956
6957varying vec2 vUV;
6958const vec2 madd=vec2(0.5,0.5);
6959void main(void) {
6960vUV=position*madd+madd;
6961gl_Position=viewportMatrix*vec4(position,0.0,1.0);
6962}`;je.a.ShadersStore.lensFlareVertexShader=$_;var Ys=function(){function r(t,e,n){this.name=t,this.lensFlares=new Array,this.borderLimit=300,this.viewportBorder=0,this.layerMask=268435455,this._vertexBuffers={},this._isEnabled=!0,this._scene=n||te.a.LastCreatedScene,r._SceneComponentInitialization(this._scene),this._emitter=e,this.id=t,n.lensFlareSystems.push(this),this.meshesSelectionPredicate=function(s){return n.activeCamera&&s.material&&s.isVisible&&s.isEnabled()&&s.isBlocker&&(s.layerMask&n.activeCamera.layerMask)!=0};var i=n.getEngine(),o=[];o.push(1,1),o.push(-1,1),o.push(-1,-1),o.push(1,-1),this._vertexBuffers[Me.b.PositionKind]=new Me.b(i,o,Me.b.PositionKind,!1,!1,2);var a=[];a.push(0),a.push(1),a.push(2),a.push(0),a.push(2),a.push(3),this._indexBuffer=i.createIndexBuffer(a),this._effect=i.createEffe
6962ct("lensFlare",[Me.b.PositionKind],["color","viewportMatrix"],["textureSampler"],"")}return 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();return e=u.e.Project(e,u.a.Identity(),this._scene.getTransformMatrix(),t),this._positionX=e.x,this._positionY=e.y,e=u.e.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),e.z>0&&(this._positionX>t.x&&this._positionX<t.x+t.width&&this._positionY>t.y&&(this._positionY,t.y,t.height),!0)},r.prototype._isVisible=function(){if(!this._isEnabled||!this._scene.activeCamera)return!1;var t=this.getEmitterPosition().subtract(this._scene.activeCamera.globalPosition),e=t.length();t.normalize();var n=new dn.a(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._effect.isReady()||!this._scene.activeCamera)return!1;var t,e,n=this._scene.getEngine(),i=this._scene.activeCamera.viewport.toGlobal(n.getRenderWidth(!0),n.getRenderHeight(!0));if(!this.computeEffectivePosition(i)||!this._isVisible())return!1;var o=(t=this._positionX<this.borderLimit+i.x?this.borderLimit+i.x-this._positionX:this._positionX>i.x+i.width-this.borderLimit?this._positionX-i.x-i.width+this.borderLimit:0)>(e=this._positionY<this.borderLimit+i.y?this.borderLimit+i.y-this._positionY:this._positionY>i.y+i.height-this.borderLimit?this._positionY-i.y-i.height+this.borderLimit:0)?t:e;(o-=this.viewportBorder)>this.borderLimit&&(o=this.borderLimit);var a=1-$.a.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,d=i.y+i.height/2,p=s-this._positionX,y=d-this._positionY;n.enableEffect(this._effect),n.setState(!1),n.setDepthBuffer(!1),n.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect);for(var P=0;P<this.lensFlares.length;P++){var O=this.lensFlares[P];if(!O.texture||O.texture.isReady()){n.setAlphaMode(O.alphaMode);var U=s-p*O.position,F=d-y*O.position,z=O.size,J=O.size*n.getAspectRatio(this._scene.activeCamera,!0),ie=U/(i.width+2*i.x)*2-1,se=1-F/(i.height+2*i.y)*2,ce=u.a.FromValues(z/2,0,0,0,0,J/2,0,0,0,0,1,0,ie,se,0,1);this._effect.setMatrix("viewportMatrix",ce),this._effect.setTexture("textureSampler",O.texture),this._effect.setFloat4("color",O.color.r*a,O.color.g*a,O.color.b*a,1),n.drawElementsType(Ht.a.TriangleFillMode,0,6)}}return n.setDepthBuffer(!0),n.setAlphaMode(h.a.ALPHA_DISABLE),!0},r.prototype.dispose=function(){var t=this._vertexBuffers[Me.b.PositionKind];for(t&&(t.dispose(),this._vertexBuffers[Me.b.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null);this.lensFlares.length;)this.lensFlares[0].dispose();var e=this._scene.lensFlareSystems.indexOf(this);this._scene.lensFlareSystems.splice(e,1)},r.Parse=function(t,e,n){var i=e.getLastEntryByID(t.emitterId),o=t.name||"lensFlareSystem#"+t.emitterId,a=new r(o,i,e);a.id=t.id||o,a.borderLimit=t.borderLimit;for(var s=0;s<t.flares.length;s++){var d=t.flares[s];zu.AddFlare(d.size,d.position,M.a.FromArray(d.color),d.textureName?n+d.textureName:"",a)}return a},r.prototype.serialize=function(){var t={};t.id=this.id,t.name=this.name,t.emitterId=this.getEmitter().id,t.borderLimit=this.borderLimit,t.flares=[];for(var e=0;e<this.lensFlares.length;e++){var n=this.lensFlares[e];t.flares.push({size:n.size,position:n.position,color:n.color.asArray(),textureName:Ye.b.GetFilename(n.texture?n.texture.name:"")})}return t},r._SceneComponentInitialization=function(t){throw En.a.WarnImport("LensFlareSystemSceneComponent")},r}();B.a.AddParser(st.a.NAME_LENSFLARESYSTEM,function(r,t,e,n){if(r.lensFlareSystems!==void 0&&r.lensFlareSystems!==null){e.lensFlareSystems||(e.lensFlareSystems=new Array);for(var i=0,o=r.lensFlareSystems.length;i<o;i++){var a=r.lensFlareSystems[i],s=Ys.Parse(a,t,n);e.lensFlareSystems.push(s)}}}),B.a.prototype.getLensFlareSystemByName=function(r){for(var t=0;t<this.lensFlareSystems.length;t++)if(this.lensFlareSystems[t].name===r)return this.lensFlareSystems[t];return null},B.a.prototype.getLensFlareSystemByID=function(r){for(var t=0;t<this.lensFlareSystems.length;t++)if(this.lensFlareSystems[t].id===r)return this.lensFlareSystems[t];return null},B.a.prototype.removeLensFlareSystem=function(r){var t=this.lensFlareSystems.indexOf(r);return t!==-1&&this.lensFlareSystems.splice(t,1),t},B.a.prototype.addLensFlareSystem=function(r){this.lensFlareSystems.push(r)};var ju=function(){function r(t){this.name=st.a.NAME_LENSFLARESYSTEM,this.scene=t,t.lensFlareSystems=new Array}return r.prototype.register=function(){this.scene._afterCameraDrawStage.registerStep(st.a.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM,this,this._draw)},r.prototype.rebuild=function(){},r.prototype.addFromContainer=function(t){var e=this;
6962t.lensFlareSystems&&t.lensFlareSystems.forEach(function(n){e.scene.addLensFlareSystem(n)})},r.prototype.removeFromContainer=function(t,e){var n=this;t.lensFlareSystems&&t.lensFlareSystems.forEach(function(i){n.scene.removeLensFlareSystem(i),e&&i.dispose()})},r.prototype.serialize=function(t){t.lensFlareSystems=[];for(var e=0,n=this.scene.lensFlareSystems;e<n.length;e++){var i=n[e];t.lensFlareSystems.push(i.serialize())}},r.prototype.dispose=function(){for(var t=this.scene.lensFlareSystems;t.length;)t[0].dispose()},r.prototype._draw=function(t){if(this.scene.lensFlaresEnabled){var e=this.scene.lensFlareSystems;Ye.b.StartPerformanceCounter("Lens flares",e.length>0);for(var n=0,i=e;n<i.length;n++){var o=i[n];t.layerMask&o.layerMask&&o.render()}Ye.b.EndPerformanceCounter("Lens flares",e.length>0)}},r}();Ys._SceneComponentInitialization=function(r){var t=r._getComponent(st.a.NAME_LENSFLARESYSTEM);t||(t=new ju(r),r._addComponent(t))};var em=`
6963
6964
6965
6966
6967float bayerDither2(vec2 _P) {
6968return mod(2.0*_P.y+_P.x+1.0,4.0);
6969}
6970
6971
6972float bayerDither4(vec2 _P) {
6973vec2 P1=mod(_P,2.0);
6974vec2 P2=floor(0.5*mod(_P,4.0));
6975return 4.0*bayerDither2(P1)+bayerDither2(P2);
6976}
6977
6978float bayerDither8(vec2 _P) {
6979vec2 P1=mod(_P,2.0);
6980vec2 P2=floor(0.5*mod(_P,4.0));
6981vec2 P4=floor(0.25*mod(_P,8.0));
6982return 4.0*(4.0*bayerDither2(P1)+bayerDither2(P2))+bayerDither2(P4);
6983}
6984`;je.a.IncludesShadersStore.bayerDitherFunctions=em;var tm=`#if SM_FLOAT == 0
6985#include<packingFunctions>
6986#endif
6987#if SM_SOFTTRANSPARENTSHADOW == 1
6988#include<bayerDitherFunctions>
6989uniform float softTransparentShadowSM;
6990#endif
6991varying float vDepthMetricSM;
6992#if SM_USEDISTANCE == 1
6993uniform vec3 lightDataSM;
6994varying vec3 vPositionWSM;
6995#endif
6996uniform vec3 biasAndScaleSM;
6997uniform vec2 depthValuesSM;
6998#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1
6999varying float zSM;
7000#endif
7001`;je.a.IncludesShadersStore.shadowMapFragmentDeclaration=tm;var nm=` float depthSM=vDepthMetricSM;
7002#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1
7003#if SM_USEDISTANCE == 1
7004depthSM=clamp(((length(vPositionWSM-lightDataSM)+depthValuesSM.x)/(depthValuesSM.y))+biasAndScaleSM.x,0.0,1.0);
7005#else
7006depthSM=clamp(((zSM+depthValuesSM.x)/(depthValuesSM.y))+biasAndScaleSM.x,0.0,1.0);
7007#endif
7008gl_FragDepth=depthSM;
7009#elif SM_USEDISTANCE == 1
7010depthSM=(length(vPositionWSM-lightDataSM)+depthValuesSM.x)/(depthValuesSM.y)+biasAndScaleSM.x;
7011#endif
7012#if SM_ESM == 1
7013depthSM=clamp(exp(-min(87.,biasAndScaleSM.z*depthSM)),0.,1.);
7014#endif
7015#if SM_FLOAT == 1
7016gl_FragColor=vec4(depthSM,1.0,1.0,1.0);
7017#else
7018gl_FragColor=pack(depthSM);
7019#endif
7020return;`;je.a.IncludesShadersStore.shadowMapFragment=nm;var im=`#include<shadowMapFragmentDeclaration>
7021#ifdef ALPHATEST
7022varying vec2 vUV;
7023uniform sampler2D diffuseSampler;
7024#endif
7025#include<clipPlaneFragmentDeclaration>
7026void main(void)
7027{
7028#include<clipPlaneFragment>
7029#ifdef ALPHATEST
7030float alphaFromAlphaTexture=texture2D(diffuseSampler,vUV).a;
7031if (alphaFromAlphaTexture<0.4)
7032discard;
7033#endif
7034#if SM_SOFTTRANSPARENTSHADOW == 1
7035#ifdef ALPHATEST
7036if ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM*alphaFromAlphaTexture) discard;
7037#else
7038if ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM) discard;
7039#endif
7040#endif
7041#include<shadowMapFragment>
7042}`;je.a.ShadersStore.shadowMapPixelShader=im;var rm=`#if SM_NORMALBIAS == 1
7043uniform vec3 lightDataSM;
7044#endif
7045uniform vec3 biasAndScaleSM;
7046uniform vec2 depthValuesSM;
7047varying float vDepthMetricSM;
7048#if SM_USEDISTANCE == 1
7049varying vec3 vPositionWSM;
7050#endif
7051#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1
7052varying float zSM;
7053#endif
7054`;je.a.IncludesShadersStore.shadowMapVertexDeclaration=rm;var om=`
7055#if SM_NORMALBIAS == 1
7056#if SM_DIRECTIONINLIGHTDATA == 1
7057vec3 worldLightDirSM=normalize(-lightDataSM.xyz);
7058#else
7059vec3 directionToLightSM=lightDataSM.xyz-worldPos.xyz;
7060vec3 worldLightDirSM=normalize(directionToLightSM);
7061#endif
7062float ndlSM=dot(vNormalW,worldLightDirSM);
7063float sinNLSM=sqrt(1.0-ndlSM*ndlSM);
7064float normalBiasSM=biasAndScaleSM.y*sinNLSM;
7065worldPos.xyz-=vNormalW*normalBiasSM;
7066#endif
7067`;je.a.IncludesShadersStore.shadowMapVertexNormalBias=om;var am=`#if SM_USEDISTANCE == 1
7068vPositionWSM=worldPos.xyz;
7069#endif
7070#if SM_DEPTHTEXTURE == 1
7071
7072gl_Position.z+=biasAndScaleSM.x*gl_Position.w;
7073#endif
7074#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1
7075zSM=gl_Position.z;
7076gl_Position.z=0.0;
7077#elif SM_USEDISTANCE == 0
7078
7079vDepthMetricSM=((gl_Position.z+depthValuesSM.x)/(depthValuesSM.y))+biasAndScaleSM.x;
7080#endif
7081`;je.a.IncludesShadersStore.shadowMapVertexMetric=am;var sm=`
7082attribute vec3 position;
7083#ifdef NORMAL
7084attribute vec3 normal;
7085#endif
7086#include<bonesDeclaration>
7087#include<morphTargetsVertexGlobalDeclaration>
7088#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
7089
7090#include<instancesDeclaration>
7091#include<helperFunctions>
7092uniform mat4 viewProjection;
7093#ifdef ALPHATEST
7094varying vec2 vUV;
7095uniform mat4 diffuseMatrix;
7096#ifdef UV1
7097attribute vec2 uv;
7098#endif
7099#ifdef UV2
7100attribute vec2 uv2;
7101#endif
7102#endif
7103#include<shadowMapVertexDeclaration>
7104#include<clipPlaneVertexDeclaration>
7105void main(void)
7106{
7107vec3 positionUpdated=position;
7108#ifdef UV1
7109vec2 uvUpdated=uv;
7110#endif
7111#ifdef NORMAL
7112vec3 normalUpdated=normal;
7113#endif
7114#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
7115#include<instancesVertex>
7116#include<bonesVertex>
7117vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);
7118#ifdef NORMAL
7119mat3 normWorldSM=mat3(finalWorld);
7120#if defined(INSTANCES) && defined(THIN_INSTANCES)
7121vec3 vNormalW=normalUpdated/vec3(dot(normWorldSM[0],normWorldSM[0]),dot(normWorldSM[1],normWorldSM[1]),dot(normWorldSM[2],normWorldSM[2]));
7122vNormalW=normalize(normWorldSM*vNormalW);
7123#else
7124#ifdef NONUNIFORMSCALING
7125normWorldSM=transposeMat3(inverseMat3(normWorldSM));
7126#endif
7127vec3 vNormalW=normalize(normWorldSM*normalUpdated);
7128#endif
7129#endif
7130#include<shadowMapVertexNormalBias>
7131
7132gl_Position=viewProjection*worldPos;
7133#include<shadowMapVertexMetric>
7134#ifdef ALPHATEST
7135#ifdef UV1
7136vUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));
7137#endif
7138#ifdef UV2
7139vUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
7140#endif
7141#endif
7142#include<clipPlaneVertex>
7143}`;je.a.ShadersStore.shadowMapVertexShader=sm;var cm=`
7144varying vec2 vUV;
7145uniform sampler2D textureSampler;
7146
7147uniform vec2 screenSize;
7148void main(void)
7149{
7150vec4 colorDepth=vec4(0.0);
7151for (int x=-OFFSET; x<=OFFSET; x++)
7152for (int y=-OFFSET; y<=OFFSET; y++)
7153colorDepth+=texture2D(textureSampler,vUV+vec2(x,y)/screenSize);
7154gl_FragColor=(colorDepth/float((OFFSET*2+1)*(OFFSET*2+1)));
7155}`;je.a.ShadersStore.depthBoxBlurPixelShader=cm;var lm=`#if SM_SOFTTRANSPARENTSHADOW == 1
7156if ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM*alpha) discard;
7157#endif
7158`;je.a.IncludesShadersStore.shadowMapFragmentSoftTransparentShadow=lm;var Hu=new u.a,Wu=new u.a,Fn=function(){function r(t,e,n){this.onBeforeShadowMapRenderObservable=new x.c,this.onAfterShadowMapRenderObservable=new x.c,this.onBeforeShadowMapRenderMeshObservable=new x.c,this.onAfterShadowMapRenderMeshObservable=new x.c,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.frustumEdgeFalloff=0,this.forceBackFacesOnly=!1,this._lightDirection=u.e.Zero(),this._viewMatrix=u.a.Zero(),this._projectionMatrix=u.a.Zero(),this._transformMatrix=u.a.Zero(),this._cachedPosition=new u.e(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cachedDirection=new u.e(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._currentFaceIndex=0,this._currentFaceIndexCache=0,this._defaultTextureMatrix=u.a.Identity(),this._mapSize=t,this._light=e,this._scene=e.getScene(),e._shadowGenerator=this,this.id=e.id,r._SceneComponentInitialization(this._scene);var i=this._scene.getEngine().getCaps();n?i.textureFloatRender&&i.textureFloatLinearFiltering?this._textureType=h.a.TEXTURETYPE_FLOAT:i.textureHalfFloatRender&&i.textureHalfFloatLinearFiltering?this._textureType=h.a.TEXTURETYPE_HALF_FLOAT:this._textureType=h.a.TEXTURETYPE_UNSIGNED_INT:i.textureHalfFloatRender&&i.textureHalfFloatLinearFiltering?this._textureType=h.a.TEXTURETYPE_HALF_FLOAT:i.textureFloatRender&&i.textureFloatLinearFiltering?this._textureType=h.a.TEXTURETYPE_FLOAT:this._textureType=h.a.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())}
7158,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().webGLVersion!==1?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}
7158,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}
7158,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){var n;return e===void 0&&(e=!0),this._shadowMap?(this._shadowMap.renderList||(this._shadowMap.renderList=[]),this._shadowMap.renderList.push(t),e&&(n=this._shadowMap.renderList).push.apply(n,t.getChildMeshes()),this):this},r.prototype.removeShadowCaster=function(t,e){if(e===void 0&&(e=!0),!this._shadowMap||!this._shadowMap.renderList)return this;var n=this._shadowMap.renderList.indexOf(t);if(n!==-1&&this._shadowMap.renderList.splice(n,1),e)for(var i=0,o=t.getChildren();i<o.length;i++){var a=o[i];this.removeShadowCaster(a)}return this},r.prototype.getLight=function(){return this._light},Object.defineProperty(r.prototype,"mapSize",{get:function(){return this._mapSize},set:function(t){this._mapSize=t,this._light._markMeshesAsLightDirty(),this.recreateShadowMap()},enumerable:!1,configurable:!0}),r.prototype._initializeGenerator=function(){this._light._markMeshesAsLightDirty(),this._initializeShadowMap()},r.prototype._createTargetRenderTexture=function(){this._scene.getEngine().webGLVersion>1?(this._shadowMap=new sn(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube(),void 0,!1,!1),this._shadowMap.createDepthStencilTexture(h.a.LESS,!0)):this._shadowMap=new sn(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube())},r.prototype._initializeShadowMap=function(){var t=this;if(this._createTargetRenderTexture(),this._shadowMap!==null){this._shadowMap.wrapU=we.a.CLAMP_ADDRESSMODE,this._shadowMap.wrapV=we.a.CLAMP_ADDRESSMODE,this._shadowMap.anisotropicFilteringLevel=1,this._shadowMap.updateSamplingMode(we.a.BILINEAR_SAMPLINGMODE),this._shadowMap.renderParticles=!1,this._shadowMap.ignoreCameraViewport=!0,this._storedUniqueId&&(this._shadowMap.uniqueId=this._storedUniqueId),this._shadowMap.customRenderFunction=this._renderForShadowMap.bind(this),this._shadowMap.customIsReadyFunction=function(a,s){return!0};var e=this._scene.getEngine();
7158this._shadowMap.onBeforeRenderObservable.add(function(a){if(t._currentFaceIndex=a,t._filter===r.FILTER_PCF&&e.setColorWrite(!1),t._scene.getSceneUniformBuffer().useUbo){var s=t._scene.getSceneUniformBuffer();s.updateMatrix("viewProjection",t.getTransformMatrix()),s.updateMatrix("view",t._viewMatrix),s.update()}}),this._shadowMap.onAfterUnbindObservable.add(function(){if(t._scene.getSceneUniformBuffer().useUbo){var a=t._scene.getSceneUniformBuffer();a.updateMatrix("viewProjection",t._scene.getTransformMatrix()),a.updateMatrix("view",t._scene.getViewMatrix()),a.update()}if(t._filter===r.FILTER_PCF&&e.setColorWrite(!0),t.useBlurExponentialShadowMap||t.useBlurCloseExponentialShadowMap){var s=t.getShadowMapForRendering();if(s){var d=s.getInternalTexture();t._scene.postProcessManager.directRender(t._blurPostProcesses,d,!0),e.unBindFramebuffer(d,!0)}}});var n=new M.b(0,0,0,0),i=new M.b(1,1,1,1);this._shadowMap.onClearObservable.add(function(a){t._filter===r.FILTER_PCF?a.clear(i,!1,!0,!1):t.useExponentialShadowMap||t.useBlurExponentialShadowMap?a.clear(n,!0,!0,!1):a.clear(i,!0,!0,!1)}),this._shadowMap.onResizeObservable.add(function(a){t._storedUniqueId=t._shadowMap.uniqueId,t._mapSize=a.getRenderSize(),t._light._markMeshesAsLightDirty(),t.recreateShadowMap()});for(var o=eo.b.MIN_RENDERINGGROUPS;o<eo.b.MAX_RENDERINGGROUPS;o++)this._shadowMap.setRenderingAutoClearDepthStencil(o,!1)}},r.prototype._initializeBlurRTTAndPostProcesses=function(){var t=this,e=this._scene.getEngine(),n=this._mapSize/this.blurScale;this.useKernelBlur&&this.blurScale===1||(this._shadowMap2=new sn(this._light.name+"_shadowMap2",n,this._scene,!1,!0,this._textureType),this._shadowMap2.wrapU=we.a.CLAMP_ADDRESSMODE,this._shadowMap2.wrapV=we.a.CLAMP_ADDRESSMODE,this._shadowMap2.updateSamplingMode(we.a.BILINEAR_SAMPLINGMODE)),this.useKernelBlur?(this._kernelBlurXPostprocess=new _n(this._light.name+"KernelBlurX",new u.d(1,0),this.blurKernel,1,null,we.a.BILINEAR_SAMPLINGMODE,e,!1,this._textureType),this._kernelBlurXPostprocess.width=n,this._kernelBlurXPostprocess.height=n,this._kernelBlurXPostprocess.onApplyObservable.add(function(i){i.setTexture("textureSampler",t._shadowMap)}),this._kernelBlurYPostprocess=new _n(this._light.name+"KernelBlurY",new u.d(0,1),this.blurKernel,1,null,we.a.BILINEAR_SAMPLINGMODE,e,!1,this._textureType),this._kernelBlurXPostprocess.autoClear=!1,this._kernelBlurYPostprocess.autoClear=!1,this._textureType===h.a.TEXTURETYPE_UNSIGNED_INT&&(this._kernelBlurXPostprocess.packedFloat=!0,this._kernelBlurYPostprocess.packedFloat=!0),this._blurPostProcesses=[this._kernelBlurXPostprocess,this._kernelBlurYPostprocess]):(this._boxBlurPostprocess=new _t(this._light.name+"DepthBoxBlur","depthBoxBlur",["screenSize","boxOffset"],[],1,null,we.a.BILINEAR_SAMPLINGMODE,e,!1,"#define OFFSET "+this._blurBoxOffset,this._textureType),this._boxBlurPostprocess.onApplyObservable.add(function(i){i.setFloat2("screenSize",n,n),i.setTexture("textureSampler",t._shadowMap)}),this._boxBlurPostprocess.autoClear=!1,this._blurPostProcesses=[this._boxBlurPostprocess])},r.prototype._renderForShadowMap=function(t,e,n,i){var o,a=this._scene.getEngine(),s=a.getColorWrite();if(i.length){for(a.setColorWrite(!1),o=0;o<i.length;o++)this._renderSubMeshForShadowMap(i.data[o]);a.setColorWrite(s)}for(o=0;o<t.length;o++)this._renderSubMeshForShadowMap(t.data[o]);for(o=0;o<e.length;o++)this._renderSubMeshForShadowMap(e.data[o]);if(this._transparencyShadow)for(o=0;o<n.length;o++)this._renderSubMeshForShadowMap(n.data[o],!0);else for(o=0;o<n.length;o++)n.data[o].getEffectiveMesh()._internalAbstractMeshDataInfo._isActiveIntermediate=!1},r.prototype._bindCustomEffectForRenderSubMeshForShadowMap=function(t,e,n,i){var o,a,s,d,p,y;e.setMatrix((o=n?.viewProjection)!==null&&o!==void 0?o:"viewProjection",this.getTransformMatrix()),e.setMatrix((a=n?.view)!==null&&a!==void 0?a:"view",this._viewMatrix),e.setMatrix((s=n?.projection)!==null&&s!==void 0?s:"projection",this._projectionMatrix);var P=i.getWorldMatrix();e.setMatrix((d=n?.world)!==null&&d!==void 0?d:"world",P),P.multiplyToRef(this.getTransformMatrix(),Hu),e.setMatr
7158ix((p=n?.worldViewProjection)!==null&&p!==void 0?p:"worldViewProjection",Hu),P.multiplyToRef(this._viewMatrix,Wu),e.setMatrix((y=n?.worldView)!==null&&y!==void 0?y:"worldView",Wu)},r.prototype._renderSubMeshForShadowMap=function(t,e){var n,i;e===void 0&&(e=!1);var o=t.getRenderingMesh(),a=t.getEffectiveMesh(),s=this._scene,d=s.getEngine(),p=t.getMaterial();if(a._internalAbstractMeshDataInfo._isActiveIntermediate=!1,p&&t.verticesCount!==0&&t._renderId!==s.getRenderId()){d.setState(p.backFaceCulling);var y=o._getInstancesRenderList(t._id,!!t.getReplacementMesh());if(!y.mustReturn){var P=d.getCaps().instancedArrays&&(y.visibleInstances[t._id]!==null&&y.visibleInstances[t._id]!==void 0||o.hasThinInstances);if(!this.customAllowRendering||this.customAllowRendering(t))if(this.isReady(t,P,e)){t._renderId=s.getRenderId();var O=(n=o.material)===null||n===void 0?void 0:n.shadowDepthWrapper,U=(i=O?.getEffect(t,this))!==null&&i!==void 0?i:this._effect;if(d.enableEffect(U),o._bind(t,U,p.fillMode),this.getTransformMatrix(),U.setFloat3("biasAndScaleSM",this.bias,this.normalBias,this.depthScale),this.getLight().getTypeID()===Ci.a.LIGHTTYPEID_DIRECTIONALLIGHT?U.setVector3("lightDataSM",this._cachedDirection):U.setVector3("lightDataSM",this._cachedPosition),s.activeCamera&&U.setFloat2("depthValuesSM",this.getLight().getDepthMinZ(s.activeCamera),this.getLight().getDepthMinZ(s.activeCamera)+this.getLight().getDepthMaxZ(s.activeCamera)),e&&this.enableSoftTransparentShadow&&U.setFloat("softTransparentShadowSM",a.visibility),O)t._effectOverride=U,O.standalone?O.baseMaterial.bindForSubMesh(a.getWorldMatrix(),o,t):p.bindForSubMesh(a.getWorldMatrix(),o,t),t._effectOverride=null;else{if(U.setMatrix("viewProjection",this.getTransformMatrix()),p&&p.needAlphaTesting()){var F=p.getAlphaTestTexture();F&&(U.setTexture("diffuseSampler",F),U.setMatrix("diffuseMatrix",F.getTextureMatrix()||this._defaultTextureMatrix))}if(o.useBones&&o.computeBonesUsingShaders&&o.skeleton){var z=o.skeleton;if(z.isUsingTextureForMatrices){var J=z.getTransformMatrixTexture(o);if(!J)return;U.setTexture("boneSampler",J),U.setFloat("boneTextureWidth",4*(z.bones.length+1))}else U.setMatrices("mBones",z.getTransformMatrices(o))}tt.a.BindMorphTargetParameters(o,U),tt.a.BindClipPlane(U,s)}this._bindCustomEffectForRenderSubMeshForShadowMap(t,U,O?._matriceNames,a),this.forceBackFacesOnly&&d.setState(!0,0,!1,!0),this.onBeforeShadowMapRenderMeshObservable.notifyObservers(o),this.onBeforeShadowMapRenderObservable.notifyObservers(U),o._processRendering(a,t,U,p.fillMode,y,P,function(ie,se){return U.setMatrix("world",se)}),this.forceBackFacesOnly&&d.setState(!0,0,!1,!1),this.onAfterShadowMapRenderObservable.notifyObservers(U),this.onAfterShadowMapRenderMeshObservable.notifyObservers(o)}else this._shadowMap&&this._shadowMap.resetRefreshCounter()}}},r.prototype._applyFilterValues=function(){this._shadowMap&&(this.filter===r.FILTER_NONE||this.filter===r.FILTER_PCSS?this._shadowMap.updateSamplingMode(we.a.NEAREST_SAMPLINGMODE):this._shadowMap.updateSamplingMode(we.a.BILINEAR_SAMPLINGMODE))},r.prototype.forceCompilation=function(t,e){var n=this,i=Object(c.a)({useInstances:!1},e),o=this.getShadowMap();if(o){var a=o.renderList;if(a){for(var s=new Array,d=0,p=a;d<p.length;d++){var y=p[d];s.push.apply(s,y.subMeshes)}if(s.length!==0){var P=0,O=function(){var U,F;if(n._scene&&n._scene.getEngine()){for(;n.isReady(s[P],i.useInstances,(F=(U=s[P].getMaterial())===null||U===void 0?void 0:U.needAlphaBlendingForMesh(s[P].getMesh()))!==null&&F!==void 0&&F);)if(++P>=s.length)return void(t&&t(n));setTimeout(O,16)}};O()}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_FLOAT "+(this._textureType!==h.a.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"));
7158var o=t.getMesh();return n.push("#define SM_NORMALBIAS "+(this.normalBias&&o.isVerticesDataPresent(Me.b.NormalKind)?"1":"0")),n.push("#define SM_DIRECTIONINLIGHTDATA "+(this.getLight().getTypeID()===Ci.a.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=t.getMaterial(),o=i?.shadowDepthWrapper,a=[];if(this._prepareShadowDefines(t,e,a,n),o){if(!o.isReadyForSubMesh(t,a,this,e))return!1}else{var s=[Me.b.PositionKind],d=t.getMesh();if(this.normalBias&&d.isVerticesDataPresent(Me.b.NormalKind)&&(s.push(Me.b.NormalKind),a.push("#define NORMAL"),d.nonUniformScaling&&a.push("#define NONUNIFORMSCALING")),i&&i.needAlphaTesting()){var p=i.getAlphaTestTexture();if(p){if(!p.isReady())return!1;a.push("#define ALPHATEST"),d.isVerticesDataPresent(Me.b.UVKind)&&(s.push(Me.b.UVKind),a.push("#define UV1")),d.isVerticesDataPresent(Me.b.UV2Kind)&&p.coordinatesIndex===1&&(s.push(Me.b.UV2Kind),a.push("#define UV2"))}}var y=new Er.a;if(d.useBones&&d.computeBonesUsingShaders&&d.skeleton){s.push(Me.b.MatricesIndicesKind),s.push(Me.b.MatricesWeightsKind),d.numBoneInfluencers>4&&(s.push(Me.b.MatricesIndicesExtraKind),s.push(Me.b.MatricesWeightsExtraKind));var P=d.skeleton;a.push("#define NUM_BONE_INFLUENCERS "+d.numBoneInfluencers),d.numBoneInfluencers>0&&y.addCPUSkinningFallback(0,d),P.isUsingTextureForMatrices?a.push("#define BONETEXTURE"):a.push("#define BonesPerMesh "+(P.bones.length+1))}else a.push("#define NUM_BONE_INFLUENCERS 0");var O=d.morphTargetManager,U=0;O&&O.numInfluencers>0&&(a.push("#define MORPHTARGETS"),U=O.numInfluencers,a.push("#define NUM_MORPH_INFLUENCERS "+U),tt.a.PrepareAttributesForMorphTargetsInfluencers(s,d,U));var F=this._scene;if(F.clipPlane&&a.push("#define CLIPPLANE"),F.clipPlane2&&a.push("#define CLIPPLANE2"),F.clipPlane3&&a.push("#define CLIPPLANE3"),F.clipPlane4&&a.push("#define CLIPPLANE4"),F.clipPlane5&&a.push("#define CLIPPLANE5"),F.clipPlane6&&a.push("#define CLIPPLANE6"),e&&(a.push("#define INSTANCES"),tt.a.PushAttributesForInstances(s),t.getRenderingMesh().hasThinInstances&&a.push("#define THIN_INSTANCES")),this.customShaderOptions&&this.customShaderOptions.defines)for(var z=0,J=this.customShaderOptions.defines;z<J.length;z++){var ie=J[z];a.indexOf(ie)===-1&&a.push(ie)}var se=a.join(`
7159`);if(this._cachedDefines!==se){this._cachedDefines=se;var ce="shadowMap",ue=["world","mBones","viewProjection","diffuseMatrix","lightDataSM","depthValuesSM","biasAndScaleSM","morphTargetInfluences","boneTextureWidth","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","softTransparentShadowSM"],fe=["diffuseSampler","boneSampler"];if(this.customShaderOptions){if(ce=this.customShaderOptions.shaderName,this.customShaderOptions.attributes)for(var ve=0,Te=this.customShaderOptions.attributes;ve<Te.length;ve++){var Oe=Te[ve];s.indexOf(Oe)===-1&&s.push(Oe)}if(this.customShaderOptions.uniforms)for(var Pe=0,Ee=this.customShaderOptions.uniforms;Pe<Ee.length;Pe++){var Se=Ee[Pe];ue.indexOf(Se)===-1&&ue.push(Se)}if(this.customShaderOptions.samplers)for(var Le=0,xe=this.customShaderOptions.samplers;Le<xe.length;Le++){var Ne=xe[Le];fe.indexOf(Ne)===-1&&fe.push(Ne)}}this._effect=this._scene.getEngine().createEffect(ce,s,ue,fe,se,y,void 0,void 0,{maxSimultaneousMorphTargets:U})}if(!this._effect.isReady())return!1}return(this.useBlurExponentialShadowMap||this.useBlurCloseExponentialShadowMap)&&(this._blurPostProcesses&&this._blurPostProcesses.length||this._initializeBlurRTTAndPostProcesses()),!(this._kernelBlurXPostprocess&&!this._kernelBlurXPostprocess.isReady())&&!(this._kernelBlurYPostprocess&&!this._kernelBlurYPostprocess.isReady())&&!(this._boxBlurPostprocess&&!this._boxBlurPostprocess.isReady())},r.prototype.prepareDefines=function(t,e){var n=this._scene,i=this._light;n.shadowsEnabled&&i.shadowEnabled&&(t["SHADOW"+e]=!0,this.useContactHardeningShadow?(t["SHADOWPCSS"+e]=!0,this._filteringQuality===r.QUALITY_LOW?t["SHADOWLOWQUALITY"+e]=!0:this._filteringQuality===r.QUALITY_MEDIUM&&(t["SHADOWMEDIUMQUALITY"+e]=!0)):this.usePercentageCloserFiltering?(t["SHADOWPCF"+e]=!0,this._filteringQuality===r.QUALITY_LOW?t["SHADOWLOWQUALITY"+e]=!0:this._filteringQuality===r.QUALITY_MEDIUM&&(t["SHADOWMEDIUMQUALITY"+e]=!0)):this.usePoissonSampling?t["SHADOWPOISSON"+e]=!0:this.useExponentialShadowMap||this.useBlurExponentialShadowMap?t["SHADOWESM"+e]=!0:(this.useCloseExponentialShadowMap||this.useBlurCloseExponentialShadowMap)&&(t["SHADOWCLOSEESM"+e]=!0),i.needCube()&&
7159(t["SHADOWCUBE"+e]=!0))},r.prototype.bindShadowLight=function(t,e){var n=this._light,i=this._scene;if(i.shadowsEnabled&&n.shadowEnabled){var o=i.activeCamera;if(o){var a=this.getShadowMap();a&&(n.needCube()||e.setMatrix("lightMatrix"+t,this.getTransformMatrix()),this._filter===r.FILTER_PCF?(e.setDepthStencilTexture("shadowSampler"+t,this.getShadowMapForRendering()),n._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),a.getSize().width,1/a.getSize().width,this.frustumEdgeFalloff,t)):this._filter===r.FILTER_PCSS?(e.setDepthStencilTexture("shadowSampler"+t,this.getShadowMapForRendering()),e.setTexture("depthSampler"+t,this.getShadowMapForRendering()),n._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),1/a.getSize().width,this._contactHardeningLightSizeUVRatio*a.getSize().width,this.frustumEdgeFalloff,t)):(e.setTexture("shadowSampler"+t,this.getShadowMapForRendering()),n._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),this.blurScale/a.getSize().width,this.depthScale,this.frustumEdgeFalloff,t)),n._uniformBuffer.updateFloat2("depthValues",this.getLight().getDepthMinZ(o),this.getLight().getDepthMinZ(o)+this.getLight().getDepthMaxZ(o),t))}}},r.prototype.getTransformMatrix=function(){var t=this._scene;if(this._currentRenderID===t.getRenderId()&&this._currentFaceIndexCache===this._currentFaceIndex)return this._transformMatrix;this._currentRenderID=t.getRenderId(),this._currentFaceIndexCache=this._currentFaceIndex;var e=this._light.position;if(this._light.computeTransformedInformation()&&(e=this._light.transformedPosition),u.e.NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex),this._lightDirection),Math.abs(u.e.Dot(this._lightDirection,u.e.Up()))===1&&(this._lightDirection.z=1e-13),this._light.needProjectionMatrixCompute()||!this._cachedPosition||!this._cachedDirection||!e.equals(this._cachedPosition)||!this._lightDirection.equals(this._cachedDirection)){this._cachedPosition.copyFrom(e),this._cachedDirection.copyFrom(this._lightDirection),u.a.LookAtLHToRef(e,e.add(this._lightDirection),u.e.Up(),this._viewMatrix);var n=this.getShadowMap();if(n){var i=n.renderList;i&&this._light.setShadowProjectionMatrix(this._projectionMatrix,this._viewMatrix,i)}this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix)}return this._transformMatrix},r.prototype.recreateShadowMap=function(){var t=this._shadowMap;if(t){var e=t.renderList;this._disposeRTTandPostProcesses(),this._initializeGenerator(),this.filter=this.filter,this._applyFilterValues(),this._shadowMap.renderList=e}},r.prototype._disposeBlurPostProcesses=function(){this._shadowMap2&&(this._shadowMap2.dispose(),this._shadowMap2=null),this._boxBlurPostprocess&&(this._boxBlurPostprocess.dispose(),this._boxBlurPostprocess=null),this._kernelBlurXPostprocess&&(this._kernelBlurXPostprocess.dispose(),this._kernelBlurXPostprocess=null),this._kernelBlurYPostprocess&&(this._kernelBlurYPostprocess.dispose(),this._kernelBlurYPostprocess=null),this._blurPostProcesses=[]},r.prototype._disposeRTTandPostProcesses=function(){this._shadowMap&&(this._shadowMap.dispose(),this._shadowMap=null),this._disposeBlurPostProcesses()},r.prototype.dispose=function(){this._disposeRTTandPostProcesses(),this._light&&(this._light._shadowGenerator=null,this._light._markMeshesAsLightDirty()),this.onBeforeShadowMapRenderMeshObservable.clear(),this.onBeforeShadowMapRenderObservable.clear(),this.onAfterShadowMapRenderMeshObservable.clear(),this.onAfterShadowMapRenderObservable.clear()},r.prototype.serialize=function(){var t={},e=this.getShadowMap();if(!e)return t;if(t.className=this.getClassName(),t.lightId=this._light.id,t.id=this._light.id,t.mapSize=e.getRenderSize(),t.forceBackFacesOnly=this.forceBackFacesOnly,t.darkness=this.getDarkness(),t.transparencyShadow=this._transparencyShadow,t.frustumEdgeFalloff=this.frustumEdgeFalloff,t.bias=this.bias,t.normalBias=this.normalBias,t.usePercentageCloserFiltering=this.usePercentageCloserFiltering,t.useContactHardeningShadow=this.useContactHardeningShadow,t.contactHardeningLightSizeUVRatio=this.contactHardeningLightSizeUVRatio,t.filteringQuality=this.filteringQuality,t.useExponentialShadowMap=this.useExponentialShadowMap,t.useBlurExponentialShadowMap=this.useBlurExponentialShadowMap,t.useCloseExponentialShadowMap=this.useBlurExponentialShadowMap,t.useBlurCloseExponentialShadowMap=this.useBlurExponentialShadowMap,t.usePoissonSampling=this.usePoissonSampling,t.depthScale=this.depthScale,t.blurBoxOffset=this.blurBoxOffset,t.blurKernel=this.blurKernel,t.blurScale=this.blurScale,t.useKernelBlur=this.useKernelBlur,t.renderList=[],e.renderList)for(var n=0;n<e.renderList.length;n++){var i=e.renderList[n];t.renderList.push(i.id)}return t},r.Parse=function(t,e,n){for(var i=e.getLightByID(t.lightId),o=n?n(t.mapSize,i):new r(t.mapSize,i),a=o.getShadowMap(),s=0;s<t.renderList.length;
7159s++)e.getMeshesByID(t.renderList[s]).forEach(function(d){a&&(a.renderList||(a.renderList=[]),a.renderList.push(d))});return t.id!==void 0&&(o.id=t.id),o.forceBackFacesOnly=!!t.forceBackFacesOnly,t.darkness!==void 0&&o.setDarkness(t.darkness),t.transparencyShadow&&o.setTransparencyShadow(!0),t.frustumEdgeFalloff!==void 0&&(o.frustumEdgeFalloff=t.frustumEdgeFalloff),t.bias!==void 0&&(o.bias=t.bias),t.normalBias!==void 0&&(o.normalBias=t.normalBias),t.usePercentageCloserFiltering?o.usePercentageCloserFiltering=!0:t.useContactHardeningShadow?o.useContactHardeningShadow=!0:t.usePoissonSampling?o.usePoissonSampling=!0:t.useExponentialShadowMap?o.useExponentialShadowMap=!0:t.useBlurExponentialShadowMap?o.useBlurExponentialShadowMap=!0:t.useCloseExponentialShadowMap?o.useCloseExponentialShadowMap=!0:t.useBlurCloseExponentialShadowMap?o.useBlurCloseExponentialShadowMap=!0:t.useVarianceShadowMap?o.useExponentialShadowMap=!0:t.useBlurVarianceShadowMap&&(o.useBlurExponentialShadowMap=!0),t.contactHardeningLightSizeUVRatio!==void 0&&(o.contactHardeningLightSizeUVRatio=t.contactHardeningLightSizeUVRatio),t.filteringQuality!==void 0&&(o.filteringQuality=t.filteringQuality),t.depthScale&&(o.depthScale=t.depthScale),t.blurScale&&(o.blurScale=t.blurScale),t.blurBoxOffset&&(o.blurBoxOffset=t.blurBoxOffset),t.useKernelBlur&&(o.useKernelBlur=t.useKernelBlur),t.blurKernel&&(o.blurKernel=t.blurKernel),o},r.CLASSNAME="ShadowGenerator",r.FILTER_NONE=0,r.FILTER_EXPONENTIALSHADOWMAP=1,r.FILTER_POISSONSAMPLING=2,r.FILTER_BLUREXPONENTIALSHADOWMAP=3,r.FILTER_CLOSEEXPONENTIALSHADOWMAP=4,r.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP=5,r.FILTER_PCF=6,r.FILTER_PCSS=7,r.QUALITY_HIGH=0,r.QUALITY_MEDIUM=1,r.QUALITY_LOW=2,r._SceneComponentInitialization=function(t){throw En.a.WarnImport("ShadowGeneratorSceneComponent")},r}(),um=`#ifdef ALPHATEST
7160varying vec2 vUV;
7161uniform sampler2D diffuseSampler;
7162#endif
7163varying float vDepthMetric;
7164#ifdef PACKED
7165#include<packingFunctions>
7166#endif
7167void main(void)
7168{
7169#ifdef ALPHATEST
7170if (texture2D(diffuseSampler,vUV).a<0.4)
7171discard;
7172#endif
7173#ifdef NONLINEARDEPTH
7174#ifdef PACKED
7175gl_FragColor=pack(gl_FragCoord.z);
7176#else
7177gl_FragColor=vec4(gl_FragCoord.z,0.0,0.0,0.0);
7178#endif
7179#else
7180#ifdef PACKED
7181gl_FragColor=pack(vDepthMetric);
7182#else
7183gl_FragColor=vec4(vDepthMetric,0.0,0.0,1.0);
7184#endif
7185#endif
7186}`;je.a.ShadersStore.depthPixelShader=um;var hm=`
7187attribute vec3 position;
7188#include<bonesDeclaration>
7189#include<morphTargetsVertexGlobalDeclaration>
7190#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
7191
7192#include<instancesDeclaration>
7193uniform mat4 viewProjection;
7194uniform vec2 depthValues;
7195#if defined(ALPHATEST) || defined(NEED_UV)
7196varying vec2 vUV;
7197uniform mat4 diffuseMatrix;
7198#ifdef UV1
7199attribute vec2 uv;
7200#endif
7201#ifdef UV2
7202attribute vec2 uv2;
7203#endif
7204#endif
7205varying float vDepthMetric;
7206void main(void)
7207{
7208vec3 positionUpdated=position;
7209#ifdef UV1
7210vec2 uvUpdated=uv;
7211#endif
7212#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
7213#include<instancesVertex>
7214#include<bonesVertex>
7215gl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);
7216vDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y));
7217#if defined(ALPHATEST) || defined(BASIC_RENDER)
7218#ifdef UV1
7219vUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));
7220#endif
7221#ifdef UV2
7222vUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
7223#endif
7224#endif
7225}
7226`;je.a.ShadersStore.depthVertexShader=hm;var ca=function(){function r(t,e,n,i){var o=this;e===void 0&&(e=h.a.TEXTURETYPE_FLOAT),n===void 0&&(n=null),i===void 0&&(i=!1),this.enabled=!0,this.useOnlyInActiveCamera=!1,this._scene=t,this._storeNonLinearDepth=i,this.isPacked=e===h.a.TEXTURETYPE_UNSIGNED_BYTE,this.isPacked?this._clearColor=new M.b(1,1,1,1):this._clearColor=new M.b(1,0,0,1),r._SceneComponentInitialization(this._scene),this._camera=n;var a=t.getEngine(),s=this.isPacked||a.webGLVersion===1?h.a.TEXTUREFORMAT_RGBA:h.a.TEXTUREFORMAT_R;this._depthMap=new sn("depthMap",{width:a.getRenderWidth(),height:a.getRenderHeight()},this._scene,!1,!0,e,!1,void 0,void 0,void 0,void 0,s),this._depthMap.wrapU=we.a.CLAMP_ADDRESSMODE,this._depthMap.wrapV=we.a.CLAMP_ADDRESSMODE,this._depthMap.refreshRate=1,this._depthMap.renderParticles=!1,this._depthMap.renderList=null,this._depthMap.activeCamera=this._camera,this._depthMap.ignoreCameraViewport=!0,this._depthMap.useCameraPostProcesses=!1,this._depthMap.onClearObservable.add(function(p){p.clear(o._clearColor,!0,!0,!0)});var d=function(p){var y=p.getRenderingMesh(),P=p.getEffectiveMesh(),O=o._scene,U=O.getEngine(),F=p.getMaterial();if(P._internalAbstractMeshDataInfo._isActiveIntermediate=!1,F&&p.verticesCount!==0&&p._renderId!==O.getRenderId()){U.setState(F.backFaceCulling,0,!1,O.useRightHandedSystem);var z=y._getInstancesRenderList(p._id,!!p.getReplacementMesh());if(!z.mustReturn){var J=U.getCaps().instancedArrays&&(z.visibleInstances[p._id]!==null&&z.visibleInstances[p._id]!==void 0||y.hasThinInstances),ie=o._camera||O.activeCamera;if(o.isReady(p,J)&&ie){if(p._renderId=O.getRenderId(),U.enableEffect(o._effect),y._bind(p,o._effect,F.fillMode),o._effect.setMatr
7226ix("viewProjection",O.getTransformMatrix()),o._effect.setFloat2("depthValues",ie.minZ,ie.minZ+ie.maxZ),F&&F.needAlphaTesting()){var se=F.getAlphaTestTexture();se&&(o._effect.setTexture("diffuseSampler",se),o._effect.setMatrix("diffuseMatrix",se.getTextureMatrix()))}y.useBones&&y.computeBonesUsingShaders&&y.skeleton&&o._effect.setMatrices("mBones",y.skeleton.getTransformMatrices(y)),tt.a.BindMorphTargetParameters(y,o._effect),y._processRendering(P,p,o._effect,F.fillMode,z,J,function(ce,ue){return o._effect.setMatrix("world",ue)})}}}};this._depthMap.customRenderFunction=function(p,y,P,O){var U;if(O.length){for(a.setColorWrite(!1),U=0;U<O.length;U++)d(O.data[U]);a.setColorWrite(!0)}for(U=0;U<p.length;U++)d(p.data[U]);for(U=0;U<y.length;U++)d(y.data[U])}}return r.prototype.isReady=function(t,e){var n=t.getMaterial();if(n.disableDepthWrite)return!1;var i=[],o=[Me.b.PositionKind],a=t.getMesh();n&&n.needAlphaTesting()&&n.getAlphaTestTexture()&&(i.push("#define ALPHATEST"),a.isVerticesDataPresent(Me.b.UVKind)&&(o.push(Me.b.UVKind),i.push("#define UV1")),a.isVerticesDataPresent(Me.b.UV2Kind)&&(o.push(Me.b.UV2Kind),i.push("#define UV2"))),a.useBones&&a.computeBonesUsingShaders?(o.push(Me.b.MatricesIndicesKind),o.push(Me.b.MatricesWeightsKind),a.numBoneInfluencers>4&&(o.push(Me.b.MatricesIndicesExtraKind),o.push(Me.b.MatricesWeightsExtraKind)),i.push("#define NUM_BONE_INFLUENCERS "+a.numBoneInfluencers),i.push("#define BonesPerMesh "+(a.skeleton?a.skeleton.bones.length+1:0))):i.push("#define NUM_BONE_INFLUENCERS 0");var s=a.morphTargetManager,d=0;s&&s.numInfluencers>0&&(d=s.numInfluencers,i.push("#define MORPHTARGETS"),i.push("#define NUM_MORPH_INFLUENCERS "+d),tt.a.PrepareAttributesForMorphTargetsInfluencers(o,a,d)),e&&(i.push("#define INSTANCES"),tt.a.PushAttributesForInstances(o),t.getRenderingMesh().hasThinInstances&&i.push("#define THIN_INSTANCES")),this._storeNonLinearDepth&&i.push("#define NONLINEARDEPTH"),this.isPacked&&i.push("#define PACKED");var p=i.join(`
7227`);return this._cachedDefines!==p&&(this._cachedDefines=p,this._effect=this._scene.getEngine().createEffect("depth",o,["world","mBones","viewProjection","diffuseMatrix","depthValues","morphTargetInfluences"],["diffuseSampler"],p,void 0,void 0,void 0,{maxSimultaneousMorphTargets:d})),this._effect.isReady()},r.prototype.getDepthMap=function(){return this._depthMap},r.prototype.dispose=function(){this._depthMap.dispose()},r._SceneComponentInitialization=function(t){throw En.a.WarnImport("DepthRendererSceneComponent")},r}(),dm=`attribute vec2 vUV;
7228uniform sampler2D textureSampler;
7229#if defined(INITIAL)
7230uniform sampler2D sourceTexture;
7231uniform vec2 texSize;
7232void main(void)
7233{
7234ivec2 coord=ivec2(vUV*(texSize-1.0));
7235float f1=texelFetch(sourceTexture,coord,0).r;
7236float f2=texelFetch(sourceTexture,coord+ivec2(1,0),0).r;
7237float f3=texelFetch(sourceTexture,coord+ivec2(1,1),0).r;
7238float f4=texelFetch(sourceTexture,coord+ivec2(0,1),0).r;
7239float minz=min(min(min(f1,f2),f3),f4);
7240#ifdef DEPTH_REDUX
7241float maxz=max(max(max(sign(1.0-f1)*f1,sign(1.0-f2)*f2),sign(1.0-f3)*f3),sign(1.0-f4)*f4);
7242#else
7243float maxz=max(max(max(f1,f2),f3),f4);
7244#endif
7245glFragColor=vec4(minz,maxz,0.,0.);
7246}
7247#elif defined(MAIN)
7248uniform vec2 texSize;
7249void main(void)
7250{
7251ivec2 coord=ivec2(vUV*(texSize-1.0));
7252vec2 f1=texelFetch(textureSampler,coord,0).rg;
7253vec2 f2=texelFetch(textureSampler,coord+ivec2(1,0),0).rg;
7254vec2 f3=texelFetch(textureSampler,coord+ivec2(1,1),0).rg;
7255vec2 f4=texelFetch(textureSampler,coord+ivec2(0,1),0).rg;
7256float minz=min(min(min(f1.x,f2.x),f3.x),f4.x);
7257float maxz=max(max(max(f1.y,f2.y),f3.y),f4.y);
7258glFragColor=vec4(minz,maxz,0.,0.);
7259}
7260#elif defined(ONEBEFORELAST)
7261uniform ivec2 texSize;
7262void main(void)
7263{
7264ivec2 coord=ivec2(vUV*vec2(texSize-1));
7265vec2 f1=texelFetch(textureSampler,coord % texSize,0).rg;
7266vec2 f2=texelFetch(textureSampler,(coord+ivec2(1,0)) % texSize,0).rg;
7267vec2 f3=texelFetch(textureSampler,(coord+ivec2(1,1)) % texSize,0).rg;
7268vec2 f4=texelFetch(textureSampler,(coord+ivec2(0,1)) % texSize,0).rg;
7269float minz=min(f1.x,f2.x);
7270float maxz=max(f1.y,f2.y);
7271glFragColor=vec4(minz,maxz,0.,0.);
7272}
7273#elif defined(LAST)
7274void main(void)
7275{
7276discard;
7277glFragColor=vec4(0.);
7278}
7279#endif
7280`;je.a.ShadersStore.minmaxReduxPixelShader=dm;var Xu=function(){function r(t){this.onAfterReductionPerformed=new x.c,this._forceFullscreenViewport=!0,this._activated=!1,this._camera=t,this._postProcessManager=new ms.a(t.getSce
7280ne())}return Object.defineProperty(r.prototype,"sourceTexture",{get:function(){return this._sourceTexture},enumerable:!1,configurable:!0}),r.prototype.setSourceTexture=function(t,e,n,i){var o=this;if(n===void 0&&(n=h.a.TEXTURETYPE_HALF_FLOAT),i===void 0&&(i=!0),t!==this._sourceTexture){this.dispose(!1),this._sourceTexture=t,this._reductionSteps=[],this._forceFullscreenViewport=i;var a=this._camera.getScene(),s=new _t("Initial reduction phase","minmaxRedux",["texSize"],["sourceTexture"],1,null,h.a.TEXTURE_NEAREST_NEAREST,a.getEngine(),!1,"#define INITIAL"+(e?`
7281#define DEPTH_REDUX`:""),n,void 0,void 0,void 0,h.a.TEXTUREFORMAT_RG);s.autoClear=!1,s.forceFullscreenViewport=i;var d=this._sourceTexture.getRenderWidth(),p=this._sourceTexture.getRenderHeight();s.onApply=function(O,U){return function(F){F.setTexture("sourceTexture",o._sourceTexture),F.setFloatArray2("texSize",new Float32Array([O,U]))}}(d,p),this._reductionSteps.push(s);for(var y=1;d>1||p>1;){d=Math.max(Math.round(d/2),1),p=Math.max(Math.round(p/2),1);var P=new _t("Reduction phase "+y,"minmaxRedux",["texSize"],null,{width:d,height:p},null,h.a.TEXTURE_NEAREST_NEAREST,a.getEngine(),!1,"#define "+(d==1&&p==1?"LAST":d==1||p==1?"ONEBEFORELAST":"MAIN"),n,void 0,void 0,void 0,h.a.TEXTUREFORMAT_RG);P.autoClear=!1,P.forceFullscreenViewport=i,P.onApply=function(O,U){return function(F){O==1||U==1?F.setIntArray2("texSize",new Int32Array([O,U])):F.setFloatArray2("texSize",new Float32Array([O,U]))}}(d,p),this._reductionSteps.push(P),y++,d==1&&p==1&&P.onAfterRenderObservable.add(function(O,U,F){var z=new Float32Array(4*O*U),J={min:0,max:0};return function(){a.getEngine()._readTexturePixels(F.inputTexture,O,U,-1,0,z),J.min=z[0],J.max=z[1],o.onAfterReductionPerformed.notifyObservers(J)}}(d,p,P))}}},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(){t._reductionSteps[0].activate(t._camera),t._postProcessManager.directRender(t._reductionSteps,t._reductionSteps[0].inputTexture,t._forceFullscreenViewport),t._camera.getScene().getEngine().unBindFramebuffer(t._reductionSteps[0].inputTexture,!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.deactivate(),this._reductionSteps){for(var e=0;e<this._reductionSteps.length;++e)this._reductionSteps[e].dispose();this._reductionSteps=null}this._postProcessManager&&t&&this._postProcessManager.dispose(),this._sourceTexture=null},r}(),Yu=function(r){function t(e){return r.call(this,e)||this}return Object(c.d)(t,r),Object.defineProperty(t.prototype,"depthRenderer",{get:function(){return this._depthRenderer},enumerable:!1,configurable:!0}),t.prototype.setDepthRenderer=function(e,n,i){e===void 0&&(e=null),n===void 0&&(n=h.a.TEXTURETYPE_HALF_FLOAT),i===void 0&&(i=!0);var o=this._camera.getScene();this._depthRenderer&&(delete o._depthRenderer[this._depthRendererId],this._depthRenderer.dispose(),this._depthRenderer=null),e===null&&(o._depthRenderer||(o._depthRenderer={}),(e=this._depthRenderer=new ca(o,n,this._camera,!1)).enabled=!1,this._depthRendererId="minmax"+this._camera.id,o._depthRenderer[this._depthRendererId]=e),r.prototype.setSourceTexture.call(this,e.getDepthMap(),!0,n,i)},t.prototype.setSourceTexture=function(e,n,i,o){i===void 0&&(i=h.a.TEXTURETYPE_HALF_FLOAT),o===void 0&&(o=!0),r.prototype.setSourceTexture.call(this,e,n,i,o)},t.prototype.activate=function(){this._depthRenderer&&(this._depthRenderer.enabled=!0),r.prototype.activate.call(this)},t.prototype.deactivate=function(){r.prototype.deactivate.call(this),this._depthRenderer&&(this._depthRenderer.enabled=!1)},t.prototype.dispose=function(e){if(e===void 0&&(e=!0),r.prototype.dispose.call(this,e),this._depthRenderer&&e){var n=this._depthRenderer.getDepthMap().getScene();n&&delete n._depthRenderer[this._depthRendererId],this._depthRenderer.dispose(),this._depthRenderer=null}},t}(Xu),Ku=u.e.Up(),fm=u.e.Zero(),mn=new u.e,Rr=new u.e,Or=new u.a,Qu=new u.a,Ks=function(r){function t(e,n,i){var o=this;if(t.IsSupported)return(o=r.call(this,e,n,i)||this).usePercentageCloserFiltering=!0,o;l.a.Error("CascadedShadowMap needs WebGL 2 support.")}return Object(c.d)(t,r),t.prototype._validateFilter=function(e){return e===Fn.FILTER_NONE||e===Fn.FILTER_PCF||e===Fn.FILTER_PCSS?e:(console.error('Unsupported filter "'+e+'"!'),Fn.FILTER_NONE)},Object.defineProperty(t.prototype,"numCascades",{get:function(){return this._numCascades},set:function(e){(e=Math.min(Math.max(e,t.MIN_CASCADES_COUNT),t.MAX_CASCADES_COUNT))!==this._numCascades&&(this._numCascades=e,this.recreateShadowMap())}
7281,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"freezeShadowCastersBoundingInfo",{get:function(){return this._freezeShadowCastersBoundingInfo},set:function(e){this._freezeShadowCastersBoundingInfoObservable&&e&&(this._scene.onBeforeRenderObservable.remove(this._freezeShadowCastersBoundingInfoObservable),this._freezeShadowCastersBoundingInfoObservable=null),this._freezeShadowCastersBoundingInfoObservable||e||(this._freezeShadowCastersBoundingInfoObservable=this._scene.onBeforeRenderObservable.add(this._computeShadowCastersBoundingInfo.bind(this))),this._freezeShadowCastersBoundingInfo=e,e&&this._computeShadowCastersBoundingInfo()},enumerable:!1,configurable:!0}),t.prototype._computeShadowCastersBoundingInfo=function(){if(this._scbiMin.copyFromFloats(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._scbiMax.copyFromFloats(Number.MIN_VALUE,Number.MIN_VALUE,Number.MIN_VALUE),this._shadowMap&&this._shadowMap.renderList){for(var e=this._shadowMap.renderList,n=0;n<e.length;n++)if(a=e[n]){var i=a.getBoundingInfo().boundingBox;this._scbiMin.minimizeInPlace(i.minimumWorld),this._scbiMax.maximizeInPlace(i.maximumWorld)}var o=this._scene.meshes;for(n=0;n<o.length;n++){var a;(a=o[n])&&a.isVisible&&a.isEnabled&&a.receiveShadows&&(i=a.getBoundingInfo().boundingBox,this._scbiMin.minimizeInPlace(i.minimumWorld),this._scbiMax.maximizeInPlace(i.maximumWorld))}}this._shadowCastersBoundingInfo.reConstruct(this._scbiMin,this._scbiMax)},Object.defineProperty(t.prototype,"shadowCastersBoundingInfo",{get:function(){return this._shadowCastersBoundingInfo},set:function(e){this._shadowCastersBoundingInfo=e},enumerable:!1,configurable:!0}),t.prototype.setMinMaxDistance=function(e,n){this._minDistance===e&&this._maxDistance===n||(e>n&&(e=0,n=1),e<0&&(e=0),n>1&&(n=1),this._minDistance=e,this._maxDistance=n,this._breaksAreDirty=!0)},Object.defineProperty(t.prototype,"minDistance",{get:function(){return this._minDistance},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"maxDistance",{get:function(){return this._maxDistance},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return t.CLASSNAME},t.prototype.getCascadeMinExtents=function(e){return e>=0&&e<this._numCascades?this._cascadeMinExtents[e]:null},t.prototype.getCascadeMaxExtents=function(e){return e>=0&&e<this._numCascades?this._cascadeMaxExtents[e]:null},Object.defineProperty(t.prototype,"shadowMaxZ",{get:function(){return this._scene&&this._scene.activeCamera?this._shadowMaxZ:0},set:function(e){this._scene&&this._scene.activeCamera?this._shadowMaxZ===e||e<this._scene.activeCamera.minZ||e>this._scene.activeCamera.maxZ||(this._shadowMaxZ=e,this._light._markMeshesAsLightDirty(),this._breaksAreDirty=!0):this._shadowMaxZ=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"debug",{get:function(){return this._debug},set:function(e){this._debug=e,this._light._markMeshesAsLightDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthClamp",{get:function(){return this._depthClamp},set:function(e){this._depthClamp=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cascadeBlendPercentage",{get:function(){return this._cascadeBlendPercentage},set:function(e){this._cascadeBlendPercentage=e,this._light._markMeshesAsLightDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lambda",{get:function(){return this._lambda},set:function(e){var n=Math.min(Math.max(e,0),1);this._lambda!=n&&(this._lambda=n,this._breaksAreDirty=!0)},enumerable:!1,configurable:!0}),t.prototype.getCascadeViewMatrix=function(e){return e>=0&&e<this._numCascades?this._viewMatrices[e]:null},t.prototype.getCascadeProjectionMatrix=function(e){return e>=0&&e<this._numCascades?this._projectionMatrices[e]:null},t.prototype.getCascadeTransformMatrix=function(e){return e>=0&&e<this._numCascades?this._transformMatrices[e]:null},t.prototype.setDepthRenderer=function(e){this._depthRenderer=e,this._depthReducer&&this._depthReducer.setDepthRenderer(this._depthRenderer)},Object.defineProperty(t.prototype,"autoCalcDepthBounds",{get:function(){return this._autoCalcDepthBounds}
7281,set:function(e){var n=this,i=this._scene.activeCamera;if(i){if(this._autoCalcDepthBounds=e,!e)return this._depthReducer&&this._depthReducer.deactivate(),void this.setMinMaxDistance(0,1);this._depthReducer||(this._depthReducer=new Yu(i),this._depthReducer.onAfterReductionPerformed.add(function(o){var a=o.min,s=o.max;a>=s&&(a=0,s=1),a==n._minDistance&&s==n._maxDistance||n.setMinMaxDistance(a,s)}),this._depthReducer.setDepthRenderer(this._depthRenderer)),this._depthReducer.activate()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"autoCalcDepthBoundsRefreshRate",{get:function(){var e,n,i;return(i=(n=(e=this._depthReducer)===null||e===void 0?void 0:e.depthRenderer)===null||n===void 0?void 0:n.getDepthMap().refreshRate)!==null&&i!==void 0?i:-1},set:function(e){var n;!((n=this._depthReducer)===null||n===void 0)&&n.depthRenderer&&(this._depthReducer.depthRenderer.getDepthMap().refreshRate=e)},enumerable:!1,configurable:!0}),t.prototype.splitFrustum=function(){this._breaksAreDirty=!0},t.prototype._splitFrustum=function(){var e=this._scene.activeCamera;if(e){for(var n=e.minZ,i=e.maxZ,o=i-n,a=this._minDistance,s=n+a*o,d=n+(this._shadowMaxZ<i&&this._shadowMaxZ>=n?Math.min((this._shadowMaxZ-n)/(i-n),this._maxDistance):this._maxDistance)*o,p=d-s,y=d/s,P=0;P<this._cascades.length;++P){var O=(P+1)/this._numCascades,U=s*Math.pow(y,O),F=s+p*O,z=this._lambda*(U-F)+F;this._cascades[P].prevBreakDistance=P===0?a:this._cascades[P-1].breakDistance,this._cascades[P].breakDistance=(z-n)/o,this._viewSpaceFrustumsZ[P]=n+this._cascades[P].breakDistance*o,this._frustumLengths[P]=(this._cascades[P].breakDistance-this._cascades[P].prevBreakDistance)*o}this._breaksAreDirty=!1}},t.prototype._computeMatrices=function(){if(this._scene.activeCamera){u.e.NormalizeToRef(this._light.getShadowDirection(0),this._lightDirection),Math.abs(u.e.Dot(this._lightDirection,u.e.Up()))===1&&(this._lightDirection.z=1e-13),this._cachedDirection.copyFrom(this._lightDirection);for(var e=0;e<this._numCascades;++e){this._computeFrustumInWorldSpace(e),this._computeCascadeFrustum(e),this._cascadeMaxExtents[e].subtractToRef(this._cascadeMinExtents[e],mn),this._frustumCenter[e].addToRef(this._lightDirection.scale(this._cascadeMinExtents[e].z),this._shadowCameraPos[e]),u.a.LookAtLHToRef(this._shadowCameraPos[e],this._frustumCenter[e],Ku,this._viewMatrices[e]);var n=0,i=mn.z,o=this._shadowCastersBoundingInfo;o.update(this._viewMatrices[e]),i=Math.min(i,o.boundingBox.maximumWorld.z),n=this._depthClamp&&this.filter!==Fn.FILTER_PCSS?Math.max(n,o.boundingBox.minimumWorld.z):Math.min(n,o.boundingBox.minimumWorld.z),u.a.OrthoOffCenterLHToRef(this._cascadeMinExtents[e].x,this._cascadeMaxExtents[e].x,this._cascadeMinExtents[e].y,this._cascadeMaxExtents[e].y,n,i,this._projectionMatrices[e]),this._cascadeMinExtents[e].z=n,this._cascadeMaxExtents[e].z=i,this._viewMatrices[e].multiplyToRef(this._projectionMatrices[e],this._transformMatrices[e]),u.e.TransformCoordinatesToRef(fm,this._transformMatrices[e],mn),mn.scaleInPlace(this._mapSize/2),Rr.copyFromFloats(Math.round(mn.x),Math.round(mn.y),Math.round(mn.z)),Rr.subtractInPlace(mn).scaleInPlace(2/this._mapSize),u.a.TranslationToRef(Rr.x,Rr.y,0,Or),this._projectionMatrices[e].multiplyToRef(Or,this._projectionMatrices[e]),this._viewMatrices[e].multiplyToRef(this._projectionMatrices[e],this._transformMatrices[e]),this._transformMatrices[e].copyToArray(this._transformMatricesAsArray,16*e)}}},t.prototype._computeFrustumInWorldSpace=function(e){if(this._scene.activeCamera){var n=this._cascades[e].prevBreakDistance,i=this._cascades[e].breakDistance;this._scene.activeCamera.getViewMatrix();for(var o=u.a.Invert(this._scene.activeCamera.getTransformationMatrix()),a=0;a<t.frustumCornersNDCSpace.length;++a)u.e.TransformCoordinatesToRef(t.frustumCornersNDCSpace[a],o,this._frustumCornersWorldSpace[e][a]);for(a=0;a<t.frustumCornersNDCSpace.length/2;++a)mn.copyFrom(this._frustumCornersWorldSpace[e][a+4]).subtractInPlace(this._frustumCornersWorldSpace[e][a]),Rr.copyFrom(mn).scaleInPlace(n),mn.scaleInPlace(i),mn.addInPlace(this._frustumCornersWorldSpace[e][a]),this._frustumCornersWorldSpace[e][a+4].copyFrom(mn
7281),this._frustumCornersWorldSpace[e][a].addInPlace(Rr)}},t.prototype._computeCascadeFrustum=function(e){if(this._cascadeMinExtents[e].copyFromFloats(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cascadeMaxExtents[e].copyFromFloats(Number.MIN_VALUE,Number.MIN_VALUE,Number.MIN_VALUE),this._frustumCenter[e].copyFromFloats(0,0,0),this._scene.activeCamera){for(var n=0;n<this._frustumCornersWorldSpace[e].length;++n)this._frustumCenter[e].addInPlace(this._frustumCornersWorldSpace[e][n]);if(this._frustumCenter[e].scaleInPlace(1/this._frustumCornersWorldSpace[e].length),this.stabilizeCascades){var i=0;for(n=0;n<this._frustumCornersWorldSpace[e].length;++n){var o=this._frustumCornersWorldSpace[e][n].subtractToRef(this._frustumCenter[e],mn).length();i=Math.max(i,o)}i=Math.ceil(16*i)/16,this._cascadeMaxExtents[e].copyFromFloats(i,i,i),this._cascadeMinExtents[e].copyFromFloats(-i,-i,-i)}else{var a=this._frustumCenter[e];for(this._frustumCenter[e].addToRef(this._lightDirection,mn),u.a.LookAtLHToRef(a,mn,Ku,Or),n=0;n<this._frustumCornersWorldSpace[e].length;++n)u.e.TransformCoordinatesToRef(this._frustumCornersWorldSpace[e][n],Or,mn),this._cascadeMinExtents[e].minimizeInPlace(mn),this._cascadeMaxExtents[e].maximizeInPlace(mn)}}},Object.defineProperty(t,"IsSupported",{get:function(){var e=te.a.LastCreatedEngine;return!!e&&e.webGLVersion!=1},enumerable:!1,configurable:!0}),t.prototype._initializeGenerator=function(){var e,n,i,o,a,s,d,p,y,P,O,U,F,z,J,ie,se,ce,ue,fe;this.penumbraDarkness=(e=this.penumbraDarkness)!==null&&e!==void 0?e:1,this._numCascades=(n=this._numCascades)!==null&&n!==void 0?n:t.DEFAULT_CASCADES_COUNT,this.stabilizeCascades=(i=this.stabilizeCascades)!==null&&i!==void 0&&i,this._freezeShadowCastersBoundingInfoObservable=(o=this._freezeShadowCastersBoundingInfoObservable)!==null&&o!==void 0?o:null,this.freezeShadowCastersBoundingInfo=(a=this.freezeShadowCastersBoundingInfo)!==null&&a!==void 0&&a,this._scbiMin=(s=this._scbiMin)!==null&&s!==void 0?s:new u.e(0,0,0),this._scbiMax=(d=this._scbiMax)!==null&&d!==void 0?d:new u.e(0,0,0),this._shadowCastersBoundingInfo=(p=this._shadowCastersBoundingInfo)!==null&&p!==void 0?p:new Fi.a(new u.e(0,0,0),new u.e(0,0,0)),this._breaksAreDirty=(y=this._breaksAreDirty)===null||y===void 0||y,this._minDistance=(P=this._minDistance)!==null&&P!==void 0?P:0,this._maxDistance=(O=this._maxDistance)!==null&&O!==void 0?O:1,this._currentLayer=(U=this._currentLayer)!==null&&U!==void 0?U:0,this._shadowMaxZ=(J=(F=this._shadowMaxZ)!==null&&F!==void 0?F:(z=this._scene.activeCamera)===null||z===void 0?void 0:z.maxZ)!==null&&J!==void 0?J:1e4,this._debug=(ie=this._debug)!==null&&ie!==void 0&&ie,this._depthClamp=(se=this._depthClamp)===null||se===void 0||se,this._cascadeBlendPercentage=(ce=this._cascadeBlendPercentage)!==null&&ce!==void 0?ce:.1,this._lambda=(ue=this._lambda)!==null&&ue!==void 0?ue:.5,this._autoCalcDepthBounds=(fe=this._autoCalcDepthBounds)!==null&&fe!==void 0&&fe,r.prototype._initializeGenerator.call(this)},t.prototype._createTargetRenderTexture=function(){var e={width:this._mapSize,height:this._mapSize,layers:this.numCascades};this._shadowMap=new sn(this._light.name+"_shadowMap",e,this._scene,!1,!0,this._textureType,!1,void 0,!1,!1,void 0),this._shadowMap.createDepthStencilTexture(h.a.LESS,!0)},t.prototype._initializeShadowMap=function(){var e=this;if(r.prototype._initializeShadowMap.call(this),this._shadowMap!==null){this._transformMatricesAsArray=new Float32Array(16*this._numCascades),this._viewSpaceFrustumsZ=new Array(this._numCascades),this._frustumLengths=new Array(this._numCascades),this._lightSizeUVCorrection=new Array(2*this._numCascades),this._depthCorrection=new Array(this._numCascades),this._cascades=[],this._viewMatrices=[],this._projectionMatrices=[],this._transformMatrices=[],this._cascadeMinExtents=[],this._cascadeMaxExtents=[],this._frustumCenter=[],this._shadowCameraPos=[],this._frustumCornersWorldSpace=[];for(var n=0;n<this._numCascades;++n){this._cascades[n]={prevBreakDistance:0,breakDistance:0},this._viewMatrices[n]=u.a.Zero(),this._projectionMatrices[n]=u.a.Zero(),this._transformMatrices[n]=u.a.Zero(),this._cascadeMinExtents[n]=new u.e,this._cascadeMaxExtents[n]=new u.e,this._frustumCenter[n]=new u.e,this._shadowCameraPos[n]=new u.e,this._frustumCornersWorldSpace[n]=new Array(t.frustumCornersNDCSpace.length);for(var i=0;i<t.frustumCornersNDCSpace.length;++i)this._frustumCornersWorldSpace[n][i]=new u.e}
7281this._shadowMap.onBeforeRenderObservable.add(function(o){if(e._currentLayer=o,e._scene.getSceneUniformBuffer().useUbo){var a=e._scene.getSceneUniformBuffer();a.updateMatrix("viewProjection",e.getCascadeTransformMatrix(o)),a.updateMatrix("view",e.getCascadeViewMatrix(o)),a.update()}}),this._shadowMap.onBeforeBindObservable.add(function(){e._breaksAreDirty&&e._splitFrustum(),e._computeMatrices()}),this._splitFrustum()}},t.prototype._bindCustomEffectForRenderSubMeshForShadowMap=function(e,n,i,o){var a,s,d,p,y,P;n.setMatrix((a=i?.viewProjection)!==null&&a!==void 0?a:"viewProjection",this.getCascadeTransformMatrix(this._currentLayer)),n.setMatrix((s=i?.view)!==null&&s!==void 0?s:"view",this.getCascadeViewMatrix(this._currentLayer)),n.setMatrix((d=i?.projection)!==null&&d!==void 0?d:"projection",this.getCascadeProjectionMatrix(this._currentLayer));var O=o.getWorldMatrix();n.setMatrix((p=i?.world)!==null&&p!==void 0?p:"world",O),O.multiplyToRef(this.getCascadeTransformMatrix(this._currentLayer),Or),n.setMatrix((y=i?.worldViewProjection)!==null&&y!==void 0?y:"worldViewProjection",Or),O.multiplyToRef(this.getCascadeViewMatrix(this._currentLayer),Qu),n.setMatrix((P=i?.worldView)!==null&&P!==void 0?P:"worldView",Qu)},t.prototype._isReadyCustomDefines=function(e,n,i){e.push("#define SM_DEPTHCLAMP "+(this._depthClamp&&this._filter!==Fn.FILTER_PCSS?"1":"0"))},t.prototype.prepareDefines=function(e,n){r.prototype.prepareDefines.call(this,e,n);var i=this._scene,o=this._light;if(i.shadowsEnabled&&o.shadowEnabled){e["SHADOWCSM"+n]=!0,e["SHADOWCSMDEBUG"+n]=this.debug,e["SHADOWCSMNUM_CASCADES"+n]=this.numCascades,e["SHADOWCSM_RIGHTHANDED"+n]=i.useRightHandedSystem;var a=i.activeCamera;a&&this._shadowMaxZ<a.maxZ&&(e["SHADOWCSMUSESHADOWMAXZ"+n]=!0),this.cascadeBlendPercentage===0&&(e["SHADOWCSMNOBLEND"+n]=!0)}},t.prototype.bindShadowLight=function(e,n){var i=this._light,o=this._scene;if(o.shadowsEnabled&&i.shadowEnabled){var a=o.activeCamera;if(a){var s=this.getShadowMap();if(s){var d=s.getSize().width;if(n.setMatrices("lightMatrix"+e,this._transformMatricesAsArray),n.setArray("viewFrustumZ"+e,this._viewSpaceFrustumsZ),n.setFloat("cascadeBlendFactor"+e,this.cascadeBlendPercentage===0?1e4:1/this.cascadeBlendPercentage),n.setArray("frustumLengths"+e,this._frustumLengths),this._filter===Fn.FILTER_PCF)n.setDepthStencilTexture("shadowSampler"+e,s),i._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),d,1/d,this.frustumEdgeFalloff,e);else if(this._filter===Fn.FILTER_PCSS){for(var p=0;p<this._numCascades;++p)this._lightSizeUVCorrection[2*p+0]=p===0?1:(this._cascadeMaxExtents[0].x-this._cascadeMinExtents[0].x)/(this._cascadeMaxExtents[p].x-this._cascadeMinExtents[p].x),this._lightSizeUVCorrection[2*p+1]=p===0?1:(this._cascadeMaxExtents[0].y-this._cascadeMinExtents[0].y)/(this._cascadeMaxExtents[p].y-this._cascadeMinExtents[p].y),this._depthCorrection[p]=p===0?1:(this._cascadeMaxExtents[p].z-this._cascadeMinExtents[p].z)/(this._cascadeMaxExtents[0].z-this._cascadeMinExtents[0].z);n.setDepthStencilTexture("shadowSampler"+e,s),n.setTexture("depthSampler"+e,s),n.setArray2("lightSizeUVCorrection"+e,this._lightSizeUVCorrection),n.setArray("depthCorrection"+e,this._depthCorrection),n.setFloat("penumbraDarkness"+e,this.penumbraDarkness),i._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),1/d,this._contactHardeningLightSizeUVRatio*d,this.frustumEdgeFalloff,e)}else n.setTexture("shadowSampler"+e,s),i._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),d,1/d,this.frustumEdgeFalloff,e);i._uniformBuffer.updateFloat2("depthValues",this.getLight().getDepthMinZ(a),this.getLight().getDepthMinZ(a)+this.getLight().getDepthMaxZ(a),e)}}}},t.prototype.getTransformMatrix=function(){return this.getCascadeTransformMatrix(0)},t.prototype.dispose=function(){r.prototype.dispose.call(this),this._freezeShadowCastersBoundingInfoObservable&&(this._scene.onBeforeRenderObservable.remove(this._freezeShadowCastersBoundingInfoObservable),this._freezeShadowCastersBoundingInfoObservable=null),this._depthReducer&&(this._depthReducer.dispose(),this._depthReducer=null)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this),n=this.getShadowMap();if(!n)return e;if(e.numCascades=this._numCascades,e.debug=this._debug,e.stabilizeCascades=this.stabilizeCascades,e.lambda=this._lambda,e.cascadeBlendPercentage=this.cascadeBlendPercentage,e.depthClamp=this._depthClamp,e.autoCalcDepthBounds=this.autoCalcDepthBounds,e.shadowMaxZ=this._shadowMaxZ,e.penumbraDarkness=this.penumbraDarkness,e.freezeShadowCastersBoundingInfo=this._freezeShadowCastersBoundingInfo,e.minDistance=this.minDistance,e.maxDistance=this.maxDistance,e.renderList=[],n.renderList)for(var i=0;i<n.renderList.length;i++){var o=n.renderList[i];e.renderList.push(o.id)}return e},t.Parse=function(e,n){var i=Fn.Parse(e,n,function(o,a){return new t(o,a)});return e.numCascades!==void 0&&(i.numCascades=e.numCascades),e.debug!==void 0&&(i.debug=e.debug),e.stabilizeCascades!==void 0&&(i.stabilizeCascades=e.stabilizeCascades),e.lambda!==void 0&&(i.lambda=e.lambda),e.cascadeBlendPercentage!==void 0&&(i.cascadeBlendPercentage=e.cascadeBlendPercentage),e.depthClamp!==void 0&&(i.depthClamp=e.depthClamp),e.autoCalcDepthBounds!==void 0&&(i.autoCalcDepthBounds=e.autoCalcDepthBounds),e.shadowMaxZ!==void 0&&(i.shadowMaxZ=e.shadowMaxZ),e.penumbraDarkness!==void 0&&(i.penumbraDarkness=e.penumbraDarkness),e.freezeShadowCastersBoundingInfo!==void 0&&(i.freezeShadowCastersBoundingInfo=e.freezeShadowCastersBoundingInfo),e.minDistance!==void 0&&e.maxDistance!==void 0&&i.setMinMaxDistance(e.minDistance,e.maxDistance),i},t.frustumCornersNDCSpace=[new u.e(-1,1,-1),new u.e(1,1,-1),new u.e(1,-1,-1),new u.e(-1,-1,-1),new u.e(-1,1,1),new u.e(1,1,1),new u.e(1,-1,1),new u.e(-1,-1,1)],t.CLASSNAME="CascadedShadowGenerator",t.DEFAULT_CA
7281SCADES_COUNT=4,t.MIN_CASCADES_COUNT=2,t.MAX_CASCADES_COUNT=4,t._SceneComponentInitialization=function(e){throw En.a.WarnImport("ShadowGeneratorSceneComponent")},t}(Fn);B.a.AddParser(st.a.NAME_SHADOWGENERATOR,function(r,t){if(r.shadowGenerators!==void 0&&r.shadowGenerators!==null)for(var e=0,n=r.shadowGenerators.length;e<n;e++){var i=r.shadowGenerators[e];i.className===Ks.CLASSNAME?Ks.Parse(i,t):Fn.Parse(i,t)}});var qu=function(){function r(t){this.name=st.a.NAME_SHADOWGENERATOR,this.scene=t}return r.prototype.register=function(){this.scene._gatherRenderTargetsStage.registerStep(st.a.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR,this,this._gatherRenderTargets)},r.prototype.rebuild=function(){},r.prototype.serialize=function(t){t.shadowGenerators=[];for(var e=0,n=this.scene.lights;e<n.length;e++){var i=n[e].getShadowGenerator();i&&t.shadowGenerators.push(i.serialize())}},r.prototype.addFromContainer=function(t){},r.prototype.removeFromContainer=function(t,e){},r.prototype.dispose=function(){},r.prototype._gatherRenderTargets=function(t){var e=this.scene;if(this.scene.shadowsEnabled)for(var n=0;n<e.lights.length;n++){var i=e.lights[n],o=i.getShadowGenerator();if(i.isEnabled()&&i.shadowEnabled&&o){var a=o.getShadowMap();e.textures.indexOf(a)!==-1&&t.push(a)}}},r}();Fn._SceneComponentInitialization=function(r){var t=r._getComponent(st.a.NAME_SHADOWGENERATOR);t||(t=new qu(r),r._addComponent(t))},Q.a.AddNodeConstructor("Light_Type_0",function(r,t){return function(){return new Qs(r,u.e.Zero(),t)}});var Qs=function(r){function t(e,n,i){var o=r.call(this,e,i)||this;return o._shadowAngle=Math.PI/2,o.position=n,o}return Object(c.d)(t,r),Object.defineProperty(t.prototype,"shadowAngle",{get:function(){return this._shadowAngle},set:function(e){this._shadowAngle=e,this.forceProjectionMatrixCompute()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"direction",{get:function(){return this._direction},set:function(e){var n=this.needCube();this._direction=e,this.needCube()!==n&&this._shadowGenerator&&this._shadowGenerator.recreateShadowMap()},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"PointLight"},t.prototype.getTypeID=function(){return Ci.a.LIGHTTYPEID_POINTLIGHT},t.prototype.needCube=function(){return!this.direction},t.prototype.getShadowDirection=function(e){if(this.direction)return r.prototype.getShadowDirection.call(this,e);switch(e){case 0:return new u.e(1,0,0);case 1:return new u.e(-1,0,0);case 2:return new u.e(0,-1,0);case 3:return new u.e(0,1,0);case 4:return new u.e(0,0,1);case 5:return new u.e(0,0,-1)}return u.e.Zero()},t.prototype._setDefaultShadowProjectionMatrix=function(e,n,i){var o=this.getScene().activeCamera;o&&u.a.PerspectiveFovLHToRef(this.shadowAngle,1,this.getDepthMinZ(o),this.getDepthMaxZ(o),e)},t.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",4),this._uniformBuffer.addUniform("vLightFalloff",4),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},t.prototype.transferToEffect=function(e,n){return this.computeTransformedInformation()?this._uniformBuffer.updateFloat4("vLightData",this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z,0,n):this._uniformBuffer.updateFloat4("vLightData",this.position.x,this.position.y,this.position.z,0,n),this._uniformBuffer.updateFloat4("vLightFalloff",this.range,this._inverseSquaredRange,0,0,n),this},t.prototype.transferToNodeMaterialEffect=function(e,n){return this.computeTransformedInformation()?e.setFloat3(n,this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z):e.setFloat3(n,this.position.x,this.position.y,this.position.z),this},t.prototype.prepareLightSpecificDefines=function(e,n){e["POINTLIGHT"+n]=!0},Object(c.c)([Object(L.c)()],t.prototype,"shadowAngle",null),t}($o),Zu=function(){function r(t,e,n){var i=this;e===void 0&&(e=""),n===void 0&&(n="black"),this._renderingCanvas=t,this._loadingText=e,this._loadingDivBackgroun
7281dColor=n,this._resizeLoadingUI=function(){var o=i._renderingCanvas.getBoundingClientRect(),a=window.getComputedStyle(i._renderingCanvas).position;i._loadingDiv&&(i._loadingDiv.style.position=a==="fixed"?"fixed":"absolute",i._loadingDiv.style.left=o.left+"px",i._loadingDiv.style.top=o.top+"px",i._loadingDiv.style.width=o.width+"px",i._loadingDiv.style.height=o.height+"px")}}return r.prototype.displayLoadingUI=function(){if(!this._loadingDiv){this._loadingDiv=document.createElement("div"),this._loadingDiv.id="babylonjsLoadingDiv",this._loadingDiv.style.opacity="0",this._loadingDiv.style.transition="opacity 1.5s ease",this._loadingDiv.style.pointerEvents="none",this._loadingDiv.style.display="grid",this._loadingDiv.style.gridTemplateRows="100%",this._loadingDiv.style.gridTemplateColumns="100%",this._loadingDiv.style.justifyItems="center",this._loadingDiv.style.alignItems="center",this._loadingTextDiv=document.createElement("div"),this._loadingTextDiv.style.position="absolute",this._loadingTextDiv.style.left="0",this._loadingTextDiv.style.top="50%",this._loadingTextDiv.style.marginTop="80px",this._loadingTextDiv.style.width="100%",this._loadingTextDiv.style.height="20px",this._loadingTextDiv.style.fontFamily="Arial",this._loadingTextDiv.style.fontSize="14px",this._loadingTextDiv.style.color="white",this._loadingTextDiv.style.textAlign="center",this._loadingTextDiv.style.zIndex="1",this._loadingTextDiv.innerHTML="Loading",this._loadingDiv.appendChild(this._loadingTextDiv),this._loadingTextDiv.innerHTML=this._loadingText;var t=document.createElement("style");t.type="text/css",t.innerHTML=`@-webkit-keyframes spin1 {                    0% { -webkit-transform: rotate(0deg);}
7282                    100% { -webkit-transform: rotate(360deg);}
7283                }                @keyframes spin1 {                    0% { transform: rotate(0deg);}
7284                    100% { transform: rotate(360deg);}
7285                }`,document.getElementsByTagName("head")[0].appendChild(t);var e=!!window.SVGSVGElement,n=new Image;r.DefaultLogoUrl?n.src=r.DefaultLogoUrl:n.src=e?"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxODAuMTcgMjA4LjA0Ij48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2ZmZjt9LmNscy0ye2ZpbGw6I2UwNjg0Yjt9LmNscy0ze2ZpbGw6I2JiNDY0Yjt9LmNscy00e2ZpbGw6I2UwZGVkODt9LmNscy01e2ZpbGw6I2Q1ZDJjYTt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPkJhYnlsb25Mb2dvPC90aXRsZT48ZyBpZD0iTGF5ZXJfMiIgZGF0YS1uYW1lPSJMYXllciAyIj48ZyBpZD0iUGFnZV9FbGVtZW50cyIgZGF0YS1uYW1lPSJQYWdlIEVsZW1lbnRzIj48cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Ik05MC4wOSwwLDAsNTJWMTU2bDkwLjA5LDUyLDkwLjA4LTUyVjUyWiIvPjxwb2x5Z29uIGNsYXNzPSJjbHMtMiIgcG9pbnRzPSIxODAuMTcgNTIuMDEgMTUxLjk3IDM1LjczIDEyNC44NSA1MS4zOSAxNTMuMDUgNjcuNjcgMTgwLjE3IDUyLjAxIi8+PHBvbHlnb24gY2xhc3M9ImNscy0yIiBwb2ludHM9IjI3LjEyIDY3LjY3IDExNy4yMSAxNS42NiA5MC4wOCAwIDAgNTIuMDEgMjcuMTIgNjcuNjciLz48cG9seWdvbiBjbGFzcz0iY2xzLTIiIHBvaW50cz0iNjEuODkgMTIwLjMgOTAuMDggMTM2LjU4IDExOC4yOCAxMjAuMyA5MC4wOCAxMDQuMDIgNjEuODkgMTIwLjMiLz48cG9seWdvbiBjbGFzcz0iY2xzLTMiIHBvaW50cz0iMTUzLjA1IDY3LjY3IDE1My4wNSAxNDAuMzcgOTAuMDggMTc2LjcyIDI3LjEyIDE0MC4zNyAyNy4xMiA2Ny42NyAwIDUyLjAxIDAgMTU2LjAzIDkwLjA4IDIwOC4wNCAxODAuMTcgMTU2LjAzIDE4MC4xNyA1Mi4wMSAxNTMuMDUgNjcuNjciLz48cG9seWdvbiBjbGFzcz0iY2xzLTMiIHBvaW50cz0iOTAuMDggNzEuNDYgNjEuODkgODcuNzQgNjEuODkgMTIwLjMgOTAuMDggMTA0LjAyIDExOC4yOCAxMjAuMyAxMTguMjggODcuNzQgOTAuMDggNzEuNDYiLz48cG9seWdvbiBjbGFzcz0iY2xzLTQiIHBvaW50cz0iMTUzLjA1IDY3LjY3IDExOC4yOCA4Ny43NCAxMTguMjggMTIwLjMgOTAuMDggMTM2LjU4IDkwLjA4IDE3Ni43MiAxNTMuMDUgMTQwLjM3IDE1My4wNSA2Ny42NyIvPjxwb2x5Z29uIGNsYXNzPSJjbHMtNSIgcG9pbnRzPSIyNy4xMiA2Ny42NyA2MS44OSA4Ny43NCA2MS44OSAxMjAuMyA5MC4wOCAxMzYuNTggOTAuMDggMTc2LjcyIDI3LjEyIDE0MC4zNyAyNy4xMiA2Ny42NyIvPjwvZz48L2c+PC9zdmc+":"https://cdn.babylonjs.com/Assets/babylonLogo.png",n.style.width="150px",n.style.gridColumn="1",n.style.gridRow="1",n.style.top="50%",n.style.left="50%",n.style.transform="translate(-50%, -50%)",n.style.position="absolute";var i=document.createElement("div");i.style.width="300px",i.style.gridColumn="1",i.style.gridRow="1",i.style.top="50%",i.style.left="50%",i.style.transform="translate(-50%, -50%)",i.style.position="absolute";var o=new Image;if(r.DefaultSpinnerUrl?o.src=r.DefaultSpinnerUrl:o.src=e?"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzOTIgMzkyIj48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2UwNjg0Yjt9LmNscy0ye2ZpbGw6bm9uZTt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPlNwaW5uZXJJY29uPC90aXRsZT48ZyBpZD0iTGF5ZXJfMiIgZGF0YS1uYW1lPSJMYXllciAyIj48ZyBpZD0iU3Bpbm5lciI+PHBhdGggY2xhc3M9ImNscy0xIiBkPSJNNDAuMjEsMTI2LjQzYzMuNy03LjMxLDcuNjctMTQuNDQsMTItMjEuMzJsMy4zNi01LjEsMy41Mi01YzEuMjMtMS42MywyLjQxLTMuMjksMy42NS00LjkxczIuNTMtMy4yMSwzLjgyLTQuNzlBMTg1LjIsMTg1LjIsMCwwLDEsODMuNCw2Ny40M2EyMDgsMjA4LDAsMCwxLDE5LTE1LjY2YzMuMzUtMi40MSw2Ljc0LTQuNzgsMTAuMjUtN3M3
7285LjExLTQuMjgsMTAuNzUtNi4zMmM3LjI5LTQsMTQuNzMtOCwyMi41My0xMS40OSwzLjktMS43Miw3Ljg4LTMuMywxMi00LjY0YTEwNC4yMiwxMDQuMjIsMCwwLDEsMTIuNDQtMy4yMyw2Mi40NCw2Mi40NCwwLDAsMSwxMi43OC0xLjM5QTI1LjkyLDI1LjkyLDAsMCwxLDE5NiwyMS40NGE2LjU1LDYuNTUsMCwwLDEsMi4wNSw5LDYuNjYsNi42NiwwLDAsMS0xLjY0LDEuNzhsLS40MS4yOWEyMi4wNywyMi4wNywwLDAsMS01Ljc4LDMsMzAuNDIsMzAuNDIsMCwwLDEtNS42NywxLjYyLDM3LjgyLDM3LjgyLDAsMCwxLTUuNjkuNzFjLTEsMC0xLjkuMTgtMi44NS4yNmwtMi44NS4yNHEtNS43Mi41MS0xMS40OCwxLjFjLTMuODQuNC03LjcxLjgyLTExLjU4LDEuNGExMTIuMzQsMTEyLjM0LDAsMCwwLTIyLjk0LDUuNjFjLTMuNzIsMS4zNS03LjM0LDMtMTAuOTQsNC42NHMtNy4xNCwzLjUxLTEwLjYsNS41MUExNTEuNiwxNTEuNiwwLDAsMCw2OC41Niw4N0M2Ny4yMyw4OC40OCw2Niw5MCw2NC42NCw5MS41NnMtMi41MSwzLjE1LTMuNzUsNC43M2wtMy41NCw0LjljLTEuMTMsMS42Ni0yLjIzLDMuMzUtMy4zMyw1YTEyNywxMjcsMCwwLDAtMTAuOTMsMjEuNDksMS41OCwxLjU4LDAsMSwxLTMtMS4xNVM0MC4xOSwxMjYuNDcsNDAuMjEsMTI2LjQzWiIvPjxyZWN0IGNsYXNzPSJjbHMtMiIgd2lkdGg9IjM5MiIgaGVpZ2h0PSIzOTIiLz48L2c+PC9nPjwvc3ZnPg==":"https://cdn.babylonjs.com/Assets/loadingIcon.png",o.style.animation="spin1 0.75s infinite linear",o.style.webkitAnimation="spin1 0.75s infinite linear",o.style.transformOrigin="50% 50%",o.style.webkitTransformOrigin="50% 50%",!e){var a={w:16,h:18.5},s={w:30,h:30};n.style.width=a.w+"vh",n.style.height=a.h+"vh",n.style.left="calc(50% - "+a.w/2+"vh)",n.style.top="calc(50% - "+a.h/2+"vh)",o.style.width=s.w+"vh",o.style.height=s.h+"vh",o.style.left="calc(50% - "+s.w/2+"vh)",o.style.top="calc(50% - "+s.h/2+"vh)"}i.appendChild(o),this._loadingDiv.appendChild(n),this._loadingDiv.appendChild(i),this._resizeLoadingUI(),window.addEventListener("resize",this._resizeLoadingUI),this._loadingDiv.style.backgroundColor=this._loadingDivBackgroundColor,document.body.appendChild(this._loadingDiv),this._loadingDiv.style.opacity="1"}},r.prototype.hideLoadingUI=function(){var t=this;this._loadingDiv&&(this._loadingDiv.style.opacity="0",this._loadingDiv.addEventListener("transitionend",function(){t._loadingDiv&&(t._loadingDiv.parentElement&&t._loadingDiv.parentElement.removeChild(t._loadingDiv),window.removeEventListener("resize",t._resizeLoadingUI),t._loadingDiv=null)}))},Object.defineProperty(r.prototype,"loadingUIText",{get:function(){return this._loadingText},set:function(t){this._loadingText=t,this._loadingTextDiv&&(this._loadingTextDiv.innerHTML=this._loadingText)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"loadingUIBackgroundColor",{get:function(){return this._loadingDivBackgroundColor},set:function(t){this._loadingDivBackgroundColor=t,this._loadingDiv&&(this._loadingDiv.style.backgroundColor=this._loadingDivBackgroundColor)},enumerable:!1,configurable:!0}),r.DefaultLogoUrl="",r.DefaultSpinnerUrl="",r}();Ue.a.DefaultLoadingScreenFactory=function(r){return new Zu(r)};var qs=f(71),ir=f(68),Zs=function(){function r(){}return r.ConvertPanoramaToCubemap=function(t,e,n,i){if(!t)throw"ConvertPanoramaToCubemap: input cannot be null";if(t.length!=e*n*3)throw"ConvertPanoramaToCubemap: input size is wrong";return{front:this.CreateCubemapTexture(i,this.FACE_FRONT,t,e,n),back:this.CreateCubemapTexture(i,this.FACE_BACK,t,e,n),left:this.CreateCubemapTexture(i,this.FACE_LEFT,t,e,n),right:this.CreateCubemapTexture(i,this.FACE_RIGHT,t,e,n),up:this.CreateCubemapTexture(i,this.FACE_UP,t,e,n),down:this.CreateCubemapTexture(i,this.FACE_DOWN,t,e,n),size:i,type:h.a.TEXTURETYPE_FLOAT,format:h.a.TEXTUREFORMAT_RGB,gammaSpace:!1}},r.CreateCubemapTexture=function(t,e,n,i,o){for(var a=new ArrayBuffer(t*t*4*3),s=new Float32Array(a),d=e[1].subtract(e[0]).scale(1/t),p=e[3].subtract(e[2]).scale(1/t),y=1/t,P=0,O=0;O<t;O++){for(var U=e[0],F=e[2],z=0;z<t;z++){var J=F.subtract(U).scale(P).add(U);J.normalize();var ie=this.CalcProjectionSpherical(J,n,i,o);s[O*t*3+3*z+0]=ie.r,s[O*t*3+3*z+1]=ie.g,s[O*t*3+3*z+2]=ie.b,U=U.add(d),F=F.add(p)}P+=y}return s},r.CalcProjectionSpherical=function(t,e,n,i){for(var o=Math.atan2(t.z,t.x),a=Math.acos(t.y);o<-Math.PI;)o+=2*Math.PI;for(;o>Math.PI;)o-=2*Math.PI;var s=o/Math.PI,d=a/Math.PI;s=.5*s+.5;var p=Math.round(s*n);p<0?p=0:p>=n&&(p=n-1);var y=Math.round(d*i);y<0?y=0:y>=i&&(y=i-1);var P=i-y-1;return{r:e[P*n*3+3*p+0],g:e[P*n*3+3*p+1],b:e[P*n*3+3*p+2]}},r.FACE_LEFT=[new u.e(-1,-1,-1),new u.e(1,-1,-1),new u.e(-1,1,-1),new u.e(1,1,-1)],r.FACE_RIGHT=[new u.e(1,-1,1),new u.e(-1,-1,1),new u.e(1,1,1),new u.e(-1,1,1)],r.FACE_FRONT=[new u.e(1,-1,-1),new u.e(1,-1,1),new u.e(1,1,-1),new u.e(1,1,1)],r.FACE_BACK=[new u.e(-1,-1,1),new u.e(-1,-1,-1),new u.e(-1,1,1),new u.e(-1,1,-1)],r.FACE_DOWN=[new u.e(1,1,-1),new u.e(1,1,1),new u.e(-1,1,-1),new u.e(-1,1,1)],r.FACE_UP=[new u.e(-1,-1,-1),new u.e(-1,-1,1),new u.e(1,-1,-1),new u.e(1,-1,1)],r}(),Ju=function(){function r(){}return r.Ldexp=function(t,e){return e>1023?t*Math.pow(2,1023)*Math.pow(2,e-1023):e<-1074?t*Math.pow(2,-1074)*Math.pow(2,e+1074):t*Math.pow(2,e)},r.Rgbe2float=function(t,e,n,i,o,a){o>
72850?(o=this.Ldexp(1,o-136),t[a+0]=e*o,t[a+1]=n*o,t[a+2]=i*o):(t[a+0]=0,t[a+1]=0,t[a+2]=0)},r.readStringLine=function(t,e){for(var n="",i="",o=e;o<t.length-e&&(i=String.fromCharCode(t[o]))!=`
7286`;o++)n+=i;return n},r.RGBE_ReadHeader=function(t){var e,n,i=this.readStringLine(t,0);if(i[0]!="#"||i[1]!="?")throw"Bad HDR Format.";var o=!1,a=!1,s=0;do s+=i.length+1,(i=this.readStringLine(t,s))=="FORMAT=32-bit_rle_rgbe"?a=!0:i.length==0&&(o=!0);while(!o);if(!a)throw"HDR Bad header format, unsupported FORMAT";s+=i.length+1,i=this.readStringLine(t,s);var d=/^\-Y (.*) \+X (.*)$/g.exec(i);if(!d||d.length<3)throw"HDR Bad header format, no size";if(n=parseInt(d[2]),e=parseInt(d[1]),n<8||n>32767)throw"HDR Bad header format, unsupported size";return{height:e,width:n,dataPosition:s+=i.length+1}},r.GetCubeMapTextureData=function(t,e){var n=new Uint8Array(t),i=this.RGBE_ReadHeader(n),o=this.RGBE_ReadPixels(n,i);return Zs.ConvertPanoramaToCubemap(o,i.width,i.height,e)},r.RGBE_ReadPixels=function(t,e){return this.RGBE_ReadPixels_RLE(t,e)},r.RGBE_ReadPixels_RLE=function(t,e){for(var n,i,o,a,s,d=e.height,p=e.width,y=e.dataPosition,P=0,O=0,U=0,F=new ArrayBuffer(4*p),z=new Uint8Array(F),J=new ArrayBuffer(e.width*e.height*4*3),ie=new Float32Array(J);d>0;){if(n=t[y++],i=t[y++],o=t[y++],a=t[y++],n!=2||i!=2||128&o||e.width<8||e.width>32767)return this.RGBE_ReadPixels_NOT_RLE(t,e);if((o<<8|a)!=p)throw"HDR Bad header format, wrong scan line width";for(P=0,U=0;U<4;U++)for(O=(U+1)*p;P<O;)if(n=t[y++],i=t[y++],n>128){if((s=n-128)==0||s>O-P)throw"HDR Bad Format, bad scanline data (run)";for(;s-- >0;)z[P++]=i}else{if((s=n)==0||s>O-P)throw"HDR Bad Format, bad scanline data (non-run)";if(z[P++]=i,--s>0)for(var se=0;se<s;se++)z[P++]=t[y++]}for(U=0;U<p;U++)n=z[U],i=z[U+p],o=z[U+2*p],a=z[U+3*p],this.Rgbe2float(ie,n,i,o,a,(e.height-d)*p*3+3*U);d--}return ie},r.RGBE_ReadPixels_NOT_RLE=function(t,e){for(var n,i,o,a,s,d=e.height,p=e.width,y=e.dataPosition,P=new ArrayBuffer(e.width*e.height*4*3),O=new Float32Array(P);d>0;){for(s=0;s<e.width;s++)n=t[y++],i=t[y++],o=t[y++],a=t[y++],this.Rgbe2float(O,n,i,o,a,(e.height-d)*p*3+3*s);d--}return O},r}(),$u=function(){function r(t,e){var n;e===void 0&&(e=r._DefaultOptions),this.engine=t,this._fullscreenViewport=new Wn.a(0,0,1,1),e=Object(c.a)(Object(c.a)({},r._DefaultOptions),e),this._vertexBuffers=((n={})[Me.b.PositionKind]=new Me.b(t,e.positions,Me.b.PositionKind,!1,!1,2),n),this._indexBuffer=t.createIndexBuffer(e.indices)}return r.prototype.setViewport=function(t){t===void 0&&(t=this._fullscreenViewport),this.engine.setViewport(t)}
7286,r.prototype.bindBuffers=function(t){this.engine.bindBuffers(this._vertexBuffers,this._indexBuffer,t)},r.prototype.applyEffectWrapper=function(t){this.engine.depthCullingState.depthTest=!1,this.engine.stencilState.stencilTest=!1,this.engine.enableEffect(t.effect),this.bindBuffers(t.effect),t.onApplyObservable.notifyObservers({})},r.prototype.restoreStates=function(){this.engine.depthCullingState.depthTest=!0,this.engine.stencilState.stencilTest=!0},r.prototype.draw=function(){this.engine.drawElementsType(h.a.MATERIAL_TriangleFillMode,0,6)},r.prototype.isRenderTargetTexture=function(t){return t.renderList!==void 0},r.prototype.render=function(t,e){if(e===void 0&&(e=null),t.effect.isReady()){this.setViewport();var n=e===null?null:this.isRenderTargetTexture(e)?e.getInternalTexture():e;n&&this.engine.bindFramebuffer(n),this.applyEffectWrapper(t),this.draw(),n&&this.engine.unBindFramebuffer(n),this.restoreStates()}},r.prototype.dispose=function(){var t=this._vertexBuffers[Me.b.PositionKind];t&&(t.dispose(),delete this._vertexBuffers[Me.b.PositionKind]),this._indexBuffer&&this.engine._releaseBuffer(this._indexBuffer)},r._DefaultOptions={positions:[1,1,-1,1,-1,-1,1,-1],indices:[0,1,2,0,2,3]},r}(),eh=function(){function r(t){var e,n=this;this.onApplyObservable=new x.c;var i=t.uniformNames||[];t.vertexShader?e={fragmentSource:t.fragmentShader,vertexSource:t.vertexShader,spectorName:t.name||"effectWrapper"}:(i.push("scale"),e={fragmentSource:t.fragmentShader,vertex:"postprocess",spectorName:t.name||"effectWrapper"},this.onApplyObservable.add(function(){n.effect.setFloat2("scale",1,1)}));var o=t.defines?t.defines.join(`
7287`):"";t.useShaderStore?(e.fragment=e.fragmentSource,e.vertex||(e.vertex=e.vertexSource),delete e.fragmentSource,delete e.vertexSource,this.effect=t.engine.createEffect(e.spectorName,t.attributeNames||["position"],i,t.samplerNames,o,void 0,t.onCompiled)):this.effect=new je.a(e,t.attributeNames||["position"],i,t.samplerNames,t.engine,o,void 0,t.onCompiled)}return r.prototype.dispose=function(){this.effect.dispose()},r}(),pm=`
7288attribute vec2 position;
7289
7290varying vec3 direction;
7291
7292uniform vec3 up;
7293uniform vec3 right;
7294uniform vec3 front;
7295void main(void) {
7296mat3 view=mat3(up,right,front);
7297direction=view*vec3(position,1.0);
7298gl_Position=vec4(position,0.0,1.0);
7299}`;je.a.ShadersStore.hdrFilteringVertexShader=pm;var _m=`#include<helperFunctions>
7300#include<importanceSampling>
7301#include<pbrBRDFFunctions>
7302#include<hdrFilteringFunctions>
7303uniform float alphaG;
7304uniform samplerCube inputTexture;
7305uniform vec2 vFilteringInfo;
7306uniform float hdrScale;
7307varying vec3 direction;
7308void main() {
7309vec3 color=radiance(alphaG,inputTexture,direction,vFilteringInfo);
7310gl_FragColor=vec4(color*hdrScale,1.0);
7311}`;je.a.ShadersStore.hdrFilteringPixelShader=_m;var th=function(){function r(t,e){e===void 0&&(e={}),this._lodGenerationOffset=0,this._lodGenerationScale=.8,this.quality=h.a.TEXTURE_FILTERING_QUALITY_OFFLINE,this.hdrScale=1,this._engine=t,this.hdrScale=e.hdrScale||this.hdrScale,this.quality=e.hdrScale||this.quality}return r.prototype._createRenderTarget=function(t){var e=h.a.TEXTURETYPE_UNSIGNED_BYTE;this._engine.getCaps().textureHalfFloatRender?e=h.a.TEXTURETYPE_HALF_FLOAT:this._engine.getCaps().textureFloatRender&&(e=h.a.TEXTURETYPE_FLOAT);var n=this._engine.createRenderTargetCubeTexture(t,{format:h.a.TEXTUREFORMAT_RGBA,type:e,generateMipMaps:!1,generateDepthBuffer:!1,generateStencilBuffer:!1,samplingMode:h.a.TEXTURE_NEAREST_SAMPLINGMODE});return this._engine.updateTextureWrappingMode(n,h.a.TEXTURE_CLAMP_ADDRESSMODE,h.a.TEXTURE_CLAMP_ADDRESSMODE,h.a.TEXTURE_CLAMP_ADDRESSMODE),this._engine.updateTextureSamplingMode(h.a.TEXTURE_TRILINEAR_SAMPLINGMODE,n,!0),n},r.prototype._prefilterInternal=function(t){var e=t.getSize().width,n=Math.round($.a.Log2(e))+1,i=this._effectWrapper.effect,o=this._createRenderTarget(e);this._effectRenderer.setViewport();var a=t.getInternalTexture();a&&this._engine.updateTextureSamplingMode(h.a.TEXTURE_TRILINEAR_SAMPLINGMODE,a,!0),this._effectRenderer.applyEffectWrapper(this._effectWrapper);var s=[[new u.e(0,0,-1),new u.e(0,-1,0),new u.e(1,0,0)],[new u.e(0,0,1),new u.e(0,-1,0),new u.e(-1,0,0)],[new u.e(1,0,0),new u.e(0,0,1),new u.e(0,1,0)],[new u.e(1,0,0),new u.e(0,0,-1),new u.e(0,-1,0)],[new u.e(1,0,0),new u.e(0,-1,0),new u.e(0,0,1)],[new u.e(-1,0,0),new u.e(0,-1,0),new u.e(0,0,-1)]];i.setFloat("hdrScale",this.hdrScale),i.setFloat2("vFilteringInfo",t.getSize().width,n),i.setTexture("inputTexture",t);for(var d=0;d<6;d++){i.setVector3("up",s[d][0]),i.setVector3("right",s[d][1]),i.setVector3("front",s[d][2]);for(var p=0;p<n;
7311p++){this._engine.bindFramebuffer(o,d,void 0,void 0,!0,p),this._effectRenderer.applyEffectWrapper(this._effectWrapper);var y=Math.pow(2,(p-this._lodGenerationOffset)/this._lodGenerationScale)/e;p===0&&(y=0),i.setFloat("alphaG",y),this._effectRenderer.draw()}}return this._effectRenderer.restoreStates(),this._engine.restoreDefaultFramebuffer(),this._engine._releaseFramebufferObjects(o),this._engine._releaseTexture(t._texture),o._swapAndDie(t._texture),t._prefiltered=!0,t},r.prototype._createEffect=function(t,e){var n=[];return t.gammaSpace&&n.push("#define GAMMA_INPUT"),n.push("#define NUM_SAMPLES "+this.quality+"u"),new eh({engine:this._engine,name:"hdrFiltering",vertexShader:"hdrFiltering",fragmentShader:"hdrFiltering",samplerNames:["inputTexture"],uniformNames:["vSampleDirections","vWeights","up","right","front","vFilteringInfo","hdrScale","alphaG"],useShaderStore:!0,defines:n,onCompiled:e})},r.prototype.isReady=function(t){return t.isReady()&&this._effectWrapper.effect.isReady()},r.prototype.prefilter=function(t,e){var n=this;if(e===void 0&&(e=null),this._engine.webGLVersion!==1)return new Promise(function(i){n._effectRenderer=new $u(n._engine),n._effectWrapper=n._createEffect(t),n._effectWrapper.effect.executeWhenCompiled(function(){n._prefilterInternal(t),n._effectRenderer.dispose(),n._effectWrapper.dispose(),i(),e&&e()})});l.a.Warn("HDR prefiltering is not available in WebGL 1., you can use real time filtering instead.")},r}(),la=function(r){function t(e,n,i,o,a,s,d,p,y){var P;o===void 0&&(o=!1),a===void 0&&(a=!0),s===void 0&&(s=!1),d===void 0&&(d=!1),p===void 0&&(p=null),y===void 0&&(y=null);var O=r.call(this,n)||this;return O._generateHarmonics=!0,O._onLoad=null,O._onError=null,O._isBlocking=!0,O._rotationY=0,O.boundingBoxPosition=u.e.Zero(),e&&(O._coordinatesMode=we.a.CUBIC_MODE,O.name=e,O.url=e,O.hasAlpha=!1,O.isCube=!0,O._textureMatrix=u.a.Identity(),O._prefilterOnLoad=d,O._onLoad=p,O._onError=y,O.gammaSpace=s,O._noMipmap=o,O._size=i,O._generateHarmonics=a,O._texture=O._getFromCache(e,O._noMipmap),O._texture?p&&(O._texture.isReady?Ye.b.SetImmediate(function(){return p()}):O._texture.onLoadedObservable.add(p)):!((P=O.getScene())===null||P===void 0)&&P.useDelayedTextureLoading?O.delayLoadState=h.a.DELAYLOADSTATE_NOTLOADED:O.loadTexture()),O}return Object(c.d)(t,r),Object.defineProperty(t.prototype,"isBlocking",{get:function(){return this._isBlocking},set:function(e){this._isBlocking=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotationY",{get:function(){return this._rotationY},set:function(e){this._rotationY=e,this.setReflectionTextureMatrix(u.a.RotationY(this._rotationY))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"boundingBoxSize",{get:function(){return this._boundingBoxSize},set:function(e){if(!this._boundingBoxSize||!this._boundingBoxSize.equals(e)){this._boundingBoxSize=e;var n=this.getScene();n&&n.markAllMaterialsAsDirty(h.a.MATERIAL_TextureDirtyFlag)}},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"HDRCubeTexture"},t.prototype.loadTexture=function(){var e=this,n=this._getEngine();if(this._getEngine().webGLVersion>=2&&this._prefilterOnLoad){var i=this._onLoad,o=new th(n);this._onLoad=function(){o.prefilter(e,i)}}this._texture=n.createRawCubeTextureFromUrl(this.url,this.getScene(),this._size,h.a.TEXTUREFORMAT_RGB,n.getCaps().textureFloat?h.a.TEXTURETYPE_FLOAT:h.a.TEXTURETYPE_UNSIGNED_INT,this._noMipmap,function(a){e.lodGenerationOffset=0,e.lodGenerationScale=.8;var s=Ju.GetCubeMapTextureData(a,e._size);if(e._generateHarmonics){var d=Xo.ConvertCubeMapToSphericalPolynomial(s);e.sphericalPolynomial=d}for(var p=[],y=null,P=0;P<6;P++){if(!n.getCaps().textureFloat){var O=new ArrayBuffer(e._size*e._size*3);y=new Uint8Array(O)}var U=s[t._facesMapping[P]];if(e.gammaSpace||y){for(var F=0;F<e._size*e._size;F++)if(e.gammaSpace&&(U[3*F+0]=Math.pow(U[3*F+0],Gt.b),U[3*F+1]=Math.pow(U[3*F+1],Gt.b),U[3*F+2]=Math.pow(U[3*F+2],Gt.b)),y){var z=Math.max(255*U[3*F+0],0),J=Math.max(255*U[3*F+1],0),ie=Math.max(255*U[3*F+2],0),se=Math.max(Math.max(z,J),ie);if(se>255){var ce=255/se;z*=ce,J*=ce,ie*=ce}y[3*F+0]=z,y[3*F+1]=J,y[3*F+2]=ie}}y?p.push(y):p.push(U)}return p},null,this._onLoad,this._onError)}
7311,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===h.a.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=h.a.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(h.a.MATERIAL_TextureDirtyFlag,function(o){return o.getActiveTextures().indexOf(i)!==-1}))},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=u.e.FromArray(e.boundingBoxPosition)),e.boundingBoxSize&&(o.boundingBoxSize=u.e.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}(zn.a);R.a.RegisteredTypes["BABYLON.HDRCubeTexture"]=la;var nh=function(){function r(t,e,n){e===void 0&&(e=0),n===void 0&&(n=null),this.name=t,this.animations=new Array,this._positions=null,this._normals=null,this._tangents=null,this._uvs=null,this._uniqueId=0,this.onInfluenceChanged=new x.c,this._onDataLayoutChanged=new x.c,this._animationPropertiesOverride=null,this._scene=n||te.a.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=L.a.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&&
7311(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())),L.a.AppendSerializedAnimations(this,t),t},r.prototype.getClassName=function(){return"MorphTarget"},r.Parse=function(t){var e=new r(t.name,t.influence);if(e.setPositions(t.positions),t.id!=null&&(e.id=t.id),t.normals&&e.setNormals(t.normals),t.tangents&&e.setTangents(t.tangents),t.uvs&&e.setUVs(t.uvs),t.animations)for(var n=0;n<t.animations.length;n++){var i=t.animations[n],o=R.a.GetClass("BABYLON.Animation");o&&e.animations.push(o.Parse(i))}return e},r.FromMesh=function(t,e,n){e||(e=t.name);var i=new r(e,n,t.getScene());return i.setPositions(t.getVerticesData(Me.b.PositionKind)),t.isVerticesDataPresent(Me.b.NormalKind)&&i.setNormals(t.getVerticesData(Me.b.NormalKind)),t.isVerticesDataPresent(Me.b.TangentKind)&&i.setTangents(t.getVerticesData(Me.b.TangentKind)),t.isVerticesDataPresent(Me.b.UVKind)&&i.setUVs(t.getVerticesData(Me.b.UVKind)),i},Object(c.c)([Object(L.c)()],r.prototype,"id",void 0),r}(),ua=function(){function r(t){t===void 0&&(t=null),this._targets=new Array,this._targetInfluenceChangedObservers=new Array,this._targetDataLayoutChangedObservers=new Array,this._activeTargets=new li.a(16),this._supportsNormals=!1,this._supportsTangents=!1,this._supportsUVs=!1,this._vertexCount=0,this._uniqueId=0,this._tempInfluences=new Array,this.enableNormalMorphing=!0,this.enableTangentMorphing=!0,this.enableUVMorphing=!0,t||(t=te.a.LastCreatedScene),this._scene=t,this._scene&&(this._scene.morphTargetManagers.push(this),this._uniqueId=this._scene.getUniqueId())}return 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}),r.prototype.getActiveTarget=function(t){return this._activeTargets.data[t]},r.prototype.getTarget=function(t){return this._targets[t]},r.prototype.addTarget=function(t){var e=this;this._targets.push(t),this._targetInfluenceChangedObservers.push(t.onInfluenceChanged.add(function(n){e._syncActiveTargets(n)})),this._targetDataLayoutChangedObservers.push(t._onDataLayoutChanged.add(function(){e._syncActiveTargets(!0)})),this._syncActiveTargets(!0)},r.prototype.removeTarget=function(t){var e=this._targets.indexOf(t);e>=0&&(this._targets.splice(e,1),t.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(e,1)[0]),t._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(e,1)[0]),this._syncActiveTargets(!0))},r.prototype.clone=function(){for(var t=new r(this._scene),e=0,n=this._targets;e<n.length;e++){var i=n[e];t.addTarget(i.clone())}return t.enableNormalMorphing=this.enableNormalMorphing,t.enableTangentMorphing=this.enableTangentMorphing,t.enableUVMorphing=this.enableUVMorphing,t},r.prototype.serialize=function(){var t={};t.id=this.uniqueId,t.targets=[];for(var e=0,n=this._targets;e<n.length;e++){var i=n[e];t.targets.push(i.serialize())}return t},r.prototype._syncActiveTargets=function(t){var e=0;this._activeTargets.reset(),this._supportsNormals=!0,this._supportsTangents=!0,this._supportsUVs=!0,this._vertexCount=0;for(var n=0,i=this._targets;n<i.length;n++){var o=i[n];if(o.influence!==0){this._activeTargets.push(o),this._tempInfluences[e++]=o.influence,this._supportsNormals=this._supportsNormals&&o.hasNormals,this._supportsTangents=this._supportsTangents&&o.hasTangents,this._supportsUVs=this._supportsUVs&&o.hasUVs;var a=o.getPositions();if(a){var s=a.length/3;if(this._vertexCount===0)this._vertexCount=s;else if(this._vertexCount!==s)return void l.a.Error("Incompatible target. Targets must all have the same vertices count.")}}}this._influences&&this._influences.length===e||(this._influences=new Float32Array(e));for(var d=0;d<e;d++)this._influences[d]=this._tempInfluences[d];t&&this.synchronize()},r.prototype.synchronize=function(){if(this._scene)for(var t=0,e=this._scene.meshes;t<e.length;t++){var n=e[t];n.morphTargetManager===this&&n._syncGeometryWithMorphTargetManager()}},r.Parse=function(t,e){var n=new r(e);n._uniqueId=t.id;for(var i=0,o=t.targets;i<o.length;i++){var a=o[i];n.addTarget(nh.Parse(a))}return n},r}(),Ct=f(32),en=f(50),Mr=function(){function r(t,e){if(e===void 0&&(e=r.DefaultPluginFactory()),this._physicsPlugin=e,this._impostors=[],this._joints=[],this._subTimeStep=0,!this._physicsPlugin.isSupported())throw new Error("Physics Engine "+this._physicsPlugin.name+" cannot be found. Please make sure it is included.");t=t||new u.e(0,-9.807,0),this.setGravity(t),this.setTimeStep()}return r.DefaultPluginFactory=function(){throw En.a.WarnImport("CannonJSPlugin")},r.prototype.setGravity=function(t){this.gravity=t,this._physicsPlugin.setGravity(this.gravity)},r.prototype.setTimeStep=function(t){t===void 0&&(t=1/60),this._physicsPlugin.setTimeStep(t)},r.prototype.getTimeStep=function(){return this._physicsPlugin.getTimeStep()},r.prototype.setSubTimeStep=function(t){t===void 0&&(t=0),this._subTimeStep=t},r.prototype.getSubTimeStep=function(){return this._subTimeStep}
7311,r.prototype.dispose=function(){this._impostors.forEach(function(t){t.dispose()}),this._physicsPlugin.dispose()},r.prototype.getPhysicsPluginName=function(){return this._physicsPlugin.name},r.prototype.addImpostor=function(t){t.uniqueId=this._impostors.push(t),t.parent||this._physicsPlugin.generatePhysicsBody(t)},r.prototype.removeImpostor=function(t){var e=this._impostors.indexOf(t);e>-1&&this._impostors.splice(e,1).length&&this.getPhysicsPlugin().removePhysicsBody(t)},r.prototype.addJoint=function(t,e,n){var i={mainImpostor:t,connectedImpostor:e,joint:n};n.physicsPlugin=this._physicsPlugin,this._joints.push(i),this._physicsPlugin.generateJoint(i)},r.prototype.removeJoint=function(t,e,n){var i=this._joints.filter(function(o){return o.connectedImpostor===e&&o.joint===n&&o.mainImpostor===t});i.length&&this._physicsPlugin.removeJoint(i[0])},r.prototype._step=function(t){var e=this;this._impostors.forEach(function(n){n.isBodyInitRequired()&&e._physicsPlugin.generatePhysicsBody(n)}),t>.1?t=.1:t<=0&&(t=1/60),this._physicsPlugin.executeStep(t,this._impostors)},r.prototype.getPhysicsPlugin=function(){return this._physicsPlugin},r.prototype.getImpostors=function(){return this._impostors},r.prototype.getImpostorForPhysicsObject=function(t){for(var e=0;e<this._impostors.length;++e)if(this._impostors[e].object===t)return this._impostors[e];return null},r.prototype.getImpostorWithPhysicsBody=function(t){for(var e=0;e<this._impostors.length;++e)if(this._impostors[e].physicsBody===t)return this._impostors[e];return null},r.prototype.raycast=function(t,e){return this._physicsPlugin.raycast(t,e)},r.Epsilon=.001,r}(),Js=function(){function r(){this._hasHit=!1,this._hitDistance=0,this._hitNormalWorld=u.e.Zero(),this._hitPointWorld=u.e.Zero(),this._rayFromWorld=u.e.Zero(),this._rayToWorld=u.e.Zero()}return Object.defineProperty(r.prototype,"hasHit",{get:function(){return this._hasHit},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"hitDistance",{get:function(){return this._hitDistance},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"hitNormalWorld",{get:function(){return this._hitNormalWorld},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"hitPointWorld",{get:function(){return this._hitPointWorld},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"rayFromWorld",{get:function(){return this._rayFromWorld},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"rayToWorld",{get:function(){return this._rayToWorld},enumerable:!1,configurable:!0}),r.prototype.setHitData=function(t,e){this._hasHit=!0,this._hitNormalWorld=new u.e(t.x,t.y,t.z),this._hitPointWorld=new u.e(e.x,e.y,e.z)},r.prototype.setHitDistance=function(t){this._hitDistance=t},r.prototype.calculateHitDistance=function(){this._hitDistance=u.e.Distance(this._rayFromWorld,this._hitPointWorld)},r.prototype.reset=function(t,e){t===void 0&&(t=u.e.Zero()),e===void 0&&(e=u.e.Zero()),this._rayFromWorld=t,this._rayToWorld=e,this._hasHit=!1,this._hitDistance=0,this._hitNormalWorld=u.e.Zero(),this._hitPointWorld=u.e.Zero()},r}(),$s=function(){function r(t,e,n){t===void 0&&(t=!0),e===void 0&&(e=10),n===void 0&&(n=CANNON),this._useDeltaForWorldStep=t,this.name="CannonJSPlugin",this._physicsMaterials=new Array,this._fixedTimeStep=1/60,this._physicsBodysToRemoveAfterStep=new Array,this._firstFrame=!0,this._minus90X=new u.b(-.7071067811865475,0,0,.7071067811865475),this._plus90X=new u.b(.7071067811865475,0,0,.7071067811865475),this._tmpPosition=u.e.Zero(),this._tmpDeltaPosition=u.e.Zero(),this._tmpUnityRotation=new u.b,this.BJSCANNON=n,this.isSupported()?(this._extendNamespace(),this.world=new this.BJSCANNON.World,this.world.broadphase=new this.BJSCANNON.NaiveBroadphase,this.world.solver.iterations=e,this._cannonRaycastResult=new this.BJSCANNON.RaycastResult,this._raycastResult=new Js):l.a.Error("CannonJS is not available. Please make sure you included the js file.")}return r.prototype.setGravity=function(t){var e=t;this.world.gravity.set(e.x,e.y,e.z)},r.prototype.setTimeStep=function(t){this._fixedTimeStep=t},r.prototype.getTimeStep=function(){return this._fixedTimeStep},r.prototype.executeStep=function(t,e){if(this._firstFrame){this._firstFrame=!1;for(var n=0,i=e;n<i.length;n++){var o=i[n];o.type!=Ct.a.HeightmapImpostor&&o.type!==Ct.a.PlaneImpostor&&o.beforeStep()}}this.world.step(this._useDeltaForWorldStep?t:this._fixedTimeStep),this._removeMarkedPhysicsBodiesFromWorld()},r.prototype._removeMarkedPhysicsBodiesFromWorld=function(){var t=this;this._physicsBodysToRemoveAfterStep.length>0&&(this._physicsBodysToRemoveAfterStep.forEach(function(e){t.world.remove(e)}),this._physicsBodysToRemoveAfterStep=[])},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),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}
7311,a=t.getParam("nativeOptions");for(var s in a)a.hasOwnProperty(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),this.world.add(t.physicsBody),n&&["force","torque","velocity","angularVelocity"].forEach(function(d){var p=n[d];t.physicsBody[d].set(p.x,p.y,p.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(n.length){var o=function(a){if(i&&a.rotationQuaternion){var s=a.getPhysicsImpostor();if(s&&s.parent!==t){var d=a.getAbsolutePosition().subtract(a.parent.getAbsolutePosition()),p=a.rotationQuaternion;s.physicsBody&&(e.removePhysicsBody(s),s.physicsBody=null),s.parent=t,s.resetUpdateFlags(),t.physicsBody.addShape(e._createShape(s),new e.BJSCANNON.Vec3(d.x,d.y,d.z),new e.BJSCANNON.Quaternion(p.x,p.y,p.z,p.w)),t.physicsBody.mass+=s.getParam("mass")}i.multiplyInPlace(a.rotationQuaternion),a.getChildMeshes(!0).filter(function(y){return!!y.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._physicsBodysToRemoveAfterStep.indexOf(t.physicsBody)===-1&&this._physicsBodysToRemoveAfterStep.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 en.e.HingeJoint:case en.e.Hinge2Joint:i=new this.BJSCANNON.HingeConstraint(e,n,a);break;case en.e.DistanceJoint:i=new this.BJSCANNON.DistanceConstraint(e,n,o.maxDistance||2);break;case en.e.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 en.e.LockJoint:i=new this.BJSCANNON.LockConstraint(e,n,a);break;case en.e.PointToPointJoint:case en.e.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!==en.e.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!==en.e.SpringJoint?this.world.removeConstraint(t.joint.physicsJoint):t.mainImpostor.unregisterAfterPhysicsStep(t.joint.jointData.forceApplicationCallback)},r.prototype._addMaterial=function(t,e,n){var i,o;for(i=0;i<this._physicsMaterials.length;i++)if((o=this._physicsMaterials[i]).friction===e&&o.restitution===n)return o;var a=new this.BJSCANNON.Material(t);return a.friction=e,a.restitution=n,this._physicsMaterials.push(a),a},r.prototype._checkWithEpsilon=function(t){return t<Mr.Epsilon?Mr.Epsilon:t},r.prototype._createShape=function(t){var e,n=t.object,i=t.getObjectExtendSize();switch(t.type){case Ct.a.SphereImpostor:var o=i.x,a=i.y,s=i.z;e=new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(o),this._checkWithEpsilon(a),this._checkWithEpsilon(s))/2);break;case Ct.a.CylinderImpostor:var d=t.getParam("nativeOptions");d||(d={});var p=d.radiusTop!==void 0?d.radiusTop:this._checkWithEpsilon(i.x)/2,y=d.radiusBottom!==void 0?d.radiusBottom:this._checkWithEpsilon(i.x)/2,P=d.height!==void 0?d.height:this._checkWithEpsilon(i.y),O=d.numSegments!==void 0?d.numSegments:16;e=new this.BJSCANNON.Cylinder(p,y,P,O);var U=new this.BJSCANNON.Quaternion;U.setFromAxisAngle(new this.BJSCANNON.Vec3(1,0,0),-Math.PI/2);var F=new this.BJSCANNON.Vec3(0,0,0);e.transformAllPoints(F,U);break;case Ct.a.BoxImpostor:var z=i.scale(.5);e=new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(z.x),this._checkWithEpsilon(z.y),this._checkWithEpsilon(z.z)));break;case Ct.a.PlaneImpostor:l.a.Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead"),e=new this.BJSCANNON.Plane;break;case Ct.a.MeshImpostor:var J=n.getVerticesData?n.getVerticesData(Me.b.PositionKind):[],ie=n.getIndices?n.getIndices():[];if(!J)return;var se=n.position.clone(),ce=n.rotation&&n.rotation.clone(),ue=n.rotationQuaternion&&n.rotationQuaternion.clone();n.position.copyFromFloats(0,0,0),n.rotation&&n.rotation.copyFromFloats(0,0,0),n.rotationQuaternion&&n.rotationQuaternion.copyFrom(t.getParentsRotation()),n.rotationQuaternion&&n.parent&&n.rotationQuaternion.conjugateInPlace();var fe,ve=n.computeWorldMatrix(!0),Te=new Array;for(fe=0;fe<J.length;fe+=3)u.e.TransformCoordinates(u.e.FromArray(J,fe),ve).toArray(Te,fe);l.a.Warn("MeshImpostor only collides against spheres."),e=new this.BJSCANNON.Trimesh(Te,ie),n.position.copyFrom(se),ce&&n.rotation&&n.rotation.copyFrom(ce),ue&&n.rotationQuaternion&&n.rotationQuaternion.copyFrom(ue);break;case Ct.a.HeightmapImpostor:var Oe=n.position.clone(),Pe=n.rotation&&n.rotation.clone(),Ee=n.rotationQuaternion&&n.rotationQuaternion.clone();n.position.copyFromFloats(0,0,0),n.rotation&&n.rotation.copyFromFloats(0,0,0),n.rotationQuaternion&&n.rotationQuaternion.copyFrom(t.getParentsRotation()),n.rotationQuaternion&&n.parent&&n.rotationQuaternion.conjugateInPlace(),n.rotationQuaternion&&n.rotationQuaternion.multiplyInPlace(this._minus90X),e=this._createHeightmap(n),n.position.copyFrom(Oe),Pe&&n.rotation&&n.rotation.copyFrom(Pe),Ee&&n.rotationQuaternion&&n.rotationQuaternion.copyFrom(Ee),n.computeWorldMatrix(!0);break;case Ct.a.ParticleImpostor:e=new this.BJSCANNON.Particle;break;case Ct.a.NoImpostor:e=new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(0,0,0))}return e},r.prototype._createHeightmap=function(t,e){var n,i=t.getVerticesData(Me.b.PositionKind),o=t.computeWorldMatrix(!0),a=new Array;for(n=0;n<i.length;n+=3)u.e.TransformCoordinates(u.e.FromArray(i,n),o).toArray(a,n);i=a;for(var s=new Array,d=e||~~(Math.sqrt(i.length/3)-1),p=t.getBoundingInfo(),y=Math.min(p.boundingBox.extendSizeWorld.x,p.boundingBox.extendSizeWorld.y),P=p.boundingBox.extendSizeWorld.z,O=2*y/d,U=0;U<i.length;U+=3){var F=Math.round(i[U+0]/O+d/2),z=Math.round(-1*(i[U+1]/O-d/2)),J=-i[U+2]+P;s[F]||(s[F]=[]),s[F][z]||(s[F][z]=J),s[F][z]=Math.max(J,s[F][z])}for(F=0;F<=d;++F){if(!s[F]){for(var ie=1;!s[(F+ie)%d];)ie++;s[F]=s[(F+ie)%d].slice()}for(z=0;z<=d;++z)if(!s[F][z]){var se;for(ie=1;se===void 0;)se=s[F][(z+ie++)%d];s[F][z]=se}}var ce=new this.BJSCANNON.Heightfield(s,{elementSize:O});return ce.minY=P,ce},r.prototype._updatePhysicsBodyTransformation=function(t){var e=t.object;if(e.computeWorldMatrix&&e.computeWorldMatrix(!0),e.getBoundingInfo()){var n=t.getObjectCenter();this._tmpDeltaPosition.copyFrom(e.getAbsolutePivotPoint().subtract(n)),this._tmpDeltaPosition.divideInPlace(t.object.scaling),this._tmpPosition.copyFrom(n);var i=e.rotationQuaternion;if(i){if(t.type!==Ct.a.PlaneImpostor&&t.type!==Ct.a.HeightmapImpostor||(i=i.multiply(this._minus90X),t.setDeltaRotation(this._plus90X)),t.type===Ct.a.HeightmapImpostor){var o=e,a=o.getBoundingInfo(),s=o.rotationQuaternion;o.rotationQuaternion=this._tmpUnityRotation,o.computeWorldMatrix(!0);var d=n.clone(),p=o.getPivotMatrix();p=p?p.clone():u.a.Identity();var y=u.a.Translation(a.boundingBox.extendSizeWorld.x,0,-a.boundingBox.extendSizeWorld.z);o.setPreTransformMatrix(y),o.computeWorldMatrix(!0);var P=a.boundingBox.centerWorld.subtract(n).subtract(o.position).negate();this._tmpPosition.copyFromFloats(P.x,P.y-a.boundingBox.extendSizeWorld.y,P.z),this._tmpDeltaPosition.copyFrom(a.boundingBox.centerWorld.subtract(d)),this._tmpDeltaPosition.y+=a.boundingBox.extendSizeWorld.y,o.rotationQuaternion=s,o.setPreTransformMatrix(p),o.computeWorldMatrix(!0)}else t.type===Ct.a.MeshImpostor&&this._tmpDeltaPosition.copyFromFloats(0,0,0);t.setDeltaPosition(this._tmpDeltaPosition),t.physicsBody.position.set(this._tmpPosition.x,this._tmpPosition.y,this._tmpPosition.z),t.physicsBody.quaternion.set(i.x,i.y,i.z,i.w)}}},r.prototype.setTransformationFromPhysicsBody=function(t){if(t.object.position.set(t.physicsBody.position.x,t.physicsBody.position.y,t.physicsBody.position.z),t.object.rotationQuaternion){var e=t.physicsBody.quaternion;t.object.rotationQuaternion.set(e.x,e.y,e.z,e.w)}},r.prototype.setPhysicsBodyTransformation=function(t,e,n){t.physicsBody.position.set(e.x,e.y,e.z),t.physicsBody.quaternion.set(n.x,n.y,n.z,n.w)},r.prototype.isSupported=function(){return this.BJSCANNON!==void 0},r.prototype.setLinearVelocity=function(t,e){t.physicsBody.velocity.set(e.x,e.y,e.z)},r.prototype.setAngularVelocity=function(t,e){t.physicsBody.angularVelocity.set(e.x,e.y,e.z)},r.prototype.getLinearVelocity=function(t){var e=t.physicsBody.velocity;return e?new u.e(e.x,e.y,e.z):null},r.prototype.getAngularVelocity=function(t){var e=t.physicsBody.angularVelocity;return e?new u.e(e.x,e.y,e.z):null},r.prototype.setBodyMass=function(t,e){t.physicsBody.mass=e,t.physicsBody.updateMassProperties()},r.prototype.getBodyMass=function(t){return t.physicsBody.mass},r.prototype.getBodyFriction=function(t){return t.physicsBody.material.friction},r.prototype.setBodyFriction=function(t,e){t.physicsBody.material.friction=e},r.prototype.getBodyRestitution=function(t){return t.physicsBody.material.restitution},r.prototype.setBodyRestitution=function(t,e){t.physicsBody.material.restitution=e},r.prototype.sleepBody=function(t){t.physicsBody.sleep()},r.prototype.wakeUpBody=function(t){t.physicsBody.wakeUp()},r.prototype.updateDistanceJoint=function(t,e){t.physicsJoint.distance=e},r.prototype.setMotor=function(t,e,n,i){i||(t.physicsJoint.enableMotor(),t.physicsJoint.setMotorSpeed(e),n&&this.setLimit(t,n))},r.prototype.setLimit=function(t,e,n){t.physicsJoint.motorEquation.maxForce=e,t.physicsJoint.motorEquation.minForce=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.quaternion.x,t.rotationQuaternion.y=n.quaternion.y,t.rotationQuaternion.z=n.quaternion.z,t.rotationQuaternion.w=n.quaternion.w)},r.prototype.getRadius=function(t){return t.physicsBody.shapes[0].boundingSphereRadius},r.prototype.getBoxSizeToRef=function(t,e){var n=t.physicsBody.shapes[0];e.x=2*n.halfExtents.x,e.y=2*n.halfExtents.y,e.z=2*n.halfExtents.z},r.prototype.dispose=function(){},r.prototype._extendNamespace=function(){var t=new this.BJSCANNON.Vec3,e=this.BJSCANNON;this.BJSCANNON.World.prototype.step=function(n,i,o){if(o=o||10,(i=i||0)===0)this.internalStep(n),this.time+=n;else{var a=Math.floor((this.time+i)/n)-Math.floor(this.time/n);a=Math.min(a,o)||1;for(var s=performance.now(),d=0;d!==a&&(this.internalStep(n),!(performance.now()-s>1e3*n));d++);this.time+=i;for(var p=this.time%n/n,y=t,P=this.bodies,O=0;O!==P.length;O++){var U=P[O];U.type!==e.Body.STATIC&&U.sleepState!==e.Body.SLEEPING?(U.position.vsub(U.previousPosition,y),y.scale(p,y),U.position.vadd(y,U.interpolatedPosition)):(U.interpolatedPosition.set(U.position.x,U.position.y,U.position.z),U.interpolatedQuaternion.set(U.quaternion.x,U.quaternion.y,U.quaternion.z,U.quaternion.w))}}}},r.prototype.raycast=function(t,e){return this._cannonRaycastResult.reset(),this.world.raycastClosest(t,e,{},this._cannonRaycastResult),this._raycastResult.reset(t,e),this._cannonRaycastResult.hasHit&&(this._raycastResult.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}),this._raycastResult.setHitDistance(this._cannonRaycastResult.distance)),this._raycastResult},r}();Mr.DefaultPluginFactory=function(){return new $s};var ih=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=u.e.Zero(),this.BJSOIMO=n,this.world=new this.BJSOIMO.World({iterations:e}),this.world.clear(),this._raycastResult=new Js}return 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}),a.onCollide({body:o.physicsBody,point: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){l.a.Warn("Oimo doesn't support applying force. Using impule 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];
7311(s=t.object).getChildMeshes&&s.getChildMeshes().forEach(function(d){d.physicsImpostor&&i.push(d.physicsImpostor)});var o=function(d){return Math.max(d,Mr.Epsilon)},a=new u.b;i.forEach(function(d){if(d.object.rotationQuaternion){var p=d.object.rotationQuaternion;a.copyFrom(p),d.object.rotationQuaternion.set(0,0,0,1),d.object.computeWorldMatrix(!0);var y=a.toEulerAngles(),P=d.getObjectExtendSize();if(d===t){var O=t.getObjectCenter();t.object.getAbsolutePivotPoint().subtractToRef(O,e._tmpPositionVector),e._tmpPositionVector.divideInPlace(t.object.scaling),n.pos.push(O.x),n.pos.push(O.y),n.pos.push(O.z),n.posShape.push(0,0,0),n.rotShape.push(0,0,0)}else{var U=d.object.position.clone();n.posShape.push(U.x),n.posShape.push(U.y),n.posShape.push(U.z),n.rotShape.push(57.29577951308232*y.x,57.29577951308232*y.y,57.29577951308232*y.z)}switch(d.object.rotationQuaternion.copyFrom(a),d.type){case Ct.a.ParticleImpostor:l.a.Warn("No Particle support in OIMO.js. using SphereImpostor instead");case Ct.a.SphereImpostor:var F=P.x,z=P.y,J=P.z,ie=Math.max(o(F),o(z),o(J))/2;n.type.push("sphere"),n.size.push(ie),n.size.push(ie),n.size.push(ie);break;case Ct.a.CylinderImpostor:var se=o(P.x)/2,ce=o(P.y);n.type.push("cylinder"),n.size.push(se),n.size.push(ce),n.size.push(ce);break;case Ct.a.PlaneImpostor:case Ct.a.BoxImpostor:default:se=o(P.x),ce=o(P.y);var ue=o(P.z);n.type.push("box"),n.size.push(se),n.size.push(ce),n.size.push(ue)}d.object.rotationQuaternion=p}}),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 en.e.BallAndSocketJoint:i="jointBall";break;case en.e.SpringJoint:l.a.Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");var d=o;s.min=d.length||s.min,s.max=Math.max(s.min,s.max);case en.e.DistanceJoint:i="jointDistance",s.max=o.maxDistance;break;case en.e.PrismaticJoint:i="jointPrisme";break;case en.e.SliderJoint:i="jointSlide";break;case en.e.WheelJoint:i="jointWheel";break;case en.e.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){l.a.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 u.e(e.x,e.y,e.z):null},r.prototype.getAngularVelocity=function(t){var e=t.physicsBody.angularVelocity;return e?new u.e(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?l.a.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.s)},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 l.a.Warn("raycast is not currently supported by the Oimo physics plugin"),this._raycastResult.reset(t,e),this._raycastResult},r}(),ha=f(97),rh=function(){function r(t,e,n){var i=this;t===void 0&&(t=!0),e===void 0&&(e=Ammo),n===void 0&&(n=null),this._useDeltaForWorldStep=t,this.bjsAMMO={},this.name="AmmoJSPlugin",this._timeStep=1/60,this._fixedTimeStep=1/60,this._maxSteps=5,this._tmpQuaternion=new u.b,this._tmpContactCallbackResult=!1,this._tmpContactPoint=new u.e,this._tmpMatrix=new u.a,typeof e=="function"?e(this.bjsAMMO):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,a,s,d){var p=(o=i.bjsAMMO.wrapPointer(o,Ammo.btManifoldPoint)).getPositionWorldOnA();i._tmpContactPoint.x=p.x(),i._tmpContactPoint.y=p.y(),i._tmpContactPoint.z=p.z(),i._tmpContactCallbackResult=!0},this._raycastResult=new Js,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)):l.a.Error("AmmoJS is not available. Please make sure you included the js file.")}return r.prototype.setGravity=function(t){this._tmpAmmoVectorA.setValue(t.x,t.y,t.z),this.world.setGravity(this._tmpAmmoVectorA),this.world.getWorldInfo().set_m_gravity(this._tmpAmmoVectorA)},r.prototype.setTimeStep=function(t){this._timeStep=t},r.prototype.setFixedTimeStep=function(t){this._fixedTimeStep=t},r.prototype.setMaxSteps=function(t){this._maxSteps=t},r.prototype.getTimeStep=function(){return this._timeStep},r.prototype._isImpostorInContact=function(t){return this._tmpContactCallbackResult=!1,this.world.contactTest(t.physicsBody,this._tmpAmmoConcreteContactResultCallback),this._tmpContactCallbackResult},r.prototype._isImpostorPairInContact=function(t,e){return this._tmpContactCallbackResult=!1,this.world.contactPairTest(t.physicsBody,e.physicsBody,this._tmpAmmoConcreteContactResultCallback),this._tmpContactCallbackResult},r.prototype._stepSimulation=function(t,e,n){if(t===void 0&&(t=1/60),e===void 0&&(e=10),n===void 0&&(n=1/60),e==0)this.world.stepSimulation(t,0);else for(;e>0&&t>0;)t-n<n?(this.world.stepSimulation(t,0),t=0):(t-=n,this.world.stepSimulation(n,0)),e--},r.prototype.executeStep=function(t,e){for(var n=0,i=e;n<i.length;n++){var o=i[n];o.soft||o.beforeStep()}this._stepSimulation(this._useDeltaForWorldStep?t:this._timeStep,this._maxSteps,this._fixedTimeStep);for(var a=0,s=e;a<s.length;a++){var d=s[a];if(d.soft?this._afterSoftStep(d):d.afterStep(),d._onPhysicsCollideCallbacks.length>0&&this._isImpostorInContact(d))for(var p=0,y=d._onPhysicsCollideCallbacks;p<y.length;p++)for(var P=0,O=y[p].otherImpostors;P<O.length;P++){var U=O[P];(d.physicsBody.isActive()||U.physicsBody.isActive())&&this._isImpostorPairInContact(d,U)&&(d.onCollide({body:U.physicsBody,point:this._tmpContactPoint}),U.onCollide({body:d.physicsBody,point:this._tmpContactPoint}))}}},r.prototype._afterSoftStep=function(t){t.type===Ct.a.RopeImpostor?this._ropeStep(t):this._softbodyOrClothStep(t)},r.prototype._ropeStep=function(t){for(var e,n,i,o,a=t.physicsBody.get_m_nodes(),s=a.size(),d=new Array,p=0;p<s;p++)n=(e=a.at(p).get_m_x()).x(),i=e.y(),o=e.z(),d.push(new u.e(n,i,o));var y=t.object,P=t.getParam("shape");t._isFromLine?t.object=cn.a.CreateLines("lines",{points:d,instance:y}):t.object=ha.a.ExtrudeShape("ext",{shape:P,path:d,instance:y})},r.prototype._softbodyOrClothStep=function(t){var e=t.type===Ct.a.ClothImpostor?1:-1,n=t.object,i=n.getVerticesData(Me.b.PositionKind);i||(i=[]);var o=n.getVerticesData(Me.b.NormalKind);o||(o=[]);for(var a,s,d,p,y,P,O,U,F=i.length/3,z=t.physicsBody.get_m_nodes(),J=0;J<F;J++){var ie;d=(s=(a=z.at(J)).get_m_x()).x(),p=s.y(),y=s.z()*e,P=(ie=a.get_m_n()).x(),O=ie.y(),U=ie.z()*e,i[3*J]=d,i[3*J+1]=p,i[3*J+2]=y,o[3*J]=P,o[3*J+1]=O,o[3*J+2]=U}var se=new ft.a;se.positions=i,se.normals=o,se.uvs=n.getVerticesData(Me.b.UVKind),se.colors=n.getVerticesData(Me.b.ColorKind),n&&n.getIndices&&(se.indices=n.getIndices()),se.applyToMesh(n)},r.prototype.applyImpulse=function(t,e,n){if(t.soft)l.a.Warn("Cannot be applied to a soft body");else{t.physicsBody.activate();var i=this._tmpAmmoVectorA,o=this._tmpAmmoVectorB;t.object&&t.object.getWorldMatrix&&n.subtractInPlace(t.object.getWorldMatrix().getTranslation()),i.setValue(n.x,n.y,n.z),o.setValue(e.x,e.y,e.z),t.physicsBody.applyImpulse(o,i)}},r.prototype.applyForce=function(t,e,n){if(t.soft)l.a.Warn("Cannot be applied to a soft body");else{t.physicsBody.activate();var i=this._tmpAmmoVectorA,o=this._tmpAmmoVectorB;t.object&&t.object.getWorldMatrix&&n.subtractInPlace(t.object.getWorldMatrix().getTranslation()),i.setValue(n.x,n.y,n.z),o.setValue(e.x,e.y,e.z),t.physicsBody.applyForce(o,i)}},r.prototype.generatePhysicsBody=function(t){if(t._pluginData.toDispose=[],t.parent)t.physicsBody&&(this.removePhysicsBody(t),t.forceUpdate());else if(t.isBodyInitRequired()){var e=this._createShape(t),n=t.getParam("mass");if(t._pluginData.mass=n,t.soft)e.get_m_cfg().set_collisions(17),e.get_m_cfg().set_kDP(t.getParam("damping")),this.bjsAMMO.castObject(e,this.bjsAMMO.btCollisionObject).getCollisionShape().setMargin(t.getParam("margin")),e.setActivationState(r.DISABLE_DEACTIVATION_FLAG),this.world.addSoftBody(e,1,-1),t.physicsBody=e,t._pluginData.toDispose.push(e),this.setBodyPressure(t,0),t.type===Ct.a.SoftbodyImpostor&&this.setBodyPressure(t,t.getParam("pressure")),this.setBodyStiffness(t,t.getParam("stiffness")),this.setBodyVelocityIterations(t,t.getParam("velocityIterations")),this.setBodyPositionIterations(t,t.getParam("positionIterations"));else{var i=new this.bjsAMMO.btVector3(0,0,0),o=new this.bjsAMMO.btTransform;o.setIdentity(),n!==0&&e.calculateLocalInertia(n,i),this._tmpAmmoVectorA.setValue(t.object.position.x,t.object.position.y,t.object.position.z),this._tmpAmmoQuaternion.setValue(t.object.rotationQuaternion.x,t.object.rotationQuaternion.y,t.object.rotationQuaternion.z,t.object.rotationQuaternion.w),o.setOrigin(this._tmpAmmoVectorA),o.setRotation(this._tmpAmmoQuaternion);var a=new this.bjsAMMO.btDefaultMotionState(o),s=new this.bjsAMMO.btRigidBodyConstructionInfo(n,a,e,i),d=new this.bjsAMMO.btRigidBody(s);n===0&&(d.setCollisionFlags(d.getCollisionFlags()|r.KINEMATIC_FLAG),d.setActivationState(r.DISABLE_DEACTIVATION_FLAG)),t.type!=Ct.a.NoImpostor||e.getChildShape||d.setCollisionFlags(d.getCollisionFlags()|r.DISABLE_COLLISION_FLAG);var p=t.getParam("group"),y=t.getParam("mask");p&&y?this.world.addRigidBody(d,p,y):this.world.addRigidBody(d),t.physicsBody=d,t._pluginData.toDispose=t._pluginData.toDispose.concat([d,s,a,o,i,e])}this.setBodyRestitution(t,t.getParam("restitution")),this.setBodyFriction(t,t.getParam("friction"))}},r.prototype.removePhysicsBody=function(t){var e=this;this.world&&(t.soft?this.world.removeSoftBody(t.physicsBody):this.world.removeRigidBody(t.physicsBody),t._pluginData&&(t._pluginData.toDispose.forEach(function(n){e.bjsAMMO.destroy(n)}),t._pluginData.toDispose=[]))},r.prototype.generateJoint=function(t){var e=t.mainImpostor.physicsBody,n=t.connectedImpostor.physicsBody;if(e&&n){var i,o=t.joint.jointData;switch(o.mainPivot||(o.mainPivot=new u.e(0,0,0)),o.connectedPivot||(o.connectedPivot=new u.e(0,0,0)),t.joint.type){case en.e.DistanceJoint:var a=o.maxDistance;a&&(o.mainPivot=new u.e(0,-a/2,0),o.connectedPivot=new u.e(0,a/2,0)),i=new this.bjsAMMO.btPoint2PointConstraint(e,n,new this.bjsAMMO.btVector3(o.mainPivot.x,o.mainPivot.y,o.mainPivot.z),new this.bjsAMMO.btVector3(o.connectedPivot.x,o.connectedPivot.y,o.connectedPivot.z));break;case en.e.HingeJoint:o.mainAxis||(o.mainAxis=new u.e(0,0,0)),o.connectedAxis||(o.connectedAxis=new u.e(0,0,0));var s=new this.bjsAMMO.btVector3(o.mainAxis.x,o.mainAxis.y,o.mainAxis.z),d=new this.bjsAMMO.btVector3(o.connectedAxis.x,o.connectedAxis.y,o.connectedAxis.z);i=new this.bjsAMMO.btHingeConstraint(e,n,new this.bjsAMMO.btVector3(o.mainPivot.x,o.mainPivot.y,o.mainPivot.z),new this.bjsAMMO.btVector3(o.connectedPivot.x,o.connectedPivot.y,o.connectedPivot.z),s,d);break;case en.e.BallAndSocketJoint:i=new this.bjsAMMO.btPoint2PointConstraint(e,n,new this.bjsAMMO.btVector3(o.mainPivot.x,o.mainPivot.y,o.mainPivot.z),new this.bjsAMMO.btVector3(o.connectedPivot.x,o.connectedPivot.y,o.connectedPivot.z));break;default:l.a.Warn("JointType not currently supported by the Ammo plugin, falling back to PhysicsJoint.BallAndSocketJoint"),i=new this.bjsAMMO.btPoint2PointConstraint(e,n,new this.bjsAMMO.btVector3(o.mainPivot.x,o.mainPivot.y,o.mainPivot.z),new this.bjsAMMO.btVector3(o.connectedPivot.x,o.connectedPivot.y,o.connectedPivot.z))}this.world.addConstraint(i,!t.joint.jointData.collision),t.joint.physicsJoint=i}},r.prototype.removeJoint=function(t){this.world&&this.world.removeConstraint(t.joint.physicsJoint)},r.prototype._addMeshVerts=function(t,e,n){var i=this,o=0;if(n&&n.getIndices&&n.getWorldMatrix&&n.getChildMeshes){var a=n.getIndices();a||(a=[]);var s=n.getVerticesData(Me.b.PositionKind);s||(s=[]),n.computeWorldMatrix(!1);for(var d=a.length/3,p=0;p<d;p++){for(var y=[],P=0;P<3;P++){var O,U=new u.e(s[3*a[3*p+P]+0],s[3*a[3*p+P]+1],s[3*a[3*p+P]+2]);u.a.ScalingToRef(n.scaling.x,n.scaling.y,n.scaling.z,this._tmpMatrix),U=u.e.TransformCoordinates(U,this._tmpMatrix),(O=P==0?this._tmpAmmoVectorA:P==1?this._tmpAmmoVectorB:this._tmpAmmoVectorC).setValue(U.x,U.y,U.z),y.push(O)}t.addTriangle(y[0],y[1],y[2]),o++}
7311n.getChildMeshes().forEach(function(F){o+=i._addMeshVerts(t,e,F)})}return o},r.prototype._softVertexData=function(t){var e=t.object;if(e&&e.getIndices&&e.getWorldMatrix&&e.getChildMeshes){e.getIndices();var n=e.getVerticesData(Me.b.PositionKind);n||(n=[]);var i=e.getVerticesData(Me.b.NormalKind);i||(i=[]),e.computeWorldMatrix(!1);for(var o=[],a=[],s=0;s<n.length;s+=3){var d=new u.e(n[s],n[s+1],n[s+2]),p=new u.e(i[s],i[s+1],i[s+2]);d=u.e.TransformCoordinates(d,e.getWorldMatrix()),p=u.e.TransformNormal(p,e.getWorldMatrix()),o.push(d.x,d.y,d.z),a.push(p.x,p.y,p.z)}var y=new ft.a;return y.positions=o,y.normals=a,y.uvs=e.getVerticesData(Me.b.UVKind),y.colors=e.getVerticesData(Me.b.ColorKind),e&&e.getIndices&&(y.indices=e.getIndices()),y.applyToMesh(e),e.position=u.e.Zero(),e.rotationQuaternion=null,e.rotation=u.e.Zero(),e.computeWorldMatrix(!0),y}return ft.a.ExtractFromMesh(e)},r.prototype._createSoftbody=function(t){var e=t.object;if(e&&e.getIndices){var n=e.getIndices();n||(n=[]);var i=this._softVertexData(t),o=i.positions,a=i.normals;if(o===null||a===null)return new this.bjsAMMO.btCompoundShape;for(var s=[],d=[],p=0;p<o.length;p+=3){var y=new u.e(o[p],o[p+1],o[p+2]),P=new u.e(a[p],a[p+1],a[p+2]);s.push(y.x,y.y,-y.z),d.push(P.x,P.y,-P.z)}var O=new this.bjsAMMO.btSoftBodyHelpers().CreateFromTriMesh(this.world.getWorldInfo(),s,e.getIndices(),n.length/3,!0),U=o.length/3,F=O.get_m_nodes();for(p=0;p<U;p++){var z;(z=F.at(p).get_m_n()).setX(d[3*p]),z.setY(d[3*p+1]),z.setZ(d[3*p+2])}return O}},r.prototype._createCloth=function(t){var e=t.object;if(e&&e.getIndices){e.getIndices();var n=this._softVertexData(t),i=n.positions,o=n.normals;if(i===null||o===null)return new this.bjsAMMO.btCompoundShape;var a=i.length,s=Math.sqrt(a/3);t.segments=s;var d=s-1;return this._tmpAmmoVectorA.setValue(i[0],i[1],i[2]),this._tmpAmmoVectorB.setValue(i[3*d],i[3*d+1],i[3*d+2]),this._tmpAmmoVectorD.setValue(i[a-3],i[a-2],i[a-1]),this._tmpAmmoVectorC.setValue(i[a-3-3*d],i[a-2-3*d],i[a-1-3*d]),new this.bjsAMMO.btSoftBodyHelpers().CreatePatch(this.world.getWorldInfo(),this._tmpAmmoVectorA,this._tmpAmmoVectorB,this._tmpAmmoVectorC,this._tmpAmmoVectorD,s,s,t.getParam("fixedPoints"),!0)}},r.prototype._createRope=function(t){var e,n,i=this._softVertexData(t),o=i.positions,a=i.normals;if(o===null||a===null)return new this.bjsAMMO.btCompoundShape;if(i.applyToMesh(t.object,!0),t._isFromLine=!0,a.map(function(y){return y*y}).reduce(function(y,P){return y+P})===0)n=(e=o.length)/3-1,this._tmpAmmoVectorA.setValue(o[0],o[1],o[2]),this._tmpAmmoVectorB.setValue(o[e-3],o[e-2],o[e-1]);else{t._isFromLine=!1;var s=t.getParam("path");if(t.getParam("shape")===null)return l.a.Warn("No shape available for extruded mesh"),new this.bjsAMMO.btCompoundShape;if(o.length%(3*s.length)!=0)return l.a.Warn("Path does not match extrusion"),new this.bjsAMMO.btCompoundShape;n=(e=s.length)-1,this._tmpAmmoVectorA.setValue(s[0].x,s[0].y,s[0].z),this._tmpAmmoVectorB.setValue(s[e-1].x,s[e-1].y,s[e-1].z)}t.segments=n;var d=t.getParam("fixedPoints");d=d>3?3:d;var p=new this.bjsAMMO.btSoftBodyHelpers().CreateRope(this.world.getWorldInfo(),this._tmpAmmoVectorA,this._tmpAmmoVectorB,n-1,d);return p.get_m_cfg().set_collisions(17),p},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(Me.b.PositionKind);s||(s=[]),n.computeWorldMatrix(!1);for(var d=a.length/3,p=0;p<d;p++){for(var y=[],P=0;P<3;P++){var O,U=new u.e(s[3*a[3*p+P]+0],s[3*a[3*p+P]+1],s[3*a[3*p+P]+2]);u.a.ScalingToRef(n.scaling.x,n.scaling.y,n.scaling.z,this._tmpMatrix),U=u.e.TransformCoordinates(U,this._tmpMatrix),(O=P==0?this._tmpAmmoVectorA:P==1?this._tmpAmmoVectorB:this._tmpAmmoVectorC).setValue(U.x,U.y,U.z),y.push(O)}t.addPoint(y[0],!0),t.addPoint(y[1],!0),t.addPoint(y[2],!0),o++}n.getChildMeshes().forEach(function(F){o+=i._addHullVerts(t,e,F)})}return o},r.prototype._createShape=function(t,e){var n=this;e===void 0&&(e=!1);var i,o=t.object,a=t.getObjectExtendSize();if(!e){var s=t.object.getChildMeshes?t.object.getChildMeshes(!0):[];i=new this.bjsAMMO.btCompoundShape;var d=0;if(s.forEach(function(F){var z=F.getPhysicsImpostor();if(z){if(z.type==Ct.a.MeshImpostor)throw"A child MeshImpostor is not supported. Only primitive impostors are supported as children (eg. box or sphere)";var J=n._createShape(z),ie=F.parent.getWorldMatrix().clone(),se=new u.e;ie.decompose(se),n._tmpAmmoTransform.getOrigin().setValue(F.position.x*se.x,F.position.y*se.y,F.position.z*se.z),n._tmpAmmoQuaternion.setValue(F.rotationQuaternion.x,F.rotationQuaternion.y,F.rotationQuaternion.z,F.rotationQuaternion.w),n._tmpAmmoTransform.setRotation(n._tmpAmmoQuaternion),i.addChildShape(n._tmpAmmoTransform,J),z.dis
7311pose(),d++}}),d>0){if(t.type!=Ct.a.NoImpostor){var p=this._createShape(t,!0);p&&(this._tmpAmmoTransform.getOrigin().setValue(0,0,0),this._tmpAmmoQuaternion.setValue(0,0,0,1),this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion),i.addChildShape(this._tmpAmmoTransform,p))}return i}this.bjsAMMO.destroy(i),i=null}switch(t.type){case Ct.a.SphereImpostor:if($.a.WithinEpsilon(a.x,a.y,1e-4)&&$.a.WithinEpsilon(a.x,a.z,1e-4))i=new this.bjsAMMO.btSphereShape(a.x/2);else{var y=[new this.bjsAMMO.btVector3(0,0,0)];(i=new this.bjsAMMO.btMultiSphereShape(y,[1],1)).setLocalScaling(new this.bjsAMMO.btVector3(a.x/2,a.y/2,a.z/2))}break;case Ct.a.CapsuleImpostor:i=new this.bjsAMMO.btCapsuleShape(a.x/2,a.y/2);break;case Ct.a.CylinderImpostor:this._tmpAmmoVectorA.setValue(a.x/2,a.y/2,a.z/2),i=new this.bjsAMMO.btCylinderShape(this._tmpAmmoVectorA);break;case Ct.a.PlaneImpostor:case Ct.a.BoxImpostor:this._tmpAmmoVectorA.setValue(a.x/2,a.y/2,a.z/2),i=new this.bjsAMMO.btBoxShape(this._tmpAmmoVectorA);break;case Ct.a.MeshImpostor:if(t.getParam("mass")==0){var P=new this.bjsAMMO.btTriangleMesh;t._pluginData.toDispose.push(P);var O=this._addMeshVerts(P,o,o);i=O==0?new this.bjsAMMO.btCompoundShape:new this.bjsAMMO.btBvhTriangleMeshShape(P);break}case Ct.a.ConvexHullImpostor:var U=new this.bjsAMMO.btConvexHullShape;(O=this._addHullVerts(U,o,o))==0?(t._pluginData.toDispose.push(U),i=new this.bjsAMMO.btCompoundShape):i=U;break;case Ct.a.NoImpostor:i=new this.bjsAMMO.btSphereShape(a.x/2);break;case Ct.a.CustomImpostor:i=this._createCustom(t);break;case Ct.a.SoftbodyImpostor:i=this._createSoftbody(t);break;case Ct.a.ClothImpostor:i=this._createCloth(t);break;case Ct.a.RopeImpostor:i=this._createRope(t);break;default:l.a.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)>Gt.a||Math.abs(i.getOrigin().y()-e.y)>Gt.a||Math.abs(i.getOrigin().z()-e.z)>Gt.a||Math.abs(i.getRotation().x()-n.x)>Gt.a||Math.abs(i.getRotation().y()-n.y)>Gt.a||Math.abs(i.getRotation().z()-n.z)>Gt.a||Math.abs(i.getRotation().w()-n.w)>Gt.a)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){if(t.soft)var e=t.physicsBody.linearVelocity();else e=t.physicsBody.getLinearVelocity();if(!e)return null;var n=new u.e(e.x(),e.y(),e.z());return this.bjsAMMO.destroy(e),n},r.prototype.getAngularVelocity=function(t){if(t.soft)var e=t.physicsBody.angularVelocity();else e=t.physicsBody.getAngularVelocity();if(!e)return null;var n=new u.e(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:(l.a.Warn("Pressure is not a property of a rigid body"),0)},r.prototype.setBodyPressure=function(t,e){t.soft?t.type===Ct.a.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):l.a.Warn("Pressure can only be applied to a softbody")},r.prototype.getBodyStiffness=function(t){return t.soft?t._pluginData.stiffness||0:(l.a.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):l.a.Warn("Stiffness cannot be applied to a rigid body")},r.prototype.getBodyVelocityIterations=function(t){return t.soft?t._pluginData.velocityIterations||0:(l.a.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):l.a.Warn("Velocity iterations cannot be applied to a rigid body")},r.prototype.getBodyPositionIterations=function(t){return t.soft?t._pluginData.positionIterations||0:(l.a.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):l.a.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,d=Math.round((s-1)*n)+s*(s-1-Math.round((s-1)*i));t.physicsBody.appendAnchor(d,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){l.a.Warn("sleepBody is not currently supported by the Ammo physics plugin")},r.prototype.wakeUpBody=function(t){t.physicsBody.activate()},r.prototype.updateDistanceJoint=function(t,e,n){l.a.Warn("updateDistanceJoint is not currently supported by the Ammo physics plugin")},r.prototype.setMotor=function(t,e,n,i){t.physicsJoint.enableAngularMotor(!0,e,n)}
7311,r.prototype.setLimit=function(t,e,n){l.a.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.getObjectExtendSize().x/2},r.prototype.getBoxSizeToRef=function(t,e){var n=t.getObjectExtendSize();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._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._tmpAmmoTransform),this.bjsAMMO.destroy(this._tmpAmmoQuaternion),this.bjsAMMO.destroy(this._tmpAmmoConcreteContactResultCallback),this.world=null},r.prototype.raycast=function(t,e){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 n=new this.bjsAMMO.ClosestRayResultCallback(this._tmpAmmoVectorRCA,this._tmpAmmoVectorRCB);return this.world.rayTest(this._tmpAmmoVectorRCA,this._tmpAmmoVectorRCB,n),this._raycastResult.reset(t,e),n.hasHit()&&(this._raycastResult.setHitData({x:n.get_m_hitNormalWorld().x(),y:n.get_m_hitNormalWorld().y(),z:n.get_m_hitNormalWorld().z()},{x:n.get_m_hitPointWorld().x(),y:n.get_m_hitPointWorld().y(),z:n.get_m_hitPointWorld().z()}),this._raycastResult.calculateHitDistance()),this.bjsAMMO.destroy(n),this.bjsAMMO.destroy(this._tmpAmmoVectorRCA),this.bjsAMMO.destroy(this._tmpAmmoVectorRCB),this._raycastResult},r.DISABLE_COLLISION_FLAG=4,r.KINEMATIC_FLAG=2,r.DISABLE_DEACTIVATION_FLAG=4,r}();B.a.prototype.removeReflectionProbe=function(r){if(!this.reflectionProbes)return-1;var t=this.reflectionProbes.indexOf(r);return t!==-1&&this.reflectionProbes.splice(t,1),t},B.a.prototype.addReflectionProbe=function(r){this.reflectionProbes||(this.reflectionProbes=[]),this.reflectionProbes.push(r)};var oh=function(){function r(t,e,n,i,o){var a=this;i===void 0&&(i=!0),o===void 0&&(o=!1),this.name=t,this._viewMatrix=u.a.Identity(),this._target=u.e.Zero(),this._add=u.e.Zero(),this._invertYAxis=!1,this.position=u.e.Zero(),this._scene=n,this._scene.reflectionProbes||(this._scene.reflectionProbes=new Array),this._scene.reflectionProbes.push(this);var s=h.a.TEXTURETYPE_UNSIGNED_BYTE;if(o){var d=this._scene.getEngine().getCaps();d.textureHalfFloatRender?s=h.a.TEXTURETYPE_HALF_FLOAT:d.textureFloatRender&&(s=h.a.TEXTURETYPE_FLOAT)}this._renderTargetTexture=new sn(t,e,n,i,!0,s,!0),this._renderTargetTexture.onBeforeRenderObservable.add(function(p){switch(p){case 0:a._add.copyFromFloats(1,0,0);break;case 1:a._add.copyFromFloats(-1,0,0);break;case 2:a._add.copyFromFloats(0,a._invertYAxis?1:-1,0);break;case 3:a._add.copyFromFloats(0,a._invertYAxis?-1:1,0);break;case 4:a._add.copyFromFloats(0,0,1);break;case 5:a._add.copyFromFloats(0,0,-1)}a._attachedMesh&&a.position.copyFrom(a._attachedMesh.getAbsolutePosition()),a.position.addToRef(a._add,a._target),u.a.LookAtLHToRef(a.position,a._target,u.e.Up(),a._viewMatrix),n.activeCamera&&(a._projectionMatrix=u.a.PerspectiveFovLH(Math.PI/2,1,n.activeCamera.minZ,n.activeCamera.maxZ),n.setTransformMatrix(a._viewMatrix,a._projectionMatrix)),n._forcedViewPosition=a.position}),this._renderTargetTexture.onAfterUnbindObservable.add(function(){n._forcedViewPosition=null,n.updateTransformMatrix(!0)})}return Object.defineProperty(r.prototype,"samples",{get:function(){return this._renderTargetTexture.samples},set:function(t){this._renderTargetTexture.samples=t}
7311,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},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);t!==-1&&this._scene.reflectionProbes.splice(t,1),this._renderTargetTexture&&(this._renderTargetTexture.dispose(),this._renderTargetTexture=null)},r.prototype.toString=function(t){var e="Name: "+this.name;return t&&(e+=", position: "+this.position.toString(),this._attachedMesh&&(e+=", attached mesh: "+this._attachedMesh.name)),e},r.prototype.getClassName=function(){return"ReflectionProbe"},r.prototype.serialize=function(){var t=L.a.Serialize(this,this._renderTargetTexture.serialize());return t.isReflectionProbe=!0,t},r.Parse=function(t,e,n){var i=null;if(e.reflectionProbes)for(var o=0;o<e.reflectionProbes.length;o++){var a=e.reflectionProbes[o];if(a.name===t.name){i=a;break}}return(i=L.a.Parse(function(){return i||new r(t.name,t.renderTargetSize,e,t._generateMipMaps)},t,e,n)).cubeTexture._waitingRenderList=t.renderList,t._attachedMesh&&i.attachToMesh(e.getMeshByID(t._attachedMesh)),i},Object(c.c)([Object(L.k)()],r.prototype,"_attachedMesh",void 0),Object(c.c)([Object(L.o)()],r.prototype,"position",void 0),r}(),mm=!0,da=function(){function r(){}return r.LoaderInjectedPhysicsEngine=void 0,r}(),ah=function(r,t,e,n){for(var i=0,o=t.materials.length;i<o;i++){var a=t.materials[i];if(a.id===r)return Ht.a.Parse(a,e,n)}return null},gm=function(r,t,e){for(var n in t)if(r.name===t[n])return e.push(r.i
7311d),!0;return!(!r.parentId||e.indexOf(r.parentId)===-1)&&(e.push(r.id),!0)},Ir=function(r,t){return r+" of "+(t?t.file+" from "+t.name+" version: "+t.version+", exporter version: "+t.exporter_version:"unknown")},sh=function(r,t){var e=t;if(t._waitingData.lods){if(t._waitingData.lods.ids&&t._waitingData.lods.ids.length>0){var n=t._waitingData.lods.ids,i=e.isEnabled(!1);if(t._waitingData.lods.distances){var o=t._waitingData.lods.distances;if(o.length>=n.length){var a=o.length>n.length?o[o.length-1]:0;e.setEnabled(!1);for(var s=0;s<n.length;s++){var d=n[s],p=r.getMeshByID(d);p!=null&&e.addLODLevel(o[s],p)}a>0&&e.addLODLevel(a,null),i===!0&&e.setEnabled(!0)}else Ye.b.Warn("Invalid level of detail distances for "+t.name)}}t._waitingData.lods=null}},ch=function(r,t,e,n,i){i===void 0&&(i=!1);var o=new An(r),a="importScene has failed JSON parse";try{var s=JSON.parse(t);a="";var d,p,y=Ut.loggingLevel===Ut.DETAILED_LOGGING;if(s.environmentTexture!==void 0&&s.environmentTexture!==null){var P=s.isPBR===void 0||s.isPBR;if(s.environmentTextureType&&s.environmentTextureType==="BABYLON.HDRCubeTexture"){var O=s.environmentTextureSize?s.environmentTextureSize:128,U=new la((s.environmentTexture.match(/https?:\/\//g)?"":e)+s.environmentTexture,r,O,!0,!P);s.environmentTextureRotationY&&(U.rotationY=s.environmentTextureRotationY),r.environmentTexture=U}else if(Xn.a.EndsWith(s.environmentTexture,".env")){var F=new ni((s.environmentTexture.match(/https?:\/\//g)?"":e)+s.environmentTexture,r);s.environmentTextureRotationY&&(F.rotationY=s.environmentTextureRotationY),r.environmentTexture=F}else{var z=ni.CreateFromPrefilteredData((s.environmentTexture.match(/https?:\/\//g)?"":e)+s.environmentTexture,r);s.environmentTextureRotationY&&(z.rotationY=s.environmentTextureRotationY),r.environmentTexture=z}if(s.createDefaultSkybox===!0){var J=r.activeCamera!==void 0&&r.activeCamera!==null?(r.activeCamera.maxZ-r.activeCamera.minZ)/2:1e3,ie=s.skyboxBlurLevel||0;r.createDefaultSkybox(r.environmentTexture,P,J,ie)}o.environmentTexture=r.environmentTexture}if(s.environmentIntensity!==void 0&&s.environmentIntensity!==null&&(r.environmentIntensity=s.environmentIntensity),s.lights!==void 0&&s.lights!==null)for(d=0,p=s.lights.length;d<p;d++){var se=s.lights[d],ce=Ci.a.Parse(se,r);ce&&(o.lights.push(ce),a+=d===0?`
7312	Lights:`:"",a+=`
7313		`+ce.toString(y))}if(s.reflectionProbes!==void 0&&s.reflectionProbes!==null)for(d=0,p=s.reflectionProbes.length;d<p;d++){var ue=s.reflectionProbes[d],fe=oh.Parse(ue,r,e);fe&&(o.reflectionProbes.push(fe),a+=d===0?`
7314	Reflection Probes:`:"",a+=`
7315		`+fe.toString(y))}if(s.animations!==void 0&&s.animations!==null)for(d=0,p=s.animations.length;d<p;d++){var ve=s.animations[d],Te=R.a.GetClass("BABYLON.Animation");if(Te){var Oe=Te.Parse(ve);r.animations.push(Oe),o.animations.push(Oe),a+=d===0?`
7316	Animations:`:"",a+=`
7317		`+Oe.toString(y)}}if(s.materials!==void 0&&s.materials!==null)for(d=0,p=s.materials.length;d<p;d++){var Pe=s.materials[d],Ee=Ht.a.Parse(Pe,r,e);Ee&&(o.materials.push(Ee),a+=d===0?`
7318	Materials:`:"",a+=`
7319		`+Ee.toString(y),Ee.getActiveTextures().forEach(function(qt){o.textures.indexOf(qt)==-1&&o.textures.push(qt)}))}if(s.multiMaterials!==void 0&&s.multiMaterials!==null)for(d=0,p=s.multiMaterials.length;d<p;d++){var Se=s.multiMaterials[d],Le=ir.a.ParseMultiMaterial(Se,r);o.multiMaterials.push(Le),a+=d===0?`
7320	MultiMaterials:`:"",a+=`
7321		`+Le.toString(y),Le.getActiveTextures().forEach(function(qt){o.textures.indexOf(qt)==-1&&o.textures.push(qt)})}if(s.morphTargetManagers!==void 0&&s.morphTargetManagers!==null)for(var xe=0,Ne=s.morphTargetManagers;xe<Ne.length;xe++){var Ie=Ne[xe];o.morphTargetManagers.push(ua.Parse(Ie,r))}if(s.skeletons!==void 0&&s.skeletons!==null)for(d=0,p=s.skeletons.length;d<p;d++){var Fe=s.skeletons[d],Ke=Bo.Parse(Fe,r);o.skeletons.push(Ke),a+=d===0?`
7322	Skeletons:`:"",a+=`
7323		`+Ke.toString(y)}var nt=s.geometries;if(nt!=null){var rt=new Array,ut=nt.vertexData;if(ut!=null)for(d=0,p=ut.length;d<p;d++){var qe=ut[d];rt.push(qs.a.Parse(qe,r,e))}rt.forEach(function(qt){qt&&o.geometries.push(qt)})}if(s.transformNodes!==void 0&&s.transformNodes!==null)for(d=0,p=s.transformNodes.length;d<p;d++){var at=s.transformNodes[d],ot=Tr.a.Parse(at,r,e);o.transformNodes.push(ot)}if(s.meshes!==void 0&&s.meshes!==null)for(d=0,p=s.meshes.length;d<p;d++){var Je=s.meshes[d],dt=De.a.Parse(Je,r,e);if(o.meshes.push(dt),dt.hasInstances)for(var Ve=0,$e=dt.instances;Ve<$e.length;Ve++){var yt=$e[Ve];o.meshes.push(yt)}a+=d===0?`
7324	Meshes:`:"",a+=`
7325		`+dt.toString(y)}if(s.cameras!==void 0&&s.cameras!==null)for(d=0,p=s.cameras.length;d<p;d++){var Wt=s.cameras[d],Nt=gt.a.Parse(Wt,r);o.cameras.push(Nt),a+=d===0?`
7326	Cameras:`:"",a+=`
7327		`+Nt.toString(y)}if(s.postProcesses!==void 0&&s.postProcesses!==null)for(d=0,p=s.postProcesses.length;d<p;d++){var Qt=s.postProcesses[d],vt=_t.Parse(Qt,r,e);vt&&(o.postProcesses.push(vt),a+=d===0?`
7328Postprocesses:`:"",a+=`
7329		`+vt.toString())}if(s.animationGroups!==void 0&&s.animationGroups!==null)for(d=0,p=s.animationGroups.length;d<p;d++){var Jt=s.animationGroups[d],Xt=He.Parse(Jt,r);o.animationGroups.push(Xt),a+=d===0?`
7330	AnimationGroups:`:"",a+=`
7331		`+Xt.toString(y)}for(d=0,p=r.cameras.length;d<p;d++)(Nt=r.cameras[d])._waitingParentId&&(Nt.parent=r.getLastEntryByID(Nt._waitingParentId),Nt._waitingParentId=null);for(d=0,p=r.lights.length;d<p;d++){var zt=r.lights[d];zt&&zt._waitingParentId&&(zt.parent=r.getLastEntryByID(zt._waitingParentId),zt._waitingParentId=null)}for(d=0,p=r.transformNodes.length;d<p;d++){var Yt=r.transformNodes[d];Yt._waitingParentId&&(Yt.parent=r.getLastEntryByID(Yt._waitingParentId),Yt._waitingParentId=null)}for(d=0,p=r.meshes.length;d<p;d++)(dt=r.meshes[d])._waitingParentId&&(dt.parent=r.getLastEntryByID(dt._waitingParentId),dt._waitingParentId=null),dt._waitingData.lods&&sh(r,dt);for(d=0,p=r.skeletons.length;d<p;d++)(Ke=r.skeletons[d])._hasWaitingData&&(Ke.bones!=null&&Ke.bones.forEach(function(qt){if(qt._waitingTransformNodeId){var si=r.getLastEntryByID(qt._waitingTransformNodeId);si&&qt.linkTransformNode(si),qt._waitingTransformNodeId=null}}),Ke._waitingOverrideMeshId&&(Ke.overrideMesh=r.getMeshByID(Ke._waitingOverrideMeshId),Ke._waitingOverrideMeshId=null),Ke._hasWaitingData=null);for(d=0,p=r.meshes.length;d<p;d++){var Et=r.meshes[d];Et._waitingData.freezeWorldMatrix?(Et.freezeWorldMatrix(),Et._waitingData.freezeWorldMatrix=null):Et.computeWorldMatrix(!0)}for(d=0,p=r.lights.length;d<p;d++){var Mt=r.lights[d];if(Mt._excludedMeshesIds.length>0){for(var $t=0;$t<Mt._excludedMeshesIds.length;$t++){var Mn=r.getMeshByID(Mt._excludedMeshesIds[$t]);Mn&&Mt.excludedMeshes.push(Mn)}Mt._excludedMeshesIds=[]}if(Mt._includedOnlyMeshesIds.length>0){for(var Bn=0;Bn<Mt._includedOnlyMeshesIds.length;Bn++){var qn=r.getMeshByID(Mt._includedOnlyMeshesIds[Bn]);qn&&Mt.includedOnlyMeshes.push(qn)}Mt._includedOnlyMeshesIds=[]}}for(B.a.Parse(s,r,o,e),d=0,p=r.meshes.length;d<p;d++)(dt=r.meshes[d])._waitingData.actions&&(pe.Parse(dt._waitingData.actions,dt,r),dt._waitingData.actions=null);s.actions!==void 0&&s.actions!==null&&pe.Parse(s.actions,null,r)}catch(qt){var In=Ir("loadAssets",s?s.producer:"Unknown")+a;if(!n)throw l.a.Log(In),qt;n(In,qt)}finally{i||o.removeAllFromScene(),a!==null&&Ut.loggingLevel!==Ut.NO_LOGGING&&l.a.Log(Ir("loadAssets",s?s.producer:"Unknown")+(Ut.loggingLevel!==Ut.MINIMAL_LOGGING?a:""))}return o};Ut.RegisterPlugin({name:"babylon.js",extensions:".babylon",canDirectLoad:function(r){return r.indexOf("babylon")!==-1},importMesh:function(r,t,e,n,i,o,a,s){var d="importMesh has failed JSON parse";try{var p=JSON.parse(e);d="";var y=Ut.loggingLevel===Ut.DETAILED_LOGGING;r?Array.isArray(r)||(r=[r]):r=null;var P=new Array;if(p.meshes!==void 0&&p.meshes!==null){var O,U,F,z=[],J=[];for(O=0,U=p.meshes.length;O<U;O++){var ie=p.meshes[O];if(r===null||gm(ie,r,P)){if(r!==null&&delete r[r.indexOf(ie.name)],ie.geometryId!==void 0&&ie.geometryId!==null&&p.geometries!==void 0&&p.geometries!==null){var se=!1;["boxes","spheres","cylinders","toruses","grounds","planes","torusKnots","vertexData"].forEach(function(ot){se!==!0&&p.geometries[ot]&&Array.isArray(p.geometries[ot])&&p.geometries[ot].forEach(function(Je){if(Je.id===ie.geometryId){switch(ot){case"vertexData":qs.a.Parse(Je,t,n)}se=!0}})}),se===!1&&l.a.Warn("Geometry not found for mesh "+ie.id)}if(ie.materialId){var ce=J.indexOf(ie.materialId)!==-1;if(ce===!1&&p.multiMaterials!==void 0&&p.multiMaterials!==null)for(var ue=0,fe=p.multiMaterials.length;ue<fe;ue++){var ve=p.multiMaterials[ue];if(ve.id===ie.materialId){for(var Te=0,Oe=ve.materials.length;Te<Oe;Te++){var Pe,Ee=ve.materials[Te];J.push(Ee),(Pe=ah(Ee,p,t,n))&&(d+=`
7332	Material `+Pe.toString(y))}J.push(ve.id);var Se=ir.a.ParseMultiMaterial(ve,t);Se&&(ce=!0,d+=`
7333	Multi-Material `+Se.toString(y));break}}ce===!1&&(J.push(ie.materialId),(Pe=ah(ie.materialId,p,t,n))?d+=`
7334	Material `+Pe.toString(y):l.a.Warn("Material not found for mesh "+ie.id))}if(ie.skeletonId>-1&&p.skeletons!==void 0&&p.skeletons!==null&&!(z.indexOf(ie.skeletonId)>-1))for(var Le=0,xe=p.skeletons.length;Le<xe;Le++){var Ne=p.skeletons[Le];if(Ne.id===ie.skeletonId){var Ie=Bo.Parse(Ne,t);a.push(Ie),z.push(Ne.id),d+=`
7335	Skeleton `+Ie.toString(y)}}if(p.morphTargetManagers!==void 0&&p.morphTargetManagers!==null)for(var Fe=0,Ke=p.morphTargetManagers;Fe<Ke.length;Fe++){var nt=Ke[Fe];ua.Parse(nt,t)}var rt=De.a.Parse(ie,t,n);i.push(rt),d+=`
7336	Mesh `+rt.toString(y)}}for(O=0,U=t.meshes.length;O<U;O++)(F=t.meshes[O])._waitingParentId&&(F.parent=t.getLastEntryByID(F._waitingParentId),F._waitingParentId=null),F._waitingData.lods&&sh(t,F);for(O=0,U=t.skeletons.length;O<U;
7336O++)(Ie=t.skeletons[O])._hasWaitingData&&(Ie.bones!=null&&Ie.bones.forEach(function(ot){if(ot._waitingTransformNodeId){var Je=t.getLastEntryByID(ot._waitingTransformNodeId);Je&&ot.linkTransformNode(Je),ot._waitingTransformNodeId=null}}),Ie._waitingOverrideMeshId&&(Ie.overrideMesh=t.getMeshByID(Ie._waitingOverrideMeshId),Ie._waitingOverrideMeshId=null),Ie._hasWaitingData=null);for(O=0,U=t.meshes.length;O<U;O++)(F=t.meshes[O])._waitingData.freezeWorldMatrix?(F.freezeWorldMatrix(),F._waitingData.freezeWorldMatrix=null):F.computeWorldMatrix(!0)}if(p.particleSystems!==void 0&&p.particleSystems!==null){var ut=B.a.GetIndividualParser(st.a.NAME_PARTICLESYSTEM);if(ut)for(O=0,U=p.particleSystems.length;O<U;O++){var qe=p.particleSystems[O];P.indexOf(qe.emitterId)!==-1&&o.push(ut(qe,t,n))}}return!0}catch(ot){var at=Ir("importMesh",p?p.producer:"Unknown")+d;if(!s)throw l.a.Log(at),ot;s(at,ot)}finally{d!==null&&Ut.loggingLevel!==Ut.NO_LOGGING&&l.a.Log(Ir("importMesh",p?p.producer:"Unknown")+(Ut.loggingLevel!==Ut.MINIMAL_LOGGING?d:""))}return!1},load:function(r,t,e,n){var i="importScene has failed JSON parse";try{var o=JSON.parse(t);if(i="",o.useDelayedTextureLoading!==void 0&&o.useDelayedTextureLoading!==null&&(r.useDelayedTextureLoading=o.useDelayedTextureLoading&&!Ut.ForceFullSceneLoadingForIncremental),o.autoClear!==void 0&&o.autoClear!==null&&(r.autoClear=o.autoClear),o.clearColor!==void 0&&o.clearColor!==null&&(r.clearColor=M.b.FromArray(o.clearColor)),o.ambientColor!==void 0&&o.ambientColor!==null&&(r.ambientColor=M.a.FromArray(o.ambientColor)),o.gravity!==void 0&&o.gravity!==null&&(r.gravity=u.e.FromArray(o.gravity)),o.fogMode&&o.fogMode!==0)switch(r.fogMode=o.fogMode,r.fogColor=M.a.FromArray(o.fogColor),r.fogStart=o.fogStart,r.fogEnd=o.fogEnd,r.fogDensity=o.fogDensity,i+="	Fog mode for scene:  ",r.fogMode){case 1:i+=`exp
7337`;break;case 2:i+=`exp2
7338`;break;case 3:i+=`linear
7339`}if(o.physicsEnabled){var a;o.physicsEngine==="cannon"?a=new $s(void 0,void 0,da.LoaderInjectedPhysicsEngine):o.physicsEngine==="oimo"?a=new ih(void 0,da.LoaderInjectedPhysicsEngine):o.physicsEngine==="ammo"&&(a=new rh(void 0,da.LoaderInjectedPhysicsEngine,void 0)),i="	Physics engine "+(o.physicsEngine?o.physicsEngine:"oimo")+` enabled
7340`;var s=o.physicsGravity?u.e.FromArray(o.physicsGravity):null;r.enablePhysics(s,a)}return o.metadata!==void 0&&o.metadata!==null&&(r.metadata=o.metadata),o.collisionsEnabled!==void 0&&o.collisionsEnabled!==null&&(r.collisionsEnabled=o.collisionsEnabled),!!ch(r,t,e,n,!0)&&(o.autoAnimate&&r.beginAnimation(r,o.autoAnimateFrom,o.autoAnimateTo,o.autoAnimateLoop,o.autoAnimateSpeed||1),o.activeCameraID!==void 0&&o.activeCameraID!==null&&r.setActiveCameraByID(o.activeCameraID),!0)}catch(p){var d=Ir("importScene",o?o.producer:"Unknown")+i;if(!n)throw l.a.Log(d),p;n(d,p)}finally{i!==null&&Ut.loggingLevel!==Ut.NO_LOGGING&&l.a.Log(Ir("importScene",o?o.producer:"Unknown")+(Ut.loggingLevel!==Ut.MINIMAL_LOGGING?i:""))}return!1},loadAssetContainer:function(r,t,e,n){return ch(r,t,e,n)}});var vm=f(121),lh=function(){function r(t){t===void 0&&(t={}),this._isEnabled=!0,this.bias=t.bias===void 0?0:t.bias,this.power=t.power===void 0?1:t.power,this.leftColor=t.leftColor||M.a.White(),this.rightColor=t.rightColor||M.a.Black(),t.isEnabled===!1&&(this.isEnabled=!1)}return Object.defineProperty(r.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(t){this._isEnabled!==t&&(this._isEnabled=t,Ue.a.MarkAllMaterialsAsDirty(h.a.MATERIAL_FresnelDirtyFlag|h.a.MATERIAL_MiscDirtyFlag))},enumerable:!1,configurable:!0}),r.prototype.clone=function(){var t=new r;return de.a.DeepCopy(this,t),t},r.prototype.equals=function(t){return t&&this.bias===t.bias&&this.power===t.power&&this.leftColor.equals(t.leftColor)&&this.rightColor.equals(t.rightColor)&&this.isEnabled===t.isEnabled},r.prototype.serialize=function(){return{isEnabled:this.isEnabled,leftColor:this.leftColor.asArray(),rightColor:this.rightColor.asArray(),bias:this.bias,power:this.power}},r.Parse=function(t){return new r({isEnabled:t.isEnabled,leftColor:M.a.FromArray(t.leftColor),rightColor:M.a.FromArray(t.rightColor),bias:t.bias,power:t.power||1})},r}();L.a._FresnelParametersParser=lh.Parse;var uh=f(119),ec=function(r){function t(e,n){var i=r.call(this,e,n)||this;return i.maxSimultaneousLights=4,i.disableLighting=!1,i.invertNormalMapX=!1,i.invertNormalMapY=!1,i.emissiveColor=new M.a(0,0,0),i.occlusionStrength=1,i.useLightmapAsShadowmap=!1,i._useAlphaFromAlbedoTexture=!0,i._useAmbientInGrayScale=!0,i}return Object(c.d)(t,r),Object.defineProperty(t.prototype,"doubleSided",{get:function(){return this._twoSidedLighting},set:function(e){this._twoSidedLighting!==e&&(this._twoSidedLighting=e,this.backFaceCulling=!e,this._markAllSubMeshesAsTexturesDirty())}
7340,enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"PBRBaseSimpleMaterial"},Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),Object(c.c)([Object(L.m)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty","_reflectionTexture")],t.prototype,"environmentTexture",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapX",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapY",void 0),Object(c.c)([Object(L.m)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty","_bumpTexture")],t.prototype,"normalTexture",void 0),Object(c.c)([Object(L.e)("emissive"),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveColor",void 0),Object(c.c)([Object(L.m)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveTexture",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty","_ambientTextureStrength")],t.prototype,"occlusionStrength",void 0),Object(c.c)([Object(L.m)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty","_ambientTexture")],t.prototype,"occlusionTexture",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty","_alphaCutOff")],t.prototype,"alphaCutOff",void 0),Object(c.c)([Object(L.c)()],t.prototype,"doubleSided",null),Object(c.c)([Object(L.m)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty",null)],t.prototype,"lightmapTexture",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLightmapAsShadowmap",void 0),t}(pn),hh=function(r){function t(e,n){var i=r.call(this,e,n)||this;return i._useRoughnessFromMetallicTextureAlpha=!1,i._useRoughnessFromMetallicTextureGreen=!0,i._useMetallnessFromMetallicTextureBlue=!0,i.metallic=1,i.roughness=1,i}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"PBRMetallicRoughnessMaterial"},t.prototype.clone=function(e){var n=this,i=L.a.Clone(function(){return new t(e,n.getScene())},this);return i.id=e,i.name=e,this.clearCoat.copyTo(i.clearCoat),this.anisotropy.copyTo(i.anisotropy),this.brdf.copyTo(i.brdf),this.sheen.copyTo(i.sheen),this.subSurface.copyTo(i.subSurface),i},t.prototype.serialize=function(){var e=L.a.Serialize(this);return e.customType="BABYLON.PBRMetallicRoughnessMaterial",e.clearCoat=this.clearCoat.serialize(),e.anisotropy=this.anisotropy.serialize(),e.brdf=this.brdf.serialize(),e.sheen=this.sheen.serialize(),e.subSurface=this.subSurface.serialize(),e},t.Parse=function(e,n,i){var o=L.a.Parse(function(){return new t(e.name,n)},e,n,i);return e.clearCoat&&o.clearCoat.parse(e.clearCoat,n,i),e.anisotropy&&o.anisotropy.parse(e.anisotropy,n,i),e.brdf&&o.brdf.parse(e.brdf,n,i),e.sheen&&o.sheen.parse(e.sheen,n,i),e.subSurface&&o.subSurface.parse(e.subSurface,n,i),o},Object(c.c)([Object(L.e)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty","_albedoColor")],t.prototype,"baseColor",void 0),Object(c.c)([Object(L.m)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty","_albedoTexture")],t.prototype,"baseTexture",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallic",void 0),Object(c.c)([Object(L.c)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),Object(c.c)([Object(L.m)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty","_metallicTexture")],t.prototype,"metallicRoughnessTexture",void 0),t}(ec);R.a.RegisteredTypes["BABYLON.PBRMetallicRoughnessMaterial"]=hh;var dh=function(r){function t(e,n){var i=r.call(this,e,n)||this;return i._useMicroSurfaceFromReflectivityMapAlpha=!0,i}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"PBRSpecularGlossinessMaterial"},t.prototype.clone=function(e){var n=this,i=L.a.Clone(function(){return new t(e,n.getScene())},this);return i.id=e,i.name=e,this.clearCoat.copyTo(i.clearCoat),this.anisotropy.copyTo(i.anisotropy),this.brdf.copyTo(i.brdf),this.sheen.copyTo(i.sheen),this.subSurface.copyTo(i.subSurface),i},t.prototype.serialize=function(){var e=L.a.Serialize(this);return e.customType="BABYLON.PBRSpecularGlossinessMaterial",e.clearCoat=this.clearCoat.serialize(),e.anisotropy=this.anisotropy.serialize(),e.brdf=this.brdf.serialize(),e.sheen=this.sheen.serialize(),e.subSurface=this.subSurface.serialize(),e},t.Parse=function(e,n,i){var o=L.a.Parse(function(){return new t(e.name,n)},e,n,i);return e.clearCoat&&o.clearCoat.parse(e.clearCoat,n,i),e.anisotropy&&o.anisotropy.parse(e.anisotropy,n,i),e.brdf&&o.brdf.parse(e.brdf,n,i),e.sheen&&o.sheen.parse(e.sheen,n,i),e.subSurface&&o.subSurface.parse(e.subSurface,n,i),o},Object(c.c)([Object(L.e)("diffuse"),Object(L.b)("_markAllSubMeshesAsTexturesDirty","_albedoColor")],t.prototype,"diffuseColor",void 0),Object(c.c)([Object(L.m)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty","_albedoTexture")],t.prototype,"diffuseTexture",void 0),Object(c.c)([Object(L.e)("specular"),Object(L.b)("_markAllSubMeshesAsTexturesDirty","_reflectivityColor")],t.prototype,"specularColor",void 0),Object(c.c)([Object(L.c)(),Ob
7340ject(L.b)("_markAllSubMeshesAsTexturesDirty","_microSurface")],t.prototype,"glossiness",void 0),Object(c.c)([Object(L.m)(),Object(L.b)("_markAllSubMeshesAsTexturesDirty","_reflectivityTexture")],t.prototype,"specularGlossinessTexture",void 0),t}(ec);R.a.RegisteredTypes["BABYLON.PBRSpecularGlossinessMaterial"]=dh;var fa=f(73),fh=function(r){function t(e,n,i){i===void 0&&(i=null);var o=r.call(this,n)||this;if(!e)return o;if(o._textureMatrix=u.a.Identity(),o.name=e,o.url=e,o._onLoad=i,o._texture=o._getFromCache(e,!0),o._texture)o._triggerOnLoad();else{var a=o.getScene();a&&a.useDelayedTextureLoading?o.delayLoadState=h.a.DELAYLOADSTATE_NOTLOADED:o.loadTexture()}return o}return Object(c.d)(t,r),t.prototype._triggerOnLoad=function(){this._onLoad&&this._onLoad()},t.prototype.getTextureMatrix=function(){return this._textureMatrix},t.prototype.load3dlTexture=function(){var e,n=this,i=this._getEngine();e=i.webGLVersion===1?i.createRawTexture(null,1,1,h.a.TEXTUREFORMAT_RGBA,!1,!1,h.a.TEXTURE_BILINEAR_SAMPLINGMODE,null,h.a.TEXTURETYPE_UNSIGNED_INT):i.createRawTexture3D(null,1,1,1,h.a.TEXTUREFORMAT_RGBA,!1,!1,h.a.TEXTURE_BILINEAR_SAMPLINGMODE,null,h.a.TEXTURETYPE_UNSIGNED_INT),this._texture=e,this._texture.isReady=!1,this.isCube=!1,this.is3D=i.webGLVersion>1,this.wrapU=h.a.TEXTURE_CLAMP_ADDRESSMODE,this.wrapV=h.a.TEXTURE_CLAMP_ADDRESSMODE,this.wrapR=h.a.TEXTURE_CLAMP_ADDRESSMODE,this.anisotropicFilteringLevel=1;var o=function(s){if(typeof s=="string"){for(var d,p=null,y=null,P=s.split(`
7341`),O=0,U=0,F=0,z=0,J=0,ie=0;ie<P.length;ie++)if(d=P[ie],t._noneEmptyLineRegex.test(d)&&d.indexOf("#")!==0){var se=d.split(" ");if(O!==0){if(O!=0){var ce=Math.max(parseInt(se[0]),0),ue=Math.max(parseInt(se[1]),0),fe=Math.max(parseInt(se[2]),0);J=Math.max(ce,J),J=Math.max(ue,J),J=Math.max(fe,J);var ve=4*(U+z*O+F*O*O);y&&(y[ve+0]=ce,y[ve+1]=ue,y[ve+2]=fe),++F%O==0&&(F=0,++z%O==0&&(U++,z=0))}}else O=se.length,p=new Uint8Array(O*O*O*4),y=new Float32Array(O*O*O*4)}if(y&&p)for(ie=0;ie<y.length;ie++)if(ie>0&&(ie+1)%4==0)p[ie]=255;else{var Te=y[ie];p[ie]=Te/J*255}e.is3D?(e.updateSize(O,O,O),i.updateRawTexture3D(e,p,h.a.TEXTUREFORMAT_RGBA,!1)):(e.updateSize(O*O,O),i.updateRawTexture(e,p,h.a.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===h.a.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=h.a.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}(zn.a);R.a.RegisteredTypes["BABYLON.ColorGradingTexture"]=fh;var ph=function(r){function t(e,n,i,o,a,s,d){o===void 0&&(o=!1),a===void 0&&(a=!0),s===void 0&&(s=null),d===void 0&&(d=null);var p=r.call(this,n)||this;if(p._onLoad=null,p._onError=null,!e)throw new Error("Image url is not set");return p._coordinatesMode=we.a.CUBIC_MODE,p.name=e,p.url=e,p._size=i,p._noMipmap=o,p.gammaSpace=a,p._onLoad=s,p._onError=d,p.hasAlpha=!1,p.isCube=!0,p._texture=p._getFromCache(e,p._noMipmap),p._texture?s&&(p._texture.isReady?Ye.b.SetImmediate(function(){return s()}):p._texture.onLoadedObservable.add(s)):n.useDelayedTextureLoading?p.delayLoadState=h.a.DELAYLOADSTATE_NOTLOADED:p.loadImage(p.loadTexture.bind(p),p._onError),p}return Object(c.d)(t,r),t.prototype.loadImage=function(e,n){var i=this,o=document.createElement("canvas"),a=new Image;a.addEventListener("load",function(){i._width=a.width,i._height=a.height,o.width=i._width,o.height=i._height;var s=o.getContext("2d");s.drawImage(a,0,0);var d=s.getImageData(0,0,a.width,a.height);i._buffer=d.data.buffer,o.remove(),e()}),a.addEventListener("error",function(s){n&&n(i.getClassName()+" could not be loaded",s)}),a.src=this.url},t.prototype.loadTexture=function(){var e=this,n=this.getScene();n&&(this._texture=n.getEngine().createRawCubeTextureFromUrl(this.url,n,this._size,h.a.TEXTUREFORMAT_RGB,n.getEngine().getCaps().textureFloat?h.a.TEXTURETYPE_FLOAT:h.a.TEXTURETYPE_UNSIGNED_INTEGER,this._noMipmap,function(){for(var i=e.getFloat32ArrayFromArrayBuffer(e._buffer),o=Zs.ConvertPanoramaToCubemap(i,e._width,e._height,e._size),a=[],s=0;s<6;s++){var d=o[t._FacesMapping[s]];a.push(d)}return a},null,this._onLoad,this._onError))},t.prototype.getFloat32ArrayFromArrayBuffer=function(e){for(var n=new DataView(e),i=new Float32Array(3*e.byteLength/4),o=0,a=0;a<e.byteLength;a++)(a+1)%4!=0&&(i[o++]=n.getUint8(a)/255);return i},t.prototype.getClassName=function(){return"EquiRectangularCubeTexture"},t.prototype.clone=function(){var e=this.getScene();if(!e)return this;var n=new t(this.url,e,this._size,this._noMipmap,this.gammaSpace);return n.level=this.level,n.wrapU=this.wrapU,n.wrapV=this.wrapV,n.coordinatesIndex=this.coordinatesIndex,n.coordinatesMode=this.coordinatesMode,n},t._FacesMapping=["right","left","up","down","front","back"],t}(zn.a),bm=function(r){function t(e,n,i){var o=r.call(this,i.scene||i.engine)||this;return n&&(i.engine||i.scene)&&(i=Object(c.a)(Object(c.a)({},t.DefaultOptions),i),o._generateMipMaps=i.generateMipMaps,o._samplingMode=i.samplingMode,o._textureMatrix=u.a.Identity(),o.name=e,o.element=n,o._isVideo=n instanceof HTMLVideoElement,o.anisotropicFilteringLevel=1,o._createInternalTexture()),o}return Object(c.d)(t,r),t.prototype._createInternalTexture=function(){var e=0,n=0;this._isVideo?(e=this.element.videoWidth,n=this.element.videoHeight):(e=this.element.width,n=this.element.height);var i=this._getEngine();i&&(this._texture=i.createDynamicTexture(e,n,this._generateMipMaps,this._samplingMode)),this.update()},t.prototype.getTextureMatrix=function(){return this._textureMatrix},t.prototype.update=function(e){e===void 0&&(e=null);var n=this._getEngine();if(this._texture!=null&&n!=null)if(this._isVideo){var i=this.element;if(i.readyState<i.HAVE_CURRENT_DATA)return;n.updateVideoTexture(this._texture,i,e===null||e)}else{var o=this.element;n.updateDynamicTexture(this._texture,o,e===null||e,!1)}},t.DefaultOptions={generateMipMaps:!1,samplingMode:h.a.TEXTURE_BILINEAR_SAMPLINGMODE,engine:null,scene:null},t}(zn.a),pa=function(){function r(){}return r.GetTGAHeader=function(t){var e=0;return{id_length:t[e++],colormap_type:t[e++],image_type:t[e++],colormap_index:t[e++]|t[e++]<<8,colormap_length:t[e++]|t[e++]<<8,colormap_size:t[e++],origin:[t[e++]|t[e++]<<8,t[e++]|t[e++]<<8],width:t[e++]|t[e++]<<8,height:t[e++]|t[e++]<<8,pixel_size:t[e++],flags:t[e++]}},r.UploadContent=function(t,e){if(e.length<19)l.a.Error("Unable to load TGA file - Not enough data to contain header");else{var n=18,i=r.GetTGAHeader(e);if(i.id_length+n>e.length)l.a.Error("Unable to load TGA file - Not enough data");else{n+=i.id_length;var o,a=!1,s=!1,d=!1;switch(i.image_type){case r._TYPE_RLE_INDEXED:a=!0;case r._TYPE_INDEXED:s=!0;break;case r._TYPE_RLE_RGB:a=!0;case r._TYPE_RGB:break;
7341case r._TYPE_RLE_GREY:a=!0;case r._TYPE_GREY:d=!0}var p,y,P,O,U,F,z,J=i.pixel_size>>3,ie=i.width*i.height*J;if(s&&(p=e.subarray(n,n+=i.colormap_length*(i.colormap_size>>3))),a){var se,ce,ue;o=new Uint8Array(ie);for(var fe=0,ve=new Uint8Array(J);n<ie&&fe<ie;)if(ce=1+(127&(se=e[n++])),128&se){for(ue=0;ue<J;++ue)ve[ue]=e[n++];for(ue=0;ue<ce;++ue)o.set(ve,fe+ue*J);fe+=J*ce}else{for(ce*=J,ue=0;ue<ce;++ue)o[fe+ue]=e[n++];fe+=ce}}else o=e.subarray(n,n+=s?i.width*i.height:ie);switch((i.flags&r._ORIGIN_MASK)>>r._ORIGIN_SHIFT){default:case r._ORIGIN_UL:y=0,O=1,z=i.width,P=0,U=1,F=i.height;break;case r._ORIGIN_BL:y=0,O=1,z=i.width,P=i.height-1,U=-1,F=-1;break;case r._ORIGIN_UR:y=i.width-1,O=-1,z=-1,P=0,U=1,F=i.height;break;case r._ORIGIN_BR:y=i.width-1,O=-1,z=-1,P=i.height-1,U=-1,F=-1}var Te=r["_getImageData"+(d?"Grey":"")+i.pixel_size+"bits"](i,p,o,P,U,F,y,O,z);t.getEngine()._uploadDataToTextureDirectly(t,Te)}}},r._getImageData8bits=function(t,e,n,i,o,a,s,d,p){var y,P,O,U=n,F=e,z=t.width,J=t.height,ie=0,se=new Uint8Array(z*J*4);for(O=i;O!==a;O+=o)for(P=s;P!==p;P+=d,ie++)y=U[ie],se[4*(P+z*O)+3]=255,se[4*(P+z*O)+2]=F[3*y+0],se[4*(P+z*O)+1]=F[3*y+1],se[4*(P+z*O)+0]=F[3*y+2];return se},r._getImageData16bits=function(t,e,n,i,o,a,s,d,p){var y,P,O,U=n,F=t.width,z=t.height,J=0,ie=new Uint8Array(F*z*4);for(O=i;O!==a;O+=o)for(P=s;P!==p;P+=d,J+=2){var se=255*((31744&(y=U[J+0]+(U[J+1]<<8)))>>10)/31|0,ce=255*((992&y)>>5)/31|0,ue=255*(31&y)/31|0;ie[4*(P+F*O)+0]=se,ie[4*(P+F*O)+1]=ce,ie[4*(P+F*O)+2]=ue,ie[4*(P+F*O)+3]=32768&y?0:255}return ie},r._getImageData24bits=function(t,e,n,i,o,a,s,d,p){var y,P,O=n,U=t.width,F=t.height,z=0,J=new Uint8Array(U*F*4);for(P=i;P!==a;P+=o)for(y=s;y!==p;y+=d,z+=3)J[4*(y+U*P)+3]=255,J[4*(y+U*P)+2]=O[z+0],J[4*(y+U*P)+1]=O[z+1],J[4*(y+U*P)+0]=O[z+2];return J},r._getImageData32bits=function(t,e,n,i,o,a,s,d,p){var y,P,O=n,U=t.width,F=t.height,z=0,J=new Uint8Array(U*F*4);for(P=i;P!==a;P+=o)for(y=s;y!==p;y+=d,z+=4)J[4*(y+U*P)+2]=O[z+0],J[4*(y+U*P)+1]=O[z+1],J[4*(y+U*P)+0]=O[z+2],J[4*(y+U*P)+3]=O[z+3];return J},r._getImageDataGrey8bits=function(t,e,n,i,o,a,s,d,p){var y,P,O,U=n,F=t.width,z=t.height,J=0,ie=new Uint8Array(F*z*4);for(O=i;O!==a;O+=o)for(P=s;P!==p;P+=d,J++)y=U[J],ie[4*(P+F*O)+0]=y,ie[4*(P+F*O)+1]=y,ie[4*(P+F*O)+2]=y,ie[4*(P+F*O)+3]=255;return ie},r._getImageDataGrey16bits=function(t,e,n,i,o,a,s,d,p){var y,P,O=n,U=t.width,F=t.height,z=0,J=new Uint8Array(U*F*4);for(P=i;P!==a;P+=o)for(y=s;y!==p;y+=d,z+=2)J[4*(y+U*P)+0]=O[z+0],J[4*(y+U*P)+1]=O[z+0],J[4*(y+U*P)+2]=O[z+0],J[4*(y+U*P)+3]=O[z+1];return J},r._TYPE_INDEXED=1,r._TYPE_RGB=2,r._TYPE_GREY=3,r._TYPE_RLE_INDEXED=9,r._TYPE_RLE_RGB=10,r._TYPE_RLE_GREY=11,r._ORIGIN_MASK=48,r._ORIGIN_SHIFT=4,r._ORIGIN_BL=0,r._ORIGIN_BR=1,r._ORIGIN_UL=2,r._ORIGIN_UR=3,r}(),_h=function(){function r(){this.supportCascades=!1}return r.prototype.canLoad=function(t){return Xn.a.EndsWith(t,".tga")},r.prototype.loadCubeData=function(t,e,n,i,o){throw".env not supported in Cube."},r.prototype.loadData=function(t,e,n){var i=new Uint8Array(t.buffer,t.byteOffset,t.byteLength),o=pa.GetTGAHeader(i);n(o.width,o.height,e.generateMipMaps,!1,function(){pa.UploadContent(e,i)})},r}();Ue.a._TextureLoaders.push(new _h);var po,ym=function(){};(function(r){r[r.cTFETC1=0]="cTFETC1",r[r.cTFBC1=1]="cTFBC1",r[r.cTFBC4=2]="cTFBC4",r[r.cTFPVRTC1_4_OPAQUE_ONLY=3]="cTFPVRTC1_4_OPAQUE_ONLY",r[r.cTFBC7_M6_OPAQUE_ONLY=4]="cTFBC7_M6_OPAQUE_ONLY",r[r.cTFETC2=5]="cTFETC2",r[r.cTFBC3=6]="cTFBC3",r[r.cTFBC5=7]="cTFBC5"})(po||(po={}));var _o=function(){function r(){}return r.GetInternalFormatFromBasisFormat=function(t){if(t===po.cTFETC1)return 36196;if(t===po.cTFBC1)return 33776;if(t===po.cTFBC3)return 33779;throw"The chosen Basis transcoder format is not currently supported"},r._CreateWorkerAsync=function(){var t=this;return this._WorkerPromise||(this._WorkerPromise=new Promise(function(e){t._Worker?e(t._Worker):Ye.b.LoadFileAsync(r.WasmModuleURL).then(function(n){var i=URL.createObjectURL(new Blob(["("+Tm+")()"],{type:"application/javascript"}));t._Worker=new Worker(i);var o=function(a){a.data.action==="init"&&(t._Worker.removeEventListener("message",o),e(t._Worker))};t._Worker.addEventListener("message",o),t._Worker.postMessage({action:"init",url:r.JSModuleURL,wasmBinary:n})})})),this._WorkerPromise},r.TranscodeAsync=function(t,e){var n=this,i=t instanceof ArrayBuffer?new Uint8Array(t):t;return new Promise(function(o,a){n._CreateWorkerAsync().then(function(){var s=n._actionId++,d=function(y){y.data.action==="transcode"&&y.data.id===s&&(n._Worker.removeEventListener("message",d),y.data.success?o(y.data):a("Transcode is not supported on this device"))};n._Worker.addEventListener("message",d);var p=new Uint8Array(i.byteLength);p.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength)),n._Worker.postMessage({action:"transcode",id:s,imageData:p,config:e,ignoreSupportedFormats:n._IgnoreSupportedFormats},[p.buffer])})})},r.LoadTextureFromTranscodeResult=function(t,e){for(var n,i=t.getEngine(),o=function(){if(n=e.fileInfo.images[a].levels[0],t._invertVScale=t.invertY,e.format===-1)if(t.type=h.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5,t.format=h.a.TEXTUREFORMAT_RGB,i.webGLVersion<2&&($.a.Log2(n.width)%1!=0||$.a.Log2(n.height)%1!=0)){var s=new xt.a(i,xt.b.Temp);t._invertVScale=t.invertY,s.type=h.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5,s.format=h.a.TEXTUREFORMAT_RGB,s.width=n.width+3&-4,
7341s.height=n.height+3&-4,i._bindTextureDirectly(i._gl.TEXTURE_2D,s,!0),i._uploadDataToTextureDirectly(s,n.transcodedPixels,a,0,h.a.TEXTUREFORMAT_RGB,!0),i._rescaleTexture(s,t,i.scenes[0],i._getInternalFormat(h.a.TEXTUREFORMAT_RGB),function(){i._releaseTexture(s),i._bindTextureDirectly(i._gl.TEXTURE_2D,t,!0)})}else t._invertVScale=!t.invertY,t.width=n.width+3&-4,t.height=n.height+3&-4,i._uploadDataToTextureDirectly(t,n.transcodedPixels,a,0,h.a.TEXTUREFORMAT_RGB,!0);else t.width=n.width,t.height=n.height,e.fileInfo.images[a].levels.forEach(function(d,p){i._uploadCompressedDataToTextureDirectly(t,r.GetInternalFormatFromBasisFormat(e.format),d.width,d.height,d.transcodedPixels,a,p)}),i.webGLVersion<2&&($.a.Log2(t.width)%1!=0||$.a.Log2(t.height)%1!=0)&&(Ye.b.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."),t._cachedWrapU=we.a.CLAMP_ADDRESSMODE,t._cachedWrapV=we.a.CLAMP_ADDRESSMODE)},a=0;a<e.fileInfo.images.length;a++)o()},r._IgnoreSupportedFormats=!1,r.JSModuleURL="https://preview.babylonjs.com/basisTranscoder/basis_transcoder.js",r.WasmModuleURL="https://preview.babylonjs.com/basisTranscoder/basis_transcoder.wasm",r._WorkerPromise=null,r._Worker=null,r._actionId=0,r}();function Tm(){var r=0,t=1,e=5,n=6,i=null;function o(a,s,d,p,y){var P=a.getImageTranscodedSizeInBytes(s,d,p),O=new Uint8Array(P);return a.transcodeImage(O,s,d,p,1,0)?(y&&(O=function(U,F,z,J){for(var ie=new Uint16Array(4),se=new Uint16Array(z*J),ce=z/4,ue=J/4,fe=0;fe<ue;fe++)for(var ve=0;ve<ce;ve++){var Te=F+8*(fe*ce+ve);ie[0]=U[Te]|U[Te+1]<<8,ie[1]=U[Te+2]|U[Te+3]<<8,ie[2]=(2*(31&ie[0])+1*(31&ie[1]))/3|(2*(2016&ie[0])+1*(2016&ie[1]))/3&2016|(2*(63488&ie[0])+1*(63488&ie[1]))/3&63488,ie[3]=(2*(31&ie[1])+1*(31&ie[0]))/3|(2*(2016&ie[1])+1*(2016&ie[0]))/3&2016|(2*(63488&ie[1])+1*(63488&ie[0]))/3&63488;for(var Oe=0;Oe<4;Oe++){var Pe=U[Te+4+Oe],Ee=(4*fe+Oe)*z+4*ve;se[Ee++]=ie[3&Pe],se[Ee++]=ie[Pe>>2&3],se[Ee++]=ie[Pe>>4&3],se[Ee++]=ie[Pe>>6&3]}}return se}(O,0,a.getImageWidth(s,d)+3&-4,a.getImageHeight(s,d)+3&-4)),O):null}onmessage=function(a){if(a.data.action==="init")i||(Module={wasmBinary:a.data.wasmBinary},importScripts(a.data.url),i=new Promise(function(fe){Module.onRuntimeInitialized=function(){Module.initializeBasis(),fe()}})),i.then(function(){postMessage({action:"init"})});else if(a.data.action==="transcode"){var s=a.data.config,d=a.data.imageData,p=new Module.BasisFile(d),y=function(fe){for(var ve=fe.getHasAlpha(),Te=fe.getNumImages(),Oe=[],Pe=0;Pe<Te;Pe++){for(var Ee={levels:[]},Se=fe.getNumLevels(Pe),Le=0;Le<Se;Le++){var xe={width:fe.getImageWidth(Pe,Le),height:fe.getImageHeight(Pe,Le)};Ee.levels.push(xe)}Oe.push(Ee)}return{hasAlpha:ve,images:Oe}}(p),P=a.data.ignoreSupportedFormats?null:function(fe,ve){var Te=null;return fe.supportedCompressionFormats&&(fe.supportedCompressionFormats.etc1?Te=r:fe.supportedCompressionFormats.s3tc?Te=ve.hasAlpha?n:t:fe.supportedCompressionFormats.pvrtc||fe.supportedCompressionFormats.etc2&&(Te=e)),Te}(a.data.config,y),O=!1;P===null&&(O=!0,P=y.hasAlpha?n:t);var U=!0;p.startTranscoding()||(U=!1);for(var F=[],z=0;z<y.images.length&&U;z++){var J=y.images[z];if(s.loadSingleImage===void 0||s.loadSingleImage===z){var ie=J.levels.length;s.loadMipmapLevels===!1&&(ie=1);for(var se=0;se<ie;se++){var ce=J.levels[se],ue=o(p,z,se,P,O);if(!ue){U=!1;break}ce.transcodedPixels=ue,F.push(ce.transcodedPixels.buffer)}}}p.close(),p.delete(),O&&(P=-1),U?postMessage({action:"transcode",success:U,id:a.data.id,fileInfo:y,format:P},F):postMessage({action:"transcode",success:U,id:a.data.id})}}}var mh=function(){function r(){this.supportCascades=!1}return r.prototype.canLoad=function(t){return Xn.a.EndsWith(t,".basis")},r.prototype.loadCubeData=function(t,e,n,i,o){if(!Array.isArray(t)){var a=e.getEngine().getCaps(),s={supportedCompressionFormats:{etc1:!!a.etc1,s3tc:!!a.s3tc,pvrtc:!!a.pvrtc,etc2:!!a.etc2}};_o.TranscodeAsync(t,s).then(function(d){var p=d.fileInfo.images[0].levels.length>1&&e.generateMipMaps;_o.LoadTextureFromTranscodeResult(e,d),e.getEngine()._setCubeMapTextureParam
7341s(e,p),e.isReady=!0,e.onLoadedObservable.notifyObservers(e),e.onLoadedObservable.clear(),i&&i()}).catch(function(d){Ye.b.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"),e.isReady=!0})}},r.prototype.loadData=function(t,e,n){var i=e.getEngine().getCaps(),o={supportedCompressionFormats:{etc1:!!i.etc1,s3tc:!!i.s3tc,pvrtc:!!i.pvrtc,etc2:!!i.etc2}};_o.TranscodeAsync(t,o).then(function(a){var s=a.fileInfo.images[0].levels[0],d=a.fileInfo.images[0].levels.length>1&&e.generateMipMaps;n(s.width,s.height,d,a.format!==-1,function(){_o.LoadTextureFromTranscodeResult(e,a)})}).catch(function(a){Ye.b.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"),n(0,0,!1,!1,function(){})})},r}();Ue.a._TextureLoaders.push(new mh);var tc=function(r){function t(e,n,i,o,a){var s=this,d=!(!a||!a.generateMipMaps)&&a.generateMipMaps,p=!(!a||!a.generateDepthTexture)&&a.generateDepthTexture,y=!a||a.doNotChangeAspectRatio===void 0||a.doNotChangeAspectRatio;if((s=r.call(this,e,n,o,d,y)||this).isSupported){var P=[],O=[];s._initTypes(i,P,O,a);var U=!a||a.generateDepthBuffer===void 0||a.generateDepthBuffer,F=!(!a||a.generateStencilBuffer===void 0)&&a.generateStencilBuffer;return s._size=n,s._multiRenderTargetOptions={samplingModes:O,generateMipMaps:d,generateDepthBuffer:U,generateStencilBuffer:F,generateDepthTexture:p,types:P,textureCount:i},s._count=i,s._createInternalTextures(),s._createTextures(),s}s.dispose()}return Object(c.d)(t,r),Object.defineProperty(t.prototype,"isSupported",{get:function(){return this._getEngine().webGLVersion>1||this._getEngine().getCaps().drawBuffersExtension},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textures",{get:function(){return this._textures},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"count",{get:function(){return this._count},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthTexture",{get:function(){return this._textures[this._textures.length-1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wrapU",{set:function(e){if(this._textures)for(var n=0;n<this._textures.length;n++)this._textures[n].wrapU=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wrapV",{set:function(e){if(this._textures)for(var n=0;n<this._textures.length;n++)this._textures[n].wrapV=e},enumerable:!1,configurable:!0}),t.prototype._initTypes=function(e,n,i,o){for(var a=0;a<e;a++)o&&o.types&&o.types[a]!==void 0?n.push(o.types[a]):n.push(o&&o.defaultType?o.defaultType:h.a.TEXTURETYPE_UNSIGNED_INT),o&&o.samplingModes&&o.samplingModes[a]!==void 0?i.push(o.samplingModes[a]):i.push(we.a.BILINEAR_SAMPLINGMODE)},t.prototype._rebuild=function(e){e===void 0&&(e=!1),this.releaseInternalTextures(),this._createInternalTextures(),e&&this._createTextures();for(var n=0;n<this._internalTextures.length;n++)this._textures[n]._texture=this._internalTextures[n];this._texture=this._internalTextures[0],this.samples!==1&&this._getEngine().updateMultipleRenderTargetTextureSampleCount(this._internalTextures,this.samples)},t.prototype._createInternalTextures=function(){this._internalTextures=this._getEngine().createMultipleRenderTarget(this._size,this._multiRenderTargetOptions)},t.prototype._createTextures=function(){this._textures=[];for(var e=0;e<this._internalTextures.length;e++){var n=new we.a(null,this.getScene());n._texture=this._internalTextures[e],this._textures.push(n)}this._texture=this._internalTextures[0]},t.prototype.replaceTexture=function(e,n){e._texture&&(this._textures[n]=e,this._internalTextures[n]=e._texture)},Object.defineProperty(t.prototype,"samples",{get:function(){return this._samples},set:function(e){this._samples!==e&&(this._samples=this._getEngine().updateMultipleRenderTargetTextureSampleCount(this._internalTextures,e))},enumerable:!1,configurable:!0}),t.prototype.resize=function(e){this._size=e,this._rebuild()},t.prototype.updateCount=function(e,n){this._multiRenderTargetOptions.textureCount=e,this._count=e;var i=[],o=[];this._initTypes(e,i,o,n),this._multiRenderTargetOptions.types=i,this._multiRenderTargetOptions.samplingModes=o,this._rebuild(!0)},t.prototype.unbindFrameBuffer=function(e,n){var i=this;e.unBindMultiColorAttachmentFramebuffer(this._internalTextures,this.isCube,function(){i.onAfterRenderObservable.notifyObservers(n)})},t.prototype.dispose=function(){this.releaseInternalTextures(),r.prototype.dispose.call(this)},t.prototype.releaseInternalTextures=function(){if(this._internalTextures)for(var e=this._internalTextures.length-1;e>=0;e--)this._internalTextures[e]!==void 0&&(this._internalTextures[e].dispose(),this._internalTextures.splice(e,1))},t}(sn),nc=function(r,t,e){this.id=r,this.scale=t,this.offset=e},Em=function(){function r(t,e,n,i){var o,a,s,d,p,y,P,O,U,F,z,J,ie;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:Me.b.UVKind,this.options.uvsOut=(s=this.options.uvsOut)!==null&&s!==void 0?s:Me.b.UVKind,this.options.layout=(d=this.options.layout)!==null&&d!==void 0?d:r.LAYOUT_STRIP,this.options.layout===r.LAYOUT_COLNUM&&(this.options.colnum=(p=this.options.colnum)!==null&&p!==void 0?p:8),this.options.updateInputMeshes=(y=this.options.updateInputMeshes)===null||y===void 0||y,this.options.disposeSources=(P=this.options.disposeSources)===null||P===void 0||P,this._expecting=0,this.options.fillBlanks=(O=this.options.fillBlanks)===null||O===void 0||O,this.options.fillBlanks===!0&&(this.options.customFillColor=(U=this.options.customFillColor)!==null&&U!==void 0?U:"black"),this.options.frameSize=(F=this.options.frameSize)!==null&&F!==void 0?F:256,this.options.paddingRatio=(z=this.options.paddingRatio)!==null&&z!==void 0?z:.0115,this._paddingValue=Math.ceil(this.options.frameSize*this.options.paddingRatio),this._paddingValue%2!=0&&this._paddingValue++,this.options.paddingMode=(J=this.options.paddingMode)!==null&&J!==void 0?J:r.SUBUV_WRAP,this.options.paddingMode===r.SUBUV_COLOR&&(this.options.paddingColor=(ie=this.options.paddingColor)!==null&&ie!==void 0?ie:new M.b(0,0,0,1)),this.sets={},this.frames=[],this}return r.prototype._createFrames=function(t){for(var e=this,n=this._calculateSize(),i=new u.d(1,1).divide(n),o=0,a=this._expecting,s=this.meshes.length,d=Object.keys(this.sets),p=0;p<d.length;p++){var y=d[p],P=new yi.a(this.name+".TexturePack."+y+"Set",{width:n.x,height:n.y},this.scene,!0,we.a.TRILINEAR_SAMPLINGMODE,Ue.a.TEXTUREFORMAT_RGBA),O=P.getContext();O.fillStyle="rgba(0,0,0,0)",O.fillRect(0,0,n.x,n.y),P.update(!1),this.sets[y]=P}var U=this.options.frameSize||256,F=this._paddingValue,z=U+2*F;for(p=0;p<s;p++)for(var J=this.meshes[p].material,ie=function(ue){var fe=new yi.a("temp",z,se.scene,!0),ve=fe.getContext(),Te=se._getFrameOffset(p),Oe=function(){o++,fe.update(!1);var Le=ve.getImageData(0,0,z,z),xe=e.sets[Pe];if(xe.getContext().putImageData(Le,n.x*Te.x,n.y*Te.y),fe.dispose(),xe.update(!1),o==a)return e._calculateMeshUVFrames(U,F,n,i,e.options.updateInputMeshes||!1),void t()},Pe=d[ue]||"_blank";if(J&&J[Pe]!==null){var Ee=J[Pe],Se=new Image;Ee instanceof yi.a?Se.src=Ee.getContext().canvas.toDataURL("image/png"):Se.src=Ee.url,Ye.b.SetCorsBehavior(Se.src,Se),Se.onload=function(){ve.fillStyle="rgba(0,0,0,0)",ve.fillRect(0,0,z,z),fe.update(!1),ve.setTransform(1,0,0,-1,0,0);var Le=[0,0,1,0,1,1,0,1,-1,1,-1,0,-2,0,-1,1,-1];switch(e.options.paddingMode){case 0:for(var xe=0;xe<9;xe++)ve.drawImage(Se,0,0,Se.width,Se.height,F+U*Le[xe],F+U*Le[xe+1]-z,U,U);break;case 1:for(var Ne=0;Ne<F;Ne++)ve.drawImage(Se,0,0,Se.width,Se.height,Ne+U*Le[0],F-z,U,U),ve.drawImage(Se,0,0,Se.width,Se.height,2*F-Ne,F-z,U,U),ve.drawImage(Se,0,0,Se.width,Se.height,F,Ne-z,U,U),ve.drawImage(Se,0,0,Se.width,Se.height,F,2*F-Ne-z,U,U);ve.drawImage(Se,0,0,Se.width,Se.height,F+U*Le[0],F+U*Le[1]-z,U,U);break;case 2:ve.fillStyle=(e.options.paddingColor||M.a.Black()).toHexString(),ve.fillRect(0,0,z,-z),ve.clearRect(F,F,U,U),ve.drawImage(Se,0,0,Se.width,Se.height,F+U*Le[0],F+U*Le[1]-z,U,U)}ve.setTransform(1,0,0,1,0,0),Oe()}}else ve.fillStyle="rgba(0,0,0,0)",se.options.fillBlanks&&(ve.fillStyle=se.options.customFillColor),ve.fillRect(0,0,z,z),Oe()},se=this,ce=0;ce<d.length;ce++)ie(ce)},r.prototype._calculateSize=function(){var t=this.meshes.length||0,e=this.options.frameSize||0,n=this._paddingValue||0;switch(this.options.layout){case 0:return new u.d(e*t+2*n*t,e+2*n);case 1:var i=Math.max(2,Math.ceil(Math.sqrt(t))),o=e*i+2*n*i;return new u.d(o,o);case 2:var a=this.options.colnum||1,s=Math.max(1,Math.ceil(t/a));return new u.d(e*a+2*n*a,e*s+2*n*s)}return u.d.Zero()},r.prototype._calculateMeshUVFrames=function(t,e,n,i,o){for(var a=this.meshes.length,s=0;s<a;s++){var d=this.meshes[s],p=new u.d(t/n.x,t/n.y),y=i.clone().scale(e),P=this._getFrameOffset(s).add(y),O=new nc(s,p,P);this.frames.push(O),o&&(this._updateMeshUV(d,s),this._updateTextureReferences(d)
7341)}},r.prototype._getFrameOffset=function(t){var e,n,i,o=this.meshes.length;switch(this.options.layout){case 0:return e=1/o,new u.d(t*e,0);case 1:var a=Math.max(2,Math.ceil(Math.sqrt(o)));return i=t-(n=Math.floor(t/a))*a,e=1/a,new u.d(i*e,n*e);case 2:var s=this.options.colnum||1,d=Math.max(1,Math.ceil(o/s));return n=t-(i=Math.floor(t/d))*d,e=new u.d(1/s,1/d),new u.d(i*e.x,n*e.y)}return u.d.Zero()},r.prototype._updateMeshUV=function(t,e){var n=this.frames[e],i=t.getVerticesData(this.options.uvsIn||Me.b.UVKind),o=[],a=0;i.length&&(a=i.length||0);for(var s=0;s<a;s+=2)o.push(i[s]*n.scale.x+n.offset.x,i[s+1]*n.scale.y+n.offset.y);t.setVerticesData(this.options.uvsOut||Me.b.UVKind,o)},r.prototype._updateTextureReferences=function(t,e){e===void 0&&(e=!1);for(var n=t.material,i=Object.keys(this.sets),o=function(d){d.dispose&&d.dispose()},a=0;a<i.length;a++){var s=i[a];if(e)n[s]!==null&&o(n[s]),n[s]=this.sets[s];else{if(!n)return;n[s]!==null&&(o(n[s]),n[s]=this.sets[s])}}},r.prototype.setMeshToFrame=function(t,e,n){n===void 0&&(n=!1),this._updateMeshUV(t,e),n&&this._updateTextureReferences(t,!0)},r.prototype.processAsync=function(){var t=this;return new Promise(function(e,n){try{if(t.meshes.length===0)return void e();for(var i=0,o=function(d){var p=t.meshes[d],y=p.material;if(!y)return++i===t.meshes.length?{value:t._createFrames(e)}:"continue";y.forceCompilationAsync(p).then(function(){(function(P){if(i++,t.options.map){for(var O=0;O<t.options.map.length;O++)P[t.options.map[O]]!==null&&(t.sets[t.options.map[O]]||(t.sets[t.options.map[O]]=!0),t._expecting++);i===t.meshes.length&&t._createFrames(e)}})(y)})},a=0;a<t.meshes.length;a++){var s=o(a);if(typeof s=="object")return s.value}}catch(d){return n(d)}})},r.prototype.dispose=function(){for(var t=Object.keys(this.sets),e=0;e<t.length;e++){var n=t[e];this.sets[n].dispose()}},r.prototype.download=function(t,e){var n=this;t===void 0&&(t="png"),e===void 0&&(e=1),setTimeout(function(){var i={name:n.name,sets:{},options:{},frames:[]},o=Object.keys(n.sets),a=Object.keys(n.options);try{for(var s=0;s<o.length;s++){var d=o[s],p=n.sets[d];i.sets[d]=p.getContext().canvas.toDataURL("image/"+t,e)}for(s=0;s<a.length;s++){var y=a[s];i.options[y]=n.options[y]}for(s=0;s<n.frames.length;s++){var P=n.frames[s];i.frames.push(P.scale.x,P.scale.y,P.offset.x,P.offset.y)}}catch(F){return void l.a.Warn("Unable to download: "+F)}var O="data:text/json;charset=utf-8,"+encodeURIComponent(JSON.stringify(i,null,4)),U=document.createElement("a");U.setAttribute("href",O),U.setAttribute("download",n.name+"_texurePackage.json"),document.body.appendChild(U),U.click(),U.remove()},0)},r.prototype.updateFromJSON=function(t){try{var e=JSON.parse(t);this.name=e.name;for(var n=Object.keys(e.options),i=0;i<n.length;i++)this.options[n[i]]=e.options[n[i]];for(i=0;i<e.frames.length;i+=4){var o=new nc(i/4,new u.d(e.frames[i],e.frames[i+1]),new u.d(e.frames[i+2],e.frames[i+3]));this.frames.push(o)}var a=Object.keys(e.sets);for(i=0;i<a.length;i++){var s=new we.a(e.sets[a[i]],this.scene,!1,!1);this.sets[a[i]]=s}}catch(d){l.a.Warn("Unable to update from JSON: "+d)}},r.LAYOUT_STRIP=0,r.LAYOUT_POWER2=1,r.LAYOUT_COLNUM=2,r.SUBUV_WRAP=0,r.SUBUV_EXTEND=1,r.SUBUV_COLOR=2,r}(),gh=function(){function r(t){this.name=st.a.NAME_PROCEDURALTEXTURE,this.scene=t,this.scene.proceduralTextures=new Array}return r.prototype.register=function(){this.scene._beforeClearStage.registerStep(st.a.STEP_BEFORECLEAR_PROCEDURALTEXTURE,this,this._beforeClear)},r.prototype.rebuild=function(){},r.prototype.dispose=function(){},r.prototype._beforeClear=function(){if(this.scene.proceduralTexturesEnabled){Ye.b.StartPerformanceCounter("Procedural textures",this.scene.proceduralTextures.length>0);for(var t=0;t<this.scene.proceduralTextures.length;t++){var e=this.scene.proceduralTextures[t];e._shouldRender()&&e.render()}Ye.b.EndPerformanceCounter("Procedural textures",this.scene.proceduralTextures.length>0)}},r}(),Sm=`
7342attribute vec2 position;
7343
7344varying vec2 vPosition;
7345varying vec2 vUV;
7346const vec2 madd=vec2(0.5,0.5);
7347void main(void) {
7348vPosition=position;
7349vUV=position*madd+madd;
7350gl_Position=vec4(position,0.0,1.0);
7351}`;je.a.ShadersStore.proceduralVertexShader=Sm;var mo=function(r){function t(e,n,i,o,a,s,d,p){a===void 0&&(a=null),s===void 0&&(s=!0),d===void 0&&(d=!1),p===void 0&&(p=h.a.TEXTURETYPE_UNSIGNED_INT);var y=r.call(this,null,o,!s)||this;y.isEnabled=!0,y.autoClear=!0,y.onGeneratedObservable=new x.c,y.onBeforeGenerationObservable=new x.c,y.nodeMaterialSource=null,y._textures={}
7351,y._currentRefreshId=-1,y._frameId=-1,y._refreshRate=1,y._vertexBuffers={},y._uniforms=new Array,y._samplers=new Array,y._floats={},y._ints={},y._floatsArrays={},y._colors3={},y._colors4={},y._vectors2={},y._vectors3={},y._matrices={},y._fallbackTextureUsed=!1,y._cachedDefines="",y._contentUpdateId=-1;var P=(o=y.getScene()||te.a.LastCreatedScene)._getComponent(st.a.NAME_PROCEDURALTEXTURE);P||(P=new gh(o),o._addComponent(P)),o.proceduralTextures.push(y),y._fullEngine=o.getEngine(),y.name=e,y.isRenderTarget=!0,y._size=n,y._generateMipMaps=s,y.setFragment(i),y._fallbackTexture=a,d?(y._texture=y._fullEngine.createRenderTargetCubeTexture(n,{generateMipMaps:s,generateDepthBuffer:!1,generateStencilBuffer:!1,type:p}),y.setFloat("face",0)):y._texture=y._fullEngine.createRenderTargetTexture(n,{generateMipMaps:s,generateDepthBuffer:!1,generateStencilBuffer:!1,type:p});var O=[];return O.push(1,1),O.push(-1,1),O.push(-1,-1),O.push(1,-1),y._vertexBuffers[Me.b.PositionKind]=new Me.b(y._fullEngine,O,Me.b.PositionKind,!1,!1,2),y._createIndexBuffer(),y}return Object(c.d)(t,r),t.prototype.getEffect=function(){return this._effect},t.prototype.getContent=function(){return this._contentData&&this._frameId===this._contentUpdateId||(this._contentData=this.readPixels(0,0,this._contentData),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[Me.b.PositionKind];e&&e._rebuild(),this._createIndexBuffer(),this.refreshRate===sn.REFRESHRATE_RENDER_ONCE&&(this.refreshRate=sn.REFRESHRATE_RENDER_ONCE)},t.prototype.reset=function(){this._effect!==void 0&&this._effect.dispose()},t.prototype._getDefines=function(){return""},t.prototype.isReady=function(){var e,n=this,i=this._fullEngine;if(this.nodeMaterialSource)return this._effect.isReady();if(!this._fragment)return!1;if(this._fallbackTextureUsed)return!0;var o=this._getDefines();return!(!this._effect||o!==this._cachedDefines||!this._effect.isReady())||(e=this._fragment.fragmentElement!==void 0?{vertex:"procedural",fragmentElement:this._fragment.fragmentElement}:{vertex:"procedural",fragment:this._fragment},this._cachedDefines=o,this._effect=i.createEffect(e,[Me.b.PositionKind],this._uniforms,this._samplers,o,void 0,void 0,function(){n.releaseInternalTexture(),n._fallbackTexture&&(n._texture=n._fallbackTexture._texture,n._texture&&n._texture.incrementReferences()),n._fallbackTextureUsed=!0}),this._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){this._fallbackTextureUsed||(this.releaseInternalTexture(),this._texture=this._fullEngine.createRenderTargetTexture(e,n),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}
7351,t.prototype.setMatrix=function(e,n){return this._checkUniform(e),this._matrices[e]=n,this},t.prototype.render=function(e){var n=this.getScene();if(n){var i=this._fullEngine;if(i.enableEffect(this._effect),this.onBeforeGenerationObservable.notifyObservers(this),i.setState(!1),!this.nodeMaterialSource){for(var o in this._textures)this._effect.setTexture(o,this._textures[o]);for(o in this._ints)this._effect.setInt(o,this._ints[o]);for(o in this._floats)this._effect.setFloat(o,this._floats[o]);for(o in this._floatsArrays)this._effect.setArray(o,this._floatsArrays[o]);for(o in this._colors3)this._effect.setColor3(o,this._colors3[o]);for(o in this._colors4){var a=this._colors4[o];this._effect.setFloat4(o,a.r,a.g,a.b,a.a)}for(o in this._vectors2)this._effect.setVector2(o,this._vectors2[o]);for(o in this._vectors3)this._effect.setVector3(o,this._vectors3[o]);for(o in this._matrices)this._effect.setMatrix(o,this._matrices[o])}if(this._texture){if(this.isCube)for(var s=0;s<6;s++)i.bindFramebuffer(this._texture,s,void 0,void 0,!0),i.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect),this._effect.setFloat("face",s),this.autoClear&&i.clear(n.clearColor,!0,!1,!1),i.drawElementsType(Ht.a.TriangleFillMode,0,6),s===5&&i.generateMipMapsForCubemap(this._texture);else i.bindFramebuffer(this._texture,0,void 0,void 0,!0),i.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect),this.autoClear&&i.clear(n.clearColor,!0,!1,!1),i.drawElementsType(Ht.a.TriangleFillMode,0,6);i.unBindFramebuffer(this._texture,this.isCube),this.onGenerated&&this.onGenerated(),this.onGeneratedObservable.notifyObservers(this)}}},t.prototype.clone=function(){var e=this.getSize(),n=new t(this.name,e.width,this._fragment,this.getScene(),this._fallbackTexture,this._generateMipMaps);return n.hasAlpha=this.hasAlpha,n.level=this.level,n.coordinatesMode=this.coordinatesMode,n},t.prototype.dispose=function(){var e=this.getScene();if(e){var n=e.proceduralTextures.indexOf(this);n>=0&&e.proceduralTextures.splice(n,1);var i=this._vertexBuffers[Me.b.PositionKind];i&&(i.dispose(),this._vertexBuffers[Me.b.PositionKind]=null),this._indexBuffer&&this._fullEngine._releaseBuffer(this._indexBuffer)&&(this._indexBuffer=null),this.onGeneratedObservable.clear(),this.onBeforeGenerationObservable.clear(),r.prototype.dispose.call(this)}},Object(c.c)([Object(L.c)()],t.prototype,"isEnabled",void 0),Object(c.c)([Object(L.c)()],t.prototype,"autoClear",void 0),Object(c.c)([Object(L.c)()],t.prototype,"_generateMipMaps",void 0),Object(c.c)([Object(L.c)()],t.prototype,"_size",void 0),Object(c.c)([Object(L.c)()],t.prototype,"refreshRate",null),t}(we.a);R.a.RegisteredTypes["BABYLON.ProceduralTexture"]=mo;var Am=function(r){function t(e,n,i,o,a,s){var d=r.call(this,e,i,null,o,a,s)||this;return d._animate=!0,d._time=0,d._texturePath=n,d._loadJson(n),d.refreshRate=1,d}return Object(c.d)(t,r),t.prototype._loadJson=function(e){var n=this,i=function(){try{n.setFragment(n._texturePath)}catch{l.a.Error("No json or ShaderStore or DOM element found for CustomProceduralTexture")}},o=e+"/config.json",a=new re.a;a.open("GET",o),a.addEventListener("load",function(){if(a.status===200||a.responseText&&a.responseText.length>0)try{n._config=JSON.parse(a.response),n.updateShaderUniforms(),n.updateTextures(),n.setFragment(n._texturePath+"/custom"),n._animate=n._config.animate,n.refreshRate=n._config.refreshrate}catch{i()}else i()},!1),a.addEventListener("error",function(){i()},!1);try{a.send()}catch{l.a.Error("CustomProceduralTexture: Error on XHR send request.")}},t.prototype.isReady=function(){if(!r.prototype.isReady.call(this))return!1;for(var e in this._textures)if(!this._textures[e].isReady())return!1;return!0},t.prototype.render=function(e){var n=this.getScene();this._animate&&n&&(this._time+=.03*n.getAnimationRatio(),this.updateShaderUniforms()),r.prototype.render.call(this,e)},t.prototype.updateTextures=function(){for(var e=0;e<this._config.sampler2Ds.length;e++)this.setTexture(this._config.sampler2Ds[e].sample2Dname,new we.a(this._texturePath+"/"+this._config.sampler2Ds[e].textureRelativeUrl,this.get
7351Scene()))},t.prototype.updateShaderUniforms=function(){if(this._config)for(var e=0;e<this._config.uniforms.length;e++){var n=this._config.uniforms[e];switch(n.type){case"float":this.setFloat(n.name,n.value);break;case"color3":this.setColor3(n.name,new M.a(n.r,n.g,n.b));break;case"color4":this.setColor4(n.name,new M.b(n.r,n.g,n.b,n.a));break;case"vector2":this.setVector2(n.name,new u.d(n.x,n.y));break;case"vector3":this.setVector3(n.name,new u.e(n.x,n.y,n.z))}}this.setFloat("time",this._time)},Object.defineProperty(t.prototype,"animate",{get:function(){return this._animate},set:function(e){this._animate=e},enumerable:!1,configurable:!0}),t}(mo),Pm=`
7352
7353uniform float brightness;
7354uniform float persistence;
7355uniform float timeScale;
7356
7357varying vec2 vUV;
7358
7359vec2 hash22(vec2 p)
7360{
7361p=p*mat2(127.1,311.7,269.5,183.3);
7362p=-1.0+2.0*fract(sin(p)*43758.5453123);
7363return sin(p*6.283+timeScale);
7364}
7365float interpolationNoise(vec2 p)
7366{
7367vec2 pi=floor(p);
7368vec2 pf=p-pi;
7369vec2 w=pf*pf*(3.-2.*pf);
7370float f00=dot(hash22(pi+vec2(.0,.0)),pf-vec2(.0,.0));
7371float f01=dot(hash22(pi+vec2(.0,1.)),pf-vec2(.0,1.));
7372float f10=dot(hash22(pi+vec2(1.0,0.)),pf-vec2(1.0,0.));
7373float f11=dot(hash22(pi+vec2(1.0,1.)),pf-vec2(1.0,1.));
7374float xm1=mix(f00,f10,w.x);
7375float xm2=mix(f01,f11,w.x);
7376float ym=mix(xm1,xm2,w.y);
7377return ym;
7378}
7379float perlinNoise2D(float x,float y)
7380{
7381float sum=0.0;
7382float frequency=0.0;
7383float amplitude=0.0;
7384for(int i=0; i<OCTAVES; i++)
7385{
7386frequency=pow(2.0,float(i));
7387amplitude=pow(persistence,float(i));
7388sum=sum+interpolationNoise(vec2(x*frequency,y*frequency))*amplitude;
7389}
7390return sum;
7391}
7392
7393void main(void)
7394{
7395float x=abs(vUV.x);
7396float y=abs(vUV.y);
7397float noise=brightness+(1.0-brightness)*perlinNoise2D(x,y);
7398gl_FragColor=vec4(noise,noise,noise,1.0);
7399}
7400`;je.a.ShadersStore.noisePixelShader=Pm;var vh=function(r){function t(e,n,i,o,a){n===void 0&&(n=256),i===void 0&&(i=te.a.LastCreatedScene);var s=r.call(this,e,n,"noise",i,o,a)||this;return s.time=0,s.brightness=.2,s.octaves=3,s.persistence=.8,s.animationSpeedFactor=1,s.autoClear=!1,s._updateShaderUniforms(),s}return Object(c.d)(t,r),t.prototype._updateShaderUniforms=function(){var e=this.getScene();e&&(this.time+=e.getAnimationRatio()*this.animationSpeedFactor*.01,this.setFloat("brightness",this.brightness),this.setFloat("persistence",this.persistence),this.setFloat("timeScale",this.time))},t.prototype._getDefines=function(){return"#define OCTAVES "+(0|this.octaves)},t.prototype.render=function(e){this._updateShaderUniforms(),r.prototype.render.call(this,e)},t.prototype.serialize=function(){var e={customType:"BABYLON.NoiseProceduralTexture"};return e.brightness=this.brightness,e.octaves=this.octaves,e.persistence=this.persistence,e.animationSpeedFactor=this.animationSpeedFactor,e.size=this.getSize().width,e.generateMipMaps=this._generateMipMaps,e.time=this.time,e},t.prototype.clone=function(){var e=this.getSize(),n=new t(this.name,e.width,this.getScene(),this._fallbackTexture?this._fallbackTexture:void 0,this._generateMipMaps);return n.hasAlpha=this.hasAlpha,n.level=this.level,n.coordinatesMode=this.coordinatesMode,n.brightness=this.brightness,n.octaves=this.octaves,n.persistence=this.persistence,n.animationSpeedFactor=this.animationSpeedFactor,n.time=this.time,n},t.Parse=function(e,n){var i,o=new t(e.name,e.size,n,void 0,e.generateMipMaps);return o.brightness=e.brightness,o.octaves=e.octaves,o.persistence=e.persistence,o.animationSpeedFactor=e.animationSpeedFactor,o.time=(i=e.time)!==null&&i!==void 0?i:0,o},t}(mo);R.a.RegisteredTypes["BABYLON.NoiseProceduralTexture"]=vh;var Re,le,gn,bt,Rn,oi,bn,Cm=function(r){function t(e,n,i,o,a,s,d,p,y){o===void 0&&(o=h.a.TEXTUREFORMAT_RGBA),a===void 0&&(a=h.a.TEXTURETYPE_UNSIGNED_INT),s===void 0&&(s=!1),d===void 0&&(d=!1),p===void 0&&(p=h.a.TEXTURE_TRILINEAR_SAMPLINGMODE),y===void 0&&(y=null);var P=r.call(this,"",e)||this;return P._texture=e.getEngine().createRawCubeTexture(n,i,o,a,s,d,p,y),P}return Object(c.d)(t,r),t.prototype.update=function(e,n,i,o,a){a===void 0&&(a=null),this._texture.getEngine().updateRawCubeTexture(this._texture,e,n,i,o,a)},t.prototype.updateRGBDAsync=function(e,n,i,o){return n===void 0&&(n=null),i===void 0&&(i=.8),o===void 0&&(o=0),t._UpdateRGBDAsync(this._texture,e,n,i,o)},t.prototype.clone=function(){var e=this;return L.a.Clone(function(){var n=e.getScene(),i=e._texture,o=new t(n,i._bufferViewArray,i.width,i.format,i.type,i.generateMipMaps,i.invertY,i.samplingMode,i._compression);return i.source===xt.b.CubeRawRGBD&&o.updateRGBDAsync(i._bufferViewArrayArray,i._sphericalPolynomial,i._lodGenerationScale,i._lodGenerationOffset),o},this)},t._UpdateRGBDAsync=function(e,n,i,o,a){return e._source=xt.b.CubeRawRGBD,e._bufferViewArrayArray=n,e._lodGenerationScale=o,e._lodGenerationOffset=a,e._sphericalPolynomial=i,Si.UploadLevelsAsync(e,n).then(function(){e.isReady=!0})},t}(ni),xm=function(r){function t(e,n,i,o,a,s,d,p,y,P){d===void 0&&(d=!0),p===void 0&&(p=!1),y===void 0&&(y=we.a.TRILINEAR_SAMPLINGMODE),P===void 0&&(P=h.a.TEXTURETYPE_UNSIGNED_INT);var O=r.call(this,null,s,!d,p)||this;return O.format=a,O._texture=s.getEngine().createRawTexture2DArray(e,n,i,o,a,d,p,y,null,P),O.is2DArray=!0,O}return Object(c.d)(t,r),t.prototype.update=function(e){this._texture&&this._getEngine().updateRawTexture2DArray(this._texture,e,this._texture.format,this._texture.invertY,null,this._texture.type)},t}(we.a),Rm=function(r){function t(e,n,i,o,a,s,d,p,y,P){d===void 0&&(d=!0),p===void 0&&(p=!1),y===void 0&&(y=we.a.TRILINEAR_SAMPLINGMODE),P===void 0&&(P=h.a.TEXTURETYPE_UNSIGNED_INT);var O=r.call(this,null,s,!d,p)||this;return O.format=a,O._texture=s.getEngine().createRawTexture3D(e,n,i,o,a,d,p,y,null,P),O.is3D=!0,O}return Object(c.d)(t,r),t.prototype.update=function(e){this._texture&&this._getEngine().updateRawTexture3D(this._texture,e,this._texture.format,this._texture.invertY,null,this._texture.type)},t}(we.a),Om=function(r){function t(e,n,i,o){var a=r.call(this,e,n,i,o,!0)||this;return a.refractionPlane=new gr.a(0,1,0,1),a.depth=2,a.onBeforeRenderObservable.add(function(){i.clipPlane=a.refractionPlane}),a.onAfterRenderObservable.add(function(){i.clipPlane=null}),a}return Object(c.d)(t,r),t.prototype.clone=function(){var e=this.getScene();if(!e)return this;var n=this.getSize(),i=new t(this.name,n.width,e,this._generateMipMaps);return i.hasAlpha=this.hasAlpha,i.level=this.level,i.refractionPlane=this.refractionPlane.clone(),this.renderList&&(i.renderList=this.renderList.slice(0)),i.depth=this.depth,i},t.prototype.serialize=function(){if(!this.name)return null;var e=r.prototype.serialize.call(this);return e.mirrorPlane=this.refractionPlane.asArray(),e.depth=this.depth,e},t}(sn);(function(r){r[r.Vertex=1]="Vertex",r[r.Fragment=2]="Fragment",r[r.Neutral=4]="Neutral",r[r.VertexAndFragment=3]="VertexAndFragment"})(Re||(Re={})),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=2
7400048]="BasedOnInput"}(le||(le={})),function(r){r[r.Uniform=0]="Uniform",r[r.Attribute=1]="Attribute",r[r.Varying=2]="Varying",r[r.Undefined=3]="Undefined"}(gn||(gn={})),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"}(bt||(bt={})),function(r){r[r.Material=0]="Material",r[r.PostProcess=1]="PostProcess",r[r.Particle=2]="Particle",r[r.ProceduralTexture=3]="ProceduralTexture"}(Rn||(Rn={})),function(r){r[r.Compatible=0]="Compatible",r[r.TypeIncompatible=1]="TypeIncompatible",r[r.TargetIncompatible=2]="TargetIncompatible"}(oi||(oi={})),function(r){r[r.Input=0]="Input",r[r.Output=1]="Output"}(bn||(bn={}));var _a=function(){function r(t,e,n){this._connectedPoint=null,this._endpoints=new Array,this._typeConnectionSource=null,this._linkedConnectionSource=null,this._acceptedConnectionPointType=null,this._type=le.Float,this._enforceAssociatedVariableName=!1,this.needDualDirectionValidation=!1,this.acceptedConnectionPointTypes=new Array,this.excludedConnectionPointTypes=new Array,this.onConnectionObservable=new x.c,this.isExposedOnFrame=!1,this.exposedPortPosition=-1,this._prioritizeVertex=!1,this._target=Re.VertexAndFragment,this._ownerBlock=e,this.name=t,this._direction=n}return r.AreEquivalentTypes=function(t,e){switch(t){case le.Vector3:if(e===le.Color3)return!0;break;case le.Vector4:if(e===le.Color4)return!0;break;case le.Color3:if(e===le.Vector3)return!0;break;case le.Color4:if(e===le.Vector4)return!0}return!1},Object.defineProperty(r.prototype,"direction",{get:function(){return this._direction},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"associatedVariableName",{get:function(){return this._ownerBlock.isInput?this._ownerBlock.associatedVariableName:this._enforceAssociatedVariableName&&this._associatedVariableName||!this._connectedPoint?this._associatedVariableName:this._connectedPoint.associatedVariableName},set:function(t){this._associatedVariableName=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"innerType",{get:function(){return this._linkedConnectionSource&&this._linkedConnectionSource.isConnected?this.type:this._type},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"type",{get:function(){if(this._type===le.AutoDetect){if(this._ownerBlock.isInput)return this._ownerBlock.type;if(this._connectedPoint)return this._connectedPoint.type;if(this._linkedConnectionSource&&this._linkedConnectionSource.isConnected)return this._linkedConnectionSource.type}return this._type===le.BasedOnInput&&this._typeConnectionSource?this._typeConnectionSource.type:this._type},set:function(t){this._type=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"target",{get:function(){return this._prioritizeVertex&&this._ownerBlock?this._target!==Re.VertexAndFragment?this._target:this._ownerBlock.target===Re.Fragment?Re.Fragment:Re.Vertex:this._target},set:function(t){this._target=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isConnected",{get:function(){return this.connectedPoint!==null||this.hasEndpoints},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isConnectedToInputBlock",{get:function(){return this.connectedPoint!==null&&this.connectedPoint.ownerBlock.isInput},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"connectInputBlock",{get:function(){return this.isConnectedToInputBlock?this.connectedPoint.ownerBlock:null},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"connectedPoint",{get:function(){return this._connectedPoint},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"ownerBlock",{get:function(){return this._ownerBlock},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sourceBlock",{get:function(){return this._connectedPoint?this._connectedPoint.ownerBlock:null},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"connectedBlocks",{get:function(){return this._endpoints.length===0?[]:this._endpoints.map(function(t){return t.ownerBlock})}
7400,enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"endpoints",{get:function(){return this._endpoints},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"hasEndpoints",{get:function(){return this._endpoints&&this._endpoints.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isConnectedInVertexShader",{get:function(){if(this.target===Re.Vertex)return!0;if(!this.hasEndpoints)return!1;for(var t=0,e=this._endpoints;t<e.length;t++){var n=e[t];if(n.ownerBlock.target===Re.Vertex||n.target===Re.Vertex||(n.ownerBlock.target===Re.Neutral||n.ownerBlock.target===Re.VertexAndFragment)&&n.ownerBlock.outputs.some(function(i){return i.isConnectedInVertexShader}))return!0}return!1},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isConnectedInFragmentShader",{get:function(){if(this.target===Re.Fragment)return!0;if(!this.hasEndpoints)return!1;for(var t=0,e=this._endpoints;t<e.length;t++){var n=e[t];if(n.ownerBlock.target===Re.Fragment||(n.ownerBlock.target===Re.Neutral||n.ownerBlock.target===Re.VertexAndFragment)&&n.ownerBlock.outputs.some(function(i){return i.isConnectedInFragmentShader}))return!0}return!1},enumerable:!1,configurable:!0}),r.prototype.createCustomInputBlock=function(){return null},r.prototype.getClassName=function(){return"NodeMaterialConnectionPoint"},r.prototype.canConnectTo=function(t){return this.checkCompatibilityState(t)===oi.Compatible},r.prototype.checkCompatibilityState=function(t){if(this._ownerBlock.target===Re.Fragment){var e=t.ownerBlock;if(e.target===Re.Vertex)return oi.TargetIncompatible;for(var n=0,i=e.outputs;n<i.length;n++)if(i[n].isConnectedInVertexShader)return oi.TargetIncompatible}return this.type!==t.type&&t.innerType!==le.AutoDetect?r.AreEquivalentTypes(this.type,t.type)||t.acceptedConnectionPointTypes&&t.acceptedConnectionPointTypes.indexOf(this.type)!==-1||t._acceptedConnectionPointType&&r.AreEquivalentTypes(t._acceptedConnectionPointType.type,this.type)?oi.Compatible:oi.TypeIncompatible:t.excludedConnectionPointTypes&&t.excludedConnectionPointTypes.indexOf(this.type)!==-1?1:oi.Compatible},r.prototype.connectTo=function(t,e){if(e===void 0&&(e=!1),!e&&!this.canConnectTo(t))throw"Cannot connect these two connectors.";return this._endpoints.push(t),t._connectedPoint=this,this._enforceAssociatedVariableName=!1,this.onConnectionObservable.notifyObservers(t),t.onConnectionObservable.notifyObservers(this),this},r.prototype.disconnectFrom=function(t){var e=this._endpoints.indexOf(t);return e===-1||(this._endpoints.splice(e,1),t._connectedPoint=null,this._enforceAssociatedVariableName=!1,t._enforceAssociatedVariableName=!1),this},r.prototype.serialize=function(t){t===void 0&&(t=!0);var e={};return e.name=this.name,e.displayName=this.displayName,t&&this.connectedPoint&&(e.inputName=this.name,e.targetBlockId=this.connectedPoint.ownerBlock.uniqueId,e.targetConnectionName=this.connectedPoint.name,e.isExposedOnFrame=!0,e.exposedPortPosition=this.exposedPortPosition),(this.isExposedOnFrame||this.exposedPortPosition>=0)&&(e.isExposedOnFrame=!0,e.exposedPortPosition=this.exposedPortPosition),e},r.prototype.dispose=function(){this.onConnectionObservable.clear()},r}(),Mm=f(152),pt=function(){function r(t,e,n,i){e===void 0&&(e=Re.Vertex),n===void 0&&(n=!1),i===void 0&&(i=!1),this._isFinalMerger=!1,this._isInput=!1,this._name="",this._isUnique=!1,this.inputsAreExclusive=!1,this._codeVariableName="",this._inputs=new Array,this._outputs=new Array,this.comments="",this.visibleInInspector=!1,this._target=e,this._isFinalMerger=n,this._isInput=i,this._name=t,this.uniqueId=Mm.a.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,"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}
7400,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.initialize=function(t){},r.prototype.bind=function(t,e,n,i){},r.prototype._declareOutput=function(t,e){return e._getGLType(t.type)+" "+t.associatedVariableName},r.prototype._writeVariable=function(t){return t.connectedPoint?""+t.associatedVariableName:"0."},r.prototype._writeFloat=function(t){var e=t.toString();return e.indexOf(".")===-1&&(e+=".0"),""+e},r.prototype.getClassName=function(){return"NodeMaterialBlock"},r.prototype.registerInput=function(t,e,n,i,o){return n===void 0&&(n=!1),(o=o??new _a(t,this,bn.Input)).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 _a(t,this,bn.Output)).type=e,n&&(i.target=n),this._outputs.push(i),this},r.prototype.getFirstAvailableInput=function(t){t===void 0&&(t=null);for(var e=0,n=this._inputs;e<n.length;e++){var i=n[e];if(!(i.connectedPoint||t&&t.type!==i.type&&i.type!==le.AutoDetect))return i}return null},r.prototype.getFirstAvailableOutput=function(t){t===void 0&&(t=null);for(var e=0,n=this._outputs;e<n.length;e++){var i=n[e];if(!t||!t.target||t.target===Re.Neutral||t.target&i.target)return i}return null},r.prototype.getSiblingOutput=function(t){var e=this._outputs.indexOf(t);return e===-1||e>=this._outputs.length?null:this._outputs[e+1]},r.prototype.connectTo=function(t,e){if(this._outputs.length!==0){for(var n=e&&e.output?this.getOutputByName(e.output):this.getFirstAvailableOutput(t),i=!0;i;){var o=e&&e.input?t.getInputByName(e.input):t.getFirstAvailableInput(n);if(n&&o&&n.canConnectTo(o))n.connectTo(o),i=!1;else{if(!n)throw"Unable to find a compatible match";n=this.getSiblingOutput(n)}}return this}},r.prototype._buildBlock=function(t){},r.prototype.updateUniformsAndSamples=function(t,e,n,i){},r.prototype.provideFallbacks=function(t,e){},r.prototype.initializeDefines=function(t,e,n,i){},r.prototype.prepareDefines=function(t,e,n,i,o){},r.prototype.autoConfigure=function(t){},r.prototype.replaceRepeatableContent=function(t,e,n,i){},r.prototype.isReady=function(t,e,n,i){return!0},r.prototype._linkConnectionTypes=function(t,e,n){n===void 0&&(n=!1),n?this._inputs[e]._acceptedConnectionPointType=this._inputs[t]:this._inputs[t]._linkedConnectionSource=this._inputs[e],this._inputs[e]._linkedConnectionSource=this._inputs[t]},r.prototype._processBuild=function(t,e,n,i){t.build(e,i);var o=e._vertexState!=null,a=t._buildTarget===Re.Vertex&&t.target!==Re.VertexAndFragment;if(o&&(!(t.target&t._buildTarget)||!(t.target&n.target)||this.target!==Re.VertexAndFragment&&a)&&(!t.isInput&&e.target!==t._buildTarget||t.isInput&&t.isAttribute&&!t._noContextSwitch)){var s=n.connectedPoint;e._vertexState._emitVaryingFromString("v_"+s.associatedVariableName,e._getGLType(s.type))&&(e._vertexState.compilationString+="v_"+s.associatedVariableName+" = "+s.associatedVariableName+`;\r
7401`),n.associatedVariableName="v_"+s.associatedVariableName,n._enforceAssociatedVariableName=!0}},r.prototype.validateBlockName=function(t){for(var e=0,n=["position","normal","tangent","particle_positionw","uv","uv2","position2d","particle_uv","matricesIndices","matricesWeights","world0","world1","world2","world3","particle_color","particle_texturemask"];e<n.length;e++)if(t===n[e])return!1;return!0},r.prototype.build=function(t,e){if(this._buildId===t.sharedData.buildId)return!0;
7401if(!this.isInput)for(var n=0,i=this._outputs;n<i.length;n++)(y=i[n]).associatedVariableName||(y.associatedVariableName=t._getFreeVariableName(y.name));for(var o=0,a=this._inputs;o<a.length;o++){var s=a[o];if(s.connectedPoint){if(this.target!==Re.Neutral&&(!(s.target&this.target)||!(s.target&t.target)))continue;(U=s.connectedPoint.ownerBlock)&&U!==this&&this._processBuild(U,t,s,e)}else s.isOptional||t.sharedData.checks.notConnectedNonOptionalInputs.push(s)}if(this._buildId===t.sharedData.buildId)return!0;if(t.sharedData.verbose&&console.log((t.target===Re.Vertex?"Vertex shader":"Fragment shader")+": Building "+this.name+" ["+this.getClassName()+"]"),this.isFinalMerger)switch(t.target){case Re.Vertex:t.sharedData.checks.emitVertex=!0;break;case Re.Fragment:t.sharedData.checks.emitFragment=!0}!this.isInput&&t.sharedData.emitComments&&(t.compilationString+=`\r
7402//`+this.name+`\r
7403`),this._buildBlock(t),this._buildId=t.sharedData.buildId,this._buildTarget=t.target;for(var d=0,p=this._outputs;d<p.length;d++){var y;if((y=p[d]).target&t.target)for(var P=0,O=y.endpoints;P<O.length;P++){var U,F=O[P];(U=F.ownerBlock)&&U.target&t.target&&e.indexOf(U)!==-1&&this._processBuild(U,t,F,e)}}return!1},r.prototype._inputRename=function(t){return t},r.prototype._outputRename=function(t){return t},r.prototype._dumpPropertiesCode=function(){return this._codeVariableName+".visibleInInspector = "+this.visibleInInspector+`;\r
7404`},r.prototype._dumpCode=function(t,e){var n;e.push(this);var i=this.name.replace(/[^A-Za-z_]+/g,"");if(this._codeVariableName=i||this.getClassName()+"_"+this.uniqueId,t.indexOf(this._codeVariableName)!==-1){var o=0;do o++,this._codeVariableName=i+o;while(t.indexOf(this._codeVariableName)!==-1)}t.push(this._codeVariableName),n=`\r
7405// `+this.getClassName()+`\r
7406`,this.comments&&(n+="// "+this.comments+`\r
7407`),n+="var "+this._codeVariableName+" = new BABYLON."+this.getClassName()+'("'+this.name+`");\r
7408`,n+=this._dumpPropertiesCode();for(var a=0,s=this.inputs;a<s.length;a++){var d=s[a];if(d.isConnected){var p=d.connectedPoint.ownerBlock;e.indexOf(p)===-1&&(n+=p._dumpCode(t,e))}}for(var y=0,P=this.outputs;y<P.length;y++){var O=P[y];if(O.hasEndpoints)for(var U=0,F=O.endpoints;U<F.length;U++)(p=F[U].ownerBlock)&&e.indexOf(p)===-1&&(n+=p._dumpCode(t,e))}return n},r.prototype._dumpCodeForOutputConnections=function(t){var e="";if(t.indexOf(this)!==-1)return e;t.push(this);for(var n=0,i=this.inputs;n<i.length;n++){var o=i[n];if(o.isConnected){var a=o.connectedPoint,s=a.ownerBlock;e+=s._dumpCodeForOutputConnections(t),e+=s._codeVariableName+"."+s._outputRename(a.name)+".connectTo("+this._codeVariableName+"."+this._inputRename(o.name)+`);\r
7409`}}return e},r.prototype.clone=function(t,e){e===void 0&&(e="");var n=this.serialize(),i=R.a.GetClass(n.customType);if(i){var o=new i;return o._deserialize(n,t,e),o}return null},r.prototype.serialize=function(){var t={};t.customType="BABYLON."+this.getClassName(),t.id=this.uniqueId,t.name=this.name,t.comments=this.comments,t.visibleInInspector=this.visibleInInspector,t.inputs=[],t.outputs=[];for(var e=0,n=this.inputs;e<n.length;e++){var i=n[e];t.inputs.push(i.serialize())}for(var o=0,a=this.outputs;o<a.length;o++){var s=a[o];t.outputs.push(s.serialize(!1))}return t},r.prototype._deserialize=function(t,e,n){this.name=t.name,this.comments=t.comments,this.visibleInInspector=!!t.visibleInInspector,this._deserializePortDisplayNamesAndExposedOnFrame(t)},r.prototype._deserializePortDisplayNamesAndExposedOnFrame=function(t){var e=this,n=t.inputs,i=t.outputs;n&&n.forEach(function(o,a){o.displayName&&(e.inputs[a].displayName=o.displayName),o.isExposedOnFrame&&(e.inputs[a].isExposedOnFrame=o.isExposedOnFrame,e.inputs[a].exposedPortPosition=o.exposedPortPosition)}),i&&i.forEach(function(o,a){o.displayName&&(e.outputs[a].displayName=o.displayName),o.isExposedOnFrame&&(e.outputs[a].isExposedOnFrame=o.isExposedOnFrame,e.outputs[a].exposedPortPosition=o.exposedPortPosition)})},r.prototype.dispose=function(){for(var t=0,e=this.inputs;t<e.length;t++)e[t].dispose();for(var n=0,i=this.outputs;n<i.length;n++)i[n].dispose()},r}(),bh=function(){function r(){this.supportUniformBuffers=!1,this.attributes=new Array,this.uniforms=new Array,this.constants=new Array,this.samplers=new Array,this.functions={},this.extensions={},this.counters={},this._attributeDeclaration="",this._uniformDeclaration="",this._constantDeclaration="",this._samplerDeclaration="",this._varyingTransfer="",this._injectAtEnd="",this._repeatableContentAnchorIndex=0,this._builtCompilationString="",this.compilationString=""}return r.prototype.finalize=function(t){var e=t.sharedData.emitComments,n=this.target===Re.Fragment;this.compilationString=`\r
7410`+(e?`//Entry point\r
7411`:"")+`void main(void) {\r
7412`+this.compilationString,this._constantDeclaration&&(this.compilationString=`\r
7413`+(e?`//Constants\r
7414`:"")+this._constantDeclaration+`\r
7415`+this.compilationString);var i="";for(var o in this.functions)i+=this.functions[o]+`\r
7416`;for(var a in this.compilationString=`\r
7417`+i+`\r
7418`+this.compilationString,!n&&this._varyingTransfer&&(this.compilationString=this.compilationString+`\r
7419`+this._varyingTransfer),this._injectAtEnd&&(this.compilationString=this.compilationString+`\r
7420`+this._injectAtEnd),this.compilationString=this.compilationString+`\r
7421}`,this.sharedData.varyingDeclaration&&(this.compilationString=`\r
7422`+(e?`//Varyings\r
7423`:"")+this.sharedData.varyingDeclaration+`\r
7424`+this.compilationString),this._samplerDeclaration&&(this.compilationString=`\r
7425`+(e?`//Samplers\r
7426`:"")+this._samplerDeclaration+`\r
7427`+this.compilationString),this._uniformDeclaration&&(this.compilationString=`\r
7428`+(e?`//Uniforms\r
7429`:"")+this._uniformDeclaration+`\r
7430`+this.compilationString),this._attributeDeclaration&&!n&&(this.compilationString=`\r
7431`+(e?`//Attributes\r
7432`:"")+this._attributeDeclaration+`\r
7433`+this.compilationString),this.compilationString=`precision highp float;\r
7434`+this.compilationString,this.extensions){var s=this.extensions[a];this.compilationString=`\r
7435`+s+`\r
7436`+this.compilationString}this._builtCompilationString=this.compilationString},Object.defineProperty(r.prototype,"_repeatableContentAnchor",{get:function(){return"###___ANCHOR"+this._repeatableContentAnchorIndex+++"___###"}
7436,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){this.samplers.indexOf(t)<0&&(this._samplerDeclaration+="uniform sampler2D "+t+`;\r
7437`,this.samplers.push(t))},r.prototype._getGLType=function(t){switch(t){case le.Float:return"float";case le.Int:return"int";case le.Vector2:return"vec2";case le.Color3:case le.Vector3:return"vec3";case le.Color4:case le.Vector4:return"vec4";case le.Matrix:return"mat4"}return""},r.prototype._emitExtension=function(t,e,n){n===void 0&&(n=""),this.extensions[t]||(n&&(e="#if "+n+`\r
7438`+e+`\r
7439#endif`),this.extensions[t]=e)},r.prototype._emitFunction=function(t,e,n){this.functions[t]||(this.sharedData.emitComments&&(e=n+`\r
7440`+e),this.functions[t]=e)},r.prototype._emitCodeFromInclude=function(t,e,n){if(n&&n.repeatKey)return"#include<"+t+">[0.."+n.repeatKey+`]\r
7441`;var i=je.a.IncludesShadersStore[t]+`\r
7442`;if(this.sharedData.emitComments&&(i=e+`\r
7443`+i),!n)return i;if(n.replaceStrings)for(var o=0;o<n.replaceStrings.length;o++){var a=n.replaceStrings[o];i=i.replace(a.search,a.replace)}return i},r.prototype._emitFunctionFromInclude=function(t,e,n,i){i===void 0&&(i="");var o=t+i;if(!this.functions[o]){if(!(n&&(n.removeAttributes||n.removeUniforms||n.removeVaryings||n.removeIfDef||n.replaceStrings)))return n&&n.repeatKey?this.functions[o]="#include<"+t+">[0.."+n.repeatKey+`]\r
7444`:this.functions[o]="#include<"+t+`>\r
7445`,void(this.sharedData.emitComments&&(this.functions[o]=e+`\r
7446`+this.functions[o]));if(this.functions[o]=je.a.IncludesShadersStore[t],this.sharedData.emitComments&&(this.functions[o]=e+`\r
7447`+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.+$/gm,"")),n.removeUniforms&&(this.functions[o]=this.functions[o].replace(/^\s*?uniform.+$/gm,"")),n.removeVaryings&&(this.functions[o]=this.functions[o].replace(/^\s*?varying.+$/gm,"")),n.replaceStrings)for(var a=0;a<n.replaceStrings.length;a++){var s=n.replaceStrings[a];this.functions[o]=this.functions[o].replace(s.search,s.replace)}}},r.prototype._registerTempVariable=function(t){return this.sharedData.temps.indexOf(t)===-1&&(this.sharedData.temps.push(t),!0)},r.prototype._emitVaryingFromString=function(t,e,n,i){return n===void 0&&(n=""),i===void 0&&(i=!1),this.sharedData.varyings.indexOf(t)===-1&&(this.sharedData.varyings.push(t),n&&(Xn.a.StartsWith(n,"defined(")?this.sharedData.varyingDeclaration+="#if "+n+`\r
7448`:this.sharedData.varyingDeclaration+=(i?"#ifndef":"#ifdef")+" "+n+`\r
7449`),this.sharedData.varyingDeclaration+="varying "+e+" "+t+`;\r
7450`,n&&(this.sharedData.varyingDeclaration+=`#endif\r
7451`),!0)},r.prototype._emitUniformFromString=function(t,e,n,i){n===void 0&&(n=""),i===void 0&&(i=!1),this.uniforms.indexOf(t)===-1&&(this.uniforms.push(t),n&&(Xn.a.StartsWith(n,"defined(")?this._uniformDeclaration+="#if "+n+`\r
7452`:this._uniformDeclaration+=(i?"#ifndef":"#ifdef")+" "+n+`\r
7453`),this._uniformDeclaration+="uniform "+e+" "+t+`;\r
7454`,n&&(this._uniformDeclaration+=`#endif\r
7455`))},r.prototype._emitFloat=function(t){return t.toString()===t.toFixed(0)?t+".0":t.toString()},r}(),Im=function(){function r(){this.temps=new Array,this.varyings=new Array,this.varyingDeclaration="",this.inputBlocks=new Array,this.textureBlocks=new Array,this.bindableBlocks=new Array,this.blocksWithFallbacks=new Array,this.blocksWithDefines=new Array,this.repeatableContentBlocks=new Array,this.dynamicUniformBlocks=new Array,this.blockingBlocks=new Array,this.animatedInputs=new Array,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.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(){var t="";this.checks.emitVertex||this.allowEmptyVertexProgram||(t+=`NodeMaterial does not have a vertex output. You need to at least add a block that generates a glPosition value.\r
7456`),this.checks.emitFragment||(t+=`NodeMaterial does not have a fragment output. You need to at least add a block that generates a glFragColor value.\r
7457`);for(var e=0,n=this.checks.notConnectedNonOptionalInputs;e<n.length;e++){var i=n[e];t+="input "+i.name+" from block "+i.ownerBlock.name+"["+i.ownerBlock.getClassName()+`] is not connected and is not optional.\r
7458`}if(t)throw`Build of NodeMaterial failed:\r
7459`+t},r}(),ma=function(r){function t(e){var n=r.call(this,e,Re.Vertex)||this;return n.complementW=1,n.complementZ=0,n.registerInput("vector",le.AutoDetect),n.registerInput("transform",le.Matrix),n.registerOutput("output",le.Vector4),n.registerOutput("xyz",le.Vector3),n._inputs[0].onConnectionObservable.add(function(i){if(i.ownerBlock.isInput){var o=i.ownerBlock;o.name!=="normal"&&o.name!=="tangent"||(n.complementW=0)}}),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"TransformBlock"},Object.defineProperty(t.prototype,"vector",{get:function(){return this._inputs[0]}
7459,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyz",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"transform",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this.vector,i=this.transform;if(n.connectedPoint){if(this.complementW===0){var o="//"+this.name;e._emitFunctionFromInclude("helperFunctions",o),e.sharedData.blocksWithDefines.push(this);var a=e._getFreeVariableName(i.associatedVariableName+"_NUS");switch(e.compilationString+="mat3 "+a+" = mat3("+i.associatedVariableName+`);\r
7460`,e.compilationString+=`#ifdef NONUNIFORMSCALING\r
7461`,e.compilationString+=a+" = transposeMat3(inverseMat3("+a+`));\r
7462`,e.compilationString+=`#endif\r
7463`,n.connectedPoint.type){case le.Vector2:e.compilationString+=this._declareOutput(this.output,e)+" = vec4("+a+" * vec3("+n.associatedVariableName+", "+this._writeFloat(this.complementZ)+"), "+this._writeFloat(this.complementW)+`);\r
7464`;break;case le.Vector3:case le.Color3:e.compilationString+=this._declareOutput(this.output,e)+" = vec4("+a+" * "+n.associatedVariableName+", "+this._writeFloat(this.complementW)+`);\r
7465`;break;default:e.compilationString+=this._declareOutput(this.output,e)+" = vec4("+a+" * "+n.associatedVariableName+".xyz, "+this._writeFloat(this.complementW)+`);\r
7466`}}else switch(a=i.associatedVariableName,n.connectedPoint.type){case le.Vector2:e.compilationString+=this._declareOutput(this.output,e)+" = "+a+" * vec4("+n.associatedVariableName+", "+this._writeFloat(this.complementZ)+", "+this._writeFloat(this.complementW)+`);\r
7467`;break;case le.Vector3:case le.Color3:e.compilationString+=this._declareOutput(this.output,e)+" = "+a+" * vec4("+n.associatedVariableName+", "+this._writeFloat(this.complementW)+`);\r
7468`;break;default:e.compilationString+=this._declareOutput(this.output,e)+" = "+a+" * "+n.associatedVariableName+`;\r
7469`}this.xyz.hasEndpoints&&(e.compilationString+=this._declareOutput(this.xyz,e)+" = "+this.output.associatedVariableName+`.xyz;\r
7470`)}return this},t.prototype.prepareDefines=function(e,n,i,o,a){e.nonUniformScaling&&i.setValue("NONUNIFORMSCALING",!0)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.complementZ=this.complementZ,e.complementW=this.complementW,e},t.prototype._deserialize=function(e,n,i){r.prototype._deserialize.call(this,e,n,i),this.complementZ=e.complementZ!==void 0?e.complementZ:0,this.complementW=e.complementW!==void 0?e.complementW:1},t.prototype._dumpPropertiesCode=function(){var e=this._codeVariableName+".complementZ = "+this.complementZ+`;\r
7471`;return e+=this._codeVariableName+".complementW = "+this.complementW+`;\r
7472`},t}(pt);R.a.RegisteredTypes["BABYLON.TransformBlock"]=ma;var go=function(r){function t(e){var n=r.call(this,e,Re.Vertex,!0)||this;return n.registerInput("vector",le.Vector4),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"VertexOutputBlock"},Object.defineProperty(t.prototype,"vector",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this.vector;return e.compilationString+="gl_Position = "+n.associatedVariableName+`;\r
7473`,this},t}(pt);R.a.RegisteredTypes["BABYLON.VertexOutputBlock"]=go;var ki,Dr=function(r){function t(e){var n=r.call(this,e,Re.Fragment,!0)||this;return n.registerInput("rgba",le.Color4,!0),n.registerInput("rgb",le.Color3,!0),n.registerInput("a",le.Float,!0),n.rgb.acceptedConnectionPointTypes.push(le.Float),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"FragmentOutputBlock"},Object.defineProperty(t.prototype,"rgba",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgb",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"a",{get:function(){return this._inputs[2]}
7473,enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this.rgba,i=this.rgb,o=this.a;if(e.sharedData.hints.needAlphaBlending=n.isConnected||o.isConnected,n.connectedPoint)o.isConnected?e.compilationString+="gl_FragColor = vec4("+n.associatedVariableName+".rgb, "+o.associatedVariableName+`);\r
7474`:e.compilationString+="gl_FragColor = "+n.associatedVariableName+`;\r
7475`;else if(i.connectedPoint){var a="1.0";o.connectedPoint&&(a=o.associatedVariableName),i.connectedPoint.type===le.Float?e.compilationString+="gl_FragColor = vec4("+i.associatedVariableName+", "+i.associatedVariableName+", "+i.associatedVariableName+", "+a+`);\r
7476`:e.compilationString+="gl_FragColor = vec4("+i.associatedVariableName+", "+a+`);\r
7477`}else e.sharedData.checks.notConnectedNonOptionalInputs.push(n);return this},t}(pt);R.a.RegisteredTypes["BABYLON.FragmentOutputBlock"]=Dr,function(r){r[r.None=0]="None",r[r.Time=1]="Time"}(ki||(ki={}));var Dm={position2d:"position",particle_uv:"vUV",particle_color:"vColor",particle_texturemask:"textureMask",particle_positionw:"vPositionW"},ic={particle_uv:!0,particle_color:!0,particle_texturemask:!0,particle_positionw:!0},yh={particle_texturemask:!0},At=function(r){function t(e,n,i){n===void 0&&(n=Re.Vertex),i===void 0&&(i=le.AutoDetect);var o=r.call(this,e,n,!1,!0)||this;return o._mode=gn.Undefined,o._animationType=ki.None,o.min=0,o.max=0,o.isBoolean=!1,o.matrixMode=0,o._systemValue=null,o.isConstant=!1,o.groupInInspector="",o.onValueChangedObservable=new x.c,o.convertToGammaSpace=!1,o.convertToLinearSpace=!1,o._type=i,o.setDefaultValue(),o.registerOutput("output",i),o}return Object(c.d)(t,r),Object.defineProperty(t.prototype,"type",{get:function(){if(this._type===le.AutoDetect){if(this.isUniform&&this.value!=null){if(!isNaN(this.value))return this._type=le.Float,this._type;switch(this.value.getClassName()){case"Vector2":return this._type=le.Vector2,this._type;case"Vector3":return this._type=le.Vector3,this._type;case"Vector4":return this._type=le.Vector4,this._type;case"Color3":return this._type=le.Color3,this._type;case"Color4":return this._type=le.Color4,this._type;case"Matrix":return this._type=le.Matrix,this._type}}if(this.isAttribute)switch(this.name){case"position":case"normal":case"tangent":case"particle_positionw":return this._type=le.Vector3,this._type;case"uv":case"uv2":case"position2d":case"particle_uv":return this._type=le.Vector2,this._type;case"matricesIndices":case"matricesWeights":case"world0":case"world1":case"world2":case"world3":return this._type=le.Vector4,this._type;case"color":case"particle_color":case"particle_texturemask":return this._type=le.Color4,this._type}if(this.isSystemValue)switch(this._systemValue){case bt.World:case bt.WorldView:case bt.WorldViewProjection:case bt.View:case bt.ViewProjection:case bt.Projection:return this._type=le.Matrix,this._type;case bt.CameraPosition:return this._type=le.Vector3,this._type;case bt.FogColor:return this._type=le.Color3,this._type;case bt.DeltaTime:return this._type=le.Float,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=gn.Attribute,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===le.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=gn.Uniform,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=gn.Uniform},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"associatedVariableName",{get:function(){return this._associatedVariableName},set:function(e){this._associatedVariableName=e}
7477,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===gn.Undefined},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isUniform",{get:function(){return this._mode===gn.Uniform},set:function(e){this._mode=e?gn.Uniform:gn.Undefined,this.associatedVariableName=""},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isAttribute",{get:function(){return this._mode===gn.Attribute},set:function(e){this._mode=e?gn.Attribute:gn.Undefined,this.associatedVariableName=""},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isVarying",{get:function(){return this._mode===gn.Varying},set:function(e){this._mode=e?gn.Varying:gn.Undefined,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=gn.Uniform,this.associatedVariableName="",this._systemValue=e},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"InputBlock"},t.prototype.animate=function(e){switch(this._animationType){case ki.Time:this.type===le.Float&&(this.value+=.01*e.getAnimationRatio())}},t.prototype._emitDefine=function(e){return e[0]==="!"?"#ifndef "+e.substring(1)+`\r
7478`:"#ifdef "+e+`\r
7479`},t.prototype.initialize=function(e){this.associatedVariableName=""},t.prototype.setDefaultValue=function(){switch(this.type){case le.Float:this.value=0;break;case le.Vector2:this.value=u.d.Zero();break;case le.Vector3:this.value=u.e.Zero();break;case le.Vector4:this.value=u.f.Zero();break;case le.Color3:this.value=M.a.White();break;case le.Color4:this.value=new M.b(1,1,1,1);break;case le.Matrix:this.value=u.a.Identity()}},t.prototype._emitConstant=function(e){switch(this.type){case le.Float:return""+e._emitFloat(this.value);case le.Vector2:return"vec2("+this.value.x+", "+this.value.y+")";case le.Vector3:return"vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")";case le.Vector4:return"vec4("+this.value.x+", "+this.value.y+", "+this.value.z+", "+this.value.w+")";case le.Color3:return M.c.Color3[0].set(this.value.r,this.value.g,this.value.b),this.convertToGammaSpace&&M.c.Color3[0].toGammaSpaceToRef(M.c.Color3[0]),this.convertToLinearSpace&&M.c.Color3[0].toLinearSpaceToRef(M.c.Color3[0]),"vec3("+M.c.Color3[0].r+", "+M.c.Color3[0].g+", "+M.c.Color3[0].b+")";case le.Color4:return M.c.Color4[0].set(this.value.r,this.value.g,this.value.b,this.value.a),this.convertToGammaSpace&&M.c.Color4[0].toGammaSpaceToRef(M.c.Color4[0]),this.convertToLinearSpace&&M.c.Color4[0].toLinearSpaceToRef(M.c.Color4[0]),"vec4("+M.c.Color4[0].r+", "+M.c.Color4[0].g+", "+M.c.Color4[0].b+", "+M.c.Color4[0].a+")"}return""},Object.defineProperty(t.prototype,"_noContextSwitch",{get:function(){return ic[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+=this._declareOutput(this.output,e)+" = "+this._emitConstant(e)+`;\r
7480`));if(e.uniforms.indexOf(this.associatedVariableName)!==-1)return;e.uniforms.push(this.associatedVariableName),n&&(e._uniformDeclaration+=this._emitDefine(n)),e._uniformDeclaration+="uniform "+e._getGLType(this.type)+" "+this.associatedVariableName+`;\r
7481`,n&&(e._uniformDeclaration+=`#endif\r
7482`);var o=e.sharedData.hints;if(this._systemValue!==null&&this._systemValue!==void 0)switch(this._systemValue){case bt.WorldView:o.needWorldViewMatrix=!0;break;case bt.WorldViewProjection:o.needWorldViewProjectionMatrix=!0}else this._animationType!==ki.None&&e.sharedData.animatedInputs.push(this)}else if(this.isAttribute){if(this.associatedVariableName=(i=Dm[this.name])!==null&&i!==void 0?i:this.name,this.target===Re.Vertex&&e._vertexState)return void(ic[this.name]?yh[this.name]?e._emitUniformFromString(this.associatedVariableName,e._getGLType(this.type),n):e._emitVaryingFromString(this.associatedVariableName,e._getGLType(this.type),n):this._emit(e._vertexState,n));if(e.attributes.indexOf(this.associatedVariableName)!==-1)return;e.attributes.push(this.associatedVariableName),ic[this.name]?yh[this.name]?e._emitUniformFromString(this.associatedVariableName,e._getGLType(this.type),n):e._emitVaryingFromString(this.associatedVariableName,e._getGLType(this.type),n):(n&&(e._attributeDeclaration+=this._emitDefine(n)),e._attributeDeclaration+="attribute "+e._getGLType(this.type)+" "+this.associatedVariableName+`;\r
7483`,n&&(e._attributeDeclaration+=`#endif\r
7484`))}},t.prototype._transmitWorld=function(e,n,i,o){if(this._systemValue){var a=this.associatedVariableName;
7484switch(this._systemValue){case bt.World:e.setMatrix(a,n);break;case bt.WorldView:e.setMatrix(a,i);break;case bt.WorldViewProjection:e.setMatrix(a,o)}}},t.prototype._transmit=function(e,n){if(!this.isAttribute){var i=this.associatedVariableName;if(this._systemValue)switch(this._systemValue){case bt.World:case bt.WorldView:case bt.WorldViewProjection:return;case bt.View:e.setMatrix(i,n.getViewMatrix());break;case bt.Projection:e.setMatrix(i,n.getProjectionMatrix());break;case bt.ViewProjection:e.setMatrix(i,n.getTransformMatrix());break;case bt.CameraPosition:tt.a.BindEyePosition(e,n,i);break;case bt.FogColor:e.setColor3(i,n.fogColor);break;case bt.DeltaTime:e.setFloat(i,n.deltaTime/1e3)}else{var o=this._valueCallback?this._valueCallback():this._storedValue;if(o!==null)switch(this.type){case le.Float:e.setFloat(i,o);break;case le.Int:e.setInt(i,o);break;case le.Color3:M.c.Color3[0].set(this.value.r,this.value.g,this.value.b),this.convertToGammaSpace&&M.c.Color3[0].toGammaSpaceToRef(M.c.Color3[0]),this.convertToLinearSpace&&M.c.Color3[0].toLinearSpaceToRef(M.c.Color3[0]),e.setColor3(i,M.c.Color3[0]);break;case le.Color4:M.c.Color4[0].set(this.value.r,this.value.g,this.value.b,this.value.a),this.convertToGammaSpace&&M.c.Color4[0].toGammaSpaceToRef(M.c.Color4[0]),this.convertToLinearSpace&&M.c.Color4[0].toLinearSpaceToRef(M.c.Color4[0]),e.setDirectColor4(i,M.c.Color4[0]);break;case le.Vector2:e.setVector2(i,o);break;case le.Vector3:e.setVector3(i,o);break;case le.Vector4:e.setVector4(i,o);break;case le.Matrix:e.setMatrix(i,o)}}}},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 e+'.setAsAttribute("'+this.name+`");\r
7485`;if(this.isSystemValue)return e+".setAsSystemValue(BABYLON.NodeMaterialSystemValues."+bt[this._systemValue]+`);\r
7486`;if(this.isUniform){var n=[],i="";switch(this.type){case le.Float:i=""+this.value;break;case le.Vector2:i="new BABYLON.Vector2("+this.value.x+", "+this.value.y+")";break;case le.Vector3:i="new BABYLON.Vector3("+this.value.x+", "+this.value.y+", "+this.value.z+")";break;case le.Vector4:i="new BABYLON.Vector4("+this.value.x+", "+this.value.y+", "+this.value.z+", "+this.value.w+")";break;case le.Color3:i="new BABYLON.Color3("+this.value.r+", "+this.value.g+", "+this.value.b+")",this.convertToGammaSpace&&(i+=".toGammaSpace()"),this.convertToLinearSpace&&(i+=".toLinearSpace()");break;case le.Color4:i="new BABYLON.Color4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",this.convertToGammaSpace&&(i+=".toGammaSpace()"),this.convertToLinearSpace&&(i+=".toLinearSpace()");break;case le.Matrix:i="BABYLON.Matrix.FromArray(["+this.value.m+"])"}return n.push(e+".value = "+i),this.type===le.Float&&n.push(e+".min = "+this.min,e+".max = "+this.max,e+".isBoolean = "+this.isBoolean,e+".matrixMode = "+this.matrixMode,e+".animationType = BABYLON.AnimatedInputBlockTypes."+ki[this.animationType]),n.push(e+".isConstant = "+this.isConstant),n.push(""),n.join(`;\r
7487`)}return""},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===gn.Uniform&&(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.matrixM
7487ode=e.matrixMode||0,this.isConstant=!!e.isConstant,this.groupInInspector=e.groupInInspector||"",this.convertToGammaSpace=!!e.convertToGammaSpace,this.convertToLinearSpace=!!e.convertToLinearSpace,e.valueType)if(e.valueType==="number")this._storedValue=e.value;else{var o=R.a.GetClass(e.valueType);o&&(this._storedValue=o.FromArray(e.value))}},t}(pt);R.a.RegisteredTypes["BABYLON.InputBlock"]=At;var rc=function(r){function t(e){var n=r.call(this,e,Re.VertexAndFragment)||this;return n._samplerName="textureSampler",n.convertToGammaSpace=!1,n.convertToLinearSpace=!1,n._isUnique=!1,n.registerInput("uv",le.Vector2,!1,Re.VertexAndFragment),n.registerOutput("rgba",le.Color4,Re.Neutral),n.registerOutput("rgb",le.Color3,Re.Neutral),n.registerOutput("r",le.Float,Re.Neutral),n.registerOutput("g",le.Float,Re.Neutral),n.registerOutput("b",le.Float,Re.Neutral),n.registerOutput("a",le.Float,Re.Neutral),n._inputs[0].acceptedConnectionPointTypes.push(le.Vector3),n._inputs[0].acceptedConnectionPointTypes.push(le.Vector4),n._inputs[0]._prioritizeVertex=!1,n}return Object(c.d)(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("textureSampler")},Object.defineProperty(t.prototype,"target",{get:function(){return this.uv.isConnected?this.uv.sourceBlock.isInput?Re.VertexAndFragment:Re.Fragment:Re.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,"vec2")),this._mainUVName="vMain"+n.associatedVariableName,e._emitVaryingFromString(this._mainUVName,"vec2"),e.compilationString+=this._mainUVName+" = "+n.associatedVariableName+`.xy;\r
7488`,this._outputs.some(function(s){return s.isConnectedInVertexShader})){this._writeTextureRead(e,!0);for(var i=0,o=this._outputs;i<o.length;i++){var a=o[i];a.hasEndpoints&&this._writeOutput(e,a,a.name,!0)}}}
7488,t.prototype._writeTextureRead=function(e,n){n===void 0&&(n=!1);var i=this.uv;if(n){if(e.target===Re.Fragment)return;e.compilationString+="vec4 "+this._tempTextureRead+" = texture2D("+this._samplerName+", "+i.associatedVariableName+`);\r
7489`}else this.uv.ownerBlock.target!==Re.Fragment?e.compilationString+="vec4 "+this._tempTextureRead+" = texture2D("+this._samplerName+", "+this._mainUVName+`);\r
7490`:e.compilationString+="vec4 "+this._tempTextureRead+" = texture2D("+this._samplerName+", "+i.associatedVariableName+`);\r
7491`},t.prototype._writeOutput=function(e,n,i,o){if(o===void 0&&(o=!1),o){if(e.target===Re.Fragment)return;e.compilationString+=this._declareOutput(n,e)+" = "+this._tempTextureRead+"."+i+`;\r
7492`}else this.uv.ownerBlock.target!==Re.Fragment?(e.compilationString+=this._declareOutput(n,e)+" = "+this._tempTextureRead+"."+i+`;\r
7493`,e.compilationString+="#ifdef "+this._linearDefineName+`\r
7494`,e.compilationString+=n.associatedVariableName+" = toGammaSpace("+n.associatedVariableName+`);\r
7495`,e.compilationString+=`#endif\r
7496`,e.compilationString+="#ifdef "+this._gammaDefineName+`\r
7497`,e.compilationString+=n.associatedVariableName+" = toLinearSpace("+n.associatedVariableName+`);\r
7498`,e.compilationString+=`#endif\r
7499`):e.compilationString+=this._declareOutput(n,e)+" = "+this._tempTextureRead+"."+i+`;\r
7500`},t.prototype._buildBlock=function(e){if(r.prototype._buildBlock.call(this,e),this._tempTextureRead=e._getFreeVariableName("tempTextureRead"),e.sharedData.blockingBlocks.indexOf(this)<0&&e.sharedData.blockingBlocks.push(this),e.sharedData.textureBlocks.indexOf(this)<0&&e.sharedData.textureBlocks.push(this),e.sharedData.blocksWithDefines.indexOf(this)<0&&e.sharedData.blocksWithDefines.push(this),e.target!==Re.Fragment)return e._emit2DSampler(this._samplerName),void this._injectVertexCode(e);if(this._outputs.some(function(s){return s.isConnectedInFragmentShader})){e._emit2DSampler(this._samplerName),this._linearDefineName=e._getFreeDefineName("ISLINEAR"),this._gammaDefineName=e._getFreeDefineName("ISGAMMA");var n="//"+this.name;e._emitFunctionFromInclude("helperFunctions",n),this._writeTextureRead(e);for(var i=0,o=this._outputs;i<o.length;i++){var a=o[i];a.hasEndpoints&&this._writeOutput(e,a,a.name)}return this}},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.convertToGammaSpace=this.convertToGammaSpace,e.convertToLinearSpace=this.convertToLinearSpace,this.texture&&(e.texture=this.texture.serialize()),e},t.prototype._deserialize=function(e,n,i){r.prototype._deserialize.call(this,e,n,i),this.convertToGammaSpace=e.convertToGammaSpace,this.convertToLinearSpace=!!e.convertToLinearSpace,e.texture&&(i=e.texture.url.indexOf("data:")===0?"":i,this.texture=we.a.Parse(e.texture,n,i))},t}(pt);R.a.RegisteredTypes["BABYLON.CurrentScreenBlock"]=rc;var oc=function(r){function t(e){var n=r.call(this,e,Re.Fragment)||this;return n._samplerName="diffuseSampler",n.convertToGammaSpace=!1,n.convertToLinearSpace=!1,n._isUnique=!1,n.registerInput("uv",le.Vector2,!1,Re.VertexAndFragment),n.registerOutput("rgba",le.Color4,Re.Neutral),n.registerOutput("rgb",le.Color3,Re.Neutral),n.registerOutput("r",le.Float,Re.Neutral),n.registerOutput("g",le.Float,Re.Neutral),n.registerOutput("b",le.Float,Re.Neutral),n.registerOutput("a",le.Float,Re.Neutral),n._inputs[0].acceptedConnectionPointTypes.push(le.Vector3),n._inputs[0].acceptedConnectionPointTypes.push(le.Vector4),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"ParticleTextureBlock"},Object.defineProperty(t.prototype,"uv",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgba",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgb",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"r",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"g",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"b",{get:function(){return this._outputs[4]}
7500,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"a",{get:function(){return this._outputs[5]},enumerable:!1,configurable:!0}),t.prototype.initialize=function(e){e._excludeVariableName("diffuseSampler")},t.prototype.autoConfigure=function(e){if(!this.uv.isConnected){var n=e.getInputBlockByPredicate(function(i){return i.isAttribute&&i.name==="particle_uv"});n||(n=new At("uv")).setAsAttribute("particle_uv"),n.output.connectTo(this.uv)}},t.prototype.prepareDefines=function(e,n,i){i.setValue(this._linearDefineName,this.convertToGammaSpace,!0),i.setValue(this._gammaDefineName,this.convertToLinearSpace,!0)},t.prototype.isReady=function(){return!(this.texture&&!this.texture.isReadyOrNotBlocking())},t.prototype._writeOutput=function(e,n,i){e.compilationString+=this._declareOutput(n,e)+" = "+this._tempTextureRead+"."+i+`;\r
7501`,e.compilationString+="#ifdef "+this._linearDefineName+`\r
7502`,e.compilationString+=n.associatedVariableName+" = toGammaSpace("+n.associatedVariableName+`);\r
7503`,e.compilationString+=`#endif\r
7504`,e.compilationString+="#ifdef "+this._gammaDefineName+`\r
7505`,e.compilationString+=n.associatedVariableName+" = toLinearSpace("+n.associatedVariableName+`);\r
7506`,e.compilationString+=`#endif\r
7507`},t.prototype._buildBlock=function(e){if(r.prototype._buildBlock.call(this,e),e.target!==Re.Vertex){this._tempTextureRead=e._getFreeVariableName("tempTextureRead"),e._emit2DSampler(this._samplerName),e.sharedData.blockingBlocks.push(this),e.sharedData.textureBlocks.push(this),e.sharedData.blocksWithDefines.push(this),this._linearDefineName=e._getFreeDefineName("ISLINEAR"),this._gammaDefineName=e._getFreeDefineName("ISGAMMA");var n="//"+this.name;e._emitFunctionFromInclude("helperFunctions",n),e.compilationString+="vec4 "+this._tempTextureRead+" = texture2D("+this._samplerName+", "+this.uv.associatedVariableName+`);\r
7508`;for(var i=0,o=this._outputs;i<o.length;i++){var a=o[i];a.hasEndpoints&&this._writeOutput(e,a,a.name)}return this}},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.convertToGammaSpace=this.convertToGammaSpace,e.convertToLinearSpace=this.convertToLinearSpace,this.texture&&(e.texture=this.texture.serialize()),e},t.prototype._deserialize=function(e,n,i){r.prototype._deserialize.call(this,e,n,i),this.convertToGammaSpace=e.convertToGammaSpace,this.convertToLinearSpace=!!e.convertToLinearSpace,e.texture&&(i=e.texture.url.indexOf("data:")===0?"":i,this.texture=we.a.Parse(e.texture,n,i))},t}(pt);R.a.RegisteredTypes["BABYLON.ParticleTextureBlock"]=oc;var ac=function(r){function t(e){var n=r.call(this,e,Re.Fragment)||this;return n._isUnique=!0,n.registerInput("color",le.Color4,!1,Re.Fragment),n.registerOutput("rampColor",le.Color4,Re.Fragment),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"ParticleRampGradientBlock"},Object.defineProperty(t.prototype,"color",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rampColor",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.initialize=function(e){e._excludeVariableName("remapRanges"),e._excludeVariableName("rampSampler"),e._excludeVariableName("baseColor"),e._excludeVariableName("alpha"),e._excludeVariableName("remappedColorIndex"),e._excludeVariableName("rampColor"),e._excludeVariableName("finalAlpha")},t.prototype._buildBlock=function(e){if(r.prototype._buildBlock.call(this,e),e.target!==Re.Vertex)return e._emit2DSampler("rampSampler"),e._emitVaryingFromString("remapRanges","vec4","RAMPGRADIENT"),e.compilationString+=`
7509            #ifdef RAMPGRADIENT
7510                vec4 baseColor = `+this.color.associatedVariableName+`;
7511                float alpha = `+this.color.associatedVariableName+`.a;
7512
7513                float remappedColorIndex = clamp((alpha - remapRanges.x) / remapRanges.y, 0.0, 1.0);
7514
7515                vec4 rampColor = texture2D(rampSampler, vec2(1.0 - remappedColorIndex, 0.));
7516                baseColor.rgb *= rampColor.rgb;
7517
7518                // Remapped alpha
7519                float finalAlpha = baseColor.a;
7520                baseColor.a = clamp((alpha * rampColor.a - remapRanges.z) / remapRanges.w, 0.0, 1.0);
7521
7522                `+this._declareOutput(this.rampColor,e)+` = baseColor;
7523            #else
7524                `+this._declareOutput(this.rampColor,e)+" = "+this.color.associatedVariableName+`;
7525            #endif
7526        `,this},t}(pt);R.a.RegisteredTypes["BABYLON.ParticleRampGradientBlock"]=ac;var sc=function(r){function t(e){var n=r.call(this,e,Re.Fragment)||this;return n._isUnique=!0,n.registerInput("color",le.Color4,!1,Re.Fragment),n.registerInput("alphaTexture",le.Float,!1,Re.Fragment),n.registerInput("alphaColor",le.Float,!1,Re.Fragment),n.registerOutput("blendColor",le.Color4,Re.Fragment),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"ParticleBlendMultiplyBlock"},Object.defineProperty(t.prototype,"color",{get:function(){return this._inputs[0]}
7526,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"alphaTexture",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"alphaColor",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendColor",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.initialize=function(e){e._excludeVariableName("sourceAlpha")},t.prototype._buildBlock=function(e){if(r.prototype._buildBlock.call(this,e),e.target!==Re.Vertex)return e.compilationString+=`
7527            #ifdef BLENDMULTIPLYMODE
7528                `+this._declareOutput(this.blendColor,e)+`;
7529                float sourceAlpha = `+this.alphaColor.associatedVariableName+" * "+this.alphaTexture.associatedVariableName+`;
7530                `+this.blendColor.associatedVariableName+".rgb = "+this.color.associatedVariableName+`.rgb * sourceAlpha + vec3(1.0) * (1.0 - sourceAlpha);
7531                `+this.blendColor.associatedVariableName+".a = "+this.color.associatedVariableName+`.a;
7532            #else
7533                `+this._declareOutput(this.blendColor,e)+" = "+this.color.associatedVariableName+`;
7534            #endif
7535        `,this},t}(pt);R.a.RegisteredTypes["BABYLON.ParticleBlendMultiplyBlock"]=sc;var Lt,vo=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("xyz ",le.Vector3,!0),n.registerInput("xy ",le.Vector2,!0),n.registerInput("x",le.Float,!0),n.registerInput("y",le.Float,!0),n.registerInput("z",le.Float,!0),n.registerInput("w",le.Float,!0),n.registerOutput("xyzw",le.Vector4),n.registerOutput("xyz",le.Vector3),n.registerOutput("xy",le.Vector2),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"VectorMergerBlock"},Object.defineProperty(t.prototype,"xyzIn",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyIn",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"x",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"z",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"w",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyzw",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyzOut",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyOut",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xy",{get:function(){return this.xyOut},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyz",{get:function(){return this.xyzOut},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this.x,i=this.y,o=this.z,a=this.w,s=this.xyIn,d=this.xyzIn,p=this._outputs[0],y=this._outputs[1],P=this._outputs[2];return d.isConnected?p.hasEndpoints?e.compilationString+=this._declareOutput(p,e)+" = vec4("+d.associatedVariableName+", "+(a.isConnected?this._writeVariable(a):"0.0")+`);\r
7536`:y.hasEndpoints?e.compilationString+=this._declareOutput(y,e)+" = "+d.associatedVariableName+`;\r
7537`:P.hasEndpoints&&(e.compilationString+=this._declareOutput(P,e)+" = "+d.associatedVariableName+`.xy;\r
7538`):s.isConnected?p.hasEndpoints?e.compilationString+=this._declareOutput(p,e)+" = vec4("+s.associatedVariableName+", "+(o.isConnected?this._writeVariable(o):"0.0")+", "+(a.isConnected?this._writeVariable(a):"0.0")+`);\r
7539`:y.hasEndpoints?e.compilationString+=this._declareOutput(y,e)+" = vec3("+s.associatedVariableName+", "+(o.isConnected?this._writeVariable(o):"0.0")+`);\r
7540`:P.hasEndpoints&&(e.compilationString+=this._declareOutput(P,e)+" = "+s.associatedVariableName+`;\r
7541`):p.hasEndpoints?e.compilationString+=this._declareOutput(p,e)+" = vec4("+(n.isConnected?this._writeVariable(n):"0.0")+", "+(i.isConnected?this._writeVariable(i):"0.0")+", "+(o.isConnected?this._writeVariable(o):"0.0")+", "+(a.isConnected?this._writeVariable(a):"0.0")+`);\r
7542`:y.hasEndpoints?e.compilationString+=this._declareOutput(y,e)+" = vec3("+(n.isConnected?this._writeVariable(n):"0.0")+", "+(i.isConnected?this._writeVariable(i):"0.0")+", "+(o.isConnected?this._writeVariable(o):"0.0")+`);\r
7543`:P.hasEndpoints&&(e.compilationString+=this._declareOutput(P,e)+" = vec2("+(n.isConnected?this._writeVariable(n):"0.0")+", "+(i.isConnected?this._writeVariable(i):"0.0")+`);\r
7544`),this},t}(pt);function Vt(r,t,e,n){return t===void 0&&(t=Lt.Boolean),e===void 0&&(e="PROPERTIES"),function(i,o){var a=i._propStore;a||(a=[],i._propStore=a),a.push({propertyName:o,displayName:r,type:t,groupName:e,options:n??{}})}}R.a.RegisteredTypes["BABYLON.VectorMergerBlock"]=vo,function(r){r[r.Boolean=0]="Boolean",r[r.Float=1]="Float",r[r.Vector2=2]="Vector2",r[r.List=3]="List"}(Lt||(Lt={}));var cc=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.sourceRange=new u.d(-1,1),n.targetRange=new u.d(0,1),n.registerInput("input",le.AutoDetect),n.registerInput("sourceMin",le.Float,!0),n.registerInput("sourceMax",le.Float,!0),n.registerInput("targetMin",le.Float,!0),n.registerInput("targetMax",le.Float,!0),n.registerOutput("output",le.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"RemapBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]}
7544,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sourceMin",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sourceMax",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"targetMin",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"targetMax",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0],i=this.sourceMin.isConnected?this.sourceMin.associatedVariableName:this._writeFloat(this.sourceRange.x),o=this.sourceMax.isConnected?this.sourceMax.associatedVariableName:this._writeFloat(this.sourceRange.y),a=this.targetMin.isConnected?this.targetMin.associatedVariableName:this._writeFloat(this.targetRange.x),s=this.targetMax.isConnected?this.targetMax.associatedVariableName:this._writeFloat(this.targetRange.y);return e.compilationString+=this._declareOutput(n,e)+" = "+a+" + ("+this._inputs[0].associatedVariableName+" - "+i+") * ("+s+" - "+a+") / ("+o+" - "+i+`);\r
7545`,this},t.prototype._dumpPropertiesCode=function(){var e=this._codeVariableName+".sourceRange = new BABYLON.Vector2("+this.sourceRange.x+", "+this.sourceRange.y+`);\r
7546`;return e+=this._codeVariableName+".targetRange = new BABYLON.Vector2("+this.targetRange.x+", "+this.targetRange.y+`);\r
7547`},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.sourceRange=this.sourceRange.asArray(),e.targetRange=this.targetRange.asArray(),e},t.prototype._deserialize=function(e,n,i){r.prototype._deserialize.call(this,e,n,i),this.sourceRange=u.d.FromArray(e.sourceRange),this.targetRange=u.d.FromArray(e.targetRange)},Object(c.c)([Vt("From",Lt.Vector2)],t.prototype,"sourceRange",void 0),Object(c.c)([Vt("To",Lt.Vector2)],t.prototype,"targetRange",void 0),t}(pt);R.a.RegisteredTypes["BABYLON.RemapBlock"]=cc;var ga=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("left",le.AutoDetect),n.registerInput("right",le.AutoDetect),n.registerOutput("output",le.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._linkConnectionTypes(0,1),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"MultiplyBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=this._declareOutput(n,e)+" = "+this.left.associatedVariableName+" * "+this.right.associatedVariableName+`;\r
7548`,this},t}(pt);R.a.RegisteredTypes["BABYLON.MultiplyBlock"]=ga;var Lr=function(){function r(){this.direction1=new u.e(0,1,0),this.direction2=new u.e(0,1,0),this.minEmitBox=new u.e(-.5,-.5,-.5),this.maxEmitBox=new u.e(.5,.5,.5)}return r.prototype.startDirectionFunction=function(t,e,n,i){var o=$.a.RandomRange(this.direction1.x,this.direction2.x),a=$.a.RandomRange(this.direction1.y,this.direction2.y),s=$.a.RandomRange(this.direction1.z,this.direction2.z);if(i)return e.x=o,e.y=a,void(e.z=s);u.e.TransformNormalFromFloatsToRef(o,a,s,t,e)},r.prototype.startPositionFunction=function(t,e,n,i){var o=$.a.RandomRange(this.minEmitBox.x,this.maxEmitBox.x),a=$.a.RandomRange(this.minEmitBox.y,this.maxEmitBox.y),s=$.a.RandomRange(this.minEmitBox.z,this.maxEmitBox.z);if(i)return e.x=o,e.y=a,void(e.z=s);u.e.TransformCoordinatesFromFloatsToRef(o,a,s,t,e)},r.prototype.clone=function(){var t=new r;return de.a.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.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){u.e.FromArrayToRef(t.direction1,0,this.direction1),u.e.FromArrayToRef(t.direction2,0,this.direction2),u.e.FromArrayToRef(t.minEmitBox,0,this.minEmitBox),u.e.FromArrayToRef(t.maxEmitBox,0,this.maxEmitBox)},r}(),lc=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()}
7548,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?u.c.Vector3[0].copyFrom(n._localPosition).normalize():n.position.subtractToRef(t.getTranslation(),u.c.Vector3[0]).normalize();var o=$.a.RandomRange(0,this.directionRandomizer),a=$.a.RandomRange(0,this.directionRandomizer),s=$.a.RandomRange(0,this.directionRandomizer);e.x=u.c.Vector3[0].x+o,e.y=u.c.Vector3[0].y+a,e.z=u.c.Vector3[0].z+s,e.normalize()},r.prototype.startPositionFunction=function(t,e,n,i){var o,a=$.a.RandomRange(0,2*Math.PI);o=this.emitFromSpawnPointOnly?1e-4:1-(o=$.a.RandomRange(0,this.heightRange))*o;var s=this._radius-$.a.RandomRange(0,this._radius*this.radiusRange),d=(s*=o)*Math.sin(a),p=s*Math.cos(a),y=o*this._height;if(i)return e.x=d,e.y=y,void(e.z=p);u.e.TransformCoordinatesFromFloatsToRef(d,y,p,t,e)},r.prototype.clone=function(){var t=new r(this._radius,this._angle,this.directionRandomizer);return de.a.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.getEffectDefines=function(){var t="#define CONEEMITTER";return this.emitFromSpawnPointOnly&&(t+=`
7549#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}(),va=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}return r.prototype.startDirectionFunction=function(t,e,n,i){var o=n.position.subtract(t.getTranslation()).normalize(),a=$.a.RandomRange(-this.directionRandomizer/2,this.directionRandomizer/2),s=Math.atan2(o.x,o.z);s+=$.a.RandomRange(-Math.PI/2,Math.PI/2)*this.directionRandomizer,o.y=a,o.x=Math.sin(s),o.z=Math.cos(s),o.normalize(),i?e.copyFrom(o):u.e.TransformNormalFromFloatsToRef(o.x,o.y,o.z,t,e)},r.prototype.startPositionFunction=function(t,e,n,i){var o=$.a.RandomRange(-this.height/2,this.height/2),a=$.a.RandomRange(0,2*Math.PI),s=$.a.RandomRange((1-this.radiusRange)*(1-this.radiusRange),1),d=Math.sqrt(s)*this.radius,p=d*Math.cos(a),y=d*Math.sin(a);i?e.copyFromFloats(p,o,y):u.e.TransformCoordinatesFromFloatsToRef(p,o,y,t,e)},r.prototype.clone=function(){var t=new r(this.radius,this.directionRandomizer);return de.a.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.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}(),uc=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 u.e(0,1,0)),a===void 0&&(a=new u.e(0,1,0));var s=r.call(this,e,n,i)||this;return s.direction1=o,s.direction2=a,s}return Object(c.d)(t,r),t.prototype.startDirectionFunction=function(e,n,i){var o=$.a.RandomRange(this.direction1.x,this.direction2.x),a=$.a.RandomRange(this.direction1.y,this.direction2.y),s=$.a.RandomRange(this.direction1.z,this.direction2.z);u.e.TransformNormalFromFloatsToRef(o,a,s,e,n)},t.prototype.clone=function(){var e=new t(this.radius,this.height,this.radiusRange,this.direction1,this.direction2);return de.a.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.getEffectDefines=function(){return`#define CYLINDEREMITTER
7550#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),this.direction1.copyFrom(e.direction1),this.direction2.copyFrom(e.direction2)},t}(va),hc=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=$.a.RandomRange(0,this.directionRandomizer),s=$.a.RandomRange(0,this.directionRandomizer),d=$.a.RandomRange(0,this.directionRandomizer);o.x+=a,o.y+=s,o.z+=d,o.normalize(),i?e.copyFrom(o):u.e.TransformNormalFromFloatsToRef(o.x,o.y,o.z,t,e)},r.prototype.startPositionFunction=function(t,e,n,i){var o=this.radius-$.a.RandomRange(0,this.radius*this.radiusRange),a=$.a.RandomRange(0,1),s=$.a.RandomRange(0,2*Math.PI),d=Math.acos(2*a-1),p=o*Math.cos(s)*Math.sin(d),y=o*Math.cos(d),P=o*Math.sin(s)*Math.sin(d);i?e.copyFromFloats(p,Math.abs(y),P):u.e.TransformCoordinatesFromFloatsToRef(p,Math.abs(y),P,t,e)},r.prototype.clone=function(){var t=new r(this.radius,this.directionRandomizer);return de.a.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.getEffectDefines=function(){return"#define HEMISPHERICEMITTER"},r.prototype.getClassName=function(){return"HemisphericParticleEmitter"},r.prototype.serialize=function(){var t={};
7550return 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}(),dc=function(){function r(){this.direction1=new u.e(0,1,0),this.direction2=new u.e(0,1,0)}return r.prototype.startDirectionFunction=function(t,e,n,i){var o=$.a.RandomRange(this.direction1.x,this.direction2.x),a=$.a.RandomRange(this.direction1.y,this.direction2.y),s=$.a.RandomRange(this.direction1.z,this.direction2.z);i?e.copyFromFloats(o,a,s):u.e.TransformNormalFromFloatsToRef(o,a,s,t,e)},r.prototype.startPositionFunction=function(t,e,n,i){i?e.copyFromFloats(0,0,0):u.e.TransformCoordinatesFromFloatsToRef(0,0,0,t,e)},r.prototype.clone=function(){var t=new r;return de.a.DeepCopy(this,t),t},r.prototype.applyToShader=function(t){t.setVector3("direction1",this.direction1),t.setVector3("direction2",this.direction2)},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){u.e.FromArrayToRef(t.direction1,0,this.direction1),u.e.FromArrayToRef(t.direction2,0,this.direction2)},r}(),ba=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=$.a.RandomRange(0,this.directionRandomizer),s=$.a.RandomRange(0,this.directionRandomizer),d=$.a.RandomRange(0,this.directionRandomizer);o.x+=a,o.y+=s,o.z+=d,o.normalize(),i?e.copyFrom(o):u.e.TransformNormalFromFloatsToRef(o.x,o.y,o.z,t,e)},r.prototype.startPositionFunction=function(t,e,n,i){var o=this.radius-$.a.RandomRange(0,this.radius*this.radiusRange),a=$.a.RandomRange(0,1),s=$.a.RandomRange(0,2*Math.PI),d=Math.acos(2*a-1),p=o*Math.cos(s)*Math.sin(d),y=o*Math.cos(d),P=o*Math.sin(s)*Math.sin(d);i?e.copyFromFloats(p,y,P):u.e.TransformCoordinatesFromFloatsToRef(p,y,P,t,e)},r.prototype.clone=function(){var t=new r(this.radius,this.directionRandomizer);return de.a.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.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}(),fc=function(r){function t(e,n,i){e===void 0&&(e=1),n===void 0&&(n=new u.e(0,1,0)),i===void 0&&(i=new u.e(0,1,0));var o=r.call(this,e)||this;return o.direction1=n,o.direction2=i,o}return Object(c.d)(t,r),t.prototype.startDirectionFunction=function(e,n,i){var o=$.a.RandomRange(this.direction1.x,this.direction2.x),a=$.a.RandomRange(this.direction1.y,this.direction2.y),s=$.a.RandomRange(this.direction1.z,this.direction2.z);u.e.TransformNormalFromFloatsToRef(o,a,s,e,n)},t.prototype.clone=function(){var e=new t(this.radius,this.direction1,this.direction2);return de.a.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.getEffectDefines=function(){return`#define SPHEREEMITTER
7551#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}(ba),Nr=function(){function r(){this.particlePositionGenerator=function(){},this.particleDestinationGenerator=function(){}}return r.prototype.startDirectionFunction=function(t,e,n,i){var o=u.c.Vector3[0];if(this.particleDestinationGenerator){this.particleDestinationGenerator(-1,n,o);var a=u.c.Vector3[1];o.subtractToRef(n.position,a),a.scaleToRef(1/n.lifeTime,o)}else o.set(0,0,0);i?e.copyFrom(o):u.e.TransformNormalToRef(o,t,e)}
7551,r.prototype.startPositionFunction=function(t,e,n,i){var o=u.c.Vector3[0];this.particlePositionGenerator?this.particlePositionGenerator(-1,n,o):o.set(0,0,0),i?e.copyFrom(o):u.e.TransformCoordinatesToRef(o,t,e)},r.prototype.clone=function(){var t=new r;return de.a.DeepCopy(this,t),t},r.prototype.applyToShader=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},r.prototype.parse=function(t){},r}(),Th=function(){function r(t){t===void 0&&(t=null),this._indices=null,this._positions=null,this._normals=null,this._storedNormal=u.e.Zero(),this._mesh=null,this.direction1=new u.e(0,1,0),this.direction2=new u.e(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(Me.b.PositionKind),this._normals=t.getVerticesData(Me.b.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)u.e.TransformNormalToRef(this._storedNormal,t,e);else{var o=$.a.RandomRange(this.direction1.x,this.direction2.x),a=$.a.RandomRange(this.direction1.y,this.direction2.y),s=$.a.RandomRange(this.direction1.z,this.direction2.z);i?e.copyFromFloats(o,a,s):u.e.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),d=1-a-s,p=this._indices[o],y=this._indices[o+1],P=this._indices[o+2],O=u.c.Vector3[0],U=u.c.Vector3[1],F=u.c.Vector3[2],z=u.c.Vector3[3];u.e.FromArrayToRef(this._positions,3*p,O),u.e.FromArrayToRef(this._positions,3*y,U),u.e.FromArrayToRef(this._positions,3*P,F),z.x=a*O.x+s*U.x+d*F.x,z.y=a*O.y+s*U.y+d*F.y,z.z=a*O.z+s*U.z+d*F.z,i?e.copyFromFloats(z.x,z.y,z.z):u.e.TransformCoordinatesFromFloatsToRef(z.x,z.y,z.z,t,e),this.useMeshNormalsForDirection&&this._normals&&(u.e.FromArrayToRef(this._normals,3*p,O),u.e.FromArrayToRef(this._normals,3*y,U),u.e.FromArrayToRef(this._normals,3*P,F),this._storedNormal.x=a*O.x+s*U.x+d*F.x,this._storedNormal.y=a*O.y+s*U.y+d*F.y,this._storedNormal.z=a*O.z+s*U.z+d*F.z)}},r.prototype.clone=function(){var t=new r(this.mesh);return de.a.DeepCopy(this,t),t},r.prototype.applyToShader=function(t){t.setVector3("direction1",this.direction1),t.setVector3("direction2",this.direction2)},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){u.e.FromArrayToRef(t.direction1,0,this.direction1),u.e.FromArrayToRef(t.direction2,0,this.direction2),t.meshId&&e&&(this.mesh=e.getLastMeshByID(t.meshId)),this.useMeshNormalsForDirection=t.useMeshNormalsForDirection},r}(),bo=function(){function r(t){this.animations=[],this.renderingGroupId=0,this.emitter=u.e.Zero(),this.emitRate=10,this.manualEmitCount=-1,this.updateSpeed=.01,this.targetStopDuration=0,this.disposeOnStop=!1,this.minEmitPower=1,this.maxEmitPower=1,this.minLifeTime=1,this.maxLifeTime=1,this.minSize=1,this.maxSize=1,this.minScaleX=1,this.maxScaleX=1,this.minScaleY=1,this.maxScaleY=1,this.minInitialRotation=0,this.maxInitialRotation=0,this.minAngularSpeed=0,this.maxAngularSpeed=0,this.layerMask=268435455,this.customShader=null,this.preventAutoStart=!1,this.noiseStrength=new u.e(10,10,10),this.onAnimationEnd=null,this.blendMode=r.BLENDMODE_ONEONE,this.forceDepthWrite=!1,this.preWarmCycles=0,this.preWarmStepOffset=1,this.spriteCellChangeSpeed=1,this.startSpriteCellID=0,this.endSpriteCellID=0,this.spriteCellWidth=0,this.spriteCellHeight=0,this.spriteRandomStartCell=!1,this.translationPivot=new u.d(0,0),this.beginAnimationOnStart=!1,this.beginAnimationFrom=0,this.beginAnimationTo=60,this.beginAnimationLoop=!1,this.worldOffset=new u.e(0,0,0),this.gravity=u.e.Zero(),this._colorGradients=null,this._sizeGradients=null,this._lifeTimeGradients=null,this._angularSpeedGradients=null,this._velocityGradients=null,this._limitVelocityGradients=null,this._dragGradients=null,this._emitRateGradients=null,this._startSizeGradients=null,this._rampGradients=null,this._colorRemapGradients=null,this._alphaRemapGradients=null,this.startDelay=0,this.limitVelocityDamping=.4,this.color1=new M.b(1,1,1,1),this.color2=new M.b(1,1,1,1),this.colorDead=new M.b(0,0,0,1),this.textureMask=new M.b(1,1,1,1),this._isSubEmitter=!1,this.billboardMode=h.a.PARTICLES_BILLBOARDMODE_ALL,this._isBillboardBased=!0,this._imageProcessingConfigurationDefines=new vn.b,this.id=t,this.name=t}return Object.defineProperty(r.prototype,"noiseTexture",{get:function(){return this._noiseTexture},set:function(t){this._noiseTexture!==t&&(this._noiseTexture=t,this._reset())}
7551,enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isAnimationSheetEnabled",{get:function(){return this._isAnimationSheetEnabled},set:function(t){this._isAnimationSheetEnabled!=t&&(this._isAnimationSheetEnabled=t,this._reset())},enumerable:!1,configurable:!0}),r.prototype.getScene=function(){return this._scene},r.prototype._hasTargetStopDurationDependantGradient=function(){return this._startSizeGradients&&this._startSizeGradients.length>0||this._emitRateGradients&&this._emitRateGradients.length>0||this._lifeTimeGradients&&this._lifeTimeGradients.length>0},r.prototype.getDragGradients=function(){return this._dragGradients},r.prototype.getLimitVelocityGradients=function(){return this._limitVelocityGradients},r.prototype.getColorGradients=function(){return this._colorGradients},r.prototype.getSizeGradients=function(){return this._sizeGradients},r.prototype.getColorRemapGradients=function(){return this._colorRemapGradients},r.prototype.getAlphaRemapGradients=function(){return this._alphaRemapGradients},r.prototype.getLifeTimeGradients=function(){return this._lifeTimeGradients},r.prototype.getAngularSpeedGradients=function(){return this._angularSpeedGradients},r.prototype.getVelocityGradients=function(){return this._velocityGradients},r.prototype.getStartSizeGradients=function(){return this._startSizeGradients},r.prototype.getEmitRateGradients=function(){return this._emitRateGradients},Object.defineProperty(r.prototype,"direction1",{get:function(){return this.particleEmitterType.direction1?this.particleEmitterType.direction1:u.e.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:u.e.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:u.e.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:u.e.Zero()},set:function(t){this.particleEmitterType.maxEmitBox&&(this.particleEmitterType.maxEmitBox=t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isBillboardBased",{get:function(){return this._isBillboardBased},set:function(t){this._isBillboardBased!==t&&(this._isBillboardBased=t,this._reset())},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(t){this._attachImageProcessingConfiguration(t)},enumerable:!1,configurable:!0}),r.prototype._attachImageProcessingConfiguration=function(t){t!==this._imageProcessingConfiguration&&(!t&&this._scene?this._imageProcessingConfiguration=this._scene.imageProcessingConfiguration:this._imageProcessingConfiguration=t)},r.prototype._reset=function(){},r.prototype._removeGradientAndTexture=function(t,e,n){if(!e)return this;for(var i=0,o=0,a=e;o<a.length;o++){if(a[o].gradient===t){e.splice(i,1);break}i++}return n&&n.dispose(),this},r.prototype.createPointEmitter=function(t,e){var n=new dc;return n.direction1=t,n.direction2=e,this.particleEmitterType=n,n},r.prototype.createHemisphericEmitter=function(t,e){t===void 0&&(t=1),e===void 0&&(e=1);var n=new hc(t,e);return this.particleEmitterType=n,n},r.prototype.createSphereEmitter=function(t,e){t===void 0&&(t=1),e===void 0&&(e=1);var n=new ba(t,e);return this.particleEmitterType=n,n},r.prototype.createDirectedSphereEmitter=function(t,e,n){t===void 0&&(t=1),e===void 0&&(e=new u.e(0,1,0)),n===void 0&&(n=new u.e(0,1,0));var i=new fc(t,e,n);return this.particleEmitterType=i,i},r.prototype.createCylinderEmitter=function(t,e,n,i){t===void 0&&(t=1),e===void 0&&(e=1),n===void 0&&(n=1),i===void 0&&(i=0);var o=new va(t,e,n,i);return this.particleEmitterType=o,o},r.prototype.createDirectedCylinderEmitter=function(t,e,n,i,o){t===void 0&&(t=1),e===void 0&&(e=1),n===void 0&&(n=1),i===void 0&&(i=new u.e(0,1,0)),o===void 0&&(o=new u.e(0,1,0));var a=new uc(t,e,n,i,o);return this.particleEmitterType=a,a},r.prototype.createConeEmitter=function(t,e){t===void 0&&(t=1),e===void 0&&(e=Math.PI/4);var n=new lc(t,e);return this.particleEmitterType=n,n},r.prototype.createBoxEmitter=function(t,e,n,i){var o=new Lr;return this.particleEmitterType=o,this.direction1=t,this.direction2=e,this.minEmitBox=n,this.maxEmitBox=i,o},r.BLENDMODE_ONEONE=0,r.BLENDMODE_STANDARD=1,r.BLENDMODE_ADD=2,r.BLENDMODE_MULTIPLY=3,r.BLENDMODE_MULTIPLYADD=4,r}(),pc=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("rgba",le.Color4,!0),n.registerInput("rgb ",le.Color3,!0),n.registerOutput("rgb",le.Color3),n.registerOutput("r",le.Float),n.registerOutput("g",le.Float),n.registerOutput("b",le.Float),n.registerOutput("a",le.Float),n.inputsAreExclusive=!0,n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"ColorSplitterBlock"},Object.defineProperty(t.prototype,"rgba",{get:function(){return this._inputs[0]}
7551,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgbIn",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgbOut",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"r",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"g",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"b",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"a",{get:function(){return this._outputs[4]},enumerable:!1,configurable:!0}),t.prototype._inputRename=function(e){return e==="rgb "?"rgbIn":e},t.prototype._outputRename=function(e){return e==="rgb"?"rgbOut":e},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this.rgba.isConnected?this.rgba:this.rgbIn;if(n.isConnected){var i=this._outputs[0],o=this._outputs[1],a=this._outputs[2],s=this._outputs[3],d=this._outputs[4];return i.hasEndpoints&&(e.compilationString+=this._declareOutput(i,e)+" = "+n.associatedVariableName+`.rgb;\r
7552`),o.hasEndpoints&&(e.compilationString+=this._declareOutput(o,e)+" = "+n.associatedVariableName+`.r;\r
7553`),a.hasEndpoints&&(e.compilationString+=this._declareOutput(a,e)+" = "+n.associatedVariableName+`.g;\r
7554`),s.hasEndpoints&&(e.compilationString+=this._declareOutput(s,e)+" = "+n.associatedVariableName+`.b;\r
7555`),d.hasEndpoints&&(e.compilationString+=this._declareOutput(d,e)+" = "+n.associatedVariableName+`.a;\r
7556`),this}},t}(pt);R.a.RegisteredTypes["BABYLON.ColorSplitterBlock"]=pc;var rn,Eh=f(104);(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"})(rn||(rn={}));var _c=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.operation=rn.Cos,n.registerInput("input",le.AutoDetect),n.registerOutput("output",le.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n}return Object(c.d)(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 rn.Cos:i="cos";break;case rn.Sin:i="sin";break;case rn.Abs:i="abs";break;case rn.Exp:i="exp";break;case rn.Exp2:i="exp2";break;case rn.Round:i="round";break;case rn.Floor:i="floor";break;case rn.Ceiling:i="ceil";break;case rn.Sqrt:i="sqrt";break;case rn.Log:i="log";break;case rn.Tan:i="tan";break;case rn.ArcTan:i="atan";break;case rn.ArcCos:i="acos";break;case rn.ArcSin:i="asin";break;case rn.Fract:i="fract";break;case rn.Sign:i="sign";break;case rn.Radians:i="radians";break;case rn.Degrees:i="degrees"}return e.compilationString+=this._declareOutput(n,e)+" = "+i+"("+this.input.associatedVariableName+`);\r
7557`,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 this._codeVariableName+".operation = BABYLON.TrigonometryBlockOperations."+rn[this.operation]+`;\r
7558`},t}(pt);R.a.RegisteredTypes["BABYLON.TrigonometryBlock"]=_c;var mc={effect:null,subMesh:null},yo=function(r){function t(){var e=r.call(this)||this;return e.NORMAL=!1,e.TANGENT=!1,e.UV1=!1,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.IMAGEPROCESSING=!1,e.VIGNETTE=!1,e.VIGNETTEBLENDMODEMULTIPLY=!1,e.VIGNETTEBLENDMODEOPAQUE=!1,e.TONEMAPPING=!1,e.TONEMAPPING_ACES=!1,e.CONTRAST=!1,e.EXPOSURE=!1,e.COLORCURVES=!1,e.COLORGRADING=!1,e.COLORGRADING3D=!1,e.SAMPLER3DGREENDEPTH=!1,e.SAMPLER3DBGRMAP=!1,e.IMAGEPROCESSINGPOSTPROCESS=!1,e.BUMPDIRECTUV=0,e.rebuild(),e}return Object(c.d)(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}(ta.a),ya=function(r){function t(e,n,i){i===void 0&&(i={});var o=r.call(this,e,n||Ue.a.LastCreatedScene)||this;return o._buildId=t._BuildIdGenerator++,o._buildWasSuccessful=!1,o._cachedWorldViewMatrix=new u.a,o._cachedWorldViewProjectionMatrix=new u.a,o._optimizers=new Array,o._animationFrame=-1,o.BJSNODEMATERIALEDITOR=o._getGlobalNodeMaterialEditor(),o.editorData=null,o.ignoreAlp
7558ha=!1,o.maxSimultaneousLights=4,o.onBuildObservable=new x.c,o._vertexOutputNodes=new Array,o._fragmentOutputNodes=new Array,o.attachedBlocks=new Array,o._mode=Rn.Material,o._options=Object(c.a)({emitComments:!1},i),o._attachImageProcessingConfiguration(null),o}return Object(c.d)(t,r),t.prototype._getGlobalNodeMaterialEditor=function(){return typeof NODEEDITOR<"u"?NODEEDITOR:typeof BABYLON<"u"&&BABYLON.NodeEditor!==void 0?BABYLON:void 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},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.get
7558Scene().imageProcessingConfiguration,this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add(function(){n._markAllSubMeshesAsImageProcessingDirty()})))},t.prototype.getBlockByName=function(e){for(var n=null,i=0,o=this.attachedBlocks;i<o.length;i++){var a=o[i];if(a.name===e){if(n)return Ye.b.Warn("More than one block was found with the name `"+e+"`"),n;n=a}}return n},t.prototype.getBlockByPredicate=function(e){for(var n=0,i=this.attachedBlocks;n<i.length;n++){var o=i[n];if(e(o))return o}return null},t.prototype.getInputBlockByPredicate=function(e){for(var n=0,i=this.attachedBlocks;n<i.length;n++){var o=i[n];if(o.isInput&&e(o))return o}return null},t.prototype.getInputBlocks=function(){for(var e=[],n=0,i=this.attachedBlocks;n<i.length;n++){var o=i[n];o.isInput&&e.push(o)}return e},t.prototype.registerOptimizer=function(e){if(!(this._optimizers.indexOf(e)>-1))return this._optimizers.push(e),this},t.prototype.unregisterOptimizer=function(e){var n=this._optimizers.indexOf(e);if(n!==-1)return this._optimizers.splice(n,1),this},t.prototype.addOutputNode=function(e){if(e.target===null)throw"This node is not meant to be an output node. You may want to explicitly set its target value.";return e.target&Re.Vertex&&this._addVertexOutputNode(e),e.target&Re.Fragment&&this._addFragmentOutputNode(e),this},t.prototype.removeOutputNode=function(e){return e.target===null||(e.target&Re.Vertex&&this._removeVertexOutputNode(e),e.target&Re.Fragment&&this._removeFragmentOutputNode(e)),this},t.prototype._addVertexOutputNode=function(e){if(this._vertexOutputNodes.indexOf(e)===-1)return e.target=Re.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=Re.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.alpha<1||this._sharedData&&this._sharedData.hints.needAlphaBlending)},t.prototype.needAlphaTesting=function(){return this._sharedData&&this._sharedData.hints.needAlphaTesting},t.prototype._initializeBlock=function(e,n,i){if(e.initialize(n),e.autoConfigure(this),e._preparationId=this._buildId,this.attachedBlocks.indexOf(e)===-1){if(e.isUnique){for(var o=e.getClassName(),a=0,s=this.attachedBlocks;a<s.length;a++)if(s[a].getClassName()===o)throw"Cannot have multiple blocks of type "+o+" in the same NodeMaterial"}this.attachedBlocks.push(e)}for(var d=0,p=e.inputs;d<p.length;d++){var y=p[d];y.associatedVariableName="";var P=y.connectedPoint;if(P){var O=P.ownerBlock;O!==e&&((O.target===Re.VertexAndFragment||n.target===Re.Fragment&&O.target===Re.Vertex&&O._preparationId!==this._buildId)&&i.push(O),this._initializeBlock(O,n,i))}}for(var U=0,F=e.outputs;U<F.length;U++)F[U].associatedVariableName=""},t.prototype._resetDualBlocks=function(e,n){e.target===Re.VertexAndFragment&&(e.buildId=n);for(var i=0,o=e.inputs;i<o.length;i++){var a=o[i].connectedPoint;if(a){var s=a.ownerBlock;s!==e&&this._resetDualBlocks(s,n)}}},t.prototype.removeBlock=function(e){var n=this.attachedBlocks.indexOf(e);n>-1&&this.attachedBlocks.splice(n,1),e.isFinalMerger&&this.removeOutputNode(e)},t.prototype.build=function(e){e===void 0&&(e=!1),this._buildWasSuccessful=!1;var n=this.getScene().getEngine(),i=this._mode===Rn.Particle;if(this._vertexOutputNodes.length===0&&!i)throw"You must define at least one vertexOutputNode";if(this._fragmentOutputNodes.length===0)throw"You must define at least one fragmentOutputNode";this._vertexCompilationState=new bh,this._vertexCompilationState.supportUniformBuffers=n.supportsUniformBuffers,this._vertexCompilationState.target=Re.Vertex,this._fragmentCompilationState=new bh,this._fragmentCompilationState.supportUniformBuffers=n.supportsUniformBuffers,this._fragmentCompilationState.target=Re.Fragment,this._sharedData=new Im,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=i;for(var o=[],a=[],s=0,d=this._vertexOutputNodes;s<d.length;s++){var p=d[s];o.push(p),this._initializeBlock(p,this._vertexCompilationState,a)}for(var y=0,P=this._fragmentOutputNodes;y<P.length;y++){var O=P[y];a.push(O),this._initializeBlock(O,this._fragmentCompilationState,o)}this.optimize();for(var U=0,F=o;U<F.length;
7558U++)(p=F[U]).build(this._vertexCompilationState,o);this._fragmentCompilationState.uniforms=this._vertexCompilationState.uniforms.slice(0),this._fragmentCompilationState._uniformDeclaration=this._vertexCompilationState._uniformDeclaration,this._fragmentCompilationState._constantDeclaration=this._vertexCompilationState._constantDeclaration,this._fragmentCompilationState._vertexState=this._vertexCompilationState;for(var z=0,J=a;z<J.length;z++)O=J[z],this._resetDualBlocks(O,this._buildId-1);for(var ie=0,se=a;ie<se.length;ie++)(O=se[ie]).build(this._fragmentCompilationState,a);this._vertexCompilationState.finalize(this._vertexCompilationState),this._fragmentCompilationState.finalize(this._fragmentCompilationState),this._buildId=t._BuildIdGenerator++,this._sharedData.emitErrors(),e&&(console.log("Vertex shader:"),console.log(this._vertexCompilationState.compilationString),console.log("Fragment shader:"),console.log(this._fragmentCompilationState.compilationString)),this._buildWasSuccessful=!0,this.onBuildObservable.notifyObservers(this);for(var ce=0,ue=this.getScene().meshes;ce<ue.length;ce++){var fe=ue[ce];if(fe.subMeshes)for(var ve=0,Te=fe.subMeshes;ve<Te.length;ve++){var Oe=Te[ve];if(Oe.getMaterial()===this&&Oe._materialDefines){var Pe=Oe._materialDefines;Pe.markAllAsDirty(),Pe.reset()}}}},t.prototype.optimize=function(){for(var e=0,n=this._optimizers;e<n.length;e++)n[e].optimize(this._vertexOutputNodes,this._fragmentOutputNodes)},t.prototype._prepareDefinesForAttributes=function(e,n){var i=n.NORMAL,o=n.TANGENT,a=n.UV1;n.NORMAL=e.isVerticesDataPresent(Me.b.NormalKind),n.TANGENT=e.isVerticesDataPresent(Me.b.TangentKind),n.UV1=e.isVerticesDataPresent(Me.b.UVKind),i===n.NORMAL&&o===n.TANGENT&&a===n.UV1||n.markAsAttributesDirty()},t.prototype.createPostProcess=function(e,n,i,o,a,s,d){return n===void 0&&(n=1),i===void 0&&(i=h.a.TEXTURE_NEAREST_SAMPLINGMODE),s===void 0&&(s=h.a.TEXTURETYPE_UNSIGNED_INT),d===void 0&&(d=h.a.TEXTUREFORMAT_RGBA),this.mode!==Rn.PostProcess?(console.log("Incompatible material mode"),null):this._createEffectForPostProcess(null,e,n,i,o,a,s,d)},t.prototype.createEffectForPostProcess=function(e){this._createEffectForPostProcess(e)},t.prototype._createEffectForPostProcess=function(e,n,i,o,a,s,d,p){var y=this;i===void 0&&(i=1),o===void 0&&(o=h.a.TEXTURE_NEAREST_SAMPLINGMODE),d===void 0&&(d=h.a.TEXTURETYPE_UNSIGNED_INT),p===void 0&&(p=h.a.TEXTUREFORMAT_RGBA);var P=this.name+this._buildId,O=new yo,U=new Dt.a(P+"PostProcess",this.getScene()),F=this._buildId;return this._processDefines(U,O),je.a.RegisterShader(P,this._fragmentCompilationState._builtCompilationString,this._vertexCompilationState._builtCompilationString),e?e.updateEffect(O.toString(),this._fragmentCompilationState.uniforms,this._fragmentCompilationState.samplers,{maxSimultaneousLights:this.maxSimultaneousLights},void 0,void 0,P,P):e=new _t(this.name+"PostProcess",P,this._fragmentCompilationState.uniforms,this._fragmentCompilationState.samplers,i,n,o,a,s,O.toString(),d,P,{maxSimultaneousLights:this.maxSimultaneousLights},!1,p),e.nodeMaterialSource=this,e.onApplyObservable.add(function(z){F!==y._buildId&&(delete je.a.ShadersStore[P+"VertexShader"],delete je.a.ShadersStore[P+"PixelShader"],P=y.name+y._buildId,O.markAsUnprocessed(),F=y._buildId),y._processDefines(U,O)&&(je.a.RegisterShader(P,y._fragmentCompilationState._builtCompilationString,y._vertexCompilationState._builtCompilationString),Eh.a.SetImmediate(function(){return e.updateEffect(O.toString(),y._fragmentCompilationState.uniforms,y._fragmentCompilationState.samplers,{maxSimultaneousLights:y.maxSimultaneousLights},void 0,void 0,P,P)})),y._checkInternals(z)}),e},t.prototype.createProceduralTexture=function(e,n){var i=this;if(this.mode!==Rn.ProceduralTexture)return console.log("Incompatible material mode"),null;var o=this.name+this._buildId,a=new mo(o,e,null,n),s=new Dt.a(o+"Procedural",this.getScene());s.reservedDataStore={hidden:!0};var d=new yo,p=this._processDefines(s,d);je.a.RegisterShader(o,this._fragmentCompilationState._builtCompilationString,this._vertexCompilationState._builtCompilationString);
7558var y=this.getScene().getEngine().createEffect({vertexElement:o,fragmentElement:o},[Me.b.PositionKind],this._fragmentCompilationState.uniforms,this._fragmentCompilationState.samplers,d.toString(),p?.fallbacks,void 0);a.nodeMaterialSource=this,a._effect=y;var P=this._buildId;return a.onBeforeGenerationObservable.add(function(){P!==i._buildId&&(delete je.a.ShadersStore[o+"VertexShader"],delete je.a.ShadersStore[o+"PixelShader"],o=i.name+i._buildId,d.markAsUnprocessed(),P=i._buildId);var O=i._processDefines(s,d);O&&(je.a.RegisterShader(o,i._fragmentCompilationState._builtCompilationString,i._vertexCompilationState._builtCompilationString),Eh.a.SetImmediate(function(){y=i.getScene().getEngine().createEffect({vertexElement:o,fragmentElement:o},[Me.b.PositionKind],i._fragmentCompilationState.uniforms,i._fragmentCompilationState.samplers,d.toString(),O?.fallbacks,void 0),a._effect=y})),i._checkInternals(y)}),a},t.prototype._createEffectForParticles=function(e,n,i,o,a,s,d,p){var y=this;p===void 0&&(p="");var P=this.name+this._buildId+"_"+n;s||(s=new yo),d||(d=this.getScene().getMeshByName(this.name+"Particle"))||((d=new Dt.a(this.name+"Particle",this.getScene())).reservedDataStore={hidden:!0});var O=this._buildId,U=[],F=p;if(!a){var z=this._processDefines(d,s);je.a.RegisterShader(P,this._fragmentCompilationState._builtCompilationString),e.fillDefines(U,n),F=U.join(`
7559`),a=this.getScene().getEngine().createEffectForParticles(P,this._fragmentCompilationState.uniforms,this._fragmentCompilationState.samplers,s.toString()+`
7560`+F,z?.fallbacks,i,o,e),e.setCustomEffect(a,n)}a.onBindObservable.add(function(J){O!==y._buildId&&(delete je.a.ShadersStore[P+"PixelShader"],P=y.name+y._buildId+"_"+n,s.markAsUnprocessed(),O=y._buildId),U.length=0,e.fillDefines(U,n);var ie=U.join(`
7561`);ie!==F&&(s.markAsUnprocessed(),F=ie);var se=y._processDefines(d,s);if(se)return je.a.RegisterShader(P,y._fragmentCompilationState._builtCompilationString),J=y.getScene().getEngine().createEffectForParticles(P,y._fragmentCompilationState.uniforms,y._fragmentCompilationState.samplers,s.toString()+`
7562`+F,se?.fallbacks,i,o,e),e.setCustomEffect(J,n),void y._createEffectForParticles(e,n,i,o,J,s,d,F);y._checkInternals(J)})},t.prototype._checkInternals=function(e){if(this._sharedData.animatedInputs){var n=this.getScene(),i=n.getFrameId();if(this._animationFrame!==i){for(var o=0,a=this._sharedData.animatedInputs;o<a.length;o++)a[o].animate(n);this._animationFrame=i}}for(var s=0,d=this._sharedData.bindableBlocks;s<d.length;s++)d[s].bind(e,this);for(var p=0,y=this._sharedData.inputBlocks;p<y.length;p++)y[p]._transmit(e,this.getScene())},t.prototype.createEffectForParticles=function(e,n,i){this.mode===Rn.Particle?(this._createEffectForParticles(e,bo.BLENDMODE_ONEONE,n,i),this._createEffectForParticles(e,bo.BLENDMODE_MULTIPLY,n,i)):console.log("Incompatible material mode")},t.prototype._processDefines=function(e,n,i,o){var a=this;i===void 0&&(i=!1);var s=null;if(this._sharedData.blocksWithDefines.forEach(function(U){U.initializeDefines(e,a,n,i)}),this._sharedData.blocksWithDefines.forEach(function(U){U.prepareDefines(e,a,n,i,o)}),n.isDirty){var d=n._areLightsDisposed;n.markAsProcessed(),this._vertexCompilationState.compilationString=this._vertexCompilationState._builtCompilationString,this._fragmentCompilationState.compilationString=this._fragmentCompilationState._builtCompilationString,this._sharedData.repeatableContentBlocks.forEach(function(U){U.replaceRepeatableContent(a._vertexCompilationState,a._fragmentCompilationState,e,n)});var p=[];this._sharedData.dynamicUniformBlocks.forEach(function(U){U.updateUniformsAndSamples(a._vertexCompilationState,a,n,p)});var y=this._vertexCompilationState.uniforms;
7562this._fragmentCompilationState.uniforms.forEach(function(U){y.indexOf(U)===-1&&y.push(U)});var P=this._vertexCompilationState.samplers;this._fragmentCompilationState.samplers.forEach(function(U){P.indexOf(U)===-1&&P.push(U)});var O=new Er.a;this._sharedData.blocksWithFallbacks.forEach(function(U){U.provideFallbacks(e,O)}),s={lightDisposed:d,uniformBuffers:p,mergedUniforms:y,mergedSamplers:P,fallbacks:O}}return s},t.prototype.isReadyForSubMesh=function(e,n,i){var o=this;if(i===void 0&&(i=!1),!this._buildWasSuccessful)return!1;var a=this.getScene();if(this._sharedData.animatedInputs){var s=a.getFrameId();if(this._animationFrame!==s){for(var d=0,p=this._sharedData.animatedInputs;d<p.length;d++)p[d].animate(a);this._animationFrame=s}}if(n.effect&&this.isFrozen&&n.effect._wasPreviouslyReady)return!0;n._materialDefines||(n._materialDefines=new yo);var y=n._materialDefines;if(this._isReadyForSubMesh(n))return!0;var P=a.getEngine();if(this._prepareDefinesForAttributes(e,y),this._sharedData.blockingBlocks.some(function(J){return!J.isReady(e,o,y,i)}))return!1;var O=this._processDefines(e,y,i,n);if(O){var U=n.effect,F=y.toString(),z=P.createEffect({vertex:"nodeMaterial"+this._buildId,fragment:"nodeMaterial"+this._buildId,vertexSource:this._vertexCompilationState.compilationString,fragmentSource:this._fragmentCompilationState.compilationString},{attributes:this._vertexCompilationState.attributes,uniformsNames:O.mergedUniforms,uniformBuffersNames:O.uniformBuffers,samplers:O.mergedSamplers,defines:F,fallbacks:O.fallbacks,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights,maxSimultaneousMorphTargets:y.NUM_MORPH_INFLUENCERS}},P);if(z)if(this._onEffectCreatedObservable&&(mc.effect=z,mc.subMesh=n,this._onEffectCreatedObservable.notifyObservers(mc)),this.allowShaderHotSwapping&&U&&!z.isReady()){if(z=U,y.markAsUnprocessed(),O.lightDisposed)return y._areLightsDisposed=!0,!1}else a.resetCachedMaterial(),n.setEffect(z,y)}return!(!n.effect||!n.effect.isReady())&&(y._renderId=a.getRenderId(),n.effect._wasPreviouslyReady=!0,!0)},Object.defineProperty(t.prototype,"compiledShaders",{get:function(){return`// Vertex shader\r
7563`+this._vertexCompilationState.compilationString+`\r
7564\r
7565// Fragment shader\r
7566`+this._fragmentCompilationState.compilationString},enumerable:!1,configurable:!0}),t.prototype.bindOnlyWorldMatrix=function(e){var n=this.getScene();if(this._activeEffect){var i=this._sharedData.hints;i.needWorldViewMatrix&&e.multiplyToRef(n.getViewMatrix(),this._cachedWorldViewMatrix),i.needWorldViewProjectionMatrix&&e.multiplyToRef(n.getTransformMatrix(),this._cachedWorldViewProjectionMatrix);for(var o=0,a=this._sharedData.inputBlocks;o<a.length;o++)a[o]._transmitWorld(this._activeEffect,e,this._cachedWorldViewMatrix,this._cachedWorldViewProjectionMatrix)}},t.prototype.bindForSubMesh=function(e,n,i){var o=this.getScene(),a=i.effect;if(a){if(this._activeEffect=a,this.bindOnlyWorldMatrix(e),this._mustRebind(o,a,n.visibility)){var s=this._sharedData;if(a&&o.getCachedEffect()!==a){for(var d=0,p=s.bindableBlocks;d<p.length;d++)p[d].bind(a,this,n,i);for(var y=0,P=s.inputBlocks;y<P.length;y++)P[y]._transmit(a,o)}}this._afterBind(n,this._activeEffect)}},t.prototype.getActiveTextures=function(){var e=r.prototype.getActiveTextures.call(this);return this._sharedData&&e.push.apply(e,this._sharedData.textureBlocks.filter(function(n){return n.texture}).map(function(n){return n.texture})),e},t.prototype.getTextureBlocks=function(){return this._sharedData?this._sharedData.textureBlocks:[]},t.prototype.hasTexture=function(e){if(r.prototype.hasTexture.call(this,e))return!0;if(!this._sharedData)return!1;for(var n=0,i=this._sharedData.textureBlocks;n<i.length;n++)if(i[n].texture===e)return!0;return!1},t.prototype.dispose=function(e,n,i){if(n)for(var o=0,a=this._sharedData.textureBlocks.filter(function(p){return p.texture}).map(function(p){return p.texture});o<a.length;o++)a[o].dispose();for(var s=0,d=this.attachedBlocks;s<d.length;s++)d[s].dispose();this.onBuildObservable.clear(),r.prototype.dispose.call(this,e,n,i)},t.prototype._createNodeEditor=function(){this.BJSNODEMATERIALEDITOR=this.BJSNODEMATERIALEDITOR||this._getGlobalNodeMaterialEditor(),this.BJSNODEMATERIALEDITOR.NodeEditor.Show({nodeMaterial:this})},t.prototype.edit=function(e){var n=this;return new Promise(function(i,o){if(n.BJSNODEMATERIALEDITOR===void 0){var a=e&&e.editorURL?e.editorURL:t.EditorURL;Ye.b.LoadScript(a,function(){n._createNodeEditor(),i()})}else n._createNodeEditor(),i()})},t.prototype.clear=function(){this._vertexOutputNodes=[],this._fragmentOutputNodes=[],this.attachedBlocks=[]},t.prototype.setToDefault=function(){this.clear(),this.editorData=null;var e=new At("Position");e.setAsAttribute("position");var n=new At("World");
7566n.setAsSystemValue(BABYLON.NodeMaterialSystemValues.World);var i=new ma("WorldPos");e.connectTo(i),n.connectTo(i);var o=new At("ViewProjection");o.setAsSystemValue(BABYLON.NodeMaterialSystemValues.ViewProjection);var a=new ma("WorldPos * ViewProjectionTransform");i.connectTo(a),o.connectTo(a);var s=new go("VertexOutput");a.connectTo(s);var d=new At("color");d.value=new M.b(.8,.8,.8,1);var p=new Dr("FragmentOutput");d.connectTo(p),this.addOutputNode(s),this.addOutputNode(p),this._mode=Rn.Material},t.prototype.setToDefaultPostProcess=function(){this.clear(),this.editorData=null;var e=new At("Position");e.setAsAttribute("position2d");var n=new At("Constant1");n.isConstant=!0,n.value=1;var i=new vo("Position3D");e.connectTo(i),n.connectTo(i,{input:"w"});var o=new go("VertexOutput");i.connectTo(o);var a=new At("Scale");a.visibleInInspector=!0,a.value=new u.d(1,1);var s=new cc("uv0");e.connectTo(s);var d=new ga("UV scale");s.connectTo(d),a.connectTo(d);var p=new rc("CurrentScreen");d.connectTo(p),p.texture=new we.a("https://assets.babylonjs.com/nme/currentScreenPostProcess.png",this.getScene());var y=new Dr("FragmentOutput");p.connectTo(y,{output:"rgba"}),this.addOutputNode(o),this.addOutputNode(y),this._mode=Rn.PostProcess},t.prototype.setToDefaultProceduralTexture=function(){this.clear(),this.editorData=null;var e=new At("Position");e.setAsAttribute("position2d");var n=new At("Constant1");n.isConstant=!0,n.value=1;var i=new vo("Position3D");e.connectTo(i),n.connectTo(i,{input:"w"});var o=new go("VertexOutput");i.connectTo(o);var a=new At("Time");a.value=0,a.min=0,a.max=0,a.isBoolean=!1,a.matrixMode=0,a.animationType=ki.Time,a.isConstant=!1;var s=new At("Color3");s.value=new M.a(1,1,1),s.isConstant=!1;var d=new Dr("FragmentOutput"),p=new vo("VectorMerger");p.visibleInInspector=!1;var y=new _c("Cos");y.operation=rn.Cos,e.connectTo(p),a.output.connectTo(y.input),y.output.connectTo(p.z),p.xyzOut.connectTo(d.rgb),this.addOutputNode(o),this.addOutputNode(d),this._mode=Rn.ProceduralTexture},t.prototype.setToDefaultParticle=function(){this.clear(),this.editorData=null;var e=new At("uv");e.setAsAttribute("particle_uv");var n=new oc("ParticleTexture");e.connectTo(n);var i=new At("Color");i.setAsAttribute("particle_color");var o=new ga("Texture * Color");n.connectTo(o),i.connectTo(o);var a=new ac("ParticleRampGradient");o.connectTo(a);var s=new pc("ColorSplitter");i.connectTo(s);var d=new sc("ParticleBlendMultiply");a.connectTo(d),n.connectTo(d,{output:"a"}),s.connectTo(d,{output:"a"});var p=new Dr("FragmentOutput");d.connectTo(p),this.addOutputNode(p),this._mode=Rn.Particle},t.prototype.loadAsync=function(e){var n=this;return this.getScene()._loadFileAsync(e).then(function(i){var o=JSON.parse(i);n.loadFromSerialization(o,"")})},t.prototype._gatherBlocks=function(e,n){if(n.indexOf(e)===-1){n.push(e);for(var i=0,o=e.inputs;i<o.length;i++){var a=o[i].connectedPoint;if(a){var s=a.ownerBlock;s!==e&&this._gatherBlocks(s,n)}}}},t.prototype.generateCode=function(){for(var e=[],n=[],i=[],o=0,a=this._vertexOutputNodes;o<a.length;o++){var s=a[o];this._gatherBlocks(s,n)}for(var d=[],p=0,y=this._fragmentOutputNodes;p<y.length;p++)s=y[p],this._gatherBlocks(s,d);for(var P='var nodeMaterial = new BABYLON.NodeMaterial("'+(this.name||"node material")+`");\r
7567`,O=0,U=n;O<U.length;O++)(Oe=U[O]).isInput&&e.indexOf(Oe)===-1&&(P+=Oe._dumpCode(i,e));for(var F=0,z=d;F<z.length;F++)(Oe=z[F]).isInput&&e.indexOf(Oe)===-1&&(P+=Oe._dumpCode(i,e));e=[],P+=`\r
7568// Connections\r
7569`;for(var J=0,ie=this._vertexOutputNodes;J<ie.length;J++)P+=(Oe=ie[J])._dumpCodeForOutputConnections(e);for(var se=0,ce=this._fragmentOutputNodes;se<ce.length;se++)P+=(Oe=ce[se])._dumpCodeForOutputConnections(e);P+=`\r
7570// Output nodes\r
7571`;for(var ue=0,fe=this._vertexOutputNodes;ue<fe.length;ue++)P+="nodeMaterial.addOutputNode("+(Oe=fe[ue])._codeVariableName+`);\r
7572`;for(var ve=0,Te=this._fragmentOutputNodes;ve<Te.length;ve++){var Oe;P+="nodeMaterial.addOutputNode("+(Oe=Te[ve])._codeVariableName+`);\r
7573`}return P+=`nodeMaterial.build();\r
7574`},t.prototype.serialize=function(e){var n=e?{}:L.a.Serialize(this);n.editorData=JSON.parse(JSON.stringify(this.editorData));var i=[];if(e)i=e;else{n.customType="BABYLON.NodeMaterial",n.outputNodes=[];for(var o=0,a=this._vertexOutputNodes;o<a.length;o++){var s=a[o];this._gatherBlocks(s,i),n.outputNodes.push(s.uniqueId)}for(var d=0,p=this._fragmentOutputNodes;d<p.length;d++)s=p[d],this._gatherBlocks(s,i),n.outputNodes.indexOf(s.uniqueId)===-1&&n.outputNodes.push(s.uniqueId)}n.blocks=[];for(var y=0,P=i;y<P.length;y++){var O=P[y];n.blocks.push(O.serialize())}if(!e)for(var U=0,F=this.attachedBlocks;U<F.length;U++)O=F[U],i.indexOf(O)===-1&&n.blocks.push(O.serialize());return n},t.prototype._restoreConnections=function(e,n,i){for(var o=0,a=e.outputs;o<a.length;o++)for(var s=a[o],d=0,p=n.blocks;d<p.length;d++){var y=p[d],P=i[y.id];if(P)for(var O=0,U=y.inputs;O<U.length;O++){var F=U[O];if(!(i[F.targetBlockId]!==e||F.targetConnectionName!==s.name)){var z=P.getIn
7574putByName(F.inputName);if(!z||z.isConnected)continue;s.connectTo(z,!0),this._restoreConnections(P,n,i)}}}},t.prototype.loadFromSerialization=function(e,n,i){var o;n===void 0&&(n=""),i===void 0&&(i=!1),i||this.clear();for(var a={},s=0,d=e.blocks;s<d.length;s++){var p=d[s],y=R.a.GetClass(p.customType);y&&((O=new y)._deserialize(p,this.getScene(),n),a[p.id]=O,this.attachedBlocks.push(O))}for(var P=0;P<e.blocks.length;P++){var O;(O=a[e.blocks[P].id])&&(O.inputs.length&&!i||this._restoreConnections(O,e,a))}if(e.outputNodes)for(var U=0,F=e.outputNodes;U<F.length;U++){var z=F[U];this.addOutputNode(a[z])}if(e.locations||e.editorData&&e.editorData.locations){for(var J=e.locations||e.editorData.locations,ie=0,se=J;ie<se.length;ie++){var ce=se[ie];a[ce.blockId]&&(ce.blockId=a[ce.blockId].uniqueId)}i&&this.editorData&&this.editorData.locations&&J.concat(this.editorData.locations),e.locations?this.editorData={locations:J}:(this.editorData=e.editorData,this.editorData.locations=J);var ue=[];for(var fe in a)ue[fe]=a[fe].uniqueId;this.editorData.map=ue}this.comment=e.comment,i||(this._mode=(o=e.mode)!==null&&o!==void 0?o:Rn.Material)},t.prototype.clone=function(e){var n=this,i=this.serialize(),o=L.a.Clone(function(){return new t(e,n.getScene(),n.options)},this);return o.id=e,o.name=e,o.loadFromSerialization(i),o.build(),o},t.Parse=function(e,n,i){i===void 0&&(i="");var o=L.a.Parse(function(){return new t(e.name,n)},e,n,i);return o.loadFromSerialization(e,i),o.build(),o},t.ParseFromFileAsync=function(e,n,i){var o=new t(e,i);return new Promise(function(a,s){return o.loadAsync(n).then(function(){o.build(),a(o)}).catch(s)})},t.ParseFromSnippetAsync=function(e,n,i,o){var a=this;return i===void 0&&(i=""),e==="_BLANK"?Promise.resolve(this.CreateDefault("blank",n)):new Promise(function(s,d){var p=new re.a;p.addEventListener("readystatechange",function(){if(p.readyState==4)if(p.status==200){var y=JSON.parse(JSON.parse(p.responseText).jsonPayload),P=JSON.parse(y.nodeMaterial);o||((o=L.a.Parse(function(){return new t(e,n)},P,n,i)).uniqueId=n.getUniqueId()),o.loadFromSerialization(P),o.snippetId=e;try{o.build(),s(o)}catch(O){d(O)}}else d("Unable to load the snippet "+e)}),p.open("GET",a.SnippetUrl+"/"+e.replace(/#/g,"/")),p.send()})},t.CreateDefault=function(e,n){var i=new t(e,n);return i.setToDefault(),i.build(),i},t._BuildIdGenerator=0,t.EditorURL="https://unpkg.com/babylonjs-node-editor@"+Ue.a.Version+"/babylon.nodeEditor.js",t.SnippetUrl="https://snippet.babylonjs.com",t.IgnoreTexturesAtLoadTime=!1,Object(c.c)([Object(L.c)("mode")],t.prototype,"_mode",void 0),Object(c.c)([Object(L.c)("comment")],t.prototype,"comment",void 0),t}(na.a);R.a.RegisteredTypes["BABYLON.NodeMaterial"]=ya;var Sh=function(r){function t(e){var n=r.call(this,e,Re.Vertex)||this;return n.registerInput("matricesIndices",le.Vector4),n.registerInput("matricesWeights",le.Vector4),n.registerInput("matricesIndicesExtra",le.Vector4,!0),n.registerInput("matricesWeightsExtra",le.Vector4,!0),n.registerInput("world",le.Matrix),n.registerOutput("output",le.Matrix),n}return Object(c.d)(t,r),t.prototype.initialize=function(e){e._excludeVariableName("boneSampler"),e._excludeVariableName("boneTextureWidth"),e._excludeVariableName("mBones"),e._excludeVariableName("BonesPerMesh")},t.prototype.getClassName=function(){return"BonesBlock"},Object.defineProperty(t.prototype,"matricesIndices",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"matricesWeights",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"matricesIndicesExtra",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"matricesWeightsExtra",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"world",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(e){if(!this.matricesIndices.isConnected){var n=e.getInputBlockByPredicate(function(a){return a.isAttribute&&a.name==="matricesIndices"});n||(n=new At("matricesIndices")).setAsAttribute("matricesIndices"),n.output.connectTo(this.matricesIndices)}if(!this.matricesWeights.isConnected){var i=e.getInputBlockByPredicate(function(a){return a.isAttribute&&a.name==="matricesWeights"});i||(i=new At("matricesWeights")).setAsAttribute("matricesWeights"),i.output.connectTo(this.matricesWeights)}if(!this.world.isConnected){var o=e.getInputBlockByPredicate(function(a){return a.systemValue===bt.World});
7574o||(o=new At("world")).setAsSystemValue(bt.World),o.output.connectTo(this.world)}},t.prototype.provideFallbacks=function(e,n){e&&e.useBones&&e.computeBonesUsingShaders&&e.skeleton&&n.addCPUSkinningFallback(0,e)},t.prototype.bind=function(e,n,i){tt.a.BindBonesParameters(i,e)},t.prototype.prepareDefines=function(e,n,i){i._areAttributesDirty&&tt.a.PrepareDefinesForBones(e,i)},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e),e.sharedData.blocksWithFallbacks.push(this),e.sharedData.bindableBlocks.push(this),e.sharedData.blocksWithDefines.push(this),e.uniforms.push("boneTextureWidth"),e.uniforms.push("mBones"),e.samplers.push("boneSampler");var n="//"+this.name;e._emitFunctionFromInclude("bonesDeclaration",n,{removeAttributes:!0,removeUniforms:!1,removeVaryings:!0,removeIfDef:!1});var i=e._getFreeVariableName("influence");e.compilationString+=e._emitCodeFromInclude("bonesVertex",n,{replaceStrings:[{search:/finalWorld=finalWorld\*influence;/,replace:""},{search:/influence/gm,replace:i}]});var o=this._outputs[0],a=this.world;return e.compilationString+=`#if NUM_BONE_INFLUENCERS>0\r
7575`,e.compilationString+=this._declareOutput(o,e)+" = "+a.associatedVariableName+" * "+i+`;\r
7576`,e.compilationString+=`#else\r
7577`,e.compilationString+=this._declareOutput(o,e)+" = "+a.associatedVariableName+`;\r
7578`,e.compilationString+=`#endif\r
7579`,this},t}(pt);R.a.RegisteredTypes["BABYLON.BonesBlock"]=Sh;var Ah=function(r){function t(e){var n=r.call(this,e,Re.Vertex)||this;return n.registerInput("world0",le.Vector4),n.registerInput("world1",le.Vector4),n.registerInput("world2",le.Vector4),n.registerInput("world3",le.Vector4),n.registerInput("world",le.Matrix,!0),n.registerOutput("output",le.Matrix),n.registerOutput("instanceID",le.Float),n}return Object(c.d)(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){if(!this.world0.connectedPoint){var n=e.getInputBlockByPredicate(function(d){return d.isAttribute&&d.name==="world0"});n||(n=new At("world0")).setAsAttribute("world0"),n.output.connectTo(this.world0)}if(!this.world1.connectedPoint){var i=e.getInputBlockByPredicate(function(d){return d.isAttribute&&d.name==="world1"});i||(i=new At("world1")).setAsAttribute("world1"),i.output.connectTo(this.world1)}if(!this.world2.connectedPoint){var o=e.getInputBlockByPredicate(function(d){return d.isAttribute&&d.name==="world2"});o||(o=new At("world2")).setAsAttribute("world2"),o.output.connectTo(this.world2)}if(!this.world3.connectedPoint){var a=e.getInputBlockByPredicate(function(d){return d.isAttribute&&d.name==="world3"});a||(a=new At("world3")).setAsAttribute("world3"),a.output.connectTo(this.world3)}if(!this.world.connectedPoint){var s=e.getInputBlockByPredicate(function(d){return d.isAttribute&&d.name==="world"});s||(s=new At("world")).setAsSystemValue(bt.World),s.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),e.sharedData.blocksWithDefines.push(this);var n=this._outputs[0],i=this._outputs[1],o=this.world0,a=this.world1,s=this.world2,d=this.world3;return e.compilationString+=`#ifdef INSTANCES\r
7580`,e.compilationString+=this._declareOutput(n,e)+" = mat4("+o.associatedVariableName+", "+a.associatedVariableName+", "+s.associatedVariableName+", "+d.associatedVariableName+`);\r
7581`,e.compilationString+=`#ifdef THIN_INSTANCES\r
7582`,e.compilationString+=n.associatedVariableName+" = "+this.world.associatedVariableName+" * "+n.associatedVariableName+`;\r
7583`,e.compilationString+=`#endif\r
7584`,e.compilationString+=this._declareOutput(i,e)+` = float(gl_InstanceID);\r
7585`,e.compilationString+=`#else\r
7586`,e.compilationString+=this._declareOutput(n,e)+" = "+this.world.associatedVariableName+`;\r
7587`,e.compilationString+=this._declareOutput(i,e)+` = 0.0;\r
7588`,e.compilationString+=`#endif\r
7589`,this},t}(pt);R.a.RegisteredTypes["BABYLON.InstancesBlock"]=Ah;var Ph=function(r){function t(e){var n=r.call(this,e,Re.Vertex)||this;return n.registerInput("position",le.Vector3),n.registerInput("normal",le.Vector3),n.registerInput("tangent",le.Vector3),n.registerInput("uv",le.Vector2),n.registerOutput("positionOutput",le.Vector3),n.registerOutput("normalOutput",le.Vector3),n.registerOutput("tangentOutput",le.Vector3),n.registerOutput("uvOutput",le.Vector2),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"MorphTargetsBlock"},Object.defineProperty(t.prototype,"position",{get:function(){return this._inputs[0]}
7589,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")},t.prototype.autoConfigure=function(e){if(!this.position.isConnected){var n=e.getInputBlockByPredicate(function(s){return s.isAttribute&&s.name==="position"});n||(n=new At("position")).setAsAttribute(),n.output.connectTo(this.position)}if(!this.normal.isConnected){var i=e.getInputBlockByPredicate(function(s){return s.isAttribute&&s.name==="normal"});i||(i=new At("normal")).setAsAttribute("normal"),i.output.connectTo(this.normal)}if(!this.tangent.isConnected){var o=e.getInputBlockByPredicate(function(s){return s.isAttribute&&s.name==="tangent"});o||(o=new At("tangent")).setAsAttribute("tangent"),o.output.connectTo(this.tangent)}if(!this.uv.isConnected){var a=e.getInputBlockByPredicate(function(s){return s.isAttribute&&s.name==="uv"});a||(a=new At("uv")).setAsAttribute("uv"),a.output.connectTo(this.uv)}},t.prototype.prepareDefines=function(e,n,i){i._areAttributesDirty&&tt.a.PrepareDefinesForMorphTargets(e,i)},t.prototype.bind=function(e,n,i){i&&i.morphTargetManager&&i.morphTargetManager.numInfluencers>0&&tt.a.BindMorphTargetParameters(i,e)},t.prototype.replaceRepeatableContent=function(e,n,i,o){for(var a=this.position,s=this.normal,d=this.tangent,p=this.uv,y=this.positionOutput,P=this.normalOutput,O=this.tangentOutput,U=this.uvOutput,F=e,z=o.NUM_MORPH_INFLUENCERS,J=i.morphTargetManager,ie=J&&J.supportsNormals&&o.NORMAL,se=J&&J.supportsTangents&&o.TANGENT,ce=J&&J.supportsUVs&&o.UV1,ue="",fe=0;fe<z;fe++)ue+=`#ifdef MORPHTARGETS\r
7590`,ue+=y.associatedVariableName+" += (position"+fe+" - "+a.associatedVariableName+") * morphTargetInfluences["+fe+`];\r
7591`,ie&&(ue+=`#ifdef MORPHTARGETS_NORMAL\r
7592`,ue+=P.associatedVariableName+" += (normal"+fe+" - "+s.associatedVariableName+") * morphTargetInfluences["+fe+`];\r
7593`,ue+=`#endif\r
7594`),se&&(ue+=`#ifdef MORPHTARGETS_TANGENT\r
7595`,ue+=O.associatedVariableName+".xyz += (tangent"+fe+" - "+d.associatedVariableName+".xyz) * morphTargetInfluences["+fe+`];\r
7596`,ue+=`#endif\r
7597`),ce&&(ue+=`#ifdef MORPHTARGETS_UV\r
7598`,ue+=U.associatedVariableName+".xy += (uv_"+fe+" - "+p.associatedVariableName+".xy) * morphTargetInfluences["+fe+`];\r
7599`,ue+=`#endif\r
7600`),ue+=`#endif\r
7601`;if(F.compilationString=F.compilationString.replace(this._repeatableContentAnchor,ue),z>0)for(fe=0;fe<z;fe++)F.attributes.push(Me.b.PositionKind+fe),ie&&F.attributes.push(Me.b.NormalKind+fe),se&&F.attributes.push(Me.b.TangentKind+fe),ce&&F.attributes.push(Me.b.UVKind+"_"+fe)},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e),e.sharedData.blocksWithDefines.push(this),e.sharedData.bindableBlocks.push(this),e.sharedData.repeatableContentBlocks.push(this);var n=this.position,i=this.normal,o=this.tangent,a=this.uv,s=this.positionOutput,d=this.normalOutput,p=this.tangentOutput,y=this.uvOutput,P="//"+this.name;return e.uniforms.push("morphTargetInfluences"),e._emitFunctionFromInclude("morphTargetsVertexGlobalDeclaration",P),e._emitFunctionFromInclude("morphTargetsVertexDeclaration",P,{repeatKey:"maxSimultaneousMorphTargets"}),e.compilationString+=this._declareOutput(s,e)+" = "+n.associatedVariableName+`;\r
7602`,e.compilationString+=`#ifdef NORMAL\r
7603`,e.compilationString+=this._declareOutput(d,e)+" = "+i.associatedVariableName+`;\r
7604`,e.compilationString+=`#else\r
7605`,e.compilationString+=this._declareOutput(d,e)+` = vec3(0., 0., 0.);\r
7606`,e.compilationString+=`#endif\r
7607`,e.compilationString+=`#ifdef TANGENT\r
7608`,e.compilationString+=this._declareOutput(p,e)+" = "+o.associatedVariableName+`;\r
7609`,e.compilationString+=`#else\r
7610`,e.compilationString+=this._declareOutput(p,e)+` = vec3(0., 0., 0.);\r
7611`,e.compilationString+=`#endif\r
7612`,e.compilationString+=`#ifdef UV1\r
7613`,e.compilationString+=this._declareOutput(y,e)+" = "+a.associatedVariableName+`;\r
7614`,e.compilationString+=`#else\r
7615`,e.compilationString+=this._declareOutput(y,e)+` = vec2(0., 0.);\r
7616`,e.compilationString+=`#endif\r
7617`,this._repeatableContentAnchor=e._repeatableContentAnchor,e.compilationString+=this._repeatableContentAnchor,this},t}(pt);R.a.RegisteredTypes["BABYLON.MorphTargetsBlock"]=Ph;var Ch=function(r){function t(e){var n=r.call(this,e,Re.Vertex)||this;return n.registerInput("worldPosition",le.Vector4,!1,Re.Vertex),n.registerOutput("direction",le.Vector3),n.registerOutput("color",le.Color3),n.registerOutput("intensity",le.Float),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"LightInformationBlock"},Object.defineProperty(t.prototype,"worldPosition",{get:function(){return this._inputs[0]}
7617,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"direction",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"color",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"intensity",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),t.prototype.bind=function(e,n,i){if(i){this.light&&this.light.isDisposed&&(this.light=null);var o=this.light,a=n.getScene();if(!o&&a.lights.length&&(o=a.lights[0]),!o||!o.isEnabled)return e.setFloat3(this._lightDataUniformName,0,0,0),void e.setFloat4(this._lightColorUniformName,0,0,0,0);o.transferToNodeMaterialEffect(e,this._lightDataUniformName),e.setColor4(this._lightColorUniformName,o.diffuse,o.intensity)}},t.prototype.prepareDefines=function(e,n,i){if(i._areLightsDirty){var o=this.light;i.setValue(this._lightTypeDefineName,!!(o&&o instanceof Qs))}},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e),e.sharedData.bindableBlocks.push(this),e.sharedData.blocksWithDefines.push(this);var n=this.direction,i=this.color,o=this.intensity;return this._lightDataUniformName=e._getFreeVariableName("lightData"),this._lightColorUniformName=e._getFreeVariableName("lightColor"),this._lightTypeDefineName=e._getFreeDefineName("LIGHTPOINTTYPE"),e._emitUniformFromString(this._lightDataUniformName,"vec3"),e._emitUniformFromString(this._lightColorUniformName,"vec4"),e.compilationString+="#ifdef "+this._lightTypeDefineName+`\r
7618`,e.compilationString+=this._declareOutput(n,e)+" = normalize("+this.worldPosition.associatedVariableName+".xyz - "+this._lightDataUniformName+`);\r
7619`,e.compilationString+=`#else\r
7620`,e.compilationString+=this._declareOutput(n,e)+" = "+this._lightDataUniformName+`;\r
7621`,e.compilationString+=`#endif\r
7622`,e.compilationString+=this._declareOutput(i,e)+" = "+this._lightColorUniformName+`.rgb;\r
7623`,e.compilationString+=this._declareOutput(o,e)+" = "+this._lightColorUniformName+`.a;\r
7624`,this},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return this.light&&(e.lightId=this.light.id),e},t.prototype._deserialize=function(e,n,i){r.prototype._deserialize.call(this,e,n,i),e.lightId&&(this.light=n.getLightByID(e.lightId))},t}(pt);R.a.RegisteredTypes["BABYLON.LightInformationBlock"]=Ch;var xh=function(r){function t(e){var n=r.call(this,e,Re.Fragment)||this;return n.registerInput("color",le.Color4),n.registerOutput("output",le.Color4),n._inputs[0].acceptedConnectionPointTypes.push(le.Color3),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"ImageProcessingBlock"},Object.defineProperty(t.prototype,"color",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.initialize=function(e){e._excludeVariableName("exposureLinear"),e._excludeVariableName("contrast"),e._excludeVariableName("vInverseScreenSize"),e._excludeVariableName("vignetteSettings1"),e._excludeVariableName("vignetteSettings2"),e._excludeVariableName("vCameraColorCurveNegative"),e._excludeVariableName("vCameraColorCurveNeutral"),e._excludeVariableName("vCameraColorCurvePositive"),e._excludeVariableName("txColorTransform"),e._excludeVariableName("colorTransformSettings")},t.prototype.isReady=function(e,n,i){return!(i._areImageProcessingDirty&&n.imageProcessingConfiguration&&!n.imageProcessingConfiguration.isReady())},t.prototype.prepareDefines=function(e,n,i){i._areImageProcessingDirty&&n.imageProcessingConfiguration&&n.imageProcessingConfiguration.prepareDefines(i)},t.prototype.bind=function(e,n,i){i&&n.imageProcessingConfiguration&&n.imageProcessingConfiguration.bind(e)},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e),e.sharedData.blocksWithDefines.push(this),e.sharedData.blockingBlocks.push(this),e.sharedData.bindableBlocks.push(this),e.uniforms.push("exposureLinear"),e.uniforms.push("contrast"),e.uniforms.push("vInverseScreenSize"),e.uniforms.push("vignetteSettings1"),e.uniforms.push("vignetteSettings2"),e.uniforms.push("vCameraColorCurveNegative"),e.uniforms.push("vCameraColorCurveNeutral"),e.uniforms.push("vCameraColorCurvePositive"),e.uniforms.push("txColorTransform"),e.uniforms.push("colorTransformSettings");var n=this.color,i=this._outputs[0],o="//"+this.name;return e._emitFunctionFromInclude("helperFunctions",o),e._emitFunctionFromInclude("imageProcessingDeclaration",o),e._emitFunctionFromInclude("imageProcessingFunctions",o),n.connectedPoint.type===le.Color4||n.connectedPoint.type===le.Vector4?e.compilationString+=this._declareOutput(i,e)+" = "+n.associatedVariableName+`;\r
7625`:e.compilationString+=this._declareOutput(i,e)+" = vec4("+n.associatedVariableName+`, 1.0);\r
7626`,e.compilationString+=`#ifdef IMAGEPROCESSINGPOSTPROCESS\r
7627`,e.compilationString+=i.associatedVariableName+".rgb = toLinearSpace("+n.associatedVariableName+`.rgb);\r
7628`,e.compilationString+=`#else\r
7629`,e.compilationString+=`#ifdef IMAGEPROCESSING\r
7630`,e.compilationString+=i.associatedVariableName+".rgb = toLinearSpace("+n.associatedVariableName+`.rgb);\r
7631`,e.compilationString+=i.associatedVariableName+" = applyImageProcessing("+i.associatedVariableName+`);\r
7632`,e.compilationString+=`#endif\r
7633`,e.compilationString+=`#endif\r
7634`,this},t}(pt);R.a.RegisteredTypes["BABYLON.ImageProcessingBlock"]=xh;var Rh=function(r){function t(e){var n=r.call(this,e,Re.Fragment)||this;return n._tangentSpaceParameterName="",n.invertX=!1,n.invertY=!1,n.registerInput("worldPosition",le.Vector4,!1),n.registerInput("worldNormal",le.Vector4,!1),n.registerInput("worldTangent",le.Vector4,!0),n.registerInput("uv",le.Vector2,!1),n.registerInput("normalMapColor",le.Color3,!1),n.registerInput("strength",le.Float,!1),n.registerOutput("output",le.Vector4),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"PerturbNormalBlock"},Object.defineProperty(t.prototype,"worldPosition",{get:function(){return this._inputs[0]}
7634,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldNormal",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldTangent",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"uv",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normalMapColor",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"strength",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.prepareDefines=function(e,n,i){i.setValue("BUMP",!0)},t.prototype.bind=function(e,n,i){n.getScene()._mirroredCameraPosition?e.setFloat2(this._tangentSpaceParameterName,this.invertX?1:-1,this.invertY?1:-1):e.setFloat2(this._tangentSpaceParameterName,this.invertX?-1:1,this.invertY?-1:1)},t.prototype.autoConfigure=function(e){if(!this.uv.isConnected){var n=e.getInputBlockByPredicate(function(o){return o.isAttribute&&o.name==="uv"});n||(n=new At("uv")).setAsAttribute(),n.output.connectTo(this.uv)}if(!this.strength.isConnected){var i=new At("strength");i.value=1,i.output.connectTo(this.strength)}},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n="//"+this.name,i=this.uv,o=this.worldPosition,a=this.worldNormal,s=this.worldTangent;e.sharedData.blocksWithDefines.push(this),e.sharedData.bindableBlocks.push(this),this._tangentSpaceParameterName=e._getFreeDefineName("tangentSpaceParameter"),e._emitUniformFromString(this._tangentSpaceParameterName,"vec2");var d=this.strength.isConnectedToInputBlock&&this.strength.connectInputBlock.isConstant?""+e._emitFloat(1/this.strength.connectInputBlock.value):"1.0 / "+this.strength.associatedVariableName;e._emitExtension("derivatives","#extension GL_OES_standard_derivatives : enable");var p={search:/defined\(TANGENT\)/g,replace:s.isConnected?"defined(TANGENT)":"defined(IGNORE)"};return s.isConnected&&(e.compilationString+="vec3 tbnNormal = normalize("+a.associatedVariableName+`.xyz);\r
7635`,e.compilationString+="vec3 tbnTangent = normalize("+s.associatedVariableName+`.xyz);\r
7636`,e.compilationString+=`vec3 tbnBitangent = cross(tbnNormal, tbnTangent);\r
7637`,e.compilationString+=`mat3 vTBN = mat3(tbnTangent, tbnBitangent, tbnNormal);\r
7638`),e._emitFunctionFromInclude("bumpFragmentMainFunctions",n,{replaceStrings:[p]}),e._emitFunctionFromInclude("bumpFragmentFunctions",n,{replaceStrings:[{search:/vBumpInfos.y/g,replace:d},{search:/vTangentSpaceParams/g,replace:this._tangentSpaceParameterName},{search:/vPositionW/g,replace:o.associatedVariableName+".xyz"}]}),e.compilationString+=this._declareOutput(this.output,e)+` = vec4(0.);\r
7639`,e.compilationString+=e._emitCodeFromInclude("bumpFragment",n,{replaceStrings:[{search:/perturbNormal\(TBN,vBumpUV\+uvOffset\)/g,replace:"perturbNormal(TBN, "+this.normalMapColor.associatedVariableName+")"},{search:/vBumpInfos.y/g,replace:d},{search:/vBumpUV/g,replace:i.associatedVariableName},{search:/vPositionW/g,replace:o.associatedVariableName+".xyz"},{search:/normalW=/g,replace:this.output.associatedVariableName+".xyz = "},{search:/mat3\(normalMatrix\)\*normalW/g,replace:"mat3(normalMatrix) * "+this.output.associatedVariableName+".xyz"},{search:/normalW/g,replace:a.associatedVariableName+".xyz"},p]}),this},t.prototype._dumpPropertiesCode=function(){var e=this._codeVariableName+".invertX = "+this.invertX+`;\r
7640`;return e+=this._codeVariableName+".invertY = "+this.invertY+`;\r
7641`},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.invertX=this.invertX,e.invertY=this.invertY,e},t.prototype._deserialize=function(e,n,i){r.prototype._deserialize.call(this,e,n,i),this.invertX=e.invertX,this.invertY=e.invertY},Object(c.c)([Vt("Invert X axis",Lt.Boolean,"PROPERTIES",{notifiers:{update:!1}})],t.prototype,"invertX",void 0),Object(c.c)([Vt("Invert Y axis",Lt.Boolean,"PROPERTIES",{notifiers:{update:!1}})],t.prototype,"invertY",void 0),t}(pt);R.a.RegisteredTypes["BABYLON.PerturbNormalBlock"]=Rh;var Oh=function(r){function t(e){var n=r.call(this,e,Re.Fragment,!0)||this;return n.registerInput("value",le.Float,!0),n.registerInput("cutoff",le.Float,!0),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"DiscardBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]}
7641,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 ("+this.value.associatedVariableName+" < "+this.cutoff.associatedVariableName+`) discard;\r
7642`,this},t}(pt);R.a.RegisteredTypes["BABYLON.DiscardBlock"]=Oh;var Mh=function(r){function t(e){var n=r.call(this,e,Re.Fragment)||this;return n.registerOutput("output",le.Float,Re.Fragment),n}return Object(c.d)(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===Re.Vertex)throw"FrontFacingBlock must only be used in a fragment shader";var n=this._outputs[0];return e.compilationString+=this._declareOutput(n,e)+` = gl_FrontFacing ? 1.0 : 0.0;\r
7643`,this},t}(pt);R.a.RegisteredTypes["BABYLON.FrontFacingBlock"]=Mh;var Ih=function(r){function t(e){var n=r.call(this,e,Re.Fragment)||this;return n.registerInput("input",le.AutoDetect,!1),n.registerOutput("dx",le.BasedOnInput),n.registerOutput("dy",le.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._outputs[1]._typeConnectionSource=n._inputs[0],n}return Object(c.d)(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];return e._emitExtension("derivatives","#extension GL_OES_standard_derivatives : enable"),n.hasEndpoints&&(e.compilationString+=this._declareOutput(n,e)+" = dFdx("+this.input.associatedVariableName+`);\r
7644`),i.hasEndpoints&&(e.compilationString+=this._declareOutput(i,e)+" = dFdy("+this.input.associatedVariableName+`);\r
7645`),this},t}(pt);R.a.RegisteredTypes["BABYLON.DerivativeBlock"]=Ih;var Dh=function(r){function t(e){var n=r.call(this,e,Re.Fragment)||this;return n.registerOutput("xy",le.Vector2,Re.Fragment),n.registerOutput("xyz",le.Vector3,Re.Fragment),n.registerOutput("xyzw",le.Vector4,Re.Fragment),n.registerOutput("x",le.Float,Re.Fragment),n.registerOutput("y",le.Float,Re.Fragment),n.registerOutput("z",le.Float,Re.Fragment),n.registerOutput("w",le.Float,Re.Fragment),n}return Object(c.d)(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=0,o=this._outputs;i<o.length;i++){var a=o[i];a.hasEndpoints&&(n+=this._declareOutput(a,e)+" = gl_FragCoord."+a.name+`;\r
7646`)}return n},t.prototype._buildBlock=function(e){if(r.prototype._buildBlock.call(this,e),e.target===Re.Vertex)throw"FragCoordBlock must only be used in a fragment shader";return e.compilationString+=this.writeOutputs(e),this},t}(pt);R.a.RegisteredTypes["BABYLON.FragCoordBlock"]=Dh;var Lh=function(r){function t(e){var n=r.call(this,e,Re.Fragment)||this;return n.registerOutput("xy",le.Vector2,Re.Fragment),n.registerOutput("x",le.Float,Re.Fragment),n.registerOutput("y",le.Float,Re.Fragment),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"ScreenSizeBlock"},Object.defineProperty(t.prototype,"xy",{get:function(){return this._outputs[0]}
7646,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"x",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),t.prototype.bind=function(e,n,i){var o=this._scene.getEngine();e.setFloat2(this._varName,o.getRenderWidth(),o.getRenderWidth())},t.prototype.writeOutputs=function(e,n){for(var i="",o=0,a=this._outputs;o<a.length;o++){var s=a[o];s.hasEndpoints&&(i+=this._declareOutput(s,e)+" = "+n+"."+s.name+`;\r
7647`)}return i},t.prototype._buildBlock=function(e){if(r.prototype._buildBlock.call(this,e),this._scene=e.sharedData.scene,e.target===Re.Vertex)throw"ScreenSizeBlock must only be used in a fragment shader";return e.sharedData.bindableBlocks.push(this),this._varName=e._getFreeVariableName("screenSize"),e._emitUniformFromString(this._varName,"vec2"),e.compilationString+=this.writeOutputs(e,this._varName),this},t}(pt);R.a.RegisteredTypes["BABYLON.ScreenSizeBlock"]=Lh;var Nh=function(r){function t(e){var n=r.call(this,e,Re.VertexAndFragment,!0)||this;return n.registerInput("worldPosition",le.Vector4,!1,Re.Vertex),n.registerInput("view",le.Matrix,!1,Re.Vertex),n.registerInput("input",le.Color3,!1,Re.Fragment),n.registerInput("fogColor",le.Color3,!1,Re.Fragment),n.registerOutput("output",le.Color3,Re.Fragment),n.input.acceptedConnectionPointTypes.push(le.Color4),n.fogColor.acceptedConnectionPointTypes.push(le.Color4),n}return Object(c.d)(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.autoConfigure=function(e){if(!this.view.isConnected){var n=e.getInputBlockByPredicate(function(o){return o.systemValue===bt.View});n||(n=new At("view")).setAsSystemValue(bt.View),n.output.connectTo(this.view)}if(!this.fogColor.isConnected){var i=e.getInputBlockByPredicate(function(o){return o.systemValue===bt.FogColor});i||(i=new At("fogColor",void 0,le.Color3)).setAsSystemValue(bt.FogColor),i.output.connectTo(this.fogColor)}},t.prototype.prepareDefines=function(e,n,i){var o=e.getScene();i.setValue("FOG",n.fogEnabled&&tt.a.GetFogState(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===Re.Fragment){e.sharedData.blocksWithDefines.push(this),e.sharedData.bindableBlocks.push(this),e._emitFunctionFromInclude("fogFragmentDeclaration","//"+this.name,{removeUniforms:!0,removeVaryings:!0,removeIfDef:!1,replaceStrings:[{search:/float CalcFogFactor\(\)/,replace:"float CalcFogFactor(vec3 vFogDistance, vec4 vFogInfos)"}]});var n=e._getFreeVariableName("fog"),i=this.input,o=this.fogColor;this._fogParameters=e._getFreeVariableName("fogParameters");var a=this._outputs[0];e._emitUniformFromString(this._fogParameters,"vec4"),e.compilationString+=`#ifdef FOG\r
7648`,e.compilationString+="float "+n+" = CalcFogFactor("+this._fogDistanceName+", "+this._fogParameters+`);\r
7649`,e.compilationString+=this._declareOutput(a,e)+" = "+n+" * "+i.associatedVariableName+".rgb + (1.0 - "+n+") * "+o.associatedVariableName+`.rgb;\r
7650`,e.compilationString+=`#else\r
7651`+this._declareOutput(a,e)+" =  "+i.associatedVariableName+`.rgb;\r
7652`,e.compilationString+=`#endif\r
7653`}else{var s=this.worldPosition,d=this.view;this._fogDistanceName=e._getFreeVariableName("vFogDistance"),e._emitVaryingFromString(this._fogDistanceName,"vec3"),e.compilationString+=this._fogDistanceName+" = ("+d.associatedVariableName+" * "+s.associatedVariableName+`).xyz;\r
7654`}return this},t}(pt);R.a.RegisteredTypes["BABYLON.FogBlock"]=Nh;var wh=function(r){function t(e){var n=r.call(this,e,Re.VertexAndFragment)||this;return n._isUnique=!0,n.registerInput("worldPosition",le.Vector4,!1,Re.Vertex),n.registerInput("worldNormal",le.Vector4,!1,Re.Fragment),n.registerInput("cameraPosition",le.Vector3,!1,Re.Fragment),n.registerInput("glossiness",le.Float,!0,Re.Fragment),n.registerInput("glossPower",le.Float,!0,Re.Fragment),n.registerInput("diffuseColor",le.Color3,!0,Re.Fragment),n.registerInput("specularColor",le.Color3,!0,Re.Fragment),n.registerInput("view",le.Matrix,!0),n.registerOutput("diffuseOutput",le.Color3,Re.Fragment),n.registerOutput("specularOutput",le.Color3,Re.Fragment),n.registerOutput("shadow",le.Float,Re.Fragment),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"LightBlock"},Object.defineProperty(t.prototype,"worldPosition",{get:function(){return this._inputs[0]}
7654,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.autoConfigure=function(e){if(!this.cameraPosition.isConnected){var n=e.getInputBlockByPredicate(function(i){return i.systemValue===bt.CameraPosition});n||(n=new At("cameraPosition")).setAsSystemValue(bt.CameraPosition),n.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};tt.a.PrepareDefinesForLight(o,e,this.light,this._lightId,i,!0,a),a.needRebuild&&i.rebuild()}else tt.a.PrepareDefinesForLights(o,e,i,!0,n.maxSimultaneousLights)}},t.prototype.updateUniformsAndSamples=function(e,n,i,o){for(var a=0;a<n.maxSimultaneousLights&&i["LIGHT"+a];a++){var s=e.uniforms.indexOf("vLightData"+a)>=0;tt.a.PrepareUniformsAndSamplersForLight(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?tt.a.BindLight(this.light,this._lightId,o,e,!0):tt.a.BindLights(o,i,e,!0,n.maxSimultaneousLights)}},t.prototype._injectVertexCode=function(e){var n=this.worldPosition,i="//"+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?"lightUboDeclaration":"lightFragmentDeclaration",i,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]},this._lightId.toString())):(e._emitFunctionFromInclude(e.supportUniformBuffers?"lightUboDeclaration":"lightFragmentDeclaration",i,{repeatKey:"maxSimultaneousLights"}),this._lightId=0,e.sharedData.dynamicUniformBlocks.push(this));var o="v_"+n.associatedVariableName;e._emitVaryingFromString(o,"vec4")&&(e.compilationString+=o+" = "+n.associatedVariableName+`;\r
7655`),this.light?e.compilationString+=e._emitCodeFromInclude("shadowsVertex",i,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()},{search:/worldPos/g,replace:n.associatedVariableName}]}):(e.compilationString+="vec4 worldPos = "+n.associatedVariableName+`;\r
7656`,this.view.isConnected&&(e.compilationString+="mat4 view = "+this.view.associatedVariableName+`;\r
7657`),e.compilationString+=e._emitCodeFromInclude("shadowsVertex",i,{repeatKey:"maxSimultaneousLights"}))},t.prototype._buildBlock=function(e){if(r.prototype._buildBlock.call(this,e),e.target===Re.Fragment){e.sharedData.bindableBlocks.push(this),e.sharedData.blocksWithDefines.push(this);var n="//"+this.name,i=this.worldPosition;e._emitFunctionFromInclude("helperFunctions",n),e._emitFunctionFromInclude("lightsFragmentFunctions",n,{replaceStrings:[{search:/vPositionW/g,replace:"v_"+i.associatedVariableName+".xyz"}]}),e._emitFunctionFromInclude("shadowsFragmentFunctions",n,{replaceStrings:[{search:/vPositionW/g,replace:"v_"+i.associatedVariableName+".xyz"}]}),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"}),this._lightId===0&&(e._registerTempVariable("viewDirectionW")&&(e.compilationString+="vec3 viewDirectionW = normalize("+this.cameraPosition.associatedVariableName+" - v_"+i.associatedVariableName+`.xyz);\r
7658`),e.compilationString+=`lightingInfo info;\r
7659`,e.compilationString+=`float shadow = 1.;\r
7660`,e.compilationString+="float glossiness = "+(this.glossiness.isConnected?this.glossiness.associatedVariableName:"1.0")+" * "+(this.glossPower.isConnected?this.glossPower.associatedVariableName:"1024.0")+`;\r
7661`,e.compilationString+=`vec3 diffuseBase = vec3(0., 0., 0.);\r
7662`,e.compilationString+=`vec3 specularBase = vec3(0., 0., 0.);\r
7663`,e.compilationString+="vec3 normalW = "+this.worldNormal.associatedVariableName+`.xyz;\r
7664`),this.light?e.compilationString+=e._emitCodeFromInclude("lightFragment",n,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]}):e.compilationString+=e._emitCodeFromInclude("lightFragment",n,{repeatKey:"maxSimultaneousLights"});var o=this.diffuseOutput,a=this.specularOutput;return e.compilationString+=this._declareOutput(o,e)+" = diffuseBase"+(this.diffuseColor.isConnected?" * "+this.diffuseColor.associatedVariableName:"")+`;\r
7665`,a.hasEndpoints&&(e.compilationString+=this._declareOutput(a,e)+" = specularBase"+(this.specularColor.isConnected?" * "+this.specularColor.associatedVariableName:"")+`;\r
7666`),this.shadow.hasEndpoints&&(e.compilationString+=this._declareOutput(this.shadow,e)+` = shadow;\r
7667`),this}this._injectVertexCode(e)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return this.light&&(e.lightId=this.light.id),e},t.prototype._deserialize=function(e,n,i){r.prototype._deserialize.call(this,e,n,i),e.lightId&&(this.light=n.getLightByID(e.lightId))},t}(pt);R.a.RegisteredTypes["BABYLON.LightBlock"]=wh;var Fh=function(r){function t(e,n){n===void 0&&(n=!1);var i=r.call(this,e,n?Re.Fragment:Re.VertexAndFragment)||this;
7667return i.convertToGammaSpace=!1,i.convertToLinearSpace=!1,i._fragmentOnly=n,i.registerInput("uv",le.Vector2,!1,Re.VertexAndFragment),i.registerOutput("rgba",le.Color4,Re.Neutral),i.registerOutput("rgb",le.Color3,Re.Neutral),i.registerOutput("r",le.Float,Re.Neutral),i.registerOutput("g",le.Float,Re.Neutral),i.registerOutput("b",le.Float,Re.Neutral),i.registerOutput("a",le.Float,Re.Neutral),i._inputs[0].acceptedConnectionPointTypes.push(le.Vector3),i._inputs[0].acceptedConnectionPointTypes.push(le.Vector4),i._inputs[0]._prioritizeVertex=!n,i}return Object(c.d)(t,r),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,"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,"target",{get:function(){if(this._fragmentOnly)return Re.Fragment;if(!this.uv.isConnected||this.uv.sourceBlock.isInput)return Re.VertexAndFragment;for(var e=this.uv.connectedPoint;e;){if(e.target===Re.Fragment)return Re.Fragment;if(e.target===Re.Vertex)return Re.VertexAndFragment;if(e.target===Re.Neutral||e.target===Re.VertexAndFragment){var n=e.ownerBlock;e=null;for(var i=0,o=n.inputs;i<o.length;i++){var a=o[i];if(a.connectedPoint){e=a.connectedPoint;break}}}}return Re.VertexAndFragment},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(e){if(!this.uv.isConnected)if(e.mode===Rn.PostProcess)(n=e.getBlockByPredicate(function(o){return o.name==="uv"}))&&n.connectTo(this);else{var n,i=e.mode===Rn.Particle?"particle_uv":"uv";(n=e.getInputBlockByPredicate(function(o){return o.isAttribute&&o.name===i}))||(n=new At("uv")).setAsAttribute(i),n.output.connectTo(this.uv)}},t.prototype.initializeDefines=function(e,n,i,o){i._areTexturesDirty&&i.setValue(this._mainUVDefineName,!1)},t.prototype.prepareDefines=function(e,n,i){if(i._areTexturesDirty){if(!this.texture||!this.texture.getTextureMatrix)return i.setValue(this._defineName,!1),void i.setValue(this._mainUVDefineName,!0);i.setValue(this._linearDefineName,this.convertToGammaSpace),i.setValue(this._gammaDefineName,this.convertToLinearSpace),this._isMixed&&(this.texture.getTextureMatrix().isIdentityAs3x2()?(i.setValue(this._defineName,!1),i.setValue(this._mainUVDefineName,!0)):i.setValue(this._defineName,!0))}},t.prototype.isReady=function(){return!(this.texture&&!this.texture.isReadyOrNotBlocking())},t.prototype.bind=function(e,n,i){this.texture&&(this._isMixed&&(e.setFloat(this._textureInfoName,this.texture.level),e.setMatrix(this._textureTransformName,this.texture.getTextureMatrix())),e.setTexture(this._samplerName,this.texture))},Object.defineProperty(t.prototype,"_isMixed",{get:function(){return this.target!==Re.Fragment},enumerable:!1,configurable:!0}),t.prototype._injectVertexCode=function(e){var n=this.uv;if(this._defineName=e._getFreeDefineName("UVTRANSFORM"),this._mainUVDefineName="VMAIN"+n.associatedVariableName.toUpperCase(),n.connectedPoint.ownerBlock.isInput&&(n.connectedPoint.ownerBlock.isAttribute||e._emitUniformFromString(n.associatedVariableName,"vec2")),this._mainUVName="vMain"+n.associatedVariableName,this._transformedUVName=e._getFreeVariableName("transformedUV"),this._textureTransformName=e._getFreeVariableName("textureTransform"),this._textureInfoName=e._getFreeVariableName("textureInfoName"),e._emitVaryingFromString(this._transformedUVName,"vec2",this._defineName),e._emitVaryingFromString(this._mainUVName,"vec2",this._mainUVDefineName),e._emitUniformFromString(this._textureTransformName,"mat4",this._defineName),e.compilationString+="#ifdef "+this._defineName+`\r
7668`,e.compilationString+=this._transformedUVName+" = vec2("+this._textureTransformName+" * vec4("+n.associatedVariableName+`.xy, 1.0, 0.0));\r
7669`,e.compilationString+="#elif defined("+this._mainUVDefineName+`)\r
7670`,e.compilationString+=this._mainUVName+" = "+n.associatedVariableName+`.xy;\r
7671`,e.compilationString+=`#endif\r
7672`,this._outputs.some(function(s){return s.isConnectedInVertexShader})){this._writeTextureRead(e,!0);for(var i=0,o=this._outputs;i<o.length;i++){var a=o[i];a.hasEndpoints&&this._writeOutput(e,a,a.name,!0)}}}
7672,t.prototype._writeTextureRead=function(e,n){n===void 0&&(n=!1);var i=this.uv;if(n){if(e.target===Re.Fragment)return;e.compilationString+="vec4 "+this._tempTextureRead+" = texture2D("+this._samplerName+", "+i.associatedVariableName+`);\r
7673`}else this.uv.ownerBlock.target!==Re.Fragment?(e.compilationString+="#ifdef "+this._defineName+`\r
7674`,e.compilationString+="vec4 "+this._tempTextureRead+" = texture2D("+this._samplerName+", "+this._transformedUVName+`);\r
7675`,e.compilationString+="#elif defined("+this._mainUVDefineName+`)\r
7676`,e.compilationString+="vec4 "+this._tempTextureRead+" = texture2D("+this._samplerName+", "+this._mainUVName+`);\r
7677`,e.compilationString+=`#endif\r
7678`):e.compilationString+="vec4 "+this._tempTextureRead+" = texture2D("+this._samplerName+", "+i.associatedVariableName+`);\r
7679`},t.prototype._writeOutput=function(e,n,i,o){if(o===void 0&&(o=!1),o){if(e.target===Re.Fragment)return;e.compilationString+=this._declareOutput(n,e)+" = "+this._tempTextureRead+"."+i+`;\r
7680`}else if(this.uv.ownerBlock.target!==Re.Fragment){var a=" * "+this._textureInfoName;e.compilationString+=this._declareOutput(n,e)+" = "+this._tempTextureRead+"."+i+a+`;\r
7681`,i!=="a"&&(e.compilationString+="#ifdef "+this._linearDefineName+`\r
7682`,e.compilationString+=n.associatedVariableName+" = toGammaSpace("+n.associatedVariableName+`);\r
7683`,e.compilationString+=`#endif\r
7684`,e.compilationString+="#ifdef "+this._gammaDefineName+`\r
7685`,e.compilationString+=n.associatedVariableName+" = toLinearSpace("+n.associatedVariableName+`);\r
7686`,e.compilationString+=`#endif\r
7687`)}else e.compilationString+=this._declareOutput(n,e)+" = "+this._tempTextureRead+"."+i+`;\r
7688`},t.prototype._buildBlock=function(e){if(r.prototype._buildBlock.call(this,e),(e.target===Re.Vertex||this._fragmentOnly)&&(this._tempTextureRead=e._getFreeVariableName("tempTextureRead")),(!this._isMixed&&e.target===Re.Fragment||this._isMixed&&e.target===Re.Vertex)&&(this._samplerName=e._getFreeVariableName(this.name+"Sampler"),e._emit2DSampler(this._samplerName),e.sharedData.blockingBlocks.push(this),e.sharedData.textureBlocks.push(this),e.sharedData.blocksWithDefines.push(this),e.sharedData.bindableBlocks.push(this)),e.target===Re.Fragment){if(this._outputs.some(function(s){return s.isConnectedInFragmentShader})){this._isMixed&&e._emit2DSampler(this._samplerName),this._linearDefineName=e._getFreeDefineName("ISLINEAR"),this._gammaDefineName=e._getFreeDefineName("ISGAMMA");var n="//"+this.name;e._emitFunctionFromInclude("helperFunctions",n),this._isMixed&&e._emitUniformFromString(this._textureInfoName,"float"),this._writeTextureRead(e);for(var i=0,o=this._outputs;i<o.length;i++){var a=o[i];a.hasEndpoints&&this._writeOutput(e,a,a.name)}return this}}else this._injectVertexCode(e)},t.prototype._dumpPropertiesCode=function(){if(!this.texture)return"";var e=this._codeVariableName+'.texture = new BABYLON.Texture("'+this.texture.name+`", null);\r
7689`;return e+=this._codeVariableName+".texture.wrapU = "+this.texture.wrapU+`;\r
7690`,e+=this._codeVariableName+".texture.wrapV = "+this.texture.wrapV+`;\r
7691`,e+=this._codeVariableName+".texture.uAng = "+this.texture.uAng+`;\r
7692`,e+=this._codeVariableName+".texture.vAng = "+this.texture.vAng+`;\r
7693`,e+=this._codeVariableName+".texture.wAng = "+this.texture.wAng+`;\r
7694`,e+=this._codeVariableName+".texture.uOffset = "+this.texture.uOffset+`;\r
7695`,e+=this._codeVariableName+".texture.vOffset = "+this.texture.vOffset+`;\r
7696`,e+=this._codeVariableName+".texture.uScale = "+this.texture.uScale+`;\r
7697`,e+=this._codeVariableName+".texture.vScale = "+this.texture.vScale+`;\r
7698`,e+=this._codeVariableName+".convertToGammaSpace = "+this.convertToGammaSpace+`;\r
7699`,e+=this._codeVariableName+".convertToLinearSpace = "+this.convertToLinearSpace+`;\r
7700`},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.convertToGammaSpace=this.convertToGammaSpace,e.convertToLinearSpace=this.convertToLinearSpace,e.fragmentOnly=this._fragmentOnly,this.texture&&!this.texture.isRenderTarget&&(e.texture=this.texture.serialize()),e},t.prototype._deserialize=function(e,n,i){r.prototype._deserialize.call(this,e,n,i),this.convertToGammaSpace=e.convertToGammaSpace,this.convertToLinearSpace
7700=!!e.convertToLinearSpace,this._fragmentOnly=!!e.fragmentOnly,e.texture&&!ya.IgnoreTexturesAtLoadTime&&(i=e.texture.url.indexOf("data:")===0?"":i,this.texture=we.a.Parse(e.texture,n,i))},t}(pt);R.a.RegisteredTypes["BABYLON.TextureBlock"]=Fh;var gc=function(r){function t(e){return r.call(this,e,Re.VertexAndFragment)||this}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"ReflectionTextureBaseBlock"},t.prototype._getTexture=function(){return this.texture},t.prototype.autoConfigure=function(e){if(!this.position.isConnected){var n=e.getInputBlockByPredicate(function(a){return a.isAttribute&&a.name==="position"});n||(n=new At("position")).setAsAttribute(),n.output.connectTo(this.position)}if(!this.world.isConnected){var i=e.getInputBlockByPredicate(function(a){return a.systemValue===bt.World});i||(i=new At("world")).setAsSystemValue(bt.World),i.output.connectTo(this.world)}if(this.view&&!this.view.isConnected){var o=e.getInputBlockByPredicate(function(a){return a.systemValue===bt.View});o||(o=new At("view")).setAsSystemValue(bt.View),o.output.connectTo(this.view)}},t.prototype.prepareDefines=function(e,n,i){if(i._areTexturesDirty){var o=this._getTexture();o&&o.getTextureMatrix&&(i.setValue(this._define3DName,o.isCube,!0),i.setValue(this._defineLocalCubicName,!!o.boundingBoxSize,!0),i.setValue(this._defineExplicitName,o.coordinatesMode===h.a.TEXTURE_EXPLICIT_MODE,!0),i.setValue(this._defineSkyboxName,o.coordinatesMode===h.a.TEXTURE_SKYBOX_MODE,!0),i.setValue(this._defineCubicName,o.coordinatesMode===h.a.TEXTURE_CUBIC_MODE||o.coordinatesMode===h.a.TEXTURE_INVCUBIC_MODE,!0),i.setValue("INVERTCUBICMAP",o.coordinatesMode===h.a.TEXTURE_INVCUBIC_MODE,!0),i.setValue(this._defineSphericalName,o.coordinatesMode===h.a.TEXTURE_SPHERICAL_MODE,!0),i.setValue(this._definePlanarName,o.coordinatesMode===h.a.TEXTURE_PLANAR_MODE,!0),i.setValue(this._defineProjectionName,o.coordinatesMode===h.a.TEXTURE_PROJECTION_MODE,!0),i.setValue(this._defineEquirectangularName,o.coordinatesMode===h.a.TEXTURE_EQUIRECTANGULAR_MODE,!0),i.setValue(this._defineEquirectangularFixedName,o.coordinatesMode===h.a.TEXTURE_FIXED_EQUIRECTANGULAR_MODE,!0),i.setValue(this._defineMirroredEquirectangularFixedName,o.coordinatesMode===h.a.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE,!0))}},t.prototype.isReady=function(){var e=this._getTexture();return!(e&&!e.isReadyOrNotBlocking())},t.prototype.bind=function(e,n,i){var o=this._getTexture();i&&o&&(e.setMatrix(this._reflectionMatrixName,o.getReflectionTextureMatrix()),o.isCube?e.setTexture(this._cubeSamplerName,o):e.setTexture(this._2DSamplerName,o))},t.prototype.handleVertexSide=function(e){this._define3DName=e._getFreeDefineName("REFLECTIONMAP_3D"),this._defineCubicName=e._getFreeDefineName("REFLECTIONMAP_CUBIC"),this._defineSphericalName=e._getFreeDefineName("REFLECTIONMAP_SPHERICAL"),this._definePlanarName=e._getFreeDefineName("REFLECTIONMAP_PLANAR"),this._defineProjectionName=e._getFreeDefineName("REFLECTIONMAP_PROJECTION"),this._defineExplicitName=e._getFreeDefineName("REFLECTIONMAP_EXPLICIT"),this._defineEquirectangularName=e._getFreeDefineName("REFLECTIONMAP_EQUIRECTANGULAR"),this._defineLocalCubicName=e._getFreeDefineName("USE_LOCAL_REFLECTIONMAP_CUBIC"),this._defineMirroredEquirectangularFixedName=e._getFreeDefineName("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"),this._defineEquirectangularFixedName=e._getFreeDefineName("REFLECTIONMAP_EQUIRECTANGULAR_FIXED"),this._defineSkyboxName=e._getFreeDefineName("REFLECTIONMAP_SKYBOX"),this._defineOppositeZ=e._getFreeDefineName("REFLECTIONMAP_OPPOSITEZ"),this._reflectionMatrixName=e._getFreeVariableName("reflectionMatrix"),e._emitUniformFromString(this._reflectionMatrixName,"mat4");var n="",i="v_"+this.worldPosition.associatedVariableName;return e._emitVaryingFromString(i,"vec4")&&(n+=i+" = "+this.worldPosition.associatedVariableName+`;\r
7701`),this._positionUVWName=e._getFreeVariableName("positionUVW"),this._directionWName=e._getFreeVariableName("directionW"),e._emitVaryingFromString(this._positionUVWName,"vec3",this._defineSkyboxName)&&(n+="#ifdef "+this._defineSkyboxName+`\r
7702`,n+=this._positionUVWName+" = "+this.position.associatedVariableName+`.xyz;\r
7703`,n+=`#endif\r
7704`),e._emitVaryingFromString(this._directionWName,"vec3","defined("+this._defineEquirectangularFixedName+") || defined("+this._defineMirroredEquirectangularFixedName+")")&&(n+="#if defined("+this._defineEquirectangularFixedName+") || defined("+this._defineMirroredEquirectangularFixedName+`)\r
7705`,n+=this._directionWName+" = normalize(vec3("+this.world.associatedVariableName+" * vec4("+this.position.associatedVariableName+`.xyz, 0.0)));\r
7706`,n+=`#endif\r
7707`),n},t.prototype.handleFragmentSideInits=function(e){e.sharedData.blockingBlocks.push(this),e.sharedData.textureBlocks.push(this),this._cubeSamplerName=e._getFreeVariableName(this.name+"CubeSampler"),e.samplers.push(this._cubeSamplerName),this._2DSamplerName=e._getFreeVariableName(this.name+"2DSampler"),e.samplers.push(this._2DSamplerName),e._samplerDeclaration+="#ifdef "+this._define3DName+`\r
7708`,e._samplerDeclaration+="uniform samplerCube "+this._cubeSamplerName+`;\r
7709`,e._samplerDeclaration+=`#else\r
7710`,e._samplerDeclaration+="uniform sampler2D "+this._2DSamplerName+`;\r
7711`,e._samplerDeclaration+=`#endif\r
7712`,e.sharedData.blocksWithDefines.push(this),e.sharedData.bindableBlocks.push(this);var n="//"+this.name;e._emitFunction("ReciprocalPI","#define RECIPROCAL_PI2 0.15915494",""),e._emitFunctionFromInclude("reflectionFunction",n,{replaceStrings:[{search:/vec3 computeReflectionCoords/g,replace:"void DUMMYFUNC"}]}),this._reflectionColorName=e._getFreeVariableName("reflectionColor"),this._reflectionVectorName=e._getFreeVariableName("reflectionUVW"),this._reflectionCoordsName=e._getFreeVariableName("reflectionCoords")},t.prototype.handleFragmentSideCodeReflectionCoords=function(e,n,i){i===void 0&&(i=!1),n||(n="v_"+this.worldPosition.associatedVariableName);var o=this._reflectionMatrixName,a="normalize("+this._directionWName+")",s=""+this._positionUVWName,d=""+this.cameraPosition.associatedVariableName,p=""+this.view.associatedVariableName;e+=".xyz";var y=`
7713            #ifdef `+this._defineMirroredEquirectangularFixedName+`
7714                vec3 `+this._reflectionVectorName+" = computeMirroredFixedEquirectangularCoords("+n+", "+e+", "+a+`);
7715            #endif
7716
7717            #ifdef `+this._defineEquirectangularFixedName+`
7718                vec3 `+this._reflectionVectorName+" = computeFixedEquirectangularCoords("+n+", "+e+", "+a+`);
7719            #endif
7720
7721            #ifdef `+this._defineEquirectangularName+`
7722                vec3 `+this._reflectionVectorName+" = computeEquirectangularCoords("+n+", "+e+", "+d+".xyz, "+o+`);
7723            #endif
7724
7725            #ifdef `+this._defineSphericalName+`
7726                vec3 `+this._reflectionVectorName+" = computeSphericalCoords("+n+", "+e+", "+p+", "+o+`);
7727            #endif
7728
7729            #ifdef `+this._definePlanarName+`
7730                vec3 `+this._reflectionVectorName+" = computePlanarCoords("+n+", "+e+", "+d+".xyz, "+o+`);
7731            #endif
7732
7733            #ifdef `+this._defineCubicName+`
7734                #ifdef `+this._defineLocalCubicName+`
7735                    vec3 `+this._reflectionVectorName+" = computeCubicLocalCoords("+n+", "+e+", "+d+".xyz, "+o+`, vReflectionSize, vReflectionPosition);
7736                #else
7737                vec3 `+this._reflectionVectorName+" = computeCubicCoords("+n+", "+e+", "+d+".xyz, "+o+`);
7738                #endif
7739            #endif
7740
7741            #ifdef `+this._defineProjectionName+`
7742                vec3 `+this._reflectionVectorName+" = computeProjectionCoords("+n+", "+p+", "+o+`);
7743            #endif
7744
7745            #ifdef `+this._defineSkyboxName+`
7746                vec3 `+this._reflectionVectorName+" = computeSkyBoxCoords("+s+", "+o+`);
7747            #endif
7748
7749            #ifdef `+this._defineExplicitName+`
7750                vec3 `+this._reflectionVectorName+` = vec3(0, 0, 0);
7751            #endif
7752
7753            #ifdef `+this._defineOppositeZ+`
7754                `+this._reflectionVectorName+`.z *= -1.0;
7755            #endif\r
7756`;
7756return i||(y+=`
7757                #ifdef `+this._define3DName+`
7758                    vec3 `+this._reflectionCoordsName+" = "+this._reflectionVectorName+`;
7759                #else
7760                    vec2 `+this._reflectionCoordsName+" = "+this._reflectionVectorName+`.xy;
7761                    #ifdef `+this._defineProjectionName+`
7762                        `+this._reflectionCoordsName+" /= "+this._reflectionVectorName+`.z;
7763                    #endif
7764                    `+this._reflectionCoordsName+".y = 1.0 - "+this._reflectionCoordsName+`.y;
7765                #endif\r
7766`),y},t.prototype.handleFragmentSideCodeReflectionColor=function(e,n){n===void 0&&(n=".rgb");var i="vec"+(n.length===0?"4":n.length-1)+" "+this._reflectionColorName+`;
7767            #ifdef `+this._define3DName+`\r
7768`;return i+=e?this._reflectionColorName+" = textureCubeLodEXT("+this._cubeSamplerName+", "+this._reflectionVectorName+", "+e+")"+n+`;\r
7769`:this._reflectionColorName+" = textureCube("+this._cubeSamplerName+", "+this._reflectionVectorName+")"+n+`;\r
7770`,i+=`
7771            #else\r
7772`,i+=e?this._reflectionColorName+" = texture2DLodEXT("+this._2DSamplerName+", "+this._reflectionCoordsName+", "+e+")"+n+`;\r
7773`:this._reflectionColorName+" = texture2D("+this._2DSamplerName+", "+this._reflectionCoordsName+")"+n+`;\r
7774`,i+=`#endif\r
7775`},t.prototype.writeOutputs=function(e,n){var i="";if(e.target===Re.Fragment)for(var o=0,a=this._outputs;o<a.length;o++){var s=a[o];s.hasEndpoints&&(i+=this._declareOutput(s,e)+" = "+n+"."+s.name+`;\r
7776`)}return i},t.prototype._buildBlock=function(e){return r.prototype._buildBlock.call(this,e),this},t.prototype._dumpPropertiesCode=function(){return this.texture?(e=this.texture.isCube?this._codeVariableName+'.texture = new BABYLON.CubeTexture("'+this.texture.name+`");\r
7777`:this._codeVariableName+'.texture = new BABYLON.Texture("'+this.texture.name+`");\r
7778`,e+=this._codeVariableName+".texture.coordinatesMode = "+this.texture.coordinatesMode+`;\r
7779`):"";var e},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return this.texture&&(e.texture=this.texture.serialize()),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=ni.Parse(e.texture,n,i):this.texture=we.a.Parse(e.texture,n,i))},t}(pt);R.a.RegisteredTypes["BABYLON.ReflectionTextureBaseBlock"]=gc;var Bh=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("position",le.Vector3,!1,Re.Vertex),n.registerInput("worldPosition",le.Vector4,!1,Re.Vertex),n.registerInput("worldNormal",le.Vector4,!1,Re.Fragment),n.registerInput("world",le.Matrix,!1,Re.Vertex),n.registerInput("cameraPosition",le.Vector3,!1,Re.Fragment),n.registerInput("view",le.Matrix,!1,Re.Fragment),n.registerOutput("rgb",le.Color3,Re.Fragment),n.registerOutput("rgba",le.Color4,Re.Fragment),n.registerOutput("r",le.Float,Re.Fragment),n.registerOutput("g",le.Float,Re.Fragment),n.registerOutput("b",le.Float,Re.Fragment),n.registerOutput("a",le.Float,Re.Fragment),n._inputs[0].acceptedConnectionPointTypes.push(le.Vector4),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"ReflectionTextureBlock"},Object.defineProperty(t.prototype,"position",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldPosition",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldNormal",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"world",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraPosition",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"view",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgb",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgba",{get:function(){return this._outputs[1]}
7779,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"r",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"g",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"b",{get:function(){return this._outputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"a",{get:function(){return this._outputs[5]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(e){if(r.prototype.autoConfigure.call(this,e),!this.cameraPosition.isConnected){var n=e.getInputBlockByPredicate(function(i){return i.systemValue===bt.CameraPosition});n||(n=new At("cameraPosition")).setAsSystemValue(bt.CameraPosition),n.output.connectTo(this.cameraPosition)}},t.prototype._buildBlock=function(e){if(r.prototype._buildBlock.call(this,e),!this.texture)return e.compilationString+=this.writeOutputs(e,"vec3(0.)"),this;if(e.target!==Re.Fragment)return e.compilationString+=this.handleVertexSide(e),this;this.handleFragmentSideInits(e);var n=e._getFreeVariableName("normalWUnit");return e.compilationString+="vec4 "+n+" = normalize("+this.worldNormal.associatedVariableName+`);\r
7780`,e.compilationString+=this.handleFragmentSideCodeReflectionCoords(n),e.compilationString+=this.handleFragmentSideCodeReflectionColor(void 0,""),e.compilationString+=this.writeOutputs(e,this._reflectionColorName),this},t}(gc);R.a.RegisteredTypes["BABYLON.ReflectionTextureBlock"]=Bh;var Uh=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("left",le.AutoDetect),n.registerInput("right",le.AutoDetect),n.registerOutput("output",le.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._linkConnectionTypes(0,1),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"AddBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=this._declareOutput(n,e)+" = "+this.left.associatedVariableName+" + "+this.right.associatedVariableName+`;\r
7781`,this},t}(pt);R.a.RegisteredTypes["BABYLON.AddBlock"]=Uh;var Vh=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("input",le.AutoDetect),n.registerInput("factor",le.Float),n.registerOutput("output",le.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"ScaleBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"factor",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=this._declareOutput(n,e)+" = "+this.input.associatedVariableName+" * "+this.factor.associatedVariableName+`;\r
7782`,this},t}(pt);R.a.RegisteredTypes["BABYLON.ScaleBlock"]=Vh;var kh=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.minimum=0,n.maximum=1,n.registerInput("value",le.AutoDetect),n.registerOutput("output",le.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"ClampBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=this._declareOutput(n,e)+" = clamp("+this.value.associatedVariableName+", "+this._writeFloat(this.minimum)+", "+this._writeFloat(this.maximum)+`);\r
7783`,this},t.prototype._dumpPropertiesCode=function(){var e=this._codeVariableName+".minimum = "+this.minimum+`;\r
7784`;return e+=this._codeVariableName+".maximum = "+this.maximum+`;\r
7785`},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.minimum=this.minimum,e.maximum=this.maximum,e},t.prototype._deserialize=function(e,n,i){r.prototype._deserialize.call(this,e,n,i),this.minimum=e.minimum,this.maximum=e.maximum},Object(c.c)([Vt("Minimum",Lt.Float)],t.prototype,"minimum",void 0),Object(c.c)([Vt("Maximum",Lt.Float)],t.prototype,"maximum",void 0),t}(pt);R.a.RegisteredTypes["BABYLON.ClampBlock"]=kh;var Gh=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("left",le.AutoDetect),n.registerInput("right",le.AutoDetect),n.registerOutput("output",le.Vector3),n._linkConnectionTypes(0,1),n._inputs[0].excludedConnectionPointTypes.push(le.Float),n._inputs[0].excludedConnectionPointTypes.push(le.Matrix),n._inputs[0].excludedConnectionPointTypes.push(le.Vector2),n._inputs[1].excludedConnectionPointTypes.push(le.Float),n._inputs[1].excludedConnectionPointTypes.push(le.Matrix),n._inputs[1].excludedConnectionPointTypes.push(le.Vector2),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"CrossBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]}
7785,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=this._declareOutput(n,e)+" = cross("+this.left.associatedVariableName+".xyz, "+this.right.associatedVariableName+`.xyz);\r
7786`,this},t}(pt);R.a.RegisteredTypes["BABYLON.CrossBlock"]=Gh;var zh=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("left",le.AutoDetect),n.registerInput("right",le.AutoDetect),n.registerOutput("output",le.Float),n._linkConnectionTypes(0,1),n._inputs[0].excludedConnectionPointTypes.push(le.Float),n._inputs[0].excludedConnectionPointTypes.push(le.Matrix),n._inputs[1].excludedConnectionPointTypes.push(le.Float),n._inputs[1].excludedConnectionPointTypes.push(le.Matrix),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"DotBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=this._declareOutput(n,e)+" = dot("+this.left.associatedVariableName+", "+this.right.associatedVariableName+`);\r
7787`,this},t}(pt);R.a.RegisteredTypes["BABYLON.DotBlock"]=zh;var jh=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("input",le.AutoDetect),n.registerOutput("output",le.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._inputs[0].excludedConnectionPointTypes.push(le.Float),n._inputs[0].excludedConnectionPointTypes.push(le.Matrix),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"NormalizeBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0],i=this._inputs[0];return e.compilationString+=this._declareOutput(n,e)+" = normalize("+i.associatedVariableName+`);\r
7788`,this},t}(pt);R.a.RegisteredTypes["BABYLON.NormalizeBlock"]=jh;var Hh=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("rgb ",le.Color3,!0),n.registerInput("r",le.Float,!0),n.registerInput("g",le.Float,!0),n.registerInput("b",le.Float,!0),n.registerInput("a",le.Float,!0),n.registerOutput("rgba",le.Color4),n.registerOutput("rgb",le.Color3),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"ColorMergerBlock"},Object.defineProperty(t.prototype,"rgbIn",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"r",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"g",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"b",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"a",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgba",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgbOut",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgb",{get:function(){return this.rgbOut},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this.r,i=this.g,o=this.b,a=this.a,s=this.rgbIn,d=this._outputs[0],p=this._outputs[1];return s.isConnected?d.hasEndpoints?e.compilationString+=this._declareOutput(d,e)+" = vec4("+s.associatedVariableName+", "+(a.isConnected?this._writeVariable(a):"0.0")+`);\r
7789`:p.hasEndpoints&&(e.compilationString+=this._declareOutput(p,e)+" = "+s.associatedVariableName+`;\r
7790`):d.hasEndpoints?e.compilationString+=this._declareOutput(d,e)+" = vec4("+(n.isConnected?this._writeVariable(n):"0.0")+", "+(i.isConnected?this._writeVariable(i):"0.0")+", "+(o.isConnected?this._writeVariable(o):"0.0")+", "+(a.isConnected?this._writeVariable(a):"0.0")+`);\r
7791`:p.hasEndpoints&&(e.compilationString+=this._declareOutput(p,e)+" = vec3("+(n.isConnected?this._writeVariable(n):"0.0")+", "+(i.isConnected?this._writeVariable(i):"0.0")+", "+(o.isConnected?this._writeVariable(o):"0.0")+`);\r
7792`),this},t}(pt);R.a.RegisteredTypes["BABYLON.ColorMergerBlock"]=Hh;var Wh=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("xyzw",le.Vector4,!0),n.registerInput("xyz ",le.Vector3,!0),n.registerInput("xy ",le.Vector2,!0),n.registerOutput("xyz",le.Vector3),n.registerOutput("xy",le.Vector2),n.registerOutput("x",le.Float),n.registerOutput("y",le.Float),n.registerOutput("z",le.Float),n.registerOutput("w",le.Float),n.inputsAreExclusive=!0,n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"VectorSplitterBlock"},Object.defineProperty(t.prototype,"xyzw",{get:function(){return this._inputs[0]}
7792,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyzIn",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyIn",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyzOut",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyOut",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"x",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"z",{get:function(){return this._outputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"w",{get:function(){return this._outputs[5]},enumerable:!1,configurable:!0}),t.prototype._inputRename=function(e){switch(e){case"xy ":return"xyIn";case"xyz ":return"xyzIn";default:return e}},t.prototype._outputRename=function(e){switch(e){case"xy":return"xyOut";case"xyz":return"xyzOut";default:return e}},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this.xyzw.isConnected?this.xyzw:this.xyzIn.isConnected?this.xyzIn:this.xyIn,i=this._outputs[0],o=this._outputs[1],a=this._outputs[2],s=this._outputs[3],d=this._outputs[4],p=this._outputs[5];return i.hasEndpoints&&(n===this.xyIn?e.compilationString+=this._declareOutput(i,e)+" = vec3("+n.associatedVariableName+`, 0.0);\r
7793`:e.compilationString+=this._declareOutput(i,e)+" = "+n.associatedVariableName+`.xyz;\r
7794`),o.hasEndpoints&&(e.compilationString+=this._declareOutput(o,e)+" = "+n.associatedVariableName+`.xy;\r
7795`),a.hasEndpoints&&(e.compilationString+=this._declareOutput(a,e)+" = "+n.associatedVariableName+`.x;\r
7796`),s.hasEndpoints&&(e.compilationString+=this._declareOutput(s,e)+" = "+n.associatedVariableName+`.y;\r
7797`),d.hasEndpoints&&(e.compilationString+=this._declareOutput(d,e)+" = "+n.associatedVariableName+`.z;\r
7798`),p.hasEndpoints&&(e.compilationString+=this._declareOutput(p,e)+" = "+n.associatedVariableName+`.w;\r
7799`),this},t}(pt);R.a.RegisteredTypes["BABYLON.VectorSplitterBlock"]=Wh;var Xh=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("left",le.AutoDetect),n.registerInput("right",le.AutoDetect),n.registerInput("gradient",le.AutoDetect),n.registerOutput("output",le.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._linkConnectionTypes(0,1),n._linkConnectionTypes(1,2,!0),n._inputs[2].acceptedConnectionPointTypes.push(le.Float),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"LerpBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"gradient",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=this._declareOutput(n,e)+" = mix("+this.left.associatedVariableName+" , "+this.right.associatedVariableName+", "+this.gradient.associatedVariableName+`);\r
7800`,this},t}(pt);R.a.RegisteredTypes["BABYLON.LerpBlock"]=Xh;var Yh=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("left",le.AutoDetect),n.registerInput("right",le.AutoDetect),n.registerOutput("output",le.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._linkConnectionTypes(0,1),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"DivideBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]}
7800,enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=this._declareOutput(n,e)+" = "+this.left.associatedVariableName+" / "+this.right.associatedVariableName+`;\r
7801`,this},t}(pt);R.a.RegisteredTypes["BABYLON.DivideBlock"]=Yh;var Kh=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("left",le.AutoDetect),n.registerInput("right",le.AutoDetect),n.registerOutput("output",le.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._linkConnectionTypes(0,1),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"SubtractBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=this._declareOutput(n,e)+" = "+this.left.associatedVariableName+" - "+this.right.associatedVariableName+`;\r
7802`,this},t}(pt);R.a.RegisteredTypes["BABYLON.SubtractBlock"]=Kh;var Qh=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("value",le.Float),n.registerInput("edge",le.Float),n.registerOutput("output",le.Float),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"StepBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"edge",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=this._declareOutput(n,e)+" = step("+this.edge.associatedVariableName+", "+this.value.associatedVariableName+`);\r
7803`,this},t}(pt);R.a.RegisteredTypes["BABYLON.StepBlock"]=Qh;var vc=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("input",le.AutoDetect),n.registerOutput("output",le.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._outputs[0].excludedConnectionPointTypes.push(le.Matrix),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"OneMinusBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=this._declareOutput(n,e)+" = 1. - "+this.input.associatedVariableName+`;\r
7804`,this},t}(pt);R.a.RegisteredTypes["BABYLON.OneMinusBlock"]=vc,R.a.RegisteredTypes["BABYLON.OppositeBlock"]=vc;var bc=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("worldPosition",le.Vector4),n.registerInput("cameraPosition",le.Vector3),n.registerOutput("output",le.Vector3),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"ViewDirectionBlock"},Object.defineProperty(t.prototype,"worldPosition",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraPosition",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(e){if(!this.cameraPosition.isConnected){var n=e.getInputBlockByPredicate(function(i){return i.systemValue===bt.CameraPosition});n||(n=new At("cameraPosition")).setAsSystemValue(bt.CameraPosition),n.output.connectTo(this.cameraPosition)}},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=this._declareOutput(n,e)+" = normalize("+this.cameraPosition.associatedVariableName+" - "+this.worldPosition.associatedVariableName+`.xyz);\r
7805`,this},t}(pt);R.a.RegisteredTypes["BABYLON.ViewDirectionBlock"]=bc,f(161);var qh=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("worldNormal",le.Vector4),n.registerInput("viewDirection",le.Vector3),n.registerInput("bias",le.Float),n.registerInput("power",le.Float),n.registerOutput("fresnel",le.Float),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"FresnelBlock"},Object.defineProperty(t.prototype,"worldNormal",{get:function(){return this._inputs[0]}
7805,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"viewDirection",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bias",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"power",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fresnel",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(e){if(!this.viewDirection.isConnected){var n=new bc("View direction");n.output.connectTo(this.viewDirection),n.autoConfigure(e)}if(!this.bias.isConnected){var i=new At("bias");i.value=0,i.output.connectTo(this.bias)}if(!this.power.isConnected){var o=new At("power");o.value=1,o.output.connectTo(this.power)}},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n="//"+this.name;return e._emitFunctionFromInclude("fresnelFunction",n,{removeIfDef:!0}),e.compilationString+=this._declareOutput(this.fresnel,e)+" = computeFresnelTerm("+this.viewDirection.associatedVariableName+".xyz, "+this.worldNormal.associatedVariableName+".xyz, "+this.bias.associatedVariableName+", "+this.power.associatedVariableName+`);\r
7806`,this},t}(pt);R.a.RegisteredTypes["BABYLON.FresnelBlock"]=qh;var Zh=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("left",le.AutoDetect),n.registerInput("right",le.AutoDetect),n.registerOutput("output",le.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._linkConnectionTypes(0,1),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"MaxBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=this._declareOutput(n,e)+" = max("+this.left.associatedVariableName+", "+this.right.associatedVariableName+`);\r
7807`,this},t}(pt);R.a.RegisteredTypes["BABYLON.MaxBlock"]=Zh;var Jh=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("left",le.AutoDetect),n.registerInput("right",le.AutoDetect),n.registerOutput("output",le.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._linkConnectionTypes(0,1),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"MinBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=this._declareOutput(n,e)+" = min("+this.left.associatedVariableName+", "+this.right.associatedVariableName+`);\r
7808`,this},t}(pt);R.a.RegisteredTypes["BABYLON.MinBlock"]=Jh;var $h=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("left",le.AutoDetect),n.registerInput("right",le.AutoDetect),n.registerOutput("output",le.Float),n._linkConnectionTypes(0,1),n._inputs[0].excludedConnectionPointTypes.push(le.Float),n._inputs[0].excludedConnectionPointTypes.push(le.Matrix),n._inputs[1].excludedConnectionPointTypes.push(le.Float),n._inputs[1].excludedConnectionPointTypes.push(le.Matrix),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"DistanceBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]}
7808,enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=this._declareOutput(n,e)+" = length("+this.left.associatedVariableName+" - "+this.right.associatedVariableName+`);\r
7809`,this},t}(pt);R.a.RegisteredTypes["BABYLON.DistanceBlock"]=$h;var ed=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("value",le.AutoDetect),n.registerOutput("output",le.Float),n._inputs[0].excludedConnectionPointTypes.push(le.Float),n._inputs[0].excludedConnectionPointTypes.push(le.Matrix),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"LengthBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=this._declareOutput(n,e)+" = length("+this.value.associatedVariableName+`);\r
7810`,this},t}(pt);R.a.RegisteredTypes["BABYLON.LengthBlock"]=ed;var td=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("value",le.AutoDetect),n.registerOutput("output",le.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"NegateBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=this._declareOutput(n,e)+" = -1.0 * "+this.value.associatedVariableName+`;\r
7811`,this},t}(pt);R.a.RegisteredTypes["BABYLON.NegateBlock"]=td;var nd=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("value",le.AutoDetect),n.registerInput("power",le.AutoDetect),n.registerOutput("output",le.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._linkConnectionTypes(0,1),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"PowBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"power",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=this._declareOutput(n,e)+" = pow("+this.value.associatedVariableName+", "+this.power.associatedVariableName+`);\r
7812`,this},t}(pt);R.a.RegisteredTypes["BABYLON.PowBlock"]=nd;var id=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("seed",le.Vector2),n.registerOutput("output",le.Float),n._inputs[0].acceptedConnectionPointTypes.push(le.Vector3),n._inputs[0].acceptedConnectionPointTypes.push(le.Vector4),n._inputs[0].acceptedConnectionPointTypes.push(le.Color3),n._inputs[0].acceptedConnectionPointTypes.push(le.Color4),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"RandomNumberBlock"},Object.defineProperty(t.prototype,"seed",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0],i="//"+this.name;return e._emitFunctionFromInclude("helperFunctions",i),e.compilationString+=this._declareOutput(n,e)+" = getRand("+this.seed.associatedVariableName+`.xy);\r
7813`,this},t}(pt);R.a.RegisteredTypes["BABYLON.RandomNumberBlock"]=id;var rd=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("x",le.Float),n.registerInput("y",le.Float),n.registerOutput("output",le.Float),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"ArcTan2Block"},Object.defineProperty(t.prototype,"x",{get:function(){return this._inputs[0]}
7813,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=this._declareOutput(n,e)+" = atan("+this.x.associatedVariableName+", "+this.y.associatedVariableName+`);\r
7814`,this},t}(pt);R.a.RegisteredTypes["BABYLON.ArcTan2Block"]=rd;var od=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("value",le.AutoDetect),n.registerInput("edge0",le.Float),n.registerInput("edge1",le.Float),n.registerOutput("output",le.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"SmoothStepBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"edge0",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"edge1",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=this._declareOutput(n,e)+" = smoothstep("+this.edge0.associatedVariableName+", "+this.edge1.associatedVariableName+", "+this.value.associatedVariableName+`);\r
7815`,this},t}(pt);R.a.RegisteredTypes["BABYLON.SmoothStepBlock"]=od;var ad=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("input",le.AutoDetect),n.registerOutput("output",le.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._outputs[0].excludedConnectionPointTypes.push(le.Matrix),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"ReciprocalBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=this._declareOutput(n,e)+" = 1. / "+this.input.associatedVariableName+`;\r
7816`,this},t}(pt);R.a.RegisteredTypes["BABYLON.ReciprocalBlock"]=ad;var sd=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("value",le.AutoDetect),n.registerInput("reference",le.AutoDetect),n.registerInput("distance",le.Float),n.registerInput("replacement",le.AutoDetect),n.registerOutput("output",le.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._linkConnectionTypes(0,1),n._linkConnectionTypes(0,3),n._inputs[0].excludedConnectionPointTypes.push(le.Float),n._inputs[0].excludedConnectionPointTypes.push(le.Matrix),n._inputs[1].excludedConnectionPointTypes.push(le.Float),n._inputs[1].excludedConnectionPointTypes.push(le.Matrix),n._inputs[3].excludedConnectionPointTypes.push(le.Float),n._inputs[3].excludedConnectionPointTypes.push(le.Matrix),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"ReplaceColorBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"reference",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"distance",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"replacement",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=this._declareOutput(n,e)+`;\r
7817`,e.compilationString+="if (length("+this.value.associatedVariableName+" - "+this.reference.associatedVariableName+") < "+this.distance.associatedVariableName+`) {\r
7818`,e.compilationString+=n.associatedVariableName+" = "+this.replacement.associatedVariableName+`;\r
7819`,e.compilationString+=`} else {\r
7820`,e.compilationString+=n.associatedVariableName+" = "+this.value.associatedVariableName+`;\r
7821`,e.compilationString+=`}\r
7822`,this},t}(pt);R.a.RegisteredTypes["BABYLON.ReplaceColorBlock"]=sd;var rr,cd=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("value",le.AutoDetect),n.registerInput("steps",le.AutoDetect),n.registerOutput("output",le.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._linkConnectionTypes(0,1),n._inputs[0].excludedConnectionPointTypes.push(le.Matrix),n._inputs[1].excludedConnectionPointTypes.push(le.Matrix),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"PosterizeBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]}
7822,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"steps",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=this._declareOutput(n,e)+" = floor("+this.value.associatedVariableName+" / (1.0 / "+this.steps.associatedVariableName+")) * (1.0 / "+this.steps.associatedVariableName+`);\r
7823`,this},t}(pt);R.a.RegisteredTypes["BABYLON.PosterizeBlock"]=cd,function(r){r[r.SawTooth=0]="SawTooth",r[r.Square=1]="Square",r[r.Triangle=2]="Triangle"}(rr||(rr={}));var ld=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.kind=rr.SawTooth,n.registerInput("input",le.AutoDetect),n.registerOutput("output",le.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._inputs[0].excludedConnectionPointTypes.push(le.Matrix),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"WaveBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];switch(this.kind){case rr.SawTooth:e.compilationString+=this._declareOutput(n,e)+" = "+this.input.associatedVariableName+" - floor(0.5 + "+this.input.associatedVariableName+`);\r
7824`;break;case rr.Square:e.compilationString+=this._declareOutput(n,e)+" = 1.0 - 2.0 * round(fract("+this.input.associatedVariableName+`));\r
7825`;break;case rr.Triangle:e.compilationString+=this._declareOutput(n,e)+" = 2.0 * abs(2.0 * ("+this.input.associatedVariableName+" - floor(0.5 + "+this.input.associatedVariableName+`))) - 1.0;\r
7826`}return this},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.kind=this.kind,e},t.prototype._deserialize=function(e,n,i){r.prototype._deserialize.call(this,e,n,i),this.kind=e.kind},t}(pt);R.a.RegisteredTypes["BABYLON.WaveBlock"]=ld;var Ta=function(){function r(t,e){this.step=t,this.color=e}return Object.defineProperty(r.prototype,"step",{get:function(){return this._step},set:function(t){this._step=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"color",{get:function(){return this._color},set:function(t){this._color=t},enumerable:!1,configurable:!0}),r}(),ud=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.colorSteps=[new Ta(0,M.a.Black()),new Ta(1,M.a.White())],n.onValueChangedObservable=new x.c,n.registerInput("gradient",le.Float),n.registerOutput("output",le.Color3),n._inputs[0].acceptedConnectionPointTypes.push(le.Vector2),n._inputs[0].acceptedConnectionPointTypes.push(le.Vector3),n._inputs[0].acceptedConnectionPointTypes.push(le.Vector4),n._inputs[0].acceptedConnectionPointTypes.push(le.Color3),n._inputs[0].acceptedConnectionPointTypes.push(le.Color4),n}return Object(c.d)(t,r),t.prototype.colorStepsUpdated=function(){this.onValueChangedObservable.notifyObservers(this)},t.prototype.getClassName=function(){return"GradientBlock"},Object.defineProperty(t.prototype,"gradient",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._writeColorConstant=function(e){var n=this.colorSteps[e];return"vec3("+n.color.r+", "+n.color.g+", "+n.color.b+")"},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];if(this.colorSteps.length&&this.gradient.connectedPoint){var i=e._getFreeVariableName("gradientTempColor"),o=e._getFreeVariableName("gradientTempPosition");e.compilationString+="vec3 "+i+" = "+this._writeColorConstant(0)+`;\r
7827`,e.compilationString+="float "+o+`;\r
7828`;var a=this.gradient.associatedVariableName;this.gradient.connectedPoint.type!==le.Float&&(a+=".x");for(var s=1;s<this.colorSteps.length;s++){var d=this.colorSteps[s],p=this.colorSteps[s-1];e.compilationString+=o+" = clamp(("+a+" - "+e._emitFloat(p.step)+") / ("+e._emitFloat(d.step)+" -  "+e._emitFloat(p.step)+"), 0.0, 1.0) * step("+e._emitFloat(s)+", "+e._emitFloat(this.colorSteps.length-1)+`);\r
7829`,e.compilationString+=i+" = mix("+i+", "+this._writeColorConstant(s)+", "+o+`);\r
7830`}return e.compilationString+=this._declareOutput(n,e)+" = "+i+`;\r
7831`,this}e.compilationString+=this._declareOutput(n,e)+` = vec3(0., 0., 0.);\r
7832`},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);e.colorSteps=[];for(var n=0,i=this.colorSteps;n<i.length;n++){var o=i[n];e.colorSteps.push({step:o.step,color:{r:o.color.r,g:o.color.g,b:o.color.b}})}return e},t.prototype._deserialize=function(e,n,i){r.prototype._deserialize.call(this,e,n,i),this.colorSteps=[];for(var o=0,a=e.colorSteps;o<a.length;o++){var s=a[o];this.colorSteps.push(new Ta(s.step,new M.a(s.color.r,s.color.g,s.color.b)))}},t.prototype._dumpPropertiesCode=function(){for(var e="",n=0,i=this.colorSteps;n<i.length;n++){var o=i[n];e+=this._codeVariableName+".colorSteps.push(new BABYLON.GradientBlockColorStep("+o.step+", new BABYLON.Color3("+o.color.r+", "+o.color.g+", "+o.color.b+`)));\r
7833`}return e},t}(pt);R.a.RegisteredTypes["BABYLON.GradientBlock"]=ud;var hd=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("left",le.AutoDetect),n.registerInput("right",le.AutoDetect),n.registerInput("gradient",le.AutoDetect),n.registerOutput("output",le.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._linkConnectionTypes(0,1),n._linkConnectionTypes(1,2,!0),n._inputs[2].acceptedConnectionPointTypes.push(le.Float),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"NLerpBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]}
7833,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"gradient",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=this._declareOutput(n,e)+" = normalize(mix("+this.left.associatedVariableName+" , "+this.right.associatedVariableName+", "+this.gradient.associatedVariableName+`));\r
7834`,this},t}(pt);R.a.RegisteredTypes["BABYLON.NLerpBlock"]=hd;var dd=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.manhattanDistance=!1,n.registerInput("seed",le.Vector3),n.registerInput("jitter",le.Float),n.registerOutput("output",le.Vector2),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"WorleyNoise3DBlock"},Object.defineProperty(t.prototype,"seed",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"jitter",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){if(r.prototype._buildBlock.call(this,e),this.seed.isConnected&&this._outputs[0].hasEndpoints)return e._emitFunction("worley3D",`vec3 permute(vec3 x){\r
7835    return mod((34.0 * x + 1.0) * x, 289.0);\r
7836}\r
7837\r
7838vec3 dist(vec3 x, vec3 y, vec3 z,  bool manhattanDistance){\r
7839    return manhattanDistance ?  abs(x) + abs(y) + abs(z) :  (x * x + y * y + z * z);\r
7840}\r
7841\r
7842vec2 worley(vec3 P, float jitter, bool manhattanDistance){\r
7843    float K = 0.142857142857; // 1/7\r
7844    float Ko = 0.428571428571; // 1/2-K/2\r
7845    float  K2 = 0.020408163265306; // 1/(7*7)\r
7846    float Kz = 0.166666666667; // 1/6\r
7847    float Kzo = 0.416666666667; // 1/2-1/6*2\r
7848\r
7849    vec3 Pi = mod(floor(P), 289.0);\r
7850    vec3 Pf = fract(P) - 0.5;\r
7851\r
7852    vec3 Pfx = Pf.x + vec3(1.0, 0.0, -1.0);\r
7853    vec3 Pfy = Pf.y + vec3(1.0, 0.0, -1.0);\r
7854    vec3 Pfz = Pf.z + vec3(1.0, 0.0, -1.0);\r
7855\r
7856    vec3 p = permute(Pi.x + vec3(-1.0, 0.0, 1.0));\r
7857    vec3 p1 = permute(p + Pi.y - 1.0);\r
7858    vec3 p2 = permute(p + Pi.y);\r
7859    vec3 p3 = permute(p + Pi.y + 1.0);\r
7860\r
7861    vec3 p11 = permute(p1 + Pi.z - 1.0);\r
7862    vec3 p12 = permute(p1 + Pi.z);\r
7863    vec3 p13 = permute(p1 + Pi.z + 1.0);\r
7864\r
7865    vec3 p21 = permute(p2 + Pi.z - 1.0);\r
7866    vec3 p22 = permute(p2 + Pi.z);\r
7867    vec3 p23 = permute(p2 + Pi.z + 1.0);\r
7868\r
7869    vec3 p31 = permute(p3 + Pi.z - 1.0);\r
7870    vec3 p32 = permute(p3 + Pi.z);\r
7871    vec3 p33 = permute(p3 + Pi.z + 1.0);\r
7872\r
7873    vec3 ox11 = fract(p11*K) - Ko;\r
7874    vec3 oy11 = mod(floor(p11*K), 7.0)*K - Ko;\r
7875    vec3 oz11 = floor(p11*K2)*Kz - Kzo; // p11 < 289 guaranteed\r
7876\r
7877    vec3 ox12 = fract(p12*K) - Ko;\r
7878    vec3 oy12 = mod(floor(p12*K), 7.0)*K - Ko;\r
7879    vec3 oz12 = floor(p12*K2)*Kz - Kzo;\r
7880\r
7881    vec3 ox13 = fract(p13*K) - Ko;\r
7882    vec3 oy13 = mod(floor(p13*K), 7.0)*K - Ko;\r
7883    vec3 oz13 = floor(p13*K2)*Kz - Kzo;\r
7884\r
7885    vec3 ox21 = fract(p21*K) - Ko;\r
7886    vec3 oy21 = mod(floor(p21*K), 7.0)*K - Ko;\r
7887    vec3 oz21 = floor(p21*K2)*Kz - Kzo;\r
7888\r
7889    vec3 ox22 = fract(p22*K) - Ko;\r
7890    vec3 oy22 = mod(floor(p22*K), 7.0)*K - Ko;\r
7891    vec3 oz22 = floor(p22*K2)*Kz - Kzo;\r
7892\r
7893    vec3 ox23 = fract(p23*K) - Ko;\r
7894    vec3 oy23 = mod(floor(p23*K), 7.0)*K - Ko;\r
7895    vec3 oz23 = floor(p23*K2)*Kz - Kzo;\r
7896\r
7897    vec3 ox31 = fract(p31*K) - Ko;\r
7898    vec3 oy31 = mod(floor(p31*K), 7.0)*K - Ko;\r
7899    vec3 oz31 = floor(p31*K2)*Kz - Kzo;\r
7900\r
7901    vec3 ox32 = fract(p32*K) - Ko;\r
7902    vec3 oy32 = mod(floor(p32*K), 7.0)*K - Ko;\r
7903    vec3 oz32 = floor(p32*K2)*Kz - Kzo;\r
7904\r
7905    vec3 ox33 = fract(p33*K) - Ko;\r
7906    vec3 oy33 = mod(floor(p33*K), 7.0)*K - Ko;\r
7907    vec3 oz33 = floor(p33*K2)*Kz - Kzo;\r
7908\r
7909    vec3 dx11 = Pfx + jitter*ox11;\r
7910    vec3 dy11 = Pfy.x + jitter*oy11;\r
7911    vec3 dz11 = Pfz.x + jitter*oz11;\r
7912\r
7913    vec3 dx12 = Pfx + jitter*ox12;\r
7914    vec3 dy12 = Pfy.x + jitter*oy12;\r
7915    vec3 dz12 = Pfz.y + jitter*oz12;\r
7916\r
7917    vec3 dx13 = Pfx + jitter*ox13;\r
7918    vec3 dy13 = Pfy.x + jitter*oy13;\r
7919    vec3 dz13 = Pfz.z + jitter*oz13;\r
7920\r
7921    vec3 dx21 = Pfx + jitter*ox21;\r
7922    vec3 dy21 = Pfy.y + jitter*oy21;\r
7923    vec3 dz21 = Pfz.x + jitter*oz21;\r
7924\r
7925    vec3 dx22 = Pfx + jitter*ox22;\r
7926    vec3 dy22 = Pfy.y + jitter*oy22;\r
7927    vec3 dz22 = Pfz.y + jitter*oz22;\r
7928\r
7929    vec3 dx23 = Pfx + jitter*ox23;\r
7930    vec3 dy23 = Pfy.y + jitter*oy23;\r
7931    vec3 dz23 = Pfz.z + jitter*oz23;\r
7932\r
7933    vec3 dx31 = Pfx + jitter*ox31;\r
7934    vec3 dy31 = Pfy.z + jitter*oy31;\r
7935    vec3 dz31 = Pfz.x + jitter*oz31;\r
7936\r
7937    vec3 dx32 = Pfx + jitter*ox32;\r
7938    vec3 dy32 = Pfy.z + jitter*oy32;\r
7939    vec3 dz32 = Pfz.y + jitter*oz32;\r
7940\r
7941    vec3 dx33 = Pfx + jitter*ox33;\r
7942    vec3 dy33 = Pfy.z + jitter*oy33;\r
7943    vec3 dz33 = Pfz.z + jitter*oz33;\r
7944\r
7945    vec3 d11 = dist(dx11, dy11, dz11, manhattanDistance);\r
7946    vec3 d12 =dist(dx12, dy12, dz12, manhattanDistance);\r
7947    vec3 d13 = dist(dx13, dy13, dz13, manhattanDistance);\r
7948    vec3 d21 = dist(dx21, dy21, dz21, manhattanDistance);\r
7949    vec3 d22 = dist(dx22, dy22, dz22, manhattanDistance);\r
7950    vec3 d23 = dist(dx23, dy23, dz23, manhattanDistance);\r
7951    vec3 d31 = dist(dx31, dy31, dz31, manhattanDistance);\r
7952    vec3 d32 = dist(dx32, dy32, dz32, manhattanDistance);\r
7953    vec3 d33 = dist(dx33, dy33, dz33, manhattanDistance);\r
7954\r
7955    vec3 d1a = min(d11, d12);\r
7956    d12 = max(d11, d12);\r
7957    d11 = min(d1a, d13); // Smallest now not in d12 or d13\r
7958    d13 = max(d1a, d13);\r
7959    d12 = min(d12, d13); // 2nd smallest now not in d13\r
7960    vec3 d2a = min(d21, d22);\r
7961    d22 = max(d21, d22);\r
7962    d21 = min(d2a, d23); // Smallest now not in d22 or d23\r
7963    d23 = max(d2a, d23);\r
7964    d22 = min(d22, d23); // 2nd smallest now not in d23\r
7965    vec3 d3a = min(d31, d32);\r
7966    d32 = max(d31, d32);\r
7967    d31 = min(d3a, d33); // Smallest now not in d32 or d33\r
7968    d33 = max(d3a, d33);\r
7969    d32 = min(d32, d33); // 2nd smallest now not in d33\r
7970    vec3 da = min(d11, d21);\r
7971    d21 = max(d11, d21);\r
7972    d11 = min(da, d31); // Smallest now in d11\r
7973    d31 = max(da, d31); // 2nd smallest now not in d31\r
7974    d11.xy = (d11.x < d11.y) ? d11.xy : d11.yx;\r
7975    d11.xz = (d11.x < d11.z) ? d11.xz : d11.zx; // d11.x now smallest\r
7976    d12 = min(d12, d21); // 2nd smallest now not in d21\r
7977    d12 = min(d12, d22); // nor in d22\r
7978    d12 = min(d12, d31); // nor in d31\r
7979    d12 = min(d12, d32); // nor in d32\r
7980    d11.yz = min(d11.yz,d12.xy); // nor in d12.yz\r
7981    d11.y = min(d11.y,d12.z); // Only two more to go\r
7982    d11.y = min(d11.y,d11.z); // Done! (Phew!)\r
7983    return sqrt(d11.xy); // F1, F2\r
7984}\r
7985\r
7986`,"// Worley3D"),e.compilationString+=this._declareOutput(this._outputs[0],e)+" = worley("+this.seed.associatedVariableName+", "+this.jitter.associatedVariableName+", "+this.manhattanDistance+`);\r
7987`,this},t.prototype._dumpPropertiesCode=function(){return this._codeVariableName+".manhattanDistance = "+this.manhattanDistance+`;\r
7988`},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},Object(c.c)([Vt("Use Manhattan Distance",Lt.Boolean,"PROPERTIES",{notifiers:{update:!1}})],t.prototype,"manhattanDistance",void 0),t}(pt);R.a.RegisteredTypes["BABYLON.WorleyNoise3DBlock"]=dd;var fd=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("seed",le.Vector3),n.registerOutput("output",le.Float),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"SimplexPerlin3DBlock"},Object.defineProperty(t.prototype,"seed",{get:function(){return this._inputs[0]}
7988,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)return e._emitFunction("SimplexPerlin3D",`const float SKEWFACTOR = 1.0/3.0;\r
7989const float UNSKEWFACTOR = 1.0/6.0;\r
7990const float SIMPLEX_CORNER_POS = 0.5;\r
7991const float SIMPLEX_TETRAHADRON_HEIGHT = 0.70710678118654752440084436210485;\r
7992float SimplexPerlin3D( vec3 P ){\r
7993    P *= SIMPLEX_TETRAHADRON_HEIGHT;\r
7994    vec3 Pi = floor( P + dot( P, vec3( SKEWFACTOR) ) );    vec3 x0 = P - Pi + dot(Pi, vec3( UNSKEWFACTOR ) );\r
7995    vec3 g = step(x0.yzx, x0.xyz);\r
7996    vec3 l = 1.0 - g;\r
7997    vec3 Pi_1 = min( g.xyz, l.zxy );\r
7998    vec3 Pi_2 = max( g.xyz, l.zxy );\r
7999    vec3 x1 = x0 - Pi_1 + UNSKEWFACTOR;\r
8000    vec3 x2 = x0 - Pi_2 + SKEWFACTOR;\r
8001    vec3 x3 = x0 - SIMPLEX_CORNER_POS;\r
8002    vec4 v1234_x = vec4( x0.x, x1.x, x2.x, x3.x );\r
8003    vec4 v1234_y = vec4( x0.y, x1.y, x2.y, x3.y );\r
8004    vec4 v1234_z = vec4( x0.z, x1.z, x2.z, x3.z );\r
8005    Pi.xyz = Pi.xyz - floor(Pi.xyz * ( 1.0 / 69.0 )) * 69.0;\r
8006    vec3 Pi_inc1 = step( Pi, vec3( 69.0 - 1.5 ) ) * ( Pi + 1.0 );\r
8007    vec4 Pt = vec4( Pi.xy, Pi_inc1.xy ) + vec2( 50.0, 161.0 ).xyxy;\r
8008    Pt *= Pt;\r
8009    vec4 V1xy_V2xy = mix( Pt.xyxy, Pt.zwzw, vec4( Pi_1.xy, Pi_2.xy ) );\r
8010    Pt = vec4( Pt.x, V1xy_V2xy.xz, Pt.z ) * vec4( Pt.y, V1xy_V2xy.yw, Pt.w );\r
8011    const vec3 SOMELARGEFLOATS = vec3( 635.298681, 682.357502, 668.926525 );\r
8012    const vec3 ZINC = vec3( 48.500388, 65.294118, 63.934599 );\r
8013    vec3 lowz_mods = vec3( 1.0 / ( SOMELARGEFLOATS.xyz + Pi.zzz * ZINC.xyz ) );\r
8014    vec3 highz_mods = vec3( 1.0 / ( SOMELARGEFLOATS.xyz + Pi_inc1.zzz * ZINC.xyz ) );\r
8015    Pi_1 = ( Pi_1.z < 0.5 ) ? lowz_mods : highz_mods;\r
8016    Pi_2 = ( Pi_2.z < 0.5 ) ? lowz_mods : highz_mods;\r
8017    vec4 hash_0 = fract( Pt * vec4( lowz_mods.x, Pi_1.x, Pi_2.x, highz_mods.x ) ) - 0.49999;\r
8018    vec4 hash_1 = fract( Pt * vec4( lowz_mods.y, Pi_1.y, Pi_2.y, highz_mods.y ) ) - 0.49999;\r
8019    vec4 hash_2 = fract( Pt * vec4( lowz_mods.z, Pi_1.z, Pi_2.z, highz_mods.z ) ) - 0.49999;\r
8020    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 );\r
8021    const float FINAL_NORMALIZATION = 37.837227241611314102871574478976;\r
8022    vec4 kernel_weights = v1234_x * v1234_x + v1234_y * v1234_y + v1234_z * v1234_z;\r
8023    kernel_weights = max(0.5 - kernel_weights, 0.0);\r
8024    kernel_weights = kernel_weights*kernel_weights*kernel_weights;\r
8025    return dot( kernel_weights, grad_results ) * FINAL_NORMALIZATION;\r
8026}\r
8027`,"// SimplexPerlin3D"),e.compilationString+=this._declareOutput(this._outputs[0],e)+" = SimplexPerlin3D("+this.seed.associatedVariableName+`);\r
8028`,this},t}(pt);R.a.RegisteredTypes["BABYLON.SimplexPerlin3DBlock"]=fd;var pd=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("normalMap0",le.Vector3),n.registerInput("normalMap1",le.Vector3),n.registerOutput("output",le.Vector3),n._inputs[0].acceptedConnectionPointTypes.push(le.Color3),n._inputs[0].acceptedConnectionPointTypes.push(le.Color4),n._inputs[0].acceptedConnectionPointTypes.push(le.Vector4),n._inputs[1].acceptedConnectionPointTypes.push(le.Color3),n._inputs[1].acceptedConnectionPointTypes.push(le.Color4),n._inputs[1].acceptedConnectionPointTypes.push(le.Vector4),n}return Object(c.d)(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+="float "+a+" = step(0.5, "+i.associatedVariableName+`.r);\r
8029`,e.compilationString+="float "+s+" = step(0.5, "+i.associatedVariableName+`.g);\r
8030`,e.compilationString+=this._declareOutput(n,e)+`;\r
8031`,e.compilationString+=n.associatedVariableName+".r = (1.0 - "+a+") * "+i.associatedVariableName+".r * "+o.associatedVariableName+".r * 2.0 + "+a+" * (1.0 - "+i.associatedVariableName+".r) * (1.0 - "+o.associatedVariableName+`.r) * 2.0;\r
8032`,e.compilationString+=n.associatedVariableName+".g = (1.0 - "+s+") * "+i.associatedVariableName+".g * "+o.associatedVariableName+".g * 2.0 + "+s+" * (1.0 - "+i.associatedVariableName+".g) * (1.0 - "+o.associatedVariableName+`.g) * 2.0;\r
8033`,e.compilationString+=n.associatedVariableName+".b = "+i.associatedVariableName+".b * "+o.associatedVariableName+`.b;\r
8034`,this},t}(pt);R.a.RegisteredTypes["BABYLON.NormalBlendBlock"]=pd;var _d=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("input",le.Vector2),n.registerInput("angle",le.Float),n.registerOutput("output",le.Vector2),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"Rotate2dBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]}
8034,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(e){if(!this.angle.isConnected){var n=new At("angle");n.value=0,n.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+=this._declareOutput(n,e)+" = vec2(cos("+i.associatedVariableName+") * "+o.associatedVariableName+".x - sin("+i.associatedVariableName+") * "+o.associatedVariableName+".y, sin("+i.associatedVariableName+") * "+o.associatedVariableName+".x + cos("+i.associatedVariableName+") * "+o.associatedVariableName+`.y);\r
8035`,this},t}(pt);R.a.RegisteredTypes["BABYLON.Rotate2dBlock"]=_d;var md=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("incident",le.Vector3),n.registerInput("normal",le.Vector3),n.registerOutput("output",le.Vector3),n._inputs[0].acceptedConnectionPointTypes.push(le.Vector4),n._inputs[0].acceptedConnectionPointTypes.push(le.Color3),n._inputs[0].acceptedConnectionPointTypes.push(le.Color4),n._inputs[1].acceptedConnectionPointTypes.push(le.Vector4),n._inputs[1].acceptedConnectionPointTypes.push(le.Color3),n._inputs[1].acceptedConnectionPointTypes.push(le.Color4),n}return Object(c.d)(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+=this._declareOutput(n,e)+" = reflect("+this.incident.associatedVariableName+".xyz, "+this.normal.associatedVariableName+`.xyz);\r
8036`,this},t}(pt);R.a.RegisteredTypes["BABYLON.ReflectBlock"]=md;var gd=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("incident",le.Vector3),n.registerInput("normal",le.Vector3),n.registerInput("ior",le.Float),n.registerOutput("output",le.Vector3),n._inputs[0].acceptedConnectionPointTypes.push(le.Vector4),n._inputs[0].acceptedConnectionPointTypes.push(le.Color3),n._inputs[0].acceptedConnectionPointTypes.push(le.Color4),n._inputs[1].acceptedConnectionPointTypes.push(le.Vector4),n._inputs[1].acceptedConnectionPointTypes.push(le.Color3),n._inputs[1].acceptedConnectionPointTypes.push(le.Color4),n}return Object(c.d)(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+=this._declareOutput(n,e)+" = refract("+this.incident.associatedVariableName+".xyz, "+this.normal.associatedVariableName+".xyz, "+this.ior.associatedVariableName+`);\r
8037`,this},t}(pt);R.a.RegisteredTypes["BABYLON.RefractBlock"]=gd;var vd=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("color",le.Color3),n.registerInput("level",le.Float),n.registerOutput("output",le.Color3),n}return Object(c.d)(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]}
8037,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+="float "+o+" = min(min("+i+".x, "+i+".y), "+i+`.z);\r
8038`,e.compilationString+="float "+a+" = max(max("+i+".x, "+i+".y), "+i+`.z);\r
8039`,e.compilationString+="float "+s+" = 0.5 * ("+o+" + "+a+`);\r
8040`,e.compilationString+=this._declareOutput(n,e)+" = mix("+i+", vec3("+s+", "+s+", "+s+"), "+this.level.associatedVariableName+`);\r
8041`,this},t}(pt);R.a.RegisteredTypes["BABYLON.DesaturateBlock"]=vd;var Kn=function(r){function t(e,n,i,o,a,s){var d=r.call(this,e,n,i)||this;return d._blockType=o,d._blockName=a,d._nameForCheking=s,d._nameForCheking||(d._nameForCheking=e),d.needDualDirectionValidation=!0,d}return Object(c.d)(t,r),t.prototype.checkCompatibilityState=function(e){return e instanceof t&&e.name===this._nameForCheking?oi.Compatible:oi.TypeIncompatible},t.prototype.createCustomInputBlock=function(){return[new this._blockType(this._blockName),this.name]},t}(_a),yc=function(r){function t(e){var n=r.call(this,e,Re.Fragment)||this;return n.albedoScaling=!1,n.linkSheenWithAlbedo=!1,n._isUnique=!0,n.registerInput("intensity",le.Float,!0,Re.Fragment),n.registerInput("color",le.Color3,!0,Re.Fragment),n.registerInput("roughness",le.Float,!0,Re.Fragment),n.registerOutput("sheen",le.Object,Re.Fragment,new Kn("sheen",n,bn.Output,t,"SheenBlock")),n}return Object(c.d)(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){return`#ifdef SHEEN
8042            sheenOutParams sheenOut;
8043
8044            vec4 vSheenColor = vec4(`+(this.color.isConnected?this.color.associatedVariableName:"vec3(1.)")+", "+(this.intensity.isConnected?this.intensity.associatedVariableName:"1.")+`);
8045
8046            sheenBlock(
8047                vSheenColor,
8048            #ifdef SHEEN_ROUGHNESS
8049                `+(this.roughness.isConnected?this.roughness.associatedVariableName:"0.")+`,
8050            #endif
8051                roughness,
8052            #ifdef SHEEN_TEXTURE
8053                vec4(0.),
8054            #endif
8055                reflectance,
8056            #ifdef SHEEN_LINKWITHALBEDO
8057                baseColor,
8058                surfaceAlbedo,
8059            #endif
8060            #ifdef ENVIRONMENTBRDF
8061                NdotV,
8062                environmentBrdf,
8063            #endif
8064            #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
8065                AARoughnessFactors,
8066                `+e?._vReflectionMicrosurfaceInfosName+`,
8067                `+e?._vReflectionInfosName+`,
8068                `+e?.reflectionColor+`,
8069                vLightingIntensity,
8070                #ifdef `+e?._define3DName+`
8071                    `+e?._cubeSamplerName+`,
8072                #else
8073                    `+e?._2DSamplerName+`,
8074                #endif
8075                reflectionOut.reflectionCoords,
8076                NdotVUnclamped,
8077                #ifndef LODBASEDMICROSFURACE
8078                    #ifdef `+e?._define3DName+`
8079                        `+e?._cubeSamplerName+`,
8080                        `+e?._cubeSamplerName+`,
8081                    #else
8082                        `+e?._2DSamplerName+`,
8083                        `+e?._2DSamplerName+`,
8084                    #endif
8085                #endif
8086                #if !defined(`+e?._defineSkyboxName+`) && defined(RADIANCEOCCLUSION)
8087                    seo,
8088                #endif
8089                #if !defined(`+e?._defineSkyboxName+") && defined(HORIZONOCCLUSION) && defined(BUMP) && defined("+e?._define3DName+`)
8090                    eho,
8091                #endif
8092            #endif
8093                sheenOut
8094            );
8095
8096            #ifdef SHEEN_LINKWITHALBEDO
8097                surfaceAlbedo = sheenOut.surfaceAlbedo;
8098            #endif
8099        #endif\r
8100`},t.prototype._buildBlock=function(e){return e.target===Re.Fragment&&e.sharedData.blocksWithDefines.push(this),this},t.prototype._dumpPropertiesCode=function(){var e=r.prototype._dumpPropertiesCode.call(this);return e+=this._codeVariableName+".albedoScaling = "+this.albedoScaling+`;\r
8101`,e+=this._codeVariableName+".linkSheenWithAlbedo = "+this.linkSheenWithAlbedo+`;\r
8102`},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},Object(c.c)([Vt("Albedo scaling",Lt.Boolean,"PROPERTIES",{notifiers:{update:!0}})],t.prototype,"albedoScaling",void 0),Object(c.c)([Vt("Link sheen with albedo",Lt.Boolean,"PROPERTIES",{notifiers:{update:!0}})],t.prototype,"linkSheenWithAlbedo",void 0),t}(pt);R.a.RegisteredTypes["BABYLON.SheenBlock"]=yc;var Tc=function(r){function t(e){var n=r.call(this,e,Re.Fragment)||this;return n._isUnique=!0,n.registerInput("intensity",le.Float,!0,Re.Fragment),n.registerInput("direction",le.Vector2,!0,Re.Fragment),n.registerInput("uv",le.Vector2,!0),n.registerInput("worldTangent",le.Vector4,!0),n.registerOutput("anisotropy",le.Object,Re.Fragment,new Kn("anisotropy",n,bn.Output,t,"AnisotropyBlock")),n}return Object(c.d)(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]}
8102,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,"anisotropy",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._generateTBNSpace=function(e){var n="",i="//"+this.name,o=this.uv,a=this.worldPositionConnectionPoint,s=this.worldNormalConnectionPoint,d=this.worldTangent;o.isConnected||console.error("You must connect the 'uv' input of the Anisotropy block!"),e._emitExtension("derivatives","#extension GL_OES_standard_derivatives : enable");var p={search:/defined\(TANGENT\)/g,replace:d.isConnected?"defined(TANGENT)":"defined(IGNORE)"};return d.isConnected&&(n+="vec3 tbnNormal = normalize("+s.associatedVariableName+`.xyz);\r
8103`,n+="vec3 tbnTangent = normalize("+d.associatedVariableName+`.xyz);\r
8104`,n+=`vec3 tbnBitangent = cross(tbnNormal, tbnTangent);\r
8105`,n+=`mat3 vTBN = mat3(tbnTangent, tbnBitangent, tbnNormal);\r
8106`),n+=`
8107            #if defined(`+(d.isConnected?"TANGENT":"IGNORE")+`) && defined(NORMAL)
8108                mat3 TBN = vTBN;
8109            #else
8110                mat3 TBN = cotangent_frame(`+s.associatedVariableName+".xyz, v_"+a.associatedVariableName+".xyz, "+(o.isConnected?o.associatedVariableName:"vec2(0.)")+`, vec2(1., 1.));
8111            #endif\r
8112`,e._emitFunctionFromInclude("bumpFragmentMainFunctions",i,{replaceStrings:[p]}),n}
8112,t.prototype.getCode=function(e,n){n===void 0&&(n=!1);var i="";n&&(i+=this._generateTBNSpace(e));var o=this.intensity.isConnected?this.intensity.associatedVariableName:"1.0";return i+=`anisotropicOutParams anisotropicOut;
8113            anisotropicBlock(
8114                vec3(`+(this.direction.isConnected?this.direction.associatedVariableName:"vec2(1., 0.)")+", "+o+`),
8115            #ifdef ANISOTROPIC_TEXTURE
8116                vec3(0.),
8117            #endif
8118                TBN,
8119                normalW,
8120                viewDirectionW,
8121                anisotropicOut
8122            );\r
8123`},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)},t.prototype._buildBlock=function(e){return e.target===Re.Fragment&&e.sharedData.blocksWithDefines.push(this),this},t}(pt);R.a.RegisteredTypes["BABYLON.AnisotropyBlock"]=Tc;var Ec=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",le.Vector3,!1,Re.Vertex),n.registerInput("world",le.Matrix,!1,Re.Vertex),n.registerInput("color",le.Color3,!0,Re.Fragment),n.registerOutput("reflection",le.Object,Re.Fragment,new Kn("reflection",n,bn.Output,t,"ReflectionBlock")),n}return Object(c.d)(t,r),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!==we.a.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,$.a.Log2(s));var d=o._materialDefines,p=a.sphericalPolynomial;if(d.USESPHERICALFROMREFLECTIONMAP&&p)if(d.SPHERICAL_HARMONICS){var y=p.preScaledHarmonics;e.setVector3("vSphericalL00",y.l00),e.setVector3("vSphericalL1_1",y.l1_1),e.setVector3("vSphericalL10",y.l10),e.setVector3("vSphericalL11",y.l11),e.setVector3("vSphericalL2_2",y.l2_2),e.setVector3("vSphericalL2_1",y.l2_1),e.setVector3("vSphericalL20",y.l20),e.setVector3("vSphericalL21",y.l21),e.setVector3("vSphericalL22",y.l22)}else e.setFloat3("vSphericalX",p.x.x,p.x.y,p.x.z),e.setFloat3("vSphericalY",p.y.x,p.y.y,p.y.z),e.setFloat3("vSphericalZ",p.z.x,p.z.y,p.z.z),e.setFloat3("vSphericalXX_ZZ",p.xx.x-p.zz.x,p.xx.y-p.zz.y,p.xx.z-p.zz.z),e.setFloat3("vSphericalYY_ZZ",p.yy.x-p.zz.x,p.yy.y-p.zz.y,p.yy.z-p.zz.z),e.setFloat3("vSphericalZZ",p.zz.x,p.zz.y,p.zz.z),e.setFloat3("vSphericalXY",p.xy.x,p.xy.y,p.xy.z),e.setFloat3("vSphericalYZ",p.yz.x,p.yz.y,p.yz.z),e.setFloat3("vSphericalZX",p.zx.x,p.zx.y,p.zx.z)}},t.prototype.handleVertexSide=function(e){var n=r.prototype.handleVertexSide.call(this,e);e._emitFunctionFromInclude("harmonicsFunctions","//"+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 i=e._getFreeVariableName("reflectionVector");return this._vEnvironmentIrradianceName=e._getFreeVariableName("vEnvironmentIrradiance"),e._emitVaryingFromString(this._vEnvironmentIrradianceName,"vec3","defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)"),e._emitUniformFromString("vSphericalL00","vec3","SPHERICAL_HARMONICS"),e._emitUniformFromString("vSphericalL1_1","vec3","SPHERICAL_HARMONICS"),e._emitUniformFromString("vSphericalL10","vec3","SPHERICAL_HARMONICS"),e._emitUniformFromString("vSphericalL11","vec3","SPHERICAL_HARMONICS"),e._emitUniformFromString("vSphericalL2_2","vec3","SPHERICAL_HARMONICS"),e._emitUniformFromString("vSphericalL2_1","vec3","SPHERICAL_HARMONICS"),e._emitUniformFromString("vSphericalL20","vec3","SPHERICAL_HARMONICS"),e._emitUniformFromString("vSphericalL21","vec3","SPHERICAL_HARMONICS"),e._emitUniformFromString("vSphericalL22","vec3","SPHERICAL_HARMONICS"),e._emitUniformFromString("vSphericalX","vec3","SPHERICAL_HARMONICS",!0),e._emitUniformFromString("vSphericalY","vec3","SPHERICAL_HARMONICS",!0),e._emitUniformFromString("vSphericalZ","vec3","SPHERICAL_HARMONICS",!0),e._emitUniformFromString("vSphericalXX_ZZ","vec3","SPHERICAL_HARMONICS",!0),e._emitUniformFromString("vSphericalYY_ZZ","vec3","SPHERICAL_HARMONICS",!0),e._emitUniformFromString("vSphericalZZ","vec3","SPHERICAL_HARMONICS",!0),e._emitUniformFromString("vSphericalXY","vec3","SPHERICAL_HARMONICS",!0),e._emitUniformFromString("vSphericalYZ","vec3","SPHERICAL_HARMONICS",!0),e._emitUniformFromString("vSphericalZX","vec3","SPHERICAL_HARMONICS",!0),n+=`#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
8124                vec3 `+i+" = vec3("+this._reflectionMatrixName+" * vec4(normalize("+this.worldNormal.associatedVariableName+`).xyz, 0)).xyz;
8125                #ifdef `+this._defineOppositeZ+`
8126                    `+i+`.z *= -1.0;
8127                #endif
8128                `+this._vEnvironmentIrradianceName+" = computeEnvironmentIrradiance("+i+`);
8129            #endif\r
8130`},t.prototype.getCode=function(e,n){var i="";this.handleFragmentSideInits(e),e._emitFunctionFromInclude("harmonicsFunctions","//"+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:""}]}),e._emitFunction("sampleReflection",`
8131            #ifdef `+this._define3DName+`
8132                #define sampleReflection(s, c) textureCube(s, c)
8133            #else
8134                #define sampleReflection(s, c) texture2D(s, c)
8135            #endif\r
8136`,"//"+this.name),e._emitFunction("sampleReflectionLod",`
8137            #ifdef `+this._define3DName+`
8138                #define sampleReflectionLod(s, c, l) textureCubeLodEXT(s, c, l)
8139            #else
8140                #define sampleReflectionLod(s, c, l) texture2DLodEXT(s, c, l)
8141            #endif\r
8142`,"//"+this.name);var o=`
8143            vec3 computeReflectionCoordsPBR(vec4 worldPos, vec3 worldNormal) {
8144                `+this.handleFragmentSideCodeReflectionCoords("worldNormal","worldPos",!0)+`
8145                return `+this._reflectionVectorName+`;
8146            }\r
8147`;
8147return e._emitFunction("computeReflectionCoordsPBR",o,"//"+this.name),this._vReflectionMicrosurfaceInfosName=e._getFreeVariableName("vReflectionMicrosurfaceInfos"),e._emitUniformFromString(this._vReflectionMicrosurfaceInfosName,"vec3"),this._vReflectionInfosName=e._getFreeVariableName("vReflectionInfos"),this._vReflectionFilteringInfoName=e._getFreeVariableName("vReflectionFilteringInfo"),e._emitUniformFromString(this._vReflectionFilteringInfoName,"vec2"),i+=`#ifdef REFLECTION
8148            vec2 `+this._vReflectionInfosName+` = vec2(1., 0.);
8149
8150            reflectionOutParams reflectionOut;
8151
8152            reflectionBlock(
8153                v_`+this.worldPosition.associatedVariableName+`.xyz,
8154                `+n+`,
8155                alphaG,
8156                `+this._vReflectionMicrosurfaceInfosName+`,
8157                `+this._vReflectionInfosName+`,
8158                `+this.reflectionColor+`,
8159            #ifdef ANISOTROPIC
8160                anisotropicOut,
8161            #endif
8162            #if defined(`+this._defineLODReflectionAlpha+") && !defined("+this._defineSkyboxName+`)
8163                NdotVUnclamped,
8164            #endif
8165            #ifdef `+this._defineLinearSpecularReflection+`
8166                roughness,
8167            #endif
8168            #ifdef `+this._define3DName+`
8169                `+this._cubeSamplerName+`,
8170            #else
8171                `+this._2DSamplerName+`,
8172            #endif
8173            #if defined(NORMAL) && defined(USESPHERICALINVERTEX)
8174                `+this._vEnvironmentIrradianceName+`,
8175            #endif
8176            #ifdef USESPHERICALFROMREFLECTIONMAP
8177                #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
8178                    `+this._reflectionMatrixName+`,
8179                #endif
8180            #endif
8181            #ifdef USEIRRADIANCEMAP
8182                irradianceSampler, // ** not handled **
8183            #endif
8184            #ifndef LODBASEDMICROSFURACE
8185                #ifdef `+this._define3DName+`
8186                    `+this._cubeSamplerName+`,
8187                    `+this._cubeSamplerName+`,
8188                #else
8189                    `+this._2DSamplerName+`,
8190                    `+this._2DSamplerName+`,
8191                #endif
8192            #endif
8193            #ifdef REALTIME_FILTERING
8194                `+this._vReflectionFilteringInfoName+`,
8195            #endif
8196                reflectionOut
8197            );
8198        #endif\r
8199`},t.prototype._buildBlock=function(e){return this._scene=e.sharedData.scene,e.target!==Re.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+=this._codeVariableName+".texture.gammaSpace = "+this.texture.gammaSpace+`);\r
8200`),e+=this._codeVariableName+".useSphericalHarmonics = "+this.useSphericalHarmonics+`;\r
8201`,e+=this._codeVariableName+".forceIrradianceInFragment = "+this.forceIrradianceInFragment+`;\r
8202`},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)},Object(c.c)([Vt("Spherical Harmonics",Lt.Boolean,"ADVANCED",{notifiers:{update:!0}})],t.prototype,"useSphericalHarmonics",void 0),Object(c.c)([Vt("Force irradiance in fragment",Lt.Boolean,"ADVANCED",{notifiers:{update:!0}})],t.prototype,"forceIrradianceInFragment",void 0),t}(gc);R.a.RegisteredTypes["BABYLON.ReflectionBlock"]=Ec;var Ea=function(r){function t(e){var n=r.call(this,e,Re.Fragment)||this;return n.remapF0OnInterfaceChange=!0,n._isUnique=!0,n.registerInput("intensity",le.Float,!1,Re.Fragment),n.registerInput("roughness",le.Float,!0,Re.Fragment),n.registerInput("indexOfRefraction",le.Float,!0,Re.Fragment),n.registerInput("normalMapColor",le.Color3,!0,Re.Fragment),n.registerInput("uv",le.Vector2,!0,Re.Fragment),n.registerInput("tintColor",le.Color3,!0,Re.Fragment),n.registerInput("tintAtDistance",le.Float,!0,Re.Fragment),n.registerInput("tintThickness",le.Float,!0,Re.Fragment),n.registerInput("worldTangent",le.Vector4,!0),n.registerOutput("clearcoat",le.Object,Re.Fragment,new Kn("clearcoat",n,bn.Output,t,"ClearCoatBlock")),n}return Object(c.d)(t,r),t.prototype.initialize=function(e){e._excludeVariableName("clearcoatOut"),e._excludeVariableName("vClearCoatParams"),e._excludeVariableName("vClearCoatTintParams"),e._excludeVariableName("vClearCoatRefractionParams"),e._excludeVariableName("vClearCoatTangentSpaceParams")},t.prototype.getClassName=function(){return"ClearCoatBlock"},Object.defineProperty(t.prototype,"intensity",{get:function(){return this._inputs[0]}
8202,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,"clearcoat",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(e){if(!this.intensity.isConnected){var n=new At("ClearCoat intensity",Re.Fragment,le.Float);n.value=1,n.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===Sr._DefaultIndexOfRefraction,!0),i.setValue("CLEARCOAT_REMAP_F0",this.remapF0OnInterfaceChange,!0)},t.prototype.bind=function(e,n,i,o){var a,s;r.prototype.bind.call(this,e,n,i);var d=(s=(a=this.indexOfRefraction.connectInputBlock)===null||a===void 0?void 0:a.value)!==null&&s!==void 0?s:Sr._DefaultIndexOfRefraction,p=1-d,y=1+d,P=Math.pow(-p/y,2),O=1/d;e.setFloat4("vClearCoatRefractionParams",P,O,p,y);var U=this.clearcoat.hasEndpoints?this.clearcoat.endpoints[0].ownerBlock:null,F=U?.perturbedNormal.isConnected?U.perturbedNormal.connectedPoint.ownerBlock:null;this._scene._mirroredCameraPosition?e.setFloat2("vClearCoatTangentSpaceParams",F?.invertX?1:-1,F?.invertY?1:-1):e.setFloat2("vClearCoatTangentSpaceParams",F?.invertX?-1:1,F?.invertY?-1:1)},t.prototype._generateTBNSpace=function(e,n,i){var o="",a="//"+this.name,s=this.worldTangent;e._emitExtension("derivatives","#extension GL_OES_standard_derivatives : enable");var d={search:/defined\(TANGENT\)/g,replace:s.isConnected?"defined(TANGENT)":"defined(IGNORE)"};return s.isConnected&&(o+="vec3 tbnNormal = normalize("+i+`.xyz);\r
8203`,o+="vec3 tbnTangent = normalize("+s.associatedVariableName+`.xyz);\r
8204`,o+=`vec3 tbnBitangent = cross(tbnNormal, tbnTangent);\r
8205`,o+=`mat3 vTBN = mat3(tbnTangent, tbnBitangent, tbnNormal);\r
8206`),e._emitFunctionFromInclude("bumpFragmentMainFunctions",a,{replaceStrings:[d]}),o},t.GetCode=function(e,n,i,o,a,s,d){var p="",y=n?.intensity.isConnected?n.intensity.associatedVariableName:"1.",P=n?.roughness.isConnected?n.roughness.associatedVariableName:"0.",O=n?.normalMapColor.isConnected?n.normalMapColor.associatedVariableName:"vec3(0.)",U=n?.uv.isConnected?n.uv.associatedVariableName:"vec2(0.)",F=n?.tintColor.isConnected?n.tintColor.associatedVariableName:"vec3(1.)",z=n?.tintThickness.isConnected?n.tintThickness.associatedVariableName:"1.",J=n?.tintAtDistance.isConnected?n.tintAtDistance.associatedVariableName:"1.";return n&&(e._emitUniformFromString("vClearCoatRefractionParams","vec4"),e._emitUniformFromString("vClearCoatTangentSpaceParams","vec2")),a&&n&&(p+=n._generateTBNSpace(e,o,d),s=n.worldTangent.isConnected),p+=`clearcoatOutParams clearcoatOut;
8207
8208        #ifdef CLEARCOAT
8209            vec2 vClearCoatParams = vec2(`+y+", "+P+`);
8210            vec4 vClearCoatTintParams = vec4(`+F+", "+z+`);
8211
8212            clearcoatBlock(
8213                `+o+`.xyz,
8214                geometricNormalW,
8215                viewDirectionW,
8216                vClearCoatParams,
8217                specularEnvironmentR0,
8218            #ifdef CLEARCOAT_TEXTURE
8219                vec2(0.),
8220            #endif
8221            #ifdef CLEARCOAT_TINT
8222                vClearCoatTintParams,
8223                `+J+`,
8224                vClearCoatRefractionParams,
8225                #ifdef CLEARCOAT_TINT_TEXTURE
8226                    vec4(0.),
8227                #endif
8228            #endif
8229            #ifdef CLEARCOAT_BUMP
8230                vec2(0., 1.),
8231                vec4(`+O+`, 0.),
8232                `+U+`,
8233                #if defined(`+(s?"TANGENT":"IGNORE")+`) && defined(NORMAL)
8234                    vTBN,
8235                #else
8236                    vClearCoatTangentSpaceParams,
8237                #endif
8238                #ifdef OBJECTSPACE_NORMALMAP
8239                    normalMatrix,
8240                #endif
8241            #endif
8242            #if defined(FORCENORMALFORWARD) && defined(NORMAL)
8243                faceNormal,
8244            #endif
8245            #ifdef REFLECTION
8246                `+i?._vReflectionMicrosurfaceInfosName+`,
8247                `+i?._vReflectionInfosName+`,
8248                `+i?.reflectionColor+`,
8249                vLightingIntensity,
8250                #ifdef `+i?._define3DName+`
8251                    `+i?._cubeSamplerName+`,
8252                #else
8253                    `+i?._2DSamplerName+`,
8254                #endif
8255                #ifndef LODBASEDMICROSFURACE
8256                    #ifdef `+i?._define3DName+`
8257                        `+i?._cubeSamplerName+`,
8258                        `+i?._cubeSamplerName+`,
8259                    #else
8260                        `+i?._2DSamplerName+`,
8261                        `+i?._2DSamplerName+`,
8262                    #endif
8263                #endif
8264            #endif
8265            #if defined(ENVIRONMENTBRDF) && !defined(`+i?._defineSkyboxName+`)
8266                #ifdef RADIANCEOCCLUSION
8267                    ambientMonochrome,
8268                #endif
8269            #endif
8270                clearcoatOut
8271            );
8272        #else
8273            clearcoatOut.specularEnvironmentR0 = specularEnvironmentR0;
8274        #endif\r
8275`},t.prototype._buildBlock=function(e){return this._scene=e.sharedData.scene,e.target===Re.Fragment&&(e.sharedData.bindableBlocks.push(this),e.sharedData.blocksWithDefines.push(this)),this},t.prototype._dumpPropertiesCode=function(){var e="";return e+=this._codeVariableName+".remapF0OnInterfaceChange = "+this.remapF0OnInterfaceChange+`;\r
8276`},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},Object(c.c)([Vt("Remap F0 on interface change",Lt.Boolean,"ADVANCED")],t.prototype,"remapF0OnInterfaceChange",void 0),t}(pt);R.a.RegisteredTypes["BABYLON.ClearCoatBlock"]=Ea;var Sc=function(r){function t(e){var n=r.call(this,e,Re.Fragment)||this;return n.linkRefractionWithTransparency=!1,n.invertRefractionY=!1,n._isUnique=!0,n.registerInput("intensity",le.Float,!1,Re.Fragment),n.registerInput("tintAtDistance",le.Float,!0,Re.Fragment),n.registerOutput("refraction",le.Object,Re.Fragment,new Kn("refraction",n,bn.Output,t,"RefractionBlock")),n}return Object(c.d)(t,r),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,"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){if(!this.intensity.isConnected){var n=new At("Refraction intensity",Re.Fragment,le.Float);n.value=1,n.output.connectTo(this.intensity)}if(this.view&&!this.view.isConnected){var i=e.getInputBlockByPredicate(function(o){return o.systemValue===bt.View});i||(i=new At("view")).setAsSystemValue(bt.View),i.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.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))},t.prototype.isReady=function(){var e=this._getTexture();return!(e&&!e.isReadyOrNotBlocking())},t.prototype.bind=function(e,n,i,o){var a,s;r.prototype.bind.call(this,e,n,i);var d=this._getTexture();if(d){d.isCube?e.setTexture(this._cubeSamplerName,d):e.setTexture(this._2DSamplerName,d),e.setMatr
8276ix(this._refractionMatrixName,d.getReflectionTextureMatrix());var p=1;d.isCube||d.depth&&(p=d.depth);var y=(s=(a=this.indexOfRefractionConnectionPoint.connectInputBlock)===null||a===void 0?void 0:a.value)!==null&&s!==void 0?s:1.5;e.setFloat4(this._vRefractionInfosName,d.level,1/y,p,this.invertRefractionY?-1:1),e.setFloat3(this._vRefractionMicrosurfaceInfosName,d.getSize().width,d.lodGenerationScale,d.lodGenerationOffset);var P=d.getSize().width;e.setFloat2(this._vRefractionFilteringInfoName,P,$.a.Log2(P))}},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"),e._samplerDeclaration+="#ifdef "+this._define3DName+`\r
8277`,e._samplerDeclaration+="uniform samplerCube "+this._cubeSamplerName+`;\r
8278`,e._samplerDeclaration+=`#else\r
8279`,e._samplerDeclaration+="uniform sampler2D "+this._2DSamplerName+`;\r
8280`,e._samplerDeclaration+=`#endif\r
8281`,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,"mat4"),e._emitFunction("sampleRefraction",`
8282            #ifdef `+this._define3DName+`
8283                #define sampleRefraction(s, c) textureCube(s, c)
8284            #else
8285                #define sampleRefraction(s, c) texture2D(s, c)
8286            #endif\r
8287`,"//"+this.name),e._emitFunction("sampleRefractionLod",`
8288            #ifdef `+this._define3DName+`
8289                #define sampleRefractionLod(s, c, l) textureCubeLodEXT(s, c, l)
8290            #else
8291                #define sampleRefractionLod(s, c, l) texture2DLodEXT(s, c, l)
8292            #endif\r
8293`,"//"+this.name),this._vRefractionMicrosurfaceInfosName=e._getFreeVariableName("vRefractionMicrosurfaceInfos"),e._emitUniformFromString(this._vRefractionMicrosurfaceInfosName,"vec3"),this._vRefractionInfosName=e._getFreeVariableName("vRefractionInfos"),e._emitUniformFromString(this._vRefractionInfosName,"vec4"),this._vRefractionFilteringInfoName=e._getFreeVariableName("vRefractionFilteringInfo"),e._emitUniformFromString(this._vRefractionFilteringInfoName,"vec2"),""},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?this._codeVariableName+'.texture = new BABYLON.CubeTexture("'+this.texture.name+`");\r
8294`:this._codeVariableName+'.texture = new BABYLON.Texture("'+this.texture.name+`");\r
8295`,e+=this._codeVariableName+".texture.coordinatesMode = "+this.texture.coordinatesMode+`;\r
8296`),e+=this._codeVariableName+".linkRefractionWithTransparency = "+this.linkRefractionWithTransparency+`;\r
8297`,e+=this._codeVariableName+".invertRefractionY = "+this.invertRefractionY+`;\r
8298`},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return this.texture&&(e.texture=this.texture.serialize()),e.linkRefractionWithTransparency=this.linkRefractionWithTransparency,e.invertRefractionY=this.invertRefractionY,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=ni.Parse(e.texture,n,i):this.texture=we.a.Parse(e.texture,n,i)),this.linkRefractionWithTransparency=e.linkRefractionWithTransparency,this.invertRefractionY=e.invertRefractionY},Object(c.c)([Vt("Link refraction to transparency",Lt.Boolean,"ADVANCED",{notifiers:{update:!0}})],t.prototype,"linkRefractionWithTransparency",void 0),Object(c.c)([Vt("Invert refraction Y",Lt.Boolean,"ADVANCED",{notifiers:{update:!0}})],t.prototype,"invertRefractionY",void 0),t}(pt);R.a.RegisteredTypes["BABYLON.RefractionBlock"]=Sc;var Sa=function(r){function t(e){var n=r.call(this,e,Re.Fragment)||this;return n._isUnique=!0,n.registerInput("thickness",le.Float,!1,Re.Fragment),n.registerInput("tintColor",le.Color3,!0,Re.Fragment),n.registerInput("translucencyIntensity",le.Float,!0,Re.Fragment),n.registerInput("translucencyDiffusionDist",le.Color3,!0,Re.Fragment),n.registerInput("refraction",le.Object,!0,Re.Fragment,new Kn("refraction",n,bn.Input,Sc,"RefractionBlock")),n.registerOutput("subsurface",le.Object,Re.Fragment,new Kn("subsurface",n,bn.Output,t,"SubSurfaceBlock")),n}return Object(c.d)(t,r),t.prototype.initialize=function(e){e._excludeVariableName("subSurfaceOut"),e._excludeVariableName("vThicknessParam"),e._excludeVariableName("vTintColor"),e._excludeVariableName("vSubSurfaceIntensity")},t.prototype.getClassName=function(){return"SubSurfaceBlock"},Object.defineProperty(t.prototype,"thickness",{get:function(){return this._inputs[0]}
8298,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,"subsurface",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(e){if(!this.thickness.isConnected){var n=new At("SubSurface thickness",Re.Fragment,le.Float);n.value=0,n.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_MASK_FROM_THICKNESS_TEXTURE",!1,!0),i.setValue("SS_MASK_FROM_THICKNESS_TEXTURE_GLTF",!1,!0)},t.GetCode=function(e,n,i,o){var a,s,d,p,y,P,O,U,F,z,J,ie,se,ce,ue,fe,ve="",Te=n?.thickness.isConnected?n.thickness.associatedVariableName:"0.",Oe=n?.tintColor.isConnected?n.tintColor.associatedVariableName:"vec3(1.)",Pe=n?.translucencyIntensity.isConnected?n?.translucencyIntensity.associatedVariableName:"1.",Ee=n?.translucencyDiffusionDist.isConnected?n?.translucencyDiffusionDist.associatedVariableName:"vec3(1.)",Se=n?.refraction.isConnected?(a=n?.refraction.connectedPoint)===null||a===void 0?void 0:a.ownerBlock:null,Le=Se?.tintAtDistance.isConnected?Se.tintAtDistance.associatedVariableName:"1.",xe=Se?.intensity.isConnected?Se.intensity.associatedVariableName:"1.",Ne=Se?.view.isConnected?Se.view.associatedVariableName:"";return ve+=(s=Se?.getCode(e))!==null&&s!==void 0?s:"",ve+=`subSurfaceOutParams subSurfaceOut;
8299
8300        #ifdef SUBSURFACE
8301            vec2 vThicknessParam = vec2(0., `+Te+`);
8302            vec4 vTintColor = vec4(`+Oe+", "+Le+`);
8303            vec3 vSubSurfaceIntensity = vec3(`+xe+", "+Pe+`, 0.);
8304
8305            subSurfaceBlock(
8306                vSubSurfaceIntensity,
8307                vThicknessParam,
8308                vTintColor,
8309                normalW,
8310                specularEnvironmentReflectance,
8311            #ifdef SS_THICKNESSANDMASK_TEXTURE
8312                vec4(0.),
8313            #endif
8314            #ifdef REFLECTION
8315                #ifdef SS_TRANSLUCENCY
8316                    `+i?._reflectionMatrixName+`,
8317                    #ifdef USESPHERICALFROMREFLECTIONMAP
8318                        #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
8319                            reflectionOut.irradianceVector,
8320                        #endif
8321                        #if defined(REALTIME_FILTERING)
8322                            `+i?._cubeSamplerName+`,
8323                            `+i?._vReflectionFilteringInfoName+`,
8324                        #endif
8325                        #endif
8326                    #ifdef USEIRRADIANCEMAP
8327                        irradianceSampler,
8328                    #endif
8329                #endif
8330            #endif
8331            #ifdef SS_REFRACTION
8332                `+o+`.xyz,
8333                viewDirectionW,
8334                `+Ne+`,
8335                surfaceAlbedo,
8336                `+((d=Se?._vRefractionInfosName)!==null&&d!==void 0?d:"")+`,
8337                `+((p=Se?._refractionMatrixName)!==null&&p!==void 0?p:"")+`,
8338                `+((y=Se?._vRefractionMicrosurfaceInfosName)!==null&&y!==void 0?y:"")+`,
8339                vLightingIntensity,
8340                #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
8341                    alpha,
8342                #endif
8343                #ifdef `+((P=Se?._defineLODRefractionAlpha)!==null&&P!==void 0?P:"IGNORE")+`
8344                    NdotVUnclamped,
8345                #endif
8346                #ifdef `+((O=Se?._defineLinearSpecularRefraction)!==null&&O!==void 0?O:"IGNORE")+`
8347                    roughness,
8348                #else
8349                    alphaG,
8350                #endif
8351                #ifdef `+((U=Se?._define3DName)!==null&&U!==void 0?U:"IGNORE")+`
8352                    `+((F=Se?._cubeSamplerName)!==null&&F!==void 0?F:"")+`,
8353                #else
8354                    `+((z=Se?._2DSamplerName)!==null&&z!==void 0?z:"")+`,
8355                #endif
8356                #ifndef LODBASEDMICROSFURACE
8357                    #ifdef `+((J=Se?._define3DName)!==null&&J!==void 0?J:"IGNORE")+`
8358                        `+((ie=Se?._cubeSamplerName)!==null&&ie!==void 0?ie:"")+`,
8359                        `+((se=Se?._cubeSamplerName)!==null&&se!==void 0?se:"")+`,
8360                    #else
8361                        `+((ce=Se?._2DSamplerName)!==null&&ce!==void 0?ce:"")+`,
8362                        `+((ue=Se?._2DSamplerName)!==null&&ue!==void 0?ue:"")+`,
8363                    #endif
8364                #endif
8365                #ifdef ANISOTROPIC
8366                    anisotropicOut,
8367                #endif
8368                #ifdef REALTIME_FILTERING
8369                    `+((fe=Se?._vRefractionFilteringInfoName)!==null&&fe!==void 0?fe:"")+`,
8370                #endif
8371            #endif
8372            #ifdef SS_TRANSLUCENCY
8373                `+Ee+`,
8374            #endif
8375                subSurfaceOut
8376            );
8377
8378            #ifdef SS_REFRACTION
8379                surfaceAlbedo = subSurfaceOut.surfaceAlbedo;
8380                #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
8381                    alpha = subSurfaceOut.alpha;
8382                #endif
8383            #endif
8384        #else
8385            subSurfaceOut.specularEnvironmentReflectance = specularEnvironmentReflectance;
8386        #endif\r
8387`},t.prototype._buildBlock=function(e){return e.target===Re.Fragment&&e.sharedData.blocksWithDefines.push(this),this},t}(pt);R.a.RegisteredTypes["BABYLON.SubSurfaceBlock"]=Sa;var Lm={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:["shadow",""],alpha:["alpha",""]},bd=function(r){function t(e){var n=r.call(this,e,Re.VertexAndFragment)||this;return n._environmentBRDFTexture=null,n._metallicReflectanceColor=M.a.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.use
8387SpecularOverAlpha=!0,n.enableSpecularAntiAliasing=!1,n.realTimeFiltering=!1,n.realTimeFilteringQuality=h.a.TEXTURE_FILTERING_QUALITY_LOW,n.useEnergyConservation=!0,n.useRadianceOcclusion=!0,n.useHorizonOcclusion=!0,n.unlit=!1,n.forceNormalForward=!1,n.debugMode=0,n.debugLimit=0,n.debugFactor=1,n._isUnique=!0,n.registerInput("worldPosition",le.Vector4,!1,Re.Vertex),n.registerInput("worldNormal",le.Vector4,!1,Re.Fragment),n.registerInput("view",le.Matrix,!1),n.registerInput("cameraPosition",le.Vector3,!1,Re.Fragment),n.registerInput("perturbedNormal",le.Vector4,!0,Re.Fragment),n.registerInput("baseColor",le.Color3,!0,Re.Fragment),n.registerInput("metallic",le.Float,!1,Re.Fragment),n.registerInput("roughness",le.Float,!1,Re.Fragment),n.registerInput("ambientOcc",le.Float,!0,Re.Fragment),n.registerInput("opacity",le.Float,!0,Re.Fragment),n.registerInput("indexOfRefraction",le.Float,!0,Re.Fragment),n.registerInput("ambientColor",le.Color3,!0,Re.Fragment),n.registerInput("reflection",le.Object,!0,Re.Fragment,new Kn("reflection",n,bn.Input,Ec,"ReflectionBlock")),n.registerInput("clearcoat",le.Object,!0,Re.Fragment,new Kn("clearcoat",n,bn.Input,Ea,"ClearCoatBlock")),n.registerInput("sheen",le.Object,!0,Re.Fragment,new Kn("sheen",n,bn.Input,yc,"SheenBlock")),n.registerInput("subsurface",le.Object,!0,Re.Fragment,new Kn("subsurface",n,bn.Input,Sa,"SubSurfaceBlock")),n.registerInput("anisotropy",le.Object,!0,Re.Fragment,new Kn("anisotropy",n,bn.Input,Tc,"AnisotropyBlock")),n.registerOutput("ambientClr",le.Color3,Re.Fragment),n.registerOutput("diffuseDir",le.Color3,Re.Fragment),n.registerOutput("specularDir",le.Color3,Re.Fragment),n.registerOutput("clearcoatDir",le.Color3,Re.Fragment),n.registerOutput("sheenDir",le.Color3,Re.Fragment),n.registerOutput("diffuseInd",le.Color3,Re.Fragment),n.registerOutput("specularInd",le.Color3,Re.Fragment),n.registerOutput("clearcoatInd",le.Color3,Re.Fragment),n.registerOutput("sheenInd",le.Color3,Re.Fragment),n.registerOutput("refraction",le.Color3,Re.Fragment),n.registerOutput("lighting",le.Color3,Re.Fragment),n.registerOutput("shadow",le.Float,Re.Fragment),n.registerOutput("alpha",le.Float,Re.Fragment),n}return Object(c.d)(t,r),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")},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]}
8387,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,"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,"diffuseIndirect",{get:function(){return this._outputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"specularIndirect",{get:function(){return this._outputs[6]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"clearcoatIndirect",{get:function(){return this._outputs[7]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sheenIndirect",{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){if(!this.cameraPosition.isConnected){var n=e.getInputBlockByPredicate(function(o){return o.systemValue===bt.CameraPosition});n||(n=new At("cameraPosition")).setAsSystemValue(bt.CameraPosition),n.output.connectTo(this.cameraPosition)}if(!this.view.isConnected){var i=e.getInputBlockByPredicate(function(o){return o.systemValue===bt.View});i||(i=new At("view")).setAsSystemValue(bt.View),i.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("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===pn.LIGHTFALLOFF_STANDARD?(i.setValue("USEPHYSICALLIGHTFA
8387LLOFF",!1),i.setValue("USEGLTFLIGHTFALLOFF",!1)):this.lightFalloff===pn.LIGHTFALLOFF_GLTF?(i.setValue("USEPHYSICALLIGHTFALLOFF",!1),i.setValue("USEGLTFLIGHTFALLOFF",!0)):(i.setValue("USEPHYSICALLIGHTFALLOFF",!0),i.setValue("USEGLTFLIGHTFALLOFF",!1));var o=this.alphaTestCutoff.toString();if(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),this._scene.getEngine().webGLVersion>1?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&&ht.a.ReflectionTextureEnabled?(i.setValue("ENVIRONMENTBRDF",!0),i.setValue("ENVIRONMENTBRDF_RGBD",this._environmentBRDFTexture.isRGBD,!0)):(i.setValue("ENVIRONMENTBRDF",!1),i.setValue("ENVIRONMENTBRDF_RGBD",!1)),i._areLightsDirty){var a=e.getScene();if(this.light){var s={needNormals:!1,needRebuild:!1,lightmapMode:!1,shadowEnabled:!1,specularEnabled:!1};tt.a.PrepareDefinesForLight(a,e,this.light,this._lightId,i,!0,s),s.needRebuild&&i.rebuild()}else tt.a.PrepareDefinesForLights(a,e,i,!0,n.maxSimultaneousLights),i._needNormals=!0,tt.a.PrepareDefinesForMultiview(a,i)}},t.prototype.updateUniformsAndSamples=function(e,n,i,o){for(var a=0;a<n.maxSimultaneousLights&&i["LIGHT"+a];a++){var s=e.uniforms.indexOf("vLightData"+a)>=0;tt.a.PrepareUniformsAndSamplersForLight(a,e.uniforms,e.samplers,i["PROJECTEDLIGHTTEXTURE"+a],o,s)}},t.prototype.bind=function(e,n,i){var o,a;if(i){var s=i.getScene();this.light?tt.a.BindLight(this.light,this._lightId,s,e,!0):tt.a.BindLights(s,i,e,!0,n.maxSimultaneousLights),e.setTexture(this._environmentBrdfSamplerName,this._environmentBRDFTexture),e.setFloat2("vDebugMode",this.debugLimit,this.debugFactor);var d=this._scene.ambientColor;d&&e.setColor3("ambientFromScene",d);var p=s.useRightHandedSystem===(s._mirroredCameraPosition!=null);e.setFloat(this._invertNormalName,p?-1:1),e.setFloat4("vLightingIntensity",this.directIntensity,1,this.environmentIntensity*this._scene.environmentIntensity,this.specularIntensity);var y=(a=(o=this.indexOfRefraction.connectInputBlock)===null||o===void 0?void 0:o.value)!==null&&a!==void 0?a:1.5,P=Math.pow((y-1)/(y+1),2);this._metallicReflectanceColor.scaleToRef(P*this._metallicF0Factor,M.c.Color3[0]);var O=this._metallicF0Factor;e.setColor4(this._vMetallicReflectanceFactorsName,M.c.Color3[0],O)}},t.prototype._injectVertexCode=function(e){var n,i,o=this.worldPosition,a="//"+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?"lightUboDeclaration":"lightFragmentDeclaration",a,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]},this._lightId.toString())):(e._emitFunctionFromInclude(e.supportUniformBuffers?"lightUboDeclaration":"lightFragmentDeclaration",a,{repeatKey:"maxSimultaneousLights"}),this._lightId=0,e.sharedData.dynamicUniformBlocks.push(this));var s="v_"+o.associatedVariableName;e._emitVaryingFromString(s,"vec4")&&(e.compilationString+=s+" = "+o.associatedVariableName+`;\r
8388`);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._emitUniformFromString("vDebugMode","vec2","defined(IGNORE) || DEBUGMODE > 0"),e._emitUniformFromString("ambientFromScene","vec3"),e._emitVaryingFromString("vClipSpacePosition","vec4","defined(IGNORE) || DEBUGMODE > 0")&&(e._injectAtEnd+=`#if DEBUGMODE > 0\r
8389`,e._injectAtEnd+=`vClipSpacePosition = gl_Position;\r
8390`,e._injectAtEnd+=`#endif\r
8391`),this.light?e.compilationString+=e._emitCodeFromInclude("shadowsVertex",a,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()},{search:/worldPos/g,replace:o.associatedVariableName}]}):(e.compilationString+="vec4 worldPos = "+o.associatedVariableName+`;\r
8392`,this.view.isConnected&&(e.compilationString+="mat4 view = "+this.view.associatedVariableName+`;\r
8393`),e.compilationString+=e._emitCodeFromInclude("shadowsVertex",a,{repeatKey:"maxSimultaneousLights"}))},t.prototype._getAlbedoOpacityCode=function(){var e=`albedoOpacityOutParams albedoOpacityOut;\r
8394`;return e+=`albedoOpacityBlock(
8395                vec4(`+(this.baseColor.isConnected?this.baseColor.associatedVariableName:"vec3(1.)")+`, 1.),
8396            #ifdef ALBEDO
8397                vec4(1.),
8398                vec2(1., 1.),
8399            #endif
8400            #ifdef OPACITY
8401                vec4(`+(this.opacity.isConnected?this.opacity.associatedVariableName:"1.")+`),
8402                vec2(1., 1.),
8403            #endif
8404                albedoOpacityOut
8405            );
8406
8407            vec3 surfaceAlbedo = albedoOpacityOut.surfaceAlbedo;
8408            float alpha = albedoOpacityOut.alpha;\r
8409`},t.prototype._getAmbientOcclusionCode=function(){var e=`ambientOcclusionOutParams aoOut;\r
8410`;return e+=`ambientOcclusionBlock(
8411            #ifdef AMBIENT
8412                vec3(`+(this.ambientOcc.isConnected?this.ambientOcc.associatedVariableName:"1.")+`),
8413                vec4(0., 1.0, 1.0, 0.),
8414            #endif
8415                aoOut
8416            );\r
8417`},t.prototype._getReflectivityCode=function(e){var n=`reflectivityOutParams reflectivityOut;\r
8418`;return this._vMetallicReflectanceFactorsName=e._getFreeVariableName("vMetallicReflectanceFactors"),e._emitUniformFromString(this._vMetallicReflectanceFactorsName,"vec4"),n+=`vec3 baseColor = surfaceAlbedo;
8419
8420            reflectivityBlock(
8421                vec4(`+this.metallic.associatedVariableName+", "+this.roughness.associatedVariableName+`, 0., 0.),
8422            #ifdef METALLICWORKFLOW
8423                surfaceAlbedo,
8424                `+this._vMetallicReflectanceFactorsName+`,
8425            #endif
8426            #ifdef REFLECTIVITY
8427                vec3(0., 0., 1.),
8428                vec4(1.),
8429            #endif
8430            #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY)  && defined(AOSTOREINMETALMAPRED)
8431                aoOut.ambientOcclusionColor,
8432            #endif
8433            #ifdef MICROSURFACEMAP
8434                microSurfaceTexel, <== not handled!
8435            #endif
8436                reflectivityOut
8437            );
8438
8439            float microSurface = reflectivityOut.microSurface;
8440            float roughness = reflectivityOut.roughness;
8441
8442            #ifdef METALLICWORKFLOW
8443                surfaceAlbedo = reflectivityOut.surfaceAlbedo;
8444            #endif
8445            #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
8446                aoOut.ambientOcclusionColor = reflectivityOut.ambientOcclusionColor;
8447            #endif\r
8448`},t.prototype._buildBlock=function(e){var n,i,o,a,s,d,p,y,P,O,U,F,z,J,ie,se,ce,ue,fe,ve,Te,Oe,Pe,Ee,Se,Le,xe,Ne,Ie,Fe,Ke,nt,rt,ut,qe,at,ot,Je,dt;r.prototype._buildBlock.call(this,e),this._scene=e.sharedData.scene,this._environmentBRDFTexture||(this._environmentBRDFTexture=ia.GetEnvironmentBRDFTexture(this._scene));var Ve=this.reflection.isConnected?(n=this.reflection.connectedPoint)===null||n===void 0?void 0:n.ownerBlock:null;if(Ve&&(Ve.worldPositionConnectionPoint=this.worldPosition,Ve.cameraPositionConnectionPoint=this.cameraPosition,Ve.worldNormalConnectionPoint=this.worldNormal),e.target!==Re.Fragment)return this._injectVertexCode(e),this;e.sharedData.bindableBlocks.push(this),e.sharedData.blocksWithDefines.push(this);var $e="//"+this.name,yt="v_"+this.worldPosition.associatedVariableName,Wt=this.perturbedNormal;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"),this.light?e._emitFunctionFromInclude(e.supportUniformBuffers?"lightUboDeclaration":"lightFragmentDeclaration",$e,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]},this._lightId.toString()):e._emitFunctionFromInclude(e.supportUniformBuffers?"lightUboDeclaration":"lightFragmentDeclaration",$e,{repeatKey:"maxSimultaneousLights"}),e._emitFunctionFromInclude("helperFunctions",$e),e._emitFunctionFromInclude("importanceSampling",$e),e._emitFunctionFromInclude("pbrHelperFunctions",$e),e._emitFunctionFromInclude("imageProcessingFunctions",$e),e._emitFunctionFromInclude("shadowsFragmentFunctions",$e,{replaceStrings:[{search:/vPositionW/g,replace:yt
8448+".xyz"}]}),e._emitFunctionFromInclude("pbrDirectLightingSetupFunctions",$e,{replaceStrings:[{search:/vPositionW/g,replace:yt+".xyz"}]}),e._emitFunctionFromInclude("pbrDirectLightingFalloffFunctions",$e),e._emitFunctionFromInclude("pbrBRDFFunctions",$e,{replaceStrings:[{search:/REFLECTIONMAP_SKYBOX/g,replace:(i=Ve?._defineSkyboxName)!==null&&i!==void 0?i:"REFLECTIONMAP_SKYBOX"}]}),e._emitFunctionFromInclude("hdrFilteringFunctions",$e),e._emitFunctionFromInclude("pbrDirectLightingFunctions",$e,{replaceStrings:[{search:/vPositionW/g,replace:yt+".xyz"}]}),e._emitFunctionFromInclude("pbrIBLFunctions",$e),e._emitFunctionFromInclude("pbrBlockAlbedoOpacity",$e),e._emitFunctionFromInclude("pbrBlockReflectivity",$e),e._emitFunctionFromInclude("pbrBlockAmbientOcclusion",$e),e._emitFunctionFromInclude("pbrBlockAlphaFresnel",$e),e._emitFunctionFromInclude("pbrBlockAnisotropic",$e),e._emitUniformFromString("vLightingIntensity","vec4"),this._vNormalWName=e._getFreeVariableName("vNormalW"),e.compilationString+="vec4 "+this._vNormalWName+" = normalize("+this.worldNormal.associatedVariableName+`);\r
8449`,e._registerTempVariable("viewDirectionW")&&(e.compilationString+="vec3 viewDirectionW = normalize("+this.cameraPosition.associatedVariableName+" - "+yt+`.xyz);\r
8450`),e.compilationString+="vec3 geometricNormalW = "+this._vNormalWName+`.xyz;\r
8451`,e.compilationString+="vec3 normalW = "+(Wt.isConnected?"normalize("+Wt.associatedVariableName+".xyz)":"geometricNormalW")+`;\r
8452`,this._invertNormalName=e._getFreeVariableName("invertNormal"),e._emitUniformFromString(this._invertNormalName,"float"),e.compilationString+=e._emitCodeFromInclude("pbrBlockNormalFinal",$e,{replaceStrings:[{search:/vPositionW/g,replace:yt+".xyz"},{search:/vEyePosition.w/g,replace:this._invertNormalName}]}),e.compilationString+=this._getAlbedoOpacityCode(),e.compilationString+=e._emitCodeFromInclude("depthPrePass",$e),e.compilationString+=this._getAmbientOcclusionCode(),e.compilationString+=e._emitCodeFromInclude("pbrBlockLightmapInit",$e),e.compilationString+=`#ifdef UNLIT
8453                vec3 diffuseBase = vec3(1., 1., 1.);
8454            #else\r
8455`,e.compilationString+=this._getReflectivityCode(e),e.compilationString+=e._emitCodeFromInclude("pbrBlockGeometryInfo",$e,{replaceStrings:[{search:/REFLECTIONMAP_SKYBOX/g,replace:(o=Ve?._defineSkyboxName)!==null&&o!==void 0?o:"REFLECTIONMAP_SKYBOX"},{search:/REFLECTIONMAP_3D/g,replace:(a=Ve?._define3DName)!==null&&a!==void 0?a:"REFLECTIONMAP_3D"}]});var Nt=this.anisotropy.isConnected?(s=this.anisotropy.connectedPoint)===null||s===void 0?void 0:s.ownerBlock:null;Nt&&(Nt.worldPositionConnectionPoint=this.worldPosition,Nt.worldNormalConnectionPoint=this.worldNormal,e.compilationString+=Nt.getCode(e,!this.perturbedNormal.isConnected)),Ve&&Ve.hasTexture&&(e.compilationString+=Ve.getCode(e,Nt?"anisotropicOut.anisotropicNormal":"normalW")),e._emitFunctionFromInclude("pbrBlockReflection",$e,{replaceStrings:[{search:/computeReflectionCoords/g,replace:"computeReflectionCoordsPBR"},{search:/REFLECTIONMAP_3D/g,replace:(d=Ve?._define3DName)!==null&&d!==void 0?d:"REFLECTIONMAP_3D"},{search:/REFLECTIONMAP_OPPOSITEZ/g,replace:(p=Ve?._defineOppositeZ)!==null&&p!==void 0?p:"REFLECTIONMAP_OPPOSITEZ"},{search:/REFLECTIONMAP_PROJECTION/g,replace:(y=Ve?._defineProjectionName)!==null&&y!==void 0?y:"REFLECTIONMAP_PROJECTION"},{search:/REFLECTIONMAP_SKYBOX/g,replace:(P=Ve?._defineSkyboxName)!==null&&P!==void 0?P:"REFLECTIONMAP_SKYBOX"},{search:/LODINREFLECTIONALPHA/g,replace:(O=Ve?._defineLODReflectionAlpha)!==null&&O!==void 0?O:"LODINREFLECTIONALPHA"},{search:/LINEARSPECULARREFLECTION/g,replace:(U=Ve?._defineLinearSpecularReflection)!==null&&U!==void 0?U:"LINEARSPECULARREFLECTION"},{search:/vReflectionFilteringInfo/g,replace:(F=Ve?._vReflectionFilteringInfoName)!==null&&F!==void 0?F:"vReflectionFilteringInfo"}]}),e.compilationString+=e._emitCodeFromInclude("pbrBlockReflectance0",$e,{replaceStrings:[{search:/metallicReflectanceFactors/g,replace:this._vMetallicReflectanceFactorsName}]});var Qt=this.sheen.isConnected?(z=this.sheen.connectedPoint)===null||z===void 0?void 0:z.ownerBlock:null;Qt&&(e.compilationString+=Qt.getCode(Ve)),e._emitFunctionFromInclude("pbrBlockSheen",$e,{replaceStrings:[{search:/REFLECTIONMAP_3D/g,replace:(J=Ve?._define3DName)!==null&&J!==void 0?J:"REFLECTIONMAP_3D"},{search:/REFLECTIONMAP_SKYBOX/g,replace:(ie=Ve?._defineSkyboxName)!==null&&ie!==void 0?ie:"REFLECTIONMAP_SKYBOX"},{search:/LODINREFLECTIONALPHA/g,replace:(se=Ve?._defineLODReflectionAlpha)!==null&&se!==void 0?se:"LODINREFLECTIONALPHA"},{search:/LINEARSPECULARREFLECTION/g,replace:(ce=Ve?._defineLinearSpecularReflection)!==null&&ce!==void 0?ce:"LINEARSPECULARREFLECTION"}]});var vt=this.clearcoat.isConnected?(ue=this.clearcoat.connectedPoint)===null||ue===void 0?void 0:ue.ownerBlock:null,Jt=!this.perturbedNormal.isConnected&&!this.anisotropy.isConnected,Xt=this.perturbedNormal.isConnected&&((fe=this.perturbedNormal.connectedPoint)===null||fe===void 0?void 0:fe.ownerBlock).worldTangent.isConnected,zt=this.anisotropy.isConnected&&((ve=this.anisotropy.connectedPoint)===null||ve===void 0?void 0:ve.ownerBlock).worldTangent.isConnected,Yt=Xt||!this.perturbedNormal.isConnected&&zt;e.compilationString+=Ea.GetCode(e,vt,Ve,yt,Jt,Yt,this.worldNormal.associatedVariableName),Jt&&(Yt=(Te=vt?.worldTangent.isConnected)!==null&&Te!==void 0&&Te),e._emitFunctionFromInclude("pbrBlockClearcoat",$e,{replaceStrings:[{search:/computeReflectionCoords/g,replace:"computeReflectionCoordsPBR"},{search:/REFLECTIONMAP_3D/g,replace:(Oe=Ve?._define3DName)!==null&&Oe!==void 0?Oe:"REFLECTIONMAP_3D"},{search:/REFLECTIONMAP_OPPOSITEZ/g,replace:(Pe=Ve?._defineOppositeZ)!==null&&Pe!==void 0?Pe:"REFLECTIONMAP_OPPOSITEZ"},{search:/REFLECTIONMAP_PROJECTION/g,replace:(Ee=Ve?._defineProjectionName)!==null&&Ee!==void 0?Ee:"REFLECTIONMAP_PROJECTION"},{search:/REFLECTIONMAP_SKYBOX/g,replace:(Se=Ve?._defineSkyboxName)!==null&&Se!==void 0?Se:"REFLECTIONMAP_SKYBOX"},{search:/LODINREFLECTIONALPHA/g,replace:(Le=Ve?._defineLODReflectionAlpha)!==null&&Le!==void 0?Le:"LODINREFLECTIONALPHA"},{search:/LINEARSPECULARREFLECTION/g,replace:(xe=Ve?._defineLinearSpecularReflection)!==null&&xe!==void 0?xe:"LINEARSPECULARREFLECTION"},{search:/defined\(TANGENT\)/g,replace:Yt?"defined(TANGENT)":"defined(IGNORE)"}]}),e.compilationString+=e._emitCodeFromInclude("pbrBlockReflectance",$e,{replaceStrings:[{search:/REFLECTIONMAP_SKYBOX/g,replace:(Ne=Ve?._defineSkyboxName)!==null&&Ne!==void 0?Ne:"REFLECTIONMAP_SKYBOX"},{search:/REFLECTIONMAP_3D/g,replace:(Ie=Ve?._define3DName)!==null&&Ie!==void 0?Ie:"REFLECTIONMAP_3D"}]});var Et=this.subsurface.isConnected?(Fe=this.subsurface.connectedPoint)===null||Fe===void 0?void 0:Fe.ownerBlock:null,Mt=this.subsurface.isConnected?(nt=((Ke=this.subsurface.connectedPoint)===null||Ke===void 0?void 0:Ke.ownerBlock).refraction.connectedPoint)===null||nt===void 0?void 0:nt.ownerBlock:null;Mt&&(Mt.viewConnectionPoint=this.view,Mt.indexOfRefractionConnectionPoint=this.indexOfRefraction),e.compilationString+=Sa.GetCode(e,Et,Ve,yt),e._emitFunctionFromInclude("pbrBlockSubSurface",$e,{replaceStrings:[{search:/REFLECTIONMAP_3D/g,replace:(rt=Ve?._define3DName)!==null&&rt!==void 0?rt:"REFLECTIONMAP_3D"},{search:/REFLECTIONMAP_OPPOSITEZ/g,replace:(ut=Ve?._defineOppositeZ)!==null&&ut!==void 0?ut:"REFLECTIONMAP_OPPOSITEZ"},{search:/REFLECTIONMAP_PROJECTION/g,replace:(qe=Ve?._defineProjectionName)!==null&&qe!==void 0?qe:"REFLECTIONMAP_PROJECTION"},{search:/SS_REFRACTIONMAP_3D/g,replace:(at=Mt?._define3DName)!==null&&at!==void 0?at:"SS_REFRACTIONMAP_3D"},{search:/SS_LODINREFRACTIONALPHA/g,replace:(ot=Mt?._defineLODRefractionAlpha)!==null&&ot!==void 0?ot:"SS_LODINREFRACTIONALPHA"},{search:/SS_LINEARSPECULARREFRACTION/g,replace:(Je=Mt?._defineLinearSpecularRefraction)!==null&&Je!==void 0?Je:"SS_LINEARSPECULARREFRACTION"},{search:/SS_REFRACTIONMAP_OPPOSITEZ/g,replace:(dt=Mt?._defineOppositeZ)!==null&&dt!==void 0?dt:"SS_REFRACTIONMAP_OPPOSITEZ"}]}),e.compilationString+=e._emitCodeFromInclude("pbrBlockDirectLighting",$e),this.light?e.compilationString+=e._emitCodeFromInclude("lightFragment",$e,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]}):e.compilationString+=e._emitCodeFromInclude("lightFragment",$e,{repeatKey:"maxSimultaneousLights"}),e.compilationString+=e._emitCodeFromInclude("pbrBlockFinalLitComponents",$e),e.compilationString+=`#endif\r
8456`;var $t=this.ambientColor.isConnected?this.ambientColor.associatedVariableName:"vec3(0., 0., 0.)",Mn=pn.DEFAULT_AO_ON_ANALYTICAL_LIGHTS.toString();Mn.indexOf(".")===-1&&(Mn+="."),e.compilationString+=e._emitCodeFromInclude("pbrBlockFinalUnlitComponents",$e,{replaceStrings:[{search:/vec3 finalEmissive[\s\S]*?finalEmissive\*=vLightingIntensity\.y;/g,replace:""},{search:/vAmbientColor/g,replace:$t+" * ambientFromScene"},{search:/vAmbientInfos\.w/g,replace:Mn}]}),e.compilationString+=e._emitCodeFromInclude("pbrBlockFinalColorComposition",$e,{replaceStrings:[{search:/finalEmissive/g,replace:"vec3(0.)"}]}),e.compilationString+=e._emitCodeFromInclude("pbrBlockImageProcessing",$e,{replaceStrings:[{search:/visibility/g,replace:"1."}]}),e.compilationString+=e._emitCodeFromInclude("pbrDebug",$e,{replaceStrings:[{search:/vNormalW/g,replace:this._vNormalWName},{search:/vPositionW/g,replace:yt},{search:/albedoTexture\.rgb;/g,replace:`vec3(1.);\r
8457gl_FragColor.rgb = toGammaSpace(gl_FragColor.rgb);\r
8458`}]});for(var Bn=0,qn=this._outputs;Bn<qn.length;Bn++){var In=qn[Bn];if(In.hasEndpoints){var qt=Lm[In.name];if(qt){var si=qt[0],xi=qt[1];xi&&(e.compilationString+="#if "+xi+`\r
8459`),e.compilationString+=this._declareOutput(In,e)+" = "+si+`;\r
8460`,xi&&(e.compilationString+=`#else\r
8461`,e.compilationString+=this._declareOutput(In,e)+` = vec3(0.);\r
8462`,e.compilationString+=`#endif\r
8463`)}else console.error("There's no remapping for the "+In.name+" end point! No code generated")}}return this},t.prototype._dumpPropertiesCode=function(){var e="";return e+=this._codeVariableName+".lightFalloff = "+this.lightFalloff+`;\r
8464`,e+=this._codeVariableName+".useAlphaTest = "+this.useAlphaTest+`;\r
8465`,e+=this._codeVariableName+".alphaTestCutoff = "+this.alphaTestCutoff+`;\r
8466`,e+=this._codeVariableName+".useAlphaBlending = "+this.useAlphaBlending+`;\r
8467`,e+=this._codeVariableName+".useRadianceOverAlpha = "+this.useRadianceOverAlpha+`;\r
8468`,e+=this._codeVariableName+".useSpecularOverAlpha = "+this.useSpecularOverAlpha+`;\r
8469`,e+=this._codeVariableName+".enableSpecularAntiAliasing = "+this.enableSpecularAntiAliasing+`;\r
8470`,e+=this._codeVariableName+".realTimeFiltering = "+this.realTimeFiltering+`;\r
8471`,e+=this._codeVariableName+".realTimeFilteringQuality = "+this.realTimeFilteringQuality+`;\r
8472`,e+=this._codeVariableName+".useEnergyConservation = "+this.useEnergyConservation+`;\r
8473`,e+=this._codeVariableName+".useRadianceOcclusion = "+this.useRadianceOcclusion+`;\r
8474`,e+=this._codeVariableName+".useHorizonOcclusion = "+this.useHorizonOcclusion+`;\r
8475`,e+=this._codeVariableName+".unlit = "+this.unlit+`;\r
8476`,e+=this._codeVariableName+".forceNormalForward = "+this.forceNormalForward+`;\r
8477`,e+=this._codeVariableName+".debugMode = "+this.debugMode+`;\r
8478`,e+=this._codeVariableName+".debugLimit = "+this.debugLimit+`;\r
8479`,e+=this._codeVariableName+".debugFactor = "+this.debugFactor+`;\r
8480`},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return this.light&&(e.lightId=this.light.id),e.lightFalloff=this.lightFalloff,e.useAlphaTest=this.useAlphaTest,e.alphaTestCutoff=this.alphaTestCutoff,e.useAlphaBlending=this.useAlphaBlending,e.useRadianceOverAlpha=this.useRadianceOverAlpha,e.useSpecularOverAlpha=this.useSpecularOverAlpha,e.enableSpecularAntiAliasing=this.enableSpecularAntiAliasing,e.realTimeFiltering=this.realTimeFiltering,e.realTimeFilteringQuality=this.realTimeFilteringQuality,e.useEnergyConservation=this.useEnergyConservation,e.useRadianceOcclusion=this.useRadianceOcclusion,e.useHorizonOcclusion=this.useHorizonOcclusion,e.unlit=this.unlit,e.forceNormalForward=this.forceNormalForward,e.debugMode=this.debugMode,e.debugLimit=this.debugLimit,e.debugFactor=this.debugFactor,e},t.prototype._deserialize=function(e,n,i){var o,a;r.prototype._deserialize.call(this,e,n,i),e.lightId&&(this.light=n.getLightByID(e.lightId)),this.lightFalloff=(o=e.lightFalloff)!==null&&o!==void 0?o:0,this.useAlphaTest=e.useAlphaTest,this.alphaTestCutoff=e.alphaTestCutoff,this.useAlphaBlending=e.useAlphaBlending,this.useRadianceOverAlpha=e.useRadianceOverAlpha,this.useSpecularOverAlpha=e.useSpecularOverAlpha,this.enableSpecularAntiAliasing=e.enableSpecularAntiAliasing,this.realTimeFiltering=!!e.realTimeFiltering,this.realTimeFilteringQuality=(a=e.realTimeFilteringQuality)!==null&&a!==void 0?a:h.a.TEXTURE_FILTERING_QUALITY_LOW,this.useEnergyConservation=e.useEnergyConservation,this.useRadianceOcclusion=e.useRadianceOcclusion,this.useHorizonOcclusion=e.useHorizonOcclusion,this.unlit=e.unlit,this.forceNormalForward=!!e.forceNormalForward,this.debugMode=e.debugMode,this.debugLimit=e.debugLimit,this.debugFactor=e.debugFactor},Object(c.c)([Vt("Direct lights",Lt.Float,"INTENSITY",{min:0,max:1,notifiers:{update:!0}})],t.prototype,"directIntensity",void 0),Object(c.c)([Vt("Environment lights",Lt.Float,"INTENSITY",{min:0,max:1,notifiers:{update:!0}})],t.prototype,"environmentIntensity",void 0),Object(c.c)([Vt("Specular highlights",Lt.Float,"INTENSITY",{min:0,max:1,notifiers:{update:!0}})],t.prototype,"specularIntensity",void 0),Object(c.c)([Vt("Light falloff",Lt.List,"LIGHTING & COLORS",{notifiers:{update:!0},options:[{label:"Physical",value:pn.LIGHTFALLOFF_PHYSICAL},{label:"GLTF",value:pn.LIGHTFALLOFF_GLTF},{label:"Standard",value:pn.LIGHTFALLOFF_STANDARD}]})],t.prototype,"lightFalloff",void 0),Object(c.c)([Vt("Alpha Testing",Lt.Boolean,"OPACITY")],t.prototype,"useAlphaTest",void 0),Object(c.c)([Vt("Alpha CutOff",Lt.Float,"OPACITY",{min:0,max:1,notifiers:{update:!0}})],t.prototype,"alphaTestCutoff",void 0),Object(c.c)([Vt("Alpha blending",Lt.Boolean,"OPACITY")],t.prototype,"useAlphaBlending",void 0),Object(c.c)([Vt("Radiance over alpha",Lt.Boolean,"RENDERING",{notifiers:{update:!0}})],t.prototype,"useRadianceOverAlpha",void 0),Object(c.c)([Vt("Specular over alpha",Lt.Boolean,"RENDERING",{notifiers:{update:!0}})],t.prototype,"useSpecularOverAlpha",void 0),Object(c.c)([Vt("Specular anti-ali
8480asing",Lt.Boolean,"RENDERING",{notifiers:{update:!0}})],t.prototype,"enableSpecularAntiAliasing",void 0),Object(c.c)([Vt("Realtime filtering",Lt.Boolean,"RENDERING",{notifiers:{update:!0}})],t.prototype,"realTimeFiltering",void 0),Object(c.c)([Vt("Realtime filtering quality",Lt.List,"RENDERING",{notifiers:{update:!0},options:[{label:"Low",value:h.a.TEXTURE_FILTERING_QUALITY_LOW},{label:"Medium",value:h.a.TEXTURE_FILTERING_QUALITY_MEDIUM},{label:"High",value:h.a.TEXTURE_FILTERING_QUALITY_HIGH}]})],t.prototype,"realTimeFilteringQuality",void 0),Object(c.c)([Vt("Energy Conservation",Lt.Boolean,"ADVANCED",{notifiers:{update:!0}})],t.prototype,"useEnergyConservation",void 0),Object(c.c)([Vt("Radiance occlusion",Lt.Boolean,"ADVANCED",{notifiers:{update:!0}})],t.prototype,"useRadianceOcclusion",void 0),Object(c.c)([Vt("Horizon occlusion",Lt.Boolean,"ADVANCED",{notifiers:{update:!0}})],t.prototype,"useHorizonOcclusion",void 0),Object(c.c)([Vt("Unlit",Lt.Boolean,"ADVANCED",{notifiers:{update:!0}})],t.prototype,"unlit",void 0),Object(c.c)([Vt("Force normal forward",Lt.Boolean,"ADVANCED",{notifiers:{update:!0}})],t.prototype,"forceNormalForward",void 0),Object(c.c)([Vt("Debug mode",Lt.List,"DEBUG",{notifiers:{update:!0},options:[{label:"None",value:0},{label:"Normalized position",value:1},{label:"Normals",value:2},{label:"Tangents",value:3},{label:"Bitangents",value:4},{label:"Bump Normals",value:5},{label:"ClearCoat Normals",value:8},{label:"ClearCoat Tangents",value:9},{label:"ClearCoat Bitangents",value:10},{label:"Anisotropic Normals",value:11},{label:"Anisotropic Tangents",value:12},{label:"Anisotropic Bitangents",value:13},{label:"Env Refraction",value:40},{label:"Env Reflection",value:41},{label:"Env Clear Coat",value:42},{label:"Direct Diffuse",value:50},{label:"Direct Specular",value:51},{label:"Direct Clear Coat",value:52},{label:"Direct Sheen",value:53},{label:"Env Irradiance",value:54},{label:"Surface Albedo",value:60},{label:"Reflectance 0",value:61},{label:"Metallic",value:62},{label:"Metallic F0",value:71},{label:"Roughness",value:63},{label:"AlphaG",value:64},{label:"NdotV",value:65},{label:"ClearCoat Color",value:66},{label:"ClearCoat Roughness",value:67},{label:"ClearCoat NdotV",value:68},{label:"Transmittance",value:69},{label:"Refraction Transmittance",value:70},{label:"SEO",value:80},{label:"EHO",value:81},{label:"Energy Factor",value:82},{label:"Specular Reflectance",value:83},{label:"Clear Coat Reflectance",value:84},{label:"Sheen Reflectance",value:85},{label:"Luminance Over Alpha",value:86},{label:"Alpha",value:87}]})],t.prototype,"debugMode",void 0),Object(c.c)([Vt("Split position",Lt.Float,"DEBUG",{min:-1,max:1,notifiers:{update:!0}})],t.prototype,"debugLimit",void 0),Object(c.c)([Vt("Output factor",Lt.Float,"DEBUG",{min:0,max:5,notifiers:{update:!0}})],t.prototype,"debugFactor",void 0),t}(pt);R.a.RegisteredTypes["BABYLON.PBRMetallicRoughnessBlock"]=bd;var yd=function(r){function t(e){var n=r.call(this,e,Re.Neutral)||this;return n.registerInput("left",le.AutoDetect),n.registerInput("right",le.AutoDetect),n.registerOutput("output",le.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._linkConnectionTypes(0,1),n}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"ModBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=this._declareOutput(n,e)+" = mod("+this.left.associatedVariableName+", "+this.right.associatedVariableName+`);\r
8481`,this},t}(pt);R.a.RegisteredTypes["BABYLON.ModBlock"]=yd;var Nm=function(){function r(){}return r.prototype.optimize=function(t,e){},r}(),wm=f(120),Fm=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}(),Bm=function(){function r(t,e,n){var i=this;this._baseMaterial=t,this._scene=e,this._options=n,this._subMeshToEffect=new Map,this._subMeshToDepthEffect=new Fm,this._meshes=new Map;var o=t.getClassName()==="NodeMaterial"?"u_":"";if(o){this._matriceNames={world:o+"World",view:o+"View",projection:o+"Projection",viewProjection:o+"ViewProjection",worldView:o+"WorldxView",worldViewProjection:o+"WorldxViewxProjection"};for(var a=t.getInputBlocks(),s=0;s<a.length;++s)switch(a[s]._systemValue){case bt.World:this._matriceNames.world=a[s].associatedVariableName;break;case bt.View:this._matriceNames.view=a[s].associatedVariableName;break;case bt.Projection:this._matriceNames.projection=a[s].associatedVariableName;break;case bt.ViewProjection:this._matriceNames.viewProjection=a[s].associatedVariableName;break;case bt.WorldView:this._matriceNames.worldView=a[s].associatedVariableName;break;case bt.WorldViewProjection:this._matriceNames.worldViewProjection=a[s].associatedVariableName}}else this._matriceNames={world:o+"world",view:o+"view",projection:o+"projection",viewProjection:o+"viewProjection",worldView:o+"worldView",worldViewProjection:o+"worldViewProjection"};this._onEffectCreatedObserver=this._baseMaterial.onEffectCreatedObservable.add(function(d){var p,y=(p=d.subMesh)===null||p===void 0?void 0:p.getMesh();y&&!i._meshes.has(y)&&i._meshes.set(y,y.onDisposeObservable.add(function(P){for(var O=i._subMeshToEffect.keys(),U=O.next();U.done!==!0;U=O.next()){var F=U.value;F?.getMesh()===P&&(i._subMeshToEffect.delete(F),i._subMeshToDepthEffect.mm.delete(F))}})),i._subMeshToEffect.set(d.subMesh,d.effect),i._subMeshToDepthEffect.mm.delete(d.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}
8481,enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"baseMaterial",{get:function(){return this._baseMaterial},enumerable:!1,configurable:!0}),r.prototype.getEffect=function(t,e){var n,i,o,a,s,d;return(d=(o=(i=(n=this._subMeshToDepthEffect.mm.get(t))===null||n===void 0?void 0:n.get(e))===null||i===void 0?void 0:i.depthEffect)!==null&&o!==void 0?o:(s=(a=this._subMeshToDepthEffect.mm.get(null))===null||a===void 0?void 0:a.get(e))===null||s===void 0?void 0:s.depthEffect)!==null&&d!==void 0?d:null},r.prototype.isReadyForSubMesh=function(t,e,n,i){var o,a;return this.standalone&&this._baseMaterial.isReadyForSubMesh(t.getMesh(),t,i),(a=(o=this._makeEffect(t,e,n))===null||o===void 0?void 0:o.isReady())!==null&&a!==void 0&&a},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){var i,o=(i=this._subMeshToEffect.get(t))!==null&&i!==void 0?i:this._subMeshToEffect.get(null);if(!o)return null;var a=this._subMeshToDepthEffect.get(t,n);a||(a={depthEffect:null,depthDefines:"",token:wm.a.RandomId()},this._subMeshToDepthEffect.set(t,n,a));var s=e.join(`
8482`);if(a.depthEffect&&s===a.depthDefines)return a.depthEffect;a.depthDefines=s;var d=o.rawVertexSourceCode,p=o.rawFragmentSourceCode,y=this._options&&this._options.remappedVariables?"#include<shadowMapVertexNormalBias>("+this._options.remappedVariables.join(",")+")":je.a.IncludesShadersStore.shadowMapVertexNormalBias,P=this._options&&this._options.remappedVariables?"#include<shadowMapVertexMetric>("+this._options.remappedVariables.join(",")+")":je.a.IncludesShadersStore.shadowMapVertexMetric,O=this._options&&this._options.remappedVariables?"#include<shadowMapFragmentSoftTransparentShadow>("+this._options.remappedVariables.join(",")+")":je.a.IncludesShadersStore.shadowMapFragmentSoftTransparentShadow,U=je.a.IncludesShadersStore.shadowMapFragment;d=(d=(d=(d=d.replace(/void\s+?main/g,je.a.IncludesShadersStore.shadowMapVertexDeclaration+`\r
8483void main`)).replace(/#define SHADOWDEPTH_NORMALBIAS|#define CUSTOM_VERTEX_UPDATE_WORLDPOS/g,y)).indexOf("#define SHADOWDEPTH_METRIC")!==-1?d.replace(/#define SHADOWDEPTH_METRIC/g,P):d.replace(/}\s*$/g,P+`\r
8484}`)).replace(/#define SHADER_NAME.*?\n|out vec4 glFragColor;\n/g,"");var F=p.indexOf("#define SHADOWDEPTH_SOFTTRANSPARENTSHADOW")>=0||p.indexOf("#define CUSTOM_FRAGMENT_BEFORE_FOG")>=0,z=p.indexOf("#define SHADOWDEPTH_FRAGMENT")!==-1,J="";F?p=p.replace(/#define SHADOWDEPTH_SOFTTRANSPARENTSHADOW|#define CUSTOM_FRAGMENT_BEFORE_FOG/g,O):J=O+`\r
8485`,p=p.replace(/void\s+?main/g,je.a.IncludesShadersStore.shadowMapFragmentDeclaration+`\r
8486void main`),z?p=p.replace(/#define SHADOWDEPTH_FRAGMENT/g,U):J+=U+`\r
8487`,J&&(p=p.replace(/}\s*$/g,J+"}")),p=p.replace(/#define SHADER_NAME.*?\n|out vec4 glFragColor;\n/g,"");var ie=o.getUniformNames().slice();return ie.push("biasAndScaleSM","depthValuesSM","lightDataSM","softTransparentShadowSM"),a.depthEffect=this._scene.getEngine().createEffect({vertexSource:d,fragmentSource:p,vertexToken:a.token,fragmentToken:a.token},{attributes:o.getAttributesNames(),uniformsNames:ie,uniformBuffersNames:o.getUniformBuffersNames(),samplers:o.getSamplers(),defines:s+`
8488`+o.defines.replace("#define SHADOWS","").replace(/#define SHADOW\d/g,""),indexParameters:o.getIndexParameters()},this._scene.getEngine()),a.depthEffect},r}(),Td=f(101);function Ac(r,t,e,n,i){var o=new r.DecoderBuffer;o.Init(t,t.byteLength);var a,s,d=new r.Decoder;try{var p=d.GetEncodedGeometryType(o);switch(p){case r.TRIANGULAR_MESH:a=new r.Mesh,s=d.DecodeBufferToMesh(o,a);break;case r.POINT_CLOUD:a=new r.PointCloud,s=d.DecodeBufferToPointCloud(o,a);break;default:throw new Error("Invalid geometry type "+p)}if(!s.ok()||!a.ptr)throw new Error(s.error_msg());if(p===r.TRIANGULAR_MESH){var y=3*a.num_faces(),P=4*y,O=r._malloc(P);try{d.GetTrianglesUInt32Array(a,P,O);var U=new Uint32Array(y);U.set(new Uint32Array(r.HEAPF32.buffer,O,y)),n(U)}finally{r._free(O)}}var F=function(se,ce){var ue=ce.num_components(),fe=a.num_points(),ve=fe*ue,Te=ve*Float32Array.BYTES_PER_ELEMENT,Oe=r._malloc(Te);try{d.GetAttributeDataArrayForAllPoints(a,ce,r.DT_FLOAT32,Te,Oe);var Pe=new Float32Array(r.HEAPF32.buffer,Oe,ve);if(se==="color"&&ue===3){for(var Ee=new Float32Array(4*fe),Se=0,Le=0;Se<Ee.length;Se+=4,Le+=ue)Ee[Se+0]=Pe[Le+0],Ee[Se+1]=Pe[Le+1],Ee[Se+2]=Pe[Le+2],Ee[Se+3]=1;i(se,Ee)}else(Ee=new Float32Array(ve)).set(new Float32Array(r.HEAPF32.buffer,Oe,ve)),i(se,Ee)}finally{r._free(Oe)}};if(e)for(var z in e){var J=e[z];F(z,d.GetAttributeByUniqueId(a,J))}else{var ie={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"};for(var z in ie)(J=d.GetAttributeId(a,r[ie[z]]))!==-1&&F(z,d.GetAttribute(a,J))}}finally{a&&r.destroy(a),r.destroy(d),r.destroy(o)}}function Um(){var r;onmessage=function(t){var e=t.data;switch(e.id){case"init":var n=e.decoder;n.url&&(importScripts(n.url),r=DracoDecoderModule({wasmBinary:n.wasmBinary})),postMessage("done");break;case"decodeMesh":if(!r)throw new Error("Draco decoder module is not available");r.then(function(i){Ac(i,e.dataView,e.attributes,function(o){postMessage({id:"indices",value:o},[o.buffer])},function(o,a){postMessage({id:o,value:a},[a.buffer])}),postMessage("done")})}}}function Ed(r){return typeof document!="object"||typeof r!="string"?r:Ye.b.GetAbsoluteUrl(r)}var Vm=function(){function r(t){t===void 0&&(t=r.DefaultNumWorkers);var e=r.Configuration.decoder,n=e.wasmUrl&&e.wasmBinaryUrl&&typeof WebAssembly=="object"?{url:e.wasmUrl,wasmBinaryPromise:Ye.b.LoadFileAsync(Ed(e.wasmBinaryUrl))}:{url:e.fallbackUrl,wasmBinaryPromise:Promise.resolve(void 0)};t&&typeof Worker=="function"?this._workerPoolPromise=n.wasmBinaryPromise.then(function(i){for(var o=Ac+"("+Um+")()",a=URL.createObjectURL(new Blob([o],{type:"application/javascript"})),s=new Array(t),d=0;d<s.length;d++)s[d]=new Promise(function(p,y){var P=new Worker(a),O=function(F){P.removeEventListener("error",O),P.removeEventListener("message",U),y(F)},U=function(F){F.data==="done"&&(P.removeEventListener("error",O),P.removeEventListener("message",U),p(P))};P.addEventListener("error",O),P.addEventListener("message",U),P.postMessage({id:"init",decoder:{url:Ed(n.url),wasmBinary:i}})});return Promise.all(s).then(function(p){return new zs(p)})}):this._decoderModulePromise=n.wasmBinaryPromise.then(function(i){if(!n.url)throw new Error("Draco decoder module is not available");return Ye.b.LoadScriptAsync(n.url).then(function(){return o=i,new Promise(function(a){DracoDecoderModule({wasmBinary:o}).then(function(s){a({module:s})})});var o})})}return Object.defineProperty(r,"DecoderAvailable",{get:function(){var t=r.Configuration.decoder;return!!(t.wasmUrl&&t.wasmBinaryUrl&&typeof WebAssembly=="object"||t.fallbackUrl)}
8488,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.prototype.dispose=function(){this._workerPoolPromise&&this._workerPoolPromise.then(function(t){t.dispose()}),delete this._workerPoolPromise,delete this._decoderModulePromise},r.prototype.whenReadyAsync=function(){return this._workerPoolPromise?this._workerPoolPromise.then(function(){}):this._decoderModulePromise?this._decoderModulePromise.then(function(){}):Promise.resolve()},r.prototype.decodeMeshAsync=function(t,e){var n=t instanceof ArrayBuffer?new Uint8Array(t):t;if(this._workerPoolPromise)return this._workerPoolPromise.then(function(i){return new Promise(function(o,a){i.push(function(s,d){var p=new ft.a,y=function(U){s.removeEventListener("error",y),s.removeEventListener("message",P),a(U),d()},P=function(U){U.data==="done"?(s.removeEventListener("error",y),s.removeEventListener("message",P),o(p),d()):U.data.id==="indices"?p.indices=U.data.value:p.set(U.data.value,U.data.id)};s.addEventListener("error",y),s.addEventListener("message",P);var O=new Uint8Array(n.byteLength);O.set(new Uint8Array(n.buffer,n.byteOffset,n.byteLength)),s.postMessage({id:"decodeMesh",dataView:O,attributes:e},[O.buffer])})})});if(this._decoderModulePromise)return this._decoderModulePromise.then(function(i){var o=new ft.a;return Ac(i.module,n,e,function(a){o.indices=a},function(a,s){o.set(s,a)}),o});throw new Error("Draco decoder module is not available")},r.Configuration={decoder:{wasmUrl:"https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js",wasmBinaryUrl:"https://preview.babylonjs.com/draco_decoder_gltf.wasm",fallbackUrl:"https://preview.babylonjs.com/draco_decoder_gltf.js"}},r.DefaultNumWorkers=r.GetDefaultNumWorkers(),r._Default=null,r}(),To=f(61),Sd=0,km=function(){function r(t,e,n,i){this.pos=t,this.normal=e,this.uv=n,this.vertColor=i}return r.prototype.clone=function(){var t,e;return new r(this.pos.clone(),this.normal.clone(),(t=this.uv)===null||t===void 0?void 0:t.clone(),(e=this.vertColor)===null||e===void 0?void 0:e.clone())},r.prototype.flip=function(){this.normal=this.normal.scale(-1)},r.prototype.interpolate=function(t,e){return new r(u.e.Lerp(this.pos,t.pos,e),u.e.Lerp(this.normal,t.normal,e),this.uv&&t.uv?u.d.Lerp(this.uv,t.uv,e):void 0,this.vertColor&&t.vertColor?M.b.Lerp(this.vertColor,t.vertColor,e):void 0)},r}(),Gm=function(){function r(t,e){this.normal=t,this.w=e}return r.FromPoints=function(t,e,n){var i=n.subtract(t),o=e.subtract(t);if(i.lengthSquared()===0||o.lengthSquared()===0)return null;var a=u.e.Normalize(u.e.Cross(i,o));return new r(a,u.e.Dot(a,t))},r.prototype.clone=function(){return new r(this.normal.clone(),this.w)},r.prototype.flip=function(){this.normal.scaleInPlace(-1),this.w=-this.w},r.prototype.splitPolygon=function(t,e,n,i,o){var a,s,d=0,p=[];for(a=0;a<t.vertices.length;a++){var y=(s=u.e.Dot(this.normal,t.vertices[a].pos)-this.w)<-r.EPSILON?2:s>r.EPSILON?1:0;d|=y,p.push(y)}switch(d){case 0:(u.e.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 P,O=[],U=[];for(a=0;a<t.vertices.length;a++){var F=(a+1)%t.vertices.length,z=p[a],J=p[F],ie=t.vertices[a],se=t.vertices[F];if(z!==2&&O.push(ie),z!==1&&U.push(z!==2?ie.clone():ie),(z|J)==3){s=(this.w-u.e.Dot(this.normal,ie.pos))/u.e.Dot(this.normal,se.pos.subtract(ie.pos));var ce=ie.interpolate(se,s);O.push(ce),U.push(ce.clone())}}O.length>=3&&(P=new Pc(O,t.shared)).plane&&i.push(P),U.length>=3&&(P=new Pc(U,t.shared)).plane&&o.push(P)}},r.EPSILON=1e-5,r}(),Pc=function(){function r(t,e){this.vertices=t,this.shared=e,this.plane=Gm.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}(),Qn=function(){function r(t){this.plane=null,this.front=null,this.back=null,this.polygons=new Array,t&&this.build(t)}return r.prototype.clone=function(){var t=new r;return t.plane=this.plane&&this.plane.clone(),t.front=this.front&&this.front.clone(),t.back=this.back&&this.back.clone(),t.polygons=this.polygons.map(function(e){return e.clone()}),t},r.prototype.invert=function(){for(var t=0;t<this.polygons.length;t++)this.polygons[t].flip();this.plane&&this.plane.flip(),this.front&&this.front.invert(),this.back&&this.back.invert();var e=this.front;this.front=this.back,this.back=e},r.prototype.clipPolygons=function(t){if(!this.plane)return t.slice();for(var e=new Array,n=new Array,i=0;i<t.length;i++)this.plane.splitPolygon(t[i],e,n,e,n);return this.front&&(e=this.front.clipPolygons(e)),n=this.back?this.back.clipPolygons(n):[],e.concat(n)},r.prototype.clipTo=function(t){this.polygons=t.clipPolygons(this.polygons),this.front&&this.front.clipTo(t),this.back&&this.back.clipTo(t)},r.prototype.allPolygons=function(){var t=this.polygons.slice();return this.front&&(t=t.concat(this.front.allPolygons())),this.back&&(t=t.concat(this.back.allPolygons())),t},r.prototype.build=function(t){if(t.length){this.plane||(this.plane=t[0].plane.clone());for(var e=new Array,n=new Array,i=0;i<t.length;i++)this.plane.splitPolygon(t[i],this.polygons,this.polygons,e,n);e.length&&(this.front||(this.front=new r),this.front.build(e)),n.length&&(this.back||(this.back=new r),this.back.build(n))}},r}(),zm=function(){function r(){this.polygons=new Array}return r.FromMesh=function(t){var e,n,i,o,a,s,d,p,y,P=void 0,O=void 0,U=new Array,F=null;if(!(t instanceof De.a))throw"BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh";t.computeWorldMatrix(!0),s=t.getWorldMatrix(),d=t.position.clone(),p=t.rotation.clone(),t.rotationQuaternion&&(F=t.rotationQuaternion.clone()),y=t.scaling.clone();for(var z=t.getIndices(),J=t.getVerticesData(Me.b.PositionKind),ie=t.getVerticesData(Me.b.NormalKind),se=t.getVerticesData(Me.b.UVKind),ce=t.getVerticesData(Me.b.ColorKind),ue=t.subMeshes,fe=0,ve=ue.length;fe<ve;fe++)for(var Te=ue[fe].indexStart,Oe=ue[fe].indexCount+ue[fe].indexStart;Te<Oe;Te+=3){a=[];for(var Pe=0;Pe<3;Pe++){var Ee=new u.e(ie[3*z[Te+Pe]],ie[3*z[Te+Pe]+1],ie[3*z[Te+Pe]+2]);se&&(P=new u.d(se[2*z[Te+Pe]],se[2*z[Te+Pe]+1])),ce&&(O=new M.b(ce[4*z[Te+Pe]],ce[4*z[Te+Pe]+1],ce[4*z[Te+Pe]+2],ce[4*z[Te+Pe]+3]));var Se=new u.e(J[3*z[Te+Pe]],J[3*z[Te+Pe]+1],J[3*z[Te+Pe]+2]);i=u.e.TransformCoordinates(Se,s),n=u.e.TransformNormal(Ee,s),e=new km(i,n,P,O),a.push(e)}(o=new Pc(a,{subMeshId:fe,meshId:Sd,materialIndex:ue[fe].materialIndex})).plane&&U.push(o)}var Le=r.FromPolygons(U);return Le.matrix=s,Le.position=d,Le.rotation=p,Le.scaling=y,Le.rotationQuaternion=F,Sd++,Le},r.FromPolygons=function(t){var e=new r;return e.polygons=t,e},r.prototype.clone=function(){var t=new r;return t.polygons=this.polygons.map(function(e){return e.clone()}),t.copyTransformAttributes(this),t},r.prototype.union=function(t){var e=new Qn(this.clone().polygons),n=new Qn(t.clone().polygons);return e.clipTo(n),n.clipTo(e),n.invert(),n.clipTo(e),n.invert(),e.build(n.allPolygons()),r.FromPolygons(e.allPolygons()).copyTransformAttributes(this)},r.prototype.unionInPlace=function(t){var e=new Qn(this.polygons),n=new Qn(t.polygons);e.clipTo(n),n.clipTo(e),n.invert(),n.clipTo(e),n.invert(),e.build(n.allPolygons()),this.polygons=e.allPolygons()},r.prototype.subtract=function(t){var e=new Qn(this.clone().polygons),n=new Qn(t.clone().polygons);return e.invert(),e.clipTo(n),n.clipTo(e),n.invert(),n.clipTo(e),n.invert(),e.build(n.allPolygons()),e.invert(),r.FromPolygons(e.allPolygons()).copyTransformAttributes(this)},r.prototype.subtractInPlace=function(t){var e=new Qn(this.polygons),n=new Qn(t.polygons);e.invert(),e.clipTo(n),n.clipTo(e),n.invert(),n.clipTo(e),n.invert(),e.build(n.allPolygons()),e.invert(),this.polygons=e.allPolygons()},r.prototype.intersect=function(t){var e=new Qn(this.clone().polygons),n=new Qn(t.clone().polygons);return e.invert(),n.clipTo(e),n.invert(),e.clipTo(n),n.clipTo(e),e.build(n.allPolygons()),e.invert(),r.FromPolygons(e.allPolygons()).copyTransformAttributes(this)},r.prototype.intersectInPlace=function(t){var e=new Qn(this.polygons),n=new Qn(t.polygons);e.invert(),n.clipTo(e),n.invert(),e.clipTo(n),n.clipTo(e),e.build(n.allPolygons()),e.invert(),this.polygons=e.allPolygons()},r.prototype.inverse=function(){var t=this.clone();return t.inverseInPlace(),t},r.prototype.inverseInPlace=function(){this.polygons.map(function(t){t.flip()})},r.prototype.copyTransformAttributes=function(t){return this.matrix=t.matrix,this.position=t.position,this.rotation=t.rotation,this.scaling=t.scaling,this.rotationQuaternion=t.rotationQuaternion,this},r.prototype.buildMeshGeometry=function(t,e,n){var i=this.matrix.clone();i.invert();var o,a,s,d=new De.a(t,e),p=[],y=[],P=[],O=null,U=null,F=u.e.Zero(),z=u.e.Zero(),J=u.d.Zero(),ie=new M.b(0,0,0,0),se=this.polygons,ce=[0,0,0],ue={},fe=0,ve={};n&&se.sort(function(ut,qe){return ut.shared.meshId===qe.shared.meshId?ut.shared.subMeshId-qe.shared.subMeshId:ut.shared.meshId-qe.shared.meshId});for(var Te=0,Oe=se.length;Te<Oe;Te++){ve[(o=se[Te]).shared.meshId]||(ve[o.shared.meshId]={}),ve[o.shared.meshId][o.shared.subMeshId]||(ve[o.shared.meshId][o.shared.subMeshId]={indexStart:1/0,indexEnd:-1/0,materialIndex:o.shared.materialIndex}),s=ve[o.shared.meshId][o.shared.subMeshId];for(var Pe=2,Ee=o.vertices.length;Pe<Ee;Pe++){ce[0]=0,ce[1]=Pe-1,ce[2]=Pe;
8488for(var Se=0;Se<3;Se++){F.copyFrom(o.vertices[ce[Se]].pos),z.copyFrom(o.vertices[ce[Se]].normal),o.vertices[ce[Se]].uv&&(O||(O=[]),J.copyFrom(o.vertices[ce[Se]].uv)),o.vertices[ce[Se]].vertColor&&(U||(U=[]),ie.copyFrom(o.vertices[ce[Se]].vertColor));var Le=u.e.TransformCoordinates(F,i),xe=u.e.TransformNormal(z,i);a=ue[Le.x+","+Le.y+","+Le.z];var Ne=!1;O&&O[2*a]!==J.x&&O[2*a+1]!==J.y&&(Ne=!0);var Ie=!1;U&&U[4*a]!==ie.r&&U[4*a+1]!==ie.g&&U[4*a+2]!==ie.b&&U[4*a+3]!==ie.a&&(Ie=!0),(a===void 0||P[3*a]!==xe.x||P[3*a+1]!==xe.y||P[3*a+2]!==xe.z||Ne||Ie)&&(p.push(Le.x,Le.y,Le.z),O&&O.push(J.x,J.y),P.push(z.x,z.y,z.z),U&&U.push(ie.r,ie.g,ie.b,ie.a),a=ue[Le.x+","+Le.y+","+Le.z]=p.length/3-1),y.push(a),s.indexStart=Math.min(fe,s.indexStart),s.indexEnd=Math.max(fe,s.indexEnd),fe++}}}if(d.setVerticesData(Me.b.PositionKind,p),d.setVerticesData(Me.b.NormalKind,P),O&&d.setVerticesData(Me.b.UVKind,O),U&&d.setVerticesData(Me.b.ColorKind,U),d.setIndices(y,null),n){var Fe,Ke=0;for(var nt in d.subMeshes=new Array,ve){for(var rt in Fe=-1,ve[nt])s=ve[nt][rt],To.a.CreateFromIndices(s.materialIndex+Ke,s.indexStart,s.indexEnd-s.indexStart+1,d),Fe=Math.max(s.materialIndex,Fe);Ke+=++Fe}}return d},r.prototype.toMesh=function(t,e,n,i){e===void 0&&(e=null);var o=this.buildMeshGeometry(t,n,i);return o.material=e,o.position.copyFrom(this.position),o.rotation.copyFrom(this.rotation),this.rotationQuaternion&&(o.rotationQuaternion=this.rotationQuaternion.clone()),o.scaling.copyFrom(this.scaling),o.computeWorldMatrix(!0),o},r}(),jm=function(r){function t(e,n,i,o,a,s){o===void 0&&(o=1),a===void 0&&(a=60),s===void 0&&(s=!0);var d=r.call(this,e,i)||this;d._sectionPolygonPointsCount=4,d._running=!1,d._autoStart=s,d._generator=n,d._diameter=o,d._length=a,d._sectionVectors=[],d._sectionNormalVectors=[];for(var p=0;p<d._sectionPolygonPointsCount;p++)d._sectionVectors[p]=u.e.Zero(),d._sectionNormalVectors[p]=u.e.Zero();return d._createMesh(),d}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"TrailMesh"},t.prototype._createMesh=function(){var e=new ft.a,n=[],i=[],o=[],a=u.e.Zero();a=this._generator instanceof Dt.a&&this._generator._boundingInfo?this._generator._boundingInfo.boundingBox.centerWorld:this._generator.position;for(var s=2*Math.PI/this._sectionPolygonPointsCount,d=0;d<this._sectionPolygonPointsCount;d++)n.push(a.x+Math.cos(d*s)*this._diameter,a.y+Math.sin(d*s)*this._diameter,a.z);for(d=1;d<=this._length;d++){for(var p=0;p<this._sectionPolygonPointsCount;p++)n.push(a.x+Math.cos(p*s)*this._diameter,a.y+Math.sin(p*s)*this._diameter,a.z);var y=n.length/3-2*this._sectionPolygonPointsCount;for(p=0;p<this._sectionPolygonPointsCount-1;p++)o.push(y+p,y+p+this._sectionPolygonPointsCount,y+p+this._sectionPolygonPointsCount+1),o.push(y+p,y+p+this._sectionPolygonPointsCount+1,y+p+1);o.push(y+this._sectionPolygonPointsCount-1,y+this._sectionPolygonPointsCount-1+this._sectionPolygonPointsCount,y+this._sectionPolygonPointsCount),o.push(y+this._sectionPolygonPointsCount-1,y+this._sectionPolygonPointsCount,y)}ft.a.ComputeNormals(n,o,i),e.positions=n,e.normals=i,e.indices=o,e.applyToMesh(this,!0),this._autoStart&&this.start()},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(Me.b.PositionKind),n=this.getVerticesData(Me.b.NormalKind),i=this._generator.getWorldMatrix();if(e&&n){for(var o=3*this._sectionPolygonPointsCount;o<e.length;o++)e[o-3*this._sectionPolygonPointsCount]=e[o]-n[o]/this._length*this._diameter;for(o=3*this._sectionPolygonPointsCount;o<n.length;o++)n[o-3*this._sectionPolygonPointsCount]=n[o];var a=e.length-3*this._sectionPolygonPointsCount,s=2*Math.PI/this._sectionPolygonPointsCount;for(o=0;o<this._sectionPolygonPointsCount;o++)this._sectionVectors[o].copyFromFloats(Math.cos(o*s)*this._diameter,Math.sin(o*s)*this._diameter,0),this._sectionNormalVectors[o].copyFromFloats(Math.cos(o*s),Math.sin(o*s),0),u.e.TransformCoordinatesToRef(this._sectionVectors[o],i,this._sectionVectors[o]),u.e.TransformNormalToRef(this._sectionNormalVectors[o],i,this._sectionNormalVectors[o]);for(o=0;o<this._sectionPolygonPointsCount;o++)e[a+3*o]=this._sectionVectors[o].x,e[a+3*o+1]=this._sectionVectors[o].y,e[a+3*o+2]=this._sectionVectors[o].z,n[a+3*o]=this._sectionNormalVectors[o].x,n[a+3*o+1]=this._sectionNormalVectors[o].y,n[a+3*o+2]=this._sectionNormalVectors[o].z;this.updateVerticesData(Me.b.PositionKind,e,!0,!1),this.updateVerticesData(Me.b.NormalKind,n,!0,!1)}},t.prototype.clone=function(e,n){return e===void 0&&(e=""),new t(e,n===void 0?this._generator:n,this.get
8488Scene(),this._diameter,this._length,this._autoStart)},t.prototype.serialize=function(e){r.prototype.serialize.call(this,e)},t.Parse=function(e,n){return new t(e.name,e._generator,n,e._diameter,e._length,e._autoStart)},t}(De.a),Hm=f(151),Eo=f(98),So=f(82);ft.a.CreateDisc=function(r){var t=new Array,e=new Array,n=new Array,i=new Array,o=r.radius||.5,a=r.tessellation||64,s=r.arc&&(r.arc<=0||r.arc>1)?1:r.arc||1,d=r.sideOrientation===0?0:r.sideOrientation||ft.a.DEFAULTSIDE;t.push(0,0,0),i.push(.5,.5);for(var p=2*Math.PI*s,y=s===1?p/a:p/(a-1),P=0,O=0;O<a;O++){var U=Math.cos(P),F=Math.sin(P),z=(U+1)/2,J=(1-F)/2;t.push(o*U,o*F,0),i.push(z,J),P+=y}s===1&&(t.push(t[3],t[4],t[5]),i.push(i[2],i[3]));for(var ie=t.length/3,se=1;se<ie-1;se++)e.push(se+1,0,se);ft.a.ComputeNormals(t,e,n),ft.a._ComputeSides(d,t,e,n,i,r.frontUVs,r.backUVs);var ce=new ft.a;return ce.indices=e,ce.positions=t,ce.normals=n,ce.uvs=i,ce},De.a.CreateDisc=function(r,t,e,n,i,o){n===void 0&&(n=null);var a={radius:t,tessellation:e,sideOrientation:o,updatable:i};return Aa.CreateDisc(r,a,n)};var Aa=function(){function r(){}return r.CreateDisc=function(t,e,n){n===void 0&&(n=null);var i=new De.a(t,n);return e.sideOrientation=De.a._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,ft.a.CreateDisc(e).applyToMesh(i,e.updatable),i},r}();ft.a.CreateTiledBox=function(r){for(var t=r.faceUV||new Array(6),e=r.faceColors,n=r.pattern||De.a.NO_FLIP,i=r.width||r.size||1,o=r.height||r.size||1,a=r.depth||r.size||1,s=r.tileWidth||r.tileSize||1,d=r.tileHeight||r.tileSize||1,p=r.alignHorizontal||0,y=r.alignVertical||0,P=r.sideOrientation===0?0:r.sideOrientation||ft.a.DEFAULTSIDE,O=0;O<6;O++)t[O]===void 0&&(t[O]=new u.f(0,0,1,1)),e&&e[O]===void 0&&(e[O]=new M.b(1,1,1,1));var U=i/2,F=o/2,z=a/2,J=[];for(O=0;O<2;O++)J[O]=ft.a.CreateTiledPlane({pattern:n,tileWidth:s,tileHeight:d,width:i,height:o,alignVertical:y,alignHorizontal:p,sideOrientation:P});for(O=2;O<4;O++)J[O]=ft.a.CreateTiledPlane({pattern:n,tileWidth:s,tileHeight:d,width:a,height:o,alignVertical:y,alignHorizontal:p,sideOrientation:P});var ie=y;for(y===De.a.BOTTOM?ie=De.a.TOP:y===De.a.TOP&&(ie=De.a.BOTTOM),O=4;O<6;O++)J[O]=ft.a.CreateTiledPlane({pattern:n,tileWidth:s,tileHeight:d,width:i,height:a,alignVertical:ie,alignHorizontal:p,sideOrientation:P});var se=[],ce=[],ue=[],fe=[],ve=[],Te=[],Oe=[],Pe=[],Ee=0,Se=0,Le=0;for(O=0;O<6;O++){Ee=J[O].positions.length,Te[O]=[],Oe[O]=[];for(var xe=0;xe<Ee/3;xe++)Te[O].push(new u.e(J[O].positions[3*xe],J[O].positions[3*xe+1],J[O].positions[3*xe+2])),Oe[O].push(new u.e(J[O].normals[3*xe],J[O].normals[3*xe+1],J[O].normals[3*xe+2]));Se=J[O].uvs.length,Pe[O]=[];for(var Ne=0;Ne<Se;Ne+=2)Pe[O][Ne]=t[O].x+(t[O].z-t[O].x)*J[O].uvs[Ne],Pe[O][Ne+1]=t[O].y+(t[O].w-t[O].y)*J[O].uvs[Ne+1];if(ue=ue.concat(Pe[O]),fe=fe.concat(J[O].indices.map(function(Ve){return Ve+Le})),Le+=Te[O].length,e)for(var Ie=0;Ie<4;Ie++)ve.push(e[O].r,e[O].g,e[O].b,e[O].a)}var Fe=new u.e(0,0,z),Ke=u.a.RotationY(Math.PI);se=Te[0].map(function(Ve){return u.e.TransformNormal(Ve,Ke).add(Fe)}).map(function(Ve){return[Ve.x,Ve.y,Ve.z]}).reduce(function(Ve,$e){return Ve.concat($e)},[]),ce=Oe[0].map(function(Ve){return u.e.TransformNormal(Ve,Ke)}).map(function(Ve){return[Ve.x,Ve.y,Ve.z]}).reduce(function(Ve,$e){return Ve.concat($e)},[]),se=se.concat(Te[1].map(function(Ve){return Ve.subtract(Fe)}).map(function(Ve){return[Ve.x,Ve.y,Ve.z]}).reduce(function(Ve,$e){return Ve.concat($e)},[])),ce=ce.concat(Oe[1].map(function(Ve){return[Ve.x,Ve.y,Ve.z]}).reduce(function(Ve,$e){return Ve.concat($e)},[]));var nt=new u.e(U,0,0),rt=u.a.RotationY(-Math.PI/2);se=se.concat(Te[2].map(function(Ve){return u.e.TransformNormal(Ve,rt).add(nt)}).map(function(Ve){return[Ve.x,Ve.y,Ve.z]}).reduce(function(Ve,$e){return Ve.concat($e)},[])),ce=ce.concat(Oe[2].map(function(Ve){return u.e.TransformNormal(Ve,rt)}).map(function(Ve){return[Ve.x,Ve.y,Ve.z]}).reduce(function(Ve,$e){return Ve.concat($e)},[]));var ut=u.a.RotationY(Math.PI/2);se=se.concat(Te[3].map(function(Ve){return u.e.TransformNormal(Ve,ut).subtract(nt)}).map(function(Ve){return[Ve.x,Ve.y,Ve.z]}).reduce(function(Ve,$e){return Ve.concat($e)},[])),ce=ce.concat(Oe[3].map(function(Ve){return u.e.TransformNormal(Ve,ut)}).map(function(Ve){return[Ve.x,Ve.y,Ve.z]}).reduce(function(Ve,$e){return Ve.concat($e)},[]));var qe=new u.e(0,F,0),at=u.a.RotationX(Math.PI/2);se=se.concat(Te[4].map(function(Ve){return u.e.TransformNormal(Ve,at).add(qe)}
8488).map(function(Ve){return[Ve.x,Ve.y,Ve.z]}).reduce(function(Ve,$e){return Ve.concat($e)},[])),ce=ce.concat(Oe[4].map(function(Ve){return u.e.TransformNormal(Ve,at)}).map(function(Ve){return[Ve.x,Ve.y,Ve.z]}).reduce(function(Ve,$e){return Ve.concat($e)},[]));var ot=u.a.RotationX(-Math.PI/2);se=se.concat(Te[5].map(function(Ve){return u.e.TransformNormal(Ve,ot).subtract(qe)}).map(function(Ve){return[Ve.x,Ve.y,Ve.z]}).reduce(function(Ve,$e){return Ve.concat($e)},[])),ce=ce.concat(Oe[5].map(function(Ve){return u.e.TransformNormal(Ve,ot)}).map(function(Ve){return[Ve.x,Ve.y,Ve.z]}).reduce(function(Ve,$e){return Ve.concat($e)},[])),ft.a._ComputeSides(P,se,fe,ce,ue);var Je=new ft.a;if(Je.indices=fe,Je.positions=se,Je.normals=ce,Je.uvs=ue,e){var dt=P===ft.a.DOUBLESIDE?ve.concat(ve):ve;Je.colors=dt}return Je};var Ad=function(){function r(){}return r.CreateTiledBox=function(t,e,n){n===void 0&&(n=null);var i=new De.a(t,n);return e.sideOrientation=De.a._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,ft.a.CreateTiledBox(e).applyToMesh(i,e.updatable),i},r}();ft.a.CreateTorusKnot=function(r){var t,e,n=new Array,i=new Array,o=new Array,a=new Array,s=r.radius||2,d=r.tube||.5,p=r.radialSegments||32,y=r.tubularSegments||32,P=r.p||2,O=r.q||3,U=r.sideOrientation===0?0:r.sideOrientation||ft.a.DEFAULTSIDE,F=function(Ne){var Ie=Math.cos(Ne),Fe=Math.sin(Ne),Ke=O/P*Ne,nt=Math.cos(Ke),rt=s*(2+nt)*.5*Ie,ut=s*(2+nt)*Fe*.5,qe=s*Math.sin(Ke)*.5;return new u.e(rt,ut,qe)};for(t=0;t<=p;t++){var z=t%p/p*2*P*Math.PI,J=F(z),ie=F(z+.01),se=ie.subtract(J),ce=ie.add(J),ue=u.e.Cross(se,ce);for(ce=u.e.Cross(ue,se),ue.normalize(),ce.normalize(),e=0;e<y;e++){var fe=e%y/y*2*Math.PI,ve=-d*Math.cos(fe),Te=d*Math.sin(fe);i.push(J.x+ve*ce.x+Te*ue.x),i.push(J.y+ve*ce.y+Te*ue.y),i.push(J.z+ve*ce.z+Te*ue.z),a.push(t/p),a.push(e/y)}}for(t=0;t<p;t++)for(e=0;e<y;e++){var Oe=(e+1)%y,Pe=t*y+e,Ee=(t+1)*y+e,Se=(t+1)*y+Oe,Le=t*y+Oe;n.push(Le),n.push(Ee),n.push(Pe),n.push(Le),n.push(Se),n.push(Ee)}ft.a.ComputeNormals(i,n,o),ft.a._ComputeSides(U,i,n,o,a,r.frontUVs,r.backUVs);var xe=new ft.a;return xe.indices=n,xe.positions=i,xe.normals=o,xe.uvs=a,xe},De.a.CreateTorusKnot=function(r,t,e,n,i,o,a,s,d,p){var y={radius:t,tube:e,radialSegments:n,tubularSegments:i,p:o,q:a,sideOrientation:p,updatable:d};return Cc.CreateTorusKnot(r,y,s)};var Cc=function(){function r(){}return r.CreateTorusKnot=function(t,e,n){var i=new De.a(t,n);return e.sideOrientation=De.a._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,ft.a.CreateTorusKnot(e).applyToMesh(i,e.updatable),i},r}(),Wm=function(r){function t(e,n){var i=r.call(this,e.x,e.y)||this;return i.index=n,i}return Object(c.d)(t,r),t}(u.d),xc=function(){function r(){this.elements=new Array}return r.prototype.add=function(t){var e=this,n=new Array;return t.forEach(function(i){var o=new Wm(i,e.elements.length);n.push(o),e.elements.push(o)}),n},r.prototype.computeBounds=function(){var t=new u.d(this.elements[0].x,this.elements[0].y),e=new u.d(this.elements[0].x,this.elements[0].y);return this.elements.forEach(function(n){n.x<t.x?t.x=n.x:n.x>e.x&&(e.x=n.x),n.y<t.y?t.y=n.y:n.y>e.y&&(e.y=n.y)}),{min:t,max:e,width:e.x-t.x,height:e.y-t.y}},r}(),Xm=function(){function r(){}return r.Rectangle=function(t,e,n,i){return[new u.d(t,e),new u.d(n,e),new u.d(n,i),new u.d(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=new Array,a=0,s=2*Math.PI/i,d=0;d<i;d++)o.push(new u.d(e+Math.cos(a)*t,n+Math.sin(a)*t)),a-=s;return o},r.Parse=function(t){var e,n=t.split(/[^-+eE\.\d]+/).map(parseFloat).filter(function(o){return!isNaN(o)}),i=[];for(e=0;e<(2147483646&n.length);e+=2)i.push(new u.d(n[e],n[e+1]));return i},r.StartingAt=function(t,e){return Ze.f.StartingAt(t,e)},r}(),Pd=function(){function r(t,e,n,i){var o;i===void 0&&(i=earcut),this._points=new xc,this._outlinepoints=new xc,this._holes=new Array,this._epoints=new Array,this._eholes=new Array,this.bjsEarcut=i,this._name=t,this._scene=n||Ue.a.LastCreatedScene,o=e instanceof Ze.f?e.getPoints():e,this._addToepoint(o),this._points.add(o),this._outlinepoints.add(o),this.bjsEarcut===void 0&&l.a.Warn("Earcut was not found, the polygon will not be built.")}return r.prototype._addToepoint=function(t){for(var e=0,n=t;e<n.length;e++){var i=n[e];this._epoints.push(i.x,i.y)}},r.prototype.addHole=function(t){this._points.add(t);var e=new xc;return e.add(t),this._holes.push(e),this._eholes.push(this._epoints.length/2),this._addToepoint(t),this},r.prototype.build=function(t,e){t===void 0&&(t=!1),e===void 0&&(e=0);var n=new De.a(this._name,this._scene),i=this.buildVertexData(e);return n.setVerticesData(Me.b.PositionKind,i.positions,t),n.setVerticesData(Me.b.NormalKind,i.normals,t),n.setVerticesData(Me.b.UVKind,i.uvs,t),n.setIndices(i.indices),n},r.prototype.buildVertexData=function(t){var e=this;t===void 0&&(t=0);var n=new ft.a,i=new Array,o=new Array,a=new Array,s=this._points.computeBounds();
8488this._points.elements.forEach(function(J){i.push(0,1,0),o.push(J.x,0,J.y),a.push((J.x-s.min.x)/s.width,(J.y-s.min.y)/s.height)});for(var d=new Array,p=this.bjsEarcut(this._epoints,this._eholes,2),y=0;y<p.length;y++)d.push(p[y]);if(t>0){var P=o.length/3;this._points.elements.forEach(function(J){i.push(0,-1,0),o.push(J.x,-t,J.y),a.push(1-(J.x-s.min.x)/s.width,1-(J.y-s.min.y)/s.height)});var O=d.length;for(y=0;y<O;y+=3){var U=d[y+0],F=d[y+1],z=d[y+2];d.push(z+P),d.push(F+P),d.push(U+P)}this.addSide(o,i,a,d,s,this._outlinepoints,t,!1),this._holes.forEach(function(J){e.addSide(o,i,a,d,s,J,t,!0)})}return n.indices=d,n.positions=o,n.normals=i,n.uvs=a,n},r.prototype.addSide=function(t,e,n,i,o,a,s,d){for(var p=t.length/3,y=0,P=0;P<a.elements.length;P++){var O,U=a.elements[P];O=P+1>a.elements.length-1?a.elements[0]:a.elements[P+1],t.push(U.x,0,U.y),t.push(U.x,-s,U.y),t.push(O.x,0,O.y),t.push(O.x,-s,O.y);var F=new u.e(U.x,0,U.y),z=new u.e(O.x,0,O.y).subtract(F),J=new u.e(0,1,0),ie=u.e.Cross(z,J);ie=ie.normalize(),n.push(y/o.width,0),n.push(y/o.width,1),y+=z.length(),n.push(y/o.width,0),n.push(y/o.width,1),d?(e.push(ie.x,ie.y,ie.z),e.push(ie.x,ie.y,ie.z),e.push(ie.x,ie.y,ie.z),e.push(ie.x,ie.y,ie.z),i.push(p),i.push(p+2),i.push(p+1),i.push(p+1),i.push(p+2),i.push(p+3)):(e.push(-ie.x,-ie.y,-ie.z),e.push(-ie.x,-ie.y,-ie.z),e.push(-ie.x,-ie.y,-ie.z),e.push(-ie.x,-ie.y,-ie.z),i.push(p),i.push(p+1),i.push(p+2),i.push(p+1),i.push(p+3),i.push(p+2)),p+=4}},r}();ft.a.CreatePolygon=function(r,t,e,n,i,o,a){for(var s=e||new Array(3),d=n,p=[],y=a||!1,P=0;P<3;P++)s[P]===void 0&&(s[P]=new u.f(0,0,1,1)),d&&d[P]===void 0&&(d[P]=new M.b(1,1,1,1));var O=r.getVerticesData(Me.b.PositionKind),U=r.getVerticesData(Me.b.NormalKind),F=r.getVerticesData(Me.b.UVKind),z=r.getIndices(),J=O.length/9,ie=0,se=0,ce=0,ue=0,fe=[0];if(y)for(var ve=J;ve<O.length/3;ve+=4)se=O[3*(ve+2)]-O[3*ve],ce=O[3*(ve+2)+2]-O[3*ve+2],ue+=Math.sqrt(se*se+ce*ce),fe.push(ue);ve=0;for(var Te=0,Oe=0;Oe<U.length;Oe+=3)Math.abs(U[Oe+1])<.001&&(Te=1),Math.abs(U[Oe+1]-1)<.001&&(Te=0),Math.abs(U[Oe+1]+1)<.001&&(Te=2),ve=Oe/3,Te===1?(ie=ve-J,F[2*ve]=ie%4<1.5?y?s[Te].x+(s[Te].z-s[Te].x)*fe[Math.floor(ie/4)]/ue:s[Te].x:y?s[Te].x+(s[Te].z-s[Te].x)*fe[Math.floor(ie/4)+1]/ue:s[Te].z,F[2*ve+1]=ie%2==0?s[Te].w:s[Te].y):(F[2*ve]=(1-F[2*ve])*s[Te].x+F[2*ve]*s[Te].z,F[2*ve+1]=(1-F[2*ve+1])*s[Te].y+F[2*ve+1]*s[Te].w),d&&p.push(d[Te].r,d[Te].g,d[Te].b,d[Te].a);ft.a._ComputeSides(t,O,z,U,F,i,o);var Pe=new ft.a;if(Pe.indices=z,Pe.positions=O,Pe.normals=U,Pe.uvs=F,d){var Ee=t===ft.a.DOUBLESIDE?p.concat(p):p;Pe.colors=Ee}return Pe},De.a.CreatePolygon=function(r,t,e,n,i,o,a){a===void 0&&(a=earcut);var s={shape:t,holes:n,updatable:i,sideOrientation:o};return Ao.CreatePolygon(r,s,e,a)},De.a.ExtrudePolygon=function(r,t,e,n,i,o,a,s){s===void 0&&(s=earcut);var d={shape:t,holes:i,depth:e,updatable:o,sideOrientation:a};return Ao.ExtrudePolygon(r,d,n,s)};var Ao=function(){function r(){}return r.CreatePolygon=function(t,e,n,i){n===void 0&&(n=null),i===void 0&&(i=earcut),e.sideOrientation=De.a._GetDefaultSideOrientation(e.sideOrientation);for(var o=e.shape,a=e.holes||[],s=e.depth||0,d=[],p=[],y=0;y<o.length;y++)d[y]=new u.d(o[y].x,o[y].z);d[0].equalsWithEpsilon(d[d.length-1],1e-8)&&d.pop();for(var P=new Pd(t,d,n||te.a.LastCreatedScene,i),O=0;O<a.length;O++){p=[];for(var U=0;U<a[O].length;U++)p.push(new u.d(a[O][U].x,a[O][U].z));P.addHole(p)}var F=P.build(e.updatable,s);return F._originalBuilderSideOrientation=e.sideOrientation,ft.a.CreatePolygon(F,e.sideOrientation,e.faceUV,e.faceColors,e.frontUVs,e.backUVs,e.wrap).applyToMesh(F,e.updatable),F},r.ExtrudePolygon=function(t,e,n,i){return n===void 0&&(n=null),i===void 0&&(i=earcut),r.CreatePolygon(t,e,n,i)},r}();De.a.CreateLathe=function(r,t,e,n,i,o,a){var s={shape:t,radius:e,tessellation:n,sideOrientation:a,updatable:o};return Rc.CreateLathe(r,s,i)};var Rc=function(){function r(){}return r.CreateLathe=function(t,e,n){n===void 0&&(n=null);var i,o=e.arc?e.arc<=0||e.arc>1?1:e.arc:1,a=e.closed===void 0||e.closed,s=e.shape,d=e.radius||1,p=e.tessellation||64,y=e.clip||0,P=e.updatable,O=De.a._GetDefaultSideOrientation(e.sideOrientation),U=e.cap||De.a.NO_CAP,F=2*Math.PI,z=new Array,J=e.invertUV||!1,ie=0,se=0,ce=F/p*o,ue=new Array;for(ie=0;ie<=p-y;ie++){for(ue=[],U!=De.a.CAP_START&&U!=De.a.CAP_ALL||(ue.push(new u.e(0,s[0].y,0)),ue.push(new u.e(Math.cos(ie*ce)*s[0].x*d,s[0].y,Math.sin(ie*ce)*s[0].x*d))),se=0;se<s.length;se++)i=new u.e(Math.cos(ie*ce)*s[se].x*d,s[se].y,Math.sin(ie*ce)*s[se].x*d),ue.push(i);U!=De.a.CAP_END&&U!=De.a.CAP_ALL||(ue.push(new u.e(Math.cos(ie*ce)*s[s.length-1].x*d,s[s.length-1].y,Math.sin(ie*ce)*s[s.length-1].x*d)),ue.push(new u.e(0,s[s.length-1].y,0))),z.pu
8488sh(ue)}return So.a.CreateRibbon(t,{pathArray:z,closeArray:a,sideOrientation:O,updatable:P,invertUV:J,frontUVs:e.frontUVs,backUVs:e.backUVs},n)},r}();ft.a.CreateTiledPlane=function(r){var t=r.pattern||De.a.NO_FLIP,e=r.tileWidth||r.tileSize||1,n=r.tileHeight||r.tileSize||1,i=r.alignHorizontal||0,o=r.alignVertical||0,a=r.width||r.size||1,s=Math.floor(a/e),d=a-s*e,p=r.height||r.size||1,y=Math.floor(p/n),P=p-y*n,O=e*s/2,U=n*y/2,F=0,z=0,J=0,ie=0,se=0,ce=0;if(d>0||P>0){switch(J=-O,ie=-U,se=O,ce=U,i){case De.a.CENTER:J-=d/=2,se+=d;break;case De.a.LEFT:se+=d,F=-d/2;break;case De.a.RIGHT:J-=d,F=d/2}switch(o){case De.a.CENTER:ie-=P/=2,ce+=P;break;case De.a.BOTTOM:ce+=P,z=-P/2;break;case De.a.TOP:ie-=P,z=P/2}}var ue=[],fe=[],ve=[];ve[0]=[0,0,1,0,1,1,0,1],ve[1]=[0,0,1,0,1,1,0,1],t!==De.a.ROTATE_TILE&&t!==De.a.ROTATE_ROW||(ve[1]=[1,1,0,1,0,0,1,0]),t!==De.a.FLIP_TILE&&t!==De.a.FLIP_ROW||(ve[1]=[1,0,0,0,0,1,1,1]),t!==De.a.FLIP_N_ROTATE_TILE&&t!==De.a.FLIP_N_ROTATE_ROW||(ve[1]=[0,1,1,1,1,0,0,0]);for(var Te=[],Oe=[],Pe=[],Ee=0,Se=0;Se<y;Se++)for(var Le=0;Le<s;Le++)ue.push(Le*e-O+F,Se*n-U+z,0),ue.push((Le+1)*e-O+F,Se*n-U+z,0),ue.push((Le+1)*e-O+F,(Se+1)*n-U+z,0),ue.push(Le*e-O+F,(Se+1)*n-U+z,0),Pe.push(Ee,Ee+1,Ee+3,Ee+1,Ee+2,Ee+3),Te=t===De.a.FLIP_TILE||t===De.a.ROTATE_TILE||t===De.a.FLIP_N_ROTATE_TILE?Te.concat(ve[(Le%2+Se%2)%2]):t===De.a.FLIP_ROW||t===De.a.ROTATE_ROW||t===De.a.FLIP_N_ROTATE_ROW?Te.concat(ve[Se%2]):Te.concat(ve[0]),Oe.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),fe.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1),Ee+=4;if(d>0||P>0){var xe,Ne,Ie,Fe,Ke=P>0&&(o===De.a.CENTER||o===De.a.TOP),nt=P>0&&(o===De.a.CENTER||o===De.a.BOTTOM),rt=d>0&&(i===De.a.CENTER||i===De.a.RIGHT),ut=d>0&&(i===De.a.CENTER||i===De.a.LEFT),qe=[];if(Ke&&rt&&(ue.push(J+F,ie+z,0),ue.push(-O+F,ie+z,0),ue.push(-O+F,ie+P+z,0),ue.push(J+F,ie+P+z,0),Pe.push(Ee,Ee+1,Ee+3,Ee+1,Ee+2,Ee+3),Ee+=4,qe=[xe=1-d/e,Ne=1-P/n,Ie=1,Ne,Ie,Fe=1,xe,Fe],t===De.a.ROTATE_ROW&&(qe=[1-xe,1-Ne,1-Ie,1-Ne,1-Ie,1-Fe,1-xe,1-Fe]),t===De.a.FLIP_ROW&&(qe=[1-xe,Ne,1-Ie,Ne,1-Ie,Fe,1-xe,Fe]),t===De.a.FLIP_N_ROTATE_ROW&&(qe=[xe,1-Ne,Ie,1-Ne,Ie,1-Fe,xe,1-Fe]),Te=Te.concat(qe),Oe.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),fe.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),Ke&&ut&&(ue.push(O+F,ie+z,0),ue.push(se+F,ie+z,0),ue.push(se+F,ie+P+z,0),ue.push(O+F,ie+P+z,0),Pe.push(Ee,Ee+1,Ee+3,Ee+1,Ee+2,Ee+3),Ee+=4,qe=[xe=0,Ne=1-P/n,Ie=d/e,Ne,Ie,Fe=1,xe,Fe],(t===De.a.ROTATE_ROW||t===De.a.ROTATE_TILE&&s%2==0)&&(qe=[1-xe,1-Ne,1-Ie,1-Ne,1-Ie,1-Fe,1-xe,1-Fe]),(t===De.a.FLIP_ROW||t===De.a.FLIP_TILE&&s%2==0)&&(qe=[1-xe,Ne,1-Ie,Ne,1-Ie,Fe,1-xe,Fe]),(t===De.a.FLIP_N_ROTATE_ROW||t===De.a.FLIP_N_ROTATE_TILE&&s%2==0)&&(qe=[xe,1-Ne,Ie,1-Ne,Ie,1-Fe,xe,1-Fe]),Te=Te.concat(qe),Oe.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),fe.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),nt&&rt&&(ue.push(J+F,U+z,0),ue.push(-O+F,U+z,0),ue.push(-O+F,ce+z,0),ue.push(J+F,ce+z,0),Pe.push(Ee,Ee+1,Ee+3,Ee+1,Ee+2,Ee+3),Ee+=4,qe=[xe=1-d/e,Ne=0,Ie=1,Ne,Ie,Fe=P/n,xe,Fe],(t===De.a.ROTATE_ROW&&y%2==1||t===De.a.ROTATE_TILE&&y%1==0)&&(qe=[1-xe,1-Ne,1-Ie,1-Ne,1-Ie,1-Fe,1-xe,1-Fe]),(t===De.a.FLIP_ROW&&y%2==1||t===De.a.FLIP_TILE&&y%2==0)&&(qe=[1-xe,Ne,1-Ie,Ne,1-Ie,Fe,1-xe,Fe]),(t===De.a.FLIP_N_ROTATE_ROW&&y%2==1||t===De.a.FLIP_N_ROTATE_TILE&&y%2==0)&&(qe=[xe,1-Ne,Ie,1-Ne,Ie,1-Fe,xe,1-Fe]),Te=Te.concat(qe),Oe.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),fe.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),nt&&ut&&(ue.push(O+F,U+z,0),ue.push(se+F,U+z,0),ue.push(se+F,ce+z,0),ue.push(O+F,ce+z,0),Pe.push(Ee,Ee+1,Ee+3,Ee+1,Ee+2,Ee+3),Ee+=4,qe=[xe=0,Ne=0,Ie=d/e,Ne,Ie,Fe=P/n,xe,Fe],(t===De.a.ROTATE_ROW&&y%2==1||t===De.a.ROTATE_TILE&&(y+s)%2==1)&&(qe=[1-xe,1-Ne,1-Ie,1-Ne,1-Ie,1-Fe,1-xe,1-Fe]),(t===De.a.FLIP_ROW&&y%2==1||t===De.a.FLIP_TILE&&(y+s)%2==1)&&(qe=[1-xe,Ne,1-Ie,Ne,1-Ie,Fe,1-xe,Fe]),(t===De.a.FLIP_N_ROTATE_ROW&&y%2==1||t===De.a.FLIP_N_ROTATE_TILE&&(y+s)%2==1)&&(qe=[xe,1-Ne,Ie,1-Ne,Ie,1-Fe,xe,1-Fe]),Te=Te.concat(qe),Oe.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),fe.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),Ke){var at=[];for(xe=0,Ne=1-P/n,Ie=1,Fe=1,at[0]=[xe,Ne,Ie,Ne,Ie,Fe,xe,Fe],at[1]=[xe,Ne,Ie,Ne,Ie,Fe,xe,Fe],t!==De.a.ROTATE_TILE&&t!==De.a.ROTATE_ROW||(at[1]=[1-xe,1-Ne,1-Ie,1-Ne,1-Ie,1-Fe,1-xe,1-Fe]),t!==De.a.FLIP_TILE&&t!==De.a.FLIP_ROW||(at[1]=[1-xe,Ne,1-Ie,Ne,1-Ie,Fe,1-xe,Fe]),t!==De.a.FLIP_N_ROTATE_TILE&&t!==De.a.FLIP_N_ROTATE_ROW||(at[1]=[xe,1-Ne,Ie,1-Ne,Ie,1-Fe,xe,1-Fe]),Le=0;Le<s;Le++)ue.push(Le*e-O+F,ie+z,0),ue.push((Le+1)*e-O+F,ie+z,0),ue.push((Le+1)*e-O+F,ie+P+z,0),ue.push(Le*e-O+F,ie+P+z,0),Pe.push(Ee,Ee+1,Ee+3,Ee+1,Ee+2,Ee+3),Ee+=4,Te=t===De.a.FLIP_TILE||t===De.a.ROTATE_TILE||t===De.a.FLIP_N_ROTATE_TILE?Te.concat(at[(Le+1)%2]):t===De.a.FLIP_ROW||t===De.a.ROTATE_ROW||t===De.a.FLIP_N_ROTATE_ROW?Te.concat(at[1]):Te.concat(at[0]),Oe.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),fe.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)}if(nt){var ot=[];for(xe=0,Ne=0,Ie=1,Fe=P/n,ot[0]=[xe,Ne,Ie,Ne,Ie,Fe,xe,Fe],ot[1]=[xe,Ne,Ie,Ne,Ie,Fe,xe,Fe],t!==De.a.ROTATE_TILE&&t!==De.a.ROTATE_ROW||(ot[1]=[1-xe,1-Ne,1-Ie,1-Ne,1-Ie,1-Fe,1-xe,1-Fe]),t!==De.a.FLIP_TILE&&t!==De.a.FLIP_ROW||(ot[1]=[1-xe,Ne,1-Ie,Ne,1-Ie,Fe,1-xe,Fe]),t!==De.a.FLIP_N_ROTATE_TILE&&t!==De.a.FLIP_N_ROTATE_ROW||(ot[1]=[xe,1-Ne,Ie,1-Ne,Ie,1-Fe,xe,1-Fe]),Le=0;Le<s;
8488Le++)ue.push(Le*e-O+F,ce-P+z,0),ue.push((Le+1)*e-O+F,ce-P+z,0),ue.push((Le+1)*e-O+F,ce+z,0),ue.push(Le*e-O+F,ce+z,0),Pe.push(Ee,Ee+1,Ee+3,Ee+1,Ee+2,Ee+3),Ee+=4,Te=t===De.a.FLIP_TILE||t===De.a.ROTATE_TILE||t===De.a.FLIP_N_ROTATE_TILE?Te.concat(ot[(Le+y)%2]):t===De.a.FLIP_ROW||t===De.a.ROTATE_ROW||t===De.a.FLIP_N_ROTATE_ROW?Te.concat(ot[y%2]):Te.concat(ot[0]),Oe.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),fe.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)}if(rt){var Je=[];for(xe=1-d/e,Ne=0,Ie=1,Fe=1,Je[0]=[xe,Ne,Ie,Ne,Ie,Fe,xe,Fe],Je[1]=[xe,Ne,Ie,Ne,Ie,Fe,xe,Fe],t!==De.a.ROTATE_TILE&&t!==De.a.ROTATE_ROW||(Je[1]=[1-xe,1-Ne,1-Ie,1-Ne,1-Ie,1-Fe,1-xe,1-Fe]),t!==De.a.FLIP_TILE&&t!==De.a.FLIP_ROW||(Je[1]=[1-xe,Ne,1-Ie,Ne,1-Ie,Fe,1-xe,Fe]),t!==De.a.FLIP_N_ROTATE_TILE&&t!==De.a.FLIP_N_ROTATE_ROW||(Je[1]=[xe,1-Ne,Ie,1-Ne,Ie,1-Fe,xe,1-Fe]),Se=0;Se<y;Se++)ue.push(J+F,Se*n-U+z,0),ue.push(J+d+F,Se*n-U+z,0),ue.push(J+d+F,(Se+1)*n-U+z,0),ue.push(J+F,(Se+1)*n-U+z,0),Pe.push(Ee,Ee+1,Ee+3,Ee+1,Ee+2,Ee+3),Ee+=4,Te=t===De.a.FLIP_TILE||t===De.a.ROTATE_TILE||t===De.a.FLIP_N_ROTATE_TILE?Te.concat(Je[(Se+1)%2]):t===De.a.FLIP_ROW||t===De.a.ROTATE_ROW||t===De.a.FLIP_N_ROTATE_ROW?Te.concat(Je[Se%2]):Te.concat(Je[0]),Oe.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),fe.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)}if(ut){var dt=[];for(xe=0,Ne=0,Ie=d/n,Fe=1,dt[0]=[xe,Ne,Ie,Ne,Ie,Fe,xe,Fe],dt[1]=[xe,Ne,Ie,Ne,Ie,Fe,xe,Fe],t!==De.a.ROTATE_TILE&&t!==De.a.ROTATE_ROW||(dt[1]=[1-xe,1-Ne,1-Ie,1-Ne,1-Ie,1-Fe,1-xe,1-Fe]),t!==De.a.FLIP_TILE&&t!==De.a.FLIP_ROW||(dt[1]=[1-xe,Ne,1-Ie,Ne,1-Ie,Fe,1-xe,Fe]),t!==De.a.FLIP_N_ROTATE_TILE&&t!==De.a.FLIP_N_ROTATE_ROW||(dt[1]=[xe,1-Ne,Ie,1-Ne,Ie,1-Fe,xe,1-Fe]),Se=0;Se<y;Se++)ue.push(se-d+F,Se*n-U+z,0),ue.push(se+F,Se*n-U+z,0),ue.push(se+F,(Se+1)*n-U+z,0),ue.push(se-d+F,(Se+1)*n-U+z,0),Pe.push(Ee,Ee+1,Ee+3,Ee+1,Ee+2,Ee+3),Ee+=4,Te=t===De.a.FLIP_TILE||t===De.a.ROTATE_TILE||t===De.a.FLIP_N_ROTATE_TILE?Te.concat(dt[(Se+s)%2]):t===De.a.FLIP_ROW||t===De.a.ROTATE_ROW||t===De.a.FLIP_N_ROTATE_ROW?Te.concat(dt[Se%2]):Te.concat(dt[0]),Oe.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),fe.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)}}var Ve=r.sideOrientation===0?0:r.sideOrientation||ft.a.DEFAULTSIDE;ft.a._ComputeSides(Ve,ue,Pe,fe,Te,r.frontUVs,r.backUVs);var $e=new ft.a;$e.indices=Pe,$e.positions=ue,$e.normals=fe,$e.uvs=Te;var yt=Ve===ft.a.DOUBLESIDE?Oe.concat(Oe):Oe;return $e.colors=yt,$e};var Cd=function(){function r(){}return r.CreateTiledPlane=function(t,e,n){n===void 0&&(n=null);var i=new De.a(t,n);return e.sideOrientation=De.a._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,ft.a.CreateTiledPlane(e).applyToMesh(i,e.updatable),i},r}();De.a.CreateTube=function(r,t,e,n,i,o,a,s,d,p){var y={path:t,radius:e,tessellation:n,radiusFunction:i,arc:1,cap:o,updatable:s,sideOrientation:d,instance:p};return Oc.CreateTube(r,y,a)};var Oc=function(){function r(){}return r.CreateTube=function(t,e,n){n===void 0&&(n=null);var i=e.path,o=e.instance,a=1;e.radius!==void 0?a=e.radius:o&&(a=o._creationDataStorage.radius);var s=e.tessellation||64,d=e.radiusFunction||null,p=e.cap||De.a.NO_CAP,y=e.invertUV||!1,P=e.updatable,O=De.a._GetDefaultSideOrientation(e.sideOrientation);e.arc=e.arc&&(e.arc<=0||e.arc>1)?1:e.arc||1;var U,F,z=function(ce,ue,fe,ve,Te,Oe,Pe,Ee){for(var Se,Le,xe,Ne,Ie=ue.getTangents(),Fe=ue.getNormals(),Ke=ue.getDistances(),nt=2*Math.PI/Te*Ee,rt=Oe||function(){return ve},ut=u.c.Matrix[0],qe=Pe===De.a.NO_CAP||Pe===De.a.CAP_END?0:2,at=0;at<ce.length;at++){Le=rt(at,Ke[at]),Se=Array(),xe=Fe[at];for(var ot=0;ot<Te;ot++)u.a.RotationAxisToRef(Ie[at],nt*ot,ut),Ne=Se[ot]?Se[ot]:u.e.Zero(),u.e.TransformCoordinatesToRef(xe,ut,Ne),Ne.scaleInPlace(Le).addInPlace(ce[at]),Se[ot]=Ne;fe[qe]=Se,qe++}var Je=function(dt,Ve){for(var $e=Array(),yt=0;yt<dt;yt++)$e.push(ce[Ve]);return $e};switch(Pe){case De.a.NO_CAP:break;case De.a.CAP_START:fe[0]=Je(Te,0),fe[1]=fe[2].slice(0);break;case De.a.CAP_END:fe[qe]=fe[qe-1].slice(0),fe[qe+1]=Je(Te,ce.length-1);break;case De.a.CAP_ALL:fe[0]=Je(Te,0),fe[1]=fe[2].slice(0),fe[qe]=fe[qe-1].slice(0),fe[qe+1]=Je(Te,ce.length-1)}return fe};if(o){var J=o._creationDataStorage,ie=e.arc||J.arc;return F=z(i,U=J.path3D.update(i),J.pathArray,a,J.tessellation,d,J.cap,ie),o=So.a.CreateRibbon("",{pathArray:F,instance:o}),J.path3D=U,J.pathArray=F,J.arc=ie,J.radius=a,o}F=z(i,U=new Ze.g(i),new Array,a,s,d,p=p<0||p>3?0:p,e.arc);var se=So.a.CreateRibbon(t,{pathArray:F,closePath:!0,closeArray:!1,updatable:P,sideOrientation:O,invertUV:y,frontUVs:e.frontUVs,backUVs:e.backUVs},n);return se._creationDataStorage.pathArray=F,se._creationDataStorage.path3D=U,se._creationDataStorage.tessellation=s,se._creationDataStorage.cap=p,se._creationDataStorage.arc=e.arc,se._creationDataStorage.radius=a,se},r}();ft.a.CreateIcoSphere=function(r){var t,e=r.sideOrientation||ft.a.DEFAULTSIDE,n=r.radius||1,i=r.flat===void 0||r.flat,o=r.subdivisions||4,a=r.radiusX||n,s=r.radiusY||n,d=r.radiusZ||n,p=(1+Math.sqrt(5))/2,y=[-1,p,-0,1,p,0,-1,-p,0,1,-p,0,0,-1,-p,0,1,-p,0,-1,p,0,1,p,p,0,1,p,0,-1,-p,0,1,-p,0,-1
8488],P=[0,11,5,0,5,1,0,1,7,0,7,10,12,22,23,1,5,20,5,11,4,23,22,13,22,18,6,7,1,8,14,21,4,14,4,2,16,13,6,15,6,19,3,8,9,4,21,5,13,17,23,6,13,22,19,6,18,9,8,1],O=[0,1,2,3,4,5,6,7,8,9,10,11,0,2,3,3,3,4,7,8,9,9,10,11],U=[5,1,3,1,6,4,0,0,5,3,4,2,2,2,4,0,2,0,1,1,6,0,6,2,0,4,3,3,4,4,3,1,4,2,4,4,0,2,1,1,2,2,3,3,1,3,2,4],F=[0,0,0,0,1,0,0,1,1,0,0,0,1,1,0,0,1,1,1,0],z=new Array,J=new Array,ie=new Array,se=new Array,ce=0,ue=new Array(3),fe=new Array(3);for(t=0;t<3;t++)ue[t]=u.e.Zero(),fe[t]=u.d.Zero();for(var ve=0;ve<20;ve++){for(t=0;t<3;t++){var Te=P[3*ve+t];ue[t].copyFromFloats(y[3*O[Te]],y[3*O[Te]+1],y[3*O[Te]+2]),ue[t].normalize().scaleInPlace(n),fe[t].copyFromFloats(U[2*Te]*(138/1024)+60/1024+F[ve]*(-40/1024),U[2*Te+1]*(239/1024)+26/1024+F[ve]*(20/1024))}for(var Oe=function(Le,xe,Ne,Ie){var Fe,Ke=u.e.Lerp(ue[0],ue[2],xe/o),nt=u.e.Lerp(ue[1],ue[2],xe/o),rt=o===xe?ue[2]:u.e.Lerp(Ke,nt,Le/(o-xe));if(rt.normalize(),i){var ut=u.e.Lerp(ue[0],ue[2],Ie/o),qe=u.e.Lerp(ue[1],ue[2],Ie/o);Fe=u.e.Lerp(ut,qe,Ne/(o-Ie))}else Fe=new u.e(rt.x,rt.y,rt.z);Fe.x/=a,Fe.y/=s,Fe.z/=d,Fe.normalize();var at=u.d.Lerp(fe[0],fe[2],xe/o),ot=u.d.Lerp(fe[1],fe[2],xe/o),Je=o===xe?fe[2]:u.d.Lerp(at,ot,Le/(o-xe));J.push(rt.x*a,rt.y*s,rt.z*d),ie.push(Fe.x,Fe.y,Fe.z),se.push(Je.x,Je.y),z.push(ce),ce++},Pe=0;Pe<o;Pe++)for(var Ee=0;Ee+Pe<o;Ee++)Oe(Ee,Pe,Ee+1/3,Pe+1/3),Oe(Ee+1,Pe,Ee+1/3,Pe+1/3),Oe(Ee,Pe+1,Ee+1/3,Pe+1/3),Ee+Pe+1<o&&(Oe(Ee+1,Pe,Ee+2/3,Pe+2/3),Oe(Ee+1,Pe+1,Ee+2/3,Pe+2/3),Oe(Ee,Pe+1,Ee+2/3,Pe+2/3))}ft.a._ComputeSides(e,J,z,ie,se,r.frontUVs,r.backUVs);var Se=new ft.a;return Se.indices=z,Se.positions=J,Se.normals=ie,Se.uvs=se,Se},De.a.CreateIcoSphere=function(r,t,e){return Mc.CreateIcoSphere(r,t,e)};var Mc=function(){function r(){}return r.CreateIcoSphere=function(t,e,n){n===void 0&&(n=null);var i=new De.a(t,n);return e.sideOrientation=De.a._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,ft.a.CreateIcoSphere(e).applyToMesh(i,e.updatable),i},r}();De.a.CreateDecal=function(r,t,e,n,i,o){var a={position:e,normal:n,size:i,angle:o};return Ic.CreateDecal(r,t,a)};var Ic=function(){function r(){}return r.CreateDecal=function(t,e,n){var i=e.getIndices(),o=e.getVerticesData(Me.b.PositionKind),a=e.getVerticesData(Me.b.NormalKind),s=n.position||u.e.Zero(),d=n.normal||u.e.Up(),p=n.size||u.e.One(),y=n.angle||0;if(!d){var P=new u.e(0,0,1),O=e.getScene().activeCamera,U=u.e.TransformCoordinates(P,O.getWorldMatrix());d=O.globalPosition.subtract(U)}var F=-Math.atan2(d.z,d.x)-Math.PI/2,z=Math.sqrt(d.x*d.x+d.z*d.z),J=Math.atan2(d.y,z),ie=u.a.RotationYawPitchRoll(F,J,y).multiply(u.a.Translation(s.x,s.y,s.z)),se=u.a.Invert(ie),ce=e.getWorldMatrix().multiply(se),ue=new ft.a;ue.indices=[],ue.positions=[],ue.normals=[],ue.uvs=[];for(var fe=0,ve=function(xe){var Ne=new Fs;if(!i||!o||!a)return Ne;var Ie=i[xe];return Ne.position=new u.e(o[3*Ie],o[3*Ie+1],o[3*Ie+2]),Ne.position=u.e.TransformCoordinates(Ne.position,ce),Ne.normal=new u.e(a[3*Ie],a[3*Ie+1],a[3*Ie+2]),Ne.normal=u.e.TransformNormal(Ne.normal,ce),Ne},Te=function(xe,Ne){if(xe.length===0)return xe;for(var Ie=.5*Math.abs(u.e.Dot(p,Ne)),Fe=function(Ve,$e){var yt=u.e.GetClipFactor(Ve.position,$e.position,Ne,Ie);return new Fs(u.e.Lerp(Ve.position,$e.position,yt),u.e.Lerp(Ve.normal,$e.normal,yt))},Ke=new Array,nt=0;nt<xe.length;nt+=3){var rt,ut,qe,at=null,ot=null,Je=null,dt=null;switch(((rt=u.e.Dot(xe[nt].position,Ne)-Ie>0)?1:0)+((ut=u.e.Dot(xe[nt+1].position,Ne)-Ie>0)?1:0)+((qe=u.e.Dot(xe[nt+2].position,Ne)-Ie>
84880)?1:0)){case 0:Ke.push(xe[nt]),Ke.push(xe[nt+1]),Ke.push(xe[nt+2]);break;case 1:if(rt&&(at=xe[nt+1],ot=xe[nt+2],Je=Fe(xe[nt],at),dt=Fe(xe[nt],ot)),ut){at=xe[nt],ot=xe[nt+2],Je=Fe(xe[nt+1],at),dt=Fe(xe[nt+1],ot),Ke.push(Je),Ke.push(ot.clone()),Ke.push(at.clone()),Ke.push(ot.clone()),Ke.push(Je.clone()),Ke.push(dt);break}qe&&(at=xe[nt],ot=xe[nt+1],Je=Fe(xe[nt+2],at),dt=Fe(xe[nt+2],ot)),at&&ot&&Je&&dt&&(Ke.push(at.clone()),Ke.push(ot.clone()),Ke.push(Je),Ke.push(dt),Ke.push(Je.clone()),Ke.push(ot.clone()));break;case 2:rt||(ot=Fe(at=xe[nt].clone(),xe[nt+1]),Je=Fe(at,xe[nt+2]),Ke.push(at),Ke.push(ot),Ke.push(Je)),ut||(ot=Fe(at=xe[nt+1].clone(),xe[nt+2]),Je=Fe(at,xe[nt]),Ke.push(at),Ke.push(ot),Ke.push(Je)),qe||(ot=Fe(at=xe[nt+2].clone(),xe[nt]),Je=Fe(at,xe[nt+1]),Ke.push(at),Ke.push(ot),Ke.push(Je))}}return Ke},Oe=0;Oe<i.length;Oe+=3){var Pe=new Array;if(Pe.push(ve(Oe)),Pe.push(ve(Oe+1)),Pe.push(ve(Oe+2)),Pe=Te(Pe,new u.e(1,0,0)),Pe=Te(Pe,new u.e(-1,0,0)),Pe=Te(Pe,new u.e(0,1,0)),Pe=Te(Pe,new u.e(0,-1,0)),Pe=Te(Pe,new u.e(0,0,1)),(Pe=Te(Pe,new u.e(0,0,-1))).length!==0)for(var Ee=0;Ee<Pe.length;Ee++){var Se=Pe[Ee];ue.indices.push(fe),Se.position.toArray(ue.positions,3*fe),Se.normal.toArray(ue.normals,3*fe),ue.uvs.push(.5+Se.position.x/p.x),ue.uvs.push(.5+Se.position.y/p.y),fe++}}var Le=new De.a(t,e.getScene());return ue.applyToMesh(Le),Le.position=s.clone(),Le.rotation=new u.e(J,F,y),Le},r}();ft.a.CreateCapsule=function(r){r===void 0&&(r={subdivisions:2,tessellation:16,height:1,radius:.25,capSubdivisions:6});var t,e,n=Math.max(r.subdivisions?r.subdivisions:2,1),i=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=Math.max(r.capSubdivisions?r.capSubdivisions:6,1),d=i,p=n,y=Math.max(r.radiusTop?r.radiusTop:a,0),P=Math.max(r.radiusBottom?r.radiusBottom:a,0),O=o-(y+P),U=2*Math.PI,F=Math.max(r.topCapSubdivisions?r.topCapSubdivisions:s,1),z=Math.max(r.bottomCapSubdivisions?r.bottomCapSubdivisions:s,1),J=Math.acos((P-y)/o),ie=[],se=[],ce=[],ue=[],fe=0,ve=[],Te=.5*O,Oe=.5*Math.PI,Pe=u.e.Zero(),Ee=u.e.Zero(),Se=Math.cos(J),Le=Math.sin(J),xe=new u.d(y*Le,Te+y*Se).subtract(new u.d(P*Le,P*Se-Te)).length(),Ne=y*J+xe+P*(Oe-J),Ie=0;for(e=0;e<=F;e++){var Fe=[],Ke=Oe-J*(e/F);Ie+=y*J/F;var nt=Math.cos(Ke),rt=Math.sin(Ke),ut=nt*y;for(t=0;t<=d;t++){var qe=(Ve=t/d)*U+0,at=Math.sin(qe),ot=Math.cos(qe);Ee.x=ut*at,Ee.y=Te+rt*y,Ee.z=ut*ot,se.push(Ee.x,Ee.y,Ee.z),Pe.set(nt*at,rt,nt*ot),ce.push(Pe.x,Pe.y,Pe.z),ue.push(Ve,1-Ie/Ne),Fe.push(fe),fe++}ve.push(Fe)}var Je=o-y-P+Se*y-Se*P,dt=Le*(P-y)/Je;for(e=1;e<=p;e++){for(Fe=[],Ie+=xe/p,ut=Le*(e*(P-y)/p+y),t=0;t<=d;t++)qe=(Ve=t/d)*U+0,at=Math.sin(qe),ot=Math.cos(qe),Ee.x=ut*at,Ee.y=Te+Se*y-e*Je/p,Ee.z=ut*ot,se.push(Ee.x,Ee.y,Ee.z),Pe.set(at,dt,ot).normalize(),ce.push(Pe.x,Pe.y,Pe.z),ue.push(Ve,1-Ie/Ne),Fe.push(fe),fe++;ve.push(Fe)}for(e=1;e<=z;e++){for(Fe=[],Ke=Oe-J-(Math.PI-J)*(e/z),Ie+=P*J/z,nt=Math.cos(Ke),rt=Math.sin(Ke),ut=nt*P,t=0;t<=d;t++){var Ve;qe=(Ve=t/d)*U+0,at=Math.sin(qe),ot=Math.cos(qe),Ee.x=ut*at,Ee.y=rt*P-Te,Ee.z=ut*ot,se.push(Ee.x,Ee.y,Ee.z),Pe.set(nt*at,rt,nt*ot),ce.push(Pe.x,Pe.y,Pe.z),ue.push(Ve,1-Ie/Ne),Fe.push(fe),fe++}ve.push(Fe)}for(t=0;t<d;t++)for(e=0;e<F+p+z;e++){var $e=ve[e][t],yt=ve[e+1][t],Wt=ve[e+1][t+1],Nt=ve[e][t+1];ie.push($e),ie.push(yt),ie.push(Nt),ie.push(yt),ie.push(Wt),ie.push(Nt)}if(ie=ie.reverse(),r.orientation&&!r.orientation.equals(u.e.Up())){var Qt=new u.a;r.orientation.clone().scale(.5*Math.PI).cross(u.e.Up()).toQuaternion().toRotationMatrix(Qt);for(var vt=u.e.Zero(),Jt=0;Jt<se.length;Jt+=3)vt.set(se[Jt],se[Jt+1],se[Jt+2]),u.e.TransformCoordinatesToRef(vt.clone(),Qt,vt),se[Jt]=vt.x,se[Jt+1]=vt.y,se[Jt+2]=vt.z}var Xt=new ft.a;return Xt.positions=se,Xt.normals=ce,Xt.uvs=ue,Xt.indices=ie,Xt},De.a.CreateCapsule=function(r,t,e){return Dc.CreateCapsule(r,t,e)};var Po,Dc=function(){function r(){}return r.CreateCapsule=function(t,e,n){e===void 0&&(e={orientation:u.e.Up(),subdivisions:2,tessellation:16,height:1,radius:.25,capSubdivisions:6});var i=new De.a(t,n);return ft.a.CreateCapsule(e).applyToMesh(i),i},r}(),Ym=function(){function r(){}return r.CreateBox=function(t,e,n){return n===void 0&&(n=null),yr.a.CreateBox(t,e,n)},r.CreateTiledBox=function(t,e,n){return n===void 0&&(n=null),Ad.CreateTiledBox(t,e,n)},r.CreateSphere=function(t,e,n){return n===void 0&&(n=null),Nn.a.CreateSphere(t,e,n)},r.CreateDisc=function(t,e,n){return n===void 0&&(n=null),Aa.CreateDisc(t,e,n)},r.CreateIcoSphere=function(t,e,n){return n===void 0&&(n=null),Mc.CreateIcoSphere(t,e,n)},r.CreateRibbon=function(t,e,n){return n===void 0&&(n=null),So.a.CreateRibbon(t,e,n)},r.CreateCylinder=function(t,e,n){return n===void 0&&(n=null),ui.a.CreateCylinder(t,e,n)},r.CreateTorus=function(t,e,n){return n===void 0&&(n=null),mr.CreateTorus(t,e,n)},r.CreateTorusKnot=function(t,e,n){return n===void 0&&(n=null),Cc.CreateTorusKnot(t,e,n)},r.CreateLineSystem=function(t,e,n){return cn.a.CreateLineSystem(t,e,n)},r.CreateLines=function(t,e,n){return n===void 0&&(n=null),cn.a.CreateLines(t,e,n)},r.CreateDashedLines=function(t,e,n){return n===void 0&&(n=null),cn.a.CreateDashedLines(t,e,n)},r.ExtrudeShape=function(t,e,n){return n===void 0&&(n=null),ha.a.ExtrudeShape(t,e,n)},r.ExtrudeShapeCustom=function(t,e,n){return n===void 0&&(n=null),ha.a.ExtrudeShapeCustom(t,e,n)},r.CreateLathe=function(t,e,n){return n===void 0&&(n=null),Rc.CreateLathe(t,e,n)},r.CreateTiledPlane=function(t,e,n){return n===void 0&&(n=null),Cd.CreateTiledPlane(t,e,n)},r.CreatePlane=function(t,e,n){return n===void 0&&(n=null),Ls.a.CreatePlane(t,e,n)},r.CreateGround=function(t,e,n){return n===void 0&&(n=null),wi.CreateGround(t,e,n)},r.CreateTiledGround=function(t,e,n){return n===void 0&&(n=null),wi.CreateTiledGround(t,e,n)},r.CreateGroundFromHeightMap=function(t,e,n,i){return i===void 0&&(i=null),wi.CreateGroundFromHeightMap(t,e,n,i)},r.CreatePolygon=function(t,e,n,i){return n===void 0&&(n=null),i===void 0&&(i=earcut),Ao.CreatePolygon(t,e,n,i)},r.ExtrudePolygon=function(t,e,n,i){return n===void 0&&(n=null),i===void 0&&(i=earcut),Ao.ExtrudePolygon(t,e,n,i)},r.CreateTube=function(t,e,n){return n===void 0&&(n=null),Oc.CreateTube(t,e,n)},r.CreatePolyhedron=function(t,e,n){return n===void 0&&(n=null),oo.CreatePolyhedron(t,e,n)},r.CreateDecal=function(t,e,n){return Ic.CreateDecal(t,e,n)},r.CreateCapsule=function(t,e,n){return e===void 0&&(e={orientation:u.e.Up(),subdivisions:2,tessellation:16,height:1,radius:.25,capSubdivisions:6}),n===void 0&&(n=null),Dc.CreateCapsule(t,e,n)},r}
8488(),Km=function(r,t,e){this.quality=r,this.distance=t,this.optimizeMesh=e},xd=function(){function r(){this.running=!1,this._simplificationArray=[]}return r.prototype.addTask=function(t){this._simplificationArray.push(t)},r.prototype.executeNext=function(){var t=this._simplificationArray.pop();t?(this.running=!0,this.runSimplification(t)):this.running=!1},r.prototype.runSimplification=function(t){var e=this;if(t.parallelProcessing)t.settings.forEach(function(i){e.getSimplifier(t).simplify(i,function(o){i.distance!==void 0&&t.mesh.addLODLevel(i.distance,o),o.isVisible=!0,i.quality===t.settings[t.settings.length-1].quality&&t.successCallback&&t.successCallback(),e.executeNext()})});else{var n=this.getSimplifier(t);Ye.a.Run(t.settings.length,function(i){var o,a;o=t.settings[i.index],a=function(){i.executeNext()},n.simplify(o,function(s){o.distance!==void 0&&t.mesh.addLODLevel(o.distance,s),s.isVisible=!0,a()})},function(){t.successCallback&&t.successCallback(),e.executeNext()})}},r.prototype.getSimplifier=function(t){switch(t.simplificationType){case Po.QUADRATIC:default:return new Od(t.mesh)}},r}();(function(r){r[r.QUADRATIC=0]="QUADRATIC"})(Po||(Po={}));var Qm=function(r){this.vertices=r,this.error=new Array(4),this.deleted=!1,this.isDirty=!1,this.deletePending=!1,this.borderFactor=0},qm=function(){function r(t,e){this.position=t,this.id=e,this.isBorder=!0,this.q=new Rd,this.triangleCount=0,this.triangleStart=0,this.originalOffsets=[]}return r.prototype.updatePosition=function(t){this.position.copyFrom(t)},r}(),Rd=function(){function r(t){this.data=new Array(10);for(var e=0;e<10;++e)t&&t[e]?this.data[e]=t[e]:this.data[e]=0}return r.prototype.det=function(t,e,n,i,o,a,s,d,p){return this.data[t]*this.data[o]*this.data[p]+this.data[n]*this.data[i]*this.data[d]+this.data[e]*this.data[a]*this.data[s]-this.data[n]*this.data[o]*this.data[s]-this.data[t]*this.data[a]*this.data[d]-this.data[e]*this.data[i]*this.data[p]},r.prototype.addInPlace=function(t){for(var e=0;e<10;++e)this.data[e]+=t.data[e]},r.prototype.addArrayInPlace=function(t){for(var e=0;e<10;++e)this.data[e]+=t[e]},r.prototype.add=function(t){for(var e=new r,n=0;n<10;++n)e.data[n]=this.data[n]+t.data[n];return e},r.FromData=function(t,e,n,i){return new r(r.DataFromNumbers(t,e,n,i))},r.DataFromNumbers=function(t,e,n,i){return[t*t,t*e,t*n,t*i,e*e,e*n,e*i,n*n,n*i,i*i]},r}(),Zm=function(r,t){this.vertexId=r,this.triangleId=t},Od=function(){function r(t){this._mesh=t,this.syncIterations=5e3,this.aggressiveness=7,this.decimationIterations=100,this.boundingBoxEpsilon=Gt.a}return r.prototype.simplify=function(t,e){var n=this;this.initDecimatedMesh(),Ye.a.Run(this._mesh.subMeshes.length,function(i){n.initWithMesh(i.index,function(){n.runDecimation(t,i.index,function(){i.executeNext()})},t.optimizeMesh)},function(){setTimeout(function(){e(n._reconstructedMesh)},0)})},r.prototype.runDecimation=function(t,e,n){var i=this,o=~~(this.triangles.length*t.quality),a=0,s=this.triangles.length;Ye.a.Run(this.decimationIterations,function(d){var p,y;s-a<=o?d.breakLoop():(p=d.index,y=function(){d.executeNext()},setTimeout(function(){p%5==0&&i.updateMesh(p===0);for(var P=0;P<i.triangles.length;++P)i.triangles[P].isDirty=!1;var O=1e-9*Math.pow(p+3,i.aggressiveness);Ye.a.SyncAsyncForLoop(i.triangles.length,i.syncIterations,function(U){var F=~~((i.triangles.length/2+U)%i.triangles.length),z=i.triangles[F];if(z&&!(z.error[3]>O||z.deleted||z.isDirty)){for(var J=0;J<3;++J)if(z.error[J]<O){var ie=[],se=[],ce=z.vertices[J],ue=z.vertices[(J+1)%3];if(ce.isBorder||ue.isBorder)continue;var fe=u.e.Zero();i.calculateError(ce,ue,fe);var ve=new Array;if(i.isFlipped(ce,ue,fe,ie,ve)||i.isFlipped(ue,ce,fe,se,ve)||ie.indexOf(!0)<0||se.indexOf(!0)<0)continue;var Te=new Array;if(ve.forEach(function(Se){Te.indexOf(Se)===-1&&(Se.deletePending=!0,Te.push(Se))}),Te.length%2!=0)continue;ce.q=ue.q.add(ce.q),ce.updatePosition(fe);var Oe=i.references.length;a=i.updateTriangles(ce,ce,ie,a),a=i.updateTriangles(ce,ue,se,a);var Pe=i.references.length-Oe;if(Pe<=ce.triangleCount){if(Pe)for(var Ee=0;Ee<Pe;Ee++)i.references[ce.triangleStart+Ee]=i.references[Oe+Ee]}else ce.triangleStart=Oe;ce.triangleCount=Pe;break}}},y,function(){return s-a<=o})},0))},function(){setTimeout(function(){i.reconstructMesh(e),n()},0)})},r.prototype.initWithMesh=function(t,e,n){var i=this;this.vertices=[],this.triangles=[];var o=this._mesh.getVerticesData(Me.b.PositionKind),a=this._mesh.getIndices(),s=this._mesh.subMeshes[t],d=[],p=s.verticesCount;Ye.a.SyncAsyncForLoop(p,this.syncIterations/4>>0,function(y){if(o){var P=y+s.verticesStart,O=u.e.FromArray(o,3*P),U=function(F){if(n){for(var z=0;z<i.vertices.length;++z)if(i.vertices[z].position.equalsWithEpsilon(F,1e-4))return i.vertices[z]}return null}(O)||new qm(O,i.vertices.length);U.originalOffsets.push(P),U.id===i.vertices.length&&i.vertices.push(U),d.push(U.id)}},function(){Ye.a.SyncAsyncForLoop(s.indexCount/3,i.syncIterations,function(y){if(a){var P=3*(s.indexStart/3+y),O=a[P+0],U=a[P+1],F=a[P+2],z=i.vertices[d[O-s.verticesStart]],J=i.vertices[d[U-s.verticesStart]],ie=i.vertices[d[F-s.verticesStart]],se=new Qm([z,J,ie]);se.originalOffset=P,i.triangles.push(se)}},function(){i.init(e)})})},r.prototype.init=function(t){var e=this;Ye.a.SyncAsyncForLoop(this.triangles.length,this.syncIterations,function(n){var i=e.triangles[n];i.normal=u.e.Cross(i.vertices[1].position.subtract(i.vertices[0].position),i.vertices[2].position.subtract(i.vertices[0].position)).normalize();for(var o=0;o<3;o++)i.vertices[o].q.addArrayInPlace(Rd.DataFromNumbers(i.normal.x,i.normal.y,i.normal.z,-u.e.Dot(i.normal,i.vertices[0].position)))},function(){Ye.a.SyncAsyncForLoop(e.triangles.length,e.syncIterations,function(n){for(var i=e.triangles[n],o=0;o<3;++o)i.error[o]=e.calculateError(i.vertices[o],i.vertices[(o+1)%3]);i.error[3]=Math.min(i.error[0],i.error[1],i.error[2])},function(){t()})})},r.prototype.reconstructMesh=function(t){var e,n,i,o=[];for(e=0;e<this.vertices.length;++e)this.vertices[e].triangleCount=0;for(e=0;e<this.triangles.length;++e)if(!this.triangles[e].deleted){for(n=this.triangles[e],i=0;i<3;++i)n.vertices[i].triangleCount=1;o.push(n)}var a=this._reconstructedMesh.getVerticesData(Me.b.PositionKind)||[],s=this._reconstructedMesh.getVerticesData(Me.b.NormalKind)||[],d=this._reconstructedMesh.getVerticesData(Me.b.UVKind)||[],p=this._reconstructedMesh.getVerticesData(Me.b.ColorKind)||[],y=this._mesh.getVerticesData(Me.b.NormalKind),P=this._mesh.getVerticesData(Me.b.UVKind),O=this._mesh.getVerticesData(Me.b.ColorKind),U=0;for(e=0;e<this.vertices.length;++e){var F=this.vertices[e];
8488F.id=U,F.triangleCount&&F.originalOffsets.forEach(function(fe){a.push(F.position.x),a.push(F.position.y),a.push(F.position.z),y&&y.length&&(s.push(y[3*fe]),s.push(y[3*fe+1]),s.push(y[3*fe+2])),P&&P.length&&(d.push(P[2*fe]),d.push(P[2*fe+1])),O&&O.length&&(p.push(O[4*fe]),p.push(O[4*fe+1]),p.push(O[4*fe+2]),p.push(O[4*fe+3])),++U})}var z=this._reconstructedMesh.getTotalIndices(),J=this._reconstructedMesh.getTotalVertices(),ie=this._reconstructedMesh.subMeshes;this._reconstructedMesh.subMeshes=[];var se=this._reconstructedMesh.getIndices(),ce=this._mesh.getIndices();for(e=0;e<o.length;++e)n=o[e],[0,1,2].forEach(function(fe){var ve=ce[n.originalOffset+fe],Te=n.vertices[fe].originalOffsets.indexOf(ve);Te<0&&(Te=0),se.push(n.vertices[fe].id+Te+J)});this._reconstructedMesh.setIndices(se),this._reconstructedMesh.setVerticesData(Me.b.PositionKind,a),s.length>0&&this._reconstructedMesh.setVerticesData(Me.b.NormalKind,s),d.length>0&&this._reconstructedMesh.setVerticesData(Me.b.UVKind,d),p.length>0&&this._reconstructedMesh.setVerticesData(Me.b.ColorKind,p);var ue=this._mesh.subMeshes[t];t>0&&(this._reconstructedMesh.subMeshes=[],ie.forEach(function(fe){To.a.AddToMesh(fe.materialIndex,fe.verticesStart,fe.verticesCount,fe.indexStart,fe.indexCount,fe.getMesh())}),To.a.AddToMesh(ue.materialIndex,J,U,z,3*o.length,this._reconstructedMesh))},r.prototype.initDecimatedMesh=function(){this._reconstructedMesh=new De.a(this._mesh.name+"Decimated",this._mesh.getScene()),this._reconstructedMesh.material=this._mesh.material,this._reconstructedMesh.parent=this._mesh.parent,this._reconstructedMesh.isVisible=!1,this._reconstructedMesh.renderingGroupId=this._mesh.renderingGroupId},r.prototype.isFlipped=function(t,e,n,i,o){for(var a=0;a<t.triangleCount;++a){var s=this.triangles[this.references[t.triangleStart+a].triangleId];if(!s.deleted){var d=this.references[t.triangleStart+a].vertexId,p=s.vertices[(d+1)%3],y=s.vertices[(d+2)%3];if(p!==e&&y!==e){var P=p.position.subtract(n);P=P.normalize();var O=y.position.subtract(n);if(O=O.normalize(),Math.abs(u.e.Dot(P,O))>.999)return!0;var U=u.e.Cross(P,O).normalize();if(i[a]=!1,u.e.Dot(U,s.normal)<.2)return!0}else i[a]=!0,o.push(s)}}return!1},r.prototype.updateTriangles=function(t,e,n,i){for(var o=i,a=0;a<e.triangleCount;++a){var s=this.references[e.triangleStart+a],d=this.triangles[s.triangleId];d.deleted||(n[a]&&d.deletePending?(d.deleted=!0,o++):(d.vertices[s.vertexId]=t,d.isDirty=!0,d.error[0]=this.calculateError(d.vertices[0],d.vertices[1])+d.borderFactor/2,d.error[1]=this.calculateError(d.vertices[1],d.vertices[2])+d.borderFactor/2,d.error[2]=this.calculateError(d.vertices[2],d.vertices[0])+d.borderFactor/2,d.error[3]=Math.min(d.error[0],d.error[1],d.error[2]),this.references.push(s)))}return o},r.prototype.identifyBorder=function(){for(var t=0;t<this.vertices.length;++t){var e,n=[],i=[],o=this.vertices[t];for(e=0;e<o.triangleCount;++e)for(var a=this.triangles[this.references[o.triangleStart+e].triangleId],s=0;s<3;s++){for(var d=0,p=a.vertices[s];d<n.length&&i[d]!==p.id;)++d;d===n.length?(n.push(1),i.push(p.id)):n[d]++}for(e=0;e<n.length;++e)n[e]===1?this.vertices[i[e]].isBorder=!0:this.vertices[i[e]].isBorder=!1}},r.prototype.updateMesh=function(t){var e,n,i,o;if(t===void 0&&(t=!1),!t){var a=[];for(e=0;e<this.triangles.length;++e)this.triangles[e].deleted||a.push(this.triangles[e]);this.triangles=a}for(e=0;e<this.vertices.length;++e)this.vertices[e].triangleCount=0,this.vertices[e].triangleStart=0;for(e=0;e<this.triangles.length;++e)for(n=this.triangles[e],i=0;i<3;++i)(o=n.vertices[i]).triangleCount++;var s=0;for(e=0;e<this.vertices.length;++e)this.vertices[e].triangleStart=s,s+=this.vertices[e].triangleCount,this.vertices[e].triangleCount=0;var d=new Array(3*this.triangles.length);for(e=0;e<this.triangles.length;++e)for(n=this.triangles[e],i=0;i<3;++i)d[(o=n.vertices[i]).triangleStart+o.triangleCount]=new Zm(i,e),o.triangleCount++;this.references=d,t&&this.identifyBorder()},r.prototype.vertexError=function(t,e){var n=e.x,i=e.y,o=e.z;return t.data[0]*n*n+2*t.data[1]*n*i+2*t.data[2]*n*o+2*t.data[3]*n+t.data[4]*i*i+2*t.data[5]*i*o+2*t.data[6]*i+t.data[7]*o*o+2*t.data[8]*o+t.data[9]},r.prototype.calculateError=function(t,e,n){var i=t.q.add(e.q),o=t.isBorder&&e.isBorder,a=0,s=i.det(0,1,2,1,4,5,2,5,7);if(s===0||o){var d=t.position.add(e.position).divide(new u.e(2,2,2)),p=this.vertexError(i,t.position),y=this.vertexError(i,e.position),P=this.vertexError(i,d);(a=Math.min(p,y,P))===p?n&&n.copyFrom(t.position):a===y?n&&n.copyFrom(e.position):n&&n.copyFrom(d)}else n||(n=u.e.Zero()),n.x=-1/s*i.det(1,2,3,4,5,6,5,7,8),n.y=1/s*i.det(0,2,3,1,5,6,2,7,8),n.z=-1/s*i.det(0,1,3,1,4,6,2,5,8),a=this.vertexError(i,n);return a},r}();Object.defineProperty(_e.a.prototype,"simplificationQueue",{get:function(){if(!this._simplificationQueue){this._simplificationQueue=new xd;var r=this._getComponent(st.a.NAME_SIMPLIFICATIONQUEUE);r||(r=new Md(this),this._addComponent(r))}return this._simplificationQueue},set:function(r){this._simplificationQueue=r},enumerable:!0,configurable:!0}),De.a.prototype.simplify=function(r,t,e,n){return t===void 0&&(t=!0),e===void 0&&(e=Po.QUADRATIC),this.get
8488Scene().simplificationQueue.addTask({settings:r,parallelProcessing:t,mesh:this,simplificationType:e,successCallback:n}),this};var Md=function(){function r(t){this.name=st.a.NAME_SIMPLIFICATIONQUEUE,this.scene=t}return r.prototype.register=function(){this.scene._beforeCameraUpdateStage.registerStep(st.a.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE,this,this._beforeCameraUpdate)},r.prototype.rebuild=function(){},r.prototype.dispose=function(){},r.prototype._beforeCameraUpdate=function(){this.scene._simplificationQueue&&!this.scene._simplificationQueue.running&&this.scene._simplificationQueue.executeNext()},r}(),Jm=f(149),$m=f(88);De.a.prototype.thinInstanceAdd=function(r,t){t===void 0&&(t=!0),this._thinInstanceUpdateBufferSize("matrix",Array.isArray(r)?r.length:1);var e=this._thinInstanceDataStorage.instancesCount;if(Array.isArray(r))for(var n=0;n<r.length;++n)this.thinInstanceSetMatrixAt(this._thinInstanceDataStorage.instancesCount++,r[n],n===r.length-1&&t);else this.thinInstanceSetMatrixAt(this._thinInstanceDataStorage.instancesCount++,r,t);return e},De.a.prototype.thinInstanceAddSelf=function(r){return r===void 0&&(r=!0),this.thinInstanceAdd(u.a.IdentityReadOnly,r)},De.a.prototype.thinInstanceRegisterAttribute=function(r,t){this.removeVerticesData(r),this._thinInstanceInitializeUserStorage(),this._userThinInstanceBuffersStorage.strides[r]=t,this._userThinInstanceBuffersStorage.sizes[r]=t*Math.max(32,this._thinInstanceDataStorage.instancesCount),this._userThinInstanceBuffersStorage.data[r]=new Float32Array(this._userThinInstanceBuffersStorage.sizes[r]),this._userThinInstanceBuffersStorage.vertexBuffers[r]=new Me.b(this.getEngine(),this._userThinInstanceBuffersStorage.data[r],r,!0,!1,t,!0),this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[r])},De.a.prototype.thinInstanceSetMatrixAt=function(r,t,e){if(e===void 0&&(e=!0),!this._thinInstanceDataStorage.matrixData||r>=this._thinInstanceDataStorage.instancesCount)return!1;var n=this._thinInstanceDataStorage.matrixData;return t.copyToArray(n,16*r),this._thinInstanceDataStorage.worldMatrices&&(this._thinInstanceDataStorage.worldMatrices[r]=t),e&&(this.thinInstanceBufferUpdated("matrix"),this.doNotSyncBoundingInfo||this.thinInstanceRefreshBoundingInfo(!1)),!0},De.a.prototype.thinInstanceSetAttributeAt=function(r,t,e,n){return n===void 0&&(n=!0),!(!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(De.a.prototype,"thinInstanceCount",{get:function(){return this._thinInstanceDataStorage.instancesCount},set:function(r){var t,e;r<=((e=(t=this._thinInstanceDataStorage.matrixData)===null||t===void 0?void 0:t.length)!==null&&e!==void 0?e:0)/16&&(this._thinInstanceDataStorage.instancesCount=r)},enumerable:!0,configurable:!0}),De.a.prototype.thinInstanceSetBuffer=function(r,t,e,n){var i,o;if(e===void 0&&(e=0),n===void 0&&(n=!1),e=e||16,r==="matrix")if((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;var a=new Me.a(this.getEngine(),t,!n,e,!1,!0);this._thinInstanceDataStorage.matrixBuffer=a,this.setVerticesBuffer(a.createVertexBuffer("world0",0,4)),this.setVerticesBuffer(a.createVertexBuffer("world1",4,4)),this.setVerticesBuffer(a.createVertexBuffer("world2",8,4)),this.setVerticesBuffer(a.createVertexBuffer("world3",12,4)),this.doNotSyncBoundingInfo||this.thinInstanceRefreshBoundingInfo(!1)}else this._thinInstanceDataStorage.instancesCount=0,this.doNotSyncBoundingInfo||this.refreshBoundingInfo(!0);else t===null?!((o=this._userThinInstanceBuffersStorage)===null||o===void 0)&&o.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 Me.b(this.getEngine(),t,r,!n,!1,e,!0),this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[r]))},De.a.prototype.thinInstanceBufferUpdated=function(r){var t;r==="matrix"?this._thinInstanceDataStorage.matrixBuffer&&this._thinInstanceDataStorage.matrixBuffer.updateDirectly(this._thinInstanceDataStorage.matrixData,0,this._thinInstanceDataStorage.
8488instancesCount):!((t=this._userThinInstanceBuffersStorage)===null||t===void 0)&&t.vertexBuffers[r]&&this._userThinInstanceBuffersStorage.vertexBuffers[r].updateDirectly(this._userThinInstanceBuffersStorage.data[r],0)},De.a.prototype.thinInstancePartialBufferUpdate=function(r,t,e){var n;r==="matrix"?this._thinInstanceDataStorage.matrixBuffer&&this._thinInstanceDataStorage.matrixBuffer.updateDirectly(t,e):!((n=this._userThinInstanceBuffersStorage)===null||n===void 0)&&n.vertexBuffers[r]&&this._userThinInstanceBuffersStorage.vertexBuffers[r].updateDirectly(t,e)},De.a.prototype.thinInstanceGetWorldMatrices=function(){if(!this._thinInstanceDataStorage.matrixData||!this._thinInstanceDataStorage.matrixBuffer)return[];var r=this._thinInstanceDataStorage.matrixData;if(!this._thinInstanceDataStorage.worldMatrices){this._thinInstanceDataStorage.worldMatrices=new Array;for(var t=0;t<this._thinInstanceDataStorage.instancesCount;++t)this._thinInstanceDataStorage.worldMatrices[t]=u.a.FromArray(r,16*t)}return this._thinInstanceDataStorage.worldMatrices},De.a.prototype.thinInstanceRefreshBoundingInfo=function(r){if(r===void 0&&(r=!1),this._thinInstanceDataStorage.matrixData&&this._thinInstanceDataStorage.matrixBuffer){var t=this._thinInstanceDataStorage.boundingVectors;r&&(t.length=0,this.refreshBoundingInfo(!0));var e=this.getBoundingInfo(),n=this._thinInstanceDataStorage.matrixData;if(t.length===0)for(var i=0;i<e.boundingBox.vectors.length;++i)t.push(e.boundingBox.vectors[i].clone());u.c.Vector3[0].setAll(Number.POSITIVE_INFINITY),u.c.Vector3[1].setAll(Number.NEGATIVE_INFINITY);for(var o=0;o<this._thinInstanceDataStorage.instancesCount;++o)for(u.a.FromArrayToRef(n,16*o,u.c.Matrix[0]),i=0;i<t.length;++i)u.e.TransformCoordinatesToRef(t[i],u.c.Matrix[0],u.c.Vector3[2]),u.c.Vector3[0].minimizeInPlace(u.c.Vector3[2]),u.c.Vector3[1].maximizeInPlace(u.c.Vector3[2]);e.reConstruct(u.c.Vector3[0],u.c.Vector3[1]),this._updateBoundingInfo()}},De.a.prototype._thinInstanceUpdateBufferSize=function(r,t){var e,n;t===void 0&&(t=1);var i=r==="matrix";if(i||this._userThinInstanceBuffersStorage&&this._userThinInstanceBuffersStorage.strides[r]){for(var o=i?16:this._userThinInstanceBuffersStorage.strides[r],a=i?this._thinInstanceDataStorage.matrixBufferSize:this._userThinInstanceBuffersStorage.sizes[r],s=i?this._thinInstanceDataStorage.matrixData:this._userThinInstanceBuffersStorage.data[r],d=(this._thinInstanceDataStorage.instancesCount+t)*o,p=a;p<d;)p*=2;if(!s||a!=p){if(s){var y=new Float32Array(p);y.set(s,0),s=y}else s=new Float32Array(p);if(i){(e=this._thinInstanceDataStorage.matrixBuffer)===null||e===void 0||e.dispose();var P=new Me.a(this.getEngine(),s,!0,o,!1,!0);this._thinInstanceDataStorage.matrixBuffer=P,this._thinInstanceDataStorage.matrixData=s,this._thinInstanceDataStorage.matrixBufferSize=p,this.setVerticesBuffer(P.createVertexBuffer("world0",0,4)),this.setVerticesBuffer(P.createVertexBuffer("world1",4,4)),this.setVerticesBuffer(P.createVertexBuffer("world2",8,4)),this.setVerticesBuffer(P.createVertexBuffer("world3",12,4))}else(n=this._userThinInstanceBuffersStorage.vertexBuffers[r])===null||n===void 0||n.dispose(),this._userThinInstanceBuffersStorage.data[r]=s,this._userThinInstanceBuffersStorage.sizes[r]=p,this._userThinInstanceBuffersStorage.vertexBuffers[r]=new Me.b(this.getEngine(),s,r,!0,!1,o,!0),this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[r])}}},De.a.prototype._thinInstanceInitializeUserStorage=function(){this._userThinInstanceBuffersStorage||(this._userThinInstanceBuffersStorage={data:{},sizes:{},vertexBuffers:{},strides:{}})},De.a.prototype._disposeThinInstanceSpecificData=function(){var r;!((r=this._thinInstanceDataStorage)===null||r===void 0)&&r.matrixBuffer&&(this._thinInstanceDataStorage.matrixBuffer.dispose(),this._thinInstanceDataStorage.matrixBuffer=null)};var eg=function(){function r(t){t===void 0&&(t=Recast),this.bjsRECAST={},this.name="RecastJSPlugin",this._maximumSubStepCount=10,this._timeStep=1/60,typeof t=="function"?t(this.bjsRECAST):this.bjsRECAST=t,this.isSupported()?this.setTimeStep():l.a.Error("RecastJS is not available. Please make sure you included the js file.")}return r.prototype.setTimeStep=function(t){t===void 0&&(t=1/60),this._timeStep=t},r.prototype.getTimeStep=function(){return this._timeStep},r.prototype.setMaximumSubStepCount=function(t){t===void 0&&(t=10),this._maximumSubStepCount=t},r.prototype.getMaximumSubStepCount=function(){return this._maximumSubStepCount},r.prototype.createNavMesh=function(t,e){var n,i,o,a=new this.bjsRECAST.rcConfig;a.cs=e.cs,a.ch=e.ch,a.borderSize=0,a.tileSize=0,a.walkableSlopeAngle=e.walkableSlopeAngle,a.walkableHeight=e.walkableHeight,a.walkableClimb=e.walkableClimb,a.walkableRadius=e.walkableRadius,a.maxEdgeLen=e.maxEdgeLen,a.maxSimplificationError=e.maxSimplificationError,a.minRegionArea=e.minRegionArea,a.mergeRegionArea=e.mergeRegionArea,a.maxVertsPerPoly=e.maxVertsPerPoly,a.detailSampleDist=e.detailSampleDist,a.detailSampleMaxError=e.detailSampleMaxError,this.navMesh=new this.bjsRECAST.NavMesh;var s=[],d=[],p=0;for(n=0;n<t.length;n++)if(t[n]){var y=t[n],P=y.getIndices();if(!P)continue;var O=y.getVerticesData(Me.b.PositionKind,!1,!1);if(!O)continue;var U=y.computeWorldMatrix(!0);for(i=0;i<P.length;i++)s.push(P[i]+p);var F=u.e.Zero(),z=u.e.Zero();for(o=0;o<O.length;o+=3)u.e.FromArrayToRef(O,o,z),u.e.TransformCoordinatesToRef(z,U,F),d.push(F.x,F.y,F.z);p+=O.length/3}this.navMesh.build(d,p,s,s.length,a)},r.prototype.createDebugNavMesh=function(t){var e,n,i=this.navMesh.getDebugNavMesh(),o=i.getTriangleCount(),a=[],s=[];for(e=0;e<3*o;e++)a.push(e);for(e=0;e<o;e++)for(n=0;n<3;n++){var d=i.getTriangle(e).getPoint(n);s.push(d.x,d.y,d.z)}var p=new De.a("NavMeshDebug",t),y=new ft.a;return y.indices=a,y.positions=s,y.applyToMesh(p,!1),p},r.prototype.getClosestPoint=function(t){var e=new this.bjsRECAST.Vec3(t.x,t.y,t.z),n=this.navMesh.getClosestPoint(e);return new u.e(n.x,n.y,n.z)},r.prototype.getClosestPointToRef=function(t,e){var n=new this.bjsRECAST.Vec3(t.x,t.y,t.z),i=this.navMesh.getClosestPoint(n);e.set(i.x,i.y,i.z)},r.prototype.getRandomPointAround=function(t,e){var n=new this.bjsRECAST.Vec3(t.x,t.y,t.z),i=this.navMesh.getRandomPointAround(n,e);return new u.e(i.x,i.y,i.z)},r.prototype.getRandomPointAroundToRef=function(t,e,n){var i=new this.bjsRECAST.Vec3(t.x,t.y,t.z),o=this.navMesh.getRandomPointAround(i,e);n.set(o.x,o.y,o.z)},r.prototype.moveAlong=function(t,e){var n=new this.bjsRECAST.Vec3(t.x,t.y,t.z),i=new this.bjsRECAST.Vec3(e.x,e.y,e.z),o=this.navMesh.moveAlong(n,i);return new u.e(o.x,o.y,o.z)},r.prototype.moveAlongToRef=function(t,e,n){var i=new this.bjsRECAST.Vec3(t.x,t.y,t.z),o=new this.bjsRECAST.Vec3(e.x,e.y,e.z),a=this.navMesh.moveAlong(i,o);n.set(a.x,a.y,a.z)},r.prototype.computePath=function(t,e){var n,i=new this.bjsRECAST.Vec3(t.x,t.y,t.z),o=new this.bjsRECAST.Vec3(e.x,e.y,e.z),a=this.navMesh.computePath(i,o),s=a.getPointCount(),d=[];for(n=0;n<s;n++){var p=a.getPoint(n);d.push(new u.e(p.x,p.y,p.z))}return d},r.prototype.createCrowd=function(t,e,n){return new Id(this,t,e,n)},r.prototype.setDefaultQueryExtent=function(t){var e=new this.bjsRECAST.Vec3(t.x,t.y,t.z);this.navMesh.setDefaultQueryExtent(e)},r.prototype.getDefaultQueryExtent=function(){var t=this.navMesh.getDefaultQueryExtent();return new u.e(t.x,t.y,t.z)},r.prototype.buildFromNavmeshData=function(t){var e=t.length*t.BYTES_PER_ELEMENT,n=this.bjsRECAST._malloc(e),i=new Uint8Array(this.bjsRECAST.HEAPU8.buffer,n,e);i.set(t);var o=new this.bjsRECAST.NavmeshData;o.dataPointer=i.byteOffset,o.size=t.length,this.navMesh=new this.bjsRECAST.NavMesh,this.navMesh.buildFromNavmeshData(o),this.bjsRECAST._free(i.byteOffset)},r.prototype.getNavmeshData=function(){var t=this.navMesh.getNavmeshData(),e=new Uint8Array(this.bjsRECAST.HEAPU8.buffer,t.dataPointer,t.size),n=new Uint8Array(t.size);return n.set(e),this.navMesh.freeNavmeshData(t),n},r.prototype.getDefaultQueryExtentToRef=function(t){var e=this.navMesh.getDefaultQueryExtent();t.set(e.x,e.y,e.z)},r.prototype.dispose=function(){},r.prototype.isSupported=function(){return this.bjsRECAST!==void 0},r}(),Id=function(){function r(t,e,n,i){var o=this;this.recastCrowd={},this.transforms=new Array,this.agents=new Array,this._onBeforeAnimationsObserver=null,this.bjsRECASTPlugin=t,this.recastCrowd=new this.bjsRECASTPlugin.bjsRECAST.Crowd(e,n,this.bjsRECASTPlugin.navMesh.getNavMesh()),this._scene=i,this._onBeforeAnimationsObserver=i.onBeforeAnimationsObservable.add(function(){o.update(.001*i.getEngine().getDeltaTime())})}return r.prototype.addAgent=function(t,e,n){var i=new this.bjsRECASTPlugin.bjsRECAST.dtCrowdAgentParam
8488s;i.radius=e.radius,i.height=e.height,i.maxAcceleration=e.maxAcceleration,i.maxSpeed=e.maxSpeed,i.collisionQueryRange=e.collisionQueryRange,i.pathOptimizationRange=e.pathOptimizationRange,i.separationWeight=e.separationWeight,i.updateFlags=7,i.obstacleAvoidanceType=0,i.queryFilterType=0,i.userData=0;var o=this.recastCrowd.addAgent(new this.bjsRECASTPlugin.bjsRECAST.Vec3(t.x,t.y,t.z),i);return this.transforms.push(n),this.agents.push(o),o},r.prototype.getAgentPosition=function(t){var e=this.recastCrowd.getAgentPosition(t);return new u.e(e.x,e.y,e.z)},r.prototype.getAgentPositionToRef=function(t,e){var n=this.recastCrowd.getAgentPosition(t);e.set(n.x,n.y,n.z)},r.prototype.getAgentVelocity=function(t){var e=this.recastCrowd.getAgentVelocity(t);return new u.e(e.x,e.y,e.z)},r.prototype.getAgentVelocityToRef=function(t,e){var n=this.recastCrowd.getAgentVelocity(t);e.set(n.x,n.y,n.z)},r.prototype.getAgentNextTargetPath=function(t){var e=this.recastCrowd.getAgentNextTargetPath(t);return new u.e(e.x,e.y,e.z)},r.prototype.getAgentNextTargetPathToRef=function(t,e){var n=this.recastCrowd.getAgentNextTargetPath(t);e.set(n.x,n.y,n.z)},r.prototype.getAgentState=function(t){return this.recastCrowd.getAgentState(t)},r.prototype.overOffmeshConnection=function(t){return this.recastCrowd.overOffmeshConnection(t)},r.prototype.agentGoto=function(t,e){this.recastCrowd.agentGoto(t,new this.bjsRECASTPlugin.bjsRECAST.Vec3(e.x,e.y,e.z))},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))},r.prototype.getAgents=function(){return this.agents},r.prototype.update=function(t){var e=this.bjsRECASTPlugin.getTimeStep(),n=this.bjsRECASTPlugin.getMaximumSubStepCount();if(e<=Gt.a)this.recastCrowd.update(t);else{var i=t/e;n&&i>n&&(i=n),i<1&&(i=1);for(var o=0;o<i;o++)this.recastCrowd.update(e)}for(var a=0;a<this.agents.length;a++)this.transforms[a].position=this.getAgentPosition(this.agents[a])},r.prototype.setDefaultQueryExtent=function(t){var e=new this.bjsRECASTPlugin.bjsRECAST.Vec3(t.x,t.y,t.z);this.recastCrowd.setDefaultQueryExtent(e)},r.prototype.getDefaultQueryExtent=function(){var t=this.recastCrowd.getDefaultQueryExtent();return new u.e(t.x,t.y,t.z)},r.prototype.getDefaultQueryExtentToRef=function(t){var e=this.recastCrowd.getDefaultQueryExtent();t.set(e.x,e.y,e.z)},r.prototype.dispose=function(){this.recastCrowd.destroy(),this._scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver),this._onBeforeAnimationsObserver=null},r}();Ue.a.OfflineProviderFactory=function(r,t,e){return e===void 0&&(e=!1),new Dd(r,t,e)};var wr,Dd=function(){function r(t,e,n){var i=this;n===void 0&&(n=!1),this._idbFactory=typeof window<"u"?window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB:indexedDB,this._callbackManifestChecked=e,this._currentSceneUrl=r._ReturnFullUrlLocation(t),this._db=null,this._enableSceneOffline=!1,this._enableTexturesOffline=!1,this._manifestVersionFound=0,this._mustUpdateRessources=!1,this._hasReachedQuota=!1,r.IDBStorageEnabled?n?(this._enableSceneOffline=!0,this._enableTexturesOffline=!0,this._manifestVersionFound=1,Ye.b.SetImmediate(function(){i._callbackManifestChecked(!0)})):this._checkManifestFile():this._callbackManifestChecked(!0)}return Object.defineProperty(r.prototype,"enableSceneOffline",{get:function(){return this._enableSceneOffline}
8488,enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"enableTexturesOffline",{get:function(){return this._enableTexturesOffline},enumerable:!1,configurable:!0}),r.prototype._checkManifestFile=function(){var t=this,e=function(){t._enableSceneOffline=!1,t._enableTexturesOffline=!1,t._callbackManifestChecked(!1)},n=!1,i=this._currentSceneUrl+".manifest",o=new re.a;navigator.onLine&&(n=!0,i=i+(i.match(/\?/)==null?"?":"&")+Date.now()),o.open("GET",i),o.addEventListener("load",function(){if(o.status===200||r._ValidateXHRData(o,1))try{var a=JSON.parse(o.response);t._enableSceneOffline=a.enableSceneOffline,t._enableTexturesOffline=a.enableTexturesOffline&&r.IsUASupportingBlobStorage,a.version&&!isNaN(parseInt(a.version))&&(t._manifestVersionFound=a.version),t._callbackManifestChecked&&t._callbackManifestChecked(!0)}catch{e()}else e()},!1),o.addEventListener("error",function(){if(n){n=!1;var a=t._currentSceneUrl+".manifest";o.open("GET",a),o.send()}else e()},!1);try{o.send()}catch{l.a.Error("Error on XHR send request."),this._callbackManifestChecked(!1)}},r.prototype.open=function(t,e){var n=this,i=function(){n._isSupported=!1,e&&e()};if(this._idbFactory&&(this._enableSceneOffline||this._enableTexturesOffline))if(this._db)t&&t();else{this._hasReachedQuota=!1,this._isSupported=!0;var o=this._idbFactory.open("babylonjs",1);o.onerror=function(){i()},o.onblocked=function(){l.a.Error("IDB request blocked. Please reload the page."),i()},o.onsuccess=function(){n._db=o.result,t()},o.onupgradeneeded=function(a){if(n._db=a.target.result,n._db)try{n._db.createObjectStore("scenes",{keyPath:"sceneUrl"}),n._db.createObjectStore("versions",{keyPath:"sceneUrl"}),n._db.createObjectStore("textures",{keyPath:"textureUrl"})}catch(s){l.a.Error("Error while creating object stores. Exception: "+s.message),i()}}}else this._isSupported=!1,e&&e()},r.prototype.loadImage=function(t,e){var n=this,i=r._ReturnFullUrlLocation(t),o=function(){n._hasReachedQuota||n._db===null?e.src=t:n._saveImageIntoDBAsync(i,e)};this._mustUpdateRessources?o():this._loadImageFromDBAsync(i,e,o)},r.prototype._loadImageFromDBAsync=function(t,e,n){if(this._isSupported&&this._db!==null){var i,o=this._db.transaction(["textures"]);o.onabort=function(){e.src=t},o.oncomplete=function(){var s;if(i){var d=window.URL||window.webkitURL;s=d.createObjectURL(i.data),e.onerror=function(){l.a.Error("Error loading image from blob URL: "+s+" switching back to web url: "+t),e.src=t},e.src=s}else n()};var a=o.objectStore("textures").get(t);a.onsuccess=function(s){i=s.target.result},a.onerror=function(){l.a.Error("Error loading texture "+t+" from DB."),e.src=t}}else l.a.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),e.src=t},r.prototype._saveImageIntoDBAsync=function(t,e){var n=this;if(this._isSupported){var i=function(){var s;if(o){var d=window.URL||window.webkitURL;try{s=d.createObjectURL(o)}catch{s=d.createObjectURL(o)}}s&&(e.src=s)};if(r.IsUASupportingBlobStorage){var o,a=new re.a;a.open("GET",t),a.responseType="blob",a.addEventListener("load",function(){if(a.status===200&&n._db){o=a.response;var s=n._db.transaction(["textures"],"readwrite");s.onabort=function(y){try{var P=(y.srcElement||y.target).error;P&&P.name==="QuotaExceededError"&&(n._hasReachedQuota=!0)}catch{}i()},s.oncomplete=function(){i()};var d={textureUrl:t,data:o};try{var p=s.objectStore("textures").put(d);p.onsuccess=function(){},p.onerror=function(){i()}}catch(y){y.code===25&&(r.IsUASupportingBlobStorage=!1,n._enableTexturesOffline=!1),e.src=t}}else e.src=t},!1),a.addEventListener("error",function(){l.a.Error("Error in XHR request in BABYLON.Database."),e.src=t},!1),a.send()}else e.src=t}else l.a.Error("Error: IndexedDB not supported by your browser or Babylon.js database is not open."),e.src=t},r.prototype._checkVersionFromDB=function(t,e){var n=this;this._loadVersionFromDBAsync(t,e,function(){n._saveVersionIntoDBAsync(t,e)})},r.prototype._loadVersionFromDBAsync=function(t,e,n){var i,o=this;if(this._isSupported&&this._db)try{var a=this._db.transaction(["versions"]);a.oncomplete=function(){i?o._manifestVersionFound!==i.data?(o._mustUpdateRessources=!0,n()):e(i.data):(o._mustUpdateRessources=!0,n())},a.onabort=function(){e(-1)};var s=a.objectStore("versions").get(t);s.onsuccess=function(d){i=d.target.result},s.onerror=function(){l.a.Error("Error loading version for scene "+t+" from DB."),e(-1)}}catch(d){l.a.Error("Error while accessing 'versions' object store (READ OP). Exception: "+d.message),e(-1)}else l.a.Error("Error: IndexedDB not supported by your browser or Babylon.js database is not open."),e(-1)},r.prototype._saveVersionIntoDBAsync=function(t,e){var n=this;if(this._isSupported&&!this._hasReachedQuota&&this._db)try{var i=this._db.transaction(["versions"],"readwrite");i.onabort=function(s){try{var d=s.srcElement.error;d&&d.name==="QuotaExceededError"&&(n._hasReachedQuota=!0)}catch{}e(-1)},i.oncomplete=function(){e(n._manifestVersionFound)};var o={sceneUrl:t,data:this._manifestVersionFound},a=i.objectStore("versions").put(o);a.onsuccess=function(){},a.onerror=function(){l.a.Error("Error in DB add version request in BABYLON.Database.")}}catch(s){l.a.Error("Error while accessing 'versions' object store (WRITE OP). Exception: "+s.message),e(-1)}else e(-1)},r.prototype.loadFile=function(t,e,n,i,o){var a=this,s=r._ReturnFullUrlLocation(t),d=function(){a._saveFileAsync(s,e,n,o,i)};this._checkVersionFromDB(s,function(p){p!==-1?a._mustUpdateRessources?a._saveFileAsync(s,e,n,o,i):a._loadFileAsync(s,e,d):i&&i()})},r.prototype._loadFileAsync=function(t,e,n){if(this._isSupported&&this._db){var i,o;
8488i=t.indexOf(".babylon")!==-1?"scenes":"textures";var a=this._db.transaction([i]);a.oncomplete=function(){o?e(o.data):n()},a.onabort=function(){n()};var s=a.objectStore(i).get(t);s.onsuccess=function(d){o=d.target.result},s.onerror=function(){l.a.Error("Error loading file "+t+" from DB."),n()}}else l.a.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),e()},r.prototype._saveFileAsync=function(t,e,n,i,o){var a=this;if(this._isSupported){var s;s=t.indexOf(".babylon")!==-1?"scenes":"textures";var d,p=new re.a;p.open("GET",t+"?"+Date.now()),i&&(p.responseType="arraybuffer"),n&&(p.onprogress=n),p.addEventListener("load",function(){if(p.status===200||p.status<400&&r._ValidateXHRData(p,i?6:1))if(d=i?p.response:p.responseText,!a._hasReachedQuota&&a._db){var y,P=a._db.transaction([s],"readwrite");P.onabort=function(U){try{var F=U.srcElement.error;F&&F.name==="QuotaExceededError"&&(a._hasReachedQuota=!0)}catch{}e(d)},P.oncomplete=function(){e(d)},y=s==="scenes"?{sceneUrl:t,data:d,version:a._manifestVersionFound}:{textureUrl:t,data:d};try{var O=P.objectStore(s).put(y);O.onsuccess=function(){},O.onerror=function(){l.a.Error("Error in DB add file request in BABYLON.Database.")}}catch{e(d)}}else e(d);else p.status>=400&&o?o(p):e()},!1),p.addEventListener("error",function(){l.a.Error("error on XHR request."),e()},!1),p.send()}else l.a.Error("Error: IndexedDB not supported by your browser or Babylon.js database is not open."),e()},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=pa.GetTGAHeader(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}(),Lc=function(){function r(t,e,n){this.gradient=t,this.color1=e,this.color2=n}return r.prototype.getColorToRef=function(t){this.color2?M.b.LerpToRef(this.color1,this.color2,Math.random(),t):t.copyFrom(this.color1)},r}(),Ld=function(r,t){this.gradient=r,this.color=t},Nc=function(){function r(t,e,n){this.gradient=t,this.factor1=e,this.factor2=n}return r.prototype.getFactor=function(){return this.factor2===void 0||this.factor2===this.factor1?this.factor1:this.factor1+(this.factor2-this.factor1)*Math.random()},r}(),On=function(){function r(){}return r.GetCurrentGradient=function(t,e,n){if(e[0].gradient>t)n(e[0],e[0],1);else{for(var i=0;i<e.length-1;i++){var o=e[i],a=e[i+1];if(t>=o.gradient&&t<=a.gradient)return void n(o,a,(t-o.gradient)/(a.gradient-o.gradient))}var s=e.length-1;n(e[s],e[s],1)}},r}(),Nd=function(){function r(t){this.particleSystem=t,this.position=u.e.Zero(),this.direction=u.e.Zero(),this.color=new M.b(0,0,0,0),this.colorStep=new M.b(0,0,0,0),this.lifeTime=1,this.age=0,this.size=0,this.scale=new u.d(1,1),this.angle=0,this.angularSpeed=0,this.cellIndex=0,this._attachedSubEmitters=null,this._currentColor1=new M.b(0,0,0,0),this._currentColor2=new M.b(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=this._initialEndSpriteCellID-this._initialStartSpriteCellID,i=$.a.Clamp(t*e%this.lifeTime/this.lifeTime);this.cellIndex=this._initialStartSpriteCellID+i*n|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=u.c.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,u.c.Vector3[0]),t.particleSystem._inheritedVelocityOffset.copyFrom(u.c.Vector3[0])},r.prototype._inheritParticleInfoToSubEmitters=function(){var t=this;this._attachedSubEmitters&&this._attachedSubEmitters.length>
84880&&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),this.particleSystem.useRampGradients&&(t.remapData&&this.remapData?t.remapData.copyFrom(this.remapData):t.remapData=new u.f(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}();(function(r){r[r.ATTACHED=0]="ATTACHED",r[r.END=1]="END"})(wr||(wr={}));var Co=function(){function r(t){if(this.particleSystem=t,this.type=wr.END,this.inheritDirection=!1,this.inheritedVelocityAmount=0,!t.emitter||!t.emitter.dispose){var e=R.a.GetClass("BABYLON.AbstractMesh");t.emitter=new e("SubemitterSystemEmitter",t.getScene())}t.onDisposeObservable.add(function(){t.emitter&&t.emitter.dispose&&t.emitter.dispose()})}return r.prototype.clone=function(){var t=this.particleSystem.emitter;t?t instanceof u.e?t=t.clone():t.getClassName().indexOf("Mesh")!==-1&&((t=new(R.a.GetClass("BABYLON.Mesh"))("",t.getScene())).isVisible=!1):t=new u.e;var e=new r(this.particleSystem.clone("",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(){var t={};return t.type=this.type,t.inheritDirection=this.inheritDirection,t.inheritedVelocityAmount=this.inheritedVelocityAmount,t.particleSystem=this.particleSystem.serialize(),t},r._ParseParticleSystem=function(t,e,n){throw En.a.WarnImport("ParseParticle")},r.Parse=function(t,e,n){var i=t.particleSystem,o=new r(r._ParseParticleSystem(i,e,n));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}(),tg=`
8489varying vec2 vUV;
8490varying vec4 vColor;
8491uniform vec4 textureMask;
8492uniform sampler2D diffuseSampler;
8493#include<clipPlaneFragmentDeclaration>
8494#include<imageProcessingDeclaration>
8495#include<helperFunctions>
8496#include<imageProcessingFunctions>
8497#ifdef RAMPGRADIENT
8498varying vec4 remapRanges;
8499uniform sampler2D rampSampler;
8500#endif
8501void main(void) {
8502#include<clipPlaneFragment>
8503vec4 textureColor=texture2D(diffuseSampler,vUV);
8504vec4 baseColor=(textureColor*textureMask+(vec4(1.,1.,1.,1.)-textureMask))*vColor;
8505#ifdef RAMPGRADIENT
8506float alpha=baseColor.a;
8507float remappedColorIndex=clamp((alpha-remapRanges.x)/remapRanges.y,0.0,1.0);
8508vec4 rampColor=texture2D(rampSampler,vec2(1.0-remappedColorIndex,0.));
8509baseColor.rgb*=rampColor.rgb;
8510
8511float finalAlpha=baseColor.a;
8512baseColor.a=clamp((alpha*rampColor.a-remapRanges.z)/remapRanges.w,0.0,1.0);
8513#endif
8514#ifdef BLENDMULTIPLYMODE
8515float sourceAlpha=vColor.a*textureColor.a;
8516baseColor.rgb=baseColor.rgb*sourceAlpha+vec3(1.0)*(1.0-sourceAlpha);
8517#endif
8518
8519
8520#ifdef IMAGEPROCESSINGPOSTPROCESS
8521baseColor.rgb=toLinearSpace(baseColor.rgb);
8522#else
8523#ifdef IMAGEPROCESSING
8524baseColor.rgb=toLinearSpace(baseColor.rgb);
8525baseColor=applyImageProcessing(baseColor);
8526#endif
8527#endif
8528gl_FragColor=baseColor;
8529}`;je.a.ShadersStore.particlesPixelShader=tg;var ng=`
8530attribute vec3 position;
8531attribute vec4 color;
8532attribute float angle;
8533attribute vec2 size;
8534#ifdef ANIMATESHEET
8535attribute float cellIndex;
8536#endif
8537#ifndef BILLBOARD
8538attribute vec3 direction;
8539#endif
8540#ifdef BILLBOARDSTRETCHED
8541attribute vec3 direction;
8542#endif
8543#ifdef RAMPGRADIENT
8544attribute vec4 remapData;
8545#endif
8546attribute vec2 offset;
8547
8548uniform mat4 view;
8549uniform mat4 projection;
8550uniform vec2 translationPivot;
8551#ifdef ANIMATESHEET
8552uniform vec3 particlesInfos;
8553#endif
8554
8555varying vec2 vUV;
8556varying vec4 vColor;
8557varying vec3 vPositionW;
8558#ifdef RAMPGRADIENT
8559varying vec4 remapRanges;
8560#endif
8561#if defined(BILLBOARD) && !defined(BILLBOARDY) && !defined(BILLBOARDSTRETCHED)
8562uniform mat4 invView;
8563#endif
8564#include<clipPlaneVertexDeclaration>
8565#ifdef BILLBOARD
8566uniform vec3 eyePosition;
8567#endif
8568vec3 rotate(vec3 yaxis,vec3 rotatedCorner) {
8569vec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));
8570vec3 zaxis=normalize(cross(yaxis,xaxis));
8571vec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);
8572vec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);
8573vec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);
8574mat3 rotMatrix=mat3(row0,row1,row2);
8575vec3 alignedCorner=rotMatrix*rotatedCorner;
8576return position+alignedCorner;
8577}
8578#ifdef BILLBOARDSTRETCHED
8579vec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {
8580vec3 normalizedToCamera=normalize(toCamera);
8581vec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));
8582vec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));
8583vec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);
8584vec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);
8585vec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);
8586mat3 rotMatrix=mat3(row0,row1,row2);
8587vec3 alignedCorner=rotMatrix*rotatedCorner;
8588return position+alignedCorner;
8589}
8590#endif
8591void main(void) {
8592vec2 cornerPos;
8593cornerPos=(vec2(offset.x-0.5,offset.y-0.5)-translationPivot)*size+translationPivot;
8594#ifdef BILLBOARD
8595
8596vec3 rotatedCorner;
8597#ifdef BILLBOARDY
8598rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
8599rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
8600rotatedCorner.y=0.;
8601vec3 yaxis=position-eyePosition;
8602yaxis.y=0.;
8603vPositionW=rotate(normalize(yaxis),rotatedCorner);
8604vec3 viewPos=(view*vec4(vPositionW,1.0)).xyz;
8605#elif defined(BILLBOARDSTRETCHED)
8606rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
8607rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
8608rotatedCorner.z=0.;
8609vec3 toCamera=position-eyePosition;
8610vPositionW=rotateAlign(toCamera,rotatedCorner);
8611vec3 viewPos=(view*vec4(vPositionW,1.0)).xyz;
8612#else
8613rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
8614rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
8615rotatedCorner.z=0.;
8616vec3 viewPos=(view*vec4(position,1.0)).xyz+rotatedCorner;
8617vPositionW=(invView*vec4(viewPos,1)).xyz;
8618#endif
8619#ifdef RAMPGRADIENT
8620remapRanges=remapData;
8621#endif
8622
8623gl_Position=projection*vec4(viewPos,1.0);
8624#else
8625
8626vec3 rotatedCorner;
8627rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
8628rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
8629rotatedCorner.y=0.;
8630vec3 yaxis=normalize(direction);
8631vPositionW=rotate(yaxis,rotatedCorner);
8632gl_Position=projection*view*vec4(vPositionW,1.0);
8633#endif
8634vColor=color;
8635#ifdef ANIMATESHEET
8636float rowOffset=floor(cellIndex*particlesInfos.z);
8637float columnOffset=cellIndex-rowOffset/particlesInfos.z;
8638vec2 uvScale=particlesInfos.xy;
8639vec2 uvOffset=vec2(offset.x ,1.0-offset.y);
8640vUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;
8641#else
8642vUV=offset;
8643#endif
8644
8645#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)
8646vec4 worldPos=vec4(vPositionW,1.0);
8647#endif
8648#include<clipPlaneVertex>
8649}`;je.a.ShadersStore.particlesVertexShader=ng;var ln=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 d=r.call(this,e)||this;return d._inheritedVelocityOffset=new u.e,d.onDisposeObservable=new x.c,d.onStoppedObservable=new x.c,d._particles=new Array,d._stockParticles=new Array,d._newPartsExcess=0,d._vertexBuffers={},d._scaledColorStep=new M.b(0,0,0,0),d._colorDiff=new M.b(0,0,0,0),d._scaledDirection=u.e.Zero(),d._scaledGravity=u.e.Zero(),d._currentRenderId=-1,d._useInstancing=!1,d._started=!1,d._stopped=!1,d._actualFrame=0,d._currentEmitRate1=0,d._currentEmitRate2=0,d._currentStartSize1=0,d._currentStartSize2=0,d._rawTextureWidth=256,d._useRampGradients=!1,d._disposeEmitterOnDispose=!1,d.isLocal=!1,d._onBeforeDrawParticlesObservable=null,d.recycleParticle=function(p){var y=d._particles.pop();y!==p&&y.copyTo(p),d._stockParticles.push(y)},d._createParticle=function(){var p;if(d._stockParticles.length!==0?(p=d._stockParticles.pop())._reset():p=new Nd(d),d._subEmitters&&d._subEmitters.length>0){var y=d._subEmitters[Math.floor(Math.random()*d._subEmitters.length)];p._attachedSubEmitters=[],y.forEach(function(P){if(P.type===wr.ATTACHED){var O=P.clone();p._attachedSubEmitters.push(O),O.particleSystem.start()}})}return p},d._emitFromParticle=function(p){if(d._subEmitters&&d._subEmitters.length!==0){var y=Math.floor(Math.random()*d._subEmitters.length);d._subEmitters[y].forEach(function(P){if(P.type===wr.END){var O=P.clone();p._inheritParticleInfoToSubEmitter(O),O.particleSystem._rootParticleSystem=d,d.activeSubSystems.push(O.particleSystem),O.particleSystem.start()}})}},d._capacity=n,d._epsilon=s,d._isAnimationSheetEnabled=a,i&&i.getClassName()!=="Scene"?(d._engine=i,d.defaultProjectionMatrix=u.a.PerspectiveFovLH(.8,1,.1,100)):(d._scene=i||te.a.LastCreatedScene,d._engine=d._scene.getEngine(),d.uniqueId=d._scene.getUniqueId(),d._scene.particleSystems.push(d)),d._engine.getCaps().vertexArrayObject&&(d._vertexArrayObject=null),d._attachImageProcessingConfiguration(null),d._customEffect={0:o},d._useInstancing=d._engine.getCaps().instancedArrays,d._createIndexBuffer(),d._createVertexBuffers(),d.particleEmitterType=new Lr,d.updateFunction=function(p){var y=null,P=null;d.noiseTexture&&(y=d.noiseTexture.getSize(),P=d.noiseTexture.getContent());for(var O,U=function(){O=p[F];var z=d._scaledUpdateSpeed,J=O.age;if(O.age+=z,O.age>O.lifeTime){var ie=O.age-J;z=(O.lifeTime-J)*z/ie,O.age=O.lifeTime}var se=O.age/O.lifeTime;d._colorGradients&&d._colorGradients.length>0?On.GetCurrentGradient(se,d._colorGradients,function(Pe,Ee,Se){Pe!==O._currentColorGradient&&(O._currentColor1.copyFrom(O._currentColor2),Ee.getColorToRef(O._currentColor2),O._currentColorGradient=Pe),M.b.LerpToRef(O._currentColor1,O._currentColor2,Se,O.color)}):(O.colorStep.scaleToRef(z,d._scaledColorStep),O.color.addInPlace(d._scaledColorStep),O.color.a<0&&(O.color.a=0)),d._angularSpeedGradients&&d._angularSpeedGradients.length>0&&On.GetCurrentGradient(se,d._angularSpeedGradients,function(Pe,Ee,Se){Pe!==O._currentAngularSpeedGradient&&(O._currentAngularSpeed1=O._currentAngularSpeed2,O._currentAngularSpeed2=Ee.getFactor(),O._currentAngularSpeedGradient=Pe),O.angularSpeed=$.a.Lerp(O._currentAngularSpeed1,O._currentAngularSpeed2,Se)}),O.angle+=O.angularSpeed*z;var ce=z;if(d._velocityGradients&&d._velocityGradients.length>0&&On.GetCurrentGradient(se,d._velocityGradients,function(Pe,Ee,Se){Pe!==O._currentVelocityGradient&&(O._currentVelocity1=O._currentVelocity2,O._currentVelocity2=Ee.getFactor(),O._currentVelocityGradient=Pe),ce*=$.a.Lerp(O._currentVelocity1,O._currentVelocity2,Se)}),O.direction.scaleToRef(ce,d._scaledDirection),d._limitVelocityGradients&&d._limitVelocityGradients.length>0&&On.GetCurrentGradient(se,d._limitVelocityGradients,function(Pe,Ee,Se){Pe!==O._currentLimitVelocityGradient&&(O._currentLimitVelocity1=O._currentLimitVelocity2,O._currentLimitVelocity2=Ee.getFactor(),O._currentLimitVelocityGradient=Pe);var Le=$.a.Lerp(O._currentLimitVelocity1,O._currentLimitVelocity2,Se);O.direction.length()>Le&&O.direction.scaleInPlace(d.limitVelocityDamping)}),d._dragGradients&&d._dragGradients.length>0&&On.GetCurrentGradient(se,d._dragGradients,function(Pe,Ee,Se){Pe!==O._currentDragGradient&&(O._currentDrag1=O._currentDrag2,O._currentDrag2=Ee.getFactor(),O._currentDragGradient=Pe);var Le=$.a.Lerp(O._currentDrag1,O._currentDrag2,Se);d._scaledDirection.scaleInPlace(1-Le)}),d.isLocal&&O._localPosition?(O._localPosition.addInPlace(d._scaledDirection),u.e.TransformCoordinatesToRef(O._localPosition,d._emitterWorldMatrix,O.position)):O.position.addInPlace(d._scaledDirection),P&&y&&O._randomNoiseCoordinates1){var ue=d._fetchR(O._randomNoiseCoordinates1.x,O._randomNoiseCoordinates1.y,y.width,y.height,P),fe=d._fetchR(O._randomNoiseCoordinates1.z,O._randomNoiseCoordinates2.x,y.width,y.height,P),ve=d._fetchR(O._randomNoiseCoordinates2.y,O._randomNoiseCoordinates2.z,y.width,y.height,P),Te=u.c.Vector3[0],Oe=u.c.Vector3[1];Te.copyFromFloats((2*ue-1)*d.noiseStrength.x,(2*fe-1)*d.noiseStrength.y,(2*ve-1)*d.noiseStrength.z),Te.scaleToRef(z,Oe),O.direction.addInPlace(Oe)}if(d.gravity.scaleToRef(z,d._scaledGravity),O.direction.addInPlace(d._scaledGravity),d._sizeGradients&&d._sizeGradients.length>0&&On.GetCurrentGradient(se,d._sizeGradients,function(Pe,Ee,Se){Pe!==O._currentSizeGradient&&(O._currentSize1=O._currentSize2,O._currentSize2=Ee.getFactor(),O._currentSizeGradient=Pe),O.size=$.a.Lerp(O._currentSize1,O._currentSize2,
8649Se)}),d._useRampGradients&&(d._colorRemapGradients&&d._colorRemapGradients.length>0&&On.GetCurrentGradient(se,d._colorRemapGradients,function(Pe,Ee,Se){var Le=$.a.Lerp(Pe.factor1,Ee.factor1,Se),xe=$.a.Lerp(Pe.factor2,Ee.factor2,Se);O.remapData.x=Le,O.remapData.y=xe-Le}),d._alphaRemapGradients&&d._alphaRemapGradients.length>0&&On.GetCurrentGradient(se,d._alphaRemapGradients,function(Pe,Ee,Se){var Le=$.a.Lerp(Pe.factor1,Ee.factor1,Se),xe=$.a.Lerp(Pe.factor2,Ee.factor2,Se);O.remapData.z=Le,O.remapData.w=xe-Le})),d._isAnimationSheetEnabled&&O.updateCellIndex(),O._inheritParticleInfoToSubEmitters(),O.age>=O.lifeTime)return d._emitFromParticle(O),O._attachedSubEmitters&&(O._attachedSubEmitters.forEach(function(Pe){Pe.particleSystem.disposeOnStop=!0,Pe.particleSystem.stop()}),O._attachedSubEmitters=null),d.recycleParticle(O),F--,"continue"},F=0;F<p.length;F++)U()},d}return Object(c.d)(t,r),Object.defineProperty(t.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useRampGradients",{get:function(){return this._useRampGradients},set:function(e){this._useRampGradients!==e&&(this._useRampGradients=e,this._resetEffect())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"particles",{get:function(){return this._particles},enumerable:!1,configurable:!0}),t.prototype.getActiveCount=function(){return this._particles.length},t.prototype.getClassName=function(){return"ParticleSystem"},t.prototype.isStopping=function(){return this._stopped&&this.isAlive()},t.prototype.getCustomEffect=function(e){var n;return e===void 0&&(e=0),(n=this._customEffect[e])!==null&&n!==void 0?n:this._customEffect[0]}
8649,t.prototype.setCustomEffect=function(e,n){n===void 0&&(n=0),this._customEffect[n]=e},Object.defineProperty(t.prototype,"onBeforeDrawParticlesObservable",{get:function(){return this._onBeforeDrawParticlesObservable||(this._onBeforeDrawParticlesObservable=new x.c),this._onBeforeDrawParticlesObservable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vertexShaderName",{get:function(){return"particles"},enumerable:!1,configurable:!0}),t.prototype._addFactorGradient=function(e,n,i,o){var a=new Nc(n,i,o);e.push(a),e.sort(function(s,d){return s.gradient<d.gradient?-1:s.gradient>d.gradient?1:0})},t.prototype._removeFactorGradient=function(e,n){if(e)for(var i=0,o=0,a=e;o<a.length;o++){if(a[o].gradient===n){e.splice(i,1);break}i++}},t.prototype.addLifeTimeGradient=function(e,n,i){return this._lifeTimeGradients||(this._lifeTimeGradients=[]),this._addFactorGradient(this._lifeTimeGradients,e,n,i),this},t.prototype.removeLifeTimeGradient=function(e){return this._removeFactorGradient(this._lifeTimeGradients,e),this},t.prototype.addSizeGradient=function(e,n,i){return this._sizeGradients||(this._sizeGradients=[]),this._addFactorGradient(this._sizeGradients,e,n,i),this},t.prototype.removeSizeGradient=function(e){return this._removeFactorGradient(this._sizeGradients,e),this},t.prototype.addColorRemapGradient=function(e,n,i){return this._colorRemapGradients||(this._colorRemapGradients=[]),this._addFactorGradient(this._colorRemapGradients,e,n,i),this},t.prototype.removeColorRemapGradient=function(e){return this._removeFactorGradient(this._colorRemapGradients,e),this},t.prototype.addAlphaRemapGradient=function(e,n,i){return this._alphaRemapGradients||(this._alphaRemapGradients=[]),this._addFactorGradient(this._alphaRemapGradients,e,n,i),this},t.prototype.removeAlphaRemapGradient=function(e){return this._removeFactorGradient(this._alphaRemapGradients,e),this},t.prototype.addAngularSpeedGradient=function(e,n,i){return this._angularSpeedGradients||(this._angularSpeedGradients=[]),this._addFactorGradient(this._angularSpeedGradients,e,n,i),this},t.prototype.removeAngularSpeedGradient=function(e){return this._removeFactorGradient(this._angularSpeedGradients,e),this},t.prototype.addVelocityGradient=function(e,n,i){return this._velocityGradients||(this._velocityGradients=[]),this._addFactorGradient(this._velocityGradients,e,n,i),this},t.prototype.removeVelocityGradient=function(e){return this._removeFactorGradient(this._velocityGradients,e),this},t.prototype.addLimitVelocityGradient=function(e,n,i){return this._limitVelocityGradients||(this._limitVelocityGradients=[]),this._addFactorGradient(this._limitVelocityGradients,e,n,i),this},t.prototype.removeLimitVelocityGradient=function(e){return this._removeFactorGradient(this._limitVelocityGradients,e),this},t.prototype.addDragGradient=function(e,n,i){return this._dragGradients||(this._dragGradients=[]),this._addFactorGradient(this._dragGradients,e,n,i),this},t.prototype.removeDragGradient=function(e){return this._removeFactorGradient(this._dragGradients,e),this},t.prototype.addEmitRateGradient=function(e,n,i){return this._emitRateGradients||(this._emitRateGradients=[]),this._addFactorGradient(this._emitRateGradients,e,n,i),this},t.prototype.removeEmitRateGradient=function(e){return this._removeFactorGradient(this._emitRateGradients,e),this},t.prototype.addStartSizeGradient=function(e,n,i){return this._startSizeGradients||(this._startSizeGradients=[]),this._addFactorGradient(this._startSizeGradients,e,n,i),this},t.prototype.removeStartSizeGradient=function(e){return this._removeFactorGradient(this._startSizeGradients,e),this},t.prototype._createRampGradientTexture=function(){if(this._rampGradients&&this._rampGradients.length&&!this._rampGradientsTexture&&this._scene){for(var e=new Uint8Array(4*this._rawTextureWidth),n=M.c.Color3[0],i=0;i<this._rawTextureWidth;i++){var o=i/this._rawTextureWidth;On.GetCurrentGradient(o,this._rampGradients,function(a,s,d){M.a.LerpToRef(a.color,s.color,d,n),e[4*i]=255*n.r,e[4*i+1]=255*n.g,e[4*i+2]=255*n.b,e[4*i+3]=255})}this._rampGradientsTexture=$n.CreateRGBATexture(e,this._rawTextureWidth,1,this._scene,!1,!1,h.a.TEXTURE_NEAREST_SAMPL
8649INGMODE)}},t.prototype.getRampGradients=function(){return this._rampGradients},t.prototype.forceRefreshGradients=function(){this._syncRampGradientTexture()},t.prototype._syncRampGradientTexture=function(){this._rampGradients&&(this._rampGradients.sort(function(e,n){return e.gradient<n.gradient?-1:e.gradient>n.gradient?1:0}),this._rampGradientsTexture&&(this._rampGradientsTexture.dispose(),this._rampGradientsTexture=null),this._createRampGradientTexture())},t.prototype.addRampGradient=function(e,n){this._rampGradients||(this._rampGradients=[]);var i=new Ld(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 Lc(e,n,i);return this._colorGradients.push(o),this._colorGradients.sort(function(a,s){return a.gradient<s.gradient?-1:a.gradient>s.gradient?1:0}),this},t.prototype.removeColorGradient=function(e){if(!this._colorGradients)return this;for(var n=0,i=0,o=this._colorGradients;i<o.length;i++){if(o[i].gradient===e){this._colorGradients.splice(n,1);break}n++}return this},t.prototype._fetchR=function(e,n,i,o,a){return a[4*(((e=.5*Math.abs(e)+.5)*i%i|0)+((n=.5*Math.abs(n)+.5)*o%o|0)*i)]/255},t.prototype._reset=function(){this._resetEffect()},t.prototype._resetEffect=function(){this._vertexBuffer&&(this._vertexBuffer.dispose(),this._vertexBuffer=null),this._spriteBuffer&&(this._spriteBuffer.dispose(),this._spriteBuffer=null),this._vertexArrayObject&&(this._engine.releaseVertexArrayObject(this._vertexArrayObject),this._vertexArrayObject=null),this._createVertexBuffers()},t.prototype._createVertexBuffers=function(){this._vertexBufferSize=this._useInstancing?10:12,this._isAnimationSheetEnabled&&(this._vertexBufferSize+=1),this._isBillboardBased&&this.billboardMode!==t.BILLBOARDMODE_STRETCHED||(this._vertexBufferSize+=3),this._useRampGradients&&(this._vertexBufferSize+=4);var e=this._engine;this._vertexData=new Float32Array(this._capacity*this._vertexBufferSize*(this._useInstancing?1:4)),this._vertexBuffer=new Me.a(e,this._vertexData,!0,this._vertexBufferSize);var n=0,i=this._vertexBuffer.createVertexBuffer(Me.b.PositionKind,n,3,this._vertexBufferSize,this._useInstancing);this._vertexBuffers[Me.b.PositionKind]=i,n+=3;var o=this._vertexBuffer.createVertexBuffer(Me.b.ColorKind,n,4,this._vertexBufferSize,this._useInstancing);this._vertexBuffers[Me.b.ColorKind]=o,n+=4;var a=this._vertexBuffer.createVertexBuffer("angle",n,1,this._vertexBufferSize,this._useInstancing);this._vertexBuffers.angle=a,n+=1;var s,d=this._vertexBuffer.createVertexBuffer("size",n,2,this._vertexBufferSize,this._useInstancing);if(this._vertexBuffers.size=d,n+=2,this._isAnimationSheetEnabled){var p=this._vertexBuffer.createVertexBuffer("cellIndex",n,1,this._vertexBufferSize,this._useInstancing);this._vertexBuffers.cellIndex=p,n+=1}if(!this._isBillboardBased||this.billboardMode===t.BILLBOARDMODE_STRETCHED){var y=this._vertexBuffer.createVertexBuffer("direction",n,3,this._vertexBufferSize,this._useInstancing);this._vertexBuffers.direction=y,n+=3}if(this._useRampGradients){var P=this._vertexBuffer.createVertexBuffer("remapData",n,4,this._vertexBufferSize,this._useInstancing);this._vertexBuffers.remapData=P,n+=4}if(this._useInstancing){var O=new Float32Array([0,0,1,0,1,1,0,1]);this._spriteBuffer=new Me.a(e,O,!1,2),s=this._spriteBuffer.createVertexBuffer("offset",0,2)}else s=this._vertexBuffer.createVertexBuffer("offset",n,2,this._vertexBufferSize,this._useInstancing),n+=2;this._vertexBuffers.offset=s},t.prototype._createIndexBuffer=function(){if(!this._useInstancing){for(var e=[],n=0,i=0;i<this._capacity;i++)e.push(n),e.push(n+1),e.push(n+2),e.push(n),e.push(n+2),e.push(n+3),n+=4;this._indexBuffer=this._engine.createIndexBuffer(e)}},t.prototype.getCapacity=function(){return this._capacity},t.prototype.isAlive=function(){return this._alive},t.prototype.isStarted=function(){return this._started},t.prototype._prepareSubEmitterInternalArray=function(){var e=this;this._subEmitters=new Array,this.subEmitters&&this.subEmitters.forEac
8649h(function(n){n instanceof t?e._subEmitters.push([new Co(n)]):n instanceof Co?e._subEmitters.push([n]):n instanceof Array&&e._subEmitters.push(n)})},t.prototype.start=function(e){var n,i=this;if(e===void 0&&(e=this.startDelay),!this.targetStopDuration&&this._hasTargetStopDurationDependantGradient())throw"Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";if(e)setTimeout(function(){i.start(0)},e);else{if(this._prepareSubEmitterInternalArray(),this._started=!0,this._stopped=!1,this._actualFrame=0,this._subEmitters&&this._subEmitters.length!=0&&(this.activeSubSystems=new Array),this._emitRateGradients&&(this._emitRateGradients.length>0&&(this._currentEmitRateGradient=this._emitRateGradients[0],this._currentEmitRate1=this._currentEmitRateGradient.getFactor(),this._currentEmitRate2=this._currentEmitRate1),this._emitRateGradients.length>1&&(this._currentEmitRate2=this._emitRateGradients[1].getFactor())),this._startSizeGradients&&(this._startSizeGradients.length>0&&(this._currentStartSizeGradient=this._startSizeGradients[0],this._currentStartSize1=this._currentStartSizeGradient.getFactor(),this._currentStartSize2=this._currentStartSize1),this._startSizeGradients.length>1&&(this._currentStartSize2=this._startSizeGradients[1].getFactor())),this.preWarmCycles){((n=this.emitter)===null||n===void 0?void 0:n.getClassName().indexOf("Mesh"))!==-1&&this.emitter.computeWorldMatrix(!0);var o=this.noiseTexture;if(o&&o.onGeneratedObservable)o.onGeneratedObservable.addOnce(function(){setTimeout(function(){for(var s=0;s<i.preWarmCycles;s++)i.animate(!0),o.render()})});else for(var a=0;a<this.preWarmCycles;a++)this.animate(!0)}this.beginAnimationOnStart&&this.animations&&this.animations.length>0&&this._scene&&this._scene.beginAnimation(this,this.beginAnimationFrom,this.beginAnimationTo,this.beginAnimationLoop)}},t.prototype.stop=function(e){e===void 0&&(e=!0),this._stopped||(this.onStoppedObservable.notifyObservers(this),this._stopped=!0,e&&this._stopSubEmitters())},t.prototype.reset=function(){this._stockParticles=[],this._particles=[]},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===t.BILLBOARDMODE_STRETCHED&&(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&&(u.e.TransformNormalToRef(s,this._emitterWorldMatrix,u.c.Vector3[0]),s=u.c.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 d=n.direction;this.isLocal&&(u.e.TransformNormalToRef(d,this._emitterWorldMatrix,u.c.Vector3[0]),d=u.c.Vector3[0]),d.x===0&&d.z===0&&(d.x=.001),this._vertexData[a++]=d.x,this._vertexData[a++]=d.y,this._vertexData[a++]=d.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._stopSubEmitters=function(){this.activeSubSystems&&(this.activeSubSystems.forEach(function(e){e.stop(!0)}),this.activeSubSystems=new Array)},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._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=u.a.Translation(a.x,a.y,a.z)}this.updateFunction(this._particles);for(var s,d=function(){if(p._particles.length===p._capacity)return"break";if(n=p._createParticle(),p._particles.push(n),p.targetStopDuration&&p._lifeTimeGradients&&p._lifeTimeGradients.length>0){var P=$.a.Clamp(p._actualFrame/p.targetStopDuration);On.GetCurrentGradient(P,p._lifeTimeGradients,function(F,z){var J=F,ie=z,se=J.getFactor(),ce=ie.getFactor(),ue=(P-J.gradient)/(ie.gradient-J.gradient);n.lifeTime=$.a.Lerp(se,ce,ue)})}else n.lifeTime=$.a.RandomRange(p.minLifeTime,p.maxLifeTime);var O=$.a.RandomRange(p.minEmitPower,p.maxEmitPower);if(p.startPositionFunction?p.startPositionFunction(p._emitterWorldMatrix,n.position,n,p.isLocal):p.particleEmitterType.startPositionFunction(p._emitterWorldMatrix,n.position,n,p.isLocal),p.isLocal&&(n._localPosition?n._localPosition.copyFrom(n.position):n._localPosition=n.position.clone(),u.e.TransformCoordinatesToRef(n._localPosition,p._emitterWorldMatrix,n.position)),p.startDirectionFunction?p.startDirectionFunction(p._emitterWorldMatrix,n.direction,n,p.isLocal):p.particleEmitterType.startDirectionFunction(p._emitterWorldMatrix,n.direction,n,p.isLocal),O===0?n._initialDirection?n._initialDirection.copyFrom(n.direction):n._initialDirection=n.direction.clone():n._initialDirection=null,n.direction.scaleInPlace(O),p._sizeGradients&&p._sizeGradients.length!==0?(n._currentSizeGradient=p._sizeGradients[0],n._currentSize1=n._currentSizeGradient.getFactor(),n.size=n._currentSize1,p._sizeGradients.length>1?n._currentSize2=p._sizeGradients[1].getFactor():n._currentSize2=n._currentSize1):n.size=$.a.RandomRange(p.minSize,p.maxSize),n.scale.copyFromFloats($.a.RandomRange(p.minScaleX,p.maxScaleX),$.a.RandomRange(p.minScaleY,p.maxScaleY)),p._startSizeGradients&&p._startSizeGradients[0]&&p.targetStopDuration){var U=p._actualFrame/p.targetStopDuration;On.GetCurrentGradient(U,p._startSizeGradients,function(F,z,J){F!==i._currentStartSizeGradient&&(i._currentStartSize1=i._currentStartSize2,i._currentStartSize2=z.getFactor(),i._currentStartSizeGradient=F);var ie=$.a.Lerp(i._currentStartSize1,i._currentStartSize2,J);n.scale.scaleInPlace(ie)})}p._angularSpeedGradients&&p._angularSpeedGradients.length!==0?(n._currentAngularSpeedGradient=p._angularSpeedGradients[0],n.angularSpeed=n._currentAngularSpeedGradient.getFactor(),n._currentAngularSpeed1=n.angularSpeed,p._angularSpeedGradients.length>1?n._currentAngularSpeed2=p._angularSpeedGradients[1].getFactor():n._currentAngularSpeed2=n._currentAngularSpeed1):n.angularSpeed=$.a.RandomRange(p.minAngularSpeed,p.maxAngularSpeed),n.angle=$.a.RandomRange(p.minInitialRotation,p.maxInitialRotation),p._velocityGradients&&p._velocityGradients.length>0&&(n._currentVelocityGradient=p._velocityGradients[0],n._currentVelocity1=n._currentVelocityGradient.getFactor(),p._velocityGradients.length>1?n._currentVelocity2=p._velocityGradients[1].getFactor():n._currentVelocity2=n._currentVelocity1),p._limitVelocityGradients&&p._limitVelocityGradients.length>0&&(n._currentLimitVelocityGradient=p._limitVelocityGradients[0],n._currentLimitVelocity1=n._currentLimitVelocityGradient.getFactor(),p._limitVelocityGradients.length>1?n._currentLimitVelocity2=p._limitVelocityGradients[1].getFactor():n._currentLimitVelocity2=n._currentLimitVelocity1),p._dragGradients&&p._dragGradients.length>0&&(n._currentDragGradient=p._dragGradients[0],n._currentDrag1=n._currentDragGradient.getFactor(),p._dragGradients.length>1?n._currentDrag2=p._dragGradients[1].getFactor():n._currentDrag2=n._currentDrag1),p._colorGradients&&p._colorGradients.length!==0?(n._currentColorGradient=p._colorGradients[0],n._currentColorGradient.getColorToRef(n.color),n._currentColor1.copyFrom(n.color),p._colorGradients.length>1?p._colorGradients[1].getColorToRef(n._currentColor2):n._currentColor2.copyFrom(n.color)):(s=$.a.RandomRange(0,1),M.b.LerpToRef(p.color1,p.color2,s,n.color),p.colorDead.subtractToRef(n.color,p._colorDiff),p._colorDiff.scaleToRef(1/n.lifeTime,n.colorStep)),p._isAnimationSheetEnabled&&(n._initialStartSpriteCellID=p.startSpriteCellID,n._initialEndSpriteCellID=p.endSpriteCellID),n.direction.addInPlace(p._inheritedVelocityOffset),p._useRampGradients&&(n.remapData=new u.f(0,1,0,1)),p.noiseTexture&&(n._randomNoiseCoordinates1?(n._randomNoiseCoordinates1.
8649copyFromFloats(Math.random(),Math.random(),Math.random()),n._randomNoiseCoordinates2.copyFromFloats(Math.random(),Math.random(),Math.random())):(n._randomNoiseCoordinates1=new u.e(Math.random(),Math.random(),Math.random()),n._randomNoiseCoordinates2=new u.e(Math.random(),Math.random(),Math.random()))),n._inheritParticleInfoToSubEmitters()},p=this,y=0;y<e&&d()!=="break";y++);},t._GetAttributeNamesOrOptions=function(e,n,i){e===void 0&&(e=!1),n===void 0&&(n=!1),i===void 0&&(i=!1);var o=[Me.b.PositionKind,Me.b.ColorKind,"angle","offset","size"];return e&&o.push("cellIndex"),n||o.push("direction"),i&&o.push("remapData"),o},t._GetEffectCreationOptions=function(e){e===void 0&&(e=!1);var n=["invView","view","projection","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","textureMask","translationPivot","eyePosition"];return e&&n.push("particlesInfos"),n},t.prototype.fillDefines=function(e,n){if(this._scene&&(this._scene.clipPlane&&e.push("#define CLIPPLANE"),this._scene.clipPlane2&&e.push("#define CLIPPLANE2"),this._scene.clipPlane3&&e.push("#define CLIPPLANE3"),this._scene.clipPlane4&&e.push("#define CLIPPLANE4"),this._scene.clipPlane5&&e.push("#define CLIPPLANE5"),this._scene.clipPlane6&&e.push("#define CLIPPLANE6")),this._isAnimationSheetEnabled&&e.push("#define ANIMATESHEET"),n===t.BLENDMODE_MULTIPLY&&e.push("#define BLENDMULTIPLYMODE"),this._useRampGradients&&e.push("#define RAMPGRADIENT"),this._isBillboardBased)switch(e.push("#define BILLBOARD"),this.billboardMode){case t.BILLBOARDMODE_Y:e.push("#define BILLBOARDY");break;case t.BILLBOARDMODE_STRETCHED:e.push("#define BILLBOARDSTRETCHED");break;case t.BILLBOARDMODE_ALL:e.push("#define BILLBOARDMODE_ALL")}this._imageProcessingConfiguration&&(this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines),e.push(this._imageProcessingConfigurationDefines.toString()))},t.prototype.fillUniformsAttributesAndSamplerNames=function(e,n,i){n.push.apply(n,t._GetAttributeNamesOrOptions(this._isAnimationSheetEnabled,this._isBillboardBased&&this.billboardMode!==t.BILLBOARDMODE_STRETCHED,this._useRampGradients)),e.push.apply(e,t._GetEffectCreationOptions(this._isAnimationSheetEnabled)),i.push("diffuseSampler","rampSampler"),this._imageProcessingConfiguration&&(vn.a.PrepareUniforms(e,this._imageProcessingConfigurationDefines),vn.a.PrepareSamplers(i,this._imageProcessingConfigurationDefines))},t.prototype._getEffect=function(e){var n=this.getCustomEffect(e);if(n)return n;var i=[];this.fillDefines(i,e);var o=i.join(`
8650`);if(this._cachedDefines!==o){this._cachedDefines=o;var a=[],s=[],d=[];this.fillUniformsAttributesAndSamplerNames(s,a,d),this._effect=this._engine.createEffect("particles",a,s,d,o)}return this._effect},t.prototype.animate=function(e){var n,i=this;if(e===void 0&&(e=!1),this._started){if(!e&&this._scene){if(!this.isReady()||this._currentRenderId===this._scene.getFrameId())return;this._currentRenderId=this._scene.getFrameId()}var o;if(this._scaledUpdateSpeed=this.updateSpeed*(e?this.preWarmStepOffset:((n=this._scene)===null||n===void 0?void 0:n.getAnimationRatio())||1),this.manualEmitCount>-1)o=this.manualEmitCount,this._newPartsExcess=0,this.manualEmitCount=0;else{var a=this.emitRate;if(this._emitRateGradients&&this._emitRateGradients.length>0&&this.targetStopDuration){var s=this._actualFrame/this.targetStopDuration;On.GetCurrentGradient(s,this._emitRateGradients,function(P,O,U){P!==i._currentEmitRateGradient&&(i._currentEmitRate1=i._currentEmitRate2,i._currentEmitRate2=O.getFactor(),i._currentEmitRateGradient=P),a=$.a.Lerp(i._currentEmitRate1,i._currentEmitRate2,U)})}o=a*this._scaledUpdateSpeed>>0,this._newPartsExcess+=a*this._scaledUpdateSpeed-o}if(this._newPartsExcess>1&&(o+=this._newPartsExcess>>0,this._newPartsExcess-=this._newPartsExcess>>0),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 d=0,p=0;p<this._particles.length;p++){var y=this._particles[p];this._appendParticleVertices(d,y),d+=this._useInstancing?1:4}this._vertexBuffer&&this._vertexBuffer.update(this._vertexData)}this.manualEmitCount===0&&this.disposeOnStop&&this.stop()}},t.prototype._appendParticleVertices=function(e,n){this._appendParticleVertex(e++,n,0,0),this._useInstancing||(this._appendParticleVertex(e++,n,1,0),this._appendParticleVertex(e++,n,1,1),this._appendParticleVertex(e++,n,0,1))},t.prototype.rebuild=function(){for(var e in this._createIndexBuffer(),this._vertexBuffer&&this._vertexBuffer._rebuild(),this._vertexBuffers)this._vertexBuffers[e]._rebuild()},t.prototype.isReady=function(){if(!this.emitter||this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.isReady()||!this.particleTexture||!this.particleTexture.isReady())return!1;if(this.blendMode!==t.BLENDMODE_MULTIPLYADD){if(!this._getEffect(this.blendMode).isReady())return!1}else if(!this._getEffect(t.BLENDMODE_MULTIPLY).isReady()||!this._getEffect(t.BLENDMODE_ADD).isReady())return!1;return!0},t.prototype._render=function(e){var n,i,o=this._getEffect(e),a=this._engine;a.enableEffect(o);var s=(n=this.defaultViewMatrix)!==null&&n!==void 0?n:this._scene.getViewMatrix();if(o.setTexture("diffuseSampler",this.particleTexture),o.setMatrix("view",s),o.setMatrix("projection",(i=this.defaultProjectionMatrix)!==null&&i!==void 0?i:this._scene.getProjectionMatrix()),this._isAnimationSheetEnabled&&this.particleTexture){var d=this.particleTexture.getBaseSize();o.setFloat3("particlesInfos",this.spriteCellWidth/d.width,this.spriteCellHeight/d.height,this.spriteCellWidth/d.width)}if(o.setVector2("translationPivot",this.translationPivot),o.setFloat4("textureMask",this.textureMask.r,this.textureMask.g,this.textureMask.b,this.textureMask.a),this._isBillboardBased&&this._scene){var p=this._scene.activeCamera;o.setVector3("eyePosition",p.globalPosition)}this._rampGradientsTexture&&(this._rampGradients&&this._rampGradients.length||(this._rampGradientsTexture.dispose(),this._rampGradientsTexture=null),o.setTexture("rampSampler",this._rampGradientsTexture));var y=o.defines;switch(this._scene&&(this._scene.clipPlane||this._scene.clipPlane2||this._scene.clipPlane3||this._scene.clipPlane4||this._scene.clipPlane5||this._scene.clipPlane6)&&uh.a.BindClipPlane(o,this._scene),y.indexOf("#define BILLBOARDMODE_ALL")>=0&&(s.invertToRef(u.c.Matrix[0]),o.setMatrix("invView",u.c.Matrix[0])),this._vertexArrayObject!==void 0?(this._vertexArrayObject||(this._vertexArrayObject=this._engine.recordVertexArrayObject(this._vertexBuffers,this._indexBuffer,o)),this._engine.b
8650indVertexArrayObject(this._vertexArrayObject,this._indexBuffer)):a.bindBuffers(this._vertexBuffers,this._indexBuffer,o),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(o),e){case t.BLENDMODE_ADD:a.setAlphaMode(h.a.ALPHA_ADD);break;case t.BLENDMODE_ONEONE:a.setAlphaMode(h.a.ALPHA_ONEONE);break;case t.BLENDMODE_STANDARD:a.setAlphaMode(h.a.ALPHA_COMBINE);break;case t.BLENDMODE_MULTIPLY:a.setAlphaMode(h.a.ALPHA_MULTIPLY)}return this._onBeforeDrawParticlesObservable&&this._onBeforeDrawParticlesObservable.notifyObservers(o),this._useInstancing?a.drawArraysType(h.a.MATERIAL_TriangleFanDrawMode,0,4,this._particles.length):a.drawElementsType(h.a.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=0;return n=this.blendMode===t.BLENDMODE_MULTIPLYADD?this._render(t.BLENDMODE_MULTIPLY)+this._render(t.BLENDMODE_ADD):this._render(this.blendMode),this._engine.unbindInstanceAttributes(),this._engine.setAlphaMode(h.a.ALPHA_DISABLE),n},t.prototype.dispose=function(e){if(e===void 0&&(e=!0),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._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._removeFromRoot(),this._subEmitters&&this._subEmitters.length){for(var n=0;n<this._subEmitters.length;n++)for(var i=0,o=this._subEmitters[n];i<o.length;i++)o[i].dispose();this._subEmitters=[],this.subEmitters=[]}this._disposeEmitterOnDispose&&this.emitter&&this.emitter.dispose&&this.emitter.dispose(!0),this._onBeforeDrawParticlesObservable&&this._onBeforeDrawParticlesObservable.clear(),this._scene&&((n=this._scene.particleSystems.indexOf(this))>-1&&this._scene.particleSystems.splice(n,1),this._scene._activeParticleSystems.dispose()),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onStoppedObservable.clear(),this.reset()},t.prototype.clone=function(e,n){var i=Object(c.a)({},this._customEffect),o=null,a=this._engine;if(a.createEffectForParticles&&this.customShader!=null){var s=(o=this.customShader).shaderOptions.defines.length>0?o.shaderOptions.defines.join(`
8651`):"";i[0]=a.createEffectForParticles(o.shaderPath.fragmentElement,o.shaderOptions.uniforms,o.shaderOptions.samplers,s)}var d=this.serialize(),p=t.Parse(d,this._scene||this._engine,"");return p.name=e,p.customShader=o,p._customEffect=i,n===void 0&&(n=this.emitter),this.noiseTexture&&(p.noiseTexture=this.noiseTexture.clone()),p.emitter=n,this.preventAutoStart||p.start(),p},t.prototype.serialize=function(e){e===void 0&&(e=!1);var n={};if(t._Serialize(n,this,e),n.textureMask=this.textureMask.asArray(),n.customShader=this.customShader,n.preventAutoStart=this.preventAutoStart,this.subEmitters){n.subEmitters=[],this._subEmitters||this._prepareSubEmitterInternalArray();for(var i=0,o=this._subEmitters;i<o.length;i++){for(var a=[],s=0,d=o[i];s<d.length;s++){var p=d[s];a.push(p.serialize())}n.subEmitters.push(a)}}return n},t._Serialize=function(e,n,i){if(e.name=n.name,e.id=n.id,e.capacity=n.getCapacity(),n.emitter.position){var o=n.emitter;e.emitterId=o.id}else{var a=n.emitter;e.emitter=a.asArray()}n.particleEmitterType&&(e.particleEmitterType=n.particleEmitterType.serialize()),n.particleTexture&&(i?e.texture=n.particleTexture.serialize():(e.textureName=n.particleTexture.name,e.invertY=!!n.particleTexture._invertY)),e.isLocal=n.isLocal,L.a.AppendSerializedAnimations(n,e),e.beginAnimationOnStart=n.beginAnimationOnStart,e.beginAnimationFrom=n.beginAnimationFrom,e.beginAnimationTo=n.beginAnimationTo,e.beginAnimationLoop=n.beginAnimationLoop,e.startDelay=n.startDelay,e.renderingGroupId=n.renderingGroupId,e.isBillboardBased=n.isBillboardBased,e.billboardMode=n.billboardMode,e.minAngularSpeed=n.minAngularSpeed,e.maxAngularSpeed=n.maxAngularSpeed,e.minSize=n.minSize,e.maxSize=n.maxSize,e.minScaleX=n.minScaleX,e.maxScaleX=n.maxScaleX,e.minScaleY=n.minScaleY,e.maxScaleY=n.maxScaleY,e.minEmitPower=n.minEmitPower,e.maxEmitPower=n.maxEmitPower,e.minLifeTime=n.minLifeTime,e.maxLifeTime=n.maxLifeTime,e.emitRate=n.emitRate,e.gravity=n.gravity.asArray(),e.noiseStrength=n.noiseStrength.asArray(),e.color1=n.
8651color1.asArray(),e.color2=n.color2.asArray(),e.colorDead=n.colorDead.asArray(),e.updateSpeed=n.updateSpeed,e.targetStopDuration=n.targetStopDuration,e.blendMode=n.blendMode,e.preWarmCycles=n.preWarmCycles,e.preWarmStepOffset=n.preWarmStepOffset,e.minInitialRotation=n.minInitialRotation,e.maxInitialRotation=n.maxInitialRotation,e.startSpriteCellID=n.startSpriteCellID,e.endSpriteCellID=n.endSpriteCellID,e.spriteCellChangeSpeed=n.spriteCellChangeSpeed,e.spriteCellWidth=n.spriteCellWidth,e.spriteCellHeight=n.spriteCellHeight,e.spriteRandomStartCell=n.spriteRandomStartCell,e.isAnimationSheetEnabled=n.isAnimationSheetEnabled;var s=n.getColorGradients();if(s){e.colorGradients=[];for(var d=0,p=s;d<p.length;d++){var y=p[d],P={gradient:y.gradient,color1:y.color1.asArray()};y.color2?P.color2=y.color2.asArray():P.color2=y.color1.asArray(),e.colorGradients.push(P)}}var O=n.getRampGradients();if(O){e.rampGradients=[];for(var U=0,F=O;U<F.length;U++){var z=F[U];P={gradient:z.gradient,color:z.color.asArray()},e.rampGradients.push(P)}e.useRampGradients=n.useRampGradients}var J=n.getColorRemapGradients();if(J){e.colorRemapGradients=[];for(var ie=0,se=J;ie<se.length;ie++){var ce=se[ie];P={gradient:ce.gradient,factor1:ce.factor1},ce.factor2!==void 0?P.factor2=ce.factor2:P.factor2=ce.factor1,e.colorRemapGradients.push(P)}}var ue=n.getAlphaRemapGradients();if(ue){e.alphaRemapGradients=[];for(var fe=0,ve=ue;fe<ve.length;fe++){var Te=ve[fe];P={gradient:Te.gradient,factor1:Te.factor1},Te.factor2!==void 0?P.factor2=Te.factor2:P.factor2=Te.factor1,e.alphaRemapGradients.push(P)}}var Oe=n.getSizeGradients();if(Oe){e.sizeGradients=[];for(var Pe=0,Ee=Oe;Pe<Ee.length;Pe++){var Se=Ee[Pe];P={gradient:Se.gradient,factor1:Se.factor1},Se.factor2!==void 0?P.factor2=Se.factor2:P.factor2=Se.factor1,e.sizeGradients.push(P)}}var Le=n.getAngularSpeedGradients();if(Le){e.angularSpeedGradients=[];for(var xe=0,Ne=Le;xe<Ne.length;xe++){var Ie=Ne[xe];P={gradient:Ie.gradient,factor1:Ie.factor1},Ie.factor2!==void 0?P.factor2=Ie.factor2:P.factor2=Ie.factor1,e.angularSpeedGradients.push(P)}}var Fe=n.getVelocityGradients();if(Fe){e.velocityGradients=[];for(var Ke=0,nt=Fe;Ke<nt.length;Ke++){var rt=nt[Ke];P={gradient:rt.gradient,factor1:rt.factor1},rt.factor2!==void 0?P.factor2=rt.factor2:P.factor2=rt.factor1,e.velocityGradients.push(P)}}var ut=n.getDragGradients();if(ut){e.dragGradients=[];for(var qe=0,at=ut;qe<at.length;qe++){var ot=at[qe];P={gradient:ot.gradient,factor1:ot.factor1},ot.factor2!==void 0?P.factor2=ot.factor2:P.factor2=ot.factor1,e.dragGradients.push(P)}}var Je=n.getEmitRateGradients();if(Je){e.emitRateGradients=[];for(var dt=0,Ve=Je;dt<Ve.length;dt++){var $e=Ve[dt];P={gradient:$e.gradient,factor1:$e.factor1},$e.factor2!==void 0?P.factor2=$e.factor2:P.factor2=$e.factor1,e.emitRateGradients.push(P)}}var yt=n.getStartSizeGradients();if(yt){e.startSizeGradients=[];for(var Wt=0,Nt=yt;Wt<Nt.length;Wt++){var Qt=Nt[Wt];P={gradient:Qt.gradient,factor1:Qt.factor1},Qt.factor2!==void 0?P.factor2=Qt.factor2:P.factor2=Qt.factor1,e.startSizeGradients.push(P)}}var vt=n.getLifeTimeGradients();if(vt){e.lifeTimeGradients=[];for(var Jt=0,Xt=vt;Jt<Xt.length;Jt++){var zt=Xt[Jt];P={gradient:zt.gradient,factor1:zt.factor1},zt.factor2!==void 0?P.factor2=zt.factor2:P.factor2=zt.factor1,e.lifeTimeGradients.push(P)}}var Yt=n.getLimitVelocityGradients();if(Yt){e.limitVelocityGradients=[];for(var Et=0,Mt=Yt;Et<Mt.length;Et++){var $t=Mt[Et];P={gradient:$t.gradient,factor1:$t.factor1},$t.factor2!==void 0?P.factor2=$t.factor2:P.factor2=$t.factor1,e.limitVelocityGradients.push(P)}e.limitVelocityDamping=n.limitVelocityDamping}n.noiseTexture&&(e.noiseTexture=n.noiseTexture.serialize())},t._Parse=function(e,n,i,o){var a;a=i instanceof Bt.a?null:i;var s,d=R.a.GetClass("BABYLON.Texture");if(d&&a&&(e.texture?n.particleTexture=d.Parse(e.texture,a,o):e.textureName&&(n.particleTexture=new d(o+e.textureName,a,!1,e.invertY===void 0||e.invertY),n.particleTexture.name=e.textureName)),e.emitterId||e.emitterId===0||e.emitter!==void 0?e.emitterId&&a?n.emitter=a.getLastMeshByID(e.emitterId):n.emitter=u.e.FromArray(e.emitter):n.emitter=u.e.Zero(),n.isLocal=!!e.isLocal,e.renderingGroupId!==void 0&&(n.renderingGroupId=e.renderingGroupId),e.isBillboardBased!==void 0&&(n.isBillboardBased=e.isBillboardBased),e.billboardMode!==void 0&&(n.billboardMode=e.billboardMode),e.animations){for(var p=0;p<e.animations.length;p++){var y=e.animations[p],P=R.a.GetClass("BABYLON.Animation");P&&n.animations.push(P.Parse(y))}n.beginAnimationOnStart=e.beginAnimationOnStart,n.beginAnimationFrom=e.beginAnimationFrom,n.beginAnimationTo=e.beginAnimationTo,n.beginAnimationLoop=e.beginAnimationLoop}if(e.autoAnimate&&a&&a.beginAnimation(n,e.autoAnimateFrom,e.autoAnimateTo,e.autoAnimateLoop,e.autoAnimateSpeed||1),n.startDelay=0|e.startDelay,n.minAngularSpeed=e.minAngularSpeed,n.maxAngularSpeed=e.maxAngularSpeed,n.minSize=e.minSize,n.maxSize=e.maxSize,e.minScaleX&&(n.minScaleX=e.minScaleX,n.maxScaleX=e.maxScaleX,n.minScaleY=e.minScaleY,n.maxScaleY=e.maxScaleY),e.preWarmCycles!==void 0&&(n.preWarmCycles=e.preWarmCycles,n.preWarmStepOffset=e.preWarmStepOffset),e.minInitialRotation!==void 0&&(n.minInitialRotation=e.minInitialRotation,n.maxInitialRotation=e.maxInitialRotation),n.minLifeTime=e.minLifeTime,n.maxLifeTime=e.maxLifeTime,n.minEmitPower=e.minEmitPower,n.maxEmitPower=e.maxEmitPower,n.emitRate=e.emitRate,n.gravity=u.e.FromArray(e.gravity),e.noiseStrength&&(n.noiseStrength=u.e.FromArray(e.noiseStrength)),n.color1=M.b.FromArray(e.color1),n.color2=M.b.FromArray(e.color2),n.colorDead=M.b.FromArray(e.colorDead),n.updateSpeed=e.updateSpeed,n.targetStopDuration=e.targetStopDuration,n.blendMode=e.blendMode,e.colorGradients)for(var O=0,U=e.colorGradients;O<U.length;O++){var F=U[O];n.addColorGradient(F.gradient,M.b.FromArray(F.color1),F.color2?M.b.FromArray(F.color2):void 0)}if(e.rampGradients){for(var z=0,J=e.rampGradients;z<J.length;z++){var ie=J[z];n.addRampGradient(ie.gradient,M.a.FromArray(ie.color))}n.useRampGradients=e.useRampGradients}if(e.colorRemapGradients)for(var se=0,ce=e.colorRemapGradients;se<ce.length;se++){var ue=ce[se];n.addColorRemapGradient(ue.gradient,ue.factor1!==void 0?ue.factor1:ue.factor,ue.factor2)}if(e.alphaRemapGradients)for(var fe=0,ve=e.alphaRemapGradients;fe<ve.length;fe++){var Te=ve[fe];
8651n.addAlphaRemapGradient(Te.gradient,Te.factor1!==void 0?Te.factor1:Te.factor,Te.factor2)}if(e.sizeGradients)for(var Oe=0,Pe=e.sizeGradients;Oe<Pe.length;Oe++){var Ee=Pe[Oe];n.addSizeGradient(Ee.gradient,Ee.factor1!==void 0?Ee.factor1:Ee.factor,Ee.factor2)}if(e.angularSpeedGradients)for(var Se=0,Le=e.angularSpeedGradients;Se<Le.length;Se++){var xe=Le[Se];n.addAngularSpeedGradient(xe.gradient,xe.factor1!==void 0?xe.factor1:xe.factor,xe.factor2)}if(e.velocityGradients)for(var Ne=0,Ie=e.velocityGradients;Ne<Ie.length;Ne++){var Fe=Ie[Ne];n.addVelocityGradient(Fe.gradient,Fe.factor1!==void 0?Fe.factor1:Fe.factor,Fe.factor2)}if(e.dragGradients)for(var Ke=0,nt=e.dragGradients;Ke<nt.length;Ke++){var rt=nt[Ke];n.addDragGradient(rt.gradient,rt.factor1!==void 0?rt.factor1:rt.factor,rt.factor2)}if(e.emitRateGradients)for(var ut=0,qe=e.emitRateGradients;ut<qe.length;ut++){var at=qe[ut];n.addEmitRateGradient(at.gradient,at.factor1!==void 0?at.factor1:at.factor,at.factor2)}if(e.startSizeGradients)for(var ot=0,Je=e.startSizeGradients;ot<Je.length;ot++){var dt=Je[ot];n.addStartSizeGradient(dt.gradient,dt.factor1!==void 0?dt.factor1:dt.factor,dt.factor2)}if(e.lifeTimeGradients)for(var Ve=0,$e=e.lifeTimeGradients;Ve<$e.length;Ve++){var yt=$e[Ve];n.addLifeTimeGradient(yt.gradient,yt.factor1!==void 0?yt.factor1:yt.factor,yt.factor2)}if(e.limitVelocityGradients){for(var Wt=0,Nt=e.limitVelocityGradients;Wt<Nt.length;Wt++){var Qt=Nt[Wt];n.addLimitVelocityGradient(Qt.gradient,Qt.factor1!==void 0?Qt.factor1:Qt.factor,Qt.factor2)}n.limitVelocityDamping=e.limitVelocityDamping}if(e.noiseTexture&&a){var vt=R.a.GetClass("BABYLON.ProceduralTexture");n.noiseTexture=vt.Parse(e.noiseTexture,a,o)}if(e.particleEmitterType){switch(e.particleEmitterType.type){case"SphereParticleEmitter":s=new ba;break;case"SphereDirectedParticleEmitter":s=new fc;break;case"ConeEmitter":case"ConeParticleEmitter":s=new lc;break;case"CylinderParticleEmitter":s=new va;break;case"CylinderDirectedParticleEmitter":s=new uc;break;case"HemisphericParticleEmitter":s=new hc;break;case"PointParticleEmitter":s=new dc;break;case"MeshParticleEmitter":s=new Th;break;case"BoxEmitter":case"BoxParticleEmitter":default:s=new Lr}s.parse(e.particleEmitterType,a)}else(s=new Lr).parse(e,a);n.particleEmitterType=s,n.startSpriteCellID=e.startSpriteCellID,n.endSpriteCellID=e.endSpriteCellID,n.spriteCellWidth=e.spriteCellWidth,n.spriteCellHeight=e.spriteCellHeight,n.spriteCellChangeSpeed=e.spriteCellChangeSpeed,n.spriteRandomStartCell=e.spriteRandomStartCell},t.Parse=function(e,n,i,o){o===void 0&&(o=!1);var a,s=e.name,d=null,p=null;if(a=n instanceof Bt.a?n:n.getEngine(),e.customShader&&a.createEffectForParticles){var y=(p=e.customShader).shaderOptions.defines.length>0?p.shaderOptions.defines.join(`
8652`):"";d=a.createEffectForParticles(p.shaderPath.fragmentElement,p.shaderOptions.uniforms,p.shaderOptions.samplers,y)}var P=new t(s,e.capacity,n,d,e.isAnimationSheetEnabled);if(P.customShader=p,e.id&&(P.id=e.id),e.subEmitters){P.subEmitters=[];for(var O=0,U=e.subEmitters;O<U.length;O++){for(var F=[],z=0,J=U[O];z<J.length;z++){var ie=J[z];F.push(Co.Parse(ie,n,i))}P.subEmitters.push(F)}}return t._Parse(e,P,n,i),e.textureMask&&(P.textureMask=M.b.FromArray(e.textureMask)),e.preventAutoStart&&(P.preventAutoStart=e.preventAutoStart),o||P.preventAutoStart||P.start(),P},t.BILLBOARDMODE_Y=h.a.PARTICLES_BILLBOARDMODE_Y,t.BILLBOARDMODE_ALL=h.a.PARTICLES_BILLBOARDMODE_ALL,t.BILLBOARDMODE_STRETCHED=h.a.PARTICLES_BILLBOARDMODE_STRETCHED,t}(bo);Co._ParseParticleSystem=ln.Parse,je.a.ShadersStore.gpuUpdateParticlesPixelShader=`#version 300 es
8653void main() {
8654discard;
8655}
8656`;var ig=`#version 300 es
8657#define PI 3.14159
8658uniform float currentCount;
8659uniform float timeDelta;
8660uniform float stopFactor;
8661#ifndef LOCAL
8662uniform mat4 emitterWM;
8663#endif
8664uniform vec2 lifeTime;
8665uniform vec2 emitPower;
8666uniform vec2 sizeRange;
8667uniform vec4 scaleRange;
8668#ifndef COLORGRADIENTS
8669uniform vec4 color1;
8670uniform vec4 color2;
8671#endif
8672uniform vec3 gravity;
8673uniform sampler2D randomSampler;
8674uniform sampler2D randomSampler2;
8675uniform vec4 angleRange;
8676#ifdef BOXEMITTER
8677uniform vec3 direction1;
8678uniform vec3 direction2;
8679uniform vec3 minEmitBox;
8680uniform vec3 maxEmitBox;
8681#endif
8682#ifdef POINTEMITTER
8683uniform vec3 direction1;
8684uniform vec3 direction2;
8685#endif
8686#ifdef HEMISPHERICEMITTER
8687uniform float radius;
8688uniform float radiusRange;
8689uniform float directionRandomizer;
8690#endif
8691#ifdef SPHEREEMITTER
8692uniform float radius;
8693uniform float radiusRange;
8694#ifdef DIRECTEDSPHEREEMITTER
8695uniform vec3 direction1;
8696uniform vec3 direction2;
8697#else
8698uniform float directionRandomizer;
8699#endif
8700#endif
8701#ifdef CYLINDEREMITTER
8702uniform float radius;
8703uniform float height;
8704uniform float radiusRange;
8705#ifdef DIRECTEDCYLINDEREMITTER
8706uniform vec3 direction1;
8707uniform vec3 direction2;
8708#else
8709uniform float directionRandomizer;
8710#endif
8711#endif
8712#ifdef CONEEMITTER
8713uniform vec2 radius;
8714uniform float coneAngle;
8715uniform vec2 height;
8716uniform float directionRandomizer;
8717#endif
8718
8719in vec3 position;
8720#ifdef CUSTOMEMITTER
8721in vec3 initialPosition;
8722#endif
8723in float age;
8724in float life;
8725in vec4 seed;
8726in vec3 size;
8727#ifndef COLORGRADIENTS
8728in vec4 color;
8729#endif
8730in vec3 direction;
8731#ifndef BILLBOARD
8732in vec3 initialDirection;
8733#endif
8734#ifdef ANGULARSPEEDGRADIENTS
8735in float angle;
8736#else
8737in vec2 angle;
8738#endif
8739#ifdef ANIMATESHEET
8740in float cellIndex;
8741#ifdef ANIMATESHEETRANDOMSTART
8742in float cellStartOffset;
8743#endif
8744#endif
8745#ifdef NOISE
8746in vec3 noiseCoordinates1;
8747in vec3 noiseCoordinates2;
8748#endif
8749
8750out vec3 outPosition;
8751#ifdef CUSTOMEMITTER
8752out vec3 outInitialPosition;
8753#endif
8754out float outAge;
8755out float outLife;
8756out vec4 outSeed;
8757out vec3 outSize;
8758#ifndef COLORGRADIENTS
8759out vec4 outColor;
8760#endif
8761out vec3 outDirection;
8762#ifndef BILLBOARD
8763out vec3 outInitialDirection;
8764#endif
8765#ifdef ANGULARSPEEDGRADIENTS
8766out float outAngle;
8767#else
8768out vec2 outAngle;
8769#endif
8770#ifdef ANIMATESHEET
8771out float outCellIndex;
8772#ifdef ANIMATESHEETRANDOMSTART
8773out float outCellStartOffset;
8774#endif
8775#endif
8776#ifdef NOISE
8777out vec3 outNoiseCoordinates1;
8778out vec3 outNoiseCoordinates2;
8779#endif
8780#ifdef SIZEGRADIENTS
8781uniform sampler2D sizeGradientSampler;
8782#endif
8783#ifdef ANGULARSPEEDGRADIENTS
8784uniform sampler2D angularSpeedGradientSampler;
8785#endif
8786#ifdef VELOCITYGRADIENTS
8787uniform sampler2D velocityGradientSampler;
8788#endif
8789#ifdef LIMITVELOCITYGRADIENTS
8790uniform sampler2D limitVelocityGradientSampler;
8791uniform float limitVelocityDamping;
8792#endif
8793#ifdef DRAGGRADIENTS
8794uniform sampler2D dragGradientSampler;
8795#endif
8796#ifdef NOISE
8797uniform vec3 noiseStrength;
8798uniform sampler2D noiseSampler;
8799#endif
8800#ifdef ANIMATESHEET
8801uniform vec3 cellInfos;
8802#endif
8803vec3 getRandomVec3(float offset) {
8804return texture(randomSampler2,vec2(float(gl_VertexID)*offset/currentCount,0)).rgb;
8805}
8806vec4 getRandomVec4(float offset) {
8807return texture(randomSampler,vec2(float(gl_VertexID)*offset/currentCount,0));
8808}
8809void main() {
8810float newAge=age+timeDelta;
8811
8812if (newAge>=life && stopFactor != 0.) {
8813vec3 newPosition;
8814vec3 newDirection;
8815
8816vec4 randoms=getRandomVec4(seed.x);
8817
8818outLife=lifeTime.x+(lifeTime.y-lifeTime.x)*randoms.r;
8819outAge=newAge-life;
8820
8821outSeed=seed;
8822
8823#ifdef SIZEGRADIENTS
8824outSize.x=texture(sizeGradientSampler,vec2(0,0)).r;
8825#else
8826outSize.x=sizeRange.x+(sizeRange.y-sizeRange.x)*randoms.g;
8827#endif
8828outSize.y=scaleRange.x+(scaleRange.y-scaleRange.x)*randoms.b;
8829outSize.z=scaleRange.z+(scaleRange.w-scaleRange.z)*randoms.a;
8830#ifndef COLORGRADIENTS
8831
8832outColor=color1+(color2-color1)*randoms.b;
8833#endif
8834
8835#ifndef ANGULARSPEEDGRADIENTS
8836outAngle.y=angleRange.x+(angleRange.y-angleRange.x)*randoms.a;
8837outAngle.x=angleRange.z+(angleRange.w-angleRange.z)*randoms.r;
8838#else
8839outAngle=angleRange.z+(angleRange.w-angleRange.z)*randoms.r;
8840#endif
8841
8842#ifdef POINTEMITTER
8843vec3 randoms2=getRandomVec3(seed.y);
8844vec3 randoms3=getRandomVec3(seed.z);
8845newPosition=vec3(0,0,0);
8846newDirection=direction1+(direction2-direction1)*randoms3;
8847#elif defined(BOXEMITTER)
8848vec3 randoms2=getRandomVec3(seed.y);
8849vec3 randoms3=getRandomVec3(seed.z);
8850newPosition=minEmitBox+(maxEmitBox-minEmitBox)*randoms2;
8851newDirection=direction1+(direction2-direction1)*randoms3;
8852#elif defined(HEMISPHERICEMITTER)
8853vec3 randoms2=getRandomVec3(seed.y);
8854vec3 randoms3=getRandomVec3(seed.z);
8855
8856float phi=2.0*PI*randoms2.x;
8857float theta=acos(2.0*randoms2.y-1.0);
8858float randX=cos(phi)*sin(theta);
8859float randY=cos(theta);
8860float randZ=sin(phi)*sin(theta);
8861newPosition=(radius-(radius*radiusRange*randoms2.z))*vec3(randX,abs(randY),randZ);
8862newDirection=newPosition+directionRandomizer*randoms3;
8863#elif defined(SPHEREEMITTER)
8864vec3 randoms2=getRandomVec3(seed.y);
8865vec3 randoms3=getRandomVec3(seed.z);
8866
8867float phi=2.0*PI*randoms2.x;
8868float theta=acos(2.0*randoms2.y-1.0);
8869float randX=cos(phi)*sin(theta);
8870float randY=cos(theta);
8871float randZ=sin(phi)*sin(theta);
8872newPosition=(radius-(radius*radiusRange*randoms2.z))*vec3(randX,randY,randZ);
8873#ifdef DIRECTEDSPHEREEMITTER
8874newDirection=direction1+(direction2-direction1)*randoms3;
8875#else
8876
8877newDirection=newPosition+directionRandomizer*randoms3;
8878#endif
8879#elif defined(CYLINDEREMITTER)
8880vec3 randoms2=getRandomVec3(seed.y);
8881vec3 randoms3=getRandomVec3(seed.z);
8882
8883float yPos=(randoms2.x-0.5)*height;
8884float angle=randoms2.y*PI*2.;
8885float inverseRadiusRangeSquared=((1.-radiusRange)*(1.-radiusRange));
8886float positionRadius=radius*sqrt(inverseRadiusRangeSquared+(randoms2.z*(1.-inverseRadiusRangeSquared)));
8887float xPos=positionRadius*cos(angle);
8888float zPos=positionRadius*sin(angle);
8889newPosition=vec3(xPos,yPos,zPos);
8890#ifdef DIRECTEDCYLINDEREMITTER
8891newDirection=direction1+(direction2-direction1)*randoms3;
8892#else
8893
8894angle=angle+((randoms3.x-0.5)*PI);
8895newDirection=vec3(cos(angle),randoms3.y-0.5,sin(angle));
8896newDirection=normalize(newDirection);
8897#endif
8898#elif defined(CONEEMITTER)
8899vec3 randoms2=getRandomVec3(seed.y);
8900float s=2.0*PI*randoms2.x;
8901#ifdef CONEEMITTERSPAWNPOINT
8902float h=0.0001;
8903#else
8904float h=randoms2.y*height.y;
8905
8906h=1.-h*h;
8907#endif
8908float lRadius=radius.x-radius.x*randoms2.z*radius.y;
8909lRadius=lRadius*h;
8910float randX=lRadius*sin(s);
8911float randZ=lRadius*cos(s);
8912float randY=h*height.x;
8913newPosition=vec3(randX,randY,randZ);
8914
8915if (abs(cos(coneAngle)) == 1.0) {
8916newDirection=vec3(0.,1.0,0.);
8917} else {
8918vec3 randoms3=getRandomVec3(seed.z);
8919newDirection=normalize(newPosition+directionRandomizer*randoms3);
8920}
8921#elif defined(CUSTOMEMITTER)
8922newPosition=initialPosition;
8923outInitialPosition=initialPosition;
8924#else
8925
8926newPosition=vec3(0.,0.,0.);
8927
8928newDirection=2.0*(getRandomVec3(seed.w)-vec3(0.5,0.5,0.5));
8929#endif
8930float power=emitPower.x+(emitPower.y-emitPower.x)*randoms.a;
8931#ifdef LOCAL
8932outPosition=newPosition;
8933#else
8934outPosition=(emitterWM*vec4(newPosition,1.)).xyz;
8935#endif
8936#ifdef CUSTOMEMITTER
8937outDirection=direction;
8938#ifndef BILLBOARD
8939outInitialDirection=direction;
8940#endif
8941#else
8942#ifdef LOCAL
8943vec3 initial=newDirection;
8944#else
8945vec3 initial=(emitterWM*vec4(newDirection,0.)).xyz;
8946#endif
8947outDirection=initial*power;
8948#ifndef BILLBOARD
8949outInitialDirection=initial;
8950#endif
8951#endif
8952#ifdef ANIMATESHEET
8953outCellIndex=cellInfos.x;
8954#ifdef ANIMATESHEETRANDOMSTART
8955outCellStartOffset=randoms.a*outLife;
8956#endif
8957#endif
8958#ifdef NOISE
8959outNoiseCoordinates1=noiseCoordinates1;
8960outNoiseCoordinates2=noiseCoordinates2;
8961#endif
8962} else {
8963float directionScale=timeDelta;
8964outAge=newAge;
8965float ageGradient=newAge/life;
8966#ifdef VELOCITYGRADIENTS
8967directionScale*=texture(velocityGradientSampler,vec2(ageGradient,0)).r;
8968#endif
8969#ifdef DRAGGRADIENTS
8970directionScale*=1.0-texture(dragGradientSampler,vec2(ageGradient,0)).r;
8971#endif
8972#if defined(CUSTOMEMITTER)
8973outPosition=position+(direction-position)*ageGradient;
8974outInitialPosition=initialPosition;
8975#else
8976outPosition=position+direction*directionScale;
8977#endif
8978outLife=life;
8979outSeed=seed;
8980#ifndef COLORGRADIENTS
8981outColor=color;
8982#endif
8983#ifdef SIZEGRADIENTS
8984outSize.x=texture(sizeGradientSampler,vec2(ageGradient,0)).r;
8985outSize.yz=size.yz;
8986#else
8987outSize=size;
8988#endif
8989#ifndef BILLBOARD
8990outInitialDirection=initialDirection;
8991#endif
8992#ifdef CUSTOMEMITTER
8993outDirection=direction;
8994#else
8995vec3 updatedDirection=direction+gravity*timeDelta;
8996#ifdef LIMITVELOCITYGRADIENTS
8997float limitVelocity=texture(limitVelocityGradientSampler,vec2(ageGradient,0)).r;
8998float currentVelocity=length(updatedDirection);
8999if (currentVelocity>limitVelocity) {
9000updatedDirection=updatedDirection*limitVelocityDamping;
9001}
9002#endif
9003outDirection=updatedDirection;
9004#ifdef NOISE
9005float fetchedR=texture(noiseSampler,vec2(noiseCoordinates1.x,noiseCoordinates1.y)*vec2(0.5)+vec2(0.5)).r;
9006float fetchedG=texture(noiseSampler,vec2(noiseCoordinates1.z,noiseCoordinates2.x)*vec2(0.5)+vec2(0.5)).r;
9007float fetchedB=texture(noiseSampler,vec2(noiseCoordinates2.y,noiseCoordinates2.z)*vec2(0.5)+vec2(0.5)).r;
9008vec3 force=vec3(2.*fetchedR-1.,2.*fetchedG-1.,2.*fetchedB-1.)*noiseStrength;
9009outDirection=outDirection+force*timeDelta;
9010outNoiseCoordinates1=noiseCoordinates1;
9011outNoiseCoordinates2=noiseCoordinates2;
9012#endif
9013#endif
9014#ifdef ANGULARSPEEDGRADIENTS
9015float angularSpeed=texture(angularSpeedGradientSampler,vec2(ageGradient,0)).r;
9016outAngle=angle+angularSpeed*timeDelta;
9017#else
9018outAngle=vec2(angle.x+angle.y*timeDelta,angle.y);
9019#endif
9020#ifdef ANIMATESHEET
9021float offsetAge=outAge;
9022float dist=cellInfos.y-cellInfos.x;
9023#ifdef ANIMATESHEETRANDOMSTART
9024outCellStartOffset=cellStartOffset;
9025offsetAge+=cellStartOffset;
9026#else
9027float cellStartOffset=0.;
9028#endif
9029float ratio=clamp(mod(cellStartOffset+cellInfos.z*offsetAge,life)/life,0.,1.0);
9030outCellIndex=float(int(cellInfos.x+ratio*dist));
9031#endif
9032}
9033}`;je.a.ShadersStore.gpuUpdateParticlesVertexShader=ig;var rg=`#ifdef CLIPPLANE
9034in float fClipDistance;
9035#endif
9036#ifdef CLIPPLANE2
9037in float fClipDistance2;
9038#endif
9039#ifdef CLIPPLANE3
9040in float fClipDistance3;
9041#endif
9042#ifdef CLIPPLANE4
9043in float fClipDistance4;
9044#endif
9045#ifdef CLIPPLANE5
9046in float fClipDistance5;
9047#endif
9048#ifdef CLIPPLANE6
9049in float fClipDistance6;
9050#endif`;je.a.IncludesShadersStore.clipPlaneFragmentDeclaration2=rg;var og=`#version 300 es
9051uniform sampler2D diffuseSampler;
9052in vec2 vUV;
9053in vec4 vColor;
9054out vec4 outFragColor;
9055#include<clipPlaneFragmentDeclaration2>
9056#include<imageProcessingDeclaration>
9057#include<helperFunctions>
9058#include<imageProcessingFunctions>
9059void main() {
9060#include<clipPlaneFragment>
9061vec4 textureColor=texture(diffuseSampler,vUV);
9062outFragColor=textureColor*vColor;
9063#ifdef BLENDMULTIPLYMODE
9064float alpha=vColor.a*textureColor.a;
9065outFragColor.rgb=outFragColor.rgb*alpha+vec3(1.0)*(1.0-alpha);
9066#endif
9067
9068
9069#ifdef IMAGEPROCESSINGPOSTPROCESS
9070outFragColor.rgb=toLinearSpace(outFragColor.rgb);
9071#else
9072#ifdef IMAGEPROCESSING
9073outFragColor.rgb=toLinearSpace(outFragColor.rgb);
9074outFragColor=applyImageProcessing(outFragColor);
9075#endif
9076#endif
9077}
9078`;je.a.ShadersStore.gpuRenderParticlesPixelShader=og;var ag=`#ifdef CLIPPLANE
9079uniform vec4 vClipPlane;
9080out float fClipDistance;
9081#endif
9082#ifdef CLIPPLANE2
9083uniform vec4 vClipPlane2;
9084out float fClipDistance2;
9085#endif
9086#ifdef CLIPPLANE3
9087uniform vec4 vClipPlane3;
9088out float fClipDistance3;
9089#endif
9090#ifdef CLIPPLANE4
9091uniform vec4 vClipPlane4;
9092out float fClipDistance4;
9093#endif
9094#ifdef CLIPPLANE5
9095uniform vec4 vClipPlane5;
9096out float fClipDistance5;
9097#endif
9098#ifdef CLIPPLANE6
9099uniform vec4 vClipPlane6;
9100out float fClipDistance6;
9101#endif`;je.a.IncludesShadersStore.clipPlaneVertexDeclaration2=ag;var sg=`#version 300 es
9102uniform mat4 view;
9103uniform mat4 projection;
9104uniform vec2 translationPivot;
9105uniform vec3 worldOffset;
9106#ifdef LOCAL
9107uniform mat4 emitterWM;
9108#endif
9109
9110in vec3 position;
9111in float age;
9112in float life;
9113in vec3 size;
9114#ifndef BILLBOARD
9115in vec3 initialDirection;
9116#endif
9117#ifdef BILLBOARDSTRETCHED
9118in vec3 direction;
9119#endif
9120in float angle;
9121#ifdef ANIMATESHEET
9122in float cellIndex;
9123#endif
9124in vec2 offset;
9125in vec2 uv;
9126out vec2 vUV;
9127out vec4 vColor;
9128out vec3 vPositionW;
9129#if defined(BILLBOARD) && !defined(BILLBOARDY) && !defined(BILLBOARDSTRETCHED)
9130uniform mat4 invView;
9131#endif
9132#include<clipPlaneVertexDeclaration2>
9133#ifdef COLORGRADIENTS
9134uniform sampler2D colorGradientSampler;
9135#else
9136uniform vec4 colorDead;
9137in vec4 color;
9138#endif
9139#ifdef ANIMATESHEET
9140uniform vec3 sheetInfos;
9141#endif
9142#ifdef BILLBOARD
9143uniform vec3 eyePosition;
9144#endif
9145vec3 rotate(vec3 yaxis,vec3 rotatedCorner) {
9146vec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));
9147vec3 zaxis=normalize(cross(yaxis,xaxis));
9148vec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);
9149vec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);
9150vec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);
9151mat3 rotMatrix=mat3(row0,row1,row2);
9152vec3 alignedCorner=rotMatrix*rotatedCorner;
9153#ifdef LOCAL
9154return ((emitterWM*vec4(position,1.0)).xyz+worldOffset)+alignedCorner;
9155#else
9156return (position+worldOffset)+alignedCorner;
9157#endif
9158}
9159#ifdef BILLBOARDSTRETCHED
9160vec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {
9161vec3 normalizedToCamera=normalize(toCamera);
9162vec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));
9163vec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));
9164vec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);
9165vec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);
9166vec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);
9167mat3 rotMatrix=mat3(row0,row1,row2);
9168vec3 alignedCorner=rotMatrix*rotatedCorner;
9169#ifdef LOCAL
9170return ((emitterWM*vec4(position,1.0)).xyz+worldOffset)+alignedCorner;
9171#else
9172return (position+worldOffset)+alignedCorner;
9173#endif
9174}
9175#endif
9176void main() {
9177#ifdef ANIMATESHEET
9178float rowOffset=floor(cellIndex/sheetInfos.z);
9179float columnOffset=cellIndex-rowOffset*sheetInfos.z;
9180vec2 uvScale=sheetInfos.xy;
9181vec2 uvOffset=vec2(uv.x ,1.0-uv.y);
9182vUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;
9183#else
9184vUV=uv;
9185#endif
9186float ratio=age/life;
9187#ifdef COLORGRADIENTS
9188vColor=texture(colorGradientSampler,vec2(ratio,0));
9189#else
9190vColor=color*vec4(1.0-ratio)+colorDead*vec4(ratio);
9191#endif
9192vec2 cornerPos=(offset-translationPivot)*size.yz*size.x+translationPivot;
9193#ifdef BILLBOARD
9194vec4 rotatedCorner;
9195rotatedCorner.w=0.;
9196#ifdef BILLBOARDY
9197rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
9198rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
9199rotatedCorner.y=0.;
9200vec3 yaxis=(position+worldOffset)-eyePosition;
9201yaxis.y=0.;
9202vPositionW=rotate(normalize(yaxis),rotatedCorner.xyz);
9203vec4 viewPosition=(view*vec4(vPositionW,1.0));
9204#elif defined(BILLBOARDSTRETCHED)
9205rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
9206rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
9207rotatedCorner.z=0.;
9208vec3 toCamera=(position+worldOffset)-eyePosition;
9209vPositionW=rotateAlign(toCamera,rotatedCorner.xyz);
9210vec4 viewPosition=(view*vec4(vPositionW,1.0));
9211#else
9212
9213rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
9214rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
9215rotatedCorner.z=0.;
9216
9217#ifdef LOCAL
9218vec4 viewPosition=view*vec4(((emitterWM*vec4(position,1.0)).xyz+worldOffset),1.0)+rotatedCorner;
9219#else
9220vec4 viewPosition=view*vec4((position+worldOffset),1.0)+rotatedCorner;
9221#endif
9222vPositionW=(invView*viewPosition).xyz;
9223#endif
9224#else
9225
9226vec3 rotatedCorner;
9227rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
9228rotatedCorner.y=0.;
9229rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
9230vec3 yaxis=normalize(initialDirection);
9231vPositionW=rotate(yaxis,rotatedCorner);
9232
9233vec4 viewPosition=view*vec4(vPositionW,1.0);
9234#endif
9235gl_Position=projection*viewPosition;
9236
9237#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)
9238vec4 worldPos=vec4(vPositionW,1.0);
9239#endif
9240#include<clipPlaneVertex>
9241}`;je.a.ShadersStore.gpuRenderParticlesVertexShader=sg;var or=function(r){function t(e,n,i,o,a){o===void 0&&(o=!1),a===void 0&&(a=null);var s=r.call(this,e)||this;s.layerMask=268435455,s._accumulatedCount=0,s._targetIndex=0,s._currentRenderId=-1,s._started=!1,s._stopped=!1,s._timeDelta=0,s._actualFrame=0,s._rawTextureWidth=256,s.onDisposeObservable=new x.c,s.onStoppedObservable=new x.c,s.forceDepthWrite=!1,s._preWarmDone=!1,s.isLocal=!1,s._onBeforeDrawParticlesObservable=null,i&&i.getClassName()!=="Scene"?(s._engine=i,s.defaultProjectionMatrix=u.a.PerspectiveFovLH(.8,1,.1,100)):(s._scene=i||te.a.LastCreatedScene,s._engine=s._scene.getEngine(),s.uniqueId=s._scene.getUniqueId(),s._scene.particleSystems.push(s)),s._customEffect={0:a},s._attachImageProcessingConfiguration(null),n.randomTextureSize||delete n.randomTextureSize;var d=Object(c.a)({capacity:5e4,randomTextureSize:s._engine.getCaps().maxTextureSize},n),p=n;isFinite(p)&&(d.capacity=p),s._capacity=d.capacity,s._activeCount=d.capacity,s._currentActiveCount=0,s._isAnimationSheetEnabled=o,s._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:[]},s.particleEmitterType=new Lr;for(var y=Math.min(s._engine.getCaps().maxTextureSize,d.randomTextureSize),P=[],O=0;O<y;++O)P.push(Math.random()),P.push(Math.random()),P.push(Math.random()),P.push(Math.random());for(s._randomTexture=new $n(new Float32Array(P),y,1,h.a.TEXTUREFORMAT_RGBA,i,!1,!1,h.a.TEXTURE_NEAREST_SAMPL
9241INGMODE,h.a.TEXTURETYPE_FLOAT),s._randomTexture.wrapU=h.a.TEXTURE_WRAP_ADDRESSMODE,s._randomTexture.wrapV=h.a.TEXTURE_WRAP_ADDRESSMODE,P=[],O=0;O<y;++O)P.push(Math.random()),P.push(Math.random()),P.push(Math.random()),P.push(Math.random());return s._randomTexture2=new $n(new Float32Array(P),y,1,h.a.TEXTUREFORMAT_RGBA,i,!1,!1,h.a.TEXTURE_NEAREST_SAMPLINGMODE,h.a.TEXTURETYPE_FLOAT),s._randomTexture2.wrapU=h.a.TEXTURE_WRAP_ADDRESSMODE,s._randomTexture2.wrapV=h.a.TEXTURE_WRAP_ADDRESSMODE,s._randomTextureSize=y,s}return Object(c.d)(t,r),Object.defineProperty(t,"IsSupported",{get:function(){return!!te.a.LastCreatedEngine&&te.a.LastCreatedEngine.webGLVersion>1},enumerable:!1,configurable:!0}),t.prototype.getCapacity=function(){return this._capacity},Object.defineProperty(t.prototype,"activeParticleCount",{get:function(){return this._activeCount},set:function(e){this._activeCount=Math.min(e,this._capacity)},enumerable:!1,configurable:!0}),t.prototype.isReady=function(){return this._updateEffect?!!(this.emitter&&this._updateEffect.isReady()&&(!this._imageProcessingConfiguration||this._imageProcessingConfiguration.isReady())&&this._getEffect().isReady()&&this.particleTexture&&this.particleTexture.isReady()):(this._recreateUpdateEffect(),this._recreateRenderEffect(),!1)},t.prototype.isStarted=function(){return this._started},t.prototype.isStopped=function(){return this._stopped},t.prototype.isStopping=function(){return!1},t.prototype.getActiveCount=function(){return this._currentActiveCount},t.prototype.start=function(e){var n=this;if(e===void 0&&(e=this.startDelay),!this.targetStopDuration&&this._hasTargetStopDurationDependantGradient())throw"Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";e?setTimeout(function(){n.start(0)},e):(this._started=!0,this._stopped=!1,this._preWarmDone=!1,this.beginAnimationOnStart&&this.animations&&this.animations.length>0&&this._scene&&this._scene.beginAnimation(this,this.beginAnimationFrom,this.beginAnimationTo,this.beginAnimationLoop))},t.prototype.stop=function(){this._stopped||(this._stopped=!0)},t.prototype.reset=function(){this._releaseBuffers(),this._releaseVAOs(),this._currentActiveCount=0,this._targetIndex=0},t.prototype.getClassName=function(){return"GPUParticleSystem"},t.prototype.getCustomEffect=function(e){var n;return e===void 0&&(e=0),(n=this._customEffect[e])!==null&&n!==void 0?n:this._customEffect[0]}
9241,t.prototype.setCustomEffect=function(e,n){n===void 0&&(n=0),this._customEffect[n]=e},Object.defineProperty(t.prototype,"onBeforeDrawParticlesObservable",{get:function(){return this._onBeforeDrawParticlesObservable||(this._onBeforeDrawParticlesObservable=new x.c),this._onBeforeDrawParticlesObservable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vertexShaderName",{get:function(){return"gpuRenderParticles"},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,i){this._colorGradients||(this._colorGradients=[]);var o=new Lc(e,n);return this._colorGradients.push(o),this._refreshColorGradient(!0),this._releaseBuffers(),this},t.prototype._refreshColorGradient=function(e){e===void 0&&(e=!1),this._colorGradients&&(e&&this._colorGradients.sort(function(n,i){return n.gradient<i.gradient?-1:n.gradient>i.gradient?1:0}),this._colorGradientsTexture&&(this._colorGradientsTexture.dispose(),this._colorGradientsTexture=null))},t.prototype.forceRefreshGradients=function(){this._refreshColorGradient(),this._refreshFactorGradient(this._sizeGradients,"_sizeGradientsTexture"),this._refreshFactorGradient(this._angularSpeedGradients,"_angularSpeedGradientsTexture"),this._refreshFactorGradient(this._velocityGradients,"_velocityGradientsTexture"),this._refreshFactorGradient(this._limitVelocityGradients,"_limitVelocityGradientsTexture"),this._refreshFactorGradient(this._dragGradients,"_dragGradientsTexture"),this.reset()},t.prototype.removeColorGradient=function(e){return this._removeGradientAndTexture(e,this._colorGradients,this._colorGradientsTexture),this._colorGradientsTexture=null,this},t.prototype._addFactorGradient=function(e,n,i){var o=new Nc(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){i===void 0&&(i=!1),e&&(i&&e.sort(function(o,a){return o.gradient<a.gradient?-1:o.gradient>a.gradient?1:0}),this[n]&&(this[n].dispose(),this[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(e,n,i){return this},t.prototype.removeEmitRateGradient=function(e){return this},t.prototype.addStartSizeGradient=function(e,n,i){return this},t.prototype.removeStartSizeGradient=function(e){return this},t.prototype.addColorRemapGradient=function(e,n,i){return this},t.prototype.removeColorRemapGradient=function(){return this}
9241,t.prototype.addAlphaRemapGradient=function(e,n,i){return this},t.prototype.removeAlphaRemapGradient=function(){return this},t.prototype.addRampGradient=function(e,n){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(e,n,i){return this},t.prototype.removeLifeTimeGradient=function(e){return this},t.prototype._reset=function(){this._releaseBuffers()},t.prototype._createUpdateVAO=function(e){var n={};n.position=e.createVertexBuffer("position",0,3);var i=3;this.particleEmitterType instanceof Nr&&(n.initialPosition=e.createVertexBuffer("initialPosition",i,3),i+=3),n.age=e.createVertexBuffer("age",i,1),i+=1,n.life=e.createVertexBuffer("life",i,1),i+=1,n.seed=e.createVertexBuffer("seed",i,4),i+=4,n.size=e.createVertexBuffer("size",i,3),i+=3,this._colorGradientsTexture||(n.color=e.createVertexBuffer("color",i,4),i+=4),n.direction=e.createVertexBuffer("direction",i,3),i+=3,this._isBillboardBased||(n.initialDirection=e.createVertexBuffer("initialDirection",i,3),i+=3),this._angularSpeedGradientsTexture?(n.angle=e.createVertexBuffer("angle",i,1),i+=1):(n.angle=e.createVertexBuffer("angle",i,2),i+=2),this._isAnimationSheetEnabled&&(n.cellIndex=e.createVertexBuffer("cellIndex",i,1),i+=1,this.spriteRandomStartCell&&(n.cellStartOffset=e.createVertexBuffer("cellStartOffset",i,1),i+=1)),this.noiseTexture&&(n.noiseCoordinates1=e.createVertexBuffer("noiseCoordinates1",i,3),i+=3,n.noiseCoordinates2=e.createVertexBuffer("noiseCoordinates2",i,3),i+=3);var o=this._engine.recordVertexArrayObject(n,null,this._updateEffect);return this._engine.bindArrayBuffer(null),o},t.prototype._createRenderVAO=function(e,n){var i={};i.position=e.createVertexBuffer("position",0,3,this._attributesStrideSize,!0);var o=3;this.particleEmitterType instanceof Nr&&(o+=3),i.age=e.createVertexBuffer("age",o,1,this._attributesStrideSize,!0),o+=1,i.life=e.createVertexBuffer("life",o,1,this._attributesStrideSize,!0),o+=5,i.size=e.createVertexBuffer("size",o,3,this._attributesStrideSize,!0),o+=3,this._colorGradientsTexture||(i.color=e.createVertexBuffer("color",o,4,this._attributesStrideSize,!0),o+=4),this.billboardMode===ln.BILLBOARDMODE_STRETCHED&&(i.direction=e.createVertexBuffer("direction",o,3,this._attributesStrideSize,!0)),o+=3,this._isBillboardBased||(i.initialDirection=e.createVertexBuffer("initialDirection",o,3,this._attributesStrideSize,!0),o+=3),i.angle=e.createVertexBuffer("angle",o,1,this._attributesStrideSize,!0),this._angularSpeedGradientsTexture?o++:o+=2,this._isAnimationSheetEnabled&&(i.cellIndex=e.createVertexBuffer("cellIndex",o,1,this._attributesStrideSize,!0),o+=1,this.spriteRandomStartCell&&(i.cellStartOffset=e.createVertexBuffer("cellStartOffset",o,1,this._attributesStrideSize,!0),o+=1)),this.noiseTexture&&(i.noiseCoordinates1=e.createVertexBuffer("noiseCoordinates1",o,3,this._attributesStrideSize,!0),o+=3,i.noiseCoordinates2=e.createVertexBuffer("noiseCoordinates2",o,3,this._attributesStrideSize,!0),o+=3),i.offset=n.createVertexBuffer("offset",0,2),i.uv=n.createVertexBuffer("uv",2,2);var a=this._engine.recordVertexArrayObject(i,null,this._getEffect());return this._engine.bindArrayBuffer(null),a},t.prototype._initialize=function(e){if(e===void 0&&(e=!1),!this._buffer0||e){var n=this._engine,i=new Array;this._attributesStrideSize=21,this._targetIndex=0,this.particleEmitterType instanceof Nr&&(this._attributesStrideSize+=3),this.isBillboardBased||(this._attributesStrideSize+=3),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);for(var o=this.particleEmitterType instanceof Nr,a=u.c.Vector3[0],s=0;s<this._capacity;s++)i.push(0),i.push(0),i.push(0),o&&(this.particleEmitterType.particlePositionGenerator(s,null,a),i.push(a.x),i.push(a.y),i.push(a.z)),i.push(0),i.push(0),i.push(Math.random()),i.push(Math.random()),i.push(Math.random()),i.push(Math.random()),i.push(0),i.push(0),i.push(0),this._colorGradientsTexture||(i.push(0),i.push(0),i.push(0),i.push(0)),o?(this.particleEmitterType.particleDestinationGenerator(s,null,a),i.push(a.x),i.push(a.y),i.push(a.z)):(i.push(0),i.push(0),i.push(0)),this.isBillboardBased||(i.push(0),i.push(0),i.push(0)),i.push(0),this._angularSpeedGradientsTexture||i.push(0),this._isAnimationSheetEnabled&&(i.push(0),this.spriteRandomStartCell&&i.push(0)),this.noiseTexture&&(i.push(Math.random()),i.push(Math.random()),i.push(Math.random()),i.push(Math.random()),i.push(Math.random()),i.push(Math.random()));var d=new Float32Array([.5,.5,1,1,-.5,.5,0,1,-.5,-.5,0,0,.5,-.5,1,0]);this._buffer0=new Me.a(n,i,!1,this._attributesStrideSize),this._buffer1=new Me.a(n,i,!1,this._attributesStrideSize),this._spriteBuffer=new Me.a(n,d,!1,4),this._updateVAO=[],this._updateVAO.push(this._createUpdateVAO(this._buffer0)),this._updateVAO.push(this._createUpdateVAO(this._buffer1)),this._renderVAO=[],this._renderVAO.push(this._createRenderVAO(this._buffer1,this._spriteBuffer)),this._renderVAO.push(this._createRenderVAO(this._buffer0,this._spriteBuffer)),this._sourceBuffer=this._buffer0,this._targetBuffer=this._buffer1}},t.prototype._recreateUpdateEffect=function(){var e=this.particleEmitterType?this.particleEmitterType.getEffectDefines():"";this._isBillboardBased&&(e+=`
9242#define BILLBOARD`),this._colorGradientsTexture&&(e+=`
9243#define COLORGRADIENTS`),this._sizeGradientsTexture&&(e+=`
9244#define SIZEGRADIENTS`),this._angularSpeedGradientsTexture&&(e+=`
9245#define ANGULARSPEEDGRADIENTS`),this._velocityGradientsTexture&&(e+=`
9246#define VELOCITYGRADIENTS`),this._limitVelocityGradientsTexture&&(e+=`
9247#define LIMITVELOCITYGRADIENTS`),this._dragGradientsTexture&&(e+=`
9248#define DRAGGRADIENTS`),this.isAnimationSheetEnabled&&(e+=`
9249#define ANIMATESHEET`,this.spriteRandomStartCell&&(e+=`
9250#define ANIMATESHEETRANDOMSTART`)),this.noiseTexture&&(e+=`
9251#define NOISE`),this.isLocal&&(e+=`
9252#define LOCAL`),this._updateEffect&&this._updateEffectOptions.defines===e||(this._updateEffectOptions.transformFeedbackVaryings=["outPosition"],this.particleEmitterType instanceof Nr&&this._updateEffectOptions.transformFeedbackVaryings.push("outInitialPosition"),this._updateEffectOptions.transformFeedbackVaryings.push("outAge"),this._updateEffectOptions.transformFeedbackVaryings.push("outLife"),this._updateEffectOptions.transformFeedbackVaryings.push("outSeed"),this._updateEffectOptions.transformFeedbackVaryings.push("outSize"),this._colorGradientsTexture||this._updateEffectOptions.transformFeedbackVaryings.push("outColor"),this._updateEffectOptions.transformFeedbackVaryings.push("outDirection"),this._isBillboardBased||this._updateEffectOptions.transformFeedbackVaryings.push("outInitialDirection"),this._updateEffectOptions.transformFeedbackVaryings.push("outAngle"),this.isAnimationSheetEnabled&&(this._updateEffectOptions.transformFeedbackVaryings.push("outCellIndex"),this.spriteRandomStartCell&&this._updateEffectOptions.transformFeedbackVaryings.push("outCellStartOffset")),this.noiseTexture&&(this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates1"),this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates2")),this._updateEffectOptions.defines=e,this._updateEffect=new je.a("gpuUpdateParticles",this._updateEffectOptions,this._engine))},t.prototype._getEffect=function(){var e;return(e=this.getCustomEffect())!==null&&e!==void 0?e:this._renderEffect},t.prototype.fillDefines=function(e,n){if(this._scene&&(this._scene.clipPlane&&e.push("#define CLIPPLANE"),this._scene.clipPlane2&&e.push("#define CLIPPLANE2"),this._scene.clipPlane3&&e.push("#define CLIPPLANE3"),this._scene.clipPlane4&&e.push("#define CLIPPLANE4"),this._scene.clipPlane5&&e.push("#define CLIPPLANE5"),this._scene.clipPlane6&&e.push("#define CLIPPLANE6")),this.blendMode===ln.BLENDMODE_MULTIPLY&&e.push("#define BLENDMULTIPLYMODE"),this.isLocal&&e.push("#define LOCAL"),this._isBillboardBased)switch(e.push("#define BILLBOARD"),this.billboardMode){case ln.BILLBOARDMODE_Y:e.push("#define BILLBOARDY");break;case ln.BILLBOARDMODE_STRETCHED:e.push("#define BILLBOARDSTRETCHED");break;case ln.BILLBOARDMODE_ALL:e.push("#define BILLBOARDMODE_ALL")}this._colorGradientsTexture&&e.push("#define COLORGRADIENTS"),this.isAnimationSheetEnabled&&e.push("#define ANIMATESHEET"),this._imageProcessingConfiguration&&(this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines),e.push(""+this._imageProcessingConfigurationDefines.toString()))},t.prototype.fillUniformsAttributesAndSamplerNames=function(e,n,i){n.push("position","age","life","size","color","offset","uv","direction","initialDirection","angle","cellIndex"),e.push("emitterWM","worldOffset","view","projection","colorDead","invView","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","sheetInfos","translationPivot","eyePosition"),i.push("diffuseSampler","colorGradientSampler"),this._imageProcessingConfiguration&&(vn.a.PrepareUniforms(e,this._imageProcessingConfigurationDefines),vn.a.PrepareSamplers(i,this._imageProcessingConfigurationDefines))},t.prototype._recreateRenderEffect=function(){var e=this.getCustomEffect();if(e)return e;var n=[];this.fillDefines(n);var i=n.join(`
9253`);if(this._renderEffect&&this._renderEffect.defines===i)return this._renderEffect;var o=[],a=[],s=[];return this.fillUniformsAttributesAndSamplerNames(a,o,s),this._renderEffect=new je.a("gpuRenderParticles",o,a,s,this._engine,i),this._renderEffect},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()},t.prototype._createFactorGradientTexture=function(e,n){var i=this[n];if(e&&e.length&&!i){for(var o=new Float32Array(this._rawTextureWidth),a=0;a<this._rawTextureWidth;a++){var s=a/this._rawTextureWidth;On.GetCurrentGradient(s,e,function(d,p,y){o[a]=$.a.Lerp(d.factor1,p.factor1,y)})}this[n]=$n.CreateRTexture(o,this._rawTextureWidth,1,this._scene||this._engine,!1,!1,h.a.TEXTURE_NEAREST_SAMPL
9253INGMODE)}},t.prototype._createSizeGradientTexture=function(){this._createFactorGradientTexture(this._sizeGradients,"_sizeGradientsTexture")},t.prototype._createAngularSpeedGradientTexture=function(){this._createFactorGradientTexture(this._angularSpeedGradients,"_angularSpeedGradientsTexture")},t.prototype._createVelocityGradientTexture=function(){this._createFactorGradientTexture(this._velocityGradients,"_velocityGradientsTexture")},t.prototype._createLimitVelocityGradientTexture=function(){this._createFactorGradientTexture(this._limitVelocityGradients,"_limitVelocityGradientsTexture")},t.prototype._createDragGradientTexture=function(){this._createFactorGradientTexture(this._dragGradients,"_dragGradientsTexture")},t.prototype._createColorGradientTexture=function(){if(this._colorGradients&&this._colorGradients.length&&!this._colorGradientsTexture){for(var e=new Uint8Array(4*this._rawTextureWidth),n=M.c.Color4[0],i=0;i<this._rawTextureWidth;i++){var o=i/this._rawTextureWidth;On.GetCurrentGradient(o,this._colorGradients,function(a,s,d){M.b.LerpToRef(a.color1,s.color1,d,n),e[4*i]=255*n.r,e[4*i+1]=255*n.g,e[4*i+2]=255*n.b,e[4*i+3]=255*n.a})}this._colorGradientsTexture=$n.CreateRGBATexture(e,this._rawTextureWidth,1,this._scene,!1,!1,h.a.TEXTURE_NEAREST_SAMPLINGMODE)}},t.prototype.render=function(e){var n,i;if(e===void 0&&(e=!1),!this._started||(this._createColorGradientTexture(),this._createSizeGradientTexture(),this._createAngularSpeedGradientTexture(),this._createVelocityGradientTexture(),this._createLimitVelocityGradientTexture(),this._createDragGradientTexture(),this._recreateUpdateEffect(),this._recreateRenderEffect(),!this.isReady()))return 0;if(!e&&this._scene){if(!this._preWarmDone&&this.preWarmCycles){for(var o=0;o<this.preWarmCycles;o++)this.animate(!0),this.render(!0);this._preWarmDone=!0}if(this._currentRenderId===this._scene.getFrameId())return 0;this._currentRenderId=this._scene.getFrameId()}if(this._initialize(),this._accumulatedCount+=this.emitRate*this._timeDelta,this._accumulatedCount>1){var a=0|this._accumulatedCount;this._accumulatedCount-=a,this._currentActiveCount=Math.min(this._activeCount,this._currentActiveCount+a)}if(!this._currentActiveCount)return 0;this._engine.enableEffect(this._updateEffect);var s,d=this._engine;if(!d.setState)throw new Error("GPU particles cannot work with a full Engine. ThinEngine is not supported");if(this._updateEffect.setFloat("currentCount",this._currentActiveCount),this._updateEffect.setFloat("timeDelta",this._timeDelta),this._updateEffect.setFloat("stopFactor",this._stopped?0:1),this._updateEffect.setTexture("randomSampler",this._randomTexture),this._updateEffect.setTexture("randomSampler2",this._randomTexture2),this._updateEffect.setFloat2("lifeTime",this.minLifeTime,this.maxLifeTime),this._updateEffect.setFloat2("emitPower",this.minEmitPower,this.maxEmitPower),this._colorGradientsTexture||(this._updateEffect.setDirectColor4("color1",this.color1),this._updateEffect.setDirectColor4("color2",this.color2)),this._updateEffect.setFloat2("sizeRange",this.minSize,this.maxSize),this._updateEffect.setFloat4("scaleRange",this.minScaleX,this.maxScaleX,this.minScaleY,this.maxScaleY),this._updateEffect.setFloat4("angleRange",this.minAngularSpeed,this.maxAngularSpeed,this.minInitialRotation,this.maxInitialRotation),this._updateEffect.setVector3("gravity",this.gravity),this._sizeGradientsTexture&&this._updateEffect.setTexture("sizeGradientSampler",this._sizeGradientsTexture),this._angularSpeedGradientsTexture&&this._updateEffect.setTexture("angularSpeedGradientSampler",this._angularSpeedGradientsTexture),this._velocityGradientsTexture&&this._updateEffect.setTexture("velocityGradientSampler",this._velocityGradientsTexture),this._limitVelocityGradientsTexture&&(this._updateEffect.setTexture("limitVelocityGradientSampler",this._limitVelocityGradientsTexture),this._updateEffect.setFloat("limitVelocityDamping",this.limitVelocityDamping)),this._dragGradientsTexture&&this._updateEffect.setTexture("dragGradientSampler",this._dragGradientsTexture),this.particleEmitterType&&this.particleEmitterType.applyToShader(this._updateEffect),this._isAnimationSheetEnabled&&this._updateEffect.setFloat3("cellInfos",this.startSpriteCellID,this.endSpriteCellID,this.spriteCellChangeSpeed),this.noiseTexture&&(this._updateEffect.setTexture("noiseSampler",this.noiseTexture),this._updateEffect.setVector3("noiseStrength",this.noiseStrength)),this.emitter.position)s=this.emitter.getWorldMatrix();else{var p=this.emitter;s=u.a.Translation(p.x,p.y,p.z)}
9253if(this.isLocal||this._updateEffect.setMatrix("emitterWM",s),this._engine.bindVertexArrayObject(this._updateVAO[this._targetIndex],null),d.bindTransformFeedbackBuffer(this._targetBuffer.getBuffer()),d.setRasterizerState(!1),d.beginTransformFeedback(!0),d.drawArraysType(h.a.MATERIAL_PointListDrawMode,0,this._currentActiveCount),d.endTransformFeedback(),d.setRasterizerState(!0),d.bindTransformFeedbackBuffer(null),!e){var y=this._getEffect();this._engine.enableEffect(y);var P=((n=this._scene)===null||n===void 0?void 0:n.getViewMatrix())||u.a.IdentityReadOnly;if(y.setMatrix("view",P),y.setMatrix("projection",(i=this.defaultProjectionMatrix)!==null&&i!==void 0?i:this._scene.getProjectionMatrix()),y.setTexture("diffuseSampler",this.particleTexture),y.setVector2("translationPivot",this.translationPivot),y.setVector3("worldOffset",this.worldOffset),this.isLocal&&y.setMatrix("emitterWM",s),this._colorGradientsTexture?y.setTexture("colorGradientSampler",this._colorGradientsTexture):y.setDirectColor4("colorDead",this.colorDead),this._isAnimationSheetEnabled&&this.particleTexture){var O=this.particleTexture.getBaseSize();y.setFloat3("sheetInfos",this.spriteCellWidth/O.width,this.spriteCellHeight/O.height,O.width/this.spriteCellWidth)}if(this._isBillboardBased&&this._scene){var U=this._scene.activeCamera;y.setVector3("eyePosition",U.globalPosition)}var F=y.defines;if(this._scene&&(this._scene.clipPlane||this._scene.clipPlane2||this._scene.clipPlane3||this._scene.clipPlane4||this._scene.clipPlane5||this._scene.clipPlane6)&&tt.a.BindClipPlane(y,this._scene),F.indexOf("#define BILLBOARDMODE_ALL")>=0){var z=P.clone();z.invert(),y.setMatrix("invView",z)}switch(this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(y),this.blendMode){case ln.BLENDMODE_ADD:this._engine.setAlphaMode(h.a.ALPHA_ADD);break;case ln.BLENDMODE_ONEONE:this._engine.setAlphaMode(h.a.ALPHA_ONEONE);break;case ln.BLENDMODE_STANDARD:this._engine.setAlphaMode(h.a.ALPHA_COMBINE);break;case ln.BLENDMODE_MULTIPLY:this._engine.setAlphaMode(h.a.ALPHA_MULTIPLY)}this.forceDepthWrite&&d.setDepthWrite(!0),this._engine.bindVertexArrayObject(this._renderVAO[this._targetIndex],null),this._onBeforeDrawParticlesObservable&&this._onBeforeDrawParticlesObservable.notifyObservers(y),this._engine.drawArraysType(h.a.MATERIAL_TriangleFanDrawMode,0,4,this._currentActiveCount),this._engine.setAlphaMode(h.a.ALPHA_DISABLE)}this._targetIndex++,this._targetIndex===2&&(this._targetIndex=0);var J=this._sourceBuffer;return this._sourceBuffer=this._targetBuffer,this._targetBuffer=J,this._currentActiveCount},t.prototype.rebuild=function(){this._initialize(!0)},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)},t.prototype._releaseVAOs=function(){if(this._updateVAO){for(var e=0;e<this._updateVAO.length;e++)this._engine.releaseVertexArrayObject(this._updateVAO[e]);for(this._updateVAO=[],e=0;e<this._renderVAO.length;e++)this._engine.releaseVertexArrayObject(this._renderVAO[e]);this._renderVAO=[]}},t.prototype.dispose=function(e){if(e===void 0&&(e=!0),this._scene){var n=this._scene.particleSystems.indexOf(this);n>-1&&this._scene.particleSystems.splice(n,1)}this._releaseBuffers(),this._releaseVAOs(),this._colorGradientsTexture&&(this._colorGradientsTexture.dispose(),this._colorGradientsTexture=null),this._sizeGradientsTexture&&(this._sizeGradientsTexture.dispose(),this._sizeGradientsTexture=null),this._angularSpeedGradientsTexture&&(this._angularSpeedGradientsTexture.dispose(),this._angularSpeedGradientsTexture=null),this._velocityGradientsTexture&&(this._velocityGradientsTexture.dispose(),this._velocityGradientsTexture=null),this._limitVelocityGradientsTexture&&(this._limitVelocityGradientsTexture.dispose(),this._limitVelocityGradientsTexture=null),this._dragGradientsTexture&&(this._dragGradientsTexture.dispose(),this._dragGradientsTexture=null),this._randomTexture&&(this._randomTexture.dispose(),this._randomTexture=null),this._randomTexture2&&(this._randomTexture2.dispose(),this._randomTexture2=null),e&&this.particleTexture&&(this.particleTexture.dispose(),this.particleTexture=null),e&&this.noiseTexture&&(this.noiseTexture.dispose(),this.noiseTexture=null),this.onStoppedObservable.clear(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},t.prototype.clone=function(e,n){var i=this.serialize(),o=t.Parse(i,this._scene||this._engine,""),a=Object(c.a)({},this._customEffect);return o.name=e,o._customEffect=a,n===void 0&&(n=this.emitter),o.emitter=n,o.noiseTexture=this.noiseTexture,o},t.prototype.serialize=function(e){e===void 0&&(e=!1);var n={};return ln._Serialize(n,this,e),n.activeParticleCount=this.activeParticleCount,n.randomTextureSize=this._randomTextureSize,n},t.Parse=function(e,n,i,o){o===void 0&&(o=!1);var a=new t(e.name,{capacity:e.capacity,randomTextureSize:e.randomTextureSize},n);return e.activeParticleCount&&(a.activeParticleCount=e.activeParticleCount),ln._Parse(e,a,n,i),e.preventAutoStart&&(a.preventAutoStart=e.preventAutoStart),o||a.preventAutoStart||a.start(),a},t}(bo),Pa=function(){function r(){this.systems=new Array}return Object.defineProperty(r.prototype,"emitterNode",{get:function(){return this._emitterNode}
9253,enumerable:!1,configurable:!0}),r.prototype.setEmitterAsSphere=function(t,e,n){this._emitterNode&&this._emitterNode.dispose(),this._emitterCreationOptions={kind:"Sphere",options:t,renderingGroupId:e};var i=Nn.a.CreateSphere("emitterSphere",{diameter:t.diameter,segments:t.segments},n);i.renderingGroupId=e;var o=new Ft.a("emitterSphereMaterial",n);o.emissiveColor=t.color,i.material=o;for(var a=0,s=this.systems;a<s.length;a++)s[a].emitter=i;this._emitterNode=i},r.prototype.start=function(t){for(var e=0,n=this.systems;e<n.length;e++){var i=n[e];t&&(i.emitter=t),i.start()}},r.prototype.dispose=function(){for(var t=0,e=this.systems;t<e.length;t++)e[t].dispose();this.systems=[],this._emitterNode&&(this._emitterNode.dispose(),this._emitterNode=null)},r.prototype.serialize=function(t){t===void 0&&(t=!1);for(var e={systems:[]},n=0,i=this.systems;n<i.length;n++){var o=i[n];e.systems.push(o.serialize(t))}return this._emitterNode&&(e.emitter=this._emitterCreationOptions),e},r.Parse=function(t,e,n){n===void 0&&(n=!1);var i=new r,o=this.BaseAssetsUrl+"/textures/";e=e||te.a.LastCreatedScene;for(var a=0,s=t.systems;a<s.length;a++){var d=s[a];i.systems.push(n?or.Parse(d,e,o,!0):ln.Parse(d,e,o,!0))}if(t.emitter){var p=t.emitter.options;switch(t.emitter.kind){case"Sphere":i.setEmitterAsSphere({diameter:p.diameter,segments:p.segments,color:M.a.FromArray(p.color)},t.emitter.renderingGroupId,e)}}return i},r.BaseAssetsUrl="https://assets.babylonjs.com/particles",r}(),cg=function(){function r(){}return r.CreateDefault=function(t,e,n,i){var o;return e===void 0&&(e=500),i===void 0&&(i=!1),(o=i?new or("default system",{capacity:e},n):new ln("default system",e,n)).emitter=t,o.particleTexture=new we.a("https://www.babylonjs.com/assets/Flare.png",o.getScene()),o.createConeEmitter(.1,Math.PI/4),o.color1=new M.b(1,1,1,1),o.color2=new M.b(1,1,1,1),o.colorDead=new M.b(1,1,1,0),o.minSize=.1,o.maxSize=.1,o.minEmitPower=2,o.maxEmitPower=2,o.updateSpeed=1/60,o.emitRate=30,o},r.CreateAsync=function(t,e,n){n===void 0&&(n=!1),e||(e=te.a.LastCreatedScene);var i={};return e._addPendingData(i),new Promise(function(o,a){if(n&&!or.IsSupported)return e._removePendingData(i),a("Particle system with GPU is not supported.");Ye.b.LoadFile(r.BaseAssetsUrl+"/systems/"+t+".json",function(s){e._removePendingData(i);var d=JSON.parse(s.toString());return o(Pa.Parse(d,e,n))},void 0,void 0,void 0,function(){return e._removePendingData(i),a("An error occured while the creation of your particle system. Check if your type '"+t+"' exists.")})})},r.ExportSet=function(t){for(var e=new Pa,n=0,i=t;n<i.length;n++){var o=i[n];e.systems.push(o)}return e},r.ParseFromFileAsync=function(t,e,n,i,o){return i===void 0&&(i=!1),o===void 0&&(o=""),new Promise(function(a,s){var d=new re.a;d.addEventListener("readystatechange",function(){if(d.readyState==4)if(d.status==200){var p=JSON.parse(d.responseText),y=void 0;y=i?or.Parse(p,n,o):ln.Parse(p,n,o),t&&(y.name=t),a(y)}else s("Unable to load the particle system")}),d.open("GET",e),d.send()})},r.CreateFromSnippetAsync=function(t,e,n,i){var o=this;if(n===void 0&&(n=!1),i===void 0&&(i=""),t==="_BLANK"){var a=this.CreateDefault(null);return a.start(),Promise.resolve(a)}return new Promise(function(s,d){var p=new re.a;p.addEventListener("readystatechange",function(){if(p.readyState==4)if(p.status==200){var y=JSON.parse(JSON.parse(p.responseText).jsonPayload),P=JSON.parse(y.particleSystem),O=void 0;(O=n?or.Parse(P,e,i):ln.Parse(P,e,i)).snippetId=t,s(O)}else d("Unable to load the snippet "+t)}),p.open("GET",o.SnippetUrl+"/"+t.replace(/#/g,"/")),p.send()})},r.BaseAssetsUrl=Pa.BaseAssetsUrl,r.SnippetUrl="https://snippet.babylonjs.com",r}();B.a.AddParser(st.a.NAME_PARTICLESYSTEM,function(r,t,e,n){var i=B.a.GetIndividualParser(st.a.NAME_PARTICLESYSTEM);if(i&&r.particleSystems!==void 0&&r.particleSystems!==null)for(var o=0,a=r.particleSystems.length;o<a;o++){var s=r.particleSystems[o];e.particleSystems.push(i(s,t,n))}}),B.a.AddIndividualParser(st.a.NAME_PARTICLESYSTEM,function(r,t,e){return r.activeParticleCount?or.Parse(r,t,e):ln.Parse(r,t,e)}
9253),Ue.a.prototype.createEffectForParticles=function(r,t,e,n,i,o,a,s){var d;t===void 0&&(t=[]),e===void 0&&(e=[]),n===void 0&&(n="");var p=[],y=[],P=[];return s?s.fillUniformsAttributesAndSamplerNames(y,p,P):(p=ln._GetAttributeNamesOrOptions(),y=ln._GetEffectCreationOptions()),n.indexOf(" BILLBOARD")===-1&&(n+=`
9254#define BILLBOARD
9255`),e.indexOf("diffuseSampler")===-1&&e.push("diffuseSampler"),this.createEffect({vertex:(d=s?.vertexShaderName)!==null&&d!==void 0?d:"particles",fragmentElement:r},p,y.concat(t),P.concat(e),n,i,o,a)},De.a.prototype.getEmittedParticleSystems=function(){for(var r=new Array,t=0;t<this.getScene().particleSystems.length;t++){var e=this.getScene().particleSystems[t];e.emitter===this&&r.push(e)}return r},De.a.prototype.getHierarchyEmittedParticleSystems=function(){var r=new Array,t=this.getDescendants();t.push(this);for(var e=0;e<this.getScene().particleSystems.length;e++){var n=this.getScene().particleSystems[e],i=n.emitter;i.position&&t.indexOf(i)!==-1&&r.push(n)}return r};var yn,wc=function(){function r(t,e,n,i,o,a,s,d,p,y){p===void 0&&(p=null),y===void 0&&(y=null),this.idx=0,this.id=0,this.color=new M.b(1,1,1,1),this.position=u.e.Zero(),this.rotation=u.e.Zero(),this.scaling=u.e.One(),this.uvs=new u.f(0,0,1,1),this.velocity=u.e.Zero(),this.pivot=u.e.Zero(),this.translateFromPivot=!1,this.alive=!0,this.isVisible=!0,this._pos=0,this._ind=0,this.shapeId=0,this.idxInShape=0,this._stillInvisible=!1,this._rotationMatrix=[1,0,0,0,1,0,0,0,1],this.parentId=null,this.materialIndex=null,this.props=null,this.cullingStrategy=Dt.a.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY,this._globalPosition=u.e.Zero(),this.idx=t,this.id=e,this._pos=n,this._ind=i,this._model=o,this.shapeId=a,this.idxInShape=s,this._sps=d,p&&(this._modelBoundingInfo=p,this._boundingInfo=new Fi.a(p.minimum,p.maximum)),y!==null&&(this.materialIndex=y)}return r.prototype.copyToRef=function(t){return t.position.copyFrom(this.position),t.rotation.copyFrom(this.rotation),this.rotationQuaternion&&(t.rotationQuaternion?t.rotationQuaternion.copyFrom(this.rotationQuaternion):t.rotationQuaternion=this.rotationQuaternion.clone()),t.scaling.copyFrom(this.scaling),this.color&&(t.color?t.color.copyFrom(this.color):t.color=this.color.clone()),t.uvs.copyFrom(this.uvs),t.velocity.copyFrom(this.velocity),t.pivot.copyFrom(this.pivot),t.translateFromPivot=this.translateFromPivot,t.alive=this.alive,t.isVisible=this.isVisible,t.parentId=this.parentId,t.cullingStrategy=this.cullingStrategy,this.materialIndex!==null&&(t.materialIndex=this.materialIndex),this},Object.defineProperty(r.prototype,"scale",{get:function(){return this.scaling},set:function(t){this.scaling=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"quaternion",{get:function(){return this.rotationQuaternion},set:function(t){this.rotationQuaternion=t},enumerable:!1,configurable:!0}),r.prototype.intersectsMesh=function(t){return!(!this._boundingInfo||!t._boundingInfo)&&(this._sps._bSphereOnly?su.a.Intersects(this._boundingInfo.boundingSphere,t._boundingInfo.boundingSphere):this._boundingInfo.intersects(t._boundingInfo,!1))},r.prototype.isInFrustum=function(t){return this._boundingInfo!==null&&this._boundingInfo.isInFrustum(t,this.cullingStrategy)},r.prototype.getRotationMatrix=function(t){var e;if(this.rotationQuaternion)e=this.rotationQuaternion;else{e=u.c.Quaternion[0];var n=this.rotation;u.b.RotationYawPitchRollToRef(n.y,n.x,n.z,e)}e.toRotationMatrix(t)},r}(),Fc=function(r,t,e,n,i,o,a,s,d){this._indicesLength=0,this.shapeID=r,this._shape=t,this._indices=e,this._indicesLength=e.length,this._shapeUV=o,this._shapeColors=i,this._normals=n,this._positionFunction=a,this._vertexFunction=s,this._material=d},wd=function(r,t,e,n){this.idx=0,this.ind=0,this.indicesLength=0,this.sqDistance=0,this.materialIndex=0,this.idx=r,this.ind=t,this.indicesLength=e,this.materialIndex=n},Fd=function(){function r(){this.position=u.e.Zero(),this.color=new M.b(1,1,1,1),this.uv=u.d.Zero()}return Object.defineProperty(r.prototype,"x",{get:function(){return this.position.x},set:function(t){this.position.x=t}
9255,enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"y",{get:function(){return this.position.y},set:function(t){this.position.y=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"z",{get:function(){return this.position.z},set:function(t){this.position.z=t},enumerable:!1,configurable:!0}),r}(),lg=function(){function r(t,e,n){this.particles=new Array,this.nbParticles=0,this.billboard=!1,this.recomputeNormals=!1,this.counter=0,this.vars={},this._bSphereOnly=!1,this._bSphereRadiusFactor=1,this._positions=new Array,this._indices=new Array,this._normals=new Array,this._colors=new Array,this._uvs=new Array,this._index=0,this._updatable=!0,this._pickable=!1,this._isVisibilityBoxLocked=!1,this._alwaysVisible=!1,this._depthSort=!1,this._expandable=!1,this._shapeCounter=0,this._copy=new wc(0,0,0,0,null,0,0,this),this._color=new M.b(0,0,0,0),this._computeParticleColor=!0,this._computeParticleTexture=!0,this._computeParticleRotation=!0,this._computeParticleVertex=!1,this._computeBoundingBox=!1,this._depthSortParticles=!0,this._mustUnrotateFixedNormals=!1,this._particlesIntersect=!1,this._needs32Bits=!1,this._isNotBuilt=!0,this._lastParticleId=0,this._idxOfId=[],this._multimaterialEnabled=!1,this._useModelMaterial=!1,this._depthSortFunction=function(i,o){return o.sqDistance-i.sqDistance},this._materialSortFunction=function(i,o){return i.materialIndex-o.materialIndex},this._autoUpdateSubMeshes=!1,this.name=t,this._scene=e||te.a.LastCreatedScene,this._camera=e.activeCamera,this._pickable=!!n&&n.isPickable,this._depthSort=!!n&&n.enableDepthSort,this._multimaterialEnabled=!!n&&n.enableMultiMaterial,this._useModelMaterial=!!n&&n.useModelMaterial,this._multimaterialEnabled=!!this._useModelMaterial||this._multimaterialEnabled,this._expandable=!!n&&n.expandable,this._particlesIntersect=!!n&&n.particleIntersection,this._bSphereOnly=!!n&&n.boundingSphereOnly,this._bSphereRadiusFactor=n&&n.bSphereRadiusFactor?n.bSphereRadiusFactor:1,n&&n.updatable!==void 0?this._updatable=n.updatable:this._updatable=!0,this._pickable&&(this.pickedBySubMesh=[[]],this.pickedParticles=this.pickedBySubMesh[0]),(this._depthSort||this._multimaterialEnabled)&&(this.depthSortedParticles=[]),this._multimaterialEnabled&&(this._multimaterial=new ir.a(this.name+"MultiMaterial",this._scene),this._materials=[],this._materialIndexesById={}),this._tmpVertex=new Fd}return r.prototype.buildMesh=function(){if(!this._isNotBuilt&&this.mesh)return this.mesh;if(this.nbParticles===0&&!this.mesh){var t=Aa.CreateDisc("",{radius:1,tessellation:3},this._scene);this.addShape(t,1),t.dispose()}if(this._indices32=this._needs32Bits?new Uint32Array(this._indices):new Uint16Array(this._indices),this._positions32=new Float32Array(this._positions),this._uvs32=new Float32Array(this._uvs),this._colors32=new Float32Array(this._colors),!this.mesh){var e=new De.a(this.name,this._scene);this.mesh=e}!this._updatable&&this._multimaterialEnabled&&this._sortParticlesByMaterial(),this.recomputeNormals&&ft.a.ComputeNormals(this._positions32,this._indices32,this._normals),this._normals32=new Float32Array(this._normals),this._fixedNormal32=new Float32Array(this._normals),this._mustUnrotateFixedNormals&&this._unrotateFixedNormals();var n=new ft.a;if(n.indices=this._depthSort?this._indices:this._indices32,n.set(this._positions32,Me.b.PositionKind),n.set(this._normals32,Me.b.NormalKind),this._uvs32.length>0&&n.set(this._uvs32,Me.b.UVKind),this._colors32.length>0&&n.set(this._colors32,Me.b.ColorKind),n.applyToMesh(this.mesh,this._updatable),this.mesh.isPickable=this._pickable,this._pickable){for(var i=0,o=0;o<this.nbParticles;o++)for(var a=this.particles[o],s=a._model._indicesLength,d=0;d<s;d++)if(d%3==0){var p={idx:a.idx,faceId:i};this.pickedParticles[i]=p,i++}}return this._multimaterialEnabled&&this.setMultiMaterial(this._materials),this._expandable||(this._depthSort||this._multimaterialEnabled||(this._indices=null),this._positions=null,this._normals=null,this._uvs=null,this._colors=null,this._updatable||(this.particles.length=0)),this._isNotBuilt=!1,this.recomputeNormals=!1,this.mesh},r.prototype.digest=function(t,e){var n=e&&e.facetNb||1,i=e&&e.number||0,o=e&&e.delta||0,a=t.getVerticesData(Me.b.PositionKind),s=t.getIndices(),d=t.getVerticesData(Me.b.UVKind),p=t.getVerticesData(Me.b.ColorKind),y=t.getVerticesData(Me.b.NormalKind),P=e&&e.storage?e.storage:null,O=0,U=s.length/3;i?(i=i>U?U:i,n=Math.round(U/i),o=0):n=n>U?U:n;for(var F=[],z=[],J=[],ie=[],se=[],ce=u.e.Zero(),ue=n;O<U;){O>U-(n=ue+Math.floor((1+o)*Math.random()))&&(n=U-O),F.length=0,z.length=0,J.length=0,ie.length=0,se.length=0;for(var fe=0,ve=3*O;ve<3*(O+n);ve++){J.push(fe);var Te=s[ve],Oe=3*Te;if(F.push(a[Oe],a[Oe+1],a[Oe+2]),z.push(y[Oe],y[Oe+1],y[Oe+2]),d){var Pe=2*Te;ie.push(d[Pe],d[Pe+1])}if(p){var Ee=4*Te;se.push(p[Ee],p[Ee+1],p[Ee+2],p[Ee+3])}fe++}var Se,Le=this.nbParticles,xe=this._posToShape(F),Ne=this._uvsToShapeUV(ie),Ie=Ye.b.
9255Slice(J),Fe=Ye.b.Slice(se),Ke=Ye.b.Slice(z);for(ce.copyFromFloats(0,0,0),Se=0;Se<xe.length;Se++)ce.addInPlace(xe[Se]);ce.scaleInPlace(1/xe.length);var nt,rt=new u.e(1/0,1/0,1/0),ut=new u.e(-1/0,-1/0,-1/0);for(Se=0;Se<xe.length;Se++)xe[Se].subtractInPlace(ce),rt.minimizeInPlaceFromFloats(xe[Se].x,xe[Se].y,xe[Se].z),ut.maximizeInPlaceFromFloats(xe[Se].x,xe[Se].y,xe[Se].z);this._particlesIntersect&&(nt=new Fi.a(rt,ut));var qe=null;this._useModelMaterial&&(qe=t.material?t.material:this._setDefaultMaterial());var at=new Fc(this._shapeCounter,xe,Ie,Ke,Fe,Ne,null,null,qe),ot=this._positions.length,Je=this._indices.length;this._meshBuilder(this._index,Je,xe,this._positions,Ie,this._indices,ie,this._uvs,Fe,this._colors,Ke,this._normals,Le,0,null,at),this._addParticle(Le,this._lastParticleId,ot,Je,at,this._shapeCounter,0,nt,P),this.particles[this.nbParticles].position.addInPlace(ce),P||(this._index+=xe.length,Le++,this.nbParticles++,this._lastParticleId++),this._shapeCounter++,O+=n}return this._isNotBuilt=!0,this},r.prototype._unrotateFixedNormals=function(){for(var t=0,e=0,n=u.c.Vector3[0],i=u.c.Quaternion[0],o=u.c.Matrix[0],a=0;a<this.particles.length;a++){var s=this.particles[a],d=s._model._shape;if(s.rotationQuaternion)s.rotationQuaternion.conjugateToRef(i);else{var p=s.rotation;u.b.RotationYawPitchRollToRef(p.y,p.x,p.z,i),i.conjugateInPlace()}i.toRotationMatrix(o);for(var y=0;y<d.length;y++)e=t+3*y,u.e.TransformNormalFromFloatsToRef(this._normals32[e],this._normals32[e+1],this._normals32[e+2],o,n),n.toArray(this._fixedNormal32,e);t=e+3}},r.prototype._resetCopy=function(){var t=this._copy;t.position.setAll(0),t.rotation.setAll(0),t.rotationQuaternion=null,t.scaling.setAll(1),t.uvs.copyFromFloats(0,0,1,1),t.color=null,t.translateFromPivot=!1,t.shapeId=0,t.materialIndex=null},r.prototype._meshBuilder=function(t,e,n,i,o,a,s,d,p,y,P,O,U,F,z,J){var ie,se=0,ce=0,ue=0;this._resetCopy();var fe=this._copy,ve=!(!z||!z.storage);if(fe.idx=U,fe.idxInShape=F,fe.shapeId=J.shapeID,this._useModelMaterial){var Te=J._material.uniqueId,Oe=this._materialIndexesById;Oe.hasOwnProperty(Te)||(Oe[Te]=this._materials.length,this._materials.push(J._material));var Pe=Oe[Te];fe.materialIndex=Pe}if(z&&z.positionFunction&&(z.positionFunction(fe,U,F),this._mustUnrotateFixedNormals=!0),ve)return fe;var Ee=u.c.Matrix[0],Se=this._tmpVertex,Le=Se.position,xe=Se.color,Ne=Se.uv,Ie=u.c.Vector3[1],Fe=u.c.Vector3[2],Ke=u.c.Vector3[3];u.a.IdentityToRef(Ee),fe.getRotationMatrix(Ee),fe.pivot.multiplyToRef(fe.scaling,Ke),fe.translateFromPivot?Fe.setAll(0):Fe.copyFrom(Ke);var nt=z&&z.vertexFunction;for(ie=0;ie<n.length;ie++){if(Le.copyFrom(n[ie]),fe.color&&xe.copyFrom(fe.color),s&&Ne.copyFromFloats(s[se],s[se+1]),nt&&z.vertexFunction(fe,Se,ie),Le.multiplyInPlace(fe.scaling).subtractInPlace(Ke),u.e.TransformCoordinatesToRef(Le,Ee,Ie),Ie.addInPlace(Fe).addInPlace(fe.position),i.push(Ie.x,Ie.y,Ie.z),s){var rt=fe.uvs;d.push((rt.z-rt.x)*Ne.x+rt.x,(rt.w-rt.y)*Ne.y+rt.y),se+=2}if(fe.color)this._color.copyFrom(xe);else{var ut=this._color;p&&p[ce]!==void 0?(ut.r=p[ce],ut.g=p[ce+1],ut.b=p[ce+2],ut.a=p[ce+3]):(ut.r=1,ut.g=1,ut.b=1,ut.a=1)}y.push(this._color.r,this._color.g,this._color.b,this._color.a),ce+=4,!this.recomputeNormals&&P&&(u.e.TransformNormalFromFloatsToRef(P[ue],P[ue+1],P[ue+2],Ee,Le),O.push(Le.x,Le.y,Le.z),ue+=3)}for(ie=0;ie<o.length;ie++){var qe=t+o[ie];a.push(qe),qe>65535&&(this._needs32Bits=!0)}if(this._depthSort||this._multimaterialEnabled){var at=fe.materialIndex!==null?fe.materialIndex:0;this.depthSortedParticles.push(new wd(U,e,o.length,at))}return fe},r.prototype._posToShape=function(t){for(var e=[],n=0;n<t.length;n+=3)e.push(u.e.FromArray(t,n));return e},r.prototype._uvsToShapeUV=function(t){var e=[];if(t)for(var n=0;n<t.length;n++)e.push(t[n]);return e},r.prototype._addParticle=function(t,e,n,i,o,a,s,d,p){d===void 0&&(d=null),p===void 0&&(p=null);var y=new wc(t,e,n,i,o,a,s,this,d);return(p||this.particles).push(y),y},r.prototype.addShape=function(t,e,n){var i=t.getVerticesData(Me.b.PositionKind),o=t.getIndices(),a=t.getVerticesData(Me.b.UVKind),s=t.getVerticesData(Me.b.ColorKind),d=t.getVerticesData(Me.b.NormalKind);this.recomputeNormals=!d;var p=Ye.b.SliceToArray(o),y=Ye.b.SliceToArray(d),P=s?Ye.b.SliceToArray(s):[],O=n&&n.storage?n.storage:null,U=null;this._particlesIntersect&&(U=t.getBoundingInfo());var F=this._posToShape(i),z=this._uvsToShapeUV(a),J=n?n.positionFunction:null,ie=n?n.vertexFunction:null,se=null;this._useModelMaterial&&(se=t.material?t.material:this._setDefaultMaterial());for(var ce=new Fc(this._shapeCounter,F,p,y,P,z,J,ie,se),ue=0;ue<e;
9255ue++)this._insertNewParticle(this.nbParticles,ue,ce,F,o,a,s,d,U,O,n);return this._shapeCounter++,this._isNotBuilt=!0,this._shapeCounter-1},r.prototype._rebuildParticle=function(t,e){e===void 0&&(e=!1),this._resetCopy();var n=this._copy;t._model._positionFunction&&t._model._positionFunction(n,t.idx,t.idxInShape);var i=u.c.Matrix[0],o=u.c.Vector3[0],a=u.c.Vector3[1],s=u.c.Vector3[2],d=u.c.Vector3[3];n.getRotationMatrix(i),t.pivot.multiplyToRef(t.scaling,d),n.translateFromPivot?s.copyFromFloats(0,0,0):s.copyFrom(d);for(var p=t._model._shape,y=0;y<p.length;y++)o.copyFrom(p[y]),t._model._vertexFunction&&t._model._vertexFunction(n,o,y),o.multiplyInPlace(n.scaling).subtractInPlace(d),u.e.TransformCoordinatesToRef(o,i,a),a.addInPlace(s).addInPlace(n.position).toArray(this._positions32,t._pos+3*y);e&&(t.position.setAll(0),t.rotation.setAll(0),t.rotationQuaternion=null,t.scaling.setAll(1),t.uvs.setAll(0),t.pivot.setAll(0),t.translateFromPivot=!1,t.parentId=null)},r.prototype.rebuildMesh=function(t){t===void 0&&(t=!1);for(var e=0;e<this.particles.length;e++)this._rebuildParticle(this.particles[e],t);return this.mesh.updateVerticesData(Me.b.PositionKind,this._positions32,!1,!1),this},r.prototype.removeParticles=function(t,e){var n=e-t+1;if(!this._expandable||n<=0||n>=this.nbParticles||!this._updatable)return[];var i=this.particles,o=this.nbParticles;if(e<o-1)for(var a=e+1,s=i[a]._pos-i[t]._pos,d=i[a]._ind-i[t]._ind,p=a;p<o;p++){var y=i[p];y._pos-=s,y._ind-=d}var P=i.splice(t,n);this._positions.length=0,this._indices.length=0,this._colors.length=0,this._uvs.length=0,this._normals.length=0,this._index=0,this._idxOfId.length=0,(this._depthSort||this._multimaterialEnabled)&&(this.depthSortedParticles=[]);for(var O=0,U=i.length,F=0;F<U;F++){var z=i[F],J=z._model,ie=J._shape,se=J._indices,ce=J._normals,ue=J._shapeColors,fe=J._shapeUV;z.idx=F,this._idxOfId[z.id]=F,this._meshBuilder(this._index,O,ie,this._positions,se,this._indices,fe,this._uvs,ue,this._colors,ce,this._normals,z.idx,z.idxInShape,null,J),this._index+=ie.length,O+=se.length}return this.nbParticles-=n,this._isNotBuilt=!0,P},r.prototype.insertParticlesFromArray=function(t){if(!this._expandable)return this;for(var e=0,n=t[0].shapeId,i=t.length,o=0;o<i;o++){var a=t[o],s=a._model,d=s._shape,p=s._indices,y=s._shapeUV,P=s._shapeColors,O=s._normals,U=!O;this.recomputeNormals=U||this.recomputeNormals;var F=a._boundingInfo,z=this._insertNewParticle(this.nbParticles,e,s,d,p,y,P,O,F,null,null);a.copyToRef(z),e++,n!=a.shapeId&&(n=a.shapeId,e=0)}return this._isNotBuilt=!0,this},r.prototype._insertNewParticle=function(t,e,n,i,o,a,s,d,p,y,P){var O=this._positions.length,U=this._indices.length,F=this._meshBuilder(this._index,U,i,this._positions,o,this._indices,a,this._uvs,s,this._colors,d,this._normals,t,e,P,n),z=null;return this._updatable&&((z=this._addParticle(this.nbParticles,this._lastParticleId,O,U,n,this._shapeCounter,e,p,y)).position.copyFrom(F.position),z.rotation.copyFrom(F.rotation),F.rotationQuaternion&&(z.rotationQuaternion?z.rotationQuaternion.copyFrom(F.rotationQuaternion):z.rotationQuaternion=F.rotationQuaternion.clone()),F.color&&(z.color?z.color.copyFrom(F.color):z.color=F.color.clone()),z.scaling.copyFrom(F.scaling),z.uvs.copyFrom(F.uvs),F.materialIndex!==null&&(z.materialIndex=F.materialIndex),this.expandable&&(this._idxOfId[z.id]=z.idx)),y||(this._index+=i.length,this.nbParticles++,this._lastParticleId++),z},r.prototype.setParticles=function(t,e,n){if(t===void 0&&(t=0),e===void 0&&(e=this.nbParticles-1),n===void 0&&(n=!0),!this._updatable||this._isNotBuilt)return this;this.beforeUpdateParticles(t,e,n);var i=u.c.Matrix[0],o=u.c.Matrix[1],a=this.mesh,s=this._colors32,d=this._positions32,p=this._normals32,y=this._uvs32,P=this._indices32,O=this._indices,U=this._fixedNormal32,F=u.c.Vector3,z=F[5].copyFromFloats(1,0,0),J=F[6].copyFromFloats(0,1,0),ie=F[7].copyFromFloats(0,0,1),se=F[8].setAll(Number.MAX_VALUE),ce=F[9].setAll(-Number.MAX_VALUE),ue=F[10].setAll(0),fe=this._tmpVertex,ve=fe.position,Te=fe.color,Oe=fe.uv;if((this.billboard||this._depthSort)&&(this.mesh.computeWorldMatrix(!0),this.mesh._worldMatrix.invertToRef(o)),this.billboard){var Pe=F[0];this._camera.getDirectionToRef(ye.a.Z,Pe),u.e.TransformNormalToRef(Pe,o,ie),ie.normalize();var Ee=this._camera.getViewMatrix(!0);u.e.TransformNormalFromFloatsToRef(Ee.m[1],Ee.m[5],Ee.m[9],o,J),u.e.CrossToRef(J,ie,z),J.normalize(),z.normalize()}this._depthSort&&u.e.TransformCoordinatesToRef(this._camera.globalPosition,o,ue),u.a.IdentityToRef(i);var Se=0,Le=0,xe=0,Ne=0,Ie=0,Fe=0,Ke=0;if(this.mesh.isFacetDataEnabled&&(this._computeBoundingBox=!0),e=e>=this.nbParticles?this.nbParticles-1:e,this._computeBoundingBox&&
9255(t!=0||e!=this.nbParticles-1)){var nt=this.mesh._boundingInfo;nt&&(se.copyFrom(nt.minimum),ce.copyFrom(nt.maximum))}var rt=(Le=this.particles[t]._pos)/3|0;Ne=4*rt,Fe=2*rt;for(var ut=t;ut<=e;ut++){var qe=this.particles[ut];this.updateParticle(qe);var at=qe._model._shape,ot=qe._model._shapeUV,Je=qe._rotationMatrix,dt=qe.position,Ve=qe.rotation,$e=qe.scaling,yt=qe._globalPosition;if(this._depthSort&&this._depthSortParticles){var Wt=this.depthSortedParticles[ut];Wt.idx=qe.idx,Wt.ind=qe._ind,Wt.indicesLength=qe._model._indicesLength,Wt.sqDistance=u.e.DistanceSquared(qe.position,ue)}if(!qe.alive||qe._stillInvisible&&!qe.isVisible)Le+=3*(Ke=at.length),Ne+=4*Ke,Fe+=2*Ke;else{if(qe.isVisible){qe._stillInvisible=!1;var Nt=F[12];if(qe.pivot.multiplyToRef($e,Nt),this.billboard&&(Ve.x=0,Ve.y=0),(this._computeParticleRotation||this.billboard)&&qe.getRotationMatrix(i),qe.parentId!==null){var Qt=this.getParticleById(qe.parentId);if(Qt){var vt=Qt._rotationMatrix,Jt=Qt._globalPosition,Xt=dt.x*vt[1]+dt.y*vt[4]+dt.z*vt[7],zt=dt.x*vt[0]+dt.y*vt[3]+dt.z*vt[6],Yt=dt.x*vt[2]+dt.y*vt[5]+dt.z*vt[8];if(yt.x=Jt.x+zt,yt.y=Jt.y+Xt,yt.z=Jt.z+Yt,this._computeParticleRotation||this.billboard){var Et=i.m;Je[0]=Et[0]*vt[0]+Et[1]*vt[3]+Et[2]*vt[6],Je[1]=Et[0]*vt[1]+Et[1]*vt[4]+Et[2]*vt[7],Je[2]=Et[0]*vt[2]+Et[1]*vt[5]+Et[2]*vt[8],Je[3]=Et[4]*vt[0]+Et[5]*vt[3]+Et[6]*vt[6],Je[4]=Et[4]*vt[1]+Et[5]*vt[4]+Et[6]*vt[7],Je[5]=Et[4]*vt[2]+Et[5]*vt[5]+Et[6]*vt[8],Je[6]=Et[8]*vt[0]+Et[9]*vt[3]+Et[10]*vt[6],Je[7]=Et[8]*vt[1]+Et[9]*vt[4]+Et[10]*vt[7],Je[8]=Et[8]*vt[2]+Et[9]*vt[5]+Et[10]*vt[8]}}else qe.parentId=null}else yt.x=dt.x,yt.y=dt.y,yt.z=dt.z,(this._computeParticleRotation||this.billboard)&&(Et=i.m,Je[0]=Et[0],Je[1]=Et[1],Je[2]=Et[2],Je[3]=Et[4],Je[4]=Et[5],Je[5]=Et[6],Je[6]=Et[8],Je[7]=Et[9],Je[8]=Et[10]);var Mt=F[11];for(qe.translateFromPivot?Mt.setAll(0):Mt.copyFrom(Nt),Ke=0;Ke<at.length;Ke++){Se=Le+3*Ke,xe=Ne+4*Ke,Ie=Fe+2*Ke;var $t=2*Ke,Mn=$t+1;ve.copyFrom(at[Ke]),this._computeParticleColor&&qe.color&&Te.copyFrom(qe.color),this._computeParticleTexture&&Oe.copyFromFloats(ot[$t],ot[Mn]),this._computeParticleVertex&&this.updateParticleVertex(qe,fe,Ke);var Bn=ve.x*$e.x-Nt.x,qn=ve.y*$e.y-Nt.y,In=ve.z*$e.z-Nt.z;zt=Bn*Je[0]+qn*Je[3]+In*Je[6],Xt=Bn*Je[1]+qn*Je[4]+In*Je[7],Yt=Bn*Je[2]+qn*Je[5]+In*Je[8],zt+=Mt.x,Xt+=Mt.y,Yt+=Mt.z;var qt=d[Se]=yt.x+z.x*zt+J.x*Xt+ie.x*Yt,si=d[Se+1]=yt.y+z.y*zt+J.y*Xt+ie.y*Yt,xi=d[Se+2]=yt.z+z.z*zt+J.z*Xt+ie.z*Yt;if(this._computeBoundingBox&&(se.minimizeInPlaceFromFloats(qt,si,xi),ce.maximizeInPlaceFromFloats(qt,si,xi)),!this._computeParticleVertex){var kr=U[Se],Gr=U[Se+1],ci=U[Se+2],Gi=kr*Je[0]+Gr*Je[3]+ci*Je[6],zr=kr*Je[1]+Gr*Je[4]+ci*Je[7],jt=kr*Je[2]+Gr*Je[5]+ci*Je[8];p[Se]=z.x*Gi+J.x*zr+ie.x*jt,p[Se+1]=z.y*Gi+J.y*zr+ie.y*jt,p[Se+2]=z.z*Gi+J.z*zr+ie.z*jt}if(this._computeParticleColor&&qe.color){var zi=this._colors32;zi[xe]=Te.r,zi[xe+1]=Te.g,zi[xe+2]=Te.b,zi[xe+3]=Te.a}if(this._computeParticleTexture){var Tn=qe.uvs;y[Ie]=Oe.x*(Tn.z-Tn.x)+Tn.x,y[Ie+1]=Oe.y*(Tn.w-Tn.y)+Tn.y}}}else for(qe._stillInvisible=!0,Ke=0;Ke<at.length;Ke++){if(xe=Ne+4*Ke,Ie=Fe+2*Ke,d[Se=Le+3*Ke]=d[Se+1]=d[Se+2]=0,p[Se]=p[Se+1]=p[Se+2]=0,this._computeParticleColor&&qe.color){var cr=qe.color;s[xe]=cr.r,s[xe+1]=cr.g,s[xe+2]=cr.b,s[xe+3]=cr.a}this._computeParticleTexture&&(Tn=qe.uvs,y[Ie]=ot[2*Ke]*(Tn.z-Tn.x)+Tn.x,y[Ie+1]=ot[2*Ke+1]*(Tn.w-Tn.y)+Tn.y)}if(this._particlesIntersect){var Ri=qe._boundingInfo,ja=Ri.boundingBox,Ha=Ri.boundingSphere,jr=qe._modelBoundingInfo;if(!this._bSphereOnly){var ji=jr.boundingBox.vectors,Hi=F[1],lr=F[2];Hi.setAll(Number.MAX_VALUE),lr.setAll(-Number.MAX_VALUE);for(var Wi=0;Wi<8;Wi++){var Hr=ji[Wi].x*$e.x,Wr=ji[Wi].y*$e.y,Xr=ji[Wi].z*$e.z,Xi=(zt=Hr*Je[0]+Wr*Je[3]+Xr*Je[6],Xt=Hr*Je[1]+Wr*Je[4]+Xr*Je[7],Yt=Hr*Je[2]+Wr*Je[5]+Xr*Je[8],dt.x+z.x*zt+J.x*Xt+ie.x*Yt),Yi=dt.y+z.y*zt+J.y*Xt+ie.y*Yt,Yr=dt.z+z.z*zt+J.z*Xt+ie.z*Yt;Hi.minimizeInPlaceFromFloats(Xi,Yi,Yr),lr.maximizeInPlaceFromFloats(Xi,Yi,Yr)}ja.reConstruct(Hi,lr,a._worldMatrix)}var Oi=jr.minimum.multiplyToRef($e,F[1]),Dn=jr.maximum.multiplyToRef($e,F[2]),Mo=Dn.addToRef(Oi,F[3]).scaleInPlace(.5).addInPlace(yt),ur=Dn.subtractToRef(Oi,F[4]).scaleInPlace(.5*this._bSphereRadiusFactor),Io=Mo.subtractToRef(ur,F[1]),Wv=Mo.addToRef(ur,F[2]);Ha.reConstruct(Io,Wv,a._worldMatrix)}Le=Se+3,Ne=xe+4,Fe=Ie+2}}if(n){if(this._computeParticleColor&&a.updateVerticesData(Me.b.ColorKind,s,!1,!1),this._computeParticleTexture&&a.updateVerticesData(Me.b.UVKind,y,!1,!1),a.updateVerticesData(Me.b.PositionKind,d,!1,!1),!a.areNormalsFrozen||a.isFacetDataEnabled){if(this._computeParticleVertex||a.isFacetDataEnabled){var Xv=a.isFacetDataEnabled?a.getFacetDataParameters():null;ft.a.ComputeNormals(d,P,p,Xv);for(var Mi=0;Mi<p.length;Mi++)U[Mi]=p[Mi]}
9255a.areNormalsFrozen||a.updateVerticesData(Me.b.NormalKind,p,!1,!1)}if(this._depthSort&&this._depthSortParticles){var ol=this.depthSortedParticles;ol.sort(this._depthSortFunction);for(var Yv=ol.length,Mf=0,al=0,sl=0;sl<Yv;sl++){var cl=ol[sl],Kv=cl.indicesLength,Qv=cl.ind;for(Mi=0;Mi<Kv;Mi++)if(P[Mf]=O[Qv+Mi],Mf++,this._pickable&&Mi%3==0){var If=this.pickedParticles[al];If.idx=cl.idx,If.faceId=al,al++}}a.updateIndices(P)}}return this._computeBoundingBox&&(a._boundingInfo?a._boundingInfo.reConstruct(se,ce,a._worldMatrix):a._boundingInfo=new Fi.a(se,ce,a._worldMatrix)),this._autoUpdateSubMeshes&&this.computeSubMeshes(),this.afterUpdateParticles(t,e,n),this},r.prototype.dispose=function(){this.mesh.dispose(),this.vars=null,this._positions=null,this._indices=null,this._normals=null,this._uvs=null,this._colors=null,this._indices32=null,this._positions32=null,this._normals32=null,this._fixedNormal32=null,this._uvs32=null,this._colors32=null,this.pickedParticles=null,this.pickedBySubMesh=null,this._materials=null,this._materialIndexes=null,this._indicesByMaterial=null,this._idxOfId=null},r.prototype.pickedParticle=function(t){if(t.hit){var e=t.subMeshId,n=t.faceId,i=this.pickedBySubMesh;if(i[e]&&i[e][n])return i[e][n]}return null},r.prototype.getParticleById=function(t){var e=this.particles[t];if(e&&e.id==t)return e;var n=this.particles,i=this._idxOfId[t];if(i!==void 0)return n[i];for(var o=0,a=this.nbParticles;o<a;){var s=n[o];if(s.id==t)return s;o++}return null},r.prototype.getParticlesByShapeId=function(t){var e=[];return this.getParticlesByShapeIdToRef(t,e),e},r.prototype.getParticlesByShapeIdToRef=function(t,e){e.length=0;for(var n=0;n<this.nbParticles;n++){var i=this.particles[n];i.shapeId==t&&e.push(i)}return this},r.prototype.computeSubMeshes=function(){if(!this.mesh||!this._multimaterialEnabled)return this;var t=this.depthSortedParticles;if(this.particles.length>0)for(var e=0;e<this.particles.length;e++){var n=this.particles[e];n.materialIndex||(n.materialIndex=0);var i=t[e];i.materialIndex=n.materialIndex,i.ind=n._ind,i.indicesLength=n._model._indicesLength,i.idx=n.idx}this._sortParticlesByMaterial();var o=this._indicesByMaterial,a=this._materialIndexes,s=this.mesh;s.subMeshes=[];for(var d=s.getTotalVertices(),p=0;p<a.length;p++){var y=o[p],P=o[p+1]-y,O=a[p];new To.a(O,0,d,y,P,s)}return this},r.prototype._sortParticlesByMaterial=function(){var t=[0];this._indicesByMaterial=t;var e=[];this._materialIndexes=e;var n=this.depthSortedParticles;n.sort(this._materialSortFunction);var i=n.length,o=this._indices32,a=this._indices,s=0,d=0,p=0,y=n[0].materialIndex;e.push(y),this._pickable&&(this.pickedBySubMesh=[[]],this.pickedParticles=this.pickedBySubMesh[0]);for(var P=0;P<i;P++){var O=n[P],U=O.indicesLength,F=O.ind;O.materialIndex!==y&&(y=O.materialIndex,t.push(p),e.push(y),this._pickable&&(s++,this.pickedBySubMesh[s]=[],d=0));for(var z=0,J=0;J<U;J++){if(o[p]=a[F+J],this._pickable&&J%3==0){var ie=this.pickedBySubMesh[s][d];ie?(ie.idx=O.idx,ie.faceId=z):this.pickedBySubMesh[s][d]={idx:O.idx,faceId:z},d++,z++}p++}}return t.push(o.length),this._updatable&&this.mesh.updateIndices(o),this},r.prototype._setMaterialIndexesById=function(){this._materialIndexesById={};for(var t=0;t<this._materials.length;t++){var e=this._materials[t].uniqueId;this._materialIndexesById[e]=t}},r.prototype._filterUniqueMaterialId=function(t){return t.filter(function(e,n,i){return i.indexOf(e)===n})},r.prototype._setDefaultMaterial=function(){return this._defaultMaterial||(this._defaultMaterial=new Ft.a(this.name+"DefaultMaterial",this._scene)),this._defaultMaterial},r.prototype.refreshVisibleSize=function(){return this._isVisibilityBoxLocked||this.mesh.refreshBoundingInfo(),this},r.prototype.setVisibilityBox=function(t){var e=t/2;this.mesh._boundingInfo=new Fi.a(new u.e(-e,-e,-e),new u.e(e,e,e))},Object.defineProperty(r.prototype,"isAlwaysVisible",{get:function(){return this._alwaysVisible},set:function(t){this._alwaysVisible=t,this.mesh.alwaysSelectAsActiveMesh=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isVisibilityBoxLocked",{get:function(){return this._isVisibilityBoxLocked},set:function(t){this._isVisibilityBoxLocked=t,this.mesh.getBoundingInfo().isLocked=t}
9255,enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"computeParticleRotation",{get:function(){return this._computeParticleRotation},set:function(t){this._computeParticleRotation=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"computeParticleColor",{get:function(){return this._computeParticleColor},set:function(t){this._computeParticleColor=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"computeParticleTexture",{get:function(){return this._computeParticleTexture},set:function(t){this._computeParticleTexture=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"computeParticleVertex",{get:function(){return this._computeParticleVertex},set:function(t){this._computeParticleVertex=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"computeBoundingBox",{get:function(){return this._computeBoundingBox},set:function(t){this._computeBoundingBox=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"depthSortParticles",{get:function(){return this._depthSortParticles},set:function(t){this._depthSortParticles=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"expandable",{get:function(){return this._expandable},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"multimaterialEnabled",{get:function(){return this._multimaterialEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"useModelMaterial",{get:function(){return this._useModelMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"materials",{get:function(){return this._materials},enumerable:!1,configurable:!0}),r.prototype.setMultiMaterial=function(t){this._materials=this._filterUniqueMaterialId(t),this._setMaterialIndexesById(),this._multimaterial&&this._multimaterial.dispose(),this._multimaterial=new ir.a(this.name+"MultiMaterial",this._scene);for(var e=0;e<this._materials.length;e++)this._multimaterial.subMaterials.push(this._materials[e]);this.computeSubMeshes(),this.mesh.material=this._multimaterial},Object.defineProperty(r.prototype,"multimaterial",{get:function(){return this._multimaterial},set:function(t){this._multimaterial=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"autoUpdateSubMeshes",{get:function(){return this._autoUpdateSubMeshes},set:function(t){this._autoUpdateSubMeshes=t},enumerable:!1,configurable:!0}),r.prototype.initParticles=function(){},r.prototype.recycleParticle=function(t){return t},r.prototype.updateParticle=function(t){return t},r.prototype.updateParticleVertex=function(t,e,n){return this},r.prototype.beforeUpdateParticles=function(t,e,n){},r.prototype.afterUpdateParticles=function(t,e,n){},r}(),Bd=function(){function r(t,e,n,i,o){this.idx=0,this.color=new M.b(1,1,1,1),this.position=u.e.Zero(),this.rotation=u.e.Zero(),this.uv=new u.d(0,0),this.velocity=u.e.Zero(),this.pivot=u.e.Zero(),this.translateFromPivot=!1,this._pos=0,this._ind=0,this.groupId=0,this.idxInGroup=0,this._stillInvisible=!1,this._rotationMatrix=[1,0,0,0,1,0,0,0,1],this.parentId=null,this._globalPosition=u.e.Zero(),this.idx=t,this._group=e,this.groupId=n,this.idxInGroup=i,this._pcs=o}return Object.defineProperty(r.prototype,"size",{get:function(){return this.size},set:function(t){this.size=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"quaternion",{get:function(){return this.rotationQuaternion},set:function(t){this.rotationQuaternion=t},enumerable:!1,configurable:!0}),r.prototype.intersectsMesh=function(t,e){if(!t._boundingInfo)return!1;if(e=e||!1)return t.getBoundingInfo().boundingSphere.intersectsPoint(this.position.add(this._pcs.mesh.position));var n,i,o,a,s,d;n=t.getBoundingInfo().boundingBox.maximumWorld.x,i=t.getBoundingInfo().boundingBox.minimumWorld.x,o=t.getBoundingInfo().boundingBox.maximumWorld.y,a=t.getBoundingInfo().boundingBox.minimumWorld.y,s=t.getBoundingInfo().boundingBox.maximumWorld.z,d=t.getBoundingInfo().boundingBox.minimumWorld.z;var p=this.position.x+this._pcs.mesh.position.x,y=this.position.y+this._pcs.mesh.position.y,P=this.position.z+this._pcs.mesh.position.z;
9255return i<=p&&p<=n&&a<=y&&y<=o&&d<=P&&P<=s},r.prototype.getRotationMatrix=function(t){var e;if(this.rotationQuaternion)e=this.rotationQuaternion;else{e=u.c.Quaternion[0];var n=this.rotation;u.b.RotationYawPitchRollToRef(n.y,n.x,n.z,e)}e.toRotationMatrix(t)},r}(),Ca=function(r,t){this.groupID=r,this._positionFunction=t};(function(r){r[r.Color=2]="Color",r[r.UV=1]="UV",r[r.Random=0]="Random",r[r.Stated=3]="Stated"})(yn||(yn={}));var ug=function(){function r(t,e,n,i){this.particles=new Array,this.nbParticles=0,this.counter=0,this.vars={},this._promises=[],this._positions=new Array,this._indices=new Array,this._normals=new Array,this._colors=new Array,this._uvs=new Array,this._updatable=!0,this._isVisibilityBoxLocked=!1,this._alwaysVisible=!1,this._groups=new Array,this._groupCounter=0,this._computeParticleColor=!0,this._computeParticleTexture=!0,this._computeParticleRotation=!0,this._computeBoundingBox=!1,this._isReady=!1,this.name=t,this._size=e,this._scene=n||te.a.LastCreatedScene,i&&i.updatable!==void 0?this._updatable=i.updatable:this._updatable=!0}return r.prototype.buildMeshAsync=function(){var t=this;return Promise.all(this._promises).then(function(){return t._isReady=!0,t._buildMesh()})},r.prototype._buildMesh=function(){this.nbParticles===0&&this.addPoints(1),this._positions32=new Float32Array(this._positions),this._uvs32=new Float32Array(this._uvs),this._colors32=new Float32Array(this._colors);var t=new ft.a;t.set(this._positions32,Me.b.PositionKind),this._uvs32.length>0&&t.set(this._uvs32,Me.b.UVKind);var e=0;this._colors32.length>0&&(e=1,t.set(this._colors32,Me.b.ColorKind));var n=new De.a(this.name,this._scene);t.applyToMesh(n,this._updatable),this.mesh=n,this._positions=null,this._uvs=null,this._colors=null,this._updatable||(this.particles.length=0);var i=new Ft.a("point cloud material",this._scene);return i.emissiveColor=new M.a(e,e,e),i.disableLighting=!0,i.pointsCloud=!0,i.pointSize=this._size,n.material=i,new Promise(function(o){return o(n)})},r.prototype._addParticle=function(t,e,n,i){var o=new Bd(t,e,n,i,this);return this.particles.push(o),o},r.prototype._randomUnitVector=function(t){t.position=new u.e(Math.random(),Math.random(),Math.random()),t.color=new M.b(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],d=s[1],p=s[2],y=s[3],P=o[s[0]],O=o[d],U=o[p],F=o[y];return new M.b(P/255,O/255,U/255,F)},r.prototype._setPointsColorOrUV=function(t,e,n,i,o,a,s){n&&t.updateFacetData();var d=2*t.getBoundingInfo().boundingSphere.radius,p=t.getVerticesData(Me.b.PositionKind),y=t.getIndices(),P=t.getVerticesData(Me.b.UVKind),O=t.getVerticesData(Me.b.ColorKind),U=u.e.Zero();t.computeWorldMatrix();var F=t.getWorldMatrix();if(!F.isIdentity())for(var z=0;z<p.length/3;z++)u.e.TransformCoordinatesFromFloatsToRef(p[3*z],p[3*z+1],p[3*z+2],F,U),p[3*z]=U.x,p[3*z+1]=U.y,p[3*z+2]=U.z;var J,ie,se=0,ce=0,ue=0,fe=0,ve=0,Te=0,Oe=0,Pe=0,Ee=0,Se=0,Le=0,xe=0,Ne=0,Ie=0,Fe=u.e.Zero(),Ke=u.e.Zero(),nt=u.e.Zero(),rt=u.e.Zero(),ut=u.e.Zero(),qe=0,at=0,ot=0,Je=0,dt=0,Ve=0,$e=u.d.Zero(),yt=u.d.Zero(),Wt=u.d.Zero(),Nt=u.d.Zero(),Qt=u.d.Zero(),vt=0,Jt=0,Xt=0,zt=0,Yt=0,Et=0,Mt=0,$t=0,Mn=0,Bn=0,qn=0,In=0,qt=u.f.Zero(),si=u.f.Zero(),xi=u.f.Zero(),kr=u.f.Zero(),Gr=u.f.Zero(),ci=0,Gi=0;s=s||0;var zr,jt=new u.f(0,0,0,0),zi=u.e.Zero(),Tn=u.e.Zero(),cr=u.e.Zero(),Ri=0,ja=u.e.Zero(),Ha=0,jr=0,ji=new dn.a(u.e.Zero(),new u.e(1,0,0)),Hi=u.e.Zero();for(ce=0;ce<y.length/3;ce++){var lr,Wi,Hr,Wr,Xr,Xi,Yi,Yr;ue=y[3*ce],fe=y[3*ce+1],ve=y[3*ce+2],Te=p[3*ue],Oe=p[3*ue+1],Pe=p[3*ue+2],Ee=p[3*fe],Se=p[3*fe+1],Le=p[3*fe+2],xe=p[3*ve],Ne=p[3*ve+1],Ie=p[3*ve+2],Fe.set(Te,Oe,Pe),Ke.set(Ee,Se,Le),nt.set(xe,Ne,Ie),Ke.subtractToRef(Fe,rt),nt.subtractToRef(Ke,ut),P&&(qe=P[2*ue],at=P[2*ue+1],ot=P[2*fe],Je=P[2*fe+1],dt=P[2*ve],Ve=P[2*ve+1],$e.set(qe,at),yt.set(ot,Je),Wt.set(dt,Ve),yt.subtractToRef($e,Nt),Wt.subtractToRef(yt,Qt)),O&&i&&(vt=O[4*ue],Jt=O[4*ue+1],Xt=O[4*ue+2],zt=O[4*ue+3],Yt=O[4*fe],Et=O[4*fe+1],Mt=O[4*fe+2],$t=O[4*fe+3],Mn=O[4*ve],Bn=O[4*ve+1],qn=O[4*ve+2],In=O[4*ve+3],qt.set(vt,Jt,Xt,zt),si.set(Yt,Et,Mt,$t),xi.set(Mn,Bn,qn,In),si.subtractToRef(qt,kr),xi.subtractToRef(si,Gr));for(var Oi,Dn,Mo=new M.a(0,0,0),ur=new M.a(0,0,0),Io=0;Io<e._groupDensity[ce];
9255Io++)se=this.particles.length,this._addParticle(se,e,this._groupCounter,ce+Io),Dn=this.particles[se],ci=$.a.RandomRange(0,1),Gi=$.a.RandomRange(0,1),J=Fe.add(rt.scale(ci)).add(ut.scale(ci*Gi)),n&&(zi=t.getFacetNormal(ce).normalize().scale(-1),Tn=rt.clone().normalize(),cr=u.e.Cross(zi,Tn),Ri=$.a.RandomRange(0,2*Math.PI),ja=Tn.scale(Math.cos(Ri)).add(cr.scale(Math.sin(Ri))),Ri=$.a.RandomRange(.1,Math.PI/2),Hi=ja.scale(Math.cos(Ri)).add(zi.scale(Math.sin(Ri))),ji.origin=J.add(Hi.scale(1e-5)),ji.direction=Hi,ji.length=d,(zr=ji.intersectsMesh(t)).hit&&(jr=zr.pickedPoint.subtract(J).length(),Ha=$.a.RandomRange(0,1)*jr,J.addInPlace(Hi.scale(Ha)))),Dn.position=J.clone(),this._positions.push(Dn.position.x,Dn.position.y,Dn.position.z),i!==void 0?P&&(ie=$e.add(Nt.scale(ci)).add(Qt.scale(ci*Gi)),i?o&&e._groupImageData!==null?(lr=e._groupImgWidth,Wi=e._groupImgHeight,Oi=this._getColorIndicesForCoord(e,Math.round(ie.x*lr),Math.round(ie.y*Wi),lr),Dn.color=Oi,this._colors.push(Oi.r,Oi.g,Oi.b,Oi.a)):O?(jt=qt.add(kr.scale(ci)).add(Gr.scale(ci*Gi)),Dn.color=new M.b(jt.x,jt.y,jt.z,jt.w),this._colors.push(jt.x,jt.y,jt.z,jt.w)):(jt=qt.set(Math.random(),Math.random(),Math.random(),1),Dn.color=new M.b(jt.x,jt.y,jt.z,jt.w),this._colors.push(jt.x,jt.y,jt.z,jt.w)):(Dn.uv=ie.clone(),this._uvs.push(Dn.uv.x,Dn.uv.y))):(a?(Mo.set(a.r,a.g,a.b),Hr=$.a.RandomRange(-s,s),Wr=$.a.RandomRange(-s,s),Xr=(Yr=Mo.toHSV()).r,(Xi=Yr.g+Hr)<0&&(Xi=0),Xi>1&&(Xi=1),(Yi=Yr.b+Wr)<0&&(Yi=0),Yi>1&&(Yi=1),M.a.HSVtoRGBToRef(Xr,Xi,Yi,ur),jt.set(ur.r,ur.g,ur.b,1)):jt=qt.set(Math.random(),Math.random(),Math.random(),1),Dn.color=new M.b(jt.x,jt.y,jt.z,jt.w),this._colors.push(jt.x,jt.y,jt.z,jt.w))}},r.prototype._colorFromTexture=function(t,e,n){var i=this;if(t.material===null)return l.a.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 l.a.Warn(t.name+"has no useable 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){zn.a.WhenAllReady(o,function(){var d=e._textureNb;return d<0&&(d=0),d>o.length-1&&(d=o.length-1),e._groupImageData=o[d].readPixels(),e._groupImgWidth=o[d].getSize().width,e._groupImgHeight=o[d].getSize().height,i._setPointsColorOrUV(a,e,n,!0,!0),a.dispose(),s()})}))},r.prototype._calculateDensity=function(t,e,n){for(var i,o,a,s,d,p,y,P,O,U,F,z,J,ie,se,ce,ue,fe=new Array,ve=u.e.Zero(),Te=u.e.Zero(),Oe=u.e.Zero(),Pe=u.e.Zero(),Ee=u.e.Zero(),Se=u.e.Zero(),Le=new Array,xe=0,Ne=n.length/3,Ie=0;Ie<Ne;Ie++)i=n[3*Ie],o=n[3*Ie+1],a=n[3*Ie+2],s=e[3*i],d=e[3*i+1],p=e[3*i+2],y=e[3*o],P=e[3*o+1],O=e[3*o+2],U=e[3*a],F=e[3*a+1],z=e[3*a+2],ve.set(s,d,p),Te.set(y,P,O),Oe.set(U,F,z),Te.subtractToRef(ve,Pe),Oe.subtractToRef(Te,Ee),Oe.subtractToRef(ve,Se),ce=((J=Pe.length())+(ie=Ee.length())+(se=Se.length()))/2,xe+=ue=Math.sqrt(ce*(ce-J)*(ce-ie)*(ce-se)),Le[Ie]=ue;var Fe=0;for(Ie=0;Ie<Ne;Ie++)fe[Ie]=Math.floor(t*Le[Ie]/xe),Fe+=fe[Ie];var Ke=t-Fe,nt=Math.floor(Ke/Ne),rt=Ke%Ne;for(nt>0&&(fe=fe.map(function(ut){return ut+nt})),Ie=0;Ie<rt;Ie++)fe[Ie]+=1;return fe},r.prototype.addPoints=function(t,e){e===void 0&&(e=this._randomUnitVector);for(var n,i=new Ca(this._groupCounter,e),o=this.nbParticles,a=0;a<t;a++)n=this._addParticle(o,i,this._groupCounter,a),i&&i._positionFunction&&i._positionFunction(n,o,a),this._positions.push(n.position.x,n.position.y,n.position.z),n.color&&this._colors.push(n.color.r,n.color.g,n.color.b,n.color.a),n.uv&&this._uvs.push(n.uv.x,n.uv.y),o++;return this.nbParticles+=t,this._groupCounter++,this._groupCounter},r.prototype.addSurfacePoints=function(t,e,n,i,o){var a=n||yn.Random;(isNaN(a)||a<0||a>3)&&(a=yn.Random);var s=t.getVerticesData(Me.b.PositionKind),d=t.getIndices();this._groups.push(this._groupCounter);var p=new Ca(this._groupCounter,null);switch(p._groupDensity=this._calculateDensity(e,s,d),a===yn.Color?p._textureNb=i||0:i=i||new M.b(1,1,1,1),a){case yn.Color:this._colorFromTexture(t,p,!1);break;case yn.UV:this._setPointsColorOrUV(t,p,!1,!1,!1);break;case yn.Random:this._setPointsColorOrUV(t,p,!1);break;case yn.Stated:this._setPointsColorOrUV(t,p,!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||yn.Random;(isNaN(a)||a<0||a>3)&&(a=yn.Random);var s=t.getVerticesData(Me.b.PositionKind),d=t.getIndices();this._groups.push(this._groupCounter);var p=new Ca(this._groupCounter,null);switch(p._groupDensity=this._calculateDensity(e,s,d),a===yn.Color?p._textureNb=i||0:i=i||new M.b(1,1,1,1),a){case yn.Color:this._colorFromTexture(t,p,!0);break;case yn.UV:this._setPointsColorOrUV(t,p,!0,!1,!1);break;case yn.Random:this._setPointsColorOrUV(t,p,!0);break;case yn.Stated:this._setPointsColorOrUV(t,p,!0,void 0,void 0,i,o)}return this.nbParticles+=e,this._groupCounter++,this._groupCounter-1},r.prototype.setParticles=function(t,e,n){if(t===void 0&&(t=0),e===void 0&&(e=this.nbParticles-1),n===void 0&&(n=!0),!this._updatable||!this._isReady)return this;this.beforeUpdateParticles(t,e,n);var i=u.c.Matrix[0],o=this.mesh,a=this._colors32,s=this._positions32,d=this._uvs32,p=u.c.Vector3,y=p[5].copyFromFloats(1,0,0),P=p[6].c
9255opyFromFloats(0,1,0),O=p[7].copyFromFloats(0,0,1),U=p[8].setAll(Number.MAX_VALUE),F=p[9].setAll(-Number.MAX_VALUE);u.a.IdentityToRef(i);var z=0;if(this.mesh.isFacetDataEnabled&&(this._computeBoundingBox=!0),e=e>=this.nbParticles?this.nbParticles-1:e,this._computeBoundingBox&&(t!=0||e!=this.nbParticles-1)){var J=this.mesh._boundingInfo;J&&(U.copyFrom(J.minimum),F.copyFrom(J.maximum))}z=0;for(var ie=0,se=0,ce=0,ue=t;ue<=e;ue++){var fe=this.particles[ue];ie=3*(z=fe.idx),se=4*z,ce=2*z,this.updateParticle(fe);var ve=fe._rotationMatrix,Te=fe.position,Oe=fe._globalPosition;if(this._computeParticleRotation&&fe.getRotationMatrix(i),fe.parentId!==null){var Pe=this.particles[fe.parentId],Ee=Pe._rotationMatrix,Se=Pe._globalPosition,Le=Te.x*Ee[1]+Te.y*Ee[4]+Te.z*Ee[7],xe=Te.x*Ee[0]+Te.y*Ee[3]+Te.z*Ee[6],Ne=Te.x*Ee[2]+Te.y*Ee[5]+Te.z*Ee[8];if(Oe.x=Se.x+xe,Oe.y=Se.y+Le,Oe.z=Se.z+Ne,this._computeParticleRotation){var Ie=i.m;ve[0]=Ie[0]*Ee[0]+Ie[1]*Ee[3]+Ie[2]*Ee[6],ve[1]=Ie[0]*Ee[1]+Ie[1]*Ee[4]+Ie[2]*Ee[7],ve[2]=Ie[0]*Ee[2]+Ie[1]*Ee[5]+Ie[2]*Ee[8],ve[3]=Ie[4]*Ee[0]+Ie[5]*Ee[3]+Ie[6]*Ee[6],ve[4]=Ie[4]*Ee[1]+Ie[5]*Ee[4]+Ie[6]*Ee[7],ve[5]=Ie[4]*Ee[2]+Ie[5]*Ee[5]+Ie[6]*Ee[8],ve[6]=Ie[8]*Ee[0]+Ie[9]*Ee[3]+Ie[10]*Ee[6],ve[7]=Ie[8]*Ee[1]+Ie[9]*Ee[4]+Ie[10]*Ee[7],ve[8]=Ie[8]*Ee[2]+Ie[9]*Ee[5]+Ie[10]*Ee[8]}}else Oe.x=0,Oe.y=0,Oe.z=0,this._computeParticleRotation&&(Ie=i.m,ve[0]=Ie[0],ve[1]=Ie[1],ve[2]=Ie[2],ve[3]=Ie[4],ve[4]=Ie[5],ve[5]=Ie[6],ve[6]=Ie[8],ve[7]=Ie[9],ve[8]=Ie[10]);var Fe=p[11];fe.translateFromPivot?Fe.setAll(0):Fe.copyFrom(fe.pivot);var Ke=p[0];Ke.copyFrom(fe.position);var nt=Ke.x-fe.pivot.x,rt=Ke.y-fe.pivot.y,ut=Ke.z-fe.pivot.z,qe=nt*ve[0]+rt*ve[3]+ut*ve[6],at=nt*ve[1]+rt*ve[4]+ut*ve[7],ot=nt*ve[2]+rt*ve[5]+ut*ve[8];qe+=Fe.x,at+=Fe.y,ot+=Fe.z;var Je=s[ie]=Oe.x+y.x*qe+P.x*at+O.x*ot,dt=s[ie+1]=Oe.y+y.y*qe+P.y*at+O.y*ot,Ve=s[ie+2]=Oe.z+y.z*qe+P.z*at+O.z*ot;if(this._computeBoundingBox&&(U.minimizeInPlaceFromFloats(Je,dt,Ve),F.maximizeInPlaceFromFloats(Je,dt,Ve)),this._computeParticleColor&&fe.color){var $e=fe.color,yt=this._colors32;yt[se]=$e.r,yt[se+1]=$e.g,yt[se+2]=$e.b,yt[se+3]=$e.a}if(this._computeParticleTexture&&fe.uv){var Wt=fe.uv,Nt=this._uvs32;Nt[ce]=Wt.x,Nt[ce+1]=Wt.y}}return n&&(this._computeParticleColor&&o.updateVerticesData(Me.b.ColorKind,a,!1,!1),this._computeParticleTexture&&o.updateVerticesData(Me.b.UVKind,d,!1,!1),o.updateVerticesData(Me.b.PositionKind,s,!1,!1)),this._computeBoundingBox&&(o._boundingInfo?o._boundingInfo.reConstruct(U,F,o._worldMatrix):o._boundingInfo=new Fi.a(U,F,o._worldMatrix)),this.afterUpdateParticles(t,e,n),this},r.prototype.dispose=function(){this.mesh.dispose(),this.vars=null,this._positions=null,this._indices=null,this._normals=null,this._uvs=null,this._colors=null,this._indices32=null,this._positions32=null,this._uvs32=null,this._colors32=null},r.prototype.refreshVisibleSize=function(){return this._isVisibilityBoxLocked||this.mesh.refreshBoundingInfo(),this},r.prototype.setVisibilityBox=function(t){var e=t/2;this.mesh._boundingInfo=new Fi.a(new u.e(-e,-e,-e),new u.e(e,e,e))},Object.defineProperty(r.prototype,"isAlwaysVisible",{get:function(){return this._alwaysVisible},set:function(t){this._alwaysVisible=t,this.mesh.alwaysSelectAsActiveMesh=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"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}();_e.a.prototype.getPhysicsEngine=function(){return this._physicsEngine},_e.a.prototype.enablePhysics=function(r,t){if(r===void 0&&(r=null),this._physicsEngine)return!0;var e=this._getComponent(st.a.NAME_PHYSICSENGINE);e||(e=new Ud(this),this._addComponent(e));try{return this._physicsEngine=new Mr(r,t),this._physicsTimeAccumulator=0,!0}catch(n){return l.a.Error(n.message),!1}},_e.a.prototype.disablePhysicsEngine=function(){this._physicsEngine&&(this._physicsEngine.dispose(),this._physicsEngine=null)},_e.a.prototype.isPhysicsEnabled=function(){return this._physicsEngine!==void 0},_e.a.prototype.deleteCompoundImpostor=function(r){var t=r.parts[0].mesh;t.physicsImpostor&&(t.physicsImpostor.dispose(),t.physicsImpostor=null)},_e.a.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)}},Object.defineProperty(Dt.a.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}),Dt.a.prototype.getPhysicsImpostor=function(){return this.physicsImpostor},Dt.a.prototype.applyImpulse=function(r,t){return this.physicsImpostor?(this.physicsImpostor.applyImpulse(r,t),this):this},Dt.a.prototype.setPhysicsLinkWith=function(r,t,e,n){return this.physicsImpostor&&r.physicsImpostor?(this.physicsImpostor.createJoint(r.physicsImpostor,en.e.HingeJoint,{mainPivot:t,connectedPivot:e,nativeParams:n}),this):this};var xo,Fr,Ud=function(){function r(t){var e=this;this.name=st.a.NAME_PHYSICSENGINE,this.scene=t,this.scene.onBeforePhysicsObservable=new x.c,this.scene.onAfterPhysicsObservable=new x.c,this.scene.getDeterministicFrameTime=function(){return e.sce
9255ne._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}(),hg=function(){function r(t){this._scene=t,this._physicsEngine=this._scene.getPhysicsEngine(),this._physicsEngine||l.a.Warn("Physics engine not enabled. Please enable the physics before you can use the methods.")}return r.prototype.applyRadialExplosionImpulse=function(t,e,n,i){if(!this._physicsEngine)return l.a.Warn("Physics engine not enabled. Please enable the physics before you call this method."),null;var o=this._physicsEngine.getImpostors();if(o.length===0)return null;typeof e=="number"&&((e=new Br).radius=e,e.strength=n||e.strength,e.falloff=i||e.falloff);var a=new Vd(this._scene,e),s=Array();return o.forEach(function(d){var p=a.getImpostorHitData(d,t);p&&(d.applyImpulse(p.force,p.contactPoint),s.push({impostor:d,hitData:p}))}),a.triggerAffectedImpostorsCallback(s),a.dispose(!1),a},r.prototype.applyRadialExplosionForce=function(t,e,n,i){if(!this._physicsEngine)return l.a.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),null;var o=this._physicsEngine.getImpostors();if(o.length===0)return null;typeof e=="number"&&((e=new Br).radius=e,e.strength=n||e.strength,e.falloff=i||e.falloff);var a=new Vd(this._scene,e),s=Array();return o.forEach(function(d){var p=a.getImpostorHitData(d,t);p&&(d.applyForce(p.force,p.contactPoint),s.push({impostor:d,hitData:p}))}),a.triggerAffectedImpostorsCallback(s),a.dispose(!1),a},r.prototype.gravitationalField=function(t,e,n,i){if(!this._physicsEngine)return l.a.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),null;if(this._physicsEngine.getImpostors().length===0)return null;typeof e=="number"&&((e=new Br).radius=e,e.strength=n||e.strength,e.falloff=i||e.falloff);var o=new dg(this,this._scene,t,e);return o.dispose(!1),o},r.prototype.updraft=function(t,e,n,i,o){if(!this._physicsEngine)return l.a.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),null;if(this._physicsEngine.getImpostors().length===0)return null;typeof e=="number"&&((e=new Bc).radius=e,e.strength=n||e.strength,e.height=i||e.height,e.updraftMode=o||e.updraftMode);var a=new fg(this._scene,t,e);return a.dispose(!1),a},r.prototype.vortex=function(t,e,n,i){if(!this._physicsEngine)return l.a.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),null;if(this._physicsEngine.getImpostors().length===0)return null;typeof e=="number"&&((e=new Uc).radius=e,e.strength=n||e.strength,e.height=i||e.height);var o=new pg(this._scene,t,e);return o.dispose(!1),o},r}(),Vd=function(){function r(t,e){this._scene=t,this._options=e,this._dataFetched=!1,this._options=Object(c.a)(Object(c.a)({},new Br),this._options)}return r.prototype.getData=function(){return this._dataFetched=!0,{sphere:this._sphere}},r.prototype.getImpostorHitData=function(t,e){if(t.mass===0||!this._intersectsWithSphere(t,e,this._options.radius)||t.object.getClassName()!=="Mesh"&&t.object.getClassName()!=="InstancedMesh")return null;var n=t.getObjectCenter().subtract(e),i=new dn.a(e,n,this._options.radius).intersectsMesh(t.object).pickedPoint;if(!i)return null;var o=u.e.Distance(e,i);if(o>this._options.radius)return null;var a=this._options.falloff===xo.Constant?this._options.strength:this._options.strength*(1-o/this._options.radius);return{force:n.multiplyByFloats(a,a,a),contactPoint:i,distanceFromOrigin:o}},r.prototype.triggerAffectedImpostorsCallback=function(t){this._options.affectedImpostorsCallback&&this._options.affectedImpostorsCallback(t)},r.prototype.dispose=function(t){var e=this;t===void 0&&(t=!0),t?this._sphere.dispose():setTimeout(function(){e._dataFetched||e._sphere.dispose()},0)},r.prototype._prepareSphere=function(){this._sphere||(this._sphere=Nn.a.CreateSphere("radialExplosionEventSphere",this._options.sphere,this._scene),this._sphere.isVisible=!1)},r.prototype._intersectsWithSphere=function(t,e,n){var i=t.object;return this._prepareSphere(),this._sphere.position=e,this._sphere.scaling=new u.e(2*n,2*n,2*n),this._sphere._updateBoundingInfo(),this._sphere.computeWorldMatrix(!0),this._sphere.intersectsMesh(i,!0)},r}(),dg=function(){function r(t,e,n,i){this._physicsHelper=t,this._scene=e,this._origin=n,this._options=i,this._dataFetched=!1,this._options=Object(c.a)(Object(c.a)({},new Br),this._options),this._tickCallback=this._tick.bind(this),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),t?this._sphere.dispose():setTimeout(function(){e._dataFetched||e._sphere.dispose()},0)},r.prototype._tick=function(){if(this._sphere)this._physicsHelper.applyRadialExplosionForce(this._origin,this._options);else{var t=this._physicsHelper.applyRadialExplosionForce(this._origin,this._options);t&&(this._sphere=t.getData().sphere.clone("radialExplosionEventSphereClone"))}},r}(),fg=function(){function r(t,e,n){this._scene=t,this._origin=e,this._options=n,this._originTop=u.e.Zero(),this._originDirection=u.e.Zero(),this._cylinderPosition=u.e.Zero(),this._dataFetched=!1,this._physicsEngine=this._scene.getPhysicsEngine(),this._options=Object(c.a)(Object(c.a)({},new Bc),this._options),this._origin.addToRef(new u.e(0,this._options.height/2,0),this._cylinderPosition),this._origin.addToRef(new u.e(0,this._options.height,0),this._originTop),this._options.updraftMode===Fr.Perpendicular&&(this._originDirection=this._origin.subtract(this._originTop).normalize()),this._tickCallback=this._tick.bind(this),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.getImpostorHitData=function(t){if(t.mass===0||!this._intersectsWithCylinder(t))return null;var e=t.getObjectCenter();if(this._options.updraftMode===Fr.Perpendicular)var n=this._originDirection;else n=e.subtract(this._originTop);var i=u.e.Distance(this._origin,e),o=-1*this._options.strength;return{force:n.multiplyByFloats(o,o,o),contactPoint:e,distanceFromOrigin:i}},r.prototype._tick=function(){var t=this;
9255this._physicsEngine.getImpostors().forEach(function(e){var n=t.getImpostorHitData(e);n&&e.applyForce(n.force,n.contactPoint)})},r.prototype._prepareCylinder=function(){this._cylinder||(this._cylinder=ui.a.CreateCylinder("updraftEventCylinder",{height:this._options.height,diameter:2*this._options.radius},this._scene),this._cylinder.isVisible=!1)},r.prototype._intersectsWithCylinder=function(t){var e=t.object;return this._cylinder.position=this._cylinderPosition,this._cylinder.intersectsMesh(e,!0)},r}(),pg=function(){function r(t,e,n){this._scene=t,this._origin=e,this._options=n,this._originTop=u.e.Zero(),this._cylinderPosition=u.e.Zero(),this._dataFetched=!1,this._physicsEngine=this._scene.getPhysicsEngine(),this._options=Object(c.a)(Object(c.a)({},new Uc),this._options),this._origin.addToRef(new u.e(0,this._options.height/2,0),this._cylinderPosition),this._origin.addToRef(new u.e(0,this._options.height,0),this._originTop),this._tickCallback=this._tick.bind(this),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),t?this._cylinder.dispose():setTimeout(function(){e._dataFetched||e._cylinder.dispose()},0)},r.prototype.getImpostorHitData=function(t){if(t.mass===0||!this._intersectsWithCylinder(t)||t.object.getClassName()!=="Mesh"&&t.object.getClassName()!=="InstancedMesh")return null;var e=t.getObjectCenter(),n=new u.e(this._origin.x,e.y,this._origin.z),i=e.subtract(n),o=new dn.a(n,i,this._options.radius).intersectsMesh(t.object),a=o.pickedPoint;if(!a)return null;var s=o.distance/this._options.radius,d=a.normalize();if(s>this._options.centripetalForceThreshold&&(d=d.negate()),s>this._options.centripetalForceThreshold)var p=d.x*this._options.centripetalForceMultiplier,y=d.y*this._options.updraftForceMultiplier,P=d.z*this._options.centripetalForceMultiplier;else{var O=u.e.Cross(n,e).normalize();p=(O.x+d.x)*this._options.centrifugalForceMultiplier,y=this._originTop.y*this._options.updraftForceMultiplier,P=(O.z+d.z)*this._options.centrifugalForceMultiplier}var U=new u.e(p,y,P);return{force:U=U.multiplyByFloats(this._options.strength,this._options.strength,this._options.strength),contactPoint:e,distanceFromOrigin:s}},r.prototype._tick=function(){var t=this;this._physicsEngine.getImpostors().forEach(function(e){var n=t.getImpostorHitData(e);n&&e.applyForce(n.force,n.contactPoint)})},r.prototype._prepareCylinder=function(){this._cylinder||(this._cylinder=ui.a.CreateCylinder("vortexEventCylinder",{height:this._options.height,diameter:2*this._options.radius},this._scene),this._cylinder.isVisible=!1)},r.prototype._intersectsWithCylinder=function(t){var e=t.object;return this._cylinder.position=this._cylinderPosition,this._cylinder.intersectsMesh(e,!0)},r}(),Br=function(){this.radius=5,this.strength=10,this.falloff=xo.Constant,this.sphere={segments:32,diameter:1}},Bc=function(){this.radius=5,this.strength=10,this.height=10,this.updraftMode=Fr.Center},Uc=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"})(xo||(xo={})),function(r){r[r.Center=0]="Center",r[r.Perpendicular=1]="Perpendicular"}(Fr||(Fr={}));var _g=`
9256varying vec2 vUV;
9257uniform sampler2D textureSampler;
9258uniform float degree;
9259void main(void)
9260{
9261vec3 color=texture2D(textureSampler,vUV).rgb;
9262float luminance=dot(color,vec3(0.3,0.59,0.11));
9263vec3 blackAndWhite=vec3(luminance,luminance,luminance);
9264gl_FragColor=vec4(color-((color-blackAndWhite)*degree),1.0);
9265}`;je.a.ShadersStore.blackAndWhitePixelShader=_g;var kd=function(r){function t(e,n,i,o,a,s){var d=r.call(this,e,"blackAndWhite",["degree"],null,n,i,o,a,s)||this;return d.degree=1,d.onApplyObservable.add(function(p){p.setFloat("degree",d.degree)}),d}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"BlackAndWhitePostProcess"},t._Parse=function(e,n,i,o){return L.a.Parse(function(){return new t(e.name,e.options,n,e.renderTargetSamplingMode,i.getEngine(),e.reusable)},e,i,o)},Object(c.c)([Object(L.c)()],t.prototype,"degree",void 0),t}(_t);R.a.RegisteredTypes["BABYLON.BlackAndWhitePostProcess"]=kd;var Rt=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(this._postProcesses.hasOwnProperty(t)){for(var e=this._postProcesses[t],n=0;n<e.length;n++)if(!e[n].isSupported)return!1}return!0}
9265,enumerable:!1,configurable:!0}),r.prototype._update=function(){},r.prototype._attachCameras=function(t){var e,n=this,i=Ye.b.MakeArray(t||this._cameras);if(i)for(var o=0;o<i.length;o++){var a=i[o];if(a){var s=a.name;if(e=this._singleInstance?0:s,!this._postProcesses[e]){var d=this._getPostProcesses();d&&(this._postProcesses[e]=Array.isArray(d)?d:[d])}this._indicesForCamera[s]||(this._indicesForCamera[s]=[]),this._postProcesses[e].forEach(function(p){var y=a.attachPostProcess(p);n._indicesForCamera[s].push(y)}),this._cameras[s]||(this._cameras[s]=a)}}},r.prototype._detachCameras=function(t){var e=Ye.b.MakeArray(t||this._cameras);if(e)for(var n=0;n<e.length;n++){var i=e[n],o=i.name,a=this._postProcesses[this._singleInstance?0:o];a&&a.forEach(function(s){i.detachPostProcess(s)}),this._cameras[o]&&(this._cameras[o]=null)}},r.prototype._enable=function(t){var e=this,n=Ye.b.MakeArray(t||this._cameras);if(n)for(var i=0;i<n.length;i++)for(var o=n[i],a=o.name,s=0;s<this._indicesForCamera[a].length;s++)o._postProcesses[this._indicesForCamera[a][s]]!==void 0&&o._postProcesses[this._indicesForCamera[a][s]]!==null||this._postProcesses[this._singleInstance?0:a].forEach(function(d){n[i].attachPostProcess(d,e._indicesForCamera[a][s])})},r.prototype._disable=function(t){var e=Ye.b.MakeArray(t||this._cameras);if(e)for(var n=0;n<e.length;n++){var i=e[n],o=i.name;this._postProcesses[this._singleInstance?0:o].forEach(function(a){i.detachPostProcess(a)})}},r.prototype.getPostProcesses=function(t){return this._singleInstance?this._postProcesses[0]:t?this._postProcesses[t.name]:null},r}(),mg=`#include<helperFunctions>
9266
9267varying vec2 vUV;
9268uniform sampler2D textureSampler;
9269uniform float threshold;
9270uniform float exposure;
9271void main(void)
9272{
9273gl_FragColor=texture2D(textureSampler,vUV);
9274float luma=getLuminance(gl_FragColor.rgb*exposure);
9275gl_FragColor.rgb=step(threshold,luma)*gl_FragColor.rgb;
9276}`;je.a.ShadersStore.extractHighlightsPixelShader=mg;var Vc=function(r){function t(e,n,i,o,a,s,d,p){d===void 0&&(d=h.a.TEXTURETYPE_UNSIGNED_INT),p===void 0&&(p=!1);var y=r.call(this,e,"extractHighlights",["threshold","exposure"],null,n,i,o,a,s,null,d,void 0,null,p)||this;return y.threshold=.9,y._exposure=1,y._inputPostProcess=null,y.onApplyObservable.add(function(P){y._inputPostProcess&&P.setTextureFromPostProcess("textureSampler",y._inputPostProcess),P.setFloat("threshold",Math.pow(y.threshold,Gt.b)),P.setFloat("exposure",y._exposure)}),y}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"ExtractHighlightsPostProcess"},Object(c.c)([Object(L.c)()],t.prototype,"threshold",void 0),t}(_t);R.a.RegisteredTypes["BABYLON.ExtractHighlightsPostProcess"]=Vc;var gg=`uniform sampler2D textureSampler;
9277uniform sampler2D bloomBlur;
9278varying vec2 vUV;
9279uniform float bloomWeight;
9280void main(void)
9281{
9282gl_FragColor=texture2D(textureSampler,vUV);
9283vec3 blurred=texture2D(bloomBlur,vUV).rgb;
9284gl_FragColor.rgb=gl_FragColor.rgb+(blurred.rgb*bloomWeight);
9285}
9286`;je.a.ShadersStore.bloomMergePixelShader=gg;var kc=function(r){function t(e,n,i,o,a,s,d,p,y,P,O){P===void 0&&(P=h.a.TEXTURETYPE_UNSIGNED_INT),O===void 0&&(O=!1);var U=r.call(this,e,"bloomMerge",["bloomWeight"],["circleOfConfusionSampler","blurStep0","blurStep1","blurStep2","bloomBlur"],a,s,d,p,y,null,P,void 0,null,!0)||this;return U.weight=1,U.weight=o,U.onApplyObservable.add(function(F){F.setTextureFromPostProcess("textureSampler",n),F.setTextureFromPostProcessOutput("bloomBlur",i),F.setFloat("bloomWeight",U.weight)}),O||U.updateEffect(),U}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"BloomMergePostProcess"},Object(c.c)([Object(L.c)()],t.prototype,"weight",void 0),t}(_t);R.a.RegisteredTypes["BABYLON.BloomMergePostProcess"]=kc;var Gc=function(r){function t(e,n,i,o,a,s){a===void 0&&(a=0),s===void 0&&(s=!1);var d=r.call(this,e.getEngine(),"bloom",function(){return d._effects},!0)||this;return d.bloomScale=n,d._effects=[],d._downscale=new Vc("highlights",1,null,we.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,a,s),d._blurX=new _n("horizontal blur",new u.d(1,0),10,n,null,we.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,a,void 0,s),d._blurX.alwaysForcePOT=!0,d._blurX.autoClear=!1,d._blurY=new _n("vertical blur",new u.d(0,1),10,n,null,we.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,a,void 0,s),d._blurY.alwaysForcePOT=!0,d._blurY.autoClear=!1,d.kernel=o,d._effects=[d._downscale,d._blurX,d._blurY],d._merge=new kc("bloomMerge",d._downscale,d._blurY,i,n,null,we.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,a,s),d._merge.autoClear=!1,d._effects.push(d._merge),d}return Object(c.d)(t,r),Object.defineProperty(t.prototype,"threshold",{get:function(){return this._downscale.threshold}
9286,set:function(e){this._downscale.threshold=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"weight",{get:function(){return this._merge.weight},set:function(e){this._merge.weight=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"kernel",{get:function(){return this._blurX.kernel/this.bloomScale},set:function(e){this._blurX.kernel=e*this.bloomScale,this._blurY.kernel=e*this.bloomScale},enumerable:!1,configurable:!0}),t.prototype.disposeEffects=function(e){for(var n=0;n<this._effects.length;n++)this._effects[n].dispose(e)},t.prototype._updateEffects=function(){for(var e=0;e<this._effects.length;e++)this._effects[e].updateEffect()},t.prototype._isReady=function(){for(var e=0;e<this._effects.length;e++)if(!this._effects[e].isReady())return!1;return!0},t}(Rt),vg=`
9287uniform sampler2D textureSampler;
9288
9289uniform float chromatic_aberration;
9290uniform float radialIntensity;
9291uniform vec2 direction;
9292uniform vec2 centerPosition;
9293uniform float screen_width;
9294uniform float screen_height;
9295
9296varying vec2 vUV;
9297void main(void)
9298{
9299vec2 centered_screen_pos=vec2(vUV.x-centerPosition.x,vUV.y-centerPosition.y);
9300vec2 directionOfEffect=direction;
9301if(directionOfEffect.x == 0. && directionOfEffect.y == 0.){
9302directionOfEffect=normalize(centered_screen_pos);
9303}
9304float radius2=centered_screen_pos.x*centered_screen_pos.x
9305+centered_screen_pos.y*centered_screen_pos.y;
9306float radius=sqrt(radius2);
9307vec4 original=texture2D(textureSampler,vUV);
9308
9309vec3 ref_indices=vec3(-0.3,0.0,0.3);
9310float ref_shiftX=chromatic_aberration*pow(radius,radialIntensity)*directionOfEffect.x/screen_width;
9311float ref_shiftY=chromatic_aberration*pow(radius,radialIntensity)*directionOfEffect.y/screen_height;
9312
9313vec2 ref_coords_r=vec2(vUV.x+ref_indices.r*ref_shiftX,vUV.y+ref_indices.r*ref_shiftY*0.5);
9314vec2 ref_coords_g=vec2(vUV.x+ref_indices.g*ref_shiftX,vUV.y+ref_indices.g*ref_shiftY*0.5);
9315vec2 ref_coords_b=vec2(vUV.x+ref_indices.b*ref_shiftX,vUV.y+ref_indices.b*ref_shiftY*0.5);
9316original.r=texture2D(textureSampler,ref_coords_r).r;
9317original.g=texture2D(textureSampler,ref_coords_g).g;
9318original.b=texture2D(textureSampler,ref_coords_b).b;
9319original.a=clamp(texture2D(textureSampler,ref_coords_r).a+texture2D(textureSampler,ref_coords_g).a+texture2D(textureSampler,ref_coords_b).a,0.,1.);
9320gl_FragColor=original;
9321}`;je.a.ShadersStore.chromaticAberrationPixelShader=vg;var zc=function(r){function t(e,n,i,o,a,s,d,p,y,P){y===void 0&&(y=h.a.TEXTURETYPE_UNSIGNED_INT),P===void 0&&(P=!1);var O=r.call(this,e,"chromaticAberration",["chromatic_aberration","screen_width","screen_height","direction","radialIntensity","centerPosition"],[],o,a,s,d,p,null,y,void 0,null,P)||this;return O.aberrationAmount=30,O.radialIntensity=0,O.direction=new u.d(.707,.707),O.centerPosition=new u.d(.5,.5),O.screenWidth=n,O.screenHeight=i,O.onApplyObservable.add(function(U){U.setFloat("chromatic_aberration",O.aberrationAmount),U.setFloat("screen_width",n),U.setFloat("screen_height",i),U.setFloat("radialIntensity",O.radialIntensity),U.setFloat2("direction",O.direction.x,O.direction.y),U.setFloat2("centerPosition",O.centerPosition.x,O.centerPosition.y)}),O}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"ChromaticAberrationPostProcess"},t._Parse=function(e,n,i,o){return L.a.Parse(function(){return new t(e.name,e.screenWidth,e.screenHeight,e.options,n,e.renderTargetSamplingMode,i.getEngine(),e.reusable,e.textureType,!1)},e,i,o)},Object(c.c)([Object(L.c)()],t.prototype,"aberrationAmount",void 0),Object(c.c)([Object(L.c)()],t.prototype,"radialIntensity",void 0),Object(c.c)([Object(L.c)()],t.prototype,"direction",void 0),Object(c.c)([Object(L.c)()],t.prototype,"centerPosition",void 0),Object(c.c)([Object(L.c)()],t.prototype,"screenWidth",void 0),Object(c.c)([Object(L.c)()],t.prototype,"screenHeight",void 0),t}(_t);R.a.RegisteredTypes["BABYLON.ChromaticAberrationPostProcess"]=zc;var bg=`
9322uniform sampler2D depthSampler;
9323
9324varying vec2 vUV;
9325
9326uniform vec2 cameraMinMaxZ;
9327
9328uniform float focusDistance;
9329uniform float cocPrecalculation;
9330void main(void)
9331{
9332float depth=texture2D(depthSampler,vUV).r;
9333float pixelDistance=(cameraMinMaxZ.x+(cameraMinMaxZ.y-cameraMinMaxZ.x)*depth)*1000.0;
9334float coc=abs(cocPrecalculation* ((focusDistance-pixelDistance)/pixelDistance));
9335coc=clamp(coc,0.0,1.0);
9336gl_FragColor=vec4(coc,depth,coc,1.0);
9337}
9338`;je.a.ShadersStore.circleOfConfusionPixelShader=bg;var jc=function(r){function t(e,n,i,o,a,s,d,p,y){p===void 0&&(p=h.a.TEXTURETYPE_UNSIGNED_INT),y===void 0&&(y=!1);var P=r.call(this,e,"circleOfConfusion",["cameraMinMaxZ","focusDistance","cocPrecalculation"],["depthSampler"],i,o,a,s,d,null,p,void 0,null,y)||this;return P.lensSize=50,P.fStop=1.4,P.focusDistance=2e3,P.focalLength=50,P._depthTexture=null,P._depthTexture=n,P.onApplyObservable.add(function(O){if(P._depthTexture){O.setTexture("depthSampler",P._depthTexture);var U=P.lensSize/P.fStop*P.focalLength/(P.focusDistance-P.focalLength);O.setFloat("focusDistance",P.focusDistance),O.setFloat("cocPrecalculation",U),O.setFloat2("cameraMinMaxZ",P._depthTexture.activeCamera.minZ,P._depthTexture.activeCamera.maxZ)}else l.a.Warn("No depth texture set on CircleOfConfusionPostProcess")}),P}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"CircleOfConfusionPostProcess"},Object.defineProperty(t.prototype,"depthTexture",{set:function(e){this._depthTexture=e},enumerable:!1,configurable:!0}),Object(c.c)([Object(L.c)()],t.prototype,"lensSize",void 0),Object(c.c)([Object(L.c)()],t.prototype,"fStop",void 0),Object(c.c)([Object(L.c)()],t.prototype,"focusDistance",void 0),Object(c.c)([Object(L.c)()],t.prototype,"focalLength",void 0),t}(_t);R.a.RegisteredTypes["BABYLON.CircleOfConfusionPostProcess"]=jc;var yg=`
9339uniform sampler2D textureSampler;
9340uniform sampler2D colorTable;
9341
9342varying vec2 vUV;
9343
9344const float SLICE_COUNT=16.0;
9345
9346vec4 sampleAs3DTexture(sampler2D textureSampler,vec3 uv,float width) {
9347float sliceSize=1.0/width;
9348float slicePixelSize=sliceSize/width;
9349float sliceInnerSize=slicePixelSize*(width-1.0);
9350float zSlice0=min(floor(uv.z*width),width-1.0);
9351float zSlice1=min(zSlice0+1.0,width-1.0);
9352float xOffset=slicePixelSize*0.5+uv.x*sliceInnerSize;
9353float s0=xOffset+(zSlice0*sliceSize);
9354float s1=xOffset+(zSlice1*sliceSize);
9355vec4 slice0Color=texture2D(textureSampler,vec2(s0,uv.y));
9356vec4 slice1Color=texture2D(textureSampler,vec2(s1,uv.y));
9357float zOffset=mod(uv.z*width,1.0);
9358vec4 result=mix(slice0Color,slice1Color,zOffset);
9359return result;
9360}
9361void main(void)
9362{
9363vec4 screen_color=texture2D(textureSampler,vUV);
9364gl_FragColor=sampleAs3DTexture(colorTable,screen_color.rgb,SLICE_COUNT);
9365}`;je.a.ShadersStore.colorCorrectionPixelShader=yg;var Gd=function(r){function t(e,n,i,o,a,s,d){var p=r.call(this,e,"colorCorrection",null,["colorTable"],i,o,a,s,d)||this;return p._colorTableTexture=new we.a(n,o.getScene(),!0,!1,we.a.TRILINEAR_SAMPLINGMODE),p._colorTableTexture.anisotropicFilteringLevel=1,p._colorTableTexture.wrapU=we.a.CLAMP_ADDRESSMODE,p._colorTableTexture.wrapV=we.a.CLAMP_ADDRESSMODE,p.colorTableUrl=n,p.onApply=function(y){y.setTexture("colorTable",p._colorTableTexture)},p}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"ColorCorrectionPostProcess"},t._Parse=function(e,n,i,o){return L.a.Parse(function(){return new t(e.name,e.colorTableUrl,e.options,n,e.renderTargetSamplingMode,i.getEngine(),e.reusable)},e,i,o)},Object(c.c)([Object(L.c)()],t.prototype,"colorTableUrl",void 0),t}(_t);R.a.RegisteredTypes["BABYLON.ColorCorrectionPostProcess"]=Gd;var Tg=`
9366varying vec2 vUV;
9367uniform sampler2D textureSampler;
9368uniform vec2 screenSize;
9369uniform float kernel[9];
9370void main(void)
9371{
9372vec2 onePixel=vec2(1.0,1.0)/screenSize;
9373vec4 colorSum =
9374texture2D(textureSampler,vUV+onePixel*vec2(-1,-1))*kernel[0] +
9375texture2D(textureSampler,vUV+onePixel*vec2(0,-1))*kernel[1] +
9376texture2D(textureSampler,vUV+onePixel*vec2(1,-1))*kernel[2] +
9377texture2D(textureSampler,vUV+onePixel*vec2(-1,0))*kernel[3] +
9378texture2D(textureSampler,vUV+onePixel*vec2(0,0))*kernel[4] +
9379texture2D(textureSampler,vUV+onePixel*vec2(1,0))*kernel[5] +
9380texture2D(textureSampler,vUV+onePixel*vec2(-1,1))*kernel[6] +
9381texture2D(textureSampler,vUV+onePixel*vec2(0,1))*kernel[7] +
9382texture2D(textureSampler,vUV+onePixel*vec2(1,1))*kernel[8];
9383float kernelWeight =
9384kernel[0] +
9385kernel[1] +
9386kernel[2] +
9387kernel[3] +
9388kernel[4] +
9389kernel[5] +
9390kernel[6] +
9391kernel[7] +
9392kernel[8];
9393if (kernelWeight<=0.0) {
9394kernelWeight=1.0;
9395}
9396gl_FragColor=vec4((colorSum/kernelWeight).rgb,1);
9397}`;je.a.ShadersStore.convolutionPixelShader=Tg;var zd=function(r){function t(e,n,i,o,a,s,d,p){p===void 0&&(p=h.a.TEXTURETYPE_UNSIGNED_INT);var y=r.call(this,e,"convolution",["kernel","screenSize"],null,i,o,a,s,d,null,p)||this;return y.kernel=n,y.onApply=function(P){P.setFloat2("screenSize",y.width,y.height),P.setArray("kernel",y.kernel)},y}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"ConvolutionPostProcess"},t._Parse=function(e,n,i,o){return L.a.Parse(function(){return new t(e.name,e.kernel,e.options,n,e.renderTargetSamplingMode,i.getEngine(),e.reusable,e.textureType)},e,i,o)},t.EdgeDetect0Kernel=[1,0,-1,0,0,0,-1,0,1],t.EdgeDetect1Kernel=[0,1,0,1,-4,1,0,1,0],t.EdgeDetect2Kernel=[-1,-1,-1,-1,8,-1,-1,-1,-1],t.SharpenKernel=[0,-1,0,-1,5,-1,0,-1,0],t.EmbossKernel=[-2,-1,0,-1,1,1,0,1,2],t.GaussianKernel=[0,1,0,1,1,1,0,1,0],Object(c.c)([Object(L.c)()],t.prototype,"kernel",void 0),t}(_t);R.a.RegisteredTypes["BABYLON.ConvolutionPostProcess"]=zd;var xa=function(r){function t(e,n,i,o,a,s,d,p,y,P,O,U,F){p===void 0&&(p=null),y===void 0&&(y=we.a.BILINEAR_SAMPLINGMODE),U===void 0&&(U=h.a.TEXTURETYPE_UNSIGNED_INT),F===void 0&&(F=!1);var z=r.call(this,e,i,o,a,s,y=h.a.TEXTURE_BILINEAR_SAMPLINGMODE,P,O,U=h.a.TEXTURETYPE_UNSIGNED_INT,`#define DOF 1\r
9398`,F)||this;return z.direction=i,z.onApplyObservable.add(function(J){p!=null&&J.setTextureFromPostProcess("textureSampler",p),J.setTextureFromPostProcessOutput("circleOfConfusionSampler",d),n.activeCamera&&J.setFloat2("cameraMinMaxZ",n.activeCamera.minZ,n.activeCamera.maxZ)}),z}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"DepthOfFieldBlurPostProcess"},Object(c.c)([Object(L.c)()],t.prototype,"direction",void 0),t}(_n);R.a.RegisteredTypes["BABYLON.DepthOfFieldBlurPostProcess"]=xa;var Eg=`uniform sampler2D textureSampler;
9399varying vec2 vUV;
9400uniform sampler2D circleOfConfusionSampler;
9401uniform sampler2D blurStep0;
9402#if BLUR_LEVEL>0
9403uniform sampler2D blurStep1;
9404#endif
9405#if BLUR_LEVEL>1
9406uniform sampler2D blurStep2;
9407#endif
9408void main(void)
9409{
9410float coc=texture2D(circleOfConfusionSampler,vUV).r;
9411#if BLUR_LEVEL == 0
9412vec4 original=texture2D(textureSampler,vUV);
9413vec4 blurred0=texture2D(blurStep0,vUV);
9414gl_FragColor=mix(original,blurred0,coc);
9415#endif
9416#if BLUR_LEVEL == 1
9417if(coc<0.5){
9418vec4 original=texture2D(textureSampler,vUV);
9419vec4 blurred1=texture2D(blurStep1,vUV);
9420gl_FragColor=mix(original,blurred1,coc/0.5);
9421}else{
9422vec4 blurred0=texture2D(blurStep0,vUV);
9423vec4 blurred1=texture2D(blurStep1,vUV);
9424gl_FragColor=mix(blurred1,blurred0,(coc-0.5)/0.5);
9425}
9426#endif
9427#if BLUR_LEVEL == 2
9428if(coc<0.33){
9429vec4 original=texture2D(textureSampler,vUV);
9430vec4 blurred2=texture2D(blurStep2,vUV);
9431gl_FragColor=mix(original,blurred2,coc/0.33);
9432}else if(coc<0.66){
9433vec4 blurred1=texture2D(blurStep1,vUV);
9434vec4 blurred2=texture2D(blurStep2,vUV);
9435gl_FragColor=mix(blurred2,blurred1,(coc-0.33)/0.33);
9436}else{
9437vec4 blurred0=texture2D(blurStep0,vUV);
9438vec4 blurred1=texture2D(blurStep1,vUV);
9439gl_FragColor=mix(blurred1,blurred0,(coc-0.66)/0.34);
9440}
9441#endif
9442}
9443`;je.a.ShadersStore.depthOfFieldMergePixelShader=Eg;var ar,Sg=function(){},jd=function(r){function t(e,n,i,o,a,s,d,p,y,P,O){P===void 0&&(P=h.a.TEXTURETYPE_UNSIGNED_INT),O===void 0&&(O=!1);var U=r.call(this,e,"depthOfFieldMerge",[],["circleOfConfusionSampler","blurStep0","blurStep1","blurStep2"],a,s,d,p,y,null,P,void 0,null,!0)||this;return U.blurSteps=o,U.onApplyObservable.add(function(F){F.setTextureFromPostProcess("textureSampler",n),F.setTextureFromPostProcessOutput("circleOfConfusionSampler",i),o.forEach(function(z,J){F.setTextureFromPostProcessOutput("blurStep"
9443+(o.length-J-1),z)})}),O||U.updateEffect(),U}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"DepthOfFieldMergePostProcess"},t.prototype.updateEffect=function(e,n,i,o,a,s){e===void 0&&(e=null),n===void 0&&(n=null),i===void 0&&(i=null),e||(e="",e+="#define BLUR_LEVEL "+(this.blurSteps.length-1)+`
9444`),r.prototype.updateEffect.call(this,e,n,i,o,a,s)},t}(_t);(function(r){r[r.Low=0]="Low",r[r.Medium=1]="Medium",r[r.High=2]="High"})(ar||(ar={}));var Hc=function(r){function t(e,n,i,o,a){i===void 0&&(i=ar.Low),o===void 0&&(o=0),a===void 0&&(a=!1);var s=r.call(this,e.getEngine(),"depth of field",function(){return s._effects},!0)||this;s._effects=[],s._circleOfConfusion=new jc("circleOfConfusion",n,1,null,we.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,o,a),s._depthOfFieldBlurY=[],s._depthOfFieldBlurX=[];var d=1,p=15;switch(i){case ar.High:d=3,p=51;break;case ar.Medium:d=2,p=31;break;default:p=15,d=1}for(var y=p/Math.pow(2,d-1),P=1,O=0;O<d;O++){var U=new xa("verticle blur",e,new u.d(0,1),y,P,null,s._circleOfConfusion,O==0?s._circleOfConfusion:null,we.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,o,a);U.autoClear=!1,P=.75/Math.pow(2,O);var F=new xa("horizontal blur",e,new u.d(1,0),y,P,null,s._circleOfConfusion,null,we.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,o,a);F.autoClear=!1,s._depthOfFieldBlurY.push(U),s._depthOfFieldBlurX.push(F)}for(s._effects=[s._circleOfConfusion],O=0;O<s._depthOfFieldBlurX.length;O++)s._effects.push(s._depthOfFieldBlurY[O]),s._effects.push(s._depthOfFieldBlurX[O]);return s._dofMerge=new jd("dofMerge",s._circleOfConfusion,s._circleOfConfusion,s._depthOfFieldBlurX,P,null,we.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,o,a),s._dofMerge.autoClear=!1,s._effects.push(s._dofMerge),s}return Object(c.d)(t,r),Object.defineProperty(t.prototype,"focalLength",{get:function(){return this._circleOfConfusion.focalLength},set:function(e){this._circleOfConfusion.focalLength=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fStop",{get:function(){return this._circleOfConfusion.fStop},set:function(e){this._circleOfConfusion.fStop=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"focusDistance",{get:function(){return this._circleOfConfusion.focusDistance},set:function(e){this._circleOfConfusion.focusDistance=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lensSize",{get:function(){return this._circleOfConfusion.lensSize},set:function(e){this._circleOfConfusion.lensSize=e},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"DepthOfFieldEffect"},Object.defineProperty(t.prototype,"depthTexture",{set:function(e){this._circleOfConfusion.depthTexture=e},enumerable:!1,configurable:!0}),t.prototype.disposeEffects=function(e){for(var n=0;n<this._effects.length;n++)this._effects[n].dispose(e)},t.prototype._updateEffects=function(){for(var e=0;e<this._effects.length;e++)this._effects[e].updateEffect()},t.prototype._isReady=function(){for(var e=0;e<this._effects.length;e++)if(!this._effects[e].isReady())return!1;return!0},t}(Rt),Ag=`
9445varying vec2 vUV;
9446uniform sampler2D textureSampler;
9447uniform sampler2D passSampler;
9448void main(void)
9449{
9450gl_FragColor=texture2D(passSampler,vUV);
9451}`;je.a.ShadersStore.displayPassPixelShader=Ag;var Hd=function(r){function t(e,n,i,o,a,s){return r.call(this,e,"displayPass",["passSampler"],["passSampler"],n,i,o,a,s)||this}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"DisplayPassPostProcess"},t._Parse=function(e,n,i,o){return L.a.Parse(function(){return new t(e.name,e.options,n,e.renderTargetSamplingMode,i.getEngine(),e.reusable)},e,i,o)},t}(_t);R.a.RegisteredTypes["BABYLON.DisplayPassPostProcess"]=Hd;var Pg=`
9452varying vec2 vUV;
9453uniform sampler2D textureSampler;
9454uniform mat4 kernelMatrix;
9455void main(void)
9456{
9457vec3 baseColor=texture2D(textureSampler,vUV).rgb;
9458vec3 updatedColor=(kernelMatrix*vec4(baseColor,1.0)).rgb;
9459gl_FragColor=vec4(updatedColor,1.0);
9460}`;je.a.ShadersStore.filterPixelShader=Pg;var Wd=function(r){function t(e,n,i,o,a,s,d){var p=r.call(this,e,"filter",["kernelMatrix"],null,i,o,a,s,d)||this;return p.kernelMatrix=n,p.onApply=function(y){y.setMatrix("kernelMatrix",p.kernelMatrix)},p}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"FilterPostProcess"},t._Parse=function(e,n,i,o){return L.a.Parse(function(){return new t(e.name,e.kernelMatrix,e.options,n,e.renderTargetSamplingMode,i.getEngine(),e.reusable)},e,i,o)},Object(c.c)([Object(L.j)()],t.prototype,"kernelMatrix",void 0),t}(_t);R.a.RegisteredTypes["BABYLON.FilterPostProcess"]=Wd;var Cg=`uniform sampler2D textureSampler;
9461uniform vec2 texelSize;
9462varying vec2 vUV;
9463varying vec2 sampleCoordS;
9464varying vec2 sampleCoordE;
9465varying vec2 sampleCoordN;
9466varying vec2 sampleCoordW;
9467varying vec2 sampleCoordNW;
9468varying vec2 sampleCoordSE;
9469varying vec2 sampleCoordNE;
9470varying vec2 sampleCoordSW;
9471const float fxaaQualitySubpix=1.0;
9472const float fxaaQualityEdgeThreshold=0.166;
9473const float fxaaQualityEdgeThresholdMin=0.0833;
9474const vec3 kLumaCoefficients=vec3(0.2126,0.7152,0.0722);
9475#define FxaaLuma(rgba) dot(rgba.rgb,kLumaCoefficients)
9476void main(){
9477vec2 posM;
9478posM.x=vUV.x;
9479posM.y=vUV.y;
9480vec4 rgbyM=texture2D(textureSampler,vUV,0.0);
9481float lumaM=FxaaLuma(rgbyM);
9482float lumaS=FxaaLuma(texture2D(textureSampler,sampleCoordS,0.0));
9483float lumaE=FxaaLuma(texture2D(textureSampler,sampleCoordE,0.0));
9484float lumaN=FxaaLuma(texture2D(textureSampler,sampleCoordN,0.0));
9485float lumaW=FxaaLuma(texture2D(textureSampler,sampleCoordW,0.0));
9486float maxSM=max(lumaS,lumaM);
9487float minSM=min(lumaS,lumaM);
9488float maxESM=max(lumaE,maxSM);
9489float minESM=min(lumaE,minSM);
9490float maxWN=max(lumaN,lumaW);
9491float minWN=min(lumaN,lumaW);
9492float rangeMax=max(maxWN,maxESM);
9493float rangeMin=min(minWN,minESM);
9494float rangeMaxScaled=rangeMax*fxaaQualityEdgeThreshold;
9495float range=rangeMax-rangeMin;
9496float rangeMaxClamped=max(fxaaQualityEdgeThresholdMin,rangeMaxScaled);
9497#ifndef MALI
9498if(range<rangeMaxClamped)
9499{
9500gl_FragColor=rgbyM;
9501return;
9502}
9503#endif
9504float lumaNW=FxaaLuma(texture2D(textureSampler,sampleCoordNW,0.0));
9505float lumaSE=FxaaLuma(texture2D(textureSampler,sampleCoordSE,0.0));
9506float lumaNE=FxaaLuma(texture2D(textureSampler,sampleCoordNE,0.0));
9507float lumaSW=FxaaLuma(texture2D(textureSampler,sampleCoordSW,0.0));
9508float lumaNS=lumaN+lumaS;
9509float lumaWE=lumaW+lumaE;
9510float subpixRcpRange=1.0/range;
9511float subpixNSWE=lumaNS+lumaWE;
9512float edgeHorz1=(-2.0*lumaM)+lumaNS;
9513float edgeVert1=(-2.0*lumaM)+lumaWE;
9514float lumaNESE=lumaNE+lumaSE;
9515float lumaNWNE=lumaNW+lumaNE;
9516float edgeHorz2=(-2.0*lumaE)+lumaNESE;
9517float edgeVert2=(-2.0*lumaN)+lumaNWNE;
9518float lumaNWSW=lumaNW+lumaSW;
9519float lumaSWSE=lumaSW+lumaSE;
9520float edgeHorz4=(abs(edgeHorz1)*2.0)+abs(edgeHorz2);
9521float edgeVert4=(abs(edgeVert1)*2.0)+abs(edgeVert2);
9522float edgeHorz3=(-2.0*lumaW)+lumaNWSW;
9523float edgeVert3=(-2.0*lumaS)+lumaSWSE;
9524float edgeHorz=abs(edgeHorz3)+edgeHorz4;
9525float edgeVert=abs(edgeVert3)+edgeVert4;
9526float subpixNWSWNESE=lumaNWSW+lumaNESE;
9527float lengthSign=texelSize.x;
9528bool horzSpan=edgeHorz>=edgeVert;
9529float subpixA=subpixNSWE*2.0+subpixNWSWNESE;
9530if (!horzSpan)
9531{
9532lumaN=lumaW;
9533}
9534if (!horzSpan)
9535{
9536lumaS=lumaE;
9537}
9538if (horzSpan)
9539{
9540lengthSign=texelSize.y;
9541}
9542float subpixB=(subpixA*(1.0/12.0))-lumaM;
9543float gradientN=lumaN-lumaM;
9544float gradientS=lumaS-lumaM;
9545float lumaNN=lumaN+lumaM;
9546float lumaSS=lumaS+lumaM;
9547bool pairN=abs(gradientN)>=abs(gradientS);
9548float gradient=max(abs(gradientN),abs(gradientS));
9549if (pairN)
9550{
9551lengthSign=-lengthSign;
9552}
9553float subpixC=clamp(abs(subpixB)*subpixRcpRange,0.0,1.0);
9554vec2 posB;
9555posB.x=posM.x;
9556posB.y=posM.y;
9557vec2 offNP;
9558offNP.x=(!horzSpan) ? 0.0 : texelSize.x;
9559offNP.y=(horzSpan) ? 0.0 : texelSize.y;
9560if (!horzSpan)
9561{
9562posB.x+=lengthSign*0.5;
9563}
9564if (horzSpan)
9565{
9566posB.y+=lengthSign*0.5;
9567}
9568vec2 posN;
9569posN.x=posB.x-offNP.x*1.5;
9570posN.y=posB.y-offNP.y*1.5;
9571vec2 posP;
9572posP.x=posB.x+offNP.x*1.5;
9573posP.y=posB.y+offNP.y*1.5;
9574float subpixD=((-2.0)*subpixC)+3.0;
9575float lumaEndN=FxaaLuma(texture2D(textureSampler,posN,0.0));
9576float subpixE=subpixC*subpixC;
9577float lumaEndP=FxaaLuma(texture2D(textureSampler,posP,0.0));
9578if (!pairN)
9579{
9580lumaNN=lumaSS;
9581}
9582float gradientScaled=gradient*1.0/4.0;
9583float lumaMM=lumaM-lumaNN*0.5;
9584float subpixF=subpixD*subpixE;
9585bool lumaMLTZero=lumaMM<0.0;
9586lumaEndN-=lumaNN*0.5;
9587lumaEndP-=lumaNN*0.5;
9588bool doneN=abs(lumaEndN)>=gradientScaled;
9589bool doneP=abs(lumaEndP)>=gradientScaled;
9590if (!doneN)
9591{
9592posN.x-=offNP.x*3.0;
9593}
9594if (!doneN)
9595{
9596posN.y-=offNP.y*3.0;
9597}
9598bool doneNP=(!doneN) || (!doneP);
9599if (!doneP)
9600{
9601posP.x+=offNP.x*3.0;
9602}
9603if (!doneP)
9604{
9605posP.y+=offNP.y*3.0;
9606}
9607if (doneNP)
9608{
9609if (!doneN) lumaEndN=FxaaLuma(texture2D(textureSampler,posN.xy,0.0));
9610if (!doneP) lumaEndP=FxaaLuma(texture2D(textureSampler,posP.xy,0.0));
9611if (!doneN) lumaEndN=lumaEndN-lumaNN*0.5;
9612if (!doneP) lumaEndP=lumaEndP-lumaNN*0.5;
9613doneN=abs(lumaEndN)>=gradientScaled;
9614doneP=abs(lumaEndP)>=gradientScaled;
9615if (!doneN) posN.x-=offNP.x*12.0;
9616if (!doneN) posN.y-=offNP.y*12.0;
9617doneNP=(!doneN) || (!doneP);
9618if (!doneP) posP.x+=offNP.x*12.0;
9619if (!doneP) posP.y+=offNP.y*12.0;
9620}
9621float dstN=posM.x-posN.x;
9622float dstP=posP.x-posM.x;
9623if (!horzSpan)
9624{
9625dstN=posM.y-posN.y;
9626}
9627if (!horzSpan)
9628{
9629dstP=posP.y-posM.y;
9630}
9631bool goodSpanN=(lumaEndN<0.0) != lumaMLTZero;
9632float spanLength=(dstP+dstN);
9633bool goodSpanP=(lumaEndP<0.0) != lumaMLTZero;
9634float spanLengthRcp=1.0/spanLength;
9635bool directionN=dstN<dstP;
9636float dst=min(dstN,dstP);
9637bool goodSpan=directionN ? goodSpanN : goodSpanP;
9638float subpixG=subpixF*subpixF;
9639float pixelOffset=(dst*(-spanLengthRcp))+0.5;
9640float subpixH=subpixG*fxaaQualitySubpix;
9641float pixelOffsetGood=goodSpan ? pixelOffset : 0.0;
9642float pixelOffsetSubpix=max(pixelOffsetGood,subpixH);
9643if (!horzSpan)
9644{
9645posM.x+=pixelOffsetSubpix*lengthSign;
9646}
9647if (horzSpan)
9648{
9649posM.y+=pixelOffsetSubpix*lengthSign;
9650}
9651#ifdef MALI
9652if(range<rangeMaxClamped)
9653{
9654gl_FragColor=rgbyM;
9655}
9656else
9657{
9658gl_FragColor=texture2D(textureSampler,posM,0.0);
9659}
9660#else
9661gl_FragColor=texture2D(textureSampler,posM,0.0);
9662#endif
9663}`;je.a.ShadersStore.fxaaPixelShader=Cg;var xg=`
9664attribute vec2 position;
9665uniform vec2 texelSize;
9666
9667varying vec2 vUV;
9668varying vec2 sampleCoordS;
9669varying vec2 sampleCoordE;
9670varying vec2 sampleCoordN;
9671varying vec2 sampleCoordW;
9672varying vec2 sampleCoordNW;
9673varying vec2 sampleCoordSE;
9674varying vec2 sampleCoordNE;
9675varying vec2 sampleCoordSW;
9676const vec2 madd=vec2(0.5,0.5);
9677void main(void) {
9678vUV=(position*madd+madd);
9679sampleCoordS=vUV+vec2( 0.0,1.0)*texelSize;
9680sampleCoordE=vUV+vec2( 1.0,0.0)*texelSize;
9681sampleCoordN=vUV+vec2( 0.0,-1.0)*texelSize;
9682sampleCoordW=vUV+vec2(-1.0,0.0)*texelSize;
9683sampleCoordNW=vUV+vec2(-1.0,-1.0)*texelSize;
9684sampleCoordSE=vUV+vec2( 1.0,1.0)*texelSize;
9685sampleCoordNE=vUV+vec2( 1.0,-1.0)*texelSize;
9686sampleCoordSW=vUV+vec2(-1.0,1.0)*texelSize;
9687gl_Position=vec4(position,0.0,1.0);
9688}`;je.a.ShadersStore.fxaaVertexShader=xg;var Ro=function(r){function t(e,n,i,o,a,s,d){i===void 0&&(i=null),d===void 0&&(d=h.a.TEXTURETYPE_UNSIGNED_INT);var p=r.call(this,e,"fxaa",["texelSize"],null,n,i,o||we.a.BILINEAR_SAMPLINGMODE,a,s,null,d,"fxaa",void 0,!0)||this,y=p._getDefines();return p.updateEffect(y),p.onApplyObservable.add(function(P){var O=p.texelSize;P.setFloat2("texelSize",O.x,O.y)}),p}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"FxaaPostProcess"},t.prototype._getDefines=function(){var e=this.getEngine();if(!e)return null;var n=e.getGlInfo();return n&&n.renderer&&n.renderer.toLowerCase().indexOf("mali")>-1?`#define MALI 1
9689`:null},t._Parse=function(e,n,i,o){return L.a.Parse(function(){return new t(e.name,e.options,n,e.renderTargetSamplingMode,i.getEngine(),e.reusable)},e,i,o)},t}(_t);R.a.RegisteredTypes["BABYLON.FxaaPostProcess"]=Ro;var Rg=`#include<helperFunctions>
9690
9691uniform sampler2D textureSampler;
9692
9693uniform float intensity;
9694uniform float animatedSeed;
9695
9696varying vec2 vUV;
9697void main(void)
9698{
9699gl_FragColor=texture2D(textureSampler,vUV);
9700vec2 seed=vUV*(animatedSeed);
9701float grain=dither(seed,intensity);
9702
9703float lum=getLuminance(gl_FragColor.rgb);
9704float grainAmount=(cos(-PI+(lum*PI*2.))+1.)/2.;
9705gl_FragColor.rgb+=grain*grainAmount;
9706gl_FragColor.rgb=max(gl_FragColor.rgb,0.0);
9707}`;je.a.ShadersStore.grainPixelShader=Rg;var Wc=function(r){function t(e,n,i,o,a,s,d,p){d===void 0&&(d=h.a.TEXTURETYPE_UNSIGNED_INT),p===void 0&&(p=!1);var y=r.call(this,e,"grain",["intensity","animatedSeed"],[],n,i,o,a,s,null,d,void 0,null,p)||this;return y.intensity=30,y.animated=!1,y.onApplyObservable.add(function(P){P.setFloat("intensity",y.intensity),P.setFloat("animatedSeed",y.animated?Math.random()+1:1)}),y}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"GrainPostProcess"},t._Parse=function(e,n,i,o){return L.a.Parse(function(){return new t(e.name,e.options,n,e.renderTargetSamplingMode,i.getEngine(),e.reusable)},e,i,o)},Object(c.c)([Object(L.c)()],t.prototype,"intensity",void 0),Object(c.c)([Object(L.c)()],t.prototype,"animated",void 0),t}(_t);R.a.RegisteredTypes["BABYLON.GrainPostProcess"]=Wc;var Og=`
9708varying vec2 vUV;
9709uniform sampler2D textureSampler;
9710const vec3 RGBLuminanceCoefficients=vec3(0.2126,0.7152,0.0722);
9711void main(void)
9712{
9713vec4 tex=texture2D(textureSampler,vUV);
9714vec3 c=tex.rgb;
9715float luma=dot(c.rgb,RGBLuminanceCoefficients);
9716
9717
9718gl_FragColor=vec4(pow(c,vec3(25.0-luma*15.0)),tex.a);
9719}`;je.a.ShadersStore.highlightsPixelShader=Og;var Mg=function(r){function t(e,n,i,o,a,s,d){return d===void 0&&(d=h.a.TEXTURETYPE_UNSIGNED_INT),r.call(this,e,"highlights",null,null,n,i,o,a,s,null,d)||this}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"HighlightsPostProcess"},t}(_t);je.a.IncludesShadersStore.mrtFragmentDeclaration=`#if __VERSION__>=200
9720layout(location=0) out vec4 glFragData[{X}];
9721#endif
9722`;var Ig=`#extension GL_EXT_draw_buffers : require
9723#if defined(BUMP) || !defined(NORMAL)
9724#extension GL_OES_standard_derivatives : enable
9725#endif
9726precision highp float;
9727precision highp int;
9728#ifdef BUMP
9729varying mat4 vWorldView;
9730varying vec3 vNormalW;
9731#else
9732varying vec3 vNormalV;
9733#endif
9734varying vec4 vViewPos;
9735#if defined(POSITION) || defined(BUMP)
9736varying vec3 vPositionW;
9737#endif
9738#ifdef VELOCITY
9739varying vec4 vCurrentPosition;
9740varying vec4 vPreviousPosition;
9741#endif
9742#ifdef NEED_UV
9743varying vec2 vUV;
9744#endif
9745#ifdef BUMP
9746uniform vec3 vBumpInfos;
9747uniform vec2 vTangentSpaceParams;
9748#endif
9749#ifdef REFLECTIVITY
9750varying vec2 vReflectivityUV;
9751uniform sampler2D reflectivitySampler;
9752#endif
9753#ifdef ALPHATEST
9754uniform sampler2D diffuseSampler;
9755#endif
9756#include<mrtFragmentDeclaration>[RENDER_TARGET_COUNT]
9757#include<bumpFragmentMainFunctions>
9758#include<bumpFragmentFunctions>
9759void main() {
9760#ifdef ALPHATEST
9761if (texture2D(diffuseSampler,vUV).a<0.4)
9762discard;
9763#endif
9764vec3 normalOutput;
9765#ifdef BUMP
9766vec3 normalW=normalize(vNormalW);
9767#include<bumpFragment>
9768normalOutput=normalize(vec3(vWorldView*vec4(normalW,0.0)));
9769#else
9770normalOutput=normalize(vNormalV);
9771#endif
9772#ifdef PREPASS
9773#ifdef PREPASS_DEPTHNORMAL
9774gl_FragData[DEPTHNORMAL_INDEX]=vec4(vViewPos.z/vViewPos.w,normalOutput);
9775#endif
9776#else
9777gl_FragData[0]=vec4(vViewPos.z/vViewPos.w,0.0,0.0,1.0);
9778gl_FragData[1]=vec4(normalOutput,1.0);
9779#endif
9780#ifdef POSITION
9781gl_FragData[POSITION_INDEX]=vec4(vPositionW,1.0);
9782#endif
9783#ifdef VELOCITY
9784vec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;
9785vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;
9786vec2 velocity=abs(a-b);
9787velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;
9788gl_FragData[VELOCITY_INDEX]=vec4(velocity,0.0,1.0);
9789#endif
9790#ifdef REFLECTIVITY
9791#ifdef HAS_SPECULAR
9792
9793vec4 reflectivity=texture2D(reflectivitySampler,vReflectivityUV);
9794#elif HAS_REFLECTIVITY
9795
9796vec4 reflectivity=vec4(texture2D(reflectivitySampler,vReflectivityUV).rgb,1.0);
9797#else
9798vec4 reflectivity=vec4(0.0,0.0,0.0,1.0);
9799#endif
9800gl_FragData[REFLECTIVITY_INDEX]=reflectivity;
9801#endif
9802}`;je.a.ShadersStore.geometryPixelShader=Ig;var Dg=`precision highp float;
9803precision highp int;
9804#include<bonesDeclaration>
9805#include<morphTargetsVertexGlobalDeclaration>
9806#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
9807#include<instancesDeclaration>
9808attribute vec3 position;
9809attribute vec3 normal;
9810#ifdef NEED_UV
9811varying vec2 vUV;
9812#ifdef ALPHATEST
9813uniform mat4 diffuseMatrix;
9814#endif
9815#ifdef BUMP
9816uniform mat4 bumpMatrix;
9817varying vec2 vBumpUV;
9818#endif
9819#ifdef REFLECTIVITY
9820uniform mat4 reflectivityMatrix;
9821varying vec2 vReflectivityUV;
9822#endif
9823#ifdef UV1
9824attribute vec2 uv;
9825#endif
9826#ifdef UV2
9827attribute vec2 uv2;
9828#endif
9829#endif
9830
9831uniform mat4 viewProjection;
9832uniform mat4 view;
9833#ifdef BUMP
9834varying mat4 vWorldView;
9835#endif
9836#ifdef BUMP
9837varying vec3 vNormalW;
9838#else
9839varying vec3 vNormalV;
9840#endif
9841varying vec4 vViewPos;
9842#if defined(POSITION) || defined(BUMP)
9843varying vec3 vPositionW;
9844#endif
9845#ifdef VELOCITY
9846uniform mat4 previousWorld;
9847uniform mat4 previousViewProjection;
9848#ifdef BONES_VELOCITY_ENABLED
9849#if NUM_BONE_INFLUENCERS>0
9850uniform mat4 mPreviousBones[BonesPerMesh];
9851#endif
9852#endif
9853varying vec4 vCurrentPosition;
9854varying vec4 vPreviousPosition;
9855#endif
9856void main(void)
9857{
9858vec3 positionUpdated=position;
9859vec3 normalUpdated=normal;
9860#ifdef UV1
9861vec2 uvUpdated=uv;
9862#endif
9863#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
9864#include<instancesVertex>
9865#if defined(VELOCITY) && !defined(BONES_VELOCITY_ENABLED)
9866
9867vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,
98671.0);
9868vPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0);
9869#endif
9870#include<bonesVertex>
9871vec4 pos=vec4(finalWorld*vec4(positionUpdated,1.0));
9872#ifdef BUMP
9873vWorldView=view*finalWorld;
9874vNormalW=normalUpdated;
9875#else
9876vNormalV=normalize(vec3((view*finalWorld)*vec4(normalUpdated,0.0)));
9877#endif
9878vViewPos=view*pos;
9879#if defined(VELOCITY) && defined(BONES_VELOCITY_ENABLED)
9880vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);
9881#if NUM_BONE_INFLUENCERS>0
9882mat4 previousInfluence;
9883previousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0];
9884#if NUM_BONE_INFLUENCERS>1
9885previousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1];
9886#endif
9887#if NUM_BONE_INFLUENCERS>2
9888previousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2];
9889#endif
9890#if NUM_BONE_INFLUENCERS>3
9891previousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3];
9892#endif
9893#if NUM_BONE_INFLUENCERS>4
9894previousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];
9895#endif
9896#if NUM_BONE_INFLUENCERS>5
9897previousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];
9898#endif
9899#if NUM_BONE_INFLUENCERS>6
9900previousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];
9901#endif
9902#if NUM_BONE_INFLUENCERS>7
9903previousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];
9904#endif
9905vPreviousPosition=previousViewProjection*previousWorld*previousInfluence*vec4(positionUpdated,1.0);
9906#else
9907vPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0);
9908#endif
9909#endif
9910#if defined(POSITION) || defined(BUMP)
9911vPositionW=pos.xyz/pos.w;
9912#endif
9913gl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);
9914#ifdef NEED_UV
9915#ifdef UV1
9916#ifdef ALPHATEST
9917vUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));
9918#else
9919vUV=uv;
9920#endif
9921#ifdef BUMP
9922vBumpUV=vec2(bumpMatrix*vec4(uvUpdated,1.0,0.0));
9923#endif
9924#ifdef REFLECTIVITY
9925vReflectivityUV=vec2(reflectivityMatrix*vec4(uvUpdated,1.0,0.0));
9926#endif
9927#endif
9928#ifdef UV2
9929#ifdef ALPHATEST
9930vUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
9931#else
9932vUV=uv2;
9933#endif
9934#ifdef BUMP
9935vBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));
9936#endif
9937#ifdef REFLECTIVITY
9938vReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));
9939#endif
9940#endif
9941#endif
9942#include<bumpVertex>
9943}
9944`;je.a.ShadersStore.geometryVertexShader=Dg;var ai=function(){function r(t,e){e===void 0&&(e=1),this._previousTransformationMatrices={},this._previousBonesTransformationMatrices={},this.excludedSkinnedMeshesFromVelocity=[],this.renderTransparentMeshes=!0,this._resizeObserver=null,this._enablePosition=!1,this._enableVelocity=!1,this._enableReflectivity=!1,this._positionIndex=-1,this._velocityIndex=-1,this._reflectivityIndex=-1,this._depthNormalIndex=-1,this._linkedWithPrePass=!1,this._scene=t,this._ratio=e,r._SceneComponentInitialization(this._scene),this._createRenderTargets()}return r.prototype._linkPrePassRenderer=function(t){this._linkedWithPrePass=!0,this._prePassRenderer=t,this._multiRenderTarget&&(this._multiRenderTarget.onClearObservable.clear(),this._multiRenderTarget.onClearObservable.add(function(e){}))},r.prototype._unlinkPrePassRenderer=function(){this._linkedWithPrePass=!1,this._createRenderTargets()},r.prototype._resetLayout=function(){this._enablePosition=!1,this._enableReflectivity=!1,this._enableVelocity=!1,this._attachments=[]},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.DEPTHNORMAL_TEXTURE_TYPE&&(this._depthNormalIndex=e)},r.prototype._setAttachments=function(t){this._attachments=t},r.prototype._linkInternalTexture=function(t){this._multiRenderTarget._texture=t},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}
9944,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;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())},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 this._ratio},enumerable:!1,configurable:!0}),r.prototype.isReady=function(t,e){var n=t.getMaterial();if(n&&n.disableDepthWrite)return!1;var i=[],o=[Me.b.PositionKind,Me.b.NormalKind],a=t.getMesh();if(n){var s=!1;n.needAlphaTesting()&&(i.push("#define ALPHATEST"),s=!0),n.bumpTexture&&Ft.a.BumpTextureEnabled&&(i.push("#define BUMP"),i.push("#define BUMPDIRECTUV 0"),s=!0),this._enableReflectivity&&(n instanceof Ft.a&&n.specularTexture?(i.push("#define HAS_SPECULAR"),s=!0):n instanceof lo&&n.reflectivityTexture&&(i.push("#define HAS_REFLECTIVITY"),s=!0)),s&&(i.push("#define NEED_UV"),a.isVerticesDataPresent(Me.b.UVKind)&&(o.push(Me.b.UVKind),i.push("#define UV1")),a.isVerticesDataPresent(Me.b.UV2Kind)&&(o.push(Me.b.UV2Kind),i.push("#define UV2")))}this._linkedWithPrePass&&(i.push("#define PREPASS"),this._depthNormalIndex!==-1&&(i.push("#define DEPTHNORMAL_INDEX "+this._depthNormalIndex),i.push("#define PREPASS_DEPTHNORMAL"))),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)),a.useBones&&a.computeBonesUsingShaders?(o.push(Me.b.MatricesIndicesKind),o.push(Me.b.MatricesWeightsKind),a.numBoneInfluencers>4&&(o.push(Me.b.MatricesIndicesExtraKind),o.push(Me.b.MatricesWeightsExtraKind)),i.push("#define NUM_BONE_INFLUENCERS "+a.numBoneInfluencers),i.push("#define BonesPerMesh "+(a.skeleton?a.skeleton.bones.length+1:0))):i.push("#define NUM_BONE_INFLUENCERS 0");var d=a.morphTargetManager,p=0;d&&d.numInfluencers>0&&(p=d.numInfluencers,i.push("#define MORPHTARGETS"),i.push("#define NUM_MORPH_INFLUENCERS "+p),tt.a.PrepareAttributesForMorphTargetsInfluencers(o,a,p)),e&&(i.push("#define INSTANCES"),tt.a.PushAttributesForInstances(o),t.getRenderingMesh().hasThinInstances&&i.push("#define THIN_INSTANCES")),this._linkedWithPrePass?i.push("#define RENDER_TARGET_COUNT "+this._attachments.length):i.push("#define RENDER_TARGET_COUNT "+this._multiRenderTarget.textures.length);var y=i.join(`
9945`);return this._cachedDefines!==y&&(this._cachedDefines=y,this._effect=this._scene.getEngine().createEffect("geometry",o,["world","mBones","viewProjection","diffuseMatrix","view","previousWorld","previousViewProjection","mPreviousBones","morphTargetInfluences","bumpMatrix","reflectivityMatrix","vTangentSpaceParams","vBumpInfos"],["diffuseSampler","bumpSampler","reflectivitySampler"],y,void 0,void 0,void 0,{buffersCount:this._multiRenderTarget.textures.length-1,maxSimultaneousMorphTargets:p})),this._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}
9945,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=2;return this._enablePosition&&(this._positionIndex=t,t++),this._enableVelocity&&(this._velocityIndex=t,t++),this._enableReflectivity&&(this._reflectivityIndex=t,t++),t},r.prototype._createRenderTargets=function(){var t=this,e=this._scene.getEngine(),n=this._assignRenderTargetIndices();if(this._multiRenderTarget=new tc("gBuffer",{width:e.getRenderWidth()*this._ratio,height:e.getRenderHeight()*this._ratio},n,this._scene,{generateMipMaps:!1,generateDepthTexture:!0,defaultType:h.a.TEXTURETYPE_FLOAT}),this.isSupported){this._multiRenderTarget.wrapU=we.a.CLAMP_ADDRESSMODE,this._multiRenderTarget.wrapV=we.a.CLAMP_ADDRESSMODE,this._multiRenderTarget.refreshRate=1,this._multiRenderTarget.renderParticles=!1,this._multiRenderTarget.renderList=null,this._multiRenderTarget.onClearObservable.add(function(o){o.clear(new M.b(0,0,0,1),!0,!0,!0)}),this._resizeObserver=e.onResizeObservable.add(function(){t._multiRenderTarget&&t._multiRenderTarget.resize({width:e.getRenderWidth()*t._ratio,height:e.getRenderHeight()*t._ratio})});var i=function(o){var a=o.getRenderingMesh(),s=o.getEffectiveMesh(),d=t._scene,p=d.getEngine(),y=o.getMaterial();if(y){if(s._internalAbstractMeshDataInfo._isActiveIntermediate=!1,t._enableVelocity&&!t._previousTransformationMatrices[s.uniqueId]&&(t._previousTransformationMatrices[s.uniqueId]={world:u.a.Identity(),viewProjection:d.getTransformMatrix()},a.skeleton)){var P=a.skeleton.getTransformMatrices(a);t._previousBonesTransformationMatrices[a.uniqueId]=t._copyBonesTransformationMatrices(P,new Float32Array(P.length))}var O=a._getInstancesRenderList(o._id,!!o.getReplacementMesh());if(!O.mustReturn){var U=p.getCaps().instancedArrays&&(O.visibleInstances[o._id]!==null||a.hasThinInstances),F=s.getWorldMatrix();if(t.isReady(o,U)){if(p.enableEffect(t._effect),a._bind(o,t._effect,y.fillMode),t._effect.setMatrix("viewProjection",d.getTransformMatrix()),t._effect.setMatrix("view",d.getViewMatrix()),y){var z,J=s._instanceDataStorage;if(J.isFrozen||!y.backFaceCulling&&y.overrideMaterialSideOrientation===null)z=J.sideOrientation;else{var ie=s._getWorldMatrixDeterminant();(z=y.overrideMaterialSideOrientation)==null&&(z=y.sideOrientation),ie<0&&(z=z===Ht.a.ClockWiseSideOrientation?Ht.a.CounterClockWiseSideOrientation:Ht.a.ClockWiseSideOrientation)}if(y._preBind(t._effect,z),y.needAlphaTesting()){var se=y.getAlphaTestTexture();se&&(t._effect.setTexture("diffuseSampler",se),t._effect.setMatrix("diffuseMatrix",se.getTextureMatrix()))}y.bumpTexture&&d.getEngine().getCaps().standardDerivatives&&Ft.a.BumpTextureEnabled&&(t._effect.setFloat3("vBumpInfos",y.bumpTexture.coordinatesIndex,1/y.bumpTexture.level,y.parallaxScaleBias),t._effect.setMatrix("bumpMatrix",y.bumpTexture.getTextureMatrix()),t._effect.setTexture("bumpSampler",y.bumpTexture),t._effect.setFloat2("vTangentSpaceParams",y.invertNormalMapX?-1:1,y.invertNormalMapY?-1:1)),t._enableReflectivity&&(y instanceof Ft.a&&y.specularTexture?(t._effect.setMatrix("reflectivityMatrix",y.specularTexture.getTextureMatrix()),t._effect.setTexture("reflectivitySampler",y.specularTexture)):y instanceof lo&&y.reflectivityTexture&&(t._effect.setMatrix("reflectivityMatrix",y.reflectivityTexture.getTextureMatrix()),t._effect.setTexture("reflectivitySampler",y.reflectivityTexture)))}a.useBones&&a.computeBonesUsingShaders&&a.skeleton&&(t._effect.setMatrices("mBones",a.skeleton.getTransformMatrices(a)),t._enableVelocity&&t._effect.setMatrices("mPreviousBones",t._previousBonesTransformationMatrices[a.uniqueId])),tt.a.BindMorphTargetParameters(a,t._effect),t._enableVelocity&&(t._effect.setMatrix("previousWorld",t._previousTransformationMatrices[s.uniqueId].world),t._effect.setMatrix("previousViewProjection",t._previousTransformationMatrices[s.uniqueId].viewProjection)),a._processRendering(s,o,t._effect,y.fillMode,O,U,function(ce,ue){return t._effect.setMatr
9945ix("world",ue)})}t._enableVelocity&&(t._previousTransformationMatrices[s.uniqueId].world=F.clone(),t._previousTransformationMatrices[s.uniqueId].viewProjection=t._scene.getTransformMatrix().clone(),a.skeleton&&t._copyBonesTransformationMatrices(a.skeleton.getTransformMatrices(a),t._previousBonesTransformationMatrices[s.uniqueId]))}}};this._multiRenderTarget.customRenderFunction=function(o,a,s,d){var p;if(t._linkedWithPrePass){if(!t._prePassRenderer.enabled)return;t._scene.getEngine().bindAttachments(t._attachments)}if(d.length){for(e.setColorWrite(!1),p=0;p<d.length;p++)i(d.data[p]);e.setColorWrite(!0)}for(p=0;p<o.length;p++)i(o.data[p]);for(p=0;p<a.length;p++)i(a.data[p]);if(t.renderTransparentMeshes)for(p=0;p<s.length;p++)i(s.data[p])}}},r.prototype._copyBonesTransformationMatrices=function(t,e){for(var n=0;n<t.length;n++)e[n]=t[n];return e},r.DEPTHNORMAL_TEXTURE_TYPE=0,r.POSITION_TEXTURE_TYPE=1,r.VELOCITY_TEXTURE_TYPE=2,r.REFLECTIVITY_TEXTURE_TYPE=3,r._SceneComponentInitialization=function(t){throw En.a.WarnImport("GeometryBufferRendererSceneComponent")},r}(),Lg=function(){this.enabled=!1,this.name="motionBlur",this.texturesRequired=[h.a.PREPASS_VELOCITY_TEXTURE_TYPE]};Object.defineProperty(_e.a.prototype,"geometryBufferRenderer",{get:function(){this._geometryBufferRenderer},set:function(r){r&&r.isSupported&&(this._geometryBufferRenderer=r)},enumerable:!0,configurable:!0}),_e.a.prototype.enableGeometryBufferRenderer=function(r){return r===void 0&&(r=1),this._geometryBufferRenderer||(this._geometryBufferRenderer=new ai(this,r),this._geometryBufferRenderer.isSupported||(this._geometryBufferRenderer=null)),this._geometryBufferRenderer},_e.a.prototype.disableGeometryBufferRenderer=function(){this._geometryBufferRenderer&&(this._geometryBufferRenderer.dispose(),this._geometryBufferRenderer=null)};var Xd=function(){function r(t){this.name=st.a.NAME_GEOMETRYBUFFERRENDERER,this.scene=t}return r.prototype.register=function(){this.scene._gatherRenderTargetsStage.registerStep(st.a.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER,this,this._gatherRenderTargets)},r.prototype.rebuild=function(){},r.prototype.dispose=function(){},r.prototype._gatherRenderTargets=function(t){this.scene._geometryBufferRenderer&&t.push(this.scene._geometryBufferRenderer.getGBuffer())},r}();ai._SceneComponentInitialization=function(r){var t=r._getComponent(st.a.NAME_GEOMETRYBUFFERRENDERER);t||(t=new Xd(r),r._addComponent(t))};var Ng=`
9946varying vec2 vUV;
9947uniform sampler2D textureSampler;
9948uniform float motionStrength;
9949uniform float motionScale;
9950uniform vec2 screenSize;
9951#ifdef OBJECT_BASED
9952uniform sampler2D velocitySampler;
9953#else
9954uniform sampler2D depthSampler;
9955uniform mat4 inverseViewProjection;
9956uniform mat4 prevViewProjection;
9957#endif
9958void main(void)
9959{
9960#ifdef GEOMETRY_SUPPORTED
9961#ifdef OBJECT_BASED
9962vec2 texelSize=1.0/screenSize;
9963vec2 velocityColor=texture2D(velocitySampler,vUV).rg*2.0-1.0;
9964vec2 velocity=vec2(pow(velocityColor.r,3.0),pow(velocityColor.g,3.0));
9965velocity*=motionScale*motionStrength;
9966float speed=length(velocity/texelSize);
9967int samplesCount=int(clamp(speed,1.0,SAMPLES));
9968velocity=normalize(velocity)*texelSize;
9969float hlim=float(-samplesCount)*0.5+0.5;
9970vec4 result=texture2D(textureSampler,vUV);
9971for (int i=1; i<int(SAMPLES); ++i)
9972{
9973if (i>=samplesCount)
9974break;
9975vec2 offset=vUV+velocity*(hlim+float(i));
9976result+=texture2D(textureSampler,offset);
9977}
9978gl_FragColor=result/float(samplesCount);
9979gl_FragColor.a=1.0;
9980#else
9981vec2 texelSize=1.0/screenSize;
9982float depth=texture2D(depthSampler,vUV).r;
9983vec4 cpos=vec4(vUV*2.0-1.0,depth,1.0);
9984cpos=cpos*inverseViewProjection;
9985vec4 ppos=cpos*prevViewProjection;
9986ppos.xyz/=ppos.w;
9987ppos.xy=ppos.xy*0.5+0.5;
9988vec2 velocity=(ppos.xy-vUV)*motionScale*motionStrength;
9989float speed=length(velocity/texelSize);
9990int nSamples=int(clamp(speed,1.0,SAMPLES));
9991vec4 result=texture2D(textureSampler,vUV);
9992for (int i=1; i<int(SAMPLES); ++i) {
9993if (i>=nSamples)
9994break;
9995vec2 offset1=vUV+velocity*(float(i)/float(nSamples-1)-0.5);
9996result+=texture2D(textureSampler,offset1);
9997}
9998gl_FragColor=result/float(nSamples);
9999#endif
10000#else
10001gl_FragColor=texture2D(textureSampler,vUV);
10002#endif
10003}
10004`;je.a.ShadersStore.motionBlurPixelShader=Ng;var Xc=function(r){function t(e,n,i,o,a,s,d,p,y,P){p===void 0&&(p=h.a.TEXTURETYPE_UNSIGNED_INT),y===void 0&&(y=!1),P===void 0&&(P=!0);var O=r.call(this,e,"motionBlur",["motionStrength","motionScale","screenSize","inverseViewProjection","prevViewProjection"],["velocitySampler"],i,o,a,s,d,`#define GEOMETRY_SUPPORTED
10005#define SAMPLES 64.0
10006#define OBJECT_BASED`,p,void 0,null,y)||this;return O.motionStrength=1,O._motionBlurSamples=32,O._isObjectBased=!0,O._forceGeometryBuffer=!1,O._geometryBufferRenderer=null,O._prePassRenderer=null,O._invViewProjection=null,O._previousViewProjection=null,O._forceGeometryBuffer=P,O._forceGeometryBuffer?(O._geometryBufferRenderer=n.enableGeometryBufferRenderer(),O._geometryBufferRenderer&&(O._geometryBufferRenderer.enableVelocity=!0)):(O._prePassRenderer=n.enablePrePassRenderer(),O._prePassRenderer&&(O._prePassRenderer.markAsDirty(),O._prePassEffectConfiguration=new Lg)),O._applyMode(),O}return Object(c.d)(t,r),Object.defineProperty(t.prototype,"motionBlurSamples",{get:function(){return this._motionBlurSamples},set:function(e){this._motionBlurSamples=e,this._updateEffect()}
10006,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isObjectBased",{get:function(){return this._isObjectBased},set:function(e){this._isObjectBased!==e&&(this._isObjectBased=e,this._applyMode())},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"MotionBlurPostProcess"},t.prototype.excludeSkinnedMesh=function(e){if(e.skeleton){var n=void 0;if(this._geometryBufferRenderer)n=this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity;else{if(!this._prePassRenderer)return;n=this._prePassRenderer.excludedSkinnedMesh}n.push(e)}},t.prototype.removeExcludedSkinnedMesh=function(e){if(e.skeleton){var n=void 0;if(this._geometryBufferRenderer)n=this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity;else{if(!this._prePassRenderer)return;n=this._prePassRenderer.excludedSkinnedMesh}var i=n.indexOf(e);i!==-1&&n.splice(i,1)}},t.prototype.dispose=function(e){this._geometryBufferRenderer&&(this._geometryBufferRenderer._previousTransformationMatrices={},this._geometryBufferRenderer._previousBonesTransformationMatrices={},this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity=[]),r.prototype.dispose.call(this,e)},t.prototype._applyMode=function(){var e=this;if(!this._geometryBufferRenderer&&!this._prePassRenderer)return l.a.Warn("Multiple Render Target support needed to compute object based motion blur"),this.updateEffect();this._updateEffect(),this._invViewProjection=null,this._previousViewProjection=null,this.isObjectBased?(this._prePassRenderer&&this._prePassEffectConfiguration&&(this._prePassEffectConfiguration.texturesRequired[0]=h.a.PREPASS_VELOCITY_TEXTURE_TYPE),this.onApply=function(n){return e._onApplyObjectBased(n)}):(this._invViewProjection=u.a.Identity(),this._previousViewProjection=u.a.Identity(),this._prePassRenderer&&this._prePassEffectConfiguration&&(this._prePassEffectConfiguration.texturesRequired[0]=h.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE),this.onApply=function(n){return e._onApplyScreenBased(n)})},t.prototype._onApplyObjectBased=function(e){if(e.setVector2("screenSize",new u.d(this.width,this.height)),e.setFloat("motionScale",this._scene.getAnimationRatio()),e.setFloat("motionStrength",this.motionStrength),this._geometryBufferRenderer){var n=this._geometryBufferRenderer.getTextureIndex(ai.VELOCITY_TEXTURE_TYPE);e.setTexture("velocitySampler",this._geometryBufferRenderer.getGBuffer().textures[n])}else this._prePassRenderer&&(n=this._prePassRenderer.getIndex(h.a.PREPASS_VELOCITY_TEXTURE_TYPE),e.setTexture("velocitySampler",this._prePassRenderer.prePassRT.textures[n]))},t.prototype._onApplyScreenBased=function(e){var n=this._scene.getProjectionMatrix().multiply(this._scene.getViewMatrix());if(n.invertToRef(this._invViewProjection),e.setMatrix("inverseViewProjection",this._invViewProjection),e.setMatrix("prevViewProjection",this._previousViewProjection),this._previousViewProjection=n,e.setVector2("screenSize",new u.d(this.width,this.height)),e.setFloat("motionScale",this._scene.getAnimationRatio()),e.setFloat("motionStrength",this.motionStrength),this._geometryBufferRenderer){var i=this._geometryBufferRenderer.getTextureIndex(ai.DEPTHNORMAL_TEXTURE_TYPE);e.setTexture("depthSampler",this._geometryBufferRenderer.getGBuffer().textures[i])}else this._prePassRenderer&&(i=this._prePassRenderer.getIndex(h.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE),e.setTexture("depthSampler",this._prePassRenderer.prePassRT.textures[i]))},t.prototype._updateEffect=function(){if(this._geometryBufferRenderer||this._prePassRenderer){var e=["#define GEOMETRY_SUPPORTED","#define SAMPLES "+this._motionBlurSamples.toFixed(1),this._isObjectBased?"#define OBJECT_BASED":"#define SCREEN_BASED"];this.updateEffect(e.join(`
10007`))}},t._Parse=function(e,n,i,o){return L.a.Parse(function(){return new t(e.name,i,e.options,n,e.renderTargetSamplingMode,i.getEngine(),e.reusable,e.textureType,!1)},e,i,o)},Object(c.c)([Object(L.c)()],t.prototype,"motionStrength",void 0),Object(c.c)([Object(L.c)()],t.prototype,"motionBlurSamples",null),Object(c.c)([Object(L.c)()],t.prototype,"isObjectBased",null),t}(_t);R.a.RegisteredTypes["BABYLON.MotionBlurPostProcess"]=Xc;var wg=`
10008varying vec2 vUV;
10009uniform sampler2D textureSampler;
10010uniform sampler2D refractionSampler;
10011
10012uniform vec3 baseColor;
10013uniform float depth;
10014uniform float colorLevel;
10015void main() {
10016float ref=1.0-texture2D(refractionSampler,vUV).r;
10017vec2 uv=vUV-vec2(0.5);
10018vec2 offset=uv*depth*ref;
10019vec3 sourceColor=texture2D(textureSampler,vUV-offset).rgb;
10020gl_FragColor=vec4(sourceColor+sourceColor*ref*colorLevel,1.0);
10021}`;je.a.ShadersStore.refractionPixelShader=wg;var Yd=function(r){function t(e,n,i,o,a,s,d,p,y,P){var O=r.call(this,e,"refraction",["baseColor","depth","colorLevel"],["refractionSampler"],s,d,p,y,P)||this;return O._ownRefractionTexture=!0,O.color=i,O.depth=o,O.colorLevel=a,O.refractionTextureUrl=n,O.onActivateObservable.add(function(U){O._refTexture=O._refTexture||new we.a(n,U.getScene())}),O.onApplyObservable.add(function(U){U.setColor3("baseColor",O.color),U.setFloat("depth",O.depth),U.setFloat("colorLevel",O.colorLevel),U.setTexture("refractionSampler",O._refTexture)}),O}return Object(c.d)(t,r),Object.defineProperty(t.prototype,"refractionTexture",{get:function(){return this._refTexture},set:function(e){this._refTexture&&this._ownRefractionTexture&&this._refTexture.dispose(),this._refTexture=e,this._ownRefractionTexture=!1}
10021,enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"RefractionPostProcess"},t.prototype.dispose=function(e){this._refTexture&&this._ownRefractionTexture&&(this._refTexture.dispose(),this._refTexture=null),r.prototype.dispose.call(this,e)},t._Parse=function(e,n,i,o){return L.a.Parse(function(){return new t(e.name,e.refractionTextureUrl,e.color,e.depth,e.colorLevel,e.options,n,e.renderTargetSamplingMode,i.getEngine(),e.reusable)},e,i,o)},Object(c.c)([Object(L.c)()],t.prototype,"color",void 0),Object(c.c)([Object(L.c)()],t.prototype,"depth",void 0),Object(c.c)([Object(L.c)()],t.prototype,"colorLevel",void 0),Object(c.c)([Object(L.c)()],t.prototype,"refractionTextureUrl",void 0),t}(_t);R.a.RegisteredTypes["BABYLON.RefractionPostProcess"]=Yd;var Fg=`
10022varying vec2 vUV;
10023uniform sampler2D textureSampler;
10024uniform vec2 screenSize;
10025uniform vec2 sharpnessAmounts;
10026void main(void)
10027{
10028vec2 onePixel=vec2(1.0,1.0)/screenSize;
10029vec4 color=texture2D(textureSampler,vUV);
10030vec4 edgeDetection=texture2D(textureSampler,vUV+onePixel*vec2(0,-1)) +
10031texture2D(textureSampler,vUV+onePixel*vec2(-1,0)) +
10032texture2D(textureSampler,vUV+onePixel*vec2(1,0)) +
10033texture2D(textureSampler,vUV+onePixel*vec2(0,1)) -
10034color*4.0;
10035gl_FragColor=max(vec4(color.rgb*sharpnessAmounts.y,color.a)-(sharpnessAmounts.x*vec4(edgeDetection.rgb,0)),0.);
10036}`;je.a.ShadersStore.sharpenPixelShader=Fg;var Yc=function(r){function t(e,n,i,o,a,s,d,p){d===void 0&&(d=h.a.TEXTURETYPE_UNSIGNED_INT),p===void 0&&(p=!1);var y=r.call(this,e,"sharpen",["sharpnessAmounts","screenSize"],null,n,i,o,a,s,null,d,void 0,null,p)||this;return y.colorAmount=1,y.edgeAmount=.3,y.onApply=function(P){P.setFloat2("screenSize",y.width,y.height),P.setFloat2("sharpnessAmounts",y.edgeAmount,y.colorAmount)},y}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"SharpenPostProcess"},t._Parse=function(e,n,i,o){return L.a.Parse(function(){return new t(e.name,e.options,n,e.renderTargetSamplingMode,i.getEngine(),e.textureType,e.reusable)},e,i,o)},Object(c.c)([Object(L.c)()],t.prototype,"colorAmount",void 0),Object(c.c)([Object(L.c)()],t.prototype,"edgeAmount",void 0),t}(_t);R.a.RegisteredTypes["BABYLON.SharpenPostProcess"]=Yc;var Ur=function(){function r(t,e){this.engine=t,this._name=e,this._renderEffects={},this._renderEffectsForIsolatedPass=new Array,this._cameras=[]}return Object.defineProperty(r.prototype,"name",{get:function(){return this._name},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"cameras",{get:function(){return this._cameras},enumerable:!1,configurable:!0}),r.prototype.getClassName=function(){return"PostProcessRenderPipeline"},Object.defineProperty(r.prototype,"isSupported",{get:function(){for(var t in this._renderEffects)if(this._renderEffects.hasOwnProperty(t)&&!this._renderEffects[t].isSupported)return!1;return!0},enumerable:!1,configurable:!0}),r.prototype.addEffect=function(t){this._renderEffects[t._name]=t},r.prototype._rebuild=function(){},r.prototype._enableEffect=function(t,e){var n=this._renderEffects[t];n&&n._enable(Ye.b.MakeArray(e||this._cameras))},r.prototype._disableEffect=function(t,e){var n=this._renderEffects[t];n&&n._disable(Ye.b.MakeArray(e||this._cameras))},r.prototype._attachCameras=function(t,e){var n=Ye.b.MakeArray(t||this._cameras);if(n){var i,o=[];for(i=0;i<n.length;i++){var a=n[i];if(a){var s=a.name;this._cameras.indexOf(a)===-1?this._cameras[s]=a:e&&o.push(i)}}for(i=0;i<o.length;i++)t.splice(o[i],1);for(var d in this._renderEffects)this._renderEffects.hasOwnProperty(d)&&this._renderEffects[d]._attachCameras(n)}},r.prototype._detachCameras=function(t){var e=Ye.b.MakeArray(t||this._cameras);if(e){for(var n in this._renderEffects)this._renderEffects.hasOwnProperty(n)&&this._renderEffects[n]._detachCameras(e);for(var i=0;i<e.length;i++)this._cameras.splice(this._cameras.indexOf(e[i]),1)}},r.prototype._update=function(){for(var t in this._renderEffects)this._renderEffects.hasOwnProperty(t)&&this._renderEffects[t]._update();for(var e=0;e<this._cameras.length;e++)if(this._cameras[e]){var n=this._cameras[e].name;this._renderEffectsForIsolatedPass[n]&&this._renderEffectsForIsolatedPass[n]._update()}},r.prototype._reset=function(){this._renderEffects={},this._renderEffectsForIsolatedPass=new Array},r.prototype._enableMSAAOnFirstPostProcess=function(t){if(this.engine.webGLVersion===1)return!1;var e=Object.keys(this._renderEffects);if(e.length>0){var n=this._renderEffects[e[0]].getPostProcesses();n&&(n[0].samples=t)}return!0},r.prototype.setPrePassRenderer=function(t){return!1},r.prototype.dispose=function(){},Object(c.c)([Object(L.c)()],r.prototype,"_name",void 0),r}(),Kd=function(){function r(){this._renderPipelines={}}return Object.defineProperty(r.prototype,"supportedPipelines",{get:function(){var t=[];for(var e in this._renderPipelines)if(this._renderPipelines.hasOwnProperty(e)){var n=this._renderPipelines[e];n.isSupported&&t.push(n)}return t}
10036,enumerable:!1,configurable:!0}),r.prototype.addPipeline=function(t){this._renderPipelines[t._name]=t},r.prototype.attachCamerasToRenderPipeline=function(t,e,n){n===void 0&&(n=!1);var i=this._renderPipelines[t];i&&i._attachCameras(e,n)},r.prototype.detachCamerasFromRenderPipeline=function(t,e){var n=this._renderPipelines[t];n&&n._detachCameras(e)},r.prototype.enableEffectInPipeline=function(t,e,n){var i=this._renderPipelines[t];i&&i._enableEffect(e,n)},r.prototype.disableEffectInPipeline=function(t,e,n){var i=this._renderPipelines[t];i&&i._disableEffect(e,n)},r.prototype.update=function(){for(var t in this._renderPipelines)if(this._renderPipelines.hasOwnProperty(t)){var e=this._renderPipelines[t];e.isSupported?e._update():(e.dispose(),delete this._renderPipelines[t])}},r.prototype._rebuild=function(){for(var t in this._renderPipelines)this._renderPipelines.hasOwnProperty(t)&&this._renderPipelines[t]._rebuild()},r.prototype.dispose=function(){for(var t in this._renderPipelines)this._renderPipelines.hasOwnProperty(t)&&this._renderPipelines[t].dispose()},r}();Object.defineProperty(_e.a.prototype,"postProcessRenderPipelineManager",{get:function(){if(!this._postProcessRenderPipelineManager){var r=this._getComponent(st.a.NAME_POSTPROCESSRENDERPIPELINEMANAGER);r||(r=new Qd(this),this._addComponent(r)),this._postProcessRenderPipelineManager=new Kd}return this._postProcessRenderPipelineManager},enumerable:!0,configurable:!0});var Qd=function(){function r(t){this.name=st.a.NAME_POSTPROCESSRENDERPIPELINEMANAGER,this.scene=t}return r.prototype.register=function(){this.scene._gatherRenderTargetsStage.registerStep(st.a.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER,this,this._gatherRenderTargets)},r.prototype.rebuild=function(){this.scene._postProcessRenderPipelineManager&&this.scene._postProcessRenderPipelineManager._rebuild()},r.prototype.dispose=function(){this.scene._postProcessRenderPipelineManager&&this.scene._postProcessRenderPipelineManager.dispose()},r.prototype._gatherRenderTargets=function(){this.scene._postProcessRenderPipelineManager&&this.scene._postProcessRenderPipelineManager.update()},r}(),qd=function(r){function t(e,n,i,o,a){e===void 0&&(e=""),n===void 0&&(n=!0),i===void 0&&(i=te.a.LastCreatedScene),a===void 0&&(a=!0);var s=r.call(this,i.getEngine(),e)||this;s._camerasToBeAttached=[],s.SharpenPostProcessId="SharpenPostProcessEffect",s.ImageProcessingPostProcessId="ImageProcessingPostProcessEffect",s.FxaaPostProcessId="FxaaPostProcessEffect",s.ChromaticAberrationPostProcessId="ChromaticAberrationPostProcessEffect",s.GrainPostProcessId="GrainPostProcessEffect",s._glowLayer=null,s.animations=[],s._imageProcessingConfigurationObserver=null,s._sharpenEnabled=!1,s._bloomEnabled=!1,s._depthOfFieldEnabled=!1,s._depthOfFieldBlurLevel=ar.Low,s._fxaaEnabled=!1,s._imageProcessingEnabled=!0,s._bloomScale=.5,s._chromaticAberrationEnabled=!1,s._grainEnabled=!1,s._buildAllowed=!0,s.onBuildObservable=new x.c,s._resizeObserver=null,s._hardwareScaleLevel=1,s._bloomKernel=64,s._bloomWeight=.15,s._bloomThreshold=.9,s._samples=1,s._hasCleared=!1,s._prevPostProcess=null,s._prevPrevPostProcess=null,s._depthOfFieldSceneObserver=null,s._cameras=o||i.cameras,s._cameras=s._cameras.slice(),s._camerasToBeAttached=s._cameras.slice(),s._buildAllowed=a,s._scene=i;var d=s._scene.getEngine().getCaps();s._hdr=n&&(d.textureHalfFloatRender||d.textureFloatRender),s._hdr?d.textureHalfFloatRender?s._defaultPipelineTextureType=h.a.TEXTURETYPE_HALF_FLOAT:d.textureFloatRender&&(s._defaultPipelineTextureType=h.a.TEXTURETYPE_FLOAT):s._defaultPipelineTextureType=h.a.TEXTURETYPE_UNSIGNED_INT,i.postProcessRenderPipelineManager.addPipeline(s);var p=s._scene.getEngine();return s.sharpen=new Yc("sharpen",1,null,we.a.BILINEAR_SAMPLINGMODE,p,!1,s._defaultPipelineTextureType,!0),s._sharpenEffect=new Rt(p,s.SharpenPostProcessId,function(){return s.sharpen},!0),s.depthOfField=new Hc(s._scene,null,s._depthOfFieldBlurLevel,s._defaultPipelineTextureType,!0),s.bloom=new Gc(s._scene,s._bloomScale,s._bloomWeight,s.bloomKernel,s._defaultPipelineTextureType,!0),s.chromaticAberration=new zc("ChromaticAberration",p.getRenderWidth(),p.getRenderHeight(),1,null,we.a.BILINEAR_SAMPLINGMODE,p,!1,s._defaultPipelineTextureType,!0),s._chromaticAberrationEffect=new Rt(p,s.ChromaticAberrationPostProcessId,function(){return s.chromaticAberration},!0),s.grain=new Wc("Grain",1,null,we.a.BILINEAR_SAMPLINGMODE,p,!1,s._defaultPipelineTextureType,!0),s._grainEffect=new Rt(p,s.GrainPostProcessId,function(){return s.grain},!0),s._resizeObserver=p.onResizeObservable.add(function(){s._hardwareScaleLevel=p.getHardwareScalingLevel(),s.bloomKernel=s.bloomKernel}),s._imageProcessingConfigurationObserver=s._scene.imageProcessingConfiguration.onUpdateParameters.add(function(){s.bloom._downscale._exposure=s._scene.imageProcessingConfiguration.exposure,s.imageProcessingEnabled!==s._scene.imageProcessingConfiguration.isEnabled&&(s._imageProcessingEnabled=s._scene.imageProcessingConfiguration.isEnabled,s._buildPipeline())}),s._buildPipeline(),s}return Object(c.d)(t,r),Object.defineProperty(t.prototype,"scene",{get:function(){return this._scene}
10036,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sharpenEnabled",{get:function(){return this._sharpenEnabled},set:function(e){this._sharpenEnabled!==e&&(this._sharpenEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bloomKernel",{get:function(){return this._bloomKernel},set:function(e){this._bloomKernel=e,this.bloom.kernel=e/this._hardwareScaleLevel},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bloomWeight",{get:function(){return this._bloomWeight},set:function(e){this._bloomWeight!==e&&(this.bloom.weight=e,this._bloomWeight=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bloomThreshold",{get:function(){return this._bloomThreshold},set:function(e){this._bloomThreshold!==e&&(this.bloom.threshold=e,this._bloomThreshold=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bloomScale",{get:function(){return this._bloomScale},set:function(e){this._bloomScale!==e&&(this._bloomScale=e,this._rebuildBloom(),this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bloomEnabled",{get:function(){return this._bloomEnabled},set:function(e){this._bloomEnabled!==e&&(this._bloomEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),t.prototype._rebuildBloom=function(){var e=this.bloom;this.bloom=new Gc(this._scene,this.bloomScale,this._bloomWeight,this.bloomKernel,this._defaultPipelineTextureType,!1),this.bloom.threshold=e.threshold;for(var n=0;n<this._cameras.length;n++)e.disposeEffects(this._cameras[n])},Object.defineProperty(t.prototype,"depthOfFieldEnabled",{get:function(){return this._depthOfFieldEnabled},set:function(e){this._depthOfFieldEnabled!==e&&(this._depthOfFieldEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthOfFieldBlurLevel",{get:function(){return this._depthOfFieldBlurLevel},set:function(e){if(this._depthOfFieldBlurLevel!==e){this._depthOfFieldBlurLevel=e;var n=this.depthOfField;this.depthOfField=new Hc(this._scene,null,this._depthOfFieldBlurLevel,this._defaultPipelineTextureType,!1),this.depthOfField.focalLength=n.focalLength,this.depthOfField.focusDistance=n.focusDistance,this.depthOfField.fStop=n.fStop,this.depthOfField.lensSize=n.lensSize;for(var i=0;i<this._cameras.length;i++)n.disposeEffects(this._cameras[i]);this._buildPipeline()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fxaaEnabled",{get:function(){return this._fxaaEnabled},set:function(e){this._fxaaEnabled!==e&&(this._fxaaEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"samples",{get:function(){return this._samples},set:function(e){this._samples!==e&&(this._samples=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"imageProcessingEnabled",{get:function(){return this._imageProcessingEnabled},set:function(e){this._imageProcessingEnabled!==e&&(this._scene.imageProcessingConfiguration.isEnabled=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"glowLayerEnabled",{get:function(){return this._glowLayer!=null},set:function(e){e&&!this._glowLayer?this._glowLayer=new sa("",this._scene):!e&&this._glowLayer&&(this._glowLayer.dispose(),this._glowLayer=null)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"glowLayer",{get:function(){return this._glowLayer},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"chromaticAberrationEnabled",{get:function(){return this._chromaticAberrationEnabled},set:function(e){this._chromaticAberrationEnabled!==e&&(this._chromaticAberrationEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"grainEnabled",{get:function(){return this._grainEnabled},set:function(e){this._grainEnabled!==e&&(this._grainEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"DefaultRenderingPipeline"},t.prototype.prepare=function(){var e=this._buildAllowed;this._buildAllowed=!0,this._buildPipeline(),this._buildAllowed=e}
10036,t.prototype._setAutoClearAndTextureSharing=function(e,n){n===void 0&&(n=!1),this._hasCleared?e.autoClear=!1:(e.autoClear=!0,this._scene.autoClear=!1,this._hasCleared=!0),n||(this._prevPrevPostProcess?e.shareOutputWith(this._prevPrevPostProcess):e.useOwnOutput(),this._prevPostProcess&&(this._prevPrevPostProcess=this._prevPostProcess),this._prevPostProcess=e)},t.prototype._buildPipeline=function(){var e=this;if(this._buildAllowed){this._scene.autoClear=!0;var n=this._scene.getEngine();if(this._disposePostProcesses(),this._cameras!==null&&(this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),this._cameras=this._camerasToBeAttached.slice()),this._reset(),this._prevPostProcess=null,this._prevPrevPostProcess=null,this._hasCleared=!1,this.depthOfFieldEnabled){if(this._cameras.length>1){for(var i=0,o=this._cameras;i<o.length;i++){var a=o[i];(s=this._scene.enableDepthRenderer(a)).useOnlyInActiveCamera=!0}this._depthOfFieldSceneObserver=this._scene.onAfterRenderTargetsRenderObservable.add(function(d){e._cameras.indexOf(d.activeCamera)>-1&&(e.depthOfField.depthTexture=d.enableDepthRenderer(d.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 Ho("imageProcessing",1,null,we.a.BILINEAR_SAMPLINGMODE,n,!1,this._defaultPipelineTextureType),this._hdr?(this.addEffect(new Rt(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 Ro("fxaa",1,null,we.a.BILINEAR_SAMPLINGMODE,n,!1,this._defaultPipelineTextureType),this.addEffect(new Rt(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.autoClear=!0),!this._enableMSAAOnFirstPostProcess(this.samples)&&this.samples>1&&l.a.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0"),this.onBuildObservable.notifyObservers(this)}},t.prototype._disposePostProcesses=function(e){e===void 0&&(e=!1);for(var n=0;n<this._cameras.length;n++){var i=this._cameras[n];this.imageProcessing&&this.imageProcessing.dispose(i),this.fxaa&&this.fxaa.dispose(i),e&&(this.sharpen&&this.sharpen.dispose(i),this.depthOfField&&(this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver),this.depthOfField.disposeEffects(i)),this.bloom&&this.bloom.disposeEffects(i),this.chromaticAberration&&this.chromaticAberration.dispose(i),this.grain&&this.grain.dispose(i),this._glowLayer&&this._glowLayer.dispose())}this.imageProcessing=null,this.fxaa=null,e&&(this.sharpen=null,this._sharpenEffect=null,this.depthOfField=null,this.bloom=null,this.chromaticAberration=null,this._chromaticAberrationEffect=null,this.grain=null,this._grainEffect=null,this._glowLayer=null)},t.prototype.addCamera=function(e){this._camerasToBeAttached.push(e),this._buildPipeline()},t.prototype.removeCamera=function(e){var n=this._camerasToBeAttached.indexOf(e);this._camerasToBeAttached.splice(n,1),this._buildPipeline()},t.prototype.dispose=function(){this.onBuildObservable.clear(),this._disposePostProcesses(!0),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),this._scene.autoClear=!0,this._resizeObserver&&(this._scene.getEngine().onResizeObservable.remove(this._resizeObserver),this._resizeObserver=null),this._scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigurationObserver),r.prototype.dispose.call(this)},t.prototype.serialize=function(){var e=L.a.Serialize(this);return e.customType="DefaultRenderingPipeline",e},t.Parse=function(e,n,i){return L.a.Parse(function(){return new t(e._name,e._name._hdr,n)},e,n,i)},Object(c.c)([Object(L.c)()],t.prototype,"sharpenEnabled",null),Object(c.c)([Object(L.c)()],t.prototype,"bloomKernel",null),Object(c.c)([Object(L.c)()],t.prototype,"_bloomWeight",void 0),Object(c.c)([Object(L.c)()],t.prototype,"_bloomThreshold",void 0),Object(c.c)([Object(L.c)()],t.prototype,"_hdr",void 0),Object(c.c)([Object(L.c)()],t.prototype,"bloomWeight",null),Object(c.c)([Object(L.c)()],t.prototype,"bloomThreshold",null),Object(c.c)([Object(L.c)()],t.prototype,"bloomScale",null),Object(c.c)([Object(L.c)()],t.prototype,"bloomEnabled",null),Object(c.c)([Object(L.c)()],t.prototype,"depthOfFieldEnabled",null),Object(c.c)([Object(L.c)()],t.prototype,"depthOfFieldBlurLevel",null),Object(c.c)([Object(L.c)()],t.prototype,"fxaaEnabled",null),Object(c.c)([Object(L.c)()],t.prototype,"samples",null),Object(c.c)([Object(L.c)()],t.prototype,"imageProcessingEnabled",null),Object(c.c)([Object(L.c)()],t.prototype,"glowLayerEnabled",null),Object(c.c)([Object(L.c)()],t.prototype,"chromaticAberrationEnabled",null),Object(c.c)([Object(L.c)()],t.prototype,"grainEnabled",null),t}(Ur);R.a.RegisteredTypes["BABYLON.DefaultRenderingPipeline"]=qd;var Bg=`
10037uniform sampler2D textureSampler;
10038
10039uniform float gain;
10040uniform float threshold;
10041uniform float screen_width;
10042uniform float screen_height;
10043
10044varying vec2 vUV;
10045
10046vec4 highlightColor(vec4 color) {
10047vec4 highlight=color;
10048float luminance=dot(highlight.rgb,vec3(0.2125,0.7154,0.0721));
10049float lum_threshold;
10050if (threshold>1.0) { lum_threshold=0.94+0.01*threshold; }
10051else { lum_threshold=0.5+0.44*threshold; }
10052luminance=clamp((luminance-lum_threshold)*(1.0/(1.0-lum_threshold)),0.0,1.0);
10053highlight*=luminance*gain;
10054highlight.a=1.0;
10055return highlight;
10056}
10057void main(void)
10058{
10059vec4 original=texture2D(textureSampler,vUV);
10060
10061if (gain == -1.0) {
10062gl_FragColor=vec4(0.0,0.0,0.0,1.0);
10063return;
10064}
10065float w=2.0/screen_width;
10066float h=2.0/screen_height;
10067float weight=1.0;
10068
10069vec4 blurred=vec4(0.0,0.0,0.0,0.0);
10070#ifdef PENTAGON
10071blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.84*w,0.43*h)));
10072blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.48*w,-1.29*h)));
10073blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.61*w,1.51*h)));
10074blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.55*w,-0.74*h)));
10075blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.71*w,-0.52*h)));
10076blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.94*w,1.59*h)));
10077blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.40*w,-1.87*h)));
10078blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.62*w,1.16*h)));
10079blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.09*w,0.25*h)));
10080blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.46*w,-1.71*h)
10080));
10081blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.08*w,2.42*h)));
10082blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.85*w,-1.89*h)));
10083blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.89*w,0.16*h)));
10084blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.29*w,1.88*h)));
10085blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.40*w,-2.81*h)));
10086blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.54*w,2.26*h)));
10087blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.60*w,-0.61*h)));
10088blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.31*w,-1.30*h)));
10089blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.83*w,2.53*h)));
10090blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.12*w,-2.48*h)));
10091blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.60*w,1.11*h)));
10092blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.82*w,0.99*h)));
10093blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.50*w,-2.81*h)));
10094blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.85*w,3.33*h)));
10095blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.94*w,-1.92*h)));
10096blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.27*w,-0.53*h)));
10097blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.95*w,2.48*h)));
10098blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.23*w,-3.04*h)));
10099blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.17*w,2.05*h)));
10100blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.97*w,-0.04*h)));
10101blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.25*w,-2.00*h)));
10102blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.31*w,3.08*h)));
10103blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.94*w,-2.59*h)));
10104blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.37*w,0.64*h)));
10105blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.13*w,1.93*h)));
10106blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.03*w,-3.65*h)));
10107blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.60*w,3.17*h)));
10108blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.14*w,-1.19*h)));
10109blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.00*w,-1.19*h)));
10110#else
10111blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.85*w,0.36*h)));
10112blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.52*w,-1.14*h)));
10113blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.46*w,1.42*h)));
10114blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.46*w,-0.83*h)));
10115blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.79*w,-0.42*h)));
10116blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.11*w,1.62*h)));
10117blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.29*w,-2.07*h)));
10118blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.69*w,1.39*h)));
10119blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.28*w,0.12*h)));
10120blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.65*w,-1.69*h)));
10121blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.08*w,2.44*h)));
10122blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.63*w,-1.90*h)));
10123blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.55*w,0.31*h)));
10124blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.13*w,1.52*h)));
10125blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.56*w,-2.61*h)));
10126blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.38*w,2.34*h)));
10127blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.64*w,-0.81*h)));
10128blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.53*w,-1.21*h)));
10129blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.06*w,2.63*h)));
10130blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.00*w,-2.69*h)));
10131blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.59*w,1.32*h)));
10132blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.82*w,0.78*h)));
10133blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.57*w,-2.50*h)));
10134blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.54*w,2.93*h)));
10135blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.39*w,-1.81*h)));
10136blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.01*w,-0.28*h)));
10137blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.04*w,2.25*h)));
10138blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.02*w,-3.05*h)));
10139blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.09*w,2.25*h)));
10140blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.07*w,-0.25*h)));
10141blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.44*w,-1.90*h)));
10142blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.52*w,3.05*h)));
10143blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.68*w,-2.61*h)));
10144blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.01*w,0.79*h)));
10145blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.76*w,
101451.46*h)));
10146blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.05*w,-2.94*h)));
10147blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.21*w,2.88*h)));
10148blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.84*w,-1.30*h)));
10149blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.98*w,-0.96*h)));
10150#endif
10151blurred/=39.0;
10152gl_FragColor=blurred;
10153
10154}`;je.a.ShadersStore.lensHighlightsPixelShader=Bg;var Ug=`
10155
10156
10157
10158
10159uniform sampler2D textureSampler;
10160uniform sampler2D highlightsSampler;
10161uniform sampler2D depthSampler;
10162uniform sampler2D grainSampler;
10163
10164uniform float grain_amount;
10165uniform bool blur_noise;
10166uniform float screen_width;
10167uniform float screen_height;
10168uniform float distortion;
10169uniform bool dof_enabled;
10170
10171uniform float screen_distance;
10172uniform float aperture;
10173uniform float darken;
10174uniform float edge_blur;
10175uniform bool highlights;
10176
10177uniform float near;
10178uniform float far;
10179
10180varying vec2 vUV;
10181
10182#define PI 3.14159265
10183#define TWOPI 6.28318530
10184#define inverse_focal_length 0.1
10185
10186vec2 centered_screen_pos;
10187vec2 distorted_coords;
10188float radius2;
10189float radius;
10190
10191vec2 rand(vec2 co)
10192{
10193float noise1=(fract(sin(dot(co,vec2(12.9898,78.233)))*43758.5453));
10194float noise2=(fract(sin(dot(co,vec2(12.9898,78.233)*2.0))*43758.5453));
10195return clamp(vec2(noise1,noise2),0.0,1.0);
10196}
10197
10198vec2 getDistortedCoords(vec2 coords) {
10199if (distortion == 0.0) { return coords; }
10200vec2 direction=1.0*normalize(centered_screen_pos);
10201vec2 dist_coords=vec2(0.5,0.5);
10202dist_coords.x=0.5+direction.x*radius2*1.0;
10203dist_coords.y=0.5+direction.y*radius2*1.0;
10204float dist_amount=clamp(distortion*0.23,0.0,1.0);
10205dist_coords=mix(coords,dist_coords,dist_amount);
10206return dist_coords;
10207}
10208
10209float sampleScreen(inout vec4 color,const in vec2 offset,const in float weight) {
10210
10211vec2 coords=distorted_coords;
10212float angle=rand(coords*100.0).x*TWOPI;
10213coords+=vec2(offset.x*cos(angle)-offset.y*sin(angle),offset.x*sin(angle)+offset.y*cos(angle));
10214color+=texture2D(textureSampler,coords)*weight;
10215return weight;
10216}
10217
10218float getBlurLevel(float size) {
10219return min(3.0,ceil(size/1.0));
10220}
10221
10222vec4 getBlurColor(float size) {
10223vec4 col=texture2D(textureSampler,distorted_coords);
10224if (size == 0.0) { return col; }
10225
10226
10227float blur_level=getBlurLevel(size);
10228float w=(size/screen_width);
10229float h=(size/screen_height);
10230float total_weight=1.0;
10231vec2 sample_coords;
10232total_weight+=sampleScreen(col,vec2(-0.50*w,0.24*h),0.93);
10233total_weight+=sampleScreen(col,vec2(0.30*w,-0.75*h),0.90);
10234total_weight+=sampleScreen(col,vec2(0.36*w,0.96*h),0.87);
10235total_weight+=sampleScreen(col,vec2(-1.08*w,-0.55*h),0.85);
10236total_weight+=sampleScreen(col,vec2(1.33*w,-0.37*h),0.83);
10237total_weight+=sampleScreen(col,vec2(-0.82*w,1.31*h),0.80);
10238total_weight+=sampleScreen(col,vec2(-0.31*w,-1.67*h),0.78);
10239total_weight+=sampleScreen(col,vec2(1.47*w,1.11*h),0.76);
10240total_weight+=sampleScreen(col,vec2(-1.97*w,0.19*h),0.74);
10241total_weight+=sampleScreen(col,vec2(1.42*w,-1.57*h),0.72);
10242if (blur_level>1.0) {
10243total_weight+=sampleScreen(col,vec2(0.01*w,2.25*h),0.70);
10244total_weight+=sampleScreen(col,vec2(-1.62*w,-1.74*h),0.67);
10245total_weight+=sampleScreen(col,vec2(2.49*w,0.20*h),0.65);
10246total_weight+=sampleScreen(col,vec2(-2.07*w,1.61*h),0.63);
10247total_weight+=sampleScreen(col,vec2(0.46*w,-2.70*h),0.61);
10248total_weight+=sampleScreen(col,vec2(1.55*w,2.40*h),0.59);
10249total_weight+=sampleScreen(col,vec2(-2.88*w,-0.75*h),0.56);
10250total_weight+=sampleScreen(col,vec2(2.73*w,-1.44*h),0.54);
10251total_weight+=sampleScreen(col,vec2(-1.08*w,3.02*h),0.52);
10252total_weight+=sampleScreen(col,vec2(-1.28*w,-3.05*h),0.49);
10253}
10254if (blur_level>2.0) {
10255total_weight+=sampleScreen(col,vec2(3.11*w,1.43*h),0.46);
10256total_weight+=sampleScreen(col,vec2(-3.36*w,1.08*h),0.44);
10257total_weight+=sampleScreen(col,vec2(1.80*w,-3.16*h),0.41);
10258total_weight+=sampleScreen(col,vec2(0.83*w,3.65*h),0.38);
10259total_weight+=sampleScreen(col,vec2(-3.16*w,-2.19*h),0.34);
10260total_weight+=sampleScreen(col,vec2(3.92*w,-0.53*h),0.31);
10261total_weight+=sampleScreen(col,vec2(-2.59*w,3.12*h),0.26);
10262total_weight+=sampleScreen(col,vec2(-0.20*w,-4.15*h),0.22);
10263total_weight+=sampleScreen(col,vec2(3.02*w,3.00*h),0.15);
10264}
10265col/=total_weight;
10266
10267if (darken>0.0) {
10268col.rgb*=clamp(0.3,1.0,1.05-size*0.5*darken);
10269}
10270
10271
10272
10273
10274return col;
10275}
10276void main(void)
10277{
10278
10279centered_screen_pos=vec2(vUV.x-0.5,vUV.y-0.5);
10280radius2=centered_screen_pos.x*centered_screen_pos.x+centered_screen_pos.y*centered_screen_pos.y;
10281radius=sqrt(radius2);
10282distorted_coords=getDistortedCoords(vUV);
10283vec2 texels_coords=vec2(vUV.x*screen_width,vUV.y*screen_height);
10284float depth=texture2D(depthSampler,distorted_coords).r;
10285float distance=near+(far-near)*depth;
10286vec4 color=texture2D(textureSampler,vUV);
10287
10288
10289float coc=abs(aperture*(screen_distance*(inverse_focal_length-1.0/distance)-1.0));
10290
10291if (dof_enabled == false || coc<0.07) { coc=0.0; }
10292
10293float edge_blur_amount=0.0;
10294if (edge_blur>0.0) {
10295edge_blur_amount=clamp((radius*2.0-1.0+0.15*edge_blur)*1.5,0.0,1.0)*1.3;
10296}
10297
10298float blur_amount=max(edge_blur_amount,coc);
10299
10300if (blur_amount == 0.0) {
10301gl_FragColor=texture2D(textureSampler,distorted_coords);
10302}
10303else {
10304
10305gl_FragColor=getBlurColor(blur_amount*1.7);
10306
10307if (highlights) {
10308gl_FragColor.rgb+=clamp(coc,0.0,1.0)*texture2D(highlightsSampler,distorted_coords).rgb;
10309}
10310if (blur_noise) {
10311
10312vec2 noise=rand(distorted_coords)*0.01*blur_amount;
10313vec2 blurred_coord=vec2(distorted_coords.x+noise.x,distorted_coords.y+noise.y);
10314gl_FragColor=0.04*texture2D(textureSampler,blurred_coord)+0.96*gl_FragColor;
10315}
10316}
10317
10318if (grain_amount>0.0) {
10319vec4 grain_color=texture2D(grainSampler,texels_coords*0.003);
10320gl_FragColor.rgb+=(-0.5+grain_color.rgb)*0.30*grain_amount;
10321}
10322}
10323`;je.a.ShadersStore.depthOfFieldPixelShader=Ug;var Vg=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.HighlightsEnhancingEffe
10323ct="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 Rt(i.getEngine(),s.LensChromaticAberrationEffect,function(){return s._chromaticAberrationPostProcess},!0)),s.addEffect(new Rt(i.getEngine(),s.HighlightsEnhancingEffect,function(){return s._highlightsPostProcess},!0)),s.addEffect(new Rt(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 Object(c.d)(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
10324`),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("LensChromaticAberration","chromaticAberration",["chromatic_aberration","screen_width","screen_height","direction","radialIntensity","centerPosition"],[],e,null,we.a.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("LensHighlights","lensHighlights",["gain","threshold","screen_width","screen_height"],[],e,null,we.a.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,this._dofPentagon?`#define PENTAGON
10325`:""),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("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,
10325null,we.a.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),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(){this._grainTexture=new yi.a("LensNoiseTexture",512,this._scene,!1,we.a.BILINEAR_SAMPLINGMODE),this._grainTexture.wrapU=we.a.WRAP_ADDRESSMODE,this._grainTexture.wrapV=we.a.WRAP_ADDRESSMODE;for(var e,n,i,o=this._grainTexture.getContext(),a=0;a<512;a++)for(var s=0;s<512;s++)e=Math.floor(255*(n=.42,i=.58,Math.random()*(i-n)+n)),o.fillStyle="rgb("+e+", "+e+", "+e+")",o.fillRect(a,s,1,1);this._grainTexture.update(!1)},t}(Ur),kg=function(){this.enabled=!1,this.name="ssao2",this.texturesRequired=[h.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE]},Gg=`
10326precision highp float;
10327uniform sampler2D textureSampler;
10328uniform float near;
10329uniform float far;
10330uniform float radius;
10331float scales[16]=float[16](
103320.1,
103330.11406250000000001,
103340.131640625,
103350.15625,
103360.187890625,
103370.2265625,
103380.272265625,
103390.325,
103400.384765625,
103410.4515625,
103420.525390625,
103430.60625,
103440.694140625,
103450.7890625,
103460.891015625,
103471.0
10348);
10349varying vec2 vUV;
10350float perspectiveDepthToViewZ( const in float invClipZ,const in float near,const in float far ) {
10351return ( near*far )/( ( far-near )*invClipZ-far );
10352}
10353float viewZToPerspectiveDepth( const in float viewZ,const in float near,const in float far ) {
10354return ( near*far/viewZ+far)/( far-near );
10355}
10356float viewZToOrthographicDepth( const in float viewZ,const in float near,const in float far ) {
10357return ( viewZ+near )/( near-far );
10358}
10359#ifdef SSAO
10360uniform sampler2D randomSampler;
10361#ifndef GEOMETRYBUFFER
10362uniform sampler2D depthNormalSampler;
10363#else
10364uniform sampler2D depthSampler;
10365uniform sampler2D normalSampler;
10366#endif
10367uniform float randTextureTiles;
10368uniform float samplesFactor;
10369uniform vec3 sampleSphere[SAMPLES];
10370uniform float totalStrength;
10371uniform float base;
10372uniform float xViewport;
10373uniform float yViewport;
10374uniform float maxZ;
10375uniform float minZAspect;
10376uniform vec2 texelSize;
10377uniform mat4 projection;
10378void main()
10379{
10380vec3 random=texture2D(randomSampler,vUV*randTextureTiles).rgb;
10381#ifndef GEOMETRYBUFFER
10382float depth=texture2D(depthNormalSampler,vUV).r;
10383#else
10384float depth=texture2D(depthSampler,vUV).r;
10385#endif
10386float depthSign=depth/abs(depth);
10387depth=depth*depthSign;
10388#ifndef GEOMETRYBUFFER
10389vec3 normal=texture2D(depthNormalSampler,vUV).gba;
10390#else
10391vec3 normal=texture2D(normalSampler,vUV).rgb;
10392#endif
10393float occlusion=0.0;
10394float correctedRadius=min(radius,minZAspect*depth/near);
10395vec3 vViewRay=vec3((vUV.x*2.0-1.0)*xViewport,(vUV.y*2.0-1.0)*yViewport,depthSign);
10396vec3 origin=vViewRay*depth;
10397vec3 rvec=random*2.0-1.0;
10398rvec.z=0.0;
10399
10400float dotProduct=dot(rvec,normal);
10401rvec=1.0-abs(dotProduct)>1e-2 ? rvec : vec3(-rvec.y,0.0,rvec.x);
10402vec3 tangent=normalize(rvec-normal*dot(rvec,normal));
10403vec3 bitangent=cross(normal,tangent);
10404mat3 tbn=mat3(tangent,bitangent,normal);
10405float difference;
10406for (int i=0; i<SAMPLES; ++i) {
10407
10408vec3 samplePosition=scales[(i+int(random.x*16.0)) % 16]*tbn*sampleSphere[(i+int(random.y*16.0)) % 16];
10409samplePosition=samplePosition*correctedRadius+origin;
10410
10411vec4 offset=vec4(samplePosition,1.0);
10412offset=projection*offset;
10413offset.xyz/=offset.w;
10414offset.xy=offset.xy*0.5+0.5;
10415if (offset.x<0.0 || offset.y<0.0 || offset.x>1.0 || offset.y>1.0) {
10416continue;
10417}
10418
10419#ifndef GEOMETRYBUFFER
10420float sampleDepth=abs(texture2D(depthNormalSampler,offset.xy).r);
10421#else
10422float sampleDepth=abs(texture2D(depthSampler,offset.xy).r);
10423#endif
10424
10425difference=depthSign*samplePosition.z-sampleDepth;
10426float rangeCheck=1.0-smoothstep(correctedRadius*0.5,correctedRadius,difference);
10427occlusion+=(difference>=0.0 ? 1.0 : 0.0)*rangeCheck;
10428}
10429occlusion=occlusion*(1.0-smoothstep(maxZ*0.75,maxZ,depth));
10430float ao=1.0-totalStrength*occlusion*samplesFactor;
10431float result=clamp(ao+base,0.0,1.0);
10432gl_FragColor=vec4(vec3(result),1.0);
10433}
10434#endif
10435#ifdef BILATERAL_BLUR
10436uniform sampler2D depthNormalSampler;
10437uniform float outSize;
10438uniform float samplerOffsets[SAMPLES];
10439vec4 blur9(sampler2D image,vec2 uv,float resolution,vec2 direction) {
10440vec4 color=vec4(0.0);
10441vec2 off1=vec2(1.3846153846)*direction;
10442vec2 off2=vec2(3.2307692308)*direction;
10443color+=texture2D(image,uv)*0.2270270270;
10444color+=texture2D(image,uv+(off1/resolution))*0.3162162162;
10445color+=texture2D(image,uv-(off1/resolution))*0.3162162162;
10446color+=texture2D(image,uv+(off2/resolution))*0.0702702703;
10447color+=texture2D(image,uv-(off2/resolution))*0.0702702703;
10448return color;
10449}
10450vec4 blur13(sampler2D image,vec2 uv,float resolution,vec2 direction) {
10451vec4 color=vec4(0.0);
10452vec2 off1=vec2(1.411764705882353)*direction;
10453vec2 off2=vec2(3.2941176470588234)*direction;
10454vec2 off3=vec2(5.176470588235294)*direction;
10455color+=texture2D(image,uv)*0.1964825501511404;
10456color+=texture2D(image,uv+(off1/resolution))*0.2969069646728344;
10457color+=texture2D(image,uv-(off1/resolution))*0.2969069646728344;
10458color+=texture2D(image,uv+(off2/resolution))*0.09447039785044732;
10459color+=texture2D(image,uv-(off2/resolution))*0.09447039785044732;
10460color+=texture2D(image,uv+(off3/resolution))*0.010381362401148057;
10461color+=texture2D(image,uv-(off3/resolution))*0.010381362401148057;
10462return color;
10463}
10464vec4 blur13Bilateral(sampler2D image,vec2 uv,float resolution,vec2 direction) {
10465vec4 color=vec4(0.0);
10466vec2 off1=vec2(1.411764705882353)*direction;
10467vec2 off2=vec2(3.2941176470588234)*direction;
10468vec2 off3=vec2(5.176470588235294)*direction;
10469float compareDepth=abs(texture2D(depthNormalSampler,uv).r);
10470float sampleDepth;
10471float weight;
10472float weightSum=30.0;
10473color+=texture2D(image,uv)*30.0;
10474sampleDepth=abs(texture2D(depthNormalSampler,uv+(off1/resolution)).r);
10475weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);
10476weightSum+=weight;
10477color+=texture2D(image,uv+(off1/resolution))*weight;
10478sampleDepth=abs(texture2D(depthNormalSampler,uv-(off1/resolution)).r);
10479weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);
10480weightSum+=weight;
10481color+=texture2D(image,uv-(off1/resolution))*weight;
10482sampleDepth=abs(texture2D(depthNormalSampler,uv+(off2/resolution)).r);
10483weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);
10484weightSum+=weight;
10485color+=texture2D(image,uv+(off2/resolution))*weight;
10486sampleDepth=abs(texture2D(depthNormalSampler,uv-(off2/resolution)).r);
10487weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);
10488weightSum+=weight;
10489color+=texture2D(image,uv-(off2/resolution))*weight;
10490sampleDepth=abs(texture2D(depthNormalSampler,uv+(off3/resolution)).r);
10491weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);
10492weightSum+=weight;
10493color+=texture2D(image,uv+(off3/resolution))*weight;
10494sampleDepth=abs(texture2D(depthNormalSampler,uv-(off3/resolution)).r);
10495weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);
10496weightSum+=weight;
10497color+=texture2D(image,uv-(off3/resolution))*weight;
10498return color/weightSum;
10499}
10500void main()
10501{
10502#if EXPENSIVE
10503float compareDepth=abs(texture2D(depthNormalSampler,vUV).r);
10504float texelsize=1.0/outSize;
10505float result=0.0;
10506float weightSum=0.0;
10507for (int i=0; i<SAMPLES; ++i)
10508{
10509#ifdef BILATERAL_BLUR_H
10510vec2 direction=vec2(1.0,0.0);
10511vec2 sampleOffset=vec2(texelsize*samplerOffsets[i],0.0);
10512#else
10513vec2 direction=vec2(0.0,1.0);
10514vec2 sampleOffset=vec2(0.0,texelsize*samplerOffsets[i]);
10515#endif
10516vec2 samplePos=vUV+sampleOffset;
10517float sampleDepth=abs(texture2D(depthNormalSampler,samplePos).r);
10518float weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30000.0);
10519result+=texture2D(textureSampler,samplePos).r*weight;
10520weightSum+=weight;
10521}
10522result/=weightSum;
10523gl_FragColor.rgb=vec3(result);
10524gl_FragColor.a=1.0;
10525#else
10526vec4 color;
10527#ifdef BILATERAL_BLUR_H
10528vec2 direction=vec2(1.0,0.0);
10529color=blur13Bilateral(textureSampler,vUV,outSize,direction);
10530#else
10531vec2 direction=vec2(0.0,1.0);
10532color=blur13Bilateral(textureSampler,vUV,outSize,direction);
10533#endif
10534gl_FragColor.rgb=vec3(color.r);
10535gl_FragColor.a=1.0;
10536#endif
10537}
10538#endif
10539`;je.a.ShadersStore.ssao2PixelShader=Gg;var zg=`uniform sampler2D textureSampler;
10540uniform sampler2D originalColor;
10541uniform vec4 viewport;
10542varying vec2 vUV;
10543void main(void) {
10544vec4 ssaoColor=texture2D(textureSampler,viewport.xy+vUV*viewport.zw);
10545vec4 sceneColor=texture2D(originalColor,vUV);
10546gl_FragColor=sceneColor*ssaoColor;
10547}
10548`;je.a.ShadersStore.ssaoCombinePixelShader=zg;var Zd=function(r){function t(e,n,i,o,a){a===void 0&&(a=!0);var s=r.call(this,n.getEngine(),e)||this;if(s.SSAOOriginalSceneColorEffect="SSAOOriginalSceneColorEffect",s.SSAORenderEffect="SSAORenderEffect",s.SSAOBlurHRenderEffect="SSAOBlurHRenderEffect",s.SSAOBlurVRenderEffect="SSAOBlurVRenderEffect",s.SSAOCombineRenderEffect="SSAOCombineRenderEffect",s.totalStrength=1,s.maxZ=100,s.minZAspect=.2,s._samples=8,s._textureSamples=1,s._forceGeometryBuffer=!1,s._expensiveBlur=!0,s.radius=2,s.base=0,s._bits=new Uint32Array(1),s._scene=n,s._ratio=i,s._forceGeometryBuffer=a,!s.isSupported)return l.a.Error("SSAO 2 needs WebGL 2 support."),s;var d=s._ratio.ssaoRatio||i,p=s._ratio.blurRatio||i;return s._forceGeometryBuffer?n.enableGeometryBufferRenderer():s._prePassRenderer=n.enablePrePassRenderer(),s._createRandomTexture(),s._originalColorPostProcess=new Li("SSAOOriginalSceneColor",1,null,we.a.BILINEAR_SAMPLINGMODE,n.getEngine(),!1),s._originalColorPostProcess.samples=s.textureSamples,s._createSSAOPostProcess(1),s._createBlurPostProcess(d,p),s._createSSAOCombinePostProcess(p),s.addEffect(new Rt(n.getEngine(),s.SSAOOriginalSceneColorEffect,function(){return s._originalColorPostProcess},!0)),s.addEffect(new Rt(n.getEngine(),s.SSAORenderEffect,function(){return s._ssaoPostProcess},!0)),s.addEffect(new Rt(n.getEngine(),s.SSAOBlurHRenderEffect,function(){return s._blurHPostProcess},!0)),s.addEffect(new Rt(n.getEngine(),s.SSAOBlurVRenderEffect,function(){return s._blurVPostProcess},!0)),s.addEffect(new Rt(n.getEngine(),s.SSAOCombineRenderEffect,function(){return s._ssaoCombinePostProcess},!0)),n.postProcessRenderPipelineManager.addPipeline(s),o&&n.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(e,o),s}return Object(c.d)(t,r),Object.defineProperty(t.prototype,"samples",{get:function(){return this._samples},set:function(e){this._samples=e,this._ssaoPostProcess.updateEffect(this._getDefinesForSSAO()),this._sampleSphere=this._generateHemisphere()}
10548,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textureSamples",{get:function(){return this._textureSamples},set:function(e){this._textureSamples=e,this._originalColorPostProcess.samples=e,this._blurHPostProcess.samples=e,this._blurVPostProcess.samples=e,this._ssaoPostProcess.samples=e,this._ssaoCombinePostProcess.samples=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"expensiveBlur",{get:function(){return this._expensiveBlur},set:function(e){this._blurHPostProcess.updateEffect(`#define BILATERAL_BLUR
10549#define BILATERAL_BLUR_H
10550#define SAMPLES 16
10551#define EXPENSIVE `+(e?"1":"0")+`
10552`,null,["textureSampler","depthNormalSampler"]),this._blurVPostProcess.updateEffect(`#define BILATERAL_BLUR
10553#define SAMPLES 16
10554#define EXPENSIVE `+(e?"1":"0")+`
10555`,null,["textureSampler","depthNormalSampler"]),this._expensiveBlur=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"IsSupported",{get:function(){var e=te.a.LastCreatedEngine;return!!e&&e.webGLVersion>=2},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"SSAO2RenderingPipeline"},t.prototype.dispose=function(e){e===void 0&&(e=!1);for(var n=0;n<this._scene.cameras.length;n++){var i=this._scene.cameras[n];this._originalColorPostProcess.dispose(i),this._ssaoPostProcess.dispose(i),this._blurHPostProcess.dispose(i),this._blurVPostProcess.dispose(i),this._ssaoCombinePostProcess.dispose(i)}this._randomTexture.dispose(),e&&this._scene.disableGeometryBufferRenderer(),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._scene.cameras),r.prototype.dispose.call(this)},t.prototype._createBlurPostProcess=function(e,n){var i=this;this._samplerOffsets=[];for(var o=this.expensiveBlur,a=-8;a<8;a++)this._samplerOffsets.push(2*a+.5);this._blurHPostProcess=new _t("BlurH","ssao2",["outSize","samplerOffsets","near","far","radius"],["depthNormalSampler"],e,null,we.a.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,`#define BILATERAL_BLUR
10556#define BILATERAL_BLUR_H
10557#define SAMPLES 16
10558#define EXPENSIVE `+(o?"1":"0")+`
10559`),this._blurHPostProcess.onApply=function(s){i._scene.activeCamera&&(s.setFloat("outSize",i._ssaoCombinePostProcess.width>0?i._ssaoCombinePostProcess.width:i._originalColorPostProcess.width),s.setFloat("near",i._scene.activeCamera.minZ),s.setFloat("far",i._scene.activeCamera.maxZ),s.setFloat("radius",i.radius),i._forceGeometryBuffer?s.setTexture("depthNormalSampler",i._scene.enableGeometryBufferRenderer().getGBuffer().textures[0]):s.setTexture("depthNormalSampler",i._prePassRenderer.prePassRT.textures[i._prePassRenderer.getIndex(h.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)]),s.setArray("samplerOffsets",i._samplerOffsets))},this._blurVPostProcess=new _t("BlurV","ssao2",["outSize","samplerOffsets","near","far","radius"],["depthNormalSampler"],n,null,we.a.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,`#define BILATERAL_BLUR
10560#define BILATERAL_BLUR_V
10561#define SAMPLES 16
10562#define EXPENSIVE `+(o?"1":"0")+`
10563`),this._blurVPostProcess.onApply=function(s){i._scene.activeCamera&&(s.setFloat("outSize",i._ssaoCombinePostProcess.height>0?i._ssaoCombinePostProcess.height:i._originalColorPostProcess.height),s.setFloat("near",i._scene.activeCamera.minZ),s.setFloat("far",i._scene.activeCamera.maxZ),s.setFloat("radius",i.radius),i._forceGeometryBuffer?s.setTexture("depthNormalSampler",i._scene.enableGeometryBufferRenderer().getGBuffer().textures[0]):s.setTexture("depthNormalSampler",i._prePassRenderer.prePassRT.textures[i._prePassRenderer.getIndex(h.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)]),s.setArray("samplerOffsets",i._samplerOffsets))},this._blurHPostProcess.samples=this.textureSamples,this._blurVPostProcess.samples=this.textureSamples},t.prototype._rebuild=function(){r.prototype._rebuild.call(this)},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+.15),a=Math.sqrt(1-o*o);return new u.e(Math.cos(i)*a,Math.sin(i)*a,o)},t.prototype._generateHemisphere=function(){for(var e,n=this.samples,i=[],o=0;o<n;){if(n<16)e=this._hemisphereSample_uniform(Math.random(),Math.random());else{var a=this._hammersley(o,n);e=this._hemisphereSample_uniform(a[0],a[1])}i.push(e.x,e.y,e.z),o++}return i},t.prototype._getDefinesForSSAO=function(){var e="#define SAMPLES "+this.samples+`
10564#define SSAO`;return this._forceGeometryBuffer&&(e+=`
10565#define GEOMETRYBUFFER`),e},t.prototype._createSSAOPostProcess=function(e){var n=this;this._sampleSphere=this._generateHemisphere();var i,o=this._getDefinesForSSAO();i=this._forceGeometryBuffer?["randomSampler","depthSampler","normalSampler"]:["randomSampler","depthNormalSampler"],this._ssaoPostProcess=new _t("ssao2","ssao2",["sampleSphere","samplesFactor","randTextureTiles","totalStrength","radius","base","range","projection","near","far","texelSize","xViewport","yViewport","maxZ","minZAspect"],i,e,null,we.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,o),this._ssaoPostProcess.onApply=function(a){n._scene.activeCamera&&(a.setArray3("sampleSphere",n._sampleSphere),a.setFloat("randTextureTiles",32),a.setFloat("samplesFactor",1/n.samples),a.setFloat("totalStrength",n.totalStrength),a.setFloat2("texelSize",1/n._ssaoPostProcess.width,1/n._ssaoPostProcess.height),a.setFloat("radius",n.radius),a.setFloat("maxZ",n.maxZ),a.setFloat("minZAspect",n.minZAspect),a.setFloat("base",n.base),a.setFloat("near",n._scene.activeCamera.minZ),a.setFloat("far",n._scene.activeCamera.maxZ),a.setFloat("xViewport",Math.tan(n._scene.activeCamera.fov/2)*n._scene.getEngine().getAspectRatio(n._scene.activeCamera,!0)),a.setFloat("yViewport",Math.tan(n._scene.activeCamera.fov/2)),a.setMatrix("projection",n._scene.getProjectionMatrix()),n._forceGeometryBuffer?(a.setTexture("depthSampler",n._scene.enableGeometryBufferRenderer().getGBuffer().textures[0]),a.setTexture("normalSampler",n._scene.enableGeometryBufferRenderer().getGBuffer().textures[1])):a.setTexture("depthNormalSampler",n._prePassRenderer.prePassRT.textures[n._prePassRenderer.getIndex(h.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)]),a.setTexture("randomSampler",n._randomTexture))},this._ssaoPostProcess.samples=this.textureSamples},t.prototype._createSSAOCombinePostProcess=function(e){var n=this;this._ssaoCombinePostProcess=new _t("ssaoCombine","ssaoCombine",[],["originalColor","viewport"],e,null,we.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),this._ssaoCombinePostProcess.onApply=function(i){var o=n._scene.activeCamera.viewport;i.setVector4("viewport",u.c.Vector4[0].copyFromFloats(o.x,o.y,o.width,o.height)),i.setTextureFromPostProcessOutput("originalColor",n._originalColorPostProcess)},this._ssaoCombinePostProcess.samples=this.textureSamples,this._forceGeometryBuffer||(this._ssaoCombinePostProcess._prePassEffectConfiguration=new kg)},t.prototype._createRandomTexture=function(){this._randomTexture=new yi.a("SSAORandomTexture",128,this._scene,!1,we.a.TRILINEAR_SAMPLINGMODE),this._randomTexture.wrapU=we.a.WRAP_ADDRESSMODE,this._randomTexture.wrapV=we.a.WRAP_ADDRESSMODE;for(var e=this._randomTexture.getContext(),n=function(s,d){return Math.random()*(d-s)+s},i=u.e.Zero(),o=0;o<128;o++)for(var a=0;a<128;a++)i.x=n(0,1),i.y=n(0,1),i.z=0,i.normalize(),i.scaleInPlace(255
10565),i.x=Math.floor(i.x),i.y=Math.floor(i.y),e.fillStyle="rgb("+i.x+", "+i.y+", "+i.z+")",e.fillRect(o,a,1,1);this._randomTexture.update(!1)},t.prototype.serialize=function(){var e=L.a.Serialize(this);return e.customType="SSAO2RenderingPipeline",e},t.Parse=function(e,n,i){return L.a.Parse(function(){return new t(e._name,n,e._ratio)},e,n,i)},Object(c.c)([Object(L.c)()],t.prototype,"totalStrength",void 0),Object(c.c)([Object(L.c)()],t.prototype,"maxZ",void 0),Object(c.c)([Object(L.c)()],t.prototype,"minZAspect",void 0),Object(c.c)([Object(L.c)("samples")],t.prototype,"_samples",void 0),Object(c.c)([Object(L.c)("textureSamples")],t.prototype,"_textureSamples",void 0),Object(c.c)([Object(L.c)()],t.prototype,"_ratio",void 0),Object(c.c)([Object(L.c)("expensiveBlur")],t.prototype,"_expensiveBlur",void 0),Object(c.c)([Object(L.c)()],t.prototype,"radius",void 0),Object(c.c)([Object(L.c)()],t.prototype,"base",void 0),t}(Ur);R.a.RegisteredTypes["BABYLON.SSAO2RenderingPipeline"]=Zd;var jg=`
10566uniform sampler2D textureSampler;
10567varying vec2 vUV;
10568#ifdef SSAO
10569uniform sampler2D randomSampler;
10570uniform float randTextureTiles;
10571uniform float samplesFactor;
10572uniform vec3 sampleSphere[SAMPLES];
10573uniform float totalStrength;
10574uniform float radius;
10575uniform float area;
10576uniform float fallOff;
10577uniform float base;
10578vec3 normalFromDepth(float depth,vec2 coords)
10579{
10580vec2 offset1=vec2(0.0,radius);
10581vec2 offset2=vec2(radius,0.0);
10582float depth1=texture2D(textureSampler,coords+offset1).r;
10583float depth2=texture2D(textureSampler,coords+offset2).r;
10584vec3 p1=vec3(offset1,depth1-depth);
10585vec3 p2=vec3(offset2,depth2-depth);
10586vec3 normal=cross(p1,p2);
10587normal.z=-normal.z;
10588return normalize(normal);
10589}
10590void main()
10591{
10592vec3 random=normalize(texture2D(randomSampler,vUV*randTextureTiles).rgb);
10593float depth=texture2D(textureSampler,vUV).r;
10594vec3 position=vec3(vUV,depth);
10595vec3 normal=normalFromDepth(depth,vUV);
10596float radiusDepth=radius/depth;
10597float occlusion=0.0;
10598vec3 ray;
10599vec3 hemiRay;
10600float occlusionDepth;
10601float difference;
10602for (int i=0; i<SAMPLES; i++)
10603{
10604ray=radiusDepth*reflect(sampleSphere[i],random);
10605hemiRay=position+sign(dot(ray,normal))*ray;
10606occlusionDepth=texture2D(textureSampler,clamp(hemiRay.xy,vec2(0.001,0.001),vec2(0.999,0.999))).r;
10607difference=depth-occlusionDepth;
10608occlusion+=step(fallOff,difference)*(1.0-smoothstep(fallOff,area,difference));
10609}
10610float ao=1.0-totalStrength*occlusion*samplesFactor;
10611float result=clamp(ao+base,0.0,1.0);
10612gl_FragColor.r=result;
10613gl_FragColor.g=result;
10614gl_FragColor.b=result;
10615gl_FragColor.a=1.0;
10616}
10617#endif
10618`;je.a.ShadersStore.ssaoPixelShader=jg;var Hg=function(r){function t(e,n,i,o){var a=r.call(this,n.getEngine(),e)||this;a.SSAOOriginalSceneColorEffect="SSAOOriginalSceneColorEffect",a.SSAORenderEffect="SSAORenderEffect",a.SSAOBlurHRenderEffect="SSAOBlurHRenderEffect",a.SSAOBlurVRenderEffect="SSAOBlurVRenderEffect",a.SSAOCombineRenderEffect="SSAOCombineRenderEffect",a.totalStrength=1,a.radius=1e-4,a.area=.0075,a.fallOff=1e-6,a.base=.5,a._firstUpdate=!0,a._scene=n,a._createRandomTexture(),a._depthTexture=n.enableDepthRenderer().getDepthMap();var s=i.ssaoRatio||i,d=i.combineRatio||i;return a._originalColorPostProcess=new Li("SSAOOriginalSceneColor",d,null,we.a.BILINEAR_SAMPLINGMODE,n.getEngine(),!1),a._createSSAOPostProcess(s),a._createBlurPostProcess(s),a._createSSAOCombinePostProcess(d),a.addEffect(new Rt(n.getEngine(),a.SSAOOriginalSceneColorEffect,function(){return a._originalColorPostProcess},!0)),a.addEffect(new Rt(n.getEngine(),a.SSAORenderEffect,function(){return a._ssaoPostProcess},!0)),a.addEffect(new Rt(n.getEngine(),a.SSAOBlurHRenderEffect,function(){return a._blurHPostProcess},!0)),a.addEffect(new Rt(n.getEngine(),a.SSAOBlurVRenderEffect,function(){return a._blurVPostProcess},!0)),a.addEffect(new Rt(n.getEngine(),a.SSAOCombineRenderEffect,function(){return a._ssaoCombinePostProcess},!0)),n.postProcessRenderPipelineManager.addPipeline(a),o&&n.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(e,o),a}return Object(c.d)(t,r),Object.defineProperty(t.prototype,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"SSAORenderingPipeline"},t.prototype.dispose=function(e){e===void 0&&(e=!1);for(var n=0;n<this._scene.cameras.length;n++){var i=this._scene.cameras[n];this._originalColorPostProcess.dispose(i),this._ssaoPostProcess.dispose(i),this._blurHPostProcess.dispose(i),this._blurVPostProcess.dispose(i),this._ssaoCombinePostProcess.dispose(i)}this._randomTexture.dispose(),e&&this._scene.disableDepthRenderer(),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._scene.cameras),r.prototype.dispose.call(this)},t.prototype._createBlurPostProcess=function(e){var n=this;this._blurHPostProcess=new _n("BlurH",new u.d(1,0),16,e,null,we.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,h.a.TEXTURETYPE_UNSIGNED_INT),this._blurVPostProcess=new _n("BlurV",new u.d(0,1),16,e,null,we.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,h.a.TEXTURETYPE_UNSIGNED_INT),this._blurHPostProcess.onActivateObservable.add(function(){var i=n._blurHPostProcess.width/n._scene.getEngine().getRenderWidth();n._blurHPostProcess.kernel=16*i}),this._blurVPostProcess.onActivateObservable.add(function(){var i=n._blurVPostProcess.height/n._scene.getEngine().getRenderHeight();n._blurVPostProcess.kernel=16*i})},t.prototype._rebuild=function(){this._firstUpdate=!0,r.prototype._rebuild.call(this)},t.prototype._createSSAOPostProcess=function(e){var n=this,i=[.5381,.1856,-.4319,.1379,.2486,.443,.3371,.5679,-.0057,-.6999,-.0451,-.0019,.0689,-.1598,-.8547,.056,.0069,-.1843,-.0146,.1402,.0762,.01,-.1924,-.0344,-.3577,-.5301,-.4358,-.3169,.1063,.0158,.0103,-.5869,.0046,-.0897,-.494,.3287,.7119,-.0154,-.0918,-.0533,.0596,-.5411,.0352,-.0631,.546,-.4776,.2847,-.0271];this._ssaoPostProcess=new _t("ssao","ssao",["sampleSphere","samplesFactor","randTextureTiles","totalStrength","radius","area","fallOff","base","range","viewport"],["randomSampler"],e,
10618null,we.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,`#define SAMPLES 16
10619#define SSAO`),this._ssaoPostProcess.onApply=function(o){n._firstUpdate&&(o.setArray3("sampleSphere",i),o.setFloat("samplesFactor",1/16),o.setFloat("randTextureTiles",4)),o.setFloat("totalStrength",n.totalStrength),o.setFloat("radius",n.radius),o.setFloat("area",n.area),o.setFloat("fallOff",n.fallOff),o.setFloat("base",n.base),o.setTexture("textureSampler",n._depthTexture),o.setTexture("randomSampler",n._randomTexture)}},t.prototype._createSSAOCombinePostProcess=function(e){var n=this;this._ssaoCombinePostProcess=new _t("ssaoCombine","ssaoCombine",[],["originalColor","viewport"],e,null,we.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),this._ssaoCombinePostProcess.onApply=function(i){i.setVector4("viewport",u.c.Vector4[0].copyFromFloats(0,0,1,1)),i.setTextureFromPostProcess("originalColor",n._originalColorPostProcess)}},t.prototype._createRandomTexture=function(){this._randomTexture=new yi.a("SSAORandomTexture",512,this._scene,!1,we.a.TRILINEAR_SAMPLINGMODE),this._randomTexture.wrapU=we.a.WRAP_ADDRESSMODE,this._randomTexture.wrapV=we.a.WRAP_ADDRESSMODE;for(var e=this._randomTexture.getContext(),n=function(s,d){return Math.random()*(d-s)+s},i=u.e.Zero(),o=0;o<512;o++)for(var a=0;a<512;a++)i.x=Math.floor(255*n(-1,1)),i.y=Math.floor(255*n(-1,1)),i.z=Math.floor(255*n(-1,1)),e.fillStyle="rgb("+i.x+", "+i.y+", "+i.z+")",e.fillRect(o,a,1,1);this._randomTexture.update(!1)},Object(c.c)([Object(L.c)()],t.prototype,"totalStrength",void 0),Object(c.c)([Object(L.c)()],t.prototype,"radius",void 0),Object(c.c)([Object(L.c)()],t.prototype,"area",void 0),Object(c.c)([Object(L.c)()],t.prototype,"fallOff",void 0),Object(c.c)([Object(L.c)()],t.prototype,"base",void 0),t}(Ur),Wg=function(){this.enabled=!1,this.name="screenSpaceReflections",this.texturesRequired=[h.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE,h.a.PREPASS_REFLECTIVITY_TEXTURE_TYPE,h.a.PREPASS_POSITION_TEXTURE_TYPE]},Xg=`
10620
10621uniform sampler2D textureSampler;
10622uniform sampler2D normalSampler;
10623uniform sampler2D positionSampler;
10624uniform sampler2D reflectivitySampler;
10625uniform mat4 view;
10626uniform mat4 projection;
10627uniform float step;
10628uniform float strength;
10629uniform float threshold;
10630uniform float roughnessFactor;
10631uniform float reflectionSpecularFalloffExponent;
10632
10633varying vec2 vUV;
10634
10635struct ReflectionInfo {
10636vec3 color;
10637vec4 coords;
10638};
10639
10640vec3 fresnelSchlick(float cosTheta,vec3 F0)
10641{
10642return F0+(1.0-F0)*pow(1.0-cosTheta,5.0);
10643}
10644
10645ReflectionInfo smoothReflectionInfo(vec3 dir,vec3 hitCoord)
10646{
10647ReflectionInfo info;
10648info.color=vec3(0.0);
10649vec4 projectedCoord;
10650float sampledDepth;
10651for(int i=0; i<SMOOTH_STEPS; i++)
10652{
10653projectedCoord=projection*vec4(hitCoord,1.0);
10654projectedCoord.xy/=projectedCoord.w;
10655projectedCoord.xy=0.5*projectedCoord.xy+vec2(0.5);
10656sampledDepth=(view*texture2D(positionSampler,projectedCoord.xy)).z;
10657float depth=sampledDepth-hitCoord.z;
10658dir*=0.5;
10659if(depth>0.0)
10660hitCoord-=dir;
10661else
10662hitCoord+=dir;
10663info.color+=texture2D(textureSampler,projectedCoord.xy).rgb;
10664}
10665projectedCoord=projection*vec4(hitCoord,1.0);
10666projectedCoord.xy/=projectedCoord.w;
10667projectedCoord.xy=0.5*projectedCoord.xy+vec2(0.5);
10668
10669info.coords=vec4(projectedCoord.xy,sampledDepth,1.0);
10670info.color+=texture2D(textureSampler,projectedCoord.xy).rgb;
10671info.color/=float(SMOOTH_STEPS+1);
10672return info;
10673}
10674
10675ReflectionInfo getReflectionInfo(vec3 dir,vec3 hitCoord)
10676{
10677ReflectionInfo info;
10678vec4 projectedCoord;
10679float sampledDepth;
10680dir*=step;
10681for(int i=0; i<REFLECTION_SAMPLES; i++)
10682{
10683hitCoord+=dir;
10684projectedCoord=projection*vec4(hitCoord,1.0);
10685projectedCoord.xy/=projectedCoord.w;
10686projectedCoord.xy=0.5*projectedCoord.xy+vec2(0.5);
10687sampledDepth=(view*texture2D(positionSampler,projectedCoord.xy)).z;
10688float depth=sampledDepth-hitCoord.z;
10689if(((depth-dir.z)<threshold) && depth<=0.0)
10690{
10691#ifdef ENABLE_SMOOTH_REFLECTIONS
10692return smoothReflectionInfo(dir,hitCoord);
10693#else
10694info.color=texture2D(textureSampler,projectedCoord.xy).rgb;
10695info.coords=vec4(projectedCoord.xy,sampledDepth,0.0);
10696return info;
10697#endif
10698}
10699}
10700info.color=texture2D(textureSampler,projectedCoord.xy).rgb;
10701info.coords=vec4(projectedCoord.xy,sampledDepth,0.0);
10702return info;
10703}
10704vec3 hash(vec3 a)
10705{
10706a=fract(a*0.8);
10707a+=dot(a,a.yxz+19.19);
10708return fract((a.xxy+a.yxx)*a.zyx);
10709}
10710void main()
10711{
10712#ifdef SSR_SUPPORTED
10713
10714vec4 albedoFull=texture2D(textureSampler,vUV);
10715vec3 albedo=albedoFull.rgb;
10716float spec=texture2D(reflectivitySampler,vUV).r;
10717if (spec == 0.0) {
10718gl_FragColor=albedoFull;
10719return;
10720}
10721
10722#ifdef PREPASS_LAYOUT
10723vec3 normal=(texture2D(normalSampler,vUV)).gba;
10724#else
10725vec3 normal=(texture2D(normalSampler,vUV)).xyz;
10726#endif
10727vec3 position=(view*texture2D(positionSampler,vUV)).xyz;
10728vec3 reflected=normalize(reflect(normalize(position),normalize(normal)));
10729float roughness=1.0-texture2D(reflectivitySampler,vUV).a;
10730vec3 jitt=mix(vec3(0.0),hash(position),roughness)*roughnessFactor;
10731ReflectionInfo info=getReflectionInfo(jitt+reflected,position);
10732
10733vec2 dCoords=smoothstep(0.2,0.6,abs(vec2(0.5,0.5)-info.coords.xy));
10734float screenEdgefactor=clamp(1.0-(dCoords.x+dCoords.y),0.0,1.0);
10735
10736vec3 F0=vec3(0.04);
10737F0=mix(F0,albedo,spec);
10738vec3 fresnel=fresnelSchlick(max(dot(normalize(normal),normalize(position)),0.0
10738),F0);
10739
10740float reflectionMultiplier=clamp(pow(spec*strength,reflectionSpecularFalloffExponent)*screenEdgefactor*reflected.z,0.0,0.9);
10741float albedoMultiplier=1.0-reflectionMultiplier;
10742vec3 SSR=info.color*fresnel;
10743gl_FragColor=vec4((albedo*albedoMultiplier)+(SSR*reflectionMultiplier),albedoFull.a);
10744#else
10745gl_FragColor=texture2D(textureSampler,vUV);
10746#endif
10747}
10748`;je.a.ShadersStore.screenSpaceReflectionPixelShader=Xg;var Kc=function(r){function t(e,n,i,o,a,s,d,p,y,P){p===void 0&&(p=h.a.TEXTURETYPE_UNSIGNED_INT),y===void 0&&(y=!1),P===void 0&&(P=!0);var O=r.call(this,e,"screenSpaceReflection",["projection","view","threshold","reflectionSpecularFalloffExponent","strength","step","roughnessFactor"],["textureSampler","normalSampler","positionSampler","reflectivitySampler"],i,o,a,s,d,`#define SSR_SUPPORTED
10749#define REFLECTION_SAMPLES 64
10750#define SMOOTH_STEPS 5
10751`,p,void 0,null,y)||this;if(O.threshold=1.2,O.strength=1,O.reflectionSpecularFalloffExponent=3,O.step=1,O.roughnessFactor=.2,O._forceGeometryBuffer=!1,O._enableSmoothReflections=!1,O._reflectionSamples=64,O._smoothSteps=5,O._forceGeometryBuffer=P,O._forceGeometryBuffer){var U=n.enableGeometryBufferRenderer();U&&U.isSupported&&(U.enablePosition=!0,U.enableReflectivity=!0,O._geometryBufferRenderer=U)}else O._prePassRenderer=n.enablePrePassRenderer(),O._prePassRenderer.markAsDirty(),O._prePassEffectConfiguration=new Wg;return O._updateEffectDefines(),O.onApply=function(F){var z=O._geometryBufferRenderer,J=O._prePassRenderer;if(J||z){if(z){var ie=z.getTextureIndex(ai.POSITION_TEXTURE_TYPE),se=z.getTextureIndex(ai.REFLECTIVITY_TEXTURE_TYPE);F.setTexture("normalSampler",z.getGBuffer().textures[1]),F.setTexture("positionSampler",z.getGBuffer().textures[ie]),F.setTexture("reflectivitySampler",z.getGBuffer().textures[se])}else{ie=J.getIndex(h.a.PREPASS_POSITION_TEXTURE_TYPE),se=J.getIndex(h.a.PREPASS_REFLECTIVITY_TEXTURE_TYPE);var ce=J.getIndex(h.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE);F.setTexture("normalSampler",J.prePassRT.textures[ce]),F.setTexture("positionSampler",J.prePassRT.textures[ie]),F.setTexture("reflectivitySampler",J.prePassRT.textures[se])}var ue=n.activeCamera;if(ue){var fe=ue.getViewMatrix(),ve=ue.getProjectionMatrix();F.setMatrix("projection",ve),F.setMatrix("view",fe),F.setFloat("threshold",O.threshold),F.setFloat("reflectionSpecularFalloffExponent",O.reflectionSpecularFalloffExponent),F.setFloat("strength",O.strength),F.setFloat("step",O.step),F.setFloat("roughnessFactor",O.roughnessFactor)}}},O}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"ScreenSpaceReflectionPostProcess"},Object.defineProperty(t.prototype,"enableSmoothReflections",{get:function(){return this._enableSmoothReflections},set:function(e){e!==this._enableSmoothReflections&&(this._enableSmoothReflections=e,this._updateEffectDefines())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"reflectionSamples",{get:function(){return this._reflectionSamples},set:function(e){e!==this._reflectionSamples&&(this._reflectionSamples=e,this._updateEffectDefines())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"smoothSteps",{get:function(){return this._smoothSteps},set:function(e){e!==this._smoothSteps&&(this._smoothSteps=e,this._updateEffectDefines())},enumerable:!1,configurable:!0}),t.prototype._updateEffectDefines=function(){var e=[];(this._geometryBufferRenderer||this._prePassRenderer)&&(e.push("#define SSR_SUPPORTED"),this._prePassRenderer&&e.push("#define PREPASS_LAYOUT")),this._enableSmoothReflections&&e.push("#define ENABLE_SMOOTH_REFLECTIONS"),e.push("#define REFLECTION_SAMPLES "+(this._reflectionSamples>>0)),e.push("#define SMOOTH_STEPS "+(this._smoothSteps>>0)),this.updateEffect(e.join(`
10752`))},t._Parse=function(e,n,i,o){return L.a.Parse(function(){return new t(e.name,i,e.options,n,e.renderTargetSamplingMode,i.getEngine(),e.textureType,e.reusable)},e,i,o)},Object(c.c)([Object(L.c)()],t.prototype,"threshold",void 0),Object(c.c)([Object(L.c)()],t.prototype,"strength",void 0),Object(c.c)([Object(L.c)()],t.prototype,"reflectionSpecularFalloffExponent",void 0),Object(c.c)([Object(L.c)()],t.prototype,"step",void 0),Object(c.c)([Object(L.c)()],t.prototype,"roughnessFactor",void 0),Object(c.c)([Object(L.c)()],t.prototype,"enableSmoothReflections",null),Object(c.c)([Object(L.c)()],t.prototype,"reflectionSamples",null),Object(c.c)([Object(L.c)()],t.prototype,"smoothSteps",null),t}(_t);R.a.RegisteredTypes["BABYLON.ScreenSpaceReflectionPostProcess"]=Kc;var Yg=`uniform sampler2D textureSampler;
10753varying vec2 vUV;
10754#if defined(PASS_POST_PROCESS)
10755void main(void)
10756{
10757vec4 color=texture2D(textureSampler,vUV);
10758gl_FragColor=color;
10759}
10760#endif
10761#if defined(DOWN_SAMPLE_X4)
10762uniform vec2 dsOffsets[16];
10763void main(void)
10764{
10765vec4 average=vec4(0.0,0.0,0.0,0.0);
10766average=texture2D(textureSampler,vUV+dsOffsets[0]);
10767average+=texture2D(textureSampler,vUV+dsOffsets[1]);
10768average+=texture2D(textureSampler,vUV+dsOffsets[2]);
10769average+=texture2D(textureSampler,vUV+dsOffsets[3]);
10770average+=texture2D(textureSampler,vUV+dsOffsets[4]);
10771average+=texture2D(textureSampler,vUV+dsOffsets[5]);
10772average+=texture2D(textureSampler,vUV+dsOffsets[6]);
10773average+=texture2D(textureSampler,vUV+dsOffsets[7]);
10774average+=texture2D(textureSampler,vUV+dsOffsets[8]);
10775average+=texture2D(textureSampler,vUV+dsOffsets[9]);
10776average+=texture2D(textureSampler,vUV+dsOffsets[10]);
10777average+=texture2D(textureSampler,vUV+dsOffsets[11]);
10778average+=texture2D(textureSampler,vUV+dsOffsets[12]);
10779average+=texture2D(textureSampler,vUV+dsOffsets[13]);
10780average+=texture2D(textureSampler,vUV+dsOffsets[14]);
10781average+=texture2D(textureSampler,vUV+dsOffsets[15]);
10782average/=16.0;
10783gl_FragColor=average;
10784}
10785#endif
10786#if defined(BRIGHT_PASS)
10787uniform vec2 dsOffsets[4];
10788uniform float brightThreshold;
10789void main(void)
10790{
10791vec4 average=vec4(0.0,0.0,0.0,0.0);
10792average=texture2D(textureSampler,vUV+vec2(dsOffsets[0].x,dsOffsets[0].y));
10793average+=texture2D(textureSampler,vUV+vec2(dsOffsets[1].x,dsOffsets[1].y));
10794average+=texture2D(textureSampler,vUV+vec2(dsOffsets[2].x,dsOffsets[2].y));
10795average+=texture2D(textureSampler,vUV+vec2(dsOffsets[3].x,dsOffsets[3].y));
10796average*=0.25;
10797float luminance=length(average.rgb);
10798if (luminance<brightThreshold) {
10799average=vec4(0.0,0.0,0.0,1.0);
10800}
10801gl_FragColor=average;
10802}
10803#endif
10804#if defined(TEXTURE_ADDER)
10805uniform sampler2D otherSampler;
10806uniform sampler2D lensSampler;
10807uniform float exposure;
10808void main(void)
10809{
10810vec3 colour=texture2D(textureSampler,vUV).rgb;
10811colour*=exposure;
10812vec3 X=max(vec3(0.0,0.0,0.0),colour-0.004);
10813vec3 retColor=(X*(6.2*X+0.5))/(X*(6.2*X+1.7)+0.06);
10814colour=retColor*retColor;
10815colour+=colour*texture2D(lensSampler,vUV).rgb;
10816vec4 finalColor=vec4(colour.rgb,1.0)+texture2D(otherSampler,vUV);
10817gl_FragColor=finalColor;
10818}
10819#endif
10820#if defined(VLS)
10821#define PI 3.1415926535897932384626433832795
10822uniform mat4 shadowViewProjection;
10823uniform mat4 lightWorld;
10824uniform vec3 cameraPosition;
10825uniform vec3 sunDirection;
10826uniform vec3 sunColor;
10827uniform vec2 depthValues;
10828uniform float scatteringCoefficient;
10829uniform float scatteringPower;
10830uniform sampler2D shadowMapSampler;
10831uniform sampler2D positionSampler;
10832float computeScattering(float lightDotView)
10833{
10834float result=1.0-scatteringCoefficient*scatteringCoefficient;
10835result/=(4.0*PI*pow(1.0+scatteringCoefficient*scatteringCoefficient-(2.0*scatteringCoefficient)*lightDotView,1.5));
10836return result;
10837}
10838void main(void)
10839{
10840
10841vec3 worldPos=texture2D(positionSampler,vUV).rgb;
10842vec3 startPosition=cameraPosition;
10843vec3 rayVector=worldPos-startPosition;
10844float rayLength=length(rayVector);
10845vec3 rayDirection=rayVector/rayLength;
10846float stepLength=rayLength/NB_STEPS;
10847vec3 stepL=rayDirection*stepLength;
10848vec3 currentPosition=startPosition;
10849vec3 accumFog=vec3(0.0);
10850for (int i=0; i<int(NB_STEPS); i++)
10851{
10852vec4 worldInShadowCameraSpace=shadowViewProjection*vec4(currentPosition,1.0);
10853float depthMetric=(worldInShadowCameraSpace.z+depthValues.x)/(depthValues.y);
10854float shadowPixelDepth=clamp(depthMetric,0.0,1.0);
10855worldInShadowCameraSpace.xyz/=worldInShadowCameraSpace.w;
10856worldInShadowCameraSpace.xyz=0.5*worldInShadowCameraSpace.xyz+vec3(0.5);
10857float shadowMapValue=texture2D(shadowMapSampler,worldInShadowCameraSpace.xy).r;
10858if (shadowMapValue>shadowPixelDepth)
10859accumFog+=sunColor*computeScattering(dot(rayDirection,sunDirection));
10860currentPosition+=stepL;
10861}
10862accumFog/=NB_STEPS;
10863vec3 color=accumFog*scatteringPower;
10864gl_FragColor=vec4(color*exp(color) ,1.0);
10865}
10866#endif
10867#if defined(VLSMERGE)
10868uniform sampler2D originalSampler;
10869void main(void)
10870{
10871gl_FragColor=texture2D(originalSampler,vUV)+texture2D(textureSampler,vUV);
10872}
10873#endif
10874#if defined(LUMINANCE)
10875uniform vec2 lumOffsets[4];
10876void main()
10877{
10878float average=0.0;
10879vec4 color=vec4(0.0);
10880float maximum=-1e20;
10881vec3 weight=vec3(0.299,0.587,0.114);
10882for (int i=0; i<4; i++)
10883{
10884color=texture2D(textureSampler,vUV+ lumOffsets[i]);
10885
10886float GreyValue=dot(color.rgb,vec3(0.33,0.33,0.33));
10887
10888#ifdef WEIGHTED_AVERAGE
10889float GreyValue=dot(color.rgb,weight);
10890#endif
10891#ifdef BRIGHTNESS
10892float GreyValue=max(color.r,max(color.g,color.b));
10893#endif
10894#ifdef HSL_COMPONENT
10895float GreyValue=0.5*(max(color.r,max(color.g,color.b))+min(color.r,min(color.g,color.b)));
10896#endif
10897#ifdef MAGNITUDE
10898float GreyValue=length(color.rgb);
10899#endif
10900maximum=max(maximum,GreyValue);
10901average+=(0.25*log(1e-5+GreyValue));
10902}
10903average=exp(average);
10904gl_FragColor=vec4(average,maximum,0.0,1.0);
10905}
10906#endif
10907#if defined(LUMINANCE_DOWN_SAMPLE)
10908uniform vec2 dsOffsets[9];
10909uniform float halfDestPixelSize;
10910#ifdef FINAL_DOWN_SAMPLER
10911#include<packingFunctions>
10912#endif
10913void main()
10914{
10915vec4 color=vec4(0.0);
10916float average=0.0;
10917for (int i=0; i<9; i++)
10918{
10919color=texture2D(textureSampler,vUV+vec2(halfDestPixelSize,halfDestPixelSize)+dsOffsets[i]);
10920average+=color.r;
10921}
10922average/=9.0;
10923#ifdef FINAL_DOWN_SAMPLER
10924gl_FragColor=pack(average);
10925#else
10926gl_FragColor=vec4(average,average,0.0,1.0);
10927#endif
10928}
10929#endif
10930#if defined(HDR)
10931uniform sampler2D textureAdderSampler;
10932uniform float averageLuminance;
10933void main()
10934{
10935vec4 color=texture2D(textureAdderSampler,vUV);
10936#ifndef AUTO_EXPOSURE
10937vec4 adjustedColor=color/averageLuminance;
10938color=adjustedColor;
10939color.a=1.0;
10940#endif
10941gl_FragColor=color;
10942}
10943#endif
10944#if defined(LENS_FLARE)
10945#define GHOSTS 3
10946uniform sampler2D lensColorSampler;
10947uniform float strength;
10948uniform float ghostDispersal;
10949uniform float haloWidth;
10950uniform vec2 resolution;
10951uniform float distortionStrength;
10952float hash(vec2 p)
10953{
10954float h=dot(p,vec2(127.1,311.7));
10955return -1.0+2.0*fract(sin(h)*43758.5453123);
10956}
10957float noise(in vec2 p)
10958{
10959vec2 i=floor(p);
10960vec2 f=fract(p);
10961vec2 u=f*f*(3.0-2.0*f);
10962return mix(mix(hash(i+vec2(0.0,0.0)),
10963hash(i+vec2(1.0,0.0)),u.x),
10964mix(hash(i+vec2(0.0,1.0)),
10965hash(i+vec2(1.0,1.0)),u.x),u.y);
10966}
10967float fbm(vec2 p)
10968{
10969float f=0.0;
10970f+=0.5000*noise(p); p*=2.02;
10971f+=0.2500*noise(p); p*=2.03;
10972f+=0.1250*noise(p); p*=2.01;
10973f+=0.0625*noise(p); p*=2.04;
10974f/=0.9375;
10975return f;
10976}
10977vec3 pattern(vec2 uv)
10978{
10979vec2 p=-1.0+2.0*uv;
10980float p2=dot(p,p);
10981float f=fbm(vec2(15.0*p2))/2.0;
10982float r=0.2+0.6*sin(12.5*length(uv-vec2(0.5)));
10983float g=0.2+0.6*sin(20.5*length(uv-vec2(0.5)));
10984float b=0.2+0.6*sin(17.2*length(uv-vec2(0.5)));
10985return (1.0-f)*vec3(r,g,b);
10986}
10987float luminance(vec3 color)
10988{
10989return dot(color.rgb,vec3(0.2126,0.7152,0.0722));
10990}
10991vec4 textureDistorted(sampler2D tex,vec2 texcoord,vec2 direction,vec3 distortion)
10992{
10993return vec4(
10994texture2D(tex,texcoord+direction*distortion.r).r,
10995texture2D(tex,texcoord+direction*distortion.g).g,
10996texture2D(tex,texcoord+direction*distortion.b).b,
109971.0
10998);
10999}
11000void main(void)
11001{
11002vec2 uv=-vUV+vec2(1.0);
11003vec2 ghostDir=(vec2(0.5)-uv)*ghostDispersal;
11004vec2 texelSize=1.0/resolution;
11005vec3 distortion=vec3(-texelSize.x*distortionStrength,0.0,texelSize.x*distortionStrength);
11006vec4 result=vec4(0.0);
11007float ghostIndice=1.0;
11008for (int i=0; i<GHOSTS; ++i)
11009{
11010vec2 offset=fract(uv+ghostDir*ghostIndice);
11011float weight=length(vec2(0.5)-offset)/length(vec2(0.5));
11012weight=pow(1.0-weight,10.0);
11013result+=textureDistorted(textureSampler,offset,normalize(ghostDir),distortion)*weight*strength;
11014ghostIndice+=1.0;
11015}
11016vec2 haloVec=normalize(ghostDir)*haloWidth;
11017float weight=length(vec2(0.5)-fract(uv+haloVec))/length(vec2(0.5));
11018weight=pow(1.0-weight,10.0);
11019result+=textureDistorted(textureSampler,fract(uv+haloVec),normalize(ghostDir),distortion)*weight*strength;
11020result*=texture2D(lensColorSampler,vec2(length(vec2(0.5)-uv)/length(vec2(0.5))));
11021gl_FragColor=result;
11022}
11023#endif
11024#if defined(LENS_FLARE_COMPOSE)
11025uniform sampler2D otherSampler;
11026uniform sampler2D lensDirtSampler;
11027uniform sampler2D lensStarSampler;
11028uniform mat4 lensStarMatrix;
11029void main(void)
11030{
11031vec2 lensFlareCoords=(lensStarMatrix*vec4(vUV,1.0,1.0)).xy;
11032vec4 lensMod=texture2D(lensDirtSampler,vUV);
11033lensMod+=texture2D(lensStarSampler,vUV);
11034vec4 result=texture2D(textureSampler,vUV)*lensMod;
11035gl_FragColor=texture2D(otherSampler,vUV)+result;
11036}
11037#endif
11038#if defined(DEPTH_OF_FIELD)
11039uniform sampler2D otherSampler;
11040uniform sampler2D depthSampler;
11041uniform float distance;
11042void main(void)
11043{
11044vec4 sharp=texture2D(otherSampler,vUV);
11045vec4 blur=texture2D(textureSampler,vUV);
11046float dist=clamp(texture2D(depthSampler,vUV).r*distance,0.0,1.0);
11047float factor=0.0;
11048if (dist<0.05)
11049factor=1.0;
11050else if (dist<0.1)
11051factor=20.0*(0.1-dist);
11052else if (dist<0.5)
11053factor=0.0;
11054else
11055factor=2.0*(dist-0.5);
11056factor=clamp(factor,0.0,0.90);
11057gl_FragColor=mix(sharp,blur,factor);
11058}
11059#endif
11060#if defined(MOTION_BLUR)
11061uniform mat4 inverseViewProjection;
11062uniform mat4 prevViewProjection;
11063uniform vec2 screenSize;
11064uniform float motionScale;
11065uniform float motionStrength;
11066uniform sampler2D depthSampler;
11067void main(void)
11068{
11069vec2 texelSize=1.0/screenSize;
11070float depth=texture2D(depthSampler,vUV).r;
11071vec4 cpos=vec4(vUV*2.0-1.0,depth,1.0);
11072cpos=cpos*inverseViewProjection;
11073vec4 ppos=cpos*prevViewProjection;
11074ppos.xyz/=ppos.w;
11075ppos.xy=ppos.xy*0.5+0.5;
11076vec2 velocity=(ppos.xy-vUV)*motionScale*motionStrength;
11077float speed=length(velocity/texelSize);
11078int nSamples=int(clamp(speed,1.0,MAX_MOTION_SAMPLES));
11079vec4 result=texture2D(textureSampler,vUV);
11080for (int i=1; i<int(MAX_MOTION_SAMPLES); ++i) {
11081if (i>=nSamples)
11082break;
11083vec2 offset1=vUV+velocity*(float(i)/float(nSamples-1)-0.5);
11084result+=texture2D(textureSampler,offset1);
11085}
11086gl_FragColor=result/float(nSamples);
11087}
11088#endif
11089`;je.a.ShadersStore.standardPixelShader=Yg;var Jd=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?h.a.TEXTURETYPE_FLOAT:h.a.TEXTURETYPE_HALF_FLOAT,n.postProcessRenderPipelineManager.addPipeline(s),s._buildPipeline(),s}return Object(c.d)(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(`
11090`))}},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())}
11090,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 l.a.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
11091#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
11092#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 Kc("HDRPass",i,n,null,we.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,this._floatTextureType),this.screenSpaceReflectionPostProcess.onApplyObservable.add(function(){e._currentDepthOfFieldSource=e.screenSpaceReflectionPostProcess}),this.addEffect(new Rt(i.getEngine(),"HDRScreenSpaceReflections",function(){return e.screenSpaceReflectionPostProcess},!0))),this._basePostProcess?this.originalPostProcess=this._basePostProcess:this.originalPostProcess=new _t("HDRPass","standard",[],[],n,null,we.a.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 Rt(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("HDRDepthOfFieldSource","standard",[],[],n,null,we.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",h.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new Rt(i.getEngine(),"HDRBaseDepthOfFieldSource",function(){return e.textureAdderFinalPostProcess}
11092,!0))),this._vlsEnabled&&(this._createVolumetricLightPostProcess(i,n),this.volumetricLightFinalPostProcess=new _t("HDRVLSFinal","standard",[],[],n,null,we.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",h.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new Rt(i.getEngine(),"HDRVLSFinal",function(){return e.volumetricLightFinalPostProcess},!0))),this._lensFlareEnabled&&(this._createLensFlarePostProcess(i,n),this.lensFlareFinalPostProcess=new _t("HDRPostLensFlareDepthOfFieldSource","standard",[],[],n,null,we.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",h.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new Rt(i.getEngine(),"HDRPostLensFlareDepthOfFieldSource",function(){return e.lensFlareFinalPostProcess},!0))),this._hdrEnabled&&(this._createLuminancePostProcesses(i,this._floatTextureType),this._createHdrPostProcess(i,n),this.hdrFinalPostProcess=new _t("HDRPostHDReDepthOfFieldSource","standard",[],[],n,null,we.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",h.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new Rt(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 Ro("fxaa",1,null,we.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,h.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new Rt(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&&l.a.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("HDRDownSampleX4","standard",["dsOffsets"],[],n,null,we.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define DOWN_SAMPLE_X4",this._floatTextureType),this.downSampleX4PostProcess.onApply=function(a){for(var s=0,d=i.downSampleX4PostProcess.width,p=i.downSampleX4PostProcess.height,y=-2;y<2;y++)for(var P=-2;P<2;P++)o[s]=(y+.5)*(1/d),o[s+1]=(P+.5)*(1/p),s+=2;a.setArray2("dsOffsets",o)},this.addEffect(new Rt(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("HDRBrightPass","standard",["dsOffsets","brightThreshold"],[],n,null,we.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define BRIGHT_PASS",this._floatTextureType),this.brightPassPostProcess.onApply=function(a){var s=1/i.brightPassPostProcess.width,d=1/i.brightPassPostProcess.height;o[0]=-.5*s,o[1]=.5*d,o[2]=.5*s,o[3]=.5*d,o[4]=-.5*s,o[5]=-.5*d,o[6]=.5*s,o[7]=-.5*d,a.setArray2("dsOffsets",o),a.setFloat("brightThreshold",i.brightThreshold)},this.addEffect(new Rt(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(),d=new _n("HDRBlurH_"+i,new u.d(1,0),this[o],n,null,we.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,this._floatTextureType),p=new _n("HDRBlurV_"+i,new u.d(0,1),this[o],n,null,we.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,this._floatTextureType);d.onActivateObservable.add(function(){var y=d.width/s.getRenderWidth();d.kernel=a[o]*y}),p.onActivateObservable.add(function(){var y=p.height/s.getRenderHeight();p.kernel=a.horizontalBlur?64*y:a[o]*y}),this.addEffect(new Rt(e.getEngine(),"HDRBlurH"+i,function(){return d},!0)),this.addEffect(new Rt(e.getEngine(),"HDRBlurV"+i,function(){return p},!0)),this.blurHPostProcesses.push(d),this.blurVPostProcesses.push(p)},t.prototype._createTextureAdderPostProcess=function(e,n){var i=this;this.textureAdderPostProcess=new _t("HDRTextureAdder","standard",["exposure"],["otherSampler","lensSampler"],n,null,we.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define TEXTURE_ADDER",this._floatTextureType),this.textureAdderPostProcess.onApply=function(o){o.setTextureFromPostProcess("otherSampler",i._vlsEnabled?
11092i._currentDepthOfFieldSource:i.originalPostProcess),o.setTexture("lensSampler",i.lensTexture),o.setFloat("exposure",i._currentExposure),i._currentDepthOfFieldSource=i.textureAdderFinalPostProcess},this.addEffect(new Rt(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("HDRVLS","standard",["shadowViewProjection","cameraPosition","sunDirection","sunColor","scatteringCoefficient","scatteringPower","depthValues"],["shadowMapSampler","positionSampler"],n/8,null,we.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,`#define VLS
11093#define NB_STEPS `+this._volumetricLightStepsCount.toFixed(1));var s=u.d.Zero();this.volumetricLightPostProcess.onApply=function(d){if(i.sourceLight&&i.sourceLight.getShadowGenerator()&&i._scene.activeCamera){var p=i.sourceLight.getShadowGenerator();d.setTexture("shadowMapSampler",p.getShadowMap()),d.setTexture("positionSampler",a.textures[2]),d.setColor3("sunColor",i.sourceLight.diffuse),d.setVector3("sunDirection",i.sourceLight.getShadowDirection()),d.setVector3("cameraPosition",i._scene.activeCamera.globalPosition),d.setMatrix("shadowViewProjection",p.getTransformMatrix()),d.setFloat("scatteringCoefficient",i.volumetricLightCoefficient),d.setFloat("scatteringPower",i.volumetricLightPower),s.x=i.sourceLight.getDepthMinZ(i._scene.activeCamera),s.y=i.sourceLight.getDepthMaxZ(i._scene.activeCamera),d.setVector2("depthValues",s)}},this.addEffect(new Rt(e.getEngine(),"HDRVLS",function(){return i.volumetricLightPostProcess},!0)),this._createBlurPostProcesses(e,n/4,0,"volumetricLightBlurScale"),this.volumetricLightMergePostProces=new _t("HDRVLSMerge","standard",[],["originalSampler"],n,null,we.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define VLSMERGE"),this.volumetricLightMergePostProces.onApply=function(d){d.setTextureFromPostProcess("originalSampler",i._bloomEnabled?i.textureAdderFinalPostProcess:i.originalPostProcess),i._currentDepthOfFieldSource=i.volumetricLightFinalPostProcess},this.addEffect(new Rt(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("HDRLuminance","standard",["lumOffsets"],[],{width:o,height:o},null,we.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LUMINANCE",n);var a=[];this.luminancePostProcess.onApply=function(P){var O=1/i.luminancePostProcess.width,U=1/i.luminancePostProcess.height;a[0]=-.5*O,a[1]=.5*U,a[2]=.5*O,a[3]=.5*U,a[4]=-.5*O,a[5]=-.5*U,a[6]=.5*O,a[7]=-.5*U,P.setArray2("lumOffsets",a)},this.addEffect(new Rt(e.getEngine(),"HDRLuminance",function(){return i.luminancePostProcess},!0));for(var s=t.LuminanceSteps-1;s>=0;s--){o=Math.pow(3,s);var d=`#define LUMINANCE_DOWN_SAMPLE
11094`;s===0&&(d+="#define FINAL_DOWN_SAMPLER");var p=new _t("HDRLuminanceDownSample"+s,"standard",["dsOffsets","halfDestPixelSize"],[],{width:o,height:o},null,we.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,d,n);this.luminanceDownSamplePostProcesses.push(p)}var y=this.luminancePostProcess;this.luminanceDownSamplePostProcesses.forEach(function(P,O){var U=new Array(18);P.onApply=function(F){if(y){for(var z=0,J=-1;J<2;J++)for(var ie=-1;ie<2;ie++)U[z]=J/y.width,U[z+1]=ie/y.height,z+=2;F.setArray2("dsOffsets",U),F.setFloat("halfDestPixelSize",.5/y.width),y=O===i.luminanceDownSamplePostProcesses.length-1?i.luminancePostProcess:P}},O===i.luminanceDownSamplePostProcesses.length-1&&(P.onAfterRender=function(){var F=e.getEngine().readPixels(0,0,1,1),z=new u.f(1/16581375,1/65025,1/255,1);i._hdrCurrentLuminance=(F[0]*z.x+F[1]*z.y+F[2]*z.z+F[3]*z.w)/100}),i.addEffect(new Rt(e.getEngine(),"HDRLuminanceDownSample"+O,function(){return P},!0))})},t.prototype._createHdrPostProcess=function(e,n){var i=this,o=["#define HDR"];this._hdrAutoExposure&&o.push("#define AUTO_EXPOSURE"),this.hdrPostProcess=new _t("HDR","standard",["averageLuminance"],["textureAdderSampler"],n,null,we.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,o.join(`
11095`),h.a.TEXTURETYPE_UNSIGNED_INT);var a=1,s=0,d=0;this.hdrPostProcess.onApply=function(p){if(p.setTextureFromPostProcess("textureAdderSampler",i._currentDepthOfFieldSource),s+=e.getEngine().getDeltaTime(),a<0)a=i._hdrCurrentLuminance;else{var y=(d-s)/1e3;i._hdrCurrentLuminance<a+i.hdrDecreaseRate*y?a+=i.hdrDecreaseRate*y:i._hdrCurrentLuminance>a-i.hdrIncreaseRate*y?a-=i.hdrIncreaseRate*y:a=i._hdrCurrentLuminance}i.hdrAutoExposure?i._currentExposure=i._fixedExposure/a:(a=$.a.Clamp(a,i.hdrMinimumLuminance,1e20),p.setFloat("averageLuminance",a)),d=s,i._currentDepthOfFieldSource=i.hdrFinalPostProcess},this.addEffect(new Rt(e.getEngine(),"HDR",function(){return i.hdrPostProcess},!0))},t.prototype._createLensFlarePostProcess=function(e,n){var i=this;this.lensFlarePostProcess=new _t("HDRLensFlare","standard",["strength","ghostDispersal","haloWidth","resolution","distortionStrength"],["lensColorSampler"],n/2,null,we.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LENS_FLARE",h.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new Rt(e.getEngine(),"HDRLensFlare",function(){return i.lensFlarePostProcess},!0)),this._createBlurPostProcesses(e,n/4,2,"lensFlareBlurWidth"),this.lensFlareComposePostProcess=new _t("HDRLensFlareCompose","standard",["lensStarMatrix"],["otherSampler","lensDirtSampler","lensStarSampler"],n,null,we.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LENS_FLARE_COMPOSE",h.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new Rt(e.getEngine(),"HDRLensFlareCompose",function(){return i.lensFlareComposePostProcess},!0));var o=new u.d(0,0);this.lensFlarePostProcess.onApply=function(d){d.setTextureFromPostProcess("textureSampler",i._bloomEnabled?i.blurHPostProcesses[
110950]:i.originalPostProcess),d.setTexture("lensColorSampler",i.lensColorTexture),d.setFloat("strength",i.lensFlareStrength),d.setFloat("ghostDispersal",i.lensFlareGhostDispersal),d.setFloat("haloWidth",i.lensFlareHaloWidth),o.x=i.lensFlarePostProcess.width,o.y=i.lensFlarePostProcess.height,d.setVector2("resolution",o),d.setFloat("distortionStrength",i.lensFlareDistortionStrength)};var a=u.a.FromValues(2,0,-1,0,0,2,-1,0,0,0,1,0,0,0,0,1),s=u.a.FromValues(.5,0,.5,0,0,.5,.5,0,0,0,1,0,0,0,0,1);this.lensFlareComposePostProcess.onApply=function(d){if(i._scene.activeCamera){d.setTextureFromPostProcess("otherSampler",i.lensFlarePostProcess),d.setTexture("lensDirtSampler",i.lensFlareDirtTexture),d.setTexture("lensStarSampler",i.lensStarTexture);var p=i._scene.activeCamera.getViewMatrix().getRow(0),y=i._scene.activeCamera.getViewMatrix().getRow(2),P=u.e.Dot(p.toVector3(),new u.e(1,0,0))+u.e.Dot(y.toVector3(),new u.e(0,0,1));P*=4;var O=u.a.FromValues(.5*Math.cos(P),-Math.sin(P),0,0,Math.sin(P),.5*Math.cos(P),0,0,0,0,1,0,0,0,0,1),U=s.multiply(O).multiply(a);d.setMatrix("lensStarMatrix",U),i._currentDepthOfFieldSource=i.lensFlareFinalPostProcess}}},t.prototype._createDepthOfFieldPostProcess=function(e,n){var i=this;this.depthOfFieldPostProcess=new _t("HDRDepthOfField","standard",["distance"],["otherSampler","depthSampler"],n,null,we.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define DEPTH_OF_FIELD",h.a.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 Rt(e.getEngine(),"HDRDepthOfField",function(){return i.depthOfFieldPostProcess},!0))},t.prototype._createMotionBlurPostProcess=function(e,n){var i=this;if(this._isObjectBasedMotionBlur){var o=new Xc("HDRMotionBlur",e,n,null,we.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,h.a.TEXTURETYPE_UNSIGNED_INT);o.motionStrength=this.motionStrength,o.motionBlurSamples=this.motionBlurSamples,this.motionBlurPostProcess=o}else{this.motionBlurPostProcess=new _t("HDRMotionBlur","standard",["inverseViewProjection","prevViewProjection","screenSize","motionScale","motionStrength"],["depthSampler"],n,null,we.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,`#define MOTION_BLUR
11096#define MAX_MOTION_SAMPLES `+this.motionBlurSamples.toFixed(1),h.a.TEXTURETYPE_UNSIGNED_INT);var a=0,s=u.a.Identity(),d=u.a.Identity(),p=u.a.Identity(),y=u.d.Zero();this.motionBlurPostProcess.onApply=function(P){(p=e.getProjectionMatrix().multiply(e.getViewMatrix())).invertToRef(d),P.setMatrix("inverseViewProjection",d),P.setMatrix("prevViewProjection",s),s=p,y.x=i.motionBlurPostProcess.width,y.y=i.motionBlurPostProcess.height,P.setVector2("screenSize",y),a=e.getEngine().getFps()/60,P.setFloat("motionScale",a),P.setFloat("motionStrength",i.motionStrength),P.setTexture("depthSampler",i._getDepthTexture())}}this.addEffect(new Rt(e.getEngine(),"HDRMotionBlur",function(){return i.motionBlurPostProcess},!0))},t.prototype._getDepthTexture=function(){return this._scene.getEngine().getCaps().drawBuffersExtension?this._scene.enableGeometryBufferRenderer().getGBuffer().textures[0]:this._scene.enableDepthRenderer().getDepthMap()},t.prototype._disposePostProcesses=function(){for(var e=0;e<this._cameras.length;e++){var n=this._cameras[e];this.originalPostProcess&&this.originalPostProcess.dispose(n),this.screenSpaceReflectionPostProcess&&this.screenSpaceReflectionPostProcess.dispose(n),this.downSampleX4PostProcess&&this.downSampleX4PostProcess.dispose(n),this.brightPassPostProcess&&this.brightPassPostProcess.dispose(n),this.textureAdderPostProcess&&this.textureAdderPostProcess.dispose(n),this.volumetricLightPostProcess&&this.volumetricLightPostProcess.dispose(n),this.volumetricLightSmoothXPostProcess&&this.volumetricLightSmoothXPostProcess.dispose(n),this.volumetricLightSmoothYPostProcess&&this.volumetricLightSmoothYPostProcess.dispose(n),this.volumetricLightMergePostProces&&this.volumetricLightMergePostProces.dispose(n),this.volumetricLightFinalPostProcess&&this.volumetricLightFinalPostProcess.dispose(n),this.lensFlarePostProcess&&this.lensFlarePostProcess.dispose(n),this.lensFlareComposePostProcess&&this.lensFlareComposePostProcess.dispose(n);for(var i=0;i<this.luminanceDownSamplePostProcesses.length;i++)this.luminanceDownSamplePostProcesses[i].dispose(n);for(this.luminancePostProcess&&this.luminancePostProcess.dispose(n),this.hdrPostProcess&&this.hdrPostProcess.dispose(n),this.hdrFinalPostProcess&&this.hdrFinalPostProcess.dispose(n),this.depthOfFieldPostProcess&&this.depthOfFieldPostProcess.dispose(n),this.motionBlurPostProcess&&this.motionBlurPostProcess.dispose(n),this.fxaaPostProcess&&this.fxaaPostProcess.dispose(n),i=0;i<this.blurHPostProcesses.length;i++)this.blurHPostProcesses[i].dispose(n);for(i=0;i<this.blurVPostProcesses.length;i++)this.blurVPostProcesses[i].dispose(n)}this.originalPostProcess=null,this.downSampleX4PostProcess=null,this.brightPassPostProcess=null,this.textureAdderPostProcess=null,this.textureAdderFinalPostProcess=null,this.volumetricLightPostProcess=null,this.volumetricLightSmoothXPostProcess=null,this.volumetricLightSmoothYPostProcess=null,this.volumetricLightMergePostProces=null,this.volumetricLightFinalPostProcess=null,this.lensFlarePostProcess=null,this.lensFlareComposePostProcess=null,this.luminancePostProcess=null,this.hdrPostProcess=null,this.hdrFinalPostProcess=null,this.depthOfFieldPostProcess=null,this.motionBlurPostProcess=null,this.fxaaPostProcess=null,this.screenSpaceReflectionPostProcess=null,this.luminanceDownSamplePostProcesses=[],this.blurHPostProcesses=[],this.blurVPostProcesses=[]},t.prototype.dispose=function(){this._disposePostProcesses(),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),r.prototype.dispose.call(this)},t.prototype.serialize=function(){var e=L.a.Serialize(this);return this.sourceLight&&(e.sourceLightId=this.sourceLight.id),this.screenSpaceReflectionPostProcess&&(e.screenSpaceReflectionPostProcess=L.a.Serialize(this.screenSpaceReflectionPostProcess)),e.customType="StandardRenderingPipeline",e},t.Parse=function(e,n,i){var o=L.a.Parse(function(){return new t(e._name,n,e._ratio)},e,n,i);
11096return e.sourceLightId&&(o.sourceLight=n.getLightByID(e.sourceLightId)),e.screenSpaceReflectionPostProcess&&L.a.Parse(function(){return o.screenSpaceReflectionPostProcess},e.screenSpaceReflectionPostProcess,n,i),o},t.LuminanceSteps=6,Object(c.c)([Object(L.c)()],t.prototype,"brightThreshold",void 0),Object(c.c)([Object(L.c)()],t.prototype,"blurWidth",void 0),Object(c.c)([Object(L.c)()],t.prototype,"horizontalBlur",void 0),Object(c.c)([Object(L.c)()],t.prototype,"exposure",null),Object(c.c)([Object(L.m)("lensTexture")],t.prototype,"lensTexture",void 0),Object(c.c)([Object(L.c)()],t.prototype,"volumetricLightCoefficient",void 0),Object(c.c)([Object(L.c)()],t.prototype,"volumetricLightPower",void 0),Object(c.c)([Object(L.c)()],t.prototype,"volumetricLightBlurScale",void 0),Object(c.c)([Object(L.c)()],t.prototype,"hdrMinimumLuminance",void 0),Object(c.c)([Object(L.c)()],t.prototype,"hdrDecreaseRate",void 0),Object(c.c)([Object(L.c)()],t.prototype,"hdrIncreaseRate",void 0),Object(c.c)([Object(L.c)()],t.prototype,"hdrAutoExposure",null),Object(c.c)([Object(L.m)("lensColorTexture")],t.prototype,"lensColorTexture",void 0),Object(c.c)([Object(L.c)()],t.prototype,"lensFlareStrength",void 0),Object(c.c)([Object(L.c)()],t.prototype,"lensFlareGhostDispersal",void 0),Object(c.c)([Object(L.c)()],t.prototype,"lensFlareHaloWidth",void 0),Object(c.c)([Object(L.c)()],t.prototype,"lensFlareDistortionStrength",void 0),Object(c.c)([Object(L.c)()],t.prototype,"lensFlareBlurWidth",void 0),Object(c.c)([Object(L.m)("lensStarTexture")],t.prototype,"lensStarTexture",void 0),Object(c.c)([Object(L.m)("lensFlareDirtTexture")],t.prototype,"lensFlareDirtTexture",void 0),Object(c.c)([Object(L.c)()],t.prototype,"depthOfFieldDistance",void 0),Object(c.c)([Object(L.c)()],t.prototype,"depthOfFieldBlurWidth",void 0),Object(c.c)([Object(L.c)()],t.prototype,"motionStrength",null),Object(c.c)([Object(L.c)()],t.prototype,"objectBasedMotionBlur",null),Object(c.c)([Object(L.c)()],t.prototype,"_ratio",void 0),Object(c.c)([Object(L.c)()],t.prototype,"BloomEnabled",null),Object(c.c)([Object(L.c)()],t.prototype,"DepthOfFieldEnabled",null),Object(c.c)([Object(L.c)()],t.prototype,"LensFlareEnabled",null),Object(c.c)([Object(L.c)()],t.prototype,"HDREnabled",null),Object(c.c)([Object(L.c)()],t.prototype,"VLSEnabled",null),Object(c.c)([Object(L.c)()],t.prototype,"MotionBlurEnabled",null),Object(c.c)([Object(L.c)()],t.prototype,"fxaaEnabled",null),Object(c.c)([Object(L.c)()],t.prototype,"screenSpaceReflectionsEnabled",null),Object(c.c)([Object(L.c)()],t.prototype,"volumetricLightStepsCount",null),Object(c.c)([Object(L.c)()],t.prototype,"motionBlurSamples",null),Object(c.c)([Object(L.c)()],t.prototype,"samples",null),t}(Ur);R.a.RegisteredTypes["BABYLON.StandardRenderingPipeline"]=Jd;var Kg=`const vec3 TWO=vec3(2.0,2.0,2.0);
11097varying vec2 vUV;
11098uniform sampler2D camASampler;
11099uniform sampler2D textureSampler;
11100uniform vec2 stepSize;
11101void main(void)
11102{
11103bool useCamA;
11104bool useCamB;
11105vec2 texCoord1;
11106vec2 texCoord2;
11107vec3 frag1;
11108vec3 frag2;
11109#ifdef IS_STEREOSCOPIC_HORIZ
11110useCamB=vUV.x>0.5;
11111useCamA=!useCamB;
11112texCoord1=vec2(useCamB ? (vUV.x-0.5)*2.0 : vUV.x*2.0,vUV.y);
11113texCoord2=vec2(texCoord1.x+stepSize.x,vUV.y);
11114#else
11115#ifdef IS_STEREOSCOPIC_INTERLACED
11116float rowNum=floor(vUV.y/stepSize.y);
11117useCamA=mod(rowNum,2.0) == 1.0;
11118useCamB=mod(rowNum,2.0) == 0.0;
11119texCoord1=vec2(vUV.x,vUV.y);
11120texCoord2=vec2(vUV.x,vUV.y);
11121#else
11122useCamB=vUV.y>0.5;
11123useCamA=!useCamB;
11124texCoord1=vec2(vUV.x,useCamB ? (vUV.y-0.5)*2.0 : vUV.y*2.0);
11125texCoord2=vec2(vUV.x,texCoord1.y+stepSize.y);
11126#endif
11127#endif
11128
11129if (useCamB){
11130frag1=texture2D(textureSampler,texCoord1).rgb;
11131frag2=texture2D(textureSampler,texCoord2).rgb;
11132}else if (useCamA){
11133frag1=texture2D(camASampler ,texCoord1).rgb;
11134frag2=texture2D(camASampler ,texCoord2).rgb;
11135}else {
11136discard;
11137}
11138gl_FragColor=vec4((frag1+frag2)/TWO,1.0);
11139}
11140`;je.a.ShadersStore.stereoscopicInterlacePixelShader=Kg;var Qg=function(r){function t(e,n,i,o,a,s,d){var p=r.call(this,e,"stereoscopicInterlace",["stepSize"],["camASampler"],1,n[1],a,s,d,o?"#define IS_STEREOSCOPIC_INTERLACED 1":i?"#define IS_STEREOSCOPIC_HORIZ 1":void 0)||this;return p._passedProcess=n[0]._rigPostProcess,p._stepSize=new u.d(1/p.width,1/p.height),p.onSizeChangedObservable.add(function(){p._stepSize=new u.d(1/p.width,1/p.height)}),p.onApplyObservable.add(function(y){y.setTextureFromPostProcess("camASampler",p._passedProcess),y.setFloat2("stepSize",p._stepSize.x,p._stepSize.y)}),p}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"StereoscopicInterlacePostProcessI"},t}(_t),qg=function(r){function t(e,n,i,o,a,s){var d=r.call(this,e,"stereoscopicInterlace",["stepSize"],["camASampler"],1,n[1],o,a,s,i?"#define IS_STEREOSCOPIC_HORIZ 1":void 0)||this;return d._passedProcess=n[0]._rigPostProcess,d._stepSize=new u.d(1/d.width,1/d.height),d.onSizeChangedObservable.add(function(){d._stepSize=new u.d(1/d.width,1/d.height)}),d.onApplyObservable.add(function(p){p.setTextureFromPostProcess("camASampler",d._passedProcess),p.setFloat2("stepSize",d._stepSize.x,d._stepSize.y)}),d}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"StereoscopicInterlacePostProcess"},t}(_t),Zg=`
11141varying vec2 vUV;
11142uniform sampler2D textureSampler;
11143
11144uniform float _ExposureAdjustment;
11145#if defined(HABLE_TONEMAPPING)
11146const float A=0.15;
11147const float B=0.50;
11148const float C=0.10;
11149const float D=0.20;
11150const float E=0.02;
11151const float F=0.30;
11152const float W=11.2;
11153#endif
11154float Luminance(vec3 c)
11155{
11156return dot(c,vec3(0.22,0.707,0.071));
11157}
11158void main(void)
11159{
11160vec3 colour=texture2D(textureSampler,vUV).rgb;
11161#if defined(REINHARD_TONEMAPPING)
11162float lum=Luminance(colour.rgb);
11163float lumTm=lum*_ExposureAdjustment;
11164float scale=lumTm/(1.0+lumTm);
11165colour*=scale/lum;
11166#elif defined(HABLE_TONEMAPPING)
11167colour*=_ExposureAdjustment;
11168const float ExposureBias=2.0;
11169vec3 x=ExposureBias*colour;
11170vec3 curr=((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;
11171x=vec3(W,W,W);
11172vec3 whiteScale=1.0/(((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F);
11173colour=curr*whiteScale;
11174#elif defined(OPTIMIZED_HEJIDAWSON_TONEMAPPING)
11175colour*=_ExposureAdjustment;
11176vec3 X=max(vec3(0.0,0.0,0.0),colour-0.004);
11177vec3 retColor=(X*(6.2*X+0.5))/(X*(6.2*X+1.7)+0.06);
11178colour=retColor*retColor;
11179#elif defined(PHOTOGRAPHIC_TONEMAPPING)
11180colour=vec3(1.0,1.0,1.0)-exp2(-_ExposureAdjustment*colour);
11181#endif
11182gl_FragColor=vec4(colour.rgb,1.0);
11183}`;je.a.ShadersStore.tonemapPixelShader=Zg;var sr;(function(r){r[r.Hable=0]="Hable",r[r.Reinhard=1]="Reinhard",r[r.HejiDawson=2]="HejiDawson",r[r.Photographic=3]="Photographic"})(sr||(sr={}));var Jg=function(r){function t(e,n,i,o,a,s,d){a===void 0&&(a=h.a.TEXTURE_BILINEAR_SAMPLINGMODE),d===void 0&&(d=h.a.TEXTURETYPE_UNSIGNED_INT);var p=r.call(this,e,"tonemap",["_ExposureAdjustment"],null,1,o,a,s,!0,null,d)||this;p._operator=n,p.exposureAdjustment=i;var y="#define ";return p._operator===sr.Hable?y+="HABLE_TONEMAPPING":p._operator===sr.Reinhard?y+="REINHARD_TONEMAPPING":p._operator===sr.HejiDawson?y+="OPTIMIZED_HEJIDAWSON_TONEMAPPING":p._operator===sr.Photographic&&(y+="PHOTOGRAPHIC_TONEMAPPING"),p.updateEffect(y),p.onApply=function(P){P.setFloat("_ExposureAdjustment",p.exposureAdjustment)},p}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"TonemapPostProcess"},t}(_t),$g=`uniform sampler2D textureSampler;
11184uniform sampler2D lightScatteringSampler;
11185uniform float decay;
11186uniform float exposure;
11187uniform float weight;
11188uniform float density;
11189uniform vec2 meshPositionOnScreen;
11190varying vec2 vUV;
11191void main(void) {
11192vec2 tc=vUV;
11193vec2 deltaTexCoord=(tc-meshPositionOnScreen.xy);
11194deltaTexCoord*=1.0/float(NUM_SAMPLES)*density;
11195float illuminationDecay=1.0;
11196vec4 color=texture2D(lightScatteringSampler,tc)*0.4;
11197for(int i=0; i<NUM_SAMPLES; i++) {
11198tc-=deltaTexCoord;
11199vec4 dataSample=texture2D(lightScatteringSampler,tc)*0.4;
11200dataSample*=illuminationDecay*weight;
11201color+=dataSample;
11202illuminationDecay*=decay;
11203}
11204vec4 realColor=texture2D(textureSampler,vUV);
11205gl_FragColor=((vec4((vec3(color.r,color.g,color.b)*exposure),1))+(realColor*(1.5-0.4)));
11206}
11207`;je.a.ShadersStore.volumetricLightScatteringPixelShader=$g;var ev=`
11208attribute vec3 position;
11209#include<bonesDeclaration>
11210#include<morphTargetsVertexGlobalDeclaration>
11211#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
11212
11213#include<instancesDeclaration>
11214uniform mat4 viewProjection;
11215uniform vec2 depthValues;
11216#if defined(ALPHATEST) || defined(NEED_UV)
11217varying vec2 vUV;
11218uniform mat4 diffuseMatrix;
11219#ifdef UV1
11220attribute vec2 uv;
11221#endif
11222#ifdef UV2
11223attribute vec2 uv2;
11224#endif
11225#endif
11226void main(void)
11227{
11228vec3 positionUpdated=position;
11229#if (defined(ALPHATEST) || defined(NEED_UV)) && defined(UV1)
11230vec2 uvUpdated=uv;
11231#endif
11232#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
11233#include<instancesVertex>
11234#include<bonesVertex>
11235gl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);
11236#if defined(ALPHATEST) || defined(BASIC_RENDER)
11237#ifdef UV1
11238vUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));
11239#endif
11240#ifdef UV2
11241vUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
11242#endif
11243#endif
11244}
11245`;je.a.ShadersStore.volumetricLightScatteringPassVertexShader=ev;var tv=`#if defined(ALPHATEST) || defined(NEED_UV)
11246varying vec2 vUV;
11247#endif
11248#if defined(ALPHATEST)
11249uniform sampler2D diffuseSampler;
11250#endif
11251void main(void)
11252{
11253#if defined(ALPHATEST)
11254vec4 diffuseColor=texture2D(diffuseSampler,vUV);
11255if (diffuseColor.a<0.4)
11256discard;
11257#endif
11258gl_FragColor=vec4(0.0,0.0,0.0,1.0);
11259}
11260`;je.a.ShadersStore.volumetricLightScatteringPassPixelShader=tv;var $d=function(r){function t(e,n,i,o,a,s,d,p,y){a===void 0&&(a=100),s===void 0&&(s=we.a.BILINEAR_SAMPLINGMODE);var P=r.call(this,e,"volumetricLightScattering",["decay","exposure","weight","meshPositionOnScreen","density"],["lightScatteringSampler"],n.postProcessRatio||n,i,s,d,p,"#define NUM_SAMPLES "+a)||this;return P._screenCoordinates=u.d.Zero(),P.customMeshPosition=u.e.Zero(),P.useCustomMeshPosition=!1,P.invert=!0,P.excludedMeshes=new Array,P.exposure=.3,P.decay=.96815,P.weight=.58767,P.density=.926,d=(y=i===null?y:i.getScene()).getEngine(),P._viewPort=new Wn.a(0,0,1,1).toGlobal(d.getRenderWidth(),d.getRenderHeight()),P.mesh=o!==null?o:t.CreateDefaultMesh("VolumetricLightScatteringMesh",y),P._createPass(y,n.passRatio||n),P.onActivate=function(O){P.isSupported||P.dispose(O),P.onActivate=null},P.onApplyObservable.add(function(O){P._updateMeshScreenCoordinates(y),O.setTexture("lightScatteringSampler",P._volumetricLightScatteringRTT),O.setFloat("exposure",P.exposure),O.setFloat("decay",P.decay),O.setFloat("weight",P.weight),O.setFloat("density",P.density),O.setVector2("meshPositionOnScreen",P._screenCoordinates)}),P}return Object(c.d)(t,r),Object.defineProperty(t.prototype,"useDiffuseColor",{get:function(){return l.a.Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead"),!1},set:function(e){l.a.Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead")}
11260,enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"VolumetricLightScatteringPostProcess"},t.prototype._isReady=function(e,n){var i=e.getMesh();if(i===this.mesh&&i.material)return i.material.isReady(i);var o=[],a=[Me.b.PositionKind],s=e.getMaterial();s&&(s.needAlphaTesting()&&o.push("#define ALPHATEST"),i.isVerticesDataPresent(Me.b.UVKind)&&(a.push(Me.b.UVKind),o.push("#define UV1")),i.isVerticesDataPresent(Me.b.UV2Kind)&&(a.push(Me.b.UV2Kind),o.push("#define UV2"))),i.useBones&&i.computeBonesUsingShaders?(a.push(Me.b.MatricesIndicesKind),a.push(Me.b.MatricesWeightsKind),o.push("#define NUM_BONE_INFLUENCERS "+i.numBoneInfluencers),o.push("#define BonesPerMesh "+(i.skeleton?i.skeleton.bones.length+1:0))):o.push("#define NUM_BONE_INFLUENCERS 0"),n&&(o.push("#define INSTANCES"),tt.a.PushAttributesForInstances(a),e.getRenderingMesh().hasThinInstances&&o.push("#define THIN_INSTANCES"));var d=o.join(`
11261`);return this._cachedDefines!==d&&(this._cachedDefines=d,this._volumetricLightScatteringPass=i.getScene().getEngine().createEffect("volumetricLightScatteringPass",a,["world","mBones","viewProjection","diffuseMatrix"],["diffuseSampler"],d,void 0,void 0,void 0,{maxSimultaneousMorphTargets:i.numBoneInfluencers})),this._volumetricLightScatteringPass.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.excludedMeshes.length>0&&this.excludedMeshes.indexOf(e)!==-1},t.prototype._createPass=function(e,n){var i=this,o=e.getEngine();this._volumetricLightScatteringRTT=new sn("volumetricLightScatteringMap",{width:o.getRenderWidth()*n,height:o.getRenderHeight()*n},e,!1,!0,h.a.TEXTURETYPE_UNSIGNED_INT),this._volumetricLightScatteringRTT.wrapU=we.a.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.wrapV=we.a.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,d=function(y){var P=y.getRenderingMesh(),O=y.getEffectiveMesh();if(!i._meshExcluded(P)){O._internalAbstractMeshDataInfo._isActiveIntermediate=!1;var U=y.getMaterial();if(U){var F=P.getScene(),z=F.getEngine();z.setState(U.backFaceCulling);var J=P._getInstancesRenderList(y._id,!!y.getReplacementMesh());if(!J.mustReturn){var ie=z.getCaps().instancedArrays&&(J.visibleInstances[y._id]!==null||P.hasThinInstances);if(i._isReady(y,ie)){var se=i._volumetricLightScatteringPass;if(P===i.mesh&&(se=y.effect?y.effect:U.getEffect()),z.enableEffect(se),P._bind(y,se,U.fillMode),P===i.mesh)U.bind(O.getWorldMatrix(),P);else{if(i._volumetricLightScatteringPass.setMatrix("viewProjection",F.getTransformMatrix()),U&&U.needAlphaTesting()){var ce=U.getAlphaTestTexture();i._volumetricLightScatteringPass.setTexture("diffuseSampler",ce),ce&&i._volumetricLightScatteringPass.setMatrix("diffuseMatrix",ce.getTextureMatrix())}P.useBones&&P.computeBonesUsingShaders&&P.skeleton&&i._volumetricLightScatteringPass.setMatrices("mBones",P.skeleton.getTransformMatrices(P))}P._processRendering(O,y,i._volumetricLightScatteringPass,Ht.a.TriangleFillMode,J,ie,function(ue,fe){return se.setMatrix("world",fe)})}}}}},p=new M.b(0,0,0,1);this._volumetricLightScatteringRTT.onBeforeRenderObservable.add(function(){s=e.clearColor,e.clearColor=p}),this._volumetricLightScatteringRTT.onAfterRenderObservable.add(function(){e.clearColor=s}),this._volumetricLightScatteringRTT.customRenderFunction=function(y,P,O,U){var F,z=e.getEngine();if(U.length){for(z.setColorWrite(!1),F=0;F<U.length;F++)d(U.data[F]);z.setColorWrite(!0)}for(F=0;F<y.length;F++)d(y.data[F]);for(F=0;F<P.length;F++)d(P.data[F]);if(O.length){for(F=0;F<O.length;F++){var J=O.data[F],ie=J.getBoundingInfo();ie&&e.activeCamera&&(J._alphaIndex=J.getMesh().alphaIndex,J._distanceToCamera=ie.boundingSphere.centerWorld.subtract(e.activeCamera.position).length())}var se=O.data.slice(0,O.length);for(se.sort(function(ce,ue){return ce._alphaIndex>
11261ue._alphaIndex?1:ce._alphaIndex<ue._alphaIndex?-1:ce._distanceToCamera<ue._distanceToCamera?1:ce._distanceToCamera>ue._distanceToCamera?-1:0}),z.setAlphaMode(h.a.ALPHA_COMBINE),F=0;F<se.length;F++)d(se[F]);z.setAlphaMode(h.a.ALPHA_DISABLE)}}},t.prototype._updateMeshScreenCoordinates=function(e){var n,i=e.getTransformMatrix();n=this.useCustomMeshPosition?this.customMeshPosition:this.attachedNode?this.attachedNode.position:this.mesh.parent?this.mesh.getAbsolutePosition():this.mesh.position;var o=u.e.Project(n,u.a.Identity(),i,this._viewPort);this._screenCoordinates.x=o.x/this._viewPort.width,this._screenCoordinates.y=o.y/this._viewPort.height,this.invert&&(this._screenCoordinates.y=1-this._screenCoordinates.y)},t.CreateDefaultMesh=function(e,n){var i=De.a.CreatePlane(e,1,n);i.billboardMode=Dt.a.BILLBOARDMODE_ALL;var o=new Ft.a(e+"Material",n);return o.emissiveColor=new M.a(1,1,1),i.material=o,i},Object(c.c)([Object(L.o)()],t.prototype,"customMeshPosition",void 0),Object(c.c)([Object(L.c)()],t.prototype,"useCustomMeshPosition",void 0),Object(c.c)([Object(L.c)()],t.prototype,"invert",void 0),Object(c.c)([Object(L.k)()],t.prototype,"mesh",void 0),Object(c.c)([Object(L.c)()],t.prototype,"excludedMeshes",void 0),Object(c.c)([Object(L.c)()],t.prototype,"exposure",void 0),Object(c.c)([Object(L.c)()],t.prototype,"decay",void 0),Object(c.c)([Object(L.c)()],t.prototype,"weight",void 0),Object(c.c)([Object(L.c)()],t.prototype,"density",void 0),t}(_t);R.a.RegisteredTypes["BABYLON.VolumetricLightScatteringPostProcess"]=$d;var nv=`
11262
11263precision highp float;
11264
11265varying vec2 vUV;
11266uniform sampler2D textureSampler;
11267uniform sampler2D normalSampler;
11268uniform float curvature_ridge;
11269uniform float curvature_valley;
11270#ifndef CURVATURE_OFFSET
11271#define CURVATURE_OFFSET 1
11272#endif
11273float curvature_soft_clamp(float curvature,float control)
11274{
11275if (curvature<0.5/control)
11276return curvature*(1.0-curvature*control);
11277return 0.25/control;
11278}
11279float calculate_curvature(ivec2 texel,float ridge,float valley)
11280{
11281vec2 normal_up=texelFetchOffset(normalSampler,texel,0,ivec2(0,CURVATURE_OFFSET)).rb;
11282vec2 normal_down=texelFetchOffset(normalSampler,texel,0,ivec2(0,-CURVATURE_OFFSET)).rb;
11283vec2 normal_left=texelFetchOffset(normalSampler,texel,0,ivec2(-CURVATURE_OFFSET,0)).rb;
11284vec2 normal_right=texelFetchOffset(normalSampler,texel,0,ivec2( CURVATURE_OFFSET,0)).rb;
11285float normal_diff=((normal_up.g-normal_down.g)+(normal_right.r-normal_left.r));
11286if (normal_diff<0.0)
11287return -2.0*curvature_soft_clamp(-normal_diff,valley);
11288return 2.0*curvature_soft_clamp(normal_diff,ridge);
11289}
11290void main(void)
11291{
11292ivec2 texel=ivec2(gl_FragCoord.xy);
11293vec4 baseColor=texture2D(textureSampler,vUV);
11294float curvature=calculate_curvature(texel,curvature_ridge,curvature_valley);
11295baseColor.rgb*=curvature+1.0;
11296gl_FragColor=baseColor;
11297}`;je.a.ShadersStore.screenSpaceCurvaturePixelShader=nv;var ef=function(r){function t(e,n,i,o,a,s,d,p,y){p===void 0&&(p=h.a.TEXTURETYPE_UNSIGNED_INT),y===void 0&&(y=!1);var P=r.call(this,e,"screenSpaceCurvature",["curvature_ridge","curvature_valley"],["textureSampler","normalSampler"],i,o,a,s,d,void 0,p,void 0,null,y)||this;return P.ridge=1,P.valley=1,P._geometryBufferRenderer=n.enableGeometryBufferRenderer(),P._geometryBufferRenderer?P.onApply=function(O){O.setFloat("curvature_ridge",.5/Math.max(P.ridge*P.ridge,1e-4)),O.setFloat("curvature_valley",.7/Math.max(P.valley*P.valley,1e-4));var U=P._geometryBufferRenderer.getGBuffer().textures[1];O.setTexture("normalSampler",U)}:l.a.Error("Multiple Render Target support needed for screen space curvature post process. Please use IsSupported test first."),P}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"ScreenSpaceCurvaturePostProcess"},Object.defineProperty(t,"IsSupported",{get:function(){var e=te.a.LastCreatedEngine;return!!e&&(e.webGLVersion>1||e.getCaps().drawBuffersExtension)},enumerable:!1,configurable:!0}),t._Parse=function(e,n,i,o){return L.a.Parse(function(){return new t(e.name,i,e.options,n,e.renderTargetSamplingMode,i.getEngine(),e.textureType,e.reusable)},e,i,o)},Object(c.c)([Object(L.c)()],t.prototype,"ridge",void 0),Object(c.c)([Object(L.c)()],t.prototype,"valley",void 0),t}(_t);R.a.RegisteredTypes["BABYLON.ScreenSpaceCurvaturePostProcess"]=ef,f(166),f(167),Object.defineProperty(_e.a.prototype,"forceShowBoundingBoxes",{get:function(){return this._forceShowBoundingBoxes||!1},set:function(r){this._forceShowBoundingBoxes=r,r&&this.getBoundingBoxRenderer()},enumerable:!0,configurable:!0}),_e.a.prototype.getBoundingBoxRenderer=function(){return this._boundingBoxRenderer||(this._boundingBoxRenderer=new tf(this)),this._boundingBoxRenderer},Object.defineProperty(Dt.a.prototype,"showBoundingBox",{get:function(){return this._showBoundingBox||!1}
11297,set:function(r){this._showBoundingBox=r,r&&this.getScene().getBoundingBoxRenderer()},enumerable:!0,configurable:!0});var tf=function(){function r(t){this.name=st.a.NAME_BOUNDINGBOXRENDERER,this.frontColor=new M.a(1,1,1),this.backColor=new M.a(.1,.1,.1),this.showBackLines=!0,this.onBeforeBoxRenderingObservable=new x.c,this.onAfterBoxRenderingObservable=new x.c,this.onResourcesReadyObservable=new x.c,this.enabled=!0,this.renderList=new li.a(32),this._vertexBuffers={},this._fillIndexBuffer=null,this._fillIndexData=null,this.scene=t,t._addComponent(this)}return r.prototype.register=function(){this.scene._beforeEvaluateActiveMeshStage.registerStep(st.a.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER,this,this.reset),this.scene._preActiveMeshStage.registerStep(st.a.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER,this,this._preActiveMesh),this.scene._evaluateSubMeshStage.registerStep(st.a.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER,this,this._evaluateSubMesh),this.scene._afterRenderingGroupDrawStage.registerStep(st.a.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER,this,this.render)},r.prototype._evaluateSubMesh=function(t,e){if(t.showSubMeshesBoundingBox){var n=e.getBoundingInfo();n!=null&&(n.boundingBox._tag=t.renderingGroupId,this.renderList.push(n.boundingBox))}},r.prototype._preActiveMesh=function(t){if(t.showBoundingBox||this.scene.forceShowBoundingBoxes){var e=t.getBoundingInfo();e.boundingBox._tag=t.renderingGroupId,this.renderList.push(e.boundingBox)}},r.prototype._prepareResources=function(){if(!this._colorShader){this._colorShader=new fa.a("colorShader",this.scene,"color",{attributes:[Me.b.PositionKind],uniforms:["world","viewProjection","color"]}),this._colorShader.reservedDataStore={hidden:!0};var t=this.scene.getEngine(),e=ft.a.CreateBox({size:1});this._vertexBuffers[Me.b.PositionKind]=new Me.b(t,e.positions,Me.b.PositionKind,!1),this._createIndexBuffer(),this._fillIndexData=e.indices,this.onResourcesReadyObservable.notifyObservers(this)}},r.prototype._createIndexBuffer=function(){var t=this.scene.getEngine();this._indexBuffer=t.createIndexBuffer([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,7,1,6,2,5,3,4])},r.prototype.rebuild=function(){var t=this._vertexBuffers[Me.b.PositionKind];t&&t._rebuild(),this._createIndexBuffer()},r.prototype.reset=function(){this.renderList.reset()},r.prototype.render=function(t){if(this.renderList.length!==0&&this.enabled&&(this._prepareResources(),this._colorShader.isReady())){var e=this.scene.getEngine();e.setDepthWrite(!1),this._colorShader._preBind();for(var n=0;n<this.renderList.length;n++){var i=this.renderList.data[n];if(i._tag===t){this.onBeforeBoxRenderingObservable.notifyObservers(i);var o=i.minimum,a=i.maximum.subtract(o),s=o.add(a.scale(.5)),d=u.a.Scaling(a.x,a.y,a.z).multiply(u.a.Translation(s.x,s.y,s.z)).multiply(i.getWorldMatrix());e.bindBuffers(this._vertexBuffers,this._indexBuffer,this._colorShader.getEffect()),this.showBackLines&&(e.setDepthFunctionToGreaterOrEqual(),this.scene.resetCachedMaterial(),this._colorShader.setColor4("color",this.backColor.toColor4()
11297),this._colorShader.bind(d),e.drawElementsType(Ht.a.LineListDrawMode,0,24)),e.setDepthFunctionToLess(),this.scene.resetCachedMaterial(),this._colorShader.setColor4("color",this.frontColor.toColor4()),this._colorShader.bind(d),e.drawElementsType(Ht.a.LineListDrawMode,0,24),this.onAfterBoxRenderingObservable.notifyObservers(i)}}this._colorShader.unbind(),e.setDepthFunctionToLessOrEqual(),e.setDepthWrite(!0)}},r.prototype.renderOcclusionBoundingBox=function(t){if(this._prepareResources(),this._colorShader.isReady()&&t._boundingInfo){var e=this.scene.getEngine();this._fillIndexBuffer||(this._fillIndexBuffer=e.createIndexBuffer(this._fillIndexData)),e.setDepthWrite(!1),e.setColorWrite(!1),this._colorShader._preBind();var n=t._boundingInfo.boundingBox,i=n.minimum,o=n.maximum.subtract(i),a=i.add(o.scale(.5)),s=u.a.Scaling(o.x,o.y,o.z).multiply(u.a.Translation(a.x,a.y,a.z)).multiply(n.getWorldMatrix());e.bindBuffers(this._vertexBuffers,this._fillIndexBuffer,this._colorShader.getEffect()),e.setDepthFunctionToLess(),this.scene.resetCachedMaterial(),this._colorShader.bind(s),e.drawElementsType(Ht.a.TriangleFillMode,0,36),this._colorShader.unbind(),e.setDepthFunctionToLessOrEqual(),e.setDepthWrite(!0),e.setColorWrite(!0)}},r.prototype.dispose=function(){if(this._colorShader){this.onBeforeBoxRenderingObservable.clear(),this.onAfterBoxRenderingObservable.clear(),this.onResourcesReadyObservable.clear(),this.renderList.dispose(),this._colorShader.dispose();var t=this._vertexBuffers[Me.b.PositionKind];t&&(t.dispose(),this._vertexBuffers[Me.b.PositionKind]=null),this.scene.getEngine()._releaseBuffer(this._indexBuffer),this._fillIndexBuffer&&(this.scene.getEngine()._releaseBuffer(this._fillIndexBuffer),this._fillIndexBuffer=null)}},r}();_e.a.prototype.enableDepthRenderer=function(r,t,e){if(t===void 0&&(t=!1),e===void 0&&(e=!1),!(r=r||this.activeCamera))throw"No camera available to enable depth renderer";if(this._depthRenderer||(this._depthRenderer={}),!this._depthRenderer[r.id]){var n=!!this.getEngine().getCaps().textureFloatRender,i=0;i=!this.getEngine().getCaps().textureHalfFloatRender||e&&n?n?h.a.TEXTURETYPE_FLOAT:h.a.TEXTURETYPE_UNSIGNED_BYTE:h.a.TEXTURETYPE_HALF_FLOAT,this._depthRenderer[r.id]=new ca(this,i,r,t)}return this._depthRenderer[r.id]},_e.a.prototype.disableDepthRenderer=function(r){(r=r||this.activeCamera)&&this._depthRenderer&&this._depthRenderer[r.id]&&(this._depthRenderer[r.id].dispose(),delete this._depthRenderer[r.id])};var nf=function(){function r(t){this.name=st.a.NAME_DEPTHRENDERER,this.scene=t}return r.prototype.register=function(){this.scene._gatherRenderTargetsStage.registerStep(st.a.STEP_GATHERRENDERTARGETS_DEPTHRENDERER,this,this._gatherRenderTargets),this.scene._gatherActiveCameraRenderTargetsStage.registerStep(st.a.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER,this,this._gatherActiveCameraRenderTargets)},r.prototype.rebuild=function(){},r.prototype.dispose=function(){for(var t in this.scene._depthRenderer)this.scene._depthRenderer[t].dispose()},r.prototype._gatherRenderTargets=function(t){if(this.scene._depthRenderer)for(var e in this.scene._depthRenderer){var n=this.scene._depthRenderer[e];n.enabled&&!n.useOnlyInActiveCamera&&t.push(n.getDepthMap())}},r.prototype._gatherActiveCameraRenderTargets=function(t){if(this.scene._depthRenderer)for(var e in this.scene._depthRenderer){var n=this.scene._depthRenderer[e];n.enabled&&n.useOnlyInActiveCamera&&this.scene.activeCamera.id===e&&t.push(n.getDepthMap())}},r}();ca._SceneComponentInitialization=function(r){var t=r._getComponent(st.a.NAME_DEPTHRENDERER);t||(t=new nf(r),r._addComponent(t))},je.a.ShadersStore.linePixelShader=`uniform vec4 color;
11298void main(void) {
11299gl_FragColor=color;
11300}`;var iv=`#include<instancesDeclaration>
11301
11302attribute vec3 position;
11303attribute vec4 normal;
11304
11305uniform mat4 viewProjection;
11306uniform float width;
11307uniform float aspectRatio;
11308void main(void) {
11309#include<instancesVertex>
11310mat4 worldViewProjection=viewProjection*finalWorld;
11311vec4 viewPosition=worldViewProjection*vec4(position,1.0);
11312vec4 viewPositionNext=worldViewProjection*vec4(normal.xyz,1.0);
11313vec2 currentScreen=viewPosition.xy/viewPosition.w;
11314vec2 nextScreen=viewPositionNext.xy/viewPositionNext.w;
11315currentScreen.x*=aspectRatio;
11316nextScreen.x*=aspectRatio;
11317vec2 dir=normalize(nextScreen-currentScreen);
11318vec2 normalDir=vec2(-dir.y,dir.x);
11319normalDir*=width/2.0;
11320normalDir.x/=aspectRatio;
11321vec4 offset=vec4(normalDir*normal.w,0.0,0.0);
11322gl_Position=viewPosition+offset;
11323}`;je.a.ShadersStore.lineVertexShader=iv,Dt.a.prototype.disableEdgesRendering=function(){return this._edgesRenderer&&(this._edgesRenderer.dispose(),this._edgesRenderer=null),this},Dt.a.prototype.enableEdgesRendering=function(r,t,e){return r===void 0&&(r=.95),t===void 0&&(t=!1),this.disableEdgesRendering(),this._edgesRenderer=new Qc(this,r,t,!0,e),this},Object.defineProperty(Dt.a.prototype,"edgesRenderer",{get:function(){return this._edgesRenderer},enumerable:!0,configurable:!0}),Eo.b.prototype.enableEdgesRendering=function(r,t){return r===void 0&&(r=.95),t===void 0&&(t=!1),this.disableEdgesRendering(),this._edgesRenderer=new rf(this,r,t),this},Eo.a.prototype.enableEdgesRendering=function(r,t){return r===void 0&&(r=.95),t===void 0&&(t=!1),Eo.b.prototype.enableEdgesRendering.apply(this,arguments),this};var rv=function(){this.edges=new Array,this.edgesConnectedCount=0},Qc=function(){function r(t,e,n,i,o){var a,s=this;e===void 0&&(e=.95),n===void 0&&(n=!1),i===void 0&&(i=!0),this.edgesWidthScalerForOrthogra
11323phic=1e3,this.edgesWidthScalerForPerspective=50,this._linesPositions=new Array,this._linesNormals=new Array,this._linesIndices=new Array,this._buffers={},this._buffersForInstances={},this._checkVerticesInsteadOfIndices=!1,this.isEnabled=!0,this.customInstances=new li.a(32),this._source=t,this._checkVerticesInsteadOfIndices=n,this._options=o??null,this._epsilon=e,this._prepareRessources(),i&&((a=o?.useAlternateEdgeFinder)===null||a===void 0||a?this._generateEdgesLinesAlternate():this._generateEdgesLines()),this._meshRebuildObserver=this._source.onRebuildObservable.add(function(){s._rebuild()}),this._meshDisposeObserver=this._source.onDisposeObservable.add(function(){s.dispose()})}return Object.defineProperty(r.prototype,"linesPositions",{get:function(){return this._linesPositions},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"linesNormals",{get:function(){return this._linesNormals},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"linesIndices",{get:function(){return this._linesIndices},enumerable:!1,configurable:!0}),r.GetShader=function(t){if(!t._edgeRenderLineShader){var e=new fa.a("lineShader",t,"line",{attributes:["position","normal"],uniforms:["world","viewProjection","color","width","aspectRatio"]});e.disableDepthWrite=!0,e.backFaceCulling=!1,t._edgeRenderLineShader=e}return t._edgeRenderLineShader},r.prototype._prepareRessources=function(){this._lineShader||(this._lineShader=r.GetShader(this._source.getScene()))},r.prototype._rebuild=function(){var t=this._buffers[Me.b.PositionKind];t&&t._rebuild(),(t=this._buffers[Me.b.NormalKind])&&t._rebuild();var e=this._source.getScene().getEngine();this._ib=e.createIndexBuffer(this._linesIndices)},r.prototype.dispose=function(){this._source.onRebuildObservable.remove(this._meshRebuildObserver),this._source.onDisposeObservable.remove(this._meshDisposeObserver);var t=this._buffers[Me.b.PositionKind];t&&(t.dispose(),this._buffers[Me.b.PositionKind]=null),(t=this._buffers[Me.b.NormalKind])&&(t.dispose(),this._buffers[Me.b.NormalKind]=null),this._ib&&this._source.getScene().getEngine()._releaseBuffer(this._ib),this._lineShader.dispose()},r.prototype._processEdgeForAdjacencies=function(t,e,n,i,o){return t===n&&e===i||t===i&&e===n?0:t===i&&e===o||t===o&&e===i?1:t===o&&e===n||t===n&&e===o?2:-1},r.prototype._processEdgeForAdjacenciesWithVertices=function(t,e,n,i,o){var a=1e-10;return t.equalsWithEpsilon(n,a)&&e.equalsWithEpsilon(i,a)||t.equalsWithEpsilon(i,a)&&e.equalsWithEpsilon(n,a)?0:t.equalsWithEpsilon(i,a)&&e.equalsWithEpsilon(o,a)||t.equalsWithEpsilon(o,a)&&e.equalsWithEpsilon(i,a)?1:t.equalsWithEpsilon(o,a)&&e.equalsWithEpsilon(n,a)||t.equalsWithEpsilon(n,a)&&e.equalsWithEpsilon(o,a)?2:-1},r.prototype._checkEdge=function(t,e,n,i,o){var a;e===void 0?a=!0:a=u.e.Dot(n[t],n[e])<this._epsilon,a&&this.createLine(i,o,this._linesPositions.length/3)},r.prototype.createLine=function(t,e,n){this._linesPositions.push(t.x,t.y,t.z,t.x,t.y,t.z,e.x,e.y,e.z,e.x,e.y,e.z),this._linesNormals.push(e.x,e.y,e.z,-1,e.x,e.y,e.z,1,t.x,t.y,t.z,-1,t.x,t.y,t.z,1),this._linesIndices.push(n,n+1,n+2,n,n+2,n+3)},r.prototype._tessellateTriangle=function(t,e,n,i){var o=function(Pe,Ee,Se){Se>=0&&Ee.push(Se);for(var Le=0;Le<Pe.length;++Le)Ee.push(Pe[Le][0])},a=0;t[1].length>=t[0].length&&t[1].length>=t[2].length?a=1:t[2].length>=t[0].length&&t[2].length>=t[1].length&&(a=2);for(var s=0;s<3;++s)s===a?t[s].sort(function(Pe,Ee){return Pe[1]<Ee[1]?-1:Pe[1]>Ee[1]?1:0}):t[s].sort(function(Pe,Ee){return Pe[1]>Ee[1]?-1:Pe[1]<Ee[1]?1:0});var d=[],p=[];o(t[a],d,-1);for(var y=d.length,P=a+2;P>=a+1;--P)o(t[P%3],p,P!==a+2?i[n[e+(P+1)%3]]:-1);var O=p.length;n.push(i[n[e+a]],d[0],p[0]),n.push(i[n[e+(a+1)%3]],p[O-1],d[y-1]);for(var U=y<=O,F=U?y:O,z=U?O:y,J=U?y-1:O-1,ie=U?0:1,se=y+O-2,ce=0,ue=0,fe=U?d:p,ve=U?p:d,Te=0;se-- >0;){ie?n.push(fe[ce],ve[ue]):n.push(ve[ue],fe[ce]);var Oe=void 0;(Te+=F)>=z&&ce<J?(Oe=fe[++ce],Te-=z):Oe=ve[++ue],n.push(Oe)}n[e+0]=n[n.length-3],n[e+1]=n[n.length-2],n[e+2]=n[n.length-1],n.length=n.length-3},r.prototype._generateEdgesLinesAlternate=function(){var t,e,n,i,o,a,s,d,p,y=this._source.getVerticesData(Me.b.PositionKind),P=this._source.getIndices();if(P&&y){Array.isArray(P)||(P=Ye.b.SliceToArray(P));var O=(e=(t=this._options)===null||t===void 0?void 0:t.useFastVertexMerger)===null||e===void 0||e,U=O?Math.round(-Math.log((i=(n=this._options)===null||n===void 0?void 0:n.epsilonVertexMerge)!==null&&i!==void 0?i:1e-6)/Math.log(10)):(a=(o=this._options)===null||o===void 0?void 0:o.epsilonVertexMerge)!==null&&a!==void 0?a:1e-6,F=[],z=[];if(O)for(var J={},ie=0;ie<y.length;ie+=3){var se=y[ie+0],ce=y[ie+1],ue=y[ie+2];
11323if(J[Mt=se.toFixed(U)+"|"+ce.toFixed(U)+"|"+ue.toFixed(U)]!==void 0)F.push(J[Mt]);else{var fe=ie/3;J[Mt]=fe,F.push(fe),z.push(fe)}}else for(ie=0;ie<y.length;ie+=3){se=y[ie+0],ce=y[ie+1],ue=y[ie+2];for(var ve=!1,Te=0;Te<ie&&!ve;Te+=3){var Oe=y[Te+0],Pe=y[Te+1],Ee=y[Te+2];if(Math.abs(se-Oe)<U&&Math.abs(ce-Pe)<U&&Math.abs(ue-Ee)<U){F.push(Te/3),ve=!0;break}}ve||(F.push(ie/3),z.push(ie/3))}if(!((s=this._options)===null||s===void 0)&&s.applyTessellation){for(var Se=(p=(d=this._options)===null||d===void 0?void 0:d.epsilonVertexAligned)!==null&&p!==void 0?p:1e-6,Le=[],xe=0;xe<P.length;xe+=3)for(var Ne=void 0,Ie=0;Ie<3;++Ie){var Fe=F[P[xe+Ie]],Ke=F[P[xe+(Ie+1)%3]],nt=F[P[xe+(Ie+2)%3]];if(Fe!==Ke)for(var rt=y[3*Fe+0],ut=y[3*Fe+1],qe=y[3*Fe+2],at=y[3*Ke+0],ot=y[3*Ke+1],Je=y[3*Ke+2],dt=Math.sqrt((at-rt)*(at-rt)+(ot-ut)*(ot-ut)+(Je-qe)*(Je-qe)),Ve=0;Ve<z.length-1;Ve++){var $e=z[Ve];if($e!==Fe&&$e!==Ke&&$e!==nt){var yt=y[3*$e+0],Wt=y[3*$e+1],Nt=y[3*$e+2],Qt=Math.sqrt((yt-rt)*(yt-rt)+(Wt-ut)*(Wt-ut)+(Nt-qe)*(Nt-qe)),vt=Math.sqrt((yt-at)*(yt-at)+(Wt-ot)*(Wt-ot)+(Nt-Je)*(Nt-Je));Math.abs(Qt+vt-dt)<Se&&(Ne||(Ne={index:xe,edgesPoints:[[],[],[]]},Le.push(Ne)),Ne.edgesPoints[Ie].push([$e,Qt]))}}}for(var Jt=0;Jt<Le.length;++Jt){var Xt=Le[Jt];this._tessellateTriangle(Xt.edgesPoints,Xt.index,P,F)}Le=null}var zt={};for(xe=0;xe<P.length;xe+=3){var Yt=void 0;for(Ie=0;Ie<3;++Ie)if(Fe=F[P[xe+Ie]],Ke=F[P[xe+(Ie+1)%3]],nt=F[P[xe+(Ie+2)%3]],Fe!==Ke){if(u.c.Vector3[0].copyFromFloats(y[3*Fe+0],y[3*Fe+1],y[3*
11323Fe+2]),u.c.Vector3[1].copyFromFloats(y[3*Ke+0],y[3*Ke+1],y[3*Ke+2]),u.c.Vector3[2].copyFromFloats(y[3*nt+0],y[3*nt+1],y[3*nt+2]),Yt||(u.c.Vector3[1].subtractToRef(u.c.Vector3[0],u.c.Vector3[3]),u.c.Vector3[2].subtractToRef(u.c.Vector3[1],u.c.Vector3[4]),(Yt=u.e.Cross(u.c.Vector3[3],u.c.Vector3[4])).normalize()),Fe>Ke){var Et=Fe;Fe=Ke,Ke=Et}($t=zt[Mt=Fe+"_"+Ke])?$t.done||(u.e.Dot(Yt,$t.normal)<this._epsilon&&this.createLine(u.c.Vector3[0],u.c.Vector3[1],this._linesPositions.length/3),$t.done=!0):zt[Mt]={normal:Yt,done:!1,index:xe,i:Ie}}}for(var Mt in zt){var $t;($t=zt[Mt]).done||(Fe=F[P[$t.index+$t.i]],Ke=F[P[$t.index+($t.i+1)%3]],u.c.Vector3[0].copyFromFloats(y[3*Fe+0],y[3*Fe+1],y[3*Fe+2]),u.c.Vector3[1].copyFromFloats(y[3*Ke+0],y[3*Ke+1],y[3*Ke+2]),this.createLine(u.c.Vector3[0],u.c.Vector3[1],this._linesPositions.length/3))}var Mn=this._source.getScene().getEngine();this._buffers[Me.b.PositionKind]=new Me.b(Mn,this._linesPositions,Me.b.PositionKind,!1),this._buffers[Me.b.NormalKind]=new Me.b(Mn,this._linesNormals,Me.b.NormalKind,!1,!1,4),this._buffersForInstances[Me.b.PositionKind]=this._buffers[Me.b.PositionKind],this._buffersForInstances[Me.b.NormalKind]=this._buffers[Me.b.NormalKind],this._ib=Mn.createIndexBuffer(this._linesIndices),this._indicesCount=this._linesIndices.length}},r.prototype._generateEdgesLines=function(){var t=this._source.getVerticesData(Me.b.PositionKind),e=this._source.getIndices();if(e&&t){var n,i,o=new Array,a=new Array;for(n=0;n<e.length;n+=3){i=new rv;var s=e[n],d=e[n+1],p=e[n+2];i.p0=new u.e(t[3*s],t[3*s+1],t[3*s+2]),i.p1=new u.e(t[3*d],t[3*d+1],t[3*d+2]),i.p2=new u.e(t[3*p],t[3*p+1],t[3*p+2]);var y=u.e.Cross(i.p1.subtract(i.p0),i.p2.subtract(i.p1));y.normalize(),a.push(y),o.push(i)}for(n=0;n<o.length;n++){i=o[n];for(var P=n+1;P<o.length;P++){var O=o[P];if(i.edgesConnectedCount===3)break;if(O.edgesConnectedCount!==3)for(var U=e[3*P],F=e[3*P+1],z=e[3*P+2],J=0;J<3;J++){var ie=0;if(i.edges[J]===void 0){switch(J){case 0:ie=this._checkVerticesInsteadOfIndices?this._processEdgeForAdjacenciesWithVertices(i.p0,i.p1,O.p0,O.p1,O.p2):this._processEdgeForAdjacencies(e[3*n],e[3*n+1],U,F,z);break;case 1:ie=this._checkVerticesInsteadOfIndices?this._processEdgeForAdjacenciesWithVertices(i.p1,i.p2,O.p0,O.p1,O.p2):this._processEdgeForAdjacencies(e[3*n+1],e[3*n+2],U,F,z);break;case 2:ie=this._checkVerticesInsteadOfIndices?this._processEdgeForAdjacenciesWithVertices(i.p2,i.p0,O.p0,O.p1,O.p2):this._processEdgeForAdjacencies(e[3*n+2],e[3*n],U,F,z)}if(ie!==-1&&(i.edges[J]=P,O.edges[ie]=n,i.edgesConnectedCount++,O.edgesConnectedCount++,i.edgesConnectedCount===3))break}}}}for(n=0;n<o.length;n++){var se=o[n];this._checkEdge(n,se.edges[0],a,se.p0,se.p1),this._checkEdge(n,se.edges[1],a,se.p1,se.p2),this._checkEdge(n,se.edges[2],a,se.p2,se.p0)}var ce=this._source.getScene().getEngine();this._buffers[Me.b.PositionKind]=new Me.b(ce,this._linesPositions,Me.b.PositionKind,!1),this._buffers[Me.b.NormalKind]=new Me.b(ce,this._linesNormals,Me.b.NormalKind,!1,!1,4),this._buffersForInstances[Me.b.PositionKind]=this._buffers[Me.b.PositionKind],this._buffersForInstances[Me.b.NormalKind]=this._buffers[Me.b.NormalKind],this._ib=ce.createIndexBuffer(this._linesIndices),this._indicesCount=this._linesIndices.length}},r.prototype.isReady=function(){return this._lineShader.isReady(this._source,this._source.hasInstances&&this.customInstances.length>0||this._source.hasThinInstances)},r.prototype.render=function(){var t=this._source.getScene();if(this.isReady()&&t.activeCamera){var e=t.getEngine();this._lineShader._preBind(),this._source.edgesColor.a!==1?e.setAlphaMode(h.a.ALPHA_COMBINE):e.setAlphaMode(h.a.ALPHA_DISABLE);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.isFrozen){for(var s=0,d=0;d<o;++d)this.customInstances.data[d].copyToArray(a.instancesData,s),s+=16;a.instancesBuffer.updateDirectly(a.instancesData,0,o)}}else o=this._source.thinInstanceCount;e.bindBuffers(i?this._buffersForInstances:this._buffers,this._ib,this._lineShader.getEffect()),t.resetCachedMaterial(),this._lineShader.setColor4("color",this._source.edgesColor),t.activeCamera.mode===gt.a.ORTHOGRAPHIC_CAMERA?this._lineShader.setFloat("width",this._source.edgesWidth/this.edgesWidthScalerForOrthogra
11323phic):this._lineShader.setFloat("width",this._source.edgesWidth/this.edgesWidthScalerForPerspective),this._lineShader.setFloat("aspectRatio",e.getAspectRatio(t.activeCamera)),this._lineShader.bind(this._source.getWorldMatrix()),e.drawElementsType(Ht.a.TriangleFillMode,0,this._indicesCount,o),this._lineShader.unbind(),i&&e.unbindInstanceAttributes(),this._source.getScene()._activeMeshesFrozen||this.customInstances.reset()}},r}(),rf=function(r){function t(e,n,i){n===void 0&&(n=.95),i===void 0&&(i=!1);var o=r.call(this,e,n,i,!1)||this;return o._generateEdgesLines(),o}return Object(c.d)(t,r),t.prototype._generateEdgesLines=function(){var e=this._source.getVerticesData(Me.b.PositionKind),n=this._source.getIndices();if(n&&e){for(var i=u.c.Vector3[0],o=u.c.Vector3[1],a=n.length-1,s=0,d=0;s<a;s+=2,d+=4)u.e.FromArrayToRef(e,3*n[s],i),u.e.FromArrayToRef(e,3*n[s+1],o),this.createLine(i,o,d);var p=this._source.getScene().getEngine();this._buffers[Me.b.PositionKind]=new Me.b(p,this._linesPositions,Me.b.PositionKind,!1),this._buffers[Me.b.NormalKind]=new Me.b(p,this._linesNormals,Me.b.NormalKind,!1,!1,4),this._ib=p.createIndexBuffer(this._linesIndices),this._indicesCount=this._linesIndices.length}},t}(Qc),qc=function(){function r(t){this._textureFormats=[{type:h.a.PREPASS_IRRADIANCE_TEXTURE_TYPE,format:h.a.TEXTURETYPE_HALF_FLOAT},{type:h.a.PREPASS_POSITION_TEXTURE_TYPE,format:h.a.TEXTURETYPE_HALF_FLOAT},{type:h.a.PREPASS_VELOCITY_TEXTURE_TYPE,format:h.a.TEXTURETYPE_HALF_FLOAT},{type:h.a.PREPASS_REFLECTIVITY_TEXTURE_TYPE,format:h.a.TEXTURETYPE_UNSIGNED_INT},{type:h.a.PREPASS_COLOR_TEXTURE_TYPE,format:h.a.TEXTURETYPE_HALF_FLOAT},{type:h.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE,format:h.a.TEXTURETYPE_HALF_FLOAT},{type:h.a.PREPASS_ALBEDO_TEXTURE_TYPE,format:h.a.TEXTURETYPE_UNSIGNED_INT}],this.excludedSkinnedMesh=[],this.excludedMaterials=[],this._textureIndices=[],this._isDirty=!1,this.mrtCount=0,this._postProcesses=[],this._clearColor=new M.b(0,0,0,0),this._effectConfigurations=[],this._mrtFormats=[],this._enabled=!1,this._useGeometryBufferFallback=!1,this.disableGammaTransform=!1,this._scene=t,this._engine=t.getEngine(),r._SceneComponentInitialization(this._scene),this._resetLayout()}return Object.defineProperty(r.prototype,"enabled",{get:function(){return this._enabled},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"samples",{get:function(){return this.prePassRT.samples},set:function(t){this.imageProcessingPostProcess||this._createCompositionEffect(),this.prePassRT.samples=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"useGeometryBufferFallback",{get:function(){return this._useGeometryBufferFallback},set:function(t){if(this._useGeometryBufferFallback=t,t){if(this._geometryBuffer=this._scene.enableGeometryBufferRenderer(),!this._geometryBuffer)return void(this._useGeometryBufferFallback=!1);this._geometryBuffer.renderList=[],this._geometryBuffer._linkPrePassRenderer(this),this._updateGeometryBufferLayout()}else this._geometryBuffer&&this._geometryBuffer._unlinkPrePassRenderer(),this._geometryBuffer=null,this._scene.disableGeometryBufferRenderer()},enumerable:!1,configurable:!0}),r.prototype._initializeAttachments=function(){for(var t=[],e=[!1],n=[!0],i=0;i<this.mrtCount;i++)t.push(!0),i>0&&(e.push(!0),n.push(!1));this._multiRenderAttachments=this._engine.buildTextureLayout(t),this._clearAttachments=this._engine.buildTextureLayout(e),this._defaultAttachments=this._engine.buildTextureLayout(n)},r.prototype._createCompositionEffect=function(){this.prePassRT=new tc("sceneprePassRT",{width:this._engine.getRenderWidth(),height:this._engine.getRenderHeight()},this.mrtCount,this._scene,{generateMipMaps:!1,generateDepthTexture:!0,defaultType:h.a.TEXTURETYPE_UNSIGNED_INT,types:this._mrtFormats}),this.prePassRT.samples=1,this._initializeAttachments(),this._useGeometryBufferFallback&&!this._geometryBuffer&&(this.useGeometryBufferFallback=!0),this.imageProcessingPostProcess=new Ho("sceneCompositionPass",1,null,void 0,this._engine),this.imageProcessingPostProcess.autoClear=!1},Object.defineProperty(r.prototype,"isSupported",{get:function(){return this._engine.webGLVersion>1||this._scene.getEngine().getCaps().drawBuffersExtension}
11323,enumerable:!1,configurable:!0}),r.prototype.bindAttachmentsForEffect=function(t,e){if(this.enabled){if(t._multiTarget)this._engine.bindAttachments(this._multiRenderAttachments);else if(this._engine.bindAttachments(this._defaultAttachments),this._geometryBuffer){var n=e.getMaterial();n&&this.excludedMaterials.indexOf(n)===-1&&this._geometryBuffer.renderList.push(e.getRenderingMesh())}}},r.prototype.restoreAttachments=function(){this.enabled&&this._defaultAttachments&&this._engine.bindAttachments(this._defaultAttachments)},r.prototype._beforeCameraDraw=function(){this._isDirty&&this._update(),this._geometryBuffer&&(this._geometryBuffer.renderList.length=0),this._bindFrameBuffer()},r.prototype._afterCameraDraw=function(){if(this._enabled){var t=this._scene.activeCamera&&this._scene.activeCamera._getFirstPostProcess();t&&this._postProcesses.length&&this._scene.postProcessManager._prepareFrame(),this._scene.postProcessManager.directRender(this._postProcesses,t?t.inputTexture:null)}},r.prototype._checkRTSize=function(){var t=this._engine.getRenderWidth(!0),e=this._engine.getRenderHeight(!0),n=this.prePassRT.getRenderWidth(),i=this.prePassRT.getRenderHeight();n===t&&i===e||(this.prePassRT.resize({width:t,height:e}),this._updateGeometryBufferLayout(),this._bindPostProcessChain())},r.prototype._bindFrameBuffer=function(){if(this._enabled){this._checkRTSize();var t=this.prePassRT.getInternalTexture();t&&this._engine.bindFramebuffer(t)}},r.prototype.clear=function(){this._enabled&&(this._bindFrameBuffer(),this._engine.clear(this._scene.clearColor,this._scene.autoClear||this._scene.forceWireframe||this._scene.forcePointsCloud,this._scene.autoClearDepthAndStencil,this._scene.autoClearDepthAndStencil),this._engine.bindAttachments(this._clearAttachments),this._engine.clear(this._clearColor,!0,!1,!1),this._engine.bindAttachments(this._defaultAttachments))},r.prototype._setState=function(t){this._enabled=t,this._scene.prePass=t,this.imageProcessingPostProcess&&(this.imageProcessingPostProcess.imageProcessingConfiguration.applyByPostProcess=t)},r.prototype._updateGeometryBufferLayout=function(){if(this._geometryBuffer){this._geometryBuffer._resetLayout();for(var t=[],e=0;e<this._mrtLayout.length;e++)t.push(!1);this._geometryBuffer._linkInternalTexture(this.prePassRT.getInternalTexture());var n=[{prePassConstant:h.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE,geometryBufferConstant:ai.DEPTHNORMAL_TEXTURE_TYPE},{prePassConstant:h.a.PREPASS_POSITION_TEXTURE_TYPE,geometryBufferConstant:ai.POSITION_TEXTURE_TYPE},{prePassConstant:h.a.PREPASS_REFLECTIVITY_TEXTURE_TYPE,geometryBufferConstant:ai.REFLECTIVITY_TEXTURE_TYPE},{prePassConstant:h.a.PREPASS_VELOCITY_TEXTURE_TYPE,geometryBufferConstant:ai.VELOCITY_TEXTURE_TYPE}];for(e=0;e<n.length;e++){var i=this._mrtLayout.indexOf(n[e].prePassConstant);i!==-1&&(this._geometryBuffer._forceTextureType(n[e].geometryBufferConstant,i),t[i]=!0)}this._geometryBuffer._setAttachments(this._engine.buildTextureLayout(t))}},r.prototype.addEffectConfiguration=function(t){for(var e=0;e<this._effectConfigurations.length;e++)if(this._effectConfigurations[e].name===t.name)return this._effectConfigurations[e];return this._effectConfigurations.push(t),t},r.prototype.getIndex=function(t){return this._textureIndices[t]},r.prototype._enable=function(){for(var t,e,n=this.mrtCount,i=0;i<this._effectConfigurations.length;i++)this._effectConfigurations[i].enabled&&this._enableTextures(this._effectConfigurations[i].texturesRequired);for(this.prePassRT&&this.mrtCount!==n&&this.prePassRT.updateCount(this.mrtCount,{types:this._mrtFormats}),this._updateGeometryBufferLayout(),this._resetPostProcessChain(),i=0;i<this._effectConfigurations.length;i++)this._effectConfigurations[i].enabled&&(!this._effectConfigurations[i].postProcess&&this._effectConfigurations[i].createPostProcess&&this._effectConfigurations[i].createPostProcess(),this._effectConfigurations[i].postProcess&&this._postProcesses.push(this._effectConfigurations[i].postProcess));this._initializeAttachments(),this.imageProcessingPostProcess||this._createCompositionEffect();var o=!1;if(!((t=this._scene.activeCamera)===null||t===void 0)&&t._postProcesses)for(i=0;i<this._scene.activeCamera._postProcesses.length;i++)((e=this._scene.activeCamera._postProcesses[i])===null||e===void 0?void 0:e.getClassName())==="ImageProcessingPostProcess"&&(o=!0);o||this.disableGammaTransform||this._postProcesses.push(this.imageProcessingPostProcess),this._bindPostProcessChain(),this._setState(!0)},r.prototype._disable=function(){this._setState(!1),this._resetLayout();for(var t=0;t<this._effectConfigurations.length;t++)this._effectConfigurations[t].enabled=!1},r.prototype._resetLayout=function(){for(var t=0;t<this._textureFormats.length;t++)this._textureIndices[this._textureFormats[t].type]=-1;this._textureIndices[h.a.PREPASS_COLOR_TEXTURE_TYPE]=0,this._mrtLayout=[h.a.PREPASS_COLOR_TEXTURE_TYPE],this._mrtFormats=[h.a.TEXTURETYPE_HALF_FLOAT],this.mrtCount=1},r.prototype._resetPostProcessChain=function(){this._postProcesses=[],this.imageProcessingPostProcess&&this.imageProcessingPostProcess.restoreDefaultInputTexture();for(var t=0;t<this._effectConfigurations.length;t++)this._effectConfigurations[t].postProcess&&this._effectConfigurations[t].postProcess.restoreDefaultInputTexture()},r.prototype._bindPostProcessChain=function(){var t;
11323if(this._postProcesses.length)this._postProcesses[0].inputTexture=this.prePassRT.getInternalTexture();else{var e=(t=this._scene.activeCamera)===null||t===void 0?void 0:t._getFirstPostProcess();e&&(e.inputTexture=this.prePassRT.getInternalTexture())}},r.prototype.markAsDirty=function(){this._isDirty=!0},r.prototype._enableTextures=function(t){for(var e=0;e<t.length;e++){var n=t[e];this._textureIndices[n]===-1&&(this._textureIndices[n]=this._mrtLayout.length,this._mrtLayout.push(n),this._mrtFormats.push(this._textureFormats[n].format),this.mrtCount++)}},r.prototype._update=function(){this._disable();for(var t=!1,e=0;e<this._scene.materials.length;e++)this._scene.materials[e].setPrePassRenderer(this)&&(t=!0);var n=this._scene.activeCamera;if(n){var i=n._postProcesses.filter(function(o){return o!=null});if(i)for(e=0;e<i.length;e++)i[e].setPrePassRenderer(this)&&(t=!0);this._markAllMaterialsAsPrePassDirty(),this._isDirty=!1,t&&this._enable(),this.enabled||(this._engine.restoreDefaultFramebuffer(),this._engine.restoreSingleAttachment())}},r.prototype._markAllMaterialsAsPrePassDirty=function(){for(var t=this._scene.materials,e=0;e<t.length;e++)t[e].markAsDirty(Ht.a.PrePassDirtyFlag)},r.prototype.dispose=function(){for(var t=0;t<this._effectConfigurations.length;t++)this._effectConfigurations[t].dispose&&this._effectConfigurations[t].dispose();this.imageProcessingPostProcess.dispose(),this.prePassRT.dispose()},r._SceneComponentInitialization=function(t){throw En.a.WarnImport("PrePassRendererSceneComponent")},r}();Object.defineProperty(_e.a.prototype,"prePassRenderer",{get:function(){return this._prePassRenderer},set:function(r){r&&r.isSupported&&(this._prePassRenderer=r)},enumerable:!0,configurable:!0}),_e.a.prototype.enablePrePassRenderer=function(){return this._prePassRenderer||(this._prePassRenderer=new qc(this),this._prePassRenderer.isSupported||(this._prePassRenderer=null,l.a.Error(`PrePassRenderer needs WebGL 2 support.
11324Maybe you tried to use the following features that need the PrePassRenderer :
11325 + Subsurface Scattering`))),this._prePassRenderer},_e.a.prototype.disablePrePassRenderer=function(){this._prePassRenderer&&(this._prePassRenderer.dispose(),this._prePassRenderer=null)};var of=function(){function r(t){this.name=st.a.NAME_PREPASSRENDERER,this.scene=t}return r.prototype.register=function(){this.scene._beforeCameraDrawStage.registerStep(st.a.STEP_BEFORECAMERADRAW_PREPASS,this,this._beforeCameraDraw),this.scene._afterCameraDrawStage.registerStep(st.a.STEP_AFTERCAMERADRAW_PREPASS,this,this._afterCameraDraw),this.scene._beforeClearStage.registerStep(st.a.STEP_BEFORECLEARSTAGE_PREPASS,this,this._beforeClearStage),this.scene._beforeRenderingMeshStage.registerStep(st.a.STEP_BEFORERENDERINGMESH_PREPASS,this,this._beforeRenderingMeshStage),this.scene._afterRenderingMeshStage.registerStep(st.a.STEP_AFTERRENDERINGMESH_PREPASS,this,this._afterRenderingMeshStage)},r.prototype._beforeCameraDraw=function(){this.scene.prePassRenderer&&this.scene.prePassRenderer._beforeCameraDraw()},r.prototype._afterCameraDraw=function(){this.scene.prePassRenderer&&this.scene.prePassRenderer._afterCameraDraw()},r.prototype._beforeClearStage=function(){this.scene.prePassRenderer&&this.scene.prePassRenderer.clear()},r.prototype._beforeRenderingMeshStage=function(t,e,n,i){if(i){var o=t.getScene();o.prePassRenderer&&o.prePassRenderer.bindAttachmentsForEffect(i,e)}},r.prototype._afterRenderingMeshStage=function(t){var e=t.getScene();e.prePassRenderer&&e.prePassRenderer.restoreAttachments()},r.prototype.rebuild=function(){},r.prototype.dispose=function(){},r}();qc._SceneComponentInitialization=function(r){var t=r._getComponent(st.a.NAME_PREPASSRENDERER);t||(t=new of(r),r._addComponent(t))};var ov=`#define rcp(x) 1./x
11326#define GOLDEN_RATIO 1.618033988749895
11327#define TWO_PI 6.2831855
11328
11329
11330vec2 Golden2dSeq(int i,float n)
11331{
11332
11333
11334return vec2(float(i)/n+(0.5/n),fract(float(i)*rcp(GOLDEN_RATIO)));
11335}
11336vec2 SampleDiskGolden(int i,int sampleCount)
11337{
11338vec2 f=Golden2dSeq(i,float(sampleCount));
11339return vec2(sqrt(f.x),TWO_PI*f.y);
11340}`;je.a.IncludesShadersStore.fibonacci=ov;var av=`uniform vec3 diffusionS[5];
11341uniform float diffusionD[5];
11342uniform float filterRadii[5];`;je.a.IncludesShadersStore.diffusionProfile=av;var sv=`
11343#include<fibonacci>
11344#include<helperFunctions>
11345#include<subSurfaceScatteringFunctions>
11346#include<diffusionProfile>
11347varying vec2 vUV;
11348uniform vec2 texelSize;
11349uniform sampler2D textureSampler;
11350uniform sampler2D irradianceSampler;
11351uniform sampler2D depthSampler;
11352uniform sampler2D albedoSampler;
11353uniform vec2 viewportSize;
11354uniform float metersPerUnit;
11355const float LOG2_E=1.4426950408889634;
11356const float SSS_PIXELS_PER_SAMPLE=4.;
11357const int _SssSampleBudget=40;
11358#define rcp(x) 1./x
11359#define Sq(x) x*x
11360#define SSS_BILATERAL_FILTER true
11361
11362
11363vec3 EvalBurleyDiffusionProfile(float r,vec3 S)
11364{
11365vec3 exp_13=exp2(((LOG2_E*(-1.0/3.0))*r)*S);
11366vec3 expSum=exp_13*(1.+exp_13*exp_13);
11367return (S*rcp(8.*PI))*expSum;
11368}
11369
11370
11371
11372
11373
11374
11375vec2 SampleBurleyDiffusionProfile(float u,float rcpS)
11376{
11377u=1.-u;
11378float g=1.+(4.*u)*(2.*u+sqrt(1.+(4.*u)*u));
11379float n=exp2(log2(g)*(-1.0/3.0));
11380float p=(g*n)*n;
11381float c=1.+p+n;
11382float d=(3./LOG2_E*2.)+(3./LOG2_E)*log2(u);
11383float x=(3./LOG2_E)*log2(c)-d;
11384
11385
11386
11387
11388
11389
11390float rcpExp=((c*c)*c)*rcp((4.*u)*((c*c)+(4.*u)*(4.*u)));
11391float r=x*rcpS;
11392float rcpPdf=(8.*PI*rcpS)*rcpExp;
11393return vec2(r,rcpPdf);
11394}
11395
11396
11397vec3 ComputeBilateralWeight(float xy2,float z,float mmPerUnit,vec3 S,float rcpPdf)
11398{
11399#ifndef SSS_BILATERAL_FILTER
11400z=0.;
11401#endif
11402
11403
11404
11405float r=sqrt(xy2+(z*mmPerUnit)*(z*mmPerUnit));
11406float area=rcpPdf;
11407#if SSS_CLAMP_ARTIFACT
11408return clamp(EvalBurleyDiffusionProfile(r,S)*area,0.0,1.0);
11409#else
11410return EvalBurleyDiffusionProfile(r,S)*area;
11411#endif
11412}
11413void EvaluateSample(int i,int n,vec3 S,float d,vec3 centerPosVS,float mmPerUnit,float pixelsPerMm,
11414float phase,inout vec3 totalIrradiance,inout vec3 totalWeight)
11415{
11416
11417float scale=rcp(float(n));
11418float offset=rcp(float(n))*0.5;
11419
11420float sinPhase,cosPhase;
11421sinPhase=sin(phase);
11422cosPhase=cos(phase);
11423vec2 bdp=SampleBurleyDiffusionProfile(float(i)*scale+offset,d);
11424float r=bdp.x;
11425float rcpPdf=bdp.y;
11426float phi=SampleDiskGolden(i,n).y;
11427float sinPhi,cosPhi;
11428sinPhi=sin(phi);
11429cosPhi=cos(phi);
11430float sinPsi=cosPhase*sinPhi+sinPhase*cosPhi;
11431float cosPsi=cosPhase*cosPhi-sinPhase*sinPhi;
11432vec2 vec=r*vec2(cosPsi,sinPsi);
11433
11434vec2 position;
11435float xy2;
11436position=vUV+round((pixelsPerMm*r)*vec2(cosPsi,sinPsi))*texelSize;
11437xy2=r*r;
11438vec4 textureSample=texture2D(irradianceSampler,position);
11439float viewZ=texture2D(depthSampler,position).r;
11440vec3 irradiance=textureSample.rgb;
11441if (testLightingForSSS(textureSample.a))
11442{
11443
11444float relZ=viewZ-centerPosVS.z;
11445vec3 weight=ComputeBilateralWeight(xy2,relZ,mmPerUnit,S,rcpPdf);
11446totalIrradiance+=weight*irradiance;
11447totalWeight+=weight;
11448}
11449else
11450{
11451
11452
11453
11454
11455
11456
11457}
11458}
11459void main(void)
11460{
11461vec4 irradianceAndDiffusionProfile=texture2D(irradianceSampler,vUV);
11462vec3 centerIrradiance=irradianceAndDiffusionProfile.rgb;
11463int diffusionProfileIndex=int(round(irradianceAndDiffusionProfile.a*255.));
11464float centerDepth=0.;
11465vec4 inputColor=texture2D(textureSampler,vUV);
11466bool passedStencilTest=testLightingForSSS(irradianceAndDiffusionProfile.a);
11467if (passedStencilTest)
11468{
11469centerDepth=texture2D(depthSampler,vUV).r;
11470}
11471if (!passedStencilTest) {
11472gl_FragColor=inputColor;
11473return;
11474}
11475float distScale=1.;
11476vec3 S=diffusionS[diffusionProfileIndex];
11477float d=diffusionD[diffusionProfileIndex];
11478float filterRadius=filterRadii[diffusionProfileIndex];
11479
11480vec2 centerPosNDC=vUV;
11481vec2 cornerPosNDC=vUV+0.5*texelSize;
11482vec3 centerPosVS=vec3(centerPosNDC*viewportSize,1.0)*centerDepth;
11483vec3 cornerPosVS=vec3(cornerPosNDC*viewportSize,1.0)*centerDepth;
11484
11485float mmPerUnit=1000.*(metersPerUnit*rcp(distScale));
11486float unitsPerMm=rcp(mmPerUnit);
11487
11488
11489float unitsPerPixel=2.*abs(cornerPosVS.x-centerPosVS.x);
11490float pixelsPerMm=rcp(unitsPerPixel)*unitsPerMm;
11491
11492float filterArea=PI*Sq(filterRadius*pixelsPerMm);
11493int sampleCount=int(filterArea*rcp(SSS_PIXELS_PER_SAMPLE));
11494int sampleBudget=_SssSampleBudget;
11495int texturingMode=0;
11496vec3 albedo=texture2D(albedoSampler,vUV).rgb;
11497if (distScale == 0. || sampleCount<1)
11498{
11499#ifdef DEBUG_SSS_SAMPLES
11500vec3 green=vec3(0.,1.,0.);
11501gl_FragColor=vec4(green,1.0);
11502return;
11503#endif
11504gl_FragColor=vec4(inputColor.rgb+albedo*centerIrradiance,1.0);
11505return;
11506}
11507#ifdef DEBUG_SSS_SAMPLES
11508vec3 red=vec3(1.,0.,0.);
11509vec3 blue=vec3(0.,0.,1.);
11510gl_FragColor=vec4(mix(blue,red,clamp(float(sampleCount)/float(sampleBudget),0.0,1.0)),1.0);
11511return;
11512#endif
11513
11514float phase=0.;
11515int n=min(sampleCount,sampleBudget);
11516
11517vec3 centerWeight=vec3(0.);
11518vec3 totalIrradiance=vec3(0.);
11519vec3 totalWeight=vec3(0.);
11520for (int i=0; i<n; i++)
11521{
11522
11523EvaluateSample(i,n,S,d,centerPosVS,mmPerUnit,pixelsPerMm,
11524phase,totalIrradiance,totalWeight);
11525}
11526
11527totalWeight=max(totalWeight,HALF_MIN);
11528gl_FragColor=vec4(inputColor.rgb+albedo*max(totalIrradiance/totalWeight,vec3(0.0)),1.);
11529}`;je.a.ShadersStore.subSurfaceScatteringPixelShader=sv;var cv=function(r){function t(e,n,i,o,a,s,d,p){o===void 0&&(o=null),p===void 0&&(p=h.a.TEXTURETYPE_UNSIGNED_INT);var y=r.call(this,e,"subSurfaceScattering",["texelSize","viewportSize","metersPerUnit"],["diffusionS","diffusionD","filterRadii","irradianceSampler","depthSampler","albedoSampler"],i,o,a||we.a.BILINEAR_SAMPLINGMODE,s,d,null,p,"postprocess",void 0,!0)||this;return y._scene=n,y.updateEffect(),y.onApplyObservable.add(function(P){if(n.prePassRenderer&&n.subSurfaceConfiguration){var O=y.texelSize;P.setFloat("metersPerUnit",n.subSurfaceConfiguration.metersPerUnit),P.setFloat2("texelSize",O.x,O.y),P.setTexture("irradianceSampler",n.prePassRenderer.prePassRT.textures[n.prePassRenderer.getIndex(h.a.PREPASS_IRRADIANCE_TEXTURE_TYPE)]),P.setTexture("depthSampler",n.prePassRenderer.prePassRT.textures[n.prePassRenderer.getIndex(h.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)]),P.setTexture("albedoSampler",n.prePassRenderer.prePassRT.textures[n.prePassRenderer.getIndex(h.a.PREPASS_ALBEDO_TEXTURE_TYPE)]),P.setFloat2("viewportSize",Math.tan(n.activeCamera.fov/2)*n.getEngine().getAspectRatio(n.activeCamera,!0),Math.tan(n.activeCamera.fov/2)),P.setArray3("diffusionS",n.subSurfaceConfiguration.ssDiffusionS),P.setArray("diffusionD",n.subSurfaceConfiguration.ssDiffusionD),P.setArray("filterRadii",n.subSurfaceConfiguration.ssFilterRadii)}else l.a.Error("PrePass and subsurface configuration needs to be enabled for subsurface scattering.")}),y}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"SubSurfaceScatteringPostProcess"},t}(_t),af=function(){function r(t){this._ssDiffusionS=[],this._ssFilterRadii=[],this._ssDiffusionD=[],this.enabled=!1,this.name=st.a.NAME_SUBSURFACE,this.ssDiffusionProfileColors=[],this.metersPerUnit=1,this.texturesRequired=[h.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE,h.a.PREPASS_ALBEDO_TEXTURE_TYPE,h.a.PREPASS_COLOR_TEXTURE_TYPE,h.a.PREPASS_IRRADIANCE_TEXTURE_TYPE],this.addDiffusionProfile(new M.a(1,1,1)),this._scene=t,r._SceneComponentInitialization(this._scene)}return Object.defineProperty(r.prototype,"ssDiffusionS",{get:function(){return this._ssDiffusionS}
11529,enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"ssDiffusionD",{get:function(){return this._ssDiffusionD},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"ssFilterRadii",{get:function(){return this._ssFilterRadii},enumerable:!1,configurable:!0}),r.prototype.addDiffusionProfile=function(t){if(this.ssDiffusionD.length>=5)return l.a.Error("You already reached the maximum number of diffusion profiles."),0;for(var e=0;e<this._ssDiffusionS.length/3;e++)if(this._ssDiffusionS[3*e]===t.r&&this._ssDiffusionS[3*e+1]===t.g&&this._ssDiffusionS[3*e+2]===t.b)return e;return this._ssDiffusionS.push(t.r,t.b,t.g),this._ssDiffusionD.push(Math.max(Math.max(t.r,t.b),t.g)),this._ssFilterRadii.push(this.getDiffusionProfileParameters(t)),this.ssDiffusionProfileColors.push(t),this._ssDiffusionD.length-1},r.prototype.createPostProcess=function(){return this.postProcess=new cv("subSurfaceScattering",this._scene,1,null,void 0,this._scene.getEngine()),this.postProcess.autoClear=!1,this.postProcess},r.prototype.clearAllDiffusionProfiles=function(){this._ssDiffusionD=[],this._ssDiffusionS=[],this._ssFilterRadii=[],this.ssDiffusionProfileColors=[]},r.prototype.dispose=function(){this.clearAllDiffusionProfiles(),this.postProcess.dispose()},r.prototype.getDiffusionProfileParameters=function(t){var e=Math.max(t.r,t.g,t.b);return this._sampleBurleyDiffusionProfile(.997,e)},r.prototype._sampleBurleyDiffusionProfile=function(t,e){var n=1+4*(t=1-t)*(2*t+Math.sqrt(1+4*t*t)),i=Math.pow(n,-1/3),o=1+n*i*i+i;return 3*Math.log(o/(4*t))*e},r._SceneComponentInitialization=function(t){throw En.a.WarnImport("PrePassRendererSceneComponent")},r}();B.a.AddParser(st.a.NAME_SUBSURFACE,function(r,t){if(r.ssDiffusionProfileColors!==void 0&&r.ssDiffusionProfileColors!==null&&(t.enableSubSurfaceForPrePass(),t.subSurfaceConfiguration))for(var e=0,n=r.ssDiffusionProfileColors.length;e<n;e++){var i=r.ssDiffusionProfileColors[e];t.subSurfaceConfiguration.addDiffusionProfile(new M.a(i.r,i.g,i.b))}}),Object.defineProperty(_e.a.prototype,"subSurfaceConfiguration",{get:function(){return this._subSurfaceConfiguration},set:function(r){r&&this.enablePrePassRenderer()&&(this._subSurfaceConfiguration=r)},enumerable:!0,configurable:!0}),_e.a.prototype.enableSubSurfaceForPrePass=function(){if(this._subSurfaceConfiguration)return this._subSurfaceConfiguration;var r=this.enablePrePassRenderer();return r?(this._subSurfaceConfiguration=new af(this),r.addEffectConfiguration(this._subSurfaceConfiguration),this._subSurfaceConfiguration):null},_e.a.prototype.disableSubSurfaceForPrePass=function(){this._subSurfaceConfiguration&&(this._subSurfaceConfiguration.dispose(),this._subSurfaceConfiguration=null)};var sf=function(){function r(t){this.name=st.a.NAME_PREPASSRENDERER,this.scene=t}return r.prototype.register=function(){},r.prototype.serialize=function(t){if(this.scene.subSurfaceConfiguration){var e=this.scene.subSurfaceConfiguration.ssDiffusionProfileColors;t.ssDiffusionProfileColors=[];for(var n=0;n<e.length;n++)t.ssDiffusionProfileColors.push({r:e[n].r,g:e[n].g,b:e[n].b})}},r.prototype.addFromContainer=function(t){},r.prototype.removeFromContainer=function(t,e){this.scene.prePassRenderer&&this.scene.subSurfaceConfiguration&&this.scene.subSurfaceConfiguration.clearAllDiffusionProfiles()},r.prototype.rebuild=function(){},r.prototype.dispose=function(){},r}();af._SceneComponentInitialization=function(r){var t=r._getComponent(st.a.NAME_SUBSURFACE);t||(t=new sf(r),r._addComponent(t))};var lv=`#ifdef LOGARITHMICDEPTH
11530#extension GL_EXT_frag_depth : enable
11531#endif
11532uniform vec4 color;
11533#ifdef ALPHATEST
11534varying vec2 vUV;
11535uniform sampler2D diffuseSampler;
11536#endif
11537#include<logDepthDeclaration>
11538void main(void) {
11539#ifdef ALPHATEST
11540if (texture2D(diffuseSampler,vUV).a<0.4)
11541discard;
11542#endif
11543#include<logDepthFragment>
11544gl_FragColor=color;
11545}`;je.a.ShadersStore.outlinePixelShader=lv;var uv=`
11546attribute vec3 position;
11547attribute vec3 normal;
11548#include<bonesDeclaration>
11549#include<morphTargetsVertexGlobalDeclaration>
11550#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
11551
11552uniform float offset;
11553#include<instancesDeclaration>
11554uniform mat4 viewProjection;
11555#ifdef ALPHATEST
11556varying vec2 vUV;
11557uniform mat4 diffuseMatrix;
11558#ifdef UV1
11559attribute vec2 uv;
11560#endif
11561#ifdef UV2
11562attribute vec2 uv2;
11563#endif
11564#endif
11565#include<logDepthDeclaration>
11566void main(void)
11567{
11568vec3 positionUpdated=position;
11569vec3 normalUpdated=normal;
11570#ifdef UV1
11571vec2 uvUpdated=uv;
11572#endif
11573#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
11574vec3 offsetPosition=positionUpdated+(normalUpdated*offset);
11575#include<instancesVertex>
11576#include<bonesVertex>
11577gl_Position=viewProjection*finalWorld*vec4(offsetPosition,1.0);
11578#ifdef ALPHATEST
11579#ifdef UV1
11580vUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));
11581#endif
11582#ifdef UV2
11583vUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
11584#endif
11585#endif
11586#include<logDepthVertex>
11587}
11588`;je.a.ShadersStore.outlineVertexShader=uv,_e.a.prototype.getOutlineRenderer=function(){return this._outlineRenderer||(this._outlineRenderer=new cf(this)),this._outlineRenderer},Object.defineProperty(De.a.prototype,"renderOutline",{get:function(){return this._renderOutline},set:function(r){r&&this.getScene().getOutlineRenderer(),this._renderOutline=r},enumerable:!0,configurable:!0}),Object.defineProperty(De.a.prototype,"renderOverlay",{get:function(){return this._renderOverlay},set:function(r){r&&this.getScene().getOutlineRenderer(),this._renderOverlay=r},enumerable:!0,configurable:!0});var cf=function(){function r(t){this.name=st.a.NAME_OUTLINERENDERER,this.zOffset=1,this.scene=t,this._engine=t.getEngine(),this.scene._addComponent(this)}return r.prototype.register=function(){this.scene._beforeRenderingMeshStage.registerStep(st.a.STEP_BEFORERENDERINGMESH_OUTLINE,this,this._beforeRenderingMesh),this.scene._afterRenderingMeshStage.registerStep(st.a.STEP_AFTERRENDERINGMESH_OUTLINE,this,this._afterRenderingMesh)},r.prototype.rebuild=function(){},r.prototype.dispose=function(){},r.prototype.render=function(t,e,n){var i=this;n===void 0&&(n=!1);var o=this.scene,a=o.getEngine(),s=a.getCaps().instancedArrays&&(e.visibleInstances[t._id]!==null&&e.visibleInstances[t._id]!==void 0||t.getRenderingMesh().hasThinInstances);if(this.isReady(t,s)){var d=t.getMesh(),p=d._internalAbstractMeshDataInfo._actAsRegularMesh?d:null,y=t.getRenderingMesh(),P=p||y,O=t.getMaterial();if(O&&o.activeCamera){if(a.enableEffect(this._effect),O.useLogarithmicDepth&&this._effect.setFloat("logarithmicDepthConstant",2/(Math.log(o.activeCamera.maxZ+1)/Math.LN2)),this._effect.setFloat("offset",n?0:y.outlineWidth),this._effect.setColor4("color",n?y.overlayColor:y.outlineColor,n?y.overlayAlpha:O.alpha),this._effect.setMatrix("viewProjection",o.getTransformMatrix()),this._effect.setMatrix("world",P.getWorldMatrix()),y.useBones&&y.computeBonesUsingShaders&&y.skeleton&&this._effect.setMatrices("mBones",y.skeleton.getTransformMatrices(y)),tt.a.BindMorphTargetParameters(y,this._effect),y._bind(t,this._effect,O.fillMode),O&&O.needAlphaTesting()){var U=O.getAlphaTestTexture();U&&(this._effect.setTexture("diffuseSampler",U),this._effect.setMatrix("diffuseMatrix",U.getTextureMatrix()))}a.setZOffset(-this.zOffset),y._processRendering(P,t,this._effect,O.fillMode,e,s,function(F,z){i._effect.setMatrix("world",z)}),a.setZOffset(0)}}},r.prototype.isReady=function(t,e){var n=[],i=[Me.b.PositionKind,Me.b.NormalKind],o=t.getMesh(),a=t.getMaterial();a&&(a.needAlphaTesting()&&(n.push("#define ALPHATEST"),o.isVerticesDataPresent(Me.b.UVKind)&&(i.push(Me.b.UVKind),n.push("#define UV1")),o.isVerticesDataPresent(Me.b.UV2Kind)&&(i.push(Me.b.UV2Kind),n.push("#define UV2"))),a.useLogarithmicDepth&&n.push("#define LOGARITHMICDEPTH")),o.useBones&&o.computeBonesUsingShaders?(i.push(Me.b.MatricesIndicesKind),i.push(Me.b.MatricesWeightsKind),o.numBoneInfluencers>4&&(i.push(Me.b.MatricesIndicesExtraKind),i.push(Me.b.MatricesWeightsExtraKind)),n.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),n.push("#define BonesPerMesh "+(o.skeleton?o.skeleton.bones.length+1:0))):n.push("#define NUM_BONE_INFLUENCERS 0");var s=o.morphTargetManager,d=0;s&&s.numInfluencers>0&&(d=s.numInfluencers,n.push("#define MORPHTARGETS"),n.push("#define NUM_MORPH_INFLUENCERS "+d),tt.a.PrepareAttributesForMorphTargetsInfluencers(i,o,d)),e&&(n.push("#define INSTANCES"),tt.a.PushAttributesForInstances(i),t.getRenderingMesh().hasThinInstances&&n.push("#define THIN_INSTANCES"));var p=n.join(`
11589`);return this._cachedDefines!==p&&(this._cachedDefines=p,this._effect=this.scene.getEngine().createEffect("outline",i,["world","mBones","viewProjection","diffuseMatrix","offset","color","logarithmicDepthConstant","morphTargetInfluences"],["diffuseSampler"],p,void 0,void 0,void 0,{maxSimultaneousMorphTargets:d})),this._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(h.a.REPLACE),this._engine.setStencilFunction(h.a.ALWAYS),this._engine.setStencilMask(r._StencilReference),this._engine.setStencilFunctionReference(r._StencilReference),this.render(e,n,!0),this._engine.setColorWrite(!0),this._engine.setStencilFunction(h.a.NOTEQUAL)),this._engine.setDepthWrite(!1),this.render(e,n),this._engine.setDepthWrite(this._savedDepthWrite),i&&i.needAlphaBlendingForMesh(t)&&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(h.a.ALPHA_COMBINE),this.render(e,n,!0),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),this._engine.setColorWrite(!0))},r._StencilReference=4,r}(),hv=f(148),lf=function(r){function t(e,n){var i=r.call(this)||this;return i.name=e,i.animations=new Array,i.isPickable=!1,i.useAlphaForPicking=!1,i.onDisposeObservable=new x.c,i._onAnimationEnd=null,i._endAnimation=function(){i._onAnimationEnd&&i._onAnimationEnd(),i.disposeWhenFinishedAnimating&&i.dispose()},i.color=new M.b(1,1,1,1),i.position=u.e.Zero(),i._manager=n,i._manager.sprites.push(i),i.uniqueId=i._manager.scene.getUniqueId(),i}return Object(c.d)(t,r),Object.defineProperty(t.prototype,"size",{get:function(){return this.width}
11589,set:function(e){this.width=e,this.height=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"manager",{get:function(){return this._manager},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"Sprite"},Object.defineProperty(t.prototype,"fromIndex",{get:function(){return this._fromIndex},set:function(e){this.playAnimation(e,this._toIndex,this._loopAnimation,this._delay,this._onAnimationEnd)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"toIndex",{get:function(){return this._toIndex},set:function(e){this.playAnimation(this._fromIndex,e,this._loopAnimation,this._delay,this._onAnimationEnd)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"loopAnimation",{get:function(){return this._loopAnimation},set:function(e){this.playAnimation(this._fromIndex,this._toIndex,e,this._delay,this._onAnimationEnd)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"delay",{get:function(){return Math.max(this._delay,1)},set:function(e){this.playAnimation(this._fromIndex,this._toIndex,this._loopAnimation,e,this._onAnimationEnd)},enumerable:!1,configurable:!0}),t.prototype.playAnimation=function(e,n,i,o,a){a===void 0&&(a=null),this._onAnimationEnd=a,r.prototype.playAnimation.call(this,e,n,i,o,this._endAnimation)},t.prototype.dispose=function(){for(var e=0;e<this._manager.sprites.length;e++)this._manager.sprites[e]==this&&this._manager.sprites.splice(e,1);this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},t.prototype.serialize=function(){var e={};return e.name=this.name,e.position=this.position.asArray(),e.color=this.color.asArray(),e.width=this.width,e.height=this.height,e.angle=this.angle,e.cellIndex=this.cellIndex,e.cellRef=this.cellRef,e.invertU=this.invertU,e.invertV=this.invertV,e.disposeWhenFinishedAnimating=this.disposeWhenFinishedAnimating,e.isPickable=this.isPickable,e.isVisible=this.isVisible,e.useAlphaForPicking=this.useAlphaForPicking,e.animationStarted=this.animationStarted,e.fromIndex=this.fromIndex,e.toIndex=this.toIndex,e.loopAnimation=this.loopAnimation,e.delay=this.delay,e},t.Parse=function(e,n){var i=new t(e.name,n);return i.position=u.e.FromArray(e.position),i.color=M.b.FromArray(e.color),i.width=e.width,i.height=e.height,i.angle=e.angle,i.cellIndex=e.cellIndex,i.cellRef=e.cellRef,i.invertU=e.invertU,i.invertV=e.invertV,i.disposeWhenFinishedAnimating=e.disposeWhenFinishedAnimating,i.isPickable=e.isPickable,i.isVisible=e.isVisible,i.useAlphaForPicking=e.useAlphaForPicking,i.fromIndex=e.fromIndex,i.toIndex=e.toIndex,i.loopAnimation=e.loopAnimation,i.delay=e.delay,e.animationStarted&&i.playAnimation(i.fromIndex,i.toIndex,i.loopAnimation,i.delay),i},t}(function(){function r(){this.width=1,this.height=1,this.angle=0,this.invertU=!1,this.invertV=!1,this.isVisible=!0,this._animationStarted=!1,this._loopAnimation=!1,this._fromIndex=0,this._toIndex=0,this._delay=0,this._direction=1,this._time=0,this._onBaseAnimationEnd=null,this.position={x:1,y:1,z:1},this.color={r:1,g:1,b:1,a:1}}return Object.defineProperty(r.prototype,"animationStarted",{get:function(){return this._animationStarted},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"fromIndex",{get:function(){return this._fromIndex},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"toIndex",{get:function(){return this._toIndex},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"loopAnimation",{get:function(){return this._loopAnimation},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"delay",{get:function(){return Math.max(this._delay,1)},enumerable:!1,configurable:!0}),r.prototype.playAnimation=function(t,e,n,i,o){this._fromIndex=t,this._toIndex=e,this._loopAnimation=n,this._delay=i||1,this._animationStarted=!0,this._onBaseAnimationEnd=o,t<e?this._direction=1:(this._direction=-1,this._toIndex=t,this._fromIndex=e),this.cellIndex=t,this._time=0},r.prototype.stopAnimation=function(){this._animationStarted=!1},r.prototype._animate=function(t){this._animationStarted&&(this._time+=t,this._time>this._delay&&(this._time=this._time%this._delay,this.cellIndex+=this._direction,(this._direction>0&&this.cellIndex>this._toIndex||this._direction<0&&this.cellIndex<this._fromIndex)&&(this._loopAnimation?this.cellIndex=this._direction>0?this._fromIndex:this._toIndex:(this.cellIndex=this._toIndex,this._animationStarted=!1,this._onBaseAnimationEnd&&this._onBaseAnimationEnd()))))},r}());_e.a.prototype._internalPickSprites=function(r,t,e,n){if(!tr.a)return null;var i=null;if(!n){if(!this.activeCamera)return null;n=this.activeCamera}if(this.spriteManagers.length>0)for(var o=0;o<this.spriteManagers.length;o++){var a=this.spriteManagers[o];if(a.isPickable){var s=a.intersects(r,n,t,e);if(s&&s.hit&&(e||i==null||!(s.distance>=i.distance))&&(i=s,e))break}}return i||new tr.a},_e.a.prototype._internalMultiPickSprites=function(r,t,e){if(!tr.a)return null;var n=new Array;
11589if(!e){if(!this.activeCamera)return null;e=this.activeCamera}if(this.spriteManagers.length>0)for(var i=0;i<this.spriteManagers.length;i++){var o=this.spriteManagers[i];if(o.isPickable){var a=o.multiIntersects(r,e,t);a!==null&&(n=n.concat(a))}}return n},_e.a.prototype.pickSprite=function(r,t,e,n,i){return this._tempSpritePickingRay?(this.createPickingRayInCameraSpaceToRef(r,t,this._tempSpritePickingRay,i),this._internalPickSprites(this._tempSpritePickingRay,e,n,i)):null},_e.a.prototype.pickSpriteWithRay=function(r,t,e,n){if(!this._tempSpritePickingRay)return null;if(!n){if(!this.activeCamera)return null;n=this.activeCamera}return dn.a.TransformToRef(r,n.getViewMatrix(),this._tempSpritePickingRay),this._internalPickSprites(this._tempSpritePickingRay,t,e,n)},_e.a.prototype.multiPickSprite=function(r,t,e,n){return this.createPickingRayInCameraSpaceToRef(r,t,this._tempSpritePickingRay,n),this._internalMultiPickSprites(this._tempSpritePickingRay,e,n)},_e.a.prototype.multiPickSpriteWithRay=function(r,t,e){if(!this._tempSpritePickingRay)return null;if(!e){if(!this.activeCamera)return null;e=this.activeCamera}return dn.a.TransformToRef(r,e.getViewMatrix(),this._tempSpritePickingRay),this._internalMultiPickSprites(this._tempSpritePickingRay,t,e)},_e.a.prototype.setPointerOverSprite=function(r){this._pointerOverSprite!==r&&(this._pointerOverSprite&&this._pointerOverSprite.actionManager&&this._pointerOverSprite.actionManager.processTrigger(h.a.ACTION_OnPointerOutTrigger,m.a.CreateNewFromSprite(this._pointerOverSprite,this)),this._pointerOverSprite=r,this._pointerOverSprite&&this._pointerOverSprite.actionManager&&this._pointerOverSprite.actionManager.processTrigger(h.a.ACTION_OnPointerOverTrigger,m.a.CreateNewFromSprite(this._pointerOverSprite,this)))},_e.a.prototype.getPointerOverSprite=function(){return this._pointerOverSprite};var uf=function(){function r(t){this.name=st.a.NAME_SPRITE,this.scene=t,this.scene.spriteManagers=new Array,this.scene._tempSpritePickingRay=dn.a?dn.a.Zero():null,this.scene.onBeforeSpritesRenderingObservable=new x.c,this.scene.onAfterSpritesRenderingObservable=new x.c,this._spritePredicate=function(e){return!!e.actionManager&&e.isPickable&&e.actionManager.hasPointerTriggers}}return r.prototype.register=function(){this.scene._pointerMoveStage.registerStep(st.a.STEP_POINTERMOVE_SPRITE,this,this._pointerMove),this.scene._pointerDownStage.registerStep(st.a.STEP_POINTERDOWN_SPRITE,this,this._pointerDown),this.scene._pointerUpStage.registerStep(st.a.STEP_POINTERUP_SPRITE,this,this._pointerUp)},r.prototype.rebuild=function(){},r.prototype.dispose=function(){this.scene.onBeforeSpritesRenderingObservable.clear(),this.scene.onAfterSpritesRenderingObservable.clear();for(var t=this.scene.spriteManagers;t.length;)t[0].dispose()},r.prototype._pickSpriteButKeepRay=function(t,e,n,i,o){var a=this.scene.pickSprite(e,n,this._spritePredicate,i,o);return a&&(a.ray=t?t.ray:null),a},r.prototype._pointerMove=function(t,e,n,i,o){var a=this.scene;return i?a.setPointerOverSprite(null):(n=this._pickSpriteButKeepRay(n,t,e,!1,a.cameraToUseForPointers||void 0))&&n.hit&&n.pickedSprite?(a.setPointerOverSprite(n.pickedSprite),a.doNotHandleCursors||(a._pointerOverSprite&&a._pointerOverSprite.actionManager&&a._pointerOverSprite.actionManager.hoverCursor?o.style.cursor=a._pointerOverSprite.actionManager.hoverCursor:o.style.cursor=a.hoverCursor)):a.setPointerOverSprite(null),n},r.prototype._pointerDown=function(t,e,n,i){var o=this.scene;if(o._pickedDownSprite=null,o.spriteManagers.length>0&&(n=o.pickSprite(t,e,this._spritePredicate,!1,o.cameraToUseForPointers||void 0))&&n.hit&&n.pickedSprite&&n.pickedSprite.actionManager){switch(o._pickedDownSprite=n.pickedSprite,i.button){case 0:n.pickedSprite.actionManager.processTrigger(h.a.ACTION_OnLeftPickTrigger,m.a.CreateNewFromSprite(n.pickedSprite,o,i));break;case 1:n.pickedSprite.actionManager.processTrigger(h.a.ACTION_OnCenterPickTrigger,m.a.CreateNewFromSprite(n.pickedSprite,o,i));break;case 2:n.pickedSprite.actionManager.processTrigger(h.a.ACTION_OnRightPickTrigger,m.a.CreateNewFromSprite(n.pickedSprite,o,i))}n.pickedSprite.actionManager&&n.pickedSprite.actionManager.processTrigger(h.a.ACTION_OnPickDownTrigger,m.a.CreateNewFromSprite(n.pickedSprite,o,i))}return n},r.prototype._pointerUp=function(t,e,n,i){var o=this.scene;if(o.spriteManagers.length>0){var a=o.pickSprite(t,e,this._spritePredicate,!1,o.cameraToUseForPointers||void 0);a&&(a.hit&&a.pickedSprite&&a.pickedSprite.actionManager&&(a.pickedSprite.actionManager.processTrigger(h.a.ACTION_OnPickUpTrigger,m.a.CreateNewFromSprite(a.pickedSprite,o,i)),a.pickedSprite.actionManager&&(this.scene._inputManager._isPointerSwiping()||a.pickedSprite.actionManager.processTrigger(h.a.ACTION_OnPickTrigger,m.a.CreateNewFromSprite(a.pickedSprite,o,i)))),o._pickedDownSprite&&o._pickedDownSprite.actionManager&&o._pickedDownSprite!==a.pickedSprite&&o._pickedDownSprite.actionManager.processTrigger(h.a.ACTION_OnPickOutTrigger,m.a.CreateNewFromSprite(o._pickedDownSprite,o,i)))}return n},r}();je.a.IncludesShadersStore.imageProcessingCompatibility=`#ifdef IMAGEPROCESSINGPOSTPROCESS
11590gl_FragColor.rgb=pow(gl_FragColor.rgb,vec3(2.2));
11591#endif`;var dv=`uniform bool alphaTest;
11592varying vec4 vColor;
11593
11594varying vec2 vUV;
11595uniform sampler2D diffuseSampler;
11596
11597#include<fogFragmentDeclaration>
11598void main(void) {
11599vec4 color=texture2D(diffuseSampler,vUV);
11600if (alphaTest)
11601{
11602if (color.a<0.95)
11603discard;
11604}
11605color*=vColor;
11606#include<fogFragment>
11607gl_FragColor=color;
11608#include<imageProcessingCompatibility>
11609}`;je.a.ShadersStore.spritesPixelShader=dv;var fv=`
11610attribute vec4 position;
11611attribute vec2 options;
11612attribute vec2 offsets;
11613attribute vec2 inverts;
11614attribute vec4 cellInfo;
11615attribute vec4 color;
11616
11617uniform mat4 view;
11618uniform mat4 projection;
11619
11620varying vec2 vUV;
11621varying vec4 vColor;
11622#include<fogVertexDeclaration>
11623void main(void) {
11624vec3 viewPos=(view*vec4(position.xyz,1.0)).xyz;
11625vec2 cornerPos;
11626float angle=position.w;
11627vec2 size=vec2(options.x,options.y);
11628vec2 offset=offsets.xy;
11629cornerPos=vec2(offset.x-0.5,offset.y-0.5)*size;
11630
11631vec3 rotatedCorner;
11632rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
11633rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
11634rotatedCorner.z=0.;
11635
11636viewPos+=rotatedCorner;
11637gl_Position=projection*vec4(viewPos,1.0);
11638
11639vColor=color;
11640
11641vec2 uvOffset=vec2(abs(offset.x-inverts.x),abs(1.0-offset.y-inverts.y));
11642vec2 uvPlace=cellInfo.xy;
11643vec2 uvSize=cellInfo.zw;
11644vUV.x=uvPlace.x+uvSize.x*uvOffset.x;
11645vUV.y=uvPlace.y+uvSize.y*uvOffset.y;
11646
11647#ifdef FOG
11648vFogDistance=viewPos;
11649#endif
11650}`;
11650je.a.ShadersStore.spritesVertexShader=fv;var pv=function(){function r(t,e,n,i){if(n===void 0&&(n=.01),i===void 0&&(i=null),this.blendMode=h.a.ALPHA_COMBINE,this.autoResetAlpha=!0,this.disableDepthWrite=!1,this.fogEnabled=!0,this._useVAO=!1,this._useInstancing=!1,this._vertexBuffers={},this._capacity=e,this._epsilon=n,this._engine=t,this._useInstancing=t.getCaps().instancedArrays,this._useVAO=t.getCaps().vertexArrayObject&&!t.disableVertexArrayObjects,this._scene=i,!this._useInstancing){for(var o=[],a=0,s=0;s<e;s++)o.push(a),o.push(a+1),o.push(a+2),o.push(a),o.push(a+2),o.push(a+3),a+=4;this._indexBuffer=t.createIndexBuffer(o)}this._vertexBufferSize=this._useInstancing?16:18,this._vertexData=new Float32Array(e*this._vertexBufferSize*(this._useInstancing?1:4)),this._buffer=new Me.a(t,this._vertexData,!0,this._vertexBufferSize);var d,p=this._buffer.createVertexBuffer(Me.b.PositionKind,0,4,this._vertexBufferSize,this._useInstancing),y=this._buffer.createVertexBuffer("options",4,2,this._vertexBufferSize,this._useInstancing),P=6;if(this._useInstancing){var O=new Float32Array([0,0,1,0,1,1,0,1]);this._spriteBuffer=new Me.a(t,O,!1,2),d=this._spriteBuffer.createVertexBuffer("offsets",0,2)}else d=this._buffer.createVertexBuffer("offsets",P,2,this._vertexBufferSize,this._useInstancing),P+=2;var U=this._buffer.createVertexBuffer("inverts",P,2,this._vertexBufferSize,this._useInstancing),F=this._buffer.createVertexBuffer("cellInfo",P+2,4,this._vertexBufferSize,this._useInstancing),z=this._buffer.createVertexBuffer(Me.b.ColorKind,P+6,4,this._vertexBufferSize,this._useInstancing);this._vertexBuffers[Me.b.PositionKind]=p,this._vertexBuffers.options=y,this._vertexBuffers.offsets=d,this._vertexBuffers.inverts=U,this._vertexBuffers.cellInfo=F,this._vertexBuffers[Me.b.ColorKind]=z,this._effectBase=this._engine.createEffect("sprites",[Me.b.PositionKind,"options","offsets","inverts","cellInfo",Me.b.ColorKind],["view","projection","textureInfos","alphaTest"],["diffuseSampler"],""),this._scene&&(this._effectFog=this._scene.getEngine().createEffect("sprites",[Me.b.PositionKind,"options","offsets","inverts","cellInfo",Me.b.ColorKind],["view","projection","textureInfos","alphaTest","vFogInfos","vFogColor"],["diffuseSampler"],"#define FOG"))}return Object.defineProperty(r.prototype,"capacity",{get:function(){return this._capacity},enumerable:!1,configurable:!0}),r.prototype.render=function(t,e,n,i,o){if(o===void 0&&(o=null),this.texture&&this.texture.isReady()&&t.length){var a=this._effectBase,s=!1;if(this.fogEnabled&&this._scene&&this._scene.fogEnabled&&this._scene.fogMode!==0&&(a=this._effectFog,s=!0),a.isReady()){for(var d=this._engine,p=!(!this._scene||!this._scene.useRightHandedSystem),y=this.texture.getBaseSize(),P=Math.min(this._capacity,t.length),O=0,U=!0,F=0;F<P;F++){var z=t[F];z&&z.isVisible&&(U=!1,z._animate(e),this._appendSpriteVertex(O++,z,0,0,y,p,o),this._useInstancing||(this._appendSpriteVertex(O++,z,1,0,y,p,o),this._appendSpriteVertex(O++,z,1,1,y,p,o),this._appendSpriteVertex(O++,z,0,1,y,p,o)))}if(!U){this._buffer.update(this._vertexData);var J=d.depthCullingState.cull||!0,ie=d.depthCullingState.zOffset;if(p&&this._scene.getEngine().setState(J,ie,!1,!1),d.enableEffect(a),a.setTexture("diffuseSampler",this.texture),a.setMatrix("view",n),a.setMatrix("projection",i),s){var se=this._scene;a.setFloat4("vFogInfos",se.fogMode,se.fogStart,se.fogEnd,se.fogDensity),a.setColor3("vFogColor",se.fogColor)}this._useVAO?(this._vertexArrayObject||(this._vertexArrayObject=d.recordVertexArrayObject(this._vertexBuffers,this._indexBuffer,a)),d.bindVertexArrayObject(this._vertexArrayObject,this._indexBuffer)):d.bindBuffers(this._vertexBuffers,this._indexBuffer,a),d.depthCullingState.depthFunc=h.a.LEQUAL,this.disableDepthWrite||(a.setBool("alphaTest",!0),d.setColorWrite(!1),this._useInstancing?d.drawArraysType(h.a.MATERIAL_TriangleFanDrawMode,0,4,O):d.drawElementsType(h.a.MATERIAL_TriangleFillMode,0,O/4*6),d.setColorWrite(!0),a.setBool("alphaTest",!1)),d.setAlphaMode(this.blendMode),this._useInstancing?d.drawArraysType(h.a.MATERIAL_TriangleFanDrawMode,0,4,O):d.drawElementsType(h.a.MATERIAL_TriangleFillMode,0,O/4*6),this.autoResetAlpha&&d.setAlphaMode(h.a.ALPHA_DISABLE),p&&this._scene.getEngine().setState(J,ie,!1,!0),d.unbindInstanceAttributes()}}}},r.prototype._appendSpriteVertex=function(t,e,n,i,o,a,s){var d=t*this._vertexBufferSize;if(n===0?n=this._epsilon:n===1&&(n=1-this._epsilon),i===0?i=this._epsilon:i===1&&(i=1-this._epsilon),s)s(e,o);else{e.cellIndex||(e.cellIndex=0);var p=o.width/this.cellWidth,y=e.cellIndex/p>>0;e._xOffset=(e.cellIndex-y*p)*this.cellWidth/o.width,e._yOffset=y*this.cellHeight/o.height,e._xSize=this.cellWidth,e._ySize=this.cellHeight}this._vertexData[d]=e.position.x,this._vertexData[d+1]=e.position.y,this._vertexData[d+2]=e.position.z,this._vertexData[d+3]=e.angle,this._vertexData[d+4]=e.width,this._vertexData[d+5]=e.he
11650ight,this._useInstancing?d-=2:(this._vertexData[d+6]=n,this._vertexData[d+7]=i),this._vertexData[d+8]=a?e.invertU?0:1:e.invertU?1:0,this._vertexData[d+9]=e.invertV?1:0,this._vertexData[d+10]=e._xOffset,this._vertexData[d+11]=e._yOffset,this._vertexData[d+12]=e._xSize/o.width,this._vertexData[d+13]=e._ySize/o.height,this._vertexData[d+14]=e.color.r,this._vertexData[d+15]=e.color.g,this._vertexData[d+16]=e.color.b,this._vertexData[d+17]=e.color.a},r.prototype.dispose=function(){this._buffer&&(this._buffer.dispose(),this._buffer=null),this._spriteBuffer&&(this._spriteBuffer.dispose(),this._spriteBuffer=null),this._indexBuffer&&(this._engine._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this._vertexArrayObject&&(this._engine.releaseVertexArrayObject(this._vertexArrayObject),this._vertexArrayObject=null),this.texture&&(this.texture.dispose(),this.texture=null)},r}(),hf=function(){function r(t,e,n,i,o,a,s,d,p){var y=this;a===void 0&&(a=.01),s===void 0&&(s=we.a.TRILINEAR_SAMPLINGMODE),d===void 0&&(d=!1),p===void 0&&(p=null),this.name=t,this.sprites=new Array,this.renderingGroupId=0,this.layerMask=268435455,this.isPickable=!1,this.onDisposeObservable=new x.c,this.disableDepthWrite=!1,this._packedAndReady=!1,this._customUpdate=function(O,U){O.cellRef||(O.cellIndex=0);var F=O.cellIndex;typeof F=="number"&&isFinite(F)&&Math.floor(F)===F&&(O.cellRef=y._spriteMap[O.cellIndex]),O._xOffset=y._cellData[O.cellRef].frame.x/U.width,O._yOffset=y._cellData[O.cellRef].frame.y/U.height,O._xSize=y._cellData[O.cellRef].frame.w,O._ySize=y._cellData[O.cellRef].frame.h},o||(o=Ue.a.LastCreatedScene),o._getComponent(st.a.NAME_SPRITE)||o._addComponent(new uf(o)),this._fromPacked=d,this._scene=o;var P=this._scene.getEngine();if(this._spriteRenderer=new pv(P,n,a,o),i.width&&i.height)this.cellWidth=i.width,this.cellHeight=i.height;else{if(i===void 0)return void(this._spriteRenderer=null);this.cellWidth=i,this.cellHeight=i}this._scene.spriteManagers.push(this),this.uniqueId=this.scene.getUniqueId(),e&&(this.texture=new we.a(e,o,!0,!1,s)),this._fromPacked&&this._makePacked(e,p)}return Object.defineProperty(r.prototype,"onDispose",{set:function(t){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"children",{get:function(){return this.sprites},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"capacity",{get:function(){return this._spriteRenderer.capacity},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"texture",{get:function(){return this._spriteRenderer.texture},set:function(t){t.wrapU=we.a.CLAMP_ADDRESSMODE,t.wrapV=we.a.CLAMP_ADDRESSMODE,this._spriteRenderer.texture=t,this._textureContent=null},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"cellWidth",{get:function(){return this._spriteRenderer.cellWidth},set:function(t){this._spriteRenderer.cellWidth=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"cellHeight",{get:function(){return this._spriteRenderer.cellHeight},set:function(t){this._spriteRenderer.cellHeight=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"fogEnabled",{get:function(){return this._spriteRenderer.fogEnabled},set:function(t){this._spriteRenderer.fogEnabled=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"blendMode",{get:function(){return this._spriteRenderer.blendMode},set:function(t){this._spriteRenderer.blendMode=t},enumerable:!1,configurable:!0}),r.prototype.getClassName=function(){return"SpriteManager"},r.prototype._makePacked=function(t,e){var n=this;if(e!==null)try{var i=void 0;if((i=typeof e=="string"?JSON.parse(e):e).frames.length){for(var o={},a=0;a<i.frames.length;a++){var s=i.frames[a];if(typeof Object.keys(s)[0]!="string")throw new Error("Invalid JSON Format.  Check the frame values and make sure the name is the first parameter.");o[s[Object.keys(s)[0]]]=s}i.frames=o}var d=Reflect.ownKeys(i.frames);this._spriteMap=d,this._packedAndReady=!0,this._cellData=i.frames}catch{throw this._fromPacked=!1,this._packedAndReady=!1,new Error("Invalid JSON from string. Spritesheet managed with constant cell size.")}else{var p=/\./g,y=void 0;do y=p.lastIndex,p.test(t);while(p.lastIndex>0);var P=t.substring(0,y-1)+".json",O=new XMLHttpRequest;O.open("GET",P,!0),O.onerror=function(){l.a.Error("JSON ERROR: Unable to load JSON file."),n._fromPacked=!1,n._packedAndReady=!1},O.onload=function(){try{var U=JSON.parse(O.response),F=Reflect.ownKeys(U.frames);n._spriteMap=F,n._packedAndReady=!0,n._cellData=U.frames}catch{throw n._fromPacked=!1,n._packedAndReady=!1,new Error("Invalid JSON format. Please check documentation for format specifications.")}},O.send()}},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=u.c.Vector3[0];s.copyFrom(e.direction),s.normalize(),s.scaleInPlace(n),s.addInPlace(e.origin);var d=(s.x-i.x)/(o.x-i.x)-.5,p=1-(s.y-i.y)/(o.y-i.y)-.5,y=t.angle,P=d*Math.cos(y)-p*Math.sin(y)+.5,O=d*Math.sin(y)+p*Math.cos(y)+.5,U=t._xOffset*a.width+P*t._xSize|0,F=t._yOffset*a.height+O*t._ySize|0;
11650return this._textureContent[4*(U+F*a.width)+3]>.5},r.prototype.intersects=function(t,e,n,i){for(var o=Math.min(this.capacity,this.sprites.length),a=u.e.Zero(),s=u.e.Zero(),d=Number.MAX_VALUE,p=null,y=u.c.Vector3[0],P=u.c.Vector3[1],O=e.getViewMatrix(),U=0;U<o;U++){var F=this.sprites[U];if(F){if(n){if(!n(F))continue}else if(!F.isPickable)continue;if(u.e.TransformCoordinatesToRef(F.position,O,P),a.copyFromFloats(P.x-F.width/2,P.y-F.height/2,P.z),s.copyFromFloats(P.x+F.width/2,P.y+F.height/2,P.z),t.intersectsBoxMinMax(a,s)){var z=u.e.Distance(P,t.origin);if(d>z){if(!this._checkTextureAlpha(F,t,z,a,s))continue;if(d=z,p=F,i)break}}}}if(p){var J=new tr.a;O.invertToRef(u.c.Matrix[0]),J.hit=!0,J.pickedSprite=p,J.distance=d;var ie=u.c.Vector3[2];return ie.copyFrom(t.direction),ie.normalize(),ie.scaleInPlace(d),t.origin.addToRef(ie,y),J.pickedPoint=u.e.TransformCoordinates(y,u.c.Matrix[0]),J}return null},r.prototype.multiIntersects=function(t,e,n){for(var i,o=Math.min(this.capacity,this.sprites.length),a=u.e.Zero(),s=u.e.Zero(),d=[],p=u.c.Vector3[0].copyFromFloats(0,0,0),y=u.c.Vector3[1].copyFromFloats(0,0,0),P=e.getViewMatrix(),O=0;O<o;O++){var U=this.sprites[O];if(U){if(n){if(!n(U))continue}else if(!U.isPickable)continue;if(u.e.TransformCoordinatesToRef(U.position,P,y),a.copyFromFloats(y.x-U.width/2,y.y-U.height/2,y.z),s.copyFromFloats(y.x+U.width/2,y.y+U.height/2,y.z),t.intersectsBoxMinMax(a,s)){if(i=u.e.Distance(y,t.origin),!this._checkTextureAlpha(U,t,i,a,s))continue;var F=new tr.a;d.push(F),P.invertToRef(u.c.Matrix[0]),F.hit=!0,F.pickedSprite=U,F.distance=i;var z=u.c.Vector3[2];z.copyFrom(t.direction),z.normalize(),z.scaleInPlace(i),t.origin.addToRef(z,p),F.pickedPoint=u.e.TransformCoordinates(p,u.c.Matrix[0])}}}return d},r.prototype.render=function(){if(!this._fromPacked||this._packedAndReady&&this._spriteMap&&this._cellData){var t=this._scene.getEngine().getDeltaTime();this._packedAndReady?this._spriteRenderer.render(this.sprites,t,this._scene.getViewMatrix(),this._scene.getProjectionMatrix(),this._customUpdate):this._spriteRenderer.render(this.sprites,t,this._scene.getViewMatrix(),this._scene.getProjectionMatrix())}},r.prototype.dispose=function(){this._spriteRenderer&&(this._spriteRenderer.dispose(),this._spriteRenderer=null),this._textureContent=null;var t=this._scene.spriteManagers.indexOf(this);this._scene.spriteManagers.splice(t,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},r.prototype.serialize=function(t){t===void 0&&(t=!1);var e={};e.name=this.name,e.capacity=this.capacity,e.cellWidth=this.cellWidth,e.cellHeight=this.cellHeight,this.texture&&(t?e.texture=this.texture.serialize():(e.textureUrl=this.texture.name,e.invertY=this.texture._invertY)),e.sprites=[];for(var n=0,i=this.sprites;n<i.length;n++){var o=i[n];e.sprites.push(o.serialize())}return e},r.Parse=function(t,e,n){var i=new r(t.name,"",t.capacity,{width:t.cellWidth,height:t.cellHeight},e);t.texture?i.texture=we.a.Parse(t.texture,e,n):t.textureName&&(i.texture=new we.a(n+t.textureUrl,e,!1,t.invertY===void 0||t.invertY));for(var o=0,a=t.sprites;o<a.length;o++){var s=a[o];lf.Parse(s,i)}return i},r.ParseFromFileAsync=function(t,e,n,i){return i===void 0&&(i=""),new Promise(function(o,a){var s=new re.a;s.addEventListener("readystatechange",function(){if(s.readyState==4)if(s.status==200){var d=JSON.parse(s.responseText),p=r.Parse(d,n||Ue.a.LastCreatedScene,i);t&&(p.name=t),o(p)}else a("Unable to load the sprite manager")}),s.open("GET",e),s.send()})},r.CreateFromSnippetAsync=function(t,e,n){var i=this;return n===void 0&&(n=""),t==="_BLANK"?Promise.resolve(new r("Default sprite manager","//playground.babylonjs.com/textures/player.png",500,64,e)):new Promise(function(o,a){var s=new re.a;s.addEventListener("readystatechange",function(){if(s.readyState==4)if(s.status==200){var d=JSON.parse(JSON.parse(s.responseText).jsonPayload),p=JSON.parse(d.spriteManager),y=r.Parse(p,e||Ue.a.LastCreatedScene,n);y.snippetId=t,o(y)}else a("Unable to load the snippet "+t)}),s.open("GET",i.SnippetUrl+"/"+t.replace(/#/g,"/")),s.send()})},r.SnippetUrl="https://snippet.babylonjs.com",r}(),_v=`precision highp float;
11651varying vec3 vPosition;
11652varying vec2 vUV;
11653varying vec2 tUV;
11654uniform float time;
11655uniform float spriteCount;
11656uniform sampler2D spriteSheet;
11657uniform vec2 spriteMapSize;
11658uniform vec2 outputSize;
11659uniform vec2 stageSize;
11660uniform sampler2D frameMap;
11661uniform sampler2D tileMaps[LAYERS];
11662uniform sampler2D animationMap;
11663uniform vec3 colorMul;
11664float mt;
11665const float fdStep=1./4.;
11666const float aFrameSteps=1./MAX_ANIMATION_FRAMES;
11667mat4 getFrameData(float frameID){
11668float fX=frameID/spriteCount;
11669return mat4(
11670texture2D(frameMap,vec2(fX,0.),0.),
11671texture2D(frameMap,vec2(fX,fdStep*1.),0.),
11672texture2D(frameMap,vec2(fX,fdStep*2.),0.),
11673vec4(0.)
11674);
11675}
11676void main(){
11677vec4 color=vec4(0.);
11678vec2 tileUV=fract(tUV);
11679#ifdef FLIPU
11680tileUV.y=1.0-tileUV.y;
11681#endif
11682vec2 tileID=floor(tUV);
11683vec2 sheetUnits=1./spriteMapSize;
11684float spriteUnits=1./spriteCount;
11685vec2 stageUnits=1./stageSize;
11686for(int i=0; i<LAYERS; i++) {
11687float frameID;
11688#define LAYER_ID_SWITCH
11689vec4 animationData=texture2D(animationMap,vec2((frameID+0.5)/spriteCount,0.),0.);
11690if(animationData.y>0.) {
11691mt=mod(time*animationData.z,1.0);
11692for(float f=0.; f<MAX_ANIMATION_FRAMES; f++){
11693if(animationData.y>mt){
11694frameID=animationData.x;
11695break;
11696}
11697animationData=texture2D(animationMap,vec2((frameID+0.5)/spriteCount,aFrameSteps*f),0.);
11698}
11699}
11700
11701mat4 frameData=getFrameData(frameID+0.5);
11702vec2 frameSize=(frameData[0].wz)/spriteMapSize;
11703vec2 offset=frameData[0].xy*sheetUnits;
11704vec2 ratio=frameData[2].xy/frameData[0].wz;
11705
11706if (frameData[2].z == 1.){
11707tileUV.xy=tileUV.yx;
11708}
11709if (i == 0){
11710color=texture2D(spriteSheet,tileUV*frameSize+offset);
11711} else {
11712vec4 nc=texture2D(spriteSheet,tileUV*frameSize+offset);
11713float alpha=min(color.a+nc.a,1.0);
11714vec3 mixed=mix(color.xyz,nc.xyz,nc.a);
11715color=vec4(mixed,alpha);
11716}
11717}
11718color.xyz*=colorMul;
11719gl_FragColor=color;
11720}`;je.a.ShadersStore.spriteMapPixelShader=_v;var mv=`precision highp float;
11721
11722attribute vec3 position;
11723attribute vec3 normal;
11724attribute vec2 uv;
11725
11726varying vec3 vPosition;
11727varying vec2 vUV;
11728varying vec2 tUV;
11729varying vec2 stageUnits;
11730varying vec2 levelUnits;
11731varying vec2 tileID;
11732
11733uniform float time;
11734uniform mat4 worldViewProjection;
11735uniform vec2 outputSize;
11736uniform vec2 stageSize;
11737uniform vec2 spriteMapSize;
11738uniform float stageScale;
11739void main() {
11740vec4 p=vec4( position,1. );
11741vPosition=p.xyz;
11742vUV=uv;
11743tUV=uv*stageSize;
11744gl_Position=worldViewProjection*p;
11745}`;je.a.ShadersStore.spriteMapVertexShader=mv;var di,gv=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 u.d(1,1),i.outputSize=i.outputSize||i.stageSize,i.outputPosition=i.outputPosition||u.e.Zero(),i.outputRotation=i.outputRotation||u.e.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 u.e(1,1,1),this._scene=o,this._frameMap=this._createFrameBuffer(),this._tileMaps=new Array;for(var s=0;s<i.layerCount;s++)this._tileMaps.push(this._createTileBuffer(null,s));this._animationMap=this._createTileAnimationBuffer(null);var d=[];d.push("#define LAYERS "+i.layerCount),i.flipU&&d.push("#define FLIPU"),d.push("#define MAX_ANIMATION_FRAMES "+i.maxAnimationFrames+".0");var p,y=je.a.ShadersStore.spriteMapPixelShader;if(this._scene.getEngine().webGLVersion===1)for(p="",s=0;s<i.layerCount;s++)p+="if ("+s+" == i) { frameID = texture2D(tileMaps["+s+"], (tileID + 0.5) / stageSize, 0.).x; }";else{for(p="switch(i) {",s=0;s<i.layerCount;s++)p+="case "+s+" : frameID = texture(tileMaps["+s+"], (tileID + 0.5) / stageSize, 0.).x;",p+="break;";p+="}"}je.a.ShadersStore["spriteMap"+this.name+"PixelShader"]=y.replace("#define LAYER_ID_SWITCH",p),this._material=new fa.a("spriteMap:"+this.name,this._scene,{vertex:"spriteMap",fragment:"spriteMap"+this.name},{defines:d,attributes:["position","normal","uv"],uniforms:["worldViewProjection","time","stageSize","outputSize","spriteMapSize","spriteCount","time","colorMul","mousePosition","curTile","flipU"],samplers:["spriteSheet","frameMap","tileMaps","animationMap"],needAlphaBlending:!0}),this._time=0,this._material.setFloat("spriteCount",this.spriteCount),this._material.setVector2("stageSize",i.stageSize),this._material.setVector2("outputSize",i.outputSize),this._material.setTexture("spriteSheet",this.spriteSheet),this._material.setVector2("spriteMapSize",new u.d(1,1)),this._material.setVector3("colorMul",i.colorMultiply);var P=0,O=function(){a.spriteSheet&&a.spriteSheet.isReady()&&a.spriteSheet._texture?a._material.setVector2("spriteMapSize",new u.d(a.spriteSheet._texture.baseWidth||1,a.spriteSheet._texture.baseHeight||1)):P<100&&setTimeout(function(){P++,O()},100)};O(),this._material.setVector3("colorMul",i.colorMultiply),this._material.setTexture("frameMap",this._frameMap),this._material.setTextureArray("tileMaps",this._tileMaps),this._material.setTexture("animationMap",this._animationMap),this._material.setFloat("time",this._time),this._output=De.a.CreatePlane(t+":output",1,o,!0),this._output.scaling.x=i.outputSize.x,this._output.scaling.y=i.outputSize.y,this.position=i.outputPosition,this.rotation=i.outputRotation,this._scene.onBeforeRenderObservable.add(function(){a._time+=a._scene.getEngine().getDeltaTime(),a._material.setFloat("time",a._time)}),this._output.material=this._material}return Object.defineProperty(r.prototype,"spriteCount",{get:function(){return this.sprites.length}
11745,enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"position",{get:function(){return this._output.position},set:function(t){this._output.position=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"rotation",{get:function(){return this._output.rotation},set:function(t){this._output.rotation=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"animationMap",{get:function(){return this._animationMap},set:function(t){var e=t._texture._bufferView,n=this._createTileAnimationBuffer(e);this._animationMap.dispose(),this._animationMap=n,this._material.setTexture("animationMap",this._animationMap)},enumerable:!1,configurable:!0}),r.prototype.getTileID=function(){var t=this.getMousePosition();return t.multiplyInPlace(this.options.stageSize||u.d.Zero()),t.x=Math.floor(t.x),t.y=Math.floor(t.y),t},r.prototype.getMousePosition=function(){var t=this._output,e=this._scene.pick(this._scene.pointerX,this._scene.pointerY,function(i){return i===t});if(!e||!e.hit||!e.getTextureCoordinates)return new u.d(-1,-1);var n=e.getTextureCoordinates();return n||new u.d(-1,-1)},r.prototype._createFrameBuffer=function(){for(var t=new Array,e=0;e<this.spriteCount;e++)t.push(0,0,0,0),t.push(0,0,0,0),t.push(0,0,0,0),t.push(0,0,0,0);for(e=0;e<this.spriteCount;e++){var n=this.sprites[e].frame,i=this.sprites[e].spriteSourceSize,o=this.sprites[e].sourceSize,a=this.sprites[e].rotated?1:0,s=this.sprites[e].trimmed?1:0;t[4*e]=n.x,t[4*e+1]=n.y,t[4*e+2]=n.w,t[4*e+3]=n.h,t[4*e+4*this.spriteCount]=i.x,t[4*e+1+4*this.spriteCount]=i.y,t[4*e+3+4*this.spriteCount]=i.h,t[4*e+8*this.spriteCount]=o.w,t[4*e+1+8*this.spriteCount]=o.h,t[4*e+2+8*this.spriteCount]=a,t[4*e+3+8*this.spriteCount]=s}var d=new Float32Array(t);return $n.CreateRGBATexture(d,this.spriteCount,4,this._scene,!1,!1,we.a.NEAREST_NEAREST,Ue.a.TEXTURETYPE_FLOAT)},r.prototype._createTileBuffer=function(t,e){e===void 0&&(e=0);var n=new Array,i=this.options.stageSize.y||0,o=this.options.stageSize.x||0;if(t)n=t;else{var a=this.options.baseTile;e!=0&&(a=0);for(var s=0;s<i;s++)for(var d=0;d<4*o;d+=4)n.push(a,0,0,0)}var p=new Float32Array(n);return $n.CreateRGBATexture(p,o,i,this._scene,!1,!1,we.a.NEAREST_NEAREST,Ue.a.TEXTURETYPE_FLOAT)},r.prototype.changeTiles=function(t,e,n){var i;if(t===void 0&&(t=0),n===void 0&&(n=0),(i=this._tileMaps[t]._texture._bufferView)!==null){var o=new Array;e instanceof u.d?o.push(e):o=e;for(var a=this.options.stageSize.x||0,s=0;s<o.length;s++){var d=o[s];d.x=Math.floor(d.x),d.y=Math.floor(d.y),i[4*d.x+d.y*(4*a)]=n}var p=this._createTileBuffer(i);this._tileMaps[t].dispose(),this._tileMaps[t]=p,this._material.setTextureArray("tileMap",this._tileMaps)}},r.prototype._createTileAnimationBuffer=function(t){var e,n=new Array;if(t)e=t;else{for(var i=0;i<this.spriteCount;i++){n.push(0,0,0,0);for(var o=1;o<(this.options.maxAnimationFrames||4);)n.push(0,0,0,0),o++}e=new Float32Array(n)}return $n.CreateRGBATexture(e,this.spriteCount,this.options.maxAnimationFrames||4,this._scene,!1,!1,we.a.NEAREST_NEAREST,Ue.a.TEXTURETYPE_FLOAT)},r.prototype.addAnimationToTile=function(t,e,n,i,o){t===void 0&&(t=0),e===void 0&&(e=0),n===void 0&&(n=0),i===void 0&&(i=0),o===void 0&&(o=1);var a=this._animationMap._texture._bufferView,s=4*t+4*this.spriteCount*e;if(a){a[s]=n,a[s+1]=i,a[s+2]=o;var d=this._createTileAnimationBuffer(a);this._animationMap.dispose(),this._animationMap=d,this._material.setTexture("animationMap",this._animationMap)}},r.prototype.saveTileMaps=function(){for(var t="",e=0;e<this._tileMaps.length;e++)e>0&&(t+=`
11746\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(`
11747\r`),a=0;a<i;a++){var s=o[a].split(",").map(Number),d=e._createTileBuffer(s);e._tileMaps[a].dispose(),e._tileMaps[a]=d}e._material.setTextureArray("tileMap",e._tileMaps)},n.send()},r.prototype.dispose=function(){this._output.dispose(),this._material.dispose(),this._animationMap.dispose(),this._tileMaps.forEach(function(t){t.dispose()}),this._frameMap.dispose()},r}(),vv=function(r){function t(e,n,i,o,a,s,d){a===void 0&&(a=null),s===void 0&&(s=.01),d===void 0&&(d=we.a.TRILINEAR_SAMPLINGMODE);var p=r.call(this,e,n,i,64,o,s,d,!0,a)||this;return p.name=e,p}return Object(c.d)(t,r),t}(hf),bv=f(143),yv=f(141),Tv=f(142),Ev=f(139);(function(r){r[r.INIT=0]="INIT",r[r.RUNNING=1]="RUNNING",r[r.DONE=2]="DONE",r[r.ERROR=3]="ERROR"})(di||(di={}));var Zc,fi=function(){function r(t){this.name=t,this._isCompleted=!1,this._taskState=di.INIT}return Object.defineProperty(r.prototype,"isCompleted",{get:function(){return this._isCompleted}
11747,enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"taskState",{get:function(){return this._taskState},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"errorObject",{get:function(){return this._errorObject},enumerable:!1,configurable:!0}),r.prototype._setErrorObject=function(t,e){this._errorObject||(this._errorObject={message:t,exception:e})},r.prototype.run=function(t,e,n){var i=this;this._taskState=di.RUNNING,this.runTask(t,function(){i.onDoneCallback(e,n)},function(o,a){i.onErrorCallback(n,o,a)})},r.prototype.runTask=function(t,e,n){throw new Error("runTask is not implemented")},r.prototype.reset=function(){this._taskState=di.INIT},r.prototype.onErrorCallback=function(t,e,n){this._taskState=di.ERROR,this._errorObject={message:e,exception:n},this.onError&&this.onError(this,e,n),t()},r.prototype.onDoneCallback=function(t,e){try{this._taskState=di.DONE,this._isCompleted=!0,this.onSuccess&&this.onSuccess(this),t()}catch(n){this.onErrorCallback(e,"Task is done, error executing success callback(s)",n)}},r}(),df=function(r,t,e){this.remainingCount=r,this.totalCount=t,this.task=e},ff=function(r){function t(e,n,i,o){var a=r.call(this,e)||this;return a.name=e,a.meshesNames=n,a.rootUrl=i,a.sceneFilename=o,a}return Object(c.d)(t,r),t.prototype.runTask=function(e,n,i){var o=this;Ut.LoadAssetContainer(this.rootUrl,this.sceneFilename,e,function(a){o.loadedContainer=a,o.loadedMeshes=a.meshes,o.loadedParticleSystems=a.particleSystems,o.loadedSkeletons=a.skeletons,o.loadedAnimationGroups=a.animationGroups,n()},null,function(a,s,d){i(s,d)})},t}(fi),pf=function(r){function t(e,n,i,o){var a=r.call(this,e)||this;return a.name=e,a.meshesNames=n,a.rootUrl=i,a.sceneFilename=o,a}return Object(c.d)(t,r),t.prototype.runTask=function(e,n,i){var o=this;Ut.ImportMesh(this.meshesNames,this.rootUrl,this.sceneFilename,e,function(a,s,d,p){o.loadedMeshes=a,o.loadedParticleSystems=s,o.loadedSkeletons=d,o.loadedAnimationGroups=p,n()},null,function(a,s,d){i(s,d)})},t}(fi),_f=function(r){function t(e,n){var i=r.call(this,e)||this;return i.name=e,i.url=n,i}return Object(c.d)(t,r),t.prototype.runTask=function(e,n,i){var o=this;e._loadFile(this.url,function(a){o.text=a,n()},void 0,!1,!1,function(a,s){a&&i(a.status+" "+a.statusText,s)})},t}(fi),mf=function(r){function t(e,n){var i=r.call(this,e)||this;return i.name=e,i.url=n,i}return Object(c.d)(t,r),t.prototype.runTask=function(e,n,i){var o=this;e._loadFile(this.url,function(a){o.data=a,n()},void 0,!0,!0,function(a,s){a&&i(a.status+" "+a.statusText,s)})},t}(fi),gf=function(r){function t(e,n){var i=r.call(this,e)||this;return i.name=e,i.url=n,i}return Object(c.d)(t,r),t.prototype.runTask=function(e,n,i){var o=this,a=new Image;Ye.b.SetCorsBehavior(this.url,a),a.onload=function(){o.image=a,n()},a.onerror=function(s){i("Error loading image",s)},a.src=this.url},t}(fi),vf=function(r){function t(e,n,i,o,a){o===void 0&&(o=!0),a===void 0&&(a=we.a.TRILINEAR_SAMPLINGMODE);var s=r.call(this,e)||this;return s.name=e,s.url=n,s.noMipmap=i,s.invertY=o,s.samplingMode=a,s}return Object(c.d)(t,r),t.prototype.runTask=function(e,n,i){this.texture=new we.a(this.url,e,this.noMipmap,this.invertY,this.samplingMode,function(){n()},function(o,a){i(o,a)})},t}(fi),bf=function(r){function t(e,n,i,o,a){var s=r.call(this,e)||this;return s.name=e,s.url=n,s.extensions=i,s.noMipmap=o,s.files=a,s}return Object(c.d)(t,r),t.prototype.runTask=function(e,n,i){this.texture=new ni(this.url,e,this.extensions,this.noMipmap,this.files,function(){n()},function(o,a){i(o,a)})},t}(fi),yf=function(r){function t(e,n,i,o,a,s,d){o===void 0&&(o=!1),a===void 0&&(a=!0),s===void 0&&(s=!1),d===void 0&&(d=!1);var p=r.call(this,e)||this;return p.name=e,p.url=n,p.size=i,p.noMipmap=o,p.generateHarmonics=a,p.gammaSpace=s,p.reserved=d,p}return Object(c.d)(t,r),t.prototype.runTask=function(e,n,i){this.texture=new la(this.url,e,this.size,this.noMipmap,this.generateHarmonics,this.gammaSpace,this.reserved,function(){n()},function(o,a){i(o,a)})},t}(fi),Tf=function(r){function t(e,n,i,o,a){o===void 0&&(o=!1),a===void 0&&(a=!0);var s=r.call(this,e)||this;return s.name=e,s.url=n,s.size=i,s.noMipmap=o,s.gammaSpace=a,s}return Object(c.d)(t,r),t.prototype.runTask=function(e,n,i){this.texture=new ph(this.url,e,this.size,this.noMipmap,this.gammaSpace,function(){n()},function(o,a){i(o,a)})},t}(fi),Sv=function(){function r(t){this._isLoading=!1,this._tasks=new Array,this._waitingTasksCount=0,this._totalTasksCount=0,this.onTaskSuccessObservable=new x.c,this.onTaskErrorObservable=new x.c,this.onTasksDoneObservable=new x.c,this.onProgressObservable=new x.c,this.useDefaultLoadingScreen=!0,this.autoHideLoadingUI=!0,this._scene=t}return r.prototype.addContainerTask=function(t,e,n,i){var o=new ff(t,e,n,i);return this._tasks.push(o),o},r.prototype.addMeshTask=function(t,e,n,i){var o=new pf(t,e,n,i);return this._tasks.push(o),o},r.prototype.addTextFileTask=function(t,e){var n=new _f(t,e);return this._tasks.push(n),n},r.prototype.addBinaryFileTask=function(t,e){var n=new mf(t,e);return this._tasks.push(n),n},r.prototype.addImageTask=function(t,e){var n=new gf(t,e);return this._tasks.push(n),n},r.prototype.addTextureTask=function(t,e,n,i,o){o===void 0&&(o=we.a.TRILINEAR_SAMPLINGMODE);var a=new vf(t,e,n,i,o);return this._tasks.push(a),a},r.prototype.addCubeTextureTask=function(t,e,n,i,o){var a=new bf(t,e,n,i,o);return this._tasks.push(a),a},r.prototype.addHDRCubeTextureTask=function(t,e,n,i,o,a,s){i===void 0&&(i=!1),o===void 0&&(o=!0),a===void 0&&(a=!1),s===void 0&&(s=!1);var d=new yf(t,e,n,i,o,a,s);return this._tasks.push(d),d},r.prototype.addEquiRectangularCubeTextureAssetTask=function(t,e,n,i,o){i===void 0&&(i=!1),o===void 0&&(o=!0);var a=new Tf(t,e,n,i,o);return this._tasks.push(a),a},r.prototype.removeTask=function(t){var e=this._tasks.indexOf(t);e>-1&&this._tasks.splice(e,1)},r.prototype._decreaseWaitingTasksCount=function(t){this._waitingTasksCount--;try{this.onProgress&&this.onProgress(this._waitingTasksCount,this._totalTasksCount,t),this.onProgressObservable.notifyObservers(new df(this._waitingTasksCount,this._totalTasksCount,t))}catch(a){l.a.Error("Error running progress callbacks."),console.log(a)}if(this._waitingTasksCount===0){try{var e=this._tasks.slice();this.onFinish&&this.onFinish(e);for(var n=0,i=e;n<i.length;n++)if((t=i[n]).taskState===di.DONE){var o=this._tasks.indexOf(t);o>
11747-1&&this._tasks.splice(o,1)}this.onTasksDoneObservable.notifyObservers(this._tasks)}catch(a){l.a.Error("Error running tasks-done callbacks."),console.log(a)}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),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.reset=function(){return this._isLoading=!1,this._tasks=new Array,this},r.prototype.load=function(){if(this._isLoading)return this;if(this._isLoading=!0,this._waitingTasksCount=this._tasks.length,this._totalTasksCount=this._tasks.length,this._waitingTasksCount===0)return this._isLoading=!1,this.onFinish&&this.onFinish(this._tasks),this.onTasksDoneObservable.notifyObservers(this._tasks),this;this.useDefaultLoadingScreen&&this._scene.getEngine().displayLoadingUI();for(var t=0;t<this._tasks.length;t++){var e=this._tasks[t];e.taskState===di.INIT&&this._runTask(e)}return this},r.prototype.loadAsync=function(){var t=this;return new Promise(function(e,n){t._isLoading?e():(t.onTasksDoneObservable.addOnce(function(i){i&&i.length?n(i):e()}),t.load())})},r}(),Av=function(){function r(){var t=this;this.promise=new Promise(function(e,n){t._resolve=e,t._reject=n})}return Object.defineProperty(r.prototype,"resolve",{get:function(){return this._resolve},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"reject",{get:function(){return this._reject},enumerable:!1,configurable:!0}),r}(),Pv=function(){function r(t,e){this._meshesOrigins=[],this._toCenterVectors=[],this._scaledDirection=u.e.Zero(),this._newPosition=u.e.Zero(),this._centerPosition=u.e.Zero(),this._meshes=t.slice(),e?this._centerMesh=e:this._setCenterMesh();var n=this._meshes.indexOf(this._centerMesh);n>=0&&this._meshes.splice(n,1),this._centerPosition=this._centerMesh.getAbsolutePosition().clone();for(var i=0;i<this._meshes.length;i++)if(this._meshes[i]){var o=this._meshes[i];this._meshesOrigins[i]=o.getAbsolutePosition().clone(),this._toCenterVectors[i]=u.e.Zero(),o._boundingInfo&&this._centerMesh._boundingInfo&&o._boundingInfo.boundingBox.centerWorld.subtractToRef(this._centerMesh._boundingInfo.boundingBox.centerWorld,this._toCenterVectors[i])}}return r.prototype._setCenterMesh=function(){for(var t=u.e.Zero(),e=u.e.Zero(),n=Number.MAX_VALUE,i=0;i<this._meshes.length;i++)this._meshes[i]&&(a=(o=this._meshes[i]).getBoundingInfo())&&e.addInPlace(a.boundingBox.centerWorld);for(t=e.scale(1/this._meshes.length),i=0;i<this._meshes.length;i++){var o,a;if(this._meshes[i]&&(a=(o=this._meshes[i]).getBoundingInfo())){var s=a.boundingBox.centerWorld.subtract(t).lengthSquared();s<n&&(this._centerMesh=o,n=s)}}},r.prototype.getClassName=function(){return"MeshExploder"},r.prototype.getMeshes=function(){var t=this._meshes.slice();return t.unshift(this._centerMesh),t},r.prototype.explode=function(t){t===void 0&&(t=1);for(var e=0;e<this._meshes.length;e++)this._meshes[e]&&this._meshesOrigins[e]&&this._toCenterVectors[e]&&(this._toCenterVectors[e].scaleToRef(t,this._scaledDirection),this._meshesOrigins[e].addToRef(this._scaledDirection,this._newPosition),this._meshes[e].setAbsolutePosition(this._newPosition));this._centerMesh.setAbsolutePosition(this._centerPosition)},r}(),Cv=function(){function r(t,e,n,i,o,a,s,d,p){this.onProcessFileCallback=function(){return!0},this._engine=t,this._currentScene=e,this._sceneLoadedCallback=n,this._progressCallback=i,this._additionalRenderLoopLogicCallback=o,this._textureLoadingCallback=a,this._startingProcessingFilesCallback=s,this._onReloadCallback=d,this._errorCallback=p}return Object.defineProperty(r,"FilesToLoad",{get:function(){return Os.a.FilesToLoad},enumerable:!1,configurable:!0}),r.prototype.monitorElementForDragNDrop=function(t){var e=this;t&&(this._elementToMonitor=t,this._dragEnterHandler=function(n){e.drag(n)},this._dragOverHandler=function(n){e.drag(n)},this._dropHandler=function(n){e.drop(n)},this._elementToMonitor.addEventListener("dragenter",this._dragEnterHandler,!1),this._elementToMonitor.addEventListener("dragover",this._dragOverHandler,!1),this._elementToMonitor.addEventListener("drop",this._dropHandler,!1))},Object.defineProperty(r.prototype,"filesToLoad",{get:function(){return this._filesToLoad}
11747,enumerable:!1,configurable:!0}),r.prototype.dispose=function(){this._elementToMonitor&&(this._elementToMonitor.removeEventListener("dragenter",this._dragEnterHandler),this._elementToMonitor.removeEventListener("dragover",this._dragOverHandler),this._elementToMonitor.removeEventListener("drop",this._dropHandler))},r.prototype.renderFunction=function(){if(this._additionalRenderLoopLogicCallback&&this._additionalRenderLoopLogicCallback(),this._currentScene){if(this._textureLoadingCallback){var t=this._currentScene.getWaitingItemsCount();t>0&&this._textureLoadingCallback(t)}this._currentScene.render()}},r.prototype.drag=function(t){t.stopPropagation(),t.preventDefault()},r.prototype.drop=function(t){t.stopPropagation(),t.preventDefault(),this.loadFiles(t)},r.prototype._traverseFolder=function(t,e,n,i){var o=this,a=t.createReader(),s=t.fullPath.replace(/^\//,"").replace(/(.+?)\/?$/,"$1/");a.readEntries(function(d){n.count+=d.length;for(var p=0,y=d;p<y.length;p++){var P=y[p];P.isFile?P.file(function(O){O.correctName=s+O.name,e.push(O),--n.count==0&&i()}):P.isDirectory&&o._traverseFolder(P,e,n,i)}--n.count==0&&i()})},r.prototype._processFiles=function(t){for(var e=0;e<t.length;e++){var n=t[e].correctName.toLowerCase(),i=n.split(".").pop();this.onProcessFileCallback(t[e],n,i)&&(Ut.IsPluginForExtensionAvailable("."+i)&&(this._sceneFileToLoad=t[e]),r.FilesToLoad[n]=t[e])}},r.prototype.loadFiles=function(t){var e=this;if(t&&t.dataTransfer&&t.dataTransfer.files&&(this._filesToLoad=t.dataTransfer.files),t&&t.target&&t.target.files&&(this._filesToLoad=t.target.files),this._filesToLoad&&this._filesToLoad.length!==0&&(this._startingProcessingFilesCallback&&this._startingProcessingFilesCallback(this._filesToLoad),this._filesToLoad&&this._filesToLoad.length>0)){for(var n=new Array,i=[],o=t.dataTransfer?t.dataTransfer.items:null,a=0;a<this._filesToLoad.length;a++){var s=this._filesToLoad[a],d=s.name.toLowerCase(),p=void 0;if(s.correctName=d,o){var y=o[a];y.getAsEntry?p=y.getAsEntry():y.webkitGetAsEntry&&(p=y.webkitGetAsEntry())}p&&p.isDirectory?i.push(p):n.push(s)}if(i.length===0)this._processFiles(n),this._processReload();else for(var P={count:i.length},O=0,U=i;O<U.length;O++){var F=U[O];this._traverseFolder(F,n,P,function(){e._processFiles(n),P.count===0&&e._processReload()})}}},r.prototype._processReload=function(){this._onReloadCallback?this._onReloadCallback(this._sceneFileToLoad):this.reload()},r.prototype.reload=function(){var t=this;this._sceneFileToLoad?(this._currentScene&&(l.a.errorsCount>0&&l.a.ClearLogCache(),this._engine.stopRenderLoop()),Ut.ShowLoadingScreen=!1,this._engine.displayLoadingUI(),Ut.LoadAsync("file:",this._sceneFileToLoad,this._engine,function(e){t._progressCallback&&t._progressCallback(e)}).then(function(e){t._currentScene&&t._currentScene.dispose(),t._currentScene=e,t._sceneLoadedCallback&&t._sceneLoadedCallback(t._sceneFileToLoad,t._currentScene),t._currentScene.executeWhenReady(function(){t._engine.hideLoadingUI(),t._engine.runRenderLoop(function(){t.renderFunction()})})}).catch(function(e){t._engine.hideLoadingUI(),t._errorCallback&&t._errorCallback(t._sceneFileToLoad,t._currentScene,e.message)})):l.a.Error("Please provide a valid .babylon file.")},r}(),Ef=f(146),xv=f(145),pi=function(){function r(t){t===void 0&&(t=0),this.priority=t}return r.prototype.getDescription=function(){return""},r.prototype.apply=function(t,e){return!0},r}(),Ra=function(r){function t(e,n,i){e===void 0&&(e=0),n===void 0&&(n=1024),i===void 0&&(i=.5);var o=r.call(this,e)||this;return o.priority=e,o.maximumSize=n,o.step=i,o}return Object(c.d)(t,r),t.prototype.getDescription=function(){return"Reducing render target texture size to "+this.maximumSize},t.prototype.apply=function(e,n){for(var i=!0,o=0;o<e.textures.length;o++){var a=e.textures[o];if(a.canRescale&&!a.getContext){var s=a.getSize();Math.max(s.width,s.height)>this.maximumSize&&(a.scale(this.step),i=!1)}}return i},t}(pi),Jc=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 Object(c.d)(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}(pi),Oa=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return Object(c.d)(t,r),t.prototype.getDescription=function(){return"Turning shadows on/off"},t.prototype.apply=function(e,n){return e.shadowsEnabled=n.isInImprovementMode,!0},t}(pi),Ma=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return Object(c.d)(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}(pi),Ia=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return Object(c.d)(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}(pi),Sf=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return Object(c.d)(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}(pi),Da=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return Object(c.d)(t,r),t.prototype.getDescription=function(){return"Turning particles on/off"},t.prototype.apply=function(e,n){return e.particlesEnabled=n.isInImprovementMode,!0},t}(pi),$c=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return Object(c.d)(t,r),t.prototype.getDescription=function(){return"Turning render targets off"},t.prototype.apply=function(e,n){return e.renderTargetsEnabled=n.isInImprovementMode,!0},t}(pi),La=function(r){function t(){var e=r!==null&&r.apply(this,arguments)||this;return e._canBeMerged=function(n){if(!(n instanceof De.a))return!1;var i=n;return!i.isDisposed()&&!(!i.isVisible||!i.isEnabled())&&!(i.instances.length>0)&&!i.skeleton&&!i.hasLODLevels},e}return Object(c.d)(t,r),Object.defineProperty(t,"UpdateSelectionTree",{get:function(){return t._UpdateSelectionTree},set:function(e){t._UpdateSelectionTree=e}
11747,enumerable:!1,configurable:!0}),t.prototype.getDescription=function(){return"Merging similar meshes together"},t.prototype.apply=function(e,n,i){for(var o=e.meshes.slice(0),a=o.length,s=0;s<a;s++){var d=new Array,p=o[s];if(this._canBeMerged(p)){d.push(p);for(var y=s+1;y<a;y++){var P=o[y];this._canBeMerged(P)&&P.material===p.material&&P.checkCollisions===p.checkCollisions&&(d.push(P),a--,o.splice(y,1),y--)}d.length<2||De.a.MergeMeshes(d,void 0,!0)}}var O=e;return O.createOrUpdateSelectionOctree&&(i!=null?i&&O.createOrUpdateSelectionOctree():t.UpdateSelectionTree&&O.createOrUpdateSelectionOctree()),!0},t._UpdateSelectionTree=!1,t}(pi),el=function(){function r(t,e){t===void 0&&(t=60),e===void 0&&(e=2e3),this.targetFrameRate=t,this.trackerDuration=e,this.optimizations=new Array}return r.prototype.addOptimization=function(t){return this.optimizations.push(t),this},r.prototype.addCustomOptimization=function(t,e,n){n===void 0&&(n=0);var i=new Sf(n);return i.onApply=t,i.onGetDescription=e,this.optimizations.push(i),this},r.LowDegradationAllowed=function(t){var e=new r(t),n=0;return e.addOptimization(new La(n)),e.addOptimization(new Oa(n)),e.addOptimization(new Ia(n)),n++,e.addOptimization(new Ma(n)),e.addOptimization(new Da(n)),n++,e.addOptimization(new Ra(n,1024)),e},r.ModerateDegradationAllowed=function(t){var e=new r(t),n=0;return e.addOptimization(new La(n)),e.addOptimization(new Oa(n)),e.addOptimization(new Ia(n)),n++,e.addOptimization(new Ma(n)),e.addOptimization(new Da(n)),n++,e.addOptimization(new Ra(n,512)),n++,e.addOptimization(new $c(n)),n++,e.addOptimization(new Jc(n,2)),e},r.HighDegradationAllowed=function(t){var e=new r(t),n=0;return e.addOptimization(new La(n)),e.addOptimization(new Oa(n)),e.addOptimization(new Ia(n)),n++,e.addOptimization(new Ma(n)),e.addOptimization(new Da(n)),n++,e.addOptimization(new Ra(n,256)),n++,e.addOptimization(new $c(n)),n++,e.addOptimization(new Jc(n,4)),e},r}(),Rv=function(){function r(t,e,n,i){var o=this;if(n===void 0&&(n=!0),i===void 0&&(i=!1),this._isRunning=!1,this._currentPriorityLevel=0,this._targetFrameRate=60,this._trackerDuration=2e3,this._currentFrameRate=0,this._improvementMode=!1,this.onSuccessObservable=new x.c,this.onNewOptimizationAppliedObservable=new x.c,this.onFailureObservable=new x.c,this._options=e||new el,this._options.targetFrameRate&&(this._targetFrameRate=this._options.targetFrameRate),this._options.trackerDuration&&(this._trackerDuration=this._options.trackerDuration),n)for(var a=0,s=0,d=this._options.optimizations;s<d.length;s++)d[s].priority=a++;this._improvementMode=i,this._scene=t||te.a.LastCreatedScene,this._sceneDisposeObserver=this._scene.onDisposeObservable.add(function(){o._sceneDisposeObserver=null,o.dispose()})}return Object.defineProperty(r.prototype,"isInImprovementMode",{get:function(){return this._improvementMode},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"currentPriorityLevel",{get:function(){return this._currentPriorityLevel},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"currentFrameRate",{get:function(){return this._currentFrameRate},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"targetFrameRate",{get:function(){return this._targetFrameRate},set:function(t){this._targetFrameRate=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"trackerDuration",{get:function(){return this._trackerDuration},set:function(t){this._trackerDuration=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"optimizations",{get:function(){return this._options.optimizations},enumerable:!1,configurable:!0}),r.prototype.stop=function(){this._isRunning=!1},r.prototype.reset=function(){this._currentPriorityLevel=0},r.prototype.start=function(){var t=this;this._isRunning||(this._isRunning=!0,this._scene.executeWhenReady(function(){setTimeout(function(){t._checkCurrentState()},t._trackerDuration)}))},r.prototype._checkCurrentState=function(){var t=this;if(this._isRunning){var e=this._scene,n=this._options;if(this._currentFrameRate=Math.round(e.getEngine().getFps()),this._improvementMode&&this._currentFrameRate<=this._targetFrameRate||!this._improvementMode&&this._currentFrameRate>=this._targetFrameRate)return this._isRunning=!1,void this.onSuccessObservable.notifyObservers(this);for(var i=!0,o=!0,a=0;a<n.optimizations.length;a++){var s=n.optimizations[a];s.priority===this._currentPriorityLevel&&(o=!1,i=i&&s.apply(e,this),this.onNewOptimizationAppliedObservable.notifyObservers(s))}if(o)return this._isRunning=!1,void this.onFailureObservable.notifyObservers(this);i&&this._currentPriorityLevel++,e.executeWhenReady(function(){setTimeout(function(){t._checkCurrentState()},t._trackerDuration)})}},r.prototype.dispose=function(){this.stop(),this.onSuccessObservable.clear(),this.onFailureObservable.clear(),this.onNewOptimizationAppliedObservable.clear(),this._sceneDisposeObserver&&this._scene.onDisposeObservable.remove(this._sceneDisposeObserver)},r.OptimizeAsync=function(t,e,n,i){var o=new r(t,e||el.ModerateDegradationAllowed(),!1);return n&&o.onSuccessObservable.add(function(){n()}),i&&o.onFailureObservable.add(function(){i()}),o.start(),o},r}(),Na=[],tl=function(r,t){Na[r.id]||r.doNotSerialize||(t.vertexData.push(r.serializeVerticeData()),Na[r.id]=!0)},Af=function(r,t){var e={},n=r._geometry;
11747return n&&(r.getScene().getGeometryByID(n.id)||tl(n,t.geometries)),r.serialize&&r.serialize(e),e},nl=function(){function r(){}return r.ClearCache=function(){Na=[]},r.Serialize=function(t){var e,n,i,o={};if(r.ClearCache(),o.useDelayedTextureLoading=t.useDelayedTextureLoading,o.autoClear=t.autoClear,o.clearColor=t.clearColor.asArray(),o.ambientColor=t.ambientColor.asArray(),o.gravity=t.gravity.asArray(),o.collisionsEnabled=t.collisionsEnabled,t.fogMode&&t.fogMode!==0&&(o.fogMode=t.fogMode,o.fogColor=t.fogColor.asArray(),o.fogStart=t.fogStart,o.fogEnd=t.fogEnd,o.fogDensity=t.fogDensity),t.isPhysicsEnabled()){var a=t.getPhysicsEngine();a&&(o.physicsEnabled=!0,o.physicsGravity=a.gravity.asArray(),o.physicsEngine=a.getPhysicsPluginName())}t.metadata&&(o.metadata=t.metadata),o.morphTargetManagers=[];for(var s=0,d=t.meshes;s<d.length;s++){var p=(se=d[s]).morphTargetManager;p&&o.morphTargetManagers.push(p.serialize())}for(o.lights=[],e=0;e<t.lights.length;e++)(n=t.lights[e]).doNotSerialize||o.lights.push(n.serialize());for(o.cameras=[],e=0;e<t.cameras.length;e++){var y=t.cameras[e];y.doNotSerialize||o.cameras.push(y.serialize())}if(t.activeCamera&&(o.activeCameraID=t.activeCamera.id),L.a.AppendSerializedAnimations(t,o),t.animationGroups&&t.animationGroups.length>0){o.animationGroups=[];for(var P=0;P<t.animationGroups.length;P++){var O=t.animationGroups[P];o.animationGroups.push(O.serialize())}}if(t.reflectionProbes&&t.reflectionProbes.length>0)for(o.reflectionProbes=[],e=0;e<t.reflectionProbes.length;e++){var U=t.reflectionProbes[e];o.reflectionProbes.push(U.serialize())}for(o.materials=[],o.multiMaterials=[],e=0;e<t.materials.length;e++)(i=t.materials[e]).doNotSerialize||o.materials.push(i.serialize());for(o.multiMaterials=[],e=0;e<t.multiMaterials.length;e++){var F=t.multiMaterials[e];o.multiMaterials.push(F.serialize())}for(t.environmentTexture&&(o.environmentTexture=t.environmentTexture.name),o.environmentIntensity=t.environmentIntensity,o.skeletons=[],e=0;e<t.skeletons.length;e++){var z=t.skeletons[e];z.doNotSerialize||o.skeletons.push(z.serialize())}for(o.transformNodes=[],e=0;e<t.transformNodes.length;e++)t.transformNodes[e].doNotSerialize||o.transformNodes.push(t.transformNodes[e].serialize());o.geometries={},o.geometries.boxes=[],o.geometries.spheres=[],o.geometries.cylinders=[],o.geometries.toruses=[],o.geometries.grounds=[],o.geometries.planes=[],o.geometries.torusKnots=[],o.geometries.vertexData=[],Na=[];var J=t.getGeometries();for(e=0;e<J.length;e++){var ie=J[e];ie.isReady()&&tl(ie,o.geometries)}for(o.meshes=[],e=0;e<t.meshes.length;e++){var se;if((se=t.meshes[e])instanceof De.a){var ce=se;ce.doNotSerialize||ce.delayLoadState!==h.a.DELAYLOADSTATE_LOADED&&ce.delayLoadState!==h.a.DELAYLOADSTATE_NONE||o.meshes.push(Af(ce,o))}}for(o.particleSystems=[],e=0;e<t.particleSystems.length;e++)o.particleSystems.push(t.particleSystems[e].serialize(!1));for(o.postProcesses=[],e=0;e<t.postProcesses.length;e++)o.postProcesses.push(t.postProcesses[e].serialize());t.actionManager&&(o.actions=t.actionManager.serialize("scene"));for(var ue=0,fe=t._serializableComponents;ue<fe.length;ue++)fe[ue].serialize(o);return o},r.SerializeMesh=function(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!1);var i={};if(r.ClearCache(),t=t instanceof Array?t:[t],e||n)for(var o=0;o<t.length;
11747++o)n&&t[o].getDescendants().forEach(function(a){a instanceof De.a&&t.indexOf(a)<0&&!a.doNotSerialize&&t.push(a)}),e&&t[o].parent&&t.indexOf(t[o].parent)<0&&!t[o].parent.doNotSerialize&&t.push(t[o].parent);return t.forEach(function(a){(function(s,d){if(s.delayLoadState===h.a.DELAYLOADSTATE_LOADED||s.delayLoadState===h.a.DELAYLOADSTATE_NONE){if(s.material&&!s.material.doNotSerialize)if(s.material instanceof ir.a){if(d.multiMaterials=d.multiMaterials||[],d.materials=d.materials||[],!d.multiMaterials.some(function(U){return U.id===s.material.id})){d.multiMaterials.push(s.material.serialize());for(var p=function(U){U&&(d.materials.some(function(F){return F.id===U.id})||d.materials.push(U.serialize()))},y=0,P=s.material.subMaterials;y<P.length;y++)p(P[y])}}else d.materials=d.materials||[],d.materials.some(function(U){return U.id===s.material.id})||d.materials.push(s.material.serialize());var O=s._geometry;O&&(d.geometries||(d.geometries={},d.geometries.boxes=[],d.geometries.spheres=[],d.geometries.cylinders=[],d.geometries.toruses=[],d.geometries.grounds=[],d.geometries.planes=[],d.geometries.torusKnots=[],d.geometries.vertexData=[]),tl(O,d.geometries)),s.skeleton&&!s.skeleton.doNotSerialize&&(d.skeletons=d.skeletons||[],d.skeletons.push(s.skeleton.serialize())),d.meshes=d.meshes||[],d.meshes.push(Af(s,d))}})(a,i)}),i},r}(),Ov=f(37),Mv=function(){function r(){}return r.CreateResizedCopy=function(t,e,n,i){i===void 0&&(i=!0);var o=t.getScene(),a=o.getEngine(),s=new sn("resized"+t.name,{width:e,height:n},o,!t.noMipmap,!0,t._texture.type,!1,t.samplingMode,!1);s.wrapU=t.wrapU,s.wrapV=t.wrapV,s.uOffset=t.uOffset,s.vOffset=t.vOffset,s.uScale=t.uScale,s.vScale=t.vScale,s.uAng=t.uAng,s.vAng=t.vAng,s.wAng=t.wAng,s.coordinatesIndex=t.coordinatesIndex,s.level=t.level,s.anisotropicFilteringLevel=t.anisotropicFilteringLevel,s._texture.isReady=!1,t.wrapU=we.a.CLAMP_ADDRESSMODE,t.wrapV=we.a.CLAMP_ADDRESSMODE;var d=new Li("pass",1,null,i?we.a.BILINEAR_SAMPLINGMODE:we.a.NEAREST_SAMPLINGMODE,a,!1,h.a.TEXTURETYPE_UNSIGNED_INT);return d.getEffect().executeWhenCompiled(function(){d.onApply=function(y){y.setTexture("textureSampler",t)};var p=s.getInternalTexture();p&&(o.postProcessManager.directRender([d],p),a.unBindFramebuffer(p),s.disposeFramebufferObjects(),d.dispose(),p.isReady=!0)}),s},r}(),Iv=function(){function r(t,e){if(e===void 0&&(e=null),!r.IsSupported(t))throw"Your browser does not support recording so far.";var n=t.getRenderingCanvas();if(!n)throw"The babylon engine must have a canvas to be recorded";this._canvas=n,this._canvas.isRecording=!1,this._options=Object(c.a)(Object(c.a)({},r._defaultOptions),e);var i=this._canvas.captureStream(this._options.fps);if(this._options.audioTracks)for(var o=0,a=this._options.audioTracks;o<a.length;o++){var s=a[o];i.addTrack(s)}this._mediaRecorder=new MediaRecorder(i,{mimeType:this._options.mimeType}),this._mediaRecorder.ondataavailable=this._handleDataAvailable.bind(this),this._mediaRecorder.onerror=this._handleError.bind(this),this._mediaRecorder.onstop=this._handleStop.bind(this)}return r.IsSupported=function(t){var e=t.getRenderingCanvas();return!!e&&typeof e.captureStream=="function"},Object.defineProperty(r.prototype,"isRecording",{get:function(){return!!this._canvas&&this._canvas.isRecording},enumerable:!1,configurable:!0}),r.prototype.stopRecording=function(){this._canvas&&this._mediaRecorder&&this.isRecording&&(this._canvas.isRecording=!1,this._mediaRecorder.stop())},r.prototype.startRecording=function(t,e){var n=this;if(t===void 0&&(t="babylonjs.webm"),e===void 0&&(e=7),!this._canvas||!this._mediaRecorder)throw"Recorder has already been disposed";if(this.isRecording)throw"Recording already in progress";return e>0&&setTimeout(function(){n.stopRecording()},1e3*e),this._fileName=t,this._recordedChunks=[],this._resolve=null,this._reject=null,this._canvas.isRecording=!0,this._mediaRecorder.start(this._options.recordChunckSize),new Promise(function(i,o){n._resolve=i,n._reject=o})},r.prototype.dispose=function(){this._canvas=null,this._mediaRecorder=null,this._recordedChunks=[],this._fileName=null,this._resolve=null,this._reject=null},r.prototype._handleDataAvailable=function(t){t.data.size>0&&this._recordedChunks.push(t.data)},r.prototype._handleError=function(t){if(this.stopRecording(),!this._reject)throw new t.error;this._reject(t.error)},r.prototype._handleStop=function(){this.stopRecording();var t=new Blob(this._recordedChunks);this._resolve&&this._resolve(t),window.URL.createObjectURL(t),this._fileName&&Ye.b.Download(t,this._fileName)},r._defaultOptions={mimeType:"video/webm",fps:25,recordChunckSize:3e3},r}(),Oo=function(){function r(){}return r.CreateScreenshot=function(t,e,n,i,o){o===void 0&&(o="image/png");var a=r._getScreenshotSize(t,e,n),s=a.height,d=a.width;if(s&&d){Ye.b._ScreenshotCanvas||(Ye.b._ScreenshotCanvas=document.createElement("canvas")),Ye.b._ScreenshotCanvas.width=d,Ye.b._ScreenshotCanvas.height=s;var p=Ye.b._ScreenshotCanvas.getContext("2d"),y=t.getRenderWidth()/t.getRenderHeight(),P=d,O=P/y;O>s&&(P=(O=s)*y);var U=Math.max(0,d-P)/2,F=Math.max(0,s-O)/2,z=t.getRenderingCanvas();p&&z&&p.drawImage(z,U,F,P,O),Ye.b.EncodeScreenshotCanvasData(i,o)}else l.a.Error("Invalid 'size' parameter !")},r.CreateScreenshotAsync=function(t,e,n,i){return i===void 0&&(i="image/png"),new Promise(function(o,a){r.CreateScreenshot(t,e,n,function(s){s!==void 0?o(s):a(new Error("Data is undefined"))},i)})},r.CreateScreenshotUsingRenderTarget=function(t,e,n,i,o,a,s,d,p,y){o===void 0&&(o="image/png"),a===void 0&&(a=1),s===void 0&&(s=!1),p===void 0&&(p=!1),y===void 0&&(y=!1);var P=r._getScreenshotSize(t,e,n),O=P.height,U=P.width,F={width:U,height:O};
11747if(O&&U){var z=t.getRenderingCanvas();if(z){var J={width:z.width,height:z.height};t.setSize(U,O);var ie=e.getScene(),se=null,ce=ie.activeCameras;(ie.activeCamera!==e||ie.activeCameras&&ie.activeCameras.length)&&(se=ie.activeCamera,ie.activeCamera=e),ie.render();var ue=new sn("screenShot",F,ie,!1,!1,h.a.TEXTURETYPE_UNSIGNED_INT,!1,we.a.NEAREST_SAMPLINGMODE,void 0,y);ue.renderList=null,ue.samples=a,ue.renderSprites=p,ue.onAfterRenderObservable.add(function(){Ye.b.DumpFramebuffer(U,O,t,i,o,d)});var fe=function(){ie.incrementRenderId(),ie.resetCachedMaterial(),ue.render(!0),ue.dispose(),se&&(ie.activeCamera=se),ie.activeCameras=ce,t.setSize(J.width,J.height),e.getProjectionMatrix(!0)};if(s){var ve=new Ro("antialiasing",1,ie.activeCamera);ue.addPostProcess(ve),ve.getEffect().isReady()?fe():ve.getEffect().onCompiled=function(){fe()}}else fe()}else l.a.Error("No rendering canvas found !")}else l.a.Error("Invalid 'size' parameter !")},r.CreateScreenshotUsingRenderTargetAsync=function(t,e,n,i,o,a,s,d){return i===void 0&&(i="image/png"),o===void 0&&(o=1),a===void 0&&(a=!1),d===void 0&&(d=!1),new Promise(function(p,y){r.CreateScreenshotUsingRenderTarget(t,e,n,function(P){P!==void 0?p(P):y(new Error("Data is undefined"))},i,o,a,s,d)})},r._getScreenshotSize=function(t,e,n){var i=0,o=0;if(typeof n=="object"){var a=n.precision?Math.abs(n.precision):1;n.width&&n.height?(i=n.height*a,o=n.width*a):n.width&&!n.height?(o=n.width*a,i=Math.round(o/t.getAspectRatio(e))):n.height&&!n.width?(i=n.height*a,o=Math.round(i*t.getAspectRatio(e))):(o=Math.round(t.getRenderWidth()*a),i=Math.round(o/t.getAspectRatio(e)))}else isNaN(n)||(i=n,o=n);return o&&(o=Math.floor(o)),i&&(i=Math.floor(i)),{height:0|i,width:0|o}},r}();Ye.b.CreateScreenshot=Oo.CreateScreenshot,Ye.b.CreateScreenshotAsync=Oo.CreateScreenshotAsync,Ye.b.CreateScreenshotUsingRenderTarget=Oo.CreateScreenshotUsingRenderTarget,Ye.b.CreateScreenshotUsingRenderTargetAsync=Oo.CreateScreenshotUsingRenderTargetAsync,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"}(Zc||(Zc={}));var Vr,Dv=f(140),Lv=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 Xn.a.Decode(this.readUint8Array(t))},r.prototype.skipBytes=function(t){this._dataByteOffset+=t,this.byteOffset+=t},r}(),Nv=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}(),wv=function(){function r(){this._trackedScene=null}return r.prototype.track=function(t){this._trackedScene=t,this._savedJSON=nl.Serialize(t)},r.prototype.getDelta=function(){if(!this._trackedScene)return null;var t=nl.Serialize(this._trackedScene),e={};for(var n in t)this._compareCollections(n,this._savedJSON[n],t[n],e);return e},r.prototype._compareArray=function(t,e,n,i){if(e.length===0&&n.length===0)return!0;if(e.length&&!isNaN(e[0])||n.length&&!isNaN(n[0])){if(e.length!==n.length)return!1;if(e.length===0)return!0;for(var o=0;o<e.length;
11747o++)if(e[o]!==n[o])return i[t]=n,!1;return!0}var a=[],s=function(){var P=e[o],O=P.uniqueId;a.push(O);var U=n.filter(function(J){return J.uniqueId===O});if(U.length){var F=U[0],z={};d._compareObjects(P,F,z)||(i[t]||(i[t]=[]),z.__state={id:F.id||F.name},i[t].push(z))}else z={__state:{deleteId:P.id||P.name}},i[t].push(z)},d=this;for(o=0;o<e.length;o++)s();for(o=0;o<n.length;o++){var p=n[o],y=p.uniqueId;a.indexOf(y)===-1&&(i[t]||(i[t]=[]),i[t].push(p))}return!0},r.prototype._compareObjects=function(t,e,n){var i=!1;for(var o in t)if(t.hasOwnProperty(o)){var a=t[o],s=e[o],d=!1;Array.isArray(a)?d=JSON.stringify(a)!==JSON.stringify(s):isNaN(a)&&Object.prototype.toString.call(a)!="[object String]"||(d=a!==s),d&&(i=!0,n[o]=s)}return!i},r.prototype._compareCollections=function(t,e,n,i){if(e!==n&&e&&n){if(Array.isArray(e)&&Array.isArray(n)){if(this._compareArray(t,e,n,i))return}else if(typeof e=="object"&&typeof n=="object"){var o={};return void(this._compareObjects(e,n,o)||(i[t]=o))}}},r.GetShadowGeneratorById=function(t,e){for(var n=0,i=t.lights.map(function(a){return a.getShadowGenerator()});n<i.length;n++){var o=i[n];if(o&&o.id===e)return o}return null},r.ApplyDelta=function(t,e){var n=this;typeof t=="string"&&(t=JSON.parse(t));var i=e;for(var o in t){var a=t[o],s=i[o];if(Array.isArray(s)||o==="shadowGenerators")switch(o){case"cameras":this._ApplyDeltaForEntity(a,e,e.getCameraByID.bind(e),function(d){return gt.a.Parse(d,e)});break;case"lights":this._ApplyDeltaForEntity(a,e,e.getLightByID.bind(e),function(d){return Ci.a.Parse(d,e)});break;case"shadowGenerators":this._ApplyDeltaForEntity(a,e,function(d){return n.GetShadowGeneratorById(e,d)},function(d){return Fn.Parse(d,e)});break;case"meshes":this._ApplyDeltaForEntity(a,e,e.getMeshByID.bind(e),function(d){return De.a.Parse(d,e,"")});break;case"skeletons":this._ApplyDeltaForEntity(a,e,e.getSkeletonById.bind(e),function(d){return Bo.Parse(d,e)});break;case"materials":this._ApplyDeltaForEntity(a,e,e.getMaterialByID.bind(e),function(d){return Ht.a.Parse(d,e,"")});break;case"multiMaterials":this._ApplyDeltaForEntity(a,e,e.getMaterialByID.bind(e),function(d){return ir.a.Parse(d,e,"")});break;case"transformNodes":this._ApplyDeltaForEntity(a,e,e.getTransformNodeByID.bind(e),function(d){return Tr.a.Parse(d,e,"")});break;case"particleSystems":this._ApplyDeltaForEntity(a,e,e.getParticleSystemByID.bind(e),function(d){return ln.Parse(d,e,"")});break;case"morphTargetManagers":this._ApplyDeltaForEntity(a,e,e.getMorphTargetById.bind(e),function(d){return ua.Parse(d,e)});break;case"postProcesses":this._ApplyDeltaForEntity(a,e,e.getPostProcessByName.bind(e),function(d){return _t.Parse(d,e,"")})}else isNaN(s)?s.fromArray&&s.fromArray(a):i[o]=a}},r._ApplyPropertiesToEntity=function(t,e){for(var n in t){var i=t[n],o=e[n];o!==void 0&&(!isNaN(o)||Array.isArray(o)?e[n]=i:o.fromArray&&o.fromArray(i))}},r._ApplyDeltaForEntity=function(t,e,n,i){for(var o=0,a=t;o<a.length;o++){var s=a[o];if(s.__state&&s.__state.id!==void 0){var d=n(s.__state.id);d&&this._ApplyPropertiesToEntity(s,d)}else if(s.__state&&s.__state.deleteId!==void 0){var p=n(s.__state.deleteId);p?.dispose()}else i(s)}},r}();(function(r){var t=function(){function n(i,o,a,s){var d;o===void 0&&(o=null),a===void 0&&(a=null),s===void 0&&(s=null),o=o??function(){return 1},a=a??function(){return 1},s=s??function(P,O){return P===O?0:1},this._characterToIdx=new Map,this._insertionCosts=new Array(i.length),this._deletionCosts=new Array(i.length),this._substitutionCosts=new Array(i.length);for(var p=0;p<i.length;++p){d=i[p],this._characterToIdx.set(d,p),this._insertionCosts[p]=o(d),this._deletionCosts[p]=a(d),this._substitutionCosts[p]=new Array(i.length);for(var y=p;y<i.length;++y)this._substitutionCosts[p][y]=s(d,i[y])}}return n.prototype.serialize=function(){var i={},o=new Array(this._characterToIdx.size);return this._characterToIdx.forEach(function(a,s){o[a]=s}),i.characters=o,i.insertionCosts=this._insertionCosts,i.deletionCosts=this._deletionCosts,i.substitutionCosts=this._substitutionCosts,JSON.stringify(i)},n.Deserialize=function(i){var o=JSON.parse(i),a=new n(o.characters);
11747return a._insertionCosts=o.insertionCosts,a._deletionCosts=o.deletionCosts,a._substitutionCosts=o.substitutionCosts,a},n.prototype.getCharacterIdx=function(i){return this._characterToIdx.get(i)},n.prototype.getInsertionCost=function(i){return this._insertionCosts[i]},n.prototype.getDeletionCost=function(i){return this._deletionCosts[i]},n.prototype.getSubstitutionCost=function(i,o){var a=Math.min(i,o),s=Math.max(i,o);return this._substitutionCosts[a][s]},n}();r.Alphabet=t;var e=function(){function n(i,o){var a=this;if(i.length>n.MAX_SEQUENCE_LENGTH)throw new Error("Sequences longer than "+n.MAX_SEQUENCE_LENGTH+" not supported.");this._alphabet=o,this._characters=i.map(function(s){return a._alphabet.getCharacterIdx(s)})}return n.prototype.serialize=function(){return JSON.stringify(this._characters)},n.Deserialize=function(i,o){var a=new n([],o);return a._characters=JSON.parse(i),a},n.prototype.distance=function(i){return n._distance(this,i)},n._distance=function(i,o){var a=i._alphabet;if(a!==o._alphabet)throw new Error("Cannot Levenshtein compare Sequences built from different alphabets.");var s=i._characters,d=o._characters,p=s.length,y=d.length,P=n._costMatrix;P[0][0]=0;for(var O=0;O<p;++O)P[O+1][0]=P[O][0]+a.getInsertionCost(s[O]);for(O=0;O<y;++O)P[0][O+1]=P[0][O]+a.getInsertionCost(d[O]);for(var U=0;U<p;++U)for(var F=0;F<y;++F)n._insertionCost=P[U+1][F]+a.getInsertionCost(d[F]),n._deletionCost=P[U][F+1]+a.getDeletionCost(s[U]),n._substitutionCost=P[U][F]+a.getSubstitutionCost(s[U],d[F]),P[U+1][F+1]=Math.min(n._insertionCost,n._deletionCost,n._substitutionCost);return P[p][y]},n.MAX_SEQUENCE_LENGTH=256,n._costMatrix=Object(c.f)(Array(n.MAX_SEQUENCE_LENGTH+1)).map(function(i){return new Array(n.MAX_SEQUENCE_LENGTH+1)}),n}();r.Sequence=e})(Vr||(Vr={}));var Fv=function(){function r(t){t===void 0&&(t=.01),this._points=[],this._segmentLength=t}return r.prototype.serialize=function(){return JSON.stringify(this)},r.Deserialize=function(t){var e=JSON.parse(t),n=new r(e._segmentLength);return n._points=e._points.map(function(i){return new u.e(i._x,i._y,i._z)}),n},r.prototype.getLength=function(){return this._points.length*this._segmentLength},r.prototype.add=function(t){var e=this,n=this._points.length;if(n===0)this._points.push(t.clone());else for(var i=function(){return e._segmentLength/u.e.Distance(e._points[n-1],t)},o=i();o<=1;o=i()){var a=this._points[n-1].scale(1-o);t.scaleAndAddToRef(o,a),this._points.push(a),++n}},r.prototype.resampleAtTargetResolution=function(t){var e=new r(this.getLength()/t);return this._points.forEach(function(n){e.add(n)}),e},r.prototype.tokenize=function(t){for(var e=[],n=new u.e,i=2;i<this._points.length;++i)r._transformSegmentDirToRef(this._points[i-2],this._points[i-1],this._points[i],n)&&e.push(r._tokenizeSegment(n,t));return e},r._transformSegmentDirToRef=function(t,e,n,i){return e.subtractToRef(t,r._forwardDir),r._forwardDir.normalize(),e.scaleToRef(-1,r._inverseFromVec),r._inverseFromVec.normalize(),!(Math.abs(u.e.Dot(r._forwardDir,r._inverseFromVec))>.98)&&(u.e.CrossToRef(r._forwardDir,r._inverseFromVec,r._upDir),r._upDir.normalize(),u.a.LookAtLHToRef(t,e,r._upDir,r._lookMatrix),n.subtractToRef(e,r._fromToVec),r._fromToVec.normalize(),u.e.TransformNormalToRef(r._fromToVec,r._lookMatrix,i),!0)},r._tokenizeSegment=function(t,e){r._bestMatch=0,r._score=u.e.Dot(t,e[0]),r._bestScore=r._score;for(var n=1;n<e.length;++n)r._score=u.e.Dot(t,e[n]),r._score>r._bestScore&&(r._bestMatch=n,r._bestScore=r._score);return r._bestMatch},r._forwardDir=new u.e,r._inverseFromVec=new u.e,r._upDir=new u.e,r._fromToVec=new u.e,r._lookMatrix=new u.a,r}(),Pf=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,d=new r(t),p=0;p<t;++p)d.chars[p]=new u.e(Math.random()-.5,Math.random()-.5,Math.random()-.5),d.chars[p].normalize();for(p=0;p<o.length;++p)d.chars[p].copyFrom(o[p]);for(var y,P=new u.e,O=new u.e,U=0;U<e;++U){a=(1-(y=U/(e-1)))*n+y*i;
11747var F=function(z){P.copyFromFloats(0,0,0),d.chars.forEach(function(J){d.chars[z].subtractToRef(J,O),(s=O.lengthSquared())>1e-6&&O.scaleAndAddToRef(1/(O.lengthSquared()*s),P)}),P.scaleInPlace(a),d.chars[z].addInPlace(P),d.chars[z].normalize()};for(p=o.length;p<d.chars.length;++p)F(p)}return d},r.prototype.serialize=function(){return JSON.stringify(this.chars)},r.Deserialize=function(t){for(var e=JSON.parse(t),n=new r(e.length),i=0;i<e.length;++i)n.chars[i]=new u.e(e[i]._x,e[i]._y,e[i]._z);return n},r}(),il=function(){function r(){this._sequences=[]}return r.prototype.serialize=function(){return JSON.stringify(this._sequences.map(function(t){return t.serialize()}))},r.Deserialize=function(t,e){var n=new r;return n._sequences=JSON.parse(t).map(function(i){return Vr.Sequence.Deserialize(i,e)}),n},r.CreateFromTrajectory=function(t,e,n){return r.CreateFromTokenizationPyramid(r._getTokenizationPyramid(t,e),n)},r.CreateFromTokenizationPyramid=function(t,e){var n=new r;return n._sequences=t.map(function(i){return new Vr.Sequence(i,e)}),n},r._getTokenizationPyramid=function(t,e,n){n===void 0&&(n=r.FINEST_DESCRIPTOR_RESOLUTION);for(var i=[],o=n;o>4;o=Math.floor(o/2))i.push(t.resampleAtTargetResolution(o).tokenize(e.chars));return i},r.prototype.distance=function(t){for(var e=0,n=0;n<this._sequences.length;++n)e+=Math.pow(2,n)*this._sequences[n].distance(t._sequences[n]);return e},r.FINEST_DESCRIPTOR_RESOLUTION=32,r}(),Cf=function(){function r(t){t===void 0&&(t=[]),this._descriptors=t,this._centroidIdx=-1,this._averageDistance=0,this._refreshDescription()}return r.prototype.serialize=function(){var t={};return t.descriptors=this._descriptors.map(function(e){return e.serialize()}),t.centroidIdx=this._centroidIdx,t.averageDistance=this._averageDistance,JSON.stringify(t)},r.Deserialize=function(t,e){var n=JSON.parse(t),i=new r;return i._descriptors=n.descriptors.map(function(o){return il.Deserialize(o,e)}),i._centroidIdx=n.centroidIdx,i._averageDistance=n.averageDistance,i},r.prototype.add=function(t){this._descriptors.push(t),this._refreshDescription()},r.prototype.getMatchCost=function(t){return t.distance(this._descriptors[this._centroidIdx])/this._averageDistance},r.prototype.getMatchMinimumDistance=function(t){return Math.min.apply(Math,this._descriptors.map(function(e){return e.distance(t)}))},r.prototype._refreshDescription=function(){var t,e=this;this._centroidIdx=-1;for(var n=this._descriptors.map(function(o){return t=0,e._descriptors.forEach(function(a){t+=o.distance(a)}),t}),i=0;i<n.length;++i)(this._centroidIdx<0||n[i]<n[this._centroidIdx])&&(this._centroidIdx=i);this._averageDistance=0,this._descriptors.forEach(function(o){e._averageDistance+=o.distance(e._descriptors[e._centroidIdx])}),this._descriptors.length>0&&(this._averageDistance=Math.max(this._averageDistance/this._descriptors.length,r.MIN_AVERAGE_DISTANCE))},r.MIN_AVERAGE_DISTANCE=1,r}(),Bv=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=Pf.Deserialize(e.vector3Alphabet),n._levenshteinAlphabet=Vr.Alphabet.Deserialize(e.levenshteinAlphabet);for(var i=0;i<e.nameToDescribedTrajectory.length;i+=2)n._nameToDescribedTrajectory.set(e.nameToDescribedTrajectory[i],Cf.Deserialize(e.nameToDescribedTrajectory[i+1],n._levenshteinAlphabet));return n},r.Generate=function(){for(var t=Pf.Generate(64,256,.1,.001,[u.e.Forward()]),e=new Array(t.chars.length),n=0;n<e.length;++n)e[n]=n;var i=new Vr.Alphabet(e,function(a){return a===0?0:1},function(a){return a===0?0:1},function(a,s){return Math.min(1-u.e.Dot(t.chars[a],t.chars[s]),1)}),o=new r;return o._vector3Alphabet=t,o._levenshteinAlphabet=i,o},r.prototype.addTrajectoryToClassification=function(t,e){this._nameToDescribedTrajectory.has(e)||this._nameToDescribedTrajectory.set(e,new Cf),this._nameToDescribedTrajectory.get(e).add(il.CreateFromTrajectory(t,this._vector3Alphabet,this._levenshteinAlphabet))},r.prototype.deleteClassification=function(t){return this._nameToDescribedTrajectory.delete(t)},r.prototype.classifyTrajectory=function(t){var e=this,n=il.CreateFromTrajectory(t,this._vector3Alphabet,this._levenshteinAlphabet),i=[];
11747if(this._nameToDescribedTrajectory.forEach(function(p,y){p.getMatchCost(n)<e._maximumAllowableMatchCost&&i.push(y)}),i.length===0)return null;for(var o,a=0,s=this._nameToDescribedTrajectory.get(i[a]).getMatchMinimumDistance(n),d=0;d<i.length;++d)(o=this._nameToDescribedTrajectory.get(i[d]).getMatchMinimumDistance(n))<s&&(s=o,a=d);return i[a]},r}(),Uv=f(150),wa=function(r){function t(e,n){n===void 0&&(n={});var i=r.call(this,e)||this;return i.options=n,i._direction=new u.e(0,0,-1),i._mat=new u.a,i._onSelectEnabled=!1,i._origin=new u.e(0,0,0),i.lastNativeXRHitResults=[],i.onHitTestResultObservable=new x.c,i._onHitTestResults=function(o){var a=o.map(function(s){var d=u.a.FromArray(s.hitMatrix);return i._xrSessionManager.scene.useRightHandedSystem||d.toggleModelMatrixHandInPlace(),i.options.worldParentNode&&d.multiplyToRef(i.options.worldParentNode.getWorldMatrix(),d),{xrHitResult:s,transformationMatrix:d}});i.lastNativeXRHitResults=o,i.onHitTestResultObservable.notifyObservers(a)},i._onSelect=function(o){i._onSelectEnabled&&t.XRHitTestWithSelectEvent(o,i._xrSessionManager.referenceSpace)},i.xrNativeFeatureName="hit-test",Ye.b.Warn("A newer version of this plugin is available"),i}return Object(c.d)(t,r),t.XRHitTestWithRay=function(e,n,i,o){return e.requestHitTest(n,i).then(function(a){var s=o||function(d){return!!d.hitMatrix};return a.filter(s)})},t.XRHitTestWithSelectEvent=function(e,n){var i=e.frame.getPose(e.inputSource.targetRaySpace,n);if(!i)return Promise.resolve([]);var o=new XRRay(i.transform);return this.XRHitTestWithRay(e.frame.session,o,n)},t.prototype.attach=function(){return!!r.prototype.attach.call(this)&&(this.options.testOnPointerDownOnly&&this._xrSessionManager.session.addEventListener("select",this._onSelect,!1),!0)},t.prototype.detach=function(){return!!r.prototype.detach.call(this)&&(this._onSelectEnabled=!1,this._xrSessionManager.session.removeEventListener("select",this._onSelect),!0)},t.prototype.dispose=function(){r.prototype.dispose.call(this),this.onHitTestResultObservable.clear()},t.prototype._onXRFrame=function(e){if(this.attached&&!this.options.testOnPointerDownOnly){var n=e.getViewerPose(this._xrSessionManager.referenceSpace);if(n){u.a.FromArrayToRef(n.transform.matrix,0,this._mat),u.e.TransformCoordinatesFromFloatsToRef(0,0,0,this._mat,this._origin),u.e.TransformCoordinatesFromFloatsToRef(0,0,-1,this._mat,this._direction),this._direction.subtractInPlace(this._origin),this._direction.normalize();var i=new XRRay({x:this._origin.x,y:this._origin.y,z:this._origin.z,w:0},{x:this._direction.x,y:this._direction.y,z:this._direction.z,w:0});t.XRHitTestWithRay(this._xrSessionManager.session,i,this._xrSessionManager.referenceSpace).then(this._onHitTestResults)}}},t.Name=ii.HIT_TEST,t.Version=1,t}(ri);Yn.AddWebXRFeature(wa.Name,function(r,t){return function(){return new wa(r,t)}},wa.Version,!1);var Vv=0,Fa=function(r){function t(e,n){n===void 0&&(n={});var i=r.call(this,e)||this;return i._options=n,i._lastFrameDetected=new Set,i._trackedAnchors=[],i._futureAnchors=[],i.onAnchorAddedObservable=new x.c,i.onAnchorRemovedObservable=new x.c,i.onAnchorUpdatedObservable=new x.c,i._tmpVector=new u.e,i._tmpQuaternion=new u.b,i.xrNativeFeatureName="anchors",i}return Object(c.d)(t,r),Object.defineProperty(t.prototype,"referenceSpaceForFrameAnchors",{set:function(e){this._referenceSpaceForFrameAnchors=e},enumerable:!1,configurable:!0}),t.prototype._populateTmpTransformation=function(e,n){return this._tmpVector.copyFrom(e),this._tmpQuaternion.copyFrom(n),this._xrSessionManager.scene.useRightHandedSystem||(this._tmpVector.z*=-1,this._tmpQuaternion.z*=-1,this._tmpQuaternion.w*=-1),{position:this._tmpVector,rotationQuaternion:this._tmpQuaternion}},t.prototype.addAnchorPointUsingHitTestResultAsync=function(e,n,i){return n===void 0&&(n=new u.e),i===void 0&&(i=new u.b),Object(c.b)(this,void 0,void 0,function(){var o,a,s,d=this;return Object(c.e)(this,function(p){switch(p.label){case 0:if(this._populateTmpTransformation(n,i),o=new XRRigidTransform({x:this._tmpVector.x,y:this._tmpVector.y,z:this._tmpVector.z},{x:this._tmpQuaternion.x,y:this._tmpQuaternion.y,z:this._tmpQuaternion.z,w:this._tmpQuaternion.w}),e.xrHitResult.createAnchor)return[3,1];throw this.detach(),new Error("Anchors not enabled in this environment/browser");case 1:return p.trys.push([1,3,,4]),[4,e.xrHitResult.createAnchor(o)];case 2:return a=p.sent(),[2,new Promise(function(y,P){d._futureAnchors.push({nativeAnchor:a,resolved:!1,submitted:!0,xrTransformation:o,resolve:y,reject:P})})];case 3:throw s=p.sent(),new Error(s);case 4:return[2]}})})},t.prototype.addAnchorAtPositionAndRotationAsync=function(e,n,i){return n===void 0&&(n=new u.b),i===void 0&&(i=!1),Object(c.b)(this,void 0,void 0,function(){var o,a,s,d=this;return Object(c.e)(this,function(p){switch(p.label){case 0:return this._populateTmpTransformation(e,n),o=new XRRigidTransform({x:this._tmpVector.x,y:this._tmpVector.y,z:this._tmpVector.z},{x:this._tmpQuaternion.x,y:this._tmpQuaternion.y,z:this._tmpQuaternion.z,w:this._tmpQuaternion.w}),i&&this.attached&&this._xrSessionManager.currentFrame?[4,this._createAnchorAtTransformation(o,this._xrSessionManager.currentFrame)]:[3,2];case 1:return s=p.sent(),[3,3];case 2:s=void 0,p.label=3;case 3:return a=s,[2,new Promise(function(y,P){d._futureAnchors.push({nativeAnchor:a,resolved:!1,submitted:!1,xrTransformation:o,resolve:y,reject:P})})]}})})},Object.defineProperty(t.prototype,"anchors",{get:function(){return this._trackedAnchors}
11747,enumerable:!1,configurable:!0}),t.prototype.detach=function(){if(!r.prototype.detach.call(this))return!1;if(!this._options.doNotRemoveAnchorsOnSessionEnded)for(;this._trackedAnchors.length;){var e=this._trackedAnchors.pop();if(e){try{e.remove()}catch{}this.onAnchorRemovedObservable.notifyObservers(e)}}return!0},t.prototype.dispose=function(){this._futureAnchors.length=0,r.prototype.dispose.call(this),this.onAnchorAddedObservable.clear(),this.onAnchorRemovedObservable.clear(),this.onAnchorUpdatedObservable.clear()},t.prototype._onXRFrame=function(e){var n=this;if(this.attached&&e){var i=e.trackedAnchors;if(i){var o=this._trackedAnchors.filter(function(s){return!i.has(s.xrAnchor)}).map(function(s){return n._trackedAnchors.indexOf(s)}),a=0;o.forEach(function(s){var d=n._trackedAnchors.splice(s-a,1)[0];n.onAnchorRemovedObservable.notifyObservers(d),a++}),i.forEach(function(s){if(n._lastFrameDetected.has(s)){var d=n._findIndexInAnchorArray(s);y=n._trackedAnchors[d];try{n._updateAnchorWithXRFrame(s,y,e),y.attachedNode&&(y.attachedNode.rotationQuaternion=y.attachedNode.rotationQuaternion||new u.b,y.transformationMatrix.decompose(y.attachedNode.scaling,y.attachedNode.rotationQuaternion,y.attachedNode.position)),n.onAnchorUpdatedObservable.notifyObservers(y)}catch{Ye.b.Warn("Anchor could not be updated")}}else{var p={id:Vv++,xrAnchor:s,remove:s.delete},y=n._updateAnchorWithXRFrame(s,p,e);n._trackedAnchors.push(y),n.onAnchorAddedObservable.notifyObservers(y);var P=n._futureAnchors.filter(function(O){return O.nativeAnchor===s})[0];P&&(P.resolve(y),P.resolved=!0)}}),this._lastFrameDetected=i}this._futureAnchors.forEach(function(s){s.resolved||s.submitted||(n._createAnchorAtTransformation(s.xrTransformation,e).then(function(d){s.nativeAnchor=d},function(d){s.resolved=!0,s.reject(d)}),s.submitted=!0)})}},t.prototype._findIndexInAnchorArray=function(e){for(var n=0;n<this._trackedAnchors.length;++n)if(this._trackedAnchors[n].xrAnchor===e)return n;return-1},t.prototype._updateAnchorWithXRFrame=function(e,n,i){var o=i.getPose(e.anchorSpace,this._xrSessionManager.referenceSpace);if(o){var a=n.transformationMatrix||new u.a;u.a.FromArrayToRef(o.transform.matrix,0,a),this._xrSessionManager.scene.useRightHandedSystem||a.toggleModelMatrixHandInPlace(),n.transformationMatrix=a,this._options.worldParentNode&&a.multiplyToRef(this._options.worldParentNode.getWorldMatrix(),a)}return n},t.prototype._createAnchorAtTransformation=function(e,n){var i;return Object(c.b)(this,void 0,void 0,function(){return Object(c.e)(this,function(o){if(!n.createAnchor)throw this.detach(),new Error("Anchors are not enabled in your browser");try{return[2,n.createAnchor(e,(i=this._referenceSpaceForFrameAnchors)!==null&&i!==void 0?i:this._xrSessionManager.referenceSpace)]}catch(a){throw new Error(a)}return[2]})})},t.Name=ii.ANCHOR_SYSTEM,t.Version=1,t}(ri);Yn.AddWebXRFeature(Fa.Name,function(r,t){return function(){return new Fa(r,t)}},Fa.Version);var kv=0,Ba=function(r){function t(e,n){n===void 0&&(n={});var i=r.call(this,e)||this;return i._options=n,i._detectedPlanes=[],i._enabled=!1,i._lastFrameDetected=new Set,i.onPlaneAddedObservable=new x.c,i.onPlaneRemovedObservable=new x.c,i.onPlaneUpdatedObservable=new x.c,i.xrNativeFeatureName="plane-detection",i._xrSessionManager.session?i._init():i._xrSessionManager.onXRSessionInit.addOnce(function(){i._init()}),i}return Object(c.d)(t,r),t.prototype.detach=function(){if(!r.prototype.detach.call(this))return!1;if(!this._options.doNotRemovePlanesOnSessionEnded)for(;this._detectedPlanes.length;){var e=this._detectedPlanes.pop();e&&this.onPlaneRemovedObservable.notifyObservers(e)}return!0},t.prototype.dispose=function(){r.prototype.dispose.call(this),this.onPlaneAddedObservable.clear(),this.onPlaneRemovedObservable.clear(),this.onPlaneUpdatedObservable.clear()},t.prototype.isCompatible=function(){return typeof XRPlane<"u"},t.prototype._onXRFrame=function(e){var n=this;if(this.attached&&this._enabled&&e){var i=e.worldInformation.detectedPlanes;if(i){var o=this._detectedPlanes.filter(function(s){return!i.has(s.xrPlane)}).map(function(s){return n._detectedPlanes.indexOf(s)}),a=0;o.forEach(function(s){var d=n._detectedPlanes.splice(s-a,1)[0];n.onPlaneRemovedObservable.notifyObservers(d),a++}
11747),i.forEach(function(s){if(n._lastFrameDetected.has(s)){if(s.lastChangedTime===n._xrSessionManager.currentTimestamp){var d=n.findIndexInPlaneArray(s);y=n._detectedPlanes[d],n._updatePlaneWithXRPlane(s,y,e),n.onPlaneUpdatedObservable.notifyObservers(y)}}else{var p={id:kv++,xrPlane:s,polygonDefinition:[]},y=n._updatePlaneWithXRPlane(s,p,e);n._detectedPlanes.push(y),n.onPlaneAddedObservable.notifyObservers(y)}}),this._lastFrameDetected=i}}},t.prototype._init=function(){var e,n,i=this,o=function(){i._enabled=!0,i._detectedPlanes.length&&(i._detectedPlanes.length=0)};this._xrSessionManager.session.updateWorldTrackingState?(this._xrSessionManager.session.updateWorldTrackingState({planeDetectionState:{enabled:!0}}),o()):!((n=(e=this._xrSessionManager.session.worldTrackingState)===null||e===void 0?void 0:e.planeDetectionState)===null||n===void 0)&&n.enabled&&o()},t.prototype._updatePlaneWithXRPlane=function(e,n,i){var o=this;n.polygonDefinition=e.polygon.map(function(d){var p=o._xrSessionManager.scene.useRightHandedSystem?1:-1;return new u.e(d.x,d.y,d.z*p)});var a=i.getPose(e.planeSpace,this._xrSessionManager.referenceSpace);if(a){var s=n.transformationMatrix||new u.a;u.a.FromArrayToRef(a.transform.matrix,0,s),this._xrSessionManager.scene.useRightHandedSystem||s.toggleModelMatrixHandInPlace(),n.transformationMatrix=s,this._options.worldParentNode&&s.multiplyToRef(this._options.worldParentNode.getWorldMatrix(),s)}return n},t.prototype.findIndexInPlaneArray=function(e){for(var n=0;n<this._detectedPlanes.length;++n)if(this._detectedPlanes[n].xrPlane===e)return n;return-1},t.Name=ii.PLANE_DETECTION,t.Version=1,t}(ri);Yn.AddWebXRFeature(Ba.Name,function(r,t){return function(){return new Ba(r,t)}},Ba.Version);var Ua=function(r){function t(e,n){n===void 0&&(n={});var i=r.call(this,e)||this;return i.options=n,i.onBackgroundStateChangedObservable=new x.c,i}return Object(c.d)(t,r),t.prototype.attach=function(){return this._setBackgroundState(!1),r.prototype.attach.call(this)},t.prototype.detach=function(){return this._setBackgroundState(!0),r.prototype.detach.call(this)},t.prototype.dispose=function(){r.prototype.dispose.call(this),this.onBackgroundStateChangedObservable.clear()},t.prototype._onXRFrame=function(e){},t.prototype._setBackgroundState=function(e){var n=this._xrSessionManager.scene;if(!this.options.ignoreEnvironmentHelper)if(this.options.environmentHelperRemovalFlags){if(this.options.environmentHelperRemovalFlags.skyBox){var i=n.getMeshByName("BackgroundSkybox");i&&i.setEnabled(e)}if(this.options.environmentHelperRemovalFlags.ground){var o=n.getMeshByName("BackgroundPlane");o&&o.setEnabled(e)}}else{var a=n.getMeshByName("BackgroundHelper");a&&a.setEnabled(e)}this.options.backgroundMeshes&&this.options.backgroundMeshes.forEach(function(s){return s.setEnabled(e)}),this.onBackgroundStateChangedObservable.notifyObservers(e)},t.Name=ii.BACKGROUND_REMOVER,t.Version=1,t}(ri);Yn.AddWebXRFeature(Ua.Name,function(r,t){return function(){return new Ua(r,t)}},Ua.Version,!0);var Gv=function(){},Va=function(r){function t(e,n){var i=r.call(this,e)||this;return i._options=n,i._attachController=function(o){if(!i._controllers[o.uniqueId])if(i._xrSessionManager.scene.isPhysicsEnabled()||l.a.Warn("physics engine not enabled, skipped. Please add this controller manually."),i._options.physicsProperties.useControllerMesh&&o.inputSource.gamepad)o.onMotionControllerInitObservable.addOnce(function(P){P.onModelLoadedObservable.addOnce(function(){var O=new Ct.a(P.rootMesh,Ct.a.MeshImpostor,Object(c.a)({mass:0},i._options.physicsProperties)),U=o.grip||o.pointer;i._controllers[o.uniqueId]={xrController:o,impostor:O,oldPos:U.position.clone(),oldRotation:U.rotationQuaternion.clone()}})});else{var a=i._options.physicsProperties.impostorType||Ct.a.SphereImpostor,s=i._options.physicsProperties.impostorSize||.1,d=Nn.a.CreateSphere("impostor-mesh-"+o.uniqueId,{diameterX:typeof s=="number"?s:s.width,diameterY:typeof s=="number"?s:s.height,diameterZ:typeof s=="number"?s:s.depth});d.isVisible=i._debugMode,d.isPickable=!1,d.rotationQuaternion=new u.b;var p=o.grip||o.pointer;d.position.copyFrom(p.position),d.rotationQuaternion.copyFrom(p.rotationQuaternion);var y=new Ct.a(d,a,Object(c.a)({mass:0},i._options.physicsProperties));i._controllers[o.uniqueId]={xrController:o,impostor:y,impostorMesh:d}}},i._controllers={},i._debugMode=!1,i._delta=0,i._lastTimestamp=0,i._tmpQuaternion=new u.b,i._tmpVector=new u.e,i._options.physicsProperties||(i._options.physicsProperties={}),i}return Object(c.d)(t,r),t.prototype._enablePhysicsDebug=function(){var e=this;
11747this._debugMode=!0,Object.keys(this._controllers).forEach(function(n){var i=e._controllers[n];i.impostorMesh&&(i.impostorMesh.isVisible=!0)})},t.prototype.addController=function(e){this._attachController(e)},t.prototype.attach=function(){var e=this;if(!r.prototype.attach.call(this))return!1;if(!this._options.xrInput)return!0;if(this._options.xrInput.controllers.forEach(this._attachController),this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable,this._attachController),this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable,function(o){e._detachController(o.uniqueId)}),this._options.enableHeadsetImpostor){var n=this._options.headsetImpostorParams||{impostorType:Ct.a.SphereImpostor,restitution:.8,impostorSize:.3},i=n.impostorSize||.3;this._headsetMesh=Nn.a.CreateSphere("headset-mesh",{diameterX:typeof i=="number"?i:i.width,diameterY:typeof i=="number"?i:i.height,diameterZ:typeof i=="number"?i:i.depth}),this._headsetMesh.rotationQuaternion=new u.b,this._headsetMesh.isVisible=!1,this._headsetImpostor=new Ct.a(this._headsetMesh,n.impostorType,Object(c.a)({mass:0},n))}return!0},t.prototype.detach=function(){var e=this;return!!r.prototype.detach.call(this)&&(Object.keys(this._controllers).forEach(function(n){e._detachController(n)}),this._headsetMesh&&this._headsetMesh.dispose(),!0)},t.prototype.getHeadsetImpostor=function(){return this._headsetImpostor},t.prototype.getImpostorForController=function(e){var n=typeof e=="string"?e:e.uniqueId;return this._controllers[n]?this._controllers[n].impostor:null},t.prototype.setPhysicsProperties=function(e){this._options.physicsProperties=Object(c.a)(Object(c.a)({},this._options.physicsProperties),e)},t.prototype._onXRFrame=function(e){var n=this;this._delta=this._xrSessionManager.currentTimestamp-this._lastTimestamp,this._lastTimestamp=this._xrSessionManager.currentTimestamp,this._headsetMesh&&(this._headsetMesh.position.copyFrom(this._options.xrInput.xrCamera.position),this._headsetMesh.rotationQuaternion.copyFrom(this._options.xrInput.xrCamera.rotationQuaternion)),Object.keys(this._controllers).forEach(function(i){var o=n._controllers[i],a=o.xrController.grip||o.xrController.pointer,s=o.oldPos||o.impostorMesh.position,d=o.oldRotation||o.impostorMesh.rotationQuaternion;if(a.position.subtractToRef(s,n._tmpVector),n._tmpVector.scaleInPlace(1e3/n._delta),o.impostor.setLinearVelocity(n._tmpVector),n._debugMode&&console.log(n._tmpVector,"linear"),!d.equalsWithEpsilon(a.rotationQuaternion)){d.conjugateInPlace().multiplyToRef(a.rotationQuaternion,n._tmpQuaternion);var p=Math.sqrt(n._tmpQuaternion.x*n._tmpQuaternion.x+n._tmpQuaternion.y*n._tmpQuaternion.y+n._tmpQuaternion.z*n._tmpQuaternion.z);if(n._tmpVector.set(n._tmpQuaternion.x,n._tmpQuaternion.y,n._tmpQuaternion.z),p<.001)n._tmpVector.scaleInPlace(2);else{var y=2*Math.atan2(p,n._tmpQuaternion.w);n._tmpVector.scaleInPlace(y/(p*(n._delta/1e3)))}o.impostor.setAngularVelocity(n._tmpVector),n._debugMode&&console.log(n._tmpVector,n._tmpQuaternion,"angular")}s.copyFrom(a.position),d.copyFrom(a.rotationQuaternion)})},t.prototype._detachController=function(e){var n=this._controllers[e];n&&(n.impostorMesh&&n.impostorMesh.dispose(),delete this._controllers[e])},t.Name=ii.PHYSICS_CONTROLLERS,t.Version=1,t}(ri);Yn.AddWebXRFeature(Va.Name,function(r,t){return function(){return new Va(r,t)}},Va.Version,!0);var ka=function(r){function t(e,n){n===void 0&&(n={});var i=r.call(this,e)||this;return i.options=n,i._tmpMat=new u.a,i._tmpPos=new u.e,i._tmpQuat=new u.b,i.initHitTestSource=function(o){if(o){var a=new XRRay(i.options.offsetRay||{}),s={space:i.options.useReferenceSpace?o:i._xrSessionManager.viewerReferenceSpace,offsetRay:a};i.options.entityTypes&&(s.entityTypes=i.options.entityTypes),s.space?i._xrSessionManager.session.requestHitTestSource(s).then(function(d){i._xrHitTestSource&&i._xrHitTestSource.cancel(),i._xrHitTestSource=d}):Ye.b.Warn("waiting for viewer reference space to initialize")}},i.autoCloneTransformation=!1,i.onHitTestResultObservable=new x.c,i.paused=!1,i.xrNativeFeatureName="hit-test",Ye.b.Warn("Hit test is an experimental and unstable feature."),i}return Object(c.d)(t,r),t.prototype.attach=function(){var e=this;if(!r.prototype.attach.call(this)||!this._xrSessionManager.session.requestHitTestSource)return!1;if(this.options.disablePermanentHitTest||(this._xrSessionManager.referenceSpace&&this.initHitTestSource(this._xrSessionManager.referenceSpace),this._xrSessionManager.onXRReferenceSpaceChanged.add(this.initHitTestSource)),this.options.enableTransientHitTest){var n=new XRRay(this.options.transientOffsetRay||{});this._xrSessionManager.session.requestHitTestSourceForTransientInput({profile:"generic-touchscreen",offsetRay:n,entityTypes:this.options.entityTypes}).then(function(i){e._transientXrHitTestSource=i})}return!0},t.prototype.detach=function(){return!!r.prototype.detach.call(this)&&(this._xrHitTestSource&&(this._xrHitTestSource.cancel(),this._xrHitTestSource=null),this._xrSessionManager.onXRReferenceSpaceChanged.removeCallback(this.initHitTestSource),this._transientXrHitTestSource&&(this._transientXrHitTestSource.cancel(),this._transientXrHitTestSource=null),!0)},t.prototype.dispose=function(){r.prototype.dispose.call(this),this.onHitTestResultObservable.clear()},t.prototype._onXRFrame=function(e){var n=this;if(this.attached&&!this.paused){if(this._xrHitTestSource){var i=e.getHitTestResults(this._xrHitTestSource);this._processWebXRHitTestResult(i)}this._transientXrHitTestSource&&e.getHitTestResultsForTransientInput(this._transientXrHitTestSource).forEach(function(o){n._processWebXRHitTestResult(o.results,o.inputSource)})}},t.prototype._processWebXRHitTestResult=function(e,n){var i=this,o=[];e.forEach(function(a){var s=a.getPose(i._xrSessionManager.referenceSpace);if(s){var d=s.transform.position,p=s.transform.orientation;i._tmpPos.set(d.x,d.y,d.z),i._tmpQuat.set(p.x,p.y,p.z,p.w),u.a.FromFloat32ArrayToRefScaled(s.transform.matrix,0,1,i._tmpMat),i._xrSessionManager.scene.useRightHandedSystem||(i._tmpPos.z*=-1,i._tmpQuat.z*=-1,i._tmpQuat.w*=-1,i._tmpMat.toggleModelMatrixHandInPlace());var y={position:i.autoCloneTransformation?i._tmpPos.clone():i._tmpPos,rotationQuaternion:i.autoCloneTransformation?i._tmpQuat.clone():i._tmpQuat,transformationMatrix:i.autoCloneTransformation?i._tmpMat.clone():i._tmpMat,inputSource:n,isTransient:!!n,xrHitResult:a};o.push(y)}}),this.onHitTestResultObservable.notifyObservers(o)},t.Name=ii.HIT_TEST,t.Version=2,t}(ri);Yn.AddWebXRFeature(ka.Name,function(r,t){return function(){return new ka(r,t)}}
11747,ka.Version,!1);var Ga=function(r){function t(e){var n=r.call(this,e)||this;return n._enabled=!1,n._featurePointCloud=[],n.onFeaturePointsAddedObservable=new x.c,n.onFeaturePointsUpdatedObservable=new x.c,n.xrNativeFeatureName="bjsfeature-points",n._xrSessionManager.session?n._init():n._xrSessionManager.onXRSessionInit.addOnce(function(){n._init()}),n}return Object(c.d)(t,r),Object.defineProperty(t.prototype,"featurePointCloud",{get:function(){return this._featurePointCloud},enumerable:!1,configurable:!0}),t.prototype.detach=function(){return!!r.prototype.detach.call(this)&&(this.featurePointCloud.length=0,!0)},t.prototype.dispose=function(){r.prototype.dispose.call(this),this._featurePointCloud.length=0,this.onFeaturePointsUpdatedObservable.clear(),this.onFeaturePointsAddedObservable.clear()},t.prototype._onXRFrame=function(e){if(this.attached&&this._enabled&&e){var n=e.featurePointCloud;if(n&&n.length!==0){if(n.length%5!=0)throw new Error("Received malformed feature point cloud of length: "+n.length);for(var i=n.length/5,o=new Array,a=new Array,s=0;s<i;s++){var d=5*s,p=n[d+4];this._featurePointCloud[p]?o.push(p):(this._featurePointCloud[p]={position:new u.e,confidenceValue:0},a.push(p)),this._featurePointCloud[p].position.x=n[d],this._featurePointCloud[p].position.y=n[d+1],this._featurePointCloud[p].position.z=n[d+2],this._featurePointCloud[p].confidenceValue=n[d+3]}a.length>0&&this.onFeaturePointsAddedObservable.notifyObservers(a),o.length>0&&this.onFeaturePointsUpdatedObservable.notifyObservers(o)}}},t.prototype._init=function(){this._xrSessionManager.session.trySetFeaturePointCloudEnabled&&this._xrSessionManager.session.trySetFeaturePointCloudEnabled(!0)&&(this._enabled=!0)},t.Name=ii.FEATURE_POINTS,t.Version=1,t}(ri);Yn.AddWebXRFeature(Ga.Name,function(r){return function(){return new Ga(r)}},Ga.Version);var xf=function(){function r(t,e,n,i,o){this.xrController=t,this.trackedMeshes=e,this._handMesh=n,this._rigMapping=i,this._defaultHandMesh=!1,this._transformNodeMapping=[],this.handPartsDefinition=this.generateHandPartsDefinition(t.inputSource.hand),this._scene=e[0].getScene(),this._handMesh&&this._rigMapping?this._defaultHandMesh=!1:o||this._generateDefaultHandMesh(),this.xrController.motionController&&(this.xrController.motionController.rootMesh?this.xrController.motionController.rootMesh.setEnabled(!1):this.xrController.motionController.onModelLoadedObservable.add(function(a){a.rootMesh&&a.rootMesh.setEnabled(!1)})),this.xrController.onMotionControllerInitObservable.add(function(a){a.onModelLoadedObservable.add(function(s){s.rootMesh&&s.rootMesh.setEnabled(!1)}),a.rootMesh&&a.rootMesh.setEnabled(!1)})}return r.prototype.generateHandPartsDefinition=function(t){var e;return(e={}).wrist=[t.WRIST],e.thumb=[t.THUMB_METACARPAL,t.THUMB_PHALANX_PROXIMAL,t.THUMB_PHALANX_DISTAL,t.THUMB_PHALANX_TIP],e.index=[t.INDEX_METACARPAL,t.INDEX_PHALANX_PROXIMAL,t.INDEX_PHALANX_INTERMEDIATE,t.INDEX_PHALANX_DISTAL,t.INDEX_PHALANX_TIP],e.middle=[t.MIDDLE_METACARPAL,t.MIDDLE_PHALANX_PROXIMAL,t.MIDDLE_PHALANX_INTERMEDIATE,t.MIDDLE_PHALANX_DISTAL,t.MIDDLE_PHALANX_TIP],e.ring=[t.RING_METACARPAL,t.RING_PHALANX_PROXIMAL,t.RING_PHALANX_INTERMEDIATE,t.RING_PHALANX_DISTAL,t.RING_PHALANX_TIP],e.little=[t.LITTLE_METACARPAL,t.LITTLE_PHALANX_PROXIMAL,t.LITTLE_PHALANX_INTERMEDIATE,t.LITTLE_PHALANX_DISTAL,t.LITTLE_PHALANX_TIP],e},r.prototype.updateFromXRFrame=function(t,e,n){var i=this;n===void 0&&(n=2);var o=this.xrController.inputSource.hand;o&&this.trackedMeshes.forEach(function(a,s){var d=o[s];if(d){var p=t.getJointPose(d,e);if(!p||!p.transform)return;var y=p.transform.position,P=p.transform.orientation;a.position.set(y.x,y.y,y.z),a.rotationQuaternion.set(P.x,P.y,P.z,P.w);var O=(p.radius||.008)*n;a.scaling.set(O,O,O),i._handMesh&&i._rigMapping&&i._rigMapping[s]&&(i._transformNodeMapping[s]=i._transformNodeMapping[s]||i._scene.getTransformNodeByName(i._rigMapping[s]),i._transformNodeMapping[s]&&(i._transformNodeMapping[s].position.copyFrom(a.position),i._transformNodeMapping[s].rotationQuaternion.copyFrom(a.rotationQuaternion),a.isVisible=!1)),a.getScene().useRightHandedSystem||(a.position.z*=-1,a.rotationQuaternion.z*=-1,a.rotationQuaternion.w*=-1)}})},r.prototype.getHandPartMeshes=function(t){var e=this;return this.handPartsDefinition[t].map(function(n){return e.trackedMeshes[n]})}
11747,r.prototype.dispose=function(){this.trackedMeshes.forEach(function(t){return t.dispose()}),this._defaultHandMesh&&this._handMesh&&this._handMesh.dispose()},r.prototype._generateDefaultHandMesh=function(){return Object(c.b)(this,void 0,void 0,function(){var t,e,n,i,o,a,s,d;return Object(c.e)(this,function(p){switch(p.label){case 0:return p.trys.push([0,3,,4]),t=this.xrController.inputSource.handedness==="right"?"right":"left",e=(t==="right"?"r":"l")+"_hand_"+(this._scene.useRightHandedSystem?"r":"l")+"hs.glb",[4,Ut.ImportMeshAsync("","https://assets.babylonjs.com/meshes/HandMeshes/",e,this._scene)];case 1:return n=p.sent(),i={base:M.a.FromInts(116,63,203),fresnel:M.a.FromInts(149,102,229),fingerColor:M.a.FromInts(177,130,255),tipFresnel:M.a.FromInts(220,200,255)},[4,(o=new ya("leftHandShader",this._scene,{emitComments:!1})).loadAsync("https://patrickryanms.github.io/BabylonJStextures/Demos/xrHandMesh/handsShader.json")];case 2:if(p.sent(),o.build(!1),o.needDepthPrePass=!0,o.transparencyMode=Ht.a.MATERIAL_ALPHABLEND,o.alphaMode=Ue.a.ALPHA_COMBINE,(a={base:o.getBlockByName("baseColor"),fresnel:o.getBlockByName("fresnelColor"),fingerColor:o.getBlockByName("fingerColor"),tipFresnel:o.getBlockByName("tipFresnelColor")}).base.value=i.base,a.fresnel.value=i.fresnel,a.fingerColor.value=i.fingerColor,a.tipFresnel.value=i.tipFresnel,n.meshes[1].material=o,this._defaultHandMesh=!0,this._handMesh=n.meshes[0],this._rigMapping=["wrist_","thumb_metacarpal_","thumb_proxPhalanx_","thumb_distPhalanx_","thumb_tip_","index_metacarpal_","index_proxPhalanx_","index_intPhalanx_","index_distPhalanx_","index_tip_","middle_metacarpal_","middle_proxPhalanx_","middle_intPhalanx_","middle_distPhalanx_","middle_tip_","ring_metacarpal_","ring_proxPhalanx_","ring_intPhalanx_","ring_distPhalanx_","ring_tip_","little_metacarpal_","little_proxPhalanx_","little_intPhalanx_","little_distPhalanx_","little_tip_"].map(function(y){return y+(t==="right"?"R":"L")}),!(s=this._scene.getTransformNodeByName(this._rigMapping[0])))throw new Error("could not find the wrist node");return s.parent&&s.parent.rotate(ye.a.Y,Math.PI),[3,4];case 3:return d=p.sent(),Ye.b.Error("error loading hand mesh"),console.log(d),[3,4];case 4:return[2]}})})},r}(),za=function(r){function t(e,n){var i=r.call(this,e)||this;return i.options=n,i.onHandAddedObservable=new x.c,i.onHandRemovedObservable=new x.c,i._hands={},i._attachHand=function(o){var a,s,d,p,y,P,O,U,F,z;if(o.inputSource.hand&&!i._hands[o.uniqueId]){var J=o.inputSource.hand,ie=[],se=((a=i.options.jointMeshes)===null||a===void 0?void 0:a.sourceMesh)||Nn.a.CreateSphere("jointParent",{diameter:1});se.isVisible=!!(!((s=i.options.jointMeshes)===null||s===void 0)&&s.keepOriginalVisible);for(var ce=0;ce<J.length;++ce){var ue=se.createInstance(o.uniqueId+"-handJoint-"+ce);if(!((d=i.options.jointMeshes)===null||d===void 0)&&d.onHandJointMeshGenerated){var fe=i.options.jointMeshes.onHandJointMeshGenerated(ue,ce,o.uniqueId);fe&&fe!==ue&&(ue.dispose(),ue=fe)}if(ue.isPickable=!1,(p=i.options.jointMeshes)===null||p===void 0?void 0:p.enablePhysics){var ve=i.options.jointMeshes.physicsProps||{},Te=ve.impostorType!==void 0?ve.impostorType:Ct.a.SphereImpostor;ue.physicsImpostor=new Ct.a(ue,Te,Object(c.a)({mass:0},ve))}ue.rotationQuaternion=new u.b,!((y=i.options.jointMeshes)===null||y===void 0)&&y.invisible&&(ue.isVisible=!1),ie.push(ue)}var Oe=o.inputSource.handedness==="right"?"right":"left",Pe=((P=i.options.jointMeshes)===null||P===void 0?void 0:P.handMeshes)&&((O=i.options.jointMeshes)===null||O===void 0?void 0:O.handMeshes[Oe]),Ee=((U=i.options.jointMeshes)===null||U===void 0?void 0:U.rigMapping)&&((F=i.options.jointMeshes)===null||F===void 0?void 0:F.rigMapping[Oe]),Se=new xf(o,ie,Pe,Ee,(z=i.options.jointMeshes)===null||z===void 0?void 0:z.disableDefaultHandMesh);i._hands[o.uniqueId]={handObject:Se,id:t._idCounter++},i.onHandAddedObservable.notifyObservers(Se)}},i.xrNativeFeatureName="hand-tracking",i}return Object(c.d)(t,r),t.prototype.isCompatible=function(){return typeof XRHand<"u"},t.prototype.attach=function(){var e=this;return!!r.prototype.attach.call(this)&&(this.options.xrInput.controllers.forEac
11747h(this._attachHand),this._addNewAttachObserver(this.options.xrInput.onControllerAddedObservable,this._attachHand),this._addNewAttachObserver(this.options.xrInput.onControllerRemovedObservable,function(n){e._detachHand(n.uniqueId)}),!0)},t.prototype.detach=function(){var e=this;return!!r.prototype.detach.call(this)&&(Object.keys(this._hands).forEach(function(n){e._detachHand(n)}),!0)},t.prototype.dispose=function(){r.prototype.dispose.call(this),this.onHandAddedObservable.clear()},t.prototype.getHandByControllerId=function(e){var n;return((n=this._hands[e])===null||n===void 0?void 0:n.handObject)||null},t.prototype.getHandByHandedness=function(e){var n=this,i=Object.keys(this._hands).map(function(o){return n._hands[o].handObject.xrController.inputSource.handedness}).indexOf(e);return i!==-1?this._hands[i].handObject:null},t.prototype._onXRFrame=function(e){var n=this;Object.keys(this._hands).forEach(function(i){var o;n._hands[i].handObject.updateFromXRFrame(e,n._xrSessionManager.referenceSpace,(o=n.options.jointMeshes)===null||o===void 0?void 0:o.scaleFactor)})},t.prototype._detachHand=function(e){this._hands[e]&&(this.onHandRemovedObservable.notifyObservers(this._hands[e].handObject),this._hands[e].handObject.dispose())},t._idCounter=0,t.Name=ii.HAND_TRACKING,t.Version=1,t}(ri);Yn.AddWebXRFeature(za.Name,function(r,t){return function(){return new za(r,t)}},za.Version,!1);var Rf=function(r){function t(e,n,i){var o=r.call(this,e,zv["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 Object(c.d)(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=Ut.IsPluginForExtensionAvailable(".glb");return e||l.a.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 l.a.Log("Skipping unknown button at index: "+o+" with mapped name: "+i);var d=n._getChildByName(n.rootMesh,s);if(!d)return void l.a.Warn("Missing button mesh with name: "+s);if(a.valueMesh=n._getImmediateChildByName(d,n._mapping.defaultButton.valueNodeName),a.pressedMesh=n._getImmediateChildByName(d,n._mapping.defaultButton.pressedNodeName),a.unpressedMesh=n._getImmediateChildByName(d,n._mapping.defaultButton.unpressedNodeName),a.valueMesh&&a.pressedMesh&&a.unpressedMesh){var p=n.getComponent(i);p&&p.onButtonStateChangedObservable.add(function(y){n._lerpTransform(a,y.value)},void 0,!0)}else l.a.Warn("Missing button submesh under mesh with name: "+s)}}),this.getComponentIds().forEach(function(i,o){var a=n.getComponent(i);a.isAxes()&&["x-axis","y-axis"].forEach(function(s){if(n.rootMesh){var d=n._mapping.axes[i][s],p=n._getChildByName(n.rootMesh,d.rootNodeName);p?(d.valueMesh=n._getImmediateChildByName(p,n._mapping.defaultAxis.valueNodeName),d.minMesh=n._getImmediateChildByName(p,n._mapping.defaultAxis.minNodeName),d.maxMesh=n._getImmediateChildByName(p,n._mapping.defaultAxis.maxNodeName),d.valueMesh&&d.minMesh&&d.maxMesh?a&&a.onAxisValueChangedObservable.add(function(y){var P=s==="x-axis"?y.x:y.y;n._lerpTransform(d,P,!0)},void 0,!0):l.a.Warn("Missing axis submesh under mesh with name: "+d.rootNodeName)):l.a.Warn("Missing axis mesh with name: "+d.rootNodeName)}})}))},t.prototype._setRootMesh=function(e){var n;this.rootMesh=new De.a(this.profileId+" "+this.handedness,this.scene),this.rootMesh.isPickable=!1;for(var i=0;i<e.length;i++){var o=e[i];o.isPickable=!1,o.parent||(n=o)}n&&n.setParent(this.rootMesh),this.scene.useRightHandedSystem||(this.rootMesh.rotationQuaternion=u.b.FromEulerAngles(0,Math.PI,0))},t.prototype._updateModel=function(){},t.MODEL_BASE_URL="https://controllers.babylonjs.com/microsoft/",t.MODEL_LEFT_FILENAME="left.glb",t.MODEL_RIGHT_FILENAME="right.glb",t}(xr);wn.RegisterController("windows-mixed-reality",function(r,t){return new Rf(t,r.gamepad,r.handedness)});var zv={left:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{xr_standard_trigger_pressed:{componentProperty:"button",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_trigger_pressed_value",minNodeName:"xr_standard_trigger_pressed_min",maxNodeName:"xr_standard_trigger_pressed_max"}}},"xr-standard-squeeze":{type:"squeeze",gamepadIndices:{button:1},rootNodeName:"xr_standard_squeeze",visualResponses:{xr_standard_squeeze_pressed:{componentProperty:"button",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_squeeze_pressed_value",minNodeName:"xr_standard_squeeze_pressed_min",maxNodeName:"xr_standard_squeeze_pressed_max"}}},"xr-standard-touchpad":{type:"touchpad",gamepadIndices:{button:2,xAxis:0,yAxis:1},rootNodeName:"xr_standard_touchpad",visualResponses:{xr_standard_touchpad_pressed:{componentProperty:"button",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_touchpad_pressed_value",minNodeName:"xr_standard_touchpad_pressed_min",maxNodeName:"xr_standard_touchpad_pressed_max"},xr_standard_touchpad_xaxis_pressed:{componentProperty:"xAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_touchpad_xaxis_pressed_value",minNodeName:"xr_standard_touchpad_xaxis_pressed_min",maxNodeName:"xr_standard_touchpad_xaxis_pressed_max"},xr_standard_touchpad_yaxis_pressed:{componentProperty:"yAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_touchpad_yaxis_pressed_value",minNodeName:"xr_standard_touchpad_yaxis_pressed_min",maxNodeName:"xr_standard_touchpad_yaxis_pressed_max"},xr_standard_touchpad_xaxis_touched:{componentProperty:"xAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_touchpad_xaxis_touched_value",minNodeName:"xr_standard_touchpad_xaxis_touched_min",maxNodeName:"xr_standard_touchpad_xaxis_touched_max"},xr_standard_touchpad_yaxis_touched:{componentProperty:"yAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_touchpad_yaxis_touched_value",minNodeName:"xr_standard_touchpad_yaxis_touched_min",maxNodeName:"xr_standard_touchpad_yaxis_touched_max"},xr_standard_touchpad_axes_touched:{componentProperty:"state",states:["touched","pressed"],valueNodeProperty:"visibility",valueNodeName:"xr_standard_touchpad_axes_touched_value"}},touchPointNodeName:"xr_standard_touchpad_axes_touched_value"},"xr-standard-thumbstick":{type:"thumbstick",gamepadIndices:{button:3,xAxis:2,yAxis:3},rootNodeName:"xr_standard_thumbstick",visualResponses:{xr_standard_thumbstick_pressed:{componentProperty:"button",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_thumbstick_pressed_value",minNodeName:"xr_standard_thumbstick_pressed_min",maxNodeName:"xr_standard_thumbstick_pressed_max"},xr_standard_thumbstick_xaxis_pressed:{componentProperty:"xAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_thumbstick_xaxis_pressed_value",minNodeName:"xr_standard_thumbstick_xaxis_pressed_min",maxNodeName:"xr_standard_thumbstick_xaxis_pressed_max"},xr_standard_thumbstick_yaxis_pressed:{componentProperty:"yAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_thumbstick_yaxis_pressed_value",minNodeName:"xr_standard_thumbstick_yaxis_pressed_min",maxNodeName:"xr_standard_thumbstick_yaxis_pressed_max"}}}},gamepadMapping:"xr-standard",rootNodeName:"microsoft-mixed-reality-left",assetPath:"left.glb"},right:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{xr_standard_trigger_pressed:{componentProperty:"button",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_trigger_pressed_value",minNodeName:"xr_standard_trigger_pressed_min",maxNodeName:"xr_standard_trigger_pressed_max"}}},"xr-standard-squeeze":{type:"squeeze",gamepadIndices:{button:1},rootNodeName:"xr_standard_squeeze",visualResponses:{xr_standard_squeeze_pressed:{componentProperty:"button",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_squeeze_pressed_value",minNodeName:"xr_standard_squeeze_pressed_min",maxNodeName:"xr_standard_squeeze_pressed_max"}}},"xr-standard-touchpad":{type:"touchpad",gamepadIndices:{button:2,xAxis:0,yAxis:1},rootNodeName:"xr_standard_touchpad",visualResponses:{xr_standard_touchpad_pressed:{componentProperty:"button",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_touchpad_pressed_value",minNodeName:"xr_standard_touchpad_pressed_min",maxNodeName:"xr_standard_touchpad_pressed_max"},xr_standard_touchpad_xaxis_pressed:{componentProperty:"xAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_touchpad_xaxis_pressed_value",minNodeName:"xr_standard_touchpad_xaxis_pressed_min",maxNodeName:"xr_standard_touchpad_xaxis_pressed_max"},xr_standard_touchpad_yaxis_pressed:{componentProperty:"yAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_touchpad_yaxis_pressed_value",minNodeName:"xr_standard_touchpad_yaxis_pressed_min",maxNodeName:"xr_standard_touchpad_yaxis_pressed_max"},xr_standard_touchpad_xaxis_touched:{componentProperty:"xAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_touchpad_xaxis_touched_value",minNodeName:"xr_standard_touchpad_xaxis_touched_min",maxNodeName:"xr_standard_touchpad_xaxis_touched_max"},xr_standard_touchpad_yaxis_touched:{componentProperty:"yAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_touchpad_yaxis_touched_value",minNodeName:"xr_standard_touchpad_yaxis_touched_min",maxNodeName:"xr_standard_touchpad_yaxis_touched_max"},xr_standard_touchpad_axes_touched:{componentProperty:"state",states:["touched","pressed"],valueNodeProperty:"visibility",valueNodeName:"xr_standard_touchpad_axes_touched_value"}},touchPointNodeName:"xr_standard_touchpad_axes_touched_value"},"xr-standard-thumbstick":{type:"thumbstick",gamepadIndices:{button:3,xAxis:2,yAxis:3},rootNodeName:"xr_standard_thumbstick",visualResponses:{xr_standard_thumbstick_pressed:{componentProperty:"button",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_thumbstick_pressed_value",minNodeName:"xr_standard_thumbstick_pressed_min",maxNodeName:"xr_standard_thumbstick_pressed_max"},xr_standard_thumbstick_xaxis_pressed:{componentProperty:"xAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_thumbstick_xaxis_pressed_value",minNodeName:"xr_standard_thumbstick_xaxis_pressed_min",maxNodeName:"xr_standard_thumbstick_xaxis_pressed_max"},xr_standard_thumbstick_yaxis_pressed:{componentProperty:"yAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_thumbstick_yaxis_pressed_value",minNodeName:"xr_standard_thumbstick_yaxis_pressed_min",maxNodeName:"xr_standard_thumbstick_yaxis_pressed_max"}}}},gamepadMapping:"xr-standard",rootNodeName:"microsoft-mixed-reality-right",assetPath:"right.glb"}},rl=function(r){function t(e,n,i,o,a){a===void 0&&(a=!1);var s=r.call(this,e,jv[i],n,i)||this;return s._forceLegacyControllers=a,s.profileId="oculus-touch",s}return Object(c.d)(t,r),t.prototype._getFilenameAndPath=function(){return{filename:this.handedness==="left"?t.MODEL_LEFT_FILENAME:t.MODEL_RIGHT_FILENAME,path:this._isQuest()?t.QUEST_MODEL_BASE_URL:t.MODEL_BASE_URL}},t.prototype._getModelLoadingConstraints=function(){return!0},t.prototype._processLoadedModel=function(e){var n=this,i=this._isQuest(),o=this.handedness==="right"?-1:1;
11747this.getComponentIds().forEach(function(a){var s=a&&n.getComponent(a);s&&s.onButtonStateChangedObservable.add(function(d){if(n.rootMesh&&!n.disableAnimation)switch(a){case"xr-standard-trigger":return void(i||(n._modelRootNode.getChildren()[3].rotation.x=.2*-d.value,n._modelRootNode.getChildren()[3].position.y=.005*-d.value,n._modelRootNode.getChildren()[3].position.z=.005*-d.value));case"xr-standard-squeeze":return void(i||(n._modelRootNode.getChildren()[4].position.x=o*d.value*.0035));case"xr-standard-thumbstick":return;case"a-button":case"x-button":return void(i||(d.pressed?n._modelRootNode.getChildren()[1].position.y=-.001:n._modelRootNode.getChildren()[1].position.y=0));case"b-button":case"y-button":return void(i||(d.pressed?n._modelRootNode.getChildren()[2].position.y=-.001:n._modelRootNode.getChildren()[2].position.y=0))}},void 0,!0)})},t.prototype._setRootMesh=function(e){this.rootMesh=new De.a(this.profileId+" "+this.handedness,this.scene),this.scene.useRightHandedSystem||(this.rootMesh.rotationQuaternion=u.b.FromEulerAngles(0,Math.PI,0)),e.forEach(function(n){n.isPickable=!1}),this._isQuest()?this._modelRootNode=e[0]:(this._modelRootNode=e[1],this.rootMesh.position.y=.034,this.rootMesh.position.z=.052),this._modelRootNode.parent=this.rootMesh},t.prototype._updateModel=function(){},t.prototype._isQuest=function(){return!!navigator.userAgent.match(/Quest/gi)&&!this._forceLegacyControllers},t.MODEL_BASE_URL="https://controllers.babylonjs.com/oculus/",t.MODEL_LEFT_FILENAME="left.babylon",t.MODEL_RIGHT_FILENAME="right.babylon",t.QUEST_MODEL_BASE_URL="https://controllers.babylonjs.com/oculusQuest/",t}(xr);wn.RegisterController("oculus-touch",function(r,t){return new rl(t,r.gamepad,r.handedness)}),wn.RegisterController("oculus-touch-legacy",function(r,t){return new rl(t,r.gamepad,r.handedness,!0)});var jv={left:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}},"xr-standard-squeeze":{type:"squeeze",gamepadIndices:{button:1},rootNodeName:"xr_standard_squeeze",visualResponses:{}},"xr-standard-thumbstick":{type:"thumbstick",gamepadIndices:{button:3,xAxis:2,yAxis:3},rootNodeName:"xr_standard_thumbstick",visualResponses:{}},"x-button":{type:"button",gamepadIndices:{button:4},rootNodeName:"x_button",visualResponses:{}},"y-button":{type:"button",gamepadIndices:{button:5},rootNodeName:"y_button",visualResponses:{}},thumbrest:{type:"button",gamepadIndices:{button:6},rootNodeName:"thumbrest",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"oculus-touch-v2-left",assetPath:"left.glb"},right:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}},"xr-standard-squeeze":{type:"squeeze",gamepadIndices:{button:1},rootNodeName:"xr_standard_squeeze",visualResponses:{}},"xr-standard-thumbstick":{type:"thumbstick",gamepadIndices:{button:3,xAxis:2,yAxis:3},rootNodeName:"xr_standard_thumbstick",visualResponses:{}},"a-button":{type:"button",gamepadIndices:{button:4},rootNodeName:"a_button",visualResponses:{}},"b-button":{type:"button",gamepadIndices:{button:5},rootNodeName:"b_button",visualResponses:{}},thumbrest:{type:"button",gamepadIndices:{button:6},rootNodeName:"thumbrest",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"oculus-touch-v2-right",assetPath:"right.glb"}},Of=function(r){function t(e,n,i){var o=r.call(this,e,Hv[i],n,i)||this;return o.profileId="htc-vive",o}return Object(c.d)(t,r),t.prototype._getFilenameAndPath=function(){return{filename:t.MODEL_FILENAME,path:t.MODEL_BASE_URL}},t.prototype._getModelLoadingConstraints=function(){return!0},t.prototype._processLoadedModel=function(e){var n=this;this.getComponentIds().forEach(function(i){var o=i&&n.getComponent(i);o&&o.onButtonStateChangedObservable.add(function(a){if(n.rootMesh&&!n.disableAnimation)switch(i){case"xr-standard-trigger":return void(n._modelRootNode.getChildren()[6].rotation.x=.15*-a.value);case"xr-standard-touchpad":case"xr-standard-squeeze":return}},void 0,!0)})},t.prototype._setRootMesh=function(e){this.rootMesh=new De.a(this.profileId+" "+this.handedness,this.scene),e.forEach(function(n){n.isPickable=!1}),this._modelRootNode=e[1],this._modelRootNode.parent=this.rootMesh,this.scene.useRightHandedSystem||(this.rootMesh.rotationQuaternion=u.b.FromEulerAngles(0,Math.PI,0))},t.prototype._updateModel=function(){},t.MODEL_BASE_URL="https://controllers.babylonjs.com/vive/",t.MODEL_FILENAME="wand.babylon",t}(xr);wn.RegisterController("htc-vive",function(r,t){return new Of(t,r.gamepad,r.handedness)});var Hv={left:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}},"xr-standard-squeeze":{type:"squeeze",gamepadIndices:{button:1},rootNodeName:"xr_standard_squeeze",visualResponses:{}},"xr-standard-touchpad":{type:"touchpad",gamepadIndices:{button:2,xAxis:0,yAxis:1},rootNodeName:"xr_standard_touchpad",visualResponses:{}},menu:{type:"button",gamepadIndices:{button:4},rootNodeName:"menu",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"htc_vive_none",assetPath:"none.glb"},right:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}},"xr-standard-squeeze":{type:"squeeze",gamepadIndices:{button:1},rootNodeName:"xr_standard_squeeze",visualResponses:{}},"xr-standard-touchpad":{type:"touchpad",gamepadIndices:{button:2,xAxis:0,yAxis:1},rootNodeName:"xr_standard_touchpad",visualResponses:{}},menu:{type:"button",gamepadIndices:{button:4},rootNodeName:"menu",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"htc_vive_none",assetPath:"none.glb"}
11747,none:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}},"xr-standard-squeeze":{type:"squeeze",gamepadIndices:{button:1},rootNodeName:"xr_standard_squeeze",visualResponses:{}},"xr-standard-touchpad":{type:"touchpad",gamepadIndices:{button:2,xAxis:0,yAxis:1},rootNodeName:"xr_standard_touchpad",visualResponses:{}},menu:{type:"button",gamepadIndices:{button:4},rootNodeName:"menu",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"htc-vive-none",assetPath:"none.glb"}}},function(Ae,v,f){f.d(v,"a",function(){return h});var B=f(34),_=function(){function b(){this.children=[]}return b.prototype.isValid=function(T){return!0},b.prototype.process=function(T,D){var w="";if(this.line){var N=this.line,I=D.processor;I&&(I.lineProcessor&&(N=I.lineProcessor(N,D.isFragment)),I.attributeProcessor&&B.a.StartsWith(this.line,"attribute")?N=I.attributeProcessor(this.line):I.varyingProcessor&&B.a.StartsWith(this.line,"varying")?N=I.varyingProcessor(this.line,D.isFragment):(I.uniformProcessor||I.uniformBufferProcessor)&&B.a.StartsWith(this.line,"uniform")&&(/uniform (.+) (.+)/.test(this.line)?I.uniformProcessor&&(N=I.uniformProcessor(this.line,D.isFragment)):I.uniformBufferProcessor&&(N=I.uniformBufferProcessor(this.line,D.isFragment),D.lookForClosingBracketForUniformBuffer=!0)),I.endOfUniformBufferProcessor&&D.lookForClosingBracketForUniformBuffer&&this.line.indexOf("}")!==-1&&(D.lookForClosingBracketForUniformBuffer=!1,N=I.endOfUniformBufferProcessor(this.line,D.isFragment))),w+=N+`\r
11748`}return this.children.forEach(function(V){w+=V.process(T,D)}),this.additionalDefineKey&&(T[this.additionalDefineKey]=this.additionalDefineValue||"true"),w},b}(),x=function(){function b(){}return Object.defineProperty(b.prototype,"currentLine",{get:function(){return this._lines[this.lineIndex]},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"canRead",{get:function(){return this.lineIndex<this._lines.length-1},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"lines",{set:function(T){this._lines=[];for(var D=0,w=T;D<w.length;D++){var N=w[D];if(N[0]!=="#")for(var I=N.split(";"),V=0;V<I.length;V++){var W=I[V];(W=W.trim())&&this._lines.push(W+(V!==I.length-1?";":""))}else this._lines.push(N)}},enumerable:!1,configurable:!0}),b}(),u=f(1),M=function(b){function T(){return b!==null&&b.apply(this,arguments)||this}return Object(u.d)(T,b),T.prototype.process=function(D,w){for(var N=0;N<this.children.length;N++){var I=this.children[N];if(I.isValid(D))return I.process(D,w)}return""},T}(_),R=function(b){function T(){return b!==null&&b.apply(this,arguments)||this}return Object(u.d)(T,b),T.prototype.isValid=function(D){return this.testExpression.isTrue(D)},T}(_),C=function(){function b(){}return b.prototype.isTrue=function(T){return!0},b.postfixToInfix=function(T){for(var D=[],w=0,N=T;w<N.length;w++){var I=N[w];if(b._OperatorPriority[I]===void 0)D.push(I);else{var V=D[D.length-1],W=D[D.length-2];D.length-=2,D.push("("+W+I+V+")")}}return D[D.length-1]},b.infixToPostfix=function(T){for(var D=[],w=-1,N=function(){(ne=ne.trim())!==""&&(D.push(ne),ne="")},I=function(pe){w<b._Stack.length-1&&(b._Stack[++w]=pe)},V=function(){return b._Stack[w]},W=function(){return w===-1?"!!INVALID EXPRESSION!!":b._Stack[w--]},j=0,ne="";j<T.length;){var te=T.charAt(j),de=j<T.length-1?T.substr(j,2):"";if(te==="(")ne="",I(te);else if(te===")"){for(N();w!==-1&&V()!=="(";)D.push(W());W()}else if(b._OperatorPriority[de]>1){for(N();w!==-1&&b._OperatorPriority[V()]>=b._OperatorPriority[de];)D.push(W());I(de),j++}else ne+=te;j++}for(N();w!==-1;)V()==="("?W():D.push(W());return D},b._OperatorPriority={")":0,"(":1,"||":2,"&&":3},b._Stack=["","","","","","","","","","","","","","","","","","","",""],b}(),m=function(b){function T(D,w){w===void 0&&(w=!1);var N=b.call(this)||this;return N.define=D,N.not=w,N}return Object(u.d)(T,b),T.prototype.isTrue=function(D){var w=D[this.define]!==void 0;return this.not&&(w=!w),w},T}(C),c=function(b){function T(){return b!==null&&b.apply(this,arguments)||this}return Object(u.d)(T,b),T.prototype.isTrue=function(D){return this.leftOperand.isTrue(D
11748)||this.rightOperand.isTrue(D)},T}(C),E=function(b){function T(){return b!==null&&b.apply(this,arguments)||this}return Object(u.d)(T,b),T.prototype.isTrue=function(D){return this.leftOperand.isTrue(D)&&this.rightOperand.isTrue(D)},T}(C),A=function(b){function T(D,w,N){var I=b.call(this)||this;return I.define=D,I.operand=w,I.testValue=N,I}return Object(u.d)(T,b),T.prototype.isTrue=function(D){var w=D[this.define];w===void 0&&(w=this.define);var N=!1,I=parseInt(w),V=parseInt(this.testValue);switch(this.operand){case">":N=I>V;break;case"<":N=I<V;break;case"<=":N=I<=V;break;case">=":N=I>=V;break;case"==":N=I===V}return N},T}(C),S=f(21),g=/defined\s*?\((.+?)\)/g,l=/defined\s*?\[(.+?)\]/g,h=function(){function b(){}return b.Process=function(T,D,w,N){var I=this;this._ProcessIncludes(T,D,function(V){var W=I._ProcessShaderConversion(V,D,N);w(W)})},b._ProcessPrecision=function(T,D){var w=D.shouldUseHighPrecisionShader;return T.indexOf("precision highp float")===-1?T=w?`precision highp float;
11749`+T:`precision mediump float;
11750`+T:w||(T=T.replace("precision highp float","precision mediump float")),T},b._ExtractOperation=function(T){var D=/defined\((.+)\)/.exec(T);if(D&&D.length)return new m(D[1].trim(),T[0]==="!");for(var w="",N=0,I=0,V=["==",">=","<=","<",">"];I<V.length&&(w=V[I],!((N=T.indexOf(w))>-1));I++);if(N===-1)return new m(T);var W=T.substring(0,N).trim(),j=T.substring(N+w.length).trim();return new A(W,w,j)},b._BuildSubExpression=function(T){T=T.replace(g,"defined[$1]");for(var D=[],w=0,N=C.infixToPostfix(T);w<N.length;w++){var I=N[w];if(I!=="||"&&I!=="&&")D.push(I);else if(D.length>=2){var V=D[D.length-1],W=D[D.length-2];D.length-=2;var j=I=="&&"?new E:new c;typeof V=="string"&&(V=V.replace(l,"defined($1)")),typeof W=="string"&&(W=W.replace(l,"defined($1)")),j.leftOperand=typeof W=="string"?this._ExtractOperation(W):W,j.rightOperand=typeof V=="string"?this._ExtractOperation(V):V,D.push(j)}}var ne=D[D.length-1];return typeof ne=="string"&&(ne=ne.replace(l,"defined($1)")),typeof ne=="string"?this._ExtractOperation(ne):ne},b._BuildExpression=function(T,D){var w=new R,N=T.substring(0,D),I=T.substring(D);return I=I.substring(0,(I.indexOf("//")+1||I.length+1)-1).trim(),w.testExpression=N==="#ifdef"?new m(I):N==="#ifndef"?new m(I,!0):this._BuildSubExpression(I),w},b._MoveCursorWithinIf=function(T,D,w){for(var N=T.currentLine;this._MoveCursor(T,w);){var I=(N=T.currentLine).substring(0,5).toLowerCase();if(I==="#else"){var V=new _;return D.children.push(V),void this._MoveCursor(T,V)}if(I==="#elif"){var W=this._BuildExpression(N,5);D.children.push(W),w=W}}},b._MoveCursor=function(T,D){for(;T.canRead;){T.lineIndex++;var w=T.currentLine,N=/(#ifdef)|(#else)|(#elif)|(#endif)|(#ifndef)|(#if)/.exec(w);if(N&&N.length)switch(N[0]){case"#ifdef":var I=new M;D.children.push(I);var V=this._BuildExpression(w,6);I.children.push(V),this._MoveCursorWithinIf(T,I,V);break;case"#else":case"#elif":return!0;case"#endif":return!1;case"#ifndef":I=new M,D.children.push(I),V=this._BuildExpression(w,7),I.children.push(V),this._MoveCursorWithinIf(T,I,V);break;case"#if":I=new M,V=this._BuildExpression(w,3),D.children.push(I),I.children.push(V),this._MoveCursorWithinIf(T,I,V)}else{var W=new _;if(W.line=w,D.children.push(W),w[0]==="#"&&w[1]==="d"){var j=w.replace(";","").split(" ");W.additionalDefineKey=j[1],j.length===3&&(W.additionalDefineValue=j[2])}}}return!1},b._EvaluatePreProcessors=function(T,D,w){var N=new _,I=new x;return I.lineIndex=-1,I.lines=T.split(`
11751`),this._MoveCursor(I,N),N.process(D,w)},b._PreparePreProcessors=function(T){for(var D={},w=0,N=T.defines;w<N.length;w++){var I=N[w].replace("#define","").replace(";","").trim().split(" ");D[I[0]]=I.length>1?I[1]:""}return D.GL_ES="true",D.__VERSION__=T.version,D[T.platformName]="true",D},b._ProcessShaderConversion=function(T,D,w){var N=this._ProcessPrecision(T,D);if(!D.processor)return N;if(N.indexOf("#version 3")!==-1)return N.replace("#version 300 es","");var I=D.defines,V=this._PreparePreProcessors(D);return D.processor.preProcessor&&(N=D.processor.preProcessor(N,I,D.isFragment)),N=this._EvaluatePreProcessors(N,V,D),D.processor.postProcessor&&(N=D.processor.postProcessor(N,I,D.isFragment,w)),N},b._ProcessIncludes=function(T,D,w){for(var N=this,I=/#include<(.+)>(\((.*)\))*(\[(.*)\])*/g,V=I.exec(T),W=new String(T),j=!1;V!=null;){var ne=V[1];if(ne.indexOf("__decl__")!==-1&&(ne=ne.replace(/__decl__/,""),D.supportsUniformBuffers&&(ne=(ne
11751=ne.replace(/Vertex/,"Ubo")).replace(/Fragment/,"Ubo")),ne+="Declaration"),!D.includesShadersStore[ne]){var te=D.shadersRepository+"ShadersInclude/"+ne+".fx";return void b._FileToolsLoadFile(te,function(Y){D.includesShadersStore[ne]=Y,N._ProcessIncludes(W,D,w)})}var de=D.includesShadersStore[ne];if(V[2])for(var pe=V[3].split(","),ae=0;ae<pe.length;ae+=2){var ee=new RegExp(pe[ae],"g"),K=pe[ae+1];de=de.replace(ee,K)}if(V[4]){var $=V[5];if($.indexOf("..")!==-1){var L=$.split(".."),G=parseInt(L[0]),Q=parseInt(L[1]),oe=de.slice(0);de="",isNaN(Q)&&(Q=D.indexParameters[L[1]]);for(var re=G;re<Q;re++)D.supportsUniformBuffers||(oe=oe.replace(/light\{X\}.(\w*)/g,function(Y,k){return k+"{X}"})),de+=oe.replace(/\{X\}/g,re.toString())+`
11752`}else D.supportsUniformBuffers||(de=de.replace(/light\{X\}.(\w*)/g,function(Y,k){return k+"{X}"})),de=de.replace(/\{X\}/g,$)}W=W.replace(V[0],de),j=j||de.indexOf("#include<")>=0,V=I.exec(T)}j?this._ProcessIncludes(W.toString(),D,w):w(W)},b._FileToolsLoadFile=function(T,D,w,N,I,V){throw S.a.WarnImport("FileTools")},b}()},function(Ae,v,f){f(26).a.prototype._readTexturePixels=function(B,_,x,u,M,R){u===void 0&&(u=-1),M===void 0&&(M=0),R===void 0&&(R=null);var C=this._gl;if(!C)throw new Error("Engine does not have gl rendering context.");if(!this._dummyFramebuffer){var m=C.createFramebuffer();if(!m)throw new Error("Unable to create dummy framebuffer");this._dummyFramebuffer=m}C.bindFramebuffer(C.FRAMEBUFFER,this._dummyFramebuffer),u>-1?C.framebufferTexture2D(C.FRAMEBUFFER,C.COLOR_ATTACHMENT0,C.TEXTURE_CUBE_MAP_POSITIVE_X+u,B._webGLTexture,M):C.framebufferTexture2D(C.FRAMEBUFFER,C.COLOR_ATTACHMENT0,C.TEXTURE_2D,B._webGLTexture,M);var c=B.type!==void 0?this._getWebGLTextureType(B.type):C.UNSIGNED_BYTE;switch(c){case C.UNSIGNED_BYTE:R||(R=new Uint8Array(4*_*x)),c=C.UNSIGNED_BYTE;break;default:R||(R=new Float32Array(4*_*x)),c=C.FLOAT}return C.readPixels(0,0,_,x,C.RGBA,c,R),C.bindFramebuffer(C.FRAMEBUFFER,this._currentFramebuffer),R}},function(Ae,v,f){var B="shadowsFragmentFunctions",_=`#ifdef SHADOWS
11753#ifndef SHADOWFLOAT
11754
11755float unpack(vec4 color)
11756{
11757const vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);
11758return dot(color,bit_shift);
11759}
11760#endif
11761float computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)
11762{
11763float mask=smoothstep(1.0-frustumEdgeFalloff,1.00000012,clamp(dot(clipSpace,clipSpace),0.,1.));
11764return mix(value,1.0,mask);
11765}
11766#define inline
11767float computeShadowCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues)
11768{
11769vec3 directionToLight=vPositionW-lightPosition;
11770float depth=length(directionToLight);
11771depth=(depth+depthValues.x)/(depthValues.y);
11772depth=clamp(depth,0.,1.0);
11773directionToLight=normalize(directionToLight);
11774directionToLight.y=-directionToLight.y;
11775#ifndef SHADOWFLOAT
11776float shadow=unpack(textureCube(shadowSampler,directionToLight));
11777#else
11778float shadow=textureCube(shadowSampler,directionToLight).x;
11779#endif
11780return depth>shadow ? darkness : 1.0;
11781}
11782#define inline
11783float computeShadowWithPoissonSamplingCube(vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues)
11784{
11785vec3 directionToLight=vPositionW-lightPosition;
11786float depth=length(directionToLight);
11787depth=(depth+depthValues.x)/(depthValues.y);
11788depth=clamp(depth,0.,1.0);
11789directionToLight=normalize(directionToLight);
11790directionToLight.y=-directionToLight.y;
11791float visibility=1.;
11792vec3 poissonDisk[4];
11793poissonDisk[0]=vec3(-1.0,1.0,-1.0);
11794poissonDisk[1]=vec3(1.0,-1.0,-1.0);
11795poissonDisk[2]=vec3(-1.0,-1.0,-1.0);
11796poissonDisk[3]=vec3(1.0,-1.0,1.0);
11797
11798#ifndef SHADOWFLOAT
11799if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))<depth) visibility-=0.25;
11800if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize))<depth) visibility-=0.25;
11801if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize))<depth) visibility-=0.25;
11802if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize))<depth) visibility-=0.25;
11803#else
11804if (textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize).x<depth) visibility-=0.25;
11805if (textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize).x<depth) visibility-=0.25;
11806if (textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize).x<depth) visibility-=0.25;
11807if (textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize).x<depth) visibility-=0.25;
11808#endif
11809return min(1.0,visibility+darkness);
11810}
11811#define inline
11812float computeShadowWithESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)
11813{
11814vec3 directionToLight=vPositionW-lightPosition;
11815float depth=length(directionToLight);
11816depth=(depth+depthValues.x)/(depthValues.y);
11817float shadowPixelDepth=clamp(depth,0.,1.0);
11818directionToLight=normalize(directionToLight);
11819directionToLight.y=-directionToLight.y;
11820#ifndef SHADOWFLOAT
11821float shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));
11822#else
11823float shadowMapSample=textureCube(shadowSampler,directionToLight).x;
11824#endif
11825float esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);
11826return esm;
11827}
11828#define inline
11829float computeShadowWithCloseESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)
11830{
11831vec3 directionToLight=vPositionW-lightPosition;
11832float depth=length(directionToLight);
11833depth=(depth+depthValues.x)/(depthValues.y);
11834float shadowPixelDepth=clamp(depth,0.,1.0);
11835directionToLight=normalize(directionToLight);
11836directionToLight.y=-directionToLight.y;
11837#ifndef SHADOWFLOAT
11838float shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));
11839#else
11840float shadowMapSample=textureCube(shadowSampler,directionToLight).x;
11841#endif
11842float esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);
11843return esm;
11844}
11845#ifdef WEBGL2
11846#define inline
11847float computeShadowCSM(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray shadowSampler,float darkness,float frustumEdgeFalloff)
11848{
11849vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
11850vec2 uv=0.5*clipSpace.xy+vec2(0.5);
11851vec3 uvLayer=vec3(uv.x,uv.y,layer);
11852float shadowPixelDepth=clamp(depthMetric,0.,1.0);
11853#ifndef SHADOWFLOAT
11854float shadow=unpack(texture2D(shadowSampler,uvLayer));
11855#else
11856float shadow=texture2D(shadowSampler,uvLayer).x;
11857#endif
11858return shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;
11859}
11860#endif
11861#define inline
11862float computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff)
11863{
11864vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
11865vec2 uv=0.5*clipSpace.xy+vec2(0.5);
11866if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
11867{
11868return 1.0;
11869}
11870else
11871{
11872float shadowPixelDepth=clamp(depthMetric,0.,1.0);
11873#ifndef SHADOWFLOAT
11874float shadow=unpack(texture2D(shadowSampler,uv));
11875#else
11876float shadow=texture2D(shadowSampler,uv).x;
11877#endif
11878return shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;
11879}
11880}
11881#define inline
11882float computeShadowWithPoissonSampling(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)
11883{
11884vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
11885vec2 uv=0.5*clipSpace.xy+vec2(0.5);
11886if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
11887{
11888return 1.0;
11889}
11890else
11891{
11892float shadowPixelDepth=clamp(depthMetric,0.,1.0);
11893float visibility=1.;
11894vec2 poissonDisk[4];
11895poissonDisk[0]=vec2(-0.94201624,-0.39906216);
11896poissonDisk[1]=vec2(0.94558609,-0.76890725);
11897poissonDisk[2]=vec2(-0.094184101,-0.92938870);
11898poissonDisk[3]=vec2(0.34495938,0.29387760);
11899
11900#ifndef SHADOWFLOAT
11901if (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))<shadowPixelDepth) visibility-=0.25;
11902if (unpack(texture2D(shadowSampler,uv+poissonDisk[1]*mapSize))<shadowPixelDepth) visibility-=0.25;
11903if (unpack(texture2D(shadowSampler,uv+poissonDisk[2]*mapSize))<shadowPixelDepth) visibility-=0.25;
11904if (unpack(texture2D(shadowSampler,uv+poissonDisk[3]*mapSize))<shadowPixelDepth) visibility-=0.25;
11905#else
11906if (texture2D(shadowSampler,uv+poissonDisk[0]*mapSize).x<shadowPixelDepth) visibility-=0.25;
11907if (texture2D(shadowSampler,uv+poissonDisk[1]*mapSize).x<shadowPixelDepth) visibility-=0.25;
11908if (texture2D(shadowSampler,uv+poissonDisk[2]*mapSize).x<shadowPixelDepth) visibility-=0.25;
11909if (texture2D(shadowSampler,uv+poissonDisk[3]*mapSize).x<shadowPixelDepth) visibility-=0.25;
11910#endif
11911return computeFallOff(min(1.0,visibility+darkness),clipSpace.xy,frustumEdgeFalloff);
11912}
11913}
11914#define inline
11915float computeShadowWithESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)
11916{
11917vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
11918vec2 uv=0.5*clipSpace.xy+vec2(0.5);
11919if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
11920{
11921return 1.0;
11922}
11923else
11924{
11925float shadowPixelDepth=clamp(depthMetric,0.,1.0);
11926#ifndef SHADOWFLOAT
11927float shadowMapSample=unpack(texture2D(shadowSampler,uv));
11928#else
11929float shadowMapSample=texture2D(shadowSampler,uv).x;
11930#endif
11931float esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);
11932return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);
11933}
11934}
11935#define inline
11936float computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)
11937{
11938vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
11939vec2 uv=0.5*clipSpace.xy+vec2(0.5);
11940if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
11941{
11942return 1.0;
11943}
11944else
11945{
11946float shadowPixelDepth=clamp(depthMetric,0.,1.0);
11947#ifndef SHADOWFLOAT
11948float shadowMapSample=unpack(texture2D(shadowSampler,uv));
11949#else
11950float shadowMapSample=texture2D(shadowSampler,uv).x;
11951#endif
11952float esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);
11953return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);
11954}
11955}
11956#ifdef WEBGL2
11957#define GREATEST_LESS_THAN_ONE 0.99999994
11958
11959#define inline
11960float computeShadowWithCSMPCF1(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,float darkness,float frustumEdgeFalloff)
11961{
11962vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
11963vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
11964uvDepth.z=clamp(uvDepth.z,0.,GREATEST_LESS_THAN_ONE);
11965vec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);
11966float shadow=texture(shadowSampler,uvDepthLayer);
11967shadow=mix(darkness,1.,shadow);
11968return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);
11969}
11970
11971
11972
11973#define inline
11974float computeShadowWithCSMPCF3(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
11975{
11976vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
11977vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
11978uvDepth.z=clamp(uvDepth.z,0.,GREATEST_LESS_THAN_ONE);
11979vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;
11980uv+=0.5;
11981vec2 st=fract(uv);
11982vec2 base_uv=floor(uv)-0.5;
11983base_uv*=shadowMapSizeAndInverse.y;
11984
11985
11986
11987
11988vec2 uvw0=3.-2.*st;
11989vec2 uvw1=1.+2.*st;
11990vec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;
11991vec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;
11992float shadow=0.;
11993shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));
11994shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));
11995shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));
11996shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));
11997shadow=shadow/16.;
11998shadow=mix(darkness,1.,shadow);
11999return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);
12000}
12001
12002
12003
12004#define inline
12005float computeShadowWithCSMPCF5(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
12006{
12007vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
12008vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
12009uvDepth.z=clamp(uvDepth.z,0.,GREATEST_LESS_THAN_ONE);
12010vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;
12011uv+=0.5;
12012vec2 st=fract(uv);
12013vec2 base_uv=floor(uv)-0.5;
12014base_uv*=shadowMapSizeAndInverse.y;
12015
12016
12017vec2 uvw0=4.-3.*st;
12018vec2 uvw1=vec2(7.);
12019vec2 uvw2=1.+3.*st;
12020vec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;
12021vec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;
12022float shadow=0.;
12023shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));
12024shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));
12025shadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[0]),layer,uvDepth.z));
12026shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));
12027shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));
12028shadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[1]),layer,uvDepth.z));
12029shadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[2]),layer,uvDepth.z));
12030shadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[2]),layer,uvDepth.z));
12031shadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[2]),layer,uvDepth.z));
12032shadow=shadow/144.;
12033shadow=mix(darkness,1.,shadow);
12034return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);
12035}
12036
12037#define inline
12038float computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff)
12039{
12040if (depthMetric>1.0 || depthMetric<0.0) {
12041return 1.0;
12042}
12043else
12044{
12045vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
12046vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
12047float shadow=texture2D(shadowSampler,uvDepth);
12048shadow=mix(darkness,1.,shadow);
12049return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);
12050}
12051}
12052
12053
12054
12055#define inline
12056float computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
12057{
12058if (depthMetric>1.0 || depthMetric<0.0) {
12059return 1.0;
12060}
12061else
12062{
12063vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
12064vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
12065vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;
12066uv+=0.5;
12067vec2 st=fract(uv);
12068vec2 base_uv=floor(uv)-0.5;
12069base_uv*=shadowMapSizeAndInverse.y;
12070
12071
12072
12073
12074vec2 uvw0=3.-2.*st;
12075vec2 uvw1=1.+2.*st;
12076vec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;
12077vec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;
12078float shadow=0.;
12079shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));
12080shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));
12081shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));
12082shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));
12083shadow=shadow/16.;
12084shadow=mix(darkness,1.,shadow);
12085return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);
12086}
12087}
12088
12089
12090
12091#define inline
12092float computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
12093{
12094if (depthMetric>1.0 || depthMetric<0.0) {
12095return 1.0;
12096}
12097else
12098{
12099vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
12100vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
12101vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;
12102uv+=0.5;
12103vec2 st=fract(uv);
12104vec2 base_uv=floor(uv)-0.5;
12105base_uv*=shadowMapSizeAndInverse.y;
12106
12107
12108vec2 uvw0=4.-3.*st;
12109vec2 uvw1=vec2(7.);
12110vec2 uvw2=1.+3.*st;
12111vec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;
12112vec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;
12113float shadow=0.;
12114shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));
12115shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));
12116shadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[0]),uvDepth.z));
12117shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));
12118shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));
12119shadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[1]),uvDepth.z));
12120shadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[2]),uvDepth.z));
12121shadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[2]),uvDepth.z));
12122shadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[2]),uvDepth.z));
12123shadow=shadow/144.;
12124shadow=mix(darkness,1.,shadow);
12125return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);
12126}
12127}
12128const vec3 PoissonSamplers32[64]=vec3[64](
12129vec3(0.06407013,0.05409927,0.),
12130vec3(0.7366577,0.5789394,0.),
12131vec3(-0.6270542,-0.5320278,0.),
12132vec3(-0.4096107,0.8411095,0.),
12133vec3(0.6849564,-0.4990818,0.),
12134vec3(-0.874181,-0.04579735,0.),
12135vec3(0.9989998,0.0009880066,0.),
12136vec3(-0.004920578,-0.9151649,0.),
12137vec3(0.1805763,0.9747483,0.),
12138vec3(-0.2138451,0.2635818,0.),
12139vec3(0.109845,0.3884785,0.),
12140vec3(0.06876755,-0.3581074,0.),
12141vec3(0.374073,-0.7661266,0.),
12142vec3(0.3079132,-0.1216763,0.),
12143vec3(-0.3794335,-0.8271583,0.),
12144vec3(-0.203878,-0.07715034,0.),
12145vec3(0.5912697,0.1469799,0.),
12146vec3(-0.88069,0.3031784,0.),
12147vec3(0.5040108,0.8283722,0.),
12148vec3(-0.5844124,0.5494877,0.),
12149vec3(0.6017799,-0.1726654,0.),
12150vec3(-0.5554981,0.1559997,0.),
12151vec3(-0.3016369,-0.3900928,0.),
12152vec3(-0.5550632,-0.1723762,0.),
12153vec3(0.925029,0.2995041,0.),
12154vec3(-0.2473137,0.5538505,0.),
12155vec3(0.9183037,-0.2862392,0.),
12156vec3(0.2469421,0.6718712,0.),
12157vec3(0.3916397,-0.4328209,0.),
12158vec3(-0.03576927,-0.6220032,0.),
12159vec3(-0.04661255,0.7995201,0.),
12160vec3(0.4402924,0.3640312,0.),
12161vec3(0.,0.,0.),
12162vec3(0.,0.,0.),
12163vec3(0.,0.,0.),
12164vec3(0.,0.,0.),
12165vec3(0.,0.,0.),
12166vec3(0.,0.,0.),
12167vec3(0.,0.,0.),
12168vec3(0.,0.,0.),
12169vec3(0.,0.,0.),
12170vec3(0.,0.,0.),
12171vec3(0.,0.,0.),
12172vec3(0.,0.,0.),
12173vec3(0.,0.,0.),
12174vec3(0.,0.,0.),
12175vec3(0.,0.,0.),
12176vec3(0.,0.,0.),
12177vec3(0.,0.,0.),
12178vec3(0.,0.,0.),
12179vec3(0.,0.,0.),
12180vec3(0.,0.,0.),
12181vec3(0.,0.,0.),
12182vec3(0.,0.,0.),
12183vec3(0.,0.,0.),
12184vec3(0.,0.,0.),
12185vec3(0.,0.,0.),
12186vec3(0.,0.,0.),
12187vec3(0.,0.,0.),
12188vec3(0.,0.,0.),
12189vec3(0.,0.,0.),
12190vec3(0.,0.,0.),
12191vec3(0.,0.,0.),
12192vec3(0.,0.,0.)
12193);
12194const vec3 PoissonSamplers64[64]=vec3[64](
12195vec3(-0.613392,0.617481,0.),
12196vec3(0.170019,-0.040254,0.),
12197vec3(-0.299417,0.791925,0.),
12198vec3(0.645680,0.493210,0.),
12199vec3(-0.651784,0.717887,0.),
12200vec3(0.421003,0.027070,0.),
12201vec3(-0.817194,-0.271096,0.),
12202vec3(-0.705374,-0.668203,0.),
12203vec3(0.977050,-0.108615,0.),
12204vec3(0.063326,0.142369,0.),
12205vec3(0.203528,0.214331,0.),
12206vec3(-0.667531,0.326090,0.),
12207vec3(-0.098422,-0.295755,0.),
12208vec3(-0.885922,0.215369,0.),
12209vec3(0.566637,0.605213,0.),
12210vec3(0.039766,-0.396100,0.),
12211vec3(0.751946,0.453352,0.),
12212vec3(0.078707,-0.715323,0.),
12213vec3(-0.075838,-0.529344,0.),
12214vec3(0.724479,-0.580798,0.),
12215vec3(0.222999,-0.215125,0.),
12216vec3(-0.467574,-0.405438,0.),
12217vec3(-0.248268,-0.814753,0.),
12218vec3(0.354411,-0.887570,0.),
12219vec3(0.175817,0.382366,0.),
12220vec3(0.487472,-0.063082,0.),
12221vec3(-0.084078,0.898312,0.),
12222vec3(0.488876,-0.783441,0.),
12223vec3(0.470016,0.217933,0.),
12224vec3(-0.696890,-0.549791,0.),
12225vec3(-0.149693,0.605762,0.),
12226vec3(0.034211,0.979980,0.),
12227vec3(0.503098,-0.308878,0.),
12228vec3(-0.016205,-0.872921,0.),
12229vec3(0.385784,-0.393902,0.),
12230vec3(-0.146886,-0.859249,0.),
12231vec3(0.643361,0.164098,0.),
12232vec3(0.634388,-0.049471,0.),
12233vec3(-0.688894,0.007843,0.),
12234vec3(0.464034,-0.188818,0.),
12235vec3(-0.440840,0.137486,0.),
12236vec3(0.364483,0.511704,0.),
12237vec3(0.034028,0.325968,0.),
12238vec3(0.099094,-0.308023,0.),
12239vec3(0.693960,-0.366253,0.),
12240vec3(0.678884,-0.204688,0.),
12241vec3(0.001801,0.780328,0.),
12242vec3(0.145177,-0.898984,0.),
12243vec3(0.062655,-0.611866,0.),
12244vec3(0.315226,-0.604297,0.),
12245vec3(-0.780145,0.486251,0.),
12246vec3(-0.371868,0.882138,0.),
12247vec3(0.200476,0.494430,0.),
12248vec3(-0.494552,-0.711051,0.),
12249vec3(0.612476,0.705252,0.),
12250vec3(-0.578845,-0.768792,0.),
12251vec3(-0.772454,-0.090976,0.),
12252vec3(0.504440,0.372295,0.),
12253vec3(0.155736,0.065157,0.),
12254vec3(0.391522,0.849605,0.),
12255vec3(-0.620106,-0.328104,0.),
12256vec3(0.789239,-0.419965,0.),
12257vec3(-0.545396,0.538133,0.),
12258vec3(-0.178564,-0.596057,0.)
12259);
12260
12261
12262
12263
12264
12265#define inline
12266float 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)
12267{
12268vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
12269vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
12270uvDepth.z=clamp(uvDepth.z,0.,GREATEST_LESS_THAN_ONE);
12271vec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);
12272float blockerDepth=0.0;
12273float sumBlockerDepth=0.0;
12274float numBlocker=0.0;
12275for (int i=0; i<searchTapCount; i ++) {
12276blockerDepth=texture(depthSampler,vec3(uvDepth.xy+(lightSizeUV*lightSizeUVCorrection*shadowMapSizeInverse*PoissonSamplers32[i].xy),layer)).r;
12277if (blockerDepth<depthMetric) {
12278sumBlockerDepth+=blockerDepth;
12279numBlocker++;
12280}
12281}
12282if (numBlocker<1.0) {
12283return 1.0;
12284}
12285else
12286{
12287float avgBlockerDepth=sumBlockerDepth/numBlocker;
12288
12289float AAOffset=shadowMapSizeInverse*10.;
12290
12291
12292float penumbraRatio=((depthMetric-avgBlockerDepth)*depthCorrection+AAOffset);
12293vec4 filterRadius=vec4(penumbraRatio*lightSizeUV*lightSizeUVCorrection*shadowMapSizeInverse,0.,0.);
12294float random=getRand(vPositionFromLight.xy);
12295float rotationAngle=random*3.1415926;
12296vec2 rotationVector=vec2(cos(rotationAngle),sin(rotationAngle));
12297float shadow=0.;
12298for (int i=0; i<pcfTapCount; i++) {
12299vec4 offset=vec4(poissonSamplers[i],0.);
12300
12301offset=vec4(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.,0.);
12302shadow+=texture2D(shadowSampler,uvDepthLayer+offset*filterRadius);
12303}
12304shadow/=float(pcfTapCount);
12305
12306shadow=mix(shadow,1.,min((depthMetric-avgBlockerDepth)*depthCorrection*penumbraDarkness,1.));
12307
12308shadow=mix(darkness,1.,shadow);
12309
12310return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);
12311}
12312}
12313
12314
12315
12316
12317
12318#define inline
12319float computeShadowWithPCSS(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers)
12320{
12321if (depthMetric>1.0 || depthMetric<0.0) {
12322return 1.0;
12323}
12324else
12325{
12326vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
12327vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
12328float blockerDepth=0.0;
12329float sumBlockerDepth=0.0;
12330float numBlocker=0.0;
12331for (int i=0; i<searchTapCount; i ++) {
12332blockerDepth=texture(depthSampler,uvDepth.xy+(lightSizeUV*shadowMapSizeInverse*PoissonSamplers32[i].xy)).r;
12333if (blockerDepth<depthMetric) {
12334sumBlockerDepth+=blockerDepth;
12335numBlocker++;
12336}
12337}
12338if (numBlocker<1.0) {
12339return 1.0;
12340}
12341else
12342{
12343float avgBlockerDepth=sumBlockerDepth/numBlocker;
12344
12345float AAOffset=shadowMapSizeInverse*10.;
12346
12347
12348float penumbraRatio=((depthMetric-avgBlockerDepth)+AAOffset);
12349float filterRadius=penumbraRatio*lightSizeUV*shadowMapSizeInverse;
12350float random=getRand(vPositionFromLight.xy);
12351float rotationAngle=random*3.1415926;
12352vec2 rotationVector=vec2(cos(rotationAngle),sin(rotationAngle));
12353float shadow=0.;
12354for (int i=0; i<pcfTapCount; i++) {
12355vec3 offset=poissonSamplers[i];
12356
12357offset=vec3(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.);
12358shadow+=texture2D(shadowSampler,uvDepth+offset*filterRadius);
12359}
12360shadow/=float(pcfTapCount);
12361
12362shadow=mix(shadow,1.,depthMetric-avgBlockerDepth);
12363
12364shadow=mix(darkness,1.,shadow);
12365
12366return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);
12367}
12368}
12369}
12370#define inline
12371float computeShadowWithPCSS16(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)
12372{
12373return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32);
12374}
12375#define inline
12376float computeShadowWithPCSS32(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)
12377{
12378return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32);
12379}
12380#define inline
12381float computeShadowWithPCSS64(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)
12382{
12383return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64);
12384}
12385#define inline
12386float computeShadowWithCSMPCSS16(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)
12387{
12388return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);
12389}
12390#define inline
12391float computeShadowWithCSMPCSS32(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)
12392{
12393return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);
12394}
12395#define inline
12396float computeShadowWithCSMPCSS64(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)
12397{
12398return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64,lightSizeUVCorrection,depthCorrection,penumbraDarkness);
12399}
12400#endif
12401#endif
12402`;f(5).a.IncludesShadersStore[B]=_},function(Ae,v,f){var B="reflectionFunction",_=`vec3 parallaxCorrectNormal( vec3 vertexPos,vec3 origVec,vec3 cubeSize,vec3 cubePos ) {
12403
12404vec3 invOrigVec=vec3(1.0,1.0,1.0)/origVec;
12405vec3 halfSize=cubeSize*0.5;
12406vec3 intersecAtMaxPlane=(cubePos+halfSize-vertexPos)*invOrigVec;
12407vec3 intersecAtMinPlane=(cubePos-halfSize-vertexPos)*invOrigVec;
12408
12409vec3 largestIntersec=max(intersecAtMaxPlane,intersecAtMinPlane);
12410
12411float distance=min(min(largestIntersec.x,largestIntersec.y),largestIntersec.z);
12412
12413vec3 intersectPositionWS=vertexPos+origVec*distance;
12414
12415return intersectPositionWS-cubePos;
12416}
12417vec3 computeFixedEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 direction)
12418{
12419float lon=atan(direction.z,direction.x);
12420float lat=acos(direction.y);
12421vec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;
12422float s=sphereCoords.x*0.5+0.5;
12423float t=sphereCoords.y;
12424return vec3(s,t,0);
12425}
12426vec3 computeMirroredFixedEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 direction)
12427{
12428float lon=atan(direction.z,direction.x);
12429float lat=acos(direction.y);
12430vec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;
12431float s=sphereCoords.x*0.5+0.5;
12432float t=sphereCoords.y;
12433return vec3(1.0-s,t,0);
12434}
12435vec3 computeEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix)
12436{
12437vec3 cameraToVertex=normalize(worldPos.xyz-eyePosition);
12438vec3 r=normalize(reflect(cameraToVertex,worldNormal));
12439r=vec3(reflectionMatrix*vec4(r,0));
12440float lon=atan(r.z,r.x);
12441float lat=acos(r.y);
12442vec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;
12443float s=sphereCoords.x*0.5+0.5;
12444float t=sphereCoords.y;
12445return vec3(s,t,0);
12446}
12447vec3 computeSphericalCoords(vec4 worldPos,vec3 worldNormal,mat4 view,mat4 reflectionMatrix)
12448{
12449vec3 viewDir=normalize(vec3(view*worldPos));
12450vec3 viewNormal=normalize(vec3(view*vec4(worldNormal,0.0)));
12451vec3 r=reflect(viewDir,viewNormal);
12452r=vec3(reflectionMatrix*vec4(r,0));
12453r.z=r.z-1.0;
12454float m=2.0*length(r);
12455return vec3(r.x/m+0.5,1.0-r.y/m-0.5,0);
12456}
12457vec3 computePlanarCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix)
12458{
12459vec3 viewDir=worldPos.xyz-eyePosition;
12460vec3 coords=normalize(reflect(viewDir,worldNormal));
12461return vec3(reflectionMatrix*vec4(coords,1));
12462}
12463vec3 computeCubicCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix)
12464{
12465vec3 viewDir=normalize(worldPos.xyz-eyePosition);
12466
12467vec3 coords=reflect(viewDir,worldNormal);
12468coords=vec3(reflectionMatrix*vec4(coords,0));
12469#ifdef INVERTCUBICMAP
12470coords.y*=-1.0;
12471#endif
12472return coords;
12473}
12474vec3 computeCubicLocalCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix,vec3 reflectionSize,vec3 reflectionPosition)
12475{
12476vec3 viewDir=normalize(worldPos.xyz-eyePosition);
12477
12478vec3 coords=reflect(viewDir,worldNormal);
12479coords=parallaxCorrectNormal(worldPos.xyz,coords,reflectionSize,reflectionPosition);
12480coords=vec3(reflectionMatrix*vec4(coords,0));
12481#ifdef INVERTCUBICMAP
12482coords.y*=-1.0;
12483#endif
12484return coords;
12485}
12486vec3 computeProjectionCoords(vec4 worldPos,mat4 view,mat4 reflectionMatrix)
12487{
12488return vec3(reflectionMatrix*(view*worldPos));
12489}
12490vec3 computeSkyBoxCoords(vec3 positionW,mat4 reflectionMatrix)
12491{
12492return vec3(reflectionMatrix*vec4(positionW,1.));
12493}
12494#ifdef REFLECTION
12495vec3 computeReflectionCoords(vec4 worldPos,vec3 worldNormal)
12496{
12497#ifdef REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED
12498vec3 direction=normalize(vDirectionW);
12499return computeMirroredFixedEquirectangularCoords(worldPos,worldNormal,direction);
12500#endif
12501#ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED
12502vec3 direction=normalize(vDirectionW);
12503return computeFixedEquirectangularCoords(worldPos,worldNormal,direction);
12504#endif
12505#ifdef REFLECTIONMAP_EQUIRECTANGULAR
12506return computeEquirectangularCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix);
12507#endif
12508#ifdef REFLECTIONMAP_SPHERICAL
12509return computeSphericalCoords(worldPos,worldNormal,view,reflectionMatrix);
12510#endif
12511#ifdef REFLECTIONMAP_PLANAR
12512return computePlanarCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix);
12513#endif
12514#ifdef REFLECTIONMAP_CUBIC
12515#ifdef USE_LOCAL_REFLECTIONMAP_CUBIC
12516return computeCubicLocalCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix,vReflectionSize,vReflectionPosition);
12517#else
12518return computeCubicCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix);
12519#endif
12520#endif
12521#ifdef REFLECTIONMAP_PROJECTION
12522return computeProjectionCoords(worldPos,view,reflectionMatrix);
12523#endif
12524#ifdef REFLECTIONMAP_SKYBOX
12525return computeSkyBoxCoords(vPositionUVW,reflectionMatrix);
12526#endif
12527#ifdef REFLECTIONMAP_EXPLICIT
12528return vec3(0,0,0);
12529#endif
12530}
12531#endif`;f(5).a.IncludesShadersStore[B]=_},function(Ae,v,f){var B="bumpFragmentMainFunctions",_=`#if defined(BUMP) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) || defined(DETAIL)
12532#if defined(TANGENT) && defined(NORMAL)
12533varying mat3 vTBN;
12534#endif
12535#ifdef OBJECTSPACE_NORMALMAP
12536uniform mat4 normalMatrix;
12537#endif
12538vec3 perturbNormalBase(mat3 cotangentFrame,vec3 normal,float scale)
12539{
12540#ifdef NORMALXYSCALE
12541normal=normalize(normal*vec3(scale,scale,1.0));
12542#endif
12543return normalize(cotangentFrame*normal);
12544}
12545vec3 perturbNormal(mat3 cotangentFrame,vec3 textureSample,float scale)
12546{
12547return perturbNormalBase(cotangentFrame,textureSample*2.0-1.0,scale);
12548}
12549
12550mat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv,vec2 tangentSpaceParams)
12551{
12552
12553uv=gl_FrontFacing ? uv : -uv;
12554
12555vec3 dp1=dFdx(p);
12556vec3 dp2=dFdy(p);
12557vec2 duv1=dFdx(uv);
12558vec2 duv2=dFdy(uv);
12559
12560vec3 dp2perp=cross(dp2,normal);
12561vec3 dp1perp=cross(normal,dp1);
12562vec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;
12563vec3 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;
12564
12565tangent*=tangentSpaceParams.x;
12566bitangent*=tangentSpaceParams.y;
12567
12568float invmax=inversesqrt(max(dot(tangent,tangent),dot(bitangent,bitangent)));
12569return mat3(tangent*invmax,bitangent*invmax,normal);
12570}
12571#endif
12572`;f(5).a.IncludesShadersStore[B]=_},function(Ae,v,f){var B="bumpFragmentFunctions",_=`#if defined(BUMP)
12573#if BUMPDIRECTUV == 1
12574#define vBumpUV vMainUV1
12575#elif BUMPDIRECTUV == 2
12576#define vBumpUV vMainUV2
12577#else
12578varying vec2 vBumpUV;
12579#endif
12580uniform sampler2D bumpSampler;
12581vec3 perturbNormal(mat3 cotangentFrame,vec2 uv)
12582{
12583return perturbNormal(cotangentFrame,texture2D(bumpSampler,uv).xyz,vBumpInfos.y);
12584}
12585#endif
12586#if defined(DETAIL)
12587#if DETAILDIRECTUV == 1
12588#define vDetailUV vMainUV1
12589#elif DETAILDIRECTUV == 2
12590#define vDetailUV vMainUV2
12591#else
12592varying vec2 vDetailUV;
12593#endif
12594uniform sampler2D detailSampler;
12595#endif
12596#if defined(BUMP)
12597vec3 perturbNormal(mat3 cotangentFrame,vec3 color)
12598{
12599return perturbNormal(cotangentFrame,color,vBumpInfos.y);
12600}
12601
12602mat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv)
12603{
12604return cotangent_frame(normal,p,uv,vTangentSpaceParams);
12605}
12606#endif
12607#if defined(BUMP) && defined(PARALLAX)
12608const float minSamples=4.;
12609const float maxSamples=15.;
12610const int iMaxSamples=15;
12611
12612vec2 parallaxOcclusion(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale) {
12613float parallaxLimit=length(vViewDirCoT.xy)/vViewDirCoT.z;
12614parallaxLimit*=parallaxScale;
12615vec2 vOffsetDir=normalize(vViewDirCoT.xy);
12616vec2 vMaxOffset=vOffsetDir*parallaxLimit;
12617float numSamples=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));
12618float stepSize=1.0/numSamples;
12619
12620float currRayHeight=1.0;
12621vec2 vCurrOffset=vec2(0,0);
12622vec2 vLastOffset=vec2(0,0);
12623float lastSampledHeight=1.0;
12624float currSampledHeight=1.0;
12625for (int i=0; i<iMaxSamples; i++)
12626{
12627currSampledHeight=texture2D(bumpSampler,vBumpUV+vCurrOffset).w;
12628
12629if (currSampledHeight>currRayHeight)
12630{
12631float delta1=currSampledHeight-currRayHeight;
12632float delta2=(currRayHeight+stepSize)-lastSampledHeight;
12633float ratio=delta1/(delta1+delta2);
12634vCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;
12635
12636break;
12637}
12638else
12639{
12640currRayHeight-=stepSize;
12641vLastOffset=vCurrOffset;
12642vCurrOffset+=stepSize*vMaxOffset;
12643lastSampledHeight=currSampledHeight;
12644}
12645}
12646return vCurrOffset;
12647}
12648vec2 parallaxOffset(vec3 viewDir,float heightScale)
12649{
12650
12651float height=texture2D(bumpSampler,vBumpUV).w;
12652vec2 texCoordOffset=heightScale*viewDir.xy*height;
12653return -texCoordOffset;
12654}
12655#endif`;f(5).a.IncludesShadersStore[B]=_},function(Ae,v,f){var B=`vec2 uvOffset=vec2(0.0,0.0);
12656#if defined(BUMP) || defined(PARALLAX) || defined(DETAIL)
12657#ifdef NORMALXYSCALE
12658float normalScale=1.0;
12659#elif defined(BUMP)
12660float normalScale=vBumpInfos.y;
12661#else
12662float normalScale=1.0;
12663#endif
12664#if defined(TANGENT) && defined(NORMAL)
12665mat3 TBN=vTBN;
12666#elif defined(BUMP)
12667mat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,vBumpUV);
12668#else
12669mat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,vDetailUV,vec2(1.,1.));
12670#endif
12671#elif defined(ANISOTROPIC)
12672#if defined(TANGENT) && defined(NORMAL)
12673mat3 TBN=vTBN;
12674#else
12675mat3 TBN=cotangent_frame(normalW,vPositionW,vMainUV1,vec2(1.,1.));
12676#endif
12677#endif
12678#ifdef PARALLAX
12679mat3 invTBN=transposeMat3(TBN);
12680#ifdef PARALLAXOCCLUSION
12681uvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,vBumpUV,vBumpInfos.z);
12682#else
12683uvOffset=parallaxOffset(invTBN*viewDirectionW,vBumpInfos.z);
12684#endif
12685#endif
12686#ifdef DETAIL
12687vec4 detailColor=texture2D(detailSampler,vDetailUV+uvOffset);
12688vec2 detailNormalRG=detailColor.wy*2.0-1.0;
12689float detailNormalB=sqrt(1.-saturate(dot(detailNormalRG,detailNormalRG)));
12690vec3 detailNormal=vec3(detailNormalRG,detailNormalB);
12691#endif
12692#ifdef BUMP
12693#ifdef OBJECTSPACE_NORMALMAP
12694normalW=normalize(texture2D(bumpSampler,vBumpUV).xyz*2.0-1.0);
12695normalW=normalize(mat3(normalMatrix)*normalW);
12696#elif !defined(DETAIL)
12697normalW=perturbNormal(TBN,vBumpUV+uvOffset);
12698#else
12699vec3 bumpNormal=texture2D(bumpSampler,vBumpUV+uvOffset).xyz*2.0-1.0;
12700
12701#if DETAIL_NORMALBLENDMETHOD == 0
12702detailNormal.xy*=vDetailInfos.z;
12703vec3 blendedNormal=normalize(vec3(bumpNormal.xy+detailNormal.xy,bumpNormal.z*detailNormal.z));
12704#elif DETAIL_NORMALBLENDMETHOD == 1
12705detailNormal.xy*=vDetailInfos.z;
12706bumpNormal+=vec3(0.0,0.0,1.0);
12707detailNormal*=vec3(-1.0,-1.0,1.0);
12708vec3 blendedNormal=bumpNormal*dot(bumpNormal,detailNormal)/bumpNormal.z-detailNormal;
12709#endif
12710normalW=perturbNormalBase(TBN,blendedNormal,vBumpInfos.y);
12711#endif
12712#elif defined(DETAIL)
12713detailNormal.xy*=vDetailInfos.z;
12714normalW=perturbNormalBase(TBN,detailNormal,vDetailInfos.z);
12715#endif`;f(5).a.IncludesShadersStore.bumpFragment=B},function(Ae,v,f){var B="lightFragment",_=`#ifdef LIGHT{X}
12716#if defined(SHADOWONLY) || defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})
12717
12718#else
12719#ifdef PBR
12720
12721#ifdef SPOTLIGHT{X}
12722preInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);
12723#elif defined(POINTLIGHT{X})
12724preInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);
12725#elif defined(HEMILIGHT{X})
12726preInfo=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);
12727#elif defined(DIRLIGHT{X})
12728preInfo=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);
12729#endif
12730preInfo.NdotV=NdotV;
12731
12732#ifdef SPOTLIGHT{X}
12733#ifdef LIGHT_FALLOFF_GLTF{X}
12734preInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);
12735preInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);
12736#elif defined(LIGHT_FALLOFF_PHYSICAL{X})
12737preInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);
12738preInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w);
12739#elif defined(LIGHT_FALLOFF_STANDARD{X})
12740preInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);
12741preInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w);
12742#else
12743preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);
12744preInfo.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);
12745#endif
12746#elif defined(POINTLIGHT{X})
12747#ifdef LIGHT_FALLOFF_GLTF{X}
12748preInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);
12749#elif defined(LIGHT_FALLOFF_PHYSICAL{X})
12750preInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);
12751#elif defined(LIGHT_FALLOFF_STANDARD{X})
12752preInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);
12753#else
12754preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);
12755#endif
12756#else
12757preInfo.attenuation=1.0;
12758#endif
12759
12760
12761#ifdef HEMILIGHT{X}
12762preInfo.roughness=roughness;
12763#else
12764preInfo.roughness=adjustRoughnessFromLightProperties(roughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
12765#endif
12766
12767#ifdef HEMILIGHT{X}
12768info.diffuse=computeHemisphericDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb,light{X}.vLightGround);
12769#elif defined(SS_TRANSLUCENCY)
12770info.diffuse=computeDiffuseAndTransmittedLighting(preInfo,light{X}.vLightDiffuse.rgb,subSurfaceOut.transmittance);
12771#else
12772info.diffuse=computeDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb);
12773#endif
12774
12775#ifdef SPECULARTERM
12776#ifdef ANISOTROPIC
12777info.specular=computeAnisotropicSpecularLighting(preInfo,viewDirectionW,normalW,anisotropicOut.anisotropicTangent,anisotropicOut.anisotropicBitangent,anisotropicOut.anisotropy,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);
12778#else
12779info.specular=computeSpecularLighting(preInfo,normalW,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);
12780#endif
12781#endif
12782
12783#ifdef SHEEN
12784#ifdef SHEEN_LINKWITHALBEDO
12785
12786preInfo.roughness=sheenOut.sheenIntensity;
12787#else
12788#ifdef HEMILIGHT{X}
12789preInfo.roughness=sheenOut.sheenRoughness;
12790#else
12791preInfo.roughness=adjustRoughnessFromLightProperties(sheenOut.sheenRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
12792#endif
12793#endif
12794info.sheen=computeSheenLighting(preInfo,normalW,sheenOut.sheenColor,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);
12795#endif
12796
12797#ifdef CLEARCOAT
12798
12799#ifdef HEMILIGHT{X}
12800preInfo.roughness=clearcoatOut.clearCoatRoughness;
12801#else
12802preInfo.roughness=adjustRoughnessFromLightProperties(clearcoatOut.clearCoatRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
12803#endif
12804info.clearCoat=computeClearCoatLighting(preInfo,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatAARoughnessFactors.x,clearcoatOut.clearCoatIntensity,light{X}.vLightDiffuse.rgb);
12805#ifdef CLEARCOAT_TINT
12806
12807absorption=computeClearCoatLightingAbsorption(clearcoatOut.clearCoatNdotVRefract,preInfo.L,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatColor,clearcoatOut.clearCoatThickness,clearcoatOut.clearCoatIntensity);
12808info.diffuse*=absorption;
12809#ifdef SPECULARTERM
12810info.specular*=absorption;
12811#endif
12812#endif
12813
12814info.diffuse*=info.clearCoat.w;
12815#ifdef SPECULARTERM
12816info.specular*=info.clearCoat.w;
12817#endif
12818#ifdef SHEEN
12819info.sheen*=info.clearCoat.w;
12820#endif
12821#endif
12822#else
12823#ifdef SPOTLIGHT{X}
12824info=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightDiffuse.a,glossiness);
12825#elif defined(HEMILIGHT{X})
12826info=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightGround,glossiness);
12827#elif defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})
12828info=computeLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightDiffuse.a,glossiness);
12829#endif
12830#endif
12831#ifdef PROJECTEDLIGHTTEXTURE{X}
12832info.diffuse*=computeProjectionTextureDiffuseLighting(projectionLightSampler{X},textureProjectionMatrix{X});
12833#endif
12834#endif
12835#ifdef SHADOW{X}
12836#ifdef SHADOWCSM{X}
12837for (int i=0; i<SHADOWCSMNUM_CASCADES{X}; i++)
12838{
12839#ifdef SHADOWCSM_RIGHTHANDED{X}
12840diff{X}=viewFrustumZ{X}[i]+vPositionFromCamera{X}.z;
12841#else
12842diff{X}=viewFrustumZ{X}[i]-vPositionFromCamera{X}.z;
12843#endif
12844if (diff{X}>=0.) {
12845index{X}=i;
12846break;
12847}
12848}
12849#ifdef SHADOWCSMUSESHADOWMAXZ{X}
12850if (index{X}>=0)
12851#endif
12852{
12853#if defined(SHADOWPCF{X})
12854#if defined(SHADOWLOWQUALITY{X})
12855shadow=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
12856#elif defined(SHADOWMEDIUMQUALITY{X})
12857shadow=computeShadowWithCSMPCF3(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
12858#else
12859shadow=computeShadowWithCSMPCF5(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
12860#endif
12861#elif defined(SHADOWPCSS{X})
12862#if defined(SHADOWLOWQUALITY{X})
12863shadow=computeShadowWithCSMPCSS16(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{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});
12864#elif defined(SHADOWMEDIUMQUALITY{X})
12865shadow=computeShadowWithCSMPCSS32(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{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});
12866#else
12867shadow=computeShadowWithCSMPCSS64(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{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});
12868#endif
12869#else
12870shadow=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
12871#endif
12872#ifdef SHADOWCSMDEBUG{X}
12873shadowDebug{X}=vec3(shadow)*vCascadeColorsMultiplier{X}[index{X}];
12874#endif
12875#ifndef SHADOWCSMNOBLEND{X}
12876float frustumLength=frustumLengths{X}[index{X}];
12877float diffRatio=clamp(diff{X}/frustumLength,0.,1.)*cascadeBlendFactor{X};
12878if (index{X}<(SHADOWCSMNUM_CASCADES{X}-1) && diffRatio<1.)
12879{
12880index{X}+=1;
12881float nextShadow=0.;
12882#if defined(SHADOWPCF{X})
12883#if defined(SHADOWLOWQUALITY{X})
12884nextShadow=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
12885#elif defined(SHADOWMEDIUMQUALITY{X})
12886nextShadow=computeShadowWithCSMPCF3(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
12887#else
12888nextShadow=computeShadowWithCSMPCF5(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
12889#endif
12890#elif defined(SHADOWPCSS{X})
12891#if defined(SHADOWLOWQUALITY{X})
12892nextShadow=computeShadowWithCSMPCSS16(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{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});
12893#elif defined(SHADOWMEDIUMQUALITY{X})
12894nextShadow=computeShadowWithCSMPCSS32(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{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});
12895#else
12896nextShadow=computeShadowWithCSMPCSS64(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{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});
12897#endif
12898#else
12899nextShadow=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
12900#endif
12901shadow=mix(nextShadow,shadow,diffRatio);
12902#ifdef SHADOWCSMDEBUG{X}
12903shadowDebug{X}=mix(vec3(nextShadow)*vCascadeColorsMultiplier{X}[index{X}],shadowDebug{X},diffRatio);
12904#endif
12905}
12906#endif
12907}
12908#elif defined(SHADOWCLOSEESM{X})
12909#if defined(SHADOWCUBE{X})
12910shadow=computeShadowWithCloseESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);
12911#else
12912shadow=computeShadowWithCloseESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);
12913#endif
12914#elif defined(SHADOWESM{X})
12915#if defined(SHADOWCUBE{X})
12916shadow=computeShadowWithESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);
12917#else
12918shadow=computeShadowWithESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);
12919#endif
12920#elif defined(SHADOWPOISSON{X})
12921#if defined(SHADOWCUBE{X})
12922shadow=computeShadowWithPoissonSamplingCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);
12923#else
12924shadow=computeShadowWithPoissonSampling(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
12925#endif
12926#elif defined(SHADOWPCF{X})
12927#if defined(SHADOWLOWQUALITY{X})
12928shadow=computeShadowWithPCF1(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
12929#elif defined(SHADOWMEDIUMQUALITY{X})
12930shadow=computeShadowWithPCF3(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
12931#else
12932shadow=computeShadowWithPCF5(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
12933#endif
12934#elif defined(SHADOWPCSS{X})
12935#if defined(SHADOWLOWQUALITY{X})
12936shadow=computeShadowWithPCSS16(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
12937#elif defined(SHADOWMEDIUMQUALITY{X})
12938shadow=computeShadowWithPCSS32(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
12939#else
12940shadow=computeShadowWithPCSS64(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
12941#endif
12942#else
12943#if defined(SHADOWCUBE{X})
12944shadow=computeShadowCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.depthValues);
12945#else
12946shadow=computeShadow(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
12947#endif
12948#endif
12949#ifdef SHADOWONLY
12950#ifndef SHADOWINUSE
12951#define SHADOWINUSE
12952#endif
12953globalShadow+=shadow;
12954shadowLightCount+=1.0;
12955#endif
12956#else
12957shadow=1.;
12958#endif
12959#ifndef SHADOWONLY
12960#ifdef CUSTOMUSERLIGHTING
12961diffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow);
12962#ifdef SPECULARTERM
12963specularBase+=computeCustomSpecularLighting(info,specularBase,shadow);
12964#endif
12965#elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})
12966diffuseBase+=lightmapColor.rgb*shadow;
12967#ifdef SPECULARTERM
12968#ifndef LIGHTMAPNOSPECULAR{X}
12969specularBase+=info.specular*shadow*lightmapColor.rgb;
12970#endif
12971#endif
12972#ifdef CLEARCOAT
12973#ifndef LIGHTMAPNOSPECULAR{X}
12974clearCoatBase+=info.clearCoat.rgb*shadow*lightmapColor.rgb;
12975#endif
12976#endif
12977#ifdef SHEEN
12978#ifndef LIGHTMAPNOSPECULAR{X}
12979sheenBase+=info.sheen.rgb*shadow;
12980#endif
12981#endif
12982#else
12983#ifdef SHADOWCSMDEBUG{X}
12984diffuseBase+=info.diffuse*shadowDebug{X};
12985#else
12986diffuseBase+=info.diffuse*shadow;
12987#endif
12988#ifdef SPECULARTERM
12989specularBase+=info.specular*shadow;
12990#endif
12991#ifdef CLEARCOAT
12992clearCoatBase+=info.clearCoat.rgb*shadow;
12993#endif
12994#ifdef SHEEN
12995sheenBase+=info.sheen.rgb*shadow;
12996#endif
12997#endif
12998#endif
12999#endif`;f(5).a.IncludesShadersStore[B]=_},function(Ae,v,f){var B=`#ifdef FOG
13000float fog=CalcFogFactor();
13001color.rgb=fog*color.rgb+(1.0-fog)*vFogColor;
13002#endif`;f(5).a.IncludesShadersStore.fogFragment=B},function(Ae,v,f){var B="fogVertexDeclaration",_=`#ifdef FOG
13003varying vec3 vFogDistance;
13004#endif`;f(5).a.IncludesShadersStore[B]=_},function(Ae,v,f){var B="shadowsVertex",_=`#ifdef SHADOWS
13005#if defined(SHADOWCSM{X})
13006vPositionFromCamera{X}
13006=view*worldPos;
13007for (int i=0; i<SHADOWCSMNUM_CASCADES{X}; i++) {
13008vPositionFromLight{X}[i]=lightMatrix{X}[i]*worldPos;
13009vDepthMetric{X}[i]=((vPositionFromLight{X}[i].z+light{X}.depthValues.x)/(light{X}.depthValues.y));
13010}
13011#elif defined(SHADOW{X}) && !defined(SHADOWCUBE{X})
13012vPositionFromLight{X}=lightMatrix{X}*worldPos;
13013vDepthMetric{X}=((vPositionFromLight{X}.z+light{X}.depthValues.x)/(light{X}.depthValues.y));
13014#endif
13015#endif`;f(5).a.IncludesShadersStore[B]=_},function(Ae,v,f){f.d(v,"a",function(){return B});var B=function(){function _(){}return _.Eval=function(x,u){return(x=x.match(/\([^\(\)]*\)/g)?x.replace(/\([^\(\)]*\)/g,function(M){return M=M.slice(1,M.length-1),_._HandleParenthesisContent(M,u)}):_._HandleParenthesisContent(x,u))==="true"||x!=="false"&&_.Eval(x,u)},_._HandleParenthesisContent=function(x,u){var M;u=u||function(S){return S==="true"};var R=x.split("||");for(var C in R)if(R.hasOwnProperty(C)){var m=_._SimplifyNegation(R[C].trim()),c=m.split("&&");if(c.length>1)for(var E=0;E<c.length;++E){var A=_._SimplifyNegation(c[E].trim());if(!(M=A!=="true"&&A!=="false"?A[0]==="!"?!u(A.substring(1)):u(A):A==="true")){m="false";break}}if(M||m==="true"){M=!0;break}M=m!=="true"&&m!=="false"?m[0]==="!"?!u(m.substring(1)):u(m):m==="true"}return M?"true":"false"},_._SimplifyNegation=function(x){return(x=(x=x.replace(/^[\s!]+/,function(u){return(u=u.replace(/[\s]/g,function(){return""})).length%2?"!":""})).trim())==="!true"?x="false":x==="!false"&&(x="true"),x},_}()},function(Ae,v,f){f.d(v,"a",function(){return B});var B=function(){function _(){}return _.ExponentialBackoff=function(x,u){return x===void 0&&(x=3),u===void 0&&(u=500),function(M,R,C){return R.status!==0||C>=x||M.indexOf("file:")!==-1?-1:Math.pow(2,C)*u}},_}()},function(Ae,v,f){f.d(v,"a",function(){return B});var B=function(){function _(){this._isDepthTestDirty=!1,this._isDepthMaskDirty=!1,this._isDepthFuncDirty=!1,this._isCullFaceDirty=!1,this._isCullDirty=!1,this._isZOffsetDirty=!1,this._isFrontFaceDirty=!1,this.reset()}return Object.defineProperty(_.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(_.prototype,"zOffset",{get:function(){return this._zOffset},set:function(x){this._zOffset!==x&&(this._zOffset=x,this._isZOffsetDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"cullFace",{get:function(){return this._cullFace},set:function(x){this._cullFace!==x&&(this._cullFace=x,this._isCullFaceDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"cull",{get:function(){return this._cull},set:function(x){this._cull!==x&&(this._cull=x,this._isCullDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"depthFunc",{get:function(){return this._depthFunc},set:function(x){this._depthFunc!==x&&(this._depthFunc=x,this._isDepthFuncDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"depthMask",{get:function(){return this._depthMask},set:function(x){this._depthMask!==x&&(this._depthMask=x,this._isDepthMaskDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"depthTest",{get:function(){return this._depthTest},set:function(x){this._depthTest!==x&&(this._depthTest=x,this._isDepthTestDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"frontFace",{get:function(){return this._frontFace},set:function(x){this._frontFace!==x&&(this._frontFace=x,this._isFrontFaceDirty=!0)},enumerable:!1,configurable:!0}),_.prototype.reset=function(){this._depthMask=!0,this._depthTest=!0,this._depthFunc=null,this._cullFace=null,this._cull=null,this._zOffset=0,this._frontFace=null,this._isDepthTestDirty=!0,this._isDepthMaskDirty=!0,this._isDepthFuncDirty=!1,this._isCullFaceDirty=!1,this._isCullDirty=!1,this._isZOffsetDirty=!1,this._isFrontFaceDirty=!1},_.prototype.apply=function(x){this.isDirty&&(this._isCullDirty&&(this.cull?x.enable(x.CULL_FACE):x.disable(x.CULL_FACE),this._isCullDirty=!1),this._isCullFaceDirty&&(x.cullFace(this.cullFace),this._isCullFaceDirty=!1),this._isDepthMaskDirty&&(x.depthMask(this.depthMask),this._isDepthMaskDirty=!1),this._isDepthTestDirty&&(this.depthTest?x.enable(x.DEPTH_TEST):x.disable(x.DEPTH_TEST),this._isDepthTestDirty=!1),this._isDepthFuncDirty&&(x.depthFunc(this.depthFunc),this._isDepthFuncDirty=!1),this._isZOffsetDirty&&(this.zOffset?(x.enable(x.POLYGON_OFFSET_FILL),x.polygonOffset(this.zOffset,0)):x.disable(x.POLYGON_OFFSET_FILL),this._isZOffsetDirty=!1),this._isFrontFaceDirty&&(x.frontFace(this.frontFace),this._isFrontFaceDirty=!1))},_}()},function(Ae,v,f){f.d(v,"a",function(){return _});var B=f(2),_=function(){function x(){this._isStencilTestDirty=!1,this._isStencilMaskDirty=!1,this._isStencilFuncDirty=!1,this._isStencilOpDirty=!1,this.reset()}return Object.defineProperty(x.prototype,"isDirty",{get:function(){return this._isStencilTestDirty||this._isStencilMaskDirty||this._isStencilFuncDirty||this._isStencilOpDirty}
13015,enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"stencilFunc",{get:function(){return this._stencilFunc},set:function(u){this._stencilFunc!==u&&(this._stencilFunc=u,this._isStencilFuncDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"stencilFuncRef",{get:function(){return this._stencilFuncRef},set:function(u){this._stencilFuncRef!==u&&(this._stencilFuncRef=u,this._isStencilFuncDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"stencilFuncMask",{get:function(){return this._stencilFuncMask},set:function(u){this._stencilFuncMask!==u&&(this._stencilFuncMask=u,this._isStencilFuncDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"stencilOpStencilFail",{get:function(){return this._stencilOpStencilFail},set:function(u){this._stencilOpStencilFail!==u&&(this._stencilOpStencilFail=u,this._isStencilOpDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"stencilOpDepthFail",{get:function(){return this._stencilOpDepthFail},set:function(u){this._stencilOpDepthFail!==u&&(this._stencilOpDepthFail=u,this._isStencilOpDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"stencilOpStencilDepthPass",{get:function(){return this._stencilOpStencilDepthPass},set:function(u){this._stencilOpStencilDepthPass!==u&&(this._stencilOpStencilDepthPass=u,this._isStencilOpDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"stencilMask",{get:function(){return this._stencilMask},set:function(u){this._stencilMask!==u&&(this._stencilMask=u,this._isStencilMaskDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"stencilTest",{get:function(){return this._stencilTest},set:function(u){this._stencilTest!==u&&(this._stencilTest=u,this._isStencilTestDirty=!0)},enumerable:!1,configurable:!0}),x.prototype.reset=function(){this._stencilTest=!1,this._stencilMask=255,this._stencilFunc=x.ALWAYS,this._stencilFuncRef=1,this._stencilFuncMask=255,this._stencilOpStencilFail=x.KEEP,this._stencilOpDepthFail=x.KEEP,this._stencilOpStencilDepthPass=x.REPLACE,this._isStencilTestDirty=!0,this._isStencilMaskDirty=!0,this._isStencilFuncDirty=!0,this._isStencilOpDirty=!0},x.prototype.apply=function(u){this.isDirty&&(this._isStencilTestDirty&&(this.stencilTest?u.enable(u.STENCIL_TEST):u.disable(u.STENCIL_TEST),this._isStencilTestDirty=!1),this._isStencilMaskDirty&&(u.stencilMask(this.stencilMask),this._isStencilMaskDirty=!1),this._isStencilFuncDirty&&(u.stencilFunc(this.stencilFunc,this.stencilFuncRef,this.stencilFuncMask),this._isStencilFuncDirty=!1),this._isStencilOpDirty&&(u.stencilOp(this.stencilOpStencilFail,this.stencilOpDepthFail,this.stencilOpStencilDepthPass),this._isStencilOpDirty=!1))},x.ALWAYS=B.a.ALWAYS,x.KEEP=B.a.KEEP,x.REPLACE=B.a.REPLACE,x}()},function(Ae,v,f){f.d(v,"a",function(){return B});var B=function(){function _(){this._isAlphaBlendDirty=!1,this._isBlendFunctionParametersDirty=!1,this._isBlendEquationParametersDirty=!1,this._isBlendConstantsDirty=!1,this._alphaBlend=!1,this._blendFunctionParameters=new Array(4),this._blendEquationParameters=new Array(2),this._blendConstants=new Array(4),this.reset()}return Object.defineProperty(_.prototype,"isDirty",{get:function(){return this._isAlphaBlendDirty||this._isBlendFunctionParametersDirty},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"alphaBlend",{get:function(){return this._alphaBlend},set:function(x){this._alphaBlend!==x&&(this._alphaBlend=x,this._isAlphaBlendDirty=!0)},enumerable:!1,configurable:!0}),_.prototype.setAlphaBlendConstants=function(x,u,M,R){this._blendConstants[0]===x&&this._blendConstants[1]===u&&this._blendConstants[2]===M&&this._blendConstants[3]===R||(this._blendConstants[0]=x,this._blendConstants[1]=u,this._blendConstants[2]=M,this._blendConstants[3]=R,this._isBlendConstantsDirty=!0)},_.prototype.setAlphaBlendFunctionParameters=function(x,u,M,R){this._blendFunctionParameters[0]===x&&this._blendFunctionParameters[1]===u&&this._blendFunctionParameters[2]===M&&this._blendFunctionParameters[3]===R||(this._blendFunctionParameters[0]=x,this._blendFunctionParameters[1]=u,this._blendFunctionParameters[2]=M,this._blendFunctionParameters[3]=R,this._isBlendFunctionParametersDirty=!0)},_.prototype.setAlphaEquationParameters=function(x,u){this._blendEquationParameters[0]===x&&this._blendEquationParameters[1]===u||(this._blendEquationParameters[0]=x,this._blendEquationParameters[1]=u,this._isBlendEquationParametersDirty=!0)},_.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._isBlendConstantsDirt
13015y=!1},_.prototype.apply=function(x){this.isDirty&&(this._isAlphaBlendDirty&&(this._alphaBlend?x.enable(x.BLEND):x.disable(x.BLEND),this._isAlphaBlendDirty=!1),this._isBlendFunctionParametersDirty&&(x.blendFuncSeparate(this._blendFunctionParameters[0],this._blendFunctionParameters[1],this._blendFunctionParameters[2],this._blendFunctionParameters[3]),this._isBlendFunctionParametersDirty=!1),this._isBlendEquationParametersDirty&&(x.blendEquationSeparate(this._blendEquationParameters[0],this._blendEquationParameters[1]),this._isBlendEquationParametersDirty=!1),this._isBlendConstantsDirty&&(x.blendColor(this._blendConstants[0],this._blendConstants[1],this._blendConstants[2],this._blendConstants[3]),this._isBlendConstantsDirty=!1))},_}()},function(Ae,v,f){f.d(v,"a",function(){return B});var B=function(){function _(){this.vertexCompilationError=null,this.fragmentCompilationError=null,this.programLinkError=null,this.programValidationError=null}return Object.defineProperty(_.prototype,"isAsync",{get:function(){return this.isParallelCompiled},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"isReady",{get:function(){return!!this.program&&(!this.isParallelCompiled||this.engine._isRenderingStateCompiled(this))},enumerable:!1,configurable:!0}),_.prototype._handlesSpectorRebuildCallback=function(x){x&&this.program&&x(this.program)},_.prototype._getVertexShaderCode=function(){return this.vertexShader?this.engine._getShaderSource(this.vertexShader):null},_.prototype._getFragmentShaderCode=function(){return this.fragmentShader?this.engine._getShaderSource(this.fragmentShader):null},_}()},function(Ae,v,f){var B;f.d(v,"a",function(){return u}),function(M){M[M.Pending=0]="Pending",M[M.Fulfilled=1]="Fulfilled",M[M.Rejected=2]="Rejected"}(B||(B={}));var _=function(){this.count=0,this.target=0,this.results=[]},x=function(){function M(R){var C=this;if(this._state=B.Pending,this._children=new Array,this._rejectWasConsumed=!1,R)try{R(function(m){C._resolve(m)},function(m){C._reject(m)})}catch(m){this._reject(m)}}return Object.defineProperty(M.prototype,"_result",{get:function(){return this._resultValue},set:function(R){this._resultValue=R,this._parent&&this._parent._result===void 0&&(this._parent._result=R)},enumerable:!1,configurable:!0}),M.prototype.catch=function(R){return this.then(void 0,R)},M.prototype.then=function(R,C){var m=this,c=new M;return c._onFulfilled=R,c._onRejected=C,this._children.push(c),c._parent=this,this._state!==B.Pending&&setTimeout(function(){if(m._state===B.Fulfilled||m._rejectWasConsumed){var E=c._resolve(m._result);if(E!=null)if(E._state!==void 0){var A=E;c._children.push(A),A._parent=c,c=A}else c._result=E}else c._reject(m._reason)}),c},M.prototype._moveChildren=function(R){var C,m=this;if((C=this._children).push.apply(C,R.splice(0,R.length)),this._children.forEach(function(g){g._parent=m}),this._state===B.Fulfilled)for(var c=0,E=this._children;c<E.length;c++)E[c]._resolve(this._result);else if(this._state===B.Rejected)for(var A=0,S=this._children;A<S.length;A++)S[A]._reject(this._reason)},M.prototype._resolve=function(R){try{this._state=B.Fulfilled;var C=null;if(this._onFulfilled&&(C=this._onFulfilled(R)),C!=null)if(C._state!==void 0){var m=C;m._parent=this,m._moveChildren(this._children),R=m._result}else R=C;this._result=R;for(var c=0,E=this._children;c<E.length;c++)E[c]._resolve(R);this._children.length=0,delete this._onFulfilled,delete this._onRejected}catch(A){this._reject(A,!0)}},M.prototype._reject=function(R,C){if(C===void 0&&(C=!1),this._state=B.Rejected,this._reason=R,this._onRejected&&!C)try{this._onRejected(R),this._rejectWasConsumed=!0}catch(A){R=A}for(var m=0,c=this._children;m<c.length;m++){var E=c[m];this._rejectWasConsumed?E._resolve(null):E._reject(R)}this._children.length=0,delete this._onFulfilled,delete this._onRejected},M.resolve=function(R){var C=new M;return C._resolve(R),C},M._RegisterForFulfillment=function(R,C,m){R.then(function(c){return C.results[m]=c,C.count++,C.count===C.target&&C.rootPromise._resolve(C.results),null},function(c){C.rootPromise._state!==B.Rejected&&C.rootPromise._reject(c)})},M.all=function(R){var C=new M,m=new _;if(m.target=R.length,m.rootPromise=C,R.length)for(var c=0;c<R.length;c++)M._RegisterForFulfillment(R[c],m,c);else C._resolve([]);return C},M.race=function(R){var C=new M;if(R.length)for(var m=0,c=R;m<c.length;m++)c[m].then(function(E){return C&&(C._resolve(E),C=null),null},function(E){C&&(C._reject(E),C=null)});return C},M}(),u=function(){function M(){}return M.Apply=function(R){R===void 0&&(R=!1),(R||typeof Promise>"u")&&(window.Promise=x)},M}()},function(Ae,v,f){f.d(v,"a",function(){return _}),f.d(v,"b",function(){return x});var B=f(57),_=function(){function u(M){M===void 0&&(M=30),this._enabled=!0,this._rollingFrameTime=new x(M)}return u.prototype.sampleFrame=function(M){if(M===void 0&&(M=B.a.Now),this._enabled){if(this._lastFrameTimeMs!=null){var R=M-this._lastFrameTimeMs;this._rollingFrameTime.add(R)}this._lastFrameTimeMs=M}},Object.defineProperty(u.prototype,"averageFrameTime",{get:function(){return this._rollingFrameTime.average}
13015,enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"averageFrameTimeVariance",{get:function(){return this._rollingFrameTime.variance},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"instantaneousFrameTime",{get:function(){return this._rollingFrameTime.history(0)},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"averageFPS",{get:function(){return 1e3/this._rollingFrameTime.average},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"instantaneousFPS",{get:function(){var M=this._rollingFrameTime.history(0);return M===0?0:1e3/M},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"isSaturated",{get:function(){return this._rollingFrameTime.isSaturated()},enumerable:!1,configurable:!0}),u.prototype.enable=function(){this._enabled=!0},u.prototype.disable=function(){this._enabled=!1,this._lastFrameTimeMs=null},Object.defineProperty(u.prototype,"isEnabled",{get:function(){return this._enabled},enumerable:!1,configurable:!0}),u.prototype.reset=function(){this._lastFrameTimeMs=null,this._rollingFrameTime.reset()},u}(),x=function(){function u(M){this._samples=new Array(M),this.reset()}return u.prototype.add=function(M){var R;if(this.isSaturated()){var C=this._samples[this._pos];R=C-this.average,this.average-=R/(this._sampleCount-1),this._m2-=R*(C-this.average)}else this._sampleCount++;R=M-this.average,this.average+=R/this._sampleCount,this._m2+=R*(M-this.average),this.variance=this._m2/(this._sampleCount-1),this._samples[this._pos]=M,this._pos++,this._pos%=this._samples.length},u.prototype.history=function(M){if(M>=this._sampleCount||M>=this._samples.length)return 0;var R=this._wrapPosition(this._pos-1);return this._samples[this._wrapPosition(R-M)]},u.prototype.isSaturated=function(){return this._sampleCount>=this._samples.length},u.prototype.reset=function(){this.average=0,this.variance=0,this._sampleCount=0,this._pos=0,this._m2=0},u.prototype._wrapPosition=function(M){var R=this._samples.length;return(M%R+R)%R},u}()},function(Ae,v,f){f.d(v,"a",function(){return _});var B=f(0),_=function(){this._checkCollisions=!1,this._collisionMask=-1,this._collisionGroup=-1,this._surroundingMeshes=null,this._collider=null,this._oldPositionForCollisions=new B.e(0,0,0),this._diffPositionForCollisions=new B.e(0,0,0),this._collisionResponse=!0}},function(Ae,v,f){f.d(v,"a",function(){return u});var B=f(33),_=f(0),x=f(2),u=function(){function M(R,C,m,c,E){m===void 0&&(m=null),c===void 0&&(c=null),E===void 0&&(E=null),this.index=R,this._opaqueSubMeshes=new B.a(256),this._transparentSubMeshes=new B.a(256),this._alphaTestSubMeshes=new B.a(256),this._depthOnlySubMeshes=new B.a(256),this._particleSystems=new B.a(256),this._spriteManagers=new B.a(256),this._edgesRenderers=new B.b(16),this._scene=C,this.opaqueSortCompareFn=m,this.alphaTestSortCompareFn=c,this.transparentSortCompareFn=E}return Object.defineProperty(M.prototype,"opaqueSortCompareFn",{set:function(R){this._opaqueSortCompareFn=R,this._renderOpaque=R?this.renderOpaqueSorted:M.renderUnsorted},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"alphaTestSortCompareFn",{set:function(R){this._alphaTestSortCompareFn=R,this._renderAlphaTest=R?this.renderAlphaTestSorted:M.renderUnsorted},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"transparentSortCompareFn",{set:function(R){this._transparentSortCompareFn=R||M.defaultTransparentSortCompare,this._renderTransparent=this.renderTransparentSorted},enumerable:!1,configurable:!0}),M.prototype.render=function(R,C,m,c){if(R)R(this._opaqueSubMeshes,this._alphaTestSubMeshes,this._transparentSubMeshes,this._depthOnlySubMeshes);else{var E=this._scene.getEngine();this._depthOnlySubMeshes.length!==0&&(E.setColorWrite(!1),this._renderAlphaTest(this._depthOnlySubMeshes),E.setColorWrite(!0)),this._opaqueSubMeshes.length!==0&&this._renderOpaque(this._opaqueSubMeshes),this._alphaTestSubMeshes.length!==0&&this._renderAlphaTest(this._alphaTestSubMeshes);var A=E.getStencilBuffer();if(E.setStencilBuffer(!1),C&&this._renderSprites(),m&&this._renderParticles(c),this.onBeforeTransparentRendering&&this.onBeforeTransparentRendering(),this._transparentSubMeshes.length!==0&&(E.setStencilBuffer(A),this._renderTransparent
13015(this._transparentSubMeshes),E.setAlphaMode(x.a.ALPHA_DISABLE)),E.setStencilBuffer(!1),this._edgesRenderers.length){for(var S=0;S<this._edgesRenderers.length;S++)this._edgesRenderers.data[S].render();E.setAlphaMode(x.a.ALPHA_DISABLE)}E.setStencilBuffer(A)}},M.prototype.renderOpaqueSorted=function(R){return M.renderSorted(R,this._opaqueSortCompareFn,this._scene.activeCamera,!1)},M.prototype.renderAlphaTestSorted=function(R){return M.renderSorted(R,this._alphaTestSortCompareFn,this._scene.activeCamera,!1)},M.prototype.renderTransparentSorted=function(R){return M.renderSorted(R,this._transparentSortCompareFn,this._scene.activeCamera,!0)},M.renderSorted=function(R,C,m,c){for(var E,A=0,S=m?m.globalPosition:M._zeroVector;A<R.length;A++)(E=R.data[A])._alphaIndex=E.getMesh().alphaIndex,E._distanceToCamera=_.e.Distance(E.getBoundingInfo().boundingSphere.centerWorld,S);var g=R.data.slice(0,R.length);for(C&&g.sort(C),A=0;A<g.length;A++){if(E=g[A],c){var l=E.getMaterial();if(l&&l.needDepthPrePass){var h=l.getScene().getEngine();h.setColorWrite(!1),h.setAlphaMode(x.a.ALPHA_DISABLE),E.render(!1),h.setColorWrite(!0)}}E.render(c)}},M.renderUnsorted=function(R){for(var C=0;C<R.length;C++)R.data[C].render(!1)},M.defaultTransparentSortCompare=function(R,C){return R._alphaIndex>C._alphaIndex?1:R._alphaIndex<C._alphaIndex?-1:M.backToFrontSortCompare(R,C)},M.backToFrontSortCompare=function(R,C){return R._distanceToCamera<C._distanceToCamera?1:R._distanceToCamera>C._distanceToCamera?-1:0},M.frontToBackSortCompare=function(R,C){return R._distanceToCamera<C._distanceToCamera?-1:R._distanceToCamera>C._distanceToCamera?1:0},M.prototype.prepare=function(){this._opaqueSubMeshes.reset(),this._transparentSubMeshes.reset(),this._alphaTestSubMeshes.reset(),this._depthOnlySubMeshes.reset(),this._particleSystems.reset(),this._spriteManagers.reset(),this._edgesRenderers.reset()},M.prototype.dispose=function(){this._opaqueSubMeshes.dispose(),this._transparentSubMeshes.dispose(),this._alphaTestSubMeshes.dispose(),this._depthOnlySubMeshes.dispose(),this._particleSystems.dispose(),this._spriteManagers.dispose(),this._edgesRenderers.dispose()},M.prototype.dispatch=function(R,C,m){C===void 0&&(C=R.getMesh()),m===void 0&&(m=R.getMaterial()),m!=null&&(m.needAlphaBlendingForMesh(C)?this._transparentSubMeshes.push(R):m.needAlphaTesting()?(m.needDepthPrePass&&this._depthOnlySubMeshes.push(R),this._alphaTestSubMeshes.push(R)):(m.needDepthPrePass&&this._depthOnlySubMeshes.push(R),this._opaqueSubMeshes.push(R)),C._renderingGroup=this,C._edgesRenderer&&C._edgesRenderer.isEnabled&&this._edgesRenderers.pushNoDuplicate(C._edgesRenderer))},M.prototype.dispatchSprites=function(R){this._spriteManagers.push(R)},M.prototype.dispatchParticles=function(R){this._particleSystems.push(R)},M.prototype._renderParticles=function(R){if(this._particleSystems.length!==0){var C=this._scene.activeCamera;this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);for(var m=0;m<this._particleSystems.length;m++){var c=this._particleSystems.data[m];if((C&&C.layerMask&c.layerMask)!==0){var E=c.emitter;E.position&&R&&R.indexOf(E)===-1||this._scene._activeParticles.addCount(c.render(),!1)}}this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene)}},M.prototype._renderSprites=function(){if(this._scene.spritesEnabled&&this._spriteManagers.length!==0){var R=this._scene.activeCamera;this._scene.onBeforeSpritesRenderingObservable.notifyObservers(this._scene);for(var C=0;C<this._spriteManagers.length;C++){var m=this._spriteManagers.data[C];(R&&R.layerMask&m.layerMask)!==0&&m.render()}this._scene.onAfterSpritesRenderingObservable.notifyObservers(this._scene)}},M._zeroVector=_.e.Zero(),M}()},function(Ae,v,f){f.d(v,"a",function(){return B});var B=function(_,x){this.distance=_,this.mesh=x}},function(Ae,v,f){f.d(v,"a",function(){return B});var B=function(){function _(){}return _.GenerateBase64StringFromTexture=function(x,u,M){u===void 0&&(u=0),M===void 0&&(M=0);var R=x.getInternalTexture();if(!R)return null;var C=x.readPixels(u,M);if(!C)return null;var m=x.getSize(),c=m.width,E=m.height;if(C instanceof Float32Array){for(var A=C.byteLength/C.BYTES_PER_ELEMENT,S=new Uint8Array(A);--A>=0;){var g=C[A];g<0?g=0:g>1&&(g=1),S[A]=255*g}C=S}var l=document.createElement("canvas");l.width=c,l.height=E;var h=l.getContext("2d");
13015if(!h)return null;var b=h.createImageData(c,E);if(b.data.set(C),h.putImageData(b,0,0),R.invertY){var T=document.createElement("canvas");T.width=c,T.height=E;var D=T.getContext("2d");return D?(D.translate(0,E),D.scale(1,-1),D.drawImage(l,0,0),T.toDataURL("image/png")):null}return l.toDataURL("image/png")},_}()},function(Ae,v,f){f.d(v,"a",function(){return A});var B=f(1),_=f(0),x=f(8),u=f(31),M=f(7),R=f(41),C=f(46),m=f(4),c=f(43),E=f(12);M.a._instancedMeshFactory=function(S,g){var l=new A(S,g);if(g.instancedBuffers)for(var h in l.instancedBuffers={},g.instancedBuffers)l.instancedBuffers[h]=g.instancedBuffers[h];return l};var A=function(S){function g(l,h){var b=S.call(this,l,h.getScene())||this;b._indexInSourceMeshInstanceArray=-1,h.addInstance(b),b._sourceMesh=h,b._unIndexed=h._unIndexed,b.position.copyFrom(h.position),b.rotation.copyFrom(h.rotation),b.scaling.copyFrom(h.scaling),h.rotationQuaternion&&(b.rotationQuaternion=h.rotationQuaternion.clone()),b.animations=E.b.Slice(h.animations);for(var T=0,D=h.getAnimationRanges();T<D.length;T++){var w=D[T];w!=null&&b.createAnimationRange(w.name,w.from,w.to)}return b.infiniteDistance=h.infiniteDistance,b.setPivotMatrix(h.getPivotMatrix()),b.refreshBoundingInfo(),b._syncSubMeshes(),b}return Object(B.d)(g,S),g.prototype.getClassName=function(){return"InstancedMesh"},Object.defineProperty(g.prototype,"lightSources",{get:function(){return this._sourceMesh._lightSources},enumerable:!1,configurable:!0}),g.prototype._resyncLightSources=function(){},g.prototype._resyncLightSource=function(l){},g.prototype._removeLightSource=function(l,h){},Object.defineProperty(g.prototype,"receiveShadows",{get:function(){return this._sourceMesh.receiveShadows},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"material",{get:function(){return this._sourceMesh.material},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"visibility",{get:function(){return this._sourceMesh.visibility},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"skeleton",{get:function(){return this._sourceMesh.skeleton},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"renderingGroupId",{get:function(){return this._sourceMesh.renderingGroupId},set:function(l){this._sourceMesh&&l!==this._sourceMesh.renderingGroupId&&x.a.Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene")},enumerable:!1,configurable:!0}),g.prototype.getTotalVertices=function(){return this._sourceMesh?this._sourceMesh.getTotalVertices():0},g.prototype.getTotalIndices=function(){return this._sourceMesh.getTotalIndices()},Object.defineProperty(g.prototype,"sourceMesh",{get:function(){return this._sourceMesh},enumerable:!1,configurable:!0}),g.prototype.createInstance=function(l){return this._sourceMesh.createInstance(l)},g.prototype.isReady=function(l){return l===void 0&&(l=!1),this._sourceMesh.isReady(l,!0)},g.prototype.getVerticesData=function(l,h){return this._sourceMesh.getVerticesData(l,h)},g.prototype.setVerticesData=function(l,h,b,T){return this.sourceMesh&&this.sourceMesh.setVerticesData(l,h,b,T),this.sourceMesh},g.prototype.updateVerticesData=function(l,h,b,T){return this.sourceMesh&&this.sourceMesh.updateVerticesData(l,h,b,T),this.sourceMesh},g.prototype.setIndices=function(l,h){return h===void 0&&(h=null),this.sourceMesh&&this.sourceMesh.setIndices(l,h),this.sourceMesh},g.prototype.isVerticesDataPresent=function(l){return this._sourceMesh.isVerticesDataPresent(l)},g.prototype.getIndices=function(){return this._sourceMesh.getIndices()},Object.defineProperty(g.prototype,"_positions",{get:function(){return this._sourceMesh._positions},enumerable:!1,configurable:!0}),g.prototype.refreshBoundingInfo=function(l){if(l===void 0&&(l=!1),this._boundingInfo&&this._boundingInfo.isLocked)return this;var h=this._sourceMesh.geometry?this._sourceMesh.geometry.boundingBias:null;return this._refreshBoundingInfo(this._sourceMesh._getPositionData(l),h),this},g.prototype._preActivate=function(){return this._currentLOD&&this._currentLOD._preActivate(),this},g.prototype._activate=function(l,h){if(this._sourceMesh.subMeshes||x.a.Warn("Instances should only be created for meshes with geometry."),this._currentLOD){if(this._currentLOD._getWorldMatrixDeterminant()>0!=this._getWorldMatrixDeterminant()>0)return this._internalAbstractMeshDataInfo._actAsRegularMesh=!0,!0;if(this._internalAbstractMeshDataInfo._actAsRegularMesh=!1,this._currentLOD._registerInstanceForRenderId(this,l),h){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},g.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)},g.prototype.getWorldMatrix=function(){if(this._currentLOD&&this._currentLOD.billboardMode!==C.a.BILLBOARDMODE_NONE&&this._currentLOD._masterMesh!==this){var l=this._currentLOD._masterMesh;return this._currentLOD._masterMesh=this,_.c.Vector3[7].copyFrom(this._currentLOD.position),this._currentLOD.position.set(0,0,0),_.c.Matrix[0].c
13015opyFrom(this._currentLOD.computeWorldMatrix(!0)),this._currentLOD.position.copyFrom(_.c.Vector3[7]),this._currentLOD._masterMesh=l,_.c.Matrix[0]}return S.prototype.getWorldMatrix.call(this)},Object.defineProperty(g.prototype,"isAnInstance",{get:function(){return!0},enumerable:!1,configurable:!0}),g.prototype.getLOD=function(l){if(!l)return this;var h=this.getBoundingInfo();return this._currentLOD=this.sourceMesh.getLOD(l,h.boundingSphere),this._currentLOD===this.sourceMesh?this.sourceMesh:this._currentLOD},g.prototype._preActivateForIntermediateRendering=function(l){return this.sourceMesh._preActivateForIntermediateRendering(l)},g.prototype._syncSubMeshes=function(){if(this.releaseSubMeshes(),this._sourceMesh.subMeshes)for(var l=0;l<this._sourceMesh.subMeshes.length;l++)this._sourceMesh.subMeshes[l].clone(this,this._sourceMesh);return this},g.prototype._generatePointsArray=function(){return this._sourceMesh._generatePointsArray()},g.prototype._updateBoundingInfo=function(){return this._boundingInfo?this._boundingInfo.update(this.worldMatrixFromCache):this._boundingInfo=new c.a(this.absolutePosition,this.absolutePosition,this.worldMatrixFromCache),this._updateSubMeshesBoundingInfo(this.worldMatrixFromCache),this},g.prototype.clone=function(l,h,b){h===void 0&&(h=null);var T=this._sourceMesh.createInstance(l);if(R.a.DeepCopy(this,T,["name","subMeshes","uniqueId","parent","lightSources","receiveShadows","material","visibility","skeleton","sourceMesh","isAnInstance","facetNb","isFacetDataEnabled","isBlocked","useBones","hasInstances","collider","edgesRenderer","forward","up","right","absolutePosition","absoluteScaling","absoluteRotationQuaternion","isWorldMatrixFrozen","nonUniformScaling","behaviors","worldMatrixFromCache","hasThinInstances"],[]),this.refreshBoundingInfo(),h&&(T.parent=h),!b)for(var D=0;D<this.getScene().meshes.length;D++){var w=this.getScene().meshes[D];w.parent===this&&w.clone(w.name,T)}return T.computeWorldMatrix(!0),T},g.prototype.dispose=function(l,h){h===void 0&&(h=!1),this._sourceMesh.removeInstance(this),S.prototype.dispose.call(this,l,h)},g}(u.a);M.a.prototype.edgesShareWithInstances=!1,M.a.prototype.registerInstancedBuffer=function(S,g){if(this.removeVerticesData(S),!this.instancedBuffers){this.instancedBuffers={};for(var l=0,h=this.instances;l<h.length;l++)h[l].instancedBuffers={};this._userInstancedBuffersStorage={data:{},vertexBuffers:{},strides:{},sizes:{}}}this.instancedBuffers[S]=null,this._userInstancedBuffersStorage.strides[S]=g,this._userInstancedBuffersStorage.sizes[S]=32*g,this._userInstancedBuffersStorage.data[S]=new Float32Array(this._userInstancedBuffersStorage.sizes[S]),this._userInstancedBuffersStorage.vertexBuffers[S]=new m.b(this.getEngine(),this._userInstancedBuffersStorage.data[S],S,!0,!1,g,!0),this.setVerticesBuffer(this._userInstancedBuffersStorage.vertexBuffers[S]);for(var b=0,T=this.instances;b<T.length;b++)T[b].instancedBuffers[S]=null},M.a.prototype._processInstancedBuffers=function(S,g){var l=S.length;for(var h in this.instancedBuffers){for(var b=this._userInstancedBuffersStorage.sizes[h],T=this._userInstancedBuffersStorage.strides[h],D=(l+1)*T;b<D;)b*=2;this._userInstancedBuffersStorage.data[h].length!=b&&(this._userInstancedBuffersStorage.data[h]=new Float32Array(b),this._userInstancedBuffersStorage.sizes[h]=b,this._userInstancedBuffersStorage.vertexBuffers[h]&&(this._userInstancedBuffersStorage.vertexBuffers[h].dispose(),this._userInstancedBuffersStorage.vertexBuffers[h]=null));var w=this._userInstancedBuffersStorage.data[h],N=0;g&&((V=this.instancedBuffers[h]).toArray?V.toArray(w,N):V.copyToArray(w,N),N+=T);for(var I=0;I<l;I++){var V;(V=S[I].instancedBuffers[h]).toArray?V.toArray(w,N):V.copyToArray(w,N),N+=T}this._userInstancedBuffersStorage.vertexBuffers[h]?this._userInstancedBuffersStorage.vertexBuffers[h].updateDirectly(w,0):(this._userInstancedBuffersStorage.vertexBuffers[h]=new m.b(this.getEngine(),this._userInstancedBuffersStorage.data[h],h,!0,!1,T,!0),this.setVerticesBuffer(this._userInstancedBuffersStorage.vertexBuffers[h]))}},M.a.prototype._disposeInstanceSpecificData=function(){for(this._instanceDataStorage.
13015instancesBuffer&&(this._instanceDataStorage.instancesBuffer.dispose(),this._instanceDataStorage.instancesBuffer=null);this.instances.length;)this.instances[0].dispose();for(var S in this.instancedBuffers)this._userInstancedBuffersStorage.vertexBuffers[S]&&this._userInstancedBuffersStorage.vertexBuffers[S].dispose();this.instancedBuffers={}}},function(Ae,v,f){f.d(v,"a",function(){return B});var B=function(){function _(){}return Object.defineProperty(_,"UniqueId",{get:function(){var x=this._UniqueIdCounter;return this._UniqueIdCounter++,x},enumerable:!1,configurable:!0}),_._UniqueIdCounter=0,_}()},function(Ae,v,f){var B=f(26),_=f(88);B.a.prototype.createUniformBuffer=function(x){var u=this._gl.createBuffer();if(!u)throw new Error("Unable to create uniform buffer");var M=new _.a(u);return this.bindUniformBuffer(M),x instanceof Float32Array?this._gl.bufferData(this._gl.UNIFORM_BUFFER,x,this._gl.STATIC_DRAW):this._gl.bufferData(this._gl.UNIFORM_BUFFER,new Float32Array(x),this._gl.STATIC_DRAW),this.bindUniformBuffer(null),M.references=1,M},B.a.prototype.createDynamicUniformBuffer=function(x){var u=this._gl.createBuffer();if(!u)throw new Error("Unable to create dynamic uniform buffer");var M=new _.a(u);return this.bindUniformBuffer(M),x instanceof Float32Array?this._gl.bufferData(this._gl.UNIFORM_BUFFER,x,this._gl.DYNAMIC_DRAW):this._gl.bufferData(this._gl.UNIFORM_BUFFER,new Float32Array(x),this._gl.DYNAMIC_DRAW),this.bindUniformBuffer(null),M.references=1,M},B.a.prototype.updateUniformBuffer=function(x,u,M,R){this.bindUniformBuffer(x),M===void 0&&(M=0),R===void 0?u instanceof Float32Array?this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,M,u):this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,M,new Float32Array(u)):u instanceof Float32Array?this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,0,u.subarray(M,M+R)):this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,0,new Float32Array(u).subarray(M,M+R)),this.bindUniformBuffer(null)},B.a.prototype.bindUniformBuffer=function(x){this._gl.bindBuffer(this._gl.UNIFORM_BUFFER,x?x.underlyingResource:null)},B.a.prototype.bindUniformBufferBase=function(x,u){this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER,u,x?x.underlyingResource:null)},B.a.prototype.bindUniformBlock=function(x,u,M){var R=x.program,C=this._gl.getUniformBlockIndex(R,u);this._gl.uniformBlockBinding(R,C,M)}},function(Ae,v,f){var B="lightsFragmentFunctions",_=`
13016struct lightingInfo
13017{
13018vec3 diffuse;
13019#ifdef SPECULARTERM
13020vec3 specular;
13021#endif
13022#ifdef NDOTL
13023float ndl;
13024#endif
13025};
13026lightingInfo computeLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {
13027lightingInfo result;
13028vec3 lightVectorW;
13029float attenuation=1.0;
13030if (lightData.w == 0.)
13031{
13032vec3 direction=lightData.xyz-vPositionW;
13033attenuation=max(0.,1.0-length(direction)/range);
13034lightVectorW=normalize(direction);
13035}
13036else
13037{
13038lightVectorW=normalize(-lightData.xyz);
13039}
13040
13041float ndl=max(0.,dot(vNormal,lightVectorW));
13042#ifdef NDOTL
13043result.ndl=ndl;
13044#endif
13045result.diffuse=ndl*diffuseColor*attenuation;
13046#ifdef SPECULARTERM
13047
13048vec3 angleW=normalize(viewDirectionW+lightVectorW);
13049float specComp=max(0.,dot(vNormal,angleW));
13050specComp=pow(specComp,max(1.,glossiness));
13051result.specular=specComp*specularColor*attenuation;
13052#endif
13053return result;
13054}
13055lightingInfo computeSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {
13056lightingInfo result;
13057vec3 direction=lightData.xyz-vPositionW;
13058vec3 lightVectorW=normalize(direction);
13059float attenuation=max(0.,1.0-length(direction)/range);
13060
13061float cosAngle=max(0.,dot(lightDirection.xyz,-lightVectorW));
13062if (cosAngle>=lightDirection.w)
13063{
13064cosAngle=max(0.,pow(cosAngle,lightData.w));
13065attenuation*=cosAngle;
13066
13067float ndl=max(0.,dot(vNormal,lightVectorW));
13068#ifdef NDOTL
13069result.ndl=ndl;
13070#endif
13071result.diffuse=ndl*diffuseColor*attenuation;
13072#ifdef SPECULARTERM
13073
13074vec3 angleW=normalize(viewDirectionW+lightVectorW);
13075float specComp=max(0.,dot(vNormal,angleW));
13076specComp=pow(specComp,max(1.,glossiness));
13077result.specular=specComp*specularColor*attenuation;
13078#endif
13079return result;
13080}
13081result.diffuse=vec3(0.);
13082#ifdef SPECULARTERM
13083result.specular=vec3(0.);
13084#endif
13085#ifdef NDOTL
13086result.ndl=0.;
13087#endif
13088return result;
13089}
13090lightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float glossiness) {
13091lightingInfo result;
13092
13093float ndl=dot(vNormal,lightData.xyz)*0.5+0.5;
13094#ifdef NDOTL
13095result.ndl=ndl;
13096#endif
13097result.diffuse=mix(groundColor,diffuseColor,ndl);
13098#ifdef SPECULARTERM
13099
13100vec3 angleW=normalize(viewDirectionW+lightData.xyz);
13101float specComp=max(0.,dot(vNormal,angleW));
13102specComp=pow(specComp,max(1.,glossiness));
13103result.specular=specComp*specularColor;
13104#endif
13105return result;
13106}
13107#define inline
13108vec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){
13109vec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);
13110strq/=strq.w;
13111vec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;
13112return textureColor;
13113}`;f(5).a.IncludesShadersStore[B]=_},function(Ae,v,f){var B="logDepthFragment",_=`#ifdef LOGARITHMICDEPTH
13114gl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;
13115#endif`;f(5).a.IncludesShadersStore[B]=_},function(Ae,v,f){var B=`#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)
13116#if defined(TANGENT) && defined(NORMAL)
13117vec3 tbnNormal=normalize(normalUpdated);
13118vec3 tbnTangent=normalize(tangentUpdated.xyz);
13119vec3 tbnBitangent=cross(tbnNormal,tbnTangent)*tangentUpdated.w;
13120vTBN=mat3(finalWorld)*mat3(tbnTangent,tbnBitangent,tbnNormal);
13121#endif
13122#endif`;f(5).a.IncludesShadersStore.bumpVertex=B},function(Ae,v,f){var B=`#ifdef FOG
13123vFogDistance=(view*worldPos).xyz;
13124#endif`;f(5).a.IncludesShadersStore.fogVertex=B},function(Ae,v,f){var B="logDepthVertex",_=`#ifdef LOGARITHMICDEPTH
13125vFragmentDepth=1.0+gl_Position.w;
13126gl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;
13127#endif`;f(5).a.IncludesShadersStore[B]=_},function(Ae,v){var f;f=function(){return this}();try{f=f||new Function("return this")()}catch{typeof window=="object"&&(f=window)}Ae.exports=f},function(Ae,v,f){var B="prePassDeclaration",_=`#ifdef PREPASS
13128#extension GL_EXT_draw_buffers : require
13129#ifdef WEBGL2
13130layout(location=0) out highp vec4 glFragData[{X}];
13131highp vec4 gl_FragColor;
13132#endif
13133#ifdef PREPASS_DEPTHNORMAL
13134varying highp vec3 vViewPos;
13135#endif
13136#ifdef PREPASS_VELOCITY
13137varying highp vec4 vCurrentPosition;
13138varying highp vec4 vPreviousPosition;
13139#endif
13140#endif
13141`;f(5).a.IncludesShadersStore[B]=_},function(Ae,v,f){var B="fresnelFunction",_=`#ifdef FRESNEL
13142float computeFresnelTerm(vec3 viewDirection,vec3 worldNormal,float bias,float power)
13143{
13144float fresnelTerm=pow(bias+abs(dot(viewDirection,worldNormal)),power);
13145return clamp(fresnelTerm,0.,1.);
13146}
13147#endif`;f(5).a.IncludesShadersStore[B]=_},function(Ae,v,f){var B=`#ifdef DEPTHPREPASS
13148gl_FragColor=vec4(0.,0.,0.,1.0);
13149return;
13150#endif`;f(5).a.IncludesShadersStore.depthPrePass=B},function(Ae,v,f){var B="prePassVertexDeclaration",_=`#ifdef PREPASS
13151#ifdef PREPASS_DEPTHNORMAL
13152varying vec3 vViewPos;
13153#endif
13154#ifdef PREPASS_VELOCITY
13155uniform mat4 previousWorld;
13156uniform mat4 previousViewProjection;
13157varying vec4 vCurrentPosition;
13158varying vec4 vPreviousPosition;
13159#endif
13160#endif`;f(5).a.IncludesShadersStore[B]=_},function(Ae,v,f){var B="bumpVertexDeclaration",_=`#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)
13161#if defined(TANGENT) && defined(NORMAL)
13162varying mat3 vTBN;
13163#endif
13164#endif
13165`;f(5).a.IncludesShadersStore[B]=_},function(Ae,v,f){var B="prePassVertex",_=`#ifdef PREPASS_DEPTHNORMAL
13166vViewPos=(view*worldPos).rgb;
13167#endif
13168#if defined(PREPASS_VELOCITY) && defined(BONES_VELOCITY_ENABLED)
13169vCurrentPosition=viewProjection*worldPos;
13170#if NUM_BONE_INFLUENCERS>0
13171mat4 previousInfluence;
13172previousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0];
13173#if NUM_BONE_INFLUENCERS>1
13174previousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1];
13175#endif
13176#if NUM_BONE_INFLUENCERS>2
13177previousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2];
13178#endif
13179#if NUM_BONE_INFLUENCERS>3
13180previousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3];
13181#endif
13182#if NUM_BONE_INFLUENCERS>4
13183previousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];
13184#endif
13185#if NUM_BONE_INFLUENCERS>5
13186previousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];
13187#endif
13188#if NUM_BONE_INFLUENCERS>6
13189previousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];
13190#endif
13191#if NUM_BONE_INFLUENCERS>7
13192previousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];
13193#endif
13194vPreviousPosition=previousViewProjection*previousWorld*previousInfluence*vec4(positionUpdated,1.0);
13195#else
13196vPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0);
13197#endif
13198#endif`;f(5).a.IncludesShadersStore[B]=_},function(Ae,v,f){var B=f(5),_=(f(115),f(110),"colorPixelShader"),x=`#ifdef VERTEXCOLOR
13199varying vec4 vColor;
13200#else
13201uniform vec4 color;
13202#endif
13203#include<clipPlaneFragmentDeclaration>
13204void main(void) {
13205#include<clipPlaneFragment>
13206#ifdef VERTEXCOLOR
13207gl_FragColor=vColor;
13208#else
13209gl_FragColor=color;
13210#endif
13211}`;B.a.ShadersStore[_]=x},function(Ae,v,f){var B=f(5),_=(f(78),f(117),f(79),f(80),f(81),f(111),"colorVertexShader"),x=`
13212attribute vec3 position;
13213#ifdef VERTEXCOLOR
13214attribute vec4 color;
13215#endif
13216#include<bonesDeclaration>
13217#include<clipPlaneVertexDeclaration>
13218
13219#include<instancesDeclaration>
13220uniform mat4 viewProjection;
13221#ifdef MULTIVIEW
13222uniform mat4 viewProjectionR;
13223#endif
13224
13225#ifdef VERTEXCOLOR
13226varying vec4 vColor;
13227#endif
13228void main(void) {
13229#include<instancesVertex>
13230#include<bonesVertex>
13231vec4 worldPos=finalWorld*vec4(position,1.0);
13232#ifdef MULTIVIEW
13233if (gl_ViewID_OVR == 0u) {
13234gl_Position=viewProjection*worldPos;
13235} else {
13236gl_Position=viewProjectionR*worldPos;
13237}
13238#else
13239gl_Position=viewProjection*worldPos;
13240#endif
13241#include<clipPlaneVertex>
13242#ifdef VERTEXCOLOR
13243
13244vColor=color;
13245#endif
13246}`;B.a.ShadersStore[_]=x},function(Ae,v,f){(function(B){f.d(v,"b",function(){return E}),f.d(v,"a",function(){return A});var _=f(1),x=f(8),u=f(13),M=f(102),R=f(27),C=f(2),m=f(89),c=f(74),E=function(){this.renderWidth=512,this.renderHeight=256,this.textureSize=512,this.deterministicLockstep=!1,this.lockstepMaxSteps=4},A=function(S){function g(l){l===void 0&&(l=new E);var h=S.call(this,null)||this;u.a.Instances.push(h),l.deterministicLockstep===void 0&&(l.deterministicLockstep=!1),l.lockstepMaxSteps===void 0&&(l.lockstepMaxSteps=4),h._options=l,c.a.SetMatrixPrecision(!!l.useHighPrecisionMatrix),h._caps={maxTexturesImageUnits:16,maxVertexTextureImageUnits:16,maxCombinedTexturesImageUnits:32,maxTextureSize:512,maxCubemapTextureSize:512,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,textureFloat:!1,textureFloatLinearFiltering:!1,textureFloatRender:!1,textureHalfFloat:!1,textureHalfFloatLinearFiltering:!1,textureHalfFloatRender:!1,textureLOD:!1,drawBuffersExtension:!1,depthTextureExtension:!1,vertexArrayObject:!1,instancedArrays:!1,canUseTimestampForTimerQuery:!1,maxMSAASamples:1,blendMinMax:!1},x.a.Log("Babylon.js v"+u.a.Version+" - Null engine");var b=typeof self<"u"?self:B!==void 0?B:window;return typeof URL>"u"&&(b.URL={createObjectURL:function(){},revokeObjectURL:function(){}}),typeof Blob>"u"&&(b.Blob=function(){}),h}return Object(_.d)(g,S),g.prototype.isDeterministicLockStep=function(){return this._options.deterministicLockstep},g.prototype.getLockstepMaxSteps=function(){return this._options.lockstepMaxSteps},g.prototype.getHardwareScalingLevel=function(){return 1},g.prototype.createVertexBuffer=function(l){var h=new m.a;return h.references=1,h},g.prototype.createIndexBuffer=function(l){var h=new m.a;return h.references=1,h},g.prototype.clear=function(l,h,b,T){},g.prototype.getRenderWidth=function(l){return l===void 0&&(l=!1),!l&&this._currentRenderTarget?this._currentRenderTarget.width:this._options.renderWidth},g.prototype.getRenderHeight=function(l){return l===void 0&&(l=!1),!l&&this._currentRenderTarget?this._currentRenderTarget.height:this._options.renderHeight},g.prototype.setViewport=function(l,h,b){this._cachedViewport=l},g.prototype.createShaderProgram=function(l,h,b,T,D){return{__SPECTOR_rebuildProgram:null}},g.prototype.getUniforms=function(l,h){return[]},g.prototype.getAttributes=function(l,h){return[]},g.prototype.bindSamplers=function(l){this._currentEffect=null},g.prototype.enableEffect=function(l){this._currentEffect=l,l.onBind&&l.onBind(l),l._onBindObservable&&l._onBindObservable.notifyObservers(l)},g.prototype.setState=function(l,h,b,T){},g.prototype.setIntArray=function(l,h){return!0},g.prototype.setIntArray2=function(l,h){return!0},g.prototype.setIntArray3=function(l,h){return!0},g.prototype.setIntArray4=function(l,h){return!0},g.prototype.setFloatArray=function(l,h){return!0},g.prototype.setFloatArray2=function(l,h){return!0},g.prototype.setFloatArray3=function(l,h){return!0},g.prototype.setFloatArray4=function(l,h){return!0},g.prototype.setArray=function(l,h){return!0},g.prototype.setArray2=function(l,h){return!0},g.prototype.setArray3=function(l,h){return!0},g.prototype.setArray4=function(l,h){return!0}
13246,g.prototype.setMatrices=function(l,h){return!0},g.prototype.setMatrix3x3=function(l,h){return!0},g.prototype.setMatrix2x2=function(l,h){return!0},g.prototype.setFloat=function(l,h){return!0},g.prototype.setFloat2=function(l,h,b){return!0},g.prototype.setFloat3=function(l,h,b,T){return!0},g.prototype.setBool=function(l,h){return!0},g.prototype.setFloat4=function(l,h,b,T,D){return!0},g.prototype.setAlphaMode=function(l,h){h===void 0&&(h=!1),this._alphaMode!==l&&(this.alphaState.alphaBlend=l!==C.a.ALPHA_DISABLE,h||this.setDepthWrite(l===C.a.ALPHA_DISABLE),this._alphaMode=l)},g.prototype.bindBuffers=function(l,h,b){},g.prototype.wipeCaches=function(l){this.preventCacheWipeBetweenFrames||(this.resetTextureCache(),this._currentEffect=null,l&&(this._currentProgram=null,this.stencilState.reset(),this.depthCullingState.reset(),this.alphaState.reset()),this._cachedVertexBuffers=null,this._cachedIndexBuffer=null,this._cachedEffectForVertexBuffers=null)},g.prototype.draw=function(l,h,b,T){},g.prototype.drawElementsType=function(l,h,b,T){},g.prototype.drawArraysType=function(l,h,b,T){},g.prototype._createTexture=function(){return{}},g.prototype._releaseTexture=function(l){},g.prototype.createTexture=function(l,h,b,T,D,w,N,I,V,W,j,ne){D===void 0&&(D=C.a.TEXTURE_TRILINEAR_SAMPLINGMODE),w===void 0&&(w=null),W===void 0&&(W=null);var te=new R.a(this,R.b.Url),de=String(l);return te.url=de,te.generateMipMaps=!h,te.samplingMode=D,te.invertY=b,te.baseWidth=this._options.textureSize,te.baseHeight=this._options.textureSize,te.width=this._options.textureSize,te.height=this._options.textureSize,W&&(te.format=W),te.isReady=!0,w&&w(),this._internalTexturesCache.push(te),te},g.prototype.createRenderTargetTexture=function(l,h){var b=new M.a;h!==void 0&&typeof h=="object"?(b.generateMipMaps=h.generateMipMaps,b.generateDepthBuffer=h.generateDepthBuffer===void 0||h.generateDepthBuffer,b.generateStencilBuffer=b.generateDepthBuffer&&h.generateStencilBuffer,b.type=h.type===void 0?C.a.TEXTURETYPE_UNSIGNED_INT:h.type,b.samplingMode=h.samplingMode===void 0?C.a.TEXTURE_TRILINEAR_SAMPLINGMODE:h.samplingMode):(b.generateMipMaps=h,b.generateDepthBuffer=!0,b.generateStencilBuffer=!1,b.type=C.a.TEXTURETYPE_UNSIGNED_INT,b.samplingMode=C.a.TEXTURE_TRILINEAR_SAMPLINGMODE);var T=new R.a(this,R.b.RenderTarget),D=l.width||l,w=l.height||l;return T._depthStencilBuffer={},T._framebuffer={},T.baseWidth=D,T.baseHeight=w,T.width=D,T.height=w,T.isReady=!0,T.samples=1,T.generateMipMaps=!!b.generateMipMaps,T.samplingMode=b.samplingMode,T.type=b.type,T._generateDepthBuffer=b.generateDepthBuffer,T._generateStencilBuffer=!!b.generateStencilBuffer,this._internalTexturesCache.push(T),T},g.prototype.updateTextureSamplingMode=function(l,h){h.samplingMode=l},g.prototype.bindFramebuffer=function(l,h,b,T,D){this._currentRenderTarget&&this.unBindFramebuffer(this._currentRenderTarget),this._currentRenderTarget=l,this._currentFramebuffer=l._MSAAFramebuffer?l._MSAAFramebuffer:l._framebuffer,this._cachedViewport&&!D&&this.setViewport(this._cachedViewport,b,T)},g.prototype.unBindFramebuffer=function(l,h,b){this._currentRenderTarget=null,b&&(l._MSAAFramebuffer&&(this._currentFramebuffer=l._framebuffer),b()),this._currentFramebuffer=null},g.prototype.createDynamicVertexBuffer=function(l){var h=new m.a;return h.references=1,h.capacity=1,h},g.prototype.updateDynamicTexture=function(l,h,b,T,D){},g.prototype.areAllEffectsReady=function(){return!0},g.prototype.getError=function(){return 0},g.prototype._getUnpackAlignement=function(){return 1},g.prototype._unpackFlipY=function(l){},g.prototype.updateDynamicIndexBuffer=function(l,h,b){},g.prototype.updateDynamicVertexBuffer=function(l,h,b,T){},g.prototype._bindTextureDirectly=function(l,h){return this._boundTexturesCache[this._activeChannel]!==h&&(this._boundTexturesCache[this._activeChannel]=h,!0)},g.prototype._bindTexture=function(l,h){l<0||this._bindTextureDirectly(0,h)},g.prototype._deleteBuffer=function(l){},g.prototype.releaseEffects=function(){},g.prototype.displayLoadingUI=function(){},g.prototype.hideLoadingUI=function(){},g.prototype._uploadCompressedDataToTextureDirectly=function(l,h,b,T,D,w,N){},g.prototype._uploadDataToTextureDirectly=function(l,h,b,T){},g.prototype._uploadArrayBufferViewToTexture=function(l,h,b,T){},g.prototype._uploadImageToTexture=function(l,h,b,T){},g}(u.a)}).call(this,f(159))},function(Ae,v,f){f.r(v),function(B){f.d(v,"Debug",function(){return m});var _=f(127),x=f(99);f.d(v,"AbstractScene",function(){return _.AbstractScene}),f.d(v,"AbstractActionManager",function(){return _.AbstractActionManager}),f.d(v,"Action",function(){return _.Action}),f.d(v,"ActionEvent",function(){return _.ActionEvent}),f.d(v,"ActionManager",function(){return _.ActionManager}),f.d(v,"Condition",function(){return _.Condition}),f.d(v,"ValueCondition",function(){return _.ValueCondition}),f.d(v,"PredicateCondition",function(){return _.PredicateCondition}),f.d(v,"StateCondition",function(){return _.StateCondition}),f.d(v,"SwitchBooleanAction",function(){return _.SwitchBooleanAction}),f.d(v,"SetStateAction",function(){return _.SetStateAction}),f.d(v,"SetValueAction",function(){return _.SetValueAction}),f.d(v,"IncrementValueAction",function(){return _.IncrementValueAction}),f.d(v,"PlayAnimationAction",function(){return _.PlayAnimationAction}),f.d(v,"StopAnimationAction",function(){return _.StopAnimationAction}),f.d(v,"DoNothingAction",function(){return _.DoNothingAction}),f.d(v,"CombineAction",function(){return _.CombineAction}),f.d(v,"ExecuteCodeAction",function(){return _.ExecuteCodeAction}),f.d(v,"SetParentAction",function(){return _.SetParentAction}),f.d(v,"PlaySoundAction",function(){return _.PlaySoundAction}),f.d(v,"StopSoundAction",function(){return _.StopSoundAction}),f.d(v,"InterpolateValueAction",function(){return _.InterpolateValueAction}),f.d(v,"Animatable",function(){return _.Animatable}),f.d(v,"_IAnimationState",function(){return _._IAnimationState}),f.d(v,"Animation",function(){return _.Animation}),f.d(v,"TargetedAnimation",function(){return _.TargetedAnimation}),f.d(v,"AnimationGroup",function(){return _.AnimationGroup}),f.d(v,"AnimationPropertiesOverride",function(){return _.AnimationPropertiesOverride}),f.d(v,"EasingFunction",function(){return _.EasingFunction}
13246),f.d(v,"CircleEase",function(){return _.CircleEase}),f.d(v,"BackEase",function(){return _.BackEase}),f.d(v,"BounceEase",function(){return _.BounceEase}),f.d(v,"CubicEase",function(){return _.CubicEase}),f.d(v,"ElasticEase",function(){return _.ElasticEase}),f.d(v,"ExponentialEase",function(){return _.ExponentialEase}),f.d(v,"PowerEase",function(){return _.PowerEase}),f.d(v,"QuadraticEase",function(){return _.QuadraticEase}),f.d(v,"QuarticEase",function(){return _.QuarticEase}),f.d(v,"QuinticEase",function(){return _.QuinticEase}),f.d(v,"SineEase",function(){return _.SineEase}),f.d(v,"BezierCurveEase",function(){return _.BezierCurveEase}),f.d(v,"RuntimeAnimation",function(){return _.RuntimeAnimation}),f.d(v,"AnimationEvent",function(){return _.AnimationEvent}),f.d(v,"AnimationKeyInterpolation",function(){return _.AnimationKeyInterpolation}),f.d(v,"AnimationRange",function(){return _.AnimationRange}),f.d(v,"KeepAssets",function(){return _.KeepAssets}),f.d(v,"InstantiatedEntries",function(){return _.InstantiatedEntries}),f.d(v,"AssetContainer",function(){return _.AssetContainer}),f.d(v,"Analyser",function(){return _.Analyser}),f.d(v,"AudioEngine",function(){return _.AudioEngine}),f.d(v,"AudioSceneComponent",function(){return _.AudioSceneComponent}),f.d(v,"Sound",function(){return _.Sound}),f.d(v,"SoundTrack",function(){return _.SoundTrack}),f.d(v,"WeightedSound",function(){return _.WeightedSound}),f.d(v,"AutoRotationBehavior",function(){return _.AutoRotationBehavior}),f.d(v,"BouncingBehavior",function(){return _.BouncingBehavior}),f.d(v,"FramingBehavior",function(){return _.FramingBehavior}),f.d(v,"AttachToBoxBehavior",function(){return _.AttachToBoxBehavior}),f.d(v,"FadeInOutBehavior",function(){return _.FadeInOutBehavior}),f.d(v,"MultiPointerScaleBehavior",function(){return _.MultiPointerScaleBehavior}),f.d(v,"PointerDragBehavior",function(){return _.PointerDragBehavior}),f.d(v,"SixDofDragBehavior",function(){return _.SixDofDragBehavior}),f.d(v,"Bone",function(){return _.Bone}),f.d(v,"BoneIKController",function(){return _.BoneIKController}),f.d(v,"BoneLookController",function(){return _.BoneLookController}),f.d(v,"Skeleton",function(){return _.Skeleton}),f.d(v,"ArcRotateCameraGamepadInput",function(){return _.ArcRotateCameraGamepadInput}),f.d(v,"ArcRotateCameraKeyboardMoveInput",function(){return _.ArcRotateCameraKeyboardMoveInput}),f.d(v,"ArcRotateCameraMouseWheelInput",function(){return _.ArcRotateCameraMouseWheelInput}),f.d(v,"ArcRotateCameraPointersInput",function(){return _.ArcRotateCameraPointersInput}),f.d(v,"ArcRotateCameraVRDeviceOrientationInput",function(){return _.ArcRotateCameraVRDeviceOrientationInput}),f.d(v,"FlyCameraKeyboardInput",function(){return _.FlyCameraKeyboardInput}),f.d(v,"FlyCameraMouseInput",function(){return _.FlyCameraMouseInput}),f.d(v,"FollowCameraKeyboardMoveInput",function(){return _.FollowCameraKeyboardMoveInput}),f.d(v,"FollowCameraMouseWheelInput",function(){return _.FollowCameraMouseWheelInput}),f.d(v,"FollowCameraPointersInput",function(){return _.FollowCameraPointersInput}),f.d(v,"FreeCameraDeviceOrientationInput",function(){return _.FreeCameraDeviceOrientationInput}),f.d(v,"FreeCameraGamepadInput",function(){return _.FreeCameraGamepadInput}),f.d(v,"FreeCameraKeyboardMoveInput",function(){return _.FreeCameraKeyboardMoveInput}),f.d(v,"FreeCameraMouseInput",function(){return _.FreeCameraMouseInput}),f.d(v,"FreeCameraMouseWheelInput",function(){return _.FreeCameraMouseWheelInput}),f.d(v,"FreeCameraTouchInput",function(){return _.FreeCameraTouchInput}),f.d(v,"FreeCameraVirtualJoystickInput",function(){return _.FreeCameraVirtualJoystickInput}),f.d(v,"CameraInputTypes",function(){return _.CameraInputTypes}),f.d(v,"CameraInputsManager",function(){return _.CameraInputsManager}),f.d(v,"Camera",function(){return _.Camera}),f.d(v,"TargetCamera",function(){return _.TargetCamera}),f.d(v,"FreeCamera",function(){return _.FreeCamera}),f.d(v,"FreeCameraInputsManager",function(){return _.FreeCameraInputsManager}),f.d(v,"TouchCamera",function(){return _.TouchCamera}),f.d(v,"ArcRotateCamera",function(){return _.ArcRotateCamera}),f.d(v,"ArcRotateCameraInputsManager",function(){return _.ArcRotateCameraInputsManager}),f.d(v,"DeviceOrientationCamera",function(){return _.DeviceOrientationCamera}),f.d(v,"FlyCamera",function(){return _.FlyCamera}),f.d(v,"FlyCameraInputsManager",function(){return _.FlyCameraInputsManager}),f.d(v,"FollowCamera",function(){return _.FollowCamera}),f.d(v,"ArcFollowCamera",function(){return _.ArcFollowCamera}),f.d(v,"FollowCameraInputsManager",function(){return _.FollowCameraInputsManager}),f.d(v,"GamepadCamera",function(){return _.GamepadCamera}),f.d(v,"AnaglyphArcRotateCamera",function(){return _.AnaglyphArcRotateCamera}),f.d(v,"AnaglyphFreeCamera",function(){return _.AnaglyphFreeCamera}),f.d(v,"AnaglyphGamepadCamera",function(){return _.AnaglyphGamepadCamera}),f.d(v,"AnaglyphUniversalCamera",function(){return _.AnaglyphUniversalCamera}),f.d(v,"StereoscopicArcRotateCamera",function(){return _.StereoscopicArcRotateCamera}),f.d(v,"StereoscopicFreeCamera",function(){return _.StereoscopicFreeCamera}),f.d(v,"StereoscopicGamepadCamera",function(){return _.StereoscopicGamepadCamera}),f.d(v,"StereoscopicUniversalCamera",function(){return _.StereoscopicUniversalCamera}),f.d(v,"UniversalCamera",function(){return _.UniversalCamera}),f.d(v,"VirtualJoysticksCamera",function(){return _.VirtualJoysticksCamera}),f.d(v,"VRCameraMetrics",function(){return _.VRCameraMetrics}),f.d(v,"VRDeviceOrientationArcRotateCamera",function(){return _.VRDeviceOrientationArcRotateCamera}),f.d(v,"VRDeviceOrientationFreeCamera",function(){return _.VRDeviceOrientationFreeCamera}),f.d(v,"VRDeviceOrientationGamepadCamera",function(){return _.VRDeviceOrientationGamepadCamera}),f.d(v,"OnAfterEnteringVRObservableEvent",function(){return _.OnAfterEnteringVRObservableEvent}),f.d(v,"VRExperienceHelper",function(){return _.VRExperienceHelper}),f.d(v,"WebVRFreeCamera",function(){return _.WebVRFreeCamera}),f.d(v,"Collider",function(){return _.Collider}),f.d(v,"DefaultCollisionCoordinator",function(){return _.DefaultCollisionCoordinator}),f.d(v,"PickingInfo",function(){return _.PickingInfo}),f.d(v,"IntersectionInfo",function(){return _.IntersectionInfo}),f.d(v,"_MeshCollisionData",function(){return _._MeshCollisionData}),f.d(v,"BoundingBox",function(){return _.BoundingBox}),f.d(v,"BoundingInfo",function(){return _.BoundingInfo}),f.d(v,"BoundingSphere",function(){return _.BoundingSphere}),f.d(v,"Octree",function(){return _.Octree}),f.d(v,"OctreeBlock",function(){return _.OctreeBlock}),f.d(v,"OctreeSceneComponent",function(){return _.OctreeSceneComponent}),f.d(v,"Ray",function(){return _.Ray}),f.d(v,"AxesViewer",function(){return _.AxesViewer}),f.d(v,"BoneAxesViewer",function(){return _.BoneAxesViewer}),f.d(v,"DebugLayerTab",function(){return _.DebugLayerTab}),f.d(v,"DebugLayer",function(){return _.DebugLayer}),f.d(v,"PhysicsViewer",function(){return _.PhysicsViewer}),f.d(v,"RayHelper",function(){return _.RayHelper}),f.d(v,"SkeletonViewer",function(){return _.SkeletonViewer}),f.d(v,"DeviceInputSystem",function(){return _.DeviceInputSystem}),f.d(v,"DeviceType",function(){return _.DeviceType}),f.d(v,"PointerInput",function(){return _.PointerInput}),f.d(v,"DualShockInput",function(){return _.DualShockInput}),f.d(v,"XboxInput",function(){return _.XboxInput}),f.d(v,"SwitchInput",function(){return _.SwitchInput}),f.d(v,"DeviceSource",function(){return _.DeviceSource}),f.d(v,"DeviceSourceManager",function(){return _.DeviceSourceManager}),f.d(v,"Constants",function(){return _.Constants}),f.d(v,"ThinEngine",function(){return _.ThinEngine}),f.d(v,"Engine",function(){return _.Engine}),f.d(v,"EngineStore",function(){return _.EngineStore}),f.d(v,"NullEngineOptions",function(){return _.NullEngineOptions}),f.d(v,"NullEngine",function(){return _.NullEngine}),f.d(v,"_OcclusionDataStorage",function(){return _._OcclusionDataStorage}),f.d(v,"_forceTransformFeedbackToBundle",function(){return _._forceTransformFeedbackToBundle}),f.d(v,"EngineView",function(){return _.EngineView}),f.d(v,"WebGLPipelineContext",function(){return _.WebGLPipelineContext}),f.d(v,"WebGL2ShaderProcessor",function(){return _.WebGL2ShaderProcessor}),f.d(v,"NativeEngine",function(){return _.NativeEngine}),f.d(v,"ShaderCodeInliner",function(){return _.ShaderCodeInliner}),f.d(v,"PerformanceConfigurator",function(){return _.PerformanceConfigurator}),f.d(v,"KeyboardEventTypes",function(){return _.KeyboardEventTypes}),f.d(v,"KeyboardInfo",function(){return _.KeyboardInfo}),f.d(v,"KeyboardInfoPre",function(){return _.KeyboardInfoPre}),f.d(v,"PointerEventTypes",function(){return _.PointerEventTypes}),f.d(v,"PointerInfoBase",function(){return _.PointerInfoBase}),f.d(v,"PointerInfoPre",function(){return _.PointerInfoPre}),f.d(v,"PointerInfo",function(){return _.PointerInfo}),f.d(v,"ClipboardEventTypes",function(){return _.ClipboardEventTypes}),f.d(v,"ClipboardInfo",function(){return _.ClipboardInfo}),f.d(v,"DaydreamController",function(){return _.DaydreamController}),f.d(v,"GearVRController",function(){return _.GearVRController}),f.d(v,"GenericController",function(){return _.GenericController}),f.d(v,"OculusTouchController",function(){return _.OculusTouchController}),f.d(v,"PoseEnabledControllerType",function(){return _.PoseEnabledControllerType}),f.d(v,"PoseEnabledControllerHelper",function(){return _.PoseEnabledControllerHelper}),f.d(v,"PoseEnabledController",function(){return _.PoseEnabledController}),f.d(v,"ViveController",function(){return _.ViveController}),f.d(v,"WebVRController",function(){return _.WebVRController}),f.d(v,"WindowsMotionController",function(){return _.WindowsMotionController}),f.d(v,"XRWindowsMotionController",function(){return _.XRWindowsMotionController}),f.d(v,"StickValues",function(){return _.StickValues}),f.d(v,"Gamepad",function(){return _.Gamepad}),f.d(v,"GenericPad",function(){return _.GenericPad}),f.d(v,"GamepadManager",function(){return _.GamepadManager}),f.d(v,"GamepadSystemSceneComponent",function(){return _.GamepadSystemSceneComponent}),f.d(v,"Xbox360Button",function(){return _.Xbox360Button}),f.d(v,"Xbox360Dpad",function(){return _.Xbox360Dpad}),f.d(v,"Xbox360Pad",function(){return _.Xbox360Pad}),f.d(v,"DualShockButton",function(){return _.DualShockButton}),f.d(v,"DualShockDpad",function(){return _.DualShockDpad}),f.d(v,"DualShockPad",function(){return _.DualShockPad}),f.d(v,"AxisDragGizmo",function(){return _.AxisDragGizmo}),f.d(v,"AxisScaleGizmo",function(){return _.AxisScaleGizmo}),f.d(v,"BoundingBoxGizmo",function(){return _.BoundingBoxGizmo}),f.d(v,"Gizmo",function(){return _.Gizmo}),f.d(v,"GizmoManager",function(){return _.GizmoManager}),f.d(v,"PlaneRotationGizmo",function(){return _.PlaneRotationGizmo}),f.d(v,"PositionGizmo",function(){return _.PositionGizmo}),f.d(v,"RotationGizmo",function(){return _.RotationGizmo}),f.d(v,"ScaleGizmo",function(){return _.ScaleGizmo}),f.d(v,"LightGizmo",function(){return _.LightGizmo}),f.d(v,"CameraGizmo",function(){return _.CameraGizmo}),f.d(v,"PlaneDragGizmo",function(){return _.PlaneDragGizmo}),f.d(v,"EnvironmentHelper",function(){return _.EnvironmentHelper}),f.d(v,"PhotoDome",function(){return _.PhotoDome}),f.d(v,"_forceSceneHelpersToBundle",function(){return _._forceSceneHelpersToBundle}),f.d(v,"VideoDome",function(){return _.VideoDome}),f.d(v,"EngineInstrumentation",function(){return _.EngineInstrumentation}),f.d(v,"SceneInstrumentation",function(){return _.SceneInstrumentation}),f.d(v,"_TimeToken",function(){return _._TimeToken}),f.d(v,"EffectLayer",function(){return _.EffectLayer}),f.d(v,"EffectLayerSceneComponent",function(){return _.EffectLayerSceneComponent}),f.d(v,"GlowLayer",function(){return _.GlowLayer}),f.d(v,"HighlightLayer",function(){return _.HighlightLayer}),f.d(v,"Layer",function(){return _.Layer}),f.d(v,"LayerSceneComponent",function(){return _.LayerSceneComponent}),f.d(v,"LensFlare",function(){return _.LensFlare}),f.d(v,"LensFlareSystem",function(){return _.LensFlareSystem}),f.d(v,"LensFlareSystemSceneComponent",function(){return _.LensFlareSystemSceneComponent}),f.d(v,"Light",function(){return _.Light}),f.d(v,"ShadowLight",function(){return _.ShadowLight}),f.d(v,"ShadowGenerator",function(){return _.ShadowGenerator}),f.d(v,"CascadedShadowGenerator",function(){return _.CascadedShadowGenerator}),f.d(v,"ShadowGeneratorSceneComponent",function(){return _.ShadowGeneratorSceneComponent}),f.d(v,"DirectionalLight",function(){return _.DirectionalLight}),f.d(v,"HemisphericLight",function(){return _.HemisphericLight}),f.d(v,"PointLight",function(){return _.PointLight}),f.d(v,"SpotLight",function(){return _.SpotLight}),f.d(v,"DefaultLoadingScreen",function(){return _.DefaultLoadingScreen}),f.d(v,"_BabylonLoaderRegistered",function(){return _._BabylonLoaderRegistered}),f.d(v,"BabylonFileLoaderConfiguration",function(){return _.BabylonFileLoaderConfiguration}),f.d(v,"SceneLoaderAnimationGroupLoadingMode",function(){return _.SceneLoaderAnimationGroupLoadingMode}),f.d(v,"SceneLoader",function(){return _.SceneLoader}),f.d(v,"SceneLoaderFlags",function(){return _.SceneLoaderFlags}
13246),f.d(v,"BackgroundMaterial",function(){return _.BackgroundMaterial}),f.d(v,"ColorCurves",function(){return _.ColorCurves}),f.d(v,"EffectFallbacks",function(){return _.EffectFallbacks}),f.d(v,"Effect",function(){return _.Effect}),f.d(v,"FresnelParameters",function(){return _.FresnelParameters}),f.d(v,"ImageProcessingConfigurationDefines",function(){return _.ImageProcessingConfigurationDefines}),f.d(v,"ImageProcessingConfiguration",function(){return _.ImageProcessingConfiguration}),f.d(v,"Material",function(){return _.Material}),f.d(v,"MaterialDefines",function(){return _.MaterialDefines}),f.d(v,"ThinMaterialHelper",function(){return _.ThinMaterialHelper}),f.d(v,"MaterialHelper",function(){return _.MaterialHelper}),f.d(v,"MultiMaterial",function(){return _.MultiMaterial}),f.d(v,"PBRMaterialDefines",function(){return _.PBRMaterialDefines}),f.d(v,"PBRBaseMaterial",function(){return _.PBRBaseMaterial}),f.d(v,"PBRBaseSimpleMaterial",function(){return _.PBRBaseSimpleMaterial}),f.d(v,"PBRMaterial",function(){return _.PBRMaterial}),f.d(v,"PBRMetallicRoughnessMaterial",function(){return _.PBRMetallicRoughnessMaterial}),f.d(v,"PBRSpecularGlossinessMaterial",function(){return _.PBRSpecularGlossinessMaterial}),f.d(v,"PushMaterial",function(){return _.PushMaterial}),f.d(v,"ShaderMaterial",function(){return _.ShaderMaterial}),f.d(v,"StandardMaterialDefines",function(){return _.StandardMaterialDefines}),f.d(v,"StandardMaterial",function(){return _.StandardMaterial}),f.d(v,"BaseTexture",function(){return _.BaseTexture}),f.d(v,"ColorGradingTexture",function(){return _.ColorGradingTexture}),f.d(v,"CubeTexture",function(){return _.CubeTexture}),f.d(v,"DynamicTexture",function(){return _.DynamicTexture}),f.d(v,"EquiRectangularCubeTexture",function(){return _.EquiRectangularCubeTexture}),f.d(v,"HDRFiltering",function(){return _.HDRFiltering}),f.d(v,"HDRCubeTexture",function(){return _.HDRCubeTexture}),f.d(v,"HtmlElementTexture",function(){return _.HtmlElementTexture}),f.d(v,"InternalTextureSource",function(){return _.InternalTextureSource}),f.d(v,"InternalTexture",function(){return _.InternalTexture}),f.d(v,"_DDSTextureLoader",function(){return _._DDSTextureLoader}),f.d(v,"_ENVTextureLoader",function(){return _._ENVTextureLoader}),f.d(v,"_KTXTextureLoader",function(){return _._KTXTextureLoader}),f.d(v,"_TGATextureLoader",function(){return _._TGATextureLoader}),f.d(v,"_BasisTextureLoader",function(){return _._BasisTextureLoader}),f.d(v,"MirrorTexture",function(){return _.MirrorTexture}),f.d(v,"MultiRenderTarget",function(){return _.MultiRenderTarget}),f.d(v,"TexturePacker",function(){return _.TexturePacker}),f.d(v,"TexturePackerFrame",function(){return _.TexturePackerFrame}),f.d(v,"CustomProceduralTexture",function(){return _.CustomProceduralTexture}),f.d(v,"NoiseProceduralTexture",function(){return _.NoiseProceduralTexture}),f.d(v,"ProceduralTexture",function(){return _.ProceduralTexture}),f.d(v,"ProceduralTextureSceneComponent",function(){return _.ProceduralTextureSceneComponent}),f.d(v,"RawCubeTexture",function(){return _.RawCubeTexture}),f.d(v,"RawTexture",function(){return _.RawTexture}),f.d(v,"RawTexture2DArray",function(){return _.RawTexture2DArray}),f.d(v,"RawTexture3D",function(){return _.RawTexture3D}),f.d(v,"RefractionTexture",function(){return _.RefractionTexture}),f.d(v,"RenderTargetTexture",function(){return _.RenderTargetTexture}),f.d(v,"Texture",function(){return _.Texture}),f.d(v,"VideoTexture",function(){return _.VideoTexture}),f.d(v,"UniformBuffer",function(){return _.UniformBuffer}),f.d(v,"MaterialFlags",function(){return _.MaterialFlags}),f.d(v,"NodeMaterialBlockTargets",function(){return _.NodeMaterialBlockTargets}),f.d(v,"NodeMaterialBlockConnectionPointTypes",function(){return _.NodeMaterialBlockConnectionPointTypes}),f.d(v,"NodeMaterialBlockConnectionPointMode",function(){return _.NodeMaterialBlockConnectionPointMode}),f.d(v,"NodeMaterialSystemValues",function(){return _.NodeMaterialSystemValues}),f.d(v,"NodeMaterialModes",function(){return _.NodeMaterialModes}),f.d(v,"NodeMaterialConnectionPointCompatibilityStates",function(){return _.NodeMaterialConnectionPointCompatibilityStates}),f.d(v,"NodeMaterialConnectionPointDirection",function(){return _.NodeMaterialConnectionPointDirection}),f.d(v,"NodeMaterialConnectionPoint",function(){return _.NodeMaterialConnectionPoint}),f.d(v,"NodeMaterialBlock",function(){return _.NodeMaterialBlock}),f.d(v,"NodeMaterialDefines",function(){return _.NodeMaterialDefines}),f.d(v,"NodeMaterial",function(){return _.NodeMaterial}),f.d(v,"VertexOutputBlock",function(){return _.VertexOutputBlock}),f.d(v,"BonesBlock",function(){return _.BonesBlock}),f.d(v,"InstancesBlock",function(){return _.InstancesBlock}
13246),f.d(v,"MorphTargetsBlock",function(){return _.MorphTargetsBlock}),f.d(v,"LightInformationBlock",function(){return _.LightInformationBlock}),f.d(v,"FragmentOutputBlock",function(){return _.FragmentOutputBlock}),f.d(v,"ImageProcessingBlock",function(){return _.ImageProcessingBlock}),f.d(v,"PerturbNormalBlock",function(){return _.PerturbNormalBlock}),f.d(v,"DiscardBlock",function(){return _.DiscardBlock}),f.d(v,"FrontFacingBlock",function(){return _.FrontFacingBlock}),f.d(v,"DerivativeBlock",function(){return _.DerivativeBlock}),f.d(v,"FragCoordBlock",function(){return _.FragCoordBlock}),f.d(v,"ScreenSizeBlock",function(){return _.ScreenSizeBlock}),f.d(v,"FogBlock",function(){return _.FogBlock}),f.d(v,"LightBlock",function(){return _.LightBlock}),f.d(v,"TextureBlock",function(){return _.TextureBlock}),f.d(v,"ReflectionTextureBlock",function(){return _.ReflectionTextureBlock}),f.d(v,"CurrentScreenBlock",function(){return _.CurrentScreenBlock}),f.d(v,"InputBlock",function(){return _.InputBlock}),f.d(v,"AnimatedInputBlockTypes",function(){return _.AnimatedInputBlockTypes}),f.d(v,"MultiplyBlock",function(){return _.MultiplyBlock}),f.d(v,"AddBlock",function(){return _.AddBlock}),f.d(v,"ScaleBlock",function(){return _.ScaleBlock}),f.d(v,"ClampBlock",function(){return _.ClampBlock}),f.d(v,"CrossBlock",function(){return _.CrossBlock}),f.d(v,"DotBlock",function(){return _.DotBlock}),f.d(v,"TransformBlock",function(){return _.TransformBlock}),f.d(v,"RemapBlock",function(){return _.RemapBlock}),f.d(v,"NormalizeBlock",function(){return _.NormalizeBlock}),f.d(v,"TrigonometryBlockOperations",function(){return _.TrigonometryBlockOperations}),f.d(v,"TrigonometryBlock",function(){return _.TrigonometryBlock}),f.d(v,"ColorMergerBlock",function(){return _.ColorMergerBlock}),f.d(v,"VectorMergerBlock",function(){return _.VectorMergerBlock}),f.d(v,"ColorSplitterBlock",function(){return _.ColorSplitterBlock}),f.d(v,"VectorSplitterBlock",function(){return _.VectorSplitterBlock}),f.d(v,"LerpBlock",function(){return _.LerpBlock}),f.d(v,"DivideBlock",function(){return _.DivideBlock}),f.d(v,"SubtractBlock",function(){return _.SubtractBlock}),f.d(v,"StepBlock",function(){return _.StepBlock}),f.d(v,"OneMinusBlock",function(){return _.OneMinusBlock}),f.d(v,"ViewDirectionBlock",function(){return _.ViewDirectionBlock}),f.d(v,"FresnelBlock",function(){return _.FresnelBlock}),f.d(v,"MaxBlock",function(){return _.MaxBlock}),f.d(v,"MinBlock",function(){return _.MinBlock}),f.d(v,"DistanceBlock",function(){return _.DistanceBlock}),f.d(v,"LengthBlock",function(){return _.LengthBlock}),f.d(v,"NegateBlock",function(){return _.NegateBlock}),f.d(v,"PowBlock",function(){return _.PowBlock}),f.d(v,"RandomNumberBlock",function(){return _.RandomNumberBlock}),f.d(v,"ArcTan2Block",function(){return _.ArcTan2Block}),f.d(v,"SmoothStepBlock",function(){return _.SmoothStepBlock}),f.d(v,"ReciprocalBlock",function(){return _.ReciprocalBlock}),f.d(v,"ReplaceColorBlock",function(){return _.ReplaceColorBlock}),f.d(v,"PosterizeBlock",function(){return _.PosterizeBlock}),f.d(v,"WaveBlockKind",function(){return _.WaveBlockKind}),f.d(v,"WaveBlock",function(){return _.WaveBlock}),f.d(v,"GradientBlockColorStep",function(){return _.GradientBlockColorStep}),f.d(v,"GradientBlock",function(){return _.GradientBlock}),f.d(v,"NLerpBlock",function(){return _.NLerpBlock}),f.d(v,"WorleyNoise3DBlock",function(){return _.WorleyNoise3DBlock}),f.d(v,"SimplexPerlin3DBlock",function(){return _.SimplexPerlin3DBlock}),f.d(v,"NormalBlendBlock",function(){return _.NormalBlendBlock}),f.d(v,"Rotate2dBlock",function(){return _.Rotate2dBlock}),f.d(v,"ReflectBlock",function(){return _.ReflectBlock}),f.d(v,"RefractBlock",function(){return _.RefractBlock}),f.d(v,"DesaturateBlock",function(){return _.DesaturateBlock}),f.d(v,"PBRMetallicRoughnessBlock",function(){return _.PBRMetallicRoughnessBlock}),f.d(v,"SheenBlock",function(){return _.SheenBlock}),f.d(v,"AnisotropyBlock",function(){return _.AnisotropyBlock}),f.d(v,"ReflectionBlock",function(){return _.ReflectionBlock}),f.d(v,"ClearCoatBlock",function(){return _.ClearCoatBlock}),f.d(v,"RefractionBlock",function(){return _.RefractionBlock}),f.d(v,"SubSurfaceBlock",function(){return _.SubSurfaceBlock}),f.d(v,"ParticleTextureBlock",function(){return _.ParticleTextureBlock}),f.d(v,"ParticleRampGradientBlock",function(){return _.ParticleRampGradientBlock}),f.d(v,"ParticleBlendMultiplyBlock",function(){return _.ParticleBlendMultiplyBlock}),f.d(v,"ModBlock",function(){return _.ModBlock}),f.d(v,"NodeMaterialOptimizer",function(){return _.NodeMaterialOptimizer}),f.d(v,"PropertyTypeForEdition",function(){return _.PropertyTypeForEdition}),f.d(v,"editableInPropertyPage",function(){return _.editableInPropertyPage}),f.d(v,"EffectRenderer",function(){return _.EffectRenderer}),f.d(v,"EffectWrapper",function(){return _.EffectWrapper}),f.d(v,"ShadowDepthWrapper",function(){return _.ShadowDepthWrapper}),f.d(v,"Scalar",function(){return _.Scalar}),f.d(v,"extractMinAndMaxIndexed",function(){return _.extractMinAndMaxIndexed}),f.d(v,"extractMinAndMax",function(){return _.extractMinAndMax}),f.d(v,"Space",function(){return _.Space}),f.d(v,"Axis",function(){return _.Axis}),f.d(v,"Coordinate",function(){return _.Coordinate}),f.d(v,"Color3",function(){return _.Color3}),f.d(v,"Color4",function(){return _.Color4}),f.d(v,"TmpColors",function(){return _.TmpColors}),f.d(v,"ToGammaSpace",function(){return _.ToGammaSpace}),f.d(v,"ToLinearSpace",function(){return _.ToLinearSpace}),f.d(v,"Epsilon",function(){return _.Epsilon}),f.d(v,"Frustum",function(){return _.Frustum}),f.d(v,"Orientation",function(){return _.Orientation}),f.d(v,"BezierCurve",function(){return _.BezierCurve}),f.d(v,"Angle",function(){return _.Angle}),f.d(v,"Arc2",function(){return _.Arc2}),f.d(v,"Path2",function(){return _.Path2}),f.d(v,"Path3D",function(){return _.Path3D}
13246),f.d(v,"Curve3",function(){return _.Curve3}),f.d(v,"Plane",function(){return _.Plane}),f.d(v,"Size",function(){return _.Size}),f.d(v,"Vector2",function(){return _.Vector2}),f.d(v,"Vector3",function(){return _.Vector3}),f.d(v,"Vector4",function(){return _.Vector4}),f.d(v,"Quaternion",function(){return _.Quaternion}),f.d(v,"Matrix",function(){return _.Matrix}),f.d(v,"TmpVectors",function(){return _.TmpVectors}),f.d(v,"PositionNormalVertex",function(){return _.PositionNormalVertex}),f.d(v,"PositionNormalTextureVertex",function(){return _.PositionNormalTextureVertex}),f.d(v,"Viewport",function(){return _.Viewport}),f.d(v,"SphericalHarmonics",function(){return _.SphericalHarmonics}),f.d(v,"SphericalPolynomial",function(){return _.SphericalPolynomial}),f.d(v,"AbstractMesh",function(){return _.AbstractMesh}),f.d(v,"Buffer",function(){return _.Buffer}),f.d(v,"VertexBuffer",function(){return _.VertexBuffer}),f.d(v,"DracoCompression",function(){return _.DracoCompression}),f.d(v,"CSG",function(){return _.CSG}),f.d(v,"Geometry",function(){return _.Geometry}),f.d(v,"GroundMesh",function(){return _.GroundMesh}),f.d(v,"TrailMesh",function(){return _.TrailMesh}),f.d(v,"InstancedMesh",function(){return _.InstancedMesh}),f.d(v,"LinesMesh",function(){return _.LinesMesh}),f.d(v,"InstancedLinesMesh",function(){return _.InstancedLinesMesh}),f.d(v,"_CreationDataStorage",function(){return _._CreationDataStorage}),f.d(v,"_InstancesBatch",function(){return _._InstancesBatch}),f.d(v,"Mesh",function(){return _.Mesh}),f.d(v,"VertexData",function(){return _.VertexData}),f.d(v,"MeshBuilder",function(){return _.MeshBuilder}),f.d(v,"SimplificationSettings",function(){return _.SimplificationSettings}),f.d(v,"SimplificationQueue",function(){return _.SimplificationQueue}),f.d(v,"SimplificationType",function(){return _.SimplificationType}),f.d(v,"QuadraticErrorSimplification",function(){return _.QuadraticErrorSimplification}),f.d(v,"SimplicationQueueSceneComponent",function(){return _.SimplicationQueueSceneComponent}),f.d(v,"Polygon",function(){return _.Polygon}),f.d(v,"PolygonMeshBuilder",function(){return _.PolygonMeshBuilder}),f.d(v,"SubMesh",function(){return _.SubMesh}),f.d(v,"MeshLODLevel",function(){return _.MeshLODLevel}),f.d(v,"TransformNode",function(){return _.TransformNode}),f.d(v,"BoxBuilder",function(){return _.BoxBuilder}),f.d(v,"TiledBoxBuilder",function(){return _.TiledBoxBuilder}),f.d(v,"DiscBuilder",function(){return _.DiscBuilder}),f.d(v,"RibbonBuilder",function(){return _.RibbonBuilder}),f.d(v,"SphereBuilder",function(){return _.SphereBuilder}),f.d(v,"HemisphereBuilder",function(){return _.HemisphereBuilder}),f.d(v,"CylinderBuilder",function(){return _.CylinderBuilder}),f.d(v,"TorusBuilder",function(){return _.TorusBuilder}),f.d(v,"TorusKnotBuilder",function(){return _.TorusKnotBuilder}),f.d(v,"LinesBuilder",function(){return _.LinesBuilder}),f.d(v,"PolygonBuilder",function(){return _.PolygonBuilder}),f.d(v,"ShapeBuilder",function(){return _.ShapeBuilder}),f.d(v,"LatheBuilder",function(){return _.LatheBuilder}),f.d(v,"PlaneBuilder",function(){return _.PlaneBuilder}),f.d(v,"TiledPlaneBuilder",function(){return _.TiledPlaneBuilder}),f.d(v,"GroundBuilder",function(){return _.GroundBuilder}),f.d(v,"TubeBuilder",function(){return _.TubeBuilder}),f.d(v,"PolyhedronBuilder",function(){return _.PolyhedronBuilder}),f.d(v,"IcoSphereBuilder",function(){return _.IcoSphereBuilder}),f.d(v,"DecalBuilder",function(){return _.DecalBuilder}),f.d(v,"CapsuleBuilder",function(){return _.CapsuleBuilder}),f.d(v,"DataBuffer",function(){return _.DataBuffer}),f.d(v,"WebGLDataBuffer",function(){return _.WebGLDataBuffer}),f.d(v,"MorphTarget",function(){return _.MorphTarget}),f.d(v,"MorphTargetManager",function(){return _.MorphTargetManager}),f.d(v,"RecastJSPlugin",function(){return _.RecastJSPlugin}),f.d(v,"RecastJSCrowd",function(){return _.RecastJSCrowd}),f.d(v,"Node",function(){return _.Node}),f.d(v,"Database",function(){return _.Database}),f.d(v,"BaseParticleSystem",function(){return _.BaseParticleSystem}),f.d(v,"BoxParticleEmitter",function(){return _.BoxParticleEmitter}),f.d(v,"ConeParticleEmitter",function(){return _.ConeParticleEmitter}),f.d(v,"CylinderParticleEmitter",function(){return _.CylinderParticleEmitter}),f.d(v,"CylinderDirectedParticleEmitter",function(){return _.CylinderDirectedParticleEmitter}),f.d(v,"HemisphericParticleEmitter",function(){return _.HemisphericParticleEmitter}),f.d(v,"PointParticleEmitter",function(){return _.PointParticleEmitter}),f.d(v,"SphereParticleEmitter",function(){return _.SphereParticleEmitter}),f.d(v,"SphereDirectedParticleEmitter",function(){return _.SphereDirectedParticleEmitter}),f.d(v,"CustomParticleEmitter",function(){return _.CustomParticleEmitter}),f.d(v,"MeshParticleEmitter",function(){return _.MeshParticleEmitter}),f.d(v,"GPUParticleSystem",function(){return _.GPUParticleSystem}),f.d(v,"Particle",function(){return _.Particle}),f.d(v,"ParticleHelper",function(){return _.ParticleHelper}),f.d(v,"ParticleSystem",function(){return _.ParticleSystem}),f.d(v,"ParticleSystemSet",function(){return _.ParticleSystemSet}),f.d(v,"SolidParticle",function(){return _.SolidParticle}),f.d(v,"ModelShape",function(){return _.ModelShape}),f.d(v,"DepthSortedParticle",function(){return _.DepthSortedParticle}),f.d(v,"SolidParticleVertex",function(){return _.SolidParticleVertex}),f.d(v,"SolidParticleSystem",function(){return _.SolidParticleSystem}),f.d(v,"CloudPoint",function(){return _.CloudPoint}),f.d(v,"PointsGroup",function(){return _.PointsGroup}),f.d(v,"PointColor",function(){return _.PointColor}),f.d(v,"PointsCloudSystem",function(){return _.PointsCloudSystem}),f.d(v,"SubEmitterType",function(){return _.SubEmitterType}),f.d(v,"SubEmitter",function(){return _.SubEmitter}),f.d(v,"PhysicsEngine",function(){return _.PhysicsEngine}),f.d(v,"PhysicsEngineSceneComponent",function(){return _.PhysicsEngineSceneComponent}),f.d(v,"PhysicsHelper",function(){return _.PhysicsHelper}),f.d(v,"PhysicsRadialExplosionEventOptions",function(){return _.PhysicsRadialExplosionEventOptions}),f.d(v,"PhysicsUpdraftEventOptions",function(){return _.PhysicsUpdraftEventOptions}),f.d(v,"PhysicsVortexEventOptions",function(){return _.PhysicsVortexEventOptions}),f.d(v,"PhysicsRadialImpulseFalloff",function(){return _.PhysicsRadialImpulseFalloff}),f.d(v,"PhysicsUpdraftMode",function(){return _.PhysicsUpdraftMode}),f.d(v,"PhysicsImpostor",function(){return _.PhysicsImpostor}),f.d(v,"PhysicsJoint",function(){return _.PhysicsJoint}),f.d(v,"DistanceJoint",function(){return _.DistanceJoint}),f.d(v,"MotorEnabledJoint",function(){return _.MotorEnabledJoint}),f.d(v,"HingeJoint",function(){return _.HingeJoint}),f.d(v,"Hinge2Joint",function(){return _.Hinge2Joint}),f.d(v,"CannonJSPlugin",function(){return _.CannonJSPlugin}),f.d(v,"AmmoJSPlugin",function(){return _.AmmoJSPlugin}),f.d(v,"OimoJSPlugin",function(){return _.OimoJSPlugin}),f.d(v,"AnaglyphPostProcess",function(){return _.AnaglyphPostProcess}),f.d(v,"BlackAndWhitePostProcess",function(){return _.BlackAndWhitePostProcess}),f.d(v,"BloomEffect",function(){return _.BloomEffect}),f.d(v,"BloomMergePostProcess",function(){return _.BloomMergePostProcess}),f.d(v,"BlurPostProcess",function(){return _.BlurPostProcess}),f.d(v,"ChromaticAberrationPostProcess",function(){return _.ChromaticAberrationPostProcess}
13246),f.d(v,"CircleOfConfusionPostProcess",function(){return _.CircleOfConfusionPostProcess}),f.d(v,"ColorCorrectionPostProcess",function(){return _.ColorCorrectionPostProcess}),f.d(v,"ConvolutionPostProcess",function(){return _.ConvolutionPostProcess}),f.d(v,"DepthOfFieldBlurPostProcess",function(){return _.DepthOfFieldBlurPostProcess}),f.d(v,"DepthOfFieldEffectBlurLevel",function(){return _.DepthOfFieldEffectBlurLevel}),f.d(v,"DepthOfFieldEffect",function(){return _.DepthOfFieldEffect}),f.d(v,"DepthOfFieldMergePostProcessOptions",function(){return _.DepthOfFieldMergePostProcessOptions}),f.d(v,"DepthOfFieldMergePostProcess",function(){return _.DepthOfFieldMergePostProcess}),f.d(v,"DisplayPassPostProcess",function(){return _.DisplayPassPostProcess}),f.d(v,"ExtractHighlightsPostProcess",function(){return _.ExtractHighlightsPostProcess}),f.d(v,"FilterPostProcess",function(){return _.FilterPostProcess}),f.d(v,"FxaaPostProcess",function(){return _.FxaaPostProcess}),f.d(v,"GrainPostProcess",function(){return _.GrainPostProcess}),f.d(v,"HighlightsPostProcess",function(){return _.HighlightsPostProcess}),f.d(v,"ImageProcessingPostProcess",function(){return _.ImageProcessingPostProcess}),f.d(v,"MotionBlurPostProcess",function(){return _.MotionBlurPostProcess}),f.d(v,"PassPostProcess",function(){return _.PassPostProcess}),f.d(v,"PassCubePostProcess",function(){return _.PassCubePostProcess}),f.d(v,"PostProcess",function(){return _.PostProcess}),f.d(v,"PostProcessManager",function(){return _.PostProcessManager}),f.d(v,"RefractionPostProcess",function(){return _.RefractionPostProcess}),f.d(v,"DefaultRenderingPipeline",function(){return _.DefaultRenderingPipeline}),f.d(v,"LensRenderingPipeline",function(){return _.LensRenderingPipeline}),f.d(v,"SSAO2RenderingPipeline",function(){return _.SSAO2RenderingPipeline}),f.d(v,"SSAORenderingPipeline",function(){return _.SSAORenderingPipeline}),f.d(v,"StandardRenderingPipeline",function(){return _.StandardRenderingPipeline}),f.d(v,"PostProcessRenderEffect",function(){return _.PostProcessRenderEffect}),f.d(v,"PostProcessRenderPipeline",function(){return _.PostProcessRenderPipeline}),f.d(v,"PostProcessRenderPipelineManager",function(){return _.PostProcessRenderPipelineManager}),f.d(v,"PostProcessRenderPipelineManagerSceneComponent",function(){return _.PostProcessRenderPipelineManagerSceneComponent}),f.d(v,"SharpenPostProcess",function(){return _.SharpenPostProcess}),f.d(v,"StereoscopicInterlacePostProcessI",function(){return _.StereoscopicInterlacePostProcessI}),f.d(v,"StereoscopicInterlacePostProcess",function(){return _.StereoscopicInterlacePostProcess}),f.d(v,"TonemappingOperator",function(){return _.TonemappingOperator}),f.d(v,"TonemapPostProcess",function(){return _.TonemapPostProcess}),f.d(v,"VolumetricLightScatteringPostProcess",function(){return _.VolumetricLightScatteringPostProcess}),f.d(v,"VRDistortionCorrectionPostProcess",function(){return _.VRDistortionCorrectionPostProcess}),f.d(v,"VRMultiviewToSingleviewPostProcess",function(){return _.VRMultiviewToSingleviewPostProcess}),f.d(v,"ScreenSpaceReflectionPostProcess",function(){return _.ScreenSpaceReflectionPostProcess}),f.d(v,"ScreenSpaceCurvaturePostProcess",function(){return _.ScreenSpaceCurvaturePostProcess}),f.d(v,"ReflectionProbe",function(){return _.ReflectionProbe}),f.d(v,"BoundingBoxRenderer",function(){return _.BoundingBoxRenderer}),f.d(v,"DepthRenderer",function(){return _.DepthRenderer}),f.d(v,"DepthRendererSceneComponent",function(){return _.DepthRendererSceneComponent}),f.d(v,"EdgesRenderer",function(){return _.EdgesRenderer}),f.d(v,"LineEdgesRenderer",function(){return _.LineEdgesRenderer}),f.d(v,"GeometryBufferRenderer",function(){return _.GeometryBufferRenderer}),f.d(v,"GeometryBufferRendererSceneComponent",function(){return _.GeometryBufferRendererSceneComponent}),f.d(v,"PrePassRenderer",function(){return _.PrePassRenderer}),f.d(v,"PrePassRendererSceneComponent",function(){return _.PrePassRendererSceneComponent}),f.d(v,"SubSurfaceSceneComponent",function(){return _.SubSurfaceSceneComponent}),f.d(v,"OutlineRenderer",function(){return _.OutlineRenderer}
13246),f.d(v,"RenderingGroup",function(){return _.RenderingGroup}),f.d(v,"RenderingGroupInfo",function(){return _.RenderingGroupInfo}),f.d(v,"RenderingManager",function(){return _.RenderingManager}),f.d(v,"UtilityLayerRenderer",function(){return _.UtilityLayerRenderer}),f.d(v,"Scene",function(){return _.Scene}),f.d(v,"SceneComponentConstants",function(){return _.SceneComponentConstants}),f.d(v,"Stage",function(){return _.Stage}),f.d(v,"Sprite",function(){return _.Sprite}),f.d(v,"SpriteManager",function(){return _.SpriteManager}),f.d(v,"SpriteMap",function(){return _.SpriteMap}),f.d(v,"SpritePackedManager",function(){return _.SpritePackedManager}),f.d(v,"SpriteSceneComponent",function(){return _.SpriteSceneComponent}),f.d(v,"AlphaState",function(){return _.AlphaState}),f.d(v,"DepthCullingState",function(){return _.DepthCullingState}),f.d(v,"StencilState",function(){return _.StencilState}),f.d(v,"AndOrNotEvaluator",function(){return _.AndOrNotEvaluator}),f.d(v,"AssetTaskState",function(){return _.AssetTaskState}),f.d(v,"AbstractAssetTask",function(){return _.AbstractAssetTask}),f.d(v,"AssetsProgressEvent",function(){return _.AssetsProgressEvent}),f.d(v,"ContainerAssetTask",function(){return _.ContainerAssetTask}),f.d(v,"MeshAssetTask",function(){return _.MeshAssetTask}),f.d(v,"TextFileAssetTask",function(){return _.TextFileAssetTask}),f.d(v,"BinaryFileAssetTask",function(){return _.BinaryFileAssetTask}),f.d(v,"ImageAssetTask",function(){return _.ImageAssetTask}),f.d(v,"TextureAssetTask",function(){return _.TextureAssetTask}),f.d(v,"CubeTextureAssetTask",function(){return _.CubeTextureAssetTask}),f.d(v,"HDRCubeTextureAssetTask",function(){return _.HDRCubeTextureAssetTask}),f.d(v,"EquiRectangularCubeTextureAssetTask",function(){return _.EquiRectangularCubeTextureAssetTask}),f.d(v,"AssetsManager",function(){return _.AssetsManager}),f.d(v,"BasisTranscodeConfiguration",function(){return _.BasisTranscodeConfiguration}),f.d(v,"BasisTools",function(){return _.BasisTools}),f.d(v,"DDSTools",function(){return _.DDSTools}),f.d(v,"expandToProperty",function(){return _.expandToProperty}),f.d(v,"serialize",function(){return _.serialize}),f.d(v,"serializeAsTexture",function(){return _.serializeAsTexture}),f.d(v,"serializeAsColor3",function(){return _.serializeAsColor3}),f.d(v,"serializeAsFresnelParameters",function(){return _.serializeAsFresnelParameters}),f.d(v,"serializeAsVector2",function(){return _.serializeAsVector2}),f.d(v,"serializeAsVector3",function(){return _.serializeAsVector3}),f.d(v,"serializeAsMeshReference",function(){return _.serializeAsMeshReference}),f.d(v,"serializeAsColorCurves",function(){return _.serializeAsColorCurves}),f.d(v,"serializeAsColor4",function(){return _.serializeAsColor4}),f.d(v,"serializeAsImageProcessingConfiguration",function(){return _.serializeAsImageProcessingConfiguration}),f.d(v,"serializeAsQuaternion",function(){return _.serializeAsQuaternion}),f.d(v,"serializeAsMatrix",function(){return _.serializeAsMatrix}),f.d(v,"serializeAsCameraReference",function(){return _.serializeAsCameraReference}),f.d(v,"SerializationHelper",function(){return _.SerializationHelper}),f.d(v,"Deferred",function(){return _.Deferred}),f.d(v,"EnvironmentTextureTools",function(){return _.EnvironmentTextureTools}),f.d(v,"MeshExploder",function(){return _.MeshExploder}),f.d(v,"FilesInput",function(){return _.FilesInput}),f.d(v,"CubeMapToSphericalPolynomialTools",function(){return _.CubeMapToSphericalPolynomialTools}),f.d(v,"HDRTools",function(){return _.HDRTools}),f.d(v,"PanoramaToCubeMapTools",function(){return _.PanoramaToCubeMapTools}),f.d(v,"KhronosTextureContainer",function(){return _.KhronosTextureContainer}),f.d(v,"EventState",function(){return _.EventState}),f.d(v,"Observer",function(){return _.Observer}),f.d(v,"MultiObserver",function(){return _.MultiObserver}),f.d(v,"Observable",function(){return _.Observable}),f.d(v,"PerformanceMonitor",function(){return _.PerformanceMonitor}),f.d(v,"RollingAverage",function(){return _.RollingAverage}),f.d(v,"PromisePolyfill",function(){return _.PromisePolyfill}),f.d(v,"SceneOptimization",function(){return _.SceneOptimization}),f.d(v,"TextureOptimization",function(){return _.TextureOptimization}),f.d(v,"HardwareScalingOptimization",function(){return _.HardwareScalingOptimization}),f.d(v,"ShadowsOptimization",function(){return _.ShadowsOptimization}),f.d(v,"PostProcessesOptimization",function(){return _.PostProcessesOptimization}),f.d(v,"LensFlaresOptimization",function(){return _.LensFlaresOptimization}),f.d(v,"CustomOptimization",function(){return _.CustomOptimization}),f.d(v,"ParticlesOptimization",function(){return _.ParticlesOptimization}
13246),f.d(v,"RenderTargetsOptimization",function(){return _.RenderTargetsOptimization}),f.d(v,"MergeMeshesOptimization",function(){return _.MergeMeshesOptimization}),f.d(v,"SceneOptimizerOptions",function(){return _.SceneOptimizerOptions}),f.d(v,"SceneOptimizer",function(){return _.SceneOptimizer}),f.d(v,"SceneSerializer",function(){return _.SceneSerializer}),f.d(v,"SmartArray",function(){return _.SmartArray}),f.d(v,"SmartArrayNoDuplicate",function(){return _.SmartArrayNoDuplicate}),f.d(v,"StringDictionary",function(){return _.StringDictionary}),f.d(v,"Tags",function(){return _.Tags}),f.d(v,"TextureTools",function(){return _.TextureTools}),f.d(v,"TGATools",function(){return _.TGATools}),f.d(v,"Tools",function(){return _.Tools}),f.d(v,"className",function(){return _.className}),f.d(v,"AsyncLoop",function(){return _.AsyncLoop}),f.d(v,"VideoRecorder",function(){return _.VideoRecorder}),f.d(v,"JoystickAxis",function(){return _.JoystickAxis}),f.d(v,"VirtualJoystick",function(){return _.VirtualJoystick}),f.d(v,"WorkerPool",function(){return _.WorkerPool}),f.d(v,"Logger",function(){return _.Logger}),f.d(v,"_TypeStore",function(){return _._TypeStore}),f.d(v,"FilesInputStore",function(){return _.FilesInputStore}),f.d(v,"DeepCopier",function(){return _.DeepCopier}),f.d(v,"PivotTools",function(){return _.PivotTools}),f.d(v,"PrecisionDate",function(){return _.PrecisionDate}),f.d(v,"ScreenshotTools",function(){return _.ScreenshotTools}),f.d(v,"WebRequest",function(){return _.WebRequest}),f.d(v,"InspectableType",function(){return _.InspectableType}),f.d(v,"BRDFTextureTools",function(){return _.BRDFTextureTools}),f.d(v,"RGBDTextureTools",function(){return _.RGBDTextureTools}),f.d(v,"ColorGradient",function(){return _.ColorGradient}),f.d(v,"Color3Gradient",function(){return _.Color3Gradient}),f.d(v,"FactorGradient",function(){return _.FactorGradient}),f.d(v,"GradientHelper",function(){return _.GradientHelper}),f.d(v,"PerfCounter",function(){return _.PerfCounter}),f.d(v,"RetryStrategy",function(){return _.RetryStrategy}),f.d(v,"CanvasGenerator",function(){return _.CanvasGenerator}),f.d(v,"LoadFileError",function(){return _.LoadFileError}),f.d(v,"RequestFileError",function(){return _.RequestFileError}),f.d(v,"ReadFileError",function(){return _.ReadFileError}),f.d(v,"FileTools",function(){return _.FileTools}),f.d(v,"StringTools",function(){return _.StringTools}),f.d(v,"DataReader",function(){return _.DataReader}),f.d(v,"MinMaxReducer",function(){return _.MinMaxReducer}),f.d(v,"DepthReducer",function(){return _.DepthReducer}),f.d(v,"DataStorage",function(){return _.DataStorage}),f.d(v,"SceneRecorder",function(){return _.SceneRecorder}),f.d(v,"KhronosTextureContainer2",function(){return _.KhronosTextureContainer2}),f.d(v,"Trajectory",function(){return _.Trajectory}),f.d(v,"TrajectoryClassifier",function(){return _.TrajectoryClassifier}),f.d(v,"TimerState",function(){return _.TimerState}),f.d(v,"setAndStartTimer",function(){return _.setAndStartTimer}),f.d(v,"AdvancedTimer",function(){return _.AdvancedTimer}),f.d(v,"CopyTools",function(){return _.CopyTools}),f.d(v,"WebXRCamera",function(){return _.WebXRCamera}),f.d(v,"WebXREnterExitUIButton",function(){return _.WebXREnterExitUIButton}),f.d(v,"WebXREnterExitUIOptions",function(){return _.WebXREnterExitUIOptions}),f.d(v,"WebXREnterExitUI",function(){return _.WebXREnterExitUI}),f.d(v,"WebXRExperienceHelper",function(){return _.WebXRExperienceHelper}),f.d(v,"WebXRInput",function(){return _.WebXRInput}),f.d(v,"WebXRInputSource",function(){return _.WebXRInputSource}),f.d(v,"WebXRManagedOutputCanvasOptions",function(){return _.WebXRManagedOutputCanvasOptions}),f.d(v,"WebXRManagedOutputCanvas",function(){return _.WebXRManagedOutputCanvas}),f.d(v,"WebXRState",function(){return _.WebXRState}),f.d(v,"WebXRTrackingState",function(){return _.WebXRTrackingState}),f.d(v,"WebXRSessionManager",function(){return _.WebXRSessionManager}),f.d(v,"WebXRDefaultExperienceOptions",function(){return _.WebXRDefaultExperienceOptions}),f.d(v,"WebXRDefaultExperience",function(){return _.WebXRDefaultExperience}),f.d(v,"WebXRFeatureName",function(){return _.WebXRFeatureName}),f.d(v,"WebXRFeaturesManager",function(){return _.WebXRFeaturesManager}),f.d(v,"WebXRAbstractFeature",function(){return _.WebXRAbstractFeature}),f.d(v,"WebXRHitTestLegacy",function(){return _.WebXRHitTestLegacy}),f.d(v,"WebXRAnchorSystem",function(){return _.WebXRAnchorSystem}),f.d(v,"WebXRPlaneDetector",function(){return _.WebXRPlaneDetector}
13246),f.d(v,"WebXRBackgroundRemover",function(){return _.WebXRBackgroundRemover}),f.d(v,"WebXRMotionControllerTeleportation",function(){return _.WebXRMotionControllerTeleportation}),f.d(v,"WebXRControllerPointerSelection",function(){return _.WebXRControllerPointerSelection}),f.d(v,"IWebXRControllerPhysicsOptions",function(){return _.IWebXRControllerPhysicsOptions}),f.d(v,"WebXRControllerPhysics",function(){return _.WebXRControllerPhysics}),f.d(v,"WebXRHitTest",function(){return _.WebXRHitTest}),f.d(v,"WebXRFeaturePointSystem",function(){return _.WebXRFeaturePointSystem}),f.d(v,"WebXRHand",function(){return _.WebXRHand}),f.d(v,"WebXRHandTracking",function(){return _.WebXRHandTracking}),f.d(v,"WebXRAbstractMotionController",function(){return _.WebXRAbstractMotionController}),f.d(v,"WebXRControllerComponent",function(){return _.WebXRControllerComponent}),f.d(v,"WebXRGenericTriggerMotionController",function(){return _.WebXRGenericTriggerMotionController}),f.d(v,"WebXRMicrosoftMixedRealityController",function(){return _.WebXRMicrosoftMixedRealityController}),f.d(v,"WebXRMotionControllerManager",function(){return _.WebXRMotionControllerManager}),f.d(v,"WebXROculusTouchMotionController",function(){return _.WebXROculusTouchMotionController}),f.d(v,"WebXRHTCViveMotionController",function(){return _.WebXRHTCViveMotionController}),f.d(v,"WebXRProfiledMotionController",function(){return _.WebXRProfiledMotionController});var u=B!==void 0?B:typeof window<"u"?window:void 0;if(u!==void 0){u.BABYLON=M,u.BABYLON=u.BABYLON||{};var M=u.BABYLON;M.Debug=M.Debug||{};var R=[];for(var C in x)M.Debug[C]=x[C],R.push(C);for(var C in _)M[C]=_[C]}var m={AxesViewer:x.AxesViewer,BoneAxesViewer:x.BoneAxesViewer,PhysicsViewer:x.PhysicsViewer,SkeletonViewer:x.SkeletonViewer}}.call(this,f(159))}])})})(kf);var _i=kf.exports;const Gf=(Qe,ke,Ae)=>{Qe.createDefaultCamera(!0,!0,!0);var v=Qe.activeCamera;ke[0]!==null&&(v.alpha=_i.Tools.ToRadians(ke[0])),ke[1]!==null&&(v.beta=_i.Tools.ToRadians(ke[1])),ke[2]!==null&&(v.radius=ke[2]),v.panningSensibility=0,v.attachControl(!1,!1,-1),v.pinchToPanMaxDistance=0,v.wheelPrecision=2500/Ae},zf=(Qe,ke,Ae,v,f,B,_)=>{if(ke&&!ke.isDisposed&&Ae&&(ke.dispose(),Ae.dispose()),Ae=new _i.Engine(Qe,!0),ke=new _i.Scene(Ae),ke.createDefaultCameraOrLight(),ke.clearColor=ke.clearColor=new _i.Color4(...f),Ae.runRenderLoop(()=>{ke.render()}),window.addEventListener("resize",()=>{Ae.resize()}),!v)return ke;let x;return x=v.url,_i.SceneLoader.ShowLoadingScreen=!1,_i.SceneLoader.Append(x,"",ke,()=>Gf(ke,B,_),void 0,void 0,"."+v.path.split(".")[1]),ke},jf=(Qe,ke,Ae)=>{Qe.removeCamera(Qe.activeCamera),Gf(Qe,ke,Ae)};var Hf={exports:{}};(function(Qe,ke){(function(Ae,v){Qe.exports=v(_i)})(typeof self<"u"?self:typeof Qr<"u"?Qr:Qr,function(Ae){return function(v){var f={};function B(_){if(f[_])return f[_].exports;var x=f[_]={i:_,l:!1,exports:{}};return v[_].call(x.exports,x,x.exports,B),x.l=!0,x.exports}return B.m=v,B.c=f,B.d=function(_,x,u){B.o(_,x)||Object.defineProperty(_,x,{enumerable:!0,get:u})},B.r=function(_){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(_,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(_,"__esModule",{value:!0})},B.t=function(_,x){if(1&x&&(_=B(_)),8&x||4&x&&typeof _=="object"&&_&&_.__esModule)return _;var u=Object.create(null);if(B.r(u),Object.defineProperty(u,"default",{enumerable:!0,value:_}),2&x&&typeof _!="string")for(var M in _)B.d(u,M,function(R){return _[R]}.bind(null,M));return u},B.n=function(_){var x=_&&_.__esModule?function(){return _.default}:function(){return _};return B.d(x,"a",x),x},B.o=function(_,x){return Object.prototype.hasOwnProperty.call(_,x)},B.p="",B(B.s=20)}([function(v,f){v.exports=Ae},function(v,f,B){B.d(f,"a",function(){return u}),B.d(f,"b",function(){return M});var _=B(0),x=B(2),u=function(){function R(){}return R.Get=function(C,m,c){if(!m||c==null||!m[c])throw new Error(C+": Failed to find index ("+c+")");return m[c]},R.Assign=function(C){if(C)for(var m=0;m<C.length;m++)C[m].index=m},R}(),M=function(){function R(C){this._completePromises=new Array,this._forAssetContainer=!1,this._babylonLights=[],this._disableInstancedMesh=0,this._disposed=!1,this._state=null,this._extensions=new Array,this._defaultBabylonMaterialData={},this._parent=C}return R.RegisterExtension=function(C,m){R.UnregisterExtension(C)&&_.Logger.Warn("Extension with the name '"+C+"' already exists"),R._RegisteredExtensions[C]={factory:m}},R.UnregisterExtension=function(C){return!!R._RegisteredExtensions[C]&&(delete R._RegisteredExtensions[C],!0)},Object.defineProperty(R.prototype,"state",{get:function(){return this._state}
13246,enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"gltf",{get:function(){return this._gltf},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"bin",{get:function(){return this._bin},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"parent",{get:function(){return this._parent},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"babylonScene",{get:function(){return this._babylonScene},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"rootBabylonMesh",{get:function(){return this._rootBabylonMesh},enumerable:!1,configurable:!0}),R.prototype.dispose=function(){if(!this._disposed){for(var C in this._disposed=!0,this._completePromises.length=0,this._extensions){var m=this._extensions[C];m.dispose&&m.dispose(),delete this._extensions[C]}this._gltf=null,this._babylonScene=null,this._rootBabylonMesh=null,this._parent.dispose()}},R.prototype.importMeshAsync=function(C,m,c,E,A,S,g){var l=this;return Promise.resolve().then(function(){l._babylonScene=m,l._rootUrl=A,l._fileName=g||"scene",l._forAssetContainer=c,l._loadData(E);var h=null;if(C){var b={};if(l._gltf.nodes)for(var T=0,D=l._gltf.nodes;T<D.length;T++){var w=D[T];w.name&&(b[w.name]=w.index)}h=(C instanceof Array?C:[C]).map(function(N){var I=b[N];if(I===void 0)throw new Error("Failed to find node '"+N+"'");return I})}return l._loadAsync(h,function(){return{meshes:l._getMeshes(),particleSystems:[],skeletons:l._getSkeletons(),animationGroups:l._getAnimationGroups(),lights:l._babylonLights,transformNodes:l._getTransformNodes(),geometries:l._getGeometries()}})})},R.prototype.loadAsync=function(C,m,c,E,A){var S=this;return Promise.resolve().then(function(){return S._babylonScene=C,S._rootUrl=c,S._fileName=A||"scene",S._loadData(m),S._loadAsync(null,function(){})})},R.prototype._loadAsync=function(C,m){var c=this;return Promise.resolve().then(function(){c._uniqueRootUrl=c._rootUrl.indexOf("file:")===-1&&c._fileName?c._rootUrl:""+c._rootUrl+Date.now()+"/",c._loadExtensions(),c._checkExtensions();var E=x.GLTFLoaderState[x.GLTFLoaderState.LOADING]+" => "+x.GLTFLoaderState[x.GLTFLoaderState.READY],A=x.GLTFLoaderState[x.GLTFLoaderState.LOADING]+" => "+x.GLTFLoaderState[x.GLTFLoaderState.COMPLETE];c._parent._startPerformanceCounter(E),c._parent._startPerformanceCounter(A),c._setState(x.GLTFLoaderState.LOADING),c._extensionsOnLoading();var S=new Array,g=c._babylonScene.blockMaterialDirtyMechanism;if(c._babylonScene.blockMaterialDirtyMechanism=!0,C)S.push(c.loadSceneAsync("/nodes",{nodes:C,index:-1}));else if(c._gltf.scene!=null||c._gltf.scenes&&c._gltf.scenes[0]){var l=u.Get("/scene",c._gltf.scenes,c._gltf.scene||0);S.push(c.loadSceneAsync("/scenes/"+l.index,l))}if(c.parent.loadAllMaterials&&c._gltf.materials)for(var h=0;h<c._gltf.materials.length;++h){var b=c._gltf.materials[h],T="/materials/"+h,D=_.Material.TriangleFillMode;S.push(c._loadMaterialAsync(T,b,null,D,function(N){}))}c._babylonScene.blockMaterialDirtyMechanism=g,c._parent.compileMaterials&&S.push(c._compileMaterialsAsync()),c._parent.compileShadowGenerators&&S.push(c._compileShadowGeneratorsAsync());var w=Promise.all(S).then(function(){return c._rootBabylonMesh&&c._rootBabylonMesh.setEnabled(!0),c._extensionsOnReady(),c._setState(x.GLTFLoaderState.READY),c._startAnimations(),m()});return w.then(function(){c._parent._endPerformanceCounter(E),_.Tools.SetImmediate(function(){c._disposed||Promise.all(c._completePromises).then(function(){c._parent._endPerformanceCounter(A),c._setState(x.GLTFLoaderState.COMPLETE),c._parent.onCompleteObservable.notifyObservers(void 0),c._parent.onCompleteObservable.clear(),c.dispose()},function(N){c._parent.onErrorObservable.notifyObservers(N),c._parent.onErrorObservable.clear(),c.dispose()})})}),w}).catch(function(E){throw c._disposed||(c._parent.onErrorObservable.notifyObservers(E),c._parent.onErrorObservable.clear(),c.dispose()),E})},R.prototype._loadData=function(C){if(this._gltf=C.json,this._setupData(),C.bin){var m=this._gltf.buffers;if(m&&m[0]&&!m[0].uri){var c=m[0];(c.byteLength<C.bin.byteLength-3||c.byteLength>C.bin.byteLength)&&_.Logger.Warn("Binary buffer length ("+c.byteLength+") from JSON does not match chunk length ("+C.bin.byteLength+")"),this._bin=C.bin}else _.Logger.Warn("Unexpected BIN chunk")}},R.prototype._setupData=function(){if(u.Assign(this._gltf.accessors),u.Assign(this._gltf.animations),u.Assign(this._gltf.buffers),u.Assign(this._gltf.bufferViews),u.Assign(this._gltf.cameras),u.Assign(this._gltf.images),u.Assign(this._gltf.materials),u.Assign(this._gltf.meshes),u.Assign(this._gltf.nodes),u.Assign(this._gltf.samplers),u.Assign(this._gltf.scenes),u.Assign(this._gltf.skins),u.Assign(this._gltf.textures),this._gltf.nodes){for(var C={},m=0,c=this._gltf.nodes;m<c.length;m++)if((h=c[m]).children)for(var E=0,A=h.children;E<A.length;E++)C[A[E]]=h.index;for(var S=this._createRootNode(),g=0,l=this._gltf.nodes;g<l.length;g++){var h,b=C[(h=l[g]).index];h.parent=b===void 0?S:this._gltf.nodes[b]}}},R.prototype._loadExtensions=function(){for(var C in R._RegisteredExtensions){var m=R._RegisteredExtensions[C].factory(this);m.name!==C&&_.Logger.Warn("The name of the glTF loader extension instance does not match the registered name: "+m.name+" !== "+C),this._extensions.push(m),this._parent.onExtensionLoadedObservable.notifyObservers(m)}this._extensions.sort(function(c,E){return(c.order||Number.MAX_VALUE)-(E.order||Number.MAX_VALUE)}),this._parent.onExtensionLoadedObservable.clear()},R.prototype._checkExtensions=function(){if(this._gltf.extensionsRequired)for(var C=function(A){if(!m._extensions.some(function(S){return S.name===A&&S.enabled}))throw new Error("Require extension "+A+" is not available")},m=this,c=0,E=this._gltf.extensionsRequired;c<E.length;c++)C(E[c])},R.prototype._setState=function(C){this._state=C,this.log(x.GLTFLoaderState[this._state])},R.prototype._createRootNode=function(){this._babylonScene._blockEntityCollection=this._forAssetContainer,this._rootBabylonMesh=new _.Mesh("__root__",this._babylonScene),this._babylonScene._blockEntityCollection=!1,this._rootBabylonMesh.setEnabled(!1);var C={_babylonTransformNode:this._rootBabylonMesh,index:-1};switch(this._parent.coordinateSystemMode){case x.GLTFLoaderCoordinateSystemMode.AUTO:this._babylonScene.useRightHandedSystem||(C.rotation=[0,1,0,0],C.scale=[1,1,-1],R._Lo
13246adTransform(C,this._rootBabylonMesh));break;case x.GLTFLoaderCoordinateSystemMode.FORCE_RIGHT_HANDED:this._babylonScene.useRightHandedSystem=!0;break;default:throw new Error("Invalid coordinate system mode ("+this._parent.coordinateSystemMode+")")}return this._parent.onMeshLoadedObservable.notifyObservers(this._rootBabylonMesh),C},R.prototype.loadSceneAsync=function(C,m){var c=this,E=this._extensionsLoadSceneAsync(C,m);if(E)return E;var A=new Array;if(this.logOpen(C+" "+(m.name||"")),m.nodes)for(var S=0,g=m.nodes;S<g.length;S++){var l=g[S],h=u.Get(C+"/nodes/"+l,this._gltf.nodes,l);A.push(this.loadNodeAsync("/nodes/"+h.index,h,function(N){N.parent=c._rootBabylonMesh}))}if(this._gltf.nodes){for(var b=0,T=this._gltf.nodes;b<T.length;b++)if((h=T[b])._babylonTransformNode&&h._babylonBones)for(var D=0,w=h._babylonBones;D<w.length;D++)w[D].linkTransformNode(h._babylonTransformNode)}return A.push(this._loadAnimationsAsync()),this.logClose(),Promise.all(A).then(function(){})},R.prototype._forEachPrimitive=function(C,m){if(C._primitiveBabylonMeshes)for(var c=0,E=C._primitiveBabylonMeshes;c<E.length;c++)m(E[c])},R.prototype._getGeometries=function(){var C=new Array,m=this._gltf.nodes;if(m)for(var c=0,E=m;c<E.length;c++){var A=E[c];this._forEachPrimitive(A,function(S){var g=S.geometry;g&&C.indexOf(g)===-1&&C.push(g)})}return C},R.prototype._getMeshes=function(){var C=new Array;C.push(this._rootBabylonMesh);var m=this._gltf.nodes;if(m)for(var c=0,E=m;c<E.length;c++){var A=E[c];this._forEachPrimitive(A,function(S){C.push(S)})}return C},R.prototype._getTransformNodes=function(){var C=new Array,m=this._gltf.nodes;if(m)for(var c=0,E=m;c<E.length;c++){var A=E[c];A._babylonTransformNode&&A._babylonTransformNode.getClassName()==="TransformNode"&&C.push(A._babylonTransformNode)}return C},R.prototype._getSkeletons=function(){var C=new Array,m=this._gltf.skins;if(m)for(var c=0,E=m;c<E.length;c++){var A=E[c];A._data&&C.push(A._data.babylonSkeleton)}return C},R.prototype._getAnimationGroups=function(){var C=new Array,m=this._gltf.animations;if(m)for(var c=0,E=m;c<E.length;c++){var A=E[c];A._babylonAnimationGroup&&C.push(A._babylonAnimationGroup)}return C},R.prototype._startAnimations=function(){switch(this._parent.animationStartMode){case x.GLTFLoaderAnimationStartMode.NONE:break;case x.GLTFLoaderAnimationStartMode.FIRST:(C=this._getAnimationGroups()).length!==0&&C[0].start(!0);break;case x.GLTFLoaderAnimationStartMode.ALL:for(var C,m=0,c=C=this._getAnimationGroups();m<c.length;m++)c[m].start(!0);break;default:return void _.Logger.Error("Invalid animation start mode ("+this._parent.animationStartMode+")")}},R.prototype.loadNodeAsync=function(C,m,c){var E=this;c===void 0&&(c=function(){});var A=this._extensionsLoadNodeAsync(C,m,c);if(A)return A;if(m._babylonTransformNode)throw new Error(C+": Invalid recursive node hierarchy");var S=new Array;this.logOpen(C+" "+(m.name||""));var g=function(b){if(R.AddPointerMetadata(b,C),R._LoadTransform(m,b),m.camera!=null){var T=u.Get(C+"/camera",E._gltf.cameras,m.camera);S.push(E.loadCameraAsync("/cameras/"+T.index,T,function(V){V.parent=b}))}if(m.children)for(var D=0,w=m.children;D<w.length;D++){var N=w[D],I=u.Get(C+"/children/"+N,E._gltf.nodes,N);S.push(E.loadNodeAsync("/nodes/"+I.index,I,function(V){V.parent=b}))}c(b)};if(m.mesh==null){var l=m.name||"node"+m.index;this._babylonScene._blockEntityCollection=this._forAssetContainer,m._babylonTransformNode=new _.TransformNode(l,this._babylonScene),this._babylonScene._blockEntityCollection=!1,g(m._babylonTransformNode)}else{var h=u.Get(C+"/mesh",this._gltf.meshes,m.mesh);S.push(this._loadMeshAsync("/meshes/"+h.index,m,h,g))}return this.logClose(),Promise.all(S).then(function(){return E._forEachPrimitive(m,function(b){b.geometry&&b.geometry.useBoundingInfoFromGeometry?b._updateBoundingInfo():b.refreshBoundingInfo(!0)}),m._babylonTransformNode})},R.prototype._loadMeshAsync=function(C,m,c,E){var A=c.primitives;if(!A||!A.length)throw new Error(C+": Primitives are missing");A[0].index==null&&u.Assign(A);var S=new Array;this.logOpen(C+" "+(c.name||""));var g=m.name||"node"+m.index;if(A.length===1){var l=c.primitives[0];S.push(this._loadMeshPrimitiveAsync(C+"/primitives/"+l.index,g,m,c,l,function(D){m._babylonTransformNode=D,m._primitiveBabylonMeshes=[D]}))}else{this._babylonScene._blockEntityCollection=this._forAssetContainer,m._babylonTransformNode=new _.TransformNode(g,this._babylonScene),this._babylonScene._blockEntityCollection=!1,m._primitiveBabylonMeshes=[];for(var h=0,b=A;h<b.length;h++)l=b[h],S.push(this._loadMeshPrimitiveAsync(C+"/primitives/"+l.index,g+"_primitive"+l.index,m,c,l,function(D){D.parent=m._babylonTransformNode,m._primitiveBabylonMeshes.push(D)}))}if(m.skin!=null){var T=u.Get(C+"/skin",this._gltf.skins,m.skin);S.push(this._loadSkinAsync("/skins/"+T.index,m,T))}return E(m._babylonTransformNode),this.logClose(),Promise.all(S).then(function(){return m._babylonTransformNode})},R.prototype._loadMeshPrimitiveAsync=function(C,m,c,E,A,S){var g=this,l=this._extensionsLoadMeshPrimitiveAsync(C,m,c,E,A,S);if(l)return l;this.logOpen(""+C);var h,b,T=this._disableInstancedMesh===0&&this._parent.createInstances&&c.skin==null&&!E.primitives[0].targets;
13246if(T&&A._instanceData)h=A._instanceData.babylonSourceMesh.createInstance(m),b=A._instanceData.promise;else{var D=new Array;this._babylonScene._blockEntityCollection=this._forAssetContainer;var w=new _.Mesh(m,this._babylonScene);this._babylonScene._blockEntityCollection=!1,w.overrideMaterialSideOrientation=this._babylonScene.useRightHandedSystem?_.Material.CounterClockWiseSideOrientation:_.Material.ClockWiseSideOrientation,this._createMorphTargets(C,c,E,A,w),D.push(this._loadVertexDataAsync(C,A,w).then(function(W){return g._loadMorphTargetsAsync(C,A,w,W).then(function(){g._babylonScene._blockEntityCollection=g._forAssetContainer,W.applyToMesh(w),g._babylonScene._blockEntityCollection=!1})}));var N=R._GetDrawMode(C,A.mode);if(A.material==null){var I=this._defaultBabylonMaterialData[N];I||(I=this._createDefaultMaterial("__GLTFLoader._default",N),this._parent.onMaterialLoadedObservable.notifyObservers(I),this._defaultBabylonMaterialData[N]=I),w.material=I}else{var V=u.Get(C+"/material",this._gltf.materials,A.material);D.push(this._loadMaterialAsync("/materials/"+V.index,V,w,N,function(W){w.material=W}))}b=Promise.all(D),T&&(A._instanceData={babylonSourceMesh:w,promise:b}),h=w}return R.AddPointerMetadata(h,C),this._parent.onMeshLoadedObservable.notifyObservers(h),S(h),this.logClose(),b.then(function(){return h})},R.prototype._loadVertexDataAsync=function(C,m,c){var E=this,A=this._extensionsLoadVertexDataAsync(C,m,c);if(A)return A;var S=m.attributes;if(!S)throw new Error(C+": Attributes are missing");var g=new Array,l=new _.Geometry(c.name,this._babylonScene);if(m.indices==null)c.isUnIndexed=!0;else{var h=u.Get(C+"/indices",this._gltf.accessors,m.indices);g.push(this._loadIndicesAccessorAsync("/accessors/"+h.index,h).then(function(T){l.setIndices(T)}))}var b=function(T,D,w){if(S[T]!=null){c._delayInfo=c._delayInfo||[],c._delayInfo.indexOf(D)===-1&&c._delayInfo.push(D);var N=u.Get(C+"/attributes/"+T,E._gltf.accessors,S[T]);g.push(E._loadVertexAccessorAsync("/accessors/"+N.index,N,D).then(function(I){if(I.getKind()===_.VertexBuffer.PositionKind&&!E.parent.alwaysComputeBoundingBox&&!c.skeleton){var V=N.min,W=N.max;if(V!==void 0&&W!==void 0){var j=_.TmpVectors.Vector3[0],ne=_.TmpVectors.Vector3[1];j.copyFromFloats.apply(j,V),ne.copyFromFloats.apply(ne,W),l._boundingInfo=new _.BoundingInfo(j,ne),l.useBoundingInfoFromGeometry=!0}}l.setVerticesBuffer(I,N.count)})),D==_.VertexBuffer.MatricesIndicesExtraKind&&(c.numBoneInfluencers=8),w&&w(N)}};return b("POSITION",_.VertexBuffer.PositionKind),b("NORMAL",_.VertexBuffer.NormalKind),b("TANGENT",_.VertexBuffer.TangentKind),b("TEXCOORD_0",_.VertexBuffer.UVKind),b("TEXCOORD_1",_.VertexBuffer.UV2Kind),b("JOINTS_0",_.VertexBuffer.MatricesIndicesKind),b("WEIGHTS_0",_.VertexBuffer.MatricesWeightsKind),b("JOINTS_1",_.VertexBuffer.MatricesIndicesExtraKind),b("WEIGHTS_1",_.VertexBuffer.MatricesWeightsExtraKind),b("COLOR_0",_.VertexBuffer.ColorKind,function(T){T.type==="VEC4"&&(c.hasVertexAlpha=!0)}),Promise.all(g).then(function(){return l})},R.prototype._createMorphTargets=function(C,m,c,E,A){if(E.targets){if(m._numMorphTargets==null)m._numMorphTargets=E.targets.length;else if(E.targets.length!==m._numMorphTargets)throw new Error(C+": Primitives do not have the same number of targets");var S=c.extras?c.extras.targetNames:null;A.morphTargetManager=new _.MorphTargetManager(A.getScene());for(var g=0;g<E.targets.length;g++){var l=m.weights?m.weights[g]:c.weights?c.weights[g]:0,h=S?S[g]:"morphTarget"+g;A.morphTargetManager.addTarget(new _.MorphTarget(h,l,A.getScene()))}}},R.prototype._loadMorphTargetsAsync=function(C,m,c,E){if(!m.targets)return Promise.resolve();for(var A=new Array,S=c.morphTargetManager,g=0;g<S.numTargets;g++){var l=S.getTarget(g);A.push(this._loadMorphTargetVertexDataAsync(C+"/targets/"+g,E,m.targets[g],l))}return Promise.all(A).then(function(){})},R.prototype._loadMorphTargetVertexDataAsync=function(C,m,c,E){var A=this,S=new Array,g=function(l,h,b){if(c[l]!=null){var T=m.getVertexBuffer(h);if(T){var D=u.Get(C+"/"+l,A._gltf.accessors,c[l]);S.push(A._loadFloatAccessorAsync("/accessors/"+D.index,D).then(function(w){b(T,w)}))}}};return g("POSITION",_.VertexBuffer.PositionKind,function(l,h){var b=new Float32Array(h.length);l.forEach(h.length,function(T,D){b[D]=h[D]+T}),E.setPositions(b)}),g("NORMAL",_.VertexBuffer.NormalKind,function(l,h){var b=new Float32Array(h.length);l.forEach(b.length,function(T,D){b[D]=h[D]+T}),E.setNormals(b)}),g("TANGENT",_.VertexBuffer.TangentKind,function(l,h){var b=new Float32Array(h.length/3*4),T=0;l.forEach(h.length/3*4,function(D,w){(w+1)%4!=0&&(b[T]=h[T]+D,T++)}),E.setTangents(b)}),Promise.all(S).then(function(){})},R._LoadTransform=function(C,m){if(C.skin==null){var c=_.Vector3.Zero(),E=_.Quaternion.Identity(),A=_.Vector3.One();
13246C.matrix?_.Matrix.FromArray(C.matrix).decompose(A,E,c):(C.translation&&(c=_.Vector3.FromArray(C.translation)),C.rotation&&(E=_.Quaternion.FromArray(C.rotation)),C.scale&&(A=_.Vector3.FromArray(C.scale))),m.position=c,m.rotationQuaternion=E,m.scaling=A}},R.prototype._loadSkinAsync=function(C,m,c){var E=this,A=this._extensionsLoadSkinAsync(C,m,c);if(A)return A;var S=function(b){E._forEachPrimitive(m,function(T){T.skeleton=b})};if(c._data)return S(c._data.babylonSkeleton),c._data.promise;var g="skeleton"+c.index;this._babylonScene._blockEntityCollection=this._forAssetContainer;var l=new _.Skeleton(c.name||g,g,this._babylonScene);this._babylonScene._blockEntityCollection=!1,l.overrideMesh=this._rootBabylonMesh,this._loadBones(C,c,l),S(l);var h=this._loadSkinInverseBindMatricesDataAsync(C,c).then(function(b){E._updateBoneMatrices(l,b)});return c._data={babylonSkeleton:l,promise:h},h},R.prototype._loadBones=function(C,m,c){for(var E={},A=0,S=m.joints;A<S.length;A++){var g=S[A],l=u.Get(C+"/joints/"+g,this._gltf.nodes,g);this._loadBone(l,m,c,E)}},R.prototype._loadBone=function(C,m,c,E){var A=E[C.index];if(A)return A;var S=null;C.parent&&C.parent._babylonTransformNode!==this._rootBabylonMesh&&(S=this._loadBone(C.parent,m,c,E));var g=m.joints.indexOf(C.index);return A=new _.Bone(C.name||"joint"+C.index,c,S,this._getNodeMatrix(C),null,null,g),E[C.index]=A,C._babylonBones=C._babylonBones||[],C._babylonBones.push(A),A},R.prototype._loadSkinInverseBindMatricesDataAsync=function(C,m){if(m.inverseBindMatrices==null)return Promise.resolve(null);var c=u.Get(C+"/inverseBindMatrices",this._gltf.accessors,m.inverseBindMatrices);return this._loadFloatAccessorAsync("/accessors/"+c.index,c)},R.prototype._updateBoneMatrices=function(C,m){for(var c=0,E=C.bones;c<E.length;c++){var A=E[c],S=_.Matrix.Identity(),g=A._index;m&&g!==-1&&(_.Matrix.FromArrayToRef(m,16*g,S),S.invertToRef(S));var l=A.getParent();l&&S.multiplyToRef(l.getInvertedAbsoluteTransform(),S),A.setBindPose(S),A.updateMatrix(S,!1,!1),A._updateDifferenceMatrix(void 0,!1)}},R.prototype._getNodeMatrix=function(C){return C.matrix?_.Matrix.FromArray(C.matrix):_.Matrix.Compose(C.scale?_.Vector3.FromArray(C.scale):_.Vector3.One(),C.rotation?_.Quaternion.FromArray(C.rotation):_.Quaternion.Identity(),C.translation?_.Vector3.FromArray(C.translation):_.Vector3.Zero())},R.prototype.loadCameraAsync=function(C,m,c){c===void 0&&(c=function(){});var E=this._extensionsLoadCameraAsync(C,m,c);if(E)return E;var A=new Array;this.logOpen(C+" "+(m.name||"")),this._babylonScene._blockEntityCollection=this._forAssetContainer;var S=new _.FreeCamera(m.name||"camera"+m.index,_.Vector3.Zero(),this._babylonScene,!1);switch(this._babylonScene._blockEntityCollection=!1,S.ignoreParentScaling=!0,S.rotation=new _.Vector3(0,Math.PI,0),m.type){case"perspective":var g=m.perspective;if(!g)throw new Error(C+": Camera perspective properties are missing");S.fov=g.yfov,S.minZ=g.znear,S.maxZ=g.zfar||Number.MAX_VALUE;break;case"orthographic":if(!m.orthographic)throw new Error(C+": Camera orthographic properties are missing");S.mode=_.Camera.ORTHOGRAPHIC_CAMERA,S.orthoLeft=-m.orthographic.xmag,S.orthoRight=m.orthographic.xmag,S.orthoBottom=-m.orthographic.ymag,S.orthoTop=m.orthographic.ymag,S.minZ=m.orthographic.znear,S.maxZ=m.orthographic.zfar;break;default:throw new Error(C+": Invalid camera type ("+m.type+")")}return R.AddPointerMetadata(S,C),this._parent.onCameraLoadedObservable.notifyObservers(S),c(S),this.logClose(),Promise.all(A).then(function(){return S})},R.prototype._loadAnimationsAsync=function(){var C=this._gltf.animations;if(!C)return Promise.resolve();for(var m=new Array,c=0;c<C.length;c++){var E=C[c];m.push(this.loadAnimationAsync("/animations/"+E.index,E))}return Promise.all(m).then(function(){})},R.prototype.loadAnimationAsync=function(C,m){var c=this._extensionsLoadAnimationAsync(C,m);if(c)return c;this._babylonScene._blockEntityCollection=this._forAssetContainer;var E=new _.AnimationGroup(m.name||"animation"+m.index,this._babylonScene);this._babylonScene._blockEntityCollection=!1,m._babylonAnimationGroup=E;var A=new Array;u.Assign(m.channels),u.Assign(m.samplers);for(var S=0,g=m.channels;S<g.length;S++){var l=g[S];A.push(this._loadAnimationChannelAsync(C+"/channels/"+l.index,C,m,l,E))}return Promise.all(A).then(function(){return E.normalize(0),E})},R.prototype._loadAnimationChannelAsync=function(C,m,c,E,A,S){var g=this;if(S===void 0&&(S=null),E.target.node==null)return Promise.resolve();var l=u.Get(C+"/target/node",this._gltf.nodes,E.target.node);
13246if(E.target.path==="weights"&&!l._numMorphTargets||E.target.path!=="weights"&&!l._babylonTransformNode)return Promise.resolve();var h=u.Get(C+"/sampler",c.samplers,E.sampler);return this._loadAnimationSamplerAsync(m+"/samplers/"+E.sampler,h).then(function(b){var T,D;switch(E.target.path){case"translation":T="position",D=_.Animation.ANIMATIONTYPE_VECTOR3;break;case"rotation":T="rotationQuaternion",D=_.Animation.ANIMATIONTYPE_QUATERNION;break;case"scale":T="scaling",D=_.Animation.ANIMATIONTYPE_VECTOR3;break;case"weights":T="influence",D=_.Animation.ANIMATIONTYPE_FLOAT;break;default:throw new Error(C+"/target/path: Invalid value ("+E.target.path+")")}var w,N,I=0;switch(T){case"position":w=function(){var pe=_.Vector3.FromArray(b.output,I);return I+=3,pe};break;case"rotationQuaternion":w=function(){var pe=_.Quaternion.FromArray(b.output,I);return I+=4,pe};break;case"scaling":w=function(){var pe=_.Vector3.FromArray(b.output,I);return I+=3,pe};break;case"influence":w=function(){for(var pe=new Array(l._numMorphTargets),ae=0;ae<l._numMorphTargets;ae++)pe[ae]=b.output[I++];return pe}}switch(b.interpolation){case"STEP":N=function(pe){return{frame:b.input[pe],value:w(),interpolation:_.AnimationKeyInterpolation.STEP}};break;case"LINEAR":N=function(pe){return{frame:b.input[pe],value:w()}};break;case"CUBICSPLINE":N=function(pe){return{frame:b.input[pe],inTangent:w(),value:w(),outTangent:w()}}}for(var V=new Array(b.input.length),W=0;W<b.input.length;W++)V[W]=N(W);if(T==="influence")for(var j=function(pe){var ae=A.name+"_channel"+A.targetedAnimations.length,ee=new _.Animation(ae,T,1,D);ee.setKeys(V.map(function(K){return{frame:K.frame,inTangent:K.inTangent?K.inTangent[pe]:void 0,value:K.value[pe],outTangent:K.outTangent?K.outTangent[pe]:void 0}})),g._forEachPrimitive(l,function(K){var $=K.morphTargetManager.getTarget(pe),L=ee.clone();$.animations.push(L),A.addTargetedAnimation(L,$)})},ne=0;ne<l._numMorphTargets;ne++)j(ne);else{var te=A.name+"_channel"+A.targetedAnimations.length,de=new _.Animation(te,T,1,D);de.setKeys(V),S!=null&&S.animations!=null?(S.animations.push(de),A.addTargetedAnimation(de,S)):(l._babylonTransformNode.animations.push(de),A.addTargetedAnimation(de,l._babylonTransformNode))}})},R.prototype._loadAnimationSamplerAsync=function(C,m){if(m._data)return m._data;var c=m.interpolation||"LINEAR";switch(c){case"STEP":case"LINEAR":case"CUBICSPLINE":break;default:throw new Error(C+"/interpolation: Invalid value ("+m.interpolation+")")}var E=u.Get(C+"/input",this._gltf.accessors,m.input),A=u.Get(C+"/output",this._gltf.accessors,m.output);return m._data=Promise.all([this._loadFloatAccessorAsync("/accessors/"+E.index,E),this._loadFloatAccessorAsync("/accessors/"+A.index,A)]).then(function(S){var g=S[0],l=S[1];return{input:g,interpolation:c,output:l}}),m._data},R.prototype._loadBufferAsync=function(C,m,c,E){var A=this._extensionsLoadBufferAsync(C,m,c,E);if(A)return A;if(!m._data)if(m.uri)m._data=this.loadUriAsync(C+"/uri",m,m.uri);else{if(!this._bin)throw new Error(C+": Uri is missing or the binary glTF is missing its binary chunk");m._data=this._bin.readAsync(0,m.byteLength)}return m._data.then(function(S){try{return new Uint8Array(S.buffer,S.byteOffset+c,E)}catch(g){throw new Error(C+": "+g.message)}})},R.prototype.loadBufferViewAsync=function(C,m){var c=this._extensionsLoadBufferViewAsync(C,m);if(c)return c;if(m._data)return m._data;var E=u.Get(C+"/buffer",this._gltf.buffers,m.buffer);return m._data=this._loadBufferAsync("/buffers/"+E.index,E,m.byteOffset||0,m.byteLength),m._data},R.prototype._loadAccessorAsync=function(C,m,c){var E=this;if(m._data)return m._data;var A=R._GetNumComponents(C,m.type),S=A*_.VertexBuffer.GetTypeByteLength(m.componentType),g=A*m.count;if(m.bufferView==null)m._data=Promise.resolve(new c(g));else{var l=u.Get(C+"/bufferView",this._gltf.bufferViews,m.bufferView);m._data=this.loadBufferViewAsync("/bufferViews/"+l.index,l).then(function(b){if(m.componentType!==5126||m.normalized||l.byteStride&&l.byteStride!==S){var T=new c(g);return _.VertexBuffer.ForEach(b,m.byteOffset||0,l.byteStride||S,A,m.componentType,T.length,m.normalized||!1,function(D,w){T[w]=D}),T}return R._GetTypedArray(C,m.componentType,b,m.byteOffset,g)})}if(m.sparse){var h=m.sparse;m._data=m._data.then(function(b){var T=b,D=u.Get(C+"/sparse/indices/bufferView",E._gltf.bufferViews,h.indices.bufferView),w=u.Get(C+"/sparse/values/bufferView",E._gltf.bufferViews,h.values.bufferView);return Promise.all([E.loadBufferViewAsync("/bufferViews/"+D.index,D),E.loadBufferViewAsync("/bufferViews/"+w.index,w)]).then(function(N){var I,V=N[0],W=N[1],j=R._GetTypedArray(C+"/sparse/indices",h.indices.componentType,V,h.indices.byteOffset,h.count),ne=A*h.count;if(m.componentType!==5126||m.normalized){var te=R._GetTypedArray(C+"/sparse/values",m.componentType,W,h.values.byteOffset,ne);I=new c(ne),_.VertexBuffer.ForEach(te,0,S,A,m.componentType,I.length,m.normalized||!1,function(K,$){I[$]=K})}else I=R._GetTypedArray(C+"/sparse/values",m.componentType,W,h.values.byteOffset,ne);for(var de=0,pe=0;pe<j.length;pe++)for(var ae=j[pe]*A,ee=0;ee<A;ee++)T[ae++]=I[de++];return T})})}return m._data},R.prototype._loadFloatAccessorAsync=function(C,m){return this._loadAccessorAsync(C,m,Float32Array)},R.prototype._loadIndicesAccessorAsync=function(C,m){if(m.type!=="SCALAR")throw new Error(C+"/type: Invalid value "+m.type);if(m.componentType!==5121&&m.componentType!==5123&&m.componentType!==5125)throw new Error(C+"/componentType: Invalid value "+m.componentType);if(m._data)return m._data;if(m.sparse){var c=R._GetTypedArrayConstructor(C+"/componentType",m.componentType);m._data=this._loadAccessorAsync(C,m,c)}else{var E=u.Get(C+"/bufferView",this._gltf.bufferViews,m.bufferView);m._data=this.loadBufferViewAsync("/bufferViews/"+E.index,E).then(function(A){return R._GetTypedArray(C,m.componentType,A,m.byteOffset,m.count)})}return m._data},R.prototype._loadVertexBufferViewAsync=function(C,m){var c=this;return C._babylonBuffer||(C._babylonBuffer=this.loadBufferViewAsync("/bufferViews/"+C.index,C).then(function(E){return new _.Buffer(c._babylonScene.getEngine(),E,!1)})),C._babylonBuffer},R.prototype._loadVertexAccessorAsync=function(C,m,c){var E=this;if(m._babylonVertexBuffer)return m._babylonVertexBuffer;if(m.sparse)m._babylonVertexBuffer=this._loadFloatAccessorAsync("/accessors/"+m.index,m).then(function(S){return new _.VertexBuffer(E._babylonScene.getEngine(),S,c,!1)});else if(m.byteOffset&&m.byteOffset%_.VertexBuffer.GetTypeByteLength(m.componentType)!=0)_.Logger.Warn("Accessor byte offset is not a multiple of component type byte length"),m._babylonVertexBuffer=this._loadFloatAccessorAsync("/accessors/"+m.index,m).then(function(S){return new _.VertexBuffer(E._babylonScene.getEngine(),S,c,!1)});else if(c===_.VertexBuffer.MatricesIndicesKind||c===_.VertexBuffer.MatricesIndicesExtraKind)m._babylonVertexBuffer=this._loadFloatAccessorAsync("/accessors/"+m.index,m).then(function(S){return new _.VertexBuffer(E._babylonScene.getEngine(),S,c,!1)});else{var A=u.Get(C+"/bufferView",this._gltf.bufferViews,m.bufferView);m._babylonVertexBuffer=this._loadVertexBufferViewAsync(A,c).then(function(S){var g=R._GetNumC
13246omponents(C,m.type);return new _.VertexBuffer(E._babylonScene.getEngine(),S,c,!1,!1,A.byteStride,!1,m.byteOffset,g,m.componentType,m.normalized,!0,1,!0)})}return m._babylonVertexBuffer},R.prototype._loadMaterialMetallicRoughnessPropertiesAsync=function(C,m,c){if(!(c instanceof _.PBRMaterial))throw new Error(C+": Material type not supported");var E=new Array;return m&&(m.baseColorFactor?(c.albedoColor=_.Color3.FromArray(m.baseColorFactor),c.alpha=m.baseColorFactor[3]):c.albedoColor=_.Color3.White(),c.metallic=m.metallicFactor==null?1:m.metallicFactor,c.roughness=m.roughnessFactor==null?1:m.roughnessFactor,m.baseColorTexture&&E.push(this.loadTextureInfoAsync(C+"/baseColorTexture",m.baseColorTexture,function(A){A.name=c.name+" (Base Color)",c.albedoTexture=A})),m.metallicRoughnessTexture&&(m.metallicRoughnessTexture.nonColorData=!0,E.push(this.loadTextureInfoAsync(C+"/metallicRoughnessTexture",m.metallicRoughnessTexture,function(A){A.name=c.name+" (Metallic Roughness)",c.metallicTexture=A})),c.useMetallnessFromMetallicTextureBlue=!0,c.useRoughnessFromMetallicTextureGreen=!0,c.useRoughnessFromMetallicTextureAlpha=!1)),Promise.all(E).then(function(){})},R.prototype._loadMaterialAsync=function(C,m,c,E,A){A===void 0&&(A=function(){});var S=this._extensionsLoadMaterialAsync(C,m,c,E,A);if(S)return S;m._data=m._data||{};var g=m._data[E];if(!g){this.logOpen(C+" "+(m.name||""));var l=this.createMaterial(C,m,E);g={babylonMaterial:l,babylonMeshes:[],promise:this.loadMaterialPropertiesAsync(C,m,l)},m._data[E]=g,R.AddPointerMetadata(l,C),this._parent.onMaterialLoadedObservable.notifyObservers(l),this.logClose()}return c&&(g.babylonMeshes.push(c),c.onDisposeObservable.addOnce(function(){var h=g.babylonMeshes.indexOf(c);h!==-1&&g.babylonMeshes.splice(h,1)})),A(g.babylonMaterial),g.promise.then(function(){return g.babylonMaterial})},R.prototype._createDefaultMaterial=function(C,m){this._babylonScene._blockEntityCollection=this._forAssetContainer;var c=new _.PBRMaterial(C,this._babylonScene);return this._babylonScene._blockEntityCollection=!1,c.fillMode=m,c.enableSpecularAntiAliasing=!0,c.useRadianceOverAlpha=!this._parent.transparencyAsCoverage,c.useSpecularOverAlpha=!this._parent.transparencyAsCoverage,c.transparencyMode=_.PBRMaterial.PBRMATERIAL_OPAQUE,c.metallic=1,c.roughness=1,c},R.prototype.createMaterial=function(C,m,c){var E=this._extensionsCreateMaterial(C,m,c);if(E)return E;var A=m.name||"material"+m.index;return this._createDefaultMaterial(A,c)},R.prototype.loadMaterialPropertiesAsync=function(C,m,c){var E=this._extensionsLoadMaterialPropertiesAsync(C,m,c);if(E)return E;var A=new Array;return A.push(this.loadMaterialBasePropertiesAsync(C,m,c)),m.pbrMetallicRoughness&&A.push(this._loadMaterialMetallicRoughnessPropertiesAsync(C+"/pbrMetallicRoughness",m.pbrMetallicRoughness,c)),this.loadMaterialAlphaProperties(C,m,c),Promise.all(A).then(function(){})},R.prototype.loadMaterialBasePropertiesAsync=function(C,m,c){if(!(c instanceof _.PBR
13246Material))throw new Error(C+": Material type not supported");var E=new Array;return c.emissiveColor=m.emissiveFactor?_.Color3.FromArray(m.emissiveFactor):new _.Color3(0,0,0),m.doubleSided&&(c.backFaceCulling=!1,c.twoSidedLighting=!0),m.normalTexture&&(m.normalTexture.nonColorData=!0,E.push(this.loadTextureInfoAsync(C+"/normalTexture",m.normalTexture,function(A){A.name=c.name+" (Normal)",c.bumpTexture=A})),c.invertNormalMapX=!this._babylonScene.useRightHandedSystem,c.invertNormalMapY=this._babylonScene.useRightHandedSystem,m.normalTexture.scale!=null&&(c.bumpTexture.level=m.normalTexture.scale),c.forceIrradianceInFragment=!0),m.occlusionTexture&&(m.occlusionTexture.nonColorData=!0,E.push(this.loadTextureInfoAsync(C+"/occlusionTexture",m.occlusionTexture,function(A){A.name=c.name+" (Occlusion)",c.ambientTexture=A})),c.useAmbientInGrayScale=!0,m.occlusionTexture.strength!=null&&(c.ambientTextureStrength=m.occlusionTexture.strength)),m.emissiveTexture&&E.push(this.loadTextureInfoAsync(C+"/emissiveTexture",m.emissiveTexture,function(A){A.name=c.name+" (Emissive)",c.emissiveTexture=A})),Promise.all(E).then(function(){})},R.prototype.loadMaterialAlphaProperties=function(C,m,c){if(!(c instanceof _.PBR
13246Material))throw new Error(C+": Material type not supported");switch(m.alphaMode||"OPAQUE"){case"OPAQUE":c.transparencyMode=_.PBRMaterial.PBRMATERIAL_OPAQUE;break;case"MASK":c.transparencyMode=_.PBRMaterial.PBRMATERIAL_ALPHATEST,c.alphaCutOff=m.alphaCutoff==null?.5:m.alphaCutoff,c.albedoTexture&&(c.albedoTexture.hasAlpha=!0);break;case"BLEND":c.transparencyMode=_.PBRMaterial.PBRMATERIAL_ALPHABLEND,c.albedoTexture&&(c.albedoTexture.hasAlpha=!0,c.useAlphaFromAlbedoTexture=!0);break;default:throw new Error(C+"/alphaMode: Invalid value ("+m.alphaMode+")")}},R.prototype.loadTextureInfoAsync=function(C,m,c){var E=this;c===void 0&&(c=function(){});var A=this._extensionsLoadTextureInfoAsync(C,m,c);if(A)return A;if(this.logOpen(""+C),m.texCoord>=2)throw new Error(C+"/texCoord: Invalid value ("+m.texCoord+")");var S=u.Get(C+"/index",this._gltf.textures,m.index);S._textureInfo=m;var g=this._loadTextureAsync("/textures/"+m.index,S,function(l){l.coordinatesIndex=m.texCoord||0,R.AddPointerMetadata(l,C),E._parent.onTextureLoadedObservable.notifyObservers(l),c(l)});return this.logClose(),g},R.prototype._loadTextureAsync=function(C,m,c){c===void 0&&(c=function(){});var E=this._extensionsLoadTextureAsync(C,m,c);if(E)return E;this.logOpen(C+" "+(m.name||""));var A=m.sampler==null?R.DefaultSampler:u.Get(C+"/sampler",this._gltf.samplers,m.sampler),S=u.Get(C+"/source",this._gltf.images,m.source),g=this._createTextureAsync(C,A,S,c);return this.logClose(),g},R.prototype._createTextureAsync=function(C,m,c,E,A){var S=this;E===void 0&&(E=function(){});var g=this._loadSampler("/samplers/"+m.index,m),l=new Array,h=new _.Deferred;this._babylonScene._blockEntityCollection=this._forAssetContainer;var b=new _.Texture(null,this._babylonScene,g.noMipMaps,!1,g.samplingMode,function(){S._disposed||h.resolve()},function(T,D){S._disposed||h.reject(new Error(C+": "+(D&&D.message?D.message:T||"Failed to load texture")))},void 0,void 0,void 0,c.mimeType,A);return this._babylonScene._blockEntityCollection=!1,l.push(h.promise),l.push(this.loadImageAsync("/images/"+c.index,c).then(function(T){var D=c.uri||S._fileName+"#image"+c.index,w="data:"+S._uniqueRootUrl+D;b.updateURL(w,T)})),b.wrapU=g.wrapU,b.wrapV=g.wrapV,E(b),Promise.all(l).then(function(){return b})},R.prototype._loadSampler=function(C,m){return m._data||(m._data={noMipMaps:m.minFilter===9728||m.minFilter===9729,samplingMode:R._GetTextureSamplingMode(C,m),wrapU:R._GetTextureWrapMode(C+"/wrapS",m.wrapS),wrapV:R._GetTextureWrapMode(C+"/wrapT",m.wrapT)}),m._data},R.prototype.loadImageAsync=function(C,m){if(!m._data){if(this.logOpen(C+" "+(m.name||"")),m.uri)m._data=this.loadUriAsync(C+"/uri",m,m.uri);else{var c=u.Get(C+"/bufferView",this._gltf.bufferViews,m.bufferView);m._data=this.loadBufferViewAsync("/bufferViews/"+c.index,c)}this.logClose()}return m._data},R.prototype.loadUriAsync=function(C,m,c){var E=this,A=this._extensionsLoadUriAsync(C,m,c);if(A)return A;if(!R._ValidateUri(c))throw new Error(C+": '"+c+"' is invalid");if(_.Tools.IsBase64(c)){var S=new Uint8Array(_.Tools.DecodeBase64(c));return this.log("Decoded "+c.substr(0,64)+"... ("+S.length+" bytes)"),Promise.resolve(S)}return this.log("Loading "+c),this._parent.preprocessUrlAsync(this._rootUrl+c).then(function(g){return new Promise(function(l,h){E._parent._loadFile(g,E._babylonScene,function(b){E._disposed||(E.log("Loaded "+c+" ("+b.byteLength+" bytes)"),l(new Uint8Array(b)))},!0,function(b){h(new _.LoadFileError(C+": Failed to load '"+c+"'"+(b?": "+b.status+" "+b.statusText:""),b))})})})},R.AddPointerMetadata=function(C,m){var c=C.metadata=C.metadata||{},E=c.gltf=c.gltf||{};(E.pointers=E.pointers||[]).push(m)},R._GetTextureWrapMode=function(C,m){switch(m=m??10497){case 33071:return _.Texture.CLAMP_ADDRESSMODE;case 33648:return _.Texture.MIRROR_ADDRESSMODE;case 10497:return _.Texture.WRAP_ADDRESSMODE;default:return _.Logger.Warn(C+": Invalid value ("+m+")"),_.Texture.WRAP_ADDRESSMODE}},R._GetTextureSamplingMode=function(C,m){var c=m.magFilter==null?9729:m.magFilter,E=m.minFilter==null?9987:m.minFilter;if(c===9729)switch(E){case 9728:return _.Texture.LINEAR_NEAREST;case 9729:return _.Texture.LINEAR_LINEAR;case 9984:return _.Texture.LINEAR_NEAREST_MIPNEAREST;case 9985:return _.Texture.LINEAR_LINEAR_MIPNEAREST;case 9986:return _.Texture.LINEAR_NEAREST_MIPLINEAR;case 9987:return _.Texture.LINEAR_LINEAR_MIPLINEAR;default:return _.Logger.Warn(C+"/minFilter: Invalid value ("+E+")"),_.Texture.LINEAR_LINEAR_MIPLINEAR}else switch(c!==9728&&_.Logger.Warn(C+"/magFilter: Invalid value ("+c+")"),E){case 9728:return _.Texture.NEAREST_NEAREST;case 9729:return _.Texture.NEAREST_LINEAR;case 9984:return _.Texture.NEAREST_NEAREST_MIPNEAREST;case 9985:return _.Texture.NEAREST_LINEAR_MIPNEAREST;case 9986:return _.Texture.NEAREST_NEAREST_MIPLINEAR;case 9987:return _.Texture.NEAREST_LINEAR_MIPLINEAR;default:return _.Logger.Warn(C+"/minFilter: Invalid value ("+E+")"),_.Texture.NEAREST_NEAREST_MIPNEAREST}},R._GetTypedArrayConstructor=function(C,m){switch(m){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(C+": Invalid component type "+m)}},R._GetTypedArray=function(C,m,c,E,A){var S=c.buffer;
13246E=c.byteOffset+(E||0);var g=R._GetTypedArrayConstructor(C+"/componentType",m);try{return new g(S,E,A)}catch(l){throw new Error(C+": "+l)}},R._GetNumComponents=function(C,m){switch(m){case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16}throw new Error(C+": Invalid type ("+m+")")},R._ValidateUri=function(C){return _.Tools.IsBase64(C)||C.indexOf("..")===-1},R._GetDrawMode=function(C,m){switch(m==null&&(m=4),m){case 0:return _.Material.PointListDrawMode;case 1:return _.Material.LineListDrawMode;case 2:return _.Material.LineLoopDrawMode;case 3:return _.Material.LineStripDrawMode;case 4:return _.Material.TriangleFillMode;case 5:return _.Material.TriangleStripDrawMode;case 6:return _.Material.TriangleFanDrawMode}throw new Error(C+": Invalid mesh primitive mode ("+m+")")},R.prototype._compileMaterialsAsync=function(){var C=this;this._parent._startPerformanceCounter("Compile materials");var m=new Array;if(this._gltf.materials)for(var c=0,E=this._gltf.materials;c<E.length;c++){var A=E[c];if(A._data)for(var S in A._data)for(var g=A._data[S],l=0,h=g.babylonMeshes;l<h.length;l++){var b=h[l];b.computeWorldMatrix(!0);var T=g.babylonMaterial;m.push(T.forceCompilationAsync(b)),m.push(T.forceCompilationAsync(b,{useInstances:!0})),this._parent.useClipPlane&&(m.push(T.forceCompilationAsync(b,{clipPlane:!0})),m.push(T.forceCompilationAsync(b,{clipPlane:!0,useInstances:!0})))}}return Promise.all(m).then(function(){C._parent._endPerformanceCounter("Compile materials")})},R.prototype._compileShadowGeneratorsAsync=function(){var C=this;this._parent._startPerformanceCounter("Compile shadow generators");for(var m=new Array,c=0,E=this._babylonScene.lights;c<E.length;c++){var A=E[c].getShadowGenerator();A&&m.push(A.forceCompilationAsync())}return Promise.all(m).then(function(){C._parent._endPerformanceCounter("Compile shadow generators")})},R.prototype._forEachExtensions=function(C){for(var m=0,c=this._extensions;m<c.length;m++){var E=c[m];E.enabled&&C(E)}},R.prototype._applyExtensions=function(C,m,c){for(var E=0,A=this._extensions;E<A.length;E++){var S=A[E];if(S.enabled){var g=S.name+"."+m,l=C;l._activeLoaderExtensionFunctions=l._activeLoaderExtensionFunctions||{};var h=l._activeLoaderExtensionFunctions;if(!h[g]){h[g]=!0;try{var b=c(S);if(b)return b}finally{delete h[g]}}}}return null},R.prototype._extensionsOnLoading=function(){this._forEachExtensions(function(C){return C.onLoading&&C.onLoading()})},R.prototype._extensionsOnReady=function(){this._forEachExtensions(function(C){return C.onReady&&C.onReady()})},R.prototype._extensionsLoadSceneAsync=function(C,m){return this._applyExtensions(m,"loadScene",function(c){return c.loadSceneAsync&&c.loadSceneAsync(C,m)})},R.prototype._extensionsLoadNodeAsync=function(C,m,c){return this._applyExtensions(m,"loadNode",function(E){return E.loadNodeAsync&&E.loadNodeAsync(C,m,c)})},R.prototype._extensionsLoadCameraAsync=function(C,m,c){return this._applyExtensions(m,"loadCamera",function(E){return E.loadCameraAsync&&E.loadCameraAsync(C,m,c)})},R.prototype._extensionsLoadVertexDataAsync=function(C,m,c){return this._applyExtensions(m,"loadVertexData",function(E){return E._loadVertexDataAsync&&E._loadVertexDataAsync(C,m,c)})},R.prototype._extensionsLoadMeshPrimitiveAsync=function(C,m,c,E,A,S){return this._applyExtensions(A,"loadMeshPrimitive",function(g){return g._loadMeshPrimitiveAsync&&g._loadMeshPrimitiveAsync(C,m,c,E,A,S)})},R.prototype._extensionsLoadMaterialAsync=function(C,m,c,E,A){return this._applyExtensions(m,"loadMaterial",function(S){return S._loadMaterialAsync&&S._loadMaterialAsync(C,m,c,E,A)})},R.prototype._extensionsCreateMaterial=function(C,m,c){return this._applyExtensions(m,"createMaterial",function(E){return E.createMaterial&&E.createMaterial(C,m,c)})},R.prototype._extensionsLoadMaterialPropertiesAsync=function(C,m,c){return this._applyExtensions(m,"loadMaterialProperties",function(E){return E.loadMaterialPropertiesAsync&&E.loadMaterialPropertiesAsync(C,m,c)})},R.prototype._extensionsLoadTextureInfoAsync=function(C,m,c){return this._applyExtensions(m,"loadTextureInfo",function(E){return E.loadTextureInfoA
13246sync&&E.loadTextureInfoAsync(C,m,c)})},R.prototype._extensionsLoadTextureAsync=function(C,m,c){return this._applyExtensions(m,"loadTexture",function(E){return E._loadTextureAsync&&E._loadTextureAsync(C,m,c)})},R.prototype._extensionsLoadAnimationAsync=function(C,m){return this._applyExtensions(m,"loadAnimation",function(c){return c.loadAnimationAsync&&c.loadAnimationAsync(C,m)})},R.prototype._extensionsLoadSkinAsync=function(C,m,c){return this._applyExtensions(c,"loadSkin",function(E){return E._loadSkinAsync&&E._loadSkinAsync(C,m,c)})},R.prototype._extensionsLoadUriAsync=function(C,m,c){return this._applyExtensions(m,"loadUri",function(E){return E._loadUriAsync&&E._loadUriAsync(C,m,c)})},R.prototype._extensionsLoadBufferViewAsync=function(C,m){return this._applyExtensions(m,"loadBufferView",function(c){return c.loadBufferViewAsync&&c.loadBufferViewAsync(C,m)})},R.prototype._extensionsLoadBufferAsync=function(C,m,c,E){return this._applyExtensions(m,"loadBuffer",function(A){return A.loadBufferAsync&&A.loadBufferAsync(C,m,c,E)})},R.LoadExtensionAsync=function(C,m,c,E){if(!m.extensions)return null;var A=m.extensions[c];return A?E(C+"/extensions/"+c,A):null},R.LoadExtraAsync=function(C,m,c,E){if(!m.extras)return null;var A=m.extras[c];return A?E(C+"/extras/"+c,A):null},R.prototype.isExtensionUsed=function(C){return!!this._gltf.extensionsUsed&&this._gltf.extensionsUsed.indexOf(C)!==-1},R.prototype.logOpen=function(C){this._parent._logOpen(C)},R.prototype.logClose=function(){this._parent._logClose()},R.prototype.log=function(C){this._parent._log(C)},R.prototype.startPerformanceCounter=function(C){this._parent._startPerformanceCounter(C)},R.prototype.endPerformanceCounter=function(C){this._parent._endPerformanceCounter(C)},R._RegisteredExtensions={},R.DefaultSampler={index:-1},R}();x.GLTFFileLoader._CreateGLTF2Loader=function(R){return new M(R)}},function(v,f,B){B.r(f),B.d(f,"GLTFLoaderCoordinateSystemMode",function(){return _}),B.d(f,"GLTFLoaderAnimationStartMode",function(){return x}),B.d(f,"GLTFLoaderState",function(){return u}),B.d(f,"GLTFFileLoader",function(){return C});var _,x,u,M=B(0),R=B(3);(function(m){m[m.AUTO=0]="AUTO",m[m.FORCE_RIGHT_HANDED=1]="FORCE_RIGHT_HANDED"})(_||(_={})),function(m){m[m.NONE=0]="NONE",m[m.FIRST=1]="FIRST",m[m.ALL=2]="ALL"}(x||(x={})),function(m){m[m.LOADING=0]="LOADING",m[m.READY=1]="READY",m[m.COMPLETE=2]="COMPLETE"}(u||(u={}));var C=function(){function m(){this.onParsedObservable=new M.Observable,this.coordinateSystemMode=_.AUTO,this.animationStartMode=x.FIRST,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.preprocessUrlAsync=function(c){return Promise.resolve(c)},this.onMeshLoadedObservable=new M.Observable,this.onTextureLoadedObservable=new M.Observable,this.onMaterialLoadedObservable=new M.Observable,this.onCameraLoadedObservable=new M.Observable,this.onCompleteObservable=new M.Observable,this.onErrorObservable=new M.Observable,this.onDisposeObservable=new M.Observable,this.onExtensionLoadedObservable=new M.Observable,this.validate=!1,this.onValidatedObservable=new M.Observable,this._loader=null,this._requests=new Array,this.name="gltf",this.extensions={".gltf":{isBinary:!1},".glb":{isBinary:!0}},this._logIndentLevel=0,this._loggingEnabled=!1,this._log=this._logDisabled,this._capturePerformanceCounters=!1,this._startPerformanceCounter=this._startPerformanceCounterDisabled,this._endPerformanceCounter=this._endPerformanceCounterDisabled}return Object.defineProperty(m.prototype,"onParsed",{set:function(c){this._onParsedObserver&&this.onParsedObservable.remove(this._onParsedObserver),this._onParsedObserver=this.onParsedObservable.add(c)},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"onMeshLoaded",{set:function(c){this._onMeshLoadedObserver&&this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver),this._onMeshLoadedObserver=this.onMeshLoadedObservable.add(c)},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"onTextureLoaded",{set:function(c){this._onTextureLoadedObserver&&this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver),this._onTextureLoadedObserver=this.onTextureLoadedObservable.add(c)}
13246,enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"onMaterialLoaded",{set:function(c){this._onMaterialLoadedObserver&&this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver),this._onMaterialLoadedObserver=this.onMaterialLoadedObservable.add(c)},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"onCameraLoaded",{set:function(c){this._onCameraLoadedObserver&&this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver),this._onCameraLoadedObserver=this.onCameraLoadedObservable.add(c)},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"onComplete",{set:function(c){this._onCompleteObserver&&this.onCompleteObservable.remove(this._onCompleteObserver),this._onCompleteObserver=this.onCompleteObservable.add(c)},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"onError",{set:function(c){this._onErrorObserver&&this.onErrorObservable.remove(this._onErrorObserver),this._onErrorObserver=this.onErrorObservable.add(c)},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"onDispose",{set:function(c){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(c)},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"onExtensionLoaded",{set:function(c){this._onExtensionLoadedObserver&&this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver),this._onExtensionLoadedObserver=this.onExtensionLoadedObservable.add(c)},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"loggingEnabled",{get:function(){return this._loggingEnabled},set:function(c){this._loggingEnabled!==c&&(this._loggingEnabled=c,this._loggingEnabled?this._log=this._logEnabled:this._log=this._logDisabled)},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"capturePerformanceCounters",{get:function(){return this._capturePerformanceCounters},set:function(c){this._capturePerformanceCounters!==c&&(this._capturePerformanceCounters=c,this._capturePerformanceCounters?(this._startPerformanceCounter=this._startPerformanceCounterEnabled,this._endPerformanceCounter=this._endPerformanceCounterEnabled):(this._startPerformanceCounter=this._startPerformanceCounterDisabled,this._endPerformanceCounter=this._endPerformanceCounterDisabled))},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"onValidated",{set:function(c){this._onValidatedObserver&&this.onValidatedObservable.remove(this._onValidatedObserver),this._onValidatedObserver=this.onValidatedObservable.add(c)},enumerable:!1,configurable:!0}),m.prototype.dispose=function(){this._loader&&(this._loader.dispose(),this._loader=null);for(var c=0,E=this._requests;c<E.length;c++)E[c].abort();this._requests.length=0,delete this._progressCallback,this.preprocessUrlAsync=function(A){return Promise.resolve(A)},this.onMeshLoadedObservable.clear(),this.onTextureLoadedObservable.clear(),this.onMaterialLoadedObservable.clear(),this.onCameraLoadedObservable.clear(),this.onCompleteObservable.clear(),this.onExtensionLoadedObservable.clear(),this.onDisposeObservable.notifyObservers(void 0),this.onDisposeObservable.clear()},m.prototype.requestFile=function(c,E,A,S,g,l){var h=this;if(this._progressCallback=S,g){if(this.useRangeRequests){this.validate&&M.Logger.Warn("glTF validation is not supported when range requests are enabled");var b={abort:function(){},onCompleteObservable:new M.Observable},T={readAsync:function(D,w){return new Promise(function(N,I){h._requestFile(E,c,function(V){N(new Uint8Array(V))},!0,function(V){I(V)},function(V){V.setRequestHeader("Range","bytes="+D+"-"+(D+w-1))})})},byteLength:0};return this._unpackBinaryAsync(new M.DataReader(T)).then(function(D){b.onCompleteObservable.notifyObservers(b),A(D)},l),b}return this._requestFile(E,c,function(D,w){var N=D;h._unpackBinaryAsync(new M.DataReader({readAsync:function(I,V){return Promise.resolve(new Uint8Array(N,I,V))},byteLength:N.byteLength})).then(function(I){A(I,w)},l)},!0,l)}return this._requestFile(E,c,function(D,w){h._validate(c,D,M.Tools.GetFolderPath(E),M.Tools.GetFilename(E)),A({json:h._parseJson(D)},w)},g,l)},m.prototype.readFile=function(c,E,A,S,g,l){var h=this;return c._readFile(E,function(b){if(h._validate(c,b,"file:",E.name),g){var T=b;h._unpackBinaryAsync(new M.DataReader({readAsync:function(D,w){return Promise.resolve(new Uint8Array(T,D,w))},byteLength:T.byteLength})).then(A,l)}else A({json:h._parseJson(b)})},S,g,l)},m.prototype.importMeshAsync=function(c,E,A,S,g,l){var h=this;return Promise.resolve().then(function(){return h.onParsedObservable.notifyObservers(A),h.onParsedObservable.clear(),h._log("Loading "+(l||"")),h._loader=h._getLoader(A),h._loader.importMeshAsync(c,E,!1,A,S,g,l)}
13246)},m.prototype.loadAsync=function(c,E,A,S,g){var l=this;return Promise.resolve().then(function(){return l.onParsedObservable.notifyObservers(E),l.onParsedObservable.clear(),l._log("Loading "+(g||"")),l._loader=l._getLoader(E),l._loader.loadAsync(c,E,A,S,g)})},m.prototype.loadAssetContainerAsync=function(c,E,A,S,g){var l=this;return Promise.resolve().then(function(){l.onParsedObservable.notifyObservers(E),l.onParsedObservable.clear(),l._log("Loading "+(g||"")),l._loader=l._getLoader(E);var h=new M.AssetContainer(c),b=[];l.onMaterialLoadedObservable.add(function(w){b.push(w),w.onDisposeObservable.addOnce(function(){var N=h.materials.indexOf(w);N>-1&&h.materials.splice(N,1),(N=b.indexOf(w))>-1&&b.splice(N,1)})});var T=[];l.onTextureLoadedObservable.add(function(w){T.push(w),w.onDisposeObservable.addOnce(function(){var N=h.textures.indexOf(w);N>-1&&h.textures.splice(N,1),(N=T.indexOf(w))>-1&&T.splice(N,1)})});var D=[];return l.onCameraLoadedObservable.add(function(w){D.push(w)}),l._loader.importMeshAsync(null,c,!0,E,A,S,g).then(function(w){return Array.prototype.push.apply(h.geometries,w.geometries),Array.prototype.push.apply(h.meshes,w.meshes),Array.prototype.push.apply(h.particleSystems,w.particleSystems),Array.prototype.push.apply(h.skeletons,w.skeletons),Array.prototype.push.apply(h.animationGroups,w.animationGroups),Array.prototype.push.apply(h.materials,b),Array.prototype.push.apply(h.textures,T),Array.prototype.push.apply(h.lights,w.lights),Array.prototype.push.apply(h.transformNodes,w.transformNodes),Array.prototype.push.apply(h.cameras,D),h})})},m.prototype.canDirectLoad=function(c){return c.indexOf("asset")!==-1&&c.indexOf("version")!==-1||M.StringTools.StartsWith(c,"data:base64,"+m.magicBase64Encoded)||M.StringTools.StartsWith(c,"data:application/octet-stream;base64,"+m.magicBase64Encoded)||M.StringTools.StartsWith(c,"data:model/gltf-binary;base64,"+m.magicBase64Encoded)},m.prototype.directLoad=function(c,E){if(M.StringTools.StartsWith(E,"base64,"+m.magicBase64Encoded)||M.StringTools.StartsWith(E,"application/octet-stream;base64,"+m.magicBase64Encoded)||M.StringTools.StartsWith(E,"model/gltf-binary;base64,"+m.magicBase64Encoded)){var A=M.Tools.DecodeBase64(E);return this._validate(c,A),this._unpackBinaryAsync(new M.DataReader({readAsync:function(S,g){return Promise.resolve(new Uint8Array(A,S,g))},byteLength:A.byteLength}))}return this._validate(c,E),Promise.resolve({json:this._parseJson(E)})},m.prototype.createPlugin=function(){return new m},Object.defineProperty(m.prototype,"loaderState",{get:function(){return this._loader?this._loader.state:null},enumerable:!1,configurable:!0}),m.prototype.whenCompleteAsync=function(){var c=this;return new Promise(function(E,A){c.onCompleteObservable.addOnce(function(){E()}),c.onErrorObservable.addOnce(function(S){A(S)})})},m.prototype._loadFile=function(c,E,A,S,g){var l=this,h=E._loadFile(c,A,function(b){l._onProgress(b,h)},void 0,S,g);return h.onCompleteObservable.add(function(b){l._requests.splice(l._requests.indexOf(b),1)}),this._requests.push(h),h},m.prototype._requestFile=function(c,E,A,S,g,l){var h=this,b=E._requestFile(c,A,function(T){h._onProgress(T,b)},void 0,S,g,l);return b.onCompleteObservable.add(function(T){h._requests.splice(h._requests.indexOf(T),1)}),this._requests.push(b),b},m.prototype._onProgress=function(c,E){if(this._progressCallback){E._lengthComputable=c.lengthComputable,E._loaded=c.loaded,E._total=c.total;for(var A=!0,S=0,g=0,l=0,h=this._requests;l<h.length;l++){var b=h[l];if(b._lengthComputable===void 0||b._loaded===void 0||b._total===void 0)return;A=A&&b._lengthComputable,S+=b._loaded,g+=b._total}this._progressCallback({lengthComputable:A,loaded:S,total:A?g:0})}},m.prototype._validate=function(c,E,A,S){var g=this;A===void 0&&(A=""),S===void 0&&(S=""),this.validate&&(this._startPerformanceCounter("Validate JSON"),R.GLTFValidation.ValidateAsync(E,A,S,function(l){return g.preprocessUrlAsync(A+l).then(function(h){return c._loadFileAsync(h,void 0,!0,!0)})}).then(function(l){g._endPerformanceCounter("Validate JSON"),g.onValidatedObservable.notifyObservers(l),g.onValidatedObservable.clear()},function(l){g._endPerformanceCounter("Validate JSON"),M.Tools.Warn("Failed to validate: "+l.message),g.onValidatedObservable.clear()}
13246))},m.prototype._getLoader=function(c){var E=c.json.asset||{};this._log("Asset version: "+E.version),E.minVersion&&this._log("Asset minimum version: "+E.minVersion),E.generator&&this._log("Asset generator: "+E.generator);var A=m._parseVersion(E.version);if(!A)throw new Error("Invalid version: "+E.version);if(E.minVersion!==void 0){var S=m._parseVersion(E.minVersion);if(!S)throw new Error("Invalid minimum version: "+E.minVersion);if(m._compareVersion(S,{major:2,minor:0})>0)throw new Error("Incompatible minimum version: "+E.minVersion)}var g={1:m._CreateGLTF1Loader,2:m._CreateGLTF2Loader}[A.major];if(!g)throw new Error("Unsupported version: "+E.version);return g(this)},m.prototype._parseJson=function(c){this._startPerformanceCounter("Parse JSON"),this._log("JSON length: "+c.length);var E=JSON.parse(c);return this._endPerformanceCounter("Parse JSON"),E},m.prototype._unpackBinaryAsync=function(c){var E=this;return this._startPerformanceCounter("Unpack Binary"),c.loadAsync(20).then(function(){var A=c.readUint32();if(A!==1179937895)throw new Error("Unexpected magic: "+A);var S=c.readUint32();E.loggingEnabled&&E._log("Binary version: "+S);var g,l=c.readUint32();if(c.buffer.byteLength!==0&&l!==c.buffer.byteLength)throw new Error("Length in header does not match actual data length: "+l+" != "+c.buffer.byteLength);switch(S){case 1:g=E._unpackBinaryV1Async(c,l);break;case 2:g=E._unpackBinaryV2Async(c,l);break;default:throw new Error("Unsupported version: "+S)}return E._endPerformanceCounter("Unpack Binary"),g})},m.prototype._unpackBinaryV1Async=function(c,E){var A=c.readUint32(),S=c.readUint32();if(S!==0)throw new Error("Unexpected content format: "+S);var g=E-c.byteOffset,l={json:this._parseJson(c.readString(A)),bin:null};if(g!==0){var h=c.byteOffset;l.bin={readAsync:function(b,T){return c.buffer.readAsync(h+b,T)},byteLength:g}}return Promise.resolve(l)},m.prototype._unpackBinaryV2Async=function(c,E){var A=this,S=1313821514,g=5130562,l=c.readUint32();if(c.readUint32()!==S)throw new Error("First chunk format is not JSON");return c.byteOffset+l===E?c.loadAsync(l).then(function(){return{json:A._parseJson(c.readString(l)),bin:null}}):c.loadAsync(l+8).then(function(){var h={json:A._parseJson(c.readString(l)),bin:null},b=function(){var T=c.readUint32();switch(c.readUint32()){case S:throw new Error("Unexpected JSON chunk");case g:var D=c.byteOffset;h.bin={readAsync:function(w,N){return c.buffer.readAsync(D+w,N)},byteLength:T},c.skipBytes(T);break;default:c.skipBytes(T)}return c.byteOffset!==E?c.loadAsync(8).then(b):Promise.resolve(h)};return b()})},m._parseVersion=function(c){if(c==="1.0"||c==="1.0.1")return{major:1,minor:0};var E=(c+"").match(/^(\d+)\.(\d+)/);return E?{major:parseInt(E[1]),minor:parseInt(E[2])}:null},m._compareVersion=function(c,E){return c.major>E.major?1:c.major<E.major?-1:c.minor>E.minor?1:c.minor<E.minor?-1:0},m.prototype._logOpen=function(c){this._log(c),this._logIndentLevel++},m.prototype._logClose=function(){--this._logIndentLevel},m.prototype._logEnabled=function(c){var E=m._logSpaces.substr(0,2*this._logIndentLevel);M.Logger.Log(""+E+c)},m.prototype._logDisabled=function(c){},m.prototype._startPerformanceCounterEnabled=function(c){M.Tools.StartPerformanceCounter(c)},m.prototype._startPerformanceCounterDisabled=function(c){},m.prototype._endPerformanceCounterEnabled=function(c){M.Tools.EndPerformanceCounter(c)},m.prototype._endPerformanceCounterDisabled=function(c){},m.IncrementalLoading=!0,m.HomogeneousCoordinates=!1,m.magicBase64Encoded="Z2xURg",m._logSpaces="                                ",m}();M.SceneLoader&&M.SceneLoader.RegisterPlugin(new C)},function(v,f,B){B.r(f),B.d(f,"GLTFValidation",function(){return M});var _=B(0);function x(R,C,m,c){var E={externalResourceFunction:function(A){return c(A).then(function(S){return new Uint8Array(S)})}};return m&&(E.uri=C==="file:"?m:C+m),R instanceof ArrayBuffer?GLTFValidator.validateBytes(new Uint8Array(R),E):GLTFValidator.validateString(R,E)}function u(){var R=[];onmessage=function(C){var m=C.data;switch(m.id){case"init":importScripts(m.url);break;case"validate":x(m.data,m.rootUrl,m.fileName,function(c){return new Promise(function(E,A){var S=R.length;R.push({resolve:E,reject:A}),postMessage({id:"getExternalResource",index:S,uri:c})})}).then(function(c){postMessage({id:"validate.resolve",value:c})},function(c){postMessage({id:"validate.reject",reason:c})});break;case"getExternalResource.resolve":R[m.index].resolve(m.value);break;case"getExternalResource.reject":R[m.index].reject(m.reason)}}}var M=function(){function R(){}return R.ValidateAsync=function(C,m,c,E){var A=this;return typeof Worker=="function"?new Promise(function(S,g){var l=x+"("+u+")()",h=URL.createObjectURL(new Blob([l],{type:"application/javascript"})),b=new Worker(h),T=function(w){b.removeEventListener("error",T),b.removeEventListener("message",D),g(w)},D=function(w){var N=w.data;switch(N.id){case"getExternalResource":E(N.uri).then(function(I){b.postMessage({id:"getExternalResource.resolve",index:N.index,value:
13246I},[I])},function(I){b.postMessage({id:"getExternalResource.reject",index:N.index,reason:I})});break;case"validate.resolve":b.removeEventListener("error",T),b.removeEventListener("message",D),S(N.value);break;case"validate.reject":b.removeEventListener("error",T),b.removeEventListener("message",D),g(N.reason)}};b.addEventListener("error",T),b.addEventListener("message",D),b.postMessage({id:"init",url:_.Tools.GetAbsoluteUrl(A.Configuration.url)}),b.postMessage({id:"validate",data:C,rootUrl:m,fileName:c})}):(this._LoadScriptPromise||(this._LoadScriptPromise=_.Tools.LoadScriptAsync(this.Configuration.url)),this._LoadScriptPromise.then(function(){return x(C,m,c,E)}))},R.Configuration={url:"https://preview.babylonjs.com/gltf_validator.js"},R}()},function(v,f,B){B.d(f,"b",function(){return x}),B.d(f,"a",function(){return u});/*! *****************************************************************************
13247	Copyright (c) Microsoft Corporation.
13248
13249	Permission to use, copy, modify, and/or distribute this software for any
13250	purpose with or without fee is hereby granted.
13251
13252	THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
13253	REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13254	AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
13255	INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13256	LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13257	OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13258	PERFORMANCE OF THIS SOFTWARE.
13259	***************************************************************************** */var _=function(M,R){return(_=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(C,m){C.__proto__=m}||function(C,m){for(var c in m)Object.prototype.hasOwnProperty.call(m,c)&&(C[c]=m[c])})(M,R)};function x(M,R){if(typeof R!="function"&&R!==null)throw new TypeError("Class extends value "+String(R)+" is not a constructor or null");function C(){this.constructor=M}_(M,R),M.prototype=R===null?Object.create(R):(C.prototype=R.prototype,new C)}var u=function(){return(u=Object.assign||function(M){for(var R,C=1,m=arguments.length;C<m;C++)for(var c in R=arguments[C])Object.prototype.hasOwnProperty.call(R,c)&&(M[c]=R[c]);return M}).apply(this,arguments)}},function(v,f){var B;B=function(){return this}();try{B=B||new Function("return this")()}catch{typeof window=="object"&&(B=window)}v.exports=B},function(v,f,B){B.r(f)},function(v,f,B){B.r(f),B.d(f,"EXT_lights_image_based",function(){return M}),B.d(f,"EXT_mesh_gpu_instancing",function(){return R}),B.d(f,"EXT_texture_webp",function(){return C}),B.d(f,"KHR_draco_mesh_compression",function(){return m}),B.d(f,"KHR_lights",function(){return c}),B.d(f,"KHR_materials_pbrSpecularGlossiness",function(){return E}),B.d(f,"KHR_materials_unlit",function(){return A}),B.d(f,"KHR_materials_clearcoat",function(){return S}),B.d(f,"KHR_materials_sheen",function(){return g}),B.d(f,"KHR_materials_specular",function(){return l}),B.d(f,"KHR_materials_ior",function(){return h}),B.d(f,"KHR_materials_variants",function(){return b}),B.d(f,"KHR_materials_transmission",function(){return w}),B.d(f,"KHR_materials_translucency",function(){return N}),B.d(f,"KHR_mesh_quantization",function(){return I}),B.d(f,"KHR_texture_basisu",function(){return V}),B.d(f,"KHR_texture_transform",function(){return W}),B.d(f,"MSFT_audio_emitter",function(){return j}),B.d(f,"MSFT_lod",function(){return ne}),B.d(f,"MSFT_minecraftMesh",function(){return te}),B.d(f,"MSFT_sRGBFactors",function(){return de}),B.d(f,"ExtrasAsMetadata",function(){return pe});var _=B(0),x=B(1),u="EXT_lights_image_based",M=function(){function ae(ee){this.name=u,this._loader=ee,this.enabled=this._loader.isExtensionUsed(u)}return ae.prototype.dispose=function(){this._loader=null,delete this._lights},ae.prototype.onLoading=function(){var ee=this._loader.gltf.extensions;if(ee&&ee[this.name]){var K=ee[this.name];this._lights=K.lights}},ae.prototype.loadSceneAsync=function(ee,K){var $=this;return x.b.LoadExtensionAsync(ee,K,this.name,function(L,G){var Q=new Array;Q.push($._loader.loadSceneAsync(ee,K)),$._loader.logOpen(""+L);var oe=x.a.Get(L+"/light",$._lights,G.light);return Q.push($._loadLightAsync("/extensions/"+$.name+"/lights/"+G.light,oe).then(function(re){$._loader.babylonScene.environmentTexture=re})),$._loader.logClose(),Promise.all(Q).then(function(){})})},ae.prototype._loadLightAsync=function(ee,K){var $=this;if(!K._loaded){var L=new Array;this._loader.logOpen(""+ee);for(var G=new Array(K.specularImages.length),Q=function(Y){var k=K.specularImages[Y];G[Y]=new Array(k.length);for(var H=function(X){var q=ee+"/specularImages/"+Y+"/"+X;oe._loader.logOpen(""+q);var he=k[X],ge=x.a.Get(q,oe._loader.gltf.images,he);L.push(oe._loader.loadImageAsync("/images/"+he,ge).then(function(me){G[Y][X]=me})),oe._loader.logClose()},Z=0;Z<k.length;Z++)H(Z)},oe=this,re=0;re<K.specularImages.length;re++)Q(re);this._loader.logClose(),K._loaded=Promise.all(L).then(function(){var Y=new _.RawCubeTexture($._loader.babylonScene,null,K.specularImageSize);if(Y.name=K.name||"environment",K._babylonTexture=Y,K.intensity!=null&&(Y.level=K.intensity),K.rotation){var k=_.Quaternion.FromArray(K.rotation);$._loader.babylonScene.useRightHandedSystem||(k=_.Quaternion.Inverse(k)),_.Matrix.FromQuaternionToRef(k,Y.getReflectionTextureMatrix())}var H=_.SphericalHarmonics.FromArray(K.irradianceCoefficients);
13259H.scaleInPlace(K.intensity),H.convertIrradianceToLambertianRadiance();var Z=_.SphericalPolynomial.FromHarmonics(H),X=(G.length-1)/_.Scalar.Log2(K.specularImageSize);return Y.updateRGBDAsync(G,Z,X)})}return K._loaded.then(function(){return K._babylonTexture})},ae}();x.b.RegisterExtension(u,function(ae){return new M(ae)});var R=function(){function ae(ee){this.name="EXT_mesh_gpu_instancing",this._loader=ee,this.enabled=this._loader.isExtensionUsed("EXT_mesh_gpu_instancing")}return ae.prototype.dispose=function(){this._loader=null},ae.prototype.loadNodeAsync=function(ee,K,$){var L=this;return x.b.LoadExtensionAsync(ee,K,this.name,function(G,Q){L._loader._disableInstancedMesh++;var oe=L._loader.loadNodeAsync("/nodes/"+K.index,K,$);if(L._loader._disableInstancedMesh--,!K._primitiveBabylonMeshes)return oe;var re=new Array,Y=0,k=function(H){if(Q.attributes[H]!=null){var Z=x.a.Get(G+"/attributes/"+H,L._loader.gltf.accessors,Q.attributes[H]);if(re.push(L._loader._loadFloatAccessorAsync("/accessors/"+Z.bufferView,Z)),Y===0)Y=Z.count;else if(Y!==Z.count)throw new Error(G+"/attributes: Instance buffer accessors do not have the same count.")}
13259else re.push(Promise.resolve(null))};return k("TRANSLATION"),k("ROTATION"),k("SCALE"),oe.then(function(H){return Promise.all(re).then(function(Z){var X=Z[0],q=Z[1],he=Z[2],ge=new Float32Array(16*Y);_.TmpVectors.Vector3[0].copyFromFloats(0,0,0),_.TmpVectors.Quaternion[0].copyFromFloats(0,0,0,1),_.TmpVectors.Vector3[1].copyFromFloats(1,1,1);for(var me=0;me<Y;++me)X&&_.Vector3.FromArrayToRef(X,3*me,_.TmpVectors.Vector3[0]),q&&_.Quaternion.FromArrayToRef(q,4*me,_.TmpVectors.Quaternion[0]),he&&_.Vector3.FromArrayToRef(he,3*me,_.TmpVectors.Vector3[1]),_.Matrix.ComposeToRef(_.TmpVectors.Vector3[1],_.TmpVectors.Quaternion[0],_.TmpVectors.Vector3[0],_.TmpVectors.Matrix[0]),_.TmpVectors.Matrix[0].copyToArray(ge,16*me);for(var _e=0,be=K._primitiveBabylonMeshes;_e<be.length;_e++)be[_e].thinInstanceSetBuffer("matrix",ge,16,!0);return H})})})},ae}();x.b.RegisterExtension("EXT_mesh_gpu_instancing",function(ae){return new R(ae)});var C=function(){function ae(ee){this.name="EXT_texture_webp",this._loader=ee,this.enabled=ee.isExtensionUsed("EXT_texture_webp")}return ae.prototype.dispose=function(){this._loader=null},ae.prototype._loadTextureAsync=function(ee,K,$){var L=this;return x.b.LoadExtensionAsync(ee,K,this.name,function(G,Q){var oe=K.sampler==null?x.b.DefaultSampler:x.a.Get(ee+"/sampler",L._loader.gltf.samplers,K.sampler),re=x.a.Get(G+"/source",L._loader.gltf.images,Q.source);return L._loader._createTextureAsync(ee,oe,re,function(Y){$(Y)})})},ae}();x.b.RegisterExtension("EXT_texture_webp",function(ae){return new C(ae)});var m=function(){function ae(ee){this.name="KHR_draco_mesh_compression",this._loader=ee,this.enabled=_.DracoCompression.DecoderAvailable&&this._loader.isExtensionUsed("KHR_draco_mesh_compression")}return ae.prototype.dispose=function(){delete this.dracoCompression,this._loader=null},ae.prototype._loadVertexDataAsync=function(ee,K,$){var L=this;return x.b.LoadExtensionAsync(ee,K,this.name,function(G,Q){if(K.mode!=null){if(K.mode!==5&&K.mode!==4)throw new Error(ee+": Unsupported mode "+K.mode);if(K.mode===5)throw new Error(ee+": Mode "+K.mode+" is not currently supported")}var oe={},re=function(k,H){var Z=Q.attributes[k];Z!=null&&($._delayInfo=$._delayInfo||[],$._delayInfo.indexOf(H)===-1&&$._delayInfo.push(H),oe[H]=Z)};re("POSITION",_.VertexBuffer.PositionKind),re("NORMAL",_.VertexBuffer.NormalKind),re("TANGENT",_.VertexBuffer.TangentKind),re("TEXCOORD_0",_.VertexBuffer.UVKind),re("TEXCOORD_1",_.VertexBuffer.UV2Kind),re("JOINTS_0",_.VertexBuffer.MatricesIndicesKind),re("WEIGHTS_0",_.VertexBuffer.MatricesWeightsKind),re("COLOR_0",_.VertexBuffer.ColorKind);var Y=x.a.Get(G,L._loader.gltf.bufferViews,Q.bufferView);return Y._dracoBabylonGeometry||(Y._dracoBabylonGeometry=L._loader.loadBufferViewAsync("/bufferViews/"+Y.index,Y).then(function(k){return(L.dracoCompression||_.DracoCompression.Default).decodeMeshAsync(k,oe).then(function(H){var Z=new _.Geometry($.name,L._loader.babylonScene);return H.applyToGeometry(Z),Z}).catch(function(H){throw new Error(ee+": "+H.message)})})),Y._dracoBabylonGeometry})},ae}();x.b.RegisterExtension("KHR_draco_mesh_compression",function(ae){return new m(ae)});var c=function(){function ae(ee){this.name="KHR_lights_punctual",this._loader=ee,this.enabled=this._loader.isExtensionUsed("KHR_lights_punctual")}return ae.prototype.dispose=function(){this._loader=null,delete this._lights},ae.prototype.onLoading=function(){var ee=this._loader.gltf.extensions;if(ee&&ee[this.name]){var K=ee[this.name];this._lights=K.lights}},ae.prototype.loadNodeAsync=function(ee,K,$){var L=this;return x.b.LoadExtensionAsync(ee,K,this.name,function(G,Q){return L._loader.loadNodeAsync(ee,K,function(oe){var re,Y=x.a.Get(G,L._lights,Q.light),k=Y.name||oe.name;switch(L._loader.babylonScene._blockEntityCollection=L._loader._forAssetContainer,Y.type){case"directional":re=new _.DirectionalLight(k,_.Vector3.Backward(),L._loader.babylonScene);break;case"point":re=new _.PointLight(k,_.Vector3.Zero(),L._loader.babylonScene);break;case"spot":var H=new _.SpotLight(k,_.Vector3.Zero(),_.Vector3.Backward(),0,1,L._loader.babylonScene);H.angle=2*(Y.spot&&Y.spot.outerConeAngle||Math.PI/4),H.innerAngle=2*(Y.spot&&Y.spot.innerConeAngle||0),re=H;break;default:throw L._loader.babylonScene._blockEntityCollection=!1,new Error(G+": Invalid light type ("+Y.type+")")}L._loader.babylonScene._blockEntityCollection=!1,re.falloffType=_.Light.FALLOFF_GLTF,re.diffuse=Y.color?_.Color3.FromArray(Y.color):_.Color3.White(),re.intensity=Y.intensity==null?1:Y.intensity,re.range=Y.range==null?Number.MAX_VALUE:Y.range,re.parent=oe,L._loader._babylonLights.push(re),x.b.AddPointerMetadata(re,G),$(oe)})})},ae}();x.b.RegisterExtension("KHR_lights_punctual",function(ae){return new c(ae)});var E=function(){function ae(ee){this.name="KHR_materials_pbrSpecularGlossiness",this.order=200,this._loader=ee,this.enabled=this._loader.isExtensionUsed("KHR_materials_pbrSpecularGlossiness")}return ae.prototype.dispose=function(){this._loader=null},ae.prototype.loadMaterialPropertiesAsync=function(ee,K,$){var L=this;return x.b.LoadExtensionAsync(ee,K,this.name,function(G,Q){var oe=new Array;return oe.push(L._loader.loadMaterialBasePropertiesAsync(ee,K,$)),oe.push(L._loadSpecularGlossinessPropertiesAsync(G,K,Q,$)),L._loader.loadMaterialAlphaProperties(ee,K,$),Promise.all(oe).then(function(){})})},ae.prototype._loadSpecularGlossinessPropertiesAsync=function(ee,K,$,L){if(!(L instanceof _.PBR
13259Material))throw new Error(ee+": Material type not supported");var G=new Array;return L.metallic=null,L.roughness=null,$.diffuseFactor?(L.albedoColor=_.Color3.FromArray($.diffuseFactor),L.alpha=$.diffuseFactor[3]):L.albedoColor=_.Color3.White(),L.reflectivityColor=$.specularFactor?_.Color3.FromArray($.specularFactor):_.Color3.White(),L.microSurface=$.glossinessFactor==null?1:$.glossinessFactor,$.diffuseTexture&&G.push(this._loader.loadTextureInfoAsync(ee+"/diffuseTexture",$.diffuseTexture,function(Q){Q.name=L.name+" (Diffuse)",L.albedoTexture=Q})),$.specularGlossinessTexture&&($.specularGlossinessTexture.nonColorData=!0,G.push(this._loader.loadTextureInfoAsync(ee+"/specularGlossinessTexture",$.specularGlossinessTexture,function(Q){Q.name=L.name+" (Specular Glossiness)",L.reflectivityTexture=Q})),L.reflectivityTexture.hasAlpha=!0,L.useMicroSurfaceFromReflectivityMapAlpha=!0),Promise.all(G).then(function(){})},ae}();x.b.RegisterExtension("KHR_materials_pbrSpecularGlossiness",function(ae){return new E(ae)});var A=function(){function ae(ee){this.name="KHR_materials_unlit",this.order=210,this._loader=ee,this.enabled=this._loader.isExtensionUsed("KHR_materials_unlit")}return ae.prototype.dispose=function(){this._loader=null},ae.prototype.loadMaterialPropertiesAsync=function(ee,K,$){var L=this;return x.b.LoadExtensionAsync(ee,K,this.name,function(){return L._loadUnlitPropertiesAsync(ee,K,$)})},ae.prototype._loadUnlitPropertiesAsync=function(ee,K,$){if(!($ instanceof _.PBR
13259Material))throw new Error(ee+": Material type not supported");var L=new Array;$.unlit=!0;var G=K.pbrMetallicRoughness;return G&&(G.baseColorFactor?($.albedoColor=_.Color3.FromArray(G.baseColorFactor),$.alpha=G.baseColorFactor[3]):$.albedoColor=_.Color3.White(),G.baseColorTexture&&L.push(this._loader.loadTextureInfoAsync(ee+"/baseColorTexture",G.baseColorTexture,function(Q){Q.name=$.name+" (Base Color)",$.albedoTexture=Q}))),K.doubleSided&&($.backFaceCulling=!1,$.twoSidedLighting=!0),this._loader.loadMaterialAlphaProperties(ee,K,$),Promise.all(L).then(function(){})},ae}();x.b.RegisterExtension("KHR_materials_unlit",function(ae){return new A(ae)});var S=function(){function ae(ee){this.name="KHR_materials_clearcoat",this.order=190,this._loader=ee,this.enabled=this._loader.isExtensionUsed("KHR_materials_clearcoat")}return ae.prototype.dispose=function(){this._loader=null},ae.prototype.loadMaterialPropertiesAsync=function(ee,K,$){var L=this;return x.b.LoadExtensionAsync(ee,K,this.name,function(G,Q){var oe=new Array;return oe.push(L._loader.loadMaterialPropertiesAsync(ee,K,$)),oe.push(L._loadClearCoatPropertiesAsync(G,Q,$)),Promise.all(oe).then(function(){})})},ae.prototype._loadClearCoatPropertiesAsync=function(ee,K,$){if(!($ instanceof _.PBR
13259Material))throw new Error(ee+": Material type not supported");var L=new Array;return $.clearCoat.isEnabled=!0,$.clearCoat.useRoughnessFromMainTexture=!1,$.clearCoat.remapF0OnInterfaceChange=!1,K.clearcoatFactor!=null?$.clearCoat.intensity=K.clearcoatFactor:$.clearCoat.intensity=0,K.clearcoatTexture&&L.push(this._loader.loadTextureInfoAsync(ee+"/clearcoatTexture",K.clearcoatTexture,function(G){G.name=$.name+" (ClearCoat Intensity)",$.clearCoat.texture=G})),K.clearcoatRoughnessFactor!=null?$.clearCoat.roughness=K.clearcoatRoughnessFactor:$.clearCoat.roughness=0,K.clearcoatRoughnessTexture&&(K.clearcoatRoughnessTexture.nonColorData=!0,L.push(this._loader.loadTextureInfoAsync(ee+"/clearcoatRoughnessTexture",K.clearcoatRoughnessTexture,function(G){G.name=$.name+" (ClearCoat Roughness)",$.clearCoat.textureRoughness=G}))),K.clearcoatNormalTexture&&(K.clearcoatNormalTexture.nonColorData=!0,L.push(this._loader.loadTextureInfoAsync(ee+"/clearcoatNormalTexture",K.clearcoatNormalTexture,function(G){G.name=$.name+" (ClearCoat Normal)",$.clearCoat.bumpTexture=G})),$.invertNormalMapX=!$.getScene().useRightHandedSystem,$.invertNormalMapY=$.getScene().useRightHandedSystem,K.clearcoatNormalTexture.scale!=null&&($.clearCoat.bumpTexture.level=K.clearcoatNormalTexture.scale)),Promise.all(L).then(function(){})},ae}();x.b.RegisterExtension("KHR_materials_clearcoat",function(ae){return new S(ae)});var g=function(){function ae(ee){this.name="KHR_materials_sheen",this.order=190,this._loader=ee,this.enabled=this._loader.isExtensionUsed("KHR_materials_sheen")}return ae.prototype.dispose=function(){this._loader=null},ae.prototype.loadMaterialPropertiesAsync=function(ee,K,$){var L=this;return x.b.LoadExtensionAsync(ee,K,this.name,function(G,Q){var oe=new Array;return oe.push(L._loader.loadMaterialPropertiesAsync(ee,K,$)),oe.push(L._loadSheenPropertiesAsync(G,Q,$)),Promise.all(oe).then(function(){})})},ae.prototype._loadSheenPropertiesAsync=function(ee,K,$){if(!($ instanceof _.PBR
13259Material))throw new Error(ee+": Material type not supported");var L=new Array;return $.sheen.isEnabled=!0,$.sheen.intensity=1,K.sheenColorFactor!=null?$.sheen.color=_.Color3.FromArray(K.sheenColorFactor):$.sheen.color=_.Color3.Black(),K.sheenColorTexture&&L.push(this._loader.loadTextureInfoAsync(ee+"/sheenColorTexture",K.sheenColorTexture,function(G){G.name=$.name+" (Sheen Color)",$.sheen.texture=G})),K.sheenRoughnessFactor!==void 0?$.sheen.roughness=K.sheenRoughnessFactor:$.sheen.roughness=0,K.sheenRoughnessTexture&&(K.sheenRoughnessTexture.nonColorData=!0,L.push(this._loader.loadTextureInfoAsync(ee+"/sheenRoughnessTexture",K.sheenRoughnessTexture,function(G){G.name=$.name+" (Sheen Roughness)",$.sheen.textureRoughness=G}))),$.sheen.albedoScaling=!0,$.sheen.useRoughnessFromMainTexture=!1,Promise.all(L).then(function(){})},ae}();x.b.RegisterExtension("KHR_materials_sheen",function(ae){return new g(ae)});var l=function(){function ae(ee){this.name="KHR_materials_specular",this.order=190,this._loader=ee,this.enabled=this._loader.isExtensionUsed("KHR_materials_specular")}return ae.prototype.dispose=function(){this._loader=null},ae.prototype.loadMaterialPropertiesAsync=function(ee,K,$){var L=this;return x.b.LoadExtensionAsync(ee,K,this.name,function(G,Q){var oe=new Array;return oe.push(L._loader.loadMaterialPropertiesAsync(ee,K,$)),oe.push(L._loadSpecularPropertiesAsync(G,Q,$)),Promise.all(oe).then(function(){})})},ae.prototype._loadSpecularPropertiesAsync=function(ee,K,$){if(!($ instanceof _.PBR
13259Material))throw new Error(ee+": Material type not supported");var L=new Array;return K.specularFactor!==void 0&&($.metallicF0Factor=K.specularFactor),K.specularColorFactor!==void 0&&($.metallicReflectanceColor=_.Color3.FromArray(K.specularColorFactor)),K.specularTexture&&(K.specularTexture.nonColorData=!0,L.push(this._loader.loadTextureInfoAsync(ee+"/specularTexture",K.specularTexture,function(G){G.name=$.name+" (Specular F0 Color)",$.metallicReflectanceTexture=G}))),Promise.all(L).then(function(){})},ae}();x.b.RegisterExtension("KHR_materials_specular",function(ae){return new l(ae)});var h=function(){function ae(ee){this.name="KHR_materials_ior",this.order=180,this._loader=ee,this.enabled=this._loader.isExtensionUsed("KHR_materials_ior")}return ae.prototype.dispose=function(){this._loader=null},ae.prototype.loadMaterialPropertiesAsync=function(ee,K,$){var L=this;return x.b.LoadExtensionAsync(ee,K,this.name,function(G,Q){var oe=new Array;return oe.push(L._loader.loadMaterialPropertiesAsync(ee,K,$)),oe.push(L._loadIorPropertiesAsync(G,Q,$)),Promise.all(oe).then(function(){})})},ae.prototype._loadIorPropertiesAsync=function(ee,K,$){if(!($ instanceof _.PBR
13259Material))throw new Error(ee+": Material type not supported");return K.ior!==void 0?$.indexOfRefraction=K.ior:$.indexOfRefraction=ae._DEFAULT_IOR,Promise.resolve()},ae._DEFAULT_IOR=1.5,ae}();x.b.RegisterExtension("KHR_materials_ior",function(ae){return new h(ae)});var b=function(){function ae(ee){this.name="KHR_materials_variants",this._loader=ee,this.enabled=this._loader.isExtensionUsed("KHR_materials_variants")}return ae.prototype.dispose=function(){this._loader=null},ae.GetAvailableVariants=function(ee){var K=this._GetExtensionMetadata(ee);return K?Object.keys(K.variants):[]},ae.prototype.getAvailableVariants=function(ee){return ae.GetAvailableVariants(ee)},ae.SelectVariant=function(ee,K){var $=this._GetExtensionMetadata(ee);if(!$)throw new Error("Cannot select variant on a glTF mesh that does not have the KHR_materials_variants extension");var L=function(oe){var re=$.variants[oe];if(re)for(var Y=0,k=re;Y<k.length;Y++){var H=k[Y];H.mesh.material=H.material}};if(K instanceof Array)for(var G=0,Q=K;G<Q.length;G++)L(Q[G]);else L(K);$.lastSelected=K},ae.prototype.selectVariant=function(ee,K){return ae.SelectVariant(ee,K)},ae.Reset=function(ee){var K=this._GetExtensionMetadata(ee);if(!K)throw new Error("Cannot reset on a glTF mesh that does not have the KHR_materials_variants extension");for(var $=0,L=K.original;$<L.length;$++){var G=L[$];G.mesh.material=G.material}K.lastSelected=null},ae.prototype.reset=function(ee){return ae.Reset(ee)},ae.GetLastSelectedVariant=function(ee){var K=this._GetExtensionMetadata(ee);if(!K)throw new Error("Cannot get the last selected variant on a glTF mesh that does not have the KHR_materials_variants extension");return K.lastSelected},ae.prototype.getLastSelectedVariant=function(ee){return ae.GetLastSelectedVariant(ee)},ae._GetExtensionMetadata=function(ee){var K,$;return(($=(K=ee?.metadata)===null||K===void 0?void 0:K.gltf)===null||$===void 0?void 0:$.KHR_materials_variants)||null},ae.prototype.onLoading=function(){var ee=this._loader.gltf.extensions;if(ee&&ee[this.name]){var K=ee[this.name];this._variants=K.variants}},ae.prototype._loadMeshPrimitiveAsync=function(ee,K,$,L,G,Q){var oe=this;return x.b.LoadExtensionAsync(ee,G,this.name,function(re,Y){var k=new Array;return k.push(oe._loader._loadMeshPrimitiveAsync(ee,K,$,L,G,function(H){if(Q(H),H instanceof _.Mesh){var Z=x.b._GetDrawMode(ee,G.mode),X=oe._loader.rootBabylonMesh,q=X.metadata=X.metadata||{},he=q.gltf=q.gltf||{},ge=he.KHR_materials_variants=he.KHR_materials_variants||{lastSelected:null,original:[],variants:{}};ge.original.push({mesh:H,material:H.material});for(var me=ge.variants,_e=0,be=Y.mappings;_e<be.length;_e++)for(var Ce=be[_e],ye=function(Xe){var He=x.a.Get(re+"/mapping/"+Xe,oe._variants,Xe),We=x.a.Get("#/materials/",oe._loader.gltf.materials,Ce.material);k.push(oe._loader._loadMaterialAsync("#/materials/"+Ce.material,We,H,Z,function(Ze){me[He.name]=me[He.name]||[],me[He.name].push({mesh:H,material:Ze})}))},Be=0,Ge=Ce.variants;Be<Ge.length;Be++)ye(Ge[Be])}})),Promise.all(k).then(function(H){return H[0]})})},ae}();x.b.RegisterExtension("KHR_materials_variants",function(ae){return new b(ae)});var T=B(4),D=function(){function ae(ee,K){var $=this;this._opaqueRenderTarget=null,this._opaqueMeshesCache=[],this._transparentMeshesCache=[],this._options=Object(T.a)(Object(T.a)({},ae._getDefaultOptions()),ee),this._scene=K,this._scene._transmissionHelper=this,this.onErrorObservable=new _.Observable,this._scene.onDisposeObservable.addOnce(function(L){$.dispose()}),this._parseScene(),this._setupRenderTargets()}return ae._getDefaultOptions=function(){return{renderSize:512}},ae.prototype.updateOptions=function(ee){var K=this;if(Object.keys(ee).filter(function(G){return K._options[G]!==ee[G]}).length){var $=Object(T.a)(Object(T.a)({},this._options),ee),L=this._options;this._options=$,$.renderSize!==L.renderSize&&this._setupRenderTargets()}},ae.prototype.getOpaqueTarget=function(){return this._opaqueRenderTarget},ae.prototype.shouldRenderAsTransmission=function(ee){return!!ee&&!!(ee instanceof _.PBR
13259Material&&ee.subSurface.isRefractionEnabled)},ae.prototype._addMesh=function(ee){ee instanceof _.Mesh&&(ee.onMaterialChangedObservable.add(this.onMeshMaterialChanged.bind(this)),this.shouldRenderAsTransmission(ee.material)?this._transparentMeshesCache.push(ee):this._opaqueMeshesCache.push(ee))},ae.prototype._removeMesh=function(ee){if(ee instanceof _.Mesh){ee.onMaterialChangedObservable.remove(this.onMeshMaterialChanged.bind(this));var K=this._transparentMeshesCache.indexOf(ee);K!==-1&&this._transparentMeshesCache.splice(K,1),(K=this._opaqueMeshesCache.indexOf(ee))!==-1&&this._opaqueMeshesCache.splice(K,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(ee){if(ee instanceof _.Mesh){var K=this._transparentMeshesCache.indexOf(ee),$=this._opaqueMeshesCache.indexOf(ee);this.shouldRenderAsTransmission(ee.material)?(ee.material instanceof _.PBR
13259Material&&(ee.material.subSurface.refractionTexture=this._opaqueRenderTarget),$!==-1?(this._opaqueMeshesCache.splice($,1),this._transparentMeshesCache.push(ee)):K===-1&&this._transparentMeshesCache.push(ee)):K!==-1?(this._transparentMeshesCache.splice(K,1),this._opaqueMeshesCache.push(ee)):$===-1&&this._opaqueMeshesCache.push(ee)}},ae.prototype._setupRenderTargets=function(){var ee=this,K=-1;if(this._scene.layers&&this._opaqueRenderTarget)for(var $=0,L=this._scene.layers;$<L.length;$++){var G=(re=L[$]).renderTargetTextures.indexOf(this._opaqueRenderTarget);G>=0&&re.renderTargetTextures.splice(G,1)}if(this._opaqueRenderTarget&&(K=this._scene.customRenderTargets.indexOf(this._opaqueRenderTarget),this._opaqueRenderTarget.dispose()),this._opaqueRenderTarget=new _.RenderTargetTexture("opaqueSceneTexture",this._options.renderSize,this._scene,!0),this._opaqueRenderTarget.renderList=this._opaqueMeshesCache,this._opaqueRenderTarget.gammaSpace=!0,this._opaqueRenderTarget.lodGenerationScale=1,this._opaqueRenderTarget.lodGenerationOffset=-4,K>=0?this._scene.customRenderTargets.splice(K,0,this._opaqueRenderTarget):(K=this._scene.customRenderTargets.length,this._scene.customRenderTargets.push(this._opaqueRenderTarget)),this._scene.layers&&this._opaqueRenderTarget)for(var Q=0,oe=this._scene.layers;Q<oe.length;Q++){var re;(re=oe[Q]).renderTargetTextures.push(this._opaqueRenderTarget)}this._transparentMeshesCache.forEach(function(Y){ee.shouldRenderAsTransmission(Y.material)&&Y.material instanceof _.PBR
13259Material&&(Y.material.refractionTexture=ee._opaqueRenderTarget)})},ae.prototype.dispose=function(){this._scene._transmissionHelper=void 0,this._opaqueRenderTarget&&(this._opaqueRenderTarget.dispose(),this._opaqueRenderTarget=null),this._transparentMeshesCache=[],this._opaqueMeshesCache=[]},ae}(),w=function(){function ae(ee){this.name="KHR_materials_transmission",this.order=175,this._loader=ee,this.enabled=this._loader.isExtensionUsed("KHR_materials_transmission"),this.enabled&&(ee.parent.transparencyAsCoverage=!0)}return ae.prototype.dispose=function(){this._loader=null},ae.prototype.loadMaterialPropertiesAsync=function(ee,K,$){var L=this;return x.b.LoadExtensionAsync(ee,K,this.name,function(G,Q){var oe=new Array;return oe.push(L._loader.loadMaterialBasePropertiesAsync(ee,K,$)),oe.push(L._loader.loadMaterialPropertiesAsync(ee,K,$)),oe.push(L._loadTransparentPropertiesAsync(G,K,$,Q)),Promise.all(oe).then(function(){})})},ae.prototype._loadTransparentPropertiesAsync=function(ee,K,$,L){if(!($ instanceof _.PBRMaterial))throw new Error(ee+": Material type not supported");var G=$;if(G.subSurface.isRefractionEnabled=!0,G.subSurface.volumeIndexOfRefraction=1,G.subSurface.useAlbedoToTintRefraction=!0,L.transmissionFactor===void 0)return G.subSurface.refractionIntensity=0,G.subSurface.isRefractionEnabled=!1,Promise.resolve();G.subSurface.refractionIntensity=L.transmissionFactor;var Q=G.getScene();return G.subSurface.refractionIntensity&&!Q._transmissionHelper&&new D({},G.getScene()),L.transmissionTexture?(L.transmissionTexture.nonColorData=!0,this._loader.loadTextureInfoAsync(ee+"/transmissionTexture",L.transmissionTexture,void 0).then(function(oe){G.subSurface.thicknessTexture=oe,G.subSurface.useMaskFromThicknessTextureGltf=!0})):Promise.resolve()},ae}();x.b.RegisterExtension("KHR_materials_transmission",function(ae){return new w(ae)});var N=function(){function ae(ee){this.name="KHR_materials_translucency",this.order=175,this._loader=ee,this.enabled=this._loader.isExtensionUsed("KHR_materials_translucency"),this.enabled&&(ee.parent.transparencyAsCoverage=!0)}return ae.prototype.dispose=function(){this._loader=null},ae.prototype.loadMaterialPropertiesAsync=function(ee,K,$){var L=this;return x.b.LoadExtensionAsync(ee,K,this.name,function(G,Q){var oe=new Array;return oe.push(L._loader.loadMaterialBasePropertiesAsync(ee,K,$)),oe.push(L._loader.loadMaterialPropertiesAsync(ee,K,$)),oe.push(L._loadTranslucentPropertiesAsync(G,K,$,Q)),Promise.all(oe).then(function(){})})},ae.prototype._loadTranslucentPropertiesAsync=function(ee,K,$,L){if(!($ instanceof _.PBR
13259Material))throw new Error(ee+": Material type not supported");var G=$;return G.subSurface.isTranslucencyEnabled=!0,G.subSurface.volumeIndexOfRefraction=1,G.subSurface.minimumThickness=0,G.subSurface.maximumThickness=0,G.subSurface.useAlbedoToTintRefraction=!0,L.translucencyFactor===void 0?(G.subSurface.translucencyIntensity=0,G.subSurface.isTranslucencyEnabled=!1,Promise.resolve()):(G.subSurface.translucencyIntensity=L.translucencyFactor,L.translucencyTexture?this._loader.loadTextureInfoAsync(ee+"/translucencyTexture",L.translucencyTexture).then(function(Q){G.subSurface.thicknessTexture=Q,G.subSurface.useMaskFromThicknessTextureGltf=!0}):Promise.resolve())},ae}();x.b.RegisterExtension("KHR_materials_translucency",function(ae){return new N(ae)});var I=function(){function ae(ee){this.name="KHR_mesh_quantization",this.enabled=ee.isExtensionUsed("KHR_mesh_quantization")}return ae.prototype.dispose=function(){},ae}();x.b.RegisterExtension("KHR_mesh_quantization",function(ae){return new I(ae)});var V=function(){function ae(ee){this.name="KHR_texture_basisu",this._loader=ee,this.enabled=ee.isExtensionUsed("KHR_texture_basisu")}return ae.prototype.dispose=function(){this._loader=null},ae.prototype._loadTextureAsync=function(ee,K,$){var L=this;return x.b.LoadExtensionAsync(ee,K,this.name,function(G,Q){var oe=K.sampler==null?x.b.DefaultSampler:x.a.Get(ee+"/sampler",L._loader.gltf.samplers,K.sampler),re=x.a.Get(G+"/source",L._loader.gltf.images,Q.source);return L._loader._createTextureAsync(ee,oe,re,function(Y){$(Y)},K._textureInfo.nonColorData?{useRGBAIfASTCBC7NotAvailableWhenUASTC:!0}:void 0)})},ae}();x.b.RegisterExtension("KHR_texture_basisu",function(ae){return new V(ae)});var W=function(){function ae(ee){this.name="KHR_texture_transform",this._loader=ee,this.enabled=this._loader.isExtensionUsed("KHR_texture_transform")}return ae.prototype.dispose=function(){this._loader=null},ae.prototype.loadTextureInfoAsync=function(ee,K,$){var L=this;return x.b.LoadExtensionAsync(ee,K,this.name,function(G,Q){return L._loader.loadTextureInfoAsync(ee,K,function(oe){if(!(oe instanceof _.Texture))throw new Error(G+": Texture type not supported");Q.offset&&(oe.uOffset=Q.offset[0],oe.vOffset=Q.offset[1]),oe.uRotationCenter=0,oe.vRotationCenter=0,Q.rotation&&(oe.wAng=-Q.rotation),Q.scale&&(oe.uScale=Q.scale[0],oe.vScale=Q.scale[1]),Q.texCoord!=null&&(oe.coordinatesIndex=Q.texCoord),$(oe)})})},ae}();x.b.RegisterExtension("KHR_texture_transform",function(ae){return new W(ae)});var j=function(){function ae(ee){this.name="MSFT_audio_emitter",this._loader=ee,this.enabled=this._loader.isExtensionUsed("MSFT_audio_emitter")}return ae.prototype.dispose=function(){this._loader=null,this._clips=null,this._emitters=null},ae.prototype.onLoading=function(){var ee=this._loader.gltf.extensions;if(ee&&ee[this.name]){var K=ee[this.name];this._clips=K.clips,this._emitters=K.emitters,x.a.Assign(this._clips),x.a.Assign(this._emitters)}},ae.prototype.loadSceneAsync=function(ee,K){var $=this;return x.b.LoadExtensionAsync(ee,K,this.name,function(L,G){var Q=new Array;Q.push($._loader.loadSceneAsync(ee,K));for(var oe=0,re=G.emitters;oe<re.length;oe++){var Y=re[oe],k=x.a.Get(L+"/emitters",$._emitters,Y);if(k.refDistance!=null||k.maxDistance!=null||k.rolloffFactor!=null||k.distanceModel!=null||k.innerAngle!=null||k.outerAngle!=null)throw new Error(L+": Direction or Distance properties are not allowed on emitters attached to a scene");Q.push($._loadEmitterAsync(L+"/emitters/"+k.index,k))}return Promise.all(Q).then(function(){})})},ae.prototype.loadNodeAsync=function(ee,K,$){var L=this;return x.b.LoadExtensionAsync(ee,K,this.name,function(G,Q){var oe=new Array;return L._loader.loadNodeAsync(G,K,function(re){for(var Y=function(Z){var X=x.a.Get(G+"/emitters",L._emitters,Z);oe.push(L._loadEmitterAsync(G+"/emitters/"+X.index,X).then(function(){for(var q=0,he=X._babylonSounds;q<he.length;q++){var ge=he[q];ge.attachToMesh(re),X.innerAngle==null&&X.outerAngle==null||(ge.setLocalDirectionToMesh(_.Vector3.Forward()),ge.setDirectionalCone(2*_.Tools.ToDegrees(X.innerAngle==null?Math.PI:X.innerAngle),2*_.Tools.ToDegrees(X.outerAngle==null?Math.PI:X.outerAngle),0))}}))},k=0,H=Q.emitters;k<H.length;k++)Y(H[k]);$(re)}).then(function(re){return Promise.all(oe).then(function(){return re})})})},ae.prototype.loadAnimationAsync=function(ee,K){var $=this;return x.b.LoadExtensionAsync(ee,K,this.name,function(L,G){return $._loader.loadAnimationAsync(ee,K).then(function(Q){var oe=new Array;x.a.Assign(G.events);for(var re=0,Y=G.events;re<Y.length;re++){var k=Y[re];oe.push($._loadAnimationEventAsync(L+"/events/"+k.index,ee,K,k,Q))}return Promise.all(oe).then(function(){return Q})})})},ae.prototype._loadClipAsync=function(ee,K){if(K._objectURL)return K._objectURL;var $;if(K.uri)$=this._loader.loadUriAsync(ee,K,K.uri);else{var L=x.a.Get(ee+"/bufferView",this._loader.gltf.bufferViews,K.bufferView);$=this._loader.loadBufferViewAsync("/bufferViews/"+L.index,L)}return K._objectURL=$.then(function(G){return URL.createObjectURL(new Blob([G],{type:K.mimeType}))}),K._objectURL},ae.prototype._loadEmitterAsync=function(ee,K){var $=this;if(K._babylonSounds=K._babylonSounds||[],!K._babylonData){for(var L=new Array,G=K.name||"emitter"+K.index,Q={loop:!1,autoplay:!1,volume:K.volume==null?1:K.volume},oe=function(H){var Z="/extensions/"+re.name+"/clips",X=x.a.Get(Z,re._clips,K.clips[H].clip);L.push(re._loadClipAsync(Z+"/"+K.clips[H].clip,X).then(function(q){var he=K._babylonSounds[H]=new _.Sound(G,q,$._loader.babylonScene,null,Q);he.refDistance=K.refDistance||1,he.maxDistance=K.maxDistance||256,he.rolloffFactor=K.rolloffFactor||1,he.distanceModel=K.distanceModel||"exponential",he._positionInEmitterSpace=!0}))},re=this,Y=0;Y<K.clips.length;Y++)oe(Y);var k=Promise.all(L).then(function(){var H=K.clips.map(function(X){return X.weight||1}),Z=new _.WeightedSound(K.loop||!1,K._babylonSounds,H);K.innerAngle&&(Z.directionalConeInnerAngle=2*_.Tools.ToDegrees(K.innerAngle)),K.outerAngle&&(Z.directionalConeOuterAngle=2*_.Tools.ToDegrees(K.outerAngle)),K.volume&&(Z.volume=K.volume),K._babylonData.sound=Z});K._babylonData={loaded:k}}return K._babylonData.loaded},ae.prototype._getEventAction=function(ee,K,$,L,G){switch($){case"play":return function(Q){var oe=(G||0)+(Q-L);K.play(oe)};case"stop":return function(Q){K.stop()};case"pause":return function(Q){K.pause()};default:throw new Error(ee+": Unsupported action "+$)}},ae.prototype._loadAnimationEventAsync=function(ee,K,$,L,G){var Q=this;if(G.targetedAnimations.length==0)return Promise.resolve();
13259var oe=G.targetedAnimations[0],re=L.emitter,Y=x.a.Get("/extensions/"+this.name+"/emitters",this._emitters,re);return this._loadEmitterAsync(ee,Y).then(function(){var k=Y._babylonData.sound;if(k){var H=new _.AnimationEvent(L.time,Q._getEventAction(ee,k,L.action,L.time,L.startOffset));oe.animation.addEvent(H),G.onAnimationGroupEndObservable.add(function(){k.stop()}),G.onAnimationGroupPauseObservable.add(function(){k.pause()})}})},ae}();x.b.RegisterExtension("MSFT_audio_emitter",function(ae){return new j(ae)});var ne=function(){function ae(ee){this.name="MSFT_lod",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=ee,this.enabled=this._loader.isExtensionUsed("MSFT_lod")}return ae.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()},ae.prototype.onReady=function(){for(var ee=this,K=function(oe){var re=Promise.all($._nodePromiseLODs[oe]).then(function(){oe!==0&&(ee._loader.endPerformanceCounter("Node LOD "+oe),ee._loader.log("Loaded node LOD "+oe)),ee.onNodeLODsLoadedObservable.notifyObservers(oe),oe!==ee._nodePromiseLODs.length-1&&(ee._loader.startPerformanceCounter("Node LOD "+(oe+1)),ee._loadBufferLOD(ee._nodeBufferLODs,oe+1),ee._nodeSignalLODs[oe]&&ee._nodeSignalLODs[oe].resolve())});$._loader._completePromises.push(re)},$=this,L=0;L<this._nodePromiseLODs.length;L++)K(L);var G=function(oe){var re=Promise.all(Q._materialPromiseLODs[oe]).then(function(){oe!==0&&(ee._loader.endPerformanceCounter("Material LOD "+oe),ee._loader.log("Loaded material LOD "+oe)),ee.onMaterialLODsLoadedObservable.notifyObservers(oe),oe!==ee._materialPromiseLODs.length-1&&(ee._loader.startPerformanceCounter("Material LOD "+(oe+1)),ee._loadBufferLOD(ee._materialBufferLODs,oe+1),ee._materialSignalLODs[oe]&&ee._materialSignalLODs[oe].resolve())});Q._loader._completePromises.push(re)},Q=this;for(L=0;L<this._materialPromiseLODs.length;L++)G(L)},ae.prototype.loadSceneAsync=function(ee,K){var $=this._loader.loadSceneAsync(ee,K);return this._loadBufferLOD(this._bufferLODs,0),$},ae.prototype.loadNodeAsync=function(ee,K,$){var L=this;return x.b.LoadExtensionAsync(ee,K,this.name,function(G,Q){var oe,re=L._getLODs(G,K,L._loader.gltf.nodes,Q.ids);L._loader.logOpen(""+G);for(var Y=function(H){var Z=re[H];H!==0&&(L._nodeIndexLOD=H,L._nodeSignalLODs[H]=L._nodeSignalLODs[H]||new _.Deferred);var X=L._loader.loadNodeAsync("/nodes/"+Z.index,Z,function(q){q.setEnabled(!1)}).then(function(q){if(H!==0){var he=re[H-1];he._babylonTransformNode&&(L._disposeTransformNode(he._babylonTransformNode),delete he._babylonTransformNode)}return q.setEnabled(!0),q});L._nodePromiseLODs[H]=L._nodePromiseLODs[H]||[],H===0?oe=X:(L._nodeIndexLOD=null,L._nodePromiseLODs[H].push(X))}
13259,k=0;k<re.length;k++)Y(k);return L._loader.logClose(),oe})},ae.prototype._loadMaterialAsync=function(ee,K,$,L,G){var Q=this;return this._nodeIndexLOD?null:x.b.LoadExtensionAsync(ee,K,this.name,function(oe,re){var Y,k=Q._getLODs(oe,K,Q._loader.gltf.materials,re.ids);Q._loader.logOpen(""+oe);for(var H=function(X){var q=k[X];X!==0&&(Q._materialIndexLOD=X);var he=Q._loader._loadMaterialAsync("/materials/"+q.index,q,$,L,function(ge){X===0&&G(ge)}).then(function(ge){if(X!==0){G(ge);var me=k[X-1]._data;me[L]&&(Q._disposeMaterials([me[L].babylonMaterial]),delete me[L])}return ge});Q._materialPromiseLODs[X]=Q._materialPromiseLODs[X]||[],X===0?Y=he:(Q._materialIndexLOD=null,Q._materialPromiseLODs[X].push(he))},Z=0;Z<k.length;Z++)H(Z);return Q._loader.logClose(),Y})},ae.prototype._loadUriAsync=function(ee,K,$){var L=this;if(this._nodeIndexLOD!==null){this._loader.log("deferred");var G=this._nodeIndexLOD-1;return this._nodeSignalLODs[G]=this._nodeSignalLODs[G]||new _.Deferred,this._nodeSignalLODs[this._nodeIndexLOD-1].promise.then(function(){return L._loader.loadUriAsync(ee,K,$)})}return this._materialIndexLOD!==null?(this._loader.log("deferred"),G=this._materialIndexLOD-1,this._materialSignalLODs[G]=this._materialSignalLODs[G]||new _.Deferred,this._materialSignalLODs[G].promise.then(function(){return L._loader.loadUriAsync(ee,K,$)})):null},ae.prototype.loadBufferAsync=function(ee,K,$,L){if(this._loader.parent.useRangeRequests&&!K.uri){if(!this._loader.bin)throw new Error(ee+": Uri is missing or the binary glTF is missing its binary chunk");var G=function(Q,oe){var re=$,Y=re+L-1,k=Q[oe];return k?(k.start=Math.min(k.start,re),k.end=Math.max(k.end,Y)):(k={start:re,end:Y,loaded:new _.Deferred},Q[oe]=k),k.loaded.promise.then(function(H){return new Uint8Array(H.buffer,H.byteOffset+$-k.start,L)})};return this._loader.log("deferred"),this._nodeIndexLOD!==null?G(this._nodeBufferLODs,this._nodeIndexLOD):this._materialIndexLOD!==null?G(this._materialBufferLODs,this._materialIndexLOD):G(this._bufferLODs,0)}return null},ae.prototype._loadBufferLOD=function(ee,K){var $=ee[K];$&&(this._loader.log("Loading buffer range ["+$.start+"-"+$.end+"]"),this._loader.bin.readAsync($.start,$.end-$.start+1).then(function(L){$.loaded.resolve(L)},function(L){$.loaded.reject(L)}))},ae.prototype._getLODs=function(ee,K,$,L){if(this.maxLODsToLoad<=0)throw new Error("maxLODsToLoad must be greater than zero");for(var G=new Array,Q=L.length-1;Q>=0;Q--)if(G.push(x.a.Get(ee+"/ids/"+L[Q],$,L[Q])),G.length===this.maxLODsToLoad)return G;return G.push(K),G},ae.prototype._disposeTransformNode=function(ee){var K=this,$=new Array,L=ee.material;L&&$.push(L);for(var G=0,Q=ee.getChildMeshes();G<Q.length;G++){var oe=Q[G];oe.material&&$.push(oe.material)}ee.dispose();var re=$.filter(function(Y){return K._loader.babylonScene.meshes.every(function(k){return k.material!=Y})});this._disposeMaterials(re)},ae.prototype._disposeMaterials=function(ee){for(var K={},$=0,L=ee;$<L.length;$++){for(var G=0,Q=(H=L[$]).getActiveTextures();G<Q.length;G++){var oe=Q[G];K[oe.uniqueId]=oe}H.dispose()}for(var re in K)for(var Y=0,k=this._loader.babylonScene.materials;Y<k.length;Y++){var H;(H=k[Y]).hasTexture(K[re])&&delete K[re]}for(var re in K)K[re].dispose()},ae}();x.b.RegisterExtension("MSFT_lod",function(ae){return new ne(ae)});var te=function(){function ae(ee){this.name="MSFT_minecraftMesh",this._loader=ee,this.enabled=this._loader.isExtensionUsed("MSFT_minecraftMesh")}return ae.prototype.dispose=function(){this._loader=null},ae.prototype.loadMaterialPropertiesAsync=function(ee,K,$){var L=this;return x.b.LoadExtraAsync(ee,K,this.name,function(G,Q){if(Q){if(!($ instanceof _.PBR
13259Material))throw new Error(G+": Material type not supported");var oe=L._loader.loadMaterialPropertiesAsync(ee,K,$);return $.needAlphaBlending()&&($.forceDepthWrite=!0,$.separateCullingPass=!0),$.backFaceCulling=$.forceDepthWrite,$.twoSidedLighting=!0,oe}return null})},ae}();x.b.RegisterExtension("MSFT_minecraftMesh",function(ae){return new te(ae)});var de=function(){function ae(ee){this.name="MSFT_sRGBFactors",this._loader=ee,this.enabled=this._loader.isExtensionUsed("MSFT_sRGBFactors")}return ae.prototype.dispose=function(){this._loader=null},ae.prototype.loadMaterialPropertiesAsync=function(ee,K,$){var L=this;return x.b.LoadExtraAsync(ee,K,this.name,function(G,Q){if(Q){if(!($ instanceof _.PBRMaterial))throw new Error(G+": Material type not supported");var oe=L._loader.loadMaterialPropertiesAsync(ee,K,$);return $.albedoTexture||$.albedoColor.toLinearSpaceToRef($.albedoColor),$.reflectivityTexture||$.reflectivityColor.toLinearSpaceToRef($.reflectivityColor),oe}return null})},ae}();x.b.RegisterExtension("MSFT_sRGBFactors",function(ae){return new de(ae)});var pe=function(){function ae(ee){this.name="ExtrasAsMetadata",this.enabled=!0,this._loader=ee}return ae.prototype._assignExtras=function(ee,K){if(K.extras&&Object.keys(K.extras).length>0){var $=ee.metadata=ee.metadata||{};($.gltf=$.gltf||{}).extras=K.extras}},ae.prototype.dispose=function(){this._loader=null},ae.prototype.loadNodeAsync=function(ee,K,$){var L=this;return this._loader.loadNodeAsync(ee,K,function(G){L._assignExtras(G,K),$(G)})},ae.prototype.loadCameraAsync=function(ee,K,$){var L=this;return this._loader.loadCameraAsync(ee,K,function(G){L._assignExtras(G,K),$(G)})},ae.prototype.createMaterial=function(ee,K,$){var L=this._loader.createMaterial(ee,K,$);return this._assignExtras(L,K),L},ae}();x.b.RegisterExtension("ExtrasAsMetadata",function(ae){return new pe(ae)})},function(v,f,B){B.r(f),B.d(f,"GLTFBinaryExtension",function(){return H}),B.d(f,"GLTFLoaderBase",function(){return re}),B.d(f,"GLTFLoader",function(){return Y}),B.d(f,"GLTFLoaderExtension",function(){return k}),B.d(f,"EComponentType",function(){return _}),B.d(f,"EShaderType",function(){return x}),B.d(f,"EParameterType",function(){return u}),B.d(f,"ETextureWrapMode",function(){return M}),B.d(f,"ETextureFilterType",function(){return R}),B.d(f,"ETextureFormat",function(){return C}),B.d(f,"ECullingType",function(){return m}),B.d(f,"EBlendingFunction",function(){return c}),B.d(f,"GLTFUtils",function(){return g}),B.d(f,"GLTFMaterialsCommonExtension",function(){return Z});var _,x,u,M,R,C,m,c,E=B(4);(function(X){X[X.BYTE=5120]="BYTE",X[X.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",X[X.SHORT=5122]="SHORT",X[X.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",X[X.FLOAT=5126]="FLOAT"})(_||(_={})),function(X){X[X.FRAGMENT=35632]="FRAGMENT",X[X.VERTEX=35633]="VERTEX"}(x||(x={})),function(X){X[X.BYTE=5120]="BYTE",X[X.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",X[X.SHORT=5122]="SHORT",X[X.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",X[X.INT=5124]="INT",X[X.UNSIGNED_INT=5125]="UNSIGNED_INT",X[X.FLOAT=5126]="FLOAT",X[X.FLOAT_VEC2=35664]="FLOAT_VEC2",X[X.FLOAT_VEC3=35665]="FLOAT_VEC3",X[X.FLOAT_VEC4=35666]="FLOAT_VEC4",X[X.INT_VEC2=35667]="INT_VEC2",X[X.INT_VEC3=35668]="INT_VEC3",X[X.INT_VEC4=35669]="INT_VEC4",X[X.BOOL=35670]="BOOL",X[X.BOOL_VEC2=35671]="BOOL_VEC2",X[X.BOOL_VEC3=35672]="BOOL_VEC3",X[X.BOOL_VEC4=35673]="BOOL_VEC4",X[X.FLOAT_MAT2=35674]="FLOAT_MAT2",X[X.FLOAT_MAT3=35675]="FLOAT_MAT3",X[X.FLOAT_MAT4=35676]="FLOAT_MAT4",X[X.SAMPLER_2D=35678]="SAMPLER_2D"}(u||(u={})),function(X){X[X.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",X[X.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",X[X.REPEAT=10497]="REPEAT"}(M||(M={})),function(X){X[X.NEAREST=9728]="NEAREST",X[X.LINEAR=9728]="LINEAR",X[X.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",X[X.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",X[X.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",X[X.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR"}(R||(R={})),function(X){X[X.ALPHA=6406]="ALPHA",X[X.RGB=6407]="RGB",X[X.RGBA=6408]="RGBA",X[X.LUMINANCE=6409]="LUMINANCE",X[X.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA"}(C||(C={})),function(X){X[X.FRONT=1028]="FRONT",X[X.BACK=1029]="BACK",X[X.FRONT_AND_BACK=1032]="FRONT_AND_BACK"}(m||(m={})),function(X){X[X.ZERO=0]="ZERO",X[X.ONE=1]="ONE",X[X.SRC_COLOR=768]="SRC_COLOR",X[X.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",X[X.DST_COLOR=774]="DST_COLOR",X[X.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",X[X.SRC_ALPHA=770]="SRC_ALPHA",X[X.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",X[X.DST_ALPHA=772]="DST_ALPHA",X[X.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",X[X.CONSTANT_COLOR=32769]="CONSTANT_COLOR",X[X.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",X[X.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",X[X.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",X[X.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE"}(c||(c={}));var A,S=B(0),g=function(){function X(){}return X.SetMatrix=function(q,he,ge,me,_e){var be=null;if(ge.semantic==="MODEL"?be=he.getWorldMatrix():ge.semantic==="PROJECTION"?be=q.getProjectionMatrix():ge.semantic==="VIEW"?be=q.getViewMatrix():ge.semantic==="MODELVIEWINVERSETRANSPOSE"?be=S.Matrix.Transpose(he.getWorldMatrix().multiply(q.getViewMatrix()).invert()):ge.semantic==="MODELVIEW"?be=he.getWorldMatrix().multiply(q.getViewMatrix()):ge.semantic==="MODELVIEWPROJECTION"?be=he.getWorldMatrix().multiply(q.getTransformMatrix()):ge.semantic==="MODELINVERSE"?be=he.getWorldMatrix().invert():ge.semantic==="VIEWINVERSE"?be=q.getViewMatrix().invert():ge.semantic==="PROJECTIONINVERSE"?be=q.getProjectionMatrix().invert():ge.semantic==="MODELVIEWINVERSE"?be=he.getWorldMatrix().multiply(q.getViewMatrix()).invert():ge.semantic==="MODELVIEWPROJECTIONINVERSE"?be=he.getWorldMatrix().multiply(q.getTransformMatrix()).invert():ge.semantic==="MODELINVERSETRANSPOSE"&&(be=S.Matrix.Transpose(he.getWorldMatrix().invert())),be)switch(ge.type){case u.FLOAT_MAT2:_e.setMatr
13259ix2x2(me,S.Matrix.GetAsMatrix2x2(be));break;case u.FLOAT_MAT3:_e.setMatrix3x3(me,S.Matrix.GetAsMatrix3x3(be));break;case u.FLOAT_MAT4:_e.setMatrix(me,be)}},X.SetUniform=function(q,he,ge,me){switch(me){case u.FLOAT:return q.setFloat(he,ge),!0;case u.FLOAT_VEC2:return q.setVector2(he,S.Vector2.FromArray(ge)),!0;case u.FLOAT_VEC3:return q.setVector3(he,S.Vector3.FromArray(ge)),!0;case u.FLOAT_VEC4:return q.setVector4(he,S.Vector4.FromArray(ge)),!0;default:return!1}},X.GetWrapMode=function(q){switch(q){case M.CLAMP_TO_EDGE:return S.Texture.CLAMP_ADDRESSMODE;case M.MIRRORED_REPEAT:return S.Texture.MIRROR_ADDRESSMODE;case M.REPEAT:default:return S.Texture.WRAP_ADDRESSMODE}},X.GetByteStrideFromType=function(q){switch(q.type){case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16;default:return 1}},X.GetTextureFilterMode=function(q){switch(q){case R.LINEAR:case R.LINEAR_MIPMAP_NEAREST:case R.LINEAR_MIPMAP_LINEAR:return S.Texture.TRILINEAR_SAMPLINGMODE;case R.NEAREST:case R.NEAREST_MIPMAP_NEAREST:return S.Texture.NEAREST_SAMPLINGMODE;default:return S.Texture.BILINEAR_SAMPLINGMODE}},X.GetBufferFromBufferView=function(q,he,ge,me,_e){ge=he.byteOffset+ge;var be=q.loadedBufferViews[he.buffer];if(ge+me>be.byteLength)throw new Error("Buffer access is out of range");var Ce=be.buffer;switch(ge+=be.byteOffset,_e){case _.BYTE:return new Int8Array(Ce,ge,me);case _.UNSIGNED_BYTE:return new Uint8Array(Ce,ge,me);case _.SHORT:return new Int16Array(Ce,ge,me);case _.UNSIGNED_SHORT:return new Uint16Array(Ce,ge,me);default:return new Float32Array(Ce,ge,me)}},X.GetBufferFromAccessor=function(q,he){var ge=q.bufferViews[he.bufferView],me=he.count*X.GetByteStrideFromType(he);return X.GetBufferFromBufferView(q,ge,he.byteOffset,me,he.componentType)},X.DecodeBufferToText=function(q){for(var he="",ge=q.byteLength,me=0;me<ge;++me)he+=String.fromCharCode(q[me]);return he},X.GetDefaultMaterial=function(q){if(!X._DefaultMaterial){S.Effect.ShadersStore.GLTFDefaultMaterialVertexShader=["precision highp float;","","uniform mat4 worldView;","uniform mat4 projection;","","attribute vec3 position;","","void main(void)","{","    gl_Position = projection * worldView * vec4(position, 1.0);","}"].join(`
13260`),S.Effect.ShadersStore.GLTFDefaultMaterialPixelShader=["precision highp float;","","uniform vec4 u_emission;","","void main(void)","{","    gl_FragColor = u_emission;","}"].join(`
13261`);var he={attributes:["position"],uniforms:["worldView","projection","u_emission"],samplers:new Array,needAlphaBlending:!1};X._DefaultMaterial=new S.ShaderMaterial("GLTFDefaultMaterial",q,{vertex:"GLTFDefaultMaterial",fragment:"GLTFDefaultMaterial"},he),X._DefaultMaterial.setColor4("u_emission",new S.Color4(.5,.5,.5,1))}return X._DefaultMaterial},X._DefaultMaterial=null,X}(),l=B(2);(function(X){X[X.IDENTIFIER=1]="IDENTIFIER",X[X.UNKNOWN=2]="UNKNOWN",X[X.END_OF_INPUT=3]="END_OF_INPUT"})(A||(A={}));var h=function(){function X(q){this._pos=0,this.currentToken=A.UNKNOWN,this.currentIdentifier="",this.currentString="",this.isLetterOrDigitPattern=/^[a-zA-Z0-9]+$/,this._toParse=q,this._maxPos=q.length}return X.prototype.getNextToken=function(){if(this.isEnd())return A.END_OF_INPUT;if(this.currentString=this.read(),this.currentToken=A.UNKNOWN,this.currentString==="_"||this.isLetterOrDigitPattern.test(this.currentString))for(this.currentToken=A.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},X.prototype.peek=function(){return this._toParse[this._pos]},X.prototype.read=function(){return this._toParse[this._pos++]},X.prototype.forward=function(){this._pos++},X.prototype.isEnd=function(){return this._pos>=this._maxPos},X}(),b=["MODEL","VIEW","PROJECTION","MODELVIEW","MODELVIEWPROJECTION","JOINTMATRIX"],T=["world","view","projection","worldView","worldViewProjection","mBones"],D=["translation","rotation","scale"],w=["position","rotationQuaternion","scaling"],N=function(X,q,he){for(var ge in X){var me=X[ge];he[q][ge]=me}},I=function(X){if(X)for(var q=0;q<X.length/2;q++)X[2*q+1]=1-X[2*q+1]},V=function(X){if(X.semantic==="NORMAL")return"normal";if(X.semantic==="POSITION")return"position";if(X.semantic==="JOINT")return"matricesIndices";if(X.semantic==="WEIGHT")return"matricesWeights";if(X.semantic==="COLOR")return"color";if(X.semantic&&X.semantic.indexOf("TEXCOORD_")!==-1){var q=Number(X.semantic.split("_")[1]);return"uv"+(q===0?"":q+1)}return null},W=function(X){var q=null;if(X.translation||X.rotation||X.scale){var he=S.Vector3.FromArray(X.scale||[1,1,1]),ge=S.Quaternion.FromArray(X.rotation||[0,0,0,1]),me=S.Vector3.FromArray(X.translation||[0,0,0]);q=S.Matrix.Compose(he,ge,me)}
13261else q=S.Matrix.FromArray(X.matrix);return q},j=function(X,q,he,ge){for(var me=0;me<ge.bones.length;me++)if(ge.bones[me].name===he)return ge.bones[me];var _e=X.nodes;for(var be in _e){var Ce=_e[be];if(Ce.jointName){var ye=Ce.children;for(me=0;me<ye.length;me++){var Be=X.nodes[ye[me]];if(Be.jointName&&Be.jointName===he){var Ge=W(Ce),Xe=new S.Bone(Ce.name||"",ge,j(X,q,Ce.jointName,ge),Ge);return Xe.id=be,Xe}}}}return null},ne=function(X,q){for(var he=0;he<X.length;he++)for(var ge=X[he],me=0;me<ge.node.children.length;me++)if(ge.node.children[me]===q)return ge.bone;return null},te=function(X,q){var he=X.nodes,ge=he[q];if(ge)return{node:ge,id:q};for(var me in he)if((ge=he[me]).jointName===q)return{node:ge,id:me};return null},de=function(X,q){for(var he=0;he<X.jointNames.length;he++)if(X.jointNames[he]===q)return!0;return!1},pe=function(X,q,he,ge,me){if(ge||(ge=new S.Skeleton(q.name||"","",X.scene)),!q.babylonSkeleton)return ge;var _e=[],be=[];(function(mt,St,wt,It){for(var Pt in mt.nodes){var Ot=mt.nodes[Pt],on=Pt;if(Ot.jointName&&!de(wt,Ot.jointName)){var Zt=W(Ot),tn=new S.Bone(Ot.name||"",St,null,Zt);tn.id=on,It.push({bone:tn,node:Ot,id:on})}}for(var De=0;De<It.length;De++)for(var Sn=It[De],nn=Sn.node.children,An=0;An<nn.length;An++){for(var Ue=null,Pn=0;Pn<It.length;Pn++)if(It[Pn].id===nn[An]){Ue=It[Pn];break}Ue&&(Ue.bone._parent=Sn.bone,Sn.bone.children.push(Ue.bone))}})(X,ge,q,_e),ge.bones=[];for(var Ce=0;Ce<q.jointNames.length;Ce++)if(ct=te(X,q.jointNames[Ce])){var ye=ct.node;if(ye){me=ct.id;var Be=X.scene.getBoneByID(me);if(Be)ge.bones.push(Be);else{for(var Ge=!1,Xe=null,He=0;He<Ce;He++){var We=te(X,q.jointNames[He]);if(We){var Ze=We.node;if(Ze){var ze=Ze.children;if(ze){Ge=!1;for(var it=0;
13261it<ze.length;it++)if(ze[it]===me){Xe=j(X,q,q.jointNames[He],ge),Ge=!0;break}if(Ge)break}}else S.Tools.Warn("Joint named "+q.jointNames[He]+" does not exist when looking for parent")}}var et=W(ye);!Xe&&_e.length>0&&(Xe=ne(_e,me))&&be.indexOf(Xe)===-1&&be.push(Xe),new S.Bone(ye.jointName||"",ge,Xe,et).id=me}}else S.Tools.Warn("Joint named "+q.jointNames[Ce]+" does not exist")}var lt=ge.bones;for(ge.bones=[],Ce=0;Ce<q.jointNames.length;Ce++){var ct;if(ct=te(X,q.jointNames[Ce])){for(He=0;He<lt.length;He++)if(lt[He].id===ct.id){ge.bones.push(lt[He]);break}}}for(ge.prepare(),Ce=0;Ce<be.length;Ce++)ge.bones.push(be[Ce]);return ge},ae=function(X,q,he,ge,me){if(me||(X.scene._blockEntityCollection=X.forAssetContainer,me=new S.Mesh(q.name||"",X.scene),X.scene._blockEntityCollection=!1,me.id=ge),!q.babylonNode)return me;for(var _e,be=[],Ce=null,ye=new Array,Be=new Array,Ge=new Array,Xe=new Array,He=0;He<he.length;He++){var We=he[He];if(tn=X.meshes[We])for(var Ze=0;Ze<tn.primitives.length;Ze++){var ze=new S.VertexData,it=tn.primitives[Ze];it.mode;var et=it.attributes,lt=null,ct=null;for(var mt in et)if(lt=X.accessors[et[mt]],ct=g.GetBufferFromAccessor(X,lt),mt==="NORMAL")ze.normals=new Float32Array(ct.length),ze.normals.set(ct);else if(mt==="POSITION"){if(l.GLTFFileLoader.HomogeneousCoordinates){ze.positions=new Float32Array(ct.length-ct.length/4);for(var St=0;St<ct.length;St+=4)ze.positions[St]=ct[St],ze.positions[St+1]=ct[St+1],ze.positions[St+2]=ct[St+2]}else ze.positions=new Float32Array(ct.length),ze.positions.set(ct);Be.push(ze.positions.length)}else if(mt.indexOf("TEXCOORD_")!==-1){var wt=Number(mt.split("_")[1]),It=S.VertexBuffer.UVKind+(wt===0?"":wt+1),Pt=new Float32Array(ct.length);Pt.set(ct),I(Pt),ze.set(Pt,It)}else mt==="JOINT"?(ze.matricesIndices=new Float32Array(ct.length),ze.matricesIndices.set(ct)):mt==="WEIGHT"?(ze.matricesWeights=new Float32Array(ct.length),ze.matricesWeights.set(ct)):mt==="COLOR"&&(ze.colors=new Float32Array(ct.length),ze.colors.set(ct));if(lt=X.accessors[it.indices])ct=g.GetBufferFromAccessor(X,lt),ze.indices=new Int32Array(ct.length),ze.indices.set(ct),Xe.push(ze.indices.length);else{var Ot=[];for(St=0;St<ze.positions.length/3;St++)Ot.push(St);ze.indices=new Int32Array(Ot),Xe.push(ze.indices.length)}Ce?Ce.merge(ze):Ce=ze;var on=X.scene.getMaterialByID(it.material);be.push(on===null?g.GetDefaultMaterial(X.scene):on),ye.push(ye.length===0?0:ye[ye.length-1]+Be[Be.length-2]),Ge.push(Ge.length===0?0:Ge[Ge.length-1]+Xe[Xe.length-2])}}X.scene._blockEntityCollection=X.forAssetContainer,be.length>1?(_e=new S.MultiMaterial("multimat"+ge,X.scene)).subMaterials=be:_e=new S.StandardMaterial("multimat"+ge,X.scene),be.length===1&&(_e=be[0]),me.material||(me.material=_e),new S.Geometry(ge,X.scene,Ce,!1,me),me.computeWorldMatrix(!0),X.scene._blockEntityCollection=!1,me.subMeshes=[];var Zt=0;for(He=0;He<he.length;He++){var tn;if(We=he[He],tn=X.meshes[We])for(Ze=0;Ze<tn.primitives.length;Ze++)tn.primitives[Ze].mode,S.SubMesh.AddToMesh(Zt,ye[Zt],Be[Zt],Ge[Zt],Xe[Zt],me,me,!0),Zt++}return me},ee=function(X,q,he,ge){X.position&&(X.position=q),(X.rotationQuaternion||X.rotation)&&(X.rotationQuaternion=he),X.scaling&&(X.scaling=ge)},K=function(X,q,he,ge){var me=null;if(X.importOnlyMeshes&&(q.skin||q.meshes)&&X.importMeshesNames&&X.importMeshesNames.length>0&&X.importMeshesNames.indexOf(q.name||"")===-1)return null;if(q.skin){if(q.meshes){var _e=X.skins[q.skin];(be=ae(X,q,q.meshes,he,q.babylonNode)).skeleton=X.scene.getLastSkeletonByID(q.skin),be.skeleton===null&&(be.skeleton=pe(X,_e,0,_e.babylonSkeleton,q.skin),_e.babylonSkeleton||(_e.babylonSkeleton=be.skeleton)),me=be}}else if(q.meshes){var be;me=be=ae(X,q,q.mesh?[q.mesh]:q.meshes,he,q.babylonNode)}else if(!q.light||q.babylonNode||X.importOnlyMeshes){if(q.camera&&!q.babylonNode&&!X.importOnlyMeshes){var Ce=X.cameras[q.camera];if(Ce){if(X.scene._blockEntityCollection=X.forAssetContainer,Ce.type==="orthographic"){var ye=new S.FreeCamera(q.camera,S.Vector3.Zero(),X.scene,!1);ye.name=q.name||"",ye.mode=S.Camera.ORTHOGRAPHIC_CAMERA,ye.attachControl(),me=ye}else if(Ce.type==="perspective"){var Be=Ce[Ce.type],Ge=new S.FreeCamera(q.camera,S.Vector3.Zero(),X.scene,!1);Ge.name=q.name||"",Ge.attachControl(),Be.aspectRatio||(Be.aspectRatio=X.scene.getEngine().getRenderWidth()/X.scene.getEngine().getRenderHeight()),Be.znear&&Be.zfar&&(Ge.maxZ=Be.zfar,Ge.minZ=Be.znear),me=Ge}X.scene._blockEntityCollection=!1}}}else{var Xe=X.lights[q.light];if(Xe){if(Xe.type==="ambient"){var He=Xe[Xe.type],We=new S.HemisphericLight(q.light,S.Vector3.Zero(),X.scene);We.name=q.name||"",He.color&&(We.diffuse=S.Color3.FromArray(He.color)),me=We}else if(Xe.type==="directional"){var Ze=Xe[Xe.type],ze=new S.DirectionalLight(q.light,S.Vector3.Zero(),X.scene);ze.name=q.name||"",Ze.color&&(ze.diffuse=S.Color3.FromArray(Ze.color)),me=ze}else if(Xe.type==="point"){var it=Xe[Xe.type],et=new S.PointLight(q.light,S.Vector3.Zero(),X.scene);et.name=q.name||"",it.color&&(et.diffuse=S.Color3.FromArray(it.color)),me=et}else if(Xe.type==="spot"){var lt=Xe[Xe.type],ct=new S.SpotLight(q.light,S.Vector3.Zero(),S.Vector3.Zero(),0,0,X.scene);ct.name=q.name||"",lt.color&&(ct.diffuse=S.Color3.FromArray(lt.color)),lt.fallOfAngle&&(ct.angle=lt.fallOfAngle),lt.fallOffExponent&&(ct.exponent=lt.fallOffExponent),me=ct}}}if(!q.jointName){if(q.babylonNode)return q.babylonNode;if(me===null){X.scene._blockEntityCollection=X.forAssetContainer;var mt=new S.Mesh(q.name||"",X.scene);X.scene._blockEntityCollection=!1,q.babylonNode=mt,me=mt}}if(me!==null){if(q.matrix&&me instanceof S.Mesh)(function(Pt,Ot,on){if(Ot.matrix){var Zt=new S.Vector3(0,0,0),tn=new S.Quaternion,De=new S.Vector3(0,0,0);S.Matrix.FromArray(Ot.matrix).decompose(De,tn,Zt),ee(Pt,Zt,tn,De)}else Ot.translation&&Ot.rotation&&Ot.scale&&ee(Pt,S.Vector3.FromArray(Ot.translation),S.Quaternion.FromArray(Ot.rotation),S.Vector3.FromArray(Ot.scale));Pt.computeWorldMatrix(!0)})(me,q);else{var St=q.translation||[0,0,0],wt=q.rotation||[0,0,0,1],It=q.scale||[1,1,1];ee(me,S.Vector3.FromArray(St),S.Quaternion.FromArray(wt),S.Vector3.FromArray(It))}me.updateCache(!0),q.babylonNode=me}return me},$=function(X,q,he,ge){ge===void 0&&(ge=!1);var me=X.nodes[q],_e=null;if(ge=!(X.importOnlyMeshes&&!ge&&X.importMeshesNames)||X.importMeshesNames.indexOf(me.name||"")!==-1||X.importMeshesNames.length===0,!me.jointName&&ge&&(_e=K(X,me,q))!==null&&(_e.id=q,_e.parent=he),me.children)for(var be=0;be<me.children.length;be++)$(X,me.children[be],_e,ge)},L=function(X){var q=X.currentScene;if(q)for(var he=0;he<q.nodes.length;
13261he++)$(X,q.nodes[he],null);else for(var ge in X.scenes)for(q=X.scenes[ge],he=0;he<q.nodes.length;he++)$(X,q.nodes[he],null);for(function(_e){for(var be in _e.animations){var Ce=_e.animations[be];if(Ce.channels&&Ce.samplers)for(var ye=null,Be=0;Be<Ce.channels.length;Be++){var Ge=Ce.channels[Be],Xe=Ce.samplers[Ge.sampler];if(Xe){var He=null,We=null;Ce.parameters?(He=Ce.parameters[Xe.input],We=Ce.parameters[Xe.output]):(He=Xe.input,We=Xe.output);var Ze=g.GetBufferFromAccessor(_e,_e.accessors[He]),ze=g.GetBufferFromAccessor(_e,_e.accessors[We]),it=Ge.target.id,et=_e.scene.getNodeByID(it);if(et===null&&(et=_e.scene.getNodeByName(it)),et!==null){var lt=et instanceof S.Bone,ct=Ge.target.path,mt=D.indexOf(ct);mt!==-1&&(ct=w[mt]);var St=S.Animation.ANIMATIONTYPE_MATRIX;lt||(ct==="rotationQuaternion"?(St=S.Animation.ANIMATIONTYPE_QUATERNION,et.rotationQuaternion=new S.Quaternion):St=S.Animation.ANIMATIONTYPE_VECTOR3);var wt=null,It=[],Pt=0,Ot=!1;lt&&ye&&ye.getKeys().length===Ze.length&&(wt=ye,Ot=!0),Ot||(_e.scene._blockEntityCollection=_e.forAssetContainer,wt=new S.Animation(be,lt?"_matrix":ct,1,St,S.Animation.ANIMATIONLOOPMODE_CYCLE),_e.scene._blockEntityCollection=!1);for(var on=0;on<Ze.length;on++){var Zt=null;if(ct==="rotationQuaternion"?(Zt=S.Quaternion.FromArray([ze[Pt],ze[Pt+1],ze[Pt+2],ze[Pt+3]]),Pt+=4):(Zt=S.Vector3.FromArray([ze[Pt],ze[Pt+1],ze[Pt+2]]),Pt+=3),lt){var tn=et,De=S.Vector3.Zero(),Sn=new S.Quaternion,nn=S.Vector3.Zero(),An=tn.getBaseMatrix();Ot&&ye&&(An=ye.getKeys()[on].value),An.decompose(nn,Sn,De),ct==="position"?De=Zt:ct==="rotationQuaternion"?Sn=Zt:nn=Zt,Zt=S.Matrix.Compose(nn,Sn,De)}Ot?ye&&(ye.getKeys()[on].value=Zt):It.push({frame:Ze[on],value:Zt})}!Ot&&wt&&(wt.setKeys(It),et.animations.push(wt)),ye=wt,_e.scene.stopAnimation(et),_e.scene.beginAnimation(et,0,Ze[Ze.length-1],!0,1)}else S.Tools.Warn("Creating animation named "+be+". But cannot find node named "+it+" to attach to")}}}}(X),he=0;he<X.scene.skeletons.length;he++){var me=X.scene.skeletons[he];X.scene.beginAnimation(me,0,Number.MAX_VALUE,!0,1)}},G=function(X,q,he,ge,me,_e){return function(be){(function(Ce,ye,Be,Ge,Xe){var He=Ge.values||Be.parameters,We=Be.uniforms;for(var Ze in Xe){var ze=Xe[Ze],it=ze.type,et=He[We[Ze]];if(et===void 0&&(et=ze.value),et){var lt=function(ct){return function(mt){ze.value&&ct&&(ye.setTexture(ct,mt),delete Xe[ct])}};it===u.SAMPLER_2D?k.LoadTextureAsync(Ce,Ge.values?et:ze.value,lt(Ze),function(){return lt(null)}):ze.value&&g.SetUniform(ye,Ze,Ge.values?et:ze.value,it)&&delete Xe[Ze]}}})(X,q,he,ge,me),q.onBind=function(Ce){(function(ye,Be,Ge,Xe,He,We,Ze){var ze=We.values||He.parameters;for(var it in Ge){var et=Ge[it],lt=et.type;if(lt===u.FLOAT_MAT2||lt===u.FLOAT_MAT3||lt===u.FLOAT_MAT4)if(!et.semantic||et.source||et.node){if(et.semantic&&(et.source||et.node)){var ct=Be.scene.getNodeByName(et.source||et.node||"");if(ct===null&&(ct=Be.scene.getNodeByID(et.source||et.node||"")),ct===null)continue;g.SetMatrix(Be.scene,ct,et,it,Xe.getEffect())}}else g.SetMatrix(Be.scene,ye,et,it,Xe.getEffect());else{var mt=ze[He.uniforms[it]];if(!mt)continue;if(lt===u.SAMPLER_2D){var St=Be.textures[We.values?mt:et.value].babylonTexture;if(St==null)continue;Xe.getEffect().setTexture(it,St)}else g.SetUniform(Xe.getEffect(),it,mt,lt)}}Ze(Xe)})(Ce,X,me,q,he,ge,_e)}}},Q=function(X,q,he){for(var ge in q.uniforms){var me=q.uniforms[ge],_e=q.parameters[me];if(X.currentIdentifier===ge&&_e.semantic&&!_e.source&&!_e.node){var be=b.indexOf(_e.semantic);if(be!==-1)return delete he[ge],T[be]}}return X.currentIdentifier},oe=function(X){for(var q in X.materials)k.LoadMaterialAsync(X,q,function(he){},function(){})},re=function(){function X(){}return X.CreateRuntime=function(q,he,ge){var me={extensions:{},accessors:{},buffers:{},bufferViews:{},meshes:{},lights:{},cameras:{},nodes:{},images:{},textures:{},shaders:{},programs:{},samplers:{},techniques:{},materials:{},animations:{},skins:{},extensionsUsed:[],scenes:{},buffersCount:0,shaderscount:0,scene:he,rootUrl:ge,loadedBufferCount:0,loadedBufferViews:{},loadedShaderCount:0,importOnlyMeshes:!1,dummyNodes:[],forAssetContainer:!1};return q.extensions&&N(q.extensions,"extensions",me),q.extensionsUsed&&N(q.extensionsUsed,"extensionsUsed",me),q.buffers&&function(_e,be){for(var Ce in _e){var ye=_e[Ce];be.buffers[Ce]=ye,be.buffersCount++}}(q.buffers,me),q.bufferViews&&N(q.bufferViews,"bufferViews",me),q.accessors&&N(q.accessors,"accessors",me),q.meshes&&N(q.meshes,"meshes",me),q.lights&&N(q.lights,"lights",me),q.cameras&&N(q.cameras,"cameras",me),q.nodes&&N(q.nodes,"nodes",me),q.images&&N(q.images,"images",me),q.textures&&N(q.textures,"textures",me),q.shaders&&function(_e,be){for(var Ce in _e){var ye=_e[Ce];be.shaders[Ce]=ye,be.shaderscount++}}(q.shaders,me),q.programs&&N(q.programs,"programs",me),q.samplers&&N(q.samplers,"samplers",me),q.techniques&&N(q.techniques,"techniques",me),q.materials&&N(q.materials,"materials",me),q.animations&&N(q.animations,"animations",me),q.skins&&N(q.skins,"skins",me),q.scenes&&(me.scenes=q.scenes),q.sce
13261ne&&q.scenes&&(me.currentScene=q.scenes[q.scene]),me},X.LoadBufferAsync=function(q,he,ge,me,_e){var be=q.buffers[he];S.Tools.IsBase64(be.uri)?setTimeout(function(){return ge(new Uint8Array(S.Tools.DecodeBase64(be.uri)))}):S.Tools.LoadFile(q.rootUrl+be.uri,function(Ce){return ge(new Uint8Array(Ce))},_e,void 0,!0,function(Ce){Ce&&me(Ce.status+" "+Ce.statusText)})},X.LoadTextureBufferAsync=function(q,he,ge,me){var _e=q.textures[he];if(_e&&_e.source)if(_e.babylonTexture)ge(null);else{var be=q.images[_e.source];S.Tools.IsBase64(be.uri)?setTimeout(function(){return ge(new Uint8Array(S.Tools.DecodeBase64(be.uri)))}):S.Tools.LoadFile(q.rootUrl+be.uri,function(Ce){return ge(new Uint8Array(Ce))},void 0,void 0,!0,function(Ce){Ce&&me(Ce.status+" "+Ce.statusText)})}else me("")},X.CreateTextureAsync=function(q,he,ge,me,_e){var be=q.textures[he];if(be.babylonTexture)me(be.babylonTexture);else{var Ce=q.samplers[be.sampler],ye=Ce.minFilter===R.NEAREST_MIPMAP_NEAREST||Ce.minFilter===R.NEAREST_MIPMAP_LINEAR||Ce.minFilter===R.LINEAR_MIPMAP_NEAREST||Ce.minFilter===R.LINEAR_MIPMAP_LINEAR,Be=S.Texture.BILINEAR_SAMPLINGMODE,Ge=ge==null?new Blob:new Blob([ge]),Xe=URL.createObjectURL(Ge),He=function(){return URL.revokeObjectURL(Xe)},We=new S.Texture(Xe,q.scene,!ye,!0,Be,He,He);Ce.wrapS!==void 0&&(We.wrapU=g.GetWrapMode(Ce.wrapS)),Ce.wrapT!==void 0&&(We.wrapV=g.GetWrapMode(Ce.wrapT)),We.name=he,be.babylonTexture=We,me(We)}},X.LoadShaderStringAsync=function(q,he,ge,me){var _e=q.shaders[he];if(S.Tools.IsBase64(_e.uri)){var be=atob(_e.uri.split(",")[1]);ge&&ge(be)}else S.Tools.LoadFile(q.rootUrl+_e.uri,ge,void 0,void 0,!1,function(Ce){Ce&&me&&me(Ce.status+" "+Ce.statusText)})},X.LoadMaterialAsync=function(q,he,ge,me){var _e=q.materials[he];if(_e.technique){var be=q.techniques[_e.technique];if(!be){q.scene._blockEntityCollection=q.forAssetContainer;var Ce=new S.StandardMaterial(he,q.scene);return q.scene._blockEntityCollection=!1,Ce.diffuseColor=new S.Color3(.5,.5,.5),Ce.sideOrientation=S.Material.CounterClockWiseSideOrientation,void ge(Ce)}var ye=q.programs[be.program],Be=be.states,Ge=S.Effect.ShadersStore[ye.vertexShader+"VertexShader"],Xe=S.Effect.ShadersStore[ye.fragmentShader+"PixelShader"],He="",We="",Ze=new h(Ge),ze=new h(Xe),it={},et=[],lt=[],ct=[];for(var mt in be.uniforms){var St=be.uniforms[mt],wt=be.parameters[St];if(it[mt]=wt,!wt.semantic||wt.node||wt.source)wt.type===u.SAMPLER_2D?ct.push(mt):et.push(mt);else{var It=b.indexOf(wt.semantic);It!==-1?(et.push(T[It]),delete it[mt]):et.push(mt)}}for(var Pt in be.attributes){var Ot=be.attributes[Pt];if((tn=be.parameters[Ot]).semantic){var on=V(tn);on&&lt.push(on)}}for(;!Ze.isEnd()&&Ze.getNextToken();)if(Ze.currentToken===A.IDENTIFIER){var Zt=!1;for(var Pt in be.attributes){Ot=be.attributes[Pt];var tn=be.parameters[Ot];if(Ze.currentIdentifier===Pt&&tn.semantic){He+=V(tn),Zt=!0;break}}Zt||(He+=Q(Ze,be,it))}else He+=Ze.currentString;for(;!ze.isEnd()&&ze.getNextToken();)ze.currentToken===A.IDENTIFIER?We+=Q(ze,be,it):We+=ze.currentString;var De={vertex:ye.vertexShader+he,fragment:ye.fragmentShader+he},Sn={attributes:lt,uniforms:et,samplers:ct,needAlphaBlending:Be&&Be.enable&&Be.enable.indexOf(3042)!==-1};S.Effect.ShadersStore[ye.vertexShader+he+"VertexShader"]=He,S.Effect.ShadersStore[ye.fragmentShader+he+"PixelShader"]=We;var nn=new S.ShaderMaterial(he,q.scene,De,Sn);if(nn.onError=function(Pn,hr,Ye){return function(En,Zn){hr.dispose(!0),Ye("Cannot compile program named "+Pn.name+". Error: "+Zn+". Default material will be applied")}}(ye,nn,me),nn.onCompiled=G(q,nn,be,_e,it,ge),nn.sideOrientation=S.Material.CounterClockWiseSideOrientation,Be&&Be.functions){var An=Be.functions;An.cullFace&&An.cullFace[0]!==m.BACK&&(nn.backFaceCulling=!1);var Ue=An.blendFuncSeparate;Ue&&(Ue[0]===c.SRC_ALPHA&&Ue[1]===c.ONE_MINUS_SRC_ALPHA&&Ue[2]===c.ONE&&Ue[3]===c.ONE?nn.alphaMode=S.Constants.ALPHA_COMBINE:Ue[0]===c.ONE&&Ue[1]===c.ONE&&Ue[2]===c.ZERO&&Ue[3]===c.ONE?nn.alphaMode=S.Constants.ALPHA_ONEONE:Ue[0]===c.SRC_ALPHA&&Ue[1]===c.ONE&&Ue[2]===c.ZERO&&Ue[3]===c.ONE?nn.alphaMode=S.Constants.ALPHA_ADD:Ue[0]===c.ZERO&&Ue[1]===c.ONE_MINUS_SRC_COLOR&&Ue[2]===c.ONE&&Ue[3]===c.ONE?nn.alphaMode=S.Constants.ALPHA_SUBTRACT:Ue[0]===c.DST_COLOR&&Ue[1]===c.ZERO&&Ue[2]===c.ONE&&Ue[3]===c.ONE?nn.alphaMode=S.Constants.ALPHA_MULTIPLY:Ue[0]===c.SRC_ALPHA&&Ue[1]===c.ONE_MINUS_SRC_COLOR&&Ue[2]===c.ONE&&Ue[3]===c.ONE&&(nn.alphaMode=S.Constants.ALPHA_MAXIMIZED))}}else me&&me("No technique found.")},X}(),Y=function(){function X(){this.state=null}return X.RegisterExtension=function(q){X.Extensions[q.name]?S.Tools.Error('Tool with the same name "'+q.name+'" already exists'):X.Extensions[q.name]=q},X.prototype.dispose=function(){},X.prototype._importMeshAsync=function(q,he,ge,me,_e,be,Ce,ye){var Be=this;return he.useRightHandedSystem=!0,k.LoadRuntimeAsync(he,ge,me,function(Ge){Ge.forAssetContainer=_e,Ge.importOnlyMeshes=!0,q===""?Ge.importMeshesNames=[]:typeof q=="string"?Ge.importMeshesNames=[q]:!q||q instanceof Array?(Ge.importMeshesNames=[],S.Tools.Warn("Argument meshesNames must be of type string or string[]")):Ge.importMeshesNames=[q],Be._createNodes(Ge);var Xe=new Array,He=new Array;for(var We in Ge.nodes){var Ze=Ge.nodes[We];Ze.babylonNode instanceof S.AbstractMesh&&Xe.push(Ze.babylonNode)}for(var ze in Ge.skins){var it=Ge.skins[ze];it.babylonSkeleton instanceof S.Skeleton&&He.push(it.babylonSkeleton)}Be._loadBuffersAsync(Ge,function(){Be._loadShadersAsync(Ge,function(){oe(Ge),L(Ge),!l.GLTFFileLoader.IncrementalLoading&&be&&be(Xe,He)})},Ce),l.GLTFFileLoader.IncrementalLoading&&be&&be(Xe,He)},ye),!0},X.prototype.importMeshAsync=function(q,he,ge,me,_e,be){var Ce=this;return new Promise(function(ye,Be){Ce._importMeshAsync(q,he,me,_e,ge,function(Ge,Xe){ye({meshes:Ge,particleSystems:[],skeletons:Xe,animationGroups:[],lights:[],transformNodes:[],geometries:[]})},be,function(Ge){Be(new Error(Ge))})})},X.prototype._loadAsync=function(q,he,ge,me,_e,be,Ce){var ye=this;q.useRightHandedSystem=!0,k.LoadRuntimeAsync(q,he,ge,function(Be){k.LoadRuntimeExtensionsAsync(Be,function(){ye._createNodes(Be),ye._loadBuffersAsync(Be,function(){ye._loadShadersAsync(Be,function(){oe(Be),L(Be),l.GLTFFileLoader.IncrementalLoading||_e()})}),l.GLTFFileLoader.IncrementalLoading&&_e()},Ce)},Ce)},X.prototype.loadAsync=function(q,he,ge,me){var _e=this;return new Promise(function(be,Ce){_e._loadAsync(q,he,ge,!1,function(){be()},me,function(ye){Ce(new Error(ye))})})},X.prototype._loadShadersAsync=function(q,he){var ge=!1,me=function(Ce,ye){k.LoadShaderStringAsync(q,Ce,function(Be){Be instanceof ArrayBuffer||(q.loadedShaderCount++,Be&&(S.Effect.ShadersStore[Ce+(ye.type===x.VERTEX?"VertexShader":"PixelShader")]=Be),q.loadedShaderCount===q.shaderscount&&he())},function(){S.Tools.Error("Error when loading shader program named "+Ce+" located at "+ye.ur
13261i)})};for(var _e in q.shaders){ge=!0;var be=q.shaders[_e];be?me.bind(this,_e,be)():S.Tools.Error("No shader named: "+_e)}ge||he()},X.prototype._loadBuffersAsync=function(q,he,ge){var me=!1,_e=function(ye,Be){k.LoadBufferAsync(q,ye,function(Ge){q.loadedBufferCount++,Ge&&(Ge.byteLength!=q.buffers[ye].byteLength&&S.Tools.Error("Buffer named "+ye+" is length "+Ge.byteLength+". Expected: "+Be.byteLength),q.loadedBufferViews[ye]=Ge),q.loadedBufferCount===q.buffersCount&&he()},function(){S.Tools.Error("Error when loading buffer named "+ye+" located at "+Be.uri)})};for(var be in q.buffers){me=!0;var Ce=q.buffers[be];Ce?_e.bind(this,be,Ce)():S.Tools.Error("No buffer named: "+be)}me||he()},X.prototype._createNodes=function(q){var he=q.currentScene;if(he)for(var ge=0;ge<he.nodes.length;ge++)$(q,he.nodes[ge],null);else for(var me in q.scenes)for(he=q.scenes[me],ge=0;ge<he.nodes.length;ge++)$(q,he.nodes[ge],null)},X.Extensions={},X}(),k=function(){function X(q){this._name=q}return Object.defineProperty(X.prototype,"name",{get:function(){return this._name},enumerable:!1,configurable:!0}),X.prototype.loadRuntimeAsync=function(q,he,ge,me,_e){return!1},X.prototype.loadRuntimeExtensionsAsync=function(q,he,ge){return!1},X.prototype.loadBufferAsync=function(q,he,ge,me,_e){return!1},X.prototype.loadTextureBufferAsync=function(q,he,ge,me){return!1},X.prototype.createTextureAsync=function(q,he,ge,me,_e){return!1},X.prototype.loadShaderStringAsync=function(q,he,ge,me){return!1},X.prototype.loadMaterialAsync=function(q,he,ge,me){return!1},X.LoadRuntimeAsync=function(q,he,ge,me,_e){X.ApplyExtensions(function(be){return be.loadRuntimeAsync(q,he,ge,me,_e)},function(){setTimeout(function(){me&&me(re.CreateRuntime(he.json,q,ge))})})},X.LoadRuntimeExtensionsAsync=function(q,he,ge){X.ApplyExtensions(function(me){return me.loadRuntimeExtensionsAsync(q,he,ge)},function(){setTimeout(function(){he()})})},X.LoadBufferAsync=function(q,he,ge,me,_e){X.ApplyExtensions(function(be){return be.loadBufferAsync(q,he,ge,me,_e)},function(){re.LoadBufferAsync(q,he,ge,me,_e)})},X.LoadTextureAsync=function(q,he,ge,me){X.LoadTextureBufferAsync(q,he,function(_e){_e&&X.CreateTextureAsync(q,he,_e,ge,me)},me)},X.LoadShaderStringAsync=function(q,he,ge,me){X.ApplyExtensions(function(_e){return _e.loadShaderStringAsync(q,he,ge,me)},function(){re.LoadShaderStringAsync(q,he,ge,me)})},X.LoadMaterialAsync=function(q,he,ge,me){X.ApplyExtensions(function(_e){return _e.loadMaterialAsync(q,he,ge,me)},function(){re.LoadMaterialAsync(q,he,ge,me)})},X.LoadTextureBufferAsync=function(q,he,ge,me){X.ApplyExtensions(function(_e){return _e.loadTextureBufferAsync(q,he,ge,me)},function(){re.LoadTextureBufferAsync(q,he,ge,me)})},X.CreateTextureAsync=function(q,he,ge,me,_e){X.ApplyExtensions(function(be){return be.createTextureAsync(q,he,ge,me,_e)},function(){re.CreateTextureAsync(q,he,ge,me,_e)})},X.ApplyExtensions=function(q,he){for(var ge in Y.Extensions)if(q(Y.Extensions[ge]))return;he()},X}();l.GLTFFileLoader._CreateGLTF1Loader=function(){return new Y};var H=function(X){function q(){return X.call(this,"KHR_binary_glTF")||this}return Object(E.b)(q,X),q.prototype.loadRuntimeAsync=function(he,ge,me,_e,be){var Ce=ge.json.extensionsUsed;return!(!Ce||Ce.indexOf(this.name)===-1||!ge.bin)&&(this._bin=ge.bin,_e(re.CreateRuntime(ge.json,he,me)),!0)},q.prototype.loadBufferAsync=function(he,ge,me,_e){return he.extensionsUsed.indexOf(this.name)!==-1&&ge==="binary_glTF"&&(this._bin.readAsync(0,this._bin.byteLength).then(me,function(be){return _e(be.message)}),!0)},q.prototype.loadTextureBufferAsync=function(he,ge,me,_e){var be=he.textures[ge],Ce=he.images[be.source];if(!Ce.extensions||!(this.name in Ce.extensions))return!1;var ye=Ce.extensions[this.name],Be=he.bufferViews[ye.bufferView];return me(g.GetBufferFromBufferView(he,Be,0,Be.byteLength,_.UNSIGNED_BYTE)),!0},q.prototype.loadShaderStringAsync=function(he,ge,me,_e){var be=he.shaders[ge];if(!be.extensions||!(this.name in be.extensions))return!1;var Ce=be.extensions[this.name],ye=he.bufferViews[Ce.bufferView],Be=g.GetBufferFromBufferView(he,ye,0,ye.byteLength,_.UNSIGNED_BYTE);return setTimeout(function(){var Ge=g.DecodeBufferToText(Be);me(Ge)}),!0},q}(k);Y.RegisterExtension(new H);var Z=function(X){function q(){return X.call(this,"KHR_materials_common")||this}return Object(E.b)(q,X),q.prototype.loadRuntimeExtensionsAsync=function(he,ge,me){if(!he.extensions)return!1;var _e=he.extensions[this.name];if(!_e)return!1;var be=_e.lights;if(be)for(var Ce in be){var ye=be[Ce];switch(ye.type){case"ambient":var Be=new S.HemisphericLight(ye.name,new S.Vector3(0,1,0),he.scene),Ge=ye.ambient;Ge&&(Be.diffuse=S.Color3.FromArray(Ge.color||[1,1,1]));break;case"point":var Xe=new S.PointLight(ye.name,new S.Vector3(10,10,10),he.scene),He=ye.point;He&&(Xe.diffuse=S.Color3.FromArray(He.color||[1,1,1]));break;case"directional":var We=new S.DirectionalLight(ye.name,new S.Vector3(0,-1,0),he.scene),Ze=ye.directional;Ze&&(We.diffuse=S.Color3.FromArray(Ze.color||[1,1,1]));break;case"spot":var ze=ye.spot;ze&&(new S.SpotLight(ye.name,new S.Vector3(0,10,0),new S.Vector3(0,-1,0),ze.fallOffAngle||Math.PI,ze.fallOffExponent||0,he.scene).diffuse=S.Color3.FromArray(ze.color||[1,1,1]));break;default:S.Tools.Warn('GLTF Material Common extension: light type "'+ye.type+"” not supported")}}return!1},q.prototype.loadMaterialAsync=function(he,ge,me,_e){var be=he.materials[ge];if(!be||!be.extensions)return!1;var Ce=be.extensions[this.name];if(!Ce)return!1;var ye=new S.StandardMaterial(ge,he.scene);return ye.sideOrientation=S.Material.CounterClockWiseSideOrientation,Ce.technique==="CONSTANT"&&(ye.disableLighting=!0),ye.backFaceCulling=Ce.doubleSided!==void 0&&!Ce.doubleSided,ye.alpha=Ce.values.transparency===void 0?1:Ce.values.transparency,ye.specularPower=Ce.values.shininess===void 0?0:Ce.values.shininess,typeof Ce.values.ambient=="string"?this._loadTexture(he,Ce.values.ambient,ye,"ambientTexture",_e):ye.ambientColor=S.Color3.FromArray(Ce.values.ambient||[0,0,0]),typeof Ce.values.diffuse=="string"?this._loadTexture(he,Ce.values.diffuse,ye,"diffuseTexture",_e):ye.diffuseColor=S.Color3.FromArray(Ce.values.diffuse||[0,0,0]),typeof Ce.values.emission=="str
13261ing"?this._loadTexture(he,Ce.values.emission,ye,"emissiveTexture",_e):ye.emissiveColor=S.Color3.FromArray(Ce.values.emission||[0,0,0]),typeof Ce.values.specular=="string"?this._loadTexture(he,Ce.values.specular,ye,"specularTexture",_e):ye.specularColor=S.Color3.FromArray(Ce.values.specular||[0,0,0]),!0},q.prototype._loadTexture=function(he,ge,me,_e,be){re.LoadTextureBufferAsync(he,ge,function(Ce){re.CreateTextureAsync(he,ge,Ce,function(ye){return me[_e]=ye},be)},be)},q}(k);Y.RegisterExtension(new Z)},function(v,f,B){B.r(f),B.d(f,"ArrayItem",function(){return _.a}),B.d(f,"GLTFLoader",function(){return _.b}),B.d(f,"EXT_lights_image_based",function(){return x.EXT_lights_image_based}),B.d(f,"EXT_mesh_gpu_instancing",function(){return x.EXT_mesh_gpu_instancing}),B.d(f,"EXT_texture_webp",function(){return x.EXT_texture_webp}),B.d(f,"KHR_draco_mesh_compression",function(){return x.KHR_draco_mesh_compression}),B.d(f,"KHR_lights",function(){return x.KHR_lights}),B.d(f,"KHR_materials_pbrSpecularGlossiness",function(){return x.KHR_materials_pbrSpecularGlossiness}),B.d(f,"KHR_materials_unlit",function(){return x.KHR_materials_unlit}),B.d(f,"KHR_materials_clearcoat",function(){return x.KHR_materials_clearcoat}),B.d(f,"KHR_materials_sheen",function(){return x.KHR_materials_sheen}),B.d(f,"KHR_materials_specular",function(){return x.KHR_materials_specular}),B.d(f,"KHR_materials_ior",function(){return x.KHR_materials_ior}),B.d(f,"KHR_materials_variants",function(){return x.KHR_materials_variants}),B.d(f,"KHR_materials_transmission",function(){return x.KHR_materials_transmission}),B.d(f,"KHR_materials_translucency",function(){return x.KHR_materials_translucency}),B.d(f,"KHR_mesh_quantization",function(){return x.KHR_mesh_quantization}),B.d(f,"KHR_texture_basisu",function(){return x.KHR_texture_basisu}),B.d(f,"KHR_texture_transform",function(){return x.KHR_texture_transform}),B.d(f,"MSFT_audio_emitter",function(){return x.MSFT_audio_emitter}),B.d(f,"MSFT_lod",function(){return x.MSFT_lod}),B.d(f,"MSFT_minecraftMesh",function(){return x.MSFT_minecraftMesh}),B.d(f,"MSFT_sRGBFactors",function(){return x.MSFT_sRGBFactors}),B.d(f,"ExtrasAsMetadata",function(){return x.ExtrasAsMetadata});var _=B(1),x=(B(6),B(7))},function(v,f,B){B.r(f),B.d(f,"MTLFileLoader",function(){return x}),B.d(f,"OBJFileLoader",function(){return u});var _=B(0),x=function(){function M(){this.materials=[]}return M.prototype.parseMTL=function(R,C,m,c){if(!(C instanceof ArrayBuffer)){for(var E,A=C.split(`
13262`),S=/\s+/,g=null,l=0;l<A.length;l++){var h=A[l].trim();if(h.length!==0&&h.charAt(0)!=="#"){var b=h.indexOf(" "),T=b>=0?h.substring(0,b):h;T=T.toLowerCase();var D=b>=0?h.substring(b+1).trim():"";T==="newmtl"?(g&&this.materials.push(g),R._blockEntityCollection=c,g=new _.StandardMaterial(D,R),R._blockEntityCollection=!1):T==="kd"&&g?(E=D.split(S,3).map(parseFloat),g.diffuseColor=_.Color3.FromArray(E)):T==="ka"&&g?(E=D.split(S,3).map(parseFloat),g.ambientColor=_.Color3.FromArray(E)):T==="ks"&&g?(E=D.split(S,3).map(parseFloat),g.specularColor=_.Color3.FromArray(E)):T==="ke"&&g?(E=D.split(S,3).map(parseFloat),g.emissiveColor=_.Color3.FromArray(E)):T==="ns"&&g?g.specularPower=parseFloat(D):T==="d"&&g?g.alpha=parseFloat(D):T==="map_ka"&&g?g.ambientTexture=M._getTexture(m,D,R):T==="map_kd"&&g?g.diffuseTexture=M._getTexture(m,D,R):T==="map_ks"&&g?g.specularTexture=M._getTexture(m,D,R):T==="map_ns"||(T==="map_bump"&&g?g.bumpTexture=M._getTexture(m,D,R):T==="map_d"&&g&&(g.opacityTexture=M._getTexture(m,D,R)))}}g&&this.materials.push(g)}},M._getTexture=function(R,C,m){if(!C)return null;var c=R;if(R==="file:"){var E=C.lastIndexOf("\\");E===-1&&(E=C.lastIndexOf("/")),c+=E>-1?C.substr(E+1):C}else c+=C;return new _.Texture(c,m,!1,M.INVERT_TEXTURE_Y)},M.INVERT_TEXTURE_Y=!0,M}(),u=function(){function M(R){this.name="obj",this.extensions=".obj",this.obj=/^o/,this.group=/^g/,this.mtllib=/^mtllib /,this.usemtl=/^usemtl /,this.smooth=/^s /,this.vertexPattern=/v(\s+[\d|\.|\+|\-|e|E]+){3,7}/,this.normalPattern=/vn(\s+[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/,this.uvPattern=/vt(\s+[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/,this.facePattern1=/f\s+(([\d]{1,}[\s]?){3,})+/,this.facePattern2=/f\s+((([\d]{1,}\/[\d]{1,}[\s]?){3,})+)/,this.facePattern3=/f\s+((([\d]{1,}\/[\d]{1,}\/[\d]{1,}[\s]?){3,})+)/,this.facePattern4=/f\s+((([\d]{1,}\/\/[\d]{1,}[\s]?){3,})+)/,this.facePattern5=/f\s+(((-[\d]{1,}\/-[\d]{1,}\/-[\d]{1,}[\s]?){3,})+)/,this._forAssetContainer=!1,this._meshLoadOptions=R||M.currentMeshLoadOptions}return Object.defineProperty(M,"INVERT_TEXTURE_Y",{get:function(){return x.INVERT_TEXTURE_Y},set:function(R){x.INVERT_TEXTURE_Y=R}
13262,enumerable:!1,configurable:!0}),Object.defineProperty(M,"currentMeshLoadOptions",{get:function(){return{ComputeNormals:M.COMPUTE_NORMALS,ImportVertexColors:M.IMPORT_VERTEX_COLORS,InvertY:M.INVERT_Y,InvertTextureY:M.INVERT_TEXTURE_Y,UVScaling:M.UV_SCALING,MaterialLoadingFailsSilently:M.MATERIAL_LOADING_FAILS_SILENTLY,OptimizeWithUV:M.OPTIMIZE_WITH_UV,SkipMaterials:M.SKIP_MATERIALS}},enumerable:!1,configurable:!0}),M.prototype._loadMTL=function(R,C,m,c){var E=_.Tools.BaseUrl+C+R;_.Tools.LoadFile(E,m,void 0,void 0,!1,function(A,S){c(E,S)})},M.prototype.createPlugin=function(){return new M(M.currentMeshLoadOptions)},M.prototype.canDirectLoad=function(R){return!1},M.prototype.importMeshAsync=function(R,C,m,c,E,A){return this._parseSolid(R,C,m,c).then(function(S){return{meshes:S,particleSystems:[],skeletons:[],animationGroups:[],transformNodes:[],geometries:[],lights:[]}})},M.prototype.loadAsync=function(R,C,m,c,E){return this.importMeshAsync(null,R,C,m,c).then(function(){})},M.prototype.loadAssetContainerAsync=function(R,C,m,c,E){var A=this;return this._forAssetContainer=!0,this.importMeshAsync(null,R,C,m).then(function(S){var g=new _.AssetContainer(R);return S.meshes.forEach(function(l){return g.meshes.push(l)}),S.meshes.forEach(function(l){var h=l.material;h&&g.materials.indexOf(h)==-1&&(g.materials.push(h),h.getActiveTextures().forEach(function(b){g.textures.indexOf(b)==-1&&g.textures.push(b)}))}),A._forAssetContainer=!1,g}).catch(function(S){throw A._forAssetContainer=!1,S})},M.prototype._parseSolid=function(R,C,m,c){for(var E,A=this,S=[],g=[],l=[],h=[],b=[],T=[],D=[],w=[],N=[],I=[],V=[],W=0,j=!1,ne=[],te=[],de=[],pe=[],ae=[],ee="",K="",$=new x,L=1,G=!0,Q=new _.Color4(.5,.5,.5,1),oe=function(ze,it,et,lt,ct,mt,St){var wt;(wt=A._meshLoadOptions.OptimizeWithUV?function(It,Pt){It[Pt[0]]||(It[Pt[0]]={normals:[],idx:[],uv:[]});var Ot=It[Pt[0]].normals.indexOf(Pt[1]);return Ot!=1&&Pt[2]===It[Pt[0]].uv[Ot]?It[Pt[0]].idx[Ot]:-1}(V,[ze,et,it]):function(It,Pt){It[Pt[0]]||(It[Pt[0]]={normals:[],idx:[]});var Ot=It[Pt[0]].normals.indexOf(Pt[1]);return Ot===-1?-1:It[Pt[0]].idx[Ot]}(V,[ze,et]))===-1?(T.push(D.length),D.push(lt),w.push(ct),I.push(mt),St!==void 0&&N.push(St),V[ze].normals.push(et),V[ze].idx.push(W++),A._meshLoadOptions.OptimizeWithUV&&V[ze].uv.push(it)):T.push(wt)},re=function(){for(var ze=0;ze<D.length;ze++)ne.push(D[ze].x,D[ze].y,D[ze].z),de.push(I[ze].x,I[ze].y,I[ze].z),pe.push(w[ze].x,w[ze].y),A._meshLoadOptions.ImportVertexColors===!0&&te.push(N[ze].r,N[ze].g,N[ze].b,N[ze].a);D=[],I=[],w=[],N=[],V=[],W=0},Y=function(ze,it){for(var et=it;et<ze.length-1;et++)ae.push(ze[0],ze[et],ze[et+1])},k=function(ze,it){Y(ze,it);for(var et=0;et<ae.length;et++){var lt=parseInt(ae[et])-1;oe(lt,0,0,S[lt],_.Vector2.Zero(),_.Vector3.Up(),A._meshLoadOptions.ImportVertexColors===!0?h[lt]:void 0)}ae=[]},H=function(ze,it){Y(ze,it);for(var et=0;et<ae.length;et++){var lt=ae[et].split("/"),ct=parseInt(lt[0])-1,mt=parseInt(lt[1])-1;oe(ct,mt,0,S[ct],l[mt],_.Vector3.Up(),A._meshLoadOptions.ImportVertexColors===!0?h[ct]:void 0)}ae=[]},Z=function(ze,it){Y(ze,it);for(var et=0;et<ae.length;et++){var lt=ae[et].split("/"),ct=parseInt(lt[0])-1,mt=parseInt(lt[1])-1,St=parseInt(lt[2])-1;oe(ct,mt,St,S[ct],l[mt],g[St])}ae=[]},X=function(ze,it){Y(ze,it);for(var et=0;et<ae.length;et++){var lt=ae[et].split("//"),ct=parseInt(lt[0])-1,mt=parseInt(lt[1])-1;oe(ct,1,mt,S[ct],_.Vector2.Zero(),g[mt],A._meshLoadOptions.ImportVertexColors===!0?h[ct]:void 0)}ae=[]},q=function(ze,it){Y(ze,it);for(var et=0;et<ae.length;et++){var lt=ae[et].split("/"),ct=S.length+parseInt(lt[0]),mt=l.length+parseInt(lt[1]),St=g.length+parseInt(lt[2]);oe(ct,mt,St,S[ct],l[mt],g[St],A._meshLoadOptions.ImportVertexColors===!0?h[ct]:void 0)}ae=[]},he=function(){b.length>0&&(E=b[b.length-1],re(),T.reverse(),E.indices=T.slice(),E.positions=ne.slice(),E.normals=de.slice(),E.uvs=pe.slice(),A._meshLoadOptions.ImportVertexColors===!0&&(E.colors=te.slice()),T=[],ne=[],te=[],de=[],pe=[])},ge=m.split(`
13263`),me=0;me<ge.length;me++){var _e,be=ge[me].trim().replace(/\s\s/g," ");if(be.length!==0&&be.charAt(0)!=="#")if(this.vertexPattern.test(be))_e=be.match(/[^ ]+/g),S.push(new _.Vector3(parseFloat(_e[1]),parseFloat(_e[2]),parseFloat(_e[3]))),this._meshLoadOptions.ImportVertexColors===!0&&(_e.length>=7?h.push(new _.Color4(parseFloat(_e[4]),parseFloat(_e[5]),parseFloat(_e[6]),_e.length===7||_e[7]===void 0?1:parseFloat(_e[7]))):h.push(Q
13263));else if((_e=this.normalPattern.exec(be))!==null)g.push(new _.Vector3(parseFloat(_e[1]),parseFloat(_e[2]),parseFloat(_e[3])));else if((_e=this.uvPattern.exec(be))!==null)l.push(new _.Vector2(parseFloat(_e[1])*M.UV_SCALING.x,parseFloat(_e[2])*M.UV_SCALING.y));else if((_e=this.facePattern3.exec(be))!==null)Z(_e[1].trim().split(" "),1);else if((_e=this.facePattern4.exec(be))!==null)X(_e[1].trim().split(" "),1);else if((_e=this.facePattern5.exec(be))!==null)q(_e[1].trim().split(" "),1);else if((_e=this.facePattern2.exec(be))!==null)H(_e[1].trim().split(" "),1);else if((_e=this.facePattern1.exec(be))!==null)k(_e[1].trim().split(" "),1);else if(this.group.test(be)||this.obj.test(be)){var Ce={name:be.substring(2).trim(),indices:void 0,positions:void 0,normals:void 0,uvs:void 0,colors:void 0,materialName:""};he(),b.push(Ce),j=!0,G=!0,L=1}else this.usemtl.test(be)?(ee=be.substring(7).trim(),(!G||!j)&&(he(),Ce={name:"mesh_mm"+L.toString(),indices:void 0,positions:void 0,normals:void 0,uvs:void 0,colors:void 0,materialName:ee},L++,b.push(Ce),j=!0),j&&G&&(b[b.length-1].materialName=ee,G=!1)):this.mtllib.test(be)?K=be.substring(7).trim():this.smooth.test(be)||console.log("Unhandled expression at line : "+be)}j&&(E=b[b.length-1],T.reverse(),re(),E.indices=T,E.positions=ne,E.normals=de,E.uvs=pe,this._meshLoadOptions.ImportVertexColors===!0&&(E.colors=te)),j||(T.reverse(),re(),b.push({name:_.Geometry.RandomId(),indices:T,positions:ne,colors:te,normals:de,uvs:pe,materialName:ee}));for(var ye=[],Be=new Array,Ge=0;Ge<b.length;Ge++){if(R&&b[Ge].name){if(R instanceof Array){if(R.indexOf(b[Ge].name)===-1)continue}else if(b[Ge].name!==R)continue}E=b[Ge],C._blockEntityCollection=this._forAssetContainer;var Xe=new _.Mesh(b[Ge].name,C);C._blockEntityCollection=!1,Be.push(b[Ge].materialName);var He=new _.VertexData;if(He.uvs=E.uvs,He.indices=E.indices,He.positions=E.positions,this._meshLoadOptions.ComputeNormals===!0){var We=new Array;_.VertexData.ComputeNormals(E.positions,E.indices,We),He.normals=We}else He.normals=E.normals;this._meshLoadOptions.ImportVertexColors===!0&&(He.colors=E.colors),He.applyToMesh(Xe),this._meshLoadOptions.InvertY&&(Xe.scaling.y*=-1),ye.push(Xe)}var Ze=[];return K!==""&&this._meshLoadOptions.SkipMaterials===!1&&Ze.push(new Promise(function(ze,it){A._loadMTL(K,c,function(et){try{$.parseMTL(C,et,c,A._forAssetContainer);for(var lt=0;lt<$.materials.length;lt++){for(var ct,mt=0,St=[];(ct=Be.indexOf($.materials[lt].name,mt))>-1;)St.push(ct),mt=ct+1;if(ct===-1&&St.length===0)$.materials[lt].dispose();else for(var wt=0;wt<St.length;wt++)ye[St[wt]].material=$.materials[lt]}ze()}catch(It){_.Tools.Warn("Error processing MTL file: '"+K+"'"),A._meshLoadOptions.MaterialLoadingFailsSilently?ze():it(It)}},function(et,lt){_.Tools.Warn("Error downloading MTL file: '"+K+"'"),A._meshLoadOptions.MaterialLoadingFailsSilently?ze():it(lt)})})),Promise.all(Ze).then(function(){return ye})},M.OPTIMIZE_WITH_UV=!0,M.INVERT_Y=!1,M.IMPORT_VERTEX_COLORS=!1,M.COMPUTE_NORMALS=!1,M.UV_SCALING=new _.Vector2(1,1),M.SKIP_MATERIALS=!1,M.MATERIAL_LOADING_FAILS_SILENTLY=!0,M}();_.SceneLoader&&_.SceneLoader.RegisterPlugin(new u)},function(v,f,B){B.r(f),B.d(f,"STLFileLoader",function(){return x});var _=B(0),x=function(){function u(){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="stl",this.extensions={".stl":{isBinary:!0}}}return u.prototype.importMesh=function(M,R,C,m,c,E,A){var S;if(typeof C!="string"){if(this._isBinary(C)){var g=new _.Mesh("stlmesh",R);return this._parseBinary(g,C),c&&c.push(g),!0}for(var l=new Uint8Array(C),h="",b=0;b<C.byteLength;b++)h+=String.fromCharCode(l[b]);C=h}for(;S=this.solidPattern.exec(C);){var T=S[1];if(T!=S[3])return _.Tools.Error("Error in STL, solid name != endsolid name"),!1;if(M&&T){if(M instanceof Array){if(!M.indexOf(T))continue}else if(T!==M)continue}T=T||"stlmesh",g=new _.Mesh(T,R),this._parseASCII(g,S[2]),c&&c.push(g)}return!0},u.prototype.load=function(M,R,C){return this.importMesh(null,M,R,C,null,null,null)},u.prototype.loadAssetContainer=function(M,R,C,m){var c=new _.AssetContainer(M);return M._blockEntityCollection=!0,this.importMesh(null,M,R,C,c.meshes,null,null),M._blockEntityCollection=!1,c},u.prototype._isBinary=function(M){var R;if(84+50*(R=new DataView(M)).getUint32(80,!0)===R.byteLength)return!0;for(var C=R.byteLength,m=0;m<C;m++)if(R.getUint8(m)>127)return!0;return!1},u.prototype._parseBinary=function(M,R){for(var C=new DataView(R),m=C.getUint32(80,!0),c=0,E=new Float32Array(3*m*3),A=new Float32Array(3*m*3),S=new Uint32Array(3*m),g=0,l=0;l<m;l++){for(var h=84+50*l,b=C.getFloat32(h,!0),T=C.getFloat32(h+4,!0),D=C.getFloat32(h+8,!0),w=1;w<=3;w++){var N=h+12*w;E[c]=C.getFloat32(N,!0),E[c+2]=C.getFloat32(N+4,!0),E[c+1]=C.getFloat32(N+8,!0),A[c]=b,A[c+2]=T,A[c+1]=D,c+=3}S[g]=g++,S[g]=g++,S[g]=g++}M.setVerticesData(_.VertexBuffer.PositionKind,E),M.setVerticesData(_.VertexBuffer.NormalKind,A),M.setIndices(S),M.computeWorldMatrix(!0)},u.prototype._parseASCII=function(M,R){for(var C,m=[],c=[],E=[],A=0;C=this.facetsPattern.exec(R);){var S=C[1],g=this.normalPattern.exec(S);if(this.normalPattern.lastIndex=0,g){for(var l,h=[Number(g[1]),Number(g[5]),Number(g[3])];l=this.vertexPattern.exec(S);)m.push(Number(l[1]),Number(l[5]),Number(l[3])),c.push(h[0],h[1],h[2]);E.push(A++,A++,A++),this.vertexPattern.lastIndex=0}}this.facetsPattern.lastIndex=0,M.setVerticesData(_.VertexBuffer.PositionKind,m),M.setVerticesData(_.VertexBuffer.NormalKind,c),M.setIndices(E),M.computeWorldMatrix(!0)},u}();_.SceneLoader&&_.SceneLoader.RegisterPlugin(new x)},function(v,f,B){(function(_){var x=B(2),u=B(3);B.d(f,"a",function(){return x.GLTFFileLoader}),B.d(f,"b",function(){return x.GLTFLoaderAnimationStartMode}),B.d(f,"c",function(){return x.GLTFLoaderCoordinateSystemMode}),B.d(f,"d",function(){return x.GLTFLoaderState}),B.d(f,"e",function(){return u.GLTFValidation});var M=_!==void 0?_:typeof window<"u"?window:void 0;if(M!==void 0){for(var R in M.BABYLON=M.BABYLON||{},x)M.BABYLON[R]=x[R];for(var R in u)M.BABYLON[R]=u[R]}}).call(this,B(5))},function(v,f,B){(function(_){var x=B(8);B.d(f,"a",function(){return x});var u=_!==void 0?_:typeof window<"u"?window:void 0;if(u!==void 0)for(var M in u.BABYLON=u.BABYLON||{},u.BABYLON.GLTF1=u.BABYLON.GLTF1||{},x)u.BABYLON.GLTF1[M]=x[M]}).call(this,B(5))},function(v,f,B){(function(_){var x=B(7),u=B(6),M=B(9);B.d(f,"a",function(){return M});var R=_!==void 0?_:typeof window<"u"?window:void 0;if(R!==void 0){R.BABYLON=R.BABYLON||{};var C=R.BABYLON;C.GLTF2=C.GLTF2||{},C.GLTF2.Loader=C.GLTF2.Loader||{},C.GLTF2.Loader.Extensions=C.GLTF2.Loader.Extensions||{};var m=[];for(var c in x)C.GLTF2.Loader.Extensions[c]=x[c],m.push(c);for(var c in u)C.GLTF2.Loader[c]=u[c],m.push(c);for(var c in M)m.indexOf(c)>-1||(C.GLTF2[c]=M[c])}}).call(this,B(5))},function(v,f,B){B.r(f),function(_){var x=B(10);B.d(f,"MTLFileLoader",function(){return x.MTLFileLoader}),B.d(f,"OBJFileLoader",function(){return x.OBJFileLoader});var u=_!==void 0?_:typeof window<"u"?window:void 0;if(u!==void 0)for(var M in x)u.BABYLON[M]=x[M]}.call(this,B(5))},function(v,f,B){B.r(f),function(_){var x=B(11);B.d(f,"STLFileLoader",function(){return x.STLFileLoader});var u=_!==void 0?_:typeof window<"u"?window:void 0;if(u!==void 0)for(var M in x)u.BABYLON[M]=x[M]}.call(this,B(5))},,,,function(v,f,B){B.r(f),B.d(f,"GLTFLoaderCoordinateSystemMode",function(){return _.c}),B.d(f,"GLTFLoaderAnimationStartMode",function(){return _.b}),B.d(f,"GLTFLoaderState",function(){return _.d}),B.d(f,"GLTFFileLoader",function(){return _.a}),B.d(f,"GLTFValidation",function(){return _.e}),B.d(f,"GLTF1",function(){return x.a}),B.d(f,"GLTF2",function(){return u.a}),B.d(f,"MTLFileLoader",function(){return M.MTLFileLoader}),B.d(f,"OBJFileLoader",function(){return M.OBJFileLoader}),B.d(f,"STLFileLoader",function(){return R.STLFileLoader}),B(2),B(3),B(8),B(9),B(10),B(11);var _=B(12),x=B(13),u=B(14),M=B(15),R=B(16)}])})})(Hf);var Qi=Hf.exports;const ob=Jv(Qi),Xa=rb({__proto__:null,default:ob}
13263,[Qi]);const{SvelteComponent:ab,append:Do,attr:Ki,binding_callbacks:sb,check_outros:cb,create_component:ll,destroy_component:ul,detach:hl,element:Wa,empty:lb,group_outros:ub,init:hb,insert:dl,mount_component:fl,safe_not_equal:db,space:pl,transition_in:Kr,transition_out:Lo}=window.__gradio__svelte__internal,{onMount:fb}=window.__gradio__svelte__internal;function Lf(Qe){let ke,Ae,v,f,B,_,x,u,M,R,C;return v=new Df({props:{Icon:$v,label:"Undo"}}),v.$on("click",Qe[12]),_=new Df({props:{Icon:Zv,label:Qe[3]("common.download")}}),{c(){ke=Wa("div"),Ae=Wa("div"),ll(v.$$.fragment),f=pl(),B=Wa("a"),ll(_.$$.fragment),M=pl(),R=Wa("canvas"),Ki(B,"href",x=Qe[0].path),Ki(B,"target",window.__is_colab__?"_blank":null),Ki(B,"download",u=window.__is_colab__?null:Qe[0].orig_name||Qe[0].path),Ki(Ae,"class","buttons svelte-xz066x"),Ki(R,"class","svelte-xz066x"),Ki(ke,"class","model3D svelte-xz066x")},m(m,c){dl(m,ke,c),Do(ke,Ae),fl(v,Ae,null),Do(Ae,f),Do(Ae,B),fl(_,B,null),Do(ke,M),Do(ke,R),Qe[13](R),C=!0},p(m,c){const E={};c&8&&(E.label=m[3]("common.download")),_.$set(E),(!C||c&1&&x!==(x=m[0].path))&&Ki(B,"href",x),(!C||c&1&&u!==(u=window.__is_colab__?null:m[0].orig_name||m[0].path))&&Ki(B,"download",u)},i(m){C||(Kr(v.$$.fragment,m),Kr(_.$$.fragment,m),C=!0)},o(m){Lo(v.$$.fragment,m),Lo(_.$$.fragment,m),C=!1},d(m){m&&hl(ke),ul(v),ul(_),Qe[13](null)}}}function pb(Qe){let ke,Ae,v,f;ke=new gl({props:{show_label:Qe[2],Icon:Ya,label:Qe[1]||Qe[3]("3D_model.3d_model")}});let B=Qe[0]&&Lf(Qe);return{c(){ll(ke.$$.fragment),Ae=pl(),B&&B.c(),v=lb()},m(_,x){fl(ke,_,x),dl(_,Ae,x),B&&B.m(_,x),dl(_,v,x),f=!0},p(_,[x]){const u={};x&4&&(u.show_label=_[2]),x&10&&(u.label=_[1]||_[3]("3D_model.3d_model")),ke.$set(u),_[0]?B?(B.p(_,x),x&1&&Kr(B,1)):(B=Lf(_),B.c(),Kr(B,1),B.m(v.parentNode,v)):B&&(ub(),Lo(B,1,1,()=>{B=null}),cb())},i(_){f||(Kr(ke.$$.fragment,_),Kr(B),f=!0)},o(_){Lo(ke.$$.fragment,_),Lo(B),f=!1},d(_){_&&(hl(Ae),hl(v)),ul(ke,_),B&&B.d(_)}}}function _b(Qe,ke,Ae){let v,{value:f}=ke,{clear_color:B=[0,0,0,0]}=ke,{label:_=""}=ke,{show_label:x}=ke,{i18n:u}=ke,{zoom_speed:M=1}=ke,{camera_position:R=[null,null,null]}=ke,C,m,c,E=!1;fb(()=>{c=new _i.Engine(C,!0),window.addEventListener("resize",()=>{c?.resize()}),Ae(10,E=!0)});function A(){m&&!m.isDisposed&&(m.dispose(),c?.stopRenderLoop(),c?.dispose(),c=null,c=new _i.Engine(C,!0),window.addEventListener("resize",()=>{c?.resize()})),c!==null&&(m=zf(C,m,c,f,B,R,M))}function S(){jf(m,R,M)}const g=()=>S();function l(h){sb[h?"unshift":"push"](()=>{C=h,Ae(4,C)})}return Qe.$$set=h=>{"value"in h&&Ae(0,f=h.value),"clear_color"in h&&Ae(6,B=h.clear_color),"label"in h&&Ae(1,_=h.label),"show_label"in h&&Ae(2,x=h.show_label),"i18n"in h&&Ae(3,u=h.i18n),"zoom_speed"in h&&Ae(7,M=h.zoom_speed),"camera_position"in h&&Ae(8,R=h.camera_position)},Qe.$$.update=()=>{Qe.$$.dirty&512&&Qi.OBJFileLoader!=null&&!Qi.OBJFileLoader.IMPORT_VERTEX_COLORS&&Ae(9,Qi.OBJFileLoader.IMPORT_VERTEX_COLORS=!0,Xa),Qe.$$.dirty&1&&Ae(11,{path:v}=f||{path:void 0},v),Qe.$$.dirty&3088&&C&&E&&v&&A()},[f,_,x,u,C,S,B,M,R,Xa,E,v,g,l]}class mb extends ab{constructor(ke){super(),hb(this,ke,_b,pb,db,{value:0,clear_color:6,label:1,show_label:2,i18n:3,zoom_speed:7,camera_position:8})}}const gb=mb;const{SvelteComponent:vb,add_flush_callback:bb,append:Nf,attr:wf,bind:yb,binding_callbacks:Wf,check_outros:Tb,create_component:vl,create_slot:Eb,destroy_component:bl,detach:_l,element:Ff,empty:Sb,get_all_dirty_from_scope:Ab,get_slot_changes:Pb,group_outros:Cb,init:xb,insert:ml,mount_component:yl,safe_not_equal:Rb,space:Xf,transition_in:qr,transition_out:Zr,update_slot_base:Ob}=window.__gradio__svelte__internal,{createEventDispatcher:Mb,tick:Bf,onMount:Ib}=window.__gradio__svelte__internal;function Db(Qe){let ke,Ae,v,f,B;return Ae=new eb({props:{undoable:!0,i18n:Qe[4],absolute:!0}}),Ae.$on("clear",Qe[8]),Ae.$on("undo",Qe[9]),{c(){ke=Ff("div"),vl(Ae.$$.fragment),v=Xf(),f=Ff("canvas"),wf(f,"class","svelte-15mfcnc"),wf(ke,"class","input-model svelte-15mfcnc")},m(_,x){ml(_,ke,x),yl(Ae,ke,null),Nf(ke,v),Nf(ke,f),Qe[18](f),B=!0},p(_,x){const u={};x&16&&(u.i18n=_[4]),Ae.$set(u)},i(_){B||(qr(Ae.$$.fragment,_),B=!0)},o(_){Zr(Ae.$$.fragment,_),B=!1},d(_){_&&_l(ke),bl(Ae),Qe[18](null)}}}
13263function Lb(Qe){let ke,Ae,v;function f(_){Qe[17](_)}let B={root:Qe[3],filetype:".obj, .gltf, .glb",$$slots:{default:[Nb]},$$scope:{ctx:Qe}};return Qe[6]!==void 0&&(B.dragging=Qe[6]),ke=new tb({props:B}),Wf.push(()=>yb(ke,"dragging",f)),ke.$on("load",Qe[7]),{c(){vl(ke.$$.fragment)},m(_,x){yl(ke,_,x),v=!0},p(_,x){const u={};x&8&&(u.root=_[3]),x&524288&&(u.$$scope={dirty:x,ctx:_}),!Ae&&x&64&&(Ae=!0,u.dragging=_[6],bb(()=>Ae=!1)),ke.$set(u)},i(_){v||(qr(ke.$$.fragment,_),v=!0)},o(_){Zr(ke.$$.fragment,_),v=!1},d(_){bl(ke,_)}}}function Nb(Qe){let ke;const Ae=Qe[16].default,v=Eb(Ae,Qe,Qe[19],null);return{c(){v&&v.c()},m(f,B){v&&v.m(f,B),ke=!0},p(f,B){v&&v.p&&(!ke||B&524288)&&Ob(v,Ae,f,f[19],ke?Pb(Ae,f[19],B,null):Ab(f[19]),null)},i(f){ke||(qr(v,f),ke=!0)},o(f){Zr(v,f),ke=!1},d(f){v&&v.d(f)}}}function wb(Qe){let ke,Ae,v,f,B,_;ke=new gl({props:{show_label:Qe[2],Icon:Ya,label:Qe[1]||"3D Model"}});const x=[Lb,Db],u=[];function M(R,C){return R[0]===null?0:1}return v=M(Qe),f=u[v]=x[v](Qe),{c(){vl(ke.$$.fragment),Ae=Xf(),f.c(),B=Sb()},m(R,C){yl(ke,R,C),ml(R,Ae,C),u[v].m(R,C),ml(R,B,C),_=!0},p(R,[C]){const m={};C&4&&(m.show_label=R[2]),C&2&&(m.label=R[1]||"3D Model"),ke.$set(m);let c=v;v=M(R),v===c?u[v].p(R,C):(Cb(),Zr(u[c],1,1,()=>{u[c]=null}),Tb(),f=u[v],f?f.p(R,C):(f=u[v]=x[v](R),f.c()),qr(f,1),f.m(B.parentNode,B))},i(R){_||(qr(ke.$$.fragment,R),qr(f),_=!0)},o(R){Zr(ke.$$.fragment,R),Zr(f),_=!1},d(R){R&&(_l(Ae),_l(B)),bl(ke,R),u[v].d(R)}}}function Fb(Qe,ke,Ae){let v,{$$slots:f={},$$scope:B}=ke,{value:_}=ke,{clear_color:x=[0,0,0,0]}=ke,{label:u=""}=ke,{show_label:M}=ke,{root:R}=ke,{i18n:C}=ke,{zoom_speed:m=1}=ke,{camera_position:c=[null,null,null]}=ke,E=!1,A,S,g;function l(){S=zf(A,S,g,_,x,c,m)}Ib(()=>{_!=null&&l(),Ae(13,E=!0)});async function h({detail:V}){Ae(0,_=V),await Bf(),l(),D("change",_)}async function b(){S&&g&&(S.dispose(),g.dispose()),Ae(0,_=null),await Bf(),D("clear")}async function T(){jf(S,c,m)}const D=Mb();let w=!1;function N(V){w=V,Ae(6,w)}function I(V){Wf[V?"unshift":"push"](()=>{A=V,Ae(5,A)})}return Qe.$$set=V=>{"value"in V&&Ae(0,_=V.value),"clear_color"in V&&Ae(10,x=V.clear_color),"label"in V&&Ae(1,u=V.label),"show_label"in V&&Ae(2,M=V.show_label),"root"in V&&Ae(3,R=V.root),"i18n"in V&&Ae(4,C=V.i18n),"zoom_speed"in V&&Ae(11,m=V.zoom_speed),"camera_position"in V&&Ae(12,c=V.camera_position),"$$scope"in V&&Ae(19,B=V.$$scope)},Qe.$$.update=()=>{Qe.$$.dirty&1&&Ae(15,{path:v}=_||{path:void 0},v),Qe.$$.dirty&40992&&A&&E&&v!=null&&l(),Qe.$$.dirty&16384&&Qi.OBJFileLoader!=null&&!Qi.OBJFileLoader.IMPORT_VERTEX_COLORS&&Ae(14,Qi.OBJFileLoader.IMPORT_VERTEX_COLORS=!0,Xa),Qe.$$.dirty&64&&D("drag",w)},[_,u,M,R,C,A,w,h,b,T,x,m,c,E,Xa,v,f,N,I,B]}class Bb extends vb{constructor(ke){super(),xb(this,ke,Fb,wb,Rb,{value:0,clear_color:10,label:1,show_label:2,root:3,i18n:4,zoom_speed:11,camera_position:12})}}const Ub=Bb,{SvelteComponent:Vb,assign:Yf,check_outros:Kf,create_component:mi,destroy_component:gi,detach:No,empty:Qf,get_spread_object:qf,get_spread_update:Zf,group_outros:Jf,init:kb,insert:wo,mount_component:vi,safe_not_equal:Gb,space:Tl,transition_in:Un,transition_out:Vn}=window.__gradio__svelte__internal;function zb(Qe){let ke,Ae;return ke=new Uf({props:{visible:Qe[3],variant:Qe[0]===null?"dashed":"solid",border_mode:Qe[18]?"focus":"base",padding:!1,elem_id:Qe[1],elem_classes:Qe[2],container:Qe[9],scale:Qe[10],min_width:Qe[11],height:Qe[13],$$slots:{default:[Wb]},$$scope:{ctx:Qe}}}),{c(){mi(ke.$$.fragment)},m(v,f){vi(ke,v,f),Ae=!0},p(v,f){const B={};f&8&&(B.visible=v[3]),f&1&&(B.variant=v[0]===null?"dashed":"solid"),f&262144&&(B.border_mode=v[18]?"focus":"base"),f&2&&(B.elem_id=v[1]),f&4&&(B.elem_classes=v[2]),f&512&&(B.container=v[9]),f&1024&&(B.scale=v[10]),f&2048&&(B.min_width=v[11]),f&8192&&(B.height=v[13]),f&17224177&&(B.$$scope={dirty:f,ctx:v}),ke.$set(B)},i(v){Ae||(Un(ke.$$.fragment,v),Ae=!0)},o(v){Vn(ke.$$.fragment,v),Ae=!1},d(v){gi(ke,v)}}}function jb(Qe){let ke,Ae;return ke=new Uf({props:{visible:Qe[3],variant:Qe[0]===null?"dashed":"solid",border_mode:Qe[18]?"focus":"base",padding:!1,elem_id:Qe[1],elem_classes:Qe[2],container:Qe[9],scale:Qe[10],min_width:Qe[11],height:Qe[13],$$slots:{default:[Qb]},$$scope:{ctx:Qe}}}),{c(){mi(ke.$$.fragment)},m(v,f){vi(ke,v,f),Ae=!0},p(v,f){const B={};
13263f&8&&(B.visible=v[3]),f&1&&(B.variant=v[0]===null?"dashed":"solid"),f&262144&&(B.border_mode=v[18]?"focus":"base"),f&2&&(B.elem_id=v[1]),f&4&&(B.elem_classes=v[2]),f&512&&(B.container=v[9]),f&1024&&(B.scale=v[10]),f&2048&&(B.min_width=v[11]),f&8192&&(B.height=v[13]),f&16962017&&(B.$$scope={dirty:f,ctx:v}),ke.$set(B)},i(v){Ae||(Un(ke.$$.fragment,v),Ae=!0)},o(v){Vn(ke.$$.fragment,v),Ae=!1},d(v){gi(ke,v)}}}function Hb(Qe){let ke,Ae;return ke=new ib({props:{i18n:Qe[12].i18n,type:"file"}}),{c(){mi(ke.$$.fragment)},m(v,f){vi(ke,v,f),Ae=!0},p(v,f){const B={};f&4096&&(B.i18n=v[12].i18n),ke.$set(B)},i(v){Ae||(Un(ke.$$.fragment,v),Ae=!0)},o(v){Vn(ke.$$.fragment,v),Ae=!1},d(v){gi(ke,v)}}}function Wb(Qe){let ke,Ae,v,f;const B=[{autoscroll:Qe[12].autoscroll},{i18n:Qe[12].i18n},Qe[6]];let _={};for(let x=0;x<B.length;x+=1)_=Yf(_,B[x]);return ke=new Vf({props:_}),v=new Ub({props:{label:Qe[7],show_label:Qe[8],root:Qe[4],clear_color:Qe[5],value:Qe[17],camera_position:Qe[15],zoom_speed:Qe[14],i18n:Qe[12].i18n,$$slots:{default:[Hb]},$$scope:{ctx:Qe}}}),v.$on("change",Qe[20]),v.$on("drag",Qe[21]),v.$on("change",Qe[22]),v.$on("clear",Qe[23]),{c(){mi(ke.$$.fragment),Ae=Tl(),mi(v.$$.fragment)},m(x,u){vi(ke,x,u),wo(x,Ae,u),vi(v,x,u),f=!0},p(x,u){const M=u&4160?Zf(B,[u&4096&&{autoscroll:x[12].autoscroll},u&4096&&{i18n:x[12].i18n},u&64&&qf(x[6])]):{};ke.$set(M);const R={};u&128&&(R.label=x[7]),u&256&&(R.show_label=x[8]),u&16&&(R.root=x[4]),u&32&&(R.clear_color=x[5]),u&131072&&(R.value=x[17]),u&32768&&(R.camera_position=x[15]),u&16384&&(R.zoom_speed=x[14]),u&4096&&(R.i18n=x[12].i18n),u&16781312&&(R.$$scope={dirty:u,ctx:x}),v.$set(R)},i(x){f||(Un(ke.$$.fragment,x),Un(v.$$.fragment,x),f=!0)},o(x){Vn(ke.$$.fragment,x),Vn(v.$$.fragment,x),f=!1},d(x){x&&No(Ae),gi(ke,x),gi(v,x)}}}function Xb(Qe){let ke,Ae,v,f;return ke=new gl({props:{show_label:Qe[8],Icon:Ya,label:Qe[7]||"3D Model"}}),v=new nb({props:{unpadded_box:!0,size:"large",$$slots:{default:[Kb]},$$scope:{ctx:Qe}}}),{c(){mi(ke.$$.fragment),Ae=Tl(),mi(v.$$.fragment)},m(B,_){vi(ke,B,_),wo(B,Ae,_),vi(v,B,_),f=!0},p(B,_){const x={};_&256&&(x.show_label=B[8]),_&128&&(x.label=B[7]||"3D Model"),ke.$set(x);const u={};_&16777216&&(u.$$scope={dirty:_,ctx:B}),v.$set(u)},i(B){f||(Un(ke.$$.fragment,B),Un(v.$$.fragment,B),f=!0)},o(B){Vn(ke.$$.fragment,B),Vn(v.$$.fragment,B),f=!1},d(B){B&&No(Ae),gi(ke,B),gi(v,B)}}}function Yb(Qe){let ke,Ae;return ke=new gb({props:{value:Qe[17],i18n:Qe[12].i18n,clear_color:Qe[5],label:Qe[7],show_label:Qe[8],camera_position:Qe[15],zoom_speed:Qe[14]}}),{c(){mi(ke.$$.fragment)},m(v,f){vi(ke,v,f),Ae=!0},p(v,f){const B={};f&131072&&(B.value=v[17]),f&4096&&(B.i18n=v[12].i18n),f&32&&(B.clear_color=v[5]),f&128&&(B.label=v[7]),f&256&&(B.show_label=v[8]),f&32768&&(B.camera_position=v[15]),f&16384&&(B.zoom_speed=v[14]),ke.$set(B)},i(v){Ae||(Un(ke.$$.fragment,v),Ae=!0)},o(v){Vn(ke.$$.fragment,v),Ae=!1},d(v){gi(ke,v)}}}function Kb(Qe){let ke,Ae;return ke=new Ya({}),{c(){mi(ke.$$.fragment)},m(v,f){vi(ke,v,f),Ae=!0},i(v){Ae||(Un(ke.$$.fragment,v),Ae=!0)},o(v){Vn(ke.$$.fragment,v),Ae=!1},d(v){gi(ke,v)}}}function Qb(Qe){let ke,Ae,v,f,B,_;const x=[{autoscroll:Qe[12].autoscroll},{i18n:Qe[12].i18n},Qe[6]];let u={};for(let m=0;m<x.length;m+=1)u=Yf(u,x[m]);ke=new Vf({props:u});const M=[Yb,Xb],R=[];function C(m,c){return m[0]?0:1}return v=C(Qe),f=R[v]=M[v](Qe),{c(){mi(ke.$$.fragment),Ae=Tl(),f.c(),B=Qf()},m(m,c){vi(ke,m,c),wo(m,Ae,c),R[v].m(m,c),wo(m,B,c),_=!0},p(m,c){const E=c&4160?Zf(x,[c&4096&&{autoscroll:m[12].autoscroll},c&4096&&{i18n:m[12].i18n},c&64&&qf(m[6])]):{};ke.$set(E);let A=v;v=C(m),v===A?R[v].p(m,c):(Jf(),Vn(R[A],1,1,()=>{R[A]=null}),Kf(),f=R[v],f?f.p(m,c):(f=R[v]=M[v](m),f.c()),Un(f,1),f.m(B.parentNode,B))},i(m){_||(Un(ke.$$.fragment,m),Un(f),_=!0)},o(m){Vn(ke.$$.fragment,m),Vn(f),_=!1},d(m){m&&(No(Ae),No(B)),gi(ke,m),R[v].d(m)}}}function qb(Qe){let ke,Ae,v,f;const B=[jb,zb],_=[];function x(u,M){return u[16]?1:0}return ke=x(Qe),Ae=_[ke]=B[ke](Qe),{c(){Ae.c(),v=Qf()},m(u,M){_[ke].m(u,M),wo(u,v,M),f=!0},p(u,[M]){let R=ke;ke=x(u),ke===R?_[ke].p(u,M):(Jf(),Vn(_[R],1,1,()=>{_[R]=null}),Kf(),Ae=_[ke],Ae?Ae.p(u,M):(Ae=_[ke]=B[ke](u),Ae.c()),Un(Ae,1),Ae.m(v.parentNode,v))},i(u){f||(Un(Ae),f=!0)},o(u){Vn(Ae),f=!1},d(u){u&&No(v),_[ke].d(u)}}}function Zb(Qe,ke,Ae){let{elem_id:v=""}=ke,{elem_classes:f=[]}=ke,{visible:B=!0}=ke,{value:_=null}=ke,{root:x}=ke,{proxy_url:u}=ke,{clear_color:M}=ke,{loading_status:R}=ke,{label:C}=ke,{show_label:m}=ke,{container:c=!0}=ke,{scale:E=null}=ke,{min_width:A=void 0}=ke,{gradio:S}=ke,{height:g=void 0}=ke,{zoom_speed:l=1}=ke,{camera_position:h=[null,null,null]}=ke,{interactive:b}=ke,T,D=!1;const w=({detail:W})=>Ae(0,_=W),N=({detail:W})=>Ae(18,D=W),I=({detail:W})=>S.dispatch("change",W),V=()=>S.dispatch("clear");return Qe.$$set=W=>{"elem_id"in W&&Ae(1,v=W.elem_id),"elem_classes"in W&&Ae(2,f=W.elem_classes),"visible"in W&&Ae(3,B=W.visible),"value"in W&&Ae(0,_=W.value),"root"in W&&Ae(4,x=W.root),"proxy_url"in W&&Ae(19,u=W.proxy_url),"clear_color"in W&&Ae(5,M=W.clear_color),"loading_status"in W&&Ae(6,R=W.loading_status),"label"in W&&Ae(7,C=W.label),"show_label"in W&&Ae(8,m=W.show_label),"container"in W&&Ae(9,c=W.container),"scale"in W&&Ae(10,E=W.scale),"min_width"in W&&Ae(11,A=W.min_width),"gradio"in W&&Ae(12,S=W.gradio),"he
13263ight"in W&&Ae(13,g=W.height),"zoom_speed"in W&&Ae(14,l=W.zoom_speed),"camera_position"in W&&Ae(15,h=W.camera_position),"interactive"in W&&Ae(16,b=W.interactive)},Qe.$$.update=()=>{Qe.$$.dirty&524305&&Ae(17,T=qv(_,x,u))},[_,v,f,B,x,M,R,C,m,c,E,A,S,g,l,h,b,T,D,u,w,N,I,V]}class dy extends Vb{constructor(ke){super(),kb(this,ke,Zb,qb,Gb,{elem_id:1,elem_classes:2,visible:3,value:0,root:4,proxy_url:19,clear_color:5,loading_status:6,label:7,show_label:8,container:9,scale:10,min_width:11,gradio:12,height:13,zoom_speed:14,camera_position:15,interactive:16})}}export{_y as BaseExample,gb as BaseModel3D,Ub as BaseModel3DUpload,dy as default};
13264//# sourceMappingURL=Index-5132bde6.js.map

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