diff --git "a/gradio/templates/frontend/assets/index.a791a429.js" "b/gradio/templates/frontend/assets/index.a791a429.js" new file mode 100644--- /dev/null +++ "b/gradio/templates/frontend/assets/index.a791a429.js" @@ -0,0 +1,13264 @@ +import{S as rl,i as ol,s as al,F as Qr,c as Wn,G as Jr,B as bi,f as Di,D as qr,m as Xn,o as un,t as mn,p as Li,l as Yn,e as sl,k as cl,n as ll,r as xf,af as Cf,b as ul,q as xv,V as Sf,E as Rf,a as Cv,j as Rv,W as Ov,X as Mv,Y as Iv,Z as Dv,v as Lv,a7 as Nv,g as wv,h as Fv,x as Af}from"./index.37b24c07.js";import{n as Bv}from"./ModifyUpload.svelte_svelte_type_style_lang.e946db2d.js";import{a as Uv}from"./Empty.svelte_svelte_type_style_lang.94e7c7a3.js";import{B as hl}from"./BlockLabel.7ce695d8.js";import{E as Vv}from"./Empty.ae5c2506.js";/* empty css */import{F as za}from"./File.92a85ebc.js";import{I as kv,M as Gv}from"./ModifyUpload.6b6d2d33.js";import{D as zv}from"./Download.5a6e5fa3.js";import{c as Zr}from"./_commonjsHelpers.a5007c1f.js";import{U as jv}from"./Upload.233e3186.js";import{U as Hv}from"./UploadText.dca45b41.js";import"./Blocks.5efe22d4.js";import{E as Cb}from"./Model3D.e4f84941.js";var Hn={exports:{}};(function(ht,Ke){(function(Me,y){ht.exports=y()})(typeof self<"u"?self:typeof Zr<"u"?Zr:Zr,function(){return function(Me){var y={};function f(U){if(y[U])return y[U].exports;var _=y[U]={i:U,l:!1,exports:{}};return Me[U].call(_.exports,_,_.exports,f),_.l=!0,_.exports}return f.m=Me,f.c=y,f.d=function(U,_,C){f.o(U,_)||Object.defineProperty(U,_,{enumerable:!0,get:C})},f.r=function(U){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(U,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(U,"__esModule",{value:!0})},f.t=function(U,_){if(1&_&&(U=f(U)),8&_||4&_&&typeof U=="object"&&U&&U.__esModule)return U;var C=Object.create(null);if(f.r(C),Object.defineProperty(C,"default",{enumerable:!0,value:U}),2&_&&typeof U!="string")for(var u in U)f.d(C,u,function(M){return U[M]}.bind(null,u));return C},f.n=function(U){var _=U&&U.__esModule?function(){return U.default}:function(){return U};return f.d(_,"a",_),_},f.o=function(U,_){return Object.prototype.hasOwnProperty.call(U,_)},f.p="",f(f.s=169)}([function(Me,y,f){f.d(y,"d",function(){return R}),f.d(y,"e",function(){return x}),f.d(y,"f",function(){return m}),f.d(y,"b",function(){return c}),f.d(y,"a",function(){return T}),f.d(y,"c",function(){return S});var U=f(14),_=f(28),C=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&&U.a.WithinEpsilon(this.x,l.x,h)&&U.a.WithinEpsilon(this.y,l.y,h)},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,v){v.x=l[h],v.y=l[h+1]},g.CatmullRom=function(l,h,v,E,D){var w=D*D,N=D*w;return new g(.5*(2*h.x+(-l.x+v.x)*D+(2*l.x-5*h.x+4*v.x-E.x)*w+(-l.x+3*h.x-3*v.x+E.x)*N),.5*(2*h.y+(-l.y+v.y)*D+(2*l.y-5*h.y+4*v.y-E.y)*w+(-l.y+3*h.y-3*v.y+E.y)*N))},g.Clamp=function(l,h,v){var E=l.x;E=(E=E>v.x?v.x:E)v.y?v.y:D)h.x?l.x:h.x,l.y>h.y?l.y:h.y)},g.Transform=function(l,h){var v=g.Zero();return g.TransformToRef(l,h,v),v},g.TransformToRef=function(l,h,v){var E=h.m,D=l.x*E[0]+l.y*E[4]+E[12],w=l.x*E[1]+l.y*E[5]+E[13];v.x=D,v.y=w},g.PointInTriangle=function(l,h,v,E){var D=.5*(-v.y*E.x+h.y*(-v.x+E.x)+h.x*(v.y-E.y)+v.x*E.y),w=D<0?-1:1,N=(h.y*E.x-h.x*E.y+(E.y-h.y)*l.x+(h.x-E.x)*l.y)*w,I=(h.x*v.y-h.y*v.x+(h.y-v.y)*l.x+(v.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 v=l.x-h.x,E=l.y-h.y;return v*v+E*E},g.Center=function(l,h){var v=l.add(h);return v.scaleInPlace(.5),v},g.DistanceOfPointFromSegment=function(l,h,v){var E=g.DistanceSquared(h,v);if(E===0)return g.Distance(l,h);var D=v.subtract(h),w=Math.max(0,Math.min(1,g.Dot(l.subtract(h),D)/E)),N=h.add(D.multiplyByFloats(w,w));return g.Distance(l,N)},g}(),x=function(){function g(l,h,v){l===void 0&&(l=0),h===void 0&&(h=0),v===void 0&&(v=0),this._isDirty=!0,this._x=l,this._y=h,this._z=v}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,v){return this.x+=l,this.y+=h,this.z+=v,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,v){return new g(this._x-l,this._y-h,this._z-v)},g.prototype.subtractFromFloatsToRef=function(l,h,v,E){return E.copyFromFloats(this._x-l,this._y-h,this._z-v)},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 v=g.Zero();return this.projectOnPlaneToRef(l,h,v),v},g.prototype.projectOnPlaneToRef=function(l,h,v){var E=l.normal,D=l.d,w=A.Vector3[0];this.subtractToRef(h,w),w.normalize();var N=g.Dot(w,E),I=-(g.Dot(h,E)+D)/N,V=w.scaleInPlace(I);h.addToRef(V,v)},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&&U.a.WithinEpsilon(this._x,l._x,h)&&U.a.WithinEpsilon(this._y,l._y,h)&&U.a.WithinEpsilon(this._z,l._z,h)},g.prototype.equalsToFloats=function(l,h,v){return this._x===l&&this._y===h&&this._z===v},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*l._y,this._z*l._z)},g.prototype.multiplyByFloats=function(l,h,v){return new g(this._x*l,this._y*h,this._z*v)},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,v){return lthis._x&&(this.x=l),h>this._y&&(this.y=h),v>this._z&&(this.z=v),this},g.prototype.isNonUniformWithinEpsilon=function(l){var h=Math.abs(this._x),v=Math.abs(this._y);if(!U.a.WithinEpsilon(h,v,l))return!0;var E=Math.abs(this._z);return!U.a.WithinEpsilon(h,E,l)||!U.a.WithinEpsilon(v,E,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(v,E){h[v]=A.Vector3[0][l[E]]})),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,v){return this.subtractToRef(h,A.Vector3[0]),A.Vector3[0].rotateByQuaternionToRef(l,A.Vector3[0]),h.addToRef(A.Vector3[0],v),v},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,v){return this.x=l,this.y=h,this.z=v,this},g.prototype.set=function(l,h,v){return this.copyFromFloats(l,h,v)},g.prototype.setAll=function(l){return this.x=this.y=this.z=l,this},g.GetClipFactor=function(l,h,v,E){var D=g.Dot(l,v)-E;return D/(D-(g.Dot(h,v)-E))},g.GetAngleBetweenVectors=function(l,h,v){var E=l.normalizeToRef(A.Vector3[1]),D=h.normalizeToRef(A.Vector3[2]),w=g.Dot(E,D),N=A.Vector3[3];return g.CrossToRef(E,D,N),g.Dot(N,v)>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,v){v.x=l[h],v.y=l[h+1],v.z=l[h+2]},g.FromFloatArrayToRef=function(l,h,v){return g.FromArrayToRef(l,h,v)},g.FromFloatsToRef=function(l,h,v,E){E.copyFromFloats(l,h,v)},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 v=g.Zero();return g.TransformCoordinatesToRef(l,h,v),v},g.TransformCoordinatesToRef=function(l,h,v){g.TransformCoordinatesFromFloatsToRef(l._x,l._y,l._z,h,v)},g.TransformCoordinatesFromFloatsToRef=function(l,h,v,E,D){var w=E.m,N=l*w[0]+h*w[4]+v*w[8]+w[12],I=l*w[1]+h*w[5]+v*w[9]+w[13],V=l*w[2]+h*w[6]+v*w[10]+w[14],X=1/(l*w[3]+h*w[7]+v*w[11]+w[15]);D.x=N*X,D.y=I*X,D.z=V*X},g.TransformNormal=function(l,h){var v=g.Zero();return g.TransformNormalToRef(l,h,v),v},g.TransformNormalToRef=function(l,h,v){this.TransformNormalFromFloatsToRef(l._x,l._y,l._z,h,v)},g.TransformNormalFromFloatsToRef=function(l,h,v,E,D){var w=E.m;D.x=l*w[0]+h*w[4]+v*w[8],D.y=l*w[1]+h*w[5]+v*w[9],D.z=l*w[2]+h*w[6]+v*w[10]},g.CatmullRom=function(l,h,v,E,D){var w=D*D,N=D*w;return new g(.5*(2*h._x+(-l._x+v._x)*D+(2*l._x-5*h._x+4*v._x-E._x)*w+(-l._x+3*h._x-3*v._x+E._x)*N),.5*(2*h._y+(-l._y+v._y)*D+(2*l._y-5*h._y+4*v._y-E._y)*w+(-l._y+3*h._y-3*v._y+E._y)*N),.5*(2*h._z+(-l._z+v._z)*D+(2*l._z-5*h._z+4*v._z-E._z)*w+(-l._z+3*h._z-3*v._z+E._z)*N))},g.Clamp=function(l,h,v){var E=new g;return g.ClampToRef(l,h,v,E),E},g.ClampToRef=function(l,h,v,E){var D=l._x;D=(D=D>v._x?v._x:D)v._y?v._y:w)v._z?v._z:N)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 x(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,v,E){return this.x=l,this.y=h,this.z=v,this.w=E,this},g.prototype.set=function(l,h,v,E){return this.copyFromFloats(l,h,v,E)},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,v){v.x=l[h],v.y=l[h+1],v.z=l[h+2],v.w=l[h+3]},g.FromFloatArrayToRef=function(l,h,v){g.FromArrayToRef(l,h,v)},g.FromFloatsToRef=function(l,h,v,E,D){D.x=l,D.y=h,D.z=v,D.w=E},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 v=l.clone();return v.minimizeInPlace(h),v},g.Maximize=function(l,h){var v=l.clone();return v.maximizeInPlace(h),v},g.Distance=function(l,h){return Math.sqrt(g.DistanceSquared(l,h))},g.DistanceSquared=function(l,h){var v=l.x-h.x,E=l.y-h.y,D=l.z-h.z,w=l.w-h.w;return v*v+E*E+D*D+w*w},g.Center=function(l,h){var v=l.add(h);return v.scaleInPlace(.5),v},g.TransformNormal=function(l,h){var v=g.Zero();return g.TransformNormalToRef(l,h,v),v},g.TransformNormalToRef=function(l,h,v){var E=h.m,D=l.x*E[0]+l.y*E[4]+l.z*E[8],w=l.x*E[1]+l.y*E[5]+l.z*E[9],N=l.x*E[2]+l.y*E[6]+l.z*E[10];v.x=D,v.y=w,v.z=N,v.w=l.w},g.TransformNormalFromFloatsToRef=function(l,h,v,E,D,w){var N=D.m;w.x=l*N[0]+h*N[4]+v*N[8],w.y=l*N[1]+h*N[5]+v*N[9],w.z=l*N[2]+h*N[6]+v*N[10],w.w=E},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,v,E){l===void 0&&(l=0),h===void 0&&(h=0),v===void 0&&(v=0),E===void 0&&(E=1),this._isDirty=!0,this._x=l,this._y=h,this._z=v,this._w=E}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&&U.a.WithinEpsilon(this._x,l._x,h)&&U.a.WithinEpsilon(this._y,l._y,h)&&U.a.WithinEpsilon(this._z,l._z,h)&&U.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,v,E){return this.x=l,this.y=h,this.z=v,this.w=E,this},g.prototype.set=function(l,h,v,E){return this.copyFromFloats(l,h,v,E)},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 v=this._x*l._w+this._y*l._z-this._z*l._y+this._w*l._x,E=-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(v,E,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=x.Zero();return this.toEulerAnglesToRef(h),h},g.prototype.toEulerAnglesToRef=function(l){var h=this._z,v=this._x,E=this._y,D=this._w,w=D*D,N=h*h,I=v*v,V=E*E,X=E*h-v*D;return X<-.4999999?(l.y=2*Math.atan2(E,D),l.x=Math.PI/2,l.z=0):X>.4999999?(l.y=2*Math.atan2(E,D),l.x=-Math.PI/2,l.z=0):(l.z=Math.atan2(2*(v*E+h*D),-N-I+V+w),l.x=Math.asin(-2*(h*E-v*D)),l.y=Math.atan2(2*(h*v+E*D),N-I-V+w)),this},g.prototype.toRotationMatrix=function(l){return T.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 v,E=l.m,D=E[0],w=E[4],N=E[8],I=E[1],V=E[5],X=E[9],j=E[2],ne=E[6],te=E[10],de=D+V+te;de>0?(v=.5/Math.sqrt(de+1),h.w=.25/v,h.x=(ne-X)*v,h.y=(N-j)*v,h.z=(I-w)*v):D>V&&D>te?(v=2*Math.sqrt(1+D-V-te),h.w=(ne-X)/v,h.x=.25*v,h.y=(w+I)/v,h.z=(N+j)/v):V>te?(v=2*Math.sqrt(1+V-D-te),h.w=(N-j)/v,h.x=(w+I)/v,h.y=.25*v,h.z=(X+ne)/v):(v=2*Math.sqrt(1+te-D-V),h.w=(I-w)/v,h.x=(N+j)/v,h.y=(X+ne)/v,h.z=.25*v)},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,v){var E=Math.sin(h/2);return l.normalize(),v.w=Math.cos(h/2),v.x=l._x*E,v.y=l._y*E,v.z=l._z*E,v},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,v){v.x=l[h],v.y=l[h+1],v.z=l[h+2],v.w=l[h+3]},g.FromEulerAngles=function(l,h,v){var E=new g;return g.RotationYawPitchRollToRef(h,l,v,E),E},g.FromEulerAnglesToRef=function(l,h,v,E){return g.RotationYawPitchRollToRef(h,l,v,E),E},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,v){var E=new g;return g.RotationYawPitchRollToRef(l,h,v,E),E},g.RotationYawPitchRollToRef=function(l,h,v,E){var D=.5*v,w=.5*h,N=.5*l,I=Math.sin(D),V=Math.cos(D),X=Math.sin(w),j=Math.cos(w),ne=Math.sin(N),te=Math.cos(N);E.x=te*X*V+ne*j*I,E.y=ne*j*V-te*X*I,E.z=te*j*I-ne*X*V,E.w=te*j*V+ne*X*I},g.RotationAlphaBetaGamma=function(l,h,v){var E=new g;return g.RotationAlphaBetaGammaToRef(l,h,v,E),E},g.RotationAlphaBetaGammaToRef=function(l,h,v,E){var D=.5*(v+l),w=.5*(v-l),N=.5*h;E.x=Math.cos(w)*Math.sin(N),E.y=Math.sin(w)*Math.sin(N),E.z=Math.sin(D)*Math.cos(N),E.w=Math.cos(D)*Math.cos(N)},g.RotationQuaternionFromAxis=function(l,h,v){var E=new g(0,0,0,0);return g.RotationQuaternionFromAxisToRef(l,h,v,E),E},g.RotationQuaternionFromAxisToRef=function(l,h,v,E){var D=A.Matrix[0];T.FromXYZAxesToRef(l.normalize(),h.normalize(),v.normalize(),D),g.FromRotationMatrixToRef(D,E)},g.Slerp=function(l,h,v){var E=g.Identity();return g.SlerpToRef(l,h,v,E),E},g.SlerpToRef=function(l,h,v,E){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-v,D=I?-v:v;else{var V=Math.acos(N),X=1/Math.sin(V);w=Math.sin((1-v)*V)*X,D=I?-Math.sin(v*V)*X:Math.sin(v*V)*X}E.x=w*l._x+D*h._x,E.y=w*l._y+D*h._y,E.z=w*l._z+D*h._z,E.w=w*l._w+D*h._w},g.Hermite=function(l,h,v,E,D){var w=D*D,N=D*w,I=2*N-3*w+1,V=-2*N+3*w,X=N-2*w+D,j=N-w;return new g(l._x*I+v._x*V+h._x*X+E._x*j,l._y*I+v._y*V+h._y*X+E._y*j,l._z*I+v._z*V+h._z*X+E._z*j,l._w*I+v._w*V+h._w*X+E._w*j)},g}(),T=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,v,E){h===void 0&&(h=!1),v===void 0&&(v=!1),E===void 0&&(E=!0),this.updateFlag=g._updateFlagSeed++,this._isIdentity=l,this._isIdentity3x2=l||v,this._isIdentityDirty=!this._isIdentity&&h,this._isIdentity3x2Dirty=!this._isIdentity3x2&&E},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],v=l[1],E=l[2],D=l[3],w=l[4],N=l[5],I=l[6],V=l[7],X=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=X*ee-de*te,Q=X*ae-ne*de,oe=X*pe-de*j;return h*+(N*K-I*$+V*L)+v*-(w*K-I*G+V*Q)+E*+(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 v=this._m,E=h._m,D=l.m,w=0;w<16;w++)E[w]=v[w]+D[w];return h._markAsUpdated(),this},g.prototype.addToSelf=function(l){for(var h=this._m,v=l.m,E=0;E<16;E++)h[E]+=v[E];return this._markAsUpdated(),this},g.prototype.invertToRef=function(l){if(this._isIdentity===!0)return g.IdentityToRef(l),this;var h=this._m,v=h[0],E=h[1],D=h[2],w=h[3],N=h[4],I=h[5],V=h[6],X=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+X*G),k=-(N*$-V*Q+X*oe),H=+(N*L-I*Q+X*re),Z=-(N*G-I*oe+V*re),W=v*Y+E*k+D*H+w*Z;if(W===0)return l.copyFrom(this),this;var q=1/W,he=V*K-ee*X,ge=I*K-ae*X,me=I*ee-ae*V,_e=N*K-pe*X,be=N*ee-pe*V,Pe=N*ae-pe*I,ye=V*de-te*X,Be=I*de-ne*X,ke=I*te-ne*V,We=N*de-j*X,je=N*te-j*V,He=N*ne-j*I,qe=-(E*$-D*L+w*G),Ge=+(v*$-D*Q+w*oe),nt=-(v*L-E*Q+w*re),$e=+(v*G-E*oe+D*re),ct=+(E*he-D*ge+w*me),st=-(v*he-D*_e+w*be),mt=+(v*ge-E*_e+w*Pe),St=-(v*me-E*be+D*Pe),wt=-(E*ye-D*Be+w*ke),It=+(v*ye-D*We+w*je),Pt=-(v*Be-E*We+w*He),Ot=+(v*ke-E*je+D*He);return g.FromValuesToRef(Y*q,qe*q,ct*q,wt*q,k*q,Ge*q,st*q,It*q,H*q,nt*q,mt*q,Pt*q,Z*q,$e*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,v){return this._m[12]=l,this._m[13]=h,this._m[14]=v,this._markAsUpdated(),this},g.prototype.addTranslationFromFloats=function(l,h,v){return this._m[12]+=l,this._m[13]+=h,this._m[14]+=v,this._markAsUpdated(),this},g.prototype.setTranslation=function(l){return this.setTranslationFromFloats(l._x,l._y,l._z)},g.prototype.getTranslation=function(){return new x(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 v=this._m;return l[h]=v[0],l[h+1]=v[1],l[h+2]=v[2],l[h+3]=v[3],l[h+4]=v[4],l[h+5]=v[5],l[h+6]=v[6],l[h+7]=v[7],l[h+8]=v[8],l[h+9]=v[9],l[h+10]=v[10],l[h+11]=v[11],l[h+12]=v[12],l[h+13]=v[13],l[h+14]=v[14],l[h+15]=v[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,v){var E=this._m,D=l.m,w=E[0],N=E[1],I=E[2],V=E[3],X=E[4],j=E[5],ne=E[6],te=E[7],de=E[8],pe=E[9],ae=E[10],ee=E[11],K=E[12],$=E[13],L=E[14],G=E[15],Q=D[0],oe=D[1],re=D[2],Y=D[3],k=D[4],H=D[5],Z=D[6],W=D[7],q=D[8],he=D[9],ge=D[10],me=D[11],_e=D[12],be=D[13],Pe=D[14],ye=D[15];return h[v]=w*Q+N*k+I*q+V*_e,h[v+1]=w*oe+N*H+I*he+V*be,h[v+2]=w*re+N*Z+I*ge+V*Pe,h[v+3]=w*Y+N*W+I*me+V*ye,h[v+4]=X*Q+j*k+ne*q+te*_e,h[v+5]=X*oe+j*H+ne*he+te*be,h[v+6]=X*re+j*Z+ne*ge+te*Pe,h[v+7]=X*Y+j*W+ne*me+te*ye,h[v+8]=de*Q+pe*k+ae*q+ee*_e,h[v+9]=de*oe+pe*H+ae*he+ee*be,h[v+10]=de*re+pe*Z+ae*ge+ee*Pe,h[v+11]=de*Y+pe*W+ae*me+ee*ye,h[v+12]=K*Q+$*k+L*q+G*_e,h[v+13]=K*oe+$*H+L*he+G*be,h[v+14]=K*re+$*Z+L*ge+G*Pe,h[v+15]=K*Y+$*W+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 v=this.m,E=h.m;return v[0]===E[0]&&v[1]===E[1]&&v[2]===E[2]&&v[3]===E[3]&&v[4]===E[4]&&v[5]===E[5]&&v[6]===E[6]&&v[7]===E[7]&&v[8]===E[8]&&v[9]===E[9]&&v[10]===E[10]&&v[11]===E[11]&&v[12]===E[12]&&v[13]===E[13]&&v[14]===E[14]&&v[15]===E[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,v){if(this._isIdentity)return v&&v.setAll(0),l&&l.setAll(1),h&&h.copyFromFloats(0,0,0,1),!0;var E=this._m;if(v&&v.copyFromFloats(E[12],E[13],E[14]),(l=l||A.Vector3[0]).x=Math.sqrt(E[0]*E[0]+E[1]*E[1]+E[2]*E[2]),l.y=Math.sqrt(E[4]*E[4]+E[5]*E[5]+E[6]*E[6]),l.z=Math.sqrt(E[8]*E[8]+E[9]*E[9]+E[10]*E[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(E[0]*D,E[1]*D,E[2]*D,0,E[4]*w,E[5]*w,E[6]*w,0,E[8]*N,E[9]*N,E[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,v,E,D){if(l<0||l>3)return this;var w=4*l;return this._m[w+0]=h,this._m[w+1]=v,this._m[w+2]=E,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 v=0;v<16;v++)h._m[v]=this._m[v]*l;return h._markAsUpdated(),this},g.prototype.scaleAndAddToRef=function(l,h){for(var v=0;v<16;v++)h._m[v]+=this._m[v]*l;return h._markAsUpdated(),this},g.prototype.toNormalMatrix=function(l){var h=A.Matrix[0];this.invertToRef(h),h.transposeToRef(l);var v=l._m;g.FromValuesToRef(v[0],v[1],v[2],0,v[4],v[5],v[6],0,v[8],v[9],v[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 v=this._m,E=1/h._x,D=1/h._y,w=1/h._z;return g.FromValuesToRef(v[0]*E,v[1]*E,v[2]*E,0,v[4]*D,v[5]*D,v[6]*D,0,v[8]*w,v[9]*w,v[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 v=new g;return g.FromArrayToRef(l,h,v),v},g.FromArrayToRef=function(l,h,v){for(var E=0;E<16;E++)v._m[E]=l[E+h];v._markAsUpdated()},g.FromFloat32ArrayToRefScaled=function(l,h,v,E){for(var D=0;D<16;D++)E._m[D]=l[D+h]*v;E._markAsUpdated()},Object.defineProperty(g,"IdentityReadOnly",{get:function(){return g._identityReadOnly},enumerable:!1,configurable:!0}),g.FromValuesToRef=function(l,h,v,E,D,w,N,I,V,X,j,ne,te,de,pe,ae,ee){var K=ee._m;K[0]=l,K[1]=h,K[2]=v,K[3]=E,K[4]=D,K[5]=w,K[6]=N,K[7]=I,K[8]=V,K[9]=X,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,v,E,D,w,N,I,V,X,j,ne,te,de,pe,ae){var ee=new g,K=ee._m;return K[0]=l,K[1]=h,K[2]=v,K[3]=E,K[4]=D,K[5]=w,K[6]=N,K[7]=I,K[8]=V,K[9]=X,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,v){var E=new g;return g.ComposeToRef(l,h,v,E),E},g.ComposeToRef=function(l,h,v,E){var D=E._m,w=h._x,N=h._y,I=h._z,V=h._w,X=w+w,j=N+N,ne=I+I,te=w*X,de=w*j,pe=w*ne,ae=N*j,ee=N*ne,K=I*ne,$=V*X,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]=v._x,D[13]=v._y,D[14]=v._z,D[15]=1,E._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 v=Math.sin(l),E=Math.cos(l);g.FromValuesToRef(1,0,0,0,0,E,v,0,0,-v,E,0,0,0,0,1,h),h._updateIdentityStatus(E===1&&v===0)},g.RotationY=function(l){var h=new g;return g.RotationYToRef(l,h),h},g.RotationYToRef=function(l,h){var v=Math.sin(l),E=Math.cos(l);g.FromValuesToRef(E,0,-v,0,0,1,0,0,v,0,E,0,0,0,0,1,h),h._updateIdentityStatus(E===1&&v===0)},g.RotationZ=function(l){var h=new g;return g.RotationZToRef(l,h),h},g.RotationZToRef=function(l,h){var v=Math.sin(l),E=Math.cos(l);g.FromValuesToRef(E,v,0,0,-v,E,0,0,0,0,1,0,0,0,0,1,h),h._updateIdentityStatus(E===1&&v===0)},g.RotationAxis=function(l,h){var v=new g;return g.RotationAxisToRef(l,h,v),v},g.RotationAxisToRef=function(l,h,v){var E=Math.sin(-h),D=Math.cos(-h),w=1-D;l.normalize();var N=v._m;N[0]=l._x*l._x*w+D,N[1]=l._x*l._y*w-l._z*E,N[2]=l._x*l._z*w+l._y*E,N[3]=0,N[4]=l._y*l._x*w+l._z*E,N[5]=l._y*l._y*w+D,N[6]=l._y*l._z*w-l._x*E,N[7]=0,N[8]=l._z*l._x*w-l._y*E,N[9]=l._z*l._y*w+l._x*E,N[10]=l._z*l._z*w+D,N[11]=0,N[12]=0,N[13]=0,N[14]=0,N[15]=1,v._markAsUpdated()},g.RotationAlignToRef=function(l,h,v){var E=x.Cross(h,l),D=x.Dot(h,l),w=1/(1+D),N=v._m;N[0]=E._x*E._x*w+D,N[1]=E._y*E._x*w-E._z,N[2]=E._z*E._x*w+E._y,N[3]=0,N[4]=E._x*E._y*w+E._z,N[5]=E._y*E._y*w+D,N[6]=E._z*E._y*w-E._x,N[7]=0,N[8]=E._x*E._z*w-E._y,N[9]=E._y*E._z*w+E._x,N[10]=E._z*E._z*w+D,N[11]=0,N[12]=0,N[13]=0,N[14]=0,N[15]=1,v._markAsUpdated()},g.RotationYawPitchRoll=function(l,h,v){var E=new g;return g.RotationYawPitchRollToRef(l,h,v,E),E},g.RotationYawPitchRollToRef=function(l,h,v,E){c.RotationYawPitchRollToRef(l,h,v,A.Quaternion[0]),A.Quaternion[0].toRotationMatrix(E)},g.Scaling=function(l,h,v){var E=new g;return g.ScalingToRef(l,h,v,E),E},g.ScalingToRef=function(l,h,v,E){g.FromValuesToRef(l,0,0,0,0,h,0,0,0,0,v,0,0,0,0,1,E),E._updateIdentityStatus(l===1&&h===1&&v===1)},g.Translation=function(l,h,v){var E=new g;return g.TranslationToRef(l,h,v,E),E},g.TranslationToRef=function(l,h,v,E){g.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,l,h,v,1,E),E._updateIdentityStatus(l===0&&h===0&&v===0)},g.Lerp=function(l,h,v){var E=new g;return g.LerpToRef(l,h,v,E),E},g.LerpToRef=function(l,h,v,E){for(var D=E._m,w=l.m,N=h.m,I=0;I<16;I++)D[I]=w[I]*(1-v)+N[I]*v;E._markAsUpdated()},g.DecomposeLerp=function(l,h,v){var E=new g;return g.DecomposeLerpToRef(l,h,v,E),E},g.DecomposeLerpToRef=function(l,h,v,E){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],X=A.Vector3[3];h.decompose(I,V,X);var j=A.Vector3[4];x.LerpToRef(D,I,v,j);var ne=A.Quaternion[2];c.SlerpToRef(w,V,v,ne);var te=A.Vector3[5];x.LerpToRef(N,X,v,te),g.ComposeToRef(j,ne,te,E)},g.LookAtLH=function(l,h,v){var E=new g;return g.LookAtLHToRef(l,h,v,E),E},g.LookAtLHToRef=function(l,h,v,E){var D=A.Vector3[0],w=A.Vector3[1],N=A.Vector3[2];h.subtractToRef(l,N),N.normalize(),x.CrossToRef(v,N,D);var I=D.lengthSquared();I===0?D.x=1:D.normalizeFromLength(Math.sqrt(I)),x.CrossToRef(N,D,w),w.normalize();var V=-x.Dot(D,l),X=-x.Dot(w,l),j=-x.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,X,j,1,E)},g.LookAtRH=function(l,h,v){var E=new g;return g.LookAtRHToRef(l,h,v,E),E},g.LookAtRHToRef=function(l,h,v,E){var D=A.Vector3[0],w=A.Vector3[1],N=A.Vector3[2];l.subtractToRef(h,N),N.normalize(),x.CrossToRef(v,N,D);var I=D.lengthSquared();I===0?D.x=1:D.normalizeFromLength(Math.sqrt(I)),x.CrossToRef(N,D,w),w.normalize();var V=-x.Dot(D,l),X=-x.Dot(w,l),j=-x.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,X,j,1,E)},g.OrthoLH=function(l,h,v,E){var D=new g;return g.OrthoLHToRef(l,h,v,E,D),D},g.OrthoLHToRef=function(l,h,v,E,D){var w=2/l,N=2/h,I=2/(E-v),V=-(E+v)/(E-v);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,v,E,D,w){var N=new g;return g.OrthoOffCenterLHToRef(l,h,v,E,D,w,N),N},g.OrthoOffCenterLHToRef=function(l,h,v,E,D,w,N){var I=2/(h-l),V=2/(E-v),X=2/(w-D),j=-(w+D)/(w-D),ne=(l+h)/(l-h),te=(E+v)/(v-E);g.FromValuesToRef(I,0,0,0,0,V,0,0,0,0,X,0,ne,te,j,1,N),N._markAsUpdated()},g.OrthoOffCenterRH=function(l,h,v,E,D,w){var N=new g;return g.OrthoOffCenterRHToRef(l,h,v,E,D,w,N),N},g.OrthoOffCenterRHToRef=function(l,h,v,E,D,w,N){g.OrthoOffCenterLHToRef(l,h,v,E,D,w,N),N._m[10]*=-1},g.PerspectiveLH=function(l,h,v,E){var D=new g,w=2*v/l,N=2*v/h,I=(E+v)/(E-v),V=-2*E*v/(E-v);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,v,E){var D=new g;return g.PerspectiveFovLHToRef(l,h,v,E,D),D},g.PerspectiveFovLHToRef=function(l,h,v,E,D,w){w===void 0&&(w=!0);var N=v,I=E,V=1/Math.tan(.5*l),X=w?V/h:V,j=w?V:V*h,ne=(I+N)/(I-N),te=-2*I*N/(I-N);g.FromValuesToRef(X,0,0,0,0,j,0,0,0,0,ne,1,0,0,te,0,D),D._updateIdentityStatus(!1)},g.PerspectiveFovReverseLHToRef=function(l,h,v,E,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,-v,1,0,0,1,0,D),D._updateIdentityStatus(!1)},g.PerspectiveFovRH=function(l,h,v,E){var D=new g;return g.PerspectiveFovRHToRef(l,h,v,E,D),D},g.PerspectiveFovRHToRef=function(l,h,v,E,D,w){w===void 0&&(w=!0);var N=v,I=E,V=1/Math.tan(.5*l),X=w?V/h:V,j=w?V:V*h,ne=-(I+N)/(I-N),te=-2*I*N/(I-N);g.FromValuesToRef(X,0,0,0,0,j,0,0,0,0,ne,-1,0,0,te,0,D),D._updateIdentityStatus(!1)},g.PerspectiveFovReverseRHToRef=function(l,h,v,E,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,-v,-1,0,0,-1,0,D),D._updateIdentityStatus(!1)},g.PerspectiveFovWebVRToRef=function(l,h,v,E,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),X=Math.tan(l.rightDegrees*Math.PI/180),j=2/(V+X),ne=2/(N+I),te=E._m;te[0]=j,te[1]=te[2]=te[3]=te[4]=0,te[5]=ne,te[6]=te[7]=0,te[8]=(V-X)*j*.5,te[9]=-(N-I)*ne*.5,te[10]=-v/(h-v),te[11]=1*w,te[12]=te[13]=te[15]=0,te[14]=-2*v*h/(v-h),E._markAsUpdated()},g.GetFinalMatrix=function(l,h,v,E,D,w){var N=l.width,I=l.height,V=l.x,X=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+X,D,1),ne=A.Matrix[0];return h.multiplyToRef(v,ne),ne.multiplyToRef(E,ne),ne.multiply(j)},g.GetAsMatrix2x2=function(l){var h=l.m,v=[h[0],h[1],h[4],h[5]];return M.a.MatrixUse64Bits?v:new Float32Array(v)},g.GetAsMatrix3x3=function(l){var h=l.m,v=[h[0],h[1],h[2],h[4],h[5],h[6],h[8],h[9],h[10]];return M.a.MatrixUse64Bits?v:new Float32Array(v)},g.Transpose=function(l){var h=new g;return g.TransposeToRef(l,h),h},g.TransposeToRef=function(l,h){var v=h._m,E=l.m;v[0]=E[0],v[1]=E[4],v[2]=E[8],v[3]=E[12],v[4]=E[1],v[5]=E[5],v[6]=E[9],v[7]=E[13],v[8]=E[2],v[9]=E[6],v[10]=E[10],v[11]=E[14],v[12]=E[3],v[13]=E[7],v[14]=E[11],v[15]=E[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 v=l.normal.x,E=l.normal.y,D=l.normal.z,w=-2*v,N=-2*E,I=-2*D;g.FromValuesToRef(w*v+1,N*v,I*v,0,w*E,N*E+1,I*E,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,v,E){g.FromValuesToRef(l._x,l._y,l._z,0,h._x,h._y,h._z,0,v._x,v._y,v._z,0,0,0,0,1,E)},g.FromQuaternionToRef=function(l,h){var v=l._x*l._x,E=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,X=l._y*l._z,j=l._x*l._w;h._m[0]=1-2*(E+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+v),h._m[6]=2*(X+j),h._m[7]=0,h._m[8]=2*(I+V),h._m[9]=2*(X-j),h._m[10]=1-2*(E+v),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=C.a.BuildArray(6,x.Zero),g.Matrix=C.a.BuildArray(2,T.Identity),g.Quaternion=C.a.BuildArray(3,c.Zero),g}(),S=function(){function g(){}return g.Vector2=C.a.BuildArray(3,R.Zero),g.Vector3=C.a.BuildArray(13,x.Zero),g.Vector4=C.a.BuildArray(3,m.Zero),g.Quaternion=C.a.BuildArray(2,c.Zero),g.Matrix=C.a.BuildArray(8,T.Identity),g}();u.a.RegisteredTypes["BABYLON.Vector2"]=R,u.a.RegisteredTypes["BABYLON.Vector3"]=x,u.a.RegisteredTypes["BABYLON.Vector4"]=m,u.a.RegisteredTypes["BABYLON.Matrix"]=T},function(Me,y,f){f.d(y,"d",function(){return _}),f.d(y,"a",function(){return C}),f.d(y,"c",function(){return u}),f.d(y,"b",function(){return M}),f.d(y,"e",function(){return R}),f.d(y,"f",function(){return x});/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */var U=function(m,c){return(U=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(T,A){T.__proto__=A}||function(T,A){for(var S in A)Object.prototype.hasOwnProperty.call(A,S)&&(T[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 T(){this.constructor=m}U(m,c),m.prototype=c===null?Object.create(c):(T.prototype=c.prototype,new T)}var C=function(){return(C=Object.assign||function(m){for(var c,T=1,A=arguments.length;T=0;h--)(S=m[h])&&(l=(g<3?S(l):g>3?S(c,T,l):S(c,T))||l);return g>3&&l&&Object.defineProperty(c,T,l),l}function M(m,c,T,A){return new(T||(T=Promise))(function(S,g){function l(E){try{v(A.next(E))}catch(D){g(D)}}function h(E){try{v(A.throw(E))}catch(D){g(D)}}function v(E){var D;E.done?S(E.value):(D=E.value,D instanceof T?D:new T(function(w){w(D)})).then(l,h)}v((A=A.apply(m,c||[])).next())})}function R(m,c){var T,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(v){return function(E){return function(D){if(T)throw new TypeError("Generator is already executing.");for(;l;)try{if(T=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]=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(x.prototype,"onBindObservable",{get:function(){return this._onBindObservable||(this._onBindObservable=new U.c),this._onBindObservable},enumerable:!1,configurable:!0}),x.prototype._useFinalCode=function(m,c,T){if(T){var A=T.vertexElement||T.vertex||T.spectorName||T,S=T.fragmentElement||T.fragment||T.spectorName||T;this._vertexSourceCode="#define SHADER_NAME vertex:"+A+` +`+m,this._fragmentSourceCode="#define SHADER_NAME fragment:"+S+` +`+c}else this._vertexSourceCode=m,this._fragmentSourceCode=c;this._prepareEffect()},Object.defineProperty(x.prototype,"key",{get:function(){return this._key},enumerable:!1,configurable:!0}),x.prototype.isReady=function(){try{return this._isReadyInternal()}catch{return!1}},x.prototype._isReadyInternal=function(){return!!this._isReady||!!this._pipelineContext&&this._pipelineContext.isReady},x.prototype.getEngine=function(){return this._engine},x.prototype.getPipelineContext=function(){return this._pipelineContext},x.prototype.getAttributesNames=function(){return this._attributesNames},x.prototype.getAttributeLocation=function(m){return this._attributes[m]},x.prototype.getAttributeLocationByName=function(m){return this._attributeLocationByName[m]},x.prototype.getAttributesCount=function(){return this._attributes.length},x.prototype.getUniformIndex=function(m){return this._uniformsNames.indexOf(m)},x.prototype.getUniform=function(m){return this._uniforms[m]},x.prototype.getSamplers=function(){return this._samplerList},x.prototype.getUniformNames=function(){return this._uniformsNames},x.prototype.getUniformBuffersNames=function(){return this._uniformBuffersNamesList},x.prototype.getIndexParameters=function(){return this._indexParameters},x.prototype.getCompilationError=function(){return this._compilationError},x.prototype.allFallbacksProcessed=function(){return this._allFallbacksProcessed},x.prototype.executeWhenCompiled=function(m){var c=this;this.isReady()?m(this):(this.onCompileObservable.add(function(T){m(T)}),this._pipelineContext&&!this._pipelineContext.isAsync||setTimeout(function(){c._checkIsReady(null)},16))},x.prototype._checkIsReady=function(m){var c=this;try{if(this._isReadyInternal())return}catch(T){return void this._processCompilationErrors(T,m)}setTimeout(function(){c._checkIsReady(m)},16)},x.prototype._loadShader=function(m,c,T,A){var S;if(typeof HTMLElement<"u"&&m instanceof HTMLElement)return void A(C.a.GetDOMTextContent(m));m.substr(0,7)!=="source:"?m.substr(0,7)!=="base64:"?x.ShadersStore[m+c+"Shader"]?A(x.ShadersStore[m+c+"Shader"]):T&&x.ShadersStore[m+T+"Shader"]?A(x.ShadersStore[m+T+"Shader"]):(S=m[0]==="."||m[0]==="/"||m.indexOf("http")>-1?m:x.ShadersRepository+m,this._engine._loadFile(S+"."+c.toLowerCase()+".fx",A)):A(window.atob(m.substr(7))):A(m.substr(7))},Object.defineProperty(x.prototype,"vertexSourceCode",{get:function(){return this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?this._vertexSourceCodeOverride:this._vertexSourceCode},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"fragmentSourceCode",{get:function(){return this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?this._fragmentSourceCodeOverride:this._fragmentSourceCode},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"rawVertexSourceCode",{get:function(){return this._rawVertexSourceCode},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"rawFragmentSourceCode",{get:function(){return this._rawFragmentSourceCode},enumerable:!1,configurable:!0}),x.prototype._rebuildProgram=function(m,c,T,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=l&&(S="Offending line ["+l+"] in "+(T?"fragment":"vertex")+" code: "+h[l-1])}}return[m,S]},x.prototype._processCompilationErrors=function(m,c){var T,A,S,g,l;c===void 0&&(c=null),this._compilationError=m.message;var h=this._attributesNames,v=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 +`+this.defines),x.LogShaderCodeOnCompilationError){var E=null,D=null,w=null;!((S=this._pipelineContext)===null||S===void 0)&&S._getVertexShaderCode()&&(w=(T=this._getShaderCodeAndErrorLine(this._pipelineContext._getVertexShaderCode(),this._compilationError,!1))[0],E=T[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))),E&&u.a.Error(E),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)),v?(this._pipelineContext=null,v.hasMoreFallbacks?(this._allFallbacksProcessed=!1,u.a.Error("Trying next fallback."),this.defines=v.reduce(this.defines,this),this._prepareEffect()):(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(x.prototype,"isSupported",{get:function(){return this._compilationError===""},enumerable:!1,configurable:!0}),x.prototype._bindTexture=function(m,c){this._engine._bindTexture(this._samplers[m],c)},x.prototype.setTexture=function(m,c){this._engine.setTexture(this._samplers[m],this._uniforms[m],c)},x.prototype.setDepthStencilTexture=function(m,c){this._engine.setDepthStencilTexture(this._samplers[m],this._uniforms[m],c)},x.prototype.setTextureArray=function(m,c){var T=m+"Ex";if(this._samplerList.indexOf(T+"0")===-1){for(var A=this._samplerList.indexOf(m),S=1;S0},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 x=0,m=this._observers;x0},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);Y0},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.distanceQ.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;oeY)return this.onLODLevelSelection&&this.onLODLevelSelection(Y,this,this),this;for(var k=0;k0||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=(je=_e[me]).getMaterial();if(be){if(be._storeEffectOnSubMeshes){if(!be.isReadyForSubMesh(this,je,he))return!1}else if(!be.isReady(this,he))return!1}}else if(!ge.isReady(this,he))return!1}for(var Pe=0,ye=this.lightSources;Pe0){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;kre){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=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 T.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;T.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 T.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.isFrozen&&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(),W=re?H.intermediateDefaultRenderId:H.defaultRenderId;k.visibleInstances[G]=H[Z],!k.visibleInstances[G]&&W&&(k.visibleInstances[G]=H[W])}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,W=H.instancesBuffer,q=16*(k.length+1)*4;H.instancesBufferSizehe&&re++,be!==0&&me++,ge+=be,he=be}if(W[me]++,me>k&&(k=me),ge===0)Y++;else{var Pe=1/ge,ye=0;for(_e=0;_e.001&&H++}}var Be=this.skeleton.bones.length,ke=this.getVerticesData(c.b.MatricesIndicesKind),We=this.getVerticesData(c.b.MatricesIndicesExtraKind),je=0;for(q=0;q=Be||He<0)&&je++}return{skinned:!0,valid:Y===0&&H===0&&je===0,report:"Number of Weights = "+oe/4+` +Maximum influences = `+k+` +Missing Weights = `+Y+` +Not Sorted = `+re+` +Not Normalized = `+H+` +WeightCounts = [`+W+`] +Number of bones = `+Be+` +Bad Bone Indices = `+je}},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 C.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;oe1)for(var oe=0,re=Q.meshes.slice(0);oe-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;Y4,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,Pe=new R.a,ye=0,Be=0;Be0&&(R.a.FromFloat32ArrayToRefScaled(me,Math.floor(16*H[ye+W]),ke,Pe),be.addToSelf(Pe));if(q)for(W=0;W<4;W++)(ke=ge[ye+W])>0&&(R.a.FromFloat32ArrayToRefScaled(me,Math.floor(16*he[ye+W]),ke,Pe),be.addToSelf(Pe));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=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 W,q,he=null;Y=!1}var ge,me=new Array,_e=new Array,be=null,Pe=new Array,ye=null;for(H=0;H
";_._AddLogEntry(M)},_._WarnDisabled=function(C){},_._WarnEnabled=function(C){var u=_._FormatMessage(C);console.warn("BJS - "+u);var M="
"+u+"

";_._AddLogEntry(M)},_._ErrorDisabled=function(C){},_._ErrorEnabled=function(C){_.errorsCount++;var u=_._FormatMessage(C);console.error("BJS - "+u);var M="
"+u+"

";_._AddLogEntry(M)},Object.defineProperty(_,"LogCache",{get:function(){return _._LogCache},enumerable:!1,configurable:!0}),_.ClearLogCache=function(){_._LogCache="",_.errorsCount=0},Object.defineProperty(_,"LogLevels",{set:function(C){(C&_.MessageLogLevel)===_.MessageLogLevel?_.Log=_._LogEnabled:_.Log=_._LogDisabled,(C&_.WarningLogLevel)===_.WarningLogLevel?_.Warn=_._WarnEnabled:_.Warn=_._WarnDisabled,(C&_.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(Me,y,f){f.d(y,"a",function(){return M}),f.d(y,"b",function(){return R}),f.d(y,"c",function(){return x});var U=f(14),_=f(28),C=f(44),u=f(11),M=function(){function m(c,T,A){c===void 0&&(c=0),T===void 0&&(T=0),A===void 0&&(A=0),this.r=c,this.g=T,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,T){return T===void 0&&(T=0),c[T]=this.r,c[T+1]=this.g,c[T+2]=this.b,this},m.prototype.fromArray=function(c,T){return T===void 0&&(T=0),m.FromArrayToRef(c,T,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,T){return T.r=this.r*c.r,T.g=this.g*c.g,T.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,T,A){return this.r===c&&this.g===T&&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,T){return T.r=this.r*c,T.g=this.g*c,T.b=this.b*c,this},m.prototype.scaleAndAddToRef=function(c,T){return T.r+=this.r*c,T.g+=this.g*c,T.b+=this.b*c,this},m.prototype.clampToRef=function(c,T,A){return c===void 0&&(c=0),T===void 0&&(T=1),A.r=U.a.Clamp(this.r,c,T),A.g=U.a.Clamp(this.g,c,T),A.b=U.a.Clamp(this.b,c,T),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,T){return T.r=this.r+c.r,T.g=this.g+c.g,T.b=this.b+c.b,this},m.prototype.subtract=function(c){return new m(this.r-c.r,this.g-c.g,this.b-c.b)},m.prototype.subtractToRef=function(c,T){return T.r=this.r-c.r,T.g=this.g-c.g,T.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,T,A){return this.r=c,this.g=T,this.b=A,this},m.prototype.set=function(c,T,A){return this.copyFromFloats(c,T,A)},m.prototype.toHexString=function(){var c=255*this.r|0,T=255*this.g|0,A=255*this.b|0;return"#"+U.a.ToHex(c)+U.a.ToHex(T)+U.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 T=this.r,A=this.g,S=this.b,g=Math.max(T,A,S),l=Math.min(T,A,S),h=0,v=0,E=g,D=g-l;g!==0&&(v=D/g),g!=l&&(g==T?(h=(A-S)/D,A=0&&l<=1?(v=g,E=h):l>=1&&l<=2?(v=h,E=g):l>=2&&l<=3?(E=g,D=h):l>=3&&l<=4?(E=h,D=g):l>=4&&l<=5?(v=h,D=g):l>=5&&l<=6&&(v=g,D=h);var w=A-g;S.set(v+w,E+w,D+w)},m.FromHexString=function(c){if(c.substring(0,1)!=="#"||c.length!==7)return new m(0,0,0);var T=parseInt(c.substring(1,3),16),A=parseInt(c.substring(3,5),16),S=parseInt(c.substring(5,7),16);return m.FromInts(T,A,S)},m.FromArray=function(c,T){return T===void 0&&(T=0),new m(c[T],c[T+1],c[T+2])},m.FromArrayToRef=function(c,T,A){T===void 0&&(T=0),A.r=c[T],A.g=c[T+1],A.b=c[T+2]},m.FromInts=function(c,T,A){return new m(c/255,T/255,A/255)},m.Lerp=function(c,T,A){var S=new m(0,0,0);return m.LerpToRef(c,T,A,S),S},m.LerpToRef=function(c,T,A,S){S.r=c.r+(T.r-c.r)*A,S.g=c.g+(T.g-c.g)*A,S.b=c.b+(T.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,T,A,S){c===void 0&&(c=0),T===void 0&&(T=0),A===void 0&&(A=0),S===void 0&&(S=1),this.r=c,this.g=T,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,T){return T===void 0&&(T=0),c[T]=this.r,c[T+1]=this.g,c[T+2]=this.b,c[T+3]=this.a,this},m.prototype.fromArray=function(c,T){return T===void 0&&(T=0),m.FromArrayToRef(c,T,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,T){return T.r=this.r-c.r,T.g=this.g-c.g,T.b=this.b-c.b,T.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,T){return T.r=this.r*c,T.g=this.g*c,T.b=this.b*c,T.a=this.a*c,this},m.prototype.scaleAndAddToRef=function(c,T){return T.r+=this.r*c,T.g+=this.g*c,T.b+=this.b*c,T.a+=this.a*c,this},m.prototype.clampToRef=function(c,T,A){return c===void 0&&(c=0),T===void 0&&(T=1),A.r=U.a.Clamp(this.r,c,T),A.g=U.a.Clamp(this.g,c,T),A.b=U.a.Clamp(this.b,c,T),A.a=U.a.Clamp(this.a,c,T),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,T){return T.r=this.r*c.r,T.g=this.g*c.g,T.b=this.b*c.b,T.a=this.a*c.a,T},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,T,A,S){return this.r=c,this.g=T,this.b=A,this.a=S,this},m.prototype.set=function(c,T,A,S){return this.copyFromFloats(c,T,A,S)},m.prototype.toHexString=function(c){c===void 0&&(c=!1);var T=255*this.r|0,A=255*this.g|0,S=255*this.b|0;if(c)return"#"+U.a.ToHex(T)+U.a.ToHex(A)+U.a.ToHex(S);var g=255*this.a|0;return"#"+U.a.ToHex(T)+U.a.ToHex(A)+U.a.ToHex(S)+U.a.ToHex(g)},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 T=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(T,A,S,g)},m.Lerp=function(c,T,A){var S=new m(0,0,0,0);return m.LerpToRef(c,T,A,S),S},m.LerpToRef=function(c,T,A,S){S.r=c.r+(T.r-c.r)*A,S.g=c.g+(T.g-c.g)*A,S.b=c.b+(T.b-c.b)*A,S.a=c.a+(T.a-c.a)*A},m.FromColor3=function(c,T){return T===void 0&&(T=1),new m(c.r,c.g,c.b,T)},m.FromArray=function(c,T){return T===void 0&&(T=0),new m(c[T],c[T+1],c[T+2],c[T+3])},m.FromArrayToRef=function(c,T,A){T===void 0&&(T=0),A.r=c[T],A.g=c[T+1],A.b=c[T+2],A.a=c[T+3]},m.FromInts=function(c,T,A,S){return new m(c/255,T/255,A/255,S/255)},m.CheckColors4=function(c,T){if(c.length===3*T){for(var A=[],S=0;S0?E.name:w+E.name,(S.a.StartsWith(E.url,"data:")||v.UseSerializedUrlIfAny&&E.url)&&(ae=E.url),X=new v(ae,D,!j,E.invertY,void 0,I)}return X},E,D);return V},v.CreateFromBase64String=function(E,D,w,N,I,V,X,j,ne){return V===void 0&&(V=v.TRILINEAR_SAMPLINGMODE),X===void 0&&(X=null),j===void 0&&(j=null),ne===void 0&&(ne=R.a.TEXTUREFORMAT_RGBA),new v("data:"+D,w,N,I,V,X,j,E,!1,ne)},v.LoadFromDataString=function(E,D,w,N,I,V,X,j,ne,te){return N===void 0&&(N=!1),I===void 0&&(I=!1),V===void 0&&(V=!0),X===void 0&&(X=v.TRILINEAR_SAMPLINGMODE),j===void 0&&(j=null),ne===void 0&&(ne=null),te===void 0&&(te=R.a.TEXTUREFORMAT_RGBA),E.substr(0,5)!=="data:"&&(E="data:"+E),new v(E,w,I,V,X,j,ne,D,N,te)},v.SerializeBuffers=!0,v.ForceSerializeBuffers=!1,v._CubeTextureParser=function(E,D,w){throw m.a.WarnImport("CubeTexture")},v._CreateMirror=function(E,D,w,N){throw m.a.WarnImport("MirrorTexture")},v._CreateRenderTargetTexture=function(E,D,w,N){throw m.a.WarnImport("RenderTargetTexture")},v.NEAREST_SAMPLINGMODE=R.a.TEXTURE_NEAREST_SAMPLINGMODE,v.NEAREST_NEAREST_MIPLINEAR=R.a.TEXTURE_NEAREST_NEAREST_MIPLINEAR,v.BILINEAR_SAMPLINGMODE=R.a.TEXTURE_BILINEAR_SAMPLINGMODE,v.LINEAR_LINEAR_MIPNEAREST=R.a.TEXTURE_LINEAR_LINEAR_MIPNEAREST,v.TRILINEAR_SAMPLINGMODE=R.a.TEXTURE_TRILINEAR_SAMPLINGMODE,v.LINEAR_LINEAR_MIPLINEAR=R.a.TEXTURE_LINEAR_LINEAR_MIPLINEAR,v.NEAREST_NEAREST_MIPNEAREST=R.a.TEXTURE_NEAREST_NEAREST_MIPNEAREST,v.NEAREST_LINEAR_MIPNEAREST=R.a.TEXTURE_NEAREST_LINEAR_MIPNEAREST,v.NEAREST_LINEAR_MIPLINEAR=R.a.TEXTURE_NEAREST_LINEAR_MIPLINEAR,v.NEAREST_LINEAR=R.a.TEXTURE_NEAREST_LINEAR,v.NEAREST_NEAREST=R.a.TEXTURE_NEAREST_NEAREST,v.LINEAR_NEAREST_MIPNEAREST=R.a.TEXTURE_LINEAR_NEAREST_MIPNEAREST,v.LINEAR_NEAREST_MIPLINEAR=R.a.TEXTURE_LINEAR_NEAREST_MIPLINEAR,v.LINEAR_LINEAR=R.a.TEXTURE_LINEAR_LINEAR,v.LINEAR_NEAREST=R.a.TEXTURE_LINEAR_NEAREST,v.EXPLICIT_MODE=R.a.TEXTURE_EXPLICIT_MODE,v.SPHERICAL_MODE=R.a.TEXTURE_SPHERICAL_MODE,v.PLANAR_MODE=R.a.TEXTURE_PLANAR_MODE,v.CUBIC_MODE=R.a.TEXTURE_CUBIC_MODE,v.PROJECTION_MODE=R.a.TEXTURE_PROJECTION_MODE,v.SKYBOX_MODE=R.a.TEXTURE_SKYBOX_MODE,v.INVCUBIC_MODE=R.a.TEXTURE_INVCUBIC_MODE,v.EQUIRECTANGULAR_MODE=R.a.TEXTURE_EQUIRECTANGULAR_MODE,v.FIXED_EQUIRECTANGULAR_MODE=R.a.TEXTURE_FIXED_EQUIRECTANGULAR_MODE,v.FIXED_EQUIRECTANGULAR_MIRRORED_MODE=R.a.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE,v.CLAMP_ADDRESSMODE=R.a.TEXTURE_CLAMP_ADDRESSMODE,v.WRAP_ADDRESSMODE=R.a.TEXTURE_WRAP_ADDRESSMODE,v.MIRROR_ADDRESSMODE=R.a.TEXTURE_MIRROR_ADDRESSMODE,v.UseSerializedUrlIfAny=!1,Object(U.c)([Object(_.c)()],v.prototype,"url",void 0),Object(U.c)([Object(_.c)()],v.prototype,"uOffset",void 0),Object(U.c)([Object(_.c)()],v.prototype,"vOffset",void 0),Object(U.c)([Object(_.c)()],v.prototype,"uScale",void 0),Object(U.c)([Object(_.c)()],v.prototype,"vScale",void 0),Object(U.c)([Object(_.c)()],v.prototype,"uAng",void 0),Object(U.c)([Object(_.c)()],v.prototype,"vAng",void 0),Object(U.c)([Object(_.c)()],v.prototype,"wAng",void 0),Object(U.c)([Object(_.c)()],v.prototype,"uRotationCenter",void 0),Object(U.c)([Object(_.c)()],v.prototype,"vRotationCenter",void 0),Object(U.c)([Object(_.c)()],v.prototype,"wRotationCenter",void 0),Object(U.c)([Object(_.c)()],v.prototype,"homogeneousRotationInUVTransform",void 0),Object(U.c)([Object(_.c)()],v.prototype,"isBlocking",null),v}(M.a);x.a.RegisteredTypes["BABYLON.Texture"]=l,_.a._TextureParser=l.Parse},function(Me,y,f){f.d(y,"a",function(){return U});var U=function(){function _(){}return _.GetClass=function(C){return this.RegisteredTypes&&this.RegisteredTypes[C]?this.RegisteredTypes[C]:null},_.RegisteredTypes={},_}()},function(Me,y,f){f.d(y,"b",function(){return l}),f.d(y,"c",function(){return h}),f.d(y,"a",function(){return v});var U=f(6),_=f(38),C=f(8),u=f(41),M=f(57),R=f(21),x=f(49),m=f(22),c=f(56),T=f(145),A=f(104),S=f(122),g=f(120),l=function(){function E(){}return Object.defineProperty(E,"BaseUrl",{get:function(){return c.a.BaseUrl},set:function(D){c.a.BaseUrl=D},enumerable:!1,configurable:!0}),Object.defineProperty(E,"DefaultRetryStrategy",{get:function(){return c.a.DefaultRetryStrategy},set:function(D){c.a.DefaultRetryStrategy=D},enumerable:!1,configurable:!0}),Object.defineProperty(E,"CorsBehavior",{get:function(){return c.a.CorsBehavior},set:function(D){c.a.CorsBehavior=D},enumerable:!1,configurable:!0}),Object.defineProperty(E,"UseFallbackTexture",{get:function(){return m.a.UseFallbackTexture},set:function(D){m.a.UseFallbackTexture=D},enumerable:!1,configurable:!0}),Object.defineProperty(E,"RegisteredExternalClasses",{get:function(){return S.a.RegisteredExternalClasses},set:function(D){S.a.RegisteredExternalClasses=D},enumerable:!1,configurable:!0}),Object.defineProperty(E,"fallbackTexture",{get:function(){return m.a.FallbackTexture},set:function(D){m.a.FallbackTexture=D},enumerable:!1,configurable:!0}),E.FetchToRef=function(D,w,N,I,V,X){var j=4*((Math.abs(D)*N%N|0)+(Math.abs(w)*I%I|0)*N);X.r=V[j]/255,X.g=V[j+1]/255,X.b=V[j+2]/255,X.a=V[j+3]/255},E.Mix=function(D,w,N){return D*(1-N)+w*N},E.Instantiate=function(D){return S.a.Instantiate(D)},E.Slice=function(D,w,N){return D.slice?D.slice(w,N):Array.prototype.slice.call(D,w,N)},E.SliceToArray=function(D,w,N){return Array.isArray(D)?D.slice(w,N):Array.prototype.slice.call(D,w,N)},E.SetImmediate=function(D){A.a.SetImmediate(D)},E.IsExponentOfTwo=function(D){var w=1;do w*=2;while(w=D)break;if(N(te),V&&V()){j.breakLoop();break}}j.executeNext()},X)},I)},E}();m.a.FallbackTexture="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/4QBmRXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUAAAABAAAARgEoAAMAAAABAAIAAAExAAIAAAAQAAAATgAAAAAAAABgAAAAAQAAAGAAAAABcGFpbnQubmV0IDQuMC41AP/bAEMABAIDAwMCBAMDAwQEBAQFCQYFBQUFCwgIBgkNCw0NDQsMDA4QFBEODxMPDAwSGBITFRYXFxcOERkbGRYaFBYXFv/bAEMBBAQEBQUFCgYGChYPDA8WFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFv/AABEIAQABAAMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/APH6KKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76P//Z",T.a.Apply()},function(Me,y,f){f.d(y,"a",function(){return S});var U=f(1),_=f(6),C=f(38),u=f(22),M=f(21),R=f(26),x=f(2),m=f(146),c=f(55),T=f(88),A=f(8),S=(f(123),f(129),f(124),function(g){function l(h,v,E,D){D===void 0&&(D=!1);var w=g.call(this,h,v,E,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._deltaTime=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(E=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(X){w.onCanvasPointerOutObservable.notifyObservers(X)},N.addEventListener("pointerout",w._onCanvasPointerOut),C.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&&E.audioEngine&&l.AudioEngineFactory&&(l.audioEngine=l.AudioEngineFactory(w.getRenderingCanvas()))}w._connectVREvents(),w.enableOfflineSupport=l.OfflineProviderFactory!==void 0,E.doNotHandleTouchAction||w._disableTouchAction(),w._deterministicLockstep=!!E.deterministicLockstep,w._lockstepMaxSteps=E.lockstepMaxSteps||0,w._timeStep=E.timeStep||1/60}return w._prepareVRComponent(),E.autoEnableWebVR&&w.initWebVR(),w}return Object(U.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,v){for(var E=0;E0?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,v){if(!this._renderingCanvas||!g.prototype.setSize.call(this,h,v))return!1;if(this.scenes){for(var E=0;E1&&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=v,h.fragmentShader=E,h.isParallelCompiled||this._finalizePipelineContext(h),N},l.prototype._releaseTexture=function(h){g.prototype._releaseTexture.call(this,h),this.scenes.forEach(function(v){v.postProcesses.forEach(function(E){E._outputTexture==h&&(E._outputTexture=null)}),v.cameras.forEach(function(E){E._postProcesses.forEach(function(D){D&&D._outputTexture==h&&(D._outputTexture=null)})})})},l.prototype._rescaleTexture=function(h,v,E,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:v.width,height:v.height},{generateMipMaps:!1,type:x.a.TEXTURETYPE_UNSIGNED_INT,samplingMode:x.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(X){X._bindTexture("textureSampler",h)};var V=E;V||(V=N.scenes[N.scenes.length-1]),V.postProcessManager.directRender([N._rescalePostProcess],I,!0),N._bindTextureDirectly(N._gl.TEXTURE_2D,v,!0),N._gl.copyTexImage2D(N._gl.TEXTURE_2D,0,D,0,0,v.width,v.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,v,E,D){E===void 0&&(E=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),X=h.isCube?w.TEXTURE_CUBE_MAP:w.TEXTURE_2D;this._bindTextureDirectly(X,h,!0),this._unpackFlipY(h.invertY);var j=w.TEXTURE_2D;h.isCube&&(j=w.TEXTURE_CUBE_MAP_POSITIVE_X+E),w.texImage2D(j,D,V,I,N,v),this._bindTextureDirectly(X,null,!0)},l.prototype.updateRenderTargetTextureSampleCount=function(h,v){if(this.webGLVersion<2||!h)return 1;if(h.samples===v)return v;var E=this._gl;if(v=Math.min(v,this.getCaps().maxMSAASamples),h._depthStencilBuffer&&(E.deleteRenderbuffer(h._depthStencilBuffer),h._depthStencilBuffer=null),h._MSAAFramebuffer&&(E.deleteFramebuffer(h._MSAAFramebuffer),h._MSAAFramebuffer=null),h._MSAARenderBuffer&&(E.deleteRenderbuffer(h._MSAARenderBuffer),h._MSAARenderBuffer=null),v>1&&E.renderbufferStorageMultisample){var D=E.createFramebuffer();if(!D)throw new Error("Unable to create multi sampled framebuffer");h._MSAAFramebuffer=D,this._bindUnboundFramebuffer(h._MSAAFramebuffer);var w=E.createRenderbuffer();if(!w)throw new Error("Unable to create multi sampled framebuffer");E.bindRenderbuffer(E.RENDERBUFFER,w),E.renderbufferStorageMultisample(E.RENDERBUFFER,v,this._getRGBAMultiSampleBufferFormat(h.type),h.width,h.height),E.framebufferRenderbuffer(E.FRAMEBUFFER,E.COLOR_ATTACHMENT0,E.RENDERBUFFER,w),h._MSAARenderBuffer=w}else this._bindUnboundFramebuffer(h._framebuffer);return h.samples=v,h._depthStencilBuffer=this._setupFramebufferDepthAttachments(h._generateStencilBuffer,h._generateDepthBuffer,h.width,h.height,v),this._bindUnboundFramebuffer(null),v},l.prototype.updateTextureComparisonFunction=function(h,v){if(this.webGLVersion!==1){var E=this._gl;h.isCube?(this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,h,!0),v===0?(E.texParameteri(E.TEXTURE_CUBE_MAP,E.TEXTURE_COMPARE_FUNC,x.a.LEQUAL),E.texParameteri(E.TEXTURE_CUBE_MAP,E.TEXTURE_COMPARE_MODE,E.NONE)):(E.texParameteri(E.TEXTURE_CUBE_MAP,E.TEXTURE_COMPARE_FUNC,v),E.texParameteri(E.TEXTURE_CUBE_MAP,E.TEXTURE_COMPARE_MODE,E.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)):(this._bindTextureDirectly(this._gl.TEXTURE_2D,h,!0),v===0?(E.texParameteri(E.TEXTURE_2D,E.TEXTURE_COMPARE_FUNC,x.a.LEQUAL),E.texParameteri(E.TEXTURE_2D,E.TEXTURE_COMPARE_MODE,E.NONE)):(E.texParameteri(E.TEXTURE_2D,E.TEXTURE_COMPARE_FUNC,v),E.texParameteri(E.TEXTURE_2D,E.TEXTURE_COMPARE_MODE,E.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_2D,null)),h._comparisonFunction=v}else A.a.Error("WebGL 1 does not support texture comparison.")},l.prototype.createInstancesBuffer=function(h){var v=this._gl.createBuffer();if(!v)throw new Error("Unable to create instance buffer");var E=new T.a(v);return E.capacity=h,this.bindArrayBuffer(E),this._gl.bufferData(this._gl.ARRAY_BUFFER,h,this._gl.DYNAMIC_DRAW),E},l.prototype.deleteInstancesBuffer=function(h){this._gl.deleteBuffer(h)},l.prototype._clientWaitAsync=function(h,v,E){v===void 0&&(v=0),E===void 0&&(E=10);var D=this._gl;return new Promise(function(w,N){var I=function(){var V=D.clientWaitSync(h,v,0);V!=D.WAIT_FAILED?V!=D.TIMEOUT_EXPIRED?w():setTimeout(I,E):N()};I()})},l.prototype._readPixelsAsync=function(h,v,E,D,w,N,I){if(this._webGLVersion<2)throw new Error("_readPixelsAsync only work on WebGL2+");var V=this._gl,X=V.createBuffer();V.bindBuffer(V.PIXEL_PACK_BUFFER,X),V.bufferData(V.PIXEL_PACK_BUFFER,I.byteLength,V.STREAM_READ),V.readPixels(h,v,E,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,X),V.getBufferSubData(V.PIXEL_PACK_BUFFER,0,I),V.bindBuffer(V.PIXEL_PACK_BUFFER,null),V.deleteBuffer(X),I})):null},l.prototype.dispose=function(){for(this.hideLoadingUI(),this.onNewSceneAddedObservable.clear();this.postProcesses.length;)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(),C.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)),C.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(C.a.IsWindowObjectExist()){var h=this.loadingScreen;h&&h.displayLoadingUI()}},l.prototype.hideLoadingUI=function(){if(C.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 v=h.requestFullscreen||h.msRequestFullscreen||h.webkitRequestFullscreen||h.mozRequestFullScreen;v&&v.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=x.a.ALPHA_DISABLE,l.ALPHA_ADD=x.a.ALPHA_ADD,l.ALPHA_COMBINE=x.a.ALPHA_COMBINE,l.ALPHA_SUBTRACT=x.a.ALPHA_SUBTRACT,l.ALPHA_MULTIPLY=x.a.ALPHA_MULTIPLY,l.ALPHA_MAXIMIZED=x.a.ALPHA_MAXIMIZED,l.ALPHA_ONEONE=x.a.ALPHA_ONEONE,l.ALPHA_PREMULTIPLIED=x.a.ALPHA_PREMULTIPLIED,l.ALPHA_PREMULTIPLIED_PORTERDUFF=x.a.ALPHA_PREMULTIPLIED_PORTERDUFF,l.ALPHA_INTERPOLATE=x.a.ALPHA_INTERPOLATE,l.ALPHA_SCREENMODE=x.a.ALPHA_SCREENMODE,l.DELAYLOADSTATE_NONE=x.a.DELAYLOADSTATE_NONE,l.DELAYLOADSTATE_LOADED=x.a.DELAYLOADSTATE_LOADED,l.DELAYLOADSTATE_LOADING=x.a.DELAYLOADSTATE_LOADING,l.DELAYLOADSTATE_NOTLOADED=x.a.DELAYLOADSTATE_NOTLOADED,l.NEVER=x.a.NEVER,l.ALWAYS=x.a.ALWAYS,l.LESS=x.a.LESS,l.EQUAL=x.a.EQUAL,l.LEQUAL=x.a.LEQUAL,l.GREATER=x.a.GREATER,l.GEQUAL=x.a.GEQUAL,l.NOTEQUAL=x.a.NOTEQUAL,l.KEEP=x.a.KEEP,l.REPLACE=x.a.REPLACE,l.INCR=x.a.INCR,l.DECR=x.a.DECR,l.INVERT=x.a.INVERT,l.INCR_WRAP=x.a.INCR_WRAP,l.DECR_WRAP=x.a.DECR_WRAP,l.TEXTURE_CLAMP_ADDRESSMODE=x.a.TEXTURE_CLAMP_ADDRESSMODE,l.TEXTURE_WRAP_ADDRESSMODE=x.a.TEXTURE_WRAP_ADDRESSMODE,l.TEXTURE_MIRROR_ADDRESSMODE=x.a.TEXTURE_MIRROR_ADDRESSMODE,l.TEXTUREFORMAT_ALPHA=x.a.TEXTUREFORMAT_ALPHA,l.TEXTUREFORMAT_LUMINANCE=x.a.TEXTUREFORMAT_LUMINANCE,l.TEXTUREFORMAT_LUMINANCE_ALPHA=x.a.TEXTUREFORMAT_LUMINANCE_ALPHA,l.TEXTUREFORMAT_RGB=x.a.TEXTUREFORMAT_RGB,l.TEXTUREFORMAT_RGBA=x.a.TEXTUREFORMAT_RGBA,l.TEXTUREFORMAT_RED=x.a.TEXTUREFORMAT_RED,l.TEXTUREFORMAT_R=x.a.TEXTUREFORMAT_R,l.TEXTUREFORMAT_RG=x.a.TEXTUREFORMAT_RG,l.TEXTUREFORMAT_RED_INTEGER=x.a.TEXTUREFORMAT_RED_INTEGER,l.TEXTUREFORMAT_R_INTEGER=x.a.TEXTUREFORMAT_R_INTEGER,l.TEXTUREFORMAT_RG_INTEGER=x.a.TEXTUREFORMAT_RG_INTEGER,l.TEXTUREFORMAT_RGB_INTEGER=x.a.TEXTUREFORMAT_RGB_INTEGER,l.TEXTUREFORMAT_RGBA_INTEGER=x.a.TEXTUREFORMAT_RGBA_INTEGER,l.TEXTURETYPE_UNSIGNED_BYTE=x.a.TEXTURETYPE_UNSIGNED_BYTE,l.TEXTURETYPE_UNSIGNED_INT=x.a.TEXTURETYPE_UNSIGNED_INT,l.TEXTURETYPE_FLOAT=x.a.TEXTURETYPE_FLOAT,l.TEXTURETYPE_HALF_FLOAT=x.a.TEXTURETYPE_HALF_FLOAT,l.TEXTURETYPE_BYTE=x.a.TEXTURETYPE_BYTE,l.TEXTURETYPE_SHORT=x.a.TEXTURETYPE_SHORT,l.TEXTURETYPE_UNSIGNED_SHORT=x.a.TEXTURETYPE_UNSIGNED_SHORT,l.TEXTURETYPE_INT=x.a.TEXTURETYPE_INT,l.TEXTURETYPE_UNSIGNED_INTEGER=x.a.TEXTURETYPE_UNSIGNED_INTEGER,l.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=x.a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4,l.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=x.a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1,l.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=x.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5,l.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=x.a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV,l.TEXTURETYPE_UNSIGNED_INT_24_8=x.a.TEXTURETYPE_UNSIGNED_INT_24_8,l.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=x.a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV,l.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=x.a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV,l.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=x.a.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV,l.TEXTURE_NEAREST_SAMPLINGMODE=x.a.TEXTURE_NEAREST_SAMPLINGMODE,l.TEXTURE_BILINEAR_SAMPLINGMODE=x.a.TEXTURE_BILINEAR_SAMPLINGMODE,l.TEXTURE_TRILINEAR_SAMPLINGMODE=x.a.TEXTURE_TRILINEAR_SAMPLINGMODE,l.TEXTURE_NEAREST_NEAREST_MIPLINEAR=x.a.TEXTURE_NEAREST_NEAREST_MIPLINEAR,l.TEXTURE_LINEAR_LINEAR_MIPNEAREST=x.a.TEXTURE_LINEAR_LINEAR_MIPNEAREST,l.TEXTURE_LINEAR_LINEAR_MIPLINEAR=x.a.TEXTURE_LINEAR_LINEAR_MIPLINEAR,l.TEXTURE_NEAREST_NEAREST_MIPNEAREST=x.a.TEXTURE_NEAREST_NEAREST_MIPNEAREST,l.TEXTURE_NEAREST_LINEAR_MIPNEAREST=x.a.TEXTURE_NEAREST_LINEAR_MIPNEAREST,l.TEXTURE_NEAREST_LINEAR_MIPLINEAR=x.a.TEXTURE_NEAREST_LINEAR_MIPLINEAR,l.TEXTURE_NEAREST_LINEAR=x.a.TEXTURE_NEAREST_LINEAR,l.TEXTURE_NEAREST_NEAREST=x.a.TEXTURE_NEAREST_NEAREST,l.TEXTURE_LINEAR_NEAREST_MIPNEAREST=x.a.TEXTURE_LINEAR_NEAREST_MIPNEAREST,l.TEXTURE_LINEAR_NEAREST_MIPLINEAR=x.a.TEXTURE_LINEAR_NEAREST_MIPLINEAR,l.TEXTURE_LINEAR_LINEAR=x.a.TEXTURE_LINEAR_LINEAR,l.TEXTURE_LINEAR_NEAREST=x.a.TEXTURE_LINEAR_NEAREST,l.TEXTURE_EXPLICIT_MODE=x.a.TEXTURE_EXPLICIT_MODE,l.TEXTURE_SPHERICAL_MODE=x.a.TEXTURE_SPHERICAL_MODE,l.TEXTURE_PLANAR_MODE=x.a.TEXTURE_PLANAR_MODE,l.TEXTURE_CUBIC_MODE=x.a.TEXTURE_CUBIC_MODE,l.TEXTURE_PROJECTION_MODE=x.a.TEXTURE_PROJECTION_MODE,l.TEXTURE_SKYBOX_MODE=x.a.TEXTURE_SKYBOX_MODE,l.TEXTURE_INVCUBIC_MODE=x.a.TEXTURE_INVCUBIC_MODE,l.TEXTURE_EQUIRECTANGULAR_MODE=x.a.TEXTURE_EQUIRECTANGULAR_MODE,l.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=x.a.TEXTURE_FIXED_EQUIRECTANGULAR_MODE,l.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=x.a.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE,l.SCALEMODE_FLOOR=x.a.SCALEMODE_FLOOR,l.SCALEMODE_NEAREST=x.a.SCALEMODE_NEAREST,l.SCALEMODE_CEILING=x.a.SCALEMODE_CEILING,l._RescalePostProcessFactory=null,l}(R.a))},function(Me,y,f){f.d(y,"a",function(){return U});var U=function(){function _(){}return _.WithinEpsilon=function(C,u,M){M===void 0&&(M=1401298e-51);var R=C-u;return-M<=R&&R<=M},_.ToHex=function(C){var u=C.toString(16);return C<=15?("0"+u).toUpperCase():u.toUpperCase()},_.Sign=function(C){return(C=+C)==0||isNaN(C)?C:C>0?1:-1},_.Clamp=function(C,u,M){return u===void 0&&(u=0),M===void 0&&(M=1),Math.min(M,Math.max(u,C))},_.Log2=function(C){return Math.log(C)*Math.LOG2E},_.Repeat=function(C,u){return C-Math.floor(C/u)*u},_.Normalize=function(C,u,M){return(C-u)/(M-u)},_.Denormalize=function(C,u,M){return C*(M-u)+u},_.DeltaAngle=function(C,u){var M=_.Repeat(u-C,360);return M>180&&(M-=360),M},_.PingPong=function(C,u){var M=_.Repeat(C,2*u);return u-Math.abs(M-u)},_.SmoothStep=function(C,u,M){var R=_.Clamp(M);return u*(R=-2*R*R*R+3*R*R)+C*(1-R)},_.MoveTowards=function(C,u,M){return Math.abs(u-C)<=M?u:C+_.Sign(u-C)*M},_.MoveTowardsAngle=function(C,u,M){var R=_.DeltaAngle(C,u),x=0;return-M180&&(R-=360),C+R*_.Clamp(M)},_.InverseLerp=function(C,u,M){return C!=u?_.Clamp((M-C)/(u-C)):0},_.Hermite=function(C,u,M,R,x){var m=x*x,c=x*m;return C*(2*c-3*m+1)+M*(-2*c+3*m)+u*(c-2*m+x)+R*(c-m)},_.RandomRange=function(C,u){return C===u?C:Math.random()*(u-C)+C},_.RangeToPercent=function(C,u,M){return(C-u)/(M-u)},_.PercentToRange=function(C,u,M){return(M-u)*C+u},_.NormalizeRadians=function(C){return C-=_.TwoPi*Math.floor((C+Math.PI)/_.TwoPi)},_.TwoPi=2*Math.PI,_}()},function(Me,y,f){f.d(y,"a",function(){return c});var U=f(8),_=f(20),C=f(22),u=f(4),M=f(48),R=f(2),x=f(9),m=f(119),c=function(){function T(){}return T.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)}},T.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},T.BindTextureMatrix=function(A,S,g){var l=A.getTextureMatrix();S.updateMatrix(g+"Matrix",l)},T.GetFogState=function(A,S){return S.fogEnabled&&A.applyFog&&S.fogMode!==_.a.FOGMODE_NONE},T.PrepareDefinesForMisc=function(A,S,g,l,h,v,E){E._areMiscDirty&&(E.LOGARITHMICDEPTH=g,E.POINTSIZE=l,E.FOG=h&&this.GetFogState(A,S),E.NONUNIFORMSCALING=A.nonUniformScaling,E.ALPHATEST=v)},T.PrepareDefinesForFrameBoundValues=function(A,S,g,l,h,v){h===void 0&&(h=null),v===void 0&&(v=!1);var E,D,w,N,I,V,X=!1;E=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!==E&&(g.CLIPPLANE=E,X=!0),g.CLIPPLANE2!==D&&(g.CLIPPLANE2=D,X=!0),g.CLIPPLANE3!==w&&(g.CLIPPLANE3=w,X=!0),g.CLIPPLANE4!==N&&(g.CLIPPLANE4=N,X=!0),g.CLIPPLANE5!==I&&(g.CLIPPLANE5=I,X=!0),g.CLIPPLANE6!==V&&(g.CLIPPLANE6=V,X=!0),g.DEPTHPREPASS!==!S.getColorWrite()&&(g.DEPTHPREPASS=!g.DEPTHPREPASS,X=!0),g.INSTANCES!==l&&(g.INSTANCES=l,X=!0),g.THIN_INSTANCES!==v&&(g.THIN_INSTANCES=v,X=!0),X&&g.markAsUnprocessed()},T.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},T.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)},T.PrepareDefinesForAttributes=function(A,S,g,l,h,v){if(h===void 0&&(h=!1),v===void 0&&(v=!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 E=A.useVertexColors&&A.isVerticesDataPresent(u.b.ColorKind);S.VERTEXCOLOR=E,S.VERTEXALPHA=A.hasVertexAlpha&&E&&v}return l&&this.PrepareDefinesForBones(A,S),h&&this.PrepareDefinesForMorphTargets(A,S),!0},T.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()}},T.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 v=0;v0&&(E.shadowEnabled=!0,D.prepareDefines(h,l))}}g.lightmapMode!=M.a.LIGHTMAP_DEFAULT?(E.lightmapMode=!0,h["LIGHTMAPEXCLUDED"+l]=!0,h["LIGHTMAPNOSPECULAR"+l]=g.lightmapMode==M.a.LIGHTMAP_SHADOWSONLY):(h["LIGHTMAPEXCLUDED"+l]=!1,h["LIGHTMAPNOSPECULAR"+l]=!1)},T.PrepareDefinesForLights=function(A,S,g,l,h,v){if(h===void 0&&(h=4),v===void 0&&(v=!1),!g._areLightsDirty)return g._needNormals;var E=0,D={needNormals:!1,needRebuild:!1,lightmapMode:!1,shadowEnabled:!1,specularEnabled:!1};if(A.lightsEnabled&&!v)for(var w=0,N=S.lightSources;w0&&(h=l+v,S.addFallback(h,"LIGHT"+v)),A.SHADOWS||(A["SHADOW"+v]&&S.addFallback(l,"SHADOW"+v),A["SHADOWPCF"+v]&&S.addFallback(l,"SHADOWPCF"+v),A["SHADOWPCSS"+v]&&S.addFallback(l,"SHADOWPCSS"+v),A["SHADOWPOISSON"+v]&&S.addFallback(l,"SHADOWPOISSON"+v),A["SHADOWESM"+v]&&S.addFallback(l,"SHADOWESM"+v),A["SHADOWCLOSEESM"+v]&&S.addFallback(l,"SHADOWCLOSEESM"+v));return h++},T.PrepareAttributesForMorphTargetsInfluencers=function(A,S,g){this._TmpMorphInfluencers.NUM_MORPH_INFLUENCERS=g,this.PrepareAttributesForMorphTargets(A,S,this._TmpMorphInfluencers)},T.PrepareAttributesForMorphTargets=function(A,S,g){var l=g.NUM_MORPH_INFLUENCERS;if(l>0&&C.a.LastCreatedEngine)for(var h=C.a.LastCreatedEngine.getCaps().maxVertexAttribs,v=S.morphTargetManager,E=v&&v.supportsNormals&&g.NORMAL,D=v&&v.supportsTangents&&g.TANGENT,w=v&&v.supportsUVs&&g.UV1,N=0;Nh&&U.a.Error("Cannot add more vertex attributes for mesh "+S.name)},T.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)))},T.PrepareAttributesForInstances=function(A,S){(S.INSTANCES||S.THIN_INSTANCES)&&this.PushAttributesForInstances(A)},T.PushAttributesForInstances=function(A){A.push("world0"),A.push("world1"),A.push("world2"),A.push("world3")},T.BindLightProperties=function(A,S,g){A.transferToEffect(S,g+"")},T.BindLight=function(A,S,g,l,h,v){v===void 0&&(v=!1),A._bindLight(S,g,l,h,v)},T.BindLights=function(A,S,g,l,h,v){h===void 0&&(h=4),v===void 0&&(v=!1);for(var E=Math.min(S.lightSources.length,h),D=0;D-1){var h=l.getTransformMatrixTexture(A);S.setTexture("boneSampler",h),S.setFloat("boneTextureWidth",4*(l.bones.length+1))}else{var v=l.getTransformMatrices(A);v&&(S.setMatrices("mBones",v),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]),T._CopyBonesTransformationMatrices(v,g.previousBones[A.uniqueId])))}}},T._CopyBonesTransformationMatrices=function(A,S){return S.set(A),S},T.BindMorphTargetParameters=function(A,S){var g=A.morphTargetManager;A&&g&&S.setFloatArray("morphTargetInfluences",g.influences)},T.BindLogDepth=function(A,S,g){A.LOGARITHMICDEPTH&&S.setFloat("logarithmicDepthConstant",2/(Math.log(g.activeCamera.maxZ+1)/Math.LN2))},T.BindClipPlane=function(A,S){m.a.BindClipPlane(A,S)},T._TmpMorphInfluencers={NUM_MORPH_INFLUENCERS:0},T._tempFogColor=x.a.Black(),T}()},function(Me,y,f){f.d(y,"a",function(){return R});var U=f(0),_=f(4),C=f(21),u=f(9),M=f(8),R=function(){function x(){}return x.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}},x.prototype.applyToMesh=function(m,c){return this._applyTo(m,c),this},x.prototype.applyToGeometry=function(m,c){return this._applyTo(m,c),this},x.prototype.updateMesh=function(m){return this._update(m),this},x.prototype.updateGeometry=function(m){return this._update(m),this},x.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},x.prototype._update=function(m,c,T){return this.positions&&m.updateVerticesData(_.b.PositionKind,this.positions,c,T),this.normals&&m.updateVerticesData(_.b.NormalKind,this.normals,c,T),this.tangents&&m.updateVerticesData(_.b.TangentKind,this.tangents,c,T),this.uvs&&m.updateVerticesData(_.b.UVKind,this.uvs,c,T),this.uvs2&&m.updateVerticesData(_.b.UV2Kind,this.uvs2,c,T),this.uvs3&&m.updateVerticesData(_.b.UV3Kind,this.uvs3,c,T),this.uvs4&&m.updateVerticesData(_.b.UV4Kind,this.uvs4,c,T),this.uvs5&&m.updateVerticesData(_.b.UV5Kind,this.uvs5,c,T),this.uvs6&&m.updateVerticesData(_.b.UV6Kind,this.uvs6,c,T),this.colors&&m.updateVerticesData(_.b.ColorKind,this.colors,c,T),this.matricesIndices&&m.updateVerticesData(_.b.MatricesIndicesKind,this.matricesIndices,c,T),this.matricesWeights&&m.updateVerticesData(_.b.MatricesWeightsKind,this.matricesWeights,c,T),this.matricesIndicesExtra&&m.updateVerticesData(_.b.MatricesIndicesExtraKind,this.matricesIndicesExtra,c,T),this.matricesWeightsExtra&&m.updateVerticesData(_.b.MatricesWeightsExtraKind,this.matricesWeightsExtra,c,T),this.indices&&m.setIndices(this.indices,null),this},x.prototype.transform=function(m){var c,T=m.determinant()<0,A=U.e.Zero();if(this.positions){var S=U.e.Zero();for(c=0;cA.bbSize.y?A.bbSize.x:A.bbSize.y;ct=ct>A.bbSize.z?ct:A.bbSize.z,H=A.subDiv.X*re/A.bbSize.x,Z=A.subDiv.Y*re/A.bbSize.y,W=A.subDiv.Z*re/A.bbSize.z,q=A.subDiv.max*A.subDiv.max,A.facetPartitioning.length=0}for(S=0;Sre.LongPressDelay&&!H._isPointerSwiping()&&(H._startingPointerTime=0,W.processTrigger(I.a.ACTION_OnLongPressTrigger,E.a.CreateNew(_e.pickedMesh,k)))},re.LongPressDelay)}}else for(var q=0,he=Z._pointerDownStage;qre.DragMovementThreshold||Math.abs(this._startingPointerPosition.y-this._pointerY)>re.DragMovementThreshold},re.prototype.simulatePointerUp=function(Y,k,H){var Z=new PointerEvent("pointerup",k),W=new ae;H?W.doubleClick=!0:W.singleClick=!0,this._checkPrePointerObservable(Y,Z,te.a.POINTERUP)||this._processPointerUp(Y,Z,W)},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 W=te.a.POINTERPICK,q=new te.b(W,k,Y);this._setRayOnPointerInfo(q),Z.onPointerObservable.notifyObservers(q,W)}var he=Y.pickedMesh._getActionManagerForTrigger();if(he&&!H.ignore){he.processTrigger(I.a.ACTION_OnPickUpTrigger,E.a.CreateNew(Y.pickedMesh,k)),!H.hasSwiped&&H.singleClick&&he.processTrigger(I.a.ACTION_OnPickTrigger,E.a.CreateNew(Y.pickedMesh,k));var ge=Y.pickedMesh._getActionManagerForTrigger(I.a.ACTION_OnDoublePickTrigger);H.doubleClick&&ge&&ge.processTrigger(I.a.ACTION_OnDoublePickTrigger,E.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,E.a.CreateNew(this._pickedDownMesh,k))}var Pe=0;Z.onPointerObservable.hasObservers()&&(!H.ignore&&!H.hasSwiped&&(H.singleClick&&Z.onPointerObservable.hasSpecificMask(te.a.POINTERTAP)?Pe=te.a.POINTERTAP:H.doubleClick&&Z.onPointerObservable.hasSpecificMask(te.a.POINTERDOUBLETAP)&&(Pe=te.a.POINTERDOUBLETAP),Pe)&&(q=new te.b(Pe,k,Y),this._setRayOnPointerInfo(q),Z.onPointerObservable.notifyObservers(q,Pe)),H.ignore||(Pe=te.a.POINTERUP,q=new te.b(Pe,k,Y),this._setRayOnPointerInfo(q),Z.onPointerObservable.notifyObservers(q,Pe))),Z.onPointerUp&&!H.ignore&&Z.onPointerUp(k,Y,Pe)},re.prototype.isPointerCaptured=function(Y){return Y===void 0&&(Y=0),this._pointerCaptures[Y]},re.prototype.attachControl=function(Y,k,H,Z){var W=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,Pe){if(!W._meshPickProceed){var ye=q.pick(W._unTranslatedPointerX,W._unTranslatedPointerY,q.pointerDownPredicate,!1,q.cameraToUseForPointers);W._currentPickResult=ye,ye&&(be=ye.hit&&ye.pickedMesh?ye.pickedMesh._getActionManagerForTrigger():null),W._meshPickProceed=!0}return be},this._delayedSimpleClick=function(be,Pe,ye){(Date.now()-W._previousStartingPointerTime>re.DoubleClickDelay&&!W._doubleClickOccured||be!==W._previousButtonPressed)&&(W._doubleClickOccured=!1,Pe.singleClick=!0,Pe.ignore=!1,ye(Pe,W._currentPickResult))},this._initClickEvent=function(be,Pe,ye,Be){var ke=new ae;W._currentPickResult=null;var We=null,je=be.hasSpecificMask(te.a.POINTERPICK)||Pe.hasSpecificMask(te.a.POINTERPICK)||be.hasSpecificMask(te.a.POINTERTAP)||Pe.hasSpecificMask(te.a.POINTERTAP)||be.hasSpecificMask(te.a.POINTERDOUBLETAP)||Pe.hasSpecificMask(te.a.POINTERDOUBLETAP);!je&&de.a&&(We=W._initActionManager(We,ke))&&(je=We.hasPickTriggers);var He=!1;if(je){var qe=ye.button;if(ke.hasSwiped=W._isPointerSwiping(),!ke.hasSwiped){var Ge=!re.ExclusiveDoubleClickMode;Ge||(Ge=!be.hasSpecificMask(te.a.POINTERDOUBLETAP)&&!Pe.hasSpecificMask(te.a.POINTERDOUBLETAP))&&!de.a.HasSpecificTrigger(I.a.ACTION_OnDoublePickTrigger)&&(We=W._initActionManager(We,ke))&&(Ge=!We.hasSpecificTrigger(I.a.ACTION_OnDoublePickTrigger)),Ge?(Date.now()-W._previousStartingPointerTime>re.DoubleClickDelay||qe!==W._previousButtonPressed)&&(ke.singleClick=!0,Be(ke,W._currentPickResult),He=!0):(W._previousDelayedSimpleClickTimeout=W._delayedSimpleClickTimeout,W._delayedSimpleClickTimeout=window.setTimeout(W._delayedSimpleClick.bind(W,qe,ke,Be),re.DoubleClickDelay));var nt=be.hasSpecificMask(te.a.POINTERDOUBLETAP)||Pe.hasSpecificMask(te.a.POINTERDOUBLETAP);!nt&&de.a.HasSpecificTrigger(I.a.ACTION_OnDoublePickTrigger)&&(We=W._initActionManager(We,ke))&&(nt=We.hasSpecificTrigger(I.a.ACTION_OnDoublePickTrigger)),nt&&(qe===W._previousButtonPressed&&Date.now()-W._previousStartingPointerTime0){for(var k=0,H=this._transientComponents;k0)return!1;for(k=0;k0,q=0,he=this._isReadyForMeshStage;q0){for(var ge=0,me=this.activeCameras;ge0},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},enumerable:!1,configurable:!0}),Y.prototype.resetLastAnimationTimeFrame=function(){this._animationTimeLast=C.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,W){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,W):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(W){Z.addMesh(W)}))},Y.prototype.removeMesh=function(k,H){var Z=this;H===void 0&&(H=!1);var W=this.meshes.indexOf(k);return W!==-1&&(this.meshes[W]=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)}),W},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,W=this.meshes;Z0?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;if(H!==-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=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 W=this.getLightByID(k);if(W)return W;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 W=this.getLightByName(k);if(W)return W;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=0;H--)if(this.skeletons[H].id===k)return this.skeletons[H];return null},Y.prototype.getSkeletonByUniqueId=function(k){for(var H=0;H0&&(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,Pe=this._preActiveMeshStage;be0)for(var Z=this.getActiveSubMeshCandidates(H),W=Z.length,q=0;q1)this.activeCamera.outputRenderTarget._bindFrameBuffer();else{var k=this.activeCamera.outputRenderTarget.getInternalTexture();k?this.getEngine().bindFramebuffer(k):X.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 W=0;W0&&this._renderTargets.concatWithNoDuplicate(k.customRenderTargets),H&&H.customRenderTargets&&H.customRenderTargets.length>0&&this._renderTargets.concatWithNoDuplicate(H.customRenderTargets);for(var he=0,ge=this._gatherActiveCameraRenderTargetsStage;he0){_.b.StartPerformanceCounter("Render targets",this._renderTargets.length>0);for(var _e=0;_e0),this._renderId++}for(var ye=0,Be=this._cameraDrawRenderTargetStage;ye1&&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-1&&(W.trigger===I.a.ACTION_OnIntersectionExitTrigger&&W._executeCurrent(E.a.CreateNew(H,void 0,he)),H.actionManager.hasSpecificTrigger(I.a.ACTION_OnIntersectionExitTrigger,function(_e){var be=_e instanceof T.a?_e:_e.mesh;return he===be})&&W.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,W=0,q=this._engine.getLockstepMaxSteps(),he=Math.floor(k/H);for(he=Math.min(he,q);k>0&&W0)for(var q=0;q0),this._intermediateRendering=!0;for(var be=0;be0),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;ye0)for(q=0;q0&&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 je=0,He=this._afterRenderStage;je-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-1?(m.a.Error("You're trying to reuse a post process not defined as reusable."),0):(E==null||E<0?this._postProcesses.push(v):this._postProcesses[E]===null?this._postProcesses[E]=v:this._postProcesses.splice(E,0,v),this._cascadePostProcessesToRigCams(),this._scene.prePassRenderer&&this._scene.prePassRenderer.markAsDirty(),this._postProcesses.indexOf(v))},h.prototype.detachPostProcess=function(v){var E=this._postProcesses.indexOf(v);E!==-1&&(this._postProcesses[E]=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(v){return!v&&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(v){this._doNotComputeProjectionMatrix=!0,v!==void 0&&(this._projectionMatrix=v)},h.prototype.unfreezeProjectionMatrix=function(){this._doNotComputeProjectionMatrix=!1},h.prototype.getProjectionMatrix=function(v){var E,D,w,N,I,V,X,j;if(this._doNotComputeProjectionMatrix||!v&&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((E=this.orthoLeft)!==null&&E!==void 0?E:-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,(X=this.orthoBottom)!==null&&X!==void 0?X:-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(v,E){if(E===void 0&&(E=!1),this._updateFrustumPlanes(),E&&this.rigCameras.length>0){var D=!1;return this.rigCameras.forEach(function(w){w._updateFrustumPlanes(),D=D||v.isInFrustum(w._frustumPlanes)}),D}return v.isInFrustum(this._frustumPlanes)},h.prototype.isCompletelyInFrustum=function(v){return this._updateFrustumPlanes(),v.isCompletelyInFrustum(this._frustumPlanes)},h.prototype.getForwardRay=function(v,E,D){throw T.a.WarnImport("Ray")},h.prototype.getForwardRayToRef=function(v,E,D,w){throw T.a.WarnImport("Ray")},h.prototype.dispose=function(v,E){for(E===void 0&&(E=!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,v,E)},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(v,E){if(this.cameraRigMode!==v){for(;this._rigCameras.length>0;){var D=this._rigCameras.pop();D&&D.dispose()}if(this.cameraRigMode=v,this._cameraRigParams={},this._cameraRigParams.interaxialDistance=E.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,E);break;case h.RIG_MODE_WEBVR:h._setWebVRRigMode(this,E)}this._cascadePostProcessesToRigCams(),this.update()}},h._setStereoscopicRigMode=function(v){throw"Import Cameras/RigModes/stereoscopicRigMode before using stereoscopic rig mode"},h._setStereoscopicAnaglyphRigMode=function(v){throw"Import Cameras/RigModes/stereoscopicAnaglyphRigMode before using stereoscopic anaglyph rig mode"},h._setVRRigMode=function(v,E){throw"Import Cameras/RigModes/vrRigMode before using VR rig mode"},h._setWebVRRigMode=function(v,E){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(v,E){this._cameraRigParams||(this._cameraRigParams={}),this._cameraRigParams[v]=E,v==="interaxialDistance"&&(this._cameraRigParams.stereoHalfAngle=u.b.ToRadians(E/.0637))},h.prototype.createRigCamera=function(v,E){return null},h.prototype._updateRigCameras=function(){for(var v=0;v=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;g1&&be.renderbufferStorageMultisample?be.renderbufferStorageMultisample(be.RENDERBUFFER,he,me,W,q):be.renderbufferStorage(be.RENDERBUFFER,ge,W,q),be.framebufferRenderbuffer(be.FRAMEBUFFER,_e,be.RENDERBUFFER,Pe),be.bindRenderbuffer(be.RENDERBUFFER,null),Pe},this._boundUniforms={};var te=null;if(I){if(X=X||{},E.a.SetMatrixPrecision(!!X.useHighPrecisionMatrix),I.getContext){if(te=I,this._renderingCanvas=te,V!=null&&(X.antialias=V),X.deterministicLockstep===void 0&&(X.deterministicLockstep=!1),X.lockstepMaxSteps===void 0&&(X.lockstepMaxSteps=4),X.timeStep===void 0&&(X.timeStep=1/60),X.preserveDrawingBuffer===void 0&&(X.preserveDrawingBuffer=!1),X.audioEngine===void 0&&(X.audioEngine=!0),X.stencil===void 0&&(X.stencil=!0),X.premultipliedAlpha===!1&&(this.premultipliedAlpha=!1),X.xrCompatible===void 0&&(X.xrCompatible=!0),this._doNotHandleContextLost=!!X.doNotHandleContextLost,navigator&&navigator.userAgent){var de=navigator.userAgent;this.hostInformation.isMobile=de.indexOf("Mobile")!==-1;for(var pe=0,ae=N.ExceptionList;pe0&&parseInt(Q[Q.length-1])>=G)continue}for(var oe=0,re=$;oe1?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=X,console.log("Babylon.js v"+N.Version+" - "+this.description)}}return Object.defineProperty(N,"NpmPackage",{get:function(){return"babylonjs@4.2.2"},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();I1?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")),textureHalfFloatRender:!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 X=0;X<16;X++)this._gl["COLOR_ATTACHMENT"+X+"_WEBGL"]=V["COLOR_ATTACHMENT"+X+"_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=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;V0?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,X,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),X&&(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,X,j){I===this._viewportCached.x&&V===this._viewportCached.y&&X===this._viewportCached.z&&j===this._viewportCached.w||(this._viewportCached.x=I,this._viewportCached.y=V,this._viewportCached.z=X,this._viewportCached.w=j,this._gl.viewport(I,V,X,j))},N.prototype.setViewport=function(I,V,X){var j=V||this.getRenderWidth(),ne=X||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,X,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,X,j):(X||(X=I.width,te&&(X/=Math.pow(2,te))),j||(j=I.height,te&&(j/=Math.pow(2,te))),this._viewport(0,0,X,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,X){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,X);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)),X&&(I._MSAAFramebuffer&&this._bindUnboundFramebuffer(I._framebuffer),X()),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 X=this._gl.createBuffer();if(!X)throw new Error("Unable to create vertex buffer");var j=new l.a(X);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 X=this._gl.createBuffer(),j=new l.a(X);if(!X)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=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,X){var j=I.program,ne=this._gl.getUniformBlockIndex(j,V);this._gl.uniformBlockBinding(j,ne,X)},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,X,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!==X&&(pe.size=X,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=X,pe.type=j,pe.normalized=ne,pe.stride=te,pe.offset=de,pe.buffer=I),(ae||this._vaoRecordInProgress)&&(this.bindArrayBuffer(I),this._gl.vertexAttribPointer(V,X,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 X=V.getAttributesNames();this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.unbindAllAttributes();for(var j=0;j=0){var te=I[X[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,X){var j=this._gl.createVertexArray();return this._vaoRecordInProgress=!0,this._gl.bindVertexArray(j),this._mustWipeVertexAttributes=!0,this._bindVertexBuffersAttributes(I,X),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,X,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=0&&(this._gl.enableVertexAttribArray(ae),this._vertexAttribArraysEnabled[ae]=!0,this._vertexAttribPointer(I,ae,X[pe],this._gl.FLOAT,!1,j,de)),de+=4*X[pe]}}this._bindIndexBufferWithCache(V)},N.prototype._unbindVertexArrayObject=function(){this._cachedVertexArrayObject&&(this._cachedVertexArrayObject=null,this._gl.bindVertexArray(null))},N.prototype.bindBuffers=function(I,V,X){this._cachedVertexBuffers===I&&this._cachedEffectForVertexBuffers===X||(this._cachedVertexBuffers=I,this._cachedEffectForVertexBuffers=X,this._bindVertexBuffersAttributes(I,X)),this._bindIndexBufferWithCache(V)},N.prototype.unbindInstanceAttributes=function(){for(var I,V=0,X=this._currentInstanceLocations.length;V1?`#version 300 es +#define WEBGL2 +`:"",pe=this._compileShader(V,"vertex",j,de),ae=this._compileShader(X,"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,X,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,X),j.linkProgram(te),I.context=j,I.vertexShader=V,I.fragmentShader=X,I.isParallelCompiled||this._finalizePipelineContext(I),te},N.prototype._finalizePipelineContext=function(I){var V=I.context,X=I.vertexShader,j=I.fragmentShader,ne=I.program;if(!V.getProgramParameter(ne,V.LINK_STATUS)){var te,de;if(!this._gl.getShaderParameter(X,this._gl.COMPILE_STATUS)&&(te=this._gl.getShaderInfoLog(X)))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(X),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,X,j,ne,te,de){var pe=I;pe.program=j?this.createRawShaderProgram(pe,V,X,void 0,de):this.createShaderProgram(pe,V,X,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 X=I;if(X.isParallelCompiled){var j=X.onCompiled;X.onCompiled=j?function(){j(),V()}:V}else V()},N.prototype.getUniforms=function(I,V){for(var X=new Array,j=I,ne=0;ne-1?I.substring(H).toLowerCase():""),W=null;Z.indexOf("?")>-1&&(Z=Z.split("?")[0]);for(var q=0,he=N._TextureLoaders;qGe||ye.height>Ge||!G._supportsHardwareTextureRescaling)return G._prepareWorkingCanvas(),!(!G._workingCanvas||!G._workingContext)&&(G._workingCanvas.width=Be,G._workingCanvas.height=ke,G._workingContext.drawImage(ye,0,0,ye.width,ye.height,0,0,Be,ke),je.texImage2D(je.TEXTURE_2D,0,qe,qe,je.UNSIGNED_BYTE,G._workingCanvas),Y.width=Be,Y.height=ke,!1);var nt=new c.a(G,c.b.Temp);return G._bindTextureDirectly(je.TEXTURE_2D,nt,!0),je.texImage2D(je.TEXTURE_2D,0,qe,qe,je.UNSIGNED_BYTE,ye),G._rescaleTexture(nt,Y,j,qe,function(){G._releaseTexture(nt),G._bindTextureDirectly(je.TEXTURE_2D,Y,!0),We()}),!0},ne)};!Q||re?pe&&(pe.decoding||pe.close)?Pe(pe):N._FileToolsLoadImage(I,Pe,_e,j?j.offlineProvider:null,$):typeof pe=="string"||pe instanceof ArrayBuffer||ArrayBuffer.isView(pe)||pe instanceof Blob?N._FileToolsLoadImage(pe,Pe,_e,j?j.offlineProvider:null,$):pe&&Pe(pe)}return Y},N._FileToolsLoadImage=function(I,V,X,j,ne){throw C.a.WarnImport("FileTools")},N.prototype._rescaleTexture=function(I,V,X,j,ne){},N.prototype.createRawTexture=function(I,V,X,j,ne,te,de,pe,ae){throw ae===void 0&&(ae=m.a.TEXTURETYPE_UNSIGNED_INT),C.a.WarnImport("Engine.RawTexture")},N.prototype.createRawCubeTexture=function(I,V,X,j,ne,te,de,pe){throw C.a.WarnImport("Engine.RawTexture")},N.prototype.createRawTexture3D=function(I,V,X,j,ne,te,de,pe,ae,ee){throw ee===void 0&&(ee=m.a.TEXTURETYPE_UNSIGNED_INT),C.a.WarnImport("Engine.RawTexture")},N.prototype.createRawTexture2DArray=function(I,V,X,j,ne,te,de,pe,ae,ee){throw ee===void 0&&(ee=m.a.TEXTURETYPE_UNSIGNED_INT),C.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,X){X===void 0&&(X=!1);var j=this._getTextureTarget(V),ne=this._getSamplingParameters(I,V.generateMipMaps||X);this._setTextureParameterInteger(j,this._gl.TEXTURE_MAG_FILTER,ne.mag,V),this._setTextureParameterInteger(j,this._gl.TEXTURE_MIN_FILTER,ne.min),X&&(V.generateMipMaps=!0,this._gl.generateMipmap(j)),this._bindTextureDirectly(j,null),V.samplingMode=I},N.prototype.updateTextureWrappingMode=function(I,V,X,j){X===void 0&&(X=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),X!==null&&(this._setTextureParameterInteger(ne,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(X),I),I._cachedWrapV=X),(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,X,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=X,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,X,j,ne,te,de){te===void 0&&(te=0),de===void 0&&(de=0);var pe=this._gl,ae=pe.TEXTURE_2D;I.isCube&&(ae=pe.TEXTURE_CUBE_MAP_POSITIVE_X+te),this._gl.compressedTexImage2D(ae,de,V,X,j,0,ne)},N.prototype._uploadDataToTextureDirectly=function(I,V,X,j,ne,te){X===void 0&&(X=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+X);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,X,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,X,j,ne,te,K,ee,V)},N.prototype._uploadArrayBufferViewToTexture=function(I,V,X,j){X===void 0&&(X=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,X,j),this._bindTextureDirectly(te,null,!0)},N.prototype._prepareWebGLTextureContinuation=function(I,V,X,j,ne){var te=this._gl;if(te){var de=this._getSamplingParameters(ne,!X);te.texParameteri(te.TEXTURE_2D,te.TEXTURE_MAG_FILTER,de.mag),te.texParameteri(te.TEXTURE_2D,te.TEXTURE_MIN_FILTER,de.min),X||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,X,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(X,K):X),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=X,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,X,j,ne){ne===void 0&&(ne=1);var te=this._gl;if(I&&V)return this._getDepthStencilBuffer(X,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(X,j,ne,de,de,te.DEPTH_ATTACHMENT)}return I?this._getDepthStencilBuffer(X,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 X=I.getSamplers(),j=0;j-1;return X&&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)):X&&(ne=!0,this._activateCurrentTexture()),te&&!X&&this._bindSamplerUniformToChannel(V._associatedChannel,this._activeChannel),ne},N.prototype._bindTexture=function(I,V){if(I!==void 0){V&&(V._associatedChannel=I),this._activeChannel=I;var X=V?this._getTextureTarget(V):this._gl.TEXTURE_2D;this._bindTextureDirectly(X,V)}},N.prototype.unbindAllTextures=function(){for(var I=0;I1&&(this._bindTextureDirectly(this._gl.TEXTURE_3D,null),this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY,null))},N.prototype.setTexture=function(I,V,X){I!==void 0&&(V&&(this._boundUniforms[I]=V),this._setTexture(I,X))},N.prototype._bindSamplerUniformToChannel=function(I,V){var X=this._boundUniforms[I];X&&X._currentState!==V&&(this._gl.uniform1i(X,V),X._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,X,j){if(X===void 0&&(X=!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,!X&&ne&&(ne._associatedChannel=I);var te=!0;this._boundTexturesCache[I]===ne&&(X||this._bindSamplerUniformToChannel(ne._associatedChannel,I),te=!1),this._activeChannel=I;var de=this._getTextureTarget(ne);if(te&&this._bindTextureDirectly(de,ne,X),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,X){if(I!==void 0&&V){this._textureUnits&&this._textureUnits.length===X.length||(this._textureUnits=new Int32Array(X.length));for(var j=0;j=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.ResetCache();for(var I=0,V=this._activeRequests;I1?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 X=!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((X=(X=X&&te===V.FRAMEBUFFER_COMPLETE)&&V.getError()===V.NO_ERROR)&&(V.clear(V.COLOR_BUFFER_BIT),X=X&&V.getError()===V.NO_ERROR),X){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),X=X&&V.getError()===V.NO_ERROR}for(V.deleteTexture(j),V.deleteFramebuffer(ne),V.bindFramebuffer(V.FRAMEBUFFER,null);!X&&V.getError()!==V.NO_ERROR;);return X},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,X,j,ne,te){var de=this,pe=N._FileToolsLoadFile(I,V,X,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,X,j,ne,te){throw C.a.WarnImport("FileTools")},N.prototype.readPixels=function(I,V,X,j,ne){ne===void 0&&(ne=!0);var te=ne?4:3,de=ne?this._gl.RGBA:this._gl.RGB,pe=new Uint8Array(j*X*te);return this._gl.readPixels(I,V,X,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=v.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=v.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),X=N.FloorPOT(I);return V-I>I-X?X:V},N.GetExponentOfTwo=function(I,V,X){var j;switch(X===void 0&&(X=m.a.SCALEMODE_NEAREST),X){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(Me,y,f){f.d(y,"b",function(){return U}),f.d(y,"a",function(){return R});var U,_=f(6),C=f(102),u=f(2),M=f(21);(function(x){x[x.Unknown=0]="Unknown",x[x.Url=1]="Url",x[x.Temp=2]="Temp",x[x.Raw=3]="Raw",x[x.Dynamic=4]="Dynamic",x[x.RenderTarget=5]="RenderTarget",x[x.MultiRenderTarget=6]="MultiRenderTarget",x[x.Cube=7]="Cube",x[x.CubeRaw=8]="CubeRaw",x[x.CubePrefiltered=9]="CubePrefiltered",x[x.Raw3D=10]="Raw3D",x[x.Raw2DArray=11]="Raw2DArray",x[x.Depth=12]="Depth",x[x.CubeRawRGBD=13]="CubeRawRGBD"})(U||(U={}));var R=function(){function x(m,c,T){T===void 0&&(T=!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=U.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,T||(this._webGLTexture=m._createTexture())}return x.prototype.getEngine=function(){return this._engine},Object.defineProperty(x.prototype,"source",{get:function(){return this._source},enumerable:!1,configurable:!0}),x.prototype.incrementReferences=function(){this._references++},x.prototype.updateSize=function(m,c,T){T===void 0&&(T=1),this.width=m,this.height=c,this.depth=T,this.baseWidth=m,this.baseHeight=c,this.baseDepth=T,this._size=m*c*T},x.prototype._rebuild=function(){var m,c,T=this;switch(this.isReady=!1,this._cachedCoordinatesMode=null,this._cachedWrapU=null,this._cachedWrapV=null,this._cachedAnisotropicFilteringLevel=null,this.source){case U.Temp:return;case U.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(T),T.isReady=!0},null,this._buffer,void 0,this.format));case U.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 U.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 U.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 U.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 U.RenderTarget:var A=new C.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 U.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 U.Cube:return void(c=this._engine.createCubeTexture(this.url,null,this._files,!this.generateMipMaps,function(){c._swapAndDie(T),T.isReady=!0},null,this.format,this._extension));case U.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 U.CubeRawRGBD:return c=this._engine.createRawCubeTexture(null,this.width,this.format,this.type,this.generateMipMaps,this.invertY,this.samplingMode,this._compression),void x._UpdateRGBDAsync(c,this._bufferViewArrayArray,this._sphericalPolynomial,this._lodGenerationScale,this._lodGenerationOffset).then(function(){c._swapAndDie(T),T.isReady=!0});case U.CubePrefiltered:return void((c=this._engine.createPrefilteredCubeTexture(this.url,null,this._lodGenerationScale,this._lodGenerationOffset,function(h){h&&h._swapAndDie(T),T.isReady=!0},null,this.format,this._extension))._sphericalPolynomial=this._sphericalPolynomial)}},x.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,T=this._engine.getLoadedTexturesCache();(c=T.indexOf(this))!==-1&&T.splice(c,1),(c=T.indexOf(m))===-1&&T.push(m)},x.prototype.dispose=function(){this._webGLTexture&&(this._references--,this._references===0&&(this._engine._releaseTexture(this),this._webGLTexture=null))},x._UpdateRGBDAsync=function(m,c,T,A,S){throw M.a.WarnImport("environmentTextureTools")},x}()},function(Me,y,f){f.d(y,"b",function(){return U}),f.d(y,"c",function(){return _}),f.d(y,"a",function(){return C});var U=1/2.2,_=2.2,C=.001},function(Me,y,f){f.d(y,"a",function(){return x});var U=f(1),_=f(0),C=f(3),u=f(6),M=f(22),R=f(21),x=function(){function m(c,T){T===void 0&&(T=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=T||M.a.LastCreatedScene,this.uniqueId=this._scene.getUniqueId(),this._initCache()}return m.AddNodeConstructor=function(c,T){this._NodeConstructors[c]=T},m.Construct=function(c,T,A,S){var g=this._NodeConstructors[c];return g?g(T,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 T=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),T||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,T=c.length-1;c[this._sceneRootNodesIndex]=c[T],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,T){var A=this;return T===void 0&&(T=!1),this._behaviors.indexOf(c)!==-1||(c.init(),this._scene.isLoading&&!T?this._scene.onDataLoadedObservable.addOnce(function(){c.attach(A)}):c.attach(this),this._behaviors.push(c)),this},m.prototype.removeBehavior=function(c){var T=this._behaviors.indexOf(c);return T===-1||(this._behaviors[T].detach(),this._behaviors.splice(T,1)),this},Object.defineProperty(m.prototype,"behaviors",{get:function(){return this._behaviors},enumerable:!1,configurable:!0}),m.prototype.getBehaviorByName=function(c){for(var T=0,A=this._behaviors;T +#if defined(BUMP) || !defined(NORMAL) +#extension GL_OES_standard_derivatives : enable +#endif +#include[SCENE_MRT_COUNT] +#define CUSTOM_FRAGMENT_BEGIN +#ifdef LOGARITHMICDEPTH +#extension GL_EXT_frag_depth : enable +#endif + +#define RECIPROCAL_PI2 0.15915494 +uniform vec3 vEyePosition; +uniform vec3 vAmbientColor; + +varying vec3 vPositionW; +#ifdef NORMAL +varying vec3 vNormalW; +#endif +#ifdef VERTEXCOLOR +varying vec4 vColor; +#endif +#ifdef MAINUV1 +varying vec2 vMainUV1; +#endif +#ifdef MAINUV2 +varying vec2 vMainUV2; +#endif + +#include + +#include<__decl__lightFragment>[0..maxSimultaneousLights] +#include +#include + +#ifdef DIFFUSE +#if DIFFUSEDIRECTUV == 1 +#define vDiffuseUV vMainUV1 +#elif DIFFUSEDIRECTUV == 2 +#define vDiffuseUV vMainUV2 +#else +varying vec2 vDiffuseUV; +#endif +uniform sampler2D diffuseSampler; +#endif +#ifdef AMBIENT +#if AMBIENTDIRECTUV == 1 +#define vAmbientUV vMainUV1 +#elif AMBIENTDIRECTUV == 2 +#define vAmbientUV vMainUV2 +#else +varying vec2 vAmbientUV; +#endif +uniform sampler2D ambientSampler; +#endif +#ifdef OPACITY +#if OPACITYDIRECTUV == 1 +#define vOpacityUV vMainUV1 +#elif OPACITYDIRECTUV == 2 +#define vOpacityUV vMainUV2 +#else +varying vec2 vOpacityUV; +#endif +uniform sampler2D opacitySampler; +#endif +#ifdef EMISSIVE +#if EMISSIVEDIRECTUV == 1 +#define vEmissiveUV vMainUV1 +#elif EMISSIVEDIRECTUV == 2 +#define vEmissiveUV vMainUV2 +#else +varying vec2 vEmissiveUV; +#endif +uniform sampler2D emissiveSampler; +#endif +#ifdef LIGHTMAP +#if LIGHTMAPDIRECTUV == 1 +#define vLightmapUV vMainUV1 +#elif LIGHTMAPDIRECTUV == 2 +#define vLightmapUV vMainUV2 +#else +varying vec2 vLightmapUV; +#endif +uniform sampler2D lightmapSampler; +#endif +#ifdef REFRACTION +#ifdef REFRACTIONMAP_3D +uniform samplerCube refractionCubeSampler; +#else +uniform sampler2D refraction2DSampler; +#endif +#endif +#if defined(SPECULAR) && defined(SPECULARTERM) +#if SPECULARDIRECTUV == 1 +#define vSpecularUV vMainUV1 +#elif SPECULARDIRECTUV == 2 +#define vSpecularUV vMainUV2 +#else +varying vec2 vSpecularUV; +#endif +uniform sampler2D specularSampler; +#endif +#ifdef ALPHATEST +uniform float alphaCutOff; +#endif + +#include + +#ifdef REFLECTION +#ifdef REFLECTIONMAP_3D +uniform samplerCube reflectionCubeSampler; +#else +uniform sampler2D reflection2DSampler; +#endif +#ifdef REFLECTIONMAP_SKYBOX +varying vec3 vPositionUVW; +#else +#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) +varying vec3 vDirectionW; +#endif +#endif +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#define CUSTOM_FRAGMENT_DEFINITIONS +void main(void) { +#define CUSTOM_FRAGMENT_MAIN_BEGIN +#include +vec3 viewDirectionW=normalize(vEyePosition-vPositionW); + +vec4 baseColor=vec4(1.,1.,1.,1.); +vec3 diffuseColor=vDiffuseColor.rgb; + +float alpha=vDiffuseColor.a; + +#ifdef NORMAL +vec3 normalW=normalize(vNormalW); +#else +vec3 normalW=normalize(-cross(dFdx(vPositionW),dFdy(vPositionW))); +#endif +#include +#ifdef TWOSIDEDLIGHTING +normalW=gl_FrontFacing ? normalW : -normalW; +#endif +#ifdef DIFFUSE +baseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset); +#if defined(ALPHATEST) && !defined(ALPHATEST_AFTERALLALPHACOMPUTATIONS) +if (baseColor.a +#ifdef VERTEXCOLOR +baseColor.rgb*=vColor.rgb; +#endif +#ifdef DETAIL +baseColor.rgb=baseColor.rgb*2.0*mix(0.5,detailColor.r,vDetailInfos.y); +#endif +#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE + +vec3 baseAmbientColor=vec3(1.,1.,1.); +#ifdef AMBIENT +baseAmbientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y; +#endif +#define CUSTOM_FRAGMENT_BEFORE_LIGHTS + +#ifdef SPECULARTERM +float glossiness=vSpecularColor.a; +vec3 specularColor=vSpecularColor.rgb; +#ifdef SPECULAR +vec4 specularMapColor=texture2D(specularSampler,vSpecularUV+uvOffset); +specularColor=specularMapColor.rgb; +#ifdef GLOSSINESS +glossiness=glossiness*specularMapColor.a; +#endif +#endif +#else +float glossiness=0.; +#endif + +vec3 diffuseBase=vec3(0.,0.,0.); +lightingInfo info; +#ifdef SPECULARTERM +vec3 specularBase=vec3(0.,0.,0.); +#endif +float shadow=1.; +#ifdef LIGHTMAP +vec4 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset); +#ifdef RGBDLIGHTMAP +lightmapColor.rgb=fromRGBD(lightmapColor); +#endif +lightmapColor.rgb*=vLightmapInfos.y; +#endif +#include[0..maxSimultaneousLights] + +vec4 refractionColor=vec4(0.,0.,0.,1.); +#ifdef REFRACTION +vec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y)); +#ifdef REFRACTIONMAP_3D +refractionVector.y=refractionVector.y*vRefractionInfos.w; +if (dot(refractionVector,viewDirectionW)<1.0) { +refractionColor=textureCube(refractionCubeSampler,refractionVector); +} +#else +vec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0))); +vec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z; +refractionCoords.y=1.0-refractionCoords.y; +refractionColor=texture2D(refraction2DSampler,refractionCoords); +#endif +#ifdef RGBDREFRACTION +refractionColor.rgb=fromRGBD(refractionColor); +#endif +#ifdef IS_REFRACTION_LINEAR +refractionColor.rgb=toGammaSpace(refractionColor.rgb); +#endif +refractionColor.rgb*=vRefractionInfos.x; +#endif + +vec4 reflectionColor=vec4(0.,0.,0.,1.); +#ifdef REFLECTION +vec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW); +#ifdef REFLECTIONMAP_3D +#ifdef ROUGHNESS +float bias=vReflectionInfos.y; +#ifdef SPECULARTERM +#ifdef SPECULAR +#ifdef GLOSSINESS +bias*=(1.0-specularMapColor.a); +#endif +#endif +#endif +reflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias); +#else +reflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW); +#endif +#else +vec2 coords=vReflectionUVW.xy; +#ifdef REFLECTIONMAP_PROJECTION +coords/=vReflectionUVW.z; +#endif +coords.y=1.0-coords.y; +reflectionColor=texture2D(reflection2DSampler,coords); +#endif +#ifdef RGBDREFLECTION +reflectionColor.rgb=fromRGBD(reflectionColor); +#endif +#ifdef IS_REFLECTION_LINEAR +reflectionColor.rgb=toGammaSpace(reflectionColor.rgb); +#endif +reflectionColor.rgb*=vReflectionInfos.x; +#ifdef REFLECTIONFRESNEL +float reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a); +#ifdef REFLECTIONFRESNELFROMSPECULAR +#ifdef SPECULARTERM +reflectionColor.rgb*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb; +#else +reflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb; +#endif +#else +reflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb; +#endif +#endif +#endif +#ifdef REFRACTIONFRESNEL +float refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a); +refractionColor.rgb*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb; +#endif +#ifdef OPACITY +vec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset); +#ifdef OPACITYRGB +opacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11); +alpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y; +#else +alpha*=opacityMap.a*vOpacityInfos.y; +#endif +#endif +#ifdef VERTEXALPHA +alpha*=vColor.a; +#endif +#ifdef OPACITYFRESNEL +float opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w); +alpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y; +#endif +#ifdef ALPHATEST +#ifdef ALPHATEST_AFTERALLALPHACOMPUTATIONS +if (alpha +#include + + +#ifdef IMAGEPROCESSINGPOSTPROCESS +color.rgb=toLinearSpace(color.rgb); +#else +#ifdef IMAGEPROCESSING +color.rgb=toLinearSpace(color.rgb); +color=applyImageProcessing(color); +#endif +#endif +color.a*=visibility; +#ifdef PREMULTIPLYALPHA + +color.rgb*=color.a; +#endif +#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR +#ifdef PREPASS +gl_FragData[0]=color; +#ifdef PREPASS_POSITION +gl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,1.0); +#endif +#ifdef PREPASS_VELOCITY +vec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5; +vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5; +vec2 velocity=abs(a-b); +velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5; +gl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,1.0); +#endif +#ifdef PREPASS_IRRADIANCE +gl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(0.0,0.0,0.0,1.0); +#endif +#ifdef PREPASS_DEPTHNORMAL +gl_FragData[PREPASS_DEPTHNORMAL_INDEX]=vec4(vViewPos.z,(view*vec4(normalW,0.0)).rgb); +#endif +#ifdef PREPASS_ALBEDO +gl_FragData[PREPASS_ALBEDO_INDEX]=vec4(0.0,0.0,0.0,1.0); +#endif +#ifdef PREPASS_REFLECTIVITY +#if defined(SPECULAR) +gl_FragData[PREPASS_REFLECTIVITY_INDEX]=specularMapColor; +#else +gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(0.0,0.0,0.0,1.0); +#endif +#endif +#endif +#if !defined(PREPASS) || defined(WEBGL2) +gl_FragColor=color; +#endif +} +`;E.a.ShadersStore.defaultPixelShader=N;var I=` +uniform mat4 viewProjection; +uniform mat4 view; +#ifdef DIFFUSE +uniform mat4 diffuseMatrix; +uniform vec2 vDiffuseInfos; +#endif +#ifdef AMBIENT +uniform mat4 ambientMatrix; +uniform vec2 vAmbientInfos; +#endif +#ifdef OPACITY +uniform mat4 opacityMatrix; +uniform vec2 vOpacityInfos; +#endif +#ifdef EMISSIVE +uniform vec2 vEmissiveInfos; +uniform mat4 emissiveMatrix; +#endif +#ifdef LIGHTMAP +uniform vec2 vLightmapInfos; +uniform mat4 lightmapMatrix; +#endif +#if defined(SPECULAR) && defined(SPECULARTERM) +uniform vec2 vSpecularInfos; +uniform mat4 specularMatrix; +#endif +#ifdef BUMP +uniform vec3 vBumpInfos; +uniform mat4 bumpMatrix; +#endif +#ifdef REFLECTION +uniform mat4 reflectionMatrix; +#endif +#ifdef POINTSIZE +uniform float pointSize; +#endif +`;E.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),E.a.IncludesShadersStore.pointCloudVertex=`#ifdef POINTSIZE +gl_PointSize=pointSize; +#endif`,f(158);var V=`#include<__decl__defaultVertex> + +#define CUSTOM_VERTEX_BEGIN +attribute vec3 position; +#ifdef NORMAL +attribute vec3 normal; +#endif +#ifdef TANGENT +attribute vec4 tangent; +#endif +#ifdef UV1 +attribute vec2 uv; +#endif +#ifdef UV2 +attribute vec2 uv2; +#endif +#ifdef VERTEXCOLOR +attribute vec4 color; +#endif +#include +#include + +#include +#include +#ifdef MAINUV1 +varying vec2 vMainUV1; +#endif +#ifdef MAINUV2 +varying vec2 vMainUV2; +#endif +#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0 +varying vec2 vDiffuseUV; +#endif +#if defined(DETAIL) && DETAILDIRECTUV == 0 +varying vec2 vDetailUV; +#endif +#if defined(AMBIENT) && AMBIENTDIRECTUV == 0 +varying vec2 vAmbientUV; +#endif +#if defined(OPACITY) && OPACITYDIRECTUV == 0 +varying vec2 vOpacityUV; +#endif +#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0 +varying vec2 vEmissiveUV; +#endif +#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0 +varying vec2 vLightmapUV; +#endif +#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0 +varying vec2 vSpecularUV; +#endif +#if defined(BUMP) && BUMPDIRECTUV == 0 +varying vec2 vBumpUV; +#endif + +varying vec3 vPositionW; +#ifdef NORMAL +varying vec3 vNormalW; +#endif +#ifdef VERTEXCOLOR +varying vec4 vColor; +#endif +#include +#include +#include +#include<__decl__lightFragment>[0..maxSimultaneousLights] +#include +#include[0..maxSimultaneousMorphTargets] +#ifdef REFLECTIONMAP_SKYBOX +varying vec3 vPositionUVW; +#endif +#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) +varying vec3 vDirectionW; +#endif +#include +#define CUSTOM_VERTEX_DEFINITIONS +void main(void) { +#define CUSTOM_VERTEX_MAIN_BEGIN +vec3 positionUpdated=position; +#ifdef NORMAL +vec3 normalUpdated=normal; +#endif +#ifdef TANGENT +vec4 tangentUpdated=tangent; +#endif +#ifdef UV1 +vec2 uvUpdated=uv; +#endif +#include[0..maxSimultaneousMorphTargets] +#ifdef REFLECTIONMAP_SKYBOX +vPositionUVW=positionUpdated; +#endif +#define CUSTOM_VERTEX_UPDATE_POSITION +#define CUSTOM_VERTEX_UPDATE_NORMAL +#include +#if defined(PREPASS) && defined(PREPASS_VELOCITY) && !defined(BONES_VELOCITY_ENABLED) + +vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0); +vPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0); +#endif +#include +vec4 worldPos=finalWorld*vec4(positionUpdated,1.0); +#ifdef NORMAL +mat3 normalWorld=mat3(finalWorld); +#if defined(INSTANCES) && defined(THIN_INSTANCES) +vNormalW=normalUpdated/vec3(dot(normalWorld[0],normalWorld[0]),dot(normalWorld[1],normalWorld[1]),dot(normalWorld[2],normalWorld[2])); +vNormalW=normalize(normalWorld*vNormalW); +#else +#ifdef NONUNIFORMSCALING +normalWorld=transposeMat3(inverseMat3(normalWorld)); +#endif +vNormalW=normalize(normalWorld*normalUpdated); +#endif +#endif +#define CUSTOM_VERTEX_UPDATE_WORLDPOS +#ifdef MULTIVIEW +if (gl_ViewID_OVR == 0u) { +gl_Position=viewProjection*worldPos; +} else { +gl_Position=viewProjectionR*worldPos; +} +#else +gl_Position=viewProjection*worldPos; +#endif +vPositionW=vec3(worldPos); +#include +#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) +vDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0))); +#endif + +#ifndef UV1 +vec2 uvUpdated=vec2(0.,0.); +#endif +#ifndef UV2 +vec2 uv2=vec2(0.,0.); +#endif +#ifdef MAINUV1 +vMainUV1=uvUpdated; +#endif +#ifdef MAINUV2 +vMainUV2=uv2; +#endif +#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0 +if (vDiffuseInfos.x == 0.) +{ +vDiffuseUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0)); +} +else +{ +vDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0)); +} +#endif +#if defined(DETAIL) && DETAILDIRECTUV == 0 +if (vDetailInfos.x == 0.) +{ +vDetailUV=vec2(detailMatrix*vec4(uvUpdated,1.0,0.0)); +} +else +{ +vDetailUV=vec2(detailMatrix*vec4(uv2,1.0,0.0)); +} +#endif +#if defined(AMBIENT) && AMBIENTDIRECTUV == 0 +if (vAmbientInfos.x == 0.) +{ +vAmbientUV=vec2(ambientMatrix*vec4(uvUpdated,1.0,0.0)); +} +else +{ +vAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0)); +} +#endif +#if defined(OPACITY) && OPACITYDIRECTUV == 0 +if (vOpacityInfos.x == 0.) +{ +vOpacityUV=vec2(opacityMatrix*vec4(uvUpdated,1.0,0.0)); +} +else +{ +vOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0)); +} +#endif +#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0 +if (vEmissiveInfos.x == 0.) +{ +vEmissiveUV=vec2(emissiveMatrix*vec4(uvUpdated,1.0,0.0)); +} +else +{ +vEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0)); +} +#endif +#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0 +if (vLightmapInfos.x == 0.) +{ +vLightmapUV=vec2(lightmapMatrix*vec4(uvUpdated,1.0,0.0)); +} +else +{ +vLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0)); +} +#endif +#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0 +if (vSpecularInfos.x == 0.) +{ +vSpecularUV=vec2(specularMatrix*vec4(uvUpdated,1.0,0.0)); +} +else +{ +vSpecularUV=vec2(specularMatrix*vec4(uv2,1.0,0.0)); +} +#endif +#if defined(BUMP) && BUMPDIRECTUV == 0 +if (vBumpInfos.x == 0.) +{ +vBumpUV=vec2(bumpMatrix*vec4(uvUpdated,1.0,0.0)); +} +else +{ +vBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0)); +} +#endif +#include +#include +#include +#include[0..maxSimultaneousLights] +#ifdef VERTEXCOLOR + +vColor=color; +#endif +#include +#include +#define CUSTOM_VERTEX_MAIN_END +} +`;E.a.ShadersStore.defaultVertexShader=V;var X=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(U.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"];$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===X.a.ALPHA_PREMULTIPLIED||this.alphaMode===X.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=[x.b.PositionKind];Q.NORMAL&&k.push(x.b.NormalKind),Q.UV1&&k.push(x.b.UVKind),Q.UV2&&k.push(x.b.UV2Kind),Q.VERTEXCOLOR&&k.push(x.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"],W=["diffuseSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","specularSampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler","boneSampler"],q=["Material","Scene"];ne.a.AddUniforms(Z),ne.a.AddSamplers(W),m.a.AddUniforms(Z),m.a.AddSamplers(Z),c.a&&(c.a.PrepareUniforms(Z,Q),c.a.PrepareSamplers(W,Q)),g.a.PrepareUniformsAndSamplersList({uniformsNames:Z,uniformBuffersNames:q,samplers:W,defines:Q,maxSimultaneousLights:this._maxSimultaneousLights});var he={};this.customShaderNameResolve&&(H=this.customShaderNameResolve(H,Z,q,W,Q,k,he));var ge=Q.toString(),me=$.effect,_e=G.getEngine().createEffect(H,{attributes:k,uniformsNames:Z,uniformBuffersNames:q,samplers:W,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(),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 v.a.DiffuseTextureEnabled},set:function(K){v.a.DiffuseTextureEnabled=K},enumerable:!1,configurable:!0}),Object.defineProperty(ee,"DetailTextureEnabled",{get:function(){return v.a.DetailTextureEnabled},set:function(K){v.a.DetailTextureEnabled=K},enumerable:!1,configurable:!0}),Object.defineProperty(ee,"AmbientTextureEnabled",{get:function(){return v.a.AmbientTextureEnabled},set:function(K){v.a.AmbientTextureEnabled=K},enumerable:!1,configurable:!0}),Object.defineProperty(ee,"OpacityTextureEnabled",{get:function(){return v.a.OpacityTextureEnabled},set:function(K){v.a.OpacityTextureEnabled=K},enumerable:!1,configurable:!0}),Object.defineProperty(ee,"ReflectionTextureEnabled",{get:function(){return v.a.ReflectionTextureEnabled},set:function(K){v.a.ReflectionTextureEnabled=K},enumerable:!1,configurable:!0}),Object.defineProperty(ee,"EmissiveTextureEnabled",{get:function(){return v.a.EmissiveTextureEnabled},set:function(K){v.a.EmissiveTextureEnabled=K},enumerable:!1,configurable:!0}),Object.defineProperty(ee,"SpecularTextureEnabled",{get:function(){return v.a.SpecularTextureEnabled},set:function(K){v.a.SpecularTextureEnabled=K},enumerable:!1,configurable:!0}),Object.defineProperty(ee,"BumpTextureEnabled",{get:function(){return v.a.BumpTextureEnabled},set:function(K){v.a.BumpTextureEnabled=K},enumerable:!1,configurable:!0}),Object.defineProperty(ee,"LightmapTextureEnabled",{get:function(){return v.a.LightmapTextureEnabled},set:function(K){v.a.LightmapTextureEnabled=K},enumerable:!1,configurable:!0}),Object.defineProperty(ee,"RefractionTextureEnabled",{get:function(){return v.a.RefractionTextureEnabled},set:function(K){v.a.RefractionTextureEnabled=K},enumerable:!1,configurable:!0}),Object.defineProperty(ee,"ColorGradingTextureEnabled",{get:function(){return v.a.ColorGradingTextureEnabled},set:function(K){v.a.ColorGradingTextureEnabled=K},enumerable:!1,configurable:!0}),Object.defineProperty(ee,"FresnelEnabled",{get:function(){return v.a.FresnelEnabled},set:function(K){v.a.FresnelEnabled=K},enumerable:!1,configurable:!0}),Object(U.c)([Object(_.m)("diffuseTexture")],ee.prototype,"_diffuseTexture",void 0),Object(U.c)([Object(_.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],ee.prototype,"diffuseTexture",void 0),Object(U.c)([Object(_.m)("ambientTexture")],ee.prototype,"_ambientTexture",void 0),Object(U.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"ambientTexture",void 0),Object(U.c)([Object(_.m)("opacityTexture")],ee.prototype,"_opacityTexture",void 0),Object(U.c)([Object(_.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],ee.prototype,"opacityTexture",void 0),Object(U.c)([Object(_.m)("reflectionTexture")],ee.prototype,"_reflectionTexture",void 0),Object(U.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"reflectionTexture",void 0),Object(U.c)([Object(_.m)("emissiveTexture")],ee.prototype,"_emissiveTexture",void 0),Object(U.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"emissiveTexture",void 0),Object(U.c)([Object(_.m)("specularTexture")],ee.prototype,"_specularTexture",void 0),Object(U.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"specularTexture",void 0),Object(U.c)([Object(_.m)("bumpTexture")],ee.prototype,"_bumpTexture",void 0),Object(U.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"bumpTexture",void 0),Object(U.c)([Object(_.m)("lightmapTexture")],ee.prototype,"_lightmapTexture",void 0),Object(U.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"lightmapTexture",void 0),Object(U.c)([Object(_.m)("refractionTexture")],ee.prototype,"_refractionTexture",void 0),Object(U.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"refractionTexture",void 0),Object(U.c)([Object(_.e)("ambient")],ee.prototype,"ambientColor",void 0),Object(U.c)([Object(_.e)("diffuse")],ee.prototype,"diffuseColor",void 0),Object(U.c)([Object(_.e)("specular")],ee.prototype,"specularColor",void 0),Object(U.c)([Object(_.e)("emissive")],ee.prototype,"emissiveColor",void 0),Object(U.c)([Object(_.c)()],ee.prototype,"specularPower",void 0),Object(U.c)([Object(_.c)("useAlphaFromDiffuseTexture")],ee.prototype,"_useAlphaFromDiffuseTexture",void 0),Object(U.c)([Object(_.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],ee.prototype,"useAlphaFromDiffuseTexture",void 0),Object(U.c)([Object(_.c)("useEmissiveAsIllumination")],ee.prototype,"_useEmissiveAsIllumination",void 0),Object(U.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"useEmissiveAsIllumination",void 0),Object(U.c)([Object(_.c)("linkEmissiveWithDiffuse")],ee.prototype,"_linkEmissiveWithDiffuse",void 0),Object(U.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"linkEmissiveWithDiffuse",void 0),Object(U.c)([Object(_.c)("useSpecularOverAlpha")],ee.prototype,"_useSpecularOverAlpha",void 0),Object(U.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"useSpecularOverAlpha",void 0),Object(U.c)([Object(_.c)("useReflectionOverAlpha")],ee.prototype,"_useReflectionOverAlpha",void 0),Object(U.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"useReflectionOverAlpha",void 0),Object(U.c)([Object(_.c)("disableLighting")],ee.prototype,"_disableLighting",void 0),Object(U.c)([Object(_.b)("_markAllSubMeshesAsLightsDirty")],ee.prototype,"disableLighting",void 0),Object(U.c)([Object(_.c)("useObjectSpaceNormalMap")],ee.prototype,"_useObjectSpaceNormalMap",void 0),Object(U.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"useObjectSpaceNormalMap",void 0),Object(U.c)([Object(_.c)("useParallax")],ee.prototype,"_useParallax",void 0),Object(U.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"useParallax",void 0),Object(U.c)([Object(_.c)("useParallaxOcclusion")],ee.prototype,"_useParallaxOcclusion",void 0),Object(U.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"useParallaxOcclusion",void 0),Object(U.c)([Object(_.c)()],ee.prototype,"parallaxScaleBias",void 0),Object(U.c)([Object(_.c)("roughness")],ee.prototype,"_roughness",void 0),Object(U.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"roughness",void 0),Object(U.c)([Object(_.c)()],ee.prototype,"indexOfRefraction",void 0),Object(U.c)([Object(_.c)()],ee.prototype,"invertRefractionY",void 0),Object(U.c)([Object(_.c)()],ee.prototype,"alphaCutOff",void 0),Object(U.c)([Object(_.c)("useLightmapAsShadowmap")],ee.prototype,"_useLightmapAsShadowmap",void 0),Object(U.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"useLightmapAsShadowmap",void 0),Object(U.c)([Object(_.h)("diffuseFresnelParameters")],ee.prototype,"_diffuseFresnelParameters",void 0),Object(U.c)([Object(_.b)("_markAllSubMeshesAsFresnelDirty")],ee.prototype,"diffuseFresnelParameters",void 0),Object(U.c)([Object(_.h)("opacityFresnelParameters")],ee.prototype,"_opacityFresnelParameters",void 0),Object(U.c)([Object(_.b)("_markAllSubMeshesAsFresnelAndMiscDirty")],ee.prototype,"opacityFresnelParameters",void 0),Object(U.c)([Object(_.h)("reflectionFresnelParameters")],ee.prototype,"_reflectionFresnelParameters",void 0),Object(U.c)([Object(_.b)("_markAllSubMeshesAsFresnelDirty")],ee.prototype,"reflectionFresnelParameters",void 0),Object(U.c)([Object(_.h)("refractionFresnelParameters")],ee.prototype,"_refractionFresnelParameters",void 0),Object(U.c)([Object(_.b)("_markAllSubMeshesAsFresnelDirty")],ee.prototype,"refractionFresnelParameters",void 0),Object(U.c)([Object(_.h)("emissiveFresnelParameters")],ee.prototype,"_emissiveFresnelParameters",void 0),Object(U.c)([Object(_.b)("_markAllSubMeshesAsFresnelDirty")],ee.prototype,"emissiveFresnelParameters",void 0),Object(U.c)([Object(_.c)("useReflectionFresnelFromSpecular")],ee.prototype,"_useReflectionFresnelFromSpecular",void 0),Object(U.c)([Object(_.b)("_markAllSubMeshesAsFresnelDirty")],ee.prototype,"useReflectionFresnelFromSpecular",void 0),Object(U.c)([Object(_.c)("useGlossinessFromSpecularMapAlpha")],ee.prototype,"_useGlossinessFromSpecularMapAlpha",void 0),Object(U.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"useGlossinessFromSpecularMapAlpha",void 0),Object(U.c)([Object(_.c)("maxSimultaneousLights")],ee.prototype,"_maxSimultaneousLights",void 0),Object(U.c)([Object(_.b)("_markAllSubMeshesAsLightsDirty")],ee.prototype,"maxSimultaneousLights",void 0),Object(U.c)([Object(_.c)("invertNormalMapX")],ee.prototype,"_invertNormalMapX",void 0),Object(U.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"invertNormalMapX",void 0),Object(U.c)([Object(_.c)("invertNormalMapY")],ee.prototype,"_invertNormalMapY",void 0),Object(U.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"invertNormalMapY",void 0),Object(U.c)([Object(_.c)("twoSidedLighting")],ee.prototype,"_twoSidedLighting",void 0),Object(U.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"twoSidedLighting",void 0),Object(U.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(Me,y,f){f.d(y,"a",function(){return I});var U=f(1),_=f(12),C=f(6),u=f(0),M=f(13),R=f(4),x=f(16),m=f(46),c=f(54),T=f(43),A=f(2),S=f(147),g=f(21),l=f(101),h=f(9),v=f(28),E=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 X(j,ne){ne===void 0&&(ne=null);var te=V.call(this,j,ne,!1)||this;return te._internalAbstractMeshDataInfo=new N,te.cullingStrategy=X.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY,te.onCollideObservable=new C.c,te.onCollisionPositionChangeObservable=new C.c,te.onMaterialChangedObservable=new C.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 C.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)},te.getScene().addMesh(te),te._resyncLightSources(),te}return Object(U.d)(X,V),Object.defineProperty(X,"BILLBOARDMODE_NONE",{get:function(){return m.a.BILLBOARDMODE_NONE},enumerable:!1,configurable:!0}),Object.defineProperty(X,"BILLBOARDMODE_X",{get:function(){return m.a.BILLBOARDMODE_X},enumerable:!1,configurable:!0}),Object.defineProperty(X,"BILLBOARDMODE_Y",{get:function(){return m.a.BILLBOARDMODE_Y},enumerable:!1,configurable:!0}),Object.defineProperty(X,"BILLBOARDMODE_Z",{get:function(){return m.a.BILLBOARDMODE_Z},enumerable:!1,configurable:!0}),Object.defineProperty(X,"BILLBOARDMODE_ALL",{get:function(){return m.a.BILLBOARDMODE_ALL},enumerable:!1,configurable:!0}),Object.defineProperty(X,"BILLBOARDMODE_USE_POSITION",{get:function(){return m.a.BILLBOARDMODE_USE_POSITION},enumerable:!1,configurable:!0}),Object.defineProperty(X.prototype,"facetNb",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetNb},enumerable:!1,configurable:!0}),Object.defineProperty(X.prototype,"partitioningSubdivisions",{get:function(){return this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions},set:function(j){this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions=j},enumerable:!1,configurable:!0}),Object.defineProperty(X.prototype,"partitioningBBoxRatio",{get:function(){return this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio},set:function(j){this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio=j},enumerable:!1,configurable:!0}),Object.defineProperty(X.prototype,"mustDepthSortFacets",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetDepthSort},set:function(j){this._internalAbstractMeshDataInfo._facetData.facetDepthSort=j},enumerable:!1,configurable:!0}),Object.defineProperty(X.prototype,"facetDepthSortFrom",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom},set:function(j){this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom=j},enumerable:!1,configurable:!0}),Object.defineProperty(X.prototype,"isFacetDataEnabled",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetDataEnabled},enumerable:!1,configurable:!0}),X.prototype._updateNonUniformScalingState=function(j){return!!V.prototype._updateNonUniformScalingState.call(this,j)&&(this._markSubMeshesAsMiscDirty(),!0)},Object.defineProperty(X.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(X.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(X.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(X.prototype,"renderingGroupId",{get:function(){return this._renderingGroupId},set:function(j){this._renderingGroupId=j},enumerable:!1,configurable:!0}),Object.defineProperty(X.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(X.prototype,"receiveShadows",{get:function(){return this._internalAbstractMeshDataInfo._receiveShadows},set:function(j){this._internalAbstractMeshDataInfo._receiveShadows!==j&&(this._internalAbstractMeshDataInfo._receiveShadows=j,this._markSubMeshesAsLightDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(X.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(X.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(X.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(X.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(X.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(X.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(X.prototype,"collisionMask",{get:function(){return this._meshCollisionData._collisionMask},set:function(j){this._meshCollisionData._collisionMask=isNaN(j)?-1:j},enumerable:!1,configurable:!0}),Object.defineProperty(X.prototype,"collisionResponse",{get:function(){return this._meshCollisionData._collisionResponse},set:function(j){this._meshCollisionData._collisionResponse=j},enumerable:!1,configurable:!0}),Object.defineProperty(X.prototype,"collisionGroup",{get:function(){return this._meshCollisionData._collisionGroup},set:function(j){this._meshCollisionData._collisionGroup=isNaN(j)?-1:j},enumerable:!1,configurable:!0}),Object.defineProperty(X.prototype,"surroundingMeshes",{get:function(){return this._meshCollisionData._surroundingMeshes},set:function(j){this._meshCollisionData._surroundingMeshes=j},enumerable:!1,configurable:!0}),Object.defineProperty(X.prototype,"lightSources",{get:function(){return this._lightSources},enumerable:!1,configurable:!0}),Object.defineProperty(X.prototype,"_positions",{get:function(){return null},enumerable:!1,configurable:!0}),Object.defineProperty(X.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}),X.prototype.getClassName=function(){return"AbstractMesh"},X.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},X.prototype._getEffectiveParent=function(){return this._masterMesh&&this.billboardMode!==m.a.BILLBOARDMODE_NONE?this._masterMesh:V.prototype._getEffectiveParent.call(this)},X.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},X.prototype._rebuild=function(){if(this.onRebuildObservable.notifyObservers(this),this._occlusionQuery&&(this._occlusionQuery=null),this.subMeshes)for(var j=0,ne=this.subMeshes;j4,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;oe0&&(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},X.prototype._updateBoundingInfo=function(){var j=this._effectiveMesh;return this._boundingInfo?this._boundingInfo.update(j.worldMatrixFromCache):this._boundingInfo=new T.a(this.absolutePosition,this.absolutePosition,j.worldMatrixFromCache),this._updateSubMeshesBoundingInfo(j.worldMatrixFromCache),this},X.prototype._updateSubMeshesBoundingInfo=function(j){if(!this.subMeshes)return this;for(var ne=this.subMeshes.length,te=0;te1||!de.IsGlobal)&&de.updateBoundingInfo(j)}return this},X.prototype._afterComputeWorldMatrix=function(){this.doNotSyncBoundingInfo||this._updateBoundingInfo()},Object.defineProperty(X.prototype,"_effectiveMesh",{get:function(){return this.skeleton&&this.skeleton.overrideMesh||this},enumerable:!1,configurable:!0}),X.prototype.isInFrustum=function(j){return this._boundingInfo!==null&&this._boundingInfo.isInFrustum(j,this.cullingStrategy)},X.prototype.isCompletelyInFrustum=function(j){return this._boundingInfo!==null&&this._boundingInfo.isCompletelyInFrustum(j)},X.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();de1&&!ae._checkCollision(j)||this._collideForSubMesh(ae,ne,j)}return this},X.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},X.prototype._generatePointsArray=function(){return!1},X.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;Y1)||H.canIntersects(j)){var Z=H.intersects(j,this._positions,this.getIndices(),ne,te);if(Z&&(ne||!G||Z.distance65535){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;$v.a?pe.maximum.x-pe.minimum.x:v.a,j.bbSize.y=pe.maximum.y-pe.minimum.y>v.a?pe.maximum.y-pe.minimum.y:v.a,j.bbSize.z=pe.maximum.z-pe.minimum.z>v.a?pe.maximum.z-pe.minimum.z:v.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,x.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;$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]},X.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},X.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 W,q,he,ge=Number.MAX_VALUE,me=ge,_e=0;_e=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)-te)*L)100&&(this.soft=!0),this._physicsEngine=this._scene.getPhysicsEngine(),this._physicsEngine?(this.object.rotationQuaternion||(this.object.rotation?this.object.rotationQuaternion=C.b.RotationYawPitchRoll(this.object.rotation.y,this.object.rotation.x,this.object.rotation.z):this.object.rotationQuaternion=new C.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&&U.a.Warn("You must affect impostors to children before affecting impostor to parent.")):U.a.Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors."))):U.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(T){this.setMass(T)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"friction",{get:function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getBodyFriction(this):0},set:function(T){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyFriction(this,T)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"restitution",{get:function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this):0},set:function(T){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this,T)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"pressure",{get:function(){if(!this._physicsEngine)return 0;var T=this._physicsEngine.getPhysicsPlugin();return T.setBodyPressure?T.getBodyPressure(this):0},set:function(T){if(this._physicsEngine){var A=this._physicsEngine.getPhysicsPlugin();A.setBodyPressure&&A.setBodyPressure(this,T)}},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"stiffness",{get:function(){if(!this._physicsEngine)return 0;var T=this._physicsEngine.getPhysicsPlugin();return T.getBodyStiffness?T.getBodyStiffness(this):0},set:function(T){if(this._physicsEngine){var A=this._physicsEngine.getPhysicsPlugin();A.setBodyStiffness&&A.setBodyStiffness(this,T)}},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"velocityIterations",{get:function(){if(!this._physicsEngine)return 0;var T=this._physicsEngine.getPhysicsPlugin();return T.getBodyVelocityIterations?T.getBodyVelocityIterations(this):0},set:function(T){if(this._physicsEngine){var A=this._physicsEngine.getPhysicsPlugin();A.setBodyVelocityIterations&&A.setBodyVelocityIterations(this,T)}},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"positionIterations",{get:function(){if(!this._physicsEngine)return 0;var T=this._physicsEngine.getPhysicsPlugin();return T.getBodyPositionIterations?T.getBodyPositionIterations(this):0},set:function(T){if(this._physicsEngine){var A=this._physicsEngine.getPhysicsPlugin();A.setBodyPositionIterations&&A.setBodyPositionIterations(this,T)}},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(T){this._physicsBody&&this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this),this._physicsBody=T,this.resetUpdateFlags()},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"parent",{get:function(){return!this._options.ignoreParent&&this._parent?this._parent:null},set:function(T){this._parent=T},enumerable:!1,configurable:!0}),c.prototype.resetUpdateFlags=function(){this._bodyUpdateRequired=!1},c.prototype.getObjectExtendSize=function(){if(this.object.getBoundingInfo){var T=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=T,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(T){return this._options[T]},c.prototype.setParam=function(T,A){this._options[T]=A,this._bodyUpdateRequired=!0},c.prototype.setMass=function(T){this.getParam("mass")!==T&&this.setParam("mass",T),this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyMass(this,T)},c.prototype.getLinearVelocity=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this):C.e.Zero()},c.prototype.setLinearVelocity=function(T){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this,T)},c.prototype.getAngularVelocity=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this):C.e.Zero()},c.prototype.setAngularVelocity=function(T){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this,T)},c.prototype.executeNativeFunction=function(T){this._physicsEngine&&T(this._physicsEngine.getPhysicsPlugin().world,this.physicsBody)},c.prototype.registerBeforePhysicsStep=function(T){this._onBeforePhysicsStepCallbacks.push(T)},c.prototype.unregisterBeforePhysicsStep=function(T){var A=this._onBeforePhysicsStepCallbacks.indexOf(T);A>-1?this._onBeforePhysicsStepCallbacks.splice(A,1):U.a.Warn("Function to remove was not found")},c.prototype.registerAfterPhysicsStep=function(T){this._onAfterPhysicsStepCallbacks.push(T)},c.prototype.unregisterAfterPhysicsStep=function(T){var A=this._onAfterPhysicsStepCallbacks.indexOf(T);A>-1?this._onAfterPhysicsStepCallbacks.splice(A,1):U.a.Warn("Function to remove was not found")},c.prototype.registerOnPhysicsCollide=function(T,A){var S=T instanceof Array?T:[T];this._onPhysicsCollideCallbacks.push({callback:A,otherImpostors:S})},c.prototype.unregisterOnPhysicsCollide=function(T,A){var S=T instanceof Array?T:[T],g=-1;this._onPhysicsCollideCallbacks.some(function(l,h){if(l.callback===A&&l.otherImpostors.length===S.length){var v=l.otherImpostors.every(function(E){return S.indexOf(E)>-1});return v&&(g=h),v}return!1})?this._onPhysicsCollideCallbacks.splice(g,1):U.a.Warn("Function to remove was not found")},c.prototype.getParentsRotation=function(){var T=this.object.parent;for(this._tmpQuat.copyFromFloats(0,0,0,1);T;)T.rotationQuaternion?this._tmpQuat2.copyFrom(T.rotationQuaternion):C.b.RotationYawPitchRollToRef(T.rotation.y,T.rotation.x,T.rotation.z,this._tmpQuat2),this._tmpQuat.multiplyToRef(this._tmpQuat2,this._tmpQuat),T=T.parent;return this._tmpQuat},c.prototype.applyForce=function(T,A){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().applyForce(this,T,A),this},c.prototype.applyImpulse=function(T,A){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().applyImpulse(this,T,A),this},c.prototype.createJoint=function(T,A,S){var g=new R.e(A,S);return this.addJoint(T,g),this},c.prototype.addJoint=function(T,A){return this._joints.push({otherImpostor:T,joint:A}),this._physicsEngine&&this._physicsEngine.addJoint(this,T,A),this},c.prototype.addAnchor=function(T,A,S,g,l){if(!this._physicsEngine)return this;var h=this._physicsEngine.getPhysicsPlugin();return h.appendAnchor?(this._physicsEngine&&h.appendAnchor(this,T,A,S,g,l),this):this},c.prototype.addHook=function(T,A,S,g){if(!this._physicsEngine)return this;var l=this._physicsEngine.getPhysicsPlugin();return l.appendAnchor?(this._physicsEngine&&l.appendHook(this,T,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(T){return T?new c(T,this.type,this._options,this._scene):null},c.prototype.dispose=function(){var T=this;this._physicsEngine&&(this._joints.forEach(function(A){T._physicsEngine&&T._physicsEngine.removeJoint(T,A.otherImpostor,A.joint)}),this._physicsEngine.removeImpostor(this),this.parent&&this.parent.forceUpdate(),this._isDisposed=!0)},c.prototype.setDeltaPosition=function(T){this._deltaPosition.copyFrom(T)},c.prototype.setDeltaRotation=function(T){this._deltaRotation||(this._deltaRotation=new C.b),this._deltaRotation.copyFrom(T),this._deltaRotationConjugated=this._deltaRotation.conjugate()},c.prototype.getBoxSizeToRef=function(T){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this,T),this},c.prototype.getRadius=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getRadius(this):0},c.prototype.syncBoneWithImpostor=function(T,A,S,g,l){var h=c._tmpVecs[0],v=this.object;if(v.rotationQuaternion)if(l){var E=c._tmpQuat;v.rotationQuaternion.multiplyToRef(l,E),T.setRotationQuaternion(E,x.c.WORLD,A)}else T.setRotationQuaternion(v.rotationQuaternion,x.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,T.getDirectionToRef(h,A,h),g==null&&(g=S.length()),h.x*=g,h.y*=g,h.z*=g),T.getParent()?(h.addInPlace(v.getAbsolutePosition()),T.setAbsolutePosition(h,A)):(A.setAbsolutePosition(v.getAbsolutePosition()),A.position.x-=h.x,A.position.y-=h.y,A.position.z-=h.z)},c.prototype.syncImpostorWithBone=function(T,A,S,g,l,h){var v=this.object;if(v.rotationQuaternion)if(l){var E=c._tmpQuat;T.getRotationQuaternionToRef(x.c.WORLD,A,E),E.multiplyToRef(l,v.rotationQuaternion)}else T.getRotationQuaternionToRef(x.c.WORLD,A,v.rotationQuaternion);var D=c._tmpVecs[0],w=c._tmpVecs[1];h||((h=c._tmpVecs[2]).x=0,h.y=1,h.z=0),T.getDirectionToRef(h,A,w),T.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),v.setAbsolutePosition(D)},c.DEFAULT_OBJECT_SIZE=new C.e(1,1,1),c.IDENTITY_QUATERNION=C.b.Identity(),c._tmpVecs=_.a.BuildArray(3,C.e.Zero),c._tmpQuat=C.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(Me,y,f){f.d(y,"a",function(){return _}),f.d(y,"b",function(){return C});var U=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;Rthis.data.length&&(this.data.length=2*(this.length+M.length));for(var R=0;R=this.length?-1:R},u.prototype.contains=function(M){return this.indexOf(M)!==-1},u._GlobalId=0,u}(),C=function(u){function M(){var R=u!==null&&u.apply(this,arguments)||this;return R._duplicateId=0,R}return Object(U.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 x=0;x>2,m=(3&u)<<4|(M=g>4,c=(15&M)<<2|(R=g>6,T=63&R,isNaN(M)?c=T=64:isNaN(R)&&(T=64),S+=A.charAt(x)+A.charAt(m)+A.charAt(c)+A.charAt(T);return S},_.PadNumber=function(C,u){for(var M=String(C);M.length0)):!S._pointerCaptures[D.pointerId]&&v.distance>E.distance&&(S.mainSceneTrackerPredicate&&S.mainSceneTrackerPredicate(E.pickedMesh)?(S._notifyObservers(g,E,D),g.skipOnPointerObservable=!0):S._lastPointerEvents[D.pointerId]&&(S.onPointerOutObservable.notifyObservers(D.pointerId),delete S._lastPointerEvents[D.pointerId])),g.type===C.a.POINTERUP&&S._pointerCaptures[D.pointerId]&&(S._pointerCaptures[D.pointerId]=!1))}}}}),this._originalPointerObserver&&T.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(T){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,T&&A&&A.isRigCamera?A.rigParent:A},c.prototype.setRenderCamera=function(T){this._renderCamera=T},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=x.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(T,A,S){T.skipOnPointerObservable||(this.utilityLayerScene.onPointerObservable.notifyObservers(new C.b(T.type,T.event,A),T.type),this._lastPointerEvents[S.pointerId]=!0)},c.prototype.render=function(){if(this._updateCamera(),this.utilityLayerScene.activeCamera){var T=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=T,A.leftCamera&&(A.leftCamera._scene=T),A.rightCamera&&(A.rightCamera._scene=T)}},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(Me,y,f){f.d(y,"a",function(){return _});var U=f(139),_=function(){function C(){}return C.EnableFor=function(u){u._tags=u._tags||{},u.hasTags=function(){return C.HasTags(u)},u.addTags=function(M){return C.AddTagsTo(u,M)},u.removeTags=function(M){return C.RemoveTagsFrom(u,M)},u.matchesTagsQuery=function(M){return C.MatchesQuery(u,M)}},C.DisableFor=function(u){delete u._tags,delete u.hasTags,delete u.addTags,delete u.removeTags,delete u.matchesTagsQuery},C.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},C.GetTags=function(u,M){if(M===void 0&&(M=!0),!u._tags)return null;if(M){var R=[];for(var x in u._tags)u._tags.hasOwnProperty(x)&&u._tags[x]===!0&&R.push(x);return R.join(" ")}return u._tags},C.AddTagsTo=function(u,M){M&&typeof M=="string"&&M.split(" ").forEach(function(R,x,m){C._AddTagTo(u,R)})},C._AddTagTo=function(u,M){(M=M.trim())!==""&&M!=="true"&&M!=="false"&&(M.match(/[\s]/)||M.match(/^([!]|([|]|[&]){2})/)||(C.EnableFor(u),u._tags[M]=!0))},C.RemoveTagsFrom=function(u,M){if(C.HasTags(u)){var R=M.split(" ");for(var x in R)C._RemoveTagFrom(u,R[x])}},C._RemoveTagFrom=function(u,M){delete u._tags[M]},C.MatchesQuery=function(u,M){return M===void 0||(M===""?C.HasTags(u):U.a.Eval(M,function(R){return C.HasTags(u)&&u._tags[R]}))},C}()},function(Me,y,f){f.d(y,"a",function(){return U});var U=function(){function _(){}return _.IsWindowObjectExist=function(){return typeof window<"u"},_.IsNavigatorAvailable=function(){return typeof navigator<"u"},_.IsDocumentAvailable=function(){return typeof document<"u"},_.GetDOMTextContent=function(C){for(var u="",M=C.firstChild;M;)M.nodeType===3&&(u+=M.textContent),M=M.nextSibling;return u},_}()},function(Me,y,f){f.d(y,"a",function(){return x});var U=f(44),_=f(0),C=f(54),u=f(114),M=f(20),R=f(24),x=function(){function m(c,T,A){A===void 0&&(A=Number.MAX_VALUE),this.origin=c,this.direction=T,this.length=A}return m.prototype.intersectsBoxMinMax=function(c,T,A){A===void 0&&(A=0);var S,g,l,h,v=m._TmpVector3[0].copyFromFloats(c.x-A,c.y-A,c.z-A),E=m._TmpVector3[1].copyFromFloats(T.x+A,T.y+A,T.z+A),D=0,w=Number.MAX_VALUE;if(Math.abs(this.direction.x)<1e-7){if(this.origin.xE.x)return!1}else if(S=1/this.direction.x,g=(v.x-this.origin.x)*S,(l=(E.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.yE.y)return!1}else if(S=1/this.direction.y,g=(v.y-this.origin.y)*S,(l=(E.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.zE.z)return!1}else if(S=1/this.direction.z,g=(v.z-this.origin.z)*S,(l=(E.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,T){return T===void 0&&(T=0),this.intersectsBoxMinMax(c.minimum,c.maximum,T)},m.prototype.intersectsSphere=function(c,T){T===void 0&&(T=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+T,v=h*h;if(l<=v)return!0;var E=A*this.direction.x+S*this.direction.y+g*this.direction.z;return!(E<0)&&l-E*E<=v},m.prototype.intersectsTriangle=function(c,T,A){var S=m._TmpVector3[0],g=m._TmpVector3[1],l=m._TmpVector3[2],h=m._TmpVector3[3],v=m._TmpVector3[4];T.subtractToRef(c,S),A.subtractToRef(c,g),_.e.CrossToRef(this.direction,g,l);var E=_.e.Dot(S,l);if(E===0)return null;var D=1/E;this.origin.subtractToRef(c,h);var w=_.e.Dot(h,l)*D;if(w<0||w>1)return null;_.e.CrossToRef(h,S,v);var N=_.e.Dot(this.direction,v)*D;if(N<0||w+N>1)return null;var I=_.e.Dot(g,v)*D;return I>this.length?null:new u.a(1-w-N,w,I)},m.prototype.intersectsPlane=function(c){var T,A=_.e.Dot(c.normal,this.direction);if(Math.abs(A)<999999997475243e-21)return null;var S=_.e.Dot(c.normal,this.origin);return(T=(-c.d-S)/A)<0?T<-999999997475243e-21?null:0:T},m.prototype.intersectsAxis=function(c,T){switch(T===void 0&&(T=0),c){case"y":return(A=(this.origin.y-T)/this.direction.y)>0?null:new _.e(this.origin.x+this.direction.x*-A,T,this.origin.z+this.direction.z*-A);case"x":return(A=(this.origin.x-T)/this.direction.x)>0?null:new _.e(T,this.origin.y+this.direction.y*-A,this.origin.z+this.direction.z*-A);case"z":var A;return(A=(this.origin.z-T)/this.direction.z)>0?null:new _.e(this.origin.x+this.direction.x*-A,this.origin.y+this.direction.y*-A,T);default:return null}},m.prototype.intersectsMesh=function(c,T){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,T)},m.prototype.intersectsMeshes=function(c,T,A){A?A.length=0:A=[];for(var S=0;ST.distance?1:0},m.prototype.intersectionSegment=function(c,T,A){var S=this.origin,g=_.c.Vector3[0],l=_.c.Vector3[1],h=_.c.Vector3[2],v=_.c.Vector3[3];T.subtractToRef(c,g),this.direction.scaleToRef(m.rayl,h),S.addToRef(h,l),c.subtractToRef(S,v);var E,D,w,N,I=_.e.Dot(g,g),V=_.e.Dot(g,h),X=_.e.Dot(h,h),j=_.e.Dot(g,v),ne=_.e.Dot(h,v),te=I*X-V*V,de=te,pe=te;tede&&(D=de,N=ne+V,pe=X)),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)),E=Math.abs(D)0&&w<=this.length&&K.lengthSquared()=m.distance?null:E:null},M.a.prototype._internalPick=function(m,c,T,A,S){if(!C.a)return null;for(var g=null,l=0;l0&&(m.push(g-1),m.push(g)),g++}var D=new C.a;return D.indices=m,D.positions=c,A&&(D.colors=S),D},C.a.CreateDashedLines=function(x){var m,c,T=x.dashSize||3,A=x.gapSize||1,S=x.dashNb||200,g=x.points,l=new Array,h=new Array,v=U.e.Zero(),E=0,D=0,w=0,N=0,I=0;for(I=0;I0)if(typeof g[0]=="object")for(var h=0;hx.max||x.min>R.max)},T=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=C.a.MESHES_CULLINGSTRATEGY_STANDARD),!(g!==C.a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION&&g!==C.a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY||!this.boundingSphere.isCenterInFrustum(S))||!!this.boundingSphere.isInFrustum(S)&&(!(g!==C.a.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY&&g!==C.a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY)||this.boundingBox.isInFrustum(S))},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=U.a.BuildArray(2,_.e.Zero),A}()},function(Me,y,f){f.d(y,"a",function(){return U});var U=function(){function _(){}return _.BuildArray=function(C,u){for(var M=[],R=0;R1)?1:M.arc||1,A=M.slice&&M.slice<=0?1:M.slice||1,S=M.sideOrientation===0?0:M.sideOrientation||C.a.DEFAULTSIDE,g=!!M.dedupTopBottomIndices,l=new U.e(x/2,m/2,c/2),h=2+R,v=2*h,E=[],D=[],w=[],N=[],I=0;I<=h;I++){for(var V=I/h,X=V*Math.PI*A,j=0;j<=v;j++){var ne=j/v,te=ne*Math.PI*2*T,de=U.a.RotationZ(-X),pe=U.a.RotationY(te),ae=U.e.TransformCoordinates(U.e.Up(),de),ee=U.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*(v+1);G+v+21&&(E.push(G),E.push(G+1),E.push(G+v+1)),(I0&&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)},T.CompareLightsPriority=function(A,S){return A.shadowEnabled!==S.shadowEnabled?(S.shadowEnabled?1:0)-(A.shadowEnabled?1:0):S.renderPriority-A.renderPriority},T.prototype.dispose=function(A,S){S===void 0&&(S=!1),this._shadowGenerator&&(this._shadowGenerator.dispose(),this._shadowGenerator=null),this.getScene().stopAnimation(this);for(var g=0,l=this.getScene().meshes;g0&&(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},T.GetConstructorFromName=function(A,S,g){var l=M.a.Construct("Light_Type_"+A,S,g);return l||null},T.Parse=function(A,S){var g=T.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=0&&this._scene.textures.splice(S,1),this._scene.onTextureRemovedObservable.notifyObservers(this),this._scene=null}this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),T.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;h1)?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&&v?2:0))*(h?l:1);for(S=0;S1e3&&(this._lastSecAverage=this._lastSecAccumulated/this._lastSecValueCount,this._lastSecTime=u,this._lastSecAccumulated=0,this._lastSecValueCount=0)},C.Enabled=!0,C}()},function(Me,y,f){f.d(y,"b",function(){return A}),f.d(y,"d",function(){return S}),f.d(y,"c",function(){return g}),f.d(y,"a",function(){return l});var U=f(1),_=f(49),C=f(38),u=f(6),M=f(83),R=f(140),x=function(h){function v(){return h!==null&&h.apply(this,arguments)||this}return Object(U.d)(v,h),v._setPrototypeOf=Object.setPrototypeOf||function(E,D){return E.__proto__=D,E},v}(Error),m=f(34),c=f(26),T=f(128),A=function(h){function v(E,D){var w=h.call(this,E)||this;return w.name="LoadFileError",x._setPrototypeOf(w,v.prototype),D instanceof _.a?w.request=D:w.file=D,w}return Object(U.d)(v,h),v}(x),S=function(h){function v(E,D){var w=h.call(this,E)||this;return w.request=D,w.name="RequestFileError",x._setPrototypeOf(w,v.prototype),w}return Object(U.d)(v,h),v}(x),g=function(h){function v(E,D){var w=h.call(this,E)||this;return w.file=D,w.name="ReadFileError",x._setPrototypeOf(w,v.prototype),w}return Object(U.d)(v,h),v}(x),l=function(){function h(){}return h._CleanUrl=function(v){return v=v.replace(/#/gm,"%23")},h.SetCorsBehavior=function(v,E){if((!v||v.indexOf("data:")!==0)&&h.CorsBehavior)if(typeof h.CorsBehavior=="string"||this.CorsBehavior instanceof String)E.crossOrigin=h.CorsBehavior;else{var D=h.CorsBehavior(v);D&&(E.crossOrigin=D)}},h.LoadImage=function(v,E,D,w,N){var I;N===void 0&&(N="");var V=!1;if(v instanceof ArrayBuffer||ArrayBuffer.isView(v)?typeof Blob<"u"?(I=URL.createObjectURL(new Blob([v],{type:N})),V=!0):I="data:"+N+";base64,"+m.a.EncodeArrayBufferToBase64(v):v instanceof Blob?(I=URL.createObjectURL(v),V=!0):(I=h._CleanUrl(v),I=h.PreprocessUrl(v)),typeof Image>"u")return h.LoadFile(I,function(ae){createImageBitmap(new Blob([ae],{type:N})).then(function(ee){E(ee),V&&URL.revokeObjectURL(I)}).catch(function(ee){D&&D("Error while trying to load image: "+v,ee)})},void 0,w||void 0,!0,function(ae,ee){D&&D("Error while trying to load image: "+v,ee)}),null;var X=new Image;h.SetCorsBehavior(I,X);var j=function(){X.removeEventListener("load",j),X.removeEventListener("error",ne),E(X),V&&X.src&&URL.revokeObjectURL(X.src)},ne=function(ae){if(X.removeEventListener("load",j),X.removeEventListener("error",ne),D){var ee=v.toString();D("Error while trying to load image: "+(ee.length<32?ee:ee.slice(0,32)+"..."),ae)}V&&X.src&&URL.revokeObjectURL(X.src)};X.addEventListener("load",j),X.addEventListener("error",ne);var te=function(){X.src=I};if(I.substr(0,5)!=="data:"&&w&&w.enableTexturesOffline)w.open(function(){w&&w.loadImage(I,X)},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])}X.src=pe,V=!0}catch{X.src=""}return X}}te()}return X},h.ReadFile=function(v,E,D,w,N){var I=new FileReader,V={onCompleteObservable:new u.c,abort:function(){return I.abort()}};return I.onloadend=function(X){return V.onCompleteObservable.notifyObservers(V)},N&&(I.onerror=function(X){N(new g("Unable to read "+v.name,v))}),I.onload=function(X){E(X.target.result)},D&&(I.onprogress=D),w?I.readAsArrayBuffer(v):I.readAsText(v),V},h.LoadFile=function(v,E,D,w,N,I){if(v.indexOf("file:")!==-1){var V=decodeURIComponent(v.substring(5).toLowerCase());V.indexOf("./")===0&&(V=V.substring(2));var X=M.a.FilesToLoad[V];if(X)return h.ReadFile(X,E,D,N,I?function(j){return I(void 0,new A(j.message,j.file))}:void 0)}return h.RequestFile(v,function(j,ne){E(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(v,E,D,w,N,I,V){v=h._CleanUrl(v),v=h.PreprocessUrl(v);var X=h.BaseUrl+v,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",X),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&&(!C.a.IsWindowObjectExist()||h.IsFileURL()))return void E(N?pe.response:pe.responseText,pe);var G=h.DefaultRetryStrategy;if(G){var Q=G(X,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 "+X,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+v,function(pe){j||E(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(v){return v},h}();c.a._FileToolsLoadImage=l.LoadImage.bind(l),c.a._FileToolsLoadFile=l.LoadFile.bind(l),T.a._FileToolsLoadFile=l.LoadFile.bind(l)},function(Me,y,f){f.d(y,"a",function(){return _});var U=f(38),_=function(){function C(){}return Object.defineProperty(C,"Now",{get:function(){return U.a.IsWindowObjectExist()&&window.performance&&window.performance.now?window.performance.now():Date.now()},enumerable:!1,configurable:!0}),C}()},function(Me,y,f){f.d(y,"a",function(){return U});var U=function(){function _(C,u,M,R){this.x=C,this.y=u,this.width=M,this.height=R}return _.prototype.toGlobal=function(C,u){return new _(this.x*C,this.y*u,this.width*C,this.height*u)},_.prototype.toGlobalToRef=function(C,u,M){return M.x=this.x*C,M.y=this.y*u,M.width=this.width*C,M.height=this.height*u,this},_.prototype.clone=function(){return new _(this.x,this.y,this.width,this.height)},_}()},function(Me,y,f){var U="helperFunctions",_=`const float PI=3.1415926535897932384626433832795; +const float HALF_MIN=5.96046448e-08; +const float LinearEncodePowerApprox=2.2; +const float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox; +const vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722); +const float Epsilon=0.0000001; +#define saturate(x) clamp(x,0.0,1.0) +#define absEps(x) abs(x)+Epsilon +#define maxEps(x) max(x,Epsilon) +#define saturateEps(x) clamp(x,Epsilon,1.0) +mat3 transposeMat3(mat3 inMatrix) { +vec3 i0=inMatrix[0]; +vec3 i1=inMatrix[1]; +vec3 i2=inMatrix[2]; +mat3 outMatrix=mat3( +vec3(i0.x,i1.x,i2.x), +vec3(i0.y,i1.y,i2.y), +vec3(i0.z,i1.z,i2.z) +); +return outMatrix; +} + +mat3 inverseMat3(mat3 inMatrix) { +float a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2]; +float a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2]; +float a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2]; +float b01=a22*a11-a12*a21; +float b11=-a22*a10+a12*a20; +float b21=a21*a10-a11*a20; +float det=a00*b01+a01*b11+a02*b21; +return mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11), +b11,(a22*a00-a02*a20),(-a12*a00+a02*a10), +b21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det; +} +float toLinearSpace(float color) +{ +return pow(color,LinearEncodePowerApprox); +} +vec3 toLinearSpace(vec3 color) +{ +return pow(color,vec3(LinearEncodePowerApprox)); +} +vec4 toLinearSpace(vec4 color) +{ +return vec4(pow(color.rgb,vec3(LinearEncodePowerApprox)),color.a); +} +vec3 toGammaSpace(vec3 color) +{ +return pow(color,vec3(GammaEncodePowerApprox)); +} +vec4 toGammaSpace(vec4 color) +{ +return vec4(pow(color.rgb,vec3(GammaEncodePowerApprox)),color.a); +} +float toGammaSpace(float color) +{ +return pow(color,GammaEncodePowerApprox); +} +float square(float value) +{ +return value*value; +} +float pow5(float value) { +float sq=value*value; +return sq*sq*value; +} +float getLuminance(vec3 color) +{ +return clamp(dot(color,LuminanceEncodeApprox),0.,1.); +} + +float getRand(vec2 seed) { +return fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453); +} +float dither(vec2 seed,float varianceAmount) { +float rand=getRand(seed); +float dither=mix(-varianceAmount/255.0,varianceAmount/255.0,rand); +return dither; +} + +const float rgbdMaxRange=255.0; +vec4 toRGBD(vec3 color) { +float maxRGB=maxEps(max(color.r,max(color.g,color.b))); +float D=max(rgbdMaxRange/maxRGB,1.); +D=clamp(floor(D)/255.0,0.,1.); + +vec3 rgb=color.rgb*D; + +rgb=toGammaSpace(rgb); +return vec4(rgb,D); +} +vec3 fromRGBD(vec4 rgbd) { + +rgbd.rgb=toLinearSpace(rgbd.rgb); + +return rgbd.rgb/rgbd.a; +} +`;f(5).a.IncludesShadersStore[U]=_},function(Me,y,f){f.d(y,"a",function(){return _});var U=f(0),_=function(){function C(){}return C._RemoveAndStorePivotPoint=function(u){u&&C._PivotCached===0&&(u.getPivotPointToRef(C._OldPivotPoint),C._PivotPostMultiplyPivotMatrix=u._postMultiplyPivotMatrix,C._OldPivotPoint.equalsToFloats(0,0,0)||(u.setPivotMatrix(U.a.IdentityReadOnly),C._OldPivotPoint.subtractToRef(u.getPivotPoint(),C._PivotTranslation),C._PivotTmpVector.copyFromFloats(1,1,1),C._PivotTmpVector.subtractInPlace(u.scaling),C._PivotTmpVector.multiplyInPlace(C._PivotTranslation),u.position.addInPlace(C._PivotTmpVector))),C._PivotCached++},C._RestorePivotPoint=function(u){u&&!C._OldPivotPoint.equalsToFloats(0,0,0)&&C._PivotCached===1&&(u.setPivotPoint(C._OldPivotPoint),u._postMultiplyPivotMatrix=C._PivotPostMultiplyPivotMatrix,C._PivotTmpVector.copyFromFloats(1,1,1),C._PivotTmpVector.subtractInPlace(u.scaling),C._PivotTmpVector.multiplyInPlace(C._PivotTranslation),u.position.subtractInPlace(C._PivotTmpVector)),this._PivotCached--},C._PivotCached=0,C._OldPivotPoint=new U.e,C._PivotTranslation=new U.e,C._PivotTmpVector=new U.e,C._PivotPostMultiplyPivotMatrix=!1,C}()},function(Me,y,f){f.d(y,"a",function(){return R});var U=f(4),_=f(114),C=f(43),u=f(2),M=f(101),R=function(){function x(m,c,T,A,S,g,l,h,v){h===void 0&&(h=!0),v===void 0&&(v=!0),this.materialIndex=m,this.verticesStart=c,this.verticesCount=T,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,v&&g.subMeshes.push(this),this._trianglePlanes=[],this._id=g.subMeshes.length-1,h&&(this.refreshBoundingInfo(),g.computeWorldMatrix(!0))}return Object.defineProperty(x.prototype,"materialDefines",{get:function(){return this._materialDefines},set:function(m){this._materialDefines=m},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"effect",{get:function(){var m;return(m=this._effectOverride)!==null&&m!==void 0?m:this._materialEffect},enumerable:!1,configurable:!0}),x.prototype.setEffect=function(m,c){c===void 0&&(c=null),this._materialEffect!==m?(this._materialDefines=c,this._materialEffect=m):m||(this._materialDefines=null)},x.AddToMesh=function(m,c,T,A,S,g,l,h){return h===void 0&&(h=!0),new x(m,c,T,A,S,g,l,h)},Object.defineProperty(x.prototype,"IsGlobal",{get:function(){return this.verticesStart===0&&this.verticesCount===this._mesh.getTotalVertices()},enumerable:!1,configurable:!0}),x.prototype.getBoundingInfo=function(){return this.IsGlobal?this._mesh.getBoundingInfo():this._boundingInfo},x.prototype.setBoundingInfo=function(m){return this._boundingInfo=m,this},x.prototype.getMesh=function(){return this._mesh},x.prototype.getRenderingMesh=function(){return this._renderingMesh},x.prototype.getReplacementMesh=function(){return this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:null},x.prototype.getEffectiveMesh=function(){var m=this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:null;return m||this._renderingMesh},x.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},x.prototype._IsMultiMaterial=function(m){return m.getSubMaterial!==void 0},x.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(U.b.PositionKind)),!m)return this._boundingInfo=this._mesh.getBoundingInfo(),this;var c,T=this._renderingMesh.getIndices();if(this.indexStart===0&&this.indexCount===T.length){var A=this._renderingMesh.getBoundingInfo();c={minimum:A.minimum.clone(),maximum:A.maximum.clone()}}else c=Object(M.b)(m,T,this.indexStart,this.indexCount,this._renderingMesh.geometry.boundingBias);return this._boundingInfo?this._boundingInfo.reConstruct(c.minimum,c.maximum):this._boundingInfo=new C.a(c.minimum,c.maximum),this},x.prototype._checkCollision=function(m){return this.getBoundingInfo()._checkCollision(m)},x.prototype.updateBoundingInfo=function(m){var c=this.getBoundingInfo();return c||(this.refreshBoundingInfo(),c=this.getBoundingInfo()),c&&c.update(m),this},x.prototype.isInFrustum=function(m){var c=this.getBoundingInfo();return!!c&&c.isInFrustum(m,this._mesh.cullingStrategy)},x.prototype.isCompletelyInFrustum=function(m){var c=this.getBoundingInfo();return!!c&&c.isCompletelyInFrustum(m)},x.prototype.render=function(m){return this._renderingMesh.render(this,m,this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:void 0),this},x.prototype._getLinesIndexBuffer=function(m,c){if(!this._linesIndexBuffer){for(var T=[],A=this.indexStart;Al&&(l=E)}return new x(m,g,l-g+1,c,T,A,S)},x}()},function(Me,y,f){f.d(y,"a",function(){return R});var U=f(1),_=f(8),C=f(10),u=f(2),M=(f(126),f(70)),R=function(x){function m(c,T,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);var v=x.call(this,null,A,!S,h,g,void 0,void 0,void 0,void 0,l)||this;v.name=c,v.wrapU=C.a.CLAMP_ADDRESSMODE,v.wrapV=C.a.CLAMP_ADDRESSMODE,v._generateMipMaps=S;var E=v._getEngine();if(!E)return v;T.getContext?(v._canvas=T,v._texture=E.createDynamicTexture(T.width,T.height,S,g)):(v._canvas=M.a.CreateCanvas(1,1),T.width||T.width===0?v._texture=E.createDynamicTexture(T.width,T.height,S,g):v._texture=E.createDynamicTexture(T,T,S,g));var D=v.getSize();return v._canvas.width=D.width,v._canvas.height=D.height,v._context=v._canvas.getContext("2d"),v}return Object(U.d)(m,x),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 T=this.getSize();T.width*=c,T.height*=c,this._recreate(T)},m.prototype.scaleTo=function(c,T){var A=this.getSize();A.width=c,A.height=T,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,T){T===void 0&&(T=!1),this._getEngine().updateDynamicTexture(this._texture,this._canvas,c===void 0||c,T,this._format||void 0)},m.prototype.drawText=function(c,T,A,S,g,l,h,v){v===void 0&&(v=!0);var E=this.getSize();if(l&&(this._context.fillStyle=l,this._context.fillRect(0,0,E.width,E.height)),this._context.font=S,T==null){var D=this._context.measureText(c);T=(E.width-D.width)/2}if(A==null){var w=parseInt(S.replace(/\D/g,""));A=E.height/2+w/3.65}this._context.fillStyle=g||"",this._context.fillText(c,T,A),v&&this.update(h)},m.prototype.clone=function(){var c=this.getScene();if(!c)return this;var T=this.getSize(),A=new m(this.name,T,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 T=x.prototype.serialize.call(this);return this._IsCanvasElement(this._canvas)&&(T.base64String=this._canvas.toDataURL()),T.invertY=this._invertY,T.samplingMode=this.samplingMode,T},m.prototype._IsCanvasElement=function(c){return c.toDataURL!==void 0},m.prototype._rebuild=function(){this.update()},m}(C.a)},function(Me,y,f){f.d(y,"a",function(){return M});var U=f(0),_=f(9),C=f(7),u=f(16);u.a.CreateBox=function(R){var x,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],T=[],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,v=R.bottomBaseAt===void 0?0:R.bottomBaseAt,E=[2,0,3,1][h=(h+4)%4],D=[2,0,1,3][v=(v+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],X=[22,23,20,21];E>0;)N.unshift(N.pop()),V.unshift(V.pop()),E--;for(;D>0;)I.unshift(I.pop()),X.unshift(X.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(X[0],X[2],X[3],X[0],X[1],X[2])}var j=[A/2,S/2,g/2];x=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 U.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(T.push(te[ee].z,te[ee].w),T.push(te[ee].x,te[ee].w),T.push(te[ee].x,te[ee].y),T.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,x,m,c,T,R.frontUVs,R.backUVs);var $=new u.a;if($.indices=m,$.positions=x,$.normals=c,$.uvs=T,de){var L=ne===u.a.DOUBLESIDE?pe.concat(pe):pe;$.colors=L}return $},C.a.CreateBox=function(R,x,m,c,T){m===void 0&&(m=null);var A={size:x,sideOrientation:T,updatable:c};return M.CreateBox(R,A,m)};var M=function(){function R(){}return R.CreateBox=function(x,m,c){c===void 0&&(c=null);var T=new C.a(x,c);return m.sideOrientation=C.a._GetDefaultSideOrientation(m.sideOrientation),T._originalBuilderSideOrientation=m.sideOrientation,u.a.CreateBox(m).applyToMesh(T,m.updatable),T},R}()},function(Me,y,f){f.d(y,"a",function(){return _});var U=f(0),_=function(){function C(u,M,R,x){this.normal=new U.e(u,M,R),this.d=x}return C.prototype.asArray=function(){return[this.normal.x,this.normal.y,this.normal.z,this.d]},C.prototype.clone=function(){return new C(this.normal.x,this.normal.y,this.normal.z,this.d)},C.prototype.getClassName=function(){return"Plane"},C.prototype.getHashCode=function(){var u=this.normal.getHashCode();return u=397*u^(0|this.d)},C.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},C.prototype.transform=function(u){var M=C._TmpMatrix;u.invertToRef(M);var R=M.m,x=this.normal.x,m=this.normal.y,c=this.normal.z,T=this.d;return new C(x*R[0]+m*R[1]+c*R[2]+T*R[3],x*R[4]+m*R[5]+c*R[6]+T*R[7],x*R[8]+m*R[9]+c*R[10]+T*R[11],x*R[12]+m*R[13]+c*R[14]+T*R[15])},C.prototype.dotCoordinate=function(u){return this.normal.x*u.x+this.normal.y*u.y+this.normal.z*u.z+this.d},C.prototype.copyFromPoints=function(u,M,R){var x,m=M.x-u.x,c=M.y-u.y,T=M.z-u.z,A=R.x-u.x,S=R.y-u.y,g=R.z-u.z,l=c*g-T*S,h=T*A-m*g,v=m*S-c*A,E=Math.sqrt(l*l+h*h+v*v);return x=E!==0?1/E:0,this.normal.x=l*x,this.normal.y=h*x,this.normal.z=v*x,this.d=-(this.normal.x*u.x+this.normal.y*u.y+this.normal.z*u.z),this},C.prototype.isFrontFacingTo=function(u,M){return U.e.Dot(this.normal,u)<=M},C.prototype.signedDistanceTo=function(u){return U.e.Dot(u,this.normal)+this.d},C.FromArray=function(u){return new C(u[0],u[1],u[2],u[3])},C.FromPoints=function(u,M,R){var x=new C(0,0,0,0);return x.copyFromPoints(u,M,R),x},C.FromPositionAndNormal=function(u,M){var R=new C(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},C.SignedDistanceToPlaneFromPositionAndNormal=function(u,M,R){var x=-(M.x*u.x+M.y*u.y+M.z*u.z);return U.e.Dot(R,M)+x},C._TmpMatrix=U.a.Identity(),C}()},function(Me,y,f){f.d(y,"a",function(){return m});var U=f(7),_=f(20),C=f(6),u=f(0),M=f(18),R=f(39),x=f(60),m=(f(84),function(){function c(T){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 C.c,this.onDragStartObservable=new C.c,this.onDragEndObservable=new C.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=T||{};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(T){this._options=T},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(T,A){var S=this;this._scene=T.getScene(),this.attachedNode=T,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=U.a.CreatePlane("pointerDragPlane",this._debugMode?1:1e4,c._planeScene,!1,U.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 v=l.event.pointerId;if(S.currentDraggingPointerID===c._AnyMouseID&&v!==c._AnyMouseID){var E=l.event;(E.pointerType==="mouse"||!S._scene.getEngine().hostInformation.isMobile&&E instanceof MouseEvent)&&(S._lastPointerRay[S.currentDraggingPointerID]&&(S._lastPointerRay[v]=S._lastPointerRay[S.currentDraggingPointerID],delete S._lastPointerRay[S.currentDraggingPointerID]),S.currentDraggingPointerID=v)}S._lastPointerRay[v]||(S._lastPointerRay[v]=new R.a(new u.e,new u.e)),l.pickInfo&&l.pickInfo.ray&&(S._lastPointerRay[v].origin.copyFrom(l.pickInfo.ray.origin),S._lastPointerRay[v].direction.copyFrom(l.pickInfo.ray.direction),S.currentDraggingPointerID==v&&S.dragging&&S._moveDrag(l.pickInfo.ray))}}}),this._beforeRenderObserver=this._scene.onBeforeRenderObservable.add(function(){S._moving&&S.moveAttached&&(x.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),x.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){if(this._scene.activeCamera.getClassName()==="ArcRotateCamera"){var T=this._scene.activeCamera;T.attachControl(!T.inputs||T.inputs.noPreventDefault,T._useCtrlForPanning,T._panningMouseButton)}else this._scene.activeCamera.attachControl(!this._scene.activeCamera.inputs||this._scene.activeCamera.inputs.noPreventDefault);this._attachedToElement=!1}},c.prototype.startDrag=function(T,A,S){T===void 0&&(T=c._AnyMouseID),this._startDrag(T,A,S);var g=this._lastPointerRay[T];T===c._AnyMouseID&&(g=this._lastPointerRay[Object.keys(this._lastPointerRay)[0]]),g&&this._moveDrag(g)},c.prototype._startDrag=function(T,A,S){if(this._scene.activeCamera&&!this.dragging&&this.attachedNode){x.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=T,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)),x.a._RestorePivotPoint(this.attachedNode)}},c.prototype._moveDrag=function(T){this._moving=!0;var A=this._pickWithRayOnDragPlane(T);if(A){this.updateDragPlane&&this._updateDragPlanePosition(T,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(T){var A=this;if(!T)return null;var S=Math.acos(u.e.Dot(this._dragPlane.forward,T.direction));if(S>Math.PI/2&&(S=Math.PI-S),this.maxDragAngle>0&&S>this.maxDragAngle){if(this._useAlternatePickedPointAboveMaxDragAngle){this._tmpVector.copyFrom(T.direction),this.attachedNode.absolutePosition.subtractToRef(T.origin,this._alternatePickedPoint),this._alternatePickedPoint.normalize(),this._alternatePickedPoint.scaleInPlace(this._useAlternatePickedPointAboveMaxDragAngleDragSpeed*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(T,function(h){return h==A._dragPlane});return l&&l.hit&&l.pickedMesh&&l.pickedPoint?l.pickedPoint:null},c.prototype._updateDragPlanePosition=function(T,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),T.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(T.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(Me,y,f){f.d(y,"a",function(){return _}),f.d(y,"b",function(){return C}),f.d(y,"c",function(){return u});var U=f(1),_=function(){function M(){}return M.KEYDOWN=1,M.KEYUP=2,M}(),C=function(M,R){this.type=M,this.event=R},u=function(M){function R(x,m){var c=M.call(this,x,m)||this;return c.type=x,c.event=m,c.skipOnPointerObservable=!1,c}return Object(U.d)(R,M),R}(C)},function(Me,y,f){f.d(y,"a",function(){return U});var U=function(){function _(){this._defines={},this._currentRank=32,this._maxRank=-1,this._mesh=null}return _.prototype.unBindMesh=function(){this._mesh=null},_.prototype.addFallback=function(C,u){this._defines[C]||(Cthis._maxRank&&(this._maxRank=C),this._defines[C]=new Array),this._defines[C].push(u)},_.prototype.addCPUSkinningFallback=function(C,u){this._mesh=u,Cthis._maxRank&&(this._maxRank=C)},Object.defineProperty(_.prototype,"hasMoreFallbacks",{get:function(){return this._currentRank<=this._maxRank},enumerable:!1,configurable:!0}),_.prototype.reduce=function(C,u){if(this._mesh&&this._mesh.computeBonesUsingShaders&&this._mesh.numBoneInfluencers>0){this._mesh.computeBonesUsingShaders=!1,C=C.replace("#define NUM_BONE_INFLUENCERS "+this._mesh.numBoneInfluencers,"#define NUM_BONE_INFLUENCERS 0"),u._bonesComputationForcedToCPU=!0;for(var M=this._mesh.getScene(),R=0;R0&&(x.computeBonesUsingShaders=!1)}}else{var T=this._defines[this._currentRank];if(T)for(R=0;R=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[m]},x.prototype.getActiveTextures=function(){var m;return(m=R.prototype.getActiveTextures.call(this)).concat.apply(m,this.subMaterials.map(function(c){return c?c.getActiveTextures():[]}))},x.prototype.hasTexture=function(m){var c;if(R.prototype.hasTexture.call(this,m))return!0;for(var T=0;T=0&&A.multiMaterials.splice(S,1),R.prototype.dispose.call(this,m,c)}},x.ParseMultiMaterial=function(m,c){var T=new x(m.name,c);T.id=m.id,C.a&&C.a.AddTagsTo(T,m.tags);for(var A=0;A"u")return new OffscreenCanvas(C,u);var M=document.createElement("canvas");return M.width=C,M.height=u,M},_}()},function(Me,y,f){f.d(y,"a",function(){return S});var U=f(0),_=f(9),C=f(16),u=f(4),M=f(61),R=f(69),x=f(43),m=f(2),c=f(12),T=f(37),A=f(101),S=function(){function g(l,h,v,E,D){E===void 0&&(E=!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=E,v?this.setAllVerticesData(v,E):(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;l0&&(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,v=this._meshes;h0){for(var h=0;h0){for(h=0;h0){for(h=0;h0){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 X=new Float32Array(l,w.uvsAttrDesc.offset,w.uvsAttrDesc.count);h.setVerticesData(u.b.UVKind,X,!1)}if(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;$>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;$>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;$>8),K.push((16711680&W)>>16),K.push(W>>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;$>8),K.push((16711680&W)>>16),K.push(W>>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-1){var E=h.getScene().getLastSkeletonByID(l.skeletonId);if(E){v=E.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,X=N.length,j=0;jV-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]=v):(N[j+te]=1-ne,D[j+te]=v)}h.setVerticesData(u.b.MatricesIndicesKind,D),l.matricesWeightsExtra&&h.setVerticesData(u.b.MatricesIndicesExtraKind,w)}}}},g.Parse=function(l,h,v){if(h.getGeometryByID(l.id))return null;var E=new g(l.id,h,void 0,l.updatable);return T.a&&T.a.AddTagsTo(E,l.tags),l.delayLoadingFile?(E.delayLoadState=m.a.DELAYLOADSTATE_NOTLOADED,E.delayLoadingFile=v+l.delayLoadingFile,E._boundingInfo=new x.a(U.e.FromArray(l.boundingBoxMinimum),U.e.FromArray(l.boundingBoxMaximum)),E._delayInfo=[],l.hasUVs&&E._delayInfo.push(u.b.UVKind),l.hasUVs2&&E._delayInfo.push(u.b.UV2Kind),l.hasUVs3&&E._delayInfo.push(u.b.UV3Kind),l.hasUVs4&&E._delayInfo.push(u.b.UV4Kind),l.hasUVs5&&E._delayInfo.push(u.b.UV5Kind),l.hasUVs6&&E._delayInfo.push(u.b.UV6Kind),l.hasColors&&E._delayInfo.push(u.b.ColorKind),l.hasMatricesIndices&&E._delayInfo.push(u.b.MatricesIndicesKind),l.hasMatricesWeights&&E._delayInfo.push(u.b.MatricesWeightsKind),E._delayLoadingFunction=C.a.ImportVertexData):C.a.ImportVertexData(l,E),h.pushGeometry(E,!0),E},g}()},function(Me,y,f){f.d(y,"e",function(){return U}),f.d(y,"c",function(){return M}),f.d(y,"a",function(){return R}),f.d(y,"b",function(){return x}),f.d(y,"f",function(){return m}),f.d(y,"g",function(){return c}),f.d(y,"d",function(){return T});var U,_=f(14),C=f(0),u=f(28);(function(A){A[A.CW=0]="CW",A[A.CCW=1]="CCW"})(U||(U={}));var M=function(){function A(){}return A.Interpolate=function(S,g,l,h,v){for(var E=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-=(E*(V*N)+D*V+w*N-S)*(1/(3*E*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)*v+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}(),x=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,v=(l-Math.pow(g.x,2)-Math.pow(g.y,2))/2,E=(A.x-S.x)*(S.y-g.y)-(S.x-g.x)*(A.y-S.y);this.centerPoint=new C.d((h*(S.y-g.y)-v*(A.y-S.y))/E,((A.x-S.x)*v-(S.x-g.x)*h)/E),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?U.CW:U.CCW,this.angle=R.FromDegrees(this.orientation===U.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 C.d(S,g))}return A.prototype.addLineTo=function(S,g){if(this.closed)return this;var l=new C.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,v){if(v===void 0&&(v=36),this.closed)return this;var E=this._points[this._points.length-1],D=new C.d(S,g),w=new C.d(l,h),N=new x(E,D,w),I=N.angle.radians()/v;N.orientation===U.CW&&(I*=-1);for(var V=N.startAngle.radians()+I,X=0;X1)return C.d.Zero();for(var g=S*this.length(),l=0,h=0;h=l&&g<=w){var N=D.normalize(),I=g-l;return new C.d(E.x+N.x*I,E.y+N.y*I)}l=w}return C.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:C.e.Zero(),previousPointArrayIndex:0,position:0,subPosition:0,interpolateReady:!1,interpolationMatrix:C.a.Identity()};for(var v=0;vg){var l=S;S=g,g=l}var h=this.getCurve(),v=this.getPointAt(S),E=this.getPreviousPointIndexAt(S),D=this.getPointAt(g),w=this.getPreviousPointIndexAt(g)+1,N=[];return S!==0&&(E++,N.push(v)),N.push.apply(N,h.slice(E,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;hg+1;)g++,l=this._curve[S].subtract(this._curve[S-g]);return l},A.prototype._normalVector=function(S,g){var l,h,v=S.length();return v===0&&(v=1),g==null?(h=_.a.WithinEpsilon(Math.abs(S.y)/v,1,u.a)?_.a.WithinEpsilon(Math.abs(S.x)/v,1,u.a)?_.a.WithinEpsilon(Math.abs(S.z)/v,1,u.a)?C.e.Zero():new C.e(0,0,1):new C.e(1,0,0):new C.e(0,-1,0),l=C.e.Cross(S,h)):(l=C.e.Cross(S,g),C.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,v=l[0],E=0,D=S*this.length(),w=1;wD){var I=(E-D)/N,V=v.subtract(h),X=h.add(V.scaleInPlace(I));return this._setPointAtData(S,1-I,X,w-1,g)}v=h}return this._pointAtData},A.prototype._setPointAtData=function(S,g,l,h,v){return this._pointAtData.point=l,this._pointAtData.position=S,this._pointAtData.subPosition=g,this._pointAtData.previousPointArrayIndex=h,this._pointAtData.interpolateReady=v,v&&this._updateInterpolationMatrix(),this._pointAtData},A.prototype._updateInterpolationMatrix=function(){this._pointAtData.interpolationMatrix=C.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(),v=this._binormals[S].clone(),E=this._tangents[g].clone(),D=this._normals[g].clone(),w=this._binormals[g].clone(),N=C.b.RotationQuaternionFromAxis(h,v,l),I=C.b.RotationQuaternionFromAxis(D,w,E);C.b.Slerp(N,I,this._pointAtData.subPosition).toRotationMatrix(this._pointAtData.interpolationMatrix)}},A}(),T=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 v=new Array,E=function(w,N,I,V){return(1-w)*(1-w)*N+2*w*(1-w)*I+w*w*V},D=0;D<=h;D++)v.push(new C.e(E(D/h,S.x,g.x,l.x),E(D/h,S.y,g.y,l.y),E(D/h,S.z,g.z,l.z)));return new A(v)},A.CreateCubicBezier=function(S,g,l,h,v){v=v>3?v:4;for(var E=new Array,D=function(N,I,V,X,j){return(1-N)*(1-N)*(1-N)*I+3*N*(1-N)*(1-N)*V+3*N*N*(1-N)*X+N*N*N*j},w=0;w<=v;w++)E.push(new C.e(D(w/v,S.x,g.x,l.x,h.x),D(w/v,S.y,g.y,l.y,h.y),D(w/v,S.z,g.z,l.z,h.z)));return new A(E)},A.CreateHermiteSpline=function(S,g,l,h,v){for(var E=new Array,D=1/v,w=0;w<=v;w++)E.push(C.e.Hermite(S,g,l,h,w*D));return new A(E)},A.CreateCatmullRomSpline=function(S,g,l){var h=new Array,v=1/g,E=0;if(l){for(var D=S.length,w=0;w1&&(this._multiview=!0,X.push("#define MULTIVIEW"),this._options.uniforms.indexOf("viewProjection")!==-1&&this._options.uniforms.push("viewProjectionR")===-1&&this._options.uniforms.push("viewProjectionR"));for(var te=0;te4&&(j.push(u.b.MatricesIndicesExtraKind),j.push(u.b.MatricesWeightsExtraKind));var pe=E.skeleton;de=E.numBoneInfluencers,X.push("#define NUM_BONE_INFLUENCERS "+de),ne.addCPUSkinningFallback(0,E),pe.isUsingTextureForMatrices?(X.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")):(X.push("#define BonesPerMesh "+(pe.bones.length+1)),this._options.uniforms.indexOf("mBones")===-1&&this._options.uniforms.push("mBones"))}else X.push("#define NUM_BONE_INFLUENCERS 0");for(var ae in this._textures)if(!this._textures[ae].isReady())return!1;E&&this._shouldTurnAlphaTestOn(E)&&X.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,X,j));var G=this._effect,Q=X.join(` +`);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)},v.prototype.bindOnlyWorldMatrix=function(E,D){var w=this.getScene(),N=D??this._effect;N&&(this._options.uniforms.indexOf("world")!==-1&&N.setMatrix("world",E),this._options.uniforms.indexOf("worldView")!==-1&&(E.multiplyToRef(w.getViewMatrix(),this._cachedWorldViewMatrix),N.setMatrix("worldView",this._cachedWorldViewMatrix)),this._options.uniforms.indexOf("worldViewProjection")!==-1&&(E.multiplyToRef(w.getTransformMatrix(),this._cachedWorldViewProjectionMatrix),N.setMatrix("worldViewProjection",this._cachedWorldViewProjectionMatrix)))},v.prototype.bindForSubMesh=function(E,D,w){this.bind(E,D,w._effectOverride)},v.prototype.bind=function(E,D,w){this.bindOnlyWorldMatrix(E,w);var N=w??this._effect;if(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 X=this._effect;this._effect=N,this._afterBind(D),this._effect=X},v.prototype._afterBind=function(E){h.prototype._afterBind.call(this,E),this.getScene()._cachedEffect=this._effect},v.prototype.getActiveTextures=function(){var E=h.prototype.getActiveTextures.call(this);for(var D in this._textures)E.push(this._textures[D]);for(var D in this._textureArrays)for(var w=this._textureArrays[D],N=0;NI.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=E._getSharedGizmoLight();de.includedOnlyMeshes=de.includedOnlyMeshes.concat(I._rootMesh.getChildMeshes(!1));var pe={gizmoMeshes:V.getChildMeshes(),colliderMeshes:X.getChildMeshes(),material:I._coloredMaterial,hoverMaterial:I._hoverMaterial,disableMaterial:I._disableMaterial,active:!1};return(N=I._parent)===null||N===void 0||N.addToAxisCache(X,pe),I._pointerObserver=E.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(U.d)(l,g),l._CreateArrow=function(h,v,E,D){E===void 0&&(E=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+(E-1)/4),tessellation:96},h),I=R.a.CreateCylinder("cylinder",{diameterTop:.005*E,height:.275,diameterBottom:.005*E,tessellation:96},h);return N.parent=w,N.material=v,N.rotation.x=Math.PI/2,N.position.z+=.3,I.parent=w,I.material=v,I.position.z+=.1375,I.rotation.x=Math.PI/2,D&&(I.visibility=0,N.visibility=0),w},l._CreateArrowInstance=function(h,v){for(var E=new u.a("arrow",h),D=0,w=v.getChildMeshes();D0 +#ifdef BONETEXTURE +uniform sampler2D boneSampler; +uniform float boneTextureWidth; +#else +uniform mat4 mBones[BonesPerMesh]; +#ifdef BONES_VELOCITY_ENABLED +uniform mat4 mPreviousBones[BonesPerMesh]; +#endif +#endif +attribute vec4 matricesIndices; +attribute vec4 matricesWeights; +#if NUM_BONE_INFLUENCERS>4 +attribute vec4 matricesIndicesExtra; +attribute vec4 matricesWeightsExtra; +#endif +#ifdef BONETEXTURE +#define inline +mat4 readMatrixFromRawSampler(sampler2D smp,float index) +{ +float offset=index*4.0; +float dx=1.0/boneTextureWidth; +vec4 m0=texture2D(smp,vec2(dx*(offset+0.5),0.)); +vec4 m1=texture2D(smp,vec2(dx*(offset+1.5),0.)); +vec4 m2=texture2D(smp,vec2(dx*(offset+2.5),0.)); +vec4 m3=texture2D(smp,vec2(dx*(offset+3.5),0.)); +return mat4(m0,m1,m2,m3); +} +#endif +#endif`;f(5).a.IncludesShadersStore[U]=_},function(Me,y,f){var U="instancesDeclaration",_=`#ifdef INSTANCES +attribute vec4 world0; +attribute vec4 world1; +attribute vec4 world2; +attribute vec4 world3; +#ifdef THIN_INSTANCES +uniform mat4 world; +#endif +#else +uniform mat4 world; +#endif`;f(5).a.IncludesShadersStore[U]=_},function(Me,y,f){var U="instancesVertex",_=`#ifdef INSTANCES +mat4 finalWorld=mat4(world0,world1,world2,world3); +#ifdef THIN_INSTANCES +finalWorld=world*finalWorld; +#endif +#else +mat4 finalWorld=world; +#endif`;f(5).a.IncludesShadersStore[U]=_},function(Me,y,f){var U=`#if NUM_BONE_INFLUENCERS>0 +mat4 influence; +#ifdef BONETEXTURE +influence=readMatrixFromRawSampler(boneSampler,matricesIndices[0])*matricesWeights[0]; +#if NUM_BONE_INFLUENCERS>1 +influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[1])*matricesWeights[1]; +#endif +#if NUM_BONE_INFLUENCERS>2 +influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[2])*matricesWeights[2]; +#endif +#if NUM_BONE_INFLUENCERS>3 +influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[3])*matricesWeights[3]; +#endif +#if NUM_BONE_INFLUENCERS>4 +influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[0])*matricesWeightsExtra[0]; +#endif +#if NUM_BONE_INFLUENCERS>5 +influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[1])*matricesWeightsExtra[1]; +#endif +#if NUM_BONE_INFLUENCERS>6 +influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[2])*matricesWeightsExtra[2]; +#endif +#if NUM_BONE_INFLUENCERS>7 +influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[3])*matricesWeightsExtra[3]; +#endif +#else +influence=mBones[int(matricesIndices[0])]*matricesWeights[0]; +#if NUM_BONE_INFLUENCERS>1 +influence+=mBones[int(matricesIndices[1])]*matricesWeights[1]; +#endif +#if NUM_BONE_INFLUENCERS>2 +influence+=mBones[int(matricesIndices[2])]*matricesWeights[2]; +#endif +#if NUM_BONE_INFLUENCERS>3 +influence+=mBones[int(matricesIndices[3])]*matricesWeights[3]; +#endif +#if NUM_BONE_INFLUENCERS>4 +influence+=mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0]; +#endif +#if NUM_BONE_INFLUENCERS>5 +influence+=mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1]; +#endif +#if NUM_BONE_INFLUENCERS>6 +influence+=mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2]; +#endif +#if NUM_BONE_INFLUENCERS>7 +influence+=mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3]; +#endif +#endif +finalWorld=finalWorld*influence; +#endif`;f(5).a.IncludesShadersStore.bonesVertex=U},function(Me,y,f){f.d(y,"a",function(){return R});var U=f(0),_=f(7),C=f(4),u=f(16),M=f(43);u.a.CreateRibbon=function(x){var m=x.pathArray,c=x.closeArray||!1,T=x.closePath||!1,A=x.invertUV||!1,S=Math.floor(m[0].length/2),g=x.offset||S;g=g>S?S:Math.floor(g);var l,h,v,E,D=x.sideOrientation===0?0:x.sideOrientation||u.a.DEFAULTSIDE,w=x.uvs,N=x.colors,I=[],V=[],X=[],j=[],ne=[],te=[],de=[],pe=[],ae=[],ee=[];if(m.length<2){var K=[],$=[];for(v=0;v0&&(Q=L[E].subtract(L[E-1]).length()+de[h],ne[h].push(Q),de[h]=Q),E++;T&&(E--,I.push(L[0].x,L[0].y,L[0].z),Q=L[E].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,W=null,q=null;for(v=0;v=U.a.ACTION_OnPickTrigger&&M<=U.a.ACTION_OnPickUpTrigger)return!0}return!1},enumerable:!1,configurable:!0}),C.HasSpecificTrigger=function(u){for(var M in C.Triggers)if(C.Triggers.hasOwnProperty(M)&&parseInt(M)===u)return!0;return!1},C.Triggers={},C}()},function(Me,y,f){f.d(y,"a",function(){return R});var U=f(1),_=f(25),C=f(3),u=f(19),M=f(15),R=function(){function x(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 x.prototype._markAllSubMeshesAsTexturesDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty()},x.prototype.isReadyForSubMesh=function(m,c){var T=c.getEngine();return!(m._areTexturesDirty&&c.texturesEnabled&&T.getCaps().standardDerivatives&&this._texture&&u.a.DetailTextureEnabled&&!this._texture.isReady())},x.prototype.prepareDefines=function(m,c){if(this._isEnabled){m.DETAIL_NORMALBLENDMETHOD=this._normalBlendMethod;var T=c.getEngine();m._areTexturesDirty&&(T.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},x.prototype.bindForSubMesh=function(m,c,T){this._isEnabled&&(m.useUbo&&T&&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))},x.prototype.hasTexture=function(m){return this._texture===m},x.prototype.getActiveTextures=function(m){this._texture&&m.push(this._texture)},x.prototype.getAnimatables=function(m){this._texture&&this._texture.animations&&this._texture.animations.length>0&&m.push(this._texture)},x.prototype.dispose=function(m){var c;m&&((c=this._texture)===null||c===void 0||c.dispose())},x.prototype.getClassName=function(){return"DetailMap"},x.AddUniforms=function(m){m.push("vDetailInfos")},x.AddSamplers=function(m){m.push("detailSampler")},x.PrepareUniformBuffer=function(m){m.addUniform("vDetailInfos",4),m.addUniform("detailMatrix",16)},x.prototype.copyTo=function(m){C.a.Clone(function(){return m},this)},x.prototype.serialize=function(){return C.a.Serialize(this)},x.prototype.parse=function(m,c,T){var A=this;C.a.Parse(function(){return A},m,c,T)},Object(U.c)([Object(C.m)("detailTexture"),Object(C.b)("_markAllSubMeshesAsTexturesDirty")],x.prototype,"texture",void 0),Object(U.c)([Object(C.c)()],x.prototype,"diffuseBlendLevel",void 0),Object(U.c)([Object(C.c)()],x.prototype,"roughnessBlendLevel",void 0),Object(U.c)([Object(C.c)()],x.prototype,"bumpLevel",void 0),Object(U.c)([Object(C.c)(),Object(C.b)("_markAllSubMeshesAsTexturesDirty")],x.prototype,"normalBlendMethod",void 0),Object(U.c)([Object(C.c)(),Object(C.b)("_markAllSubMeshesAsTexturesDirty")],x.prototype,"isEnabled",void 0),x}()},function(Me,y,f){var U="morphTargetsVertexGlobalDeclaration",_=`#ifdef MORPHTARGETS +uniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS]; +#endif`;f(5).a.IncludesShadersStore[U]=_},function(Me,y,f){var U="morphTargetsVertexDeclaration",_=`#ifdef MORPHTARGETS +attribute vec3 position{X}; +#ifdef MORPHTARGETS_NORMAL +attribute vec3 normal{X}; +#endif +#ifdef MORPHTARGETS_TANGENT +attribute vec3 tangent{X}; +#endif +#ifdef MORPHTARGETS_UV +attribute vec2 uv_{X}; +#endif +#endif`;f(5).a.IncludesShadersStore[U]=_},function(Me,y,f){f.d(y,"a",function(){return u});var U=f(25),_=f(4),C=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,x){R===void 0&&(R=null),x===void 0&&(x=null);var m=this._scene.activeCamera;return!!m&&!(!(x=x||m._postProcesses.filter(function(c){return c!=null}))||x.length===0||!this._scene.postProcessesEnabled)&&(x[0].activate(m,R,x!=null),!0)},M.prototype.directRender=function(R,x,m,c,T,A){x===void 0&&(x=null),m===void 0&&(m=!1),c===void 0&&(c=0),T===void 0&&(T=0),A===void 0&&(A=!1);for(var S=this._scene.getEngine(),g=0;g3?0:v,E);var ae=C.a.CreateRibbon(x,{pathArray:te,closeArray:l,closePath:h,updatable:w,sideOrientation:N,invertUV:V,frontUVs:X||void 0,backUVs:j||void 0},D);return ae._creationDataStorage.pathArray=te,ae._creationDataStorage.path3D=ne,ae._creationDataStorage.cap=v,ae},R}()},function(Me,y,f){f.d(y,"b",function(){return c}),f.d(y,"a",function(){return T});var U=f(1),_=f(9),C=f(4),u=f(7),M=f(151),R=f(25),x=f(73),m=f(15),c=(f(166),f(167),function(A){function S(g,l,h,v,E,D,w){l===void 0&&(l=null),h===void 0&&(h=null),v===void 0&&(v=null);var N=A.call(this,g,l,h,v,E)||this;N.useVertexColor=D,N.useVertexAlpha=w,N.color=new _.a(1,1,1),N.alpha=1,v&&(N.color=v.color.clone(),N.alpha=v.alpha,N.useVertexColor=v.useVertexColor,N.useVertexAlpha=v.useVertexAlpha),N.intersectionThreshold=.1;var I={attributes:[C.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(C.b.ColorKind)):(I.uniforms.push("color"),N.color4=new _.b),N._colorShader=new x.a("colorShader",N.getScene(),"color",I),N}return Object(U.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){},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 v=this._colorShader.getEffect(),E=this.isUnIndexed?null:this._geometry.getIndexBuffer();if(this._geometry._bind(v,E),!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(v,this.getScene()),this},S.prototype._draw=function(g,l,h){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;var v=this.getScene().getEngine();return this._unIndexed?v.drawArraysType(R.a.LineListDrawMode,g.verticesStart,g.verticesCount,h):v.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 T(g,this)},S}(u.a)),T=function(A){function S(g,l){var h=A.call(this,g,l)||this;return h.intersectionThreshold=l.intersectionThreshold,h}return Object(U.d)(S,A),S.prototype.getClassName=function(){return"InstancedLinesMesh"},S}(M.a)},function(Me,y,f){f.r(y),f.d(y,"AxesViewer",function(){return R}),f.d(y,"BoneAxesViewer",function(){return c}),f.d(y,"DebugLayerTab",function(){return U}),f.d(y,"DebugLayer",function(){return l}),f.d(y,"PhysicsViewer",function(){return V}),f.d(y,"RayHelper",function(){return j}),f.d(y,"SkeletonViewer",function(){return K});var U,_=f(0),C=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 C.a("",L);k.disableLighting=!0,k.emissiveColor=M.a.Red().scale(.5),oe=u.a._CreateArrow(L,k)}if(!re){var H=new C.a("",L);H.disableLighting=!0,H.emissiveColor=M.a.Green().scale(.5),re=u.a._CreateArrow(L,H)}if(!Y){var Z=new C.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})},$}(),x=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(x.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),T=f(12),A=f(6),S=f(20),g=f(13);Object.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"}(U||(U={}));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-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 C.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=v.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=E.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")},$.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;case 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$.DISPLAY_SPHERE_AND_SPURS&&(Ge=$.DISPLAY_LINES),this.displayMode=Ge,this.update(),this._bindObs()}return $.CreateBoneWeightShader=function(L,G){var Q,oe,re,Y,k,H,Z=L.skeleton,W=(Q=L.colorBase)!==null&&Q!==void 0?Q:M.a.Black(),q=(oe=L.colorZero)!==null&&oe!==void 0?oe:M.a.Blue(),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; + + attribute vec3 position; + attribute vec2 uv; + + uniform mat4 view; + uniform mat4 projection; + uniform mat4 worldViewProjection; + + #include + #if NUM_BONE_INFLUENCERS == 0 + attribute vec4 matricesIndices; + attribute vec4 matricesWeights; + #endif + + #include + + varying vec3 vColor; + + uniform vec3 colorBase; + uniform vec3 colorZero; + uniform vec3 colorQuarter; + uniform vec3 colorHalf; + uniform vec3 colorFull; + + uniform float targetBoneIndex; + + void main() { + vec3 positionUpdated = position; + + #include + #include + + vec4 worldPos = finalWorld * vec4(positionUpdated, 1.0); + + vec3 color = colorBase; + float totalWeight = 0.; + if(matricesIndices[0] == targetBoneIndex && matricesWeights[0] > 0.){ + totalWeight += matricesWeights[0]; + } + if(matricesIndices[1] == targetBoneIndex && matricesWeights[1] > 0.){ + totalWeight += matricesWeights[1]; + } + if(matricesIndices[2] == targetBoneIndex && matricesWeights[2] > 0.){ + totalWeight += matricesWeights[2]; + } + if(matricesIndices[3] == targetBoneIndex && matricesWeights[3] > 0.){ + totalWeight += matricesWeights[3]; + } + + color = mix(color, colorZero, smoothstep(0., 0.25, totalWeight)); + color = mix(color, colorQuarter, smoothstep(0.25, 0.5, totalWeight)); + color = mix(color, colorHalf, smoothstep(0.5, 0.75, totalWeight)); + color = mix(color, colorFull, smoothstep(0.75, 1.0, totalWeight)); + vColor = color; + + gl_Position = projection * view * worldPos; + }`,ae.a.ShadersStore["boneWeights:"+Z.name+"FragmentShader"]=` + precision highp float; + varying vec3 vPosition; + + varying vec3 vColor; + + void main() { + vec4 color = vec4(vColor, 1.0); + gl_FragColor = color; + } + `;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",W),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}],Y=oe.bones.length+1,k=$._CreateBoneMapColorBuffer(Y,re,G),H=new te.a("boneWeights:"+oe.name,G,{vertexSource:`precision highp float; + + attribute vec3 position; + attribute vec2 uv; + + uniform mat4 view; + uniform mat4 projection; + uniform mat4 worldViewProjection; + uniform float colorMap[`+4*oe.bones.length+`]; + + #include + #if NUM_BONE_INFLUENCERS == 0 + attribute vec4 matricesIndices; + attribute vec4 matricesWeights; + #endif + #include + + varying vec3 vColor; + + void main() { + vec3 positionUpdated = position; + + #include + #include + + vec3 color = vec3(0.); + bool first = true; + + for (int i = 0; i < 4; i++) { + int boneIdx = int(matricesIndices[i]); + float boneWgt = matricesWeights[i]; + + vec3 c = vec3(colorMap[boneIdx * 4 + 0], colorMap[boneIdx * 4 + 1], colorMap[boneIdx * 4 + 2]); + + if (boneWgt > 0.) { + if (first) { + first = false; + color = c; + } else { + color = mix(color, c, boneWgt); + } + } + } + + vColor = color; + + vec4 worldPos = finalWorld * vec4(positionUpdated, 1.0); + + gl_Position = projection * view * worldPos; + }`,fragmentSource:` + precision highp float; + varying vec3 vColor; + + void main() { + vec4 color = vec4( vColor, 1.0 ); + gl_FragColor = color; + } + `},{attributes:["position","normal","matricesIndices","matricesWeights"],uniforms:["world","worldView","worldViewProjection","view","projection","viewProjection","colorMap"]});return 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(W){Y.addColorStop(W.location,W.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$.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))},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=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,W=this.options.displayOptions||{},q=function(He){var qe=re[He];if(qe._index===-1||!he._boneIndices.has(qe.getIndex())&&!he.options.useAllBones)return"continue";var Ge=new _.a;he._getAbsoluteBindPoseToRef(qe,Ge);var nt=new _.e;Ge.decompose(void 0,void 0,nt),qe.children.forEach(function(It,Pt){var Ot=new _.a;It.getBindPose().multiplyToRef(Ge,Ot);var on=new _.e;Ot.decompose(void 0,void 0,on);var Zt=_.e.Distance(nt,on);if(Zt>Z&&(Z=Zt),!L){for(var tn=on.clone().subtract(nt.clone()),De=tn.length(),Pn=tn.normalize().scale(De),nn=W.midStep||.165,xn=W.midStepFactor||.215,Ue=Pn.scale(nn),Cn=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,Pn],scaleFunction:function(Lo){switch(Lo){case 0:case 2:return 0;case 1:return De*xn}return 0},sideOrientation:h.a.DEFAULTSIDE,updatable:!1},oe),dr=Cn.getTotalVertices(),Xe=[],An=[],ti=0;ti9?An.push(It.getIndex(),0,0,0):An.push(qe.getIndex(),0,0,0);Cn.position=nt.clone(),Cn.setVerticesData(pe.b.MatricesWeightsKind,Xe,!1),Cn.setVerticesData(pe.b.MatricesIndicesKind,An,!1),Cn.convertToFlatShadedMesh(),k.push(Cn)}});for(var $e=W.sphereBaseSize||.2,ct=E.a.CreateSphere("skeletonViewer",{segments:6,diameter:$e,updatable:!0},oe),st=ct.getTotalVertices(),mt=[],St=[],wt=0;wth-c)&&!(g-vv-T)&&!(l-EE-A)},M.prototype.intersectsSphere=function(R){return M.IntersectsSphere(this.minimumWorld,this.maximumWorld,R.centerWorld,R.radiusWorld)},M.prototype.intersectsMinMax=function(R,x){var m=this.minimumWorld,c=this.maximumWorld,T=m.x,A=m.y,S=m.z,g=c.x,l=c.y,h=c.z,v=R.x,E=R.y,D=R.z,w=x.x,N=x.y,I=x.z;return!(gw)&&!(lN)&&!(hI)},M.Intersects=function(R,x){return R.intersectsMinMax(x.minimumWorld,x.maximumWorld)},M.IntersectsSphere=function(R,x,m,c){var T=M.TmpVector3[0];return _.e.ClampToRef(m,R,x,T),_.e.DistanceSquared(m,T)<=c*c},M.IsCompletelyInFrustum=function(R,x){for(var m=0;m<6;++m)for(var c=x[m],T=0;T<8;++T)if(c.dotCoordinate(R[T])<0)return!1;return!0},M.IsInFrustum=function(R,x){for(var m=0;m<6;++m){for(var c=!0,T=x[m],A=0;A<8;++A)if(T.dotCoordinate(R[A])>=0){c=!1;break}if(c)return!1}return!0},M.TmpVector3=U.a.BuildArray(3,_.e.Zero),M}()},function(Me,y,f){f.d(y,"a",function(){return _});var U=f(38),_=function(){function C(){}return C.SetImmediate=function(u){U.a.IsWindowObjectExist()&&window.setImmediate?window.setImmediate(u):setTimeout(u,1)},C}()},function(Me,y,f){f.d(y,"a",function(){return C});var U=f(0),_=f(2),C=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,x,m,c){R.prePassRenderer&&R.prePassRenderer.enabled&&R.prePassRenderer.getIndex(_.a.PREPASS_VELOCITY_TEXTURE_TYPE)!==-1&&(this.previousWorldMatrices[x.uniqueId]||(this.previousWorldMatrices[x.uniqueId]=U.a.Identity()),this.previousViewProjection||(this.previousViewProjection=R.getTransformMatrix()),M.setMatrix("previousWorld",this.previousWorldMatrices[x.uniqueId]),M.setMatrix("previousViewProjection",this.previousViewProjection),this.previousWorldMatrices[x.uniqueId]=m.clone(),this.previousViewProjection=R.getTransformMatrix().clone())},u}()},function(Me,y,f){var U="lightFragmentDeclaration",_=`#ifdef LIGHT{X} +uniform vec4 vLightData{X}; +uniform vec4 vLightDiffuse{X}; +#ifdef SPECULARTERM +uniform vec4 vLightSpecular{X}; +#else +vec4 vLightSpecular{X}=vec4(0.); +#endif +#ifdef SHADOW{X} +#ifdef SHADOWCSM{X} +uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}]; +uniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}]; +uniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}]; +uniform float cascadeBlendFactor{X}; +varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}]; +varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}]; +varying vec4 vPositionFromCamera{X}; +#if defined(SHADOWPCSS{X}) +uniform highp sampler2DArrayShadow shadowSampler{X}; +uniform highp sampler2DArray depthSampler{X}; +uniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}]; +uniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}]; +uniform float penumbraDarkness{X}; +#elif defined(SHADOWPCF{X}) +uniform highp sampler2DArrayShadow shadowSampler{X}; +#else +uniform highp sampler2DArray shadowSampler{X}; +#endif +#ifdef SHADOWCSMDEBUG{X} +const vec3 vCascadeColorsMultiplier{X}[8]=vec3[8] +( +vec3 ( 1.5,0.0,0.0 ), +vec3 ( 0.0,1.5,0.0 ), +vec3 ( 0.0,0.0,5.5 ), +vec3 ( 1.5,0.0,5.5 ), +vec3 ( 1.5,1.5,0.0 ), +vec3 ( 1.0,1.0,1.0 ), +vec3 ( 0.0,1.0,5.5 ), +vec3 ( 0.5,3.5,0.75 ) +); +vec3 shadowDebug{X}; +#endif +#ifdef SHADOWCSMUSESHADOWMAXZ{X} +int index{X}=-1; +#else +int index{X}=SHADOWCSMNUM_CASCADES{X}-1; +#endif +float diff{X}=0.; +#elif defined(SHADOWCUBE{X}) +uniform samplerCube shadowSampler{X}; +#else +varying vec4 vPositionFromLight{X}; +varying float vDepthMetric{X}; +#if defined(SHADOWPCSS{X}) +uniform highp sampler2DShadow shadowSampler{X}; +uniform highp sampler2D depthSampler{X}; +#elif defined(SHADOWPCF{X}) +uniform highp sampler2DShadow shadowSampler{X}; +#else +uniform sampler2D shadowSampler{X}; +#endif +uniform mat4 lightMatrix{X}; +#endif +uniform vec4 shadowsInfo{X}; +uniform vec2 depthValues{X}; +#endif +#ifdef SPOTLIGHT{X} +uniform vec4 vLightDirection{X}; +uniform vec4 vLightFalloff{X}; +#elif defined(POINTLIGHT{X}) +uniform vec4 vLightFalloff{X}; +#elif defined(HEMILIGHT{X}) +uniform vec3 vLightGround{X}; +#endif +#ifdef PROJECTEDLIGHTTEXTURE{X} +uniform mat4 textureProjectionMatrix{X}; +uniform sampler2D projectionLightSampler{X}; +#endif +#endif`;f(5).a.IncludesShadersStore[U]=_},function(Me,y,f){var U="lightUboDeclaration",_=`#ifdef LIGHT{X} +uniform Light{X} +{ +vec4 vLightData; +vec4 vLightDiffuse; +vec4 vLightSpecular; +#ifdef SPOTLIGHT{X} +vec4 vLightDirection; +vec4 vLightFalloff; +#elif defined(POINTLIGHT{X}) +vec4 vLightFalloff; +#elif defined(HEMILIGHT{X}) +vec3 vLightGround; +#endif +vec4 shadowsInfo; +vec2 depthValues; +} light{X}; +#ifdef PROJECTEDLIGHTTEXTURE{X} +uniform mat4 textureProjectionMatrix{X}; +uniform sampler2D projectionLightSampler{X}; +#endif +#ifdef SHADOW{X} +#ifdef SHADOWCSM{X} +uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}]; +uniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}]; +uniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}]; +uniform float cascadeBlendFactor{X}; +varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}]; +varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}]; +varying vec4 vPositionFromCamera{X}; +#if defined(SHADOWPCSS{X}) +uniform highp sampler2DArrayShadow shadowSampler{X}; +uniform highp sampler2DArray depthSampler{X}; +uniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}]; +uniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}]; +uniform float penumbraDarkness{X}; +#elif defined(SHADOWPCF{X}) +uniform highp sampler2DArrayShadow shadowSampler{X}; +#else +uniform highp sampler2DArray shadowSampler{X}; +#endif +#ifdef SHADOWCSMDEBUG{X} +const vec3 vCascadeColorsMultiplier{X}[8]=vec3[8] +( +vec3 ( 1.5,0.0,0.0 ), +vec3 ( 0.0,1.5,0.0 ), +vec3 ( 0.0,0.0,5.5 ), +vec3 ( 1.5,0.0,5.5 ), +vec3 ( 1.5,1.5,0.0 ), +vec3 ( 1.0,1.0,1.0 ), +vec3 ( 0.0,1.0,5.5 ), +vec3 ( 0.5,3.5,0.75 ) +); +vec3 shadowDebug{X}; +#endif +#ifdef SHADOWCSMUSESHADOWMAXZ{X} +int index{X}=-1; +#else +int index{X}=SHADOWCSMNUM_CASCADES{X}-1; +#endif +float diff{X}=0.; +#elif defined(SHADOWCUBE{X}) +uniform samplerCube shadowSampler{X}; +#else +varying vec4 vPositionFromLight{X}; +varying float vDepthMetric{X}; +#if defined(SHADOWPCSS{X}) +uniform highp sampler2DShadow shadowSampler{X}; +uniform highp sampler2D depthSampler{X}; +#elif defined(SHADOWPCF{X}) +uniform highp sampler2DShadow shadowSampler{X}; +#else +uniform sampler2D shadowSampler{X}; +#endif +uniform mat4 lightMatrix{X}; +#endif +#endif +#endif`;f(5).a.IncludesShadersStore[U]=_},function(Me,y,f){var U="imageProcessingDeclaration",_=`#ifdef EXPOSURE +uniform float exposureLinear; +#endif +#ifdef CONTRAST +uniform float contrast; +#endif +#ifdef VIGNETTE +uniform vec2 vInverseScreenSize; +uniform vec4 vignetteSettings1; +uniform vec4 vignetteSettings2; +#endif +#ifdef COLORCURVES +uniform vec4 vCameraColorCurveNegative; +uniform vec4 vCameraColorCurveNeutral; +uniform vec4 vCameraColorCurvePositive; +#endif +#ifdef COLORGRADING +#ifdef COLORGRADING3D +uniform highp sampler3D txColorTransform; +#else +uniform sampler2D txColorTransform; +#endif +uniform vec4 colorTransformSettings; +#endif`;f(5).a.IncludesShadersStore[U]=_},function(Me,y,f){var U="imageProcessingFunctions",_=`#if defined(COLORGRADING) && !defined(COLORGRADING3D) + +#define inline +vec3 sampleTexture3D(sampler2D colorTransform,vec3 color,vec2 sampler3dSetting) +{ +float sliceSize=2.0*sampler3dSetting.x; +#ifdef SAMPLER3DGREENDEPTH +float sliceContinuous=(color.g-sampler3dSetting.x)*sampler3dSetting.y; +#else +float sliceContinuous=(color.b-sampler3dSetting.x)*sampler3dSetting.y; +#endif +float sliceInteger=floor(sliceContinuous); + + +float sliceFraction=sliceContinuous-sliceInteger; +#ifdef SAMPLER3DGREENDEPTH +vec2 sliceUV=color.rb; +#else +vec2 sliceUV=color.rg; +#endif +sliceUV.x*=sliceSize; +sliceUV.x+=sliceInteger*sliceSize; +sliceUV=saturate(sliceUV); +vec4 slice0Color=texture2D(colorTransform,sliceUV); +sliceUV.x+=sliceSize; +sliceUV=saturate(sliceUV); +vec4 slice1Color=texture2D(colorTransform,sliceUV); +vec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction); +#ifdef SAMPLER3DBGRMAP +color.rgb=result.rgb; +#else +color.rgb=result.bgr; +#endif +return color; +} +#endif +#ifdef TONEMAPPING_ACES + + + + + +const mat3 ACESInputMat=mat3( +vec3(0.59719,0.07600,0.02840), +vec3(0.35458,0.90834,0.13383), +vec3(0.04823,0.01566,0.83777) +); + +const mat3 ACESOutputMat=mat3( +vec3( 1.60475,-0.10208,-0.00327), +vec3(-0.53108,1.10813,-0.07276), +vec3(-0.07367,-0.00605,1.07602) +); +vec3 RRTAndODTFit(vec3 v) +{ +vec3 a=v*(v+0.0245786)-0.000090537; +vec3 b=v*(0.983729*v+0.4329510)+0.238081; +return a/b; +} +vec3 ACESFitted(vec3 color) +{ +color=ACESInputMat*color; + +color=RRTAndODTFit(color); +color=ACESOutputMat*color; + +color=saturate(color); +return color; +} +#endif +vec4 applyImageProcessing(vec4 result) { +#ifdef EXPOSURE +result.rgb*=exposureLinear; +#endif +#ifdef VIGNETTE + +vec2 viewportXY=gl_FragCoord.xy*vInverseScreenSize; +viewportXY=viewportXY*2.0-1.0; +vec3 vignetteXY1=vec3(viewportXY*vignetteSettings1.xy+vignetteSettings1.zw,1.0); +float vignetteTerm=dot(vignetteXY1,vignetteXY1); +float vignette=pow(vignetteTerm,vignetteSettings2.w); + +vec3 vignetteColor=vignetteSettings2.rgb; +#ifdef VIGNETTEBLENDMODEMULTIPLY +vec3 vignetteColorMultiplier=mix(vignetteColor,vec3(1,1,1),vignette); +result.rgb*=vignetteColorMultiplier; +#endif +#ifdef VIGNETTEBLENDMODEOPAQUE +result.rgb=mix(vignetteColor,result.rgb,vignette); +#endif +#endif +#ifdef TONEMAPPING +#ifdef TONEMAPPING_ACES +result.rgb=ACESFitted(result.rgb); +#else +const float tonemappingCalibration=1.590579; +result.rgb=1.0-exp2(-tonemappingCalibration*result.rgb); +#endif +#endif + +result.rgb=toGammaSpace(result.rgb); +result.rgb=saturate(result.rgb); +#ifdef CONTRAST + +vec3 resultHighContrast=result.rgb*result.rgb*(3.0-2.0*result.rgb); +if (contrast<1.0) { + +result.rgb=mix(vec3(0.5,0.5,0.5),result.rgb,contrast); +} else { + +result.rgb=mix(result.rgb,resultHighContrast,contrast-1.0); +} +#endif + +#ifdef COLORGRADING +vec3 colorTransformInput=result.rgb*colorTransformSettings.xxx+colorTransformSettings.yyy; +#ifdef COLORGRADING3D +vec3 colorTransformOutput=texture(txColorTransform,colorTransformInput).rgb; +#else +vec3 colorTransformOutput=sampleTexture3D(txColorTransform,colorTransformInput,colorTransformSettings.yz).rgb; +#endif +result.rgb=mix(result.rgb,colorTransformOutput,colorTransformSettings.www); +#endif +#ifdef COLORCURVES + +float luma=getLuminance(result.rgb); +vec2 curveMix=clamp(vec2(luma*3.0-1.5,luma*-3.0+1.5),vec2(0.0),vec2(1.0)); +vec4 colorCurve=vCameraColorCurveNeutral+curveMix.x*vCameraColorCurvePositive-curveMix.y*vCameraColorCurveNegative; +result.rgb*=colorCurve.rgb; +result.rgb=mix(vec3(luma),result.rgb,colorCurve.a); +#endif +return result; +}`;f(5).a.IncludesShadersStore[U]=_},function(Me,y,f){var U="clipPlaneFragment",_=`#ifdef CLIPPLANE +if (fClipDistance>0.0) +{ +discard; +} +#endif +#ifdef CLIPPLANE2 +if (fClipDistance2>0.0) +{ +discard; +} +#endif +#ifdef CLIPPLANE3 +if (fClipDistance3>0.0) +{ +discard; +} +#endif +#ifdef CLIPPLANE4 +if (fClipDistance4>0.0) +{ +discard; +} +#endif +#ifdef CLIPPLANE5 +if (fClipDistance5>0.0) +{ +discard; +} +#endif +#ifdef CLIPPLANE6 +if (fClipDistance6>0.0) +{ +discard; +} +#endif`;f(5).a.IncludesShadersStore[U]=_},function(Me,y,f){var U="clipPlaneVertex",_=`#ifdef CLIPPLANE +fClipDistance=dot(worldPos,vClipPlane); +#endif +#ifdef CLIPPLANE2 +fClipDistance2=dot(worldPos,vClipPlane2); +#endif +#ifdef CLIPPLANE3 +fClipDistance3=dot(worldPos,vClipPlane3); +#endif +#ifdef CLIPPLANE4 +fClipDistance4=dot(worldPos,vClipPlane4); +#endif +#ifdef CLIPPLANE5 +fClipDistance5=dot(worldPos,vClipPlane5); +#endif +#ifdef CLIPPLANE6 +fClipDistance6=dot(worldPos,vClipPlane6); +#endif`;f(5).a.IncludesShadersStore[U]=_},function(Me,y,f){f.d(y,"a",function(){return U});var U=function(){function _(){this._count=0,this._data={}}return _.prototype.copyFrom=function(C){var u=this;this.clear(),C.forEach(function(M,R){return u.add(M,R)})},_.prototype.get=function(C){var u=this._data[C];if(u!==void 0)return u},_.prototype.getOrAddWithFactory=function(C,u){var M=this.get(C);return M!==void 0||(M=u(C))&&this.add(C,M),M},_.prototype.getOrAdd=function(C,u){var M=this.get(C);return M!==void 0?M:(this.add(C,u),u)},_.prototype.contains=function(C){return this._data[C]!==void 0},_.prototype.add=function(C,u){return this._data[C]===void 0&&(this._data[C]=u,++this._count,!0)},_.prototype.set=function(C,u){return this._data[C]!==void 0&&(this._data[C]=u,!0)},_.prototype.getAndRemove=function(C){var u=this.get(C);return u!==void 0?(delete this._data[C],--this._count,u):null},_.prototype.remove=function(C){return!!this.contains(C)&&(delete this._data[C],--this._count,!0)},_.prototype.clear=function(){this._data={},this._count=0},Object.defineProperty(_.prototype,"count",{get:function(){return this._count},enumerable:!1,configurable:!0}),_.prototype.forEach=function(C){for(var u in this._data)C(u,this._data[u])},_.prototype.first=function(C){for(var u in this._data){var M=C(u,this._data[u]);if(M)return M}return null},_}()},function(Me,y,f){f.d(y,"a",function(){return C});var U=f(44),_=f(0),C=function(){function u(M,R,x){this.center=_.e.Zero(),this.centerWorld=_.e.Zero(),this.minimum=_.e.Zero(),this.maximum=_.e.Zero(),this.reConstruct(M,R,x)}return u.prototype.reConstruct=function(M,R,x){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(x||_.a.IdentityReadOnly)},u.prototype.scale=function(M){var R=this.radius*M,x=u.TmpVector3,m=x[0].setAll(R),c=this.center.subtractToRef(m,x[1]),T=this.center.addToRef(m,x[2]);return this.reConstruct(c,T,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,x=this.radiusWorld,m=0;m<6;m++)if(M[m].dotCoordinate(R)<=-x)return!1;return!0},u.prototype.isCenterInFrustum=function(M){for(var R=this.centerWorld,x=0;x<6;x++)if(M[x].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===0?C instanceof Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,u,new Float32Array(C)):this._gl.bufferSubData(this._gl.ARRAY_BUFFER,u,C):C instanceof Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,new Float32Array(C).subarray(u,u+M)):(C=C instanceof ArrayBuffer?new Uint8Array(C,u,M):new Uint8Array(C.buffer,C.byteOffset+u,M),this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,C)),this._resetVertexBufferBinding()}},function(Me,y,f){var U="fogFragmentDeclaration",_=`#ifdef FOG +#define FOGMODE_NONE 0. +#define FOGMODE_EXP 1. +#define FOGMODE_EXP2 2. +#define FOGMODE_LINEAR 3. +#define E 2.71828 +uniform vec4 vFogInfos; +uniform vec3 vFogColor; +varying vec3 vFogDistance; +float CalcFogFactor() +{ +float fogCoeff=1.0; +float fogStart=vFogInfos.y; +float fogEnd=vFogInfos.z; +float fogDensity=vFogInfos.w; +float fogDistance=length(vFogDistance); +if (FOGMODE_LINEAR == vFogInfos.x) +{ +fogCoeff=(fogEnd-fogDistance)/(fogEnd-fogStart); +} +else if (FOGMODE_EXP == vFogInfos.x) +{ +fogCoeff=1.0/pow(E,fogDistance*fogDensity); +} +else if (FOGMODE_EXP2 == vFogInfos.x) +{ +fogCoeff=1.0/pow(E,fogDistance*fogDistance*fogDensity*fogDensity); +} +return clamp(fogCoeff,0.0,1.0); +} +#endif`;f(5).a.IncludesShadersStore[U]=_},function(Me,y,f){var U=f(26),_=f(27);U.a.prototype.createDynamicTexture=function(C,u,M,R){var x=new _.a(this,_.b.Dynamic);return x.baseWidth=C,x.baseHeight=u,M&&(C=this.needPOTTextures?U.a.GetExponentOfTwo(C,this._caps.maxTextureSize):C,u=this.needPOTTextures?U.a.GetExponentOfTwo(u,this._caps.maxTextureSize):u),x.width=C,x.height=u,x.isReady=!1,x.generateMipMaps=M,x.samplingMode=R,this.updateTextureSamplingMode(R,x),this._internalTexturesCache.push(x),x},U.a.prototype.updateDynamicTexture=function(C,u,M,R,x,m){if(R===void 0&&(R=!1),m===void 0&&(m=!1),C){var c=this._gl,T=c.TEXTURE_2D,A=this._bindTextureDirectly(T,C,!0,m);this._unpackFlipY(M===void 0?C.invertY:M),R&&c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1);var S=this._getWebGLTextureType(C.type),g=this._getInternalFormat(x||C.format),l=this._getRGBABufferInternalSizedFormat(C.type,g);c.texImage2D(T,0,l,g,S,u),C.generateMipMaps&&c.generateMipmap(T),A||this._bindTextureDirectly(T,null),R&&c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),C.isReady=!0}}},function(Me,y,f){f.r(y),f.d(y,"AbstractScene",function(){return U.a}),f.d(y,"AbstractActionManager",function(){return _.a}),f.d(y,"Action",function(){return x}),f.d(y,"ActionEvent",function(){return m.a}),f.d(y,"ActionManager",function(){return pe}),f.d(y,"Condition",function(){return T}),f.d(y,"ValueCondition",function(){return A}),f.d(y,"PredicateCondition",function(){return S}),f.d(y,"StateCondition",function(){return g}),f.d(y,"SwitchBooleanAction",function(){return v}),f.d(y,"SetStateAction",function(){return E}),f.d(y,"SetValueAction",function(){return D}),f.d(y,"IncrementValueAction",function(){return w}),f.d(y,"PlayAnimationAction",function(){return N}),f.d(y,"StopAnimationAction",function(){return I}),f.d(y,"DoNothingAction",function(){return V}),f.d(y,"CombineAction",function(){return X}),f.d(y,"ExecuteCodeAction",function(){return j}),f.d(y,"SetParentAction",function(){return ne}),f.d(y,"PlaySoundAction",function(){return ae}),f.d(y,"StopSoundAction",function(){return ee}),f.d(y,"InterpolateValueAction",function(){return H}),f.d(y,"Animatable",function(){return ke}),f.d(y,"_IAnimationState",function(){return Y}),f.d(y,"Animation",function(){return k}),f.d(y,"TargetedAnimation",function(){return We}),f.d(y,"AnimationGroup",function(){return je}),f.d(y,"AnimationPropertiesOverride",function(){return He}),f.d(y,"EasingFunction",function(){return Ge}),f.d(y,"CircleEase",function(){return nt}),f.d(y,"BackEase",function(){return $e}),f.d(y,"BounceEase",function(){return ct}),f.d(y,"CubicEase",function(){return st}),f.d(y,"ElasticEase",function(){return mt}),f.d(y,"ExponentialEase",function(){return St}),f.d(y,"PowerEase",function(){return wt}),f.d(y,"QuadraticEase",function(){return It}),f.d(y,"QuarticEase",function(){return Pt}),f.d(y,"QuinticEase",function(){return Ot}),f.d(y,"SineEase",function(){return on}),f.d(y,"BezierCurveEase",function(){return Zt}),f.d(y,"RuntimeAnimation",function(){return me}),f.d(y,"AnimationEvent",function(){return tn}),f.d(y,"AnimationKeyInterpolation",function(){return K}),f.d(y,"AnimationRange",function(){return G}),f.d(y,"KeepAssets",function(){return Pn}),f.d(y,"InstantiatedEntries",function(){return nn}),f.d(y,"AssetContainer",function(){return xn}),f.d(y,"Analyser",function(){return Cn}),f.d(y,"AudioEngine",function(){return dr}),f.d(y,"AudioSceneComponent",function(){return ni}),f.d(y,"Sound",function(){return ti}),f.d(y,"SoundTrack",function(){return Lo}),f.d(y,"WeightedSound",function(){return Of}),f.d(y,"AutoRotationBehavior",function(){return fl}),f.d(y,"BouncingBehavior",function(){return pl}),f.d(y,"FramingBehavior",function(){return _l}),f.d(y,"AttachToBoxBehavior",function(){return Mf}),f.d(y,"FadeInOutBehavior",function(){return If}),f.d(y,"MultiPointerScaleBehavior",function(){return Df}),f.d(y,"PointerDragBehavior",function(){return yi.a}),f.d(y,"SixDofDragBehavior",function(){return ml}),f.d(y,"Bone",function(){return Be}),f.d(y,"BoneIKController",function(){return Lf}),f.d(y,"BoneLookController",function(){return Nf}),f.d(y,"Skeleton",function(){return No}),f.d(y,"ArcRotateCameraGamepadInput",function(){return ja}),f.d(y,"ArcRotateCameraKeyboardMoveInput",function(){return Ha}),f.d(y,"ArcRotateCameraMouseWheelInput",function(){return Wa}),f.d(y,"ArcRotateCameraPointersInput",function(){return Xa}),f.d(y,"ArcRotateCameraVRDeviceOrientationInput",function(){return Ya}),f.d(y,"FlyCameraKeyboardInput",function(){return Ka}),f.d(y,"FlyCameraMouseInput",function(){return Qa}),f.d(y,"FollowCameraKeyboardMoveInput",function(){return qa}),f.d(y,"FollowCameraMouseWheelInput",function(){return Za}),f.d(y,"FollowCameraPointersInput",function(){return Ja}),f.d(y,"FreeCameraDeviceOrientationInput",function(){return is}),f.d(y,"FreeCameraGamepadInput",function(){return rs}),f.d(y,"FreeCameraKeyboardMoveInput",function(){return $a}),f.d(y,"FreeCameraMouseInput",function(){return es}),f.d(y,"FreeCameraMouseWheelInput",function(){return ts}),f.d(y,"FreeCameraTouchInput",function(){return ns}),f.d(y,"FreeCameraVirtualJoystickInput",function(){return as}),f.d(y,"CameraInputTypes",function(){return hn}),f.d(y,"CameraInputsManager",function(){return $r}),f.d(y,"Camera",function(){return gt.a}),f.d(y,"TargetCamera",function(){return Ni}),f.d(y,"FreeCamera",function(){return Kn}),f.d(y,"FreeCameraInputsManager",function(){return eo}),f.d(y,"TouchCamera",function(){return ss}),f.d(y,"ArcRotateCamera",function(){return Ji}),f.d(y,"ArcRotateCameraInputsManager",function(){return wo}),f.d(y,"DeviceOrientationCamera",function(){return Fo}),f.d(y,"FlyCamera",function(){return Bf}),f.d(y,"FlyCameraInputsManager",function(){return Sl}),f.d(y,"FollowCamera",function(){return Pl}),f.d(y,"ArcFollowCamera",function(){return xl}),f.d(y,"FollowCameraInputsManager",function(){return Al}),f.d(y,"GamepadCamera",function(){return Bo}),f.d(y,"AnaglyphArcRotateCamera",function(){return Dl}),f.d(y,"AnaglyphFreeCamera",function(){return Ll}),f.d(y,"AnaglyphGamepadCamera",function(){return Nl}),f.d(y,"AnaglyphUniversalCamera",function(){return wl}),f.d(y,"StereoscopicArcRotateCamera",function(){return Fl}),f.d(y,"StereoscopicFreeCamera",function(){return Bl}),f.d(y,"StereoscopicGamepadCamera",function(){return Ul}),f.d(y,"StereoscopicUniversalCamera",function(){return Vl}),f.d(y,"UniversalCamera",function(){return _r}),f.d(y,"VirtualJoysticksCamera",function(){return kl}),f.d(y,"VRCameraMetrics",function(){return mr}),f.d(y,"VRDeviceOrientationArcRotateCamera",function(){return Hl}),f.d(y,"VRDeviceOrientationFreeCamera",function(){return Uo}),f.d(y,"VRDeviceOrientationGamepadCamera",function(){return Wl}),f.d(y,"OnAfterEnteringVRObservableEvent",function(){return Yf}),f.d(y,"VRExperienceHelper",function(){return Ql}),f.d(y,"WebVRFreeCamera",function(){return ko}),f.d(y,"Collider",function(){return ql}),f.d(y,"DefaultCollisionCoordinator",function(){return Zl}),f.d(y,"PickingInfo",function(){return nr.a}),f.d(y,"IntersectionInfo",function(){return Kf.a}),f.d(y,"_MeshCollisionData",function(){return Qf.a}),f.d(y,"BoundingBox",function(){return ms.a}),f.d(y,"BoundingInfo",function(){return Vi.a}),f.d(y,"BoundingSphere",function(){return Jl.a}),f.d(y,"Octree",function(){return no}),f.d(y,"OctreeBlock",function(){return $l}),f.d(y,"OctreeSceneComponent",function(){return Ts}),f.d(y,"Ray",function(){return fn.a}),f.d(y,"AxesViewer",function(){return ir.AxesViewer}),f.d(y,"BoneAxesViewer",function(){return ir.BoneAxesViewer}),f.d(y,"DebugLayerTab",function(){return ir.DebugLayerTab}),f.d(y,"DebugLayer",function(){return ir.DebugLayer}),f.d(y,"PhysicsViewer",function(){return ir.PhysicsViewer}),f.d(y,"RayHelper",function(){return ir.RayHelper}),f.d(y,"SkeletonViewer",function(){return ir.SkeletonViewer}),f.d(y,"DeviceInputSystem",function(){return eu}),f.d(y,"DeviceType",function(){return Kt}),f.d(y,"PointerInput",function(){return gs}),f.d(y,"DualShockInput",function(){return vs}),f.d(y,"XboxInput",function(){return bs}),f.d(y,"SwitchInput",function(){return ys}),f.d(y,"DeviceSource",function(){return tu}),f.d(y,"DeviceSourceManager",function(){return qf}),f.d(y,"Constants",function(){return h.a}),f.d(y,"ThinEngine",function(){return Bt.a}),f.d(y,"Engine",function(){return Ue.a}),f.d(y,"EngineStore",function(){return te.a}),f.d(y,"NullEngineOptions",function(){return nu.b}),f.d(y,"NullEngine",function(){return nu.a}),f.d(y,"_OcclusionDataStorage",function(){return ru}),f.d(y,"_forceTransformFeedbackToBundle",function(){return Zf}),f.d(y,"EngineView",function(){return Jf}),f.d(y,"WebGLPipelineContext",function(){return ep.a}),f.d(y,"WebGL2ShaderProcessor",function(){return ou.a}),f.d(y,"NativeEngine",function(){return op}),f.d(y,"ShaderCodeInliner",function(){return Ss}),f.d(y,"PerformanceConfigurator",function(){return ap.a}),f.d(y,"KeyboardEventTypes",function(){return Zi.a}),f.d(y,"KeyboardInfo",function(){return Zi.b}),f.d(y,"KeyboardInfoPre",function(){return Zi.c}),f.d(y,"PointerEventTypes",function(){return Tt.a}),f.d(y,"PointerInfoBase",function(){return Tt.c}),f.d(y,"PointerInfoPre",function(){return Tt.d}),f.d(y,"PointerInfo",function(){return Tt.b}),f.d(y,"ClipboardEventTypes",function(){return Ho}),f.d(y,"ClipboardInfo",function(){return sp}),f.d(y,"DaydreamController",function(){return Ps}),f.d(y,"GearVRController",function(){return xs}),f.d(y,"GenericController",function(){return Wo}),f.d(y,"OculusTouchController",function(){return Cs}),f.d(y,"PoseEnabledControllerType",function(){return ri}),f.d(y,"PoseEnabledControllerHelper",function(){return wi}),f.d(y,"PoseEnabledController",function(){return pr}),f.d(y,"ViveController",function(){return lu}),f.d(y,"WebVRController",function(){return Bi}),f.d(y,"WindowsMotionController",function(){return Xo}),f.d(y,"XRWindowsMotionController",function(){return lp}),f.d(y,"StickValues",function(){return wf}),f.d(y,"Gamepad",function(){return dn}),f.d(y,"GenericPad",function(){return yl}),f.d(y,"GamepadManager",function(){return Ol}),f.d(y,"GamepadSystemSceneComponent",function(){return Ml}),f.d(y,"Xbox360Button",function(){return Rn}),f.d(y,"Xbox360Dpad",function(){return $i}),f.d(y,"Xbox360Pad",function(){return Cl}),f.d(y,"DualShockButton",function(){return Gn}),f.d(y,"DualShockDpad",function(){return er}),f.d(y,"DualShockPad",function(){return Rl}),f.d(y,"AxisDragGizmo",function(){return Yo.a}),f.d(y,"AxisScaleGizmo",function(){return oo}),f.d(y,"BoundingBoxGizmo",function(){return uu}),f.d(y,"Gizmo",function(){return wn.a}),f.d(y,"GizmoManager",function(){return up}),f.d(y,"PlaneRotationGizmo",function(){return Ko}),f.d(y,"PositionGizmo",function(){return du}),f.d(y,"RotationGizmo",function(){return hu}),f.d(y,"ScaleGizmo",function(){return fu}),f.d(y,"LightGizmo",function(){return hp}),f.d(y,"CameraGizmo",function(){return fp}),f.d(y,"PlaneDragGizmo",function(){return Qo}),f.d(y,"EnvironmentHelper",function(){return Ls}),f.d(y,"PhotoDome",function(){return Pp}),f.d(y,"_forceSceneHelpersToBundle",function(){return m_}),f.d(y,"VideoDome",function(){return g_}),f.d(y,"EngineInstrumentation",function(){return v_}),f.d(y,"SceneInstrumentation",function(){return b_}),f.d(y,"_TimeToken",function(){return iu}),f.d(y,"EffectLayer",function(){return po}),f.d(y,"EffectLayerSceneComponent",function(){return Mu}),f.d(y,"GlowLayer",function(){return ra}),f.d(y,"HighlightLayer",function(){return Gs}),f.d(y,"Layer",function(){return C_}),f.d(y,"LayerSceneComponent",function(){return Du}),f.d(y,"LensFlare",function(){return Lu}),f.d(y,"LensFlareSystem",function(){return zs}),f.d(y,"LensFlareSystemSceneComponent",function(){return Nu}),f.d(y,"Light",function(){return Ci.a}),f.d(y,"ShadowLight",function(){return qo}),f.d(y,"ShadowGenerator",function(){return Un}),f.d(y,"CascadedShadowGenerator",function(){return js}),f.d(y,"ShadowGeneratorSceneComponent",function(){return Gu}),f.d(y,"DirectionalLight",function(){return Os}),f.d(y,"HemisphericLight",function(){return Vo.a}),f.d(y,"PointLight",function(){return Hs}),f.d(y,"SpotLight",function(){return Ms}),f.d(y,"DefaultLoadingScreen",function(){return zu}),f.d(y,"_BabylonLoaderRegistered",function(){return X_}),f.d(y,"BabylonFileLoaderConfiguration",function(){return la}),f.d(y,"SceneLoaderAnimationGroupLoadingMode",function(){return Pi}),f.d(y,"SceneLoader",function(){return Ut}),f.d(y,"SceneLoaderFlags",function(){return xi.a}),f.d(y,"BackgroundMaterial",function(){return so}),f.d(y,"ColorCurves",function(){return K_.a}),f.d(y,"EffectFallbacks",function(){return Sr.a}),f.d(y,"Effect",function(){return ze.a}),f.d(y,"FresnelParameters",function(){return eh}),f.d(y,"ImageProcessingConfigurationDefines",function(){return yn.b}),f.d(y,"ImageProcessingConfiguration",function(){return yn.a}),f.d(y,"Material",function(){return Ht.a}),f.d(y,"MaterialDefines",function(){return Jo.a}),f.d(y,"ThinMaterialHelper",function(){return th.a}),f.d(y,"MaterialHelper",function(){return et.a}),f.d(y,"MultiMaterial",function(){return rr.a}),f.d(y,"PBRMaterialDefines",function(){return ws}),f.d(y,"PBRBaseMaterial",function(){return _n}),f.d(y,"PBRBaseSimpleMaterial",function(){return Qs}),f.d(y,"PBRMaterial",function(){return uo}),f.d(y,"PBRMetallicRoughnessMaterial",function(){return nh}),f.d(y,"PBRSpecularGlossinessMaterial",function(){return ih}),f.d(y,"PushMaterial",function(){return $o.a}),f.d(y,"ShaderMaterial",function(){return ua.a}),f.d(y,"StandardMaterialDefines",function(){return Ft.b}),f.d(y,"StandardMaterial",function(){return Ft.a}),f.d(y,"BaseTexture",function(){return zn.a}),f.d(y,"ColorGradingTexture",function(){return rh}),f.d(y,"CubeTexture",function(){return ai}),f.d(y,"DynamicTexture",function(){return Ti.a}),f.d(y,"EquiRectangularCubeTexture",function(){return oh}),f.d(y,"HDRFiltering",function(){return Xu}),f.d(y,"HDRCubeTexture",function(){return aa}),f.d(y,"HtmlElementTexture",function(){return Q_}),f.d(y,"InternalTextureSource",function(){return Ct.b}),f.d(y,"InternalTexture",function(){return Ct.a}),f.d(y,"_DDSTextureLoader",function(){return vu}),f.d(y,"_ENVTextureLoader",function(){return bu}),f.d(y,"_KTXTextureLoader",function(){return yu}),f.d(y,"_TGATextureLoader",function(){return ah}),f.d(y,"_BasisTextureLoader",function(){return sh}),f.d(y,"MirrorTexture",function(){return Ds}),f.d(y,"MultiRenderTarget",function(){return qs}),f.d(y,"TexturePacker",function(){return J_}),f.d(y,"TexturePackerFrame",function(){return Zs}),f.d(y,"CustomProceduralTexture",function(){return em}),f.d(y,"NoiseProceduralTexture",function(){return lh}),f.d(y,"ProceduralTexture",function(){return go}),f.d(y,"ProceduralTextureSceneComponent",function(){return ch}),f.d(y,"RawCubeTexture",function(){return nm}),f.d(y,"RawTexture",function(){return ii}),f.d(y,"RawTexture2DArray",function(){return im}),f.d(y,"RawTexture3D",function(){return rm}),f.d(y,"RefractionTexture",function(){return om}),f.d(y,"RenderTargetTexture",function(){return sn}),f.d(y,"Texture",function(){return we.a}),f.d(y,"VideoTexture",function(){return Ou}),f.d(y,"UniformBuffer",function(){return Gl.a}),f.d(y,"MaterialFlags",function(){return ut.a}),f.d(y,"NodeMaterialBlockTargets",function(){return Ce}),f.d(y,"NodeMaterialBlockConnectionPointTypes",function(){return le}),f.d(y,"NodeMaterialBlockConnectionPointMode",function(){return bn}),f.d(y,"NodeMaterialSystemValues",function(){return bt}),f.d(y,"NodeMaterialModes",function(){return Mn}),f.d(y,"NodeMaterialConnectionPointCompatibilityStates",function(){return li}),f.d(y,"NodeMaterialConnectionPointDirection",function(){return Tn}),f.d(y,"NodeMaterialConnectionPoint",function(){return da}),f.d(y,"NodeMaterialBlock",function(){return pt}),f.d(y,"NodeMaterialDefines",function(){return To}),f.d(y,"NodeMaterial",function(){return ga}),f.d(y,"VertexOutputBlock",function(){return vo}),f.d(y,"BonesBlock",function(){return ph}),f.d(y,"InstancesBlock",function(){return _h}),f.d(y,"MorphTargetsBlock",function(){return mh}),f.d(y,"LightInformationBlock",function(){return gh}),f.d(y,"FragmentOutputBlock",function(){return Lr}),f.d(y,"ImageProcessingBlock",function(){return vh}),f.d(y,"PerturbNormalBlock",function(){return bh}),f.d(y,"DiscardBlock",function(){return yh}),f.d(y,"FrontFacingBlock",function(){return Th}),f.d(y,"DerivativeBlock",function(){return Eh}),f.d(y,"FragCoordBlock",function(){return Sh}),f.d(y,"ScreenSizeBlock",function(){return Ah}),f.d(y,"FogBlock",function(){return Ph}),f.d(y,"LightBlock",function(){return xh}),f.d(y,"TextureBlock",function(){return Ch}),f.d(y,"ReflectionTextureBlock",function(){return Rh}),f.d(y,"CurrentScreenBlock",function(){return $s}),f.d(y,"InputBlock",function(){return At}),f.d(y,"AnimatedInputBlockTypes",function(){return ji}),f.d(y,"MultiplyBlock",function(){return pa}),f.d(y,"AddBlock",function(){return Oh}),f.d(y,"ScaleBlock",function(){return Mh}),f.d(y,"ClampBlock",function(){return Ih}),f.d(y,"CrossBlock",function(){return Dh}),f.d(y,"DotBlock",function(){return Lh}),f.d(y,"TransformBlock",function(){return fa}),f.d(y,"RemapBlock",function(){return ic}),f.d(y,"NormalizeBlock",function(){return Nh}),f.d(y,"TrigonometryBlockOperations",function(){return rn}),f.d(y,"TrigonometryBlock",function(){return uc}),f.d(y,"ColorMergerBlock",function(){return wh}),f.d(y,"VectorMergerBlock",function(){return bo}),f.d(y,"ColorSplitterBlock",function(){return lc}),f.d(y,"VectorSplitterBlock",function(){return Fh}),f.d(y,"LerpBlock",function(){return Bh}),f.d(y,"DivideBlock",function(){return Uh}),f.d(y,"SubtractBlock",function(){return Vh}),f.d(y,"StepBlock",function(){return kh}),f.d(y,"OneMinusBlock",function(){return fc}),f.d(y,"ViewDirectionBlock",function(){return pc}),f.d(y,"FresnelBlock",function(){return Gh}),f.d(y,"MaxBlock",function(){return zh}),f.d(y,"MinBlock",function(){return jh}),f.d(y,"DistanceBlock",function(){return Hh}),f.d(y,"LengthBlock",function(){return Wh}),f.d(y,"NegateBlock",function(){return Xh}),f.d(y,"PowBlock",function(){return Yh}),f.d(y,"RandomNumberBlock",function(){return Kh}),f.d(y,"ArcTan2Block",function(){return Qh}),f.d(y,"SmoothStepBlock",function(){return qh}),f.d(y,"ReciprocalBlock",function(){return Zh}),f.d(y,"ReplaceColorBlock",function(){return Jh}),f.d(y,"PosterizeBlock",function(){return $h}),f.d(y,"WaveBlockKind",function(){return or}),f.d(y,"WaveBlock",function(){return ed}),f.d(y,"GradientBlockColorStep",function(){return va}),f.d(y,"GradientBlock",function(){return td}),f.d(y,"NLerpBlock",function(){return nd}),f.d(y,"WorleyNoise3DBlock",function(){return id}),f.d(y,"SimplexPerlin3DBlock",function(){return rd}),f.d(y,"NormalBlendBlock",function(){return od}),f.d(y,"Rotate2dBlock",function(){return ad}),f.d(y,"ReflectBlock",function(){return sd}),f.d(y,"RefractBlock",function(){return cd}),f.d(y,"DesaturateBlock",function(){return ld}),f.d(y,"PBRMetallicRoughnessBlock",function(){return ud}),f.d(y,"SheenBlock",function(){return _c}),f.d(y,"AnisotropyBlock",function(){return mc}),f.d(y,"ReflectionBlock",function(){return gc}),f.d(y,"ClearCoatBlock",function(){return ba}),f.d(y,"RefractionBlock",function(){return vc}),f.d(y,"SubSurfaceBlock",function(){return ya}),f.d(y,"ParticleTextureBlock",function(){return ec}),f.d(y,"ParticleRampGradientBlock",function(){return tc}),f.d(y,"ParticleBlendMultiplyBlock",function(){return nc}),f.d(y,"ModBlock",function(){return hd}),f.d(y,"NodeMaterialOptimizer",function(){return um}),f.d(y,"PropertyTypeForEdition",function(){return Lt}),f.d(y,"editableInPropertyPage",function(){return Vt}),f.d(y,"EffectRenderer",function(){return Hu}),f.d(y,"EffectWrapper",function(){return Wu}),f.d(y,"ShadowDepthWrapper",function(){return fm}),f.d(y,"Scalar",function(){return $.a}),f.d(y,"extractMinAndMaxIndexed",function(){return dd.b}),f.d(y,"extractMinAndMax",function(){return dd.a}),f.d(y,"Space",function(){return ye.c}),f.d(y,"Axis",function(){return ye.a}),f.d(y,"Coordinate",function(){return ye.b}),f.d(y,"Color3",function(){return M.a}),f.d(y,"Color4",function(){return M.b}),f.d(y,"TmpColors",function(){return M.c}),f.d(y,"ToGammaSpace",function(){return Gt.b}),f.d(y,"ToLinearSpace",function(){return Gt.c}),f.d(y,"Epsilon",function(){return Gt.a}),f.d(y,"Frustum",function(){return jl.a}),f.d(y,"Orientation",function(){return qe.e}),f.d(y,"BezierCurve",function(){return qe.c}),f.d(y,"Angle",function(){return qe.a}),f.d(y,"Arc2",function(){return qe.b}),f.d(y,"Path2",function(){return qe.f}),f.d(y,"Path3D",function(){return qe.g}),f.d(y,"Curve3",function(){return qe.d}),f.d(y,"Plane",function(){return vr.a}),f.d(y,"Size",function(){return oe.a}),f.d(y,"Vector2",function(){return u.d}),f.d(y,"Vector3",function(){return u.e}),f.d(y,"Vector4",function(){return u.f}),f.d(y,"Quaternion",function(){return u.b}),f.d(y,"Matrix",function(){return u.a}),f.d(y,"TmpVectors",function(){return u.c}),f.d(y,"PositionNormalVertex",function(){return Is}),f.d(y,"PositionNormalTextureVertex",function(){return dp}),f.d(y,"Viewport",function(){return Qn.a}),f.d(y,"SphericalHarmonics",function(){return Es}),f.d(y,"SphericalPolynomial",function(){return ro}),f.d(y,"AbstractMesh",function(){return Dt.a}),f.d(y,"Buffer",function(){return Oe.a}),f.d(y,"VertexBuffer",function(){return Oe.b}),f.d(y,"DracoCompression",function(){return _m}),f.d(y,"CSG",function(){return vm}),f.d(y,"Geometry",function(){return Ws.a}),f.d(y,"GroundMesh",function(){return zo}),f.d(y,"TrailMesh",function(){return bm}),f.d(y,"InstancedMesh",function(){return ym.a}),f.d(y,"LinesMesh",function(){return So.b}),f.d(y,"InstancedLinesMesh",function(){return So.a}),f.d(y,"_CreationDataStorage",function(){return De.b}),f.d(y,"_InstancesBatch",function(){return De.c}),f.d(y,"Mesh",function(){return De.a}),f.d(y,"VertexData",function(){return ft.a}),f.d(y,"MeshBuilder",function(){return Sm}),f.d(y,"SimplificationSettings",function(){return Am}),f.d(y,"SimplificationQueue",function(){return vd}),f.d(y,"SimplificationType",function(){return xo}),f.d(y,"QuadraticErrorSimplification",function(){return yd}),f.d(y,"SimplicationQueueSceneComponent",function(){return Td}),f.d(y,"Polygon",function(){return Em}),f.d(y,"PolygonMeshBuilder",function(){return md}),f.d(y,"SubMesh",function(){return Eo.a}),f.d(y,"MeshLODLevel",function(){return Rm.a}),f.d(y,"TransformNode",function(){return Er.a}),f.d(y,"BoxBuilder",function(){return Tr.a}),f.d(y,"TiledBoxBuilder",function(){return _d}),f.d(y,"DiscBuilder",function(){return Ta}),f.d(y,"RibbonBuilder",function(){return Ao.a}),f.d(y,"SphereBuilder",function(){return Fn.a}),f.d(y,"HemisphereBuilder",function(){return Zo}),f.d(y,"CylinderBuilder",function(){return pi.a}),f.d(y,"TorusBuilder",function(){return gr}),f.d(y,"TorusKnotBuilder",function(){return Tc}),f.d(y,"LinesBuilder",function(){return cn.a}),f.d(y,"PolygonBuilder",function(){return Po}),f.d(y,"ShapeBuilder",function(){return ca.a}),f.d(y,"LatheBuilder",function(){return Sc}),f.d(y,"PlaneBuilder",function(){return Rs.a}),f.d(y,"TiledPlaneBuilder",function(){return gd}),f.d(y,"GroundBuilder",function(){return Ui}),f.d(y,"TubeBuilder",function(){return Ac}),f.d(y,"PolyhedronBuilder",function(){return ao}),f.d(y,"IcoSphereBuilder",function(){return Pc}),f.d(y,"DecalBuilder",function(){return xc}),f.d(y,"CapsuleBuilder",function(){return Cc}),f.d(y,"DataBuffer",function(){return au.a}),f.d(y,"WebGLDataBuffer",function(){return Om.a}),f.d(y,"MorphTarget",function(){return Yu}),f.d(y,"MorphTargetManager",function(){return sa}),f.d(y,"RecastJSPlugin",function(){return Mm}),f.d(y,"RecastJSCrowd",function(){return Ed}),f.d(y,"Node",function(){return Q.a}),f.d(y,"Database",function(){return Sd}),f.d(y,"BaseParticleSystem",function(){return yo}),f.d(y,"BoxParticleEmitter",function(){return Nr}),f.d(y,"ConeParticleEmitter",function(){return rc}),f.d(y,"CylinderParticleEmitter",function(){return _a}),f.d(y,"CylinderDirectedParticleEmitter",function(){return oc}),f.d(y,"HemisphericParticleEmitter",function(){return ac}),f.d(y,"PointParticleEmitter",function(){return sc}),f.d(y,"SphereParticleEmitter",function(){return ma}),f.d(y,"SphereDirectedParticleEmitter",function(){return cc}),f.d(y,"CustomParticleEmitter",function(){return wr}),f.d(y,"MeshParticleEmitter",function(){return dh}),f.d(y,"GPUParticleSystem",function(){return ar}),f.d(y,"Particle",function(){return Pd}),f.d(y,"ParticleHelper",function(){return Um}),f.d(y,"ParticleSystem",function(){return ln}),f.d(y,"ParticleSystemSet",function(){return Ea}),f.d(y,"SolidParticle",function(){return Mc}),f.d(y,"ModelShape",function(){return Ic}),f.d(y,"DepthSortedParticle",function(){return xd}),f.d(y,"SolidParticleVertex",function(){return Cd}),f.d(y,"SolidParticleSystem",function(){return Vm}),f.d(y,"CloudPoint",function(){return Rd}),f.d(y,"PointsGroup",function(){return Sa}),f.d(y,"PointColor",function(){return En}),f.d(y,"PointsCloudSystem",function(){return km}),f.d(y,"SubEmitterType",function(){return Fr}),f.d(y,"SubEmitter",function(){return Co}),f.d(y,"PhysicsEngine",function(){return Ir}),f.d(y,"PhysicsEngineSceneComponent",function(){return Od}),f.d(y,"PhysicsHelper",function(){return Gm}),f.d(y,"PhysicsRadialExplosionEventOptions",function(){return Ur}),f.d(y,"PhysicsUpdraftEventOptions",function(){return Dc}),f.d(y,"PhysicsVortexEventOptions",function(){return Lc}),f.d(y,"PhysicsRadialImpulseFalloff",function(){return Ro}),f.d(y,"PhysicsUpdraftMode",function(){return Br}),f.d(y,"PhysicsImpostor",function(){return xt.a}),f.d(y,"PhysicsJoint",function(){return en.e}),f.d(y,"DistanceJoint",function(){return en.a}),f.d(y,"MotorEnabledJoint",function(){return en.d}),f.d(y,"HingeJoint",function(){return en.c}),f.d(y,"Hinge2Joint",function(){return en.b}),f.d(y,"CannonJSPlugin",function(){return Ks}),f.d(y,"AmmoJSPlugin",function(){return Qu}),f.d(y,"OimoJSPlugin",function(){return Ku}),f.d(y,"AnaglyphPostProcess",function(){return ls}),f.d(y,"BlackAndWhitePostProcess",function(){return Id}),f.d(y,"BloomEffect",function(){return Fc}),f.d(y,"BloomMergePostProcess",function(){return wc}),f.d(y,"BlurPostProcess",function(){return gn}),f.d(y,"ChromaticAberrationPostProcess",function(){return Bc}),f.d(y,"CircleOfConfusionPostProcess",function(){return Uc}),f.d(y,"ColorCorrectionPostProcess",function(){return Dd}),f.d(y,"ConvolutionPostProcess",function(){return Ld}),f.d(y,"DepthOfFieldBlurPostProcess",function(){return Aa}),f.d(y,"DepthOfFieldEffectBlurLevel",function(){return sr}),f.d(y,"DepthOfFieldEffect",function(){return Vc}),f.d(y,"DepthOfFieldMergePostProcessOptions",function(){return $m}),f.d(y,"DepthOfFieldMergePostProcess",function(){return Nd}),f.d(y,"DisplayPassPostProcess",function(){return wd}),f.d(y,"ExtractHighlightsPostProcess",function(){return Nc}),f.d(y,"FilterPostProcess",function(){return Fd}),f.d(y,"FxaaPostProcess",function(){return Oo}),f.d(y,"GrainPostProcess",function(){return kc}),f.d(y,"HighlightsPostProcess",function(){return ag}),f.d(y,"ImageProcessingPostProcess",function(){return Go}),f.d(y,"MotionBlurPostProcess",function(){return Gc}),f.d(y,"PassPostProcess",function(){return Fi}),f.d(y,"PassCubePostProcess",function(){return Gf}),f.d(y,"PostProcess",function(){return _t}),f.d(y,"PostProcessManager",function(){return hs.a}),f.d(y,"RefractionPostProcess",function(){return Ud}),f.d(y,"DefaultRenderingPipeline",function(){return Gd}),f.d(y,"LensRenderingPipeline",function(){return _g}),f.d(y,"SSAO2RenderingPipeline",function(){return zd}),f.d(y,"SSAORenderingPipeline",function(){return yg}),f.d(y,"StandardRenderingPipeline",function(){return jd}),f.d(y,"PostProcessRenderEffect",function(){return Rt}),f.d(y,"PostProcessRenderPipeline",function(){return Vr}),f.d(y,"PostProcessRenderPipelineManager",function(){return Vd}),f.d(y,"PostProcessRenderPipelineManagerSceneComponent",function(){return kd}),f.d(y,"SharpenPostProcess",function(){return zc}),f.d(y,"StereoscopicInterlacePostProcessI",function(){return Pg}),f.d(y,"StereoscopicInterlacePostProcess",function(){return xg}),f.d(y,"TonemappingOperator",function(){return cr}),f.d(y,"TonemapPostProcess",function(){return Rg}),f.d(y,"VolumetricLightScatteringPostProcess",function(){return Hd}),f.d(y,"VRDistortionCorrectionPostProcess",function(){return us}),f.d(y,"VRMultiviewToSingleviewPostProcess",function(){return ds}),f.d(y,"ScreenSpaceReflectionPostProcess",function(){return jc}),f.d(y,"ScreenSpaceCurvaturePostProcess",function(){return Wd}),f.d(y,"ReflectionProbe",function(){return qu}),f.d(y,"BoundingBoxRenderer",function(){return Xd}),f.d(y,"DepthRenderer",function(){return oa}),f.d(y,"DepthRendererSceneComponent",function(){return Yd}),f.d(y,"EdgesRenderer",function(){return Hc}),f.d(y,"LineEdgesRenderer",function(){return Kd}),f.d(y,"GeometryBufferRenderer",function(){return ui}),f.d(y,"GeometryBufferRendererSceneComponent",function(){return Bd}),f.d(y,"PrePassRenderer",function(){return Wc}),f.d(y,"PrePassRendererSceneComponent",function(){return Qd}),f.d(y,"SubSurfaceSceneComponent",function(){return Zd}),f.d(y,"OutlineRenderer",function(){return Jd}),f.d(y,"RenderingGroup",function(){return Gg.a}),f.d(y,"RenderingGroupInfo",function(){return to.a}),f.d(y,"RenderingManager",function(){return to.b}),f.d(y,"UtilityLayerRenderer",function(){return On.a}),f.d(y,"Scene",function(){return _e.a}),f.d(y,"SceneComponentConstants",function(){return at.a}),f.d(y,"Stage",function(){return at.b}),f.d(y,"Sprite",function(){return $d}),f.d(y,"SpriteManager",function(){return tf}),f.d(y,"SpriteMap",function(){return Yg}),f.d(y,"SpritePackedManager",function(){return Kg}),f.d(y,"SpriteSceneComponent",function(){return ef}),f.d(y,"AlphaState",function(){return Qg.a}),f.d(y,"DepthCullingState",function(){return qg.a}),f.d(y,"StencilState",function(){return Zg.a}),f.d(y,"AndOrNotEvaluator",function(){return Jg.a}),f.d(y,"AssetTaskState",function(){return mi}),f.d(y,"AbstractAssetTask",function(){return gi}),f.d(y,"AssetsProgressEvent",function(){return nf}),f.d(y,"ContainerAssetTask",function(){return rf}),f.d(y,"MeshAssetTask",function(){return of}),f.d(y,"TextFileAssetTask",function(){return af}),f.d(y,"BinaryFileAssetTask",function(){return sf}),f.d(y,"ImageAssetTask",function(){return cf}),f.d(y,"TextureAssetTask",function(){return lf}),f.d(y,"CubeTextureAssetTask",function(){return uf}),f.d(y,"HDRCubeTextureAssetTask",function(){return hf}),f.d(y,"EquiRectangularCubeTextureAssetTask",function(){return df}),f.d(y,"AssetsManager",function(){return $g}),f.d(y,"BasisTranscodeConfiguration",function(){return q_}),f.d(y,"BasisTools",function(){return mo}),f.d(y,"DDSTools",function(){return Gi}),f.d(y,"expandToProperty",function(){return L.b}),f.d(y,"serialize",function(){return L.c}),f.d(y,"serializeAsTexture",function(){return L.m}),f.d(y,"serializeAsColor3",function(){return L.e}),f.d(y,"serializeAsFresnelParameters",function(){return L.h}),f.d(y,"serializeAsVector2",function(){return L.n}),f.d(y,"serializeAsVector3",function(){return L.o}),f.d(y,"serializeAsMeshReference",function(){return L.k}),f.d(y,"serializeAsColorCurves",function(){return L.g}),f.d(y,"serializeAsColor4",function(){return L.f}),f.d(y,"serializeAsImageProcessingConfiguration",function(){return L.i}),f.d(y,"serializeAsQuaternion",function(){return L.l}),f.d(y,"serializeAsMatrix",function(){return L.j}),f.d(y,"serializeAsCameraReference",function(){return L.d}),f.d(y,"SerializationHelper",function(){return L.a}),f.d(y,"Deferred",function(){return ev}),f.d(y,"EnvironmentTextureTools",function(){return Ai}),f.d(y,"MeshExploder",function(){return tv}),f.d(y,"FilesInput",function(){return nv}),f.d(y,"CubeMapToSphericalPolynomialTools",function(){return jo}),f.d(y,"HDRTools",function(){return ju}),f.d(y,"PanoramaToCubeMapTools",function(){return Xs}),f.d(y,"KhronosTextureContainer",function(){return ia}),f.d(y,"EventState",function(){return C.a}),f.d(y,"Observer",function(){return C.d}),f.d(y,"MultiObserver",function(){return C.b}),f.d(y,"Observable",function(){return C.c}),f.d(y,"PerformanceMonitor",function(){return ff.a}),f.d(y,"RollingAverage",function(){return ff.b}),f.d(y,"PromisePolyfill",function(){return iv.a}),f.d(y,"SceneOptimization",function(){return vi}),f.d(y,"TextureOptimization",function(){return Pa}),f.d(y,"HardwareScalingOptimization",function(){return Yc}),f.d(y,"ShadowsOptimization",function(){return xa}),f.d(y,"PostProcessesOptimization",function(){return Ca}),f.d(y,"LensFlaresOptimization",function(){return Ra}),f.d(y,"CustomOptimization",function(){return pf}),f.d(y,"ParticlesOptimization",function(){return Oa}),f.d(y,"RenderTargetsOptimization",function(){return Kc}),f.d(y,"MergeMeshesOptimization",function(){return Ma}),f.d(y,"SceneOptimizerOptions",function(){return Qc}),f.d(y,"SceneOptimizer",function(){return rv}),f.d(y,"SceneSerializer",function(){return Zc}),f.d(y,"SmartArray",function(){return fi.a}),f.d(y,"SmartArrayNoDuplicate",function(){return fi.b}),f.d(y,"StringDictionary",function(){return El.a}),f.d(y,"Tags",function(){return ov.a}),f.d(y,"TextureTools",function(){return av}),f.d(y,"TGATools",function(){return ha}),f.d(y,"Tools",function(){return Xe.b}),f.d(y,"className",function(){return Xe.c}),f.d(y,"AsyncLoop",function(){return Xe.a}),f.d(y,"VideoRecorder",function(){return sv}),f.d(y,"JoystickAxis",function(){return an}),f.d(y,"VirtualJoystick",function(){return os}),f.d(y,"WorkerPool",function(){return Bs}),f.d(y,"Logger",function(){return l.a}),f.d(y,"_TypeStore",function(){return R.a}),f.d(y,"FilesInputStore",function(){return As.a}),f.d(y,"DeepCopier",function(){return de.a}),f.d(y,"PivotTools",function(){return kn.a}),f.d(y,"PrecisionDate",function(){return be.a}),f.d(y,"ScreenshotTools",function(){return Mo}),f.d(y,"WebRequest",function(){return re.a}),f.d(y,"InspectableType",function(){return Xc}),f.d(y,"BRDFTextureTools",function(){return ea}),f.d(y,"RGBDTextureTools",function(){return pu}),f.d(y,"ColorGradient",function(){return Rc}),f.d(y,"Color3Gradient",function(){return Ad}),f.d(y,"FactorGradient",function(){return Oc}),f.d(y,"GradientHelper",function(){return In}),f.d(y,"PerfCounter",function(){return jn.a}),f.d(y,"RetryStrategy",function(){return cv.a}),f.d(y,"CanvasGenerator",function(){return fs.a}),f.d(y,"LoadFileError",function(){return io.b}),f.d(y,"RequestFileError",function(){return io.d}),f.d(y,"ReadFileError",function(){return io.c}),f.d(y,"FileTools",function(){return io.a}),f.d(y,"StringTools",function(){return qn.a}),f.d(y,"DataReader",function(){return lv}),f.d(y,"MinMaxReducer",function(){return Bu}),f.d(y,"DepthReducer",function(){return Uu}),f.d(y,"DataStorage",function(){return uv}),f.d(y,"SceneRecorder",function(){return hv}),f.d(y,"KhronosTextureContainer2",function(){return Us}),f.d(y,"Trajectory",function(){return dv}),f.d(y,"TrajectoryClassifier",function(){return fv}),f.d(y,"TimerState",function(){return zi}),f.d(y,"setAndStartTimer",function(){return ks}),f.d(y,"AdvancedTimer",function(){return p_}),f.d(y,"CopyTools",function(){return pv.a}),f.d(y,"WebXRCamera",function(){return Tu}),f.d(y,"WebXREnterExitUIButton",function(){return xu}),f.d(y,"WebXREnterExitUIOptions",function(){return f_}),f.d(y,"WebXREnterExitUI",function(){return Cu}),f.d(y,"WebXRExperienceHelper",function(){return Eu}),f.d(y,"WebXRInput",function(){return Pu}),f.d(y,"WebXRInputSource",function(){return Au}),f.d(y,"WebXRManagedOutputCanvasOptions",function(){return ps}),f.d(y,"WebXRManagedOutputCanvas",function(){return Xl}),f.d(y,"WebXRState",function(){return pn}),f.d(y,"WebXRTrackingState",function(){return tr}),f.d(y,"WebXRSessionManager",function(){return _s}),f.d(y,"WebXRDefaultExperienceOptions",function(){return __}),f.d(y,"WebXRDefaultExperience",function(){return Ru}),f.d(y,"WebXRFeatureName",function(){return si}),f.d(y,"WebXRFeaturesManager",function(){return Zn}),f.d(y,"WebXRAbstractFeature",function(){return ci}),f.d(y,"WebXRHitTestLegacy",function(){return Da}),f.d(y,"WebXRAnchorSystem",function(){return La}),f.d(y,"WebXRPlaneDetector",function(){return Na}),f.d(y,"WebXRBackgroundRemover",function(){return wa}),f.d(y,"WebXRMotionControllerTeleportation",function(){return fo}),f.d(y,"WebXRControllerPointerSelection",function(){return ho}),f.d(y,"IWebXRControllerPhysicsOptions",function(){return gv}),f.d(y,"WebXRControllerPhysics",function(){return Fa}),f.d(y,"WebXRHitTest",function(){return Ba}),f.d(y,"WebXRFeaturePointSystem",function(){return Ua}),f.d(y,"WebXRHand",function(){return vf}),f.d(y,"WebXRHandTracking",function(){return Va}),f.d(y,"WebXRAbstractMotionController",function(){return Rr}),f.d(y,"WebXRControllerComponent",function(){return Cr}),f.d(y,"WebXRGenericTriggerMotionController",function(){return Vs}),f.d(y,"WebXRMicrosoftMixedRealityController",function(){return bf}),f.d(y,"WebXRMotionControllerManager",function(){return Bn}),f.d(y,"WebXROculusTouchMotionController",function(){return $c}),f.d(y,"WebXRHTCViveMotionController",function(){return yf}),f.d(y,"WebXRProfiledMotionController",function(){return Su});var U=f(35),_=f(91),C=f(6),u=f(0),M=f(9),R=f(11),x=function(){function r(t,e){this.triggerOptions=t,this.onBeforeExecuteObservable=new C.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"]=x;var m=f(47),c=f(1),T=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},enumerable:!1,configurable:!0}),Object.defineProperty(t,"IsGreater",{get:function(){return t._IsGreater},enumerable:!1,configurable:!0}),Object.defineProperty(t,"IsLesser",{get:function(){return t._IsLesser},enumerable:!1,configurable:!0}),t.prototype.isValid=function(){switch(this.operator){case t.IsGreater:return this._effectiveTarget[this._property]>this.value;case t.IsLesser:return this._effectiveTarget[this._property]-1&&this._scene.actionManagers.splice(e,1)},t.prototype.getScene=function(){return this._scene},t.prototype.hasSpecificTriggers=function(e){for(var n=0;n-1)return!0}return!1},t.prototype.hasSpecificTriggers2=function(e,n){for(var i=0;i=t.OnPickTrigger&&n.trigger<=t.OnPointerOutTrigger)return!0}return!1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasPickTriggers",{get:function(){for(var e=0;e=t.OnPickTrigger&&n.trigger<=t.OnPickUpTrigger)return!0}return!1},enumerable:!1,configurable:!0}),t.prototype.registerAction=function(e){return e.trigger===t.OnEveryFrameTrigger&&this.getScene().actionManager!==this?(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;i0;if(F.type===2?ce.push(o):ce.push(z),ve){for(var Te=new Array,Re=0;Re0){var P=b.properties[0].value,O=b.properties[0].targetType===null?P:i.getMeshByName(P);O._meshId&&(O.mesh=i.getMeshByID(O._meshId)),p={trigger:t[b.name],parameter:O}}else p=t[b.name];for(var B=0;B=0?e:0;var s=0,d=a._keys[0],p=a._keys.length-1,b=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,B=d.frame,F=b.frame;if(n){var z=a.getRange(n);z&&(B=z.from,F=z.to)}var J=d.frame===B,ie=b.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>=b.frame&&(se=a._getKeyValue(b.value),P.referenceValue=se.clone?se.clone():se,O=!0);for(var ce=0;!O||!J||!ie&&ce=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&&B>=ue.frame&&B<=fe.frame){if(B===ue.frame)s=ce;else if(B===fe.frame)s=ce+1;else{ve={key:ce,repeatCount:0,loopMode:this.ANIMATIONLOOPMODE_CONSTANT};var Te={frame:B,value:(se=a._interpolate(B,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 b=i.beginAnimation(n,0,p,!1);return b.onAnimationEnd=d,b},Object.defineProperty(r.prototype,"runtimeAnimations",{get:function(){return this._runtimeAnimations},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"hasRunningRuntimeAnimations",{get:function(){for(var t=0,e=this._runtimeAnimations;t=0;a--)this._keys[a].frame>=i&&this._keys[a].frame<=o&&this._keys.splice(a,1);this._ranges[t]=null}},r.prototype.getRange=function(t){return this._ranges[t]},r.prototype.getKeys=function(){return this._keys},r.prototype.getHighestFrame=function(){for(var t=0,e=0,n=this._keys.length;e0)return e.highLimitValue.clone?e.highLimitValue.clone():e.highLimitValue;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=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),b=s.outTangent!==void 0&&a.inTangent!==void 0,P=a.frame-s.frame,O=(t-s.frame)/P,B=this.getEasingFunction();switch(B!=null&&(O=B.ease(O)),this.dataType){case r.ANIMATIONTYPE_FLOAT:var F=b?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=b?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=b?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=b?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);if(t.enableBlending=this.enableBlending,t.blendingSpeed=this.blendingSpeed,this._keys&&t.setKeys(this._keys),this._ranges)for(var e in t._ranges={},this._ranges){var n=this._ranges[e];n&&(t._ranges[e]=n.clone())}return t},r.prototype.setKeys=function(t){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=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 b=u.b.FromArray(p.values.slice(4,8));b.equals(u.b.Zero())||(s=b)}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;n0&&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-1&&this._animation.runtimeAnimations.splice(t,1)},r.prototype.setValue=function(t,e){if(this._targetIsArray)for(var n=0;ne[e.length-1].frame&&(t=e[e.length-1].frame);var n=this._events;if(n.length)for(var i=0;ithis._maxFrame)&&(e=this._minFrame),(nthis._maxFrame)&&(n=this._maxFrame);var b,P,O=n-e,B=t*(s.framePerSecond*o)/1e3+this._ratioOffset,F=0;if(this._previousDelay=t,this._previousRatio=B,!i&&n>=e&&B>=O)p=!1,F=s._getKeyValue(this._maxValue);else if(!i&&e>=n&&B<=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],b=this._offsetsCache[z]}if(b===void 0)switch(s.dataType){case k.ANIMATIONTYPE_FLOAT:b=0;break;case k.ANIMATIONTYPE_QUATERNION:b=Z;break;case k.ANIMATIONTYPE_VECTOR3:b=W;break;case k.ANIMATIONTYPE_VECTOR2:b=q;break;case k.ANIMATIONTYPE_SIZE:b=he;break;case k.ANIMATIONTYPE_COLOR3:b=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+B%O:n;var ce=this._events;if((O>0&&this.currentFrame>P||O<0&&this.currentFrame>0,this._animationState.highLimitValue=F,this._animationState.offsetValue=b;var fe=s._interpolate(P,this._animationState);if(this.setValue(fe,a),ce.length){for(ue=0;ue0&&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),Pe=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.getSkeleton().bones.indexOf(this):this._index},t.prototype.setParent=function(e,n){if(n===void 0&&(n=!0),this._parent!==e){if(this._parent){var i=this._parent.children.indexOf(this);i!==-1&&this._parent.children.splice(i,1)}this._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-1&&(this._scene._activeAnimatables.splice(e,1),this._scene._activeAnimatables.push(this))}return this},r.prototype.getAnimations=function(){return this._runtimeAnimations},r.prototype.appendAnimations=function(t,e){for(var n=this,i=0;i-1){for(var 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;i0)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;ne&&i>0&&(i*=-1),s&&this.stopAnimation(r,void 0,d),a||(a=new ke(this,r,t,e,n,i,o,void 0,p,b));var P=!d||d(r);if(r.animations&&P&&a.appendAnimations(r,r.animations),r.getAnimatables)for(var O=r.getAnimatables(),B=0;Bn&&o>0&&(o*=-1),new ke(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 b=r.getDescendants(t),P=[];P.push(this.beginDirectAnimation(r,e,n,i,o,a,s,d,p));for(var O=0,B=b;O0)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=p&&a.frame<=b&&(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,b+e),!0};var We=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}(),je=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 C.c,this.onAnimationLoopObservable=new C.c,this.onAnimationGroupLoopObservable=new C.c,this.onAnimationGroupEndObservable=new C.c,this.onAnimationGroupPauseObservable=new C.c,this.onAnimationGroupPlayObservable=new C.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;ei[0].frame&&(this._from=i[0].frame),this._tot){var s={frame:t,value:o.value,inTangent:o.inTangent,outTangent:o.outTangent,interpolation:o.interpolation};i.splice(0,0,s)}a.framei&&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-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=.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}(),nt=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}(Ge),$e=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}(Ge),ct=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),b=Math.floor(p),P=b+1,O=(1-Math.pow(i,b))/(a*s),B=.5*(O+(1-Math.pow(i,P))/(a*s)),F=e-B,z=B-O;return-Math.pow(1/i,n-b)/(z*z)*(F-z)*(F+z)},t}(Ge),st=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}(Ge),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}(Ge),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}(Ge),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}(Ge),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}(Ge),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}(Ge),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}(Ge),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}(Ge),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 qe.c.Interpolate(e,this.x1,this.y1,this.x2,this.y2)},t}(Ge),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),Pn=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return Object(c.d)(t,r),t}(U.a),nn=function(){this.rootNodes=[],this.skeletons=[],this.animationGroups=[]},xn=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=[],b={doNotInstantiate:!0},P=function(O,B){if(o[O.uniqueId]=B.uniqueId,a[B.uniqueId]=B,e&&(B.name=e(O.name)),B instanceof De.a){var F=B;if(F.morphTargetManager){var z=O.morphTargetManager;F.morphTargetManager=z.clone();for(var J=0;J-1&&d.animations.splice(J,1)}},b=0,P=s.animations;b0&&(B=!0,this._soundLoaded(e));break;case"String":O.push(e);case"Array":O.length===0&&(O=e);for(var F=0;F0&&(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,300)},n={autoplay:this.autoplay,loop:this.loop,volume:this._volume,spatialSound:this.spatialSound,maxDistance:this.maxDistance,useCustomAttenuation:this.useCustomAttenuation,rolloffFactor:this.rolloffFactor,refDistance:this.refDistance,distanceModel:this.distanceModel},i=new r(this.name+"_cloned",new ArrayBuffer(0),this._scene,null,n);return this.useCustomAttenuation&&i.setAttenuationFunction(this._customAttenuationFunction),i.setPosition(this._position),i.setPlaybackRate(this._playbackRate),e(),i},r.prototype.getAudioBuffer=function(){return this._audioBuffer},r.prototype.getSoundSource=function(){return this._soundSource},r.prototype.getSoundGain=function(){return this._soundGain},r.prototype.serialize=function(){var t={name:this.name,url:this.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 b=u.e.FromArray(t.position);s.setPosition(b)}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 An.a.WarnImport("AudioSceneComponent")},r}(),Lo=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;t0?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;d0?1/o:0,p=0;p0},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}(),pl=function(){function r(){this.transitionDuration=450,this.lowerRadiusTransitionRange=2,this.upperRadiusTransitionRange=-2,this._autoTransitionRange=!1,this._radiusIsAnimating=!1,this._radiusBounceTransition=null,this._animatables=new Array}return Object.defineProperty(r.prototype,"name",{get:function(){return"Bouncing"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"autoTransitionRange",{get:function(){return this._autoTransitionRange},set:function(t){var e=this;if(this._autoTransitionRange!==t){this._autoTransitionRange=t;var n=this._attachedCamera;n&&(t?this._onMeshTargetChangedObserver=n.onMeshTargetChangedObservable.add(function(i){if(i){i.computeWorldMatrix(!0);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 $e(.3),r.EasingMode=Ge.EASINGMODE_EASEOUT,r}(),_l=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},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;ap.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()},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=Ge.EASINGMODE_EASEINOUT,r.IgnoreBoundsSizeMode=0,r.FitFrustumSidesMode=1,r}(),fr=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},Mf=function(){function r(t){this.ui=t,this.name="AttachToBoxBehavior",this.distanceAwayFromFace=.15,this.distanceAwayFromBottomOfFace=.15,this._faceVectors=[new fr(u.e.Up()),new fr(u.e.Down()),new fr(u.e.Left()),new fr(u.e.Right()),new fr(u.e.Forward()),new fr(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.diff1)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"},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}(),yi=f(65),Df=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 yi.a({}),this._dragBehaviorA.moveAttached=!1,this._dragBehaviorB=new yi.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),ml=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 C.c,this.onDragObservable=new C.c,this.onDragEndObservable=new C.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 b=a.pickInfo.ray.origin.subtract(i);i.copyFrom(a.pickInfo.ray.origin);var P=-u.e.Dot(b,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._moving||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}(),Lf=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],b=r._tmpVecs[4],P=r._tmpQuat;t.getAbsolutePositionToRef(this.mesh,a),n.subtractToRef(a,b),b.x==0&&b.y==0&&b.z==0?b.y=1:b.normalize(),e.subtractToRef(a,p),p.normalize(),u.e.CrossToRef(p,b,s),s.normalize(),u.e.CrossToRef(p,s,d),d.normalize(),u.a.FromXYZAxesToRef(d,p,s,i);var O=this._bone1Length,B=this._bone2Length,F=u.e.Distance(a,e);this._maxReach>0&&(F=Math.min(this._maxReach,F));var z=(B*B+F*F-O*O)/(2*B*F),J=(F*F+O*O-B*B)/(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),ce=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}(),Nf=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,b=!1;if(this._maxYaw==Math.PI&&this._minYaw==-Math.PI||(p=!0),this._maxPitch==Math.PI&&this._minPitch==-Math.PI||(b=!0),p||b){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 B=u.e.Cross(d,F);B.normalize();var F=u.e.Cross(B,d);u.a.FromXYZAxesToRef(B,d,F,P)}else P.copyFrom(a.getWorldMatrix());P.invertToRef(O);var z=null;if(b){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):iethis._maxYaw||ceMath.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):ceMath.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);if(this._getAngleBetween(Te,ce)>this._getAngleBetween(Te,this._midYawConstraint)){z==null&&(z=Math.sqrt(J.x*J.x+J.z*J.z));var Re=this._getAngleBetween(Te,this._maxYaw);this._getAngleBetween(Te,this._minYaw)Math.PI?n-=2*Math.PI:n<-Math.PI&&(n+=2*Math.PI),n},r.prototype._getAngleBetween=function(t,e){var n=0;return(n=(t=(t%=2*Math.PI)<0?t+2*Math.PI:t)<(e=(e%=2*Math.PI)<0?e+2*Math.PI:e)?e-t:t-e)>Math.PI&&(n=2*Math.PI-n),n},r.prototype._isAngleBetween=function(t,e,n){if(t=(t%=2*Math.PI)<0?t+2*Math.PI:t,(e=(e%=2*Math.PI)<0?e+2*Math.PI:e)<(n=(n%=2*Math.PI)<0?n+2*Math.PI:n)){if(t>e&&tn&&t>Re,Ee=0;Ee<6;Ee++){var Se=Te[Re][Ee];ve&&(Se=gl(Se,Ae,Ae,i)),B.texImage2D(Ee,Re,fe,Ae,Ae,0,ue,ce,Se)}O._bindTextureDirectly(B.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=vl(!1),Bt.a.prototype.createRawTexture3D=vl(!0),Bt.a.prototype.updateRawTexture2DArray=bl(!1),Bt.a.prototype.updateRawTexture3D=bl(!0);var ii=function(r){function t(e,n,i,o,a,s,d,p,b){s===void 0&&(s=!0),d===void 0&&(d=!1),p===void 0&&(p=h.a.TEXTURE_TRILINEAR_SAMPLINGMODE),b===void 0&&(b=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,b),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),No=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._meshesWithPoseMatrix=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 C.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-1&&this._meshesWithPoseMatrix.splice(e,1)},r.prototype._computeTransformMatrices=function(t,e){this.onBeforeComputeObservable.notifyObservers(this);for(var n=0;n0)for(var t=0,e=this.bones;t0&&(s.animation=o.animations[0].serialize()),n.ranges=[],this._ranges){var p=this._ranges[d];if(p){var b={};b.name=d,b.from=p.from,b.to=p.to,n.ranges.push(b)}}}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-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;n0&&(t=this._meshesWithPoseMatrix[0].getPoseMatrix()),t},r.prototype.sortBones=function(){for(var t=new Array,e=new Array(this.bones.length),n=0;n=2&&(this._leftStick={x:this.browserGamepad.axes[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]}),this.browserGamepad.axes.length>=4&&(this._rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})}return Object.defineProperty(r.prototype,"isConnected",{get:function(){return this._isConnected},enumerable:!1,configurable:!0}),r.prototype.onleftstickchanged=function(t){this._onleftstickchanged=t},r.prototype.onrightstickchanged=function(t){this._onrightstickchanged=t},Object.defineProperty(r.prototype,"leftStick",{get:function(){return this._leftStick},set:function(t){!this._onleftstickchanged||this._leftStick.x===t.x&&this._leftStick.y===t.y||this._onleftstickchanged(t),this._leftStick=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"rightStick",{get:function(){return this._rightStick},set:function(t){!this._onrightstickchanged||this._rightStick.x===t.x&&this._rightStick.y===t.y||this._onrightstickchanged(t),this._rightStick=t},enumerable:!1,configurable:!0}),r.prototype.update=function(){this._leftStick&&(this.leftStick={x:this.browserGamepad.axes[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]},this._invertLeftStickY&&(this.leftStick.y*=-1)),this._rightStick&&(this.rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})},r.prototype.dispose=function(){},r.GAMEPAD=0,r.GENERIC=1,r.XBOX=2,r.POSE_ENABLED=3,r.DUALSHOCK=4,r}(),yl=function(r){function t(e,n,i){var o=r.call(this,e,n,i)||this;return o.onButtonDownObservable=new C.c,o.onButtonUpObservable=new C.c,o.type=dn.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.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}();hn.ArcRotateCameraGamepadInput=ja;var Zi=f(66),Ha=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=Xe.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===Zi.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.keyCode)===-1&&e.keysDown.indexOf(o.keyCode)===-1&&e.keysLeft.indexOf(o.keyCode)===-1&&e.keysRight.indexOf(o.keyCode)===-1&&e.keysReset.indexOf(o.keyCode)===-1||((i=e._keys.indexOf(o.keyCode))>=0&&e._keys.splice(i,1),o.preventDefault&&(t||o.preventDefault())))}))},r.prototype.detachControl=function(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;e0?n/(1+this.wheelDeltaPercentage):n*(1+this.wheelDeltaPercentage)},r.prototype.attachControl=function(t){var e=this;t=Xe.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,b=e.camera.inertialRadiusOffset+a,P=0;P<20&&Math.abs(b)>.001;P++)p-=b,b*=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}();hn.ArcRotateCameraMouseWheelInput=Wa;var Tl=function(){function r(){this.buttons=[0,1,2]}return r.prototype.attachControl=function(t){var e=this;t=Xe.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 b=d.event,P=b.pointerType==="touch";if(!n.isInVRExclusivePointerMode&&(d.type===Tt.a.POINTERMOVE||e.buttons.indexOf(b.button)!==-1)){var O=b.srcElement||b.target;if(e._altKey=b.altKey,e._ctrlKey=b.ctrlKey,e._metaKey=b.metaKey,e._shiftKey=b.shiftKey,e._buttonsPressed=b.buttons,n.isPointerLock){var B=b.movementX||b.mozMovementX||b.webkitMovementX||b.msMovementX||0,F=b.movementY||b.mozMovementY||b.webkitMovementY||b.msMovementY||0;e.onTouch(null,B,F),e.pointA=null,e.pointB=null}else if(d.type===Tt.a.POINTERDOWN&&O){try{O.setPointerCapture(b.pointerId)}catch{}e.pointA===null?e.pointA={x:b.clientX,y:b.clientY,pointerId:b.pointerId,type:b.pointerType}:e.pointB===null&&(e.pointB={x:b.clientX,y:b.clientY,pointerId:b.pointerId,type:b.pointerType}),e.onButtonDown(b),t||(b.preventDefault(),i&&i.focus())}else if(d.type===Tt.a.POINTERDOUBLETAP)e.onDoubleTap(b.pointerType);else if(d.type===Tt.a.POINTERUP&&O){try{O.releasePointerCapture(b.pointerId)}catch{}P||(e.pointB=null),n._badOS?e.pointA=e.pointB=null:e.pointB&&e.pointA&&e.pointA.pointerId==b.pointerId?(e.pointA=e.pointB,e.pointB=null):e.pointA&&e.pointB&&e.pointB.pointerId==b.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(b),t||b.preventDefault()}else if(d.type===Tt.a.POINTERMOVE){if(t||b.preventDefault(),e.pointA&&e.pointB===null)B=b.clientX-e.pointA.x,F=b.clientY-e.pointA.y,e.onTouch(e.pointA,B,F),e.pointA.x=b.clientX,e.pointA.y=b.clientY;else if(e.pointA&&e.pointB){var z=e.pointA.pointerId===b.pointerId?e.pointA:e.pointB;z.x=b.clientX,z.y=b.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:b.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&&Xe.b.RegisterTopRootEvents(s,[{name:"blur",handler:this._onLostFocus}])},r.prototype.detachControl=function(t){if(this._onLostFocus){var e=this.camera.getScene().getEngine().getHostWindow();e&&Xe.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}(),Xa=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()},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,b=s.y-a.y;this.camera.inertialPanningX+=-p/this.panningSensibility,this.camera.inertialPanningY+=b/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,b=s.y-a.y,this.camera.inertialPanningX+=-p/this.panningSensibility,this.camera.inertialPanningY+=b/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}(Tl);hn.ArcRotateCameraPointersInput=Xa;var wo=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 Wa),this},t.prototype.addPointers=function(){return this.add(new Xa),this},t.prototype.addKeyboard=function(){return this.add(new Ha),this},t}($r);wo.prototype.addVRDeviceOrientation=function(){return this.add(new Ya),this};var Ya=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=Xe.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):Xe.b.Warn("Permission not granted.")}).catch(function(i){Xe.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}();hn.ArcRotateCameraVRDeviceOrientationInput=Ya;var Ka=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=Xe.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;n.type===Zi.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=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(){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}();hn.FollowCameraKeyboardMoveInput=qa;var Za=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=Xe.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}();hn.FollowCameraMouseWheelInput=Za;var Ja=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)},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}(Tl);hn.FollowCameraPointersInput=Ja;var $a=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=Xe.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===Zi.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;e1)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._cameraRotationMatrix))}}},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}();hn.FreeCameraTouchInput=ns;var eo=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 $a),this},t.prototype.addMouse=function(e){return e===void 0&&(e=!0),this._mouseInput||(this._mouseInput=new es(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 ts,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 ns),this},t.prototype.clear=function(){r.prototype.clear.call(this),this._mouseInput=null},t}($r);eo.prototype.addDeviceOrientation=function(){return this._deviceOrientationInput||(this._deviceOrientationInput=new is,this.add(this._deviceOrientationInput)),this};var is=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 C.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=-Xe.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):Xe.b.Warn("Permission not granted.")}).catch(function(a){Xe.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():Xe.b.Warn("Permission not granted.")}).catch(function(i){Xe.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(Xe.b.ToRadians(this._alpha),Xe.b.ToRadians(this._beta),-Xe.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}();hn.FreeCameraDeviceOrientationInput=is;var rs=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},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!==dn.POSE_ENABLED&&(t.gamepad&&n.type!==dn.XBOX||(t.gamepad=n))}),this._onGamepadDisconnectedObserver=e.onGamepadDisconnectedObservable.add(function(n){t.gamepad===n&&(t.gamepad=null)}),this.gamepad=e.getGamepadByType(dn.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}();hn.FreeCameraGamepadInput=rs;var an,El=f(112);(function(r){r[r.X=0]="X",r[r.Y=1]="Y",r[r.Z=2]="Z"})(an||(an={}));var os=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 El.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.clientXr.halfWidth)&&this._joystickPointerID<0?(this._joystickPointerID=t.pointerId,this._joystickPosition?(this._joystickPointerStartPos=this._joystickPosition.clone(),this._joystickPointerPos=this._joystickPosition.clone(),this._joystickPreviousPointerPos=this._joystickPosition.clone(),this._onPointerMove(t)):(this._joystickPointerStartPos.x=t.clientX,this._joystickPointerStartPos.y=t.clientY,this._joystickPointerPos=this._joystickPointerStartPos.clone(),this._joystickPreviousPointerPos=this._joystickPointerStartPos.clone()),this._deltaJoystickVector.x=0,this._deltaJoystickVector.y=0,this.pressed=!0,this._touches.add(t.pointerId.toString(),t)):r._globalJoystickIndex<2&&this._action&&(this._action(),this._touches.add(t.pointerId.toString(),{x:t.clientX,y:t.clientY,prevX:t.clientX,prevY:t.clientY}))},r.prototype._onPointerMove=function(t){if(this._joystickPointerID==t.pointerId){if(this.limitToContainer){var e=new 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=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)},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)Ue.a.CollisionsEpsilon&&(a.position.addInPlace(a._diffPosition),a.onCollide&&p&&a.onCollide(p))},a.inputs=new eo(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,"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}),t.prototype.attachControl=function(e,n){n=Xe.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}(Ni);Q.a.AddNodeConstructor("TouchCamera",function(r,t){return function(){return new ss(r,u.e.Zero(),t)}});var ss=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}(Kn);Q.a.AddNodeConstructor("ArcRotateCamera",function(r,t){return function(){return new Ji(r,0,0,1,u.e.Zero(),t)}});var Ji=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 C.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(b,P,O){O===void 0&&(O=null),O?(p.setPosition(P),p.onCollide&&p.onCollide(O)):p._previousPosition.copyFrom(p._position);var B=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*B*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 wo(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}),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 pl,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 _l,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 fl,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.radius===this.radius&&this._cache.targetScreenOffset.equals(this.targetScreenOffset)},t.prototype.attachControl=function(e,n,i,o){var a=this;i===void 0&&(i=!0),o===void 0&&(o=2),n=Xe.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)Math.PI&&(this.beta=this.beta-2*Math.PI):this.betathis.upperBetaLimit&&(this.beta=this.upperBetaLimit),this.lowerAlphaLimit!==null&&this.alphathis.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),this.lowerRadiusLimit!==null&&this.radiusthis.upperRadiusLimit&&(this.radius=this.upperRadiusLimit,this.inertialRadiusOffset=0)},t.prototype.rebuildAnglesAndRadius=function(){this._position.subtractToRef(this._getTargetPosition(),this._computationVector),this._upVector.x===0&&this._upVector.y===1&&this._upVector.z===0||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.getScene().collisionsEnabled&&this.checkCollisions){var s=this.getScene().collisionCoordinator;this._collider||(this._collider=s.createCollider()),this._collider._radius=this.collisionRadius,this._newPosition.subtractToRef(this._position,this._collisionVelocity),this._collisionTriggered=!0,s.getNewPosition(this._position,this._collisionVelocity,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)}else{this._position.copyFrom(this._newPosition);var 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.getScene().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}(Ni);Q.a.AddNodeConstructor("DeviceOrientationCamera",function(r,t){return function(){return new Fo(r,u.e.Zero(),t)}});var Fo=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},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}(Kn),Sl=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 Ka),this},t.prototype.addMouse=function(e){return e===void 0&&(e=!0),this.add(new Qa(e)),this},t}($r),Bf=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 b;b=d,a._newPosition.copyFrom(b),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 Sl(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}),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=Xe.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}(Ni),Al=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 qa),this},t.prototype.addMouseWheel=function(){return this.add(new Za),this},t.prototype.addPointers=function(){return this.add(new Ja),this},t.prototype.addVRDeviceOrientation=function(){return console.warn("DeviceOrientation support not yet implemented for FollowCamera."),this},t}($r);Q.a.AddNodeConstructor("FollowCamera",function(r,t){return function(){return new Pl(r,u.e.Zero(),t)}}),Q.a.AddNodeConstructor("ArcFollowCamera",function(r,t){return function(){return new xl(r,0,0,1,null,t)}});var ri,Pl=function(r){function t(e,n,i,o){o===void 0&&(o=null);var a=r.call(this,e,n,i)||this;return a.radius=12,a.lowerRadiusLimit=null,a.upperRadiusLimit=null,a.rotationOffset=0,a.lowerRotationOffsetLimit=null,a.upperRotationOffsetLimit=null,a.heightOffset=4,a.lowerHeightOffsetLimit=null,a.upperHeightOffsetLimit=null,a.cameraAcceleration=.05,a.maxCameraSpeed=20,a.lockedTarget=o,a.inputs=new Al(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=Xe.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,b=a.y+this.heightOffset-this.position.y,P=d-this.position.z,O=p*this.cameraAcceleration*2,B=b*this.cameraAcceleration,F=P*this.cameraAcceleration*2;(O>this.maxCameraSpeed||O<-this.maxCameraSpeed)&&(O=O<1?-this.maxCameraSpeed:this.maxCameraSpeed),(B>this.maxCameraSpeed||B<-this.maxCameraSpeed)&&(B=B<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+B,this.position.z+F),this.setTarget(a)}},t.prototype.attachControl=function(e,n){n=Xe.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.radiusthis.upperRadiusLimit&&(this.radius=this.upperRadiusLimit),this.lowerHeightOffsetLimit!==null&&this.heightOffsetthis.upperHeightOffsetLimit&&(this.heightOffset=this.upperHeightOffsetLimit),this.lowerRotationOffsetLimit!==null&&this.rotationOffsetthis.upperRotationOffsetLimit&&(this.rotationOffset=this.upperRotationOffsetLimit)},t.prototype.getClassName=function(){return"FollowCamera"},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}(Ni),xl=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}(Ni),cs=f(38),fn=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"})(ri||(ri={}));var Rn,$i,wi=function(){function r(){}return r.InitiateController=function(t){for(var e=0,n=this._ControllerFactories;ethis._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),!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 fn.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 fn.a(i,s,e)},t.POINTING_POSE="POINTING_POSE",t}(dn);(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"})(Rn||(Rn={})),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 Gn,er,Cl=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 C.c,a.onButtonUpObservable=new C.c,a.onPadDownObservable=new C.c,a.onPadUpObservable=new C.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=dn.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,Rn.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,Rn.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,Rn.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,Rn.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,Rn.Start)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonBack",{get:function(){return this._buttonBack},set:function(e){this._buttonBack=this._setButtonValue(e,this._buttonBack,Rn.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,Rn.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,Rn.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,Rn.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,Rn.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._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}(dn);(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"}(er||(er={}));var Rl=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 C.c,o.onButtonUpObservable=new C.c,o.onPadDownObservable=new C.c,o.onPadUpObservable=new C.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=dn.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},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,er.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,er.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,er.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,er.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}(dn),Ol=function(){function r(t){var e=this;if(this._scene=t,this._babylonGamepads=[],this._oneGamepadConnected=!1,this._isMonitoring=!1,this.onGamepadDisconnectedObservable=new C.c,cs.a.IsWindowObjectExist()?(this._gamepadEventSupported="GamepadEvent"in window,this._gamepadSupport=navigator.getGamepads||navigator.webkitGetGamepads||navigator.msGetGamepads||navigator.webkitGamepads):this._gamepadEventSupported=!1,this.onGamepadConnectedObservable=new C.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},enumerable:!1,configurable:!0}),r.prototype.getGamepadByType=function(t){t===void 0&&(t=dn.XBOX);for(var e=0,n=this._babylonGamepads;e1&&(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,b,P,O,B,F,z){s===void 0&&(s=h.a.TEXTURE_NEAREST_SAMPLINGMODE),b===void 0&&(b=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 fi.a(2),this._currentRenderTextureInd=0,this._scaleRatio=new u.d(1,1),this._texelSize=u.d.Zero(),this.onActivateObservable=new C.c,this.onSizeChangedObservable=new C.c,this.onApplyObservable=new C.c,this.onBeforeRenderObservable=new C.c,this.onAfterRenderObservable=new C.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=B,F||this.updateEffect(b)}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.forEach(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 fi.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,b=t.parent;!b||b.leftCamera!=t&&b.rightCamera!=t||(d/=2);var P,O=this._options.width||d,B=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,B*=z.height)}if((F||this.alwaysForcePOT)&&(this._options.width||(O=a.needPOTTextures?Ue.a.GetExponentOfTwo(O,s,this.scaleMode):O),this._options.height||(B=a.needPOTTextures?Ue.a.GetExponentOfTwo(B,s,this.scaleMode):B)),this.width!==O||this.height!==B){if(this._textures.length>0){for(var J=0;J0)for(var t=0;t0){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 Vf=` +varying vec2 vUV; +uniform sampler2D textureSampler; +void main(void) +{ +gl_FragColor=texture2D(textureSampler,vUV); +}`;ze.a.ShadersStore.passPixelShader=Vf;var kf=` +varying vec2 vUV; +uniform samplerCube textureSampler; +void main(void) +{ +vec2 uv=vUV*2.0-1.0; +#ifdef POSITIVEX +gl_FragColor=textureCube(textureSampler,vec3(1.001,uv.y,uv.x)); +#endif +#ifdef NEGATIVEX +gl_FragColor=textureCube(textureSampler,vec3(-1.001,uv.y,uv.x)); +#endif +#ifdef POSITIVEY +gl_FragColor=textureCube(textureSampler,vec3(uv.y,1.001,uv.x)); +#endif +#ifdef NEGATIVEY +gl_FragColor=textureCube(textureSampler,vec3(uv.y,-1.001,uv.x)); +#endif +#ifdef POSITIVEZ +gl_FragColor=textureCube(textureSampler,vec3(uv,1.001)); +#endif +#ifdef NEGATIVEZ +gl_FragColor=textureCube(textureSampler,vec3(uv,-1.001)); +#endif +}`;ze.a.ShadersStore.passCubePixelShader=kf;var Fi=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"]=Fi;var Gf=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 b=r.call(this,e,"passCube",null,null,n,i,o,a,s,"#define POSITIVEX",d,void 0,null,p)||this;return b._face=0,b}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")}},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 Fi("rescale",1,null,h.a.TEXTURE_BILINEAR_SAMPLINGMODE,r,!1,h.a.TEXTURETYPE_UNSIGNED_INT)};var zf=` +varying vec2 vUV; +uniform sampler2D textureSampler; +uniform sampler2D leftSampler; +void main(void) +{ +vec4 leftFrag=texture2D(leftSampler,vUV); +leftFrag=vec4(1.0,leftFrag.g,leftFrag.b,1.0); +vec4 rightFrag=texture2D(textureSampler,vUV); +rightFrag=vec4(rightFrag.r,1.0,1.0,1.0); +gl_FragColor=vec4(rightFrag.rgb*leftFrag.rgb,1.0); +}`;ze.a.ShadersStore.anaglyphPixelShader=zf;var ls=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"]=ls,gt.a._setStereoscopicAnaglyphRigMode=function(r){r._rigCameras[0]._rigPostProcess=new Fi(r.name+"_passthru",1,r._rigCameras[0]),r._rigCameras[1]._rigPostProcess=new ls(r.name+"_anaglyph",1,r._rigCameras)},Q.a.AddNodeConstructor("AnaglyphArcRotateCamera",function(r,t,e){return function(){return new Dl(r,0,0,1,u.e.Zero(),e.interaxial_distance,t)}});var Dl=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}(Ji);Q.a.AddNodeConstructor("AnaglyphFreeCamera",function(r,t,e){return function(){return new Ll(r,u.e.Zero(),e.interaxial_distance,t)}});var Ll=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}(Kn);Q.a.AddNodeConstructor("AnaglyphGamepadCamera",function(r,t,e){return function(){return new Nl(r,u.e.Zero(),e.interaxial_distance,t)}});var Nl=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}(Bo);Q.a.AddNodeConstructor("AnaglyphUniversalCamera",function(r,t,e){return function(){return new wl(r,u.e.Zero(),e.interaxial_distance,t)}});var wl=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}(_r),Qn=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 Qn.a(0,0,t?.5:1,t?1:.5),r._rigCameras[e?0:1].viewport=new Qn.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 Fl(r,0,0,1,u.e.Zero(),e.interaxial_distance,e.isStereoscopicSideBySide,t)}});var Fl=function(r){function t(e,n,i,o,a,s,d,p){var b=r.call(this,e,n,i,o,a,p)||this;return b.interaxialDistance=s,b.isStereoscopicSideBySide=d,b.setCameraRigMode(d?gt.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:gt.a.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:s}),b}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"StereoscopicArcRotateCamera"},t}(Ji);Q.a.AddNodeConstructor("StereoscopicFreeCamera",function(r,t,e){return function(){return new Bl(r,u.e.Zero(),e.interaxial_distance,e.isStereoscopicSideBySide,t)}});var Bl=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}(Kn);Q.a.AddNodeConstructor("StereoscopicGamepadCamera",function(r,t,e){return function(){return new Ul(r,u.e.Zero(),e.interaxial_distance,e.isStereoscopicSideBySide,t)}});var Ul=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}(Bo);Q.a.AddNodeConstructor("StereoscopicFreeCamera",function(r,t,e){return function(){return new Vl(r,u.e.Zero(),e.interaxial_distance,e.isStereoscopicSideBySide,t)}});var Vl=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}(_r);Q.a.AddNodeConstructor("VirtualJoysticksCamera",function(r,t){return function(){return new kl(r,u.e.Zero(),t)}});var kl=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}(Kn),mr=function(){function r(){this.compensateDistortion=!0,this.multiviewEnabled=!1}return Object.defineProperty(r.prototype,"aspectRatio",{get:function(){return this.hResolution/(2*this.vResolution)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"aspectRatioFov",{get:function(){return 2*Math.atan(this.postProcessScaleFactor*this.vScreenSize/(2*this.eyeToScreenDistance))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"leftHMatrix",{get:function(){var t=4*(this.hScreenSize/4-this.lensSeparationDistance/2)/this.hScreenSize;return 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}(),jf=` +varying vec2 vUV; +uniform sampler2D textureSampler; +uniform vec2 LensCenter; +uniform vec2 Scale; +uniform vec2 ScaleIn; +uniform vec4 HmdWarpParam; +vec2 HmdWarp(vec2 in01) { +vec2 theta=(in01-LensCenter)*ScaleIn; +float rSq=theta.x*theta.x+theta.y*theta.y; +vec2 rvector=theta*(HmdWarpParam.x+HmdWarpParam.y*rSq+HmdWarpParam.z*rSq*rSq+HmdWarpParam.w*rSq*rSq*rSq); +return LensCenter+Scale*rvector; +} +void main(void) +{ +vec2 tc=HmdWarp(vUV); +if (tc.x <0.0 || tc.x>1.0 || tc.y<0.0 || tc.y>1.0) +gl_FragColor=vec4(0.0,0.0,0.0,0.0); +else{ +gl_FragColor=texture2D(textureSampler,tc); +} +}`;ze.a.ShadersStore.vrDistortionCorrectionPixelShader=jf;var us=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),Hf=`precision mediump sampler2DArray; +varying vec2 vUV; +uniform sampler2DArray multiviewSampler; +uniform int imageIndex; +void main(void) +{ +gl_FragColor=texture(multiviewSampler,vec3(vUV,imageIndex)); +}`;ze.a.ShadersStore.vrMultiviewToSingleviewPixelShader=Hf;var Gl=f(85),hs=f(95),to=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 Ct.a(this,Ct.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,b,P,O,B,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),b===void 0&&(b=!0),P===void 0&&(P=!1),O===void 0&&(O=!1),B===void 0&&(B=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 C.c,z.onAfterUnbindObservable=new C.c,z.onBeforeRenderObservable=new C.c,z.onAfterRenderObservable=new C.c,z.onClearObservable=new C.c,z.onResizeObservable=new C.c,z._currentRefreshId=-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 to.b(i),z._renderingManager._useSceneAutoClearSetup=!0,O||(z._renderTargetOptions={generateMipMaps:o,type:s,format:B,samplingMode:p,generateDepthBuffer:b,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;s0&&(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;a1||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=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,b=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,b,P)),p?this._prepareRenderingManager(p,p.length,a,!1):(this._defaultRenderListPrepared||(this._prepareRenderingManager(b,P,a,!this.renderList),this._defaultRenderListPrepared=!0),p=b),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,B=s._beforeRenderTargetDrawStage;O=0&&e.customRenderTargets.splice(n,1);for(var i=0,o=e.cameras;i=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,Ct.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 Ct.a(this,Ct.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 Gl.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=2&&e.onControllersAttachedObservable.notifyObservers(e.controllers)}}})},t}(Kn),Bi=function(r){function t(e){var n=r.call(this,e)||this;return n.onTriggerStateChangedObservable=new C.c,n.onMainButtonStateChangedObservable=new C.c,n.onSecondaryButtonStateChangedObservable=new C.c,n.onPadStateChangedObservable=new C.c,n.onPadValuesChangedObservable=new C.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 +#include +#include +void main(void) +{ +vec4 result=texture2D(textureSampler,vUV); +#ifdef IMAGEPROCESSING +#ifndef FROMLINEARSPACE + +result.rgb=toLinearSpace(result.rgb); +#endif +result=applyImageProcessing(result); +#else + +#ifdef FROMLINEARSPACE +result=applyImageProcessing(result); +#endif +#endif +gl_FragColor=result; +}`);ze.a.ShadersStore.imageProcessingPixelShader=Wf;var Go=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 b=r.call(this,e,"imageProcessing",[],[],n,i,o,a,s,null,d,"postprocess",null,!0)||this;return b._fromLinearSpace=!0,b._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,b._attachImageProcessingConfiguration(p,!0),b.fromLinearSpace=!1):(b._attachImageProcessingConfiguration(null,!0),b.imageProcessingConfiguration.applyByPostProcess=!0),b.onApply=function(P){b.imageProcessingConfiguration.bind(P,b.aspectRatio)},b}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)},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 yn.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},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 +`);var i=["textureSampler"],o=["scale"];yn.a&&(yn.a.PrepareSamplers(i,this._defines),yn.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),Oe=f(4);De.a._GroundMeshParser=function(r,t){return zo.Parse(r,t)};var zo=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}),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,ethis._maxX||nthis._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,ethis._maxX||nthis._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 nr.maxHeight){p=!0;var b=r.maxHeight;r.maxHeight=r.minHeight,r.minHeight=b}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),B=r.buffer[O]/255,F=r.buffer[O+1]/255,z=r.buffer[O+2]/255,J=r.buffer[O+3]/255;p&&(B=1-B,F=1-F,z=1-z);var ie=B*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.minHeight,Te=i[3*ce+1]>=r.minHeight,Re=i[3*ue+1]>=r.minHeight;ve&&Te&&Re&&(n.push(se),n.push(ce),n.push(ue)),i[3*fe+1]>=r.minHeight&&ve&&Re&&(n.push(fe),n.push(se),n.push(ue))}ft.a.ComputeNormals(i,n,o);var Ae=new ft.a;return Ae.indices=n,Ae.positions=i,Ae.normals=o,Ae.uvs=a,Ae},De.a.CreateGround=function(r,t,e,n,i,o){var a={width:t,height:e,subdivisions:n,updatable:o};return Ui.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 Ui.CreateTiledGround(r,p,s)},De.a.CreateGroundFromHeightMap=function(r,t,e,n,i,o,a,s,d,p,b){var P={width:e,height:n,subdivisions:i,minHeight:o,maxHeight:a,updatable:d,onReady:p,alphaFilter:b};return Ui.CreateGroundFromHeightMap(r,t,P,s)};var Ui=function(){function r(){}return r.CreateGround=function(t,e,n){var i=new zo(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,b=n.colorFilter||new M.a(.3,.59,.11),P=n.alphaFilter||0,O=n.updatable,B=n.onReady;i=i||te.a.LastCreatedScene;var F=new zo(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),Xe.b.LoadImage(e,function(z){var J=z.width,ie=z.height,se=fs.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:b,buffer:ce,bufferWidth:J,bufferHeight:ie,alphaFilter:P}).applyToMesh(F,O),B&&B(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,b=0;b<=s;b++)for(var P=b/s,O=b*Math.PI*2/s-Math.PI/2,B=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,B),ce=u.e.TransformNormal(ce,B),e.push(ue.x,ue.y,ue.z),n.push(ce.x,ce.y,ce.z),i.push(fe.x,fe.y);var ve=(b+1)%p,Te=(F+1)%p;t.push(b*p+F),t.push(b*p+Te),t.push(ve*p+F),t.push(b*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 Re=new ft.a;return Re.indices=t,Re.positions=e,Re.normals=n,Re.uvs=i,Re},De.a.CreateTorus=function(r,t,e,n,i,o,a){var s={diameter:t,thickness:e,tessellation:n,sideOrientation:a,updatable:o};return gr.CreateTorus(r,s,i)};var pn,tr,gr=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}(),pi=f(53),ps=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}(),Xl=function(){function r(t,e){var n=this;if(e===void 0&&(e=ps.GetDefaults()),this._options=e,this._canvas=null,this.xrLayer=null,this.onXRLayerInitObservable=new C.c,this._engine=t.scene.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}(),_s=function(){function r(t){this.scene=t,this._sessionEnded=!1,this.baseLayer=null,this.currentTimestamp=-1,this.defaultHeightCompensation=1.7,this.onXRFrameObservable=new C.c,this.onXRReferenceSpaceChanged=new C.c,this.onXRSessionEnded=new C.c,this.onXRSessionInit=new C.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||ps.GetDefaults(e)).canvasElement=e.getRenderingCanvas()||void 0,new Xl(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.defaultHeightCompensation,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 Ct.a(this.scene.getEngine(),Ct.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"})(pn||(pn={})),function(r){r[r.NOT_TRACKING=0]="NOT_TRACKING",r[r.TRACKING_LOST=1]="TRACKING_LOST",r[r.TRACKING=2]="TRACKING"}(tr||(tr={}));var oi,Yl=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 fn.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}(),Xf=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(pr.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().forEach(function(d){n(d)})};n(e);var i=e.getChildren(void 0,!1),o=e;this.webVRController._pointingPoseNode=null;for(var a=0;a=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}(Yl),Kl=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 fn.a(u.e.Zero(),u.e.Forward())},t}(Yl),Yf=function(){},Ql=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 C.c,this.onAfterEnteringVRObservable=new C.c,this.onExitingVRObservable=new C.c,this.onControllerMeshLoadedObservable=new C.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 C.c,this.onMeshSelectedWithController=new C.c,this.onNewMeshPicked=new C.c,this.onBeforeCameraTeleport=new C.c,this.onAfterCameraTeleport=new C.c,this.onSelectedMeshUnselected=new C.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!==dn.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===dn.XBOX&&(o.onbuttondown(function(d){n._interactionsEnabled&&d===Rn.A&&n._cameraGazer._selectionPointerDown()}),o.onbuttonup(function(d){n._interactionsEnabled&&d===Rn.A&&n._cameraGazer._selectionPointerUp()}));else{var a=o,s=new Xf(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 Bi&&(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){if(this._deviceOrientationCamera=new Fo("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 Ni&&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?_s.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 Kl(function(){return n.xr.baseExperience.camera},t),n.xr.baseExperience.onStateChangedObservable.add(function(s){switch(s){case pn.ENTERING_XR:n.onEnteringVRObservable.notifyObservers(n),n._interactionsEnabled||n.xr.pointerSelection.detach(),n.xr.pointerSelection.displayLaserPointer=n._displayLaserPointer;break;case pn.EXITING_XR:n.onExitingVRObservable.notifyObservers(n),n._scene.getEngine().resize();break;case pn.IN_XR:n._hasEnteredVR=!0;break;case pn.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))},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=mr.GetDefault()),e.vrDeviceOrientationCameraMetrics.multiviewEnabled=!0),this._vrDeviceOrientationCamera=new Uo("VRDeviceOrientationVRHelper",this._position,this._scene,!0,e.vrDeviceOrientationCameraMetrics),this._vrDeviceOrientationCamera.angularSensibility=Number.MAX_VALUE),this._webVRCamera=new ko("WebVRHelper",this._position,this._scene,e),this._webVRCamera.useStandingMatrix(),this._cameraGazer=new Kl(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 nt,this._circleEase.setEasingMode(Ge.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===pn.IN_XR||this._webVRpresenting||this._fullscreenVRpresenting},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)},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===pn.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-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 yn.a;a.vignetteColor=new M.b(0,0,0,0),a.vignetteEnabled=!0,this._postProcessMove=new Go("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.valuee._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&&(e._rotationLeftAsked=!1):t.x<-this._padSensibilityUp&&e._dpadPressed&&(e._rotationLeftAsked=!0,this._rotationAllowed&&this._rotateCamera(!1)),e._rotationRightAsked?t.xthis._padSensibilityUp&&e._dpadPressed&&(e._rotationRightAsked=!0,this._rotationAllowed&&this._rotateCamera(!0)))},r.prototype._checkTeleportBackwards=function(t,e){if(!e._teleportationRequestInitiated)if(t.y>this._padSensibilityUp&&e._dpadPressed){if(!e._teleportationBackRequestInitiated){if(!this.currentVRCamera)return;var n=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 fn.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===ri.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 Ti.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();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(Ge.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 Kn){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 Kn){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),b=[];b.push({frame:0,value:0}),b.push({frame:d,value:8}),b.push({frame:i,value:0}),p.setKeys(b),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))s){var d=s;s=a,a=d}return a>0&&a0&&s=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,b){return!(s.x>p.x+b)&&!(p.x-b>d.x)&&!(s.y>p.y+b)&&!(p.y-b>d.y)&&!(s.z>p.z+b)&&!(p.z-b>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 vr.a(0,0,0,0),e[t].copyFromPoints(n,i,o));var b=e[t];if(a||b.isFrontFacingTo(this._normalizedVelocity,0)){var P=b.signedDistanceTo(this._basePoint),O=u.e.Dot(b.normal,this._velocity);if(O==0){if(Math.abs(P)>=1)return;p=!0,d=0}else{var B=(1-P)/O;if((d=(-1-P)/O)>B){var F=B;B=d,d=F}if(d>1||B<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(b.normal,this._planeIntersectionPoint),this._velocity.scaleToRef(d,this._tempVector),this._planeIntersectionPoint.addInPlace(this._tempVector),this._checkPointInTriangle(this._planeIntersectionPoint,n,i,o,b.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=br(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=br(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=br(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),Re=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*Re,ue=ve*(1-this._baseToVertex.lengthSquared())+Re*Re,(fe=br(se,ce,ue,J)).found){var Ae=(Te*fe.root-Re)/ve;Ae>=0&&Ae<=1&&(J=fe.root,z=!0,this._edge.scaleInPlace(Ae),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),Re=u.e.Dot(this._edge,this._baseToVertex),se=ve*-ie+Te*Te,ce=ve*(2*u.e.Dot(this._velocity,this._baseToVertex))-2*Te*Re,ue=ve*(1-this._baseToVertex.lengthSquared())+Re*Re,(fe=br(se,ce,ue,J)).found&&(Ae=(Te*fe.root-Re)/ve)>=0&&Ae<=1&&(J=fe.root,z=!0,this._edge.scaleInPlace(Ae),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),Re=u.e.Dot(this._edge,this._baseToVertex),se=ve*-ie+Te*Te,ce=ve*(2*u.e.Dot(this._velocity,this._baseToVertex))-2*Te*Re,ue=ve*(1-this._baseToVertex.lengthSquared())+Re*Re,(fe=br(se,ce,ue,J)).found&&(Ae=(Te*fe.root-Re)/ve)>=0&&Ae<=1&&(J=fe.root,z=!0,this._edge.scaleInPlace(Ae),o.addToRef(this._edge,this._collisionPoint))}if(z){var Ee=J*this._velocity.length();(!this.collisionFound||Ee=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,b=0;bthis.capacity&&this._depth-1&&this.entries.splice(n,1)}},r.prototype.addEntries=function(t){for(var e=0;e=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}(),tu=function(){function r(t,e,n){n===void 0&&(n=0),this.deviceType=e,this.deviceSlot=n,this.onInputChangedObservable=new C.c,this._deviceInputSystem=t}return r.prototype.getInput=function(t){return this._deviceInputSystem.pollInput(this.deviceType,this.deviceSlot,t)},r}(),qf=function(){function r(t){var e=this;this.onDeviceConnectedObservable=new C.c(function(i){e.getDevices().forEach(function(o){e.onDeviceConnectedObservable.notifyObserver(i,o)})}),this.onDeviceDisconnectedObservable=new C.c;var n=Object.keys(Kt).length/2;this._devices=new Array(n),this._firstDevice=new Array(n),this._deviceInputSystem=eu.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 tu(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;nr.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}return r.isOccluded};var Zf=!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=fs.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;n1?"COLOR_ATTACHMENT"+a:"COLOR_ATTACHMENT"+a+"_WEBGL"],n.readBuffer(i[a]),n.drawBuffers(i),n.blitFramebuffer(0,0,s.width,s.height,0,0,s.width,s.height,n.COLOR_BUFFER_BIT,n.NEAREST)}for(a=0;a1?"COLOR_ATTACHMENT"+a:"COLOR_ATTACHMENT"+a+"_WEBGL"];n.drawBuffers(i)}for(a=0;a1?"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),B,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=B,ve.baseHeight=F,ve.width=B,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 Re=new Ct.a(this,Ct.b.MultiRenderTarget);P.activeTexture(P.TEXTURE0),P.bindTexture(P.TEXTURE_2D,Re._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,B,F,0,P.DEPTH_COMPONENT,P.UNSIGNED_SHORT,null),P.framebufferTexture2D(P.FRAMEBUFFER,P.DEPTH_ATTACHMENT,P.TEXTURE_2D,Re._webGLTexture,0),Re._framebuffer=O,Re.baseWidth=B,Re.baseHeight=F,Re.width=B,Re.height=F,Re.isReady=!0,Re.samples=1,Re.generateMipMaps=e,Re.samplingMode=P.NEAREST,Re._generateDepthBuffer=n,Re._generateStencilBuffer=i,z.push(Re),this._internalTexturesCache.push(Re)}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;i1&&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;i1?"COLOR_ATTACHMENT"+i:"COLOR_ATTACHMENT"+i+"_WEBGL"],b=n.createRenderbuffer();if(!b)throw new Error("Unable to create multi sampled framebuffer");n.bindRenderbuffer(n.RENDERBUFFER,b),n.renderbufferStorageMultisample(n.RENDERBUFFER,t,this._getRGBAMultiSampleBufferFormat(d.type),d.width,d.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,p,n.RENDERBUFFER,b),d._MSAAFramebuffer=o,d._MSAARenderBuffer=b,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 io=f(56);Bt.a.prototype._createDepthStencilCubeTexture=function(r,t){var e=new Ct.a(this,Ct.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=io.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)},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,b,P,O){var B=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),b===void 0&&(b=0),P===void 0&&(P=null);var F=this._gl,z=P||new Ct.a(this,Ct.b.Cube);z.isCube=!0,z.url=r,z.generateMipMaps=!n,z._lodGenerationScale=p,z._lodGenerationOffset=b,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-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 +void main(void) +{ +gl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb); +}`;ze.a.ShadersStore.rgbdEncodePixelShader=np;var ip=` +varying vec2 vUV; +uniform sampler2D textureSampler; +#include +void main(void) +{ +gl_FragColor=vec4(fromRGBD(texture2D(textureSampler,vUV)),1.0); +}`;ze.a.ShadersStore.rgbdDecodePixelShader=ip;var Ai=function(){function r(){}return r.GetEnvInfo=function(t){for(var e=new DataView(t.buffer,t.byteOffset,t.byteLength),n=0,i=0;i"u")Ye=createImageBitmap(Ie).then(function(it){return n._OnImageReadyAsync(it,o,a,d,Fe,xe,Ee,s,b,p,t)});else{var tt=new Image;tt.src=Fe,Ye=new Promise(function(it,lt){tt.onload=function(){n._OnImageReadyAsync(tt,o,a,d,Fe,xe,Ee,s,b,p,t).then(function(){return it()}).catch(function(Qe){lt(Qe)})},tt.onerror=function(Qe){lt(Qe)}})}ue.push(Ye)},Le=0;Le<6;Le++)Se(Le)};for(F=0;F=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=0},r.prototype._extractBetweenMarkers=function(t,e,n,i){for(var o=i,a=0,s="";o0?this._sourceCode.substring(0,b):"",fe=O+1"u"&&(window.URL={createObjectURL:function(){},revokeObjectURL:function(){}}),typeof Blob>"u"&&(window.Blob=function(){}),e._shaderProcessor=new ou.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 su;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 su;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.recordIndexBuffer(e,i.nativeIndexBuffer);for(var a=o.getAttributesNames(),s=0;s=0){var p=n[a[s]];if(p){var b=p.getBuffer();b&&this._native.recordVertexBuffer(e,b.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){n()},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 Ss(n);d.processCode(),n=d.code;var p=new Ss(i);p.processCode(),i=p.code,n=Bt.a._ConcatenateShader(n,o),i=Bt.a._ConcatenateShader(i,o);var b=this._native.createProgram(n,i);return this.onAfterShaderCompilationObservable.notifyObservers(this),b},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-1?e.substring(ue).toLowerCase():""),ve=null,Te=0,Re=Ue.a._TextureLoaders;Te-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=Ai.GetEnvInfo(ce);if(z.width=ue.width,z.height=ue.width,Ai.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=Ai.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 Xe.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 Il.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 cu(this,Ct.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 Oe.b.UNSIGNED_BYTE:return this._native.ATTRIB_TYPE_UINT8;case Oe.b.SHORT:return this._native.ATTRIB_TYPE_INT16;case Oe.b.FLOAT:return this._native.ATTRIB_TYPE_FLOAT;default:throw new Error("Unsupported attribute type: "+e+".")}},t}(Ue.a),ap=f(74),Ho=function(){function r(){}return r.COPY=1,r.CUT=2,r.PASTE=3,r}(),sp=function(){function r(t,e){this.type=t,this.event=e}return r.GetTypeFromCharacter=function(t){switch(t){case 67:return Ho.COPY;case 86:return Ho.PASTE;case 88:return Ho.CUT;default:return-1}},r}(),As=f(83),xi=f(69);(function(r){r[r.Clean=0]="Clean",r[r.Stop=1]="Stop",r[r.Sync=2]="Sync",r[r.NoSync=3]="NoSync"})(Pi||(Pi={}));var Ut=function(){function r(){}return Object.defineProperty(r,"ForceFullSceneLoadingForIncremental",{get:function(){return xi.a.ForceFullSceneLoadingForIncremental},set:function(t){xi.a.ForceFullSceneLoadingForIncremental=t},enumerable:!1,configurable:!0}),Object.defineProperty(r,"ShowLoadingScreen",{get:function(){return xi.a.ShowLoadingScreen},set:function(t){xi.a.ShowLoadingScreen=t},enumerable:!1,configurable:!0}),Object.defineProperty(r,"loggingLevel",{get:function(){return xi.a.loggingLevel},set:function(t){xi.a.loggingLevel=t},enumerable:!1,configurable:!0}),Object.defineProperty(r,"CleanBoneMatrixWeights",{get:function(){return xi.a.CleanBoneMatrixWeights},set:function(t){xi.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("?");e!==-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),b=s?r._GetPluginForExtension(s):p?r._GetPluginForDirectLoad(t.name):r._GetPluginForFilename(t.name);if(!(d=b.plugin.createPlugin!==void 0?b.plugin.createPlugin():b.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(Ae){n(d,Ae)}).catch(function(Ae){o("Error in directLoad of _loadData: "+Ae,Ae)}):n(d,P)}else n(d,p);return d}var O=b.isBinary,B=function(Ae,Ee){e.isDisposed?o("Scene has been disposed"):n(d,Ae,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 Ae=function(Se,Le){B(Se,Le?Le.responseURL:void 0)},Ee=function(Se){o(Se.message,Se)};F=d.requestFile?d.requestFile(e,t.url,Ae,i,O,Ee):e._requestFile(t.url,Ae,i,!0,O,Ee)}},se=t.file||As.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;veF.snapDistance?(Fe=Math.floor(Math.abs(Re)/F.snapDistance),Re<0&&(Fe*=-1),Re%=F.snapDistance,Ae.scaleToRef(F.snapDistance*Fe,Ae),Ie=!0):Ae.scaleInPlace(0)),u.a.ScalingToRef(1+Ae.x,1+Ae.y,1+Ae.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=(b=o?.uniformScaleGizmo)===null||b===void 0?void 0:b.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};(B=F._parent)===null||B===void 0||B.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;Se.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=Tr.a.CreateBox("yPosMesh",{size:.4*(1+(n-1)/4)},this.gizmoLayer.utilityLayerScene),a=pi.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}(wn.a),Fn=f(45),cn=f(40),uu=function(r){function t(e,n){e===void 0&&(e=M.a.Gray()),n===void 0&&(n=On.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 C.c,i.onScaleBoxDragObservable=new C.c,i.onScaleBoxDragEndObservable=new C.c,i.onRotationSphereDragObservable=new C.c,i.onRotationSphereDragEndObservable=new C.c,i.scalePivot=null,i._existingMeshScale=new u.e,i._dragMesh=null,i.pointerDragBehavior=new yi.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=Fn.a.CreateSphere("",{diameter:1},n.utilityLayerScene);ie.rotationQuaternion=new u.b,ie.material=s.coloredMaterial,(P=new yi.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}),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)),Re=ve.subtract(Te).normalizeToNew(),Ae=u.e.Dot(Re,ue.delta)<0?Math.abs(ue.delta.length()):-Math.abs(ue.delta.length());Ae=Ae/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+=Ae,Math.abs(ce)<=2*Math.PI&&(J>=8?u.b.RotationYawPitchRollToRef(0,0,Ae,i._tmpQuaternion):J>=4?u.b.RotationYawPitchRollToRef(Ae,0,0,i._tmpQuaternion):u.b.RotationYawPitchRollToRef(0,Ae,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 b=0;b<3;b++)for(var P,O=function(){var J=(p===1?1:0)+(b===1?1:0)+(F===1?1:0);if(J===1||J===3)return"continue";var ie=Tr.a.CreateBox("",{size:1},n.utilityLayerScene);ie.material=B.coloredMaterial,ie.metadata=J===2;var se=new u.e(p-1,b-1,F-1).normalize();(P=new yi.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()}),B._scaleBoxesParent.addChild(ie)},B=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()).forEach(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);if(s!==1&&s!==3){if(e[n])if(e[n].position.set(this._boundingDimensions.x*(i/2),this._boundingDimensions.y*(o/2),this._boundingDimensions.z*(a/2)),e[n].position.addInPlace(new 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)})},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=Tr.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}(wn.a),Ko=function(r){function t(e,n,i,o,a,s,d){var p;n===void 0&&(n=M.a.Gray()),i===void 0&&(i=On.a.DefaultUtilityLayer),o===void 0&&(o=32),a===void 0&&(a=null),d===void 0&&(d=1);var b=r.call(this,i)||this;b._pointerObserver=null,b.snapDistance=0,b.onSnapObservable=new C.c,b._isEnabled=!0,b._parent=null,b._dragging=!1,b._parent=a,b._coloredMaterial=new Ft.a("",i.utilityLayerScene),b._coloredMaterial.diffuseColor=n,b._coloredMaterial.specularColor=n.subtract(new M.a(.1,.1,.1)),b._hoverMaterial=new Ft.a("",i.utilityLayerScene),b._hoverMaterial.diffuseColor=M.a.Yellow(),b._disableMaterial=new Ft.a("",i.utilityLayerScene),b._disableMaterial.diffuseColor=M.a.Gray(),b._disableMaterial.alpha=.4,b._gizmoMesh=new De.a("",i.utilityLayerScene);var P=b._createGizmoMesh(b._gizmoMesh,d,o),O=P.rotationMesh,B=P.collider,F=[];b._rotationCircle=b.setupRotationCircle(F,b._gizmoMesh),b._gizmoMesh.lookAt(b._rootMesh.position.add(e)),b._rootMesh.addChild(b._gizmoMesh),b._gizmoMesh.scaling.scaleInPlace(1/3),b.dragBehavior=new yi.a({dragPlaneNormal:e}),b.dragBehavior.moveAttached=!1,b.dragBehavior.maxDragAngle=9*Math.PI/20,b.dragBehavior._useAlternatePickedPointAboveMaxDragAngle=!0,b._rootMesh.addBehavior(b.dragBehavior);var z=0,J=new u.e,ie=new u.e,se=new u.a,ce=new u.e,ue=new u.e;b.dragBehavior.onDragStartObservable.add(function(Se){if(b.attachedNode){J.copyFrom(Se.dragPlanePoint);var Le=new u.e(0,0,1),xe=b._rotationCircle.getDirection(Le);xe.normalize(),b._gizmoMesh.removeChild(b._rotationCircle),J.copyFrom(Se.dragPlanePoint),ie=Se.dragPlanePoint;var Ne=b._rotationCircle.getAbsolutePosition().clone(),Ie=b._rotationCircle.getAbsolutePosition().clone().addInPlace(xe),Fe=Se.dragPlanePoint,Ye=u.e.GetAngleBetweenVectors(Ie.subtract(Ne),Fe.subtract(Ne),b._rotationCircle.up);b._rotationCircle.addRotation(0,Ye,0),b._dragging=!0}}),b.dragBehavior.onDragEndObservable.add(function(){z=0,b.updateRotationCircle(b._rotationCircle,F,z,ie),b._gizmoMesh.addChild(b._rotationCircle),b._dragging=!1});var fe={snapDistance:0},ve=0,Te=new u.a,Re=new u.b;b.dragBehavior.onDragObservable.add(function(Se){if(b.attachedNode){var Le=new u.e(1,1,1),xe=new u.b(0,0,0,1),Ne=new u.e(0,0,0);b.attachedNode.getWorldMatrix().decompose(Le,xe,Ne);var Ie=Se.dragPlanePoint.subtract(Ne).normalize(),Fe=J.subtract(Ne).normalize(),Ye=u.e.Cross(Ie,Fe),tt=u.e.Dot(Ie,Fe),it=Math.atan2(Ye.length(),tt);ce.copyFrom(e),ue.copyFrom(e),b.updateGizmoRotationToMatchAttachedMesh&&(xe.toRotationMatrix(se),ue=u.e.TransformCoordinates(ce,se));var lt=!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),lt=!0)}u.e.Dot(ue,Ye)>0&&(it=-it);var ot=!1;if(b.snapDistance!=0)if(ve+=it,Math.abs(ve)>b.snapDistance){var rt=Math.floor(Math.abs(ve)/b.snapDistance);ve<0&&(rt*=-1),ve%=b.snapDistance,it=b.snapDistance*rt,ot=!0}else it=0;z+=lt?-it:it,b.updateRotationCircle(b._rotationCircle,F,z,ie);var Ze=Math.sin(it/2);if(Re.set(ce.x*Ze,ce.y*Ze,ce.z*Ze,Math.cos(it/2)),Te.determinant()>0){var dt=new u.e;Re.toEulerAnglesToRef(dt),u.b.RotationYawPitchRollToRef(dt.y,-dt.x,-dt.z,Re)}b.updateGizmoRotationToMatchAttachedMesh?xe.multiplyToRef(Re,xe):Re.multiplyToRef(xe,xe),b.attachedNode.getWorldMatrix().copyFrom(u.a.Compose(Le,xe,Ne)),J.copyFrom(Se.dragPlanePoint),ot&&(fe.snapDistance=it,b.onSnapObservable.notifyObservers(fe)),b._matrixChanged()}});var Ae=i._getSharedGizmoLight();Ae.includedOnlyMeshes=Ae.includedOnlyMeshes.concat(b._rootMesh.getChildMeshes(!1));var Ee={colliderMeshes:[B],gizmoMeshes:[O],material:b._coloredMaterial,hoverMaterial:b._hoverMaterial,disableMaterial:b._disableMaterial,active:!1};return(p=b._parent)===null||p===void 0||p.addToAxisCache(b._gizmoMesh,Ee),b._pointerObserver=i.utilityLayerScene.onPointerObservable.add(function(Se){var Le;if(!b._customMeshSet&&(b._isHovered=Ee.colliderMeshes.indexOf((Le=Se?.pickInfo)===null||Le===void 0?void 0:Le.pickedMesh)!=-1,!b._parent)){var xe=b._isHovered||b._dragging?b._hoverMaterial:b._coloredMaterial;Ee.gizmoMeshes.forEach(function(Ne){Ne.material=xe,Ne.color&&(Ne.color=xe.diffuseColor)})}}),b}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;o0?p:-1*p,P=n>0?a:-1*a;s[d].set(t._CircleConstants.radius*Math.sin(b)*Math.cos(P),0,t._CircleConstants.radius*Math.cos(b)*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}(wn.a),hu=function(r){function t(e,n,i,o,a){e===void 0&&(e=On.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 C.c,s.onDragEndObservable=new C.c,s._observables=[],s._gizmoAxisCache=new Map,s.xGizmo=new Ko(new u.e(1,0,0),M.a.Red().scale(.5),e,n,s,i,o),s.yGizmo=new Ko(new u.e(0,1,0),M.a.Green().scale(.5),e,n,s,i,o),s.zGizmo=new Ko(new u.e(0,0,1),M.a.Blue().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):wn.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}(wn.a),Er=f(46),Rs=f(84),Qo=function(r){function t(e,n,i,o){var a;n===void 0&&(n=M.a.Gray()),i===void 0&&(i=On.a.DefaultUtilityLayer),o===void 0&&(o=null);var s=r.call(this,i)||this;s._pointerObserver=null,s.snapDistance=0,s.onSnapObservable=new C.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,b={snapDistance:0};s.dragBehavior=new yi.a({dragPlaneNormal:e}),s.dragBehavior.moveAttached=!1,s._rootMesh.addBehavior(s.dragBehavior),s.dragBehavior.onDragObservable.add(function(B){if(s.attachedNode){if(s.snapDistance==0)s.attachedNode.getWorldMatrix().addTranslationFromFloats(B.delta.x,B.delta.y,B.delta.z);else if(d+=B.dragDistance,Math.abs(d)>s.snapDistance){var F=Math.floor(Math.abs(d)/s.snapDistance);d%=s.snapDistance,B.delta.normalizeToRef(p),p.scaleInPlace(s.snapDistance*F),s.attachedNode.getWorldMatrix().addTranslationFromFloats(p.x,p.y,p.z),b.snapDistance=s.snapDistance*F,s.onSnapObservable.notifyObservers(b)}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._coloredMaterial,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(B){var F;if(!s._customMeshSet&&(s._isHovered=O.colliderMeshes.indexOf((F=B?.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 Er.a("plane",e),o=Rs.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}(wn.a),du=function(r){function t(e,n,i){e===void 0&&(e=On.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 C.c,o.onDragEndObservable=new C.c,o._planarGizmoEnabled=!1,o.xGizmo=new Yo.a(new u.e(1,0,0),M.a.Red().scale(.5),e,o,n),o.yGizmo=new Yo.a(new u.e(0,1,0),M.a.Green().scale(.5),e,o,n),o.zGizmo=new Yo.a(new u.e(0,0,1),M.a.Blue().scale(.5),e,o,n),o.xPlaneGizmo=new Qo(new u.e(1,0,0),M.a.Red().scale(.5),o.gizmoLayer,o),o.yPlaneGizmo=new Qo(new u.e(0,1,0),M.a.Green().scale(.5),o.gizmoLayer,o),o.zPlaneGizmo=new Qo(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):wn.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].forEach(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}(wn.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,-.969981],[-.487004,.26021,.48049],[-.460089,-.750282,-.512622],[-.376468,.973135,-.325605],[-.331735,-.646985,.084342],[-.254001,.831847,.530001],[-.125239,-.494738,-.966586],[.029622,.027949,.730817],[.056536,-.982543,-.262295],[.08085,1.087391,.076037],[.125583,-.532729,.485984],[.262625,.599586,.780328],[.391387,-.726999,-.716259],[.513854,-.868287,.139347],[.597475,.85513,.326364],[.641224,.109523,.783723],[.737185,-.451155,.538891],[.848705,-.612742,-.314616],[.976075,.365067,.32976],[1.072036,-.19561,.084927]],face:[[15,18,21],[12,20,16],[6,10,2],[3,0,1],[9,7,13],[2,8,4,0],[0,4,5,1],[1,5,11,7],[7,11,17,13],[13,17,22,18],[18,22,24,21],[21,24,23,20],[20,23,19,16],[16,19,14,10],[10,14,8,2],[15,9,13,18],[12,15,21,20],[6,12,16,10],[3,6,2,0],[9,3,1,7],[9,15,12,6,3],[22,17,11,5,4,8,14,19,23,24]]};var e,n,i,o,a,s,d=r.type&&(r.type<0||r.type>=t.length)?0:r.type||0,p=r.size,b=r.sizeX||p||1,P=r.sizeY||p||1,O=r.sizeZ||p||1,B=r.custom||t[d],F=B.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,Re=0,Ae=0,Ee=new Array,Se=0,Le=0;if(ie)for(Le=0;Le0&&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),qo=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 Os(r,u.e.Zero(),t)}});var Os=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()},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;pthis._orthoRight&&(this._orthoRight=a.x),a.y>this._orthoTop&&(this._orthoTop=a.y),this.autoCalcShadowZBounds&&(a.zd&&(d=a.z))}this.autoCalcShadowZBounds&&(this._shadowMinZ=s,this._shadowMaxZ=d)}var B=this._orthoRight-this._orthoLeft,F=this._orthoTop-this._orthoBottom;u.a.OrthoOffCenterLHToRef(this._orthoLeft-B*this.shadowOrthoScale,this._orthoRight+B*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}(qo);De.a.CreateHemisphere=function(r,t,e,n){var i={segments:t,diameter:e};return Zo.CreateHemisphere(r,i,n)};var Zo=function(){function r(){}return r.CreateHemisphere=function(t,e,n){e.diameter||(e.diameter=1),e.segments||(e.segments=16);var i=Fn.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 Ms(r,u.e.Zero(),u.e.Zero(),0,0,t)}});var Ms=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()},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.setMatrix("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}(qo),hp=function(r){function t(e){e===void 0&&(e=On.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 C.c,n._light=null,n.attachedMesh=new Dt.a("",n.gizmoLayer.utilityLayerScene),n._attachedMeshParent=new Er.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 Vo.a?this._lightMesh=t._CreateHemisphericLightMesh(this.gizmoLayer.utilityLayerScene):this._lightMesh=e instanceof Os?t._CreateDirectionalLightMesh(this.gizmoLayer.utilityLayerScene):e instanceof Ms?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()}},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=Zo.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=Fn.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);Fn.a.CreateSphere(n.name,{segments:10,diameter:1},e).parent=n;var i=Zo.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,Fn.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}(wn.a),Is=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}(),dp=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}(),fp=function(r){function t(e){e===void 0&&(e=On.a.DefaultUtilityLayer);var n=r.call(this,e)||this;return n._pointerObserver=null,n.onClickedObservable=new C.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._camera&&(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,Tr.a.CreateBox(n.name,{width:1,height:.8,depth:.5},e).parent=i;var o=pi.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=pi.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=pi.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}(wn.a);ze.a.IncludesShadersStore.kernelBlurVaryingDeclaration="varying vec2 sampleCoord{X};";var pp=`vec4 pack(float depth) +{ +const vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0); +const vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0); +vec4 res=fract(depth*bit_shift); +res-=res.xxyz*bit_mask; +return res; +} +float unpack(vec4 color) +{ +const vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0); +return dot(color,bit_shift); +}`;ze.a.IncludesShadersStore.packingFunctions=pp;var _p=`#ifdef DOF +factor=sampleCoC(sampleCoord{X}); +computedWeight=KERNEL_WEIGHT{X}*factor; +sumOfWeights+=computedWeight; +#else +computedWeight=KERNEL_WEIGHT{X}; +#endif +#ifdef PACKEDFLOAT +blend+=unpack(texture2D(textureSampler,sampleCoord{X}))*computedWeight; +#else +blend+=texture2D(textureSampler,sampleCoord{X})*computedWeight; +#endif`;ze.a.IncludesShadersStore.kernelBlurFragment=_p;var mp=`#ifdef DOF +factor=sampleCoC(sampleCenter+delta*KERNEL_DEP_OFFSET{X}); +computedWeight=KERNEL_DEP_WEIGHT{X}*factor; +sumOfWeights+=computedWeight; +#else +computedWeight=KERNEL_DEP_WEIGHT{X}; +#endif +#ifdef PACKEDFLOAT +blend+=unpack(texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X}))*computedWeight; +#else +blend+=texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X})*computedWeight; +#endif`;ze.a.IncludesShadersStore.kernelBlurFragment2=mp;var gp=` +uniform sampler2D textureSampler; +uniform vec2 delta; + +varying vec2 sampleCenter; +#ifdef DOF +uniform sampler2D circleOfConfusionSampler; +uniform vec2 cameraMinMaxZ; +float sampleDistance(const in vec2 offset) { +float depth=texture2D(circleOfConfusionSampler,offset).g; +return cameraMinMaxZ.x+(cameraMinMaxZ.y-cameraMinMaxZ.x)*depth; +} +float sampleCoC(const in vec2 offset) { +float coc=texture2D(circleOfConfusionSampler,offset).r; +return coc; +} +#endif +#include[0..varyingCount] +#ifdef PACKEDFLOAT +#include +#endif +void main(void) +{ +float computedWeight=0.0; +#ifdef PACKEDFLOAT +float blend=0.; +#else +vec4 blend=vec4(0.); +#endif +#ifdef DOF +float sumOfWeights=CENTER_WEIGHT; +float factor=0.0; + +#ifdef PACKEDFLOAT +blend+=unpack(texture2D(textureSampler,sampleCenter))*CENTER_WEIGHT; +#else +blend+=texture2D(textureSampler,sampleCenter)*CENTER_WEIGHT; +#endif +#endif +#include[0..varyingCount] +#include[0..depCount] +#ifdef PACKEDFLOAT +gl_FragColor=pack(blend); +#else +gl_FragColor=blend; +#endif +#ifdef DOF +gl_FragColor/=sumOfWeights; +#endif +}`;ze.a.ShadersStore.kernelBlurPixelShader=gp,ze.a.IncludesShadersStore.kernelBlurVertex="sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";var vp=` +attribute vec2 position; + +uniform vec2 delta; + +varying vec2 sampleCenter; +#include[0..varyingCount] +const vec2 madd=vec2(0.5,0.5); +void main(void) { +sampleCenter=(position*madd+madd); +#include[0..varyingCount] +gl_Position=vec4(position,0.0,1.0); +}`;ze.a.ShadersStore.kernelBlurVertexShader=vp;var gn=function(r){function t(e,n,i,o,a,s,d,p,b,P,O){s===void 0&&(s=we.a.BILINEAR_SAMPLINGMODE),b===void 0&&(b=h.a.TEXTURETYPE_UNSIGNED_INT),P===void 0&&(P=""),O===void 0&&(O=!1);var B=r.call(this,e,"kernelBlur",["delta","direction","cameraMinMaxZ"],["circleOfConfusionSampler"],o,a,s,d,p,null,b,"kernelBlur",{varyingCount:0,depCount:0},!0)||this;return B.blockCompilation=O,B._packedFloat=!1,B._staticDefines="",B._staticDefines=P,B.direction=n,B.onApplyObservable.add(function(F){B._outputTexture?F.setFloat2("delta",1/B._outputTexture.width*B.direction.x,1/B._outputTexture.height*B.direction.y):F.setFloat2("delta",1/B.width*B.direction.x,1/B.height*B.direction.y)}),B.kernel=i,B}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;p0)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"]=gn;var Ds=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 vr.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())},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 gn("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 gn("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 Ds(r,t,e,n)};var qn=f(34),ai=function(r){function t(e,n,i,o,a,s,d,p,b,P,O,B,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),b===void 0&&(b=!1),P===void 0&&(P=null),O===void 0&&(O=!1),B===void 0&&(B=.8),F===void 0&&(F=0);var ie=r.call(this,n)||this;if(ie.onLoadObservable=new C.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=b,b&&(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 +#define RECIPROCAL_PI2 0.15915494 + +uniform vec3 vEyePosition; + +varying vec3 vPositionW; +#ifdef MAINUV1 +varying vec2 vMainUV1; +#endif +#ifdef MAINUV2 +varying vec2 vMainUV2; +#endif +#ifdef NORMAL +varying vec3 vNormalW; +#endif +#ifdef DIFFUSE +#if DIFFUSEDIRECTUV == 1 +#define vDiffuseUV vMainUV1 +#elif DIFFUSEDIRECTUV == 2 +#define vDiffuseUV vMainUV2 +#else +varying vec2 vDiffuseUV; +#endif +uniform sampler2D diffuseSampler; +#endif + +#ifdef REFLECTION +#ifdef REFLECTIONMAP_3D +#define sampleReflection(s,c) textureCube(s,c) +uniform samplerCube reflectionSampler; +#ifdef TEXTURELODSUPPORT +#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l) +#else +uniform samplerCube reflectionSamplerLow; +uniform samplerCube reflectionSamplerHigh; +#endif +#else +#define sampleReflection(s,c) texture2D(s,c) +uniform sampler2D reflectionSampler; +#ifdef TEXTURELODSUPPORT +#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l) +#else +uniform samplerCube reflectionSamplerLow; +uniform samplerCube reflectionSamplerHigh; +#endif +#endif +#ifdef REFLECTIONMAP_SKYBOX +varying vec3 vPositionUVW; +#else +#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) +varying vec3 vDirectionW; +#endif +#endif +#include +#endif + +#ifndef FROMLINEARSPACE +#define FROMLINEARSPACE; +#endif + +#ifndef SHADOWONLY +#define SHADOWONLY; +#endif +#include + +#include<__decl__lightFragment>[0..maxSimultaneousLights] +#include +#include +#include +#include +#include + +#include +#ifdef REFLECTIONFRESNEL +#define FRESNEL_MAXIMUM_ON_ROUGH 0.25 +vec3 fresnelSchlickEnvironmentGGX(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness) +{ + +float weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness); +return reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN)); +} +#endif +void main(void) { +#include +vec3 viewDirectionW=normalize(vEyePosition-vPositionW); + +#ifdef NORMAL +vec3 normalW=normalize(vNormalW); +#else +vec3 normalW=vec3(0.0,1.0,0.0); +#endif + +float shadow=1.; +float globalShadow=0.; +float shadowLightCount=0.; +#include[0..maxSimultaneousLights] +#ifdef SHADOWINUSE +globalShadow/=shadowLightCount; +#else +globalShadow=1.0; +#endif +#ifndef BACKMAT_SHADOWONLY + +vec4 reflectionColor=vec4(1.,1.,1.,1.); +#ifdef REFLECTION +vec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW); +#ifdef REFLECTIONMAP_OPPOSITEZ +reflectionVector.z*=-1.0; +#endif + +#ifdef REFLECTIONMAP_3D +vec3 reflectionCoords=reflectionVector; +#else +vec2 reflectionCoords=reflectionVector.xy; +#ifdef REFLECTIONMAP_PROJECTION +reflectionCoords/=reflectionVector.z; +#endif +reflectionCoords.y=1.0-reflectionCoords.y; +#endif +#ifdef REFLECTIONBLUR +float reflectionLOD=vReflectionInfos.y; +#ifdef TEXTURELODSUPPORT + +reflectionLOD=reflectionLOD*log2(vReflectionMicrosurfaceInfos.x)*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z; +reflectionColor=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD); +#else +float lodReflectionNormalized=saturate(reflectionLOD); +float lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0; +vec4 reflectionSpecularMid=sampleReflection(reflectionSampler,reflectionCoords); +if(lodReflectionNormalizedDoubled<1.0){ +reflectionColor=mix( +sampleReflection(reflectionSamplerHigh,reflectionCoords), +reflectionSpecularMid, +lodReflectionNormalizedDoubled +); +} else { +reflectionColor=mix( +reflectionSpecularMid, +sampleReflection(reflectionSamplerLow,reflectionCoords), +lodReflectionNormalizedDoubled-1.0 +); +} +#endif +#else +vec4 reflectionSample=sampleReflection(reflectionSampler,reflectionCoords); +reflectionColor=reflectionSample; +#endif +#ifdef RGBDREFLECTION +reflectionColor.rgb=fromRGBD(reflectionColor); +#endif +#ifdef GAMMAREFLECTION +reflectionColor.rgb=toLinearSpace(reflectionColor.rgb); +#endif +#ifdef REFLECTIONBGR +reflectionColor.rgb=reflectionColor.bgr; +#endif + +reflectionColor.rgb*=vReflectionInfos.x; +#endif + +vec3 diffuseColor=vec3(1.,1.,1.); +float finalAlpha=alpha; +#ifdef DIFFUSE +vec4 diffuseMap=texture2D(diffuseSampler,vDiffuseUV); +#ifdef GAMMADIFFUSE +diffuseMap.rgb=toLinearSpace(diffuseMap.rgb); +#endif + +diffuseMap.rgb*=vDiffuseInfos.y; +#ifdef DIFFUSEHASALPHA +finalAlpha*=diffuseMap.a; +#endif +diffuseColor=diffuseMap.rgb; +#endif + +#ifdef REFLECTIONFRESNEL +vec3 colorBase=diffuseColor; +#else +vec3 colorBase=reflectionColor.rgb*diffuseColor; +#endif +colorBase=max(colorBase,0.0); + +#ifdef USERGBCOLOR +vec3 finalColor=colorBase; +#else +#ifdef USEHIGHLIGHTANDSHADOWCOLORS +vec3 mainColor=mix(vPrimaryColorShadow.rgb,vPrimaryColor.rgb,colorBase); +#else +vec3 mainColor=vPrimaryColor.rgb; +#endif +vec3 finalColor=colorBase*mainColor; +#endif + +#ifdef REFLECTIONFRESNEL +vec3 reflectionAmount=vReflectionControl.xxx; +vec3 reflectionReflectance0=vReflectionControl.yyy; +vec3 reflectionReflectance90=vReflectionControl.zzz; +float VdotN=dot(normalize(vEyePosition),normalW); +vec3 planarReflectionFresnel=fresnelSchlickEnvironmentGGX(saturate(VdotN),reflectionReflectance0,reflectionReflectance90,1.0); +reflectionAmount*=planarReflectionFresnel; +#ifdef REFLECTIONFALLOFF +float reflectionDistanceFalloff=1.0-saturate(length(vPositionW.xyz-vBackgroundCenter)*vReflectionControl.w); +reflectionDistanceFalloff*=reflectionDistanceFalloff; +reflectionAmount*=reflectionDistanceFalloff; +#endif +finalColor=mix(finalColor,reflectionColor.rgb,saturate(reflectionAmount)); +#endif +#ifdef OPACITYFRESNEL +float viewAngleToFloor=dot(normalW,normalize(vEyePosition-vBackgroundCenter)); + +const float startAngle=0.1; +float fadeFactor=saturate(viewAngleToFloor/startAngle); +finalAlpha*=fadeFactor*fadeFactor; +#endif + +#ifdef SHADOWINUSE +finalColor=mix(finalColor*shadowLevel,finalColor,globalShadow); +#endif + +vec4 color=vec4(finalColor,finalAlpha); +#else +vec4 color=vec4(vPrimaryColor.rgb,(1.0-clamp(globalShadow,0.,1.))*alpha); +#endif +#include +#ifdef IMAGEPROCESSINGPOSTPROCESS + + +color.rgb=clamp(color.rgb,0.,30.0); +#else + +color=applyImageProcessing(color); +#endif +#ifdef PREMULTIPLYALPHA + +color.rgb*=color.a; +#endif +#ifdef NOISE +color.rgb+=dither(vPositionW.xy,0.5); +color=max(color,0.0); +#endif +gl_FragColor=color; +} +`;ze.a.ShadersStore.backgroundPixelShader=Tp;var Ep=`uniform mat4 view; +uniform mat4 viewProjection; +uniform float shadowLevel; +#ifdef DIFFUSE +uniform mat4 diffuseMatrix; +uniform vec2 vDiffuseInfos; +#endif +#ifdef REFLECTION +uniform vec2 vReflectionInfos; +uniform mat4 reflectionMatrix; +uniform vec3 vReflectionMicrosurfaceInfos; +uniform float fFovMultiplier; +#endif +#ifdef POINTSIZE +uniform float pointSize; +#endif`;ze.a.IncludesShadersStore.backgroundVertexDeclaration=Ep,f(78),f(79),f(117),f(137),f(80),f(81),f(111),f(157),f(138);var Sp=`precision highp float; +#include<__decl__backgroundVertex> +#include + +attribute vec3 position; +#ifdef NORMAL +attribute vec3 normal; +#endif +#include + +#include + +varying vec3 vPositionW; +#ifdef NORMAL +varying vec3 vNormalW; +#endif +#ifdef UV1 +attribute vec2 uv; +#endif +#ifdef UV2 +attribute vec2 uv2; +#endif +#ifdef MAINUV1 +varying vec2 vMainUV1; +#endif +#ifdef MAINUV2 +varying vec2 vMainUV2; +#endif +#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0 +varying vec2 vDiffuseUV; +#endif +#include +#include +#include<__decl__lightFragment>[0..maxSimultaneousLights] +#ifdef REFLECTIONMAP_SKYBOX +varying vec3 vPositionUVW; +#endif +#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) +varying vec3 vDirectionW; +#endif +void main(void) { +#ifdef REFLECTIONMAP_SKYBOX +vPositionUVW=position; +#endif +#include +#include +#ifdef MULTIVIEW +if (gl_ViewID_OVR == 0u) { +gl_Position=viewProjection*finalWorld*vec4(position,1.0); +} else { +gl_Position=viewProjectionR*finalWorld*vec4(position,1.0); +} +#else +gl_Position=viewProjection*finalWorld*vec4(position,1.0); +#endif +vec4 worldPos=finalWorld*vec4(position,1.0); +vPositionW=vec3(worldPos); +#ifdef NORMAL +mat3 normalWorld=mat3(finalWorld); +#ifdef NONUNIFORMSCALING +normalWorld=transposeMat3(inverseMat3(normalWorld)); +#endif +vNormalW=normalize(normalWorld*normal); +#endif +#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) +vDirectionW=normalize(vec3(finalWorld*vec4(position,0.0))); +#ifdef EQUIRECTANGULAR_RELFECTION_FOV +mat3 screenToWorld=inverseMat3(mat3(finalWorld*viewProjection)); +vec3 segment=mix(vDirectionW,screenToWorld*vec3(0.0,0.0,1.0),abs(fFovMultiplier-1.0)); +if (fFovMultiplier<=1.0) { +vDirectionW=normalize(segment); +} else { +vDirectionW=normalize(vDirectionW+(vDirectionW-segment)); +} +#endif +#endif +#ifndef UV1 +vec2 uv=vec2(0.,0.); +#endif +#ifndef UV2 +vec2 uv2=vec2(0.,0.); +#endif +#ifdef MAINUV1 +vMainUV1=uv; +#endif +#ifdef MAINUV2 +vMainUV2=uv2; +#endif +#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0 +if (vDiffuseInfos.x == 0.) +{ +vDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0)); +} +else +{ +vDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0)); +} +#endif + +#include + +#include + +#include[0..maxSimultaneousLights] + +#ifdef VERTEXCOLOR +vColor=color; +#endif + +#ifdef POINTSIZE +gl_PointSize=pointSize; +#endif +} +`;ze.a.ShadersStore.backgroundVertexShader=Sp;var Sr=f(67),Ap=function(r){function t(){var e=r.call(this)||this;return e.DIFFUSE=!1,e.DIFFUSEDIRECTUV=0,e.GAMMADIFFUSE=!1,e.DIFFUSEHASALPHA=!1,e.OPACITYFRESNEL=!1,e.REFLECTIONBLUR=!1,e.REFLECTIONFRESNEL=!1,e.REFLECTIONFALLOFF=!1,e.TEXTURELODSUPPORT=!1,e.PREMULTIPLYALPHA=!1,e.USERGBCOLOR=!1,e.USEHIGHLIGHTANDSHADOWCOLORS=!1,e.BACKMAT_SHADOWONLY=!1,e.NOISE=!1,e.REFLECTIONBGR=!1,e.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}(Jo.a),so=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 fi.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.getScene().imageProcessingConfiguration,this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add(function(){n._computePrimaryColorFromPerceptualColor(),n._markAllSubMeshesAsImageProcessingDirty()})))},Object.defineProperty(t.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this.imageProcessingConfiguration.colorGradingTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorCurves",{get:function(){return this.imageProcessingConfiguration.colorCurves},set:function(e){this.imageProcessingConfiguration.colorCurves=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasRenderTargetTextures",{get:function(){return!(!this._diffuseTexture||!this._diffuseTexture.isRenderTarget)||!(!this._reflectionTexture||!this._reflectionTexture.isRenderTarget)},enumerable:!1,configurable:!0}),t.prototype.needAlphaTesting=function(){return!0},t.prototype.needAlphaBlending=function(){return this.alpha<1||this._diffuseTexture!=null&&this._diffuseTexture.hasAlpha||this._shadowOnly},t.prototype.isReadyForSubMesh=function(e,n,i){var o=this;if(i===void 0&&(i=!1),n.effect&&this.isFrozen&&n.effect._wasPreviouslyReady)return!0;n._materialDefines||(n._materialDefines=new Ap);var a=this.getScene(),s=n._materialDefines;if(this._isReadyForSubMesh(n))return!0;var d=a.getEngine();if(et.a.PrepareDefinesForLights(a,e,s,!1,this._maxSimultaneousLights),s._needNormals=!0,et.a.PrepareDefinesForMultiview(a,s),s._areTexturesDirty){if(s._needUVs=!1,a.texturesEnabled){if(a.getEngine().getCaps().textureLOD&&(s.TEXTURELODSUPPORT=!0),this._diffuseTexture&&ut.a.DiffuseTextureEnabled){if(!this._diffuseTexture.isReadyOrNotBlocking())return!1;et.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&&ut.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}if(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(et.a.PrepareDefinesForMisc(e,a,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),s),et.a.PrepareDefinesForFrameBoundValues(a,d,s,i,null,n.getRenderingMesh().hasThinInstances),et.a.PrepareDefinesForAttributes(e,s,!1,!0,!1)&&e&&(a.getEngine().getCaps().standardDerivatives||e.isVerticesDataPresent(Oe.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 b=new Sr.a;s.FOG&&b.addFallback(0,"FOG"),s.POINTSIZE&&b.addFallback(1,"POINTSIZE"),s.MULTIVIEW&&b.addFallback(0,"MULTIVIEW"),et.a.HandleFallbacksForShadows(s,b,this._maxSimultaneousLights);var P=[Oe.b.PositionKind];s.NORMAL&&P.push(Oe.b.NormalKind),s.UV1&&P.push(Oe.b.UVKind),s.UV2&&P.push(Oe.b.UV2Kind),et.a.PrepareAttributesForBones(P,e,s,b),et.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"],B=["diffuseSampler","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh"],F=["Material","Scene"];yn.a&&(yn.a.PrepareUniforms(O,s),yn.a.PrepareSamplers(B,s)),et.a.PrepareUniformsAndSamplersList({uniformsNames:O,uniformBuffersNames:F,samplers:B,defines:s,maxSimultaneousLights:this._maxSimultaneousLights});var z=s.toString();n.setEffect(a.getEngine().createEffect("background",{attributes:P,uniformsNames:O,uniformBuffersNames:F,samplers:B,defines:z,fallbacks:b,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("vBackgroundCenter",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),et.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&&ut.a.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),et.a.BindTextureMatrix(this._diffuseTexture,this._uniformBuffer,"diffuse")),p&&ut.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&&ut.a.DiffuseTextureEnabled&&this._uniformBuffer.setTexture("diffuseSampler",this._diffuseTexture),p&&ut.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("vBackgroundCenter",this.sceneCenter.x,this.sceneCenter.y,this.sceneCenter.z),this._uniformBuffer.updateFloat4("vReflectionControl",this._reflectionControls.x,this._reflectionControls.y,this._reflectionControls.z,this._reflectionControls.w)))),et.a.BindClipPlane(this._activeEffect,o),et.a.BindEyePosition(s,o)}!d&&this.isFrozen||(o.lightsEnabled&&et.a.BindLights(o,n,this._activeEffect,a,this._maxSimultaneousLights,!1),this.bindView(s),et.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);return 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}($o.a);R.a.RegisteredTypes["BABYLON.BackgroundMaterial"]=so;var Ls=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 C.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=ai.CreateFromPrefilteredData(this._options.environmentTexture,this._scene);this._scene.environmentTexture=t}},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 Ji&&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 so("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;if(!this._groundMirror&&(this._groundMirror=new Ds("BackgroundPlaneMirrorTexture",{ratio:this._options.groundMirrorSizeRatio},this._scene,!1,this._options.groundMirrorTextureType,we.a.BILINEAR_SAMPLINGMODE,!0),this._groundMirror.mirrorPlane=new vr.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;n0&&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)},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}(),Pr=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&&ut.a.AnisotropicTextureEnabled&&!this._texture.isReadyOrNotBlocking())},r.prototype.prepareDefines=function(t,e,n){this._isEnabled?(t.ANISOTROPIC=this._isEnabled,this._isEnabled&&!e.isVerticesDataPresent(Oe.b.TangentKind)&&(t._needUVs=!0,t.MAINUV1=!0),t._areTexturesDirty&&n.texturesEnabled&&(this._texture&&ut.a.AnisotropicTextureEnabled?et.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&&ut.a.AnisotropicTextureEnabled&&(t.updateFloat2("vAnisotropyInfos",this._texture.coordinatesIndex,this._texture.level),et.a.BindTextureMatrix(this._texture,t,"anisotropy")),t.updateFloat3("vAnisotropy",this.direction.x,this.direction.y,this.intensity)),e.texturesEnabled&&this._texture&&ut.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}(),xp=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)(),Object(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}(),co=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&&ut.a.SheenTextureEnabled&&!this._texture.isReadyOrNotBlocking()||this._textureRoughness&&ut.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&&ut.a.SheenTextureEnabled?et.a.PrepareDefinesForMergedUV(this._texture,t,"SHEEN_TEXTURE"):t.SHEEN_TEXTURE=!1,this._textureRoughness&&ut.a.SheenTextureEnabled?et.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,b,P,O,B=i._materialDefines,F=B.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL;t.useUbo&&n&&t.isSync||(F&&ut.a.SheenTextureEnabled?(t.updateFloat4("vSheenInfos",this._texture.coordinatesIndex,this._texture.level,-1,-1),et.a.BindTextureMatrix(this._texture,t,"sheen")):(this._texture||this._textureRoughness)&&ut.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,(b=(p=this._textureRoughness)===null||p===void 0?void 0:p.coordinatesIndex)!==null&&b!==void 0?b:0,(O=(P=this._textureRoughness)===null||P===void 0?void 0:P.level)!==null&&O!==void 0?O:0),this._texture&&et.a.BindTextureMatrix(this._texture,t,"sheen"),!this._textureRoughness||F||B.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE||et.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&&ut.a.SheenTextureEnabled&&t.setTexture("sheenSampler",this._texture),this._textureRoughness&&!F&&!B.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE&&ut.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)},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}(),lo=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&&ut.a.ThicknessTextureEnabled&&!this._thicknessTexture.isReadyOrNotBlocking())return!1;var n=this._getRefractionTexture(e);if(n&&ut.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&&ut.a.ThicknessTextureEnabled&&et.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&&ut.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);if(!t.useUbo||!i||!t.isSync){if(this._thicknessTexture&&ut.a.ThicknessTextureEnabled&&(t.updateFloat2("vThicknessInfos",this._thicknessTexture.coordinatesIndex,this._thicknessTexture.level),et.a.BindTextureMatrix(this._thicknessTexture,t,"thickness")),t.updateFloat2("vThicknessParam",this.minimumThickness,this.maximumThickness-this.minimumThickness),s&&ut.a.RefractionTextureEnabled){t.updateMatrix("refractionMatrix",s.getReflectionTextureMatrix());var d=1;s.isCube||s.depth&&(d=s.depth);var p=s.getSize().width,b=this.volumeIndexOfRefraction;t.updateFloat4("vRefractionInfos",s.level,1/b,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&&ut.a.ThicknessTextureEnabled&&t.setTexture("thicknessSampler",this._thicknessTexture),s&&ut.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){ut.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!!(ut.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)},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}(),Ns=f(105),Ht=f(25),Cp=(f(160),`uniform vec3 vReflectionColor; +uniform vec4 vAlbedoColor; + +uniform vec4 vLightingIntensity; +uniform vec4 vReflectivityColor; +uniform vec4 vMetallicReflectanceFactors; +uniform vec3 vEmissiveColor; +uniform float visibility; + +#ifdef ALBEDO +uniform vec2 vAlbedoInfos; +#endif +#ifdef AMBIENT +uniform vec4 vAmbientInfos; +#endif +#ifdef BUMP +uniform vec3 vBumpInfos; +uniform vec2 vTangentSpaceParams; +#endif +#ifdef OPACITY +uniform vec2 vOpacityInfos; +#endif +#ifdef EMISSIVE +uniform vec2 vEmissiveInfos; +#endif +#ifdef LIGHTMAP +uniform vec2 vLightmapInfos; +#endif +#ifdef REFLECTIVITY +uniform vec3 vReflectivityInfos; +#endif +#ifdef MICROSURFACEMAP +uniform vec2 vMicroSurfaceSamplerInfos; +#endif + +#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(SS_REFRACTION) +uniform mat4 view; +#endif + +#ifdef REFLECTION +uniform vec2 vReflectionInfos; +#ifdef REALTIME_FILTERING +uniform vec2 vReflectionFilteringInfo; +#endif +uniform mat4 reflectionMatrix; +uniform vec3 vReflectionMicrosurfaceInfos; +#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC) +uniform vec3 vReflectionPosition; +uniform vec3 vReflectionSize; +#endif +#endif + +#ifdef CLEARCOAT +uniform vec2 vClearCoatParams; +uniform vec4 vClearCoatRefractionParams; +#if defined(CLEARCOAT_TEXTURE) || defined(CLEARCOAT_TEXTURE_ROUGHNESS) +uniform vec4 vClearCoatInfos; +#endif +#ifdef CLEARCOAT_TEXTURE +uniform mat4 clearCoatMatrix; +#endif +#ifdef CLEARCOAT_TEXTURE_ROUGHNESS +uniform mat4 clearCoatRoughnessMatrix; +#endif +#ifdef CLEARCOAT_BUMP +uniform vec2 vClearCoatBumpInfos; +uniform vec2 vClearCoatTangentSpaceParams; +uniform mat4 clearCoatBumpMatrix; +#endif +#ifdef CLEARCOAT_TINT +uniform vec4 vClearCoatTintParams; +uniform float clearCoatColorAtDistance; +#ifdef CLEARCOAT_TINT_TEXTURE +uniform vec2 vClearCoatTintInfos; +uniform mat4 clearCoatTintMatrix; +#endif +#endif +#endif + +#ifdef ANISOTROPIC +uniform vec3 vAnisotropy; +#ifdef ANISOTROPIC_TEXTURE +uniform vec2 vAnisotropyInfos; +uniform mat4 anisotropyMatrix; +#endif +#endif + +#ifdef SHEEN +uniform vec4 vSheenColor; +#ifdef SHEEN_ROUGHNESS +uniform float vSheenRoughness; +#endif +#if defined(SHEEN_TEXTURE) || defined(SHEEN_TEXTURE_ROUGHNESS) +uniform vec4 vSheenInfos; +#endif +#ifdef SHEEN_TEXTURE +uniform mat4 sheenMatrix; +#endif +#ifdef SHEEN_TEXTURE_ROUGHNESS +uniform mat4 sheenRoughnessMatrix; +#endif +#endif + +#ifdef SUBSURFACE +#ifdef SS_REFRACTION +uniform vec3 vRefractionMicrosurfaceInfos; +uniform vec4 vRefractionInfos; +uniform mat4 refractionMatrix; +#ifdef REALTIME_FILTERING +uniform vec2 vRefractionFilteringInfo; +#endif +#endif +#ifdef SS_THICKNESSANDMASK_TEXTURE +uniform vec2 vThicknessInfos; +uniform mat4 thicknessMatrix; +#endif +uniform vec2 vThicknessParam; +uniform vec3 vDiffusionDistance; +uniform vec4 vTintColor; +uniform vec3 vSubSurfaceIntensity; +#endif +#ifdef PREPASS +#ifdef PREPASS_IRRADIANCE +uniform float scatteringDiffusionProfile; +#endif +#endif`);ze.a.IncludesShadersStore.pbrFragmentDeclaration=Cp;var Rp=`layout(std140,column_major) uniform; +uniform Material +{ +uniform vec2 vAlbedoInfos; +uniform vec4 vAmbientInfos; +uniform vec2 vOpacityInfos; +uniform vec2 vEmissiveInfos; +uniform vec2 vLightmapInfos; +uniform vec3 vReflectivityInfos; +uniform vec2 vMicroSurfaceSamplerInfos; +uniform vec2 vReflectionInfos; +uniform vec2 vReflectionFilteringInfo; +uniform vec3 vReflectionPosition; +uniform vec3 vReflectionSize; +uniform vec3 vBumpInfos; +uniform mat4 albedoMatrix; +uniform mat4 ambientMatrix; +uniform mat4 opacityMatrix; +uniform mat4 emissiveMatrix; +uniform mat4 lightmapMatrix; +uniform mat4 reflectivityMatrix; +uniform mat4 microSurfaceSamplerMatrix; +uniform mat4 bumpMatrix; +uniform vec2 vTangentSpaceParams; +uniform mat4 reflectionMatrix; +uniform vec3 vReflectionColor; +uniform vec4 vAlbedoColor; +uniform vec4 vLightingIntensity; +uniform vec3 vReflectionMicrosurfaceInfos; +uniform float pointSize; +uniform vec4 vReflectivityColor; +uniform vec3 vEmissiveColor; +uniform float visibility; +uniform vec4 vMetallicReflectanceFactors; +uniform vec2 vMetallicReflectanceInfos; +uniform mat4 metallicReflectanceMatrix; +uniform vec2 vClearCoatParams; +uniform vec4 vClearCoatRefractionParams; +uniform vec4 vClearCoatInfos; +uniform mat4 clearCoatMatrix; +uniform mat4 clearCoatRoughnessMatrix; +uniform vec2 vClearCoatBumpInfos; +uniform vec2 vClearCoatTangentSpaceParams; +uniform mat4 clearCoatBumpMatrix; +uniform vec4 vClearCoatTintParams; +uniform float clearCoatColorAtDistance; +uniform vec2 vClearCoatTintInfos; +uniform mat4 clearCoatTintMatrix; +uniform vec3 vAnisotropy; +uniform vec2 vAnisotropyInfos; +uniform mat4 anisotropyMatrix; +uniform vec4 vSheenColor; +uniform float vSheenRoughness; +uniform vec4 vSheenInfos; +uniform mat4 sheenMatrix; +uniform mat4 sheenRoughnessMatrix; +uniform vec3 vRefractionMicrosurfaceInfos; +uniform vec2 vRefractionFilteringInfo; +uniform vec4 vRefractionInfos; +uniform mat4 refractionMatrix; +uniform vec2 vThicknessInfos; +uniform mat4 thicknessMatrix; +uniform vec2 vThicknessParam; +uniform vec3 vDiffusionDistance; +uniform vec4 vTintColor; +uniform vec3 vSubSurfaceIntensity; +uniform float scatteringDiffusionProfile; +uniform vec4 vDetailInfos; +uniform mat4 detailMatrix; +}; +uniform Scene { +mat4 viewProjection; +#ifdef MULTIVIEW +mat4 viewProjectionR; +#endif +mat4 view; +};`;ze.a.IncludesShadersStore.pbrUboDeclaration=Rp;var Op=`uniform vec4 vEyePosition; +uniform vec3 vAmbientColor; +uniform vec4 vCameraInfos; + +varying vec3 vPositionW; +#if DEBUGMODE>0 +uniform vec2 vDebugMode; +varying vec4 vClipSpacePosition; +#endif +#ifdef MAINUV1 +varying vec2 vMainUV1; +#endif +#ifdef MAINUV2 +varying vec2 vMainUV2; +#endif +#ifdef NORMAL +varying vec3 vNormalW; +#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX) +varying vec3 vEnvironmentIrradiance; +#endif +#endif +#ifdef VERTEXCOLOR +varying vec4 vColor; +#endif`;ze.a.IncludesShadersStore.pbrFragmentExtraDeclaration=Op;var Mp=`#ifdef ALBEDO +#if ALBEDODIRECTUV == 1 +#define vAlbedoUV vMainUV1 +#elif ALBEDODIRECTUV == 2 +#define vAlbedoUV vMainUV2 +#else +varying vec2 vAlbedoUV; +#endif +uniform sampler2D albedoSampler; +#endif +#ifdef AMBIENT +#if AMBIENTDIRECTUV == 1 +#define vAmbientUV vMainUV1 +#elif AMBIENTDIRECTUV == 2 +#define vAmbientUV vMainUV2 +#else +varying vec2 vAmbientUV; +#endif +uniform sampler2D ambientSampler; +#endif +#ifdef OPACITY +#if OPACITYDIRECTUV == 1 +#define vOpacityUV vMainUV1 +#elif OPACITYDIRECTUV == 2 +#define vOpacityUV vMainUV2 +#else +varying vec2 vOpacityUV; +#endif +uniform sampler2D opacitySampler; +#endif +#ifdef EMISSIVE +#if EMISSIVEDIRECTUV == 1 +#define vEmissiveUV vMainUV1 +#elif EMISSIVEDIRECTUV == 2 +#define vEmissiveUV vMainUV2 +#else +varying vec2 vEmissiveUV; +#endif +uniform sampler2D emissiveSampler; +#endif +#ifdef LIGHTMAP +#if LIGHTMAPDIRECTUV == 1 +#define vLightmapUV vMainUV1 +#elif LIGHTMAPDIRECTUV == 2 +#define vLightmapUV vMainUV2 +#else +varying vec2 vLightmapUV; +#endif +uniform sampler2D lightmapSampler; +#endif +#ifdef REFLECTIVITY +#if REFLECTIVITYDIRECTUV == 1 +#define vReflectivityUV vMainUV1 +#elif REFLECTIVITYDIRECTUV == 2 +#define vReflectivityUV vMainUV2 +#else +varying vec2 vReflectivityUV; +#endif +uniform sampler2D reflectivitySampler; +#endif +#ifdef MICROSURFACEMAP +#if MICROSURFACEMAPDIRECTUV == 1 +#define vMicroSurfaceSamplerUV vMainUV1 +#elif MICROSURFACEMAPDIRECTUV == 2 +#define vMicroSurfaceSamplerUV vMainUV2 +#else +varying vec2 vMicroSurfaceSamplerUV; +#endif +uniform sampler2D microSurfaceSampler; +#endif +#ifdef METALLIC_REFLECTANCE +#if METALLIC_REFLECTANCEDIRECTUV == 1 +#define vMetallicReflectanceUV vMainUV1 +#elif METALLIC_REFLECTANCEDIRECTUV == 2 +#define vMetallicReflectanceUV vMainUV2 +#else +varying vec2 vMetallicReflectanceUV; +#endif +uniform sampler2D metallicReflectanceSampler; +#endif +#ifdef CLEARCOAT +#if defined(CLEARCOAT_TEXTURE) +#if CLEARCOAT_TEXTUREDIRECTUV == 1 +#define vClearCoatUV vMainUV1 +#elif CLEARCOAT_TEXTUREDIRECTUV == 2 +#define vClearCoatUV vMainUV2 +#else +varying vec2 vClearCoatUV; +#endif +#endif +#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) +#if CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV == 1 +#define vClearCoatRoughnessUV vMainUV1 +#elif CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV == 2 +#define vClearCoatRoughnessUV vMainUV2 +#else +varying vec2 vClearCoatRoughnessUV; +#endif +#endif +#ifdef CLEARCOAT_TEXTURE +uniform sampler2D clearCoatSampler; +#endif +#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) +uniform sampler2D clearCoatRoughnessSampler; +#endif +#ifdef CLEARCOAT_BUMP +#if CLEARCOAT_BUMPDIRECTUV == 1 +#define vClearCoatBumpUV vMainUV1 +#elif CLEARCOAT_BUMPDIRECTUV == 2 +#define vClearCoatBumpUV vMainUV2 +#else +varying vec2 vClearCoatBumpUV; +#endif +uniform sampler2D clearCoatBumpSampler; +#endif +#ifdef CLEARCOAT_TINT_TEXTURE +#if CLEARCOAT_TINT_TEXTUREDIRECTUV == 1 +#define vClearCoatTintUV vMainUV1 +#elif CLEARCOAT_TINT_TEXTUREDIRECTUV == 2 +#define vClearCoatTintUV vMainUV2 +#else +varying vec2 vClearCoatTintUV; +#endif +uniform sampler2D clearCoatTintSampler; +#endif +#endif +#ifdef SHEEN +#ifdef SHEEN_TEXTURE +#if SHEEN_TEXTUREDIRECTUV == 1 +#define vSheenUV vMainUV1 +#elif SHEEN_TEXTUREDIRECTUV == 2 +#define vSheenUV vMainUV2 +#else +varying vec2 vSheenUV; +#endif +#endif +#ifdef SHEEN_TEXTURE_ROUGHNESS +#if SHEEN_TEXTURE_ROUGHNESSDIRECTUV == 1 +#define vSheenRoughnessUV vMainUV1 +#elif SHEEN_TEXTURE_ROUGHNESSDIRECTUV == 2 +#define vSheenRoughnessUV vMainUV2 +#else +varying vec2 vSheenRoughnessUV; +#endif +#endif +#ifdef SHEEN_TEXTURE +uniform sampler2D sheenSampler; +#endif +#if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL) +uniform sampler2D sheenRoughnessSampler; +#endif +#endif +#ifdef ANISOTROPIC +#ifdef ANISOTROPIC_TEXTURE +#if ANISOTROPIC_TEXTUREDIRECTUV == 1 +#define vAnisotropyUV vMainUV1 +#elif ANISOTROPIC_TEXTUREDIRECTUV == 2 +#define vAnisotropyUV vMainUV2 +#else +varying vec2 vAnisotropyUV; +#endif +uniform sampler2D anisotropySampler; +#endif +#endif + +#ifdef REFLECTION +#ifdef REFLECTIONMAP_3D +#define sampleReflection(s,c) textureCube(s,c) +uniform samplerCube reflectionSampler; +#ifdef LODBASEDMICROSFURACE +#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l) +#else +uniform samplerCube reflectionSamplerLow; +uniform samplerCube reflectionSamplerHigh; +#endif +#ifdef USEIRRADIANCEMAP +uniform samplerCube irradianceSampler; +#endif +#else +#define sampleReflection(s,c) texture2D(s,c) +uniform sampler2D reflectionSampler; +#ifdef LODBASEDMICROSFURACE +#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l) +#else +uniform sampler2D reflectionSamplerLow; +uniform sampler2D reflectionSamplerHigh; +#endif +#ifdef USEIRRADIANCEMAP +uniform sampler2D irradianceSampler; +#endif +#endif +#ifdef REFLECTIONMAP_SKYBOX +varying vec3 vPositionUVW; +#else +#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) +varying vec3 vDirectionW; +#endif +#endif +#endif +#ifdef ENVIRONMENTBRDF +uniform sampler2D environmentBrdfSampler; +#endif + +#ifdef SUBSURFACE +#ifdef SS_REFRACTION +#ifdef SS_REFRACTIONMAP_3D +#define sampleRefraction(s,c) textureCube(s,c) +uniform samplerCube refractionSampler; +#ifdef LODBASEDMICROSFURACE +#define sampleRefractionLod(s,c,l) textureCubeLodEXT(s,c,l) +#else +uniform samplerCube refractionSamplerLow; +uniform samplerCube refractionSamplerHigh; +#endif +#else +#define sampleRefraction(s,c) texture2D(s,c) +uniform sampler2D refractionSampler; +#ifdef LODBASEDMICROSFURACE +#define sampleRefractionLod(s,c,l) texture2DLodEXT(s,c,l) +#else +uniform sampler2D refractionSamplerLow; +uniform sampler2D refractionSamplerHigh; +#endif +#endif +#endif +#ifdef SS_THICKNESSANDMASK_TEXTURE +#if SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 1 +#define vThicknessUV vMainUV1 +#elif SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 2 +#define vThicknessUV vMainUV2 +#else +varying vec2 vThicknessUV; +#endif +uniform sampler2D thicknessSampler; +#endif +#endif`;ze.a.IncludesShadersStore.pbrFragmentSamplersDeclaration=Mp,f(116),ze.a.IncludesShadersStore.subSurfaceScatteringFunctions=`bool testLightingForSSS(float diffusionProfile) +{ +return diffusionProfile<1.; +}`;var Ip=` + + + + + + + + + + + + + + + + + + + + + + + + + + + + +vec3 hemisphereCosSample(vec2 u) { + +float phi=2.*PI*u.x; +float cosTheta2=1.-u.y; +float cosTheta=sqrt(cosTheta2); +float sinTheta=sqrt(1.-cosTheta2); +return vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +vec3 hemisphereImportanceSampleDggx(vec2 u,float a) { + +float phi=2.*PI*u.x; + +float cosTheta2=(1.-u.y)/(1.+(a+1.)*((a-1.)*u.y)); +float cosTheta=sqrt(cosTheta2); +float sinTheta=sqrt(1.-cosTheta2); +return vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +vec3 hemisphereImportanceSampleDCharlie(vec2 u,float a) { + +float phi=2.*PI*u.x; +float sinTheta=pow(u.y,a/(2.*a+1.)); +float cosTheta=sqrt(1.-sinTheta*sinTheta); +return vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta); +}`;ze.a.IncludesShadersStore.importanceSampling=Ip;var Dp=` +#define RECIPROCAL_PI2 0.15915494 +#define RECIPROCAL_PI 0.31830988618 + +#define MINIMUMVARIANCE 0.0005 +float convertRoughnessToAverageSlope(float roughness) +{ + +return square(roughness)+MINIMUMVARIANCE; +} +float fresnelGrazingReflectance(float reflectance0) { + + +float reflectance90=saturate(reflectance0*25.0); +return reflectance90; +} +vec2 getAARoughnessFactors(vec3 normalVector) { +#ifdef SPECULARAA +vec3 nDfdx=dFdx(normalVector.xyz); +vec3 nDfdy=dFdy(normalVector.xyz); +float slopeSquare=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy)); + +float geometricRoughnessFactor=pow(saturate(slopeSquare),0.333); + +float geometricAlphaGFactor=sqrt(slopeSquare); + +geometricAlphaGFactor*=0.75; +return vec2(geometricRoughnessFactor,geometricAlphaGFactor); +#else +return vec2(0.); +#endif +} +#ifdef ANISOTROPIC + + +vec2 getAnisotropicRoughness(float alphaG,float anisotropy) { +float alphaT=max(alphaG*(1.0+anisotropy),MINIMUMVARIANCE); +float alphaB=max(alphaG*(1.0-anisotropy),MINIMUMVARIANCE); +return vec2(alphaT,alphaB); +} + + +vec3 getAnisotropicBentNormals(const vec3 T,const vec3 B,const vec3 N,const vec3 V,float anisotropy) { +vec3 anisotropicFrameDirection=anisotropy>=0.0 ? B : T; +vec3 anisotropicFrameTangent=cross(normalize(anisotropicFrameDirection),V); +vec3 anisotropicFrameNormal=cross(anisotropicFrameTangent,anisotropicFrameDirection); +vec3 anisotropicNormal=normalize(mix(N,anisotropicFrameNormal,abs(anisotropy))); +return anisotropicNormal; + +} +#endif +#if defined(CLEARCOAT) || defined(SS_REFRACTION) + + + +vec3 cocaLambert(vec3 alpha,float distance) { +return exp(-alpha*distance); +} + +vec3 cocaLambert(float NdotVRefract,float NdotLRefract,vec3 alpha,float thickness) { +return cocaLambert(alpha,(thickness*((NdotLRefract+NdotVRefract)/(NdotLRefract*NdotVRefract)))); +} + +vec3 computeColorAtDistanceInMedia(vec3 color,float distance) { +return -log(color)/distance; +} +vec3 computeClearCoatAbsorption(float NdotVRefract,float NdotLRefract,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) { +vec3 clearCoatAbsorption=mix(vec3(1.0), +cocaLambert(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness), +clearCoatIntensity); +return clearCoatAbsorption; +} +#endif + + + + +#ifdef MICROSURFACEAUTOMATIC +float computeDefaultMicroSurface(float microSurface,vec3 reflectivityColor) +{ +const float kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95; +float reflectivityLuminance=getLuminance(reflectivityColor); +float reflectivityLuma=sqrt(reflectivityLuminance); +microSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax; +return microSurface; +} +#endif`;ze.a.IncludesShadersStore.pbrHelperFunctions=Dp;var Lp=`#ifdef USESPHERICALFROMREFLECTIONMAP +#ifdef SPHERICAL_HARMONICS +uniform vec3 vSphericalL00; +uniform vec3 vSphericalL1_1; +uniform vec3 vSphericalL10; +uniform vec3 vSphericalL11; +uniform vec3 vSphericalL2_2; +uniform vec3 vSphericalL2_1; +uniform vec3 vSphericalL20; +uniform vec3 vSphericalL21; +uniform vec3 vSphericalL22; + + + + + + + +vec3 computeEnvironmentIrradiance(vec3 normal) { +return vSphericalL00 ++vSphericalL1_1*(normal.y) ++vSphericalL10*(normal.z) ++vSphericalL11*(normal.x) ++vSphericalL2_2*(normal.y*normal.x) ++vSphericalL2_1*(normal.y*normal.z) ++vSphericalL20*((3.0*normal.z*normal.z)-1.0) ++vSphericalL21*(normal.z*normal.x) ++vSphericalL22*(normal.x*normal.x-(normal.y*normal.y)); +} +#else +uniform vec3 vSphericalX; +uniform vec3 vSphericalY; +uniform vec3 vSphericalZ; +uniform vec3 vSphericalXX_ZZ; +uniform vec3 vSphericalYY_ZZ; +uniform vec3 vSphericalZZ; +uniform vec3 vSphericalXY; +uniform vec3 vSphericalYZ; +uniform vec3 vSphericalZX; + +vec3 computeEnvironmentIrradiance(vec3 normal) { + + + + + + + + + +float Nx=normal.x; +float Ny=normal.y; +float Nz=normal.z; +vec3 C1=vSphericalZZ.rgb; +vec3 Cx=vSphericalX.rgb; +vec3 Cy=vSphericalY.rgb; +vec3 Cz=vSphericalZ.rgb; +vec3 Cxx_zz=vSphericalXX_ZZ.rgb; +vec3 Cyy_zz=vSphericalYY_ZZ.rgb; +vec3 Cxy=vSphericalXY.rgb; +vec3 Cyz=vSphericalYZ.rgb; +vec3 Czx=vSphericalZX.rgb; +vec3 a1=Cyy_zz*Ny+Cy; +vec3 a2=Cyz*Nz+a1; +vec3 b1=Czx*Nz+Cx; +vec3 b2=Cxy*Ny+b1; +vec3 b3=Cxx_zz*Nx+b2; +vec3 t1=Cz*Nz+C1; +vec3 t2=a2*Ny+t1; +vec3 t3=b3*Nx+t2; +return t3; +} +#endif +#endif`;ze.a.IncludesShadersStore.harmonicsFunctions=Lp;var Np=` +struct preLightingInfo +{ + +vec3 lightOffset; +float lightDistanceSquared; +float lightDistance; + +float attenuation; + +vec3 L; +vec3 H; +float NdotV; +float NdotLUnclamped; +float NdotL; +float VdotH; +float roughness; +}; +preLightingInfo computePointAndSpotPreLightingInfo(vec4 lightData,vec3 V,vec3 N) { +preLightingInfo result; + +result.lightOffset=lightData.xyz-vPositionW; +result.lightDistanceSquared=dot(result.lightOffset,result.lightOffset); + +result.lightDistance=sqrt(result.lightDistanceSquared); + +result.L=normalize(result.lightOffset); +result.H=normalize(V+result.L); +result.VdotH=saturate(dot(V,result.H)); +result.NdotLUnclamped=dot(N,result.L); +result.NdotL=saturateEps(result.NdotLUnclamped); +return result; +} +preLightingInfo computeDirectionalPreLightingInfo(vec4 lightData,vec3 V,vec3 N) { +preLightingInfo result; + +result.lightDistance=length(-lightData.xyz); + +result.L=normalize(-lightData.xyz); +result.H=normalize(V+result.L); +result.VdotH=saturate(dot(V,result.H)); +result.NdotLUnclamped=dot(N,result.L); +result.NdotL=saturateEps(result.NdotLUnclamped); +return result; +} +preLightingInfo computeHemisphericPreLightingInfo(vec4 lightData,vec3 V,vec3 N) { +preLightingInfo result; + + +result.NdotL=dot(N,lightData.xyz)*0.5+0.5; +result.NdotL=saturateEps(result.NdotL); +result.NdotLUnclamped=result.NdotL; +#ifdef SPECULARTERM +result.L=normalize(lightData.xyz); +result.H=normalize(V+result.L); +result.VdotH=saturate(dot(V,result.H)); +#endif +return result; +}`;ze.a.IncludesShadersStore.pbrDirectLightingSetupFunctions=Np;var wp=`float computeDistanceLightFalloff_Standard(vec3 lightOffset,float range) +{ +return max(0.,1.0-length(lightOffset)/range); +} +float computeDistanceLightFalloff_Physical(float lightDistanceSquared) +{ +return 1.0/maxEps(lightDistanceSquared); +} +float computeDistanceLightFalloff_GLTF(float lightDistanceSquared,float inverseSquaredRange) +{ +float lightDistanceFalloff=1.0/maxEps(lightDistanceSquared); +float factor=lightDistanceSquared*inverseSquaredRange; +float attenuation=saturate(1.0-factor*factor); +attenuation*=attenuation; + +lightDistanceFalloff*=attenuation; +return lightDistanceFalloff; +} +float computeDistanceLightFalloff(vec3 lightOffset,float lightDistanceSquared,float range,float inverseSquaredRange) +{ +#ifdef USEPHYSICALLIGHTFALLOFF +return computeDistanceLightFalloff_Physical(lightDistanceSquared); +#elif defined(USEGLTFLIGHTFALLOFF) +return computeDistanceLightFalloff_GLTF(lightDistanceSquared,inverseSquaredRange); +#else +return computeDistanceLightFalloff_Standard(lightOffset,range); +#endif +} +float computeDirectionalLightFalloff_Standard(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent) +{ +float falloff=0.0; +float cosAngle=maxEps(dot(-lightDirection,directionToLightCenterW)); +if (cosAngle>=cosHalfAngle) +{ +falloff=max(0.,pow(cosAngle,exponent)); +} +return falloff; +} +float computeDirectionalLightFalloff_Physical(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle) +{ +const float kMinusLog2ConeAngleIntensityRatio=6.64385618977; + + + + + +float concentrationKappa=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle); + + +vec4 lightDirectionSpreadSG=vec4(-lightDirection*concentrationKappa,-concentrationKappa); +float falloff=exp2(dot(vec4(directionToLightCenterW,1.0),lightDirectionSpreadSG)); +return falloff; +} +float computeDirectionalLightFalloff_GLTF(vec3 lightDirection,vec3 directionToLightCenterW,float lightAngleScale,float lightAngleOffset) +{ + + + +float cd=dot(-lightDirection,directionToLightCenterW); +float falloff=saturate(cd*lightAngleScale+lightAngleOffset); + +falloff*=falloff; +return falloff; +} +float computeDirectionalLightFalloff(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent,float lightAngleScale,float lightAngleOffset) +{ +#ifdef USEPHYSICALLIGHTFALLOFF +return computeDirectionalLightFalloff_Physical(lightDirection,directionToLightCenterW,cosHalfAngle); +#elif defined(USEGLTFLIGHTFALLOFF) +return computeDirectionalLightFalloff_GLTF(lightDirection,directionToLightCenterW,lightAngleScale,lightAngleOffset); +#else +return computeDirectionalLightFalloff_Standard(lightDirection,directionToLightCenterW,cosHalfAngle,exponent); +#endif +}`;ze.a.IncludesShadersStore.pbrDirectLightingFalloffFunctions=wp;var Fp=` +#define FRESNEL_MAXIMUM_ON_ROUGH 0.25 + + + + +#ifdef MS_BRDF_ENERGY_CONSERVATION + + +vec3 getEnergyConservationFactor(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) { +return 1.0+specularEnvironmentR0*(1.0/environmentBrdf.y-1.0); +} +#endif +#ifdef ENVIRONMENTBRDF +vec3 getBRDFLookup(float NdotV,float perceptualRoughness) { + +vec2 UV=vec2(NdotV,perceptualRoughness); + +vec4 brdfLookup=texture2D(environmentBrdfSampler,UV); +#ifdef ENVIRONMENTBRDF_RGBD +brdfLookup.rgb=fromRGBD(brdfLookup.rgba); +#endif +return brdfLookup.rgb; +} +vec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,const vec3 specularEnvironmentR90,const vec3 environmentBrdf) { +#ifdef BRDF_V_HEIGHT_CORRELATED +vec3 reflectance=(specularEnvironmentR90-specularEnvironmentR0)*environmentBrdf.x+specularEnvironmentR0*environmentBrdf.y; + +#else +vec3 reflectance=specularEnvironmentR0*environmentBrdf.x+specularEnvironmentR90*environmentBrdf.y; +#endif +return reflectance; +} +vec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) { +#ifdef BRDF_V_HEIGHT_CORRELATED +vec3 reflectance=mix(environmentBrdf.xxx,environmentBrdf.yyy,specularEnvironmentR0); +#else +vec3 reflectance=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y; +#endif +return reflectance; +} +#endif + +#if !defined(ENVIRONMENTBRDF) || defined(REFLECTIONMAP_SKYBOX) || defined(ALPHAFRESNEL) +vec3 getReflectanceFromAnalyticalBRDFLookup_Jones(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness) +{ + +float weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness); +return reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN)); +} +#endif +#if defined(SHEEN) && defined(ENVIRONMENTBRDF) + +vec3 getSheenReflectanceFromBRDFLookup(const vec3 reflectance0,const vec3 environmentBrdf) { +vec3 sheenEnvironmentReflectance=reflectance0*environmentBrdf.b; +return sheenEnvironmentReflectance; +} +#endif + + + + + + + + + + + + + + + + + + + + + + + + +vec3 fresnelSchlickGGX(float VdotH,vec3 reflectance0,vec3 reflectance90) +{ +return reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH); +} +float fresnelSchlickGGX(float VdotH,float reflectance0,float reflectance90) +{ +return reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH); +} +#ifdef CLEARCOAT + + + + + +vec3 getR0RemappedForClearCoat(vec3 f0) { +#ifdef CLEARCOAT_DEFAULTIOR +#ifdef MOBILE +return saturate(f0*(f0*0.526868+0.529324)-0.0482256); +#else +return saturate(f0*(f0*(0.941892-0.263008*f0)+0.346479)-0.0285998); +#endif +#else +vec3 s=sqrt(f0); +vec3 t=(vClearCoatRefractionParams.z+vClearCoatRefractionParams.w*s)/(vClearCoatRefractionParams.w+vClearCoatRefractionParams.z*s); +return t*t; +#endif +} +#endif + + + + + + +float normalDistributionFunction_TrowbridgeReitzGGX(float NdotH,float alphaG) +{ + + + +float a2=square(alphaG); +float d=NdotH*NdotH*(a2-1.0)+1.0; +return a2/(PI*d*d); +} +#ifdef SHEEN + + +float normalDistributionFunction_CharlieSheen(float NdotH,float alphaG) +{ +float invR=1./alphaG; +float cos2h=NdotH*NdotH; +float sin2h=1.-cos2h; +return (2.+invR)*pow(sin2h,invR*.5)/(2.*PI); +} +#endif +#ifdef ANISOTROPIC + + +float normalDistributionFunction_BurleyGGX_Anisotropic(float NdotH,float TdotH,float BdotH,const vec2 alphaTB) { +float a2=alphaTB.x*alphaTB.y; +vec3 v=vec3(alphaTB.y*TdotH,alphaTB.x*BdotH,a2*NdotH); +float v2=dot(v,v); +float w2=a2/v2; +return a2*w2*w2*RECIPROCAL_PI; +} +#endif + + + + +#ifdef BRDF_V_HEIGHT_CORRELATED + + + +float smithVisibility_GGXCorrelated(float NdotL,float NdotV,float alphaG) { +#ifdef MOBILE + +float GGXV=NdotL*(NdotV*(1.0-alphaG)+alphaG); +float GGXL=NdotV*(NdotL*(1.0-alphaG)+alphaG); +return 0.5/(GGXV+GGXL); +#else +float a2=alphaG*alphaG; +float GGXV=NdotL*sqrt(NdotV*(NdotV-a2*NdotV)+a2); +float GGXL=NdotV*sqrt(NdotL*(NdotL-a2*NdotL)+a2); +return 0.5/(GGXV+GGXL); +#endif +} +#else + + + + + + + + + + + + + + + +float smithVisibilityG1_TrowbridgeReitzGGXFast(float dot,float alphaG) +{ +#ifdef MOBILE + +return 1.0/(dot+alphaG+(1.0-alphaG)*dot )); +#else +float alphaSquared=alphaG*alphaG; +return 1.0/(dot+sqrt(alphaSquared+(1.0-alphaSquared)*dot*dot)); +#endif +} +float smithVisibility_TrowbridgeReitzGGXFast(float NdotL,float NdotV,float alphaG) +{ +float visibility=smithVisibilityG1_TrowbridgeReitzGGXFast(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGXFast(NdotV,alphaG); + +return visibility; +} +#endif +#ifdef ANISOTROPIC + + +float smithVisibility_GGXCorrelated_Anisotropic(float NdotL,float NdotV,float TdotV,float BdotV,float TdotL,float BdotL,const vec2 alphaTB) { +float lambdaV=NdotL*length(vec3(alphaTB.x*TdotV,alphaTB.y*BdotV,NdotV)); +float lambdaL=NdotV*length(vec3(alphaTB.x*TdotL,alphaTB.y*BdotL,NdotL)); +float v=0.5/(lambdaV+lambdaL); +return v; +} +#endif +#ifdef CLEARCOAT +float visibility_Kelemen(float VdotH) { + + + +return 0.25/(VdotH*VdotH); +} +#endif +#ifdef SHEEN + + + +float visibility_Ashikhmin(float NdotL,float NdotV) +{ +return 1./(4.*(NdotL+NdotV-NdotL*NdotV)); +} + +#endif + + + + + + + +float diffuseBRDF_Burley(float NdotL,float NdotV,float VdotH,float roughness) { + + +float diffuseFresnelNV=pow5(saturateEps(1.0-NdotL)); +float diffuseFresnelNL=pow5(saturateEps(1.0-NdotV)); +float diffuseFresnel90=0.5+2.0*VdotH*VdotH*roughness; +float fresnel = +(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) * +(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV); +return fresnel/PI; +} +#ifdef SS_TRANSLUCENCY + + +vec3 transmittanceBRDF_Burley(const vec3 tintColor,const vec3 diffusionDistance,float thickness) { +vec3 S=1./maxEps(diffusionDistance); +vec3 temp=exp((-0.333333333*thickness)*S); +return tintColor.rgb*0.25*(temp*temp*temp+3.0*temp); +} + + +float computeWrappedDiffuseNdotL(float NdotL,float w) { +float t=1.0+w; +float invt2=1.0/square(t); +return saturate((NdotL+w)*invt2); +} +#endif +`;ze.a.IncludesShadersStore.pbrBRDFFunctions=Fp;var Bp=`#ifdef NUM_SAMPLES +#if NUM_SAMPLES>0 +#ifdef WEBGL2 + + +float radicalInverse_VdC(uint bits) +{ +bits=(bits << 16u) | (bits >> 16u); +bits=((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); +bits=((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); +bits=((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); +bits=((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); +return float(bits)*2.3283064365386963e-10; +} +vec2 hammersley(uint i,uint N) +{ +return vec2(float(i)/float(N),radicalInverse_VdC(i)); +} +#else +float vanDerCorpus(int n,int base) +{ +float invBase=1.0/float(base); +float denom=1.0; +float result=0.0; +for(int i=0; i<32; ++i) +{ +if(n>0) +{ +denom=mod(float(n),2.0); +result+=denom*invBase; +invBase=invBase/2.0; +n=int(float(n)/2.0); +} +} +return result; +} +vec2 hammersley(int i,int N) +{ +return vec2(float(i)/float(N),vanDerCorpus(i,2)); +} +#endif +float log4(float x) { +return log2(x)/2.; +} +const float NUM_SAMPLES_FLOAT=float(NUM_SAMPLES); +const float NUM_SAMPLES_FLOAT_INVERSED=1./NUM_SAMPLES_FLOAT; +const float K=4.; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +#define inline +vec3 irradiance(samplerCube inputTexture,vec3 inputN,vec2 filteringInfo) +{ +vec3 n=normalize(inputN); +vec3 result=vec3(0.0); +vec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.); +tangent=normalize(cross(tangent,n)); +vec3 bitangent=cross(n,tangent); +mat3 tbn=mat3(tangent,bitangent,n); +float maxLevel=filteringInfo.y; +float dim0=filteringInfo.x; +float omegaP=(4.*PI)/(6.*dim0*dim0); +#ifdef WEBGL2 +for(uint i=0u; i0.) { +float pdf_inversed=PI/NoL; +float omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed; +float l=log4(omegaS)-log4(omegaP)+log4(K); +float mipLevel=clamp(l,0.0,maxLevel); +vec3 c=textureCubeLodEXT(inputTexture,tbn*Ls,mipLevel).rgb; +#ifdef GAMMA_INPUT +c=toLinearSpace(c); +#endif +result+=c; +} +} +result=result*NUM_SAMPLES_FLOAT_INVERSED; +return result; +} +#define inline +vec3 radiance(float alphaG,samplerCube inputTexture,vec3 inputN,vec2 filteringInfo) +{ +vec3 n=normalize(inputN); +if (alphaG == 0.) { +vec3 c=textureCube(inputTexture,n).rgb; +#ifdef GAMMA_INPUT +c=toLinearSpace(c); +#endif +return c; +} +vec3 result=vec3(0.); +vec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.); +tangent=normalize(cross(tangent,n)); +vec3 bitangent=cross(n,tangent); +mat3 tbn=mat3(tangent,bitangent,n); +float maxLevel=filteringInfo.y; +float dim0=filteringInfo.x; +float omegaP=(4.*PI)/(6.*dim0*dim0); +float weight=0.; +#ifdef WEBGL2 +for(uint i=0u; i0.) { +float pdf_inversed=4./normalDistributionFunction_TrowbridgeReitzGGX(NoH,alphaG); +float omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed; +float l=log4(omegaS)-log4(omegaP)+log4(K); +float mipLevel=clamp(float(l),0.0,maxLevel); +weight+=NoL; +vec3 c=textureCubeLodEXT(inputTexture,tbn*L,mipLevel).rgb; +#ifdef GAMMA_INPUT +c=toLinearSpace(c); +#endif +result+=c*NoL; +} +} +result=result/weight; +return result; +} +#endif +#endif`;ze.a.IncludesShadersStore.hdrFilteringFunctions=Bp;var Up=`#define CLEARCOATREFLECTANCE90 1.0 + +struct lightingInfo +{ +vec3 diffuse; +#ifdef SPECULARTERM +vec3 specular; +#endif +#ifdef CLEARCOAT + + +vec4 clearCoat; +#endif +#ifdef SHEEN +vec3 sheen; +#endif +}; + +float adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance) { +#if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF) + +float lightRoughness=lightRadius/lightDistance; + +float totalRoughness=saturate(lightRoughness+roughness); +return totalRoughness; +#else +return roughness; +#endif +} +vec3 computeHemisphericDiffuseLighting(preLightingInfo info,vec3 lightColor,vec3 groundColor) { +return mix(groundColor,lightColor,info.NdotL); +} +vec3 computeDiffuseLighting(preLightingInfo info,vec3 lightColor) { +float diffuseTerm=diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.roughness); +return diffuseTerm*info.attenuation*info.NdotL*lightColor; +} +#define inline +vec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){ +vec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0); +strq/=strq.w; +vec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb; +return toLinearSpace(textureColor); +} +#ifdef SS_TRANSLUCENCY +vec3 computeDiffuseAndTransmittedLighting(preLightingInfo info,vec3 lightColor,vec3 transmittance) { +float NdotL=absEps(info.NdotLUnclamped); + +float wrapNdotL=computeWrappedDiffuseNdotL(NdotL,0.02); + +float trAdapt=step(0.,info.NdotLUnclamped); +vec3 transmittanceNdotL=mix(transmittance*wrapNdotL,vec3(wrapNdotL),trAdapt); +float diffuseTerm=diffuseBRDF_Burley(NdotL,info.NdotV,info.VdotH,info.roughness); +return diffuseTerm*transmittanceNdotL*info.attenuation*lightColor; +} +#endif +#ifdef SPECULARTERM +vec3 computeSpecularLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) { +float NdotH=saturateEps(dot(N,info.H)); +float roughness=max(info.roughness,geometricRoughnessFactor); +float alphaG=convertRoughnessToAverageSlope(roughness); +vec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90); +float distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG); +#ifdef BRDF_V_HEIGHT_CORRELATED +float smithVisibility=smithVisibility_GGXCorrelated(info.NdotL,info.NdotV,alphaG); +#else +float smithVisibility=smithVisibility_TrowbridgeReitzGGXFast(info.NdotL,info.NdotV,alphaG); +#endif +vec3 specTerm=fresnel*distribution*smithVisibility; +return specTerm*info.attenuation*info.NdotL*lightColor; +} +#endif +#ifdef ANISOTROPIC +vec3 computeAnisotropicSpecularLighting(preLightingInfo info,vec3 V,vec3 N,vec3 T,vec3 B,float anisotropy,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) { +float NdotH=saturateEps(dot(N,info.H)); +float TdotH=dot(T,info.H); +float BdotH=dot(B,info.H); +float TdotV=dot(T,V); +float BdotV=dot(B,V); +float TdotL=dot(T,info.L); +float BdotL=dot(B,info.L); +float alphaG=convertRoughnessToAverageSlope(info.roughness); +vec2 alphaTB=getAnisotropicRoughness(alphaG,anisotropy); +alphaTB=max(alphaTB,square(geometricRoughnessFactor)); +vec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90); +float distribution=normalDistributionFunction_BurleyGGX_Anisotropic(NdotH,TdotH,BdotH,alphaTB); +float smithVisibility=smithVisibility_GGXCorrelated_Anisotropic(info.NdotL,info.NdotV,TdotV,BdotV,TdotL,BdotL,alphaTB); +vec3 specTerm=fresnel*distribution*smithVisibility; +return specTerm*info.attenuation*info.NdotL*lightColor; +} +#endif +#ifdef CLEARCOAT +vec4 computeClearCoatLighting(preLightingInfo info,vec3 Ncc,float geometricRoughnessFactor,float clearCoatIntensity,vec3 lightColor) { +float NccdotL=saturateEps(dot(Ncc,info.L)); +float NccdotH=saturateEps(dot(Ncc,info.H)); +float clearCoatRoughness=max(info.roughness,geometricRoughnessFactor); +float alphaG=convertRoughnessToAverageSlope(clearCoatRoughness); +float fresnel=fresnelSchlickGGX(info.VdotH,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90); +fresnel*=clearCoatIntensity; +float distribution=normalDistributionFunction_TrowbridgeReitzGGX(NccdotH,alphaG); +float kelemenVisibility=visibility_Kelemen(info.VdotH); +float clearCoatTerm=fresnel*distribution*kelemenVisibility; +return vec4( +clearCoatTerm*info.attenuation*NccdotL*lightColor, +1.0-fresnel +); +} +vec3 computeClearCoatLightingAbsorption(float NdotVRefract,vec3 L,vec3 Ncc,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) { +vec3 LRefract=-refract(L,Ncc,vClearCoatRefractionParams.y); +float NdotLRefract=saturateEps(dot(Ncc,LRefract)); +vec3 absorption=computeClearCoatAbsorption(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity); +return absorption; +} +#endif +#ifdef SHEEN +vec3 computeSheenLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) { +float NdotH=saturateEps(dot(N,info.H)); +float roughness=max(info.roughness,geometricRoughnessFactor); +float alphaG=convertRoughnessToAverageSlope(roughness); + + +float fresnel=1.; +float distribution=normalDistributionFunction_CharlieSheen(NdotH,alphaG); + +float visibility=visibility_Ashikhmin(info.NdotL,info.NdotV); + +float sheenTerm=fresnel*distribution*visibility; +return sheenTerm*info.attenuation*info.NdotL*lightColor; +} +#endif +`;ze.a.IncludesShadersStore.pbrDirectLightingFunctions=Up;var Vp=`#if defined(REFLECTION) || defined(SS_REFRACTION) +float getLodFromAlphaG(float cubeMapDimensionPixels,float microsurfaceAverageSlope) { +float microsurfaceAverageSlopeTexels=cubeMapDimensionPixels*microsurfaceAverageSlope; +float lod=log2(microsurfaceAverageSlopeTexels); +return lod; +} +float getLinearLodFromRoughness(float cubeMapDimensionPixels,float roughness) { +float lod=log2(cubeMapDimensionPixels)*roughness; +return lod; +} +#endif +#if defined(ENVIRONMENTBRDF) && defined(RADIANCEOCCLUSION) +float environmentRadianceOcclusion(float ambientOcclusion,float NdotVUnclamped) { + + +float temp=NdotVUnclamped+ambientOcclusion; +return saturate(square(temp)-1.0+ambientOcclusion); +} +#endif +#if defined(ENVIRONMENTBRDF) && defined(HORIZONOCCLUSION) +float environmentHorizonOcclusion(vec3 view,vec3 normal,vec3 geometricNormal) { + +vec3 reflection=reflect(view,normal); +float temp=saturate(1.0+1.1*dot(reflection,geometricNormal)); +return square(temp); +} +#endif + + + + +#if defined(LODINREFLECTIONALPHA) || defined(SS_LODINREFRACTIONALPHA) + + +#define UNPACK_LOD(x) (1.0-x)*255.0 +float getLodFromAlphaG(float cubeMapDimensionPixels,float alphaG,float NdotV) { +float microsurfaceAverageSlope=alphaG; + + + + + + +microsurfaceAverageSlope*=sqrt(abs(NdotV)); +return getLodFromAlphaG(cubeMapDimensionPixels,microsurfaceAverageSlope); +} +#endif`;ze.a.IncludesShadersStore.pbrIBLFunctions=Vp,f(132),f(133);var kp=`struct albedoOpacityOutParams +{ +vec3 surfaceAlbedo; +float alpha; +}; +#define pbr_inline +void albedoOpacityBlock( +const in vec4 vAlbedoColor, +#ifdef ALBEDO +const in vec4 albedoTexture, +const in vec2 albedoInfos, +#endif +#ifdef OPACITY +const in vec4 opacityMap, +const in vec2 vOpacityInfos, +#endif +#ifdef DETAIL +const in vec4 detailColor, +const in vec4 vDetailInfos, +#endif +out albedoOpacityOutParams outParams +) +{ + +vec3 surfaceAlbedo=vAlbedoColor.rgb; +float alpha=vAlbedoColor.a; +#ifdef ALBEDO +#if defined(ALPHAFROMALBEDO) || defined(ALPHATEST) +alpha*=albedoTexture.a; +#endif +#ifdef GAMMAALBEDO +surfaceAlbedo*=toLinearSpace(albedoTexture.rgb); +#else +surfaceAlbedo*=albedoTexture.rgb; +#endif +surfaceAlbedo*=albedoInfos.y; +#endif +#ifdef VERTEXCOLOR +surfaceAlbedo*=vColor.rgb; +#endif +#ifdef DETAIL +float detailAlbedo=2.0*mix(0.5,detailColor.r,vDetailInfos.y); +surfaceAlbedo.rgb=surfaceAlbedo.rgb*detailAlbedo*detailAlbedo; +#endif +#define CUSTOM_FRAGMENT_UPDATE_ALBEDO + +#ifdef OPACITY +#ifdef OPACITYRGB +alpha=getLuminance(opacityMap.rgb); +#else +alpha*=opacityMap.a; +#endif +alpha*=vOpacityInfos.y; +#endif +#ifdef VERTEXALPHA +alpha*=vColor.a; +#endif +#if !defined(SS_LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL) +#ifdef ALPHATEST +if (alpha0 +vec4 surfaceMetallicColorMap; +vec4 surfaceReflectivityColorMap; +vec2 metallicRoughness; +vec3 metallicF0; +#endif +}; +#define pbr_inline +void reflectivityBlock( +const in vec4 vReflectivityColor, +#ifdef METALLICWORKFLOW +const in vec3 surfaceAlbedo, +const in vec4 metallicReflectanceFactors, +#endif +#ifdef REFLECTIVITY +const in vec3 reflectivityInfos, +const in vec4 surfaceMetallicOrReflectivityColorMap, +#endif +#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED) +const in vec3 ambientOcclusionColorIn, +#endif +#ifdef MICROSURFACEMAP +const in vec4 microSurfaceTexel, +#endif +#ifdef DETAIL +const in vec4 detailColor, +const in vec4 vDetailInfos, +#endif +out reflectivityOutParams outParams +) +{ +float microSurface=vReflectivityColor.a; +vec3 surfaceReflectivityColor=vReflectivityColor.rgb; +#ifdef METALLICWORKFLOW +vec2 metallicRoughness=surfaceReflectivityColor.rg; +#ifdef REFLECTIVITY +#if DEBUGMODE>0 +outParams.surfaceMetallicColorMap=surfaceMetallicOrReflectivityColorMap; +#endif +#ifdef AOSTOREINMETALMAPRED +vec3 aoStoreInMetalMap=vec3(surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r); +outParams.ambientOcclusionColor=mix(ambientOcclusionColorIn,aoStoreInMetalMap,reflectivityInfos.z); +#endif +#ifdef METALLNESSSTOREINMETALMAPBLUE +metallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.b; +#else +metallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.r; +#endif +#ifdef ROUGHNESSSTOREINMETALMAPALPHA +metallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.a; +#else +#ifdef ROUGHNESSSTOREINMETALMAPGREEN +metallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.g; +#endif +#endif +#endif +#ifdef DETAIL +float detailRoughness=mix(0.5,detailColor.b,vDetailInfos.w); +float loLerp=mix(0.,metallicRoughness.g,detailRoughness*2.); +float hiLerp=mix(metallicRoughness.g,1.,(detailRoughness-0.5)*2.); +metallicRoughness.g=mix(loLerp,hiLerp,step(detailRoughness,0.5)); +#endif +#ifdef MICROSURFACEMAP +metallicRoughness.g*=microSurfaceTexel.r; +#endif +#if DEBUGMODE>0 +outParams.metallicRoughness=metallicRoughness; +#endif +#define CUSTOM_FRAGMENT_UPDATE_METALLICROUGHNESS + +microSurface=1.0-metallicRoughness.g; + +vec3 baseColor=surfaceAlbedo; +#ifdef FROSTBITE_REFLECTANCE + + + + + + +outParams.surfaceAlbedo=baseColor.rgb*(1.0-metallicRoughness.r); + +surfaceReflectivityColor=mix(0.16*reflectance*reflectance,baseColor,metallicRoughness.r); +#else +vec3 metallicF0=metallicReflectanceFactors.rgb; +#if DEBUGMODE>0 +outParams.metallicF0=metallicF0; +#endif + +outParams.surfaceAlbedo=mix(baseColor.rgb*(1.0-metallicF0),vec3(0.,0.,0.),metallicRoughness.r); + +surfaceReflectivityColor=mix(metallicF0,baseColor,metallicRoughness.r); +#endif +#else +#ifdef REFLECTIVITY +surfaceReflectivityColor*=surfaceMetallicOrReflectivityColorMap.rgb; +#if DEBUGMODE>0 +outParams.surfaceReflectivityColorMap=surfaceMetallicOrReflectivityColorMap; +#endif +#ifdef MICROSURFACEFROMREFLECTIVITYMAP +microSurface*=surfaceMetallicOrReflectivityColorMap.a; +microSurface*=reflectivityInfos.z; +#else +#ifdef MICROSURFACEAUTOMATIC +microSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor); +#endif +#ifdef MICROSURFACEMAP +microSurface*=microSurfaceTexel.r; +#endif +#define CUSTOM_FRAGMENT_UPDATE_MICROSURFACE +#endif +#endif +#endif + +microSurface=saturate(microSurface); + +float roughness=1.-microSurface; +outParams.microSurface=microSurface; +outParams.roughness=roughness; +outParams.surfaceReflectivityColor=surfaceReflectivityColor; +} +`;ze.a.IncludesShadersStore.pbrBlockReflectivity=Gp;var zp=`struct ambientOcclusionOutParams +{ +vec3 ambientOcclusionColor; +#if DEBUGMODE>0 +vec3 ambientOcclusionColorMap; +#endif +}; +#define pbr_inline +void ambientOcclusionBlock( +#ifdef AMBIENT +const in vec3 ambientOcclusionColorMap_, +const in vec4 vAmbientInfos, +#endif +out ambientOcclusionOutParams outParams +) +{ +vec3 ambientOcclusionColor=vec3(1.,1.,1.); +#ifdef AMBIENT +vec3 ambientOcclusionColorMap=ambientOcclusionColorMap_*vAmbientInfos.y; +#ifdef AMBIENTINGRAYSCALE +ambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r); +#endif +ambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z); +#if DEBUGMODE>0 +outParams.ambientOcclusionColorMap=ambientOcclusionColorMap; +#endif +#endif +outParams.ambientOcclusionColor=ambientOcclusionColor; +} +`;ze.a.IncludesShadersStore.pbrBlockAmbientOcclusion=zp;var jp=`#ifdef ALPHAFRESNEL +#if defined(ALPHATEST) || defined(ALPHABLEND) +struct alphaFresnelOutParams +{ +float alpha; +}; +#define pbr_inline +void alphaFresnelBlock( +const in vec3 normalW, +const in vec3 viewDirectionW, +const in float alpha, +const in float microSurface, +out alphaFresnelOutParams outParams +) +{ + + + +float opacityPerceptual=alpha; +#ifdef LINEARALPHAFRESNEL +float opacity0=opacityPerceptual; +#else +float opacity0=opacityPerceptual*opacityPerceptual; +#endif +float opacity90=fresnelGrazingReflectance(opacity0); +vec3 normalForward=faceforward(normalW,-viewDirectionW,normalW); + +outParams.alpha=getReflectanceFromAnalyticalBRDFLookup_Jones(saturate(dot(viewDirectionW,normalForward)),vec3(opacity0),vec3(opacity90),sqrt(microSurface)).x; +#ifdef ALPHATEST +if (outParams.alpha0 +vec3 anisotropyMapData; +#endif +}; +#define pbr_inline +void anisotropicBlock( +const in vec3 vAnisotropy, +#ifdef ANISOTROPIC_TEXTURE +const in vec3 anisotropyMapData, +#endif +const in mat3 TBN, +const in vec3 normalW, +const in vec3 viewDirectionW, +out anisotropicOutParams outParams +) +{ +float anisotropy=vAnisotropy.b; +vec3 anisotropyDirection=vec3(vAnisotropy.xy,0.); +#ifdef ANISOTROPIC_TEXTURE +anisotropy*=anisotropyMapData.b; +anisotropyDirection.rg*=anisotropyMapData.rg*2.0-1.0; +#if DEBUGMODE>0 +outParams.anisotropyMapData=anisotropyMapData; +#endif +#endif +mat3 anisoTBN=mat3(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2])); +vec3 anisotropicTangent=normalize(anisoTBN*anisotropyDirection); +vec3 anisotropicBitangent=normalize(cross(anisoTBN[2],anisotropicTangent)); +outParams.anisotropy=anisotropy; +outParams.anisotropicTangent=anisotropicTangent; +outParams.anisotropicBitangent=anisotropicBitangent; +outParams.anisotropicNormal=getAnisotropicBentNormals(anisotropicTangent,anisotropicBitangent,normalW,viewDirectionW,anisotropy); +} +#endif +`;ze.a.IncludesShadersStore.pbrBlockAnisotropic=Hp;var Wp=`#ifdef REFLECTION +struct reflectionOutParams +{ +vec4 environmentRadiance; +vec3 environmentIrradiance; +#ifdef REFLECTIONMAP_3D +vec3 reflectionCoords; +#else +vec2 reflectionCoords; +#endif +#ifdef SS_TRANSLUCENCY +#ifdef USESPHERICALFROMREFLECTIONMAP +#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX) +vec3 irradianceVector; +#endif +#endif +#endif +}; +#define pbr_inline +void createReflectionCoords( +const in vec3 vPositionW, +const in vec3 normalW, +#ifdef ANISOTROPIC +const in anisotropicOutParams anisotropicOut, +#endif +#ifdef REFLECTIONMAP_3D +out vec3 reflectionCoords +#else +out vec2 reflectionCoords +#endif +) +{ +#ifdef ANISOTROPIC +vec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),anisotropicOut.anisotropicNormal); +#else +vec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW); +#endif +#ifdef REFLECTIONMAP_OPPOSITEZ +reflectionVector.z*=-1.0; +#endif + +#ifdef REFLECTIONMAP_3D +reflectionCoords=reflectionVector; +#else +reflectionCoords=reflectionVector.xy; +#ifdef REFLECTIONMAP_PROJECTION +reflectionCoords/=reflectionVector.z; +#endif +reflectionCoords.y=1.0-reflectionCoords.y; +#endif +} +#define pbr_inline +#define inline +void sampleReflectionTexture( +const in float alphaG, +const in vec3 vReflectionMicrosurfaceInfos, +const in vec2 vReflectionInfos, +const in vec3 vReflectionColor, +#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX) +const in float NdotVUnclamped, +#endif +#ifdef LINEARSPECULARREFLECTION +const in float roughness, +#endif +#ifdef REFLECTIONMAP_3D +const in samplerCube reflectionSampler, +const vec3 reflectionCoords, +#else +const in sampler2D reflectionSampler, +const vec2 reflectionCoords, +#endif +#ifndef LODBASEDMICROSFURACE +#ifdef REFLECTIONMAP_3D +const in samplerCube reflectionSamplerLow, +const in samplerCube reflectionSamplerHigh, +#else +const in sampler2D reflectionSamplerLow, +const in sampler2D reflectionSamplerHigh, +#endif +#endif +#ifdef REALTIME_FILTERING +const in vec2 vReflectionFilteringInfo, +#endif +out vec4 environmentRadiance +) +{ + +#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX) +float reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped); +#elif defined(LINEARSPECULARREFLECTION) +float reflectionLOD=getLinearLodFromRoughness(vReflectionMicrosurfaceInfos.x,roughness); +#else +float reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG); +#endif +#ifdef LODBASEDMICROSFURACE + +reflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z; +#ifdef LODINREFLECTIONALPHA + + + + + + + + + +float automaticReflectionLOD=UNPACK_LOD(sampleReflection(reflectionSampler,reflectionCoords).a); +float requestedReflectionLOD=max(automaticReflectionLOD,reflectionLOD); +#else +float requestedReflectionLOD=reflectionLOD; +#endif +#ifdef REALTIME_FILTERING +environmentRadiance=vec4(radiance(alphaG,reflectionSampler,reflectionCoords,vReflectionFilteringInfo),1.0); +#else +environmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD); +#endif +#else +float lodReflectionNormalized=saturate(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x)); +float lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0; +vec4 environmentMid=sampleReflection(reflectionSampler,reflectionCoords); +if (lodReflectionNormalizedDoubled<1.0){ +environmentRadiance=mix( +sampleReflection(reflectionSamplerHigh,reflectionCoords), +environmentMid, +lodReflectionNormalizedDoubled +); +} else { +environmentRadiance=mix( +environmentMid, +sampleReflection(reflectionSamplerLow,reflectionCoords), +lodReflectionNormalizedDoubled-1.0 +); +} +#endif +#ifdef RGBDREFLECTION +environmentRadiance.rgb=fromRGBD(environmentRadiance); +#endif +#ifdef GAMMAREFLECTION +environmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb); +#endif + +environmentRadiance.rgb*=vReflectionInfos.x; +environmentRadiance.rgb*=vReflectionColor.rgb; +} +#define pbr_inline +#define inline +void reflectionBlock( +const in vec3 vPositionW, +const in vec3 normalW, +const in float alphaG, +const in vec3 vReflectionMicrosurfaceInfos, +const in vec2 vReflectionInfos, +const in vec3 vReflectionColor, +#ifdef ANISOTROPIC +const in anisotropicOutParams anisotropicOut, +#endif +#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX) +const in float NdotVUnclamped, +#endif +#ifdef LINEARSPECULARREFLECTION +const in float roughness, +#endif +#ifdef REFLECTIONMAP_3D +const in samplerCube reflectionSampler, +#else +const in sampler2D reflectionSampler, +#endif +#if defined(NORMAL) && defined(USESPHERICALINVERTEX) +const in vec3 vEnvironmentIrradiance, +#endif +#ifdef USESPHERICALFROMREFLECTIONMAP +#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX) +const in mat4 reflectionMatrix, +#endif +#endif +#ifdef USEIRRADIANCEMAP +#ifdef REFLECTIONMAP_3D +const in samplerCube irradianceSampler, +#else +const in sampler2D irradianceSampler, +#endif +#endif +#ifndef LODBASEDMICROSFURACE +#ifdef REFLECTIONMAP_3D +const in samplerCube reflectionSamplerLow, +const in samplerCube reflectionSamplerHigh, +#else +const in sampler2D reflectionSamplerLow, +const in sampler2D reflectionSamplerHigh, +#endif +#endif +#ifdef REALTIME_FILTERING +const in vec2 vReflectionFilteringInfo, +#endif +out reflectionOutParams outParams +) +{ + +vec4 environmentRadiance=vec4(0.,0.,0.,0.); +#ifdef REFLECTIONMAP_3D +vec3 reflectionCoords=vec3(0.); +#else +vec2 reflectionCoords=vec2(0.); +#endif +createReflectionCoords( +vPositionW, +normalW, +#ifdef ANISOTROPIC +anisotropicOut, +#endif +reflectionCoords +); +sampleReflectionTexture( +alphaG, +vReflectionMicrosurfaceInfos, +vReflectionInfos, +vReflectionColor, +#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX) +NdotVUnclamped, +#endif +#ifdef LINEARSPECULARREFLECTION +roughness, +#endif +#ifdef REFLECTIONMAP_3D +reflectionSampler, +reflectionCoords, +#else +reflectionSampler, +reflectionCoords, +#endif +#ifndef LODBASEDMICROSFURACE +reflectionSamplerLow, +reflectionSamplerHigh, +#endif +#ifdef REALTIME_FILTERING +vReflectionFilteringInfo, +#endif +environmentRadiance +); + +vec3 environmentIrradiance=vec3(0.,0.,0.); +#ifdef USESPHERICALFROMREFLECTIONMAP +#if defined(NORMAL) && defined(USESPHERICALINVERTEX) +environmentIrradiance=vEnvironmentIrradiance; +#else +#ifdef ANISOTROPIC +vec3 irradianceVector=vec3(reflectionMatrix*vec4(anisotropicOut.anisotropicNormal,0)).xyz; +#else +vec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz; +#endif +#ifdef REFLECTIONMAP_OPPOSITEZ +irradianceVector.z*=-1.0; +#endif +#ifdef INVERTCUBICMAP +irradianceVector.y*=-1.0; +#endif +#if defined(REALTIME_FILTERING) +environmentIrradiance=irradiance(reflectionSampler,irradianceVector,vReflectionFilteringInfo); +#else +environmentIrradiance=computeEnvironmentIrradiance(irradianceVector); +#endif +#ifdef SS_TRANSLUCENCY +outParams.irradianceVector=irradianceVector; +#endif +#endif +#elif defined(USEIRRADIANCEMAP) +vec4 environmentIrradiance4=sampleReflection(irradianceSampler,reflectionCoords); +environmentIrradiance=environmentIrradiance4.rgb; +#ifdef RGBDREFLECTION +environmentIrradiance.rgb=fromRGBD(environmentIrradiance4); +#endif +#ifdef GAMMAREFLECTION +environmentIrradiance.rgb=toLinearSpace(environmentIrradiance.rgb); +#endif +#endif +environmentIrradiance*=vReflectionColor.rgb; +outParams.environmentRadiance=environmentRadiance; +outParams.environmentIrradiance=environmentIrradiance; +outParams.reflectionCoords=reflectionCoords; +} +#endif +`;ze.a.IncludesShadersStore.pbrBlockReflection=Wp;var Xp=`#ifdef SHEEN +struct sheenOutParams +{ +float sheenIntensity; +vec3 sheenColor; +float sheenRoughness; +#ifdef SHEEN_LINKWITHALBEDO +vec3 surfaceAlbedo; +#endif +#if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING) +float sheenAlbedoScaling; +#endif +#if defined(REFLECTION) && defined(ENVIRONMENTBRDF) +vec3 finalSheenRadianceScaled; +#endif +#if DEBUGMODE>0 +vec4 sheenMapData; +vec3 sheenEnvironmentReflectance; +#endif +}; +#define pbr_inline +#define inline +void sheenBlock( +const in vec4 vSheenColor, +#ifdef SHEEN_ROUGHNESS +const in float vSheenRoughness, +#if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE) +const in vec4 sheenMapRoughnessData, +#endif +#endif +const in float roughness, +#ifdef SHEEN_TEXTURE +const in vec4 sheenMapData, +#endif +const in float reflectance, +#ifdef SHEEN_LINKWITHALBEDO +const in vec3 baseColor, +const in vec3 surfaceAlbedo, +#endif +#ifdef ENVIRONMENTBRDF +const in float NdotV, +const in vec3 environmentBrdf, +#endif +#if defined(REFLECTION) && defined(ENVIRONMENTBRDF) +const in vec2 AARoughnessFactors, +const in vec3 vReflectionMicrosurfaceInfos, +const in vec2 vReflectionInfos, +const in vec3 vReflectionColor, +const in vec4 vLightingIntensity, +#ifdef REFLECTIONMAP_3D +const in samplerCube reflectionSampler, +const in vec3 reflectionCoords, +#else +const in sampler2D reflectionSampler, +const in vec2 reflectionCoords, +#endif +const in float NdotVUnclamped, +#ifndef LODBASEDMICROSFURACE +#ifdef REFLECTIONMAP_3D +const in samplerCube reflectionSamplerLow, +const in samplerCube reflectionSamplerHigh, +#else +const in sampler2D reflectionSamplerLow, +const in sampler2D reflectionSamplerHigh, +#endif +#endif +#ifdef REALTIME_FILTERING +const in vec2 vReflectionFilteringInfo, +#endif +#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION) +const in float seo, +#endif +#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D) +const in float eho, +#endif +#endif +out sheenOutParams outParams +) +{ +float sheenIntensity=vSheenColor.a; +#ifdef SHEEN_TEXTURE +#if DEBUGMODE>0 +outParams.sheenMapData=sheenMapData; +#endif +#endif +#ifdef SHEEN_LINKWITHALBEDO +float sheenFactor=pow5(1.0-sheenIntensity); +vec3 sheenColor=baseColor.rgb*(1.0-sheenFactor); +float sheenRoughness=sheenIntensity; +outParams.surfaceAlbedo=surfaceAlbedo*sheenFactor; +#ifdef SHEEN_TEXTURE +sheenIntensity*=sheenMapData.a; +#endif +#else +vec3 sheenColor=vSheenColor.rgb; +#ifdef SHEEN_TEXTURE +sheenColor.rgb*=sheenMapData.rgb; +#endif +#ifdef SHEEN_ROUGHNESS +float sheenRoughness=vSheenRoughness; +#ifdef SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE +#if defined(SHEEN_TEXTURE) +sheenRoughness*=sheenMapData.a; +#endif +#elif defined(SHEEN_TEXTURE_ROUGHNESS) +#ifdef SHEEN_TEXTURE_ROUGHNESS_IDENTICAL +sheenRoughness*=sheenMapData.a; +#else +sheenRoughness*=sheenMapRoughnessData.a; +#endif +#endif +#else +float sheenRoughness=roughness; +#ifdef SHEEN_TEXTURE +sheenIntensity*=sheenMapData.a; +#endif +#endif + +#if !defined(SHEEN_ALBEDOSCALING) +sheenIntensity*=(1.-reflectance); +#endif + +sheenColor*=sheenIntensity; +#endif + +#ifdef ENVIRONMENTBRDF + +#ifdef SHEEN_ROUGHNESS +vec3 environmentSheenBrdf=getBRDFLookup(NdotV,sheenRoughness); +#else +vec3 environmentSheenBrdf=environmentBrdf; +#endif + +#endif +#if defined(REFLECTION) && defined(ENVIRONMENTBRDF) +float sheenAlphaG=convertRoughnessToAverageSlope(sheenRoughness); +#ifdef SPECULARAA + +sheenAlphaG+=AARoughnessFactors.y; +#endif +vec4 environmentSheenRadiance=vec4(0.,0.,0.,0.); +sampleReflectionTexture( +sheenAlphaG, +vReflectionMicrosurfaceInfos, +vReflectionInfos, +vReflectionColor, +#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX) +NdotVUnclamped, +#endif +#ifdef LINEARSPECULARREFLECTION +sheenRoughness, +#endif +reflectionSampler, +reflectionCoords, +#ifndef LODBASEDMICROSFURACE +reflectionSamplerLow, +reflectionSamplerHigh, +#endif +#ifdef REALTIME_FILTERING +vReflectionFilteringInfo, +#endif +environmentSheenRadiance +); +vec3 sheenEnvironmentReflectance=getSheenReflectanceFromBRDFLookup(sheenColor,environmentSheenBrdf); +#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION) +sheenEnvironmentReflectance*=seo; +#endif +#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D) +sheenEnvironmentReflectance*=eho; +#endif +#if DEBUGMODE>0 +outParams.sheenEnvironmentReflectance=sheenEnvironmentReflectance; +#endif +outParams.finalSheenRadianceScaled= +environmentSheenRadiance.rgb * +sheenEnvironmentReflectance * +vLightingIntensity.z; + + + + + +#endif +#if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING) + + + +outParams.sheenAlbedoScaling=1.0-sheenIntensity*max(max(sheenColor.r,sheenColor.g),sheenColor.b)*environmentSheenBrdf.b; +#endif + +outParams.sheenIntensity=sheenIntensity; +outParams.sheenColor=sheenColor; +outParams.sheenRoughness=sheenRoughness; +} +#endif +`;ze.a.IncludesShadersStore.pbrBlockSheen=Xp;var Yp=`struct clearcoatOutParams +{ +vec3 specularEnvironmentR0; +float conservationFactor; +vec3 clearCoatNormalW; +vec2 clearCoatAARoughnessFactors; +float clearCoatIntensity; +float clearCoatRoughness; +#ifdef REFLECTION +vec3 finalClearCoatRadianceScaled; +#endif +#ifdef CLEARCOAT_TINT +vec3 absorption; +float clearCoatNdotVRefract; +vec3 clearCoatColor; +float clearCoatThickness; +#endif +#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION) +vec3 energyConservationFactorClearCoat; +#endif +#if DEBUGMODE>0 +mat3 TBNClearCoat; +vec2 clearCoatMapData; +vec4 clearCoatTintMapData; +vec4 environmentClearCoatRadiance; +float clearCoatNdotV; +vec3 clearCoatEnvironmentReflectance; +#endif +}; +#ifdef CLEARCOAT +#define pbr_inline +#define inline +void clearcoatBlock( +const in vec3 vPositionW, +const in vec3 geometricNormalW, +const in vec3 viewDirectionW, +const in vec2 vClearCoatParams, +#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE) +const in vec4 clearCoatMapRoughnessData, +#endif +const in vec3 specularEnvironmentR0, +#ifdef CLEARCOAT_TEXTURE +const in vec2 clearCoatMapData, +#endif +#ifdef CLEARCOAT_TINT +const in vec4 vClearCoatTintParams, +const in float clearCoatColorAtDistance, +const in vec4 vClearCoatRefractionParams, +#ifdef CLEARCOAT_TINT_TEXTURE +const in vec4 clearCoatTintMapData, +#endif +#endif +#ifdef CLEARCOAT_BUMP +const in vec2 vClearCoatBumpInfos, +const in vec4 clearCoatBumpMapData, +const in vec2 vClearCoatBumpUV, +#if defined(TANGENT) && defined(NORMAL) +const in mat3 vTBN, +#else +const in vec2 vClearCoatTangentSpaceParams, +#endif +#ifdef OBJECTSPACE_NORMALMAP +const in mat4 normalMatrix, +#endif +#endif +#if defined(FORCENORMALFORWARD) && defined(NORMAL) +const in vec3 faceNormal, +#endif +#ifdef REFLECTION +const in vec3 vReflectionMicrosurfaceInfos, +const in vec2 vReflectionInfos, +const in vec3 vReflectionColor, +const in vec4 vLightingIntensity, +#ifdef REFLECTIONMAP_3D +const in samplerCube reflectionSampler, +#else +const in sampler2D reflectionSampler, +#endif +#ifndef LODBASEDMICROSFURACE +#ifdef REFLECTIONMAP_3D +const in samplerCube reflectionSamplerLow, +const in samplerCube reflectionSamplerHigh, +#else +const in sampler2D reflectionSamplerLow, +const in sampler2D reflectionSamplerHigh, +#endif +#endif +#ifdef REALTIME_FILTERING +const in vec2 vReflectionFilteringInfo, +#endif +#endif +#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX) +#ifdef RADIANCEOCCLUSION +const in float ambientMonochrome, +#endif +#endif +out clearcoatOutParams outParams +) +{ + +float clearCoatIntensity=vClearCoatParams.x; +float clearCoatRoughness=vClearCoatParams.y; +#ifdef CLEARCOAT_TEXTURE +clearCoatIntensity*=clearCoatMapData.x; +#ifdef CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE +clearCoatRoughness*=clearCoatMapData.y; +#endif +#if DEBUGMODE>0 +outParams.clearCoatMapData=clearCoatMapData; +#endif +#endif +#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE) +#ifdef CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL +clearCoatRoughness*=clearCoatMapData.y; +#else +clearCoatRoughness*=clearCoatMapRoughnessData.y; +#endif +#endif +outParams.clearCoatIntensity=clearCoatIntensity; +outParams.clearCoatRoughness=clearCoatRoughness; +#ifdef CLEARCOAT_TINT +vec3 clearCoatColor=vClearCoatTintParams.rgb; +float clearCoatThickness=vClearCoatTintParams.a; +#ifdef CLEARCOAT_TINT_TEXTURE +clearCoatColor*=clearCoatTintMapData.rgb; +clearCoatThickness*=clearCoatTintMapData.a; +#if DEBUGMODE>0 +outParams.clearCoatTintMapData=clearCoatTintMapData; +#endif +#endif +outParams.clearCoatColor=computeColorAtDistanceInMedia(clearCoatColor,clearCoatColorAtDistance); +outParams.clearCoatThickness=clearCoatThickness; +#endif + + + + +#ifdef CLEARCOAT_REMAP_F0 +vec3 specularEnvironmentR0Updated=getR0RemappedForClearCoat(specularEnvironmentR0); +#else +vec3 specularEnvironmentR0Updated=specularEnvironmentR0; +#endif +outParams.specularEnvironmentR0=mix(specularEnvironmentR0,specularEnvironmentR0Updated,clearCoatIntensity); + +vec3 clearCoatNormalW=geometricNormalW; +#ifdef CLEARCOAT_BUMP +#ifdef NORMALXYSCALE +float clearCoatNormalScale=1.0; +#else +float clearCoatNormalScale=vClearCoatBumpInfos.y; +#endif +#if defined(TANGENT) && defined(NORMAL) +mat3 TBNClearCoat=vTBN; +#else +mat3 TBNClearCoat=cotangent_frame(clearCoatNormalW*clearCoatNormalScale,vPositionW,vClearCoatBumpUV,vClearCoatTangentSpaceParams); +#endif +#if DEBUGMODE>0 +outParams.TBNClearCoat=TBNClearCoat; +#endif +#ifdef OBJECTSPACE_NORMALMAP +clearCoatNormalW=normalize(clearCoatBumpMapData.xyz*2.0-1.0); +clearCoatNormalW=normalize(mat3(normalMatrix)*clearCoatNormalW); +#else +clearCoatNormalW=perturbNormal(TBNClearCoat,clearCoatBumpMapData.xyz,vClearCoatBumpInfos.y); +#endif +#endif +#if defined(FORCENORMALFORWARD) && defined(NORMAL) +clearCoatNormalW*=sign(dot(clearCoatNormalW,faceNormal)); +#endif +#if defined(TWOSIDEDLIGHTING) && defined(NORMAL) +clearCoatNormalW=gl_FrontFacing ? clearCoatNormalW : -clearCoatNormalW; +#endif +outParams.clearCoatNormalW=clearCoatNormalW; + +outParams.clearCoatAARoughnessFactors=getAARoughnessFactors(clearCoatNormalW.xyz); + +float clearCoatNdotVUnclamped=dot(clearCoatNormalW,viewDirectionW); + +float clearCoatNdotV=absEps(clearCoatNdotVUnclamped); +#if DEBUGMODE>0 +outParams.clearCoatNdotV=clearCoatNdotV; +#endif +#ifdef CLEARCOAT_TINT + +vec3 clearCoatVRefract=-refract(vPositionW,clearCoatNormalW,vClearCoatRefractionParams.y); + +outParams.clearCoatNdotVRefract=absEps(dot(clearCoatNormalW,clearCoatVRefract)); +#endif +#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX) + +vec3 environmentClearCoatBrdf=getBRDFLookup(clearCoatNdotV,clearCoatRoughness); +#endif + +#if defined(REFLECTION) +float clearCoatAlphaG=convertRoughnessToAverageSlope(clearCoatRoughness); +#ifdef SPECULARAA + +clearCoatAlphaG+=outParams.clearCoatAARoughnessFactors.y; +#endif +vec4 environmentClearCoatRadiance=vec4(0.,0.,0.,0.); +vec3 clearCoatReflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),clearCoatNormalW); +#ifdef REFLECTIONMAP_OPPOSITEZ +clearCoatReflectionVector.z*=-1.0; +#endif + +#ifdef REFLECTIONMAP_3D +vec3 clearCoatReflectionCoords=clearCoatReflectionVector; +#else +vec2 clearCoatReflectionCoords=clearCoatReflectionVector.xy; +#ifdef REFLECTIONMAP_PROJECTION +clearCoatReflectionCoords/=clearCoatReflectionVector.z; +#endif +clearCoatReflectionCoords.y=1.0-clearCoatReflectionCoords.y; +#endif +sampleReflectionTexture( +clearCoatAlphaG, +vReflectionMicrosurfaceInfos, +vReflectionInfos, +vReflectionColor, +#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX) +clearCoatNdotVUnclamped, +#endif +#ifdef LINEARSPECULARREFLECTION +clearCoatRoughness, +#endif +reflectionSampler, +clearCoatReflectionCoords, +#ifndef LODBASEDMICROSFURACE +reflectionSamplerLow, +reflectionSamplerHigh, +#endif +#ifdef REALTIME_FILTERING +vReflectionFilteringInfo, +#endif +environmentClearCoatRadiance +); +#if DEBUGMODE>0 +outParams.environmentClearCoatRadiance=environmentClearCoatRadiance; +#endif + +#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX) +vec3 clearCoatEnvironmentReflectance=getReflectanceFromBRDFLookup(vec3(vClearCoatRefractionParams.x),environmentClearCoatBrdf); +#ifdef RADIANCEOCCLUSION +float clearCoatSeo=environmentRadianceOcclusion(ambientMonochrome,clearCoatNdotVUnclamped); +clearCoatEnvironmentReflectance*=clearCoatSeo; +#endif +#ifdef HORIZONOCCLUSION +#ifdef BUMP +#ifdef REFLECTIONMAP_3D +float clearCoatEho=environmentHorizonOcclusion(-viewDirectionW,clearCoatNormalW,geometricNormalW); +clearCoatEnvironmentReflectance*=clearCoatEho; +#endif +#endif +#endif +#else + +vec3 clearCoatEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(clearCoatNdotV,vec3(1.),vec3(1.),sqrt(1.-clearCoatRoughness)); +#endif +clearCoatEnvironmentReflectance*=clearCoatIntensity; +#if DEBUGMODE>0 +outParams.clearCoatEnvironmentReflectance=clearCoatEnvironmentReflectance; +#endif +outParams.finalClearCoatRadianceScaled= +environmentClearCoatRadiance.rgb * +clearCoatEnvironmentReflectance * +vLightingIntensity.z; +#endif +#if defined(CLEARCOAT_TINT) + +outParams.absorption=computeClearCoatAbsorption(outParams.clearCoatNdotVRefract,outParams.clearCoatNdotVRefract,outParams.clearCoatColor,clearCoatThickness,clearCoatIntensity); +#endif + +float fresnelIBLClearCoat=fresnelSchlickGGX(clearCoatNdotV,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90); +fresnelIBLClearCoat*=clearCoatIntensity; +outParams.conservationFactor=(1.-fresnelIBLClearCoat); +#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION) +outParams.energyConservationFactorClearCoat=getEnergyConservationFactor(outParams.specularEnvironmentR0,environmentClearCoatBrdf); +#endif +} +#endif +`;ze.a.IncludesShadersStore.pbrBlockClearcoat=Yp;var Kp=`struct subSurfaceOutParams +{ +vec3 specularEnvironmentReflectance; +#ifdef SS_REFRACTION +vec3 finalRefraction; +vec3 surfaceAlbedo; +#ifdef SS_LINKREFRACTIONTOTRANSPARENCY +float alpha; +#endif +#ifdef REFLECTION +float refractionFactorForIrradiance; +#endif +#endif +#ifdef SS_TRANSLUCENCY +vec3 transmittance; +float translucencyIntensity; +#ifdef REFLECTION +vec3 refractionIrradiance; +#endif +#endif +#if DEBUGMODE>0 +vec4 thicknessMap; +vec4 environmentRefraction; +vec3 refractionTransmittance; +#endif +}; +#ifdef SUBSURFACE +#define pbr_inline +#define inline +void subSurfaceBlock( +const in vec3 vSubSurfaceIntensity, +const in vec2 vThicknessParam, +const in vec4 vTintColor, +const in vec3 normalW, +const in vec3 specularEnvironmentReflectance, +#ifdef SS_THICKNESSANDMASK_TEXTURE +const in vec4 thicknessMap, +#endif +#ifdef REFLECTION +#ifdef SS_TRANSLUCENCY +const in mat4 reflectionMatrix, +#ifdef USESPHERICALFROMREFLECTIONMAP +#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX) +const in vec3 irradianceVector_, +#endif +#if defined(REALTIME_FILTERING) +const in samplerCube reflectionSampler, +const in vec2 vReflectionFilteringInfo, +#endif +#endif +#ifdef USEIRRADIANCEMAP +#ifdef REFLECTIONMAP_3D +const in samplerCube irradianceSampler, +#else +const in sampler2D irradianceSampler, +#endif +#endif +#endif +#endif +#ifdef SS_REFRACTION +const in vec3 vPositionW, +const in vec3 viewDirectionW, +const in mat4 view, +const in vec3 surfaceAlbedo, +const in vec4 vRefractionInfos, +const in mat4 refractionMatrix, +const in vec3 vRefractionMicrosurfaceInfos, +const in vec4 vLightingIntensity, +#ifdef SS_LINKREFRACTIONTOTRANSPARENCY +const in float alpha, +#endif +#ifdef SS_LODINREFRACTIONALPHA +const in float NdotVUnclamped, +#endif +#ifdef SS_LINEARSPECULARREFRACTION +const in float roughness, +#else +const in float alphaG, +#endif +#ifdef SS_REFRACTIONMAP_3D +const in samplerCube refractionSampler, +#ifndef LODBASEDMICROSFURACE +const in samplerCube refractionSamplerLow, +const in samplerCube refractionSamplerHigh, +#endif +#else +const in sampler2D refractionSampler, +#ifndef LODBASEDMICROSFURACE +const in sampler2D refractionSamplerLow, +const in sampler2D refractionSamplerHigh, +#endif +#endif +#ifdef ANISOTROPIC +const in anisotropicOutParams anisotropicOut, +#endif +#ifdef REALTIME_FILTERING +const in vec2 vRefractionFilteringInfo, +#endif +#endif +#ifdef SS_TRANSLUCENCY +const in vec3 vDiffusionDistance, +#endif +out subSurfaceOutParams outParams +) +{ +outParams.specularEnvironmentReflectance=specularEnvironmentReflectance; + + + +#ifdef SS_REFRACTION +float refractionIntensity=vSubSurfaceIntensity.x; +#ifdef SS_LINKREFRACTIONTOTRANSPARENCY +refractionIntensity*=(1.0-alpha); + +outParams.alpha=1.0; +#endif +#endif +#ifdef SS_TRANSLUCENCY +float translucencyIntensity=vSubSurfaceIntensity.y; +#endif +#ifdef SS_THICKNESSANDMASK_TEXTURE +float thickness=thicknessMap.r*vThicknessParam.y+vThicknessParam.x; +#if DEBUGMODE>0 +outParams.thicknessMap=thicknessMap; +#endif +#ifdef SS_MASK_FROM_THICKNESS_TEXTURE +#ifdef SS_REFRACTION +refractionIntensity*=thicknessMap.g; +#endif +#ifdef SS_TRANSLUCENCY +translucencyIntensity*=thicknessMap.b; +#endif +#elif defined(SS_MASK_FROM_THICKNESS_TEXTURE_GLTF) +#ifdef SS_REFRACTION +refractionIntensity*=thicknessMap.r; +#elif defined(SS_TRANSLUCENCY) +translucencyIntensity*=thicknessMap.r; +#endif +thickness=thicknessMap.g*vThicknessParam.y+vThicknessParam.x; +#endif +#else +float thickness=vThicknessParam.y; +#endif + + + +#ifdef SS_TRANSLUCENCY +thickness=maxEps(thickness); +vec3 transmittance=transmittanceBRDF_Burley(vTintColor.rgb,vDiffusionDistance,thickness); +transmittance*=translucencyIntensity; +outParams.transmittance=transmittance; +outParams.translucencyIntensity=translucencyIntensity; +#endif + + + +#ifdef SS_REFRACTION +vec4 environmentRefraction=vec4(0.,0.,0.,0.); +#ifdef ANISOTROPIC +vec3 refractionVector=refract(-viewDirectionW,anisotropicOut.anisotropicNormal,vRefractionInfos.y); +#else +vec3 refractionVector=refract(-viewDirectionW,normalW,vRefractionInfos.y); +#endif +#ifdef SS_REFRACTIONMAP_OPPOSITEZ +refractionVector.z*=-1.0; +#endif + +#ifdef SS_REFRACTIONMAP_3D +refractionVector.y=refractionVector.y*vRefractionInfos.w; +vec3 refractionCoords=refractionVector; +refractionCoords=vec3(refractionMatrix*vec4(refractionCoords,0)); +#else +vec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0))); +vec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z; +refractionCoords.y=1.0-refractionCoords.y; +#endif +#ifdef SS_LODINREFRACTIONALPHA +float refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,NdotVUnclamped); +#elif defined(SS_LINEARSPECULARREFRACTION) +float refractionLOD=getLinearLodFromRoughness(vRefractionMicrosurfaceInfos.x,roughness); +#else +float refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG); +#endif +#ifdef LODBASEDMICROSFURACE + +refractionLOD=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z; +#ifdef SS_LODINREFRACTIONALPHA + + + + + + + + + +float automaticRefractionLOD=UNPACK_LOD(sampleRefraction(refractionSampler,refractionCoords).a); +float requestedRefractionLOD=max(automaticRefractionLOD,refractionLOD); +#else +float requestedRefractionLOD=refractionLOD; +#endif +#ifdef REALTIME_FILTERING +environmentRefraction=vec4(radiance(alphaG,refractionSampler,refractionCoords,vRefractionFilteringInfo),1.0); +#else +environmentRefraction=sampleRefractionLod(refractionSampler,refractionCoords,requestedRefractionLOD); +#endif +#else +float lodRefractionNormalized=saturate(refractionLOD/log2(vRefractionMicrosurfaceInfos.x)); +float lodRefractionNormalizedDoubled=lodRefractionNormalized*2.0; +vec4 environmentRefractionMid=sampleRefraction(refractionSampler,refractionCoords); +if (lodRefractionNormalizedDoubled<1.0){ +environmentRefraction=mix( +sampleRefraction(refractionSamplerHigh,refractionCoords), +environmentRefractionMid, +lodRefractionNormalizedDoubled +); +} else { +environmentRefraction=mix( +environmentRefractionMid, +sampleRefraction(refractionSamplerLow,refractionCoords), +lodRefractionNormalizedDoubled-1.0 +); +} +#endif +#ifdef SS_RGBDREFRACTION +environmentRefraction.rgb=fromRGBD(environmentRefraction); +#endif +#ifdef SS_GAMMAREFRACTION +environmentRefraction.rgb=toLinearSpace(environmentRefraction.rgb); +#endif + +environmentRefraction.rgb*=vRefractionInfos.x; +#endif + + + +#ifdef SS_REFRACTION +vec3 refractionTransmittance=vec3(refractionIntensity); +#ifdef SS_THICKNESSANDMASK_TEXTURE +vec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w); + + + + + +refractionTransmittance*=cocaLambert(volumeAlbedo,thickness); +#elif defined(SS_LINKREFRACTIONTOTRANSPARENCY) + +float maxChannel=max(max(surfaceAlbedo.r,surfaceAlbedo.g),surfaceAlbedo.b); +vec3 volumeAlbedo=saturate(maxChannel*surfaceAlbedo); + +environmentRefraction.rgb*=volumeAlbedo; +#else + +vec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w); +refractionTransmittance*=cocaLambert(volumeAlbedo,vThicknessParam.y); +#endif +#ifdef SS_ALBEDOFORREFRACTIONTINT + +environmentRefraction.rgb*=surfaceAlbedo.rgb; +#endif + +outParams.surfaceAlbedo=surfaceAlbedo*(1.-refractionIntensity); +#ifdef REFLECTION + +outParams.refractionFactorForIrradiance=(1.-refractionIntensity); + +#endif + +vec3 bounceSpecularEnvironmentReflectance=(2.0*specularEnvironmentReflectance)/(1.0+specularEnvironmentReflectance); +outParams.specularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,specularEnvironmentReflectance,refractionIntensity); + +refractionTransmittance*=1.0-outParams.specularEnvironmentReflectance; +#if DEBUGMODE>0 +outParams.refractionTransmittance=refractionTransmittance; +#endif +outParams.finalRefraction=environmentRefraction.rgb*refractionTransmittance*vLightingIntensity.z; +#if DEBUGMODE>0 +outParams.environmentRefraction=environmentRefraction; +#endif +#endif + + + +#if defined(REFLECTION) && defined(SS_TRANSLUCENCY) +#if defined(NORMAL) && defined(USESPHERICALINVERTEX) || !defined(USESPHERICALFROMREFLECTIONMAP) +vec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz; +#ifdef REFLECTIONMAP_OPPOSITEZ +irradianceVector.z*=-1.0; +#endif +#ifdef INVERTCUBICMAP +irradianceVector.y*=-1.0; +#endif +#else +vec3 irradianceVector=irradianceVector_; +#endif +#if defined(USESPHERICALFROMREFLECTIONMAP) +#if defined(REALTIME_FILTERING) +vec3 refractionIrradiance=irradiance(reflectionSampler,-irradianceVector,vReflectionFilteringInfo); +#else +vec3 refractionIrradiance=computeEnvironmentIrradiance(-irradianceVector); +#endif +#elif defined(USEIRRADIANCEMAP) +#ifdef REFLECTIONMAP_3D +vec3 irradianceCoords=irradianceVector; +#else +vec2 irradianceCoords=irradianceVector.xy; +#ifdef REFLECTIONMAP_PROJECTION +irradianceCoords/=irradianceVector.z; +#endif +irradianceCoords.y=1.0-irradianceCoords.y; +#endif +vec4 refractionIrradiance=sampleReflection(irradianceSampler,-irradianceCoords); +#ifdef RGBDREFLECTION +refractionIrradiance.rgb=fromRGBD(refractionIrradiance); +#endif +#ifdef GAMMAREFLECTION +refractionIrradiance.rgb=toLinearSpace(refractionIrradiance.rgb); +#endif +#else +vec4 refractionIrradiance=vec4(0.); +#endif +refractionIrradiance.rgb*=transmittance; +outParams.refractionIrradiance=refractionIrradiance.rgb; +#endif +} +#endif +`;ze.a.IncludesShadersStore.pbrBlockSubSurface=Kp;var Qp=`vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW); +#ifdef NORMAL +vec3 normalW=normalize(vNormalW); +#else +vec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w; +#endif +vec3 geometricNormalW=normalW; +#if defined(TWOSIDEDLIGHTING) && defined(NORMAL) +geometricNormalW=gl_FrontFacing ? geometricNormalW : -geometricNormalW; +#endif +`;ze.a.IncludesShadersStore.pbrBlockNormalGeometric=Qp,f(134);var qp=`#if defined(FORCENORMALFORWARD) && defined(NORMAL) +vec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w; +#if defined(TWOSIDEDLIGHTING) +faceNormal=gl_FrontFacing ? faceNormal : -faceNormal; +#endif +normalW*=sign(dot(normalW,faceNormal)); +#endif +#if defined(TWOSIDEDLIGHTING) && defined(NORMAL) +normalW=gl_FrontFacing ? normalW : -normalW; +#endif +`;ze.a.IncludesShadersStore.pbrBlockNormalFinal=qp,f(162);var Zp=`#ifdef LIGHTMAP +vec4 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset); +#ifdef RGBDLIGHTMAP +lightmapColor.rgb=fromRGBD(lightmapColor); +#endif +#ifdef GAMMALIGHTMAP +lightmapColor.rgb=toLinearSpace(lightmapColor.rgb); +#endif +lightmapColor.rgb*=vLightmapInfos.y; +#endif +`;ze.a.IncludesShadersStore.pbrBlockLightmapInit=Zp;var Jp=`float NdotVUnclamped=dot(normalW,viewDirectionW); + +float NdotV=absEps(NdotVUnclamped); +float alphaG=convertRoughnessToAverageSlope(roughness); +vec2 AARoughnessFactors=getAARoughnessFactors(normalW.xyz); +#ifdef SPECULARAA + +alphaG+=AARoughnessFactors.y; +#endif +#if defined(ENVIRONMENTBRDF) + +vec3 environmentBrdf=getBRDFLookup(NdotV,roughness); +#endif +#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX) +#ifdef RADIANCEOCCLUSION +#ifdef AMBIENTINGRAYSCALE +float ambientMonochrome=aoOut.ambientOcclusionColor.r; +#else +float ambientMonochrome=getLuminance(aoOut.ambientOcclusionColor); +#endif +float seo=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped); +#endif +#ifdef HORIZONOCCLUSION +#ifdef BUMP +#ifdef REFLECTIONMAP_3D +float eho=environmentHorizonOcclusion(-viewDirectionW,normalW,geometricNormalW); +#endif +#endif +#endif +#endif +`;ze.a.IncludesShadersStore.pbrBlockGeometryInfo=Jp;var $p=`float reflectance=max(max(reflectivityOut.surfaceReflectivityColor.r,reflectivityOut.surfaceReflectivityColor.g),reflectivityOut.surfaceReflectivityColor.b); +vec3 specularEnvironmentR0=reflectivityOut.surfaceReflectivityColor.rgb; +#ifdef METALLICWORKFLOW +vec3 specularEnvironmentR90=vec3(metallicReflectanceFactors.a); +#else +vec3 specularEnvironmentR90=vec3(1.0,1.0,1.0); +#endif + +#ifdef ALPHAFRESNEL +float reflectance90=fresnelGrazingReflectance(reflectance); +specularEnvironmentR90=specularEnvironmentR90*reflectance90; +#endif +`;ze.a.IncludesShadersStore.pbrBlockReflectance0=$p;var e_=`#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX) +vec3 specularEnvironmentReflectance=getReflectanceFromBRDFLookup(clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,environmentBrdf); +#ifdef RADIANCEOCCLUSION +specularEnvironmentReflectance*=seo; +#endif +#ifdef HORIZONOCCLUSION +#ifdef BUMP +#ifdef REFLECTIONMAP_3D +specularEnvironmentReflectance*=eho; +#endif +#endif +#endif +#else + +vec3 specularEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(NdotV,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface)); +#endif +#ifdef CLEARCOAT +specularEnvironmentReflectance*=clearcoatOut.conservationFactor; +#if defined(CLEARCOAT_TINT) +specularEnvironmentReflectance*=clearcoatOut.absorption; +#endif +#endif +`;ze.a.IncludesShadersStore.pbrBlockReflectance=e_;var t_=`vec3 diffuseBase=vec3(0.,0.,0.); +#ifdef SPECULARTERM +vec3 specularBase=vec3(0.,0.,0.); +#endif +#ifdef CLEARCOAT +vec3 clearCoatBase=vec3(0.,0.,0.); +#endif +#ifdef SHEEN +vec3 sheenBase=vec3(0.,0.,0.); +#endif + +preLightingInfo preInfo; +lightingInfo info; +float shadow=1.; +#if defined(CLEARCOAT) && defined(CLEARCOAT_TINT) +vec3 absorption=vec3(0.); +#endif +`;ze.a.IncludesShadersStore.pbrBlockDirectLighting=t_;var n_=` + + + +#if defined(ENVIRONMENTBRDF) +#ifdef MS_BRDF_ENERGY_CONSERVATION +vec3 energyConservationFactor=getEnergyConservationFactor(clearcoatOut.specularEnvironmentR0,environmentBrdf); +#endif +#endif +#ifndef METALLICWORKFLOW +#ifdef SPECULAR_GLOSSINESS_ENERGY_CONSERVATION +surfaceAlbedo.rgb=(1.-reflectance)*surfaceAlbedo.rgb; +#endif +#endif +#if defined(SHEEN) && defined(SHEEN_ALBEDOSCALING) && defined(ENVIRONMENTBRDF) +surfaceAlbedo.rgb=sheenOut.sheenAlbedoScaling*surfaceAlbedo.rgb; +#endif + +#ifdef REFLECTION +vec3 finalIrradiance=reflectionOut.environmentIrradiance; +#if defined(CLEARCOAT) +finalIrradiance*=clearcoatOut.conservationFactor; +#if defined(CLEARCOAT_TINT) +finalIrradiance*=clearcoatOut.absorption; +#endif +#endif +#if defined(SS_REFRACTION) +finalIrradiance*=subSurfaceOut.refractionFactorForIrradiance; +#endif +#if defined(SS_TRANSLUCENCY) +finalIrradiance*=(1.0-subSurfaceOut.translucencyIntensity); +finalIrradiance+=subSurfaceOut.refractionIrradiance; +#endif +finalIrradiance*=surfaceAlbedo.rgb; +finalIrradiance*=vLightingIntensity.z; +finalIrradiance*=aoOut.ambientOcclusionColor; +#endif + +#ifdef SPECULARTERM +vec3 finalSpecular=specularBase; +finalSpecular=max(finalSpecular,0.0); +vec3 finalSpecularScaled=finalSpecular*vLightingIntensity.x*vLightingIntensity.w; +#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION) +finalSpecularScaled*=energyConservationFactor; +#endif +#if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING) +finalSpecularScaled*=sheenOut.sheenAlbedoScaling; +#endif +#endif + +#ifdef REFLECTION +vec3 finalRadiance=reflectionOut.environmentRadiance.rgb; +finalRadiance*=subSurfaceOut.specularEnvironmentReflectance; +vec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z; +#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION) +finalRadianceScaled*=energyConservationFactor; +#endif +#if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING) +finalRadianceScaled*=sheenOut.sheenAlbedoScaling; +#endif +#endif + +#ifdef SHEEN +vec3 finalSheen=sheenBase*sheenOut.sheenColor; +finalSheen=max(finalSheen,0.0); +vec3 finalSheenScaled=finalSheen*vLightingIntensity.x*vLightingIntensity.w; +#if defined(CLEARCOAT) && defined(REFLECTION) && defined(ENVIRONMENTBRDF) +sheenOut.finalSheenRadianceScaled*=clearcoatOut.conservationFactor; +#if defined(CLEARCOAT_TINT) +sheenOut.finalSheenRadianceScaled*=clearcoatOut.absorption; +#endif +#endif +#endif + +#ifdef CLEARCOAT +vec3 finalClearCoat=clearCoatBase; +finalClearCoat=max(finalClearCoat,0.0); +vec3 finalClearCoatScaled=finalClearCoat*vLightingIntensity.x*vLightingIntensity.w; +#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION) +finalClearCoatScaled*=clearcoatOut.energyConservationFactorClearCoat; +#endif +#ifdef SS_REFRACTION +subSurfaceOut.finalRefraction*=clearcoatOut.conservationFactor; +#ifdef CLEARCOAT_TINT +subSurfaceOut.finalRefraction*=clearcoatOut.absorption; +#endif +#endif +#endif + +#ifdef ALPHABLEND +float luminanceOverAlpha=0.0; +#if defined(REFLECTION) && defined(RADIANCEOVERALPHA) +luminanceOverAlpha+=getLuminance(finalRadianceScaled); +#if defined(CLEARCOAT) +luminanceOverAlpha+=getLuminance(clearcoatOut.finalClearCoatRadianceScaled); +#endif +#endif +#if defined(SPECULARTERM) && defined(SPECULAROVERALPHA) +luminanceOverAlpha+=getLuminance(finalSpecularScaled); +#endif +#if defined(CLEARCOAT) && defined(CLEARCOATOVERALPHA) +luminanceOverAlpha+=getLuminance(finalClearCoatScaled); +#endif +#if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA) || defined(CLEARCOATOVERALPHA) +alpha=saturate(alpha+luminanceOverAlpha*luminanceOverAlpha); +#endif +#endif +`;ze.a.IncludesShadersStore.pbrBlockFinalLitComponents=n_;var i_=` +vec3 finalDiffuse=diffuseBase; +finalDiffuse*=surfaceAlbedo.rgb; +finalDiffuse=max(finalDiffuse,0.0); +finalDiffuse*=vLightingIntensity.x; + +vec3 finalAmbient=vAmbientColor; +finalAmbient*=surfaceAlbedo.rgb; + +vec3 finalEmissive=vEmissiveColor; +#ifdef EMISSIVE +vec3 emissiveColorTex=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb; +finalEmissive*=toLinearSpace(emissiveColorTex.rgb); +finalEmissive*=vEmissiveInfos.y; +#endif +finalEmissive*=vLightingIntensity.y; + +#ifdef AMBIENT +vec3 ambientOcclusionForDirectDiffuse=mix(vec3(1.),aoOut.ambientOcclusionColor,vAmbientInfos.w); +#else +vec3 ambientOcclusionForDirectDiffuse=aoOut.ambientOcclusionColor; +#endif +finalAmbient*=aoOut.ambientOcclusionColor; +finalDiffuse*=ambientOcclusionForDirectDiffuse; +`;ze.a.IncludesShadersStore.pbrBlockFinalUnlitComponents=i_;var r_=`vec4 finalColor=vec4( +finalAmbient + +finalDiffuse + +#ifndef UNLIT +#ifdef REFLECTION +finalIrradiance + +#endif +#ifdef SPECULARTERM +finalSpecularScaled + +#endif +#ifdef SHEEN +finalSheenScaled + +#endif +#ifdef CLEARCOAT +finalClearCoatScaled + +#endif +#ifdef REFLECTION +finalRadianceScaled + +#if defined(SHEEN) && defined(ENVIRONMENTBRDF) +sheenOut.finalSheenRadianceScaled + +#endif +#ifdef CLEARCOAT +clearcoatOut.finalClearCoatRadianceScaled + +#endif +#endif +#ifdef SS_REFRACTION +subSurfaceOut.finalRefraction + +#endif +#endif +finalEmissive, +alpha); + +#ifdef LIGHTMAP +#ifndef LIGHTMAPEXCLUDED +#ifdef USELIGHTMAPASSHADOWMAP +finalColor.rgb*=lightmapColor.rgb; +#else +finalColor.rgb+=lightmapColor.rgb; +#endif +#endif +#endif +#define CUSTOM_FRAGMENT_BEFORE_FOG + +finalColor=max(finalColor,0.0); +`;ze.a.IncludesShadersStore.pbrBlockFinalColorComposition=r_,f(155);var o_=`#ifdef IMAGEPROCESSINGPOSTPROCESS + + +finalColor.rgb=clamp(finalColor.rgb,0.,30.0); +#else + +finalColor=applyImageProcessing(finalColor); +#endif +finalColor.a*=visibility; +#ifdef PREMULTIPLYALPHA + +finalColor.rgb*=finalColor.a; +#endif +`;ze.a.IncludesShadersStore.pbrBlockImageProcessing=o_;var a_=`#if DEBUGMODE>0 +if (vClipSpacePosition.x/vClipSpacePosition.w>=vDebugMode.x) { + +#if DEBUGMODE == 1 +gl_FragColor.rgb=vPositionW.rgb; +#define DEBUGMODE_NORMALIZE +#elif DEBUGMODE == 2 && defined(NORMAL) +gl_FragColor.rgb=vNormalW.rgb; +#define DEBUGMODE_NORMALIZE +#elif DEBUGMODE == 3 && defined(BUMP) || DEBUGMODE == 3 && defined(PARALLAX) || DEBUGMODE == 3 && defined(ANISOTROPIC) + +gl_FragColor.rgb=TBN[0]; +#define DEBUGMODE_NORMALIZE +#elif DEBUGMODE == 4 && defined(BUMP) || DEBUGMODE == 4 && defined(PARALLAX) || DEBUGMODE == 4 && defined(ANISOTROPIC) + +gl_FragColor.rgb=TBN[1]; +#define DEBUGMODE_NORMALIZE +#elif DEBUGMODE == 5 + +gl_FragColor.rgb=normalW; +#define DEBUGMODE_NORMALIZE +#elif DEBUGMODE == 6 && defined(MAINUV1) +gl_FragColor.rgb=vec3(vMainUV1,0.0); +#elif DEBUGMODE == 7 && defined(MAINUV2) +gl_FragColor.rgb=vec3(vMainUV2,0.0); +#elif DEBUGMODE == 8 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP) + +gl_FragColor.rgb=clearcoatOut.TBNClearCoat[0]; +#define DEBUGMODE_NORMALIZE +#elif DEBUGMODE == 9 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP) + +gl_FragColor.rgb=clearcoatOut.TBNClearCoat[1]; +#define DEBUGMODE_NORMALIZE +#elif DEBUGMODE == 10 && defined(CLEARCOAT) + +gl_FragColor.rgb=clearcoatOut.clearCoatNormalW; +#define DEBUGMODE_NORMALIZE +#elif DEBUGMODE == 11 && defined(ANISOTROPIC) +gl_FragColor.rgb=anisotropicOut.anisotropicNormal; +#define DEBUGMODE_NORMALIZE +#elif DEBUGMODE == 12 && defined(ANISOTROPIC) +gl_FragColor.rgb=anisotropicOut.anisotropicTangent; +#define DEBUGMODE_NORMALIZE +#elif DEBUGMODE == 13 && defined(ANISOTROPIC) +gl_FragColor.rgb=anisotropicOut.anisotropicBitangent; +#define DEBUGMODE_NORMALIZE + +#elif DEBUGMODE == 20 && defined(ALBEDO) +gl_FragColor.rgb=albedoTexture.rgb; +#elif DEBUGMODE == 21 && defined(AMBIENT) +gl_FragColor.rgb=aoOut.ambientOcclusionColorMap.rgb; +#elif DEBUGMODE == 22 && defined(OPACITY) +gl_FragColor.rgb=opacityMap.rgb; +#elif DEBUGMODE == 23 && defined(EMISSIVE) +gl_FragColor.rgb=emissiveColorTex.rgb; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE == 24 && defined(LIGHTMAP) +gl_FragColor.rgb=lightmapColor.rgb; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE == 25 && defined(REFLECTIVITY) && defined(METALLICWORKFLOW) +gl_FragColor.rgb=reflectivityOut.surfaceMetallicColorMap.rgb; +#elif DEBUGMODE == 26 && defined(REFLECTIVITY) && !defined(METALLICWORKFLOW) +gl_FragColor.rgb=reflectivityOut.surfaceReflectivityColorMap.rgb; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE == 27 && defined(CLEARCOAT) && defined(CLEARCOAT_TEXTURE) +gl_FragColor.rgb=vec3(clearcoatOut.clearCoatMapData.rg,0.0); +#elif DEBUGMODE == 28 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE) +gl_FragColor.rgb=clearcoatOut.clearCoatTintMapData.rgb; +#elif DEBUGMODE == 29 && defined(SHEEN) && defined(SHEEN_TEXTURE) +gl_FragColor.rgb=sheenOut.sheenMapData.rgb; +#elif DEBUGMODE == 30 && defined(ANISOTROPIC) && defined(ANISOTROPIC_TEXTURE) +gl_FragColor.rgb=anisotropicOut.anisotropyMapData.rgb; +#elif DEBUGMODE == 31 && defined(SUBSURFACE) && defined(SS_THICKNESSANDMASK_TEXTURE) +gl_FragColor.rgb=subSurfaceOut.thicknessMap.rgb; + +#elif DEBUGMODE == 40 && defined(SS_REFRACTION) + +gl_FragColor.rgb=subSurfaceOut.environmentRefraction.rgb; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE == 41 && defined(REFLECTION) +gl_FragColor.rgb=reflectionOut.environmentRadiance.rgb; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE == 42 && defined(CLEARCOAT) && defined(REFLECTION) +gl_FragColor.rgb=clearcoatOut.environmentClearCoatRadiance.rgb; +#define DEBUGMODE_GAMMA + +#elif DEBUGMODE == 50 +gl_FragColor.rgb=diffuseBase.rgb; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE == 51 && defined(SPECULARTERM) +gl_FragColor.rgb=specularBase.rgb; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE == 52 && defined(CLEARCOAT) +gl_FragColor.rgb=clearCoatBase.rgb; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE == 53 && defined(SHEEN) +gl_FragColor.rgb=sheenBase.rgb; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE == 54 && defined(REFLECTION) +gl_FragColor.rgb=reflectionOut.environmentIrradiance.rgb; +#define DEBUGMODE_GAMMA + +#elif DEBUGMODE == 60 +gl_FragColor.rgb=surfaceAlbedo.rgb; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE == 61 +gl_FragColor.rgb=clearcoatOut.specularEnvironmentR0; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE == 62 && defined(METALLICWORKFLOW) +gl_FragColor.rgb=vec3(reflectivityOut.metallicRoughness.r); +#elif DEBUGMODE == 71 && defined(METALLICWORKFLOW) +gl_FragColor.rgb=reflectivityOut.metallicF0; +#elif DEBUGMODE == 63 +gl_FragColor.rgb=vec3(roughness); +#elif DEBUGMODE == 64 +gl_FragColor.rgb=vec3(alphaG); +#elif DEBUGMODE == 65 +gl_FragColor.rgb=vec3(NdotV); +#elif DEBUGMODE == 66 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT) +gl_FragColor.rgb=clearcoatOut.clearCoatColor.rgb; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE == 67 && defined(CLEARCOAT) +gl_FragColor.rgb=vec3(clearcoatOut.clearCoatRoughness); +#elif DEBUGMODE == 68 && defined(CLEARCOAT) +gl_FragColor.rgb=vec3(clearcoatOut.clearCoatNdotV); +#elif DEBUGMODE == 69 && defined(SUBSURFACE) && defined(SS_TRANSLUCENCY) +gl_FragColor.rgb=subSurfaceOut.transmittance; +#elif DEBUGMODE == 70 && defined(SUBSURFACE) && defined(SS_REFRACTION) +gl_FragColor.rgb=subSurfaceOut.refractionTransmittance; + +#elif DEBUGMODE == 80 && defined(RADIANCEOCCLUSION) +gl_FragColor.rgb=vec3(seo); +#elif DEBUGMODE == 81 && defined(HORIZONOCCLUSION) +gl_FragColor.rgb=vec3(eho); +#elif DEBUGMODE == 82 && defined(MS_BRDF_ENERGY_CONSERVATION) +gl_FragColor.rgb=vec3(energyConservationFactor); +#elif DEBUGMODE == 83 && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX) +gl_FragColor.rgb=specularEnvironmentReflectance; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE == 84 && defined(CLEARCOAT) && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX) +gl_FragColor.rgb=clearcoatOut.clearCoatEnvironmentReflectance; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE == 85 && defined(SHEEN) && defined(REFLECTION) +gl_FragColor.rgb=sheenOut.sheenEnvironmentReflectance; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE == 86 && defined(ALPHABLEND) +gl_FragColor.rgb=vec3(luminanceOverAlpha); +#elif DEBUGMODE == 87 +gl_FragColor.rgb=vec3(alpha); +#endif +gl_FragColor.rgb*=vDebugMode.y; +#ifdef DEBUGMODE_NORMALIZE +gl_FragColor.rgb=normalize(gl_FragColor.rgb)*0.5+0.5; +#endif +#ifdef DEBUGMODE_GAMMA +gl_FragColor.rgb=toGammaSpace(gl_FragColor.rgb); +#endif +gl_FragColor.a=1.0; +#ifdef PREPASS +gl_FragData[0]=toLinearSpace(gl_FragColor); +gl_FragData[1]=vec4(0.,0.,0.,0.); +#endif +return; +} +#endif`;ze.a.IncludesShadersStore.pbrDebug=a_;var s_=`#if defined(BUMP) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) +#extension GL_OES_standard_derivatives : enable +#endif +#ifdef LODBASEDMICROSFURACE +#extension GL_EXT_shader_texture_lod : enable +#endif +#define CUSTOM_FRAGMENT_BEGIN +#ifdef LOGARITHMICDEPTH +#extension GL_EXT_frag_depth : enable +#endif +#include[SCENE_MRT_COUNT] +precision highp float; + +#ifndef FROMLINEARSPACE +#define FROMLINEARSPACE +#endif + +#include<__decl__pbrFragment> +#include +#include<__decl__lightFragment>[0..maxSimultaneousLights] +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef REFLECTION +#include +#endif +#define CUSTOM_FRAGMENT_DEFINITIONS +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void main(void) { +#define CUSTOM_FRAGMENT_MAIN_BEGIN +#include + +#include +#include +#include + +albedoOpacityOutParams albedoOpacityOut; +#ifdef ALBEDO +vec4 albedoTexture=texture2D(albedoSampler,vAlbedoUV+uvOffset); +#endif +#ifdef OPACITY +vec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset); +#endif +albedoOpacityBlock( +vAlbedoColor, +#ifdef ALBEDO +albedoTexture, +vAlbedoInfos, +#endif +#ifdef OPACITY +opacityMap, +vOpacityInfos, +#endif +#ifdef DETAIL +detailColor, +vDetailInfos, +#endif +albedoOpacityOut +); +vec3 surfaceAlbedo=albedoOpacityOut.surfaceAlbedo; +float alpha=albedoOpacityOut.alpha; +#define CUSTOM_FRAGMENT_UPDATE_ALPHA +#include +#define CUSTOM_FRAGMENT_BEFORE_LIGHTS + +ambientOcclusionOutParams aoOut; +#ifdef AMBIENT +vec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb; +#endif +ambientOcclusionBlock( +#ifdef AMBIENT +ambientOcclusionColorMap, +vAmbientInfos, +#endif +aoOut +); +#include +#ifdef UNLIT +vec3 diffuseBase=vec3(1.,1.,1.); +#else + +vec3 baseColor=surfaceAlbedo; +reflectivityOutParams reflectivityOut; +#if defined(REFLECTIVITY) +vec4 surfaceMetallicOrReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset); +vec4 baseReflectivity=surfaceMetallicOrReflectivityColorMap; +#ifndef METALLICWORKFLOW +surfaceMetallicOrReflectivityColorMap=toLinearSpace(surfaceMetallicOrReflectivityColorMap); +surfaceMetallicOrReflectivityColorMap.rgb*=vReflectivityInfos.y; +#endif +#endif +#if defined(MICROSURFACEMAP) +vec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y; +#endif +#ifdef METALLICWORKFLOW +vec4 metallicReflectanceFactors=vMetallicReflectanceFactors; +#ifdef METALLIC_REFLECTANCE +vec4 metallicReflectanceFactorsMap=texture2D(metallicReflectanceSampler,vMetallicReflectanceUV+uvOffset); +metallicReflectanceFactorsMap=toLinearSpace(metallicReflectanceFactorsMap); +metallicReflectanceFactors*=metallicReflectanceFactorsMap; +#endif +#endif +reflectivityBlock( +vReflectivityColor, +#ifdef METALLICWORKFLOW +surfaceAlbedo, +metallicReflectanceFactors, +#endif +#ifdef REFLECTIVITY +vReflectivityInfos, +surfaceMetallicOrReflectivityColorMap, +#endif +#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED) +aoOut.ambientOcclusionColor, +#endif +#ifdef MICROSURFACEMAP +microSurfaceTexel, +#endif +#ifdef DETAIL +detailColor, +vDetailInfos, +#endif +reflectivityOut +); +float microSurface=reflectivityOut.microSurface; +float roughness=reflectivityOut.roughness; +#ifdef METALLICWORKFLOW +surfaceAlbedo=reflectivityOut.surfaceAlbedo; +#endif +#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED) +aoOut.ambientOcclusionColor=reflectivityOut.ambientOcclusionColor; +#endif + +#ifdef ALPHAFRESNEL +#if defined(ALPHATEST) || defined(ALPHABLEND) +alphaFresnelOutParams alphaFresnelOut; +alphaFresnelBlock( +normalW, +viewDirectionW, +alpha, +microSurface, +alphaFresnelOut +); +alpha=alphaFresnelOut.alpha; +#endif +#endif + +#include + +#ifdef ANISOTROPIC +anisotropicOutParams anisotropicOut; +#ifdef ANISOTROPIC_TEXTURE +vec3 anisotropyMapData=texture2D(anisotropySampler,vAnisotropyUV+uvOffset).rgb*vAnisotropyInfos.y; +#endif +anisotropicBlock( +vAnisotropy, +#ifdef ANISOTROPIC_TEXTURE +anisotropyMapData, +#endif +TBN, +normalW, +viewDirectionW, +anisotropicOut +); +#endif + +#ifdef REFLECTION +reflectionOutParams reflectionOut; +reflectionBlock( +vPositionW, +normalW, +alphaG, +vReflectionMicrosurfaceInfos, +vReflectionInfos, +vReflectionColor, +#ifdef ANISOTROPIC +anisotropicOut, +#endif +#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX) +NdotVUnclamped, +#endif +#ifdef LINEARSPECULARREFLECTION +roughness, +#endif +reflectionSampler, +#if defined(NORMAL) && defined(USESPHERICALINVERTEX) +vEnvironmentIrradiance, +#endif +#ifdef USESPHERICALFROMREFLECTIONMAP +#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX) +reflectionMatrix, +#endif +#endif +#ifdef USEIRRADIANCEMAP +irradianceSampler, +#endif +#ifndef LODBASEDMICROSFURACE +reflectionSamplerLow, +reflectionSamplerHigh, +#endif +#ifdef REALTIME_FILTERING +vReflectionFilteringInfo, +#endif +reflectionOut +); +#endif + +#include + +#ifdef SHEEN +sheenOutParams sheenOut; +#ifdef SHEEN_TEXTURE +vec4 sheenMapData=toLinearSpace(texture2D(sheenSampler,vSheenUV+uvOffset))*vSheenInfos.y; +#endif +#if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE) +vec4 sheenMapRoughnessData=texture2D(sheenRoughnessSampler,vSheenRoughnessUV+uvOffset)*vSheenInfos.w; +#endif +sheenBlock( +vSheenColor, +#ifdef SHEEN_ROUGHNESS +vSheenRoughness, +#if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE) +sheenMapRoughnessData, +#endif +#endif +roughness, +#ifdef SHEEN_TEXTURE +sheenMapData, +#endif +reflectance, +#ifdef SHEEN_LINKWITHALBEDO +baseColor, +surfaceAlbedo, +#endif +#ifdef ENVIRONMENTBRDF +NdotV, +environmentBrdf, +#endif +#if defined(REFLECTION) && defined(ENVIRONMENTBRDF) +AARoughnessFactors, +vReflectionMicrosurfaceInfos, +vReflectionInfos, +vReflectionColor, +vLightingIntensity, +reflectionSampler, +reflectionOut.reflectionCoords, +NdotVUnclamped, +#ifndef LODBASEDMICROSFURACE +reflectionSamplerLow, +reflectionSamplerHigh, +#endif +#ifdef REALTIME_FILTERING +vReflectionFilteringInfo, +#endif +#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION) +seo, +#endif +#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D) +eho, +#endif +#endif +sheenOut +); +#ifdef SHEEN_LINKWITHALBEDO +surfaceAlbedo=sheenOut.surfaceAlbedo; +#endif +#endif + +clearcoatOutParams clearcoatOut; +#ifdef CLEARCOAT +#ifdef CLEARCOAT_TEXTURE +vec2 clearCoatMapData=texture2D(clearCoatSampler,vClearCoatUV+uvOffset).rg*vClearCoatInfos.y; +#endif +#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE) +vec4 clearCoatMapRoughnessData=texture2D(clearCoatRoughnessSampler,vClearCoatRoughnessUV+uvOffset)*vClearCoatInfos.w; +#endif +#if defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE) +vec4 clearCoatTintMapData=toLinearSpace(texture2D(clearCoatTintSampler,vClearCoatTintUV+uvOffset)); +#endif +#ifdef CLEARCOAT_BUMP +vec4 clearCoatBumpMapData=texture2D(clearCoatBumpSampler,vClearCoatBumpUV+uvOffset); +#endif +clearcoatBlock( +vPositionW, +geometricNormalW, +viewDirectionW, +vClearCoatParams, +#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE) +clearCoatMapRoughnessData, +#endif +specularEnvironmentR0, +#ifdef CLEARCOAT_TEXTURE +clearCoatMapData, +#endif +#ifdef CLEARCOAT_TINT +vClearCoatTintParams, +clearCoatColorAtDistance, +vClearCoatRefractionParams, +#ifdef CLEARCOAT_TINT_TEXTURE +clearCoatTintMapData, +#endif +#endif +#ifdef CLEARCOAT_BUMP +vClearCoatBumpInfos, +clearCoatBumpMapData, +vClearCoatBumpUV, +#if defined(TANGENT) && defined(NORMAL) +vTBN, +#else +vClearCoatTangentSpaceParams, +#endif +#ifdef OBJECTSPACE_NORMALMAP +normalMatrix, +#endif +#endif +#if defined(FORCENORMALFORWARD) && defined(NORMAL) +faceNormal, +#endif +#ifdef REFLECTION +vReflectionMicrosurfaceInfos, +vReflectionInfos, +vReflectionColor, +vLightingIntensity, +reflectionSampler, +#ifndef LODBASEDMICROSFURACE +reflectionSamplerLow, +reflectionSamplerHigh, +#endif +#ifdef REALTIME_FILTERING +vReflectionFilteringInfo, +#endif +#endif +#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX) +#ifdef RADIANCEOCCLUSION +ambientMonochrome, +#endif +#endif +clearcoatOut +); +#else +clearcoatOut.specularEnvironmentR0=specularEnvironmentR0; +#endif + +#include + +subSurfaceOutParams subSurfaceOut; +#ifdef SUBSURFACE +#ifdef SS_THICKNESSANDMASK_TEXTURE +vec4 thicknessMap=texture2D(thicknessSampler,vThicknessUV+uvOffset); +#endif +subSurfaceBlock( +vSubSurfaceIntensity, +vThicknessParam, +vTintColor, +normalW, +specularEnvironmentReflectance, +#ifdef SS_THICKNESSANDMASK_TEXTURE +thicknessMap, +#endif +#ifdef REFLECTION +#ifdef SS_TRANSLUCENCY +reflectionMatrix, +#ifdef USESPHERICALFROMREFLECTIONMAP +#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX) +reflectionOut.irradianceVector, +#endif +#if defined(REALTIME_FILTERING) +reflectionSampler, +vReflectionFilteringInfo, +#endif +#endif +#ifdef USEIRRADIANCEMAP +irradianceSampler, +#endif +#endif +#endif +#ifdef SS_REFRACTION +vPositionW, +viewDirectionW, +view, +surfaceAlbedo, +vRefractionInfos, +refractionMatrix, +vRefractionMicrosurfaceInfos, +vLightingIntensity, +#ifdef SS_LINKREFRACTIONTOTRANSPARENCY +alpha, +#endif +#ifdef SS_LODINREFRACTIONALPHA +NdotVUnclamped, +#endif +#ifdef SS_LINEARSPECULARREFRACTION +roughness, +#else +alphaG, +#endif +refractionSampler, +#ifndef LODBASEDMICROSFURACE +refractionSamplerLow, +refractionSamplerHigh, +#endif +#ifdef ANISOTROPIC +anisotropicOut, +#endif +#ifdef REALTIME_FILTERING +vRefractionFilteringInfo, +#endif +#endif +#ifdef SS_TRANSLUCENCY +vDiffusionDistance, +#endif +subSurfaceOut +); +#ifdef SS_REFRACTION +surfaceAlbedo=subSurfaceOut.surfaceAlbedo; +#ifdef SS_LINKREFRACTIONTOTRANSPARENCY +alpha=subSurfaceOut.alpha; +#endif +#endif +#else +subSurfaceOut.specularEnvironmentReflectance=specularEnvironmentReflectance; +#endif + +#include +#include[0..maxSimultaneousLights] + +#include +#endif +#include +#include +#include +#include(color,finalColor) +#include +#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR +#ifdef PREPASS +#ifdef PREPASS_POSITION +gl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,1.0); +#endif +#ifdef PREPASS_VELOCITY +vec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5; +vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5; +vec2 velocity=abs(a-b); +velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5; +gl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,1.0); +#endif +#ifdef PREPASS_IRRADIANCE +vec3 irradiance=finalDiffuse; +#ifndef UNLIT +#ifdef REFLECTION +irradiance+=finalIrradiance; +#endif +#endif +vec3 sqAlbedo=sqrt(surfaceAlbedo); +#ifdef SS_SCATTERING +gl_FragData[0]=vec4(finalColor.rgb-irradiance,finalColor.a); +irradiance/=sqAlbedo; +#else +gl_FragData[0]=finalColor; +float scatteringDiffusionProfile=255.; +#endif +gl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(irradiance,scatteringDiffusionProfile/255.); +#else +gl_FragData[0]=vec4(finalColor.rgb,finalColor.a); +#endif +#ifdef PREPASS_DEPTHNORMAL +gl_FragData[PREPASS_DEPTHNORMAL_INDEX]=vec4(vViewPos.z,(view*vec4(normalW,0.0)).rgb); +#endif +#ifdef PREPASS_ALBEDO +gl_FragData[PREPASS_ALBEDO_INDEX]=vec4(sqAlbedo,1.0); +#endif +#ifdef PREPASS_REFLECTIVITY +#if defined(REFLECTIVITY) +gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(baseReflectivity.rgb,1.0); +#else +gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(0.0,0.0,0.0,1.0); +#endif +#endif +#endif +#if !defined(PREPASS) || defined(WEBGL2) +gl_FragColor=finalColor; +#endif +#include +} +`;ze.a.ShadersStore.pbrPixelShader=s_;var c_=`uniform mat4 view; +uniform mat4 viewProjection; +#ifdef ALBEDO +uniform mat4 albedoMatrix; +uniform vec2 vAlbedoInfos; +#endif +#ifdef AMBIENT +uniform mat4 ambientMatrix; +uniform vec4 vAmbientInfos; +#endif +#ifdef OPACITY +uniform mat4 opacityMatrix; +uniform vec2 vOpacityInfos; +#endif +#ifdef EMISSIVE +uniform vec2 vEmissiveInfos; +uniform mat4 emissiveMatrix; +#endif +#ifdef LIGHTMAP +uniform vec2 vLightmapInfos; +uniform mat4 lightmapMatrix; +#endif +#ifdef REFLECTIVITY +uniform vec3 vReflectivityInfos; +uniform mat4 reflectivityMatrix; +#endif +#ifdef METALLIC_REFLECTANCE +uniform vec2 vMetallicReflectanceInfos; +uniform mat4 metallicReflectanceMatrix; +#endif +#ifdef MICROSURFACEMAP +uniform vec2 vMicroSurfaceSamplerInfos; +uniform mat4 microSurfaceSamplerMatrix; +#endif +#ifdef BUMP +uniform vec3 vBumpInfos; +uniform mat4 bumpMatrix; +#endif +#ifdef POINTSIZE +uniform float pointSize; +#endif + +#ifdef REFLECTION +uniform vec2 vReflectionInfos; +uniform mat4 reflectionMatrix; +#endif + +#ifdef CLEARCOAT +#if defined(CLEARCOAT_TEXTURE) || defined(CLEARCOAT_TEXTURE_ROUGHNESS) +uniform vec4 vClearCoatInfos; +#endif +#ifdef CLEARCOAT_TEXTURE +uniform mat4 clearCoatMatrix; +#endif +#ifdef CLEARCOAT_TEXTURE_ROUGHNESS +uniform mat4 clearCoatRoughnessMatrix; +#endif +#ifdef CLEARCOAT_BUMP +uniform vec2 vClearCoatBumpInfos; +uniform mat4 clearCoatBumpMatrix; +#endif +#ifdef CLEARCOAT_TINT_TEXTURE +uniform vec2 vClearCoatTintInfos; +uniform mat4 clearCoatTintMatrix; +#endif +#endif + +#ifdef ANISOTROPIC +#ifdef ANISOTROPIC_TEXTURE +uniform vec2 vAnisotropyInfos; +uniform mat4 anisotropyMatrix; +#endif +#endif + +#ifdef SHEEN +#if defined(SHEEN_TEXTURE) || defined(SHEEN_TEXTURE_ROUGHNESS) +uniform vec4 vSheenInfos; +#endif +#ifdef SHEEN_TEXTURE +uniform mat4 sheenMatrix; +#endif +#ifdef SHEEN_TEXTURE_ROUGHNESS +uniform mat4 sheenRoughnessMatrix; +#endif +#endif + +#ifdef SUBSURFACE +#ifdef SS_REFRACTION +uniform vec4 vRefractionInfos; +uniform mat4 refractionMatrix; +#endif +#ifdef SS_THICKNESSANDMASK_TEXTURE +uniform vec2 vThicknessInfos; +uniform mat4 thicknessMatrix; +#endif +#endif +`;ze.a.IncludesShadersStore.pbrVertexDeclaration=c_,f(163),f(164),f(93),f(94),f(100),f(165),f(156),f(158);var l_=`precision highp float; +#include<__decl__pbrVertex> +#define CUSTOM_VERTEX_BEGIN + +attribute vec3 position; +#ifdef NORMAL +attribute vec3 normal; +#endif +#ifdef TANGENT +attribute vec4 tangent; +#endif +#ifdef UV1 +attribute vec2 uv; +#endif +#ifdef UV2 +attribute vec2 uv2; +#endif +#ifdef MAINUV1 +varying vec2 vMainUV1; +#endif +#ifdef MAINUV2 +varying vec2 vMainUV2; +#endif +#ifdef VERTEXCOLOR +attribute vec4 color; +#endif +#include +#include + +#include +#include +#if defined(ALBEDO) && ALBEDODIRECTUV == 0 +varying vec2 vAlbedoUV; +#endif +#if defined(DETAIL) && DETAILDIRECTUV == 0 +varying vec2 vDetailUV; +#endif +#if defined(AMBIENT) && AMBIENTDIRECTUV == 0 +varying vec2 vAmbientUV; +#endif +#if defined(OPACITY) && OPACITYDIRECTUV == 0 +varying vec2 vOpacityUV; +#endif +#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0 +varying vec2 vEmissiveUV; +#endif +#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0 +varying vec2 vLightmapUV; +#endif +#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0 +varying vec2 vReflectivityUV; +#endif +#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0 +varying vec2 vMicroSurfaceSamplerUV; +#endif +#if defined(METALLIC_REFLECTANCE) && METALLIC_REFLECTANCEDIRECTUV == 0 +varying vec2 vMetallicReflectanceUV; +#endif +#if defined(BUMP) && BUMPDIRECTUV == 0 +varying vec2 vBumpUV; +#endif +#ifdef CLEARCOAT +#if defined(CLEARCOAT_TEXTURE) && CLEARCOAT_TEXTUREDIRECTUV == 0 +varying vec2 vClearCoatUV; +#endif +#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV == 0 +varying vec2 vClearCoatRoughnessUV; +#endif +#if defined(CLEARCOAT_BUMP) && CLEARCOAT_BUMPDIRECTUV == 0 +varying vec2 vClearCoatBumpUV; +#endif +#if defined(CLEARCOAT_TINT_TEXTURE) && CLEARCOAT_TINT_TEXTUREDIRECTUV == 0 +varying vec2 vClearCoatTintUV; +#endif +#endif +#ifdef SHEEN +#if defined(SHEEN_TEXTURE) && SHEEN_TEXTUREDIRECTUV == 0 +varying vec2 vSheenUV; +#endif +#if defined(SHEEN_TEXTURE_ROUGHNESS) && SHEEN_TEXTURE_ROUGHNESSDIRECTUV == 0 +varying vec2 vSheenRoughnessUV; +#endif +#endif +#ifdef ANISOTROPIC +#if defined(ANISOTROPIC_TEXTURE) && ANISOTROPIC_TEXTUREDIRECTUV == 0 +varying vec2 vAnisotropyUV; +#endif +#endif +#ifdef SUBSURFACE +#if defined(SS_THICKNESSANDMASK_TEXTURE) && SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 0 +varying vec2 vThicknessUV; +#endif +#endif + +varying vec3 vPositionW; +#if DEBUGMODE>0 +varying vec4 vClipSpacePosition; +#endif +#ifdef NORMAL +varying vec3 vNormalW; +#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX) +varying vec3 vEnvironmentIrradiance; +#include +#endif +#endif +#ifdef VERTEXCOLOR +varying vec4 vColor; +#endif +#include +#include +#include +#include<__decl__lightFragment>[0..maxSimultaneousLights] +#include +#include[0..maxSimultaneousMorphTargets] +#ifdef REFLECTIONMAP_SKYBOX +varying vec3 vPositionUVW; +#endif +#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) +varying vec3 vDirectionW; +#endif +#include +#define CUSTOM_VERTEX_DEFINITIONS +void main(void) { +#define CUSTOM_VERTEX_MAIN_BEGIN +vec3 positionUpdated=position; +#ifdef NORMAL +vec3 normalUpdated=normal; +#endif +#ifdef TANGENT +vec4 tangentUpdated=tangent; +#endif +#ifdef UV1 +vec2 uvUpdated=uv; +#endif +#include[0..maxSimultaneousMorphTargets] +#ifdef REFLECTIONMAP_SKYBOX +vPositionUVW=positionUpdated; +#endif +#define CUSTOM_VERTEX_UPDATE_POSITION +#define CUSTOM_VERTEX_UPDATE_NORMAL +#include +#if defined(PREPASS) && defined(PREPASS_VELOCITY) && !defined(BONES_VELOCITY_ENABLED) + +vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0); +vPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0); +#endif +#include +vec4 worldPos=finalWorld*vec4(positionUpdated,1.0); +vPositionW=vec3(worldPos); +#include +#ifdef NORMAL +mat3 normalWorld=mat3(finalWorld); +#if defined(INSTANCES) && defined(THIN_INSTANCES) +vNormalW=normalUpdated/vec3(dot(normalWorld[0],normalWorld[0]),dot(normalWorld[1],normalWorld[1]),dot(normalWorld[2],normalWorld[2])); +vNormalW=normalize(normalWorld*vNormalW); +#else +#ifdef NONUNIFORMSCALING +normalWorld=transposeMat3(inverseMat3(normalWorld)); +#endif +vNormalW=normalize(normalWorld*normalUpdated); +#endif +#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX) +vec3 reflectionVector=vec3(reflectionMatrix*vec4(vNormalW,0)).xyz; +#ifdef REFLECTIONMAP_OPPOSITEZ +reflectionVector.z*=-1.0; +#endif +vEnvironmentIrradiance=computeEnvironmentIrradiance(reflectionVector); +#endif +#endif +#define CUSTOM_VERTEX_UPDATE_WORLDPOS +#ifdef MULTIVIEW +if (gl_ViewID_OVR == 0u) { +gl_Position=viewProjection*worldPos; +} else { +gl_Position=viewProjectionR*worldPos; +} +#else +gl_Position=viewProjection*worldPos; +#endif +#if DEBUGMODE>0 +vClipSpacePosition=gl_Position; +#endif +#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) +vDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0))); +#endif + +#ifndef UV1 +vec2 uvUpdated=vec2(0.,0.); +#endif +#ifndef UV2 +vec2 uv2=vec2(0.,0.); +#endif +#ifdef MAINUV1 +vMainUV1=uvUpdated; +#endif +#ifdef MAINUV2 +vMainUV2=uv2; +#endif +#if defined(ALBEDO) && ALBEDODIRECTUV == 0 +if (vAlbedoInfos.x == 0.) +{ +vAlbedoUV=vec2(albedoMatrix*vec4(uvUpdated,1.0,0.0)); +} +else +{ +vAlbedoUV=vec2(albedoMatrix*vec4(uv2,1.0,0.0)); +} +#endif +#if defined(DETAIL) && DETAILDIRECTUV == 0 +if (vDetailInfos.x == 0.) +{ +vDetailUV=vec2(detailMatrix*vec4(uvUpdated,1.0,0.0)); +} +else +{ +vDetailUV=vec2(detailMatrix*vec4(uv2,1.0,0.0)); +} +#endif +#if defined(AMBIENT) && AMBIENTDIRECTUV == 0 +if (vAmbientInfos.x == 0.) +{ +vAmbientUV=vec2(ambientMatrix*vec4(uvUpdated,1.0,0.0)); +} +else +{ +vAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0)); +} +#endif +#if defined(OPACITY) && OPACITYDIRECTUV == 0 +if (vOpacityInfos.x == 0.) +{ +vOpacityUV=vec2(opacityMatrix*vec4(uvUpdated,1.0,0.0)); +} +else +{ +vOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0)); +} +#endif +#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0 +if (vEmissiveInfos.x == 0.) +{ +vEmissiveUV=vec2(emissiveMatrix*vec4(uvUpdated,1.0,0.0)); +} +else +{ +vEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0)); +} +#endif +#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0 +if (vLightmapInfos.x == 0.) +{ +vLightmapUV=vec2(lightmapMatrix*vec4(uvUpdated,1.0,0.0)); +} +else +{ +vLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0)); +} +#endif +#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0 +if (vReflectivityInfos.x == 0.) +{ +vReflectivityUV=vec2(reflectivityMatrix*vec4(uvUpdated,1.0,0.0)); +} +else +{ +vReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0)); +} +#endif +#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0 +if (vMicroSurfaceSamplerInfos.x == 0.) +{ +vMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uvUpdated,1.0,0.0)); +} +else +{ +vMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv2,1.0,0.0)); +} +#endif +#if defined(METALLIC_REFLECTANCE) && METALLIC_REFLECTANCEDIRECTUV == 0 +if (vMetallicReflectanceInfos.x == 0.) +{ +vMetallicReflectanceUV=vec2(metallicReflectanceMatrix*vec4(uvUpdated,1.0,0.0)); +} +else +{ +vMetallicReflectanceUV=vec2(metallicReflectanceMatrix*vec4(uv2,1.0,0.0)); +} +#endif +#if defined(BUMP) && BUMPDIRECTUV == 0 +if (vBumpInfos.x == 0.) +{ +vBumpUV=vec2(bumpMatrix*vec4(uvUpdated,1.0,0.0)); +} +else +{ +vBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0)); +} +#endif +#ifdef CLEARCOAT +#if defined(CLEARCOAT_TEXTURE) && CLEARCOAT_TEXTUREDIRECTUV == 0 +if (vClearCoatInfos.x == 0.) +{ +vClearCoatUV=vec2(clearCoatMatrix*vec4(uvUpdated,1.0,0.0)); +} +else +{ +vClearCoatUV=vec2(clearCoatMatrix*vec4(uv2,1.0,0.0)); +} +#endif +#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV == 0 +if (vClearCoatInfos.z == 0.) +{ +vClearCoatRoughnessUV=vec2(clearCoatRoughnessMatrix*vec4(uvUpdated,1.0,0.0)); +} +else +{ +vClearCoatRoughnessUV=vec2(clearCoatRoughnessMatrix*vec4(uv2,1.0,0.0)); +} +#endif +#if defined(CLEARCOAT_BUMP) && CLEARCOAT_BUMPDIRECTUV == 0 +if (vClearCoatBumpInfos.x == 0.) +{ +vClearCoatBumpUV=vec2(clearCoatBumpMatrix*vec4(uvUpdated,1.0,0.0)); +} +else +{ +vClearCoatBumpUV=vec2(clearCoatBumpMatrix*vec4(uv2,1.0,0.0)); +} +#endif +#if defined(CLEARCOAT_TINT_TEXTURE) && CLEARCOAT_TINT_TEXTUREDIRECTUV == 0 +if (vClearCoatTintInfos.x == 0.) +{ +vClearCoatTintUV=vec2(clearCoatTintMatrix*vec4(uvUpdated,1.0,0.0)); +} +else +{ +vClearCoatTintUV=vec2(clearCoatTintMatrix*vec4(uv2,1.0,0.0)); +} +#endif +#endif +#ifdef SHEEN +#if defined(SHEEN_TEXTURE) && SHEEN_TEXTUREDIRECTUV == 0 +if (vSheenInfos.x == 0.) +{ +vSheenUV=vec2(sheenMatrix*vec4(uvUpdated,1.0,0.0)); +} +else +{ +vSheenUV=vec2(sheenMatrix*vec4(uv2,1.0,0.0)); +} +#endif +#if defined(SHEEN_TEXTURE_ROUGHNESS) && SHEEN_TEXTURE_ROUGHNESSDIRECTUV == 0 +if (vSheenInfos.z == 0.) +{ +vSheenRoughnessUV=vec2(sheenRoughnessMatrix*vec4(uvUpdated,1.0,0.0)); +} +else +{ +vSheenRoughnessUV=vec2(sheenRoughnessMatrix*vec4(uv2,1.0,0.0)); +} +#endif +#endif +#ifdef ANISOTROPIC +#if defined(ANISOTROPIC_TEXTURE) && ANISOTROPIC_TEXTUREDIRECTUV == 0 +if (vAnisotropyInfos.x == 0.) +{ +vAnisotropyUV=vec2(anisotropyMatrix*vec4(uvUpdated,1.0,0.0)); +} +else +{ +vAnisotropyUV=vec2(anisotropyMatrix*vec4(uv2,1.0,0.0)); +} +#endif +#endif +#ifdef SUBSURFACE +#if defined(SS_THICKNESSANDMASK_TEXTURE) && SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 0 +if (vThicknessInfos.x == 0.) +{ +vThicknessUV=vec2(thicknessMatrix*vec4(uvUpdated,1.0,0.0)); +} +else +{ +vThicknessUV=vec2(thicknessMatrix*vec4(uv2,1.0,0.0)); +} +#endif +#endif + +#include + +#include + +#include + +#include[0..maxSimultaneousLights] + +#ifdef VERTEXCOLOR +vColor=color; +#endif + +#ifdef POINTSIZE +gl_PointSize=pointSize; +#endif + +#include +#define CUSTOM_VERTEX_MAIN_END +}`;ze.a.ShadersStore.pbrVertexShader=l_;var ta=f(92),xr={effect:null,subMesh:null},ws=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_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.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}(Jo.a),_n=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._alphaCutOff=.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 fi.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 Ar(i._markAllSubMeshesAsTexturesDirty.bind(i)),i.anisotropy=new Pr(i._markAllSubMeshesAsTexturesDirty.bind(i)),i.brdf=new xp(i._markAllSubMeshesAsMiscDirty.bind(i)),i.sheen=new co(i._markAllSubMeshesAsTexturesDirty.bind(i)),i.detailMap=new ta.a(i._markAllSubMeshesAsTexturesDirty.bind(i)),i._rebuildInParallel=!1,i._attachImageProcessingConfiguration(null),i.getRenderTargetTextures=function(){return i._renderTargets.reset(),ut.a.ReflectionTextureEnabled&&i._reflectionTexture&&i._reflectionTexture.isRenderTarget&&i._renderTargets.push(i._reflectionTexture),i.subSurface.fillRenderTargetTextures(i._renderTargets),i._renderTargets},i._environmentBRDFTexture=ea.GetEnvironmentBRDFTexture(n),i.subSurface=new lo(i._markAllSubMeshesAsTexturesDirty.bind(i),i._markScenePrePassDirty.bind(i),n),i.prePassConfiguration=new Ns.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.getScene().imageProcessingConfiguration,this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add(function(){n._markAllSubMeshesAsImageProcessingDirty()})))},Object.defineProperty(t.prototype,"hasRenderTargetTextures",{get:function(){return!!(ut.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 ws);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&&ut.a.DiffuseTextureEnabled&&!this._albedoTexture.isReadyOrNotBlocking()||this._ambientTexture&&ut.a.AmbientTextureEnabled&&!this._ambientTexture.isReadyOrNotBlocking()||this._opacityTexture&&ut.a.OpacityTextureEnabled&&!this._opacityTexture.isReadyOrNotBlocking())return!1;var d=this._getReflectionTexture();if(d&&ut.a.ReflectionTextureEnabled&&(!d.isReadyOrNotBlocking()||d.irradianceTexture&&!d.irradianceTexture.isReadyOrNotBlocking())||this._lightmapTexture&&ut.a.LightmapTextureEnabled&&!this._lightmapTexture.isReadyOrNotBlocking()||this._emissiveTexture&&ut.a.EmissiveTextureEnabled&&!this._emissiveTexture.isReadyOrNotBlocking())return!1;if(ut.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&&ut.a.BumpTextureEnabled&&!this._disableBumpMap&&!this._bumpTexture.isReady()||this._environmentBRDFTexture&&ut.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(Oe.b.NormalKind)||(e.createNormals(!0),l.a.Warn("PBRMaterial: Normals have been created for the mesh: "+e.name));var p=n.effect,b=o._areLightsDisposed,P=this._prepareEffect(e,o,this.onCompiled,this.onError,i,null,n.getRenderingMesh().hasThinInstances);if(P)if(this._onEffectCreatedObservable&&(xr.effect=P,xr.subMesh=n,this._onEffectCreatedObservable.notifyObservers(xr)),this.allowShaderHotSwapping&&p&&!P.isReady()){if(P=p,this._rebuildInParallel=!0,o.markAsUnprocessed(),b)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(),b=new Sr.a,P=0;n.USESPHERICALINVERTEX&&b.addFallback(P++,"USESPHERICALINVERTEX"),n.FOG&&b.addFallback(P,"FOG"),n.SPECULARAA&&b.addFallback(P,"SPECULARAA"),n.POINTSIZE&&b.addFallback(P,"POINTSIZE"),n.LOGARITHMICDEPTH&&b.addFallback(P,"LOGARITHMICDEPTH"),n.PARALLAX&&b.addFallback(P,"PARALLAX"),n.PARALLAXOCCLUSION&&b.addFallback(P++,"PARALLAXOCCLUSION"),P=Pr.AddFallbacks(n,b,P),P=Pr.AddFallbacks(n,b,P),P=lo.AddFallbacks(n,b,P),P=co.AddFallbacks(n,b,P),n.ENVIRONMENTBRDF&&b.addFallback(P++,"ENVIRONMENTBRDF"),n.TANGENT&&b.addFallback(P++,"TANGENT"),n.BUMP&&b.addFallback(P++,"BUMP"),P=et.a.HandleFallbacksForShadows(n,b,this._maxSimultaneousLights,P++),n.SPECULARTERM&&b.addFallback(P++,"SPECULARTERM"),n.USESPHERICALFROMREFLECTIONMAP&&b.addFallback(P++,"USESPHERICALFROMREFLECTIONMAP"),n.USEIRRADIANCEMAP&&b.addFallback(P++,"USEIRRADIANCEMAP"),n.LIGHTMAP&&b.addFallback(P++,"LIGHTMAP"),n.NORMAL&&b.addFallback(P++,"NORMAL"),n.AMBIENT&&b.addFallback(P++,"AMBIENT"),n.EMISSIVE&&b.addFallback(P++,"EMISSIVE"),n.VERTEXCOLOR&&b.addFallback(P++,"VERTEXCOLOR"),n.MORPHTARGETS&&b.addFallback(P++,"MORPHTARGETS"),n.MULTIVIEW&&b.addFallback(0,"MULTIVIEW");var O=[Oe.b.PositionKind];n.NORMAL&&O.push(Oe.b.NormalKind),n.TANGENT&&O.push(Oe.b.TangentKind),n.UV1&&O.push(Oe.b.UVKind),n.UV2&&O.push(Oe.b.UV2Kind),n.VERTEXCOLOR&&O.push(Oe.b.ColorKind),et.a.PrepareAttributesForBones(O,e,n,b),et.a.PrepareAttributesForInstances(O,n),et.a.PrepareAttributesForMorphTargets(O,e,n);var B="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"];ta.a.AddUniforms(F),ta.a.AddSamplers(z),lo.AddUniforms(F),lo.AddSamplers(z),Ar.AddUniforms(F),Ar.AddSamplers(z),Pr.AddUniforms(F),Pr.AddSamplers(z),co.AddUniforms(F),co.AddSamplers(z),Ns.a.AddUniforms(F),Ns.a.AddSamplers(F),yn.a&&(yn.a.PrepareUniforms(F,n),yn.a.PrepareSamplers(z,n)),et.a.PrepareUniformsAndSamplersList({uniformsNames:F,uniformBuffersNames:J,samplers:z,defines:n,maxSimultaneousLights:this._maxSimultaneousLights});var ie={};this.customShaderNameResolve&&(B=this.customShaderNameResolve(B,F,J,z,n,O,ie));var se=n.toString();return p.createEffect(B,{attributes:O,uniformsNames:F,uniformBuffersNames:J,samplers:z,defines:se,fallbacks:b,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(et.a.PrepareDefinesForLights(s,e,n,!0,this._maxSimultaneousLights,this._disableLighting),n._needNormals=!0,et.a.PrepareDefinesForMultiview(s,n),et.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&&ut.a.DiffuseTextureEnabled?(et.a.PrepareDefinesForMergedUV(this._albedoTexture,n,"ALBEDO"),n.GAMMAALBEDO=this._albedoTexture.gammaSpace):n.ALBEDO=!1,this._ambientTexture&&ut.a.AmbientTextureEnabled?(et.a.PrepareDefinesForMergedUV(this._ambientTexture,n,"AMBIENT"),n.AMBIENTINGRAYSCALE=this._useAmbientInGrayScale):n.AMBIENT=!1,this._opacityTexture&&ut.a.OpacityTextureEnabled?(et.a.PrepareDefinesForMergedUV(this._opacityTexture,n,"OPACITY"),n.OPACITYRGB=this._opacityTexture.getAlphaFromRGB):n.OPACITY=!1;var p=this._getReflectionTexture();if(p&&ut.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&&ut.a.LightmapTextureEnabled?(et.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&&ut.a.EmissiveTextureEnabled?et.a.PrepareDefinesForMergedUV(this._emissiveTexture,n,"EMISSIVE"):n.EMISSIVE=!1,ut.a.SpecularTextureEnabled?(this._metallicTexture?(et.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?(et.a.PrepareDefinesForMergedUV(this._reflectivityTexture,n,"REFLECTIVITY"),n.MICROSURFACEFROMREFLECTIVITYMAP=this._useMicroSurfaceFromReflectivityMapAlpha,n.MICROSURFACEAUTOMATIC=this._useAutoMicroSurfaceFromReflectivityMap):n.REFLECTIVITY=!1,this._metallicReflectanceTexture?et.a.PrepareDefinesForMergedUV(this._metallicReflectanceTexture,n,"METALLIC_REFLECTANCE"):n.METALLIC_REFLECTANCE=!1,this._microSurfaceTexture?et.a.PrepareDefinesForMergedUV(this._microSurfaceTexture,n,"MICROSURFACEMAP"):n.MICROSURFACEMAP=!1):(n.REFLECTIVITY=!1,n.MICROSURFACEMAP=!1),s.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&ut.a.BumpTextureEnabled&&!this._disableBumpMap?(et.a.PrepareDefinesForMergedUV(this._bumpTexture,n,"BUMP"),this._useParallax&&this._albedoTexture&&ut.a.DiffuseTextureEnabled?(n.PARALLAX=!0,n.PARALLAXOCCLUSION=!!this._useParallaxOcclusion):n.PARALLAX=!1,n.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap):n.BUMP=!1,this._environmentBRDFTexture&&ut.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.USEPHYSICALLIGHTFALLOFF=!1,n.USEGLTFLIGHTFALLOFF=!1):this._lightFalloff===t.LIGHTFALLOFF_GLTF?(n.USEPHYSICALLIGHTFALLOFF=!1,n.USEGLTFLIGHTFALLOFF=!0):(n.USEPHYSICALLIGHTFALLOFF=!0,n.USEGLTFLIGHTFALLOFF=!1),n.RADIANCEOVERALPHA=this._useRadianceOverAlpha,!this.backFaceCulling&&this._twoSidedLighting?n.TWOSIDEDLIGHTING=!0:n.TWOSIDEDLIGHTING=!1,n.SPECULARAA=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&&(et.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(Oe.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),et.a.PrepareDefinesForFrameBoundValues(s,d,n,!!i,o,a),et.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 ws,d=this._prepareEffect(e,s,void 0,void 0,a.useInstances,a.clipPlane,e.hasThinInstances);this._onEffectCreatedObservable&&(xr.effect=d,xr.subMesh=null,this._onEffectCreatedObservable.notifyObservers(xr)),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),Ar.PrepareUniformBuffer(e),Pr.PrepareUniformBuffer(e),co.PrepareUniformBuffer(e),lo.PrepareUniformBuffer(e),ta.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);et.a.BindBonesParameters(n,this._activeEffect,this.prePassConfiguration);var p=null,b=this._uniformBuffer;if(d){var P=o.getEngine();if(b.bindToEffect(s,"Material"),this.bindViewProjection(s),p=this._getReflectionTexture(),!b.useUbo||!this.isFrozen||!b.isSync){if(o.texturesEnabled){if(this._albedoTexture&&ut.a.DiffuseTextureEnabled&&(b.updateFloat2("vAlbedoInfos",this._albedoTexture.coordinatesIndex,this._albedoTexture.level),et.a.BindTextureMatrix(this._albedoTexture,b,"albedo")),this._ambientTexture&&ut.a.AmbientTextureEnabled&&(b.updateFloat4("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level,this._ambientTextureStrength,this._ambientTextureImpactOnAnalyticalLights),et.a.BindTextureMatrix(this._ambientTexture,b,"ambient")),this._opacityTexture&&ut.a.OpacityTextureEnabled&&(b.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),et.a.BindTextureMatrix(this._opacityTexture,b,"opacity")),p&&ut.a.ReflectionTextureEnabled){if(b.updateMatrix("reflectionMatrix",p.getReflectionTextureMatrix()),b.updateFloat2("vReflectionInfos",p.level,0),p.boundingBoxSize){var O=p;b.updateVector3("vReflectionPosition",O.boundingBoxPosition),b.updateVector3("vReflectionSize",O.boundingBoxSize)}if(this.realTimeFiltering){var B=p.getSize().width;b.updateFloat2("vReflectionFilteringInfo",B,$.a.Log2(B))}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)}b.updateFloat3("vReflectionMicrosurfaceInfos",p.getSize().width,p.lodGenerationScale,p.lodGenerationOffset)}this._emissiveTexture&&ut.a.EmissiveTextureEnabled&&(b.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),et.a.BindTextureMatrix(this._emissiveTexture,b,"emissive")),this._lightmapTexture&&ut.a.LightmapTextureEnabled&&(b.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),et.a.BindTextureMatrix(this._lightmapTexture,b,"lightmap")),ut.a.SpecularTextureEnabled&&(this._metallicTexture?(b.updateFloat3("vReflectivityInfos",this._metallicTexture.coordinatesIndex,this._metallicTexture.level,this._ambientTextureStrength),et.a.BindTextureMatrix(this._metallicTexture,b,"reflectivity")):this._reflectivityTexture&&(b.updateFloat3("vReflectivityInfos",this._reflectivityTexture.coordinatesIndex,this._reflectivityTexture.level,1),et.a.BindTextureMatrix(this._reflectivityTexture,b,"reflectivity")),this._metallicReflectanceTexture&&(b.updateFloat2("vMetallicReflectanceInfos",this._metallicReflectanceTexture.coordinatesIndex,this._metallicReflectanceTexture.level),et.a.BindTextureMatrix(this._metallicReflectanceTexture,b,"metallicReflectance")),this._microSurfaceTexture&&(b.updateFloat2("vMicroSurfaceSamplerInfos",this._microSurfaceTexture.coordinatesIndex,this._microSurfaceTexture.level),et.a.BindTextureMatrix(this._microSurfaceTexture,b,"microSurfaceSampler"))),this._bumpTexture&&P.getCaps().standardDerivatives&&ut.a.BumpTextureEnabled&&!this._disableBumpMap&&(b.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level,this._parallaxScaleBias),et.a.BindTextureMatrix(this._bumpTexture,b,"bump"),o._mirroredCameraPosition?b.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):b.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1))}if(this.pointsCloud&&b.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,b.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;b.updateColor4("vMetallicReflectanceFactors",M.c.Color3[0],se)}else b.updateColor4("vReflectivityColor",this._reflectivityColor,this._microSurface);b.updateColor3("vEmissiveColor",ut.a.EmissiveTextureEnabled?this._emissiveColor:M.a.BlackReadOnly),b.updateColor3("vReflectionColor",this._reflectionColor),!a.SS_REFRACTION&&this.subSurface.linkRefractionWithTransparency?b.updateColor4("vAlbedoColor",this._albedoColor,1):b.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,b.updateVector4("vLightingIntensity",this._lightingInfos)}b.updateFloat("visibility",n.visibility),o.texturesEnabled&&(this._albedoTexture&&ut.a.DiffuseTextureEnabled&&b.setTexture("albedoSampler",this._albedoTexture),this._ambientTexture&&ut.a.AmbientTextureEnabled&&b.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&ut.a.OpacityTextureEnabled&&b.setTexture("opacitySampler",this._opacityTexture),p&&ut.a.ReflectionTextureEnabled&&(a.LODBASEDMICROSFURACE?b.setTexture("reflectionSampler",p):(b.setTexture("reflectionSampler",p._lodTextureMid||p),b.setTexture("reflectionSamplerLow",p._lodTextureLow||p),b.setTexture("reflectionSamplerHigh",p._lodTextureHigh||p)),a.USEIRRADIANCEMAP&&b.setTexture("irradianceSampler",p.irradianceTexture)),a.ENVIRONMENTBRDF&&b.setTexture("environmentBrdfSampler",this._environmentBRDFTexture),this._emissiveTexture&&ut.a.EmissiveTextureEnabled&&b.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&ut.a.LightmapTextureEnabled&&b.setTexture("lightmapSampler",this._lightmapTexture),ut.a.SpecularTextureEnabled&&(this._metallicTexture?b.setTexture("reflectivitySampler",this._metallicTexture):this._reflectivityTexture&&b.setTexture("reflectivitySampler",this._reflectivityTexture),this._metallicReflectanceTexture&&b.setTexture("metallicReflectanceSampler",this._metallicReflectanceTexture),this._microSurfaceTexture&&b.setTexture("microSurfaceSampler",this._microSurfaceTexture)),this._bumpTexture&&P.getCaps().standardDerivatives&&ut.a.BumpTextureEnabled&&!this._disableBumpMap&&b.setTexture("bumpSampler",this._bumpTexture)),this.detailMap.bindForSubMesh(b,o,this.isFrozen),this.subSurface.bindForSubMesh(b,o,P,this.isFrozen,a.LODBASEDMICROSFURACE,this.realTimeFiltering),this.clearCoat.bindForSubMesh(b,o,P,this._disableBumpMap,this.isFrozen,this._invertNormalMapX,this._invertNormalMapY,i),this.anisotropy.bindForSubMesh(b,o,this.isFrozen),this.sheen.bindForSubMesh(b,o,this.isFrozen,i),et.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&&et.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),et.a.BindFogParameters(o,n,this._activeEffect,!0),a.NUM_MORPH_INFLUENCERS&&et.a.BindMorphTargetParameters(n,this._activeEffect),this._imageProcessingConfiguration.bind(this._activeEffect),et.a.BindLogDepth(a,this._activeEffect,o)),b.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,b,P,O,B,F;n&&(this._environmentBRDFTexture&&this.getScene().environmentBRDFTexture!==this._environmentBRDFTexture&&this._environmentBRDFTexture.dispose(),(i=this._albedoTexture)===null||i===void 0||i.dispose(),(o=this._ambientTexture)===null||o===void 0||o.dispose(),(a=this._opacityTexture)===null||a===void 0||a.dispose(),(s=this._reflectionTexture)===null||s===void 0||s.dispose(),(d=this._emissiveTexture)===null||d===void 0||d.dispose(),(p=this._metallicTexture)===null||p===void 0||p.dispose(),(b=this._reflectivityTexture)===null||b===void 0||b.dispose(),(P=this._bumpTexture)===null||P===void 0||P.dispose(),(O=this._lightmapTexture)===null||O===void 0||O.dispose(),(B=this._metallicReflectanceTexture)===null||B===void 0||B.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}($o.a),uo=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=ea.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)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"usePhysicalLightFalloff",{get:function(){return this._lightFalloff===_n.LIGHTFALLOFF_PHYSICAL},set:function(e){e!==this.usePhysicalLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),this._lightFalloff=e?_n.LIGHTFALLOFF_PHYSICAL:_n.LIGHTFALLOFF_STANDARD)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useGLTFLightFalloff",{get:function(){return this._lightFalloff===_n.LIGHTFALLOFF_GLTF},set:function(e){e!==this.useGLTFLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),this._lightFalloff=e?_n.LIGHTFALLOFF_GLTF:_n.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=_n.PBRMATERIAL_OPAQUE,t.PBRMATERIAL_ALPHATEST=_n.PBRMATERIAL_ALPHATEST,t.PBRMATERIAL_ALPHABLEND=_n.PBRMATERIAL_ALPHABLEND,t.PBRMATERIAL_ALPHATESTANDBLEND=_n.PBRMATERIAL_ALPHATESTANDBLEND,t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=_n.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)(),Object(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)(),Object(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}(_n);R.a.RegisteredTypes["BABYLON.PBRMaterial"]=uo;function na(r){return r.charCodeAt(0)+(r.charCodeAt(1)<<8)+(r.charCodeAt(2)<<16)+(r.charCodeAt(3)<<24)}var _u=na("DXT1"),mu=na("DXT3"),gu=na("DXT5"),Fs=na("DX10"),Gi=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===Fs?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 Fs: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===_u||o===mu||o===gu,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,b=0;b>8)},r._GetRGBArrayBuffer=function(t,e,n,i,o,a,s,d){for(var p=new Uint8Array(i),b=new Uint8Array(o,n),P=0,O=0;O>8&255,Te>>16&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]);Re&&(ue=t._getRGBABufferInternalSizedFormat(i.textureType)),z=1,131072&se[2]&&o!==!1&&(z=Math.max(1,se[7]));for(var Ne=d||0;Ne0?i.sphericalPolynomial=jo.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(b){if(b){var P=b.texture;if(d?b.info.sphericalPolynomial&&(P._sphericalPolynomial=b.info.sphericalPolynomial):P._sphericalPolynomial=new ro,P._source=Ct.b.CubePrefiltered,p.getCaps().textureLOD)i&&i(P);else{var O=p._gl,B=b.width;if(B){for(var F=[],z=0;z<3;z++){var J=1-z/2,ie=n,se=$.a.Log2(B)*e+n,ce=ie+(se-ie)*J,ue=Math.round(Math.min(Math.max(ce,0),se)),fe=new Ct.a(p,Ct.b.Temp);if(fe.type=P.type,fe.format=P.format,fe.width=Math.pow(2,Math.max($.a.Log2(B)-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),b.isDDS){var ve=b.info,Te=b.data;p._unpackFlipY(ve.isCompressed),Gi.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 Re=new zn.a(t);Re.isCube=!0,Re._texture=fe,fe.isReady=!0,F.push(Re)}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 vu=function(){function r(){this.supportCascades=!0}return r.prototype.canLoad=function(t){return qn.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;p1)&&e.generateMipMaps,s._unpackFlipY(a.isCompressed),Gi.UploadDDSLevels(s,e,b,a,d,6,-1,p),a.isFourCC||a.mipmapCount!==1||s.generateMipMapsForCubemap(e)}else{var P=t;a=Gi.GetDDSInfo(P),e.width=a.width,e.height=a.height,n&&(a.sphericalPolynomial=new ro),d=(a.isRGB||a.isLuminance||a.mipmapCount>1)&&e.generateMipMaps,s._unpackFlipY(a.isCompressed),Gi.UploadDDSLevels(s,e,P,a,d,6),a.isFourCC||a.mipmapCount!==1||s.generateMipMapsForCubemap(e,!1)}s._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=Gi.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(){Gi.UploadDDSLevels(e.getEngine(),e,t,i,o,1)})},r}();Ue.a._TextureLoaders.push(new vu);var bu=function(){function r(){this.supportCascades=!1}return r.prototype.canLoad=function(t){return qn.a.EndsWith(t,".env")},r.prototype.loadCubeData=function(t,e,n,i,o){if(!Array.isArray(t)){var a=Ai.GetEnvInfo(t);a?(e.width=a.width,e.height=a.width,Ai.UploadEnvSpherical(e,a),Ai.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 bu);var ia=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}},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=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}(),Bs=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;t1,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]===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 u_(){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;o1&&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(ia.IsValid(t)){e._invertVScale=!e.invertY;var o=new ia(t,1);n(o.pixelWidth,o.pixelHeight,e.generateMipMaps,!0,function(){o.uploadLevels(e,e.generateMipMaps)},o.isInvalid)}else Us.IsValid(t)?new Us(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 yu);var Tu=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=tr.NOT_TRACKING,o.onBeforeCameraTeleport=new C.c,o.onAfterCameraTeleport=new C.c,o.onTrackingStateChanged=new C.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 Qn.a(0,0,.5,1),this.rigCameras[0].outputRenderTarget=null,this.rigCameras[1].viewport=new Qn.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?tr.TRACKING_LOST:tr.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 b=s.transform.position,P=s.transform.orientation;if(p.position.set(b.x,b.y,b.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),B=e._xrSessionManager.session.renderState.baseLayer.framebufferWidth,F=e._xrSessionManager.session.renderState.baseLayer.framebufferHeight;p.viewport.width=O.width/B,p.viewport.height=O.height/F,p.viewport.x=O.x/B,p.viewport.y=O.y/F}p.outputRenderTarget=e._xrSessionManager.getRenderTargetTextureForEye(s.eye)})}else this._setTrackingState(tr.NOT_TRACKING)},t.prototype._updateNumberOfRigCameras=function(e){for(e===void 0&&(e=1);this.rigCameras.lengthe;){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}(Kn),si=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}(),Zn=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;this.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],b=r.ConstructFeature(s,d,this._xrSessionManager,n);if(!b)throw new Error("feature not found - "+s);p&&this.disableFeature(s);var P=b();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 Xe.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}(),Eu=function(){function r(t){var e=this;this.scene=t,this._nonVRCamera=null,this._originalSceneAutoClear=!0,this._supported=!1,this.onInitialXRPoseSetObservable=new C.c,this.onStateChangedObservable=new C.c,this.state=pn.NOT_IN_XR,this.sessionManager=new _s(t),this.camera=new Tu("",t,this.sessionManager),this.featuresManager=new Zn(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(pn.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(pn.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(pn.NOT_IN_XR)}),o.sessionManager.onXRFrameObservable.addOnce(function(){o._setState(pn.IN_XR)}),o.sessionManager}).catch(function(a){throw console.log(a),console.log(a.message),o._setState(pn.NOT_IN_XR),a})},r.prototype.exitXRAsync=function(){return this.state!==pn.IN_XR?Promise.resolve():(this._setState(pn.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 C.c,this.onButtonStateChangedObservable=new C.c}return Object.defineProperty(r.prototype,"axes",{get:function(){return this._axes},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"changes",{get:function(){return this._changes},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"hasChanges",{get:function(){return this._hasChanges},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"pressed",{get:function(){return this._pressed},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"touched",{get:function(){return this._touched},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"value",{get:function(){return this._currentValue},enumerable:!1,configurable:!0}),r.prototype.dispose=function(){this.onAxisValueChangedObservable.clear(),this.onButtonStateChangedObservable.clear()},r.prototype.isAxes=function(){return this._axesIndices.length!==0},r.prototype.isButton=function(){return this._buttonIndex!==-1},r.prototype.update=function(t){var e=!1,n=!1;if(this._hasChanges=!1,this._changes={},this.isButton()){var i=t.buttons[this._buttonIndex];if(!i)return;this._currentValue!==i.value&&(this.changes.value={current:i.value,previous:this._currentValue},e=!0,this._currentValue=i.value),this._touched!==i.touched&&(this.changes.touched={current:i.touched,previous:this._touched},e=!0,this._touched=i.touched),this._pressed!==i.pressed&&(this.changes.pressed={current:i.pressed,previous:this._pressed},e=!0,this._pressed=i.pressed)}this.isAxes()&&(this._axes.x!==t.axes[this._axesIndices[0]]&&(this.changes.axes={current:{x:t.axes[this._axesIndices[0]],y:this._axes.y},previous:{x:this._axes.x,y:this._axes.y}},this._axes.x=t.axes[this._axesIndices[0]],n=!0),this._axes.y!==t.axes[this._axesIndices[1]]&&(this.changes.axes?this.changes.axes.current.y=t.axes[this._axesIndices[1]]:this.changes.axes={current:{x:this._axes.x,y:t.axes[this._axesIndices[1]]},previous:{x:this._axes.x,y:this._axes.y}},this._axes.y=t.axes[this._axesIndices[1]],n=!0)),e&&(this._hasChanges=!0,this.onButtonStateChangedObservable.notifyObservers(this)),n&&(this._hasChanges=!0,this.onAxisValueChangedObservable.notifyObservers(this._axes))},r.BUTTON_TYPE="button",r.SQUEEZE_TYPE="squeeze",r.THUMBSTICK_TYPE="thumbstick",r.TOUCHPAD_TYPE="touchpad",r.TRIGGER_TYPE="trigger",r}(),Rr=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,b=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,b,P)}},this._modelReady=!1,this.components={},this.disableAnimation=!1,this.onModelLoadedObservable=new C.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;this.getComponentIds().forEach(function(n){return e.getComponent(n).update(e.gamepadObject)}),this.updateModel(t)},Object.defineProperty(r.prototype,"handness",{get:function(){return this.handedness},enumerable:!1,configurable:!0}),r.prototype.pulse=function(t,e,n){return n===void 0&&(n=0),this.gamepadObject.hapticActuators&&this.gamepadObject.hapticActuators[n]?this.gamepadObject.hapticActuators[n].pulse(t,e):Promise.resolve(!1)},r.prototype._getChildByName=function(t,e){return t.getChildren(function(n){return n.name===e},!1)[0]},r.prototype._getImmediateChildByName=function(t,e){return t.getChildren(function(n){return n.name==e},!0)[0]},r.prototype._lerpTransform=function(t,e,n){if(t.minMesh&&t.maxMesh&&t.valueMesh&&t.minMesh.rotationQuaternion&&t.maxMesh.rotationQuaternion&&t.valueMesh.rotationQuaternion){var i=n?.5*e+.5:e;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}(),Vs=function(r){function t(e,n,i){var o=r.call(this,e,h_[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}(Rr),h_={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"}},Su=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=Fn.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;io/10&&(d.isVisible=!0),(p+=n._scene.getEngine().getDeltaTime())>=o)n._scene.simulatePointerDown(i.pick,{pointerId:i.id}),b=!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 b=!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&&b&&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 b=p.changes.pressed.current;i.pick?(n._options.enablePointerSelectionOnAllControllers||e.uniqueId===n._attachedController)&&(b?(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)):!b||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.laserPointerPickedColor)},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))o},t.prototype._updatePointerDistance=function(e,n){n===void 0&&(n=100),e.scaling.y=n,this._scene.useRightHandedSystem&&(n*=-1),e.position.z=n/2+.05},Object.defineProperty(t.prototype,"lasterPointerDefaultColor",{get:function(){return this.laserPointerDefaultColor},enumerable:!1,configurable:!0}),t._idCounter=200,t.Name=si.POINTER_SELECTION,t.Version=1,t}(ci);Zn.AddWebXRFeature(ho.Name,function(r,t){return function(){return new ho(r,t)}},ho.Version,!0);var zi,xu=function(){function r(t,e,n){this.element=t,this.sessionMode=e,this.referenceSpaceType=n}return r.prototype.update=function(t){},r}(),f_=function(){},Cu=function(){function r(t,e){var n=this;if(this.scene=t,this.options=e,this._activeButton=null,this._buttons=[],this.activeButtonChangedObservable=new C.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:"&&Xe.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 xu(d,i,o)),this._buttons[this._buttons.length-1].update=function(b){this.element.style.display=b===null||b===this?"":"none",d.className="babylonVRicon"+(b===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==pn.NOT_IN_XR&&o._updateButtons(null)}),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 b,P,O;return Object(c.e)(this,function(B){switch(B.label){case 0:return e.state!=pn.IN_XR?[3,2]:[4,e.exitXRAsync()];case 1:return B.sent(),o._updateButtons(null),[3,6];case 2:if(e.state!=pn.NOT_IN_XR)return[3,6];if(!n.renderTarget)return[3,6];B.label=3;case 3:return B.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 B.sent(),o._updateButtons(o._buttons[p]),[3,6];case 5:return b=B.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(b),[3,6];case 6:return[2]}})})}):Xe.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 ks(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"})(zi||(zi={}));var p_=function(){function r(t){var e,n,i=this;this.onEachCountObservable=new C.c,this.onTimerAbortedObservable=new C.c,this.onTimerEndedObservable=new C.c,this.onStateChangedObservable=new C.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(zi.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===zi.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(zi.STARTED)},r.prototype.stop=function(){this._state===zi.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(zi.ENDED),e?this.onTimerAbortedObservable.notifyObservers(t):this.onTimerEndedObservable.notifyObservers(t)},r}(),fo=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 fn.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(!(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,ks({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(b){if(b.y<=.7&&a.teleportationState.backwards&&(a.teleportationState.backwards=!1),b.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(B){return i._floorMeshes.indexOf(B)!==-1});P&&P.pickedPoint&&(i._options.xrInput.xrCamera.position.x=P.pickedPoint.x,i._options.xrInput.xrCamera.position.z=P.pickedPoint.z)}if(b.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),b.x){if(a.teleportationState.forward)i._currentTeleportationControllerId===a.xrController.uniqueId&&(i.rotationEnabled?setTimeout(function(){a.teleportationState.currentRotation=Math.atan2(b.x,b.y*(i._xrSessionManager.scene.useRightHandedSystem?1:-1))}):a.teleportationState.currentRotation=0);else if(!a.teleportationState.rotating&&Math.abs(b.x)>.7){a.teleportationState.rotating=!0;var O=i.rotationAngle*(b.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;b.x===0&&b.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,ks({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)}},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=p.video.HAVE_CURRENT_DATA;return!d.poster||d.autoPlay&&b?b&&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 C.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 Xe.b.SetCorsBehavior(e.currentSrc,e),e;var n=document.createElement("video");return typeof e=="string"?(Xe.b.SetCorsBehavior(e,n),n.src=e):(Xe.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 Ou((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=ki.MODE_MONOSCOPIC,t.MODE_TOPBOTTOM=ki.MODE_TOPBOTTOM,t.MODE_SIDEBYSIDE=ki.MODE_SIDEBYSIDE,t}(ki),jn=f(55),v_=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},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}(),b_=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&&(Xe.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&&(Xe.b.EndPerformanceCounter("Scene rendering"),e._frameTime.endMonitoring()),e._captureRenderTime&&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(){Xe.b.StartPerformanceCounter("Active meshes evaluation"),e._activeMeshesEvaluationTime.beginMonitoring()}),this._onAfterActiveMeshesEvaluationObserver=this.scene.onAfterActiveMeshesEvaluationObservable.add(function(){Xe.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(){Xe.b.StartPerformanceCounter("Render targets rendering"),e._renderTargetsRenderTime.beginMonitoring()}),this._onAfterRenderTargetsRenderObserver=this.scene.onAfterRenderTargetsRenderObservable.add(function(){Xe.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(){Xe.b.StartPerformanceCounter("Particles"),e._particlesRenderTime.beginMonitoring()}),this._onAfterParticlesRenderingObserver=this.scene.onAfterParticlesRenderingObservable.add(function(){Xe.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(){Xe.b.StartPerformanceCounter("Sprites"),e._spritesRenderTime.beginMonitoring()}),this._onAfterSpritesRenderingObserver=this.scene.onAfterSpritesRenderingObservable.add(function(){Xe.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)))},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(){Xe.b.StartPerformanceCounter("Physics"),e._physicsTime.beginMonitoring()}),this._onAfterPhysicsObserver=this.scene.onAfterPhysicsObservable.add(function(){Xe.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(),Xe.b.StartPerformanceCounter("Main render")}),this._onAfterDrawPhaseObserver=this.scene.onAfterDrawPhaseObservable.add(function(){e._renderTime.endMonitoring(!1),Xe.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(),Xe.b.StartPerformanceCounter("Rendering camera "+n.name)}),this._onAfterCameraRenderObserver=this.scene.onAfterCameraRenderObservable.add(function(n){e._cameraRenderTime.endMonitoring(!1),Xe.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},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}(),y_=`#ifdef DIFFUSE +varying vec2 vUVDiffuse; +uniform sampler2D diffuseSampler; +#endif +#ifdef OPACITY +varying vec2 vUVOpacity; +uniform sampler2D opacitySampler; +uniform float opacityIntensity; +#endif +#ifdef EMISSIVE +varying vec2 vUVEmissive; +uniform sampler2D emissiveSampler; +#endif +#ifdef VERTEXALPHA +varying vec4 vColor; +#endif +uniform vec4 glowColor; +void main(void) +{ +vec4 finalColor=glowColor; + +#ifdef DIFFUSE +vec4 albedoTexture=texture2D(diffuseSampler,vUVDiffuse); +#ifdef GLOW + +finalColor.a*=albedoTexture.a; +#endif +#ifdef HIGHLIGHT + +finalColor.a=albedoTexture.a; +#endif +#endif +#ifdef OPACITY +vec4 opacityMap=texture2D(opacitySampler,vUVOpacity); +#ifdef OPACITYRGB +finalColor.a*=getLuminance(opacityMap.rgb); +#else +finalColor.a*=opacityMap.a; +#endif +finalColor.a*=opacityIntensity; +#endif +#ifdef VERTEXALPHA +finalColor.a*=vColor.a; +#endif +#ifdef ALPHATEST +if (finalColor.a +#include +#include[0..maxSimultaneousMorphTargets] + +#include +uniform mat4 viewProjection; +varying vec4 vPosition; +#ifdef UV1 +attribute vec2 uv; +#endif +#ifdef UV2 +attribute vec2 uv2; +#endif +#ifdef DIFFUSE +varying vec2 vUVDiffuse; +uniform mat4 diffuseMatrix; +#endif +#ifdef OPACITY +varying vec2 vUVOpacity; +uniform mat4 opacityMatrix; +#endif +#ifdef EMISSIVE +varying vec2 vUVEmissive; +uniform mat4 emissiveMatrix; +#endif +#ifdef VERTEXALPHA +attribute vec4 color; +varying vec4 vColor; +#endif +void main(void) +{ +vec3 positionUpdated=position; +#ifdef UV1 +vec2 uvUpdated=uv; +#endif +#include[0..maxSimultaneousMorphTargets] +#include +#include +#ifdef CUBEMAP +vPosition=finalWorld*vec4(positionUpdated,1.0); +gl_Position=viewProjection*finalWorld*vec4(position,1.0); +#else +vPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0); +gl_Position=vPosition; +#endif +#ifdef DIFFUSE +#ifdef DIFFUSEUV1 +vUVDiffuse=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0)); +#endif +#ifdef DIFFUSEUV2 +vUVDiffuse=vec2(diffuseMatrix*vec4(uv2,1.0,0.0)); +#endif +#endif +#ifdef OPACITY +#ifdef OPACITYUV1 +vUVOpacity=vec2(opacityMatrix*vec4(uvUpdated,1.0,0.0)); +#endif +#ifdef OPACITYUV2 +vUVOpacity=vec2(opacityMatrix*vec4(uv2,1.0,0.0)); +#endif +#endif +#ifdef EMISSIVE +#ifdef EMISSIVEUV1 +vUVEmissive=vec2(emissiveMatrix*vec4(uvUpdated,1.0,0.0)); +#endif +#ifdef EMISSIVEUV2 +vUVEmissive=vec2(emissiveMatrix*vec4(uv2,1.0,0.0)); +#endif +#endif +#ifdef VERTEXALPHA +vColor=color; +#endif +}`;ze.a.ShadersStore.glowMapGenerationVertexShader=T_;var po=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 C.c,this.onBeforeRenderMainTextureObservable=new C.c,this.onBeforeComposeObservable=new C.c,this.onBeforeRenderMeshToEffect=new C.c,this.onAfterRenderMeshToEffect=new C.c,this.onAfterComposeObservable=new C.c,this.onSizeChangedObservable=new C.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 Oe.b(this._engine,t,Oe.b.PositionKind,!1,!1,2);this._vertexBuffers[Oe.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;s4&&(a.push(Oe.b.MatricesIndicesExtraKind),a.push(Oe.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),et.a.PrepareAttributesForMorphTargetsInfluencers(a,s,ie)),e&&(o.push("#define INSTANCES"),et.a.PushAttributesForInstances(a),t.getRenderingMesh().hasThinInstances&&o.push("#define THIN_INSTANCES")),this._addCustomEffectDefines(o);var se=o.join(` +`);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-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 Xe.b.Instantiate(t.customType).Parse(t,e,n)},r._SceneComponentInitialization=function(t){throw An.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}();U.a.AddParser(at.a.NAME_EFFECTLAYER,function(r,t,e,n){if(r.effectLayers){e.effectLayers||(e.effectLayers=new Array);for(var i=0;i0){this._previousStencilState=this._engine.getStencilBuffer();for(var i=0,o=n;i-1)){this._renderEffects=!0,this._needStencil=this._needStencil||a.needStencil();var s=a._mainTexture;s._shouldRender()&&(this.scene.incrementRenderId(),s.render(!1,!1),e=!0)}}this.scene.incrementRenderId()}return e},r.prototype._setStencil=function(){this._needStencil&&this._engine.setStencilBuffer(!0)},r.prototype._setStencilBack=function(){this._needStencil&&this._engine.setStencilBuffer(this._previousStencilState)},r.prototype._draw=function(t){if(this._renderEffects){this._engine.setDepthBuffer(!1);for(var e=this.scene.effectLayers,n=0;n-1},t.prototype.referenceMeshToUseItsOwnMaterial=function(e){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;e0&&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;t.layers&&t.layers.forEach(function(n){e.scene.layers.push(n)})},r.prototype.removeFromContainer=function(t,e){var n=this;e===void 0&&(e=!1),t.layers&&t.layers.forEach(function(i){var o=n.scene.layers.indexOf(i);o!==-1&&n.scene.layers.splice(o,1),e&&i.dispose()})},r}(),P_=` +varying vec2 vUV; +uniform sampler2D textureSampler; + +uniform vec4 color; + +#include +void main(void) { +vec4 baseColor=texture2D(textureSampler,vUV); +#ifdef LINEAR +baseColor.rgb=toGammaSpace(baseColor.rgb); +#endif +#ifdef ALPHATEST +if (baseColor.a<0.4) +discard; +#endif +gl_FragColor=baseColor*color; +}`;ze.a.ShadersStore.layerPixelShader=P_;var x_=` +attribute vec2 position; + +uniform vec2 scale; +uniform vec2 offset; +uniform mat4 textureMatrix; + +varying vec2 vUV; +const vec2 madd=vec2(0.5,0.5); +void main(void) { +vec2 shiftedPosition=position*scale+offset; +vUV=vec2(textureMatrix*vec4(shiftedPosition*madd+madd,1.0,0.0)); +gl_Position=vec4(shiftedPosition,0.0,1.0); +}`;ze.a.ShadersStore.layerVertexShader=x_;var C_=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 C.c,this.onBeforeRenderObservable=new C.c,this.onAfterRenderObservable=new C.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(at.a.NAME_LAYER);a||(a=new Du(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 Oe.b(s,d,Oe.b.PositionKind,!1,!1,2);this._vertexBuffers[Oe.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[Oe.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 +#define LINEAR`),this._previousDefines!==e&&(this._previousDefines=e,this._effect=t.createEffect("layer",[Oe.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[Oe.b.PositionKind];t&&(t.dispose(),this._vertexBuffers[Oe.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}(),Lu=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}(),R_=` +varying vec2 vUV; +uniform sampler2D textureSampler; + +uniform vec4 color; +void main(void) { +vec4 baseColor=texture2D(textureSampler,vUV); +gl_FragColor=baseColor*color; +}`;ze.a.ShadersStore.lensFlarePixelShader=R_;var O_=` +attribute vec2 position; + +uniform mat4 viewportMatrix; + +varying vec2 vUV; +const vec2 madd=vec2(0.5,0.5); +void main(void) { +vUV=position*madd+madd; +gl_Position=viewportMatrix*vec4(position,0.0,1.0); +}`;ze.a.ShadersStore.lensFlareVertexShader=O_;var zs=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[Oe.b.PositionKind]=new Oe.b(i,o,Oe.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.createEffect("lensFlare",[Oe.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._positionXt.y&&(this._positionY,t.y,t.height),!0)},r.prototype._isVisible=function(){if(!this._isEnabled||!this._scene.activeCamera)return!1;var t=this.getEmitterPosition().subtract(this._scene.activeCamera.globalPosition),e=t.length();t.normalize();var n=new fn.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._positionXi.x+i.width-this.borderLimit?this._positionX-i.x-i.width+this.borderLimit:0)>(e=this._positionYi.y+i.height-this.borderLimit?this._positionY-i.y-i.height+this.borderLimit:0)?t:e;(o-=this.viewportBorder)>this.borderLimit&&(o=this.borderLimit);var a=1-$.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,b=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;P0);for(var n=0,i=e;n0)}},r}();zs._SceneComponentInitialization=function(r){var t=r._getComponent(at.a.NAME_LENSFLARESYSTEM);t||(t=new Nu(r),r._addComponent(t))};var M_=` + + + + +float bayerDither2(vec2 _P) { +return mod(2.0*_P.y+_P.x+1.0,4.0); +} + + +float bayerDither4(vec2 _P) { +vec2 P1=mod(_P,2.0); +vec2 P2=floor(0.5*mod(_P,4.0)); +return 4.0*bayerDither2(P1)+bayerDither2(P2); +} + +float bayerDither8(vec2 _P) { +vec2 P1=mod(_P,2.0); +vec2 P2=floor(0.5*mod(_P,4.0)); +vec2 P4=floor(0.25*mod(_P,8.0)); +return 4.0*(4.0*bayerDither2(P1)+bayerDither2(P2))+bayerDither2(P4); +} +`;ze.a.IncludesShadersStore.bayerDitherFunctions=M_;var I_=`#if SM_FLOAT == 0 +#include +#endif +#if SM_SOFTTRANSPARENTSHADOW == 1 +#include +uniform float softTransparentShadowSM; +#endif +varying float vDepthMetricSM; +#if SM_USEDISTANCE == 1 +uniform vec3 lightDataSM; +varying vec3 vPositionWSM; +#endif +uniform vec3 biasAndScaleSM; +uniform vec2 depthValuesSM; +#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1 +varying float zSM; +#endif +`;ze.a.IncludesShadersStore.shadowMapFragmentDeclaration=I_;var D_=` float depthSM=vDepthMetricSM; +#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1 +#if SM_USEDISTANCE == 1 +depthSM=clamp(((length(vPositionWSM-lightDataSM)+depthValuesSM.x)/(depthValuesSM.y))+biasAndScaleSM.x,0.0,1.0); +#else +depthSM=clamp(((zSM+depthValuesSM.x)/(depthValuesSM.y))+biasAndScaleSM.x,0.0,1.0); +#endif +gl_FragDepth=depthSM; +#elif SM_USEDISTANCE == 1 +depthSM=(length(vPositionWSM-lightDataSM)+depthValuesSM.x)/(depthValuesSM.y)+biasAndScaleSM.x; +#endif +#if SM_ESM == 1 +depthSM=clamp(exp(-min(87.,biasAndScaleSM.z*depthSM)),0.,1.); +#endif +#if SM_FLOAT == 1 +gl_FragColor=vec4(depthSM,1.0,1.0,1.0); +#else +gl_FragColor=pack(depthSM); +#endif +return;`;ze.a.IncludesShadersStore.shadowMapFragment=D_;var L_=`#include +#ifdef ALPHATEST +varying vec2 vUV; +uniform sampler2D diffuseSampler; +#endif +#include +void main(void) +{ +#include +#ifdef ALPHATEST +float alphaFromAlphaTexture=texture2D(diffuseSampler,vUV).a; +if (alphaFromAlphaTexture<0.4) +discard; +#endif +#if SM_SOFTTRANSPARENTSHADOW == 1 +#ifdef ALPHATEST +if ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM*alphaFromAlphaTexture) discard; +#else +if ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM) discard; +#endif +#endif +#include +}`;ze.a.ShadersStore.shadowMapPixelShader=L_;var N_=`#if SM_NORMALBIAS == 1 +uniform vec3 lightDataSM; +#endif +uniform vec3 biasAndScaleSM; +uniform vec2 depthValuesSM; +varying float vDepthMetricSM; +#if SM_USEDISTANCE == 1 +varying vec3 vPositionWSM; +#endif +#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1 +varying float zSM; +#endif +`;ze.a.IncludesShadersStore.shadowMapVertexDeclaration=N_;var w_=` +#if SM_NORMALBIAS == 1 +#if SM_DIRECTIONINLIGHTDATA == 1 +vec3 worldLightDirSM=normalize(-lightDataSM.xyz); +#else +vec3 directionToLightSM=lightDataSM.xyz-worldPos.xyz; +vec3 worldLightDirSM=normalize(directionToLightSM); +#endif +float ndlSM=dot(vNormalW,worldLightDirSM); +float sinNLSM=sqrt(1.0-ndlSM*ndlSM); +float normalBiasSM=biasAndScaleSM.y*sinNLSM; +worldPos.xyz-=vNormalW*normalBiasSM; +#endif +`;ze.a.IncludesShadersStore.shadowMapVertexNormalBias=w_;var F_=`#if SM_USEDISTANCE == 1 +vPositionWSM=worldPos.xyz; +#endif +#if SM_DEPTHTEXTURE == 1 + +gl_Position.z+=biasAndScaleSM.x*gl_Position.w; +#endif +#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1 +zSM=gl_Position.z; +gl_Position.z=0.0; +#elif SM_USEDISTANCE == 0 + +vDepthMetricSM=((gl_Position.z+depthValuesSM.x)/(depthValuesSM.y))+biasAndScaleSM.x; +#endif +`;ze.a.IncludesShadersStore.shadowMapVertexMetric=F_;var B_=` +attribute vec3 position; +#ifdef NORMAL +attribute vec3 normal; +#endif +#include +#include +#include[0..maxSimultaneousMorphTargets] + +#include +#include +uniform mat4 viewProjection; +#ifdef ALPHATEST +varying vec2 vUV; +uniform mat4 diffuseMatrix; +#ifdef UV1 +attribute vec2 uv; +#endif +#ifdef UV2 +attribute vec2 uv2; +#endif +#endif +#include +#include +void main(void) +{ +vec3 positionUpdated=position; +#ifdef UV1 +vec2 uvUpdated=uv; +#endif +#ifdef NORMAL +vec3 normalUpdated=normal; +#endif +#include[0..maxSimultaneousMorphTargets] +#include +#include +vec4 worldPos=finalWorld*vec4(positionUpdated,1.0); +#ifdef NORMAL +mat3 normWorldSM=mat3(finalWorld); +#if defined(INSTANCES) && defined(THIN_INSTANCES) +vec3 vNormalW=normalUpdated/vec3(dot(normWorldSM[0],normWorldSM[0]),dot(normWorldSM[1],normWorldSM[1]),dot(normWorldSM[2],normWorldSM[2])); +vNormalW=normalize(normWorldSM*vNormalW); +#else +#ifdef NONUNIFORMSCALING +normWorldSM=transposeMat3(inverseMat3(normWorldSM)); +#endif +vec3 vNormalW=normalize(normWorldSM*normalUpdated); +#endif +#endif +#include + +gl_Position=viewProjection*worldPos; +#include +#ifdef ALPHATEST +#ifdef UV1 +vUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0)); +#endif +#ifdef UV2 +vUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0)); +#endif +#endif +#include +}`;ze.a.ShadersStore.shadowMapVertexShader=B_;var U_=` +varying vec2 vUV; +uniform sampler2D textureSampler; + +uniform vec2 screenSize; +void main(void) +{ +vec4 colorDepth=vec4(0.0); +for (int x=-OFFSET; x<=OFFSET; x++) +for (int y=-OFFSET; y<=OFFSET; y++) +colorDepth+=texture2D(textureSampler,vUV+vec2(x,y)/screenSize); +gl_FragColor=(colorDepth/float((OFFSET*2+1)*(OFFSET*2+1))); +}`;ze.a.ShadersStore.depthBoxBlurPixelShader=U_;var V_=`#if SM_SOFTTRANSPARENTSHADOW == 1 +if ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM*alpha) discard; +#endif +`;ze.a.IncludesShadersStore.shadowMapFragmentSoftTransparentShadow=V_;var wu=new u.a,Fu=new u.a,Un=function(){function r(t,e,n){this.onBeforeShadowMapRenderObservable=new C.c,this.onAfterShadowMapRenderObservable=new C.c,this.onBeforeShadowMapRenderMeshObservable=new C.c,this.onAfterShadowMapRenderMeshObservable=new C.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())},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},set:function(t){var e=this._validateFilter(r.FILTER_POISSONSAMPLING);(t||this.filter===r.FILTER_POISSONSAMPLING)&&(this.filter=t?e:r.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"useExponentialShadowMap",{get:function(){return this.filter===r.FILTER_EXPONENTIALSHADOWMAP},set:function(t){var e=this._validateFilter(r.FILTER_EXPONENTIALSHADOWMAP);(t||this.filter===r.FILTER_EXPONENTIALSHADOWMAP)&&(this.filter=t?e:r.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"useBlurExponentialShadowMap",{get:function(){return this.filter===r.FILTER_BLUREXPONENTIALSHADOWMAP},set:function(t){var e=this._validateFilter(r.FILTER_BLUREXPONENTIALSHADOWMAP);(t||this.filter===r.FILTER_BLUREXPONENTIALSHADOWMAP)&&(this.filter=t?e:r.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"useCloseExponentialShadowMap",{get:function(){return this.filter===r.FILTER_CLOSEEXPONENTIALSHADOWMAP},set:function(t){var e=this._validateFilter(r.FILTER_CLOSEEXPONENTIALSHADOWMAP);(t||this.filter===r.FILTER_CLOSEEXPONENTIALSHADOWMAP)&&(this.filter=t?e:r.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"useBlurCloseExponentialShadowMap",{get:function(){return this.filter===r.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP},set:function(t){var e=this._validateFilter(r.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP);(t||this.filter===r.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)&&(this.filter=t?e:r.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"usePercentageCloserFiltering",{get:function(){return this.filter===r.FILTER_PCF},set:function(t){var e=this._validateFilter(r.FILTER_PCF);(t||this.filter===r.FILTER_PCF)&&(this.filter=t?e:r.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"filteringQuality",{get:function(){return this._filteringQuality},set:function(t){this._filteringQuality!==t&&(this._filteringQuality=t,this._disposeBlurPostProcesses(),this._applyFilterValues(),this._light._markMeshesAsLightDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"useContactHardeningShadow",{get:function(){return this.filter===r.FILTER_PCSS},set:function(t){var e=this._validateFilter(r.FILTER_PCSS);(t||this.filter===r.FILTER_PCSS)&&(this.filter=t?e:r.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"contactHardeningLightSizeUVRatio",{get:function(){return this._contactHardeningLightSizeUVRatio},set:function(t){this._contactHardeningLightSizeUVRatio=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"darkness",{get:function(){return this._darkness},set:function(t){this.setDarkness(t)},enumerable:!1,configurable:!0}),r.prototype.getDarkness=function(){return this._darkness},r.prototype.setDarkness=function(t){return this._darkness=t>=1?1:t<=0?0:t,this},Object.defineProperty(r.prototype,"transparencyShadow",{get:function(){return this._transparencyShadow},set:function(t){this.setTransparencyShadow(t)},enumerable:!1,configurable:!0}),r.prototype.setTransparencyShadow=function(t){return this._transparencyShadow=t,this},r.prototype.getShadowMap=function(){return this._shadowMap},r.prototype.getShadowMapForRendering=function(){return this._shadowMap2?this._shadowMap2:this._shadowMap},r.prototype.getClassName=function(){return r.CLASSNAME},r.prototype.addShadowCaster=function(t,e){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();i1?(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();this._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=to.b.MIN_RENDERINGGROUPS;o=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"));var o=t.getMesh();return n.push("#define SM_NORMALBIAS "+(this.normalBias&&o.isVerticesDataPresent(Oe.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=[Oe.b.PositionKind],d=t.getMesh();if(this.normalBias&&d.isVerticesDataPresent(Oe.b.NormalKind)&&(s.push(Oe.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(Oe.b.UVKind)&&(s.push(Oe.b.UVKind),a.push("#define UV1")),d.isVerticesDataPresent(Oe.b.UV2Kind)&&p.coordinatesIndex===1&&(s.push(Oe.b.UV2Kind),a.push("#define UV2"))}}var b=new Sr.a;if(d.useBones&&d.computeBonesUsingShaders&&d.skeleton){s.push(Oe.b.MatricesIndicesKind),s.push(Oe.b.MatricesWeightsKind),d.numBoneInfluencers>4&&(s.push(Oe.b.MatricesIndicesExtraKind),s.push(Oe.b.MatricesWeightsExtraKind));var P=d.skeleton;a.push("#define NUM_BONE_INFLUENCERS "+d.numBoneInfluencers),d.numBoneInfluencers>0&&b.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,B=0;O&&O.numInfluencers>0&&(a.push("#define MORPHTARGETS"),B=O.numInfluencers,a.push("#define NUM_MORPH_INFLUENCERS "+B),et.a.PrepareAttributesForMorphTargetsInfluencers(s,d,B));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"),et.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 +#endif +void main(void) +{ +#ifdef ALPHATEST +if (texture2D(diffuseSampler,vUV).a<0.4) +discard; +#endif +#ifdef NONLINEARDEPTH +#ifdef PACKED +gl_FragColor=pack(gl_FragCoord.z); +#else +gl_FragColor=vec4(gl_FragCoord.z,0.0,0.0,0.0); +#endif +#else +#ifdef PACKED +gl_FragColor=pack(vDepthMetric); +#else +gl_FragColor=vec4(vDepthMetric,0.0,0.0,1.0); +#endif +#endif +}`;ze.a.ShadersStore.depthPixelShader=k_;var G_=` +attribute vec3 position; +#include +#include +#include[0..maxSimultaneousMorphTargets] + +#include +uniform mat4 viewProjection; +uniform vec2 depthValues; +#if defined(ALPHATEST) || defined(NEED_UV) +varying vec2 vUV; +uniform mat4 diffuseMatrix; +#ifdef UV1 +attribute vec2 uv; +#endif +#ifdef UV2 +attribute vec2 uv2; +#endif +#endif +varying float vDepthMetric; +void main(void) +{ +vec3 positionUpdated=position; +#ifdef UV1 +vec2 uvUpdated=uv; +#endif +#include[0..maxSimultaneousMorphTargets] +#include +#include +gl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0); +vDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y)); +#if defined(ALPHATEST) || defined(BASIC_RENDER) +#ifdef UV1 +vUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0)); +#endif +#ifdef UV2 +vUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0)); +#endif +#endif +} +`;ze.a.ShadersStore.depthVertexShader=G_;var oa=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 b=p.getRenderingMesh(),P=p.getEffectiveMesh(),O=o._scene,B=O.getEngine(),F=p.getMaterial();if(P._internalAbstractMeshDataInfo._isActiveIntermediate=!1,F&&p.verticesCount!==0&&p._renderId!==O.getRenderId()){B.setState(F.backFaceCulling,0,!1,O.useRightHandedSystem);var z=b._getInstancesRenderList(p._id,!!p.getReplacementMesh());if(!z.mustReturn){var J=B.getCaps().instancedArrays&&(z.visibleInstances[p._id]!==null&&z.visibleInstances[p._id]!==void 0||b.hasThinInstances),ie=o._camera||O.activeCamera;if(o.isReady(p,J)&&ie){if(p._renderId=O.getRenderId(),B.enableEffect(o._effect),b._bind(p,o._effect,F.fillMode),o._effect.setMatrix("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()))}b.useBones&&b.computeBonesUsingShaders&&b.skeleton&&o._effect.setMatrices("mBones",b.skeleton.getTransformMatrices(b)),et.a.BindMorphTargetParameters(b,o._effect),b._processRendering(P,p,o._effect,F.fillMode,z,J,function(ce,ue){return o._effect.setMatrix("world",ue)})}}}};this._depthMap.customRenderFunction=function(p,b,P,O){var B;if(O.length){for(a.setColorWrite(!1),B=0;B4&&(o.push(Oe.b.MatricesIndicesExtraKind),o.push(Oe.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),et.a.PrepareAttributesForMorphTargetsInfluencers(o,a,d)),e&&(i.push("#define INSTANCES"),et.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(` +`);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 An.a.WarnImport("DepthRendererSceneComponent")},r}(),z_=`attribute vec2 vUV; +uniform sampler2D textureSampler; +#if defined(INITIAL) +uniform sampler2D sourceTexture; +uniform vec2 texSize; +void main(void) +{ +ivec2 coord=ivec2(vUV*(texSize-1.0)); +float f1=texelFetch(sourceTexture,coord,0).r; +float f2=texelFetch(sourceTexture,coord+ivec2(1,0),0).r; +float f3=texelFetch(sourceTexture,coord+ivec2(1,1),0).r; +float f4=texelFetch(sourceTexture,coord+ivec2(0,1),0).r; +float minz=min(min(min(f1,f2),f3),f4); +#ifdef DEPTH_REDUX +float maxz=max(max(max(sign(1.0-f1)*f1,sign(1.0-f2)*f2),sign(1.0-f3)*f3),sign(1.0-f4)*f4); +#else +float maxz=max(max(max(f1,f2),f3),f4); +#endif +glFragColor=vec4(minz,maxz,0.,0.); +} +#elif defined(MAIN) +uniform vec2 texSize; +void main(void) +{ +ivec2 coord=ivec2(vUV*(texSize-1.0)); +vec2 f1=texelFetch(textureSampler,coord,0).rg; +vec2 f2=texelFetch(textureSampler,coord+ivec2(1,0),0).rg; +vec2 f3=texelFetch(textureSampler,coord+ivec2(1,1),0).rg; +vec2 f4=texelFetch(textureSampler,coord+ivec2(0,1),0).rg; +float minz=min(min(min(f1.x,f2.x),f3.x),f4.x); +float maxz=max(max(max(f1.y,f2.y),f3.y),f4.y); +glFragColor=vec4(minz,maxz,0.,0.); +} +#elif defined(ONEBEFORELAST) +uniform ivec2 texSize; +void main(void) +{ +ivec2 coord=ivec2(vUV*vec2(texSize-1)); +vec2 f1=texelFetch(textureSampler,coord % texSize,0).rg; +vec2 f2=texelFetch(textureSampler,(coord+ivec2(1,0)) % texSize,0).rg; +vec2 f3=texelFetch(textureSampler,(coord+ivec2(1,1)) % texSize,0).rg; +vec2 f4=texelFetch(textureSampler,(coord+ivec2(0,1)) % texSize,0).rg; +float minz=min(f1.x,f2.x); +float maxz=max(f1.y,f2.y); +glFragColor=vec4(minz,maxz,0.,0.); +} +#elif defined(LAST) +void main(void) +{ +discard; +glFragColor=vec4(0.); +} +#endif +`;ze.a.ShadersStore.minmaxReduxPixelShader=z_;var Bu=function(){function r(t){this.onAfterReductionPerformed=new C.c,this._forceFullscreenViewport=!0,this._activated=!1,this._camera=t,this._postProcessManager=new hs.a(t.getScene())}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?` +#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,B){return function(F){F.setTexture("sourceTexture",o._sourceTexture),F.setFloatArray2("texSize",new Float32Array([O,B]))}}(d,p),this._reductionSteps.push(s);for(var b=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 "+b,"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,B){return function(F){O==1||B==1?F.setIntArray2("texSize",new Int32Array([O,B])):F.setFloatArray2("texSize",new Float32Array([O,B]))}}(d,p),this._reductionSteps.push(P),b++,d==1&&p==1&&P.onAfterRenderObservable.add(function(O,B,F){var z=new Float32Array(4*O*B),J={min:0,max:0};return function(){a.getEngine()._readTexturePixels(F.inputTexture,O,B,-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;en&&(e=0,n=1),e<0&&(e=0),n>1&&(n=1),this._minDistance=e,this._maxDistance=n,this._breaksAreDirty=!0)},Object.defineProperty(t.prototype,"minDistance",{get:function(){return this._minDistance},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"maxDistance",{get:function(){return this._maxDistance},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return t.CLASSNAME},t.prototype.getCascadeMinExtents=function(e){return e>=0&&e=0&&ethis._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=0&&e=0&&e=s&&(a=0,s=1),a==n._minDistance&&s==n._maxDistance||n.setMinMaxDistance(a,s)}),this._depthReducer.setDepthRenderer(this._depthRenderer)),this._depthReducer.activate()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"autoCalcDepthBoundsRefreshRate",{get:function(){var e,n,i;return(i=(n=(e=this._depthReducer)===null||e===void 0?void 0:e.depthRenderer)===null||n===void 0?void 0:n.getDepthMap().refreshRate)!==null&&i!==void 0?i:-1},set:function(e){var n;!((n=this._depthReducer)===null||n===void 0)&&n.depthRenderer&&(this._depthReducer.depthRenderer.getDepthMap().refreshRate=e)},enumerable:!1,configurable:!0}),t.prototype.splitFrustum=function(){this._breaksAreDirty=!0},t.prototype._splitFrustum=function(){var e=this._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=n?Math.min((this._shadowMaxZ-n)/(i-n),this._maxDistance):this._maxDistance)*o,p=d-s,b=d/s,P=0;PMath.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 b=Math.round(d*i);b<0?b=0:b>=i&&(b=i-1);var P=i-b-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>0?(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;o32767)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 Xs.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,b=e.dataPosition,P=0,O=0,B=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[b++],i=t[b++],o=t[b++],a=t[b++],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,B=0;B<4;B++)for(O=(B+1)*p;P128){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;se0;){for(s=0;s +#include +#include +#include +uniform float alphaG; +uniform samplerCube inputTexture; +uniform vec2 vFilteringInfo; +uniform float hdrScale; +varying vec3 direction; +void main() { +vec3 color=radiance(alphaG,inputTexture,direction,vFilteringInfo); +gl_FragColor=vec4(color*hdrScale,1.0); +}`;ze.a.ShadersStore.hdrFilteringPixelShader=W_;var Xu=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=2&&this._prefilterOnLoad){var i=this._onLoad,o=new Xu(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=jo.ConvertCubeMapToSphericalPolynomial(s);e.sphericalPolynomial=d}for(var p=[],b=null,P=0;P<6;P++){if(!n.getCaps().textureFloat){var O=new ArrayBuffer(e._size*e._size*3);b=new Uint8Array(O)}var B=s[t._facesMapping[P]];if(e.gammaSpace||b){for(var F=0;F255){var ce=255/se;z*=ce,J*=ce,ie*=ce}b[3*F+0]=z,b[3*F+1]=J,b[3*F+2]=ie}}b?p.push(b):p.push(B)}return p},null,this._onLoad,this._onError)},t.prototype.clone=function(){var e=new t(this.url,this.getScene()||this._getEngine(),this._size,this._noMipmap,this._generateHarmonics,this.gammaSpace);return e.level=this.level,e.wrapU=this.wrapU,e.wrapV=this.wrapV,e.coordinatesIndex=this.coordinatesIndex,e.coordinatesMode=this.coordinatesMode,e},t.prototype.delayLoad=function(){this.delayLoadState===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"]=aa;var Yu=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 C.c,this._onDataLayoutChanged=new C.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&&(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=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-1&&this._impostors.splice(e,1).length&&this.getPhysicsPlugin().removePhysicsBody(t)},r.prototype.addJoint=function(t,e,n){var i={mainImpostor:t,connectedImpostor:e,joint:n};n.physicsPlugin=this._physicsPlugin,this._joints.push(i),this._physicsPlugin.generateJoint(i)},r.prototype.removeJoint=function(t,e,n){var i=this._joints.filter(function(o){return o.connectedImpostor===e&&o.joint===n&&o.mainImpostor===t});i.length&&this._physicsPlugin.removeJoint(i[0])},r.prototype._step=function(t){var e=this;this._impostors.forEach(function(n){n.isBodyInitRequired()&&e._physicsPlugin.generatePhysicsBody(n)}),t>.1?t=.1:t<=0&&(t=1/60),this._physicsPlugin.executeStep(t,this._impostors)},r.prototype.getPhysicsPlugin=function(){return this._physicsPlugin},r.prototype.getImpostors=function(){return this._impostors},r.prototype.getImpostorForPhysicsObject=function(t){for(var e=0;e0&&(this._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},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(b){return!!b.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;i1e3*n));d++);this.time+=i;for(var p=this.time%n/n,b=t,P=this.bodies,O=0;O!==P.length;O++){var B=P[O];B.type!==e.Body.STATIC&&B.sleepState!==e.Body.SLEEPING?(B.position.vsub(B.previousPosition,b),b.scale(p,b),B.position.vadd(b,B.interpolatedPosition)):(B.interpolatedPosition.set(B.position.x,B.position.y,B.position.z),B.interpolatedQuaternion.set(B.quaternion.x,B.quaternion.y,B.quaternion.z,B.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}();Ir.DefaultPluginFactory=function(){return new Ks};var Ku=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 Ys}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];(s=t.object).getChildMeshes&&s.getChildMeshes().forEach(function(d){d.physicsImpostor&&i.push(d.physicsImpostor)});var o=function(d){return Math.max(d,Ir.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 b=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 B=d.object.position.clone();n.posShape.push(B.x),n.posShape.push(B.y),n.posShape.push(B.z),n.rotShape.push(57.29577951308232*b.x,57.29577951308232*b.y,57.29577951308232*b.z)}switch(d.object.rotationQuaternion.copyFrom(a),d.type){case xt.a.ParticleImpostor:l.a.Warn("No Particle support in OIMO.js. using SphereImpostor instead");case xt.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 xt.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 xt.a.PlaneImpostor:case xt.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}(),ca=f(97),Qu=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 Ys,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-n0&&this._isImpostorInContact(d))for(var p=0,b=d._onPhysicsCollideCallbacks;p3?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(Oe.b.PositionKind);s||(s=[]),n.computeWorldMatrix(!1);for(var d=a.length/3,p=0;p0){if(t.type!=xt.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 xt.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 b=[new this.bjsAMMO.btVector3(0,0,0)];(i=new this.bjsAMMO.btMultiSphereShape(b,[1],1)).setLocalScaling(new this.bjsAMMO.btVector3(a.x/2,a.y/2,a.z/2))}break;case xt.a.CapsuleImpostor:i=new this.bjsAMMO.btCapsuleShape(a.x/2,a.y/2);break;case xt.a.CylinderImpostor:this._tmpAmmoVectorA.setValue(a.x/2,a.y/2,a.z/2),i=new this.bjsAMMO.btCylinderShape(this._tmpAmmoVectorA);break;case xt.a.PlaneImpostor:case xt.a.BoxImpostor:this._tmpAmmoVectorA.setValue(a.x/2,a.y/2,a.z/2),i=new this.bjsAMMO.btBoxShape(this._tmpAmmoVectorA);break;case xt.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 xt.a.ConvexHullImpostor:var B=new this.bjsAMMO.btConvexHullShape;(O=this._addHullVerts(B,o,o))==0?(t._pluginData.toDispose.push(B),i=new this.bjsAMMO.btCompoundShape):i=B;break;case xt.a.NoImpostor:i=new this.bjsAMMO.btSphereShape(a.x/2);break;case xt.a.CustomImpostor:i=this._createCustom(t);break;case xt.a.SoftbodyImpostor:i=this._createSoftbody(t);break;case xt.a.ClothImpostor:i=this._createCloth(t);break;case xt.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===xt.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)},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}();U.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},U.a.prototype.addReflectionProbe=function(r){this.reflectionProbes||(this.reflectionProbes=[]),this.reflectionProbes.push(r)};var qu=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},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;o0){var n=t._waitingData.lods.ids,i=e.isEnabled(!1);if(t._waitingData.lods.distances){var o=t._waitingData.lods.distances;if(o.length>=n.length){var a=o.length>n.length?o[o.length-1]:0;e.setEnabled(!1);for(var s=0;s0&&e.addLODLevel(a,null),i===!0&&e.setEnabled(!0)}else Xe.b.Warn("Invalid level of detail distances for "+t.name)}}t._waitingData.lods=null}},$u=function(r,t,e,n,i){i===void 0&&(i=!1);var o=new xn(r),a="importScene has failed JSON parse";try{var s=JSON.parse(t);a="";var d,p,b=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,B=new aa((s.environmentTexture.match(/https?:\/\//g)?"":e)+s.environmentTexture,r,O,!0,!P);s.environmentTextureRotationY&&(B.rotationY=s.environmentTextureRotationY),r.environmentTexture=B}else if(qn.a.EndsWith(s.environmentTexture,".env")){var F=new ai((s.environmentTexture.match(/https?:\/\//g)?"":e)+s.environmentTexture,r);s.environmentTextureRotationY&&(F.rotationY=s.environmentTextureRotationY),r.environmentTexture=F}else{var z=ai.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;d0){for(var $t=0;$t0){for(var Vn=0;Vn-1&&p.skeletons!==void 0&&p.skeletons!==null&&!(z.indexOf(ie.skeletonId)>-1))for(var Le=0,xe=p.skeletons.length;Le1,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,b=null,P=s.split(` +`),O=0,B=0,F=0,z=0,J=0,ie=0;ie0&&(ie+1)%4==0)p[ie]=255;else{var Te=b[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"]=rh;var oh=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?Xe.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=Xs.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;ae.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;case r._TYPE_RLE_GREY:a=!0;case r._TYPE_GREY:d=!0}var p,b,P,O,B,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>r._ORIGIN_SHIFT){default:case r._ORIGIN_UL:b=0,O=1,z=i.width,P=0,B=1,F=i.height;break;case r._ORIGIN_BL:b=0,O=1,z=i.width,P=i.height-1,B=-1,F=-1;break;case r._ORIGIN_UR:b=i.width-1,O=-1,z=-1,P=0,B=1,F=i.height;break;case r._ORIGIN_BR:b=i.width-1,O=-1,z=-1,P=i.height-1,B=-1,F=-1}var Te=r["_getImageData"+(d?"Grey":"")+i.pixel_size+"bits"](i,p,o,P,B,F,b,O,z);t.getEngine()._uploadDataToTextureDirectly(t,Te)}}},r._getImageData8bits=function(t,e,n,i,o,a,s,d,p){var b,P,O,B=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++)b=B[ie],se[4*(P+z*O)+3]=255,se[4*(P+z*O)+2]=F[3*b+0],se[4*(P+z*O)+1]=F[3*b+1],se[4*(P+z*O)+0]=F[3*b+2];return se},r._getImageData16bits=function(t,e,n,i,o,a,s,d,p){var b,P,O,B=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&(b=B[J+0]+(B[J+1]<<8)))>>10)/31|0,ce=255*((992&b)>>5)/31|0,ue=255*(31&b)/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&b?0:255}return ie},r._getImageData24bits=function(t,e,n,i,o,a,s,d,p){var b,P,O=n,B=t.width,F=t.height,z=0,J=new Uint8Array(B*F*4);for(P=i;P!==a;P+=o)for(b=s;b!==p;b+=d,z+=3)J[4*(b+B*P)+3]=255,J[4*(b+B*P)+2]=O[z+0],J[4*(b+B*P)+1]=O[z+1],J[4*(b+B*P)+0]=O[z+2];return J},r._getImageData32bits=function(t,e,n,i,o,a,s,d,p){var b,P,O=n,B=t.width,F=t.height,z=0,J=new Uint8Array(B*F*4);for(P=i;P!==a;P+=o)for(b=s;b!==p;b+=d,z+=4)J[4*(b+B*P)+2]=O[z+0],J[4*(b+B*P)+1]=O[z+1],J[4*(b+B*P)+0]=O[z+2],J[4*(b+B*P)+3]=O[z+3];return J},r._getImageDataGrey8bits=function(t,e,n,i,o,a,s,d,p){var b,P,O,B=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++)b=B[J],ie[4*(P+F*O)+0]=b,ie[4*(P+F*O)+1]=b,ie[4*(P+F*O)+2]=b,ie[4*(P+F*O)+3]=255;return ie},r._getImageDataGrey16bits=function(t,e,n,i,o,a,s,d,p){var b,P,O=n,B=t.width,F=t.height,z=0,J=new Uint8Array(B*F*4);for(P=i;P!==a;P+=o)for(b=s;b!==p;b+=d,z+=2)J[4*(b+B*P)+0]=O[z+0],J[4*(b+B*P)+1]=O[z+0],J[4*(b+B*P)+2]=O[z+0],J[4*(b+B*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}(),ah=function(){function r(){this.supportCascades=!1}return r.prototype.canLoad=function(t){return qn.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=ha.GetTGAHeader(i);n(o.width,o.height,e.generateMipMaps,!1,function(){ha.UploadContent(e,i)})},r}();Ue.a._TextureLoaders.push(new ah);var _o,q_=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"})(_o||(_o={}));var mo=function(){function r(){}return r.GetInternalFormatFromBasisFormat=function(t){if(t===_o.cTFETC1)return 36196;if(t===_o.cTFBC1)return 33776;if(t===_o.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):Xe.b.LoadFileAsync(r.WasmModuleURL).then(function(n){var i=URL.createObjectURL(new Blob(["("+Z_+")()"],{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(b){b.data.action==="transcode"&&b.data.id===s&&(n._Worker.removeEventListener("message",d),b.data.success?o(b.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 Ct.a(i,Ct.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,s.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)&&(Xe.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>2&3],se[Ee++]=ie[Ae>>4&3],se[Ee++]=ie[Ae>>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),b=function(fe){for(var ve=fe.getHasAlpha(),Te=fe.getNumImages(),Re=[],Ae=0;Ae1&&e.generateMipMaps;mo.LoadTextureFromTranscodeResult(e,d),e.getEngine()._setCubeMapTextureParams(e,p),e.isReady=!0,e.onLoadedObservable.notifyObservers(e),e.onLoadedObservable.clear(),i&&i()}).catch(function(d){Xe.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}};mo.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(){mo.LoadTextureFromTranscodeResult(e,a)})}).catch(function(a){Xe.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 sh);var qs=function(r){function t(e,n,i,o,a){var s=this,d=!(!a||!a.generateMipMaps)&&a.generateMipMaps,p=!(!a||!a.generateDepthTexture)&&a.generateDepthTexture,b=!a||a.doNotChangeAspectRatio===void 0||a.doNotChangeAspectRatio;if((s=r.call(this,e,n,o,d,b)||this).isSupported){var P=[],O=[];s._initTypes(i,P,O,a);var B=!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:B,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=0;e--)this._internalTextures[e]!==void 0&&(this._internalTextures[e].dispose(),this._internalTextures.splice(e,1))},t}(sn),Zs=function(r,t,e){this.id=r,this.scale=t,this.offset=e},J_=function(){function r(t,e,n,i){var o,a,s,d,p,b,P,O,B,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:Oe.b.UVKind,this.options.uvsOut=(s=this.options.uvsOut)!==null&&s!==void 0?s:Oe.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=(b=this.options.updateInputMeshes)===null||b===void 0||b,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=(B=this.options.customFillColor)!==null&&B!==void 0?B:"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;p0);for(var t=0;t0)}},r}(),$_=` +attribute vec2 position; + +varying vec2 vPosition; +varying vec2 vUV; +const vec2 madd=vec2(0.5,0.5); +void main(void) { +vPosition=position; +vUV=position*madd+madd; +gl_Position=vec4(position,0.0,1.0); +}`;ze.a.ShadersStore.proceduralVertexShader=$_;var go=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 b=r.call(this,null,o,!s)||this;b.isEnabled=!0,b.autoClear=!0,b.onGeneratedObservable=new C.c,b.onBeforeGenerationObservable=new C.c,b.nodeMaterialSource=null,b._textures={},b._currentRefreshId=-1,b._frameId=-1,b._refreshRate=1,b._vertexBuffers={},b._uniforms=new Array,b._samplers=new Array,b._floats={},b._ints={},b._floatsArrays={},b._colors3={},b._colors4={},b._vectors2={},b._vectors3={},b._matrices={},b._fallbackTextureUsed=!1,b._cachedDefines="",b._contentUpdateId=-1;var P=(o=b.getScene()||te.a.LastCreatedScene)._getComponent(at.a.NAME_PROCEDURALTEXTURE);P||(P=new ch(o),o._addComponent(P)),o.proceduralTextures.push(b),b._fullEngine=o.getEngine(),b.name=e,b.isRenderTarget=!0,b._size=n,b._generateMipMaps=s,b.setFragment(i),b._fallbackTexture=a,d?(b._texture=b._fullEngine.createRenderTargetCubeTexture(n,{generateMipMaps:s,generateDepthBuffer:!1,generateStencilBuffer:!1,type:p}),b.setFloat("face",0)):b._texture=b._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),b._vertexBuffers[Oe.b.PositionKind]=new Oe.b(b._fullEngine,O,Oe.b.PositionKind,!1,!1,2),b._createIndexBuffer(),b}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[Oe.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,[Oe.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},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[Oe.b.PositionKind];i&&(i.dispose(),this._vertexBuffers[Oe.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"]=go;var em=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;e0},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isConnectedInVertexShader",{get:function(){if(this.target===Ce.Vertex)return!0;if(!this.hasEndpoints)return!1;for(var t=0,e=this._endpoints;t=0)&&(e.isExposedOnFrame=!0,e.exposedPortPosition=this.exposedPortPosition),e},r.prototype.dispose=function(){this.onConnectionObservable.clear()},r}(),am=f(152),pt=function(){function r(t,e,n,i){e===void 0&&(e=Ce.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=am.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},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)==0&&(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 da(t,this,Tn.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 da(t,this,Tn.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=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===Ce.Vertex&&t.target!==Ce.VertexAndFragment;if(o&&((t.target&t._buildTarget)==0||(t.target&n.target)==0||this.target!==Ce.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 +`),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[0.."+n.repeatKey+`]\r +`;var i=ze.a.IncludesShadersStore[t]+`\r +`;if(this.sharedData.emitComments&&(i=e+`\r +`+i),!n)return i;if(n.replaceStrings)for(var o=0;o[0.."+n.repeatKey+`]\r +`:this.functions[o]="#include<"+t+`>\r +`,void(this.sharedData.emitComments&&(this.functions[o]=e+`\r +`+this.functions[o]));if(this.functions[o]=ze.a.IncludesShadersStore[t],this.sharedData.emitComments&&(this.functions[o]=e+`\r +`+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;a0||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-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&Ce.Vertex)!=0&&this._addVertexOutputNode(e),(e.target&Ce.Fragment)!=0&&this._addFragmentOutputNode(e),this},t.prototype.removeOutputNode=function(e){return e.target===null||((e.target&Ce.Vertex)!=0&&this._removeVertexOutputNode(e),(e.target&Ce.Fragment)!=0&&this._removeFragmentOutputNode(e)),this},t.prototype._addVertexOutputNode=function(e){if(this._vertexOutputNodes.indexOf(e)===-1)return e.target=Ce.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=Ce.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-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===Mn.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 uh,this._vertexCompilationState.supportUniformBuffers=n.supportsUniformBuffers,this._vertexCompilationState.target=Ce.Vertex,this._fragmentCompilationState=new uh,this._fragmentCompilationState.supportUniformBuffers=n.supportsUniformBuffers,this._fragmentCompilationState.target=Ce.Fragment,this._sharedData=new sm,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;s0\r +`,e.compilationString+=this._declareOutput(o,e)+" = "+a.associatedVariableName+" * "+i+`;\r +`,e.compilationString+=`#else\r +`,e.compilationString+=this._declareOutput(o,e)+" = "+a.associatedVariableName+`;\r +`,e.compilationString+=`#endif\r +`,this},t}(pt);R.a.RegisteredTypes["BABYLON.BonesBlock"]=ph;var _h=function(r){function t(e){var n=r.call(this,e,Ce.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 +`,e.compilationString+=this._declareOutput(n,e)+" = mat4("+o.associatedVariableName+", "+a.associatedVariableName+", "+s.associatedVariableName+", "+d.associatedVariableName+`);\r +`,e.compilationString+=`#ifdef THIN_INSTANCES\r +`,e.compilationString+=n.associatedVariableName+" = "+this.world.associatedVariableName+" * "+n.associatedVariableName+`;\r +`,e.compilationString+=`#endif\r +`,e.compilationString+=this._declareOutput(i,e)+` = float(gl_InstanceID);\r +`,e.compilationString+=`#else\r +`,e.compilationString+=this._declareOutput(n,e)+" = "+this.world.associatedVariableName+`;\r +`,e.compilationString+=this._declareOutput(i,e)+` = 0.0;\r +`,e.compilationString+=`#endif\r +`,this},t}(pt);R.a.RegisteredTypes["BABYLON.InstancesBlock"]=_h;var mh=function(r){function t(e){var n=r.call(this,e,Ce.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]},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&&et.a.PrepareDefinesForMorphTargets(e,i)},t.prototype.bind=function(e,n,i){i&&i.morphTargetManager&&i.morphTargetManager.numInfluencers>0&&et.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,b=this.positionOutput,P=this.normalOutput,O=this.tangentOutput,B=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;fe0)for(fe=0;fe=0;et.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?et.a.BindLight(this.light,this._lightId,o,e,!0):et.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 +`),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 +`,this.view.isConnected&&(e.compilationString+="mat4 view = "+this.view.associatedVariableName+`;\r +`),e.compilationString+=e._emitCodeFromInclude("shadowsVertex",i,{repeatKey:"maxSimultaneousLights"}))},t.prototype._buildBlock=function(e){if(r.prototype._buildBlock.call(this,e),e.target===Ce.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 +`),e.compilationString+=`lightingInfo info;\r +`,e.compilationString+=`float shadow = 1.;\r +`,e.compilationString+="float glossiness = "+(this.glossiness.isConnected?this.glossiness.associatedVariableName:"1.0")+" * "+(this.glossPower.isConnected?this.glossPower.associatedVariableName:"1024.0")+`;\r +`,e.compilationString+=`vec3 diffuseBase = vec3(0., 0., 0.);\r +`,e.compilationString+=`vec3 specularBase = vec3(0., 0., 0.);\r +`,e.compilationString+="vec3 normalW = "+this.worldNormal.associatedVariableName+`.xyz;\r +`),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 +`,a.hasEndpoints&&(e.compilationString+=this._declareOutput(a,e)+" = specularBase"+(this.specularColor.isConnected?" * "+this.specularColor.associatedVariableName:"")+`;\r +`),this.shadow.hasEndpoints&&(e.compilationString+=this._declareOutput(this.shadow,e)+` = shadow;\r +`),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"]=xh;var Ch=function(r){function t(e,n){n===void 0&&(n=!1);var i=r.call(this,e,n?Ce.Fragment:Ce.VertexAndFragment)||this;return i.convertToGammaSpace=!1,i.convertToLinearSpace=!1,i._fragmentOnly=n,i.registerInput("uv",le.Vector2,!1,Ce.VertexAndFragment),i.registerOutput("rgba",le.Color4,Ce.Neutral),i.registerOutput("rgb",le.Color3,Ce.Neutral),i.registerOutput("r",le.Float,Ce.Neutral),i.registerOutput("g",le.Float,Ce.Neutral),i.registerOutput("b",le.Float,Ce.Neutral),i.registerOutput("a",le.Float,Ce.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 Ce.Fragment;if(!this.uv.isConnected||this.uv.sourceBlock.isInput)return Ce.VertexAndFragment;for(var e=this.uv.connectedPoint;e;){if(e.target===Ce.Fragment)return Ce.Fragment;if(e.target===Ce.Vertex)return Ce.VertexAndFragment;if(e.target===Ce.Neutral||e.target===Ce.VertexAndFragment){var n=e.ownerBlock;e=null;for(var i=0,o=n.inputs;i1?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&&ut.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};et.a.PrepareDefinesForLight(a,e,this.light,this._lightId,i,!0,s),s.needRebuild&&i.rebuild()}else et.a.PrepareDefinesForLights(a,e,i,!0,n.maxSimultaneousLights),i._needNormals=!0,et.a.PrepareDefinesForMultiview(a,i)}},t.prototype.updateUniformsAndSamples=function(e,n,i,o){for(var a=0;a=0;et.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?et.a.BindLight(this.light,this._lightId,s,e,!0):et.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 b=(a=(o=this.indexOfRefraction.connectInputBlock)===null||o===void 0?void 0:o.value)!==null&&a!==void 0?a:1.5,P=Math.pow((b-1)/(b+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 +`);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 +`,e._injectAtEnd+=`vClipSpacePosition = gl_Position;\r +`,e._injectAtEnd+=`#endif\r +`),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 +`,this.view.isConnected&&(e.compilationString+="mat4 view = "+this.view.associatedVariableName+`;\r +`),e.compilationString+=e._emitCodeFromInclude("shadowsVertex",a,{repeatKey:"maxSimultaneousLights"}))},t.prototype._getAlbedoOpacityCode=function(){var e=`albedoOpacityOutParams albedoOpacityOut;\r +`;return e+=`albedoOpacityBlock( + vec4(`+(this.baseColor.isConnected?this.baseColor.associatedVariableName:"vec3(1.)")+`, 1.), + #ifdef ALBEDO + vec4(1.), + vec2(1., 1.), + #endif + #ifdef OPACITY + vec4(`+(this.opacity.isConnected?this.opacity.associatedVariableName:"1.")+`), + vec2(1., 1.), + #endif + albedoOpacityOut + ); + + vec3 surfaceAlbedo = albedoOpacityOut.surfaceAlbedo; + float alpha = albedoOpacityOut.alpha;\r +`},t.prototype._getAmbientOcclusionCode=function(){var e=`ambientOcclusionOutParams aoOut;\r +`;return e+=`ambientOcclusionBlock( + #ifdef AMBIENT + vec3(`+(this.ambientOcc.isConnected?this.ambientOcc.associatedVariableName:"1.")+`), + vec4(0., 1.0, 1.0, 0.), + #endif + aoOut + );\r +`},t.prototype._getReflectivityCode=function(e){var n=`reflectivityOutParams reflectivityOut;\r +`;return this._vMetallicReflectanceFactorsName=e._getFreeVariableName("vMetallicReflectanceFactors"),e._emitUniformFromString(this._vMetallicReflectanceFactorsName,"vec4"),n+=`vec3 baseColor = surfaceAlbedo; + + reflectivityBlock( + vec4(`+this.metallic.associatedVariableName+", "+this.roughness.associatedVariableName+`, 0., 0.), + #ifdef METALLICWORKFLOW + surfaceAlbedo, + `+this._vMetallicReflectanceFactorsName+`, + #endif + #ifdef REFLECTIVITY + vec3(0., 0., 1.), + vec4(1.), + #endif + #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED) + aoOut.ambientOcclusionColor, + #endif + #ifdef MICROSURFACEMAP + microSurfaceTexel, <== not handled! + #endif + reflectivityOut + ); + + float microSurface = reflectivityOut.microSurface; + float roughness = reflectivityOut.roughness; + + #ifdef METALLICWORKFLOW + surfaceAlbedo = reflectivityOut.surfaceAlbedo; + #endif + #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED) + aoOut.ambientOcclusionColor = reflectivityOut.ambientOcclusionColor; + #endif\r +`},t.prototype._buildBlock=function(e){var n,i,o,a,s,d,p,b,P,O,B,F,z,J,ie,se,ce,ue,fe,ve,Te,Re,Ae,Ee,Se,Le,xe,Ne,Ie,Fe,Ye,tt,it,lt,Qe,ot,rt,Ze,dt;r.prototype._buildBlock.call(this,e),this._scene=e.sharedData.scene,this._environmentBRDFTexture||(this._environmentBRDFTexture=ea.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!==Ce.Fragment)return this._injectVertexCode(e),this;e.sharedData.bindableBlocks.push(this),e.sharedData.blocksWithDefines.push(this);var Je="//"+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",Je,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]},this._lightId.toString()):e._emitFunctionFromInclude(e.supportUniformBuffers?"lightUboDeclaration":"lightFragmentDeclaration",Je,{repeatKey:"maxSimultaneousLights"}),e._emitFunctionFromInclude("helperFunctions",Je),e._emitFunctionFromInclude("importanceSampling",Je),e._emitFunctionFromInclude("pbrHelperFunctions",Je),e._emitFunctionFromInclude("imageProcessingFunctions",Je),e._emitFunctionFromInclude("shadowsFragmentFunctions",Je,{replaceStrings:[{search:/vPositionW/g,replace:yt+".xyz"}]}),e._emitFunctionFromInclude("pbrDirectLightingSetupFunctions",Je,{replaceStrings:[{search:/vPositionW/g,replace:yt+".xyz"}]}),e._emitFunctionFromInclude("pbrDirectLightingFalloffFunctions",Je),e._emitFunctionFromInclude("pbrBRDFFunctions",Je,{replaceStrings:[{search:/REFLECTIONMAP_SKYBOX/g,replace:(i=Ve?._defineSkyboxName)!==null&&i!==void 0?i:"REFLECTIONMAP_SKYBOX"}]}),e._emitFunctionFromInclude("hdrFilteringFunctions",Je),e._emitFunctionFromInclude("pbrDirectLightingFunctions",Je,{replaceStrings:[{search:/vPositionW/g,replace:yt+".xyz"}]}),e._emitFunctionFromInclude("pbrIBLFunctions",Je),e._emitFunctionFromInclude("pbrBlockAlbedoOpacity",Je),e._emitFunctionFromInclude("pbrBlockReflectivity",Je),e._emitFunctionFromInclude("pbrBlockAmbientOcclusion",Je),e._emitFunctionFromInclude("pbrBlockAlphaFresnel",Je),e._emitFunctionFromInclude("pbrBlockAnisotropic",Je),e._emitUniformFromString("vLightingIntensity","vec4"),this._vNormalWName=e._getFreeVariableName("vNormalW"),e.compilationString+="vec4 "+this._vNormalWName+" = normalize("+this.worldNormal.associatedVariableName+`);\r +`,e._registerTempVariable("viewDirectionW")&&(e.compilationString+="vec3 viewDirectionW = normalize("+this.cameraPosition.associatedVariableName+" - "+yt+`.xyz);\r +`),e.compilationString+="vec3 geometricNormalW = "+this._vNormalWName+`.xyz;\r +`,e.compilationString+="vec3 normalW = "+(Wt.isConnected?"normalize("+Wt.associatedVariableName+".xyz)":"geometricNormalW")+`;\r +`,this._invertNormalName=e._getFreeVariableName("invertNormal"),e._emitUniformFromString(this._invertNormalName,"float"),e.compilationString+=e._emitCodeFromInclude("pbrBlockNormalFinal",Je,{replaceStrings:[{search:/vPositionW/g,replace:yt+".xyz"},{search:/vEyePosition.w/g,replace:this._invertNormalName}]}),e.compilationString+=this._getAlbedoOpacityCode(),e.compilationString+=e._emitCodeFromInclude("depthPrePass",Je),e.compilationString+=this._getAmbientOcclusionCode(),e.compilationString+=e._emitCodeFromInclude("pbrBlockLightmapInit",Je),e.compilationString+=`#ifdef UNLIT + vec3 diffuseBase = vec3(1., 1., 1.); + #else\r +`,e.compilationString+=this._getReflectivityCode(e),e.compilationString+=e._emitCodeFromInclude("pbrBlockGeometryInfo",Je,{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",Je,{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:(b=Ve?._defineProjectionName)!==null&&b!==void 0?b:"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:(B=Ve?._defineLinearSpecularReflection)!==null&&B!==void 0?B:"LINEARSPECULARREFLECTION"},{search:/vReflectionFilteringInfo/g,replace:(F=Ve?._vReflectionFilteringInfoName)!==null&&F!==void 0?F:"vReflectionFilteringInfo"}]}),e.compilationString+=e._emitCodeFromInclude("pbrBlockReflectance0",Je,{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",Je,{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+=ba.GetCode(e,vt,Ve,yt,Jt,Yt,this.worldNormal.associatedVariableName),Jt&&(Yt=(Te=vt?.worldTangent.isConnected)!==null&&Te!==void 0&&Te),e._emitFunctionFromInclude("pbrBlockClearcoat",Je,{replaceStrings:[{search:/computeReflectionCoords/g,replace:"computeReflectionCoordsPBR"},{search:/REFLECTIONMAP_3D/g,replace:(Re=Ve?._define3DName)!==null&&Re!==void 0?Re:"REFLECTIONMAP_3D"},{search:/REFLECTIONMAP_OPPOSITEZ/g,replace:(Ae=Ve?._defineOppositeZ)!==null&&Ae!==void 0?Ae:"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",Je,{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?(tt=((Ye=this.subsurface.connectedPoint)===null||Ye===void 0?void 0:Ye.ownerBlock).refraction.connectedPoint)===null||tt===void 0?void 0:tt.ownerBlock:null;Mt&&(Mt.viewConnectionPoint=this.view,Mt.indexOfRefractionConnectionPoint=this.indexOfRefraction),e.compilationString+=ya.GetCode(e,Et,Ve,yt),e._emitFunctionFromInclude("pbrBlockSubSurface",Je,{replaceStrings:[{search:/REFLECTIONMAP_3D/g,replace:(it=Ve?._define3DName)!==null&&it!==void 0?it:"REFLECTIONMAP_3D"},{search:/REFLECTIONMAP_OPPOSITEZ/g,replace:(lt=Ve?._defineOppositeZ)!==null&<!==void 0?lt:"REFLECTIONMAP_OPPOSITEZ"},{search:/REFLECTIONMAP_PROJECTION/g,replace:(Qe=Ve?._defineProjectionName)!==null&&Qe!==void 0?Qe:"REFLECTIONMAP_PROJECTION"},{search:/SS_REFRACTIONMAP_3D/g,replace:(ot=Mt?._define3DName)!==null&&ot!==void 0?ot:"SS_REFRACTIONMAP_3D"},{search:/SS_LODINREFRACTIONALPHA/g,replace:(rt=Mt?._defineLODRefractionAlpha)!==null&&rt!==void 0?rt:"SS_LODINREFRACTIONALPHA"},{search:/SS_LINEARSPECULARREFRACTION/g,replace:(Ze=Mt?._defineLinearSpecularRefraction)!==null&&Ze!==void 0?Ze:"SS_LINEARSPECULARREFRACTION"},{search:/SS_REFRACTIONMAP_OPPOSITEZ/g,replace:(dt=Mt?._defineOppositeZ)!==null&&dt!==void 0?dt:"SS_REFRACTIONMAP_OPPOSITEZ"}]}),e.compilationString+=e._emitCodeFromInclude("pbrBlockDirectLighting",Je),this.light?e.compilationString+=e._emitCodeFromInclude("lightFragment",Je,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]}):e.compilationString+=e._emitCodeFromInclude("lightFragment",Je,{repeatKey:"maxSimultaneousLights"}),e.compilationString+=e._emitCodeFromInclude("pbrBlockFinalLitComponents",Je),e.compilationString+=`#endif\r +`;var $t=this.ambientColor.isConnected?this.ambientColor.associatedVariableName:"vec3(0., 0., 0.)",Dn=_n.DEFAULT_AO_ON_ANALYTICAL_LIGHTS.toString();Dn.indexOf(".")===-1&&(Dn+="."),e.compilationString+=e._emitCodeFromInclude("pbrBlockFinalUnlitComponents",Je,{replaceStrings:[{search:/vec3 finalEmissive[\s\S]*?finalEmissive\*=vLightingIntensity\.y;/g,replace:""},{search:/vAmbientColor/g,replace:$t+" * ambientFromScene"},{search:/vAmbientInfos\.w/g,replace:Dn}]}),e.compilationString+=e._emitCodeFromInclude("pbrBlockFinalColorComposition",Je,{replaceStrings:[{search:/finalEmissive/g,replace:"vec3(0.)"}]}),e.compilationString+=e._emitCodeFromInclude("pbrBlockImageProcessing",Je,{replaceStrings:[{search:/visibility/g,replace:"1."}]}),e.compilationString+=e._emitCodeFromInclude("pbrDebug",Je,{replaceStrings:[{search:/vNormalW/g,replace:this._vNormalWName},{search:/vPositionW/g,replace:yt},{search:/albedoTexture\.rgb;/g,replace:`vec3(1.);\r +gl_FragColor.rgb = toGammaSpace(gl_FragColor.rgb);\r +`}]});for(var Vn=0,ei=this._outputs;Vn("+this._options.remappedVariables.join(",")+")":ze.a.IncludesShadersStore.shadowMapVertexNormalBias,P=this._options&&this._options.remappedVariables?"#include("+this._options.remappedVariables.join(",")+")":ze.a.IncludesShadersStore.shadowMapVertexMetric,O=this._options&&this._options.remappedVariables?"#include("+this._options.remappedVariables.join(",")+")":ze.a.IncludesShadersStore.shadowMapFragmentSoftTransparentShadow,B=ze.a.IncludesShadersStore.shadowMapFragment;d=(d=(d=(d=d.replace(/void\s+?main/g,ze.a.IncludesShadersStore.shadowMapVertexDeclaration+`\r +void main`)).replace(/#define SHADOWDEPTH_NORMALBIAS|#define CUSTOM_VERTEX_UPDATE_WORLDPOS/g,b)).indexOf("#define SHADOWDEPTH_METRIC")!==-1?d.replace(/#define SHADOWDEPTH_METRIC/g,P):d.replace(/}\s*$/g,P+`\r +}`)).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 +`,p=p.replace(/void\s+?main/g,ze.a.IncludesShadersStore.shadowMapFragmentDeclaration+`\r +void main`),z?p=p.replace(/#define SHADOWDEPTH_FRAGMENT/g,B):J+=B+`\r +`,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+` +`+o.defines.replace("#define SHADOWS","").replace(/#define SHADOW\d/g,""),indexParameters:o.getIndexParameters()},this._scene.getEngine()),a.depthEffect},r}(),dd=f(101);function bc(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 b=3*a.num_faces(),P=4*b,O=r._malloc(P);try{d.GetTrianglesUInt32Array(a,P,O);var B=new Uint32Array(b);B.set(new Uint32Array(r.HEAPF32.buffer,O,b)),n(B)}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,Re=r._malloc(Te);try{d.GetAttributeDataArrayForAllPoints(a,ce,r.DT_FLOAT32,Te,Re);var Ae=new Float32Array(r.HEAPF32.buffer,Re,ve);if(se==="color"&&ue===3){for(var Ee=new Float32Array(4*fe),Se=0,Le=0;Ser.EPSILON?1:0;d|=b,p.push(b)}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=[],B=[];for(a=0;a=3&&(P=new yc(O,t.shared)).plane&&i.push(P),B.length>=3&&(P=new yc(B,t.shared)).plane&&o.push(P)}},r.EPSILON=1e-5,r}(),yc=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}(),$n=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;t1)?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,b=s===1?p/a:p/(a-1),P=0,O=0;Oe.x&&(e.x=n.x),n.ye.y&&(e.y=n.y)}),{min:t,max:e,width:e.x-t.x,height:e.y-t.y}},r}(),Em=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;d0){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(b=0;ba.elements.length-1?a.elements[0]:a.elements[P+1],t.push(B.x,0,B.y),t.push(B.x,-s,B.y),t.push(O.x,0,O.y),t.push(O.x,-s,O.y);var F=new u.e(B.x,0,B.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(b/o.width,0),n.push(b/o.width,1),b+=z.length(),n.push(b/o.width,0),n.push(b/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=[],b=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(Oe.b.PositionKind),B=r.getVerticesData(Oe.b.NormalKind),F=r.getVerticesData(Oe.b.UVKind),z=r.getIndices(),J=O.length/9,ie=0,se=0,ce=0,ue=0,fe=[0];if(b)for(var ve=J;ve1?1:e.arc:1,a=e.closed===void 0||e.closed,s=e.shape,d=e.radius||1,p=e.tessellation||64,b=e.clip||0,P=e.updatable,O=De.a._GetDefaultSideOrientation(e.sideOrientation),B=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-b;ie++){for(ue=[],B!=De.a.CAP_START&&B!=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;se0||P>0){switch(J=-O,ie=-B,se=O,ce=B,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=[],Re=[],Ae=[],Ee=0,Se=0;Se0||P>0){var xe,Ne,Ie,Fe,Ye=P>0&&(o===De.a.CENTER||o===De.a.TOP),tt=P>0&&(o===De.a.CENTER||o===De.a.BOTTOM),it=d>0&&(i===De.a.CENTER||i===De.a.RIGHT),lt=d>0&&(i===De.a.CENTER||i===De.a.LEFT),Qe=[];if(Ye&&it&&(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),Ae.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),Re.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)),Ye&<&&(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),Ae.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),Re.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)),tt&&it&&(ue.push(J+F,B+z,0),ue.push(-O+F,B+z,0),ue.push(-O+F,ce+z,0),ue.push(J+F,ce+z,0),Ae.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&&b%2==1||t===De.a.ROTATE_TILE&&b%1==0)&&(Qe=[1-xe,1-Ne,1-Ie,1-Ne,1-Ie,1-Fe,1-xe,1-Fe]),(t===De.a.FLIP_ROW&&b%2==1||t===De.a.FLIP_TILE&&b%2==0)&&(Qe=[1-xe,Ne,1-Ie,Ne,1-Ie,Fe,1-xe,Fe]),(t===De.a.FLIP_N_ROTATE_ROW&&b%2==1||t===De.a.FLIP_N_ROTATE_TILE&&b%2==0)&&(Qe=[xe,1-Ne,Ie,1-Ne,Ie,1-Fe,xe,1-Fe]),Te=Te.concat(Qe),Re.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)),tt&<&&(ue.push(O+F,B+z,0),ue.push(se+F,B+z,0),ue.push(se+F,ce+z,0),ue.push(O+F,ce+z,0),Ae.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&&b%2==1||t===De.a.ROTATE_TILE&&(b+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&&b%2==1||t===De.a.FLIP_TILE&&(b+s)%2==1)&&(Qe=[1-xe,Ne,1-Ie,Ne,1-Ie,Fe,1-xe,Fe]),(t===De.a.FLIP_N_ROTATE_ROW&&b%2==1||t===De.a.FLIP_N_ROTATE_TILE&&(b+s)%2==1)&&(Qe=[xe,1-Ne,Ie,1-Ne,Ie,1-Fe,xe,1-Fe]),Te=Te.concat(Qe),Re.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)),Ye){var ot=[];for(xe=0,Ne=1-P/n,Ie=1,Fe=1,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;Le1)?1:e.arc||1;var B,F,z=function(ce,ue,fe,ve,Te,Re,Ae,Ee){for(var Se,Le,xe,Ne,Ie=ue.getTangents(),Fe=ue.getNormals(),Ye=ue.getDistances(),tt=2*Math.PI/Te*Ee,it=Re||function(){return ve},lt=u.c.Matrix[0],Qe=Ae===De.a.NO_CAP||Ae===De.a.CAP_END?0:2,ot=0;ot3?0:p,e.arc);var se=Ao.a.CreateRibbon(t,{pathArray:F,closePath:!0,closeArray:!1,updatable:P,sideOrientation:O,invertUV:b,frontUVs:e.frontUVs,backUVs:e.backUVs},n);return se._creationDataStorage.pathArray=F,se._creationDataStorage.path3D=B,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,b=[-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],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],B=[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(b[3*O[Te]],b[3*O[Te]+1],b[3*O[Te]+2]),ue[t].normalize().scaleInPlace(n),fe[t].copyFromFloats(B[2*Te]*(138/1024)+60/1024+F[ve]*(-40/1024),B[2*Te+1]*(239/1024)+26/1024+F[ve]*(20/1024))}for(var Re=function(Le,xe,Ne,Ie){var Fe,Ye=u.e.Lerp(ue[0],ue[2],xe/o),tt=u.e.Lerp(ue[1],ue[2],xe/o),it=o===xe?ue[2]:u.e.Lerp(Ye,tt,Le/(o-xe));if(it.normalize(),i){var lt=u.e.Lerp(ue[0],ue[2],Ie/o),Qe=u.e.Lerp(ue[1],ue[2],Ie/o);Fe=u.e.Lerp(lt,Qe,Ne/(o-Ie))}else Fe=new u.e(it.x,it.y,it.z);Fe.x/=a,Fe.y/=s,Fe.z/=d,Fe.normalize();var ot=u.d.Lerp(fe[0],fe[2],xe/o),rt=u.d.Lerp(fe[1],fe[2],xe/o),Ze=o===xe?fe[2]:u.d.Lerp(ot,rt,Le/(o-xe));J.push(it.x*a,it.y*s,it.z*d),ie.push(Fe.x,Fe.y,Fe.z),se.push(Ze.x,Ze.y),z.push(ce),ce++},Ae=0;Ae0)?1:0)+((lt=u.e.Dot(xe[tt+1].position,Ne)-Ie>0)?1:0)+((Qe=u.e.Dot(xe[tt+2].position,Ne)-Ie>0)?1:0)){case 0:Ye.push(xe[tt]),Ye.push(xe[tt+1]),Ye.push(xe[tt+2]);break;case 1:if(it&&(ot=xe[tt+1],rt=xe[tt+2],Ze=Fe(xe[tt],ot),dt=Fe(xe[tt],rt)),lt){ot=xe[tt],rt=xe[tt+2],Ze=Fe(xe[tt+1],ot),dt=Fe(xe[tt+1],rt),Ye.push(Ze),Ye.push(rt.clone()),Ye.push(ot.clone()),Ye.push(rt.clone()),Ye.push(Ze.clone()),Ye.push(dt);break}Qe&&(ot=xe[tt],rt=xe[tt+1],Ze=Fe(xe[tt+2],ot),dt=Fe(xe[tt+2],rt)),ot&&rt&&Ze&&dt&&(Ye.push(ot.clone()),Ye.push(rt.clone()),Ye.push(Ze),Ye.push(dt),Ye.push(Ze.clone()),Ye.push(rt.clone()));break;case 2:it||(rt=Fe(ot=xe[tt].clone(),xe[tt+1]),Ze=Fe(ot,xe[tt+2]),Ye.push(ot),Ye.push(rt),Ye.push(Ze)),lt||(rt=Fe(ot=xe[tt+1].clone(),xe[tt+2]),Ze=Fe(ot,xe[tt]),Ye.push(ot),Ye.push(rt),Ye.push(Ze)),Qe||(rt=Fe(ot=xe[tt+2].clone(),xe[tt]),Ze=Fe(ot,xe[tt+1]),Ye.push(ot),Ye.push(rt),Ye.push(Ze))}}return Ye},Re=0;ReO||z.deleted||z.isDirty)){for(var J=0;J<3;++J)if(z.error[J]>0,function(b){if(o){var P=b+s.verticesStart,O=u.e.FromArray(o,3*P),B=function(F){if(n){for(var z=0;z0&&this._reconstructedMesh.setVerticesData(Oe.b.NormalKind,s),d.length>0&&this._reconstructedMesh.setVerticesData(Oe.b.UVKind,d),p.length>0&&this._reconstructedMesh.setVerticesData(Oe.b.ColorKind,p);var ue=this._mesh.subMeshes[t];t>0&&(this._reconstructedMesh.subMeshes=[],ie.forEach(function(fe){Eo.a.AddToMesh(fe.materialIndex,fe.verticesStart,fe.verticesCount,fe.indexStart,fe.indexCount,fe.getMesh())}),Eo.a.AddToMesh(ue.materialIndex,J,B,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.999)return!0;var B=u.e.Cross(P,O).normalize();if(i[a]=!1,u.e.Dot(B,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=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 Oe.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 Oe.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.instancesCount):!((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-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=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=ha.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}(),Rc=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}(),Ad=function(r,t){this.gradient=r,this.color=t},Oc=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}(),In=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=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}(),Pd=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>0&&this._attachedSubEmitters.forEach(function(e){t._inheritParticleInfoToSubEmitter(e)})},r.prototype._reset=function(){this.age=0,this.id=r._Count++,this._currentColorGradient=null,this._currentSizeGradient=null,this._currentAngularSpeedGradient=null,this._currentVelocityGradient=null,this._currentLimitVelocityGradient=null,this._currentDragGradient=null,this.cellIndex=this.particleSystem.startSpriteCellID,this._randomCellOffset=void 0},r.prototype.copyTo=function(t){t.position.copyFrom(this.position),this._initialDirection?t._initialDirection?t._initialDirection.copyFrom(this._initialDirection):t._initialDirection=this._initialDirection.clone():t._initialDirection=null,t.direction.copyFrom(this.direction),this._localPosition&&(t._localPosition?t._localPosition.copyFrom(this._localPosition):t._localPosition=this._localPosition.clone()),t.color.copyFrom(this.color),t.colorStep.copyFrom(this.colorStep),t.lifeTime=this.lifeTime,t.age=this.age,t._randomCellOffset=this._randomCellOffset,t.size=this.size,t.scale.copyFrom(this.scale),t.angle=this.angle,t.angularSpeed=this.angularSpeed,t.particleSystem=this.particleSystem,t.cellIndex=this.cellIndex,t.id=this.id,t._attachedSubEmitters=this._attachedSubEmitters,this._currentColorGradient&&(t._currentColorGradient=this._currentColorGradient,t._currentColor1.copyFrom(this._currentColor1),t._currentColor2.copyFrom(this._currentColor2)),this._currentSizeGradient&&(t._currentSizeGradient=this._currentSizeGradient,t._currentSize1=this._currentSize1,t._currentSize2=this._currentSize2),this._currentAngularSpeedGradient&&(t._currentAngularSpeedGradient=this._currentAngularSpeedGradient,t._currentAngularSpeed1=this._currentAngularSpeed1,t._currentAngularSpeed2=this._currentAngularSpeed2),this._currentVelocityGradient&&(t._currentVelocityGradient=this._currentVelocityGradient,t._currentVelocity1=this._currentVelocity1,t._currentVelocity2=this._currentVelocity2),this._currentLimitVelocityGradient&&(t._currentLimitVelocityGradient=this._currentLimitVelocityGradient,t._currentLimitVelocity1=this._currentLimitVelocity1,t._currentLimitVelocity2=this._currentLimitVelocity2),this._currentDragGradient&&(t._currentDragGradient=this._currentDragGradient,t._currentDrag1=this._currentDrag1,t._currentDrag2=this._currentDrag2),this.particleSystem.isAnimationSheetEnabled&&(t._initialStartSpriteCellID=this._initialStartSpriteCellID,t._initialEndSpriteCellID=this._initialEndSpriteCellID),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"})(Fr||(Fr={}));var Co=function(){function r(t){if(this.particleSystem=t,this.type=Fr.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 An.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}(),Im=` +varying vec2 vUV; +varying vec4 vColor; +uniform vec4 textureMask; +uniform sampler2D diffuseSampler; +#include +#include +#include +#include +#ifdef RAMPGRADIENT +varying vec4 remapRanges; +uniform sampler2D rampSampler; +#endif +void main(void) { +#include +vec4 textureColor=texture2D(diffuseSampler,vUV); +vec4 baseColor=(textureColor*textureMask+(vec4(1.,1.,1.,1.)-textureMask))*vColor; +#ifdef RAMPGRADIENT +float alpha=baseColor.a; +float remappedColorIndex=clamp((alpha-remapRanges.x)/remapRanges.y,0.0,1.0); +vec4 rampColor=texture2D(rampSampler,vec2(1.0-remappedColorIndex,0.)); +baseColor.rgb*=rampColor.rgb; + +float finalAlpha=baseColor.a; +baseColor.a=clamp((alpha*rampColor.a-remapRanges.z)/remapRanges.w,0.0,1.0); +#endif +#ifdef BLENDMULTIPLYMODE +float sourceAlpha=vColor.a*textureColor.a; +baseColor.rgb=baseColor.rgb*sourceAlpha+vec3(1.0)*(1.0-sourceAlpha); +#endif + + +#ifdef IMAGEPROCESSINGPOSTPROCESS +baseColor.rgb=toLinearSpace(baseColor.rgb); +#else +#ifdef IMAGEPROCESSING +baseColor.rgb=toLinearSpace(baseColor.rgb); +baseColor=applyImageProcessing(baseColor); +#endif +#endif +gl_FragColor=baseColor; +}`;ze.a.ShadersStore.particlesPixelShader=Im;var Dm=` +attribute vec3 position; +attribute vec4 color; +attribute float angle; +attribute vec2 size; +#ifdef ANIMATESHEET +attribute float cellIndex; +#endif +#ifndef BILLBOARD +attribute vec3 direction; +#endif +#ifdef BILLBOARDSTRETCHED +attribute vec3 direction; +#endif +#ifdef RAMPGRADIENT +attribute vec4 remapData; +#endif +attribute vec2 offset; + +uniform mat4 view; +uniform mat4 projection; +uniform vec2 translationPivot; +#ifdef ANIMATESHEET +uniform vec3 particlesInfos; +#endif + +varying vec2 vUV; +varying vec4 vColor; +varying vec3 vPositionW; +#ifdef RAMPGRADIENT +varying vec4 remapRanges; +#endif +#if defined(BILLBOARD) && !defined(BILLBOARDY) && !defined(BILLBOARDSTRETCHED) +uniform mat4 invView; +#endif +#include +#ifdef BILLBOARD +uniform vec3 eyePosition; +#endif +vec3 rotate(vec3 yaxis,vec3 rotatedCorner) { +vec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis)); +vec3 zaxis=normalize(cross(yaxis,xaxis)); +vec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z); +vec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z); +vec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z); +mat3 rotMatrix=mat3(row0,row1,row2); +vec3 alignedCorner=rotMatrix*rotatedCorner; +return position+alignedCorner; +} +#ifdef BILLBOARDSTRETCHED +vec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) { +vec3 normalizedToCamera=normalize(toCamera); +vec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera)); +vec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera)); +vec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z); +vec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z); +vec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z); +mat3 rotMatrix=mat3(row0,row1,row2); +vec3 alignedCorner=rotMatrix*rotatedCorner; +return position+alignedCorner; +} +#endif +void main(void) { +vec2 cornerPos; +cornerPos=(vec2(offset.x-0.5,offset.y-0.5)-translationPivot)*size+translationPivot; +#ifdef BILLBOARD + +vec3 rotatedCorner; +#ifdef BILLBOARDY +rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle); +rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle); +rotatedCorner.y=0.; +vec3 yaxis=position-eyePosition; +yaxis.y=0.; +vPositionW=rotate(normalize(yaxis),rotatedCorner); +vec3 viewPos=(view*vec4(vPositionW,1.0)).xyz; +#elif defined(BILLBOARDSTRETCHED) +rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle); +rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle); +rotatedCorner.z=0.; +vec3 toCamera=position-eyePosition; +vPositionW=rotateAlign(toCamera,rotatedCorner); +vec3 viewPos=(view*vec4(vPositionW,1.0)).xyz; +#else +rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle); +rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle); +rotatedCorner.z=0.; +vec3 viewPos=(view*vec4(position,1.0)).xyz+rotatedCorner; +vPositionW=(invView*vec4(viewPos,1)).xyz; +#endif +#ifdef RAMPGRADIENT +remapRanges=remapData; +#endif + +gl_Position=projection*vec4(viewPos,1.0); +#else + +vec3 rotatedCorner; +rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle); +rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle); +rotatedCorner.y=0.; +vec3 yaxis=normalize(direction); +vPositionW=rotate(yaxis,rotatedCorner); +gl_Position=projection*view*vec4(vPositionW,1.0); +#endif +vColor=color; +#ifdef ANIMATESHEET +float rowOffset=floor(cellIndex*particlesInfos.z); +float columnOffset=cellIndex-rowOffset/particlesInfos.z; +vec2 uvScale=particlesInfos.xy; +vec2 uvOffset=vec2(offset.x ,1.0-offset.y); +vUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale; +#else +vUV=offset; +#endif + +#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6) +vec4 worldPos=vec4(vPositionW,1.0); +#endif +#include +}`;ze.a.ShadersStore.particlesVertexShader=Dm;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 C.c,d.onStoppedObservable=new C.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 b=d._particles.pop();b!==p&&b.copyTo(p),d._stockParticles.push(b)},d._createParticle=function(){var p;if(d._stockParticles.length!==0?(p=d._stockParticles.pop())._reset():p=new Pd(d),d._subEmitters&&d._subEmitters.length>0){var b=d._subEmitters[Math.floor(Math.random()*d._subEmitters.length)];p._attachedSubEmitters=[],b.forEach(function(P){if(P.type===Fr.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 b=Math.floor(Math.random()*d._subEmitters.length);d._subEmitters[b].forEach(function(P){if(P.type===Fr.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 Nr,d.updateFunction=function(p){var b=null,P=null;d.noiseTexture&&(b=d.noiseTexture.getSize(),P=d.noiseTexture.getContent());for(var O,B=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?In.GetCurrentGradient(se,d._colorGradients,function(Ae,Ee,Se){Ae!==O._currentColorGradient&&(O._currentColor1.copyFrom(O._currentColor2),Ee.getColorToRef(O._currentColor2),O._currentColorGradient=Ae),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&&In.GetCurrentGradient(se,d._angularSpeedGradients,function(Ae,Ee,Se){Ae!==O._currentAngularSpeedGradient&&(O._currentAngularSpeed1=O._currentAngularSpeed2,O._currentAngularSpeed2=Ee.getFactor(),O._currentAngularSpeedGradient=Ae),O.angularSpeed=$.a.Lerp(O._currentAngularSpeed1,O._currentAngularSpeed2,Se)}),O.angle+=O.angularSpeed*z;var ce=z;if(d._velocityGradients&&d._velocityGradients.length>0&&In.GetCurrentGradient(se,d._velocityGradients,function(Ae,Ee,Se){Ae!==O._currentVelocityGradient&&(O._currentVelocity1=O._currentVelocity2,O._currentVelocity2=Ee.getFactor(),O._currentVelocityGradient=Ae),ce*=$.a.Lerp(O._currentVelocity1,O._currentVelocity2,Se)}),O.direction.scaleToRef(ce,d._scaledDirection),d._limitVelocityGradients&&d._limitVelocityGradients.length>0&&In.GetCurrentGradient(se,d._limitVelocityGradients,function(Ae,Ee,Se){Ae!==O._currentLimitVelocityGradient&&(O._currentLimitVelocity1=O._currentLimitVelocity2,O._currentLimitVelocity2=Ee.getFactor(),O._currentLimitVelocityGradient=Ae);var Le=$.a.Lerp(O._currentLimitVelocity1,O._currentLimitVelocity2,Se);O.direction.length()>Le&&O.direction.scaleInPlace(d.limitVelocityDamping)}),d._dragGradients&&d._dragGradients.length>0&&In.GetCurrentGradient(se,d._dragGradients,function(Ae,Ee,Se){Ae!==O._currentDragGradient&&(O._currentDrag1=O._currentDrag2,O._currentDrag2=Ee.getFactor(),O._currentDragGradient=Ae);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&&b&&O._randomNoiseCoordinates1){var ue=d._fetchR(O._randomNoiseCoordinates1.x,O._randomNoiseCoordinates1.y,b.width,b.height,P),fe=d._fetchR(O._randomNoiseCoordinates1.z,O._randomNoiseCoordinates2.x,b.width,b.height,P),ve=d._fetchR(O._randomNoiseCoordinates2.y,O._randomNoiseCoordinates2.z,b.width,b.height,P),Te=u.c.Vector3[0],Re=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,Re),O.direction.addInPlace(Re)}if(d.gravity.scaleToRef(z,d._scaledGravity),O.direction.addInPlace(d._scaledGravity),d._sizeGradients&&d._sizeGradients.length>0&&In.GetCurrentGradient(se,d._sizeGradients,function(Ae,Ee,Se){Ae!==O._currentSizeGradient&&(O._currentSize1=O._currentSize2,O._currentSize2=Ee.getFactor(),O._currentSizeGradient=Ae),O.size=$.a.Lerp(O._currentSize1,O._currentSize2,Se)}),d._useRampGradients&&(d._colorRemapGradients&&d._colorRemapGradients.length>0&&In.GetCurrentGradient(se,d._colorRemapGradients,function(Ae,Ee,Se){var Le=$.a.Lerp(Ae.factor1,Ee.factor1,Se),xe=$.a.Lerp(Ae.factor2,Ee.factor2,Se);O.remapData.x=Le,O.remapData.y=xe-Le}),d._alphaRemapGradients&&d._alphaRemapGradients.length>0&&In.GetCurrentGradient(se,d._alphaRemapGradients,function(Ae,Ee,Se){var Le=$.a.Lerp(Ae.factor1,Ee.factor1,Se),xe=$.a.Lerp(Ae.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(Ae){Ae.particleSystem.disposeOnStop=!0,Ae.particleSystem.stop()}),O._attachedSubEmitters=null),d.recycleParticle(O),F--,"continue"},F=0;Fd.gradient?1:0})},t.prototype._removeFactorGradient=function(e,n){if(e)for(var i=0,o=0,a=e;on.gradient?1:0}),this._rampGradientsTexture&&(this._rampGradientsTexture.dispose(),this._rampGradientsTexture=null),this._createRampGradientTexture())},t.prototype.addRampGradient=function(e,n){this._rampGradients||(this._rampGradients=[]);var i=new Ad(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 Rc(e,n,i);return this._colorGradients.push(o),this._colorGradients.sort(function(a,s){return a.gradients.gradient?1:0}),this},t.prototype.removeColorGradient=function(e){if(!this._colorGradients)return this;for(var n=0,i=0,o=this._colorGradients;i0&&(this._currentEmitRateGradient=this._emitRateGradients[0],this._currentEmitRate1=this._currentEmitRateGradient.getFactor(),this._currentEmitRate2=this._currentEmitRate1),this._emitRateGradients.length>1&&(this._currentEmitRate2=this._emitRateGradients[1].getFactor())),this._startSizeGradients&&(this._startSizeGradients.length>0&&(this._currentStartSizeGradient=this._startSizeGradients[0],this._currentStartSize1=this._currentStartSizeGradient.getFactor(),this._currentStartSize2=this._currentStartSize1),this._startSizeGradients.length>1&&(this._currentStartSize2=this._startSizeGradients[1].getFactor())),this.preWarmCycles){((n=this.emitter)===null||n===void 0?void 0:n.getClassName().indexOf("Mesh"))!==-1&&this.emitter.computeWorldMatrix(!0);var o=this.noiseTexture;if(o&&o.onGeneratedObservable)o.onGeneratedObservable.addOnce(function(){setTimeout(function(){for(var s=0;s0&&this._scene&&this._scene.beginAnimation(this,this.beginAnimationFrom,this.beginAnimationTo,this.beginAnimationLoop)}},t.prototype.stop=function(e){e===void 0&&(e=!0),this._stopped||(this.onStoppedObservable.notifyObservers(this),this._stopped=!0,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);In.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 B=p._actualFrame/p.targetStopDuration;In.GetCurrentGradient(B,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.copyFromFloats(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,b=0;b-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;In.GetCurrentGradient(s,this._emitRateGradients,function(P,O,B){P!==i._currentEmitRateGradient&&(i._currentEmitRate1=i._currentEmitRate2,i._currentEmitRate2=O.getFactor(),i._currentEmitRateGradient=P),a=$.a.Lerp(i._currentEmitRate1,i._currentEmitRate2,B)})}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=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.bindVertexArrayObject(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-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(` +`):"";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;i0?p.shaderOptions.defines.join(` +`):"";d=a.createEffectForParticles(p.shaderPath.fragmentElement,p.shaderOptions.uniforms,p.shaderOptions.samplers,b)}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,B=e.subEmitters;O=life && stopFactor != 0.) { +vec3 newPosition; +vec3 newDirection; + +vec4 randoms=getRandomVec4(seed.x); + +outLife=lifeTime.x+(lifeTime.y-lifeTime.x)*randoms.r; +outAge=newAge-life; + +outSeed=seed; + +#ifdef SIZEGRADIENTS +outSize.x=texture(sizeGradientSampler,vec2(0,0)).r; +#else +outSize.x=sizeRange.x+(sizeRange.y-sizeRange.x)*randoms.g; +#endif +outSize.y=scaleRange.x+(scaleRange.y-scaleRange.x)*randoms.b; +outSize.z=scaleRange.z+(scaleRange.w-scaleRange.z)*randoms.a; +#ifndef COLORGRADIENTS + +outColor=color1+(color2-color1)*randoms.b; +#endif + +#ifndef ANGULARSPEEDGRADIENTS +outAngle.y=angleRange.x+(angleRange.y-angleRange.x)*randoms.a; +outAngle.x=angleRange.z+(angleRange.w-angleRange.z)*randoms.r; +#else +outAngle=angleRange.z+(angleRange.w-angleRange.z)*randoms.r; +#endif + +#ifdef POINTEMITTER +vec3 randoms2=getRandomVec3(seed.y); +vec3 randoms3=getRandomVec3(seed.z); +newPosition=vec3(0,0,0); +newDirection=direction1+(direction2-direction1)*randoms3; +#elif defined(BOXEMITTER) +vec3 randoms2=getRandomVec3(seed.y); +vec3 randoms3=getRandomVec3(seed.z); +newPosition=minEmitBox+(maxEmitBox-minEmitBox)*randoms2; +newDirection=direction1+(direction2-direction1)*randoms3; +#elif defined(HEMISPHERICEMITTER) +vec3 randoms2=getRandomVec3(seed.y); +vec3 randoms3=getRandomVec3(seed.z); + +float phi=2.0*PI*randoms2.x; +float theta=acos(2.0*randoms2.y-1.0); +float randX=cos(phi)*sin(theta); +float randY=cos(theta); +float randZ=sin(phi)*sin(theta); +newPosition=(radius-(radius*radiusRange*randoms2.z))*vec3(randX,abs(randY),randZ); +newDirection=newPosition+directionRandomizer*randoms3; +#elif defined(SPHEREEMITTER) +vec3 randoms2=getRandomVec3(seed.y); +vec3 randoms3=getRandomVec3(seed.z); + +float phi=2.0*PI*randoms2.x; +float theta=acos(2.0*randoms2.y-1.0); +float randX=cos(phi)*sin(theta); +float randY=cos(theta); +float randZ=sin(phi)*sin(theta); +newPosition=(radius-(radius*radiusRange*randoms2.z))*vec3(randX,randY,randZ); +#ifdef DIRECTEDSPHEREEMITTER +newDirection=direction1+(direction2-direction1)*randoms3; +#else + +newDirection=newPosition+directionRandomizer*randoms3; +#endif +#elif defined(CYLINDEREMITTER) +vec3 randoms2=getRandomVec3(seed.y); +vec3 randoms3=getRandomVec3(seed.z); + +float yPos=(randoms2.x-0.5)*height; +float angle=randoms2.y*PI*2.; +float inverseRadiusRangeSquared=((1.-radiusRange)*(1.-radiusRange)); +float positionRadius=radius*sqrt(inverseRadiusRangeSquared+(randoms2.z*(1.-inverseRadiusRangeSquared))); +float xPos=positionRadius*cos(angle); +float zPos=positionRadius*sin(angle); +newPosition=vec3(xPos,yPos,zPos); +#ifdef DIRECTEDCYLINDEREMITTER +newDirection=direction1+(direction2-direction1)*randoms3; +#else + +angle=angle+((randoms3.x-0.5)*PI); +newDirection=vec3(cos(angle),randoms3.y-0.5,sin(angle)); +newDirection=normalize(newDirection); +#endif +#elif defined(CONEEMITTER) +vec3 randoms2=getRandomVec3(seed.y); +float s=2.0*PI*randoms2.x; +#ifdef CONEEMITTERSPAWNPOINT +float h=0.0001; +#else +float h=randoms2.y*height.y; + +h=1.-h*h; +#endif +float lRadius=radius.x-radius.x*randoms2.z*radius.y; +lRadius=lRadius*h; +float randX=lRadius*sin(s); +float randZ=lRadius*cos(s); +float randY=h*height.x; +newPosition=vec3(randX,randY,randZ); + +if (abs(cos(coneAngle)) == 1.0) { +newDirection=vec3(0.,1.0,0.); +} else { +vec3 randoms3=getRandomVec3(seed.z); +newDirection=normalize(newPosition+directionRandomizer*randoms3); +} +#elif defined(CUSTOMEMITTER) +newPosition=initialPosition; +outInitialPosition=initialPosition; +#else + +newPosition=vec3(0.,0.,0.); + +newDirection=2.0*(getRandomVec3(seed.w)-vec3(0.5,0.5,0.5)); +#endif +float power=emitPower.x+(emitPower.y-emitPower.x)*randoms.a; +#ifdef LOCAL +outPosition=newPosition; +#else +outPosition=(emitterWM*vec4(newPosition,1.)).xyz; +#endif +#ifdef CUSTOMEMITTER +outDirection=direction; +#ifndef BILLBOARD +outInitialDirection=direction; +#endif +#else +#ifdef LOCAL +vec3 initial=newDirection; +#else +vec3 initial=(emitterWM*vec4(newDirection,0.)).xyz; +#endif +outDirection=initial*power; +#ifndef BILLBOARD +outInitialDirection=initial; +#endif +#endif +#ifdef ANIMATESHEET +outCellIndex=cellInfos.x; +#ifdef ANIMATESHEETRANDOMSTART +outCellStartOffset=randoms.a*outLife; +#endif +#endif +#ifdef NOISE +outNoiseCoordinates1=noiseCoordinates1; +outNoiseCoordinates2=noiseCoordinates2; +#endif +} else { +float directionScale=timeDelta; +outAge=newAge; +float ageGradient=newAge/life; +#ifdef VELOCITYGRADIENTS +directionScale*=texture(velocityGradientSampler,vec2(ageGradient,0)).r; +#endif +#ifdef DRAGGRADIENTS +directionScale*=1.0-texture(dragGradientSampler,vec2(ageGradient,0)).r; +#endif +#if defined(CUSTOMEMITTER) +outPosition=position+(direction-position)*ageGradient; +outInitialPosition=initialPosition; +#else +outPosition=position+direction*directionScale; +#endif +outLife=life; +outSeed=seed; +#ifndef COLORGRADIENTS +outColor=color; +#endif +#ifdef SIZEGRADIENTS +outSize.x=texture(sizeGradientSampler,vec2(ageGradient,0)).r; +outSize.yz=size.yz; +#else +outSize=size; +#endif +#ifndef BILLBOARD +outInitialDirection=initialDirection; +#endif +#ifdef CUSTOMEMITTER +outDirection=direction; +#else +vec3 updatedDirection=direction+gravity*timeDelta; +#ifdef LIMITVELOCITYGRADIENTS +float limitVelocity=texture(limitVelocityGradientSampler,vec2(ageGradient,0)).r; +float currentVelocity=length(updatedDirection); +if (currentVelocity>limitVelocity) { +updatedDirection=updatedDirection*limitVelocityDamping; +} +#endif +outDirection=updatedDirection; +#ifdef NOISE +float fetchedR=texture(noiseSampler,vec2(noiseCoordinates1.x,noiseCoordinates1.y)*vec2(0.5)+vec2(0.5)).r; +float fetchedG=texture(noiseSampler,vec2(noiseCoordinates1.z,noiseCoordinates2.x)*vec2(0.5)+vec2(0.5)).r; +float fetchedB=texture(noiseSampler,vec2(noiseCoordinates2.y,noiseCoordinates2.z)*vec2(0.5)+vec2(0.5)).r; +vec3 force=vec3(2.*fetchedR-1.,2.*fetchedG-1.,2.*fetchedB-1.)*noiseStrength; +outDirection=outDirection+force*timeDelta; +outNoiseCoordinates1=noiseCoordinates1; +outNoiseCoordinates2=noiseCoordinates2; +#endif +#endif +#ifdef ANGULARSPEEDGRADIENTS +float angularSpeed=texture(angularSpeedGradientSampler,vec2(ageGradient,0)).r; +outAngle=angle+angularSpeed*timeDelta; +#else +outAngle=vec2(angle.x+angle.y*timeDelta,angle.y); +#endif +#ifdef ANIMATESHEET +float offsetAge=outAge; +float dist=cellInfos.y-cellInfos.x; +#ifdef ANIMATESHEETRANDOMSTART +outCellStartOffset=cellStartOffset; +offsetAge+=cellStartOffset; +#else +float cellStartOffset=0.; +#endif +float ratio=clamp(mod(cellStartOffset+cellInfos.z*offsetAge,life)/life,0.,1.0); +outCellIndex=float(int(cellInfos.x+ratio*dist)); +#endif +} +}`;ze.a.ShadersStore.gpuUpdateParticlesVertexShader=Lm;var Nm=`#ifdef CLIPPLANE +in float fClipDistance; +#endif +#ifdef CLIPPLANE2 +in float fClipDistance2; +#endif +#ifdef CLIPPLANE3 +in float fClipDistance3; +#endif +#ifdef CLIPPLANE4 +in float fClipDistance4; +#endif +#ifdef CLIPPLANE5 +in float fClipDistance5; +#endif +#ifdef CLIPPLANE6 +in float fClipDistance6; +#endif`;ze.a.IncludesShadersStore.clipPlaneFragmentDeclaration2=Nm;var wm=`#version 300 es +uniform sampler2D diffuseSampler; +in vec2 vUV; +in vec4 vColor; +out vec4 outFragColor; +#include +#include +#include +#include +void main() { +#include +vec4 textureColor=texture(diffuseSampler,vUV); +outFragColor=textureColor*vColor; +#ifdef BLENDMULTIPLYMODE +float alpha=vColor.a*textureColor.a; +outFragColor.rgb=outFragColor.rgb*alpha+vec3(1.0)*(1.0-alpha); +#endif + + +#ifdef IMAGEPROCESSINGPOSTPROCESS +outFragColor.rgb=toLinearSpace(outFragColor.rgb); +#else +#ifdef IMAGEPROCESSING +outFragColor.rgb=toLinearSpace(outFragColor.rgb); +outFragColor=applyImageProcessing(outFragColor); +#endif +#endif +} +`;ze.a.ShadersStore.gpuRenderParticlesPixelShader=wm;var Fm=`#ifdef CLIPPLANE +uniform vec4 vClipPlane; +out float fClipDistance; +#endif +#ifdef CLIPPLANE2 +uniform vec4 vClipPlane2; +out float fClipDistance2; +#endif +#ifdef CLIPPLANE3 +uniform vec4 vClipPlane3; +out float fClipDistance3; +#endif +#ifdef CLIPPLANE4 +uniform vec4 vClipPlane4; +out float fClipDistance4; +#endif +#ifdef CLIPPLANE5 +uniform vec4 vClipPlane5; +out float fClipDistance5; +#endif +#ifdef CLIPPLANE6 +uniform vec4 vClipPlane6; +out float fClipDistance6; +#endif`;ze.a.IncludesShadersStore.clipPlaneVertexDeclaration2=Fm;var Bm=`#version 300 es +uniform mat4 view; +uniform mat4 projection; +uniform vec2 translationPivot; +uniform vec3 worldOffset; +#ifdef LOCAL +uniform mat4 emitterWM; +#endif + +in vec3 position; +in float age; +in float life; +in vec3 size; +#ifndef BILLBOARD +in vec3 initialDirection; +#endif +#ifdef BILLBOARDSTRETCHED +in vec3 direction; +#endif +in float angle; +#ifdef ANIMATESHEET +in float cellIndex; +#endif +in vec2 offset; +in vec2 uv; +out vec2 vUV; +out vec4 vColor; +out vec3 vPositionW; +#if defined(BILLBOARD) && !defined(BILLBOARDY) && !defined(BILLBOARDSTRETCHED) +uniform mat4 invView; +#endif +#include +#ifdef COLORGRADIENTS +uniform sampler2D colorGradientSampler; +#else +uniform vec4 colorDead; +in vec4 color; +#endif +#ifdef ANIMATESHEET +uniform vec3 sheetInfos; +#endif +#ifdef BILLBOARD +uniform vec3 eyePosition; +#endif +vec3 rotate(vec3 yaxis,vec3 rotatedCorner) { +vec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis)); +vec3 zaxis=normalize(cross(yaxis,xaxis)); +vec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z); +vec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z); +vec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z); +mat3 rotMatrix=mat3(row0,row1,row2); +vec3 alignedCorner=rotMatrix*rotatedCorner; +#ifdef LOCAL +return ((emitterWM*vec4(position,1.0)).xyz+worldOffset)+alignedCorner; +#else +return (position+worldOffset)+alignedCorner; +#endif +} +#ifdef BILLBOARDSTRETCHED +vec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) { +vec3 normalizedToCamera=normalize(toCamera); +vec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera)); +vec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera)); +vec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z); +vec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z); +vec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z); +mat3 rotMatrix=mat3(row0,row1,row2); +vec3 alignedCorner=rotMatrix*rotatedCorner; +#ifdef LOCAL +return ((emitterWM*vec4(position,1.0)).xyz+worldOffset)+alignedCorner; +#else +return (position+worldOffset)+alignedCorner; +#endif +} +#endif +void main() { +#ifdef ANIMATESHEET +float rowOffset=floor(cellIndex/sheetInfos.z); +float columnOffset=cellIndex-rowOffset*sheetInfos.z; +vec2 uvScale=sheetInfos.xy; +vec2 uvOffset=vec2(uv.x ,1.0-uv.y); +vUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale; +#else +vUV=uv; +#endif +float ratio=age/life; +#ifdef COLORGRADIENTS +vColor=texture(colorGradientSampler,vec2(ratio,0)); +#else +vColor=color*vec4(1.0-ratio)+colorDead*vec4(ratio); +#endif +vec2 cornerPos=(offset-translationPivot)*size.yz*size.x+translationPivot; +#ifdef BILLBOARD +vec4 rotatedCorner; +rotatedCorner.w=0.; +#ifdef BILLBOARDY +rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle); +rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle); +rotatedCorner.y=0.; +vec3 yaxis=(position+worldOffset)-eyePosition; +yaxis.y=0.; +vPositionW=rotate(normalize(yaxis),rotatedCorner.xyz); +vec4 viewPosition=(view*vec4(vPositionW,1.0)); +#elif defined(BILLBOARDSTRETCHED) +rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle); +rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle); +rotatedCorner.z=0.; +vec3 toCamera=(position+worldOffset)-eyePosition; +vPositionW=rotateAlign(toCamera,rotatedCorner.xyz); +vec4 viewPosition=(view*vec4(vPositionW,1.0)); +#else + +rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle); +rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle); +rotatedCorner.z=0.; + +#ifdef LOCAL +vec4 viewPosition=view*vec4(((emitterWM*vec4(position,1.0)).xyz+worldOffset),1.0)+rotatedCorner; +#else +vec4 viewPosition=view*vec4((position+worldOffset),1.0)+rotatedCorner; +#endif +vPositionW=(invView*viewPosition).xyz; +#endif +#else + +vec3 rotatedCorner; +rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle); +rotatedCorner.y=0.; +rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle); +vec3 yaxis=normalize(initialDirection); +vPositionW=rotate(yaxis,rotatedCorner); + +vec4 viewPosition=view*vec4(vPositionW,1.0); +#endif +gl_Position=projection*viewPosition; + +#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6) +vec4 worldPos=vec4(vPositionW,1.0); +#endif +#include +}`;ze.a.ShadersStore.gpuRenderParticlesVertexShader=Bm;var ar=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 C.c,s.onStoppedObservable=new C.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 Nr;for(var b=Math.min(s._engine.getCaps().maxTextureSize,d.randomTextureSize),P=[],O=0;O1},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]},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 C.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 Rc(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.gradienti.gradient?1:0}),this._colorGradientsTexture&&(this._colorGradientsTexture.dispose(),this._colorGradientsTexture=null))},t.prototype.forceRefreshGradients=function(){this._refreshColorGradient(),this._refreshFactorGradient(this._sizeGradients,"_sizeGradientsTexture"),this._refreshFactorGradient(this._angularSpeedGradients,"_angularSpeedGradientsTexture"),this._refreshFactorGradient(this._velocityGradients,"_velocityGradientsTexture"),this._refreshFactorGradient(this._limitVelocityGradients,"_limitVelocityGradientsTexture"),this._refreshFactorGradient(this._dragGradients,"_dragGradientsTexture"),this.reset()},t.prototype.removeColorGradient=function(e){return this._removeGradientAndTexture(e,this._colorGradients,this._colorGradientsTexture),this._colorGradientsTexture=null,this},t.prototype._addFactorGradient=function(e,n,i){var o=new Oc(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.gradienta.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},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 wr&&(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 wr&&(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 wr&&(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 wr,a=u.c.Vector3[0],s=0;s=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;a1){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)}if(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 b=this._getEffect();this._engine.enableEffect(b);var P=((n=this._scene)===null||n===void 0?void 0:n.getViewMatrix())||u.a.IdentityReadOnly;if(b.setMatrix("view",P),b.setMatrix("projection",(i=this.defaultProjectionMatrix)!==null&&i!==void 0?i:this._scene.getProjectionMatrix()),b.setTexture("diffuseSampler",this.particleTexture),b.setVector2("translationPivot",this.translationPivot),b.setVector3("worldOffset",this.worldOffset),this.isLocal&&b.setMatrix("emitterWM",s),this._colorGradientsTexture?b.setTexture("colorGradientSampler",this._colorGradientsTexture):b.setDirectColor4("colorDead",this.colorDead),this._isAnimationSheetEnabled&&this.particleTexture){var O=this.particleTexture.getBaseSize();b.setFloat3("sheetInfos",this.spriteCellWidth/O.width,this.spriteCellHeight/O.height,O.width/this.spriteCellWidth)}if(this._isBillboardBased&&this._scene){var B=this._scene.activeCamera;b.setVector3("eyePosition",B.globalPosition)}var F=b.defines;if(this._scene&&(this._scene.clipPlane||this._scene.clipPlane2||this._scene.clipPlane3||this._scene.clipPlane4||this._scene.clipPlane5||this._scene.clipPlane6)&&et.a.BindClipPlane(b,this._scene),F.indexOf("#define BILLBOARDMODE_ALL")>=0){var z=P.clone();z.invert(),b.setMatrix("invView",z)}switch(this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(b),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(b),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-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}(yo),Ea=function(){function r(){this.systems=new Array}return Object.defineProperty(r.prototype,"emitterNode",{get:function(){return this._emitterNode},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=Fn.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;a0&&n.set(this._uvs32,Oe.b.UVKind),this._colors32.length>0&&n.set(this._colors32,Oe.b.ColorKind),n.applyToMesh(this.mesh,this._updatable),this.mesh.isPickable=this._pickable,this._pickable){for(var i=0,o=0;oB?B:i,n=Math.round(B/i),o=0):n=n>B?B:n;for(var F=[],z=[],J=[],ie=[],se=[],ce=u.e.Zero(),ue=n;OB-(n=ue+Math.floor((1+o)*Math.random()))&&(n=B-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],Re=3*Te;if(F.push(a[Re],a[Re+1],a[Re+2]),z.push(b[Re],b[Re+1],b[Re+2]),d){var Ae=2*Te;ie.push(d[Ae],d[Ae+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=Xe.b.Slice(J),Fe=Xe.b.Slice(se),Ye=Xe.b.Slice(z);for(ce.copyFromFloats(0,0,0),Se=0;Se65535&&(this._needs32Bits=!0)}if(this._depthSort||this._multimaterialEnabled){var ot=fe.materialIndex!==null?fe.materialIndex:0;this.depthSortedParticles.push(new xd(B,e,o.length,ot))}return fe},r.prototype._posToShape=function(t){for(var e=[],n=0;n=this.nbParticles||!this._updatable)return[];var i=this.particles,o=this.nbParticles;if(e=this.nbParticles?this.nbParticles-1:e,this._computeBoundingBox&&(t!=0||e!=this.nbParticles-1)){var tt=this.mesh._boundingInfo;tt&&(se.copyFrom(tt.minimum),ce.copyFrom(tt.maximum))}var it=(Le=this.particles[t]._pos)/3|0;Ne=4*it,Fe=2*it;for(var lt=t;lt<=e;lt++){var Qe=this.particles[lt];this.updateParticle(Qe);var ot=Qe._model._shape,rt=Qe._model._shapeUV,Ze=Qe._rotationMatrix,dt=Qe.position,Ve=Qe.rotation,Je=Qe.scaling,yt=Qe._globalPosition;if(this._depthSort&&this._depthSortParticles){var Wt=this.depthSortedParticles[lt];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*(Ye=ot.length),Ne+=4*Ye,Fe+=2*Ye;else{if(Qe.isVisible){Qe._stillInvisible=!1;var Nt=F[12];if(Qe.pivot.multiplyToRef(Je,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;Ze[0]=Et[0]*vt[0]+Et[1]*vt[3]+Et[2]*vt[6],Ze[1]=Et[0]*vt[1]+Et[1]*vt[4]+Et[2]*vt[7],Ze[2]=Et[0]*vt[2]+Et[1]*vt[5]+Et[2]*vt[8],Ze[3]=Et[4]*vt[0]+Et[5]*vt[3]+Et[6]*vt[6],Ze[4]=Et[4]*vt[1]+Et[5]*vt[4]+Et[6]*vt[7],Ze[5]=Et[4]*vt[2]+Et[5]*vt[5]+Et[6]*vt[8],Ze[6]=Et[8]*vt[0]+Et[9]*vt[3]+Et[10]*vt[6],Ze[7]=Et[8]*vt[1]+Et[9]*vt[4]+Et[10]*vt[7],Ze[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,Ze[0]=Et[0],Ze[1]=Et[1],Ze[2]=Et[2],Ze[3]=Et[4],Ze[4]=Et[5],Ze[5]=Et[6],Ze[6]=Et[8],Ze[7]=Et[9],Ze[8]=Et[10]);var Mt=F[11];for(Qe.translateFromPivot?Mt.setAll(0):Mt.copyFrom(Nt),Ye=0;Ye0)for(var e=0;e0&&t.set(this._uvs32,Oe.b.UVKind);var e=0;this._colors32.length>0&&(e=1,t.set(this._colors32,Oe.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 Rd(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],b=s[3],P=o[s[0]],O=o[d],B=o[p],F=o[b];return new M.b(P/255,O/255,B/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(Oe.b.PositionKind),b=t.getIndices(),P=t.getVerticesData(Oe.b.UVKind),O=t.getVerticesData(Oe.b.ColorKind),B=u.e.Zero();t.computeWorldMatrix();var F=t.getWorldMatrix();if(!F.isIdentity())for(var z=0;z1&&(Qi=1),(qi=Kr.b+Xr)<0&&(qi=0),qi>1&&(qi=1),M.a.HSVtoRGBToRef(Yr,Qi,qi,hr),jt.set(hr.r,hr.g,hr.b,1)):jt=qt.set(Math.random(),Math.random(),Math.random(),1),Nn.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,b,P,O,B,F,z,J,ie,se,ce,ue,fe=new Array,ve=u.e.Zero(),Te=u.e.Zero(),Re=u.e.Zero(),Ae=u.e.Zero(),Ee=u.e.Zero(),Se=u.e.Zero(),Le=new Array,xe=0,Ne=n.length/3,Ie=0;Ie0&&(fe=fe.map(function(lt){return lt+tt})),Ie=0;Ie3)&&(a=En.Random);var s=t.getVerticesData(Oe.b.PositionKind),d=t.getIndices();this._groups.push(this._groupCounter);var p=new Sa(this._groupCounter,null);switch(p._groupDensity=this._calculateDensity(e,s,d),a===En.Color?p._textureNb=i||0:i=i||new M.b(1,1,1,1),a){case En.Color:this._colorFromTexture(t,p,!1);break;case En.UV:this._setPointsColorOrUV(t,p,!1,!1,!1);break;case En.Random:this._setPointsColorOrUV(t,p,!1);break;case En.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||En.Random;(isNaN(a)||a<0||a>3)&&(a=En.Random);var s=t.getVerticesData(Oe.b.PositionKind),d=t.getIndices();this._groups.push(this._groupCounter);var p=new Sa(this._groupCounter,null);switch(p._groupDensity=this._calculateDensity(e,s,d),a===En.Color?p._textureNb=i||0:i=i||new M.b(1,1,1,1),a){case En.Color:this._colorFromTexture(t,p,!0);break;case En.UV:this._setPointsColorOrUV(t,p,!0,!1,!1);break;case En.Random:this._setPointsColorOrUV(t,p,!0);break;case En.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,b=p[5].copyFromFloats(1,0,0),P=p[6].copyFromFloats(0,1,0),O=p[7].copyFromFloats(0,0,1),B=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&&(B.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,Re=fe._globalPosition;if(this._computeParticleRotation&&fe.getRotationMatrix(i),fe.parentId!==null){var Ae=this.particles[fe.parentId],Ee=Ae._rotationMatrix,Se=Ae._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(Re.x=Se.x+xe,Re.y=Se.y+Le,Re.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 Re.x=0,Re.y=0,Re.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 Ye=p[0];Ye.copyFrom(fe.position);var tt=Ye.x-fe.pivot.x,it=Ye.y-fe.pivot.y,lt=Ye.z-fe.pivot.z,Qe=tt*ve[0]+it*ve[3]+lt*ve[6],ot=tt*ve[1]+it*ve[4]+lt*ve[7],rt=tt*ve[2]+it*ve[5]+lt*ve[8];Qe+=Fe.x,ot+=Fe.y,rt+=Fe.z;var Ze=s[ie]=Re.x+b.x*Qe+P.x*ot+O.x*rt,dt=s[ie+1]=Re.y+b.y*Qe+P.y*ot+O.y*rt,Ve=s[ie+2]=Re.z+b.z*Qe+P.z*ot+O.z*rt;if(this._computeBoundingBox&&(B.minimizeInPlaceFromFloats(Ze,dt,Ve),F.maximizeInPlaceFromFloats(Ze,dt,Ve)),this._computeParticleColor&&fe.color){var Je=fe.color,yt=this._colors32;yt[se]=Je.r,yt[se+1]=Je.g,yt[se+2]=Je.b,yt[se+3]=Je.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(Oe.b.ColorKind,a,!1,!1),this._computeParticleTexture&&o.updateVerticesData(Oe.b.UVKind,d,!1,!1),o.updateVerticesData(Oe.b.PositionKind,s,!1,!1)),this._computeBoundingBox&&(o._boundingInfo?o._boundingInfo.reConstruct(B,F,o._worldMatrix):o._boundingInfo=new Vi.a(B,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 Vi.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(at.a.NAME_PHYSICSENGINE);e||(e=new Od(this),this._addComponent(e));try{return this._physicsEngine=new Ir(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 Ro,Br,Od=function(){function r(t){var e=this;this.name=at.a.NAME_PHYSICSENGINE,this.scene=t,this.scene.onBeforePhysicsObservable=new C.c,this.scene.onAfterPhysicsObservable=new C.c,this.scene.getDeterministicFrameTime=function(){return e.scene._physicsEngine?1e3*e.scene._physicsEngine.getTimeStep():1e3/60}}return r.prototype.register=function(){},r.prototype.rebuild=function(){},r.prototype.dispose=function(){this.scene.onBeforePhysicsObservable.clear(),this.scene.onAfterPhysicsObservable.clear(),this.scene._physicsEngine&&this.scene.disablePhysicsEngine()},r}(),Gm=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 Ur).radius=e,e.strength=n||e.strength,e.falloff=i||e.falloff);var a=new Md(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 Ur).radius=e,e.strength=n||e.strength,e.falloff=i||e.falloff);var a=new Md(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 Ur).radius=e,e.strength=n||e.strength,e.falloff=i||e.falloff);var o=new zm(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 Dc).radius=e,e.strength=n||e.strength,e.height=i||e.height,e.updraftMode=o||e.updraftMode);var a=new jm(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 Lc).radius=e,e.strength=n||e.strength,e.height=i||e.height);var o=new Hm(this._scene,t,e);return o.dispose(!1),o},r}(),Md=function(){function r(t,e){this._scene=t,this._options=e,this._dataFetched=!1,this._options=Object(c.a)(Object(c.a)({},new Ur),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 fn.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===Ro.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=Fn.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}(),zm=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 Ur),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}(),jm=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 Dc),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===Br.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===Br.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;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=pi.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}(),Hm=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 Lc),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 fn.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,b=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,b=this._originTop.y*this._options.updraftForceMultiplier,P=(O.z+d.z)*this._options.centrifugalForceMultiplier}var B=new u.e(p,b,P);return{force:B=B.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=pi.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}(),Ur=function(){this.radius=5,this.strength=10,this.falloff=Ro.Constant,this.sphere={segments:32,diameter:1}},Dc=function(){this.radius=5,this.strength=10,this.height=10,this.updraftMode=Br.Center},Lc=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"})(Ro||(Ro={})),function(r){r[r.Center=0]="Center",r[r.Perpendicular=1]="Perpendicular"}(Br||(Br={}));var Wm=` +varying vec2 vUV; +uniform sampler2D textureSampler; +uniform float degree; +void main(void) +{ +vec3 color=texture2D(textureSampler,vUV).rgb; +float luminance=dot(color,vec3(0.3,0.59,0.11)); +vec3 blackAndWhite=vec3(luminance,luminance,luminance); +gl_FragColor=vec4(color-((color-blackAndWhite)*degree),1.0); +}`;ze.a.ShadersStore.blackAndWhitePixelShader=Wm;var Id=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"]=Id;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 + +varying vec2 vUV; +uniform sampler2D textureSampler; +uniform float threshold; +uniform float exposure; +void main(void) +{ +gl_FragColor=texture2D(textureSampler,vUV); +float luma=getLuminance(gl_FragColor.rgb*exposure); +gl_FragColor.rgb=step(threshold,luma)*gl_FragColor.rgb; +}`;ze.a.ShadersStore.extractHighlightsPixelShader=Xm;var Nc=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 b=r.call(this,e,"extractHighlights",["threshold","exposure"],null,n,i,o,a,s,null,d,void 0,null,p)||this;return b.threshold=.9,b._exposure=1,b._inputPostProcess=null,b.onApplyObservable.add(function(P){b._inputPostProcess&&P.setTextureFromPostProcess("textureSampler",b._inputPostProcess),P.setFloat("threshold",Math.pow(b.threshold,Gt.b)),P.setFloat("exposure",b._exposure)}),b}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"]=Nc;var Ym=`uniform sampler2D textureSampler; +uniform sampler2D bloomBlur; +varying vec2 vUV; +uniform float bloomWeight; +void main(void) +{ +gl_FragColor=texture2D(textureSampler,vUV); +vec3 blurred=texture2D(bloomBlur,vUV).rgb; +gl_FragColor.rgb=gl_FragColor.rgb+(blurred.rgb*bloomWeight); +} +`;ze.a.ShadersStore.bloomMergePixelShader=Ym;var wc=function(r){function t(e,n,i,o,a,s,d,p,b,P,O){P===void 0&&(P=h.a.TEXTURETYPE_UNSIGNED_INT),O===void 0&&(O=!1);var B=r.call(this,e,"bloomMerge",["bloomWeight"],["circleOfConfusionSampler","blurStep0","blurStep1","blurStep2","bloomBlur"],a,s,d,p,b,null,P,void 0,null,!0)||this;return B.weight=1,B.weight=o,B.onApplyObservable.add(function(F){F.setTextureFromPostProcess("textureSampler",n),F.setTextureFromPostProcessOutput("bloomBlur",i),F.setFloat("bloomWeight",B.weight)}),O||B.updateEffect(),B}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"]=wc;var Fc=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 Nc("highlights",1,null,we.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,a,s),d._blurX=new gn("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 gn("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 wc("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},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;n0 +uniform sampler2D blurStep1; +#endif +#if BLUR_LEVEL>1 +uniform sampler2D blurStep2; +#endif +void main(void) +{ +float coc=texture2D(circleOfConfusionSampler,vUV).r; +#if BLUR_LEVEL == 0 +vec4 original=texture2D(textureSampler,vUV); +vec4 blurred0=texture2D(blurStep0,vUV); +gl_FragColor=mix(original,blurred0,coc); +#endif +#if BLUR_LEVEL == 1 +if(coc<0.5){ +vec4 original=texture2D(textureSampler,vUV); +vec4 blurred1=texture2D(blurStep1,vUV); +gl_FragColor=mix(original,blurred1,coc/0.5); +}else{ +vec4 blurred0=texture2D(blurStep0,vUV); +vec4 blurred1=texture2D(blurStep1,vUV); +gl_FragColor=mix(blurred1,blurred0,(coc-0.5)/0.5); +} +#endif +#if BLUR_LEVEL == 2 +if(coc<0.33){ +vec4 original=texture2D(textureSampler,vUV); +vec4 blurred2=texture2D(blurStep2,vUV); +gl_FragColor=mix(original,blurred2,coc/0.33); +}else if(coc<0.66){ +vec4 blurred1=texture2D(blurStep1,vUV); +vec4 blurred2=texture2D(blurStep2,vUV); +gl_FragColor=mix(blurred2,blurred1,(coc-0.33)/0.33); +}else{ +vec4 blurred0=texture2D(blurStep0,vUV); +vec4 blurred1=texture2D(blurStep1,vUV); +gl_FragColor=mix(blurred1,blurred0,(coc-0.66)/0.34); +} +#endif +} +`;ze.a.ShadersStore.depthOfFieldMergePixelShader=Jm;var sr,$m=function(){},Nd=function(r){function t(e,n,i,o,a,s,d,p,b,P,O){P===void 0&&(P=h.a.TEXTURETYPE_UNSIGNED_INT),O===void 0&&(O=!1);var B=r.call(this,e,"depthOfFieldMerge",[],["circleOfConfusionSampler","blurStep0","blurStep1","blurStep2"],a,s,d,p,b,null,P,void 0,null,!0)||this;return B.blurSteps=o,B.onApplyObservable.add(function(F){F.setTextureFromPostProcess("textureSampler",n),F.setTextureFromPostProcessOutput("circleOfConfusionSampler",i),o.forEach(function(z,J){F.setTextureFromPostProcessOutput("blurStep"+(o.length-J-1),z)})}),O||B.updateEffect(),B}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)+` +`),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"})(sr||(sr={}));var Vc=function(r){function t(e,n,i,o,a){i===void 0&&(i=sr.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 Uc("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 sr.High:d=3,p=51;break;case sr.Medium:d=2,p=31;break;default:p=15,d=1}for(var b=p/Math.pow(2,d-1),P=1,O=0;O=edgeVert; +float subpixA=subpixNSWE*2.0+subpixNWSWNESE; +if (!horzSpan) +{ +lumaN=lumaW; +} +if (!horzSpan) +{ +lumaS=lumaE; +} +if (horzSpan) +{ +lengthSign=texelSize.y; +} +float subpixB=(subpixA*(1.0/12.0))-lumaM; +float gradientN=lumaN-lumaM; +float gradientS=lumaS-lumaM; +float lumaNN=lumaN+lumaM; +float lumaSS=lumaS+lumaM; +bool pairN=abs(gradientN)>=abs(gradientS); +float gradient=max(abs(gradientN),abs(gradientS)); +if (pairN) +{ +lengthSign=-lengthSign; +} +float subpixC=clamp(abs(subpixB)*subpixRcpRange,0.0,1.0); +vec2 posB; +posB.x=posM.x; +posB.y=posM.y; +vec2 offNP; +offNP.x=(!horzSpan) ? 0.0 : texelSize.x; +offNP.y=(horzSpan) ? 0.0 : texelSize.y; +if (!horzSpan) +{ +posB.x+=lengthSign*0.5; +} +if (horzSpan) +{ +posB.y+=lengthSign*0.5; +} +vec2 posN; +posN.x=posB.x-offNP.x*1.5; +posN.y=posB.y-offNP.y*1.5; +vec2 posP; +posP.x=posB.x+offNP.x*1.5; +posP.y=posB.y+offNP.y*1.5; +float subpixD=((-2.0)*subpixC)+3.0; +float lumaEndN=FxaaLuma(texture2D(textureSampler,posN,0.0)); +float subpixE=subpixC*subpixC; +float lumaEndP=FxaaLuma(texture2D(textureSampler,posP,0.0)); +if (!pairN) +{ +lumaNN=lumaSS; +} +float gradientScaled=gradient*1.0/4.0; +float lumaMM=lumaM-lumaNN*0.5; +float subpixF=subpixD*subpixE; +bool lumaMLTZero=lumaMM<0.0; +lumaEndN-=lumaNN*0.5; +lumaEndP-=lumaNN*0.5; +bool doneN=abs(lumaEndN)>=gradientScaled; +bool doneP=abs(lumaEndP)>=gradientScaled; +if (!doneN) +{ +posN.x-=offNP.x*3.0; +} +if (!doneN) +{ +posN.y-=offNP.y*3.0; +} +bool doneNP=(!doneN) || (!doneP); +if (!doneP) +{ +posP.x+=offNP.x*3.0; +} +if (!doneP) +{ +posP.y+=offNP.y*3.0; +} +if (doneNP) +{ +if (!doneN) lumaEndN=FxaaLuma(texture2D(textureSampler,posN.xy,0.0)); +if (!doneP) lumaEndP=FxaaLuma(texture2D(textureSampler,posP.xy,0.0)); +if (!doneN) lumaEndN=lumaEndN-lumaNN*0.5; +if (!doneP) lumaEndP=lumaEndP-lumaNN*0.5; +doneN=abs(lumaEndN)>=gradientScaled; +doneP=abs(lumaEndP)>=gradientScaled; +if (!doneN) posN.x-=offNP.x*12.0; +if (!doneN) posN.y-=offNP.y*12.0; +doneNP=(!doneN) || (!doneP); +if (!doneP) posP.x+=offNP.x*12.0; +if (!doneP) posP.y+=offNP.y*12.0; +} +float dstN=posM.x-posN.x; +float dstP=posP.x-posM.x; +if (!horzSpan) +{ +dstN=posM.y-posN.y; +} +if (!horzSpan) +{ +dstP=posP.y-posM.y; +} +bool goodSpanN=(lumaEndN<0.0) != lumaMLTZero; +float spanLength=(dstP+dstN); +bool goodSpanP=(lumaEndP<0.0) != lumaMLTZero; +float spanLengthRcp=1.0/spanLength; +bool directionN=dstN-1?`#define MALI 1 +`: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"]=Oo;var rg=`#include + +uniform sampler2D textureSampler; + +uniform float intensity; +uniform float animatedSeed; + +varying vec2 vUV; +void main(void) +{ +gl_FragColor=texture2D(textureSampler,vUV); +vec2 seed=vUV*(animatedSeed); +float grain=dither(seed,intensity); + +float lum=getLuminance(gl_FragColor.rgb); +float grainAmount=(cos(-PI+(lum*PI*2.))+1.)/2.; +gl_FragColor.rgb+=grain*grainAmount; +gl_FragColor.rgb=max(gl_FragColor.rgb,0.0); +}`;ze.a.ShadersStore.grainPixelShader=rg;var kc=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 b=r.call(this,e,"grain",["intensity","animatedSeed"],[],n,i,o,a,s,null,d,void 0,null,p)||this;return b.intensity=30,b.animated=!1,b.onApplyObservable.add(function(P){P.setFloat("intensity",b.intensity),P.setFloat("animatedSeed",b.animated?Math.random()+1:1)}),b}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"]=kc;var og=` +varying vec2 vUV; +uniform sampler2D textureSampler; +const vec3 RGBLuminanceCoefficients=vec3(0.2126,0.7152,0.0722); +void main(void) +{ +vec4 tex=texture2D(textureSampler,vUV); +vec3 c=tex.rgb; +float luma=dot(c.rgb,RGBLuminanceCoefficients); + + +gl_FragColor=vec4(pow(c,vec3(25.0-luma*15.0)),tex.a); +}`;ze.a.ShadersStore.highlightsPixelShader=og;var ag=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);ze.a.IncludesShadersStore.mrtFragmentDeclaration=`#if __VERSION__>=200 +layout(location=0) out vec4 glFragData[{X}]; +#endif +`;var sg=`#extension GL_EXT_draw_buffers : require +#if defined(BUMP) || !defined(NORMAL) +#extension GL_OES_standard_derivatives : enable +#endif +precision highp float; +precision highp int; +#ifdef BUMP +varying mat4 vWorldView; +varying vec3 vNormalW; +#else +varying vec3 vNormalV; +#endif +varying vec4 vViewPos; +#if defined(POSITION) || defined(BUMP) +varying vec3 vPositionW; +#endif +#ifdef VELOCITY +varying vec4 vCurrentPosition; +varying vec4 vPreviousPosition; +#endif +#ifdef NEED_UV +varying vec2 vUV; +#endif +#ifdef BUMP +uniform vec3 vBumpInfos; +uniform vec2 vTangentSpaceParams; +#endif +#ifdef REFLECTIVITY +varying vec2 vReflectivityUV; +uniform sampler2D reflectivitySampler; +#endif +#ifdef ALPHATEST +uniform sampler2D diffuseSampler; +#endif +#include[RENDER_TARGET_COUNT] +#include +#include +void main() { +#ifdef ALPHATEST +if (texture2D(diffuseSampler,vUV).a<0.4) +discard; +#endif +vec3 normalOutput; +#ifdef BUMP +vec3 normalW=normalize(vNormalW); +#include +normalOutput=normalize(vec3(vWorldView*vec4(normalW,0.0))); +#else +normalOutput=normalize(vNormalV); +#endif +#ifdef PREPASS +#ifdef PREPASS_DEPTHNORMAL +gl_FragData[DEPTHNORMAL_INDEX]=vec4(vViewPos.z/vViewPos.w,normalOutput); +#endif +#else +gl_FragData[0]=vec4(vViewPos.z/vViewPos.w,0.0,0.0,1.0); +gl_FragData[1]=vec4(normalOutput,1.0); +#endif +#ifdef POSITION +gl_FragData[POSITION_INDEX]=vec4(vPositionW,1.0); +#endif +#ifdef VELOCITY +vec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5; +vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5; +vec2 velocity=abs(a-b); +velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5; +gl_FragData[VELOCITY_INDEX]=vec4(velocity,0.0,1.0); +#endif +#ifdef REFLECTIVITY +#ifdef HAS_SPECULAR + +vec4 reflectivity=texture2D(reflectivitySampler,vReflectivityUV); +#elif HAS_REFLECTIVITY + +vec4 reflectivity=vec4(texture2D(reflectivitySampler,vReflectivityUV).rgb,1.0); +#else +vec4 reflectivity=vec4(0.0,0.0,0.0,1.0); +#endif +gl_FragData[REFLECTIVITY_INDEX]=reflectivity; +#endif +}`;ze.a.ShadersStore.geometryPixelShader=sg;var cg=`precision highp float; +precision highp int; +#include +#include +#include[0..maxSimultaneousMorphTargets] +#include +attribute vec3 position; +attribute vec3 normal; +#ifdef NEED_UV +varying vec2 vUV; +#ifdef ALPHATEST +uniform mat4 diffuseMatrix; +#endif +#ifdef BUMP +uniform mat4 bumpMatrix; +varying vec2 vBumpUV; +#endif +#ifdef REFLECTIVITY +uniform mat4 reflectivityMatrix; +varying vec2 vReflectivityUV; +#endif +#ifdef UV1 +attribute vec2 uv; +#endif +#ifdef UV2 +attribute vec2 uv2; +#endif +#endif + +uniform mat4 viewProjection; +uniform mat4 view; +#ifdef BUMP +varying mat4 vWorldView; +#endif +#ifdef BUMP +varying vec3 vNormalW; +#else +varying vec3 vNormalV; +#endif +varying vec4 vViewPos; +#if defined(POSITION) || defined(BUMP) +varying vec3 vPositionW; +#endif +#ifdef VELOCITY +uniform mat4 previousWorld; +uniform mat4 previousViewProjection; +#ifdef BONES_VELOCITY_ENABLED +#if NUM_BONE_INFLUENCERS>0 +uniform mat4 mPreviousBones[BonesPerMesh]; +#endif +#endif +varying vec4 vCurrentPosition; +varying vec4 vPreviousPosition; +#endif +void main(void) +{ +vec3 positionUpdated=position; +vec3 normalUpdated=normal; +#ifdef UV1 +vec2 uvUpdated=uv; +#endif +#include[0..maxSimultaneousMorphTargets] +#include +#if defined(VELOCITY) && !defined(BONES_VELOCITY_ENABLED) + +vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0); +vPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0); +#endif +#include +vec4 pos=vec4(finalWorld*vec4(positionUpdated,1.0)); +#ifdef BUMP +vWorldView=view*finalWorld; +vNormalW=normalUpdated; +#else +vNormalV=normalize(vec3((view*finalWorld)*vec4(normalUpdated,0.0))); +#endif +vViewPos=view*pos; +#if defined(VELOCITY) && defined(BONES_VELOCITY_ENABLED) +vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0); +#if NUM_BONE_INFLUENCERS>0 +mat4 previousInfluence; +previousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0]; +#if NUM_BONE_INFLUENCERS>1 +previousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1]; +#endif +#if NUM_BONE_INFLUENCERS>2 +previousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2]; +#endif +#if NUM_BONE_INFLUENCERS>3 +previousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3]; +#endif +#if NUM_BONE_INFLUENCERS>4 +previousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0]; +#endif +#if NUM_BONE_INFLUENCERS>5 +previousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1]; +#endif +#if NUM_BONE_INFLUENCERS>6 +previousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2]; +#endif +#if NUM_BONE_INFLUENCERS>7 +previousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3]; +#endif +vPreviousPosition=previousViewProjection*previousWorld*previousInfluence*vec4(positionUpdated,1.0); +#else +vPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0); +#endif +#endif +#if defined(POSITION) || defined(BUMP) +vPositionW=pos.xyz/pos.w; +#endif +gl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0); +#ifdef NEED_UV +#ifdef UV1 +#ifdef ALPHATEST +vUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0)); +#else +vUV=uv; +#endif +#ifdef BUMP +vBumpUV=vec2(bumpMatrix*vec4(uvUpdated,1.0,0.0)); +#endif +#ifdef REFLECTIVITY +vReflectivityUV=vec2(reflectivityMatrix*vec4(uvUpdated,1.0,0.0)); +#endif +#endif +#ifdef UV2 +#ifdef ALPHATEST +vUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0)); +#else +vUV=uv2; +#endif +#ifdef BUMP +vBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0)); +#endif +#ifdef REFLECTIVITY +vReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0)); +#endif +#endif +#endif +#include +} +`;ze.a.ShadersStore.geometryVertexShader=cg;var ui=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},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=[Oe.b.PositionKind,Oe.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 uo&&n.reflectivityTexture&&(i.push("#define HAS_REFLECTIVITY"),s=!0)),s&&(i.push("#define NEED_UV"),a.isVerticesDataPresent(Oe.b.UVKind)&&(o.push(Oe.b.UVKind),i.push("#define UV1")),a.isVerticesDataPresent(Oe.b.UV2Kind)&&(o.push(Oe.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(Oe.b.MatricesIndicesKind),o.push(Oe.b.MatricesWeightsKind),a.numBoneInfluencers>4&&(o.push(Oe.b.MatricesIndicesExtraKind),o.push(Oe.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),et.a.PrepareAttributesForMorphTargetsInfluencers(o,a,p)),e&&(i.push("#define INSTANCES"),et.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 b=i.join(` +`);return this._cachedDefines!==b&&(this._cachedDefines=b,this._effect=this._scene.getEngine().createEffect("geometry",o,["world","mBones","viewProjection","diffuseMatrix","view","previousWorld","previousViewProjection","mPreviousBones","morphTargetInfluences","bumpMatrix","reflectivityMatrix","vTangentSpaceParams","vBumpInfos"],["diffuseSampler","bumpSampler","reflectivitySampler"],b,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},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 qs("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(),b=o.getMaterial();if(b){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 B=p.getCaps().instancedArrays&&(O.visibleInstances[o._id]!==null||a.hasThinInstances),F=s.getWorldMatrix();if(t.isReady(o,B)){if(p.enableEffect(t._effect),a._bind(o,t._effect,b.fillMode),t._effect.setMatrix("viewProjection",d.getTransformMatrix()),t._effect.setMatrix("view",d.getViewMatrix()),b){var z,J=s._instanceDataStorage;if(J.isFrozen||!b.backFaceCulling&&b.overrideMaterialSideOrientation===null)z=J.sideOrientation;else{var ie=s._getWorldMatrixDeterminant();(z=b.overrideMaterialSideOrientation)==null&&(z=b.sideOrientation),ie<0&&(z=z===Ht.a.ClockWiseSideOrientation?Ht.a.CounterClockWiseSideOrientation:Ht.a.ClockWiseSideOrientation)}if(b._preBind(t._effect,z),b.needAlphaTesting()){var se=b.getAlphaTestTexture();se&&(t._effect.setTexture("diffuseSampler",se),t._effect.setMatrix("diffuseMatrix",se.getTextureMatrix()))}b.bumpTexture&&d.getEngine().getCaps().standardDerivatives&&Ft.a.BumpTextureEnabled&&(t._effect.setFloat3("vBumpInfos",b.bumpTexture.coordinatesIndex,1/b.bumpTexture.level,b.parallaxScaleBias),t._effect.setMatrix("bumpMatrix",b.bumpTexture.getTextureMatrix()),t._effect.setTexture("bumpSampler",b.bumpTexture),t._effect.setFloat2("vTangentSpaceParams",b.invertNormalMapX?-1:1,b.invertNormalMapY?-1:1)),t._enableReflectivity&&(b instanceof Ft.a&&b.specularTexture?(t._effect.setMatrix("reflectivityMatrix",b.specularTexture.getTextureMatrix()),t._effect.setTexture("reflectivitySampler",b.specularTexture)):b instanceof uo&&b.reflectivityTexture&&(t._effect.setMatrix("reflectivityMatrix",b.reflectivityTexture.getTextureMatrix()),t._effect.setTexture("reflectivitySampler",b.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])),et.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,b.fillMode,O,B,function(ce,ue){return t._effect.setMatrix("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=samplesCount) +break; +vec2 offset=vUV+velocity*(hlim+float(i)); +result+=texture2D(textureSampler,offset); +} +gl_FragColor=result/float(samplesCount); +gl_FragColor.a=1.0; +#else +vec2 texelSize=1.0/screenSize; +float depth=texture2D(depthSampler,vUV).r; +vec4 cpos=vec4(vUV*2.0-1.0,depth,1.0); +cpos=cpos*inverseViewProjection; +vec4 ppos=cpos*prevViewProjection; +ppos.xyz/=ppos.w; +ppos.xy=ppos.xy*0.5+0.5; +vec2 velocity=(ppos.xy-vUV)*motionScale*motionStrength; +float speed=length(velocity/texelSize); +int nSamples=int(clamp(speed,1.0,SAMPLES)); +vec4 result=texture2D(textureSampler,vUV); +for (int i=1; i=nSamples) +break; +vec2 offset1=vUV+velocity*(float(i)/float(nSamples-1)-0.5); +result+=texture2D(textureSampler,offset1); +} +gl_FragColor=result/float(nSamples); +#endif +#else +gl_FragColor=texture2D(textureSampler,vUV); +#endif +} +`;ze.a.ShadersStore.motionBlurPixelShader=ug;var Gc=function(r){function t(e,n,i,o,a,s,d,p,b,P){p===void 0&&(p=h.a.TEXTURETYPE_UNSIGNED_INT),b===void 0&&(b=!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 +#define SAMPLES 64.0 +#define OBJECT_BASED`,p,void 0,null,b)||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()},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(ui.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(ui.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(` +`))}},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"]=Gc;var hg=` +varying vec2 vUV; +uniform sampler2D textureSampler; +uniform sampler2D refractionSampler; + +uniform vec3 baseColor; +uniform float depth; +uniform float colorLevel; +void main() { +float ref=1.0-texture2D(refractionSampler,vUV).r; +vec2 uv=vUV-vec2(0.5); +vec2 offset=uv*depth*ref; +vec3 sourceColor=texture2D(textureSampler,vUV-offset).rgb; +gl_FragColor=vec4(sourceColor+sourceColor*ref*colorLevel,1.0); +}`;ze.a.ShadersStore.refractionPixelShader=hg;var Ud=function(r){function t(e,n,i,o,a,s,d,p,b,P){var O=r.call(this,e,"refraction",["baseColor","depth","colorLevel"],["refractionSampler"],s,d,p,b,P)||this;return O._ownRefractionTexture=!0,O.color=i,O.depth=o,O.colorLevel=a,O.refractionTextureUrl=n,O.onActivateObservable.add(function(B){O._refTexture=O._refTexture||new we.a(n,B.getScene())}),O.onApplyObservable.add(function(B){B.setColor3("baseColor",O.color),B.setFloat("depth",O.depth),B.setFloat("colorLevel",O.colorLevel),B.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},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"]=Ud;var dg=` +varying vec2 vUV; +uniform sampler2D textureSampler; +uniform vec2 screenSize; +uniform vec2 sharpnessAmounts; +void main(void) +{ +vec2 onePixel=vec2(1.0,1.0)/screenSize; +vec4 color=texture2D(textureSampler,vUV); +vec4 edgeDetection=texture2D(textureSampler,vUV+onePixel*vec2(0,-1)) + +texture2D(textureSampler,vUV+onePixel*vec2(-1,0)) + +texture2D(textureSampler,vUV+onePixel*vec2(1,0)) + +texture2D(textureSampler,vUV+onePixel*vec2(0,1)) - +color*4.0; +gl_FragColor=max(vec4(color.rgb*sharpnessAmounts.y,color.a)-(sharpnessAmounts.x*vec4(edgeDetection.rgb,0)),0.); +}`;ze.a.ShadersStore.sharpenPixelShader=dg;var zc=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 b=r.call(this,e,"sharpen",["sharpnessAmounts","screenSize"],null,n,i,o,a,s,null,d,void 0,null,p)||this;return b.colorAmount=1,b.edgeAmount=.3,b.onApply=function(P){P.setFloat2("screenSize",b.width,b.height),P.setFloat2("sharpnessAmounts",b.edgeAmount,b.colorAmount)},b}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"]=zc;var Vr=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(Xe.b.MakeArray(e||this._cameras))},r.prototype._disableEffect=function(t,e){var n=this._renderEffects[t];n&&n._disable(Xe.b.MakeArray(e||this._cameras))},r.prototype._attachCameras=function(t,e){var n=Xe.b.MakeArray(t||this._cameras);if(n){var i,o=[];for(i=0;i0){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}(),Vd=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},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(at.a.NAME_POSTPROCESSRENDERPIPELINEMANAGER);r||(r=new kd(this),this._addComponent(r)),this._postProcessRenderPipelineManager=new Vd}return this._postProcessRenderPipelineManager},enumerable:!0,configurable:!0});var kd=function(){function r(t){this.name=at.a.NAME_POSTPROCESSRENDERPIPELINEMANAGER,this.scene=t}return r.prototype.register=function(){this.scene._gatherRenderTargetsStage.registerStep(at.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}(),Gd=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=sr.Low,s._fxaaEnabled=!1,s._imageProcessingEnabled=!0,s._bloomScale=.5,s._chromaticAberrationEnabled=!1,s._grainEnabled=!1,s._buildAllowed=!0,s.onBuildObservable=new C.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 zc("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 Vc(s._scene,null,s._depthOfFieldBlurLevel,s._defaultPipelineTextureType,!0),s.bloom=new Fc(s._scene,s._bloomScale,s._bloomWeight,s.bloomKernel,s._defaultPipelineTextureType,!0),s.chromaticAberration=new Bc("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 kc("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},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 Fc(this._scene,this.bloomScale,this._bloomWeight,this.bloomKernel,this._defaultPipelineTextureType,!1),this.bloom.threshold=e.threshold;for(var n=0;n1){for(var i=0,o=this._cameras;i-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 Go("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 Oo("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;n1.0) { lum_threshold=0.94+0.01*threshold; } +else { lum_threshold=0.5+0.44*threshold; } +luminance=clamp((luminance-lum_threshold)*(1.0/(1.0-lum_threshold)),0.0,1.0); +highlight*=luminance*gain; +highlight.a=1.0; +return highlight; +} +void main(void) +{ +vec4 original=texture2D(textureSampler,vUV); + +if (gain == -1.0) { +gl_FragColor=vec4(0.0,0.0,0.0,1.0); +return; +} +float w=2.0/screen_width; +float h=2.0/screen_height; +float weight=1.0; + +vec4 blurred=vec4(0.0,0.0,0.0,0.0); +#ifdef PENTAGON +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.84*w,0.43*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.48*w,-1.29*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.61*w,1.51*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.55*w,-0.74*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.71*w,-0.52*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.94*w,1.59*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.40*w,-1.87*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.62*w,1.16*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.09*w,0.25*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.46*w,-1.71*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.08*w,2.42*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.85*w,-1.89*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.89*w,0.16*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.29*w,1.88*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.40*w,-2.81*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.54*w,2.26*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.60*w,-0.61*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.31*w,-1.30*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.83*w,2.53*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.12*w,-2.48*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.60*w,1.11*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.82*w,0.99*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.50*w,-2.81*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.85*w,3.33*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.94*w,-1.92*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.27*w,-0.53*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.95*w,2.48*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.23*w,-3.04*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.17*w,2.05*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.97*w,-0.04*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.25*w,-2.00*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.31*w,3.08*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.94*w,-2.59*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.37*w,0.64*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.13*w,1.93*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.03*w,-3.65*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.60*w,3.17*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.14*w,-1.19*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.00*w,-1.19*h))); +#else +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.85*w,0.36*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.52*w,-1.14*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.46*w,1.42*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.46*w,-0.83*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.79*w,-0.42*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.11*w,1.62*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.29*w,-2.07*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.69*w,1.39*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.28*w,0.12*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.65*w,-1.69*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.08*w,2.44*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.63*w,-1.90*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.55*w,0.31*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.13*w,1.52*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.56*w,-2.61*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.38*w,2.34*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.64*w,-0.81*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.53*w,-1.21*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.06*w,2.63*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.00*w,-2.69*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.59*w,1.32*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.82*w,0.78*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.57*w,-2.50*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.54*w,2.93*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.39*w,-1.81*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.01*w,-0.28*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.04*w,2.25*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.02*w,-3.05*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.09*w,2.25*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.07*w,-0.25*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.44*w,-1.90*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.52*w,3.05*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.68*w,-2.61*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.01*w,0.79*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.76*w,1.46*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.05*w,-2.94*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.21*w,2.88*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.84*w,-1.30*h))); +blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.98*w,-0.96*h))); +#endif +blurred/=39.0; +gl_FragColor=blurred; + +}`;ze.a.ShadersStore.lensHighlightsPixelShader=fg;var pg=` + + + + +uniform sampler2D textureSampler; +uniform sampler2D highlightsSampler; +uniform sampler2D depthSampler; +uniform sampler2D grainSampler; + +uniform float grain_amount; +uniform bool blur_noise; +uniform float screen_width; +uniform float screen_height; +uniform float distortion; +uniform bool dof_enabled; + +uniform float screen_distance; +uniform float aperture; +uniform float darken; +uniform float edge_blur; +uniform bool highlights; + +uniform float near; +uniform float far; + +varying vec2 vUV; + +#define PI 3.14159265 +#define TWOPI 6.28318530 +#define inverse_focal_length 0.1 + +vec2 centered_screen_pos; +vec2 distorted_coords; +float radius2; +float radius; + +vec2 rand(vec2 co) +{ +float noise1=(fract(sin(dot(co,vec2(12.9898,78.233)))*43758.5453)); +float noise2=(fract(sin(dot(co,vec2(12.9898,78.233)*2.0))*43758.5453)); +return clamp(vec2(noise1,noise2),0.0,1.0); +} + +vec2 getDistortedCoords(vec2 coords) { +if (distortion == 0.0) { return coords; } +vec2 direction=1.0*normalize(centered_screen_pos); +vec2 dist_coords=vec2(0.5,0.5); +dist_coords.x=0.5+direction.x*radius2*1.0; +dist_coords.y=0.5+direction.y*radius2*1.0; +float dist_amount=clamp(distortion*0.23,0.0,1.0); +dist_coords=mix(coords,dist_coords,dist_amount); +return dist_coords; +} + +float sampleScreen(inout vec4 color,const in vec2 offset,const in float weight) { + +vec2 coords=distorted_coords; +float angle=rand(coords*100.0).x*TWOPI; +coords+=vec2(offset.x*cos(angle)-offset.y*sin(angle),offset.x*sin(angle)+offset.y*cos(angle)); +color+=texture2D(textureSampler,coords)*weight; +return weight; +} + +float getBlurLevel(float size) { +return min(3.0,ceil(size/1.0)); +} + +vec4 getBlurColor(float size) { +vec4 col=texture2D(textureSampler,distorted_coords); +if (size == 0.0) { return col; } + + +float blur_level=getBlurLevel(size); +float w=(size/screen_width); +float h=(size/screen_height); +float total_weight=1.0; +vec2 sample_coords; +total_weight+=sampleScreen(col,vec2(-0.50*w,0.24*h),0.93); +total_weight+=sampleScreen(col,vec2(0.30*w,-0.75*h),0.90); +total_weight+=sampleScreen(col,vec2(0.36*w,0.96*h),0.87); +total_weight+=sampleScreen(col,vec2(-1.08*w,-0.55*h),0.85); +total_weight+=sampleScreen(col,vec2(1.33*w,-0.37*h),0.83); +total_weight+=sampleScreen(col,vec2(-0.82*w,1.31*h),0.80); +total_weight+=sampleScreen(col,vec2(-0.31*w,-1.67*h),0.78); +total_weight+=sampleScreen(col,vec2(1.47*w,1.11*h),0.76); +total_weight+=sampleScreen(col,vec2(-1.97*w,0.19*h),0.74); +total_weight+=sampleScreen(col,vec2(1.42*w,-1.57*h),0.72); +if (blur_level>1.0) { +total_weight+=sampleScreen(col,vec2(0.01*w,2.25*h),0.70); +total_weight+=sampleScreen(col,vec2(-1.62*w,-1.74*h),0.67); +total_weight+=sampleScreen(col,vec2(2.49*w,0.20*h),0.65); +total_weight+=sampleScreen(col,vec2(-2.07*w,1.61*h),0.63); +total_weight+=sampleScreen(col,vec2(0.46*w,-2.70*h),0.61); +total_weight+=sampleScreen(col,vec2(1.55*w,2.40*h),0.59); +total_weight+=sampleScreen(col,vec2(-2.88*w,-0.75*h),0.56); +total_weight+=sampleScreen(col,vec2(2.73*w,-1.44*h),0.54); +total_weight+=sampleScreen(col,vec2(-1.08*w,3.02*h),0.52); +total_weight+=sampleScreen(col,vec2(-1.28*w,-3.05*h),0.49); +} +if (blur_level>2.0) { +total_weight+=sampleScreen(col,vec2(3.11*w,1.43*h),0.46); +total_weight+=sampleScreen(col,vec2(-3.36*w,1.08*h),0.44); +total_weight+=sampleScreen(col,vec2(1.80*w,-3.16*h),0.41); +total_weight+=sampleScreen(col,vec2(0.83*w,3.65*h),0.38); +total_weight+=sampleScreen(col,vec2(-3.16*w,-2.19*h),0.34); +total_weight+=sampleScreen(col,vec2(3.92*w,-0.53*h),0.31); +total_weight+=sampleScreen(col,vec2(-2.59*w,3.12*h),0.26); +total_weight+=sampleScreen(col,vec2(-0.20*w,-4.15*h),0.22); +total_weight+=sampleScreen(col,vec2(3.02*w,3.00*h),0.15); +} +col/=total_weight; + +if (darken>0.0) { +col.rgb*=clamp(0.3,1.0,1.05-size*0.5*darken); +} + + + + +return col; +} +void main(void) +{ + +centered_screen_pos=vec2(vUV.x-0.5,vUV.y-0.5); +radius2=centered_screen_pos.x*centered_screen_pos.x+centered_screen_pos.y*centered_screen_pos.y; +radius=sqrt(radius2); +distorted_coords=getDistortedCoords(vUV); +vec2 texels_coords=vec2(vUV.x*screen_width,vUV.y*screen_height); +float depth=texture2D(depthSampler,distorted_coords).r; +float distance=near+(far-near)*depth; +vec4 color=texture2D(textureSampler,vUV); + + +float coc=abs(aperture*(screen_distance*(inverse_focal_length-1.0/distance)-1.0)); + +if (dof_enabled == false || coc<0.07) { coc=0.0; } + +float edge_blur_amount=0.0; +if (edge_blur>0.0) { +edge_blur_amount=clamp((radius*2.0-1.0+0.15*edge_blur)*1.5,0.0,1.0)*1.3; +} + +float blur_amount=max(edge_blur_amount,coc); + +if (blur_amount == 0.0) { +gl_FragColor=texture2D(textureSampler,distorted_coords); +} +else { + +gl_FragColor=getBlurColor(blur_amount*1.7); + +if (highlights) { +gl_FragColor.rgb+=clamp(coc,0.0,1.0)*texture2D(highlightsSampler,distorted_coords).rgb; +} +if (blur_noise) { + +vec2 noise=rand(distorted_coords)*0.01*blur_amount; +vec2 blurred_coord=vec2(distorted_coords.x+noise.x,distorted_coords.y+noise.y); +gl_FragColor=0.04*texture2D(textureSampler,blurred_coord)+0.96*gl_FragColor; +} +} + +if (grain_amount>0.0) { +vec4 grain_color=texture2D(grainSampler,texels_coords*0.003); +gl_FragColor.rgb+=(-0.5+grain_color.rgb)*0.30*grain_amount; +} +} +`;ze.a.ShadersStore.depthOfFieldPixelShader=pg;var _g=function(r){function t(e,n,i,o,a){o===void 0&&(o=1);var s=r.call(this,i.getEngine(),e)||this;return s.LensChromaticAberrationEffect="LensChromaticAberrationEffect",s.HighlightsEnhancingEffect="HighlightsEnhancingEffect",s.LensDepthOfFieldEffect="LensDepthOfFieldEffect",s._pentagonBokehIsEnabled=!1,s._scene=i,s._depthTexture=i.enableDepthRenderer().getDepthMap(),n.grain_texture?s._grainTexture=n.grain_texture:s._createGrainTexture(),s._edgeBlur=n.edge_blur?n.edge_blur:0,s._grainAmount=n.grain_amount?n.grain_amount:0,s._chromaticAberration=n.chromatic_aberration?n.chromatic_aberration:0,s._distortion=n.distortion?n.distortion:0,s._highlightsGain=n.dof_gain!==void 0?n.dof_gain:-1,s._highlightsThreshold=n.dof_threshold?n.dof_threshold:1,s._dofDistance=n.dof_focus_distance!==void 0?n.dof_focus_distance:-1,s._dofAperture=n.dof_aperture?n.dof_aperture:1,s._dofDarken=n.dof_darken?n.dof_darken:0,s._dofPentagon=n.dof_pentagon===void 0||n.dof_pentagon,s._blurNoise=n.blur_noise===void 0||n.blur_noise,s._createChromaticAberrationPostProcess(o),s._createHighlightsPostProcess(o),s._createDepthOfFieldPostProcess(o/4),s.addEffect(new 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 +`),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 +`:""),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,null,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 Ti.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}(Vr),mg=function(){this.enabled=!1,this.name="ssao2",this.texturesRequired=[h.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE]},gg=` +precision highp float; +uniform sampler2D textureSampler; +uniform float near; +uniform float far; +uniform float radius; +float scales[16]=float[16]( +0.1, +0.11406250000000001, +0.131640625, +0.15625, +0.187890625, +0.2265625, +0.272265625, +0.325, +0.384765625, +0.4515625, +0.525390625, +0.60625, +0.694140625, +0.7890625, +0.891015625, +1.0 +); +varying vec2 vUV; +float perspectiveDepthToViewZ( const in float invClipZ,const in float near,const in float far ) { +return ( near*far )/( ( far-near )*invClipZ-far ); +} +float viewZToPerspectiveDepth( const in float viewZ,const in float near,const in float far ) { +return ( near*far/viewZ+far)/( far-near ); +} +float viewZToOrthographicDepth( const in float viewZ,const in float near,const in float far ) { +return ( viewZ+near )/( near-far ); +} +#ifdef SSAO +uniform sampler2D randomSampler; +#ifndef GEOMETRYBUFFER +uniform sampler2D depthNormalSampler; +#else +uniform sampler2D depthSampler; +uniform sampler2D normalSampler; +#endif +uniform float randTextureTiles; +uniform float samplesFactor; +uniform vec3 sampleSphere[SAMPLES]; +uniform float totalStrength; +uniform float base; +uniform float xViewport; +uniform float yViewport; +uniform float maxZ; +uniform float minZAspect; +uniform vec2 texelSize; +uniform mat4 projection; +void main() +{ +vec3 random=texture2D(randomSampler,vUV*randTextureTiles).rgb; +#ifndef GEOMETRYBUFFER +float depth=texture2D(depthNormalSampler,vUV).r; +#else +float depth=texture2D(depthSampler,vUV).r; +#endif +float depthSign=depth/abs(depth); +depth=depth*depthSign; +#ifndef GEOMETRYBUFFER +vec3 normal=texture2D(depthNormalSampler,vUV).gba; +#else +vec3 normal=texture2D(normalSampler,vUV).rgb; +#endif +float occlusion=0.0; +float correctedRadius=min(radius,minZAspect*depth/near); +vec3 vViewRay=vec3((vUV.x*2.0-1.0)*xViewport,(vUV.y*2.0-1.0)*yViewport,depthSign); +vec3 origin=vViewRay*depth; +vec3 rvec=random*2.0-1.0; +rvec.z=0.0; + +float dotProduct=dot(rvec,normal); +rvec=1.0-abs(dotProduct)>1e-2 ? rvec : vec3(-rvec.y,0.0,rvec.x); +vec3 tangent=normalize(rvec-normal*dot(rvec,normal)); +vec3 bitangent=cross(normal,tangent); +mat3 tbn=mat3(tangent,bitangent,normal); +float difference; +for (int i=0; i1.0 || offset.y>1.0) { +continue; +} + +#ifndef GEOMETRYBUFFER +float sampleDepth=abs(texture2D(depthNormalSampler,offset.xy).r); +#else +float sampleDepth=abs(texture2D(depthSampler,offset.xy).r); +#endif + +difference=depthSign*samplePosition.z-sampleDepth; +float rangeCheck=1.0-smoothstep(correctedRadius*0.5,correctedRadius,difference); +occlusion+=(difference>=0.0 ? 1.0 : 0.0)*rangeCheck; +} +occlusion=occlusion*(1.0-smoothstep(maxZ*0.75,maxZ,depth)); +float ao=1.0-totalStrength*occlusion*samplesFactor; +float result=clamp(ao+base,0.0,1.0); +gl_FragColor=vec4(vec3(result),1.0); +} +#endif +#ifdef BILATERAL_BLUR +uniform sampler2D depthNormalSampler; +uniform float outSize; +uniform float samplerOffsets[SAMPLES]; +vec4 blur9(sampler2D image,vec2 uv,float resolution,vec2 direction) { +vec4 color=vec4(0.0); +vec2 off1=vec2(1.3846153846)*direction; +vec2 off2=vec2(3.2307692308)*direction; +color+=texture2D(image,uv)*0.2270270270; +color+=texture2D(image,uv+(off1/resolution))*0.3162162162; +color+=texture2D(image,uv-(off1/resolution))*0.3162162162; +color+=texture2D(image,uv+(off2/resolution))*0.0702702703; +color+=texture2D(image,uv-(off2/resolution))*0.0702702703; +return color; +} +vec4 blur13(sampler2D image,vec2 uv,float resolution,vec2 direction) { +vec4 color=vec4(0.0); +vec2 off1=vec2(1.411764705882353)*direction; +vec2 off2=vec2(3.2941176470588234)*direction; +vec2 off3=vec2(5.176470588235294)*direction; +color+=texture2D(image,uv)*0.1964825501511404; +color+=texture2D(image,uv+(off1/resolution))*0.2969069646728344; +color+=texture2D(image,uv-(off1/resolution))*0.2969069646728344; +color+=texture2D(image,uv+(off2/resolution))*0.09447039785044732; +color+=texture2D(image,uv-(off2/resolution))*0.09447039785044732; +color+=texture2D(image,uv+(off3/resolution))*0.010381362401148057; +color+=texture2D(image,uv-(off3/resolution))*0.010381362401148057; +return color; +} +vec4 blur13Bilateral(sampler2D image,vec2 uv,float resolution,vec2 direction) { +vec4 color=vec4(0.0); +vec2 off1=vec2(1.411764705882353)*direction; +vec2 off2=vec2(3.2941176470588234)*direction; +vec2 off3=vec2(5.176470588235294)*direction; +float compareDepth=abs(texture2D(depthNormalSampler,uv).r); +float sampleDepth; +float weight; +float weightSum=30.0; +color+=texture2D(image,uv)*30.0; +sampleDepth=abs(texture2D(depthNormalSampler,uv+(off1/resolution)).r); +weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0); +weightSum+=weight; +color+=texture2D(image,uv+(off1/resolution))*weight; +sampleDepth=abs(texture2D(depthNormalSampler,uv-(off1/resolution)).r); +weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0); +weightSum+=weight; +color+=texture2D(image,uv-(off1/resolution))*weight; +sampleDepth=abs(texture2D(depthNormalSampler,uv+(off2/resolution)).r); +weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0); +weightSum+=weight; +color+=texture2D(image,uv+(off2/resolution))*weight; +sampleDepth=abs(texture2D(depthNormalSampler,uv-(off2/resolution)).r); +weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0); +weightSum+=weight; +color+=texture2D(image,uv-(off2/resolution))*weight; +sampleDepth=abs(texture2D(depthNormalSampler,uv+(off3/resolution)).r); +weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0); +weightSum+=weight; +color+=texture2D(image,uv+(off3/resolution))*weight; +sampleDepth=abs(texture2D(depthNormalSampler,uv-(off3/resolution)).r); +weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0); +weightSum+=weight; +color+=texture2D(image,uv-(off3/resolution))*weight; +return color/weightSum; +} +void main() +{ +#if EXPENSIVE +float compareDepth=abs(texture2D(depthNormalSampler,vUV).r); +float texelsize=1.0/outSize; +float result=0.0; +float weightSum=0.0; +for (int i=0; i=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;n0?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 +#define BILATERAL_BLUR_V +#define SAMPLES 16 +#define EXPENSIVE `+(o?"1":"0")+` +`),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;o0.0) +hitCoord-=dir; +else +hitCoord+=dir; +info.color+=texture2D(textureSampler,projectedCoord.xy).rgb; +} +projectedCoord=projection*vec4(hitCoord,1.0); +projectedCoord.xy/=projectedCoord.w; +projectedCoord.xy=0.5*projectedCoord.xy+vec2(0.5); + +info.coords=vec4(projectedCoord.xy,sampledDepth,1.0); +info.color+=texture2D(textureSampler,projectedCoord.xy).rgb; +info.color/=float(SMOOTH_STEPS+1); +return info; +} + +ReflectionInfo getReflectionInfo(vec3 dir,vec3 hitCoord) +{ +ReflectionInfo info; +vec4 projectedCoord; +float sampledDepth; +dir*=step; +for(int i=0; i>0)),e.push("#define SMOOTH_STEPS "+(this._smoothSteps>>0)),this.updateEffect(e.join(` +`))},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"]=jc;var Sg=`uniform sampler2D textureSampler; +varying vec2 vUV; +#if defined(PASS_POST_PROCESS) +void main(void) +{ +vec4 color=texture2D(textureSampler,vUV); +gl_FragColor=color; +} +#endif +#if defined(DOWN_SAMPLE_X4) +uniform vec2 dsOffsets[16]; +void main(void) +{ +vec4 average=vec4(0.0,0.0,0.0,0.0); +average=texture2D(textureSampler,vUV+dsOffsets[0]); +average+=texture2D(textureSampler,vUV+dsOffsets[1]); +average+=texture2D(textureSampler,vUV+dsOffsets[2]); +average+=texture2D(textureSampler,vUV+dsOffsets[3]); +average+=texture2D(textureSampler,vUV+dsOffsets[4]); +average+=texture2D(textureSampler,vUV+dsOffsets[5]); +average+=texture2D(textureSampler,vUV+dsOffsets[6]); +average+=texture2D(textureSampler,vUV+dsOffsets[7]); +average+=texture2D(textureSampler,vUV+dsOffsets[8]); +average+=texture2D(textureSampler,vUV+dsOffsets[9]); +average+=texture2D(textureSampler,vUV+dsOffsets[10]); +average+=texture2D(textureSampler,vUV+dsOffsets[11]); +average+=texture2D(textureSampler,vUV+dsOffsets[12]); +average+=texture2D(textureSampler,vUV+dsOffsets[13]); +average+=texture2D(textureSampler,vUV+dsOffsets[14]); +average+=texture2D(textureSampler,vUV+dsOffsets[15]); +average/=16.0; +gl_FragColor=average; +} +#endif +#if defined(BRIGHT_PASS) +uniform vec2 dsOffsets[4]; +uniform float brightThreshold; +void main(void) +{ +vec4 average=vec4(0.0,0.0,0.0,0.0); +average=texture2D(textureSampler,vUV+vec2(dsOffsets[0].x,dsOffsets[0].y)); +average+=texture2D(textureSampler,vUV+vec2(dsOffsets[1].x,dsOffsets[1].y)); +average+=texture2D(textureSampler,vUV+vec2(dsOffsets[2].x,dsOffsets[2].y)); +average+=texture2D(textureSampler,vUV+vec2(dsOffsets[3].x,dsOffsets[3].y)); +average*=0.25; +float luminance=length(average.rgb); +if (luminanceshadowPixelDepth) +accumFog+=sunColor*computeScattering(dot(rayDirection,sunDirection)); +currentPosition+=stepL; +} +accumFog/=NB_STEPS; +vec3 color=accumFog*scatteringPower; +gl_FragColor=vec4(color*exp(color) ,1.0); +} +#endif +#if defined(VLSMERGE) +uniform sampler2D originalSampler; +void main(void) +{ +gl_FragColor=texture2D(originalSampler,vUV)+texture2D(textureSampler,vUV); +} +#endif +#if defined(LUMINANCE) +uniform vec2 lumOffsets[4]; +void main() +{ +float average=0.0; +vec4 color=vec4(0.0); +float maximum=-1e20; +vec3 weight=vec3(0.299,0.587,0.114); +for (int i=0; i<4; i++) +{ +color=texture2D(textureSampler,vUV+ lumOffsets[i]); + +float GreyValue=dot(color.rgb,vec3(0.33,0.33,0.33)); + +#ifdef WEIGHTED_AVERAGE +float GreyValue=dot(color.rgb,weight); +#endif +#ifdef BRIGHTNESS +float GreyValue=max(color.r,max(color.g,color.b)); +#endif +#ifdef HSL_COMPONENT +float GreyValue=0.5*(max(color.r,max(color.g,color.b))+min(color.r,min(color.g,color.b))); +#endif +#ifdef MAGNITUDE +float GreyValue=length(color.rgb); +#endif +maximum=max(maximum,GreyValue); +average+=(0.25*log(1e-5+GreyValue)); +} +average=exp(average); +gl_FragColor=vec4(average,maximum,0.0,1.0); +} +#endif +#if defined(LUMINANCE_DOWN_SAMPLE) +uniform vec2 dsOffsets[9]; +uniform float halfDestPixelSize; +#ifdef FINAL_DOWN_SAMPLER +#include +#endif +void main() +{ +vec4 color=vec4(0.0); +float average=0.0; +for (int i=0; i<9; i++) +{ +color=texture2D(textureSampler,vUV+vec2(halfDestPixelSize,halfDestPixelSize)+dsOffsets[i]); +average+=color.r; +} +average/=9.0; +#ifdef FINAL_DOWN_SAMPLER +gl_FragColor=pack(average); +#else +gl_FragColor=vec4(average,average,0.0,1.0); +#endif +} +#endif +#if defined(HDR) +uniform sampler2D textureAdderSampler; +uniform float averageLuminance; +void main() +{ +vec4 color=texture2D(textureAdderSampler,vUV); +#ifndef AUTO_EXPOSURE +vec4 adjustedColor=color/averageLuminance; +color=adjustedColor; +color.a=1.0; +#endif +gl_FragColor=color; +} +#endif +#if defined(LENS_FLARE) +#define GHOSTS 3 +uniform sampler2D lensColorSampler; +uniform float strength; +uniform float ghostDispersal; +uniform float haloWidth; +uniform vec2 resolution; +uniform float distortionStrength; +float hash(vec2 p) +{ +float h=dot(p,vec2(127.1,311.7)); +return -1.0+2.0*fract(sin(h)*43758.5453123); +} +float noise(in vec2 p) +{ +vec2 i=floor(p); +vec2 f=fract(p); +vec2 u=f*f*(3.0-2.0*f); +return mix(mix(hash(i+vec2(0.0,0.0)), +hash(i+vec2(1.0,0.0)),u.x), +mix(hash(i+vec2(0.0,1.0)), +hash(i+vec2(1.0,1.0)),u.x),u.y); +} +float fbm(vec2 p) +{ +float f=0.0; +f+=0.5000*noise(p); p*=2.02; +f+=0.2500*noise(p); p*=2.03; +f+=0.1250*noise(p); p*=2.01; +f+=0.0625*noise(p); p*=2.04; +f/=0.9375; +return f; +} +vec3 pattern(vec2 uv) +{ +vec2 p=-1.0+2.0*uv; +float p2=dot(p,p); +float f=fbm(vec2(15.0*p2))/2.0; +float r=0.2+0.6*sin(12.5*length(uv-vec2(0.5))); +float g=0.2+0.6*sin(20.5*length(uv-vec2(0.5))); +float b=0.2+0.6*sin(17.2*length(uv-vec2(0.5))); +return (1.0-f)*vec3(r,g,b); +} +float luminance(vec3 color) +{ +return dot(color.rgb,vec3(0.2126,0.7152,0.0722)); +} +vec4 textureDistorted(sampler2D tex,vec2 texcoord,vec2 direction,vec3 distortion) +{ +return vec4( +texture2D(tex,texcoord+direction*distortion.r).r, +texture2D(tex,texcoord+direction*distortion.g).g, +texture2D(tex,texcoord+direction*distortion.b).b, +1.0 +); +} +void main(void) +{ +vec2 uv=-vUV+vec2(1.0); +vec2 ghostDir=(vec2(0.5)-uv)*ghostDispersal; +vec2 texelSize=1.0/resolution; +vec3 distortion=vec3(-texelSize.x*distortionStrength,0.0,texelSize.x*distortionStrength); +vec4 result=vec4(0.0); +float ghostIndice=1.0; +for (int i=0; i=nSamples) +break; +vec2 offset1=vUV+velocity*(float(i)/float(nSamples-1)-0.5); +result+=texture2D(textureSampler,offset1); +} +gl_FragColor=result/float(nSamples); +} +#endif +`;ze.a.ShadersStore.standardPixelShader=Sg;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(` +`))}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"motionStrength",{get:function(){return this._motionStrength},set:function(e){this._motionStrength=e,this._isObjectBasedMotionBlur&&this.motionBlurPostProcess&&(this.motionBlurPostProcess.motionStrength=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"objectBasedMotionBlur",{get:function(){return this._isObjectBasedMotionBlur},set:function(e){var n=this._isObjectBasedMotionBlur!==e;this._isObjectBasedMotionBlur=e,n&&this._buildPipeline()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"BloomEnabled",{get:function(){return this._bloomEnabled},set:function(e){this._bloomEnabled!==e&&(this._bloomEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"DepthOfFieldEnabled",{get:function(){return this._depthOfFieldEnabled},set:function(e){this._depthOfFieldEnabled!==e&&(this._depthOfFieldEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"LensFlareEnabled",{get:function(){return this._lensFlareEnabled},set:function(e){this._lensFlareEnabled!==e&&(this._lensFlareEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"HDREnabled",{get:function(){return this._hdrEnabled},set:function(e){this._hdrEnabled!==e&&(this._hdrEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"VLSEnabled",{get:function(){return this._vlsEnabled},set:function(e){if(this._vlsEnabled!==e){if(e&&!this._scene.enableGeometryBufferRenderer())return void 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 +#define NB_STEPS `+e.toFixed(1)),this._volumetricLightStepsCount=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"motionBlurSamples",{get:function(){return this._motionBlurSamples},set:function(e){this.motionBlurPostProcess&&(this._isObjectBasedMotionBlur?this.motionBlurPostProcess.motionBlurSamples=e:this.motionBlurPostProcess.updateEffect(`#define MOTION_BLUR +#define MAX_MOTION_SAMPLES `+e.toFixed(1))),this._motionBlurSamples=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"samples",{get:function(){return this._samples},set:function(e){this._samples!==e&&(this._samples=e,this._buildPipeline())},enumerable:!1,configurable:!0}),t.prototype._buildPipeline=function(){var e=this,n=this._ratio,i=this._scene;this._disposePostProcesses(),this._cameras!==null&&(this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),this._cameras=this._camerasToBeAttached.slice()),this._reset(),this._screenSpaceReflectionsEnabled&&(this.screenSpaceReflectionPostProcess=new jc("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},!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 Oo("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,b=-2;b<2;b++)for(var P=-2;P<2;P++)o[s]=(b+.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 gn("HDRBlurH_"+i,new u.d(1,0),this[o],n,null,we.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,this._floatTextureType),p=new gn("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 b=d.width/s.getRenderWidth();d.kernel=a[o]*b}),p.onActivateObservable.add(function(){var b=p.height/s.getRenderHeight();p.kernel=a.horizontalBlur?64*b:a[o]*b}),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?i._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 +#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,B=1/i.luminancePostProcess.height;a[0]=-.5*O,a[1]=.5*B,a[2]=.5*O,a[3]=.5*B,a[4]=-.5*O,a[5]=-.5*B,a[6]=.5*O,a[7]=-.5*B,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 +`;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 b=this.luminancePostProcess;this.luminanceDownSamplePostProcesses.forEach(function(P,O){var B=new Array(18);P.onApply=function(F){if(b){for(var z=0,J=-1;J<2;J++)for(var ie=-1;ie<2;ie++)B[z]=J/b.width,B[z+1]=ie/b.height,z+=2;F.setArray2("dsOffsets",B),F.setFloat("halfDestPixelSize",.5/b.width),b=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(` +`),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 b=(d-s)/1e3;i._hdrCurrentLuminancea-i.hdrIncreaseRate*b?a-=i.hdrIncreaseRate*b: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[0]: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),b=i._scene.activeCamera.getViewMatrix().getRow(2),P=u.e.Dot(p.toVector3(),new u.e(1,0,0))+u.e.Dot(b.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),B=s.multiply(O).multiply(a);d.setMatrix("lensStarMatrix",B),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 Gc("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 +#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(),b=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,b.x=i.motionBlurPostProcess.width,b.y=i.motionBlurPostProcess.height,P.setVector2("screenSize",b),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;e0.5; +useCamA=!useCamB; +texCoord1=vec2(useCamB ? (vUV.x-0.5)*2.0 : vUV.x*2.0,vUV.y); +texCoord2=vec2(texCoord1.x+stepSize.x,vUV.y); +#else +#ifdef IS_STEREOSCOPIC_INTERLACED +float rowNum=floor(vUV.y/stepSize.y); +useCamA=mod(rowNum,2.0) == 1.0; +useCamB=mod(rowNum,2.0) == 0.0; +texCoord1=vec2(vUV.x,vUV.y); +texCoord2=vec2(vUV.x,vUV.y); +#else +useCamB=vUV.y>0.5; +useCamA=!useCamB; +texCoord1=vec2(vUV.x,useCamB ? (vUV.y-0.5)*2.0 : vUV.y*2.0); +texCoord2=vec2(vUV.x,texCoord1.y+stepSize.y); +#endif +#endif + +if (useCamB){ +frag1=texture2D(textureSampler,texCoord1).rgb; +frag2=texture2D(textureSampler,texCoord2).rgb; +}else if (useCamA){ +frag1=texture2D(camASampler ,texCoord1).rgb; +frag2=texture2D(camASampler ,texCoord2).rgb; +}else { +discard; +} +gl_FragColor=vec4((frag1+frag2)/TWO,1.0); +} +`;ze.a.ShadersStore.stereoscopicInterlacePixelShader=Ag;var Pg=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(b){b.setTextureFromPostProcess("camASampler",p._passedProcess),b.setFloat2("stepSize",p._stepSize.x,p._stepSize.y)}),p}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"StereoscopicInterlacePostProcessI"},t}(_t),xg=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),Cg=` +varying vec2 vUV; +uniform sampler2D textureSampler; + +uniform float _ExposureAdjustment; +#if defined(HABLE_TONEMAPPING) +const float A=0.15; +const float B=0.50; +const float C=0.10; +const float D=0.20; +const float E=0.02; +const float F=0.30; +const float W=11.2; +#endif +float Luminance(vec3 c) +{ +return dot(c,vec3(0.22,0.707,0.071)); +} +void main(void) +{ +vec3 colour=texture2D(textureSampler,vUV).rgb; +#if defined(REINHARD_TONEMAPPING) +float lum=Luminance(colour.rgb); +float lumTm=lum*_ExposureAdjustment; +float scale=lumTm/(1.0+lumTm); +colour*=scale/lum; +#elif defined(HABLE_TONEMAPPING) +colour*=_ExposureAdjustment; +const float ExposureBias=2.0; +vec3 x=ExposureBias*colour; +vec3 curr=((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F; +x=vec3(W,W,W); +vec3 whiteScale=1.0/(((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F); +colour=curr*whiteScale; +#elif defined(OPTIMIZED_HEJIDAWSON_TONEMAPPING) +colour*=_ExposureAdjustment; +vec3 X=max(vec3(0.0,0.0,0.0),colour-0.004); +vec3 retColor=(X*(6.2*X+0.5))/(X*(6.2*X+1.7)+0.06); +colour=retColor*retColor; +#elif defined(PHOTOGRAPHIC_TONEMAPPING) +colour=vec3(1.0,1.0,1.0)-exp2(-_ExposureAdjustment*colour); +#endif +gl_FragColor=vec4(colour.rgb,1.0); +}`;ze.a.ShadersStore.tonemapPixelShader=Cg;var cr;(function(r){r[r.Hable=0]="Hable",r[r.Reinhard=1]="Reinhard",r[r.HejiDawson=2]="HejiDawson",r[r.Photographic=3]="Photographic"})(cr||(cr={}));var Rg=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 b="#define ";return p._operator===cr.Hable?b+="HABLE_TONEMAPPING":p._operator===cr.Reinhard?b+="REINHARD_TONEMAPPING":p._operator===cr.HejiDawson?b+="OPTIMIZED_HEJIDAWSON_TONEMAPPING":p._operator===cr.Photographic&&(b+="PHOTOGRAPHIC_TONEMAPPING"),p.updateEffect(b),p.onApply=function(P){P.setFloat("_ExposureAdjustment",p.exposureAdjustment)},p}return Object(c.d)(t,r),t.prototype.getClassName=function(){return"TonemapPostProcess"},t}(_t),Og=`uniform sampler2D textureSampler; +uniform sampler2D lightScatteringSampler; +uniform float decay; +uniform float exposure; +uniform float weight; +uniform float density; +uniform vec2 meshPositionOnScreen; +varying vec2 vUV; +void main(void) { +vec2 tc=vUV; +vec2 deltaTexCoord=(tc-meshPositionOnScreen.xy); +deltaTexCoord*=1.0/float(NUM_SAMPLES)*density; +float illuminationDecay=1.0; +vec4 color=texture2D(lightScatteringSampler,tc)*0.4; +for(int i=0; i +#include +#include[0..maxSimultaneousMorphTargets] + +#include +uniform mat4 viewProjection; +uniform vec2 depthValues; +#if defined(ALPHATEST) || defined(NEED_UV) +varying vec2 vUV; +uniform mat4 diffuseMatrix; +#ifdef UV1 +attribute vec2 uv; +#endif +#ifdef UV2 +attribute vec2 uv2; +#endif +#endif +void main(void) +{ +vec3 positionUpdated=position; +#if (defined(ALPHATEST) || defined(NEED_UV)) && defined(UV1) +vec2 uvUpdated=uv; +#endif +#include[0..maxSimultaneousMorphTargets] +#include +#include +gl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0); +#if defined(ALPHATEST) || defined(BASIC_RENDER) +#ifdef UV1 +vUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0)); +#endif +#ifdef UV2 +vUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0)); +#endif +#endif +} +`;ze.a.ShadersStore.volumetricLightScatteringPassVertexShader=Mg;var Ig=`#if defined(ALPHATEST) || defined(NEED_UV) +varying vec2 vUV; +#endif +#if defined(ALPHATEST) +uniform sampler2D diffuseSampler; +#endif +void main(void) +{ +#if defined(ALPHATEST) +vec4 diffuseColor=texture2D(diffuseSampler,vUV); +if (diffuseColor.a<0.4) +discard; +#endif +gl_FragColor=vec4(0.0,0.0,0.0,1.0); +} +`;ze.a.ShadersStore.volumetricLightScatteringPassPixelShader=Ig;var Hd=function(r){function t(e,n,i,o,a,s,d,p,b){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=(b=i===null?b:i.getScene()).getEngine(),P._viewPort=new Qn.a(0,0,1,1).toGlobal(d.getRenderWidth(),d.getRenderHeight()),P.mesh=o!==null?o:t.CreateDefaultMesh("VolumetricLightScatteringMesh",b),P._createPass(b,n.passRatio||n),P.onActivate=function(O){P.isSupported||P.dispose(O),P.onActivate=null},P.onApplyObservable.add(function(O){P._updateMeshScreenCoordinates(b),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")},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=[Oe.b.PositionKind],s=e.getMaterial();s&&(s.needAlphaTesting()&&o.push("#define ALPHATEST"),i.isVerticesDataPresent(Oe.b.UVKind)&&(a.push(Oe.b.UVKind),o.push("#define UV1")),i.isVerticesDataPresent(Oe.b.UV2Kind)&&(a.push(Oe.b.UV2Kind),o.push("#define UV2"))),i.useBones&&i.computeBonesUsingShaders?(a.push(Oe.b.MatricesIndicesKind),a.push(Oe.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"),et.a.PushAttributesForInstances(a),e.getRenderingMesh().hasThinInstances&&o.push("#define THIN_INSTANCES"));var d=o.join(` +`);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(b){var P=b.getRenderingMesh(),O=b.getEffectiveMesh();if(!i._meshExcluded(P)){O._internalAbstractMeshDataInfo._isActiveIntermediate=!1;var B=b.getMaterial();if(B){var F=P.getScene(),z=F.getEngine();z.setState(B.backFaceCulling);var J=P._getInstancesRenderList(b._id,!!b.getReplacementMesh());if(!J.mustReturn){var ie=z.getCaps().instancedArrays&&(J.visibleInstances[b._id]!==null||P.hasThinInstances);if(i._isReady(b,ie)){var se=i._volumetricLightScatteringPass;if(P===i.mesh&&(se=b.effect?b.effect:B.getEffect()),z.enableEffect(se),P._bind(b,se,B.fillMode),P===i.mesh)B.bind(O.getWorldMatrix(),P);else{if(i._volumetricLightScatteringPass.setMatrix("viewProjection",F.getTransformMatrix()),B&&B.needAlphaTesting()){var ce=B.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,b,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(b,P,O,B){var F,z=e.getEngine();if(B.length){for(z.setColorWrite(!1),F=0;Fue._alphaIndex?1:ce._alphaIndexue._distanceToCamera?-1:0}),z.setAlphaMode(h.a.ALPHA_COMBINE),F=0;F1||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"]=Wd,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 Xd(this)),this._boundingBoxRenderer},Object.defineProperty(Dt.a.prototype,"showBoundingBox",{get:function(){return this._showBoundingBox||!1},set:function(r){this._showBoundingBox=r,r&&this.getScene().getBoundingBoxRenderer()},enumerable:!0,configurable:!0});var Xd=function(){function r(t){this.name=at.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 C.c,this.onAfterBoxRenderingObservable=new C.c,this.onResourcesReadyObservable=new C.c,this.enabled=!0,this.renderList=new fi.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(at.a.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER,this,this.reset),this.scene._preActiveMeshStage.registerStep(at.a.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER,this,this._preActiveMesh),this.scene._evaluateSubMeshStage.registerStep(at.a.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER,this,this._evaluateSubMesh),this.scene._afterRenderingGroupDrawStage.registerStep(at.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 ua.a("colorShader",this.scene,"color",{attributes:[Oe.b.PositionKind],uniforms:["world","viewProjection","color"]}),this._colorShader.reservedDataStore={hidden:!0};var t=this.scene.getEngine(),e=ft.a.CreateBox({size:1});this._vertexBuffers[Oe.b.PositionKind]=new Oe.b(t,e.positions,Oe.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[Oe.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 + +attribute vec3 position; +attribute vec4 normal; + +uniform mat4 viewProjection; +uniform float width; +uniform float aspectRatio; +void main(void) { +#include +mat4 worldViewProjection=viewProjection*finalWorld; +vec4 viewPosition=worldViewProjection*vec4(position,1.0); +vec4 viewPositionNext=worldViewProjection*vec4(normal.xyz,1.0); +vec2 currentScreen=viewPosition.xy/viewPosition.w; +vec2 nextScreen=viewPositionNext.xy/viewPositionNext.w; +currentScreen.x*=aspectRatio; +nextScreen.x*=aspectRatio; +vec2 dir=normalize(nextScreen-currentScreen); +vec2 normalDir=vec2(-dir.y,dir.x); +normalDir*=width/2.0; +normalDir.x/=aspectRatio; +vec4 offset=vec4(normalDir*normal.w,0.0,0.0); +gl_Position=viewPosition+offset; +}`;ze.a.ShadersStore.lineVertexShader=Lg,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 Hc(this,r,t,!0,e),this},Object.defineProperty(Dt.a.prototype,"edgesRenderer",{get:function(){return this._edgesRenderer},enumerable:!0,configurable:!0}),So.b.prototype.enableEdgesRendering=function(r,t){return r===void 0&&(r=.95),t===void 0&&(t=!1),this.disableEdgesRendering(),this._edgesRenderer=new Kd(this,r,t),this},So.a.prototype.enableEdgesRendering=function(r,t){return r===void 0&&(r=.95),t===void 0&&(t=!1),So.b.prototype.enableEdgesRendering.apply(this,arguments),this};var Ng=function(){this.edges=new Array,this.edgesConnectedCount=0},Hc=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.edgesWidthScalerForOrthographic=1e3,this.edgesWidthScalerForPerspective=50,this._linesPositions=new Array,this._linesNormals=new Array,this._linesIndices=new Array,this._buffers={},this._buffersForInstances={},this._checkVerticesInsteadOfIndices=!1,this.isEnabled=!0,this.customInstances=new fi.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 ua.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[Oe.b.PositionKind];t&&t._rebuild(),(t=this._buffers[Oe.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[Oe.b.PositionKind];t&&(t.dispose(),this._buffers[Oe.b.PositionKind]=null),(t=this._buffers[Oe.b.NormalKind])&&(t.dispose(),this._buffers[Oe.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])=0&&Ee.push(Se);for(var Le=0;Le=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(Ae,Ee){return Ae[1]Ee[1]?1:0}):t[s].sort(function(Ae,Ee){return Ae[1]>Ee[1]?-1:Ae[1]=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[b-1]);for(var B=b<=O,F=B?b:O,z=B?O:b,J=B?b-1:O-1,ie=B?0:1,se=b+O-2,ce=0,ue=0,fe=B?d:p,ve=B?p:d,Te=0;se-- >0;){ie?n.push(fe[ce],ve[ue]):n.push(ve[ue],fe[ce]);var Re=void 0;(Te+=F)>=z&&ceYe){var Et=Fe;Fe=Ye,Ye=Et}($t=zt[Mt=Fe+"_"+Ye])?$t.done||(u.e.Dot(Yt,$t.normal)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;d0&&(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 qs("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 Go("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},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 +#include +#include +#include +varying vec2 vUV; +uniform vec2 texelSize; +uniform sampler2D textureSampler; +uniform sampler2D irradianceSampler; +uniform sampler2D depthSampler; +uniform sampler2D albedoSampler; +uniform vec2 viewportSize; +uniform float metersPerUnit; +const float LOG2_E=1.4426950408889634; +const float SSS_PIXELS_PER_SAMPLE=4.; +const int _SssSampleBudget=40; +#define rcp(x) 1./x +#define Sq(x) x*x +#define SSS_BILATERAL_FILTER true + + +vec3 EvalBurleyDiffusionProfile(float r,vec3 S) +{ +vec3 exp_13=exp2(((LOG2_E*(-1.0/3.0))*r)*S); +vec3 expSum=exp_13*(1.+exp_13*exp_13); +return (S*rcp(8.*PI))*expSum; +} + + + + + + +vec2 SampleBurleyDiffusionProfile(float u,float rcpS) +{ +u=1.-u; +float g=1.+(4.*u)*(2.*u+sqrt(1.+(4.*u)*u)); +float n=exp2(log2(g)*(-1.0/3.0)); +float p=(g*n)*n; +float c=1.+p+n; +float d=(3./LOG2_E*2.)+(3./LOG2_E)*log2(u); +float x=(3./LOG2_E)*log2(c)-d; + + + + + + +float rcpExp=((c*c)*c)*rcp((4.*u)*((c*c)+(4.*u)*(4.*u))); +float r=x*rcpS; +float rcpPdf=(8.*PI*rcpS)*rcpExp; +return vec2(r,rcpPdf); +} + + +vec3 ComputeBilateralWeight(float xy2,float z,float mmPerUnit,vec3 S,float rcpPdf) +{ +#ifndef SSS_BILATERAL_FILTER +z=0.; +#endif + + + +float r=sqrt(xy2+(z*mmPerUnit)*(z*mmPerUnit)); +float area=rcpPdf; +#if SSS_CLAMP_ARTIFACT +return clamp(EvalBurleyDiffusionProfile(r,S)*area,0.0,1.0); +#else +return EvalBurleyDiffusionProfile(r,S)*area; +#endif +} +void EvaluateSample(int i,int n,vec3 S,float d,vec3 centerPosVS,float mmPerUnit,float pixelsPerMm, +float phase,inout vec3 totalIrradiance,inout vec3 totalWeight) +{ + +float scale=rcp(float(n)); +float offset=rcp(float(n))*0.5; + +float sinPhase,cosPhase; +sinPhase=sin(phase); +cosPhase=cos(phase); +vec2 bdp=SampleBurleyDiffusionProfile(float(i)*scale+offset,d); +float r=bdp.x; +float rcpPdf=bdp.y; +float phi=SampleDiskGolden(i,n).y; +float sinPhi,cosPhi; +sinPhi=sin(phi); +cosPhi=cos(phi); +float sinPsi=cosPhase*sinPhi+sinPhase*cosPhi; +float cosPsi=cosPhase*cosPhi-sinPhase*sinPhi; +vec2 vec=r*vec2(cosPsi,sinPsi); + +vec2 position; +float xy2; +position=vUV+round((pixelsPerMm*r)*vec2(cosPsi,sinPsi))*texelSize; +xy2=r*r; +vec4 textureSample=texture2D(irradianceSampler,position); +float viewZ=texture2D(depthSampler,position).r; +vec3 irradiance=textureSample.rgb; +if (testLightingForSSS(textureSample.a)) +{ + +float relZ=viewZ-centerPosVS.z; +vec3 weight=ComputeBilateralWeight(xy2,relZ,mmPerUnit,S,rcpPdf); +totalIrradiance+=weight*irradiance; +totalWeight+=weight; +} +else +{ + + + + + + +} +} +void main(void) +{ +vec4 irradianceAndDiffusionProfile=texture2D(irradianceSampler,vUV); +vec3 centerIrradiance=irradianceAndDiffusionProfile.rgb; +int diffusionProfileIndex=int(round(irradianceAndDiffusionProfile.a*255.)); +float centerDepth=0.; +vec4 inputColor=texture2D(textureSampler,vUV); +bool passedStencilTest=testLightingForSSS(irradianceAndDiffusionProfile.a); +if (passedStencilTest) +{ +centerDepth=texture2D(depthSampler,vUV).r; +} +if (!passedStencilTest) { +gl_FragColor=inputColor; +return; +} +float distScale=1.; +vec3 S=diffusionS[diffusionProfileIndex]; +float d=diffusionD[diffusionProfileIndex]; +float filterRadius=filterRadii[diffusionProfileIndex]; + +vec2 centerPosNDC=vUV; +vec2 cornerPosNDC=vUV+0.5*texelSize; +vec3 centerPosVS=vec3(centerPosNDC*viewportSize,1.0)*centerDepth; +vec3 cornerPosVS=vec3(cornerPosNDC*viewportSize,1.0)*centerDepth; + +float mmPerUnit=1000.*(metersPerUnit*rcp(distScale)); +float unitsPerMm=rcp(mmPerUnit); + + +float unitsPerPixel=2.*abs(cornerPosVS.x-centerPosVS.x); +float pixelsPerMm=rcp(unitsPerPixel)*unitsPerMm; + +float filterArea=PI*Sq(filterRadius*pixelsPerMm); +int sampleCount=int(filterArea*rcp(SSS_PIXELS_PER_SAMPLE)); +int sampleBudget=_SssSampleBudget; +int texturingMode=0; +vec3 albedo=texture2D(albedoSampler,vUV).rgb; +if (distScale == 0. || sampleCount<1) +{ +#ifdef DEBUG_SSS_SAMPLES +vec3 green=vec3(0.,1.,0.); +gl_FragColor=vec4(green,1.0); +return; +#endif +gl_FragColor=vec4(inputColor.rgb+albedo*centerIrradiance,1.0); +return; +} +#ifdef DEBUG_SSS_SAMPLES +vec3 red=vec3(1.,0.,0.); +vec3 blue=vec3(0.,0.,1.); +gl_FragColor=vec4(mix(blue,red,clamp(float(sampleCount)/float(sampleBudget),0.0,1.0)),1.0); +return; +#endif + +float phase=0.; +int n=min(sampleCount,sampleBudget); + +vec3 centerWeight=vec3(0.); +vec3 totalIrradiance=vec3(0.); +vec3 totalWeight=vec3(0.); +for (int i=0; i=5)return l.a.Error("You already reached the maximum number of diffusion profiles."),0;for(var e=0;e +void main(void) { +#ifdef ALPHATEST +if (texture2D(diffuseSampler,vUV).a<0.4) +discard; +#endif +#include +gl_FragColor=color; +}`;ze.a.ShadersStore.outlinePixelShader=Vg;var kg=` +attribute vec3 position; +attribute vec3 normal; +#include +#include +#include[0..maxSimultaneousMorphTargets] + +uniform float offset; +#include +uniform mat4 viewProjection; +#ifdef ALPHATEST +varying vec2 vUV; +uniform mat4 diffuseMatrix; +#ifdef UV1 +attribute vec2 uv; +#endif +#ifdef UV2 +attribute vec2 uv2; +#endif +#endif +#include +void main(void) +{ +vec3 positionUpdated=position; +vec3 normalUpdated=normal; +#ifdef UV1 +vec2 uvUpdated=uv; +#endif +#include[0..maxSimultaneousMorphTargets] +vec3 offsetPosition=positionUpdated+(normalUpdated*offset); +#include +#include +gl_Position=viewProjection*finalWorld*vec4(offsetPosition,1.0); +#ifdef ALPHATEST +#ifdef UV1 +vUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0)); +#endif +#ifdef UV2 +vUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0)); +#endif +#endif +#include +} +`;ze.a.ShadersStore.outlineVertexShader=kg,_e.a.prototype.getOutlineRenderer=function(){return this._outlineRenderer||(this._outlineRenderer=new Jd(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 Jd=function(){function r(t){this.name=at.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(at.a.STEP_BEFORERENDERINGMESH_OUTLINE,this,this._beforeRenderingMesh),this.scene._afterRenderingMeshStage.registerStep(at.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,b=t.getRenderingMesh(),P=p||b,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:b.outlineWidth),this._effect.setColor4("color",n?b.overlayColor:b.outlineColor,n?b.overlayAlpha:O.alpha),this._effect.setMatrix("viewProjection",o.getTransformMatrix()),this._effect.setMatrix("world",P.getWorldMatrix()),b.useBones&&b.computeBonesUsingShaders&&b.skeleton&&this._effect.setMatrices("mBones",b.skeleton.getTransformMatrices(b)),et.a.BindMorphTargetParameters(b,this._effect),b._bind(t,this._effect,O.fillMode),O&&O.needAlphaTesting()){var B=O.getAlphaTestTexture();B&&(this._effect.setTexture("diffuseSampler",B),this._effect.setMatrix("diffuseMatrix",B.getTextureMatrix()))}a.setZOffset(-this.zOffset),b._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=[Oe.b.PositionKind,Oe.b.NormalKind],o=t.getMesh(),a=t.getMaterial();a&&(a.needAlphaTesting()&&(n.push("#define ALPHATEST"),o.isVerticesDataPresent(Oe.b.UVKind)&&(i.push(Oe.b.UVKind),n.push("#define UV1")),o.isVerticesDataPresent(Oe.b.UV2Kind)&&(i.push(Oe.b.UV2Kind),n.push("#define UV2"))),a.useLogarithmicDepth&&n.push("#define LOGARITHMICDEPTH")),o.useBones&&o.computeBonesUsingShaders?(i.push(Oe.b.MatricesIndicesKind),i.push(Oe.b.MatricesWeightsKind),o.numBoneInfluencers>4&&(i.push(Oe.b.MatricesIndicesExtraKind),i.push(Oe.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),et.a.PrepareAttributesForMorphTargetsInfluencers(i,o,d)),e&&(n.push("#define INSTANCES"),et.a.PushAttributesForInstances(i),t.getRenderingMesh().hasThinInstances&&n.push("#define THIN_INSTANCES"));var p=n.join(` +`);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}(),Gg=f(148),$d=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 C.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},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;ethis._delay&&(this._time=this._time%this._delay,this.cellIndex+=this._direction,(this._direction>0&&this.cellIndex>this._toIndex||this._direction<0&&this.cellIndex0?this._fromIndex:this._toIndex:(this.cellIndex=this._toIndex,this._animationStarted=!1,this._onBaseAnimationEnd&&this._onBaseAnimationEnd()))))},r}());_e.a.prototype._internalPickSprites=function(r,t,e,n){if(!nr.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=i.distance))&&(i=s,e))break}}return i||new nr.a},_e.a.prototype._internalMultiPickSprites=function(r,t,e){if(!nr.a)return null;var n=new Array;if(!e){if(!this.activeCamera)return null;e=this.activeCamera}if(this.spriteManagers.length>0)for(var i=0;i0&&(n=o.pickSprite(t,e,this._spritePredicate,!1,o.cameraToUseForPointers||void 0))&&n.hit&&n.pickedSprite&&n.pickedSprite.actionManager){switch(o._pickedDownSprite=n.pickedSprite,i.button){case 0:n.pickedSprite.actionManager.processTrigger(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}();ze.a.IncludesShadersStore.imageProcessingCompatibility=`#ifdef IMAGEPROCESSINGPOSTPROCESS +gl_FragColor.rgb=pow(gl_FragColor.rgb,vec3(2.2)); +#endif`;var zg=`uniform bool alphaTest; +varying vec4 vColor; + +varying vec2 vUV; +uniform sampler2D diffuseSampler; + +#include +void main(void) { +vec4 color=texture2D(diffuseSampler,vUV); +if (alphaTest) +{ +if (color.a<0.95) +discard; +} +color*=vColor; +#include +gl_FragColor=color; +#include +}`;ze.a.ShadersStore.spritesPixelShader=zg;var jg=` +attribute vec4 position; +attribute vec2 options; +attribute vec2 offsets; +attribute vec2 inverts; +attribute vec4 cellInfo; +attribute vec4 color; + +uniform mat4 view; +uniform mat4 projection; + +varying vec2 vUV; +varying vec4 vColor; +#include +void main(void) { +vec3 viewPos=(view*vec4(position.xyz,1.0)).xyz; +vec2 cornerPos; +float angle=position.w; +vec2 size=vec2(options.x,options.y); +vec2 offset=offsets.xy; +cornerPos=vec2(offset.x-0.5,offset.y-0.5)*size; + +vec3 rotatedCorner; +rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle); +rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle); +rotatedCorner.z=0.; + +viewPos+=rotatedCorner; +gl_Position=projection*vec4(viewPos,1.0); + +vColor=color; + +vec2 uvOffset=vec2(abs(offset.x-inverts.x),abs(1.0-offset.y-inverts.y)); +vec2 uvPlace=cellInfo.xy; +vec2 uvSize=cellInfo.zw; +vUV.x=uvPlace.x+uvSize.x*uvOffset.x; +vUV.y=uvPlace.y+uvSize.y*uvOffset.y; + +#ifdef FOG +vFogDistance=viewPos; +#endif +}`;ze.a.ShadersStore.spritesVertexShader=jg;var Hg=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>0;e._xOffset=(e.cellIndex-b*p)*this.cellWidth/o.width,e._yOffset=b*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.height,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}(),tf=function(){function r(t,e,n,i,o,a,s,d,p){var b=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 C.c,this.disableDepthWrite=!1,this._packedAndReady=!1,this._customUpdate=function(O,B){O.cellRef||(O.cellIndex=0);var F=O.cellIndex;typeof F=="number"&&isFinite(F)&&Math.floor(F)===F&&(O.cellRef=b._spriteMap[O.cellIndex]),O._xOffset=b._cellData[O.cellRef].frame.x/B.width,O._yOffset=b._cellData[O.cellRef].frame.y/B.height,O._xSize=b._cellData[O.cellRef].frame.w,O._ySize=b._cellData[O.cellRef].frame.h},o||(o=Ue.a.LastCreatedScene),o._getComponent(at.a.NAME_SPRITE)||o._addComponent(new ef(o)),this._fromPacked=d,this._scene=o;var P=this._scene.getEngine();if(this._spriteRenderer=new Hg(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;a0);var P=t.substring(0,b-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 B=JSON.parse(O.response),F=Reflect.ownKeys(B.frames);n._spriteMap=F,n._packedAndReady=!0,n._cellData=B.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,b=t.angle,P=d*Math.cos(b)-p*Math.sin(b)+.5,O=d*Math.sin(b)+p*Math.cos(b)+.5,B=t._xOffset*a.width+P*t._xSize|0,F=t._yOffset*a.height+O*t._ySize|0;return this._textureContent[4*(B+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,b=u.c.Vector3[0],P=u.c.Vector3[1],O=e.getViewMatrix(),B=0;Bz){if(!this._checkTextureAlpha(F,t,z,a,s))continue;if(d=z,p=F,i)break}}}}if(p){var J=new nr.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,b),J.pickedPoint=u.e.TransformCoordinates(b,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),b=u.c.Vector3[1].copyFromFloats(0,0,0),P=e.getViewMatrix(),O=0;O0.) { +mt=mod(time*animationData.z,1.0); +for(float f=0.; fmt){ +frameID=animationData.x; +break; +} +animationData=texture2D(animationMap,vec2((frameID+0.5)/spriteCount,aFrameSteps*f),0.); +} +} + +mat4 frameData=getFrameData(frameID+0.5); +vec2 frameSize=(frameData[0].wz)/spriteMapSize; +vec2 offset=frameData[0].xy*sheetUnits; +vec2 ratio=frameData[2].xy/frameData[0].wz; + +if (frameData[2].z == 1.){ +tileUV.xy=tileUV.yx; +} +if (i == 0){ +color=texture2D(spriteSheet,tileUV*frameSize+offset); +} else { +vec4 nc=texture2D(spriteSheet,tileUV*frameSize+offset); +float alpha=min(color.a+nc.a,1.0); +vec3 mixed=mix(color.xyz,nc.xyz,nc.a); +color=vec4(mixed,alpha); +} +} +color.xyz*=colorMul; +gl_FragColor=color; +}`;ze.a.ShadersStore.spriteMapPixelShader=Wg;var Xg=`precision highp float; + +attribute vec3 position; +attribute vec3 normal; +attribute vec2 uv; + +varying vec3 vPosition; +varying vec2 vUV; +varying vec2 tUV; +varying vec2 stageUnits; +varying vec2 levelUnits; +varying vec2 tileID; + +uniform float time; +uniform mat4 worldViewProjection; +uniform vec2 outputSize; +uniform vec2 stageSize; +uniform vec2 spriteMapSize; +uniform float stageScale; +void main() { +vec4 p=vec4( position,1. ); +vPosition=p.xyz; +vUV=uv; +tUV=uv*stageSize; +gl_Position=worldViewProjection*p; +}`;ze.a.ShadersStore.spriteMapVertexShader=Xg;var mi,Yg=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;s0&&(t+=` +\r`),t+=this._tileMaps[e]._texture._bufferView.toString();var n=document.createElement("a");n.href="data:octet/stream;charset=utf-8,"+encodeURI(t),n.target="_blank",n.download=this.name+".tilemaps",n.click(),n.remove()},r.prototype.loadTileMaps=function(t){var e=this,n=new XMLHttpRequest;n.open("GET",t);var i=this.options.layerCount||0;n.onload=function(){for(var o=n.response.split(` +\r`),a=0;a-1&&this._tasks.splice(e,1)},r.prototype._decreaseWaitingTasksCount=function(t){this._waitingTasksCount--;try{this.onProgress&&this.onProgress(this._waitingTasksCount,this._totalTasksCount,t),this.onProgressObservable.notifyObservers(new nf(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-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=0&&this._meshes.splice(n,1),this._centerPosition=this._centerMesh.getAbsolutePosition().clone();for(var i=0;i0&&this._textureLoadingCallback(t)}this._currentScene.render()}},r.prototype.drag=function(t){t.stopPropagation(),t.preventDefault()},r.prototype.drop=function(t){t.stopPropagation(),t.preventDefault(),this.loadFiles(t)},r.prototype._traverseFolder=function(t,e,n,i){var o=this,a=t.createReader(),s=t.fullPath.replace(/^\//,"").replace(/(.+?)\/?$/,"$1/");a.readEntries(function(d){n.count+=d.length;for(var p=0,b=d;p0)){for(var n=new Array,i=[],o=t.dataTransfer?t.dataTransfer.items:null,a=0;a0&&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}(),ff=f(146),iv=f(145),vi=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}(),Pa=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;othis.maximumSize&&(a.scale(this.step),i=!1)}}return i},t}(vi),Yc=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}(vi),xa=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}(vi),Ca=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}(vi),Ra=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}(vi),pf=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}(vi),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 particles on/off"},t.prototype.apply=function(e,n){return e.particlesEnabled=n.isInImprovementMode,!0},t}(vi),Kc=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}(vi),Ma=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},enumerable:!1,configurable:!0}),t.prototype.getDescription=function(){return"Merging similar meshes together"},t.prototype.apply=function(e,n,i){for(var o=e.meshes.slice(0),a=o.length,s=0;s=this._targetFrameRate)return this._isRunning=!1,void this.onSuccessObservable.notifyObservers(this);for(var i=!0,o=!0,a=0;a0){o.animationGroups=[];for(var P=0;P0)for(o.reflectionProbes=[],e=0;e0&&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&&Xe.b.Download(t,this._fileName)},r._defaultOptions={mimeType:"video/webm",fps:25,recordChunckSize:3e3},r}(),Mo=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){Xe.b._ScreenshotCanvas||(Xe.b._ScreenshotCanvas=document.createElement("canvas")),Xe.b._ScreenshotCanvas.width=d,Xe.b._ScreenshotCanvas.height=s;var p=Xe.b._ScreenshotCanvas.getContext("2d"),b=t.getRenderWidth()/t.getRenderHeight(),P=d,O=P/b;O>s&&(P=(O=s)*b);var B=Math.max(0,d-P)/2,F=Math.max(0,s-O)/2,z=t.getRenderingCanvas();p&&z&&p.drawImage(z,B,F,P,O),Xe.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,b){o===void 0&&(o="image/png"),a===void 0&&(a=1),s===void 0&&(s=!1),p===void 0&&(p=!1),b===void 0&&(b=!1);var P=r._getScreenshotSize(t,e,n),O=P.height,B=P.width,F={width:B,height:O};if(O&&B){var z=t.getRenderingCanvas();if(z){var J={width:z.width,height:z.height};t.setSize(B,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,b);ue.renderList=null,ue.samples=a,ue.renderSprites=p,ue.onAfterRenderObservable.add(function(){Xe.b.DumpFramebuffer(B,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 Oo("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,b){r.CreateScreenshotUsingRenderTarget(t,e,n,function(P){P!==void 0?p(P):b(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}();Xe.b.CreateScreenshot=Mo.CreateScreenshot,Xe.b.CreateScreenshotAsync=Mo.CreateScreenshotAsync,Xe.b.CreateScreenshotUsingRenderTarget=Mo.CreateScreenshotUsingRenderTarget,Xe.b.CreateScreenshotUsingRenderTargetAsync=Mo.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"}(Xc||(Xc={}));var kr,cv=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 qn.a.Decode(this.readUint8Array(t))},r.prototype.skipBytes=function(t){this._dataByteOffset+=t,this.byteOffset+=t},r}(),uv=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}(),hv=function(){function r(){this._trackedScene=null}return r.prototype.track=function(t){this._trackedScene=t,this._savedJSON=Zc.Serialize(t)},r.prototype.getDelta=function(){if(!this._trackedScene)return null;var t=Zc.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;on.MAX_SEQUENCE_LENGTH)throw new Error("Sequences longer than "+n.MAX_SEQUENCE_LENGTH+" not supported.");this._alphabet=o,this._characters=i.map(function(s){return a._alphabet.getCharacterIdx(s)})}return n.prototype.serialize=function(){return JSON.stringify(this._characters)},n.Deserialize=function(i,o){var a=new n([],o);return a._characters=JSON.parse(i),a},n.prototype.distance=function(i){return n._distance(this,i)},n._distance=function(i,o){var a=i._alphabet;if(a!==o._alphabet)throw new Error("Cannot Levenshtein compare Sequences built from different alphabets.");var s=i._characters,d=o._characters,p=s.length,b=d.length,P=n._costMatrix;P[0][0]=0;for(var O=0;O.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;nr._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}(),mf=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;p1e-6&&O.scaleAndAddToRef(1/(O.lengthSquared()*s),P)}),P.scaleInPlace(a),d.chars[z].addInPlace(P),d.chars[z].normalize()};for(p=o.length;p4;o=Math.floor(o/2))i.push(t.resampleAtTargetResolution(o).tokenize(e.chars));return i},r.prototype.distance=function(t){for(var e=0,n=0;n0&&(this._averageDistance=Math.max(this._averageDistance/this._descriptors.length,r.MIN_AVERAGE_DISTANCE))},r.MIN_AVERAGE_DISTANCE=1,r}(),fv=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=mf.Deserialize(e.vector3Alphabet),n._levenshteinAlphabet=kr.Alphabet.Deserialize(e.levenshteinAlphabet);for(var i=0;i0&&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=si.FEATURE_POINTS,t.Version=1,t}(ci);Zn.AddWebXRFeature(Ua.Name,function(r){return function(){return new Ua(r)}},Ua.Version);var vf=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 b=p.transform.position,P=p.transform.orientation;a.position.set(b.x,b.y,b.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]})},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 ga("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(b){return b+(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(),Xe.b.Error("error loading hand mesh"),console.log(d),[3,4];case 4:return[2]}})})},r}(),Va=function(r){function t(e,n){var i=r.call(this,e)||this;return i.options=n,i.onHandAddedObservable=new C.c,i.onHandRemovedObservable=new C.c,i._hands={},i._attachHand=function(o){var a,s,d,p,b,P,O,B,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)||Fn.a.CreateSphere("jointParent",{diameter:1});se.isVisible=!!(!((s=i.options.jointMeshes)===null||s===void 0)&&s.keepOriginalVisible);for(var ce=0;ce1){for(N();w!==-1&&v._OperatorPriority[V()]>=v._OperatorPriority[de];)D.push(X());I(de),j++}else ne+=te;j++}for(N();w!==-1;)V()==="("?X():D.push(X());return D},v._OperatorPriority={")":0,"(":1,"||":2,"&&":3},v._Stack=["","","","","","","","","","","","","","","","","","","",""],v}(),m=function(v){function E(D,w){w===void 0&&(w=!1);var N=v.call(this)||this;return N.define=D,N.not=w,N}return Object(u.d)(E,v),E.prototype.isTrue=function(D){var w=D[this.define]!==void 0;return this.not&&(w=!w),w},E}(x),c=function(v){function E(){return v!==null&&v.apply(this,arguments)||this}return Object(u.d)(E,v),E.prototype.isTrue=function(D){return this.leftOperand.isTrue(D)||this.rightOperand.isTrue(D)},E}(x),T=function(v){function E(){return v!==null&&v.apply(this,arguments)||this}return Object(u.d)(E,v),E.prototype.isTrue=function(D){return this.leftOperand.isTrue(D)&&this.rightOperand.isTrue(D)},E}(x),A=function(v){function E(D,w,N){var I=v.call(this)||this;return I.define=D,I.operand=w,I.testValue=N,I}return Object(u.d)(E,v),E.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=":N=I>=V;break;case"==":N=I===V}return N},E}(x),S=f(21),g=/defined\s*?\((.+?)\)/g,l=/defined\s*?\[(.+?)\]/g,h=function(){function v(){}return v.Process=function(E,D,w,N){var I=this;this._ProcessIncludes(E,D,function(V){var X=I._ProcessShaderConversion(V,D,N);w(X)})},v._ProcessPrecision=function(E,D){var w=D.shouldUseHighPrecisionShader;return E.indexOf("precision highp float")===-1?E=w?`precision highp float; +`+E:`precision mediump float; +`+E:w||(E=E.replace("precision highp float","precision mediump float")),E},v._ExtractOperation=function(E){var D=/defined\((.+)\)/.exec(E);if(D&&D.length)return new m(D[1].trim(),E[0]==="!");for(var w="",N=0,I=0,V=["==",">=","<=","<",">"];I-1));I++);if(N===-1)return new m(E);var X=E.substring(0,N).trim(),j=E.substring(N+w.length).trim();return new A(X,w,j)},v._BuildSubExpression=function(E){E=E.replace(g,"defined[$1]");for(var D=[],w=0,N=x.infixToPostfix(E);w=2){var V=D[D.length-1],X=D[D.length-2];D.length-=2;var j=I=="&&"?new T:new c;typeof V=="string"&&(V=V.replace(l,"defined($1)")),typeof X=="string"&&(X=X.replace(l,"defined($1)")),j.leftOperand=typeof X=="string"?this._ExtractOperation(X):X,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},v._BuildExpression=function(E,D){var w=new R,N=E.substring(0,D),I=E.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},v._MoveCursorWithinIf=function(E,D,w){for(var N=E.currentLine;this._MoveCursor(E,w);){var I=(N=E.currentLine).substring(0,5).toLowerCase();if(I==="#else"){var V=new _;return D.children.push(V),void this._MoveCursor(E,V)}if(I==="#elif"){var X=this._BuildExpression(N,5);D.children.push(X),w=X}}},v._MoveCursor=function(E,D){for(;E.canRead;){E.lineIndex++;var w=E.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(E,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(E,I,V);break;case"#if":I=new M,V=this._BuildExpression(w,3),D.children.push(I),I.children.push(V),this._MoveCursorWithinIf(E,I,V)}else{var X=new _;if(X.line=w,D.children.push(X),w[0]==="#"&&w[1]==="d"){var j=w.replace(";","").split(" ");X.additionalDefineKey=j[1],j.length===3&&(X.additionalDefineValue=j[2])}}}return!1},v._EvaluatePreProcessors=function(E,D,w){var N=new _,I=new C;return I.lineIndex=-1,I.lines=E.split(` +`),this._MoveCursor(I,N),N.process(D,w)},v._PreparePreProcessors=function(E){for(var D={},w=0,N=E.defines;w1?I[1]:""}return D.GL_ES="true",D.__VERSION__=E.version,D[E.platformName]="true",D},v._ProcessShaderConversion=function(E,D,w){var N=this._ProcessPrecision(E,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},v._ProcessIncludes=function(E,D,w){for(var N=this,I=/#include<(.+)>(\((.*)\))*(\[(.*)\])*/g,V=I.exec(E),X=new String(E),j=!1;V!=null;){var ne=V[1];if(ne.indexOf("__decl__")!==-1&&(ne=ne.replace(/__decl__/,""),D.supportsUniformBuffers&&(ne=(ne=ne.replace(/Vertex/,"Ubo")).replace(/Fragment/,"Ubo")),ne+="Declaration"),!D.includesShadersStore[ne]){var te=D.shadersRepository+"ShadersInclude/"+ne+".fx";return void v._FileToolsLoadFile(te,function(Y){D.includesShadersStore[ne]=Y,N._ProcessIncludes(X,D,w)})}var de=D.includesShadersStore[ne];if(V[2])for(var pe=V[3].split(","),ae=0;ae=0,V=I.exec(E)}j?this._ProcessIncludes(X.toString(),D,w):w(X)},v._FileToolsLoadFile=function(E,D,w,N,I,V){throw S.a.WarnImport("FileTools")},v}()},function(Me,y,f){f(26).a.prototype._readTexturePixels=function(U,_,C,u,M,R){u===void 0&&(u=-1),M===void 0&&(M=0),R===void 0&&(R=null);var x=this._gl;if(!x)throw new Error("Engine does not have gl rendering context.");if(!this._dummyFramebuffer){var m=x.createFramebuffer();if(!m)throw new Error("Unable to create dummy framebuffer");this._dummyFramebuffer=m}x.bindFramebuffer(x.FRAMEBUFFER,this._dummyFramebuffer),u>-1?x.framebufferTexture2D(x.FRAMEBUFFER,x.COLOR_ATTACHMENT0,x.TEXTURE_CUBE_MAP_POSITIVE_X+u,U._webGLTexture,M):x.framebufferTexture2D(x.FRAMEBUFFER,x.COLOR_ATTACHMENT0,x.TEXTURE_2D,U._webGLTexture,M);var c=U.type!==void 0?this._getWebGLTextureType(U.type):x.UNSIGNED_BYTE;switch(c){case x.UNSIGNED_BYTE:R||(R=new Uint8Array(4*_*C)),c=x.UNSIGNED_BYTE;break;default:R||(R=new Float32Array(4*_*C)),c=x.FLOAT}return x.readPixels(0,0,_,C,x.RGBA,c,R),x.bindFramebuffer(x.FRAMEBUFFER,this._currentFramebuffer),R}},function(Me,y,f){var U="shadowsFragmentFunctions",_=`#ifdef SHADOWS +#ifndef SHADOWFLOAT + +float unpack(vec4 color) +{ +const vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0); +return dot(color,bit_shift); +} +#endif +float computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff) +{ +float mask=smoothstep(1.0-frustumEdgeFalloff,1.00000012,clamp(dot(clipSpace,clipSpace),0.,1.)); +return mix(value,1.0,mask); +} +#define inline +float computeShadowCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues) +{ +vec3 directionToLight=vPositionW-lightPosition; +float depth=length(directionToLight); +depth=(depth+depthValues.x)/(depthValues.y); +depth=clamp(depth,0.,1.0); +directionToLight=normalize(directionToLight); +directionToLight.y=-directionToLight.y; +#ifndef SHADOWFLOAT +float shadow=unpack(textureCube(shadowSampler,directionToLight)); +#else +float shadow=textureCube(shadowSampler,directionToLight).x; +#endif +return depth>shadow ? darkness : 1.0; +} +#define inline +float computeShadowWithPoissonSamplingCube(vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues) +{ +vec3 directionToLight=vPositionW-lightPosition; +float depth=length(directionToLight); +depth=(depth+depthValues.x)/(depthValues.y); +depth=clamp(depth,0.,1.0); +directionToLight=normalize(directionToLight); +directionToLight.y=-directionToLight.y; +float visibility=1.; +vec3 poissonDisk[4]; +poissonDisk[0]=vec3(-1.0,1.0,-1.0); +poissonDisk[1]=vec3(1.0,-1.0,-1.0); +poissonDisk[2]=vec3(-1.0,-1.0,-1.0); +poissonDisk[3]=vec3(1.0,-1.0,1.0); + +#ifndef SHADOWFLOAT +if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.; +} +#endif +#define inline +float computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff) +{ +vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w; +vec2 uv=0.5*clipSpace.xy+vec2(0.5); +if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0) +{ +return 1.0; +} +else +{ +float shadowPixelDepth=clamp(depthMetric,0.,1.0); +#ifndef SHADOWFLOAT +float shadow=unpack(texture2D(shadowSampler,uv)); +#else +float shadow=texture2D(shadowSampler,uv).x; +#endif +return shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.; +} +} +#define inline +float computeShadowWithPoissonSampling(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff) +{ +vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w; +vec2 uv=0.5*clipSpace.xy+vec2(0.5); +if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0) +{ +return 1.0; +} +else +{ +float shadowPixelDepth=clamp(depthMetric,0.,1.0); +float visibility=1.; +vec2 poissonDisk[4]; +poissonDisk[0]=vec2(-0.94201624,-0.39906216); +poissonDisk[1]=vec2(0.94558609,-0.76890725); +poissonDisk[2]=vec2(-0.094184101,-0.92938870); +poissonDisk[3]=vec2(0.34495938,0.29387760); + +#ifndef SHADOWFLOAT +if (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))1.0 || uv.y<0. || uv.y>1.0) +{ +return 1.0; +} +else +{ +float shadowPixelDepth=clamp(depthMetric,0.,1.0); +#ifndef SHADOWFLOAT +float shadowMapSample=unpack(texture2D(shadowSampler,uv)); +#else +float shadowMapSample=texture2D(shadowSampler,uv).x; +#endif +float esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness); +return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff); +} +} +#define inline +float computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff) +{ +vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w; +vec2 uv=0.5*clipSpace.xy+vec2(0.5); +if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0) +{ +return 1.0; +} +else +{ +float shadowPixelDepth=clamp(depthMetric,0.,1.0); +#ifndef SHADOWFLOAT +float shadowMapSample=unpack(texture2D(shadowSampler,uv)); +#else +float shadowMapSample=texture2D(shadowSampler,uv).x; +#endif +float esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.); +return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff); +} +} +#ifdef WEBGL2 +#define GREATEST_LESS_THAN_ONE 0.99999994 + +#define inline +float computeShadowWithCSMPCF1(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,float darkness,float frustumEdgeFalloff) +{ +vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w; +vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5)); +uvDepth.z=clamp(uvDepth.z,0.,GREATEST_LESS_THAN_ONE); +vec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z); +float shadow=texture(shadowSampler,uvDepthLayer); +shadow=mix(darkness,1.,shadow); +return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff); +} + + + +#define inline +float computeShadowWithCSMPCF3(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff) +{ +vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w; +vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5)); +uvDepth.z=clamp(uvDepth.z,0.,GREATEST_LESS_THAN_ONE); +vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; +uv+=0.5; +vec2 st=fract(uv); +vec2 base_uv=floor(uv)-0.5; +base_uv*=shadowMapSizeAndInverse.y; + + + + +vec2 uvw0=3.-2.*st; +vec2 uvw1=1.+2.*st; +vec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y; +vec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y; +float shadow=0.; +shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z)); +shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z)); +shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z)); +shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z)); +shadow=shadow/16.; +shadow=mix(darkness,1.,shadow); +return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff); +} + + + +#define inline +float computeShadowWithCSMPCF5(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff) +{ +vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w; +vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5)); +uvDepth.z=clamp(uvDepth.z,0.,GREATEST_LESS_THAN_ONE); +vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; +uv+=0.5; +vec2 st=fract(uv); +vec2 base_uv=floor(uv)-0.5; +base_uv*=shadowMapSizeAndInverse.y; + + +vec2 uvw0=4.-3.*st; +vec2 uvw1=vec2(7.); +vec2 uvw2=1.+3.*st; +vec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y; +vec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y; +float shadow=0.; +shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z)); +shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z)); +shadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[0]),layer,uvDepth.z)); +shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z)); +shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z)); +shadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[1]),layer,uvDepth.z)); +shadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[2]),layer,uvDepth.z)); +shadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[2]),layer,uvDepth.z)); +shadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[2]),layer,uvDepth.z)); +shadow=shadow/144.; +shadow=mix(darkness,1.,shadow); +return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff); +} + +#define inline +float computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff) +{ +if (depthMetric>1.0 || depthMetric<0.0) { +return 1.0; +} +else +{ +vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w; +vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5)); +float shadow=texture2D(shadowSampler,uvDepth); +shadow=mix(darkness,1.,shadow); +return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff); +} +} + + + +#define inline +float computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff) +{ +if (depthMetric>1.0 || depthMetric<0.0) { +return 1.0; +} +else +{ +vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w; +vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5)); +vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; +uv+=0.5; +vec2 st=fract(uv); +vec2 base_uv=floor(uv)-0.5; +base_uv*=shadowMapSizeAndInverse.y; + + + + +vec2 uvw0=3.-2.*st; +vec2 uvw1=1.+2.*st; +vec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y; +vec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y; +float shadow=0.; +shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z)); +shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z)); +shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z)); +shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z)); +shadow=shadow/16.; +shadow=mix(darkness,1.,shadow); +return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff); +} +} + + + +#define inline +float computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff) +{ +if (depthMetric>1.0 || depthMetric<0.0) { +return 1.0; +} +else +{ +vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w; +vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5)); +vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; +uv+=0.5; +vec2 st=fract(uv); +vec2 base_uv=floor(uv)-0.5; +base_uv*=shadowMapSizeAndInverse.y; + + +vec2 uvw0=4.-3.*st; +vec2 uvw1=vec2(7.); +vec2 uvw2=1.+3.*st; +vec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y; +vec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y; +float shadow=0.; +shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z)); +shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z)); +shadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[0]),uvDepth.z)); +shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z)); +shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z)); +shadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[1]),uvDepth.z)); +shadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[2]),uvDepth.z)); +shadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[2]),uvDepth.z)); +shadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[2]),uvDepth.z)); +shadow=shadow/144.; +shadow=mix(darkness,1.,shadow); +return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff); +} +} +const vec3 PoissonSamplers32[64]=vec3[64]( +vec3(0.06407013,0.05409927,0.), +vec3(0.7366577,0.5789394,0.), +vec3(-0.6270542,-0.5320278,0.), +vec3(-0.4096107,0.8411095,0.), +vec3(0.6849564,-0.4990818,0.), +vec3(-0.874181,-0.04579735,0.), +vec3(0.9989998,0.0009880066,0.), +vec3(-0.004920578,-0.9151649,0.), +vec3(0.1805763,0.9747483,0.), +vec3(-0.2138451,0.2635818,0.), +vec3(0.109845,0.3884785,0.), +vec3(0.06876755,-0.3581074,0.), +vec3(0.374073,-0.7661266,0.), +vec3(0.3079132,-0.1216763,0.), +vec3(-0.3794335,-0.8271583,0.), +vec3(-0.203878,-0.07715034,0.), +vec3(0.5912697,0.1469799,0.), +vec3(-0.88069,0.3031784,0.), +vec3(0.5040108,0.8283722,0.), +vec3(-0.5844124,0.5494877,0.), +vec3(0.6017799,-0.1726654,0.), +vec3(-0.5554981,0.1559997,0.), +vec3(-0.3016369,-0.3900928,0.), +vec3(-0.5550632,-0.1723762,0.), +vec3(0.925029,0.2995041,0.), +vec3(-0.2473137,0.5538505,0.), +vec3(0.9183037,-0.2862392,0.), +vec3(0.2469421,0.6718712,0.), +vec3(0.3916397,-0.4328209,0.), +vec3(-0.03576927,-0.6220032,0.), +vec3(-0.04661255,0.7995201,0.), +vec3(0.4402924,0.3640312,0.), +vec3(0.,0.,0.), +vec3(0.,0.,0.), +vec3(0.,0.,0.), +vec3(0.,0.,0.), +vec3(0.,0.,0.), +vec3(0.,0.,0.), +vec3(0.,0.,0.), +vec3(0.,0.,0.), +vec3(0.,0.,0.), +vec3(0.,0.,0.), +vec3(0.,0.,0.), +vec3(0.,0.,0.), +vec3(0.,0.,0.), +vec3(0.,0.,0.), +vec3(0.,0.,0.), +vec3(0.,0.,0.), +vec3(0.,0.,0.), +vec3(0.,0.,0.), +vec3(0.,0.,0.), +vec3(0.,0.,0.), +vec3(0.,0.,0.), +vec3(0.,0.,0.), +vec3(0.,0.,0.), +vec3(0.,0.,0.), +vec3(0.,0.,0.), +vec3(0.,0.,0.), +vec3(0.,0.,0.), +vec3(0.,0.,0.), +vec3(0.,0.,0.), +vec3(0.,0.,0.), +vec3(0.,0.,0.), +vec3(0.,0.,0.) +); +const vec3 PoissonSamplers64[64]=vec3[64]( +vec3(-0.613392,0.617481,0.), +vec3(0.170019,-0.040254,0.), +vec3(-0.299417,0.791925,0.), +vec3(0.645680,0.493210,0.), +vec3(-0.651784,0.717887,0.), +vec3(0.421003,0.027070,0.), +vec3(-0.817194,-0.271096,0.), +vec3(-0.705374,-0.668203,0.), +vec3(0.977050,-0.108615,0.), +vec3(0.063326,0.142369,0.), +vec3(0.203528,0.214331,0.), +vec3(-0.667531,0.326090,0.), +vec3(-0.098422,-0.295755,0.), +vec3(-0.885922,0.215369,0.), +vec3(0.566637,0.605213,0.), +vec3(0.039766,-0.396100,0.), +vec3(0.751946,0.453352,0.), +vec3(0.078707,-0.715323,0.), +vec3(-0.075838,-0.529344,0.), +vec3(0.724479,-0.580798,0.), +vec3(0.222999,-0.215125,0.), +vec3(-0.467574,-0.405438,0.), +vec3(-0.248268,-0.814753,0.), +vec3(0.354411,-0.887570,0.), +vec3(0.175817,0.382366,0.), +vec3(0.487472,-0.063082,0.), +vec3(-0.084078,0.898312,0.), +vec3(0.488876,-0.783441,0.), +vec3(0.470016,0.217933,0.), +vec3(-0.696890,-0.549791,0.), +vec3(-0.149693,0.605762,0.), +vec3(0.034211,0.979980,0.), +vec3(0.503098,-0.308878,0.), +vec3(-0.016205,-0.872921,0.), +vec3(0.385784,-0.393902,0.), +vec3(-0.146886,-0.859249,0.), +vec3(0.643361,0.164098,0.), +vec3(0.634388,-0.049471,0.), +vec3(-0.688894,0.007843,0.), +vec3(0.464034,-0.188818,0.), +vec3(-0.440840,0.137486,0.), +vec3(0.364483,0.511704,0.), +vec3(0.034028,0.325968,0.), +vec3(0.099094,-0.308023,0.), +vec3(0.693960,-0.366253,0.), +vec3(0.678884,-0.204688,0.), +vec3(0.001801,0.780328,0.), +vec3(0.145177,-0.898984,0.), +vec3(0.062655,-0.611866,0.), +vec3(0.315226,-0.604297,0.), +vec3(-0.780145,0.486251,0.), +vec3(-0.371868,0.882138,0.), +vec3(0.200476,0.494430,0.), +vec3(-0.494552,-0.711051,0.), +vec3(0.612476,0.705252,0.), +vec3(-0.578845,-0.768792,0.), +vec3(-0.772454,-0.090976,0.), +vec3(0.504440,0.372295,0.), +vec3(0.155736,0.065157,0.), +vec3(0.391522,0.849605,0.), +vec3(-0.620106,-0.328104,0.), +vec3(0.789239,-0.419965,0.), +vec3(-0.545396,0.538133,0.), +vec3(-0.178564,-0.596057,0.) +); + + + + + +#define inline +float computeShadowWithCSMPCSS(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness) +{ +vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w; +vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5)); +uvDepth.z=clamp(uvDepth.z,0.,GREATEST_LESS_THAN_ONE); +vec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z); +float blockerDepth=0.0; +float sumBlockerDepth=0.0; +float numBlocker=0.0; +for (int i=0; i1.0 || depthMetric<0.0) { +return 1.0; +} +else +{ +vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w; +vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5)); +float blockerDepth=0.0; +float sumBlockerDepth=0.0; +float numBlocker=0.0; +for (int i=0; icurrRayHeight) +{ +float delta1=currSampledHeight-currRayHeight; +float delta2=(currRayHeight+stepSize)-lastSampledHeight; +float ratio=delta1/(delta1+delta2); +vCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset; + +break; +} +else +{ +currRayHeight-=stepSize; +vLastOffset=vCurrOffset; +vCurrOffset+=stepSize*vMaxOffset; +lastSampledHeight=currSampledHeight; +} +} +return vCurrOffset; +} +vec2 parallaxOffset(vec3 viewDir,float heightScale) +{ + +float height=texture2D(bumpSampler,vBumpUV).w; +vec2 texCoordOffset=heightScale*viewDir.xy*height; +return -texCoordOffset; +} +#endif`;f(5).a.IncludesShadersStore[U]=_},function(Me,y,f){var U=`vec2 uvOffset=vec2(0.0,0.0); +#if defined(BUMP) || defined(PARALLAX) || defined(DETAIL) +#ifdef NORMALXYSCALE +float normalScale=1.0; +#elif defined(BUMP) +float normalScale=vBumpInfos.y; +#else +float normalScale=1.0; +#endif +#if defined(TANGENT) && defined(NORMAL) +mat3 TBN=vTBN; +#elif defined(BUMP) +mat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,vBumpUV); +#else +mat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,vDetailUV,vec2(1.,1.)); +#endif +#elif defined(ANISOTROPIC) +#if defined(TANGENT) && defined(NORMAL) +mat3 TBN=vTBN; +#else +mat3 TBN=cotangent_frame(normalW,vPositionW,vMainUV1,vec2(1.,1.)); +#endif +#endif +#ifdef PARALLAX +mat3 invTBN=transposeMat3(TBN); +#ifdef PARALLAXOCCLUSION +uvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,vBumpUV,vBumpInfos.z); +#else +uvOffset=parallaxOffset(invTBN*viewDirectionW,vBumpInfos.z); +#endif +#endif +#ifdef DETAIL +vec4 detailColor=texture2D(detailSampler,vDetailUV+uvOffset); +vec2 detailNormalRG=detailColor.wy*2.0-1.0; +float detailNormalB=sqrt(1.-saturate(dot(detailNormalRG,detailNormalRG))); +vec3 detailNormal=vec3(detailNormalRG,detailNormalB); +#endif +#ifdef BUMP +#ifdef OBJECTSPACE_NORMALMAP +normalW=normalize(texture2D(bumpSampler,vBumpUV).xyz*2.0-1.0); +normalW=normalize(mat3(normalMatrix)*normalW); +#elif !defined(DETAIL) +normalW=perturbNormal(TBN,vBumpUV+uvOffset); +#else +vec3 bumpNormal=texture2D(bumpSampler,vBumpUV+uvOffset).xyz*2.0-1.0; + +#if DETAIL_NORMALBLENDMETHOD == 0 +detailNormal.xy*=vDetailInfos.z; +vec3 blendedNormal=normalize(vec3(bumpNormal.xy+detailNormal.xy,bumpNormal.z*detailNormal.z)); +#elif DETAIL_NORMALBLENDMETHOD == 1 +detailNormal.xy*=vDetailInfos.z; +bumpNormal+=vec3(0.0,0.0,1.0); +detailNormal*=vec3(-1.0,-1.0,1.0); +vec3 blendedNormal=bumpNormal*dot(bumpNormal,detailNormal)/bumpNormal.z-detailNormal; +#endif +normalW=perturbNormalBase(TBN,blendedNormal,vBumpInfos.y); +#endif +#elif defined(DETAIL) +detailNormal.xy*=vDetailInfos.z; +normalW=perturbNormalBase(TBN,detailNormal,vDetailInfos.z); +#endif`;f(5).a.IncludesShadersStore.bumpFragment=U},function(Me,y,f){var U="lightFragment",_=`#ifdef LIGHT{X} +#if defined(SHADOWONLY) || defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X}) + +#else +#ifdef PBR + +#ifdef SPOTLIGHT{X} +preInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW); +#elif defined(POINTLIGHT{X}) +preInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW); +#elif defined(HEMILIGHT{X}) +preInfo=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW); +#elif defined(DIRLIGHT{X}) +preInfo=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW); +#endif +preInfo.NdotV=NdotV; + +#ifdef SPOTLIGHT{X} +#ifdef LIGHT_FALLOFF_GLTF{X} +preInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y); +preInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w); +#elif defined(LIGHT_FALLOFF_PHYSICAL{X}) +preInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared); +preInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w); +#elif defined(LIGHT_FALLOFF_STANDARD{X}) +preInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x); +preInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w); +#else +preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y); +preInfo.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w); +#endif +#elif defined(POINTLIGHT{X}) +#ifdef LIGHT_FALLOFF_GLTF{X} +preInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y); +#elif defined(LIGHT_FALLOFF_PHYSICAL{X}) +preInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared); +#elif defined(LIGHT_FALLOFF_STANDARD{X}) +preInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x); +#else +preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y); +#endif +#else +preInfo.attenuation=1.0; +#endif + + +#ifdef HEMILIGHT{X} +preInfo.roughness=roughness; +#else +preInfo.roughness=adjustRoughnessFromLightProperties(roughness,light{X}.vLightSpecular.a,preInfo.lightDistance); +#endif + +#ifdef HEMILIGHT{X} +info.diffuse=computeHemisphericDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb,light{X}.vLightGround); +#elif defined(SS_TRANSLUCENCY) +info.diffuse=computeDiffuseAndTransmittedLighting(preInfo,light{X}.vLightDiffuse.rgb,subSurfaceOut.transmittance); +#else +info.diffuse=computeDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb); +#endif + +#ifdef SPECULARTERM +#ifdef ANISOTROPIC +info.specular=computeAnisotropicSpecularLighting(preInfo,viewDirectionW,normalW,anisotropicOut.anisotropicTangent,anisotropicOut.anisotropicBitangent,anisotropicOut.anisotropy,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb); +#else +info.specular=computeSpecularLighting(preInfo,normalW,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb); +#endif +#endif + +#ifdef SHEEN +#ifdef SHEEN_LINKWITHALBEDO + +preInfo.roughness=sheenOut.sheenIntensity; +#else +#ifdef HEMILIGHT{X} +preInfo.roughness=sheenOut.sheenRoughness; +#else +preInfo.roughness=adjustRoughnessFromLightProperties(sheenOut.sheenRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance); +#endif +#endif +info.sheen=computeSheenLighting(preInfo,normalW,sheenOut.sheenColor,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb); +#endif + +#ifdef CLEARCOAT + +#ifdef HEMILIGHT{X} +preInfo.roughness=clearcoatOut.clearCoatRoughness; +#else +preInfo.roughness=adjustRoughnessFromLightProperties(clearcoatOut.clearCoatRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance); +#endif +info.clearCoat=computeClearCoatLighting(preInfo,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatAARoughnessFactors.x,clearcoatOut.clearCoatIntensity,light{X}.vLightDiffuse.rgb); +#ifdef CLEARCOAT_TINT + +absorption=computeClearCoatLightingAbsorption(clearcoatOut.clearCoatNdotVRefract,preInfo.L,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatColor,clearcoatOut.clearCoatThickness,clearcoatOut.clearCoatIntensity); +info.diffuse*=absorption; +#ifdef SPECULARTERM +info.specular*=absorption; +#endif +#endif + +info.diffuse*=info.clearCoat.w; +#ifdef SPECULARTERM +info.specular*=info.clearCoat.w; +#endif +#ifdef SHEEN +info.sheen*=info.clearCoat.w; +#endif +#endif +#else +#ifdef SPOTLIGHT{X} +info=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightDiffuse.a,glossiness); +#elif defined(HEMILIGHT{X}) +info=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightGround,glossiness); +#elif defined(POINTLIGHT{X}) || defined(DIRLIGHT{X}) +info=computeLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightDiffuse.a,glossiness); +#endif +#endif +#ifdef PROJECTEDLIGHTTEXTURE{X} +info.diffuse*=computeProjectionTextureDiffuseLighting(projectionLightSampler{X},textureProjectionMatrix{X}); +#endif +#endif +#ifdef SHADOW{X} +#ifdef SHADOWCSM{X} +for (int i=0; i=0.) { +index{X}=i; +break; +} +} +#ifdef SHADOWCSMUSESHADOWMAXZ{X} +if (index{X}>=0) +#endif +{ +#if defined(SHADOWPCF{X}) +#if defined(SHADOWLOWQUALITY{X}) +shadow=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#elif defined(SHADOWMEDIUMQUALITY{X}) +shadow=computeShadowWithCSMPCF3(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#else +shadow=computeShadowWithCSMPCF5(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#endif +#elif defined(SHADOWPCSS{X}) +#if defined(SHADOWLOWQUALITY{X}) +shadow=computeShadowWithCSMPCSS16(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],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}); +#elif defined(SHADOWMEDIUMQUALITY{X}) +shadow=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}); +#else +shadow=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}); +#endif +#else +shadow=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#endif +#ifdef SHADOWCSMDEBUG{X} +shadowDebug{X}=vec3(shadow)*vCascadeColorsMultiplier{X}[index{X}]; +#endif +#ifndef SHADOWCSMNOBLEND{X} +float frustumLength=frustumLengths{X}[index{X}]; +float diffRatio=clamp(diff{X}/frustumLength,0.,1.)*cascadeBlendFactor{X}; +if (index{X}<(SHADOWCSMNUM_CASCADES{X}-1) && diffRatio<1.) +{ +index{X}+=1; +float nextShadow=0.; +#if defined(SHADOWPCF{X}) +#if defined(SHADOWLOWQUALITY{X}) +nextShadow=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#elif defined(SHADOWMEDIUMQUALITY{X}) +nextShadow=computeShadowWithCSMPCF3(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#else +nextShadow=computeShadowWithCSMPCF5(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#endif +#elif defined(SHADOWPCSS{X}) +#if defined(SHADOWLOWQUALITY{X}) +nextShadow=computeShadowWithCSMPCSS16(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],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}); +#elif defined(SHADOWMEDIUMQUALITY{X}) +nextShadow=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}); +#else +nextShadow=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}); +#endif +#else +nextShadow=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#endif +shadow=mix(nextShadow,shadow,diffRatio); +#ifdef SHADOWCSMDEBUG{X} +shadowDebug{X}=mix(vec3(nextShadow)*vCascadeColorsMultiplier{X}[index{X}],shadowDebug{X},diffRatio); +#endif +} +#endif +} +#elif defined(SHADOWCLOSEESM{X}) +#if defined(SHADOWCUBE{X}) +shadow=computeShadowWithCloseESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues); +#else +shadow=computeShadowWithCloseESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w); +#endif +#elif defined(SHADOWESM{X}) +#if defined(SHADOWCUBE{X}) +shadow=computeShadowWithESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues); +#else +shadow=computeShadowWithESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w); +#endif +#elif defined(SHADOWPOISSON{X}) +#if defined(SHADOWCUBE{X}) +shadow=computeShadowWithPoissonSamplingCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues); +#else +shadow=computeShadowWithPoissonSampling(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#endif +#elif defined(SHADOWPCF{X}) +#if defined(SHADOWLOWQUALITY{X}) +shadow=computeShadowWithPCF1(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#elif defined(SHADOWMEDIUMQUALITY{X}) +shadow=computeShadowWithPCF3(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#else +shadow=computeShadowWithPCF5(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#endif +#elif defined(SHADOWPCSS{X}) +#if defined(SHADOWLOWQUALITY{X}) +shadow=computeShadowWithPCSS16(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#elif defined(SHADOWMEDIUMQUALITY{X}) +shadow=computeShadowWithPCSS32(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#else +shadow=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); +#endif +#else +#if defined(SHADOWCUBE{X}) +shadow=computeShadowCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.depthValues); +#else +shadow=computeShadow(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#endif +#endif +#ifdef SHADOWONLY +#ifndef SHADOWINUSE +#define SHADOWINUSE +#endif +globalShadow+=shadow; +shadowLightCount+=1.0; +#endif +#else +shadow=1.; +#endif +#ifndef SHADOWONLY +#ifdef CUSTOMUSERLIGHTING +diffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow); +#ifdef SPECULARTERM +specularBase+=computeCustomSpecularLighting(info,specularBase,shadow); +#endif +#elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) +diffuseBase+=lightmapColor.rgb*shadow; +#ifdef SPECULARTERM +#ifndef LIGHTMAPNOSPECULAR{X} +specularBase+=info.specular*shadow*lightmapColor.rgb; +#endif +#endif +#ifdef CLEARCOAT +#ifndef LIGHTMAPNOSPECULAR{X} +clearCoatBase+=info.clearCoat.rgb*shadow*lightmapColor.rgb; +#endif +#endif +#ifdef SHEEN +#ifndef LIGHTMAPNOSPECULAR{X} +sheenBase+=info.sheen.rgb*shadow; +#endif +#endif +#else +#ifdef SHADOWCSMDEBUG{X} +diffuseBase+=info.diffuse*shadowDebug{X}; +#else +diffuseBase+=info.diffuse*shadow; +#endif +#ifdef SPECULARTERM +specularBase+=info.specular*shadow; +#endif +#ifdef CLEARCOAT +clearCoatBase+=info.clearCoat.rgb*shadow; +#endif +#ifdef SHEEN +sheenBase+=info.sheen.rgb*shadow; +#endif +#endif +#endif +#endif`;f(5).a.IncludesShadersStore[U]=_},function(Me,y,f){var U=`#ifdef FOG +float fog=CalcFogFactor(); +color.rgb=fog*color.rgb+(1.0-fog)*vFogColor; +#endif`;f(5).a.IncludesShadersStore.fogFragment=U},function(Me,y,f){var U="fogVertexDeclaration",_=`#ifdef FOG +varying vec3 vFogDistance; +#endif`;f(5).a.IncludesShadersStore[U]=_},function(Me,y,f){var U="shadowsVertex",_=`#ifdef SHADOWS +#if defined(SHADOWCSM{X}) +vPositionFromCamera{X}=view*worldPos; +for (int i=0; i1)for(var T=0;T=C||M.indexOf("file:")!==-1?-1:Math.pow(2,x)*u}},_}()},function(Me,y,f){f.d(y,"a",function(){return U});var U=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(C){this._zOffset!==C&&(this._zOffset=C,this._isZOffsetDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"cullFace",{get:function(){return this._cullFace},set:function(C){this._cullFace!==C&&(this._cullFace=C,this._isCullFaceDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"cull",{get:function(){return this._cull},set:function(C){this._cull!==C&&(this._cull=C,this._isCullDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"depthFunc",{get:function(){return this._depthFunc},set:function(C){this._depthFunc!==C&&(this._depthFunc=C,this._isDepthFuncDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"depthMask",{get:function(){return this._depthMask},set:function(C){this._depthMask!==C&&(this._depthMask=C,this._isDepthMaskDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"depthTest",{get:function(){return this._depthTest},set:function(C){this._depthTest!==C&&(this._depthTest=C,this._isDepthTestDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"frontFace",{get:function(){return this._frontFace},set:function(C){this._frontFace!==C&&(this._frontFace=C,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(C){this.isDirty&&(this._isCullDirty&&(this.cull?C.enable(C.CULL_FACE):C.disable(C.CULL_FACE),this._isCullDirty=!1),this._isCullFaceDirty&&(C.cullFace(this.cullFace),this._isCullFaceDirty=!1),this._isDepthMaskDirty&&(C.depthMask(this.depthMask),this._isDepthMaskDirty=!1),this._isDepthTestDirty&&(this.depthTest?C.enable(C.DEPTH_TEST):C.disable(C.DEPTH_TEST),this._isDepthTestDirty=!1),this._isDepthFuncDirty&&(C.depthFunc(this.depthFunc),this._isDepthFuncDirty=!1),this._isZOffsetDirty&&(this.zOffset?(C.enable(C.POLYGON_OFFSET_FILL),C.polygonOffset(this.zOffset,0)):C.disable(C.POLYGON_OFFSET_FILL),this._isZOffsetDirty=!1),this._isFrontFaceDirty&&(C.frontFace(this.frontFace),this._isFrontFaceDirty=!1))},_}()},function(Me,y,f){f.d(y,"a",function(){return _});var U=f(2),_=function(){function C(){this._isStencilTestDirty=!1,this._isStencilMaskDirty=!1,this._isStencilFuncDirty=!1,this._isStencilOpDirty=!1,this.reset()}return Object.defineProperty(C.prototype,"isDirty",{get:function(){return this._isStencilTestDirty||this._isStencilMaskDirty||this._isStencilFuncDirty||this._isStencilOpDirty},enumerable:!1,configurable:!0}),Object.defineProperty(C.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(C.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(C.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(C.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(C.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(C.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(C.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(C.prototype,"stencilTest",{get:function(){return this._stencilTest},set:function(u){this._stencilTest!==u&&(this._stencilTest=u,this._isStencilTestDirty=!0)},enumerable:!1,configurable:!0}),C.prototype.reset=function(){this._stencilTest=!1,this._stencilMask=255,this._stencilFunc=C.ALWAYS,this._stencilFuncRef=1,this._stencilFuncMask=255,this._stencilOpStencilFail=C.KEEP,this._stencilOpDepthFail=C.KEEP,this._stencilOpStencilDepthPass=C.REPLACE,this._isStencilTestDirty=!0,this._isStencilMaskDirty=!0,this._isStencilFuncDirty=!0,this._isStencilOpDirty=!0},C.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))},C.ALWAYS=U.a.ALWAYS,C.KEEP=U.a.KEEP,C.REPLACE=U.a.REPLACE,C}()},function(Me,y,f){f.d(y,"a",function(){return U});var U=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(C){this._alphaBlend!==C&&(this._alphaBlend=C,this._isAlphaBlendDirty=!0)},enumerable:!1,configurable:!0}),_.prototype.setAlphaBlendConstants=function(C,u,M,R){this._blendConstants[0]===C&&this._blendConstants[1]===u&&this._blendConstants[2]===M&&this._blendConstants[3]===R||(this._blendConstants[0]=C,this._blendConstants[1]=u,this._blendConstants[2]=M,this._blendConstants[3]=R,this._isBlendConstantsDirty=!0)},_.prototype.setAlphaBlendFunctionParameters=function(C,u,M,R){this._blendFunctionParameters[0]===C&&this._blendFunctionParameters[1]===u&&this._blendFunctionParameters[2]===M&&this._blendFunctionParameters[3]===R||(this._blendFunctionParameters[0]=C,this._blendFunctionParameters[1]=u,this._blendFunctionParameters[2]=M,this._blendFunctionParameters[3]=R,this._isBlendFunctionParametersDirty=!0)},_.prototype.setAlphaEquationParameters=function(C,u){this._blendEquationParameters[0]===C&&this._blendEquationParameters[1]===u||(this._blendEquationParameters[0]=C,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._isBlendConstantsDirty=!1},_.prototype.apply=function(C){this.isDirty&&(this._isAlphaBlendDirty&&(this._alphaBlend?C.enable(C.BLEND):C.disable(C.BLEND),this._isAlphaBlendDirty=!1),this._isBlendFunctionParametersDirty&&(C.blendFuncSeparate(this._blendFunctionParameters[0],this._blendFunctionParameters[1],this._blendFunctionParameters[2],this._blendFunctionParameters[3]),this._isBlendFunctionParametersDirty=!1),this._isBlendEquationParametersDirty&&(C.blendEquationSeparate(this._blendEquationParameters[0],this._blendEquationParameters[1]),this._isBlendEquationParametersDirty=!1),this._isBlendConstantsDirty&&(C.blendColor(this._blendConstants[0],this._blendConstants[1],this._blendConstants[2],this._blendConstants[3]),this._isBlendConstantsDirty=!1))},_}()},function(Me,y,f){f.d(y,"a",function(){return U});var U=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(C){C&&this.program&&C(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(Me,y,f){var U;f.d(y,"a",function(){return u}),function(M){M[M.Pending=0]="Pending",M[M.Fulfilled=1]="Fulfilled",M[M.Rejected=2]="Rejected"}(U||(U={}));var _=function(){this.count=0,this.target=0,this.results=[]},C=function(){function M(R){var x=this;if(this._state=U.Pending,this._children=new Array,this._rejectWasConsumed=!1,R)try{R(function(m){x._resolve(m)},function(m){x._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,x){var m=this,c=new M;return c._onFulfilled=R,c._onRejected=x,this._children.push(c),c._parent=this,this._state!==U.Pending&&setTimeout(function(){if(m._state===U.Fulfilled||m._rejectWasConsumed){var T=c._resolve(m._result);if(T!=null)if(T._state!==void 0){var A=T;c._children.push(A),A._parent=c,c=A}else c._result=T}else c._reject(m._reason)}),c},M.prototype._moveChildren=function(R){var x,m=this;if((x=this._children).push.apply(x,R.splice(0,R.length)),this._children.forEach(function(g){g._parent=m}),this._state===U.Fulfilled)for(var c=0,T=this._children;c"u")&&(window.Promise=C)},M}()},function(Me,y,f){f.d(y,"a",function(){return _}),f.d(y,"b",function(){return C});var U=f(57),_=function(){function u(M){M===void 0&&(M=30),this._enabled=!0,this._rollingFrameTime=new C(M)}return u.prototype.sampleFrame=function(M){if(M===void 0&&(M=U.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},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}(),C=function(){function u(M){this._samples=new Array(M),this.reset()}return u.prototype.add=function(M){var R;if(this.isSaturated()){var x=this._samples[this._pos];R=x-this.average,this.average-=R/(this._sampleCount-1),this._m2-=R*(x-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(Me,y,f){f.d(y,"a",function(){return _});var U=f(0),_=function(){this._checkCollisions=!1,this._collisionMask=-1,this._collisionGroup=-1,this._surroundingMeshes=null,this._collider=null,this._oldPositionForCollisions=new U.e(0,0,0),this._diffPositionForCollisions=new U.e(0,0,0),this._collisionResponse=!0}},function(Me,y,f){f.d(y,"a",function(){return u});var U=f(33),_=f(0),C=f(2),u=function(){function M(R,x,m,c,T){m===void 0&&(m=null),c===void 0&&(c=null),T===void 0&&(T=null),this.index=R,this._opaqueSubMeshes=new U.a(256),this._transparentSubMeshes=new U.a(256),this._alphaTestSubMeshes=new U.a(256),this._depthOnlySubMeshes=new U.a(256),this._particleSystems=new U.a(256),this._spriteManagers=new U.a(256),this._edgesRenderers=new U.b(16),this._scene=x,this.opaqueSortCompareFn=m,this.alphaTestSortCompareFn=c,this.transparentSortCompareFn=T}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,x,m,c){if(R)R(this._opaqueSubMeshes,this._alphaTestSubMeshes,this._transparentSubMeshes,this._depthOnlySubMeshes);else{var T=this._scene.getEngine();this._depthOnlySubMeshes.length!==0&&(T.setColorWrite(!1),this._renderAlphaTest(this._depthOnlySubMeshes),T.setColorWrite(!0)),this._opaqueSubMeshes.length!==0&&this._renderOpaque(this._opaqueSubMeshes),this._alphaTestSubMeshes.length!==0&&this._renderAlphaTest(this._alphaTestSubMeshes);var A=T.getStencilBuffer();if(T.setStencilBuffer(!1),x&&this._renderSprites(),m&&this._renderParticles(c),this.onBeforeTransparentRendering&&this.onBeforeTransparentRendering(),this._transparentSubMeshes.length!==0&&(T.setStencilBuffer(A),this._renderTransparent(this._transparentSubMeshes),T.setAlphaMode(C.a.ALPHA_DISABLE)),T.setStencilBuffer(!1),this._edgesRenderers.length){for(var S=0;Sx._alphaIndex?1:R._alphaIndexx._distanceToCamera?-1:0},M.frontToBackSortCompare=function(R,x){return R._distanceToCamerax._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,x,m){x===void 0&&(x=R.getMesh()),m===void 0&&(m=R.getMaterial()),m!=null&&(m.needAlphaBlendingForMesh(x)?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)),x._renderingGroup=this,x._edgesRenderer&&x._edgesRenderer.isEnabled&&this._edgesRenderers.pushNoDuplicate(x._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 x=this._scene.activeCamera;this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);for(var m=0;m=0;){var g=x[A];g<0?g=0:g>1&&(g=1),S[A]=255*g}x=S}var l=document.createElement("canvas");l.width=c,l.height=T;var h=l.getContext("2d");if(!h)return null;var v=h.createImageData(c,T);if(v.data.set(x),h.putImageData(v,0,0),R.invertY){var E=document.createElement("canvas");E.width=c,E.height=T;var D=E.getContext("2d");return D?(D.translate(0,T),D.scale(1,-1),D.drawImage(l,0,0),E.toDataURL("image/png")):null}return l.toDataURL("image/png")},_}()},function(Me,y,f){f.d(y,"a",function(){return A});var U=f(1),_=f(0),C=f(8),u=f(31),M=f(7),R=f(41),x=f(46),m=f(4),c=f(43),T=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 v=S.call(this,l,h.getScene())||this;v._indexInSourceMeshInstanceArray=-1,h.addInstance(v),v._sourceMesh=h,v._unIndexed=h._unIndexed,v.position.copyFrom(h.position),v.rotation.copyFrom(h.rotation),v.scaling.copyFrom(h.scaling),h.rotationQuaternion&&(v.rotationQuaternion=h.rotationQuaternion.clone()),v.animations=T.b.Slice(h.animations);for(var E=0,D=h.getAnimationRanges();E0!=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!==x.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].copyFrom(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=lightDirection.w) +{ +cosAngle=max(0.,pow(cosAngle,lightData.w)); +attenuation*=cosAngle; + +float ndl=max(0.,dot(vNormal,lightVectorW)); +#ifdef NDOTL +result.ndl=ndl; +#endif +result.diffuse=ndl*diffuseColor*attenuation; +#ifdef SPECULARTERM + +vec3 angleW=normalize(viewDirectionW+lightVectorW); +float specComp=max(0.,dot(vNormal,angleW)); +specComp=pow(specComp,max(1.,glossiness)); +result.specular=specComp*specularColor*attenuation; +#endif +return result; +} +result.diffuse=vec3(0.); +#ifdef SPECULARTERM +result.specular=vec3(0.); +#endif +#ifdef NDOTL +result.ndl=0.; +#endif +return result; +} +lightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float glossiness) { +lightingInfo result; + +float ndl=dot(vNormal,lightData.xyz)*0.5+0.5; +#ifdef NDOTL +result.ndl=ndl; +#endif +result.diffuse=mix(groundColor,diffuseColor,ndl); +#ifdef SPECULARTERM + +vec3 angleW=normalize(viewDirectionW+lightData.xyz); +float specComp=max(0.,dot(vNormal,angleW)); +specComp=pow(specComp,max(1.,glossiness)); +result.specular=specComp*specularColor; +#endif +return result; +} +#define inline +vec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){ +vec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0); +strq/=strq.w; +vec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb; +return textureColor; +}`;f(5).a.IncludesShadersStore[U]=_},function(Me,y,f){var U="logDepthFragment",_=`#ifdef LOGARITHMICDEPTH +gl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5; +#endif`;f(5).a.IncludesShadersStore[U]=_},function(Me,y,f){var U=`#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) +#if defined(TANGENT) && defined(NORMAL) +vec3 tbnNormal=normalize(normalUpdated); +vec3 tbnTangent=normalize(tangentUpdated.xyz); +vec3 tbnBitangent=cross(tbnNormal,tbnTangent)*tangentUpdated.w; +vTBN=mat3(finalWorld)*mat3(tbnTangent,tbnBitangent,tbnNormal); +#endif +#endif`;f(5).a.IncludesShadersStore.bumpVertex=U},function(Me,y,f){var U=`#ifdef FOG +vFogDistance=(view*worldPos).xyz; +#endif`;f(5).a.IncludesShadersStore.fogVertex=U},function(Me,y,f){var U="logDepthVertex",_=`#ifdef LOGARITHMICDEPTH +vFragmentDepth=1.0+gl_Position.w; +gl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant; +#endif`;f(5).a.IncludesShadersStore[U]=_},function(Me,y){var f;f=function(){return this}();try{f=f||new Function("return this")()}catch{typeof window=="object"&&(f=window)}Me.exports=f},function(Me,y,f){var U="prePassDeclaration",_=`#ifdef PREPASS +#extension GL_EXT_draw_buffers : require +#ifdef WEBGL2 +layout(location=0) out highp vec4 glFragData[{X}]; +highp vec4 gl_FragColor; +#endif +#ifdef PREPASS_DEPTHNORMAL +varying highp vec3 vViewPos; +#endif +#ifdef PREPASS_VELOCITY +varying highp vec4 vCurrentPosition; +varying highp vec4 vPreviousPosition; +#endif +#endif +`;f(5).a.IncludesShadersStore[U]=_},function(Me,y,f){var U="fresnelFunction",_=`#ifdef FRESNEL +float computeFresnelTerm(vec3 viewDirection,vec3 worldNormal,float bias,float power) +{ +float fresnelTerm=pow(bias+abs(dot(viewDirection,worldNormal)),power); +return clamp(fresnelTerm,0.,1.); +} +#endif`;f(5).a.IncludesShadersStore[U]=_},function(Me,y,f){var U=`#ifdef DEPTHPREPASS +gl_FragColor=vec4(0.,0.,0.,1.0); +return; +#endif`;f(5).a.IncludesShadersStore.depthPrePass=U},function(Me,y,f){var U="prePassVertexDeclaration",_=`#ifdef PREPASS +#ifdef PREPASS_DEPTHNORMAL +varying vec3 vViewPos; +#endif +#ifdef PREPASS_VELOCITY +uniform mat4 previousWorld; +uniform mat4 previousViewProjection; +varying vec4 vCurrentPosition; +varying vec4 vPreviousPosition; +#endif +#endif`;f(5).a.IncludesShadersStore[U]=_},function(Me,y,f){var U="bumpVertexDeclaration",_=`#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) +#if defined(TANGENT) && defined(NORMAL) +varying mat3 vTBN; +#endif +#endif +`;f(5).a.IncludesShadersStore[U]=_},function(Me,y,f){var U="prePassVertex",_=`#ifdef PREPASS_DEPTHNORMAL +vViewPos=(view*worldPos).rgb; +#endif +#if defined(PREPASS_VELOCITY) && defined(BONES_VELOCITY_ENABLED) +vCurrentPosition=viewProjection*worldPos; +#if NUM_BONE_INFLUENCERS>0 +mat4 previousInfluence; +previousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0]; +#if NUM_BONE_INFLUENCERS>1 +previousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1]; +#endif +#if NUM_BONE_INFLUENCERS>2 +previousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2]; +#endif +#if NUM_BONE_INFLUENCERS>3 +previousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3]; +#endif +#if NUM_BONE_INFLUENCERS>4 +previousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0]; +#endif +#if NUM_BONE_INFLUENCERS>5 +previousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1]; +#endif +#if NUM_BONE_INFLUENCERS>6 +previousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2]; +#endif +#if NUM_BONE_INFLUENCERS>7 +previousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3]; +#endif +vPreviousPosition=previousViewProjection*previousWorld*previousInfluence*vec4(positionUpdated,1.0); +#else +vPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0); +#endif +#endif`;f(5).a.IncludesShadersStore[U]=_},function(Me,y,f){var U=f(5),_=(f(115),f(110),"colorPixelShader"),C=`#ifdef VERTEXCOLOR +varying vec4 vColor; +#else +uniform vec4 color; +#endif +#include +void main(void) { +#include +#ifdef VERTEXCOLOR +gl_FragColor=vColor; +#else +gl_FragColor=color; +#endif +}`;U.a.ShadersStore[_]=C},function(Me,y,f){var U=f(5),_=(f(78),f(117),f(79),f(80),f(81),f(111),"colorVertexShader"),C=` +attribute vec3 position; +#ifdef VERTEXCOLOR +attribute vec4 color; +#endif +#include +#include + +#include +uniform mat4 viewProjection; +#ifdef MULTIVIEW +uniform mat4 viewProjectionR; +#endif + +#ifdef VERTEXCOLOR +varying vec4 vColor; +#endif +void main(void) { +#include +#include +vec4 worldPos=finalWorld*vec4(position,1.0); +#ifdef MULTIVIEW +if (gl_ViewID_OVR == 0u) { +gl_Position=viewProjection*worldPos; +} else { +gl_Position=viewProjectionR*worldPos; +} +#else +gl_Position=viewProjection*worldPos; +#endif +#include +#ifdef VERTEXCOLOR + +vColor=color; +#endif +}`;U.a.ShadersStore[_]=C},function(Me,y,f){(function(U){f.d(y,"b",function(){return T}),f.d(y,"a",function(){return A});var _=f(1),C=f(8),u=f(13),M=f(102),R=f(27),x=f(2),m=f(89),c=f(74),T=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 T);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},C.a.Log("Babylon.js v"+u.a.Version+" - Null engine");var v=typeof self<"u"?self:U!==void 0?U:window;return typeof URL>"u"&&(v.URL={createObjectURL:function(){},revokeObjectURL:function(){}}),typeof Blob>"u"&&(v.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,v,E){},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,v){this._cachedViewport=l},g.prototype.createShaderProgram=function(l,h,v,E,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,v,E){},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},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,v){return!0},g.prototype.setFloat3=function(l,h,v,E){return!0},g.prototype.setBool=function(l,h){return!0},g.prototype.setFloat4=function(l,h,v,E,D){return!0},g.prototype.setAlphaMode=function(l,h){h===void 0&&(h=!1),this._alphaMode!==l&&(this.alphaState.alphaBlend=l!==x.a.ALPHA_DISABLE,h||this.setDepthWrite(l===x.a.ALPHA_DISABLE),this._alphaMode=l)},g.prototype.bindBuffers=function(l,h,v){},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,v,E){},g.prototype.drawElementsType=function(l,h,v,E){},g.prototype.drawArraysType=function(l,h,v,E){},g.prototype._createTexture=function(){return{}},g.prototype._releaseTexture=function(l){},g.prototype.createTexture=function(l,h,v,E,D,w,N,I,V,X,j,ne){D===void 0&&(D=x.a.TEXTURE_TRILINEAR_SAMPLINGMODE),w===void 0&&(w=null),X===void 0&&(X=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=v,te.baseWidth=this._options.textureSize,te.baseHeight=this._options.textureSize,te.width=this._options.textureSize,te.height=this._options.textureSize,X&&(te.format=X),te.isReady=!0,w&&w(),this._internalTexturesCache.push(te),te},g.prototype.createRenderTargetTexture=function(l,h){var v=new M.a;h!==void 0&&typeof h=="object"?(v.generateMipMaps=h.generateMipMaps,v.generateDepthBuffer=h.generateDepthBuffer===void 0||h.generateDepthBuffer,v.generateStencilBuffer=v.generateDepthBuffer&&h.generateStencilBuffer,v.type=h.type===void 0?x.a.TEXTURETYPE_UNSIGNED_INT:h.type,v.samplingMode=h.samplingMode===void 0?x.a.TEXTURE_TRILINEAR_SAMPLINGMODE:h.samplingMode):(v.generateMipMaps=h,v.generateDepthBuffer=!0,v.generateStencilBuffer=!1,v.type=x.a.TEXTURETYPE_UNSIGNED_INT,v.samplingMode=x.a.TEXTURE_TRILINEAR_SAMPLINGMODE);var E=new R.a(this,R.b.RenderTarget),D=l.width||l,w=l.height||l;return E._depthStencilBuffer={},E._framebuffer={},E.baseWidth=D,E.baseHeight=w,E.width=D,E.height=w,E.isReady=!0,E.samples=1,E.generateMipMaps=!!v.generateMipMaps,E.samplingMode=v.samplingMode,E.type=v.type,E._generateDepthBuffer=v.generateDepthBuffer,E._generateStencilBuffer=!!v.generateStencilBuffer,this._internalTexturesCache.push(E),E},g.prototype.updateTextureSamplingMode=function(l,h){h.samplingMode=l},g.prototype.bindFramebuffer=function(l,h,v,E,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,v,E)},g.prototype.unBindFramebuffer=function(l,h,v){this._currentRenderTarget=null,v&&(l._MSAAFramebuffer&&(this._currentFramebuffer=l._framebuffer),v()),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,v,E,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,v){},g.prototype.updateDynamicVertexBuffer=function(l,h,v,E){},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,v,E,D,w,N){},g.prototype._uploadDataToTextureDirectly=function(l,h,v,E){},g.prototype._uploadArrayBufferViewToTexture=function(l,h,v,E){},g.prototype._uploadImageToTexture=function(l,h,v,E){},g}(u.a)}).call(this,f(159))},function(Me,y,f){f.r(y),function(U){f.d(y,"Debug",function(){return m});var _=f(127),C=f(99);f.d(y,"AbstractScene",function(){return _.AbstractScene}),f.d(y,"AbstractActionManager",function(){return _.AbstractActionManager}),f.d(y,"Action",function(){return _.Action}),f.d(y,"ActionEvent",function(){return _.ActionEvent}),f.d(y,"ActionManager",function(){return _.ActionManager}),f.d(y,"Condition",function(){return _.Condition}),f.d(y,"ValueCondition",function(){return _.ValueCondition}),f.d(y,"PredicateCondition",function(){return _.PredicateCondition}),f.d(y,"StateCondition",function(){return _.StateCondition}),f.d(y,"SwitchBooleanAction",function(){return _.SwitchBooleanAction}),f.d(y,"SetStateAction",function(){return _.SetStateAction}),f.d(y,"SetValueAction",function(){return _.SetValueAction}),f.d(y,"IncrementValueAction",function(){return _.IncrementValueAction}),f.d(y,"PlayAnimationAction",function(){return _.PlayAnimationAction}),f.d(y,"StopAnimationAction",function(){return _.StopAnimationAction}),f.d(y,"DoNothingAction",function(){return _.DoNothingAction}),f.d(y,"CombineAction",function(){return _.CombineAction}),f.d(y,"ExecuteCodeAction",function(){return _.ExecuteCodeAction}),f.d(y,"SetParentAction",function(){return _.SetParentAction}),f.d(y,"PlaySoundAction",function(){return _.PlaySoundAction}),f.d(y,"StopSoundAction",function(){return _.StopSoundAction}),f.d(y,"InterpolateValueAction",function(){return _.InterpolateValueAction}),f.d(y,"Animatable",function(){return _.Animatable}),f.d(y,"_IAnimationState",function(){return _._IAnimationState}),f.d(y,"Animation",function(){return _.Animation}),f.d(y,"TargetedAnimation",function(){return _.TargetedAnimation}),f.d(y,"AnimationGroup",function(){return _.AnimationGroup}),f.d(y,"AnimationPropertiesOverride",function(){return _.AnimationPropertiesOverride}),f.d(y,"EasingFunction",function(){return _.EasingFunction}),f.d(y,"CircleEase",function(){return _.CircleEase}),f.d(y,"BackEase",function(){return _.BackEase}),f.d(y,"BounceEase",function(){return _.BounceEase}),f.d(y,"CubicEase",function(){return _.CubicEase}),f.d(y,"ElasticEase",function(){return _.ElasticEase}),f.d(y,"ExponentialEase",function(){return _.ExponentialEase}),f.d(y,"PowerEase",function(){return _.PowerEase}),f.d(y,"QuadraticEase",function(){return _.QuadraticEase}),f.d(y,"QuarticEase",function(){return _.QuarticEase}),f.d(y,"QuinticEase",function(){return _.QuinticEase}),f.d(y,"SineEase",function(){return _.SineEase}),f.d(y,"BezierCurveEase",function(){return _.BezierCurveEase}),f.d(y,"RuntimeAnimation",function(){return _.RuntimeAnimation}),f.d(y,"AnimationEvent",function(){return _.AnimationEvent}),f.d(y,"AnimationKeyInterpolation",function(){return _.AnimationKeyInterpolation}),f.d(y,"AnimationRange",function(){return _.AnimationRange}),f.d(y,"KeepAssets",function(){return _.KeepAssets}),f.d(y,"InstantiatedEntries",function(){return _.InstantiatedEntries}),f.d(y,"AssetContainer",function(){return _.AssetContainer}),f.d(y,"Analyser",function(){return _.Analyser}),f.d(y,"AudioEngine",function(){return _.AudioEngine}),f.d(y,"AudioSceneComponent",function(){return _.AudioSceneComponent}),f.d(y,"Sound",function(){return _.Sound}),f.d(y,"SoundTrack",function(){return _.SoundTrack}),f.d(y,"WeightedSound",function(){return _.WeightedSound}),f.d(y,"AutoRotationBehavior",function(){return _.AutoRotationBehavior}),f.d(y,"BouncingBehavior",function(){return _.BouncingBehavior}),f.d(y,"FramingBehavior",function(){return _.FramingBehavior}),f.d(y,"AttachToBoxBehavior",function(){return _.AttachToBoxBehavior}),f.d(y,"FadeInOutBehavior",function(){return _.FadeInOutBehavior}),f.d(y,"MultiPointerScaleBehavior",function(){return _.MultiPointerScaleBehavior}),f.d(y,"PointerDragBehavior",function(){return _.PointerDragBehavior}),f.d(y,"SixDofDragBehavior",function(){return _.SixDofDragBehavior}),f.d(y,"Bone",function(){return _.Bone}),f.d(y,"BoneIKController",function(){return _.BoneIKController}),f.d(y,"BoneLookController",function(){return _.BoneLookController}),f.d(y,"Skeleton",function(){return _.Skeleton}),f.d(y,"ArcRotateCameraGamepadInput",function(){return _.ArcRotateCameraGamepadInput}),f.d(y,"ArcRotateCameraKeyboardMoveInput",function(){return _.ArcRotateCameraKeyboardMoveInput}),f.d(y,"ArcRotateCameraMouseWheelInput",function(){return _.ArcRotateCameraMouseWheelInput}),f.d(y,"ArcRotateCameraPointersInput",function(){return _.ArcRotateCameraPointersInput}),f.d(y,"ArcRotateCameraVRDeviceOrientationInput",function(){return _.ArcRotateCameraVRDeviceOrientationInput}),f.d(y,"FlyCameraKeyboardInput",function(){return _.FlyCameraKeyboardInput}),f.d(y,"FlyCameraMouseInput",function(){return _.FlyCameraMouseInput}),f.d(y,"FollowCameraKeyboardMoveInput",function(){return _.FollowCameraKeyboardMoveInput}),f.d(y,"FollowCameraMouseWheelInput",function(){return _.FollowCameraMouseWheelInput}),f.d(y,"FollowCameraPointersInput",function(){return _.FollowCameraPointersInput}),f.d(y,"FreeCameraDeviceOrientationInput",function(){return _.FreeCameraDeviceOrientationInput}),f.d(y,"FreeCameraGamepadInput",function(){return _.FreeCameraGamepadInput}),f.d(y,"FreeCameraKeyboardMoveInput",function(){return _.FreeCameraKeyboardMoveInput}),f.d(y,"FreeCameraMouseInput",function(){return _.FreeCameraMouseInput}),f.d(y,"FreeCameraMouseWheelInput",function(){return _.FreeCameraMouseWheelInput}),f.d(y,"FreeCameraTouchInput",function(){return _.FreeCameraTouchInput}),f.d(y,"FreeCameraVirtualJoystickInput",function(){return _.FreeCameraVirtualJoystickInput}),f.d(y,"CameraInputTypes",function(){return _.CameraInputTypes}),f.d(y,"CameraInputsManager",function(){return _.CameraInputsManager}),f.d(y,"Camera",function(){return _.Camera}),f.d(y,"TargetCamera",function(){return _.TargetCamera}),f.d(y,"FreeCamera",function(){return _.FreeCamera}),f.d(y,"FreeCameraInputsManager",function(){return _.FreeCameraInputsManager}),f.d(y,"TouchCamera",function(){return _.TouchCamera}),f.d(y,"ArcRotateCamera",function(){return _.ArcRotateCamera}),f.d(y,"ArcRotateCameraInputsManager",function(){return _.ArcRotateCameraInputsManager}),f.d(y,"DeviceOrientationCamera",function(){return _.DeviceOrientationCamera}),f.d(y,"FlyCamera",function(){return _.FlyCamera}),f.d(y,"FlyCameraInputsManager",function(){return _.FlyCameraInputsManager}),f.d(y,"FollowCamera",function(){return _.FollowCamera}),f.d(y,"ArcFollowCamera",function(){return _.ArcFollowCamera}),f.d(y,"FollowCameraInputsManager",function(){return _.FollowCameraInputsManager}),f.d(y,"GamepadCamera",function(){return _.GamepadCamera}),f.d(y,"AnaglyphArcRotateCamera",function(){return _.AnaglyphArcRotateCamera}),f.d(y,"AnaglyphFreeCamera",function(){return _.AnaglyphFreeCamera}),f.d(y,"AnaglyphGamepadCamera",function(){return _.AnaglyphGamepadCamera}),f.d(y,"AnaglyphUniversalCamera",function(){return _.AnaglyphUniversalCamera}),f.d(y,"StereoscopicArcRotateCamera",function(){return _.StereoscopicArcRotateCamera}),f.d(y,"StereoscopicFreeCamera",function(){return _.StereoscopicFreeCamera}),f.d(y,"StereoscopicGamepadCamera",function(){return _.StereoscopicGamepadCamera}),f.d(y,"StereoscopicUniversalCamera",function(){return _.StereoscopicUniversalCamera}),f.d(y,"UniversalCamera",function(){return _.UniversalCamera}),f.d(y,"VirtualJoysticksCamera",function(){return _.VirtualJoysticksCamera}),f.d(y,"VRCameraMetrics",function(){return _.VRCameraMetrics}),f.d(y,"VRDeviceOrientationArcRotateCamera",function(){return _.VRDeviceOrientationArcRotateCamera}),f.d(y,"VRDeviceOrientationFreeCamera",function(){return _.VRDeviceOrientationFreeCamera}),f.d(y,"VRDeviceOrientationGamepadCamera",function(){return _.VRDeviceOrientationGamepadCamera}),f.d(y,"OnAfterEnteringVRObservableEvent",function(){return _.OnAfterEnteringVRObservableEvent}),f.d(y,"VRExperienceHelper",function(){return _.VRExperienceHelper}),f.d(y,"WebVRFreeCamera",function(){return _.WebVRFreeCamera}),f.d(y,"Collider",function(){return _.Collider}),f.d(y,"DefaultCollisionCoordinator",function(){return _.DefaultCollisionCoordinator}),f.d(y,"PickingInfo",function(){return _.PickingInfo}),f.d(y,"IntersectionInfo",function(){return _.IntersectionInfo}),f.d(y,"_MeshCollisionData",function(){return _._MeshCollisionData}),f.d(y,"BoundingBox",function(){return _.BoundingBox}),f.d(y,"BoundingInfo",function(){return _.BoundingInfo}),f.d(y,"BoundingSphere",function(){return _.BoundingSphere}),f.d(y,"Octree",function(){return _.Octree}),f.d(y,"OctreeBlock",function(){return _.OctreeBlock}),f.d(y,"OctreeSceneComponent",function(){return _.OctreeSceneComponent}),f.d(y,"Ray",function(){return _.Ray}),f.d(y,"AxesViewer",function(){return _.AxesViewer}),f.d(y,"BoneAxesViewer",function(){return _.BoneAxesViewer}),f.d(y,"DebugLayerTab",function(){return _.DebugLayerTab}),f.d(y,"DebugLayer",function(){return _.DebugLayer}),f.d(y,"PhysicsViewer",function(){return _.PhysicsViewer}),f.d(y,"RayHelper",function(){return _.RayHelper}),f.d(y,"SkeletonViewer",function(){return _.SkeletonViewer}),f.d(y,"DeviceInputSystem",function(){return _.DeviceInputSystem}),f.d(y,"DeviceType",function(){return _.DeviceType}),f.d(y,"PointerInput",function(){return _.PointerInput}),f.d(y,"DualShockInput",function(){return _.DualShockInput}),f.d(y,"XboxInput",function(){return _.XboxInput}),f.d(y,"SwitchInput",function(){return _.SwitchInput}),f.d(y,"DeviceSource",function(){return _.DeviceSource}),f.d(y,"DeviceSourceManager",function(){return _.DeviceSourceManager}),f.d(y,"Constants",function(){return _.Constants}),f.d(y,"ThinEngine",function(){return _.ThinEngine}),f.d(y,"Engine",function(){return _.Engine}),f.d(y,"EngineStore",function(){return _.EngineStore}),f.d(y,"NullEngineOptions",function(){return _.NullEngineOptions}),f.d(y,"NullEngine",function(){return _.NullEngine}),f.d(y,"_OcclusionDataStorage",function(){return _._OcclusionDataStorage}),f.d(y,"_forceTransformFeedbackToBundle",function(){return _._forceTransformFeedbackToBundle}),f.d(y,"EngineView",function(){return _.EngineView}),f.d(y,"WebGLPipelineContext",function(){return _.WebGLPipelineContext}),f.d(y,"WebGL2ShaderProcessor",function(){return _.WebGL2ShaderProcessor}),f.d(y,"NativeEngine",function(){return _.NativeEngine}),f.d(y,"ShaderCodeInliner",function(){return _.ShaderCodeInliner}),f.d(y,"PerformanceConfigurator",function(){return _.PerformanceConfigurator}),f.d(y,"KeyboardEventTypes",function(){return _.KeyboardEventTypes}),f.d(y,"KeyboardInfo",function(){return _.KeyboardInfo}),f.d(y,"KeyboardInfoPre",function(){return _.KeyboardInfoPre}),f.d(y,"PointerEventTypes",function(){return _.PointerEventTypes}),f.d(y,"PointerInfoBase",function(){return _.PointerInfoBase}),f.d(y,"PointerInfoPre",function(){return _.PointerInfoPre}),f.d(y,"PointerInfo",function(){return _.PointerInfo}),f.d(y,"ClipboardEventTypes",function(){return _.ClipboardEventTypes}),f.d(y,"ClipboardInfo",function(){return _.ClipboardInfo}),f.d(y,"DaydreamController",function(){return _.DaydreamController}),f.d(y,"GearVRController",function(){return _.GearVRController}),f.d(y,"GenericController",function(){return _.GenericController}),f.d(y,"OculusTouchController",function(){return _.OculusTouchController}),f.d(y,"PoseEnabledControllerType",function(){return _.PoseEnabledControllerType}),f.d(y,"PoseEnabledControllerHelper",function(){return _.PoseEnabledControllerHelper}),f.d(y,"PoseEnabledController",function(){return _.PoseEnabledController}),f.d(y,"ViveController",function(){return _.ViveController}),f.d(y,"WebVRController",function(){return _.WebVRController}),f.d(y,"WindowsMotionController",function(){return _.WindowsMotionController}),f.d(y,"XRWindowsMotionController",function(){return _.XRWindowsMotionController}),f.d(y,"StickValues",function(){return _.StickValues}),f.d(y,"Gamepad",function(){return _.Gamepad}),f.d(y,"GenericPad",function(){return _.GenericPad}),f.d(y,"GamepadManager",function(){return _.GamepadManager}),f.d(y,"GamepadSystemSceneComponent",function(){return _.GamepadSystemSceneComponent}),f.d(y,"Xbox360Button",function(){return _.Xbox360Button}),f.d(y,"Xbox360Dpad",function(){return _.Xbox360Dpad}),f.d(y,"Xbox360Pad",function(){return _.Xbox360Pad}),f.d(y,"DualShockButton",function(){return _.DualShockButton}),f.d(y,"DualShockDpad",function(){return _.DualShockDpad}),f.d(y,"DualShockPad",function(){return _.DualShockPad}),f.d(y,"AxisDragGizmo",function(){return _.AxisDragGizmo}),f.d(y,"AxisScaleGizmo",function(){return _.AxisScaleGizmo}),f.d(y,"BoundingBoxGizmo",function(){return _.BoundingBoxGizmo}),f.d(y,"Gizmo",function(){return _.Gizmo}),f.d(y,"GizmoManager",function(){return _.GizmoManager}),f.d(y,"PlaneRotationGizmo",function(){return _.PlaneRotationGizmo}),f.d(y,"PositionGizmo",function(){return _.PositionGizmo}),f.d(y,"RotationGizmo",function(){return _.RotationGizmo}),f.d(y,"ScaleGizmo",function(){return _.ScaleGizmo}),f.d(y,"LightGizmo",function(){return _.LightGizmo}),f.d(y,"CameraGizmo",function(){return _.CameraGizmo}),f.d(y,"PlaneDragGizmo",function(){return _.PlaneDragGizmo}),f.d(y,"EnvironmentHelper",function(){return _.EnvironmentHelper}),f.d(y,"PhotoDome",function(){return _.PhotoDome}),f.d(y,"_forceSceneHelpersToBundle",function(){return _._forceSceneHelpersToBundle}),f.d(y,"VideoDome",function(){return _.VideoDome}),f.d(y,"EngineInstrumentation",function(){return _.EngineInstrumentation}),f.d(y,"SceneInstrumentation",function(){return _.SceneInstrumentation}),f.d(y,"_TimeToken",function(){return _._TimeToken}),f.d(y,"EffectLayer",function(){return _.EffectLayer}),f.d(y,"EffectLayerSceneComponent",function(){return _.EffectLayerSceneComponent}),f.d(y,"GlowLayer",function(){return _.GlowLayer}),f.d(y,"HighlightLayer",function(){return _.HighlightLayer}),f.d(y,"Layer",function(){return _.Layer}),f.d(y,"LayerSceneComponent",function(){return _.LayerSceneComponent}),f.d(y,"LensFlare",function(){return _.LensFlare}),f.d(y,"LensFlareSystem",function(){return _.LensFlareSystem}),f.d(y,"LensFlareSystemSceneComponent",function(){return _.LensFlareSystemSceneComponent}),f.d(y,"Light",function(){return _.Light}),f.d(y,"ShadowLight",function(){return _.ShadowLight}),f.d(y,"ShadowGenerator",function(){return _.ShadowGenerator}),f.d(y,"CascadedShadowGenerator",function(){return _.CascadedShadowGenerator}),f.d(y,"ShadowGeneratorSceneComponent",function(){return _.ShadowGeneratorSceneComponent}),f.d(y,"DirectionalLight",function(){return _.DirectionalLight}),f.d(y,"HemisphericLight",function(){return _.HemisphericLight}),f.d(y,"PointLight",function(){return _.PointLight}),f.d(y,"SpotLight",function(){return _.SpotLight}),f.d(y,"DefaultLoadingScreen",function(){return _.DefaultLoadingScreen}),f.d(y,"_BabylonLoaderRegistered",function(){return _._BabylonLoaderRegistered}),f.d(y,"BabylonFileLoaderConfiguration",function(){return _.BabylonFileLoaderConfiguration}),f.d(y,"SceneLoaderAnimationGroupLoadingMode",function(){return _.SceneLoaderAnimationGroupLoadingMode}),f.d(y,"SceneLoader",function(){return _.SceneLoader}),f.d(y,"SceneLoaderFlags",function(){return _.SceneLoaderFlags}),f.d(y,"BackgroundMaterial",function(){return _.BackgroundMaterial}),f.d(y,"ColorCurves",function(){return _.ColorCurves}),f.d(y,"EffectFallbacks",function(){return _.EffectFallbacks}),f.d(y,"Effect",function(){return _.Effect}),f.d(y,"FresnelParameters",function(){return _.FresnelParameters}),f.d(y,"ImageProcessingConfigurationDefines",function(){return _.ImageProcessingConfigurationDefines}),f.d(y,"ImageProcessingConfiguration",function(){return _.ImageProcessingConfiguration}),f.d(y,"Material",function(){return _.Material}),f.d(y,"MaterialDefines",function(){return _.MaterialDefines}),f.d(y,"ThinMaterialHelper",function(){return _.ThinMaterialHelper}),f.d(y,"MaterialHelper",function(){return _.MaterialHelper}),f.d(y,"MultiMaterial",function(){return _.MultiMaterial}),f.d(y,"PBRMaterialDefines",function(){return _.PBRMaterialDefines}),f.d(y,"PBRBaseMaterial",function(){return _.PBRBaseMaterial}),f.d(y,"PBRBaseSimpleMaterial",function(){return _.PBRBaseSimpleMaterial}),f.d(y,"PBRMaterial",function(){return _.PBRMaterial}),f.d(y,"PBRMetallicRoughnessMaterial",function(){return _.PBRMetallicRoughnessMaterial}),f.d(y,"PBRSpecularGlossinessMaterial",function(){return _.PBRSpecularGlossinessMaterial}),f.d(y,"PushMaterial",function(){return _.PushMaterial}),f.d(y,"ShaderMaterial",function(){return _.ShaderMaterial}),f.d(y,"StandardMaterialDefines",function(){return _.StandardMaterialDefines}),f.d(y,"StandardMaterial",function(){return _.StandardMaterial}),f.d(y,"BaseTexture",function(){return _.BaseTexture}),f.d(y,"ColorGradingTexture",function(){return _.ColorGradingTexture}),f.d(y,"CubeTexture",function(){return _.CubeTexture}),f.d(y,"DynamicTexture",function(){return _.DynamicTexture}),f.d(y,"EquiRectangularCubeTexture",function(){return _.EquiRectangularCubeTexture}),f.d(y,"HDRFiltering",function(){return _.HDRFiltering}),f.d(y,"HDRCubeTexture",function(){return _.HDRCubeTexture}),f.d(y,"HtmlElementTexture",function(){return _.HtmlElementTexture}),f.d(y,"InternalTextureSource",function(){return _.InternalTextureSource}),f.d(y,"InternalTexture",function(){return _.InternalTexture}),f.d(y,"_DDSTextureLoader",function(){return _._DDSTextureLoader}),f.d(y,"_ENVTextureLoader",function(){return _._ENVTextureLoader}),f.d(y,"_KTXTextureLoader",function(){return _._KTXTextureLoader}),f.d(y,"_TGATextureLoader",function(){return _._TGATextureLoader}),f.d(y,"_BasisTextureLoader",function(){return _._BasisTextureLoader}),f.d(y,"MirrorTexture",function(){return _.MirrorTexture}),f.d(y,"MultiRenderTarget",function(){return _.MultiRenderTarget}),f.d(y,"TexturePacker",function(){return _.TexturePacker}),f.d(y,"TexturePackerFrame",function(){return _.TexturePackerFrame}),f.d(y,"CustomProceduralTexture",function(){return _.CustomProceduralTexture}),f.d(y,"NoiseProceduralTexture",function(){return _.NoiseProceduralTexture}),f.d(y,"ProceduralTexture",function(){return _.ProceduralTexture}),f.d(y,"ProceduralTextureSceneComponent",function(){return _.ProceduralTextureSceneComponent}),f.d(y,"RawCubeTexture",function(){return _.RawCubeTexture}),f.d(y,"RawTexture",function(){return _.RawTexture}),f.d(y,"RawTexture2DArray",function(){return _.RawTexture2DArray}),f.d(y,"RawTexture3D",function(){return _.RawTexture3D}),f.d(y,"RefractionTexture",function(){return _.RefractionTexture}),f.d(y,"RenderTargetTexture",function(){return _.RenderTargetTexture}),f.d(y,"Texture",function(){return _.Texture}),f.d(y,"VideoTexture",function(){return _.VideoTexture}),f.d(y,"UniformBuffer",function(){return _.UniformBuffer}),f.d(y,"MaterialFlags",function(){return _.MaterialFlags}),f.d(y,"NodeMaterialBlockTargets",function(){return _.NodeMaterialBlockTargets}),f.d(y,"NodeMaterialBlockConnectionPointTypes",function(){return _.NodeMaterialBlockConnectionPointTypes}),f.d(y,"NodeMaterialBlockConnectionPointMode",function(){return _.NodeMaterialBlockConnectionPointMode}),f.d(y,"NodeMaterialSystemValues",function(){return _.NodeMaterialSystemValues}),f.d(y,"NodeMaterialModes",function(){return _.NodeMaterialModes}),f.d(y,"NodeMaterialConnectionPointCompatibilityStates",function(){return _.NodeMaterialConnectionPointCompatibilityStates}),f.d(y,"NodeMaterialConnectionPointDirection",function(){return _.NodeMaterialConnectionPointDirection}),f.d(y,"NodeMaterialConnectionPoint",function(){return _.NodeMaterialConnectionPoint}),f.d(y,"NodeMaterialBlock",function(){return _.NodeMaterialBlock}),f.d(y,"NodeMaterialDefines",function(){return _.NodeMaterialDefines}),f.d(y,"NodeMaterial",function(){return _.NodeMaterial}),f.d(y,"VertexOutputBlock",function(){return _.VertexOutputBlock}),f.d(y,"BonesBlock",function(){return _.BonesBlock}),f.d(y,"InstancesBlock",function(){return _.InstancesBlock}),f.d(y,"MorphTargetsBlock",function(){return _.MorphTargetsBlock}),f.d(y,"LightInformationBlock",function(){return _.LightInformationBlock}),f.d(y,"FragmentOutputBlock",function(){return _.FragmentOutputBlock}),f.d(y,"ImageProcessingBlock",function(){return _.ImageProcessingBlock}),f.d(y,"PerturbNormalBlock",function(){return _.PerturbNormalBlock}),f.d(y,"DiscardBlock",function(){return _.DiscardBlock}),f.d(y,"FrontFacingBlock",function(){return _.FrontFacingBlock}),f.d(y,"DerivativeBlock",function(){return _.DerivativeBlock}),f.d(y,"FragCoordBlock",function(){return _.FragCoordBlock}),f.d(y,"ScreenSizeBlock",function(){return _.ScreenSizeBlock}),f.d(y,"FogBlock",function(){return _.FogBlock}),f.d(y,"LightBlock",function(){return _.LightBlock}),f.d(y,"TextureBlock",function(){return _.TextureBlock}),f.d(y,"ReflectionTextureBlock",function(){return _.ReflectionTextureBlock}),f.d(y,"CurrentScreenBlock",function(){return _.CurrentScreenBlock}),f.d(y,"InputBlock",function(){return _.InputBlock}),f.d(y,"AnimatedInputBlockTypes",function(){return _.AnimatedInputBlockTypes}),f.d(y,"MultiplyBlock",function(){return _.MultiplyBlock}),f.d(y,"AddBlock",function(){return _.AddBlock}),f.d(y,"ScaleBlock",function(){return _.ScaleBlock}),f.d(y,"ClampBlock",function(){return _.ClampBlock}),f.d(y,"CrossBlock",function(){return _.CrossBlock}),f.d(y,"DotBlock",function(){return _.DotBlock}),f.d(y,"TransformBlock",function(){return _.TransformBlock}),f.d(y,"RemapBlock",function(){return _.RemapBlock}),f.d(y,"NormalizeBlock",function(){return _.NormalizeBlock}),f.d(y,"TrigonometryBlockOperations",function(){return _.TrigonometryBlockOperations}),f.d(y,"TrigonometryBlock",function(){return _.TrigonometryBlock}),f.d(y,"ColorMergerBlock",function(){return _.ColorMergerBlock}),f.d(y,"VectorMergerBlock",function(){return _.VectorMergerBlock}),f.d(y,"ColorSplitterBlock",function(){return _.ColorSplitterBlock}),f.d(y,"VectorSplitterBlock",function(){return _.VectorSplitterBlock}),f.d(y,"LerpBlock",function(){return _.LerpBlock}),f.d(y,"DivideBlock",function(){return _.DivideBlock}),f.d(y,"SubtractBlock",function(){return _.SubtractBlock}),f.d(y,"StepBlock",function(){return _.StepBlock}),f.d(y,"OneMinusBlock",function(){return _.OneMinusBlock}),f.d(y,"ViewDirectionBlock",function(){return _.ViewDirectionBlock}),f.d(y,"FresnelBlock",function(){return _.FresnelBlock}),f.d(y,"MaxBlock",function(){return _.MaxBlock}),f.d(y,"MinBlock",function(){return _.MinBlock}),f.d(y,"DistanceBlock",function(){return _.DistanceBlock}),f.d(y,"LengthBlock",function(){return _.LengthBlock}),f.d(y,"NegateBlock",function(){return _.NegateBlock}),f.d(y,"PowBlock",function(){return _.PowBlock}),f.d(y,"RandomNumberBlock",function(){return _.RandomNumberBlock}),f.d(y,"ArcTan2Block",function(){return _.ArcTan2Block}),f.d(y,"SmoothStepBlock",function(){return _.SmoothStepBlock}),f.d(y,"ReciprocalBlock",function(){return _.ReciprocalBlock}),f.d(y,"ReplaceColorBlock",function(){return _.ReplaceColorBlock}),f.d(y,"PosterizeBlock",function(){return _.PosterizeBlock}),f.d(y,"WaveBlockKind",function(){return _.WaveBlockKind}),f.d(y,"WaveBlock",function(){return _.WaveBlock}),f.d(y,"GradientBlockColorStep",function(){return _.GradientBlockColorStep}),f.d(y,"GradientBlock",function(){return _.GradientBlock}),f.d(y,"NLerpBlock",function(){return _.NLerpBlock}),f.d(y,"WorleyNoise3DBlock",function(){return _.WorleyNoise3DBlock}),f.d(y,"SimplexPerlin3DBlock",function(){return _.SimplexPerlin3DBlock}),f.d(y,"NormalBlendBlock",function(){return _.NormalBlendBlock}),f.d(y,"Rotate2dBlock",function(){return _.Rotate2dBlock}),f.d(y,"ReflectBlock",function(){return _.ReflectBlock}),f.d(y,"RefractBlock",function(){return _.RefractBlock}),f.d(y,"DesaturateBlock",function(){return _.DesaturateBlock}),f.d(y,"PBRMetallicRoughnessBlock",function(){return _.PBRMetallicRoughnessBlock}),f.d(y,"SheenBlock",function(){return _.SheenBlock}),f.d(y,"AnisotropyBlock",function(){return _.AnisotropyBlock}),f.d(y,"ReflectionBlock",function(){return _.ReflectionBlock}),f.d(y,"ClearCoatBlock",function(){return _.ClearCoatBlock}),f.d(y,"RefractionBlock",function(){return _.RefractionBlock}),f.d(y,"SubSurfaceBlock",function(){return _.SubSurfaceBlock}),f.d(y,"ParticleTextureBlock",function(){return _.ParticleTextureBlock}),f.d(y,"ParticleRampGradientBlock",function(){return _.ParticleRampGradientBlock}),f.d(y,"ParticleBlendMultiplyBlock",function(){return _.ParticleBlendMultiplyBlock}),f.d(y,"ModBlock",function(){return _.ModBlock}),f.d(y,"NodeMaterialOptimizer",function(){return _.NodeMaterialOptimizer}),f.d(y,"PropertyTypeForEdition",function(){return _.PropertyTypeForEdition}),f.d(y,"editableInPropertyPage",function(){return _.editableInPropertyPage}),f.d(y,"EffectRenderer",function(){return _.EffectRenderer}),f.d(y,"EffectWrapper",function(){return _.EffectWrapper}),f.d(y,"ShadowDepthWrapper",function(){return _.ShadowDepthWrapper}),f.d(y,"Scalar",function(){return _.Scalar}),f.d(y,"extractMinAndMaxIndexed",function(){return _.extractMinAndMaxIndexed}),f.d(y,"extractMinAndMax",function(){return _.extractMinAndMax}),f.d(y,"Space",function(){return _.Space}),f.d(y,"Axis",function(){return _.Axis}),f.d(y,"Coordinate",function(){return _.Coordinate}),f.d(y,"Color3",function(){return _.Color3}),f.d(y,"Color4",function(){return _.Color4}),f.d(y,"TmpColors",function(){return _.TmpColors}),f.d(y,"ToGammaSpace",function(){return _.ToGammaSpace}),f.d(y,"ToLinearSpace",function(){return _.ToLinearSpace}),f.d(y,"Epsilon",function(){return _.Epsilon}),f.d(y,"Frustum",function(){return _.Frustum}),f.d(y,"Orientation",function(){return _.Orientation}),f.d(y,"BezierCurve",function(){return _.BezierCurve}),f.d(y,"Angle",function(){return _.Angle}),f.d(y,"Arc2",function(){return _.Arc2}),f.d(y,"Path2",function(){return _.Path2}),f.d(y,"Path3D",function(){return _.Path3D}),f.d(y,"Curve3",function(){return _.Curve3}),f.d(y,"Plane",function(){return _.Plane}),f.d(y,"Size",function(){return _.Size}),f.d(y,"Vector2",function(){return _.Vector2}),f.d(y,"Vector3",function(){return _.Vector3}),f.d(y,"Vector4",function(){return _.Vector4}),f.d(y,"Quaternion",function(){return _.Quaternion}),f.d(y,"Matrix",function(){return _.Matrix}),f.d(y,"TmpVectors",function(){return _.TmpVectors}),f.d(y,"PositionNormalVertex",function(){return _.PositionNormalVertex}),f.d(y,"PositionNormalTextureVertex",function(){return _.PositionNormalTextureVertex}),f.d(y,"Viewport",function(){return _.Viewport}),f.d(y,"SphericalHarmonics",function(){return _.SphericalHarmonics}),f.d(y,"SphericalPolynomial",function(){return _.SphericalPolynomial}),f.d(y,"AbstractMesh",function(){return _.AbstractMesh}),f.d(y,"Buffer",function(){return _.Buffer}),f.d(y,"VertexBuffer",function(){return _.VertexBuffer}),f.d(y,"DracoCompression",function(){return _.DracoCompression}),f.d(y,"CSG",function(){return _.CSG}),f.d(y,"Geometry",function(){return _.Geometry}),f.d(y,"GroundMesh",function(){return _.GroundMesh}),f.d(y,"TrailMesh",function(){return _.TrailMesh}),f.d(y,"InstancedMesh",function(){return _.InstancedMesh}),f.d(y,"LinesMesh",function(){return _.LinesMesh}),f.d(y,"InstancedLinesMesh",function(){return _.InstancedLinesMesh}),f.d(y,"_CreationDataStorage",function(){return _._CreationDataStorage}),f.d(y,"_InstancesBatch",function(){return _._InstancesBatch}),f.d(y,"Mesh",function(){return _.Mesh}),f.d(y,"VertexData",function(){return _.VertexData}),f.d(y,"MeshBuilder",function(){return _.MeshBuilder}),f.d(y,"SimplificationSettings",function(){return _.SimplificationSettings}),f.d(y,"SimplificationQueue",function(){return _.SimplificationQueue}),f.d(y,"SimplificationType",function(){return _.SimplificationType}),f.d(y,"QuadraticErrorSimplification",function(){return _.QuadraticErrorSimplification}),f.d(y,"SimplicationQueueSceneComponent",function(){return _.SimplicationQueueSceneComponent}),f.d(y,"Polygon",function(){return _.Polygon}),f.d(y,"PolygonMeshBuilder",function(){return _.PolygonMeshBuilder}),f.d(y,"SubMesh",function(){return _.SubMesh}),f.d(y,"MeshLODLevel",function(){return _.MeshLODLevel}),f.d(y,"TransformNode",function(){return _.TransformNode}),f.d(y,"BoxBuilder",function(){return _.BoxBuilder}),f.d(y,"TiledBoxBuilder",function(){return _.TiledBoxBuilder}),f.d(y,"DiscBuilder",function(){return _.DiscBuilder}),f.d(y,"RibbonBuilder",function(){return _.RibbonBuilder}),f.d(y,"SphereBuilder",function(){return _.SphereBuilder}),f.d(y,"HemisphereBuilder",function(){return _.HemisphereBuilder}),f.d(y,"CylinderBuilder",function(){return _.CylinderBuilder}),f.d(y,"TorusBuilder",function(){return _.TorusBuilder}),f.d(y,"TorusKnotBuilder",function(){return _.TorusKnotBuilder}),f.d(y,"LinesBuilder",function(){return _.LinesBuilder}),f.d(y,"PolygonBuilder",function(){return _.PolygonBuilder}),f.d(y,"ShapeBuilder",function(){return _.ShapeBuilder}),f.d(y,"LatheBuilder",function(){return _.LatheBuilder}),f.d(y,"PlaneBuilder",function(){return _.PlaneBuilder}),f.d(y,"TiledPlaneBuilder",function(){return _.TiledPlaneBuilder}),f.d(y,"GroundBuilder",function(){return _.GroundBuilder}),f.d(y,"TubeBuilder",function(){return _.TubeBuilder}),f.d(y,"PolyhedronBuilder",function(){return _.PolyhedronBuilder}),f.d(y,"IcoSphereBuilder",function(){return _.IcoSphereBuilder}),f.d(y,"DecalBuilder",function(){return _.DecalBuilder}),f.d(y,"CapsuleBuilder",function(){return _.CapsuleBuilder}),f.d(y,"DataBuffer",function(){return _.DataBuffer}),f.d(y,"WebGLDataBuffer",function(){return _.WebGLDataBuffer}),f.d(y,"MorphTarget",function(){return _.MorphTarget}),f.d(y,"MorphTargetManager",function(){return _.MorphTargetManager}),f.d(y,"RecastJSPlugin",function(){return _.RecastJSPlugin}),f.d(y,"RecastJSCrowd",function(){return _.RecastJSCrowd}),f.d(y,"Node",function(){return _.Node}),f.d(y,"Database",function(){return _.Database}),f.d(y,"BaseParticleSystem",function(){return _.BaseParticleSystem}),f.d(y,"BoxParticleEmitter",function(){return _.BoxParticleEmitter}),f.d(y,"ConeParticleEmitter",function(){return _.ConeParticleEmitter}),f.d(y,"CylinderParticleEmitter",function(){return _.CylinderParticleEmitter}),f.d(y,"CylinderDirectedParticleEmitter",function(){return _.CylinderDirectedParticleEmitter}),f.d(y,"HemisphericParticleEmitter",function(){return _.HemisphericParticleEmitter}),f.d(y,"PointParticleEmitter",function(){return _.PointParticleEmitter}),f.d(y,"SphereParticleEmitter",function(){return _.SphereParticleEmitter}),f.d(y,"SphereDirectedParticleEmitter",function(){return _.SphereDirectedParticleEmitter}),f.d(y,"CustomParticleEmitter",function(){return _.CustomParticleEmitter}),f.d(y,"MeshParticleEmitter",function(){return _.MeshParticleEmitter}),f.d(y,"GPUParticleSystem",function(){return _.GPUParticleSystem}),f.d(y,"Particle",function(){return _.Particle}),f.d(y,"ParticleHelper",function(){return _.ParticleHelper}),f.d(y,"ParticleSystem",function(){return _.ParticleSystem}),f.d(y,"ParticleSystemSet",function(){return _.ParticleSystemSet}),f.d(y,"SolidParticle",function(){return _.SolidParticle}),f.d(y,"ModelShape",function(){return _.ModelShape}),f.d(y,"DepthSortedParticle",function(){return _.DepthSortedParticle}),f.d(y,"SolidParticleVertex",function(){return _.SolidParticleVertex}),f.d(y,"SolidParticleSystem",function(){return _.SolidParticleSystem}),f.d(y,"CloudPoint",function(){return _.CloudPoint}),f.d(y,"PointsGroup",function(){return _.PointsGroup}),f.d(y,"PointColor",function(){return _.PointColor}),f.d(y,"PointsCloudSystem",function(){return _.PointsCloudSystem}),f.d(y,"SubEmitterType",function(){return _.SubEmitterType}),f.d(y,"SubEmitter",function(){return _.SubEmitter}),f.d(y,"PhysicsEngine",function(){return _.PhysicsEngine}),f.d(y,"PhysicsEngineSceneComponent",function(){return _.PhysicsEngineSceneComponent}),f.d(y,"PhysicsHelper",function(){return _.PhysicsHelper}),f.d(y,"PhysicsRadialExplosionEventOptions",function(){return _.PhysicsRadialExplosionEventOptions}),f.d(y,"PhysicsUpdraftEventOptions",function(){return _.PhysicsUpdraftEventOptions}),f.d(y,"PhysicsVortexEventOptions",function(){return _.PhysicsVortexEventOptions}),f.d(y,"PhysicsRadialImpulseFalloff",function(){return _.PhysicsRadialImpulseFalloff}),f.d(y,"PhysicsUpdraftMode",function(){return _.PhysicsUpdraftMode}),f.d(y,"PhysicsImpostor",function(){return _.PhysicsImpostor}),f.d(y,"PhysicsJoint",function(){return _.PhysicsJoint}),f.d(y,"DistanceJoint",function(){return _.DistanceJoint}),f.d(y,"MotorEnabledJoint",function(){return _.MotorEnabledJoint}),f.d(y,"HingeJoint",function(){return _.HingeJoint}),f.d(y,"Hinge2Joint",function(){return _.Hinge2Joint}),f.d(y,"CannonJSPlugin",function(){return _.CannonJSPlugin}),f.d(y,"AmmoJSPlugin",function(){return _.AmmoJSPlugin}),f.d(y,"OimoJSPlugin",function(){return _.OimoJSPlugin}),f.d(y,"AnaglyphPostProcess",function(){return _.AnaglyphPostProcess}),f.d(y,"BlackAndWhitePostProcess",function(){return _.BlackAndWhitePostProcess}),f.d(y,"BloomEffect",function(){return _.BloomEffect}),f.d(y,"BloomMergePostProcess",function(){return _.BloomMergePostProcess}),f.d(y,"BlurPostProcess",function(){return _.BlurPostProcess}),f.d(y,"ChromaticAberrationPostProcess",function(){return _.ChromaticAberrationPostProcess}),f.d(y,"CircleOfConfusionPostProcess",function(){return _.CircleOfConfusionPostProcess}),f.d(y,"ColorCorrectionPostProcess",function(){return _.ColorCorrectionPostProcess}),f.d(y,"ConvolutionPostProcess",function(){return _.ConvolutionPostProcess}),f.d(y,"DepthOfFieldBlurPostProcess",function(){return _.DepthOfFieldBlurPostProcess}),f.d(y,"DepthOfFieldEffectBlurLevel",function(){return _.DepthOfFieldEffectBlurLevel}),f.d(y,"DepthOfFieldEffect",function(){return _.DepthOfFieldEffect}),f.d(y,"DepthOfFieldMergePostProcessOptions",function(){return _.DepthOfFieldMergePostProcessOptions}),f.d(y,"DepthOfFieldMergePostProcess",function(){return _.DepthOfFieldMergePostProcess}),f.d(y,"DisplayPassPostProcess",function(){return _.DisplayPassPostProcess}),f.d(y,"ExtractHighlightsPostProcess",function(){return _.ExtractHighlightsPostProcess}),f.d(y,"FilterPostProcess",function(){return _.FilterPostProcess}),f.d(y,"FxaaPostProcess",function(){return _.FxaaPostProcess}),f.d(y,"GrainPostProcess",function(){return _.GrainPostProcess}),f.d(y,"HighlightsPostProcess",function(){return _.HighlightsPostProcess}),f.d(y,"ImageProcessingPostProcess",function(){return _.ImageProcessingPostProcess}),f.d(y,"MotionBlurPostProcess",function(){return _.MotionBlurPostProcess}),f.d(y,"PassPostProcess",function(){return _.PassPostProcess}),f.d(y,"PassCubePostProcess",function(){return _.PassCubePostProcess}),f.d(y,"PostProcess",function(){return _.PostProcess}),f.d(y,"PostProcessManager",function(){return _.PostProcessManager}),f.d(y,"RefractionPostProcess",function(){return _.RefractionPostProcess}),f.d(y,"DefaultRenderingPipeline",function(){return _.DefaultRenderingPipeline}),f.d(y,"LensRenderingPipeline",function(){return _.LensRenderingPipeline}),f.d(y,"SSAO2RenderingPipeline",function(){return _.SSAO2RenderingPipeline}),f.d(y,"SSAORenderingPipeline",function(){return _.SSAORenderingPipeline}),f.d(y,"StandardRenderingPipeline",function(){return _.StandardRenderingPipeline}),f.d(y,"PostProcessRenderEffect",function(){return _.PostProcessRenderEffect}),f.d(y,"PostProcessRenderPipeline",function(){return _.PostProcessRenderPipeline}),f.d(y,"PostProcessRenderPipelineManager",function(){return _.PostProcessRenderPipelineManager}),f.d(y,"PostProcessRenderPipelineManagerSceneComponent",function(){return _.PostProcessRenderPipelineManagerSceneComponent}),f.d(y,"SharpenPostProcess",function(){return _.SharpenPostProcess}),f.d(y,"StereoscopicInterlacePostProcessI",function(){return _.StereoscopicInterlacePostProcessI}),f.d(y,"StereoscopicInterlacePostProcess",function(){return _.StereoscopicInterlacePostProcess}),f.d(y,"TonemappingOperator",function(){return _.TonemappingOperator}),f.d(y,"TonemapPostProcess",function(){return _.TonemapPostProcess}),f.d(y,"VolumetricLightScatteringPostProcess",function(){return _.VolumetricLightScatteringPostProcess}),f.d(y,"VRDistortionCorrectionPostProcess",function(){return _.VRDistortionCorrectionPostProcess}),f.d(y,"VRMultiviewToSingleviewPostProcess",function(){return _.VRMultiviewToSingleviewPostProcess}),f.d(y,"ScreenSpaceReflectionPostProcess",function(){return _.ScreenSpaceReflectionPostProcess}),f.d(y,"ScreenSpaceCurvaturePostProcess",function(){return _.ScreenSpaceCurvaturePostProcess}),f.d(y,"ReflectionProbe",function(){return _.ReflectionProbe}),f.d(y,"BoundingBoxRenderer",function(){return _.BoundingBoxRenderer}),f.d(y,"DepthRenderer",function(){return _.DepthRenderer}),f.d(y,"DepthRendererSceneComponent",function(){return _.DepthRendererSceneComponent}),f.d(y,"EdgesRenderer",function(){return _.EdgesRenderer}),f.d(y,"LineEdgesRenderer",function(){return _.LineEdgesRenderer}),f.d(y,"GeometryBufferRenderer",function(){return _.GeometryBufferRenderer}),f.d(y,"GeometryBufferRendererSceneComponent",function(){return _.GeometryBufferRendererSceneComponent}),f.d(y,"PrePassRenderer",function(){return _.PrePassRenderer}),f.d(y,"PrePassRendererSceneComponent",function(){return _.PrePassRendererSceneComponent}),f.d(y,"SubSurfaceSceneComponent",function(){return _.SubSurfaceSceneComponent}),f.d(y,"OutlineRenderer",function(){return _.OutlineRenderer}),f.d(y,"RenderingGroup",function(){return _.RenderingGroup}),f.d(y,"RenderingGroupInfo",function(){return _.RenderingGroupInfo}),f.d(y,"RenderingManager",function(){return _.RenderingManager}),f.d(y,"UtilityLayerRenderer",function(){return _.UtilityLayerRenderer}),f.d(y,"Scene",function(){return _.Scene}),f.d(y,"SceneComponentConstants",function(){return _.SceneComponentConstants}),f.d(y,"Stage",function(){return _.Stage}),f.d(y,"Sprite",function(){return _.Sprite}),f.d(y,"SpriteManager",function(){return _.SpriteManager}),f.d(y,"SpriteMap",function(){return _.SpriteMap}),f.d(y,"SpritePackedManager",function(){return _.SpritePackedManager}),f.d(y,"SpriteSceneComponent",function(){return _.SpriteSceneComponent}),f.d(y,"AlphaState",function(){return _.AlphaState}),f.d(y,"DepthCullingState",function(){return _.DepthCullingState}),f.d(y,"StencilState",function(){return _.StencilState}),f.d(y,"AndOrNotEvaluator",function(){return _.AndOrNotEvaluator}),f.d(y,"AssetTaskState",function(){return _.AssetTaskState}),f.d(y,"AbstractAssetTask",function(){return _.AbstractAssetTask}),f.d(y,"AssetsProgressEvent",function(){return _.AssetsProgressEvent}),f.d(y,"ContainerAssetTask",function(){return _.ContainerAssetTask}),f.d(y,"MeshAssetTask",function(){return _.MeshAssetTask}),f.d(y,"TextFileAssetTask",function(){return _.TextFileAssetTask}),f.d(y,"BinaryFileAssetTask",function(){return _.BinaryFileAssetTask}),f.d(y,"ImageAssetTask",function(){return _.ImageAssetTask}),f.d(y,"TextureAssetTask",function(){return _.TextureAssetTask}),f.d(y,"CubeTextureAssetTask",function(){return _.CubeTextureAssetTask}),f.d(y,"HDRCubeTextureAssetTask",function(){return _.HDRCubeTextureAssetTask}),f.d(y,"EquiRectangularCubeTextureAssetTask",function(){return _.EquiRectangularCubeTextureAssetTask}),f.d(y,"AssetsManager",function(){return _.AssetsManager}),f.d(y,"BasisTranscodeConfiguration",function(){return _.BasisTranscodeConfiguration}),f.d(y,"BasisTools",function(){return _.BasisTools}),f.d(y,"DDSTools",function(){return _.DDSTools}),f.d(y,"expandToProperty",function(){return _.expandToProperty}),f.d(y,"serialize",function(){return _.serialize}),f.d(y,"serializeAsTexture",function(){return _.serializeAsTexture}),f.d(y,"serializeAsColor3",function(){return _.serializeAsColor3}),f.d(y,"serializeAsFresnelParameters",function(){return _.serializeAsFresnelParameters}),f.d(y,"serializeAsVector2",function(){return _.serializeAsVector2}),f.d(y,"serializeAsVector3",function(){return _.serializeAsVector3}),f.d(y,"serializeAsMeshReference",function(){return _.serializeAsMeshReference}),f.d(y,"serializeAsColorCurves",function(){return _.serializeAsColorCurves}),f.d(y,"serializeAsColor4",function(){return _.serializeAsColor4}),f.d(y,"serializeAsImageProcessingConfiguration",function(){return _.serializeAsImageProcessingConfiguration}),f.d(y,"serializeAsQuaternion",function(){return _.serializeAsQuaternion}),f.d(y,"serializeAsMatrix",function(){return _.serializeAsMatrix}),f.d(y,"serializeAsCameraReference",function(){return _.serializeAsCameraReference}),f.d(y,"SerializationHelper",function(){return _.SerializationHelper}),f.d(y,"Deferred",function(){return _.Deferred}),f.d(y,"EnvironmentTextureTools",function(){return _.EnvironmentTextureTools}),f.d(y,"MeshExploder",function(){return _.MeshExploder}),f.d(y,"FilesInput",function(){return _.FilesInput}),f.d(y,"CubeMapToSphericalPolynomialTools",function(){return _.CubeMapToSphericalPolynomialTools}),f.d(y,"HDRTools",function(){return _.HDRTools}),f.d(y,"PanoramaToCubeMapTools",function(){return _.PanoramaToCubeMapTools}),f.d(y,"KhronosTextureContainer",function(){return _.KhronosTextureContainer}),f.d(y,"EventState",function(){return _.EventState}),f.d(y,"Observer",function(){return _.Observer}),f.d(y,"MultiObserver",function(){return _.MultiObserver}),f.d(y,"Observable",function(){return _.Observable}),f.d(y,"PerformanceMonitor",function(){return _.PerformanceMonitor}),f.d(y,"RollingAverage",function(){return _.RollingAverage}),f.d(y,"PromisePolyfill",function(){return _.PromisePolyfill}),f.d(y,"SceneOptimization",function(){return _.SceneOptimization}),f.d(y,"TextureOptimization",function(){return _.TextureOptimization}),f.d(y,"HardwareScalingOptimization",function(){return _.HardwareScalingOptimization}),f.d(y,"ShadowsOptimization",function(){return _.ShadowsOptimization}),f.d(y,"PostProcessesOptimization",function(){return _.PostProcessesOptimization}),f.d(y,"LensFlaresOptimization",function(){return _.LensFlaresOptimization}),f.d(y,"CustomOptimization",function(){return _.CustomOptimization}),f.d(y,"ParticlesOptimization",function(){return _.ParticlesOptimization}),f.d(y,"RenderTargetsOptimization",function(){return _.RenderTargetsOptimization}),f.d(y,"MergeMeshesOptimization",function(){return _.MergeMeshesOptimization}),f.d(y,"SceneOptimizerOptions",function(){return _.SceneOptimizerOptions}),f.d(y,"SceneOptimizer",function(){return _.SceneOptimizer}),f.d(y,"SceneSerializer",function(){return _.SceneSerializer}),f.d(y,"SmartArray",function(){return _.SmartArray}),f.d(y,"SmartArrayNoDuplicate",function(){return _.SmartArrayNoDuplicate}),f.d(y,"StringDictionary",function(){return _.StringDictionary}),f.d(y,"Tags",function(){return _.Tags}),f.d(y,"TextureTools",function(){return _.TextureTools}),f.d(y,"TGATools",function(){return _.TGATools}),f.d(y,"Tools",function(){return _.Tools}),f.d(y,"className",function(){return _.className}),f.d(y,"AsyncLoop",function(){return _.AsyncLoop}),f.d(y,"VideoRecorder",function(){return _.VideoRecorder}),f.d(y,"JoystickAxis",function(){return _.JoystickAxis}),f.d(y,"VirtualJoystick",function(){return _.VirtualJoystick}),f.d(y,"WorkerPool",function(){return _.WorkerPool}),f.d(y,"Logger",function(){return _.Logger}),f.d(y,"_TypeStore",function(){return _._TypeStore}),f.d(y,"FilesInputStore",function(){return _.FilesInputStore}),f.d(y,"DeepCopier",function(){return _.DeepCopier}),f.d(y,"PivotTools",function(){return _.PivotTools}),f.d(y,"PrecisionDate",function(){return _.PrecisionDate}),f.d(y,"ScreenshotTools",function(){return _.ScreenshotTools}),f.d(y,"WebRequest",function(){return _.WebRequest}),f.d(y,"InspectableType",function(){return _.InspectableType}),f.d(y,"BRDFTextureTools",function(){return _.BRDFTextureTools}),f.d(y,"RGBDTextureTools",function(){return _.RGBDTextureTools}),f.d(y,"ColorGradient",function(){return _.ColorGradient}),f.d(y,"Color3Gradient",function(){return _.Color3Gradient}),f.d(y,"FactorGradient",function(){return _.FactorGradient}),f.d(y,"GradientHelper",function(){return _.GradientHelper}),f.d(y,"PerfCounter",function(){return _.PerfCounter}),f.d(y,"RetryStrategy",function(){return _.RetryStrategy}),f.d(y,"CanvasGenerator",function(){return _.CanvasGenerator}),f.d(y,"LoadFileError",function(){return _.LoadFileError}),f.d(y,"RequestFileError",function(){return _.RequestFileError}),f.d(y,"ReadFileError",function(){return _.ReadFileError}),f.d(y,"FileTools",function(){return _.FileTools}),f.d(y,"StringTools",function(){return _.StringTools}),f.d(y,"DataReader",function(){return _.DataReader}),f.d(y,"MinMaxReducer",function(){return _.MinMaxReducer}),f.d(y,"DepthReducer",function(){return _.DepthReducer}),f.d(y,"DataStorage",function(){return _.DataStorage}),f.d(y,"SceneRecorder",function(){return _.SceneRecorder}),f.d(y,"KhronosTextureContainer2",function(){return _.KhronosTextureContainer2}),f.d(y,"Trajectory",function(){return _.Trajectory}),f.d(y,"TrajectoryClassifier",function(){return _.TrajectoryClassifier}),f.d(y,"TimerState",function(){return _.TimerState}),f.d(y,"setAndStartTimer",function(){return _.setAndStartTimer}),f.d(y,"AdvancedTimer",function(){return _.AdvancedTimer}),f.d(y,"CopyTools",function(){return _.CopyTools}),f.d(y,"WebXRCamera",function(){return _.WebXRCamera}),f.d(y,"WebXREnterExitUIButton",function(){return _.WebXREnterExitUIButton}),f.d(y,"WebXREnterExitUIOptions",function(){return _.WebXREnterExitUIOptions}),f.d(y,"WebXREnterExitUI",function(){return _.WebXREnterExitUI}),f.d(y,"WebXRExperienceHelper",function(){return _.WebXRExperienceHelper}),f.d(y,"WebXRInput",function(){return _.WebXRInput}),f.d(y,"WebXRInputSource",function(){return _.WebXRInputSource}),f.d(y,"WebXRManagedOutputCanvasOptions",function(){return _.WebXRManagedOutputCanvasOptions}),f.d(y,"WebXRManagedOutputCanvas",function(){return _.WebXRManagedOutputCanvas}),f.d(y,"WebXRState",function(){return _.WebXRState}),f.d(y,"WebXRTrackingState",function(){return _.WebXRTrackingState}),f.d(y,"WebXRSessionManager",function(){return _.WebXRSessionManager}),f.d(y,"WebXRDefaultExperienceOptions",function(){return _.WebXRDefaultExperienceOptions}),f.d(y,"WebXRDefaultExperience",function(){return _.WebXRDefaultExperience}),f.d(y,"WebXRFeatureName",function(){return _.WebXRFeatureName}),f.d(y,"WebXRFeaturesManager",function(){return _.WebXRFeaturesManager}),f.d(y,"WebXRAbstractFeature",function(){return _.WebXRAbstractFeature}),f.d(y,"WebXRHitTestLegacy",function(){return _.WebXRHitTestLegacy}),f.d(y,"WebXRAnchorSystem",function(){return _.WebXRAnchorSystem}),f.d(y,"WebXRPlaneDetector",function(){return _.WebXRPlaneDetector}),f.d(y,"WebXRBackgroundRemover",function(){return _.WebXRBackgroundRemover}),f.d(y,"WebXRMotionControllerTeleportation",function(){return _.WebXRMotionControllerTeleportation}),f.d(y,"WebXRControllerPointerSelection",function(){return _.WebXRControllerPointerSelection}),f.d(y,"IWebXRControllerPhysicsOptions",function(){return _.IWebXRControllerPhysicsOptions}),f.d(y,"WebXRControllerPhysics",function(){return _.WebXRControllerPhysics}),f.d(y,"WebXRHitTest",function(){return _.WebXRHitTest}),f.d(y,"WebXRFeaturePointSystem",function(){return _.WebXRFeaturePointSystem}),f.d(y,"WebXRHand",function(){return _.WebXRHand}),f.d(y,"WebXRHandTracking",function(){return _.WebXRHandTracking}),f.d(y,"WebXRAbstractMotionController",function(){return _.WebXRAbstractMotionController}),f.d(y,"WebXRControllerComponent",function(){return _.WebXRControllerComponent}),f.d(y,"WebXRGenericTriggerMotionController",function(){return _.WebXRGenericTriggerMotionController}),f.d(y,"WebXRMicrosoftMixedRealityController",function(){return _.WebXRMicrosoftMixedRealityController}),f.d(y,"WebXRMotionControllerManager",function(){return _.WebXRMotionControllerManager}),f.d(y,"WebXROculusTouchMotionController",function(){return _.WebXROculusTouchMotionController}),f.d(y,"WebXRHTCViveMotionController",function(){return _.WebXRHTCViveMotionController}),f.d(y,"WebXRProfiledMotionController",function(){return _.WebXRProfiledMotionController});var u=U!==void 0?U: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 x in C)M.Debug[x]=C[x],R.push(x);for(var x in _)M[x]=_[x]}var m={AxesViewer:C.AxesViewer,BoneAxesViewer:C.BoneAxesViewer,PhysicsViewer:C.PhysicsViewer,SkeletonViewer:C.SkeletonViewer}}.call(this,f(159))}])})})(Hn);var dl={exports:{}};(function(ht,Ke){(function(Me,y){ht.exports=y(Hn.exports)})(typeof self<"u"?self:typeof Zr<"u"?Zr:Zr,function(Me){return function(y){var f={};function U(_){if(f[_])return f[_].exports;var C=f[_]={i:_,l:!1,exports:{}};return y[_].call(C.exports,C,C.exports,U),C.l=!0,C.exports}return U.m=y,U.c=f,U.d=function(_,C,u){U.o(_,C)||Object.defineProperty(_,C,{enumerable:!0,get:u})},U.r=function(_){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(_,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(_,"__esModule",{value:!0})},U.t=function(_,C){if(1&C&&(_=U(_)),8&C||4&C&&typeof _=="object"&&_&&_.__esModule)return _;var u=Object.create(null);if(U.r(u),Object.defineProperty(u,"default",{enumerable:!0,value:_}),2&C&&typeof _!="string")for(var M in _)U.d(u,M,function(R){return _[R]}.bind(null,M));return u},U.n=function(_){var C=_&&_.__esModule?function(){return _.default}:function(){return _};return U.d(C,"a",C),C},U.o=function(_,C){return Object.prototype.hasOwnProperty.call(_,C)},U.p="",U(U.s=20)}([function(y,f){y.exports=Me},function(y,f,U){U.d(f,"a",function(){return u}),U.d(f,"b",function(){return M});var _=U(0),C=U(2),u=function(){function R(){}return R.Get=function(x,m,c){if(!m||c==null||!m[c])throw new Error(x+": Failed to find index ("+c+")");return m[c]},R.Assign=function(x){if(x)for(var m=0;m "+C.GLTFLoaderState[C.GLTFLoaderState.READY],A=C.GLTFLoaderState[C.GLTFLoaderState.LOADING]+" => "+C.GLTFLoaderState[C.GLTFLoaderState.COMPLETE];c._parent._startPerformanceCounter(T),c._parent._startPerformanceCounter(A),c._setState(C.GLTFLoaderState.LOADING),c._extensionsOnLoading();var S=new Array,g=c._babylonScene.blockMaterialDirtyMechanism;if(c._babylonScene.blockMaterialDirtyMechanism=!0,x)S.push(c.loadSceneAsync("/nodes",{nodes:x,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;hx.bin.byteLength)&&_.Logger.Warn("Binary buffer length ("+c.byteLength+") from JSON does not match chunk length ("+x.bin.byteLength+")"),this._bin=x.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 x={},m=0,c=this._gltf.nodes;m=2)throw new Error(x+"/texCoord: Invalid value ("+m.texCoord+")");var S=u.Get(x+"/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,x),T._parent.onTextureLoadedObservable.notifyObservers(l),c(l)});return this.logClose(),g},R.prototype._loadTextureAsync=function(x,m,c){c===void 0&&(c=function(){});var T=this._extensionsLoadTextureAsync(x,m,c);if(T)return T;this.logOpen(x+" "+(m.name||""));var A=m.sampler==null?R.DefaultSampler:u.Get(x+"/sampler",this._gltf.samplers,m.sampler),S=u.Get(x+"/source",this._gltf.images,m.source),g=this._createTextureAsync(x,A,S,c);return this.logClose(),g},R.prototype._createTextureAsync=function(x,m,c,T,A){var S=this;T===void 0&&(T=function(){});var g=this._loadSampler("/samplers/"+m.index,m),l=new Array,h=new _.Deferred;this._babylonScene._blockEntityCollection=this._forAssetContainer;var v=new _.Texture(null,this._babylonScene,g.noMipMaps,!1,g.samplingMode,function(){S._disposed||h.resolve()},function(E,D){S._disposed||h.reject(new Error(x+": "+(D&&D.message?D.message:E||"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(E){var D=c.uri||S._fileName+"#image"+c.index,w="data:"+S._uniqueRootUrl+D;v.updateURL(w,E)})),v.wrapU=g.wrapU,v.wrapV=g.wrapV,T(v),Promise.all(l).then(function(){return v})},R.prototype._loadSampler=function(x,m){return m._data||(m._data={noMipMaps:m.minFilter===9728||m.minFilter===9729,samplingMode:R._GetTextureSamplingMode(x,m),wrapU:R._GetTextureWrapMode(x+"/wrapS",m.wrapS),wrapV:R._GetTextureWrapMode(x+"/wrapT",m.wrapT)}),m._data},R.prototype.loadImageAsync=function(x,m){if(!m._data){if(this.logOpen(x+" "+(m.name||"")),m.uri)m._data=this.loadUriAsync(x+"/uri",m,m.uri);else{var c=u.Get(x+"/bufferView",this._gltf.bufferViews,m.bufferView);m._data=this.loadBufferViewAsync("/bufferViews/"+c.index,c)}this.logClose()}return m._data},R.prototype.loadUriAsync=function(x,m,c){var T=this,A=this._extensionsLoadUriAsync(x,m,c);if(A)return A;if(!R._ValidateUri(c))throw new Error(x+": '"+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){T._parent._loadFile(g,T._babylonScene,function(v){T._disposed||(T.log("Loaded "+c+" ("+v.byteLength+" bytes)"),l(new Uint8Array(v)))},!0,function(v){h(new _.LoadFileError(x+": Failed to load '"+c+"'"+(v?": "+v.status+" "+v.statusText:""),v))})})})},R.AddPointerMetadata=function(x,m){var c=x.metadata=x.metadata||{},T=c.gltf=c.gltf||{};(T.pointers=T.pointers||[]).push(m)},R._GetTextureWrapMode=function(x,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(x+": Invalid value ("+m+")"),_.Texture.WRAP_ADDRESSMODE}},R._GetTextureSamplingMode=function(x,m){var c=m.magFilter==null?9729:m.magFilter,T=m.minFilter==null?9987:m.minFilter;if(c===9729)switch(T){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(x+"/minFilter: Invalid value ("+T+")"),_.Texture.LINEAR_LINEAR_MIPLINEAR}else switch(c!==9728&&_.Logger.Warn(x+"/magFilter: Invalid value ("+c+")"),T){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(x+"/minFilter: Invalid value ("+T+")"),_.Texture.NEAREST_NEAREST_MIPNEAREST}},R._GetTypedArrayConstructor=function(x,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(x+": Invalid component type "+m)}},R._GetTypedArray=function(x,m,c,T,A){var S=c.buffer;T=c.byteOffset+(T||0);var g=R._GetTypedArrayConstructor(x+"/componentType",m);try{return new g(S,T,A)}catch(l){throw new Error(x+": "+l)}},R._GetNumComponents=function(x,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(x+": Invalid type ("+m+")")},R._ValidateUri=function(x){return _.Tools.IsBase64(x)||x.indexOf("..")===-1},R._GetDrawMode=function(x,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(x+": Invalid mesh primitive mode ("+m+")")},R.prototype._compileMaterialsAsync=function(){var x=this;this._parent._startPerformanceCounter("Compile materials");var m=new Array;if(this._gltf.materials)for(var c=0,T=this._gltf.materials;c-1&&h.materials.splice(N,1),(N=v.indexOf(w))>-1&&v.splice(N,1)})});var E=[];l.onTextureLoadedObservable.add(function(w){E.push(w),w.onDisposeObservable.addOnce(function(){var N=h.textures.indexOf(w);N>-1&&h.textures.splice(N,1),(N=E.indexOf(w))>-1&&E.splice(N,1)})});var D=[];return l.onCameraLoadedObservable.add(function(w){D.push(w)}),l._loader.importMeshAsync(null,c,!0,T,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,v),Array.prototype.push.apply(h.textures,E),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,T){if(M.StringTools.StartsWith(T,"base64,"+m.magicBase64Encoded)||M.StringTools.StartsWith(T,"application/octet-stream;base64,"+m.magicBase64Encoded)||M.StringTools.StartsWith(T,"model/gltf-binary;base64,"+m.magicBase64Encoded)){var A=M.Tools.DecodeBase64(T);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,T),Promise.resolve({json:this._parseJson(T)})},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(T,A){c.onCompleteObservable.addOnce(function(){T()}),c.onErrorObservable.addOnce(function(S){A(S)})})},m.prototype._loadFile=function(c,T,A,S,g){var l=this,h=T._loadFile(c,A,function(v){l._onProgress(v,h)},void 0,S,g);return h.onCompleteObservable.add(function(v){l._requests.splice(l._requests.indexOf(v),1)}),this._requests.push(h),h},m.prototype._requestFile=function(c,T,A,S,g,l){var h=this,v=T._requestFile(c,A,function(E){h._onProgress(E,v)},void 0,S,g,l);return v.onCompleteObservable.add(function(E){h._requests.splice(h._requests.indexOf(E),1)}),this._requests.push(v),v},m.prototype._onProgress=function(c,T){if(this._progressCallback){T._lengthComputable=c.lengthComputable,T._loaded=c.loaded,T._total=c.total;for(var A=!0,S=0,g=0,l=0,h=this._requests;l0)throw new Error("Incompatible minimum version: "+T.minVersion)}var g={1:m._CreateGLTF1Loader,2:m._CreateGLTF2Loader}[A.major];if(!g)throw new Error("Unsupported version: "+T.version);return g(this)},m.prototype._parseJson=function(c){this._startPerformanceCounter("Parse JSON"),this._log("JSON length: "+c.length);var T=JSON.parse(c);return this._endPerformanceCounter("Parse JSON"),T},m.prototype._unpackBinaryAsync=function(c){var T=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();T.loggingEnabled&&T._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=T._unpackBinaryV1Async(c,l);break;case 2:g=T._unpackBinaryV2Async(c,l);break;default:throw new Error("Unsupported version: "+S)}return T._endPerformanceCounter("Unpack Binary"),g})},m.prototype._unpackBinaryV1Async=function(c,T){var A=c.readUint32(),S=c.readUint32();if(S!==0)throw new Error("Unexpected content format: "+S);var g=T-c.byteOffset,l={json:this._parseJson(c.readString(A)),bin:null};if(g!==0){var h=c.byteOffset;l.bin={readAsync:function(v,E){return c.buffer.readAsync(h+v,E)},byteLength:g}}return Promise.resolve(l)},m.prototype._unpackBinaryV2Async=function(c,T){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===T?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},v=function(){var E=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:E},c.skipBytes(E);break;default:c.skipBytes(E)}return c.byteOffset!==T?c.loadAsync(8).then(v):Promise.resolve(h)};return v()})},m._parseVersion=function(c){if(c==="1.0"||c==="1.0.1")return{major:1,minor:0};var T=(c+"").match(/^(\d+)\.(\d+)/);return T?{major:parseInt(T[1]),minor:parseInt(T[2])}:null},m._compareVersion=function(c,T){return c.major>T.major?1:c.majorT.minor?1:c.minor=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=0;Q--)if(G.push(C.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();G0){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}();C.b.RegisterExtension("ExtrasAsMetadata",function(ae){return new pe(ae)})},function(y,f,U){U.r(f),U.d(f,"GLTFBinaryExtension",function(){return H}),U.d(f,"GLTFLoaderBase",function(){return re}),U.d(f,"GLTFLoader",function(){return Y}),U.d(f,"GLTFLoaderExtension",function(){return k}),U.d(f,"EComponentType",function(){return _}),U.d(f,"EShaderType",function(){return C}),U.d(f,"EParameterType",function(){return u}),U.d(f,"ETextureWrapMode",function(){return M}),U.d(f,"ETextureFilterType",function(){return R}),U.d(f,"ETextureFormat",function(){return x}),U.d(f,"ECullingType",function(){return m}),U.d(f,"EBlendingFunction",function(){return c}),U.d(f,"GLTFUtils",function(){return g}),U.d(f,"GLTFMaterialsCommonExtension",function(){return Z});var _,C,u,M,R,x,m,c,T=U(4);(function(W){W[W.BYTE=5120]="BYTE",W[W.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",W[W.SHORT=5122]="SHORT",W[W.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",W[W.FLOAT=5126]="FLOAT"})(_||(_={})),function(W){W[W.FRAGMENT=35632]="FRAGMENT",W[W.VERTEX=35633]="VERTEX"}(C||(C={})),function(W){W[W.BYTE=5120]="BYTE",W[W.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",W[W.SHORT=5122]="SHORT",W[W.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",W[W.INT=5124]="INT",W[W.UNSIGNED_INT=5125]="UNSIGNED_INT",W[W.FLOAT=5126]="FLOAT",W[W.FLOAT_VEC2=35664]="FLOAT_VEC2",W[W.FLOAT_VEC3=35665]="FLOAT_VEC3",W[W.FLOAT_VEC4=35666]="FLOAT_VEC4",W[W.INT_VEC2=35667]="INT_VEC2",W[W.INT_VEC3=35668]="INT_VEC3",W[W.INT_VEC4=35669]="INT_VEC4",W[W.BOOL=35670]="BOOL",W[W.BOOL_VEC2=35671]="BOOL_VEC2",W[W.BOOL_VEC3=35672]="BOOL_VEC3",W[W.BOOL_VEC4=35673]="BOOL_VEC4",W[W.FLOAT_MAT2=35674]="FLOAT_MAT2",W[W.FLOAT_MAT3=35675]="FLOAT_MAT3",W[W.FLOAT_MAT4=35676]="FLOAT_MAT4",W[W.SAMPLER_2D=35678]="SAMPLER_2D"}(u||(u={})),function(W){W[W.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",W[W.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",W[W.REPEAT=10497]="REPEAT"}(M||(M={})),function(W){W[W.NEAREST=9728]="NEAREST",W[W.LINEAR=9728]="LINEAR",W[W.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",W[W.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",W[W.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",W[W.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR"}(R||(R={})),function(W){W[W.ALPHA=6406]="ALPHA",W[W.RGB=6407]="RGB",W[W.RGBA=6408]="RGBA",W[W.LUMINANCE=6409]="LUMINANCE",W[W.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA"}(x||(x={})),function(W){W[W.FRONT=1028]="FRONT",W[W.BACK=1029]="BACK",W[W.FRONT_AND_BACK=1032]="FRONT_AND_BACK"}(m||(m={})),function(W){W[W.ZERO=0]="ZERO",W[W.ONE=1]="ONE",W[W.SRC_COLOR=768]="SRC_COLOR",W[W.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",W[W.DST_COLOR=774]="DST_COLOR",W[W.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",W[W.SRC_ALPHA=770]="SRC_ALPHA",W[W.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",W[W.DST_ALPHA=772]="DST_ALPHA",W[W.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",W[W.CONSTANT_COLOR=32769]="CONSTANT_COLOR",W[W.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",W[W.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",W[W.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",W[W.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE"}(c||(c={}));var A,S=U(0),g=function(){function W(){}return W.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.setMatrix2x2(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)}},W.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}},W.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}},W.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}},W.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}},W.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 Pe=be.buffer;switch(ge+=be.byteOffset,_e){case _.BYTE:return new Int8Array(Pe,ge,me);case _.UNSIGNED_BYTE:return new Uint8Array(Pe,ge,me);case _.SHORT:return new Int16Array(Pe,ge,me);case _.UNSIGNED_SHORT:return new Uint16Array(Pe,ge,me);default:return new Float32Array(Pe,ge,me)}},W.GetBufferFromAccessor=function(q,he){var ge=q.bufferViews[he.bufferView],me=he.count*W.GetByteStrideFromType(he);return W.GetBufferFromBufferView(q,ge,he.byteOffset,me,he.componentType)},W.DecodeBufferToText=function(q){for(var he="",ge=q.byteLength,me=0;me=this._maxPos},W}(),v=["MODEL","VIEW","PROJECTION","MODELVIEW","MODELVIEWPROJECTION","JOINTMATRIX"],E=["world","view","projection","worldView","worldViewProjection","mBones"],D=["translation","rotation","scale"],w=["position","rotationQuaternion","scaling"],N=function(W,q,he){for(var ge in W){var me=W[ge];he[q][ge]=me}},I=function(W){if(W)for(var q=0;q0&&(We=ne(_e,me))&&be.indexOf(We)===-1&&be.push(We),new S.Bone(ye.jointName||"",ge,We,$e).id=me}}else S.Tools.Warn("Joint named "+q.jointNames[Pe]+" does not exist")}var ct=ge.bones;for(ge.bones=[],Pe=0;Pe1?(_e=new S.MultiMaterial("multimat"+ge,W.scene)).subMaterials=be:_e=new S.StandardMaterial("multimat"+ge,W.scene),be.length===1&&(_e=be[0]),me.material||(me.material=_e),new S.Geometry(ge,W.scene,Pe,!1,me),me.computeWorldMatrix(!0),W.scene._blockEntityCollection=!1,me.subMeshes=[];var Zt=0;for(je=0;je0&&W.importMeshesNames.indexOf(q.name||"")===-1)return null;if(q.skin){if(q.meshes){var _e=W.skins[q.skin];(be=ae(W,q,q.meshes,he,q.babylonNode)).skeleton=W.scene.getLastSkeletonByID(q.skin),be.skeleton===null&&(be.skeleton=pe(W,_e,0,_e.babylonSkeleton,q.skin),_e.babylonSkeleton||(_e.babylonSkeleton=be.skeleton)),me=be}}else if(q.meshes){var be;me=be=ae(W,q,q.mesh?[q.mesh]:q.meshes,he,q.babylonNode)}else if(!q.light||q.babylonNode||W.importOnlyMeshes){if(q.camera&&!q.babylonNode&&!W.importOnlyMeshes){var Pe=W.cameras[q.camera];if(Pe){if(W.scene._blockEntityCollection=W.forAssetContainer,Pe.type==="orthographic"){var ye=new S.FreeCamera(q.camera,S.Vector3.Zero(),W.scene,!1);ye.name=q.name||"",ye.mode=S.Camera.ORTHOGRAPHIC_CAMERA,ye.attachControl(),me=ye}else if(Pe.type==="perspective"){var Be=Pe[Pe.type],ke=new S.FreeCamera(q.camera,S.Vector3.Zero(),W.scene,!1);ke.name=q.name||"",ke.attachControl(),Be.aspectRatio||(Be.aspectRatio=W.scene.getEngine().getRenderWidth()/W.scene.getEngine().getRenderHeight()),Be.znear&&Be.zfar&&(ke.maxZ=Be.zfar,ke.minZ=Be.znear),me=ke}W.scene._blockEntityCollection=!1}}}else{var We=W.lights[q.light];if(We){if(We.type==="ambient"){var je=We[We.type],He=new S.HemisphericLight(q.light,S.Vector3.Zero(),W.scene);He.name=q.name||"",je.color&&(He.diffuse=S.Color3.FromArray(je.color)),me=He}else if(We.type==="directional"){var qe=We[We.type],Ge=new S.DirectionalLight(q.light,S.Vector3.Zero(),W.scene);Ge.name=q.name||"",qe.color&&(Ge.diffuse=S.Color3.FromArray(qe.color)),me=Ge}else if(We.type==="point"){var nt=We[We.type],$e=new S.PointLight(q.light,S.Vector3.Zero(),W.scene);$e.name=q.name||"",nt.color&&($e.diffuse=S.Color3.FromArray(nt.color)),me=$e}else if(We.type==="spot"){var ct=We[We.type],st=new S.SpotLight(q.light,S.Vector3.Zero(),S.Vector3.Zero(),0,0,W.scene);st.name=q.name||"",ct.color&&(st.diffuse=S.Color3.FromArray(ct.color)),ct.fallOfAngle&&(st.angle=ct.fallOfAngle),ct.fallOffExponent&&(st.exponent=ct.fallOffExponent),me=st}}}if(!q.jointName){if(q.babylonNode)return q.babylonNode;if(me===null){W.scene._blockEntityCollection=W.forAssetContainer;var mt=new S.Mesh(q.name||"",W.scene);W.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(W,q,he,ge){ge===void 0&&(ge=!1);var me=W.nodes[q],_e=null;if(ge=!(W.importOnlyMeshes&&!ge&&W.importMeshesNames)||W.importMeshesNames.indexOf(me.name||"")!==-1||W.importMeshesNames.length===0,!me.jointName&&ge&&(_e=K(W,me,q))!==null&&(_e.id=q,_e.parent=he),me.children)for(var be=0;be=0?h.substring(0,v):h;E=E.toLowerCase();var D=v>=0?h.substring(v+1).trim():"";E==="newmtl"?(g&&this.materials.push(g),R._blockEntityCollection=c,g=new _.StandardMaterial(D,R),R._blockEntityCollection=!1):E==="kd"&&g?(T=D.split(S,3).map(parseFloat),g.diffuseColor=_.Color3.FromArray(T)):E==="ka"&&g?(T=D.split(S,3).map(parseFloat),g.ambientColor=_.Color3.FromArray(T)):E==="ks"&&g?(T=D.split(S,3).map(parseFloat),g.specularColor=_.Color3.FromArray(T)):E==="ke"&&g?(T=D.split(S,3).map(parseFloat),g.emissiveColor=_.Color3.FromArray(T)):E==="ns"&&g?g.specularPower=parseFloat(D):E==="d"&&g?g.alpha=parseFloat(D):E==="map_ka"&&g?g.ambientTexture=M._getTexture(m,D,R):E==="map_kd"&&g?g.diffuseTexture=M._getTexture(m,D,R):E==="map_ks"&&g?g.specularTexture=M._getTexture(m,D,R):E==="map_ns"||(E==="map_bump"&&g?g.bumpTexture=M._getTexture(m,D,R):E==="map_d"&&g&&(g.opacityTexture=M._getTexture(m,D,R)))}}g&&this.materials.push(g)}},M._getTexture=function(R,x,m){if(!x)return null;var c=R;if(R==="file:"){var T=x.lastIndexOf("\\");T===-1&&(T=x.lastIndexOf("/")),c+=T>-1?x.substr(T+1):x}else c+=x;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 C.INVERT_TEXTURE_Y},set:function(R){C.INVERT_TEXTURE_Y=R},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,x,m,c){var T=_.Tools.BaseUrl+x+R;_.Tools.LoadFile(T,m,void 0,void 0,!1,function(A,S){c(T,S)})},M.prototype.createPlugin=function(){return new M(M.currentMeshLoadOptions)},M.prototype.canDirectLoad=function(R){return!1},M.prototype.importMeshAsync=function(R,x,m,c,T,A){return this._parseSolid(R,x,m,c).then(function(S){return{meshes:S,particleSystems:[],skeletons:[],animationGroups:[],transformNodes:[],geometries:[],lights:[]}})},M.prototype.loadAsync=function(R,x,m,c,T){return this.importMeshAsync(null,R,x,m,c).then(function(){})},M.prototype.loadAssetContainerAsync=function(R,x,m,c,T){var A=this;return this._forAssetContainer=!0,this.importMeshAsync(null,R,x,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(v){g.textures.indexOf(v)==-1&&g.textures.push(v)}))}),A._forAssetContainer=!1,g}).catch(function(S){throw A._forAssetContainer=!1,S})},M.prototype._parseSolid=function(R,x,m,c){for(var T,A=this,S=[],g=[],l=[],h=[],v=[],E=[],D=[],w=[],N=[],I=[],V=[],X=0,j=!1,ne=[],te=[],de=[],pe=[],ae=[],ee="",K="",$=new C,L=1,G=!0,Q=new _.Color4(.5,.5,.5,1),oe=function(Ge,nt,$e,ct,st,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,[Ge,$e,nt]):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,[Ge,$e]))===-1?(E.push(D.length),D.push(ct),w.push(st),I.push(mt),St!==void 0&&N.push(St),V[Ge].normals.push($e),V[Ge].idx.push(X++),A._meshLoadOptions.OptimizeWithUV&&V[Ge].uv.push(nt)):E.push(wt)},re=function(){for(var Ge=0;Ge0&&(T=v[v.length-1],re(),E.reverse(),T.indices=E.slice(),T.positions=ne.slice(),T.normals=de.slice(),T.uvs=pe.slice(),A._meshLoadOptions.ImportVertexColors===!0&&(T.colors=te.slice()),E=[],ne=[],te=[],de=[],pe=[])},ge=m.split(` +`),me=0;me=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));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)W(_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 Pe={name:be.substring(2).trim(),indices:void 0,positions:void 0,normals:void 0,uvs:void 0,colors:void 0,materialName:""};he(),v.push(Pe),j=!0,G=!0,L=1}else this.usemtl.test(be)?(ee=be.substring(7).trim(),(!G||!j)&&(he(),Pe={name:"mesh_mm"+L.toString(),indices:void 0,positions:void 0,normals:void 0,uvs:void 0,colors:void 0,materialName:ee},L++,v.push(Pe),j=!0),j&&G&&(v[v.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&&(T=v[v.length-1],E.reverse(),re(),T.indices=E,T.positions=ne,T.normals=de,T.uvs=pe,this._meshLoadOptions.ImportVertexColors===!0&&(T.colors=te)),j||(E.reverse(),re(),v.push({name:_.Geometry.RandomId(),indices:E,positions:ne,colors:te,normals:de,uvs:pe,materialName:ee}));for(var ye=[],Be=new Array,ke=0;ke-1;)St.push(st),mt=st+1;if(st===-1&&St.length===0)$.materials[ct].dispose();else for(var wt=0;wt127)return!0;return!1},u.prototype._parseBinary=function(M,R){for(var x=new DataView(R),m=x.getUint32(80,!0),c=0,T=new Float32Array(3*m*3),A=new Float32Array(3*m*3),S=new Uint32Array(3*m),g=0,l=0;l-1||(x.GLTF2[c]=M[c])}}).call(this,U(5))},function(y,f,U){U.r(f),function(_){var C=U(10);U.d(f,"MTLFileLoader",function(){return C.MTLFileLoader}),U.d(f,"OBJFileLoader",function(){return C.OBJFileLoader});var u=_!==void 0?_:typeof window<"u"?window:void 0;if(u!==void 0)for(var M in C)u.BABYLON[M]=C[M]}.call(this,U(5))},function(y,f,U){U.r(f),function(_){var C=U(11);U.d(f,"STLFileLoader",function(){return C.STLFileLoader});var u=_!==void 0?_:typeof window<"u"?window:void 0;if(u!==void 0)for(var M in C)u.BABYLON[M]=C[M]}.call(this,U(5))},,,,function(y,f,U){U.r(f),U.d(f,"GLTFLoaderCoordinateSystemMode",function(){return _.c}),U.d(f,"GLTFLoaderAnimationStartMode",function(){return _.b}),U.d(f,"GLTFLoaderState",function(){return _.d}),U.d(f,"GLTFFileLoader",function(){return _.a}),U.d(f,"GLTFValidation",function(){return _.e}),U.d(f,"GLTF1",function(){return C.a}),U.d(f,"GLTF2",function(){return u.a}),U.d(f,"MTLFileLoader",function(){return M.MTLFileLoader}),U.d(f,"OBJFileLoader",function(){return M.OBJFileLoader}),U.d(f,"STLFileLoader",function(){return R.STLFileLoader}),U(2),U(3),U(8),U(9),U(10),U(11);var _=U(12),C=U(13),u=U(14),M=U(15),R=U(16)}])})})(dl);function Pf(ht){let Ke,Me,y,f,U,_,C,u,M,R;return f=new kv({props:{Icon:zv,label:"Download"}}),{c(){Ke=Qr("div"),Me=Qr("div"),y=Qr("a"),Wn(f.$$.fragment),u=Jr(),M=Qr("canvas"),bi(y,"href",U=ht[0].data),bi(y,"target",_=window.__is_colab__?"_blank":null),bi(y,"download",C=window.__is_colab__?null:ht[0].orig_name||ht[0].name),bi(Me,"class","download svelte-14ct53h"),bi(M,"class","svelte-14ct53h"),bi(Ke,"class","model3D svelte-14ct53h")},m(x,m){Di(x,Ke,m),qr(Ke,Me),qr(Me,y),Xn(f,y,null),qr(Ke,u),qr(Ke,M),ht[5](M),R=!0},p(x,m){(!R||m&1&&U!==(U=x[0].data))&&bi(y,"href",U),(!R||m&1&&C!==(C=window.__is_colab__?null:x[0].orig_name||x[0].name))&&bi(y,"download",C)},i(x){R||(un(f.$$.fragment,x),R=!0)},o(x){mn(f.$$.fragment,x),R=!1},d(x){x&&Li(Ke),Yn(f),ht[5](null)}}}function Wv(ht){let Ke,Me,y,f;Ke=new hl({props:{show_label:ht[2],Icon:za,label:ht[1]||"3D Model"}});let U=ht[0]&&Pf(ht);return{c(){Wn(Ke.$$.fragment),Me=Jr(),U&&U.c(),y=sl()},m(_,C){Xn(Ke,_,C),Di(_,Me,C),U&&U.m(_,C),Di(_,y,C),f=!0},p(_,[C]){const u={};C&4&&(u.show_label=_[2]),C&2&&(u.label=_[1]||"3D Model"),Ke.$set(u),_[0]?U?(U.p(_,C),C&1&&un(U,1)):(U=Pf(_),U.c(),un(U,1),U.m(y.parentNode,y)):U&&(cl(),mn(U,1,1,()=>{U=null}),ll())},i(_){f||(un(Ke.$$.fragment,_),un(U),f=!0)},o(_){mn(Ke.$$.fragment,_),mn(U),f=!1},d(_){Yn(Ke,_),_&&Li(Me),U&&U.d(_),_&&Li(y)}}}function Xv(ht,Ke,Me){let{value:y}=Ke,{clearColor:f=[0,0,0,0]}=Ke,{label:U=""}=Ke,{show_label:_}=Ke;dl.exports.OBJFileLoader.IMPORT_VERTEX_COLORS=!0;let C,u,M;xf(()=>{M=new Hn.exports.Engine(C,!0),window.addEventListener("resize",()=>{M?.resize()})}),Cf(()=>{u&&!u.isDisposed&&(u.dispose(),M?.stopRenderLoop(),M?.dispose(),M=null,M=new Hn.exports.Engine(C,!0),window.addEventListener("resize",()=>{M?.resize()})),R()});function R(){if(u=new Hn.exports.Scene(M),u.createDefaultCameraOrLight(),u.clearColor=new Hn.exports.Color4(...f),M?.runRenderLoop(()=>{u.render()}),!y)return;let m;if(y.is_file)m=y.data;else{let c=y.data,T=Hn.exports.Tools.DecodeBase64(c),A=new Blob([T]);m=URL.createObjectURL(A)}Hn.exports.SceneLoader.Append("",m,u,()=>{u.createDefaultCamera(!0,!0,!0)},void 0,void 0,"."+y.name.split(".")[1])}function x(m){ul[m?"unshift":"push"](()=>{C=m,Me(3,C)})}return ht.$$set=m=>{"value"in m&&Me(0,y=m.value),"clearColor"in m&&Me(4,f=m.clearColor),"label"in m&&Me(1,U=m.label),"show_label"in m&&Me(2,_=m.show_label)},[y,U,_,C,f,x]}class Yv extends rl{constructor(Ke){super(),ol(this,Ke,Xv,Wv,al,{value:0,clearColor:4,label:1,show_label:2})}}function Kv(ht){let Ke,Me,y,f,U;return Me=new Gv({props:{absolute:!0}}),Me.$on("clear",ht[6]),{c(){Ke=Qr("div"),Wn(Me.$$.fragment),y=Jr(),f=Qr("canvas"),bi(f,"class","svelte-wn75i6"),bi(Ke,"class","input-model svelte-wn75i6")},m(_,C){Di(_,Ke,C),Xn(Me,Ke,null),qr(Ke,y),qr(Ke,f),ht[10](f),U=!0},p:Rf,i(_){U||(un(Me.$$.fragment,_),U=!0)},o(_){mn(Me.$$.fragment,_),U=!1},d(_){_&&Li(Ke),Yn(Me),ht[10](null)}}}function Qv(ht){let Ke,Me,y;function f(_){ht[9](_)}let U={filetype:".obj, .gltf, .glb",$$slots:{default:[qv]},$$scope:{ctx:ht}};return ht[3]!==void 0&&(U.dragging=ht[3]),Ke=new jv({props:U}),ul.push(()=>Cv(Ke,"dragging",f)),Ke.$on("load",ht[5]),{c(){Wn(Ke.$$.fragment)},m(_,C){Xn(Ke,_,C),y=!0},p(_,C){const u={};C&2048&&(u.$$scope={dirty:C,ctx:_}),!Me&&C&8&&(Me=!0,u.dragging=_[3],Rv(()=>Me=!1)),Ke.$set(u)},i(_){y||(un(Ke.$$.fragment,_),y=!0)},o(_){mn(Ke.$$.fragment,_),y=!1},d(_){Yn(Ke,_)}}}function qv(ht){let Ke;const Me=ht[8].default,y=Ov(Me,ht,ht[11],null);return{c(){y&&y.c()},m(f,U){y&&y.m(f,U),Ke=!0},p(f,U){y&&y.p&&(!Ke||U&2048)&&Mv(y,Me,f,f[11],Ke?Dv(Me,f[11],U,null):Iv(f[11]),null)},i(f){Ke||(un(y,f),Ke=!0)},o(f){mn(y,f),Ke=!1},d(f){y&&y.d(f)}}}function Zv(ht){let Ke,Me,y,f,U,_;Ke=new hl({props:{show_label:ht[2],Icon:za,label:ht[1]||"3D Model"}});const C=[Qv,Kv],u=[];function M(R,x){return R[0]===null?0:1}return y=M(ht),f=u[y]=C[y](ht),{c(){Wn(Ke.$$.fragment),Me=Jr(),f.c(),U=sl()},m(R,x){Xn(Ke,R,x),Di(R,Me,x),u[y].m(R,x),Di(R,U,x),_=!0},p(R,[x]){const m={};x&4&&(m.show_label=R[2]),x&2&&(m.label=R[1]||"3D Model"),Ke.$set(m);let c=y;y=M(R),y===c?u[y].p(R,x):(cl(),mn(u[c],1,1,()=>{u[c]=null}),ll(),f=u[y],f?f.p(R,x):(f=u[y]=C[y](R),f.c()),un(f,1),f.m(U.parentNode,U))},i(R){_||(un(Ke.$$.fragment,R),un(f),_=!0)},o(R){mn(Ke.$$.fragment,R),mn(f),_=!1},d(R){Yn(Ke,R),R&&Li(Me),u[y].d(R),R&&Li(U)}}}function Jv(ht,Ke,Me){let{$$slots:y={},$$scope:f}=Ke,{value:U}=Ke,{clearColor:_=[0,0,0,0]}=Ke,{label:C=""}=Ke,{show_label:u}=Ke;xf(()=>{U!=null&&S()}),Cf(()=>{U!=null&&U.is_file&&S()});async function M({detail:h}){Me(0,U=h),await Sf(),x("change",U),S()}async function R(){T&&A&&(T.dispose(),A.dispose()),Me(0,U=null),await Sf(),x("clear")}const x=xv();let m=!1;dl.exports.OBJFileLoader.IMPORT_VERTEX_COLORS=!0;let c,T,A;function S(){if(T&&!T.isDisposed&&A&&(T.dispose(),A.dispose()),A=new Hn.exports.Engine(c,!0),T=new Hn.exports.Scene(A),T.createDefaultCameraOrLight(),T.clearColor=T.clearColor=new Hn.exports.Color4(..._),A.runRenderLoop(()=>{T.render()}),window.addEventListener("resize",()=>{A.resize()}),!U)return;let h;if(U.is_file)h=U.data;else{let v=U.data,E=Hn.exports.Tools.DecodeBase64(v),D=new Blob([E]);h=URL.createObjectURL(D)}Hn.exports.SceneLoader.Append(h,"",T,()=>{T.createDefaultCamera(!0,!0,!0)},void 0,void 0,"."+U.name.split(".")[1])}function g(h){m=h,Me(3,m)}function l(h){ul[h?"unshift":"push"](()=>{c=h,Me(4,c)})}return ht.$$set=h=>{"value"in h&&Me(0,U=h.value),"clearColor"in h&&Me(7,_=h.clearColor),"label"in h&&Me(1,C=h.label),"show_label"in h&&Me(2,u=h.show_label),"$$scope"in h&&Me(11,f=h.$$scope)},ht.$$.update=()=>{ht.$$.dirty&8&&x("drag",m)},[U,C,u,m,c,M,R,_,y,g,l,f]}class $v extends rl{constructor(Ke){super(),ol(this,Ke,Jv,Zv,al,{value:0,clearColor:7,label:1,show_label:2})}}function eb(ht){let Ke,Me,y,f;return Ke=new hl({props:{show_label:ht[8],Icon:za,label:ht[7]||"3D Model"}}),y=new Vv({props:{size:"large",unpadded_box:!0,$$slots:{default:[ib]},$$scope:{ctx:ht}}}),{c(){Wn(Ke.$$.fragment),Me=Jr(),Wn(y.$$.fragment)},m(U,_){Xn(Ke,U,_),Di(U,Me,_),Xn(y,U,_),f=!0},p(U,_){const C={};_&256&&(C.show_label=U[8]),_&128&&(C.label=U[7]||"3D Model"),Ke.$set(C);const u={};_&131072&&(u.$$scope={dirty:_,ctx:U}),y.$set(u)},i(U){f||(un(Ke.$$.fragment,U),un(y.$$.fragment,U),f=!0)},o(U){mn(Ke.$$.fragment,U),mn(y.$$.fragment,U),f=!1},d(U){Yn(Ke,U),U&&Li(Me),Yn(y,U)}}}function tb(ht){let Ke,Me;return Ke=new Yv({props:{value:ht[9],clearColor:ht[5],label:ht[7],show_label:ht[8]}}),{c(){Wn(Ke.$$.fragment)},m(y,f){Xn(Ke,y,f),Me=!0},p(y,f){const U={};f&512&&(U.value=y[9]),f&32&&(U.clearColor=y[5]),f&128&&(U.label=y[7]),f&256&&(U.show_label=y[8]),Ke.$set(U)},i(y){Me||(un(Ke.$$.fragment,y),Me=!0)},o(y){mn(Ke.$$.fragment,y),Me=!1},d(y){Yn(Ke,y)}}}function nb(ht){let Ke,Me;return Ke=new $v({props:{label:ht[7],show_label:ht[8],clearColor:ht[5],value:ht[9],$$slots:{default:[rb]},$$scope:{ctx:ht}}}),Ke.$on("change",ht[13]),Ke.$on("drag",ht[14]),Ke.$on("change",ht[15]),Ke.$on("clear",ht[16]),{c(){Wn(Ke.$$.fragment)},m(y,f){Xn(Ke,y,f),Me=!0},p(y,f){const U={};f&128&&(U.label=y[7]),f&256&&(U.show_label=y[8]),f&32&&(U.clearColor=y[5]),f&512&&(U.value=y[9]),f&131072&&(U.$$scope={dirty:f,ctx:y}),Ke.$set(U)},i(y){Me||(un(Ke.$$.fragment,y),Me=!0)},o(y){mn(Ke.$$.fragment,y),Me=!1},d(y){Yn(Ke,y)}}}function ib(ht){let Ke,Me;return Ke=new za({}),{c(){Wn(Ke.$$.fragment)},m(y,f){Xn(Ke,y,f),Me=!0},i(y){Me||(un(Ke.$$.fragment,y),Me=!0)},o(y){mn(Ke.$$.fragment,y),Me=!1},d(y){Yn(Ke,y)}}}function rb(ht){let Ke,Me;return Ke=new Hv({props:{type:"file"}}),{c(){Wn(Ke.$$.fragment)},m(y,f){Xn(Ke,y,f),Me=!0},p:Rf,i(y){Me||(un(Ke.$$.fragment,y),Me=!0)},o(y){mn(Ke.$$.fragment,y),Me=!1},d(y){Yn(Ke,y)}}}function ob(ht){let Ke,Me,y,f,U,_;const C=[ht[6]];let u={};for(let m=0;m{R[A]=null}),ll(),f=R[y],f?f.p(m,c):(f=R[y]=M[y](m),f.c()),un(f,1),f.m(U.parentNode,U))},i(m){_||(un(Ke.$$.fragment,m),un(f),_=!0)},o(m){mn(Ke.$$.fragment,m),mn(f),_=!1},d(m){Yn(Ke,m),m&&Li(Me),R[y].d(m),m&&Li(U)}}}function ab(ht){let Ke,Me;return Ke=new Uv({props:{visible:ht[3],variant:ht[0]===null?"dashed":"solid",border_mode:ht[10]?"focus":"base",padding:!1,elem_id:ht[1],elem_classes:ht[2],$$slots:{default:[ob]},$$scope:{ctx:ht}}}),{c(){Wn(Ke.$$.fragment)},m(y,f){Xn(Ke,y,f),Me=!0},p(y,[f]){const U={};f&8&&(U.visible=y[3]),f&1&&(U.variant=y[0]===null?"dashed":"solid"),f&1024&&(U.border_mode=y[10]?"focus":"base"),f&2&&(U.elem_id=y[1]),f&4&&(U.elem_classes=y[2]),f&133105&&(U.$$scope={dirty:f,ctx:y}),Ke.$set(U)},i(y){Me||(un(Ke.$$.fragment,y),Me=!0)},o(y){mn(Ke.$$.fragment,y),Me=!1},d(y){Yn(Ke,y)}}}function sb(ht,Ke,Me){let{elem_id:y=""}=Ke,{elem_classes:f=[]}=Ke,{visible:U=!0}=Ke,{value:_=null}=Ke,{mode:C}=Ke,{root:u}=Ke,{root_url:M}=Ke,{clearColor:R}=Ke,{loading_status:x}=Ke,{label:m}=Ke,{show_label:c}=Ke,T,A=!1;const S=({detail:v})=>Me(0,_=v),g=({detail:v})=>Me(10,A=v);function l(v){Af.call(this,ht,v)}function h(v){Af.call(this,ht,v)}return ht.$$set=v=>{"elem_id"in v&&Me(1,y=v.elem_id),"elem_classes"in v&&Me(2,f=v.elem_classes),"visible"in v&&Me(3,U=v.visible),"value"in v&&Me(0,_=v.value),"mode"in v&&Me(4,C=v.mode),"root"in v&&Me(11,u=v.root),"root_url"in v&&Me(12,M=v.root_url),"clearColor"in v&&Me(5,R=v.clearColor),"loading_status"in v&&Me(6,x=v.loading_status),"label"in v&&Me(7,m=v.label),"show_label"in v&&Me(8,c=v.show_label)},ht.$$.update=()=>{ht.$$.dirty&6145&&Me(9,T=Bv(_,u,M))},[_,y,f,U,C,R,x,m,c,T,A,u,M,S,g,l,h]}class cb extends rl{constructor(Ke){super(),ol(this,Ke,sb,ab,al,{elem_id:1,elem_classes:2,visible:3,value:0,mode:4,root:11,root_url:12,clearColor:5,loading_status:6,label:7,show_label:8})}}var Eb=cb;const Sb=["static","dynamic"],Ab=ht=>({type:{payload:"{ name: string; data: string }"},description:{payload:"object with file name and base64 data"}});export{Eb as Component,Cb as ExampleComponent,Ab as document,Sb as modes}; +//# sourceMappingURL=index.a791a429.js.map