/*! *****************************************************************************
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 e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},e(t,i)};function t(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function r(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(r.prototype=i.prototype,new r)}var i=function(){return i=Object.assign||function(e){for(var t,i=1,r=arguments.length;i<r;i++)for(var n in t=arguments[i])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},i.apply(this,arguments)};function r(e,t,i,r){var n,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,i,r);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,i,s):n(t,i))||s);return o>3&&s&&Object.defineProperty(t,i,s),s}var n=function(){function e(){}return e.Eval=function(t,i){return"true"===(t=t.match(/\([^\(\)]*\)/g)?t.replace(/\([^\(\)]*\)/g,(function(t){return t=t.slice(1,t.length-1),e._HandleParenthesisContent(t,i)})):e._HandleParenthesisContent(t,i))||"false"!==t&&e.Eval(t,i)},e._HandleParenthesisContent=function(t,i){var r;i=i||function(e){return"true"===e};var n=t.split("||");for(var o in n)if(n.hasOwnProperty(o)){var s=e._SimplifyNegation(n[o].trim()),a=s.split("&&");if(a.length>1)for(var h=0;h<a.length;++h){var u=e._SimplifyNegation(a[h].trim());if(!(r="true"!==u&&"false"!==u?"!"===u[0]?!i(u.substring(1)):i(u):"true"===u)){s="false";break}}if(r||"true"===s){r=!0;break}r="true"!==s&&"false"!==s?"!"===s[0]?!i(s.substring(1)):i(s):"true"===s}return r?"true":"false"},e._SimplifyNegation=function(e){return"!true"===(e=(e=e.replace(/^[\s!]+/,(function(e){return(e=e.replace(/[\s]/g,(function(){return""}))).length%2?"!":""}))).trim())?e="false":"!false"===e&&(e="true"),e},e}(),o=function(){function e(){}return e.EnableFor=function(t){t._tags=t._tags||{},t.hasTags=function(){return e.HasTags(t)},t.addTags=function(i){return e.AddTagsTo(t,i)},t.removeTags=function(i){return e.RemoveTagsFrom(t,i)},t.matchesTagsQuery=function(i){return e.MatchesQuery(t,i)}},e.DisableFor=function(e){delete e._tags,delete e.hasTags,delete e.addTags,delete e.removeTags,delete e.matchesTagsQuery},e.HasTags=function(e){if(!e._tags)return!1;var t=e._tags;for(var i in t)if(t.hasOwnProperty(i))return!0;return!1},e.GetTags=function(e,t){if(void 0===t&&(t=!0),!e._tags)return null;if(t){var i=[];for(var r in e._tags)e._tags.hasOwnProperty(r)&&!0===e._tags[r]&&i.push(r);return i.join(" ")}return e._tags},e.AddTagsTo=function(t,i){i&&("string"==typeof i&&i.split(" ").forEach((function(i,r,n){e._AddTagTo(t,i)})))},e._AddTagTo=function(t,i){""!==(i=i.trim())&&"true"!==i&&"false"!==i&&(i.match(/[\s]/)||i.match(/^([!]|([|]|[&]){2})/)||(e.EnableFor(t),t._tags[i]=!0))},e.RemoveTagsFrom=function(t,i){if(e.HasTags(t)){var r=i.split(" ");for(var n in r)e._RemoveTagFrom(t,r[n])}},e._RemoveTagFrom=function(e,t){delete e._tags[t]},e.MatchesQuery=function(t,i){return void 0===i||(""===i?e.HasTags(t):n.Eval(i,(function(i){return e.HasTags(t)&&t._tags[i]})))},e}(),s=function(){function e(){}return e.WithinEpsilon=function(e,t,i){void 0===i&&(i=1401298e-51);var r=e-t;return-i<=r&&r<=i},e.ToHex=function(e){var t=e.toString(16);return e<=15?("0"+t).toUpperCase():t.toUpperCase()},e.Sign=function(e){return 0===(e=+e)||isNaN(e)?e:e>0?1:-1},e.Clamp=function(e,t,i){return void 0===t&&(t=0),void 0===i&&(i=1),Math.min(i,Math.max(t,e))},e.Log2=function(e){return Math.log(e)*Math.LOG2E},e.Repeat=function(e,t){return e-Math.floor(e/t)*t},e.Normalize=function(e,t,i){return(e-t)/(i-t)},e.Denormalize=function(e,t,i){return e*(i-t)+t},e.DeltaAngle=function(t,i){var r=e.Repeat(i-t,360);return r>180&&(r-=360),r},e.PingPong=function(t,i){var r=e.Repeat(t,2*i);return i-Math.abs(r-i)},e.SmoothStep=function(t,i,r){var n=e.Clamp(r);return i*(n=-2*n*n*n+3*n*n)+t*(1-n)},e.MoveTowards=function(t,i,r){return Math.abs(i-t)<=r?i:t+e.Sign(i-t)*r},e.MoveTowardsAngle=function(t,i,r){var n=e.DeltaAngle(t,i),o=0;return-r<n&&n<r?o=i:(i=t+n,o=e.MoveTowards(t,i,r)),o},e.Lerp=function(e,t,i){return e+(t-e)*i},e.LerpAngle=function(t,i,r){var n=e.Repeat(i-t,360);return n>180&&(n-=360),t+n*e.Clamp(r)},e.InverseLerp=function(t,i,r){return t!=i?e.Clamp((r-t)/(i-t)):0},e.Hermite=function(e,t,i,r,n){var o=n*n,s=n*o;return e*(2*s-3*o+1)+i*(-2*s+3*o)+t*(s-2*o+n)+r*(s-o)},e.RandomRange=function(e,t){return e===t?e:Math.random()*(t-e)+e},e.RangeToPercent=function(e,t,i){return(e-t)/(i-t)},e.PercentToRange=function(e,t,i){return(i-t)*e+t},e.NormalizeRadians=function(t){return t-=e.TwoPi*Math.floor((t+Math.PI)/e.TwoPi)},e.TwoPi=2*Math.PI,e}(),a=1/2.2,h=2.2,u=.001,l=function(){function e(){}return e.BuildArray=function(e,t){for(var i=[],r=0;r<e;++r)i.push(t());return i},e}(),c=function(){function e(){}return e.GetClass=function(e){return this.RegisteredTypes&&this.RegisteredTypes[e]?this.RegisteredTypes[e]:null},e.RegisteredTypes={},e}(),f=function(){function e(){}return e.SetMatrixPrecision=function(t){if(e.MatrixTrackPrecisionChange=!1,t&&!e.MatrixUse64Bits&&e.MatrixTrackedMatrices)for(var i=0;i<e.MatrixTrackedMatrices.length;++i){var r=e.MatrixTrackedMatrices[i],n=r._m;r._m=new Array(16);for(var o=0;o<16;++o)r._m[o]=n[o]}e.MatrixUse64Bits=t,e.MatrixCurrentType=e.MatrixUse64Bits?Array:Float32Array,e.MatrixTrackedMatrices=null},e.MatrixUse64Bits=!1,e.MatrixTrackPrecisionChange=!0,e.MatrixCurrentType=Float32Array,e.MatrixTrackedMatrices=[],e}(),d=function(){function e(e,t){void 0===e&&(e=0),void 0===t&&(t=0),this.x=e,this.y=t}return e.prototype.toString=function(){return"{X: "+this.x+" Y: "+this.y+"}"},e.prototype.getClassName=function(){return"Vector2"},e.prototype.getHashCode=function(){var e=0|this.x;return e=397*e^(0|this.y)},e.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,this},e.prototype.fromArray=function(t,i){return void 0===i&&(i=0),e.FromArrayToRef(t,i,this),this},e.prototype.asArray=function(){var e=new Array;return this.toArray(e,0),e},e.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this},e.prototype.copyFromFloats=function(e,t){return this.x=e,this.y=t,this},e.prototype.set=function(e,t){return this.copyFromFloats(e,t)},e.prototype.add=function(t){return new e(this.x+t.x,this.y+t.y)},e.prototype.addToRef=function(e,t){return t.x=this.x+e.x,t.y=this.y+e.y,this},e.prototype.addInPlace=function(e){return this.x+=e.x,this.y+=e.y,this},e.prototype.addVector3=function(t){return new e(this.x+t.x,this.y+t.y)},e.prototype.subtract=function(t){return new e(this.x-t.x,this.y-t.y)},e.prototype.subtractToRef=function(e,t){return t.x=this.x-e.x,t.y=this.y-e.y,this},e.prototype.subtractInPlace=function(e){return this.x-=e.x,this.y-=e.y,this},e.prototype.multiplyInPlace=function(e){return this.x*=e.x,this.y*=e.y,this},e.prototype.multiply=function(t){return new e(this.x*t.x,this.y*t.y)},e.prototype.multiplyToRef=function(e,t){return t.x=this.x*e.x,t.y=this.y*e.y,this},e.prototype.multiplyByFloats=function(t,i){return new e(this.x*t,this.y*i)},e.prototype.divide=function(t){return new e(this.x/t.x,this.y/t.y)},e.prototype.divideToRef=function(e,t){return t.x=this.x/e.x,t.y=this.y/e.y,this},e.prototype.divideInPlace=function(e){return this.divideToRef(e,this)},e.prototype.negate=function(){return new e(-this.x,-this.y)},e.prototype.negateInPlace=function(){return this.x*=-1,this.y*=-1,this},e.prototype.negateToRef=function(e){return e.copyFromFloats(-1*this.x,-1*this.y)},e.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this},e.prototype.scale=function(t){var i=new e(0,0);return this.scaleToRef(t,i),i},e.prototype.scaleToRef=function(e,t){return t.x=this.x*e,t.y=this.y*e,this},e.prototype.scaleAndAddToRef=function(e,t){return t.x+=this.x*e,t.y+=this.y*e,this},e.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y},e.prototype.equalsWithEpsilon=function(e,t){return void 0===t&&(t=u),e&&s.WithinEpsilon(this.x,e.x,t)&&s.WithinEpsilon(this.y,e.y,t)},e.prototype.floor=function(){return new e(Math.floor(this.x),Math.floor(this.y))},e.prototype.fract=function(){return new e(this.x-Math.floor(this.x),this.y-Math.floor(this.y))},e.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},e.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y},e.prototype.normalize=function(){var e=this.length();return 0===e||(this.x/=e,this.y/=e),this},e.prototype.clone=function(){return new e(this.x,this.y)},e.Zero=function(){return new e(0,0)},e.One=function(){return new e(1,1)},e.FromArray=function(t,i){return void 0===i&&(i=0),new e(t[i],t[i+1])},e.FromArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1]},e.CatmullRom=function(t,i,r,n,o){var s=o*o,a=o*s;return new e(.5*(2*i.x+(-t.x+r.x)*o+(2*t.x-5*i.x+4*r.x-n.x)*s+(-t.x+3*i.x-3*r.x+n.x)*a),.5*(2*i.y+(-t.y+r.y)*o+(2*t.y-5*i.y+4*r.y-n.y)*s+(-t.y+3*i.y-3*r.y+n.y)*a))},e.Clamp=function(t,i,r){var n=t.x;n=(n=n>r.x?r.x:n)<i.x?i.x:n;var o=t.y;return new e(n,o=(o=o>r.y?r.y:o)<i.y?i.y:o)},e.Hermite=function(t,i,r,n,o){var s=o*o,a=o*s,h=2*a-3*s+1,u=-2*a+3*s,l=a-2*s+o,c=a-s;return new e(t.x*h+r.x*u+i.x*l+n.x*c,t.y*h+r.y*u+i.y*l+n.y*c)},e.Lerp=function(t,i,r){return new e(t.x+(i.x-t.x)*r,t.y+(i.y-t.y)*r)},e.Dot=function(e,t){return e.x*t.x+e.y*t.y},e.Normalize=function(e){var t=e.clone();return t.normalize(),t},e.Minimize=function(t,i){return new e(t.x<i.x?t.x:i.x,t.y<i.y?t.y:i.y)},e.Maximize=function(t,i){return new e(t.x>i.x?t.x:i.x,t.y>i.y?t.y:i.y)},e.Transform=function(t,i){var r=e.Zero();return e.TransformToRef(t,i,r),r},e.TransformToRef=function(e,t,i){var r=t.m,n=e.x*r[0]+e.y*r[4]+r[12],o=e.x*r[1]+e.y*r[5]+r[13];i.x=n,i.y=o},e.PointInTriangle=function(e,t,i,r){var n=.5*(-i.y*r.x+t.y*(-i.x+r.x)+t.x*(i.y-r.y)+i.x*r.y),o=n<0?-1:1,s=(t.y*r.x-t.x*r.y+(r.y-t.y)*e.x+(t.x-r.x)*e.y)*o,a=(t.x*i.y-t.y*i.x+(t.y-i.y)*e.x+(i.x-t.x)*e.y)*o;return s>0&&a>0&&s+a<2*n*o},e.Distance=function(t,i){return Math.sqrt(e.DistanceSquared(t,i))},e.DistanceSquared=function(e,t){var i=e.x-t.x,r=e.y-t.y;return i*i+r*r},e.Center=function(e,t){var i=e.add(t);return i.scaleInPlace(.5),i},e.DistanceOfPointFromSegment=function(t,i,r){var n=e.DistanceSquared(i,r);if(0===n)return e.Distance(t,i);var o=r.subtract(i),s=Math.max(0,Math.min(1,e.Dot(t.subtract(i),o)/n)),a=i.add(o.multiplyByFloats(s,s));return e.Distance(t,a)},e}(),p=function(){function e(e,t,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),this._isDirty=!0,this._x=e,this._y=t,this._z=i}return Object.defineProperty(e.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"z",{get:function(){return this._z},set:function(e){this._z=e,this._isDirty=!0},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return"{X: "+this._x+" Y:"+this._y+" Z:"+this._z+"}"},e.prototype.getClassName=function(){return"Vector3"},e.prototype.getHashCode=function(){var e=0|this._x;return e=397*(e=397*e^(0|this._y))^(0|this._z)},e.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},e.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,this},e.prototype.fromArray=function(t,i){return void 0===i&&(i=0),e.FromArrayToRef(t,i,this),this},e.prototype.toQuaternion=function(){return g.RotationYawPitchRoll(this._y,this._x,this._z)},e.prototype.addInPlace=function(e){return this.addInPlaceFromFloats(e._x,e._y,e._z)},e.prototype.addInPlaceFromFloats=function(e,t,i){return this.x+=e,this.y+=t,this.z+=i,this},e.prototype.add=function(t){return new e(this._x+t._x,this._y+t._y,this._z+t._z)},e.prototype.addToRef=function(e,t){return t.copyFromFloats(this._x+e._x,this._y+e._y,this._z+e._z)},e.prototype.subtractInPlace=function(e){return this.x-=e._x,this.y-=e._y,this.z-=e._z,this},e.prototype.subtract=function(t){return new e(this._x-t._x,this._y-t._y,this._z-t._z)},e.prototype.subtractToRef=function(e,t){return this.subtractFromFloatsToRef(e._x,e._y,e._z,t)},e.prototype.subtractFromFloats=function(t,i,r){return new e(this._x-t,this._y-i,this._z-r)},e.prototype.subtractFromFloatsToRef=function(e,t,i,r){return r.copyFromFloats(this._x-e,this._y-t,this._z-i)},e.prototype.negate=function(){return new e(-this._x,-this._y,-this._z)},e.prototype.negateInPlace=function(){return this.x*=-1,this.y*=-1,this.z*=-1,this},e.prototype.negateToRef=function(e){return e.copyFromFloats(-1*this._x,-1*this._y,-1*this._z)},e.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this.z*=e,this},e.prototype.scale=function(t){return new e(this._x*t,this._y*t,this._z*t)},e.prototype.scaleToRef=function(e,t){return t.copyFromFloats(this._x*e,this._y*e,this._z*e)},e.prototype.scaleAndAddToRef=function(e,t){return t.addInPlaceFromFloats(this._x*e,this._y*e,this._z*e)},e.prototype.projectOnPlane=function(t,i){var r=e.Zero();return this.projectOnPlaneToRef(t,i,r),r},e.prototype.projectOnPlaneToRef=function(t,i,r){var n=t.normal,o=t.d,s=v.Vector3[0];this.subtractToRef(i,s),s.normalize();var a=e.Dot(s,n),h=-(e.Dot(i,n)+o)/a,u=s.scaleInPlace(h);i.addToRef(u,r)},e.prototype.equals=function(e){return e&&this._x===e._x&&this._y===e._y&&this._z===e._z},e.prototype.equalsWithEpsilon=function(e,t){return void 0===t&&(t=u),e&&s.WithinEpsilon(this._x,e._x,t)&&s.WithinEpsilon(this._y,e._y,t)&&s.WithinEpsilon(this._z,e._z,t)},e.prototype.equalsToFloats=function(e,t,i){return this._x===e&&this._y===t&&this._z===i},e.prototype.multiplyInPlace=function(e){return this.x*=e._x,this.y*=e._y,this.z*=e._z,this},e.prototype.multiply=function(e){return this.multiplyByFloats(e._x,e._y,e._z)},e.prototype.multiplyToRef=function(e,t){return t.copyFromFloats(this._x*e._x,this._y*e._y,this._z*e._z)},e.prototype.multiplyByFloats=function(t,i,r){return new e(this._x*t,this._y*i,this._z*r)},e.prototype.divide=function(t){return new e(this._x/t._x,this._y/t._y,this._z/t._z)},e.prototype.divideToRef=function(e,t){return t.copyFromFloats(this._x/e._x,this._y/e._y,this._z/e._z)},e.prototype.divideInPlace=function(e){return this.divideToRef(e,this)},e.prototype.minimizeInPlace=function(e){return this.minimizeInPlaceFromFloats(e._x,e._y,e._z)},e.prototype.maximizeInPlace=function(e){return this.maximizeInPlaceFromFloats(e._x,e._y,e._z)},e.prototype.minimizeInPlaceFromFloats=function(e,t,i){return e<this._x&&(this.x=e),t<this._y&&(this.y=t),i<this._z&&(this.z=i),this},e.prototype.maximizeInPlaceFromFloats=function(e,t,i){return e>this._x&&(this.x=e),t>this._y&&(this.y=t),i>this._z&&(this.z=i),this},e.prototype.isNonUniformWithinEpsilon=function(e){var t=Math.abs(this._x),i=Math.abs(this._y);if(!s.WithinEpsilon(t,i,e))return!0;var r=Math.abs(this._z);return!s.WithinEpsilon(t,r,e)||!s.WithinEpsilon(i,r,e)},Object.defineProperty(e.prototype,"isNonUniform",{get:function(){var e=Math.abs(this._x);return e!==Math.abs(this._y)||e!==Math.abs(this._z)},enumerable:!1,configurable:!0}),e.prototype.floor=function(){return new e(Math.floor(this._x),Math.floor(this._y),Math.floor(this._z))},e.prototype.fract=function(){return new e(this._x-Math.floor(this._x),this._y-Math.floor(this._y),this._z-Math.floor(this._z))},e.prototype.length=function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z)},e.prototype.lengthSquared=function(){return this._x*this._x+this._y*this._y+this._z*this._z},e.prototype.normalize=function(){return this.normalizeFromLength(this.length())},e.prototype.reorderInPlace=function(e){var t=this;return"xyz"===(e=e.toLowerCase())||(v.Vector3[0].copyFrom(this),["x","y","z"].forEach((function(i,r){t[i]=v.Vector3[0][e[r]]}))),this},e.prototype.rotateByQuaternionToRef=function(t,i){return t.toRotationMatrix(v.Matrix[0]),e.TransformCoordinatesToRef(this,v.Matrix[0],i),i},e.prototype.rotateByQuaternionAroundPointToRef=function(e,t,i){return this.subtractToRef(t,v.Vector3[0]),v.Vector3[0].rotateByQuaternionToRef(e,v.Vector3[0]),t.addToRef(v.Vector3[0],i),i},e.prototype.cross=function(t){return e.Cross(this,t)},e.prototype.normalizeFromLength=function(e){return 0===e||1===e?this:this.scaleInPlace(1/e)},e.prototype.normalizeToNew=function(){var t=new e(0,0,0);return this.normalizeToRef(t),t},e.prototype.normalizeToRef=function(e){var t=this.length();return 0===t||1===t?e.copyFromFloats(this._x,this._y,this._z):this.scaleToRef(1/t,e)},e.prototype.clone=function(){return new e(this._x,this._y,this._z)},e.prototype.copyFrom=function(e){return this.copyFromFloats(e._x,e._y,e._z)},e.prototype.copyFromFloats=function(e,t,i){return this.x=e,this.y=t,this.z=i,this},e.prototype.set=function(e,t,i){return this.copyFromFloats(e,t,i)},e.prototype.setAll=function(e){return this.x=this.y=this.z=e,this},e.GetClipFactor=function(t,i,r,n){var o=e.Dot(t,r)-n;return o/(o-(e.Dot(i,r)-n))},e.GetAngleBetweenVectors=function(t,i,r){var n=t.normalizeToRef(v.Vector3[1]),o=i.normalizeToRef(v.Vector3[2]),s=e.Dot(n,o),a=v.Vector3[3];return e.CrossToRef(n,o,a),e.Dot(a,r)>0?Math.acos(s):-Math.acos(s)},e.FromArray=function(t,i){return void 0===i&&(i=0),new e(t[i],t[i+1],t[i+2])},e.FromFloatArray=function(t,i){return e.FromArray(t,i)},e.FromArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1],i.z=e[t+2]},e.FromFloatArrayToRef=function(t,i,r){return e.FromArrayToRef(t,i,r)},e.FromFloatsToRef=function(e,t,i,r){r.copyFromFloats(e,t,i)},e.Zero=function(){return new e(0,0,0)},e.One=function(){return new e(1,1,1)},e.Up=function(){return new e(0,1,0)},Object.defineProperty(e,"UpReadOnly",{get:function(){return e._UpReadOnly},enumerable:!1,configurable:!0}),Object.defineProperty(e,"ZeroReadOnly",{get:function(){return e._ZeroReadOnly},enumerable:!1,configurable:!0}),e.Down=function(){return new e(0,-1,0)},e.Forward=function(t){return void 0===t&&(t=!1),new e(0,0,t?-1:1)},e.Backward=function(t){return void 0===t&&(t=!1),new e(0,0,t?1:-1)},e.Right=function(){return new e(1,0,0)},e.Left=function(){return new e(-1,0,0)},e.TransformCoordinates=function(t,i){var r=e.Zero();return e.TransformCoordinatesToRef(t,i,r),r},e.TransformCoordinatesToRef=function(t,i,r){e.TransformCoordinatesFromFloatsToRef(t._x,t._y,t._z,i,r)},e.TransformCoordinatesFromFloatsToRef=function(e,t,i,r,n){var o=r.m,s=e*o[0]+t*o[4]+i*o[8]+o[12],a=e*o[1]+t*o[5]+i*o[9]+o[13],h=e*o[2]+t*o[6]+i*o[10]+o[14],u=1/(e*o[3]+t*o[7]+i*o[11]+o[15]);n.x=s*u,n.y=a*u,n.z=h*u},e.TransformNormal=function(t,i){var r=e.Zero();return e.TransformNormalToRef(t,i,r),r},e.TransformNormalToRef=function(e,t,i){this.TransformNormalFromFloatsToRef(e._x,e._y,e._z,t,i)},e.TransformNormalFromFloatsToRef=function(e,t,i,r,n){var o=r.m;n.x=e*o[0]+t*o[4]+i*o[8],n.y=e*o[1]+t*o[5]+i*o[9],n.z=e*o[2]+t*o[6]+i*o[10]},e.CatmullRom=function(t,i,r,n,o){var s=o*o,a=o*s;return new e(.5*(2*i._x+(-t._x+r._x)*o+(2*t._x-5*i._x+4*r._x-n._x)*s+(-t._x+3*i._x-3*r._x+n._x)*a),.5*(2*i._y+(-t._y+r._y)*o+(2*t._y-5*i._y+4*r._y-n._y)*s+(-t._y+3*i._y-3*r._y+n._y)*a),.5*(2*i._z+(-t._z+r._z)*o+(2*t._z-5*i._z+4*r._z-n._z)*s+(-t._z+3*i._z-3*r._z+n._z)*a))},e.Clamp=function(t,i,r){var n=new e;return e.ClampToRef(t,i,r,n),n},e.ClampToRef=function(e,t,i,r){var n=e._x;n=(n=n>i._x?i._x:n)<t._x?t._x:n;var o=e._y;o=(o=o>i._y?i._y:o)<t._y?t._y:o;var s=e._z;s=(s=s>i._z?i._z:s)<t._z?t._z:s,r.copyFromFloats(n,o,s)},e.CheckExtends=function(e,t,i){t.minimizeInPlace(e),i.maximizeInPlace(e)},e.Hermite=function(t,i,r,n,o){var s=o*o,a=o*s,h=2*a-3*s+1,u=-2*a+3*s,l=a-2*s+o,c=a-s;return new e(t._x*h+r._x*u+i._x*l+n._x*c,t._y*h+r._y*u+i._y*l+n._y*c,t._z*h+r._z*u+i._z*l+n._z*c)},e.Lerp=function(t,i,r){var n=new e(0,0,0);return e.LerpToRef(t,i,r,n),n},e.LerpToRef=function(e,t,i,r){r.x=e._x+(t._x-e._x)*i,r.y=e._y+(t._y-e._y)*i,r.z=e._z+(t._z-e._z)*i},e.Dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z},e.Cross=function(t,i){var r=e.Zero();return e.CrossToRef(t,i,r),r},e.CrossToRef=function(e,t,i){var r=e._y*t._z-e._z*t._y,n=e._z*t._x-e._x*t._z,o=e._x*t._y-e._y*t._x;i.copyFromFloats(r,n,o)},e.Normalize=function(t){var i=e.Zero();return e.NormalizeToRef(t,i),i},e.NormalizeToRef=function(e,t){e.normalizeToRef(t)},e.Project=function(t,i,r,n){var o=new e;return e.ProjectToRef(t,i,r,n,o),o},e.ProjectToRef=function(t,i,r,n,o){var s=n.width,a=n.height,h=n.x,u=n.y,l=v.Matrix[1];m.FromValuesToRef(s/2,0,0,0,0,-a/2,0,0,0,0,.5,0,h+s/2,a/2+u,.5,1,l);var c=v.Matrix[0];return i.multiplyToRef(r,c),c.multiplyToRef(l,c),e.TransformCoordinatesToRef(t,c,o),o},e._UnprojectFromInvertedMatrixToRef=function(t,i,r){e.TransformCoordinatesToRef(t,i,r);var n=i.m,o=t._x*n[3]+t._y*n[7]+t._z*n[11]+n[15];s.WithinEpsilon(o,1)&&r.scaleInPlace(1/o)},e.UnprojectFromTransform=function(t,i,r,n,o){var s=v.Matrix[0];n.multiplyToRef(o,s),s.invert(),t.x=t._x/i*2-1,t.y=-(t._y/r*2-1);var a=new e;return e._UnprojectFromInvertedMatrixToRef(t,s,a),a},e.Unproject=function(t,i,r,n,o,s){var a=e.Zero();return e.UnprojectToRef(t,i,r,n,o,s,a),a},e.UnprojectToRef=function(t,i,r,n,o,s,a){e.UnprojectFloatsToRef(t._x,t._y,t._z,i,r,n,o,s,a)},e.UnprojectFloatsToRef=function(t,i,r,n,o,s,a,h,u){var l=v.Matrix[0];s.multiplyToRef(a,l),l.multiplyToRef(h,l),l.invert();var c=v.Vector3[0];c.x=t/n*2-1,c.y=-(i/o*2-1),c.z=2*r-1,e._UnprojectFromInvertedMatrixToRef(c,l,u)},e.Minimize=function(e,t){var i=e.clone();return i.minimizeInPlace(t),i},e.Maximize=function(e,t){var i=e.clone();return i.maximizeInPlace(t),i},e.Distance=function(t,i){return Math.sqrt(e.DistanceSquared(t,i))},e.DistanceSquared=function(e,t){var i=e._x-t._x,r=e._y-t._y,n=e._z-t._z;return i*i+r*r+n*n},e.Center=function(e,t){var i=e.add(t);return i.scaleInPlace(.5),i},e.RotationFromAxis=function(t,i,r){var n=e.Zero();return e.RotationFromAxisToRef(t,i,r,n),n},e.RotationFromAxisToRef=function(e,t,i,r){var n=v.Quaternion[0];g.RotationQuaternionFromAxisToRef(e,t,i,n),n.toEulerAnglesToRef(r)},e._UpReadOnly=e.Up(),e._ZeroReadOnly=e.Zero(),e}(),_=function(){function e(e,t,i,r){this.x=e,this.y=t,this.z=i,this.w=r}return e.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+" W:"+this.w+"}"},e.prototype.getClassName=function(){return"Vector4"},e.prototype.getHashCode=function(){var e=0|this.x;return e=397*(e=397*(e=397*e^(0|this.y))^(0|this.z))^(0|this.w)},e.prototype.asArray=function(){var e=new Array;return this.toArray(e,0),e},e.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,this},e.prototype.fromArray=function(t,i){return void 0===i&&(i=0),e.FromArrayToRef(t,i,this),this},e.prototype.addInPlace=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this},e.prototype.add=function(t){return new e(this.x+t.x,this.y+t.y,this.z+t.z,this.w+t.w)},e.prototype.addToRef=function(e,t){return t.x=this.x+e.x,t.y=this.y+e.y,t.z=this.z+e.z,t.w=this.w+e.w,this},e.prototype.subtractInPlace=function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this},e.prototype.subtract=function(t){return new e(this.x-t.x,this.y-t.y,this.z-t.z,this.w-t.w)},e.prototype.subtractToRef=function(e,t){return t.x=this.x-e.x,t.y=this.y-e.y,t.z=this.z-e.z,t.w=this.w-e.w,this},e.prototype.subtractFromFloats=function(t,i,r,n){return new e(this.x-t,this.y-i,this.z-r,this.w-n)},e.prototype.subtractFromFloatsToRef=function(e,t,i,r,n){return n.x=this.x-e,n.y=this.y-t,n.z=this.z-i,n.w=this.w-r,this},e.prototype.negate=function(){return new e(-this.x,-this.y,-this.z,-this.w)},e.prototype.negateInPlace=function(){return this.x*=-1,this.y*=-1,this.z*=-1,this.w*=-1,this},e.prototype.negateToRef=function(e){return e.copyFromFloats(-1*this.x,-1*this.y,-1*this.z,-1*this.w)},e.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},e.prototype.scale=function(t){return new e(this.x*t,this.y*t,this.z*t,this.w*t)},e.prototype.scaleToRef=function(e,t){return t.x=this.x*e,t.y=this.y*e,t.z=this.z*e,t.w=this.w*e,this},e.prototype.scaleAndAddToRef=function(e,t){return t.x+=this.x*e,t.y+=this.y*e,t.z+=this.z*e,t.w+=this.w*e,this},e.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w},e.prototype.equalsWithEpsilon=function(e,t){return void 0===t&&(t=u),e&&s.WithinEpsilon(this.x,e.x,t)&&s.WithinEpsilon(this.y,e.y,t)&&s.WithinEpsilon(this.z,e.z,t)&&s.WithinEpsilon(this.w,e.w,t)},e.prototype.equalsToFloats=function(e,t,i,r){return this.x===e&&this.y===t&&this.z===i&&this.w===r},e.prototype.multiplyInPlace=function(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this},e.prototype.multiply=function(t){return new e(this.x*t.x,this.y*t.y,this.z*t.z,this.w*t.w)},e.prototype.multiplyToRef=function(e,t){return t.x=this.x*e.x,t.y=this.y*e.y,t.z=this.z*e.z,t.w=this.w*e.w,this},e.prototype.multiplyByFloats=function(t,i,r,n){return new e(this.x*t,this.y*i,this.z*r,this.w*n)},e.prototype.divide=function(t){return new e(this.x/t.x,this.y/t.y,this.z/t.z,this.w/t.w)},e.prototype.divideToRef=function(e,t){return t.x=this.x/e.x,t.y=this.y/e.y,t.z=this.z/e.z,t.w=this.w/e.w,this},e.prototype.divideInPlace=function(e){return this.divideToRef(e,this)},e.prototype.minimizeInPlace=function(e){return e.x<this.x&&(this.x=e.x),e.y<this.y&&(this.y=e.y),e.z<this.z&&(this.z=e.z),e.w<this.w&&(this.w=e.w),this},e.prototype.maximizeInPlace=function(e){return e.x>this.x&&(this.x=e.x),e.y>this.y&&(this.y=e.y),e.z>this.z&&(this.z=e.z),e.w>this.w&&(this.w=e.w),this},e.prototype.floor=function(){return new e(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z),Math.floor(this.w))},e.prototype.fract=function(){return new e(this.x-Math.floor(this.x),this.y-Math.floor(this.y),this.z-Math.floor(this.z),this.w-Math.floor(this.w))},e.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},e.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},e.prototype.normalize=function(){var e=this.length();return 0===e?this:this.scaleInPlace(1/e)},e.prototype.toVector3=function(){return new p(this.x,this.y,this.z)},e.prototype.clone=function(){return new e(this.x,this.y,this.z,this.w)},e.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this},e.prototype.copyFromFloats=function(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this},e.prototype.set=function(e,t,i,r){return this.copyFromFloats(e,t,i,r)},e.prototype.setAll=function(e){return this.x=this.y=this.z=this.w=e,this},e.FromArray=function(t,i){return i||(i=0),new e(t[i],t[i+1],t[i+2],t[i+3])},e.FromArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1],i.z=e[t+2],i.w=e[t+3]},e.FromFloatArrayToRef=function(t,i,r){e.FromArrayToRef(t,i,r)},e.FromFloatsToRef=function(e,t,i,r,n){n.x=e,n.y=t,n.z=i,n.w=r},e.Zero=function(){return new e(0,0,0,0)},e.One=function(){return new e(1,1,1,1)},e.Normalize=function(t){var i=e.Zero();return e.NormalizeToRef(t,i),i},e.NormalizeToRef=function(e,t){t.copyFrom(e),t.normalize()},e.Minimize=function(e,t){var i=e.clone();return i.minimizeInPlace(t),i},e.Maximize=function(e,t){var i=e.clone();return i.maximizeInPlace(t),i},e.Distance=function(t,i){return Math.sqrt(e.DistanceSquared(t,i))},e.DistanceSquared=function(e,t){var i=e.x-t.x,r=e.y-t.y,n=e.z-t.z,o=e.w-t.w;return i*i+r*r+n*n+o*o},e.Center=function(e,t){var i=e.add(t);return i.scaleInPlace(.5),i},e.TransformNormal=function(t,i){var r=e.Zero();return e.TransformNormalToRef(t,i,r),r},e.TransformNormalToRef=function(e,t,i){var r=t.m,n=e.x*r[0]+e.y*r[4]+e.z*r[8],o=e.x*r[1]+e.y*r[5]+e.z*r[9],s=e.x*r[2]+e.y*r[6]+e.z*r[10];i.x=n,i.y=o,i.z=s,i.w=e.w},e.TransformNormalFromFloatsToRef=function(e,t,i,r,n,o){var s=n.m;o.x=e*s[0]+t*s[4]+i*s[8],o.y=e*s[1]+t*s[5]+i*s[9],o.z=e*s[2]+t*s[6]+i*s[10],o.w=r},e.FromVector3=function(t,i){return void 0===i&&(i=0),new e(t._x,t._y,t._z,i)},e}(),g=function(){function e(e,t,i,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=1),this._isDirty=!0,this._x=e,this._y=t,this._z=i,this._w=r}return Object.defineProperty(e.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"z",{get:function(){return this._z},set:function(e){this._z=e,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"w",{get:function(){return this._w},set:function(e){this._w=e,this._isDirty=!0},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return"{X: "+this._x+" Y:"+this._y+" Z:"+this._z+" W:"+this._w+"}"},e.prototype.getClassName=function(){return"Quaternion"},e.prototype.getHashCode=function(){var e=0|this._x;return e=397*(e=397*(e=397*e^(0|this._y))^(0|this._z))^(0|this._w)},e.prototype.asArray=function(){return[this._x,this._y,this._z,this._w]},e.prototype.equals=function(e){return e&&this._x===e._x&&this._y===e._y&&this._z===e._z&&this._w===e._w},e.prototype.equalsWithEpsilon=function(e,t){return void 0===t&&(t=u),e&&s.WithinEpsilon(this._x,e._x,t)&&s.WithinEpsilon(this._y,e._y,t)&&s.WithinEpsilon(this._z,e._z,t)&&s.WithinEpsilon(this._w,e._w,t)},e.prototype.clone=function(){return new e(this._x,this._y,this._z,this._w)},e.prototype.copyFrom=function(e){return this.x=e._x,this.y=e._y,this.z=e._z,this.w=e._w,this},e.prototype.copyFromFloats=function(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this},e.prototype.set=function(e,t,i,r){return this.copyFromFloats(e,t,i,r)},e.prototype.add=function(t){return new e(this._x+t._x,this._y+t._y,this._z+t._z,this._w+t._w)},e.prototype.addInPlace=function(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,this._w+=e._w,this},e.prototype.subtract=function(t){return new e(this._x-t._x,this._y-t._y,this._z-t._z,this._w-t._w)},e.prototype.scale=function(t){return new e(this._x*t,this._y*t,this._z*t,this._w*t)},e.prototype.scaleToRef=function(e,t){return t.x=this._x*e,t.y=this._y*e,t.z=this._z*e,t.w=this._w*e,this},e.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},e.prototype.scaleAndAddToRef=function(e,t){return t.x+=this._x*e,t.y+=this._y*e,t.z+=this._z*e,t.w+=this._w*e,this},e.prototype.multiply=function(t){var i=new e(0,0,0,1);return this.multiplyToRef(t,i),i},e.prototype.multiplyToRef=function(e,t){var i=this._x*e._w+this._y*e._z-this._z*e._y+this._w*e._x,r=-this._x*e._z+this._y*e._w+this._z*e._x+this._w*e._y,n=this._x*e._y-this._y*e._x+this._z*e._w+this._w*e._z,o=-this._x*e._x-this._y*e._y-this._z*e._z+this._w*e._w;return t.copyFromFloats(i,r,n,o),this},e.prototype.multiplyInPlace=function(e){return this.multiplyToRef(e,this),this},e.prototype.conjugateToRef=function(e){return e.copyFromFloats(-this._x,-this._y,-this._z,this._w),this},e.prototype.conjugateInPlace=function(){return this.x*=-1,this.y*=-1,this.z*=-1,this},e.prototype.conjugate=function(){return new e(-this._x,-this._y,-this._z,this._w)},e.prototype.length=function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},e.prototype.normalize=function(){var e=this.length();if(0===e)return this;var t=1/e;return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},e.prototype.toEulerAngles=function(e){var t=p.Zero();return this.toEulerAnglesToRef(t),t},e.prototype.toEulerAnglesToRef=function(e){var t=this._z,i=this._x,r=this._y,n=this._w,o=n*n,s=t*t,a=i*i,h=r*r,u=r*t-i*n,l=.4999999;return u<-l?(e.y=2*Math.atan2(r,n),e.x=Math.PI/2,e.z=0):u>l?(e.y=2*Math.atan2(r,n),e.x=-Math.PI/2,e.z=0):(e.z=Math.atan2(2*(i*r+t*n),-s-a+h+o),e.x=Math.asin(-2*(t*r-i*n)),e.y=Math.atan2(2*(t*i+r*n),s-a-h+o)),this},e.prototype.toRotationMatrix=function(e){return m.FromQuaternionToRef(this,e),this},e.prototype.fromRotationMatrix=function(t){return e.FromRotationMatrixToRef(t,this),this},e.FromRotationMatrix=function(t){var i=new e;return e.FromRotationMatrixToRef(t,i),i},e.FromRotationMatrixToRef=function(e,t){var i,r=e.m,n=r[0],o=r[4],s=r[8],a=r[1],h=r[5],u=r[9],l=r[2],c=r[6],f=r[10],d=n+h+f;d>0?(i=.5/Math.sqrt(d+1),t.w=.25/i,t.x=(c-u)*i,t.y=(s-l)*i,t.z=(a-o)*i):n>h&&n>f?(i=2*Math.sqrt(1+n-h-f),t.w=(c-u)/i,t.x=.25*i,t.y=(o+a)/i,t.z=(s+l)/i):h>f?(i=2*Math.sqrt(1+h-n-f),t.w=(s-l)/i,t.x=(o+a)/i,t.y=.25*i,t.z=(u+c)/i):(i=2*Math.sqrt(1+f-n-h),t.w=(a-o)/i,t.x=(s+l)/i,t.y=(u+c)/i,t.z=.25*i)},e.Dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w},e.AreClose=function(t,i){return e.Dot(t,i)>=0},e.Zero=function(){return new e(0,0,0,0)},e.Inverse=function(t){return new e(-t._x,-t._y,-t._z,t._w)},e.InverseToRef=function(e,t){return t.set(-e._x,-e._y,-e._z,e._w),t},e.Identity=function(){return new e(0,0,0,1)},e.IsIdentity=function(e){return e&&0===e._x&&0===e._y&&0===e._z&&1===e._w},e.RotationAxis=function(t,i){return e.RotationAxisToRef(t,i,new e)},e.RotationAxisToRef=function(e,t,i){var r=Math.sin(t/2);return e.normalize(),i.w=Math.cos(t/2),i.x=e._x*r,i.y=e._y*r,i.z=e._z*r,i},e.FromArray=function(t,i){return i||(i=0),new e(t[i],t[i+1],t[i+2],t[i+3])},e.FromArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1],i.z=e[t+2],i.w=e[t+3]},e.FromEulerAngles=function(t,i,r){var n=new e;return e.RotationYawPitchRollToRef(i,t,r,n),n},e.FromEulerAnglesToRef=function(t,i,r,n){return e.RotationYawPitchRollToRef(i,t,r,n),n},e.FromEulerVector=function(t){var i=new e;return e.RotationYawPitchRollToRef(t._y,t._x,t._z,i),i},e.FromEulerVectorToRef=function(t,i){return e.RotationYawPitchRollToRef(t._y,t._x,t._z,i),i},e.RotationYawPitchRoll=function(t,i,r){var n=new e;return e.RotationYawPitchRollToRef(t,i,r,n),n},e.RotationYawPitchRollToRef=function(e,t,i,r){var n=.5*i,o=.5*t,s=.5*e,a=Math.sin(n),h=Math.cos(n),u=Math.sin(o),l=Math.cos(o),c=Math.sin(s),f=Math.cos(s);r.x=f*u*h+c*l*a,r.y=c*l*h-f*u*a,r.z=f*l*a-c*u*h,r.w=f*l*h+c*u*a},e.RotationAlphaBetaGamma=function(t,i,r){var n=new e;return e.RotationAlphaBetaGammaToRef(t,i,r,n),n},e.RotationAlphaBetaGammaToRef=function(e,t,i,r){var n=.5*(i+e),o=.5*(i-e),s=.5*t;r.x=Math.cos(o)*Math.sin(s),r.y=Math.sin(o)*Math.sin(s),r.z=Math.sin(n)*Math.cos(s),r.w=Math.cos(n)*Math.cos(s)},e.RotationQuaternionFromAxis=function(t,i,r){var n=new e(0,0,0,0);return e.RotationQuaternionFromAxisToRef(t,i,r,n),n},e.RotationQuaternionFromAxisToRef=function(t,i,r,n){var o=v.Matrix[0];m.FromXYZAxesToRef(t.normalize(),i.normalize(),r.normalize(),o),e.FromRotationMatrixToRef(o,n)},e.Slerp=function(t,i,r){var n=e.Identity();return e.SlerpToRef(t,i,r,n),n},e.SlerpToRef=function(e,t,i,r){var n,o,s=e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w,a=!1;if(s<0&&(a=!0,s=-s),s>.999999)o=1-i,n=a?-i:i;else{var h=Math.acos(s),u=1/Math.sin(h);o=Math.sin((1-i)*h)*u,n=a?-Math.sin(i*h)*u:Math.sin(i*h)*u}r.x=o*e._x+n*t._x,r.y=o*e._y+n*t._y,r.z=o*e._z+n*t._z,r.w=o*e._w+n*t._w},e.Hermite=function(t,i,r,n,o){var s=o*o,a=o*s,h=2*a-3*s+1,u=-2*a+3*s,l=a-2*s+o,c=a-s;return new e(t._x*h+r._x*u+i._x*l+n._x*c,t._y*h+r._y*u+i._y*l+n._y*c,t._z*h+r._z*u+i._z*l+n._z*c,t._w*h+r._w*u+i._w*l+n._w*c)},e}(),m=function(){function e(){this._isIdentity=!1,this._isIdentityDirty=!0,this._isIdentity3x2=!0,this._isIdentity3x2Dirty=!0,this.updateFlag=-1,f.MatrixTrackPrecisionChange&&f.MatrixTrackedMatrices.push(this),this._m=new f.MatrixCurrentType(16),this._updateIdentityStatus(!1)}return Object.defineProperty(e,"Use64Bits",{get:function(){return f.MatrixUse64Bits},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"m",{get:function(){return this._m},enumerable:!1,configurable:!0}),e.prototype._markAsUpdated=function(){this.updateFlag=e._updateFlagSeed++,this._isIdentity=!1,this._isIdentity3x2=!1,this._isIdentityDirty=!0,this._isIdentity3x2Dirty=!0},e.prototype._updateIdentityStatus=function(t,i,r,n){void 0===i&&(i=!1),void 0===r&&(r=!1),void 0===n&&(n=!0),this.updateFlag=e._updateFlagSeed++,this._isIdentity=t,this._isIdentity3x2=t||r,this._isIdentityDirty=!this._isIdentity&&i,this._isIdentity3x2Dirty=!this._isIdentity3x2&&n},e.prototype.isIdentity=function(){if(this._isIdentityDirty){this._isIdentityDirty=!1;var e=this._m;this._isIdentity=1===e[0]&&0===e[1]&&0===e[2]&&0===e[3]&&0===e[4]&&1===e[5]&&0===e[6]&&0===e[7]&&0===e[8]&&0===e[9]&&1===e[10]&&0===e[11]&&0===e[12]&&0===e[13]&&0===e[14]&&1===e[15]}return this._isIdentity},e.prototype.isIdentityAs3x2=function(){return this._isIdentity3x2Dirty&&(this._isIdentity3x2Dirty=!1,1!==this._m[0]||1!==this._m[5]||1!==this._m[15]||0!==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]?this._isIdentity3x2=!1:this._isIdentity3x2=!0),this._isIdentity3x2},e.prototype.determinant=function(){if(!0===this._isIdentity)return 1;var e=this._m,t=e[0],i=e[1],r=e[2],n=e[3],o=e[4],s=e[5],a=e[6],h=e[7],u=e[8],l=e[9],c=e[10],f=e[11],d=e[12],p=e[13],_=e[14],g=e[15],m=c*g-_*f,v=l*g-p*f,y=l*_-p*c,b=u*g-d*f,T=u*_-c*d,E=u*p-d*l;return t*+(s*m-a*v+h*y)+i*-(o*m-a*b+h*T)+r*+(o*v-s*b+h*E)+n*-(o*y-s*T+a*E)},e.prototype.toArray=function(){return this._m},e.prototype.asArray=function(){return this._m},e.prototype.invert=function(){return this.invertToRef(this),this},e.prototype.reset=function(){return e.FromValuesToRef(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,this),this._updateIdentityStatus(!1),this},e.prototype.add=function(t){var i=new e;return this.addToRef(t,i),i},e.prototype.addToRef=function(e,t){for(var i=this._m,r=t._m,n=e.m,o=0;o<16;o++)r[o]=i[o]+n[o];return t._markAsUpdated(),this},e.prototype.addToSelf=function(e){for(var t=this._m,i=e.m,r=0;r<16;r++)t[r]+=i[r];return this._markAsUpdated(),this},e.prototype.invertToRef=function(t){if(!0===this._isIdentity)return e.IdentityToRef(t),this;var i=this._m,r=i[0],n=i[1],o=i[2],s=i[3],a=i[4],h=i[5],u=i[6],l=i[7],c=i[8],f=i[9],d=i[10],p=i[11],_=i[12],g=i[13],m=i[14],v=i[15],y=d*v-m*p,b=f*v-g*p,T=f*m-g*d,E=c*v-_*p,x=c*m-d*_,A=c*g-_*f,M=+(h*y-u*b+l*T),P=-(a*y-u*E+l*x),C=+(a*b-h*E+l*A),S=-(a*T-h*x+u*A),I=r*M+n*P+o*C+s*S;if(0===I)return t.copyFrom(this),this;var O=1/I,R=u*v-m*l,D=h*v-g*l,w=h*m-g*u,L=a*v-_*l,F=a*m-_*u,N=a*g-_*h,B=u*p-d*l,k=h*p-f*l,U=h*d-f*u,V=a*p-c*l,W=a*d-c*u,z=a*f-c*h,G=-(n*y-o*b+s*T),H=+(r*y-o*E+s*x),X=-(r*b-n*E+s*A),j=+(r*T-n*x+o*A),K=+(n*R-o*D+s*w),Y=-(r*R-o*L+s*F),q=+(r*D-n*L+s*N),Z=-(r*w-n*F+o*N),Q=-(n*B-o*k+s*U),J=+(r*B-o*V+s*W),$=-(r*k-n*V+s*z),ee=+(r*U-n*W+o*z);return e.FromValuesToRef(M*O,G*O,K*O,Q*O,P*O,H*O,Y*O,J*O,C*O,X*O,q*O,$*O,S*O,j*O,Z*O,ee*O,t),this},e.prototype.addAtIndex=function(e,t){return this._m[e]+=t,this._markAsUpdated(),this},e.prototype.multiplyAtIndex=function(e,t){return this._m[e]*=t,this._markAsUpdated(),this},e.prototype.setTranslationFromFloats=function(e,t,i){return this._m[12]=e,this._m[13]=t,this._m[14]=i,this._markAsUpdated(),this},e.prototype.addTranslationFromFloats=function(e,t,i){return this._m[12]+=e,this._m[13]+=t,this._m[14]+=i,this._markAsUpdated(),this},e.prototype.setTranslation=function(e){return this.setTranslationFromFloats(e._x,e._y,e._z)},e.prototype.getTranslation=function(){return new p(this._m[12],this._m[13],this._m[14])},e.prototype.getTranslationToRef=function(e){return e.x=this._m[12],e.y=this._m[13],e.z=this._m[14],this},e.prototype.removeRotationAndScaling=function(){var t=this.m;return e.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,t[12],t[13],t[14],t[15],this),this._updateIdentityStatus(0===t[12]&&0===t[13]&&0===t[14]&&1===t[15]),this},e.prototype.multiply=function(t){var i=new e;return this.multiplyToRef(t,i),i},e.prototype.copyFrom=function(e){e.copyToArray(this._m);var t=e;return this._updateIdentityStatus(t._isIdentity,t._isIdentityDirty,t._isIdentity3x2,t._isIdentity3x2Dirty),this},e.prototype.copyToArray=function(e,t){void 0===t&&(t=0);var i=this._m;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],this},e.prototype.multiplyToRef=function(e,t){return this._isIdentity?(t.copyFrom(e),this):e._isIdentity?(t.copyFrom(this),this):(this.multiplyToArray(e,t._m,0),t._markAsUpdated(),this)},e.prototype.multiplyToArray=function(e,t,i){var r=this._m,n=e.m,o=r[0],s=r[1],a=r[2],h=r[3],u=r[4],l=r[5],c=r[6],f=r[7],d=r[8],p=r[9],_=r[10],g=r[11],m=r[12],v=r[13],y=r[14],b=r[15],T=n[0],E=n[1],x=n[2],A=n[3],M=n[4],P=n[5],C=n[6],S=n[7],I=n[8],O=n[9],R=n[10],D=n[11],w=n[12],L=n[13],F=n[14],N=n[15];return t[i]=o*T+s*M+a*I+h*w,t[i+1]=o*E+s*P+a*O+h*L,t[i+2]=o*x+s*C+a*R+h*F,t[i+3]=o*A+s*S+a*D+h*N,t[i+4]=u*T+l*M+c*I+f*w,t[i+5]=u*E+l*P+c*O+f*L,t[i+6]=u*x+l*C+c*R+f*F,t[i+7]=u*A+l*S+c*D+f*N,t[i+8]=d*T+p*M+_*I+g*w,t[i+9]=d*E+p*P+_*O+g*L,t[i+10]=d*x+p*C+_*R+g*F,t[i+11]=d*A+p*S+_*D+g*N,t[i+12]=m*T+v*M+y*I+b*w,t[i+13]=m*E+v*P+y*O+b*L,t[i+14]=m*x+v*C+y*R+b*F,t[i+15]=m*A+v*S+y*D+b*N,this},e.prototype.equals=function(e){var t=e;if(!t)return!1;if((this._isIdentity||t._isIdentity)&&!this._isIdentityDirty&&!t._isIdentityDirty)return this._isIdentity&&t._isIdentity;var i=this.m,r=t.m;return i[0]===r[0]&&i[1]===r[1]&&i[2]===r[2]&&i[3]===r[3]&&i[4]===r[4]&&i[5]===r[5]&&i[6]===r[6]&&i[7]===r[7]&&i[8]===r[8]&&i[9]===r[9]&&i[10]===r[10]&&i[11]===r[11]&&i[12]===r[12]&&i[13]===r[13]&&i[14]===r[14]&&i[15]===r[15]},e.prototype.clone=function(){var t=new e;return t.copyFrom(this),t},e.prototype.getClassName=function(){return"Matrix"},e.prototype.getHashCode=function(){for(var e=0|this._m[0],t=1;t<16;t++)e=397*e^(0|this._m[t]);return e},e.prototype.decompose=function(t,i,r){if(this._isIdentity)return r&&r.setAll(0),t&&t.setAll(1),i&&i.copyFromFloats(0,0,0,1),!0;var n=this._m;if(r&&r.copyFromFloats(n[12],n[13],n[14]),(t=t||v.Vector3[0]).x=Math.sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]),t.y=Math.sqrt(n[4]*n[4]+n[5]*n[5]+n[6]*n[6]),t.z=Math.sqrt(n[8]*n[8]+n[9]*n[9]+n[10]*n[10]),this.determinant()<=0&&(t.y*=-1),0===t._x||0===t._y||0===t._z)return i&&i.copyFromFloats(0,0,0,1),!1;if(i){var o=1/t._x,s=1/t._y,a=1/t._z;e.FromValuesToRef(n[0]*o,n[1]*o,n[2]*o,0,n[4]*s,n[5]*s,n[6]*s,0,n[8]*a,n[9]*a,n[10]*a,0,0,0,0,1,v.Matrix[0]),g.FromRotationMatrixToRef(v.Matrix[0],i)}return!0},e.prototype.getRow=function(e){if(e<0||e>3)return null;var t=4*e;return new _(this._m[t+0],this._m[t+1],this._m[t+2],this._m[t+3])},e.prototype.setRow=function(e,t){return this.setRowFromFloats(e,t.x,t.y,t.z,t.w)},e.prototype.transpose=function(){return e.Transpose(this)},e.prototype.transposeToRef=function(t){return e.TransposeToRef(this,t),this},e.prototype.setRowFromFloats=function(e,t,i,r,n){if(e<0||e>3)return this;var o=4*e;return this._m[o+0]=t,this._m[o+1]=i,this._m[o+2]=r,this._m[o+3]=n,this._markAsUpdated(),this},e.prototype.scale=function(t){var i=new e;return this.scaleToRef(t,i),i},e.prototype.scaleToRef=function(e,t){for(var i=0;i<16;i++)t._m[i]=this._m[i]*e;return t._markAsUpdated(),this},e.prototype.scaleAndAddToRef=function(e,t){for(var i=0;i<16;i++)t._m[i]+=this._m[i]*e;return t._markAsUpdated(),this},e.prototype.toNormalMatrix=function(t){var i=v.Matrix[0];this.invertToRef(i),i.transposeToRef(t);var r=t._m;e.FromValuesToRef(r[0],r[1],r[2],0,r[4],r[5],r[6],0,r[8],r[9],r[10],0,0,0,0,1,t)},e.prototype.getRotationMatrix=function(){var t=new e;return this.getRotationMatrixToRef(t),t},e.prototype.getRotationMatrixToRef=function(t){var i=v.Vector3[0];if(!this.decompose(i))return e.IdentityToRef(t),this;var r=this._m,n=1/i._x,o=1/i._y,s=1/i._z;return e.FromValuesToRef(r[0]*n,r[1]*n,r[2]*n,0,r[4]*o,r[5]*o,r[6]*o,0,r[8]*s,r[9]*s,r[10]*s,0,0,0,0,1,t),this},e.prototype.toggleModelMatrixHandInPlace=function(){var e=this._m;e[2]*=-1,e[6]*=-1,e[8]*=-1,e[9]*=-1,e[14]*=-1,this._markAsUpdated()},e.prototype.toggleProjectionMatrixHandInPlace=function(){var e=this._m;e[8]*=-1,e[9]*=-1,e[10]*=-1,e[11]*=-1,this._markAsUpdated()},e.FromArray=function(t,i){void 0===i&&(i=0);var r=new e;return e.FromArrayToRef(t,i,r),r},e.FromArrayToRef=function(e,t,i){for(var r=0;r<16;r++)i._m[r]=e[r+t];i._markAsUpdated()},e.FromFloat32ArrayToRefScaled=function(e,t,i,r){for(var n=0;n<16;n++)r._m[n]=e[n+t]*i;r._markAsUpdated()},Object.defineProperty(e,"IdentityReadOnly",{get:function(){return e._identityReadOnly},enumerable:!1,configurable:!0}),e.FromValuesToRef=function(e,t,i,r,n,o,s,a,h,u,l,c,f,d,p,_,g){var m=g._m;m[0]=e,m[1]=t,m[2]=i,m[3]=r,m[4]=n,m[5]=o,m[6]=s,m[7]=a,m[8]=h,m[9]=u,m[10]=l,m[11]=c,m[12]=f,m[13]=d,m[14]=p,m[15]=_,g._markAsUpdated()},e.FromValues=function(t,i,r,n,o,s,a,h,u,l,c,f,d,p,_,g){var m=new e,v=m._m;return v[0]=t,v[1]=i,v[2]=r,v[3]=n,v[4]=o,v[5]=s,v[6]=a,v[7]=h,v[8]=u,v[9]=l,v[10]=c,v[11]=f,v[12]=d,v[13]=p,v[14]=_,v[15]=g,m._markAsUpdated(),m},e.Compose=function(t,i,r){var n=new e;return e.ComposeToRef(t,i,r,n),n},e.ComposeToRef=function(e,t,i,r){var n=r._m,o=t._x,s=t._y,a=t._z,h=t._w,u=o+o,l=s+s,c=a+a,f=o*u,d=o*l,p=o*c,_=s*l,g=s*c,m=a*c,v=h*u,y=h*l,b=h*c,T=e._x,E=e._y,x=e._z;n[0]=(1-(_+m))*T,n[1]=(d+b)*T,n[2]=(p-y)*T,n[3]=0,n[4]=(d-b)*E,n[5]=(1-(f+m))*E,n[6]=(g+v)*E,n[7]=0,n[8]=(p+y)*x,n[9]=(g-v)*x,n[10]=(1-(f+_))*x,n[11]=0,n[12]=i._x,n[13]=i._y,n[14]=i._z,n[15]=1,r._markAsUpdated()},e.Identity=function(){var t=e.FromValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return t._updateIdentityStatus(!0),t},e.IdentityToRef=function(t){e.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,t),t._updateIdentityStatus(!0)},e.Zero=function(){var t=e.FromValues(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);return t._updateIdentityStatus(!1),t},e.RotationX=function(t){var i=new e;return e.RotationXToRef(t,i),i},e.Invert=function(t){var i=new e;return t.invertToRef(i),i},e.RotationXToRef=function(t,i){var r=Math.sin(t),n=Math.cos(t);e.FromValuesToRef(1,0,0,0,0,n,r,0,0,-r,n,0,0,0,0,1,i),i._updateIdentityStatus(1===n&&0===r)},e.RotationY=function(t){var i=new e;return e.RotationYToRef(t,i),i},e.RotationYToRef=function(t,i){var r=Math.sin(t),n=Math.cos(t);e.FromValuesToRef(n,0,-r,0,0,1,0,0,r,0,n,0,0,0,0,1,i),i._updateIdentityStatus(1===n&&0===r)},e.RotationZ=function(t){var i=new e;return e.RotationZToRef(t,i),i},e.RotationZToRef=function(t,i){var r=Math.sin(t),n=Math.cos(t);e.FromValuesToRef(n,r,0,0,-r,n,0,0,0,0,1,0,0,0,0,1,i),i._updateIdentityStatus(1===n&&0===r)},e.RotationAxis=function(t,i){var r=new e;return e.RotationAxisToRef(t,i,r),r},e.RotationAxisToRef=function(e,t,i){var r=Math.sin(-t),n=Math.cos(-t),o=1-n;e.normalize();var s=i._m;s[0]=e._x*e._x*o+n,s[1]=e._x*e._y*o-e._z*r,s[2]=e._x*e._z*o+e._y*r,s[3]=0,s[4]=e._y*e._x*o+e._z*r,s[5]=e._y*e._y*o+n,s[6]=e._y*e._z*o-e._x*r,s[7]=0,s[8]=e._z*e._x*o-e._y*r,s[9]=e._z*e._y*o+e._x*r,s[10]=e._z*e._z*o+n,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,i._markAsUpdated()},e.RotationAlignToRef=function(e,t,i){var r=p.Cross(t,e),n=p.Dot(t,e),o=1/(1+n),s=i._m;s[0]=r._x*r._x*o+n,s[1]=r._y*r._x*o-r._z,s[2]=r._z*r._x*o+r._y,s[3]=0,s[4]=r._x*r._y*o+r._z,s[5]=r._y*r._y*o+n,s[6]=r._z*r._y*o-r._x,s[7]=0,s[8]=r._x*r._z*o-r._y,s[9]=r._y*r._z*o+r._x,s[10]=r._z*r._z*o+n,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,i._markAsUpdated()},e.RotationYawPitchRoll=function(t,i,r){var n=new e;return e.RotationYawPitchRollToRef(t,i,r,n),n},e.RotationYawPitchRollToRef=function(e,t,i,r){g.RotationYawPitchRollToRef(e,t,i,v.Quaternion[0]),v.Quaternion[0].toRotationMatrix(r)},e.Scaling=function(t,i,r){var n=new e;return e.ScalingToRef(t,i,r,n),n},e.ScalingToRef=function(t,i,r,n){e.FromValuesToRef(t,0,0,0,0,i,0,0,0,0,r,0,0,0,0,1,n),n._updateIdentityStatus(1===t&&1===i&&1===r)},e.Translation=function(t,i,r){var n=new e;return e.TranslationToRef(t,i,r,n),n},e.TranslationToRef=function(t,i,r,n){e.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,t,i,r,1,n),n._updateIdentityStatus(0===t&&0===i&&0===r)},e.Lerp=function(t,i,r){var n=new e;return e.LerpToRef(t,i,r,n),n},e.LerpToRef=function(e,t,i,r){for(var n=r._m,o=e.m,s=t.m,a=0;a<16;a++)n[a]=o[a]*(1-i)+s[a]*i;r._markAsUpdated()},e.DecomposeLerp=function(t,i,r){var n=new e;return e.DecomposeLerpToRef(t,i,r,n),n},e.DecomposeLerpToRef=function(t,i,r,n){var o=v.Vector3[0],s=v.Quaternion[0],a=v.Vector3[1];t.decompose(o,s,a);var h=v.Vector3[2],u=v.Quaternion[1],l=v.Vector3[3];i.decompose(h,u,l);var c=v.Vector3[4];p.LerpToRef(o,h,r,c);var f=v.Quaternion[2];g.SlerpToRef(s,u,r,f);var d=v.Vector3[5];p.LerpToRef(a,l,r,d),e.ComposeToRef(c,f,d,n)},e.LookAtLH=function(t,i,r){var n=new e;return e.LookAtLHToRef(t,i,r,n),n},e.LookAtLHToRef=function(t,i,r,n){var o=v.Vector3[0],s=v.Vector3[1],a=v.Vector3[2];i.subtractToRef(t,a),a.normalize(),p.CrossToRef(r,a,o);var h=o.lengthSquared();0===h?o.x=1:o.normalizeFromLength(Math.sqrt(h)),p.CrossToRef(a,o,s),s.normalize();var u=-p.Dot(o,t),l=-p.Dot(s,t),c=-p.Dot(a,t);e.FromValuesToRef(o._x,s._x,a._x,0,o._y,s._y,a._y,0,o._z,s._z,a._z,0,u,l,c,1,n)},e.LookAtRH=function(t,i,r){var n=new e;return e.LookAtRHToRef(t,i,r,n),n},e.LookAtRHToRef=function(t,i,r,n){var o=v.Vector3[0],s=v.Vector3[1],a=v.Vector3[2];t.subtractToRef(i,a),a.normalize(),p.CrossToRef(r,a,o);var h=o.lengthSquared();0===h?o.x=1:o.normalizeFromLength(Math.sqrt(h)),p.CrossToRef(a,o,s),s.normalize();var u=-p.Dot(o,t),l=-p.Dot(s,t),c=-p.Dot(a,t);e.FromValuesToRef(o._x,s._x,a._x,0,o._y,s._y,a._y,0,o._z,s._z,a._z,0,u,l,c,1,n)},e.OrthoLH=function(t,i,r,n){var o=new e;return e.OrthoLHToRef(t,i,r,n,o),o},e.OrthoLHToRef=function(t,i,r,n,o){var s=2/t,a=2/i,h=2/(n-r),u=-(n+r)/(n-r);e.FromValuesToRef(s,0,0,0,0,a,0,0,0,0,h,0,0,0,u,1,o),o._updateIdentityStatus(1===s&&1===a&&1===h&&0===u)},e.OrthoOffCenterLH=function(t,i,r,n,o,s){var a=new e;return e.OrthoOffCenterLHToRef(t,i,r,n,o,s,a),a},e.OrthoOffCenterLHToRef=function(t,i,r,n,o,s,a){var h=2/(i-t),u=2/(n-r),l=2/(s-o),c=-(s+o)/(s-o),f=(t+i)/(t-i),d=(n+r)/(r-n);e.FromValuesToRef(h,0,0,0,0,u,0,0,0,0,l,0,f,d,c,1,a),a._markAsUpdated()},e.OrthoOffCenterRH=function(t,i,r,n,o,s){var a=new e;return e.OrthoOffCenterRHToRef(t,i,r,n,o,s,a),a},e.OrthoOffCenterRHToRef=function(t,i,r,n,o,s,a){e.OrthoOffCenterLHToRef(t,i,r,n,o,s,a),a._m[10]*=-1},e.PerspectiveLH=function(t,i,r,n){var o=new e,s=2*r/t,a=2*r/i,h=(n+r)/(n-r),u=-2*n*r/(n-r);return e.FromValuesToRef(s,0,0,0,0,a,0,0,0,0,h,1,0,0,u,0,o),o._updateIdentityStatus(!1),o},e.PerspectiveFovLH=function(t,i,r,n){var o=new e;return e.PerspectiveFovLHToRef(t,i,r,n,o),o},e.PerspectiveFovLHToRef=function(t,i,r,n,o,s){void 0===s&&(s=!0);var a=r,h=n,u=1/Math.tan(.5*t),l=s?u/i:u,c=s?u:u*i,f=(h+a)/(h-a),d=-2*h*a/(h-a);e.FromValuesToRef(l,0,0,0,0,c,0,0,0,0,f,1,0,0,d,0,o),o._updateIdentityStatus(!1)},e.PerspectiveFovReverseLHToRef=function(t,i,r,n,o,s){void 0===s&&(s=!0);var a=1/Math.tan(.5*t),h=s?a/i:a,u=s?a:a*i;e.FromValuesToRef(h,0,0,0,0,u,0,0,0,0,-r,1,0,0,1,0,o),o._updateIdentityStatus(!1)},e.PerspectiveFovRH=function(t,i,r,n){var o=new e;return e.PerspectiveFovRHToRef(t,i,r,n,o),o},e.PerspectiveFovRHToRef=function(t,i,r,n,o,s){void 0===s&&(s=!0);var a=r,h=n,u=1/Math.tan(.5*t),l=s?u/i:u,c=s?u:u*i,f=-(h+a)/(h-a),d=-2*h*a/(h-a);e.FromValuesToRef(l,0,0,0,0,c,0,0,0,0,f,-1,0,0,d,0,o),o._updateIdentityStatus(!1)},e.PerspectiveFovReverseRHToRef=function(t,i,r,n,o,s){void 0===s&&(s=!0);var a=1/Math.tan(.5*t),h=s?a/i:a,u=s?a:a*i;e.FromValuesToRef(h,0,0,0,0,u,0,0,0,0,-r,-1,0,0,-1,0,o),o._updateIdentityStatus(!1)},e.PerspectiveFovWebVRToRef=function(e,t,i,r,n){void 0===n&&(n=!1);var o=n?-1:1,s=Math.tan(e.upDegrees*Math.PI/180),a=Math.tan(e.downDegrees*Math.PI/180),h=Math.tan(e.leftDegrees*Math.PI/180),u=Math.tan(e.rightDegrees*Math.PI/180),l=2/(h+u),c=2/(s+a),f=r._m;f[0]=l,f[1]=f[2]=f[3]=f[4]=0,f[5]=c,f[6]=f[7]=0,f[8]=(h-u)*l*.5,f[9]=-(s-a)*c*.5,f[10]=-i/(t-i),f[11]=1*o,f[12]=f[13]=f[15]=0,f[14]=-2*i*t/(i-t),r._markAsUpdated()},e.GetFinalMatrix=function(t,i,r,n,o,s){var a=t.width,h=t.height,u=t.x,l=t.y,c=e.FromValues(a/2,0,0,0,0,-h/2,0,0,0,0,s-o,0,u+a/2,h/2+l,o,1),f=v.Matrix[0];return i.multiplyToRef(r,f),f.multiplyToRef(n,f),f.multiply(c)},e.GetAsMatrix2x2=function(e){var t=e.m,i=[t[0],t[1],t[4],t[5]];return f.MatrixUse64Bits?i:new Float32Array(i)},e.GetAsMatrix3x3=function(e){var t=e.m,i=[t[0],t[1],t[2],t[4],t[5],t[6],t[8],t[9],t[10]];return f.MatrixUse64Bits?i:new Float32Array(i)},e.Transpose=function(t){var i=new e;return e.TransposeToRef(t,i),i},e.TransposeToRef=function(e,t){var i=t._m,r=e.m;i[0]=r[0],i[1]=r[4],i[2]=r[8],i[3]=r[12],i[4]=r[1],i[5]=r[5],i[6]=r[9],i[7]=r[13],i[8]=r[2],i[9]=r[6],i[10]=r[10],i[11]=r[14],i[12]=r[3],i[13]=r[7],i[14]=r[11],i[15]=r[15],t._updateIdentityStatus(e._isIdentity,e._isIdentityDirty)},e.Reflection=function(t){var i=new e;return e.ReflectionToRef(t,i),i},e.ReflectionToRef=function(t,i){t.normalize();var r=t.normal.x,n=t.normal.y,o=t.normal.z,s=-2*r,a=-2*n,h=-2*o;e.FromValuesToRef(s*r+1,a*r,h*r,0,s*n,a*n+1,h*n,0,s*o,a*o,h*o+1,0,s*t.d,a*t.d,h*t.d,1,i)},e.FromXYZAxesToRef=function(t,i,r,n){e.FromValuesToRef(t._x,t._y,t._z,0,i._x,i._y,i._z,0,r._x,r._y,r._z,0,0,0,0,1,n)},e.FromQuaternionToRef=function(e,t){var i=e._x*e._x,r=e._y*e._y,n=e._z*e._z,o=e._x*e._y,s=e._z*e._w,a=e._z*e._x,h=e._y*e._w,u=e._y*e._z,l=e._x*e._w;t._m[0]=1-2*(r+n),t._m[1]=2*(o+s),t._m[2]=2*(a-h),t._m[3]=0,t._m[4]=2*(o-s),t._m[5]=1-2*(n+i),t._m[6]=2*(u+l),t._m[7]=0,t._m[8]=2*(a+h),t._m[9]=2*(u-l),t._m[10]=1-2*(r+i),t._m[11]=0,t._m[12]=0,t._m[13]=0,t._m[14]=0,t._m[15]=1,t._markAsUpdated()},e._updateFlagSeed=0,e._identityReadOnly=e.Identity(),e}(),v=function(){function e(){}return e.Vector3=l.BuildArray(6,p.Zero),e.Matrix=l.BuildArray(2,m.Identity),e.Quaternion=l.BuildArray(3,g.Zero),e}(),y=function(){function e(){}return e.Vector2=l.BuildArray(3,d.Zero),e.Vector3=l.BuildArray(13,p.Zero),e.Vector4=l.BuildArray(3,_.Zero),e.Quaternion=l.BuildArray(2,g.Zero),e.Matrix=l.BuildArray(8,m.Identity),e}();c.RegisteredTypes["BABYLON.Vector2"]=d,c.RegisteredTypes["BABYLON.Vector3"]=p,c.RegisteredTypes["BABYLON.Vector4"]=_,c.RegisteredTypes["BABYLON.Matrix"]=m;var b=function(){function e(){}return e.WarnImport=function(e){return e+" needs to be imported before as it contains a side-effect required by your code."},e}(),T=function(){function e(e,t,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),this.r=e,this.g=t,this.b=i}return e.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+"}"},e.prototype.getClassName=function(){return"Color3"},e.prototype.getHashCode=function(){var e=255*this.r|0;return e=397*(e=397*e^(255*this.g|0))^(255*this.b|0)},e.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,this},e.prototype.fromArray=function(t,i){return void 0===i&&(i=0),e.FromArrayToRef(t,i,this),this},e.prototype.toColor4=function(e){return void 0===e&&(e=1),new E(this.r,this.g,this.b,e)},e.prototype.asArray=function(){var e=new Array;return this.toArray(e,0),e},e.prototype.toLuminance=function(){return.3*this.r+.59*this.g+.11*this.b},e.prototype.multiply=function(t){return new e(this.r*t.r,this.g*t.g,this.b*t.b)},e.prototype.multiplyToRef=function(e,t){return t.r=this.r*e.r,t.g=this.g*e.g,t.b=this.b*e.b,this},e.prototype.equals=function(e){return e&&this.r===e.r&&this.g===e.g&&this.b===e.b},e.prototype.equalsFloats=function(e,t,i){return this.r===e&&this.g===t&&this.b===i},e.prototype.scale=function(t){return new e(this.r*t,this.g*t,this.b*t)},e.prototype.scaleToRef=function(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,this},e.prototype.scaleAndAddToRef=function(e,t){return t.r+=this.r*e,t.g+=this.g*e,t.b+=this.b*e,this},e.prototype.clampToRef=function(e,t,i){return void 0===e&&(e=0),void 0===t&&(t=1),i.r=s.Clamp(this.r,e,t),i.g=s.Clamp(this.g,e,t),i.b=s.Clamp(this.b,e,t),this},e.prototype.add=function(t){return new e(this.r+t.r,this.g+t.g,this.b+t.b)},e.prototype.addToRef=function(e,t){return t.r=this.r+e.r,t.g=this.g+e.g,t.b=this.b+e.b,this},e.prototype.subtract=function(t){return new e(this.r-t.r,this.g-t.g,this.b-t.b)},e.prototype.subtractToRef=function(e,t){return t.r=this.r-e.r,t.g=this.g-e.g,t.b=this.b-e.b,this},e.prototype.clone=function(){return new e(this.r,this.g,this.b)},e.prototype.copyFrom=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},e.prototype.copyFromFloats=function(e,t,i){return this.r=e,this.g=t,this.b=i,this},e.prototype.set=function(e,t,i){return this.copyFromFloats(e,t,i)},e.prototype.toHexString=function(){var e=255*this.r|0,t=255*this.g|0,i=255*this.b|0;return"#"+s.ToHex(e)+s.ToHex(t)+s.ToHex(i)},e.prototype.toLinearSpace=function(){var t=new e;return this.toLinearSpaceToRef(t),t},e.prototype.toHSV=function(){var t=new e;return this.toHSVToRef(t),t},e.prototype.toHSVToRef=function(e){var t=this.r,i=this.g,r=this.b,n=Math.max(t,i,r),o=Math.min(t,i,r),s=0,a=0,h=n,u=n-o;0!==n&&(a=u/n),n!=o&&(n==t?(s=(i-r)/u,i<r&&(s+=6)):n==i?s=(r-t)/u+2:n==r&&(s=(t-i)/u+4),s*=60),e.r=s,e.g=a,e.b=h},e.prototype.toLinearSpaceToRef=function(e){return e.r=Math.pow(this.r,h),e.g=Math.pow(this.g,h),e.b=Math.pow(this.b,h),this},e.prototype.toGammaSpace=function(){var t=new e;return this.toGammaSpaceToRef(t),t},e.prototype.toGammaSpaceToRef=function(e){return e.r=Math.pow(this.r,a),e.g=Math.pow(this.g,a),e.b=Math.pow(this.b,a),this},e.HSVtoRGBToRef=function(e,t,i,r){var n=i*t,o=e/60,s=n*(1-Math.abs(o%2-1)),a=0,h=0,u=0;o>=0&&o<=1?(a=n,h=s):o>=1&&o<=2?(a=s,h=n):o>=2&&o<=3?(h=n,u=s):o>=3&&o<=4?(h=s,u=n):o>=4&&o<=5?(a=s,u=n):o>=5&&o<=6&&(a=n,u=s);var l=i-n;r.set(a+l,h+l,u+l)},e.FromHexString=function(t){if("#"!==t.substring(0,1)||7!==t.length)return new e(0,0,0);var i=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),n=parseInt(t.substring(5,7),16);return e.FromInts(i,r,n)},e.FromArray=function(t,i){return void 0===i&&(i=0),new e(t[i],t[i+1],t[i+2])},e.FromArrayToRef=function(e,t,i){void 0===t&&(t=0),i.r=e[t],i.g=e[t+1],i.b=e[t+2]},e.FromInts=function(t,i,r){return new e(t/255,i/255,r/255)},e.Lerp=function(t,i,r){var n=new e(0,0,0);return e.LerpToRef(t,i,r,n),n},e.LerpToRef=function(e,t,i,r){r.r=e.r+(t.r-e.r)*i,r.g=e.g+(t.g-e.g)*i,r.b=e.b+(t.b-e.b)*i},e.Red=function(){return new e(1,0,0)},e.Green=function(){return new e(0,1,0)},e.Blue=function(){return new e(0,0,1)},e.Black=function(){return new e(0,0,0)},Object.defineProperty(e,"BlackReadOnly",{get:function(){return e._BlackReadOnly},enumerable:!1,configurable:!0}),e.White=function(){return new e(1,1,1)},e.Purple=function(){return new e(.5,0,.5)},e.Magenta=function(){return new e(1,0,1)},e.Yellow=function(){return new e(1,1,0)},e.Gray=function(){return new e(.5,.5,.5)},e.Teal=function(){return new e(0,1,1)},e.Random=function(){return new e(Math.random(),Math.random(),Math.random())},e._BlackReadOnly=e.Black(),e}(),E=function(){function e(e,t,i,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=1),this.r=e,this.g=t,this.b=i,this.a=r}return e.prototype.addInPlace=function(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this.a+=e.a,this},e.prototype.asArray=function(){var e=new Array;return this.toArray(e,0),e},e.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e[t+3]=this.a,this},e.prototype.fromArray=function(t,i){return void 0===i&&(i=0),e.FromArrayToRef(t,i,this),this},e.prototype.equals=function(e){return e&&this.r===e.r&&this.g===e.g&&this.b===e.b&&this.a===e.a},e.prototype.add=function(t){return new e(this.r+t.r,this.g+t.g,this.b+t.b,this.a+t.a)},e.prototype.subtract=function(t){return new e(this.r-t.r,this.g-t.g,this.b-t.b,this.a-t.a)},e.prototype.subtractToRef=function(e,t){return t.r=this.r-e.r,t.g=this.g-e.g,t.b=this.b-e.b,t.a=this.a-e.a,this},e.prototype.scale=function(t){return new e(this.r*t,this.g*t,this.b*t,this.a*t)},e.prototype.scaleToRef=function(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,t.a=this.a*e,this},e.prototype.scaleAndAddToRef=function(e,t){return t.r+=this.r*e,t.g+=this.g*e,t.b+=this.b*e,t.a+=this.a*e,this},e.prototype.clampToRef=function(e,t,i){return void 0===e&&(e=0),void 0===t&&(t=1),i.r=s.Clamp(this.r,e,t),i.g=s.Clamp(this.g,e,t),i.b=s.Clamp(this.b,e,t),i.a=s.Clamp(this.a,e,t),this},e.prototype.multiply=function(t){return new e(this.r*t.r,this.g*t.g,this.b*t.b,this.a*t.a)},e.prototype.multiplyToRef=function(e,t){return t.r=this.r*e.r,t.g=this.g*e.g,t.b=this.b*e.b,t.a=this.a*e.a,t},e.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+" A:"+this.a+"}"},e.prototype.getClassName=function(){return"Color4"},e.prototype.getHashCode=function(){var e=255*this.r|0;return e=397*(e=397*(e=397*e^(255*this.g|0))^(255*this.b|0))^(255*this.a|0)},e.prototype.clone=function(){return new e(this.r,this.g,this.b,this.a)},e.prototype.copyFrom=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this.a=e.a,this},e.prototype.copyFromFloats=function(e,t,i,r){return this.r=e,this.g=t,this.b=i,this.a=r,this},e.prototype.set=function(e,t,i,r){return this.copyFromFloats(e,t,i,r)},e.prototype.toHexString=function(e){void 0===e&&(e=!1);var t=255*this.r|0,i=255*this.g|0,r=255*this.b|0;if(e)return"#"+s.ToHex(t)+s.ToHex(i)+s.ToHex(r);var n=255*this.a|0;return"#"+s.ToHex(t)+s.ToHex(i)+s.ToHex(r)+s.ToHex(n)},e.prototype.toLinearSpace=function(){var t=new e;return this.toLinearSpaceToRef(t),t},e.prototype.toLinearSpaceToRef=function(e){return e.r=Math.pow(this.r,h),e.g=Math.pow(this.g,h),e.b=Math.pow(this.b,h),e.a=this.a,this},e.prototype.toGammaSpace=function(){var t=new e;return this.toGammaSpaceToRef(t),t},e.prototype.toGammaSpaceToRef=function(e){return e.r=Math.pow(this.r,a),e.g=Math.pow(this.g,a),e.b=Math.pow(this.b,a),e.a=this.a,this},e.FromHexString=function(t){if("#"!==t.substring(0,1)||9!==t.length)return new e(0,0,0,0);var i=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),n=parseInt(t.substring(5,7),16),o=parseInt(t.substring(7,9),16);return e.FromInts(i,r,n,o)},e.Lerp=function(t,i,r){var n=new e(0,0,0,0);return e.LerpToRef(t,i,r,n),n},e.LerpToRef=function(e,t,i,r){r.r=e.r+(t.r-e.r)*i,r.g=e.g+(t.g-e.g)*i,r.b=e.b+(t.b-e.b)*i,r.a=e.a+(t.a-e.a)*i},e.FromColor3=function(t,i){return void 0===i&&(i=1),new e(t.r,t.g,t.b,i)},e.FromArray=function(t,i){return void 0===i&&(i=0),new e(t[i],t[i+1],t[i+2],t[i+3])},e.FromArrayToRef=function(e,t,i){void 0===t&&(t=0),i.r=e[t],i.g=e[t+1],i.b=e[t+2],i.a=e[t+3]},e.FromInts=function(t,i,r,n){return new e(t/255,i/255,r/255,n/255)},e.CheckColors4=function(e,t){if(e.length===3*t){for(var i=[],r=0;r<e.length;r+=3){var n=r/3*4;i[n]=e[r],i[n+1]=e[r+1],i[n+2]=e[r+2],i[n+3]=1}return i}return e},e}(),x=function(){function e(){}return e.Color3=l.BuildArray(3,T.Black),e.Color4=l.BuildArray(3,(function(){return new E(0,0,0,0)})),e}();c.RegisteredTypes["BABYLON.Color3"]=T,c.RegisteredTypes["BABYLON.Color4"]=E;var A={},M={},P=function(e,t,i){var r=e();o&&o.AddTagsTo(r,t.tags);var n=C(r);for(var s in n){var a=n[s],h=t[s],u=a.type;if(null!=h&&"uniqueId"!==s)switch(u){case 0:case 6:case 11:r[s]=h;break;case 1:r[s]=i||h.isRenderTarget?h:h.clone();break;case 2:case 3:case 4:case 5:case 7:case 10:case 12:r[s]=i?h:h.clone()}}return r};function C(e){var t=e.getClassName();if(M[t])return M[t];M[t]={};for(var i=M[t],r=e,n=t;n;){var o=A[n];for(var s in o)i[s]=o[s];var a=void 0,h=!1;do{if(!(a=Object.getPrototypeOf(r)).getClassName){h=!0;break}if(a.getClassName()!==n)break;r=a}while(a);if(h)break;n=a.getClassName(),r=a}return i}function S(e,t){return function(i,r){var n=function(e){var t=e.getClassName();return A[t]||(A[t]={}),A[t]}(i);n[r]||(n[r]={type:e,sourceName:t})}}function I(e,t){return void 0===t&&(t=null),function(e,t){return void 0===t&&(t=null),function(i,r){var n=t||"_"+r;Object.defineProperty(i,r,{get:function(){return this[n]},set:function(t){this[n]!==t&&(this[n]=t,i[e].apply(this))},enumerable:!0,configurable:!0})}}(e,t)}function O(e){return S(0,e)}function R(e){return S(1,e)}function D(e){return S(2,e)}function w(e){return S(3,e)}function L(e){return S(5,e)}function F(e){return S(8,e)}var N=function(){function e(){}return e.AppendSerializedAnimations=function(e,t){if(e.animations){t.animations=[];for(var i=0;i<e.animations.length;i++){var r=e.animations[i];t.animations.push(r.serialize())}}},e.Serialize=function(e,t){t||(t={}),o&&(t.tags=o.GetTags(e));var i=C(e);for(var r in i){var n=i[r],s=n.sourceName||r,a=n.type,h=e[r];if(null!=h&&"uniqueId"!==r)switch(a){case 0:t[s]=h;break;case 1:t[s]=h.serialize();break;case 2:t[s]=h.asArray();break;case 3:t[s]=h.serialize();break;case 4:case 5:t[s]=h.asArray();break;case 6:t[s]=h.id;break;case 7:t[s]=h.serialize();break;case 8:t[s]=h.asArray();break;case 9:t[s]=h.serialize();break;case 10:t[s]=h.asArray();break;case 11:t[s]=h.id;case 12:t[s]=h.asArray()}}return t},e.Parse=function(t,i,r,n){void 0===n&&(n=null);var s=t();n||(n=""),o&&o.AddTagsTo(s,i.tags);var a=C(s);for(var h in a){var u=a[h],l=i[u.sourceName||h],c=u.type;if(null!=l&&"uniqueId"!==h){var f=s;switch(c){case 0:f[h]=l;break;case 1:r&&(f[h]=e._TextureParser(l,r,n));break;case 2:f[h]=T.FromArray(l);break;case 3:f[h]=e._FresnelParametersParser(l);break;case 4:f[h]=d.FromArray(l);break;case 5:f[h]=p.FromArray(l);break;case 6:r&&(f[h]=r.getLastMeshByID(l));break;case 7:f[h]=e._ColorCurvesParser(l);break;case 8:f[h]=E.FromArray(l);break;case 9:f[h]=e._ImageProcessingConfigurationParser(l);break;case 10:f[h]=g.FromArray(l);break;case 11:r&&(f[h]=r.getCameraByID(l));case 12:f[h]=m.FromArray(l)}}}return s},e.Clone=function(e,t){return P(e,t,!1)},e.Instanciate=function(e,t){return P(e,t,!0)},e._ImageProcessingConfigurationParser=function(e){throw b.WarnImport("ImageProcessingConfiguration")},e._FresnelParametersParser=function(e){throw b.WarnImport("FresnelParameters")},e._ColorCurvesParser=function(e){throw b.WarnImport("ColorCurves")},e._TextureParser=function(e,t,i){throw b.WarnImport("Texture")},e}(),B=function(){function e(e,t,i,r){void 0===t&&(t=!1),this.initalize(e,t,i,r)}return e.prototype.initalize=function(e,t,i,r){return void 0===t&&(t=!1),this.mask=e,this.skipNextObservers=t,this.target=i,this.currentTarget=r,this},e}(),k=function(e,t,i){void 0===i&&(i=null),this.callback=e,this.mask=t,this.scope=i,this._willBeUnregistered=!1,this.unregisterOnNextCall=!1},U=function(){function e(e){this._observers=new Array,this._eventState=new B(0),e&&(this._onObserverAdded=e)}return Object.defineProperty(e.prototype,"observers",{get:function(){return this._observers},enumerable:!1,configurable:!0}),e.prototype.add=function(e,t,i,r,n){if(void 0===t&&(t=-1),void 0===i&&(i=!1),void 0===r&&(r=null),void 0===n&&(n=!1),!e)return null;var o=new k(e,t,r);return o.unregisterOnNextCall=n,i?this._observers.unshift(o):this._observers.push(o),this._onObserverAdded&&this._onObserverAdded(o),o},e.prototype.addOnce=function(e){return this.add(e,void 0,void 0,void 0,!0)},e.prototype.remove=function(e){return!!e&&(-1!==this._observers.indexOf(e)&&(this._deferUnregister(e),!0))},e.prototype.removeCallback=function(e,t){for(var i=0;i<this._observers.length;i++){var r=this._observers[i];if(!r._willBeUnregistered&&(r.callback===e&&(!t||t===r.scope)))return this._deferUnregister(r),!0}return!1},e.prototype._deferUnregister=function(e){var t=this;e.unregisterOnNextCall=!1,e._willBeUnregistered=!0,setTimeout((function(){t._remove(e)}),0)},e.prototype._remove=function(e){if(!e)return!1;var t=this._observers.indexOf(e);return-1!==t&&(this._observers.splice(t,1),!0)},e.prototype.makeObserverTopPriority=function(e){this._remove(e),this._observers.unshift(e)},e.prototype.makeObserverBottomPriority=function(e){this._remove(e),this._observers.push(e)},e.prototype.notifyObservers=function(e,t,i,r,n){if(void 0===t&&(t=-1),!this._observers.length)return!0;var o=this._eventState;o.mask=t,o.target=i,o.currentTarget=r,o.skipNextObservers=!1,o.lastReturnValue=e,o.userInfo=n;for(var s=0,a=this._observers;s<a.length;s++){var h=a[s];if(!h._willBeUnregistered&&(h.mask&t&&(h.scope?o.lastReturnValue=h.callback.apply(h.scope,[e,o]):o.lastReturnValue=h.callback(e,o),h.unregisterOnNextCall&&this._deferUnregister(h)),o.skipNextObservers))return!1}return!0},e.prototype.notifyObserversWithPromise=function(e,t,i,r,n){var o=this;void 0===t&&(t=-1);var s=Promise.resolve(e);if(!this._observers.length)return s;var a=this._eventState;return a.mask=t,a.target=i,a.currentTarget=r,a.skipNextObservers=!1,a.userInfo=n,this._observers.forEach((function(i){a.skipNextObservers||i._willBeUnregistered||i.mask&t&&(s=i.scope?s.then((function(t){return a.lastReturnValue=t,i.callback.apply(i.scope,[e,a])})):s.then((function(t){return a.lastReturnValue=t,i.callback(e,a)})),i.unregisterOnNextCall&&o._deferUnregister(i))})),s.then((function(){return e}))},e.prototype.notifyObserver=function(e,t,i){void 0===i&&(i=-1);var r=this._eventState;r.mask=i,r.skipNextObservers=!1,e.callback(t,r)},e.prototype.hasObservers=function(){return this._observers.length>0},e.prototype.clear=function(){this._observers=new Array,this._onObserverAdded=null},e.prototype.clone=function(){var t=new e;return t._observers=this._observers.slice(0),t},e.prototype.hasSpecificMask=function(e){void 0===e&&(e=-1);for(var t=0,i=this._observers;t<i.length;t++){var r=i[t];if(r.mask&e||r.mask===e)return!0}return!1},e}(),V=function(){function e(){}return Object.defineProperty(e,"LastCreatedEngine",{get:function(){return 0===this.Instances.length?null:this.Instances[this.Instances.length-1]},enumerable:!1,configurable:!0}),Object.defineProperty(e,"LastCreatedScene",{get:function(){return this._LastCreatedScene},enumerable:!1,configurable:!0}),e.Instances=new Array,e._LastCreatedScene=null,e.UseFallbackTexture=!0,e.FallbackTexture="",e}(),W=function(){function e(){}return e.RandomId=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))},e}();var z,G=function(){function e(){this._xhr="undefined"!=typeof _native&&_native.XMLHttpRequest?new _native.XMLHttpRequest:new XMLHttpRequest}return e.prototype._injectCustomRequestHeaders=function(){for(var t in e.CustomRequestHeaders){var i=e.CustomRequestHeaders[t];i&&this._xhr.setRequestHeader(t,i)}},Object.defineProperty(e.prototype,"onprogress",{get:function(){return this._xhr.onprogress},set:function(e){this._xhr.onprogress=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"readyState",{get:function(){return this._xhr.readyState},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"status",{get:function(){return this._xhr.status},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"statusText",{get:function(){return this._xhr.statusText},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"response",{get:function(){return this._xhr.response},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"responseURL",{get:function(){return this._xhr.responseURL},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"responseText",{get:function(){return this._xhr.responseText},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"responseType",{get:function(){return this._xhr.responseType},set:function(e){this._xhr.responseType=e},enumerable:!1,configurable:!0}),e.prototype.addEventListener=function(e,t,i){this._xhr.addEventListener(e,t,i)},e.prototype.removeEventListener=function(e,t,i){this._xhr.removeEventListener(e,t,i)},e.prototype.abort=function(){this._xhr.abort()},e.prototype.send=function(t){e.CustomRequestHeaders&&this._injectCustomRequestHeaders(),this._xhr.send(t)},e.prototype.open=function(t,i){for(var r=0,n=e.CustomRequestModifiers;r<n.length;r++){(0,n[r])(this._xhr,i)}return i=(i=i.replace("file:http:","http:")).replace("file:https:","https:"),this._xhr.open(t,i,!0)},e.prototype.setRequestHeader=function(e,t){this._xhr.setRequestHeader(e,t)},e.prototype.getResponseHeader=function(e){return this._xhr.getResponseHeader(e)},e.CustomRequestHeaders={},e.CustomRequestModifiers=new Array,e}(),H=function(){function e(){}return e.IsWindowObjectExist=function(){return"undefined"!=typeof window},e.IsNavigatorAvailable=function(){return"undefined"!=typeof navigator},e.IsDocumentAvailable=function(){return"undefined"!=typeof document},e.GetDOMTextContent=function(e){for(var t="",i=e.firstChild;i;)3===i.nodeType&&(t+=i.textContent),i=i.nextSibling;return t},e}(),X=function(){function e(){}return e.FilesToLoad={},e}(),j=function(){function e(){}return e.ExponentialBackoff=function(e,t){return void 0===e&&(e=3),void 0===t&&(t=500),function(i,r,n){return 0!==r.status||n>=e||-1!==i.indexOf("file:")?-1:Math.pow(2,n)*t}},e}(),K=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t(i,e),i._setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},i}(Error),Y=function(){function e(){}return e.EndsWith=function(e,t){return-1!==e.indexOf(t,e.length-t.length)},e.StartsWith=function(e,t){return!!e&&0===e.indexOf(t)},e.Decode=function(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);for(var t="",i=0;i<e.byteLength;i++)t+=String.fromCharCode(e[i]);return t},e.EncodeArrayBufferToBase64=function(e){for(var t,i,r,n,o,s,a,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",u="",l=0,c=ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e);l<c.length;)n=(t=c[l++])>>2,o=(3&t)<<4|(i=l<c.length?c[l++]:Number.NaN)>>4,s=(15&i)<<2|(r=l<c.length?c[l++]:Number.NaN)>>6,a=63&r,isNaN(i)?s=a=64:isNaN(r)&&(a=64),u+=h.charAt(n)+h.charAt(o)+h.charAt(s)+h.charAt(a);return u},e.PadNumber=function(e,t){for(var i=String(e);i.length<t;)i="0"+i;return i},e}(),q=function(){function e(){}return e._AddLogEntry=function(t){e._LogCache=t+e._LogCache,e.OnNewCacheEntry&&e.OnNewCacheEntry(t)},e._FormatMessage=function(e){var t=function(e){return e<10?"0"+e:""+e},i=new Date;return"["+t(i.getHours())+":"+t(i.getMinutes())+":"+t(i.getSeconds())+"]: "+e},e._LogDisabled=function(e){},e._LogEnabled=function(t){var i="<div style='color:white'>"+e._FormatMessage(t)+"</div><br>";e._AddLogEntry(i)},e._WarnDisabled=function(e){},e._WarnEnabled=function(t){var i="<div style='color:orange'>"+e._FormatMessage(t)+"</div><br>";e._AddLogEntry(i)},e._ErrorDisabled=function(e){},e._ErrorEnabled=function(t){e.errorsCount++;var i="<div style='color:red'>"+e._FormatMessage(t)+"</div><br>";e._AddLogEntry(i)},Object.defineProperty(e,"LogCache",{get:function(){return e._LogCache},enumerable:!1,configurable:!0}),e.ClearLogCache=function(){e._LogCache="",e.errorsCount=0},Object.defineProperty(e,"LogLevels",{set:function(t){(t&e.MessageLogLevel)===e.MessageLogLevel?e.Log=e._LogEnabled:e.Log=e._LogDisabled,(t&e.WarningLogLevel)===e.WarningLogLevel?e.Warn=e._WarnEnabled:e.Warn=e._WarnDisabled,(t&e.ErrorLogLevel)===e.ErrorLogLevel?e.Error=e._ErrorEnabled:e.Error=e._ErrorDisabled},enumerable:!1,configurable:!0}),e.NoneLogLevel=0,e.MessageLogLevel=1,e.WarningLogLevel=2,e.ErrorLogLevel=4,e.AllLogLevel=7,e._LogCache="",e.errorsCount=0,e.Log=e._LogEnabled,e.Warn=e._WarnEnabled,e.Error=e._ErrorEnabled,e}(),Z=function(){function e(){this.children=[]}return e.prototype.isValid=function(e){return!0},e.prototype.process=function(e,t){var i="";if(this.line){var r=this.line,n=t.processor;if(n){if(n.lineProcessor&&(r=n.lineProcessor(r,t.isFragment)),n.attributeProcessor&&Y.StartsWith(this.line,"attribute"))r=n.attributeProcessor(this.line);else if(n.varyingProcessor&&Y.StartsWith(this.line,"varying"))r=n.varyingProcessor(this.line,t.isFragment);else if((n.uniformProcessor||n.uniformBufferProcessor)&&Y.StartsWith(this.line,"uniform")){/uniform (.+) (.+)/.test(this.line)?n.uniformProcessor&&(r=n.uniformProcessor(this.line,t.isFragment)):n.uniformBufferProcessor&&(r=n.uniformBufferProcessor(this.line,t.isFragment),t.lookForClosingBracketForUniformBuffer=!0)}n.endOfUniformBufferProcessor&&t.lookForClosingBracketForUniformBuffer&&-1!==this.line.indexOf("}")&&(t.lookForClosingBracketForUniformBuffer=!1,r=n.endOfUniformBufferProcessor(this.line,t.isFragment))}i+=r+"\r\n"}return this.children.forEach((function(r){i+=r.process(e,t)})),this.additionalDefineKey&&(e[this.additionalDefineKey]=this.additionalDefineValue||"true"),i},e}(),Q=function(){function e(){}return Object.defineProperty(e.prototype,"currentLine",{get:function(){return this._lines[this.lineIndex]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"canRead",{get:function(){return this.lineIndex<this._lines.length-1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lines",{set:function(e){this._lines=[];for(var t=0,i=e;t<i.length;t++){var r=i[t];if("#"!==r[0])for(var n=r.split(";"),o=0;o<n.length;o++){var s=n[o];(s=s.trim())&&this._lines.push(s+(o!==n.length-1?";":""))}else this._lines.push(r)}},enumerable:!1,configurable:!0}),e}(),J=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t(i,e),i.prototype.process=function(e,t){for(var i=0;i<this.children.length;i++){var r=this.children[i];if(r.isValid(e))return r.process(e,t)}return""},i}(Z),$=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t(i,e),i.prototype.isValid=function(e){return this.testExpression.isTrue(e)},i}(Z),ee=function(){function e(){}return e.prototype.isTrue=function(e){return!0},e.postfixToInfix=function(t){for(var i=[],r=0,n=t;r<n.length;r++){var o=n[r];if(void 0===e._OperatorPriority[o])i.push(o);else{var s=i[i.length-1],a=i[i.length-2];i.length-=2,i.push("("+a+o+s+")")}}return i[i.length-1]},e.infixToPostfix=function(t){for(var i=[],r=-1,n=function(){""!==(u=u.trim())&&(i.push(u),u="")},o=function(t){r<e._Stack.length-1&&(e._Stack[++r]=t)},s=function(){return e._Stack[r]},a=function(){return-1===r?"!!INVALID EXPRESSION!!":e._Stack[r--]},h=0,u="";h<t.length;){var l=t.charAt(h),c=h<t.length-1?t.substr(h,2):"";if("("===l)u="",o(l);else if(")"===l){for(n();-1!==r&&"("!==s();)i.push(a());a()}else if(e._OperatorPriority[c]>1){for(n();-1!==r&&e._OperatorPriority[s()]>=e._OperatorPriority[c];)i.push(a());o(c),h++}else u+=l;h++}for(n();-1!==r;)"("===s()?a():i.push(a());return i},e._OperatorPriority={")":0,"(":1,"||":2,"&&":3},e._Stack=["","","","","","","","","","","","","","","","","","","",""],e}(),te=function(e){function i(t,i){void 0===i&&(i=!1);var r=e.call(this)||this;return r.define=t,r.not=i,r}return t(i,e),i.prototype.isTrue=function(e){var t=void 0!==e[this.define];return this.not&&(t=!t),t},i}(ee),ie=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t(i,e),i.prototype.isTrue=function(e){return this.leftOperand.isTrue(e)||this.rightOperand.isTrue(e)},i}(ee),re=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t(i,e),i.prototype.isTrue=function(e){return this.leftOperand.isTrue(e)&&this.rightOperand.isTrue(e)},i}(ee),ne=function(e){function i(t,i,r){var n=e.call(this)||this;return n.define=t,n.operand=i,n.testValue=r,n}return t(i,e),i.prototype.isTrue=function(e){var t=e[this.define];void 0===t&&(t=this.define);var i=!1,r=parseInt(t),n=parseInt(this.testValue);switch(this.operand){case">":i=r>n;break;case"<":i=r<n;break;case"<=":i=r<=n;break;case">=":i=r>=n;break;case"==":i=r===n}return i},i}(ee),oe=/defined\s*?\((.+?)\)/g,se=/defined\s*?\[(.+?)\]/g,ae=function(){function e(){}return e.Process=function(e,t,i,r){var n=this;this._ProcessIncludes(e,t,(function(e){var o=n._ProcessShaderConversion(e,t,r);i(o)}))},e._ProcessPrecision=function(e,t){var i=t.shouldUseHighPrecisionShader;return-1===e.indexOf("precision highp float")?e=i?"precision highp float;\n"+e:"precision mediump float;\n"+e:i||(e=e.replace("precision highp float","precision mediump float")),e},e._ExtractOperation=function(e){var t=/defined\((.+)\)/.exec(e);if(t&&t.length)return new te(t[1].trim(),"!"===e[0]);for(var i="",r=0,n=0,o=["==",">=","<=","<",">"];n<o.length&&(i=o[n],!((r=e.indexOf(i))>-1));n++);if(-1===r)return new te(e);var s=e.substring(0,r).trim(),a=e.substring(r+i.length).trim();return new ne(s,i,a)},e._BuildSubExpression=function(e){e=e.replace(oe,"defined[$1]");for(var t=[],i=0,r=ee.infixToPostfix(e);i<r.length;i++){var n=r[i];if("||"!==n&&"&&"!==n)t.push(n);else if(t.length>=2){var o=t[t.length-1],s=t[t.length-2];t.length-=2;var a="&&"==n?new re:new ie;"string"==typeof o&&(o=o.replace(se,"defined($1)")),"string"==typeof s&&(s=s.replace(se,"defined($1)")),a.leftOperand="string"==typeof s?this._ExtractOperation(s):s,a.rightOperand="string"==typeof o?this._ExtractOperation(o):o,t.push(a)}}var h=t[t.length-1];return"string"==typeof h&&(h=h.replace(se,"defined($1)")),"string"==typeof h?this._ExtractOperation(h):h},e._BuildExpression=function(e,t){var i=new $,r=e.substring(0,t),n=e.substring(t);return n=n.substring(0,(n.indexOf("//")+1||n.length+1)-1).trim(),i.testExpression="#ifdef"===r?new te(n):"#ifndef"===r?new te(n,!0):this._BuildSubExpression(n),i},e._MoveCursorWithinIf=function(e,t,i){for(var r=e.currentLine;this._MoveCursor(e,i);){var n=(r=e.currentLine).substring(0,5).toLowerCase();if("#else"===n){var o=new Z;return t.children.push(o),void this._MoveCursor(e,o)}if("#elif"===n){var s=this._BuildExpression(r,5);t.children.push(s),i=s}}},e._MoveCursor=function(e,t){for(;e.canRead;){e.lineIndex++;var i=e.currentLine,r=/(#ifdef)|(#else)|(#elif)|(#endif)|(#ifndef)|(#if)/.exec(i);if(r&&r.length){switch(r[0]){case"#ifdef":var n=new J;t.children.push(n);var o=this._BuildExpression(i,6);n.children.push(o),this._MoveCursorWithinIf(e,n,o);break;case"#else":case"#elif":return!0;case"#endif":return!1;case"#ifndef":n=new J;t.children.push(n);o=this._BuildExpression(i,7);n.children.push(o),this._MoveCursorWithinIf(e,n,o);break;case"#if":n=new J,o=this._BuildExpression(i,3);t.children.push(n),n.children.push(o),this._MoveCursorWithinIf(e,n,o)}}else{var s=new Z;if(s.line=i,t.children.push(s),"#"===i[0]&&"d"===i[1]){var a=i.replace(";","").split(" ");s.additionalDefineKey=a[1],3===a.length&&(s.additionalDefineValue=a[2])}}}return!1},e._EvaluatePreProcessors=function(e,t,i){var r=new Z,n=new Q;return n.lineIndex=-1,n.lines=e.split("\n"),this._MoveCursor(n,r),r.process(t,i)},e._PreparePreProcessors=function(e){for(var t={},i=0,r=e.defines;i<r.length;i++){var n=r[i].replace("#define","").replace(";","").trim().split(" ");t[n[0]]=n.length>1?n[1]:""}return t.GL_ES="true",t.__VERSION__=e.version,t[e.platformName]="true",t},e._ProcessShaderConversion=function(e,t,i){var r=this._ProcessPrecision(e,t);if(!t.processor)return r;if(-1!==r.indexOf("#version 3"))return r.replace("#version 300 es","");var n=t.defines,o=this._PreparePreProcessors(t);return t.processor.preProcessor&&(r=t.processor.preProcessor(r,n,t.isFragment)),r=this._EvaluatePreProcessors(r,o,t),t.processor.postProcessor&&(r=t.processor.postProcessor(r,n,t.isFragment,i)),r},e._ProcessIncludes=function(t,i,r){for(var n=this,o=/#include<(.+)>(\((.*)\))*(\[(.*)\])*/g,s=o.exec(t),a=new String(t),h=!1;null!=s;){var u=s[1];if(-1!==u.indexOf("__decl__")&&(u=u.replace(/__decl__/,""),i.supportsUniformBuffers&&(u=(u=u.replace(/Vertex/,"Ubo")).replace(/Fragment/,"Ubo")),u+="Declaration"),!i.includesShadersStore[u]){var l=i.shadersRepository+"ShadersInclude/"+u+".fx";return void e._FileToolsLoadFile(l,(function(e){i.includesShadersStore[u]=e,n._ProcessIncludes(a,i,r)}))}var c=i.includesShadersStore[u];if(s[2])for(var f=s[3].split(","),d=0;d<f.length;d+=2){var p=new RegExp(f[d],"g"),_=f[d+1];c=c.replace(p,_)}if(s[4]){var g=s[5];if(-1!==g.indexOf("..")){var m=g.split(".."),v=parseInt(m[0]),y=parseInt(m[1]),b=c.slice(0);c="",isNaN(y)&&(y=i.indexParameters[m[1]]);for(var T=v;T<y;T++)i.supportsUniformBuffers||(b=b.replace(/light\{X\}.(\w*)/g,(function(e,t){return t+"{X}"}))),c+=b.replace(/\{X\}/g,T.toString())+"\n"}else i.supportsUniformBuffers||(c=c.replace(/light\{X\}.(\w*)/g,(function(e,t){return t+"{X}"}))),c=c.replace(/\{X\}/g,g)}a=a.replace(s[0],c),h=h||c.indexOf("#include<")>=0,s=o.exec(t)}h?this._ProcessIncludes(a.toString(),i,r):r(a)},e._FileToolsLoadFile=function(e,t,i,r,n,o){throw b.WarnImport("FileTools")},e}(),he=function(){function e(t,i,r,n,o,s,a,h,u,l){var c,f=this;void 0===n&&(n=null),void 0===s&&(s=null),void 0===a&&(a=null),void 0===h&&(h=null),void 0===u&&(u=null),this.name=null,this.defines="",this.onCompiled=null,this.onError=null,this.onBind=null,this.uniqueId=0,this.onCompileObservable=new U,this.onErrorObservable=new U,this._onBindObservable=null,this._wasPreviouslyReady=!1,this._bonesComputationForcedToCPU=!1,this._multiTarget=!1,this._uniformBuffersNames={},this._samplers={},this._isReady=!1,this._compilationError="",this._allFallbacksProcessed=!1,this._uniforms={},this._key="",this._fallbacks=null,this._vertexSourceCode="",this._fragmentSourceCode="",this._vertexSourceCodeOverride="",this._fragmentSourceCodeOverride="",this._transformFeedbackVaryings=null,this._rawVertexSourceCode="",this._rawFragmentSourceCode="",this._pipelineContext=null,this._valueCache={},this.name=t;var d,p,_=null;if(i.attributes){var g=i;if(this._engine=r,this._attributesNames=g.attributes,this._uniformsNames=g.uniformsNames.concat(g.samplers),this._samplerList=g.samplers.slice(),this.defines=g.defines,this.onError=g.onError,this.onCompiled=g.onCompiled,this._fallbacks=g.fallbacks,this._indexParameters=g.indexParameters,this._transformFeedbackVaryings=g.transformFeedbackVaryings||null,this._multiTarget=!!g.multiTarget,g.uniformBuffersNames){this._uniformBuffersNamesList=g.uniformBuffersNames.slice();for(var m=0;m<g.uniformBuffersNames.length;m++)this._uniformBuffersNames[g.uniformBuffersNames[m]]=m}_=null!==(c=g.processFinalCode)&&void 0!==c?c:null}else this._engine=o,this.defines=null==s?"":s,this._uniformsNames=r.concat(n),this._samplerList=n?n.slice():[],this._attributesNames=i,this._uniformBuffersNamesList=[],this.onError=u,this.onCompiled=h,this._indexParameters=l,this._fallbacks=a;this._attributeLocationByName={},this.uniqueId=e._uniqueIdSeed++;var v=H.IsWindowObjectExist()?this._engine.getHostDocument():null;t.vertexSource?d="source:"+t.vertexSource:t.vertexElement?(d=v?v.getElementById(t.vertexElement):null)||(d=t.vertexElement):d=t.vertex||t,t.fragmentSource?p="source:"+t.fragmentSource:t.fragmentElement?(p=v?v.getElementById(t.fragmentElement):null)||(p=t.fragmentElement):p=t.fragment||t;var y={defines:this.defines.split("\n"),indexParameters:this._indexParameters,isFragment:!1,shouldUseHighPrecisionShader:this._engine._shouldUseHighPrecisionShader,processor:this._engine._shaderProcessor,supportsUniformBuffers:this._engine.supportsUniformBuffers,shadersRepository:e.ShadersRepository,includesShadersStore:e.IncludesShadersStore,version:(100*this._engine.webGLVersion).toString(),platformName:this._engine.webGLVersion>=2?"WEBGL2":"WEBGL1"};this._loadShader(d,"Vertex","",(function(e){f._rawVertexSourceCode=e,f._loadShader(p,"Fragment","Pixel",(function(i){f._rawFragmentSourceCode=i,ae.Process(e,y,(function(e){_&&(e=_("vertex",e)),y.isFragment=!0,ae.Process(i,y,(function(i){_&&(i=_("fragment",i)),f._useFinalCode(e,i,t)}),f._engine)}),f._engine)}))}))}return Object.defineProperty(e.prototype,"onBindObservable",{get:function(){return this._onBindObservable||(this._onBindObservable=new U),this._onBindObservable},enumerable:!1,configurable:!0}),e.prototype._useFinalCode=function(e,t,i){if(i){var r=i.vertexElement||i.vertex||i.spectorName||i,n=i.fragmentElement||i.fragment||i.spectorName||i;this._vertexSourceCode="#define SHADER_NAME vertex:"+r+"\n"+e,this._fragmentSourceCode="#define SHADER_NAME fragment:"+n+"\n"+t}else this._vertexSourceCode=e,this._fragmentSourceCode=t;this._prepareEffect()},Object.defineProperty(e.prototype,"key",{get:function(){return this._key},enumerable:!1,configurable:!0}),e.prototype.isReady=function(){try{return this._isReadyInternal()}catch(e){return!1}},e.prototype._isReadyInternal=function(){return!!this._isReady||!!this._pipelineContext&&this._pipelineContext.isReady},e.prototype.getEngine=function(){return this._engine},e.prototype.getPipelineContext=function(){return this._pipelineContext},e.prototype.getAttributesNames=function(){return this._attributesNames},e.prototype.getAttributeLocation=function(e){return this._attributes[e]},e.prototype.getAttributeLocationByName=function(e){return this._attributeLocationByName[e]},e.prototype.getAttributesCount=function(){return this._attributes.length},e.prototype.getUniformIndex=function(e){return this._uniformsNames.indexOf(e)},e.prototype.getUniform=function(e){return this._uniforms[e]},e.prototype.getSamplers=function(){return this._samplerList},e.prototype.getUniformNames=function(){return this._uniformsNames},e.prototype.getUniformBuffersNames=function(){return this._uniformBuffersNamesList},e.prototype.getIndexParameters=function(){return this._indexParameters},e.prototype.getCompilationError=function(){return this._compilationError},e.prototype.allFallbacksProcessed=function(){return this._allFallbacksProcessed},e.prototype.executeWhenCompiled=function(e){var t=this;this.isReady()?e(this):(this.onCompileObservable.add((function(t){e(t)})),this._pipelineContext&&!this._pipelineContext.isAsync||setTimeout((function(){t._checkIsReady(null)}),16))},e.prototype._checkIsReady=function(e){var t=this;try{if(this._isReadyInternal())return}catch(t){return void this._processCompilationErrors(t,e)}setTimeout((function(){t._checkIsReady(e)}),16)},e.prototype._loadShader=function(t,i,r,n){var o;if("undefined"!=typeof HTMLElement&&t instanceof HTMLElement)return void n(H.GetDOMTextContent(t));"source:"!==t.substr(0,7)?"base64:"!==t.substr(0,7)?e.ShadersStore[t+i+"Shader"]?n(e.ShadersStore[t+i+"Shader"]):r&&e.ShadersStore[t+r+"Shader"]?n(e.ShadersStore[t+r+"Shader"]):(o="."===t[0]||"/"===t[0]||t.indexOf("http")>-1?t:e.ShadersRepository+t,this._engine._loadFile(o+"."+i.toLowerCase()+".fx",n)):n(window.atob(t.substr(7))):n(t.substr(7))},Object.defineProperty(e.prototype,"vertexSourceCode",{get:function(){return this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?this._vertexSourceCodeOverride:this._vertexSourceCode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fragmentSourceCode",{get:function(){return this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?this._fragmentSourceCodeOverride:this._fragmentSourceCode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rawVertexSourceCode",{get:function(){return this._rawVertexSourceCode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rawFragmentSourceCode",{get:function(){return this._rawFragmentSourceCode},enumerable:!1,configurable:!0}),e.prototype._rebuildProgram=function(e,t,i,r){var n=this;this._isReady=!1,this._vertexSourceCodeOverride=e,this._fragmentSourceCodeOverride=t,this.onError=function(e,t){r&&r(t)},this.onCompiled=function(){var e=n.getEngine().scenes;if(e)for(var t=0;t<e.length;t++)e[t].markAllMaterialsAsDirty(63);n._pipelineContext._handlesSpectorRebuildCallback(i)},this._fallbacks=null,this._prepareEffect()},e.prototype._prepareEffect=function(){var e=this,t=this._attributesNames,i=this.defines;this._valueCache={};var r=this._pipelineContext;try{var n=this._engine;this._pipelineContext=n.createPipelineContext();var o=this._rebuildProgram.bind(this);this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?n._preparePipelineContext(this._pipelineContext,this._vertexSourceCodeOverride,this._fragmentSourceCodeOverride,!0,o,null,this._transformFeedbackVaryings):n._preparePipelineContext(this._pipelineContext,this._vertexSourceCode,this._fragmentSourceCode,!1,o,i,this._transformFeedbackVaryings),n._executeWhenRenderingStateIsCompiled(this._pipelineContext,(function(){if(n.supportsUniformBuffers)for(var i in e._uniformBuffersNames)e.bindUniformBlock(i,e._uniformBuffersNames[i]);var o;if(n.getUniforms(e._pipelineContext,e._uniformsNames).forEach((function(t,i){e._uniforms[e._uniformsNames[i]]=t})),e._attributes=n.getAttributes(e._pipelineContext,t),t)for(var s=0;s<t.length;s++){var a=t[s];e._attributeLocationByName[a]=e._attributes[s]}for(o=0;o<e._samplerList.length;o++){null==e.getUniform(e._samplerList[o])&&(e._samplerList.splice(o,1),o--)}e._samplerList.forEach((function(t,i){e._samplers[t]=i})),n.bindSamplers(e),e._compilationError="",e._isReady=!0,e.onCompiled&&e.onCompiled(e),e.onCompileObservable.notifyObservers(e),e.onCompileObservable.clear(),e._fallbacks&&e._fallbacks.unBindMesh(),r&&e.getEngine()._deletePipelineContext(r)})),this._pipelineContext.isAsync&&this._checkIsReady(r)}catch(e){this._processCompilationErrors(e,r)}},e.prototype._getShaderCodeAndErrorLine=function(e,t,i){var r=i?/FRAGMENT SHADER ERROR: 0:(\d+?):/:/VERTEX SHADER ERROR: 0:(\d+?):/,n=null;if(t&&e){var o=t.match(r);if(o&&2===o.length){var s=parseInt(o[1]),a=e.split("\n",-1);a.length>=s&&(n="Offending line ["+s+"] in "+(i?"fragment":"vertex")+" code: "+a[s-1])}}return[e,n]},e.prototype._processCompilationErrors=function(t,i){var r,n,o,s,a;void 0===i&&(i=null),this._compilationError=t.message;var h=this._attributesNames,u=this._fallbacks;if(q.Error("Unable to compile effect:"),q.Error("Uniforms: "+this._uniformsNames.map((function(e){return" "+e}))),q.Error("Attributes: "+h.map((function(e){return" "+e}))),q.Error("Defines:\r\n"+this.defines),e.LogShaderCodeOnCompilationError){var l=null,c=null,f=null;(null===(o=this._pipelineContext)||void 0===o?void 0:o._getVertexShaderCode())&&(f=(r=this._getShaderCodeAndErrorLine(this._pipelineContext._getVertexShaderCode(),this._compilationError,!1))[0],l=r[1],f&&(q.Error("Vertex code:"),q.Error(f))),(null===(s=this._pipelineContext)||void 0===s?void 0:s._getFragmentShaderCode())&&(f=(n=this._getShaderCodeAndErrorLine(null===(a=this._pipelineContext)||void 0===a?void 0:a._getFragmentShaderCode(),this._compilationError,!0))[0],c=n[1],f&&(q.Error("Fragment code:"),q.Error(f))),l&&q.Error(l),c&&q.Error(c)}q.Error("Error: "+this._compilationError),i&&(this._pipelineContext=i,this._isReady=!0,this.onError&&this.onError(this,this._compilationError),this.onErrorObservable.notifyObservers(this)),u?(this._pipelineContext=null,u.hasMoreFallbacks?(this._allFallbacksProcessed=!1,q.Error("Trying next fallback."),this.defines=u.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(e.prototype,"isSupported",{get:function(){return""===this._compilationError},enumerable:!1,configurable:!0}),e.prototype._bindTexture=function(e,t){this._engine._bindTexture(this._samplers[e],t)},e.prototype.setTexture=function(e,t){this._engine.setTexture(this._samplers[e],this._uniforms[e],t)},e.prototype.setDepthStencilTexture=function(e,t){this._engine.setDepthStencilTexture(this._samplers[e],this._uniforms[e],t)},e.prototype.setTextureArray=function(e,t){var i=e+"Ex";if(-1===this._samplerList.indexOf(i+"0")){for(var r=this._samplerList.indexOf(e),n=1;n<t.length;n++){var o=i+(n-1).toString();this._samplerList.splice(r+n,0,o)}for(var s=0,a=0,h=this._samplerList;a<h.length;a++){var u=h[a];this._samplers[u]=s,s+=1}}this._engine.setTextureArray(this._samplers[e],this._uniforms[e],t)},e.prototype.setTextureFromPostProcess=function(e,t){this._engine.setTextureFromPostProcess(this._samplers[e],t)},e.prototype.setTextureFromPostProcessOutput=function(e,t){this._engine.setTextureFromPostProcessOutput(this._samplers[e],t)},e.prototype._cacheMatrix=function(e,t){var i=this._valueCache[e],r=t.updateFlag;return(void 0===i||i!==r)&&(this._valueCache[e]=r,!0)},e.prototype._cacheFloat2=function(e,t,i){var r=this._valueCache[e];if(!r||2!==r.length)return r=[t,i],this._valueCache[e]=r,!0;var n=!1;return r[0]!==t&&(r[0]=t,n=!0),r[1]!==i&&(r[1]=i,n=!0),n},e.prototype._cacheFloat3=function(e,t,i,r){var n=this._valueCache[e];if(!n||3!==n.length)return n=[t,i,r],this._valueCache[e]=n,!0;var o=!1;return n[0]!==t&&(n[0]=t,o=!0),n[1]!==i&&(n[1]=i,o=!0),n[2]!==r&&(n[2]=r,o=!0),o},e.prototype._cacheFloat4=function(e,t,i,r,n){var o=this._valueCache[e];if(!o||4!==o.length)return o=[t,i,r,n],this._valueCache[e]=o,!0;var s=!1;return o[0]!==t&&(o[0]=t,s=!0),o[1]!==i&&(o[1]=i,s=!0),o[2]!==r&&(o[2]=r,s=!0),o[3]!==n&&(o[3]=n,s=!0),s},e.prototype.bindUniformBuffer=function(t,i){var r=this._uniformBuffersNames[i];void 0!==r&&e._baseCache[r]!==t&&(e._baseCache[r]=t,this._engine.bindUniformBufferBase(t,r))},e.prototype.bindUniformBlock=function(e,t){this._engine.bindUniformBlock(this._pipelineContext,e,t)},e.prototype.setInt=function(e,t){var i=this._valueCache[e];return void 0!==i&&i===t||this._engine.setInt(this._uniforms[e],t)&&(this._valueCache[e]=t),this},e.prototype.setIntArray=function(e,t){return this._valueCache[e]=null,this._engine.setIntArray(this._uniforms[e],t),this},e.prototype.setIntArray2=function(e,t){return this._valueCache[e]=null,this._engine.setIntArray2(this._uniforms[e],t),this},e.prototype.setIntArray3=function(e,t){return this._valueCache[e]=null,this._engine.setIntArray3(this._uniforms[e],t),this},e.prototype.setIntArray4=function(e,t){return this._valueCache[e]=null,this._engine.setIntArray4(this._uniforms[e],t),this},e.prototype.setFloatArray=function(e,t){return this._valueCache[e]=null,this._engine.setArray(this._uniforms[e],t),this},e.prototype.setFloatArray2=function(e,t){return this._valueCache[e]=null,this._engine.setArray2(this._uniforms[e],t),this},e.prototype.setFloatArray3=function(e,t){return this._valueCache[e]=null,this._engine.setArray3(this._uniforms[e],t),this},e.prototype.setFloatArray4=function(e,t){return this._valueCache[e]=null,this._engine.setArray4(this._uniforms[e],t),this},e.prototype.setArray=function(e,t){return this._valueCache[e]=null,this._engine.setArray(this._uniforms[e],t),this},e.prototype.setArray2=function(e,t){return this._valueCache[e]=null,this._engine.setArray2(this._uniforms[e],t),this},e.prototype.setArray3=function(e,t){return this._valueCache[e]=null,this._engine.setArray3(this._uniforms[e],t),this},e.prototype.setArray4=function(e,t){return this._valueCache[e]=null,this._engine.setArray4(this._uniforms[e],t),this},e.prototype.setMatrices=function(e,t){return t?(this._valueCache[e]=null,this._engine.setMatrices(this._uniforms[e],t),this):this},e.prototype.setMatrix=function(e,t){return this._cacheMatrix(e,t)&&(this._engine.setMatrices(this._uniforms[e],t.toArray())||(this._valueCache[e]=null)),this},e.prototype.setMatrix3x3=function(e,t){return this._valueCache[e]=null,this._engine.setMatrix3x3(this._uniforms[e],t),this},e.prototype.setMatrix2x2=function(e,t){return this._valueCache[e]=null,this._engine.setMatrix2x2(this._uniforms[e],t),this},e.prototype.setFloat=function(e,t){var i=this._valueCache[e];return void 0!==i&&i===t||this._engine.setFloat(this._uniforms[e],t)&&(this._valueCache[e]=t),this},e.prototype.setBool=function(e,t){var i=this._valueCache[e];return void 0!==i&&i===t||this._engine.setInt(this._uniforms[e],t?1:0)&&(this._valueCache[e]=t),this},e.prototype.setVector2=function(e,t){return this._cacheFloat2(e,t.x,t.y)&&(this._engine.setFloat2(this._uniforms[e],t.x,t.y)||(this._valueCache[e]=null)),this},e.prototype.setFloat2=function(e,t,i){return this._cacheFloat2(e,t,i)&&(this._engine.setFloat2(this._uniforms[e],t,i)||(this._valueCache[e]=null)),this},e.prototype.setVector3=function(e,t){return this._cacheFloat3(e,t.x,t.y,t.z)&&(this._engine.setFloat3(this._uniforms[e],t.x,t.y,t.z)||(this._valueCache[e]=null)),this},e.prototype.setFloat3=function(e,t,i,r){return this._cacheFloat3(e,t,i,r)&&(this._engine.setFloat3(this._uniforms[e],t,i,r)||(this._valueCache[e]=null)),this},e.prototype.setVector4=function(e,t){return this._cacheFloat4(e,t.x,t.y,t.z,t.w)&&(this._engine.setFloat4(this._uniforms[e],t.x,t.y,t.z,t.w)||(this._valueCache[e]=null)),this},e.prototype.setFloat4=function(e,t,i,r,n){return this._cacheFloat4(e,t,i,r,n)&&(this._engine.setFloat4(this._uniforms[e],t,i,r,n)||(this._valueCache[e]=null)),this},e.prototype.setColor3=function(e,t){return this._cacheFloat3(e,t.r,t.g,t.b)&&(this._engine.setFloat3(this._uniforms[e],t.r,t.g,t.b)||(this._valueCache[e]=null)),this},e.prototype.setColor4=function(e,t,i){return this._cacheFloat4(e,t.r,t.g,t.b,i)&&(this._engine.setFloat4(this._uniforms[e],t.r,t.g,t.b,i)||(this._valueCache[e]=null)),this},e.prototype.setDirectColor4=function(e,t){return this._cacheFloat4(e,t.r,t.g,t.b,t.a)&&(this._engine.setFloat4(this._uniforms[e],t.r,t.g,t.b,t.a)||(this._valueCache[e]=null)),this},e.prototype.dispose=function(){this._engine._releaseEffect(this)},e.RegisterShader=function(t,i,r){i&&(e.ShadersStore[t+"PixelShader"]=i),r&&(e.ShadersStore[t+"VertexShader"]=r)},e.ResetCache=function(){e._baseCache={}},e.ShadersRepository="src/Shaders/",e.LogShaderCodeOnCompilationError=!0,e._uniqueIdSeed=0,e._baseCache={},e.ShadersStore={},e.IncludesShadersStore={},e}(),ue=function(){function e(){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(e.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(e.prototype,"zOffset",{get:function(){return this._zOffset},set:function(e){this._zOffset!==e&&(this._zOffset=e,this._isZOffsetDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cullFace",{get:function(){return this._cullFace},set:function(e){this._cullFace!==e&&(this._cullFace=e,this._isCullFaceDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cull",{get:function(){return this._cull},set:function(e){this._cull!==e&&(this._cull=e,this._isCullDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"depthFunc",{get:function(){return this._depthFunc},set:function(e){this._depthFunc!==e&&(this._depthFunc=e,this._isDepthFuncDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"depthMask",{get:function(){return this._depthMask},set:function(e){this._depthMask!==e&&(this._depthMask=e,this._isDepthMaskDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"depthTest",{get:function(){return this._depthTest},set:function(e){this._depthTest!==e&&(this._depthTest=e,this._isDepthTestDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"frontFace",{get:function(){return this._frontFace},set:function(e){this._frontFace!==e&&(this._frontFace=e,this._isFrontFaceDirty=!0)},enumerable:!1,configurable:!0}),e.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},e.prototype.apply=function(e){this.isDirty&&(this._isCullDirty&&(this.cull?e.enable(e.CULL_FACE):e.disable(e.CULL_FACE),this._isCullDirty=!1),this._isCullFaceDirty&&(e.cullFace(this.cullFace),this._isCullFaceDirty=!1),this._isDepthMaskDirty&&(e.depthMask(this.depthMask),this._isDepthMaskDirty=!1),this._isDepthTestDirty&&(this.depthTest?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),this._isDepthTestDirty=!1),this._isDepthFuncDirty&&(e.depthFunc(this.depthFunc),this._isDepthFuncDirty=!1),this._isZOffsetDirty&&(this.zOffset?(e.enable(e.POLYGON_OFFSET_FILL),e.polygonOffset(this.zOffset,0)):e.disable(e.POLYGON_OFFSET_FILL),this._isZOffsetDirty=!1),this._isFrontFaceDirty&&(e.frontFace(this.frontFace),this._isFrontFaceDirty=!1))},e}(),le=function(){function e(){this._isStencilTestDirty=!1,this._isStencilMaskDirty=!1,this._isStencilFuncDirty=!1,this._isStencilOpDirty=!1,this.reset()}return Object.defineProperty(e.prototype,"isDirty",{get:function(){return this._isStencilTestDirty||this._isStencilMaskDirty||this._isStencilFuncDirty||this._isStencilOpDirty},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilFunc",{get:function(){return this._stencilFunc},set:function(e){this._stencilFunc!==e&&(this._stencilFunc=e,this._isStencilFuncDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilFuncRef",{get:function(){return this._stencilFuncRef},set:function(e){this._stencilFuncRef!==e&&(this._stencilFuncRef=e,this._isStencilFuncDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilFuncMask",{get:function(){return this._stencilFuncMask},set:function(e){this._stencilFuncMask!==e&&(this._stencilFuncMask=e,this._isStencilFuncDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilOpStencilFail",{get:function(){return this._stencilOpStencilFail},set:function(e){this._stencilOpStencilFail!==e&&(this._stencilOpStencilFail=e,this._isStencilOpDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilOpDepthFail",{get:function(){return this._stencilOpDepthFail},set:function(e){this._stencilOpDepthFail!==e&&(this._stencilOpDepthFail=e,this._isStencilOpDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilOpStencilDepthPass",{get:function(){return this._stencilOpStencilDepthPass},set:function(e){this._stencilOpStencilDepthPass!==e&&(this._stencilOpStencilDepthPass=e,this._isStencilOpDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilMask",{get:function(){return this._stencilMask},set:function(e){this._stencilMask!==e&&(this._stencilMask=e,this._isStencilMaskDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilTest",{get:function(){return this._stencilTest},set:function(e){this._stencilTest!==e&&(this._stencilTest=e,this._isStencilTestDirty=!0)},enumerable:!1,configurable:!0}),e.prototype.reset=function(){this._stencilTest=!1,this._stencilMask=255,this._stencilFunc=e.ALWAYS,this._stencilFuncRef=1,this._stencilFuncMask=255,this._stencilOpStencilFail=e.KEEP,this._stencilOpDepthFail=e.KEEP,this._stencilOpStencilDepthPass=e.REPLACE,this._isStencilTestDirty=!0,this._isStencilMaskDirty=!0,this._isStencilFuncDirty=!0,this._isStencilOpDirty=!0},e.prototype.apply=function(e){this.isDirty&&(this._isStencilTestDirty&&(this.stencilTest?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this._isStencilTestDirty=!1),this._isStencilMaskDirty&&(e.stencilMask(this.stencilMask),this._isStencilMaskDirty=!1),this._isStencilFuncDirty&&(e.stencilFunc(this.stencilFunc,this.stencilFuncRef,this.stencilFuncMask),this._isStencilFuncDirty=!1),this._isStencilOpDirty&&(e.stencilOp(this.stencilOpStencilFail,this.stencilOpDepthFail,this.stencilOpStencilDepthPass),this._isStencilOpDirty=!1))},e.ALWAYS=519,e.KEEP=7680,e.REPLACE=7681,e}(),ce=function(){function e(){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(e.prototype,"isDirty",{get:function(){return this._isAlphaBlendDirty||this._isBlendFunctionParametersDirty},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"alphaBlend",{get:function(){return this._alphaBlend},set:function(e){this._alphaBlend!==e&&(this._alphaBlend=e,this._isAlphaBlendDirty=!0)},enumerable:!1,configurable:!0}),e.prototype.setAlphaBlendConstants=function(e,t,i,r){this._blendConstants[0]===e&&this._blendConstants[1]===t&&this._blendConstants[2]===i&&this._blendConstants[3]===r||(this._blendConstants[0]=e,this._blendConstants[1]=t,this._blendConstants[2]=i,this._blendConstants[3]=r,this._isBlendConstantsDirty=!0)},e.prototype.setAlphaBlendFunctionParameters=function(e,t,i,r){this._blendFunctionParameters[0]===e&&this._blendFunctionParameters[1]===t&&this._blendFunctionParameters[2]===i&&this._blendFunctionParameters[3]===r||(this._blendFunctionParameters[0]=e,this._blendFunctionParameters[1]=t,this._blendFunctionParameters[2]=i,this._blendFunctionParameters[3]=r,this._isBlendFunctionParametersDirty=!0)},e.prototype.setAlphaEquationParameters=function(e,t){this._blendEquationParameters[0]===e&&this._blendEquationParameters[1]===t||(this._blendEquationParameters[0]=e,this._blendEquationParameters[1]=t,this._isBlendEquationParametersDirty=!0)},e.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},e.prototype.apply=function(e){this.isDirty&&(this._isAlphaBlendDirty&&(this._alphaBlend?e.enable(e.BLEND):e.disable(e.BLEND),this._isAlphaBlendDirty=!1),this._isBlendFunctionParametersDirty&&(e.blendFuncSeparate(this._blendFunctionParameters[0],this._blendFunctionParameters[1],this._blendFunctionParameters[2],this._blendFunctionParameters[3]),this._isBlendFunctionParametersDirty=!1),this._isBlendEquationParametersDirty&&(e.blendEquationSeparate(this._blendEquationParameters[0],this._blendEquationParameters[1]),this._isBlendEquationParametersDirty=!1),this._isBlendConstantsDirty&&(e.blendColor(this._blendConstants[0],this._blendConstants[1],this._blendConstants[2],this._blendConstants[3]),this._isBlendConstantsDirty=!1))},e}(),fe=function(){};!function(e){e[e.Unknown=0]="Unknown",e[e.Url=1]="Url",e[e.Temp=2]="Temp",e[e.Raw=3]="Raw",e[e.Dynamic=4]="Dynamic",e[e.RenderTarget=5]="RenderTarget",e[e.MultiRenderTarget=6]="MultiRenderTarget",e[e.Cube=7]="Cube",e[e.CubeRaw=8]="CubeRaw",e[e.CubePrefiltered=9]="CubePrefiltered",e[e.Raw3D=10]="Raw3D",e[e.Raw2DArray=11]="Raw2DArray",e[e.Depth=12]="Depth",e[e.CubeRawRGBD=13]="CubeRawRGBD"}(z||(z={}));var de=function(){function e(e,t,i){void 0===i&&(i=!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 U,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=z.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=e,this._source=t,i||(this._webGLTexture=e._createTexture())}return e.prototype.getEngine=function(){return this._engine},Object.defineProperty(e.prototype,"source",{get:function(){return this._source},enumerable:!1,configurable:!0}),e.prototype.incrementReferences=function(){this._references++},e.prototype.updateSize=function(e,t,i){void 0===i&&(i=1),this.width=e,this.height=t,this.depth=i,this.baseWidth=e,this.baseHeight=t,this.baseDepth=i,this._size=e*t*i},e.prototype._rebuild=function(){var t,i,r=this;switch(this.isReady=!1,this._cachedCoordinatesMode=null,this._cachedWrapU=null,this._cachedWrapV=null,this._cachedAnisotropicFilteringLevel=null,this.source){case z.Temp:return;case z.Url:return void(i=this._engine.createTexture(null!==(t=this._originalUrl)&&void 0!==t?t:this.url,!this.generateMipMaps,this.invertY,null,this.samplingMode,(function(){i._swapAndDie(r),r.isReady=!0}),null,this._buffer,void 0,this.format));case z.Raw:return(i=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 z.Raw3D:return(i=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 z.Raw2DArray:return(i=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 z.Dynamic:return(i=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 z.RenderTarget:var n=new fe;if(n.generateDepthBuffer=this._generateDepthBuffer,n.generateMipMaps=this.generateMipMaps,n.generateStencilBuffer=this._generateStencilBuffer,n.samplingMode=this.samplingMode,n.type=this.type,this.isCube)i=this._engine.createRenderTargetCubeTexture(this.width,n);else{var o={width:this.width,height:this.height,layers:this.is2DArray?this.depth:void 0};i=this._engine.createRenderTargetTexture(o,n)}return i._swapAndDie(this),void(this.isReady=!0);case z.Depth:var s={bilinearFiltering:2!==this.samplingMode,comparisonFunction:this._comparisonFunction,generateStencil:this._generateStencilBuffer,isCube:this.isCube},a={width:this.width,height:this.height,layers:this.is2DArray?this.depth:void 0};return(i=this._engine.createDepthStencilTexture(a,s))._swapAndDie(this),void(this.isReady=!0);case z.Cube:return void(i=this._engine.createCubeTexture(this.url,null,this._files,!this.generateMipMaps,(function(){i._swapAndDie(r),r.isReady=!0}),null,this.format,this._extension));case z.CubeRaw:return(i=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 z.CubeRawRGBD:return i=this._engine.createRawCubeTexture(null,this.width,this.format,this.type,this.generateMipMaps,this.invertY,this.samplingMode,this._compression),void e._UpdateRGBDAsync(i,this._bufferViewArrayArray,this._sphericalPolynomial,this._lodGenerationScale,this._lodGenerationOffset).then((function(){i._swapAndDie(r),r.isReady=!0}));case z.CubePrefiltered:return void((i=this._engine.createPrefilteredCubeTexture(this.url,null,this._lodGenerationScale,this._lodGenerationOffset,(function(e){e&&e._swapAndDie(r),r.isReady=!0}),null,this.format,this._extension))._sphericalPolynomial=this._sphericalPolynomial)}},e.prototype._swapAndDie=function(e){e._webGLTexture=this._webGLTexture,e._isRGBD=this._isRGBD,this._framebuffer&&(e._framebuffer=this._framebuffer),this._depthStencilBuffer&&(e._depthStencilBuffer=this._depthStencilBuffer),e._depthStencilTexture=this._depthStencilTexture,this._lodTextureHigh&&(e._lodTextureHigh&&e._lodTextureHigh.dispose(),e._lodTextureHigh=this._lodTextureHigh),this._lodTextureMid&&(e._lodTextureMid&&e._lodTextureMid.dispose(),e._lodTextureMid=this._lodTextureMid),this._lodTextureLow&&(e._lodTextureLow&&e._lodTextureLow.dispose(),e._lodTextureLow=this._lodTextureLow),this._irradianceTexture&&(e._irradianceTexture&&e._irradianceTexture.dispose(),e._irradianceTexture=this._irradianceTexture);var t,i=this._engine.getLoadedTexturesCache();-1!==(t=i.indexOf(this))&&i.splice(t,1),-1===(t=i.indexOf(e))&&i.push(e)},e.prototype.dispose=function(){this._webGLTexture&&(this._references--,0===this._references&&(this._engine._releaseTexture(this),this._webGLTexture=null))},e._UpdateRGBDAsync=function(e,t,i,r,n){throw b.WarnImport("environmentTextureTools")},e}(),pe=function(){function e(){}return e.prototype.postProcessor=function(e,t,i,r){if(!r.getCaps().drawBuffersExtension){e=e.replace(/#extension.+GL_EXT_draw_buffers.+(enable|require)/g,"")}return e},e}(),_e=function(){function e(){}return e.prototype.attributeProcessor=function(e){return e.replace("attribute","in")},e.prototype.varyingProcessor=function(e,t){return e.replace("varying",t?"in":"out")},e.prototype.postProcessor=function(e,t,i){var r=-1!==e.search(/#extension.+GL_EXT_draw_buffers.+require/);if(e=(e=e.replace(/#extension.+(GL_OVR_multiview2|GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g,"")).replace(/texture2D\s*\(/g,"texture("),i)e=(e=(e=(e=(e=(e=(e=e.replace(/texture2DLodEXT\s*\(/g,"textureLod(")).replace(/textureCubeLodEXT\s*\(/g,"textureLod(")).replace(/textureCube\s*\(/g,"texture(")).replace(/gl_FragDepthEXT/g,"gl_FragDepth")).replace(/gl_FragColor/g,"glFragColor")).replace(/gl_FragData/g,"glFragData")).replace(/void\s+?main\s*\(/g,(r?"":"out vec4 glFragColor;\n")+"void main(");else if(-1!==t.indexOf("#define MULTIVIEW"))return"#extension GL_OVR_multiview2 : require\nlayout (num_views = 2) in;\n"+e;return e},e}(),ge=function(e){function i(t){var i=e.call(this)||this;return i._buffer=t,i}return t(i,e),Object.defineProperty(i.prototype,"underlyingResource",{get:function(){return this._buffer},enumerable:!1,configurable:!0}),i}(function(){function e(){this.references=0,this.capacity=0,this.is32Bits=!1}return Object.defineProperty(e.prototype,"underlyingResource",{get:function(){return null},enumerable:!1,configurable:!0}),e}()),me=function(){function e(){this.vertexCompilationError=null,this.fragmentCompilationError=null,this.programLinkError=null,this.programValidationError=null}return Object.defineProperty(e.prototype,"isAsync",{get:function(){return this.isParallelCompiled},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isReady",{get:function(){return!!this.program&&(!this.isParallelCompiled||this.engine._isRenderingStateCompiled(this))},enumerable:!1,configurable:!0}),e.prototype._handlesSpectorRebuildCallback=function(e){e&&this.program&&e(this.program)},e.prototype._getVertexShaderCode=function(){return this.vertexShader?this.engine._getShaderSource(this.vertexShader):null},e.prototype._getFragmentShaderCode=function(){return this.fragmentShader?this.engine._getShaderSource(this.fragmentShader):null},e}(),ve=function(){function e(){}return e.CreateCanvas=function(e,t){if("undefined"==typeof document)return new OffscreenCanvas(e,t);var i=document.createElement("canvas");return i.width=e,i.height=t,i},e}(),ye=function(){},be=function(){function e(t,i,r,n){var o=this;void 0===n&&(n=!1),this.forcePOTTextures=!1,this.isFullscreen=!1,this.cullBackFaces=!0,this.renderEvenInBackground=!0,this.preventCacheWipeBetweenFrames=!1,this.validateShaderPrograms=!1,this.useReverseDepthBuffer=!1,this.disableUniformBuffers=!1,this._uniformBuffers=new Array,this._webGLVersion=1,this._windowIsBackground=!1,this._highPrecisionShadersAllowed=!0,this._badOS=!1,this._badDesktopOS=!1,this._renderingQueueLaunched=!1,this._activeRenderLoops=new Array,this.onContextLostObservable=new U,this.onContextRestoredObservable=new U,this._contextWasLost=!1,this._doNotHandleContextLost=!1,this.disableVertexArrayObjects=!1,this._colorWrite=!0,this._colorWriteChanged=!0,this._depthCullingState=new ue,this._stencilState=new le,this._alphaState=new ce,this._alphaMode=1,this._alphaEquation=0,this._internalTexturesCache=new Array,this._activeChannel=0,this._currentTextureChannel=-1,this._boundTexturesCache={},this._compiledEffects={},this._vertexAttribArraysEnabled=[],this._uintIndicesCurrentlySet=!1,this._currentBoundBuffer=new Array,this._currentFramebuffer=null,this._dummyFramebuffer=null,this._currentBufferPointers=new Array,this._currentInstanceLocations=new Array,this._currentInstanceBuffers=new Array,this._vaoRecordInProgress=!1,this._mustWipeVertexAttributes=!1,this._nextFreeTextureSlots=new Array,this._maxSimultaneousTextures=0,this._activeRequests=new Array,this._transformTextureUrl=null,this.hostInformation={isMobile:!1},this.premultipliedAlpha=!0,this.onBeforeTextureInitObservable=new U,this._viewportCached={x:0,y:0,z:0,w:0},this._unpackFlipYCached=null,this.enableUnpackFlipYCached=!0,this._getDepthStencilBuffer=function(e,t,i,r,n,s){var a=o._gl,h=a.createRenderbuffer();return a.bindRenderbuffer(a.RENDERBUFFER,h),i>1&&a.renderbufferStorageMultisample?a.renderbufferStorageMultisample(a.RENDERBUFFER,i,n,e,t):a.renderbufferStorage(a.RENDERBUFFER,r,e,t),a.framebufferRenderbuffer(a.FRAMEBUFFER,s,a.RENDERBUFFER,h),a.bindRenderbuffer(a.RENDERBUFFER,null),h},this._boundUniforms={};var s=null;if(t){if(r=r||{},f.SetMatrixPrecision(!!r.useHighPrecisionMatrix),t.getContext){if(s=t,this._renderingCanvas=s,null!=i&&(r.antialias=i),void 0===r.deterministicLockstep&&(r.deterministicLockstep=!1),void 0===r.lockstepMaxSteps&&(r.lockstepMaxSteps=4),void 0===r.timeStep&&(r.timeStep=1/60),void 0===r.preserveDrawingBuffer&&(r.preserveDrawingBuffer=!1),void 0===r.audioEngine&&(r.audioEngine=!0),void 0===r.stencil&&(r.stencil=!0),!1===r.premultipliedAlpha&&(this.premultipliedAlpha=!1),void 0===r.xrCompatible&&(r.xrCompatible=!0),this._doNotHandleContextLost=!!r.doNotHandleContextLost,navigator&&navigator.userAgent){var a=navigator.userAgent;this.hostInformation.isMobile=-1!==a.indexOf("Mobile");for(var h=0,u=e.ExceptionList;h<u.length;h++){var l=u[h],c=l.key,d=l.targets;if(new RegExp(c).test(a)){if(l.capture&&l.captureConstraint){var p=l.capture,_=l.captureConstraint,g=new RegExp(p).exec(a);if(g&&g.length>0)if(parseInt(g[g.length-1])>=_)continue}for(var m=0,v=d;m<v.length;m++){switch(v[m]){case"uniformBuffer":this.disableUniformBuffers=!0;break;case"vao":this.disableVertexArrayObjects=!0}}}}}if(this._doNotHandleContextLost||(this._onContextLost=function(e){e.preventDefault(),o._contextWasLost=!0,q.Warn("WebGL context lost."),o.onContextLostObservable.notifyObservers(o)},this._onContextRestored=function(){setTimeout((function(){o._initGLContext(),o._rebuildEffects(),o._rebuildInternalTextures(),o._rebuildBuffers(),o.wipeCaches(!0),q.Warn("WebGL context successfully restored."),o.onContextRestoredObservable.notifyObservers(o),o._contextWasLost=!1}),0)},s.addEventListener("webglcontextlost",this._onContextLost,!1),s.addEventListener("webglcontextrestored",this._onContextRestored,!1),r.powerPreference="high-performance"),!r.disableWebGL2Support)try{this._gl=s.getContext("webgl2",r)||s.getContext("experimental-webgl2",r),this._gl&&(this._webGLVersion=2,this._gl.deleteQuery||(this._webGLVersion=1))}catch(e){}if(!this._gl){if(!s)throw new Error("The provided canvas is null or undefined.");try{this._gl=s.getContext("webgl",r)||s.getContext("experimental-webgl",r)}catch(e){throw new Error("WebGL not supported")}}if(!this._gl)throw new Error("WebGL not supported")}else{this._gl=t,this._renderingCanvas=this._gl.canvas,this._gl.renderbufferStorageMultisample&&(this._webGLVersion=2);var y=this._gl.getContextAttributes();y&&(r.stencil=y.stencil)}this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL,this._gl.NONE),void 0!==r.useHighPrecisionFloats&&(this._highPrecisionShadersAllowed=r.useHighPrecisionFloats);var b=H.IsWindowObjectExist()&&window.devicePixelRatio||1,T=r.limitDeviceRatio||b;this._hardwareScalingLevel=n?1/Math.min(T,b):1,this.resize(),this._isStencilEnable=!!r.stencil,this._initGLContext();for(var E=0;E<this._caps.maxVertexAttribs;E++)this._currentBufferPointers[E]=new ye;this.webGLVersion>1?this._shaderProcessor=new _e:this._shaderProcessor=new pe,this._badOS=/iPad/i.test(navigator.userAgent)||/iPhone/i.test(navigator.userAgent),this._badDesktopOS=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),this._creationOptions=r}}return Object.defineProperty(e,"NpmPackage",{get:function(){return"babylonjs@4.2.0"},enumerable:!1,configurable:!0}),Object.defineProperty(e,"Version",{get:function(){return"4.2.0"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"description",{get:function(){var e="WebGL"+this.webGLVersion;return this._caps.parallelShaderCompile&&(e+=" - Parallel shader compilation"),e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"ShadersRepository",{get:function(){return he.ShadersRepository},set:function(e){he.ShadersRepository=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"supportsUniformBuffers",{get:function(){return this.webGLVersion>1&&!this.disableUniformBuffers},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_shouldUseHighPrecisionShader",{get:function(){return!(!this._caps.highPrecisionShaderSupported||!this._highPrecisionShadersAllowed)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"needPOTTextures",{get:function(){return this._webGLVersion<2||this.forcePOTTextures},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"doNotHandleContextLost",{get:function(){return this._doNotHandleContextLost},set:function(e){this._doNotHandleContextLost=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_supportsHardwareTextureRescaling",{get:function(){return!1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"framebufferDimensionsObject",{set:function(e){this._framebufferDimensionsObject=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentViewport",{get:function(){return this._cachedViewport},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emptyTexture",{get:function(){return this._emptyTexture||(this._emptyTexture=this.createRawTexture(new Uint8Array(4),1,1,5,!1,!1,1)),this._emptyTexture},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emptyTexture3D",{get:function(){return this._emptyTexture3D||(this._emptyTexture3D=this.createRawTexture3D(new Uint8Array(4),1,1,1,5,!1,!1,1)),this._emptyTexture3D},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emptyTexture2DArray",{get:function(){return this._emptyTexture2DArray||(this._emptyTexture2DArray=this.createRawTexture2DArray(new Uint8Array(4),1,1,1,5,!1,!1,1)),this._emptyTexture2DArray},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emptyCubeTexture",{get:function(){if(!this._emptyCubeTexture){var e=new Uint8Array(4),t=[e,e,e,e,e,e];this._emptyCubeTexture=this.createRawCubeTexture(t,1,5,0,!1,!1,1)}return this._emptyCubeTexture},enumerable:!1,configurable:!0}),e.prototype._rebuildInternalTextures=function(){for(var e=0,t=this._internalTexturesCache.slice();e<t.length;e++){t[e]._rebuild()}},e.prototype._rebuildEffects=function(){for(var e in this._compiledEffects){this._compiledEffects[e]._prepareEffect()}he.ResetCache()},e.prototype.areAllEffectsReady=function(){for(var e in this._compiledEffects){if(!this._compiledEffects[e].isReady())return!1}return!0},e.prototype._rebuildBuffers=function(){for(var e=0,t=this._uniformBuffers;e<t.length;e++){t[e]._rebuild()}},e.prototype._initGLContext=function(){this._caps={maxTexturesImageUnits:this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),maxCombinedTexturesImageUnits:this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS),maxVertexTextureImageUnits:this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxTextureSize:this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),maxSamples:this._webGLVersion>1?this._gl.getParameter(this._gl.MAX_SAMPLES):1,maxCubemapTextureSize:this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE),maxRenderTextureSize:this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE),maxVertexAttribs:this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS),maxVaryingVectors:this._gl.getParameter(this._gl.MAX_VARYING_VECTORS),maxFragmentUniformVectors:this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS),maxVertexUniformVectors:this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS),parallelShaderCompile:this._gl.getExtension("KHR_parallel_shader_compile"),standardDerivatives:this._webGLVersion>1||null!==this._gl.getExtension("OES_standard_derivatives"),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||null!==this._gl.getExtension("OES_element_index_uint"),fragmentDepthSupported:this._webGLVersion>1||null!==this._gl.getExtension("EXT_frag_depth"),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 e=this._gl.getExtension("WEBGL_debug_renderer_info");if(null!=e&&(this._glRenderer=this._gl.getParameter(e.UNMASKED_RENDERER_WEBGL),this._glVendor=this._gl.getParameter(e.UNMASKED_VENDOR_WEBGL)),this._glVendor||(this._glVendor="Unknown vendor"),this._glRenderer||(this._glRenderer="Unknown renderer"),36193!==this._gl.HALF_FLOAT_OES&&(this._gl.HALF_FLOAT_OES=36193),34842!==this._gl.RGBA16F&&(this._gl.RGBA16F=34842),34836!==this._gl.RGBA32F&&(this._gl.RGBA32F=34836),35056!==this._gl.DEPTH24_STENCIL8&&(this._gl.DEPTH24_STENCIL8=35056),this._caps.timerQuery&&(1===this._webGLVersion&&(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&&5131!==this._gl.HALF_FLOAT_OES&&(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 t=this._gl.getExtension("WEBGL_draw_buffers");if(null!==t){this._caps.drawBuffersExtension=!0,this._gl.drawBuffers=t.drawBuffersWEBGL.bind(t),this._gl.DRAW_FRAMEBUFFER=this._gl.FRAMEBUFFER;for(var i=0;i<16;i++)this._gl["COLOR_ATTACHMENT"+i+"_WEBGL"]=t["COLOR_ATTACHMENT"+i+"_WEBGL"]}}if(this._webGLVersion>1)this._caps.depthTextureExtension=!0;else{var r=this._gl.getExtension("WEBGL_depth_texture");null!=r&&(this._caps.depthTextureExtension=!0,this._gl.UNSIGNED_INT_24_8=r.UNSIGNED_INT_24_8_WEBGL)}if(this.disableVertexArrayObjects)this._caps.vertexArrayObject=!1;else if(this._webGLVersion>1)this._caps.vertexArrayObject=!0;else{var n=this._gl.getExtension("OES_vertex_array_object");null!=n&&(this._caps.vertexArrayObject=!0,this._gl.createVertexArray=n.createVertexArrayOES.bind(n),this._gl.bindVertexArray=n.bindVertexArrayOES.bind(n),this._gl.deleteVertexArray=n.deleteVertexArrayOES.bind(n))}if(this._webGLVersion>1)this._caps.instancedArrays=!0;else{var o=this._gl.getExtension("ANGLE_instanced_arrays");null!=o?(this._caps.instancedArrays=!0,this._gl.drawArraysInstanced=o.drawArraysInstancedANGLE.bind(o),this._gl.drawElementsInstanced=o.drawElementsInstancedANGLE.bind(o),this._gl.vertexAttribDivisor=o.vertexAttribDivisorANGLE.bind(o)):this._caps.instancedArrays=!1}if(this._gl.getShaderPrecisionFormat){var s=this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER,this._gl.HIGH_FLOAT),a=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.HIGH_FLOAT);s&&a&&(this._caps.highPrecisionShaderSupported=0!==s.precision&&0!==a.precision)}if(this._webGLVersion>1)this._caps.blendMinMax=!0;else{var h=this._gl.getExtension("EXT_blend_minmax");null!=h&&(this._caps.blendMinMax=!0,this._gl.MAX=h.MAX_EXT,this._gl.MIN=h.MIN_EXT)}this._depthCullingState.depthTest=!0,this._depthCullingState.depthFunc=this._gl.LEQUAL,this._depthCullingState.depthMask=!0,this._maxSimultaneousTextures=this._caps.maxCombinedTexturesImageUnits;for(var u=0;u<this._maxSimultaneousTextures;u++)this._nextFreeTextureSlots.push(u)},Object.defineProperty(e.prototype,"webGLVersion",{get:function(){return this._webGLVersion},enumerable:!1,configurable:!0}),e.prototype.getClassName=function(){return"ThinEngine"},Object.defineProperty(e.prototype,"isStencilEnable",{get:function(){return this._isStencilEnable},enumerable:!1,configurable:!0}),e.prototype._prepareWorkingCanvas=function(){if(!this._workingCanvas){this._workingCanvas=ve.CreateCanvas(1,1);var e=this._workingCanvas.getContext("2d");e&&(this._workingContext=e)}},e.prototype.resetTextureCache=function(){for(var e in this._boundTexturesCache)this._boundTexturesCache.hasOwnProperty(e)&&(this._boundTexturesCache[e]=null);this._currentTextureChannel=-1},e.prototype.getGlInfo=function(){return{vendor:this._glVendor,renderer:this._glRenderer,version:this._glVersion}},e.prototype.setHardwareScalingLevel=function(e){this._hardwareScalingLevel=e,this.resize()},e.prototype.getHardwareScalingLevel=function(){return this._hardwareScalingLevel},e.prototype.getLoadedTexturesCache=function(){return this._internalTexturesCache},e.prototype.getCaps=function(){return this._caps},e.prototype.stopRenderLoop=function(e){if(e){var t=this._activeRenderLoops.indexOf(e);t>=0&&this._activeRenderLoops.splice(t,1)}else this._activeRenderLoops=[]},e.prototype._renderLoop=function(){if(!this._contextWasLost){var e=!0;if(!this.renderEvenInBackground&&this._windowIsBackground&&(e=!1),e){this.beginFrame();for(var t=0;t<this._activeRenderLoops.length;t++){(0,this._activeRenderLoops[t])()}this.endFrame()}}this._activeRenderLoops.length>0?this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow()):this._renderingQueueLaunched=!1},e.prototype.getRenderingCanvas=function(){return this._renderingCanvas},e.prototype.getHostWindow=function(){return H.IsWindowObjectExist()?this._renderingCanvas&&this._renderingCanvas.ownerDocument&&this._renderingCanvas.ownerDocument.defaultView?this._renderingCanvas.ownerDocument.defaultView:window:null},e.prototype.getRenderWidth=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.width:this._framebufferDimensionsObject?this._framebufferDimensionsObject.framebufferWidth:this._gl.drawingBufferWidth},e.prototype.getRenderHeight=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.height:this._framebufferDimensionsObject?this._framebufferDimensionsObject.framebufferHeight:this._gl.drawingBufferHeight},e.prototype._queueNewFrame=function(t,i){return e.QueueNewFrame(t,i)},e.prototype.runRenderLoop=function(e){-1===this._activeRenderLoops.indexOf(e)&&(this._activeRenderLoops.push(e),this._renderingQueueLaunched||(this._renderingQueueLaunched=!0,this._boundRenderFunction=this._renderLoop.bind(this),this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow())))},e.prototype.clear=function(e,t,i,r){void 0===r&&(r=!1),this.applyStates();var n=0;t&&e&&(this._gl.clearColor(e.r,e.g,e.b,void 0!==e.a?e.a:1),n|=this._gl.COLOR_BUFFER_BIT),i&&(this.useReverseDepthBuffer?(this._depthCullingState.depthFunc=this._gl.GREATER,this._gl.clearDepth(0)):this._gl.clearDepth(1),n|=this._gl.DEPTH_BUFFER_BIT),r&&(this._gl.clearStencil(0),n|=this._gl.STENCIL_BUFFER_BIT),this._gl.clear(n)},e.prototype._viewport=function(e,t,i,r){e===this._viewportCached.x&&t===this._viewportCached.y&&i===this._viewportCached.z&&r===this._viewportCached.w||(this._viewportCached.x=e,this._viewportCached.y=t,this._viewportCached.z=i,this._viewportCached.w=r,this._gl.viewport(e,t,i,r))},e.prototype.setViewport=function(e,t,i){var r=t||this.getRenderWidth(),n=i||this.getRenderHeight(),o=e.x||0,s=e.y||0;this._cachedViewport=e,this._viewport(o*r,s*n,r*e.width,n*e.height)},e.prototype.beginFrame=function(){},e.prototype.endFrame=function(){this._badOS&&this.flushFramebuffer()},e.prototype.resize=function(){var e,t;H.IsWindowObjectExist()?(e=this._renderingCanvas?this._renderingCanvas.clientWidth||this._renderingCanvas.width:window.innerWidth,t=this._renderingCanvas?this._renderingCanvas.clientHeight||this._renderingCanvas.height:window.innerHeight):(e=this._renderingCanvas?this._renderingCanvas.width:100,t=this._renderingCanvas?this._renderingCanvas.height:100),this.setSize(e/this._hardwareScalingLevel,t/this._hardwareScalingLevel)},e.prototype.setSize=function(e,t){return!!this._renderingCanvas&&(e|=0,t|=0,(this._renderingCanvas.width!==e||this._renderingCanvas.height!==t)&&(this._renderingCanvas.width=e,this._renderingCanvas.height=t,!0))},e.prototype.bindFramebuffer=function(e,t,i,r,n,o,s){void 0===t&&(t=0),void 0===o&&(o=0),void 0===s&&(s=0),this._currentRenderTarget&&this.unBindFramebuffer(this._currentRenderTarget),this._currentRenderTarget=e,this._bindUnboundFramebuffer(e._MSAAFramebuffer?e._MSAAFramebuffer:e._framebuffer);var a=this._gl;e.is2DArray?a.framebufferTextureLayer(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,e._webGLTexture,o,s):e.isCube&&a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+t,e._webGLTexture,o);var h=e._depthStencilTexture;if(h){var u=h._generateStencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT;e.is2DArray?a.framebufferTextureLayer(a.FRAMEBUFFER,u,h._webGLTexture,o,s):e.isCube?a.framebufferTexture2D(a.FRAMEBUFFER,u,a.TEXTURE_CUBE_MAP_POSITIVE_X+t,h._webGLTexture,o):a.framebufferTexture2D(a.FRAMEBUFFER,u,a.TEXTURE_2D,h._webGLTexture,o)}this._cachedViewport&&!n?this.setViewport(this._cachedViewport,i,r):(i||(i=e.width,o&&(i/=Math.pow(2,o))),r||(r=e.height,o&&(r/=Math.pow(2,o))),this._viewport(0,0,i,r)),this.wipeCaches()},e.prototype._bindUnboundFramebuffer=function(e){this._currentFramebuffer!==e&&(this._gl.bindFramebuffer(this._gl.FRAMEBUFFER,e),this._currentFramebuffer=e)},e.prototype.unBindFramebuffer=function(e,t,i){void 0===t&&(t=!1),this._currentRenderTarget=null;var r=this._gl;if(e._MSAAFramebuffer){if(e._textureArray)return void this.unBindMultiColorAttachmentFramebuffer(e._textureArray,t,i);r.bindFramebuffer(r.READ_FRAMEBUFFER,e._MSAAFramebuffer),r.bindFramebuffer(r.DRAW_FRAMEBUFFER,e._framebuffer),r.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,r.COLOR_BUFFER_BIT,r.NEAREST)}!e.generateMipMaps||t||e.isCube||(this._bindTextureDirectly(r.TEXTURE_2D,e,!0),r.generateMipmap(r.TEXTURE_2D),this._bindTextureDirectly(r.TEXTURE_2D,null)),i&&(e._MSAAFramebuffer&&this._bindUnboundFramebuffer(e._framebuffer),i()),this._bindUnboundFramebuffer(null)},e.prototype.flushFramebuffer=function(){this._gl.flush()},e.prototype.restoreDefaultFramebuffer=function(){this._currentRenderTarget?this.unBindFramebuffer(this._currentRenderTarget):this._bindUnboundFramebuffer(null),this._cachedViewport&&this.setViewport(this._cachedViewport),this.wipeCaches()},e.prototype._resetVertexBufferBinding=function(){this.bindArrayBuffer(null),this._cachedVertexBuffers=null},e.prototype.createVertexBuffer=function(e){return this._createVertexBuffer(e,this._gl.STATIC_DRAW)},e.prototype._createVertexBuffer=function(e,t){var i=this._gl.createBuffer();if(!i)throw new Error("Unable to create vertex buffer");var r=new ge(i);return this.bindArrayBuffer(r),e instanceof Array?this._gl.bufferData(this._gl.ARRAY_BUFFER,new Float32Array(e),this._gl.STATIC_DRAW):this._gl.bufferData(this._gl.ARRAY_BUFFER,e,this._gl.STATIC_DRAW),this._resetVertexBufferBinding(),r.references=1,r},e.prototype.createDynamicVertexBuffer=function(e){return this._createVertexBuffer(e,this._gl.DYNAMIC_DRAW)},e.prototype._resetIndexBufferBinding=function(){this.bindIndexBuffer(null),this._cachedIndexBuffer=null},e.prototype.createIndexBuffer=function(e,t){var i=this._gl.createBuffer(),r=new ge(i);if(!i)throw new Error("Unable to create index buffer");this.bindIndexBuffer(r);var n=this._normalizeIndexData(e);return this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,n,t?this._gl.DYNAMIC_DRAW:this._gl.STATIC_DRAW),this._resetIndexBufferBinding(),r.references=1,r.is32Bits=4===n.BYTES_PER_ELEMENT,r},e.prototype._normalizeIndexData=function(e){if(e instanceof Uint16Array)return e;if(this._caps.uintIndices){if(e instanceof Uint32Array)return e;for(var t=0;t<e.length;t++)if(e[t]>=65535)return new Uint32Array(e);return new Uint16Array(e)}return new Uint16Array(e)},e.prototype.bindArrayBuffer=function(e){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.bindBuffer(e,this._gl.ARRAY_BUFFER)},e.prototype.bindUniformBlock=function(e,t,i){var r=e.program,n=this._gl.getUniformBlockIndex(r,t);this._gl.uniformBlockBinding(r,n,i)},e.prototype.bindIndexBuffer=function(e){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.bindBuffer(e,this._gl.ELEMENT_ARRAY_BUFFER)},e.prototype.bindBuffer=function(e,t){(this._vaoRecordInProgress||this._currentBoundBuffer[t]!==e)&&(this._gl.bindBuffer(t,e?e.underlyingResource:null),this._currentBoundBuffer[t]=e)},e.prototype.updateArrayBuffer=function(e){this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,e)},e.prototype._vertexAttribPointer=function(e,t,i,r,n,o,s){var a=this._currentBufferPointers[t];if(a){var h=!1;a.active?(a.buffer!==e&&(a.buffer=e,h=!0),a.size!==i&&(a.size=i,h=!0),a.type!==r&&(a.type=r,h=!0),a.normalized!==n&&(a.normalized=n,h=!0),a.stride!==o&&(a.stride=o,h=!0),a.offset!==s&&(a.offset=s,h=!0)):(h=!0,a.active=!0,a.index=t,a.size=i,a.type=r,a.normalized=n,a.stride=o,a.offset=s,a.buffer=e),(h||this._vaoRecordInProgress)&&(this.bindArrayBuffer(e),this._gl.vertexAttribPointer(t,i,r,n,o,s))}},e.prototype._bindIndexBufferWithCache=function(e){null!=e&&this._cachedIndexBuffer!==e&&(this._cachedIndexBuffer=e,this.bindIndexBuffer(e),this._uintIndicesCurrentlySet=e.is32Bits)},e.prototype._bindVertexBuffersAttributes=function(e,t){var i=t.getAttributesNames();this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.unbindAllAttributes();for(var r=0;r<i.length;r++){var n=t.getAttributeLocation(r);if(n>=0){var o=e[i[r]];if(!o)continue;this._gl.enableVertexAttribArray(n),this._vaoRecordInProgress||(this._vertexAttribArraysEnabled[n]=!0);var s=o.getBuffer();s&&(this._vertexAttribPointer(s,n,o.getSize(),o.type,o.normalized,o.byteStride,o.byteOffset),o.getIsInstanced()&&(this._gl.vertexAttribDivisor(n,o.getInstanceDivisor()),this._vaoRecordInProgress||(this._currentInstanceLocations.push(n),this._currentInstanceBuffers.push(s))))}}},e.prototype.recordVertexArrayObject=function(e,t,i){var r=this._gl.createVertexArray();return this._vaoRecordInProgress=!0,this._gl.bindVertexArray(r),this._mustWipeVertexAttributes=!0,this._bindVertexBuffersAttributes(e,i),this.bindIndexBuffer(t),this._vaoRecordInProgress=!1,this._gl.bindVertexArray(null),r},e.prototype.bindVertexArrayObject=function(e,t){this._cachedVertexArrayObject!==e&&(this._cachedVertexArrayObject=e,this._gl.bindVertexArray(e),this._cachedVertexBuffers=null,this._cachedIndexBuffer=null,this._uintIndicesCurrentlySet=null!=t&&t.is32Bits,this._mustWipeVertexAttributes=!0)},e.prototype.bindBuffersDirectly=function(e,t,i,r,n){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==n){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=n;var o=n.getAttributesCount();this._unbindVertexArrayObject(),this.unbindAllAttributes();for(var s=0,a=0;a<o;a++)if(a<i.length){var h=n.getAttributeLocation(a);h>=0&&(this._gl.enableVertexAttribArray(h),this._vertexAttribArraysEnabled[h]=!0,this._vertexAttribPointer(e,h,i[a],this._gl.FLOAT,!1,r,s)),s+=4*i[a]}}this._bindIndexBufferWithCache(t)},e.prototype._unbindVertexArrayObject=function(){this._cachedVertexArrayObject&&(this._cachedVertexArrayObject=null,this._gl.bindVertexArray(null))},e.prototype.bindBuffers=function(e,t,i){this._cachedVertexBuffers===e&&this._cachedEffectForVertexBuffers===i||(this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=i,this._bindVertexBuffersAttributes(e,i)),this._bindIndexBufferWithCache(t)},e.prototype.unbindInstanceAttributes=function(){for(var e,t=0,i=this._currentInstanceLocations.length;t<i;t++){var r=this._currentInstanceBuffers[t];e!=r&&r.references&&(e=r,this.bindArrayBuffer(r));var n=this._currentInstanceLocations[t];this._gl.vertexAttribDivisor(n,0)}this._currentInstanceBuffers.length=0,this._currentInstanceLocations.length=0},e.prototype.releaseVertexArrayObject=function(e){this._gl.deleteVertexArray(e)},e.prototype._releaseBuffer=function(e){return e.references--,0===e.references&&(this._deleteBuffer(e),!0)},e.prototype._deleteBuffer=function(e){this._gl.deleteBuffer(e.underlyingResource)},e.prototype.updateAndBindInstancesBuffer=function(e,t,i){if(this.bindArrayBuffer(e),t&&this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,t),void 0!==i[0].index)this.bindInstancesBuffer(e,i,!0);else for(var r=0;r<4;r++){var n=i[r];this._vertexAttribArraysEnabled[n]||(this._gl.enableVertexAttribArray(n),this._vertexAttribArraysEnabled[n]=!0),this._vertexAttribPointer(e,n,4,this._gl.FLOAT,!1,64,16*r),this._gl.vertexAttribDivisor(n,1),this._currentInstanceLocations.push(n),this._currentInstanceBuffers.push(e)}},e.prototype.bindInstancesBuffer=function(e,t,i){void 0===i&&(i=!0),this.bindArrayBuffer(e);var r=0;if(i)for(var n=0;n<t.length;n++){r+=4*(o=t[n]).attributeSize}for(n=0;n<t.length;n++){var o;void 0===(o=t[n]).index&&(o.index=this._currentEffect.getAttributeLocationByName(o.attributeName)),o.index<0||(this._vertexAttribArraysEnabled[o.index]||(this._gl.enableVertexAttribArray(o.index),this._vertexAttribArraysEnabled[o.index]=!0),this._vertexAttribPointer(e,o.index,o.attributeSize,o.attributeType||this._gl.FLOAT,o.normalized||!1,r,o.offset),this._gl.vertexAttribDivisor(o.index,void 0===o.divisor?1:o.divisor),this._currentInstanceLocations.push(o.index),this._currentInstanceBuffers.push(e))}},e.prototype.disableInstanceAttributeByName=function(e){if(this._currentEffect){var t=this._currentEffect.getAttributeLocationByName(e);this.disableInstanceAttribute(t)}},e.prototype.disableInstanceAttribute=function(e){for(var t,i=!1;-1!==(t=this._currentInstanceLocations.indexOf(e));)this._currentInstanceLocations.splice(t,1),this._currentInstanceBuffers.splice(t,1),i=!0,t=this._currentInstanceLocations.indexOf(e);i&&(this._gl.vertexAttribDivisor(e,0),this.disableAttributeByIndex(e))},e.prototype.disableAttributeByIndex=function(e){this._gl.disableVertexAttribArray(e),this._vertexAttribArraysEnabled[e]=!1,this._currentBufferPointers[e].active=!1},e.prototype.draw=function(e,t,i,r){this.drawElementsType(e?0:1,t,i,r)},e.prototype.drawPointClouds=function(e,t,i){this.drawArraysType(2,e,t,i)},e.prototype.drawUnIndexed=function(e,t,i,r){this.drawArraysType(e?0:1,t,i,r)},e.prototype.drawElementsType=function(e,t,i,r){this.applyStates(),this._reportDrawCall();var n=this._drawMode(e),o=this._uintIndicesCurrentlySet?this._gl.UNSIGNED_INT:this._gl.UNSIGNED_SHORT,s=this._uintIndicesCurrentlySet?4:2;r?this._gl.drawElementsInstanced(n,i,o,t*s,r):this._gl.drawElements(n,i,o,t*s)},e.prototype.drawArraysType=function(e,t,i,r){this.applyStates(),this._reportDrawCall();var n=this._drawMode(e);r?this._gl.drawArraysInstanced(n,t,i,r):this._gl.drawArrays(n,t,i)},e.prototype._drawMode=function(e){switch(e){case 0:default:return this._gl.TRIANGLES;case 2:case 3:return this._gl.POINTS;case 1:case 4:return this._gl.LINES;case 5:return this._gl.LINE_LOOP;case 6:return this._gl.LINE_STRIP;case 7:return this._gl.TRIANGLE_STRIP;case 8:return this._gl.TRIANGLE_FAN}},e.prototype._reportDrawCall=function(){},e.prototype._releaseEffect=function(e){this._compiledEffects[e._key]&&(delete this._compiledEffects[e._key],this._deletePipelineContext(e.getPipelineContext()))},e.prototype._deletePipelineContext=function(e){var t=e;t&&t.program&&(t.program.__SPECTOR_rebuildProgram=null,this._gl.deleteProgram(t.program))},e.prototype.createEffect=function(e,t,i,r,n,o,s,a,h){var u=(e.vertexElement||e.vertex||e.vertexToken||e.vertexSource||e)+"+"+(e.fragmentElement||e.fragment||e.fragmentToken||e.fragmentSource||e)+"@"+(n||t.defines);if(this._compiledEffects[u]){var l=this._compiledEffects[u];return s&&l.isReady()&&s(l),l}var c=new he(e,t,i,r,this,n,o,s,a,h);return c._key=u,this._compiledEffects[u]=c,c},e._ConcatenateShader=function(e,t,i){return void 0===i&&(i=""),i+(t?t+"\n":"")+e},e.prototype._compileShader=function(t,i,r,n){return this._compileRawShader(e._ConcatenateShader(t,r,n),i)},e.prototype._compileRawShader=function(e,t){var i=this._gl,r=i.createShader("vertex"===t?i.VERTEX_SHADER:i.FRAGMENT_SHADER);if(!r)throw new Error("Something went wrong while compile the shader.");return i.shaderSource(r,e),i.compileShader(r),r},e.prototype._getShaderSource=function(e){return this._gl.getShaderSource(e)},e.prototype.createRawShaderProgram=function(e,t,i,r,n){void 0===n&&(n=null),r=r||this._gl;var o=this._compileRawShader(t,"vertex"),s=this._compileRawShader(i,"fragment");return this._createShaderProgram(e,o,s,r,n)},e.prototype.createShaderProgram=function(e,t,i,r,n,o){void 0===o&&(o=null),n=n||this._gl;var s=this._webGLVersion>1?"#version 300 es\n#define WEBGL2 \n":"",a=this._compileShader(t,"vertex",r,s),h=this._compileShader(i,"fragment",r,s);return this._createShaderProgram(e,a,h,n,o)},e.prototype.createPipelineContext=function(){var e=new me;return e.engine=this,this._caps.parallelShaderCompile&&(e.isParallelCompiled=!0),e},e.prototype._createShaderProgram=function(e,t,i,r,n){var o=r.createProgram();if(e.program=o,!o)throw new Error("Unable to create program");return r.attachShader(o,t),r.attachShader(o,i),r.linkProgram(o),e.context=r,e.vertexShader=t,e.fragmentShader=i,e.isParallelCompiled||this._finalizePipelineContext(e),o},e.prototype._finalizePipelineContext=function(e){var t=e.context,i=e.vertexShader,r=e.fragmentShader,n=e.program;if(!t.getProgramParameter(n,t.LINK_STATUS)){var o,s;if(!this._gl.getShaderParameter(i,this._gl.COMPILE_STATUS))if(o=this._gl.getShaderInfoLog(i))throw e.vertexCompilationError=o,new Error("VERTEX SHADER "+o);if(!this._gl.getShaderParameter(r,this._gl.COMPILE_STATUS))if(o=this._gl.getShaderInfoLog(r))throw e.fragmentCompilationError=o,new Error("FRAGMENT SHADER "+o);if(s=t.getProgramInfoLog(n))throw e.programLinkError=s,new Error(s)}if(this.validateShaderPrograms&&(t.validateProgram(n),!t.getProgramParameter(n,t.VALIDATE_STATUS)&&(s=t.getProgramInfoLog(n))))throw e.programValidationError=s,new Error(s);t.deleteShader(i),t.deleteShader(r),e.vertexShader=void 0,e.fragmentShader=void 0,e.onCompiled&&(e.onCompiled(),e.onCompiled=void 0)},e.prototype._preparePipelineContext=function(e,t,i,r,n,o,s){var a=e;a.program=r?this.createRawShaderProgram(a,t,i,void 0,s):this.createShaderProgram(a,t,i,o,void 0,s),a.program.__SPECTOR_rebuildProgram=n},e.prototype._isRenderingStateCompiled=function(e){var t=e;return!!this._gl.getProgramParameter(t.program,this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR)&&(this._finalizePipelineContext(t),!0)},e.prototype._executeWhenRenderingStateIsCompiled=function(e,t){var i=e;if(i.isParallelCompiled){var r=i.onCompiled;i.onCompiled=r?function(){r(),t()}:t}else t()},e.prototype.getUniforms=function(e,t){for(var i=new Array,r=e,n=0;n<t.length;n++)i.push(this._gl.getUniformLocation(r.program,t[n]));return i},e.prototype.getAttributes=function(e,t){for(var i=[],r=e,n=0;n<t.length;n++)try{i.push(this._gl.getAttribLocation(r.program,t[n]))}catch(e){i.push(-1)}return i},e.prototype.enableEffect=function(e){e&&e!==this._currentEffect&&(this.bindSamplers(e),this._currentEffect=e,e.onBind&&e.onBind(e),e._onBindObservable&&e._onBindObservable.notifyObservers(e))},e.prototype.setInt=function(e,t){return!!e&&(this._gl.uniform1i(e,t),!0)},e.prototype.setIntArray=function(e,t){return!!e&&(this._gl.uniform1iv(e,t),!0)},e.prototype.setIntArray2=function(e,t){return!(!e||t.length%2!=0)&&(this._gl.uniform2iv(e,t),!0)},e.prototype.setIntArray3=function(e,t){return!(!e||t.length%3!=0)&&(this._gl.uniform3iv(e,t),!0)},e.prototype.setIntArray4=function(e,t){return!(!e||t.length%4!=0)&&(this._gl.uniform4iv(e,t),!0)},e.prototype.setArray=function(e,t){return!!e&&(this._gl.uniform1fv(e,t),!0)},e.prototype.setArray2=function(e,t){return!(!e||t.length%2!=0)&&(this._gl.uniform2fv(e,t),!0)},e.prototype.setArray3=function(e,t){return!(!e||t.length%3!=0)&&(this._gl.uniform3fv(e,t),!0)},e.prototype.setArray4=function(e,t){return!(!e||t.length%4!=0)&&(this._gl.uniform4fv(e,t),!0)},e.prototype.setMatrices=function(e,t){return!!e&&(this._gl.uniformMatrix4fv(e,!1,t),!0)},e.prototype.setMatrix3x3=function(e,t){return!!e&&(this._gl.uniformMatrix3fv(e,!1,t),!0)},e.prototype.setMatrix2x2=function(e,t){return!!e&&(this._gl.uniformMatrix2fv(e,!1,t),!0)},e.prototype.setFloat=function(e,t){return!!e&&(this._gl.uniform1f(e,t),!0)},e.prototype.setFloat2=function(e,t,i){return!!e&&(this._gl.uniform2f(e,t,i),!0)},e.prototype.setFloat3=function(e,t,i,r){return!!e&&(this._gl.uniform3f(e,t,i,r),!0)},e.prototype.setFloat4=function(e,t,i,r,n){return!!e&&(this._gl.uniform4f(e,t,i,r,n),!0)},e.prototype.applyStates=function(){if(this._depthCullingState.apply(this._gl),this._stencilState.apply(this._gl),this._alphaState.apply(this._gl),this._colorWriteChanged){this._colorWriteChanged=!1;var e=this._colorWrite;this._gl.colorMask(e,e,e,e)}},e.prototype.setColorWrite=function(e){e!==this._colorWrite&&(this._colorWriteChanged=!0,this._colorWrite=e)},e.prototype.getColorWrite=function(){return this._colorWrite},Object.defineProperty(e.prototype,"depthCullingState",{get:function(){return this._depthCullingState},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"alphaState",{get:function(){return this._alphaState},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilState",{get:function(){return this._stencilState},enumerable:!1,configurable:!0}),e.prototype.clearInternalTexturesCache=function(){this._internalTexturesCache=[]},e.prototype.wipeCaches=function(e){this.preventCacheWipeBetweenFrames&&!e||(this._currentEffect=null,this._viewportCached.x=0,this._viewportCached.y=0,this._viewportCached.z=0,this._viewportCached.w=0,this._unbindVertexArrayObject(),e&&(this._currentProgram=null,this.resetTextureCache(),this._stencilState.reset(),this._depthCullingState.reset(),this._depthCullingState.depthFunc=this._gl.LEQUAL,this._alphaState.reset(),this._alphaMode=1,this._alphaEquation=0,this._colorWrite=!0,this._colorWriteChanged=!0,this._unpackFlipYCached=null,this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL,this._gl.NONE),this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),this._mustWipeVertexAttributes=!0,this.unbindAllAttributes()),this._resetVertexBufferBinding(),this._cachedIndexBuffer=null,this._cachedEffectForVertexBuffers=null,this.bindIndexBuffer(null))},e.prototype._getSamplingParameters=function(e,t){var i=this._gl,r=i.NEAREST,n=i.NEAREST;switch(e){case 11:r=i.LINEAR,n=t?i.LINEAR_MIPMAP_NEAREST:i.LINEAR;break;case 3:r=i.LINEAR,n=t?i.LINEAR_MIPMAP_LINEAR:i.LINEAR;break;case 8:r=i.NEAREST,n=t?i.NEAREST_MIPMAP_LINEAR:i.NEAREST;break;case 4:r=i.NEAREST,n=t?i.NEAREST_MIPMAP_NEAREST:i.NEAREST;break;case 5:r=i.NEAREST,n=t?i.LINEAR_MIPMAP_NEAREST:i.LINEAR;break;case 6:r=i.NEAREST,n=t?i.LINEAR_MIPMAP_LINEAR:i.LINEAR;break;case 7:r=i.NEAREST,n=i.LINEAR;break;case 1:r=i.NEAREST,n=i.NEAREST;break;case 9:r=i.LINEAR,n=t?i.NEAREST_MIPMAP_NEAREST:i.NEAREST;break;case 10:r=i.LINEAR,n=t?i.NEAREST_MIPMAP_LINEAR:i.NEAREST;break;case 2:r=i.LINEAR,n=i.LINEAR;break;case 12:r=i.LINEAR,n=i.NEAREST}return{min:n,mag:r}},e.prototype._createTexture=function(){var e=this._gl.createTexture();if(!e)throw new Error("Unable to create texture");return e},e.prototype.createTexture=function(t,i,r,n,o,s,a,h,u,l,c,f,d){var p=this;void 0===o&&(o=3),void 0===s&&(s=null),void 0===a&&(a=null),void 0===h&&(h=null),void 0===u&&(u=null),void 0===l&&(l=null),void 0===c&&(c=null);var _="data:"===(t=t||"").substr(0,5),g="blob:"===t.substr(0,5),m=_&&-1!==t.indexOf(";base64,"),v=u||new de(this,z.Url),y=t;!this._transformTextureUrl||m||u||h||(t=this._transformTextureUrl(t)),y!==t&&(v._originalUrl=y);var b=t.lastIndexOf("."),T=c||(b>-1?t.substring(b).toLowerCase():""),E=null;T.indexOf("?")>-1&&(T=T.split("?")[0]);for(var x=0,A=e._TextureLoaders;x<A.length;x++){var M=A[x];if(M.canLoad(T,f)){E=M;break}}n&&n._addPendingData(v),v.url=t,v.generateMipMaps=!i,v.samplingMode=o,v.invertY=r,this._doNotHandleContextLost||(v._buffer=h);var P=null;s&&!u&&(P=v.onLoadedObservable.add(s)),u||this._internalTexturesCache.push(v);var C=function(e,r){n&&n._removePendingData(v),t===y?(P&&v.onLoadedObservable.remove(P),V.UseFallbackTexture&&p.createTexture(V.FallbackTexture,i,v.invertY,n,o,null,a,h,v),a&&a((e||"Unknown error")+(V.UseFallbackTexture?" - Fallback texture was used":""),r)):(q.Warn("Failed to load "+t+", falling back to "+y),p.createTexture(y,i,v.invertY,n,o,s,a,h,v,l,c,f,d))};if(E){var S=function(e){E.loadData(e,v,(function(e,t,i,r,s,a){a?C("TextureLoader failed to load data"):p._prepareWebGLTexture(v,n,e,t,v.invertY,!i,r,(function(){return s(),!1}),o)}),d)};h?h instanceof ArrayBuffer?S(new Uint8Array(h)):ArrayBuffer.isView(h)?S(h):a&&a("Unable to load: only ArrayBuffer or ArrayBufferView is supported",null):this._loadFile(t,(function(e){return S(new Uint8Array(e))}),void 0,n?n.offlineProvider:void 0,!0,(function(e,t){C("Unable to load "+(e&&e.responseURL,t))}))}else{var I=function(e){g&&!p._doNotHandleContextLost&&(v._buffer=e),p._prepareWebGLTexture(v,n,e.width,e.height,v.invertY,i,!1,(function(t,i,r){var o=p._gl,s=e.width===t&&e.height===i,a=l?p._getInternalFormat(l):".jpg"===T?o.RGB:o.RGBA;if(s)return o.texImage2D(o.TEXTURE_2D,0,a,a,o.UNSIGNED_BYTE,e),!1;var h=p._caps.maxTextureSize;if(e.width>h||e.height>h||!p._supportsHardwareTextureRescaling)return p._prepareWorkingCanvas(),!(!p._workingCanvas||!p._workingContext)&&(p._workingCanvas.width=t,p._workingCanvas.height=i,p._workingContext.drawImage(e,0,0,e.width,e.height,0,0,t,i),o.texImage2D(o.TEXTURE_2D,0,a,a,o.UNSIGNED_BYTE,p._workingCanvas),v.width=t,v.height=i,!1);var u=new de(p,z.Temp);return p._bindTextureDirectly(o.TEXTURE_2D,u,!0),o.texImage2D(o.TEXTURE_2D,0,a,a,o.UNSIGNED_BYTE,e),p._rescaleTexture(u,v,n,a,(function(){p._releaseTexture(u),p._bindTextureDirectly(o.TEXTURE_2D,v,!0),r()})),!0}),o)};!_||m?h&&(h.decoding||h.close)?I(h):e._FileToolsLoadImage(t,I,C,n?n.offlineProvider:null,f):"string"==typeof h||h instanceof ArrayBuffer||ArrayBuffer.isView(h)||h instanceof Blob?e._FileToolsLoadImage(h,I,C,n?n.offlineProvider:null,f):h&&I(h)}return v},e._FileToolsLoadImage=function(e,t,i,r,n){throw b.WarnImport("FileTools")},e.prototype._rescaleTexture=function(e,t,i,r,n){},e.prototype.createRawTexture=function(e,t,i,r,n,o,s,a,h){throw b.WarnImport("Engine.RawTexture")},e.prototype.createRawCubeTexture=function(e,t,i,r,n,o,s,a){throw b.WarnImport("Engine.RawTexture")},e.prototype.createRawTexture3D=function(e,t,i,r,n,o,s,a,h,u){throw b.WarnImport("Engine.RawTexture")},e.prototype.createRawTexture2DArray=function(e,t,i,r,n,o,s,a,h,u){throw b.WarnImport("Engine.RawTexture")},e.prototype._unpackFlipY=function(e){this._unpackFlipYCached!==e&&(this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,e?1:0),this.enableUnpackFlipYCached&&(this._unpackFlipYCached=e))},e.prototype._getUnpackAlignement=function(){return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT)},e.prototype._getTextureTarget=function(e){return e.isCube?this._gl.TEXTURE_CUBE_MAP:e.is3D?this._gl.TEXTURE_3D:e.is2DArray||e.isMultiview?this._gl.TEXTURE_2D_ARRAY:this._gl.TEXTURE_2D},e.prototype.updateTextureSamplingMode=function(e,t,i){void 0===i&&(i=!1);var r=this._getTextureTarget(t),n=this._getSamplingParameters(e,t.generateMipMaps||i);this._setTextureParameterInteger(r,this._gl.TEXTURE_MAG_FILTER,n.mag,t),this._setTextureParameterInteger(r,this._gl.TEXTURE_MIN_FILTER,n.min),i&&(t.generateMipMaps=!0,this._gl.generateMipmap(r)),this._bindTextureDirectly(r,null),t.samplingMode=e},e.prototype.updateTextureWrappingMode=function(e,t,i,r){void 0===i&&(i=null),void 0===r&&(r=null);var n=this._getTextureTarget(e);null!==t&&(this._setTextureParameterInteger(n,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(t),e),e._cachedWrapU=t),null!==i&&(this._setTextureParameterInteger(n,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(i),e),e._cachedWrapV=i),(e.is2DArray||e.is3D)&&null!==r&&(this._setTextureParameterInteger(n,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(r),e),e._cachedWrapR=r),this._bindTextureDirectly(n,null)},e.prototype._setupDepthStencilTexture=function(e,t,i,r,n){var o=t.width||t,s=t.height||t,a=t.layers||0;e.baseWidth=o,e.baseHeight=s,e.width=o,e.height=s,e.is2DArray=a>0,e.depth=a,e.isReady=!0,e.samples=1,e.generateMipMaps=!1,e._generateDepthBuffer=!0,e._generateStencilBuffer=i,e.samplingMode=r?2:1,e.type=0,e._comparisonFunction=n;var h=this._gl,u=this._getTextureTarget(e),l=this._getSamplingParameters(e.samplingMode,!1);h.texParameteri(u,h.TEXTURE_MAG_FILTER,l.mag),h.texParameteri(u,h.TEXTURE_MIN_FILTER,l.min),h.texParameteri(u,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(u,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),0===n?(h.texParameteri(u,h.TEXTURE_COMPARE_FUNC,515),h.texParameteri(u,h.TEXTURE_COMPARE_MODE,h.NONE)):(h.texParameteri(u,h.TEXTURE_COMPARE_FUNC,n),h.texParameteri(u,h.TEXTURE_COMPARE_MODE,h.COMPARE_REF_TO_TEXTURE))},e.prototype._uploadCompressedDataToTextureDirectly=function(e,t,i,r,n,o,s){void 0===o&&(o=0),void 0===s&&(s=0);var a=this._gl,h=a.TEXTURE_2D;e.isCube&&(h=a.TEXTURE_CUBE_MAP_POSITIVE_X+o),this._gl.compressedTexImage2D(h,s,t,i,r,0,n)},e.prototype._uploadDataToTextureDirectly=function(e,t,i,r,n,o){void 0===i&&(i=0),void 0===r&&(r=0),void 0===o&&(o=!1);var s=this._gl,a=this._getWebGLTextureType(e.type),h=this._getInternalFormat(e.format),u=void 0===n?this._getRGBABufferInternalSizedFormat(e.type,e.format):this._getInternalFormat(n);this._unpackFlipY(e.invertY);var l=s.TEXTURE_2D;e.isCube&&(l=s.TEXTURE_CUBE_MAP_POSITIVE_X+i);var c=Math.round(Math.log(e.width)*Math.LOG2E),f=Math.round(Math.log(e.height)*Math.LOG2E),d=o?e.width:Math.pow(2,Math.max(c-r,0)),p=o?e.height:Math.pow(2,Math.max(f-r,0));s.texImage2D(l,r,u,d,p,0,h,a,t)},e.prototype.updateTextureData=function(e,t,i,r,n,o,s,a){void 0===s&&(s=0),void 0===a&&(a=0);var h=this._gl,u=this._getWebGLTextureType(e.type),l=this._getInternalFormat(e.format);this._unpackFlipY(e.invertY);var c=h.TEXTURE_2D;e.isCube&&(c=h.TEXTURE_CUBE_MAP_POSITIVE_X+s),h.texSubImage2D(c,a,i,r,n,o,l,u,t)},e.prototype._uploadArrayBufferViewToTexture=function(e,t,i,r){void 0===i&&(i=0),void 0===r&&(r=0);var n=this._gl,o=e.isCube?n.TEXTURE_CUBE_MAP:n.TEXTURE_2D;this._bindTextureDirectly(o,e,!0),this._uploadDataToTextureDirectly(e,t,i,r),this._bindTextureDirectly(o,null,!0)},e.prototype._prepareWebGLTextureContinuation=function(e,t,i,r,n){var o=this._gl;if(o){var s=this._getSamplingParameters(n,!i);o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,s.mag),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,s.min),i||r||o.generateMipmap(o.TEXTURE_2D),this._bindTextureDirectly(o.TEXTURE_2D,null),t&&t._removePendingData(e),e.onLoadedObservable.notifyObservers(e),e.onLoadedObservable.clear()}},e.prototype._prepareWebGLTexture=function(t,i,r,n,o,s,a,h,u){var l=this;void 0===u&&(u=3);var c=this.getCaps().maxTextureSize,f=Math.min(c,this.needPOTTextures?e.GetExponentOfTwo(r,c):r),d=Math.min(c,this.needPOTTextures?e.GetExponentOfTwo(n,c):n),p=this._gl;p&&(t._webGLTexture?(this._bindTextureDirectly(p.TEXTURE_2D,t,!0),this._unpackFlipY(void 0===o||!!o),t.baseWidth=r,t.baseHeight=n,t.width=f,t.height=d,t.isReady=!0,h(f,d,(function(){l._prepareWebGLTextureContinuation(t,i,s,a,u)}))||this._prepareWebGLTextureContinuation(t,i,s,a,u)):i&&i._removePendingData(t))},e.prototype._setupFramebufferDepthAttachments=function(e,t,i,r,n){void 0===n&&(n=1);var o=this._gl;if(e&&t)return this._getDepthStencilBuffer(i,r,n,o.DEPTH_STENCIL,o.DEPTH24_STENCIL8,o.DEPTH_STENCIL_ATTACHMENT);if(t){var s=o.DEPTH_COMPONENT16;return this._webGLVersion>1&&(s=o.DEPTH_COMPONENT32F),this._getDepthStencilBuffer(i,r,n,s,s,o.DEPTH_ATTACHMENT)}return e?this._getDepthStencilBuffer(i,r,n,o.STENCIL_INDEX8,o.STENCIL_INDEX8,o.STENCIL_ATTACHMENT):null},e.prototype._releaseFramebufferObjects=function(e){var t=this._gl;e._framebuffer&&(t.deleteFramebuffer(e._framebuffer),e._framebuffer=null),e._depthStencilBuffer&&(t.deleteRenderbuffer(e._depthStencilBuffer),e._depthStencilBuffer=null),e._MSAAFramebuffer&&(t.deleteFramebuffer(e._MSAAFramebuffer),e._MSAAFramebuffer=null),e._MSAARenderBuffer&&(t.deleteRenderbuffer(e._MSAARenderBuffer),e._MSAARenderBuffer=null)},e.prototype._releaseTexture=function(e){this._releaseFramebufferObjects(e),this._deleteTexture(e._webGLTexture),this.unbindAllTextures();var t=this._internalTexturesCache.indexOf(e);-1!==t&&this._internalTexturesCache.splice(t,1),e._lodTextureHigh&&e._lodTextureHigh.dispose(),e._lodTextureMid&&e._lodTextureMid.dispose(),e._lodTextureLow&&e._lodTextureLow.dispose(),e._irradianceTexture&&e._irradianceTexture.dispose()},e.prototype._deleteTexture=function(e){this._gl.deleteTexture(e)},e.prototype._setProgram=function(e){this._currentProgram!==e&&(this._gl.useProgram(e),this._currentProgram=e)},e.prototype.bindSamplers=function(e){var t=e.getPipelineContext();this._setProgram(t.program);for(var i=e.getSamplers(),r=0;r<i.length;r++){var n=e.getUniform(i[r]);n&&(this._boundUniforms[r]=n)}this._currentEffect=null},e.prototype._activateCurrentTexture=function(){this._currentTextureChannel!==this._activeChannel&&(this._gl.activeTexture(this._gl.TEXTURE0+this._activeChannel),this._currentTextureChannel=this._activeChannel)},e.prototype._bindTextureDirectly=function(e,t,i,r){void 0===i&&(i=!1),void 0===r&&(r=!1);var n=!1,o=t&&t._associatedChannel>-1;return i&&o&&(this._activeChannel=t._associatedChannel),this._boundTexturesCache[this._activeChannel]!==t||r?(this._activateCurrentTexture(),t&&t.isMultiview?this._gl.bindTexture(e,t?t._colorTextureArray:null):this._gl.bindTexture(e,t?t._webGLTexture:null),this._boundTexturesCache[this._activeChannel]=t,t&&(t._associatedChannel=this._activeChannel)):i&&(n=!0,this._activateCurrentTexture()),o&&!i&&this._bindSamplerUniformToChannel(t._associatedChannel,this._activeChannel),n},e.prototype._bindTexture=function(e,t){if(void 0!==e){t&&(t._associatedChannel=e),this._activeChannel=e;var i=t?this._getTextureTarget(t):this._gl.TEXTURE_2D;this._bindTextureDirectly(i,t)}},e.prototype.unbindAllTextures=function(){for(var e=0;e<this._maxSimultaneousTextures;e++)this._activeChannel=e,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))},e.prototype.setTexture=function(e,t,i){void 0!==e&&(t&&(this._boundUniforms[e]=t),this._setTexture(e,i))},e.prototype._bindSamplerUniformToChannel=function(e,t){var i=this._boundUniforms[e];i&&i._currentState!==t&&(this._gl.uniform1i(i,t),i._currentState=t)},e.prototype._getTextureWrapMode=function(e){switch(e){case 1:return this._gl.REPEAT;case 0:return this._gl.CLAMP_TO_EDGE;case 2:return this._gl.MIRRORED_REPEAT}return this._gl.REPEAT},e.prototype._setTexture=function(e,t,i,r){if(void 0===i&&(i=!1),void 0===r&&(r=!1),!t)return null!=this._boundTexturesCache[e]&&(this._activeChannel=e,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(t.video)this._activeChannel=e,t.update();else if(4===t.delayLoadState)return t.delayLoad(),!1;var n;n=r?t.depthStencilTexture:t.isReady()?t.getInternalTexture():t.isCube?this.emptyCubeTexture:t.is3D?this.emptyTexture3D:t.is2DArray?this.emptyTexture2DArray:this.emptyTexture,!i&&n&&(n._associatedChannel=e);var o=!0;this._boundTexturesCache[e]===n&&(i||this._bindSamplerUniformToChannel(n._associatedChannel,e),o=!1),this._activeChannel=e;var s=this._getTextureTarget(n);if(o&&this._bindTextureDirectly(s,n,i),n&&!n.isMultiview){if(n.isCube&&n._cachedCoordinatesMode!==t.coordinatesMode){n._cachedCoordinatesMode=t.coordinatesMode;var a=3!==t.coordinatesMode&&5!==t.coordinatesMode?1:0;t.wrapU=a,t.wrapV=a}n._cachedWrapU!==t.wrapU&&(n._cachedWrapU=t.wrapU,this._setTextureParameterInteger(s,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(t.wrapU),n)),n._cachedWrapV!==t.wrapV&&(n._cachedWrapV=t.wrapV,this._setTextureParameterInteger(s,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(t.wrapV),n)),n.is3D&&n._cachedWrapR!==t.wrapR&&(n._cachedWrapR=t.wrapR,this._setTextureParameterInteger(s,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(t.wrapR),n)),this._setAnisotropicLevel(s,n,t.anisotropicFilteringLevel)}return!0},e.prototype.setTextureArray=function(e,t,i){if(void 0!==e&&t){this._textureUnits&&this._textureUnits.length===i.length||(this._textureUnits=new Int32Array(i.length));for(var r=0;r<i.length;r++){var n=i[r].getInternalTexture();n?(this._textureUnits[r]=e+r,n._associatedChannel=e+r):this._textureUnits[r]=-1}this._gl.uniform1iv(t,this._textureUnits);for(var o=0;o<i.length;o++)this._setTexture(this._textureUnits[o],i[o],!0)}},e.prototype._setAnisotropicLevel=function(e,t,i){var r=this._caps.textureAnisotropicFilterExtension;11!==t.samplingMode&&3!==t.samplingMode&&2!==t.samplingMode&&(i=1),r&&t._cachedAnisotropicFilteringLevel!==i&&(this._setTextureParameterFloat(e,r.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(i,this._caps.maxAnisotropy),t),t._cachedAnisotropicFilteringLevel=i)},e.prototype._setTextureParameterFloat=function(e,t,i,r){this._bindTextureDirectly(e,r,!0,!0),this._gl.texParameterf(e,t,i)},e.prototype._setTextureParameterInteger=function(e,t,i,r){r&&this._bindTextureDirectly(e,r,!0,!0),this._gl.texParameteri(e,t,i)},e.prototype.unbindAllAttributes=function(){if(this._mustWipeVertexAttributes){this._mustWipeVertexAttributes=!1;for(var e=0;e<this._caps.maxVertexAttribs;e++)this.disableAttributeByIndex(e)}else{e=0;for(var t=this._vertexAttribArraysEnabled.length;e<t;e++)e>=this._caps.maxVertexAttribs||!this._vertexAttribArraysEnabled[e]||this.disableAttributeByIndex(e)}},e.prototype.releaseEffects=function(){for(var e in this._compiledEffects){var t=this._compiledEffects[e].getPipelineContext();this._deletePipelineContext(t)}this._compiledEffects={}},e.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=[],H.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,he.ResetCache();for(var e=0,t=this._activeRequests;e<t.length;e++){t[e].abort()}},e.prototype.attachContextLostEvent=function(e){this._renderingCanvas&&this._renderingCanvas.addEventListener("webglcontextlost",e,!1)},e.prototype.attachContextRestoredEvent=function(e){this._renderingCanvas&&this._renderingCanvas.addEventListener("webglcontextrestored",e,!1)},e.prototype.getError=function(){return this._gl.getError()},e.prototype._canRenderToFloatFramebuffer=function(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(1)},e.prototype._canRenderToHalfFloatFramebuffer=function(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(2)},e.prototype._canRenderToFramebuffer=function(e){for(var t=this._gl;t.getError()!==t.NO_ERROR;);var i=!0,r=t.createTexture();t.bindTexture(t.TEXTURE_2D,r),t.texImage2D(t.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(e),1,1,0,t.RGBA,this._getWebGLTextureType(e),null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST);var n=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,n),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r,0);var o=t.checkFramebufferStatus(t.FRAMEBUFFER);if((i=(i=i&&o===t.FRAMEBUFFER_COMPLETE)&&t.getError()===t.NO_ERROR)&&(t.clear(t.COLOR_BUFFER_BIT),i=i&&t.getError()===t.NO_ERROR),i){t.bindFramebuffer(t.FRAMEBUFFER,null);var s=t.RGBA,a=t.UNSIGNED_BYTE,h=new Uint8Array(4);t.readPixels(0,0,1,1,s,a,h),i=i&&t.getError()===t.NO_ERROR}for(t.deleteTexture(r),t.deleteFramebuffer(n),t.bindFramebuffer(t.FRAMEBUFFER,null);!i&&t.getError()!==t.NO_ERROR;);return i},e.prototype._getWebGLTextureType=function(e){if(1===this._webGLVersion){switch(e){case 1:return this._gl.FLOAT;case 2:return this._gl.HALF_FLOAT_OES;case 0:return this._gl.UNSIGNED_BYTE;case 8:return this._gl.UNSIGNED_SHORT_4_4_4_4;case 9:return this._gl.UNSIGNED_SHORT_5_5_5_1;case 10:return this._gl.UNSIGNED_SHORT_5_6_5}return this._gl.UNSIGNED_BYTE}switch(e){case 3:return this._gl.BYTE;case 0:return this._gl.UNSIGNED_BYTE;case 4:return this._gl.SHORT;case 5:return this._gl.UNSIGNED_SHORT;case 6:return this._gl.INT;case 7:return this._gl.UNSIGNED_INT;case 1:return this._gl.FLOAT;case 2:return this._gl.HALF_FLOAT;case 8:return this._gl.UNSIGNED_SHORT_4_4_4_4;case 9:return this._gl.UNSIGNED_SHORT_5_5_5_1;case 10:return this._gl.UNSIGNED_SHORT_5_6_5;case 11:return this._gl.UNSIGNED_INT_2_10_10_10_REV;case 12:return this._gl.UNSIGNED_INT_24_8;case 13:return this._gl.UNSIGNED_INT_10F_11F_11F_REV;case 14:return this._gl.UNSIGNED_INT_5_9_9_9_REV;case 15:return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV}return this._gl.UNSIGNED_BYTE},e.prototype._getInternalFormat=function(e){var t=this._gl.RGBA;switch(e){case 0:t=this._gl.ALPHA;break;case 1:t=this._gl.LUMINANCE;break;case 2:t=this._gl.LUMINANCE_ALPHA;break;case 6:t=this._gl.RED;break;case 7:t=this._gl.RG;break;case 4:t=this._gl.RGB;break;case 5:t=this._gl.RGBA}if(this._webGLVersion>1)switch(e){case 8:t=this._gl.RED_INTEGER;break;case 9:t=this._gl.RG_INTEGER;break;case 10:t=this._gl.RGB_INTEGER;break;case 11:t=this._gl.RGBA_INTEGER}return t},e.prototype._getRGBABufferInternalSizedFormat=function(e,t){if(1===this._webGLVersion){if(void 0!==t)switch(t){case 0:return this._gl.ALPHA;case 1:return this._gl.LUMINANCE;case 2:return this._gl.LUMINANCE_ALPHA;case 4:return this._gl.RGB}return this._gl.RGBA}switch(e){case 3:switch(t){case 6:return this._gl.R8_SNORM;case 7:return this._gl.RG8_SNORM;case 4:return this._gl.RGB8_SNORM;case 8:return this._gl.R8I;case 9:return this._gl.RG8I;case 10:return this._gl.RGB8I;case 11:return this._gl.RGBA8I;default:return this._gl.RGBA8_SNORM}case 0:switch(t){case 6:return this._gl.R8;case 7:return this._gl.RG8;case 4:return this._gl.RGB8;case 5:default:return this._gl.RGBA8;case 8:return this._gl.R8UI;case 9:return this._gl.RG8UI;case 10:return this._gl.RGB8UI;case 11:return this._gl.RGBA8UI;case 0:return this._gl.ALPHA;case 1:return this._gl.LUMINANCE;case 2:return this._gl.LUMINANCE_ALPHA}case 4:switch(t){case 8:return this._gl.R16I;case 9:return this._gl.RG16I;case 10:return this._gl.RGB16I;default:return this._gl.RGBA16I}case 5:switch(t){case 8:return this._gl.R16UI;case 9:return this._gl.RG16UI;case 10:return this._gl.RGB16UI;default:return this._gl.RGBA16UI}case 6:switch(t){case 8:return this._gl.R32I;case 9:return this._gl.RG32I;case 10:return this._gl.RGB32I;default:return this._gl.RGBA32I}case 7:switch(t){case 8:return this._gl.R32UI;case 9:return this._gl.RG32UI;case 10:return this._gl.RGB32UI;default:return this._gl.RGBA32UI}case 1:switch(t){case 6:return this._gl.R32F;case 7:return this._gl.RG32F;case 4:return this._gl.RGB32F;default:return this._gl.RGBA32F}case 2:switch(t){case 6:return this._gl.R16F;case 7:return this._gl.RG16F;case 4:return this._gl.RGB16F;default:return this._gl.RGBA16F}case 10:return this._gl.RGB565;case 13:return this._gl.R11F_G11F_B10F;case 14:return this._gl.RGB9_E5;case 8:return this._gl.RGBA4;case 9:return this._gl.RGB5_A1;case 11:switch(t){case 5:default:return this._gl.RGB10_A2;case 11:return this._gl.RGB10_A2UI}}return this._gl.RGBA8},e.prototype._getRGBAMultiSampleBufferFormat=function(e){return 1===e?this._gl.RGBA32F:2===e?this._gl.RGBA16F:this._gl.RGBA8},e.prototype._loadFile=function(t,i,r,n,o,s){var a=this,h=e._FileToolsLoadFile(t,i,r,n,o,s);return this._activeRequests.push(h),h.onCompleteObservable.add((function(e){a._activeRequests.splice(a._activeRequests.indexOf(e),1)})),h},e._FileToolsLoadFile=function(e,t,i,r,n,o){throw b.WarnImport("FileTools")},e.prototype.readPixels=function(e,t,i,r,n){void 0===n&&(n=!0);var o=n?4:3,s=n?this._gl.RGBA:this._gl.RGB,a=new Uint8Array(r*i*o);return this._gl.readPixels(e,t,i,r,s,this._gl.UNSIGNED_BYTE,a),a},Object.defineProperty(e,"IsSupported",{get:function(){return this.isSupported()},enumerable:!1,configurable:!0}),e.isSupported=function(){if(null!==this._HasMajorPerformanceCaveat)return!this._HasMajorPerformanceCaveat;if(null===this._IsSupported)try{var e=ve.CreateCanvas(1,1),t=e.getContext("webgl")||e.getContext("experimental-webgl");this._IsSupported=null!=t&&!!window.WebGLRenderingContext}catch(e){this._IsSupported=!1}return this._IsSupported},Object.defineProperty(e,"HasMajorPerformanceCaveat",{get:function(){if(null===this._HasMajorPerformanceCaveat)try{var e=ve.CreateCanvas(1,1),t=e.getContext("webgl",{failIfMajorPerformanceCaveat:!0})||e.getContext("experimental-webgl",{failIfMajorPerformanceCaveat:!0});this._HasMajorPerformanceCaveat=!t}catch(e){this._HasMajorPerformanceCaveat=!1}return this._HasMajorPerformanceCaveat},enumerable:!1,configurable:!0}),e.CeilingPOT=function(e){return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e},e.FloorPOT=function(e){return e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,(e|=e>>16)-(e>>1)},e.NearestPOT=function(t){var i=e.CeilingPOT(t),r=e.FloorPOT(t);return i-t>t-r?r:i},e.GetExponentOfTwo=function(t,i,r){var n;switch(void 0===r&&(r=2),r){case 1:n=e.FloorPOT(t);break;case 2:n=e.NearestPOT(t);break;default:n=e.CeilingPOT(t)}return Math.min(n,i)},e.QueueNewFrame=function(e,t){return H.IsWindowObjectExist()?(t||(t=window),t.requestPostAnimationFrame?t.requestPostAnimationFrame(e):t.requestAnimationFrame?t.requestAnimationFrame(e):t.msRequestAnimationFrame?t.msRequestAnimationFrame(e):t.webkitRequestAnimationFrame?t.webkitRequestAnimationFrame(e):t.mozRequestAnimationFrame?t.mozRequestAnimationFrame(e):t.oRequestAnimationFrame?t.oRequestAnimationFrame(e):window.setTimeout(e,16)):"undefined"!=typeof requestAnimationFrame?requestAnimationFrame(e):setTimeout(e,16)},e.prototype.getHostDocument=function(){return this._renderingCanvas&&this._renderingCanvas.ownerDocument?this._renderingCanvas.ownerDocument:document},e.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"]}],e._TextureLoaders=[],e.CollisionsEpsilon=.001,e._IsSupported=null,e._HasMajorPerformanceCaveat=null,e}(),Te=function(e){function i(t,r){var n=e.call(this,t)||this;return n.name="LoadFileError",K._setPrototypeOf(n,i.prototype),r instanceof G?n.request=r:n.file=r,n}return t(i,e),i}(K),Ee=function(e){function i(t,r){var n=e.call(this,t)||this;return n.request=r,n.name="RequestFileError",K._setPrototypeOf(n,i.prototype),n}return t(i,e),i}(K),xe=function(e){function i(t,r){var n=e.call(this,t)||this;return n.file=r,n.name="ReadFileError",K._setPrototypeOf(n,i.prototype),n}return t(i,e),i}(K),Ae=function(){function e(){}return e._CleanUrl=function(e){return e=e.replace(/#/gm,"%23")},e.SetCorsBehavior=function(t,i){if((!t||0!==t.indexOf("data:"))&&e.CorsBehavior)if("string"==typeof e.CorsBehavior||this.CorsBehavior instanceof String)i.crossOrigin=e.CorsBehavior;else{var r=e.CorsBehavior(t);r&&(i.crossOrigin=r)}},e.LoadImage=function(t,i,r,n,o){var s;void 0===o&&(o="");var a=!1;if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)?"undefined"!=typeof Blob?(s=URL.createObjectURL(new Blob([t],{type:o})),a=!0):s="data:"+o+";base64,"+Y.EncodeArrayBufferToBase64(t):t instanceof Blob?(s=URL.createObjectURL(t),a=!0):(s=e._CleanUrl(t),s=e.PreprocessUrl(t)),"undefined"==typeof Image)return e.LoadFile(s,(function(e){createImageBitmap(new Blob([e],{type:o})).then((function(e){i(e),a&&URL.revokeObjectURL(s)})).catch((function(e){r&&r("Error while trying to load image: "+t,e)}))}),void 0,n||void 0,!0,(function(e,i){r&&r("Error while trying to load image: "+t,i)})),null;var h=new Image;e.SetCorsBehavior(s,h);var u=function(){h.removeEventListener("load",u),h.removeEventListener("error",l),i(h),a&&h.src&&URL.revokeObjectURL(h.src)},l=function(e){if(h.removeEventListener("load",u),h.removeEventListener("error",l),r){var i=t.toString();r("Error while trying to load image: "+(i.length<32?i:i.slice(0,32)+"..."),e)}a&&h.src&&URL.revokeObjectURL(h.src)};h.addEventListener("load",u),h.addEventListener("error",l);var c=function(){h.src=s};if("data:"!==s.substr(0,5)&&n&&n.enableTexturesOffline)n.open((function(){n&&n.loadImage(s,h)}),c);else{if(-1!==s.indexOf("file:")){var f=decodeURIComponent(s.substring(5).toLowerCase());if(X.FilesToLoad[f]){try{var d;try{d=URL.createObjectURL(X.FilesToLoad[f])}catch(e){d=URL.createObjectURL(X.FilesToLoad[f])}h.src=d,a=!0}catch(e){h.src=""}return h}}c()}return h},e.ReadFile=function(e,t,i,r,n){var o=new FileReader,s={onCompleteObservable:new U,abort:function(){return o.abort()}};return o.onloadend=function(e){return s.onCompleteObservable.notifyObservers(s)},n&&(o.onerror=function(t){n(new xe("Unable to read "+e.name,e))}),o.onload=function(e){t(e.target.result)},i&&(o.onprogress=i),r?o.readAsArrayBuffer(e):o.readAsText(e),s},e.LoadFile=function(t,i,r,n,o,s){if(-1!==t.indexOf("file:")){var a=decodeURIComponent(t.substring(5).toLowerCase());0===a.indexOf("./")&&(a=a.substring(2));var h=X.FilesToLoad[a];if(h)return e.ReadFile(h,i,r,o,s?function(e){return s(void 0,new Te(e.message,e.file))}:void 0)}return e.RequestFile(t,(function(e,t){i(e,t?t.responseURL:void 0)}),r,n,o,s?function(e){s(e.request,new Te(e.message,e.request))}:void 0)},e.RequestFile=function(t,i,r,n,o,s,a){t=e._CleanUrl(t),t=e.PreprocessUrl(t);var h=e.BaseUrl+t,u=!1,l={onCompleteObservable:new U,abort:function(){return u=!0}},c=function(){var t=new G,n=null;l.abort=function(){u=!0,t.readyState!==(XMLHttpRequest.DONE||4)&&t.abort(),null!==n&&(clearTimeout(n),n=null)};var c=function(f){t.open("GET",h),a&&a(t),o&&(t.responseType="arraybuffer"),r&&t.addEventListener("progress",r);var d=function(){t.removeEventListener("loadend",d),l.onCompleteObservable.notifyObservers(l),l.onCompleteObservable.clear()};t.addEventListener("loadend",d);var p=function(){if(!u&&t.readyState===(XMLHttpRequest.DONE||4)){if(t.removeEventListener("readystatechange",p),t.status>=200&&t.status<300||0===t.status&&(!H.IsWindowObjectExist()||e.IsFileURL()))return void i(o?t.response:t.responseText,t);var r=e.DefaultRetryStrategy;if(r){var a=r(h,t,f);if(-1!==a)return t.removeEventListener("loadend",d),t=new G,void(n=setTimeout((function(){return c(f+1)}),a))}var l=new Ee("Error status: "+t.status+" "+t.statusText+" - Unable to load "+h,t);s&&s(l)}};t.addEventListener("readystatechange",p),t.send()};c(0)};if(n&&n.enableSceneOffline){var f=function(e){e&&e.status>400?s&&s(e):c()};n.open((function(){n&&n.loadFile(e.BaseUrl+t,(function(e){u||i(e),l.onCompleteObservable.notifyObservers(l)}),r?function(e){u||r(e)}:void 0,f,o)}),f)}else c();return l},e.IsFileURL=function(){return"undefined"!=typeof location&&"file:"===location.protocol},e.DefaultRetryStrategy=j.ExponentialBackoff(),e.BaseUrl="",e.CorsBehavior="anonymous",e.PreprocessUrl=function(e){return e},e}();be._FileToolsLoadImage=Ae.LoadImage.bind(Ae),be._FileToolsLoadFile=Ae.LoadFile.bind(Ae),ae._FileToolsLoadFile=Ae.LoadFile.bind(Ae);var Me=function(){function e(e,t){this.width=e,this.height=t}return e.prototype.toString=function(){return"{W: "+this.width+", H: "+this.height+"}"},e.prototype.getClassName=function(){return"Size"},e.prototype.getHashCode=function(){var e=0|this.width;return e=397*e^(0|this.height)},e.prototype.copyFrom=function(e){this.width=e.width,this.height=e.height},e.prototype.copyFromFloats=function(e,t){return this.width=e,this.height=t,this},e.prototype.set=function(e,t){return this.copyFromFloats(e,t)},e.prototype.multiplyByFloats=function(t,i){return new e(this.width*t,this.height*i)},e.prototype.clone=function(){return new e(this.width,this.height)},e.prototype.equals=function(e){return!!e&&(this.width===e.width&&this.height===e.height)},Object.defineProperty(e.prototype,"surface",{get:function(){return this.width*this.height},enumerable:!1,configurable:!0}),e.Zero=function(){return new e(0,0)},e.prototype.add=function(t){return new e(this.width+t.width,this.height+t.height)},e.prototype.subtract=function(t){return new e(this.width-t.width,this.height-t.height)},e.Lerp=function(t,i,r){return new e(t.width+(i.width-t.width)*r,t.height+(i.height-t.height)*r)},e}(),Pe=function(e){function i(t){var r=e.call(this,null)||this;return r.metadata=null,r.reservedDataStore=null,r._hasAlpha=!1,r.getAlphaFromRGB=!1,r.level=1,r.coordinatesIndex=0,r._coordinatesMode=0,r.wrapR=1,r.anisotropicFilteringLevel=i.DEFAULT_ANISOTROPIC_FILTERING_LEVEL,r._isCube=!1,r._gammaSpace=!0,r.invertZ=!1,r.lodLevelInAlpha=!1,r.isRenderTarget=!1,r._prefiltered=!1,r.animations=new Array,r.onDisposeObservable=new U,r._onDisposeObserver=null,r._scene=null,r._texture=null,r._uid=null,t?i._isScene(t)?r._scene=t:r._engine=t:r._scene=V.LastCreatedScene,r._scene&&(r.uniqueId=r._scene.getUniqueId(),r._scene.addTexture(r),r._engine=r._scene.getEngine()),r._uid=null,r}return t(i,e),Object.defineProperty(i.prototype,"hasAlpha",{get:function(){return this._hasAlpha},set:function(e){this._hasAlpha!==e&&(this._hasAlpha=e,this._scene&&this._scene.markAllMaterialsAsDirty(17))},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"coordinatesMode",{get:function(){return this._coordinatesMode},set:function(e){this._coordinatesMode!==e&&(this._coordinatesMode=e,this._scene&&this._scene.markAllMaterialsAsDirty(1))},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"wrapU",{get:function(){return this._wrapU},set:function(e){this._wrapU=e},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"wrapV",{get:function(){return this._wrapV},set:function(e){this._wrapV=e},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"isCube",{get:function(){return this._texture?this._texture.isCube:this._isCube},set:function(e){this._texture?this._texture.isCube=e:this._isCube=e},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"is3D",{get:function(){return!!this._texture&&this._texture.is3D},set:function(e){this._texture&&(this._texture.is3D=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"is2DArray",{get:function(){return!!this._texture&&this._texture.is2DArray},set:function(e){this._texture&&(this._texture.is2DArray=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"gammaSpace",{get:function(){return this._texture?(null===this._texture._gammaSpace&&(this._texture._gammaSpace=this._gammaSpace),this._texture._gammaSpace):this._gammaSpace},set:function(e){if(this._texture){if(this._texture._gammaSpace===e)return;this._texture._gammaSpace=e}else{if(this._gammaSpace===e)return;this._gammaSpace=e}this._markAllSubMeshesAsTexturesDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"isRGBD",{get:function(){return null!=this._texture&&this._texture._isRGBD},set:function(e){this._texture&&(this._texture._isRGBD=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"noMipmap",{get:function(){return!1},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"lodGenerationOffset",{get:function(){return this._texture?this._texture._lodGenerationOffset:0},set:function(e){this._texture&&(this._texture._lodGenerationOffset=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"lodGenerationScale",{get:function(){return this._texture?this._texture._lodGenerationScale:0},set:function(e){this._texture&&(this._texture._lodGenerationScale=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"linearSpecularLOD",{get:function(){return!!this._texture&&this._texture._linearSpecularLOD},set:function(e){this._texture&&(this._texture._linearSpecularLOD=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"irradianceTexture",{get:function(){return this._texture?this._texture._irradianceTexture:null},set:function(e){this._texture&&(this._texture._irradianceTexture=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"uid",{get:function(){return this._uid||(this._uid=W.RandomId()),this._uid},enumerable:!1,configurable:!0}),i.prototype.toString=function(){return this.name},i.prototype.getClassName=function(){return"BaseTexture"},Object.defineProperty(i.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"isBlocking",{get:function(){return!0},enumerable:!1,configurable:!0}),i.prototype.getScene=function(){return this._scene},i.prototype._getEngine=function(){return this._engine},i.prototype.checkTransformsAreIdentical=function(e){return null!==e},i.prototype.getTextureMatrix=function(){return m.IdentityReadOnly},i.prototype.getReflectionTextureMatrix=function(){return m.IdentityReadOnly},i.prototype.isReadyOrNotBlocking=function(){return!this.isBlocking||this.isReady()},i.prototype.scale=function(e){},Object.defineProperty(i.prototype,"canRescale",{get:function(){return!1},enumerable:!1,configurable:!0}),i.prototype._getFromCache=function(e,t,i,r){var n=this._getEngine();if(!n)return null;for(var o=n.getLoadedTexturesCache(),s=0;s<o.length;s++){var a=o[s];if(!(void 0!==r&&r!==a.invertY||a.url!==e||a.generateMipMaps!==!t||i&&i!==a.samplingMode))return a.incrementReferences(),a}return null},i.prototype._rebuild=function(){},i.prototype.clone=function(){return null},Object.defineProperty(i.prototype,"textureType",{get:function(){return this._texture&&void 0!==this._texture.type?this._texture.type:0},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"textureFormat",{get:function(){return this._texture&&void 0!==this._texture.format?this._texture.format:5},enumerable:!1,configurable:!0}),i.prototype._markAllSubMeshesAsTexturesDirty=function(){var e=this.getScene();e&&e.markAllMaterialsAsDirty(1)},i.prototype.readPixels=function(e,t,i){if(void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=null),!this._texture)return null;var r=this.getSize(),n=r.width,o=r.height,s=this._getEngine();if(!s)return null;0!=t&&(n/=Math.pow(2,t),o/=Math.pow(2,t),n=Math.round(n),o=Math.round(o));try{return this._texture.isCube?s._readTexturePixels(this._texture,n,o,e,t,i):s._readTexturePixels(this._texture,n,o,-1,t,i)}catch(e){return null}},Object.defineProperty(i.prototype,"_lodTextureHigh",{get:function(){return this._texture?this._texture._lodTextureHigh:null},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"_lodTextureMid",{get:function(){return this._texture?this._texture._lodTextureMid:null},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"_lodTextureLow",{get:function(){return this._texture?this._texture._lodTextureLow:null},enumerable:!1,configurable:!0}),i.prototype.dispose=function(){if(this._scene){this._scene.stopAnimation&&this._scene.stopAnimation(this),this._scene._removePendingData(this);var t=this._scene.textures.indexOf(this);t>=0&&this._scene.textures.splice(t,1),this._scene.onTextureRemovedObservable.notifyObservers(this),this._scene=null}this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),e.prototype.dispose.call(this)},i.prototype.serialize=function(){if(!this.name)return null;var e=N.Serialize(this);return N.AppendSerializedAnimations(this,e),e},i.WhenAllReady=function(e,t){var i=e.length;if(0!==i)for(var r=0;r<e.length;r++){var n=e[r];if(n.isReady())0==--i&&t();else{var o=n.onLoadObservable;o&&o.addOnce((function(){0==--i&&t()}))}}else t()},i._isScene=function(e){return"Scene"===e.getClassName()},i.DEFAULT_ANISOTROPIC_FILTERING_LEVEL=4,r([O()],i.prototype,"uniqueId",void 0),r([O()],i.prototype,"name",void 0),r([O()],i.prototype,"metadata",void 0),r([O("hasAlpha")],i.prototype,"_hasAlpha",void 0),r([O()],i.prototype,"getAlphaFromRGB",void 0),r([O()],i.prototype,"level",void 0),r([O()],i.prototype,"coordinatesIndex",void 0),r([O("coordinatesMode")],i.prototype,"_coordinatesMode",void 0),r([O()],i.prototype,"wrapU",null),r([O()],i.prototype,"wrapV",null),r([O()],i.prototype,"wrapR",void 0),r([O()],i.prototype,"anisotropicFilteringLevel",void 0),r([O()],i.prototype,"isCube",null),r([O()],i.prototype,"is3D",null),r([O()],i.prototype,"is2DArray",null),r([O()],i.prototype,"gammaSpace",null),r([O()],i.prototype,"invertZ",void 0),r([O()],i.prototype,"lodLevelInAlpha",void 0),r([O()],i.prototype,"lodGenerationOffset",null),r([O()],i.prototype,"lodGenerationScale",null),r([O()],i.prototype,"linearSpecularLOD",null),r([R()],i.prototype,"irradianceTexture",null),r([O()],i.prototype,"isRenderTarget",void 0),i}(function(){function e(e){this._wrapU=1,this._wrapV=1,this.wrapR=1,this.anisotropicFilteringLevel=4,this.delayLoadState=0,this._texture=null,this._engine=null,this._cachedSize=Me.Zero(),this._cachedBaseSize=Me.Zero(),this._texture=e,this._texture&&(this._engine=this._texture.getEngine())}return Object.defineProperty(e.prototype,"wrapU",{get:function(){return this._wrapU},set:function(e){this._wrapU=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"wrapV",{get:function(){return this._wrapV},set:function(e){this._wrapV=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coordinatesMode",{get:function(){return 0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isCube",{get:function(){return!!this._texture&&this._texture.isCube},set:function(e){this._texture&&(this._texture.isCube=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"is3D",{get:function(){return!!this._texture&&this._texture.is3D},set:function(e){this._texture&&(this._texture.is3D=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"is2DArray",{get:function(){return!!this._texture&&this._texture.is2DArray},set:function(e){this._texture&&(this._texture.is2DArray=e)},enumerable:!1,configurable:!0}),e.prototype.getClassName=function(){return"ThinTexture"},e.prototype.isReady=function(){return 4===this.delayLoadState?(this.delayLoad(),!1):!!this._texture&&this._texture.isReady},e.prototype.delayLoad=function(){},e.prototype.getInternalTexture=function(){return this._texture},e.prototype.getSize=function(){if(this._texture){if(this._texture.width)return this._cachedSize.width=this._texture.width,this._cachedSize.height=this._texture.height,this._cachedSize;if(this._texture._size)return this._cachedSize.width=this._texture._size,this._cachedSize.height=this._texture._size,this._cachedSize}return this._cachedSize},e.prototype.getBaseSize=function(){return this.isReady()&&this._texture?this._texture._size?(this._cachedBaseSize.width=this._texture._size,this._cachedBaseSize.height=this._texture._size,this._cachedBaseSize):(this._cachedBaseSize.width=this._texture.baseWidth,this._cachedBaseSize.height=this._texture.baseHeight,this._cachedBaseSize):(this._cachedBaseSize.width=0,this._cachedBaseSize.height=0,this._cachedBaseSize)},e.prototype.updateSamplingMode=function(e){this._texture&&this._engine&&this._engine.updateTextureSamplingMode(e,this._texture)},e.prototype.releaseInternalTexture=function(){this._texture&&(this._texture.dispose(),this._texture=null)},e.prototype.dispose=function(){this._texture&&(this.releaseInternalTexture(),this._engine=null)},e}()),Ce=function(){function e(){}return e.SetImmediate=function(e){H.IsWindowObjectExist()&&window.setImmediate?window.setImmediate(e):setTimeout(e,1)},e}(),Se=function(){function e(){}return e.Instantiate=function(e){if(this.RegisteredExternalClasses&&this.RegisteredExternalClasses[e])return this.RegisteredExternalClasses[e];var t=c.GetClass(e);if(t)return t;q.Warn(e+" not found, you may have missed an import.");for(var i=e.split("."),r=window||this,n=0,o=i.length;n<o;n++)r=r[i[n]];return"function"!=typeof r?null:r},e.RegisteredExternalClasses={},e}(),Ie=function(){function e(e,t,i,r){this.normal=new p(e,t,i),this.d=r}return e.prototype.asArray=function(){return[this.normal.x,this.normal.y,this.normal.z,this.d]},e.prototype.clone=function(){return new e(this.normal.x,this.normal.y,this.normal.z,this.d)},e.prototype.getClassName=function(){return"Plane"},e.prototype.getHashCode=function(){var e=this.normal.getHashCode();return e=397*e^(0|this.d)},e.prototype.normalize=function(){var e=Math.sqrt(this.normal.x*this.normal.x+this.normal.y*this.normal.y+this.normal.z*this.normal.z),t=0;return 0!==e&&(t=1/e),this.normal.x*=t,this.normal.y*=t,this.normal.z*=t,this.d*=t,this},e.prototype.transform=function(t){var i=e._TmpMatrix;t.invertToRef(i);var r=i.m,n=this.normal.x,o=this.normal.y,s=this.normal.z,a=this.d;return new e(n*r[0]+o*r[1]+s*r[2]+a*r[3],n*r[4]+o*r[5]+s*r[6]+a*r[7],n*r[8]+o*r[9]+s*r[10]+a*r[11],n*r[12]+o*r[13]+s*r[14]+a*r[15])},e.prototype.dotCoordinate=function(e){return this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z+this.d},e.prototype.copyFromPoints=function(e,t,i){var r,n=t.x-e.x,o=t.y-e.y,s=t.z-e.z,a=i.x-e.x,h=i.y-e.y,u=i.z-e.z,l=o*u-s*h,c=s*a-n*u,f=n*h-o*a,d=Math.sqrt(l*l+c*c+f*f);return r=0!==d?1/d:0,this.normal.x=l*r,this.normal.y=c*r,this.normal.z=f*r,this.d=-(this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z),this},e.prototype.isFrontFacingTo=function(e,t){return p.Dot(this.normal,e)<=t},e.prototype.signedDistanceTo=function(e){return p.Dot(e,this.normal)+this.d},e.FromArray=function(t){return new e(t[0],t[1],t[2],t[3])},e.FromPoints=function(t,i,r){var n=new e(0,0,0,0);return n.copyFromPoints(t,i,r),n},e.FromPositionAndNormal=function(t,i){var r=new e(0,0,0,0);return i.normalize(),r.normal=i,r.d=-(i.x*t.x+i.y*t.y+i.z*t.z),r},e.SignedDistanceToPlaneFromPositionAndNormal=function(e,t,i){var r=-(t.x*e.x+t.y*e.y+t.z*e.z);return p.Dot(i,t)+r},e._TmpMatrix=m.Identity(),e}(),Oe=function(){function e(){}return e.GenerateBase64StringFromTexture=function(e,t,i){void 0===t&&(t=0),void 0===i&&(i=0);var r=e.getInternalTexture();if(!r)return null;var n=e.readPixels(t,i);if(!n)return null;var o=e.getSize(),s=o.width,a=o.height;if(n instanceof Float32Array){for(var h=n.byteLength/n.BYTES_PER_ELEMENT,u=new Uint8Array(h);--h>=0;){var l=n[h];l<0?l=0:l>1&&(l=1),u[h]=255*l}n=u}var c=document.createElement("canvas");c.width=s,c.height=a;var f=c.getContext("2d");if(!f)return null;var d=f.createImageData(s,a);if(d.data.set(n),f.putImageData(d,0,0),r.invertY){var p=document.createElement("canvas");p.width=s,p.height=a;var _=p.getContext("2d");return _?(_.translate(0,a),_.scale(1,-1),_.drawImage(c,0,0),p.toDataURL("image/png")):null}return c.toDataURL("image/png")},e}(),Re=function(e){function i(t,r,n,o,s,a,h,u,l,c,f,d){void 0===n&&(n=!1),void 0===o&&(o=!0),void 0===s&&(s=i.TRILINEAR_SAMPLINGMODE),void 0===a&&(a=null),void 0===h&&(h=null),void 0===u&&(u=null),void 0===l&&(l=!1);var p=e.call(this,r)||this;p.url=null,p.uOffset=0,p.vOffset=0,p.uScale=1,p.vScale=1,p.uAng=0,p.vAng=0,p.wAng=0,p.uRotationCenter=.5,p.vRotationCenter=.5,p.wRotationCenter=.5,p.homogeneousRotationInUVTransform=!1,p.inspectableCustomProperties=null,p._noMipmap=!1,p._invertY=!1,p._rowGenerationMatrix=null,p._cachedTextureMatrix=null,p._projectionModeMatrix=null,p._t0=null,p._t1=null,p._t2=null,p._cachedUOffset=-1,p._cachedVOffset=-1,p._cachedUScale=0,p._cachedVScale=0,p._cachedUAng=-1,p._cachedVAng=-1,p._cachedWAng=-1,p._cachedProjectionMatrixId=-1,p._cachedURotationCenter=-1,p._cachedVRotationCenter=-1,p._cachedWRotationCenter=-1,p._cachedHomogeneousRotationInUVTransform=!1,p._cachedCoordinatesMode=-1,p._initialSamplingMode=i.BILINEAR_SAMPLINGMODE,p._buffer=null,p._deleteBuffer=!1,p._format=null,p._delayedOnLoad=null,p._delayedOnError=null,p.onLoadObservable=new U,p._isBlocking=!0,p.name=t||"",p.url=t,p._noMipmap=n,p._invertY=o,p._initialSamplingMode=s,p._buffer=u,p._deleteBuffer=l,p._mimeType=f,p._loaderOptions=d,c&&(p._format=c);var _=p.getScene(),g=p._getEngine();if(!g)return p;g.onBeforeTextureInitObservable.notifyObservers(p);var m=function(){p._texture&&(p._texture._invertVScale&&(p.vScale*=-1,p.vOffset+=1),null!==p._texture._cachedWrapU&&(p.wrapU=p._texture._cachedWrapU,p._texture._cachedWrapU=null),null!==p._texture._cachedWrapV&&(p.wrapV=p._texture._cachedWrapV,p._texture._cachedWrapV=null),null!==p._texture._cachedWrapR&&(p.wrapR=p._texture._cachedWrapR,p._texture._cachedWrapR=null)),p.onLoadObservable.hasObservers()&&p.onLoadObservable.notifyObservers(p),a&&a(),!p.isBlocking&&_&&_.resetCachedMaterial()};return p.url?(p._texture=p._getFromCache(p.url,n,s,o),p._texture?p._texture.isReady?Ce.SetImmediate((function(){return m()})):p._texture.onLoadedObservable.add(m):_&&_.useDelayedTextureLoading?(p.delayLoadState=4,p._delayedOnLoad=m,p._delayedOnError=h):(p._texture=g.createTexture(p.url,n,o,_,s,m,h,p._buffer,void 0,p._format,null,f,d),l&&(p._buffer=null)),p):(p._delayedOnLoad=m,p._delayedOnError=h,p)}return t(i,e),Object.defineProperty(i.prototype,"noMipmap",{get:function(){return this._noMipmap},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"mimeType",{get:function(){return this._mimeType},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"isBlocking",{get:function(){return this._isBlocking},set:function(e){this._isBlocking=e},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"samplingMode",{get:function(){return this._texture?this._texture.samplingMode:this._initialSamplingMode},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"invertY",{get:function(){return this._invertY},enumerable:!1,configurable:!0}),i.prototype.updateURL=function(e,t,i){void 0===t&&(t=null),this.url&&(this.releaseInternalTexture(),this.getScene().markAllMaterialsAsDirty(1)),this.name&&!Y.StartsWith(this.name,"data:")||(this.name=e),this.url=e,this._buffer=t,this.delayLoadState=4,i&&(this._delayedOnLoad=i),this.delayLoad()},i.prototype.delayLoad=function(){if(4===this.delayLoadState){var e=this.getScene();e&&(this.delayLoadState=1,this._texture=this._getFromCache(this.url,this._noMipmap,this.samplingMode,this._invertY),this._texture?this._delayedOnLoad&&(this._texture.isReady?Ce.SetImmediate(this._delayedOnLoad):this._texture.onLoadedObservable.add(this._delayedOnLoad)):(this._texture=e.getEngine().createTexture(this.url,this._noMipmap,this._invertY,e,this.samplingMode,this._delayedOnLoad,this._delayedOnError,this._buffer,null,this._format,null,this._mimeType,this._loaderOptions),this._deleteBuffer&&(this._buffer=null)),this._delayedOnLoad=null,this._delayedOnError=null)}},i.prototype._prepareRowForTextureGeneration=function(e,t,i,r){e*=this._cachedUScale,t*=this._cachedVScale,e-=this.uRotationCenter*this._cachedUScale,t-=this.vRotationCenter*this._cachedVScale,i-=this.wRotationCenter,p.TransformCoordinatesFromFloatsToRef(e,t,i,this._rowGenerationMatrix,r),r.x+=this.uRotationCenter*this._cachedUScale+this._cachedUOffset,r.y+=this.vRotationCenter*this._cachedVScale+this._cachedVOffset,r.z+=this.wRotationCenter},i.prototype.checkTransformsAreIdentical=function(e){return null!==e&&this.uOffset===e.uOffset&&this.vOffset===e.vOffset&&this.uScale===e.uScale&&this.vScale===e.vScale&&this.uAng===e.uAng&&this.vAng===e.vAng&&this.wAng===e.wAng},i.prototype.getTextureMatrix=function(e){var t=this;if(void 0===e&&(e=1),this.uOffset===this._cachedUOffset&&this.vOffset===this._cachedVOffset&&this.uScale*e===this._cachedUScale&&this.vScale===this._cachedVScale&&this.uAng===this._cachedUAng&&this.vAng===this._cachedVAng&&this.wAng===this._cachedWAng&&this.uRotationCenter===this._cachedURotationCenter&&this.vRotationCenter===this._cachedVRotationCenter&&this.wRotationCenter===this._cachedWRotationCenter&&this.homogeneousRotationInUVTransform===this._cachedHomogeneousRotationInUVTransform)return this._cachedTextureMatrix;this._cachedUOffset=this.uOffset,this._cachedVOffset=this.vOffset,this._cachedUScale=this.uScale*e,this._cachedVScale=this.vScale,this._cachedUAng=this.uAng,this._cachedVAng=this.vAng,this._cachedWAng=this.wAng,this._cachedURotationCenter=this.uRotationCenter,this._cachedVRotationCenter=this.vRotationCenter,this._cachedWRotationCenter=this.wRotationCenter,this._cachedHomogeneousRotationInUVTransform=this.homogeneousRotationInUVTransform,this._cachedTextureMatrix&&this._rowGenerationMatrix||(this._cachedTextureMatrix=m.Zero(),this._rowGenerationMatrix=new m,this._t0=p.Zero(),this._t1=p.Zero(),this._t2=p.Zero()),m.RotationYawPitchRollToRef(this.vAng,this.uAng,this.wAng,this._rowGenerationMatrix),this.homogeneousRotationInUVTransform?(m.TranslationToRef(-this._cachedURotationCenter,-this._cachedVRotationCenter,-this._cachedWRotationCenter,y.Matrix[0]),m.TranslationToRef(this._cachedURotationCenter,this._cachedVRotationCenter,this._cachedWRotationCenter,y.Matrix[1]),m.ScalingToRef(this._cachedUScale,this._cachedVScale,0,y.Matrix[2]),m.TranslationToRef(this._cachedUOffset,this._cachedVOffset,0,y.Matrix[3]),y.Matrix[0].multiplyToRef(this._rowGenerationMatrix,this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(y.Matrix[1],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(y.Matrix[2],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(y.Matrix[3],this._cachedTextureMatrix),this._cachedTextureMatrix.setRowFromFloats(2,this._cachedTextureMatrix.m[12],this._cachedTextureMatrix.m[13],this._cachedTextureMatrix.m[14],1)):(this._prepareRowForTextureGeneration(0,0,0,this._t0),this._prepareRowForTextureGeneration(1,0,0,this._t1),this._prepareRowForTextureGeneration(0,1,0,this._t2),this._t1.subtractInPlace(this._t0),this._t2.subtractInPlace(this._t0),m.FromValuesToRef(this._t1.x,this._t1.y,this._t1.z,0,this._t2.x,this._t2.y,this._t2.z,0,this._t0.x,this._t0.y,this._t0.z,0,0,0,0,1,this._cachedTextureMatrix));var i=this.getScene();return i?(i.markAllMaterialsAsDirty(1,(function(e){return e.hasTexture(t)})),this._cachedTextureMatrix):this._cachedTextureMatrix},i.prototype.getReflectionTextureMatrix=function(){var e=this,t=this.getScene();if(!t)return this._cachedTextureMatrix;if(this.uOffset===this._cachedUOffset&&this.vOffset===this._cachedVOffset&&this.uScale===this._cachedUScale&&this.vScale===this._cachedVScale&&this.coordinatesMode===this._cachedCoordinatesMode){if(this.coordinatesMode!==i.PROJECTION_MODE)return this._cachedTextureMatrix;if(this._cachedProjectionMatrixId===t.getProjectionMatrix().updateFlag)return this._cachedTextureMatrix}switch(this._cachedTextureMatrix||(this._cachedTextureMatrix=m.Zero()),this._projectionModeMatrix||(this._projectionModeMatrix=m.Zero()),this._cachedUOffset=this.uOffset,this._cachedVOffset=this.vOffset,this._cachedUScale=this.uScale,this._cachedVScale=this.vScale,this._cachedCoordinatesMode=this.coordinatesMode,this.coordinatesMode){case i.PLANAR_MODE:m.IdentityToRef(this._cachedTextureMatrix),this._cachedTextureMatrix[0]=this.uScale,this._cachedTextureMatrix[5]=this.vScale,this._cachedTextureMatrix[12]=this.uOffset,this._cachedTextureMatrix[13]=this.vOffset;break;case i.PROJECTION_MODE:m.FromValuesToRef(.5,0,0,0,0,-.5,0,0,0,0,0,0,.5,.5,1,1,this._projectionModeMatrix);var r=t.getProjectionMatrix();this._cachedProjectionMatrixId=r.updateFlag,r.multiplyToRef(this._projectionModeMatrix,this._cachedTextureMatrix);break;default:m.IdentityToRef(this._cachedTextureMatrix)}return t.markAllMaterialsAsDirty(1,(function(t){return-1!==t.getActiveTextures().indexOf(e)})),this._cachedTextureMatrix},i.prototype.clone=function(){var e=this;return N.Clone((function(){return new i(e._texture?e._texture.url:null,e.getScene(),e._noMipmap,e._invertY,e.samplingMode,void 0,void 0,e._texture?e._texture._buffer:void 0)}),this)},i.prototype.serialize=function(){var t=this.name;i.SerializeBuffers||Y.StartsWith(this.name,"data:")&&(this.name=""),Y.StartsWith(this.name,"data:")&&this.url===this.name&&(this.url="");var r=e.prototype.serialize.call(this);return r?((i.SerializeBuffers||i.ForceSerializeBuffers)&&("string"==typeof this._buffer&&"data:"===this._buffer.substr(0,5)?(r.base64String=this._buffer,r.name=r.name.replace("data:","")):this.url&&Y.StartsWith(this.url,"data:")&&this._buffer instanceof Uint8Array?r.base64String="data:image/png;base64,"+Y.EncodeArrayBufferToBase64(this._buffer):i.ForceSerializeBuffers&&(r.base64String=Oe.GenerateBase64StringFromTexture(this))),r.invertY=this._invertY,r.samplingMode=this.samplingMode,this.name=t,r):null},i.prototype.getClassName=function(){return"Texture"},i.prototype.dispose=function(){e.prototype.dispose.call(this),this.onLoadObservable.clear(),this._delayedOnLoad=null,this._delayedOnError=null},i.Parse=function(e,t,r){if(e.customType){var n=Se.Instantiate(e.customType).Parse(e,t,r);return e.samplingMode&&n.updateSamplingMode&&n._samplingMode&&n._samplingMode!==e.samplingMode&&n.updateSamplingMode(e.samplingMode),n}if(e.isCube&&!e.isRenderTarget)return i._CubeTextureParser(e,t,r);if(!e.name&&!e.isRenderTarget)return null;var o=function(){if(s&&s._texture&&(s._texture._cachedWrapU=null,s._texture._cachedWrapV=null,s._texture._cachedWrapR=null),e.samplingMode){var t=e.samplingMode;s&&s.samplingMode!==t&&s.updateSamplingMode(t)}if(s&&e.animations)for(var i=0;i<e.animations.length;i++){var r=e.animations[i],n=c.GetClass("BABYLON.Animation");n&&s.animations.push(n.Parse(r))}},s=N.Parse((function(){var n,s=!0;if(e.noMipmap&&(s=!1),e.mirrorPlane){var a=i._CreateMirror(e.name,e.renderTargetSize,t,s);return a._waitingRenderList=e.renderList,a.mirrorPlane=Ie.FromArray(e.mirrorPlane),o(),a}if(e.isRenderTarget){var h=null;if(e.isCube){if(t.reflectionProbes)for(var u=0;u<t.reflectionProbes.length;u++){var l=t.reflectionProbes[u];if(l.name===e.name)return l.cubeTexture}}else(h=i._CreateRenderTargetTexture(e.name,e.renderTargetSize,t,s))._waitingRenderList=e.renderList;return o(),h}if(e.base64String)n=i.CreateFromBase64String(e.base64String,e.name,t,!s,e.invertY,void 0,o);else{var c=void 0;c=e.name&&e.name.indexOf("://")>0?e.name:r+e.name,(Y.StartsWith(e.url,"data:")||i.UseSerializedUrlIfAny&&e.url)&&(c=e.url),n=new i(c,t,!s,e.invertY,void 0,o)}return n}),e,t);return s},i.CreateFromBase64String=function(e,t,r,n,o,s,a,h,u){return void 0===s&&(s=i.TRILINEAR_SAMPLINGMODE),void 0===a&&(a=null),void 0===h&&(h=null),void 0===u&&(u=5),new i("data:"+t,r,n,o,s,a,h,e,!1,u)},i.LoadFromDataString=function(e,t,r,n,o,s,a,h,u,l){return void 0===n&&(n=!1),void 0===o&&(o=!1),void 0===s&&(s=!0),void 0===a&&(a=i.TRILINEAR_SAMPLINGMODE),void 0===h&&(h=null),void 0===u&&(u=null),void 0===l&&(l=5),"data:"!==e.substr(0,5)&&(e="data:"+e),new i(e,r,o,s,a,h,u,t,n,l)},i.SerializeBuffers=!0,i.ForceSerializeBuffers=!1,i._CubeTextureParser=function(e,t,i){throw b.WarnImport("CubeTexture")},i._CreateMirror=function(e,t,i,r){throw b.WarnImport("MirrorTexture")},i._CreateRenderTargetTexture=function(e,t,i,r){throw b.WarnImport("RenderTargetTexture")},i.NEAREST_SAMPLINGMODE=1,i.NEAREST_NEAREST_MIPLINEAR=8,i.BILINEAR_SAMPLINGMODE=2,i.LINEAR_LINEAR_MIPNEAREST=11,i.TRILINEAR_SAMPLINGMODE=3,i.LINEAR_LINEAR_MIPLINEAR=3,i.NEAREST_NEAREST_MIPNEAREST=4,i.NEAREST_LINEAR_MIPNEAREST=5,i.NEAREST_LINEAR_MIPLINEAR=6,i.NEAREST_LINEAR=7,i.NEAREST_NEAREST=1,i.LINEAR_NEAREST_MIPNEAREST=9,i.LINEAR_NEAREST_MIPLINEAR=10,i.LINEAR_LINEAR=2,i.LINEAR_NEAREST=12,i.EXPLICIT_MODE=0,i.SPHERICAL_MODE=1,i.PLANAR_MODE=2,i.CUBIC_MODE=3,i.PROJECTION_MODE=4,i.SKYBOX_MODE=5,i.INVCUBIC_MODE=6,i.EQUIRECTANGULAR_MODE=7,i.FIXED_EQUIRECTANGULAR_MODE=8,i.FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9,i.CLAMP_ADDRESSMODE=0,i.WRAP_ADDRESSMODE=1,i.MIRROR_ADDRESSMODE=2,i.UseSerializedUrlIfAny=!1,r([O()],i.prototype,"url",void 0),r([O()],i.prototype,"uOffset",void 0),r([O()],i.prototype,"vOffset",void 0),r([O()],i.prototype,"uScale",void 0),r([O()],i.prototype,"vScale",void 0),r([O()],i.prototype,"uAng",void 0),r([O()],i.prototype,"vAng",void 0),r([O()],i.prototype,"wAng",void 0),r([O()],i.prototype,"uRotationCenter",void 0),r([O()],i.prototype,"vRotationCenter",void 0),r([O()],i.prototype,"wRotationCenter",void 0),r([O()],i.prototype,"homogeneousRotationInUVTransform",void 0),r([O()],i.prototype,"isBlocking",null),i}(Pe);c.RegisteredTypes["BABYLON.Texture"]=Re,N._TextureParser=Re.Parse;var De=function(e,t){return e?e.getClassName&&"Mesh"===e.getClassName()?null:e.getClassName&&"SubMesh"===e.getClassName()?e.clone(t):e.clone?e.clone():null:null};var we,Le=function(){function e(){}return e.DeepCopy=function(e,t,i,r){for(var n=function(e){var t=[];do{Object.getOwnPropertyNames(e).forEach((function(e){-1===t.indexOf(e)&&t.push(e)}))}while(e=Object.getPrototypeOf(e));return t}(e),o=0,s=n;o<s.length;o++){var a=s[o];if(("_"!==a[0]||r&&-1!==r.indexOf(a))&&!(Y.EndsWith(a,"Observable")||i&&-1!==i.indexOf(a))){var h=e[a],u=typeof h;if("function"!==u)try{if("object"===u)if(h instanceof Array){if(t[a]=[],h.length>0)if("object"==typeof h[0])for(var l=0;l<h.length;l++){var c=De(h[l],t);-1===t[a].indexOf(c)&&t[a].push(c)}else t[a]=h.slice(0)}else t[a]=De(h,t);else t[a]=h}catch(e){q.Warn(e.message)}}}},e}(),Fe=function(){function e(){}return Object.defineProperty(e,"Now",{get:function(){return H.IsWindowObjectExist()&&window.performance&&window.performance.now?window.performance.now():Date.now()},enumerable:!1,configurable:!0}),e}();!function(e){e[e.Pending=0]="Pending",e[e.Fulfilled=1]="Fulfilled",e[e.Rejected=2]="Rejected"}(we||(we={}));var Ne=function(){this.count=0,this.target=0,this.results=[]},Be=function(){function e(e){var t=this;if(this._state=we.Pending,this._children=new Array,this._rejectWasConsumed=!1,e)try{e((function(e){t._resolve(e)}),(function(e){t._reject(e)}))}catch(e){this._reject(e)}}return Object.defineProperty(e.prototype,"_result",{get:function(){return this._resultValue},set:function(e){this._resultValue=e,this._parent&&void 0===this._parent._result&&(this._parent._result=e)},enumerable:!1,configurable:!0}),e.prototype.catch=function(e){return this.then(void 0,e)},e.prototype.then=function(t,i){var r=this,n=new e;return n._onFulfilled=t,n._onRejected=i,this._children.push(n),n._parent=this,this._state!==we.Pending&&setTimeout((function(){if(r._state===we.Fulfilled||r._rejectWasConsumed){var e=n._resolve(r._result);if(null!=e)if(void 0!==e._state){var t=e;n._children.push(t),t._parent=n,n=t}else n._result=e}else n._reject(r._reason)})),n},e.prototype._moveChildren=function(e){var t,i=this;if((t=this._children).push.apply(t,e.splice(0,e.length)),this._children.forEach((function(e){e._parent=i})),this._state===we.Fulfilled)for(var r=0,n=this._children;r<n.length;r++){n[r]._resolve(this._result)}else if(this._state===we.Rejected)for(var o=0,s=this._children;o<s.length;o++){s[o]._reject(this._reason)}},e.prototype._resolve=function(e){try{this._state=we.Fulfilled;var t=null;if(this._onFulfilled&&(t=this._onFulfilled(e)),null!=t)if(void 0!==t._state){var i=t;i._parent=this,i._moveChildren(this._children),e=i._result}else e=t;this._result=e;for(var r=0,n=this._children;r<n.length;r++){n[r]._resolve(e)}this._children.length=0,delete this._onFulfilled,delete this._onRejected}catch(e){this._reject(e,!0)}},e.prototype._reject=function(e,t){if(void 0===t&&(t=!1),this._state=we.Rejected,this._reason=e,this._onRejected&&!t)try{this._onRejected(e),this._rejectWasConsumed=!0}catch(t){e=t}for(var i=0,r=this._children;i<r.length;i++){var n=r[i];this._rejectWasConsumed?n._resolve(null):n._reject(e)}this._children.length=0,delete this._onFulfilled,delete this._onRejected},e.resolve=function(t){var i=new e;return i._resolve(t),i},e._RegisterForFulfillment=function(e,t,i){e.then((function(e){return t.results[i]=e,t.count++,t.count===t.target&&t.rootPromise._resolve(t.results),null}),(function(e){t.rootPromise._state!==we.Rejected&&t.rootPromise._reject(e)}))},e.all=function(t){var i=new e,r=new Ne;if(r.target=t.length,r.rootPromise=i,t.length)for(var n=0;n<t.length;n++)e._RegisterForFulfillment(t[n],r,n);else i._resolve([]);return i},e.race=function(t){var i=new e;if(t.length)for(var r=0,n=t;r<n.length;r++){n[r].then((function(e){return i&&(i._resolve(e),i=null),null}),(function(e){i&&(i._reject(e),i=null)}))}return i},e}(),ke=function(){function e(){}return e.Apply=function(e){(void 0===e&&(e=!1),e||"undefined"==typeof Promise)&&(window.Promise=Be)},e}(),Ue=function(){function e(){}return Object.defineProperty(e,"BaseUrl",{get:function(){return Ae.BaseUrl},set:function(e){Ae.BaseUrl=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"DefaultRetryStrategy",{get:function(){return Ae.DefaultRetryStrategy},set:function(e){Ae.DefaultRetryStrategy=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"CorsBehavior",{get:function(){return Ae.CorsBehavior},set:function(e){Ae.CorsBehavior=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"UseFallbackTexture",{get:function(){return V.UseFallbackTexture},set:function(e){V.UseFallbackTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"RegisteredExternalClasses",{get:function(){return Se.RegisteredExternalClasses},set:function(e){Se.RegisteredExternalClasses=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"fallbackTexture",{get:function(){return V.FallbackTexture},set:function(e){V.FallbackTexture=e},enumerable:!1,configurable:!0}),e.FetchToRef=function(e,t,i,r,n,o){var s=4*((Math.abs(e)*i%i|0)+(Math.abs(t)*r%r|0)*i);o.r=n[s]/255,o.g=n[s+1]/255,o.b=n[s+2]/255,o.a=n[s+3]/255},e.Mix=function(e,t,i){return e*(1-i)+t*i},e.Instantiate=function(e){return Se.Instantiate(e)},e.Slice=function(e,t,i){return e.slice?e.slice(t,i):Array.prototype.slice.call(e,t,i)},e.SliceToArray=function(e,t,i){return Array.isArray(e)?e.slice(t,i):Array.prototype.slice.call(e,t,i)},e.SetImmediate=function(e){Ce.SetImmediate(e)},e.IsExponentOfTwo=function(e){var t=1;do{t*=2}while(t<e);return t===e},e.FloatRound=function(t){return Math.fround?Math.fround(t):e._tmpFloatArray[0]=t},e.GetFilename=function(e){var t=e.lastIndexOf("/");return t<0?e:e.substring(t+1)},e.GetFolderPath=function(e,t){void 0===t&&(t=!1);var i=e.lastIndexOf("/");return i<0?t?e:"":e.substring(0,i+1)},e.ToDegrees=function(e){return 180*e/Math.PI},e.ToRadians=function(e){return e*Math.PI/180},e.MakeArray=function(e,t){return!0===t||void 0!==e&&null!=e?Array.isArray(e)?e:[e]:null},e.GetPointerPrefix=function(e){var t="pointer";return H.IsWindowObjectExist()&&!window.PointerEvent&&H.IsNavigatorAvailable()&&!navigator.pointerEnabled&&(t="mouse"),!e._badDesktopOS||e._badOS||document&&"ontouchend"in document||(t="mouse"),t},e.SetCorsBehavior=function(e,t){Ae.SetCorsBehavior(e,t)},e.CleanUrl=function(e){return e=e.replace(/#/gm,"%23")},Object.defineProperty(e,"PreprocessUrl",{get:function(){return Ae.PreprocessUrl},set:function(e){Ae.PreprocessUrl=e},enumerable:!1,configurable:!0}),e.LoadImage=function(e,t,i,r,n){return Ae.LoadImage(e,t,i,r,n)},e.LoadFile=function(e,t,i,r,n,o){return Ae.LoadFile(e,t,i,r,n,o)},e.LoadFileAsync=function(e,t){return void 0===t&&(t=!0),new Promise((function(i,r){Ae.LoadFile(e,(function(e){i(e)}),void 0,void 0,t,(function(e,t){r(t)}))}))},e.LoadScript=function(e,t,i,r){if(H.IsWindowObjectExist()){var n=document.getElementsByTagName("head")[0],o=document.createElement("script");o.setAttribute("type","text/javascript"),o.setAttribute("src",e),r&&(o.id=r),o.onload=function(){t&&t()},o.onerror=function(t){i&&i("Unable to load script '"+e+"'",t)},n.appendChild(o)}},e.LoadScriptAsync=function(e,t){var i=this;return new Promise((function(t,r){i.LoadScript(e,(function(){t()}),(function(e,t){r(t)}))}))},e.ReadFileAsDataURL=function(e,t,i){var r=new FileReader,n={onCompleteObservable:new U,abort:function(){return r.abort()}};return r.onloadend=function(e){n.onCompleteObservable.notifyObservers(n)},r.onload=function(e){t(e.target.result)},r.onprogress=i,r.readAsDataURL(e),n},e.ReadFile=function(e,t,i,r,n){return Ae.ReadFile(e,t,i,r,n)},e.FileAsURL=function(e){var t=new Blob([e]);return(window.URL||window.webkitURL).createObjectURL(t)},e.Format=function(e,t){return void 0===t&&(t=2),e.toFixed(t)},e.DeepCopy=function(e,t,i,r){Le.DeepCopy(e,t,i,r)},e.IsEmpty=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},e.RegisterTopRootEvents=function(e,t){for(var i=0;i<t.length;i++){var r=t[i];e.addEventListener(r.name,r.handler,!1);try{window.parent&&window.parent.addEventListener(r.name,r.handler,!1)}catch(e){}}},e.UnregisterTopRootEvents=function(e,t){for(var i=0;i<t.length;i++){var r=t[i];e.removeEventListener(r.name,r.handler);try{e.parent&&e.parent.removeEventListener(r.name,r.handler)}catch(e){}}},e.DumpFramebuffer=function(t,i,r,n,o,s){void 0===o&&(o="image/png");for(var a=4*t,h=i/2,u=r.readPixels(0,0,t,i),l=0;l<h;l++)for(var c=0;c<a;c++){var f=c+l*a,d=c+(i-l-1)*a,p=u[f];u[f]=u[d],u[d]=p}e._ScreenshotCanvas||(e._ScreenshotCanvas=document.createElement("canvas")),e._ScreenshotCanvas.width=t,e._ScreenshotCanvas.height=i;var _=e._ScreenshotCanvas.getContext("2d");if(_){var g=_.createImageData(t,i);g.data.set(u),_.putImageData(g,0,0),e.EncodeScreenshotCanvasData(n,o,s)}},e.ToBlob=function(e,t,i){void 0===i&&(i="image/png"),e.toBlob||(e.toBlob=function(e,t,i){var r=this;setTimeout((function(){for(var n=atob(r.toDataURL(t,i).split(",")[1]),o=n.length,s=new Uint8Array(o),a=0;a<o;a++)s[a]=n.charCodeAt(a);e(new Blob([s]))}))}),e.toBlob((function(e){t(e)}),i)},e.EncodeScreenshotCanvasData=function(t,i,r){(void 0===i&&(i="image/png"),t)?t(e._ScreenshotCanvas.toDataURL(i)):this.ToBlob(e._ScreenshotCanvas,(function(t){if("download"in document.createElement("a")){if(!r){var i=new Date,n=(i.getFullYear()+"-"+(i.getMonth()+1)).slice(2)+"-"+i.getDate()+"_"+i.getHours()+"-"+("0"+i.getMinutes()).slice(-2);r="screenshot_"+n+".png"}e.Download(t,r)}else{var o=URL.createObjectURL(t),s=window.open("");if(!s)return;var a=s.document.createElement("img");a.onload=function(){URL.revokeObjectURL(o)},a.src=o,s.document.body.appendChild(a)}}),i)},e.Download=function(e,t){if(navigator&&navigator.msSaveBlob)navigator.msSaveBlob(e,t);else{var i=window.URL.createObjectURL(e),r=document.createElement("a");document.body.appendChild(r),r.style.display="none",r.href=i,r.download=t,r.addEventListener("click",(function(){r.parentElement&&r.parentElement.removeChild(r)})),r.click(),window.URL.revokeObjectURL(i)}},e.BackCompatCameraNoPreventDefault=function(e){return"boolean"==typeof e[0]?e[0]:"boolean"==typeof e[1]&&e[1]},e.CreateScreenshot=function(e,t,i,r,n){throw b.WarnImport("ScreenshotTools")},e.CreateScreenshotAsync=function(e,t,i,r){throw b.WarnImport("ScreenshotTools")},e.CreateScreenshotUsingRenderTarget=function(e,t,i,r,n,o,s,a){throw b.WarnImport("ScreenshotTools")},e.CreateScreenshotUsingRenderTargetAsync=function(e,t,i,r,n,o,s){throw b.WarnImport("ScreenshotTools")},e.RandomId=function(){return W.RandomId()},e.IsBase64=function(e){return!(e.length<5)&&"data:"===e.substr(0,5)},e.DecodeBase64=function(e){for(var t=atob(e.split(",")[1]),i=t.length,r=new Uint8Array(new ArrayBuffer(i)),n=0;n<i;n++)r[n]=t.charCodeAt(n);return r.buffer},e.GetAbsoluteUrl=function(e){var t=document.createElement("a");return t.href=e,t.href},Object.defineProperty(e,"errorsCount",{get:function(){return q.errorsCount},enumerable:!1,configurable:!0}),e.Log=function(e){q.Log(e)},e.Warn=function(e){q.Warn(e)},e.Error=function(e){q.Error(e)},Object.defineProperty(e,"LogCache",{get:function(){return q.LogCache},enumerable:!1,configurable:!0}),e.ClearLogCache=function(){q.ClearLogCache()},Object.defineProperty(e,"LogLevels",{set:function(e){q.LogLevels=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"PerformanceLogLevel",{set:function(t){return(t&e.PerformanceUserMarkLogLevel)===e.PerformanceUserMarkLogLevel?(e.StartPerformanceCounter=e._StartUserMark,void(e.EndPerformanceCounter=e._EndUserMark)):(t&e.PerformanceConsoleLogLevel)===e.PerformanceConsoleLogLevel?(e.StartPerformanceCounter=e._StartPerformanceConsole,void(e.EndPerformanceCounter=e._EndPerformanceConsole)):(e.StartPerformanceCounter=e._StartPerformanceCounterDisabled,void(e.EndPerformanceCounter=e._EndPerformanceCounterDisabled))},enumerable:!1,configurable:!0}),e._StartPerformanceCounterDisabled=function(e,t){},e._EndPerformanceCounterDisabled=function(e,t){},e._StartUserMark=function(t,i){if(void 0===i&&(i=!0),!e._performance){if(!H.IsWindowObjectExist())return;e._performance=window.performance}i&&e._performance.mark&&e._performance.mark(t+"-Begin")},e._EndUserMark=function(t,i){void 0===i&&(i=!0),i&&e._performance.mark&&(e._performance.mark(t+"-End"),e._performance.measure(t,t+"-Begin",t+"-End"))},e._StartPerformanceConsole=function(t,i){void 0===i&&(i=!0),i&&(e._StartUserMark(t,i),console.time)},e._EndPerformanceConsole=function(t,i){void 0===i&&(i=!0),i&&e._EndUserMark(t,i)},Object.defineProperty(e,"Now",{get:function(){return Fe.Now},enumerable:!1,configurable:!0}),e.GetClassName=function(e,t){void 0===t&&(t=!1);var i=null;if(!t&&e.getClassName)i=e.getClassName();else{if(e instanceof Object)i=(t?e:Object.getPrototypeOf(e)).constructor.__bjsclassName__;i||(i=typeof e)}return i},e.First=function(e,t){for(var i=0,r=e;i<r.length;i++){var n=r[i];if(t(n))return n}return null},e.getFullClassName=function(e,t){void 0===t&&(t=!1);var i=null,r=null;if(!t&&e.getClassName)i=e.getClassName();else{if(e instanceof Object){var n=t?e:Object.getPrototypeOf(e);i=n.constructor.__bjsclassName__,r=n.constructor.__bjsmoduleName__}i||(i=typeof e)}return i?(null!=r?r+".":"")+i:null},e.DelayAsync=function(e){return new Promise((function(t){setTimeout((function(){t()}),e)}))},e.IsSafari=function(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)},e.UseCustomRequestHeaders=!1,e.CustomRequestHeaders=G.CustomRequestHeaders,e._tmpFloatArray=new Float32Array(1),e.GetDOMTextContent=H.GetDOMTextContent,e.NoneLogLevel=q.NoneLogLevel,e.MessageLogLevel=q.MessageLogLevel,e.WarningLogLevel=q.WarningLogLevel,e.ErrorLogLevel=q.ErrorLogLevel,e.AllLogLevel=q.AllLogLevel,e.IsWindowObjectExist=H.IsWindowObjectExist,e.PerformanceNoneLogLevel=0,e.PerformanceUserMarkLogLevel=1,e.PerformanceConsoleLogLevel=2,e.StartPerformanceCounter=e._StartPerformanceCounterDisabled,e.EndPerformanceCounter=e._EndPerformanceCounterDisabled,e}(),Ve=function(){function e(e,t,i,r){void 0===r&&(r=0),this.iterations=e,this.index=r-1,this._done=!1,this._fn=t,this._successCallback=i}return e.prototype.executeNext=function(){this._done||(this.index+1<this.iterations?(++this.index,this._fn(this)):this.breakLoop())},e.prototype.breakLoop=function(){this._done=!0,this._successCallback()},e.Run=function(t,i,r,n){void 0===n&&(n=0);var o=new e(t,i,r,n);return o.executeNext(),o},e.SyncAsyncForLoop=function(t,i,r,n,o,s){return void 0===s&&(s=0),e.Run(Math.ceil(t/i),(function(e){o&&o()?e.breakLoop():setTimeout((function(){for(var n=0;n<i;++n){var s=e.index*i+n;if(s>=t)break;if(r(s),o&&o()){e.breakLoop();break}}e.executeNext()}),s)}),n)},e}();function We(e,t,i,r){var n;n=1===r?new Float32Array(t*i*4):new Uint32Array(t*i*4);for(var o=0;o<t;o++)for(var s=0;s<i;s++){var a=3*(s*t+o),h=4*(s*t+o);n[h+0]=e[a+0],n[h+1]=e[a+1],n[h+2]=e[a+2],n[h+3]=1}return n}function ze(e){return function(t,i,r,n,o,s,a,h,u,l){void 0===u&&(u=null),void 0===l&&(l=0);var c=e?this._gl.TEXTURE_3D:this._gl.TEXTURE_2D_ARRAY,f=e?z.Raw3D:z.Raw2DArray,d=new de(this,f);d.baseWidth=i,d.baseHeight=r,d.baseDepth=n,d.width=i,d.height=r,d.depth=n,d.format=o,d.type=l,d.generateMipMaps=s,d.samplingMode=h,e?d.is3D=!0:d.is2DArray=!0,this._doNotHandleContextLost||(d._bufferView=t),e?this.updateRawTexture3D(d,t,o,a,u,l):this.updateRawTexture2DArray(d,t,o,a,u,l),this._bindTextureDirectly(c,d,!0);var p=this._getSamplingParameters(h,s);return this._gl.texParameteri(c,this._gl.TEXTURE_MAG_FILTER,p.mag),this._gl.texParameteri(c,this._gl.TEXTURE_MIN_FILTER,p.min),s&&this._gl.generateMipmap(c),this._bindTextureDirectly(c,null),this._internalTexturesCache.push(d),d}}function Ge(e){return function(t,i,r,n,o,s){void 0===o&&(o=null),void 0===s&&(s=0);var a=e?this._gl.TEXTURE_3D:this._gl.TEXTURE_2D_ARRAY,h=this._getWebGLTextureType(s),u=this._getInternalFormat(r),l=this._getRGBABufferInternalSizedFormat(s,r);this._bindTextureDirectly(a,t,!0),this._unpackFlipY(void 0===n||!!n),this._doNotHandleContextLost||(t._bufferView=i,t.format=r,t.invertY=n,t._compression=o),t.width%4!=0&&this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT,1),o&&i?this._gl.compressedTexImage3D(a,0,this.getCaps().s3tc[o],t.width,t.height,t.depth,0,i):this._gl.texImage3D(a,0,l,t.width,t.height,t.depth,0,u,h,i),t.generateMipMaps&&this._gl.generateMipmap(a),this._bindTextureDirectly(a,null),t.isReady=!0}}V.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",ke.Apply(),be.prototype.updateRawTexture=function(e,t,i,r,n,o){if(void 0===n&&(n=null),void 0===o&&(o=0),e){var s=this._getRGBABufferInternalSizedFormat(o,i),a=this._getInternalFormat(i),h=this._getWebGLTextureType(o);this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0),this._unpackFlipY(void 0===r||!!r),this._doNotHandleContextLost||(e._bufferView=t,e.format=i,e.type=o,e.invertY=r,e._compression=n),e.width%4!=0&&this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT,1),n&&t?this._gl.compressedTexImage2D(this._gl.TEXTURE_2D,0,this.getCaps().s3tc[n],e.width,e.height,0,t):this._gl.texImage2D(this._gl.TEXTURE_2D,0,s,e.width,e.height,0,a,h,t),e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),e.isReady=!0}},be.prototype.createRawTexture=function(e,t,i,r,n,o,s,a,h){void 0===a&&(a=null),void 0===h&&(h=0);var u=new de(this,z.Raw);u.baseWidth=t,u.baseHeight=i,u.width=t,u.height=i,u.format=r,u.generateMipMaps=n,u.samplingMode=s,u.invertY=o,u._compression=a,u.type=h,this._doNotHandleContextLost||(u._bufferView=e),this.updateRawTexture(u,e,r,o,a,h),this._bindTextureDirectly(this._gl.TEXTURE_2D,u,!0);var l=this._getSamplingParameters(s,n);return this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,l.mag),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,l.min),n&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._internalTexturesCache.push(u),u},be.prototype.createRawCubeTexture=function(e,t,i,r,n,o,s,a){void 0===a&&(a=null);var h=this._gl,u=new de(this,z.CubeRaw);u.isCube=!0,u.format=i,u.type=r,this._doNotHandleContextLost||(u._bufferViewArray=e);var l=this._getWebGLTextureType(r),c=this._getInternalFormat(i);c===h.RGB&&(c=h.RGBA),l!==h.FLOAT||this._caps.textureFloatLinearFiltering?l!==this._gl.HALF_FLOAT_OES||this._caps.textureHalfFloatLinearFiltering?l!==h.FLOAT||this._caps.textureFloatRender?l!==h.HALF_FLOAT||this._caps.colorBufferFloat||(n=!1,q.Warn("Render to half float textures is not supported. Mipmap generation forced to false.")):(n=!1,q.Warn("Render to float textures is not supported. Mipmap generation forced to false.")):(n=!1,s=1,q.Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")):(n=!1,s=1,q.Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively."));var f=t,d=f;u.width=f,u.height=d,!this.needPOTTextures||Ue.IsExponentOfTwo(u.width)&&Ue.IsExponentOfTwo(u.height)||(n=!1),e&&this.updateRawCubeTexture(u,e,i,r,o,a),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,u,!0),e&&n&&this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);var p=this._getSamplingParameters(s,n);return h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_MAG_FILTER,p.mag),h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_MIN_FILTER,p.min),h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),this._bindTextureDirectly(h.TEXTURE_CUBE_MAP,null),u.generateMipMaps=n,u},be.prototype.updateRawCubeTexture=function(e,t,i,r,n,o,s){void 0===o&&(o=null),void 0===s&&(s=0),e._bufferViewArray=t,e.format=i,e.type=r,e.invertY=n,e._compression=o;var a=this._gl,h=this._getWebGLTextureType(r),u=this._getInternalFormat(i),l=this._getRGBABufferInternalSizedFormat(r),c=!1;u===a.RGB&&(u=a.RGBA,c=!0),this._bindTextureDirectly(a.TEXTURE_CUBE_MAP,e,!0),this._unpackFlipY(void 0===n||!!n),e.width%4!=0&&a.pixelStorei(a.UNPACK_ALIGNMENT,1);for(var f=0;f<6;f++){var d=t[f];o?a.compressedTexImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+f,s,this.getCaps().s3tc[o],e.width,e.height,0,d):(c&&(d=We(d,e.width,e.height,r)),a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+f,s,l,e.width,e.height,0,u,h,d))}(!this.needPOTTextures||Ue.IsExponentOfTwo(e.width)&&Ue.IsExponentOfTwo(e.height))&&e.generateMipMaps&&0===s&&this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),e.isReady=!0},be.prototype.createRawCubeTextureFromUrl=function(e,t,i,r,n,o,s,a,h,u,l,c){var f=this;void 0===h&&(h=null),void 0===u&&(u=null),void 0===l&&(l=3),void 0===c&&(c=!1);var d=this._gl,p=this.createRawCubeTexture(null,i,r,n,!o,c,l,null);null==t||t._addPendingData(p),p.url=e,this._internalTexturesCache.push(p);return this._loadFile(e,(function(e){!function(e){var i=p.width,o=s(e);if(o){if(a){var u=f._getWebGLTextureType(n),l=f._getInternalFormat(r),_=f._getRGBABufferInternalSizedFormat(n),g=!1;l===d.RGB&&(l=d.RGBA,g=!0),f._bindTextureDirectly(d.TEXTURE_CUBE_MAP,p,!0),f._unpackFlipY(!1);for(var m=a(o),v=0;v<m.length;v++)for(var y=i>>v,b=0;b<6;b++){var T=m[v][b];g&&(T=We(T,y,y,n)),d.texImage2D(b,v,_,y,y,0,l,u,T)}f._bindTextureDirectly(d.TEXTURE_CUBE_MAP,null)}else f.updateRawCubeTexture(p,o,r,n,c);p.isReady=!0,null==t||t._removePendingData(p),h&&h()}}(e)}),void 0,null==t?void 0:t.offlineProvider,!0,(function(e,i){null==t||t._removePendingData(p),u&&e&&u(e.status+" "+e.statusText,i)})),p},be.prototype.createRawTexture2DArray=ze(!1),be.prototype.createRawTexture3D=ze(!0),be.prototype.updateRawTexture2DArray=Ge(!1),be.prototype.updateRawTexture3D=Ge(!0);!function(e){function i(t,i,r,n,o,s,a,h,u){void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===h&&(h=3),void 0===u&&(u=0);var l=e.call(this,null,o,!s,a)||this;return l.format=n,l._engine?(l._texture=l._engine.createRawTexture(t,i,r,n,s,a,h,null,u),l.wrapU=Re.CLAMP_ADDRESSMODE,l.wrapV=Re.CLAMP_ADDRESSMODE,l):l}t(i,e),i.prototype.update=function(e){this._getEngine().updateRawTexture(this._texture,e,this._texture.format,this._texture.invertY,null,this._texture.type)},i.CreateLuminanceTexture=function(e,t,r,n,o,s,a){return void 0===o&&(o=!0),void 0===s&&(s=!1),void 0===a&&(a=3),new i(e,t,r,1,n,o,s,a)},i.CreateLuminanceAlphaTexture=function(e,t,r,n,o,s,a){return void 0===o&&(o=!0),void 0===s&&(s=!1),void 0===a&&(a=3),new i(e,t,r,2,n,o,s,a)},i.CreateAlphaTexture=function(e,t,r,n,o,s,a){return void 0===o&&(o=!0),void 0===s&&(s=!1),void 0===a&&(a=3),new i(e,t,r,0,n,o,s,a)},i.CreateRGBTexture=function(e,t,r,n,o,s,a,h){return void 0===o&&(o=!0),void 0===s&&(s=!1),void 0===a&&(a=3),void 0===h&&(h=0),new i(e,t,r,4,n,o,s,a,h)},i.CreateRGBATexture=function(e,t,r,n,o,s,a,h){return void 0===o&&(o=!0),void 0===s&&(s=!1),void 0===a&&(a=3),void 0===h&&(h=0),new i(e,t,r,5,n,o,s,a,h)},i.CreateRTexture=function(e,t,r,n,o,s,a,h){return void 0===o&&(o=!0),void 0===s&&(s=!1),void 0===a&&(a=Re.TRILINEAR_SAMPLINGMODE),void 0===h&&(h=1),new i(e,t,r,6,n,o,s,a,h)}}(Re);be.prototype.createDynamicTexture=function(e,t,i,r){var n=new de(this,z.Dynamic);return n.baseWidth=e,n.baseHeight=t,i&&(e=this.needPOTTextures?be.GetExponentOfTwo(e,this._caps.maxTextureSize):e,t=this.needPOTTextures?be.GetExponentOfTwo(t,this._caps.maxTextureSize):t),n.width=e,n.height=t,n.isReady=!1,n.generateMipMaps=i,n.samplingMode=r,this.updateTextureSamplingMode(r,n),this._internalTexturesCache.push(n),n},be.prototype.updateDynamicTexture=function(e,t,i,r,n,o){if(void 0===r&&(r=!1),void 0===o&&(o=!1),e){var s=this._gl,a=s.TEXTURE_2D,h=this._bindTextureDirectly(a,e,!0,o);this._unpackFlipY(void 0===i?e.invertY:i),r&&s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1);var u=this._getWebGLTextureType(e.type),l=this._getInternalFormat(n||e.format),c=this._getRGBABufferInternalSizedFormat(e.type,l);s.texImage2D(a,0,c,l,u,t),e.generateMipMaps&&s.generateMipmap(a),h||this._bindTextureDirectly(a,null),r&&s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),e.isReady=!0}};var He=function(e){function i(t,i,r,n,o,s,a){void 0===r&&(r=null),void 0===o&&(o=3),void 0===s&&(s=5);var h=e.call(this,null,r,!n,a,o,void 0,void 0,void 0,void 0,s)||this;h.name=t,h.wrapU=Re.CLAMP_ADDRESSMODE,h.wrapV=Re.CLAMP_ADDRESSMODE,h._generateMipMaps=n;var u=h._getEngine();if(!u)return h;i.getContext?(h._canvas=i,h._texture=u.createDynamicTexture(i.width,i.height,n,o)):(h._canvas=ve.CreateCanvas(1,1),i.width||0===i.width?h._texture=u.createDynamicTexture(i.width,i.height,n,o):h._texture=u.createDynamicTexture(i,i,n,o));var l=h.getSize();return h._canvas.width=l.width,h._canvas.height=l.height,h._context=h._canvas.getContext("2d"),h}return t(i,e),i.prototype.getClassName=function(){return"DynamicTexture"},Object.defineProperty(i.prototype,"canRescale",{get:function(){return!0},enumerable:!1,configurable:!0}),i.prototype._recreate=function(e){this._canvas.width=e.width,this._canvas.height=e.height,this.releaseInternalTexture(),this._texture=this._getEngine().createDynamicTexture(e.width,e.height,this._generateMipMaps,this.samplingMode)},i.prototype.scale=function(e){var t=this.getSize();t.width*=e,t.height*=e,this._recreate(t)},i.prototype.scaleTo=function(e,t){var i=this.getSize();i.width=e,i.height=t,this._recreate(i)},i.prototype.getContext=function(){return this._context},i.prototype.clear=function(){var e=this.getSize();this._context.fillRect(0,0,e.width,e.height)},i.prototype.update=function(e,t){void 0===t&&(t=!1),this._getEngine().updateDynamicTexture(this._texture,this._canvas,void 0===e||e,t,this._format||void 0)},i.prototype.drawText=function(e,t,i,r,n,o,s,a){void 0===a&&(a=!0);var h=this.getSize();if(o&&(this._context.fillStyle=o,this._context.fillRect(0,0,h.width,h.height)),this._context.font=r,null==t){var u=this._context.measureText(e);t=(h.width-u.width)/2}if(null==i){var l=parseInt(r.replace(/\D/g,""));i=h.height/2+l/3.65}this._context.fillStyle=n||"",this._context.fillText(e,t,i),a&&this.update(s)},i.prototype.clone=function(){var e=this.getScene();if(!e)return this;var t=this.getSize(),r=new i(this.name,t,e,this._generateMipMaps);return r.hasAlpha=this.hasAlpha,r.level=this.level,r.wrapU=this.wrapU,r.wrapV=this.wrapV,r},i.prototype.serialize=function(){var t=this.getScene();t&&!t.isReady()&&q.Warn("The scene must be ready before serializing the dynamic texture");var i=e.prototype.serialize.call(this);return this._IsCanvasElement(this._canvas)&&(i.base64String=this._canvas.toDataURL()),i.invertY=this._invertY,i.samplingMode=this.samplingMode,i},i.prototype._IsCanvasElement=function(e){return void 0!==e.toDataURL},i.prototype._rebuild=function(){this.update()},i}(Re);he.ShadersStore.layerVertexShader="\nattribute vec2 position;\n\nuniform vec2 scale;\nuniform vec2 offset;\nuniform mat4 textureMatrix;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) {\nvec2 shiftedPosition=position*scale+offset;\nvUV=vec2(textureMatrix*vec4(shiftedPosition*madd+madd,1.0,0.0));\ngl_Position=vec4(shiftedPosition,0.0,1.0);\n}";he.IncludesShadersStore.helperFunctions="const float PI=3.1415926535897932384626433832795;\nconst float HALF_MIN=5.96046448e-08;\nconst float LinearEncodePowerApprox=2.2;\nconst float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;\nconst vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);\nconst float Epsilon=0.0000001;\n#define saturate(x) clamp(x,0.0,1.0)\n#define absEps(x) abs(x)+Epsilon\n#define maxEps(x) max(x,Epsilon)\n#define saturateEps(x) clamp(x,Epsilon,1.0)\nmat3 transposeMat3(mat3 inMatrix) {\nvec3 i0=inMatrix[0];\nvec3 i1=inMatrix[1];\nvec3 i2=inMatrix[2];\nmat3 outMatrix=mat3(\nvec3(i0.x,i1.x,i2.x),\nvec3(i0.y,i1.y,i2.y),\nvec3(i0.z,i1.z,i2.z)\n);\nreturn outMatrix;\n}\n\nmat3 inverseMat3(mat3 inMatrix) {\nfloat a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];\nfloat a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];\nfloat a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];\nfloat b01=a22*a11-a12*a21;\nfloat b11=-a22*a10+a12*a20;\nfloat b21=a21*a10-a11*a20;\nfloat det=a00*b01+a01*b11+a02*b21;\nreturn mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),\nb11,(a22*a00-a02*a20),(-a12*a00+a02*a10),\nb21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;\n}\nfloat toLinearSpace(float color)\n{\nreturn pow(color,LinearEncodePowerApprox);\n}\nvec3 toLinearSpace(vec3 color)\n{\nreturn pow(color,vec3(LinearEncodePowerApprox));\n}\nvec4 toLinearSpace(vec4 color)\n{\nreturn vec4(pow(color.rgb,vec3(LinearEncodePowerApprox)),color.a);\n}\nvec3 toGammaSpace(vec3 color)\n{\nreturn pow(color,vec3(GammaEncodePowerApprox));\n}\nvec4 toGammaSpace(vec4 color)\n{\nreturn vec4(pow(color.rgb,vec3(GammaEncodePowerApprox)),color.a);\n}\nfloat toGammaSpace(float color)\n{\nreturn pow(color,GammaEncodePowerApprox);\n}\nfloat square(float value)\n{\nreturn value*value;\n}\nfloat pow5(float value) {\nfloat sq=value*value;\nreturn sq*sq*value;\n}\nfloat getLuminance(vec3 color)\n{\nreturn clamp(dot(color,LuminanceEncodeApprox),0.,1.);\n}\n\nfloat getRand(vec2 seed) {\nreturn fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);\n}\nfloat dither(vec2 seed,float varianceAmount) {\nfloat rand=getRand(seed);\nfloat dither=mix(-varianceAmount/255.0,varianceAmount/255.0,rand);\nreturn dither;\n}\n\nconst float rgbdMaxRange=255.0;\nvec4 toRGBD(vec3 color) {\nfloat maxRGB=maxEps(max(color.r,max(color.g,color.b)));\nfloat D=max(rgbdMaxRange/maxRGB,1.);\nD=clamp(floor(D)/255.0,0.,1.);\n\nvec3 rgb=color.rgb*D;\n\nrgb=toGammaSpace(rgb);\nreturn vec4(rgb,D);\n}\nvec3 fromRGBD(vec4 rgbd) {\n\nrgbd.rgb=toLinearSpace(rgbd.rgb);\n\nreturn rgbd.rgb/rgbd.a;\n}\n";he.ShadersStore.layerPixelShader="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec4 color;\n\n#include<helperFunctions>\nvoid main(void) {\nvec4 baseColor=texture2D(textureSampler,vUV);\n#ifdef LINEAR\nbaseColor.rgb=toGammaSpace(baseColor.rgb);\n#endif\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\ngl_FragColor=baseColor*color;\n}";var Xe=function(){function e(e,t,i,r,n,o){this.source=e,this.pointerX=t,this.pointerY=i,this.meshUnderPointer=r,this.sourceEvent=n,this.additionalData=o}return e.CreateNew=function(t,i,r){var n=t.getScene();return new e(t,n.pointerX,n.pointerY,n.meshUnderPointer||t,i,r)},e.CreateNewFromSprite=function(t,i,r,n){return new e(t,i.pointerX,i.pointerY,i.meshUnderPointer,r,n)},e.CreateNewFromScene=function(t,i){return new e(null,t.pointerX,t.pointerY,t.meshUnderPointer,i)},e.CreateNewFromPrimitive=function(t,i,r,n){return new e(t,i.x,i.y,null,r,n)},e}(),je=function(){function e(e,t){this.triggerOptions=e,this.onBeforeExecuteObservable=new U,e.parameter?(this.trigger=e.trigger,this._triggerParameter=e.parameter):e.trigger?this.trigger=e.trigger:this.trigger=e,this._nextActiveAction=this,this._condition=t}return e.prototype._prepare=function(){},e.prototype.getTriggerParameter=function(){return this._triggerParameter},e.prototype._executeCurrent=function(e){if(this._nextActiveAction._condition){var t=this._nextActiveAction._condition,i=this._actionManager.getScene().getRenderId();if(t._evaluationId===i){if(!t._currentResult)return}else{if(t._evaluationId=i,!t.isValid())return void(t._currentResult=!1);t._currentResult=!0}}this.onBeforeExecuteObservable.notifyObservers(this),this._nextActiveAction.execute(e),this.skipToNextActiveAction()},e.prototype.execute=function(e){},e.prototype.skipToNextActiveAction=function(){this._nextActiveAction._child?(this._nextActiveAction._child._actionManager||(this._nextActiveAction._child._actionManager=this._actionManager),this._nextActiveAction=this._nextActiveAction._child):this._nextActiveAction=this},e.prototype.then=function(e){return this._child=e,e._actionManager=this._actionManager,e._prepare(),e},e.prototype._getProperty=function(e){return this._actionManager._getProperty(e)},e.prototype._getEffectiveTarget=function(e,t){return this._actionManager._getEffectiveTarget(e,t)},e.prototype.serialize=function(e){},e.prototype._serialize=function(e,t){var i={type:1,children:[],name:e.name,properties:e.properties||[]};if(this._child&&this._child.serialize(i),this._condition){var r=this._condition.serialize();return r.children.push(i),t&&t.children.push(r),r}return t&&t.children.push(i),i},e._SerializeValueAsString=function(e){return"number"==typeof e?e.toString():"boolean"==typeof e?e?"true":"false":e instanceof d?e.x+", "+e.y:e instanceof p?e.x+", "+e.y+", "+e.z:e instanceof T?e.r+", "+e.g+", "+e.b:e instanceof E?e.r+", "+e.g+", "+e.b+", "+e.a:e},e._GetTargetProperty=function(e){return{name:"target",targetType:e._isMesh?"MeshProperties":e._isLight?"LightProperties":e._isCamera?"CameraProperties":"SceneProperties",value:e._isScene?"Scene":e.name}},e}();c.RegisteredTypes["BABYLON.Action"]=je;var Ke=function(){function e(e){this._actionManager=e}return e.prototype.isValid=function(){return!0},e.prototype._getProperty=function(e){return this._actionManager._getProperty(e)},e.prototype._getEffectiveTarget=function(e,t){return this._actionManager._getEffectiveTarget(e,t)},e.prototype.serialize=function(){},e.prototype._serialize=function(e){return{type:2,children:[],name:e.name,properties:e.properties}},e}(),Ye=function(e){function i(t,r,n,o,s){void 0===s&&(s=i.IsEqual);var a=e.call(this,t)||this;return a.propertyPath=n,a.value=o,a.operator=s,a._target=r,a._effectiveTarget=a._getEffectiveTarget(r,a.propertyPath),a._property=a._getProperty(a.propertyPath),a}return t(i,e),Object.defineProperty(i,"IsEqual",{get:function(){return i._IsEqual},enumerable:!1,configurable:!0}),Object.defineProperty(i,"IsDifferent",{get:function(){return i._IsDifferent},enumerable:!1,configurable:!0}),Object.defineProperty(i,"IsGreater",{get:function(){return i._IsGreater},enumerable:!1,configurable:!0}),Object.defineProperty(i,"IsLesser",{get:function(){return i._IsLesser},enumerable:!1,configurable:!0}),i.prototype.isValid=function(){switch(this.operator){case i.IsGreater:return this._effectiveTarget[this._property]>this.value;case i.IsLesser:return this._effectiveTarget[this._property]<this.value;case i.IsEqual:case i.IsDifferent:var e;return e=this.value.equals?this.value.equals(this._effectiveTarget[this._property]):this.value===this._effectiveTarget[this._property],this.operator===i.IsEqual?e:!e}return!1},i.prototype.serialize=function(){return this._serialize({name:"ValueCondition",properties:[je._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:je._SerializeValueAsString(this.value)},{name:"operator",value:i.GetOperatorName(this.operator)}]})},i.GetOperatorName=function(e){switch(e){case i._IsEqual:return"IsEqual";case i._IsDifferent:return"IsDifferent";case i._IsGreater:return"IsGreater";case i._IsLesser:return"IsLesser";default:return""}},i._IsEqual=0,i._IsDifferent=1,i._IsGreater=2,i._IsLesser=3,i}(Ke),qe=function(e){function i(t,i){var r=e.call(this,t)||this;return r.predicate=i,r}return t(i,e),i.prototype.isValid=function(){return this.predicate()},i}(Ke),Ze=function(e){function i(t,i,r){var n=e.call(this,t)||this;return n.value=r,n._target=i,n}return t(i,e),i.prototype.isValid=function(){return this._target.state===this.value},i.prototype.serialize=function(){return this._serialize({name:"StateCondition",properties:[je._GetTargetProperty(this._target),{name:"value",value:this.value}]})},i}(Ke);c.RegisteredTypes["BABYLON.ValueCondition"]=Ye,c.RegisteredTypes["BABYLON.PredicateCondition"]=qe,c.RegisteredTypes["BABYLON.StateCondition"]=Ze;!function(e){function i(t,i,r,n){var o=e.call(this,t,n)||this;return o.propertyPath=r,o._target=o._effectiveTarget=i,o}t(i,e),i.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath)},i.prototype.execute=function(){this._effectiveTarget[this._property]=!this._effectiveTarget[this._property]},i.prototype.serialize=function(t){return e.prototype._serialize.call(this,{name:"SwitchBooleanAction",properties:[je._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath}]},t)}}(je);var Qe=function(e){function i(t,i,r,n){var o=e.call(this,t,n)||this;return o.value=r,o._target=i,o}return t(i,e),i.prototype.execute=function(){this._target.state=this.value},i.prototype.serialize=function(t){return e.prototype._serialize.call(this,{name:"SetStateAction",properties:[je._GetTargetProperty(this._target),{name:"value",value:this.value}]},t)},i}(je),Je=function(e){function i(t,i,r,n,o){var s=e.call(this,t,o)||this;return s.propertyPath=r,s.value=n,s._target=s._effectiveTarget=i,s}return t(i,e),i.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath)},i.prototype.execute=function(){this._effectiveTarget[this._property]=this.value,this._target.markAsDirty&&this._target.markAsDirty(this._property)},i.prototype.serialize=function(t){return e.prototype._serialize.call(this,{name:"SetValueAction",properties:[je._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:je._SerializeValueAsString(this.value)}]},t)},i}(je),$e=function(e){function i(t,i,r,n,o){var s=e.call(this,t,o)||this;return s.propertyPath=r,s.value=n,s._target=s._effectiveTarget=i,s}return t(i,e),i.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath),"number"!=typeof this._effectiveTarget[this._property]&&q.Warn("Warning: IncrementValueAction can only be used with number values")},i.prototype.execute=function(){this._effectiveTarget[this._property]+=this.value,this._target.markAsDirty&&this._target.markAsDirty(this._property)},i.prototype.serialize=function(t){return e.prototype._serialize.call(this,{name:"IncrementValueAction",properties:[je._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:je._SerializeValueAsString(this.value)}]},t)},i}(je),et=function(e){function i(t,i,r,n,o,s){var a=e.call(this,t,s)||this;return a.from=r,a.to=n,a.loop=o,a._target=i,a}return t(i,e),i.prototype._prepare=function(){},i.prototype.execute=function(){this._actionManager.getScene().beginAnimation(this._target,this.from,this.to,this.loop)},i.prototype.serialize=function(t){return e.prototype._serialize.call(this,{name:"PlayAnimationAction",properties:[je._GetTargetProperty(this._target),{name:"from",value:String(this.from)},{name:"to",value:String(this.to)},{name:"loop",value:je._SerializeValueAsString(this.loop)||!1}]},t)},i}(je),tt=function(e){function i(t,i,r){var n=e.call(this,t,r)||this;return n._target=i,n}return t(i,e),i.prototype._prepare=function(){},i.prototype.execute=function(){this._actionManager.getScene().stopAnimation(this._target)},i.prototype.serialize=function(t){return e.prototype._serialize.call(this,{name:"StopAnimationAction",properties:[je._GetTargetProperty(this._target)]},t)},i}(je),it=function(e){function i(t,i){return void 0===t&&(t=0),e.call(this,t,i)||this}return t(i,e),i.prototype.execute=function(){},i.prototype.serialize=function(t){return e.prototype._serialize.call(this,{name:"DoNothingAction",properties:[]},t)},i}(je),rt=(function(e){function i(t,i,r){var n=e.call(this,t,r)||this;return n.children=i,n}t(i,e),i.prototype._prepare=function(){for(var e=0;e<this.children.length;e++)this.children[e]._actionManager=this._actionManager,this.children[e]._prepare()},i.prototype.execute=function(e){for(var t=0;t<this.children.length;t++)this.children[t].execute(e)},i.prototype.serialize=function(t){for(var i=e.prototype._serialize.call(this,{name:"CombineAction",properties:[],combine:[]},t),r=0;r<this.children.length;r++)i.combine.push(this.children[r].serialize(null));return i}}(je),function(e){function i(t,i,r){var n=e.call(this,t,r)||this;return n.func=i,n}return t(i,e),i.prototype.execute=function(e){this.func(e)},i}(je)),nt=function(e){function i(t,i,r,n){var o=e.call(this,t,n)||this;return o._target=i,o._parent=r,o}return t(i,e),i.prototype._prepare=function(){},i.prototype.execute=function(){if(this._target.parent!==this._parent){var e=this._parent.getWorldMatrix().clone();e.invert(),this._target.position=p.TransformCoordinates(this._target.position,e),this._target.parent=this._parent}},i.prototype.serialize=function(t){return e.prototype._serialize.call(this,{name:"SetParentAction",properties:[je._GetTargetProperty(this._target),je._GetTargetProperty(this._parent)]},t)},i}(je);c.RegisteredTypes["BABYLON.SetParentAction"]=nt,c.RegisteredTypes["BABYLON.ExecuteCodeAction"]=rt,c.RegisteredTypes["BABYLON.DoNothingAction"]=it,c.RegisteredTypes["BABYLON.StopAnimationAction"]=tt,c.RegisteredTypes["BABYLON.PlayAnimationAction"]=et,c.RegisteredTypes["BABYLON.IncrementValueAction"]=$e,c.RegisteredTypes["BABYLON.SetValueAction"]=Je,c.RegisteredTypes["BABYLON.SetStateAction"]=Qe,c.RegisteredTypes["BABYLON.SetParentAction"]=nt;var ot,st=function(){function e(){this.hoverCursor="",this.actions=new Array,this.isRecursive=!1}return Object.defineProperty(e,"HasTriggers",{get:function(){for(var t in e.Triggers)if(e.Triggers.hasOwnProperty(t))return!0;return!1},enumerable:!1,configurable:!0}),Object.defineProperty(e,"HasPickTriggers",{get:function(){for(var t in e.Triggers)if(e.Triggers.hasOwnProperty(t)){var i=parseInt(t);if(i>=1&&i<=7)return!0}return!1},enumerable:!1,configurable:!0}),e.HasSpecificTrigger=function(t){for(var i in e.Triggers){if(e.Triggers.hasOwnProperty(i))if(parseInt(i)===t)return!0}return!1},e.Triggers={},e}(),at=function(e){function i(t){var i=e.call(this)||this;return i._scene=t||V.LastCreatedScene,t.actionManagers.push(i),i}return t(i,e),i.prototype.dispose=function(){for(var e=this._scene.actionManagers.indexOf(this),t=0;t<this.actions.length;t++){var r=this.actions[t];i.Triggers[r.trigger]--,0===i.Triggers[r.trigger]&&delete i.Triggers[r.trigger]}e>-1&&this._scene.actionManagers.splice(e,1)},i.prototype.getScene=function(){return this._scene},i.prototype.hasSpecificTriggers=function(e){for(var t=0;t<this.actions.length;t++){var i=this.actions[t];if(e.indexOf(i.trigger)>-1)return!0}return!1},i.prototype.hasSpecificTriggers2=function(e,t){for(var i=0;i<this.actions.length;i++){var r=this.actions[i];if(e==r.trigger||t==r.trigger)return!0}return!1},i.prototype.hasSpecificTrigger=function(e,t){for(var i=0;i<this.actions.length;i++){var r=this.actions[i];if(r.trigger===e){if(!t)return!0;if(t(r.getTriggerParameter()))return!0}}return!1},Object.defineProperty(i.prototype,"hasPointerTriggers",{get:function(){for(var e=0;e<this.actions.length;e++){var t=this.actions[e];if(t.trigger>=i.OnPickTrigger&&t.trigger<=i.OnPointerOutTrigger)return!0}return!1},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"hasPickTriggers",{get:function(){for(var e=0;e<this.actions.length;e++){var t=this.actions[e];if(t.trigger>=i.OnPickTrigger&&t.trigger<=i.OnPickUpTrigger)return!0}return!1},enumerable:!1,configurable:!0}),i.prototype.registerAction=function(e){return e.trigger===i.OnEveryFrameTrigger&&this.getScene().actionManager!==this?(q.Warn("OnEveryFrameTrigger can only be used with scene.actionManager"),null):(this.actions.push(e),i.Triggers[e.trigger]?i.Triggers[e.trigger]++:i.Triggers[e.trigger]=1,e._actionManager=this,e._prepare(),e)},i.prototype.unregisterAction=function(e){var t=this.actions.indexOf(e);return-1!==t&&(this.actions.splice(t,1),i.Triggers[e.trigger]-=1,0===i.Triggers[e.trigger]&&delete i.Triggers[e.trigger],e._actionManager=null,!0)},i.prototype.processTrigger=function(e,t){for(var r=0;r<this.actions.length;r++){var n=this.actions[r];if(n.trigger===e){if(t&&(e===i.OnKeyUpTrigger||e===i.OnKeyDownTrigger)){var o=n.getTriggerParameter();if(o&&o!==t.sourceEvent.keyCode){if(!o.toLowerCase)continue;var s=o.toLowerCase();if(s!==t.sourceEvent.key){var a=t.sourceEvent.charCode?t.sourceEvent.charCode:t.sourceEvent.keyCode;if(String.fromCharCode(a).toLowerCase()!==s)continue}}}n._executeCurrent(t)}}},i.prototype._getEffectiveTarget=function(e,t){for(var i=t.split("."),r=0;r<i.length-1;r++)e=e[i[r]];return e},i.prototype._getProperty=function(e){var t=e.split(".");return t[t.length-1]},i.prototype.serialize=function(e){for(var t={children:new Array,name:e,type:3,properties:new Array},r=0;r<this.actions.length;r++){var n={type:0,children:new Array,name:i.GetTriggerName(this.actions[r].trigger),properties:new Array},o=this.actions[r].triggerOptions;if(o&&"number"!=typeof o)if(o.parameter instanceof Node)n.properties.push(je._GetTargetProperty(o.parameter));else{var s={};Le.DeepCopy(o.parameter,s,["mesh"]),o.parameter&&o.parameter.mesh&&(s._meshId=o.parameter.mesh.id),n.properties.push({name:"parameter",targetType:null,value:s})}this.actions[r].serialize(n),t.children.push(n)}return t},i.Parse=function(e,t,r){var n=new i(r);null===t?r.actionManager=n:t.actionManager=n;for(var o=function(e,t,i,r){if(null===r){var n=parseFloat(t);return"true"===t||"false"===t?"true"===t:isNaN(n)?t:n}for(var o=r.split("."),s=t.split(","),a=0;a<o.length;a++)i=i[o[a]];if("boolean"==typeof i)return"true"===s[0];if("string"==typeof i)return s[0];var h=new Array;for(a=0;a<s.length;a++)h.push(parseFloat(s[a]));return i instanceof p?p.FromArray(h):i instanceof _?_.FromArray(h):i instanceof T?T.FromArray(h):i instanceof E?E.FromArray(h):parseFloat(s[0])},s=function(e,t,a,h,u){if(void 0===u&&(u=null),!e.detached){var l=new Array,f=null,d=null,p=e.combine&&e.combine.length>0;if(2===e.type?l.push(n):l.push(t),p){for(var _=new Array,g=0;g<e.combine.length;g++)s(e.combine[g],i.NothingTrigger,a,h,_);l.push(_)}else for(var m=0;m<e.properties.length;m++){var v=e.properties[m].value,y=e.properties[m].name,b=e.properties[m].targetType;"target"===y?v=f=null!==b&&"SceneProperties"===b?r:r.getNodeByName(v):"parent"===y?v=r.getNodeByName(v):"sound"===y?r.getSoundByName&&(v=r.getSoundByName(v)):"propertyPath"!==y?v=2===e.type&&"operator"===y?Ye[v]:o(0,v,f,"value"===y?d:null):d=v,l.push(v)}if(null===u?l.push(a):l.push(null),"InterpolateValueAction"===e.name){var T=l[l.length-2];l[l.length-1]=T,l[l.length-2]=a}var E=function(e,t){var i=c.GetClass("BABYLON."+e);if(i){var r=Object.create(i.prototype);return r.constructor.apply(r,t),r}}(e.name,l);if(E instanceof Ke&&null!==a){var x=new it(t,a);h?h.then(x):n.registerAction(x),h=x}null===u?E instanceof Ke?(a=E,E=h):(a=null,h?h.then(E):n.registerAction(E)):u.push(E);for(m=0;m<e.children.length;m++)s(e.children[m],t,a,E,null)}},a=0;a<e.children.length;a++){var h,u=e.children[a];if(u.properties.length>0){var l=u.properties[0].value,f=null===u.properties[0].targetType?l:r.getMeshByName(l);f._meshId&&(f.mesh=r.getMeshByID(f._meshId)),h={trigger:i[u.name],parameter:f}}else h=i[u.name];for(var d=0;d<u.children.length;d++)u.detached||s(u.children[d],h,null,null)}},i.GetTriggerName=function(e){switch(e){case 0:return"NothingTrigger";case 1:return"OnPickTrigger";case 2:return"OnLeftPickTrigger";case 3:return"OnRightPickTrigger";case 4:return"OnCenterPickTrigger";case 5:return"OnPickDownTrigger";case 6:return"OnPickUpTrigger";case 7:return"OnLongPressTrigger";case 8:return"OnPointerOverTrigger";case 9:return"OnPointerOutTrigger";case 10:return"OnEveryFrameTrigger";case 11:return"OnIntersectionEnterTrigger";case 12:return"OnIntersectionExitTrigger";case 13:return"OnKeyDownTrigger";case 14:return"OnKeyUpTrigger";case 15:return"OnPickOutTrigger";default:return""}},i.NothingTrigger=0,i.OnPickTrigger=1,i.OnLeftPickTrigger=2,i.OnRightPickTrigger=3,i.OnCenterPickTrigger=4,i.OnPickDownTrigger=5,i.OnDoublePickTrigger=6,i.OnPickUpTrigger=7,i.OnPickOutTrigger=16,i.OnLongPressTrigger=8,i.OnPointerOverTrigger=9,i.OnPointerOutTrigger=10,i.OnEveryFrameTrigger=11,i.OnIntersectionEnterTrigger=12,i.OnIntersectionExitTrigger=13,i.OnKeyDownTrigger=14,i.OnKeyUpTrigger=15,i}(st);!function(e){e[e.STEP=1]="STEP"}(ot||(ot={}));var ht=function(){function e(e,t,i){this.name=e,this.from=t,this.to=i}return e.prototype.clone=function(){return new e(this.name,this.from,this.to)},e}(),ut=function(){function e(e,t){void 0===t&&(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=m.Identity(),this._worldMatrixDeterminant=0,this._worldMatrixDeterminantIsDirty=!0,this._sceneRootNodesIndex=-1,this._animationPropertiesOverride=null,this._isNode=!0,this.onDisposeObservable=new U,this._onDisposeObserver=null,this._behaviors=new Array,this.name=e,this.id=e,this._scene=t||V.LastCreatedScene,this.uniqueId=this._scene.getUniqueId(),this._initCache()}return e.AddNodeConstructor=function(e,t){this._NodeConstructors[e]=t},e.Construct=function(e,t,i,r){var n=this._NodeConstructors[e];return n?n(t,i,r):null},Object.defineProperty(e.prototype,"doNotSerialize",{get:function(){return!!this._doNotSerialize||!!this._parentNode&&this._parentNode.doNotSerialize},set:function(e){this._doNotSerialize=e},enumerable:!1,configurable:!0}),e.prototype.isDisposed=function(){return this._isDisposed},Object.defineProperty(e.prototype,"parent",{get:function(){return this._parentNode},set:function(e){if(this._parentNode!==e){var t=this._parentNode;if(this._parentNode&&void 0!==this._parentNode._children&&null!==this._parentNode._children){var i=this._parentNode._children.indexOf(this);-1!==i&&this._parentNode._children.splice(i,1),e||this._isDisposed||this._addToSceneRootNodes()}this._parentNode=e,this._parentNode&&(void 0!==this._parentNode._children&&null!==this._parentNode._children||(this._parentNode._children=new Array),this._parentNode._children.push(this),t||this._removeFromSceneRootNodes()),this._syncParentEnabledState()}},enumerable:!1,configurable:!0}),e.prototype._addToSceneRootNodes=function(){-1===this._sceneRootNodesIndex&&(this._sceneRootNodesIndex=this._scene.rootNodes.length,this._scene.rootNodes.push(this))},e.prototype._removeFromSceneRootNodes=function(){if(-1!==this._sceneRootNodesIndex){var e=this._scene.rootNodes,t=e.length-1;e[this._sceneRootNodesIndex]=e[t],e[this._sceneRootNodesIndex]._sceneRootNodesIndex=this._sceneRootNodesIndex,this._scene.rootNodes.pop(),this._sceneRootNodesIndex=-1}},Object.defineProperty(e.prototype,"animationPropertiesOverride",{get:function(){return this._animationPropertiesOverride?this._animationPropertiesOverride:this._scene.animationPropertiesOverride},set:function(e){this._animationPropertiesOverride=e},enumerable:!1,configurable:!0}),e.prototype.getClassName=function(){return"Node"},Object.defineProperty(e.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),e.prototype.getScene=function(){return this._scene},e.prototype.getEngine=function(){return this._scene.getEngine()},e.prototype.addBehavior=function(e,t){var i=this;return void 0===t&&(t=!1),-1!==this._behaviors.indexOf(e)||(e.init(),this._scene.isLoading&&!t?this._scene.onDataLoadedObservable.addOnce((function(){e.attach(i)})):e.attach(this),this._behaviors.push(e)),this},e.prototype.removeBehavior=function(e){var t=this._behaviors.indexOf(e);return-1===t||(this._behaviors[t].detach(),this._behaviors.splice(t,1)),this},Object.defineProperty(e.prototype,"behaviors",{get:function(){return this._behaviors},enumerable:!1,configurable:!0}),e.prototype.getBehaviorByName=function(e){for(var t=0,i=this._behaviors;t<i.length;t++){var r=i[t];if(r.name===e)return r}return null},e.prototype.getWorldMatrix=function(){return this._currentRenderId!==this._scene.getRenderId()&&this.computeWorldMatrix(),this._worldMatrix},e.prototype._getWorldMatrixDeterminant=function(){return this._worldMatrixDeterminantIsDirty&&(this._worldMatrixDeterminantIsDirty=!1,this._worldMatrixDeterminant=this._worldMatrix.determinant()),this._worldMatrixDeterminant},Object.defineProperty(e.prototype,"worldMatrixFromCache",{get:function(){return this._worldMatrix},enumerable:!1,configurable:!0}),e.prototype._initCache=function(){this._cache={},this._cache.parent=void 0},e.prototype.updateCache=function(e){!e&&this.isSynchronized()||(this._cache.parent=this.parent,this._updateCache())},e.prototype._getActionManagerForTrigger=function(e,t){return this.parent?this.parent._getActionManagerForTrigger(e,!1):null},e.prototype._updateCache=function(e){},e.prototype._isSynchronized=function(){return!0},e.prototype._markSyncedWithParent=function(){this._parentNode&&(this._parentUpdateId=this._parentNode._childUpdateId)},e.prototype.isSynchronizedWithParent=function(){return!this._parentNode||this._parentUpdateId===this._parentNode._childUpdateId&&this._parentNode.isSynchronized()},e.prototype.isSynchronized=function(){return this._cache.parent!=this._parentNode?(this._cache.parent=this._parentNode,!1):!(this._parentNode&&!this.isSynchronizedWithParent())&&this._isSynchronized()},e.prototype.isReady=function(e){return this._isReady},e.prototype.isEnabled=function(e){return void 0===e&&(e=!0),!1===e?this._isEnabled:!!this._isEnabled&&this._isParentEnabled},e.prototype._syncParentEnabledState=function(){this._isParentEnabled=!this._parentNode||this._parentNode.isEnabled(),this._children&&this._children.forEach((function(e){e._syncParentEnabledState()}))},e.prototype.setEnabled=function(e){this._isEnabled=e,this._syncParentEnabledState()},e.prototype.isDescendantOf=function(e){return!!this.parent&&(this.parent===e||this.parent.isDescendantOf(e))},e.prototype._getDescendants=function(e,t,i){if(void 0===t&&(t=!1),this._children)for(var r=0;r<this._children.length;r++){var n=this._children[r];i&&!i(n)||e.push(n),t||n._getDescendants(e,!1,i)}},e.prototype.getDescendants=function(e,t){var i=new Array;return this._getDescendants(i,e,t),i},e.prototype.getChildMeshes=function(e,t){var i=[];return this._getDescendants(i,e,(function(e){return(!t||t(e))&&void 0!==e.cullingStrategy})),i},e.prototype.getChildren=function(e,t){return void 0===t&&(t=!0),this.getDescendants(t,e)},e.prototype._setReady=function(e){e!==this._isReady&&(e?(this.onReady&&this.onReady(this),this._isReady=!0):this._isReady=!1)},e.prototype.getAnimationByName=function(e){for(var t=0;t<this.animations.length;t++){var i=this.animations[t];if(i.name===e)return i}return null},e.prototype.createAnimationRange=function(t,i,r){if(!this._ranges[t]){this._ranges[t]=e._AnimationRangeFactory(t,i,r);for(var n=0,o=this.animations.length;n<o;n++)this.animations[n]&&this.animations[n].createRange(t,i,r)}},e.prototype.deleteAnimationRange=function(e,t){void 0===t&&(t=!0);for(var i=0,r=this.animations.length;i<r;i++)this.animations[i]&&this.animations[i].deleteRange(e,t);this._ranges[e]=null},e.prototype.getAnimationRange=function(e){return this._ranges[e]||null},e.prototype.getAnimationRanges=function(){var e,t=[];for(e in this._ranges)t.push(this._ranges[e]);return t},e.prototype.beginAnimation=function(e,t,i,r){var n=this.getAnimationRange(e);return n?this._scene.beginAnimation(this,n.from,n.to,t,i,r):null},e.prototype.serializeAnimationRanges=function(){var e=[];for(var t in this._ranges){var i=this._ranges[t];if(i){var r={};r.name=t,r.from=i.from,r.to=i.to,e.push(r)}}return e},e.prototype.computeWorldMatrix=function(e){return this._worldMatrix||(this._worldMatrix=m.Identity()),this._worldMatrix},e.prototype.dispose=function(e,t){if(void 0===t&&(t=!1),this._isDisposed=!0,!e)for(var i=0,r=this.getDescendants(!0);i<r.length;i++){r[i].dispose(e,t)}this.parent?this.parent=null:this._removeFromSceneRootNodes(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear();for(var n=0,o=this._behaviors;n<o.length;n++){o[n].detach()}this._behaviors=[]},e.ParseAnimationRanges=function(e,t,i){if(t.ranges)for(var r=0;r<t.ranges.length;r++){var n=t.ranges[r];e.createAnimationRange(n.name,n.from,n.to)}},e.prototype.getHierarchyBoundingVectors=function(e,t){var i,r;void 0===e&&(e=!0),void 0===t&&(t=null),this.getScene().incrementRenderId(),this.computeWorldMatrix(!0);var n=this;if(n.getBoundingInfo&&n.subMeshes){var o=n.getBoundingInfo();i=o.boundingBox.minimumWorld.clone(),r=o.boundingBox.maximumWorld.clone()}else i=new p(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),r=new p(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);if(e)for(var s=0,a=this.getDescendants(!1);s<a.length;s++){var h=a[s];if(h.computeWorldMatrix(!0),(!t||t(h))&&h.getBoundingInfo&&0!==h.getTotalVertices()){var u=h.getBoundingInfo().boundingBox,l=u.minimumWorld,c=u.maximumWorld;p.CheckExtends(l,i,r),p.CheckExtends(c,i,r)}}return{min:i,max:r}},e._AnimationRangeFactory=function(e,t,i){throw b.WarnImport("AnimationRange")},e._NodeConstructors={},r([O()],e.prototype,"name",void 0),r([O()],e.prototype,"id",void 0),r([O()],e.prototype,"uniqueId",void 0),r([O()],e.prototype,"state",void 0),r([O()],e.prototype,"metadata",void 0),e}(),lt=function(){function e(t,i,r,n,o,s){this.name=t,this.targetProperty=i,this.framePerSecond=r,this.dataType=n,this.loopMode=o,this.enableBlending=s,this._runtimeAnimations=new Array,this._events=new Array,this.blendingSpeed=.01,this._ranges={},this.targetPropertyPath=i.split("."),this.dataType=n,this.loopMode=void 0===o?e.ANIMATIONLOOPMODE_CYCLE:o}return e._PrepareAnimation=function(t,i,r,n,o,s,a,h){var u=void 0;if(!isNaN(parseFloat(o))&&isFinite(o)?u=e.ANIMATIONTYPE_FLOAT:o instanceof g?u=e.ANIMATIONTYPE_QUATERNION:o instanceof p?u=e.ANIMATIONTYPE_VECTOR3:o instanceof d?u=e.ANIMATIONTYPE_VECTOR2:o instanceof T?u=e.ANIMATIONTYPE_COLOR3:o instanceof E?u=e.ANIMATIONTYPE_COLOR4:o instanceof Me&&(u=e.ANIMATIONTYPE_SIZE),null==u)return null;var l=new e(t,i,r,u,a),c=[{frame:0,value:o},{frame:n,value:s}];return l.setKeys(c),void 0!==h&&l.setEasingFunction(h),l},e.CreateAnimation=function(t,i,r,n){var o=new e(t+"Animation",t,r,i,e.ANIMATIONLOOPMODE_CONSTANT);return o.setEasingFunction(n),o},e.CreateAndStartAnimation=function(t,i,r,n,o,s,a,h,u,l){var c=e._PrepareAnimation(t,r,n,o,s,a,h,u);return c?i.getScene().beginDirectAnimation(i,[c],0,o,1===c.loopMode,1,l):null},e.CreateAndStartHierarchyAnimation=function(t,i,r,n,o,s,a,h,u,l,c){var f=e._PrepareAnimation(t,n,o,s,a,h,u,l);return f?i.getScene().beginDirectHierarchyAnimation(i,r,[f],0,s,1===f.loopMode,1,c):null},e.CreateMergeAndStartAnimation=function(t,i,r,n,o,s,a,h,u,l){var c=e._PrepareAnimation(t,r,n,o,s,a,h,u);return c?(i.animations.push(c),i.getScene().beginAnimation(i,0,o,1===c.loopMode,1,l)):null},e.MakeAnimationAdditive=function(t,i,r,n,o){void 0===i&&(i=0),void 0===n&&(n=!1);var s=t;if(n&&((s=t.clone()).name=o||s.name),!s._keys.length)return s;i=i>=0?i:0;var a=0,h=s._keys[0],u=s._keys.length-1,l=s._keys[u],c={referenceValue:h.value,referencePosition:y.Vector3[0],referenceQuaternion:y.Quaternion[0],referenceScaling:y.Vector3[1],keyPosition:y.Vector3[2],keyQuaternion:y.Quaternion[1],keyScaling:y.Vector3[3]},f=!1,d=h.frame,p=l.frame;if(r){var _=s.getRange(r);_&&(d=_.from,p=_.to)}var g=h.frame===d,v=l.frame===p;if(1===s._keys.length){var b=s._getKeyValue(s._keys[0]);c.referenceValue=b.clone?b.clone():b,f=!0}else if(i<=h.frame){b=s._getKeyValue(h.value);c.referenceValue=b.clone?b.clone():b,f=!0}else if(i>=l.frame){b=s._getKeyValue(l.value);c.referenceValue=b.clone?b.clone():b,f=!0}for(var T=0;!f||!g||!v&&T<s._keys.length-1;){var E=s._keys[T],x=s._keys[T+1];if(!f&&i>=E.frame&&i<=x.frame){b=void 0;if(i===E.frame)b=s._getKeyValue(E.value);else if(i===x.frame)b=s._getKeyValue(x.value);else{var A={key:T,repeatCount:0,loopMode:this.ANIMATIONLOOPMODE_CONSTANT};b=s._interpolate(i,A)}c.referenceValue=b.clone?b.clone():b,f=!0}if(!g&&d>=E.frame&&d<=x.frame){if(d===E.frame)a=T;else if(d===x.frame)a=T+1;else{A={key:T,repeatCount:0,loopMode:this.ANIMATIONLOOPMODE_CONSTANT};var M={frame:d,value:(b=s._interpolate(d,A)).clone?b.clone():b};s._keys.splice(T+1,0,M),a=T+1}g=!0}if(!v&&p>=E.frame&&p<=x.frame){if(p===E.frame)u=T;else if(p===x.frame)u=T+1;else{A={key:T,repeatCount:0,loopMode:this.ANIMATIONLOOPMODE_CONSTANT},M={frame:p,value:(b=s._interpolate(p,A)).clone?b.clone():b};s._keys.splice(T+1,0,M),u=T+1}v=!0}T++}s.dataType===e.ANIMATIONTYPE_QUATERNION?c.referenceValue.normalize().conjugateInPlace():s.dataType===e.ANIMATIONTYPE_MATRIX&&(c.referenceValue.decompose(c.referenceScaling,c.referenceQuaternion,c.referencePosition),c.referenceQuaternion.normalize().conjugateInPlace());for(T=a;T<=u;T++){M=s._keys[T];if(!T||s.dataType===e.ANIMATIONTYPE_FLOAT||M.value!==h.value)switch(s.dataType){case e.ANIMATIONTYPE_MATRIX:M.value.decompose(c.keyScaling,c.keyQuaternion,c.keyPosition),c.keyPosition.subtractInPlace(c.referencePosition),c.keyScaling.divideInPlace(c.referenceScaling),c.referenceQuaternion.multiplyToRef(c.keyQuaternion,c.keyQuaternion),m.ComposeToRef(c.keyScaling,c.keyQuaternion,c.keyPosition,M.value);break;case e.ANIMATIONTYPE_QUATERNION:c.referenceValue.multiplyToRef(M.value,M.value);break;case e.ANIMATIONTYPE_VECTOR2:case e.ANIMATIONTYPE_VECTOR3:case e.ANIMATIONTYPE_COLOR3:case e.ANIMATIONTYPE_COLOR4:M.value.subtractToRef(c.referenceValue,M.value);break;case e.ANIMATIONTYPE_SIZE:M.value.width-=c.referenceValue.width,M.value.height-=c.referenceValue.height;break;default:M.value-=c.referenceValue}}return s},e.TransitionTo=function(e,t,i,r,n,o,s,a){if(void 0===a&&(a=null),s<=0)return i[e]=t,a&&a(),null;var h=n*(s/1e3);o.setKeys([{frame:0,value:i[e].clone?i[e].clone():i[e]},{frame:h,value:t}]),i.animations||(i.animations=[]),i.animations.push(o);var u=r.beginAnimation(i,0,h,!1);return u.onAnimationEnd=a,u},Object.defineProperty(e.prototype,"runtimeAnimations",{get:function(){return this._runtimeAnimations},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasRunningRuntimeAnimations",{get:function(){for(var e=0,t=this._runtimeAnimations;e<t.length;e++){if(!t[e].isStopped)return!0}return!1},enumerable:!1,configurable:!0}),e.prototype.toString=function(e){var t="Name: "+this.name+", property: "+this.targetProperty;if(t+=", datatype: "+["Float","Vector3","Quaternion","Matrix","Color3","Vector2"][this.dataType],t+=", nKeys: "+(this._keys?this._keys.length:"none"),t+=", nRanges: "+(this._ranges?Object.keys(this._ranges).length:"none"),e){t+=", Ranges: {";var i=!0;for(var r in this._ranges)i&&(t+=", ",i=!1),t+=r;t+="}"}return t},e.prototype.addEvent=function(e){this._events.push(e),this._events.sort((function(e,t){return e.frame-t.frame}))},e.prototype.removeEvents=function(e){for(var t=0;t<this._events.length;t++)this._events[t].frame===e&&(this._events.splice(t,1),t--)},e.prototype.getEvents=function(){return this._events},e.prototype.createRange=function(e,t,i){this._ranges[e]||(this._ranges[e]=new ht(e,t,i))},e.prototype.deleteRange=function(e,t){void 0===t&&(t=!0);var i=this._ranges[e];if(i){if(t)for(var r=i.from,n=i.to,o=this._keys.length-1;o>=0;o--)this._keys[o].frame>=r&&this._keys[o].frame<=n&&this._keys.splice(o,1);this._ranges[e]=null}},e.prototype.getRange=function(e){return this._ranges[e]},e.prototype.getKeys=function(){return this._keys},e.prototype.getHighestFrame=function(){for(var e=0,t=0,i=this._keys.length;t<i;t++)e<this._keys[t].frame&&(e=this._keys[t].frame);return e},e.prototype.getEasingFunction=function(){return this._easingFunction},e.prototype.setEasingFunction=function(e){this._easingFunction=e},e.prototype.floatInterpolateFunction=function(e,t,i){return s.Lerp(e,t,i)},e.prototype.floatInterpolateFunctionWithTangents=function(e,t,i,r,n){return s.Hermite(e,t,i,r,n)},e.prototype.quaternionInterpolateFunction=function(e,t,i){return g.Slerp(e,t,i)},e.prototype.quaternionInterpolateFunctionWithTangents=function(e,t,i,r,n){return g.Hermite(e,t,i,r,n).normalize()},e.prototype.vector3InterpolateFunction=function(e,t,i){return p.Lerp(e,t,i)},e.prototype.vector3InterpolateFunctionWithTangents=function(e,t,i,r,n){return p.Hermite(e,t,i,r,n)},e.prototype.vector2InterpolateFunction=function(e,t,i){return d.Lerp(e,t,i)},e.prototype.vector2InterpolateFunctionWithTangents=function(e,t,i,r,n){return d.Hermite(e,t,i,r,n)},e.prototype.sizeInterpolateFunction=function(e,t,i){return Me.Lerp(e,t,i)},e.prototype.color3InterpolateFunction=function(e,t,i){return T.Lerp(e,t,i)},e.prototype.color4InterpolateFunction=function(e,t,i){return E.Lerp(e,t,i)},e.prototype._getKeyValue=function(e){return"function"==typeof e?e():e},e.prototype._interpolate=function(t,i){if(i.loopMode===e.ANIMATIONLOOPMODE_CONSTANT&&i.repeatCount>0)return i.highLimitValue.clone?i.highLimitValue.clone():i.highLimitValue;var r=this._keys;if(1===r.length)return this._getKeyValue(r[0].value);var n=i.key;if(r[n].frame>=t)for(;n-1>=0&&r[n].frame>=t;)n--;for(var o=n;o<r.length;o++){var s=r[o+1];if(s.frame>=t){i.key=o;var a=r[o],h=this._getKeyValue(a.value);if(a.interpolation===ot.STEP)return h;var u=this._getKeyValue(s.value),l=void 0!==a.outTangent&&void 0!==s.inTangent,c=s.frame-a.frame,f=(t-a.frame)/c,d=this.getEasingFunction();switch(null!=d&&(f=d.ease(f)),this.dataType){case e.ANIMATIONTYPE_FLOAT:var p=l?this.floatInterpolateFunctionWithTangents(h,a.outTangent*c,u,s.inTangent*c,f):this.floatInterpolateFunction(h,u,f);switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return p;case e.ANIMATIONLOOPMODE_RELATIVE:return i.offsetValue*i.repeatCount+p}break;case e.ANIMATIONTYPE_QUATERNION:var _=l?this.quaternionInterpolateFunctionWithTangents(h,a.outTangent.scale(c),u,s.inTangent.scale(c),f):this.quaternionInterpolateFunction(h,u,f);switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return _;case e.ANIMATIONLOOPMODE_RELATIVE:return _.addInPlace(i.offsetValue.scale(i.repeatCount))}return _;case e.ANIMATIONTYPE_VECTOR3:var g=l?this.vector3InterpolateFunctionWithTangents(h,a.outTangent.scale(c),u,s.inTangent.scale(c),f):this.vector3InterpolateFunction(h,u,f);switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return g;case e.ANIMATIONLOOPMODE_RELATIVE:return g.add(i.offsetValue.scale(i.repeatCount))}case e.ANIMATIONTYPE_VECTOR2:var m=l?this.vector2InterpolateFunctionWithTangents(h,a.outTangent.scale(c),u,s.inTangent.scale(c),f):this.vector2InterpolateFunction(h,u,f);switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return m;case e.ANIMATIONLOOPMODE_RELATIVE:return m.add(i.offsetValue.scale(i.repeatCount))}case e.ANIMATIONTYPE_SIZE:switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return this.sizeInterpolateFunction(h,u,f);case e.ANIMATIONLOOPMODE_RELATIVE:return this.sizeInterpolateFunction(h,u,f).add(i.offsetValue.scale(i.repeatCount))}case e.ANIMATIONTYPE_COLOR3:switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return this.color3InterpolateFunction(h,u,f);case e.ANIMATIONLOOPMODE_RELATIVE:return this.color3InterpolateFunction(h,u,f).add(i.offsetValue.scale(i.repeatCount))}case e.ANIMATIONTYPE_COLOR4:switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return this.color4InterpolateFunction(h,u,f);case e.ANIMATIONLOOPMODE_RELATIVE:return this.color4InterpolateFunction(h,u,f).add(i.offsetValue.scale(i.repeatCount))}case e.ANIMATIONTYPE_MATRIX:switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:if(e.AllowMatricesInterpolation)return this.matrixInterpolateFunction(h,u,f,i.workValue);case e.ANIMATIONLOOPMODE_RELATIVE:return h}}break}}return this._getKeyValue(r[r.length-1].value)},e.prototype.matrixInterpolateFunction=function(t,i,r,n){return e.AllowMatrixDecomposeForInterpolation?n?(m.DecomposeLerpToRef(t,i,r,n),n):m.DecomposeLerp(t,i,r):n?(m.LerpToRef(t,i,r,n),n):m.Lerp(t,i,r)},e.prototype.clone=function(){var t=new e(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 i in t._ranges={},this._ranges){var r=this._ranges[i];r&&(t._ranges[i]=r.clone())}return t},e.prototype.setKeys=function(e){this._keys=e.slice(0)},e.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 i=this.dataType;t.keys=[];for(var r=this.getKeys(),n=0;n<r.length;n++){var o=r[n],s={};switch(s.frame=o.frame,i){case e.ANIMATIONTYPE_FLOAT:s.values=[o.value],void 0!==o.inTangent&&s.values.push(o.inTangent),void 0!==o.outTangent&&(void 0===o.inTangent&&s.values.push(void 0),s.values.push(o.outTangent));break;case e.ANIMATIONTYPE_QUATERNION:case e.ANIMATIONTYPE_MATRIX:case e.ANIMATIONTYPE_VECTOR3:case e.ANIMATIONTYPE_COLOR3:case e.ANIMATIONTYPE_COLOR4:s.values=o.value.asArray(),null!=o.inTangent&&s.values.push(o.inTangent.asArray()),null!=o.outTangent&&(void 0===o.inTangent&&s.values.push(void 0),s.values.push(o.outTangent.asArray()))}t.keys.push(s)}for(var a in t.ranges=[],this._ranges){var h=this._ranges[a];if(h){var u={};u.name=a,u.from=h.from,u.to=h.to,t.ranges.push(u)}}return t},e._UniversalLerp=function(e,t,i){var r=e.constructor;return r.Lerp?r.Lerp(e,t,i):r.Slerp?r.Slerp(e,t,i):e.toFixed?e*(1-i)+i*t:t},e.Parse=function(t){var i,r,n=new e(t.name,t.property,t.framePerSecond,t.dataType,t.loopBehavior),o=t.dataType,s=[];for(t.enableBlending&&(n.enableBlending=t.enableBlending),t.blendingSpeed&&(n.blendingSpeed=t.blendingSpeed),r=0;r<t.keys.length;r++){var a,h,u=t.keys[r];switch(o){case e.ANIMATIONTYPE_FLOAT:i=u.values[0],u.values.length>=1&&(a=u.values[1]),u.values.length>=2&&(h=u.values[2]);break;case e.ANIMATIONTYPE_QUATERNION:if(i=g.FromArray(u.values),u.values.length>=8){var l=g.FromArray(u.values.slice(4,8));l.equals(g.Zero())||(a=l)}if(u.values.length>=12){var c=g.FromArray(u.values.slice(8,12));c.equals(g.Zero())||(h=c)}break;case e.ANIMATIONTYPE_MATRIX:i=m.FromArray(u.values);break;case e.ANIMATIONTYPE_COLOR3:i=T.FromArray(u.values);break;case e.ANIMATIONTYPE_COLOR4:i=E.FromArray(u.values);break;case e.ANIMATIONTYPE_VECTOR3:default:i=p.FromArray(u.values)}var f={};f.frame=u.frame,f.value=i,null!=a&&(f.inTangent=a),null!=h&&(f.outTangent=h),s.push(f)}if(n.setKeys(s),t.ranges)for(r=0;r<t.ranges.length;r++)i=t.ranges[r],n.createRange(i.name,i.from,i.to);return n},e.AppendSerializedAnimations=function(e,t){N.AppendSerializedAnimations(e,t)},e.ParseFromFileAsync=function(e,t){var i=this;return new Promise((function(r,n){var o=new G;o.addEventListener("readystatechange",(function(){if(4==o.readyState)if(200==o.status){var t=JSON.parse(o.responseText);if(t.length){for(var s=new Array,a=0,h=t;a<h.length;a++){var u=h[a];s.push(i.Parse(u))}r(s)}else{s=i.Parse(t);e&&(s.name=e),r(s)}}else n("Unable to load the animation")})),o.open("GET",t),o.send()}))},e.CreateFromSnippetAsync=function(e){var t=this;return new Promise((function(i,r){var n=new G;n.addEventListener("readystatechange",(function(){if(4==n.readyState)if(200==n.status){var o=JSON.parse(JSON.parse(n.responseText).jsonPayload);if(o.animations){for(var s=JSON.parse(o.animations),a=new Array,h=0,u=s;h<u.length;h++){var l=u[h];a.push(t.Parse(l))}i(a)}else{s=JSON.parse(o.animation);(a=t.Parse(s)).snippetId=e,i(a)}}else r("Unable to load the snippet "+e)})),n.open("GET",t.SnippetUrl+"/"+e.replace(/#/g,"/")),n.send()}))},e.AllowMatricesInterpolation=!1,e.AllowMatrixDecomposeForInterpolation=!0,e.SnippetUrl="https://snippet.babylonjs.com",e.ANIMATIONTYPE_FLOAT=0,e.ANIMATIONTYPE_VECTOR3=1,e.ANIMATIONTYPE_QUATERNION=2,e.ANIMATIONTYPE_MATRIX=3,e.ANIMATIONTYPE_COLOR3=4,e.ANIMATIONTYPE_COLOR4=7,e.ANIMATIONTYPE_VECTOR2=5,e.ANIMATIONTYPE_SIZE=6,e.ANIMATIONLOOPMODE_RELATIVE=0,e.ANIMATIONLOOPMODE_CYCLE=1,e.ANIMATIONLOOPMODE_CONSTANT=2,e}();c.RegisteredTypes["BABYLON.Animation"]=lt,ut._AnimationRangeFactory=function(e,t,i){return new ht(e,t,i)};var ct=function(){function e(e,t,i,r,n,o,s,a){void 0===r&&(r=0),void 0===n&&(n=!1),void 0===o&&(o=!1),void 0===s&&(s=!1),this._isAlreadyOwned=!1,e.getScene?this._engine=e.getScene().getEngine():this._engine=e,this._updatable=i,this._instanced=o,this._divisor=a||1,this._data=t,this.byteStride=s?r:r*Float32Array.BYTES_PER_ELEMENT,n||this.create()}return e.prototype.createVertexBuffer=function(e,t,i,r,n,o,s){void 0===o&&(o=!1);var a=o?t:t*Float32Array.BYTES_PER_ELEMENT,h=r?o?r:r*Float32Array.BYTES_PER_ELEMENT:this.byteStride;return new ft(this._engine,this,e,this._updatable,!0,h,void 0===n?this._instanced:n,a,i,void 0,void 0,!0,this._divisor||s)},e.prototype.isUpdatable=function(){return this._updatable},e.prototype.getData=function(){return this._data},e.prototype.getBuffer=function(){return this._buffer},e.prototype.getStrideSize=function(){return this.byteStride/Float32Array.BYTES_PER_ELEMENT},e.prototype.create=function(e){void 0===e&&(e=null),!e&&this._buffer||(e=e||this._data)&&(this._buffer?this._updatable&&(this._engine.updateDynamicVertexBuffer(this._buffer,e),this._data=e):this._updatable?(this._buffer=this._engine.createDynamicVertexBuffer(e),this._data=e):this._buffer=this._engine.createVertexBuffer(e))},e.prototype._rebuild=function(){this._buffer=null,this.create(this._data)},e.prototype.update=function(e){this.create(e)},e.prototype.updateDirectly=function(e,t,i,r){void 0===r&&(r=!1),this._buffer&&this._updatable&&(this._engine.updateDynamicVertexBuffer(this._buffer,e,r?t:t*Float32Array.BYTES_PER_ELEMENT,i?i*this.byteStride:void 0),this._data=null)},e.prototype._increaseReferences=function(){this._buffer&&(this._isAlreadyOwned?this._buffer.references++:this._isAlreadyOwned=!0)},e.prototype.dispose=function(){this._buffer&&this._engine._releaseBuffer(this._buffer)&&(this._buffer=null)},e}(),ft=function(){function e(t,i,r,n,o,s,a,h,u,l,c,f,d,p){if(void 0===c&&(c=!1),void 0===f&&(f=!1),void 0===d&&(d=1),void 0===p&&(p=!1),i instanceof ct?(this._buffer=i,this._ownsBuffer=p,p&&this._buffer._increaseReferences()):(this._buffer=new ct(t,i,n,s,o,a,f),this._ownsBuffer=!0),this._kind=r,null==l){var _=this.getData();this.type=e.FLOAT,_ instanceof Int8Array?this.type=e.BYTE:_ instanceof Uint8Array?this.type=e.UNSIGNED_BYTE:_ instanceof Int16Array?this.type=e.SHORT:_ instanceof Uint16Array?this.type=e.UNSIGNED_SHORT:_ instanceof Int32Array?this.type=e.INT:_ instanceof Uint32Array&&(this.type=e.UNSIGNED_INT)}else this.type=l;var g=e.GetTypeByteLength(this.type);f?(this._size=u||(s?s/g:e.DeduceStride(r)),this.byteStride=s||this._buffer.byteStride||this._size*g,this.byteOffset=h||0):(this._size=u||s||e.DeduceStride(r),this.byteStride=s?s*g:this._buffer.byteStride||this._size*g,this.byteOffset=(h||0)*g),this.normalized=c,this._instanced=void 0!==a&&a,this._instanceDivisor=a?d:0}return Object.defineProperty(e.prototype,"instanceDivisor",{get:function(){return this._instanceDivisor},set:function(e){this._instanceDivisor=e,this._instanced=0!=e},enumerable:!1,configurable:!0}),e.prototype._rebuild=function(){this._buffer&&this._buffer._rebuild()},e.prototype.getKind=function(){return this._kind},e.prototype.isUpdatable=function(){return this._buffer.isUpdatable()},e.prototype.getData=function(){return this._buffer.getData()},e.prototype.getBuffer=function(){return this._buffer.getBuffer()},e.prototype.getStrideSize=function(){return this.byteStride/e.GetTypeByteLength(this.type)},e.prototype.getOffset=function(){return this.byteOffset/e.GetTypeByteLength(this.type)},e.prototype.getSize=function(){return this._size},e.prototype.getIsInstanced=function(){return this._instanced},e.prototype.getInstanceDivisor=function(){return this._instanceDivisor},e.prototype.create=function(e){this._buffer.create(e)},e.prototype.update=function(e){this._buffer.update(e)},e.prototype.updateDirectly=function(e,t,i){void 0===i&&(i=!1),this._buffer.updateDirectly(e,t,void 0,i)},e.prototype.dispose=function(){this._ownsBuffer&&this._buffer.dispose()},e.prototype.forEach=function(t,i){e.ForEach(this._buffer.getData(),this.byteOffset,this.byteStride,this._size,this.type,t,this.normalized,i)},e.DeduceStride=function(t){switch(t){case e.UVKind:case e.UV2Kind:case e.UV3Kind:case e.UV4Kind:case e.UV5Kind:case e.UV6Kind:return 2;case e.NormalKind:case e.PositionKind:return 3;case e.ColorKind:case e.MatricesIndicesKind:case e.MatricesIndicesExtraKind:case e.MatricesWeightsKind:case e.MatricesWeightsExtraKind:case e.TangentKind:return 4;default:throw new Error("Invalid kind '"+t+"'")}},e.GetTypeByteLength=function(t){switch(t){case e.BYTE:case e.UNSIGNED_BYTE:return 1;case e.SHORT:case e.UNSIGNED_SHORT:return 2;case e.INT:case e.UNSIGNED_INT:case e.FLOAT:return 4;default:throw new Error("Invalid type '"+t+"'")}},e.ForEach=function(t,i,r,n,o,s,a,h){if(t instanceof Array)for(var u=i/4,l=r/4,c=0;c<s;c+=n){for(var f=0;f<n;f++)h(t[u+f],c+f);u+=l}else{var d=t instanceof ArrayBuffer?new DataView(t):new DataView(t.buffer,t.byteOffset,t.byteLength),p=e.GetTypeByteLength(o);for(c=0;c<s;c+=n){var _=i;for(f=0;f<n;f++){h(e._GetFloatValue(d,o,_,a),c+f),_+=p}i+=r}}},e._GetFloatValue=function(t,i,r,n){switch(i){case e.BYTE:var o=t.getInt8(r);return n&&(o=Math.max(o/127,-1)),o;case e.UNSIGNED_BYTE:o=t.getUint8(r);return n&&(o/=255),o;case e.SHORT:o=t.getInt16(r,!0);return n&&(o=Math.max(o/32767,-1)),o;case e.UNSIGNED_SHORT:o=t.getUint16(r,!0);return n&&(o/=65535),o;case e.INT:return t.getInt32(r,!0);case e.UNSIGNED_INT:return t.getUint32(r,!0);case e.FLOAT:return t.getFloat32(r,!0);default:throw new Error("Invalid component type "+i)}},e.BYTE=5120,e.UNSIGNED_BYTE=5121,e.SHORT=5122,e.UNSIGNED_SHORT=5123,e.INT=5124,e.UNSIGNED_INT=5125,e.FLOAT=5126,e.PositionKind="position",e.NormalKind="normal",e.TangentKind="tangent",e.UVKind="uv",e.UV2Kind="uv2",e.UV3Kind="uv3",e.UV4Kind="uv4",e.UV5Kind="uv5",e.UV6Kind="uv6",e.ColorKind="color",e.MatricesIndicesKind="matricesIndices",e.MatricesWeightsKind="matricesWeights",e.MatricesIndicesExtraKind="matricesIndicesExtra",e.MatricesWeightsExtraKind="matricesWeightsExtra",e}(),dt=function(){function e(){}return e.prototype.set=function(e,t){switch(e.length||q.Warn("Setting vertex data kind '"+t+"' with an empty array"),t){case ft.PositionKind:this.positions=e;break;case ft.NormalKind:this.normals=e;break;case ft.TangentKind:this.tangents=e;break;case ft.UVKind:this.uvs=e;break;case ft.UV2Kind:this.uvs2=e;break;case ft.UV3Kind:this.uvs3=e;break;case ft.UV4Kind:this.uvs4=e;break;case ft.UV5Kind:this.uvs5=e;break;case ft.UV6Kind:this.uvs6=e;break;case ft.ColorKind:this.colors=e;break;case ft.MatricesIndicesKind:this.matricesIndices=e;break;case ft.MatricesWeightsKind:this.matricesWeights=e;break;case ft.MatricesIndicesExtraKind:this.matricesIndicesExtra=e;break;case ft.MatricesWeightsExtraKind:this.matricesWeightsExtra=e}},e.prototype.applyToMesh=function(e,t){return this._applyTo(e,t),this},e.prototype.applyToGeometry=function(e,t){return this._applyTo(e,t),this},e.prototype.updateMesh=function(e){return this._update(e),this},e.prototype.updateGeometry=function(e){return this._update(e),this},e.prototype._applyTo=function(e,t){return void 0===t&&(t=!1),this.positions&&e.setVerticesData(ft.PositionKind,this.positions,t),this.normals&&e.setVerticesData(ft.NormalKind,this.normals,t),this.tangents&&e.setVerticesData(ft.TangentKind,this.tangents,t),this.uvs&&e.setVerticesData(ft.UVKind,this.uvs,t),this.uvs2&&e.setVerticesData(ft.UV2Kind,this.uvs2,t),this.uvs3&&e.setVerticesData(ft.UV3Kind,this.uvs3,t),this.uvs4&&e.setVerticesData(ft.UV4Kind,this.uvs4,t),this.uvs5&&e.setVerticesData(ft.UV5Kind,this.uvs5,t),this.uvs6&&e.setVerticesData(ft.UV6Kind,this.uvs6,t),this.colors&&e.setVerticesData(ft.ColorKind,this.colors,t),this.matricesIndices&&e.setVerticesData(ft.MatricesIndicesKind,this.matricesIndices,t),this.matricesWeights&&e.setVerticesData(ft.MatricesWeightsKind,this.matricesWeights,t),this.matricesIndicesExtra&&e.setVerticesData(ft.MatricesIndicesExtraKind,this.matricesIndicesExtra,t),this.matricesWeightsExtra&&e.setVerticesData(ft.MatricesWeightsExtraKind,this.matricesWeightsExtra,t),this.indices?e.setIndices(this.indices,null,t):e.setIndices([],null),this},e.prototype._update=function(e,t,i){return this.positions&&e.updateVerticesData(ft.PositionKind,this.positions,t,i),this.normals&&e.updateVerticesData(ft.NormalKind,this.normals,t,i),this.tangents&&e.updateVerticesData(ft.TangentKind,this.tangents,t,i),this.uvs&&e.updateVerticesData(ft.UVKind,this.uvs,t,i),this.uvs2&&e.updateVerticesData(ft.UV2Kind,this.uvs2,t,i),this.uvs3&&e.updateVerticesData(ft.UV3Kind,this.uvs3,t,i),this.uvs4&&e.updateVerticesData(ft.UV4Kind,this.uvs4,t,i),this.uvs5&&e.updateVerticesData(ft.UV5Kind,this.uvs5,t,i),this.uvs6&&e.updateVerticesData(ft.UV6Kind,this.uvs6,t,i),this.colors&&e.updateVerticesData(ft.ColorKind,this.colors,t,i),this.matricesIndices&&e.updateVerticesData(ft.MatricesIndicesKind,this.matricesIndices,t,i),this.matricesWeights&&e.updateVerticesData(ft.MatricesWeightsKind,this.matricesWeights,t,i),this.matricesIndicesExtra&&e.updateVerticesData(ft.MatricesIndicesExtraKind,this.matricesIndicesExtra,t,i),this.matricesWeightsExtra&&e.updateVerticesData(ft.MatricesWeightsExtraKind,this.matricesWeightsExtra,t,i),this.indices&&e.setIndices(this.indices,null),this},e.prototype.transform=function(e){var t,i=e.determinant()<0,r=p.Zero();if(this.positions){var n=p.Zero();for(t=0;t<this.positions.length;t+=3)p.FromArrayToRef(this.positions,t,n),p.TransformCoordinatesToRef(n,e,r),this.positions[t]=r.x,this.positions[t+1]=r.y,this.positions[t+2]=r.z}if(this.normals){var o=p.Zero();for(t=0;t<this.normals.length;t+=3)p.FromArrayToRef(this.normals,t,o),p.TransformNormalToRef(o,e,r),this.normals[t]=r.x,this.normals[t+1]=r.y,this.normals[t+2]=r.z}if(this.tangents){var s=_.Zero(),a=_.Zero();for(t=0;t<this.tangents.length;t+=4)_.FromArrayToRef(this.tangents,t,s),_.TransformNormalToRef(s,e,a),this.tangents[t]=a.x,this.tangents[t+1]=a.y,this.tangents[t+2]=a.z,this.tangents[t+3]=a.w}if(i&&this.indices)for(t=0;t<this.indices.length;t+=3){var h=this.indices[t+1];this.indices[t+1]=this.indices[t+2],this.indices[t+2]=h}return this},e.prototype.merge=function(e,t){if(void 0===t&&(t=!1),this._validate(),e._validate(),!this.normals!=!e.normals||!this.tangents!=!e.tangents||!this.uvs!=!e.uvs||!this.uvs2!=!e.uvs2||!this.uvs3!=!e.uvs3||!this.uvs4!=!e.uvs4||!this.uvs5!=!e.uvs5||!this.uvs6!=!e.uvs6||!this.colors!=!e.colors||!this.matricesIndices!=!e.matricesIndices||!this.matricesWeights!=!e.matricesWeights||!this.matricesIndicesExtra!=!e.matricesIndicesExtra||!this.matricesWeightsExtra!=!e.matricesWeightsExtra)throw new Error("Cannot merge vertex data that do not have the same set of attributes");if(e.indices){this.indices||(this.indices=[]);var i=this.positions?this.positions.length/3:0;if(void 0!==this.indices.BYTES_PER_ELEMENT){var r=this.indices.length+e.indices.length,n=t||this.indices instanceof Uint32Array?new Uint32Array(r):new Uint16Array(r);n.set(this.indices);for(var o=this.indices.length,s=0;s<e.indices.length;s++)n[o+s]=e.indices[s]+i;this.indices=n}else for(s=0;s<e.indices.length;s++)this.indices.push(e.indices[s]+i)}return this.positions=this._mergeElement(this.positions,e.positions),this.normals=this._mergeElement(this.normals,e.normals),this.tangents=this._mergeElement(this.tangents,e.tangents),this.uvs=this._mergeElement(this.uvs,e.uvs),this.uvs2=this._mergeElement(this.uvs2,e.uvs2),this.uvs3=this._mergeElement(this.uvs3,e.uvs3),this.uvs4=this._mergeElement(this.uvs4,e.uvs4),this.uvs5=this._mergeElement(this.uvs5,e.uvs5),this.uvs6=this._mergeElement(this.uvs6,e.uvs6),this.colors=this._mergeElement(this.colors,e.colors),this.matricesIndices=this._mergeElement(this.matricesIndices,e.matricesIndices),this.matricesWeights=this._mergeElement(this.matricesWeights,e.matricesWeights),this.matricesIndicesExtra=this._mergeElement(this.matricesIndicesExtra,e.matricesIndicesExtra),this.matricesWeightsExtra=this._mergeElement(this.matricesWeightsExtra,e.matricesWeightsExtra),this},e.prototype._mergeElement=function(e,t){if(!e)return t;if(!t)return e;var i=t.length+e.length,r=e instanceof Float32Array,n=t instanceof Float32Array;if(r){var o=new Float32Array(i);return o.set(e),o.set(t,e.length),o}if(n){var s=e.slice(0),a=0;for(i=t.length;a<i;a++)s.push(t[a]);return s}return e.concat(t)},e.prototype._validate=function(){if(!this.positions)throw new Error("Positions are required");var e=function(e,t){var i=ft.DeduceStride(e);if(t.length%i!=0)throw new Error("The "+e+"s array count must be a multiple of "+i);return t.length/i},t=e(ft.PositionKind,this.positions),i=function(i,r){var n=e(i,r);if(n!==t)throw new Error("The "+i+"s element count ("+n+") does not match the positions count ("+t+")")};this.normals&&i(ft.NormalKind,this.normals),this.tangents&&i(ft.TangentKind,this.tangents),this.uvs&&i(ft.UVKind,this.uvs),this.uvs2&&i(ft.UV2Kind,this.uvs2),this.uvs3&&i(ft.UV3Kind,this.uvs3),this.uvs4&&i(ft.UV4Kind,this.uvs4),this.uvs5&&i(ft.UV5Kind,this.uvs5),this.uvs6&&i(ft.UV6Kind,this.uvs6),this.colors&&i(ft.ColorKind,this.colors),this.matricesIndices&&i(ft.MatricesIndicesKind,this.matricesIndices),this.matricesWeights&&i(ft.MatricesWeightsKind,this.matricesWeights),this.matricesIndicesExtra&&i(ft.MatricesIndicesExtraKind,this.matricesIndicesExtra),this.matricesWeightsExtra&&i(ft.MatricesWeightsExtraKind,this.matricesWeightsExtra)},e.prototype.serialize=function(){var e=this.serialize();return this.positions&&(e.positions=this.positions),this.normals&&(e.normals=this.normals),this.tangents&&(e.tangents=this.tangents),this.uvs&&(e.uvs=this.uvs),this.uvs2&&(e.uvs2=this.uvs2),this.uvs3&&(e.uvs3=this.uvs3),this.uvs4&&(e.uvs4=this.uvs4),this.uvs5&&(e.uvs5=this.uvs5),this.uvs6&&(e.uvs6=this.uvs6),this.colors&&(e.colors=this.colors),this.matricesIndices&&(e.matricesIndices=this.matricesIndices,e.matricesIndices._isExpanded=!0),this.matricesWeights&&(e.matricesWeights=this.matricesWeights),this.matricesIndicesExtra&&(e.matricesIndicesExtra=this.matricesIndicesExtra,e.matricesIndicesExtra._isExpanded=!0),this.matricesWeightsExtra&&(e.matricesWeightsExtra=this.matricesWeightsExtra),e.indices=this.indices,e},e.ExtractFromMesh=function(t,i,r){return e._ExtractFrom(t,i,r)},e.ExtractFromGeometry=function(t,i,r){return e._ExtractFrom(t,i,r)},e._ExtractFrom=function(t,i,r){var n=new e;return t.isVerticesDataPresent(ft.PositionKind)&&(n.positions=t.getVerticesData(ft.PositionKind,i,r)),t.isVerticesDataPresent(ft.NormalKind)&&(n.normals=t.getVerticesData(ft.NormalKind,i,r)),t.isVerticesDataPresent(ft.TangentKind)&&(n.tangents=t.getVerticesData(ft.TangentKind,i,r)),t.isVerticesDataPresent(ft.UVKind)&&(n.uvs=t.getVerticesData(ft.UVKind,i,r)),t.isVerticesDataPresent(ft.UV2Kind)&&(n.uvs2=t.getVerticesData(ft.UV2Kind,i,r)),t.isVerticesDataPresent(ft.UV3Kind)&&(n.uvs3=t.getVerticesData(ft.UV3Kind,i,r)),t.isVerticesDataPresent(ft.UV4Kind)&&(n.uvs4=t.getVerticesData(ft.UV4Kind,i,r)),t.isVerticesDataPresent(ft.UV5Kind)&&(n.uvs5=t.getVerticesData(ft.UV5Kind,i,r)),t.isVerticesDataPresent(ft.UV6Kind)&&(n.uvs6=t.getVerticesData(ft.UV6Kind,i,r)),t.isVerticesDataPresent(ft.ColorKind)&&(n.colors=t.getVerticesData(ft.ColorKind,i,r)),t.isVerticesDataPresent(ft.MatricesIndicesKind)&&(n.matricesIndices=t.getVerticesData(ft.MatricesIndicesKind,i,r)),t.isVerticesDataPresent(ft.MatricesWeightsKind)&&(n.matricesWeights=t.getVerticesData(ft.MatricesWeightsKind,i,r)),t.isVerticesDataPresent(ft.MatricesIndicesExtraKind)&&(n.matricesIndicesExtra=t.getVerticesData(ft.MatricesIndicesExtraKind,i,r)),t.isVerticesDataPresent(ft.MatricesWeightsExtraKind)&&(n.matricesWeightsExtra=t.getVerticesData(ft.MatricesWeightsExtraKind,i,r)),n.indices=t.getIndices(i,r),n},e.CreateRibbon=function(e){throw b.WarnImport("ribbonBuilder")},e.CreateBox=function(e){throw b.WarnImport("boxBuilder")},e.CreateTiledBox=function(e){throw b.WarnImport("tiledBoxBuilder")},e.CreateTiledPlane=function(e){throw b.WarnImport("tiledPlaneBuilder")},e.CreateSphere=function(e){throw b.WarnImport("sphereBuilder")},e.CreateCylinder=function(e){throw b.WarnImport("cylinderBuilder")},e.CreateTorus=function(e){throw b.WarnImport("torusBuilder")},e.CreateLineSystem=function(e){throw b.WarnImport("linesBuilder")},e.CreateDashedLines=function(e){throw b.WarnImport("linesBuilder")},e.CreateGround=function(e){throw b.WarnImport("groundBuilder")},e.CreateTiledGround=function(e){throw b.WarnImport("groundBuilder")},e.CreateGroundFromHeightMap=function(e){throw b.WarnImport("groundBuilder")},e.CreatePlane=function(e){throw b.WarnImport("planeBuilder")},e.CreateDisc=function(e){throw b.WarnImport("discBuilder")},e.CreatePolygon=function(e,t,i,r,n,o,s){throw b.WarnImport("polygonBuilder")},e.CreateIcoSphere=function(e){throw b.WarnImport("icoSphereBuilder")},e.CreatePolyhedron=function(e){throw b.WarnImport("polyhedronBuilder")},e.CreateCapsule=function(e){throw void 0===e&&(e={orientation:p.Up(),subdivisions:2,tessellation:16,height:1,radius:.25,capSubdivisions:6}),b.WarnImport("capsuleBuilder")},e.CreateTorusKnot=function(e){throw b.WarnImport("torusKnotBuilder")},e.ComputeNormals=function(e,t,i,r){var n=0,o=0,s=0,a=0,h=0,u=0,l=0,c=0,f=0,d=0,_=0,g=0,m=0,v=0,y=0,b=0,T=0,E=0,x=0,A=0,M=!1,P=!1,C=!1,S=!1,I=1,O=0,R=null;if(r&&(M=!!r.facetNormals,P=!!r.facetPositions,C=!!r.facetPartitioning,I=!0===r.useRightHandedSystem?-1:1,O=r.ratio||0,S=!!r.depthSort,R=r.distanceTo,S)){void 0===R&&(R=p.Zero());var D=r.depthSortedFacets}var w=0,L=0,F=0,N=0;if(C&&r&&r.bbSize){var B=0,k=0,U=0,V=0,W=0,z=0,G=0,H=0,X=0,j=0,K=0,Y=0,q=0,Z=0,Q=0,J=0,$=r.bbSize.x>r.bbSize.y?r.bbSize.x:r.bbSize.y;$=$>r.bbSize.z?$:r.bbSize.z,w=r.subDiv.X*O/r.bbSize.x,L=r.subDiv.Y*O/r.bbSize.y,F=r.subDiv.Z*O/r.bbSize.z,N=r.subDiv.max*r.subDiv.max,r.facetPartitioning.length=0}for(n=0;n<e.length;n++)i[n]=0;var ee=t.length/3|0;for(n=0;n<ee;n++){if(m=(g=3*t[3*n])+1,v=g+2,b=(y=3*t[3*n+1])+1,T=y+2,x=(E=3*t[3*n+2])+1,A=E+2,o=e[g]-e[y],s=e[m]-e[b],a=e[v]-e[T],h=e[E]-e[y],u=e[x]-e[b],c=I*(s*(l=e[A]-e[T])-a*u),f=I*(a*h-o*l),d=I*(o*u-s*h),c/=_=0===(_=Math.sqrt(c*c+f*f+d*d))?1:_,f/=_,d/=_,M&&r&&(r.facetNormals[n].x=c,r.facetNormals[n].y=f,r.facetNormals[n].z=d),P&&r&&(r.facetPositions[n].x=(e[g]+e[y]+e[E])/3,r.facetPositions[n].y=(e[m]+e[b]+e[x])/3,r.facetPositions[n].z=(e[v]+e[T]+e[A])/3),C&&r&&(B=Math.floor((r.facetPositions[n].x-r.bInfo.minimum.x*O)*w),k=Math.floor((r.facetPositions[n].y-r.bInfo.minimum.y*O)*L),U=Math.floor((r.facetPositions[n].z-r.bInfo.minimum.z*O)*F),V=Math.floor((e[g]-r.bInfo.minimum.x*O)*w),W=Math.floor((e[m]-r.bInfo.minimum.y*O)*L),z=Math.floor((e[v]-r.bInfo.minimum.z*O)*F),G=Math.floor((e[y]-r.bInfo.minimum.x*O)*w),H=Math.floor((e[b]-r.bInfo.minimum.y*O)*L),X=Math.floor((e[T]-r.bInfo.minimum.z*O)*F),j=Math.floor((e[E]-r.bInfo.minimum.x*O)*w),K=Math.floor((e[x]-r.bInfo.minimum.y*O)*L),Y=Math.floor((e[A]-r.bInfo.minimum.z*O)*F),Z=V+r.subDiv.max*W+N*z,Q=G+r.subDiv.max*H+N*X,J=j+r.subDiv.max*K+N*Y,q=B+r.subDiv.max*k+N*U,r.facetPartitioning[q]=r.facetPartitioning[q]?r.facetPartitioning[q]:new Array,r.facetPartitioning[Z]=r.facetPartitioning[Z]?r.facetPartitioning[Z]:new Array,r.facetPartitioning[Q]=r.facetPartitioning[Q]?r.facetPartitioning[Q]:new Array,r.facetPartitioning[J]=r.facetPartitioning[J]?r.facetPartitioning[J]:new Array,r.facetPartitioning[Z].push(n),Q!=Z&&r.facetPartitioning[Q].push(n),J!=Q&&J!=Z&&r.facetPartitioning[J].push(n),q!=Z&&q!=Q&&q!=J&&r.facetPartitioning[q].push(n)),S&&r&&r.facetPositions){var te=D[n];te.ind=3*n,te.sqDistance=p.DistanceSquared(r.facetPositions[n],R)}i[g]+=c,i[m]+=f,i[v]+=d,i[y]+=c,i[b]+=f,i[T]+=d,i[E]+=c,i[x]+=f,i[A]+=d}for(n=0;n<i.length/3;n++)c=i[3*n],f=i[3*n+1],d=i[3*n+2],c/=_=0===(_=Math.sqrt(c*c+f*f+d*d))?1:_,f/=_,d/=_,i[3*n]=c,i[3*n+1]=f,i[3*n+2]=d},e._ComputeSides=function(t,i,r,n,o,s,a){var h,u,l=r.length,c=n.length;switch(t=t||e.DEFAULTSIDE){case e.FRONTSIDE:break;case e.BACKSIDE:var f;for(h=0;h<l;h+=3)f=r[h],r[h]=r[h+2],r[h+2]=f;for(u=0;u<c;u++)n[u]=-n[u];break;case e.DOUBLESIDE:for(var d=i.length,p=d/3,g=0;g<d;g++)i[d+g]=i[g];for(h=0;h<l;h+=3)r[h+l]=r[h+2]+p,r[h+1+l]=r[h+1]+p,r[h+2+l]=r[h]+p;for(u=0;u<c;u++)n[c+u]=-n[u];var m=o.length,v=0;for(v=0;v<m;v++)o[v+m]=o[v];for(s=s||new _(0,0,1,1),a=a||new _(0,0,1,1),v=0,h=0;h<m/2;h++)o[v]=s.x+(s.z-s.x)*o[v],o[v+1]=s.y+(s.w-s.y)*o[v+1],o[v+m]=a.x+(a.z-a.x)*o[v+m],o[v+m+1]=a.y+(a.w-a.y)*o[v+m+1],v+=2}},e.ImportVertexData=function(t,i){var r=new e,n=t.positions;n&&r.set(n,ft.PositionKind);var o=t.normals;o&&r.set(o,ft.NormalKind);var s=t.tangents;s&&r.set(s,ft.TangentKind);var a=t.uvs;a&&r.set(a,ft.UVKind);var h=t.uv2s;h&&r.set(h,ft.UV2Kind);var u=t.uv3s;u&&r.set(u,ft.UV3Kind);var l=t.uv4s;l&&r.set(l,ft.UV4Kind);var c=t.uv5s;c&&r.set(c,ft.UV5Kind);var f=t.uv6s;f&&r.set(f,ft.UV6Kind);var d=t.colors;d&&r.set(E.CheckColors4(d,n.length/3),ft.ColorKind);var p=t.matricesIndices;p&&r.set(p,ft.MatricesIndicesKind);var _=t.matricesWeights;_&&r.set(_,ft.MatricesWeightsKind);var g=t.indices;g&&(r.indices=g),i.setAllVerticesData(r,t.updatable)},e.FRONTSIDE=0,e.BACKSIDE=1,e.DOUBLESIDE=2,e.DEFAULTSIDE=0,e}(),pt=function(e,t,i){this.bu=e,this.bv=t,this.distance=i,this.faceId=0,this.subMeshId=0},_t=function(){function e(e,t,i){this.vectors=l.BuildArray(8,p.Zero),this.center=p.Zero(),this.centerWorld=p.Zero(),this.extendSize=p.Zero(),this.extendSizeWorld=p.Zero(),this.directions=l.BuildArray(3,p.Zero),this.vectorsWorld=l.BuildArray(8,p.Zero),this.minimumWorld=p.Zero(),this.maximumWorld=p.Zero(),this.minimum=p.Zero(),this.maximum=p.Zero(),this.reConstruct(e,t,i)}return e.prototype.reConstruct=function(e,t,i){var r=e.x,n=e.y,o=e.z,s=t.x,a=t.y,h=t.z,u=this.vectors;this.minimum.copyFromFloats(r,n,o),this.maximum.copyFromFloats(s,a,h),u[0].copyFromFloats(r,n,o),u[1].copyFromFloats(s,a,h),u[2].copyFromFloats(s,n,o),u[3].copyFromFloats(r,a,o),u[4].copyFromFloats(r,n,h),u[5].copyFromFloats(s,a,o),u[6].copyFromFloats(r,a,h),u[7].copyFromFloats(s,n,h),t.addToRef(e,this.center).scaleInPlace(.5),t.subtractToRef(e,this.extendSize).scaleInPlace(.5),this._worldMatrix=i||m.IdentityReadOnly,this._update(this._worldMatrix)},e.prototype.scale=function(t){var i=e.TmpVector3,r=this.maximum.subtractToRef(this.minimum,i[0]),n=r.length();r.normalizeFromLength(n);var o=n*t,s=r.scaleInPlace(.5*o),a=this.center.subtractToRef(s,i[1]),h=this.center.addToRef(s,i[2]);return this.reConstruct(a,h,this._worldMatrix),this},e.prototype.getWorldMatrix=function(){return this._worldMatrix},e.prototype._update=function(e){var t=this.minimumWorld,i=this.maximumWorld,r=this.directions,n=this.vectorsWorld,o=this.vectors;if(e.isIdentity()){t.copyFrom(this.minimum),i.copyFrom(this.maximum);for(s=0;s<8;++s)n[s].copyFrom(o[s]);this.extendSizeWorld.copyFrom(this.extendSize),this.centerWorld.copyFrom(this.center)}else{t.setAll(Number.MAX_VALUE),i.setAll(-Number.MAX_VALUE);for(var s=0;s<8;++s){var a=n[s];p.TransformCoordinatesToRef(o[s],e,a),t.minimizeInPlace(a),i.maximizeInPlace(a)}i.subtractToRef(t,this.extendSizeWorld).scaleInPlace(.5),i.addToRef(t,this.centerWorld).scaleInPlace(.5)}p.FromArrayToRef(e.m,0,r[0]),p.FromArrayToRef(e.m,4,r[1]),p.FromArrayToRef(e.m,8,r[2]),this._worldMatrix=e},e.prototype.isInFrustum=function(t){return e.IsInFrustum(this.vectorsWorld,t)},e.prototype.isCompletelyInFrustum=function(t){return e.IsCompletelyInFrustum(this.vectorsWorld,t)},e.prototype.intersectsPoint=function(e){var t=this.minimumWorld,i=this.maximumWorld,r=t.x,n=t.y,o=t.z,s=i.x,a=i.y,h=i.z,u=e.x,l=e.y,c=e.z,f=-.001;return!(s-u<f||f>u-r)&&(!(a-l<f||f>l-n)&&!(h-c<f||f>c-o))},e.prototype.intersectsSphere=function(t){return e.IntersectsSphere(this.minimumWorld,this.maximumWorld,t.centerWorld,t.radiusWorld)},e.prototype.intersectsMinMax=function(e,t){var i=this.minimumWorld,r=this.maximumWorld,n=i.x,o=i.y,s=i.z,a=r.x,h=r.y,u=r.z,l=e.x,c=e.y,f=e.z,d=t.x,p=t.y,_=t.z;return!(a<l||n>d)&&(!(h<c||o>p)&&!(u<f||s>_))},e.Intersects=function(e,t){return e.intersectsMinMax(t.minimumWorld,t.maximumWorld)},e.IntersectsSphere=function(t,i,r,n){var o=e.TmpVector3[0];return p.ClampToRef(r,t,i,o),p.DistanceSquared(r,o)<=n*n},e.IsCompletelyInFrustum=function(e,t){for(var i=0;i<6;++i)for(var r=t[i],n=0;n<8;++n)if(r.dotCoordinate(e[n])<0)return!1;return!0},e.IsInFrustum=function(e,t){for(var i=0;i<6;++i){for(var r=!0,n=t[i],o=0;o<8;++o)if(n.dotCoordinate(e[o])>=0){r=!1;break}if(r)return!1}return!0},e.TmpVector3=l.BuildArray(3,p.Zero),e}(),gt=function(){function e(e,t,i){this.center=p.Zero(),this.centerWorld=p.Zero(),this.minimum=p.Zero(),this.maximum=p.Zero(),this.reConstruct(e,t,i)}return e.prototype.reConstruct=function(e,t,i){this.minimum.copyFrom(e),this.maximum.copyFrom(t);var r=p.Distance(e,t);t.addToRef(e,this.center).scaleInPlace(.5),this.radius=.5*r,this._update(i||m.IdentityReadOnly)},e.prototype.scale=function(t){var i=this.radius*t,r=e.TmpVector3,n=r[0].setAll(i),o=this.center.subtractToRef(n,r[1]),s=this.center.addToRef(n,r[2]);return this.reConstruct(o,s,this._worldMatrix),this},e.prototype.getWorldMatrix=function(){return this._worldMatrix},e.prototype._update=function(t){if(t.isIdentity())this.centerWorld.copyFrom(this.center),this.radiusWorld=this.radius;else{p.TransformCoordinatesToRef(this.center,t,this.centerWorld);var i=e.TmpVector3[0];p.TransformNormalFromFloatsToRef(1,1,1,t,i),this.radiusWorld=Math.max(Math.abs(i.x),Math.abs(i.y),Math.abs(i.z))*this.radius}},e.prototype.isInFrustum=function(e){for(var t=this.centerWorld,i=this.radiusWorld,r=0;r<6;r++)if(e[r].dotCoordinate(t)<=-i)return!1;return!0},e.prototype.isCenterInFrustum=function(e){for(var t=this.centerWorld,i=0;i<6;i++)if(e[i].dotCoordinate(t)<0)return!1;return!0},e.prototype.intersectsPoint=function(e){var t=p.DistanceSquared(this.centerWorld,e);return!(this.radiusWorld*this.radiusWorld<t)},e.Intersects=function(e,t){var i=p.DistanceSquared(e.centerWorld,t.centerWorld),r=e.radiusWorld+t.radiusWorld;return!(r*r<i)},e.TmpVector3=l.BuildArray(3,p.Zero),e}(),mt={min:0,max:0},vt={min:0,max:0},yt=function(e,t,i){var r=p.Dot(t.centerWorld,e),n=Math.abs(p.Dot(t.directions[0],e))*t.extendSize.x+Math.abs(p.Dot(t.directions[1],e))*t.extendSize.y+Math.abs(p.Dot(t.directions[2],e))*t.extendSize.z;i.min=r-n,i.max=r+n},bt=function(e,t,i){return yt(e,t,mt),yt(e,i,vt),!(mt.min>vt.max||vt.min>mt.max)},Tt=function(){function e(e,t,i){this._isLocked=!1,this.boundingBox=new _t(e,t,i),this.boundingSphere=new gt(e,t,i)}return e.prototype.reConstruct=function(e,t,i){this.boundingBox.reConstruct(e,t,i),this.boundingSphere.reConstruct(e,t,i)},Object.defineProperty(e.prototype,"minimum",{get:function(){return this.boundingBox.minimum},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maximum",{get:function(){return this.boundingBox.maximum},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLocked",{get:function(){return this._isLocked},set:function(e){this._isLocked=e},enumerable:!1,configurable:!0}),e.prototype.update=function(e){this._isLocked||(this.boundingBox._update(e),this.boundingSphere._update(e))},e.prototype.centerOn=function(t,i){var r=e.TmpVector3[0].copyFrom(t).subtractInPlace(i),n=e.TmpVector3[1].copyFrom(t).addInPlace(i);return this.boundingBox.reConstruct(r,n,this.boundingBox.getWorldMatrix()),this.boundingSphere.reConstruct(r,n,this.boundingBox.getWorldMatrix()),this},e.prototype.scale=function(e){return this.boundingBox.scale(e),this.boundingSphere.scale(e),this},e.prototype.isInFrustum=function(e,t){return void 0===t&&(t=0),!(2!==t&&3!==t||!this.boundingSphere.isCenterInFrustum(e))||!!this.boundingSphere.isInFrustum(e)&&(!(1!==t&&3!==t)||this.boundingBox.isInFrustum(e))},Object.defineProperty(e.prototype,"diagonalLength",{get:function(){var t=this.boundingBox;return t.maximumWorld.subtractToRef(t.minimumWorld,e.TmpVector3[0]).length()},enumerable:!1,configurable:!0}),e.prototype.isCompletelyInFrustum=function(e){return this.boundingBox.isCompletelyInFrustum(e)},e.prototype._checkCollision=function(e){return e._canDoCollision(this.boundingSphere.centerWorld,this.boundingSphere.radiusWorld,this.boundingBox.minimumWorld,this.boundingBox.maximumWorld)},e.prototype.intersectsPoint=function(e){return!!this.boundingSphere.centerWorld&&(!!this.boundingSphere.intersectsPoint(e)&&!!this.boundingBox.intersectsPoint(e))},e.prototype.intersects=function(e,t){if(!gt.Intersects(this.boundingSphere,e.boundingSphere))return!1;if(!_t.Intersects(this.boundingBox,e.boundingBox))return!1;if(!t)return!0;var i=this.boundingBox,r=e.boundingBox;return!!bt(i.directions[0],i,r)&&(!!bt(i.directions[1],i,r)&&(!!bt(i.directions[2],i,r)&&(!!bt(r.directions[0],i,r)&&(!!bt(r.directions[1],i,r)&&(!!bt(r.directions[2],i,r)&&(!!bt(p.Cross(i.directions[0],r.directions[0]),i,r)&&(!!bt(p.Cross(i.directions[0],r.directions[1]),i,r)&&(!!bt(p.Cross(i.directions[0],r.directions[2]),i,r)&&(!!bt(p.Cross(i.directions[1],r.directions[0]),i,r)&&(!!bt(p.Cross(i.directions[1],r.directions[1]),i,r)&&(!!bt(p.Cross(i.directions[1],r.directions[2]),i,r)&&(!!bt(p.Cross(i.directions[2],r.directions[0]),i,r)&&(!!bt(p.Cross(i.directions[2],r.directions[1]),i,r)&&!!bt(p.Cross(i.directions[2],r.directions[2]),i,r))))))))))))))},e.TmpVector3=l.BuildArray(2,p.Zero),e}();function Et(e,t,i,r,n){void 0===r&&(r=null);var o=new p(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),s=new p(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);n||(n=3);for(var a=t,h=t*n;a<t+i;a++,h+=n){var u=e[h],l=e[h+1],c=e[h+2];o.minimizeInPlaceFromFloats(u,l,c),s.maximizeInPlaceFromFloats(u,l,c)}return r&&(o.x-=o.x*r.x+r.y,o.y-=o.y*r.x+r.y,o.z-=o.z*r.x+r.y,s.x+=s.x*r.x+r.y,s.y+=s.y*r.x+r.y,s.z+=s.z*r.x+r.y),{minimum:o,maximum:s}}var xt=function(){function e(e,t,i,r,n,o,s,a,h){void 0===a&&(a=!0),void 0===h&&(h=!0),this.materialIndex=e,this.verticesStart=t,this.verticesCount=i,this.indexStart=r,this.indexCount=n,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=o,this._renderingMesh=s||o,h&&o.subMeshes.push(this),this._trianglePlanes=[],this._id=o.subMeshes.length-1,a&&(this.refreshBoundingInfo(),o.computeWorldMatrix(!0))}return Object.defineProperty(e.prototype,"materialDefines",{get:function(){return this._materialDefines},set:function(e){this._materialDefines=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"effect",{get:function(){var e;return null!==(e=this._effectOverride)&&void 0!==e?e:this._materialEffect},enumerable:!1,configurable:!0}),e.prototype.setEffect=function(e,t){void 0===t&&(t=null),this._materialEffect!==e?(this._materialDefines=t,this._materialEffect=e):e||(this._materialDefines=null)},e.AddToMesh=function(t,i,r,n,o,s,a,h){return void 0===h&&(h=!0),new e(t,i,r,n,o,s,a,h)},Object.defineProperty(e.prototype,"IsGlobal",{get:function(){return 0===this.verticesStart&&this.verticesCount===this._mesh.getTotalVertices()},enumerable:!1,configurable:!0}),e.prototype.getBoundingInfo=function(){return this.IsGlobal?this._mesh.getBoundingInfo():this._boundingInfo},e.prototype.setBoundingInfo=function(e){return this._boundingInfo=e,this},e.prototype.getMesh=function(){return this._mesh},e.prototype.getRenderingMesh=function(){return this._renderingMesh},e.prototype.getReplacementMesh=function(){return this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:null},e.prototype.getEffectiveMesh=function(){var e=this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:null;return e||this._renderingMesh},e.prototype.getMaterial=function(){var e=this._renderingMesh.material;if(null==e)return this._mesh.getScene().defaultMaterial;if(this._IsMultiMaterial(e)){var t=e.getSubMaterial(this.materialIndex);return this._currentMaterial!==t&&(this._currentMaterial=t,this._materialDefines=null),t}return e},e.prototype._IsMultiMaterial=function(e){return void 0!==e.getSubMaterial},e.prototype.refreshBoundingInfo=function(e){if(void 0===e&&(e=null),this._lastColliderWorldVertices=null,this.IsGlobal||!this._renderingMesh||!this._renderingMesh.geometry)return this;if(e||(e=this._renderingMesh.getVerticesData(ft.PositionKind)),!e)return this._boundingInfo=this._mesh.getBoundingInfo(),this;var t,i=this._renderingMesh.getIndices();if(0===this.indexStart&&this.indexCount===i.length){var r=this._renderingMesh.getBoundingInfo();t={minimum:r.minimum.clone(),maximum:r.maximum.clone()}}else t=function(e,t,i,r,n){void 0===n&&(n=null);for(var o=new p(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),s=new p(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),a=i;a<i+r;a++){var h=3*t[a],u=e[h],l=e[h+1],c=e[h+2];o.minimizeInPlaceFromFloats(u,l,c),s.maximizeInPlaceFromFloats(u,l,c)}return n&&(o.x-=o.x*n.x+n.y,o.y-=o.y*n.x+n.y,o.z-=o.z*n.x+n.y,s.x+=s.x*n.x+n.y,s.y+=s.y*n.x+n.y,s.z+=s.z*n.x+n.y),{minimum:o,maximum:s}}(e,i,this.indexStart,this.indexCount,this._renderingMesh.geometry.boundingBias);return this._boundingInfo?this._boundingInfo.reConstruct(t.minimum,t.maximum):this._boundingInfo=new Tt(t.minimum,t.maximum),this},e.prototype._checkCollision=function(e){return this.getBoundingInfo()._checkCollision(e)},e.prototype.updateBoundingInfo=function(e){var t=this.getBoundingInfo();return t||(this.refreshBoundingInfo(),t=this.getBoundingInfo()),t&&t.update(e),this},e.prototype.isInFrustum=function(e){var t=this.getBoundingInfo();return!!t&&t.isInFrustum(e,this._mesh.cullingStrategy)},e.prototype.isCompletelyInFrustum=function(e){var t=this.getBoundingInfo();return!!t&&t.isCompletelyInFrustum(e)},e.prototype.render=function(e){return this._renderingMesh.render(this,e,this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:void 0),this},e.prototype._getLinesIndexBuffer=function(e,t){if(!this._linesIndexBuffer){for(var i=[],r=this.indexStart;r<this.indexStart+this.indexCount;r+=3)i.push(e[r],e[r+1],e[r+1],e[r+2],e[r+2],e[r]);this._linesIndexBuffer=t.createIndexBuffer(i),this._linesIndexCount=i.length}return this._linesIndexBuffer},e.prototype.canIntersects=function(e){var t=this.getBoundingInfo();return!!t&&e.intersectsBox(t.boundingBox)},e.prototype.intersects=function(e,t,i,r,n){var o=this.getMaterial();if(!o)return null;var s=3,a=!1;switch(o.fillMode){case 3:case 4:case 5:case 6:case 8:return null;case 7:s=1,a=!0}return"InstancedLinesMesh"===this._mesh.getClassName()||"LinesMesh"===this._mesh.getClassName()?i.length?this._intersectLines(e,t,i,this._mesh.intersectionThreshold,r):this._intersectUnIndexedLines(e,t,i,this._mesh.intersectionThreshold,r):!i.length&&this._mesh._unIndexed?this._intersectUnIndexedTriangles(e,t,i,r,n):this._intersectTriangles(e,t,i,s,a,r,n)},e.prototype._intersectLines=function(e,t,i,r,n){for(var o=null,s=this.indexStart;s<this.indexStart+this.indexCount;s+=2){var a=t[i[s]],h=t[i[s+1]],u=e.intersectionSegment(a,h,r);if(!(u<0)&&((n||!o||u<o.distance)&&((o=new pt(null,null,u)).faceId=s/2,n)))break}return o},e.prototype._intersectUnIndexedLines=function(e,t,i,r,n){for(var o=null,s=this.verticesStart;s<this.verticesStart+this.verticesCount;s+=2){var a=t[s],h=t[s+1],u=e.intersectionSegment(a,h,r);if(!(u<0)&&((n||!o||u<o.distance)&&((o=new pt(null,null,u)).faceId=s/2,n)))break}return o},e.prototype._intersectTriangles=function(e,t,i,r,n,o,s){for(var a=null,h=-1,u=this.indexStart;u<this.indexStart+this.indexCount;u+=r){h++;var l=i[u],c=i[u+1],f=i[u+2];if(n&&4294967295===f)u+=2;else{var d=t[l],p=t[c],_=t[f];if(!s||s(d,p,_,e)){var g=e.intersectsTriangle(d,p,_);if(g){if(g.distance<0)continue;if((o||!a||g.distance<a.distance)&&((a=g).faceId=h,o))break}}}}return a},e.prototype._intersectUnIndexedTriangles=function(e,t,i,r,n){for(var o=null,s=this.verticesStart;s<this.verticesStart+this.verticesCount;s+=3){var a=t[s],h=t[s+1],u=t[s+2];if(!n||n(a,h,u,e)){var l=e.intersectsTriangle(a,h,u);if(l){if(l.distance<0)continue;if((r||!o||l.distance<o.distance)&&((o=l).faceId=s/3,r))break}}}return o},e.prototype._rebuild=function(){this._linesIndexBuffer&&(this._linesIndexBuffer=null)},e.prototype.clone=function(t,i){var r=new e(this.materialIndex,this.verticesStart,this.verticesCount,this.indexStart,this.indexCount,t,i,!1);if(!this.IsGlobal){var n=this.getBoundingInfo();if(!n)return r;r._boundingInfo=new Tt(n.minimum,n.maximum)}return r},e.prototype.dispose=function(){this._linesIndexBuffer&&(this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer),this._linesIndexBuffer=null);var e=this._mesh.subMeshes.indexOf(this);this._mesh.subMeshes.splice(e,1)},e.prototype.getClassName=function(){return"SubMesh"},e.CreateFromIndices=function(t,i,r,n,o){for(var s=Number.MAX_VALUE,a=-Number.MAX_VALUE,h=(o||n).getIndices(),u=i;u<i+r;u++){var l=h[u];l<s&&(s=l),l>a&&(a=l)}return new e(t,s,a-s+1,i,r,n,o)},e}(),At=function(){function e(){}return Object.defineProperty(e,"ForceFullSceneLoadingForIncremental",{get:function(){return e._ForceFullSceneLoadingForIncremental},set:function(t){e._ForceFullSceneLoadingForIncremental=t},enumerable:!1,configurable:!0}),Object.defineProperty(e,"ShowLoadingScreen",{get:function(){return e._ShowLoadingScreen},set:function(t){e._ShowLoadingScreen=t},enumerable:!1,configurable:!0}),Object.defineProperty(e,"loggingLevel",{get:function(){return e._loggingLevel},set:function(t){e._loggingLevel=t},enumerable:!1,configurable:!0}),Object.defineProperty(e,"CleanBoneMatrixWeights",{get:function(){return e._CleanBoneMatrixWeights},set:function(t){e._CleanBoneMatrixWeights=t},enumerable:!1,configurable:!0}),e._ForceFullSceneLoadingForIncremental=!1,e._ShowLoadingScreen=!0,e._CleanBoneMatrixWeights=!1,e._loggingLevel=0,e}(),Mt=function(){function e(e,t,i,r,n){void 0===r&&(r=!1),void 0===n&&(n=null),this.delayLoadState=0,this._totalVertices=0,this._isDisposed=!1,this._indexBufferIsUpdatable=!1,this._positionsCache=[],this.useBoundingInfoFromGeometry=!1,this.id=e,this.uniqueId=t.getUniqueId(),this._engine=t.getEngine(),this._meshes=[],this._scene=t,this._vertexBuffers={},this._indices=[],this._updatable=r,i?this.setAllVerticesData(i,r):(this._totalVertices=0,this._indices=[]),this._engine.getCaps().vertexArrayObject&&(this._vertexArrayObjects={}),n&&(this.applyToMesh(n),n.computeWorldMatrix(!0))}return Object.defineProperty(e.prototype,"boundingBias",{get:function(){return this._boundingBias},set:function(e){this._boundingBias?this._boundingBias.copyFrom(e):this._boundingBias=e.clone(),this._updateBoundingInfo(!0,null)},enumerable:!1,configurable:!0}),e.CreateGeometryForMesh=function(t){var i=new e(e.RandomId(),t.getScene());return i.applyToMesh(t),i},Object.defineProperty(e.prototype,"meshes",{get:function(){return this._meshes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"extend",{get:function(){return this._extend},enumerable:!1,configurable:!0}),e.prototype.getScene=function(){return this._scene},e.prototype.getEngine=function(){return this._engine},e.prototype.isReady=function(){return 1===this.delayLoadState||0===this.delayLoadState},Object.defineProperty(e.prototype,"doNotSerialize",{get:function(){for(var e=0;e<this._meshes.length;e++)if(!this._meshes[e].doNotSerialize)return!1;return!0},enumerable:!1,configurable:!0}),e.prototype._rebuild=function(){for(var e in this._vertexArrayObjects&&(this._vertexArrayObjects={}),0!==this._meshes.length&&this._indices&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices)),this._vertexBuffers){this._vertexBuffers[e]._rebuild()}},e.prototype.setAllVerticesData=function(e,t){e.applyToGeometry(this,t),this.notifyUpdate()},e.prototype.setVerticesData=function(e,t,i,r){void 0===i&&(i=!1),i&&Array.isArray(t)&&(t=new Float32Array(t));var n=new ft(this._engine,t,e,i,0===this._meshes.length,r);this.setVerticesBuffer(n)},e.prototype.removeVerticesData=function(e){this._vertexBuffers[e]&&(this._vertexBuffers[e].dispose(),delete this._vertexBuffers[e])},e.prototype.setVerticesBuffer=function(e,t){void 0===t&&(t=null);var i=e.getKind();if(this._vertexBuffers[i]&&this._vertexBuffers[i].dispose(),this._vertexBuffers[i]=e,i===ft.PositionKind){var r=e.getData();null!=t?this._totalVertices=t:null!=r&&(this._totalVertices=r.length/(e.byteStride/4)),this._updateExtend(r),this._resetPointsArrayCache();for(var n=this._meshes,o=n.length,s=0;s<o;s++){var a=n[s];a._boundingInfo=new Tt(this._extend.minimum,this._extend.maximum),a._createGlobalSubMesh(!1),a.computeWorldMatrix(!0)}}this.notifyUpdate(i),this._vertexArrayObjects&&(this._disposeVertexArrayObjects(),this._vertexArrayObjects={})},e.prototype.updateVerticesDataDirectly=function(e,t,i,r){void 0===r&&(r=!1);var n=this.getVertexBuffer(e);n&&(n.updateDirectly(t,i,r),this.notifyUpdate(e))},e.prototype.updateVerticesData=function(e,t,i){void 0===i&&(i=!1);var r=this.getVertexBuffer(e);r&&(r.update(t),e===ft.PositionKind&&this._updateBoundingInfo(i,t),this.notifyUpdate(e))},e.prototype._updateBoundingInfo=function(e,t){if(e&&this._updateExtend(t),this._resetPointsArrayCache(),e)for(var i=0,r=this._meshes;i<r.length;i++){var n=r[i];n._boundingInfo?n._boundingInfo.reConstruct(this._extend.minimum,this._extend.maximum):n._boundingInfo=new Tt(this._extend.minimum,this._extend.maximum);for(var o=0,s=n.subMeshes;o<s.length;o++){s[o].refreshBoundingInfo()}}},e.prototype._bind=function(e,t){if(e){void 0===t&&(t=this._indexBuffer);var i=this.getVertexBuffers();i&&(t==this._indexBuffer&&this._vertexArrayObjects?(this._vertexArrayObjects[e.key]||(this._vertexArrayObjects[e.key]=this._engine.recordVertexArrayObject(i,t,e)),this._engine.bindVertexArrayObject(this._vertexArrayObjects[e.key],t)):this._engine.bindBuffers(i,t,e))}},e.prototype.getTotalVertices=function(){return this.isReady()?this._totalVertices:0},e.prototype.getVerticesData=function(e,t,i){var r=this.getVertexBuffer(e);if(!r)return null;var n=r.getData();if(!n)return null;var o=r.getSize()*ft.GetTypeByteLength(r.type),s=this._totalVertices*r.getSize();if(r.type!==ft.FLOAT||r.byteStride!==o){var a=[];return r.forEach(s,(function(e){return a.push(e)})),a}if(!(n instanceof Array||n instanceof Float32Array)||0!==r.byteOffset||n.length!==s){if(n instanceof Array){var h=r.byteOffset/4;return Ue.Slice(n,h,h+s)}if(n instanceof ArrayBuffer)return new Float32Array(n,r.byteOffset,s);h=n.byteOffset+r.byteOffset;if(i||t&&1!==this._meshes.length){var u=new Float32Array(s),l=new Float32Array(n.buffer,h,s);return u.set(l),u}var c=h%4;return c&&(h=Math.max(0,h-c)),new Float32Array(n.buffer,h,s)}return i||t&&1!==this._meshes.length?Ue.Slice(n):n},e.prototype.isVertexBufferUpdatable=function(e){var t=this._vertexBuffers[e];return!!t&&t.isUpdatable()},e.prototype.getVertexBuffer=function(e){return this.isReady()?this._vertexBuffers[e]:null},e.prototype.getVertexBuffers=function(){return this.isReady()?this._vertexBuffers:null},e.prototype.isVerticesDataPresent=function(e){return this._vertexBuffers?void 0!==this._vertexBuffers[e]:!!this._delayInfo&&-1!==this._delayInfo.indexOf(e)},e.prototype.getVerticesDataKinds=function(){var e,t=[];if(!this._vertexBuffers&&this._delayInfo)for(e in this._delayInfo)t.push(e);else for(e in this._vertexBuffers)t.push(e);return t},e.prototype.updateIndices=function(e,t,i){if(void 0===i&&(i=!1),this._indexBuffer)if(this._indexBufferIsUpdatable){var r=e.length!==this._indices.length;if(i||(this._indices=e.slice()),this._engine.updateDynamicIndexBuffer(this._indexBuffer,e,t),r)for(var n=0,o=this._meshes;n<o.length;n++){o[n]._createGlobalSubMesh(!0)}}else this.setIndices(e,null,!0)},e.prototype.setIndices=function(e,t,i){void 0===t&&(t=null),void 0===i&&(i=!1),this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer),this._disposeVertexArrayObjects(),this._indices=e,this._indexBufferIsUpdatable=i,0!==this._meshes.length&&this._indices&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices,i)),null!=t&&(this._totalVertices=t);for(var r=0,n=this._meshes;r<n.length;r++){n[r]._createGlobalSubMesh(!0)}this.notifyUpdate()},e.prototype.getTotalIndices=function(){return this.isReady()?this._indices.length:0},e.prototype.getIndices=function(e,t){if(!this.isReady())return null;var i=this._indices;if(t||e&&1!==this._meshes.length){for(var r=i.length,n=[],o=0;o<r;o++)n.push(i[o]);return n}return i},e.prototype.getIndexBuffer=function(){return this.isReady()?this._indexBuffer:null},e.prototype._releaseVertexArrayObject=function(e){void 0===e&&(e=null),e&&this._vertexArrayObjects&&this._vertexArrayObjects[e.key]&&(this._engine.releaseVertexArrayObject(this._vertexArrayObjects[e.key]),delete this._vertexArrayObjects[e.key])},e.prototype.releaseForMesh=function(e,t){var i=this._meshes,r=i.indexOf(e);-1!==r&&(i.splice(r,1),e._geometry=null,0===i.length&&t&&this.dispose())},e.prototype.applyToMesh=function(e){if(e._geometry!==this){var t=e._geometry;t&&t.releaseForMesh(e);var i=this._meshes;e._geometry=this,this._scene.pushGeometry(this),i.push(e),this.isReady()?this._applyToMesh(e):e._boundingInfo=this._boundingInfo}},e.prototype._updateExtend=function(e){void 0===e&&(e=null),this.useBoundingInfoFromGeometry&&this._boundingInfo?this._extend={minimum:this._boundingInfo.minimum.clone(),maximum:this._boundingInfo.maximum.clone()}:(e||(e=this.getVerticesData(ft.PositionKind)),this._extend=Et(e,0,this._totalVertices,this.boundingBias,3))},e.prototype._applyToMesh=function(e){var t=this._meshes.length;for(var i in this._vertexBuffers){1===t&&this._vertexBuffers[i].create();var r=this._vertexBuffers[i].getBuffer();r&&(r.references=t),i===ft.PositionKind&&(this._extend||this._updateExtend(),e._boundingInfo=new Tt(this._extend.minimum,this._extend.maximum),e._createGlobalSubMesh(!1),e._updateBoundingInfo())}1===t&&this._indices&&this._indices.length>0&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices)),this._indexBuffer&&(this._indexBuffer.references=t),e._syncGeometryWithMorphTargetManager(),e.synchronizeInstances()},e.prototype.notifyUpdate=function(e){this.onGeometryUpdated&&this.onGeometryUpdated(this,e);for(var t=0,i=this._meshes;t<i.length;t++){i[t]._markSubMeshesAsAttributesDirty()}},e.prototype.load=function(e,t){2!==this.delayLoadState&&(this.isReady()?t&&t():(this.delayLoadState=2,this._queueLoad(e,t)))},e.prototype._queueLoad=function(e,t){var i=this;this.delayLoadingFile&&(e._addPendingData(this),e._loadFile(this.delayLoadingFile,(function(r){if(i._delayLoadingFunction){i._delayLoadingFunction(JSON.parse(r),i),i.delayLoadState=1,i._delayInfo=[],e._removePendingData(i);for(var n=i._meshes,o=n.length,s=0;s<o;s++)i._applyToMesh(n[s]);t&&t()}}),void 0,!0))},e.prototype.toLeftHanded=function(){var e=this.getIndices(!1);if(null!=e&&e.length>0){for(var t=0;t<e.length;t+=3){var i=e[t+0];e[t+0]=e[t+2],e[t+2]=i}this.setIndices(e)}var r=this.getVerticesData(ft.PositionKind,!1);if(null!=r&&r.length>0){for(t=0;t<r.length;t+=3)r[t+2]=-r[t+2];this.setVerticesData(ft.PositionKind,r,!1)}var n=this.getVerticesData(ft.NormalKind,!1);if(null!=n&&n.length>0){for(t=0;t<n.length;t+=3)n[t+2]=-n[t+2];this.setVerticesData(ft.NormalKind,n,!1)}},e.prototype._resetPointsArrayCache=function(){this._positions=null},e.prototype._generatePointsArray=function(){if(this._positions)return!0;var e=this.getVerticesData(ft.PositionKind);if(!e||0===e.length)return!1;for(var t=3*this._positionsCache.length,i=this._positionsCache.length;t<e.length;t+=3,++i)this._positionsCache[i]=p.FromArray(e,t);for(t=0,i=0;t<e.length;t+=3,++i)this._positionsCache[i].set(e[0+t],e[1+t],e[2+t]);return this._positionsCache.length=e.length/3,this._positions=this._positionsCache,!0},e.prototype.isDisposed=function(){return this._isDisposed},e.prototype._disposeVertexArrayObjects=function(){if(this._vertexArrayObjects){for(var e in this._vertexArrayObjects)this._engine.releaseVertexArrayObject(this._vertexArrayObjects[e]);this._vertexArrayObjects={}}},e.prototype.dispose=function(){var e,t=this._meshes,i=t.length;for(e=0;e<i;e++)this.releaseForMesh(t[e]);for(var r in this._meshes=[],this._disposeVertexArrayObjects(),this._vertexBuffers)this._vertexBuffers[r].dispose();this._vertexBuffers={},this._totalVertices=0,this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer),this._indexBuffer=null,this._indices=[],this.delayLoadState=0,this.delayLoadingFile=null,this._delayLoadingFunction=null,this._delayInfo=[],this._boundingInfo=null,this._scene.removeGeometry(this),this._isDisposed=!0},e.prototype.copy=function(t){var i=new dt;i.indices=[];var r=this.getIndices();if(r)for(var n=0;n<r.length;n++)i.indices.push(r[n]);var o,s=!1,a=!1;for(o in this._vertexBuffers){var h=this.getVerticesData(o);if(h&&(h instanceof Float32Array?i.set(new Float32Array(h),o):i.set(h.slice(0),o),!a)){var u=this.getVertexBuffer(o);u&&(a=!(s=u.isUpdatable()))}}var l=new e(t,this._scene,i,s);for(o in l.delayLoadState=this.delayLoadState,l.delayLoadingFile=this.delayLoadingFile,l._delayLoadingFunction=this._delayLoadingFunction,this._delayInfo)l._delayInfo=l._delayInfo||[],l._delayInfo.push(o);return l._boundingInfo=new Tt(this._extend.minimum,this._extend.maximum),l},e.prototype.serialize=function(){var e={};return e.id=this.id,e.updatable=this._updatable,o&&o.HasTags(this)&&(e.tags=o.GetTags(this)),e},e.prototype.toNumberArray=function(e){return Array.isArray(e)?e:Array.prototype.slice.call(e)},e.prototype.serializeVerticeData=function(){var e=this.serialize();return this.isVerticesDataPresent(ft.PositionKind)&&(e.positions=this.toNumberArray(this.getVerticesData(ft.PositionKind)),this.isVertexBufferUpdatable(ft.PositionKind)&&(e.positions._updatable=!0)),this.isVerticesDataPresent(ft.NormalKind)&&(e.normals=this.toNumberArray(this.getVerticesData(ft.NormalKind)),this.isVertexBufferUpdatable(ft.NormalKind)&&(e.normals._updatable=!0)),this.isVerticesDataPresent(ft.TangentKind)&&(e.tangets=this.toNumberArray(this.getVerticesData(ft.TangentKind)),this.isVertexBufferUpdatable(ft.TangentKind)&&(e.tangets._updatable=!0)),this.isVerticesDataPresent(ft.UVKind)&&(e.uvs=this.toNumberArray(this.getVerticesData(ft.UVKind)),this.isVertexBufferUpdatable(ft.UVKind)&&(e.uvs._updatable=!0)),this.isVerticesDataPresent(ft.UV2Kind)&&(e.uv2s=this.toNumberArray(this.getVerticesData(ft.UV2Kind)),this.isVertexBufferUpdatable(ft.UV2Kind)&&(e.uv2s._updatable=!0)),this.isVerticesDataPresent(ft.UV3Kind)&&(e.uv3s=this.toNumberArray(this.getVerticesData(ft.UV3Kind)),this.isVertexBufferUpdatable(ft.UV3Kind)&&(e.uv3s._updatable=!0)),this.isVerticesDataPresent(ft.UV4Kind)&&(e.uv4s=this.toNumberArray(this.getVerticesData(ft.UV4Kind)),this.isVertexBufferUpdatable(ft.UV4Kind)&&(e.uv4s._updatable=!0)),this.isVerticesDataPresent(ft.UV5Kind)&&(e.uv5s=this.toNumberArray(this.getVerticesData(ft.UV5Kind)),this.isVertexBufferUpdatable(ft.UV5Kind)&&(e.uv5s._updatable=!0)),this.isVerticesDataPresent(ft.UV6Kind)&&(e.uv6s=this.toNumberArray(this.getVerticesData(ft.UV6Kind)),this.isVertexBufferUpdatable(ft.UV6Kind)&&(e.uv6s._updatable=!0)),this.isVerticesDataPresent(ft.ColorKind)&&(e.colors=this.toNumberArray(this.getVerticesData(ft.ColorKind)),this.isVertexBufferUpdatable(ft.ColorKind)&&(e.colors._updatable=!0)),this.isVerticesDataPresent(ft.MatricesIndicesKind)&&(e.matricesIndices=this.toNumberArray(this.getVerticesData(ft.MatricesIndicesKind)),e.matricesIndices._isExpanded=!0,this.isVertexBufferUpdatable(ft.MatricesIndicesKind)&&(e.matricesIndices._updatable=!0)),this.isVerticesDataPresent(ft.MatricesWeightsKind)&&(e.matricesWeights=this.toNumberArray(this.getVerticesData(ft.MatricesWeightsKind)),this.isVertexBufferUpdatable(ft.MatricesWeightsKind)&&(e.matricesWeights._updatable=!0)),e.indices=this.toNumberArray(this.getIndices()),e},e.ExtractFromMesh=function(e,t){var i=e._geometry;return i?i.copy(t):null},e.RandomId=function(){return Ue.RandomId()},e._ImportGeometry=function(t,i){var r=i.getScene(),n=t.geometryId;if(n){var o=r.getGeometryByID(n);o&&o.applyToMesh(i)}else if(t instanceof ArrayBuffer){var s=i._binaryInfo;if(s.positionsAttrDesc&&s.positionsAttrDesc.count>0){var a=new Float32Array(t,s.positionsAttrDesc.offset,s.positionsAttrDesc.count);i.setVerticesData(ft.PositionKind,a,!1)}if(s.normalsAttrDesc&&s.normalsAttrDesc.count>0){var h=new Float32Array(t,s.normalsAttrDesc.offset,s.normalsAttrDesc.count);i.setVerticesData(ft.NormalKind,h,!1)}if(s.tangetsAttrDesc&&s.tangetsAttrDesc.count>0){var u=new Float32Array(t,s.tangetsAttrDesc.offset,s.tangetsAttrDesc.count);i.setVerticesData(ft.TangentKind,u,!1)}if(s.uvsAttrDesc&&s.uvsAttrDesc.count>0){var l=new Float32Array(t,s.uvsAttrDesc.offset,s.uvsAttrDesc.count);i.setVerticesData(ft.UVKind,l,!1)}if(s.uvs2AttrDesc&&s.uvs2AttrDesc.count>0){var c=new Float32Array(t,s.uvs2AttrDesc.offset,s.uvs2AttrDesc.count);i.setVerticesData(ft.UV2Kind,c,!1)}if(s.uvs3AttrDesc&&s.uvs3AttrDesc.count>0){var f=new Float32Array(t,s.uvs3AttrDesc.offset,s.uvs3AttrDesc.count);i.setVerticesData(ft.UV3Kind,f,!1)}if(s.uvs4AttrDesc&&s.uvs4AttrDesc.count>0){var d=new Float32Array(t,s.uvs4AttrDesc.offset,s.uvs4AttrDesc.count);i.setVerticesData(ft.UV4Kind,d,!1)}if(s.uvs5AttrDesc&&s.uvs5AttrDesc.count>0){var p=new Float32Array(t,s.uvs5AttrDesc.offset,s.uvs5AttrDesc.count);i.setVerticesData(ft.UV5Kind,p,!1)}if(s.uvs6AttrDesc&&s.uvs6AttrDesc.count>0){var _=new Float32Array(t,s.uvs6AttrDesc.offset,s.uvs6AttrDesc.count);i.setVerticesData(ft.UV6Kind,_,!1)}if(s.colorsAttrDesc&&s.colorsAttrDesc.count>0){var g=new Float32Array(t,s.colorsAttrDesc.offset,s.colorsAttrDesc.count);i.setVerticesData(ft.ColorKind,g,!1,s.colorsAttrDesc.stride)}if(s.matricesIndicesAttrDesc&&s.matricesIndicesAttrDesc.count>0){for(var m=new Int32Array(t,s.matricesIndicesAttrDesc.offset,s.matricesIndicesAttrDesc.count),v=[],y=0;y<m.length;y++){var b=m[y];v.push(255&b),v.push((65280&b)>>8),v.push((16711680&b)>>16),v.push(b>>24&255)}i.setVerticesData(ft.MatricesIndicesKind,v,!1)}if(s.matricesIndicesExtraAttrDesc&&s.matricesIndicesExtraAttrDesc.count>0){for(m=new Int32Array(t,s.matricesIndicesExtraAttrDesc.offset,s.matricesIndicesExtraAttrDesc.count),v=[],y=0;y<m.length;y++){b=m[y];v.push(255&b),v.push((65280&b)>>8),v.push((16711680&b)>>16),v.push(b>>24&255)}i.setVerticesData(ft.MatricesIndicesExtraKind,v,!1)}if(s.matricesWeightsAttrDesc&&s.matricesWeightsAttrDesc.count>0){var T=new Float32Array(t,s.matricesWeightsAttrDesc.offset,s.matricesWeightsAttrDesc.count);i.setVerticesData(ft.MatricesWeightsKind,T,!1)}if(s.indicesAttrDesc&&s.indicesAttrDesc.count>0){var x=new Int32Array(t,s.indicesAttrDesc.offset,s.indicesAttrDesc.count);i.setIndices(x,null)}if(s.subMeshesAttrDesc&&s.subMeshesAttrDesc.count>0){var A=new Int32Array(t,s.subMeshesAttrDesc.offset,5*s.subMeshesAttrDesc.count);i.subMeshes=[];for(y=0;y<s.subMeshesAttrDesc.count;y++){var M=A[5*y+0],P=A[5*y+1],C=A[5*y+2],S=A[5*y+3],I=A[5*y+4];xt.AddToMesh(M,P,C,S,I,i)}}}else if(t.positions&&t.normals&&t.indices){if(i.setVerticesData(ft.PositionKind,t.positions,t.positions._updatable),i.setVerticesData(ft.NormalKind,t.normals,t.normals._updatable),t.tangents&&i.setVerticesData(ft.TangentKind,t.tangents,t.tangents._updatable),t.uvs&&i.setVerticesData(ft.UVKind,t.uvs,t.uvs._updatable),t.uvs2&&i.setVerticesData(ft.UV2Kind,t.uvs2,t.uvs2._updatable),t.uvs3&&i.setVerticesData(ft.UV3Kind,t.uvs3,t.uvs3._updatable),t.uvs4&&i.setVerticesData(ft.UV4Kind,t.uvs4,t.uvs4._updatable),t.uvs5&&i.setVerticesData(ft.UV5Kind,t.uvs5,t.uvs5._updatable),t.uvs6&&i.setVerticesData(ft.UV6Kind,t.uvs6,t.uvs6._updatable),t.colors&&i.setVerticesData(ft.ColorKind,E.CheckColors4(t.colors,t.positions.length/3),t.colors._updatable),t.matricesIndices)if(t.matricesIndices._isExpanded)delete t.matricesIndices._isExpanded,i.setVerticesData(ft.MatricesIndicesKind,t.matricesIndices,t.matricesIndices._updatable);else{for(v=[],y=0;y<t.matricesIndices.length;y++){var O=t.matricesIndices[y];v.push(255&O),v.push((65280&O)>>8),v.push((16711680&O)>>16),v.push(O>>24&255)}i.setVerticesData(ft.MatricesIndicesKind,v,t.matricesIndices._updatable)}if(t.matricesIndicesExtra)if(t.matricesIndicesExtra._isExpanded)delete t.matricesIndices._isExpanded,i.setVerticesData(ft.MatricesIndicesExtraKind,t.matricesIndicesExtra,t.matricesIndicesExtra._updatable);else{for(v=[],y=0;y<t.matricesIndicesExtra.length;y++){O=t.matricesIndicesExtra[y];v.push(255&O),v.push((65280&O)>>8),v.push((16711680&O)>>16),v.push(O>>24&255)}i.setVerticesData(ft.MatricesIndicesExtraKind,v,t.matricesIndicesExtra._updatable)}t.matricesWeights&&(e._CleanMatricesWeights(t,i),i.setVerticesData(ft.MatricesWeightsKind,t.matricesWeights,t.matricesWeights._updatable)),t.matricesWeightsExtra&&i.setVerticesData(ft.MatricesWeightsExtraKind,t.matricesWeightsExtra,t.matricesWeights._updatable),i.setIndices(t.indices,null)}if(t.subMeshes){i.subMeshes=[];for(var R=0;R<t.subMeshes.length;R++){var D=t.subMeshes[R];xt.AddToMesh(D.materialIndex,D.verticesStart,D.verticesCount,D.indexStart,D.indexCount,i)}}i._shouldGenerateFlatShading&&(i.convertToFlatShadedMesh(),i._shouldGenerateFlatShading=!1),i.computeWorldMatrix(!0),r.onMeshImportedObservable.notifyObservers(i)},e._CleanMatricesWeights=function(e,t){var i=.001;if(At.CleanBoneMatrixWeights){var r=0;if(e.skeletonId>-1){var n=t.getScene().getLastSkeletonByID(e.skeletonId);if(n){r=n.bones.length;for(var o=t.getVerticesData(ft.MatricesIndicesKind),s=t.getVerticesData(ft.MatricesIndicesExtraKind),a=e.matricesWeights,h=e.matricesWeightsExtra,u=e.numBoneInfluencer,l=a.length,c=0;c<l;c+=4){for(var f=0,d=-1,p=0;p<4;p++){f+=_=a[c+p],_<i&&d<0&&(d=p)}if(h)for(p=0;p<4;p++){var _;f+=_=h[c+p],_<i&&d<0&&(d=p+4)}if((d<0||d>u-1)&&(d=u-1),f>i){var g=1/f;for(p=0;p<4;p++)a[c+p]*=g;if(h)for(p=0;p<4;p++)h[c+p]*=g}else d>=4?(h[c+d-4]=1-f,s[c+d-4]=r):(a[c+d]=1-f,o[c+d]=r)}t.setVerticesData(ft.MatricesIndicesKind,o),e.matricesWeightsExtra&&t.setVerticesData(ft.MatricesIndicesExtraKind,s)}}}},e.Parse=function(t,i,r){if(i.getGeometryByID(t.id))return null;var n=new e(t.id,i,void 0,t.updatable);return o&&o.AddTagsTo(n,t.tags),t.delayLoadingFile?(n.delayLoadState=4,n.delayLoadingFile=r+t.delayLoadingFile,n._boundingInfo=new Tt(p.FromArray(t.boundingBoxMinimum),p.FromArray(t.boundingBoxMaximum)),n._delayInfo=[],t.hasUVs&&n._delayInfo.push(ft.UVKind),t.hasUVs2&&n._delayInfo.push(ft.UV2Kind),t.hasUVs3&&n._delayInfo.push(ft.UV3Kind),t.hasUVs4&&n._delayInfo.push(ft.UV4Kind),t.hasUVs5&&n._delayInfo.push(ft.UV5Kind),t.hasUVs6&&n._delayInfo.push(ft.UV6Kind),t.hasColors&&n._delayInfo.push(ft.ColorKind),t.hasMatricesIndices&&n._delayInfo.push(ft.MatricesIndicesKind),t.hasMatricesWeights&&n._delayInfo.push(ft.MatricesWeightsKind),n._delayLoadingFunction=dt.ImportVertexData):dt.ImportVertexData(t,n),i.pushGeometry(n,!0),n},e}(),Pt=function(){function e(e){void 0===e&&(e=30),this._enabled=!0,this._rollingFrameTime=new Ct(e)}return e.prototype.sampleFrame=function(e){if(void 0===e&&(e=Fe.Now),this._enabled){if(null!=this._lastFrameTimeMs){var t=e-this._lastFrameTimeMs;this._rollingFrameTime.add(t)}this._lastFrameTimeMs=e}},Object.defineProperty(e.prototype,"averageFrameTime",{get:function(){return this._rollingFrameTime.average},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"averageFrameTimeVariance",{get:function(){return this._rollingFrameTime.variance},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"instantaneousFrameTime",{get:function(){return this._rollingFrameTime.history(0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"averageFPS",{get:function(){return 1e3/this._rollingFrameTime.average},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"instantaneousFPS",{get:function(){var e=this._rollingFrameTime.history(0);return 0===e?0:1e3/e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isSaturated",{get:function(){return this._rollingFrameTime.isSaturated()},enumerable:!1,configurable:!0}),e.prototype.enable=function(){this._enabled=!0},e.prototype.disable=function(){this._enabled=!1,this._lastFrameTimeMs=null},Object.defineProperty(e.prototype,"isEnabled",{get:function(){return this._enabled},enumerable:!1,configurable:!0}),e.prototype.reset=function(){this._lastFrameTimeMs=null,this._rollingFrameTime.reset()},e}(),Ct=function(){function e(e){this._samples=new Array(e),this.reset()}return e.prototype.add=function(e){var t;if(this.isSaturated()){var i=this._samples[this._pos];t=i-this.average,this.average-=t/(this._sampleCount-1),this._m2-=t*(i-this.average)}else this._sampleCount++;t=e-this.average,this.average+=t/this._sampleCount,this._m2+=t*(e-this.average),this.variance=this._m2/(this._sampleCount-1),this._samples[this._pos]=e,this._pos++,this._pos%=this._samples.length},e.prototype.history=function(e){if(e>=this._sampleCount||e>=this._samples.length)return 0;var t=this._wrapPosition(this._pos-1);return this._samples[this._wrapPosition(t-e)]},e.prototype.isSaturated=function(){return this._sampleCount>=this._samples.length},e.prototype.reset=function(){this.average=0,this.variance=0,this._sampleCount=0,this._pos=0,this._m2=0},e.prototype._wrapPosition=function(e){var t=this._samples.length;return(e%t+t)%t},e}(),St=function(){function e(){this._startMonitoringTime=0,this._min=0,this._max=0,this._average=0,this._lastSecAverage=0,this._current=0,this._totalValueCount=0,this._totalAccumulated=0,this._lastSecAccumulated=0,this._lastSecTime=0,this._lastSecValueCount=0}return Object.defineProperty(e.prototype,"min",{get:function(){return this._min},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"max",{get:function(){return this._max},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"average",{get:function(){return this._average},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastSecAverage",{get:function(){return this._lastSecAverage},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"current",{get:function(){return this._current},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"total",{get:function(){return this._totalAccumulated},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"count",{get:function(){return this._totalValueCount},enumerable:!1,configurable:!0}),e.prototype.fetchNewFrame=function(){this._totalValueCount++,this._current=0,this._lastSecValueCount++},e.prototype.addCount=function(t,i){e.Enabled&&(this._current+=t,i&&this._fetchResult())},e.prototype.beginMonitoring=function(){e.Enabled&&(this._startMonitoringTime=Fe.Now)},e.prototype.endMonitoring=function(t){if(void 0===t&&(t=!0),e.Enabled){t&&this.fetchNewFrame();var i=Fe.Now;this._current=i-this._startMonitoringTime,t&&this._fetchResult()}},e.prototype._fetchResult=function(){this._totalAccumulated+=this._current,this._lastSecAccumulated+=this._current,this._min=Math.min(this._min,this._current),this._max=Math.max(this._max,this._current),this._average=this._totalAccumulated/this._totalValueCount;var e=Fe.Now;e-this._lastSecTime>1e3&&(this._lastSecAverage=this._lastSecAccumulated/this._lastSecValueCount,this._lastSecTime=e,this._lastSecAccumulated=0,this._lastSecValueCount=0)},e.Enabled=!0,e}();be.prototype.setAlphaConstants=function(e,t,i,r){this._alphaState.setAlphaBlendConstants(e,t,i,r)},be.prototype.setAlphaMode=function(e,t){if(void 0===t&&(t=!1),this._alphaMode!==e){switch(e){case 0:this._alphaState.alphaBlend=!1;break;case 7:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case 8:case 14:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0;break;case 2:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case 6:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case 1:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case 3:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case 4:this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR,this._gl.ZERO,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case 5:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case 9:this._alphaState.setAlphaBlendFunctionParameters(this._gl.CONSTANT_COLOR,this._gl.ONE_MINUS_CONSTANT_COLOR,this._gl.CONSTANT_ALPHA,this._gl.ONE_MINUS_CONSTANT_ALPHA),this._alphaState.alphaBlend=!0;break;case 10:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0;break;case 11:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case 12:this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_ALPHA,this._gl.ONE,this._gl.ZERO,this._gl.ZERO),this._alphaState.alphaBlend=!0;break;case 13:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE_MINUS_DST_COLOR,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE_MINUS_DST_ALPHA,this._gl.ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0;break;case 15:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ONE,this._gl.ZERO),this._alphaState.alphaBlend=!0;break;case 16:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE_MINUS_DST_COLOR,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0}t||(this.depthCullingState.depthMask=0===e),this._alphaMode=e}},be.prototype.getAlphaMode=function(){return this._alphaMode},be.prototype.setAlphaEquation=function(e){if(this._alphaEquation!==e){switch(e){case 0:this._alphaState.setAlphaEquationParameters(this._gl.FUNC_ADD,this._gl.FUNC_ADD);break;case 1:this._alphaState.setAlphaEquationParameters(this._gl.FUNC_SUBTRACT,this._gl.FUNC_SUBTRACT);break;case 2:this._alphaState.setAlphaEquationParameters(this._gl.FUNC_REVERSE_SUBTRACT,this._gl.FUNC_REVERSE_SUBTRACT);break;case 3:this._alphaState.setAlphaEquationParameters(this._gl.MAX,this._gl.MAX);break;case 4:this._alphaState.setAlphaEquationParameters(this._gl.MIN,this._gl.MIN);break;case 5:this._alphaState.setAlphaEquationParameters(this._gl.MIN,this._gl.FUNC_ADD)}this._alphaEquation=e}},be.prototype.getAlphaEquation=function(){return this._alphaEquation},be.prototype._readTexturePixels=function(e,t,i,r,n,o){void 0===r&&(r=-1),void 0===n&&(n=0),void 0===o&&(o=null);var s=this._gl;if(!s)throw new Error("Engine does not have gl rendering context.");if(!this._dummyFramebuffer){var a=s.createFramebuffer();if(!a)throw new Error("Unable to create dummy framebuffer");this._dummyFramebuffer=a}s.bindFramebuffer(s.FRAMEBUFFER,this._dummyFramebuffer),r>-1?s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+r,e._webGLTexture,n):s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,e._webGLTexture,n);var h=void 0!==e.type?this._getWebGLTextureType(e.type):s.UNSIGNED_BYTE;if(h===s.UNSIGNED_BYTE)o||(o=new Uint8Array(4*t*i)),h=s.UNSIGNED_BYTE;else o||(o=new Float32Array(4*t*i)),h=s.FLOAT;return s.readPixels(0,0,t,i,s.RGBA,h,o),s.bindFramebuffer(s.FRAMEBUFFER,this._currentFramebuffer),o},be.prototype.updateDynamicIndexBuffer=function(e,t,i){var r;this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER]=null,this.bindIndexBuffer(e),r=t instanceof Uint16Array||t instanceof Uint32Array?t:e.is32Bits?new Uint32Array(t):new Uint16Array(t),this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,r,this._gl.DYNAMIC_DRAW),this._resetIndexBufferBinding()},be.prototype.updateDynamicVertexBuffer=function(e,t,i,r){this.bindArrayBuffer(e),void 0===i&&(i=0);var n=t.length||t.byteLength;void 0===r||r>=n&&0===i?t instanceof Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,i,new Float32Array(t)):this._gl.bufferSubData(this._gl.ARRAY_BUFFER,i,t):t instanceof Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,new Float32Array(t).subarray(i,i+r)):(t=t instanceof ArrayBuffer?new Uint8Array(t,i,r):new Uint8Array(t.buffer,t.byteOffset+i,r),this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,t)),this._resetVertexBufferBinding()};var It,Ot=function(e){function i(t,r,n,o){void 0===o&&(o=!1);var s=e.call(this,t,r,n,o)||this;if(s.enableOfflineSupport=!1,s.disableManifestCheck=!1,s.scenes=new Array,s.onNewSceneAddedObservable=new U,s.postProcesses=new Array,s.isPointerLock=!1,s.onResizeObservable=new U,s.onCanvasBlurObservable=new U,s.onCanvasFocusObservable=new U,s.onCanvasPointerOutObservable=new U,s.onBeginFrameObservable=new U,s.customAnimationFrameRequester=null,s.onEndFrameObservable=new U,s.onBeforeShaderCompilationObservable=new U,s.onAfterShaderCompilationObservable=new U,s._deterministicLockstep=!1,s._lockstepMaxSteps=4,s._timeStep=1/60,s._fps=60,s._deltaTime=0,s._drawCalls=new St,s.canvasTabIndex=1,s.disablePerformanceMonitorInBackground=!1,s._performanceMonitor=new Pt,i.Instances.push(s),!t)return s;if(n=s._creationOptions,t.getContext){var a=t;if(s._onCanvasFocus=function(){s.onCanvasFocusObservable.notifyObservers(s)},s._onCanvasBlur=function(){s.onCanvasBlurObservable.notifyObservers(s)},a.addEventListener("focus",s._onCanvasFocus),a.addEventListener("blur",s._onCanvasBlur),s._onBlur=function(){s.disablePerformanceMonitorInBackground&&s._performanceMonitor.disable(),s._windowIsBackground=!0},s._onFocus=function(){s.disablePerformanceMonitorInBackground&&s._performanceMonitor.enable(),s._windowIsBackground=!1},s._onCanvasPointerOut=function(e){s.onCanvasPointerOutObservable.notifyObservers(e)},a.addEventListener("pointerout",s._onCanvasPointerOut),H.IsWindowObjectExist()){var h=s.getHostWindow();h.addEventListener("blur",s._onBlur),h.addEventListener("focus",s._onFocus);var u=document;s._onFullscreenChange=function(){void 0!==u.fullscreen?s.isFullscreen=u.fullscreen:void 0!==u.mozFullScreen?s.isFullscreen=u.mozFullScreen:void 0!==u.webkitIsFullScreen?s.isFullscreen=u.webkitIsFullScreen:void 0!==u.msIsFullScreen&&(s.isFullscreen=u.msIsFullScreen),s.isFullscreen&&s._pointerLockRequested&&a&&i._RequestPointerlock(a)},document.addEventListener("fullscreenchange",s._onFullscreenChange,!1),document.addEventListener("mozfullscreenchange",s._onFullscreenChange,!1),document.addEventListener("webkitfullscreenchange",s._onFullscreenChange,!1),document.addEventListener("msfullscreenchange",s._onFullscreenChange,!1),s._onPointerLockChange=function(){s.isPointerLock=u.mozPointerLockElement===a||u.webkitPointerLockElement===a||u.msPointerLockElement===a||u.pointerLockElement===a},document.addEventListener("pointerlockchange",s._onPointerLockChange,!1),document.addEventListener("mspointerlockchange",s._onPointerLockChange,!1),document.addEventListener("mozpointerlockchange",s._onPointerLockChange,!1),document.addEventListener("webkitpointerlockchange",s._onPointerLockChange,!1),!i.audioEngine&&n.audioEngine&&i.AudioEngineFactory&&(i.audioEngine=i.AudioEngineFactory(s.getRenderingCanvas()))}s._connectVREvents(),s.enableOfflineSupport=void 0!==i.OfflineProviderFactory,n.doNotHandleTouchAction||s._disableTouchAction(),s._deterministicLockstep=!!n.deterministicLockstep,s._lockstepMaxSteps=n.lockstepMaxSteps||0,s._timeStep=n.timeStep||1/60}return s._prepareVRComponent(),n.autoEnableWebVR&&s.initWebVR(),s}return t(i,e),Object.defineProperty(i,"NpmPackage",{get:function(){return be.NpmPackage},enumerable:!1,configurable:!0}),Object.defineProperty(i,"Version",{get:function(){return be.Version},enumerable:!1,configurable:!0}),Object.defineProperty(i,"Instances",{get:function(){return V.Instances},enumerable:!1,configurable:!0}),Object.defineProperty(i,"LastCreatedEngine",{get:function(){return V.LastCreatedEngine},enumerable:!1,configurable:!0}),Object.defineProperty(i,"LastCreatedScene",{get:function(){return V.LastCreatedScene},enumerable:!1,configurable:!0}),i.MarkAllMaterialsAsDirty=function(e,t){for(var r=0;r<i.Instances.length;r++)for(var n=i.Instances[r],o=0;o<n.scenes.length;o++)n.scenes[o].markAllMaterialsAsDirty(e,t)},i.DefaultLoadingScreenFactory=function(e){throw b.WarnImport("LoadingScreen")},Object.defineProperty(i.prototype,"_supportsHardwareTextureRescaling",{get:function(){return!!i._RescalePostProcessFactory},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"performanceMonitor",{get:function(){return this._performanceMonitor},enumerable:!1,configurable:!0}),i.prototype.getInputElement=function(){return this._renderingCanvas},i.prototype.getAspectRatio=function(e,t){void 0===t&&(t=!1);var i=e.viewport;return this.getRenderWidth(t)*i.width/(this.getRenderHeight(t)*i.height)},i.prototype.getScreenAspectRatio=function(){return this.getRenderWidth(!0)/this.getRenderHeight(!0)},i.prototype.getRenderingCanvasClientRect=function(){return this._renderingCanvas?this._renderingCanvas.getBoundingClientRect():null},i.prototype.getInputElementClientRect=function(){return this._renderingCanvas?this.getInputElement().getBoundingClientRect():null},i.prototype.isDeterministicLockStep=function(){return this._deterministicLockstep},i.prototype.getLockstepMaxSteps=function(){return this._lockstepMaxSteps},i.prototype.getTimeStep=function(){return 1e3*this._timeStep},i.prototype.generateMipMapsForCubemap=function(e,t){if(void 0===t&&(t=!0),e.generateMipMaps){var i=this._gl;this._bindTextureDirectly(i.TEXTURE_CUBE_MAP,e,!0),i.generateMipmap(i.TEXTURE_CUBE_MAP),t&&this._bindTextureDirectly(i.TEXTURE_CUBE_MAP,null)}},i.prototype.setState=function(e,t,i,r){void 0===t&&(t=0),void 0===r&&(r=!1),(this._depthCullingState.cull!==e||i)&&(this._depthCullingState.cull=e);var n=this.cullBackFaces?this._gl.BACK:this._gl.FRONT;(this._depthCullingState.cullFace!==n||i)&&(this._depthCullingState.cullFace=n),this.setZOffset(t);var o=r?this._gl.CW:this._gl.CCW;(this._depthCullingState.frontFace!==o||i)&&(this._depthCullingState.frontFace=o)},i.prototype.setZOffset=function(e){this._depthCullingState.zOffset=e},i.prototype.getZOffset=function(){return this._depthCullingState.zOffset},i.prototype.setDepthBuffer=function(e){this._depthCullingState.depthTest=e},i.prototype.getDepthWrite=function(){return this._depthCullingState.depthMask},i.prototype.setDepthWrite=function(e){this._depthCullingState.depthMask=e},i.prototype.getStencilBuffer=function(){return this._stencilState.stencilTest},i.prototype.setStencilBuffer=function(e){this._stencilState.stencilTest=e},i.prototype.getStencilMask=function(){return this._stencilState.stencilMask},i.prototype.setStencilMask=function(e){this._stencilState.stencilMask=e},i.prototype.getStencilFunction=function(){return this._stencilState.stencilFunc},i.prototype.getStencilFunctionReference=function(){return this._stencilState.stencilFuncRef},i.prototype.getStencilFunctionMask=function(){return this._stencilState.stencilFuncMask},i.prototype.setStencilFunction=function(e){this._stencilState.stencilFunc=e},i.prototype.setStencilFunctionReference=function(e){this._stencilState.stencilFuncRef=e},i.prototype.setStencilFunctionMask=function(e){this._stencilState.stencilFuncMask=e},i.prototype.getStencilOperationFail=function(){return this._stencilState.stencilOpStencilFail},i.prototype.getStencilOperationDepthFail=function(){return this._stencilState.stencilOpDepthFail},i.prototype.getStencilOperationPass=function(){return this._stencilState.stencilOpStencilDepthPass},i.prototype.setStencilOperationFail=function(e){this._stencilState.stencilOpStencilFail=e},i.prototype.setStencilOperationDepthFail=function(e){this._stencilState.stencilOpDepthFail=e},i.prototype.setStencilOperationPass=function(e){this._stencilState.stencilOpStencilDepthPass=e},i.prototype.setDitheringState=function(e){e?this._gl.enable(this._gl.DITHER):this._gl.disable(this._gl.DITHER)},i.prototype.setRasterizerState=function(e){e?this._gl.disable(this._gl.RASTERIZER_DISCARD):this._gl.enable(this._gl.RASTERIZER_DISCARD)},i.prototype.getDepthFunction=function(){return this._depthCullingState.depthFunc},i.prototype.setDepthFunction=function(e){this._depthCullingState.depthFunc=e},i.prototype.setDepthFunctionToGreater=function(){this._depthCullingState.depthFunc=this._gl.GREATER},i.prototype.setDepthFunctionToGreaterOrEqual=function(){this._depthCullingState.depthFunc=this._gl.GEQUAL},i.prototype.setDepthFunctionToLess=function(){this._depthCullingState.depthFunc=this._gl.LESS},i.prototype.setDepthFunctionToLessOrEqual=function(){this._depthCullingState.depthFunc=this._gl.LEQUAL},i.prototype.cacheStencilState=function(){this._cachedStencilBuffer=this.getStencilBuffer(),this._cachedStencilFunction=this.getStencilFunction(),this._cachedStencilMask=this.getStencilMask(),this._cachedStencilOperationPass=this.getStencilOperationPass(),this._cachedStencilOperationFail=this.getStencilOperationFail(),this._cachedStencilOperationDepthFail=this.getStencilOperationDepthFail(),this._cachedStencilReference=this.getStencilFunctionReference()},i.prototype.restoreStencilState=function(){this.setStencilFunction(this._cachedStencilFunction),this.setStencilMask(this._cachedStencilMask),this.setStencilBuffer(this._cachedStencilBuffer),this.setStencilOperationPass(this._cachedStencilOperationPass),this.setStencilOperationFail(this._cachedStencilOperationFail),this.setStencilOperationDepthFail(this._cachedStencilOperationDepthFail),this.setStencilFunctionReference(this._cachedStencilReference)},i.prototype.setDirectViewport=function(e,t,i,r){var n=this._cachedViewport;return this._cachedViewport=null,this._viewport(e,t,i,r),n},i.prototype.scissorClear=function(e,t,i,r,n){this.enableScissor(e,t,i,r),this.clear(n,!0,!0,!0),this.disableScissor()},i.prototype.enableScissor=function(e,t,i,r){var n=this._gl;n.enable(n.SCISSOR_TEST),n.scissor(e,t,i,r)},i.prototype.disableScissor=function(){var e=this._gl;e.disable(e.SCISSOR_TEST)},i.prototype._reportDrawCall=function(){this._drawCalls.addCount(1,!1)},i.prototype.initWebVR=function(){throw b.WarnImport("WebVRCamera")},i.prototype._prepareVRComponent=function(){},i.prototype._connectVREvents=function(e,t){},i.prototype._submitVRFrame=function(){},i.prototype.disableVR=function(){},i.prototype.isVRPresenting=function(){return!1},i.prototype._requestVRFrame=function(){},i.prototype._loadFileAsync=function(e,t,i){var r=this;return new Promise((function(n,o){r._loadFile(e,(function(e){n(e)}),void 0,t,i,(function(e,t){o(t)}))}))},i.prototype.getVertexShaderSource=function(e){var t=this._gl.getAttachedShaders(e);return t?this._gl.getShaderSource(t[0]):null},i.prototype.getFragmentShaderSource=function(e){var t=this._gl.getAttachedShaders(e);return t?this._gl.getShaderSource(t[1]):null},i.prototype.setDepthStencilTexture=function(e,t,i){void 0!==e&&(t&&(this._boundUniforms[e]=t),i&&i.depthStencilTexture?this._setTexture(e,i,!1,!0):this._setTexture(e,null))},i.prototype.setTextureFromPostProcess=function(e,t){this._bindTexture(e,t?t._textures.data[t._currentRenderTextureInd]:null)},i.prototype.setTextureFromPostProcessOutput=function(e,t){this._bindTexture(e,t?t._outputTexture:null)},i.prototype._rebuildBuffers=function(){for(var t=0,i=this.scenes;t<i.length;t++){var r=i[t];r.resetCachedMaterial(),r._rebuildGeometries(),r._rebuildTextures()}e.prototype._rebuildBuffers.call(this)},i.prototype._renderFrame=function(){for(var e=0;e<this._activeRenderLoops.length;e++){(0,this._activeRenderLoops[e])()}},i.prototype._renderLoop=function(){if(!this._contextWasLost){var e=!0;!this.renderEvenInBackground&&this._windowIsBackground&&(e=!1),e&&(this.beginFrame(),this._renderViews()||this._renderFrame(),this.endFrame())}this._activeRenderLoops.length>0?this.customAnimationFrameRequester?(this.customAnimationFrameRequester.requestID=this._queueNewFrame(this.customAnimationFrameRequester.renderFunction||this._boundRenderFunction,this.customAnimationFrameRequester),this._frameHandler=this.customAnimationFrameRequester.requestID):this.isVRPresenting()?this._requestVRFrame():this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow()):this._renderingQueueLaunched=!1},i.prototype._renderViews=function(){return!1},i.prototype.switchFullscreen=function(e){this.isFullscreen?this.exitFullscreen():this.enterFullscreen(e)},i.prototype.enterFullscreen=function(e){this.isFullscreen||(this._pointerLockRequested=e,this._renderingCanvas&&i._RequestFullscreen(this._renderingCanvas))},i.prototype.exitFullscreen=function(){this.isFullscreen&&i._ExitFullscreen()},i.prototype.enterPointerlock=function(){this._renderingCanvas&&i._RequestPointerlock(this._renderingCanvas)},i.prototype.exitPointerlock=function(){i._ExitPointerlock()},i.prototype.beginFrame=function(){this._measureFps(),this.onBeginFrameObservable.notifyObservers(this),e.prototype.beginFrame.call(this)},i.prototype.endFrame=function(){e.prototype.endFrame.call(this),this._submitVRFrame(),this.onEndFrameObservable.notifyObservers(this)},i.prototype.resize=function(){this.isVRPresenting()||e.prototype.resize.call(this)},i.prototype.setSize=function(t,i){if(!this._renderingCanvas)return!1;if(!e.prototype.setSize.call(this,t,i))return!1;if(this.scenes){for(var r=0;r<this.scenes.length;r++)for(var n=this.scenes[r],o=0;o<n.cameras.length;o++){n.cameras[o]._currentRenderId=0}this.onResizeObservable.hasObservers()&&this.onResizeObservable.notifyObservers(this)}return!0},i.prototype._deletePipelineContext=function(t){var i=t;i&&i.program&&i.transformFeedback&&(this.deleteTransformFeedback(i.transformFeedback),i.transformFeedback=null),e.prototype._deletePipelineContext.call(this,t)},i.prototype.createShaderProgram=function(t,i,r,n,o,s){void 0===s&&(s=null),o=o||this._gl,this.onBeforeShaderCompilationObservable.notifyObservers(this);var a=e.prototype.createShaderProgram.call(this,t,i,r,n,o,s);return this.onAfterShaderCompilationObservable.notifyObservers(this),a},i.prototype._createShaderProgram=function(e,t,i,r,n){void 0===n&&(n=null);var o=r.createProgram();if(e.program=o,!o)throw new Error("Unable to create program");if(r.attachShader(o,t),r.attachShader(o,i),this.webGLVersion>1&&n){var s=this.createTransformFeedback();this.bindTransformFeedback(s),this.setTranformFeedbackVaryings(o,n),e.transformFeedback=s}return r.linkProgram(o),this.webGLVersion>1&&n&&this.bindTransformFeedback(null),e.context=r,e.vertexShader=t,e.fragmentShader=i,e.isParallelCompiled||this._finalizePipelineContext(e),o},i.prototype._releaseTexture=function(t){e.prototype._releaseTexture.call(this,t),this.scenes.forEach((function(e){e.postProcesses.forEach((function(e){e._outputTexture==t&&(e._outputTexture=null)})),e.cameras.forEach((function(e){e._postProcesses.forEach((function(e){e&&e._outputTexture==t&&(e._outputTexture=null)}))}))}))},i.prototype._rescaleTexture=function(e,t,r,n,o){var s=this;this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,this._gl.LINEAR),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,this._gl.LINEAR),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._gl.CLAMP_TO_EDGE),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._gl.CLAMP_TO_EDGE);var a=this.createRenderTargetTexture({width:t.width,height:t.height},{generateMipMaps:!1,type:0,samplingMode:2,generateDepthBuffer:!1,generateStencilBuffer:!1});!this._rescalePostProcess&&i._RescalePostProcessFactory&&(this._rescalePostProcess=i._RescalePostProcessFactory(this)),this._rescalePostProcess.getEffect().executeWhenCompiled((function(){s._rescalePostProcess.onApply=function(t){t._bindTexture("textureSampler",e)};var i=r;i||(i=s.scenes[s.scenes.length-1]),i.postProcessManager.directRender([s._rescalePostProcess],a,!0),s._bindTextureDirectly(s._gl.TEXTURE_2D,t,!0),s._gl.copyTexImage2D(s._gl.TEXTURE_2D,0,n,0,0,t.width,t.height,0),s.unBindFramebuffer(a),s._releaseTexture(a),o&&o()}))},i.prototype.getFps=function(){return this._fps},i.prototype.getDeltaTime=function(){return this._deltaTime},i.prototype._measureFps=function(){this._performanceMonitor.sampleFrame(),this._fps=this._performanceMonitor.averageFPS,this._deltaTime=this._performanceMonitor.instantaneousFrameTime||0},i.prototype._uploadImageToTexture=function(e,t,i,r){void 0===i&&(i=0),void 0===r&&(r=0);var n=this._gl,o=this._getWebGLTextureType(e.type),s=this._getInternalFormat(e.format),a=this._getRGBABufferInternalSizedFormat(e.type,s),h=e.isCube?n.TEXTURE_CUBE_MAP:n.TEXTURE_2D;this._bindTextureDirectly(h,e,!0),this._unpackFlipY(e.invertY);var u=n.TEXTURE_2D;e.isCube&&(u=n.TEXTURE_CUBE_MAP_POSITIVE_X+i),n.texImage2D(u,r,a,s,o,t),this._bindTextureDirectly(h,null,!0)},i.prototype.updateRenderTargetTextureSampleCount=function(e,t){if(this.webGLVersion<2||!e)return 1;if(e.samples===t)return t;var i=this._gl;if(t=Math.min(t,this.getCaps().maxMSAASamples),e._depthStencilBuffer&&(i.deleteRenderbuffer(e._depthStencilBuffer),e._depthStencilBuffer=null),e._MSAAFramebuffer&&(i.deleteFramebuffer(e._MSAAFramebuffer),e._MSAAFramebuffer=null),e._MSAARenderBuffer&&(i.deleteRenderbuffer(e._MSAARenderBuffer),e._MSAARenderBuffer=null),t>1&&i.renderbufferStorageMultisample){var r=i.createFramebuffer();if(!r)throw new Error("Unable to create multi sampled framebuffer");e._MSAAFramebuffer=r,this._bindUnboundFramebuffer(e._MSAAFramebuffer);var n=i.createRenderbuffer();if(!n)throw new Error("Unable to create multi sampled framebuffer");i.bindRenderbuffer(i.RENDERBUFFER,n),i.renderbufferStorageMultisample(i.RENDERBUFFER,t,this._getRGBAMultiSampleBufferFormat(e.type),e.width,e.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,n),e._MSAARenderBuffer=n}else this._bindUnboundFramebuffer(e._framebuffer);return e.samples=t,e._depthStencilBuffer=this._setupFramebufferDepthAttachments(e._generateStencilBuffer,e._generateDepthBuffer,e.width,e.height,t),this._bindUnboundFramebuffer(null),t},i.prototype.updateTextureComparisonFunction=function(e,t){if(1!==this.webGLVersion){var i=this._gl;e.isCube?(this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,e,!0),0===t?(i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_FUNC,515),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_MODE,i.NONE)):(i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_FUNC,t),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)):(this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0),0===t?(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_FUNC,515),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_MODE,i.NONE)):(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_FUNC,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_2D,null)),e._comparisonFunction=t}else q.Error("WebGL 1 does not support texture comparison.")},i.prototype.createInstancesBuffer=function(e){var t=this._gl.createBuffer();if(!t)throw new Error("Unable to create instance buffer");var i=new ge(t);return i.capacity=e,this.bindArrayBuffer(i),this._gl.bufferData(this._gl.ARRAY_BUFFER,e,this._gl.DYNAMIC_DRAW),i},i.prototype.deleteInstancesBuffer=function(e){this._gl.deleteBuffer(e)},i.prototype._clientWaitAsync=function(e,t,i){void 0===t&&(t=0),void 0===i&&(i=10);var r=this._gl;return new Promise((function(n,o){var s=function(){var a=r.clientWaitSync(e,t,0);a!=r.WAIT_FAILED?a!=r.TIMEOUT_EXPIRED?n():setTimeout(s,i):o()};s()}))},i.prototype._readPixelsAsync=function(e,t,i,r,n,o,s){if(this._webGLVersion<2)throw new Error("_readPixelsAsync only work on WebGL2+");var a=this._gl,h=a.createBuffer();a.bindBuffer(a.PIXEL_PACK_BUFFER,h),a.bufferData(a.PIXEL_PACK_BUFFER,s.byteLength,a.STREAM_READ),a.readPixels(e,t,i,r,n,o,0),a.bindBuffer(a.PIXEL_PACK_BUFFER,null);var u=a.fenceSync(a.SYNC_GPU_COMMANDS_COMPLETE,0);return u?(a.flush(),this._clientWaitAsync(u,0,10).then((function(){return a.deleteSync(u),a.bindBuffer(a.PIXEL_PACK_BUFFER,h),a.getBufferSubData(a.PIXEL_PACK_BUFFER,0,s),a.bindBuffer(a.PIXEL_PACK_BUFFER,null),a.deleteBuffer(h),s}))):null},i.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();1===i.Instances.length&&i.audioEngine&&i.audioEngine.dispose(),this.disableVR(),H.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)),H.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))),e.prototype.dispose.call(this);var t=i.Instances.indexOf(this);t>=0&&i.Instances.splice(t,1),this.onResizeObservable.clear(),this.onCanvasBlurObservable.clear(),this.onCanvasFocusObservable.clear(),this.onCanvasPointerOutObservable.clear(),this.onBeginFrameObservable.clear(),this.onEndFrameObservable.clear()},i.prototype._disableTouchAction=function(){this._renderingCanvas&&this._renderingCanvas.setAttribute&&(this._renderingCanvas.setAttribute("touch-action","none"),this._renderingCanvas.style.touchAction="none",this._renderingCanvas.style.msTouchAction="none")},i.prototype.displayLoadingUI=function(){if(H.IsWindowObjectExist()){var e=this.loadingScreen;e&&e.displayLoadingUI()}},i.prototype.hideLoadingUI=function(){if(H.IsWindowObjectExist()){var e=this._loadingScreen;e&&e.hideLoadingUI()}},Object.defineProperty(i.prototype,"loadingScreen",{get:function(){return!this._loadingScreen&&this._renderingCanvas&&(this._loadingScreen=i.DefaultLoadingScreenFactory(this._renderingCanvas)),this._loadingScreen},set:function(e){this._loadingScreen=e},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"loadingUIText",{set:function(e){this.loadingScreen.loadingUIText=e},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"loadingUIBackgroundColor",{set:function(e){this.loadingScreen.loadingUIBackgroundColor=e},enumerable:!1,configurable:!0}),i._RequestPointerlock=function(e){e.requestPointerLock=e.requestPointerLock||e.msRequestPointerLock||e.mozRequestPointerLock||e.webkitRequestPointerLock,e.requestPointerLock&&e.requestPointerLock()},i._ExitPointerlock=function(){var e=document;document.exitPointerLock=document.exitPointerLock||e.msExitPointerLock||e.mozExitPointerLock||e.webkitExitPointerLock,document.exitPointerLock&&document.exitPointerLock()},i._RequestFullscreen=function(e){var t=e.requestFullscreen||e.msRequestFullscreen||e.webkitRequestFullscreen||e.mozRequestFullScreen;t&&t.call(e)},i._ExitFullscreen=function(){var e=document;document.exitFullscreen?document.exitFullscreen():e.mozCancelFullScreen?e.mozCancelFullScreen():e.webkitCancelFullScreen?e.webkitCancelFullScreen():e.msCancelFullScreen&&e.msCancelFullScreen()},i.ALPHA_DISABLE=0,i.ALPHA_ADD=1,i.ALPHA_COMBINE=2,i.ALPHA_SUBTRACT=3,i.ALPHA_MULTIPLY=4,i.ALPHA_MAXIMIZED=5,i.ALPHA_ONEONE=6,i.ALPHA_PREMULTIPLIED=7,i.ALPHA_PREMULTIPLIED_PORTERDUFF=8,i.ALPHA_INTERPOLATE=9,i.ALPHA_SCREENMODE=10,i.DELAYLOADSTATE_NONE=0,i.DELAYLOADSTATE_LOADED=1,i.DELAYLOADSTATE_LOADING=2,i.DELAYLOADSTATE_NOTLOADED=4,i.NEVER=512,i.ALWAYS=519,i.LESS=513,i.EQUAL=514,i.LEQUAL=515,i.GREATER=516,i.GEQUAL=518,i.NOTEQUAL=517,i.KEEP=7680,i.REPLACE=7681,i.INCR=7682,i.DECR=7683,i.INVERT=5386,i.INCR_WRAP=34055,i.DECR_WRAP=34056,i.TEXTURE_CLAMP_ADDRESSMODE=0,i.TEXTURE_WRAP_ADDRESSMODE=1,i.TEXTURE_MIRROR_ADDRESSMODE=2,i.TEXTUREFORMAT_ALPHA=0,i.TEXTUREFORMAT_LUMINANCE=1,i.TEXTUREFORMAT_LUMINANCE_ALPHA=2,i.TEXTUREFORMAT_RGB=4,i.TEXTUREFORMAT_RGBA=5,i.TEXTUREFORMAT_RED=6,i.TEXTUREFORMAT_R=6,i.TEXTUREFORMAT_RG=7,i.TEXTUREFORMAT_RED_INTEGER=8,i.TEXTUREFORMAT_R_INTEGER=8,i.TEXTUREFORMAT_RG_INTEGER=9,i.TEXTUREFORMAT_RGB_INTEGER=10,i.TEXTUREFORMAT_RGBA_INTEGER=11,i.TEXTURETYPE_UNSIGNED_BYTE=0,i.TEXTURETYPE_UNSIGNED_INT=0,i.TEXTURETYPE_FLOAT=1,i.TEXTURETYPE_HALF_FLOAT=2,i.TEXTURETYPE_BYTE=3,i.TEXTURETYPE_SHORT=4,i.TEXTURETYPE_UNSIGNED_SHORT=5,i.TEXTURETYPE_INT=6,i.TEXTURETYPE_UNSIGNED_INTEGER=7,i.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=8,i.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=9,i.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=10,i.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=11,i.TEXTURETYPE_UNSIGNED_INT_24_8=12,i.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=13,i.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=14,i.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=15,i.TEXTURE_NEAREST_SAMPLINGMODE=1,i.TEXTURE_BILINEAR_SAMPLINGMODE=2,i.TEXTURE_TRILINEAR_SAMPLINGMODE=3,i.TEXTURE_NEAREST_NEAREST_MIPLINEAR=8,i.TEXTURE_LINEAR_LINEAR_MIPNEAREST=11,i.TEXTURE_LINEAR_LINEAR_MIPLINEAR=3,i.TEXTURE_NEAREST_NEAREST_MIPNEAREST=4,i.TEXTURE_NEAREST_LINEAR_MIPNEAREST=5,i.TEXTURE_NEAREST_LINEAR_MIPLINEAR=6,i.TEXTURE_NEAREST_LINEAR=7,i.TEXTURE_NEAREST_NEAREST=1,i.TEXTURE_LINEAR_NEAREST_MIPNEAREST=9,i.TEXTURE_LINEAR_NEAREST_MIPLINEAR=10,i.TEXTURE_LINEAR_LINEAR=2,i.TEXTURE_LINEAR_NEAREST=12,i.TEXTURE_EXPLICIT_MODE=0,i.TEXTURE_SPHERICAL_MODE=1,i.TEXTURE_PLANAR_MODE=2,i.TEXTURE_CUBIC_MODE=3,i.TEXTURE_PROJECTION_MODE=4,i.TEXTURE_SKYBOX_MODE=5,i.TEXTURE_INVCUBIC_MODE=6,i.TEXTURE_EQUIRECTANGULAR_MODE=7,i.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=8,i.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9,i.SCALEMODE_FLOOR=1,i.SCALEMODE_NEAREST=2,i.SCALEMODE_CEILING=3,i._RescalePostProcessFactory=null,i}(be);!function(e){e[e.LOCAL=0]="LOCAL",e[e.WORLD=1]="WORLD",e[e.BONE=2]="BONE"}(It||(It={}));var Rt,Dt=function(){function e(){}return e.X=new p(1,0,0),e.Y=new p(0,1,0),e.Z=new p(0,0,1),e}();!function(e){e[e.X=0]="X",e[e.Y=1]="Y",e[e.Z=2]="Z"}(Rt||(Rt={}));var wt=function(e){function i(t,r,n){void 0===r&&(r=null),void 0===n&&(n=!0);var o=e.call(this,t,r)||this;return o._forward=new p(0,0,1),o._forwardInverted=new p(0,0,-1),o._up=new p(0,1,0),o._right=new p(1,0,0),o._rightInverted=new p(-1,0,0),o._position=p.Zero(),o._rotation=p.Zero(),o._rotationQuaternion=null,o._scaling=p.One(),o._isDirty=!1,o._transformToBoneReferal=null,o._isAbsoluteSynced=!1,o._billboardMode=i.BILLBOARDMODE_NONE,o._preserveParentRotationForBillboard=!1,o.scalingDeterminant=1,o._infiniteDistance=!1,o.ignoreNonUniformScaling=!1,o.reIntegrateRotationIntoRotationQuaternion=!1,o._poseMatrix=null,o._localMatrix=m.Zero(),o._usePivotMatrix=!1,o._absolutePosition=p.Zero(),o._absoluteScaling=p.Zero(),o._absoluteRotationQuaternion=g.Identity(),o._pivotMatrix=m.Identity(),o._postMultiplyPivotMatrix=!1,o._isWorldMatrixFrozen=!1,o._indexInSceneTransformNodesArray=-1,o.onAfterWorldMatrixUpdateObservable=new U,o._nonUniformScaling=!1,n&&o.getScene().addTransformNode(o),o}var n;return t(i,e),Object.defineProperty(i.prototype,"billboardMode",{get:function(){return this._billboardMode},set:function(e){this._billboardMode!==e&&(this._billboardMode=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"preserveParentRotationForBillboard",{get:function(){return this._preserveParentRotationForBillboard},set:function(e){e!==this._preserveParentRotationForBillboard&&(this._preserveParentRotationForBillboard=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"infiniteDistance",{get:function(){return this._infiniteDistance},set:function(e){this._infiniteDistance!==e&&(this._infiniteDistance=e)},enumerable:!1,configurable:!0}),i.prototype.getClassName=function(){return"TransformNode"},Object.defineProperty(i.prototype,"position",{get:function(){return this._position},set:function(e){this._position=e,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"rotation",{get:function(){return this._rotation},set:function(e){this._rotation=e,this._rotationQuaternion=null,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"scaling",{get:function(){return this._scaling},set:function(e){this._scaling=e,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"rotationQuaternion",{get:function(){return this._rotationQuaternion},set:function(e){this._rotationQuaternion=e,e&&this._rotation.setAll(0),this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"forward",{get:function(){return p.Normalize(p.TransformNormal(this.getScene().useRightHandedSystem?this._forwardInverted:this._forward,this.getWorldMatrix()))},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"up",{get:function(){return p.Normalize(p.TransformNormal(this._up,this.getWorldMatrix()))},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"right",{get:function(){return p.Normalize(p.TransformNormal(this.getScene().useRightHandedSystem?this._rightInverted:this._right,this.getWorldMatrix()))},enumerable:!1,configurable:!0}),i.prototype.updatePoseMatrix=function(e){return this._poseMatrix?(this._poseMatrix.copyFrom(e),this):(this._poseMatrix=e.clone(),this)},i.prototype.getPoseMatrix=function(){return this._poseMatrix||(this._poseMatrix=m.Identity()),this._poseMatrix},i.prototype._isSynchronized=function(){var e=this._cache;return this.billboardMode===e.billboardMode&&this.billboardMode===i.BILLBOARDMODE_NONE&&(!e.pivotMatrixUpdated&&(!this.infiniteDistance&&(!this.position._isDirty&&(!this.scaling._isDirty&&!(this._rotationQuaternion&&this._rotationQuaternion._isDirty||this.rotation._isDirty)))))},i.prototype._initCache=function(){e.prototype._initCache.call(this);var t=this._cache;t.localMatrixUpdated=!1,t.billboardMode=-1,t.infiniteDistance=!1},i.prototype.markAsDirty=function(e){return this._currentRenderId=Number.MAX_VALUE,this._isDirty=!0,this},Object.defineProperty(i.prototype,"absolutePosition",{get:function(){return this._absolutePosition},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"absoluteScaling",{get:function(){return this._syncAbsoluteScalingAndRotation(),this._absoluteScaling},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"absoluteRotationQuaternion",{get:function(){return this._syncAbsoluteScalingAndRotation(),this._absoluteRotationQuaternion},enumerable:!1,configurable:!0}),i.prototype.setPreTransformMatrix=function(e){return this.setPivotMatrix(e,!1)},i.prototype.setPivotMatrix=function(e,t){return void 0===t&&(t=!0),this._pivotMatrix.copyFrom(e),this._usePivotMatrix=!this._pivotMatrix.isIdentity(),this._cache.pivotMatrixUpdated=!0,this._postMultiplyPivotMatrix=t,this._postMultiplyPivotMatrix&&(this._pivotMatrixInverse?this._pivotMatrix.invertToRef(this._pivotMatrixInverse):this._pivotMatrixInverse=m.Invert(this._pivotMatrix)),this},i.prototype.getPivotMatrix=function(){return this._pivotMatrix},i.prototype.instantiateHierarchy=function(e,t,i){void 0===e&&(e=null);var r=this.clone("Clone of "+(this.name||this.id),e||this.parent,!0);r&&i&&i(this,r);for(var n=0,o=this.getChildTransformNodes(!0);n<o.length;n++){o[n].instantiateHierarchy(r,t,i)}return r},i.prototype.freezeWorldMatrix=function(e){return void 0===e&&(e=null),e?this._worldMatrix=e:(this._isWorldMatrixFrozen=!1,this.computeWorldMatrix(!0)),this._isDirty=!1,this._isWorldMatrixFrozen=!0,this},i.prototype.unfreezeWorldMatrix=function(){return this._isWorldMatrixFrozen=!1,this.computeWorldMatrix(!0),this},Object.defineProperty(i.prototype,"isWorldMatrixFrozen",{get:function(){return this._isWorldMatrixFrozen},enumerable:!1,configurable:!0}),i.prototype.getAbsolutePosition=function(){return this.computeWorldMatrix(),this._absolutePosition},i.prototype.setAbsolutePosition=function(e){if(!e)return this;var t,i,r;if(void 0===e.x){if(arguments.length<3)return this;t=arguments[0],i=arguments[1],r=arguments[2]}else t=e.x,i=e.y,r=e.z;if(this.parent){var n=y.Matrix[0];this.parent.getWorldMatrix().invertToRef(n),p.TransformCoordinatesFromFloatsToRef(t,i,r,n,this.position)}else this.position.x=t,this.position.y=i,this.position.z=r;return this._absolutePosition.copyFrom(e),this},i.prototype.setPositionWithLocalVector=function(e){return this.computeWorldMatrix(),this.position=p.TransformNormal(e,this._localMatrix),this},i.prototype.getPositionExpressedInLocalSpace=function(){this.computeWorldMatrix();var e=y.Matrix[0];return this._localMatrix.invertToRef(e),p.TransformNormal(this.position,e)},i.prototype.locallyTranslate=function(e){return this.computeWorldMatrix(!0),this.position=p.TransformCoordinates(e,this._localMatrix),this},i.prototype.lookAt=function(e,t,r,n,o){void 0===t&&(t=0),void 0===r&&(r=0),void 0===n&&(n=0),void 0===o&&(o=It.LOCAL);var s=i._lookAtVectorCache,a=o===It.LOCAL?this.position:this.getAbsolutePosition();if(e.subtractToRef(a,s),this.setDirection(s,t,r,n),o===It.WORLD&&this.parent)if(this.rotationQuaternion){var h=y.Matrix[0];this.rotationQuaternion.toRotationMatrix(h);var u=y.Matrix[1];this.parent.getWorldMatrix().getRotationMatrixToRef(u),u.invert(),h.multiplyToRef(u,h),this.rotationQuaternion.fromRotationMatrix(h)}else{var l=y.Quaternion[0];g.FromEulerVectorToRef(this.rotation,l);h=y.Matrix[0];l.toRotationMatrix(h);u=y.Matrix[1];this.parent.getWorldMatrix().getRotationMatrixToRef(u),u.invert(),h.multiplyToRef(u,h),l.fromRotationMatrix(h),l.toEulerAnglesToRef(this.rotation)}return this},i.prototype.getDirection=function(e){var t=p.Zero();return this.getDirectionToRef(e,t),t},i.prototype.getDirectionToRef=function(e,t){return p.TransformNormalToRef(e,this.getWorldMatrix(),t),this},i.prototype.setDirection=function(e,t,i,r){void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=0);var n=-Math.atan2(e.z,e.x)+Math.PI/2,o=Math.sqrt(e.x*e.x+e.z*e.z),s=-Math.atan2(e.y,o);return this.rotationQuaternion?g.RotationYawPitchRollToRef(n+t,s+i,r,this.rotationQuaternion):(this.rotation.x=s+i,this.rotation.y=n+t,this.rotation.z=r),this},i.prototype.setPivotPoint=function(e,t){void 0===t&&(t=It.LOCAL),0==this.getScene().getRenderId()&&this.computeWorldMatrix(!0);var i=this.getWorldMatrix();if(t==It.WORLD){var r=y.Matrix[0];i.invertToRef(r),e=p.TransformCoordinates(e,r)}return this.setPivotMatrix(m.Translation(-e.x,-e.y,-e.z),!0)},i.prototype.getPivotPoint=function(){var e=p.Zero();return this.getPivotPointToRef(e),e},i.prototype.getPivotPointToRef=function(e){return e.x=-this._pivotMatrix.m[12],e.y=-this._pivotMatrix.m[13],e.z=-this._pivotMatrix.m[14],this},i.prototype.getAbsolutePivotPoint=function(){var e=p.Zero();return this.getAbsolutePivotPointToRef(e),e},i.prototype.getAbsolutePivotPointToRef=function(e){return this.getPivotPointToRef(e),p.TransformCoordinatesToRef(e,this.getWorldMatrix(),e),this},i.prototype.setParent=function(e){if(!e&&!this.parent)return this;var t=y.Quaternion[0],i=y.Vector3[0],r=y.Vector3[1];if(e){var n=y.Matrix[0],o=y.Matrix[1];this.computeWorldMatrix(!0),e.computeWorldMatrix(!0),e.getWorldMatrix().invertToRef(o),this.getWorldMatrix().multiplyToRef(o,n),n.decompose(r,t,i)}else this.computeWorldMatrix(!0),this.getWorldMatrix().decompose(r,t,i);return this.rotationQuaternion?this.rotationQuaternion.copyFrom(t):t.toEulerAnglesToRef(this.rotation),this.scaling.copyFrom(r),this.position.copyFrom(i),this.parent=e,this},Object.defineProperty(i.prototype,"nonUniformScaling",{get:function(){return this._nonUniformScaling},enumerable:!1,configurable:!0}),i.prototype._updateNonUniformScalingState=function(e){return this._nonUniformScaling!==e&&(this._nonUniformScaling=e,!0)},i.prototype.attachToBone=function(e,t){return this._transformToBoneReferal=t,this.parent=e,e.getSkeleton().prepare(),e.getWorldMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this},i.prototype.detachFromBone=function(){return this.parent?(this.parent.getWorldMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this._transformToBoneReferal=null,this.parent=null,this):this},i.prototype.rotate=function(e,t,r){var n;if(e.normalize(),this.rotationQuaternion||(this.rotationQuaternion=this.rotation.toQuaternion(),this.rotation.setAll(0)),r&&r!==It.LOCAL){if(this.parent){var o=y.Matrix[0];this.parent.getWorldMatrix().invertToRef(o),e=p.TransformNormal(e,o)}(n=g.RotationAxisToRef(e,t,i._rotationAxisCache)).multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)}else n=g.RotationAxisToRef(e,t,i._rotationAxisCache),this.rotationQuaternion.multiplyToRef(n,this.rotationQuaternion);return this},i.prototype.rotateAround=function(e,t,i){t.normalize(),this.rotationQuaternion||(this.rotationQuaternion=g.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z),this.rotation.setAll(0));var r=y.Vector3[0],n=y.Vector3[1],o=y.Vector3[2],s=y.Quaternion[0],a=y.Matrix[0],h=y.Matrix[1],u=y.Matrix[2],l=y.Matrix[3];return e.subtractToRef(this.position,r),m.TranslationToRef(r.x,r.y,r.z,a),m.TranslationToRef(-r.x,-r.y,-r.z,h),m.RotationAxisToRef(t,i,u),h.multiplyToRef(u,l),l.multiplyToRef(a,l),l.decompose(n,s,o),this.position.addInPlace(o),s.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion),this},i.prototype.translate=function(e,t,i){var r=e.scale(t);if(i&&i!==It.LOCAL)this.setAbsolutePosition(this.getAbsolutePosition().add(r));else{var n=this.getPositionExpressedInLocalSpace().add(r);this.setPositionWithLocalVector(n)}return this},i.prototype.addRotation=function(e,t,i){var r;this.rotationQuaternion?r=this.rotationQuaternion:(r=y.Quaternion[1],g.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,r));var n=y.Quaternion[0];return g.RotationYawPitchRollToRef(t,e,i,n),r.multiplyInPlace(n),this.rotationQuaternion||r.toEulerAnglesToRef(this.rotation),this},i.prototype._getEffectiveParent=function(){return this.parent},i.prototype.computeWorldMatrix=function(e){if(this._isWorldMatrixFrozen&&!this._isDirty)return this._worldMatrix;var t=this.getScene().getRenderId();if(!this._isDirty&&!e&&this.isSynchronized())return this._currentRenderId=t,this._worldMatrix;var r=this.getScene().activeCamera,n=0!=(this._billboardMode&i.BILLBOARDMODE_USE_POSITION),o=this._billboardMode!==i.BILLBOARDMODE_NONE&&!this.preserveParentRotationForBillboard;o&&r&&n&&(this.lookAt(r.position),(this.billboardMode&i.BILLBOARDMODE_X)!==i.BILLBOARDMODE_X&&(this.rotation.x=0),(this.billboardMode&i.BILLBOARDMODE_Y)!==i.BILLBOARDMODE_Y&&(this.rotation.y=0),(this.billboardMode&i.BILLBOARDMODE_Z)!==i.BILLBOARDMODE_Z&&(this.rotation.z=0)),this._updateCache();var s=this._cache;s.pivotMatrixUpdated=!1,s.billboardMode=this.billboardMode,s.infiniteDistance=this.infiniteDistance,this._currentRenderId=t,this._childUpdateId++,this._isDirty=!1,this._position._isDirty=!1,this._rotation._isDirty=!1,this._scaling._isDirty=!1;var a,h=this._getEffectiveParent(),u=i._TmpScaling,l=this._position;if(this._infiniteDistance&&!this.parent&&r){var c=r.getWorldMatrix(),f=new p(c.m[12],c.m[13],c.m[14]);(l=i._TmpTranslation).copyFromFloats(this._position.x+f.x,this._position.y+f.y,this._position.z+f.z)}(u.copyFromFloats(this._scaling.x*this.scalingDeterminant,this._scaling.y*this.scalingDeterminant,this._scaling.z*this.scalingDeterminant),this._rotationQuaternion)?(this._rotationQuaternion._isDirty=!1,a=this._rotationQuaternion,this.reIntegrateRotationIntoRotationQuaternion&&this.rotation.lengthSquared()&&(this._rotationQuaternion.multiplyInPlace(g.RotationYawPitchRoll(this._rotation.y,this._rotation.x,this._rotation.z)),this._rotation.copyFromFloats(0,0,0))):(a=i._TmpRotation,g.RotationYawPitchRollToRef(this._rotation.y,this._rotation.x,this._rotation.z,a));if(this._usePivotMatrix){var d=y.Matrix[1];m.ScalingToRef(u.x,u.y,u.z,d);var _=y.Matrix[0];a.toRotationMatrix(_),this._pivotMatrix.multiplyToRef(d,y.Matrix[4]),y.Matrix[4].multiplyToRef(_,this._localMatrix),this._postMultiplyPivotMatrix&&this._localMatrix.multiplyToRef(this._pivotMatrixInverse,this._localMatrix),this._localMatrix.addTranslationFromFloats(l.x,l.y,l.z)}else m.ComposeToRef(u,a,l,this._localMatrix);if(h&&h.getWorldMatrix){if(e&&h.computeWorldMatrix(),o){this._transformToBoneReferal?h.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),y.Matrix[7]):y.Matrix[7].copyFrom(h.getWorldMatrix());var v=y.Vector3[5],b=y.Vector3[6];y.Matrix[7].decompose(b,void 0,v),m.ScalingToRef(b.x,b.y,b.z,y.Matrix[7]),y.Matrix[7].setTranslation(v),this._localMatrix.multiplyToRef(y.Matrix[7],this._worldMatrix)}else this._transformToBoneReferal?(this._localMatrix.multiplyToRef(h.getWorldMatrix(),y.Matrix[6]),y.Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),this._worldMatrix)):this._localMatrix.multiplyToRef(h.getWorldMatrix(),this._worldMatrix);this._markSyncedWithParent()}else this._worldMatrix.copyFrom(this._localMatrix);if(o&&r&&this.billboardMode&&!n){var T=y.Vector3[0];if(this._worldMatrix.getTranslationToRef(T),y.Matrix[1].copyFrom(r.getViewMatrix()),y.Matrix[1].setTranslationFromFloats(0,0,0),y.Matrix[1].invertToRef(y.Matrix[0]),(this.billboardMode&i.BILLBOARDMODE_ALL)!==i.BILLBOARDMODE_ALL){y.Matrix[0].decompose(void 0,y.Quaternion[0],void 0);var E=y.Vector3[1];y.Quaternion[0].toEulerAnglesToRef(E),(this.billboardMode&i.BILLBOARDMODE_X)!==i.BILLBOARDMODE_X&&(E.x=0),(this.billboardMode&i.BILLBOARDMODE_Y)!==i.BILLBOARDMODE_Y&&(E.y=0),(this.billboardMode&i.BILLBOARDMODE_Z)!==i.BILLBOARDMODE_Z&&(E.z=0),m.RotationYawPitchRollToRef(E.y,E.x,E.z,y.Matrix[0])}this._worldMatrix.setTranslationFromFloats(0,0,0),this._worldMatrix.multiplyToRef(y.Matrix[0],this._worldMatrix),this._worldMatrix.setTranslation(y.Vector3[0])}return this.ignoreNonUniformScaling?this._updateNonUniformScalingState(!1):this._scaling.isNonUniformWithinEpsilon(1e-6)?this._updateNonUniformScalingState(!0):h&&h._nonUniformScaling?this._updateNonUniformScalingState(h._nonUniformScaling):this._updateNonUniformScalingState(!1),this._afterComputeWorldMatrix(),this._absolutePosition.copyFromFloats(this._worldMatrix.m[12],this._worldMatrix.m[13],this._worldMatrix.m[14]),this._isAbsoluteSynced=!1,this.onAfterWorldMatrixUpdateObservable.notifyObservers(this),this._poseMatrix||(this._poseMatrix=m.Invert(this._worldMatrix)),this._worldMatrixDeterminantIsDirty=!0,this._worldMatrix},i.prototype.resetLocalMatrix=function(e){if(void 0===e&&(e=!0),this.computeWorldMatrix(),e)for(var t=this.getChildren(),i=0;i<t.length;++i){var r=t[i];if(r){r.computeWorldMatrix();var n=y.Matrix[0];r._localMatrix.multiplyToRef(this._localMatrix,n);var o=y.Quaternion[0];n.decompose(r.scaling,o,r.position),r.rotationQuaternion?r.rotationQuaternion=o:o.toEulerAnglesToRef(r.rotation)}}this.scaling.copyFromFloats(1,1,1),this.position.copyFromFloats(0,0,0),this.rotation.copyFromFloats(0,0,0),this.rotationQuaternion&&(this.rotationQuaternion=g.Identity()),this._worldMatrix=m.Identity()},i.prototype._afterComputeWorldMatrix=function(){},i.prototype.registerAfterWorldMatrixUpdate=function(e){return this.onAfterWorldMatrixUpdateObservable.add(e),this},i.prototype.unregisterAfterWorldMatrixUpdate=function(e){return this.onAfterWorldMatrixUpdateObservable.removeCallback(e),this},i.prototype.getPositionInCameraSpace=function(e){return void 0===e&&(e=null),e||(e=this.getScene().activeCamera),p.TransformCoordinates(this.getAbsolutePosition(),e.getViewMatrix())},i.prototype.getDistanceToCamera=function(e){return void 0===e&&(e=null),e||(e=this.getScene().activeCamera),this.getAbsolutePosition().subtract(e.globalPosition).length()},i.prototype.clone=function(e,t,r){var n=this,o=N.Clone((function(){return new i(e,n.getScene())}),this);if(o.name=e,o.id=e,t&&(o.parent=t),!r)for(var s=this.getDescendants(!0),a=0;a<s.length;a++){var h=s[a];h.clone&&h.clone(e+"."+h.name,o)}return o},i.prototype.serialize=function(e){var t=N.Serialize(this,e);return t.type=this.getClassName(),this.parent&&(t.parentId=this.parent.id),t.localMatrix=this.getPivotMatrix().asArray(),t.isEnabled=this.isEnabled(),this.parent&&(t.parentId=this.parent.id),t},i.Parse=function(e,t,r){var n=N.Parse((function(){return new i(e.name,t)}),e,t,r);return e.localMatrix?n.setPreTransformMatrix(m.FromArray(e.localMatrix)):e.pivotMatrix&&n.setPivotMatrix(m.FromArray(e.pivotMatrix)),n.setEnabled(e.isEnabled),e.parentId&&(n._waitingParentId=e.parentId),n},i.prototype.getChildTransformNodes=function(e,t){var r=[];return this._getDescendants(r,e,(function(e){return(!t||t(e))&&e instanceof i})),r},i.prototype.dispose=function(t,i){if(void 0===i&&(i=!1),this.getScene().stopAnimation(this),this.getScene().removeTransformNode(this),this.onAfterWorldMatrixUpdateObservable.clear(),t)for(var r=0,n=this.getChildTransformNodes(!0);r<n.length;r++){var o=n[r];o.parent=null,o.computeWorldMatrix(!0)}e.prototype.dispose.call(this,t,i)},i.prototype.normalizeToUnitCube=function(e,t,i){void 0===e&&(e=!0),void 0===t&&(t=!1);var r=null,n=null;t&&(this.rotationQuaternion?(n=this.rotationQuaternion.clone(),this.rotationQuaternion.copyFromFloats(0,0,0,1)):this.rotation&&(r=this.rotation.clone(),this.rotation.copyFromFloats(0,0,0)));var o=this.getHierarchyBoundingVectors(e,i),s=o.max.subtract(o.min),a=Math.max(s.x,s.y,s.z);if(0===a)return this;var h=1/a;return this.scaling.scaleInPlace(h),t&&(this.rotationQuaternion&&n?this.rotationQuaternion.copyFrom(n):this.rotation&&r&&this.rotation.copyFrom(r)),this},i.prototype._syncAbsoluteScalingAndRotation=function(){this._isAbsoluteSynced||(this._worldMatrix.decompose(this._absoluteScaling,this._absoluteRotationQuaternion),this._isAbsoluteSynced=!0)},i.BILLBOARDMODE_NONE=0,i.BILLBOARDMODE_X=1,i.BILLBOARDMODE_Y=2,i.BILLBOARDMODE_Z=4,i.BILLBOARDMODE_ALL=7,i.BILLBOARDMODE_USE_POSITION=128,i._TmpRotation=g.Zero(),i._TmpScaling=p.Zero(),i._TmpTranslation=p.Zero(),i._lookAtVectorCache=new p(0,0,0),i._rotationAxisCache=new g,r([L("position")],i.prototype,"_position",void 0),r([L("rotation")],i.prototype,"_rotation",void 0),r([(n="rotationQuaternion",S(10,n))],i.prototype,"_rotationQuaternion",void 0),r([L("scaling")],i.prototype,"_scaling",void 0),r([O("billboardMode")],i.prototype,"_billboardMode",void 0),r([O()],i.prototype,"scalingDeterminant",void 0),r([O("infiniteDistance")],i.prototype,"_infiniteDistance",void 0),r([O()],i.prototype,"ignoreNonUniformScaling",void 0),r([O()],i.prototype,"reIntegrateRotationIntoRotationQuaternion",void 0),i}(ut),Lt=function(){function e(){this._pickingUnavailable=!1,this.hit=!1,this.distance=0,this.pickedPoint=null,this.pickedMesh=null,this.bu=0,this.bv=0,this.faceId=-1,this.subMeshFaceId=-1,this.subMeshId=0,this.pickedSprite=null,this.thinInstanceIndex=-1,this.originMesh=null,this.ray=null}return e.prototype.getNormal=function(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=!0),!this.pickedMesh||!this.pickedMesh.isVerticesDataPresent(ft.NormalKind))return null;var i,r=this.pickedMesh.getIndices();if(!r)return null;if(t){var n=this.pickedMesh.getVerticesData(ft.NormalKind),o=p.FromArray(n,3*r[3*this.faceId]),s=p.FromArray(n,3*r[3*this.faceId+1]),a=p.FromArray(n,3*r[3*this.faceId+2]);o=o.scale(this.bu),s=s.scale(this.bv),a=a.scale(1-this.bu-this.bv),i=new p(o.x+s.x+a.x,o.y+s.y+a.y,o.z+s.z+a.z)}else{var h=this.pickedMesh.getVerticesData(ft.PositionKind),u=p.FromArray(h,3*r[3*this.faceId]),l=p.FromArray(h,3*r[3*this.faceId+1]),c=p.FromArray(h,3*r[3*this.faceId+2]),f=u.subtract(l),d=c.subtract(l);i=p.Cross(f,d)}if(e){var _=this.pickedMesh.getWorldMatrix();this.pickedMesh.nonUniformScaling&&(y.Matrix[0].copyFrom(_),(_=y.Matrix[0]).setTranslationFromFloats(0,0,0),_.invert(),_.transposeToRef(y.Matrix[1]),_=y.Matrix[1]),i=p.TransformNormal(i,_)}return i.normalize(),i},e.prototype.getTextureCoordinates=function(){if(!this.pickedMesh||!this.pickedMesh.isVerticesDataPresent(ft.UVKind))return null;var e=this.pickedMesh.getIndices();if(!e)return null;var t=this.pickedMesh.getVerticesData(ft.UVKind);if(!t)return null;var i=d.FromArray(t,2*e[3*this.faceId]),r=d.FromArray(t,2*e[3*this.faceId+1]),n=d.FromArray(t,2*e[3*this.faceId+2]);return i=i.scale(this.bu),r=r.scale(this.bv),n=n.scale(1-this.bu-this.bv),new d(i.x+r.x+n.x,i.y+r.y+n.y)},e}(),Ft=function(){this._checkCollisions=!1,this._collisionMask=-1,this._collisionGroup=-1,this._surroundingMeshes=null,this._collider=null,this._oldPositionForCollisions=new p(0,0,0),this._diffPositionForCollisions=new p(0,0,0),this._collisionResponse=!0},Nt=function(){this.facetNb=0,this.partitioningSubdivisions=10,this.partitioningBBoxRatio=1.01,this.facetDataEnabled=!1,this.facetParameters={},this.bbSize=p.Zero(),this.subDiv={max:1,X:1,Y:1,Z:1},this.facetDepthSort=!1,this.facetDepthSortEnabled=!1},Bt=function(){this._hasVertexAlpha=!1,this._useVertexColors=!0,this._numBoneInfluencers=4,this._applyFog=!0,this._receiveShadows=!1,this._facetData=new Nt,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},kt=function(e){function i(t,r){void 0===r&&(r=null);var n=e.call(this,t,r,!1)||this;return n._internalAbstractMeshDataInfo=new Bt,n.cullingStrategy=i.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY,n.onCollideObservable=new U,n.onCollisionPositionChangeObservable=new U,n.onMaterialChangedObservable=new U,n.definedFacingForward=!0,n._occlusionQuery=null,n._renderingGroup=null,n.alphaIndex=Number.MAX_VALUE,n.isVisible=!0,n.isPickable=!0,n.showSubMeshesBoundingBox=!1,n.isBlocker=!1,n.enablePointerMoveEvents=!1,n._renderingGroupId=0,n._material=null,n.outlineColor=T.Red(),n.outlineWidth=.02,n.overlayColor=T.Red(),n.overlayAlpha=.5,n.useOctreeForRenderingSelection=!0,n.useOctreeForPicking=!0,n.useOctreeForCollisions=!0,n.alwaysSelectAsActiveMesh=!1,n.doNotSyncBoundingInfo=!1,n.actionManager=null,n._meshCollisionData=new Ft,n.ellipsoid=new p(.5,1,.5),n.ellipsoidOffset=new p(0,0,0),n.edgesWidth=1,n.edgesColor=new E(1,0,0,1),n._edgesRenderer=null,n._masterMesh=null,n._boundingInfo=null,n._renderId=0,n._intersectionsInProgress=new Array,n._unIndexed=!1,n._lightSources=new Array,n._waitingData={lods:null,actions:null,freezeWorldMatrix:null},n._bonesTransformMatrices=null,n._transformMatrixTexture=null,n.onRebuildObservable=new U,n._onCollisionPositionChange=function(e,t,i){void 0===i&&(i=null),t.subtractToRef(n._meshCollisionData._oldPositionForCollisions,n._meshCollisionData._diffPositionForCollisions),n._meshCollisionData._diffPositionForCollisions.length()>Ot.CollisionsEpsilon&&n.position.addInPlace(n._meshCollisionData._diffPositionForCollisions),i&&n.onCollideObservable.notifyObservers(i),n.onCollisionPositionChangeObservable.notifyObservers(n.position)},n.getScene().addMesh(n),n._resyncLightSources(),n}return t(i,e),Object.defineProperty(i,"BILLBOARDMODE_NONE",{get:function(){return wt.BILLBOARDMODE_NONE},enumerable:!1,configurable:!0}),Object.defineProperty(i,"BILLBOARDMODE_X",{get:function(){return wt.BILLBOARDMODE_X},enumerable:!1,configurable:!0}),Object.defineProperty(i,"BILLBOARDMODE_Y",{get:function(){return wt.BILLBOARDMODE_Y},enumerable:!1,configurable:!0}),Object.defineProperty(i,"BILLBOARDMODE_Z",{get:function(){return wt.BILLBOARDMODE_Z},enumerable:!1,configurable:!0}),Object.defineProperty(i,"BILLBOARDMODE_ALL",{get:function(){return wt.BILLBOARDMODE_ALL},enumerable:!1,configurable:!0}),Object.defineProperty(i,"BILLBOARDMODE_USE_POSITION",{get:function(){return wt.BILLBOARDMODE_USE_POSITION},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"facetNb",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetNb},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"partitioningSubdivisions",{get:function(){return this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions},set:function(e){this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions=e},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"partitioningBBoxRatio",{get:function(){return this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio},set:function(e){this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio=e},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"mustDepthSortFacets",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetDepthSort},set:function(e){this._internalAbstractMeshDataInfo._facetData.facetDepthSort=e},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"facetDepthSortFrom",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom},set:function(e){this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom=e},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"isFacetDataEnabled",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetDataEnabled},enumerable:!1,configurable:!0}),i.prototype._updateNonUniformScalingState=function(t){return!!e.prototype._updateNonUniformScalingState.call(this,t)&&(this._markSubMeshesAsMiscDirty(),!0)},Object.defineProperty(i.prototype,"onCollide",{set:function(e){this._meshCollisionData._onCollideObserver&&this.onCollideObservable.remove(this._meshCollisionData._onCollideObserver),this._meshCollisionData._onCollideObserver=this.onCollideObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"onCollisionPositionChange",{set:function(e){this._meshCollisionData._onCollisionPositionChangeObserver&&this.onCollisionPositionChangeObservable.remove(this._meshCollisionData._onCollisionPositionChangeObserver),this._meshCollisionData._onCollisionPositionChangeObserver=this.onCollisionPositionChangeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"visibility",{get:function(){return this._internalAbstractMeshDataInfo._visibility},set:function(e){this._internalAbstractMeshDataInfo._visibility!==e&&(this._internalAbstractMeshDataInfo._visibility=e,this._markSubMeshesAsMiscDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"renderingGroupId",{get:function(){return this._renderingGroupId},set:function(e){this._renderingGroupId=e},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"material",{get:function(){return this._material},set:function(e){this._material!==e&&(this._material&&this._material.meshMap&&(this._material.meshMap[this.uniqueId]=void 0),this._material=e,e&&e.meshMap&&(e.meshMap[this.uniqueId]=this),this.onMaterialChangedObservable.hasObservers()&&this.onMaterialChangedObservable.notifyObservers(this),this.subMeshes&&this._unBindEffect())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"receiveShadows",{get:function(){return this._internalAbstractMeshDataInfo._receiveShadows},set:function(e){this._internalAbstractMeshDataInfo._receiveShadows!==e&&(this._internalAbstractMeshDataInfo._receiveShadows=e,this._markSubMeshesAsLightDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"hasVertexAlpha",{get:function(){return this._internalAbstractMeshDataInfo._hasVertexAlpha},set:function(e){this._internalAbstractMeshDataInfo._hasVertexAlpha!==e&&(this._internalAbstractMeshDataInfo._hasVertexAlpha=e,this._markSubMeshesAsAttributesDirty(),this._markSubMeshesAsMiscDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"useVertexColors",{get:function(){return this._internalAbstractMeshDataInfo._useVertexColors},set:function(e){this._internalAbstractMeshDataInfo._useVertexColors!==e&&(this._internalAbstractMeshDataInfo._useVertexColors=e,this._markSubMeshesAsAttributesDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"computeBonesUsingShaders",{get:function(){return this._internalAbstractMeshDataInfo._computeBonesUsingShaders},set:function(e){this._internalAbstractMeshDataInfo._computeBonesUsingShaders!==e&&(this._internalAbstractMeshDataInfo._computeBonesUsingShaders=e,this._markSubMeshesAsAttributesDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"numBoneInfluencers",{get:function(){return this._internalAbstractMeshDataInfo._numBoneInfluencers},set:function(e){this._internalAbstractMeshDataInfo._numBoneInfluencers!==e&&(this._internalAbstractMeshDataInfo._numBoneInfluencers=e,this._markSubMeshesAsAttributesDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"applyFog",{get:function(){return this._internalAbstractMeshDataInfo._applyFog},set:function(e){this._internalAbstractMeshDataInfo._applyFog!==e&&(this._internalAbstractMeshDataInfo._applyFog=e,this._markSubMeshesAsMiscDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"layerMask",{get:function(){return this._internalAbstractMeshDataInfo._layerMask},set:function(e){e!==this._internalAbstractMeshDataInfo._layerMask&&(this._internalAbstractMeshDataInfo._layerMask=e,this._resyncLightSources())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"collisionMask",{get:function(){return this._meshCollisionData._collisionMask},set:function(e){this._meshCollisionData._collisionMask=isNaN(e)?-1:e},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"collisionResponse",{get:function(){return this._meshCollisionData._collisionResponse},set:function(e){this._meshCollisionData._collisionResponse=e},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"collisionGroup",{get:function(){return this._meshCollisionData._collisionGroup},set:function(e){this._meshCollisionData._collisionGroup=isNaN(e)?-1:e},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"surroundingMeshes",{get:function(){return this._meshCollisionData._surroundingMeshes},set:function(e){this._meshCollisionData._surroundingMeshes=e},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"lightSources",{get:function(){return this._lightSources},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"_positions",{get:function(){return null},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"skeleton",{get:function(){return this._internalAbstractMeshDataInfo._skeleton},set:function(e){var t=this._internalAbstractMeshDataInfo._skeleton;t&&t.needInitialSkinMatrix&&t._unregisterMeshWithPoseMatrix(this),e&&e.needInitialSkinMatrix&&e._registerMeshWithPoseMatrix(this),this._internalAbstractMeshDataInfo._skeleton=e,this._internalAbstractMeshDataInfo._skeleton||(this._bonesTransformMatrices=null),this._markSubMeshesAsAttributesDirty()},enumerable:!1,configurable:!0}),i.prototype.getClassName=function(){return"AbstractMesh"},i.prototype.toString=function(e){var t="Name: "+this.name+", isInstance: "+("InstancedMesh"!==this.getClassName()?"YES":"NO");t+=", # of submeshes: "+(this.subMeshes?this.subMeshes.length:0);var i=this._internalAbstractMeshDataInfo._skeleton;return i&&(t+=", skeleton: "+i.name),e&&(t+=", billboard mode: "+["NONE","X","Y",null,"Z",null,null,"ALL"][this.billboardMode],t+=", freeze wrld mat: "+(this._isWorldMatrixFrozen||this._waitingData.freezeWorldMatrix?"YES":"NO")),t},i.prototype._getEffectiveParent=function(){return this._masterMesh&&this.billboardMode!==wt.BILLBOARDMODE_NONE?this._masterMesh:e.prototype._getEffectiveParent.call(this)},i.prototype._getActionManagerForTrigger=function(e,t){if(void 0===t&&(t=!0),this.actionManager&&(t||this.actionManager.isRecursive)){if(!e)return this.actionManager;if(this.actionManager.hasSpecificTrigger(e))return this.actionManager}return this.parent?this.parent._getActionManagerForTrigger(e,!1):null},i.prototype._rebuild=function(){if(this.onRebuildObservable.notifyObservers(this),this._occlusionQuery&&(this._occlusionQuery=null),this.subMeshes)for(var e=0,t=this.subMeshes;e<t.length;e++){t[e]._rebuild()}},i.prototype._resyncLightSources=function(){this._lightSources.length=0;for(var e=0,t=this.getScene().lights;e<t.length;e++){var i=t[e];i.isEnabled()&&(i.canAffectMesh(this)&&this._lightSources.push(i))}this._markSubMeshesAsLightDirty()},i.prototype._resyncLightSource=function(e){var t=e.isEnabled()&&e.canAffectMesh(this),i=this._lightSources.indexOf(e),r=!1;if(-1===i){if(!t)return;this._lightSources.push(e)}else{if(t)return;r=!0,this._lightSources.splice(i,1)}this._markSubMeshesAsLightDirty(r)},i.prototype._unBindEffect=function(){for(var e=0,t=this.subMeshes;e<t.length;e++){t[e].setEffect(null)}},i.prototype._removeLightSource=function(e,t){var i=this._lightSources.indexOf(e);-1!==i&&(this._lightSources.splice(i,1),this._markSubMeshesAsLightDirty(t))},i.prototype._markSubMeshesAsDirty=function(e){if(this.subMeshes)for(var t=0,i=this.subMeshes;t<i.length;t++){var r=i[t];r._materialDefines&&e(r._materialDefines)}},i.prototype._markSubMeshesAsLightDirty=function(e){void 0===e&&(e=!1),this._markSubMeshesAsDirty((function(t){return t.markAsLightDirty(e)}))},i.prototype._markSubMeshesAsAttributesDirty=function(){this._markSubMeshesAsDirty((function(e){return e.markAsAttributesDirty()}))},i.prototype._markSubMeshesAsMiscDirty=function(){this._markSubMeshesAsDirty((function(e){return e.markAsMiscDirty()}))},Object.defineProperty(i.prototype,"scaling",{get:function(){return this._scaling},set:function(e){this._scaling=e},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"isBlocked",{get:function(){return!1},enumerable:!1,configurable:!0}),i.prototype.getLOD=function(e){return this},i.prototype.getTotalVertices=function(){return 0},i.prototype.getTotalIndices=function(){return 0},i.prototype.getIndices=function(){return null},i.prototype.getVerticesData=function(e){return null},i.prototype.setVerticesData=function(e,t,i,r){return this},i.prototype.updateVerticesData=function(e,t,i,r){return this},i.prototype.setIndices=function(e,t){return this},i.prototype.isVerticesDataPresent=function(e){return!1},i.prototype.getBoundingInfo=function(){return this._masterMesh?this._masterMesh.getBoundingInfo():(this._boundingInfo||this._updateBoundingInfo(),this._boundingInfo)},i.prototype.normalizeToUnitCube=function(t,i,r){return void 0===t&&(t=!0),void 0===i&&(i=!1),e.prototype.normalizeToUnitCube.call(this,t,i,r)},i.prototype.setBoundingInfo=function(e){return this._boundingInfo=e,this},Object.defineProperty(i.prototype,"useBones",{get:function(){return this.skeleton&&this.getScene().skeletonsEnabled&&this.isVerticesDataPresent(ft.MatricesIndicesKind)&&this.isVerticesDataPresent(ft.MatricesWeightsKind)},enumerable:!1,configurable:!0}),i.prototype._preActivate=function(){},i.prototype._preActivateForIntermediateRendering=function(e){},i.prototype._activate=function(e,t){return this._renderId=e,!0},i.prototype._postActivate=function(){},i.prototype._freeze=function(){},i.prototype._unFreeze=function(){},i.prototype.getWorldMatrix=function(){return this._masterMesh&&this.billboardMode===wt.BILLBOARDMODE_NONE?this._masterMesh.getWorldMatrix():e.prototype.getWorldMatrix.call(this)},i.prototype._getWorldMatrixDeterminant=function(){return this._masterMesh?this._masterMesh._getWorldMatrixDeterminant():e.prototype._getWorldMatrixDeterminant.call(this)},Object.defineProperty(i.prototype,"isAnInstance",{get:function(){return!1},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"hasInstances",{get:function(){return!1},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"hasThinInstances",{get:function(){return!1},enumerable:!1,configurable:!0}),i.prototype.movePOV=function(e,t,i){return this.position.addInPlace(this.calcMovePOV(e,t,i)),this},i.prototype.calcMovePOV=function(e,t,i){var r=new m;(this.rotationQuaternion?this.rotationQuaternion:g.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z)).toRotationMatrix(r);var n=p.Zero(),o=this.definedFacingForward?-1:1;return p.TransformCoordinatesFromFloatsToRef(e*o,t,i*o,r,n),n},i.prototype.rotatePOV=function(e,t,i){return this.rotation.addInPlace(this.calcRotatePOV(e,t,i)),this},i.prototype.calcRotatePOV=function(e,t,i){var r=this.definedFacingForward?1:-1;return new p(e*r,t,i*r)},i.prototype.refreshBoundingInfo=function(e){return void 0===e&&(e=!1),this._boundingInfo&&this._boundingInfo.isLocked||this._refreshBoundingInfo(this._getPositionData(e),null),this},i.prototype._refreshBoundingInfo=function(e,t){if(e){var i=Et(e,0,this.getTotalVertices(),t);this._boundingInfo?this._boundingInfo.reConstruct(i.minimum,i.maximum):this._boundingInfo=new Tt(i.minimum,i.maximum)}if(this.subMeshes)for(var r=0;r<this.subMeshes.length;r++)this.subMeshes[r].refreshBoundingInfo(e);this._updateBoundingInfo()},i.prototype._getPositionData=function(e){var t=this.getVerticesData(ft.PositionKind);if(t&&e&&this.skeleton){t=Ue.Slice(t),this._generatePointsArray();var i=this.getVerticesData(ft.MatricesIndicesKind),r=this.getVerticesData(ft.MatricesWeightsKind);if(r&&i){var n=this.numBoneInfluencers>4,o=n?this.getVerticesData(ft.MatricesIndicesExtraKind):null,s=n?this.getVerticesData(ft.MatricesWeightsExtraKind):null;this.skeleton.prepare();for(var a=this.skeleton.getTransformMatrices(this),h=y.Vector3[0],u=y.Matrix[0],l=y.Matrix[1],c=0,f=0;f<t.length;f+=3,c+=4){var d,_;for(u.reset(),d=0;d<4;d++)(_=r[c+d])>0&&(m.FromFloat32ArrayToRefScaled(a,Math.floor(16*i[c+d]),_,l),u.addToSelf(l));if(n)for(d=0;d<4;d++)(_=s[c+d])>0&&(m.FromFloat32ArrayToRefScaled(a,Math.floor(16*o[c+d]),_,l),u.addToSelf(l));p.TransformCoordinatesFromFloatsToRef(t[f],t[f+1],t[f+2],u,h),h.toArray(t,f),this._positions&&this._positions[f/3].copyFrom(h)}}}return t},i.prototype._updateBoundingInfo=function(){var e=this._effectiveMesh;return this._boundingInfo?this._boundingInfo.update(e.worldMatrixFromCache):this._boundingInfo=new Tt(this.absolutePosition,this.absolutePosition,e.worldMatrixFromCache),this._updateSubMeshesBoundingInfo(e.worldMatrixFromCache),this},i.prototype._updateSubMeshesBoundingInfo=function(e){if(!this.subMeshes)return this;for(var t=this.subMeshes.length,i=0;i<t;i++){var r=this.subMeshes[i];(t>1||!r.IsGlobal)&&r.updateBoundingInfo(e)}return this},i.prototype._afterComputeWorldMatrix=function(){this.doNotSyncBoundingInfo||this._updateBoundingInfo()},Object.defineProperty(i.prototype,"_effectiveMesh",{get:function(){return this.skeleton&&this.skeleton.overrideMesh||this},enumerable:!1,configurable:!0}),i.prototype.isInFrustum=function(e){return null!==this._boundingInfo&&this._boundingInfo.isInFrustum(e,this.cullingStrategy)},i.prototype.isCompletelyInFrustum=function(e){return null!==this._boundingInfo&&this._boundingInfo.isCompletelyInFrustum(e)},i.prototype.intersectsMesh=function(e,t,i){if(void 0===t&&(t=!1),!this._boundingInfo||!e._boundingInfo)return!1;if(this._boundingInfo.intersects(e._boundingInfo,t))return!0;if(i)for(var r=0,n=this.getChildMeshes();r<n.length;r++){if(n[r].intersectsMesh(e,t,!0))return!0}return!1},i.prototype.intersectsPoint=function(e){return!!this._boundingInfo&&this._boundingInfo.intersectsPoint(e)},Object.defineProperty(i.prototype,"checkCollisions",{get:function(){return this._meshCollisionData._checkCollisions},set:function(e){this._meshCollisionData._checkCollisions=e},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"collider",{get:function(){return this._meshCollisionData._collider},enumerable:!1,configurable:!0}),i.prototype.moveWithCollisions=function(e){this.getAbsolutePosition().addToRef(this.ellipsoidOffset,this._meshCollisionData._oldPositionForCollisions);var t=this.getScene().collisionCoordinator;return this._meshCollisionData._collider||(this._meshCollisionData._collider=t.createCollider()),this._meshCollisionData._collider._radius=this.ellipsoid,t.getNewPosition(this._meshCollisionData._oldPositionForCollisions,e,this._meshCollisionData._collider,3,this,this._onCollisionPositionChange,this.uniqueId),this},i.prototype._collideForSubMesh=function(e,t,i){if(this._generatePointsArray(),!this._positions)return this;if(!e._lastColliderWorldVertices||!e._lastColliderTransformMatrix.equals(t)){e._lastColliderTransformMatrix=t.clone(),e._lastColliderWorldVertices=[],e._trianglePlanes=[];for(var r=e.verticesStart,n=e.verticesStart+e.verticesCount,o=r;o<n;o++)e._lastColliderWorldVertices.push(p.TransformCoordinates(this._positions[o],t))}return i._collide(e._trianglePlanes,e._lastColliderWorldVertices,this.getIndices(),e.indexStart,e.indexStart+e.indexCount,e.verticesStart,!!e.getMaterial(),this),this},i.prototype._processCollisionsForSubMeshes=function(e,t){for(var i=this._scene.getCollidingSubMeshCandidates(this,e),r=i.length,n=0;n<r;n++){var o=i.data[n];r>1&&!o._checkCollision(e)||this._collideForSubMesh(o,t,e)}return this},i.prototype._checkCollision=function(e){if(!this._boundingInfo||!this._boundingInfo._checkCollision(e))return this;var t=y.Matrix[0],i=y.Matrix[1];return m.ScalingToRef(1/e._radius.x,1/e._radius.y,1/e._radius.z,t),this.worldMatrixFromCache.multiplyToRef(t,i),this._processCollisionsForSubMeshes(e,i),this},i.prototype._generatePointsArray=function(){return!1},i.prototype.intersects=function(e,t,i,r,n,o){var s;void 0===r&&(r=!1),void 0===o&&(o=!1);var a=new Lt,h="InstancedLinesMesh"===this.getClassName()||"LinesMesh"===this.getClassName()?this.intersectionThreshold:0,u=this._boundingInfo;if(!this.subMeshes||!u)return a;if(!(o||e.intersectsSphere(u.boundingSphere,h)&&e.intersectsBox(u.boundingBox,h)))return a;if(r)return a.hit=!o,a.pickedMesh=o?null:this,a.distance=o?0:p.Distance(e.origin,u.boundingSphere.center),a.subMeshId=0,a;if(!this._generatePointsArray())return a;for(var l=null,c=this._scene.getIntersectingSubMeshCandidates(this,e),f=c.length,d=!1,_=0;_<f;_++){var g=(m=c.data[_]).getMaterial();if(g&&((null===(s=this.getIndices())||void 0===s?void 0:s.length)&&(7==g.fillMode||0==g.fillMode||1==g.fillMode||2==g.fillMode))){d=!0;break}}if(!d)return a.hit=!0,a.pickedMesh=this,a.distance=p.Distance(e.origin,u.boundingSphere.center),a.subMeshId=-1,a;for(_=0;_<f;_++){var m=c.data[_];if(!(f>1)||m.canIntersects(e)){var v=m.intersects(e,this._positions,this.getIndices(),t,i);if(v&&(t||!l||v.distance<l.distance)&&((l=v).subMeshId=_,t))break}}if(l){var b=null!=n?n:this.skeleton&&this.skeleton.overrideMesh?this.skeleton.overrideMesh.getWorldMatrix():this.getWorldMatrix(),T=y.Vector3[0],E=y.Vector3[1];p.TransformCoordinatesToRef(e.origin,b,T),e.direction.scaleToRef(l.distance,E);var x=p.TransformNormal(E,b).addInPlace(T);return a.hit=!0,a.distance=p.Distance(T,x),a.pickedPoint=x,a.pickedMesh=this,a.bu=l.bu||0,a.bv=l.bv||0,a.subMeshFaceId=l.faceId,a.faceId=l.faceId+c.data[l.subMeshId].indexStart/(-1!==this.getClassName().indexOf("LinesMesh")?2:3),a.subMeshId=l.subMeshId,a}return a},i.prototype.clone=function(e,t,i){return null},i.prototype.releaseSubMeshes=function(){if(this.subMeshes)for(;this.subMeshes.length;)this.subMeshes[0].dispose();else this.subMeshes=new Array;return this},i.prototype.dispose=function(t,i){var r,n=this;for(void 0===i&&(i=!1),this._scene.useMaterialMeshMap&&this._material&&this._material.meshMap&&(this._material.meshMap[this.uniqueId]=void 0),this.getScene().freeActiveMeshes(),this.getScene().freeRenderingGroups(),void 0!==this.actionManager&&null!==this.actionManager&&(this.actionManager.dispose(),this.actionManager=null),this._internalAbstractMeshDataInfo._skeleton=null,this._transformMatrixTexture&&(this._transformMatrixTexture.dispose(),this._transformMatrixTexture=null),r=0;r<this._intersectionsInProgress.length;r++){var o=this._intersectionsInProgress[r],s=o._intersectionsInProgress.indexOf(this);o._intersectionsInProgress.splice(s,1)}this._intersectionsInProgress=[],this.getScene().lights.forEach((function(e){var t=e.includedOnlyMeshes.indexOf(n);-1!==t&&e.includedOnlyMeshes.splice(t,1),-1!==(t=e.excludedMeshes.indexOf(n))&&e.excludedMeshes.splice(t,1);var i=e.getShadowGenerator();if(i){var r=i.getShadowMap();r&&r.renderList&&-1!==(t=r.renderList.indexOf(n))&&r.renderList.splice(t,1)}})),"InstancedMesh"===this.getClassName()&&"InstancedLinesMesh"===this.getClassName()||this.releaseSubMeshes();var a=this.getScene().getEngine();if(this._occlusionQuery&&(this.isOcclusionQueryInProgress=!1,a.deleteQuery(this._occlusionQuery),this._occlusionQuery=null),a.wipeCaches(),this.getScene().removeMesh(this),i&&this.material&&("MultiMaterial"===this.material.getClassName()?this.material.dispose(!1,!0,!0):this.material.dispose(!1,!0)),!t)for(r=0;r<this.getScene().particleSystems.length;r++)this.getScene().particleSystems[r].emitter===this&&(this.getScene().particleSystems[r].dispose(),r--);this._internalAbstractMeshDataInfo._facetData.facetDataEnabled&&this.disableFacetData(),this.onAfterWorldMatrixUpdateObservable.clear(),this.onCollideObservable.clear(),this.onCollisionPositionChangeObservable.clear(),this.onRebuildObservable.clear(),e.prototype.dispose.call(this,t,i)},i.prototype.addChild=function(e){return e.setParent(this),this},i.prototype.removeChild=function(e){return e.setParent(null),this},i.prototype._initFacetData=function(){var e=this._internalAbstractMeshDataInfo._facetData;e.facetNormals||(e.facetNormals=new Array),e.facetPositions||(e.facetPositions=new Array),e.facetPartitioning||(e.facetPartitioning=new Array),e.facetNb=this.getIndices().length/3|0,e.partitioningSubdivisions=e.partitioningSubdivisions?e.partitioningSubdivisions:10,e.partitioningBBoxRatio=e.partitioningBBoxRatio?e.partitioningBBoxRatio:1.01;for(var t=0;t<e.facetNb;t++)e.facetNormals[t]=p.Zero(),e.facetPositions[t]=p.Zero();return e.facetDataEnabled=!0,this},i.prototype.updateFacetData=function(){var e=this._internalAbstractMeshDataInfo._facetData;e.facetDataEnabled||this._initFacetData();var t=this.getVerticesData(ft.PositionKind),i=this.getIndices(),r=this.getVerticesData(ft.NormalKind),n=this.getBoundingInfo();if(e.facetDepthSort&&!e.facetDepthSortEnabled){if(e.facetDepthSortEnabled=!0,i instanceof Uint16Array)e.depthSortedIndices=new Uint16Array(i);else if(i instanceof Uint32Array)e.depthSortedIndices=new Uint32Array(i);else{for(var o=!1,s=0;s<i.length;s++)if(i[s]>65535){o=!0;break}e.depthSortedIndices=o?new Uint32Array(i):new Uint16Array(i)}if(e.facetDepthSortFunction=function(e,t){return t.sqDistance-e.sqDistance},!e.facetDepthSortFrom){var a=this.getScene().activeCamera;e.facetDepthSortFrom=a?a.position:p.Zero()}e.depthSortedFacets=[];for(var h=0;h<e.facetNb;h++){var l={ind:3*h,sqDistance:0};e.depthSortedFacets.push(l)}e.invertedMatrix=m.Identity(),e.facetDepthSortOrigin=p.Zero()}e.bbSize.x=n.maximum.x-n.minimum.x>u?n.maximum.x-n.minimum.x:u,e.bbSize.y=n.maximum.y-n.minimum.y>u?n.maximum.y-n.minimum.y:u,e.bbSize.z=n.maximum.z-n.minimum.z>u?n.maximum.z-n.minimum.z:u;var c=e.bbSize.x>e.bbSize.y?e.bbSize.x:e.bbSize.y;if(c=c>e.bbSize.z?c:e.bbSize.z,e.subDiv.max=e.partitioningSubdivisions,e.subDiv.X=Math.floor(e.subDiv.max*e.bbSize.x/c),e.subDiv.Y=Math.floor(e.subDiv.max*e.bbSize.y/c),e.subDiv.Z=Math.floor(e.subDiv.max*e.bbSize.z/c),e.subDiv.X=e.subDiv.X<1?1:e.subDiv.X,e.subDiv.Y=e.subDiv.Y<1?1:e.subDiv.Y,e.subDiv.Z=e.subDiv.Z<1?1:e.subDiv.Z,e.facetParameters.facetNormals=this.getFacetLocalNormals(),e.facetParameters.facetPositions=this.getFacetLocalPositions(),e.facetParameters.facetPartitioning=this.getFacetLocalPartitioning(),e.facetParameters.bInfo=n,e.facetParameters.bbSize=e.bbSize,e.facetParameters.subDiv=e.subDiv,e.facetParameters.ratio=this.partitioningBBoxRatio,e.facetParameters.depthSort=e.facetDepthSort,e.facetDepthSort&&e.facetDepthSortEnabled&&(this.computeWorldMatrix(!0),this._worldMatrix.invertToRef(e.invertedMatrix),p.TransformCoordinatesToRef(e.facetDepthSortFrom,e.invertedMatrix,e.facetDepthSortOrigin),e.facetParameters.distanceTo=e.facetDepthSortOrigin),e.facetParameters.depthSortedFacets=e.depthSortedFacets,dt.ComputeNormals(t,i,r,e.facetParameters),e.facetDepthSort&&e.facetDepthSortEnabled){e.depthSortedFacets.sort(e.facetDepthSortFunction);var f=e.depthSortedIndices.length/3|0;for(h=0;h<f;h++){var d=e.depthSortedFacets[h].ind;e.depthSortedIndices[3*h]=i[d],e.depthSortedIndices[3*h+1]=i[d+1],e.depthSortedIndices[3*h+2]=i[d+2]}this.updateIndices(e.depthSortedIndices,void 0,!0)}return this},i.prototype.getFacetLocalNormals=function(){var e=this._internalAbstractMeshDataInfo._facetData;return e.facetNormals||this.updateFacetData(),e.facetNormals},i.prototype.getFacetLocalPositions=function(){var e=this._internalAbstractMeshDataInfo._facetData;return e.facetPositions||this.updateFacetData(),e.facetPositions},i.prototype.getFacetLocalPartitioning=function(){var e=this._internalAbstractMeshDataInfo._facetData;return e.facetPartitioning||this.updateFacetData(),e.facetPartitioning},i.prototype.getFacetPosition=function(e){var t=p.Zero();return this.getFacetPositionToRef(e,t),t},i.prototype.getFacetPositionToRef=function(e,t){var i=this.getFacetLocalPositions()[e],r=this.getWorldMatrix();return p.TransformCoordinatesToRef(i,r,t),this},i.prototype.getFacetNormal=function(e){var t=p.Zero();return this.getFacetNormalToRef(e,t),t},i.prototype.getFacetNormalToRef=function(e,t){var i=this.getFacetLocalNormals()[e];return p.TransformNormalToRef(i,this.getWorldMatrix(),t),this},i.prototype.getFacetsAtLocalCoordinates=function(e,t,i){var r=this.getBoundingInfo(),n=this._internalAbstractMeshDataInfo._facetData,o=Math.floor((e-r.minimum.x*n.partitioningBBoxRatio)*n.subDiv.X*n.partitioningBBoxRatio/n.bbSize.x),s=Math.floor((t-r.minimum.y*n.partitioningBBoxRatio)*n.subDiv.Y*n.partitioningBBoxRatio/n.bbSize.y),a=Math.floor((i-r.minimum.z*n.partitioningBBoxRatio)*n.subDiv.Z*n.partitioningBBoxRatio/n.bbSize.z);return o<0||o>n.subDiv.max||s<0||s>n.subDiv.max||a<0||a>n.subDiv.max?null:n.facetPartitioning[o+n.subDiv.max*s+n.subDiv.max*n.subDiv.max*a]},i.prototype.getClosestFacetAtCoordinates=function(e,t,i,r,n,o){void 0===n&&(n=!1),void 0===o&&(o=!0);var s=this.getWorldMatrix(),a=y.Matrix[5];s.invertToRef(a);var h=y.Vector3[8];p.TransformCoordinatesFromFloatsToRef(e,t,i,a,h);var u=this.getClosestFacetAtLocalCoordinates(h.x,h.y,h.z,r,n,o);return r&&p.TransformCoordinatesFromFloatsToRef(r.x,r.y,r.z,s,r),u},i.prototype.getClosestFacetAtLocalCoordinates=function(e,t,i,r,n,o){void 0===n&&(n=!1),void 0===o&&(o=!0);var s=null,a=0,h=0,u=0,l=0,c=0,f=0,d=0,p=0,_=this.getFacetLocalPositions(),g=this.getFacetLocalNormals(),m=this.getFacetsAtLocalCoordinates(e,t,i);if(!m)return null;for(var v,y,b,T=Number.MAX_VALUE,E=T,x=0;x<m.length;x++)y=g[v=m[x]],l=(e-(b=_[v]).x)*y.x+(t-b.y)*y.y+(i-b.z)*y.z,(!n||n&&o&&l>=0||n&&!o&&l<=0)&&(l=y.x*b.x+y.y*b.y+y.z*b.z,c=-(y.x*e+y.y*t+y.z*i-l)/(y.x*y.x+y.y*y.y+y.z*y.z),(E=(a=(f=e+y.x*c)-e)*a+(h=(d=t+y.y*c)-t)*h+(u=(p=i+y.z*c)-i)*u)<T&&(T=E,s=v,r&&(r.x=f,r.y=d,r.z=p)));return s},i.prototype.getFacetDataParameters=function(){return this._internalAbstractMeshDataInfo._facetData.facetParameters},i.prototype.disableFacetData=function(){var e=this._internalAbstractMeshDataInfo._facetData;return e.facetDataEnabled&&(e.facetDataEnabled=!1,e.facetPositions=new Array,e.facetNormals=new Array,e.facetPartitioning=new Array,e.facetParameters=null,e.depthSortedIndices=new Uint32Array(0)),this},i.prototype.updateIndices=function(e,t,i){return this},i.prototype.createNormals=function(e){var t,i=this.getVerticesData(ft.PositionKind),r=this.getIndices();return t=this.isVerticesDataPresent(ft.NormalKind)?this.getVerticesData(ft.NormalKind):[],dt.ComputeNormals(i,r,t,{useRightHandedSystem:this.getScene().useRightHandedSystem}),this.setVerticesData(ft.NormalKind,t,e),this},i.prototype.alignWithNormal=function(e,t){t||(t=Dt.Y);var i=y.Vector3[0],r=y.Vector3[1];return p.CrossToRef(t,e,r),p.CrossToRef(e,r,i),this.rotationQuaternion?g.RotationQuaternionFromAxisToRef(i,e,r,this.rotationQuaternion):p.RotationFromAxisToRef(i,e,r,this.rotation),this},i.prototype._checkOcclusionQuery=function(){return!1},i.prototype.disableEdgesRendering=function(){throw b.WarnImport("EdgesRenderer")},i.prototype.enableEdgesRendering=function(e,t,i){throw b.WarnImport("EdgesRenderer")},i.prototype.getConnectedParticleSystems=function(){var e=this;return this._scene.particleSystems.filter((function(t){return t.emitter===e}))},i.OCCLUSION_TYPE_NONE=0,i.OCCLUSION_TYPE_OPTIMISTIC=1,i.OCCLUSION_TYPE_STRICT=2,i.OCCLUSION_ALGORITHM_TYPE_ACCURATE=0,i.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE=1,i.CULLINGSTRATEGY_STANDARD=0,i.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY=1,i.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION=2,i.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY=3,i}(wt);c.RegisteredTypes["BABYLON.AbstractMesh"]=kt,be.prototype.createUniformBuffer=function(e){var t=this._gl.createBuffer();if(!t)throw new Error("Unable to create uniform buffer");var i=new ge(t);return this.bindUniformBuffer(i),e instanceof Float32Array?this._gl.bufferData(this._gl.UNIFORM_BUFFER,e,this._gl.STATIC_DRAW):this._gl.bufferData(this._gl.UNIFORM_BUFFER,new Float32Array(e),this._gl.STATIC_DRAW),this.bindUniformBuffer(null),i.references=1,i},be.prototype.createDynamicUniformBuffer=function(e){var t=this._gl.createBuffer();if(!t)throw new Error("Unable to create dynamic uniform buffer");var i=new ge(t);return this.bindUniformBuffer(i),e instanceof Float32Array?this._gl.bufferData(this._gl.UNIFORM_BUFFER,e,this._gl.DYNAMIC_DRAW):this._gl.bufferData(this._gl.UNIFORM_BUFFER,new Float32Array(e),this._gl.DYNAMIC_DRAW),this.bindUniformBuffer(null),i.references=1,i},be.prototype.updateUniformBuffer=function(e,t,i,r){this.bindUniformBuffer(e),void 0===i&&(i=0),void 0===r?t instanceof Float32Array?this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,i,t):this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,i,new Float32Array(t)):t instanceof Float32Array?this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,0,t.subarray(i,i+r)):this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,0,new Float32Array(t).subarray(i,i+r)),this.bindUniformBuffer(null)},be.prototype.bindUniformBuffer=function(e){this._gl.bindBuffer(this._gl.UNIFORM_BUFFER,e?e.underlyingResource:null)},be.prototype.bindUniformBufferBase=function(e,t){this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER,t,e?e.underlyingResource:null)},be.prototype.bindUniformBlock=function(e,t,i){var r=e.program,n=this._gl.getUniformBlockIndex(r,t);this._gl.uniformBlockBinding(r,n,i)};var Ut=function(){function e(e,t,i){this._alreadyBound=!1,this._valueCache={},this._engine=e,this._noUBO=!e.supportsUniformBuffers,this._dynamic=i,this._data=t||[],this._uniformLocations={},this._uniformSizes={},this._uniformLocationPointer=0,this._needSync=!1,this._noUBO?(this.updateMatrix3x3=this._updateMatrix3x3ForEffect,this.updateMatrix2x2=this._updateMatrix2x2ForEffect,this.updateFloat=this._updateFloatForEffect,this.updateFloat2=this._updateFloat2ForEffect,this.updateFloat3=this._updateFloat3ForEffect,this.updateFloat4=this._updateFloat4ForEffect,this.updateMatrix=this._updateMatrixForEffect,this.updateVector3=this._updateVector3ForEffect,this.updateVector4=this._updateVector4ForEffect,this.updateColor3=this._updateColor3ForEffect,this.updateColor4=this._updateColor4ForEffect):(this._engine._uniformBuffers.push(this),this.updateMatrix3x3=this._updateMatrix3x3ForUniform,this.updateMatrix2x2=this._updateMatrix2x2ForUniform,this.updateFloat=this._updateFloatForUniform,this.updateFloat2=this._updateFloat2ForUniform,this.updateFloat3=this._updateFloat3ForUniform,this.updateFloat4=this._updateFloat4ForUniform,this.updateMatrix=this._updateMatrixForUniform,this.updateVector3=this._updateVector3ForUniform,this.updateVector4=this._updateVector4ForUniform,this.updateColor3=this._updateColor3ForUniform,this.updateColor4=this._updateColor4ForUniform)}return Object.defineProperty(e.prototype,"useUbo",{get:function(){return!this._noUBO},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isSync",{get:function(){return!this._needSync},enumerable:!1,configurable:!0}),e.prototype.isDynamic=function(){return void 0!==this._dynamic},e.prototype.getData=function(){return this._bufferData},e.prototype.getBuffer=function(){return this._buffer},e.prototype._fillAlignment=function(e){var t;if(t=e<=2?e:4,this._uniformLocationPointer%t!=0){var i=this._uniformLocationPointer;this._uniformLocationPointer+=t-this._uniformLocationPointer%t;for(var r=this._uniformLocationPointer-i,n=0;n<r;n++)this._data.push(0)}},e.prototype.addUniform=function(e,t){if(!this._noUBO&&void 0===this._uniformLocations[e]){var i;if(t instanceof Array)t=(i=t).length;else{i=[];for(var r=0;r<t;r++)i.push(0)}this._fillAlignment(t),this._uniformSizes[e]=t,this._uniformLocations[e]=this._uniformLocationPointer,this._uniformLocationPointer+=t;for(r=0;r<t;r++)this._data.push(i[r]);this._needSync=!0}},e.prototype.addMatrix=function(e,t){this.addUniform(e,Array.prototype.slice.call(t.toArray()))},e.prototype.addFloat2=function(e,t,i){var r=[t,i];this.addUniform(e,r)},e.prototype.addFloat3=function(e,t,i,r){var n=[t,i,r];this.addUniform(e,n)},e.prototype.addColor3=function(e,t){var i=new Array;t.toArray(i),this.addUniform(e,i)},e.prototype.addColor4=function(e,t,i){var r=new Array;t.toArray(r),r.push(i),this.addUniform(e,r)},e.prototype.addVector3=function(e,t){var i=new Array;t.toArray(i),this.addUniform(e,i)},e.prototype.addMatrix3x3=function(e){this.addUniform(e,12)},e.prototype.addMatrix2x2=function(e){this.addUniform(e,8)},e.prototype.create=function(){this._noUBO||this._buffer||(this._fillAlignment(4),this._bufferData=new Float32Array(this._data),this._rebuild(),this._needSync=!0)},e.prototype._rebuild=function(){!this._noUBO&&this._bufferData&&(this._dynamic?this._buffer=this._engine.createDynamicUniformBuffer(this._bufferData):this._buffer=this._engine.createUniformBuffer(this._bufferData))},e.prototype.update=function(){this._buffer?(this._dynamic||this._needSync)&&(this._engine.updateUniformBuffer(this._buffer,this._bufferData),this._needSync=!1):this.create()},e.prototype.updateUniform=function(e,t,i){var r=this._uniformLocations[e];if(void 0===r){if(this._buffer)return void q.Error("Cannot add an uniform after UBO has been created.");this.addUniform(e,i),r=this._uniformLocations[e]}if(this._buffer||this.create(),this._dynamic)for(o=0;o<i;o++)this._bufferData[r+o]=t[o];else{for(var n=!1,o=0;o<i;o++)16!==i&&this._bufferData[r+o]===t[o]||(n=!0,this._bufferData[r+o]=t[o]);this._needSync=this._needSync||n}},e.prototype._cacheMatrix=function(e,t){var i=this._valueCache[e],r=t.updateFlag;return(void 0===i||i!==r)&&(this._valueCache[e]=r,!0)},e.prototype._updateMatrix3x3ForUniform=function(t,i){for(var r=0;r<3;r++)e._tempBuffer[4*r]=i[3*r],e._tempBuffer[4*r+1]=i[3*r+1],e._tempBuffer[4*r+2]=i[3*r+2],e._tempBuffer[4*r+3]=0;this.updateUniform(t,e._tempBuffer,12)},e.prototype._updateMatrix3x3ForEffect=function(e,t){this._currentEffect.setMatrix3x3(e,t)},e.prototype._updateMatrix2x2ForEffect=function(e,t){this._currentEffect.setMatrix2x2(e,t)},e.prototype._updateMatrix2x2ForUniform=function(t,i){for(var r=0;r<2;r++)e._tempBuffer[4*r]=i[2*r],e._tempBuffer[4*r+1]=i[2*r+1],e._tempBuffer[4*r+2]=0,e._tempBuffer[4*r+3]=0;this.updateUniform(t,e._tempBuffer,8)},e.prototype._updateFloatForEffect=function(e,t){this._currentEffect.setFloat(e,t)},e.prototype._updateFloatForUniform=function(t,i){e._tempBuffer[0]=i,this.updateUniform(t,e._tempBuffer,1)},e.prototype._updateFloat2ForEffect=function(e,t,i,r){void 0===r&&(r=""),this._currentEffect.setFloat2(e+r,t,i)},e.prototype._updateFloat2ForUniform=function(t,i,r){e._tempBuffer[0]=i,e._tempBuffer[1]=r,this.updateUniform(t,e._tempBuffer,2)},e.prototype._updateFloat3ForEffect=function(e,t,i,r,n){void 0===n&&(n=""),this._currentEffect.setFloat3(e+n,t,i,r)},e.prototype._updateFloat3ForUniform=function(t,i,r,n){e._tempBuffer[0]=i,e._tempBuffer[1]=r,e._tempBuffer[2]=n,this.updateUniform(t,e._tempBuffer,3)},e.prototype._updateFloat4ForEffect=function(e,t,i,r,n,o){void 0===o&&(o=""),this._currentEffect.setFloat4(e+o,t,i,r,n)},e.prototype._updateFloat4ForUniform=function(t,i,r,n,o){e._tempBuffer[0]=i,e._tempBuffer[1]=r,e._tempBuffer[2]=n,e._tempBuffer[3]=o,this.updateUniform(t,e._tempBuffer,4)},e.prototype._updateMatrixForEffect=function(e,t){this._currentEffect.setMatrix(e,t)},e.prototype._updateMatrixForUniform=function(e,t){this._cacheMatrix(e,t)&&this.updateUniform(e,t.toArray(),16)},e.prototype._updateVector3ForEffect=function(e,t){this._currentEffect.setVector3(e,t)},e.prototype._updateVector3ForUniform=function(t,i){i.toArray(e._tempBuffer),this.updateUniform(t,e._tempBuffer,3)},e.prototype._updateVector4ForEffect=function(e,t){this._currentEffect.setVector4(e,t)},e.prototype._updateVector4ForUniform=function(t,i){i.toArray(e._tempBuffer),this.updateUniform(t,e._tempBuffer,4)},e.prototype._updateColor3ForEffect=function(e,t,i){void 0===i&&(i=""),this._currentEffect.setColor3(e+i,t)},e.prototype._updateColor3ForUniform=function(t,i){i.toArray(e._tempBuffer),this.updateUniform(t,e._tempBuffer,3)},e.prototype._updateColor4ForEffect=function(e,t,i,r){void 0===r&&(r=""),this._currentEffect.setColor4(e+r,t,i)},e.prototype._updateColor4ForUniform=function(t,i,r){i.toArray(e._tempBuffer),e._tempBuffer[3]=r,this.updateUniform(t,e._tempBuffer,4)},e.prototype.setTexture=function(e,t){this._currentEffect.setTexture(e,t)},e.prototype.updateUniformDirectly=function(e,t){this.updateUniform(e,t,t.length),this.update()},e.prototype.bindToEffect=function(e,t){this._currentEffect=e,!this._noUBO&&this._buffer&&(this._alreadyBound=!0,e.bindUniformBuffer(this._buffer,t))},e.prototype.dispose=function(){if(!this._noUBO){var e=this._engine._uniformBuffers,t=e.indexOf(this);-1!==t&&(e[t]=e[e.length-1],e.pop()),this._buffer&&this._engine._releaseBuffer(this._buffer)&&(this._buffer=null)}},e._MAX_UNIFORM_SIZE=256,e._tempBuffer=new Float32Array(e._MAX_UNIFORM_SIZE),e}(),Vt=function(){function e(t,i,r){this.shadowDepthWrapper=null,this.allowShaderHotSwapping=!0,this.metadata=null,this.reservedDataStore=null,this.checkReadyOnEveryCall=!1,this.checkReadyOnlyOnce=!1,this.state="",this._alpha=1,this._backFaceCulling=!0,this.onCompiled=null,this.onError=null,this.getRenderTargetTextures=null,this.doNotSerialize=!1,this._storeEffectOnSubMeshes=!1,this.animations=null,this.onDisposeObservable=new U,this._onDisposeObserver=null,this._onUnBindObservable=null,this._onBindObserver=null,this._alphaMode=2,this._needDepthPrePass=!1,this.disableDepthWrite=!1,this.disableColorWrite=!1,this.forceDepthWrite=!1,this.depthFunction=0,this.separateCullingPass=!1,this._fogEnabled=!0,this.pointSize=1,this.zOffset=0,this._effect=null,this._useUBO=!1,this._fillMode=e.TriangleFillMode,this._cachedDepthWriteState=!1,this._cachedColorWriteState=!1,this._cachedDepthFunctionState=0,this._indexInSceneMaterialArray=-1,this.meshMap=null,this._forceAlphaTest=!1,this._transparencyMode=null,this.name=t;var n=1;for(this._scene=i||V.LastCreatedScene,this.id=t||Ue.RandomId();this._scene.getMaterialByID(this.id);)this.id=t+" "+n++;this.uniqueId=this._scene.getUniqueId(),this._scene.useRightHandedSystem?this.sideOrientation=e.ClockWiseSideOrientation:this.sideOrientation=e.CounterClockWiseSideOrientation,this._uniformBuffer=new Ut(this._scene.getEngine()),this._useUBO=this.getScene().getEngine().supportsUniformBuffers,r||this._scene.addMaterial(this),this._scene.useMaterialMeshMap&&(this.meshMap={})}return Object.defineProperty(e.prototype,"canRenderToMRT",{get:function(){return!1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"alpha",{get:function(){return this._alpha},set:function(t){this._alpha!==t&&(this._alpha=t,this.markAsDirty(e.MiscDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"backFaceCulling",{get:function(){return this._backFaceCulling},set:function(t){this._backFaceCulling!==t&&(this._backFaceCulling=t,this.markAsDirty(e.TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasRenderTargetTextures",{get:function(){return!1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onBindObservable",{get:function(){return this._onBindObservable||(this._onBindObservable=new U),this._onBindObservable},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onBind",{set:function(e){this._onBindObserver&&this.onBindObservable.remove(this._onBindObserver),this._onBindObserver=this.onBindObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onUnBindObservable",{get:function(){return this._onUnBindObservable||(this._onUnBindObservable=new U),this._onUnBindObservable},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onEffectCreatedObservable",{get:function(){return this._onEffectCreatedObservable||(this._onEffectCreatedObservable=new U),this._onEffectCreatedObservable},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"alphaMode",{get:function(){return this._alphaMode},set:function(t){this._alphaMode!==t&&(this._alphaMode=t,this.markAsDirty(e.TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"needDepthPrePass",{get:function(){return this._needDepthPrePass},set:function(e){this._needDepthPrePass!==e&&(this._needDepthPrePass=e,this._needDepthPrePass&&(this.checkReadyOnEveryCall=!0))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fogEnabled",{get:function(){return this._fogEnabled},set:function(t){this._fogEnabled!==t&&(this._fogEnabled=t,this.markAsDirty(e.MiscDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"wireframe",{get:function(){switch(this._fillMode){case e.WireFrameFillMode:case e.LineListDrawMode:case e.LineLoopDrawMode:case e.LineStripDrawMode:return!0}return this._scene.forceWireframe},set:function(t){this.fillMode=t?e.WireFrameFillMode:e.TriangleFillMode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pointsCloud",{get:function(){switch(this._fillMode){case e.PointFillMode:case e.PointListDrawMode:return!0}return this._scene.forcePointsCloud},set:function(t){this.fillMode=t?e.PointFillMode:e.TriangleFillMode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fillMode",{get:function(){return this._fillMode},set:function(t){this._fillMode!==t&&(this._fillMode=t,this.markAsDirty(e.MiscDirtyFlag))},enumerable:!1,configurable:!0}),e.prototype.toString=function(e){return"Name: "+this.name},e.prototype.getClassName=function(){return"Material"},Object.defineProperty(e.prototype,"isFrozen",{get:function(){return this.checkReadyOnlyOnce},enumerable:!1,configurable:!0}),e.prototype.freeze=function(){this.markDirty(),this.checkReadyOnlyOnce=!0},e.prototype.unfreeze=function(){this.markDirty(),this.checkReadyOnlyOnce=!1},e.prototype.isReady=function(e,t){return!0},e.prototype.isReadyForSubMesh=function(e,t,i){return!1},e.prototype.getEffect=function(){return this._effect},e.prototype.getScene=function(){return this._scene},Object.defineProperty(e.prototype,"transparencyMode",{get:function(){return this._transparencyMode},set:function(t){this._transparencyMode!==t&&(this._transparencyMode=t,this._forceAlphaTest=t===e.MATERIAL_ALPHATESTANDBLEND,this._markAllSubMeshesAsTexturesAndMiscDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_disableAlphaBlending",{get:function(){return this._transparencyMode===e.MATERIAL_OPAQUE||this._transparencyMode===e.MATERIAL_ALPHATEST},enumerable:!1,configurable:!0}),e.prototype.needAlphaBlending=function(){return!this._disableAlphaBlending&&this.alpha<1},e.prototype.needAlphaBlendingForMesh=function(e){return!(this._disableAlphaBlending&&e.visibility>=1)&&(this.needAlphaBlending()||e.visibility<1||e.hasVertexAlpha)},e.prototype.needAlphaTesting=function(){return!!this._forceAlphaTest},e.prototype._shouldTurnAlphaTestOn=function(e){return!this.needAlphaBlendingForMesh(e)&&this.needAlphaTesting()},e.prototype.getAlphaTestTexture=function(){return null},e.prototype.markDirty=function(){for(var e=0,t=this.getScene().meshes;e<t.length;e++){var i=t[e];if(i.subMeshes)for(var r=0,n=i.subMeshes;r<n.length;r++){var o=n[r];o.getMaterial()===this&&(o.effect&&(o.effect._wasPreviouslyReady=!1))}}},e.prototype._preBind=function(t,i){void 0===i&&(i=null);var r=this._scene.getEngine(),n=(null==i?this.sideOrientation:i)===e.ClockWiseSideOrientation;return r.enableEffect(t||this._effect),r.setState(this.backFaceCulling,this.zOffset,!1,n),n},e.prototype.bind=function(e,t){},e.prototype.bindForSubMesh=function(e,t,i){},e.prototype.bindOnlyWorldMatrix=function(e){},e.prototype.bindSceneUniformBuffer=function(e,t){t.bindToEffect(e,"Scene")},e.prototype.bindView=function(e){this._useUBO?this.bindSceneUniformBuffer(e,this.getScene().getSceneUniformBuffer()):e.setMatrix("view",this.getScene().getViewMatrix())},e.prototype.bindViewProjection=function(e){this._useUBO?this.bindSceneUniformBuffer(e,this.getScene().getSceneUniformBuffer()):e.setMatrix("viewProjection",this.getScene().getTransformMatrix())},e.prototype._afterBind=function(e){if(this._scene._cachedMaterial=this,this._scene._cachedVisibility=e?e.visibility:1,this._onBindObservable&&e&&this._onBindObservable.notifyObservers(e),this.disableDepthWrite){var t=this._scene.getEngine();this._cachedDepthWriteState=t.getDepthWrite(),t.setDepthWrite(!1)}if(this.disableColorWrite){t=this._scene.getEngine();this._cachedColorWriteState=t.getColorWrite(),t.setColorWrite(!1)}if(0!==this.depthFunction){t=this._scene.getEngine();this._cachedDepthFunctionState=t.getDepthFunction()||0,t.setDepthFunction(this.depthFunction)}},e.prototype.unbind=function(){(this._onUnBindObservable&&this._onUnBindObservable.notifyObservers(this),0!==this.depthFunction)&&this._scene.getEngine().setDepthFunction(this._cachedDepthFunctionState);this.disableDepthWrite&&this._scene.getEngine().setDepthWrite(this._cachedDepthWriteState);this.disableColorWrite&&this._scene.getEngine().setColorWrite(this._cachedColorWriteState)},e.prototype.getActiveTextures=function(){return[]},e.prototype.hasTexture=function(e){return!1},e.prototype.clone=function(e){return null},e.prototype.getBindedMeshes=function(){var e=this;if(this.meshMap){var t=new Array;for(var i in this.meshMap){var r=this.meshMap[i];r&&t.push(r)}return t}return this._scene.meshes.filter((function(t){return t.material===e}))},e.prototype.forceCompilation=function(e,t,r,n){var o=this,s=i({clipPlane:!1,useInstances:!1},r),a=this.getScene(),h=this.allowShaderHotSwapping;this.allowShaderHotSwapping=!1;var u=function(){if(o._scene&&o._scene.getEngine()){var i=a.clipPlane;if(s.clipPlane&&(a.clipPlane=new Ie(0,0,0,1)),o._storeEffectOnSubMeshes){var r=!0,l=null;if(e.subMeshes){var c=new xt(0,0,0,0,0,e,void 0,!1,!1);c._materialDefines&&(c._materialDefines._renderId=-1),o.isReadyForSubMesh(e,c,s.useInstances)||(c.effect&&c.effect.getCompilationError()&&c.effect.allFallbacksProcessed()?l=c.effect.getCompilationError():(r=!1,setTimeout(u,16)))}r&&(o.allowShaderHotSwapping=h,l&&n&&n(l),t&&t(o))}else o.isReady()?(o.allowShaderHotSwapping=h,t&&t(o)):setTimeout(u,16);s.clipPlane&&(a.clipPlane=i)}};u()},e.prototype.forceCompilationAsync=function(e,t){var i=this;return new Promise((function(r,n){i.forceCompilation(e,(function(){r()}),t,(function(e){n(e)}))}))},e.prototype.markAsDirty=function(t){this.getScene().blockMaterialDirtyMechanism||(e._DirtyCallbackArray.length=0,t&e.TextureDirtyFlag&&e._DirtyCallbackArray.push(e._TextureDirtyCallBack),t&e.LightDirtyFlag&&e._DirtyCallbackArray.push(e._LightsDirtyCallBack),t&e.FresnelDirtyFlag&&e._DirtyCallbackArray.push(e._FresnelDirtyCallBack),t&e.AttributesDirtyFlag&&e._DirtyCallbackArray.push(e._AttributeDirtyCallBack),t&e.MiscDirtyFlag&&e._DirtyCallbackArray.push(e._MiscDirtyCallBack),t&e.PrePassDirtyFlag&&e._DirtyCallbackArray.push(e._PrePassDirtyCallBack),e._DirtyCallbackArray.length&&this._markAllSubMeshesAsDirty(e._RunDirtyCallBacks),this.getScene().resetCachedMaterial())},e.prototype._markAllSubMeshesAsDirty=function(e){if(!this.getScene().blockMaterialDirtyMechanism)for(var t=0,i=this.getScene().meshes;t<i.length;t++){var r=i[t];if(r.subMeshes)for(var n=0,o=r.subMeshes;n<o.length;n++){var s=o[n];s.getMaterial()===this&&(s._materialDefines&&e(s._materialDefines))}}},e.prototype._markScenePrePassDirty=function(){if(!this.getScene().blockMaterialDirtyMechanism){var e=this.getScene().enablePrePassRenderer();e&&e.markAsDirty()}},e.prototype._markAllSubMeshesAsAllDirty=function(){this._markAllSubMeshesAsDirty(e._AllDirtyCallBack)},e.prototype._markAllSubMeshesAsImageProcessingDirty=function(){this._markAllSubMeshesAsDirty(e._ImageProcessingDirtyCallBack)},e.prototype._markAllSubMeshesAsTexturesDirty=function(){this._markAllSubMeshesAsDirty(e._TextureDirtyCallBack)},e.prototype._markAllSubMeshesAsFresnelDirty=function(){this._markAllSubMeshesAsDirty(e._FresnelDirtyCallBack)},e.prototype._markAllSubMeshesAsFresnelAndMiscDirty=function(){this._markAllSubMeshesAsDirty(e._FresnelAndMiscDirtyCallBack)},e.prototype._markAllSubMeshesAsLightsDirty=function(){this._markAllSubMeshesAsDirty(e._LightsDirtyCallBack)},e.prototype._markAllSubMeshesAsAttributesDirty=function(){this._markAllSubMeshesAsDirty(e._AttributeDirtyCallBack)},e.prototype._markAllSubMeshesAsMiscDirty=function(){this._markAllSubMeshesAsDirty(e._MiscDirtyCallBack)},e.prototype._markAllSubMeshesAsPrePassDirty=function(){this._markAllSubMeshesAsDirty(e._MiscDirtyCallBack)},e.prototype._markAllSubMeshesAsTexturesAndMiscDirty=function(){this._markAllSubMeshesAsDirty(e._TextureAndMiscDirtyCallBack)},e.prototype.setPrePassRenderer=function(e){return!1},e.prototype.dispose=function(e,t,i){var r=this.getScene();if(r.stopAnimation(this),r.freeProcessedMaterials(),r.removeMaterial(this),!0!==i)if(this.meshMap)for(var n in this.meshMap){(a=this.meshMap[n])&&(a.material=null,this.releaseVertexArrayObject(a,e))}else for(var o=0,s=r.meshes;o<s.length;o++){var a;(a=s[o]).material!==this||a.sourceMesh||(a.material=null,this.releaseVertexArrayObject(a,e))}this._uniformBuffer.dispose(),e&&this._effect&&(this._storeEffectOnSubMeshes||this._effect.dispose(),this._effect=null),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this._onBindObservable&&this._onBindObservable.clear(),this._onUnBindObservable&&this._onUnBindObservable.clear(),this._onEffectCreatedObservable&&this._onEffectCreatedObservable.clear()},e.prototype.releaseVertexArrayObject=function(e,t){if(e.geometry){var i=e.geometry;if(this._storeEffectOnSubMeshes)for(var r=0,n=e.subMeshes;r<n.length;r++){var o=n[r];i._releaseVertexArrayObject(o._materialEffect),t&&o._materialEffect&&o._materialEffect.dispose()}else i._releaseVertexArrayObject(this._effect)}},e.prototype.serialize=function(){return N.Serialize(this)},e.Parse=function(e,t,i){if(e.customType){if("BABYLON.PBRMaterial"===e.customType&&e.overloadedAlbedo&&(e.customType="BABYLON.LegacyPBRMaterial",!BABYLON.LegacyPBRMaterial))return q.Error("Your scene is trying to load a legacy version of the PBRMaterial, please, include it from the materials library."),null}else e.customType="BABYLON.StandardMaterial";return Ue.Instantiate(e.customType).Parse(e,t,i)},e.TriangleFillMode=0,e.WireFrameFillMode=1,e.PointFillMode=2,e.PointListDrawMode=3,e.LineListDrawMode=4,e.LineLoopDrawMode=5,e.LineStripDrawMode=6,e.TriangleStripDrawMode=7,e.TriangleFanDrawMode=8,e.ClockWiseSideOrientation=0,e.CounterClockWiseSideOrientation=1,e.TextureDirtyFlag=1,e.LightDirtyFlag=2,e.FresnelDirtyFlag=4,e.AttributesDirtyFlag=8,e.MiscDirtyFlag=16,e.PrePassDirtyFlag=32,e.AllDirtyFlag=63,e.MATERIAL_OPAQUE=0,e.MATERIAL_ALPHATEST=1,e.MATERIAL_ALPHABLEND=2,e.MATERIAL_ALPHATESTANDBLEND=3,e.MATERIAL_NORMALBLENDMETHOD_WHITEOUT=0,e.MATERIAL_NORMALBLENDMETHOD_RNM=1,e._AllDirtyCallBack=function(e){return e.markAllAsDirty()},e._ImageProcessingDirtyCallBack=function(e){return e.markAsImageProcessingDirty()},e._TextureDirtyCallBack=function(e){return e.markAsTexturesDirty()},e._FresnelDirtyCallBack=function(e){return e.markAsFresnelDirty()},e._MiscDirtyCallBack=function(e){return e.markAsMiscDirty()},e._PrePassDirtyCallBack=function(e){return e.markAsPrePassDirty()},e._LightsDirtyCallBack=function(e){return e.markAsLightDirty()},e._AttributeDirtyCallBack=function(e){return e.markAsAttributesDirty()},e._FresnelAndMiscDirtyCallBack=function(t){e._FresnelDirtyCallBack(t),e._MiscDirtyCallBack(t)},e._TextureAndMiscDirtyCallBack=function(t){e._TextureDirtyCallBack(t),e._MiscDirtyCallBack(t)},e._DirtyCallbackArray=[],e._RunDirtyCallBacks=function(t){for(var i=0,r=e._DirtyCallbackArray;i<r.length;i++){(0,r[i])(t)}},r([O()],e.prototype,"id",void 0),r([O()],e.prototype,"uniqueId",void 0),r([O()],e.prototype,"name",void 0),r([O()],e.prototype,"checkReadyOnEveryCall",void 0),r([O()],e.prototype,"checkReadyOnlyOnce",void 0),r([O()],e.prototype,"state",void 0),r([O("alpha")],e.prototype,"_alpha",void 0),r([O("backFaceCulling")],e.prototype,"_backFaceCulling",void 0),r([O()],e.prototype,"sideOrientation",void 0),r([O("alphaMode")],e.prototype,"_alphaMode",void 0),r([O()],e.prototype,"_needDepthPrePass",void 0),r([O()],e.prototype,"disableDepthWrite",void 0),r([O()],e.prototype,"disableColorWrite",void 0),r([O()],e.prototype,"forceDepthWrite",void 0),r([O()],e.prototype,"depthFunction",void 0),r([O()],e.prototype,"separateCullingPass",void 0),r([O("fogEnabled")],e.prototype,"_fogEnabled",void 0),r([O()],e.prototype,"pointSize",void 0),r([O()],e.prototype,"zOffset",void 0),r([O()],e.prototype,"pointsCloud",null),r([O()],e.prototype,"fillMode",null),r([O()],e.prototype,"transparencyMode",null),e}(),Wt=function(e){function i(t,i){var r=e.call(this,t,i,!0)||this;return i.multiMaterials.push(r),r.subMaterials=new Array,r._storeEffectOnSubMeshes=!0,r}return t(i,e),Object.defineProperty(i.prototype,"subMaterials",{get:function(){return this._subMaterials},set:function(e){this._subMaterials=e,this._hookArray(e)},enumerable:!1,configurable:!0}),i.prototype.getChildren=function(){return this.subMaterials},i.prototype._hookArray=function(e){var t=this,i=e.push;e.push=function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];var o=i.apply(e,r);return t._markAllSubMeshesAsTexturesDirty(),o};var r=e.splice;e.splice=function(i,n){var o=r.apply(e,[i,n]);return t._markAllSubMeshesAsTexturesDirty(),o}},i.prototype.getSubMaterial=function(e){return e<0||e>=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[e]},i.prototype.getActiveTextures=function(){var t;return(t=e.prototype.getActiveTextures.call(this)).concat.apply(t,this.subMaterials.map((function(e){return e?e.getActiveTextures():[]})))},i.prototype.hasTexture=function(t){var i;if(e.prototype.hasTexture.call(this,t))return!0;for(var r=0;r<this.subMaterials.length;r++)if(null===(i=this.subMaterials[r])||void 0===i?void 0:i.hasTexture(t))return!0;return!1},i.prototype.getClassName=function(){return"MultiMaterial"},i.prototype.isReadyForSubMesh=function(e,t,i){for(var r=0;r<this.subMaterials.length;r++){var n=this.subMaterials[r];if(n){if(n._storeEffectOnSubMeshes){if(!n.isReadyForSubMesh(e,t,i))return!1;continue}if(!n.isReady(e))return!1}}return!0},i.prototype.clone=function(e,t){for(var r=new i(e,this.getScene()),n=0;n<this.subMaterials.length;n++){var o=null,s=this.subMaterials[n];o=t&&s?s.clone(e+"-"+s.name):this.subMaterials[n],r.subMaterials.push(o)}return r},i.prototype.serialize=function(){var e={};e.name=this.name,e.id=this.id,o&&(e.tags=o.GetTags(this)),e.materials=[];for(var t=0;t<this.subMaterials.length;t++){var i=this.subMaterials[t];i?e.materials.push(i.id):e.materials.push(null)}return e},i.prototype.dispose=function(t,i,r){var n=this.getScene();if(n){if(r)for(var o=0;o<this.subMaterials.length;o++){var s=this.subMaterials[o];s&&s.dispose(t,i)}(o=n.multiMaterials.indexOf(this))>=0&&n.multiMaterials.splice(o,1),e.prototype.dispose.call(this,t,i)}},i.ParseMultiMaterial=function(e,t){var r=new i(e.name,t);r.id=e.id,o&&o.AddTagsTo(r,e.tags);for(var n=0;n<e.materials.length;n++){var s=e.materials[n];s?r.subMaterials.push(t.getLastMaterialByID(s)):r.subMaterials.push(null)}return r},i}(Vt);c.RegisteredTypes["BABYLON.MultiMaterial"]=Wt;var zt=function(){function e(){}return e.NAME_EFFECTLAYER="EffectLayer",e.NAME_LAYER="Layer",e.NAME_LENSFLARESYSTEM="LensFlareSystem",e.NAME_BOUNDINGBOXRENDERER="BoundingBoxRenderer",e.NAME_PARTICLESYSTEM="ParticleSystem",e.NAME_GAMEPAD="Gamepad",e.NAME_SIMPLIFICATIONQUEUE="SimplificationQueue",e.NAME_GEOMETRYBUFFERRENDERER="GeometryBufferRenderer",e.NAME_PREPASSRENDERER="PrePassRenderer",e.NAME_DEPTHRENDERER="DepthRenderer",e.NAME_POSTPROCESSRENDERPIPELINEMANAGER="PostProcessRenderPipelineManager",e.NAME_SPRITE="Sprite",e.NAME_SUBSURFACE="SubSurface",e.NAME_OUTLINERENDERER="Outline",e.NAME_PROCEDURALTEXTURE="ProceduralTexture",e.NAME_SHADOWGENERATOR="ShadowGenerator",e.NAME_OCTREE="Octree",e.NAME_PHYSICSENGINE="PhysicsEngine",e.NAME_AUDIO="Audio",e.STEP_ISREADYFORMESH_EFFECTLAYER=0,e.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER=0,e.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER=0,e.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER=0,e.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER=1,e.STEP_BEFORECAMERADRAW_EFFECTLAYER=0,e.STEP_BEFORECAMERADRAW_LAYER=1,e.STEP_BEFORECAMERADRAW_PREPASS=2,e.STEP_BEFORERENDERTARGETDRAW_LAYER=0,e.STEP_BEFORERENDERINGMESH_PREPASS=0,e.STEP_BEFORERENDERINGMESH_OUTLINE=1,e.STEP_AFTERRENDERINGMESH_PREPASS=0,e.STEP_AFTERRENDERINGMESH_OUTLINE=1,e.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW=0,e.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER=1,e.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE=0,e.STEP_BEFORECAMERAUPDATE_GAMEPAD=1,e.STEP_BEFORECLEAR_PROCEDURALTEXTURE=0,e.STEP_AFTERRENDERTARGETDRAW_LAYER=0,e.STEP_AFTERCAMERADRAW_EFFECTLAYER=0,e.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM=1,e.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW=2,e.STEP_AFTERCAMERADRAW_LAYER=3,e.STEP_AFTERCAMERADRAW_PREPASS=4,e.STEP_AFTERRENDER_AUDIO=0,e.STEP_GATHERRENDERTARGETS_DEPTHRENDERER=0,e.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER=1,e.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR=2,e.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER=3,e.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER=0,e.STEP_BEFORECLEARSTAGE_PREPASS=0,e.STEP_POINTERMOVE_SPRITE=0,e.STEP_POINTERDOWN_SPRITE=0,e.STEP_POINTERUP_SPRITE=0,e}(),Gt=function(e){function i(t){return e.apply(this,t)||this}return t(i,e),i.Create=function(){return Object.create(i.prototype)},i.prototype.registerStep=function(e,t,i){var r=0;for(Number.MAX_VALUE;r<this.length;r++){if(e<this[r].index)break}this.splice(r,0,{index:e,component:t,action:i.bind(t)})},i.prototype.clear=function(){this.length=0},i}(Array),Ht=function(e,t){this.distance=e,this.mesh=t},Xt=function(){},jt=function(){this.visibleInstances={},this.batchCache=new Kt,this.instancesBufferSize=2048},Kt=function(){this.mustReturn=!1,this.visibleInstances=new Array,this.renderSelf=new Array,this.hardwareInstancedRendering=new Array},Yt=function(){this.instancesCount=0,this.matrixBuffer=null,this.matrixBufferSize=512,this.boundingVectors=[],this.worldMatrices=null},qt=function(){this._areNormalsFrozen=!1,this._source=null,this.meshMap=null,this._preActivateId=-1,this._LODLevels=new Array,this._morphTargetManager=null},Zt=function(e){function i(t,r,n,s,a,h){void 0===r&&(r=null),void 0===n&&(n=null),void 0===s&&(s=null),void 0===h&&(h=!0);var u=e.call(this,t,r)||this;if(u._internalMeshDataInfo=new qt,u.delayLoadState=0,u.instances=new Array,u._creationDataStorage=null,u._geometry=null,u._instanceDataStorage=new jt,u._thinInstanceDataStorage=new Yt,u._effectiveMaterial=null,u._shouldGenerateFlatShading=!1,u._originalBuilderSideOrientation=i.DEFAULTSIDE,u.overrideMaterialSideOrientation=null,r=u.getScene(),s){if(s._geometry&&s._geometry.applyToMesh(u),Le.DeepCopy(s,u,["name","material","skeleton","instances","parent","uniqueId","source","metadata","morphTargetManager","hasInstances","source","worldMatrixInstancedBuffer","hasLODLevels","geometry","isBlocked","areNormalsFrozen","facetNb","isFacetDataEnabled","lightSources","useBones","isAnInstance","collider","edgesRenderer","forward","up","right","absolutePosition","absoluteScaling","absoluteRotationQuaternion","isWorldMatrixFrozen","nonUniformScaling","behaviors","worldMatrixFromCache","hasThinInstances","cloneMeshMap"],["_poseMatrix"]),u._internalMeshDataInfo._source=s,r.useClonedMeshMap&&(s._internalMeshDataInfo.meshMap||(s._internalMeshDataInfo.meshMap={}),s._internalMeshDataInfo.meshMap[u.uniqueId]=u),u._originalBuilderSideOrientation=s._originalBuilderSideOrientation,u._creationDataStorage=s._creationDataStorage,s._ranges){var l=s._ranges;for(var t in l)l.hasOwnProperty(t)&&l[t]&&u.createAnimationRange(t,l[t].from,l[t].to)}var c;if(s.metadata&&s.metadata.clone?u.metadata=s.metadata.clone():u.metadata=s.metadata,o&&o.HasTags(s)&&o.AddTagsTo(u,o.GetTags(s,!0)),u.setEnabled(s.isEnabled()),u.parent=s.parent,u.setPivotMatrix(s.getPivotMatrix()),u.id=t+"."+s.id,u.material=s.material,!a)for(var f=s.getDescendants(!0),d=0;d<f.length;d++){var p=f[d];p.clone&&p.clone(t+"."+p.name,u)}if(s.morphTargetManager&&(u.morphTargetManager=s.morphTargetManager),r.getPhysicsEngine){var _=r.getPhysicsEngine();if(h&&_){var g=_.getImpostorForPhysicsObject(s);g&&(u.physicsImpostor=g.clone(u))}}for(c=0;c<r.particleSystems.length;c++){var m=r.particleSystems[c];m.emitter===s&&m.clone(m.name,u)}u.refreshBoundingInfo(),u.computeWorldMatrix(!0)}return null!==n&&(u.parent=n),u._instanceDataStorage.hardwareInstancedRendering=u.getEngine().getCaps().instancedArrays,u}return t(i,e),i._GetDefaultSideOrientation=function(e){return e||i.FRONTSIDE},Object.defineProperty(i.prototype,"computeBonesUsingShaders",{get:function(){return this._internalAbstractMeshDataInfo._computeBonesUsingShaders},set:function(e){this._internalAbstractMeshDataInfo._computeBonesUsingShaders!==e&&(e&&this._internalMeshDataInfo._sourcePositions&&(this.setVerticesData(ft.PositionKind,this._internalMeshDataInfo._sourcePositions.slice(),!0),this._internalMeshDataInfo._sourceNormals&&this.setVerticesData(ft.NormalKind,this._internalMeshDataInfo._sourceNormals.slice(),!0)),this._internalAbstractMeshDataInfo._computeBonesUsingShaders=e,this._markSubMeshesAsAttributesDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"onBeforeRenderObservable",{get:function(){return this._internalMeshDataInfo._onBeforeRenderObservable||(this._internalMeshDataInfo._onBeforeRenderObservable=new U),this._internalMeshDataInfo._onBeforeRenderObservable},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"onBeforeBindObservable",{get:function(){return this._internalMeshDataInfo._onBeforeBindObservable||(this._internalMeshDataInfo._onBeforeBindObservable=new U),this._internalMeshDataInfo._onBeforeBindObservable},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"onAfterRenderObservable",{get:function(){return this._internalMeshDataInfo._onAfterRenderObservable||(this._internalMeshDataInfo._onAfterRenderObservable=new U),this._internalMeshDataInfo._onAfterRenderObservable},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"onBeforeDrawObservable",{get:function(){return this._internalMeshDataInfo._onBeforeDrawObservable||(this._internalMeshDataInfo._onBeforeDrawObservable=new U),this._internalMeshDataInfo._onBeforeDrawObservable},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"onBeforeDraw",{set:function(e){this._onBeforeDrawObserver&&this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver),this._onBeforeDrawObserver=this.onBeforeDrawObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"hasInstances",{get:function(){return this.instances.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"hasThinInstances",{get:function(){var e;return(null!==(e=this._thinInstanceDataStorage.instancesCount)&&void 0!==e?e:0)>0},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"morphTargetManager",{get:function(){return this._internalMeshDataInfo._morphTargetManager},set:function(e){this._internalMeshDataInfo._morphTargetManager!==e&&(this._internalMeshDataInfo._morphTargetManager=e,this._syncGeometryWithMorphTargetManager())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"source",{get:function(){return this._internalMeshDataInfo._source},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"cloneMeshMap",{get:function(){return this._internalMeshDataInfo.meshMap},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"isUnIndexed",{get:function(){return this._unIndexed},set:function(e){this._unIndexed!==e&&(this._unIndexed=e,this._markSubMeshesAsAttributesDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"worldMatrixInstancedBuffer",{get:function(){return this._instanceDataStorage.instancesData},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"manualUpdateOfWorldMatrixInstancedBuffer",{get:function(){return this._instanceDataStorage.manualUpdate},set:function(e){this._instanceDataStorage.manualUpdate=e},enumerable:!1,configurable:!0}),i.prototype.instantiateHierarchy=function(e,t,i){void 0===e&&(e=null);var r=!(this.getTotalVertices()>0)||t&&t.doNotInstantiate?this.clone("Clone of "+(this.name||this.id),e||this.parent,!0):this.createInstance("instance of "+(this.name||this.id));r&&(r.parent=e||this.parent,r.position=this.position.clone(),r.scaling=this.scaling.clone(),this.rotationQuaternion?r.rotationQuaternion=this.rotationQuaternion.clone():r.rotation=this.rotation.clone(),i&&i(this,r));for(var n=0,o=this.getChildTransformNodes(!0);n<o.length;n++){o[n].instantiateHierarchy(r,t,i)}return r},i.prototype.getClassName=function(){return"Mesh"},Object.defineProperty(i.prototype,"_isMesh",{get:function(){return!0},enumerable:!1,configurable:!0}),i.prototype.toString=function(t){var i=e.prototype.toString.call(this,t);if(i+=", n vertices: "+this.getTotalVertices(),i+=", parent: "+(this._waitingParentId?this._waitingParentId:this.parent?this.parent.name:"NONE"),this.animations)for(var r=0;r<this.animations.length;r++)i+=", animation[0]: "+this.animations[r].toString(t);if(t)if(this._geometry){var n=this.getIndices(),o=this.getVerticesData(ft.PositionKind);o&&n&&(i+=", flat shading: "+(o.length/3===n.length?"YES":"NO"))}else i+=", flat shading: UNKNOWN";return i},i.prototype._unBindEffect=function(){e.prototype._unBindEffect.call(this);for(var t=0,i=this.instances;t<i.length;t++){i[t]._unBindEffect()}},Object.defineProperty(i.prototype,"hasLODLevels",{get:function(){return this._internalMeshDataInfo._LODLevels.length>0},enumerable:!1,configurable:!0}),i.prototype.getLODLevels=function(){return this._internalMeshDataInfo._LODLevels},i.prototype._sortLODLevels=function(){this._internalMeshDataInfo._LODLevels.sort((function(e,t){return e.distance<t.distance?1:e.distance>t.distance?-1:0}))},i.prototype.addLODLevel=function(e,t){if(t&&t._masterMesh)return q.Warn("You cannot use a mesh as LOD level twice"),this;var i=new Ht(e,t);return this._internalMeshDataInfo._LODLevels.push(i),t&&(t._masterMesh=this),this._sortLODLevels(),this},i.prototype.getLODLevelAtDistance=function(e){for(var t=this._internalMeshDataInfo,i=0;i<t._LODLevels.length;i++){var r=t._LODLevels[i];if(r.distance===e)return r.mesh}return null},i.prototype.removeLODLevel=function(e){for(var t=this._internalMeshDataInfo,i=0;i<t._LODLevels.length;i++)t._LODLevels[i].mesh===e&&(t._LODLevels.splice(i,1),e&&(e._masterMesh=null));return this._sortLODLevels(),this},i.prototype.getLOD=function(e,t){var i,r=this._internalMeshDataInfo;if(!r._LODLevels||0===r._LODLevels.length)return this;t?i=t:i=this.getBoundingInfo().boundingSphere;var n=i.centerWorld.subtract(e.globalPosition).length();if(r._LODLevels[r._LODLevels.length-1].distance>n)return this.onLODLevelSelection&&this.onLODLevelSelection(n,this,this),this;for(var o=0;o<r._LODLevels.length;o++){var s=r._LODLevels[o];if(s.distance<n){if(s.mesh){if(4===s.mesh.delayLoadState)return s.mesh._checkDelayState(),this;if(2===s.mesh.delayLoadState)return this;s.mesh._preActivate(),s.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache)}return this.onLODLevelSelection&&this.onLODLevelSelection(n,this,s.mesh),s.mesh}}return this.onLODLevelSelection&&this.onLODLevelSelection(n,this,this),this},Object.defineProperty(i.prototype,"geometry",{get:function(){return this._geometry},enumerable:!1,configurable:!0}),i.prototype.getTotalVertices=function(){return null===this._geometry||void 0===this._geometry?0:this._geometry.getTotalVertices()},i.prototype.getVerticesData=function(e,t,i){return this._geometry?this._geometry.getVerticesData(e,t,i):null},i.prototype.getVertexBuffer=function(e){return this._geometry?this._geometry.getVertexBuffer(e):null},i.prototype.isVerticesDataPresent=function(e){return this._geometry?this._geometry.isVerticesDataPresent(e):!!this._delayInfo&&-1!==this._delayInfo.indexOf(e)},i.prototype.isVertexBufferUpdatable=function(e){return this._geometry?this._geometry.isVertexBufferUpdatable(e):!!this._delayInfo&&-1!==this._delayInfo.indexOf(e)},i.prototype.getVerticesDataKinds=function(){if(!this._geometry){var e=new Array;return this._delayInfo&&this._delayInfo.forEach((function(t){e.push(t)})),e}return this._geometry.getVerticesDataKinds()},i.prototype.getTotalIndices=function(){return this._geometry?this._geometry.getTotalIndices():0},i.prototype.getIndices=function(e,t){return this._geometry?this._geometry.getIndices(e,t):[]},Object.defineProperty(i.prototype,"isBlocked",{get:function(){return null!==this._masterMesh&&void 0!==this._masterMesh},enumerable:!1,configurable:!0}),i.prototype.isReady=function(t,i){var r,n,o,s,a,h;if(void 0===t&&(t=!1),void 0===i&&(i=!1),2===this.delayLoadState)return!1;if(!e.prototype.isReady.call(this,t))return!1;if(!this.subMeshes||0===this.subMeshes.length)return!0;if(!t)return!0;var u=this.getEngine(),l=this.getScene(),c=i||u.getCaps().instancedArrays&&(this.instances.length>0||this.hasThinInstances);this.computeWorldMatrix();var f=this.material||l.defaultMaterial;if(f)if(f._storeEffectOnSubMeshes)for(var d=0,p=this.subMeshes;d<p.length;d++){var _=(T=p[d]).getMaterial();if(_)if(_._storeEffectOnSubMeshes){if(!_.isReadyForSubMesh(this,T,c))return!1}else if(!_.isReady(this,c))return!1}else if(!f.isReady(this,c))return!1;for(var g=0,m=this.lightSources;g<m.length;g++){var v=m[g].getShadowGenerator();if(v&&(!(null===(r=v.getShadowMap())||void 0===r?void 0:r.renderList)||(null===(n=v.getShadowMap())||void 0===n?void 0:n.renderList)&&-1!==(null===(s=null===(o=v.getShadowMap())||void 0===o?void 0:o.renderList)||void 0===s?void 0:s.indexOf(this))))for(var y=0,b=this.subMeshes;y<b.length;y++){var T=b[y];if(!v.isReady(T,c,null!==(h=null===(a=T.getMaterial())||void 0===a?void 0:a.needAlphaBlendingForMesh(this))&&void 0!==h&&h))return!1}}for(var E=0,x=this._internalMeshDataInfo._LODLevels;E<x.length;E++){var A=x[E];if(A.mesh&&!A.mesh.isReady(c))return!1}return!0},Object.defineProperty(i.prototype,"areNormalsFrozen",{get:function(){return this._internalMeshDataInfo._areNormalsFrozen},enumerable:!1,configurable:!0}),i.prototype.freezeNormals=function(){return this._internalMeshDataInfo._areNormalsFrozen=!0,this},i.prototype.unfreezeNormals=function(){return this._internalMeshDataInfo._areNormalsFrozen=!1,this},Object.defineProperty(i.prototype,"overridenInstanceCount",{set:function(e){this._instanceDataStorage.overridenInstanceCount=e},enumerable:!1,configurable:!0}),i.prototype._preActivate=function(){var e=this._internalMeshDataInfo,t=this.getScene().getRenderId();return e._preActivateId===t||(e._preActivateId=t,this._instanceDataStorage.visibleInstances=null),this},i.prototype._preActivateForIntermediateRendering=function(e){return this._instanceDataStorage.visibleInstances&&(this._instanceDataStorage.visibleInstances.intermediateDefaultRenderId=e),this},i.prototype._registerInstanceForRenderId=function(e,t){return this._instanceDataStorage.visibleInstances||(this._instanceDataStorage.visibleInstances={defaultRenderId:t,selfDefaultRenderId:this._renderId}),this._instanceDataStorage.visibleInstances[t]||(void 0!==this._instanceDataStorage.previousRenderId&&this._instanceDataStorage.isFrozen&&(this._instanceDataStorage.visibleInstances[this._instanceDataStorage.previousRenderId]=null),this._instanceDataStorage.previousRenderId=t,this._instanceDataStorage.visibleInstances[t]=new Array),this._instanceDataStorage.visibleInstances[t].push(e),this},i.prototype._afterComputeWorldMatrix=function(){e.prototype._afterComputeWorldMatrix.call(this),this.hasThinInstances&&(this.doNotSyncBoundingInfo||this.thinInstanceRefreshBoundingInfo(!1))},i.prototype._postActivate=function(){this.edgesShareWithInstances&&this.edgesRenderer&&this.edgesRenderer.isEnabled&&this._renderingGroup&&(this._renderingGroup._edgesRenderers.pushNoDuplicate(this.edgesRenderer),this.edgesRenderer.customInstances.push(this.getWorldMatrix()))},i.prototype.refreshBoundingInfo=function(e){if(void 0===e&&(e=!1),this._boundingInfo&&this._boundingInfo.isLocked)return this;var t=this.geometry?this.geometry.boundingBias:null;return this._refreshBoundingInfo(this._getPositionData(e),t),this},i.prototype._createGlobalSubMesh=function(e){var t=this.getTotalVertices();if(!t||!this.getIndices())return null;if(this.subMeshes&&this.subMeshes.length>0){var i=this.getIndices();if(!i)return null;var r=i.length,n=!1;if(e)n=!0;else for(var o=0,s=this.subMeshes;o<s.length;o++){var a=s[o];if(a.indexStart+a.indexCount>r){n=!0;break}if(a.verticesStart+a.verticesCount>t){n=!0;break}}if(!n)return this.subMeshes[0]}return this.releaseSubMeshes(),new xt(0,0,t,0,this.getTotalIndices(),this)},i.prototype.subdivide=function(e){if(!(e<1)){for(var t=this.getTotalIndices(),i=t/e|0,r=0;i%3!=0;)i++;this.releaseSubMeshes();for(var n=0;n<e&&!(r>=t);n++)xt.CreateFromIndices(0,r,n===e-1?t-r:i,this),r+=i;this.synchronizeInstances()}},i.prototype.setVerticesData=function(e,t,i,r){if(void 0===i&&(i=!1),this._geometry)this._geometry.setVerticesData(e,t,i,r);else{var n=new dt;n.set(t,e);var o=this.getScene();new Mt(Mt.RandomId(),o,n,i,this)}return this},i.prototype.removeVerticesData=function(e){this._geometry&&this._geometry.removeVerticesData(e)},i.prototype.markVerticesDataAsUpdatable=function(e,t){void 0===t&&(t=!0);var i=this.getVertexBuffer(e);i&&i.isUpdatable()!==t&&this.setVerticesData(e,this.getVerticesData(e),t)},i.prototype.setVerticesBuffer=function(e){return this._geometry||(this._geometry=Mt.CreateGeometryForMesh(this)),this._geometry.setVerticesBuffer(e),this},i.prototype.updateVerticesData=function(e,t,i,r){return this._geometry?(r?(this.makeGeometryUnique(),this.updateVerticesData(e,t,i,!1)):this._geometry.updateVerticesData(e,t,i),this):this},i.prototype.updateMeshPositions=function(e,t){void 0===t&&(t=!0);var i=this.getVerticesData(ft.PositionKind);if(!i)return this;if(e(i),this.updateVerticesData(ft.PositionKind,i,!1,!1),t){var r=this.getIndices(),n=this.getVerticesData(ft.NormalKind);if(!n)return this;dt.ComputeNormals(i,r,n),this.updateVerticesData(ft.NormalKind,n,!1,!1)}return this},i.prototype.makeGeometryUnique=function(){if(!this._geometry)return this;if(1===this._geometry.meshes.length)return this;var e=this._geometry,t=this._geometry.copy(Mt.RandomId());return e.releaseForMesh(this,!0),t.applyToMesh(this),this},i.prototype.setIndices=function(e,t,i){if(void 0===t&&(t=null),void 0===i&&(i=!1),this._geometry)this._geometry.setIndices(e,t,i);else{var r=new dt;r.indices=e;var n=this.getScene();new Mt(Mt.RandomId(),n,r,i,this)}return this},i.prototype.updateIndices=function(e,t,i){return void 0===i&&(i=!1),this._geometry?(this._geometry.updateIndices(e,t,i),this):this},i.prototype.toLeftHanded=function(){return this._geometry?(this._geometry.toLeftHanded(),this):this},i.prototype._bind=function(e,t,i){if(!this._geometry)return this;var r,n=this.getScene().getEngine();if(this._unIndexed)r=null;else switch(i){case Vt.PointFillMode:r=null;break;case Vt.WireFrameFillMode:r=e._getLinesIndexBuffer(this.getIndices(),n);break;default:case Vt.TriangleFillMode:r=this._geometry.getIndexBuffer()}return this._geometry._bind(t,r),this},i.prototype._draw=function(e,t,i){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;this._internalMeshDataInfo._onBeforeDrawObservable&&this._internalMeshDataInfo._onBeforeDrawObservable.notifyObservers(this);var r=this.getScene().getEngine();return this._unIndexed||t==Vt.PointFillMode?r.drawArraysType(t,e.verticesStart,e.verticesCount,i):t==Vt.WireFrameFillMode?r.drawElementsType(t,0,e._linesIndexCount,i):r.drawElementsType(t,e.indexStart,e.indexCount,i),this},i.prototype.registerBeforeRender=function(e){return this.onBeforeRenderObservable.add(e),this},i.prototype.unregisterBeforeRender=function(e){return this.onBeforeRenderObservable.removeCallback(e),this},i.prototype.registerAfterRender=function(e){return this.onAfterRenderObservable.add(e),this},i.prototype.unregisterAfterRender=function(e){return this.onAfterRenderObservable.removeCallback(e),this},i.prototype._getInstancesRenderList=function(e,t){if(void 0===t&&(t=!1),this._instanceDataStorage.isFrozen&&this._instanceDataStorage.previousBatch)return this._instanceDataStorage.previousBatch;var i=this.getScene(),r=i._isInIntermediateRendering(),n=r?this._internalAbstractMeshDataInfo._onlyForInstancesIntermediate:this._internalAbstractMeshDataInfo._onlyForInstances,o=this._instanceDataStorage.batchCache;if(o.mustReturn=!1,o.renderSelf[e]=t||!n&&this.isEnabled()&&this.isVisible,o.visibleInstances[e]=null,this._instanceDataStorage.visibleInstances&&!t){var s=this._instanceDataStorage.visibleInstances,a=i.getRenderId(),h=r?s.intermediateDefaultRenderId:s.defaultRenderId;o.visibleInstances[e]=s[a],!o.visibleInstances[e]&&h&&(o.visibleInstances[e]=s[h])}return o.hardwareInstancedRendering[e]=!t&&this._instanceDataStorage.hardwareInstancedRendering&&null!==o.visibleInstances[e]&&void 0!==o.visibleInstances[e],this._instanceDataStorage.previousBatch=o,o},i.prototype._renderWithInstances=function(e,t,i,r,n){var o=i.visibleInstances[e._id];if(!o)return this;for(var s=this._instanceDataStorage,a=s.instancesBufferSize,h=s.instancesBuffer,u=16*(o.length+1)*4;s.instancesBufferSize<u;)s.instancesBufferSize*=2;s.instancesData&&a==s.instancesBufferSize||(s.instancesData=new Float32Array(s.instancesBufferSize/4));var l=0,c=0,f=i.renderSelf[e._id],d=!h||a!==s.instancesBufferSize;if(this._instanceDataStorage.manualUpdate||s.isFrozen&&!d)c=(f?1:0)+o.length;else{var p=this._effectiveMesh.getWorldMatrix();if(f&&(p.copyToArray(s.instancesData,l),l+=16,c++),o)for(var _=0;_<o.length;_++){o[_].getWorldMatrix().copyToArray(s.instancesData,l),l+=16,c++}}return d?(h&&h.dispose(),h=new ct(n,s.instancesData,!0,16,!1,!0),s.instancesBuffer=h,this.setVerticesBuffer(h.createVertexBuffer("world0",0,4)),this.setVerticesBuffer(h.createVertexBuffer("world1",4,4)),this.setVerticesBuffer(h.createVertexBuffer("world2",8,4)),this.setVerticesBuffer(h.createVertexBuffer("world3",12,4))):this._instanceDataStorage.isFrozen||h.updateDirectly(s.instancesData,0,c),this._processInstancedBuffers(o,f),this.getScene()._activeIndices.addCount(e.indexCount*c,!1),this._bind(e,r,t),this._draw(e,t,c),n.unbindInstanceAttributes(),this},i.prototype._renderWithThinInstances=function(e,t,i,r){var n,o,s=null!==(o=null===(n=this._thinInstanceDataStorage)||void 0===n?void 0:n.instancesCount)&&void 0!==o?o:0;this.getScene()._activeIndices.addCount(e.indexCount*s,!1),this._bind(e,i,t),this._draw(e,t,s),r.unbindInstanceAttributes()},i.prototype._processInstancedBuffers=function(e,t){},i.prototype._processRendering=function(e,t,i,r,n,o,s,a){var h=this.getScene(),u=h.getEngine();if(o&&t.getRenderingMesh().hasThinInstances)return this._renderWithThinInstances(t,r,i,u),this;if(o)this._renderWithInstances(t,r,n,i,u);else{var l=0;n.renderSelf[t._id]&&(s&&s(!1,e._effectiveMesh.getWorldMatrix(),a),l++,this._draw(t,r,this._instanceDataStorage.overridenInstanceCount));var c=n.visibleInstances[t._id];if(c){var f=c.length;l+=f;for(var d=0;d<f;d++){var p=c[d].getWorldMatrix();s&&s(!0,p,a),this._draw(t,r)}}h._activeIndices.addCount(t.indexCount*l,!1)}return this},i.prototype._rebuild=function(){this._instanceDataStorage.instancesBuffer&&(this._instanceDataStorage.instancesBuffer.dispose(),this._instanceDataStorage.instancesBuffer=null),e.prototype._rebuild.call(this)},i.prototype._freeze=function(){if(this.subMeshes){for(var e=0;e<this.subMeshes.length;e++)this._getInstancesRenderList(e);this._effectiveMaterial=null,this._instanceDataStorage.isFrozen=!0}},i.prototype._unFreeze=function(){this._instanceDataStorage.isFrozen=!1,this._instanceDataStorage.previousBatch=null},i.prototype.render=function(e,t,i){var r=this.getScene();if(this._internalAbstractMeshDataInfo._isActiveIntermediate?this._internalAbstractMeshDataInfo._isActiveIntermediate=!1:this._internalAbstractMeshDataInfo._isActive=!1,this._checkOcclusionQuery())return this;var n=this._getInstancesRenderList(e._id,!!i);if(n.mustReturn)return this;if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;this._internalMeshDataInfo._onBeforeRenderObservable&&this._internalMeshDataInfo._onBeforeRenderObservable.notifyObservers(this);var o,s=r.getEngine(),a=n.hardwareInstancedRendering[e._id]||e.getRenderingMesh().hasThinInstances,h=this._instanceDataStorage,u=e.getMaterial();if(!u)return this;if(!h.isFrozen||!this._effectiveMaterial||this._effectiveMaterial!==u){if(u._storeEffectOnSubMeshes){if(!u.isReadyForSubMesh(this,e,a))return this}else if(!u.isReady(this,a))return this;this._effectiveMaterial=u}t&&s.setAlphaMode(this._effectiveMaterial.alphaMode),o=this._effectiveMaterial._storeEffectOnSubMeshes?e.effect:this._effectiveMaterial.getEffect();for(var l=0,c=r._beforeRenderingMeshStage;l<c.length;l++){c[l].action(this,e,n,o)}if(!o)return this;var f,d=i||this._effectiveMesh;if(h.isFrozen||!this._effectiveMaterial.backFaceCulling&&null===this.overrideMaterialSideOrientation)f=h.sideOrientation;else{var p=d._getWorldMatrixDeterminant();null==(f=this.overrideMaterialSideOrientation)&&(f=this._effectiveMaterial.sideOrientation),p<0&&(f=f===Vt.ClockWiseSideOrientation?Vt.CounterClockWiseSideOrientation:Vt.ClockWiseSideOrientation),h.sideOrientation=f}var _=this._effectiveMaterial._preBind(o,f);this._effectiveMaterial.forceDepthWrite&&s.setDepthWrite(!0);var g=r.forcePointsCloud?Vt.PointFillMode:r.forceWireframe?Vt.WireFrameFillMode:this._effectiveMaterial.fillMode;this._internalMeshDataInfo._onBeforeBindObservable&&this._internalMeshDataInfo._onBeforeBindObservable.notifyObservers(this),a||this._bind(e,o,g);var m=d.getWorldMatrix();this._effectiveMaterial._storeEffectOnSubMeshes?this._effectiveMaterial.bindForSubMesh(m,this,e):this._effectiveMaterial.bind(m,this),!this._effectiveMaterial.backFaceCulling&&this._effectiveMaterial.separateCullingPass&&(s.setState(!0,this._effectiveMaterial.zOffset,!1,!_),this._processRendering(this,e,o,g,n,a,this._onBeforeDraw,this._effectiveMaterial),s.setState(!0,this._effectiveMaterial.zOffset,!1,_)),this._processRendering(this,e,o,g,n,a,this._onBeforeDraw,this._effectiveMaterial),this._effectiveMaterial.unbind();for(var v=0,y=r._afterRenderingMeshStage;v<y.length;v++){y[v].action(this,e,n,o)}return this._internalMeshDataInfo._onAfterRenderObservable&&this._internalMeshDataInfo._onAfterRenderObservable.notifyObservers(this),this},i.prototype._onBeforeDraw=function(e,t,i){e&&i&&i.bindOnlyWorldMatrix(t)},i.prototype.cleanMatrixWeights=function(){this.isVerticesDataPresent(ft.MatricesWeightsKind)&&(this.isVerticesDataPresent(ft.MatricesWeightsExtraKind)?this.normalizeSkinWeightsAndExtra():this.normalizeSkinFourWeights())},i.prototype.normalizeSkinFourWeights=function(){for(var e=this.getVerticesData(ft.MatricesWeightsKind),t=e.length,i=0;i<t;i+=4){var r=e[i]+e[i+1]+e[i+2]+e[i+3];if(0===r)e[i]=1;else{var n=1/r;e[i]*=n,e[i+1]*=n,e[i+2]*=n,e[i+3]*=n}}this.setVerticesData(ft.MatricesWeightsKind,e)},i.prototype.normalizeSkinWeightsAndExtra=function(){for(var e=this.getVerticesData(ft.MatricesWeightsExtraKind),t=this.getVerticesData(ft.MatricesWeightsKind),i=t.length,r=0;r<i;r+=4){var n=t[r]+t[r+1]+t[r+2]+t[r+3];if(0===(n+=e[r]+e[r+1]+e[r+2]+e[r+3]))t[r]=1;else{var o=1/n;t[r]*=o,t[r+1]*=o,t[r+2]*=o,t[r+3]*=o,e[r]*=o,e[r+1]*=o,e[r+2]*=o,e[r+3]*=o}}this.setVerticesData(ft.MatricesWeightsKind,t),this.setVerticesData(ft.MatricesWeightsKind,e)},i.prototype.validateSkinning=function(){var e=this.getVerticesData(ft.MatricesWeightsExtraKind),t=this.getVerticesData(ft.MatricesWeightsKind);if(null===t||null==this.skeleton)return{skinned:!1,valid:!0,report:"not skinned"};for(var i=t.length,r=0,n=0,o=0,s=0,a=null===e?4:8,h=new Array,u=0;u<=a;u++)h[u]=0;for(u=0;u<i;u+=4){for(var l=t[u],c=l,f=0===c?0:1,d=1;d<a;d++){var p=d<4?t[u+d]:e[u+d-4];p>l&&r++,0!==p&&f++,c+=p,l=p}if(h[f]++,f>o&&(o=f),0===c)n++;else{var _=1/c,g=0;for(d=0;d<a;d++)g+=d<4?Math.abs(t[u+d]-t[u+d]*_):Math.abs(e[u+d-4]-e[u+d-4]*_);g>.001&&s++}}var m=this.skeleton.bones.length,v=this.getVerticesData(ft.MatricesIndicesKind),y=this.getVerticesData(ft.MatricesIndicesExtraKind),b=0;for(u=0;u<i;u+=4)for(d=0;d<a;d++){var T=d<4?v[u+d]:y[u+d-4];(T>=m||T<0)&&b++}return{skinned:!0,valid:0===n&&0===s&&0===b,report:"Number of Weights = "+i/4+"\nMaximum influences = "+o+"\nMissing Weights = "+n+"\nNot Sorted = "+r+"\nNot Normalized = "+s+"\nWeightCounts = ["+h+"]\nNumber of bones = "+m+"\nBad Bone Indices = "+b}},i.prototype._checkDelayState=function(){var e=this.getScene();return this._geometry?this._geometry.load(e):4===this.delayLoadState&&(this.delayLoadState=2,this._queueLoad(e)),this},i.prototype._queueLoad=function(e){var t=this;e._addPendingData(this);var i=-1!==this.delayLoadingFile.indexOf(".babylonbinarymeshdata");return Ue.LoadFile(this.delayLoadingFile,(function(i){i instanceof ArrayBuffer?t._delayLoadingFunction(i,t):t._delayLoadingFunction(JSON.parse(i),t),t.instances.forEach((function(e){e.refreshBoundingInfo(),e._syncSubMeshes()})),t.delayLoadState=1,e._removePendingData(t)}),(function(){}),e.offlineProvider,i),this},i.prototype.isInFrustum=function(t){return 2!==this.delayLoadState&&(!!e.prototype.isInFrustum.call(this,t)&&(this._checkDelayState(),!0))},i.prototype.setMaterialByID=function(e){var t,i=this.getScene().materials;for(t=i.length-1;t>-1;t--)if(i[t].id===e)return this.material=i[t],this;var r=this.getScene().multiMaterials;for(t=r.length-1;t>-1;t--)if(r[t].id===e)return this.material=r[t],this;return this},i.prototype.getAnimatables=function(){var e=new Array;return this.material&&e.push(this.material),this.skeleton&&e.push(this.skeleton),e},i.prototype.bakeTransformIntoVertices=function(e){if(!this.isVerticesDataPresent(ft.PositionKind))return this;var t=this.subMeshes.splice(0);this._resetPointsArrayCache();var i,r=this.getVerticesData(ft.PositionKind),n=new Array;for(i=0;i<r.length;i+=3)p.TransformCoordinates(p.FromArray(r,i),e).toArray(n,i);if(this.setVerticesData(ft.PositionKind,n,this.getVertexBuffer(ft.PositionKind).isUpdatable()),this.isVerticesDataPresent(ft.NormalKind)){for(r=this.getVerticesData(ft.NormalKind),n=[],i=0;i<r.length;i+=3)p.TransformNormal(p.FromArray(r,i),e).normalize().toArray(n,i);this.setVerticesData(ft.NormalKind,n,this.getVertexBuffer(ft.NormalKind).isUpdatable())}return e.m[0]*e.m[5]*e.m[10]<0&&this.flipFaces(),this.releaseSubMeshes(),this.subMeshes=t,this},i.prototype.bakeCurrentTransformIntoVertices=function(e){return void 0===e&&(e=!0),this.bakeTransformIntoVertices(this.computeWorldMatrix(!0)),this.resetLocalMatrix(e),this},Object.defineProperty(i.prototype,"_positions",{get:function(){return this._geometry?this._geometry._positions:null},enumerable:!1,configurable:!0}),i.prototype._resetPointsArrayCache=function(){return this._geometry&&this._geometry._resetPointsArrayCache(),this},i.prototype._generatePointsArray=function(){return!!this._geometry&&this._geometry._generatePointsArray()},i.prototype.clone=function(e,t,r,n){return void 0===e&&(e=""),void 0===t&&(t=null),void 0===n&&(n=!0),new i(e,this.getScene(),t,this,r,n)},i.prototype.dispose=function(t,i){void 0===i&&(i=!1),this.morphTargetManager=null,this._geometry&&this._geometry.releaseForMesh(this,!0);var r=this._internalMeshDataInfo;if(r._onBeforeDrawObservable&&r._onBeforeDrawObservable.clear(),r._onBeforeBindObservable&&r._onBeforeBindObservable.clear(),r._onBeforeRenderObservable&&r._onBeforeRenderObservable.clear(),r._onAfterRenderObservable&&r._onAfterRenderObservable.clear(),this._scene.useClonedMeshMap){if(r.meshMap)for(var n in r.meshMap){(a=r.meshMap[n])&&(a._internalMeshDataInfo._source=null,r.meshMap[n]=void 0)}r._source&&r._source._internalMeshDataInfo.meshMap&&(r._source._internalMeshDataInfo.meshMap[this.uniqueId]=void 0)}else for(var o=0,s=this.getScene().meshes;o<s.length;o++){var a;(a=s[o])._internalMeshDataInfo&&a._internalMeshDataInfo._source&&a._internalMeshDataInfo._source===this&&(a._internalMeshDataInfo._source=null)}r._source=null,this._disposeInstanceSpecificData(),this._disposeThinInstanceSpecificData(),e.prototype.dispose.call(this,t,i)},i.prototype._disposeInstanceSpecificData=function(){},i.prototype._disposeThinInstanceSpecificData=function(){},i.prototype.applyDisplacementMap=function(e,t,i,r,n,o,s){var a=this;void 0===s&&(s=!1);var h=this.getScene();return Ue.LoadImage(e,(function(e){var h=e.width,u=e.height,l=ve.CreateCanvas(h,u).getContext("2d");l.drawImage(e,0,0);var c=l.getImageData(0,0,h,u).data;a.applyDisplacementMapFromBuffer(c,h,u,t,i,n,o,s),r&&r(a)}),(function(){}),h.offlineProvider),this},i.prototype.applyDisplacementMapFromBuffer=function(e,t,i,r,n,o,s,a){if(void 0===a&&(a=!1),!this.isVerticesDataPresent(ft.PositionKind)||!this.isVerticesDataPresent(ft.NormalKind)||!this.isVerticesDataPresent(ft.UVKind))return q.Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing"),this;var h=this.getVerticesData(ft.PositionKind,!0,!0),u=this.getVerticesData(ft.NormalKind),l=this.getVerticesData(ft.UVKind),c=p.Zero(),f=p.Zero(),_=d.Zero();o=o||d.Zero(),s=s||new d(1,1);for(var g=0;g<h.length;g+=3){p.FromArrayToRef(h,g,c),p.FromArrayToRef(u,g,f),d.FromArrayToRef(l,g/3*2,_);var m=4*((Math.abs(_.x*s.x+o.x%1)*(t-1)%t|0)+(Math.abs(_.y*s.y+o.y%1)*(i-1)%i|0)*t),v=.3*(e[m]/255)+.59*(e[m+1]/255)+.11*(e[m+2]/255);f.normalize(),f.scaleInPlace(r+(n-r)*v),(c=c.add(f)).toArray(h,g)}return dt.ComputeNormals(h,this.getIndices(),u),a?(this.setVerticesData(ft.PositionKind,h),this.setVerticesData(ft.NormalKind,u)):(this.updateVerticesData(ft.PositionKind,h),this.updateVerticesData(ft.NormalKind,u)),this},i.prototype.convertToFlatShadedMesh=function(){var e,t,i=this.getVerticesDataKinds(),r={},n={},o={},s=!1;for(e=0;e<i.length;e++){t=i[e];var a=this.getVertexBuffer(t);t!==ft.NormalKind?(r[t]=a,n[t]=r[t].getData(),o[t]=[]):(s=a.isUpdatable(),i.splice(e,1),e--)}var h,u=this.subMeshes.slice(0),l=this.getIndices(),c=this.getTotalIndices();for(h=0;h<c;h++){var f=l[h];for(e=0;e<i.length;e++)for(var d=r[t=i[e]].getStrideSize(),_=0;_<d;_++)o[t].push(n[t][f*d+_])}var g=[],m=o[ft.PositionKind];for(h=0;h<c;h+=3){l[h]=h,l[h+1]=h+1,l[h+2]=h+2;for(var v=p.FromArray(m,3*h),y=p.FromArray(m,3*(h+1)),b=p.FromArray(m,3*(h+2)),T=v.subtract(y),E=b.subtract(y),x=p.Normalize(p.Cross(T,E)),A=0;A<3;A++)g.push(x.x),g.push(x.y),g.push(x.z)}for(this.setIndices(l),this.setVerticesData(ft.NormalKind,g,s),e=0;e<i.length;e++)t=i[e],this.setVerticesData(t,o[t],r[t].isUpdatable());this.releaseSubMeshes();for(var M=0;M<u.length;M++){var P=u[M];xt.AddToMesh(P.materialIndex,P.indexStart,P.indexCount,P.indexStart,P.indexCount,this)}return this.synchronizeInstances(),this},i.prototype.convertToUnIndexedMesh=function(){var e,t,i=this.getVerticesDataKinds(),r={},n={},o={};for(e=0;e<i.length;e++){t=i[e];var s=this.getVertexBuffer(t);r[t]=s,n[t]=r[t].getData(),o[t]=[]}var a,h=this.subMeshes.slice(0),u=this.getIndices(),l=this.getTotalIndices();for(a=0;a<l;a++){var c=u[a];for(e=0;e<i.length;e++)for(var f=r[t=i[e]].getStrideSize(),d=0;d<f;d++)o[t].push(n[t][c*f+d])}for(a=0;a<l;a+=3)u[a]=a,u[a+1]=a+1,u[a+2]=a+2;for(this.setIndices(u),e=0;e<i.length;e++)t=i[e],this.setVerticesData(t,o[t],r[t].isUpdatable());this.releaseSubMeshes();for(var p=0;p<h.length;p++){var _=h[p];xt.AddToMesh(_.materialIndex,_.indexStart,_.indexCount,_.indexStart,_.indexCount,this)}return this._unIndexed=!0,this.synchronizeInstances(),this},i.prototype.flipFaces=function(e){void 0===e&&(e=!1);var t,i,r=dt.ExtractFromMesh(this);if(e&&this.isVerticesDataPresent(ft.NormalKind)&&r.normals)for(t=0;t<r.normals.length;t++)r.normals[t]*=-1;if(r.indices)for(t=0;t<r.indices.length;t+=3)i=r.indices[t+1],r.indices[t+1]=r.indices[t+2],r.indices[t+2]=i;return r.applyToMesh(this,this.isVertexBufferUpdatable(ft.PositionKind)),this},i.prototype.increaseVertices=function(e){var t=dt.ExtractFromMesh(this),i=t.uvs,r=t.indices,n=t.positions,o=t.normals;if(r&&n&&o&&i){for(var s,a,h=e+1,u=new Array,l=0;l<h+1;l++)u[l]=new Array;var c,f=new p(0,0,0),_=new p(0,0,0),g=new d(0,0),m=new Array,v=new Array,y=new Array,b=n.length,T=i.length;for(l=0;l<r.length;l+=3){v[0]=r[l],v[1]=r[l+1],v[2]=r[l+2];for(var E=0;E<3;E++)if(s=v[E],a=v[(E+1)%3],void 0===y[s]&&void 0===y[a]?(y[s]=new Array,y[a]=new Array):(void 0===y[s]&&(y[s]=new Array),void 0===y[a]&&(y[a]=new Array)),void 0===y[s][a]&&void 0===y[a][s]){y[s][a]=[],f.x=(n[3*a]-n[3*s])/h,f.y=(n[3*a+1]-n[3*s+1])/h,f.z=(n[3*a+2]-n[3*s+2])/h,_.x=(o[3*a]-o[3*s])/h,_.y=(o[3*a+1]-o[3*s+1])/h,_.z=(o[3*a+2]-o[3*s+2])/h,g.x=(i[2*a]-i[2*s])/h,g.y=(i[2*a+1]-i[2*s+1])/h,y[s][a].push(s);for(var x=1;x<h;x++)y[s][a].push(n.length/3),n[b]=n[3*s]+x*f.x,o[b++]=o[3*s]+x*_.x,n[b]=n[3*s+1]+x*f.y,o[b++]=o[3*s+1]+x*_.y,n[b]=n[3*s+2]+x*f.z,o[b++]=o[3*s+2]+x*_.z,i[T++]=i[2*s]+x*g.x,i[T++]=i[2*s+1]+x*g.y;y[s][a].push(a),y[a][s]=new Array,c=y[s][a].length;for(var A=0;A<c;A++)y[a][s][A]=y[s][a][c-1-A]}u[0][0]=r[l],u[1][0]=y[r[l]][r[l+1]][1],u[1][1]=y[r[l]][r[l+2]][1];for(x=2;x<h;x++){u[x][0]=y[r[l]][r[l+1]][x],u[x][x]=y[r[l]][r[l+2]][x],f.x=(n[3*u[x][x]]-n[3*u[x][0]])/x,f.y=(n[3*u[x][x]+1]-n[3*u[x][0]+1])/x,f.z=(n[3*u[x][x]+2]-n[3*u[x][0]+2])/x,_.x=(o[3*u[x][x]]-o[3*u[x][0]])/x,_.y=(o[3*u[x][x]+1]-o[3*u[x][0]+1])/x,_.z=(o[3*u[x][x]+2]-o[3*u[x][0]+2])/x,g.x=(i[2*u[x][x]]-i[2*u[x][0]])/x,g.y=(i[2*u[x][x]+1]-i[2*u[x][0]+1])/x;for(E=1;E<x;E++)u[x][E]=n.length/3,n[b]=n[3*u[x][0]]+E*f.x,o[b++]=o[3*u[x][0]]+E*_.x,n[b]=n[3*u[x][0]+1]+E*f.y,o[b++]=o[3*u[x][0]+1]+E*_.y,n[b]=n[3*u[x][0]+2]+E*f.z,o[b++]=o[3*u[x][0]+2]+E*_.z,i[T++]=i[2*u[x][0]]+E*g.x,i[T++]=i[2*u[x][0]+1]+E*g.y}u[h]=y[r[l+1]][r[l+2]],m.push(u[0][0],u[1][0],u[1][1]);for(x=1;x<h;x++){for(E=0;E<x;E++)m.push(u[x][E],u[x+1][E],u[x+1][E+1]),m.push(u[x][E],u[x+1][E+1],u[x][E+1]);m.push(u[x][E],u[x+1][E],u[x+1][E+1])}}t.indices=m,t.applyToMesh(this,this.isVertexBufferUpdatable(ft.PositionKind))}else q.Warn("VertexData contains null entries")},i.prototype.forceSharedVertices=function(){var e=dt.ExtractFromMesh(this),t=e.uvs,i=e.indices,r=e.positions,n=e.colors;if(void 0===i||void 0===r||null===i||null===r)q.Warn("VertexData contains empty entries");else{for(var o,s,a=new Array,h=new Array,u=new Array,l=new Array,c=new Array,f=0,d={},p=0;p<i.length;p+=3){s=[i[p],i[p+1],i[p+2]],c=new Array;for(var _=0;_<3;_++){c[_]="";for(var g=0;g<3;g++)Math.abs(r[3*s[_]+g])<1e-8&&(r[3*s[_]+g]=0),c[_]+=r[3*s[_]+g]+"|"}if(c[0]!=c[1]&&c[0]!=c[2]&&c[1]!=c[2])for(_=0;_<3;_++){if(void 0===(o=d[c[_]])){d[c[_]]=f,o=f++;for(g=0;g<3;g++)a.push(r[3*s[_]+g]);if(null!=n)for(g=0;g<4;g++)l.push(n[4*s[_]+g]);if(null!=t)for(g=0;g<2;g++)u.push(t[2*s[_]+g])}h.push(o)}}var m=new Array;dt.ComputeNormals(a,h,m),e.positions=a,e.indices=h,e.normals=m,null!=t&&(e.uvs=u),null!=n&&(e.colors=l),e.applyToMesh(this,this.isVertexBufferUpdatable(ft.PositionKind))}},i._instancedMeshFactory=function(e,t){throw b.WarnImport("InstancedMesh")},i._PhysicsImpostorParser=function(e,t,i){throw b.WarnImport("PhysicsImpostor")},i.prototype.createInstance=function(e){var t=this.geometry;if(t&&t.meshes.length>1)for(var r=0,n=t.meshes.slice(0);r<n.length;r++){var o=n[r];o!==this&&o.makeGeometryUnique()}return i._instancedMeshFactory(e,this)},i.prototype.synchronizeInstances=function(){this._geometry&&1!==this._geometry.meshes.length&&this.instances.length&&this.makeGeometryUnique();for(var e=0;e<this.instances.length;e++){this.instances[e]._syncSubMeshes()}return this},i.prototype.optimizeIndices=function(e){var t=this,i=this.getIndices(),r=this.getVerticesData(ft.PositionKind);if(!r||!i)return this;for(var n=new Array,o=0;o<r.length;o+=3)n.push(p.FromArray(r,o));var s=new Array;return Ve.SyncAsyncForLoop(n.length,40,(function(e){for(var t=n.length-1-e,i=n[t],r=0;r<t;++r){var o=n[r];if(i.equals(o)){s[t]=r;break}}}),(function(){for(var r=0;r<i.length;++r)i[r]=s[i[r]]||i[r];var n=t.subMeshes.slice(0);t.setIndices(i),t.subMeshes=n,e&&e(t)})),this},i.prototype.serialize=function(e){e.name=this.name,e.id=this.id,e.uniqueId=this.uniqueId,e.type=this.getClassName(),o&&o.HasTags(this)&&(e.tags=o.GetTags(this)),e.position=this.position.asArray(),this.rotationQuaternion?e.rotationQuaternion=this.rotationQuaternion.asArray():this.rotation&&(e.rotation=this.rotation.asArray()),e.scaling=this.scaling.asArray(),this._postMultiplyPivotMatrix?e.pivotMatrix=this.getPivotMatrix().asArray():e.localMatrix=this.getPivotMatrix().asArray(),e.isEnabled=this.isEnabled(!1),e.isVisible=this.isVisible,e.infiniteDistance=this.infiniteDistance,e.pickable=this.isPickable,e.receiveShadows=this.receiveShadows,e.billboardMode=this.billboardMode,e.visibility=this.visibility,e.checkCollisions=this.checkCollisions,e.isBlocker=this.isBlocker,e.overrideMaterialSideOrientation=this.overrideMaterialSideOrientation,this.parent&&(e.parentId=this.parent.id),e.isUnIndexed=this.isUnIndexed;var t=this._geometry;if(t){var i=t.id;e.geometryId=i,e.subMeshes=[];for(var r=0;r<this.subMeshes.length;r++){var n=this.subMeshes[r];e.subMeshes.push({materialIndex:n.materialIndex,verticesStart:n.verticesStart,verticesCount:n.verticesCount,indexStart:n.indexStart,indexCount:n.indexCount})}}(this.material?this.material.doNotSerialize||(e.materialId=this.material.id):this.material=null,this.morphTargetManager&&(e.morphTargetManagerId=this.morphTargetManager.uniqueId),this.skeleton&&(e.skeletonId=this.skeleton.id,e.numBoneInfluencers=this.numBoneInfluencers),this.getScene()._getComponent(zt.NAME_PHYSICSENGINE))&&((h=this.getPhysicsImpostor())&&(e.physicsMass=h.getParam("mass"),e.physicsFriction=h.getParam("friction"),e.physicsRestitution=h.getParam("mass"),e.physicsImpostor=h.type));this.metadata&&(e.metadata=this.metadata),e.instances=[];for(var s=0;s<this.instances.length;s++){var a=this.instances[s];if(!a.doNotSerialize){var h,u={name:a.name,id:a.id,isEnabled:a.isEnabled(!1),isVisible:a.isVisible,isPickable:a.isPickable,checkCollisions:a.checkCollisions,position:a.position.asArray(),scaling:a.scaling.asArray()};if(a.parent&&(u.parentId=a.parent.id),a.rotationQuaternion?u.rotationQuaternion=a.rotationQuaternion.asArray():a.rotation&&(u.rotation=a.rotation.asArray()),this.getScene()._getComponent(zt.NAME_PHYSICSENGINE))(h=a.getPhysicsImpostor())&&(u.physicsMass=h.getParam("mass"),u.physicsFriction=h.getParam("friction"),u.physicsRestitution=h.getParam("mass"),u.physicsImpostor=h.type);a.metadata&&(u.metadata=a.metadata),e.instances.push(u),N.AppendSerializedAnimations(a,u),u.ranges=a.serializeAnimationRanges()}}if(this._thinInstanceDataStorage.instancesCount&&this._thinInstanceDataStorage.matrixData&&(e.thinInstances={instancesCount:this._thinInstanceDataStorage.instancesCount,matrixData:Ue.SliceToArray(this._thinInstanceDataStorage.matrixData),matrixBufferSize:this._thinInstanceDataStorage.matrixBufferSize},this._userThinInstanceBuffersStorage)){var l={data:{},sizes:{},strides:{}};for(var c in this._userThinInstanceBuffersStorage.data)l.data[c]=Ue.SliceToArray(this._userThinInstanceBuffersStorage.data[c]),l.sizes[c]=this._userThinInstanceBuffersStorage.sizes[c],l.strides[c]=this._userThinInstanceBuffersStorage.strides[c];e.thinInstances.userThinInstance=l}N.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e.layerMask=this.layerMask,e.alphaIndex=this.alphaIndex,e.hasVertexAlpha=this.hasVertexAlpha,e.overlayAlpha=this.overlayAlpha,e.overlayColor=this.overlayColor.asArray(),e.renderOverlay=this.renderOverlay,e.applyFog=this.applyFog,this.actionManager&&(e.actions=this.actionManager.serialize(this.name))},i.prototype._syncGeometryWithMorphTargetManager=function(){if(this.geometry){this._markSubMeshesAsAttributesDirty();var e=this._internalMeshDataInfo._morphTargetManager;if(e&&e.vertexCount){if(e.vertexCount!==this.getTotalVertices())return q.Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count."),void(this.morphTargetManager=null);for(var t=0;t<e.numInfluencers;t++){var i=e.getActiveTarget(t),r=i.getPositions();if(!r)return void q.Error("Invalid morph target. Target must have positions.");this.geometry.setVerticesData(ft.PositionKind+t,r,!1,3);var n=i.getNormals();n&&this.geometry.setVerticesData(ft.NormalKind+t,n,!1,3);var o=i.getTangents();o&&this.geometry.setVerticesData(ft.TangentKind+t,o,!1,3);var s=i.getUVs();s&&this.geometry.setVerticesData(ft.UVKind+"_"+t,s,!1,2)}}else for(t=0;this.geometry.isVerticesDataPresent(ft.PositionKind+t);)this.geometry.removeVerticesData(ft.PositionKind+t),this.geometry.isVerticesDataPresent(ft.NormalKind+t)&&this.geometry.removeVerticesData(ft.NormalKind+t),this.geometry.isVerticesDataPresent(ft.TangentKind+t)&&this.geometry.removeVerticesData(ft.TangentKind+t),this.geometry.isVerticesDataPresent(ft.UVKind+t)&&this.geometry.removeVerticesData(ft.UVKind+"_"+t),t++}},i.Parse=function(e,t,r){var n;if((n=e.type&&"GroundMesh"===e.type?i._GroundMeshParser(e,t):new i(e.name,t)).id=e.id,o&&o.AddTagsTo(n,e.tags),n.position=p.FromArray(e.position),void 0!==e.metadata&&(n.metadata=e.metadata),e.rotationQuaternion?n.rotationQuaternion=g.FromArray(e.rotationQuaternion):e.rotation&&(n.rotation=p.FromArray(e.rotation)),n.scaling=p.FromArray(e.scaling),e.localMatrix?n.setPreTransformMatrix(m.FromArray(e.localMatrix)):e.pivotMatrix&&n.setPivotMatrix(m.FromArray(e.pivotMatrix)),n.setEnabled(e.isEnabled),n.isVisible=e.isVisible,n.infiniteDistance=e.infiniteDistance,n.showBoundingBox=e.showBoundingBox,n.showSubMeshesBoundingBox=e.showSubMeshesBoundingBox,void 0!==e.applyFog&&(n.applyFog=e.applyFog),void 0!==e.pickable&&(n.isPickable=e.pickable),void 0!==e.alphaIndex&&(n.alphaIndex=e.alphaIndex),n.receiveShadows=e.receiveShadows,n.billboardMode=e.billboardMode,void 0!==e.visibility&&(n.visibility=e.visibility),n.checkCollisions=e.checkCollisions,n.overrideMaterialSideOrientation=e.overrideMaterialSideOrientation,void 0!==e.isBlocker&&(n.isBlocker=e.isBlocker),n._shouldGenerateFlatShading=e.useFlatShading,e.freezeWorldMatrix&&(n._waitingData.freezeWorldMatrix=e.freezeWorldMatrix),e.parentId&&(n._waitingParentId=e.parentId),void 0!==e.actions&&(n._waitingData.actions=e.actions),void 0!==e.overlayAlpha&&(n.overlayAlpha=e.overlayAlpha),void 0!==e.overlayColor&&(n.overlayColor=T.FromArray(e.overlayColor)),void 0!==e.renderOverlay&&(n.renderOverlay=e.renderOverlay),n.isUnIndexed=!!e.isUnIndexed,n.hasVertexAlpha=e.hasVertexAlpha,e.delayLoadingFile?(n.delayLoadState=4,n.delayLoadingFile=r+e.delayLoadingFile,n._boundingInfo=new Tt(p.FromArray(e.boundingBoxMinimum),p.FromArray(e.boundingBoxMaximum)),e._binaryInfo&&(n._binaryInfo=e._binaryInfo),n._delayInfo=[],e.hasUVs&&n._delayInfo.push(ft.UVKind),e.hasUVs2&&n._delayInfo.push(ft.UV2Kind),e.hasUVs3&&n._delayInfo.push(ft.UV3Kind),e.hasUVs4&&n._delayInfo.push(ft.UV4Kind),e.hasUVs5&&n._delayInfo.push(ft.UV5Kind),e.hasUVs6&&n._delayInfo.push(ft.UV6Kind),e.hasColors&&n._delayInfo.push(ft.ColorKind),e.hasMatricesIndices&&n._delayInfo.push(ft.MatricesIndicesKind),e.hasMatricesWeights&&n._delayInfo.push(ft.MatricesWeightsKind),n._delayLoadingFunction=Mt._ImportGeometry,At.ForceFullSceneLoadingForIncremental&&n._checkDelayState()):Mt._ImportGeometry(e,n),e.materialId?n.setMaterialByID(e.materialId):n.material=null,e.morphTargetManagerId>-1&&(n.morphTargetManager=t.getMorphTargetManagerById(e.morphTargetManagerId)),void 0!==e.skeletonId&&null!==e.skeletonId&&(n.skeleton=t.getLastSkeletonByID(e.skeletonId),e.numBoneInfluencers&&(n.numBoneInfluencers=e.numBoneInfluencers)),e.animations){for(var s=0;s<e.animations.length;s++){var a=e.animations[s];(f=c.GetClass("BABYLON.Animation"))&&n.animations.push(f.Parse(a))}ut.ParseAnimationRanges(n,e,t)}if(e.autoAnimate&&t.beginAnimation(n,e.autoAnimateFrom,e.autoAnimateTo,e.autoAnimateLoop,e.autoAnimateSpeed||1),e.layerMask&&!isNaN(e.layerMask)?n.layerMask=Math.abs(parseInt(e.layerMask)):n.layerMask=268435455,e.physicsImpostor&&i._PhysicsImpostorParser(t,n,e),e.lodMeshIds&&(n._waitingData.lods={ids:e.lodMeshIds,distances:e.lodDistances?e.lodDistances:null,coverages:e.lodCoverages?e.lodCoverages:null}),e.instances)for(var h=0;h<e.instances.length;h++){var u=e.instances[h],l=n.createInstance(u.name);if(u.id&&(l.id=u.id),o&&(u.tags?o.AddTagsTo(l,u.tags):o.AddTagsTo(l,e.tags)),l.position=p.FromArray(u.position),void 0!==u.metadata&&(l.metadata=u.metadata),u.parentId&&(l._waitingParentId=u.parentId),void 0!==u.isEnabled&&null!==u.isEnabled&&l.setEnabled(u.isEnabled),void 0!==u.isVisible&&null!==u.isVisible&&(l.isVisible=u.isVisible),void 0!==u.isPickable&&null!==u.isPickable&&(l.isPickable=u.isPickable),u.rotationQuaternion?l.rotationQuaternion=g.FromArray(u.rotationQuaternion):u.rotation&&(l.rotation=p.FromArray(u.rotation)),l.scaling=p.FromArray(u.scaling),null!=u.checkCollisions&&null!=u.checkCollisions&&(l.checkCollisions=u.checkCollisions),null!=u.pickable&&null!=u.pickable&&(l.isPickable=u.pickable),null!=u.showBoundingBox&&null!=u.showBoundingBox&&(l.showBoundingBox=u.showBoundingBox),null!=u.showSubMeshesBoundingBox&&null!=u.showSubMeshesBoundingBox&&(l.showSubMeshesBoundingBox=u.showSubMeshesBoundingBox),null!=u.alphaIndex&&null!=u.showSubMeshesBoundingBox&&(l.alphaIndex=u.alphaIndex),u.physicsImpostor&&i._PhysicsImpostorParser(t,l,u),u.animations){for(s=0;s<u.animations.length;s++){var f;a=u.animations[s],(f=c.GetClass("BABYLON.Animation"))&&l.animations.push(f.Parse(a))}ut.ParseAnimationRanges(l,u,t),u.autoAnimate&&t.beginAnimation(l,u.autoAnimateFrom,u.autoAnimateTo,u.autoAnimateLoop,u.autoAnimateSpeed||1)}}if(e.thinInstances){var d=e.thinInstances;if(d.matrixData?(n.thinInstanceSetBuffer("matrix",new Float32Array(d.matrixData),16,!1),n._thinInstanceDataStorage.matrixBufferSize=d.matrixBufferSize,n._thinInstanceDataStorage.instancesCount=d.instancesCount):n._thinInstanceDataStorage.matrixBufferSize=d.matrixBufferSize,e.thinInstances.userThinInstance){var _=e.thinInstances.userThinInstance;for(var v in _.data)n.thinInstanceSetBuffer(v,new Float32Array(_.data[v]),_.strides[v],!1),n._userThinInstanceBuffersStorage.sizes[v]=_.sizes[v]}}return n},i.CreateRibbon=function(e,t,i,r,n,o,s,a,h){throw b.WarnImport("MeshBuilder")},i.CreateDisc=function(e,t,i,r,n,o){throw b.WarnImport("MeshBuilder")},i.CreateBox=function(e,t,i,r,n){throw b.WarnImport("MeshBuilder")},i.CreateSphere=function(e,t,i,r,n,o){throw b.WarnImport("MeshBuilder")},i.CreateHemisphere=function(e,t,i,r){throw b.WarnImport("MeshBuilder")},i.CreateCylinder=function(e,t,i,r,n,o,s,a,h){throw b.WarnImport("MeshBuilder")},i.CreateTorus=function(e,t,i,r,n,o,s){throw b.WarnImport("MeshBuilder")},i.CreateTorusKnot=function(e,t,i,r,n,o,s,a,h,u){throw b.WarnImport("MeshBuilder")},i.CreateLines=function(e,t,i,r,n){throw b.WarnImport("MeshBuilder")},i.CreateDashedLines=function(e,t,i,r,n,o,s,a){throw b.WarnImport("MeshBuilder")},i.CreatePolygon=function(e,t,i,r,n,o,s){throw void 0===s&&(s=earcut),b.WarnImport("MeshBuilder")},i.ExtrudePolygon=function(e,t,i,r,n,o,s,a){throw void 0===a&&(a=earcut),b.WarnImport("MeshBuilder")},i.ExtrudeShape=function(e,t,i,r,n,o,s,a,h,u){throw b.WarnImport("MeshBuilder")},i.ExtrudeShapeCustom=function(e,t,i,r,n,o,s,a,h,u,l,c){throw b.WarnImport("MeshBuilder")},i.CreateLathe=function(e,t,i,r,n,o,s){throw b.WarnImport("MeshBuilder")},i.CreatePlane=function(e,t,i,r,n){throw b.WarnImport("MeshBuilder")},i.CreateGround=function(e,t,i,r,n,o){throw b.WarnImport("MeshBuilder")},i.CreateTiledGround=function(e,t,i,r,n,o,s,a,h){throw b.WarnImport("MeshBuilder")},i.CreateGroundFromHeightMap=function(e,t,i,r,n,o,s,a,h,u,l){throw b.WarnImport("MeshBuilder")},i.CreateTube=function(e,t,i,r,n,o,s,a,h,u){throw b.WarnImport("MeshBuilder")},i.CreatePolyhedron=function(e,t,i){throw b.WarnImport("MeshBuilder")},i.CreateIcoSphere=function(e,t,i){throw b.WarnImport("MeshBuilder")},i.CreateDecal=function(e,t,i,r,n,o){throw b.WarnImport("MeshBuilder")},i.CreateCapsule=function(e,t,i){throw b.WarnImport("MeshBuilder")},i.prototype.setPositionsForCPUSkinning=function(){var e=this._internalMeshDataInfo;if(!e._sourcePositions){var t=this.getVerticesData(ft.PositionKind);if(!t)return e._sourcePositions;e._sourcePositions=new Float32Array(t),this.isVertexBufferUpdatable(ft.PositionKind)||this.setVerticesData(ft.PositionKind,t,!0)}return e._sourcePositions},i.prototype.setNormalsForCPUSkinning=function(){var e=this._internalMeshDataInfo;if(!e._sourceNormals){var t=this.getVerticesData(ft.NormalKind);if(!t)return e._sourceNormals;e._sourceNormals=new Float32Array(t),this.isVertexBufferUpdatable(ft.NormalKind)||this.setVerticesData(ft.NormalKind,t,!0)}return e._sourceNormals},i.prototype.applySkeleton=function(e){if(!this.geometry)return this;if(this.geometry._softwareSkinningFrameId==this.getScene().getFrameId())return this;if(this.geometry._softwareSkinningFrameId=this.getScene().getFrameId(),!this.isVerticesDataPresent(ft.PositionKind))return this;if(!this.isVerticesDataPresent(ft.MatricesIndicesKind))return this;if(!this.isVerticesDataPresent(ft.MatricesWeightsKind))return this;var t=this.isVerticesDataPresent(ft.NormalKind),i=this._internalMeshDataInfo;if(!i._sourcePositions){var r=this.subMeshes.slice();this.setPositionsForCPUSkinning(),this.subMeshes=r}t&&!i._sourceNormals&&this.setNormalsForCPUSkinning();var n=this.getVerticesData(ft.PositionKind);if(!n)return this;n instanceof Float32Array||(n=new Float32Array(n));var o=this.getVerticesData(ft.NormalKind);if(t){if(!o)return this;o instanceof Float32Array||(o=new Float32Array(o))}var s=this.getVerticesData(ft.MatricesIndicesKind),a=this.getVerticesData(ft.MatricesWeightsKind);if(!a||!s)return this;for(var h,u=this.numBoneInfluencers>4,l=u?this.getVerticesData(ft.MatricesIndicesExtraKind):null,c=u?this.getVerticesData(ft.MatricesWeightsExtraKind):null,f=e.getTransformMatrices(this),d=p.Zero(),_=new m,g=new m,v=0,y=0;y<n.length;y+=3,v+=4){var b;for(h=0;h<4;h++)(b=a[v+h])>0&&(m.FromFloat32ArrayToRefScaled(f,Math.floor(16*s[v+h]),b,g),_.addToSelf(g));if(u)for(h=0;h<4;h++)(b=c[v+h])>0&&(m.FromFloat32ArrayToRefScaled(f,Math.floor(16*l[v+h]),b,g),_.addToSelf(g));p.TransformCoordinatesFromFloatsToRef(i._sourcePositions[y],i._sourcePositions[y+1],i._sourcePositions[y+2],_,d),d.toArray(n,y),t&&(p.TransformNormalFromFloatsToRef(i._sourceNormals[y],i._sourceNormals[y+1],i._sourceNormals[y+2],_,d),d.toArray(o,y)),_.reset()}return this.updateVerticesData(ft.PositionKind,n),t&&this.updateVerticesData(ft.NormalKind,o),this},i.MinMax=function(e){var t=null,i=null;return e.forEach((function(e){var r=e.getBoundingInfo().boundingBox;t&&i?(t.minimizeInPlace(r.minimumWorld),i.maximizeInPlace(r.maximumWorld)):(t=r.minimumWorld,i=r.maximumWorld)})),t&&i?{min:t,max:i}:{min:p.Zero(),max:p.Zero()}},i.Center=function(e){var t=e instanceof Array?i.MinMax(e):e;return p.Center(t.min,t.max)},i.MergeMeshes=function(e,t,r,n,o,s){var a;if(void 0===t&&(t=!0),!r){var h=0;for(a=0;a<e.length;a++)if(e[a]&&(h+=e[a].getTotalVertices())>=65536)return q.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices"),null}if(s){var u,l,c=null;o=!1}var f,d=new Array,p=new Array,_=null,g=new Array,m=null;for(a=0;a<e.length;a++)if(e[a]){var v=e[a];if(v.isAnInstance)return q.Warn("Cannot merge instance meshes."),null;var y=v.computeWorldMatrix(!0);if((f=dt.ExtractFromMesh(v,!0,!0)).transform(y),_?_.merge(f,r):(_=f,m=v),o&&g.push(v.getTotalIndices()),s)if(v.material){var b=v.material;if(b instanceof Wt){for(l=0;l<b.subMaterials.length;l++)d.indexOf(b.subMaterials[l])<0&&d.push(b.subMaterials[l]);for(u=0;u<v.subMeshes.length;u++)p.push(d.indexOf(b.subMaterials[v.subMeshes[u].materialIndex])),g.push(v.subMeshes[u].indexCount)}else for(d.indexOf(b)<0&&d.push(b),u=0;u<v.subMeshes.length;u++)p.push(d.indexOf(b)),g.push(v.subMeshes[u].indexCount)}else for(u=0;u<v.subMeshes.length;u++)p.push(0),g.push(v.subMeshes[u].indexCount)}if(n||(n=new i(m.name+"_merged",m.getScene())),_.applyToMesh(n),n.checkCollisions=m.checkCollisions,n.overrideMaterialSideOrientation=m.overrideMaterialSideOrientation,t)for(a=0;a<e.length;a++)e[a]&&e[a].dispose();if(o||s){n.releaseSubMeshes(),a=0;for(var T=0;a<g.length;)xt.CreateFromIndices(0,T,g[a],n),T+=g[a],a++}if(s){for((c=new Wt(m.name+"_merged",m.getScene())).subMaterials=d,u=0;u<n.subMeshes.length;u++)n.subMeshes[u].materialIndex=p[u];n.material=c}else n.material=m.material;return n},i.prototype.addInstance=function(e){e._indexInSourceMeshInstanceArray=this.instances.length,this.instances.push(e)},i.prototype.removeInstance=function(e){var t=e._indexInSourceMeshInstanceArray;if(-1!=t){if(t!==this.instances.length-1){var i=this.instances[this.instances.length-1];this.instances[t]=i,i._indexInSourceMeshInstanceArray=t}e._indexInSourceMeshInstanceArray=-1,this.instances.pop()}},i.FRONTSIDE=dt.FRONTSIDE,i.BACKSIDE=dt.BACKSIDE,i.DOUBLESIDE=dt.DOUBLESIDE,i.DEFAULTSIDE=dt.DEFAULTSIDE,i.NO_CAP=0,i.CAP_START=1,i.CAP_END=2,i.CAP_ALL=3,i.NO_FLIP=0,i.FLIP_TILE=1,i.ROTATE_TILE=2,i.FLIP_ROW=3,i.ROTATE_ROW=4,i.FLIP_N_ROTATE_TILE=5,i.FLIP_N_ROTATE_ROW=6,i.CENTER=0,i.LEFT=1,i.RIGHT=2,i.TOP=3,i.BOTTOM=4,i._GroundMeshParser=function(e,t){throw b.WarnImport("GroundMesh")},i}(kt);c.RegisteredTypes["BABYLON.Mesh"]=Zt;var Qt,Jt=function(){function e(){}return e.POINTERDOWN=1,e.POINTERUP=2,e.POINTERMOVE=4,e.POINTERWHEEL=8,e.POINTERPICK=16,e.POINTERTAP=32,e.POINTERDOUBLETAP=64,e}(),$t=function(e,t){this.type=e,this.event=t},ei=function(e){function i(t,i,r,n){var o=e.call(this,t,i)||this;return o.ray=null,o.skipOnPointerObservable=!1,o.localPosition=new d(r,n),o}return t(i,e),i}($t),ti=function(e){function i(t,i,r){var n=e.call(this,t,i)||this;return n.pickInfo=r,n}return t(i,e),i}($t),ii=function(){function e(){this._zoomStopsAnimation=!1,this._idleRotationSpeed=.05,this._idleRotationWaitTime=2e3,this._idleRotationSpinupTime=2e3,this._isPointerDown=!1,this._lastFrameTime=null,this._lastInteractionTime=-1/0,this._cameraRotationSpeed=0,this._lastFrameRadius=0}return Object.defineProperty(e.prototype,"name",{get:function(){return"AutoRotation"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"zoomStopsAnimation",{get:function(){return this._zoomStopsAnimation},set:function(e){this._zoomStopsAnimation=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"idleRotationSpeed",{get:function(){return this._idleRotationSpeed},set:function(e){this._idleRotationSpeed=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"idleRotationWaitTime",{get:function(){return this._idleRotationWaitTime},set:function(e){this._idleRotationWaitTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"idleRotationSpinupTime",{get:function(){return this._idleRotationSpinupTime},set:function(e){this._idleRotationSpinupTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rotationInProgress",{get:function(){return Math.abs(this._cameraRotationSpeed)>0},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e){var t=this;this._attachedCamera=e;var i=this._attachedCamera.getScene();this._onPrePointerObservableObserver=i.onPrePointerObservable.add((function(e){e.type!==Jt.POINTERDOWN?e.type===Jt.POINTERUP&&(t._isPointerDown=!1):t._isPointerDown=!0})),this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add((function(){var e=Fe.Now,i=0;null!=t._lastFrameTime&&(i=e-t._lastFrameTime),t._lastFrameTime=e,t._applyUserInteraction();var r=e-t._lastInteractionTime-t._idleRotationWaitTime,n=Math.max(Math.min(r/t._idleRotationSpinupTime,1),0);t._cameraRotationSpeed=t._idleRotationSpeed*n,t._attachedCamera&&(t._attachedCamera.alpha-=t._cameraRotationSpeed*(i/1e3))}))},e.prototype.detach=function(){if(this._attachedCamera){var e=this._attachedCamera.getScene();this._onPrePointerObservableObserver&&e.onPrePointerObservable.remove(this._onPrePointerObservableObserver),this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._attachedCamera=null}},e.prototype._userIsZooming=function(){return!!this._attachedCamera&&0!==this._attachedCamera.inertialRadiusOffset},e.prototype._shouldAnimationStopForInteraction=function(){if(!this._attachedCamera)return!1;var e=!1;return this._lastFrameRadius===this._attachedCamera.radius&&0!==this._attachedCamera.inertialRadiusOffset&&(e=!0),this._lastFrameRadius=this._attachedCamera.radius,this._zoomStopsAnimation?e:this._userIsZooming()},e.prototype._applyUserInteraction=function(){this._userIsMoving()&&!this._shouldAnimationStopForInteraction()&&(this._lastInteractionTime=Fe.Now)},e.prototype._userIsMoving=function(){return!!this._attachedCamera&&(0!==this._attachedCamera.inertialAlphaOffset||0!==this._attachedCamera.inertialBetaOffset||0!==this._attachedCamera.inertialRadiusOffset||0!==this._attachedCamera.inertialPanningX||0!==this._attachedCamera.inertialPanningY||this._isPointerDown)},e}();!function(e){e[e.CW=0]="CW",e[e.CCW=1]="CCW"}(Qt||(Qt={}));var ri=function(){function e(){}return e.Interpolate=function(e,t,i,r,n){for(var o=1-3*r+3*t,s=3*r-6*t,a=3*t,h=e,u=0;u<5;u++){var l=h*h;h-=(o*(l*h)+s*l+a*h-e)*(1/(3*o*l+2*s*h+a)),h=Math.min(1,Math.max(0,h))}return 3*Math.pow(1-h,2)*h*i+3*(1-h)*Math.pow(h,2)*n+Math.pow(h,3)},e}(),ni=function(){function e(e){this._radians=e,this._radians<0&&(this._radians+=2*Math.PI)}return e.prototype.degrees=function(){return 180*this._radians/Math.PI},e.prototype.radians=function(){return this._radians},e.BetweenTwoPoints=function(t,i){var r=i.subtract(t);return new e(Math.atan2(r.y,r.x))},e.FromRadians=function(t){return new e(t)},e.FromDegrees=function(t){return new e(t*Math.PI/180)},e}(),oi=function(e,t,i){this.startPoint=e,this.midPoint=t,this.endPoint=i;var r=Math.pow(t.x,2)+Math.pow(t.y,2),n=(Math.pow(e.x,2)+Math.pow(e.y,2)-r)/2,o=(r-Math.pow(i.x,2)-Math.pow(i.y,2))/2,s=(e.x-t.x)*(t.y-i.y)-(t.x-i.x)*(e.y-t.y);this.centerPoint=new d((n*(t.y-i.y)-o*(e.y-t.y))/s,((e.x-t.x)*o-(t.x-i.x)*n)/s),this.radius=this.centerPoint.subtract(this.startPoint).length(),this.startAngle=ni.BetweenTwoPoints(this.centerPoint,this.startPoint);var a=this.startAngle.degrees(),h=ni.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),u=ni.BetweenTwoPoints(this.centerPoint,this.endPoint).degrees();h-a>180&&(h-=360),h-a<-180&&(h+=360),u-h>180&&(u-=360),u-h<-180&&(u+=360),this.orientation=h-a<0?Qt.CW:Qt.CCW,this.angle=ni.FromDegrees(this.orientation===Qt.CW?a-u:u-a)},si=function(){function e(e,t){this._points=new Array,this._length=0,this.closed=!1,this._points.push(new d(e,t))}return e.prototype.addLineTo=function(e,t){if(this.closed)return this;var i=new d(e,t),r=this._points[this._points.length-1];return this._points.push(i),this._length+=i.subtract(r).length(),this},e.prototype.addArcTo=function(e,t,i,r,n){if(void 0===n&&(n=36),this.closed)return this;var o=this._points[this._points.length-1],s=new d(e,t),a=new d(i,r),h=new oi(o,s,a),u=h.angle.radians()/n;h.orientation===Qt.CW&&(u*=-1);for(var l=h.startAngle.radians()+u,c=0;c<n;c++){var f=Math.cos(l)*h.radius+h.centerPoint.x,p=Math.sin(l)*h.radius+h.centerPoint.y;this.addLineTo(f,p),l+=u}return this},e.prototype.close=function(){return this.closed=!0,this},e.prototype.length=function(){var e=this._length;if(this.closed){var t=this._points[this._points.length-1];e+=this._points[0].subtract(t).length()}return e},e.prototype.getPoints=function(){return this._points},e.prototype.getPointAtLengthPosition=function(e){if(e<0||e>1)return d.Zero();for(var t=e*this.length(),i=0,r=0;r<this._points.length;r++){var n=(r+1)%this._points.length,o=this._points[r],s=this._points[n].subtract(o),a=s.length()+i;if(t>=i&&t<=a){var h=s.normalize(),u=t-i;return new d(o.x+h.x*u,o.y+h.y*u)}i=a}return d.Zero()},e.StartingAt=function(t,i){return new e(t,i)},e}(),ai=function(){function e(e,t,i,r){void 0===t&&(t=null),void 0===r&&(r=!1),this.path=e,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:p.Zero(),previousPointArrayIndex:0,position:0,subPosition:0,interpolateReady:!1,interpolationMatrix:m.Identity()};for(var n=0;n<e.length;n++)this._curve[n]=e[n].clone();this._raw=i||!1,this._alignTangentsWithPath=r,this._compute(t,r)}return e.prototype.getCurve=function(){return this._curve},e.prototype.getPoints=function(){return this._curve},e.prototype.length=function(){return this._distances[this._distances.length-1]},e.prototype.getTangents=function(){return this._tangents},e.prototype.getNormals=function(){return this._normals},e.prototype.getBinormals=function(){return this._binormals},e.prototype.getDistances=function(){return this._distances},e.prototype.getPointAt=function(e){return this._updatePointAtData(e).point},e.prototype.getTangentAt=function(e,t){return void 0===t&&(t=!1),this._updatePointAtData(e,t),t?p.TransformCoordinates(p.Forward(),this._pointAtData.interpolationMatrix):this._tangents[this._pointAtData.previousPointArrayIndex]},e.prototype.getNormalAt=function(e,t){return void 0===t&&(t=!1),this._updatePointAtData(e,t),t?p.TransformCoordinates(p.Right(),this._pointAtData.interpolationMatrix):this._normals[this._pointAtData.previousPointArrayIndex]},e.prototype.getBinormalAt=function(e,t){return void 0===t&&(t=!1),this._updatePointAtData(e,t),t?p.TransformCoordinates(p.UpReadOnly,this._pointAtData.interpolationMatrix):this._binormals[this._pointAtData.previousPointArrayIndex]},e.prototype.getDistanceAt=function(e){return this.length()*e},e.prototype.getPreviousPointIndexAt=function(e){return this._updatePointAtData(e),this._pointAtData.previousPointArrayIndex},e.prototype.getSubPositionAt=function(e){return this._updatePointAtData(e),this._pointAtData.subPosition},e.prototype.getClosestPositionTo=function(e){for(var t=Number.MAX_VALUE,i=0,r=0;r<this._curve.length-1;r++){var n=this._curve[r+0],o=this._curve[r+1].subtract(n).normalize(),s=this._distances[r+1]-this._distances[r+0],a=Math.min(Math.max(p.Dot(o,e.subtract(n).normalize()),0)*p.Distance(n,e)/s,1),h=p.Distance(n.add(o.scale(a*s)),e);h<t&&(t=h,i=(this._distances[r+0]+s*a)/this.length())}return i},e.prototype.slice=function(t,i){if(void 0===t&&(t=0),void 0===i&&(i=1),t<0&&(t=1- -1*t%1),i<0&&(i=1- -1*i%1),t>i){var r=t;t=i,i=r}var n=this.getCurve(),o=this.getPointAt(t),s=this.getPreviousPointIndexAt(t),a=this.getPointAt(i),h=this.getPreviousPointIndexAt(i)+1,u=[];return 0!==t&&(s++,u.push(o)),u.push.apply(u,n.slice(s,h)),1===i&&1!==t||u.push(a),new e(u,this.getNormalAt(t),this._raw,this._alignTangentsWithPath)},e.prototype.update=function(e,t,i){void 0===t&&(t=null),void 0===i&&(i=!1);for(var r=0;r<e.length;r++)this._curve[r].x=e[r].x,this._curve[r].y=e[r].y,this._curve[r].z=e[r].z;return this._compute(t,i),this},e.prototype._compute=function(e,t){void 0===t&&(t=!1);var i=this._curve.length;if(!(i<2)){this._tangents[0]=this._getFirstNonNullVector(0),this._raw||this._tangents[0].normalize(),this._tangents[i-1]=this._curve[i-1].subtract(this._curve[i-2]),this._raw||this._tangents[i-1].normalize();var r,n,o,s,a,h=this._tangents[0],u=this._normalVector(h,e);this._normals[0]=u,this._raw||this._normals[0].normalize(),this._binormals[0]=p.Cross(h,this._normals[0]),this._raw||this._binormals[0].normalize(),this._distances[0]=0;for(var l=1;l<i;l++)r=this._getLastNonNullVector(l),l<i-1&&(n=this._getFirstNonNullVector(l),this._tangents[l]=t?n:r.add(n),this._tangents[l].normalize()),this._distances[l]=this._distances[l-1]+this._curve[l].subtract(this._curve[l-1]).length(),o=this._tangents[l],a=this._binormals[l-1],this._normals[l]=p.Cross(a,o),this._raw||(0===this._normals[l].length()?(s=this._normals[l-1],this._normals[l]=s.clone()):this._normals[l].normalize()),this._binormals[l]=p.Cross(o,this._normals[l]),this._raw||this._binormals[l].normalize();this._pointAtData.id=NaN}},e.prototype._getFirstNonNullVector=function(e){for(var t=1,i=this._curve[e+t].subtract(this._curve[e]);0===i.length()&&e+t+1<this._curve.length;)t++,i=this._curve[e+t].subtract(this._curve[e]);return i},e.prototype._getLastNonNullVector=function(e){for(var t=1,i=this._curve[e].subtract(this._curve[e-t]);0===i.length()&&e>t+1;)t++,i=this._curve[e].subtract(this._curve[e-t]);return i},e.prototype._normalVector=function(e,t){var i,r,n=e.length();(0===n&&(n=1),null==t)?(r=s.WithinEpsilon(Math.abs(e.y)/n,1,u)?s.WithinEpsilon(Math.abs(e.x)/n,1,u)?s.WithinEpsilon(Math.abs(e.z)/n,1,u)?p.Zero():new p(0,0,1):new p(1,0,0):new p(0,-1,0),i=p.Cross(e,r)):(i=p.Cross(e,t),p.CrossToRef(i,e,i));return i.normalize(),i},e.prototype._updatePointAtData=function(e,t){if(void 0===t&&(t=!1),this._pointAtData.id===e)return this._pointAtData.interpolateReady||this._updateInterpolationMatrix(),this._pointAtData;this._pointAtData.id=e;var i=this.getPoints();if(e<=0)return this._setPointAtData(0,0,i[0],0,t);if(e>=1)return this._setPointAtData(1,1,i[i.length-1],i.length-1,t);for(var r,n=i[0],o=0,s=e*this.length(),a=1;a<i.length;a++){r=i[a];var h=p.Distance(n,r);if((o+=h)===s)return this._setPointAtData(e,1,r,a,t);if(o>s){var u=(o-s)/h,l=n.subtract(r),c=r.add(l.scaleInPlace(u));return this._setPointAtData(e,1-u,c,a-1,t)}n=r}return this._pointAtData},e.prototype._setPointAtData=function(e,t,i,r,n){return this._pointAtData.point=i,this._pointAtData.position=e,this._pointAtData.subPosition=t,this._pointAtData.previousPointArrayIndex=r,this._pointAtData.interpolateReady=n,n&&this._updateInterpolationMatrix(),this._pointAtData},e.prototype._updateInterpolationMatrix=function(){this._pointAtData.interpolationMatrix=m.Identity();var e=this._pointAtData.previousPointArrayIndex;if(e!==this._tangents.length-1){var t=e+1,i=this._tangents[e].clone(),r=this._normals[e].clone(),n=this._binormals[e].clone(),o=this._tangents[t].clone(),s=this._normals[t].clone(),a=this._binormals[t].clone(),h=g.RotationQuaternionFromAxis(r,n,i),u=g.RotationQuaternionFromAxis(s,a,o);g.Slerp(h,u,this._pointAtData.subPosition).toRotationMatrix(this._pointAtData.interpolationMatrix)}},e}(),hi=function(){function e(){this._easingMode=e.EASINGMODE_EASEIN}return e.prototype.setEasingMode=function(e){var t=Math.min(Math.max(e,0),2);this._easingMode=t},e.prototype.getEasingMode=function(){return this._easingMode},e.prototype.easeInCore=function(e){throw new Error("You must implement this method")},e.prototype.ease=function(t){switch(this._easingMode){case e.EASINGMODE_EASEIN:return this.easeInCore(t);case e.EASINGMODE_EASEOUT:return 1-this.easeInCore(1-t)}return t>=.5?.5*(1-this.easeInCore(2*(1-t)))+.5:.5*this.easeInCore(2*t)},e.EASINGMODE_EASEIN=0,e.EASINGMODE_EASEOUT=1,e.EASINGMODE_EASEINOUT=2,e}(),ui=(function(e){function i(){return null!==e&&e.apply(this,arguments)||this}t(i,e),i.prototype.easeInCore=function(e){return e=Math.max(0,Math.min(1,e)),1-Math.sqrt(1-e*e)}}(hi),function(e){function i(t){void 0===t&&(t=1);var i=e.call(this)||this;return i.amplitude=t,i}return t(i,e),i.prototype.easeInCore=function(e){var t=Math.max(0,this.amplitude);return Math.pow(e,3)-e*t*Math.sin(3.141592653589793*e)},i}(hi)),li=(function(e){function i(t,i){void 0===t&&(t=3),void 0===i&&(i=2);var r=e.call(this)||this;return r.bounces=t,r.bounciness=i,r}t(i,e),i.prototype.easeInCore=function(e){var t=Math.max(0,this.bounces),i=this.bounciness;i<=1&&(i=1.001);var r=Math.pow(i,t),n=1-i,o=(1-r)/n+.5*r,s=e*o,a=Math.log(-s*(1-i)+1)/Math.log(i),h=Math.floor(a),u=h+1,l=(1-Math.pow(i,h))/(n*o),c=.5*(l+(1-Math.pow(i,u))/(n*o)),f=e-c,d=c-l;return-Math.pow(1/i,t-h)/(d*d)*(f-d)*(f+d)}}(hi),function(e){function i(){return null!==e&&e.apply(this,arguments)||this}t(i,e),i.prototype.easeInCore=function(e){return e*e*e}}(hi),function(e){function i(t,i){void 0===t&&(t=3),void 0===i&&(i=3);var r=e.call(this)||this;return r.oscillations=t,r.springiness=i,r}t(i,e),i.prototype.easeInCore=function(e){var t=Math.max(0,this.oscillations),i=Math.max(0,this.springiness);return(0==i?e:(Math.exp(i*e)-1)/(Math.exp(i)-1))*Math.sin((6.283185307179586*t+1.5707963267948966)*e)}}(hi),function(e){function i(t){void 0===t&&(t=2);var i=e.call(this)||this;return i.exponent=t,i}return t(i,e),i.prototype.easeInCore=function(e){return this.exponent<=0?e:(Math.exp(this.exponent*e)-1)/(Math.exp(this.exponent)-1)},i}(hi)),ci=(function(e){function i(t){void 0===t&&(t=2);var i=e.call(this)||this;return i.power=t,i}t(i,e),i.prototype.easeInCore=function(e){var t=Math.max(0,this.power);return Math.pow(e,t)}}(hi),function(e){function i(){return null!==e&&e.apply(this,arguments)||this}t(i,e),i.prototype.easeInCore=function(e){return e*e}}(hi),function(e){function i(){return null!==e&&e.apply(this,arguments)||this}t(i,e),i.prototype.easeInCore=function(e){return e*e*e*e}}(hi),function(e){function i(){return null!==e&&e.apply(this,arguments)||this}t(i,e),i.prototype.easeInCore=function(e){return e*e*e*e*e}}(hi),function(e){function i(){return null!==e&&e.apply(this,arguments)||this}t(i,e),i.prototype.easeInCore=function(e){return 1-Math.sin(1.5707963267948966*(1-e))}}(hi),function(e){function i(t,i,r,n){void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=1),void 0===n&&(n=1);var o=e.call(this)||this;return o.x1=t,o.y1=i,o.x2=r,o.y2=n,o}t(i,e),i.prototype.easeInCore=function(e){return ri.Interpolate(e,this.x1,this.y1,this.x2,this.y2)}}(hi),function(){function e(){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(e.prototype,"name",{get:function(){return"Bouncing"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"autoTransitionRange",{get:function(){return this._autoTransitionRange},set:function(e){var t=this;if(this._autoTransitionRange!==e){this._autoTransitionRange=e;var i=this._attachedCamera;i&&(e?this._onMeshTargetChangedObserver=i.onMeshTargetChangedObservable.add((function(e){if(e){e.computeWorldMatrix(!0);var i=e.getBoundingInfo().diagonalLength;t.lowerRadiusTransitionRange=.05*i,t.upperRadiusTransitionRange=.05*i}})):this._onMeshTargetChangedObserver&&i.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver))}},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e){var t=this;this._attachedCamera=e,this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add((function(){t._attachedCamera&&(t._isRadiusAtLimit(t._attachedCamera.lowerRadiusLimit)&&t._applyBoundRadiusAnimation(t.lowerRadiusTransitionRange),t._isRadiusAtLimit(t._attachedCamera.upperRadiusLimit)&&t._applyBoundRadiusAnimation(t.upperRadiusTransitionRange))}))},e.prototype.detach=function(){this._attachedCamera&&(this._onAfterCheckInputsObserver&&this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._onMeshTargetChangedObserver&&this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),this._attachedCamera=null)},e.prototype._isRadiusAtLimit=function(e){return!!this._attachedCamera&&(this._attachedCamera.radius===e&&!this._radiusIsAnimating)},e.prototype._applyBoundRadiusAnimation=function(t){var i=this;if(this._attachedCamera){this._radiusBounceTransition||(e.EasingFunction.setEasingMode(e.EasingMode),this._radiusBounceTransition=lt.CreateAnimation("radius",lt.ANIMATIONTYPE_FLOAT,60,e.EasingFunction)),this._cachedWheelPrecision=this._attachedCamera.wheelPrecision,this._attachedCamera.wheelPrecision=1/0,this._attachedCamera.inertialRadiusOffset=0,this.stopAllAnimations(),this._radiusIsAnimating=!0;var r=lt.TransitionTo("radius",this._attachedCamera.radius+t,this._attachedCamera,this._attachedCamera.getScene(),60,this._radiusBounceTransition,this.transitionDuration,(function(){return i._clearAnimationLocks()}));r&&this._animatables.push(r)}},e.prototype._clearAnimationLocks=function(){this._radiusIsAnimating=!1,this._attachedCamera&&(this._attachedCamera.wheelPrecision=this._cachedWheelPrecision)},e.prototype.stopAllAnimations=function(){for(this._attachedCamera&&(this._attachedCamera.animations=[]);this._animatables.length;)this._animatables[0].onAnimationEnd=null,this._animatables[0].stop(),this._animatables.shift()},e.EasingFunction=new ui(.3),e.EasingMode=hi.EASINGMODE_EASEOUT,e}()),fi=function(){function e(){this._mode=e.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(e.prototype,"name",{get:function(){return"Framing"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mode",{get:function(){return this._mode},set:function(e){this._mode=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"radiusScale",{get:function(){return this._radiusScale},set:function(e){this._radiusScale=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"positionScale",{get:function(){return this._positionScale},set:function(e){this._positionScale=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"defaultElevation",{get:function(){return this._defaultElevation},set:function(e){this._defaultElevation=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"elevationReturnTime",{get:function(){return this._elevationReturnTime},set:function(e){this._elevationReturnTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"elevationReturnWaitTime",{get:function(){return this._elevationReturnWaitTime},set:function(e){this._elevationReturnWaitTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"zoomStopsAnimation",{get:function(){return this._zoomStopsAnimation},set:function(e){this._zoomStopsAnimation=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"framingTime",{get:function(){return this._framingTime},set:function(e){this._framingTime=e},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(t){var i=this;this._attachedCamera=t;var r=this._attachedCamera.getScene();e.EasingFunction.setEasingMode(e.EasingMode),this._onPrePointerObservableObserver=r.onPrePointerObservable.add((function(e){e.type!==Jt.POINTERDOWN?e.type===Jt.POINTERUP&&(i._isPointerDown=!1):i._isPointerDown=!0})),this._onMeshTargetChangedObserver=t.onMeshTargetChangedObservable.add((function(e){e&&i.zoomOnMesh(e)})),this._onAfterCheckInputsObserver=t.onAfterCheckInputsObservable.add((function(){i._applyUserInteraction(),i._maintainCameraAboveGround()}))},e.prototype.detach=function(){if(this._attachedCamera){var e=this._attachedCamera.getScene();this._onPrePointerObservableObserver&&e.onPrePointerObservable.remove(this._onPrePointerObservableObserver),this._onAfterCheckInputsObserver&&this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._onMeshTargetChangedObserver&&this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),this._attachedCamera=null}},e.prototype.zoomOnMesh=function(e,t,i){void 0===t&&(t=!1),void 0===i&&(i=null),e.computeWorldMatrix(!0);var r=e.getBoundingInfo().boundingBox;this.zoomOnBoundingInfo(r.minimumWorld,r.maximumWorld,t,i)},e.prototype.zoomOnMeshHierarchy=function(e,t,i){void 0===t&&(t=!1),void 0===i&&(i=null),e.computeWorldMatrix(!0);var r=e.getHierarchyBoundingVectors(!0);this.zoomOnBoundingInfo(r.min,r.max,t,i)},e.prototype.zoomOnMeshesHierarchy=function(e,t,i){void 0===t&&(t=!1),void 0===i&&(i=null);for(var r=new p(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),n=new p(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),o=0;o<e.length;o++){var s=e[o].getHierarchyBoundingVectors(!0);p.CheckExtends(s.min,r,n),p.CheckExtends(s.max,r,n)}this.zoomOnBoundingInfo(r,n,t,i)},e.prototype.zoomOnBoundingInfo=function(t,i,r,n){var o,s=this;if(void 0===r&&(r=!1),void 0===n&&(n=null),this._attachedCamera){var a=t.y,h=a+(i.y-a)*this._positionScale,u=i.subtract(t).scale(.5);if(r)o=new p(0,h,0);else{var l=t.add(u);o=new p(l.x,h,l.z)}this._vectorTransition||(this._vectorTransition=lt.CreateAnimation("target",lt.ANIMATIONTYPE_VECTOR3,60,e.EasingFunction)),this._betaIsAnimating=!0;var c=lt.TransitionTo("target",o,this._attachedCamera,this._attachedCamera.getScene(),60,this._vectorTransition,this._framingTime);c&&this._animatables.push(c);var f=0;if(this._mode===e.FitFrustumSidesMode){var d=this._calculateLowerRadiusFromModelBoundingSphere(t,i);this.autoCorrectCameraLimitsAndSensibility&&(this._attachedCamera.lowerRadiusLimit=u.length()+this._attachedCamera.minZ),f=d}else this._mode===e.IgnoreBoundsSizeMode&&(f=this._calculateLowerRadiusFromModelBoundingSphere(t,i),this.autoCorrectCameraLimitsAndSensibility&&null===this._attachedCamera.lowerRadiusLimit&&(this._attachedCamera.lowerRadiusLimit=this._attachedCamera.minZ));if(this.autoCorrectCameraLimitsAndSensibility){var _=i.subtract(t).length();this._attachedCamera.panningSensibility=5e3/_,this._attachedCamera.wheelPrecision=100/f}this._radiusTransition||(this._radiusTransition=lt.CreateAnimation("radius",lt.ANIMATIONTYPE_FLOAT,60,e.EasingFunction)),(c=lt.TransitionTo("radius",f,this._attachedCamera,this._attachedCamera.getScene(),60,this._radiusTransition,this._framingTime,(function(){s.stopAllAnimations(),n&&n(),s._attachedCamera&&s._attachedCamera.useInputToRestoreState&&s._attachedCamera.storeState()})))&&this._animatables.push(c)}},e.prototype._calculateLowerRadiusFromModelBoundingSphere=function(t,i){var r=i.subtract(t).length(),n=this._getFrustumSlope(),o=.5*r*this._radiusScale,s=o*Math.sqrt(1+1/(n.x*n.x)),a=o*Math.sqrt(1+1/(n.y*n.y)),h=Math.max(s,a),u=this._attachedCamera;return u?(u.lowerRadiusLimit&&this._mode===e.IgnoreBoundsSizeMode&&(h=h<u.lowerRadiusLimit?u.lowerRadiusLimit:h),u.upperRadiusLimit&&(h=h>u.upperRadiusLimit?u.upperRadiusLimit:h),h):0},e.prototype._maintainCameraAboveGround=function(){var t=this;if(!(this._elevationReturnTime<0)){var i=Fe.Now-this._lastInteractionTime,r=.5*Math.PI-this._defaultElevation,n=.5*Math.PI;if(this._attachedCamera&&!this._betaIsAnimating&&this._attachedCamera.beta>n&&i>=this._elevationReturnWaitTime){this._betaIsAnimating=!0,this.stopAllAnimations(),this._betaTransition||(this._betaTransition=lt.CreateAnimation("beta",lt.ANIMATIONTYPE_FLOAT,60,e.EasingFunction));var o=lt.TransitionTo("beta",r,this._attachedCamera,this._attachedCamera.getScene(),60,this._betaTransition,this._elevationReturnTime,(function(){t._clearAnimationLocks(),t.stopAllAnimations()}));o&&this._animatables.push(o)}}},e.prototype._getFrustumSlope=function(){var e=this._attachedCamera;if(!e)return d.Zero();var t=e.getScene().getEngine().getAspectRatio(e),i=Math.tan(e.fov/2);return new d(i*t,i)},e.prototype._clearAnimationLocks=function(){this._betaIsAnimating=!1},e.prototype._applyUserInteraction=function(){this.isUserIsMoving&&(this._lastInteractionTime=Fe.Now,this.stopAllAnimations(),this._clearAnimationLocks())},e.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(e.prototype,"isUserIsMoving",{get:function(){return!!this._attachedCamera&&(0!==this._attachedCamera.inertialAlphaOffset||0!==this._attachedCamera.inertialBetaOffset||0!==this._attachedCamera.inertialRadiusOffset||0!==this._attachedCamera.inertialPanningX||0!==this._attachedCamera.inertialPanningY||this._isPointerDown)},enumerable:!1,configurable:!0}),e.EasingFunction=new li,e.EasingMode=hi.EASINGMODE_EASEINOUT,e.IgnoreBoundsSizeMode=0,e.FitFrustumSidesMode=1,e}(),di=function(){function e(t){this.length=0,this.data=new Array(t),this._id=e._GlobalId++}return e.prototype.push=function(e){this.data[this.length++]=e,this.length>this.data.length&&(this.data.length*=2)},e.prototype.forEach=function(e){for(var t=0;t<this.length;t++)e(this.data[t])},e.prototype.sort=function(e){this.data.sort(e)},e.prototype.reset=function(){this.length=0},e.prototype.dispose=function(){this.reset(),this.data&&(this.data.length=0,this.data=[])},e.prototype.concat=function(e){if(0!==e.length){this.length+e.length>this.data.length&&(this.data.length=2*(this.length+e.length));for(var t=0;t<e.length;t++)this.data[this.length++]=(e.data||e)[t]}},e.prototype.indexOf=function(e){var t=this.data.indexOf(e);return t>=this.length?-1:t},e.prototype.contains=function(e){return-1!==this.indexOf(e)},e._GlobalId=0,e}(),pi=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t._duplicateId=0,t}return t(i,e),i.prototype.push=function(t){e.prototype.push.call(this,t),t.__smartArrayFlags||(t.__smartArrayFlags={}),t.__smartArrayFlags[this._id]=this._duplicateId},i.prototype.pushNoDuplicate=function(e){return(!e.__smartArrayFlags||e.__smartArrayFlags[this._id]!==this._duplicateId)&&(this.push(e),!0)},i.prototype.reset=function(){e.prototype.reset.call(this),this._duplicateId++},i.prototype.concatWithNoDuplicate=function(e){if(0!==e.length){this.length+e.length>this.data.length&&(this.data.length=2*(this.length+e.length));for(var t=0;t<e.length;t++){var i=(e.data||e)[t];this.pushNoDuplicate(i)}}},i}(di),_i=function(){function e(e,t,i,r){this.x=e,this.y=t,this.width=i,this.height=r}return e.prototype.toGlobal=function(t,i){return new e(this.x*t,this.y*i,this.width*t,this.height*i)},e.prototype.toGlobalToRef=function(e,t,i){return i.x=this.x*e,i.y=this.y*t,i.width=this.width*e,i.height=this.height*t,this},e.prototype.clone=function(){return new e(this.x,this.y,this.width,this.height)},e}(),gi=function(){function e(){}return e.GetPlanes=function(t){for(var i=[],r=0;r<6;r++)i.push(new Ie(0,0,0,0));return e.GetPlanesToRef(t,i),i},e.GetNearPlaneToRef=function(e,t){var i=e.m;t.normal.x=i[3]+i[2],t.normal.y=i[7]+i[6],t.normal.z=i[11]+i[10],t.d=i[15]+i[14],t.normalize()},e.GetFarPlaneToRef=function(e,t){var i=e.m;t.normal.x=i[3]-i[2],t.normal.y=i[7]-i[6],t.normal.z=i[11]-i[10],t.d=i[15]-i[14],t.normalize()},e.GetLeftPlaneToRef=function(e,t){var i=e.m;t.normal.x=i[3]+i[0],t.normal.y=i[7]+i[4],t.normal.z=i[11]+i[8],t.d=i[15]+i[12],t.normalize()},e.GetRightPlaneToRef=function(e,t){var i=e.m;t.normal.x=i[3]-i[0],t.normal.y=i[7]-i[4],t.normal.z=i[11]-i[8],t.d=i[15]-i[12],t.normalize()},e.GetTopPlaneToRef=function(e,t){var i=e.m;t.normal.x=i[3]-i[1],t.normal.y=i[7]-i[5],t.normal.z=i[11]-i[9],t.d=i[15]-i[13],t.normalize()},e.GetBottomPlaneToRef=function(e,t){var i=e.m;t.normal.x=i[3]+i[1],t.normal.y=i[7]+i[5],t.normal.z=i[11]+i[9],t.d=i[15]+i[13],t.normalize()},e.GetPlanesToRef=function(t,i){e.GetNearPlaneToRef(t,i[0]),e.GetFarPlaneToRef(t,i[1]),e.GetLeftPlaneToRef(t,i[2]),e.GetRightPlaneToRef(t,i[3]),e.GetTopPlaneToRef(t,i[4]),e.GetBottomPlaneToRef(t,i[5])},e}(),mi=function(e){function i(t,r,n,o){void 0===o&&(o=!0);var s=e.call(this,t,n)||this;return s._position=p.Zero(),s._upVector=p.Up(),s.orthoLeft=null,s.orthoRight=null,s.orthoBottom=null,s.orthoTop=null,s.fov=.8,s.minZ=1,s.maxZ=1e4,s.inertia=.9,s.mode=i.PERSPECTIVE_CAMERA,s.isIntermediate=!1,s.viewport=new _i(0,0,1,1),s.layerMask=268435455,s.fovMode=i.FOVMODE_VERTICAL_FIXED,s.cameraRigMode=i.RIG_MODE_NONE,s.customRenderTargets=new Array,s.outputRenderTarget=null,s.onViewMatrixChangedObservable=new U,s.onProjectionMatrixChangedObservable=new U,s.onAfterCheckInputsObservable=new U,s.onRestoreStateObservable=new U,s.isRigCamera=!1,s._rigCameras=new Array,s._webvrViewMatrix=m.Identity(),s._skipRendering=!1,s._projectionMatrix=new m,s._postProcesses=new Array,s._activeMeshes=new di(256),s._globalPosition=p.Zero(),s._computedViewMatrix=m.Identity(),s._doNotComputeProjectionMatrix=!1,s._transformMatrix=m.Zero(),s._refreshFrustumPlanes=!0,s._isCamera=!0,s._isLeftCamera=!1,s._isRightCamera=!1,s.getScene().addCamera(s),o&&!s.getScene().activeCamera&&(s.getScene().activeCamera=s),s.position=r,s}return t(i,e),Object.defineProperty(i.prototype,"position",{get:function(){return this._position},set:function(e){this._position=e},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"upVector",{get:function(){return this._upVector},set:function(e){this._upVector=e},enumerable:!1,configurable:!0}),i.prototype.storeState=function(){return this._stateStored=!0,this._storedFov=this.fov,this},i.prototype._restoreStateValues=function(){return!!this._stateStored&&(this.fov=this._storedFov,!0)},i.prototype.restoreState=function(){return!!this._restoreStateValues()&&(this.onRestoreStateObservable.notifyObservers(this),!0)},i.prototype.getClassName=function(){return"Camera"},i.prototype.toString=function(e){var t="Name: "+this.name;if(t+=", type: "+this.getClassName(),this.animations)for(var i=0;i<this.animations.length;i++)t+=", animation[0]: "+this.animations[i].toString(e);return t},Object.defineProperty(i.prototype,"globalPosition",{get:function(){return this._globalPosition},enumerable:!1,configurable:!0}),i.prototype.getActiveMeshes=function(){return this._activeMeshes},i.prototype.isActiveMesh=function(e){return-1!==this._activeMeshes.indexOf(e)},i.prototype.isReady=function(t){if(void 0===t&&(t=!1),t)for(var i=0,r=this._postProcesses;i<r.length;i++){var n=r[i];if(n&&!n.isReady())return!1}return e.prototype.isReady.call(this,t)},i.prototype._initCache=function(){e.prototype._initCache.call(this),this._cache.position=new p(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.upVector=new p(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.mode=void 0,this._cache.minZ=void 0,this._cache.maxZ=void 0,this._cache.fov=void 0,this._cache.fovMode=void 0,this._cache.aspectRatio=void 0,this._cache.orthoLeft=void 0,this._cache.orthoRight=void 0,this._cache.orthoBottom=void 0,this._cache.orthoTop=void 0,this._cache.renderWidth=void 0,this._cache.renderHeight=void 0},i.prototype._updateCache=function(t){t||e.prototype._updateCache.call(this),this._cache.position.copyFrom(this.position),this._cache.upVector.copyFrom(this.upVector)},i.prototype._isSynchronized=function(){return this._isSynchronizedViewMatrix()&&this._isSynchronizedProjectionMatrix()},i.prototype._isSynchronizedViewMatrix=function(){return!!e.prototype._isSynchronized.call(this)&&(this._cache.position.equals(this.position)&&this._cache.upVector.equals(this.upVector)&&this.isSynchronizedWithParent())},i.prototype._isSynchronizedProjectionMatrix=function(){var e=this._cache.mode===this.mode&&this._cache.minZ===this.minZ&&this._cache.maxZ===this.maxZ;if(!e)return!1;var t=this.getEngine();return e=this.mode===i.PERSPECTIVE_CAMERA?this._cache.fov===this.fov&&this._cache.fovMode===this.fovMode&&this._cache.aspectRatio===t.getAspectRatio(this):this._cache.orthoLeft===this.orthoLeft&&this._cache.orthoRight===this.orthoRight&&this._cache.orthoBottom===this.orthoBottom&&this._cache.orthoTop===this.orthoTop&&this._cache.renderWidth===t.getRenderWidth()&&this._cache.renderHeight===t.getRenderHeight()},i.prototype.attachControl=function(e,t){},i.prototype.detachControl=function(e){},i.prototype.update=function(){this._checkInputs(),this.cameraRigMode!==i.RIG_MODE_NONE&&this._updateRigCameras()},i.prototype._checkInputs=function(){this.onAfterCheckInputsObservable.notifyObservers(this)},Object.defineProperty(i.prototype,"rigCameras",{get:function(){return this._rigCameras},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"rigPostProcess",{get:function(){return this._rigPostProcess},enumerable:!1,configurable:!0}),i.prototype._getFirstPostProcess=function(){for(var e=0;e<this._postProcesses.length;e++)if(null!==this._postProcesses[e])return this._postProcesses[e];return null},i.prototype._cascadePostProcessesToRigCams=function(){var e=this._getFirstPostProcess();e&&e.markTextureDirty();for(var t=0,i=this._rigCameras.length;t<i;t++){var r=this._rigCameras[t],n=r._rigPostProcess;if(n)"pass"===n.getEffectName()&&(r.isIntermediate=0===this._postProcesses.length),r._postProcesses=this._postProcesses.slice(0).concat(n),n.markTextureDirty();else r._postProcesses=this._postProcesses.slice(0)}},i.prototype.attachPostProcess=function(e,t){return void 0===t&&(t=null),!e.isReusable()&&this._postProcesses.indexOf(e)>-1?(q.Error("You're trying to reuse a post process not defined as reusable."),0):(null==t||t<0?this._postProcesses.push(e):null===this._postProcesses[t]?this._postProcesses[t]=e:this._postProcesses.splice(t,0,e),this._cascadePostProcessesToRigCams(),this._scene.prePassRenderer&&this._scene.prePassRenderer.markAsDirty(),this._postProcesses.indexOf(e))},i.prototype.detachPostProcess=function(e){var t=this._postProcesses.indexOf(e);-1!==t&&(this._postProcesses[t]=null),this._scene.prePassRenderer&&this._scene.prePassRenderer.markAsDirty(),this._cascadePostProcessesToRigCams()},i.prototype.getWorldMatrix=function(){return this._isSynchronizedViewMatrix()||this.getViewMatrix(),this._worldMatrix},i.prototype._getViewMatrix=function(){return m.Identity()},i.prototype.getViewMatrix=function(e){return!e&&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},i.prototype.freezeProjectionMatrix=function(e){this._doNotComputeProjectionMatrix=!0,void 0!==e&&(this._projectionMatrix=e)},i.prototype.unfreezeProjectionMatrix=function(){this._doNotComputeProjectionMatrix=!1},i.prototype.getProjectionMatrix=function(e){var t,r,n,o,s,a,h,u;if(this._doNotComputeProjectionMatrix||!e&&this._isSynchronizedProjectionMatrix())return this._projectionMatrix;this._cache.mode=this.mode,this._cache.minZ=this.minZ,this._cache.maxZ=this.maxZ,this._refreshFrustumPlanes=!0;var l=this.getEngine(),c=this.getScene();if(this.mode===i.PERSPECTIVE_CAMERA){this._cache.fov=this.fov,this._cache.fovMode=this.fovMode,this._cache.aspectRatio=l.getAspectRatio(this),this.minZ<=0&&(this.minZ=.1);var f=l.useReverseDepthBuffer;(c.useRightHandedSystem?f?m.PerspectiveFovReverseRHToRef:m.PerspectiveFovRHToRef:f?m.PerspectiveFovReverseLHToRef:m.PerspectiveFovLHToRef)(this.fov,l.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===i.FOVMODE_VERTICAL_FIXED)}else{var d=l.getRenderWidth()/2,p=l.getRenderHeight()/2;c.useRightHandedSystem?m.OrthoOffCenterRHToRef(null!==(t=this.orthoLeft)&&void 0!==t?t:-d,null!==(r=this.orthoRight)&&void 0!==r?r:d,null!==(n=this.orthoBottom)&&void 0!==n?n:-p,null!==(o=this.orthoTop)&&void 0!==o?o:p,this.minZ,this.maxZ,this._projectionMatrix):m.OrthoOffCenterLHToRef(null!==(s=this.orthoLeft)&&void 0!==s?s:-d,null!==(a=this.orthoRight)&&void 0!==a?a:d,null!==(h=this.orthoBottom)&&void 0!==h?h:-p,null!==(u=this.orthoTop)&&void 0!==u?u:p,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=l.getRenderWidth(),this._cache.renderHeight=l.getRenderHeight()}return this.onProjectionMatrixChangedObservable.notifyObservers(this),this._projectionMatrix},i.prototype.getTransformationMatrix=function(){return this._computedViewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._transformMatrix},i.prototype._updateFrustumPlanes=function(){this._refreshFrustumPlanes&&(this.getTransformationMatrix(),this._frustumPlanes?gi.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=gi.GetPlanes(this._transformMatrix),this._refreshFrustumPlanes=!1)},i.prototype.isInFrustum=function(e,t){if(void 0===t&&(t=!1),this._updateFrustumPlanes(),t&&this.rigCameras.length>0){var i=!1;return this.rigCameras.forEach((function(t){t._updateFrustumPlanes(),i=i||e.isInFrustum(t._frustumPlanes)})),i}return e.isInFrustum(this._frustumPlanes)},i.prototype.isCompletelyInFrustum=function(e){return this._updateFrustumPlanes(),e.isCompletelyInFrustum(this._frustumPlanes)},i.prototype.getForwardRay=function(e,t,i){throw b.WarnImport("Ray")},i.prototype.getForwardRayToRef=function(e,t,i,r){throw b.WarnImport("Ray")},i.prototype.dispose=function(t,r){for(void 0===r&&(r=!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 n=this._rigCameras.pop();n&&n.dispose()}if(this._rigPostProcess)this._rigPostProcess.dispose(this),this._rigPostProcess=null,this._postProcesses=[];else if(this.cameraRigMode!==i.RIG_MODE_NONE)this._rigPostProcess=null,this._postProcesses=[];else for(var o=this._postProcesses.length;--o>=0;){var s=this._postProcesses[o];s&&s.dispose(this)}for(o=this.customRenderTargets.length;--o>=0;)this.customRenderTargets[o].dispose();this.customRenderTargets=[],this._activeMeshes.dispose(),e.prototype.dispose.call(this,t,r)},Object.defineProperty(i.prototype,"isLeftCamera",{get:function(){return this._isLeftCamera},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"isRightCamera",{get:function(){return this._isRightCamera},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"leftCamera",{get:function(){return this._rigCameras.length<1?null:this._rigCameras[0]},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"rightCamera",{get:function(){return this._rigCameras.length<2?null:this._rigCameras[1]},enumerable:!1,configurable:!0}),i.prototype.getLeftTarget=function(){return this._rigCameras.length<1?null:this._rigCameras[0].getTarget()},i.prototype.getRightTarget=function(){return this._rigCameras.length<2?null:this._rigCameras[1].getTarget()},i.prototype.setCameraRigMode=function(e,t){if(this.cameraRigMode!==e){for(;this._rigCameras.length>0;){var r=this._rigCameras.pop();r&&r.dispose()}if(this.cameraRigMode=e,this._cameraRigParams={},this._cameraRigParams.interaxialDistance=t.interaxialDistance||.0637,this._cameraRigParams.stereoHalfAngle=Ue.ToRadians(this._cameraRigParams.interaxialDistance/.0637),this.cameraRigMode!==i.RIG_MODE_NONE){var n=this.createRigCamera(this.name+"_L",0);n&&(n._isLeftCamera=!0);var o=this.createRigCamera(this.name+"_R",1);o&&(o._isRightCamera=!0),n&&o&&(this._rigCameras.push(n),this._rigCameras.push(o))}switch(this.cameraRigMode){case i.RIG_MODE_STEREOSCOPIC_ANAGLYPH:i._setStereoscopicAnaglyphRigMode(this);break;case i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case i.RIG_MODE_STEREOSCOPIC_OVERUNDER:case i.RIG_MODE_STEREOSCOPIC_INTERLACED:i._setStereoscopicRigMode(this);break;case i.RIG_MODE_VR:i._setVRRigMode(this,t);break;case i.RIG_MODE_WEBVR:i._setWebVRRigMode(this,t)}this._cascadePostProcessesToRigCams(),this.update()}},i._setStereoscopicRigMode=function(e){throw"Import Cameras/RigModes/stereoscopicRigMode before using stereoscopic rig mode"},i._setStereoscopicAnaglyphRigMode=function(e){throw"Import Cameras/RigModes/stereoscopicAnaglyphRigMode before using stereoscopic anaglyph rig mode"},i._setVRRigMode=function(e,t){throw"Import Cameras/RigModes/vrRigMode before using VR rig mode"},i._setWebVRRigMode=function(e,t){throw"Import Cameras/RigModes/WebVRRigMode before using Web VR rig mode"},i.prototype._getVRProjectionMatrix=function(){return m.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},i.prototype._updateCameraRotationMatrix=function(){},i.prototype._updateWebVRCameraRotationMatrix=function(){},i.prototype._getWebVRProjectionMatrix=function(){return m.Identity()},i.prototype._getWebVRViewMatrix=function(){return m.Identity()},i.prototype.setCameraRigParameter=function(e,t){this._cameraRigParams||(this._cameraRigParams={}),this._cameraRigParams[e]=t,"interaxialDistance"===e&&(this._cameraRigParams.stereoHalfAngle=Ue.ToRadians(t/.0637))},i.prototype.createRigCamera=function(e,t){return null},i.prototype._updateRigCameras=function(){for(var e=0;e<this._rigCameras.length;e++)this._rigCameras[e].minZ=this.minZ,this._rigCameras[e].maxZ=this.maxZ,this._rigCameras[e].fov=this.fov,this._rigCameras[e].upVector.copyFrom(this.upVector);this.cameraRigMode===i.RIG_MODE_STEREOSCOPIC_ANAGLYPH&&(this._rigCameras[0].viewport=this._rigCameras[1].viewport=this.viewport)},i.prototype._setupInputs=function(){},i.prototype.serialize=function(){var e=N.Serialize(this);return e.type=this.getClassName(),this.parent&&(e.parentId=this.parent.id),this.inputs&&this.inputs.serialize(e),N.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e},i.prototype.clone=function(e){return N.Clone(i.GetConstructorFromName(this.getClassName(),e,this.getScene(),this.interaxialDistance,this.isStereoscopicSideBySide),this)},i.prototype.getDirection=function(e){var t=p.Zero();return this.getDirectionToRef(e,t),t},Object.defineProperty(i.prototype,"absoluteRotation",{get:function(){var e=g.Zero();return this.getWorldMatrix().decompose(void 0,e),e},enumerable:!1,configurable:!0}),i.prototype.getDirectionToRef=function(e,t){p.TransformNormalToRef(e,this.getWorldMatrix(),t)},i.GetConstructorFromName=function(e,t,r,n,o){void 0===n&&(n=0),void 0===o&&(o=!0);var s=ut.Construct(e,t,r,{interaxial_distance:n,isStereoscopicSideBySide:o});return s||function(){return i._createDefaultParsedCamera(t,r)}},i.prototype.computeWorldMatrix=function(){return this.getWorldMatrix()},i.Parse=function(e,t){var r=e.type,n=i.GetConstructorFromName(r,e.name,t,e.interaxial_distance,e.isStereoscopicSideBySide),o=N.Parse(n,e,t);if(e.parentId&&(o._waitingParentId=e.parentId),o.inputs&&(o.inputs.parse(e),o._setupInputs()),e.upVector&&(o.upVector=p.FromArray(e.upVector)),o.setPosition&&(o.position.copyFromFloats(0,0,0),o.setPosition(p.FromArray(e.position))),e.target&&o.setTarget&&o.setTarget(p.FromArray(e.target)),e.cameraRigMode){var s=e.interaxial_distance?{interaxialDistance:e.interaxial_distance}:{};o.setCameraRigMode(e.cameraRigMode,s)}if(e.animations){for(var a=0;a<e.animations.length;a++){var h=e.animations[a],u=c.GetClass("BABYLON.Animation");u&&o.animations.push(u.Parse(h))}ut.ParseAnimationRanges(o,e,t)}return e.autoAnimate&&t.beginAnimation(o,e.autoAnimateFrom,e.autoAnimateTo,e.autoAnimateLoop,e.autoAnimateSpeed||1),o},i._createDefaultParsedCamera=function(e,t){throw b.WarnImport("UniversalCamera")},i.PERSPECTIVE_CAMERA=0,i.ORTHOGRAPHIC_CAMERA=1,i.FOVMODE_VERTICAL_FIXED=0,i.FOVMODE_HORIZONTAL_FIXED=1,i.RIG_MODE_NONE=0,i.RIG_MODE_STEREOSCOPIC_ANAGLYPH=10,i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL=11,i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED=12,i.RIG_MODE_STEREOSCOPIC_OVERUNDER=13,i.RIG_MODE_STEREOSCOPIC_INTERLACED=14,i.RIG_MODE_VR=20,i.RIG_MODE_WEBVR=21,i.RIG_MODE_CUSTOM=22,i.ForceAttachControlToAlwaysPreventDefault=!1,r([L("position")],i.prototype,"_position",void 0),r([L("upVector")],i.prototype,"_upVector",void 0),r([O()],i.prototype,"orthoLeft",void 0),r([O()],i.prototype,"orthoRight",void 0),r([O()],i.prototype,"orthoBottom",void 0),r([O()],i.prototype,"orthoTop",void 0),r([O()],i.prototype,"fov",void 0),r([O()],i.prototype,"minZ",void 0),r([O()],i.prototype,"maxZ",void 0),r([O()],i.prototype,"inertia",void 0),r([O()],i.prototype,"mode",void 0),r([O()],i.prototype,"layerMask",void 0),r([O()],i.prototype,"fovMode",void 0),r([O()],i.prototype,"cameraRigMode",void 0),r([O()],i.prototype,"interaxialDistance",void 0),r([O()],i.prototype,"isStereoscopicSideBySide",void 0),i}(ut),vi=function(e){function i(t,i,r,n){void 0===n&&(n=!0);var o=e.call(this,t,i,r,n)||this;return o._tmpUpVector=p.Zero(),o._tmpTargetVector=p.Zero(),o.cameraDirection=new p(0,0,0),o.cameraRotation=new d(0,0),o.ignoreParentScaling=!1,o.updateUpVectorFromRotation=!1,o._tmpQuaternion=new g,o.rotation=new p(0,0,0),o.speed=2,o.noRotationConstraint=!1,o.invertRotation=!1,o.inverseRotationSpeed=.2,o.lockedTarget=null,o._currentTarget=p.Zero(),o._initialFocalDistance=1,o._viewMatrix=m.Zero(),o._camMatrix=m.Zero(),o._cameraTransformMatrix=m.Zero(),o._cameraRotationMatrix=m.Zero(),o._referencePoint=new p(0,0,1),o._transformedReferencePoint=p.Zero(),o._defaultUp=p.Up(),o._cachedRotationZ=0,o._cachedQuaternionRotationZ=0,o}var n;return t(i,e),i.prototype.getFrontPosition=function(e){this.getWorldMatrix();var t=this.getTarget().subtract(this.position);return t.normalize(),t.scaleInPlace(e),this.globalPosition.add(t)},i.prototype._getLockedTargetPosition=function(){return this.lockedTarget?(this.lockedTarget.absolutePosition&&this.lockedTarget.computeWorldMatrix(),this.lockedTarget.absolutePosition||this.lockedTarget):null},i.prototype.storeState=function(){return this._storedPosition=this.position.clone(),this._storedRotation=this.rotation.clone(),this.rotationQuaternion&&(this._storedRotationQuaternion=this.rotationQuaternion.clone()),e.prototype.storeState.call(this)},i.prototype._restoreStateValues=function(){return!!e.prototype._restoreStateValues.call(this)&&(this.position=this._storedPosition.clone(),this.rotation=this._storedRotation.clone(),this.rotationQuaternion&&(this.rotationQuaternion=this._storedRotationQuaternion.clone()),this.cameraDirection.copyFromFloats(0,0,0),this.cameraRotation.copyFromFloats(0,0),!0)},i.prototype._initCache=function(){e.prototype._initCache.call(this),this._cache.lockedTarget=new p(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotation=new p(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotationQuaternion=new g(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)},i.prototype._updateCache=function(t){t||e.prototype._updateCache.call(this);var i=this._getLockedTargetPosition();i?this._cache.lockedTarget?this._cache.lockedTarget.copyFrom(i):this._cache.lockedTarget=i.clone():this._cache.lockedTarget=null,this._cache.rotation.copyFrom(this.rotation),this.rotationQuaternion&&this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion)},i.prototype._isSynchronizedViewMatrix=function(){if(!e.prototype._isSynchronizedViewMatrix.call(this))return!1;var t=this._getLockedTargetPosition();return(this._cache.lockedTarget?this._cache.lockedTarget.equals(t):!t)&&(this.rotationQuaternion?this.rotationQuaternion.equals(this._cache.rotationQuaternion):this._cache.rotation.equals(this.rotation))},i.prototype._computeLocalCameraSpeed=function(){var e=this.getEngine();return this.speed*Math.sqrt(e.getDeltaTime()/(100*e.getFps()))},i.prototype.setTarget=function(e){this.upVector.normalize(),this._initialFocalDistance=e.subtract(this.position).length(),this.position.z===e.z&&(this.position.z+=u),this._referencePoint.normalize().scaleInPlace(this._initialFocalDistance),m.LookAtLHToRef(this.position,e,this._defaultUp,this._camMatrix),this._camMatrix.invert(),this.rotation.x=Math.atan(this._camMatrix.m[6]/this._camMatrix.m[10]);var t=e.subtract(this.position);t.x>=0?this.rotation.y=-Math.atan(t.z/t.x)+Math.PI/2:this.rotation.y=-Math.atan(t.z/t.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&&g.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)},Object.defineProperty(i.prototype,"target",{get:function(){return this.getTarget()},set:function(e){this.setTarget(e)},enumerable:!1,configurable:!0}),i.prototype.getTarget=function(){return this._currentTarget},i.prototype._decideIfNeedsToMove=function(){return Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},i.prototype._updatePosition=function(){if(this.parent)return this.parent.getWorldMatrix().invertToRef(y.Matrix[0]),p.TransformNormalToRef(this.cameraDirection,y.Matrix[0],y.Vector3[0]),void this.position.addInPlace(y.Vector3[0]);this.position.addInPlace(this.cameraDirection)},i.prototype._checkInputs=function(){var t=this.invertRotation?-this.inverseRotationSpeed:1,i=this._decideIfNeedsToMove(),r=Math.abs(this.cameraRotation.x)>0||Math.abs(this.cameraRotation.y)>0;if(i&&this._updatePosition(),r){if(this.rotationQuaternion&&this.rotationQuaternion.toEulerAnglesToRef(this.rotation),this.rotation.x+=this.cameraRotation.x*t,this.rotation.y+=this.cameraRotation.y*t,!this.noRotationConstraint){var n=1.570796;this.rotation.x>n&&(this.rotation.x=n),this.rotation.x<-n&&(this.rotation.x=-n)}if(this.rotationQuaternion)this.rotation.lengthSquared()&&g.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)}i&&(Math.abs(this.cameraDirection.x)<this.speed*u&&(this.cameraDirection.x=0),Math.abs(this.cameraDirection.y)<this.speed*u&&(this.cameraDirection.y=0),Math.abs(this.cameraDirection.z)<this.speed*u&&(this.cameraDirection.z=0),this.cameraDirection.scaleInPlace(this.inertia)),r&&(Math.abs(this.cameraRotation.x)<this.speed*u&&(this.cameraRotation.x=0),Math.abs(this.cameraRotation.y)<this.speed*u&&(this.cameraRotation.y=0),this.cameraRotation.scaleInPlace(this.inertia)),e.prototype._checkInputs.call(this)},i.prototype._updateCameraRotationMatrix=function(){this.rotationQuaternion?this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix):m.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this._cameraRotationMatrix)},i.prototype._rotateUpVectorWithCameraRotationMatrix=function(){return p.TransformNormalToRef(this._defaultUp,this._cameraRotationMatrix,this.upVector),this},i.prototype._getViewMatrix=function(){return this.lockedTarget&&this.setTarget(this._getLockedTargetPosition()),this._updateCameraRotationMatrix(),this.rotationQuaternion&&this._cachedQuaternionRotationZ!=this.rotationQuaternion.z?(this._rotateUpVectorWithCameraRotationMatrix(),this._cachedQuaternionRotationZ=this.rotationQuaternion.z):this._cachedRotationZ!=this.rotation.z&&(this._rotateUpVectorWithCameraRotationMatrix(),this._cachedRotationZ=this.rotation.z),p.TransformCoordinatesToRef(this._referencePoint,this._cameraRotationMatrix,this._transformedReferencePoint),this.position.addToRef(this._transformedReferencePoint,this._currentTarget),this.updateUpVectorFromRotation&&(this.rotationQuaternion?Dt.Y.rotateByQuaternionToRef(this.rotationQuaternion,this.upVector):(g.FromEulerVectorToRef(this.rotation,this._tmpQuaternion),Dt.Y.rotateByQuaternionToRef(this._tmpQuaternion,this.upVector))),this._computeViewMatrix(this.position,this._currentTarget,this.upVector),this._viewMatrix},i.prototype._computeViewMatrix=function(e,t,i){if(this.ignoreParentScaling){if(this.parent){var r=this.parent.getWorldMatrix();p.TransformCoordinatesToRef(e,r,this._globalPosition),p.TransformCoordinatesToRef(t,r,this._tmpTargetVector),p.TransformNormalToRef(i,r,this._tmpUpVector),this._markSyncedWithParent()}else this._globalPosition.copyFrom(e),this._tmpTargetVector.copyFrom(t),this._tmpUpVector.copyFrom(i);this.getScene().useRightHandedSystem?m.LookAtRHToRef(this._globalPosition,this._tmpTargetVector,this._tmpUpVector,this._viewMatrix):m.LookAtLHToRef(this._globalPosition,this._tmpTargetVector,this._tmpUpVector,this._viewMatrix)}else if(this.getScene().useRightHandedSystem?m.LookAtRHToRef(e,t,i,this._viewMatrix):m.LookAtLHToRef(e,t,i,this._viewMatrix),this.parent){r=this.parent.getWorldMatrix();this._viewMatrix.invert(),this._viewMatrix.multiplyToRef(r,this._viewMatrix),this._viewMatrix.getTranslationToRef(this._globalPosition),this._viewMatrix.invert(),this._markSyncedWithParent()}else this._globalPosition.copyFrom(e)},i.prototype.createRigCamera=function(e,t){if(this.cameraRigMode!==mi.RIG_MODE_NONE){var r=new i(e,this.position.clone(),this.getScene());return r.isRigCamera=!0,r.rigParent=this,this.cameraRigMode!==mi.RIG_MODE_VR&&this.cameraRigMode!==mi.RIG_MODE_WEBVR||(this.rotationQuaternion||(this.rotationQuaternion=new g),r._cameraRigParams={},r.rotationQuaternion=new g),r}return null},i.prototype._updateRigCameras=function(){var t=this._rigCameras[0],i=this._rigCameras[1];switch(this.computeWorldMatrix(),this.cameraRigMode){case mi.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case mi.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case mi.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case mi.RIG_MODE_STEREOSCOPIC_OVERUNDER:case mi.RIG_MODE_STEREOSCOPIC_INTERLACED:var r=this.cameraRigMode===mi.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED?1:-1,n=this.cameraRigMode===mi.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED?-1:1;this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle*r,t),this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle*n,i);break;case mi.RIG_MODE_VR:t.rotationQuaternion?(t.rotationQuaternion.copyFrom(this.rotationQuaternion),i.rotationQuaternion.copyFrom(this.rotationQuaternion)):(t.rotation.copyFrom(this.rotation),i.rotation.copyFrom(this.rotation)),t.position.copyFrom(this.position),i.position.copyFrom(this.position)}e.prototype._updateRigCameras.call(this)},i.prototype._getRigCamPositionAndTarget=function(e,t){this.getTarget().subtractToRef(this.position,i._TargetFocalPoint),i._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);var r=i._TargetFocalPoint.addInPlace(this.position);m.TranslationToRef(-r.x,-r.y,-r.z,i._TargetTransformMatrix),i._TargetTransformMatrix.multiplyToRef(m.RotationAxis(t.upVector,e),i._RigCamTransformMatrix),m.TranslationToRef(r.x,r.y,r.z,i._TargetTransformMatrix),i._RigCamTransformMatrix.multiplyToRef(i._TargetTransformMatrix,i._RigCamTransformMatrix),p.TransformCoordinatesToRef(this.position,i._RigCamTransformMatrix,t.position),t.setTarget(r)},i.prototype.getClassName=function(){return"TargetCamera"},i._RigCamTransformMatrix=new m,i._TargetTransformMatrix=new m,i._TargetFocalPoint=new p,r([L()],i.prototype,"rotation",void 0),r([O()],i.prototype,"speed",void 0),r([(n="lockedTargetId",S(6,n))],i.prototype,"lockedTarget",void 0),i}(mi),yi={},bi=function(){function e(e){this.attachedToElement=!1,this.attached={},this.camera=e,this.checkInputs=function(){}}return e.prototype.add=function(e){var t=e.getSimpleName();this.attached[t]?q.Warn("camera input of type "+t+" already exists on camera"):(this.attached[t]=e,e.camera=this.camera,e.checkInputs&&(this.checkInputs=this._addCheckInputs(e.checkInputs.bind(e))),this.attachedToElement&&e.attachControl())},e.prototype.remove=function(e){for(var t in this.attached){var i=this.attached[t];i===e&&(i.detachControl(),i.camera=null,delete this.attached[t],this.rebuildInputCheck())}},e.prototype.removeByType=function(e){for(var t in this.attached){var i=this.attached[t];i.getClassName()===e&&(i.detachControl(),i.camera=null,delete this.attached[t],this.rebuildInputCheck())}},e.prototype._addCheckInputs=function(e){var t=this.checkInputs;return function(){t(),e()}},e.prototype.attachInput=function(e){this.attachedToElement&&e.attachControl(this.noPreventDefault)},e.prototype.attachElement=function(e){if(void 0===e&&(e=!1),!this.attachedToElement)for(var t in e=!mi.ForceAttachControlToAlwaysPreventDefault&&e,this.attachedToElement=!0,this.noPreventDefault=e,this.attached)this.attached[t].attachControl(e)},e.prototype.detachElement=function(e){for(var t in void 0===e&&(e=!1),this.attached)this.attached[t].detachControl(),e&&(this.attached[t].camera=null);this.attachedToElement=!1},e.prototype.rebuildInputCheck=function(){for(var e in this.checkInputs=function(){},this.attached){var t=this.attached[e];t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t)))}},e.prototype.clear=function(){this.attachedToElement&&this.detachElement(!0),this.attached={},this.attachedToElement=!1,this.checkInputs=function(){}},e.prototype.serialize=function(e){var t={};for(var i in this.attached){var r=this.attached[i],n=N.Serialize(r);t[r.getClassName()]=n}e.inputsmgr=t},e.prototype.parse=function(e){var t=e.inputsmgr;if(t)for(var i in this.clear(),t){if(o=yi[i]){var r=t[i],n=N.Parse((function(){return new o}),r,null);this.add(n)}}else for(var i in this.attached){var o;if(o=yi[this.attached[i].getClassName()]){n=N.Parse((function(){return new o}),e,null);this.remove(this.attached[i]),this.add(n)}}},e}(),Ti=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.buttons=[0,1,2],t.angularSensibilityX=1e3,t.angularSensibilityY=1e3,t.pinchPrecision=12,t.pinchDeltaPercentage=0,t.useNaturalPinchZoom=!1,t.panningSensibility=1e3,t.multiTouchPanning=!0,t.multiTouchPanAndZoom=!0,t.pinchInwards=!0,t._isPanClick=!1,t._twoFingerActivityCount=0,t._isPinching=!1,t}return t(i,e),i.prototype.getClassName=function(){return"ArcRotateCameraPointersInput"},i.prototype.onTouch=function(e,t,i){0!==this.panningSensibility&&(this._ctrlKey&&this.camera._useCtrlForPanning||this._isPanClick)?(this.camera.inertialPanningX+=-t/this.panningSensibility,this.camera.inertialPanningY+=i/this.panningSensibility):(this.camera.inertialAlphaOffset-=t/this.angularSensibilityX,this.camera.inertialBetaOffset-=i/this.angularSensibilityY)},i.prototype.onDoubleTap=function(e){this.camera.useInputToRestoreState&&this.camera.restoreState()},i.prototype.onMultiTouch=function(e,t,i,r,n,o){if(!(0===i&&null===n||0===r&&null===o)){var s=this.pinchInwards?1:-1;if(this.multiTouchPanAndZoom){if(this.useNaturalPinchZoom?this.camera.radius=this.camera.radius*Math.sqrt(i)/Math.sqrt(r):this.pinchDeltaPercentage?this.camera.inertialRadiusOffset+=.001*(r-i)*this.camera.radius*this.pinchDeltaPercentage:this.camera.inertialRadiusOffset+=(r-i)/(this.pinchPrecision*s*(this.angularSensibilityX+this.angularSensibilityY)/2),0!==this.panningSensibility&&n&&o){var a=o.x-n.x,h=o.y-n.y;this.camera.inertialPanningX+=-a/this.panningSensibility,this.camera.inertialPanningY+=h/this.panningSensibility}}else{this._twoFingerActivityCount++;var u=Math.sqrt(i),l=Math.sqrt(r);if(this._isPinching||this._twoFingerActivityCount<20&&Math.abs(l-u)>this.camera.pinchToPanMaxDistance)this.pinchDeltaPercentage?this.camera.inertialRadiusOffset+=.001*(r-i)*this.camera.radius*this.pinchDeltaPercentage:this.camera.inertialRadiusOffset+=(r-i)/(this.pinchPrecision*s*(this.angularSensibilityX+this.angularSensibilityY)/2),this._isPinching=!0;else if(0!==this.panningSensibility&&this.multiTouchPanning&&o&&n){a=o.x-n.x,h=o.y-n.y;this.camera.inertialPanningX+=-a/this.panningSensibility,this.camera.inertialPanningY+=h/this.panningSensibility}}}},i.prototype.onButtonDown=function(e){this._isPanClick=e.button===this.camera._panningMouseButton},i.prototype.onButtonUp=function(e){this._twoFingerActivityCount=0,this._isPinching=!1},i.prototype.onLostFocus=function(){this._isPanClick=!1,this._twoFingerActivityCount=0,this._isPinching=!1},r([O()],i.prototype,"buttons",void 0),r([O()],i.prototype,"angularSensibilityX",void 0),r([O()],i.prototype,"angularSensibilityY",void 0),r([O()],i.prototype,"pinchPrecision",void 0),r([O()],i.prototype,"pinchDeltaPercentage",void 0),r([O()],i.prototype,"useNaturalPinchZoom",void 0),r([O()],i.prototype,"panningSensibility",void 0),r([O()],i.prototype,"multiTouchPanning",void 0),r([O()],i.prototype,"multiTouchPanAndZoom",void 0),i}(function(){function e(){this.buttons=[0,1,2]}return e.prototype.attachControl=function(e){var t=this;e=Ue.BackCompatCameraNoPreventDefault(arguments);var i=this.camera.getEngine(),r=i.getInputElement(),n=0,o=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(s,a){var h=s.event,u="touch"===h.pointerType;if(!i.isInVRExclusivePointerMode&&(s.type===Jt.POINTERMOVE||-1!==t.buttons.indexOf(h.button))){var l=h.srcElement||h.target;if(t._altKey=h.altKey,t._ctrlKey=h.ctrlKey,t._metaKey=h.metaKey,t._shiftKey=h.shiftKey,t._buttonsPressed=h.buttons,i.isPointerLock){var c=h.movementX||h.mozMovementX||h.webkitMovementX||h.msMovementX||0,f=h.movementY||h.mozMovementY||h.webkitMovementY||h.msMovementY||0;t.onTouch(null,c,f),t.pointA=null,t.pointB=null}else if(s.type===Jt.POINTERDOWN&&l){try{l.setPointerCapture(h.pointerId)}catch(e){}null===t.pointA?t.pointA={x:h.clientX,y:h.clientY,pointerId:h.pointerId,type:h.pointerType}:null===t.pointB&&(t.pointB={x:h.clientX,y:h.clientY,pointerId:h.pointerId,type:h.pointerType}),t.onButtonDown(h),e||(h.preventDefault(),r&&r.focus())}else if(s.type===Jt.POINTERDOUBLETAP)t.onDoubleTap(h.pointerType);else if(s.type===Jt.POINTERUP&&l){try{l.releasePointerCapture(h.pointerId)}catch(e){}u||(t.pointB=null),i._badOS?t.pointA=t.pointB=null:t.pointB&&t.pointA&&t.pointA.pointerId==h.pointerId?(t.pointA=t.pointB,t.pointB=null):t.pointA&&t.pointB&&t.pointB.pointerId==h.pointerId?t.pointB=null:t.pointA=t.pointB=null,(0!==n||o)&&(t.onMultiTouch(t.pointA,t.pointB,n,0,o,null),n=0,o=null),t.onButtonUp(h),e||h.preventDefault()}else if(s.type===Jt.POINTERMOVE)if(e||h.preventDefault(),t.pointA&&null===t.pointB){c=h.clientX-t.pointA.x,f=h.clientY-t.pointA.y;t.onTouch(t.pointA,c,f),t.pointA.x=h.clientX,t.pointA.y=h.clientY}else if(t.pointA&&t.pointB){var d=t.pointA.pointerId===h.pointerId?t.pointA:t.pointB;d.x=h.clientX,d.y=h.clientY;var p=t.pointA.x-t.pointB.x,_=t.pointA.y-t.pointB.y,g=p*p+_*_,m={x:(t.pointA.x+t.pointB.x)/2,y:(t.pointA.y+t.pointB.y)/2,pointerId:h.pointerId,type:s.type};t.onMultiTouch(t.pointA,t.pointB,n,g,o,m),o=m,n=g}}},this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,Jt.POINTERDOWN|Jt.POINTERUP|Jt.POINTERMOVE),this._onLostFocus=function(){t.pointA=t.pointB=null,n=0,o=null,t.onLostFocus()},r&&r.addEventListener("contextmenu",this.onContextMenu.bind(this),!1);var s=this.camera.getScene().getEngine().getHostWindow();s&&Ue.RegisterTopRootEvents(s,[{name:"blur",handler:this._onLostFocus}])},e.prototype.detachControl=function(e){if(this._onLostFocus){var t=this.camera.getScene().getEngine().getHostWindow();t&&Ue.UnregisterTopRootEvents(t,[{name:"blur",handler:this._onLostFocus}])}if(this._observer){if(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,this.onContextMenu){var i=this.camera.getScene().getEngine().getInputElement();i&&i.removeEventListener("contextmenu",this.onContextMenu)}this._onLostFocus=null}this._altKey=!1,this._ctrlKey=!1,this._metaKey=!1,this._shiftKey=!1,this._buttonsPressed=0},e.prototype.getClassName=function(){return"BaseCameraPointersInput"},e.prototype.getSimpleName=function(){return"pointers"},e.prototype.onDoubleTap=function(e){},e.prototype.onTouch=function(e,t,i){},e.prototype.onMultiTouch=function(e,t,i,r,n,o){},e.prototype.onContextMenu=function(e){e.preventDefault()},e.prototype.onButtonDown=function(e){},e.prototype.onButtonUp=function(e){},e.prototype.onLostFocus=function(){},r([O()],e.prototype,"buttons",void 0),e}());yi.ArcRotateCameraPointersInput=Ti;var Ei=function(){function e(){}return e.KEYDOWN=1,e.KEYUP=2,e}(),xi=function(e,t){this.type=e,this.event=t},Ai=function(e){function i(t,i){var r=e.call(this,t,i)||this;return r.type=t,r.event=i,r.skipOnPointerObservable=!1,r}return t(i,e),i}(xi),Mi=function(){function e(){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 e.prototype.attachControl=function(e){var t=this;e=Ue.BackCompatCameraNoPreventDefault(arguments),this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add((function(){t._keys=[]})),this._onKeyboardObserver=this._scene.onKeyboardObservable.add((function(i){var r,n=i.event;n.metaKey||(i.type===Ei.KEYDOWN?(t._ctrlPressed=n.ctrlKey,t._altPressed=n.altKey,(-1!==t.keysUp.indexOf(n.keyCode)||-1!==t.keysDown.indexOf(n.keyCode)||-1!==t.keysLeft.indexOf(n.keyCode)||-1!==t.keysRight.indexOf(n.keyCode)||-1!==t.keysReset.indexOf(n.keyCode))&&(-1===(r=t._keys.indexOf(n.keyCode))&&t._keys.push(n.keyCode),n.preventDefault&&(e||n.preventDefault()))):-1===t.keysUp.indexOf(n.keyCode)&&-1===t.keysDown.indexOf(n.keyCode)&&-1===t.keysLeft.indexOf(n.keyCode)&&-1===t.keysRight.indexOf(n.keyCode)&&-1===t.keysReset.indexOf(n.keyCode)||((r=t._keys.indexOf(n.keyCode))>=0&&t._keys.splice(r,1),n.preventDefault&&(e||n.preventDefault())))})))},e.prototype.detachControl=function(e){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=[]},e.prototype.checkInputs=function(){if(this._onKeyboardObserver)for(var e=this.camera,t=0;t<this._keys.length;t++){var i=this._keys[t];-1!==this.keysLeft.indexOf(i)?this._ctrlPressed&&this.camera._useCtrlForPanning?e.inertialPanningX-=1/this.panningSensibility:e.inertialAlphaOffset-=this.angularSpeed:-1!==this.keysUp.indexOf(i)?this._ctrlPressed&&this.camera._useCtrlForPanning?e.inertialPanningY+=1/this.panningSensibility:this._altPressed&&this.useAltToZoom?e.inertialRadiusOffset+=1/this.zoomingSensibility:e.inertialBetaOffset-=this.angularSpeed:-1!==this.keysRight.indexOf(i)?this._ctrlPressed&&this.camera._useCtrlForPanning?e.inertialPanningX+=1/this.panningSensibility:e.inertialAlphaOffset+=this.angularSpeed:-1!==this.keysDown.indexOf(i)?this._ctrlPressed&&this.camera._useCtrlForPanning?e.inertialPanningY-=1/this.panningSensibility:this._altPressed&&this.useAltToZoom?e.inertialRadiusOffset-=1/this.zoomingSensibility:e.inertialBetaOffset+=this.angularSpeed:-1!==this.keysReset.indexOf(i)&&e.useInputToRestoreState&&e.restoreState()}},e.prototype.getClassName=function(){return"ArcRotateCameraKeyboardMoveInput"},e.prototype.getSimpleName=function(){return"keyboard"},r([O()],e.prototype,"keysUp",void 0),r([O()],e.prototype,"keysDown",void 0),r([O()],e.prototype,"keysLeft",void 0),r([O()],e.prototype,"keysRight",void 0),r([O()],e.prototype,"keysReset",void 0),r([O()],e.prototype,"panningSensibility",void 0),r([O()],e.prototype,"zoomingSensibility",void 0),r([O()],e.prototype,"useAltToZoom",void 0),r([O()],e.prototype,"angularSpeed",void 0),e}();yi.ArcRotateCameraKeyboardMoveInput=Mi;var Pi=function(){function e(){this.wheelPrecision=3,this.wheelDeltaPercentage=0}return e.prototype.computeDeltaFromMouseWheelLegacyEvent=function(e,t){var i=.01*e*this.wheelDeltaPercentage*t;return e>0?i/(1+this.wheelDeltaPercentage):i*(1+this.wheelDeltaPercentage)},e.prototype.attachControl=function(e){var t=this;e=Ue.BackCompatCameraNoPreventDefault(arguments),this._wheel=function(i,r){if(i.type===Jt.POINTERWHEEL){var n=i.event,o=0,a=n,h=0;if(h=a.wheelDelta?a.wheelDelta:60*-(n.deltaY||n.detail),t.wheelDeltaPercentage){if((o=t.computeDeltaFromMouseWheelLegacyEvent(h,t.camera.radius))>0){for(var u=t.camera.radius,l=t.camera.inertialRadiusOffset+o,c=0;c<20&&Math.abs(l)>.001;c++)u-=l,l*=t.camera.inertia;u=s.Clamp(u,0,Number.MAX_VALUE),o=t.computeDeltaFromMouseWheelLegacyEvent(h,u)}}else o=h/(40*t.wheelPrecision);o&&(t.camera.inertialRadiusOffset+=o),n.preventDefault&&(e||n.preventDefault())}},this._observer=this.camera.getScene().onPointerObservable.add(this._wheel,Jt.POINTERWHEEL)},e.prototype.detachControl=function(e){this._observer&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,this._wheel=null)},e.prototype.getClassName=function(){return"ArcRotateCameraMouseWheelInput"},e.prototype.getSimpleName=function(){return"mousewheel"},r([O()],e.prototype,"wheelPrecision",void 0),r([O()],e.prototype,"wheelDeltaPercentage",void 0),e}();yi.ArcRotateCameraMouseWheelInput=Pi;var Ci=function(e){function i(t){return e.call(this,t)||this}return t(i,e),i.prototype.addMouseWheel=function(){return this.add(new Pi),this},i.prototype.addPointers=function(){return this.add(new Ti),this},i.prototype.addKeyboard=function(){return this.add(new Mi),this},i}(bi);ut.AddNodeConstructor("ArcRotateCamera",(function(e,t){return function(){return new Si(e,0,0,1,p.Zero(),t)}}));var Si=function(e){function i(t,i,r,n,o,s,a){void 0===a&&(a=!0);var h=e.call(this,t,p.Zero(),s,a)||this;return h.inertialAlphaOffset=0,h.inertialBetaOffset=0,h.inertialRadiusOffset=0,h.lowerAlphaLimit=null,h.upperAlphaLimit=null,h.lowerBetaLimit=.01,h.upperBetaLimit=Math.PI-.01,h.lowerRadiusLimit=null,h.upperRadiusLimit=null,h.inertialPanningX=0,h.inertialPanningY=0,h.pinchToPanMaxDistance=20,h.panningDistanceLimit=null,h.panningOriginTarget=p.Zero(),h.panningInertia=.9,h.zoomOnFactor=1,h.targetScreenOffset=d.Zero(),h.allowUpsideDown=!0,h.useInputToRestoreState=!0,h._viewMatrix=new m,h.panningAxis=new p(1,1,0),h.onMeshTargetChangedObservable=new U,h.checkCollisions=!1,h.collisionRadius=new p(.5,.5,.5),h._previousPosition=p.Zero(),h._collisionVelocity=p.Zero(),h._newPosition=p.Zero(),h._computationVector=p.Zero(),h._onCollisionPositionChange=function(e,t,i){void 0===i&&(i=null),i?(h.setPosition(t),h.onCollide&&h.onCollide(i)):h._previousPosition.copyFrom(h._position);var r=Math.cos(h.alpha),n=Math.sin(h.alpha),o=Math.cos(h.beta),s=Math.sin(h.beta);0===s&&(s=1e-4);var a=h._getTargetPosition();h._computationVector.copyFromFloats(h.radius*r*s,h.radius*o,h.radius*n*s),a.addToRef(h._computationVector,h._newPosition),h._position.copyFrom(h._newPosition);var u=h.upVector;h.allowUpsideDown&&h.beta<0&&(u=(u=u.clone()).negate()),h._computeViewMatrix(h._position,a,u),h._viewMatrix.addAtIndex(12,h.targetScreenOffset.x),h._viewMatrix.addAtIndex(13,h.targetScreenOffset.y),h._collisionTriggered=!1},h._target=p.Zero(),o&&h.setTarget(o),h.alpha=i,h.beta=r,h.radius=n,h.getViewMatrix(),h.inputs=new Ci(h),h.inputs.addKeyboard().addMouseWheel().addPointers(),h}return t(i,e),Object.defineProperty(i.prototype,"target",{get:function(){return this._target},set:function(e){this.setTarget(e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"position",{get:function(){return this._position},set:function(e){this.setPosition(e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"upVector",{get:function(){return this._upVector},set:function(e){this._upToYMatrix||(this._YToUpMatrix=new m,this._upToYMatrix=new m,this._upVector=p.Zero()),e.normalize(),this._upVector.copyFrom(e),this.setMatUp()},enumerable:!1,configurable:!0}),i.prototype.setMatUp=function(){m.RotationAlignToRef(p.UpReadOnly,this._upVector,this._YToUpMatrix),m.RotationAlignToRef(this._upVector,p.UpReadOnly,this._upToYMatrix)},Object.defineProperty(i.prototype,"angularSensibilityX",{get:function(){var e=this.inputs.attached.pointers;return e?e.angularSensibilityX:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.angularSensibilityX=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"angularSensibilityY",{get:function(){var e=this.inputs.attached.pointers;return e?e.angularSensibilityY:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.angularSensibilityY=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"pinchPrecision",{get:function(){var e=this.inputs.attached.pointers;return e?e.pinchPrecision:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.pinchPrecision=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"pinchDeltaPercentage",{get:function(){var e=this.inputs.attached.pointers;return e?e.pinchDeltaPercentage:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.pinchDeltaPercentage=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"useNaturalPinchZoom",{get:function(){var e=this.inputs.attached.pointers;return!!e&&e.useNaturalPinchZoom},set:function(e){var t=this.inputs.attached.pointers;t&&(t.useNaturalPinchZoom=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"panningSensibility",{get:function(){var e=this.inputs.attached.pointers;return e?e.panningSensibility:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.panningSensibility=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"keysUp",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysUp:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysUp=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"keysDown",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysDown:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDown=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"keysLeft",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysLeft:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"keysRight",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRight:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRight=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"wheelPrecision",{get:function(){var e=this.inputs.attached.mousewheel;return e?e.wheelPrecision:0},set:function(e){var t=this.inputs.attached.mousewheel;t&&(t.wheelPrecision=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"wheelDeltaPercentage",{get:function(){var e=this.inputs.attached.mousewheel;return e?e.wheelDeltaPercentage:0},set:function(e){var t=this.inputs.attached.mousewheel;t&&(t.wheelDeltaPercentage=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"bouncingBehavior",{get:function(){return this._bouncingBehavior},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"useBouncingBehavior",{get:function(){return null!=this._bouncingBehavior},set:function(e){e!==this.useBouncingBehavior&&(e?(this._bouncingBehavior=new ci,this.addBehavior(this._bouncingBehavior)):this._bouncingBehavior&&(this.removeBehavior(this._bouncingBehavior),this._bouncingBehavior=null))},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"framingBehavior",{get:function(){return this._framingBehavior},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"useFramingBehavior",{get:function(){return null!=this._framingBehavior},set:function(e){e!==this.useFramingBehavior&&(e?(this._framingBehavior=new fi,this.addBehavior(this._framingBehavior)):this._framingBehavior&&(this.removeBehavior(this._framingBehavior),this._framingBehavior=null))},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"autoRotationBehavior",{get:function(){return this._autoRotationBehavior},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"useAutoRotationBehavior",{get:function(){return null!=this._autoRotationBehavior},set:function(e){e!==this.useAutoRotationBehavior&&(e?(this._autoRotationBehavior=new ii,this.addBehavior(this._autoRotationBehavior)):this._autoRotationBehavior&&(this.removeBehavior(this._autoRotationBehavior),this._autoRotationBehavior=null))},enumerable:!1,configurable:!0}),i.prototype._initCache=function(){e.prototype._initCache.call(this),this._cache._target=new p(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=d.Zero()},i.prototype._updateCache=function(t){t||e.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)},i.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 t=this._getLockedTargetPosition();return t||this._target},i.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(),e.prototype.storeState.call(this)},i.prototype._restoreStateValues=function(){return!!e.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)},i.prototype._isSynchronizedViewMatrix=function(){return!!e.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))},i.prototype.attachControl=function(e,t,i,r){var n=this;void 0===i&&(i=!0),void 0===r&&(r=2),t=Ue.BackCompatCameraNoPreventDefault(arguments),this._useCtrlForPanning=i,this._panningMouseButton=r,"boolean"==typeof arguments[0]&&(arguments.length>1&&(this._useCtrlForPanning=arguments[1]),arguments.length>2&&(this._panningMouseButton=arguments[2])),this.inputs.attachElement(t),this._reset=function(){n.inertialAlphaOffset=0,n.inertialBetaOffset=0,n.inertialRadiusOffset=0,n.inertialPanningX=0,n.inertialPanningY=0}},i.prototype.detachControl=function(e){this.inputs.detachElement(),this._reset&&this._reset()},i.prototype._checkInputs=function(){if(!this._collisionTriggered){if(this.inputs.checkInputs(),0!==this.inertialAlphaOffset||0!==this.inertialBetaOffset||0!==this.inertialRadiusOffset){var t=this.inertialAlphaOffset;this.beta<=0&&(t*=-1),this.getScene().useRightHandedSystem&&(t*=-1),this.parent&&this.parent._getWorldMatrixDeterminant()<0&&(t*=-1),this.alpha+=t,this.beta+=this.inertialBetaOffset,this.radius-=this.inertialRadiusOffset,this.inertialAlphaOffset*=this.inertia,this.inertialBetaOffset*=this.inertia,this.inertialRadiusOffset*=this.inertia,Math.abs(this.inertialAlphaOffset)<u&&(this.inertialAlphaOffset=0),Math.abs(this.inertialBetaOffset)<u&&(this.inertialBetaOffset=0),Math.abs(this.inertialRadiusOffset)<this.speed*u&&(this.inertialRadiusOffset=0)}if(0!==this.inertialPanningX||0!==this.inertialPanningY){if(this._localDirection||(this._localDirection=p.Zero(),this._transformedDirection=p.Zero()),this._localDirection.copyFromFloats(this.inertialPanningX,this.inertialPanningY,this.inertialPanningY),this._localDirection.multiplyInPlace(this.panningAxis),this._viewMatrix.invertToRef(this._cameraTransformMatrix),p.TransformNormalToRef(this._localDirection,this._cameraTransformMatrix,this._transformedDirection),this.panningAxis.y||(this._transformedDirection.y=0),!this._targetHost)if(this.panningDistanceLimit)this._transformedDirection.addInPlace(this._target),p.DistanceSquared(this._transformedDirection,this.panningOriginTarget)<=this.panningDistanceLimit*this.panningDistanceLimit&&this._target.copyFrom(this._transformedDirection);else this._target.addInPlace(this._transformedDirection);this.inertialPanningX*=this.panningInertia,this.inertialPanningY*=this.panningInertia,Math.abs(this.inertialPanningX)<this.speed*u&&(this.inertialPanningX=0),Math.abs(this.inertialPanningY)<this.speed*u&&(this.inertialPanningY=0)}this._checkLimits(),e.prototype._checkInputs.call(this)}},i.prototype._checkLimits=function(){null===this.lowerBetaLimit||void 0===this.lowerBetaLimit?this.allowUpsideDown&&this.beta>Math.PI&&(this.beta=this.beta-2*Math.PI):this.beta<this.lowerBetaLimit&&(this.beta=this.lowerBetaLimit),null===this.upperBetaLimit||void 0===this.upperBetaLimit?this.allowUpsideDown&&this.beta<-Math.PI&&(this.beta=this.beta+2*Math.PI):this.beta>this.upperBetaLimit&&(this.beta=this.upperBetaLimit),null!==this.lowerAlphaLimit&&this.alpha<this.lowerAlphaLimit&&(this.alpha=this.lowerAlphaLimit),null!==this.upperAlphaLimit&&this.alpha>this.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),null!==this.lowerRadiusLimit&&this.radius<this.lowerRadiusLimit&&(this.radius=this.lowerRadiusLimit,this.inertialRadiusOffset=0),null!==this.upperRadiusLimit&&this.radius>this.upperRadiusLimit&&(this.radius=this.upperRadiusLimit,this.inertialRadiusOffset=0)},i.prototype.rebuildAnglesAndRadius=function(){this._position.subtractToRef(this._getTargetPosition(),this._computationVector),0===this._upVector.x&&1===this._upVector.y&&0===this._upVector.z||p.TransformCoordinatesToRef(this._computationVector,this._upToYMatrix,this._computationVector),this.radius=this._computationVector.length(),0===this.radius&&(this.radius=1e-4);var e=this.alpha;0===this._computationVector.x&&0===this._computationVector.z?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 t=Math.round((e-this.alpha)/(2*Math.PI));this.alpha+=2*t*Math.PI,this.beta=Math.acos(this._computationVector.y/this.radius),this._checkLimits()},i.prototype.setPosition=function(e){this._position.equals(e)||(this._position.copyFrom(e),this.rebuildAnglesAndRadius())},i.prototype.setTarget=function(e,t,i){if(void 0===t&&(t=!1),void 0===i&&(i=!1),e.getBoundingInfo)this._targetBoundingCenter=t?e.getBoundingInfo().boundingBox.centerWorld.clone():null,e.computeWorldMatrix(),this._targetHost=e,this._target=this._getTargetPosition(),this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);else{var r=e,n=this._getTargetPosition();if(n&&!i&&n.equals(r))return;this._targetHost=null,this._target=r,this._targetBoundingCenter=null,this.onMeshTargetChangedObservable.notifyObservers(null)}this.rebuildAnglesAndRadius()},i.prototype._getViewMatrix=function(){var e=Math.cos(this.alpha),t=Math.sin(this.alpha),i=Math.cos(this.beta),r=Math.sin(this.beta);0===r&&(r=1e-4),0===this.radius&&(this.radius=1e-4);var n=this._getTargetPosition();if(this._computationVector.copyFromFloats(this.radius*e*r,this.radius*i,this.radius*t*r),0===this._upVector.x&&1===this._upVector.y&&0===this._upVector.z||p.TransformCoordinatesToRef(this._computationVector,this._YToUpMatrix,this._computationVector),n.addToRef(this._computationVector,this._newPosition),this.getScene().collisionsEnabled&&this.checkCollisions){var o=this.getScene().collisionCoordinator;this._collider||(this._collider=o.createCollider()),this._collider._radius=this.collisionRadius,this._newPosition.subtractToRef(this._position,this._collisionVelocity),this._collisionTriggered=!0,o.getNewPosition(this._position,this._collisionVelocity,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)}else{this._position.copyFrom(this._newPosition);var s=this.upVector;this.allowUpsideDown&&r<0&&(s=s.negate()),this._computeViewMatrix(this._position,n,s),this._viewMatrix.addAtIndex(12,this.targetScreenOffset.x),this._viewMatrix.addAtIndex(13,this.targetScreenOffset.y)}return this._currentTarget=n,this._viewMatrix},i.prototype.zoomOn=function(e,t){void 0===t&&(t=!1),e=e||this.getScene().meshes;var i=Zt.MinMax(e),r=p.Distance(i.min,i.max);this.radius=r*this.zoomOnFactor,this.focusOn({min:i.min,max:i.max,distance:r},t)},i.prototype.focusOn=function(e,t){var i,r;if(void 0===t&&(t=!1),void 0===e.min){var n=e||this.getScene().meshes;i=Zt.MinMax(n),r=p.Distance(i.min,i.max)}else{i=e,r=e.distance}this._target=Zt.Center(i),t||(this.maxZ=2*r)},i.prototype.createRigCamera=function(e,t){var r=0;switch(this.cameraRigMode){case mi.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case mi.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case mi.RIG_MODE_STEREOSCOPIC_OVERUNDER:case mi.RIG_MODE_STEREOSCOPIC_INTERLACED:case mi.RIG_MODE_VR:r=this._cameraRigParams.stereoHalfAngle*(0===t?1:-1);break;case mi.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:r=this._cameraRigParams.stereoHalfAngle*(0===t?-1:1)}var n=new i(e,this.alpha+r,this.beta,this.radius,this._target,this.getScene());return n._cameraRigParams={},n.isRigCamera=!0,n.rigParent=this,n.upVector=this.upVector,n},i.prototype._updateRigCameras=function(){var t=this._rigCameras[0],i=this._rigCameras[1];switch(t.beta=i.beta=this.beta,this.cameraRigMode){case mi.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case mi.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case mi.RIG_MODE_STEREOSCOPIC_OVERUNDER:case mi.RIG_MODE_STEREOSCOPIC_INTERLACED:case mi.RIG_MODE_VR:t.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,i.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle;break;case mi.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:t.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle,i.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle}e.prototype._updateRigCameras.call(this)},i.prototype.dispose=function(){this.inputs.clear(),e.prototype.dispose.call(this)},i.prototype.getClassName=function(){return"ArcRotateCamera"},r([O()],i.prototype,"alpha",void 0),r([O()],i.prototype,"beta",void 0),r([O()],i.prototype,"radius",void 0),r([L("target")],i.prototype,"_target",void 0),r([O()],i.prototype,"inertialAlphaOffset",void 0),r([O()],i.prototype,"inertialBetaOffset",void 0),r([O()],i.prototype,"inertialRadiusOffset",void 0),r([O()],i.prototype,"lowerAlphaLimit",void 0),r([O()],i.prototype,"upperAlphaLimit",void 0),r([O()],i.prototype,"lowerBetaLimit",void 0),r([O()],i.prototype,"upperBetaLimit",void 0),r([O()],i.prototype,"lowerRadiusLimit",void 0),r([O()],i.prototype,"upperRadiusLimit",void 0),r([O()],i.prototype,"inertialPanningX",void 0),r([O()],i.prototype,"inertialPanningY",void 0),r([O()],i.prototype,"pinchToPanMaxDistance",void 0),r([O()],i.prototype,"panningDistanceLimit",void 0),r([L()],i.prototype,"panningOriginTarget",void 0),r([O()],i.prototype,"panningInertia",void 0),r([O()],i.prototype,"zoomOnFactor",void 0),r([O()],i.prototype,"targetScreenOffset",void 0),r([O()],i.prototype,"allowUpsideDown",void 0),r([O()],i.prototype,"useInputToRestoreState",void 0),i}(vi),Ii=function(){function e(){this._count=0,this._data={}}return e.prototype.copyFrom=function(e){var t=this;this.clear(),e.forEach((function(e,i){return t.add(e,i)}))},e.prototype.get=function(e){var t=this._data[e];if(void 0!==t)return t},e.prototype.getOrAddWithFactory=function(e,t){var i=this.get(e);return void 0!==i||(i=t(e))&&this.add(e,i),i},e.prototype.getOrAdd=function(e,t){var i=this.get(e);return void 0!==i?i:(this.add(e,t),t)},e.prototype.contains=function(e){return void 0!==this._data[e]},e.prototype.add=function(e,t){return void 0===this._data[e]&&(this._data[e]=t,++this._count,!0)},e.prototype.set=function(e,t){return void 0!==this._data[e]&&(this._data[e]=t,!0)},e.prototype.getAndRemove=function(e){var t=this.get(e);return void 0!==t?(delete this._data[e],--this._count,t):null},e.prototype.remove=function(e){return!!this.contains(e)&&(delete this._data[e],--this._count,!0)},e.prototype.clear=function(){this._data={},this._count=0},Object.defineProperty(e.prototype,"count",{get:function(){return this._count},enumerable:!1,configurable:!0}),e.prototype.forEach=function(e){for(var t in this._data){e(t,this._data[t])}},e.prototype.first=function(e){for(var t in this._data){var i=e(t,this._data[t]);if(i)return i}return null},e}(),Oi=function(){function e(){this.rootNodes=new Array,this.cameras=new Array,this.lights=new Array,this.meshes=new Array,this.skeletons=new Array,this.particleSystems=new Array,this.animations=[],this.animationGroups=new Array,this.multiMaterials=new Array,this.materials=new Array,this.morphTargetManagers=new Array,this.geometries=new Array,this.transformNodes=new Array,this.actionManagers=new Array,this.textures=new Array,this._environmentTexture=null,this.postProcesses=new Array}return e.AddParser=function(e,t){this._BabylonFileParsers[e]=t},e.GetParser=function(e){return this._BabylonFileParsers[e]?this._BabylonFileParsers[e]:null},e.AddIndividualParser=function(e,t){this._IndividualBabylonFileParsers[e]=t},e.GetIndividualParser=function(e){return this._IndividualBabylonFileParsers[e]?this._IndividualBabylonFileParsers[e]:null},e.Parse=function(e,t,i,r){for(var n in this._BabylonFileParsers)this._BabylonFileParsers.hasOwnProperty(n)&&this._BabylonFileParsers[n](e,t,i,r)},Object.defineProperty(e.prototype,"environmentTexture",{get:function(){return this._environmentTexture},set:function(e){this._environmentTexture=e},enumerable:!1,configurable:!0}),e.prototype.getNodes=function(){var e=new Array;return e=(e=(e=(e=e.concat(this.meshes)).concat(this.lights)).concat(this.cameras)).concat(this.transformNodes),this.skeletons.forEach((function(t){return e=e.concat(t.bones)})),e},e._BabylonFileParsers={},e._IndividualBabylonFileParsers={},e}(),Ri=function(){function e(){this._isDirty=!0,this._areLightsDirty=!0,this._areLightsDisposed=!1,this._areAttributesDirty=!0,this._areTexturesDirty=!0,this._areFresnelDirty=!0,this._areMiscDirty=!0,this._arePrePassDirty=!0,this._areImageProcessingDirty=!0,this._normals=!1,this._uvs=!1,this._needNormals=!1,this._needUVs=!1}return Object.defineProperty(e.prototype,"isDirty",{get:function(){return this._isDirty},enumerable:!1,configurable:!0}),e.prototype.markAsProcessed=function(){this._isDirty=!1,this._areAttributesDirty=!1,this._areTexturesDirty=!1,this._areFresnelDirty=!1,this._areLightsDirty=!1,this._areLightsDisposed=!1,this._areMiscDirty=!1,this._arePrePassDirty=!1,this._areImageProcessingDirty=!1},e.prototype.markAsUnprocessed=function(){this._isDirty=!0},e.prototype.markAllAsDirty=function(){this._areTexturesDirty=!0,this._areAttributesDirty=!0,this._areLightsDirty=!0,this._areFresnelDirty=!0,this._areMiscDirty=!0,this._areImageProcessingDirty=!0,this._isDirty=!0},e.prototype.markAsImageProcessingDirty=function(){this._areImageProcessingDirty=!0,this._isDirty=!0},e.prototype.markAsLightDirty=function(e){void 0===e&&(e=!1),this._areLightsDirty=!0,this._areLightsDisposed=this._areLightsDisposed||e,this._isDirty=!0},e.prototype.markAsAttributesDirty=function(){this._areAttributesDirty=!0,this._isDirty=!0},e.prototype.markAsTexturesDirty=function(){this._areTexturesDirty=!0,this._isDirty=!0},e.prototype.markAsFresnelDirty=function(){this._areFresnelDirty=!0,this._isDirty=!0},e.prototype.markAsMiscDirty=function(){this._areMiscDirty=!0,this._isDirty=!0},e.prototype.markAsPrePassDirty=function(){this._arePrePassDirty=!0,this._isDirty=!0},e.prototype.rebuild=function(){this._keys=[];for(var e=0,t=Object.keys(this);e<t.length;e++){var i=t[e];"_"!==i[0]&&this._keys.push(i)}},e.prototype.isEqual=function(e){if(this._keys.length!==e._keys.length)return!1;for(var t=0;t<this._keys.length;t++){var i=this._keys[t];if(this[i]!==e[i])return!1}return!0},e.prototype.cloneTo=function(e){this._keys.length!==e._keys.length&&(e._keys=this._keys.slice(0));for(var t=0;t<this._keys.length;t++){var i=this._keys[t];e[i]=this[i]}},e.prototype.reset=function(){for(var e=0;e<this._keys.length;e++){var t=this._keys[e];switch(typeof this[t]){case"number":this[t]=0;break;case"string":this[t]="";break;default:this[t]=!1}}},e.prototype.toString=function(){for(var e="",t=0;t<this._keys.length;t++){var i=this._keys[t],r=this[i];switch(typeof r){case"number":case"string":e+="#define "+i+" "+r+"\n";break;default:r&&(e+="#define "+i+"\n")}}return e},e}(),Di=function(){function e(){this._dirty=!0,this._tempColor=new E(0,0,0,0),this._globalCurve=new E(0,0,0,0),this._highlightsCurve=new E(0,0,0,0),this._midtonesCurve=new E(0,0,0,0),this._shadowsCurve=new E(0,0,0,0),this._positiveCurve=new E(0,0,0,0),this._negativeCurve=new E(0,0,0,0),this._globalHue=30,this._globalDensity=0,this._globalSaturation=0,this._globalExposure=0,this._highlightsHue=30,this._highlightsDensity=0,this._highlightsSaturation=0,this._highlightsExposure=0,this._midtonesHue=30,this._midtonesDensity=0,this._midtonesSaturation=0,this._midtonesExposure=0,this._shadowsHue=30,this._shadowsDensity=0,this._shadowsSaturation=0,this._shadowsExposure=0}return Object.defineProperty(e.prototype,"globalHue",{get:function(){return this._globalHue},set:function(e){this._globalHue=e,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"globalDensity",{get:function(){return this._globalDensity},set:function(e){this._globalDensity=e,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"globalSaturation",{get:function(){return this._globalSaturation},set:function(e){this._globalSaturation=e,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"globalExposure",{get:function(){return this._globalExposure},set:function(e){this._globalExposure=e,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"highlightsHue",{get:function(){return this._highlightsHue},set:function(e){this._highlightsHue=e,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"highlightsDensity",{get:function(){return this._highlightsDensity},set:function(e){this._highlightsDensity=e,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"highlightsSaturation",{get:function(){return this._highlightsSaturation},set:function(e){this._highlightsSaturation=e,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"highlightsExposure",{get:function(){return this._highlightsExposure},set:function(e){this._highlightsExposure=e,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"midtonesHue",{get:function(){return this._midtonesHue},set:function(e){this._midtonesHue=e,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"midtonesDensity",{get:function(){return this._midtonesDensity},set:function(e){this._midtonesDensity=e,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"midtonesSaturation",{get:function(){return this._midtonesSaturation},set:function(e){this._midtonesSaturation=e,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"midtonesExposure",{get:function(){return this._midtonesExposure},set:function(e){this._midtonesExposure=e,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shadowsHue",{get:function(){return this._shadowsHue},set:function(e){this._shadowsHue=e,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shadowsDensity",{get:function(){return this._shadowsDensity},set:function(e){this._shadowsDensity=e,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shadowsSaturation",{get:function(){return this._shadowsSaturation},set:function(e){this._shadowsSaturation=e,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shadowsExposure",{get:function(){return this._shadowsExposure},set:function(e){this._shadowsExposure=e,this._dirty=!0},enumerable:!1,configurable:!0}),e.prototype.getClassName=function(){return"ColorCurves"},e.Bind=function(e,t,i,r,n){void 0===i&&(i="vCameraColorCurvePositive"),void 0===r&&(r="vCameraColorCurveNeutral"),void 0===n&&(n="vCameraColorCurveNegative"),e._dirty&&(e._dirty=!1,e.getColorGradingDataToRef(e._globalHue,e._globalDensity,e._globalSaturation,e._globalExposure,e._globalCurve),e.getColorGradingDataToRef(e._highlightsHue,e._highlightsDensity,e._highlightsSaturation,e._highlightsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._highlightsCurve),e.getColorGradingDataToRef(e._midtonesHue,e._midtonesDensity,e._midtonesSaturation,e._midtonesExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._midtonesCurve),e.getColorGradingDataToRef(e._shadowsHue,e._shadowsDensity,e._shadowsSaturation,e._shadowsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._shadowsCurve),e._highlightsCurve.subtractToRef(e._midtonesCurve,e._positiveCurve),e._midtonesCurve.subtractToRef(e._shadowsCurve,e._negativeCurve)),t&&(t.setFloat4(i,e._positiveCurve.r,e._positiveCurve.g,e._positiveCurve.b,e._positiveCurve.a),t.setFloat4(r,e._midtonesCurve.r,e._midtonesCurve.g,e._midtonesCurve.b,e._midtonesCurve.a),t.setFloat4(n,e._negativeCurve.r,e._negativeCurve.g,e._negativeCurve.b,e._negativeCurve.a))},e.PrepareUniforms=function(e){e.push("vCameraColorCurveNeutral","vCameraColorCurvePositive","vCameraColorCurveNegative")},e.prototype.getColorGradingDataToRef=function(t,i,r,n,o){null!=t&&(t=e.clamp(t,0,360),i=e.clamp(i,-100,100),r=e.clamp(r,-100,100),n=e.clamp(n,-100,100),i=e.applyColorGradingSliderNonlinear(i),i*=.5,n=e.applyColorGradingSliderNonlinear(n),i<0&&(i*=-1,t=(t+180)%360),e.fromHSBToRef(t,i,50+.25*n,o),o.scaleToRef(2,o),o.a=1+.01*r)},e.applyColorGradingSliderNonlinear=function(e){e/=100;var t=Math.abs(e);return t=Math.pow(t,2),e<0&&(t*=-1),t*=100},e.fromHSBToRef=function(t,i,r,n){var o=e.clamp(t,0,360),s=e.clamp(i/100,0,1),a=e.clamp(r/100,0,1);if(0===s)n.r=a,n.g=a,n.b=a;else{o/=60;var h=Math.floor(o),u=o-h,l=a*(1-s),c=a*(1-s*u),f=a*(1-s*(1-u));switch(h){case 0:n.r=a,n.g=f,n.b=l;break;case 1:n.r=c,n.g=a,n.b=l;break;case 2:n.r=l,n.g=a,n.b=f;break;case 3:n.r=l,n.g=c,n.b=a;break;case 4:n.r=f,n.g=l,n.b=a;break;default:n.r=a,n.g=l,n.b=c}}n.a=1},e.clamp=function(e,t,i){return Math.min(Math.max(e,t),i)},e.prototype.clone=function(){return N.Clone((function(){return new e}),this)},e.prototype.serialize=function(){return N.Serialize(this)},e.Parse=function(t){return N.Parse((function(){return new e}),t,null,null)},r([O()],e.prototype,"_globalHue",void 0),r([O()],e.prototype,"_globalDensity",void 0),r([O()],e.prototype,"_globalSaturation",void 0),r([O()],e.prototype,"_globalExposure",void 0),r([O()],e.prototype,"_highlightsHue",void 0),r([O()],e.prototype,"_highlightsDensity",void 0),r([O()],e.prototype,"_highlightsSaturation",void 0),r([O()],e.prototype,"_highlightsExposure",void 0),r([O()],e.prototype,"_midtonesHue",void 0),r([O()],e.prototype,"_midtonesDensity",void 0),r([O()],e.prototype,"_midtonesSaturation",void 0),r([O()],e.prototype,"_midtonesExposure",void 0),e}();N._ColorCurvesParser=Di.Parse;!function(e){function i(){var t=e.call(this)||this;return t.IMAGEPROCESSING=!1,t.VIGNETTE=!1,t.VIGNETTEBLENDMODEMULTIPLY=!1,t.VIGNETTEBLENDMODEOPAQUE=!1,t.TONEMAPPING=!1,t.TONEMAPPING_ACES=!1,t.CONTRAST=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.COLORGRADING3D=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.EXPOSURE=!1,t.rebuild(),t}t(i,e)}(Ri);var wi=function(){function e(){this.colorCurves=new Di,this._colorCurvesEnabled=!1,this._colorGradingEnabled=!1,this._colorGradingWithGreenDepth=!0,this._colorGradingBGR=!0,this._exposure=1,this._toneMappingEnabled=!1,this._toneMappingType=e.TONEMAPPING_STANDARD,this._contrast=1,this.vignetteStretch=0,this.vignetteCentreX=0,this.vignetteCentreY=0,this.vignetteWeight=1.5,this.vignetteColor=new E(0,0,0,0),this.vignetteCameraFov=.5,this._vignetteBlendMode=e.VIGNETTEMODE_MULTIPLY,this._vignetteEnabled=!1,this._applyByPostProcess=!1,this._isEnabled=!0,this.onUpdateParameters=new U}var t;return Object.defineProperty(e.prototype,"colorCurvesEnabled",{get:function(){return this._colorCurvesEnabled},set:function(e){this._colorCurvesEnabled!==e&&(this._colorCurvesEnabled=e,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"colorGradingTexture",{get:function(){return this._colorGradingTexture},set:function(e){this._colorGradingTexture!==e&&(this._colorGradingTexture=e,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"colorGradingEnabled",{get:function(){return this._colorGradingEnabled},set:function(e){this._colorGradingEnabled!==e&&(this._colorGradingEnabled=e,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"colorGradingWithGreenDepth",{get:function(){return this._colorGradingWithGreenDepth},set:function(e){this._colorGradingWithGreenDepth!==e&&(this._colorGradingWithGreenDepth=e,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"colorGradingBGR",{get:function(){return this._colorGradingBGR},set:function(e){this._colorGradingBGR!==e&&(this._colorGradingBGR=e,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"exposure",{get:function(){return this._exposure},set:function(e){this._exposure!==e&&(this._exposure=e,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"toneMappingEnabled",{get:function(){return this._toneMappingEnabled},set:function(e){this._toneMappingEnabled!==e&&(this._toneMappingEnabled=e,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"toneMappingType",{get:function(){return this._toneMappingType},set:function(e){this._toneMappingType!==e&&(this._toneMappingType=e,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"contrast",{get:function(){return this._contrast},set:function(e){this._contrast!==e&&(this._contrast=e,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"vignetteBlendMode",{get:function(){return this._vignetteBlendMode},set:function(e){this._vignetteBlendMode!==e&&(this._vignetteBlendMode=e,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"vignetteEnabled",{get:function(){return this._vignetteEnabled},set:function(e){this._vignetteEnabled!==e&&(this._vignetteEnabled=e,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"applyByPostProcess",{get:function(){return this._applyByPostProcess},set:function(e){this._applyByPostProcess!==e&&(this._applyByPostProcess=e,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled!==e&&(this._isEnabled=e,this._updateParameters())},enumerable:!1,configurable:!0}),e.prototype._updateParameters=function(){this.onUpdateParameters.notifyObservers(this)},e.prototype.getClassName=function(){return"ImageProcessingConfiguration"},e.PrepareUniforms=function(e,t){t.EXPOSURE&&e.push("exposureLinear"),t.CONTRAST&&e.push("contrast"),t.COLORGRADING&&e.push("colorTransformSettings"),t.VIGNETTE&&(e.push("vInverseScreenSize"),e.push("vignetteSettings1"),e.push("vignetteSettings2")),t.COLORCURVES&&Di.PrepareUniforms(e)},e.PrepareSamplers=function(e,t){t.COLORGRADING&&e.push("txColorTransform")},e.prototype.prepareDefines=function(t,i){if(void 0===i&&(i=!1),i!==this.applyByPostProcess||!this._isEnabled)return t.VIGNETTE=!1,t.TONEMAPPING=!1,t.TONEMAPPING_ACES=!1,t.CONTRAST=!1,t.EXPOSURE=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.COLORGRADING3D=!1,t.IMAGEPROCESSING=!1,void(t.IMAGEPROCESSINGPOSTPROCESS=this.applyByPostProcess&&this._isEnabled);if(t.VIGNETTE=this.vignetteEnabled,t.VIGNETTEBLENDMODEMULTIPLY=this.vignetteBlendMode===e._VIGNETTEMODE_MULTIPLY,t.VIGNETTEBLENDMODEOPAQUE=!t.VIGNETTEBLENDMODEMULTIPLY,t.TONEMAPPING=this.toneMappingEnabled,this._toneMappingType===e.TONEMAPPING_ACES)t.TONEMAPPING_ACES=!0;else t.TONEMAPPING_ACES=!1;t.CONTRAST=1!==this.contrast,t.EXPOSURE=1!==this.exposure,t.COLORCURVES=this.colorCurvesEnabled&&!!this.colorCurves,t.COLORGRADING=this.colorGradingEnabled&&!!this.colorGradingTexture,t.COLORGRADING?t.COLORGRADING3D=this.colorGradingTexture.is3D:t.COLORGRADING3D=!1,t.SAMPLER3DGREENDEPTH=this.colorGradingWithGreenDepth,t.SAMPLER3DBGRMAP=this.colorGradingBGR,t.IMAGEPROCESSINGPOSTPROCESS=this.applyByPostProcess,t.IMAGEPROCESSING=t.VIGNETTE||t.TONEMAPPING||t.CONTRAST||t.EXPOSURE||t.COLORCURVES||t.COLORGRADING},e.prototype.isReady=function(){return!this.colorGradingEnabled||!this.colorGradingTexture||this.colorGradingTexture.isReady()},e.prototype.bind=function(e,t){if(this._colorCurvesEnabled&&this.colorCurves&&Di.Bind(this.colorCurves,e),this._vignetteEnabled){var i=1/e.getEngine().getRenderWidth(),r=1/e.getEngine().getRenderHeight();e.setFloat2("vInverseScreenSize",i,r);var n=null!=t?t:r/i,o=Math.tan(.5*this.vignetteCameraFov),s=o*n,a=Math.sqrt(s*o);s=Ue.Mix(s,a,this.vignetteStretch),o=Ue.Mix(o,a,this.vignetteStretch),e.setFloat4("vignetteSettings1",s,o,-s*this.vignetteCentreX,-o*this.vignetteCentreY);var h=-2*this.vignetteWeight;e.setFloat4("vignetteSettings2",this.vignetteColor.r,this.vignetteColor.g,this.vignetteColor.b,h)}if(e.setFloat("exposureLinear",this.exposure),e.setFloat("contrast",this.contrast),this.colorGradingTexture){e.setTexture("txColorTransform",this.colorGradingTexture);var u=this.colorGradingTexture.getSize().height;e.setFloat4("colorTransformSettings",(u-1)/u,.5/u,u,this.colorGradingTexture.level)}},e.prototype.clone=function(){return N.Clone((function(){return new e}),this)},e.prototype.serialize=function(){return N.Serialize(this)},e.Parse=function(t){return N.Parse((function(){return new e}),t,null,null)},Object.defineProperty(e,"VIGNETTEMODE_MULTIPLY",{get:function(){return this._VIGNETTEMODE_MULTIPLY},enumerable:!1,configurable:!0}),Object.defineProperty(e,"VIGNETTEMODE_OPAQUE",{get:function(){return this._VIGNETTEMODE_OPAQUE},enumerable:!1,configurable:!0}),e.TONEMAPPING_STANDARD=0,e.TONEMAPPING_ACES=1,e._VIGNETTEMODE_MULTIPLY=0,e._VIGNETTEMODE_OPAQUE=1,r([S(7,t)],e.prototype,"colorCurves",void 0),r([O()],e.prototype,"_colorCurvesEnabled",void 0),r([R("colorGradingTexture")],e.prototype,"_colorGradingTexture",void 0),r([O()],e.prototype,"_colorGradingEnabled",void 0),r([O()],e.prototype,"_colorGradingWithGreenDepth",void 0),r([O()],e.prototype,"_colorGradingBGR",void 0),r([O()],e.prototype,"_exposure",void 0),r([O()],e.prototype,"_toneMappingEnabled",void 0),r([O()],e.prototype,"_toneMappingType",void 0),r([O()],e.prototype,"_contrast",void 0),r([O()],e.prototype,"vignetteStretch",void 0),r([O()],e.prototype,"vignetteCentreX",void 0),r([O()],e.prototype,"vignetteCentreY",void 0),r([O()],e.prototype,"vignetteWeight",void 0),r([F()],e.prototype,"vignetteColor",void 0),r([O()],e.prototype,"vignetteCameraFov",void 0),r([O()],e.prototype,"_vignetteBlendMode",void 0),r([O()],e.prototype,"_vignetteEnabled",void 0),r([O()],e.prototype,"_applyByPostProcess",void 0),r([O()],e.prototype,"_isEnabled",void 0),e}();N._ImageProcessingConfigurationParser=wi.Parse;var Li=function(e){function i(t,r){var n=e.call(this,t,r)||this;return n.diffuse=new T(1,1,1),n.specular=new T(1,1,1),n.falloffType=i.FALLOFF_DEFAULT,n.intensity=1,n._range=Number.MAX_VALUE,n._inverseSquaredRange=0,n._photometricScale=1,n._intensityMode=i.INTENSITYMODE_AUTOMATIC,n._radius=1e-5,n.renderPriority=0,n._shadowEnabled=!0,n._excludeWithLayerMask=0,n._includeOnlyWithLayerMask=0,n._lightmapMode=0,n._excludedMeshesIds=new Array,n._includedOnlyMeshesIds=new Array,n._isLight=!0,n.getScene().addLight(n),n._uniformBuffer=new Ut(n.getScene().getEngine()),n._buildUniformLayout(),n.includedOnlyMeshes=new Array,n.excludedMeshes=new Array,n._resyncMeshes(),n}return t(i,e),Object.defineProperty(i.prototype,"range",{get:function(){return this._range},set:function(e){this._range=e,this._inverseSquaredRange=1/(this.range*this.range)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"intensityMode",{get:function(){return this._intensityMode},set:function(e){this._intensityMode=e,this._computePhotometricScale()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"radius",{get:function(){return this._radius},set:function(e){this._radius=e,this._computePhotometricScale()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"shadowEnabled",{get:function(){return this._shadowEnabled},set:function(e){this._shadowEnabled!==e&&(this._shadowEnabled=e,this._markMeshesAsLightDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"includedOnlyMeshes",{get:function(){return this._includedOnlyMeshes},set:function(e){this._includedOnlyMeshes=e,this._hookArrayForIncludedOnly(e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"excludedMeshes",{get:function(){return this._excludedMeshes},set:function(e){this._excludedMeshes=e,this._hookArrayForExcluded(e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"excludeWithLayerMask",{get:function(){return this._excludeWithLayerMask},set:function(e){this._excludeWithLayerMask=e,this._resyncMeshes()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"includeOnlyWithLayerMask",{get:function(){return this._includeOnlyWithLayerMask},set:function(e){this._includeOnlyWithLayerMask=e,this._resyncMeshes()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"lightmapMode",{get:function(){return this._lightmapMode},set:function(e){this._lightmapMode!==e&&(this._lightmapMode=e,this._markMeshesAsLightDirty())},enumerable:!1,configurable:!0}),i.prototype.transferTexturesToEffect=function(e,t){return this},i.prototype._bindLight=function(e,t,i,r,n){void 0===n&&(n=!1);var o=e.toString(),s=!1;if(!n||!this._uniformBuffer._alreadyBound){if(this._uniformBuffer.bindToEffect(i,"Light"+o),this._renderId!==t.getRenderId()||!this._uniformBuffer.useUbo){this._renderId=t.getRenderId();var a=this.getScaledIntensity();this.transferToEffect(i,o),this.diffuse.scaleToRef(a,x.Color3[0]),this._uniformBuffer.updateColor4("vLightDiffuse",x.Color3[0],this.range,o),r&&(this.specular.scaleToRef(a,x.Color3[1]),this._uniformBuffer.updateColor4("vLightSpecular",x.Color3[1],this.radius,o)),s=!0}if(this.transferTexturesToEffect(i,o),t.shadowsEnabled&&this.shadowEnabled){var h=this.getShadowGenerator();h&&(h.bindShadowLight(o,i),s=!0)}s&&this._uniformBuffer.update()}},i.prototype.getClassName=function(){return"Light"},i.prototype.toString=function(e){var t="Name: "+this.name;if(t+=", type: "+["Point","Directional","Spot","Hemispheric"][this.getTypeID()],this.animations)for(var i=0;i<this.animations.length;i++)t+=", animation[0]: "+this.animations[i].toString(e);return t},i.prototype._syncParentEnabledState=function(){e.prototype._syncParentEnabledState.call(this),this.isDisposed()||this._resyncMeshes()},i.prototype.setEnabled=function(t){e.prototype.setEnabled.call(this,t),this._resyncMeshes()},i.prototype.getShadowGenerator=function(){return this._shadowGenerator},i.prototype.getAbsolutePosition=function(){return p.Zero()},i.prototype.canAffectMesh=function(e){return!e||!(this.includedOnlyMeshes&&this.includedOnlyMeshes.length>0&&-1===this.includedOnlyMeshes.indexOf(e))&&(!(this.excludedMeshes&&this.excludedMeshes.length>0&&-1!==this.excludedMeshes.indexOf(e))&&((0===this.includeOnlyWithLayerMask||0!=(this.includeOnlyWithLayerMask&e.layerMask))&&!(0!==this.excludeWithLayerMask&&this.excludeWithLayerMask&e.layerMask)))},i.CompareLightsPriority=function(e,t){return e.shadowEnabled!==t.shadowEnabled?(t.shadowEnabled?1:0)-(e.shadowEnabled?1:0):t.renderPriority-e.renderPriority},i.prototype.dispose=function(t,i){void 0===i&&(i=!1),this._shadowGenerator&&(this._shadowGenerator.dispose(),this._shadowGenerator=null),this.getScene().stopAnimation(this);for(var r=0,n=this.getScene().meshes;r<n.length;r++){n[r]._removeLightSource(this,!0)}this._uniformBuffer.dispose(),this.getScene().removeLight(this),e.prototype.dispose.call(this,t,i)},i.prototype.getTypeID=function(){return 0},i.prototype.getScaledIntensity=function(){return this._photometricScale*this.intensity},i.prototype.clone=function(e,t){void 0===t&&(t=null);var r=i.GetConstructorFromName(this.getTypeID(),e,this.getScene());if(!r)return null;var n=N.Clone(r,this);return t&&(n.parent=t),n.setEnabled(this.isEnabled()),n},i.prototype.serialize=function(){var e=N.Serialize(this);return e.type=this.getTypeID(),this.parent&&(e.parentId=this.parent.id),this.excludedMeshes.length>0&&(e.excludedMeshesIds=[],this.excludedMeshes.forEach((function(t){e.excludedMeshesIds.push(t.id)}))),this.includedOnlyMeshes.length>0&&(e.includedOnlyMeshesIds=[],this.includedOnlyMeshes.forEach((function(t){e.includedOnlyMeshesIds.push(t.id)}))),N.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e},i.GetConstructorFromName=function(e,t,i){var r=ut.Construct("Light_Type_"+e,t,i);return r||null},i.Parse=function(e,t){var r=i.GetConstructorFromName(e.type,e.name,t);if(!r)return null;var n=N.Parse(r,e,t);if(e.excludedMeshesIds&&(n._excludedMeshesIds=e.excludedMeshesIds),e.includedOnlyMeshesIds&&(n._includedOnlyMeshesIds=e.includedOnlyMeshesIds),e.parentId&&(n._waitingParentId=e.parentId),void 0!==e.falloffType&&(n.falloffType=e.falloffType),void 0!==e.lightmapMode&&(n.lightmapMode=e.lightmapMode),e.animations){for(var o=0;o<e.animations.length;o++){var s=e.animations[o],a=c.GetClass("BABYLON.Animation");a&&n.animations.push(a.Parse(s))}ut.ParseAnimationRanges(n,e,t)}return e.autoAnimate&&t.beginAnimation(n,e.autoAnimateFrom,e.autoAnimateTo,e.autoAnimateLoop,e.autoAnimateSpeed||1),n},i.prototype._hookArrayForExcluded=function(e){var t=this,i=e.push;e.push=function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];for(var o=i.apply(e,r),s=0,a=r;s<a.length;s++){a[s]._resyncLightSource(t)}return o};var r=e.splice;e.splice=function(i,n){for(var o=r.apply(e,[i,n]),s=0,a=o;s<a.length;s++){a[s]._resyncLightSource(t)}return o};for(var n=0,o=e;n<o.length;n++){o[n]._resyncLightSource(this)}},i.prototype._hookArrayForIncludedOnly=function(e){var t=this,i=e.push;e.push=function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];var o=i.apply(e,r);return t._resyncMeshes(),o};var r=e.splice;e.splice=function(i,n){var o=r.apply(e,[i,n]);return t._resyncMeshes(),o},this._resyncMeshes()},i.prototype._resyncMeshes=function(){for(var e=0,t=this.getScene().meshes;e<t.length;e++){t[e]._resyncLightSource(this)}},i.prototype._markMeshesAsLightDirty=function(){for(var e=0,t=this.getScene().meshes;e<t.length;e++){var i=t[e];-1!==i.lightSources.indexOf(this)&&i._markSubMeshesAsLightDirty()}},i.prototype._computePhotometricScale=function(){this._photometricScale=this._getPhotometricScale(),this.getScene().resetCachedMaterial()},i.prototype._getPhotometricScale=function(){var e=0,t=this.getTypeID(),r=this.intensityMode;switch(r===i.INTENSITYMODE_AUTOMATIC&&(r=t===i.LIGHTTYPEID_DIRECTIONALLIGHT?i.INTENSITYMODE_ILLUMINANCE:i.INTENSITYMODE_LUMINOUSINTENSITY),t){case i.LIGHTTYPEID_POINTLIGHT:case i.LIGHTTYPEID_SPOTLIGHT:switch(r){case i.INTENSITYMODE_LUMINOUSPOWER:e=1/(4*Math.PI);break;case i.INTENSITYMODE_LUMINOUSINTENSITY:e=1;break;case i.INTENSITYMODE_LUMINANCE:e=this.radius*this.radius}break;case i.LIGHTTYPEID_DIRECTIONALLIGHT:switch(r){case i.INTENSITYMODE_ILLUMINANCE:e=1;break;case i.INTENSITYMODE_LUMINANCE:var n=this.radius;n=Math.max(n,.001),e=2*Math.PI*(1-Math.cos(n))}break;case i.LIGHTTYPEID_HEMISPHERICLIGHT:e=1}return e},i.prototype._reorderLightsInScene=function(){var e=this.getScene();0!=this._renderPriority&&(e.requireLightSorting=!0),this.getScene().sortLightsByPriority()},i.FALLOFF_DEFAULT=0,i.FALLOFF_PHYSICAL=1,i.FALLOFF_GLTF=2,i.FALLOFF_STANDARD=3,i.LIGHTMAP_DEFAULT=0,i.LIGHTMAP_SPECULAR=1,i.LIGHTMAP_SHADOWSONLY=2,i.INTENSITYMODE_AUTOMATIC=0,i.INTENSITYMODE_LUMINOUSPOWER=1,i.INTENSITYMODE_LUMINOUSINTENSITY=2,i.INTENSITYMODE_ILLUMINANCE=3,i.INTENSITYMODE_LUMINANCE=4,i.LIGHTTYPEID_POINTLIGHT=0,i.LIGHTTYPEID_DIRECTIONALLIGHT=1,i.LIGHTTYPEID_SPOTLIGHT=2,i.LIGHTTYPEID_HEMISPHERICLIGHT=3,r([D()],i.prototype,"diffuse",void 0),r([D()],i.prototype,"specular",void 0),r([O()],i.prototype,"falloffType",void 0),r([O()],i.prototype,"intensity",void 0),r([O()],i.prototype,"range",null),r([O()],i.prototype,"intensityMode",null),r([O()],i.prototype,"radius",null),r([O()],i.prototype,"_renderPriority",void 0),r([I("_reorderLightsInScene")],i.prototype,"renderPriority",void 0),r([O("shadowEnabled")],i.prototype,"_shadowEnabled",void 0),r([O("excludeWithLayerMask")],i.prototype,"_excludeWithLayerMask",void 0),r([O("includeOnlyWithLayerMask")],i.prototype,"_includeOnlyWithLayerMask",void 0),r([O("lightmapMode")],i.prototype,"_lightmapMode",void 0),i}(ut),Fi=function(){function e(e){this._vertexBuffers={},this._scene=e}return e.prototype._prepareBuffers=function(){if(!this._vertexBuffers[ft.PositionKind]){var e=[];e.push(1,1),e.push(-1,1),e.push(-1,-1),e.push(1,-1),this._vertexBuffers[ft.PositionKind]=new ft(this._scene.getEngine(),e,ft.PositionKind,!1,!1,2),this._buildIndexBuffer()}},e.prototype._buildIndexBuffer=function(){var e=[];e.push(0),e.push(1),e.push(2),e.push(0),e.push(2),e.push(3),this._indexBuffer=this._scene.getEngine().createIndexBuffer(e)},e.prototype._rebuild=function(){var e=this._vertexBuffers[ft.PositionKind];e&&(e._rebuild(),this._buildIndexBuffer())},e.prototype._prepareFrame=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null);var i=this._scene.activeCamera;return!!i&&(!(!(t=t||i._postProcesses.filter((function(e){return null!=e})))||0===t.length||!this._scene.postProcessesEnabled)&&(t[0].activate(i,e,null!=t),!0))},e.prototype.directRender=function(e,t,i,r,n,o){void 0===t&&(t=null),void 0===i&&(i=!1),void 0===r&&(r=0),void 0===n&&(n=0),void 0===o&&(o=!1);for(var s=this._scene.getEngine(),a=0;a<e.length;a++){a<e.length-1?e[a+1].activate(this._scene.activeCamera,t):t?s.bindFramebuffer(t,r,void 0,void 0,i,n):o||s.restoreDefaultFramebuffer();var h=e[a],u=h.apply();u&&(h.onBeforeRenderObservable.notifyObservers(u),this._prepareBuffers(),s.bindBuffers(this._vertexBuffers,this._indexBuffer,u),s.drawElementsType(Vt.TriangleFillMode,0,6),h.onAfterRenderObservable.notifyObservers(u))}s.setDepthBuffer(!0),s.setDepthWrite(!0)},e.prototype._finalizeFrame=function(e,t,i,r,n){void 0===n&&(n=!1);var o=this._scene.activeCamera;if(o&&(r=r||o._postProcesses.filter((function(e){return null!=e})),0!==r.length&&this._scene.postProcessesEnabled)){for(var s=this._scene.getEngine(),a=0,h=r.length;a<h;a++){var u=r[a];if(a<h-1?u._outputTexture=r[a+1].activate(o,t):t?(s.bindFramebuffer(t,i,void 0,void 0,n),u._outputTexture=t):(s.restoreDefaultFramebuffer(),u._outputTexture=null),e)break;var l=u.apply();l&&(u.onBeforeRenderObservable.notifyObservers(l),this._prepareBuffers(),s.bindBuffers(this._vertexBuffers,this._indexBuffer,l),s.drawElementsType(Vt.TriangleFillMode,0,6),u.onAfterRenderObservable.notifyObservers(l))}s.setDepthBuffer(!0),s.setDepthWrite(!0),s.setAlphaMode(0)}},e.prototype.dispose=function(){var e=this._vertexBuffers[ft.PositionKind];e&&(e.dispose(),this._vertexBuffers[ft.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null)},e}(),Ni=function(){function e(e,t,i,r,n){void 0===i&&(i=null),void 0===r&&(r=null),void 0===n&&(n=null),this.index=e,this._opaqueSubMeshes=new di(256),this._transparentSubMeshes=new di(256),this._alphaTestSubMeshes=new di(256),this._depthOnlySubMeshes=new di(256),this._particleSystems=new di(256),this._spriteManagers=new di(256),this._edgesRenderers=new pi(16),this._scene=t,this.opaqueSortCompareFn=i,this.alphaTestSortCompareFn=r,this.transparentSortCompareFn=n}return Object.defineProperty(e.prototype,"opaqueSortCompareFn",{set:function(t){this._opaqueSortCompareFn=t,this._renderOpaque=t?this.renderOpaqueSorted:e.renderUnsorted},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"alphaTestSortCompareFn",{set:function(t){this._alphaTestSortCompareFn=t,this._renderAlphaTest=t?this.renderAlphaTestSorted:e.renderUnsorted},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transparentSortCompareFn",{set:function(t){this._transparentSortCompareFn=t||e.defaultTransparentSortCompare,this._renderTransparent=this.renderTransparentSorted},enumerable:!1,configurable:!0}),e.prototype.render=function(e,t,i,r){if(e)e(this._opaqueSubMeshes,this._alphaTestSubMeshes,this._transparentSubMeshes,this._depthOnlySubMeshes);else{var n=this._scene.getEngine();0!==this._depthOnlySubMeshes.length&&(n.setColorWrite(!1),this._renderAlphaTest(this._depthOnlySubMeshes),n.setColorWrite(!0)),0!==this._opaqueSubMeshes.length&&this._renderOpaque(this._opaqueSubMeshes),0!==this._alphaTestSubMeshes.length&&this._renderAlphaTest(this._alphaTestSubMeshes);var o=n.getStencilBuffer();if(n.setStencilBuffer(!1),t&&this._renderSprites(),i&&this._renderParticles(r),this.onBeforeTransparentRendering&&this.onBeforeTransparentRendering(),0!==this._transparentSubMeshes.length&&(n.setStencilBuffer(o),this._renderTransparent(this._transparentSubMeshes),n.setAlphaMode(0)),n.setStencilBuffer(!1),this._edgesRenderers.length){for(var s=0;s<this._edgesRenderers.length;s++)this._edgesRenderers.data[s].render();n.setAlphaMode(0)}n.setStencilBuffer(o)}},e.prototype.renderOpaqueSorted=function(t){return e.renderSorted(t,this._opaqueSortCompareFn,this._scene.activeCamera,!1)},e.prototype.renderAlphaTestSorted=function(t){return e.renderSorted(t,this._alphaTestSortCompareFn,this._scene.activeCamera,!1)},e.prototype.renderTransparentSorted=function(t){return e.renderSorted(t,this._transparentSortCompareFn,this._scene.activeCamera,!0)},e.renderSorted=function(t,i,r,n){for(var o,s=0,a=r?r.globalPosition:e._zeroVector;s<t.length;s++)(o=t.data[s])._alphaIndex=o.getMesh().alphaIndex,o._distanceToCamera=p.Distance(o.getBoundingInfo().boundingSphere.centerWorld,a);var h=t.data.slice(0,t.length);for(i&&h.sort(i),s=0;s<h.length;s++){if(o=h[s],n){var u=o.getMaterial();if(u&&u.needDepthPrePass){var l=u.getScene().getEngine();l.setColorWrite(!1),l.setAlphaMode(0),o.render(!1),l.setColorWrite(!0)}}o.render(n)}},e.renderUnsorted=function(e){for(var t=0;t<e.length;t++){e.data[t].render(!1)}},e.defaultTransparentSortCompare=function(t,i){return t._alphaIndex>i._alphaIndex?1:t._alphaIndex<i._alphaIndex?-1:e.backToFrontSortCompare(t,i)},e.backToFrontSortCompare=function(e,t){return e._distanceToCamera<t._distanceToCamera?1:e._distanceToCamera>t._distanceToCamera?-1:0},e.frontToBackSortCompare=function(e,t){return e._distanceToCamera<t._distanceToCamera?-1:e._distanceToCamera>t._distanceToCamera?1:0},e.prototype.prepare=function(){this._opaqueSubMeshes.reset(),this._transparentSubMeshes.reset(),this._alphaTestSubMeshes.reset(),this._depthOnlySubMeshes.reset(),this._particleSystems.reset(),this._spriteManagers.reset(),this._edgesRenderers.reset()},e.prototype.dispose=function(){this._opaqueSubMeshes.dispose(),this._transparentSubMeshes.dispose(),this._alphaTestSubMeshes.dispose(),this._depthOnlySubMeshes.dispose(),this._particleSystems.dispose(),this._spriteManagers.dispose(),this._edgesRenderers.dispose()},e.prototype.dispatch=function(e,t,i){void 0===t&&(t=e.getMesh()),void 0===i&&(i=e.getMaterial()),null!=i&&(i.needAlphaBlendingForMesh(t)?this._transparentSubMeshes.push(e):i.needAlphaTesting()?(i.needDepthPrePass&&this._depthOnlySubMeshes.push(e),this._alphaTestSubMeshes.push(e)):(i.needDepthPrePass&&this._depthOnlySubMeshes.push(e),this._opaqueSubMeshes.push(e)),t._renderingGroup=this,t._edgesRenderer&&t._edgesRenderer.isEnabled&&this._edgesRenderers.pushNoDuplicate(t._edgesRenderer))},e.prototype.dispatchSprites=function(e){this._spriteManagers.push(e)},e.prototype.dispatchParticles=function(e){this._particleSystems.push(e)},e.prototype._renderParticles=function(e){if(0!==this._particleSystems.length){var t=this._scene.activeCamera;this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);for(var i=0;i<this._particleSystems.length;i++){var r=this._particleSystems.data[i];if(0!==(t&&t.layerMask&r.layerMask)){var n=r.emitter;n.position&&e&&-1===e.indexOf(n)||this._scene._activeParticles.addCount(r.render(),!1)}}this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene)}},e.prototype._renderSprites=function(){if(this._scene.spritesEnabled&&0!==this._spriteManagers.length){var e=this._scene.activeCamera;this._scene.onBeforeSpritesRenderingObservable.notifyObservers(this._scene);for(var t=0;t<this._spriteManagers.length;t++){var i=this._spriteManagers.data[t];0!==(e&&e.layerMask&i.layerMask)&&i.render()}this._scene.onAfterSpritesRenderingObservable.notifyObservers(this._scene)}},e._zeroVector=p.Zero(),e}(),Bi=function(){},ki=function(){function e(t){this._useSceneAutoClearSetup=!1,this._renderingGroups=new Array,this._autoClearDepthStencil={},this._customOpaqueSortCompareFn={},this._customAlphaTestSortCompareFn={},this._customTransparentSortCompareFn={},this._renderingGroupInfo=new Bi,this._scene=t;for(var i=e.MIN_RENDERINGGROUPS;i<e.MAX_RENDERINGGROUPS;i++)this._autoClearDepthStencil[i]={autoClear:!0,depth:!0,stencil:!0}}return e.prototype._clearDepthStencilBuffer=function(e,t){void 0===e&&(e=!0),void 0===t&&(t=!0),this._depthStencilBufferAlreadyCleaned||(this._scene.getEngine().clear(null,!1,e,t),this._depthStencilBufferAlreadyCleaned=!0)},e.prototype.render=function(t,i,r,n){var o=this._renderingGroupInfo;if(o.scene=this._scene,o.camera=this._scene.activeCamera,this._scene.spriteManagers&&n)for(var s=0;s<this._scene.spriteManagers.length;s++){var a=this._scene.spriteManagers[s];this.dispatchSprites(a)}for(s=e.MIN_RENDERINGGROUPS;s<e.MAX_RENDERINGGROUPS;s++){this._depthStencilBufferAlreadyCleaned=s===e.MIN_RENDERINGGROUPS;var h=this._renderingGroups[s];if(h){var u=Math.pow(2,s);if(o.renderingGroupId=s,this._scene.onBeforeRenderingGroupObservable.notifyObservers(o,u),e.AUTOCLEAR){var l=this._useSceneAutoClearSetup?this._scene.getAutoClearDepthStencilSetup(s):this._autoClearDepthStencil[s];l&&l.autoClear&&this._clearDepthStencilBuffer(l.depth,l.stencil)}for(var c=0,f=this._scene._beforeRenderingGroupDrawStage;c<f.length;c++){f[c].action(s)}h.render(t,n,r,i);for(var d=0,p=this._scene._afterRenderingGroupDrawStage;d<p.length;d++){p[d].action(s)}this._scene.onAfterRenderingGroupObservable.notifyObservers(o,u)}}},e.prototype.reset=function(){for(var t=e.MIN_RENDERINGGROUPS;t<e.MAX_RENDERINGGROUPS;t++){var i=this._renderingGroups[t];i&&i.prepare()}},e.prototype.dispose=function(){this.freeRenderingGroups(),this._renderingGroups.length=0,this._renderingGroupInfo=null},e.prototype.freeRenderingGroups=function(){for(var t=e.MIN_RENDERINGGROUPS;t<e.MAX_RENDERINGGROUPS;t++){var i=this._renderingGroups[t];i&&i.dispose()}},e.prototype._prepareRenderingGroup=function(e){void 0===this._renderingGroups[e]&&(this._renderingGroups[e]=new Ni(e,this._scene,this._customOpaqueSortCompareFn[e],this._customAlphaTestSortCompareFn[e],this._customTransparentSortCompareFn[e]))},e.prototype.dispatchSprites=function(e){var t=e.renderingGroupId||0;this._prepareRenderingGroup(t),this._renderingGroups[t].dispatchSprites(e)},e.prototype.dispatchParticles=function(e){var t=e.renderingGroupId||0;this._prepareRenderingGroup(t),this._renderingGroups[t].dispatchParticles(e)},e.prototype.dispatch=function(e,t,i){void 0===t&&(t=e.getMesh());var r=t.renderingGroupId||0;this._prepareRenderingGroup(r),this._renderingGroups[r].dispatch(e,t,i)},e.prototype.setRenderingOrder=function(e,t,i,r){if(void 0===t&&(t=null),void 0===i&&(i=null),void 0===r&&(r=null),this._customOpaqueSortCompareFn[e]=t,this._customAlphaTestSortCompareFn[e]=i,this._customTransparentSortCompareFn[e]=r,this._renderingGroups[e]){var n=this._renderingGroups[e];n.opaqueSortCompareFn=this._customOpaqueSortCompareFn[e],n.alphaTestSortCompareFn=this._customAlphaTestSortCompareFn[e],n.transparentSortCompareFn=this._customTransparentSortCompareFn[e]}},e.prototype.setRenderingAutoClearDepthStencil=function(e,t,i,r){void 0===i&&(i=!0),void 0===r&&(r=!0),this._autoClearDepthStencil[e]={autoClear:t,depth:i,stencil:r}},e.prototype.getAutoClearDepthStencilSetup=function(e){return this._autoClearDepthStencil[e]},e.MAX_RENDERINGGROUPS=4,e.MIN_RENDERINGGROUPS=0,e.AUTOCLEAR=!0,e}(),Ui=function(){function e(){this._singleClick=!1,this._doubleClick=!1,this._hasSwiped=!1,this._ignore=!1}return Object.defineProperty(e.prototype,"singleClick",{get:function(){return this._singleClick},set:function(e){this._singleClick=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"doubleClick",{get:function(){return this._doubleClick},set:function(e){this._doubleClick=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasSwiped",{get:function(){return this._hasSwiped},set:function(e){this._hasSwiped=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ignore",{get:function(){return this._ignore},set:function(e){this._ignore=e},enumerable:!1,configurable:!0}),e}(),Vi=function(){function e(e){this._alreadyAttached=!1,this._wheelEventName="",this._meshPickProceed=!1,this._currentPickResult=null,this._previousPickResult=null,this._totalPointersPressed=0,this._doubleClickOccured=!1,this._pointerX=0,this._pointerY=0,this._startingPointerPosition=new d(0,0),this._previousStartingPointerPosition=new d(0,0),this._startingPointerTime=0,this._previousStartingPointerTime=0,this._pointerCaptures={},this._meshUnderPointerId=[],this._keyboardIsAttached=!1,this._scene=e}return Object.defineProperty(e.prototype,"meshUnderPointer",{get:function(){return this._pointerOverMesh},enumerable:!1,configurable:!0}),e.prototype.getMeshUnderPointerByPointerId=function(e){return this._meshUnderPointerId[e]},Object.defineProperty(e.prototype,"unTranslatedPointer",{get:function(){return new d(this._unTranslatedPointerX,this._unTranslatedPointerY)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pointerX",{get:function(){return this._pointerX},set:function(e){this._pointerX=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pointerY",{get:function(){return this._pointerY},set:function(e){this._pointerY=e},enumerable:!1,configurable:!0}),e.prototype._updatePointerPosition=function(e){var t=this._scene.getEngine().getInputElementClientRect();t&&(this._pointerX=e.clientX-t.left,this._pointerY=e.clientY-t.top,this._unTranslatedPointerX=this._pointerX,this._unTranslatedPointerY=this._pointerY)},e.prototype._processPointerMove=function(e,t){var i=this._scene,r=i.getEngine(),n=r.getInputElement();if(n){n.tabIndex=r.canvasTabIndex,i.doNotHandleCursors||(n.style.cursor=i.defaultCursor);var o=!!(e&&e.hit&&e.pickedMesh);o?(i.setPointerOverMesh(e.pickedMesh,t.pointerId),this._pointerOverMesh&&this._pointerOverMesh.actionManager&&this._pointerOverMesh.actionManager.hasPointerTriggers&&(i.doNotHandleCursors||(this._pointerOverMesh.actionManager.hoverCursor?n.style.cursor=this._pointerOverMesh.actionManager.hoverCursor:n.style.cursor=i.hoverCursor))):i.setPointerOverMesh(null,t.pointerId);for(var s=0,a=i._pointerMoveStage;s<a.length;s++){e=a[s].action(this._unTranslatedPointerX,this._unTranslatedPointerY,e,o,n)}if(e){var h=t.type===this._wheelEventName?Jt.POINTERWHEEL:Jt.POINTERMOVE;if(i.onPointerMove&&i.onPointerMove(t,e,h),i.onPointerObservable.hasObservers()){var u=new ti(h,t,e);this._setRayOnPointerInfo(u),i.onPointerObservable.notifyObservers(u,h)}}}},e.prototype._setRayOnPointerInfo=function(e){var t=this._scene;e.pickInfo&&!e.pickInfo._pickingUnavailable&&(e.pickInfo.ray||(e.pickInfo.ray=t.createPickingRay(e.event.offsetX,e.event.offsetY,m.Identity(),t.activeCamera)))},e.prototype._checkPrePointerObservable=function(e,t,i){var r=this._scene,n=new ei(i,t,this._unTranslatedPointerX,this._unTranslatedPointerY);return e&&(n.ray=e.ray),r.onPrePointerObservable.notifyObservers(n,i),!!n.skipOnPointerObservable},e.prototype.simulatePointerMove=function(e,t){var i=new PointerEvent("pointermove",t);this._checkPrePointerObservable(e,i,Jt.POINTERMOVE)||this._processPointerMove(e,i)},e.prototype.simulatePointerDown=function(e,t){var i=new PointerEvent("pointerdown",t);this._checkPrePointerObservable(e,i,Jt.POINTERDOWN)||this._processPointerDown(e,i)},e.prototype._processPointerDown=function(t,i){var r=this,n=this._scene;if(t&&t.hit&&t.pickedMesh){this._pickedDownMesh=t.pickedMesh;var o=t.pickedMesh._getActionManagerForTrigger();if(o){if(o.hasPickTriggers)switch(o.processTrigger(5,Xe.CreateNew(t.pickedMesh,i)),i.button){case 0:o.processTrigger(2,Xe.CreateNew(t.pickedMesh,i));break;case 1:o.processTrigger(4,Xe.CreateNew(t.pickedMesh,i));break;case 2:o.processTrigger(3,Xe.CreateNew(t.pickedMesh,i))}o.hasSpecificTrigger(8)&&window.setTimeout((function(){var t=n.pick(r._unTranslatedPointerX,r._unTranslatedPointerY,(function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.actionManager&&e.actionManager.hasSpecificTrigger(8)&&e==r._pickedDownMesh}),!1,n.cameraToUseForPointers);t&&t.hit&&t.pickedMesh&&o&&0!==r._totalPointersPressed&&Date.now()-r._startingPointerTime>e.LongPressDelay&&!r._isPointerSwiping()&&(r._startingPointerTime=0,o.processTrigger(8,Xe.CreateNew(t.pickedMesh,i)))}),e.LongPressDelay)}}else for(var s=0,a=n._pointerDownStage;s<a.length;s++){t=a[s].action(this._unTranslatedPointerX,this._unTranslatedPointerY,t,i)}if(t){var h=Jt.POINTERDOWN;if(n.onPointerDown&&n.onPointerDown(i,t,h),n.onPointerObservable.hasObservers()){var u=new ti(h,i,t);this._setRayOnPointerInfo(u),n.onPointerObservable.notifyObservers(u,h)}}},e.prototype._isPointerSwiping=function(){return Math.abs(this._startingPointerPosition.x-this._pointerX)>e.DragMovementThreshold||Math.abs(this._startingPointerPosition.y-this._pointerY)>e.DragMovementThreshold},e.prototype.simulatePointerUp=function(e,t,i){var r=new PointerEvent("pointerup",t),n=new Ui;i?n.doubleClick=!0:n.singleClick=!0,this._checkPrePointerObservable(e,r,Jt.POINTERUP)||this._processPointerUp(e,r,n)},e.prototype._processPointerUp=function(e,t,i){var r=this._scene;if(e&&e&&e.pickedMesh){if(this._pickedUpMesh=e.pickedMesh,this._pickedDownMesh===this._pickedUpMesh&&(r.onPointerPick&&r.onPointerPick(t,e),i.singleClick&&!i.ignore&&r.onPointerObservable.hasObservers())){var n=Jt.POINTERPICK,o=new ti(n,t,e);this._setRayOnPointerInfo(o),r.onPointerObservable.notifyObservers(o,n)}var s=e.pickedMesh._getActionManagerForTrigger();if(s&&!i.ignore){s.processTrigger(7,Xe.CreateNew(e.pickedMesh,t)),!i.hasSwiped&&i.singleClick&&s.processTrigger(1,Xe.CreateNew(e.pickedMesh,t));var a=e.pickedMesh._getActionManagerForTrigger(6);i.doubleClick&&a&&a.processTrigger(6,Xe.CreateNew(e.pickedMesh,t))}}else if(!i.ignore)for(var h=0,u=r._pointerUpStage;h<u.length;h++){e=u[h].action(this._unTranslatedPointerX,this._unTranslatedPointerY,e,t)}if(this._pickedDownMesh&&this._pickedDownMesh!==this._pickedUpMesh){var l=this._pickedDownMesh._getActionManagerForTrigger(16);l&&l.processTrigger(16,Xe.CreateNew(this._pickedDownMesh,t))}var c=0;if(r.onPointerObservable.hasObservers()){if(!i.ignore&&!i.hasSwiped&&(i.singleClick&&r.onPointerObservable.hasSpecificMask(Jt.POINTERTAP)?c=Jt.POINTERTAP:i.doubleClick&&r.onPointerObservable.hasSpecificMask(Jt.POINTERDOUBLETAP)&&(c=Jt.POINTERDOUBLETAP),c)){o=new ti(c,t,e);this._setRayOnPointerInfo(o),r.onPointerObservable.notifyObservers(o,c)}if(!i.ignore){c=Jt.POINTERUP;o=new ti(c,t,e);this._setRayOnPointerInfo(o),r.onPointerObservable.notifyObservers(o,c)}}r.onPointerUp&&!i.ignore&&r.onPointerUp(t,e,c)},e.prototype.isPointerCaptured=function(e){return void 0===e&&(e=0),this._pointerCaptures[e]},e.prototype.attachControl=function(t,i,r,n){var o=this;void 0===t&&(t=!0),void 0===i&&(i=!0),void 0===r&&(r=!0),void 0===n&&(n=null);var s=this._scene;if(n||(n=s.getEngine().getInputElement()),n){this._alreadyAttached&&this.detachControl(),this._alreadyAttachedTo=n;var a=s.getEngine();this._initActionManager=function(e,t){if(!o._meshPickProceed){var i=s.pick(o._unTranslatedPointerX,o._unTranslatedPointerY,s.pointerDownPredicate,!1,s.cameraToUseForPointers);o._currentPickResult=i,i&&(e=i.hit&&i.pickedMesh?i.pickedMesh._getActionManagerForTrigger():null),o._meshPickProceed=!0}return e},this._delayedSimpleClick=function(t,i,r){(Date.now()-o._previousStartingPointerTime>e.DoubleClickDelay&&!o._doubleClickOccured||t!==o._previousButtonPressed)&&(o._doubleClickOccured=!1,i.singleClick=!0,i.ignore=!1,r(i,o._currentPickResult))},this._initClickEvent=function(t,i,r,n){var s=new Ui;o._currentPickResult=null;var a=null,h=t.hasSpecificMask(Jt.POINTERPICK)||i.hasSpecificMask(Jt.POINTERPICK)||t.hasSpecificMask(Jt.POINTERTAP)||i.hasSpecificMask(Jt.POINTERTAP)||t.hasSpecificMask(Jt.POINTERDOUBLETAP)||i.hasSpecificMask(Jt.POINTERDOUBLETAP);!h&&st&&(a=o._initActionManager(a,s))&&(h=a.hasPickTriggers);var u=!1;if(h){var l=r.button;if(s.hasSwiped=o._isPointerSwiping(),!s.hasSwiped){var c=!e.ExclusiveDoubleClickMode;c||(c=!t.hasSpecificMask(Jt.POINTERDOUBLETAP)&&!i.hasSpecificMask(Jt.POINTERDOUBLETAP))&&!st.HasSpecificTrigger(6)&&(a=o._initActionManager(a,s))&&(c=!a.hasSpecificTrigger(6)),c?(Date.now()-o._previousStartingPointerTime>e.DoubleClickDelay||l!==o._previousButtonPressed)&&(s.singleClick=!0,n(s,o._currentPickResult),u=!0):(o._previousDelayedSimpleClickTimeout=o._delayedSimpleClickTimeout,o._delayedSimpleClickTimeout=window.setTimeout(o._delayedSimpleClick.bind(o,l,s,n),e.DoubleClickDelay));var f=t.hasSpecificMask(Jt.POINTERDOUBLETAP)||i.hasSpecificMask(Jt.POINTERDOUBLETAP);!f&&st.HasSpecificTrigger(6)&&(a=o._initActionManager(a,s))&&(f=a.hasSpecificTrigger(6)),f&&(l===o._previousButtonPressed&&Date.now()-o._previousStartingPointerTime<e.DoubleClickDelay&&!o._doubleClickOccured?(s.hasSwiped||o._isPointerSwiping()?(o._doubleClickOccured=!1,o._previousStartingPointerTime=o._startingPointerTime,o._previousStartingPointerPosition.x=o._startingPointerPosition.x,o._previousStartingPointerPosition.y=o._startingPointerPosition.y,o._previousButtonPressed=l,e.ExclusiveDoubleClickMode?(o._previousDelayedSimpleClickTimeout&&clearTimeout(o._previousDelayedSimpleClickTimeout),o._previousDelayedSimpleClickTimeout=o._delayedSimpleClickTimeout,n(s,o._previousPickResult)):n(s,o._currentPickResult)):(o._previousStartingPointerTime=0,o._doubleClickOccured=!0,s.doubleClick=!0,s.ignore=!1,e.ExclusiveDoubleClickMode&&o._previousDelayedSimpleClickTimeout&&clearTimeout(o._previousDelayedSimpleClickTimeout),o._previousDelayedSimpleClickTimeout=o._delayedSimpleClickTimeout,n(s,o._currentPickResult)),u=!0):(o._doubleClickOccured=!1,o._previousStartingPointerTime=o._startingPointerTime,o._previousStartingPointerPosition.x=o._startingPointerPosition.x,o._previousStartingPointerPosition.y=o._startingPointerPosition.y,o._previousButtonPressed=l))}}u||n(s,o._currentPickResult)},this._onPointerMove=function(e){if(void 0===e.pointerId&&(e.pointerId=0),o._updatePointerPosition(e),!o._checkPrePointerObservable(null,e,e.type===o._wheelEventName?Jt.POINTERWHEEL:Jt.POINTERMOVE)&&(s.cameraToUseForPointers||s.activeCamera)){s.pointerMovePredicate||(s.pointerMovePredicate=function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()&&(e.enablePointerMoveEvents||s.constantlyUpdateMeshUnderPointer||null!=e._getActionManagerForTrigger())&&(!s.cameraToUseForPointers||0!=(s.cameraToUseForPointers.layerMask&e.layerMask))});var t=s.pick(o._unTranslatedPointerX,o._unTranslatedPointerY,s.pointerMovePredicate,!1,s.cameraToUseForPointers);o._processPointerMove(t,e)}},this._onPointerDown=function(e){if(o._totalPointersPressed++,o._pickedDownMesh=null,o._meshPickProceed=!1,void 0===e.pointerId&&(e.pointerId=0),o._updatePointerPosition(e),s.preventDefaultOnPointerDown&&n&&(e.preventDefault(),n.focus()),o._startingPointerPosition.x=o._pointerX,o._startingPointerPosition.y=o._pointerY,o._startingPointerTime=Date.now(),!o._checkPrePointerObservable(null,e,Jt.POINTERDOWN)&&(s.cameraToUseForPointers||s.activeCamera)){o._pointerCaptures[e.pointerId]=!0,s.pointerDownPredicate||(s.pointerDownPredicate=function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()&&(!s.cameraToUseForPointers||0!=(s.cameraToUseForPointers.layerMask&e.layerMask))}),o._pickedDownMesh=null;var t=s.pick(o._unTranslatedPointerX,o._unTranslatedPointerY,s.pointerDownPredicate,!1,s.cameraToUseForPointers);o._processPointerDown(t,e)}},this._onPointerUp=function(e){0!==o._totalPointersPressed&&(o._totalPointersPressed--,o._pickedUpMesh=null,o._meshPickProceed=!1,void 0===e.pointerId&&(e.pointerId=0),o._updatePointerPosition(e),s.preventDefaultOnPointerUp&&n&&(e.preventDefault(),n.focus()),o._initClickEvent(s.onPrePointerObservable,s.onPointerObservable,e,(function(t,i){if(s.onPrePointerObservable.hasObservers()&&!t.ignore){if(!t.hasSwiped){if(t.singleClick&&s.onPrePointerObservable.hasSpecificMask(Jt.POINTERTAP)&&o._checkPrePointerObservable(null,e,Jt.POINTERTAP))return;if(t.doubleClick&&s.onPrePointerObservable.hasSpecificMask(Jt.POINTERDOUBLETAP)&&o._checkPrePointerObservable(null,e,Jt.POINTERDOUBLETAP))return}if(o._checkPrePointerObservable(null,e,Jt.POINTERUP))return}o._pointerCaptures[e.pointerId]&&(o._pointerCaptures[e.pointerId]=!1,(s.cameraToUseForPointers||s.activeCamera)&&(s.pointerUpPredicate||(s.pointerUpPredicate=function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()&&(!s.cameraToUseForPointers||0!=(s.cameraToUseForPointers.layerMask&e.layerMask))}),!o._meshPickProceed&&(st&&st.HasTriggers||s.onPointerObservable.hasObservers())&&o._initActionManager(null,t),i||(i=o._currentPickResult),o._processPointerUp(i,e,t),o._previousPickResult=o._currentPickResult))})))},this._onKeyDown=function(e){var t=Ei.KEYDOWN;if(s.onPreKeyboardObservable.hasObservers()){var i=new Ai(t,e);if(s.onPreKeyboardObservable.notifyObservers(i,t),i.skipOnPointerObservable)return}if(s.onKeyboardObservable.hasObservers()){i=new xi(t,e);s.onKeyboardObservable.notifyObservers(i,t)}s.actionManager&&s.actionManager.processTrigger(14,Xe.CreateNewFromScene(s,e))},this._onKeyUp=function(e){var t=Ei.KEYUP;if(s.onPreKeyboardObservable.hasObservers()){var i=new Ai(t,e);if(s.onPreKeyboardObservable.notifyObservers(i,t),i.skipOnPointerObservable)return}if(s.onKeyboardObservable.hasObservers()){i=new xi(t,e);s.onKeyboardObservable.notifyObservers(i,t)}s.actionManager&&s.actionManager.processTrigger(15,Xe.CreateNewFromScene(s,e))};var h=function(){n&&!o._keyboardIsAttached&&(n.addEventListener("keydown",o._onKeyDown,!1),n.addEventListener("keyup",o._onKeyUp,!1),o._keyboardIsAttached=!0)};this._onCanvasFocusObserver=a.onCanvasFocusObservable.add((document.activeElement===n&&h(),h)),this._onCanvasBlurObserver=a.onCanvasBlurObservable.add((function(){n&&(n.removeEventListener("keydown",o._onKeyDown),n.removeEventListener("keyup",o._onKeyUp),o._keyboardIsAttached=!1)})),h();var u=Ue.GetPointerPrefix(a);if(r&&(n.addEventListener(u+"move",this._onPointerMove,!1),this._wheelEventName="onwheel"in document.createElement("div")?"wheel":void 0!==document.onmousewheel?"mousewheel":"DOMMouseScroll",n.addEventListener(this._wheelEventName,this._onPointerMove,!1)),i&&n.addEventListener(u+"down",this._onPointerDown,!1),t){var l=s.getEngine().getHostWindow();l&&l.addEventListener(u+"up",this._onPointerUp,!1)}this._alreadyAttached=!0}},e.prototype.detachControl=function(){var e=this._scene.getEngine(),t=Ue.GetPointerPrefix(e);this._alreadyAttachedTo&&this._alreadyAttached&&(this._alreadyAttachedTo.removeEventListener(t+"move",this._onPointerMove),this._alreadyAttachedTo.removeEventListener(this._wheelEventName,this._onPointerMove),this._alreadyAttachedTo.removeEventListener(t+"down",this._onPointerDown),window.removeEventListener(t+"up",this._onPointerUp),this._onCanvasBlurObserver&&e.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),this._onCanvasFocusObserver&&e.onCanvasFocusObservable.remove(this._onCanvasFocusObserver),this._alreadyAttachedTo.removeEventListener("keydown",this._onKeyDown),this._alreadyAttachedTo.removeEventListener("keyup",this._onKeyUp),this._scene.doNotHandleCursors||(this._alreadyAttachedTo.style.cursor=this._scene.defaultCursor),this._alreadyAttached=!1)},e.prototype.setPointerOverMesh=function(e,t){if(void 0===t&&(t=0),t<0&&(t=0),this._meshUnderPointerId[t]!==e){var i,r=this._meshUnderPointerId[t];r&&(i=r._getActionManagerForTrigger(10))&&i.processTrigger(10,Xe.CreateNew(r,void 0,{pointerId:t})),this._meshUnderPointerId[t]=e,this._pointerOverMesh=e,(r=this._meshUnderPointerId[t])&&(i=r._getActionManagerForTrigger(9))&&i.processTrigger(9,Xe.CreateNew(r,void 0,{pointerId:t}))}},e.prototype.getPointerOverMesh=function(){return this._pointerOverMesh},e.DragMovementThreshold=10,e.LongPressDelay=500,e.DoubleClickDelay=300,e.ExclusiveDoubleClickMode=!1,e}(),Wi=function(){function e(){}return Object.defineProperty(e,"UniqueId",{get:function(){var e=this._UniqueIdCounter;return this._UniqueIdCounter++,e},enumerable:!1,configurable:!0}),e._UniqueIdCounter=0,e}(),zi=function(e){function r(t,n){var o=e.call(this)||this;o._inputManager=new Vi(o),o.cameraToUseForPointers=null,o._isScene=!0,o._blockEntityCollection=!1,o.autoClear=!0,o.autoClearDepthAndStencil=!0,o.clearColor=new E(.2,.2,.3,1),o.ambientColor=new T(0,0,0),o._environmentIntensity=1,o._forceWireframe=!1,o._skipFrustumClipping=!1,o._forcePointsCloud=!1,o.animationsEnabled=!0,o._animationPropertiesOverride=null,o.useConstantAnimationDeltaTime=!1,o.constantlyUpdateMeshUnderPointer=!1,o.hoverCursor="pointer",o.defaultCursor="",o.doNotHandleCursors=!1,o.preventDefaultOnPointerDown=!0,o.preventDefaultOnPointerUp=!0,o.metadata=null,o.reservedDataStore=null,o.disableOfflineSupportExceptionRules=new Array,o.onDisposeObservable=new U,o._onDisposeObserver=null,o.onBeforeRenderObservable=new U,o._onBeforeRenderObserver=null,o.onAfterRenderObservable=new U,o.onAfterRenderCameraObservable=new U,o._onAfterRenderObserver=null,o.onBeforeAnimationsObservable=new U,o.onAfterAnimationsObservable=new U,o.onBeforeDrawPhaseObservable=new U,o.onAfterDrawPhaseObservable=new U,o.onReadyObservable=new U,o.onBeforeCameraRenderObservable=new U,o._onBeforeCameraRenderObserver=null,o.onAfterCameraRenderObservable=new U,o._onAfterCameraRenderObserver=null,o.onBeforeActiveMeshesEvaluationObservable=new U,o.onAfterActiveMeshesEvaluationObservable=new U,o.onBeforeParticlesRenderingObservable=new U,o.onAfterParticlesRenderingObservable=new U,o.onDataLoadedObservable=new U,o.onNewCameraAddedObservable=new U,o.onCameraRemovedObservable=new U,o.onNewLightAddedObservable=new U,o.onLightRemovedObservable=new U,o.onNewGeometryAddedObservable=new U,o.onGeometryRemovedObservable=new U,o.onNewTransformNodeAddedObservable=new U,o.onTransformNodeRemovedObservable=new U,o.onNewMeshAddedObservable=new U,o.onMeshRemovedObservable=new U,o.onNewSkeletonAddedObservable=new U,o.onSkeletonRemovedObservable=new U,o.onNewMaterialAddedObservable=new U,o.onNewMultiMaterialAddedObservable=new U,o.onMaterialRemovedObservable=new U,o.onMultiMaterialRemovedObservable=new U,o.onNewTextureAddedObservable=new U,o.onTextureRemovedObservable=new U,o.onBeforeRenderTargetsRenderObservable=new U,o.onAfterRenderTargetsRenderObservable=new U,o.onBeforeStepObservable=new U,o.onAfterStepObservable=new U,o.onActiveCameraChanged=new U,o.onBeforeRenderingGroupObservable=new U,o.onAfterRenderingGroupObservable=new U,o.onMeshImportedObservable=new U,o.onAnimationFileImportedObservable=new U,o._registeredForLateAnimationBindings=new pi(256),o.onPrePointerObservable=new U,o.onPointerObservable=new U,o.onPreKeyboardObservable=new U,o.onKeyboardObservable=new U,o._useRightHandedSystem=!1,o._timeAccumulator=0,o._currentStepId=0,o._currentInternalStep=0,o._fogEnabled=!0,o._fogMode=r.FOGMODE_NONE,o.fogColor=new T(.2,.2,.3),o.fogDensity=.1,o.fogStart=0,o.fogEnd=1e3,o.prePass=!1,o._shadowsEnabled=!0,o._lightsEnabled=!0,o.activeCameras=new Array,o._texturesEnabled=!0,o.physicsEnabled=!0,o.particlesEnabled=!0,o.spritesEnabled=!0,o._skeletonsEnabled=!0,o.lensFlaresEnabled=!0,o.collisionsEnabled=!0,o.gravity=new p(0,-9.807,0),o.postProcessesEnabled=!0,o.renderTargetsEnabled=!0,o.dumpNextRenderTargets=!1,o.customRenderTargets=new Array,o.importedMeshesFiles=new Array,o.probesEnabled=!0,o._meshesForIntersections=new pi(256),o.proceduralTexturesEnabled=!0,o._totalVertices=new St,o._activeIndices=new St,o._activeParticles=new St,o._activeBones=new St,o._animationTime=0,o.animationTimeScale=1,o._renderId=0,o._frameId=0,o._executeWhenReadyTimeoutId=-1,o._intermediateRendering=!1,o._viewUpdateFlag=-1,o._projectionUpdateFlag=-1,o._toBeDisposed=new Array(256),o._activeRequests=new Array,o._pendingData=new Array,o._isDisposed=!1,o.dispatchAllSubMeshesOfActiveMeshes=!1,o._activeMeshes=new di(256),o._processedMaterials=new di(256),o._renderTargets=new pi(256),o._activeParticleSystems=new di(256),o._activeSkeletons=new pi(32),o._softwareSkinnedMeshes=new pi(32),o._activeAnimatables=new Array,o._transformMatrix=m.Zero(),o.requireLightSorting=!1,o._components=[],o._serializableComponents=[],o._transientComponents=[],o._beforeCameraUpdateStage=Gt.Create(),o._beforeClearStage=Gt.Create(),o._gatherRenderTargetsStage=Gt.Create(),o._gatherActiveCameraRenderTargetsStage=Gt.Create(),o._isReadyForMeshStage=Gt.Create(),o._beforeEvaluateActiveMeshStage=Gt.Create(),o._evaluateSubMeshStage=Gt.Create(),o._preActiveMeshStage=Gt.Create(),o._cameraDrawRenderTargetStage=Gt.Create(),o._beforeCameraDrawStage=Gt.Create(),o._beforeRenderTargetDrawStage=Gt.Create(),o._beforeRenderingGroupDrawStage=Gt.Create(),o._beforeRenderingMeshStage=Gt.Create(),o._afterRenderingMeshStage=Gt.Create(),o._afterRenderingGroupDrawStage=Gt.Create(),o._afterCameraDrawStage=Gt.Create(),o._afterRenderTargetDrawStage=Gt.Create(),o._afterRenderStage=Gt.Create(),o._pointerMoveStage=Gt.Create(),o._pointerDownStage=Gt.Create(),o._pointerUpStage=Gt.Create(),o.geometriesByUniqueId=null,o._defaultMeshCandidates={data:[],length:0},o._defaultSubMeshCandidates={data:[],length:0},o._preventFreeActiveMeshesAndRenderingGroups=!1,o._activeMeshesFrozen=!1,o._skipEvaluateActiveMeshesCompletely=!1,o._allowPostProcessClearColor=!0,o.getDeterministicFrameTime=function(){return o._engine.getTimeStep()},o._blockMaterialDirtyMechanism=!1;var s=i({useGeometryUniqueIdsMap:!0,useMaterialMeshMap:!0,useClonedMeshMap:!0,virtual:!1},n);return o._engine=t||V.LastCreatedEngine,s.virtual||(V._LastCreatedScene=o,o._engine.scenes.push(o)),o._uid=null,o._renderingManager=new ki(o),Fi&&(o.postProcessManager=new Fi(o)),H.IsWindowObjectExist()&&o.attachControl(),o._createUbo(),wi&&(o._imageProcessingConfiguration=new wi),o.setDefaultCandidateProviders(),s.useGeometryUniqueIdsMap&&(o.geometriesByUniqueId={}),o.useMaterialMeshMap=s.useMaterialMeshMap,o.useClonedMeshMap=s.useClonedMeshMap,n&&n.virtual||o._engine.onNewSceneAddedObservable.notifyObservers(o),o}return t(r,e),r.DefaultMaterialFactory=function(e){throw b.WarnImport("StandardMaterial")},r.CollisionCoordinatorFactory=function(){throw b.WarnImport("DefaultCollisionCoordinator")},Object.defineProperty(r.prototype,"environmentTexture",{get:function(){return this._environmentTexture},set:function(e){this._environmentTexture!==e&&(this._environmentTexture=e,this.markAllMaterialsAsDirty(1))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"environmentIntensity",{get:function(){return this._environmentIntensity},set:function(e){this._environmentIntensity!==e&&(this._environmentIntensity=e,this.markAllMaterialsAsDirty(1))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"forceWireframe",{get:function(){return this._forceWireframe},set:function(e){this._forceWireframe!==e&&(this._forceWireframe=e,this.markAllMaterialsAsDirty(16))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"skipFrustumClipping",{get:function(){return this._skipFrustumClipping},set:function(e){this._skipFrustumClipping!==e&&(this._skipFrustumClipping=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"forcePointsCloud",{get:function(){return this._forcePointsCloud},set:function(e){this._forcePointsCloud!==e&&(this._forcePointsCloud=e,this.markAllMaterialsAsDirty(16))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"animationPropertiesOverride",{get:function(){return this._animationPropertiesOverride},set:function(e){this._animationPropertiesOverride=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"beforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),e&&(this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"afterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),e&&(this._onAfterRenderObserver=this.onAfterRenderObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"beforeCameraRender",{set:function(e){this._onBeforeCameraRenderObserver&&this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=this.onBeforeCameraRenderObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"afterCameraRender",{set:function(e){this._onAfterCameraRenderObserver&&this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=this.onAfterCameraRenderObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"unTranslatedPointer",{get:function(){return this._inputManager.unTranslatedPointer},enumerable:!1,configurable:!0}),Object.defineProperty(r,"DragMovementThreshold",{get:function(){return Vi.DragMovementThreshold},set:function(e){Vi.DragMovementThreshold=e},enumerable:!1,configurable:!0}),Object.defineProperty(r,"LongPressDelay",{get:function(){return Vi.LongPressDelay},set:function(e){Vi.LongPressDelay=e},enumerable:!1,configurable:!0}),Object.defineProperty(r,"DoubleClickDelay",{get:function(){return Vi.DoubleClickDelay},set:function(e){Vi.DoubleClickDelay=e},enumerable:!1,configurable:!0}),Object.defineProperty(r,"ExclusiveDoubleClickMode",{get:function(){return Vi.ExclusiveDoubleClickMode},set:function(e){Vi.ExclusiveDoubleClickMode=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"useRightHandedSystem",{get:function(){return this._useRightHandedSystem},set:function(e){this._useRightHandedSystem!==e&&(this._useRightHandedSystem=e,this.markAllMaterialsAsDirty(16))},enumerable:!1,configurable:!0}),r.prototype.setStepId=function(e){this._currentStepId=e},r.prototype.getStepId=function(){return this._currentStepId},r.prototype.getInternalStep=function(){return this._currentInternalStep},Object.defineProperty(r.prototype,"fogEnabled",{get:function(){return this._fogEnabled},set:function(e){this._fogEnabled!==e&&(this._fogEnabled=e,this.markAllMaterialsAsDirty(16))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"fogMode",{get:function(){return this._fogMode},set:function(e){this._fogMode!==e&&(this._fogMode=e,this.markAllMaterialsAsDirty(16))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"shadowsEnabled",{get:function(){return this._shadowsEnabled},set:function(e){this._shadowsEnabled!==e&&(this._shadowsEnabled=e,this.markAllMaterialsAsDirty(2))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"lightsEnabled",{get:function(){return this._lightsEnabled},set:function(e){this._lightsEnabled!==e&&(this._lightsEnabled=e,this.markAllMaterialsAsDirty(2))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"activeCamera",{get:function(){return this._activeCamera},set:function(e){e!==this._activeCamera&&(this._activeCamera=e,this.onActiveCameraChanged.notifyObservers(this))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"defaultMaterial",{get:function(){return this._defaultMaterial||(this._defaultMaterial=r.DefaultMaterialFactory(this)),this._defaultMaterial},set:function(e){this._defaultMaterial=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"texturesEnabled",{get:function(){return this._texturesEnabled},set:function(e){this._texturesEnabled!==e&&(this._texturesEnabled=e,this.markAllMaterialsAsDirty(1))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"skeletonsEnabled",{get:function(){return this._skeletonsEnabled},set:function(e){this._skeletonsEnabled!==e&&(this._skeletonsEnabled=e,this.markAllMaterialsAsDirty(8))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"collisionCoordinator",{get:function(){return this._collisionCoordinator||(this._collisionCoordinator=r.CollisionCoordinatorFactory(),this._collisionCoordinator.init(this)),this._collisionCoordinator},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"frustumPlanes",{get:function(){return this._frustumPlanes},enumerable:!1,configurable:!0}),r.prototype._registerTransientComponents=function(){if(this._transientComponents.length>0){for(var e=0,t=this._transientComponents;e<t.length;e++){t[e].register()}this._transientComponents=[]}},r.prototype._addComponent=function(e){this._components.push(e),this._transientComponents.push(e);var t=e;t.addFromContainer&&t.serialize&&this._serializableComponents.push(t)},r.prototype._getComponent=function(e){for(var t=0,i=this._components;t<i.length;t++){var r=i[t];if(r.name===e)return r}return null},r.prototype.getClassName=function(){return"Scene"},r.prototype._getDefaultMeshCandidates=function(){return this._defaultMeshCandidates.data=this.meshes,this._defaultMeshCandidates.length=this.meshes.length,this._defaultMeshCandidates},r.prototype._getDefaultSubMeshCandidates=function(e){return this._defaultSubMeshCandidates.data=e.subMeshes,this._defaultSubMeshCandidates.length=e.subMeshes.length,this._defaultSubMeshCandidates},r.prototype.setDefaultCandidateProviders=function(){this.getActiveMeshCandidates=this._getDefaultMeshCandidates.bind(this),this.getActiveSubMeshCandidates=this._getDefaultSubMeshCandidates.bind(this),this.getIntersectingSubMeshCandidates=this._getDefaultSubMeshCandidates.bind(this),this.getCollidingSubMeshCandidates=this._getDefaultSubMeshCandidates.bind(this)},Object.defineProperty(r.prototype,"meshUnderPointer",{get:function(){return this._inputManager.meshUnderPointer},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"pointerX",{get:function(){return this._inputManager.pointerX},set:function(e){this._inputManager.pointerX=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"pointerY",{get:function(){return this._inputManager.pointerY},set:function(e){this._inputManager.pointerY=e},enumerable:!1,configurable:!0}),r.prototype.getCachedMaterial=function(){return this._cachedMaterial},r.prototype.getCachedEffect=function(){return this._cachedEffect},r.prototype.getCachedVisibility=function(){return this._cachedVisibility},r.prototype.isCachedMaterialInvalid=function(e,t,i){return void 0===i&&(i=1),this._cachedEffect!==t||this._cachedMaterial!==e||this._cachedVisibility!==i},r.prototype.getEngine=function(){return this._engine},r.prototype.getTotalVertices=function(){return this._totalVertices.current},Object.defineProperty(r.prototype,"totalVerticesPerfCounter",{get:function(){return this._totalVertices},enumerable:!1,configurable:!0}),r.prototype.getActiveIndices=function(){return this._activeIndices.current},Object.defineProperty(r.prototype,"totalActiveIndicesPerfCounter",{get:function(){return this._activeIndices},enumerable:!1,configurable:!0}),r.prototype.getActiveParticles=function(){return this._activeParticles.current},Object.defineProperty(r.prototype,"activeParticlesPerfCounter",{get:function(){return this._activeParticles},enumerable:!1,configurable:!0}),r.prototype.getActiveBones=function(){return this._activeBones.current},Object.defineProperty(r.prototype,"activeBonesPerfCounter",{get:function(){return this._activeBones},enumerable:!1,configurable:!0}),r.prototype.getActiveMeshes=function(){return this._activeMeshes},r.prototype.getAnimationRatio=function(){return void 0!==this._animationRatio?this._animationRatio:1},r.prototype.getRenderId=function(){return this._renderId},r.prototype.getFrameId=function(){return this._frameId},r.prototype.incrementRenderId=function(){this._renderId++},r.prototype._createUbo=function(){this._sceneUbo=new Ut(this._engine,void 0,!0),this._sceneUbo.addUniform("viewProjection",16),this._sceneUbo.addUniform("view",16)},r.prototype.simulatePointerMove=function(e,t){return this._inputManager.simulatePointerMove(e,t),this},r.prototype.simulatePointerDown=function(e,t){return this._inputManager.simulatePointerDown(e,t),this},r.prototype.simulatePointerUp=function(e,t,i){return this._inputManager.simulatePointerUp(e,t,i),this},r.prototype.isPointerCaptured=function(e){return void 0===e&&(e=0),this._inputManager.isPointerCaptured(e)},r.prototype.attachControl=function(e,t,i){void 0===e&&(e=!0),void 0===t&&(t=!0),void 0===i&&(i=!0),this._inputManager.attachControl(e,t,i)},r.prototype.detachControl=function(){this._inputManager.detachControl()},r.prototype.isReady=function(){if(this._isDisposed)return!1;var e,t=this.getEngine();if(!t.areAllEffectsReady())return!1;if(this._pendingData.length>0)return!1;for(e=0;e<this.meshes.length;e++){var i=this.meshes[e];if(i.isEnabled()&&(i.subMeshes&&0!==i.subMeshes.length)){if(!i.isReady(!0))return!1;for(var r=i.hasThinInstances||"InstancedMesh"===i.getClassName()||"InstancedLinesMesh"===i.getClassName()||t.getCaps().instancedArrays&&i.instances.length>0,n=0,o=this._isReadyForMeshStage;n<o.length;n++){if(!o[n].action(i,r))return!1}}}for(e=0;e<this.geometries.length;e++){if(2===this.geometries[e].delayLoadState)return!1}if(this.activeCameras&&this.activeCameras.length>0)for(var s=0,a=this.activeCameras;s<a.length;s++){if(!a[s].isReady(!0))return!1}else if(this.activeCamera&&!this.activeCamera.isReady(!0))return!1;for(var h=0,u=this.particleSystems;h<u.length;h++){if(!u[h].isReady())return!1}return!0},r.prototype.resetCachedMaterial=function(){this._cachedMaterial=null,this._cachedEffect=null,this._cachedVisibility=null},r.prototype.registerBeforeRender=function(e){this.onBeforeRenderObservable.add(e)},r.prototype.unregisterBeforeRender=function(e){this.onBeforeRenderObservable.removeCallback(e)},r.prototype.registerAfterRender=function(e){this.onAfterRenderObservable.add(e)},r.prototype.unregisterAfterRender=function(e){this.onAfterRenderObservable.removeCallback(e)},r.prototype._executeOnceBeforeRender=function(e){var t=this,i=function(){e(),setTimeout((function(){t.unregisterBeforeRender(i)}))};this.registerBeforeRender(i)},r.prototype.executeOnceBeforeRender=function(e,t){var i=this;void 0!==t?setTimeout((function(){i._executeOnceBeforeRender(e)}),t):this._executeOnceBeforeRender(e)},r.prototype._addPendingData=function(e){this._pendingData.push(e)},r.prototype._removePendingData=function(e){var t=this.isLoading,i=this._pendingData.indexOf(e);-1!==i&&this._pendingData.splice(i,1),t&&!this.isLoading&&this.onDataLoadedObservable.notifyObservers(this)},r.prototype.getWaitingItemsCount=function(){return this._pendingData.length},Object.defineProperty(r.prototype,"isLoading",{get:function(){return this._pendingData.length>0},enumerable:!1,configurable:!0}),r.prototype.executeWhenReady=function(e){var t=this;this.onReadyObservable.add(e),-1===this._executeWhenReadyTimeoutId&&(this._executeWhenReadyTimeoutId=setTimeout((function(){t._checkIsReady()}),150))},r.prototype.whenReadyAsync=function(){var e=this;return new Promise((function(t){e.executeWhenReady((function(){t()}))}))},r.prototype._checkIsReady=function(){var e=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(){e._checkIsReady()}),150))},Object.defineProperty(r.prototype,"animatables",{get:function(){return this._activeAnimatables},enumerable:!1,configurable:!0}),r.prototype.resetLastAnimationTimeFrame=function(){this._animationTimeLast=Fe.Now},r.prototype.getViewMatrix=function(){return this._viewMatrix},r.prototype.getProjectionMatrix=function(){return this._projectionMatrix},r.prototype.getTransformMatrix=function(){return this._transformMatrix},r.prototype.setTransformMatrix=function(e,t,i,r){this._viewUpdateFlag===e.updateFlag&&this._projectionUpdateFlag===t.updateFlag||(this._viewUpdateFlag=e.updateFlag,this._projectionUpdateFlag=t.updateFlag,this._viewMatrix=e,this._projectionMatrix=t,this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._frustumPlanes?gi.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=gi.GetPlanes(this._transformMatrix),this._multiviewSceneUbo&&this._multiviewSceneUbo.useUbo?this._updateMultiviewUbo(i,r):this._sceneUbo.useUbo&&(this._sceneUbo.updateMatrix("viewProjection",this._transformMatrix),this._sceneUbo.updateMatrix("view",this._viewMatrix),this._sceneUbo.update()))},r.prototype.getSceneUniformBuffer=function(){return this._multiviewSceneUbo?this._multiviewSceneUbo:this._sceneUbo},r.prototype.getUniqueId=function(){return Wi.UniqueId},r.prototype.addMesh=function(e,t){var i=this;void 0===t&&(t=!1),this._blockEntityCollection||(this.meshes.push(e),e._resyncLightSources(),e.parent||e._addToSceneRootNodes(),this.onNewMeshAddedObservable.notifyObservers(e),t&&e.getChildMeshes().forEach((function(e){i.addMesh(e)})))},r.prototype.removeMesh=function(e,t){var i=this;void 0===t&&(t=!1);var r=this.meshes.indexOf(e);return-1!==r&&(this.meshes[r]=this.meshes[this.meshes.length-1],this.meshes.pop(),e.parent||e._removeFromSceneRootNodes()),this.onMeshRemovedObservable.notifyObservers(e),t&&e.getChildMeshes().forEach((function(e){i.removeMesh(e)})),r},r.prototype.addTransformNode=function(e){this._blockEntityCollection||(e._indexInSceneTransformNodesArray=this.transformNodes.length,this.transformNodes.push(e),e.parent||e._addToSceneRootNodes(),this.onNewTransformNodeAddedObservable.notifyObservers(e))},r.prototype.removeTransformNode=function(e){var t=e._indexInSceneTransformNodesArray;if(-1!==t){if(t!==this.transformNodes.length-1){var i=this.transformNodes[this.transformNodes.length-1];this.transformNodes[t]=i,i._indexInSceneTransformNodesArray=t}e._indexInSceneTransformNodesArray=-1,this.transformNodes.pop(),e.parent||e._removeFromSceneRootNodes()}return this.onTransformNodeRemovedObservable.notifyObservers(e),t},r.prototype.removeSkeleton=function(e){var t=this.skeletons.indexOf(e);return-1!==t&&(this.skeletons.splice(t,1),this.onSkeletonRemovedObservable.notifyObservers(e)),t},r.prototype.removeMorphTargetManager=function(e){var t=this.morphTargetManagers.indexOf(e);return-1!==t&&this.morphTargetManagers.splice(t,1),t},r.prototype.removeLight=function(e){var t=this.lights.indexOf(e);if(-1!==t){for(var i=0,r=this.meshes;i<r.length;i++){r[i]._removeLightSource(e,!1)}this.lights.splice(t,1),this.sortLightsByPriority(),e.parent||e._removeFromSceneRootNodes()}return this.onLightRemovedObservable.notifyObservers(e),t},r.prototype.removeCamera=function(e){var t=this.cameras.indexOf(e);if(-1!==t&&(this.cameras.splice(t,1),e.parent||e._removeFromSceneRootNodes()),this.activeCameras){var i=this.activeCameras.indexOf(e);-1!==i&&this.activeCameras.splice(i,1)}return this.activeCamera===e&&(this.cameras.length>0?this.activeCamera=this.cameras[0]:this.activeCamera=null),this.onCameraRemovedObservable.notifyObservers(e),t},r.prototype.removeParticleSystem=function(e){var t=this.particleSystems.indexOf(e);return-1!==t&&this.particleSystems.splice(t,1),t},r.prototype.removeAnimation=function(e){var t=this.animations.indexOf(e);return-1!==t&&this.animations.splice(t,1),t},r.prototype.stopAnimation=function(e,t,i){},r.prototype.removeAnimationGroup=function(e){var t=this.animationGroups.indexOf(e);return-1!==t&&this.animationGroups.splice(t,1),t},r.prototype.removeMultiMaterial=function(e){var t=this.multiMaterials.indexOf(e);return-1!==t&&this.multiMaterials.splice(t,1),this.onMultiMaterialRemovedObservable.notifyObservers(e),t},r.prototype.removeMaterial=function(e){var t=e._indexInSceneMaterialArray;if(-1!==t&&t<this.materials.length){if(t!==this.materials.length-1){var i=this.materials[this.materials.length-1];this.materials[t]=i,i._indexInSceneMaterialArray=t}e._indexInSceneMaterialArray=-1,this.materials.pop()}return this.onMaterialRemovedObservable.notifyObservers(e),t},r.prototype.removeActionManager=function(e){var t=this.actionManagers.indexOf(e);return-1!==t&&this.actionManagers.splice(t,1),t},r.prototype.removeTexture=function(e){var t=this.textures.indexOf(e);return-1!==t&&this.textures.splice(t,1),this.onTextureRemovedObservable.notifyObservers(e),t},r.prototype.addLight=function(e){if(!this._blockEntityCollection){this.lights.push(e),this.sortLightsByPriority(),e.parent||e._addToSceneRootNodes();for(var t=0,i=this.meshes;t<i.length;t++){var r=i[t];-1===r.lightSources.indexOf(e)&&(r.lightSources.push(e),r._resyncLightSources())}this.onNewLightAddedObservable.notifyObservers(e)}},r.prototype.sortLightsByPriority=function(){this.requireLightSorting&&this.lights.sort(Li.CompareLightsPriority)},r.prototype.addCamera=function(e){this._blockEntityCollection||(this.cameras.push(e),this.onNewCameraAddedObservable.notifyObservers(e),e.parent||e._addToSceneRootNodes())},r.prototype.addSkeleton=function(e){this._blockEntityCollection||(this.skeletons.push(e),this.onNewSkeletonAddedObservable.notifyObservers(e))},r.prototype.addParticleSystem=function(e){this._blockEntityCollection||this.particleSystems.push(e)},r.prototype.addAnimation=function(e){this._blockEntityCollection||this.animations.push(e)},r.prototype.addAnimationGroup=function(e){this._blockEntityCollection||this.animationGroups.push(e)},r.prototype.addMultiMaterial=function(e){this._blockEntityCollection||(this.multiMaterials.push(e),this.onNewMultiMaterialAddedObservable.notifyObservers(e))},r.prototype.addMaterial=function(e){this._blockEntityCollection||(e._indexInSceneMaterialArray=this.materials.length,this.materials.push(e),this.onNewMaterialAddedObservable.notifyObservers(e))},r.prototype.addMorphTargetManager=function(e){this._blockEntityCollection||this.morphTargetManagers.push(e)},r.prototype.addGeometry=function(e){this._blockEntityCollection||(this.geometriesByUniqueId&&(this.geometriesByUniqueId[e.uniqueId]=this.geometries.length),this.geometries.push(e))},r.prototype.addActionManager=function(e){this.actionManagers.push(e)},r.prototype.addTexture=function(e){this._blockEntityCollection||(this.textures.push(e),this.onNewTextureAddedObservable.notifyObservers(e))},r.prototype.switchActiveCamera=function(e,t){void 0===t&&(t=!0),this._engine.getInputElement()&&(this.activeCamera&&this.activeCamera.detachControl(),this.activeCamera=e,t&&e.attachControl())},r.prototype.setActiveCameraByID=function(e){var t=this.getCameraByID(e);return t?(this.activeCamera=t,t):null},r.prototype.setActiveCameraByName=function(e){var t=this.getCameraByName(e);return t?(this.activeCamera=t,t):null},r.prototype.getAnimationGroupByName=function(e){for(var t=0;t<this.animationGroups.length;t++)if(this.animationGroups[t].name===e)return this.animationGroups[t];return null},r.prototype.getMaterialByUniqueID=function(e){for(var t=0;t<this.materials.length;t++)if(this.materials[t].uniqueId===e)return this.materials[t];return null},r.prototype.getMaterialByID=function(e){for(var t=0;t<this.materials.length;t++)if(this.materials[t].id===e)return this.materials[t];return null},r.prototype.getLastMaterialByID=function(e){for(var t=this.materials.length-1;t>=0;t--)if(this.materials[t].id===e)return this.materials[t];return null},r.prototype.getMaterialByName=function(e){for(var t=0;t<this.materials.length;t++)if(this.materials[t].name===e)return this.materials[t];return null},r.prototype.getTextureByUniqueID=function(e){for(var t=0;t<this.textures.length;t++)if(this.textures[t].uniqueId===e)return this.textures[t];return null},r.prototype.getCameraByID=function(e){for(var t=0;t<this.cameras.length;t++)if(this.cameras[t].id===e)return this.cameras[t];return null},r.prototype.getCameraByUniqueID=function(e){for(var t=0;t<this.cameras.length;t++)if(this.cameras[t].uniqueId===e)return this.cameras[t];return null},r.prototype.getCameraByName=function(e){for(var t=0;t<this.cameras.length;t++)if(this.cameras[t].name===e)return this.cameras[t];return null},r.prototype.getBoneByID=function(e){for(var t=0;t<this.skeletons.length;t++)for(var i=this.skeletons[t],r=0;r<i.bones.length;r++)if(i.bones[r].id===e)return i.bones[r];return null},r.prototype.getBoneByName=function(e){for(var t=0;t<this.skeletons.length;t++)for(var i=this.skeletons[t],r=0;r<i.bones.length;r++)if(i.bones[r].name===e)return i.bones[r];return null},r.prototype.getLightByName=function(e){for(var t=0;t<this.lights.length;t++)if(this.lights[t].name===e)return this.lights[t];return null},r.prototype.getLightByID=function(e){for(var t=0;t<this.lights.length;t++)if(this.lights[t].id===e)return this.lights[t];return null},r.prototype.getLightByUniqueID=function(e){for(var t=0;t<this.lights.length;t++)if(this.lights[t].uniqueId===e)return this.lights[t];return null},r.prototype.getParticleSystemByID=function(e){for(var t=0;t<this.particleSystems.length;t++)if(this.particleSystems[t].id===e)return this.particleSystems[t];return null},r.prototype.getGeometryByID=function(e){for(var t=0;t<this.geometries.length;t++)if(this.geometries[t].id===e)return this.geometries[t];return null},r.prototype._getGeometryByUniqueID=function(e){if(this.geometriesByUniqueId){var t=this.geometriesByUniqueId[e];if(void 0!==t)return this.geometries[t]}else for(var i=0;i<this.geometries.length;i++)if(this.geometries[i].uniqueId===e)return this.geometries[i];return null},r.prototype.pushGeometry=function(e,t){return!(!t&&this._getGeometryByUniqueID(e.uniqueId))&&(this.addGeometry(e),this.onNewGeometryAddedObservable.notifyObservers(e),!0)},r.prototype.removeGeometry=function(e){var t;if(this.geometriesByUniqueId){if(void 0===(t=this.geometriesByUniqueId[e.uniqueId]))return!1}else if((t=this.geometries.indexOf(e))<0)return!1;if(t!==this.geometries.length-1){var i=this.geometries[this.geometries.length-1];i&&(this.geometries[t]=i,this.geometriesByUniqueId&&(this.geometriesByUniqueId[i.uniqueId]=t,this.geometriesByUniqueId[e.uniqueId]=void 0))}return this.geometries.pop(),this.onGeometryRemovedObservable.notifyObservers(e),!0},r.prototype.getGeometries=function(){return this.geometries},r.prototype.getMeshByID=function(e){for(var t=0;t<this.meshes.length;t++)if(this.meshes[t].id===e)return this.meshes[t];return null},r.prototype.getMeshesByID=function(e){return this.meshes.filter((function(t){return t.id===e}))},r.prototype.getTransformNodeByID=function(e){for(var t=0;t<this.transformNodes.length;t++)if(this.transformNodes[t].id===e)return this.transformNodes[t];return null},r.prototype.getTransformNodeByUniqueID=function(e){for(var t=0;t<this.transformNodes.length;t++)if(this.transformNodes[t].uniqueId===e)return this.transformNodes[t];return null},r.prototype.getTransformNodesByID=function(e){return this.transformNodes.filter((function(t){return t.id===e}))},r.prototype.getMeshByUniqueID=function(e){for(var t=0;t<this.meshes.length;t++)if(this.meshes[t].uniqueId===e)return this.meshes[t];return null},r.prototype.getLastMeshByID=function(e){for(var t=this.meshes.length-1;t>=0;t--)if(this.meshes[t].id===e)return this.meshes[t];return null},r.prototype.getLastEntryByID=function(e){var t;for(t=this.meshes.length-1;t>=0;t--)if(this.meshes[t].id===e)return this.meshes[t];for(t=this.transformNodes.length-1;t>=0;t--)if(this.transformNodes[t].id===e)return this.transformNodes[t];for(t=this.cameras.length-1;t>=0;t--)if(this.cameras[t].id===e)return this.cameras[t];for(t=this.lights.length-1;t>=0;t--)if(this.lights[t].id===e)return this.lights[t];return null},r.prototype.getNodeByID=function(e){var t=this.getMeshByID(e);if(t)return t;var i=this.getTransformNodeByID(e);if(i)return i;var r=this.getLightByID(e);if(r)return r;var n=this.getCameraByID(e);if(n)return n;var o=this.getBoneByID(e);return o||null},r.prototype.getNodeByName=function(e){var t=this.getMeshByName(e);if(t)return t;var i=this.getTransformNodeByName(e);if(i)return i;var r=this.getLightByName(e);if(r)return r;var n=this.getCameraByName(e);if(n)return n;var o=this.getBoneByName(e);return o||null},r.prototype.getMeshByName=function(e){for(var t=0;t<this.meshes.length;t++)if(this.meshes[t].name===e)return this.meshes[t];return null},r.prototype.getTransformNodeByName=function(e){for(var t=0;t<this.transformNodes.length;t++)if(this.transformNodes[t].name===e)return this.transformNodes[t];return null},r.prototype.getLastSkeletonByID=function(e){for(var t=this.skeletons.length-1;t>=0;t--)if(this.skeletons[t].id===e)return this.skeletons[t];return null},r.prototype.getSkeletonByUniqueId=function(e){for(var t=0;t<this.skeletons.length;t++)if(this.skeletons[t].uniqueId===e)return this.skeletons[t];return null},r.prototype.getSkeletonById=function(e){for(var t=0;t<this.skeletons.length;t++)if(this.skeletons[t].id===e)return this.skeletons[t];return null},r.prototype.getSkeletonByName=function(e){for(var t=0;t<this.skeletons.length;t++)if(this.skeletons[t].name===e)return this.skeletons[t];return null},r.prototype.getMorphTargetManagerById=function(e){for(var t=0;t<this.morphTargetManagers.length;t++)if(this.morphTargetManagers[t].uniqueId===e)return this.morphTargetManagers[t];return null},r.prototype.getMorphTargetById=function(e){for(var t=0;t<this.morphTargetManagers.length;++t)for(var i=this.morphTargetManagers[t],r=0;r<i.numTargets;++r){var n=i.getTarget(r);if(n.id===e)return n}return null},r.prototype.getMorphTargetByName=function(e){for(var t=0;t<this.morphTargetManagers.length;++t)for(var i=this.morphTargetManagers[t],r=0;r<i.numTargets;++r){var n=i.getTarget(r);if(n.name===e)return n}return null},r.prototype.getPostProcessByName=function(e){for(var t=0;t<this.postProcesses.length;++t){var i=this.postProcesses[t];if(i.name===e)return i}return null},r.prototype.isActiveMesh=function(e){return-1!==this._activeMeshes.indexOf(e)},Object.defineProperty(r.prototype,"uid",{get:function(){return this._uid||(this._uid=Ue.RandomId()),this._uid},enumerable:!1,configurable:!0}),r.prototype.addExternalData=function(e,t){return this._externalData||(this._externalData=new Ii),this._externalData.add(e,t)},r.prototype.getExternalData=function(e){return this._externalData?this._externalData.get(e):null},r.prototype.getOrAddExternalDataWithFactory=function(e,t){return this._externalData||(this._externalData=new Ii),this._externalData.getOrAddWithFactory(e,t)},r.prototype.removeExternalData=function(e){return this._externalData.remove(e)},r.prototype._evaluateSubMesh=function(e,t,i){if(i.hasInstances||i.isAnInstance||this.dispatchAllSubMeshesOfActiveMeshes||this._skipFrustumClipping||t.alwaysSelectAsActiveMesh||1===t.subMeshes.length||e.isInFrustum(this._frustumPlanes)){for(var r=0,n=this._evaluateSubMeshStage;r<n.length;r++){n[r].action(t,e)}var o=e.getMaterial();null!=o&&(o.hasRenderTargetTextures&&null!=o.getRenderTargetTextures&&-1===this._processedMaterials.indexOf(o)&&(this._processedMaterials.push(o),this._renderTargets.concatWithNoDuplicate(o.getRenderTargetTextures())),this._renderingManager.dispatch(e,t,o))}},r.prototype.freeProcessedMaterials=function(){this._processedMaterials.dispose()},Object.defineProperty(r.prototype,"blockfreeActiveMeshesAndRenderingGroups",{get:function(){return this._preventFreeActiveMeshesAndRenderingGroups},set:function(e){this._preventFreeActiveMeshesAndRenderingGroups!==e&&(e&&(this.freeActiveMeshes(),this.freeRenderingGroups()),this._preventFreeActiveMeshesAndRenderingGroups=e)},enumerable:!1,configurable:!0}),r.prototype.freeActiveMeshes=function(){if(!this.blockfreeActiveMeshesAndRenderingGroups&&(this._activeMeshes.dispose(),this.activeCamera&&this.activeCamera._activeMeshes&&this.activeCamera._activeMeshes.dispose(),this.activeCameras))for(var e=0;e<this.activeCameras.length;e++){var t=this.activeCameras[e];t&&t._activeMeshes&&t._activeMeshes.dispose()}},r.prototype.freeRenderingGroups=function(){if(!this.blockfreeActiveMeshesAndRenderingGroups&&(this._renderingManager&&this._renderingManager.freeRenderingGroups(),this.textures))for(var e=0;e<this.textures.length;e++){var t=this.textures[e];t&&t.renderList&&t.freeRenderingGroups()}},r.prototype._isInIntermediateRendering=function(){return this._intermediateRendering},r.prototype.freezeActiveMeshes=function(e,t,i){var r=this;return void 0===e&&(e=!1),this.executeWhenReady((function(){if(r.activeCamera){r._frustumPlanes||r.setTransformMatrix(r.activeCamera.getViewMatrix(),r.activeCamera.getProjectionMatrix()),r._evaluateActiveMeshes(),r._activeMeshesFrozen=!0,r._skipEvaluateActiveMeshesCompletely=e;for(var n=0;n<r._activeMeshes.length;n++)r._activeMeshes.data[n]._freeze();t&&t()}else i&&i("No active camera found")})),this},r.prototype.unfreezeActiveMeshes=function(){for(var e=0;e<this.meshes.length;e++){var t=this.meshes[e];t._internalAbstractMeshDataInfo&&(t._internalAbstractMeshDataInfo._isActive=!1)}for(e=0;e<this._activeMeshes.length;e++)this._activeMeshes.data[e]._unFreeze();return this._activeMeshesFrozen=!1,this},r.prototype._evaluateActiveMeshes=function(){if(this._activeMeshesFrozen&&this._activeMeshes.length){if(!this._skipEvaluateActiveMeshesCompletely)for(var e=this._activeMeshes.length,t=0;t<e;t++){(a=this._activeMeshes.data[t]).computeWorldMatrix()}if(this._activeParticleSystems){var i=this._activeParticleSystems.length;for(t=0;t<i;t++)this._activeParticleSystems.data[t].animate()}}else if(this.activeCamera){this.onBeforeActiveMeshesEvaluationObservable.notifyObservers(this),this.activeCamera._activeMeshes.reset(),this._activeMeshes.reset(),this._renderingManager.reset(),this._processedMaterials.reset(),this._activeParticleSystems.reset(),this._activeSkeletons.reset(),this._softwareSkinnedMeshes.reset();for(var r=0,n=this._beforeEvaluateActiveMeshStage;r<n.length;r++){n[r].action()}var o=this.getActiveMeshCandidates(),s=o.length;for(t=0;t<s;t++){var a;if((a=o.data[t])._internalAbstractMeshDataInfo._currentLODIsUpToDate=!1,!a.isBlocked&&(this._totalVertices.addCount(a.getTotalVertices(),!1),a.isReady()&&a.isEnabled()&&0!==a.scaling.lengthSquared())){a.computeWorldMatrix(),a.actionManager&&a.actionManager.hasSpecificTriggers2(12,13)&&this._meshesForIntersections.pushNoDuplicate(a);var h=this.customLODSelector?this.customLODSelector(a,this.activeCamera):a.getLOD(this.activeCamera);if(a._internalAbstractMeshDataInfo._currentLOD=h,a._internalAbstractMeshDataInfo._currentLODIsUpToDate=!0,null!=h&&(h!==a&&h.billboardMode!==wt.BILLBOARDMODE_NONE&&h.computeWorldMatrix(),a._preActivate(),a.isVisible&&a.visibility>0&&0!=(a.layerMask&this.activeCamera.layerMask)&&(this._skipFrustumClipping||a.alwaysSelectAsActiveMesh||a.isInFrustum(this._frustumPlanes)))){this._activeMeshes.push(a),this.activeCamera._activeMeshes.push(a),h!==a&&h._activate(this._renderId,!1);for(var u=0,l=this._preActiveMeshStage;u<l.length;u++){l[u].action(a)}a._activate(this._renderId,!1)&&(a.isAnInstance?a._internalAbstractMeshDataInfo._actAsRegularMesh&&(h=a):h._internalAbstractMeshDataInfo._onlyForInstances=!1,h._internalAbstractMeshDataInfo._isActive=!0,this._activeMesh(a,h)),a._postActivate()}}}if(this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this),this.particlesEnabled){this.onBeforeParticlesRenderingObservable.notifyObservers(this);for(var c=0;c<this.particleSystems.length;c++){var f=this.particleSystems[c];if(f.isStarted()&&f.emitter){var d=f.emitter;d.position&&!d.isEnabled()||(this._activeParticleSystems.push(f),f.animate(),this._renderingManager.dispatchParticles(f))}}this.onAfterParticlesRenderingObservable.notifyObservers(this)}}},r.prototype._activeMesh=function(e,t){if(this._skeletonsEnabled&&null!==t.skeleton&&void 0!==t.skeleton&&(this._activeSkeletons.pushNoDuplicate(t.skeleton)&&t.skeleton.prepare(),t.computeBonesUsingShaders||this._softwareSkinnedMeshes.pushNoDuplicate(t)),null!=t&&void 0!==t.subMeshes&&null!==t.subMeshes&&t.subMeshes.length>0)for(var i=this.getActiveSubMeshCandidates(t),r=i.length,n=0;n<r;n++){var o=i.data[n];this._evaluateSubMesh(o,t,e)}},r.prototype.updateTransformMatrix=function(e){this.activeCamera&&this.setTransformMatrix(this.activeCamera.getViewMatrix(),this.activeCamera.getProjectionMatrix(e))},r.prototype._bindFrameBuffer=function(){if(this.activeCamera&&this.activeCamera._multiviewTexture)this.activeCamera._multiviewTexture._bindFrameBuffer();else if(this.activeCamera&&this.activeCamera.outputRenderTarget){if(this.getEngine().getCaps().multiview&&this.activeCamera.outputRenderTarget&&this.activeCamera.outputRenderTarget.getViewCount()>1)this.activeCamera.outputRenderTarget._bindFrameBuffer();else{var e=this.activeCamera.outputRenderTarget.getInternalTexture();e?this.getEngine().bindFramebuffer(e):q.Error("Camera contains invalid customDefaultRenderTarget")}}else this.getEngine().restoreDefaultFramebuffer()},r.prototype._renderForCamera=function(e,t){if(!e||!e._skipRendering){var i=this._engine;if(this._activeCamera=e,!this.activeCamera)throw new Error("Active camera not set");i.setViewport(this.activeCamera.viewport),this.resetCachedMaterial(),this._renderId++,this.getEngine().getCaps().multiview&&e.outputRenderTarget&&e.outputRenderTarget.getViewCount()>1?this.setTransformMatrix(e._rigCameras[0].getViewMatrix(),e._rigCameras[0].getProjectionMatrix(),e._rigCameras[1].getViewMatrix(),e._rigCameras[1].getProjectionMatrix()):this.updateTransformMatrix(),this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera),this._evaluateActiveMeshes();for(var r=0;r<this._softwareSkinnedMeshes.length;r++){var n=this._softwareSkinnedMeshes.data[r];n.applySkeleton(n.skeleton)}this.onBeforeRenderTargetsRenderObservable.notifyObservers(this),e.customRenderTargets&&e.customRenderTargets.length>0&&this._renderTargets.concatWithNoDuplicate(e.customRenderTargets),t&&t.customRenderTargets&&t.customRenderTargets.length>0&&this._renderTargets.concatWithNoDuplicate(t.customRenderTargets);for(var o=0,s=this._gatherActiveCameraRenderTargetsStage;o<s.length;o++){s[o].action(this._renderTargets)}var a=!1;if(this.renderTargetsEnabled){if(this._intermediateRendering=!0,this._renderTargets.length>0){Ue.StartPerformanceCounter("Render targets",this._renderTargets.length>0);for(var h=0;h<this._renderTargets.length;h++){var u=this._renderTargets.data[h];if(u._shouldRender()){this._renderId++;var l=u.activeCamera&&u.activeCamera!==this.activeCamera;u.render(l,this.dumpNextRenderTargets),a=!0}}Ue.EndPerformanceCounter("Render targets",this._renderTargets.length>0),this._renderId++}for(var c=0,f=this._cameraDrawRenderTargetStage;c<f.length;c++){a=f[c].action(this.activeCamera)||a}this._intermediateRendering=!1,this.activeCamera&&this.activeCamera.outputRenderTarget&&(a=!0)}a&&!this.prePass&&this._bindFrameBuffer(),this.onAfterRenderTargetsRenderObservable.notifyObservers(this),!this.postProcessManager||e._multiviewTexture||this.prePass||this.postProcessManager._prepareFrame();for(var d=0,p=this._beforeCameraDrawStage;d<p.length;d++){p[d].action(this.activeCamera)}this.onBeforeDrawPhaseObservable.notifyObservers(this),this._renderingManager.render(null,null,!0,!0),this.onAfterDrawPhaseObservable.notifyObservers(this);for(var _=0,g=this._afterCameraDrawStage;_<g.length;_++){g[_].action(this.activeCamera)}if(this.postProcessManager&&!e._multiviewTexture){var m=e.outputRenderTarget?e.outputRenderTarget.getInternalTexture():void 0;this.postProcessManager._finalizeFrame(e.isIntermediate,m)}this._renderTargets.reset(),this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera)}},r.prototype._processSubCameras=function(e){if(e.cameraRigMode===mi.RIG_MODE_NONE||e.outputRenderTarget&&e.outputRenderTarget.getViewCount()>1&&this.getEngine().getCaps().multiview)return this._renderForCamera(e),void this.onAfterRenderCameraObservable.notifyObservers(e);if(e._useMultiviewToSingleView)this._renderMultiviewToSingleView(e);else for(var t=0;t<e._rigCameras.length;t++)this._renderForCamera(e._rigCameras[t],e);this._activeCamera=e,this.setTransformMatrix(this._activeCamera.getViewMatrix(),this._activeCamera.getProjectionMatrix()),this.onAfterRenderCameraObservable.notifyObservers(e)},r.prototype._checkIntersections=function(){for(var e=0;e<this._meshesForIntersections.length;e++){var t=this._meshesForIntersections.data[e];if(t.actionManager)for(var i=0;t.actionManager&&i<t.actionManager.actions.length;i++){var r=t.actionManager.actions[i];if(12===r.trigger||13===r.trigger){var n=r.getTriggerParameter(),o=n instanceof kt?n:n.mesh,s=o.intersectsMesh(t,n.usePreciseIntersection),a=t._intersectionsInProgress.indexOf(o);s&&-1===a?12===r.trigger?(r._executeCurrent(Xe.CreateNew(t,void 0,o)),t._intersectionsInProgress.push(o)):13===r.trigger&&t._intersectionsInProgress.push(o):!s&&a>-1&&(13===r.trigger&&r._executeCurrent(Xe.CreateNew(t,void 0,o)),t.actionManager.hasSpecificTrigger(13,(function(e){var t=e instanceof kt?e:e.mesh;return o===t}))&&13!==r.trigger||t._intersectionsInProgress.splice(a,1))}}}},r.prototype._advancePhysicsEngineStep=function(e){},r.prototype._animate=function(){},r.prototype.animate=function(){if(this._engine.isDeterministicLockStep()){var e=Math.max(r.MinDeltaTime,Math.min(this._engine.getDeltaTime(),r.MaxDeltaTime))+this._timeAccumulator,t=this._engine.getTimeStep(),i=1e3/t/1e3,n=0,o=this._engine.getLockstepMaxSteps(),s=Math.floor(e/t);for(s=Math.min(s,o);e>0&&n<s;)this.onBeforeStepObservable.notifyObservers(this),this._animationRatio=t*i,this._animate(),this.onAfterAnimationsObservable.notifyObservers(this),this.physicsEnabled&&this._advancePhysicsEngineStep(t),this.onAfterStepObservable.notifyObservers(this),this._currentStepId++,n++,e-=t;this._timeAccumulator=e<0?0:e}else{e=this.useConstantAnimationDeltaTime?16:Math.max(r.MinDeltaTime,Math.min(this._engine.getDeltaTime(),r.MaxDeltaTime));this._animationRatio=.06*e,this._animate(),this.onAfterAnimationsObservable.notifyObservers(this),this.physicsEnabled&&this._advancePhysicsEngineStep(e)}},r.prototype.render=function(e,t){if(void 0===e&&(e=!0),void 0===t&&(t=!1),!this.isDisposed){this.onReadyObservable.hasObservers()&&-1===this._executeWhenReadyTimeoutId&&this._checkIsReady(),this._frameId++,this._registerTransientComponents(),this._activeParticles.fetchNewFrame(),this._totalVertices.fetchNewFrame(),this._activeIndices.fetchNewFrame(),this._activeBones.fetchNewFrame(),this._meshesForIntersections.reset(),this.resetCachedMaterial(),this.onBeforeAnimationsObservable.notifyObservers(this),this.actionManager&&this.actionManager.processTrigger(11),t||this.animate();for(var i=0,r=this._beforeCameraUpdateStage;i<r.length;i++){r[i].action()}if(e)if(this.activeCameras&&this.activeCameras.length>0)for(var n=0;n<this.activeCameras.length;n++){var o=this.activeCameras[n];if(o.update(),o.cameraRigMode!==mi.RIG_MODE_NONE)for(var s=0;s<o._rigCameras.length;s++)o._rigCameras[s].update()}else if(this.activeCamera&&(this.activeCamera.update(),this.activeCamera.cameraRigMode!==mi.RIG_MODE_NONE))for(s=0;s<this.activeCamera._rigCameras.length;s++)this.activeCamera._rigCameras[s].update();this.onBeforeRenderObservable.notifyObservers(this),this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);var a=this.getEngine(),h=this.activeCamera;if(this.renderTargetsEnabled){Ue.StartPerformanceCounter("Custom render targets",this.customRenderTargets.length>0),this._intermediateRendering=!0;for(var u=0;u<this.customRenderTargets.length;u++){var l=this.customRenderTargets[u];if(l._shouldRender()){if(this._renderId++,this.activeCamera=l.activeCamera||this.activeCamera,!this.activeCamera)throw new Error("Active camera not set");a.setViewport(this.activeCamera.viewport),this.updateTransformMatrix(),l.render(h!==this.activeCamera,this.dumpNextRenderTargets)}}Ue.EndPerformanceCounter("Custom render targets",this.customRenderTargets.length>0),this._intermediateRendering=!1,this._renderId++}this.activeCamera=h,this._activeCamera&&this._activeCamera.cameraRigMode!==mi.RIG_MODE_CUSTOM&&!this.prePass&&this._bindFrameBuffer(),this.onAfterRenderTargetsRenderObservable.notifyObservers(this);for(var c=0,f=this._beforeClearStage;c<f.length;c++){f[c].action()}!this.autoClearDepthAndStencil&&!this.autoClear||this.prePass||this._engine.clear(this.clearColor,this.autoClear||this.forceWireframe||this.forcePointsCloud,this.autoClearDepthAndStencil,this.autoClearDepthAndStencil);for(var d=0,p=this._gatherRenderTargetsStage;d<p.length;d++){p[d].action(this._renderTargets)}if(this.activeCameras&&this.activeCameras.length>0)for(n=0;n<this.activeCameras.length;n++)n>0&&this._engine.clear(null,!1,!0,!0),this._processSubCameras(this.activeCameras[n]);else{if(!this.activeCamera)throw new Error("No camera defined");this._processSubCameras(this.activeCamera)}this._checkIntersections();for(var _=0,g=this._afterRenderStage;_<g.length;_++){g[_].action()}if(this.afterRender&&this.afterRender(),this.onAfterRenderObservable.notifyObservers(this),this._toBeDisposed.length){for(s=0;s<this._toBeDisposed.length;s++){var m=this._toBeDisposed[s];m&&m.dispose()}this._toBeDisposed=[]}this.dumpNextRenderTargets&&(this.dumpNextRenderTargets=!1),this._activeBones.addCount(0,!0),this._activeIndices.addCount(0,!0),this._activeParticles.addCount(0,!0)}},r.prototype.freezeMaterials=function(){for(var e=0;e<this.materials.length;e++)this.materials[e].freeze()},r.prototype.unfreezeMaterials=function(){for(var e=0;e<this.materials.length;e++)this.materials[e].unfreeze()},r.prototype.dispose=function(){this.beforeRender=null,this.afterRender=null,V._LastCreatedScene===this&&(V._LastCreatedScene=null),this.skeletons=[],this.morphTargetManagers=[],this._transientComponents=[],this._isReadyForMeshStage.clear(),this._beforeEvaluateActiveMeshStage.clear(),this._evaluateSubMeshStage.clear(),this._preActiveMeshStage.clear(),this._cameraDrawRenderTargetStage.clear(),this._beforeCameraDrawStage.clear(),this._beforeRenderTargetDrawStage.clear(),this._beforeRenderingGroupDrawStage.clear(),this._beforeRenderingMeshStage.clear(),this._afterRenderingMeshStage.clear(),this._afterRenderingGroupDrawStage.clear(),this._afterCameraDrawStage.clear(),this._afterRenderTargetDrawStage.clear(),this._afterRenderStage.clear(),this._beforeCameraUpdateStage.clear(),this._beforeClearStage.clear(),this._gatherRenderTargetsStage.clear(),this._gatherActiveCameraRenderTargetsStage.clear(),this._pointerMoveStage.clear(),this._pointerDownStage.clear(),this._pointerUpStage.clear();for(var e=0,t=this._components;e<t.length;e++){t[e].dispose()}this.importedMeshesFiles=new Array,this.stopAllAnimations&&this.stopAllAnimations(),this.resetCachedMaterial(),this.activeCamera&&(this.activeCamera._activeMeshes.dispose(),this.activeCamera=null),this._activeMeshes.dispose(),this._renderingManager.dispose(),this._processedMaterials.dispose(),this._activeParticleSystems.dispose(),this._activeSkeletons.dispose(),this._softwareSkinnedMeshes.dispose(),this._renderTargets.dispose(),this._registeredForLateAnimationBindings.dispose(),this._meshesForIntersections.dispose(),this._toBeDisposed=[];for(var i=0,r=this._activeRequests;i<r.length;i++){r[i].abort()}var n;if(this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onBeforeRenderObservable.clear(),this.onAfterRenderObservable.clear(),this.onBeforeRenderTargetsRenderObservable.clear(),this.onAfterRenderTargetsRenderObservable.clear(),this.onAfterStepObservable.clear(),this.onBeforeStepObservable.clear(),this.onBeforeActiveMeshesEvaluationObservable.clear(),this.onAfterActiveMeshesEvaluationObservable.clear(),this.onBeforeParticlesRenderingObservable.clear(),this.onAfterParticlesRenderingObservable.clear(),this.onBeforeDrawPhaseObservable.clear(),this.onAfterDrawPhaseObservable.clear(),this.onBeforeAnimationsObservable.clear(),this.onAfterAnimationsObservable.clear(),this.onDataLoadedObservable.clear(),this.onBeforeRenderingGroupObservable.clear(),this.onAfterRenderingGroupObservable.clear(),this.onMeshImportedObservable.clear(),this.onBeforeCameraRenderObservable.clear(),this.onAfterCameraRenderObservable.clear(),this.onReadyObservable.clear(),this.onNewCameraAddedObservable.clear(),this.onCameraRemovedObservable.clear(),this.onNewLightAddedObservable.clear(),this.onLightRemovedObservable.clear(),this.onNewGeometryAddedObservable.clear(),this.onGeometryRemovedObservable.clear(),this.onNewTransformNodeAddedObservable.clear(),this.onTransformNodeRemovedObservable.clear(),this.onNewMeshAddedObservable.clear(),this.onMeshRemovedObservable.clear(),this.onNewSkeletonAddedObservable.clear(),this.onSkeletonRemovedObservable.clear(),this.onNewMaterialAddedObservable.clear(),this.onNewMultiMaterialAddedObservable.clear(),this.onMaterialRemovedObservable.clear(),this.onMultiMaterialRemovedObservable.clear(),this.onNewTextureAddedObservable.clear(),this.onTextureRemovedObservable.clear(),this.onPrePointerObservable.clear(),this.onPointerObservable.clear(),this.onPreKeyboardObservable.clear(),this.onKeyboardObservable.clear(),this.onActiveCameraChanged.clear(),this.detachControl(),this._engine.getInputElement())for(n=0;n<this.cameras.length;n++)this.cameras[n].detachControl();for(;this.animationGroups.length;)this.animationGroups[0].dispose();for(;this.lights.length;)this.lights[0].dispose();for(;this.meshes.length;)this.meshes[0].dispose(!0);for(;this.transformNodes.length;)this.transformNodes[0].dispose(!0);for(;this.cameras.length;)this.cameras[0].dispose();for(this._defaultMaterial&&this._defaultMaterial.dispose();this.multiMaterials.length;)this.multiMaterials[0].dispose();for(;this.materials.length;)this.materials[0].dispose();for(;this.particleSystems.length;)this.particleSystems[0].dispose();for(;this.postProcesses.length;)this.postProcesses[0].dispose();for(;this.textures.length;)this.textures[0].dispose();this._sceneUbo.dispose(),this._multiviewSceneUbo&&this._multiviewSceneUbo.dispose(),this.postProcessManager.dispose(),(n=this._engine.scenes.indexOf(this))>-1&&this._engine.scenes.splice(n,1),this._engine.wipeCaches(!0),this._isDisposed=!0},Object.defineProperty(r.prototype,"isDisposed",{get:function(){return this._isDisposed},enumerable:!1,configurable:!0}),r.prototype.clearCachedVertexData=function(){for(var e=0;e<this.meshes.length;e++){var t=this.meshes[e].geometry;if(t)for(var i in t._indices=[],t._vertexBuffers)t._vertexBuffers.hasOwnProperty(i)&&(t._vertexBuffers[i]._buffer._data=null)}},r.prototype.cleanCachedTextureBuffer=function(){for(var e=0,t=this.textures;e<t.length;e++){var i=t[e];i._buffer&&(i._buffer=null)}},r.prototype.getWorldExtends=function(e){var t=new p(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),i=new p(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);return e=e||function(){return!0},this.meshes.filter(e).forEach((function(e){if(e.computeWorldMatrix(!0),e.subMeshes&&0!==e.subMeshes.length&&!e.infiniteDistance){var r=e.getBoundingInfo(),n=r.boundingBox.minimumWorld,o=r.boundingBox.maximumWorld;p.CheckExtends(n,t,i),p.CheckExtends(o,t,i)}})),{min:t,max:i}},r.prototype.createPickingRay=function(e,t,i,r,n){throw b.WarnImport("Ray")},r.prototype.createPickingRayToRef=function(e,t,i,r,n,o){throw b.WarnImport("Ray")},r.prototype.createPickingRayInCameraSpace=function(e,t,i){throw b.WarnImport("Ray")},r.prototype.createPickingRayInCameraSpaceToRef=function(e,t,i,r){throw b.WarnImport("Ray")},r.prototype.pick=function(e,t,i,r,n,o){var s=new Lt;return s._pickingUnavailable=!0,s},r.prototype.pickWithBoundingInfo=function(e,t,i,r,n){var o=new Lt;return o._pickingUnavailable=!0,o},r.prototype.pickWithRay=function(e,t,i,r){throw b.WarnImport("Ray")},r.prototype.multiPick=function(e,t,i,r,n){throw b.WarnImport("Ray")},r.prototype.multiPickWithRay=function(e,t,i){throw b.WarnImport("Ray")},r.prototype.setPointerOverMesh=function(e,t){this._inputManager.setPointerOverMesh(e,t)},r.prototype.getPointerOverMesh=function(){return this._inputManager.getPointerOverMesh()},r.prototype._rebuildGeometries=function(){for(var e=0,t=this.geometries;e<t.length;e++){t[e]._rebuild()}for(var i=0,r=this.meshes;i<r.length;i++){r[i]._rebuild()}this.postProcessManager&&this.postProcessManager._rebuild();for(var n=0,o=this._components;n<o.length;n++){o[n].rebuild()}for(var s=0,a=this.particleSystems;s<a.length;s++){a[s].rebuild()}},r.prototype._rebuildTextures=function(){for(var e=0,t=this.textures;e<t.length;e++){t[e]._rebuild()}this.markAllMaterialsAsDirty(1)},r.prototype._getByTags=function(e,t,i){if(void 0===t)return e;var r=[];for(var n in i=i||function(e){},e){var s=e[n];o&&o.MatchesQuery(s,t)&&(r.push(s),i(s))}return r},r.prototype.getMeshesByTags=function(e,t){return this._getByTags(this.meshes,e,t)},r.prototype.getCamerasByTags=function(e,t){return this._getByTags(this.cameras,e,t)},r.prototype.getLightsByTags=function(e,t){return this._getByTags(this.lights,e,t)},r.prototype.getMaterialByTags=function(e,t){return this._getByTags(this.materials,e,t).concat(this._getByTags(this.multiMaterials,e,t))},r.prototype.getTransformNodesByTags=function(e,t){return this._getByTags(this.transformNodes,e,t)},r.prototype.setRenderingOrder=function(e,t,i,r){void 0===t&&(t=null),void 0===i&&(i=null),void 0===r&&(r=null),this._renderingManager.setRenderingOrder(e,t,i,r)},r.prototype.setRenderingAutoClearDepthStencil=function(e,t,i,r){void 0===i&&(i=!0),void 0===r&&(r=!0),this._renderingManager.setRenderingAutoClearDepthStencil(e,t,i,r)},r.prototype.getAutoClearDepthStencilSetup=function(e){return this._renderingManager.getAutoClearDepthStencilSetup(e)},Object.defineProperty(r.prototype,"blockMaterialDirtyMechanism",{get:function(){return this._blockMaterialDirtyMechanism},set:function(e){this._blockMaterialDirtyMechanism!==e&&(this._blockMaterialDirtyMechanism=e,e||this.markAllMaterialsAsDirty(63))},enumerable:!1,configurable:!0}),r.prototype.markAllMaterialsAsDirty=function(e,t){if(!this._blockMaterialDirtyMechanism)for(var i=0,r=this.materials;i<r.length;i++){var n=r[i];t&&!t(n)||n.markAsDirty(e)}},r.prototype._loadFile=function(e,t,i,r,n,o){var s=this,a=Ae.LoadFile(e,t,i,r?this.offlineProvider:void 0,n,o);return this._activeRequests.push(a),a.onCompleteObservable.add((function(e){s._activeRequests.splice(s._activeRequests.indexOf(e),1)})),a},r.prototype._loadFileAsync=function(e,t,i,r){var n=this;return new Promise((function(o,s){n._loadFile(e,(function(e){o(e)}),t,i,r,(function(e,t){s(t)}))}))},r.prototype._requestFile=function(e,t,i,r,n,o,s){var a=this,h=Ae.RequestFile(e,t,i,r?this.offlineProvider:void 0,n,o,s);return this._activeRequests.push(h),h.onCompleteObservable.add((function(e){a._activeRequests.splice(a._activeRequests.indexOf(e),1)})),h},r.prototype._requestFileAsync=function(e,t,i,r,n){var o=this;return new Promise((function(s,a){o._requestFile(e,(function(e){s(e)}),t,i,r,(function(e){a(e)}),n)}))},r.prototype._readFile=function(e,t,i,r,n){var o=this,s=Ae.ReadFile(e,t,i,r,n);return this._activeRequests.push(s),s.onCompleteObservable.add((function(e){o._activeRequests.splice(o._activeRequests.indexOf(e),1)})),s},r.prototype._readFileAsync=function(e,t,i){var r=this;return new Promise((function(n,o){r._readFile(e,(function(e){n(e)}),t,i,(function(e){o(e)}))}))},r.FOGMODE_NONE=0,r.FOGMODE_EXP=1,r.FOGMODE_EXP2=2,r.FOGMODE_LINEAR=3,r.MinDeltaTime=1,r.MaxDeltaTime=1e3,r}(Oi),Gi=function(){function e(e,t,i){void 0===i&&(i=Number.MAX_VALUE),this.origin=e,this.direction=t,this.length=i}return e.prototype.intersectsBoxMinMax=function(t,i,r){void 0===r&&(r=0);var n,o,s,a,h=e._TmpVector3[0].copyFromFloats(t.x-r,t.y-r,t.z-r),u=e._TmpVector3[1].copyFromFloats(i.x+r,i.y+r,i.z+r),l=0,c=Number.MAX_VALUE;if(Math.abs(this.direction.x)<1e-7){if(this.origin.x<h.x||this.origin.x>u.x)return!1}else if(n=1/this.direction.x,o=(h.x-this.origin.x)*n,(s=(u.x-this.origin.x)*n)===-1/0&&(s=1/0),o>s&&(a=o,o=s,s=a),(l=Math.max(o,l))>(c=Math.min(s,c)))return!1;if(Math.abs(this.direction.y)<1e-7){if(this.origin.y<h.y||this.origin.y>u.y)return!1}else if(n=1/this.direction.y,o=(h.y-this.origin.y)*n,(s=(u.y-this.origin.y)*n)===-1/0&&(s=1/0),o>s&&(a=o,o=s,s=a),(l=Math.max(o,l))>(c=Math.min(s,c)))return!1;if(Math.abs(this.direction.z)<1e-7){if(this.origin.z<h.z||this.origin.z>u.z)return!1}else if(n=1/this.direction.z,o=(h.z-this.origin.z)*n,(s=(u.z-this.origin.z)*n)===-1/0&&(s=1/0),o>s&&(a=o,o=s,s=a),(l=Math.max(o,l))>(c=Math.min(s,c)))return!1;return!0},e.prototype.intersectsBox=function(e,t){return void 0===t&&(t=0),this.intersectsBoxMinMax(e.minimum,e.maximum,t)},e.prototype.intersectsSphere=function(e,t){void 0===t&&(t=0);var i=e.center.x-this.origin.x,r=e.center.y-this.origin.y,n=e.center.z-this.origin.z,o=i*i+r*r+n*n,s=e.radius+t,a=s*s;if(o<=a)return!0;var h=i*this.direction.x+r*this.direction.y+n*this.direction.z;return!(h<0)&&o-h*h<=a},e.prototype.intersectsTriangle=function(t,i,r){var n=e._TmpVector3[0],o=e._TmpVector3[1],s=e._TmpVector3[2],a=e._TmpVector3[3],h=e._TmpVector3[4];i.subtractToRef(t,n),r.subtractToRef(t,o),p.CrossToRef(this.direction,o,s);var u=p.Dot(n,s);if(0===u)return null;var l=1/u;this.origin.subtractToRef(t,a);var c=p.Dot(a,s)*l;if(c<0||c>1)return null;p.CrossToRef(a,n,h);var f=p.Dot(this.direction,h)*l;if(f<0||c+f>1)return null;var d=p.Dot(o,h)*l;return d>this.length?null:new pt(1-c-f,c,d)},e.prototype.intersectsPlane=function(e){var t,i=p.Dot(e.normal,this.direction);if(Math.abs(i)<9.99999997475243e-7)return null;var r=p.Dot(e.normal,this.origin);return(t=(-e.d-r)/i)<0?t<-9.99999997475243e-7?null:0:t},e.prototype.intersectsAxis=function(e,t){switch(void 0===t&&(t=0),e){case"y":return(i=(this.origin.y-t)/this.direction.y)>0?null:new p(this.origin.x+this.direction.x*-i,t,this.origin.z+this.direction.z*-i);case"x":return(i=(this.origin.x-t)/this.direction.x)>0?null:new p(t,this.origin.y+this.direction.y*-i,this.origin.z+this.direction.z*-i);case"z":var i;return(i=(this.origin.z-t)/this.direction.z)>0?null:new p(this.origin.x+this.direction.x*-i,this.origin.y+this.direction.y*-i,t);default:return null}},e.prototype.intersectsMesh=function(t,i){var r=y.Matrix[0];return t.getWorldMatrix().invertToRef(r),this._tmpRay?e.TransformToRef(this,r,this._tmpRay):this._tmpRay=e.Transform(this,r),t.intersects(this._tmpRay,i)},e.prototype.intersectsMeshes=function(e,t,i){i?i.length=0:i=[];for(var r=0;r<e.length;r++){var n=this.intersectsMesh(e[r],t);n.hit&&i.push(n)}return i.sort(this._comparePickingInfo),i},e.prototype._comparePickingInfo=function(e,t){return e.distance<t.distance?-1:e.distance>t.distance?1:0},e.prototype.intersectionSegment=function(t,i,r){var n=this.origin,o=y.Vector3[0],s=y.Vector3[1],a=y.Vector3[2],h=y.Vector3[3];i.subtractToRef(t,o),this.direction.scaleToRef(e.rayl,a),n.addToRef(a,s),t.subtractToRef(n,h);var u,l,c,f,d=p.Dot(o,o),_=p.Dot(o,a),g=p.Dot(a,a),m=p.Dot(o,h),v=p.Dot(a,h),b=d*g-_*_,T=b,E=b;b<e.smallnum?(l=0,T=1,f=v,E=g):(f=d*v-_*m,(l=_*v-g*m)<0?(l=0,f=v,E=g):l>T&&(l=T,f=v+_,E=g)),f<0?(f=0,-m<0?l=0:-m>d?l=T:(l=-m,T=d)):f>E&&(f=E,-m+_<0?l=0:-m+_>d?l=T:(l=-m+_,T=d)),u=Math.abs(l)<e.smallnum?0:l/T,c=Math.abs(f)<e.smallnum?0:f/E;var x=y.Vector3[4];a.scaleToRef(c,x);var A=y.Vector3[5];o.scaleToRef(u,A),A.addInPlace(h);var M=y.Vector3[6];return A.subtractToRef(x,M),c>0&&c<=this.length&&M.lengthSquared()<r*r?A.length():-1},e.prototype.update=function(e,t,i,r,n,o,s){return this.unprojectRayToRef(e,t,i,r,n,o,s),this},e.Zero=function(){return new e(p.Zero(),p.Zero())},e.CreateNew=function(t,i,r,n,o,s,a){return e.Zero().update(t,i,r,n,o,s,a)},e.CreateNewFromTo=function(t,i,r){void 0===r&&(r=m.IdentityReadOnly);var n=i.subtract(t),o=Math.sqrt(n.x*n.x+n.y*n.y+n.z*n.z);return n.normalize(),e.Transform(new e(t,n,o),r)},e.Transform=function(t,i){var r=new e(new p(0,0,0),new p(0,0,0));return e.TransformToRef(t,i,r),r},e.TransformToRef=function(e,t,i){p.TransformCoordinatesToRef(e.origin,t,i.origin),p.TransformNormalToRef(e.direction,t,i.direction),i.length=e.length;var r=i.direction,n=r.length();if(0!==n&&1!==n){var o=1/n;r.x*=o,r.y*=o,r.z*=o,i.length*=n}},e.prototype.unprojectRayToRef=function(e,t,i,r,n,o,s){var a=y.Matrix[0];n.multiplyToRef(o,a),a.multiplyToRef(s,a),a.invert();var h=y.Vector3[0];h.x=e/i*2-1,h.y=-(t/r*2-1),h.z=-1;var u=y.Vector3[1].copyFromFloats(h.x,h.y,1),l=y.Vector3[2],c=y.Vector3[3];p._UnprojectFromInvertedMatrixToRef(h,a,l),p._UnprojectFromInvertedMatrixToRef(u,a,c),this.origin.copyFrom(l),c.subtractToRef(l,this.direction),this.direction.normalize()},e._TmpVector3=l.BuildArray(6,p.Zero),e.smallnum=1e-8,e.rayl=1e9,e}();zi.prototype.createPickingRay=function(e,t,i,r,n){void 0===n&&(n=!1);var o=Gi.Zero();return this.createPickingRayToRef(e,t,i,o,r,n),o},zi.prototype.createPickingRayToRef=function(e,t,i,r,n,o){void 0===o&&(o=!1);var s=this.getEngine();if(!n){if(!this.activeCamera)return this;n=this.activeCamera}var a=n.viewport.toGlobal(s.getRenderWidth(),s.getRenderHeight());return e=e/s.getHardwareScalingLevel()-a.x,t=t/s.getHardwareScalingLevel()-(s.getRenderHeight()-a.y-a.height),r.update(e,t,a.width,a.height,i||m.IdentityReadOnly,o?m.IdentityReadOnly:n.getViewMatrix(),n.getProjectionMatrix()),this},zi.prototype.createPickingRayInCameraSpace=function(e,t,i){var r=Gi.Zero();return this.createPickingRayInCameraSpaceToRef(e,t,r,i),r},zi.prototype.createPickingRayInCameraSpaceToRef=function(e,t,i,r){if(!Lt)return this;var n=this.getEngine();if(!r){if(!this.activeCamera)throw new Error("Active camera not set");r=this.activeCamera}var o=r.viewport.toGlobal(n.getRenderWidth(),n.getRenderHeight()),s=m.Identity();return e=e/n.getHardwareScalingLevel()-o.x,t=t/n.getHardwareScalingLevel()-(n.getRenderHeight()-o.y-o.height),i.update(e,t,o.width,o.height,s,s,r.getProjectionMatrix()),this},zi.prototype._internalPickForMesh=function(e,t,i,r,n,o,s,a){var h=t(r),u=i.intersects(h,n,s,o,r,a);return u&&u.hit?!n&&null!=e&&u.distance>=e.distance?null:u:null},zi.prototype._internalPick=function(e,t,i,r,n){if(!Lt)return null;for(var o=null,s=0;s<this.meshes.length;s++){var a=this.meshes[s];if(t){if(!t(a))continue}else if(!a.isEnabled()||!a.isVisible||!a.isPickable)continue;var h,u=a.skeleton&&a.skeleton.overrideMesh?a.skeleton.overrideMesh.getWorldMatrix():a.getWorldMatrix();if(a.hasThinInstances&&a.thinInstanceEnablePicking){if(h=this._internalPickForMesh(o,e,a,u,!0,!0,n)){if(r)return o;for(var l=y.Matrix[1],c=a.thinInstanceGetWorldMatrices(),f=0;f<c.length;f++){c[f].multiplyToRef(u,l);var d=this._internalPickForMesh(o,e,a,l,i,r,n,!0);if(d&&((o=d).thinInstanceIndex=f,i))return o}}}else if((h=this._internalPickForMesh(o,e,a,u,i,r,n))&&(o=h,i))return o}return o||new Lt},zi.prototype._internalMultiPick=function(e,t,i){if(!Lt)return null;for(var r=new Array,n=0;n<this.meshes.length;n++){var o=this.meshes[n];if(t){if(!t(o))continue}else if(!o.isEnabled()||!o.isVisible||!o.isPickable)continue;var s,a=o.skeleton&&o.skeleton.overrideMesh?o.skeleton.overrideMesh.getWorldMatrix():o.getWorldMatrix();if(o.hasThinInstances&&o.thinInstanceEnablePicking){if(s=this._internalPickForMesh(null,e,o,a,!0,!0,i))for(var h=y.Matrix[1],u=o.thinInstanceGetWorldMatrices(),l=0;l<u.length;l++){u[l].multiplyToRef(a,h);var c=this._internalPickForMesh(null,e,o,h,!1,!1,i,!0);c&&(c.thinInstanceIndex=l,r.push(c))}}else(s=this._internalPickForMesh(null,e,o,a,!1,!1,i))&&r.push(s)}return r},zi.prototype.pickWithBoundingInfo=function(e,t,i,r,n){var o=this;if(!Lt)return null;var s=this._internalPick((function(i){return o._tempPickingRay||(o._tempPickingRay=Gi.Zero()),o.createPickingRayToRef(e,t,i,o._tempPickingRay,n||null),o._tempPickingRay}),i,r,!0);return s&&(s.ray=this.createPickingRay(e,t,m.Identity(),n||null)),s},zi.prototype.pick=function(e,t,i,r,n,o){var s=this;if(!Lt)return null;var a=this._internalPick((function(i){return s._tempPickingRay||(s._tempPickingRay=Gi.Zero()),s.createPickingRayToRef(e,t,i,s._tempPickingRay,n||null),s._tempPickingRay}),i,r,!1,o);return a&&(a.ray=this.createPickingRay(e,t,m.Identity(),n||null)),a},zi.prototype.pickWithRay=function(e,t,i,r){var n=this,o=this._internalPick((function(t){return n._pickWithRayInverseMatrix||(n._pickWithRayInverseMatrix=m.Identity()),t.invertToRef(n._pickWithRayInverseMatrix),n._cachedRayForTransform||(n._cachedRayForTransform=Gi.Zero()),Gi.TransformToRef(e,n._pickWithRayInverseMatrix,n._cachedRayForTransform),n._cachedRayForTransform}),t,i,!1,r);return o&&(o.ray=e),o},zi.prototype.multiPick=function(e,t,i,r,n){var o=this;return this._internalMultiPick((function(i){return o.createPickingRay(e,t,i,r||null)}),i,n)},zi.prototype.multiPickWithRay=function(e,t,i){var r=this;return this._internalMultiPick((function(t){return r._pickWithRayInverseMatrix||(r._pickWithRayInverseMatrix=m.Identity()),t.invertToRef(r._pickWithRayInverseMatrix),r._cachedRayForTransform||(r._cachedRayForTransform=Gi.Zero()),Gi.TransformToRef(e,r._pickWithRayInverseMatrix,r._cachedRayForTransform),r._cachedRayForTransform}),t,i)},mi.prototype.getForwardRay=function(e,t,i){return void 0===e&&(e=100),this.getForwardRayToRef(new Gi(p.Zero(),p.Zero(),e),e,t,i)},mi.prototype.getForwardRayToRef=function(e,t,i,r){return void 0===t&&(t=100),i||(i=this.getWorldMatrix()),e.length=t,r?e.origin.copyFrom(r):e.origin.copyFrom(this.position),y.Vector3[2].set(0,0,this._scene.useRightHandedSystem?-1:1),p.TransformNormalToRef(y.Vector3[2],i,y.Vector3[3]),p.NormalizeToRef(y.Vector3[3],e.direction),e};var Hi=function(){function e(){}return e.BindClipPlane=function(e,t){if(t.clipPlane){var i=t.clipPlane;e.setFloat4("vClipPlane",i.normal.x,i.normal.y,i.normal.z,i.d)}if(t.clipPlane2){i=t.clipPlane2;e.setFloat4("vClipPlane2",i.normal.x,i.normal.y,i.normal.z,i.d)}if(t.clipPlane3){i=t.clipPlane3;e.setFloat4("vClipPlane3",i.normal.x,i.normal.y,i.normal.z,i.d)}if(t.clipPlane4){i=t.clipPlane4;e.setFloat4("vClipPlane4",i.normal.x,i.normal.y,i.normal.z,i.d)}if(t.clipPlane5){i=t.clipPlane5;e.setFloat4("vClipPlane5",i.normal.x,i.normal.y,i.normal.z,i.d)}if(t.clipPlane6){i=t.clipPlane6;e.setFloat4("vClipPlane6",i.normal.x,i.normal.y,i.normal.z,i.d)}},e}(),Xi=function(){function e(){}return e.BindEyePosition=function(e,t,i){if(void 0===i&&(i="vEyePosition"),t._forcedViewPosition)e.setVector3(i,t._forcedViewPosition);else{var r=t.activeCamera.globalPosition;r||(r=t.activeCamera.devicePosition),e.setVector3(i,t._mirroredCameraPosition?t._mirroredCameraPosition:r)}},e.PrepareDefinesForMergedUV=function(e,t,i){t._needUVs=!0,t[i]=!0,e.getTextureMatrix().isIdentityAs3x2()?(t[i+"DIRECTUV"]=e.coordinatesIndex+1,0===e.coordinatesIndex?t.MAINUV1=!0:t.MAINUV2=!0):t[i+"DIRECTUV"]=0},e.BindTextureMatrix=function(e,t,i){var r=e.getTextureMatrix();t.updateMatrix(i+"Matrix",r)},e.GetFogState=function(e,t){return t.fogEnabled&&e.applyFog&&t.fogMode!==zi.FOGMODE_NONE},e.PrepareDefinesForMisc=function(e,t,i,r,n,o,s){s._areMiscDirty&&(s.LOGARITHMICDEPTH=i,s.POINTSIZE=r,s.FOG=n&&this.GetFogState(e,t),s.NONUNIFORMSCALING=e.nonUniformScaling,s.ALPHATEST=o)},e.PrepareDefinesForFrameBoundValues=function(e,t,i,r,n,o){void 0===n&&(n=null),void 0===o&&(o=!1);var s,a,h,u,l,c,f=!1;s=null==n?void 0!==e.clipPlane&&null!==e.clipPlane:n,a=null==n?void 0!==e.clipPlane2&&null!==e.clipPlane2:n,h=null==n?void 0!==e.clipPlane3&&null!==e.clipPlane3:n,u=null==n?void 0!==e.clipPlane4&&null!==e.clipPlane4:n,l=null==n?void 0!==e.clipPlane5&&null!==e.clipPlane5:n,c=null==n?void 0!==e.clipPlane6&&null!==e.clipPlane6:n,i.CLIPPLANE!==s&&(i.CLIPPLANE=s,f=!0),i.CLIPPLANE2!==a&&(i.CLIPPLANE2=a,f=!0),i.CLIPPLANE3!==h&&(i.CLIPPLANE3=h,f=!0),i.CLIPPLANE4!==u&&(i.CLIPPLANE4=u,f=!0),i.CLIPPLANE5!==l&&(i.CLIPPLANE5=l,f=!0),i.CLIPPLANE6!==c&&(i.CLIPPLANE6=c,f=!0),i.DEPTHPREPASS!==!t.getColorWrite()&&(i.DEPTHPREPASS=!i.DEPTHPREPASS,f=!0),i.INSTANCES!==r&&(i.INSTANCES=r,f=!0),i.THIN_INSTANCES!==o&&(i.THIN_INSTANCES=o,f=!0),f&&i.markAsUnprocessed()},e.PrepareDefinesForBones=function(e,t){if(e.useBones&&e.computeBonesUsingShaders&&e.skeleton){t.NUM_BONE_INFLUENCERS=e.numBoneInfluencers;var i=void 0!==t.BONETEXTURE;if(e.skeleton.isUsingTextureForMatrices&&i)t.BONETEXTURE=!0;else{t.BonesPerMesh=e.skeleton.bones.length+1,t.BONETEXTURE=!i&&void 0;var r=e.getScene().prePassRenderer;if(r&&r.enabled){var n=-1===r.excludedSkinnedMesh.indexOf(e);t.BONES_VELOCITY_ENABLED=n}}}else t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0},e.PrepareDefinesForMorphTargets=function(e,t){var i=e.morphTargetManager;i?(t.MORPHTARGETS_UV=i.supportsUVs&&t.UV1,t.MORPHTARGETS_TANGENT=i.supportsTangents&&t.TANGENT,t.MORPHTARGETS_NORMAL=i.supportsNormals&&t.NORMAL,t.MORPHTARGETS=i.numInfluencers>0,t.NUM_MORPH_INFLUENCERS=i.numInfluencers):(t.MORPHTARGETS_UV=!1,t.MORPHTARGETS_TANGENT=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS=!1,t.NUM_MORPH_INFLUENCERS=0)},e.PrepareDefinesForAttributes=function(e,t,i,r,n,o){if(void 0===n&&(n=!1),void 0===o&&(o=!0),!t._areAttributesDirty&&t._needNormals===t._normals&&t._needUVs===t._uvs)return!1;if(t._normals=t._needNormals,t._uvs=t._needUVs,t.NORMAL=t._needNormals&&e.isVerticesDataPresent(ft.NormalKind),t._needNormals&&e.isVerticesDataPresent(ft.TangentKind)&&(t.TANGENT=!0),t._needUVs?(t.UV1=e.isVerticesDataPresent(ft.UVKind),t.UV2=e.isVerticesDataPresent(ft.UV2Kind)):(t.UV1=!1,t.UV2=!1),i){var s=e.useVertexColors&&e.isVerticesDataPresent(ft.ColorKind);t.VERTEXCOLOR=s,t.VERTEXALPHA=e.hasVertexAlpha&&s&&o}return r&&this.PrepareDefinesForBones(e,t),n&&this.PrepareDefinesForMorphTargets(e,t),!0},e.PrepareDefinesForMultiview=function(e,t){if(e.activeCamera){var i=t.MULTIVIEW;t.MULTIVIEW=null!==e.activeCamera.outputRenderTarget&&e.activeCamera.outputRenderTarget.getViewCount()>1,t.MULTIVIEW!=i&&t.markAsUnprocessed()}},e.PrepareDefinesForPrePass=function(e,t,i){var r=t.PREPASS;if(t._arePrePassDirty){var n=[{type:1,define:"PREPASS_POSITION",index:"PREPASS_POSITION_INDEX"},{type:2,define:"PREPASS_VELOCITY",index:"PREPASS_VELOCITY_INDEX"},{type:3,define:"PREPASS_REFLECTIVITY",index:"PREPASS_REFLECTIVITY_INDEX"},{type:0,define:"PREPASS_IRRADIANCE",index:"PREPASS_IRRADIANCE_INDEX"},{type:6,define:"PREPASS_ALBEDO",index:"PREPASS_ALBEDO_INDEX"},{type:5,define:"PREPASS_DEPTHNORMAL",index:"PREPASS_DEPTHNORMAL_INDEX"}];if(e.prePassRenderer&&e.prePassRenderer.enabled&&i){t.PREPASS=!0,t.SCENE_MRT_COUNT=e.prePassRenderer.mrtCount;for(var o=0;o<n.length;o++){var s=e.prePassRenderer.getIndex(n[o].type);-1!==s?(t[n[o].define]=!0,t[n[o].index]=s):t[n[o].define]=!1}}else{t.PREPASS=!1;for(o=0;o<n.length;o++)t[n[o].define]=!1}t.PREPASS!=r&&(t.markAsUnprocessed(),t.markAsImageProcessingDirty())}},e.PrepareDefinesForLight=function(e,t,i,r,n,o,s){switch(s.needNormals=!0,void 0===n["LIGHT"+r]&&(s.needRebuild=!0),n["LIGHT"+r]=!0,n["SPOTLIGHT"+r]=!1,n["HEMILIGHT"+r]=!1,n["POINTLIGHT"+r]=!1,n["DIRLIGHT"+r]=!1,i.prepareLightSpecificDefines(n,r),n["LIGHT_FALLOFF_PHYSICAL"+r]=!1,n["LIGHT_FALLOFF_GLTF"+r]=!1,n["LIGHT_FALLOFF_STANDARD"+r]=!1,i.falloffType){case Li.FALLOFF_GLTF:n["LIGHT_FALLOFF_GLTF"+r]=!0;break;case Li.FALLOFF_PHYSICAL:n["LIGHT_FALLOFF_PHYSICAL"+r]=!0;break;case Li.FALLOFF_STANDARD:n["LIGHT_FALLOFF_STANDARD"+r]=!0}if(o&&!i.specular.equalsFloats(0,0,0)&&(s.specularEnabled=!0),n["SHADOW"+r]=!1,n["SHADOWCSM"+r]=!1,n["SHADOWCSMDEBUG"+r]=!1,n["SHADOWCSMNUM_CASCADES"+r]=!1,n["SHADOWCSMUSESHADOWMAXZ"+r]=!1,n["SHADOWCSMNOBLEND"+r]=!1,n["SHADOWCSM_RIGHTHANDED"+r]=!1,n["SHADOWPCF"+r]=!1,n["SHADOWPCSS"+r]=!1,n["SHADOWPOISSON"+r]=!1,n["SHADOWESM"+r]=!1,n["SHADOWCLOSEESM"+r]=!1,n["SHADOWCUBE"+r]=!1,n["SHADOWLOWQUALITY"+r]=!1,n["SHADOWMEDIUMQUALITY"+r]=!1,t&&t.receiveShadows&&e.shadowsEnabled&&i.shadowEnabled){var a=i.getShadowGenerator();if(a){var h=a.getShadowMap();h&&h.renderList&&h.renderList.length>0&&(s.shadowEnabled=!0,a.prepareDefines(n,r))}}i.lightmapMode!=Li.LIGHTMAP_DEFAULT?(s.lightmapMode=!0,n["LIGHTMAPEXCLUDED"+r]=!0,n["LIGHTMAPNOSPECULAR"+r]=i.lightmapMode==Li.LIGHTMAP_SHADOWSONLY):(n["LIGHTMAPEXCLUDED"+r]=!1,n["LIGHTMAPNOSPECULAR"+r]=!1)},e.PrepareDefinesForLights=function(e,t,i,r,n,o){if(void 0===n&&(n=4),void 0===o&&(o=!1),!i._areLightsDirty)return i._needNormals;var s=0,a={needNormals:!1,needRebuild:!1,lightmapMode:!1,shadowEnabled:!1,specularEnabled:!1};if(e.lightsEnabled&&!o)for(var h=0,u=t.lightSources;h<u.length;h++){var l=u[h];if(this.PrepareDefinesForLight(e,t,l,s,i,r,a),++s===n)break}i.SPECULARTERM=a.specularEnabled,i.SHADOWS=a.shadowEnabled;for(var c=s;c<n;c++)void 0!==i["LIGHT"+c]&&(i["LIGHT"+c]=!1,i["HEMILIGHT"+c]=!1,i["POINTLIGHT"+c]=!1,i["DIRLIGHT"+c]=!1,i["SPOTLIGHT"+c]=!1,i["SHADOW"+c]=!1,i["SHADOWCSM"+c]=!1,i["SHADOWCSMDEBUG"+c]=!1,i["SHADOWCSMNUM_CASCADES"+c]=!1,i["SHADOWCSMUSESHADOWMAXZ"+c]=!1,i["SHADOWCSMNOBLEND"+c]=!1,i["SHADOWCSM_RIGHTHANDED"+c]=!1,i["SHADOWPCF"+c]=!1,i["SHADOWPCSS"+c]=!1,i["SHADOWPOISSON"+c]=!1,i["SHADOWESM"+c]=!1,i["SHADOWCLOSEESM"+c]=!1,i["SHADOWCUBE"+c]=!1,i["SHADOWLOWQUALITY"+c]=!1,i["SHADOWMEDIUMQUALITY"+c]=!1);var f=e.getEngine().getCaps();return void 0===i.SHADOWFLOAT&&(a.needRebuild=!0),i.SHADOWFLOAT=a.shadowEnabled&&(f.textureFloatRender&&f.textureFloatLinearFiltering||f.textureHalfFloatRender&&f.textureHalfFloatLinearFiltering),i.LIGHTMAPEXCLUDED=a.lightmapMode,a.needRebuild&&i.rebuild(),a.needNormals},e.PrepareUniformsAndSamplersForLight=function(e,t,i,r,n,o){void 0===n&&(n=null),void 0===o&&(o=!1),n&&n.push("Light"+e),o||(t.push("vLightData"+e,"vLightDiffuse"+e,"vLightSpecular"+e,"vLightDirection"+e,"vLightFalloff"+e,"vLightGround"+e,"lightMatrix"+e,"shadowsInfo"+e,"depthValues"+e),i.push("shadowSampler"+e),i.push("depthSampler"+e),t.push("viewFrustumZ"+e,"cascadeBlendFactor"+e,"lightSizeUVCorrection"+e,"depthCorrection"+e,"penumbraDarkness"+e,"frustumLengths"+e),r&&(i.push("projectionLightSampler"+e),t.push("textureProjectionMatrix"+e)))},e.PrepareUniformsAndSamplersList=function(e,t,i,r){var n;void 0===r&&(r=4);var o=null;if(e.uniformsNames){var s=e;n=s.uniformsNames,o=s.uniformBuffersNames,t=s.samplers,i=s.defines,r=s.maxSimultaneousLights||0}else n=e,t||(t=[]);for(var a=0;a<r&&i["LIGHT"+a];a++)this.PrepareUniformsAndSamplersForLight(a,n,t,i["PROJECTEDLIGHTTEXTURE"+a],o);i.NUM_MORPH_INFLUENCERS&&n.push("morphTargetInfluences")},e.HandleFallbacksForShadows=function(e,t,i,r){void 0===i&&(i=4),void 0===r&&(r=0);for(var n=0,o=0;o<i&&e["LIGHT"+o];o++)o>0&&(n=r+o,t.addFallback(n,"LIGHT"+o)),e.SHADOWS||(e["SHADOW"+o]&&t.addFallback(r,"SHADOW"+o),e["SHADOWPCF"+o]&&t.addFallback(r,"SHADOWPCF"+o),e["SHADOWPCSS"+o]&&t.addFallback(r,"SHADOWPCSS"+o),e["SHADOWPOISSON"+o]&&t.addFallback(r,"SHADOWPOISSON"+o),e["SHADOWESM"+o]&&t.addFallback(r,"SHADOWESM"+o),e["SHADOWCLOSEESM"+o]&&t.addFallback(r,"SHADOWCLOSEESM"+o));return n++},e.PrepareAttributesForMorphTargetsInfluencers=function(e,t,i){this._TmpMorphInfluencers.NUM_MORPH_INFLUENCERS=i,this.PrepareAttributesForMorphTargets(e,t,this._TmpMorphInfluencers)},e.PrepareAttributesForMorphTargets=function(e,t,i){var r=i.NUM_MORPH_INFLUENCERS;if(r>0&&V.LastCreatedEngine)for(var n=V.LastCreatedEngine.getCaps().maxVertexAttribs,o=t.morphTargetManager,s=o&&o.supportsNormals&&i.NORMAL,a=o&&o.supportsTangents&&i.TANGENT,h=o&&o.supportsUVs&&i.UV1,u=0;u<r;u++)e.push(ft.PositionKind+u),s&&e.push(ft.NormalKind+u),a&&e.push(ft.TangentKind+u),h&&e.push(ft.UVKind+"_"+u),e.length>n&&q.Error("Cannot add more vertex attributes for mesh "+t.name)},e.PrepareAttributesForBones=function(e,t,i,r){i.NUM_BONE_INFLUENCERS>0&&(r.addCPUSkinningFallback(0,t),e.push(ft.MatricesIndicesKind),e.push(ft.MatricesWeightsKind),i.NUM_BONE_INFLUENCERS>4&&(e.push(ft.MatricesIndicesExtraKind),e.push(ft.MatricesWeightsExtraKind)))},e.PrepareAttributesForInstances=function(e,t){(t.INSTANCES||t.THIN_INSTANCES)&&this.PushAttributesForInstances(e)},e.PushAttributesForInstances=function(e){e.push("world0"),e.push("world1"),e.push("world2"),e.push("world3")},e.BindLightProperties=function(e,t,i){e.transferToEffect(t,i+"")},e.BindLight=function(e,t,i,r,n,o){void 0===o&&(o=!1),e._bindLight(t,i,r,n,o)},e.BindLights=function(e,t,i,r,n,o){void 0===n&&(n=4),void 0===o&&(o=!1);for(var s=Math.min(t.lightSources.length,n),a=0;a<s;a++){var h=t.lightSources[a];this.BindLight(h,a,e,i,"boolean"==typeof r?r:r.SPECULARTERM,o)}},e.BindFogParameters=function(e,t,i,r){void 0===r&&(r=!1),e.fogEnabled&&t.applyFog&&e.fogMode!==zi.FOGMODE_NONE&&(i.setFloat4("vFogInfos",e.fogMode,e.fogStart,e.fogEnd,e.fogDensity),r?(e.fogColor.toLinearSpaceToRef(this._tempFogColor),i.setColor3("vFogColor",this._tempFogColor)):i.setColor3("vFogColor",e.fogColor))},e.BindBonesParameters=function(t,i,r){if(i&&t&&(t.computeBonesUsingShaders&&i._bonesComputationForcedToCPU&&(t.computeBonesUsingShaders=!1),t.useBones&&t.computeBonesUsingShaders&&t.skeleton)){var n=t.skeleton;if(n.isUsingTextureForMatrices&&i.getUniformIndex("boneTextureWidth")>-1){var o=n.getTransformMatrixTexture(t);i.setTexture("boneSampler",o),i.setFloat("boneTextureWidth",4*(n.bones.length+1))}else{var s=n.getTransformMatrices(t);s&&(i.setMatrices("mBones",s),r&&t.getScene().prePassRenderer&&t.getScene().prePassRenderer.getIndex(2)&&(r.previousBones[t.uniqueId]&&i.setMatrices("mPreviousBones",r.previousBones[t.uniqueId]),e._CopyBonesTransformationMatrices(s,r.previousBones[t.uniqueId])))}}},e._CopyBonesTransformationMatrices=function(e,t){return t.set(e),t},e.BindMorphTargetParameters=function(e,t){var i=e.morphTargetManager;e&&i&&t.setFloatArray("morphTargetInfluences",i.influences)},e.BindLogDepth=function(e,t,i){e.LOGARITHMICDEPTH&&t.setFloat("logarithmicDepthConstant",2/(Math.log(i.activeCamera.maxZ+1)/Math.LN2))},e.BindClipPlane=function(e,t){Hi.BindClipPlane(e,t)},e._TmpMorphInfluencers={NUM_MORPH_INFLUENCERS:0},e._tempFogColor=T.Black(),e}(),ji=function(){function e(){this._defines={},this._currentRank=32,this._maxRank=-1,this._mesh=null}return e.prototype.unBindMesh=function(){this._mesh=null},e.prototype.addFallback=function(e,t){this._defines[e]||(e<this._currentRank&&(this._currentRank=e),e>this._maxRank&&(this._maxRank=e),this._defines[e]=new Array),this._defines[e].push(t)},e.prototype.addCPUSkinningFallback=function(e,t){this._mesh=t,e<this._currentRank&&(this._currentRank=e),e>this._maxRank&&(this._maxRank=e)},Object.defineProperty(e.prototype,"hasMoreFallbacks",{get:function(){return this._currentRank<=this._maxRank},enumerable:!1,configurable:!0}),e.prototype.reduce=function(e,t){if(this._mesh&&this._mesh.computeBonesUsingShaders&&this._mesh.numBoneInfluencers>0){this._mesh.computeBonesUsingShaders=!1,e=e.replace("#define NUM_BONE_INFLUENCERS "+this._mesh.numBoneInfluencers,"#define NUM_BONE_INFLUENCERS 0"),t._bonesComputationForcedToCPU=!0;for(var i=this._mesh.getScene(),r=0;r<i.meshes.length;r++){var n=i.meshes[r];if(n.material){if(n.computeBonesUsingShaders&&0!==n.numBoneInfluencers)if(n.material.getEffect()===t)n.computeBonesUsingShaders=!1;else if(n.subMeshes)for(var o=0,s=n.subMeshes;o<s.length;o++){if(s[o].effect===t){n.computeBonesUsingShaders=!1;break}}}else!this._mesh.material&&n.computeBonesUsingShaders&&n.numBoneInfluencers>0&&(n.computeBonesUsingShaders=!1)}}else{var a=this._defines[this._currentRank];if(a)for(r=0;r<a.length;r++)e=e.replace("#define "+a[r],"");this._currentRank++}return e},e}(),Ki={effect:null,subMesh:null},Yi=function(e){function r(t,r,n,o){void 0===o&&(o={});var s=e.call(this,t,r)||this;return s._textures={},s._textureArrays={},s._floats={},s._ints={},s._floatsArrays={},s._colors3={},s._colors3Arrays={},s._colors4={},s._colors4Arrays={},s._vectors2={},s._vectors3={},s._vectors4={},s._matrices={},s._matrixArrays={},s._matrices3x3={},s._matrices2x2={},s._vectors2Arrays={},s._vectors3Arrays={},s._vectors4Arrays={},s._cachedWorldViewMatrix=new m,s._cachedWorldViewProjectionMatrix=new m,s._multiview=!1,s._shaderPath=n,s._options=i({needAlphaBlending:!1,needAlphaTesting:!1,attributes:["position","normal","uv"],uniforms:["worldViewProjection"],uniformBuffers:[],samplers:[],defines:[]},o),s}return t(r,e),Object.defineProperty(r.prototype,"shaderPath",{get:function(){return this._shaderPath},set:function(e){this._shaderPath=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"options",{get:function(){return this._options},enumerable:!1,configurable:!0}),r.prototype.getClassName=function(){return"ShaderMaterial"},r.prototype.needAlphaBlending=function(){return this.alpha<1||this._options.needAlphaBlending},r.prototype.needAlphaTesting=function(){return this._options.needAlphaTesting},r.prototype._checkUniform=function(e){-1===this._options.uniforms.indexOf(e)&&this._options.uniforms.push(e)},r.prototype.setTexture=function(e,t){return-1===this._options.samplers.indexOf(e)&&this._options.samplers.push(e),this._textures[e]=t,this},r.prototype.setTextureArray=function(e,t){return-1===this._options.samplers.indexOf(e)&&this._options.samplers.push(e),this._checkUniform(e),this._textureArrays[e]=t,this},r.prototype.setFloat=function(e,t){return this._checkUniform(e),this._floats[e]=t,this},r.prototype.setInt=function(e,t){return this._checkUniform(e),this._ints[e]=t,this},r.prototype.setFloats=function(e,t){return this._checkUniform(e),this._floatsArrays[e]=t,this},r.prototype.setColor3=function(e,t){return this._checkUniform(e),this._colors3[e]=t,this},r.prototype.setColor3Array=function(e,t){return this._checkUniform(e),this._colors3Arrays[e]=t.reduce((function(e,t){return t.toArray(e,e.length),e}),[]),this},r.prototype.setColor4=function(e,t){return this._checkUniform(e),this._colors4[e]=t,this},r.prototype.setColor4Array=function(e,t){return this._checkUniform(e),this._colors4Arrays[e]=t.reduce((function(e,t){return t.toArray(e,e.length),e}),[]),this},r.prototype.setVector2=function(e,t){return this._checkUniform(e),this._vectors2[e]=t,this},r.prototype.setVector3=function(e,t){return this._checkUniform(e),this._vectors3[e]=t,this},r.prototype.setVector4=function(e,t){return this._checkUniform(e),this._vectors4[e]=t,this},r.prototype.setMatrix=function(e,t){return this._checkUniform(e),this._matrices[e]=t,this},r.prototype.setMatrices=function(e,t){this._checkUniform(e);for(var i=new Float32Array(16*t.length),r=0;r<t.length;r++){t[r].copyToArray(i,16*r)}return this._matrixArrays[e]=i,this},r.prototype.setMatrix3x3=function(e,t){return this._checkUniform(e),this._matrices3x3[e]=t,this},r.prototype.setMatrix2x2=function(e,t){return this._checkUniform(e),this._matrices2x2[e]=t,this},r.prototype.setArray2=function(e,t){return this._checkUniform(e),this._vectors2Arrays[e]=t,this},r.prototype.setArray3=function(e,t){return this._checkUniform(e),this._vectors3Arrays[e]=t,this},r.prototype.setArray4=function(e,t){return this._checkUniform(e),this._vectors4Arrays[e]=t,this},r.prototype._checkCache=function(e,t){return!e||(!this._effect||-1!==this._effect.defines.indexOf("#define INSTANCES")===t)},r.prototype.isReadyForSubMesh=function(e,t,i){return this.isReady(e,i)},r.prototype.isReady=function(e,t){var i,r;if(this._effect&&this.isFrozen&&this._effect._wasPreviouslyReady)return!0;var n=this.getScene(),o=n.getEngine();if(!this.checkReadyOnEveryCall&&this._renderId===n.getRenderId()&&this._checkCache(e,t))return!0;var s=[],a=[],h=new ji;o.getCaps().multiview&&n.activeCamera&&n.activeCamera.outputRenderTarget&&n.activeCamera.outputRenderTarget.getViewCount()>1&&(this._multiview=!0,s.push("#define MULTIVIEW"),-1!==this._options.uniforms.indexOf("viewProjection")&&-1===this._options.uniforms.push("viewProjectionR")&&this._options.uniforms.push("viewProjectionR"));for(var u=0;u<this._options.defines.length;u++)s.push(this._options.defines[u]);for(u=0;u<this._options.attributes.length;u++)a.push(this._options.attributes[u]);e&&e.isVerticesDataPresent(ft.ColorKind)&&(a.push(ft.ColorKind),s.push("#define VERTEXCOLOR")),t&&(s.push("#define INSTANCES"),Xi.PushAttributesForInstances(a),(null==e?void 0:e.hasThinInstances)&&s.push("#define THIN_INSTANCES"));var l=0;if(e&&e.useBones&&e.computeBonesUsingShaders&&e.skeleton){a.push(ft.MatricesIndicesKind),a.push(ft.MatricesWeightsKind),e.numBoneInfluencers>4&&(a.push(ft.MatricesIndicesExtraKind),a.push(ft.MatricesWeightsExtraKind));var c=e.skeleton;l=e.numBoneInfluencers,s.push("#define NUM_BONE_INFLUENCERS "+l),h.addCPUSkinningFallback(0,e),c.isUsingTextureForMatrices?(s.push("#define BONETEXTURE"),-1===this._options.uniforms.indexOf("boneTextureWidth")&&this._options.uniforms.push("boneTextureWidth"),-1===this._options.samplers.indexOf("boneSampler")&&this._options.samplers.push("boneSampler")):(s.push("#define BonesPerMesh "+(c.bones.length+1)),-1===this._options.uniforms.indexOf("mBones")&&this._options.uniforms.push("mBones"))}else s.push("#define NUM_BONE_INFLUENCERS 0");for(var f in this._textures)if(!this._textures[f].isReady())return!1;e&&this._shouldTurnAlphaTestOn(e)&&s.push("#define ALPHATEST");var d=this._shaderPath,p=this._options.uniforms,_=this._options.uniformBuffers,g=this._options.samplers;this.customShaderNameResolve&&(p=p.slice(),_=_.slice(),g=g.slice(),d=this.customShaderNameResolve(d,p,_,g,s,a));var m=this._effect,v=s.join("\n");return this._cachedDefines!==v&&(this._cachedDefines=v,this._effect=o.createEffect(d,{attributes:a,uniformsNames:p,uniformBuffersNames:_,samplers:g,defines:v,fallbacks:h,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousMorphTargets:l}},o),this._onEffectCreatedObservable&&(Ki.effect=this._effect,this._onEffectCreatedObservable.notifyObservers(Ki))),null!==(r=!(null===(i=this._effect)||void 0===i?void 0:i.isReady()))&&void 0!==r&&!r&&(m!==this._effect&&n.resetCachedMaterial(),this._renderId=n.getRenderId(),this._effect._wasPreviouslyReady=!0,!0)},r.prototype.bindOnlyWorldMatrix=function(e,t){var i=this.getScene(),r=null!=t?t:this._effect;r&&(-1!==this._options.uniforms.indexOf("world")&&r.setMatrix("world",e),-1!==this._options.uniforms.indexOf("worldView")&&(e.multiplyToRef(i.getViewMatrix(),this._cachedWorldViewMatrix),r.setMatrix("worldView",this._cachedWorldViewMatrix)),-1!==this._options.uniforms.indexOf("worldViewProjection")&&(e.multiplyToRef(i.getTransformMatrix(),this._cachedWorldViewProjectionMatrix),r.setMatrix("worldViewProjection",this._cachedWorldViewProjectionMatrix)))},r.prototype.bindForSubMesh=function(e,t,i){this.bind(e,t,i._effectOverride)},r.prototype.bind=function(e,t,i){this.bindOnlyWorldMatrix(e,i);var r=null!=i?i:this._effect;if(r&&this.getScene().getCachedMaterial()!==this){var n;for(n in-1!==this._options.uniforms.indexOf("view")&&r.setMatrix("view",this.getScene().getViewMatrix()),-1!==this._options.uniforms.indexOf("projection")&&r.setMatrix("projection",this.getScene().getProjectionMatrix()),-1!==this._options.uniforms.indexOf("viewProjection")&&(r.setMatrix("viewProjection",this.getScene().getTransformMatrix()),this._multiview&&r.setMatrix("viewProjectionR",this.getScene()._transformMatrixR)),this.getScene().activeCamera&&-1!==this._options.uniforms.indexOf("cameraPosition")&&r.setVector3("cameraPosition",this.getScene().activeCamera.globalPosition),Xi.BindBonesParameters(t,r),this._textures)r.setTexture(n,this._textures[n]);for(n in this._textureArrays)r.setTextureArray(n,this._textureArrays[n]);for(n in this._ints)r.setInt(n,this._ints[n]);for(n in this._floats)r.setFloat(n,this._floats[n]);for(n in this._floatsArrays)r.setArray(n,this._floatsArrays[n]);for(n in this._colors3)r.setColor3(n,this._colors3[n]);for(n in this._colors3Arrays)r.setArray3(n,this._colors3Arrays[n]);for(n in this._colors4){var o=this._colors4[n];r.setFloat4(n,o.r,o.g,o.b,o.a)}for(n in this._colors4Arrays)r.setArray4(n,this._colors4Arrays[n]);for(n in this._vectors2)r.setVector2(n,this._vectors2[n]);for(n in this._vectors3)r.setVector3(n,this._vectors3[n]);for(n in this._vectors4)r.setVector4(n,this._vectors4[n]);for(n in this._matrices)r.setMatrix(n,this._matrices[n]);for(n in this._matrixArrays)r.setMatrices(n,this._matrixArrays[n]);for(n in this._matrices3x3)r.setMatrix3x3(n,this._matrices3x3[n]);for(n in this._matrices2x2)r.setMatrix2x2(n,this._matrices2x2[n]);for(n in this._vectors2Arrays)r.setArray2(n,this._vectors2Arrays[n]);for(n in this._vectors3Arrays)r.setArray3(n,this._vectors3Arrays[n]);for(n in this._vectors4Arrays)r.setArray4(n,this._vectors4Arrays[n])}var s=this._effect;this._effect=r,this._afterBind(t),this._effect=s},r.prototype._afterBind=function(t){e.prototype._afterBind.call(this,t),this.getScene()._cachedEffect=this._effect},r.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);for(var i in this._textures)t.push(this._textures[i]);for(var i in this._textureArrays)for(var r=this._textureArrays[i],n=0;n<r.length;n++)t.push(r[n]);return t},r.prototype.hasTexture=function(t){if(e.prototype.hasTexture.call(this,t))return!0;for(var i in this._textures)if(this._textures[i]===t)return!0;for(var i in this._textureArrays)for(var r=this._textureArrays[i],n=0;n<r.length;n++)if(r[n]===t)return!0;return!1},r.prototype.clone=function(e){var t=this,n=N.Clone((function(){return new r(e,t.getScene(),t._shaderPath,t._options)}),this);for(var o in n.name=e,n.id=e,"object"==typeof n._shaderPath&&(n._shaderPath=i({},n._shaderPath)),this._options=i({},this._options),Object.keys(this._options).forEach((function(e){var i=t._options[e];Array.isArray(i)&&(t._options[e]=i.slice(0))})),this._textures)n.setTexture(o,this._textures[o]);for(var o in this._floats)n.setFloat(o,this._floats[o]);for(var o in this._floatsArrays)n.setFloats(o,this._floatsArrays[o]);for(var o in this._colors3)n.setColor3(o,this._colors3[o]);for(var o in this._colors4)n.setColor4(o,this._colors4[o]);for(var o in this._vectors2)n.setVector2(o,this._vectors2[o]);for(var o in this._vectors3)n.setVector3(o,this._vectors3[o]);for(var o in this._vectors4)n.setVector4(o,this._vectors4[o]);for(var o in this._matrices)n.setMatrix(o,this._matrices[o]);for(var o in this._matrices3x3)n.setMatrix3x3(o,this._matrices3x3[o]);for(var o in this._matrices2x2)n.setMatrix2x2(o,this._matrices2x2[o]);return n},r.prototype.dispose=function(t,i,r){if(i){var n;for(n in this._textures)this._textures[n].dispose();for(n in this._textureArrays)for(var o=this._textureArrays[n],s=0;s<o.length;s++)o[s].dispose()}this._textures={},e.prototype.dispose.call(this,t,i,r)},r.prototype.serialize=function(){var e,t=N.Serialize(this);for(e in t.customType="BABYLON.ShaderMaterial",t.options=this._options,t.shaderPath=this._shaderPath,t.textures={},this._textures)t.textures[e]=this._textures[e].serialize();for(e in t.textureArrays={},this._textureArrays){t.textureArrays[e]=[];for(var i=this._textureArrays[e],r=0;r<i.length;r++)t.textureArrays[e].push(i[r].serialize())}for(e in t.floats={},this._floats)t.floats[e]=this._floats[e];for(e in t.FloatArrays={},this._floatsArrays)t.FloatArrays[e]=this._floatsArrays[e];for(e in t.colors3={},this._colors3)t.colors3[e]=this._colors3[e].asArray();for(e in t.colors3Arrays={},this._colors3Arrays)t.colors3Arrays[e]=this._colors3Arrays[e];for(e in t.colors4={},this._colors4)t.colors4[e]=this._colors4[e].asArray();for(e in t.colors4Arrays={},this._colors4Arrays)t.colors4Arrays[e]=this._colors4Arrays[e];for(e in t.vectors2={},this._vectors2)t.vectors2[e]=this._vectors2[e].asArray();for(e in t.vectors3={},this._vectors3)t.vectors3[e]=this._vectors3[e].asArray();for(e in t.vectors4={},this._vectors4)t.vectors4[e]=this._vectors4[e].asArray();for(e in t.matrices={},this._matrices)t.matrices[e]=this._matrices[e].asArray();for(e in t.matrixArray={},this._matrixArrays)t.matrixArray[e]=this._matrixArrays[e];for(e in t.matrices3x3={},this._matrices3x3)t.matrices3x3[e]=this._matrices3x3[e];for(e in t.matrices2x2={},this._matrices2x2)t.matrices2x2[e]=this._matrices2x2[e];for(e in t.vectors2Arrays={},this._vectors2Arrays)t.vectors2Arrays[e]=this._vectors2Arrays[e];for(e in t.vectors3Arrays={},this._vectors3Arrays)t.vectors3Arrays[e]=this._vectors3Arrays[e];for(e in t.vectors4Arrays={},this._vectors4Arrays)t.vectors4Arrays[e]=this._vectors4Arrays[e];return t},r.Parse=function(e,t,i){var n,o=N.Parse((function(){return new r(e.name,t,e.shaderPath,e.options)}),e,t,i);for(n in e.textures)o.setTexture(n,Re.Parse(e.textures[n],t,i));for(n in e.textureArrays){for(var s=e.textureArrays[n],a=new Array,h=0;h<s.length;h++)a.push(Re.Parse(s[h],t,i));o.setTextureArray(n,a)}for(n in e.floats)o.setFloat(n,e.floats[n]);for(n in e.floatsArrays)o.setFloats(n,e.floatsArrays[n]);for(n in e.colors3)o.setColor3(n,T.FromArray(e.colors3[n]));for(n in e.colors3Arrays){var u=e.colors3Arrays[n].reduce((function(e,t,i){return i%3==0?e.push([t]):e[e.length-1].push(t),e}),[]).map((function(e){return T.FromArray(e)}));o.setColor3Array(n,u)}for(n in e.colors4)o.setColor4(n,E.FromArray(e.colors4[n]));for(n in e.colors4Arrays){u=e.colors4Arrays[n].reduce((function(e,t,i){return i%4==0?e.push([t]):e[e.length-1].push(t),e}),[]).map((function(e){return E.FromArray(e)}));o.setColor4Array(n,u)}for(n in e.vectors2)o.setVector2(n,d.FromArray(e.vectors2[n]));for(n in e.vectors3)o.setVector3(n,p.FromArray(e.vectors3[n]));for(n in e.vectors4)o.setVector4(n,_.FromArray(e.vectors4[n]));for(n in e.matrices)o.setMatrix(n,m.FromArray(e.matrices[n]));for(n in e.matrixArray)o._matrixArrays[n]=new Float32Array(e.matrixArray[n]);for(n in e.matrices3x3)o.setMatrix3x3(n,e.matrices3x3[n]);for(n in e.matrices2x2)o.setMatrix2x2(n,e.matrices2x2[n]);for(n in e.vectors2Arrays)o.setArray2(n,e.vectors2Arrays[n]);for(n in e.vectors3Arrays)o.setArray3(n,e.vectors3Arrays[n]);for(n in e.vectors4Arrays)o.setArray4(n,e.vectors4Arrays[n]);return o},r.ParseFromFileAsync=function(e,t,i,r){var n=this;return void 0===r&&(r=""),new Promise((function(o,s){var a=new G;a.addEventListener("readystatechange",(function(){if(4==a.readyState)if(200==a.status){var t=JSON.parse(a.responseText),h=n.Parse(t,i||Ot.LastCreatedScene,r);e&&(h.name=e),o(h)}else s("Unable to load the ShaderMaterial")})),a.open("GET",t),a.send()}))},r.CreateFromSnippetAsync=function(e,t,i){var r=this;return void 0===i&&(i=""),new Promise((function(n,o){var s=new G;s.addEventListener("readystatechange",(function(){if(4==s.readyState)if(200==s.status){var a=JSON.parse(JSON.parse(s.responseText).jsonPayload),h=JSON.parse(a.shaderMaterial),u=r.Parse(h,t||Ot.LastCreatedScene,i);u.snippetId=e,n(u)}else o("Unable to load the snippet "+e)})),s.open("GET",r.SnippetUrl+"/"+e.replace(/#/g,"/")),s.send()}))},r.SnippetUrl="https://snippet.babylonjs.com",r}(Vt);c.RegisteredTypes["BABYLON.ShaderMaterial"]=Yi;var qi=function(){function e(){this.previousWorldMatrices={},this.previousBones={}}return e.AddUniforms=function(e){e.push("previousWorld","previousViewProjection")},e.AddSamplers=function(e){},e.prototype.bindForSubMesh=function(e,t,i,r,n){t.prePassRenderer&&t.prePassRenderer.enabled&&-1!==t.prePassRenderer.getIndex(2)&&(this.previousWorldMatrices[i.uniqueId]||(this.previousWorldMatrices[i.uniqueId]=m.Identity()),this.previousViewProjection||(this.previousViewProjection=t.getTransformMatrix()),e.setMatrix("previousWorld",this.previousWorldMatrices[i.uniqueId]),e.setMatrix("previousViewProjection",this.previousViewProjection),this.previousWorldMatrices[i.uniqueId]=r.clone(),this.previousViewProjection=t.getTransformMatrix().clone())},e}(),Zi=function(e){function i(t,i){var r=e.call(this,t,i)||this;return r._normalMatrix=new m,r._storeEffectOnSubMeshes=!0,r}return t(i,e),i.prototype.getEffect=function(){return this._activeEffect},i.prototype.isReady=function(e,t){return!!e&&(!e.subMeshes||0===e.subMeshes.length||this.isReadyForSubMesh(e,e.subMeshes[0],t))},i.prototype._isReadyForSubMesh=function(e){var t=e._materialDefines;return!(this.checkReadyOnEveryCall||!e.effect||!t||t._renderId!==this.getScene().getRenderId())},i.prototype.bindOnlyWorldMatrix=function(e){this._activeEffect.setMatrix("world",e)},i.prototype.bindOnlyNormalMatrix=function(e){this._activeEffect.setMatrix("normalMatrix",e)},i.prototype.bind=function(e,t){t&&this.bindForSubMesh(e,t,t.subMeshes[0])},i.prototype._afterBind=function(t,i){void 0===i&&(i=null),e.prototype._afterBind.call(this,t),this.getScene()._cachedEffect=i},i.prototype._mustRebind=function(e,t,i){return void 0===i&&(i=1),e.isCachedMaterialInvalid(this,t,i)},i}(Vt),Qi=function(){function e(){}return Object.defineProperty(e,"DiffuseTextureEnabled",{get:function(){return this._DiffuseTextureEnabled},set:function(e){this._DiffuseTextureEnabled!==e&&(this._DiffuseTextureEnabled=e,Ot.MarkAllMaterialsAsDirty(1))},enumerable:!1,configurable:!0}),Object.defineProperty(e,"DetailTextureEnabled",{get:function(){return this._DetailTextureEnabled},set:function(e){this._DetailTextureEnabled!==e&&(this._DetailTextureEnabled=e,Ot.MarkAllMaterialsAsDirty(1))},enumerable:!1,configurable:!0}),Object.defineProperty(e,"AmbientTextureEnabled",{get:function(){return this._AmbientTextureEnabled},set:function(e){this._AmbientTextureEnabled!==e&&(this._AmbientTextureEnabled=e,Ot.MarkAllMaterialsAsDirty(1))},enumerable:!1,configurable:!0}),Object.defineProperty(e,"OpacityTextureEnabled",{get:function(){return this._OpacityTextureEnabled},set:function(e){this._OpacityTextureEnabled!==e&&(this._OpacityTextureEnabled=e,Ot.MarkAllMaterialsAsDirty(1))},enumerable:!1,configurable:!0}),Object.defineProperty(e,"ReflectionTextureEnabled",{get:function(){return this._ReflectionTextureEnabled},set:function(e){this._ReflectionTextureEnabled!==e&&(this._ReflectionTextureEnabled=e,Ot.MarkAllMaterialsAsDirty(1))},enumerable:!1,configurable:!0}),Object.defineProperty(e,"EmissiveTextureEnabled",{get:function(){return this._EmissiveTextureEnabled},set:function(e){this._EmissiveTextureEnabled!==e&&(this._EmissiveTextureEnabled=e,Ot.MarkAllMaterialsAsDirty(1))},enumerable:!1,configurable:!0}),Object.defineProperty(e,"SpecularTextureEnabled",{get:function(){return this._SpecularTextureEnabled},set:function(e){this._SpecularTextureEnabled!==e&&(this._SpecularTextureEnabled=e,Ot.MarkAllMaterialsAsDirty(1))},enumerable:!1,configurable:!0}),Object.defineProperty(e,"BumpTextureEnabled",{get:function(){return this._BumpTextureEnabled},set:function(e){this._BumpTextureEnabled!==e&&(this._BumpTextureEnabled=e,Ot.MarkAllMaterialsAsDirty(1))},enumerable:!1,configurable:!0}),Object.defineProperty(e,"LightmapTextureEnabled",{get:function(){return this._LightmapTextureEnabled},set:function(e){this._LightmapTextureEnabled!==e&&(this._LightmapTextureEnabled=e,Ot.MarkAllMaterialsAsDirty(1))},enumerable:!1,configurable:!0}),Object.defineProperty(e,"RefractionTextureEnabled",{get:function(){return this._RefractionTextureEnabled},set:function(e){this._RefractionTextureEnabled!==e&&(this._RefractionTextureEnabled=e,Ot.MarkAllMaterialsAsDirty(1))},enumerable:!1,configurable:!0}),Object.defineProperty(e,"ColorGradingTextureEnabled",{get:function(){return this._ColorGradingTextureEnabled},set:function(e){this._ColorGradingTextureEnabled!==e&&(this._ColorGradingTextureEnabled=e,Ot.MarkAllMaterialsAsDirty(1))},enumerable:!1,configurable:!0}),Object.defineProperty(e,"FresnelEnabled",{get:function(){return this._FresnelEnabled},set:function(e){this._FresnelEnabled!==e&&(this._FresnelEnabled=e,Ot.MarkAllMaterialsAsDirty(4))},enumerable:!1,configurable:!0}),Object.defineProperty(e,"ClearCoatTextureEnabled",{get:function(){return this._ClearCoatTextureEnabled},set:function(e){this._ClearCoatTextureEnabled!==e&&(this._ClearCoatTextureEnabled=e,Ot.MarkAllMaterialsAsDirty(1))},enumerable:!1,configurable:!0}),Object.defineProperty(e,"ClearCoatBumpTextureEnabled",{get:function(){return this._ClearCoatBumpTextureEnabled},set:function(e){this._ClearCoatBumpTextureEnabled!==e&&(this._ClearCoatBumpTextureEnabled=e,Ot.MarkAllMaterialsAsDirty(1))},enumerable:!1,configurable:!0}),Object.defineProperty(e,"ClearCoatTintTextureEnabled",{get:function(){return this._ClearCoatTintTextureEnabled},set:function(e){this._ClearCoatTintTextureEnabled!==e&&(this._ClearCoatTintTextureEnabled=e,Ot.MarkAllMaterialsAsDirty(1))},enumerable:!1,configurable:!0}),Object.defineProperty(e,"SheenTextureEnabled",{get:function(){return this._SheenTextureEnabled},set:function(e){this._SheenTextureEnabled!==e&&(this._SheenTextureEnabled=e,Ot.MarkAllMaterialsAsDirty(1))},enumerable:!1,configurable:!0}),Object.defineProperty(e,"AnisotropicTextureEnabled",{get:function(){return this._AnisotropicTextureEnabled},set:function(e){this._AnisotropicTextureEnabled!==e&&(this._AnisotropicTextureEnabled=e,Ot.MarkAllMaterialsAsDirty(1))},enumerable:!1,configurable:!0}),Object.defineProperty(e,"ThicknessTextureEnabled",{get:function(){return this._ThicknessTextureEnabled},set:function(e){this._ThicknessTextureEnabled!==e&&(this._ThicknessTextureEnabled=e,Ot.MarkAllMaterialsAsDirty(1))},enumerable:!1,configurable:!0}),e._DiffuseTextureEnabled=!0,e._DetailTextureEnabled=!0,e._AmbientTextureEnabled=!0,e._OpacityTextureEnabled=!0,e._ReflectionTextureEnabled=!0,e._EmissiveTextureEnabled=!0,e._SpecularTextureEnabled=!0,e._BumpTextureEnabled=!0,e._LightmapTextureEnabled=!0,e._RefractionTextureEnabled=!0,e._ColorGradingTextureEnabled=!0,e._FresnelEnabled=!0,e._ClearCoatTextureEnabled=!0,e._ClearCoatBumpTextureEnabled=!0,e._ClearCoatTintTextureEnabled=!0,e._SheenTextureEnabled=!0,e._AnisotropicTextureEnabled=!0,e._ThicknessTextureEnabled=!0,e}();he.IncludesShadersStore.defaultFragmentDeclaration="uniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nuniform vec3 vEmissiveColor;\nuniform float visibility;\n\n#ifdef DIFFUSE\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\n#ifndef REFRACTIONMAP_3D\nuniform mat4 refractionMatrix;\n#endif\n#ifdef REFRACTIONFRESNEL\nuniform vec4 refractionLeftColor;\nuniform vec4 refractionRightColor;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nuniform vec2 vSpecularInfos;\n#endif\n#ifdef DIFFUSEFRESNEL\nuniform vec4 diffuseLeftColor;\nuniform vec4 diffuseRightColor;\n#endif\n#ifdef OPACITYFRESNEL\nuniform vec4 opacityParts;\n#endif\n#ifdef EMISSIVEFRESNEL\nuniform vec4 emissiveLeftColor;\nuniform vec4 emissiveRightColor;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\n#if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION) || defined(REFLECTIONMAP_EQUIRECTANGULAR) || defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_SKYBOX)\nuniform mat4 reflectionMatrix;\n#endif\n#ifndef REFLECTIONMAP_SKYBOX\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize;\n#endif\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 reflectionLeftColor;\nuniform vec4 reflectionRightColor;\n#endif\n#endif";he.IncludesShadersStore.defaultUboDeclaration="layout(std140,column_major) uniform;\nuniform Material\n{\nvec4 diffuseLeftColor;\nvec4 diffuseRightColor;\nvec4 opacityParts;\nvec4 reflectionLeftColor;\nvec4 reflectionRightColor;\nvec4 refractionLeftColor;\nvec4 refractionRightColor;\nvec4 emissiveLeftColor;\nvec4 emissiveRightColor;\nvec2 vDiffuseInfos;\nvec2 vAmbientInfos;\nvec2 vOpacityInfos;\nvec2 vReflectionInfos;\nvec3 vReflectionPosition;\nvec3 vReflectionSize;\nvec2 vEmissiveInfos;\nvec2 vLightmapInfos;\nvec2 vSpecularInfos;\nvec3 vBumpInfos;\nmat4 diffuseMatrix;\nmat4 ambientMatrix;\nmat4 opacityMatrix;\nmat4 reflectionMatrix;\nmat4 emissiveMatrix;\nmat4 lightmapMatrix;\nmat4 specularMatrix;\nmat4 bumpMatrix;\nvec2 vTangentSpaceParams;\nfloat pointSize;\nmat4 refractionMatrix;\nvec4 vRefractionInfos;\nvec4 vSpecularColor;\nvec3 vEmissiveColor;\nfloat visibility;\nvec4 vDiffuseColor;\nvec4 vDetailInfos;\nmat4 detailMatrix;\n};\nuniform Scene {\nmat4 viewProjection;\n#ifdef MULTIVIEW\nmat4 viewProjectionR;\n#endif\nmat4 view;\n};\n";he.IncludesShadersStore.prePassDeclaration="#ifdef PREPASS\n#extension GL_EXT_draw_buffers : require\n#ifdef WEBGL2\nlayout(location=0) out highp vec4 glFragData[{X}];\nhighp vec4 gl_FragColor;\n#endif\n#ifdef PREPASS_DEPTHNORMAL\nvarying highp vec3 vViewPos;\n#endif\n#ifdef PREPASS_VELOCITY\nvarying highp vec4 vCurrentPosition;\nvarying highp vec4 vPreviousPosition;\n#endif\n#endif\n";he.IncludesShadersStore.lightFragmentDeclaration="#ifdef LIGHT{X}\nuniform vec4 vLightData{X};\nuniform vec4 vLightDiffuse{X};\n#ifdef SPECULARTERM\nuniform vec4 vLightSpecular{X};\n#else\nvec4 vLightSpecular{X}=vec4(0.);\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCSM{X}\nuniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float cascadeBlendFactor{X};\nvarying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying vec4 vPositionFromCamera{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DArrayShadow shadowSampler{X};\nuniform highp sampler2DArray depthSampler{X};\nuniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float penumbraDarkness{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DArrayShadow shadowSampler{X};\n#else\nuniform highp sampler2DArray shadowSampler{X};\n#endif\n#ifdef SHADOWCSMDEBUG{X}\nconst vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]\n(\nvec3 ( 1.5,0.0,0.0 ),\nvec3 ( 0.0,1.5,0.0 ),\nvec3 ( 0.0,0.0,5.5 ),\nvec3 ( 1.5,0.0,5.5 ),\nvec3 ( 1.5,1.5,0.0 ),\nvec3 ( 1.0,1.0,1.0 ),\nvec3 ( 0.0,1.0,5.5 ),\nvec3 ( 0.5,3.5,0.75 )\n);\nvec3 shadowDebug{X};\n#endif\n#ifdef SHADOWCSMUSESHADOWMAXZ{X}\nint index{X}=-1;\n#else\nint index{X}=SHADOWCSMNUM_CASCADES{X}-1;\n#endif\nfloat diff{X}=0.;\n#elif defined(SHADOWCUBE{X})\nuniform samplerCube shadowSampler{X};\n#else\nvarying vec4 vPositionFromLight{X};\nvarying float vDepthMetric{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DShadow shadowSampler{X};\nuniform highp sampler2D depthSampler{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DShadow shadowSampler{X};\n#else\nuniform sampler2D shadowSampler{X};\n#endif\nuniform mat4 lightMatrix{X};\n#endif\nuniform vec4 shadowsInfo{X};\nuniform vec2 depthValues{X};\n#endif\n#ifdef SPOTLIGHT{X}\nuniform vec4 vLightDirection{X};\nuniform vec4 vLightFalloff{X};\n#elif defined(POINTLIGHT{X})\nuniform vec4 vLightFalloff{X};\n#elif defined(HEMILIGHT{X})\nuniform vec3 vLightGround{X};\n#endif\n#ifdef PROJECTEDLIGHTTEXTURE{X}\nuniform mat4 textureProjectionMatrix{X};\nuniform sampler2D projectionLightSampler{X};\n#endif\n#endif";he.IncludesShadersStore.lightUboDeclaration="#ifdef LIGHT{X}\nuniform Light{X}\n{\nvec4 vLightData;\nvec4 vLightDiffuse;\nvec4 vLightSpecular;\n#ifdef SPOTLIGHT{X}\nvec4 vLightDirection;\nvec4 vLightFalloff;\n#elif defined(POINTLIGHT{X})\nvec4 vLightFalloff;\n#elif defined(HEMILIGHT{X})\nvec3 vLightGround;\n#endif\nvec4 shadowsInfo;\nvec2 depthValues;\n} light{X};\n#ifdef PROJECTEDLIGHTTEXTURE{X}\nuniform mat4 textureProjectionMatrix{X};\nuniform sampler2D projectionLightSampler{X};\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCSM{X}\nuniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float cascadeBlendFactor{X};\nvarying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying vec4 vPositionFromCamera{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DArrayShadow shadowSampler{X};\nuniform highp sampler2DArray depthSampler{X};\nuniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float penumbraDarkness{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DArrayShadow shadowSampler{X};\n#else\nuniform highp sampler2DArray shadowSampler{X};\n#endif\n#ifdef SHADOWCSMDEBUG{X}\nconst vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]\n(\nvec3 ( 1.5,0.0,0.0 ),\nvec3 ( 0.0,1.5,0.0 ),\nvec3 ( 0.0,0.0,5.5 ),\nvec3 ( 1.5,0.0,5.5 ),\nvec3 ( 1.5,1.5,0.0 ),\nvec3 ( 1.0,1.0,1.0 ),\nvec3 ( 0.0,1.0,5.5 ),\nvec3 ( 0.5,3.5,0.75 )\n);\nvec3 shadowDebug{X};\n#endif\n#ifdef SHADOWCSMUSESHADOWMAXZ{X}\nint index{X}=-1;\n#else\nint index{X}=SHADOWCSMNUM_CASCADES{X}-1;\n#endif\nfloat diff{X}=0.;\n#elif defined(SHADOWCUBE{X})\nuniform samplerCube shadowSampler{X};\n#else\nvarying vec4 vPositionFromLight{X};\nvarying float vDepthMetric{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DShadow shadowSampler{X};\nuniform highp sampler2D depthSampler{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DShadow shadowSampler{X};\n#else\nuniform sampler2D shadowSampler{X};\n#endif\nuniform mat4 lightMatrix{X};\n#endif\n#endif\n#endif";he.IncludesShadersStore.lightsFragmentFunctions="\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n#ifdef NDOTL\nfloat ndl;\n#endif\n};\nlightingInfo computeLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {\nlightingInfo result;\nvec3 lightVectorW;\nfloat attenuation=1.0;\nif (lightData.w == 0.)\n{\nvec3 direction=lightData.xyz-vPositionW;\nattenuation=max(0.,1.0-length(direction)/range);\nlightVectorW=normalize(direction);\n}\nelse\n{\nlightVectorW=normalize(-lightData.xyz);\n}\n\nfloat ndl=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\n\nvec3 angleW=normalize(viewDirectionW+lightVectorW);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {\nlightingInfo result;\nvec3 direction=lightData.xyz-vPositionW;\nvec3 lightVectorW=normalize(direction);\nfloat attenuation=max(0.,1.0-length(direction)/range);\n\nfloat cosAngle=max(0.,dot(lightDirection.xyz,-lightVectorW));\nif (cosAngle>=lightDirection.w)\n{\ncosAngle=max(0.,pow(cosAngle,lightData.w));\nattenuation*=cosAngle;\n\nfloat ndl=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\n\nvec3 angleW=normalize(viewDirectionW+lightVectorW);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;\n}\nresult.diffuse=vec3(0.);\n#ifdef SPECULARTERM\nresult.specular=vec3(0.);\n#endif\n#ifdef NDOTL\nresult.ndl=0.;\n#endif\nreturn result;\n}\nlightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float glossiness) {\nlightingInfo result;\n\nfloat ndl=dot(vNormal,lightData.xyz)*0.5+0.5;\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=mix(groundColor,diffuseColor,ndl);\n#ifdef SPECULARTERM\n\nvec3 angleW=normalize(viewDirectionW+lightData.xyz);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor;\n#endif\nreturn result;\n}\n#define inline\nvec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){\nvec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);\nstrq/=strq.w;\nvec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;\nreturn textureColor;\n}";he.IncludesShadersStore.shadowsFragmentFunctions="#ifdef SHADOWS\n#ifndef SHADOWFLOAT\n\nfloat unpack(vec4 color)\n{\nconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\nreturn dot(color,bit_shift);\n}\n#endif\nfloat computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)\n{\nfloat mask=smoothstep(1.0-frustumEdgeFalloff,1.00000012,clamp(dot(clipSpace,clipSpace),0.,1.));\nreturn mix(value,1.0,mask);\n}\n#define inline\nfloat computeShadowCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadow=textureCube(shadowSampler,directionToLight).x;\n#endif\nreturn depth>shadow ? darkness : 1.0;\n}\n#define inline\nfloat computeShadowWithPoissonSamplingCube(vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\nfloat visibility=1.;\nvec3 poissonDisk[4];\npoissonDisk[0]=vec3(-1.0,1.0,-1.0);\npoissonDisk[1]=vec3(1.0,-1.0,-1.0);\npoissonDisk[2]=vec3(-1.0,-1.0,-1.0);\npoissonDisk[3]=vec3(1.0,-1.0,1.0);\n\n#ifndef SHADOWFLOAT\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize))<depth) visibility-=0.25;\n#else\nif (textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize).x<depth) visibility-=0.25;\n#endif\nreturn min(1.0,visibility+darkness);\n}\n#define inline\nfloat computeShadowWithESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);\nreturn esm;\n}\n#define inline\nfloat computeShadowWithCloseESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn esm;\n}\n#ifdef WEBGL2\n#define inline\nfloat computeShadowCSM(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nvec3 uvLayer=vec3(uv.x,uv.y,layer);\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uvLayer));\n#else\nfloat shadow=texture2D(shadowSampler,uvLayer).x;\n#endif\nreturn shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;\n}\n#endif\n#define inline\nfloat computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nelse\n{\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadow=texture2D(shadowSampler,uv).x;\n#endif\nreturn shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;\n}\n}\n#define inline\nfloat computeShadowWithPoissonSampling(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nelse\n{\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\nfloat visibility=1.;\nvec2 poissonDisk[4];\npoissonDisk[0]=vec2(-0.94201624,-0.39906216);\npoissonDisk[1]=vec2(0.94558609,-0.76890725);\npoissonDisk[2]=vec2(-0.094184101,-0.92938870);\npoissonDisk[3]=vec2(0.34495938,0.29387760);\n\n#ifndef SHADOWFLOAT\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[1]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[2]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[3]*mapSize))<shadowPixelDepth) visibility-=0.25;\n#else\nif (texture2D(shadowSampler,uv+poissonDisk[0]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[1]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[2]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[3]*mapSize).x<shadowPixelDepth) visibility-=0.25;\n#endif\nreturn computeFallOff(min(1.0,visibility+darkness),clipSpace.xy,frustumEdgeFalloff);\n}\n}\n#define inline\nfloat computeShadowWithESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nelse\n{\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\n}\n#define inline\nfloat computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nelse\n{\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\n}\n#ifdef WEBGL2\n#define GREATEST_LESS_THAN_ONE 0.99999994\n\n#define inline\nfloat computeShadowWithCSMPCF1(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=clamp(uvDepth.z,0.,GREATEST_LESS_THAN_ONE);\nvec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);\nfloat shadow=texture(shadowSampler,uvDepthLayer);\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n\n\n\n#define inline\nfloat computeShadowWithCSMPCF3(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=clamp(uvDepth.z,0.,GREATEST_LESS_THAN_ONE);\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;\nuv+=0.5;\nvec2 st=fract(uv);\nvec2 base_uv=floor(uv)-0.5;\nbase_uv*=shadowMapSizeAndInverse.y;\n\n\n\n\nvec2 uvw0=3.-2.*st;\nvec2 uvw1=1.+2.*st;\nvec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;\nvec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));\nshadow=shadow/16.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n\n\n\n#define inline\nfloat computeShadowWithCSMPCF5(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=clamp(uvDepth.z,0.,GREATEST_LESS_THAN_ONE);\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;\nuv+=0.5;\nvec2 st=fract(uv);\nvec2 base_uv=floor(uv)-0.5;\nbase_uv*=shadowMapSizeAndInverse.y;\n\n\nvec2 uvw0=4.-3.*st;\nvec2 uvw1=vec2(7.);\nvec2 uvw2=1.+3.*st;\nvec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;\nvec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));\nshadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[0]),layer,uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));\nshadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[1]),layer,uvDepth.z));\nshadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[2]),layer,uvDepth.z));\nshadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[2]),layer,uvDepth.z));\nshadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[2]),layer,uvDepth.z));\nshadow=shadow/144.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n\n#define inline\nfloat computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nelse\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nfloat shadow=texture2D(shadowSampler,uvDepth);\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n}\n\n\n\n#define inline\nfloat computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nelse\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;\nuv+=0.5;\nvec2 st=fract(uv);\nvec2 base_uv=floor(uv)-0.5;\nbase_uv*=shadowMapSizeAndInverse.y;\n\n\n\n\nvec2 uvw0=3.-2.*st;\nvec2 uvw1=1.+2.*st;\nvec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;\nvec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));\nshadow=shadow/16.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n}\n\n\n\n#define inline\nfloat computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nelse\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;\nuv+=0.5;\nvec2 st=fract(uv);\nvec2 base_uv=floor(uv)-0.5;\nbase_uv*=shadowMapSizeAndInverse.y;\n\n\nvec2 uvw0=4.-3.*st;\nvec2 uvw1=vec2(7.);\nvec2 uvw2=1.+3.*st;\nvec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;\nvec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));\nshadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[0]),uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));\nshadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[1]),uvDepth.z));\nshadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[2]),uvDepth.z));\nshadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[2]),uvDepth.z));\nshadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[2]),uvDepth.z));\nshadow=shadow/144.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n}\nconst vec3 PoissonSamplers32[64]=vec3[64](\nvec3(0.06407013,0.05409927,0.),\nvec3(0.7366577,0.5789394,0.),\nvec3(-0.6270542,-0.5320278,0.),\nvec3(-0.4096107,0.8411095,0.),\nvec3(0.6849564,-0.4990818,0.),\nvec3(-0.874181,-0.04579735,0.),\nvec3(0.9989998,0.0009880066,0.),\nvec3(-0.004920578,-0.9151649,0.),\nvec3(0.1805763,0.9747483,0.),\nvec3(-0.2138451,0.2635818,0.),\nvec3(0.109845,0.3884785,0.),\nvec3(0.06876755,-0.3581074,0.),\nvec3(0.374073,-0.7661266,0.),\nvec3(0.3079132,-0.1216763,0.),\nvec3(-0.3794335,-0.8271583,0.),\nvec3(-0.203878,-0.07715034,0.),\nvec3(0.5912697,0.1469799,0.),\nvec3(-0.88069,0.3031784,0.),\nvec3(0.5040108,0.8283722,0.),\nvec3(-0.5844124,0.5494877,0.),\nvec3(0.6017799,-0.1726654,0.),\nvec3(-0.5554981,0.1559997,0.),\nvec3(-0.3016369,-0.3900928,0.),\nvec3(-0.5550632,-0.1723762,0.),\nvec3(0.925029,0.2995041,0.),\nvec3(-0.2473137,0.5538505,0.),\nvec3(0.9183037,-0.2862392,0.),\nvec3(0.2469421,0.6718712,0.),\nvec3(0.3916397,-0.4328209,0.),\nvec3(-0.03576927,-0.6220032,0.),\nvec3(-0.04661255,0.7995201,0.),\nvec3(0.4402924,0.3640312,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.)\n);\nconst vec3 PoissonSamplers64[64]=vec3[64](\nvec3(-0.613392,0.617481,0.),\nvec3(0.170019,-0.040254,0.),\nvec3(-0.299417,0.791925,0.),\nvec3(0.645680,0.493210,0.),\nvec3(-0.651784,0.717887,0.),\nvec3(0.421003,0.027070,0.),\nvec3(-0.817194,-0.271096,0.),\nvec3(-0.705374,-0.668203,0.),\nvec3(0.977050,-0.108615,0.),\nvec3(0.063326,0.142369,0.),\nvec3(0.203528,0.214331,0.),\nvec3(-0.667531,0.326090,0.),\nvec3(-0.098422,-0.295755,0.),\nvec3(-0.885922,0.215369,0.),\nvec3(0.566637,0.605213,0.),\nvec3(0.039766,-0.396100,0.),\nvec3(0.751946,0.453352,0.),\nvec3(0.078707,-0.715323,0.),\nvec3(-0.075838,-0.529344,0.),\nvec3(0.724479,-0.580798,0.),\nvec3(0.222999,-0.215125,0.),\nvec3(-0.467574,-0.405438,0.),\nvec3(-0.248268,-0.814753,0.),\nvec3(0.354411,-0.887570,0.),\nvec3(0.175817,0.382366,0.),\nvec3(0.487472,-0.063082,0.),\nvec3(-0.084078,0.898312,0.),\nvec3(0.488876,-0.783441,0.),\nvec3(0.470016,0.217933,0.),\nvec3(-0.696890,-0.549791,0.),\nvec3(-0.149693,0.605762,0.),\nvec3(0.034211,0.979980,0.),\nvec3(0.503098,-0.308878,0.),\nvec3(-0.016205,-0.872921,0.),\nvec3(0.385784,-0.393902,0.),\nvec3(-0.146886,-0.859249,0.),\nvec3(0.643361,0.164098,0.),\nvec3(0.634388,-0.049471,0.),\nvec3(-0.688894,0.007843,0.),\nvec3(0.464034,-0.188818,0.),\nvec3(-0.440840,0.137486,0.),\nvec3(0.364483,0.511704,0.),\nvec3(0.034028,0.325968,0.),\nvec3(0.099094,-0.308023,0.),\nvec3(0.693960,-0.366253,0.),\nvec3(0.678884,-0.204688,0.),\nvec3(0.001801,0.780328,0.),\nvec3(0.145177,-0.898984,0.),\nvec3(0.062655,-0.611866,0.),\nvec3(0.315226,-0.604297,0.),\nvec3(-0.780145,0.486251,0.),\nvec3(-0.371868,0.882138,0.),\nvec3(0.200476,0.494430,0.),\nvec3(-0.494552,-0.711051,0.),\nvec3(0.612476,0.705252,0.),\nvec3(-0.578845,-0.768792,0.),\nvec3(-0.772454,-0.090976,0.),\nvec3(0.504440,0.372295,0.),\nvec3(0.155736,0.065157,0.),\nvec3(0.391522,0.849605,0.),\nvec3(-0.620106,-0.328104,0.),\nvec3(0.789239,-0.419965,0.),\nvec3(-0.545396,0.538133,0.),\nvec3(-0.178564,-0.596057,0.)\n);\n\n\n\n\n\n#define inline\nfloat 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)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=clamp(uvDepth.z,0.,GREATEST_LESS_THAN_ONE);\nvec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);\nfloat blockerDepth=0.0;\nfloat sumBlockerDepth=0.0;\nfloat numBlocker=0.0;\nfor (int i=0; i<searchTapCount; i ++) {\nblockerDepth=texture(depthSampler,vec3(uvDepth.xy+(lightSizeUV*lightSizeUVCorrection*shadowMapSizeInverse*PoissonSamplers32[i].xy),layer)).r;\nif (blockerDepth<depthMetric) {\nsumBlockerDepth+=blockerDepth;\nnumBlocker++;\n}\n}\nif (numBlocker<1.0) {\nreturn 1.0;\n}\nelse\n{\nfloat avgBlockerDepth=sumBlockerDepth/numBlocker;\n\nfloat AAOffset=shadowMapSizeInverse*10.;\n\n\nfloat penumbraRatio=((depthMetric-avgBlockerDepth)*depthCorrection+AAOffset);\nvec4 filterRadius=vec4(penumbraRatio*lightSizeUV*lightSizeUVCorrection*shadowMapSizeInverse,0.,0.);\nfloat random=getRand(vPositionFromLight.xy);\nfloat rotationAngle=random*3.1415926;\nvec2 rotationVector=vec2(cos(rotationAngle),sin(rotationAngle));\nfloat shadow=0.;\nfor (int i=0; i<pcfTapCount; i++) {\nvec4 offset=vec4(poissonSamplers[i],0.);\n\noffset=vec4(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.,0.);\nshadow+=texture2D(shadowSampler,uvDepthLayer+offset*filterRadius);\n}\nshadow/=float(pcfTapCount);\n\nshadow=mix(shadow,1.,min((depthMetric-avgBlockerDepth)*depthCorrection*penumbraDarkness,1.));\n\nshadow=mix(darkness,1.,shadow);\n\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n}\n\n\n\n\n\n#define inline\nfloat computeShadowWithPCSS(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nelse\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nfloat blockerDepth=0.0;\nfloat sumBlockerDepth=0.0;\nfloat numBlocker=0.0;\nfor (int i=0; i<searchTapCount; i ++) {\nblockerDepth=texture(depthSampler,uvDepth.xy+(lightSizeUV*shadowMapSizeInverse*PoissonSamplers32[i].xy)).r;\nif (blockerDepth<depthMetric) {\nsumBlockerDepth+=blockerDepth;\nnumBlocker++;\n}\n}\nif (numBlocker<1.0) {\nreturn 1.0;\n}\nelse\n{\nfloat avgBlockerDepth=sumBlockerDepth/numBlocker;\n\nfloat AAOffset=shadowMapSizeInverse*10.;\n\n\nfloat penumbraRatio=((depthMetric-avgBlockerDepth)+AAOffset);\nfloat filterRadius=penumbraRatio*lightSizeUV*shadowMapSizeInverse;\nfloat random=getRand(vPositionFromLight.xy);\nfloat rotationAngle=random*3.1415926;\nvec2 rotationVector=vec2(cos(rotationAngle),sin(rotationAngle));\nfloat shadow=0.;\nfor (int i=0; i<pcfTapCount; i++) {\nvec3 offset=poissonSamplers[i];\n\noffset=vec3(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.);\nshadow+=texture2D(shadowSampler,uvDepth+offset*filterRadius);\n}\nshadow/=float(pcfTapCount);\n\nshadow=mix(shadow,1.,depthMetric-avgBlockerDepth);\n\nshadow=mix(darkness,1.,shadow);\n\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n}\n}\n#define inline\nfloat computeShadowWithPCSS16(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32);\n}\n#define inline\nfloat computeShadowWithPCSS32(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32);\n}\n#define inline\nfloat computeShadowWithPCSS64(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64);\n}\n#define inline\nfloat computeShadowWithCSMPCSS16(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)\n{\nreturn computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);\n}\n#define inline\nfloat computeShadowWithCSMPCSS32(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)\n{\nreturn computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);\n}\n#define inline\nfloat computeShadowWithCSMPCSS64(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)\n{\nreturn computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64,lightSizeUVCorrection,depthCorrection,penumbraDarkness);\n}\n#endif\n#endif\n";he.IncludesShadersStore.fresnelFunction="#ifdef FRESNEL\nfloat computeFresnelTerm(vec3 viewDirection,vec3 worldNormal,float bias,float power)\n{\nfloat fresnelTerm=pow(bias+abs(dot(viewDirection,worldNormal)),power);\nreturn clamp(fresnelTerm,0.,1.);\n}\n#endif";he.IncludesShadersStore.reflectionFunction="vec3 parallaxCorrectNormal( vec3 vertexPos,vec3 origVec,vec3 cubeSize,vec3 cubePos ) {\n\nvec3 invOrigVec=vec3(1.0,1.0,1.0)/origVec;\nvec3 halfSize=cubeSize*0.5;\nvec3 intersecAtMaxPlane=(cubePos+halfSize-vertexPos)*invOrigVec;\nvec3 intersecAtMinPlane=(cubePos-halfSize-vertexPos)*invOrigVec;\n\nvec3 largestIntersec=max(intersecAtMaxPlane,intersecAtMinPlane);\n\nfloat distance=min(min(largestIntersec.x,largestIntersec.y),largestIntersec.z);\n\nvec3 intersectPositionWS=vertexPos+origVec*distance;\n\nreturn intersectPositionWS-cubePos;\n}\nvec3 computeFixedEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 direction)\n{\nfloat lon=atan(direction.z,direction.x);\nfloat lat=acos(direction.y);\nvec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;\nfloat s=sphereCoords.x*0.5+0.5;\nfloat t=sphereCoords.y;\nreturn vec3(s,t,0);\n}\nvec3 computeMirroredFixedEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 direction)\n{\nfloat lon=atan(direction.z,direction.x);\nfloat lat=acos(direction.y);\nvec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;\nfloat s=sphereCoords.x*0.5+0.5;\nfloat t=sphereCoords.y;\nreturn vec3(1.0-s,t,0);\n}\nvec3 computeEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix)\n{\nvec3 cameraToVertex=normalize(worldPos.xyz-eyePosition);\nvec3 r=normalize(reflect(cameraToVertex,worldNormal));\nr=vec3(reflectionMatrix*vec4(r,0));\nfloat lon=atan(r.z,r.x);\nfloat lat=acos(r.y);\nvec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;\nfloat s=sphereCoords.x*0.5+0.5;\nfloat t=sphereCoords.y;\nreturn vec3(s,t,0);\n}\nvec3 computeSphericalCoords(vec4 worldPos,vec3 worldNormal,mat4 view,mat4 reflectionMatrix)\n{\nvec3 viewDir=normalize(vec3(view*worldPos));\nvec3 viewNormal=normalize(vec3(view*vec4(worldNormal,0.0)));\nvec3 r=reflect(viewDir,viewNormal);\nr=vec3(reflectionMatrix*vec4(r,0));\nr.z=r.z-1.0;\nfloat m=2.0*length(r);\nreturn vec3(r.x/m+0.5,1.0-r.y/m-0.5,0);\n}\nvec3 computePlanarCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix)\n{\nvec3 viewDir=worldPos.xyz-eyePosition;\nvec3 coords=normalize(reflect(viewDir,worldNormal));\nreturn vec3(reflectionMatrix*vec4(coords,1));\n}\nvec3 computeCubicCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix)\n{\nvec3 viewDir=normalize(worldPos.xyz-eyePosition);\n\nvec3 coords=reflect(viewDir,worldNormal);\ncoords=vec3(reflectionMatrix*vec4(coords,0));\n#ifdef INVERTCUBICMAP\ncoords.y*=-1.0;\n#endif\nreturn coords;\n}\nvec3 computeCubicLocalCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix,vec3 reflectionSize,vec3 reflectionPosition)\n{\nvec3 viewDir=normalize(worldPos.xyz-eyePosition);\n\nvec3 coords=reflect(viewDir,worldNormal);\ncoords=parallaxCorrectNormal(worldPos.xyz,coords,reflectionSize,reflectionPosition);\ncoords=vec3(reflectionMatrix*vec4(coords,0));\n#ifdef INVERTCUBICMAP\ncoords.y*=-1.0;\n#endif\nreturn coords;\n}\nvec3 computeProjectionCoords(vec4 worldPos,mat4 view,mat4 reflectionMatrix)\n{\nreturn vec3(reflectionMatrix*(view*worldPos));\n}\nvec3 computeSkyBoxCoords(vec3 positionW,mat4 reflectionMatrix)\n{\nreturn vec3(reflectionMatrix*vec4(positionW,1.));\n}\n#ifdef REFLECTION\nvec3 computeReflectionCoords(vec4 worldPos,vec3 worldNormal)\n{\n#ifdef REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED\nvec3 direction=normalize(vDirectionW);\nreturn computeMirroredFixedEquirectangularCoords(worldPos,worldNormal,direction);\n#endif\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED\nvec3 direction=normalize(vDirectionW);\nreturn computeFixedEquirectangularCoords(worldPos,worldNormal,direction);\n#endif\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR\nreturn computeEquirectangularCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix);\n#endif\n#ifdef REFLECTIONMAP_SPHERICAL\nreturn computeSphericalCoords(worldPos,worldNormal,view,reflectionMatrix);\n#endif\n#ifdef REFLECTIONMAP_PLANAR\nreturn computePlanarCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix);\n#endif\n#ifdef REFLECTIONMAP_CUBIC\n#ifdef USE_LOCAL_REFLECTIONMAP_CUBIC\nreturn computeCubicLocalCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix,vReflectionSize,vReflectionPosition);\n#else\nreturn computeCubicCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix);\n#endif\n#endif\n#ifdef REFLECTIONMAP_PROJECTION\nreturn computeProjectionCoords(worldPos,view,reflectionMatrix);\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nreturn computeSkyBoxCoords(vPositionUVW,reflectionMatrix);\n#endif\n#ifdef REFLECTIONMAP_EXPLICIT\nreturn vec3(0,0,0);\n#endif\n}\n#endif";he.IncludesShadersStore.imageProcessingDeclaration="#ifdef EXPOSURE\nuniform float exposureLinear;\n#endif\n#ifdef CONTRAST\nuniform float contrast;\n#endif\n#ifdef VIGNETTE\nuniform vec2 vInverseScreenSize;\nuniform vec4 vignetteSettings1;\nuniform vec4 vignetteSettings2;\n#endif\n#ifdef COLORCURVES\nuniform vec4 vCameraColorCurveNegative;\nuniform vec4 vCameraColorCurveNeutral;\nuniform vec4 vCameraColorCurvePositive;\n#endif\n#ifdef COLORGRADING\n#ifdef COLORGRADING3D\nuniform highp sampler3D txColorTransform;\n#else\nuniform sampler2D txColorTransform;\n#endif\nuniform vec4 colorTransformSettings;\n#endif";he.IncludesShadersStore.imageProcessingFunctions="#if defined(COLORGRADING) && !defined(COLORGRADING3D)\n\n#define inline\nvec3 sampleTexture3D(sampler2D colorTransform,vec3 color,vec2 sampler3dSetting)\n{\nfloat sliceSize=2.0*sampler3dSetting.x;\n#ifdef SAMPLER3DGREENDEPTH\nfloat sliceContinuous=(color.g-sampler3dSetting.x)*sampler3dSetting.y;\n#else\nfloat sliceContinuous=(color.b-sampler3dSetting.x)*sampler3dSetting.y;\n#endif\nfloat sliceInteger=floor(sliceContinuous);\n\n\nfloat sliceFraction=sliceContinuous-sliceInteger;\n#ifdef SAMPLER3DGREENDEPTH\nvec2 sliceUV=color.rb;\n#else\nvec2 sliceUV=color.rg;\n#endif\nsliceUV.x*=sliceSize;\nsliceUV.x+=sliceInteger*sliceSize;\nsliceUV=saturate(sliceUV);\nvec4 slice0Color=texture2D(colorTransform,sliceUV);\nsliceUV.x+=sliceSize;\nsliceUV=saturate(sliceUV);\nvec4 slice1Color=texture2D(colorTransform,sliceUV);\nvec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction);\n#ifdef SAMPLER3DBGRMAP\ncolor.rgb=result.rgb;\n#else\ncolor.rgb=result.bgr;\n#endif\nreturn color;\n}\n#endif\n#ifdef TONEMAPPING_ACES\n\n\n\n\n\nconst mat3 ACESInputMat=mat3(\nvec3(0.59719,0.07600,0.02840),\nvec3(0.35458,0.90834,0.13383),\nvec3(0.04823,0.01566,0.83777)\n);\n\nconst mat3 ACESOutputMat=mat3(\nvec3( 1.60475,-0.10208,-0.00327),\nvec3(-0.53108,1.10813,-0.07276),\nvec3(-0.07367,-0.00605,1.07602)\n);\nvec3 RRTAndODTFit(vec3 v)\n{\nvec3 a=v*(v+0.0245786)-0.000090537;\nvec3 b=v*(0.983729*v+0.4329510)+0.238081;\nreturn a/b;\n}\nvec3 ACESFitted(vec3 color)\n{\ncolor=ACESInputMat*color;\n\ncolor=RRTAndODTFit(color);\ncolor=ACESOutputMat*color;\n\ncolor=saturate(color);\nreturn color;\n}\n#endif\nvec4 applyImageProcessing(vec4 result) {\n#ifdef EXPOSURE\nresult.rgb*=exposureLinear;\n#endif\n#ifdef VIGNETTE\n\nvec2 viewportXY=gl_FragCoord.xy*vInverseScreenSize;\nviewportXY=viewportXY*2.0-1.0;\nvec3 vignetteXY1=vec3(viewportXY*vignetteSettings1.xy+vignetteSettings1.zw,1.0);\nfloat vignetteTerm=dot(vignetteXY1,vignetteXY1);\nfloat vignette=pow(vignetteTerm,vignetteSettings2.w);\n\nvec3 vignetteColor=vignetteSettings2.rgb;\n#ifdef VIGNETTEBLENDMODEMULTIPLY\nvec3 vignetteColorMultiplier=mix(vignetteColor,vec3(1,1,1),vignette);\nresult.rgb*=vignetteColorMultiplier;\n#endif\n#ifdef VIGNETTEBLENDMODEOPAQUE\nresult.rgb=mix(vignetteColor,result.rgb,vignette);\n#endif\n#endif\n#ifdef TONEMAPPING\n#ifdef TONEMAPPING_ACES\nresult.rgb=ACESFitted(result.rgb);\n#else\nconst float tonemappingCalibration=1.590579;\nresult.rgb=1.0-exp2(-tonemappingCalibration*result.rgb);\n#endif\n#endif\n\nresult.rgb=toGammaSpace(result.rgb);\nresult.rgb=saturate(result.rgb);\n#ifdef CONTRAST\n\nvec3 resultHighContrast=result.rgb*result.rgb*(3.0-2.0*result.rgb);\nif (contrast<1.0) {\n\nresult.rgb=mix(vec3(0.5,0.5,0.5),result.rgb,contrast);\n} else {\n\nresult.rgb=mix(result.rgb,resultHighContrast,contrast-1.0);\n}\n#endif\n\n#ifdef COLORGRADING\nvec3 colorTransformInput=result.rgb*colorTransformSettings.xxx+colorTransformSettings.yyy;\n#ifdef COLORGRADING3D\nvec3 colorTransformOutput=texture(txColorTransform,colorTransformInput).rgb;\n#else\nvec3 colorTransformOutput=sampleTexture3D(txColorTransform,colorTransformInput,colorTransformSettings.yz).rgb;\n#endif\nresult.rgb=mix(result.rgb,colorTransformOutput,colorTransformSettings.www);\n#endif\n#ifdef COLORCURVES\n\nfloat luma=getLuminance(result.rgb);\nvec2 curveMix=clamp(vec2(luma*3.0-1.5,luma*-3.0+1.5),vec2(0.0),vec2(1.0));\nvec4 colorCurve=vCameraColorCurveNeutral+curveMix.x*vCameraColorCurvePositive-curveMix.y*vCameraColorCurveNegative;\nresult.rgb*=colorCurve.rgb;\nresult.rgb=mix(vec3(luma),result.rgb,colorCurve.a);\n#endif\nreturn result;\n}";he.IncludesShadersStore.bumpFragmentMainFunctions="#if defined(BUMP) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) || defined(DETAIL)\n#if defined(TANGENT) && defined(NORMAL)\nvarying mat3 vTBN;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nuniform mat4 normalMatrix;\n#endif\nvec3 perturbNormalBase(mat3 cotangentFrame,vec3 normal,float scale)\n{\n#ifdef NORMALXYSCALE\nnormal=normalize(normal*vec3(scale,scale,1.0));\n#endif\nreturn normalize(cotangentFrame*normal);\n}\nvec3 perturbNormal(mat3 cotangentFrame,vec3 textureSample,float scale)\n{\nreturn perturbNormalBase(cotangentFrame,textureSample*2.0-1.0,scale);\n}\n\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv,vec2 tangentSpaceParams)\n{\n\nuv=gl_FrontFacing ? uv : -uv;\n\nvec3 dp1=dFdx(p);\nvec3 dp2=dFdy(p);\nvec2 duv1=dFdx(uv);\nvec2 duv2=dFdy(uv);\n\nvec3 dp2perp=cross(dp2,normal);\nvec3 dp1perp=cross(normal,dp1);\nvec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;\nvec3 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;\n\ntangent*=tangentSpaceParams.x;\nbitangent*=tangentSpaceParams.y;\n\nfloat invmax=inversesqrt(max(dot(tangent,tangent),dot(bitangent,bitangent)));\nreturn mat3(tangent*invmax,bitangent*invmax,normal);\n}\n#endif\n";he.IncludesShadersStore.bumpFragmentFunctions="#if defined(BUMP)\n#if BUMPDIRECTUV == 1\n#define vBumpUV vMainUV1\n#elif BUMPDIRECTUV == 2\n#define vBumpUV vMainUV2\n#else\nvarying vec2 vBumpUV;\n#endif\nuniform sampler2D bumpSampler;\nvec3 perturbNormal(mat3 cotangentFrame,vec2 uv)\n{\nreturn perturbNormal(cotangentFrame,texture2D(bumpSampler,uv).xyz,vBumpInfos.y);\n}\n#endif\n#if defined(DETAIL)\n#if DETAILDIRECTUV == 1\n#define vDetailUV vMainUV1\n#elif DETAILDIRECTUV == 2\n#define vDetailUV vMainUV2\n#else\nvarying vec2 vDetailUV;\n#endif\nuniform sampler2D detailSampler;\n#endif\n#if defined(BUMP)\nvec3 perturbNormal(mat3 cotangentFrame,vec3 color)\n{\nreturn perturbNormal(cotangentFrame,color,vBumpInfos.y);\n}\n\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv)\n{\nreturn cotangent_frame(normal,p,uv,vTangentSpaceParams);\n}\n#endif\n#if defined(BUMP) && defined(PARALLAX)\nconst float minSamples=4.;\nconst float maxSamples=15.;\nconst int iMaxSamples=15;\n\nvec2 parallaxOcclusion(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale) {\nfloat parallaxLimit=length(vViewDirCoT.xy)/vViewDirCoT.z;\nparallaxLimit*=parallaxScale;\nvec2 vOffsetDir=normalize(vViewDirCoT.xy);\nvec2 vMaxOffset=vOffsetDir*parallaxLimit;\nfloat numSamples=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));\nfloat stepSize=1.0/numSamples;\n\nfloat currRayHeight=1.0;\nvec2 vCurrOffset=vec2(0,0);\nvec2 vLastOffset=vec2(0,0);\nfloat lastSampledHeight=1.0;\nfloat currSampledHeight=1.0;\nfor (int i=0; i<iMaxSamples; i++)\n{\ncurrSampledHeight=texture2D(bumpSampler,vBumpUV+vCurrOffset).w;\n\nif (currSampledHeight>currRayHeight)\n{\nfloat delta1=currSampledHeight-currRayHeight;\nfloat delta2=(currRayHeight+stepSize)-lastSampledHeight;\nfloat ratio=delta1/(delta1+delta2);\nvCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;\n\nbreak;\n}\nelse\n{\ncurrRayHeight-=stepSize;\nvLastOffset=vCurrOffset;\nvCurrOffset+=stepSize*vMaxOffset;\nlastSampledHeight=currSampledHeight;\n}\n}\nreturn vCurrOffset;\n}\nvec2 parallaxOffset(vec3 viewDir,float heightScale)\n{\n\nfloat height=texture2D(bumpSampler,vBumpUV).w;\nvec2 texCoordOffset=heightScale*viewDir.xy*height;\nreturn -texCoordOffset;\n}\n#endif";he.IncludesShadersStore.clipPlaneFragmentDeclaration="#ifdef CLIPPLANE\nvarying float fClipDistance;\n#endif\n#ifdef CLIPPLANE2\nvarying float fClipDistance2;\n#endif\n#ifdef CLIPPLANE3\nvarying float fClipDistance3;\n#endif\n#ifdef CLIPPLANE4\nvarying float fClipDistance4;\n#endif\n#ifdef CLIPPLANE5\nvarying float fClipDistance5;\n#endif\n#ifdef CLIPPLANE6\nvarying float fClipDistance6;\n#endif";he.IncludesShadersStore.logDepthDeclaration="#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;\nvarying float vFragmentDepth;\n#endif";he.IncludesShadersStore.fogFragmentDeclaration="#ifdef FOG\n#define FOGMODE_NONE 0.\n#define FOGMODE_EXP 1.\n#define FOGMODE_EXP2 2.\n#define FOGMODE_LINEAR 3.\n#define E 2.71828\nuniform vec4 vFogInfos;\nuniform vec3 vFogColor;\nvarying vec3 vFogDistance;\nfloat CalcFogFactor()\n{\nfloat fogCoeff=1.0;\nfloat fogStart=vFogInfos.y;\nfloat fogEnd=vFogInfos.z;\nfloat fogDensity=vFogInfos.w;\nfloat fogDistance=length(vFogDistance);\nif (FOGMODE_LINEAR == vFogInfos.x)\n{\nfogCoeff=(fogEnd-fogDistance)/(fogEnd-fogStart);\n}\nelse if (FOGMODE_EXP == vFogInfos.x)\n{\nfogCoeff=1.0/pow(E,fogDistance*fogDensity);\n}\nelse if (FOGMODE_EXP2 == vFogInfos.x)\n{\nfogCoeff=1.0/pow(E,fogDistance*fogDistance*fogDensity*fogDensity);\n}\nreturn clamp(fogCoeff,0.0,1.0);\n}\n#endif";he.IncludesShadersStore.clipPlaneFragment="#ifdef CLIPPLANE\nif (fClipDistance>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE2\nif (fClipDistance2>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE3\nif (fClipDistance3>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE4\nif (fClipDistance4>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE5\nif (fClipDistance5>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE6\nif (fClipDistance6>0.0)\n{\ndiscard;\n}\n#endif";he.IncludesShadersStore.bumpFragment="vec2 uvOffset=vec2(0.0,0.0);\n#if defined(BUMP) || defined(PARALLAX) || defined(DETAIL)\n#ifdef NORMALXYSCALE\nfloat normalScale=1.0;\n#elif defined(BUMP)\nfloat normalScale=vBumpInfos.y;\n#else\nfloat normalScale=1.0;\n#endif\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBN=vTBN;\n#elif defined(BUMP)\nmat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,vBumpUV);\n#else\nmat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,vDetailUV,vec2(1.,1.));\n#endif\n#elif defined(ANISOTROPIC)\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBN=vTBN;\n#else\nmat3 TBN=cotangent_frame(normalW,vPositionW,vMainUV1,vec2(1.,1.));\n#endif\n#endif\n#ifdef PARALLAX\nmat3 invTBN=transposeMat3(TBN);\n#ifdef PARALLAXOCCLUSION\nuvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,vBumpUV,vBumpInfos.z);\n#else\nuvOffset=parallaxOffset(invTBN*viewDirectionW,vBumpInfos.z);\n#endif\n#endif\n#ifdef DETAIL\nvec4 detailColor=texture2D(detailSampler,vDetailUV+uvOffset);\nvec2 detailNormalRG=detailColor.wy*2.0-1.0;\nfloat detailNormalB=sqrt(1.-saturate(dot(detailNormalRG,detailNormalRG)));\nvec3 detailNormal=vec3(detailNormalRG,detailNormalB);\n#endif\n#ifdef BUMP\n#ifdef OBJECTSPACE_NORMALMAP\nnormalW=normalize(texture2D(bumpSampler,vBumpUV).xyz*2.0-1.0);\nnormalW=normalize(mat3(normalMatrix)*normalW);\n#elif !defined(DETAIL)\nnormalW=perturbNormal(TBN,vBumpUV+uvOffset);\n#else\nvec3 bumpNormal=texture2D(bumpSampler,vBumpUV+uvOffset).xyz*2.0-1.0;\n\n#if DETAIL_NORMALBLENDMETHOD == 0\ndetailNormal.xy*=vDetailInfos.z;\nvec3 blendedNormal=normalize(vec3(bumpNormal.xy+detailNormal.xy,bumpNormal.z*detailNormal.z));\n#elif DETAIL_NORMALBLENDMETHOD == 1\ndetailNormal.xy*=vDetailInfos.z;\nbumpNormal+=vec3(0.0,0.0,1.0);\ndetailNormal*=vec3(-1.0,-1.0,1.0);\nvec3 blendedNormal=bumpNormal*dot(bumpNormal,detailNormal)/bumpNormal.z-detailNormal;\n#endif\nnormalW=perturbNormalBase(TBN,blendedNormal,vBumpInfos.y);\n#endif\n#elif defined(DETAIL)\ndetailNormal.xy*=vDetailInfos.z;\nnormalW=perturbNormalBase(TBN,detailNormal,vDetailInfos.z);\n#endif";he.IncludesShadersStore.depthPrePass="#ifdef DEPTHPREPASS\ngl_FragColor=vec4(0.,0.,0.,1.0);\nreturn;\n#endif";he.IncludesShadersStore.lightFragment="#ifdef LIGHT{X}\n#if defined(SHADOWONLY) || defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})\n\n#else\n#ifdef PBR\n\n#ifdef SPOTLIGHT{X}\npreInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(POINTLIGHT{X})\npreInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(HEMILIGHT{X})\npreInfo=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(DIRLIGHT{X})\npreInfo=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#endif\npreInfo.NdotV=NdotV;\n\n#ifdef SPOTLIGHT{X}\n#ifdef LIGHT_FALLOFF_GLTF{X}\npreInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\npreInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npreInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);\npreInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npreInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);\npreInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w);\n#else\npreInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\npreInfo.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#endif\n#elif defined(POINTLIGHT{X})\n#ifdef LIGHT_FALLOFF_GLTF{X}\npreInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npreInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npreInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);\n#else\npreInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\n#endif\n#else\npreInfo.attenuation=1.0;\n#endif\n\n\n#ifdef HEMILIGHT{X}\npreInfo.roughness=roughness;\n#else\npreInfo.roughness=adjustRoughnessFromLightProperties(roughness,light{X}.vLightSpecular.a,preInfo.lightDistance);\n#endif\n\n#ifdef HEMILIGHT{X}\ninfo.diffuse=computeHemisphericDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb,light{X}.vLightGround);\n#elif defined(SS_TRANSLUCENCY)\ninfo.diffuse=computeDiffuseAndTransmittedLighting(preInfo,light{X}.vLightDiffuse.rgb,subSurfaceOut.transmittance);\n#else\ninfo.diffuse=computeDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb);\n#endif\n\n#ifdef SPECULARTERM\n#ifdef ANISOTROPIC\ninfo.specular=computeAnisotropicSpecularLighting(preInfo,viewDirectionW,normalW,anisotropicOut.anisotropicTangent,anisotropicOut.anisotropicBitangent,anisotropicOut.anisotropy,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\n#else\ninfo.specular=computeSpecularLighting(preInfo,normalW,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\n#endif\n#endif\n\n#ifdef SHEEN\n#ifdef SHEEN_LINKWITHALBEDO\n\npreInfo.roughness=sheenOut.sheenIntensity;\n#else\n#ifdef HEMILIGHT{X}\npreInfo.roughness=sheenOut.sheenRoughness;\n#else\npreInfo.roughness=adjustRoughnessFromLightProperties(sheenOut.sheenRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);\n#endif\n#endif\ninfo.sheen=computeSheenLighting(preInfo,normalW,sheenOut.sheenColor,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\n#endif\n\n#ifdef CLEARCOAT\n\n#ifdef HEMILIGHT{X}\npreInfo.roughness=clearcoatOut.clearCoatRoughness;\n#else\npreInfo.roughness=adjustRoughnessFromLightProperties(clearcoatOut.clearCoatRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);\n#endif\ninfo.clearCoat=computeClearCoatLighting(preInfo,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatAARoughnessFactors.x,clearcoatOut.clearCoatIntensity,light{X}.vLightDiffuse.rgb);\n#ifdef CLEARCOAT_TINT\n\nabsorption=computeClearCoatLightingAbsorption(clearcoatOut.clearCoatNdotVRefract,preInfo.L,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatColor,clearcoatOut.clearCoatThickness,clearcoatOut.clearCoatIntensity);\ninfo.diffuse*=absorption;\n#ifdef SPECULARTERM\ninfo.specular*=absorption;\n#endif\n#endif\n\ninfo.diffuse*=info.clearCoat.w;\n#ifdef SPECULARTERM\ninfo.specular*=info.clearCoat.w;\n#endif\n#ifdef SHEEN\ninfo.sheen*=info.clearCoat.w;\n#endif\n#endif\n#else\n#ifdef SPOTLIGHT{X}\ninfo=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightDiffuse.a,glossiness);\n#elif defined(HEMILIGHT{X})\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightGround,glossiness);\n#elif defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})\ninfo=computeLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightDiffuse.a,glossiness);\n#endif\n#endif\n#ifdef PROJECTEDLIGHTTEXTURE{X}\ninfo.diffuse*=computeProjectionTextureDiffuseLighting(projectionLightSampler{X},textureProjectionMatrix{X});\n#endif\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCSM{X}\nfor (int i=0; i<SHADOWCSMNUM_CASCADES{X}; i++)\n{\n#ifdef SHADOWCSM_RIGHTHANDED{X}\ndiff{X}=viewFrustumZ{X}[i]+vPositionFromCamera{X}.z;\n#else\ndiff{X}=viewFrustumZ{X}[i]-vPositionFromCamera{X}.z;\n#endif\nif (diff{X}>=0.) {\nindex{X}=i;\nbreak;\n}\n}\n#ifdef SHADOWCSMUSESHADOWMAXZ{X}\nif (index{X}>=0)\n#endif\n{\n#if defined(SHADOWPCF{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=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);\n#else\nshadow=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);\n#endif\n#elif defined(SHADOWPCSS{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=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});\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=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});\n#else\nshadow=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});\n#endif\n#else\nshadow=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#ifdef SHADOWCSMDEBUG{X}\nshadowDebug{X}=vec3(shadow)*vCascadeColorsMultiplier{X}[index{X}];\n#endif\n#ifndef SHADOWCSMNOBLEND{X}\nfloat frustumLength=frustumLengths{X}[index{X}];\nfloat diffRatio=clamp(diff{X}/frustumLength,0.,1.)*cascadeBlendFactor{X};\nif (index{X}<(SHADOWCSMNUM_CASCADES{X}-1) && diffRatio<1.)\n{\nindex{X}+=1;\nfloat nextShadow=0.;\n#if defined(SHADOWPCF{X})\n#if defined(SHADOWLOWQUALITY{X})\nnextShadow=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nnextShadow=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);\n#else\nnextShadow=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);\n#endif\n#elif defined(SHADOWPCSS{X})\n#if defined(SHADOWLOWQUALITY{X})\nnextShadow=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});\n#elif defined(SHADOWMEDIUMQUALITY{X})\nnextShadow=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});\n#else\nnextShadow=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});\n#endif\n#else\nnextShadow=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\nshadow=mix(nextShadow,shadow,diffRatio);\n#ifdef SHADOWCSMDEBUG{X}\nshadowDebug{X}=mix(vec3(nextShadow)*vCascadeColorsMultiplier{X}[index{X}],shadowDebug{X},diffRatio);\n#endif\n}\n#endif\n}\n#elif defined(SHADOWCLOSEESM{X})\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithCloseESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithCloseESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWESM{X})\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPOISSON{X})\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithPoissonSamplingCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadowWithPoissonSampling(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCF{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=computeShadowWithPCF1(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=computeShadowWithPCF3(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nshadow=computeShadowWithPCF5(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCSS{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=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);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=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);\n#else\nshadow=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);\n#endif\n#else\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadow(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#endif\n#ifdef SHADOWONLY\n#ifndef SHADOWINUSE\n#define SHADOWINUSE\n#endif\nglobalShadow+=shadow;\nshadowLightCount+=1.0;\n#endif\n#else\nshadow=1.;\n#endif\n#ifndef SHADOWONLY\n#ifdef CUSTOMUSERLIGHTING\ndiffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow);\n#ifdef SPECULARTERM\nspecularBase+=computeCustomSpecularLighting(info,specularBase,shadow);\n#endif\n#elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})\ndiffuseBase+=lightmapColor.rgb*shadow;\n#ifdef SPECULARTERM\n#ifndef LIGHTMAPNOSPECULAR{X}\nspecularBase+=info.specular*shadow*lightmapColor.rgb;\n#endif\n#endif\n#ifdef CLEARCOAT\n#ifndef LIGHTMAPNOSPECULAR{X}\nclearCoatBase+=info.clearCoat.rgb*shadow*lightmapColor.rgb;\n#endif\n#endif\n#ifdef SHEEN\n#ifndef LIGHTMAPNOSPECULAR{X}\nsheenBase+=info.sheen.rgb*shadow;\n#endif\n#endif\n#else\n#ifdef SHADOWCSMDEBUG{X}\ndiffuseBase+=info.diffuse*shadowDebug{X};\n#else\ndiffuseBase+=info.diffuse*shadow;\n#endif\n#ifdef SPECULARTERM\nspecularBase+=info.specular*shadow;\n#endif\n#ifdef CLEARCOAT\nclearCoatBase+=info.clearCoat.rgb*shadow;\n#endif\n#ifdef SHEEN\nsheenBase+=info.sheen.rgb*shadow;\n#endif\n#endif\n#endif\n#endif";he.IncludesShadersStore.logDepthFragment="#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif";he.IncludesShadersStore.fogFragment="#ifdef FOG\nfloat fog=CalcFogFactor();\ncolor.rgb=fog*color.rgb+(1.0-fog)*vFogColor;\n#endif";he.ShadersStore.defaultPixelShader="#include<__decl__defaultFragment>\n#if defined(BUMP) || !defined(NORMAL)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#include<prePassDeclaration>[SCENE_MRT_COUNT]\n#define CUSTOM_FRAGMENT_BEGIN\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n\n#define RECIPROCAL_PI2 0.15915494\nuniform vec3 vEyePosition;\nuniform vec3 vAmbientColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\n#if DIFFUSEDIRECTUV == 1\n#define vDiffuseUV vMainUV1\n#elif DIFFUSEDIRECTUV == 2\n#define vDiffuseUV vMainUV2\n#else\nvarying vec2 vDiffuseUV;\n#endif\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY\n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\nuniform samplerCube refractionCubeSampler;\n#else\nuniform sampler2D refraction2DSampler;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\n#if SPECULARDIRECTUV == 1\n#define vSpecularUV vMainUV1\n#elif SPECULARDIRECTUV == 2\n#define vSpecularUV vMainUV2\n#else\nvarying vec2 vSpecularUV;\n#endif\nuniform sampler2D specularSampler;\n#endif\n#ifdef ALPHATEST\nuniform float alphaCutOff;\n#endif\n\n#include<fresnelFunction>\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\nuniform samplerCube reflectionCubeSampler;\n#else\nuniform sampler2D reflection2DSampler;\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n#include<imageProcessingDeclaration>\n#include<imageProcessingFunctions>\n#include<bumpFragmentMainFunctions>\n#include<bumpFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(-cross(dFdx(vPositionW),dFdy(vPositionW)));\n#endif\n#include<bumpFragment>\n#ifdef TWOSIDEDLIGHTING\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);\n#if defined(ALPHATEST) && !defined(ALPHATEST_AFTERALLALPHACOMPUTATIONS)\nif (baseColor.a<alphaCutOff)\ndiscard;\n#endif\n#ifdef ALPHAFROMDIFFUSE\nalpha*=baseColor.a;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_ALPHA\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#include<depthPrePass>\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n#ifdef DETAIL\nbaseColor.rgb=baseColor.rgb*2.0*mix(0.5,detailColor.r,vDetailInfos.y);\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE\n\nvec3 baseAmbientColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nbaseAmbientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_LIGHTS\n\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularColor=vSpecularColor.rgb;\n#ifdef SPECULAR\nvec4 specularMapColor=texture2D(specularSampler,vSpecularUV+uvOffset);\nspecularColor=specularMapColor.rgb;\n#ifdef GLOSSINESS\nglossiness=glossiness*specularMapColor.a;\n#endif\n#endif\n#else\nfloat glossiness=0.;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\nfloat shadow=1.;\n#ifdef LIGHTMAP\nvec4 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset);\n#ifdef RGBDLIGHTMAP\nlightmapColor.rgb=fromRGBD(lightmapColor);\n#endif\nlightmapColor.rgb*=vLightmapInfos.y;\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n\nvec4 refractionColor=vec4(0.,0.,0.,1.);\n#ifdef REFRACTION\nvec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y));\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nif (dot(refractionVector,viewDirectionW)<1.0) {\nrefractionColor=textureCube(refractionCubeSampler,refractionVector);\n}\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\nrefractionColor=texture2D(refraction2DSampler,refractionCoords);\n#endif\n#ifdef RGBDREFRACTION\nrefractionColor.rgb=fromRGBD(refractionColor);\n#endif\n#ifdef IS_REFRACTION_LINEAR\nrefractionColor.rgb=toGammaSpace(refractionColor.rgb);\n#endif\nrefractionColor.rgb*=vRefractionInfos.x;\n#endif\n\nvec4 reflectionColor=vec4(0.,0.,0.,1.);\n#ifdef REFLECTION\nvec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_3D\n#ifdef ROUGHNESS\nfloat bias=vReflectionInfos.y;\n#ifdef SPECULARTERM\n#ifdef SPECULAR\n#ifdef GLOSSINESS\nbias*=(1.0-specularMapColor.a);\n#endif\n#endif\n#endif\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias);\n#else\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW);\n#endif\n#else\nvec2 coords=vReflectionUVW.xy;\n#ifdef REFLECTIONMAP_PROJECTION\ncoords/=vReflectionUVW.z;\n#endif\ncoords.y=1.0-coords.y;\nreflectionColor=texture2D(reflection2DSampler,coords);\n#endif\n#ifdef RGBDREFLECTION\nreflectionColor.rgb=fromRGBD(reflectionColor);\n#endif\n#ifdef IS_REFLECTION_LINEAR\nreflectionColor.rgb=toGammaSpace(reflectionColor.rgb);\n#endif\nreflectionColor.rgb*=vReflectionInfos.x;\n#ifdef REFLECTIONFRESNEL\nfloat reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a);\n#ifdef REFLECTIONFRESNELFROMSPECULAR\n#ifdef SPECULARTERM\nreflectionColor.rgb*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#else\nreflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#else\nreflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#endif\n#endif\n#ifdef REFRACTIONFRESNEL\nfloat refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a);\nrefractionColor.rgb*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nopacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);\nalpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;\n#else\nalpha*=opacityMap.a*vOpacityInfos.y;\n#endif\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef OPACITYFRESNEL\nfloat opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);\nalpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y;\n#endif\n#ifdef ALPHATEST\n#ifdef ALPHATEST_AFTERALLALPHACOMPUTATIONS\nif (alpha<alphaCutOff)\ndiscard;\n#endif\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\n#endif\n\nvec3 emissiveColor=vEmissiveColor;\n#ifdef EMISSIVE\nemissiveColor+=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb*vEmissiveInfos.y;\n#endif\n#ifdef EMISSIVEFRESNEL\nfloat emissiveFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,emissiveRightColor.a,emissiveLeftColor.a);\nemissiveColor*=emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*emissiveRightColor.rgb;\n#endif\n\n#ifdef DIFFUSEFRESNEL\nfloat diffuseFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,diffuseRightColor.a,diffuseLeftColor.a);\ndiffuseBase*=diffuseLeftColor.rgb*(1.0-diffuseFresnelTerm)+diffuseFresnelTerm*diffuseRightColor.rgb;\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\n#ifdef LINKEMISSIVEWITHDIFFUSE\nvec3 finalDiffuse=clamp((diffuseBase+emissiveColor)*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+emissiveColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#endif\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#ifdef SPECULAROVERALPHA\nalpha=clamp(alpha+dot(finalSpecular,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\n#ifdef REFLECTIONOVERALPHA\nalpha=clamp(alpha+dot(reflectionColor.rgb,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec4 color=vec4(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor.rgb+emissiveColor+refractionColor.rgb,0.0,1.0),alpha);\n#else\nvec4 color=vec4(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor.rgb+refractionColor.rgb,alpha);\n#endif\n\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\ncolor.rgb*=lightmapColor.rgb;\n#else\ncolor.rgb+=lightmapColor.rgb;\n#endif\n#endif\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FOG\ncolor.rgb=max(color.rgb,0.);\n#include<logDepthFragment>\n#include<fogFragment>\n\n\n#ifdef IMAGEPROCESSINGPOSTPROCESS\ncolor.rgb=toLinearSpace(color.rgb);\n#else\n#ifdef IMAGEPROCESSING\ncolor.rgb=toLinearSpace(color.rgb);\ncolor=applyImageProcessing(color);\n#endif\n#endif\ncolor.a*=visibility;\n#ifdef PREMULTIPLYALPHA\n\ncolor.rgb*=color.a;\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\n#ifdef PREPASS\ngl_FragData[0]=color;\n#ifdef PREPASS_POSITION\ngl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,1.0);\n#endif\n#ifdef PREPASS_VELOCITY\nvec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;\nvec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;\nvec2 velocity=abs(a-b);\nvelocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;\ngl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,1.0);\n#endif\n#ifdef PREPASS_IRRADIANCE\ngl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(0.0,0.0,0.0,1.0);\n#endif\n#ifdef PREPASS_DEPTHNORMAL\ngl_FragData[PREPASS_DEPTHNORMAL_INDEX]=vec4(vViewPos.z,(view*vec4(normalW,0.0)).rgb);\n#endif\n#ifdef PREPASS_ALBEDO\ngl_FragData[PREPASS_ALBEDO_INDEX]=vec4(0.0,0.0,0.0,1.0);\n#endif\n#ifdef PREPASS_REFLECTIVITY\n#if defined(SPECULAR)\ngl_FragData[PREPASS_REFLECTIVITY_INDEX]=specularMapColor;\n#else\ngl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(0.0,0.0,0.0,1.0);\n#endif\n#endif\n#endif\n#if !defined(PREPASS) || defined(WEBGL2)\ngl_FragColor=color;\n#endif\n}\n";he.IncludesShadersStore.defaultVertexDeclaration="\nuniform mat4 viewProjection;\nuniform mat4 view;\n#ifdef DIFFUSE\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nuniform mat4 ambientMatrix;\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform mat4 opacityMatrix;\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\nuniform mat4 emissiveMatrix;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\nuniform mat4 lightmapMatrix;\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nuniform vec2 vSpecularInfos;\nuniform mat4 specularMatrix;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform mat4 bumpMatrix;\n#endif\n#ifdef REFLECTION\nuniform mat4 reflectionMatrix;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n";he.IncludesShadersStore.bonesDeclaration="#if NUM_BONE_INFLUENCERS>0\n#ifdef BONETEXTURE\nuniform sampler2D boneSampler;\nuniform float boneTextureWidth;\n#else\nuniform mat4 mBones[BonesPerMesh];\n#ifdef BONES_VELOCITY_ENABLED\nuniform mat4 mPreviousBones[BonesPerMesh];\n#endif\n#endif\nattribute vec4 matricesIndices;\nattribute vec4 matricesWeights;\n#if NUM_BONE_INFLUENCERS>4\nattribute vec4 matricesIndicesExtra;\nattribute vec4 matricesWeightsExtra;\n#endif\n#ifdef BONETEXTURE\n#define inline\nmat4 readMatrixFromRawSampler(sampler2D smp,float index)\n{\nfloat offset=index*4.0;\nfloat dx=1.0/boneTextureWidth;\nvec4 m0=texture2D(smp,vec2(dx*(offset+0.5),0.));\nvec4 m1=texture2D(smp,vec2(dx*(offset+1.5),0.));\nvec4 m2=texture2D(smp,vec2(dx*(offset+2.5),0.));\nvec4 m3=texture2D(smp,vec2(dx*(offset+3.5),0.));\nreturn mat4(m0,m1,m2,m3);\n}\n#endif\n#endif";he.IncludesShadersStore.instancesDeclaration="#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#ifdef THIN_INSTANCES\nuniform mat4 world;\n#endif\n#else\nuniform mat4 world;\n#endif";he.IncludesShadersStore.prePassVertexDeclaration="#ifdef PREPASS\n#ifdef PREPASS_DEPTHNORMAL\nvarying vec3 vViewPos;\n#endif\n#ifdef PREPASS_VELOCITY\nuniform mat4 previousWorld;\nuniform mat4 previousViewProjection;\nvarying vec4 vCurrentPosition;\nvarying vec4 vPreviousPosition;\n#endif\n#endif";he.IncludesShadersStore.bumpVertexDeclaration="#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)\n#if defined(TANGENT) && defined(NORMAL)\nvarying mat3 vTBN;\n#endif\n#endif\n";he.IncludesShadersStore.clipPlaneVertexDeclaration="#ifdef CLIPPLANE\nuniform vec4 vClipPlane;\nvarying float fClipDistance;\n#endif\n#ifdef CLIPPLANE2\nuniform vec4 vClipPlane2;\nvarying float fClipDistance2;\n#endif\n#ifdef CLIPPLANE3\nuniform vec4 vClipPlane3;\nvarying float fClipDistance3;\n#endif\n#ifdef CLIPPLANE4\nuniform vec4 vClipPlane4;\nvarying float fClipDistance4;\n#endif\n#ifdef CLIPPLANE5\nuniform vec4 vClipPlane5;\nvarying float fClipDistance5;\n#endif\n#ifdef CLIPPLANE6\nuniform vec4 vClipPlane6;\nvarying float fClipDistance6;\n#endif";he.IncludesShadersStore.fogVertexDeclaration="#ifdef FOG\nvarying vec3 vFogDistance;\n#endif";he.IncludesShadersStore.morphTargetsVertexGlobalDeclaration="#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#endif";he.IncludesShadersStore.morphTargetsVertexDeclaration="#ifdef MORPHTARGETS\nattribute vec3 position{X};\n#ifdef MORPHTARGETS_NORMAL\nattribute vec3 normal{X};\n#endif\n#ifdef MORPHTARGETS_TANGENT\nattribute vec3 tangent{X};\n#endif\n#ifdef MORPHTARGETS_UV\nattribute vec2 uv_{X};\n#endif\n#endif";he.IncludesShadersStore.morphTargetsVertex="#ifdef MORPHTARGETS\npositionUpdated+=(position{X}-position)*morphTargetInfluences[{X}];\n#ifdef MORPHTARGETS_NORMAL\nnormalUpdated+=(normal{X}-normal)*morphTargetInfluences[{X}];\n#endif\n#ifdef MORPHTARGETS_TANGENT\ntangentUpdated.xyz+=(tangent{X}-tangent.xyz)*morphTargetInfluences[{X}];\n#endif\n#ifdef MORPHTARGETS_UV\nuvUpdated+=(uv_{X}-uv)*morphTargetInfluences[{X}];\n#endif\n#endif";he.IncludesShadersStore.instancesVertex="#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#ifdef THIN_INSTANCES\nfinalWorld=world*finalWorld;\n#endif\n#else\nmat4 finalWorld=world;\n#endif";he.IncludesShadersStore.bonesVertex="#if NUM_BONE_INFLUENCERS>0\nmat4 influence;\n#ifdef BONETEXTURE\ninfluence=readMatrixFromRawSampler(boneSampler,matricesIndices[0])*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndices[1])*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndices[2])*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndices[3])*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[0])*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[1])*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[2])*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[3])*matricesWeightsExtra[3];\n#endif\n#else\ninfluence=mBones[int(matricesIndices[0])]*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\ninfluence+=mBones[int(matricesIndices[1])]*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\ninfluence+=mBones[int(matricesIndices[2])]*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\ninfluence+=mBones[int(matricesIndices[3])]*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\ninfluence+=mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\ninfluence+=mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\ninfluence+=mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\ninfluence+=mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\n#endif\n#endif\nfinalWorld=finalWorld*influence;\n#endif";he.IncludesShadersStore.prePassVertex="#ifdef PREPASS_DEPTHNORMAL\nvViewPos=(view*worldPos).rgb;\n#endif\n#if defined(PREPASS_VELOCITY) && defined(BONES_VELOCITY_ENABLED)\nvCurrentPosition=viewProjection*worldPos;\n#if NUM_BONE_INFLUENCERS>0\nmat4 previousInfluence;\npreviousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\npreviousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\npreviousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\npreviousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\n#endif\nvPreviousPosition=previousViewProjection*previousWorld*previousInfluence*vec4(positionUpdated,1.0);\n#else\nvPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0);\n#endif\n#endif";he.IncludesShadersStore.bumpVertex="#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)\n#if defined(TANGENT) && defined(NORMAL)\nvec3 tbnNormal=normalize(normalUpdated);\nvec3 tbnTangent=normalize(tangentUpdated.xyz);\nvec3 tbnBitangent=cross(tbnNormal,tbnTangent)*tangentUpdated.w;\nvTBN=mat3(finalWorld)*mat3(tbnTangent,tbnBitangent,tbnNormal);\n#endif\n#endif";he.IncludesShadersStore.clipPlaneVertex="#ifdef CLIPPLANE\nfClipDistance=dot(worldPos,vClipPlane);\n#endif\n#ifdef CLIPPLANE2\nfClipDistance2=dot(worldPos,vClipPlane2);\n#endif\n#ifdef CLIPPLANE3\nfClipDistance3=dot(worldPos,vClipPlane3);\n#endif\n#ifdef CLIPPLANE4\nfClipDistance4=dot(worldPos,vClipPlane4);\n#endif\n#ifdef CLIPPLANE5\nfClipDistance5=dot(worldPos,vClipPlane5);\n#endif\n#ifdef CLIPPLANE6\nfClipDistance6=dot(worldPos,vClipPlane6);\n#endif";he.IncludesShadersStore.fogVertex="#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif";he.IncludesShadersStore.shadowsVertex="#ifdef SHADOWS\n#if defined(SHADOWCSM{X})\nvPositionFromCamera{X}=view*worldPos;\nfor (int i=0; i<SHADOWCSMNUM_CASCADES{X}; i++) {\nvPositionFromLight{X}[i]=lightMatrix{X}[i]*worldPos;\nvDepthMetric{X}[i]=((vPositionFromLight{X}[i].z+light{X}.depthValues.x)/(light{X}.depthValues.y));\n}\n#elif defined(SHADOW{X}) && !defined(SHADOWCUBE{X})\nvPositionFromLight{X}=lightMatrix{X}*worldPos;\nvDepthMetric{X}=((vPositionFromLight{X}.z+light{X}.depthValues.x)/(light{X}.depthValues.y));\n#endif\n#endif";he.IncludesShadersStore.pointCloudVertex="#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif";he.IncludesShadersStore.logDepthVertex="#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif";he.ShadersStore.defaultVertexShader="#include<__decl__defaultVertex>\n\n#define CUSTOM_VERTEX_BEGIN\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<helperFunctions>\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n#include<prePassVertexDeclaration>\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nvarying vec2 vDiffuseUV;\n#endif\n#if defined(DETAIL) && DETAILDIRECTUV == 0\nvarying vec2 vDetailUV;\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0\nvarying vec2 vSpecularUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvec3 positionUpdated=position;\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=positionUpdated;\n#endif\n#define CUSTOM_VERTEX_UPDATE_POSITION\n#define CUSTOM_VERTEX_UPDATE_NORMAL\n#include<instancesVertex>\n#if defined(PREPASS) && defined(PREPASS_VELOCITY) && !defined(BONES_VELOCITY_ENABLED)\n\nvCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0);\n#endif\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#if defined(INSTANCES) && defined(THIN_INSTANCES)\nvNormalW=normalUpdated/vec3(dot(normalWorld[0],normalWorld[0]),dot(normalWorld[1],normalWorld[1]),dot(normalWorld[2],normalWorld[2]));\nvNormalW=normalize(normalWorld*vNormalW);\n#else\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#endif\n#endif\n#define CUSTOM_VERTEX_UPDATE_WORLDPOS\n#ifdef MULTIVIEW\nif (gl_ViewID_OVR == 0u) {\ngl_Position=viewProjection*worldPos;\n} else {\ngl_Position=viewProjectionR*worldPos;\n}\n#else\ngl_Position=viewProjection*worldPos;\n#endif\nvPositionW=vec3(worldPos);\n#include<prePassVertex>\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uvUpdated=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uvUpdated;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(DETAIL) && DETAILDIRECTUV == 0\nif (vDetailInfos.x == 0.)\n{\nvDetailUV=vec2(detailMatrix*vec4(uvUpdated,1.0,0.0));\n}\nelse\n{\nvDetailUV=vec2(detailMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uvUpdated,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uvUpdated,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uvUpdated,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uvUpdated,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0\nif (vSpecularInfos.x == 0.)\n{\nvSpecularUV=vec2(specularMatrix*vec4(uvUpdated,1.0,0.0));\n}\nelse\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uvUpdated,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#include<bumpVertex>\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n#include<pointCloudVertex>\n#include<logDepthVertex>\n#define CUSTOM_VERTEX_MAIN_END\n}\n";var Ji=function(){function e(e){this._texture=null,this.diffuseBlendLevel=1,this.roughnessBlendLevel=1,this.bumpLevel=1,this._normalBlendMethod=Vt.MATERIAL_NORMALBLENDMETHOD_WHITEOUT,this._isEnabled=!1,this.isEnabled=!1,this._internalMarkAllSubMeshesAsTexturesDirty=e}return e.prototype._markAllSubMeshesAsTexturesDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty()},e.prototype.isReadyForSubMesh=function(e,t){var i=t.getEngine();return!(e._areTexturesDirty&&t.texturesEnabled&&i.getCaps().standardDerivatives&&this._texture&&Qi.DetailTextureEnabled&&!this._texture.isReady())},e.prototype.prepareDefines=function(e,t){if(this._isEnabled){e.DETAIL_NORMALBLENDMETHOD=this._normalBlendMethod;var i=t.getEngine();e._areTexturesDirty&&(i.getCaps().standardDerivatives&&this._texture&&Qi.DetailTextureEnabled&&this._isEnabled?(Xi.PrepareDefinesForMergedUV(this._texture,e,"DETAIL"),e.DETAIL_NORMALBLENDMETHOD=this._normalBlendMethod):e.DETAIL=!1)}else e.DETAIL=!1},e.prototype.bindForSubMesh=function(e,t,i){this._isEnabled&&(e.useUbo&&i&&e.isSync||this._texture&&Qi.DetailTextureEnabled&&(e.updateFloat4("vDetailInfos",this._texture.coordinatesIndex,this.diffuseBlendLevel,this.bumpLevel,this.roughnessBlendLevel),Xi.BindTextureMatrix(this._texture,e,"detail")),t.texturesEnabled&&this._texture&&Qi.DetailTextureEnabled&&e.setTexture("detailSampler",this._texture))},e.prototype.hasTexture=function(e){return this._texture===e},e.prototype.getActiveTextures=function(e){this._texture&&e.push(this._texture)},e.prototype.getAnimatables=function(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture)},e.prototype.dispose=function(e){var t;e&&(null===(t=this._texture)||void 0===t||t.dispose())},e.prototype.getClassName=function(){return"DetailMap"},e.AddUniforms=function(e){e.push("vDetailInfos")},e.AddSamplers=function(e){e.push("detailSampler")},e.PrepareUniformBuffer=function(e){e.addUniform("vDetailInfos",4),e.addUniform("detailMatrix",16)},e.prototype.copyTo=function(e){N.Clone((function(){return e}),this)},e.prototype.serialize=function(){return N.Serialize(this)},e.prototype.parse=function(e,t,i){var r=this;N.Parse((function(){return r}),e,t,i)},r([R("detailTexture"),I("_markAllSubMeshesAsTexturesDirty")],e.prototype,"texture",void 0),r([O()],e.prototype,"diffuseBlendLevel",void 0),r([O()],e.prototype,"roughnessBlendLevel",void 0),r([O()],e.prototype,"bumpLevel",void 0),r([O(),I("_markAllSubMeshesAsTexturesDirty")],e.prototype,"normalBlendMethod",void 0),r([O(),I("_markAllSubMeshesAsTexturesDirty")],e.prototype,"isEnabled",void 0),e}(),$i={effect:null,subMesh:null},er=function(e){function i(){var t=e.call(this)||this;return t.MAINUV1=!1,t.MAINUV2=!1,t.DIFFUSE=!1,t.DIFFUSEDIRECTUV=0,t.DETAIL=!1,t.DETAILDIRECTUV=0,t.DETAIL_NORMALBLENDMETHOD=0,t.AMBIENT=!1,t.AMBIENTDIRECTUV=0,t.OPACITY=!1,t.OPACITYDIRECTUV=0,t.OPACITYRGB=!1,t.REFLECTION=!1,t.EMISSIVE=!1,t.EMISSIVEDIRECTUV=0,t.SPECULAR=!1,t.SPECULARDIRECTUV=0,t.BUMP=!1,t.BUMPDIRECTUV=0,t.PARALLAX=!1,t.PARALLAXOCCLUSION=!1,t.SPECULAROVERALPHA=!1,t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!1,t.CLIPPLANE5=!1,t.CLIPPLANE6=!1,t.ALPHATEST=!1,t.DEPTHPREPASS=!1,t.ALPHAFROMDIFFUSE=!1,t.POINTSIZE=!1,t.FOG=!1,t.SPECULARTERM=!1,t.DIFFUSEFRESNEL=!1,t.OPACITYFRESNEL=!1,t.REFLECTIONFRESNEL=!1,t.REFRACTIONFRESNEL=!1,t.EMISSIVEFRESNEL=!1,t.FRESNEL=!1,t.NORMAL=!1,t.UV1=!1,t.UV2=!1,t.VERTEXCOLOR=!1,t.VERTEXALPHA=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.BONETEXTURE=!1,t.BONES_VELOCITY_ENABLED=!1,t.INSTANCES=!1,t.THIN_INSTANCES=!1,t.GLOSSINESS=!1,t.ROUGHNESS=!1,t.EMISSIVEASILLUMINATION=!1,t.LINKEMISSIVEWITHDIFFUSE=!1,t.REFLECTIONFRESNELFROMSPECULAR=!1,t.LIGHTMAP=!1,t.LIGHTMAPDIRECTUV=0,t.OBJECTSPACE_NORMALMAP=!1,t.USELIGHTMAPASSHADOWMAP=!1,t.REFLECTIONMAP_3D=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_CUBIC=!1,t.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.LOGARITHMICDEPTH=!1,t.REFRACTION=!1,t.REFRACTIONMAP_3D=!1,t.REFLECTIONOVERALPHA=!1,t.TWOSIDEDLIGHTING=!1,t.SHADOWFLOAT=!1,t.MORPHTARGETS=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS_TANGENT=!1,t.MORPHTARGETS_UV=!1,t.NUM_MORPH_INFLUENCERS=0,t.NONUNIFORMSCALING=!1,t.PREMULTIPLYALPHA=!1,t.ALPHATEST_AFTERALLALPHACOMPUTATIONS=!1,t.ALPHABLEND=!0,t.PREPASS=!1,t.PREPASS_IRRADIANCE=!1,t.PREPASS_IRRADIANCE_INDEX=-1,t.PREPASS_ALBEDO=!1,t.PREPASS_ALBEDO_INDEX=-1,t.PREPASS_DEPTHNORMAL=!1,t.PREPASS_DEPTHNORMAL_INDEX=-1,t.PREPASS_POSITION=!1,t.PREPASS_POSITION_INDEX=-1,t.PREPASS_VELOCITY=!1,t.PREPASS_VELOCITY_INDEX=-1,t.PREPASS_REFLECTIVITY=!1,t.PREPASS_REFLECTIVITY_INDEX=-1,t.SCENE_MRT_COUNT=0,t.RGBDLIGHTMAP=!1,t.RGBDREFLECTION=!1,t.RGBDREFRACTION=!1,t.IMAGEPROCESSING=!1,t.VIGNETTE=!1,t.VIGNETTEBLENDMODEMULTIPLY=!1,t.VIGNETTEBLENDMODEOPAQUE=!1,t.TONEMAPPING=!1,t.TONEMAPPING_ACES=!1,t.CONTRAST=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.COLORGRADING3D=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.MULTIVIEW=!1,t.IS_REFLECTION_LINEAR=!1,t.IS_REFRACTION_LINEAR=!1,t.EXPOSURE=!1,t.rebuild(),t}return t(i,e),i.prototype.setReflectionMode=function(e){for(var t=0,i=["REFLECTIONMAP_CUBIC","REFLECTIONMAP_EXPLICIT","REFLECTIONMAP_PLANAR","REFLECTIONMAP_PROJECTION","REFLECTIONMAP_PROJECTION","REFLECTIONMAP_SKYBOX","REFLECTIONMAP_SPHERICAL","REFLECTIONMAP_EQUIRECTANGULAR","REFLECTIONMAP_EQUIRECTANGULAR_FIXED","REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"];t<i.length;t++){var r=i[t];this[r]=r===e}},i}(Ri),tr=function(e){function i(t,r){var n=e.call(this,t,r)||this;return n._diffuseTexture=null,n._ambientTexture=null,n._opacityTexture=null,n._reflectionTexture=null,n._emissiveTexture=null,n._specularTexture=null,n._bumpTexture=null,n._lightmapTexture=null,n._refractionTexture=null,n.ambientColor=new T(0,0,0),n.diffuseColor=new T(1,1,1),n.specularColor=new T(1,1,1),n.emissiveColor=new T(0,0,0),n.specularPower=64,n._useAlphaFromDiffuseTexture=!1,n._useEmissiveAsIllumination=!1,n._linkEmissiveWithDiffuse=!1,n._useSpecularOverAlpha=!1,n._useReflectionOverAlpha=!1,n._disableLighting=!1,n._useObjectSpaceNormalMap=!1,n._useParallax=!1,n._useParallaxOcclusion=!1,n.parallaxScaleBias=.05,n._roughness=0,n.indexOfRefraction=.98,n.invertRefractionY=!0,n.alphaCutOff=.4,n._useLightmapAsShadowmap=!1,n._useReflectionFresnelFromSpecular=!1,n._useGlossinessFromSpecularMapAlpha=!1,n._maxSimultaneousLights=4,n._invertNormalMapX=!1,n._invertNormalMapY=!1,n._twoSidedLighting=!1,n.detailMap=new Ji(n._markAllSubMeshesAsTexturesDirty.bind(n)),n._renderTargets=new di(16),n._worldViewProjectionMatrix=m.Zero(),n._globalAmbientColor=new T(0,0,0),n._rebuildInParallel=!1,n._attachImageProcessingConfiguration(null),n.prePassConfiguration=new qi,n.getRenderTargetTextures=function(){return n._renderTargets.reset(),i.ReflectionTextureEnabled&&n._reflectionTexture&&n._reflectionTexture.isRenderTarget&&n._renderTargets.push(n._reflectionTexture),i.RefractionTextureEnabled&&n._refractionTexture&&n._refractionTexture.isRenderTarget&&n._renderTargets.push(n._refractionTexture),n._renderTargets},n}return t(i,e),Object.defineProperty(i.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!1,configurable:!0}),i.prototype._attachImageProcessingConfiguration=function(e){var t=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(){t._markAllSubMeshesAsImageProcessingDirty()}))))},Object.defineProperty(i.prototype,"cameraColorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this._imageProcessingConfiguration.colorGradingTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"cameraColorCurves",{get:function(){return this._imageProcessingConfiguration.colorCurves},set:function(e){this._imageProcessingConfiguration.colorCurves=e},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"canRenderToMRT",{get:function(){return!0},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"hasRenderTargetTextures",{get:function(){return!!(i.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget)||!!(i.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget)},enumerable:!1,configurable:!0}),i.prototype.getClassName=function(){return"StandardMaterial"},Object.defineProperty(i.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(e){this._useLogarithmicDepth=e&&this.getScene().getEngine().getCaps().fragmentDepthSupported,this._markAllSubMeshesAsMiscDirty()},enumerable:!1,configurable:!0}),i.prototype.needAlphaBlending=function(){return!this._disableAlphaBlending&&(this.alpha<1||null!=this._opacityTexture||this._shouldUseAlphaFromDiffuseTexture()||this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled)},i.prototype.needAlphaTesting=function(){return!!this._forceAlphaTest||this._hasAlphaChannel()&&(null==this._transparencyMode||this._transparencyMode===Vt.MATERIAL_ALPHATEST)},i.prototype._shouldUseAlphaFromDiffuseTexture=function(){return null!=this._diffuseTexture&&this._diffuseTexture.hasAlpha&&this._useAlphaFromDiffuseTexture&&this._transparencyMode!==Vt.MATERIAL_OPAQUE},i.prototype._hasAlphaChannel=function(){return null!=this._diffuseTexture&&this._diffuseTexture.hasAlpha||null!=this._opacityTexture},i.prototype.getAlphaTestTexture=function(){return this._diffuseTexture},i.prototype.isReadyForSubMesh=function(e,t,r){if(void 0===r&&(r=!1),t.effect&&this.isFrozen&&t.effect._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new er);var n=this.getScene(),o=t._materialDefines;if(this._isReadyForSubMesh(t))return!0;var s=n.getEngine();if(o._needNormals=Xi.PrepareDefinesForLights(n,e,o,!0,this._maxSimultaneousLights,this._disableLighting),Xi.PrepareDefinesForMultiview(n,o),Xi.PrepareDefinesForPrePass(n,o,this.canRenderToMRT),o._areTexturesDirty){if(o._needUVs=!1,o.MAINUV1=!1,o.MAINUV2=!1,n.texturesEnabled){if(this._diffuseTexture&&i.DiffuseTextureEnabled){if(!this._diffuseTexture.isReadyOrNotBlocking())return!1;Xi.PrepareDefinesForMergedUV(this._diffuseTexture,o,"DIFFUSE")}else o.DIFFUSE=!1;if(this._ambientTexture&&i.AmbientTextureEnabled){if(!this._ambientTexture.isReadyOrNotBlocking())return!1;Xi.PrepareDefinesForMergedUV(this._ambientTexture,o,"AMBIENT")}else o.AMBIENT=!1;if(this._opacityTexture&&i.OpacityTextureEnabled){if(!this._opacityTexture.isReadyOrNotBlocking())return!1;Xi.PrepareDefinesForMergedUV(this._opacityTexture,o,"OPACITY"),o.OPACITYRGB=this._opacityTexture.getAlphaFromRGB}else o.OPACITY=!1;if(this._reflectionTexture&&i.ReflectionTextureEnabled){if(!this._reflectionTexture.isReadyOrNotBlocking())return!1;switch(o._needNormals=!0,o.REFLECTION=!0,o.ROUGHNESS=this._roughness>0,o.REFLECTIONOVERALPHA=this._useReflectionOverAlpha,o.INVERTCUBICMAP=this._reflectionTexture.coordinatesMode===Re.INVCUBIC_MODE,o.REFLECTIONMAP_3D=this._reflectionTexture.isCube,o.RGBDREFLECTION=this._reflectionTexture.isRGBD,this._reflectionTexture.coordinatesMode){case Re.EXPLICIT_MODE:o.setReflectionMode("REFLECTIONMAP_EXPLICIT");break;case Re.PLANAR_MODE:o.setReflectionMode("REFLECTIONMAP_PLANAR");break;case Re.PROJECTION_MODE:o.setReflectionMode("REFLECTIONMAP_PROJECTION");break;case Re.SKYBOX_MODE:o.setReflectionMode("REFLECTIONMAP_SKYBOX");break;case Re.SPHERICAL_MODE:o.setReflectionMode("REFLECTIONMAP_SPHERICAL");break;case Re.EQUIRECTANGULAR_MODE:o.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");break;case Re.FIXED_EQUIRECTANGULAR_MODE:o.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");break;case Re.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:o.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");break;case Re.CUBIC_MODE:case Re.INVCUBIC_MODE:default:o.setReflectionMode("REFLECTIONMAP_CUBIC")}o.USE_LOCAL_REFLECTIONMAP_CUBIC=!!this._reflectionTexture.boundingBoxSize}else o.REFLECTION=!1;if(this._emissiveTexture&&i.EmissiveTextureEnabled){if(!this._emissiveTexture.isReadyOrNotBlocking())return!1;Xi.PrepareDefinesForMergedUV(this._emissiveTexture,o,"EMISSIVE")}else o.EMISSIVE=!1;if(this._lightmapTexture&&i.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;Xi.PrepareDefinesForMergedUV(this._lightmapTexture,o,"LIGHTMAP"),o.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap,o.RGBDLIGHTMAP=this._lightmapTexture.isRGBD}else o.LIGHTMAP=!1;if(this._specularTexture&&i.SpecularTextureEnabled){if(!this._specularTexture.isReadyOrNotBlocking())return!1;Xi.PrepareDefinesForMergedUV(this._specularTexture,o,"SPECULAR"),o.GLOSSINESS=this._useGlossinessFromSpecularMapAlpha}else o.SPECULAR=!1;if(n.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&i.BumpTextureEnabled){if(!this._bumpTexture.isReady())return!1;Xi.PrepareDefinesForMergedUV(this._bumpTexture,o,"BUMP"),o.PARALLAX=this._useParallax,o.PARALLAXOCCLUSION=this._useParallaxOcclusion,o.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap}else o.BUMP=!1;if(this._refractionTexture&&i.RefractionTextureEnabled){if(!this._refractionTexture.isReadyOrNotBlocking())return!1;o._needUVs=!0,o.REFRACTION=!0,o.REFRACTIONMAP_3D=this._refractionTexture.isCube,o.RGBDREFRACTION=this._refractionTexture.isRGBD}else o.REFRACTION=!1;o.TWOSIDEDLIGHTING=!this._backFaceCulling&&this._twoSidedLighting}else o.DIFFUSE=!1,o.AMBIENT=!1,o.OPACITY=!1,o.REFLECTION=!1,o.EMISSIVE=!1,o.LIGHTMAP=!1,o.BUMP=!1,o.REFRACTION=!1;o.ALPHAFROMDIFFUSE=this._shouldUseAlphaFromDiffuseTexture(),o.EMISSIVEASILLUMINATION=this._useEmissiveAsIllumination,o.LINKEMISSIVEWITHDIFFUSE=this._linkEmissiveWithDiffuse,o.SPECULAROVERALPHA=this._useSpecularOverAlpha,o.PREMULTIPLYALPHA=7===this.alphaMode||8===this.alphaMode,o.ALPHATEST_AFTERALLALPHACOMPUTATIONS=null!==this.transparencyMode,o.ALPHABLEND=null===this.transparencyMode||this.needAlphaBlendingForMesh(e)}if(!this.detailMap.isReadyForSubMesh(o,n))return!1;if(o._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(o),o.IS_REFLECTION_LINEAR=null!=this.reflectionTexture&&!this.reflectionTexture.gammaSpace,o.IS_REFRACTION_LINEAR=null!=this.refractionTexture&&!this.refractionTexture.gammaSpace}if(o._areFresnelDirty&&(i.FresnelEnabled?(this._diffuseFresnelParameters||this._opacityFresnelParameters||this._emissiveFresnelParameters||this._refractionFresnelParameters||this._reflectionFresnelParameters)&&(o.DIFFUSEFRESNEL=this._diffuseFresnelParameters&&this._diffuseFresnelParameters.isEnabled,o.OPACITYFRESNEL=this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled,o.REFLECTIONFRESNEL=this._reflectionFresnelParameters&&this._reflectionFresnelParameters.isEnabled,o.REFLECTIONFRESNELFROMSPECULAR=this._useReflectionFresnelFromSpecular,o.REFRACTIONFRESNEL=this._refractionFresnelParameters&&this._refractionFresnelParameters.isEnabled,o.EMISSIVEFRESNEL=this._emissiveFresnelParameters&&this._emissiveFresnelParameters.isEnabled,o._needNormals=!0,o.FRESNEL=!0):o.FRESNEL=!1),Xi.PrepareDefinesForMisc(e,n,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e)||this._forceAlphaTest,o),Xi.PrepareDefinesForAttributes(e,o,!0,!0,!0),Xi.PrepareDefinesForFrameBoundValues(n,s,o,r,null,t.getRenderingMesh().hasThinInstances),this.detailMap.prepareDefines(o,n),o.isDirty){var a=o._areLightsDisposed;o.markAsProcessed();var h=new ji;o.REFLECTION&&h.addFallback(0,"REFLECTION"),o.SPECULAR&&h.addFallback(0,"SPECULAR"),o.BUMP&&h.addFallback(0,"BUMP"),o.PARALLAX&&h.addFallback(1,"PARALLAX"),o.PARALLAXOCCLUSION&&h.addFallback(0,"PARALLAXOCCLUSION"),o.SPECULAROVERALPHA&&h.addFallback(0,"SPECULAROVERALPHA"),o.FOG&&h.addFallback(1,"FOG"),o.POINTSIZE&&h.addFallback(0,"POINTSIZE"),o.LOGARITHMICDEPTH&&h.addFallback(0,"LOGARITHMICDEPTH"),Xi.HandleFallbacksForShadows(o,h,this._maxSimultaneousLights),o.SPECULARTERM&&h.addFallback(0,"SPECULARTERM"),o.DIFFUSEFRESNEL&&h.addFallback(1,"DIFFUSEFRESNEL"),o.OPACITYFRESNEL&&h.addFallback(2,"OPACITYFRESNEL"),o.REFLECTIONFRESNEL&&h.addFallback(3,"REFLECTIONFRESNEL"),o.EMISSIVEFRESNEL&&h.addFallback(4,"EMISSIVEFRESNEL"),o.FRESNEL&&h.addFallback(4,"FRESNEL"),o.MULTIVIEW&&h.addFallback(0,"MULTIVIEW");var u=[ft.PositionKind];o.NORMAL&&u.push(ft.NormalKind),o.UV1&&u.push(ft.UVKind),o.UV2&&u.push(ft.UV2Kind),o.VERTEXCOLOR&&u.push(ft.ColorKind),Xi.PrepareAttributesForBones(u,e,o,h),Xi.PrepareAttributesForInstances(u,o),Xi.PrepareAttributesForMorphTargets(u,e,o);var l="default",c=["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"],f=["diffuseSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","specularSampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler","boneSampler"],d=["Material","Scene"];Ji.AddUniforms(c),Ji.AddSamplers(f),qi.AddUniforms(c),qi.AddSamplers(c),wi&&(wi.PrepareUniforms(c,o),wi.PrepareSamplers(f,o)),Xi.PrepareUniformsAndSamplersList({uniformsNames:c,uniformBuffersNames:d,samplers:f,defines:o,maxSimultaneousLights:this._maxSimultaneousLights});var p={};this.customShaderNameResolve&&(l=this.customShaderNameResolve(l,c,d,f,o,u,p));var _=o.toString(),g=t.effect,m=n.getEngine().createEffect(l,{attributes:u,uniformsNames:c,uniformBuffersNames:d,samplers:f,defines:_,fallbacks:h,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:o.NUM_MORPH_INFLUENCERS},processFinalCode:p.processFinalCode,multiTarget:o.PREPASS},s);if(m)if(this._onEffectCreatedObservable&&($i.effect=m,$i.subMesh=t,this._onEffectCreatedObservable.notifyObservers($i)),this.allowShaderHotSwapping&&g&&!m.isReady()){if(m=g,this._rebuildInParallel=!0,o.markAsUnprocessed(),a)return o._areLightsDisposed=!0,!1}else this._rebuildInParallel=!1,n.resetCachedMaterial(),t.setEffect(m,o),this.buildUniformLayout()}return!(!t.effect||!t.effect.isReady())&&(o._renderId=n.getRenderId(),t.effect._wasPreviouslyReady=!0,!0)},i.prototype.buildUniformLayout=function(){var e=this._uniformBuffer;e.addUniform("diffuseLeftColor",4),e.addUniform("diffuseRightColor",4),e.addUniform("opacityParts",4),e.addUniform("reflectionLeftColor",4),e.addUniform("reflectionRightColor",4),e.addUniform("refractionLeftColor",4),e.addUniform("refractionRightColor",4),e.addUniform("emissiveLeftColor",4),e.addUniform("emissiveRightColor",4),e.addUniform("vDiffuseInfos",2),e.addUniform("vAmbientInfos",2),e.addUniform("vOpacityInfos",2),e.addUniform("vReflectionInfos",2),e.addUniform("vReflectionPosition",3),e.addUniform("vReflectionSize",3),e.addUniform("vEmissiveInfos",2),e.addUniform("vLightmapInfos",2),e.addUniform("vSpecularInfos",2),e.addUniform("vBumpInfos",3),e.addUniform("diffuseMatrix",16),e.addUniform("ambientMatrix",16),e.addUniform("opacityMatrix",16),e.addUniform("reflectionMatrix",16),e.addUniform("emissiveMatrix",16),e.addUniform("lightmapMatrix",16),e.addUniform("specularMatrix",16),e.addUniform("bumpMatrix",16),e.addUniform("vTangentSpaceParams",2),e.addUniform("pointSize",1),e.addUniform("refractionMatrix",16),e.addUniform("vRefractionInfos",4),e.addUniform("vSpecularColor",4),e.addUniform("vEmissiveColor",3),e.addUniform("visibility",1),e.addUniform("vDiffuseColor",4),Ji.PrepareUniformBuffer(e),e.create()},i.prototype.unbind=function(){if(this._activeEffect){var t=!1;this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&(this._activeEffect.setTexture("reflection2DSampler",null),t=!0),this._refractionTexture&&this._refractionTexture.isRenderTarget&&(this._activeEffect.setTexture("refraction2DSampler",null),t=!0),t&&this._markAllSubMeshesAsTexturesDirty()}e.prototype.unbind.call(this)},i.prototype.bindForSubMesh=function(e,t,r){var n=this.getScene(),o=r._materialDefines;if(o){var s=r.effect;if(s){this._activeEffect=s,o.INSTANCES&&!o.THIN_INSTANCES||this.bindOnlyWorldMatrix(e),this.prePassConfiguration.bindForSubMesh(this._activeEffect,n,t,e,this.isFrozen),o.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));var a=this._mustRebind(n,s,t.visibility);Xi.BindBonesParameters(t,s);var h=this._uniformBuffer;if(a){if(h.bindToEffect(s,"Material"),this.bindViewProjection(s),!h.useUbo||!this.isFrozen||!h.isSync){if(i.FresnelEnabled&&o.FRESNEL&&(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled&&(h.updateColor4("diffuseLeftColor",this.diffuseFresnelParameters.leftColor,this.diffuseFresnelParameters.power),h.updateColor4("diffuseRightColor",this.diffuseFresnelParameters.rightColor,this.diffuseFresnelParameters.bias)),this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled&&h.updateColor4("opacityParts",new T(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias),this.opacityFresnelParameters.power),this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled&&(h.updateColor4("reflectionLeftColor",this.reflectionFresnelParameters.leftColor,this.reflectionFresnelParameters.power),h.updateColor4("reflectionRightColor",this.reflectionFresnelParameters.rightColor,this.reflectionFresnelParameters.bias)),this.refractionFresnelParameters&&this.refractionFresnelParameters.isEnabled&&(h.updateColor4("refractionLeftColor",this.refractionFresnelParameters.leftColor,this.refractionFresnelParameters.power),h.updateColor4("refractionRightColor",this.refractionFresnelParameters.rightColor,this.refractionFresnelParameters.bias)),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(h.updateColor4("emissiveLeftColor",this.emissiveFresnelParameters.leftColor,this.emissiveFresnelParameters.power),h.updateColor4("emissiveRightColor",this.emissiveFresnelParameters.rightColor,this.emissiveFresnelParameters.bias))),n.texturesEnabled){if(this._diffuseTexture&&i.DiffuseTextureEnabled&&(h.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),Xi.BindTextureMatrix(this._diffuseTexture,h,"diffuse")),this._ambientTexture&&i.AmbientTextureEnabled&&(h.updateFloat2("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level),Xi.BindTextureMatrix(this._ambientTexture,h,"ambient")),this._opacityTexture&&i.OpacityTextureEnabled&&(h.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),Xi.BindTextureMatrix(this._opacityTexture,h,"opacity")),this._hasAlphaChannel()&&s.setFloat("alphaCutOff",this.alphaCutOff),this._reflectionTexture&&i.ReflectionTextureEnabled&&(h.updateFloat2("vReflectionInfos",this._reflectionTexture.level,this.roughness),h.updateMatrix("reflectionMatrix",this._reflectionTexture.getReflectionTextureMatrix()),this._reflectionTexture.boundingBoxSize)){var u=this._reflectionTexture;h.updateVector3("vReflectionPosition",u.boundingBoxPosition),h.updateVector3("vReflectionSize",u.boundingBoxSize)}if(this._emissiveTexture&&i.EmissiveTextureEnabled&&(h.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),Xi.BindTextureMatrix(this._emissiveTexture,h,"emissive")),this._lightmapTexture&&i.LightmapTextureEnabled&&(h.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),Xi.BindTextureMatrix(this._lightmapTexture,h,"lightmap")),this._specularTexture&&i.SpecularTextureEnabled&&(h.updateFloat2("vSpecularInfos",this._specularTexture.coordinatesIndex,this._specularTexture.level),Xi.BindTextureMatrix(this._specularTexture,h,"specular")),this._bumpTexture&&n.getEngine().getCaps().standardDerivatives&&i.BumpTextureEnabled&&(h.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,1/this._bumpTexture.level,this.parallaxScaleBias),Xi.BindTextureMatrix(this._bumpTexture,h,"bump"),n._mirroredCameraPosition?h.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):h.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1)),this._refractionTexture&&i.RefractionTextureEnabled){var l=1;this._refractionTexture.isCube||(h.updateMatrix("refractionMatrix",this._refractionTexture.getReflectionTextureMatrix()),this._refractionTexture.depth&&(l=this._refractionTexture.depth)),h.updateFloat4("vRefractionInfos",this._refractionTexture.level,this.indexOfRefraction,l,this.invertRefractionY?-1:1)}}this.pointsCloud&&h.updateFloat("pointSize",this.pointSize),o.SPECULARTERM&&h.updateColor4("vSpecularColor",this.specularColor,this.specularPower),h.updateColor3("vEmissiveColor",i.EmissiveTextureEnabled?this.emissiveColor:T.BlackReadOnly),h.updateColor4("vDiffuseColor",this.diffuseColor,this.alpha)}if(h.updateFloat("visibility",t.visibility),n.texturesEnabled&&(this._diffuseTexture&&i.DiffuseTextureEnabled&&s.setTexture("diffuseSampler",this._diffuseTexture),this._ambientTexture&&i.AmbientTextureEnabled&&s.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&i.OpacityTextureEnabled&&s.setTexture("opacitySampler",this._opacityTexture),this._reflectionTexture&&i.ReflectionTextureEnabled&&(this._reflectionTexture.isCube?s.setTexture("reflectionCubeSampler",this._reflectionTexture):s.setTexture("reflection2DSampler",this._reflectionTexture)),this._emissiveTexture&&i.EmissiveTextureEnabled&&s.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&i.LightmapTextureEnabled&&s.setTexture("lightmapSampler",this._lightmapTexture),this._specularTexture&&i.SpecularTextureEnabled&&s.setTexture("specularSampler",this._specularTexture),this._bumpTexture&&n.getEngine().getCaps().standardDerivatives&&i.BumpTextureEnabled&&s.setTexture("bumpSampler",this._bumpTexture),this._refractionTexture&&i.RefractionTextureEnabled)){l=1;this._refractionTexture.isCube?s.setTexture("refractionCubeSampler",this._refractionTexture):s.setTexture("refraction2DSampler",this._refractionTexture)}this.detailMap.bindForSubMesh(h,n,this.isFrozen),Xi.BindClipPlane(s,n),n.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),Xi.BindEyePosition(s,n),s.setColor3("vAmbientColor",this._globalAmbientColor)}!a&&this.isFrozen||(n.lightsEnabled&&!this._disableLighting&&Xi.BindLights(n,t,s,o,this._maxSimultaneousLights,this._rebuildInParallel),(n.fogEnabled&&t.applyFog&&n.fogMode!==zi.FOGMODE_NONE||this._reflectionTexture||this._refractionTexture)&&this.bindView(s),Xi.BindFogParameters(n,t,s),o.NUM_MORPH_INFLUENCERS&&Xi.BindMorphTargetParameters(t,s),this.useLogarithmicDepth&&Xi.BindLogDepth(o,s,n),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(this._activeEffect)),h.update(),this._afterBind(t,this._activeEffect)}}},i.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&e.push(this._emissiveTexture),this._specularTexture&&this._specularTexture.animations&&this._specularTexture.animations.length>0&&e.push(this._specularTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&e.push(this._lightmapTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),this.detailMap.getAnimatables(e),e},i.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this._diffuseTexture&&t.push(this._diffuseTexture),this._ambientTexture&&t.push(this._ambientTexture),this._opacityTexture&&t.push(this._opacityTexture),this._reflectionTexture&&t.push(this._reflectionTexture),this._emissiveTexture&&t.push(this._emissiveTexture),this._specularTexture&&t.push(this._specularTexture),this._bumpTexture&&t.push(this._bumpTexture),this._lightmapTexture&&t.push(this._lightmapTexture),this._refractionTexture&&t.push(this._refractionTexture),this.detailMap.getActiveTextures(t),t},i.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||(this._diffuseTexture===t||(this._ambientTexture===t||(this._opacityTexture===t||(this._reflectionTexture===t||(this._emissiveTexture===t||(this._specularTexture===t||(this._bumpTexture===t||(this._lightmapTexture===t||(this._refractionTexture===t||this.detailMap.hasTexture(t))))))))))},i.prototype.dispose=function(t,i){var r,n,o,s,a,h,u,l,c;i&&(null===(r=this._diffuseTexture)||void 0===r||r.dispose(),null===(n=this._ambientTexture)||void 0===n||n.dispose(),null===(o=this._opacityTexture)||void 0===o||o.dispose(),null===(s=this._reflectionTexture)||void 0===s||s.dispose(),null===(a=this._emissiveTexture)||void 0===a||a.dispose(),null===(h=this._specularTexture)||void 0===h||h.dispose(),null===(u=this._bumpTexture)||void 0===u||u.dispose(),null===(l=this._lightmapTexture)||void 0===l||l.dispose(),null===(c=this._refractionTexture)||void 0===c||c.dispose()),this.detailMap.dispose(i),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),e.prototype.dispose.call(this,t,i)},i.prototype.clone=function(e){var t=this,r=N.Clone((function(){return new i(e,t.getScene())}),this);return r.name=e,r.id=e,r},i.prototype.serialize=function(){return N.Serialize(this)},i.Parse=function(e,t,r){return N.Parse((function(){return new i(e.name,t)}),e,t,r)},Object.defineProperty(i,"DiffuseTextureEnabled",{get:function(){return Qi.DiffuseTextureEnabled},set:function(e){Qi.DiffuseTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(i,"DetailTextureEnabled",{get:function(){return Qi.DetailTextureEnabled},set:function(e){Qi.DetailTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(i,"AmbientTextureEnabled",{get:function(){return Qi.AmbientTextureEnabled},set:function(e){Qi.AmbientTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(i,"OpacityTextureEnabled",{get:function(){return Qi.OpacityTextureEnabled},set:function(e){Qi.OpacityTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(i,"ReflectionTextureEnabled",{get:function(){return Qi.ReflectionTextureEnabled},set:function(e){Qi.ReflectionTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(i,"EmissiveTextureEnabled",{get:function(){return Qi.EmissiveTextureEnabled},set:function(e){Qi.EmissiveTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(i,"SpecularTextureEnabled",{get:function(){return Qi.SpecularTextureEnabled},set:function(e){Qi.SpecularTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(i,"BumpTextureEnabled",{get:function(){return Qi.BumpTextureEnabled},set:function(e){Qi.BumpTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(i,"LightmapTextureEnabled",{get:function(){return Qi.LightmapTextureEnabled},set:function(e){Qi.LightmapTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(i,"RefractionTextureEnabled",{get:function(){return Qi.RefractionTextureEnabled},set:function(e){Qi.RefractionTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(i,"ColorGradingTextureEnabled",{get:function(){return Qi.ColorGradingTextureEnabled},set:function(e){Qi.ColorGradingTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(i,"FresnelEnabled",{get:function(){return Qi.FresnelEnabled},set:function(e){Qi.FresnelEnabled=e},enumerable:!1,configurable:!0}),r([R("diffuseTexture")],i.prototype,"_diffuseTexture",void 0),r([I("_markAllSubMeshesAsTexturesAndMiscDirty")],i.prototype,"diffuseTexture",void 0),r([R("ambientTexture")],i.prototype,"_ambientTexture",void 0),r([I("_markAllSubMeshesAsTexturesDirty")],i.prototype,"ambientTexture",void 0),r([R("opacityTexture")],i.prototype,"_opacityTexture",void 0),r([I("_markAllSubMeshesAsTexturesAndMiscDirty")],i.prototype,"opacityTexture",void 0),r([R("reflectionTexture")],i.prototype,"_reflectionTexture",void 0),r([I("_markAllSubMeshesAsTexturesDirty")],i.prototype,"reflectionTexture",void 0),r([R("emissiveTexture")],i.prototype,"_emissiveTexture",void 0),r([I("_markAllSubMeshesAsTexturesDirty")],i.prototype,"emissiveTexture",void 0),r([R("specularTexture")],i.prototype,"_specularTexture",void 0),r([I("_markAllSubMeshesAsTexturesDirty")],i.prototype,"specularTexture",void 0),r([R("bumpTexture")],i.prototype,"_bumpTexture",void 0),r([I("_markAllSubMeshesAsTexturesDirty")],i.prototype,"bumpTexture",void 0),r([R("lightmapTexture")],i.prototype,"_lightmapTexture",void 0),r([I("_markAllSubMeshesAsTexturesDirty")],i.prototype,"lightmapTexture",void 0),r([R("refractionTexture")],i.prototype,"_refractionTexture",void 0),r([I("_markAllSubMeshesAsTexturesDirty")],i.prototype,"refractionTexture",void 0),r([D("ambient")],i.prototype,"ambientColor",void 0),r([D("diffuse")],i.prototype,"diffuseColor",void 0),r([D("specular")],i.prototype,"specularColor",void 0),r([D("emissive")],i.prototype,"emissiveColor",void 0),r([O()],i.prototype,"specularPower",void 0),r([O("useAlphaFromDiffuseTexture")],i.prototype,"_useAlphaFromDiffuseTexture",void 0),r([I("_markAllSubMeshesAsTexturesAndMiscDirty")],i.prototype,"useAlphaFromDiffuseTexture",void 0),r([O("useEmissiveAsIllumination")],i.prototype,"_useEmissiveAsIllumination",void 0),r([I("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useEmissiveAsIllumination",void 0),r([O("linkEmissiveWithDiffuse")],i.prototype,"_linkEmissiveWithDiffuse",void 0),r([I("_markAllSubMeshesAsTexturesDirty")],i.prototype,"linkEmissiveWithDiffuse",void 0),r([O("useSpecularOverAlpha")],i.prototype,"_useSpecularOverAlpha",void 0),r([I("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useSpecularOverAlpha",void 0),r([O("useReflectionOverAlpha")],i.prototype,"_useReflectionOverAlpha",void 0),r([I("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useReflectionOverAlpha",void 0),r([O("disableLighting")],i.prototype,"_disableLighting",void 0),r([I("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),r([O("useObjectSpaceNormalMap")],i.prototype,"_useObjectSpaceNormalMap",void 0),r([I("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useObjectSpaceNormalMap",void 0),r([O("useParallax")],i.prototype,"_useParallax",void 0),r([I("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useParallax",void 0),r([O("useParallaxOcclusion")],i.prototype,"_useParallaxOcclusion",void 0),r([I("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useParallaxOcclusion",void 0),r([O()],i.prototype,"parallaxScaleBias",void 0),r([O("roughness")],i.prototype,"_roughness",void 0),r([I("_markAllSubMeshesAsTexturesDirty")],i.prototype,"roughness",void 0),r([O()],i.prototype,"indexOfRefraction",void 0),r([O()],i.prototype,"invertRefractionY",void 0),r([O()],i.prototype,"alphaCutOff",void 0),r([O("useLightmapAsShadowmap")],i.prototype,"_useLightmapAsShadowmap",void 0),r([I("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useLightmapAsShadowmap",void 0),r([w("diffuseFresnelParameters")],i.prototype,"_diffuseFresnelParameters",void 0),r([I("_markAllSubMeshesAsFresnelDirty")],i.prototype,"diffuseFresnelParameters",void 0),r([w("opacityFresnelParameters")],i.prototype,"_opacityFresnelParameters",void 0),r([I("_markAllSubMeshesAsFresnelAndMiscDirty")],i.prototype,"opacityFresnelParameters",void 0),r([w("reflectionFresnelParameters")],i.prototype,"_reflectionFresnelParameters",void 0),r([I("_markAllSubMeshesAsFresnelDirty")],i.prototype,"reflectionFresnelParameters",void 0),r([w("refractionFresnelParameters")],i.prototype,"_refractionFresnelParameters",void 0),r([I("_markAllSubMeshesAsFresnelDirty")],i.prototype,"refractionFresnelParameters",void 0),r([w("emissiveFresnelParameters")],i.prototype,"_emissiveFresnelParameters",void 0),r([I("_markAllSubMeshesAsFresnelDirty")],i.prototype,"emissiveFresnelParameters",void 0),r([O("useReflectionFresnelFromSpecular")],i.prototype,"_useReflectionFresnelFromSpecular",void 0),r([I("_markAllSubMeshesAsFresnelDirty")],i.prototype,"useReflectionFresnelFromSpecular",void 0),r([O("useGlossinessFromSpecularMapAlpha")],i.prototype,"_useGlossinessFromSpecularMapAlpha",void 0),r([I("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useGlossinessFromSpecularMapAlpha",void 0),r([O("maxSimultaneousLights")],i.prototype,"_maxSimultaneousLights",void 0),r([I("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),r([O("invertNormalMapX")],i.prototype,"_invertNormalMapX",void 0),r([I("_markAllSubMeshesAsTexturesDirty")],i.prototype,"invertNormalMapX",void 0),r([O("invertNormalMapY")],i.prototype,"_invertNormalMapY",void 0),r([I("_markAllSubMeshesAsTexturesDirty")],i.prototype,"invertNormalMapY",void 0),r([O("twoSidedLighting")],i.prototype,"_twoSidedLighting",void 0),r([I("_markAllSubMeshesAsTexturesDirty")],i.prototype,"twoSidedLighting",void 0),r([O()],i.prototype,"useLogarithmicDepth",null),i}(Zi);c.RegisteredTypes["BABYLON.StandardMaterial"]=tr,zi.DefaultMaterialFactory=function(e){return new tr("default material",e)},Zt._instancedMeshFactory=function(e,t){var i=new ir(e,t);if(t.instancedBuffers)for(var r in i.instancedBuffers={},t.instancedBuffers)i.instancedBuffers[r]=t.instancedBuffers[r];return i};var ir=function(e){function i(t,i){var r=e.call(this,t,i.getScene())||this;r._indexInSourceMeshInstanceArray=-1,i.addInstance(r),r._sourceMesh=i,r._unIndexed=i._unIndexed,r.position.copyFrom(i.position),r.rotation.copyFrom(i.rotation),r.scaling.copyFrom(i.scaling),i.rotationQuaternion&&(r.rotationQuaternion=i.rotationQuaternion.clone()),r.animations=Ue.Slice(i.animations);for(var n=0,o=i.getAnimationRanges();n<o.length;n++){var s=o[n];null!=s&&r.createAnimationRange(s.name,s.from,s.to)}return r.infiniteDistance=i.infiniteDistance,r.setPivotMatrix(i.getPivotMatrix()),r.refreshBoundingInfo(),r._syncSubMeshes(),r}return t(i,e),i.prototype.getClassName=function(){return"InstancedMesh"},Object.defineProperty(i.prototype,"lightSources",{get:function(){return this._sourceMesh._lightSources},enumerable:!1,configurable:!0}),i.prototype._resyncLightSources=function(){},i.prototype._resyncLightSource=function(e){},i.prototype._removeLightSource=function(e,t){},Object.defineProperty(i.prototype,"receiveShadows",{get:function(){return this._sourceMesh.receiveShadows},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"material",{get:function(){return this._sourceMesh.material},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"visibility",{get:function(){return this._sourceMesh.visibility},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"skeleton",{get:function(){return this._sourceMesh.skeleton},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"renderingGroupId",{get:function(){return this._sourceMesh.renderingGroupId},set:function(e){this._sourceMesh&&e!==this._sourceMesh.renderingGroupId&&q.Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene")},enumerable:!1,configurable:!0}),i.prototype.getTotalVertices=function(){return this._sourceMesh?this._sourceMesh.getTotalVertices():0},i.prototype.getTotalIndices=function(){return this._sourceMesh.getTotalIndices()},Object.defineProperty(i.prototype,"sourceMesh",{get:function(){return this._sourceMesh},enumerable:!1,configurable:!0}),i.prototype.createInstance=function(e){return this._sourceMesh.createInstance(e)},i.prototype.isReady=function(e){return void 0===e&&(e=!1),this._sourceMesh.isReady(e,!0)},i.prototype.getVerticesData=function(e,t){return this._sourceMesh.getVerticesData(e,t)},i.prototype.setVerticesData=function(e,t,i,r){return this.sourceMesh&&this.sourceMesh.setVerticesData(e,t,i,r),this.sourceMesh},i.prototype.updateVerticesData=function(e,t,i,r){return this.sourceMesh&&this.sourceMesh.updateVerticesData(e,t,i,r),this.sourceMesh},i.prototype.setIndices=function(e,t){return void 0===t&&(t=null),this.sourceMesh&&this.sourceMesh.setIndices(e,t),this.sourceMesh},i.prototype.isVerticesDataPresent=function(e){return this._sourceMesh.isVerticesDataPresent(e)},i.prototype.getIndices=function(){return this._sourceMesh.getIndices()},Object.defineProperty(i.prototype,"_positions",{get:function(){return this._sourceMesh._positions},enumerable:!1,configurable:!0}),i.prototype.refreshBoundingInfo=function(e){if(void 0===e&&(e=!1),this._boundingInfo&&this._boundingInfo.isLocked)return this;var t=this._sourceMesh.geometry?this._sourceMesh.geometry.boundingBias:null;return this._refreshBoundingInfo(this._sourceMesh._getPositionData(e),t),this},i.prototype._preActivate=function(){return this._currentLOD&&this._currentLOD._preActivate(),this},i.prototype._activate=function(e,t){if(this._sourceMesh.subMeshes||q.Warn("Instances should only be created for meshes with geometry."),this._currentLOD){if(this._currentLOD._getWorldMatrixDeterminant()>0!=this._getWorldMatrixDeterminant()>0)return this._internalAbstractMeshDataInfo._actAsRegularMesh=!0,!0;if(this._internalAbstractMeshDataInfo._actAsRegularMesh=!1,this._currentLOD._registerInstanceForRenderId(this,e),t){if(!this._currentLOD._internalAbstractMeshDataInfo._isActiveIntermediate)return this._currentLOD._internalAbstractMeshDataInfo._onlyForInstancesIntermediate=!0,!0}else if(!this._currentLOD._internalAbstractMeshDataInfo._isActive)return this._currentLOD._internalAbstractMeshDataInfo._onlyForInstances=!0,!0}return!1},i.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)},i.prototype.getWorldMatrix=function(){if(this._currentLOD&&this._currentLOD.billboardMode!==wt.BILLBOARDMODE_NONE&&this._currentLOD._masterMesh!==this){var t=this._currentLOD._masterMesh;return this._currentLOD._masterMesh=this,y.Vector3[7].copyFrom(this._currentLOD.position),this._currentLOD.position.set(0,0,0),y.Matrix[0].copyFrom(this._currentLOD.computeWorldMatrix(!0)),this._currentLOD.position.copyFrom(y.Vector3[7]),this._currentLOD._masterMesh=t,y.Matrix[0]}return e.prototype.getWorldMatrix.call(this)},Object.defineProperty(i.prototype,"isAnInstance",{get:function(){return!0},enumerable:!1,configurable:!0}),i.prototype.getLOD=function(e){if(!e)return this;var t=this.getBoundingInfo();return this._currentLOD=this.sourceMesh.getLOD(e,t.boundingSphere),this._currentLOD===this.sourceMesh?this.sourceMesh:this._currentLOD},i.prototype._preActivateForIntermediateRendering=function(e){return this.sourceMesh._preActivateForIntermediateRendering(e)},i.prototype._syncSubMeshes=function(){if(this.releaseSubMeshes(),this._sourceMesh.subMeshes)for(var e=0;e<this._sourceMesh.subMeshes.length;e++)this._sourceMesh.subMeshes[e].clone(this,this._sourceMesh);return this},i.prototype._generatePointsArray=function(){return this._sourceMesh._generatePointsArray()},i.prototype._updateBoundingInfo=function(){var e=this;return this._boundingInfo?this._boundingInfo.update(e.worldMatrixFromCache):this._boundingInfo=new Tt(this.absolutePosition,this.absolutePosition,e.worldMatrixFromCache),this._updateSubMeshesBoundingInfo(e.worldMatrixFromCache),this},i.prototype.clone=function(e,t,i){void 0===t&&(t=null);var r=this._sourceMesh.createInstance(e);if(Le.DeepCopy(this,r,["name","subMeshes","uniqueId","parent","lightSources","receiveShadows","material","visibility","skeleton","sourceMesh","isAnInstance","facetNb","isFacetDataEnabled","isBlocked","useBones","hasInstances","collider","edgesRenderer","forward","up","right","absolutePosition","absoluteScaling","absoluteRotationQuaternion","isWorldMatrixFrozen","nonUniformScaling","behaviors","worldMatrixFromCache","hasThinInstances"],[]),this.refreshBoundingInfo(),t&&(r.parent=t),!i)for(var n=0;n<this.getScene().meshes.length;n++){var o=this.getScene().meshes[n];o.parent===this&&o.clone(o.name,r)}return r.computeWorldMatrix(!0),r},i.prototype.dispose=function(t,i){void 0===i&&(i=!1),this._sourceMesh.removeInstance(this),e.prototype.dispose.call(this,t,i)},i}(kt);Zt.prototype.edgesShareWithInstances=!1,Zt.prototype.registerInstancedBuffer=function(e,t){if(this.removeVerticesData(e),!this.instancedBuffers){this.instancedBuffers={};for(var i=0,r=this.instances;i<r.length;i++){r[i].instancedBuffers={}}this._userInstancedBuffersStorage={data:{},vertexBuffers:{},strides:{},sizes:{}}}this.instancedBuffers[e]=null,this._userInstancedBuffersStorage.strides[e]=t,this._userInstancedBuffersStorage.sizes[e]=32*t,this._userInstancedBuffersStorage.data[e]=new Float32Array(this._userInstancedBuffersStorage.sizes[e]),this._userInstancedBuffersStorage.vertexBuffers[e]=new ft(this.getEngine(),this._userInstancedBuffersStorage.data[e],e,!0,!1,t,!0),this.setVerticesBuffer(this._userInstancedBuffersStorage.vertexBuffers[e]);for(var n=0,o=this.instances;n<o.length;n++){o[n].instancedBuffers[e]=null}},Zt.prototype._processInstancedBuffers=function(e,t){var i=e.length;for(var r in this.instancedBuffers){for(var n=this._userInstancedBuffersStorage.sizes[r],o=this._userInstancedBuffersStorage.strides[r],s=(i+1)*o;n<s;)n*=2;this._userInstancedBuffersStorage.data[r].length!=n&&(this._userInstancedBuffersStorage.data[r]=new Float32Array(n),this._userInstancedBuffersStorage.sizes[r]=n,this._userInstancedBuffersStorage.vertexBuffers[r]&&(this._userInstancedBuffersStorage.vertexBuffers[r].dispose(),this._userInstancedBuffersStorage.vertexBuffers[r]=null));var a=this._userInstancedBuffersStorage.data[r],h=0;if(t)(l=this.instancedBuffers[r]).toArray?l.toArray(a,h):l.copyToArray(a,h),h+=o;for(var u=0;u<i;u++){var l;(l=e[u].instancedBuffers[r]).toArray?l.toArray(a,h):l.copyToArray(a,h),h+=o}this._userInstancedBuffersStorage.vertexBuffers[r]?this._userInstancedBuffersStorage.vertexBuffers[r].updateDirectly(a,0):(this._userInstancedBuffersStorage.vertexBuffers[r]=new ft(this.getEngine(),this._userInstancedBuffersStorage.data[r],r,!0,!1,o,!0),this.setVerticesBuffer(this._userInstancedBuffersStorage.vertexBuffers[r]))}},Zt.prototype._disposeInstanceSpecificData=function(){for(this._instanceDataStorage.instancesBuffer&&(this._instanceDataStorage.instancesBuffer.dispose(),this._instanceDataStorage.instancesBuffer=null);this.instances.length;)this.instances[0].dispose();for(var e in this.instancedBuffers)this._userInstancedBuffersStorage.vertexBuffers[e]&&this._userInstancedBuffersStorage.vertexBuffers[e].dispose();this.instancedBuffers={}};he.ShadersStore.colorPixelShader="#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#else\nuniform vec4 color;\n#endif\n#include<clipPlaneFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\n#ifdef VERTEXCOLOR\ngl_FragColor=vColor;\n#else\ngl_FragColor=color;\n#endif\n}";he.ShadersStore.colorVertexShader="\nattribute vec3 position;\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n#include<clipPlaneVertexDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\n#ifdef MULTIVIEW\nuniform mat4 viewProjectionR;\n#endif\n\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(position,1.0);\n#ifdef MULTIVIEW\nif (gl_ViewID_OVR == 0u) {\ngl_Position=viewProjection*worldPos;\n} else {\ngl_Position=viewProjectionR*worldPos;\n}\n#else\ngl_Position=viewProjection*worldPos;\n#endif\n#include<clipPlaneVertex>\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n}";var rr=function(e){function i(t,i,r,n,o,s,a){void 0===i&&(i=null),void 0===r&&(r=null),void 0===n&&(n=null);var h=e.call(this,t,i,r,n,o)||this;h.useVertexColor=s,h.useVertexAlpha=a,h.color=new T(1,1,1),h.alpha=1,n&&(h.color=n.color.clone(),h.alpha=n.alpha,h.useVertexColor=n.useVertexColor,h.useVertexAlpha=n.useVertexAlpha),h.intersectionThreshold=.1;var u={attributes:[ft.PositionKind,"world0","world1","world2","world3"],uniforms:["vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","world","viewProjection"],needAlphaBlending:!0,defines:[]};return!1===a&&(u.needAlphaBlending=!1),s?(u.defines.push("#define VERTEXCOLOR"),u.attributes.push(ft.ColorKind)):(u.uniforms.push("color"),h.color4=new E),h._colorShader=new Yi("colorShader",h.getScene(),"color",u),h}return t(i,e),i.prototype._addClipPlaneDefine=function(e){var t="#define "+e;-1===this._colorShader.options.defines.indexOf(t)&&this._colorShader.options.defines.push(t)},i.prototype._removeClipPlaneDefine=function(e){var t="#define "+e,i=this._colorShader.options.defines.indexOf(t);-1!==i&&this._colorShader.options.defines.splice(i,1)},i.prototype.isReady=function(){var t=this.getScene();return t.clipPlane?this._addClipPlaneDefine("CLIPPLANE"):this._removeClipPlaneDefine("CLIPPLANE"),t.clipPlane2?this._addClipPlaneDefine("CLIPPLANE2"):this._removeClipPlaneDefine("CLIPPLANE2"),t.clipPlane3?this._addClipPlaneDefine("CLIPPLANE3"):this._removeClipPlaneDefine("CLIPPLANE3"),t.clipPlane4?this._addClipPlaneDefine("CLIPPLANE4"):this._removeClipPlaneDefine("CLIPPLANE4"),t.clipPlane5?this._addClipPlaneDefine("CLIPPLANE5"):this._removeClipPlaneDefine("CLIPPLANE5"),t.clipPlane6?this._addClipPlaneDefine("CLIPPLANE6"):this._removeClipPlaneDefine("CLIPPLANE6"),!!this._colorShader.isReady(this)&&e.prototype.isReady.call(this)},i.prototype.getClassName=function(){return"LinesMesh"},Object.defineProperty(i.prototype,"material",{get:function(){return this._colorShader},set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"checkCollisions",{get:function(){return!1},enumerable:!1,configurable:!0}),i.prototype._bind=function(e,t,i){if(!this._geometry)return this;var r=this._colorShader.getEffect(),n=this.isUnIndexed?null:this._geometry.getIndexBuffer();if(this._geometry._bind(r,n),!this.useVertexColor){var o=this.color,s=o.r,a=o.g,h=o.b;this.color4.set(s,a,h,this.alpha),this._colorShader.setColor4("color",this.color4)}return Xi.BindClipPlane(r,this.getScene()),this},i.prototype._draw=function(e,t,i){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;var r=this.getScene().getEngine();return this._unIndexed?r.drawArraysType(Vt.LineListDrawMode,e.verticesStart,e.verticesCount,i):r.drawElementsType(Vt.LineListDrawMode,e.indexStart,e.indexCount,i),this},i.prototype.dispose=function(t){this._colorShader.dispose(!1,!1,!0),e.prototype.dispose.call(this,t)},i.prototype.clone=function(e,t,r){return void 0===t&&(t=null),new i(e,this.getScene(),t,this,r)},i.prototype.createInstance=function(e){return new nr(e,this)},i}(Zt),nr=function(e){function i(t,i){var r=e.call(this,t,i)||this;return r.intersectionThreshold=i.intersectionThreshold,r}return t(i,e),i.prototype.getClassName=function(){return"InstancedLinesMesh"},i}(ir);dt.CreateRibbon=function(e){var t=e.pathArray,i=e.closeArray||!1,r=e.closePath||!1,n=e.invertUV||!1,o=Math.floor(t[0].length/2),s=e.offset||o;s=s>o?o:Math.floor(s);var a,h,u,l,c=0===e.sideOrientation?0:e.sideOrientation||dt.DEFAULTSIDE,f=e.uvs,d=e.colors,p=[],_=[],g=[],m=[],v=[],y=[],b=[],T=[],E=[],x=[];if(t.length<2){var A=[],M=[];for(u=0;u<t[0].length-s;u++)A.push(t[0][u]),M.push(t[0][u+s]);t=[A,M]}var P,C,S,I,O,R=0,D=r?1:0;for(a=t[0].length,h=0;h<t.length;h++){for(b[h]=0,v[h]=[0],a=a<(C=(P=t[h]).length)?a:C,l=0;l<C;)p.push(P[l].x,P[l].y,P[l].z),l>0&&(S=P[l].subtract(P[l-1]).length()+b[h],v[h].push(S),b[h]=S),l++;r&&(l--,p.push(P[0].x,P[0].y,P[0].z),S=P[l].subtract(P[0]).length()+b[h],v[h].push(S),b[h]=S),E[h]=C+D,x[h]=R,R+=C+D}var w,L,F=null,N=null;for(u=0;u<a+D;u++){for(T[u]=0,y[u]=[0],h=0;h<t.length-1;h++)I=t[h],O=t[h+1],u===a?(F=I[0],N=O[0]):(F=I[u],N=O[u]),S=N.subtract(F).length()+T[u],y[u].push(S),T[u]=S;i&&N&&F&&(I=t[h],O=t[0],u===a&&(N=O[0]),S=N.subtract(F).length()+T[u],T[u]=S)}if(f)for(h=0;h<f.length;h++)m.push(f[h].x,f[h].y);else for(h=0;h<t.length;h++)for(u=0;u<a+D;u++)w=0!=b[h]?v[h][u]/b[h]:0,L=0!=T[u]?y[u][h]/T[u]:0,n?m.push(L,w):m.push(w,L);for(var B=0,k=E[h=0]-1,U=E[h+1]-1,V=k<U?k:U,W=x[1]-x[0],z=i?E.length:E.length-1;B<=V&&h<z;)_.push(B,B+W,B+1),_.push(B+W+1,B+1,B+W),(B+=1)===V&&(++h===E.length-1?(W=x[0]-x[h],k=E[h]-1,U=E[0]-1):(W=x[h+1]-x[h],k=E[h]-1,U=E[h+1]-1),B=x[h],V=k<U?k+B:U+B);if(dt.ComputeNormals(p,_,g),r){var G=0,H=0;for(h=0;h<t.length;h++)G=3*x[h],H=h+1<t.length?3*(x[h+1]-1):g.length-3,g[G]=.5*(g[G]+g[H]),g[G+1]=.5*(g[G+1]+g[H+1]),g[G+2]=.5*(g[G+2]+g[H+2]),g[H]=g[G],g[H+1]=g[G+1],g[H+2]=g[G+2]}dt._ComputeSides(c,p,_,g,m,e.frontUVs,e.backUVs);var X=null;if(d){X=new Float32Array(4*d.length);for(var j=0;j<d.length;j++)X[4*j]=d[j].r,X[4*j+1]=d[j].g,X[4*j+2]=d[j].b,X[4*j+3]=d[j].a}var K=new dt,Y=new Float32Array(p),q=new Float32Array(g),Z=new Float32Array(m);return K.indices=_,K.positions=Y,K.normals=q,K.uvs=Z,X&&K.set(X,ft.ColorKind),r&&(K._idx=x),K},Zt.CreateRibbon=function(e,t,i,r,n,o,s,a,h){return void 0===i&&(i=!1),void 0===s&&(s=!1),or.CreateRibbon(e,{pathArray:t,closeArray:i,closePath:r,offset:n,updatable:s,sideOrientation:a,instance:h},o)};var or=function(){function e(){}return e.CreateRibbon=function(e,t,i){void 0===i&&(i=null);var r=t.pathArray,n=t.closeArray,o=t.closePath,s=Zt._GetDefaultSideOrientation(t.sideOrientation),a=t.instance,h=t.updatable;if(a){var u=y.Vector3[0].setAll(Number.MAX_VALUE),l=y.Vector3[1].setAll(-Number.MAX_VALUE),c=a.getVerticesData(ft.PositionKind);if(function(e){for(var t=r[0].length,i=a,n=0,o=i._originalBuilderSideOrientation===Zt.DOUBLESIDE?2:1,s=1;s<=o;++s)for(var h=0;h<r.length;++h){var c=r[h],f=c.length;t=t<f?t:f;for(var d=0;d<t;++d){var p=c[d];e[n]=p.x,e[n+1]=p.y,e[n+2]=p.z,u.minimizeInPlaceFromFloats(p.x,p.y,p.z),l.maximizeInPlaceFromFloats(p.x,p.y,p.z),n+=3}if(i._creationDataStorage&&i._creationDataStorage.closePath){p=c[0];e[n]=p.x,e[n+1]=p.y,e[n+2]=p.z,n+=3}}}(c),a._boundingInfo?a._boundingInfo.reConstruct(u,l,a._worldMatrix):a._boundingInfo=new Tt(u,l,a._worldMatrix),a.updateVerticesData(ft.PositionKind,c,!1,!1),t.colors){for(var f=a.getVerticesData(ft.ColorKind),d=0,p=0;d<t.colors.length;d++,p+=4){var _=t.colors[d];f[p]=_.r,f[p+1]=_.g,f[p+2]=_.b,f[p+3]=_.a}a.updateVerticesData(ft.ColorKind,f,!1,!1)}if(t.uvs){for(var g=a.getVerticesData(ft.UVKind),m=0;m<t.uvs.length;m++)g[2*m]=t.uvs[m].x,g[2*m+1]=t.uvs[m].y;a.updateVerticesData(ft.UVKind,g,!1,!1)}if(!a.areNormalsFrozen||a.isFacetDataEnabled){var v=a.getIndices(),b=a.getVerticesData(ft.NormalKind),T=a.isFacetDataEnabled?a.getFacetDataParameters():null;if(dt.ComputeNormals(c,v,b,T),a._creationDataStorage&&a._creationDataStorage.closePath)for(var E=0,x=0,A=0;A<r.length;A++)E=3*a._creationDataStorage.idx[A],x=A+1<r.length?3*(a._creationDataStorage.idx[A+1]-1):b.length-3,b[E]=.5*(b[E]+b[x]),b[E+1]=.5*(b[E+1]+b[x+1]),b[E+2]=.5*(b[E+2]+b[x+2]),b[x]=b[E],b[x+1]=b[E+1],b[x+2]=b[E+2];a.areNormalsFrozen||a.updateVerticesData(ft.NormalKind,b,!1,!1)}return a}var M=new Zt(e,i);M._originalBuilderSideOrientation=s,M._creationDataStorage=new Xt;var P=dt.CreateRibbon(t);return o&&(M._creationDataStorage.idx=P._idx),M._creationDataStorage.closePath=o,M._creationDataStorage.closeArray=n,P.applyToMesh(M,h),M},e}();dt.CreateDisc=function(e){var t=new Array,i=new Array,r=new Array,n=new Array,o=e.radius||.5,s=e.tessellation||64,a=e.arc&&(e.arc<=0||e.arc>1)?1:e.arc||1,h=0===e.sideOrientation?0:e.sideOrientation||dt.DEFAULTSIDE;t.push(0,0,0),n.push(.5,.5);for(var u=2*Math.PI*a,l=1===a?u/s:u/(s-1),c=0,f=0;f<s;f++){var d=Math.cos(c),p=Math.sin(c),_=(d+1)/2,g=(1-p)/2;t.push(o*d,o*p,0),n.push(_,g),c+=l}1===a&&(t.push(t[3],t[4],t[5]),n.push(n[2],n[3]));for(var m=t.length/3,v=1;v<m-1;v++)i.push(v+1,0,v);dt.ComputeNormals(t,i,r),dt._ComputeSides(h,t,i,r,n,e.frontUVs,e.backUVs);var y=new dt;return y.indices=i,y.positions=t,y.normals=r,y.uvs=n,y},Zt.CreateDisc=function(e,t,i,r,n,o){void 0===r&&(r=null);var s={radius:t,tessellation:i,sideOrientation:o,updatable:n};return sr.CreateDisc(e,s,r)};var sr=function(){function e(){}return e.CreateDisc=function(e,t,i){void 0===i&&(i=null);var r=new Zt(e,i);return t.sideOrientation=Zt._GetDefaultSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,dt.CreateDisc(t).applyToMesh(r,t.updatable),r},e}();dt.CreateBox=function(e){var t,i=[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],r=[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],n=[],o=e.width||e.size||1,s=e.height||e.size||1,a=e.depth||e.size||1,h=e.wrap||!1,u=void 0===e.topBaseAt?1:e.topBaseAt,l=void 0===e.bottomBaseAt?0:e.bottomBaseAt,c=[2,0,3,1][u=(u+4)%4],f=[2,0,1,3][l=(l+4)%4],d=[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(h){i=[2,3,0,2,0,1,4,5,6,4,6,7,9,10,11,9,11,8,12,14,15,12,13,14],d=[-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 p=[[1,1,1],[-1,1,1],[-1,1,-1],[1,1,-1]],g=[[-1,-1,1],[1,-1,1],[1,-1,-1],[-1,-1,-1]],m=[17,18,19,16],v=[22,23,20,21];c>0;)p.unshift(p.pop()),m.unshift(m.pop()),c--;for(;f>0;)g.unshift(g.pop()),v.unshift(v.pop()),f--;p=p.flat(),g=g.flat(),d=d.concat(p).concat(g),i.push(m[0],m[2],m[3],m[0],m[1],m[2]),i.push(v[0],v[2],v[3],v[0],v[1],v[2])}var y=[o/2,s/2,a/2];t=d.reduce((function(e,t,i){return e.concat(t*y[i%3])}),[]);for(var b=0===e.sideOrientation?0:e.sideOrientation||dt.DEFAULTSIDE,T=e.faceUV||new Array(6),x=e.faceColors,A=[],M=0;M<6;M++)void 0===T[M]&&(T[M]=new _(0,0,1,1)),x&&void 0===x[M]&&(x[M]=new E(1,1,1,1));for(var P=0;P<6;P++)if(n.push(T[P].z,T[P].w),n.push(T[P].x,T[P].w),n.push(T[P].x,T[P].y),n.push(T[P].z,T[P].y),x)for(var C=0;C<4;C++)A.push(x[P].r,x[P].g,x[P].b,x[P].a);dt._ComputeSides(b,t,i,r,n,e.frontUVs,e.backUVs);var S=new dt;if(S.indices=i,S.positions=t,S.normals=r,S.uvs=n,x){var I=b===dt.DOUBLESIDE?A.concat(A):A;S.colors=I}return S},Zt.CreateBox=function(e,t,i,r,n){void 0===i&&(i=null);var o={size:t,sideOrientation:n,updatable:r};return ar.CreateBox(e,o,i)};var ar=function(){function e(){}return e.CreateBox=function(e,t,i){void 0===i&&(i=null);var r=new Zt(e,i);return t.sideOrientation=Zt._GetDefaultSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,dt.CreateBox(t).applyToMesh(r,t.updatable),r},e}();dt.CreateTiledBox=function(e){for(var t=e.faceUV||new Array(6),i=e.faceColors,r=e.pattern||Zt.NO_FLIP,n=e.width||e.size||1,o=e.height||e.size||1,s=e.depth||e.size||1,a=e.tileWidth||e.tileSize||1,h=e.tileHeight||e.tileSize||1,u=e.alignHorizontal||0,l=e.alignVertical||0,c=0===e.sideOrientation?0:e.sideOrientation||dt.DEFAULTSIDE,f=0;f<6;f++)void 0===t[f]&&(t[f]=new _(0,0,1,1)),i&&void 0===i[f]&&(i[f]=new E(1,1,1,1));var d=n/2,g=o/2,v=s/2,y=[];for(f=0;f<2;f++)y[f]=dt.CreateTiledPlane({pattern:r,tileWidth:a,tileHeight:h,width:n,height:o,alignVertical:l,alignHorizontal:u,sideOrientation:c});for(f=2;f<4;f++)y[f]=dt.CreateTiledPlane({pattern:r,tileWidth:a,tileHeight:h,width:s,height:o,alignVertical:l,alignHorizontal:u,sideOrientation:c});var b=l;l===Zt.BOTTOM?b=Zt.TOP:l===Zt.TOP&&(b=Zt.BOTTOM);for(f=4;f<6;f++)y[f]=dt.CreateTiledPlane({pattern:r,tileWidth:a,tileHeight:h,width:n,height:s,alignVertical:b,alignHorizontal:u,sideOrientation:c});var T=[],x=[],A=[],M=[],P=[],C=[],S=[],I=[],O=0,R=0,D=0;for(f=0;f<6;f++){O=y[f].positions.length;C[f]=[],S[f]=[];for(var w=0;w<O/3;w++)C[f].push(new p(y[f].positions[3*w],y[f].positions[3*w+1],y[f].positions[3*w+2])),S[f].push(new p(y[f].normals[3*w],y[f].normals[3*w+1],y[f].normals[3*w+2]));R=y[f].uvs.length,I[f]=[];for(var L=0;L<R;L+=2)I[f][L]=t[f].x+(t[f].z-t[f].x)*y[f].uvs[L],I[f][L+1]=t[f].y+(t[f].w-t[f].y)*y[f].uvs[L+1];if(A=A.concat(I[f]),M=M.concat(y[f].indices.map((function(e){return e+D}))),D+=C[f].length,i)for(var F=0;F<4;F++)P.push(i[f].r,i[f].g,i[f].b,i[f].a)}var N=new p(0,0,v),B=m.RotationY(Math.PI);T=C[0].map((function(e){return p.TransformNormal(e,B).add(N)})).map((function(e){return[e.x,e.y,e.z]})).reduce((function(e,t){return e.concat(t)}),[]),x=S[0].map((function(e){return p.TransformNormal(e,B)})).map((function(e){return[e.x,e.y,e.z]})).reduce((function(e,t){return e.concat(t)}),[]),T=T.concat(C[1].map((function(e){return e.subtract(N)})).map((function(e){return[e.x,e.y,e.z]})).reduce((function(e,t){return e.concat(t)}),[])),x=x.concat(S[1].map((function(e){return[e.x,e.y,e.z]})).reduce((function(e,t){return e.concat(t)}),[]));var k=new p(d,0,0),U=m.RotationY(-Math.PI/2);T=T.concat(C[2].map((function(e){return p.TransformNormal(e,U).add(k)})).map((function(e){return[e.x,e.y,e.z]})).reduce((function(e,t){return e.concat(t)}),[])),x=x.concat(S[2].map((function(e){return p.TransformNormal(e,U)})).map((function(e){return[e.x,e.y,e.z]})).reduce((function(e,t){return e.concat(t)}),[]));var V=m.RotationY(Math.PI/2);T=T.concat(C[3].map((function(e){return p.TransformNormal(e,V).subtract(k)})).map((function(e){return[e.x,e.y,e.z]})).reduce((function(e,t){return e.concat(t)}),[])),x=x.concat(S[3].map((function(e){return p.TransformNormal(e,V)})).map((function(e){return[e.x,e.y,e.z]})).reduce((function(e,t){return e.concat(t)}),[]));var W=new p(0,g,0),z=m.RotationX(Math.PI/2);T=T.concat(C[4].map((function(e){return p.TransformNormal(e,z).add(W)})).map((function(e){return[e.x,e.y,e.z]})).reduce((function(e,t){return e.concat(t)}),[])),x=x.concat(S[4].map((function(e){return p.TransformNormal(e,z)})).map((function(e){return[e.x,e.y,e.z]})).reduce((function(e,t){return e.concat(t)}),[]));var G=m.RotationX(-Math.PI/2);T=T.concat(C[5].map((function(e){return p.TransformNormal(e,G).subtract(W)})).map((function(e){return[e.x,e.y,e.z]})).reduce((function(e,t){return e.concat(t)}),[])),x=x.concat(S[5].map((function(e){return p.TransformNormal(e,G)})).map((function(e){return[e.x,e.y,e.z]})).reduce((function(e,t){return e.concat(t)}),[])),dt._ComputeSides(c,T,M,x,A);var H=new dt;if(H.indices=M,H.positions=T,H.normals=x,H.uvs=A,i){var X=c===dt.DOUBLESIDE?P.concat(P):P;H.colors=X}return H};var hr=function(){function e(){}return e.CreateTiledBox=function(e,t,i){void 0===i&&(i=null);var r=new Zt(e,i);return t.sideOrientation=Zt._GetDefaultSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,dt.CreateTiledBox(t).applyToMesh(r,t.updatable),r},e}();dt.CreateSphere=function(e){for(var t=e.segments||32,i=e.diameterX||e.diameter||1,r=e.diameterY||e.diameter||1,n=e.diameterZ||e.diameter||1,o=e.arc&&(e.arc<=0||e.arc>1)?1:e.arc||1,s=e.slice&&e.slice<=0?1:e.slice||1,a=0===e.sideOrientation?0:e.sideOrientation||dt.DEFAULTSIDE,h=!!e.dedupTopBottomIndices,u=new p(i/2,r/2,n/2),l=2+t,c=2*l,f=[],d=[],_=[],g=[],v=0;v<=l;v++){for(var y=v/l,b=y*Math.PI*s,T=0;T<=c;T++){var E=T/c,x=E*Math.PI*2*o,A=m.RotationZ(-b),M=m.RotationY(x),P=p.TransformCoordinates(p.Up(),A),C=p.TransformCoordinates(P,M),S=C.multiply(u),I=C.divide(u).normalize();d.push(S.x,S.y,S.z),_.push(I.x,I.y,I.z),g.push(E,y)}if(v>0)for(var O=d.length/3,R=O-2*(c+1);R+c+2<O;R++)h?(v>1&&(f.push(R),f.push(R+1),f.push(R+c+1)),(v<l||s<1)&&(f.push(R+c+1),f.push(R+1),f.push(R+c+2))):(f.push(R),f.push(R+1),f.push(R+c+1),f.push(R+c+1),f.push(R+1),f.push(R+c+2))}dt._ComputeSides(a,d,f,_,g,e.frontUVs,e.backUVs);var D=new dt;return D.indices=f,D.positions=d,D.normals=_,D.uvs=g,D},Zt.CreateSphere=function(e,t,i,r,n,o){var s={segments:t,diameterX:i,diameterY:i,diameterZ:i,sideOrientation:o,updatable:n};return ur.CreateSphere(e,s,r)};var ur=function(){function e(){}return e.CreateSphere=function(e,t,i){void 0===i&&(i=null);var r=new Zt(e,i);return t.sideOrientation=Zt._GetDefaultSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,dt.CreateSphere(t).applyToMesh(r,t.updatable),r},e}();dt.CreateCylinder=function(e){var t=e.height||2,i=0===e.diameterTop?0:e.diameterTop||e.diameter||1,r=0===e.diameterBottom?0:e.diameterBottom||e.diameter||1;i=i||1e-5,r=r||1e-5;var n,o=e.tessellation||24,s=e.subdivisions||1,a=!!e.hasRings,h=!!e.enclose,u=0===e.cap?0:e.cap||Zt.CAP_ALL,l=e.arc&&(e.arc<=0||e.arc>1)?1:e.arc||1,c=0===e.sideOrientation?0:e.sideOrientation||dt.DEFAULTSIDE,f=e.faceUV||new Array(3),g=e.faceColors,m=2+(1+(1!==l&&h?2:0))*(a?s:1);for(n=0;n<m;n++)g&&void 0===g[n]&&(g[n]=new E(1,1,1,1));for(n=0;n<m;n++)f&&void 0===f[n]&&(f[n]=new _(0,0,1,1));var v,y,b,T,x,A,M=new Array,P=new Array,C=new Array,S=new Array,I=new Array,O=2*Math.PI*l/o,R=(r-i)/2/t,D=p.Zero(),w=p.Zero(),L=p.Zero(),F=p.Zero(),N=p.Zero(),B=Dt.Y,k=1,U=1,V=0,W=0;for(T=0;T<=s;T++)for(b=((y=T/s)*(i-r)+r)/2,k=a&&0!==T&&T!==s?2:1,A=0;A<k;A++){for(a&&(U+=A),h&&(U+=2*A),x=0;x<=o;x++)v=x*O,D.x=Math.cos(-v)*b,D.y=-t/2+y*t,D.z=Math.sin(-v)*b,0===i&&T===s?(w.x=C[C.length-3*(o+1)],w.y=C[C.length-3*(o+1)+1],w.z=C[C.length-3*(o+1)+2]):(w.x=D.x,w.z=D.z,w.y=Math.sqrt(w.x*w.x+w.z*w.z)*R,w.normalize()),0===x&&(L.copyFrom(D),F.copyFrom(w)),P.push(D.x,D.y,D.z),C.push(w.x,w.y,w.z),W=a?V!==U?f[U].y:f[U].w:f[U].y+(f[U].w-f[U].y)*y,S.push(f[U].x+(f[U].z-f[U].x)*x/o,W),g&&I.push(g[U].r,g[U].g,g[U].b,g[U].a);1!==l&&h&&(P.push(D.x,D.y,D.z),P.push(0,D.y,0),P.push(0,D.y,0),P.push(L.x,L.y,L.z),p.CrossToRef(B,w,N),N.normalize(),C.push(N.x,N.y,N.z,N.x,N.y,N.z),p.CrossToRef(F,B,N),N.normalize(),C.push(N.x,N.y,N.z,N.x,N.y,N.z),W=a?V!==U?f[U+1].y:f[U+1].w:f[U+1].y+(f[U+1].w-f[U+1].y)*y,S.push(f[U+1].x,W),S.push(f[U+1].z,W),W=a?V!==U?f[U+2].y:f[U+2].w:f[U+2].y+(f[U+2].w-f[U+2].y)*y,S.push(f[U+2].x,W),S.push(f[U+2].z,W),g&&(I.push(g[U+1].r,g[U+1].g,g[U+1].b,g[U+1].a),I.push(g[U+1].r,g[U+1].g,g[U+1].b,g[U+1].a),I.push(g[U+2].r,g[U+2].g,g[U+2].b,g[U+2].a),I.push(g[U+2].r,g[U+2].g,g[U+2].b,g[U+2].a))),V!==U&&(V=U)}var z=1!==l&&h?o+4:o;for(T=0,U=0;U<s;U++){var G=0,H=0,X=0,j=0;for(x=0;x<o;x++)G=T*(z+1)+x,H=(T+1)*(z+1)+x,X=T*(z+1)+(x+1),j=(T+1)*(z+1)+(x+1),M.push(G,H,X),M.push(j,X,H);1!==l&&h&&(M.push(G+2,H+2,X+2),M.push(j+2,X+2,H+2),M.push(G+4,H+4,X+4),M.push(j+4,X+4,H+4)),T=a?T+2:T+1}var K=function(e){var n=e?i/2:r/2;if(0!==n){var s,a,h,u=e?f[m-1]:f[0],c=null;g&&(c=e?g[m-1]:g[0]);var _=P.length/3,v=e?t/2:-t/2,y=new p(0,v,0);P.push(y.x,y.y,y.z),C.push(0,e?1:-1,0),S.push(u.x+.5*(u.z-u.x),u.y+.5*(u.w-u.y)),c&&I.push(c.r,c.g,c.b,c.a);var b=new d(.5,.5);for(h=0;h<=o;h++){s=2*Math.PI*h*l/o;var T=Math.cos(-s),E=Math.sin(-s);a=new p(T*n,v,E*n);var x=new d(T*b.x+.5,E*b.y+.5);P.push(a.x,a.y,a.z),C.push(0,e?1:-1,0),S.push(u.x+(u.z-u.x)*x.x,u.y+(u.w-u.y)*x.y),c&&I.push(c.r,c.g,c.b,c.a)}for(h=0;h<o;h++)e?(M.push(_),M.push(_+(h+2)),M.push(_+(h+1))):(M.push(_),M.push(_+(h+1)),M.push(_+(h+2)))}};u!==Zt.CAP_START&&u!==Zt.CAP_ALL||K(!1),u!==Zt.CAP_END&&u!==Zt.CAP_ALL||K(!0),dt._ComputeSides(c,P,M,C,S,e.frontUVs,e.backUVs);var Y=new dt;return Y.indices=M,Y.positions=P,Y.normals=C,Y.uvs=S,g&&(Y.colors=I),Y},Zt.CreateCylinder=function(e,t,i,r,n,o,s,a,h){void 0!==s&&s instanceof zi||(void 0!==s&&(h=a||Zt.DEFAULTSIDE,a=s),s=o,o=1);var u={height:t,diameterTop:i,diameterBottom:r,tessellation:n,subdivisions:o,sideOrientation:h,updatable:a};return lr.CreateCylinder(e,u,s)};var lr=function(){function e(){}return e.CreateCylinder=function(e,t,i){var r=new Zt(e,i);return t.sideOrientation=Zt._GetDefaultSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,dt.CreateCylinder(t).applyToMesh(r,t.updatable),r},e}();dt.CreateTorus=function(e){for(var t=[],i=[],r=[],n=[],o=e.diameter||1,s=e.thickness||.5,a=e.tessellation||16,h=0===e.sideOrientation?0:e.sideOrientation||dt.DEFAULTSIDE,u=a+1,l=0;l<=a;l++)for(var c=l/a,f=l*Math.PI*2/a-Math.PI/2,_=m.Translation(o/2,0,0).multiply(m.RotationY(f)),g=0;g<=a;g++){var v=1-g/a,y=g*Math.PI*2/a+Math.PI,b=Math.cos(y),T=Math.sin(y),E=new p(b,T,0),x=E.scale(s/2),A=new d(c,v);x=p.TransformCoordinates(x,_),E=p.TransformNormal(E,_),i.push(x.x,x.y,x.z),r.push(E.x,E.y,E.z),n.push(A.x,A.y);var M=(l+1)%u,P=(g+1)%u;t.push(l*u+g),t.push(l*u+P),t.push(M*u+g),t.push(l*u+P),t.push(M*u+P),t.push(M*u+g)}dt._ComputeSides(h,i,t,r,n,e.frontUVs,e.backUVs);var C=new dt;return C.indices=t,C.positions=i,C.normals=r,C.uvs=n,C},Zt.CreateTorus=function(e,t,i,r,n,o,s){var a={diameter:t,thickness:i,tessellation:r,sideOrientation:s,updatable:o};return cr.CreateTorus(e,a,n)};var cr=function(){function e(){}return e.CreateTorus=function(e,t,i){var r=new Zt(e,i);return t.sideOrientation=Zt._GetDefaultSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,dt.CreateTorus(t).applyToMesh(r,t.updatable),r},e}();dt.CreateTorusKnot=function(e){var t,i,r=new Array,n=new Array,o=new Array,s=new Array,a=e.radius||2,h=e.tube||.5,u=e.radialSegments||32,l=e.tubularSegments||32,c=e.p||2,f=e.q||3,d=0===e.sideOrientation?0:e.sideOrientation||dt.DEFAULTSIDE,_=function(e){var t=Math.cos(e),i=Math.sin(e),r=f/c*e,n=Math.cos(r),o=a*(2+n)*.5*t,s=a*(2+n)*i*.5,h=a*Math.sin(r)*.5;return new p(o,s,h)};for(t=0;t<=u;t++){var g=t%u/u*2*c*Math.PI,m=_(g),v=_(g+.01),y=v.subtract(m),b=v.add(m),T=p.Cross(y,b);for(b=p.Cross(T,y),T.normalize(),b.normalize(),i=0;i<l;i++){var E=i%l/l*2*Math.PI,x=-h*Math.cos(E),A=h*Math.sin(E);n.push(m.x+x*b.x+A*T.x),n.push(m.y+x*b.y+A*T.y),n.push(m.z+x*b.z+A*T.z),s.push(t/u),s.push(i/l)}}for(t=0;t<u;t++)for(i=0;i<l;i++){var M=(i+1)%l,P=t*l+i,C=(t+1)*l+i,S=(t+1)*l+M,I=t*l+M;r.push(I),r.push(C),r.push(P),r.push(I),r.push(S),r.push(C)}dt.ComputeNormals(n,r,o),dt._ComputeSides(d,n,r,o,s,e.frontUVs,e.backUVs);var O=new dt;return O.indices=r,O.positions=n,O.normals=o,O.uvs=s,O},Zt.CreateTorusKnot=function(e,t,i,r,n,o,s,a,h,u){var l={radius:t,tube:i,radialSegments:r,tubularSegments:n,p:o,q:s,sideOrientation:u,updatable:h};return fr.CreateTorusKnot(e,l,a)};var fr=function(){function e(){}return e.CreateTorusKnot=function(e,t,i){var r=new Zt(e,i);return t.sideOrientation=Zt._GetDefaultSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,dt.CreateTorusKnot(t).applyToMesh(r,t.updatable),r},e}();dt.CreateLineSystem=function(e){for(var t=[],i=[],r=e.lines,n=e.colors,o=[],s=0,a=0;a<r.length;a++)for(var h=r[a],u=0;u<h.length;u++){if(i.push(h[u].x,h[u].y,h[u].z),n){var l=n[a];o.push(l[u].r,l[u].g,l[u].b,l[u].a)}u>0&&(t.push(s-1),t.push(s)),s++}var c=new dt;return c.indices=t,c.positions=i,n&&(c.colors=o),c},dt.CreateDashedLines=function(e){var t,i,r=e.dashSize||3,n=e.gapSize||1,o=e.dashNb||200,s=e.points,a=new Array,h=new Array,u=p.Zero(),l=0,c=0,f=0,d=0,_=0;for(_=0;_<s.length-1;_++)s[_+1].subtractToRef(s[_],u),l+=u.length();for(i=r*(t=l/o)/(r+n),_=0;_<s.length-1;_++){s[_+1].subtractToRef(s[_],u),c=Math.floor(u.length()/t),u.normalize();for(var g=0;g<c;g++)f=t*g,a.push(s[_].x+f*u.x,s[_].y+f*u.y,s[_].z+f*u.z),a.push(s[_].x+(f+i)*u.x,s[_].y+(f+i)*u.y,s[_].z+(f+i)*u.z),h.push(d,d+1),d+=2}var m=new dt;return m.positions=a,m.indices=h,m},Zt.CreateLines=function(e,t,i,r,n){void 0===i&&(i=null),void 0===r&&(r=!1),void 0===n&&(n=null);var o={points:t,updatable:r,instance:n};return dr.CreateLines(e,o,i)},Zt.CreateDashedLines=function(e,t,i,r,n,o,s,a){void 0===o&&(o=null);var h={points:t,dashSize:i,gapSize:r,dashNb:n,updatable:s,instance:a};return dr.CreateDashedLines(e,h,o)};var dr=function(){function e(){}return e.CreateLineSystem=function(e,t,i){var r=t.instance,n=t.lines,o=t.colors;if(r){var s,a,h=r.getVerticesData(ft.PositionKind);o&&(s=r.getVerticesData(ft.ColorKind));for(var u=0,l=0,c=0;c<n.length;c++)for(var f=n[c],d=0;d<f.length;d++)h[u]=f[d].x,h[u+1]=f[d].y,h[u+2]=f[d].z,o&&s&&(a=o[c],s[l]=a[d].r,s[l+1]=a[d].g,s[l+2]=a[d].b,s[l+3]=a[d].a,l+=4),u+=3;return r.updateVerticesData(ft.PositionKind,h,!1,!1),o&&s&&r.updateVerticesData(ft.ColorKind,s,!1,!1),r}var p=new rr(e,i,null,void 0,void 0,!!o,t.useVertexAlpha);return dt.CreateLineSystem(t).applyToMesh(p,t.updatable),p},e.CreateLines=function(t,i,r){void 0===r&&(r=null);var n=i.colors?[i.colors]:null;return e.CreateLineSystem(t,{lines:[i.points],updatable:i.updatable,instance:i.instance,colors:n,useVertexAlpha:i.useVertexAlpha},r)},e.CreateDashedLines=function(e,t,i){void 0===i&&(i=null);var r=t.points,n=t.instance,o=t.gapSize||1,s=t.dashSize||3;if(n){return n.updateMeshPositions((function(e){var t,i,o=p.Zero(),s=e.length/6,a=0,h=0,u=0,l=0,c=0,f=0;for(c=0;c<r.length-1;c++)r[c+1].subtractToRef(r[c],o),a+=o.length();t=a/s;var d=n._creationDataStorage.dashSize;for(i=d*t/(d+n._creationDataStorage.gapSize),c=0;c<r.length-1;c++)for(r[c+1].subtractToRef(r[c],o),h=Math.floor(o.length()/t),o.normalize(),f=0;f<h&&l<e.length;)u=t*f,e[l]=r[c].x+u*o.x,e[l+1]=r[c].y+u*o.y,e[l+2]=r[c].z+u*o.z,e[l+3]=r[c].x+(u+i)*o.x,e[l+4]=r[c].y+(u+i)*o.y,e[l+5]=r[c].z+(u+i)*o.z,l+=6,f++;for(;l<e.length;)e[l]=r[c].x,e[l+1]=r[c].y,e[l+2]=r[c].z,l+=3}),!1),n}var a=new rr(e,i,null,void 0,void 0,void 0,t.useVertexAlpha);return dt.CreateDashedLines(t).applyToMesh(a,t.updatable),a._creationDataStorage=new Xt,a._creationDataStorage.dashSize=s,a._creationDataStorage.gapSize=o,a},e}(),pr=function(e){function i(t,i){var r=e.call(this,t.x,t.y)||this;return r.index=i,r}return t(i,e),i}(d),_r=function(){function e(){this.elements=new Array}return e.prototype.add=function(e){var t=this,i=new Array;return e.forEach((function(e){var r=new pr(e,t.elements.length);i.push(r),t.elements.push(r)})),i},e.prototype.computeBounds=function(){var e=new d(this.elements[0].x,this.elements[0].y),t=new d(this.elements[0].x,this.elements[0].y);return this.elements.forEach((function(i){i.x<e.x?e.x=i.x:i.x>t.x&&(t.x=i.x),i.y<e.y?e.y=i.y:i.y>t.y&&(t.y=i.y)})),{min:e,max:t,width:t.x-e.x,height:t.y-e.y}},e}(),gr=function(){function e(e,t,i,r){var n;void 0===r&&(r=earcut),this._points=new _r,this._outlinepoints=new _r,this._holes=new Array,this._epoints=new Array,this._eholes=new Array,this.bjsEarcut=r,this._name=e,this._scene=i||Ot.LastCreatedScene,n=t instanceof si?t.getPoints():t,this._addToepoint(n),this._points.add(n),this._outlinepoints.add(n),void 0===this.bjsEarcut&&q.Warn("Earcut was not found, the polygon will not be built.")}return e.prototype._addToepoint=function(e){for(var t=0,i=e;t<i.length;t++){var r=i[t];this._epoints.push(r.x,r.y)}},e.prototype.addHole=function(e){this._points.add(e);var t=new _r;return t.add(e),this._holes.push(t),this._eholes.push(this._epoints.length/2),this._addToepoint(e),this},e.prototype.build=function(e,t){void 0===e&&(e=!1),void 0===t&&(t=0);var i=new Zt(this._name,this._scene),r=this.buildVertexData(t);return i.setVerticesData(ft.PositionKind,r.positions,e),i.setVerticesData(ft.NormalKind,r.normals,e),i.setVerticesData(ft.UVKind,r.uvs,e),i.setIndices(r.indices),i},e.prototype.buildVertexData=function(e){var t=this;void 0===e&&(e=0);var i=new dt,r=new Array,n=new Array,o=new Array,s=this._points.computeBounds();this._points.elements.forEach((function(e){r.push(0,1,0),n.push(e.x,0,e.y),o.push((e.x-s.min.x)/s.width,(e.y-s.min.y)/s.height)}));for(var a=new Array,h=this.bjsEarcut(this._epoints,this._eholes,2),u=0;u<h.length;u++)a.push(h[u]);if(e>0){var l=n.length/3;this._points.elements.forEach((function(t){r.push(0,-1,0),n.push(t.x,-e,t.y),o.push(1-(t.x-s.min.x)/s.width,1-(t.y-s.min.y)/s.height)}));var c=a.length;for(u=0;u<c;u+=3){var f=a[u+0],d=a[u+1],p=a[u+2];a.push(p+l),a.push(d+l),a.push(f+l)}this.addSide(n,r,o,a,s,this._outlinepoints,e,!1),this._holes.forEach((function(i){t.addSide(n,r,o,a,s,i,e,!0)}))}return i.indices=a,i.positions=n,i.normals=r,i.uvs=o,i},e.prototype.addSide=function(e,t,i,r,n,o,s,a){for(var h=e.length/3,u=0,l=0;l<o.elements.length;l++){var c,f=o.elements[l];c=l+1>o.elements.length-1?o.elements[0]:o.elements[l+1],e.push(f.x,0,f.y),e.push(f.x,-s,f.y),e.push(c.x,0,c.y),e.push(c.x,-s,c.y);var d=new p(f.x,0,f.y),_=new p(c.x,0,c.y).subtract(d),g=new p(0,1,0),m=p.Cross(_,g);m=m.normalize(),i.push(u/n.width,0),i.push(u/n.width,1),u+=_.length(),i.push(u/n.width,0),i.push(u/n.width,1),a?(t.push(m.x,m.y,m.z),t.push(m.x,m.y,m.z),t.push(m.x,m.y,m.z),t.push(m.x,m.y,m.z),r.push(h),r.push(h+2),r.push(h+1),r.push(h+1),r.push(h+2),r.push(h+3)):(t.push(-m.x,-m.y,-m.z),t.push(-m.x,-m.y,-m.z),t.push(-m.x,-m.y,-m.z),t.push(-m.x,-m.y,-m.z),r.push(h),r.push(h+1),r.push(h+2),r.push(h+1),r.push(h+3),r.push(h+2)),h+=4}},e}();dt.CreatePolygon=function(e,t,i,r,n,o,s){for(var a=i||new Array(3),h=r,u=[],l=s||!1,c=0;c<3;c++)void 0===a[c]&&(a[c]=new _(0,0,1,1)),h&&void 0===h[c]&&(h[c]=new E(1,1,1,1));var f=e.getVerticesData(ft.PositionKind),d=e.getVerticesData(ft.NormalKind),p=e.getVerticesData(ft.UVKind),g=e.getIndices(),m=f.length/9,v=0,y=0,b=0,T=0,x=[0];if(l)for(var A=m;A<f.length/3;A+=4)y=f[3*(A+2)]-f[3*A],b=f[3*(A+2)+2]-f[3*A+2],T+=Math.sqrt(y*y+b*b),x.push(T);A=0;for(var M=0,P=0;P<d.length;P+=3)Math.abs(d[P+1])<.001&&(M=1),Math.abs(d[P+1]-1)<.001&&(M=0),Math.abs(d[P+1]+1)<.001&&(M=2),A=P/3,1===M?(v=A-m,p[2*A]=v%4<1.5?l?a[M].x+(a[M].z-a[M].x)*x[Math.floor(v/4)]/T:a[M].x:l?a[M].x+(a[M].z-a[M].x)*x[Math.floor(v/4)+1]/T:a[M].z,p[2*A+1]=v%2==0?a[M].w:a[M].y):(p[2*A]=(1-p[2*A])*a[M].x+p[2*A]*a[M].z,p[2*A+1]=(1-p[2*A+1])*a[M].y+p[2*A+1]*a[M].w),h&&u.push(h[M].r,h[M].g,h[M].b,h[M].a);dt._ComputeSides(t,f,g,d,p,n,o);var C=new dt;if(C.indices=g,C.positions=f,C.normals=d,C.uvs=p,h){var S=t===dt.DOUBLESIDE?u.concat(u):u;C.colors=S}return C},Zt.CreatePolygon=function(e,t,i,r,n,o,s){void 0===s&&(s=earcut);var a={shape:t,holes:r,updatable:n,sideOrientation:o};return mr.CreatePolygon(e,a,i,s)},Zt.ExtrudePolygon=function(e,t,i,r,n,o,s,a){void 0===a&&(a=earcut);var h={shape:t,holes:n,depth:i,updatable:o,sideOrientation:s};return mr.ExtrudePolygon(e,h,r,a)};var mr=function(){function e(){}return e.CreatePolygon=function(e,t,i,r){void 0===i&&(i=null),void 0===r&&(r=earcut),t.sideOrientation=Zt._GetDefaultSideOrientation(t.sideOrientation);for(var n=t.shape,o=t.holes||[],s=t.depth||0,a=[],h=[],u=0;u<n.length;u++)a[u]=new d(n[u].x,n[u].z);a[0].equalsWithEpsilon(a[a.length-1],1e-8)&&a.pop();for(var l=new gr(e,a,i||V.LastCreatedScene,r),c=0;c<o.length;c++){h=[];for(var f=0;f<o[c].length;f++)h.push(new d(o[c][f].x,o[c][f].z));l.addHole(h)}var p=l.build(t.updatable,s);return p._originalBuilderSideOrientation=t.sideOrientation,dt.CreatePolygon(p,t.sideOrientation,t.faceUV,t.faceColors,t.frontUVs,t.backUVs,t.wrap).applyToMesh(p,t.updatable),p},e.ExtrudePolygon=function(t,i,r,n){return void 0===r&&(r=null),void 0===n&&(n=earcut),e.CreatePolygon(t,i,r,n)},e}();Zt.ExtrudeShape=function(e,t,i,r,n,o,s,a,h,u){void 0===s&&(s=null);var l={shape:t,path:i,scale:r,rotation:n,cap:0===o?0:o||Zt.NO_CAP,sideOrientation:h,instance:u,updatable:a};return vr.ExtrudeShape(e,l,s)},Zt.ExtrudeShapeCustom=function(e,t,i,r,n,o,s,a,h,u,l,c){var f={shape:t,path:i,scaleFunction:r,rotationFunction:n,ribbonCloseArray:o,ribbonClosePath:s,cap:0===a?0:a||Zt.NO_CAP,sideOrientation:l,instance:c,updatable:u};return vr.ExtrudeShapeCustom(e,f,h)};var vr=function(){function e(){}return e.ExtrudeShape=function(t,i,r){void 0===r&&(r=null);var n=i.path,o=i.shape,s=i.scale||1,a=i.rotation||0,h=0===i.cap?0:i.cap||Zt.NO_CAP,u=i.updatable,l=Zt._GetDefaultSideOrientation(i.sideOrientation),c=i.instance||null,f=i.invertUV||!1;return e._ExtrudeShapeGeneric(t,o,n,s,a,null,null,!1,!1,h,!1,r,!!u,l,c,f,i.frontUVs||null,i.backUVs||null)},e.ExtrudeShapeCustom=function(t,i,r){void 0===r&&(r=null);var n=i.path,o=i.shape,s=i.scaleFunction||function(){return 1},a=i.rotationFunction||function(){return 0},h=i.ribbonCloseArray||!1,u=i.ribbonClosePath||!1,l=0===i.cap?0:i.cap||Zt.NO_CAP,c=i.updatable,f=Zt._GetDefaultSideOrientation(i.sideOrientation),d=i.instance,p=i.invertUV||!1;return e._ExtrudeShapeGeneric(t,o,n,null,null,s,a,h,u,l,!0,r,!!c,f,d||null,p,i.frontUVs||null,i.backUVs||null)},e._ExtrudeShapeGeneric=function(e,t,i,r,n,o,s,a,h,u,l,c,f,d,_,g,v,b){var T,E,x=function(e,t,i,r,n,o,s,a,h,u){for(var l=i.getTangents(),c=i.getNormals(),f=i.getBinormals(),d=i.getDistances(),_=0,g=u&&a?a:function(){return null!==o?o:0},v=u&&s?s:function(){return null!==n?n:1},b=h===Zt.NO_CAP||h===Zt.CAP_END?0:2,T=y.Matrix[0],E=0;E<t.length;E++){for(var x=new Array,A=g(E,d[E]),M=v(E,d[E]),P=0;P<e.length;P++){m.RotationAxisToRef(l[E],_,T);var C=l[E].scale(e[P].z).add(c[E].scale(e[P].x)).add(f[E].scale(e[P].y)),S=x[P]?x[P]:p.Zero();p.TransformCoordinatesToRef(C,T,S),S.scaleInPlace(M).addInPlace(t[E]),x[P]=S}r[b]=x,_+=A,b++}var I=function(e){var t,i=Array(),r=p.Zero();for(t=0;t<e.length;t++)r.addInPlace(e[t]);for(r.scaleInPlace(1/e.length),t=0;t<e.length;t++)i.push(r);return i};switch(h){case Zt.NO_CAP:break;case Zt.CAP_START:r[0]=I(r[2]),r[1]=r[2];break;case Zt.CAP_END:r[b]=r[b-1],r[b+1]=I(r[b-1]);break;case Zt.CAP_ALL:r[0]=I(r[2]),r[1]=r[2],r[b]=r[b-1],r[b+1]=I(r[b-1])}return r};if(_){var A=_._creationDataStorage;return T=A.path3D.update(i),E=x(t,i,A.path3D,A.pathArray,r,n,o,s,A.cap,l),_=Zt.CreateRibbon("",E,!1,!1,0,c||void 0,!1,0,_)}E=x(t,i,T=new ai(i),new Array,r,n,o,s,u=u<0||u>3?0:u,l);var M=or.CreateRibbon(e,{pathArray:E,closeArray:a,closePath:h,updatable:f,sideOrientation:d,invertUV:g,frontUVs:v||void 0,backUVs:b||void 0},c);return M._creationDataStorage.pathArray=E,M._creationDataStorage.path3D=T,M._creationDataStorage.cap=u,M},e}();Zt.CreateLathe=function(e,t,i,r,n,o,s){var a={shape:t,radius:i,tessellation:r,sideOrientation:s,updatable:o};return yr.CreateLathe(e,a,n)};var yr=function(){function e(){}return e.CreateLathe=function(e,t,i){void 0===i&&(i=null);var r,n=t.arc?t.arc<=0||t.arc>1?1:t.arc:1,o=void 0===t.closed||t.closed,s=t.shape,a=t.radius||1,h=t.tessellation||64,u=t.clip||0,l=t.updatable,c=Zt._GetDefaultSideOrientation(t.sideOrientation),f=t.cap||Zt.NO_CAP,d=2*Math.PI,_=new Array,g=t.invertUV||!1,m=0,v=0,y=d/h*n,b=new Array;for(m=0;m<=h-u;m++){b=[];for(f!=Zt.CAP_START&&f!=Zt.CAP_ALL||(b.push(new p(0,s[0].y,0)),b.push(new p(Math.cos(m*y)*s[0].x*a,s[0].y,Math.sin(m*y)*s[0].x*a))),v=0;v<s.length;v++)r=new p(Math.cos(m*y)*s[v].x*a,s[v].y,Math.sin(m*y)*s[v].x*a),b.push(r);f!=Zt.CAP_END&&f!=Zt.CAP_ALL||(b.push(new p(Math.cos(m*y)*s[s.length-1].x*a,s[s.length-1].y,Math.sin(m*y)*s[s.length-1].x*a)),b.push(new p(0,s[s.length-1].y,0))),_.push(b)}return or.CreateRibbon(e,{pathArray:_,closeArray:o,sideOrientation:c,updatable:l,invertUV:g,frontUVs:t.frontUVs,backUVs:t.backUVs},i)},e}();dt.CreatePlane=function(e){var t=[],i=[],r=[],n=[],o=e.width||e.size||1,s=e.height||e.size||1,a=0===e.sideOrientation?0:e.sideOrientation||dt.DEFAULTSIDE,h=o/2,u=s/2;i.push(-h,-u,0),r.push(0,0,-1),n.push(0,0),i.push(h,-u,0),r.push(0,0,-1),n.push(1,0),i.push(h,u,0),r.push(0,0,-1),n.push(1,1),i.push(-h,u,0),r.push(0,0,-1),n.push(0,1),t.push(0),t.push(1),t.push(2),t.push(0),t.push(2),t.push(3),dt._ComputeSides(a,i,t,r,n,e.frontUVs,e.backUVs);var l=new dt;return l.indices=t,l.positions=i,l.normals=r,l.uvs=n,l},Zt.CreatePlane=function(e,t,i,r,n){var o={size:t,width:t,height:t,sideOrientation:n,updatable:r};return br.CreatePlane(e,o,i)};var br=function(){function e(){}return e.CreatePlane=function(e,t,i){void 0===i&&(i=null);var r=new Zt(e,i);return t.sideOrientation=Zt._GetDefaultSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,dt.CreatePlane(t).applyToMesh(r,t.updatable),t.sourcePlane&&(r.translate(t.sourcePlane.normal,-t.sourcePlane.d),r.setDirection(t.sourcePlane.normal.scale(-1))),r},e}();dt.CreateTiledPlane=function(e){var t=e.pattern||Zt.NO_FLIP,i=e.tileWidth||e.tileSize||1,r=e.tileHeight||e.tileSize||1,n=e.alignHorizontal||0,o=e.alignVertical||0,s=e.width||e.size||1,a=Math.floor(s/i),h=s-a*i,u=e.height||e.size||1,l=Math.floor(u/r),c=u-l*r,f=i*a/2,d=r*l/2,p=0,_=0,g=0,m=0,v=0,y=0;if(h>0||c>0){g=-f,m=-d;v=f,y=d;switch(n){case Zt.CENTER:g-=h/=2,v+=h;break;case Zt.LEFT:v+=h,p=-h/2;break;case Zt.RIGHT:g-=h,p=h/2}switch(o){case Zt.CENTER:m-=c/=2,y+=c;break;case Zt.BOTTOM:y+=c,_=-c/2;break;case Zt.TOP:m-=c,_=c/2}}var b=[],T=[],E=[];E[0]=[0,0,1,0,1,1,0,1],E[1]=[0,0,1,0,1,1,0,1],t!==Zt.ROTATE_TILE&&t!==Zt.ROTATE_ROW||(E[1]=[1,1,0,1,0,0,1,0]),t!==Zt.FLIP_TILE&&t!==Zt.FLIP_ROW||(E[1]=[1,0,0,0,0,1,1,1]),t!==Zt.FLIP_N_ROTATE_TILE&&t!==Zt.FLIP_N_ROTATE_ROW||(E[1]=[0,1,1,1,1,0,0,0]);for(var x=[],A=[],M=[],P=0,C=0;C<l;C++)for(var S=0;S<a;S++)b.push(S*i-f+p,C*r-d+_,0),b.push((S+1)*i-f+p,C*r-d+_,0),b.push((S+1)*i-f+p,(C+1)*r-d+_,0),b.push(S*i-f+p,(C+1)*r-d+_,0),M.push(P,P+1,P+3,P+1,P+2,P+3),x=t===Zt.FLIP_TILE||t===Zt.ROTATE_TILE||t===Zt.FLIP_N_ROTATE_TILE?x.concat(E[(S%2+C%2)%2]):t===Zt.FLIP_ROW||t===Zt.ROTATE_ROW||t===Zt.FLIP_N_ROTATE_ROW?x.concat(E[C%2]):x.concat(E[0]),A.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),T.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1),P+=4;if(h>0||c>0){var I,O,R,D,w=c>0&&(o===Zt.CENTER||o===Zt.TOP),L=c>0&&(o===Zt.CENTER||o===Zt.BOTTOM),F=h>0&&(n===Zt.CENTER||n===Zt.RIGHT),N=h>0&&(n===Zt.CENTER||n===Zt.LEFT),B=[];if(w&&F&&(b.push(g+p,m+_,0),b.push(-f+p,m+_,0),b.push(-f+p,m+c+_,0),b.push(g+p,m+c+_,0),M.push(P,P+1,P+3,P+1,P+2,P+3),P+=4,B=[I=1-h/i,O=1-c/r,R=1,O,R,D=1,I,D],t===Zt.ROTATE_ROW&&(B=[1-I,1-O,1-R,1-O,1-R,1-D,1-I,1-D]),t===Zt.FLIP_ROW&&(B=[1-I,O,1-R,O,1-R,D,1-I,D]),t===Zt.FLIP_N_ROTATE_ROW&&(B=[I,1-O,R,1-O,R,1-D,I,1-D]),x=x.concat(B),A.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),T.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),w&&N&&(b.push(f+p,m+_,0),b.push(v+p,m+_,0),b.push(v+p,m+c+_,0),b.push(f+p,m+c+_,0),M.push(P,P+1,P+3,P+1,P+2,P+3),P+=4,B=[I=0,O=1-c/r,R=h/i,O,R,D=1,I,D],(t===Zt.ROTATE_ROW||t===Zt.ROTATE_TILE&&a%2==0)&&(B=[1-I,1-O,1-R,1-O,1-R,1-D,1-I,1-D]),(t===Zt.FLIP_ROW||t===Zt.FLIP_TILE&&a%2==0)&&(B=[1-I,O,1-R,O,1-R,D,1-I,D]),(t===Zt.FLIP_N_ROTATE_ROW||t===Zt.FLIP_N_ROTATE_TILE&&a%2==0)&&(B=[I,1-O,R,1-O,R,1-D,I,1-D]),x=x.concat(B),A.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),T.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),L&&F&&(b.push(g+p,d+_,0),b.push(-f+p,d+_,0),b.push(-f+p,y+_,0),b.push(g+p,y+_,0),M.push(P,P+1,P+3,P+1,P+2,P+3),P+=4,B=[I=1-h/i,O=0,R=1,O,R,D=c/r,I,D],(t===Zt.ROTATE_ROW&&l%2==1||t===Zt.ROTATE_TILE&&l%1==0)&&(B=[1-I,1-O,1-R,1-O,1-R,1-D,1-I,1-D]),(t===Zt.FLIP_ROW&&l%2==1||t===Zt.FLIP_TILE&&l%2==0)&&(B=[1-I,O,1-R,O,1-R,D,1-I,D]),(t===Zt.FLIP_N_ROTATE_ROW&&l%2==1||t===Zt.FLIP_N_ROTATE_TILE&&l%2==0)&&(B=[I,1-O,R,1-O,R,1-D,I,1-D]),x=x.concat(B),A.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),T.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),L&&N&&(b.push(f+p,d+_,0),b.push(v+p,d+_,0),b.push(v+p,y+_,0),b.push(f+p,y+_,0),M.push(P,P+1,P+3,P+1,P+2,P+3),P+=4,B=[I=0,O=0,R=h/i,O,R,D=c/r,I,D],(t===Zt.ROTATE_ROW&&l%2==1||t===Zt.ROTATE_TILE&&(l+a)%2==1)&&(B=[1-I,1-O,1-R,1-O,1-R,1-D,1-I,1-D]),(t===Zt.FLIP_ROW&&l%2==1||t===Zt.FLIP_TILE&&(l+a)%2==1)&&(B=[1-I,O,1-R,O,1-R,D,1-I,D]),(t===Zt.FLIP_N_ROTATE_ROW&&l%2==1||t===Zt.FLIP_N_ROTATE_TILE&&(l+a)%2==1)&&(B=[I,1-O,R,1-O,R,1-D,I,1-D]),x=x.concat(B),A.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),T.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),w){var k=[];I=0,O=1-c/r,R=1,D=1,k[0]=[I,O,R,O,R,D,I,D],k[1]=[I,O,R,O,R,D,I,D],t!==Zt.ROTATE_TILE&&t!==Zt.ROTATE_ROW||(k[1]=[1-I,1-O,1-R,1-O,1-R,1-D,1-I,1-D]),t!==Zt.FLIP_TILE&&t!==Zt.FLIP_ROW||(k[1]=[1-I,O,1-R,O,1-R,D,1-I,D]),t!==Zt.FLIP_N_ROTATE_TILE&&t!==Zt.FLIP_N_ROTATE_ROW||(k[1]=[I,1-O,R,1-O,R,1-D,I,1-D]);for(S=0;S<a;S++)b.push(S*i-f+p,m+_,0),b.push((S+1)*i-f+p,m+_,0),b.push((S+1)*i-f+p,m+c+_,0),b.push(S*i-f+p,m+c+_,0),M.push(P,P+1,P+3,P+1,P+2,P+3),P+=4,x=t===Zt.FLIP_TILE||t===Zt.ROTATE_TILE||t===Zt.FLIP_N_ROTATE_TILE?x.concat(k[(S+1)%2]):t===Zt.FLIP_ROW||t===Zt.ROTATE_ROW||t===Zt.FLIP_N_ROTATE_ROW?x.concat(k[1]):x.concat(k[0]),A.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),T.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)}if(L){var U=[];I=0,O=0,R=1,D=c/r,U[0]=[I,O,R,O,R,D,I,D],U[1]=[I,O,R,O,R,D,I,D],t!==Zt.ROTATE_TILE&&t!==Zt.ROTATE_ROW||(U[1]=[1-I,1-O,1-R,1-O,1-R,1-D,1-I,1-D]),t!==Zt.FLIP_TILE&&t!==Zt.FLIP_ROW||(U[1]=[1-I,O,1-R,O,1-R,D,1-I,D]),t!==Zt.FLIP_N_ROTATE_TILE&&t!==Zt.FLIP_N_ROTATE_ROW||(U[1]=[I,1-O,R,1-O,R,1-D,I,1-D]);for(S=0;S<a;S++)b.push(S*i-f+p,y-c+_,0),b.push((S+1)*i-f+p,y-c+_,0),b.push((S+1)*i-f+p,y+_,0),b.push(S*i-f+p,y+_,0),M.push(P,P+1,P+3,P+1,P+2,P+3),P+=4,x=t===Zt.FLIP_TILE||t===Zt.ROTATE_TILE||t===Zt.FLIP_N_ROTATE_TILE?x.concat(U[(S+l)%2]):t===Zt.FLIP_ROW||t===Zt.ROTATE_ROW||t===Zt.FLIP_N_ROTATE_ROW?x.concat(U[l%2]):x.concat(U[0]),A.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),T.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)}if(F){var V=[];I=1-h/i,O=0,R=1,D=1,V[0]=[I,O,R,O,R,D,I,D],V[1]=[I,O,R,O,R,D,I,D],t!==Zt.ROTATE_TILE&&t!==Zt.ROTATE_ROW||(V[1]=[1-I,1-O,1-R,1-O,1-R,1-D,1-I,1-D]),t!==Zt.FLIP_TILE&&t!==Zt.FLIP_ROW||(V[1]=[1-I,O,1-R,O,1-R,D,1-I,D]),t!==Zt.FLIP_N_ROTATE_TILE&&t!==Zt.FLIP_N_ROTATE_ROW||(V[1]=[I,1-O,R,1-O,R,1-D,I,1-D]);for(C=0;C<l;C++)b.push(g+p,C*r-d+_,0),b.push(g+h+p,C*r-d+_,0),b.push(g+h+p,(C+1)*r-d+_,0),b.push(g+p,(C+1)*r-d+_,0),M.push(P,P+1,P+3,P+1,P+2,P+3),P+=4,x=t===Zt.FLIP_TILE||t===Zt.ROTATE_TILE||t===Zt.FLIP_N_ROTATE_TILE?x.concat(V[(C+1)%2]):t===Zt.FLIP_ROW||t===Zt.ROTATE_ROW||t===Zt.FLIP_N_ROTATE_ROW?x.concat(V[C%2]):x.concat(V[0]),A.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),T.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)}if(N){var W=[];I=0,O=0,R=h/r,D=1,W[0]=[I,O,R,O,R,D,I,D],W[1]=[I,O,R,O,R,D,I,D],t!==Zt.ROTATE_TILE&&t!==Zt.ROTATE_ROW||(W[1]=[1-I,1-O,1-R,1-O,1-R,1-D,1-I,1-D]),t!==Zt.FLIP_TILE&&t!==Zt.FLIP_ROW||(W[1]=[1-I,O,1-R,O,1-R,D,1-I,D]),t!==Zt.FLIP_N_ROTATE_TILE&&t!==Zt.FLIP_N_ROTATE_ROW||(W[1]=[I,1-O,R,1-O,R,1-D,I,1-D]);for(C=0;C<l;C++)b.push(v-h+p,C*r-d+_,0),b.push(v+p,C*r-d+_,0),b.push(v+p,(C+1)*r-d+_,0),b.push(v-h+p,(C+1)*r-d+_,0),M.push(P,P+1,P+3,P+1,P+2,P+3),P+=4,x=t===Zt.FLIP_TILE||t===Zt.ROTATE_TILE||t===Zt.FLIP_N_ROTATE_TILE?x.concat(W[(C+a)%2]):t===Zt.FLIP_ROW||t===Zt.ROTATE_ROW||t===Zt.FLIP_N_ROTATE_ROW?x.concat(W[C%2]):x.concat(W[0]),A.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),T.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)}}var z=0===e.sideOrientation?0:e.sideOrientation||dt.DEFAULTSIDE;dt._ComputeSides(z,b,M,T,x,e.frontUVs,e.backUVs);var G=new dt;G.indices=M,G.positions=b,G.normals=T,G.uvs=x;var H=z===dt.DOUBLESIDE?A.concat(A):A;return G.colors=H,G};var Tr=function(){function e(){}return e.CreateTiledPlane=function(e,t,i){void 0===i&&(i=null);var r=new Zt(e,i);return t.sideOrientation=Zt._GetDefaultSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,dt.CreateTiledPlane(t).applyToMesh(r,t.updatable),r},e}();Zt._GroundMeshParser=function(e,t){return Er.Parse(e,t)};var Er=function(e){function i(t,i){var r=e.call(this,t,i)||this;return r.generateOctree=!1,r}return t(i,e),i.prototype.getClassName=function(){return"GroundMesh"},Object.defineProperty(i.prototype,"subdivisions",{get:function(){return Math.min(this._subdivisionsX,this._subdivisionsY)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"subdivisionsX",{get:function(){return this._subdivisionsX},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"subdivisionsY",{get:function(){return this._subdivisionsY},enumerable:!1,configurable:!0}),i.prototype.optimize=function(e,t){void 0===t&&(t=32),this._subdivisionsX=e,this._subdivisionsY=e,this.subdivide(e);this.createOrUpdateSubmeshesOctree&&this.createOrUpdateSubmeshesOctree(t)},i.prototype.getHeightAtCoordinates=function(e,t){var i=this.getWorldMatrix(),r=y.Matrix[5];i.invertToRef(r);var n=y.Vector3[8];if(p.TransformCoordinatesFromFloatsToRef(e,0,t,r,n),e=n.x,t=n.z,e<this._minX||e>this._maxX||t<this._minZ||t>this._maxZ)return this.position.y;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var o=this._getFacetAt(e,t),s=-(o.x*e+o.z*t+o.w)/o.y;return p.TransformCoordinatesFromFloatsToRef(0,s,0,i,n),n.y},i.prototype.getNormalAtCoordinates=function(e,t){var i=new p(0,1,0);return this.getNormalAtCoordinatesToRef(e,t,i),i},i.prototype.getNormalAtCoordinatesToRef=function(e,t,i){var r=this.getWorldMatrix(),n=y.Matrix[5];r.invertToRef(n);var o=y.Vector3[8];if(p.TransformCoordinatesFromFloatsToRef(e,0,t,n,o),e=o.x,t=o.z,e<this._minX||e>this._maxX||t<this._minZ||t>this._maxZ)return this;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var s=this._getFacetAt(e,t);return p.TransformNormalFromFloatsToRef(s.x,s.y,s.z,r,i),this},i.prototype.updateCoordinateHeights=function(){return this._heightQuads&&0!=this._heightQuads.length||this._initHeightQuads(),this._computeHeightQuads(),this},i.prototype._getFacetAt=function(e,t){var i=Math.floor((e+this._maxX)*this._subdivisionsX/this._width),r=Math.floor(-(t+this._maxZ)*this._subdivisionsY/this._height+this._subdivisionsY),n=this._heightQuads[r*this._subdivisionsX+i];return t<n.slope.x*e+n.slope.y?n.facet1:n.facet2},i.prototype._initHeightQuads=function(){var e=this._subdivisionsX,t=this._subdivisionsY;this._heightQuads=new Array;for(var i=0;i<t;i++)for(var r=0;r<e;r++){var n={slope:d.Zero(),facet1:new _(0,0,0,0),facet2:new _(0,0,0,0)};this._heightQuads[i*e+r]=n}return this},i.prototype._computeHeightQuads=function(){var e=this.getVerticesData(ft.PositionKind);if(!e)return this;for(var t=y.Vector3[3],i=y.Vector3[2],r=y.Vector3[1],n=y.Vector3[0],o=y.Vector3[4],s=y.Vector3[5],a=y.Vector3[6],h=y.Vector3[7],u=y.Vector3[8],l=0,c=0,f=0,d=0,_=0,g=0,m=0,v=this._subdivisionsX,b=this._subdivisionsY,T=0;T<b;T++)for(var E=0;E<v;E++){l=3*E,c=T*(v+1)*3,f=(T+1)*(v+1)*3,t.x=e[c+l],t.y=e[c+l+1],t.z=e[c+l+2],i.x=e[c+l+3],i.y=e[c+l+4],i.z=e[c+l+5],r.x=e[f+l],r.y=e[f+l+1],r.z=e[f+l+2],n.x=e[f+l+3],n.y=e[f+l+4],n.z=e[f+l+5],d=(n.z-t.z)/(n.x-t.x),_=t.z-d*t.x,i.subtractToRef(t,o),r.subtractToRef(t,s),n.subtractToRef(t,a),p.CrossToRef(a,s,h),p.CrossToRef(o,a,u),h.normalize(),u.normalize(),g=-(h.x*t.x+h.y*t.y+h.z*t.z),m=-(u.x*i.x+u.y*i.y+u.z*i.z);var x=this._heightQuads[T*v+E];x.slope.copyFromFloats(d,_),x.facet1.copyFromFloats(h.x,h.y,h.z,g),x.facet2.copyFromFloats(u.x,u.y,u.z,m)}return this},i.prototype.serialize=function(t){e.prototype.serialize.call(this,t),t.subdivisionsX=this._subdivisionsX,t.subdivisionsY=this._subdivisionsY,t.minX=this._minX,t.maxX=this._maxX,t.minZ=this._minZ,t.maxZ=this._maxZ,t.width=this._width,t.height=this._height},i.Parse=function(e,t){var r=new i(e.name,t);return r._subdivisionsX=e.subdivisionsX||1,r._subdivisionsY=e.subdivisionsY||1,r._minX=e.minX,r._maxX=e.maxX,r._minZ=e.minZ,r._maxZ=e.maxZ,r._width=e.width,r._height=e.height,r},i}(Zt);dt.CreateGround=function(e){var t,i,r=[],n=[],o=[],s=[],a=e.width||1,h=e.height||1,u=e.subdivisionsX||e.subdivisions||1,l=e.subdivisionsY||e.subdivisions||1;for(t=0;t<=l;t++)for(i=0;i<=u;i++){var c=new p(i*a/u-a/2,0,(l-t)*h/l-h/2),f=new p(0,1,0);n.push(c.x,c.y,c.z),o.push(f.x,f.y,f.z),s.push(i/u,1-t/l)}for(t=0;t<l;t++)for(i=0;i<u;i++)r.push(i+1+(t+1)*(u+1)),r.push(i+1+t*(u+1)),r.push(i+t*(u+1)),r.push(i+(t+1)*(u+1)),r.push(i+1+(t+1)*(u+1)),r.push(i+t*(u+1));var d=new dt;return d.indices=r,d.positions=n,d.normals=o,d.uvs=s,d},dt.CreateTiledGround=function(e){var t,i,r,n,o=void 0!==e.xmin&&null!==e.xmin?e.xmin:-1,s=void 0!==e.zmin&&null!==e.zmin?e.zmin:-1,a=void 0!==e.xmax&&null!==e.xmax?e.xmax:1,h=void 0!==e.zmax&&null!==e.zmax?e.zmax:1,u=e.subdivisions||{w:1,h:1},l=e.precision||{w:1,h:1},c=new Array,f=new Array,d=new Array,_=new Array;u.h=u.h<1?1:u.h,u.w=u.w<1?1:u.w,l.w=l.w<1?1:l.w,l.h=l.h<1?1:l.h;var g=(a-o)/u.w,m=(h-s)/u.h;function v(e,r,n,o){var s=f.length/3,a=l.w+1;for(t=0;t<l.h;t++)for(i=0;i<l.w;i++){var h=[s+i+t*a,s+(i+1)+t*a,s+(i+1)+(t+1)*a,s+i+(t+1)*a];c.push(h[1]),c.push(h[2]),c.push(h[3]),c.push(h[0]),c.push(h[1]),c.push(h[3])}var u=p.Zero(),g=new p(0,1,0);for(t=0;t<=l.h;t++)for(u.z=t*(o-r)/l.h+r,i=0;i<=l.w;i++)u.x=i*(n-e)/l.w+e,u.y=0,f.push(u.x,u.y,u.z),d.push(g.x,g.y,g.z),_.push(i/l.w,t/l.h)}for(r=0;r<u.h;r++)for(n=0;n<u.w;n++)v(o+n*g,s+r*m,o+(n+1)*g,s+(r+1)*m);var y=new dt;return y.indices=c,y.positions=f,y.normals=d,y.uvs=_,y},dt.CreateGroundFromHeightMap=function(e){var t,i,r=[],n=[],o=[],s=[],a=e.colorFilter||new T(.3,.59,.11),h=e.alphaFilter||0,l=!1;if(e.minHeight>e.maxHeight){l=!0;var c=e.maxHeight;e.maxHeight=e.minHeight,e.minHeight=c}for(t=0;t<=e.subdivisions;t++)for(i=0;i<=e.subdivisions;i++){var f=new p(i*e.width/e.subdivisions-e.width/2,0,(e.subdivisions-t)*e.height/e.subdivisions-e.height/2),d=4*(((f.x+e.width/2)/e.width*(e.bufferWidth-1)|0)+((1-(f.z+e.height/2)/e.height)*(e.bufferHeight-1)|0)*e.bufferWidth),_=e.buffer[d]/255,g=e.buffer[d+1]/255,m=e.buffer[d+2]/255,v=e.buffer[d+3]/255;l&&(_=1-_,g=1-g,m=1-m);var y=_*a.r+g*a.g+m*a.b;f.y=v>=h?e.minHeight+(e.maxHeight-e.minHeight)*y:e.minHeight-u,n.push(f.x,f.y,f.z),o.push(0,0,0),s.push(i/e.subdivisions,1-t/e.subdivisions)}for(t=0;t<e.subdivisions;t++)for(i=0;i<e.subdivisions;i++){var b=i+1+(t+1)*(e.subdivisions+1),E=i+1+t*(e.subdivisions+1),x=i+t*(e.subdivisions+1),A=i+(t+1)*(e.subdivisions+1),M=n[3*b+1]>=e.minHeight,P=n[3*E+1]>=e.minHeight,C=n[3*x+1]>=e.minHeight;M&&P&&C&&(r.push(b),r.push(E),r.push(x)),n[3*A+1]>=e.minHeight&&M&&C&&(r.push(A),r.push(b),r.push(x))}dt.ComputeNormals(n,r,o);var S=new dt;return S.indices=r,S.positions=n,S.normals=o,S.uvs=s,S},Zt.CreateGround=function(e,t,i,r,n,o){var s={width:t,height:i,subdivisions:r,updatable:o};return xr.CreateGround(e,s,n)},Zt.CreateTiledGround=function(e,t,i,r,n,o,s,a,h){var u={xmin:t,zmin:i,xmax:r,zmax:n,subdivisions:o,precision:s,updatable:h};return xr.CreateTiledGround(e,u,a)},Zt.CreateGroundFromHeightMap=function(e,t,i,r,n,o,s,a,h,u,l){var c={width:i,height:r,subdivisions:n,minHeight:o,maxHeight:s,updatable:h,onReady:u,alphaFilter:l};return xr.CreateGroundFromHeightMap(e,t,c,a)};var xr=function(){function e(){}return e.CreateGround=function(e,t,i){var r=new Er(e,i);return r._setReady(!1),r._subdivisionsX=t.subdivisionsX||t.subdivisions||1,r._subdivisionsY=t.subdivisionsY||t.subdivisions||1,r._width=t.width||1,r._height=t.height||1,r._maxX=r._width/2,r._maxZ=r._height/2,r._minX=-r._maxX,r._minZ=-r._maxZ,dt.CreateGround(t).applyToMesh(r,t.updatable),r._setReady(!0),r},e.CreateTiledGround=function(e,t,i){void 0===i&&(i=null);var r=new Zt(e,i);return dt.CreateTiledGround(t).applyToMesh(r,t.updatable),r},e.CreateGroundFromHeightMap=function(e,t,i,r){void 0===r&&(r=null);var n=i.width||10,o=i.height||10,s=i.subdivisions||1,a=i.minHeight||0,h=i.maxHeight||1,u=i.colorFilter||new T(.3,.59,.11),l=i.alphaFilter||0,c=i.updatable,f=i.onReady;r=r||V.LastCreatedScene;var d=new Er(e,r);d._subdivisionsX=s,d._subdivisionsY=s,d._width=n,d._height=o,d._maxX=d._width/2,d._maxZ=d._height/2,d._minX=-d._maxX,d._minZ=-d._maxZ,d._setReady(!1);return Ue.LoadImage(t,(function(e){var t=e.width,i=e.height,p=ve.CreateCanvas(t,i).getContext("2d");if(!p)throw new Error("Unable to get 2d context for CreateGroundFromHeightMap");if(!r.isDisposed){p.drawImage(e,0,0);var _=p.getImageData(0,0,t,i).data;dt.CreateGroundFromHeightMap({width:n,height:o,subdivisions:s,minHeight:a,maxHeight:h,colorFilter:u,buffer:_,bufferWidth:t,bufferHeight:i,alphaFilter:l}).applyToMesh(d,c),f&&f(d),d._setReady(!0)}}),(function(){}),r.offlineProvider),d},e}();Zt.CreateTube=function(e,t,i,r,n,o,s,a,h,u){var l={path:t,radius:i,tessellation:r,radiusFunction:n,arc:1,cap:o,updatable:a,sideOrientation:h,instance:u};return Ar.CreateTube(e,l,s)};var Ar=function(){function e(){}return e.CreateTube=function(e,t,i){void 0===i&&(i=null);var r=t.path,n=t.instance,o=1;void 0!==t.radius?o=t.radius:n&&(o=n._creationDataStorage.radius);var s=t.tessellation||64,a=t.radiusFunction||null,h=t.cap||Zt.NO_CAP,u=t.invertUV||!1,l=t.updatable,c=Zt._GetDefaultSideOrientation(t.sideOrientation);t.arc=t.arc&&(t.arc<=0||t.arc>1)?1:t.arc||1;var f,d,_=function(e,t,i,r,n,o,s,a){for(var h,u,l,c,f=t.getTangents(),d=t.getNormals(),_=t.getDistances(),g=2*Math.PI/n*a,v=o||function(){return r},b=y.Matrix[0],T=s===Zt.NO_CAP||s===Zt.CAP_END?0:2,E=0;E<e.length;E++){u=v(E,_[E]),h=Array(),l=d[E];for(var x=0;x<n;x++)m.RotationAxisToRef(f[E],g*x,b),c=h[x]?h[x]:p.Zero(),p.TransformCoordinatesToRef(l,b,c),c.scaleInPlace(u).addInPlace(e[E]),h[x]=c;i[T]=h,T++}var A=function(t,i){for(var r=Array(),n=0;n<t;n++)r.push(e[i]);return r};switch(s){case Zt.NO_CAP:break;case Zt.CAP_START:i[0]=A(n,0),i[1]=i[2].slice(0);break;case Zt.CAP_END:i[T]=i[T-1].slice(0),i[T+1]=A(n,e.length-1);break;case Zt.CAP_ALL:i[0]=A(n,0),i[1]=i[2].slice(0),i[T]=i[T-1].slice(0),i[T+1]=A(n,e.length-1)}return i};if(n){var g=n._creationDataStorage,v=t.arc||g.arc;return d=_(r,f=g.path3D.update(r),g.pathArray,o,g.tessellation,a,g.cap,v),n=or.CreateRibbon("",{pathArray:d,instance:n}),g.path3D=f,g.pathArray=d,g.arc=v,g.radius=o,n}d=_(r,f=new ai(r),new Array,o,s,a,h=h<0||h>3?0:h,t.arc);var b=or.CreateRibbon(e,{pathArray:d,closePath:!0,closeArray:!1,updatable:l,sideOrientation:c,invertUV:u,frontUVs:t.frontUVs,backUVs:t.backUVs},i);return b._creationDataStorage.pathArray=d,b._creationDataStorage.path3D=f,b._creationDataStorage.tessellation=s,b._creationDataStorage.cap=h,b._creationDataStorage.arc=t.arc,b._creationDataStorage.radius=o,b},e}();dt.CreatePolyhedron=function(e){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 i,r,n,o,s,a,h=e.type&&(e.type<0||e.type>=t.length)?0:e.type||0,u=e.size,l=e.sizeX||u||1,c=e.sizeY||u||1,f=e.sizeZ||u||1,d=e.custom||t[h],p=d.face.length,g=e.faceUV||new Array(p),m=e.faceColors,v=void 0===e.flat||e.flat,y=0===e.sideOrientation?0:e.sideOrientation||dt.DEFAULTSIDE,b=new Array,T=new Array,x=new Array,A=new Array,M=new Array,P=0,C=0,S=new Array,I=0,O=0;if(v)for(O=0;O<p;O++)m&&void 0===m[O]&&(m[O]=new E(1,1,1,1)),g&&void 0===g[O]&&(g[O]=new _(0,0,1,1));if(v)for(O=0;O<p;O++){var R=d.face[O].length;for(n=2*Math.PI/R,o=.5*Math.tan(n/2),s=.5,I=0;I<R;I++)b.push(d.vertex[d.face[O][I]][0]*l,d.vertex[d.face[O][I]][1]*c,d.vertex[d.face[O][I]][2]*f),S.push(P),P++,i=g[O].x+(g[O].z-g[O].x)*(.5+o),r=g[O].y+(g[O].w-g[O].y)*(s-.5),A.push(i,r),a=o*Math.cos(n)-s*Math.sin(n),s=o*Math.sin(n)+s*Math.cos(n),o=a,m&&M.push(m[O].r,m[O].g,m[O].b,m[O].a);for(I=0;I<R-2;I++)T.push(S[0+C],S[I+2+C],S[I+1+C]);C+=R}else{for(I=0;I<d.vertex.length;I++)b.push(d.vertex[I][0]*l,d.vertex[I][1]*c,d.vertex[I][2]*f),A.push(0,0);for(O=0;O<p;O++)for(I=0;I<d.face[O].length-2;I++)T.push(d.face[O][0],d.face[O][I+2],d.face[O][I+1])}dt.ComputeNormals(b,T,x),dt._ComputeSides(y,b,T,x,A,e.frontUVs,e.backUVs);var D=new dt;return D.positions=b,D.indices=T,D.normals=x,D.uvs=A,m&&v&&(D.colors=M),D},Zt.CreatePolyhedron=function(e,t,i){return Mr.CreatePolyhedron(e,t,i)};var Mr=function(){function e(){}return e.CreatePolyhedron=function(e,t,i){void 0===i&&(i=null);var r=new Zt(e,i);return t.sideOrientation=Zt._GetDefaultSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,dt.CreatePolyhedron(t).applyToMesh(r,t.updatable),r},e}();dt.CreateIcoSphere=function(e){var t,i=e.sideOrientation||dt.DEFAULTSIDE,r=e.radius||1,n=void 0===e.flat||e.flat,o=e.subdivisions||4,s=e.radiusX||r,a=e.radiusY||r,h=e.radiusZ||r,u=(1+Math.sqrt(5))/2,l=[-1,u,-0,1,u,0,-1,-u,0,1,-u,0,0,-1,-u,0,1,-u,0,-1,u,0,1,u,u,0,1,u,0,-1,-u,0,1,-u,0,-1],c=[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],f=[0,1,2,3,4,5,6,7,8,9,10,11,0,2,3,3,3,4,7,8,9,9,10,11],_=[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],g=[0,0,0,0,1,0,0,1,1,0,0,0,1,1,0,0,1,1,1,0],m=new Array,v=new Array,y=new Array,b=new Array,T=0,E=new Array(3),x=new Array(3);for(t=0;t<3;t++)E[t]=p.Zero(),x[t]=d.Zero();for(var A=0;A<20;A++){for(t=0;t<3;t++){var M=c[3*A+t];E[t].copyFromFloats(l[3*f[M]],l[3*f[M]+1],l[3*f[M]+2]),E[t].normalize().scaleInPlace(r),x[t].copyFromFloats(.134765625*_[2*M]+.05859375+-.0390625*g[A],.2333984375*_[2*M+1]+.025390625+.01953125*g[A])}for(var P=function(e,t,i,r){var u,l=p.Lerp(E[0],E[2],t/o),c=p.Lerp(E[1],E[2],t/o),f=o===t?E[2]:p.Lerp(l,c,e/(o-t));if(f.normalize(),n){var _=p.Lerp(E[0],E[2],r/o),g=p.Lerp(E[1],E[2],r/o);u=p.Lerp(_,g,i/(o-r))}else u=new p(f.x,f.y,f.z);u.x/=s,u.y/=a,u.z/=h,u.normalize();var A=d.Lerp(x[0],x[2],t/o),M=d.Lerp(x[1],x[2],t/o),P=o===t?x[2]:d.Lerp(A,M,e/(o-t));v.push(f.x*s,f.y*a,f.z*h),y.push(u.x,u.y,u.z),b.push(P.x,P.y),m.push(T),T++},C=0;C<o;C++)for(var S=0;S+C<o;S++)P(S,C,S+1/3,C+1/3),P(S+1,C,S+1/3,C+1/3),P(S,C+1,S+1/3,C+1/3),S+C+1<o&&(P(S+1,C,S+2/3,C+2/3),P(S+1,C+1,S+2/3,C+2/3),P(S,C+1,S+2/3,C+2/3))}dt._ComputeSides(i,v,m,y,b,e.frontUVs,e.backUVs);var I=new dt;return I.indices=m,I.positions=v,I.normals=y,I.uvs=b,I},Zt.CreateIcoSphere=function(e,t,i){return Pr.CreateIcoSphere(e,t,i)};var Pr=function(){function e(){}return e.CreateIcoSphere=function(e,t,i){void 0===i&&(i=null);var r=new Zt(e,i);return t.sideOrientation=Zt._GetDefaultSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,dt.CreateIcoSphere(t).applyToMesh(r,t.updatable),r},e}(),Cr=function(){function e(e,t){void 0===e&&(e=p.Zero()),void 0===t&&(t=p.Up()),this.position=e,this.normal=t}return e.prototype.clone=function(){return new e(this.position.clone(),this.normal.clone())},e}();Zt.CreateDecal=function(e,t,i,r,n,o){var s={position:i,normal:r,size:n,angle:o};return Sr.CreateDecal(e,t,s)};var Sr=function(){function e(){}return e.CreateDecal=function(e,t,i){var r=t.getIndices(),n=t.getVerticesData(ft.PositionKind),o=t.getVerticesData(ft.NormalKind),s=i.position||p.Zero(),a=i.normal||p.Up(),h=i.size||p.One(),u=i.angle||0;if(!a){var l=new p(0,0,1),c=t.getScene().activeCamera,f=p.TransformCoordinates(l,c.getWorldMatrix());a=c.globalPosition.subtract(f)}var d=-Math.atan2(a.z,a.x)-Math.PI/2,_=Math.sqrt(a.x*a.x+a.z*a.z),g=Math.atan2(a.y,_),v=m.RotationYawPitchRoll(d,g,u).multiply(m.Translation(s.x,s.y,s.z)),y=m.Invert(v),b=t.getWorldMatrix().multiply(y),T=new dt;T.indices=[],T.positions=[],T.normals=[],T.uvs=[];for(var E=0,x=function(e){var t=new Cr;if(!r||!n||!o)return t;var i=r[e];return t.position=new p(n[3*i],n[3*i+1],n[3*i+2]),t.position=p.TransformCoordinates(t.position,b),t.normal=new p(o[3*i],o[3*i+1],o[3*i+2]),t.normal=p.TransformNormal(t.normal,b),t},A=function(e,t){if(0===e.length)return e;for(var i=.5*Math.abs(p.Dot(h,t)),r=function(e,r){var n=p.GetClipFactor(e.position,r.position,t,i);return new Cr(p.Lerp(e.position,r.position,n),p.Lerp(e.normal,r.normal,n))},n=new Array,o=0;o<e.length;o+=3){var s,a,u,l=null,c=null,f=null,d=null;switch(((s=p.Dot(e[o].position,t)-i>0)?1:0)+((a=p.Dot(e[o+1].position,t)-i>0)?1:0)+((u=p.Dot(e[o+2].position,t)-i>0)?1:0)){case 0:n.push(e[o]),n.push(e[o+1]),n.push(e[o+2]);break;case 1:if(s&&(l=e[o+1],c=e[o+2],f=r(e[o],l),d=r(e[o],c)),a){l=e[o],c=e[o+2],f=r(e[o+1],l),d=r(e[o+1],c),n.push(f),n.push(c.clone()),n.push(l.clone()),n.push(c.clone()),n.push(f.clone()),n.push(d);break}u&&(l=e[o],c=e[o+1],f=r(e[o+2],l),d=r(e[o+2],c)),l&&c&&f&&d&&(n.push(l.clone()),n.push(c.clone()),n.push(f),n.push(d),n.push(f.clone()),n.push(c.clone()));break;case 2:s||(c=r(l=e[o].clone(),e[o+1]),f=r(l,e[o+2]),n.push(l),n.push(c),n.push(f)),a||(c=r(l=e[o+1].clone(),e[o+2]),f=r(l,e[o]),n.push(l),n.push(c),n.push(f)),u||(c=r(l=e[o+2].clone(),e[o]),f=r(l,e[o+1]),n.push(l),n.push(c),n.push(f))}}return n},M=0;M<r.length;M+=3){var P=new Array;if(P.push(x(M)),P.push(x(M+1)),P.push(x(M+2)),P=A(P,new p(1,0,0)),P=A(P,new p(-1,0,0)),P=A(P,new p(0,1,0)),P=A(P,new p(0,-1,0)),P=A(P,new p(0,0,1)),0!==(P=A(P,new p(0,0,-1))).length)for(var C=0;C<P.length;C++){var S=P[C];T.indices.push(E),S.position.toArray(T.positions,3*E),S.normal.toArray(T.normals,3*E),T.uvs.push(.5+S.position.x/h.x),T.uvs.push(.5+S.position.y/h.y),E++}}var I=new Zt(e,t.getScene());return T.applyToMesh(I),I.position=s.clone(),I.rotation=new p(g,d,u),I},e}();dt.CreateCapsule=function(e){void 0===e&&(e={subdivisions:2,tessellation:16,height:1,radius:.25,capSubdivisions:6});var t,i,r=Math.max(e.subdivisions?e.subdivisions:2,1),n=Math.max(e.tessellation?e.tessellation:16,3),o=Math.max(e.height?e.height:1,0),s=Math.max(e.radius?e.radius:.25,0),a=Math.max(e.capSubdivisions?e.capSubdivisions:6,1),h=n,u=r,l=Math.max(e.radiusTop?e.radiusTop:s,0),c=Math.max(e.radiusBottom?e.radiusBottom:s,0),f=o-(l+c),_=2*Math.PI,g=Math.max(e.topCapSubdivisions?e.topCapSubdivisions:a,1),v=Math.max(e.bottomCapSubdivisions?e.bottomCapSubdivisions:a,1),y=Math.acos((c-l)/o),b=[],T=[],E=[],x=[],A=0,M=[],P=.5*f,C=.5*Math.PI,S=p.Zero(),I=p.Zero(),O=Math.cos(y),R=Math.sin(y),D=new d(l*R,P+l*O).subtract(new d(c*R,c*O-P)).length(),w=l*y+D+c*(C-y),L=0;for(i=0;i<=g;i++){var F=[],N=C-y*(i/g);L+=l*y/g;var B=Math.cos(N),k=Math.sin(N),U=B*l;for(t=0;t<=h;t++){var V=(X=t/h)*_+0,W=Math.sin(V),z=Math.cos(V);I.x=U*W,I.y=P+k*l,I.z=U*z,T.push(I.x,I.y,I.z),S.set(B*W,k,B*z),E.push(S.x,S.y,S.z),x.push(X,1-L/w),F.push(A),A++}M.push(F)}var G=o-l-c+O*l-O*c,H=R*(c-l)/G;for(i=1;i<=u;i++){F=[];L+=D/u;U=R*(i*(c-l)/u+l);for(t=0;t<=h;t++){V=(X=t/h)*_+0,W=Math.sin(V),z=Math.cos(V);I.x=U*W,I.y=P+O*l-i*G/u,I.z=U*z,T.push(I.x,I.y,I.z),S.set(W,H,z).normalize(),E.push(S.x,S.y,S.z),x.push(X,1-L/w),F.push(A),A++}M.push(F)}for(i=1;i<=v;i++){F=[],N=C-y-(Math.PI-y)*(i/v);L+=c*y/v;B=Math.cos(N),k=Math.sin(N),U=B*c;for(t=0;t<=h;t++){var X;V=(X=t/h)*_+0,W=Math.sin(V),z=Math.cos(V);I.x=U*W,I.y=k*c-P,I.z=U*z,T.push(I.x,I.y,I.z),S.set(B*W,k,B*z),E.push(S.x,S.y,S.z),x.push(X,1-L/w),F.push(A),A++}M.push(F)}for(t=0;t<h;t++)for(i=0;i<g+u+v;i++){var j=M[i][t],K=M[i+1][t],Y=M[i+1][t+1],q=M[i][t+1];b.push(j),b.push(K),b.push(q),b.push(K),b.push(Y),b.push(q)}if(b=b.reverse(),e.orientation&&!e.orientation.equals(p.Up())){var Z=new m;e.orientation.clone().scale(.5*Math.PI).cross(p.Up()).toQuaternion().toRotationMatrix(Z);for(var Q=p.Zero(),J=0;J<T.length;J+=3)Q.set(T[J],T[J+1],T[J+2]),p.TransformCoordinatesToRef(Q.clone(),Z,Q),T[J]=Q.x,T[J+1]=Q.y,T[J+2]=Q.z}var $=new dt;return $.positions=T,$.normals=E,$.uvs=x,$.indices=b,$},Zt.CreateCapsule=function(e,t,i){return Ir.CreateCapsule(e,t,i)};var Ir=function(){function e(){}return e.CreateCapsule=function(e,t,i){void 0===t&&(t={orientation:p.Up(),subdivisions:2,tessellation:16,height:1,radius:.25,capSubdivisions:6});var r=new Zt(e,i);return dt.CreateCapsule(t).applyToMesh(r),r},e}(),Or=function(){function e(){}return e.CreateBox=function(e,t,i){return void 0===i&&(i=null),ar.CreateBox(e,t,i)},e.CreateTiledBox=function(e,t,i){return void 0===i&&(i=null),hr.CreateTiledBox(e,t,i)},e.CreateSphere=function(e,t,i){return void 0===i&&(i=null),ur.CreateSphere(e,t,i)},e.CreateDisc=function(e,t,i){return void 0===i&&(i=null),sr.CreateDisc(e,t,i)},e.CreateIcoSphere=function(e,t,i){return void 0===i&&(i=null),Pr.CreateIcoSphere(e,t,i)},e.CreateRibbon=function(e,t,i){return void 0===i&&(i=null),or.CreateRibbon(e,t,i)},e.CreateCylinder=function(e,t,i){return void 0===i&&(i=null),lr.CreateCylinder(e,t,i)},e.CreateTorus=function(e,t,i){return void 0===i&&(i=null),cr.CreateTorus(e,t,i)},e.CreateTorusKnot=function(e,t,i){return void 0===i&&(i=null),fr.CreateTorusKnot(e,t,i)},e.CreateLineSystem=function(e,t,i){return dr.CreateLineSystem(e,t,i)},e.CreateLines=function(e,t,i){return void 0===i&&(i=null),dr.CreateLines(e,t,i)},e.CreateDashedLines=function(e,t,i){return void 0===i&&(i=null),dr.CreateDashedLines(e,t,i)},e.ExtrudeShape=function(e,t,i){return void 0===i&&(i=null),vr.ExtrudeShape(e,t,i)},e.ExtrudeShapeCustom=function(e,t,i){return void 0===i&&(i=null),vr.ExtrudeShapeCustom(e,t,i)},e.CreateLathe=function(e,t,i){return void 0===i&&(i=null),yr.CreateLathe(e,t,i)},e.CreateTiledPlane=function(e,t,i){return void 0===i&&(i=null),Tr.CreateTiledPlane(e,t,i)},e.CreatePlane=function(e,t,i){return void 0===i&&(i=null),br.CreatePlane(e,t,i)},e.CreateGround=function(e,t,i){return void 0===i&&(i=null),xr.CreateGround(e,t,i)},e.CreateTiledGround=function(e,t,i){return void 0===i&&(i=null),xr.CreateTiledGround(e,t,i)},e.CreateGroundFromHeightMap=function(e,t,i,r){return void 0===r&&(r=null),xr.CreateGroundFromHeightMap(e,t,i,r)},e.CreatePolygon=function(e,t,i,r){return void 0===i&&(i=null),void 0===r&&(r=earcut),mr.CreatePolygon(e,t,i,r)},e.ExtrudePolygon=function(e,t,i,r){return void 0===i&&(i=null),void 0===r&&(r=earcut),mr.ExtrudePolygon(e,t,i,r)},e.CreateTube=function(e,t,i){return void 0===i&&(i=null),Ar.CreateTube(e,t,i)},e.CreatePolyhedron=function(e,t,i){return void 0===i&&(i=null),Mr.CreatePolyhedron(e,t,i)},e.CreateDecal=function(e,t,i){return Sr.CreateDecal(e,t,i)},e.CreateCapsule=function(e,t,i){return void 0===t&&(t={orientation:p.Up(),subdivisions:2,tessellation:16,height:1,radius:.25,capSubdivisions:6}),void 0===i&&(i=null),Ir.CreateCapsule(e,t,i)},e}(),Rr=function(){function e(t,i,r){void 0===i&&(i=e.UNITMODE_PIXEL),void 0===r&&(r=!0),this.unit=i,this.negativeValueAllowed=r,this._value=1,this.ignoreAdaptiveScaling=!1,this._value=t,this._originalUnit=i}return Object.defineProperty(e.prototype,"isPercentage",{get:function(){return this.unit===e.UNITMODE_PERCENTAGE},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isPixel",{get:function(){return this.unit===e.UNITMODE_PIXEL},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"internalValue",{get:function(){return this._value},enumerable:!1,configurable:!0}),e.prototype.getValueInPixel=function(e,t){return this.isPixel?this.getValue(e):this.getValue(e)*t},e.prototype.updateInPlace=function(t,i){return void 0===i&&(i=e.UNITMODE_PIXEL),this._value=t,this.unit=i,this},e.prototype.getValue=function(t){if(t&&!this.ignoreAdaptiveScaling&&this.unit!==e.UNITMODE_PERCENTAGE){var i=0,r=0;if(t.idealWidth&&(i=this._value*t.getSize().width/t.idealWidth),t.idealHeight&&(r=this._value*t.getSize().height/t.idealHeight),t.useSmallestIdeal&&t.idealWidth&&t.idealHeight)return window.innerWidth<window.innerHeight?i:r;if(t.idealWidth)return i;if(t.idealHeight)return r}return this._value},e.prototype.toString=function(t,i){switch(this.unit){case e.UNITMODE_PERCENTAGE:var r=100*this.getValue(t);return(i?r.toFixed(i):r)+"%";case e.UNITMODE_PIXEL:var n=this.getValue(t);return(i?n.toFixed(i):n)+"px"}return this.unit.toString()},e.prototype.fromString=function(t){var i=e._Regex.exec(t.toString());if(!i||0===i.length)return!1;var r=parseFloat(i[1]),n=this._originalUnit;if(this.negativeValueAllowed||r<0&&(r=0),4===i.length)switch(i[3]){case"px":n=e.UNITMODE_PIXEL;break;case"%":n=e.UNITMODE_PERCENTAGE,r/=100}return(r!==this._value||n!==this.unit)&&(this._value=r,this.unit=n,!0)},Object.defineProperty(e,"UNITMODE_PERCENTAGE",{get:function(){return e._UNITMODE_PERCENTAGE},enumerable:!1,configurable:!0}),Object.defineProperty(e,"UNITMODE_PIXEL",{get:function(){return e._UNITMODE_PIXEL},enumerable:!1,configurable:!0}),e._Regex=/(^-?\d*(\.\d+)?)(%|px)?/,e._UNITMODE_PERCENTAGE=0,e._UNITMODE_PIXEL=1,e}(),Dr=[new d(0,0),new d(0,0),new d(0,0),new d(0,0)],wr=[new d(0,0),new d(0,0),new d(0,0),new d(0,0)],Lr=new d(0,0),Fr=new d(0,0),Nr=function(){function e(e,t,i,r){this.left=e,this.top=t,this.width=i,this.height=r}return e.prototype.copyFrom=function(e){this.left=e.left,this.top=e.top,this.width=e.width,this.height=e.height},e.prototype.copyFromFloats=function(e,t,i,r){this.left=e,this.top=t,this.width=i,this.height=r},e.CombineToRef=function(e,t,i){var r=Math.min(e.left,t.left),n=Math.min(e.top,t.top),o=Math.max(e.left+e.width,t.left+t.width),s=Math.max(e.top+e.height,t.top+t.height);i.left=r,i.top=n,i.width=o-r,i.height=s-n},e.prototype.addAndTransformToRef=function(e,t,i,r,n,o){var s=this.left+t,a=this.top+i,h=this.width+r,u=this.height+n;Dr[0].copyFromFloats(s,a),Dr[1].copyFromFloats(s+h,a),Dr[2].copyFromFloats(s+h,a+u),Dr[3].copyFromFloats(s,a+u),Lr.copyFromFloats(Number.MAX_VALUE,Number.MAX_VALUE),Fr.copyFromFloats(0,0);for(var l=0;l<4;l++)e.transformCoordinates(Dr[l].x,Dr[l].y,wr[l]),Lr.x=Math.floor(Math.min(Lr.x,wr[l].x)),Lr.y=Math.floor(Math.min(Lr.y,wr[l].y)),Fr.x=Math.ceil(Math.max(Fr.x,wr[l].x)),Fr.y=Math.ceil(Math.max(Fr.y,wr[l].y));o.left=Lr.x,o.top=Lr.y,o.width=Fr.x-Lr.x,o.height=Fr.y-Lr.y},e.prototype.transformToRef=function(e,t){this.addAndTransformToRef(e,0,0,0,0,t)},e.prototype.isEqualsTo=function(e){return this.left===e.left&&(this.top===e.top&&(this.width===e.width&&this.height===e.height))},e.Empty=function(){return new e(0,0,0,0)},e}(),Br=function(e){function i(t,i){void 0===i&&(i=0);var r=e.call(this,t.x,t.y)||this;return r.buttonIndex=i,r}return t(i,e),i}(d),kr=function(){function e(e,t,i,r,n,o){this.m=new Float32Array(6),this.fromValues(e,t,i,r,n,o)}return e.prototype.fromValues=function(e,t,i,r,n,o){return this.m[0]=e,this.m[1]=t,this.m[2]=i,this.m[3]=r,this.m[4]=n,this.m[5]=o,this},e.prototype.determinant=function(){return this.m[0]*this.m[3]-this.m[1]*this.m[2]},e.prototype.invertToRef=function(e){var t=this.m[0],i=this.m[1],r=this.m[2],n=this.m[3],o=this.m[4],s=this.m[5],a=this.determinant();if(a<1e-6)return e.m[0]=0,e.m[1]=0,e.m[2]=0,e.m[3]=0,e.m[4]=0,e.m[5]=0,this;var h=1/a,u=r*s-n*o,l=i*o-t*s;return e.m[0]=n*h,e.m[1]=-i*h,e.m[2]=-r*h,e.m[3]=t*h,e.m[4]=u*h,e.m[5]=l*h,this},e.prototype.multiplyToRef=function(e,t){var i=this.m[0],r=this.m[1],n=this.m[2],o=this.m[3],s=this.m[4],a=this.m[5],h=e.m[0],u=e.m[1],l=e.m[2],c=e.m[3],f=e.m[4],d=e.m[5];return t.m[0]=i*h+r*l,t.m[1]=i*u+r*c,t.m[2]=n*h+o*l,t.m[3]=n*u+o*c,t.m[4]=s*h+a*l+f,t.m[5]=s*u+a*c+d,this},e.prototype.transformCoordinates=function(e,t,i){return i.x=e*this.m[0]+t*this.m[2]+this.m[4],i.y=e*this.m[1]+t*this.m[3]+this.m[5],this},e.Identity=function(){return new e(1,0,0,1,0,0)},e.TranslationToRef=function(e,t,i){i.fromValues(1,0,0,1,e,t)},e.ScalingToRef=function(e,t,i){i.fromValues(e,0,0,t,0,0)},e.RotationToRef=function(e,t){var i=Math.sin(e),r=Math.cos(e);t.fromValues(r,i,-i,r,0,0)},e.ComposeToRef=function(t,i,r,n,o,s,a){e.TranslationToRef(t,i,e._TempPreTranslationMatrix),e.ScalingToRef(n,o,e._TempScalingMatrix),e.RotationToRef(r,e._TempRotationMatrix),e.TranslationToRef(-t,-i,e._TempPostTranslationMatrix),e._TempPreTranslationMatrix.multiplyToRef(e._TempScalingMatrix,e._TempCompose0),e._TempCompose0.multiplyToRef(e._TempRotationMatrix,e._TempCompose1),s?(e._TempCompose1.multiplyToRef(e._TempPostTranslationMatrix,e._TempCompose2),e._TempCompose2.multiplyToRef(s,a)):e._TempCompose1.multiplyToRef(e._TempPostTranslationMatrix,a)},e._TempPreTranslationMatrix=e.Identity(),e._TempPostTranslationMatrix=e.Identity(),e._TempRotationMatrix=e.Identity(),e._TempScalingMatrix=e.Identity(),e._TempCompose0=e.Identity(),e._TempCompose1=e.Identity(),e._TempCompose2=e.Identity(),e}(),Ur=function(){function e(t){this.name=t,this._alpha=1,this._alphaSet=!1,this._zIndex=0,this._currentMeasure=Nr.Empty(),this._fontFamily="Arial",this._fontStyle="",this._fontWeight="",this._fontSize=new Rr(18,Rr.UNITMODE_PIXEL,!1),this._width=new Rr(1,Rr.UNITMODE_PERCENTAGE,!1),this._height=new Rr(1,Rr.UNITMODE_PERCENTAGE,!1),this._color="",this._style=null,this._horizontalAlignment=e.HORIZONTAL_ALIGNMENT_CENTER,this._verticalAlignment=e.VERTICAL_ALIGNMENT_CENTER,this._isDirty=!0,this._wasDirty=!1,this._tempParentMeasure=Nr.Empty(),this._prevCurrentMeasureTransformedIntoGlobalSpace=Nr.Empty(),this._cachedParentMeasure=Nr.Empty(),this._paddingLeft=new Rr(0),this._paddingRight=new Rr(0),this._paddingTop=new Rr(0),this._paddingBottom=new Rr(0),this._left=new Rr(0),this._top=new Rr(0),this._scaleX=1,this._scaleY=1,this._rotation=0,this._transformCenterX=.5,this._transformCenterY=.5,this._transformMatrix=kr.Identity(),this._invertTransformMatrix=kr.Identity(),this._transformedPosition=d.Zero(),this._isMatrixDirty=!0,this._isVisible=!0,this._isHighlighted=!1,this._fontSet=!1,this._dummyVector2=d.Zero(),this._downCount=0,this._enterCount=-1,this._doNotRender=!1,this._downPointerIds={},this._isEnabled=!0,this._disabledColor="#9a9a9a",this._disabledColorItem="#6a6a6a",this._rebuildLayout=!1,this._customData={},this._isClipped=!1,this._automaticSize=!1,this.metadata=null,this.isHitTestVisible=!0,this.isPointerBlocker=!1,this.isFocusInvisible=!1,this.clipChildren=!0,this.clipContent=!0,this.useBitmapCache=!1,this._shadowOffsetX=0,this._shadowOffsetY=0,this._shadowBlur=0,this._shadowColor="black",this.hoverCursor="",this._linkOffsetX=new Rr(0),this._linkOffsetY=new Rr(0),this.onWheelObservable=new U,this.onPointerMoveObservable=new U,this.onPointerOutObservable=new U,this.onPointerDownObservable=new U,this.onPointerUpObservable=new U,this.onPointerClickObservable=new U,this.onPointerEnterObservable=new U,this.onDirtyObservable=new U,this.onBeforeDrawObservable=new U,this.onAfterDrawObservable=new U,this.onDisposeObservable=new U,this.fixedRatio=0,this._fixedRatioMasterIsWidth=!0,this._tmpMeasureA=new Nr(0,0,0,0)}return Object.defineProperty(e.prototype,"shadowOffsetX",{get:function(){return this._shadowOffsetX},set:function(e){this._shadowOffsetX!==e&&(this._shadowOffsetX=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shadowOffsetY",{get:function(){return this._shadowOffsetY},set:function(e){this._shadowOffsetY!==e&&(this._shadowOffsetY=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shadowBlur",{get:function(){return this._shadowBlur},set:function(e){this._shadowBlur!==e&&(this._shadowBlur=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shadowColor",{get:function(){return this._shadowColor},set:function(e){this._shadowColor!==e&&(this._shadowColor=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"typeName",{get:function(){return this._getTypeName()},enumerable:!1,configurable:!0}),e.prototype.getClassName=function(){return this._getTypeName()},Object.defineProperty(e.prototype,"host",{get:function(){return this._host},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fontOffset",{get:function(){return this._fontOffset},set:function(e){this._fontOffset=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"alpha",{get:function(){return this._alpha},set:function(e){this._alpha!==e&&(this._alphaSet=!0,this._alpha=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isHighlighted",{get:function(){return this._isHighlighted},set:function(e){this._isHighlighted!==e&&(this._isHighlighted=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scaleX",{get:function(){return this._scaleX},set:function(e){this._scaleX!==e&&(this._scaleX=e,this._markAsDirty(),this._markMatrixAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scaleY",{get:function(){return this._scaleY},set:function(e){this._scaleY!==e&&(this._scaleY=e,this._markAsDirty(),this._markMatrixAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rotation",{get:function(){return this._rotation},set:function(e){this._rotation!==e&&(this._rotation=e,this._markAsDirty(),this._markMatrixAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transformCenterY",{get:function(){return this._transformCenterY},set:function(e){this._transformCenterY!==e&&(this._transformCenterY=e,this._markAsDirty(),this._markMatrixAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transformCenterX",{get:function(){return this._transformCenterX},set:function(e){this._transformCenterX!==e&&(this._transformCenterX=e,this._markAsDirty(),this._markMatrixAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"horizontalAlignment",{get:function(){return this._horizontalAlignment},set:function(e){this._horizontalAlignment!==e&&(this._horizontalAlignment=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"verticalAlignment",{get:function(){return this._verticalAlignment},set:function(e){this._verticalAlignment!==e&&(this._verticalAlignment=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this._width.toString(this._host)},set:function(e){this._fixedRatioMasterIsWidth=!0,this._width.toString(this._host)!==e&&this._width.fromString(e)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"widthInPixels",{get:function(){return this._width.getValueInPixel(this._host,this._cachedParentMeasure.width)},set:function(e){isNaN(e)||(this._fixedRatioMasterIsWidth=!0,this.width=e+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height.toString(this._host)},set:function(e){this._fixedRatioMasterIsWidth=!1,this._height.toString(this._host)!==e&&this._height.fromString(e)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"heightInPixels",{get:function(){return this._height.getValueInPixel(this._host,this._cachedParentMeasure.height)},set:function(e){isNaN(e)||(this._fixedRatioMasterIsWidth=!1,this.height=e+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fontFamily",{get:function(){return this._fontSet?this._fontFamily:""},set:function(e){this._fontFamily!==e&&(this._fontFamily=e,this._resetFontCache())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fontStyle",{get:function(){return this._fontStyle},set:function(e){this._fontStyle!==e&&(this._fontStyle=e,this._resetFontCache())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fontWeight",{get:function(){return this._fontWeight},set:function(e){this._fontWeight!==e&&(this._fontWeight=e,this._resetFontCache())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"style",{get:function(){return this._style},set:function(e){var t=this;this._style&&(this._style.onChangedObservable.remove(this._styleObserver),this._styleObserver=null),this._style=e,this._style&&(this._styleObserver=this._style.onChangedObservable.add((function(){t._markAsDirty(),t._resetFontCache()}))),this._markAsDirty(),this._resetFontCache()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_isFontSizeInPercentage",{get:function(){return this._fontSize.isPercentage},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fontSizeInPixels",{get:function(){var e=this._style?this._style._fontSize:this._fontSize;return e.isPixel?e.getValue(this._host):e.getValueInPixel(this._host,this._tempParentMeasure.height||this._cachedParentMeasure.height)},set:function(e){isNaN(e)||(this.fontSize=e+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fontSize",{get:function(){return this._fontSize.toString(this._host)},set:function(e){this._fontSize.toString(this._host)!==e&&this._fontSize.fromString(e)&&(this._markAsDirty(),this._resetFontCache())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"color",{get:function(){return this._color},set:function(e){this._color!==e&&(this._color=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"zIndex",{get:function(){return this._zIndex},set:function(e){this.zIndex!==e&&(this._zIndex=e,this.parent&&this.parent._reOrderControl(this))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"notRenderable",{get:function(){return this._doNotRender},set:function(e){this._doNotRender!==e&&(this._doNotRender=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isVisible",{get:function(){return this._isVisible},set:function(e){this._isVisible!==e&&(this._isVisible=e,this._markAsDirty(!0))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isDirty",{get:function(){return this._isDirty},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"linkedMesh",{get:function(){return this._linkedMesh},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"paddingLeft",{get:function(){return this._paddingLeft.toString(this._host)},set:function(e){this._paddingLeft.fromString(e)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"paddingLeftInPixels",{get:function(){return this._paddingLeft.getValueInPixel(this._host,this._cachedParentMeasure.width)},set:function(e){isNaN(e)||(this.paddingLeft=e+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"paddingRight",{get:function(){return this._paddingRight.toString(this._host)},set:function(e){this._paddingRight.fromString(e)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"paddingRightInPixels",{get:function(){return this._paddingRight.getValueInPixel(this._host,this._cachedParentMeasure.width)},set:function(e){isNaN(e)||(this.paddingRight=e+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"paddingTop",{get:function(){return this._paddingTop.toString(this._host)},set:function(e){this._paddingTop.fromString(e)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"paddingTopInPixels",{get:function(){return this._paddingTop.getValueInPixel(this._host,this._cachedParentMeasure.height)},set:function(e){isNaN(e)||(this.paddingTop=e+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"paddingBottom",{get:function(){return this._paddingBottom.toString(this._host)},set:function(e){this._paddingBottom.fromString(e)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"paddingBottomInPixels",{get:function(){return this._paddingBottom.getValueInPixel(this._host,this._cachedParentMeasure.height)},set:function(e){isNaN(e)||(this.paddingBottom=e+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"left",{get:function(){return this._left.toString(this._host)},set:function(e){this._left.fromString(e)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftInPixels",{get:function(){return this._left.getValueInPixel(this._host,this._cachedParentMeasure.width)},set:function(e){isNaN(e)||(this.left=e+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"top",{get:function(){return this._top.toString(this._host)},set:function(e){this._top.fromString(e)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"topInPixels",{get:function(){return this._top.getValueInPixel(this._host,this._cachedParentMeasure.height)},set:function(e){isNaN(e)||(this.top=e+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"linkOffsetX",{get:function(){return this._linkOffsetX.toString(this._host)},set:function(e){this._linkOffsetX.fromString(e)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"linkOffsetXInPixels",{get:function(){return this._linkOffsetX.getValueInPixel(this._host,this._cachedParentMeasure.width)},set:function(e){isNaN(e)||(this.linkOffsetX=e+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"linkOffsetY",{get:function(){return this._linkOffsetY.toString(this._host)},set:function(e){this._linkOffsetY.fromString(e)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"linkOffsetYInPixels",{get:function(){return this._linkOffsetY.getValueInPixel(this._host,this._cachedParentMeasure.height)},set:function(e){isNaN(e)||(this.linkOffsetY=e+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"centerX",{get:function(){return this._currentMeasure.left+this._currentMeasure.width/2},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"centerY",{get:function(){return this._currentMeasure.top+this._currentMeasure.height/2},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled!==e&&(this._isEnabled=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"disabledColor",{get:function(){return this._disabledColor},set:function(e){this._disabledColor!==e&&(this._disabledColor=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"disabledColorItem",{get:function(){return this._disabledColorItem},set:function(e){this._disabledColorItem!==e&&(this._disabledColorItem=e,this._markAsDirty())},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"Control"},e.prototype.getAscendantOfClass=function(e){return this.parent?this.parent.getClassName()===e?this.parent:this.parent.getAscendantOfClass(e):null},e.prototype._resetFontCache=function(){this._fontSet=!0,this._markAsDirty()},e.prototype.isAscendant=function(e){return!!this.parent&&(this.parent===e||this.parent.isAscendant(e))},e.prototype.getLocalCoordinates=function(e){var t=d.Zero();return this.getLocalCoordinatesToRef(e,t),t},e.prototype.getLocalCoordinatesToRef=function(e,t){return t.x=e.x-this._currentMeasure.left,t.y=e.y-this._currentMeasure.top,this},e.prototype.getParentLocalCoordinates=function(e){var t=d.Zero();return t.x=e.x-this._cachedParentMeasure.left,t.y=e.y-this._cachedParentMeasure.top,t},e.prototype.moveToVector3=function(t,i){if(this._host&&this.parent===this._host._rootContainer){this.horizontalAlignment=e.HORIZONTAL_ALIGNMENT_LEFT,this.verticalAlignment=e.VERTICAL_ALIGNMENT_TOP;var r=this._host._getGlobalViewport(i),n=p.Project(t,m.Identity(),i.getTransformMatrix(),r);this._moveToProjectedPosition(n),n.z<0||n.z>1?this.notRenderable=!0:this.notRenderable=!1}else Ue.Error("Cannot move a control to a vector3 if the control is not at root level")},e.prototype.getDescendantsToRef=function(e,t,i){},e.prototype.getDescendants=function(e,t){var i=new Array;return this.getDescendantsToRef(i,e,t),i},e.prototype.linkWithMesh=function(t){if(!this._host||this.parent&&this.parent!==this._host._rootContainer)t&&Ue.Error("Cannot link a control to a mesh if the control is not at root level");else{var i=this._host._linkedControls.indexOf(this);if(-1!==i)return this._linkedMesh=t,void(t||this._host._linkedControls.splice(i,1));t&&(this.horizontalAlignment=e.HORIZONTAL_ALIGNMENT_LEFT,this.verticalAlignment=e.VERTICAL_ALIGNMENT_TOP,this._linkedMesh=t,this._host._linkedControls.push(this))}},e.prototype._moveToProjectedPosition=function(e){var t=this._left.getValue(this._host),i=this._top.getValue(this._host),r=e.x+this._linkOffsetX.getValue(this._host)-this._currentMeasure.width/2,n=e.y+this._linkOffsetY.getValue(this._host)-this._currentMeasure.height/2;this._left.ignoreAdaptiveScaling&&this._top.ignoreAdaptiveScaling&&(Math.abs(r-t)<.5&&(r=t),Math.abs(n-i)<.5&&(n=i)),this.left=r+"px",this.top=n+"px",this._left.ignoreAdaptiveScaling=!0,this._top.ignoreAdaptiveScaling=!0,this._markAsDirty()},e.prototype._offsetLeft=function(e){this._isDirty=!0,this._currentMeasure.left+=e},e.prototype._offsetTop=function(e){this._isDirty=!0,this._currentMeasure.top+=e},e.prototype._markMatrixAsDirty=function(){this._isMatrixDirty=!0,this._flagDescendantsAsMatrixDirty()},e.prototype._flagDescendantsAsMatrixDirty=function(){},e.prototype._intersectsRect=function(e){return this._currentMeasure.transformToRef(this._transformMatrix,this._tmpMeasureA),!(this._tmpMeasureA.left>=e.left+e.width)&&(!(this._tmpMeasureA.top>=e.top+e.height)&&(!(this._tmpMeasureA.left+this._tmpMeasureA.width<=e.left)&&!(this._tmpMeasureA.top+this._tmpMeasureA.height<=e.top)))},e.prototype.invalidateRect=function(){if(this._transform(),this.host&&this.host.useInvalidateRectOptimization)if(this._currentMeasure.transformToRef(this._transformMatrix,this._tmpMeasureA),Nr.CombineToRef(this._tmpMeasureA,this._prevCurrentMeasureTransformedIntoGlobalSpace,this._tmpMeasureA),this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY){var e=this.shadowOffsetX,t=this.shadowOffsetY,i=this.shadowBlur,r=Math.min(Math.min(e,0)-2*i,0),n=Math.max(Math.max(e,0)+2*i,0),o=Math.min(Math.min(t,0)-2*i,0),s=Math.max(Math.max(t,0)+2*i,0);this.host.invalidateRect(Math.floor(this._tmpMeasureA.left+r),Math.floor(this._tmpMeasureA.top+o),Math.ceil(this._tmpMeasureA.left+this._tmpMeasureA.width+n),Math.ceil(this._tmpMeasureA.top+this._tmpMeasureA.height+s))}else this.host.invalidateRect(Math.floor(this._tmpMeasureA.left),Math.floor(this._tmpMeasureA.top),Math.ceil(this._tmpMeasureA.left+this._tmpMeasureA.width),Math.ceil(this._tmpMeasureA.top+this._tmpMeasureA.height))},e.prototype._markAsDirty=function(e){void 0===e&&(e=!1),(this._isVisible||e)&&(this._isDirty=!0,this._host&&this._host.markAsDirty())},e.prototype._markAllAsDirty=function(){this._markAsDirty(),this._font&&this._prepareFont()},e.prototype._link=function(e){this._host=e,this._host&&(this.uniqueId=this._host.getScene().getUniqueId())},e.prototype._transform=function(e){if(this._isMatrixDirty||1!==this._scaleX||1!==this._scaleY||0!==this._rotation){var t=this._currentMeasure.width*this._transformCenterX+this._currentMeasure.left,i=this._currentMeasure.height*this._transformCenterY+this._currentMeasure.top;e&&(e.translate(t,i),e.rotate(this._rotation),e.scale(this._scaleX,this._scaleY),e.translate(-t,-i)),(this._isMatrixDirty||this._cachedOffsetX!==t||this._cachedOffsetY!==i)&&(this._cachedOffsetX=t,this._cachedOffsetY=i,this._isMatrixDirty=!1,this._flagDescendantsAsMatrixDirty(),kr.ComposeToRef(-t,-i,this._rotation,this._scaleX,this._scaleY,this.parent?this.parent._transformMatrix:null,this._transformMatrix),this._transformMatrix.invertToRef(this._invertTransformMatrix))}},e.prototype._renderHighlight=function(e){this.isHighlighted&&(e.save(),e.strokeStyle="#4affff",e.lineWidth=2,this._renderHighlightSpecific(e),e.restore())},e.prototype._renderHighlightSpecific=function(e){e.strokeRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)},e.prototype._applyStates=function(t){this._isFontSizeInPercentage&&(this._fontSet=!0),this._fontSet&&(this._prepareFont(),this._fontSet=!1),this._font&&(t.font=this._font),this._color&&(t.fillStyle=this._color),e.AllowAlphaInheritance?t.globalAlpha*=this._alpha:this._alphaSet&&(t.globalAlpha=this.parent?this.parent.alpha*this._alpha:this._alpha)},e.prototype._layout=function(e,t){if(!this.isDirty&&(!this.isVisible||this.notRenderable))return!1;if(this._isDirty||!this._cachedParentMeasure.isEqualsTo(e)){this.host._numLayoutCalls++,this._currentMeasure.addAndTransformToRef(this._transformMatrix,0|-this.paddingLeftInPixels,0|-this.paddingTopInPixels,0|this.paddingRightInPixels,0|this.paddingBottomInPixels,this._prevCurrentMeasureTransformedIntoGlobalSpace),t.save(),this._applyStates(t);var i=0;do{this._rebuildLayout=!1,this._processMeasures(e,t),i++}while(this._rebuildLayout&&i<3);i>=3&&q.Error("Layout cycle detected in GUI (Control name="+this.name+", uniqueId="+this.uniqueId+")"),t.restore(),this.invalidateRect(),this._evaluateClippingState(e)}return this._wasDirty=this._isDirty,this._isDirty=!1,!0},e.prototype._processMeasures=function(e,t){this._currentMeasure.copyFrom(e),this._preMeasure(e,t),this._measure(),this._computeAlignment(e,t),this._currentMeasure.left=0|this._currentMeasure.left,this._currentMeasure.top=0|this._currentMeasure.top,this._currentMeasure.width=0|this._currentMeasure.width,this._currentMeasure.height=0|this._currentMeasure.height,this._additionalProcessing(e,t),this._cachedParentMeasure.copyFrom(e),this.onDirtyObservable.hasObservers()&&this.onDirtyObservable.notifyObservers(this)},e.prototype._evaluateClippingState=function(e){if(this.parent&&this.parent.clipChildren){if(this._currentMeasure.left>e.left+e.width)return void(this._isClipped=!0);if(this._currentMeasure.left+this._currentMeasure.width<e.left)return void(this._isClipped=!0);if(this._currentMeasure.top>e.top+e.height)return void(this._isClipped=!0);if(this._currentMeasure.top+this._currentMeasure.height<e.top)return void(this._isClipped=!0)}this._isClipped=!1},e.prototype._measure=function(){this._width.isPixel?this._currentMeasure.width=this._width.getValue(this._host):this._currentMeasure.width*=this._width.getValue(this._host),this._height.isPixel?this._currentMeasure.height=this._height.getValue(this._host):this._currentMeasure.height*=this._height.getValue(this._host),0!==this.fixedRatio&&(this._fixedRatioMasterIsWidth?this._currentMeasure.height=this._currentMeasure.width*this.fixedRatio:this._currentMeasure.width=this._currentMeasure.height*this.fixedRatio)},e.prototype._computeAlignment=function(t,i){var r=this._currentMeasure.width,n=this._currentMeasure.height,o=t.width,s=t.height,a=0,h=0;switch(this.horizontalAlignment){case e.HORIZONTAL_ALIGNMENT_LEFT:a=0;break;case e.HORIZONTAL_ALIGNMENT_RIGHT:a=o-r;break;case e.HORIZONTAL_ALIGNMENT_CENTER:a=(o-r)/2}switch(this.verticalAlignment){case e.VERTICAL_ALIGNMENT_TOP:h=0;break;case e.VERTICAL_ALIGNMENT_BOTTOM:h=s-n;break;case e.VERTICAL_ALIGNMENT_CENTER:h=(s-n)/2}this._paddingLeft.isPixel?(this._currentMeasure.left+=this._paddingLeft.getValue(this._host),this._currentMeasure.width-=this._paddingLeft.getValue(this._host)):(this._currentMeasure.left+=o*this._paddingLeft.getValue(this._host),this._currentMeasure.width-=o*this._paddingLeft.getValue(this._host)),this._paddingRight.isPixel?this._currentMeasure.width-=this._paddingRight.getValue(this._host):this._currentMeasure.width-=o*this._paddingRight.getValue(this._host),this._paddingTop.isPixel?(this._currentMeasure.top+=this._paddingTop.getValue(this._host),this._currentMeasure.height-=this._paddingTop.getValue(this._host)):(this._currentMeasure.top+=s*this._paddingTop.getValue(this._host),this._currentMeasure.height-=s*this._paddingTop.getValue(this._host)),this._paddingBottom.isPixel?this._currentMeasure.height-=this._paddingBottom.getValue(this._host):this._currentMeasure.height-=s*this._paddingBottom.getValue(this._host),this._left.isPixel?this._currentMeasure.left+=this._left.getValue(this._host):this._currentMeasure.left+=o*this._left.getValue(this._host),this._top.isPixel?this._currentMeasure.top+=this._top.getValue(this._host):this._currentMeasure.top+=s*this._top.getValue(this._host),this._currentMeasure.left+=a,this._currentMeasure.top+=h},e.prototype._preMeasure=function(e,t){},e.prototype._additionalProcessing=function(e,t){},e.prototype._clipForChildren=function(e){},e.prototype._clip=function(t,i){if(t.beginPath(),e._ClipMeasure.copyFrom(this._currentMeasure),i){i.transformToRef(this._invertTransformMatrix,this._tmpMeasureA);var r=new Nr(0,0,0,0);r.left=Math.max(this._tmpMeasureA.left,this._currentMeasure.left),r.top=Math.max(this._tmpMeasureA.top,this._currentMeasure.top),r.width=Math.min(this._tmpMeasureA.left+this._tmpMeasureA.width,this._currentMeasure.left+this._currentMeasure.width)-r.left,r.height=Math.min(this._tmpMeasureA.top+this._tmpMeasureA.height,this._currentMeasure.top+this._currentMeasure.height)-r.top,e._ClipMeasure.copyFrom(r)}if(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY){var n=this.shadowOffsetX,o=this.shadowOffsetY,s=this.shadowBlur,a=Math.min(Math.min(n,0)-2*s,0),h=Math.max(Math.max(n,0)+2*s,0),u=Math.min(Math.min(o,0)-2*s,0),l=Math.max(Math.max(o,0)+2*s,0);t.rect(e._ClipMeasure.left+a,e._ClipMeasure.top+u,e._ClipMeasure.width+h-a,e._ClipMeasure.height+l-u)}else t.rect(e._ClipMeasure.left,e._ClipMeasure.top,e._ClipMeasure.width,e._ClipMeasure.height);t.clip()},e.prototype._render=function(e,t){return!this.isVisible||this.notRenderable||this._isClipped?(this._isDirty=!1,!1):(this.host._numRenderCalls++,e.save(),this._applyStates(e),this._transform(e),this.clipContent&&this._clip(e,t),this.onBeforeDrawObservable.hasObservers()&&this.onBeforeDrawObservable.notifyObservers(this),this.useBitmapCache&&!this._wasDirty&&this._cacheData?e.putImageData(this._cacheData,this._currentMeasure.left,this._currentMeasure.top):this._draw(e,t),this.useBitmapCache&&this._wasDirty&&(this._cacheData=e.getImageData(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)),this._renderHighlight(e),this.onAfterDrawObservable.hasObservers()&&this.onAfterDrawObservable.notifyObservers(this),e.restore(),!0)},e.prototype._draw=function(e,t){},e.prototype.contains=function(e,t){return this._invertTransformMatrix.transformCoordinates(e,t,this._transformedPosition),e=this._transformedPosition.x,t=this._transformedPosition.y,!(e<this._currentMeasure.left)&&(!(e>this._currentMeasure.left+this._currentMeasure.width)&&(!(t<this._currentMeasure.top)&&(!(t>this._currentMeasure.top+this._currentMeasure.height)&&(this.isPointerBlocker&&(this._host._shouldBlockPointer=!0),!0))))},e.prototype._processPicking=function(e,t,i,r,n,o,s,a){return!!this._isEnabled&&(!(!this.isHitTestVisible||!this.isVisible||this._doNotRender)&&(!!this.contains(e,t)&&(this._processObservables(r,e,t,i,n,o,s,a),!0)))},e.prototype._onPointerMove=function(e,t,i,r){this.onPointerMoveObservable.notifyObservers(t,-1,e,this,r)&&null!=this.parent&&this.parent._onPointerMove(e,t,i,r)},e.prototype._onPointerEnter=function(e,t){return!!this._isEnabled&&(!(this._enterCount>0)&&(-1===this._enterCount&&(this._enterCount=0),this._enterCount++,this.onPointerEnterObservable.notifyObservers(this,-1,e,this,t)&&null!=this.parent&&this.parent._onPointerEnter(e,t),!0))},e.prototype._onPointerOut=function(e,t,i){if(void 0===i&&(i=!1),i||this._isEnabled&&e!==this){this._enterCount=0;var r=!0;e.isAscendant(this)||(r=this.onPointerOutObservable.notifyObservers(this,-1,e,this,t)),r&&null!=this.parent&&this.parent._onPointerOut(e,t,i)}},e.prototype._onPointerDown=function(e,t,i,r,n){return this._onPointerEnter(this,n),0===this._downCount&&(this._downCount++,this._downPointerIds[i]=!0,this.onPointerDownObservable.notifyObservers(new Br(t,r),-1,e,this,n)&&null!=this.parent&&this.parent._onPointerDown(e,t,i,r,n),!0)},e.prototype._onPointerUp=function(e,t,i,r,n,o){if(this._isEnabled){this._downCount=0,delete this._downPointerIds[i];var s=n;n&&(this._enterCount>0||-1===this._enterCount)&&(s=this.onPointerClickObservable.notifyObservers(new Br(t,r),-1,e,this,o)),this.onPointerUpObservable.notifyObservers(new Br(t,r),-1,e,this,o)&&null!=this.parent&&this.parent._onPointerUp(e,t,i,r,s,o)}},e.prototype._forcePointerUp=function(e){if(void 0===e&&(e=null),null!==e)this._onPointerUp(this,d.Zero(),e,0,!0);else for(var t in this._downPointerIds)this._onPointerUp(this,d.Zero(),+t,0,!0)},e.prototype._onWheelScroll=function(e,t){this._isEnabled&&(this.onWheelObservable.notifyObservers(new d(e,t))&&null!=this.parent&&this.parent._onWheelScroll(e,t))},e.prototype._onCanvasBlur=function(){},e.prototype._processObservables=function(e,t,i,r,n,o,s,a){if(!this._isEnabled)return!1;if(this._dummyVector2.copyFromFloats(t,i),e===Jt.POINTERMOVE){this._onPointerMove(this,this._dummyVector2,n,r);var h=this._host._lastControlOver[n];return h&&h!==this&&h._onPointerOut(this,r),h!==this&&this._onPointerEnter(this,r),this._host._lastControlOver[n]=this,!0}return e===Jt.POINTERDOWN?(this._onPointerDown(this,this._dummyVector2,n,o,r),this._host._registerLastControlDown(this,n),this._host._lastPickedControl=this,!0):e===Jt.POINTERUP?(this._host._lastControlDown[n]&&this._host._lastControlDown[n]._onPointerUp(this,this._dummyVector2,n,o,!0,r),delete this._host._lastControlDown[n],!0):!(e!==Jt.POINTERWHEEL||!this._host._lastControlOver[n])&&(this._host._lastControlOver[n]._onWheelScroll(s,a),!0)},e.prototype._prepareFont=function(){(this._font||this._fontSet)&&(this._style?this._font=this._style.fontStyle+" "+this._style.fontWeight+" "+this.fontSizeInPixels+"px "+this._style.fontFamily:this._font=this._fontStyle+" "+this._fontWeight+" "+this.fontSizeInPixels+"px "+this._fontFamily,this._fontOffset=e._GetFontOffset(this._font))},e.prototype.dispose=function(){(this.onDirtyObservable.clear(),this.onBeforeDrawObservable.clear(),this.onAfterDrawObservable.clear(),this.onPointerDownObservable.clear(),this.onPointerEnterObservable.clear(),this.onPointerMoveObservable.clear(),this.onPointerOutObservable.clear(),this.onPointerUpObservable.clear(),this.onPointerClickObservable.clear(),this.onWheelObservable.clear(),this._styleObserver&&this._style&&(this._style.onChangedObservable.remove(this._styleObserver),this._styleObserver=null),this.parent&&(this.parent.removeControl(this),this.parent=null),this._host)&&(this._host._linkedControls.indexOf(this)>-1&&this.linkWithMesh(null));this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},Object.defineProperty(e,"HORIZONTAL_ALIGNMENT_LEFT",{get:function(){return e._HORIZONTAL_ALIGNMENT_LEFT},enumerable:!1,configurable:!0}),Object.defineProperty(e,"HORIZONTAL_ALIGNMENT_RIGHT",{get:function(){return e._HORIZONTAL_ALIGNMENT_RIGHT},enumerable:!1,configurable:!0}),Object.defineProperty(e,"HORIZONTAL_ALIGNMENT_CENTER",{get:function(){return e._HORIZONTAL_ALIGNMENT_CENTER},enumerable:!1,configurable:!0}),Object.defineProperty(e,"VERTICAL_ALIGNMENT_TOP",{get:function(){return e._VERTICAL_ALIGNMENT_TOP},enumerable:!1,configurable:!0}),Object.defineProperty(e,"VERTICAL_ALIGNMENT_BOTTOM",{get:function(){return e._VERTICAL_ALIGNMENT_BOTTOM},enumerable:!1,configurable:!0}),Object.defineProperty(e,"VERTICAL_ALIGNMENT_CENTER",{get:function(){return e._VERTICAL_ALIGNMENT_CENTER},enumerable:!1,configurable:!0}),e._GetFontOffset=function(t){if(e._FontHeightSizes[t])return e._FontHeightSizes[t];var i=document.createElement("span");i.innerHTML="Hg",i.style.font=t;var r=document.createElement("div");r.style.display="inline-block",r.style.width="1px",r.style.height="0px",r.style.verticalAlign="bottom";var n=document.createElement("div");n.style.whiteSpace="nowrap",n.appendChild(i),n.appendChild(r),document.body.appendChild(n);var o=0,s=0;try{s=r.getBoundingClientRect().top-i.getBoundingClientRect().top,r.style.verticalAlign="baseline",o=r.getBoundingClientRect().top-i.getBoundingClientRect().top}finally{document.body.removeChild(n)}var a={ascent:o,height:s,descent:s-o};return e._FontHeightSizes[t]=a,a},e.drawEllipse=function(e,t,i,r,n){n.translate(e,t),n.scale(i,r),n.beginPath(),n.arc(0,0,1,0,2*Math.PI),n.closePath(),n.scale(1/i,1/r),n.translate(-e,-t)},e.AllowAlphaInheritance=!1,e._ClipMeasure=new Nr(0,0,0,0),e._HORIZONTAL_ALIGNMENT_LEFT=0,e._HORIZONTAL_ALIGNMENT_RIGHT=1,e._HORIZONTAL_ALIGNMENT_CENTER=2,e._VERTICAL_ALIGNMENT_TOP=0,e._VERTICAL_ALIGNMENT_BOTTOM=1,e._VERTICAL_ALIGNMENT_CENTER=2,e._FontHeightSizes={},e.AddHeader=function(){},e}();c.RegisteredTypes["BABYLON.GUI.Control"]=Ur;var Vr=function(e){function i(t){var i=e.call(this,t)||this;return i.name=t,i._children=new Array,i._measureForChildren=Nr.Empty(),i._background="",i._adaptWidthToChildren=!1,i._adaptHeightToChildren=!1,i.logLayoutCycleErrors=!1,i.maxLayoutCycle=3,i}return t(i,e),Object.defineProperty(i.prototype,"adaptHeightToChildren",{get:function(){return this._adaptHeightToChildren},set:function(e){this._adaptHeightToChildren!==e&&(this._adaptHeightToChildren=e,e&&(this.height="100%"),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"adaptWidthToChildren",{get:function(){return this._adaptWidthToChildren},set:function(e){this._adaptWidthToChildren!==e&&(this._adaptWidthToChildren=e,e&&(this.width="100%"),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"background",{get:function(){return this._background},set:function(e){this._background!==e&&(this._background=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"children",{get:function(){return this._children},enumerable:!1,configurable:!0}),i.prototype._getTypeName=function(){return"Container"},i.prototype._flagDescendantsAsMatrixDirty=function(){for(var e=0,t=this.children;e<t.length;e++){t[e]._markMatrixAsDirty()}},i.prototype.getChildByName=function(e){for(var t=0,i=this.children;t<i.length;t++){var r=i[t];if(r.name===e)return r}return null},i.prototype.getChildByType=function(e,t){for(var i=0,r=this.children;i<r.length;i++){var n=r[i];if(n.typeName===t)return n}return null},i.prototype.containsControl=function(e){return-1!==this.children.indexOf(e)},i.prototype.addControl=function(e){return e?(-1!==this._children.indexOf(e)||(e._link(this._host),e._markAllAsDirty(),this._reOrderControl(e),this._markAsDirty()),this):this},i.prototype.clearControls=function(){for(var e=0,t=this.children.slice();e<t.length;e++){var i=t[e];this.removeControl(i)}return this},i.prototype.removeControl=function(e){var t=this._children.indexOf(e);return-1!==t&&(this._children.splice(t,1),e.parent=null),e.linkWithMesh(null),this._host&&this._host._cleanControlAfterRemoval(e),this._markAsDirty(),this},i.prototype._reOrderControl=function(e){this.removeControl(e);for(var t=!1,i=0;i<this._children.length;i++)if(this._children[i].zIndex>e.zIndex){this._children.splice(i,0,e),t=!0;break}t||this._children.push(e),e.parent=this,this._markAsDirty()},i.prototype._offsetLeft=function(t){e.prototype._offsetLeft.call(this,t);for(var i=0,r=this._children;i<r.length;i++){r[i]._offsetLeft(t)}},i.prototype._offsetTop=function(t){e.prototype._offsetTop.call(this,t);for(var i=0,r=this._children;i<r.length;i++){r[i]._offsetTop(t)}},i.prototype._markAllAsDirty=function(){e.prototype._markAllAsDirty.call(this);for(var t=0;t<this._children.length;t++)this._children[t]._markAllAsDirty()},i.prototype._localDraw=function(e){this._background&&(e.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY),e.fillStyle=this._background,e.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height),e.restore())},i.prototype._link=function(t){e.prototype._link.call(this,t);for(var i=0,r=this._children;i<r.length;i++){r[i]._link(t)}},i.prototype._beforeLayout=function(){},i.prototype._processMeasures=function(t,i){!this._isDirty&&this._cachedParentMeasure.isEqualsTo(t)||(e.prototype._processMeasures.call(this,t,i),this._evaluateClippingState(t))},i.prototype._layout=function(e,t){if(!this.isDirty&&(!this.isVisible||this.notRenderable))return!1;this.host._numLayoutCalls++,this._isDirty&&this._currentMeasure.transformToRef(this._transformMatrix,this._prevCurrentMeasureTransformedIntoGlobalSpace);var i=0;t.save(),this._applyStates(t),this._beforeLayout();do{var r=-1,n=-1;if(this._rebuildLayout=!1,this._processMeasures(e,t),!this._isClipped){for(var o=0,s=this._children;o<s.length;o++){var a=s[o];a._tempParentMeasure.copyFrom(this._measureForChildren),a._layout(this._measureForChildren,t)&&(this.adaptWidthToChildren&&a._width.isPixel&&(r=Math.max(r,a._currentMeasure.width+a.paddingLeftInPixels+a.paddingRightInPixels)),this.adaptHeightToChildren&&a._height.isPixel&&(n=Math.max(n,a._currentMeasure.height+a.paddingTopInPixels+a.paddingBottomInPixels)))}this.adaptWidthToChildren&&r>=0&&(r+=this.paddingLeftInPixels+this.paddingRightInPixels,this.width!==r+"px"&&(this.width=r+"px",this._rebuildLayout=!0)),this.adaptHeightToChildren&&n>=0&&(n+=this.paddingTopInPixels+this.paddingBottomInPixels,this.height!==n+"px"&&(this.height=n+"px",this._rebuildLayout=!0)),this._postMeasure()}i++}while(this._rebuildLayout&&i<this.maxLayoutCycle);return i>=3&&this.logLayoutCycleErrors&&q.Error("Layout cycle detected in GUI (Container name="+this.name+", uniqueId="+this.uniqueId+")"),t.restore(),this._isDirty&&(this.invalidateRect(),this._isDirty=!1),!0},i.prototype._postMeasure=function(){},i.prototype._draw=function(e,t){this._localDraw(e),this.clipChildren&&this._clipForChildren(e);for(var i=0,r=this._children;i<r.length;i++){var n=r[i];t&&!n._intersectsRect(t)||n._render(e,t)}},i.prototype.getDescendantsToRef=function(e,t,i){if(void 0===t&&(t=!1),this.children)for(var r=0;r<this.children.length;r++){var n=this.children[r];i&&!i(n)||e.push(n),t||n.getDescendantsToRef(e,!1,i)}},i.prototype._processPicking=function(t,i,r,n,o,s,a,h){if(!this._isEnabled||!this.isVisible||this.notRenderable)return!1;if(!e.prototype.contains.call(this,t,i))return!1;for(var u=this._children.length-1;u>=0;u--){var l=this._children[u];if(l._processPicking(t,i,r,n,o,s,a,h))return l.hoverCursor&&this._host._changeCursor(l.hoverCursor),!0}return!!this.isHitTestVisible&&this._processObservables(n,t,i,r,o,s,a,h)},i.prototype._additionalProcessing=function(t,i){e.prototype._additionalProcessing.call(this,t,i),this._measureForChildren.copyFrom(this._currentMeasure)},i.prototype.dispose=function(){e.prototype.dispose.call(this);for(var t=this.children.length-1;t>=0;t--)this.children[t].dispose()},i}(Ur);c.RegisteredTypes["BABYLON.GUI.Container"]=Vr;var Wr,zr=function(e){function i(t){var i=e.call(this,t)||this;return i.name=t,i._thickness=1,i._cornerRadius=0,i}return t(i,e),Object.defineProperty(i.prototype,"thickness",{get:function(){return this._thickness},set:function(e){this._thickness!==e&&(this._thickness=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"cornerRadius",{get:function(){return this._cornerRadius},set:function(e){e<0&&(e=0),this._cornerRadius!==e&&(this._cornerRadius=e,this._markAsDirty())},enumerable:!1,configurable:!0}),i.prototype._getTypeName=function(){return"Rectangle"},i.prototype._localDraw=function(e){e.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY),this._background&&(e.fillStyle=this._background,this._cornerRadius?(this._drawRoundedRect(e,this._thickness/2),e.fill()):e.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)),this._thickness&&((this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0),this.color&&(e.strokeStyle=this.color),e.lineWidth=this._thickness,this._cornerRadius?(this._drawRoundedRect(e,this._thickness/2),e.stroke()):e.strokeRect(this._currentMeasure.left+this._thickness/2,this._currentMeasure.top+this._thickness/2,this._currentMeasure.width-this._thickness,this._currentMeasure.height-this._thickness)),e.restore()},i.prototype._additionalProcessing=function(t,i){e.prototype._additionalProcessing.call(this,t,i),this._measureForChildren.width-=2*this._thickness,this._measureForChildren.height-=2*this._thickness,this._measureForChildren.left+=this._thickness,this._measureForChildren.top+=this._thickness},i.prototype._drawRoundedRect=function(e,t){void 0===t&&(t=0);var i=this._currentMeasure.left+t,r=this._currentMeasure.top+t,n=this._currentMeasure.width-2*t,o=this._currentMeasure.height-2*t,s=Math.min(o/2-2,Math.min(n/2-2,this._cornerRadius));e.beginPath(),e.moveTo(i+s,r),e.lineTo(i+n-s,r),e.quadraticCurveTo(i+n,r,i+n,r+s),e.lineTo(i+n,r+o-s),e.quadraticCurveTo(i+n,r+o,i+n-s,r+o),e.lineTo(i+s,r+o),e.quadraticCurveTo(i,r+o,i,r+o-s),e.lineTo(i,r+s),e.quadraticCurveTo(i,r,i+s,r),e.closePath()},i.prototype._clipForChildren=function(e){this._cornerRadius&&(this._drawRoundedRect(e,this._thickness),e.clip())},i}(Vr);c.RegisteredTypes["BABYLON.GUI.Rectangle"]=zr,function(e){e[e.Clip=0]="Clip",e[e.WordWrap=1]="WordWrap",e[e.Ellipsis=2]="Ellipsis"}(Wr||(Wr={}));var Gr=function(e){function i(t,i){void 0===i&&(i="");var r=e.call(this,t)||this;return r.name=t,r._text="",r._textWrapping=Wr.Clip,r._textHorizontalAlignment=Ur.HORIZONTAL_ALIGNMENT_CENTER,r._textVerticalAlignment=Ur.VERTICAL_ALIGNMENT_CENTER,r._resizeToFit=!1,r._lineSpacing=new Rr(0),r._outlineWidth=0,r._outlineColor="white",r._underline=!1,r._lineThrough=!1,r.onTextChangedObservable=new U,r.onLinesReadyObservable=new U,r.text=i,r}return t(i,e),Object.defineProperty(i.prototype,"lines",{get:function(){return this._lines},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"resizeToFit",{get:function(){return this._resizeToFit},set:function(e){this._resizeToFit!==e&&(this._resizeToFit=e,this._resizeToFit&&(this._width.ignoreAdaptiveScaling=!0,this._height.ignoreAdaptiveScaling=!0),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"textWrapping",{get:function(){return this._textWrapping},set:function(e){this._textWrapping!==e&&(this._textWrapping=+e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"text",{get:function(){return this._text},set:function(e){this._text!==e&&(this._text=e,this._markAsDirty(),this.onTextChangedObservable.notifyObservers(this))},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"textHorizontalAlignment",{get:function(){return this._textHorizontalAlignment},set:function(e){this._textHorizontalAlignment!==e&&(this._textHorizontalAlignment=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"textVerticalAlignment",{get:function(){return this._textVerticalAlignment},set:function(e){this._textVerticalAlignment!==e&&(this._textVerticalAlignment=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"lineSpacing",{get:function(){return this._lineSpacing.toString(this._host)},set:function(e){this._lineSpacing.fromString(e)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"outlineWidth",{get:function(){return this._outlineWidth},set:function(e){this._outlineWidth!==e&&(this._outlineWidth=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"underline",{get:function(){return this._underline},set:function(e){this._underline!==e&&(this._underline=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"lineThrough",{get:function(){return this._lineThrough},set:function(e){this._lineThrough!==e&&(this._lineThrough=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"outlineColor",{get:function(){return this._outlineColor},set:function(e){this._outlineColor!==e&&(this._outlineColor=e,this._markAsDirty())},enumerable:!1,configurable:!0}),i.prototype._getTypeName=function(){return"TextBlock"},i.prototype._processMeasures=function(t,i){this._fontOffset||(this._fontOffset=Ur._GetFontOffset(i.font)),e.prototype._processMeasures.call(this,t,i),this._lines=this._breakLines(this._currentMeasure.width,i),this.onLinesReadyObservable.notifyObservers(this);for(var r=0,n=0;n<this._lines.length;n++){var o=this._lines[n];o.width>r&&(r=o.width)}if(this._resizeToFit){if(this._textWrapping===Wr.Clip){var s=this.paddingLeftInPixels+this.paddingRightInPixels+r|0;s!==this._width.internalValue&&(this._width.updateInPlace(s,Rr.UNITMODE_PIXEL),this._rebuildLayout=!0)}var a=this.paddingTopInPixels+this.paddingBottomInPixels+this._fontOffset.height*this._lines.length|0;if(this._lines.length>0&&0!==this._lineSpacing.internalValue){var h=0;h=this._lineSpacing.isPixel?this._lineSpacing.getValue(this._host):this._lineSpacing.getValue(this._host)*this._height.getValueInPixel(this._host,this._cachedParentMeasure.height),a+=(this._lines.length-1)*h}a!==this._height.internalValue&&(this._height.updateInPlace(a,Rr.UNITMODE_PIXEL),this._rebuildLayout=!0)}},i.prototype._drawText=function(e,t,i,r){var n=this._currentMeasure.width,o=0;switch(this._textHorizontalAlignment){case Ur.HORIZONTAL_ALIGNMENT_LEFT:o=0;break;case Ur.HORIZONTAL_ALIGNMENT_RIGHT:o=n-t;break;case Ur.HORIZONTAL_ALIGNMENT_CENTER:o=(n-t)/2}(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(r.shadowColor=this.shadowColor,r.shadowBlur=this.shadowBlur,r.shadowOffsetX=this.shadowOffsetX,r.shadowOffsetY=this.shadowOffsetY),this.outlineWidth&&r.strokeText(e,this._currentMeasure.left+o,i),r.fillText(e,this._currentMeasure.left+o,i),this._underline&&(r.beginPath(),r.lineWidth=Math.round(.05*this.fontSizeInPixels),r.moveTo(this._currentMeasure.left+o,i+3),r.lineTo(this._currentMeasure.left+o+t,i+3),r.stroke(),r.closePath()),this._lineThrough&&(r.beginPath(),r.lineWidth=Math.round(.05*this.fontSizeInPixels),r.moveTo(this._currentMeasure.left+o,i-this.fontSizeInPixels/3),r.lineTo(this._currentMeasure.left+o+t,i-this.fontSizeInPixels/3),r.stroke(),r.closePath())},i.prototype._draw=function(e,t){e.save(),this._applyStates(e),this._renderLines(e),e.restore()},i.prototype._applyStates=function(t){e.prototype._applyStates.call(this,t),this.outlineWidth&&(t.lineWidth=this.outlineWidth,t.strokeStyle=this.outlineColor,t.lineJoin="miter",t.miterLimit=2)},i.prototype._breakLines=function(e,t){var i=[],r=this.text.split("\n");if(this._textWrapping===Wr.Ellipsis)for(var n=0,o=r;n<o.length;n++){var s=o[n];i.push(this._parseLineEllipsis(s,e,t))}else if(this._textWrapping===Wr.WordWrap)for(var a=0,h=r;a<h.length;a++){s=h[a];i.push.apply(i,this._parseLineWordWrap(s,e,t))}else for(var u=0,l=r;u<l.length;u++){s=l[u];i.push(this._parseLine(s,t))}return i},i.prototype._parseLine=function(e,t){return void 0===e&&(e=""),{text:e,width:t.measureText(e).width}},i.prototype._parseLineEllipsis=function(e,t,i){void 0===e&&(e="");var r=i.measureText(e).width;r>t&&(e+="…");var n=Array.from&&Array.from(e);if(n)for(;n.length&&r>t;)n.pop(),e=n.join("")+"...",r=i.measureText(e).width;else for(;e.length>2&&r>t;)e=e.slice(0,-2)+"…",r=i.measureText(e).width;return{text:e,width:r}},i.prototype._parseLineWordWrap=function(e,t,i){void 0===e&&(e="");for(var r=[],n=this.wordSplittingFunction?this.wordSplittingFunction(e):e.split(" "),o=0,s=0;s<n.length;s++){var a=s>0?e+" "+n[s]:n[0],h=i.measureText(a).width;h>t&&s>0?(r.push({text:e,width:o}),e=n[s],o=i.measureText(e).width):(o=h,e=a)}return r.push({text:e,width:o}),r},i.prototype._renderLines=function(e){var t=this._currentMeasure.height,i=0;switch(this._textVerticalAlignment){case Ur.VERTICAL_ALIGNMENT_TOP:i=this._fontOffset.ascent;break;case Ur.VERTICAL_ALIGNMENT_BOTTOM:i=t-this._fontOffset.height*(this._lines.length-1)-this._fontOffset.descent;break;case Ur.VERTICAL_ALIGNMENT_CENTER:i=this._fontOffset.ascent+(t-this._fontOffset.height*this._lines.length)/2}i+=this._currentMeasure.top;for(var r=0;r<this._lines.length;r++){var n=this._lines[r];0!==r&&0!==this._lineSpacing.internalValue&&(this._lineSpacing.isPixel?i+=this._lineSpacing.getValue(this._host):i+=this._lineSpacing.getValue(this._host)*this._height.getValueInPixel(this._host,this._cachedParentMeasure.height)),this._drawText(n.text,n.width,i,e),i+=this._fontOffset.height}},i.prototype.computeExpectedHeight=function(){if(this.text&&this.widthInPixels){var e=document.createElement("canvas").getContext("2d");if(e){this._applyStates(e),this._fontOffset||(this._fontOffset=Ur._GetFontOffset(e.font));var t=this._lines?this._lines:this._breakLines(this.widthInPixels-this.paddingLeftInPixels-this.paddingRightInPixels,e),i=this.paddingTopInPixels+this.paddingBottomInPixels+this._fontOffset.height*t.length;if(t.length>0&&0!==this._lineSpacing.internalValue){var r=0;r=this._lineSpacing.isPixel?this._lineSpacing.getValue(this._host):this._lineSpacing.getValue(this._host)*this._height.getValueInPixel(this._host,this._cachedParentMeasure.height),i+=(t.length-1)*r}return i}}return 0},i.prototype.dispose=function(){e.prototype.dispose.call(this),this.onTextChangedObservable.clear()},i}(Ur);c.RegisteredTypes["BABYLON.GUI.TextBlock"]=Gr;var Hr=function(e){function i(t,r){void 0===r&&(r=null);var n=e.call(this,t)||this;return n.name=t,n._workingCanvas=null,n._loaded=!1,n._stretch=i.STRETCH_FILL,n._autoScale=!1,n._sourceLeft=0,n._sourceTop=0,n._sourceWidth=0,n._sourceHeight=0,n._svgAttributesComputationCompleted=!1,n._isSVG=!1,n._cellWidth=0,n._cellHeight=0,n._cellId=-1,n._populateNinePatchSlicesFromImage=!1,n._imageDataCache={data:null,key:""},n.onImageLoadedObservable=new U,n.onSVGAttributesComputedObservable=new U,n.source=r,n}return t(i,e),Object.defineProperty(i.prototype,"isLoaded",{get:function(){return this._loaded},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"populateNinePatchSlicesFromImage",{get:function(){return this._populateNinePatchSlicesFromImage},set:function(e){this._populateNinePatchSlicesFromImage!==e&&(this._populateNinePatchSlicesFromImage=e,this._populateNinePatchSlicesFromImage&&this._loaded&&this._extractNinePatchSliceDataFromImage())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"detectPointerOnOpaqueOnly",{get:function(){return this._detectPointerOnOpaqueOnly},set:function(e){this._detectPointerOnOpaqueOnly!==e&&(this._detectPointerOnOpaqueOnly=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"sliceLeft",{get:function(){return this._sliceLeft},set:function(e){this._sliceLeft!==e&&(this._sliceLeft=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"sliceRight",{get:function(){return this._sliceRight},set:function(e){this._sliceRight!==e&&(this._sliceRight=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"sliceTop",{get:function(){return this._sliceTop},set:function(e){this._sliceTop!==e&&(this._sliceTop=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"sliceBottom",{get:function(){return this._sliceBottom},set:function(e){this._sliceBottom!==e&&(this._sliceBottom=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"sourceLeft",{get:function(){return this._sourceLeft},set:function(e){this._sourceLeft!==e&&(this._sourceLeft=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"sourceTop",{get:function(){return this._sourceTop},set:function(e){this._sourceTop!==e&&(this._sourceTop=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"sourceWidth",{get:function(){return this._sourceWidth},set:function(e){this._sourceWidth!==e&&(this._sourceWidth=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"sourceHeight",{get:function(){return this._sourceHeight},set:function(e){this._sourceHeight!==e&&(this._sourceHeight=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"isSVG",{get:function(){return this._isSVG},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"svgAttributesComputationCompleted",{get:function(){return this._svgAttributesComputationCompleted},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"autoScale",{get:function(){return this._autoScale},set:function(e){this._autoScale!==e&&(this._autoScale=e,e&&this._loaded&&this.synchronizeSizeWithContent())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"stretch",{get:function(){return this._stretch},set:function(e){this._stretch!==e&&(this._stretch=e,this._markAsDirty())},enumerable:!1,configurable:!0}),i.prototype._rotate90=function(e,t){void 0===t&&(t=!1);var r=document.createElement("canvas"),n=r.getContext("2d"),o=this._domImage.width,s=this._domImage.height;r.width=s,r.height=o,n.translate(r.width/2,r.height/2),n.rotate(e*Math.PI/2),n.drawImage(this._domImage,0,0,o,s,-o/2,-s/2,o,s);var a=r.toDataURL("image/jpg"),h=new i(this.name+"rotated",a);return t&&(h._stretch=this._stretch,h._autoScale=this._autoScale,h._cellId=this._cellId,h._cellWidth=e%1?this._cellHeight:this._cellWidth,h._cellHeight=e%1?this._cellWidth:this._cellHeight),this._handleRotationForSVGImage(this,h,e),this._imageDataCache.data=null,h},i.prototype._handleRotationForSVGImage=function(e,t,i){var r=this;e._isSVG&&(e._svgAttributesComputationCompleted?(this._rotate90SourceProperties(e,t,i),this._markAsDirty()):e.onSVGAttributesComputedObservable.addOnce((function(){r._rotate90SourceProperties(e,t,i),r._markAsDirty()})))},i.prototype._rotate90SourceProperties=function(e,t,i){var r,n,o=e.sourceLeft,s=e.sourceTop,a=e.domImage.width,h=e.domImage.height,u=o,l=s,c=e.sourceWidth,f=e.sourceHeight;if(0!=i){var d=i<0?-1:1;i%=4;for(var p=0;p<Math.abs(i);++p)u=-(s-h/2)*d+h/2,l=(o-a/2)*d+a/2,c=(r=[f,c])[0],f=r[1],i<0?l-=f:u-=c,o=u,s=l,a=(n=[h,a])[0],h=n[1]}t.sourceLeft=u,t.sourceTop=l,t.sourceWidth=c,t.sourceHeight=f},Object.defineProperty(i.prototype,"domImage",{get:function(){return this._domImage},set:function(e){var t=this;this._domImage=e,this._loaded=!1,this._imageDataCache.data=null,this._domImage.width?this._onImageLoaded():this._domImage.onload=function(){t._onImageLoaded()}},enumerable:!1,configurable:!0}),i.prototype._onImageLoaded=function(){this._imageDataCache.data=null,this._imageWidth=this._domImage.width,this._imageHeight=this._domImage.height,this._loaded=!0,this._populateNinePatchSlicesFromImage&&this._extractNinePatchSliceDataFromImage(),this._autoScale&&this.synchronizeSizeWithContent(),this.onImageLoadedObservable.notifyObservers(this),this._markAsDirty()},i.prototype._extractNinePatchSliceDataFromImage=function(){this._workingCanvas||(this._workingCanvas=document.createElement("canvas"));var e=this._workingCanvas,t=e.getContext("2d"),i=this._domImage.width,r=this._domImage.height;e.width=i,e.height=r,t.drawImage(this._domImage,0,0,i,r);var n=t.getImageData(0,0,i,r);this._sliceLeft=-1,this._sliceRight=-1;for(var o=0;o<i;o++){if((a=n.data[4*o+3])>127&&-1===this._sliceLeft)this._sliceLeft=o;else if(a<127&&this._sliceLeft>-1){this._sliceRight=o;break}}this._sliceTop=-1,this._sliceBottom=-1;for(var s=0;s<r;s++){var a;if((a=n.data[s*i*4+3])>127&&-1===this._sliceTop)this._sliceTop=s;else if(a<127&&this._sliceTop>-1){this._sliceBottom=s;break}}},Object.defineProperty(i.prototype,"source",{set:function(e){var t=this;this._source!==e&&(this._loaded=!1,this._source=e,this._imageDataCache.data=null,e&&(e=this._svgCheck(e)),this._domImage=document.createElement("img"),this._domImage.onload=function(){t._onImageLoaded()},e&&(Ue.SetCorsBehavior(e,this._domImage),this._domImage.src=e))},enumerable:!1,configurable:!0}),i.prototype._svgCheck=function(e){var t=this;if(window.SVGSVGElement&&-1!==e.search(/.svg#/gi)&&e.indexOf("#")===e.lastIndexOf("#")){this._isSVG=!0;var i=e.split("#")[0],r=e.split("#")[1],n=document.body.querySelector('object[data="'+i+'"]');if(n){var o=n.contentDocument;if(o&&o.documentElement){var s=o.documentElement.getAttribute("viewBox"),a=Number(o.documentElement.getAttribute("width")),h=Number(o.documentElement.getAttribute("height"));if(o.getElementById(r)&&s&&a&&h)return this._getSVGAttribs(n,r),e}n.addEventListener("load",(function(){t._getSVGAttribs(n,r)}))}else{var u=document.createElement("object");u.data=i,u.type="image/svg+xml",u.width="0%",u.height="0%",document.body.appendChild(u),u.onload=function(){var e=document.body.querySelector('object[data="'+i+'"]');e&&t._getSVGAttribs(e,r)}}return i}return e},i.prototype._getSVGAttribs=function(e,t){var i=e.contentDocument;if(i&&i.documentElement){var r=i.documentElement.getAttribute("viewBox"),n=Number(i.documentElement.getAttribute("width")),o=Number(i.documentElement.getAttribute("height")),s=i.getElementById(t);if(r&&n&&o&&s){var a=Number(r.split(" ")[2]),h=Number(r.split(" ")[3]),u=s.getBBox(),l=1,c=1,f=0,d=0;s.transform&&s.transform.baseVal.consolidate()&&(l=s.transform.baseVal.consolidate().matrix.a,c=s.transform.baseVal.consolidate().matrix.d,f=s.transform.baseVal.consolidate().matrix.e,d=s.transform.baseVal.consolidate().matrix.f),this.sourceLeft=(l*u.x+f)*n/a,this.sourceTop=(c*u.y+d)*o/h,this.sourceWidth=u.width*l*(n/a),this.sourceHeight=u.height*c*(o/h),this._svgAttributesComputationCompleted=!0,this.onSVGAttributesComputedObservable.notifyObservers(this)}}},Object.defineProperty(i.prototype,"cellWidth",{get:function(){return this._cellWidth},set:function(e){this._cellWidth!==e&&(this._cellWidth=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"cellHeight",{get:function(){return this._cellHeight},set:function(e){this._cellHeight!==e&&(this._cellHeight=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"cellId",{get:function(){return this._cellId},set:function(e){this._cellId!==e&&(this._cellId=e,this._markAsDirty())},enumerable:!1,configurable:!0}),i.prototype.contains=function(t,i){if(!e.prototype.contains.call(this,t,i))return!1;if(!this._detectPointerOnOpaqueOnly||!this._workingCanvas)return!0;var r=0|this._currentMeasure.width,n=0|this._currentMeasure.height,o=r+"_"+n,s=this._imageDataCache.data;if(!s||this._imageDataCache.key!==o){var a=this._workingCanvas.getContext("2d");this._imageDataCache.data=s=a.getImageData(0,0,r,n).data,this._imageDataCache.key=o}return s[4*((t=t-this._currentMeasure.left|0)+(i=i-this._currentMeasure.top|0)*r)+3]>0},i.prototype._getTypeName=function(){return"Image"},i.prototype.synchronizeSizeWithContent=function(){this._loaded&&(this.width=this._domImage.width+"px",this.height=this._domImage.height+"px")},i.prototype._processMeasures=function(t,r){if(this._loaded)switch(this._stretch){case i.STRETCH_NONE:case i.STRETCH_FILL:case i.STRETCH_UNIFORM:case i.STRETCH_NINE_PATCH:break;case i.STRETCH_EXTEND:this._autoScale&&this.synchronizeSizeWithContent(),this.parent&&this.parent.parent&&(this.parent.adaptWidthToChildren=!0,this.parent.adaptHeightToChildren=!0)}e.prototype._processMeasures.call(this,t,r)},i.prototype._prepareWorkingCanvasForOpaqueDetection=function(){if(this._detectPointerOnOpaqueOnly){this._workingCanvas||(this._workingCanvas=document.createElement("canvas"));var e=this._workingCanvas,t=this._currentMeasure.width,i=this._currentMeasure.height,r=e.getContext("2d");e.width=t,e.height=i,r.clearRect(0,0,t,i)}},i.prototype._drawImage=function(e,t,i,r,n,o,s,a,h){(e.drawImage(this._domImage,t,i,r,n,o,s,a,h),this._detectPointerOnOpaqueOnly)&&(e=this._workingCanvas.getContext("2d")).drawImage(this._domImage,t,i,r,n,o-this._currentMeasure.left,s-this._currentMeasure.top,a,h)},i.prototype._draw=function(e){var t,r,n,o;if(e.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY),-1==this.cellId)t=this._sourceLeft,r=this._sourceTop,n=this._sourceWidth?this._sourceWidth:this._imageWidth,o=this._sourceHeight?this._sourceHeight:this._imageHeight;else{var s=this._domImage.naturalWidth/this.cellWidth,a=this.cellId/s>>0,h=this.cellId%s;t=this.cellWidth*h,r=this.cellHeight*a,n=this.cellWidth,o=this.cellHeight}if(this._prepareWorkingCanvasForOpaqueDetection(),this._applyStates(e),this._loaded)switch(this._stretch){case i.STRETCH_NONE:case i.STRETCH_FILL:this._drawImage(e,t,r,n,o,this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height);break;case i.STRETCH_UNIFORM:var u=this._currentMeasure.width/n,l=this._currentMeasure.height/o,c=Math.min(u,l),f=(this._currentMeasure.width-n*c)/2,d=(this._currentMeasure.height-o*c)/2;this._drawImage(e,t,r,n,o,this._currentMeasure.left+f,this._currentMeasure.top+d,n*c,o*c);break;case i.STRETCH_EXTEND:this._drawImage(e,t,r,n,o,this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height);break;case i.STRETCH_NINE_PATCH:this._renderNinePatch(e)}e.restore()},i.prototype._renderCornerPatch=function(e,t,i,r,n,o,s){this._drawImage(e,t,i,r,n,this._currentMeasure.left+o,this._currentMeasure.top+s,r,n)},i.prototype._renderNinePatch=function(e){var t=this._imageHeight,i=this._sliceLeft,r=this._sliceTop,n=this._imageHeight-this._sliceBottom,o=this._imageWidth-this._sliceRight,s=0,a=0;this._populateNinePatchSlicesFromImage&&(s=1,a=1,t-=2,i-=1,r-=1,n-=1,o-=1);var h=this._sliceRight-this._sliceLeft,u=this._currentMeasure.width-o-this.sliceLeft,l=this._currentMeasure.height-t+this._sliceBottom;this._renderCornerPatch(e,s,a,i,r,0,0),this._renderCornerPatch(e,s,this._sliceBottom,i,t-this._sliceBottom,0,l),this._renderCornerPatch(e,this._sliceRight,a,o,r,this._currentMeasure.width-o,0),this._renderCornerPatch(e,this._sliceRight,this._sliceBottom,o,t-this._sliceBottom,this._currentMeasure.width-o,l),this._drawImage(e,this._sliceLeft,this._sliceTop,h,this._sliceBottom-this._sliceTop,this._currentMeasure.left+i,this._currentMeasure.top+r,u,l-r),this._drawImage(e,s,this._sliceTop,i,this._sliceBottom-this._sliceTop,this._currentMeasure.left,this._currentMeasure.top+r,i,l-r),this._drawImage(e,this._sliceRight,this._sliceTop,i,this._sliceBottom-this._sliceTop,this._currentMeasure.left+this._currentMeasure.width-o,this._currentMeasure.top+r,i,l-r),this._drawImage(e,this._sliceLeft,a,h,r,this._currentMeasure.left+i,this._currentMeasure.top,u,r),this._drawImage(e,this._sliceLeft,this._sliceBottom,h,n,this._currentMeasure.left+i,this._currentMeasure.top+l,u,n)},i.prototype.dispose=function(){e.prototype.dispose.call(this),this.onImageLoadedObservable.clear(),this.onSVGAttributesComputedObservable.clear()},i.STRETCH_NONE=0,i.STRETCH_FILL=1,i.STRETCH_UNIFORM=2,i.STRETCH_EXTEND=3,i.STRETCH_NINE_PATCH=4,i}(Ur);c.RegisteredTypes["BABYLON.GUI.Image"]=Hr;var Xr=function(e){function i(t){var i=e.call(this,t)||this;i.name=t,i.delegatePickingToChildren=!1,i.thickness=1,i.isPointerBlocker=!0;var r=null;return i.pointerEnterAnimation=function(){r=i.alpha,i.alpha-=.1},i.pointerOutAnimation=function(){null!==r&&(i.alpha=r)},i.pointerDownAnimation=function(){i.scaleX-=.05,i.scaleY-=.05},i.pointerUpAnimation=function(){i.scaleX+=.05,i.scaleY+=.05},i}return t(i,e),Object.defineProperty(i.prototype,"image",{get:function(){return this._image},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"textBlock",{get:function(){return this._textBlock},enumerable:!1,configurable:!0}),i.prototype._getTypeName=function(){return"Button"},i.prototype._processPicking=function(t,i,r,n,o,s,a,h){if(!this._isEnabled||!this.isHitTestVisible||!this.isVisible||this.notRenderable)return!1;if(!e.prototype.contains.call(this,t,i))return!1;if(this.delegatePickingToChildren){for(var u=!1,l=this._children.length-1;l>=0;l--){var c=this._children[l];if(c.isEnabled&&c.isHitTestVisible&&c.isVisible&&!c.notRenderable&&c.contains(t,i)){u=!0;break}}if(!u)return!1}return this._processObservables(n,t,i,r,o,s,a,h),!0},i.prototype._onPointerEnter=function(t,i){return!!e.prototype._onPointerEnter.call(this,t,i)&&(this.pointerEnterAnimation&&this.pointerEnterAnimation(),!0)},i.prototype._onPointerOut=function(t,i,r){void 0===r&&(r=!1),this.pointerOutAnimation&&this.pointerOutAnimation(),e.prototype._onPointerOut.call(this,t,i,r)},i.prototype._onPointerDown=function(t,i,r,n,o){return!!e.prototype._onPointerDown.call(this,t,i,r,n,o)&&(this.pointerDownAnimation&&this.pointerDownAnimation(),!0)},i.prototype._onPointerUp=function(t,i,r,n,o,s){this.pointerUpAnimation&&this.pointerUpAnimation(),e.prototype._onPointerUp.call(this,t,i,r,n,o,s)},i.CreateImageButton=function(e,t,r){var n=new i(e),o=new Gr(e+"_button",t);o.textWrapping=!0,o.textHorizontalAlignment=Ur.HORIZONTAL_ALIGNMENT_CENTER,o.paddingLeft="20%",n.addControl(o);var s=new Hr(e+"_icon",r);return s.width="20%",s.stretch=Hr.STRETCH_UNIFORM,s.horizontalAlignment=Ur.HORIZONTAL_ALIGNMENT_LEFT,n.addControl(s),n._image=s,n._textBlock=o,n},i.CreateImageOnlyButton=function(e,t){var r=new i(e),n=new Hr(e+"_icon",t);return n.stretch=Hr.STRETCH_FILL,n.horizontalAlignment=Ur.HORIZONTAL_ALIGNMENT_LEFT,r.addControl(n),r._image=n,r},i.CreateSimpleButton=function(e,t){var r=new i(e),n=new Gr(e+"_button",t);return n.textWrapping=!0,n.textHorizontalAlignment=Ur.HORIZONTAL_ALIGNMENT_CENTER,r.addControl(n),r._textBlock=n,r},i.CreateImageWithCenterTextButton=function(e,t,r){var n=new i(e),o=new Hr(e+"_icon",r);o.stretch=Hr.STRETCH_FILL,n.addControl(o);var s=new Gr(e+"_button",t);return s.textWrapping=!0,s.textHorizontalAlignment=Ur.HORIZONTAL_ALIGNMENT_CENTER,n.addControl(s),n._image=o,n._textBlock=s,n},i}(zr);c.RegisteredTypes["BABYLON.GUI.Button"]=Xr;var jr=function(e){function i(t){var i=e.call(this,t)||this;return i.name=t,i._isVertical=!0,i._manualWidth=!1,i._manualHeight=!1,i._doNotTrackManualChanges=!1,i.ignoreLayoutWarnings=!1,i}return t(i,e),Object.defineProperty(i.prototype,"isVertical",{get:function(){return this._isVertical},set:function(e){this._isVertical!==e&&(this._isVertical=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"width",{get:function(){return this._width.toString(this._host)},set:function(e){this._doNotTrackManualChanges||(this._manualWidth=!0),this._width.toString(this._host)!==e&&this._width.fromString(e)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"height",{get:function(){return this._height.toString(this._host)},set:function(e){this._doNotTrackManualChanges||(this._manualHeight=!0),this._height.toString(this._host)!==e&&this._height.fromString(e)&&this._markAsDirty()},enumerable:!1,configurable:!0}),i.prototype._getTypeName=function(){return"StackPanel"},i.prototype._preMeasure=function(t,i){for(var r=0,n=this._children;r<n.length;r++){var o=n[r];this._isVertical?o.verticalAlignment=Ur.VERTICAL_ALIGNMENT_TOP:o.horizontalAlignment=Ur.HORIZONTAL_ALIGNMENT_LEFT}e.prototype._preMeasure.call(this,t,i)},i.prototype._additionalProcessing=function(t,i){e.prototype._additionalProcessing.call(this,t,i),this._measureForChildren.copyFrom(t),this._measureForChildren.left=this._currentMeasure.left,this._measureForChildren.top=this._currentMeasure.top,this.isVertical&&!this._manualWidth||(this._measureForChildren.width=this._currentMeasure.width),(this.isVertical||this._manualHeight)&&(this._measureForChildren.height=this._currentMeasure.height)},i.prototype._postMeasure=function(){for(var t=0,i=0,r=0,n=this._children;r<n.length;r++){var o=n[r];o.isVisible&&!o.notRenderable&&(this._isVertical?(o.top!==i+"px"&&(o.top=i+"px",this._rebuildLayout=!0,o._top.ignoreAdaptiveScaling=!0),o._height.isPercentage&&!o._automaticSize?this.ignoreLayoutWarnings||Ue.Warn("Control (Name:"+o.name+", UniqueId:"+o.uniqueId+") is using height in percentage mode inside a vertical StackPanel"):i+=o._currentMeasure.height+o.paddingTopInPixels+o.paddingBottomInPixels):(o.left!==t+"px"&&(o.left=t+"px",this._rebuildLayout=!0,o._left.ignoreAdaptiveScaling=!0),o._width.isPercentage&&!o._automaticSize?this.ignoreLayoutWarnings||Ue.Warn("Control (Name:"+o.name+", UniqueId:"+o.uniqueId+") is using width in percentage mode inside a horizontal StackPanel"):t+=o._currentMeasure.width+o.paddingLeftInPixels+o.paddingRightInPixels))}t+=this.paddingLeftInPixels+this.paddingRightInPixels,i+=this.paddingTopInPixels+this.paddingBottomInPixels,this._doNotTrackManualChanges=!0;var s=!1,a=!1;if(!this._manualHeight&&this._isVertical){var h=this.height;this.height=i+"px",a=h!==this.height||!this._height.ignoreAdaptiveScaling}if(!this._manualWidth&&!this._isVertical){var u=this.width;this.width=t+"px",s=u!==this.width||!this._width.ignoreAdaptiveScaling}a&&(this._height.ignoreAdaptiveScaling=!0),s&&(this._width.ignoreAdaptiveScaling=!0),this._doNotTrackManualChanges=!1,(s||a)&&(this._rebuildLayout=!0),e.prototype._postMeasure.call(this)},i}(Vr);c.RegisteredTypes["BABYLON.GUI.StackPanel"]=jr;var Kr=function(e){function i(t){var i=e.call(this,t)||this;return i.name=t,i._isChecked=!1,i._background="black",i._checkSizeRatio=.8,i._thickness=1,i.onIsCheckedChangedObservable=new U,i.isPointerBlocker=!0,i}return t(i,e),Object.defineProperty(i.prototype,"thickness",{get:function(){return this._thickness},set:function(e){this._thickness!==e&&(this._thickness=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"checkSizeRatio",{get:function(){return this._checkSizeRatio},set:function(e){e=Math.max(Math.min(1,e),0),this._checkSizeRatio!==e&&(this._checkSizeRatio=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"background",{get:function(){return this._background},set:function(e){this._background!==e&&(this._background=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"isChecked",{get:function(){return this._isChecked},set:function(e){this._isChecked!==e&&(this._isChecked=e,this._markAsDirty(),this.onIsCheckedChangedObservable.notifyObservers(e))},enumerable:!1,configurable:!0}),i.prototype._getTypeName=function(){return"Checkbox"},i.prototype._draw=function(e,t){e.save(),this._applyStates(e);var i=this._currentMeasure.width-this._thickness,r=this._currentMeasure.height-this._thickness;if((this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY),e.fillStyle=this._isEnabled?this._background:this._disabledColor,e.fillRect(this._currentMeasure.left+this._thickness/2,this._currentMeasure.top+this._thickness/2,i,r),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0),this._isChecked){e.fillStyle=this._isEnabled?this.color:this._disabledColorItem;var n=i*this._checkSizeRatio,o=r*this._checkSizeRatio;e.fillRect(this._currentMeasure.left+this._thickness/2+(i-n)/2,this._currentMeasure.top+this._thickness/2+(r-o)/2,n,o)}e.strokeStyle=this.color,e.lineWidth=this._thickness,e.strokeRect(this._currentMeasure.left+this._thickness/2,this._currentMeasure.top+this._thickness/2,i,r),e.restore()},i.prototype._onPointerDown=function(t,i,r,n,o){return!!e.prototype._onPointerDown.call(this,t,i,r,n,o)&&(this.isChecked=!this.isChecked,!0)},i.AddCheckBoxWithHeader=function(e,t){var r=new jr;r.isVertical=!1,r.height="30px";var n=new i;n.width="20px",n.height="20px",n.isChecked=!0,n.color="green",n.onIsCheckedChangedObservable.add(t),r.addControl(n);var o=new Gr;return o.text=e,o.width="180px",o.paddingLeft="5px",o.textHorizontalAlignment=Ur.HORIZONTAL_ALIGNMENT_LEFT,o.color="white",r.addControl(o),r},i}(Ur);c.RegisteredTypes["BABYLON.GUI.Checkbox"]=Kr;var Yr=function(){function e(){}return e.COPY=1,e.CUT=2,e.PASTE=3,e}(),qr=function(){function e(e,t){this.type=e,this.event=t}return e.GetTypeFromCharacter=function(e){switch(e){case 67:return Yr.COPY;case 86:return Yr.PASTE;case 88:return Yr.CUT;default:return-1}},e}(),Zr=function(){function e(){}return Object.defineProperty(e.prototype,"text",{get:function(){return this._characters?this._characters.join(""):this._text},set:function(e){this._text=e,this._characters=Array.from&&Array.from(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this._characters?this._characters.length:this._text.length},enumerable:!1,configurable:!0}),e.prototype.removePart=function(e,t,i){var r;if(this._text=this._text.slice(0,e)+(i||"")+this._text.slice(t),this._characters){var n=i?Array.from(i):[];(r=this._characters).splice.apply(r,function(){for(var e=0,t=0,i=arguments.length;t<i;t++)e+=arguments[t].length;var r=Array(e),n=0;for(t=0;t<i;t++)for(var o=arguments[t],s=0,a=o.length;s<a;s++,n++)r[n]=o[s];return r}([e,t-e],n))}},e.prototype.charAt=function(e){return this._characters?this._characters[e]:this._text.charAt(e)},e.prototype.substr=function(e,t){if(this._characters){e=isNaN(e)?0:e>=0?Math.min(e,this._characters.length):this._characters.length+Math.max(e,-this._characters.length),void 0===t?t=this._characters.length-e:(isNaN(t)||t<0)&&(t=0);for(var i=[];--t>=0;)i[t]=this._characters[e+t];return i.join("")}return this._text.substr(e,t)},e.prototype.substring=function(e,t){if(this._characters){isNaN(e)?e=0:e>this._characters.length?e=this._characters.length:e<0&&(e=0),void 0===t?t=this._characters.length:isNaN(t)?t=0:t>this._characters.length?t=this._characters.length:t<0&&(t=0);for(var i=[],r=0;e<t;)i[r++]=this._characters[e++];return i.join("")}return this._text.substring(e,t)},e.prototype.isWord=function(e){var t=/\w/g;return this._characters?-1!==this._characters[e].search(t):-1!==this._text.search(t)},e}(),Qr=function(e){function i(t,i){void 0===i&&(i="");var r=e.call(this,t)||this;return r.name=t,r._placeholderText="",r._background="#222222",r._focusedBackground="#000000",r._focusedColor="white",r._placeholderColor="gray",r._thickness=1,r._margin=new Rr(10,Rr.UNITMODE_PIXEL),r._autoStretchWidth=!0,r._maxWidth=new Rr(1,Rr.UNITMODE_PERCENTAGE,!1),r._isFocused=!1,r._blinkIsEven=!1,r._cursorOffset=0,r._deadKey=!1,r._addKey=!0,r._currentKey="",r._isTextHighlightOn=!1,r._textHighlightColor="#d5e0ff",r._highligherOpacity=.4,r._highlightedText="",r._startHighlightIndex=0,r._endHighlightIndex=0,r._cursorIndex=-1,r._onFocusSelectAll=!1,r._isPointerDown=!1,r.promptMessage="Please enter text:",r.disableMobilePrompt=!1,r.onTextChangedObservable=new U,r.onBeforeKeyAddObservable=new U,r.onFocusObservable=new U,r.onBlurObservable=new U,r.onTextHighlightObservable=new U,r.onTextCopyObservable=new U,r.onTextCutObservable=new U,r.onTextPasteObservable=new U,r.onKeyboardEventProcessedObservable=new U,r.text=i,r.isPointerBlocker=!0,r}return t(i,e),Object.defineProperty(i.prototype,"maxWidth",{get:function(){return this._maxWidth.toString(this._host)},set:function(e){this._maxWidth.toString(this._host)!==e&&this._maxWidth.fromString(e)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"maxWidthInPixels",{get:function(){return this._maxWidth.getValueInPixel(this._host,this._cachedParentMeasure.width)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"highligherOpacity",{get:function(){return this._highligherOpacity},set:function(e){this._highligherOpacity!==e&&(this._highligherOpacity=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"onFocusSelectAll",{get:function(){return this._onFocusSelectAll},set:function(e){this._onFocusSelectAll!==e&&(this._onFocusSelectAll=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"textHighlightColor",{get:function(){return this._textHighlightColor},set:function(e){this._textHighlightColor!==e&&(this._textHighlightColor=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"margin",{get:function(){return this._margin.toString(this._host)},set:function(e){this._margin.toString(this._host)!==e&&this._margin.fromString(e)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"marginInPixels",{get:function(){return this._margin.getValueInPixel(this._host,this._cachedParentMeasure.width)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"autoStretchWidth",{get:function(){return this._autoStretchWidth},set:function(e){this._autoStretchWidth!==e&&(this._autoStretchWidth=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"thickness",{get:function(){return this._thickness},set:function(e){this._thickness!==e&&(this._thickness=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"focusedBackground",{get:function(){return this._focusedBackground},set:function(e){this._focusedBackground!==e&&(this._focusedBackground=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"focusedColor",{get:function(){return this._focusedColor},set:function(e){this._focusedColor!==e&&(this._focusedColor=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"background",{get:function(){return this._background},set:function(e){this._background!==e&&(this._background=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"placeholderColor",{get:function(){return this._placeholderColor},set:function(e){this._placeholderColor!==e&&(this._placeholderColor=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"placeholderText",{get:function(){return this._placeholderText},set:function(e){this._placeholderText!==e&&(this._placeholderText=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"deadKey",{get:function(){return this._deadKey},set:function(e){this._deadKey=e},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"highlightedText",{get:function(){return this._highlightedText},set:function(e){this._highlightedText!==e&&(this._highlightedText=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"addKey",{get:function(){return this._addKey},set:function(e){this._addKey=e},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"currentKey",{get:function(){return this._currentKey},set:function(e){this._currentKey=e},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"text",{get:function(){return this._textWrapper.text},set:function(e){var t=e.toString();this._textWrapper||(this._textWrapper=new Zr),this._textWrapper.text!==t&&(this._textWrapper.text=t,this._textHasChanged())},enumerable:!1,configurable:!0}),i.prototype._textHasChanged=function(){this._markAsDirty(),this.onTextChangedObservable.notifyObservers(this)},Object.defineProperty(i.prototype,"width",{get:function(){return this._width.toString(this._host)},set:function(e){this._width.toString(this._host)!==e&&(this._width.fromString(e)&&this._markAsDirty(),this.autoStretchWidth=!1)},enumerable:!1,configurable:!0}),i.prototype.onBlur=function(){this._isFocused=!1,this._scrollLeft=null,this._cursorOffset=0,clearTimeout(this._blinkTimeout),this._markAsDirty(),this.onBlurObservable.notifyObservers(this),this._host.unRegisterClipboardEvents(),this._onClipboardObserver&&this._host.onClipboardObservable.remove(this._onClipboardObserver);var e=this._host.getScene();this._onPointerDblTapObserver&&e&&e.onPointerObservable.remove(this._onPointerDblTapObserver)},i.prototype.onFocus=function(){var e=this;if(this._isEnabled){if(this._scrollLeft=null,this._isFocused=!0,this._blinkIsEven=!1,this._cursorOffset=0,this._markAsDirty(),this.onFocusObservable.notifyObservers(this),-1!==navigator.userAgent.indexOf("Mobile")&&!this.disableMobilePrompt){var t=prompt(this.promptMessage);return null!==t&&(this.text=t),void(this._host.focusedControl=null)}this._host.registerClipboardEvents(),this._onClipboardObserver=this._host.onClipboardObservable.add((function(t){switch(t.type){case Yr.COPY:e._onCopyText(t.event),e.onTextCopyObservable.notifyObservers(e);break;case Yr.CUT:e._onCutText(t.event),e.onTextCutObservable.notifyObservers(e);break;case Yr.PASTE:e._onPasteText(t.event),e.onTextPasteObservable.notifyObservers(e);break;default:return}}));var i=this._host.getScene();i&&(this._onPointerDblTapObserver=i.onPointerObservable.add((function(t){e._isFocused&&t.type===Jt.POINTERDOUBLETAP&&e._processDblClick(t)}))),this._onFocusSelectAll&&this._selectAllText()}},i.prototype._getTypeName=function(){return"InputText"},i.prototype.keepsFocusWith=function(){return this._connectedVirtualKeyboard?[this._connectedVirtualKeyboard]:null},i.prototype.processKey=function(e,t,i){if(!i||!i.ctrlKey&&!i.metaKey||67!==e&&86!==e&&88!==e){if(i&&(i.ctrlKey||i.metaKey)&&65===e)return this._selectAllText(),void i.preventDefault();switch(e){case 32:t=" ";break;case 191:i&&i.preventDefault();break;case 8:if(this._textWrapper.text&&this._textWrapper.length>0){if(this._isTextHighlightOn)return this._textWrapper.removePart(this._startHighlightIndex,this._endHighlightIndex),this._textHasChanged(),this._isTextHighlightOn=!1,this._cursorOffset=this._textWrapper.length-this._startHighlightIndex,this._blinkIsEven=!1,void(i&&i.preventDefault());if(0===this._cursorOffset)this.text=this._textWrapper.substr(0,this._textWrapper.length-1);else(r=this._textWrapper.length-this._cursorOffset)>0&&(this._textWrapper.removePart(r-1,r),this._textHasChanged())}return void(i&&i.preventDefault());case 46:if(this._isTextHighlightOn)return this._textWrapper.removePart(this._startHighlightIndex,this._endHighlightIndex),this._textHasChanged(),this._isTextHighlightOn=!1,this._cursorOffset=this._textWrapper.length-this._startHighlightIndex,void(i&&i.preventDefault());if(this._textWrapper.text&&this._textWrapper.length>0&&this._cursorOffset>0){var r=this._textWrapper.length-this._cursorOffset;this._textWrapper.removePart(r,r+1),this._textHasChanged(),this._cursorOffset--}return void(i&&i.preventDefault());case 13:return this._host.focusedControl=null,void(this._isTextHighlightOn=!1);case 35:return this._cursorOffset=0,this._blinkIsEven=!1,this._isTextHighlightOn=!1,void this._markAsDirty();case 36:return this._cursorOffset=this._textWrapper.length,this._blinkIsEven=!1,this._isTextHighlightOn=!1,void this._markAsDirty();case 37:if(this._cursorOffset++,this._cursorOffset>this._textWrapper.length&&(this._cursorOffset=this._textWrapper.length),i&&i.shiftKey){if(this._blinkIsEven=!1,i.ctrlKey||i.metaKey){if(!this._isTextHighlightOn){if(this._textWrapper.length===this._cursorOffset)return;this._endHighlightIndex=this._textWrapper.length-this._cursorOffset+1}return this._startHighlightIndex=0,this._cursorIndex=this._textWrapper.length-this._endHighlightIndex,this._cursorOffset=this._textWrapper.length,this._isTextHighlightOn=!0,void this._markAsDirty()}return this._isTextHighlightOn?-1===this._cursorIndex&&(this._cursorIndex=this._textWrapper.length-this._endHighlightIndex,this._cursorOffset=0===this._startHighlightIndex?this._textWrapper.length:this._textWrapper.length-this._startHighlightIndex+1):(this._isTextHighlightOn=!0,this._cursorIndex=this._cursorOffset>=this._textWrapper.length?this._textWrapper.length:this._cursorOffset-1),this._cursorIndex<this._cursorOffset?(this._endHighlightIndex=this._textWrapper.length-this._cursorIndex,this._startHighlightIndex=this._textWrapper.length-this._cursorOffset):this._cursorIndex>this._cursorOffset?(this._endHighlightIndex=this._textWrapper.length-this._cursorOffset,this._startHighlightIndex=this._textWrapper.length-this._cursorIndex):this._isTextHighlightOn=!1,void this._markAsDirty()}return this._isTextHighlightOn&&(this._cursorOffset=this._textWrapper.length-this._startHighlightIndex,this._isTextHighlightOn=!1),i&&(i.ctrlKey||i.metaKey)&&(this._cursorOffset=this._textWrapper.length,i.preventDefault()),this._blinkIsEven=!1,this._isTextHighlightOn=!1,this._cursorIndex=-1,void this._markAsDirty();case 39:if(this._cursorOffset--,this._cursorOffset<0&&(this._cursorOffset=0),i&&i.shiftKey){if(this._blinkIsEven=!1,i.ctrlKey||i.metaKey){if(!this._isTextHighlightOn){if(0===this._cursorOffset)return;this._startHighlightIndex=this._textWrapper.length-this._cursorOffset-1}return this._endHighlightIndex=this._textWrapper.length,this._isTextHighlightOn=!0,this._cursorIndex=this._textWrapper.length-this._startHighlightIndex,this._cursorOffset=0,void this._markAsDirty()}return this._isTextHighlightOn?-1===this._cursorIndex&&(this._cursorIndex=this._textWrapper.length-this._startHighlightIndex,this._cursorOffset=this._textWrapper.length===this._endHighlightIndex?0:this._textWrapper.length-this._endHighlightIndex-1):(this._isTextHighlightOn=!0,this._cursorIndex=this._cursorOffset<=0?0:this._cursorOffset+1),this._cursorIndex<this._cursorOffset?(this._endHighlightIndex=this._textWrapper.length-this._cursorIndex,this._startHighlightIndex=this._textWrapper.length-this._cursorOffset):this._cursorIndex>this._cursorOffset?(this._endHighlightIndex=this._textWrapper.length-this._cursorOffset,this._startHighlightIndex=this._textWrapper.length-this._cursorIndex):this._isTextHighlightOn=!1,void this._markAsDirty()}return this._isTextHighlightOn&&(this._cursorOffset=this._textWrapper.length-this._endHighlightIndex,this._isTextHighlightOn=!1),i&&(i.ctrlKey||i.metaKey)&&(this._cursorOffset=0,i.preventDefault()),this._blinkIsEven=!1,this._isTextHighlightOn=!1,this._cursorIndex=-1,void this._markAsDirty();case 222:i&&i.preventDefault(),this._cursorIndex=-1,this.deadKey=!0}if(t&&(-1===e||32===e||e>47&&e<64||e>64&&e<91||e>159&&e<193||e>218&&e<223||e>95&&e<112)&&(this._currentKey=t,this.onBeforeKeyAddObservable.notifyObservers(this),t=this._currentKey,this._addKey))if(this._isTextHighlightOn)this._textWrapper.removePart(this._startHighlightIndex,this._endHighlightIndex,t),this._textHasChanged(),this._cursorOffset=this._textWrapper.length-(this._startHighlightIndex+1),this._isTextHighlightOn=!1,this._blinkIsEven=!1,this._markAsDirty();else if(0===this._cursorOffset)this.text+=t;else{var n=this._textWrapper.length-this._cursorOffset;this._textWrapper.removePart(n,n,t),this._textHasChanged()}}},i.prototype._updateValueFromCursorIndex=function(e){if(this._blinkIsEven=!1,-1===this._cursorIndex)this._cursorIndex=e;else if(this._cursorIndex<this._cursorOffset)this._endHighlightIndex=this._textWrapper.length-this._cursorIndex,this._startHighlightIndex=this._textWrapper.length-this._cursorOffset;else{if(!(this._cursorIndex>this._cursorOffset))return this._isTextHighlightOn=!1,void this._markAsDirty();this._endHighlightIndex=this._textWrapper.length-this._cursorOffset,this._startHighlightIndex=this._textWrapper.length-this._cursorIndex}this._isTextHighlightOn=!0,this._markAsDirty()},i.prototype._processDblClick=function(e){var t,i;this._startHighlightIndex=this._textWrapper.length-this._cursorOffset,this._endHighlightIndex=this._startHighlightIndex;do{i=this._endHighlightIndex<this._textWrapper.length&&this._textWrapper.isWord(this._endHighlightIndex)?++this._endHighlightIndex:0,t=this._startHighlightIndex>0&&this._textWrapper.isWord(this._startHighlightIndex-1)?--this._startHighlightIndex:0}while(t||i);this._cursorOffset=this._textWrapper.length-this._startHighlightIndex,this.onTextHighlightObservable.notifyObservers(this),this._isTextHighlightOn=!0,this._clickedCoordinate=null,this._blinkIsEven=!0,this._cursorIndex=-1,this._markAsDirty()},i.prototype._selectAllText=function(){this._blinkIsEven=!0,this._isTextHighlightOn=!0,this._startHighlightIndex=0,this._endHighlightIndex=this._textWrapper.length,this._cursorOffset=this._textWrapper.length,this._cursorIndex=-1,this._markAsDirty()},i.prototype.processKeyboard=function(e){this.processKey(e.keyCode,e.key,e),this.onKeyboardEventProcessedObservable.notifyObservers(e)},i.prototype._onCopyText=function(e){this._isTextHighlightOn=!1;try{e.clipboardData&&e.clipboardData.setData("text/plain",this._highlightedText)}catch(e){}this._host.clipboardData=this._highlightedText},i.prototype._onCutText=function(e){if(this._highlightedText){this._textWrapper.removePart(this._startHighlightIndex,this._endHighlightIndex),this._textHasChanged(),this._isTextHighlightOn=!1,this._cursorOffset=this._textWrapper.length-this._startHighlightIndex;try{e.clipboardData&&e.clipboardData.setData("text/plain",this._highlightedText)}catch(e){}this._host.clipboardData=this._highlightedText,this._highlightedText=""}},i.prototype._onPasteText=function(e){var t="";t=e.clipboardData&&-1!==e.clipboardData.types.indexOf("text/plain")?e.clipboardData.getData("text/plain"):this._host.clipboardData;var i=this._textWrapper.length-this._cursorOffset;this._textWrapper.removePart(i,i,t),this._textHasChanged()},i.prototype._draw=function(e,t){var i=this;e.save(),this._applyStates(e),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY),this._isFocused?this._focusedBackground&&(e.fillStyle=this._isEnabled?this._focusedBackground:this._disabledColor,e.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)):this._background&&(e.fillStyle=this._isEnabled?this._background:this._disabledColor,e.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0),this._fontOffset||(this._fontOffset=Ur._GetFontOffset(e.font));var r=this._currentMeasure.left+this._margin.getValueInPixel(this._host,this._tempParentMeasure.width);this.color&&(e.fillStyle=this.color);var n=this._beforeRenderText(this._textWrapper);this._isFocused||this._textWrapper.text||!this._placeholderText||((n=new Zr).text=this._placeholderText,this._placeholderColor&&(e.fillStyle=this._placeholderColor)),this._textWidth=e.measureText(n.text).width;var o=2*this._margin.getValueInPixel(this._host,this._tempParentMeasure.width);this._autoStretchWidth&&(this.width=Math.min(this._maxWidth.getValueInPixel(this._host,this._tempParentMeasure.width),this._textWidth+o)+"px");var s=this._fontOffset.ascent+(this._currentMeasure.height-this._fontOffset.height)/2,a=this._width.getValueInPixel(this._host,this._tempParentMeasure.width)-o;if(e.save(),e.beginPath(),e.rect(r,this._currentMeasure.top+(this._currentMeasure.height-this._fontOffset.height)/2,a+2,this._currentMeasure.height),e.clip(),this._isFocused&&this._textWidth>a){var h=r-this._textWidth+a;this._scrollLeft||(this._scrollLeft=h)}else this._scrollLeft=r;if(e.fillText(n.text,this._scrollLeft,this._currentMeasure.top+s),this._isFocused){if(this._clickedCoordinate){var u=this._scrollLeft+this._textWidth-this._clickedCoordinate,l=0;this._cursorOffset=0;var c=0;do{this._cursorOffset&&(c=Math.abs(u-l)),this._cursorOffset++,l=e.measureText(n.substr(n.length-this._cursorOffset,this._cursorOffset)).width}while(l<u&&n.length>=this._cursorOffset);Math.abs(u-l)>c&&this._cursorOffset--,this._blinkIsEven=!1,this._clickedCoordinate=null}if(!this._blinkIsEven){var f=n.substr(n.length-this._cursorOffset),d=e.measureText(f).width,p=this._scrollLeft+this._textWidth-d;p<r?(this._scrollLeft+=r-p,p=r,this._markAsDirty()):p>r+a&&(this._scrollLeft+=r+a-p,p=r+a,this._markAsDirty()),this._isTextHighlightOn||e.fillRect(p,this._currentMeasure.top+(this._currentMeasure.height-this._fontOffset.height)/2,2,this._fontOffset.height)}if(clearTimeout(this._blinkTimeout),this._blinkTimeout=setTimeout((function(){i._blinkIsEven=!i._blinkIsEven,i._markAsDirty()}),500),this._isTextHighlightOn){clearTimeout(this._blinkTimeout);var _=e.measureText(n.substring(this._startHighlightIndex)).width,g=this._scrollLeft+this._textWidth-_;this._highlightedText=n.substring(this._startHighlightIndex,this._endHighlightIndex);var m=e.measureText(n.substring(this._startHighlightIndex,this._endHighlightIndex)).width;g<r&&((m-=r-g)||(m=e.measureText(n.charAt(n.length-this._cursorOffset)).width),g=r),e.globalAlpha=this._highligherOpacity,e.fillStyle=this._textHighlightColor,e.fillRect(g,this._currentMeasure.top+(this._currentMeasure.height-this._fontOffset.height)/2,m,this._fontOffset.height),e.globalAlpha=1}}e.restore(),this._thickness&&(this._isFocused?this.focusedColor&&(e.strokeStyle=this.focusedColor):this.color&&(e.strokeStyle=this.color),e.lineWidth=this._thickness,e.strokeRect(this._currentMeasure.left+this._thickness/2,this._currentMeasure.top+this._thickness/2,this._currentMeasure.width-this._thickness,this._currentMeasure.height-this._thickness)),e.restore()},i.prototype._onPointerDown=function(t,i,r,n,o){return!!e.prototype._onPointerDown.call(this,t,i,r,n,o)&&(this._clickedCoordinate=i.x,this._isTextHighlightOn=!1,this._highlightedText="",this._cursorIndex=-1,this._isPointerDown=!0,this._host._capturingControl[r]=this,this._host.focusedControl===this?(clearTimeout(this._blinkTimeout),this._markAsDirty(),!0):!!this._isEnabled&&(this._host.focusedControl=this,!0))},i.prototype._onPointerMove=function(t,i,r,n){this._host.focusedControl===this&&this._isPointerDown&&(this._clickedCoordinate=i.x,this._markAsDirty(),this._updateValueFromCursorIndex(this._cursorOffset)),e.prototype._onPointerMove.call(this,t,i,r,n)},i.prototype._onPointerUp=function(t,i,r,n,o){this._isPointerDown=!1,delete this._host._capturingControl[r],e.prototype._onPointerUp.call(this,t,i,r,n,o)},i.prototype._beforeRenderText=function(e){return e},i.prototype.dispose=function(){e.prototype.dispose.call(this),this.onBlurObservable.clear(),this.onFocusObservable.clear(),this.onTextChangedObservable.clear(),this.onTextCopyObservable.clear(),this.onTextCutObservable.clear(),this.onTextPasteObservable.clear(),this.onTextHighlightObservable.clear(),this.onKeyboardEventProcessedObservable.clear()},i}(Ur);c.RegisteredTypes["BABYLON.GUI.InputText"]=Qr;var Jr=function(e){function i(t){var i=e.call(this,t)||this;return i.name=t,i._rowDefinitions=new Array,i._columnDefinitions=new Array,i._cells={},i._childControls=new Array,i}return t(i,e),Object.defineProperty(i.prototype,"columnCount",{get:function(){return this._columnDefinitions.length},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"rowCount",{get:function(){return this._rowDefinitions.length},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"children",{get:function(){return this._childControls},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"cells",{get:function(){return this._cells},enumerable:!1,configurable:!0}),i.prototype.getRowDefinition=function(e){return e<0||e>=this._rowDefinitions.length?null:this._rowDefinitions[e]},i.prototype.getColumnDefinition=function(e){return e<0||e>=this._columnDefinitions.length?null:this._columnDefinitions[e]},i.prototype.addRowDefinition=function(e,t){return void 0===t&&(t=!1),this._rowDefinitions.push(new Rr(e,t?Rr.UNITMODE_PIXEL:Rr.UNITMODE_PERCENTAGE)),this._markAsDirty(),this},i.prototype.addColumnDefinition=function(e,t){return void 0===t&&(t=!1),this._columnDefinitions.push(new Rr(e,t?Rr.UNITMODE_PIXEL:Rr.UNITMODE_PERCENTAGE)),this._markAsDirty(),this},i.prototype.setRowDefinition=function(e,t,i){if(void 0===i&&(i=!1),e<0||e>=this._rowDefinitions.length)return this;var r=this._rowDefinitions[e];return r&&r.isPixel===i&&r.internalValue===t||(this._rowDefinitions[e]=new Rr(t,i?Rr.UNITMODE_PIXEL:Rr.UNITMODE_PERCENTAGE),this._markAsDirty()),this},i.prototype.setColumnDefinition=function(e,t,i){if(void 0===i&&(i=!1),e<0||e>=this._columnDefinitions.length)return this;var r=this._columnDefinitions[e];return r&&r.isPixel===i&&r.internalValue===t||(this._columnDefinitions[e]=new Rr(t,i?Rr.UNITMODE_PIXEL:Rr.UNITMODE_PERCENTAGE),this._markAsDirty()),this},i.prototype.getChildrenAt=function(e,t){var i=this._cells[e+":"+t];return i?i.children:null},i.prototype.getChildCellInfo=function(e){return e._tag},i.prototype._removeCell=function(t,i){if(t){e.prototype.removeControl.call(this,t);for(var r=0,n=t.children;r<n.length;r++){var o=n[r],s=this._childControls.indexOf(o);-1!==s&&this._childControls.splice(s,1)}delete this._cells[i]}},i.prototype._offsetCell=function(e,t){if(this._cells[t]){this._cells[e]=this._cells[t];for(var i=0,r=this._cells[e].children;i<r.length;i++){r[i]._tag=e}delete this._cells[t]}},i.prototype.removeColumnDefinition=function(e){if(e<0||e>=this._columnDefinitions.length)return this;for(var t=0;t<this._rowDefinitions.length;t++){var i=t+":"+e,r=this._cells[i];this._removeCell(r,i)}for(t=0;t<this._rowDefinitions.length;t++)for(var n=e+1;n<this._columnDefinitions.length;n++){var o=t+":"+(n-1);i=t+":"+n;this._offsetCell(o,i)}return this._columnDefinitions.splice(e,1),this._markAsDirty(),this},i.prototype.removeRowDefinition=function(e){if(e<0||e>=this._rowDefinitions.length)return this;for(var t=0;t<this._columnDefinitions.length;t++){var i=e+":"+t,r=this._cells[i];this._removeCell(r,i)}for(t=0;t<this._columnDefinitions.length;t++)for(var n=e+1;n<this._rowDefinitions.length;n++){var o=n-1+":"+t;i=n+":"+t;this._offsetCell(o,i)}return this._rowDefinitions.splice(e,1),this._markAsDirty(),this},i.prototype.addControl=function(t,i,r){if(void 0===i&&(i=0),void 0===r&&(r=0),0===this._rowDefinitions.length&&this.addRowDefinition(1,!1),0===this._columnDefinitions.length&&this.addColumnDefinition(1,!1),-1!==this._childControls.indexOf(t))return Ue.Warn("Control (Name:"+t.name+", UniqueId:"+t.uniqueId+") is already associated with this grid. You must remove it before reattaching it"),this;var n=Math.min(i,this._rowDefinitions.length-1)+":"+Math.min(r,this._columnDefinitions.length-1),o=this._cells[n];return o||(o=new Vr(n),this._cells[n]=o,o.horizontalAlignment=Ur.HORIZONTAL_ALIGNMENT_LEFT,o.verticalAlignment=Ur.VERTICAL_ALIGNMENT_TOP,e.prototype.addControl.call(this,o)),o.addControl(t),this._childControls.push(t),t._tag=n,t.parent=this,this._markAsDirty(),this},i.prototype.removeControl=function(e){var t=this._childControls.indexOf(e);-1!==t&&this._childControls.splice(t,1);var i=this._cells[e._tag];return i&&(i.removeControl(e),e._tag=null),this._markAsDirty(),this},i.prototype._getTypeName=function(){return"Grid"},i.prototype._getGridDefinitions=function(e){for(var t=[],i=[],r=[],n=[],o=this._currentMeasure.width,s=0,a=this._currentMeasure.height,h=0,u=0,l=0,c=this._rowDefinitions;l<c.length;l++){if((g=c[l]).isPixel)a-=_=g.getValue(this._host),i[u]=_;else h+=g.internalValue;u++}var f=0;u=0;for(var d=0,p=this._rowDefinitions;d<p.length;d++){var _,g=p[d];if(n.push(f),g.isPixel)f+=g.getValue(this._host);else f+=_=g.internalValue/h*a,i[u]=_;u++}u=0;for(var m=0,v=this._columnDefinitions;m<v.length;m++){if((g=v[m]).isPixel)o-=E=g.getValue(this._host),t[u]=E;else s+=g.internalValue;u++}var y=0;u=0;for(var b=0,T=this._columnDefinitions;b<T.length;b++){var E;g=T[b];if(r.push(y),g.isPixel)y+=g.getValue(this._host);else y+=E=g.internalValue/s*o,t[u]=E;u++}e(r,n,t,i)},i.prototype._additionalProcessing=function(t,i){var r=this;this._getGridDefinitions((function(e,t,i,n){for(var o in r._cells)if(r._cells.hasOwnProperty(o)){var s=o.split(":"),a=parseInt(s[0]),h=parseInt(s[1]),u=r._cells[o];u.left=e[h]+"px",u.top=t[a]+"px",u.width=i[h]+"px",u.height=n[a]+"px",u._left.ignoreAdaptiveScaling=!0,u._top.ignoreAdaptiveScaling=!0,u._width.ignoreAdaptiveScaling=!0,u._height.ignoreAdaptiveScaling=!0}})),e.prototype._additionalProcessing.call(this,t,i)},i.prototype._flagDescendantsAsMatrixDirty=function(){for(var e in this._cells){if(this._cells.hasOwnProperty(e))this._cells[e]._markMatrixAsDirty()}},i.prototype._renderHighlightSpecific=function(t){var i=this;e.prototype._renderHighlightSpecific.call(this,t),this._getGridDefinitions((function(e,r,n,o){for(var s=0;s<e.length;s++){var a=i._currentMeasure.left+e[s]+n[s];t.beginPath(),t.moveTo(a,i._currentMeasure.top),t.lineTo(a,i._currentMeasure.top+i._currentMeasure.height),t.stroke()}for(s=0;s<r.length;s++){var h=i._currentMeasure.top+r[s]+o[s];t.beginPath(),t.moveTo(i._currentMeasure.left,h),t.lineTo(i._currentMeasure.left+i._currentMeasure.width,h),t.stroke()}})),t.restore()},i.prototype.dispose=function(){e.prototype.dispose.call(this);for(var t=0,i=this._childControls;t<i.length;t++){i[t].dispose()}this._childControls=[]},i}(Vr);c.RegisteredTypes["BABYLON.GUI.Grid"]=Jr;var $r=function(e){function i(t){var i=e.call(this,t)||this;return i.name=t,i._value=T.Red(),i._tmpColor=new T,i._pointerStartedOnSquare=!1,i._pointerStartedOnWheel=!1,i._squareLeft=0,i._squareTop=0,i._squareSize=0,i._h=360,i._s=1,i._v=1,i._lastPointerDownID=-1,i.onValueChangedObservable=new U,i._pointerIsDown=!1,i.value=new T(.88,.1,.1),i.size="200px",i.isPointerBlocker=!0,i}return t(i,e),Object.defineProperty(i.prototype,"value",{get:function(){return this._value},set:function(e){this._value.equals(e)||(this._value.copyFrom(e),this._value.toHSVToRef(this._tmpColor),this._h=this._tmpColor.r,this._s=Math.max(this._tmpColor.g,1e-5),this._v=Math.max(this._tmpColor.b,1e-5),this._markAsDirty(),this._value.r<=i._Epsilon&&(this._value.r=0),this._value.g<=i._Epsilon&&(this._value.g=0),this._value.b<=i._Epsilon&&(this._value.b=0),this._value.r>=1-i._Epsilon&&(this._value.r=1),this._value.g>=1-i._Epsilon&&(this._value.g=1),this._value.b>=1-i._Epsilon&&(this._value.b=1),this.onValueChangedObservable.notifyObservers(this._value))},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"width",{get:function(){return this._width.toString(this._host)},set:function(e){this._width.toString(this._host)!==e&&this._width.fromString(e)&&(this._height.fromString(e),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"height",{get:function(){return this._height.toString(this._host)},set:function(e){this._height.toString(this._host)!==e&&this._height.fromString(e)&&(this._width.fromString(e),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"size",{get:function(){return this.width},set:function(e){this.width=e},enumerable:!1,configurable:!0}),i.prototype._getTypeName=function(){return"ColorPicker"},i.prototype._preMeasure=function(e,t){e.width<e.height?this._currentMeasure.height=e.width:this._currentMeasure.width=e.height},i.prototype._updateSquareProps=function(){var e=.5*Math.min(this._currentMeasure.width,this._currentMeasure.height),t=2*(e-.2*e)/Math.sqrt(2),i=e-.5*t;this._squareLeft=this._currentMeasure.left+i,this._squareTop=this._currentMeasure.top+i,this._squareSize=t},i.prototype._drawGradientSquare=function(e,t,i,r,n,o){var s=o.createLinearGradient(t,i,r+t,i);s.addColorStop(0,"#fff"),s.addColorStop(1,"hsl("+e+", 100%, 50%)"),o.fillStyle=s,o.fillRect(t,i,r,n);var a=o.createLinearGradient(t,i,t,n+i);a.addColorStop(0,"rgba(0,0,0,0)"),a.addColorStop(1,"#000"),o.fillStyle=a,o.fillRect(t,i,r,n)},i.prototype._drawCircle=function(e,t,i,r){r.beginPath(),r.arc(e,t,i+1,0,2*Math.PI,!1),r.lineWidth=3,r.strokeStyle="#333333",r.stroke(),r.beginPath(),r.arc(e,t,i,0,2*Math.PI,!1),r.lineWidth=3,r.strokeStyle="#ffffff",r.stroke()},i.prototype._createColorWheelCanvas=function(e,t){var i=document.createElement("canvas");i.width=2*e,i.height=2*e;for(var r=i.getContext("2d"),n=r.getImageData(0,0,2*e,2*e),o=n.data,s=this._tmpColor,a=e*e,h=e-t,u=h*h,l=-e;l<e;l++)for(var c=-e;c<e;c++){var f=l*l+c*c;if(!(f>a||f<u)){var d=Math.sqrt(f),p=Math.atan2(c,l);T.HSVtoRGBToRef(180*p/Math.PI+180,d/e,1,s);var _=4*(l+e+2*(c+e)*e);o[_]=255*s.r,o[_+1]=255*s.g,o[_+2]=255*s.b;var g=.2;g=e<50?.2:e>150?.04:-.16*(e-50)/100+.2;var m=(d-h)/(e-h);o[_+3]=m<g?m/g*255:m>1-g?255*(1-(m-(1-g))/g):255}}return r.putImageData(n,0,0),i},i.prototype._draw=function(e){e.save(),this._applyStates(e);var t=.5*Math.min(this._currentMeasure.width,this._currentMeasure.height),i=.2*t,r=this._currentMeasure.left,n=this._currentMeasure.top;this._colorWheelCanvas&&this._colorWheelCanvas.width==2*t||(this._colorWheelCanvas=this._createColorWheelCanvas(t,i)),this._updateSquareProps(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY,e.fillRect(this._squareLeft,this._squareTop,this._squareSize,this._squareSize)),e.drawImage(this._colorWheelCanvas,r,n),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0),this._drawGradientSquare(this._h,this._squareLeft,this._squareTop,this._squareSize,this._squareSize,e);var o=this._squareLeft+this._squareSize*this._s,s=this._squareTop+this._squareSize*(1-this._v);this._drawCircle(o,s,.04*t,e);var a=t-.5*i;o=r+t+Math.cos((this._h-180)*Math.PI/180)*a,s=n+t+Math.sin((this._h-180)*Math.PI/180)*a,this._drawCircle(o,s,.35*i,e),e.restore()},i.prototype._updateValueFromPointer=function(e,t){if(this._pointerStartedOnWheel){var r=.5*Math.min(this._currentMeasure.width,this._currentMeasure.height),n=r+this._currentMeasure.left,o=r+this._currentMeasure.top;this._h=180*Math.atan2(t-o,e-n)/Math.PI+180}else this._pointerStartedOnSquare&&(this._updateSquareProps(),this._s=(e-this._squareLeft)/this._squareSize,this._v=1-(t-this._squareTop)/this._squareSize,this._s=Math.min(this._s,1),this._s=Math.max(this._s,i._Epsilon),this._v=Math.min(this._v,1),this._v=Math.max(this._v,i._Epsilon));T.HSVtoRGBToRef(this._h,this._s,this._v,this._tmpColor),this.value=this._tmpColor},i.prototype._isPointOnSquare=function(e,t){this._updateSquareProps();var i=this._squareLeft,r=this._squareTop,n=this._squareSize;return e>=i&&e<=i+n&&t>=r&&t<=r+n},i.prototype._isPointOnWheel=function(e,t){var i=.5*Math.min(this._currentMeasure.width,this._currentMeasure.height),r=i-.2*i,n=e-(i+this._currentMeasure.left),o=t-(i+this._currentMeasure.top),s=n*n+o*o;return s<=i*i&&s>=r*r},i.prototype._onPointerDown=function(t,i,r,n,o){if(!e.prototype._onPointerDown.call(this,t,i,r,n,o))return!1;this._pointerIsDown=!0,this._pointerStartedOnSquare=!1,this._pointerStartedOnWheel=!1,this._invertTransformMatrix.transformCoordinates(i.x,i.y,this._transformedPosition);var s=this._transformedPosition.x,a=this._transformedPosition.y;return this._isPointOnSquare(s,a)?this._pointerStartedOnSquare=!0:this._isPointOnWheel(s,a)&&(this._pointerStartedOnWheel=!0),this._updateValueFromPointer(s,a),this._host._capturingControl[r]=this,this._lastPointerDownID=r,!0},i.prototype._onPointerMove=function(t,i,r,n){if(r==this._lastPointerDownID){this._invertTransformMatrix.transformCoordinates(i.x,i.y,this._transformedPosition);var o=this._transformedPosition.x,s=this._transformedPosition.y;this._pointerIsDown&&this._updateValueFromPointer(o,s),e.prototype._onPointerMove.call(this,t,i,r,n)}},i.prototype._onPointerUp=function(t,i,r,n,o,s){this._pointerIsDown=!1,delete this._host._capturingControl[r],e.prototype._onPointerUp.call(this,t,i,r,n,o,s)},i.prototype._onCanvasBlur=function(){this._forcePointerUp(),e.prototype._onCanvasBlur.call(this)},i.ShowPickerDialogAsync=function(e,t){return new Promise((function(r,n){t.pickerWidth=t.pickerWidth||"640px",t.pickerHeight=t.pickerHeight||"400px",t.headerHeight=t.headerHeight||"35px",t.lastColor=t.lastColor||"#000000",t.swatchLimit=t.swatchLimit||20,t.numSwatchesPerLine=t.numSwatchesPerLine||10;var o,s,a,h,u,l,c,f,d,p,_,g,m,v,y,b,E,x,A,M=t.swatchLimit/t.numSwatchesPerLine,P=parseFloat(t.pickerWidth)/t.numSwatchesPerLine,C=Math.floor(.25*P),S=C*(t.numSwatchesPerLine+1),I=Math.floor((parseFloat(t.pickerWidth)-S)/t.numSwatchesPerLine),O=I*M+C*(M+1),R=(parseInt(t.pickerHeight)+O+Math.floor(.25*I)).toString()+"px",D="#c0c0c0",w="#535353",L="#414141",F="515151",N="#555555",B="#454545",k=T.FromHexString("#dddddd"),U=k.r+k.g+k.b,V="#aaaaaa",W="#ffffff",z=["R","G","B"],G="#454545",H="#f0f0f0",X=!1;function j(e,t){A=t;var i=e.toHexString();if(E.background=i,p.name!=A&&(p.text=Math.floor(255*e.r).toString()),_.name!=A&&(_.text=Math.floor(255*e.g).toString()),g.name!=A&&(g.text=Math.floor(255*e.b).toString()),m.name!=A&&(m.text=e.r.toString()),v.name!=A&&(v.text=e.g.toString()),y.name!=A&&(y.text=e.b.toString()),b.name!=A){var r=i.split("#");b.text=r[1]}d.name!=A&&(d.value=e)}function K(e,t){var i=e.text;if(/[^0-9]/g.test(i))e.text=x;else if(""!=i&&(Math.floor(parseInt(i))<0?i="0":Math.floor(parseInt(i))>255?i="255":isNaN(parseInt(i))&&(i="0")),A==e.name&&(x=i),""!=i){i=parseInt(i).toString(),e.text=i;var r=T.FromHexString(E.background);A==e.name&&j("r"==t?new T(parseInt(i)/255,r.g,r.b):"g"==t?new T(r.r,parseInt(i)/255,r.b):new T(r.r,r.g,parseInt(i)/255),e.name)}}function Y(e,t){var i=e.text;if(/[^0-9\.]/g.test(i))e.text=x;else{""!=i&&"."!=i&&0!=parseFloat(i)&&(parseFloat(i)<0?i="0.0":parseFloat(i)>1?i="1.0":isNaN(parseFloat(i))&&(i="0.0")),A==e.name&&(x=i),""!=i&&"."!=i&&0!=parseFloat(i)?(i=parseFloat(i).toString(),e.text=i):i="0.0";var r=T.FromHexString(E.background);A==e.name&&j("r"==t?new T(parseFloat(i),r.g,r.b):"g"==t?new T(r.r,parseFloat(i),r.b):new T(r.r,r.g,parseFloat(i)),e.name)}}function q(){if(t.savedColors&&t.savedColors[c]){if(X)var e="b";else e="";var i=Xr.CreateSimpleButton("Swatch_"+c,e);i.fontFamily="BabylonJSglyphs";var r=T.FromHexString(t.savedColors[c]),n=r.r+r.g+r.b;i.color=n>U?V:W,i.fontSize=Math.floor(.7*I),i.textBlock.verticalAlignment=Ur.VERTICAL_ALIGNMENT_CENTER,i.height=i.width=I.toString()+"px",i.background=t.savedColors[c],i.thickness=2;var o=c;return i.pointerDownAnimation=function(){i.thickness=4},i.pointerUpAnimation=function(){i.thickness=3},i.pointerEnterAnimation=function(){i.thickness=3},i.pointerOutAnimation=function(){i.thickness=2},i.onPointerClickObservable.add((function(){var e;X?(e=o,t.savedColors&&t.savedColors.splice(e,1),t.savedColors&&0==t.savedColors.length&&(J(!1),X=!1),Q("",we)):t.savedColors&&j(T.FromHexString(t.savedColors[o]),i.name)})),i}return null}function Z(e){if(void 0!==e&&(X=e),X){for(var t=0;t<f.children.length;t++){f.children[t].textBlock.text="b"}void 0!==a&&(a.textBlock.text="Done")}else{for(t=0;t<f.children.length;t++){f.children[t].textBlock.text=""}void 0!==a&&(a.textBlock.text="Edit")}}function Q(e,i){if(t.savedColors){""!=e&&t.savedColors.push(e),c=0,f.clearControls();var r=Math.ceil(t.savedColors.length/t.numSwatchesPerLine);if(0==r)var n=0;else n=r+1;if(f.rowCount!=r+n){for(var o=f.rowCount,s=0;s<o;s++)f.removeRowDefinition(0);for(s=0;s<r+n;s++)s%2?f.addRowDefinition(I,!0):f.addRowDefinition(C,!0)}f.height=(I*r+n*C).toString()+"px";for(var a=1,h=1;a<r+n;a+=2,h++){if(t.savedColors.length>h*t.numSwatchesPerLine)var u=t.numSwatchesPerLine;else u=t.savedColors.length-(h-1)*t.numSwatchesPerLine;for(var l=Math.min(Math.max(u,0),t.numSwatchesPerLine),d=0,p=1;d<l;d++)if(!(d>t.numSwatchesPerLine)){var _=q();null!=_&&(f.addControl(_,a,p),p+=2,c++)}}t.savedColors.length>=t.swatchLimit?$(i,!0):$(i,!1)}}function J(e){e?((a=Xr.CreateSimpleButton("butEdit","Edit")).width=h,a.height=u,a.left=Math.floor(.1*parseInt(h)).toString()+"px",a.top=(-1*parseFloat(a.left)).toString()+"px",a.verticalAlignment=Ur.VERTICAL_ALIGNMENT_BOTTOM,a.horizontalAlignment=Ur.HORIZONTAL_ALIGNMENT_LEFT,a.thickness=2,a.color=D,a.fontSize=s,a.background=w,a.onPointerEnterObservable.add((function(){a.background=L})),a.onPointerOutObservable.add((function(){a.background=w})),a.pointerDownAnimation=function(){a.background=F},a.pointerUpAnimation=function(){a.background=L},a.onPointerClickObservable.add((function(){X=!X,Z()})),pe.addControl(a,1,0)):pe.removeControl(a)}function $(e,t){t?(e.color=N,e.background=B):(e.color=D,e.background=w)}function ee(i){t.savedColors&&t.savedColors.length>0?r({savedColors:t.savedColors,pickedColor:i}):r({pickedColor:i}),e.removeControl(te)}var te=new Jr;if(te.name="Dialog Container",te.width=t.pickerWidth,t.savedColors){te.height=R;var ie=parseInt(t.pickerHeight)/parseInt(R);te.addRowDefinition(ie,!1),te.addRowDefinition(1-ie,!1)}else te.height=t.pickerHeight,te.addRowDefinition(1,!1);if(e.addControl(te),t.savedColors){(f=new Jr).name="Swatch Drawer",f.verticalAlignment=Ur.VERTICAL_ALIGNMENT_TOP,f.background=w,f.width=t.pickerWidth;var re=t.savedColors.length/t.numSwatchesPerLine;if(0==re)var ne=0;else ne=re+1;f.height=(I*re+ne*C).toString()+"px",f.top=Math.floor(.25*I).toString()+"px";for(var oe=0;oe<2*Math.ceil(t.savedColors.length/t.numSwatchesPerLine)+1;oe++)oe%2!=0?f.addRowDefinition(I,!0):f.addRowDefinition(C,!0);for(oe=0;oe<2*t.numSwatchesPerLine+1;oe++)oe%2!=0?f.addColumnDefinition(I,!0):f.addColumnDefinition(C,!0);te.addControl(f,1,0)}var se=new Jr;se.name="Picker Panel",se.height=t.pickerHeight;var ae=parseInt(t.headerHeight)/parseInt(t.pickerHeight),he=[ae,1-ae];se.addRowDefinition(he[0],!1),se.addRowDefinition(he[1],!1),te.addControl(se,0,0);var ue=new zr;ue.name="Dialogue Header Bar",ue.background="#cccccc",ue.thickness=0,se.addControl(ue,0,0);var le=Xr.CreateSimpleButton("closeButton","a");le.fontFamily="BabylonJSglyphs";var ce=T.FromHexString(ue.background);o=new T(1-ce.r,1-ce.g,1-ce.b),le.color=o.toHexString(),le.fontSize=Math.floor(.6*parseInt(t.headerHeight)),le.textBlock.textVerticalAlignment=Ur.VERTICAL_ALIGNMENT_CENTER,le.horizontalAlignment=Ur.HORIZONTAL_ALIGNMENT_RIGHT,le.height=le.width=t.headerHeight,le.background=ue.background,le.thickness=0,le.pointerDownAnimation=function(){},le.pointerUpAnimation=function(){le.background=ue.background},le.pointerEnterAnimation=function(){le.color=ue.background,le.background="red"},le.pointerOutAnimation=function(){le.color=o.toHexString(),le.background=ue.background},le.onPointerClickObservable.add((function(){ee(Pe.background)})),se.addControl(le,0,0);var fe=new Jr;fe.name="Dialogue Body",fe.background=w;var de=[.4375,.5625];fe.addRowDefinition(1,!1),fe.addColumnDefinition(de[0],!1),fe.addColumnDefinition(de[1],!1),se.addControl(fe,1,0);var pe=new Jr;pe.name="Picker Grid",pe.addRowDefinition(.85,!1),pe.addRowDefinition(.15,!1),fe.addControl(pe,0,0),(d=new i).name="GUI Color Picker",t.pickerHeight<t.pickerWidth?d.width=.89:d.height=.89,d.value=T.FromHexString(t.lastColor),d.horizontalAlignment=Ur.HORIZONTAL_ALIGNMENT_CENTER,d.verticalAlignment=Ur.VERTICAL_ALIGNMENT_CENTER,d.onPointerDownObservable.add((function(){A=d.name,x="",Z(!1)})),d.onValueChangedObservable.add((function(e){A==d.name&&j(e,d.name)})),pe.addControl(d,0,0);var _e=new Jr;_e.name="Dialogue Right Half",_e.horizontalAlignment=Ur.HORIZONTAL_ALIGNMENT_LEFT;var ge=[.514,.486];_e.addRowDefinition(ge[0],!1),_e.addRowDefinition(ge[1],!1),fe.addControl(_e,1,1);var me=new Jr;me.name="Swatches and Buttons";var ve=[.417,.583];me.addRowDefinition(1,!1),me.addColumnDefinition(ve[0],!1),me.addColumnDefinition(ve[1],!1),_e.addControl(me,0,0);var ye=new Jr;ye.name="New and Current Swatches";var be=[.04,.16,.64,.16];ye.addRowDefinition(be[0],!1),ye.addRowDefinition(be[1],!1),ye.addRowDefinition(be[2],!1),ye.addRowDefinition(be[3],!1),me.addControl(ye,0,0);var Te=new Jr;Te.name="Active Swatches",Te.width=.67,Te.addRowDefinition(.5,!1),Te.addRowDefinition(.5,!1),ye.addControl(Te,2,0);var Ee=Math.floor(parseInt(t.pickerWidth)*de[1]*ve[0]*.11),xe=Math.floor(parseInt(t.pickerHeight)*he[1]*ge[0]*be[1]*.5);if(t.pickerWidth>t.pickerHeight)var Ae=xe;else Ae=Ee;var Me=new Gr;Me.text="new",Me.name="New Color Label",Me.color=D,Me.fontSize=Ae,ye.addControl(Me,1,0),(E=new zr).name="New Color Swatch",E.background=t.lastColor,E.thickness=0,Te.addControl(E,0,0);var Pe=Xr.CreateSimpleButton("currentSwatch","");Pe.background=t.lastColor,Pe.thickness=0,Pe.onPointerClickObservable.add((function(){j(T.FromHexString(Pe.background),Pe.name),Z(!1)})),Pe.pointerDownAnimation=function(){},Pe.pointerUpAnimation=function(){},Pe.pointerEnterAnimation=function(){},Pe.pointerOutAnimation=function(){},Te.addControl(Pe,1,0);var Ce=new zr;Ce.name="Swatch Outline",Ce.width=.67,Ce.thickness=2,Ce.color="#404040",Ce.isHitTestVisible=!1,ye.addControl(Ce,2,0);var Se=new Gr;Se.name="Current Color Label",Se.text="current",Se.color=D,Se.fontSize=Ae,ye.addControl(Se,3,0);var Ie=new Jr;Ie.name="Button Grid",Ie.height=.8;var Oe=1/3;Ie.addRowDefinition(Oe,!1),Ie.addRowDefinition(Oe,!1),Ie.addRowDefinition(Oe,!1),me.addControl(Ie,0,1),h=Math.floor(parseInt(t.pickerWidth)*de[1]*ve[1]*.67).toString()+"px",u=Math.floor(parseInt(t.pickerHeight)*he[1]*ge[0]*(parseFloat(Ie.height.toString())/100)*Oe*.7).toString()+"px",s=parseFloat(h)>parseFloat(u)?Math.floor(.45*parseFloat(u)):Math.floor(.11*parseFloat(h));var Re=Xr.CreateSimpleButton("butOK","OK");Re.width=h,Re.height=u,Re.verticalAlignment=Ur.VERTICAL_ALIGNMENT_CENTER,Re.thickness=2,Re.color=D,Re.fontSize=s,Re.background=w,Re.onPointerEnterObservable.add((function(){Re.background=L})),Re.onPointerOutObservable.add((function(){Re.background=w})),Re.pointerDownAnimation=function(){Re.background=F},Re.pointerUpAnimation=function(){Re.background=L},Re.onPointerClickObservable.add((function(){Z(!1),ee(E.background)})),Ie.addControl(Re,0,0);var De=Xr.CreateSimpleButton("butCancel","Cancel");if(De.width=h,De.height=u,De.verticalAlignment=Ur.VERTICAL_ALIGNMENT_CENTER,De.thickness=2,De.color=D,De.fontSize=s,De.background=w,De.onPointerEnterObservable.add((function(){De.background=L})),De.onPointerOutObservable.add((function(){De.background=w})),De.pointerDownAnimation=function(){De.background=F},De.pointerUpAnimation=function(){De.background=L},De.onPointerClickObservable.add((function(){Z(!1),ee(Pe.background)})),Ie.addControl(De,1,0),t.savedColors){var we=Xr.CreateSimpleButton("butSave","Save");we.width=h,we.height=u,we.verticalAlignment=Ur.VERTICAL_ALIGNMENT_CENTER,we.thickness=2,we.fontSize=s,t.savedColors.length<t.swatchLimit?(we.color=D,we.background=w):$(we,!0),we.onPointerEnterObservable.add((function(){t.savedColors&&t.savedColors.length<t.swatchLimit&&(we.background=L)})),we.onPointerOutObservable.add((function(){t.savedColors&&t.savedColors.length<t.swatchLimit&&(we.background=w)})),we.pointerDownAnimation=function(){t.savedColors&&t.savedColors.length<t.swatchLimit&&(we.background=F)},we.pointerUpAnimation=function(){t.savedColors&&t.savedColors.length<t.swatchLimit&&(we.background=L)},we.onPointerClickObservable.add((function(){t.savedColors&&(0==t.savedColors.length&&J(!0),t.savedColors.length<t.swatchLimit&&Q(E.background,we),Z(!1))})),t.savedColors.length>0&&J(!0),Ie.addControl(we,2,0)}var Le=new Jr;Le.name="Dialog Lower Right",Le.addRowDefinition(.02,!1),Le.addRowDefinition(.63,!1),Le.addRowDefinition(.21,!1),Le.addRowDefinition(.14,!1),_e.addControl(Le,1,0),l=T.FromHexString(t.lastColor);var Fe=new Jr;Fe.name="RGB Values",Fe.width=.82,Fe.verticalAlignment=Ur.VERTICAL_ALIGNMENT_CENTER,Fe.addRowDefinition(1/3,!1),Fe.addRowDefinition(1/3,!1),Fe.addRowDefinition(1/3,!1),Fe.addColumnDefinition(.1,!1),Fe.addColumnDefinition(.2,!1),Fe.addColumnDefinition(.7,!1),Le.addControl(Fe,1,0);for(oe=0;oe<z.length;oe++){(Ne=new Gr).text=z[oe],Ne.color=D,Ne.fontSize=s,Fe.addControl(Ne,oe,0)}(p=new Qr).width=.83,p.height=.72,p.name="rIntField",p.fontSize=s,p.text=(255*l.r).toString(),p.color=H,p.background=G,p.onFocusObservable.add((function(){A=p.name,x=p.text,Z(!1)})),p.onBlurObservable.add((function(){""==p.text&&(p.text="0"),K(p,"r"),A==p.name&&(A="")})),p.onTextChangedObservable.add((function(){A==p.name&&K(p,"r")})),Fe.addControl(p,0,1),(_=new Qr).width=.83,_.height=.72,_.name="gIntField",_.fontSize=s,_.text=(255*l.g).toString(),_.color=H,_.background=G,_.onFocusObservable.add((function(){A=_.name,x=_.text,Z(!1)})),_.onBlurObservable.add((function(){""==_.text&&(_.text="0"),K(_,"g"),A==_.name&&(A="")})),_.onTextChangedObservable.add((function(){A==_.name&&K(_,"g")})),Fe.addControl(_,1,1),(g=new Qr).width=.83,g.height=.72,g.name="bIntField",g.fontSize=s,g.text=(255*l.b).toString(),g.color=H,g.background=G,g.onFocusObservable.add((function(){A=g.name,x=g.text,Z(!1)})),g.onBlurObservable.add((function(){""==g.text&&(g.text="0"),K(g,"b"),A==g.name&&(A="")})),g.onTextChangedObservable.add((function(){A==g.name&&K(g,"b")})),Fe.addControl(g,2,1),(m=new Qr).width=.95,m.height=.72,m.name="rDecField",m.fontSize=s,m.text=l.r.toString(),m.color=H,m.background=G,m.onFocusObservable.add((function(){A=m.name,x=m.text,Z(!1)})),m.onBlurObservable.add((function(){0!=parseFloat(m.text)&&""!=m.text||(m.text="0",Y(m,"r")),A==m.name&&(A="")})),m.onTextChangedObservable.add((function(){A==m.name&&Y(m,"r")})),Fe.addControl(m,0,2),(v=new Qr).width=.95,v.height=.72,v.name="gDecField",v.fontSize=s,v.text=l.g.toString(),v.color=H,v.background=G,v.onFocusObservable.add((function(){A=v.name,x=v.text,Z(!1)})),v.onBlurObservable.add((function(){0!=parseFloat(v.text)&&""!=v.text||(v.text="0",Y(v,"g")),A==v.name&&(A="")})),v.onTextChangedObservable.add((function(){A==v.name&&Y(v,"g")})),Fe.addControl(v,1,2),(y=new Qr).width=.95,y.height=.72,y.name="bDecField",y.fontSize=s,y.text=l.b.toString(),y.color=H,y.background=G,y.onFocusObservable.add((function(){A=y.name,x=y.text,Z(!1)})),y.onBlurObservable.add((function(){0!=parseFloat(y.text)&&""!=y.text||(y.text="0",Y(y,"b")),A==y.name&&(A="")})),y.onTextChangedObservable.add((function(){A==y.name&&Y(y,"b")})),Fe.addControl(y,2,2);var Ne,Be=new Jr;Be.name="Hex Value",Be.width=.82,Be.addRowDefinition(1,!1),Be.addColumnDefinition(.1,!1),Be.addColumnDefinition(.9,!1),Le.addControl(Be,2,0),(Ne=new Gr).text="#",Ne.color=D,Ne.fontSize=s,Be.addControl(Ne,0,0),(b=new Qr).width=.96,b.height=.72,b.name="hexField",b.horizontalAlignment=Ur.HORIZONTAL_ALIGNMENT_CENTER,b.fontSize=s;var ke=t.lastColor.split("#");b.text=ke[1],b.color=H,b.background=G,b.onFocusObservable.add((function(){A=b.name,x=b.text,Z(!1)})),b.onBlurObservable.add((function(){if(3==b.text.length){var e=b.text.split("");b.text=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]}""==b.text&&(b.text="000000",j(T.FromHexString(b.text),"b")),A==b.name&&(A="")})),b.onTextChangedObservable.add((function(){var e=b.text,t=/[^0-9A-F]/i.test(e);if((b.text.length>6||t)&&A==b.name)b.text=x;else{if(b.text.length<6)for(var i=6-b.text.length,r=0;r<i;r++)e="0"+e;if(3==b.text.length){var n=b.text.split("");e=n[0]+n[0]+n[1]+n[1]+n[2]+n[2]}e="#"+e,A==b.name&&(x=b.text,j(T.FromHexString(e),b.name))}})),Be.addControl(b,0,1),t.savedColors&&t.savedColors.length>0&&Q("",we)}))},i._Epsilon=1e-6,i}(Ur);c.RegisteredTypes["BABYLON.GUI.ColorPicker"]=$r;var en=function(e){function i(t){var i=e.call(this,t)||this;return i.name=t,i._thickness=1,i}return t(i,e),Object.defineProperty(i.prototype,"thickness",{get:function(){return this._thickness},set:function(e){this._thickness!==e&&(this._thickness=e,this._markAsDirty())},enumerable:!1,configurable:!0}),i.prototype._getTypeName=function(){return"Ellipse"},i.prototype._localDraw=function(e){e.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY),Ur.drawEllipse(this._currentMeasure.left+this._currentMeasure.width/2,this._currentMeasure.top+this._currentMeasure.height/2,this._currentMeasure.width/2-this._thickness/2,this._currentMeasure.height/2-this._thickness/2,e),this._background&&(e.fillStyle=this._background,e.fill()),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0),this._thickness&&(this.color&&(e.strokeStyle=this.color),e.lineWidth=this._thickness,e.stroke()),e.restore()},i.prototype._additionalProcessing=function(t,i){e.prototype._additionalProcessing.call(this,t,i),this._measureForChildren.width-=2*this._thickness,this._measureForChildren.height-=2*this._thickness,this._measureForChildren.left+=this._thickness,this._measureForChildren.top+=this._thickness},i.prototype._clipForChildren=function(e){Ur.drawEllipse(this._currentMeasure.left+this._currentMeasure.width/2,this._currentMeasure.top+this._currentMeasure.height/2,this._currentMeasure.width/2,this._currentMeasure.height/2,e),e.clip()},i}(Vr);c.RegisteredTypes["BABYLON.GUI.Ellipse"]=en;var tn=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t(i,e),i.prototype._beforeRenderText=function(e){for(var t=new Zr,i="",r=0;r<e.length;r++)i+="•";return t.text=i,t},i}(Qr);c.RegisteredTypes["BABYLON.GUI.InputPassword"]=tn;var rn=function(e){function i(t){var i=e.call(this,t)||this;return i.name=t,i._lineWidth=1,i._x1=new Rr(0),i._y1=new Rr(0),i._x2=new Rr(0),i._y2=new Rr(0),i._dash=new Array,i._automaticSize=!0,i.isHitTestVisible=!1,i._horizontalAlignment=Ur.HORIZONTAL_ALIGNMENT_LEFT,i._verticalAlignment=Ur.VERTICAL_ALIGNMENT_TOP,i}return t(i,e),Object.defineProperty(i.prototype,"dash",{get:function(){return this._dash},set:function(e){this._dash!==e&&(this._dash=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"connectedControl",{get:function(){return this._connectedControl},set:function(e){var t=this;this._connectedControl!==e&&(this._connectedControlDirtyObserver&&this._connectedControl&&(this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver),this._connectedControlDirtyObserver=null),e&&(this._connectedControlDirtyObserver=e.onDirtyObservable.add((function(){return t._markAsDirty()}))),this._connectedControl=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"x1",{get:function(){return this._x1.toString(this._host)},set:function(e){this._x1.toString(this._host)!==e&&this._x1.fromString(e)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"y1",{get:function(){return this._y1.toString(this._host)},set:function(e){this._y1.toString(this._host)!==e&&this._y1.fromString(e)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"x2",{get:function(){return this._x2.toString(this._host)},set:function(e){this._x2.toString(this._host)!==e&&this._x2.fromString(e)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"y2",{get:function(){return this._y2.toString(this._host)},set:function(e){this._y2.toString(this._host)!==e&&this._y2.fromString(e)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"lineWidth",{get:function(){return this._lineWidth},set:function(e){this._lineWidth!==e&&(this._lineWidth=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"horizontalAlignment",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"verticalAlignment",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"_effectiveX2",{get:function(){return(this._connectedControl?this._connectedControl.centerX:0)+this._x2.getValue(this._host)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"_effectiveY2",{get:function(){return(this._connectedControl?this._connectedControl.centerY:0)+this._y2.getValue(this._host)},enumerable:!1,configurable:!0}),i.prototype._getTypeName=function(){return"Line"},i.prototype._draw=function(e){e.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY),this._applyStates(e),e.strokeStyle=this.color,e.lineWidth=this._lineWidth,e.setLineDash(this._dash),e.beginPath(),e.moveTo(this._cachedParentMeasure.left+this._x1.getValue(this._host),this._cachedParentMeasure.top+this._y1.getValue(this._host)),e.lineTo(this._cachedParentMeasure.left+this._effectiveX2,this._cachedParentMeasure.top+this._effectiveY2),e.stroke(),e.restore()},i.prototype._measure=function(){this._currentMeasure.width=Math.abs(this._x1.getValue(this._host)-this._effectiveX2)+this._lineWidth,this._currentMeasure.height=Math.abs(this._y1.getValue(this._host)-this._effectiveY2)+this._lineWidth},i.prototype._computeAlignment=function(e,t){this._currentMeasure.left=e.left+Math.min(this._x1.getValue(this._host),this._effectiveX2)-this._lineWidth/2,this._currentMeasure.top=e.top+Math.min(this._y1.getValue(this._host),this._effectiveY2)-this._lineWidth/2},i.prototype.moveToVector3=function(e,t,i){if(void 0===i&&(i=!1),this._host&&this.parent===this._host._rootContainer){var r=this._host._getGlobalViewport(t),n=p.Project(e,m.Identity(),t.getTransformMatrix(),r);this._moveToProjectedPosition(n,i),n.z<0||n.z>1?this.notRenderable=!0:this.notRenderable=!1}else Ue.Error("Cannot move a control to a vector3 if the control is not at root level")},i.prototype._moveToProjectedPosition=function(e,t){void 0===t&&(t=!1);var i=e.x+this._linkOffsetX.getValue(this._host)+"px",r=e.y+this._linkOffsetY.getValue(this._host)+"px";t?(this.x2=i,this.y2=r,this._x2.ignoreAdaptiveScaling=!0,this._y2.ignoreAdaptiveScaling=!0):(this.x1=i,this.y1=r,this._x1.ignoreAdaptiveScaling=!0,this._y1.ignoreAdaptiveScaling=!0)},i}(Ur);c.RegisteredTypes["BABYLON.GUI.Line"]=rn;var nn=function(){function e(e){this._multiLine=e,this._x=new Rr(0),this._y=new Rr(0),this._point=new p(0,0,0)}return Object.defineProperty(e.prototype,"x",{get:function(){return this._x.toString(this._multiLine._host)},set:function(e){this._x.toString(this._multiLine._host)!==e&&this._x.fromString(e)&&this._multiLine._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this._y.toString(this._multiLine._host)},set:function(e){this._y.toString(this._multiLine._host)!==e&&this._y.fromString(e)&&this._multiLine._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"control",{get:function(){return this._control},set:function(e){this._control!==e&&(this._control&&this._controlObserver&&(this._control.onDirtyObservable.remove(this._controlObserver),this._controlObserver=null),this._control=e,this._control&&(this._controlObserver=this._control.onDirtyObservable.add(this._multiLine.onPointUpdate)),this._multiLine._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mesh",{get:function(){return this._mesh},set:function(e){this._mesh!==e&&(this._mesh&&this._meshObserver&&this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver),this._mesh=e,this._mesh&&(this._meshObserver=this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate)),this._multiLine._markAsDirty())},enumerable:!1,configurable:!0}),e.prototype.resetLinks=function(){this.control=null,this.mesh=null},e.prototype.translate=function(){return this._point=this._translatePoint(),this._point},e.prototype._translatePoint=function(){if(null!=this._mesh)return this._multiLine._host.getProjectedPositionWithZ(this._mesh.getBoundingInfo().boundingSphere.center,this._mesh.getWorldMatrix());if(null!=this._control)return new p(this._control.centerX,this._control.centerY,.999);var e=this._multiLine._host,t=this._x.getValueInPixel(e,Number(e._canvas.width)),i=this._y.getValueInPixel(e,Number(e._canvas.height));return new p(t,i,.999)},e.prototype.dispose=function(){this.resetLinks()},e}(),on=function(e){function i(t){var i=e.call(this,t)||this;return i.name=t,i._lineWidth=1,i.onPointUpdate=function(){i._markAsDirty()},i._automaticSize=!0,i.isHitTestVisible=!1,i._horizontalAlignment=Ur.HORIZONTAL_ALIGNMENT_LEFT,i._verticalAlignment=Ur.VERTICAL_ALIGNMENT_TOP,i._dash=[],i._points=[],i}return t(i,e),Object.defineProperty(i.prototype,"dash",{get:function(){return this._dash},set:function(e){this._dash!==e&&(this._dash=e,this._markAsDirty())},enumerable:!1,configurable:!0}),i.prototype.getAt=function(e){return this._points[e]||(this._points[e]=new nn(this)),this._points[e]},i.prototype.add=function(){for(var e=this,t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];return t.map((function(t){return e.push(t)}))},i.prototype.push=function(e){var t=this.getAt(this._points.length);return null==e||(e instanceof kt?t.mesh=e:e instanceof Ur?t.control=e:null!=e.x&&null!=e.y&&(t.x=e.x,t.y=e.y)),t},i.prototype.remove=function(e){var t;if(e instanceof nn){if(-1===(t=this._points.indexOf(e)))return}else t=e;var i=this._points[t];i&&(i.dispose(),this._points.splice(t,1))},i.prototype.reset=function(){for(;this._points.length>0;)this.remove(this._points.length-1)},i.prototype.resetLinks=function(){this._points.forEach((function(e){null!=e&&e.resetLinks()}))},Object.defineProperty(i.prototype,"lineWidth",{get:function(){return this._lineWidth},set:function(e){this._lineWidth!==e&&(this._lineWidth=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"horizontalAlignment",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"verticalAlignment",{set:function(e){},enumerable:!1,configurable:!0}),i.prototype._getTypeName=function(){return"MultiLine"},i.prototype._draw=function(e,t){e.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY),this._applyStates(e),e.strokeStyle=this.color,e.lineWidth=this._lineWidth,e.setLineDash(this._dash),e.beginPath();var i,r=!0;this._points.forEach((function(t){t&&(r?(e.moveTo(t._point.x,t._point.y),r=!1):t._point.z<1&&i.z<1?e.lineTo(t._point.x,t._point.y):e.moveTo(t._point.x,t._point.y),i=t._point)})),e.stroke(),e.restore()},i.prototype._additionalProcessing=function(e,t){var i=this;this._minX=null,this._minY=null,this._maxX=null,this._maxY=null,this._points.forEach((function(e,t){e&&(e.translate(),(null==i._minX||e._point.x<i._minX)&&(i._minX=e._point.x),(null==i._minY||e._point.y<i._minY)&&(i._minY=e._point.y),(null==i._maxX||e._point.x>i._maxX)&&(i._maxX=e._point.x),(null==i._maxY||e._point.y>i._maxY)&&(i._maxY=e._point.y))})),null==this._minX&&(this._minX=0),null==this._minY&&(this._minY=0),null==this._maxX&&(this._maxX=0),null==this._maxY&&(this._maxY=0)},i.prototype._measure=function(){null!=this._minX&&null!=this._maxX&&null!=this._minY&&null!=this._maxY&&(this._currentMeasure.width=Math.abs(this._maxX-this._minX)+this._lineWidth,this._currentMeasure.height=Math.abs(this._maxY-this._minY)+this._lineWidth)},i.prototype._computeAlignment=function(e,t){null!=this._minX&&null!=this._minY&&(this._currentMeasure.left=this._minX-this._lineWidth/2,this._currentMeasure.top=this._minY-this._lineWidth/2)},i.prototype.dispose=function(){this.reset(),e.prototype.dispose.call(this)},i}(Ur);c.RegisteredTypes["BABYLON.GUI.MultiLine"]=on;var sn=function(e){function i(t){var i=e.call(this,t)||this;return i.name=t,i._isChecked=!1,i._background="black",i._checkSizeRatio=.8,i._thickness=1,i.group="",i.onIsCheckedChangedObservable=new U,i.isPointerBlocker=!0,i}return t(i,e),Object.defineProperty(i.prototype,"thickness",{get:function(){return this._thickness},set:function(e){this._thickness!==e&&(this._thickness=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"checkSizeRatio",{get:function(){return this._checkSizeRatio},set:function(e){e=Math.max(Math.min(1,e),0),this._checkSizeRatio!==e&&(this._checkSizeRatio=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"background",{get:function(){return this._background},set:function(e){this._background!==e&&(this._background=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"isChecked",{get:function(){return this._isChecked},set:function(e){var t=this;this._isChecked!==e&&(this._isChecked=e,this._markAsDirty(),this.onIsCheckedChangedObservable.notifyObservers(e),this._isChecked&&this._host&&this._host.executeOnAllControls((function(e){if(e!==t&&void 0!==e.group){var i=e;i.group===t.group&&(i.isChecked=!1)}})))},enumerable:!1,configurable:!0}),i.prototype._getTypeName=function(){return"RadioButton"},i.prototype._draw=function(e){e.save(),this._applyStates(e);var t=this._currentMeasure.width-this._thickness,i=this._currentMeasure.height-this._thickness;if((this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY),Ur.drawEllipse(this._currentMeasure.left+this._currentMeasure.width/2,this._currentMeasure.top+this._currentMeasure.height/2,this._currentMeasure.width/2-this._thickness/2,this._currentMeasure.height/2-this._thickness/2,e),e.fillStyle=this._isEnabled?this._background:this._disabledColor,e.fill(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0),e.strokeStyle=this.color,e.lineWidth=this._thickness,e.stroke(),this._isChecked){e.fillStyle=this._isEnabled?this.color:this._disabledColor;var r=t*this._checkSizeRatio,n=i*this._checkSizeRatio;Ur.drawEllipse(this._currentMeasure.left+this._currentMeasure.width/2,this._currentMeasure.top+this._currentMeasure.height/2,r/2-this._thickness/2,n/2-this._thickness/2,e),e.fill()}e.restore()},i.prototype._onPointerDown=function(t,i,r,n,o){return!!e.prototype._onPointerDown.call(this,t,i,r,n,o)&&(this.isChecked||(this.isChecked=!0),!0)},i.AddRadioButtonWithHeader=function(e,t,r,n){var o=new jr;o.isVertical=!1,o.height="30px";var s=new i;s.width="20px",s.height="20px",s.isChecked=r,s.color="green",s.group=t,s.onIsCheckedChangedObservable.add((function(e){return n(s,e)})),o.addControl(s);var a=new Gr;return a.text=e,a.width="180px",a.paddingLeft="5px",a.textHorizontalAlignment=Ur.HORIZONTAL_ALIGNMENT_LEFT,a.color="white",o.addControl(a),o},i}(Ur);c.RegisteredTypes["BABYLON.GUI.RadioButton"]=sn;var an=function(e){function i(t){var i=e.call(this,t)||this;return i.name=t,i._thumbWidth=new Rr(20,Rr.UNITMODE_PIXEL,!1),i._minimum=0,i._maximum=100,i._value=50,i._isVertical=!1,i._barOffset=new Rr(5,Rr.UNITMODE_PIXEL,!1),i._isThumbClamped=!1,i._displayThumb=!0,i._step=0,i._lastPointerDownID=-1,i._effectiveBarOffset=0,i.onValueChangedObservable=new U,i._pointerIsDown=!1,i.isPointerBlocker=!0,i}return t(i,e),Object.defineProperty(i.prototype,"displayThumb",{get:function(){return this._displayThumb},set:function(e){this._displayThumb!==e&&(this._displayThumb=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"step",{get:function(){return this._step},set:function(e){this._step!==e&&(this._step=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"barOffset",{get:function(){return this._barOffset.toString(this._host)},set:function(e){this._barOffset.toString(this._host)!==e&&this._barOffset.fromString(e)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"barOffsetInPixels",{get:function(){return this._barOffset.getValueInPixel(this._host,this._cachedParentMeasure.width)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"thumbWidth",{get:function(){return this._thumbWidth.toString(this._host)},set:function(e){this._thumbWidth.toString(this._host)!==e&&this._thumbWidth.fromString(e)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"thumbWidthInPixels",{get:function(){return this._thumbWidth.getValueInPixel(this._host,this._cachedParentMeasure.width)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"minimum",{get:function(){return this._minimum},set:function(e){this._minimum!==e&&(this._minimum=e,this._markAsDirty(),this.value=Math.max(Math.min(this.value,this._maximum),this._minimum))},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"maximum",{get:function(){return this._maximum},set:function(e){this._maximum!==e&&(this._maximum=e,this._markAsDirty(),this.value=Math.max(Math.min(this.value,this._maximum),this._minimum))},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"value",{get:function(){return this._value},set:function(e){e=Math.max(Math.min(e,this._maximum),this._minimum),this._value!==e&&(this._value=e,this._markAsDirty(),this.onValueChangedObservable.notifyObservers(this._value))},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"isVertical",{get:function(){return this._isVertical},set:function(e){this._isVertical!==e&&(this._isVertical=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"isThumbClamped",{get:function(){return this._isThumbClamped},set:function(e){this._isThumbClamped!==e&&(this._isThumbClamped=e,this._markAsDirty())},enumerable:!1,configurable:!0}),i.prototype._getTypeName=function(){return"BaseSlider"},i.prototype._getThumbPosition=function(){return this.isVertical?(this.maximum-this.value)/(this.maximum-this.minimum)*this._backgroundBoxLength:(this.value-this.minimum)/(this.maximum-this.minimum)*this._backgroundBoxLength},i.prototype._getThumbThickness=function(e){var t=0;switch(e){case"circle":t=this._thumbWidth.isPixel?Math.max(this._thumbWidth.getValue(this._host),this._backgroundBoxThickness):this._backgroundBoxThickness*this._thumbWidth.getValue(this._host);break;case"rectangle":t=this._thumbWidth.isPixel?Math.min(this._thumbWidth.getValue(this._host),this._backgroundBoxThickness):this._backgroundBoxThickness*this._thumbWidth.getValue(this._host)}return t},i.prototype._prepareRenderingData=function(e){this._effectiveBarOffset=0,this._renderLeft=this._currentMeasure.left,this._renderTop=this._currentMeasure.top,this._renderWidth=this._currentMeasure.width,this._renderHeight=this._currentMeasure.height,this._backgroundBoxLength=Math.max(this._currentMeasure.width,this._currentMeasure.height),this._backgroundBoxThickness=Math.min(this._currentMeasure.width,this._currentMeasure.height),this._effectiveThumbThickness=this._getThumbThickness(e),this.displayThumb&&(this._backgroundBoxLength-=this._effectiveThumbThickness),this.isVertical&&this._currentMeasure.height<this._currentMeasure.width||(this._barOffset.isPixel?this._effectiveBarOffset=Math.min(this._barOffset.getValue(this._host),this._backgroundBoxThickness):this._effectiveBarOffset=this._backgroundBoxThickness*this._barOffset.getValue(this._host),this._backgroundBoxThickness-=2*this._effectiveBarOffset,this.isVertical?(this._renderLeft+=this._effectiveBarOffset,!this.isThumbClamped&&this.displayThumb&&(this._renderTop+=this._effectiveThumbThickness/2),this._renderHeight=this._backgroundBoxLength,this._renderWidth=this._backgroundBoxThickness):(this._renderTop+=this._effectiveBarOffset,!this.isThumbClamped&&this.displayThumb&&(this._renderLeft+=this._effectiveThumbThickness/2),this._renderHeight=this._backgroundBoxThickness,this._renderWidth=this._backgroundBoxLength))},i.prototype._updateValueFromPointer=function(e,t){var i;0!=this.rotation&&(this._invertTransformMatrix.transformCoordinates(e,t,this._transformedPosition),e=this._transformedPosition.x,t=this._transformedPosition.y),i=this._isVertical?this._minimum+(1-(t-this._currentMeasure.top)/this._currentMeasure.height)*(this._maximum-this._minimum):this._minimum+(e-this._currentMeasure.left)/this._currentMeasure.width*(this._maximum-this._minimum);var r=1/this._step|0;this.value=this._step?(i*r|0)/r:i},i.prototype._onPointerDown=function(t,i,r,n,o){return!!e.prototype._onPointerDown.call(this,t,i,r,n,o)&&(this._pointerIsDown=!0,this._updateValueFromPointer(i.x,i.y),this._host._capturingControl[r]=this,this._lastPointerDownID=r,!0)},i.prototype._onPointerMove=function(t,i,r,n){r==this._lastPointerDownID&&(this._pointerIsDown&&this._updateValueFromPointer(i.x,i.y),e.prototype._onPointerMove.call(this,t,i,r,n))},i.prototype._onPointerUp=function(t,i,r,n,o){this._pointerIsDown=!1,delete this._host._capturingControl[r],e.prototype._onPointerUp.call(this,t,i,r,n,o)},i.prototype._onCanvasBlur=function(){this._forcePointerUp(),e.prototype._onCanvasBlur.call(this)},i}(Ur),hn=function(e){function i(t){var i=e.call(this,t)||this;return i.name=t,i._background="black",i._borderColor="white",i._thumbColor="",i._isThumbCircle=!1,i._displayValueBar=!0,i}return t(i,e),Object.defineProperty(i.prototype,"displayValueBar",{get:function(){return this._displayValueBar},set:function(e){this._displayValueBar!==e&&(this._displayValueBar=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"borderColor",{get:function(){return this._borderColor},set:function(e){this._borderColor!==e&&(this._borderColor=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"background",{get:function(){return this._background},set:function(e){this._background!==e&&(this._background=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"thumbColor",{get:function(){return this._thumbColor},set:function(e){this._thumbColor!==e&&(this._thumbColor=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"isThumbCircle",{get:function(){return this._isThumbCircle},set:function(e){this._isThumbCircle!==e&&(this._isThumbCircle=e,this._markAsDirty())},enumerable:!1,configurable:!0}),i.prototype._getTypeName=function(){return"Slider"},i.prototype._draw=function(e,t){e.save(),this._applyStates(e),this._prepareRenderingData(this.isThumbCircle?"circle":"rectangle");var i=this._renderLeft,r=this._renderTop,n=this._renderWidth,o=this._renderHeight,s=0;this.isThumbClamped&&this.isThumbCircle?(this.isVertical?r+=this._effectiveThumbThickness/2:i+=this._effectiveThumbThickness/2,s=this._backgroundBoxThickness/2):s=(this._effectiveThumbThickness-this._effectiveBarOffset)/2,(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY);var a=this._getThumbPosition();e.fillStyle=this._background,this.isVertical?this.isThumbClamped?this.isThumbCircle?(e.beginPath(),e.arc(i+this._backgroundBoxThickness/2,r,s,Math.PI,2*Math.PI),e.fill(),e.fillRect(i,r,n,o)):e.fillRect(i,r,n,o+this._effectiveThumbThickness):e.fillRect(i,r,n,o):this.isThumbClamped?this.isThumbCircle?(e.beginPath(),e.arc(i+this._backgroundBoxLength,r+this._backgroundBoxThickness/2,s,0,2*Math.PI),e.fill(),e.fillRect(i,r,n,o)):e.fillRect(i,r,n+this._effectiveThumbThickness,o):e.fillRect(i,r,n,o),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0),e.fillStyle=this.color,this._displayValueBar&&(this.isVertical?this.isThumbClamped?this.isThumbCircle?(e.beginPath(),e.arc(i+this._backgroundBoxThickness/2,r+this._backgroundBoxLength,s,0,2*Math.PI),e.fill(),e.fillRect(i,r+a,n,o-a)):e.fillRect(i,r+a,n,o-a+this._effectiveThumbThickness):e.fillRect(i,r+a,n,o-a):this.isThumbClamped&&this.isThumbCircle?(e.beginPath(),e.arc(i,r+this._backgroundBoxThickness/2,s,0,2*Math.PI),e.fill(),e.fillRect(i,r,a,o)):e.fillRect(i,r,a,o)),e.fillStyle=this._thumbColor||this.color,this.displayThumb&&((this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY),this._isThumbCircle?(e.beginPath(),this.isVertical?e.arc(i+this._backgroundBoxThickness/2,r+a,s,0,2*Math.PI):e.arc(i+a,r+this._backgroundBoxThickness/2,s,0,2*Math.PI),e.fill(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0),e.strokeStyle=this._borderColor,e.stroke()):(this.isVertical?e.fillRect(i-this._effectiveBarOffset,this._currentMeasure.top+a,this._currentMeasure.width,this._effectiveThumbThickness):e.fillRect(this._currentMeasure.left+a,this._currentMeasure.top,this._effectiveThumbThickness,this._currentMeasure.height),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0),e.strokeStyle=this._borderColor,this.isVertical?e.strokeRect(i-this._effectiveBarOffset,this._currentMeasure.top+a,this._currentMeasure.width,this._effectiveThumbThickness):e.strokeRect(this._currentMeasure.left+a,this._currentMeasure.top,this._effectiveThumbThickness,this._currentMeasure.height))),e.restore()},i}(an);c.RegisteredTypes["BABYLON.GUI.Slider"]=hn;var un=function(){function e(e){this.name=e,this._groupPanel=new jr,this._selectors=new Array,this._groupPanel.verticalAlignment=Ur.VERTICAL_ALIGNMENT_TOP,this._groupPanel.horizontalAlignment=Ur.HORIZONTAL_ALIGNMENT_LEFT,this._groupHeader=this._addGroupHeader(e)}return Object.defineProperty(e.prototype,"groupPanel",{get:function(){return this._groupPanel},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"selectors",{get:function(){return this._selectors},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"header",{get:function(){return this._groupHeader.text},set:function(e){"label"!==this._groupHeader.text&&(this._groupHeader.text=e)},enumerable:!1,configurable:!0}),e.prototype._addGroupHeader=function(e){var t=new Gr("groupHead",e);return t.width=.9,t.height="30px",t.textWrapping=!0,t.color="black",t.horizontalAlignment=Ur.HORIZONTAL_ALIGNMENT_LEFT,t.textHorizontalAlignment=Ur.HORIZONTAL_ALIGNMENT_LEFT,t.left="2px",this._groupPanel.addControl(t),t},e.prototype._getSelector=function(e){if(!(e<0||e>=this._selectors.length))return this._selectors[e]},e.prototype.removeSelector=function(e){e<0||e>=this._selectors.length||(this._groupPanel.removeControl(this._selectors[e]),this._selectors.splice(e,1))},e}(),ln=(function(e){function i(){return null!==e&&e.apply(this,arguments)||this}t(i,e),i.prototype.addCheckbox=function(e,t,i){void 0===t&&(t=function(e){}),void 0===i&&(i=!1);i=i||!1;var r=new Kr;r.width="20px",r.height="20px",r.color="#364249",r.background="#CCCCCC",r.horizontalAlignment=Ur.HORIZONTAL_ALIGNMENT_LEFT,r.onIsCheckedChangedObservable.add((function(e){t(e)}));var n=Ur.AddHeader(r,e,"200px",{isHorizontal:!0,controlFirst:!0});n.height="30px",n.horizontalAlignment=Ur.HORIZONTAL_ALIGNMENT_LEFT,n.left="4px",this.groupPanel.addControl(n),this.selectors.push(n),r.isChecked=i,this.groupPanel.parent&&this.groupPanel.parent.parent&&(r.color=this.groupPanel.parent.parent.buttonColor,r.background=this.groupPanel.parent.parent.buttonBackground)},i.prototype._setSelectorLabel=function(e,t){this.selectors[e].children[1].text=t},i.prototype._setSelectorLabelColor=function(e,t){this.selectors[e].children[1].color=t},i.prototype._setSelectorButtonColor=function(e,t){this.selectors[e].children[0].color=t},i.prototype._setSelectorButtonBackground=function(e,t){this.selectors[e].children[0].background=t}}(un),function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t._selectNb=0,t}t(i,e),i.prototype.addRadio=function(e,t,i){void 0===t&&(t=function(e){}),void 0===i&&(i=!1);var r=this._selectNb++,n=new sn;n.name=e,n.width="20px",n.height="20px",n.color="#364249",n.background="#CCCCCC",n.group=this.name,n.horizontalAlignment=Ur.HORIZONTAL_ALIGNMENT_LEFT,n.onIsCheckedChangedObservable.add((function(e){e&&t(r)}));var o=Ur.AddHeader(n,e,"200px",{isHorizontal:!0,controlFirst:!0});o.height="30px",o.horizontalAlignment=Ur.HORIZONTAL_ALIGNMENT_LEFT,o.left="4px",this.groupPanel.addControl(o),this.selectors.push(o),n.isChecked=i,this.groupPanel.parent&&this.groupPanel.parent.parent&&(n.color=this.groupPanel.parent.parent.buttonColor,n.background=this.groupPanel.parent.parent.buttonBackground)},i.prototype._setSelectorLabel=function(e,t){this.selectors[e].children[1].text=t},i.prototype._setSelectorLabelColor=function(e,t){this.selectors[e].children[1].color=t},i.prototype._setSelectorButtonColor=function(e,t){this.selectors[e].children[0].color=t},i.prototype._setSelectorButtonBackground=function(e,t){this.selectors[e].children[0].background=t}}(un),function(e){function i(){return null!==e&&e.apply(this,arguments)||this}t(i,e),i.prototype.addSlider=function(e,t,i,r,n,o,s){void 0===t&&(t=function(e){}),void 0===i&&(i="Units"),void 0===r&&(r=0),void 0===n&&(n=0),void 0===o&&(o=0),void 0===s&&(s=function(e){return 0|e});var a=new hn;a.name=i,a.value=o,a.minimum=r,a.maximum=n,a.width=.9,a.height="20px",a.color="#364249",a.background="#CCCCCC",a.borderColor="black",a.horizontalAlignment=Ur.HORIZONTAL_ALIGNMENT_LEFT,a.left="4px",a.paddingBottom="4px",a.onValueChangedObservable.add((function(e){a.parent.children[0].text=a.parent.children[0].name+": "+s(e)+" "+a.name,t(e)}));var h=Ur.AddHeader(a,e+": "+s(o)+" "+i,"30px",{isHorizontal:!1,controlFirst:!1});h.height="60px",h.horizontalAlignment=Ur.HORIZONTAL_ALIGNMENT_LEFT,h.left="4px",h.children[0].name=e,this.groupPanel.addControl(h),this.selectors.push(h),this.groupPanel.parent&&this.groupPanel.parent.parent&&(a.color=this.groupPanel.parent.parent.buttonColor,a.background=this.groupPanel.parent.parent.buttonBackground)},i.prototype._setSelectorLabel=function(e,t){this.selectors[e].children[0].name=t,this.selectors[e].children[0].text=t+": "+this.selectors[e].children[1].value+" "+this.selectors[e].children[1].name},i.prototype._setSelectorLabelColor=function(e,t){this.selectors[e].children[0].color=t},i.prototype._setSelectorButtonColor=function(e,t){this.selectors[e].children[1].color=t},i.prototype._setSelectorButtonBackground=function(e,t){this.selectors[e].children[1].background=t}}(un),function(e){function i(t,i){void 0===i&&(i=[]);var r=e.call(this,t)||this;if(r.name=t,r.groups=i,r._buttonColor="#364249",r._buttonBackground="#CCCCCC",r._headerColor="black",r._barColor="white",r._barHeight="2px",r._spacerHeight="20px",r._bars=new Array,r._groups=i,r.thickness=2,r._panel=new jr,r._panel.verticalAlignment=Ur.VERTICAL_ALIGNMENT_TOP,r._panel.horizontalAlignment=Ur.HORIZONTAL_ALIGNMENT_LEFT,r._panel.top=5,r._panel.left=5,r._panel.width=.95,i.length>0){for(var n=0;n<i.length-1;n++)r._panel.addControl(i[n].groupPanel),r._addSpacer();r._panel.addControl(i[i.length-1].groupPanel)}return r.addControl(r._panel),r}t(i,e),i.prototype._getTypeName=function(){return"SelectionPanel"},Object.defineProperty(i.prototype,"panel",{get:function(){return this._panel},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"headerColor",{get:function(){return this._headerColor},set:function(e){this._headerColor!==e&&(this._headerColor=e,this._setHeaderColor())},enumerable:!1,configurable:!0}),i.prototype._setHeaderColor=function(){for(var e=0;e<this._groups.length;e++)this._groups[e].groupPanel.children[0].color=this._headerColor},Object.defineProperty(i.prototype,"buttonColor",{get:function(){return this._buttonColor},set:function(e){this._buttonColor!==e&&(this._buttonColor=e,this._setbuttonColor())},enumerable:!1,configurable:!0}),i.prototype._setbuttonColor=function(){for(var e=0;e<this._groups.length;e++)for(var t=0;t<this._groups[e].selectors.length;t++)this._groups[e]._setSelectorButtonColor(t,this._buttonColor)},Object.defineProperty(i.prototype,"labelColor",{get:function(){return this._labelColor},set:function(e){this._labelColor!==e&&(this._labelColor=e,this._setLabelColor())},enumerable:!1,configurable:!0}),i.prototype._setLabelColor=function(){for(var e=0;e<this._groups.length;e++)for(var t=0;t<this._groups[e].selectors.length;t++)this._groups[e]._setSelectorLabelColor(t,this._labelColor)},Object.defineProperty(i.prototype,"buttonBackground",{get:function(){return this._buttonBackground},set:function(e){this._buttonBackground!==e&&(this._buttonBackground=e,this._setButtonBackground())},enumerable:!1,configurable:!0}),i.prototype._setButtonBackground=function(){for(var e=0;e<this._groups.length;e++)for(var t=0;t<this._groups[e].selectors.length;t++)this._groups[e]._setSelectorButtonBackground(t,this._buttonBackground)},Object.defineProperty(i.prototype,"barColor",{get:function(){return this._barColor},set:function(e){this._barColor!==e&&(this._barColor=e,this._setBarColor())},enumerable:!1,configurable:!0}),i.prototype._setBarColor=function(){for(var e=0;e<this._bars.length;e++)this._bars[e].children[0].background=this._barColor},Object.defineProperty(i.prototype,"barHeight",{get:function(){return this._barHeight},set:function(e){this._barHeight!==e&&(this._barHeight=e,this._setBarHeight())},enumerable:!1,configurable:!0}),i.prototype._setBarHeight=function(){for(var e=0;e<this._bars.length;e++)this._bars[e].children[0].height=this._barHeight},Object.defineProperty(i.prototype,"spacerHeight",{get:function(){return this._spacerHeight},set:function(e){this._spacerHeight!==e&&(this._spacerHeight=e,this._setSpacerHeight())},enumerable:!1,configurable:!0}),i.prototype._setSpacerHeight=function(){for(var e=0;e<this._bars.length;e++)this._bars[e].height=this._spacerHeight},i.prototype._addSpacer=function(){var e=new Vr;e.width=1,e.height=this._spacerHeight,e.horizontalAlignment=Ur.HORIZONTAL_ALIGNMENT_LEFT;var t=new zr;t.width=1,t.height=this._barHeight,t.horizontalAlignment=Ur.HORIZONTAL_ALIGNMENT_LEFT,t.verticalAlignment=Ur.VERTICAL_ALIGNMENT_CENTER,t.background=this._barColor,t.color="transparent",e.addControl(t),this._panel.addControl(e),this._bars.push(e)},i.prototype.addGroup=function(e){this._groups.length>0&&this._addSpacer(),this._panel.addControl(e.groupPanel),this._groups.push(e),e.groupPanel.children[0].color=this._headerColor;for(var t=0;t<e.selectors.length;t++)e._setSelectorButtonColor(t,this._buttonColor),e._setSelectorButtonBackground(t,this._buttonBackground)},i.prototype.removeGroup=function(e){if(!(e<0||e>=this._groups.length)){var t=this._groups[e];this._panel.removeControl(t.groupPanel),this._groups.splice(e,1),e<this._bars.length&&(this._panel.removeControl(this._bars[e]),this._bars.splice(e,1))}},i.prototype.setHeaderName=function(e,t){t<0||t>=this._groups.length||(this._groups[t].groupPanel.children[0].text=e)},i.prototype.relabel=function(e,t,i){if(!(t<0||t>=this._groups.length)){var r=this._groups[t];i<0||i>=r.selectors.length||r._setSelectorLabel(i,e)}},i.prototype.removeFromGroupSelector=function(e,t){if(!(e<0||e>=this._groups.length)){var i=this._groups[e];t<0||t>=i.selectors.length||i.removeSelector(t)}},i.prototype.addToGroupCheckbox=function(e,t,i,r){(void 0===i&&(i=function(){}),void 0===r&&(r=!1),e<0||e>=this._groups.length)||this._groups[e].addCheckbox(t,i,r)},i.prototype.addToGroupRadio=function(e,t,i,r){(void 0===i&&(i=function(){}),void 0===r&&(r=!1),e<0||e>=this._groups.length)||this._groups[e].addRadio(t,i,r)},i.prototype.addToGroupSlider=function(e,t,i,r,n,o,s,a){(void 0===i&&(i=function(){}),void 0===r&&(r="Units"),void 0===n&&(n=0),void 0===o&&(o=0),void 0===s&&(s=0),void 0===a&&(a=function(e){return 0|e}),e<0||e>=this._groups.length)||this._groups[e].addSlider(t,i,r,n,o,s,a)}}(zr),function(e){function i(t){var i=e.call(this,t)||this;return i._freezeControls=!1,i._bucketWidth=0,i._bucketHeight=0,i._buckets={},i}return t(i,e),Object.defineProperty(i.prototype,"freezeControls",{get:function(){return this._freezeControls},set:function(e){if(this._freezeControls!==e){e||this._restoreMeasures(),this._freezeControls=!1;var t=this.host.getSize(),i=t.width,r=t.height,n=this.host.getContext(),o=new Nr(0,0,i,r);this.host._numLayoutCalls=0,this.host._rootContainer._layout(o,n),e&&(this._updateMeasures(),this._useBuckets()&&this._makeBuckets()),this._freezeControls=e,this.host.markAsDirty()}},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"bucketWidth",{get:function(){return this._bucketWidth},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"bucketHeight",{get:function(){return this._bucketHeight},enumerable:!1,configurable:!0}),i.prototype.setBucketSizes=function(e,t){this._bucketWidth=e,this._bucketHeight=t,this._useBuckets()?this._freezeControls&&this._makeBuckets():this._buckets={}},i.prototype._useBuckets=function(){return this._bucketWidth>0&&this._bucketHeight>0},i.prototype._makeBuckets=function(){this._buckets={},this._bucketLen=Math.ceil(this.widthInPixels/this._bucketWidth),this._dispatchInBuckets(this._children),this._oldLeft=null,this._oldTop=null},i.prototype._dispatchInBuckets=function(e){for(var t=0;t<e.length;++t){for(var i=e[t],r=Math.max(0,Math.floor((i._customData._origLeft-this._customData.origLeft)/this._bucketWidth)),n=Math.floor((i._customData._origLeft-this._customData.origLeft+i._currentMeasure.width-1)/this._bucketWidth),o=Math.max(0,Math.floor((i._customData._origTop-this._customData.origTop)/this._bucketHeight)),s=Math.floor((i._customData._origTop-this._customData.origTop+i._currentMeasure.height-1)/this._bucketHeight);o<=s;){for(var a=r;a<=n;++a){var h=o*this._bucketLen+a,u=this._buckets[h];u||(u=[],this._buckets[h]=u),u.push(i)}o++}i instanceof Vr&&i._children.length>0&&this._dispatchInBuckets(i._children)}},i.prototype._updateMeasures=function(){var e=0|this.leftInPixels,t=0|this.topInPixels;this._measureForChildren.left-=e,this._measureForChildren.top-=t,this._currentMeasure.left-=e,this._currentMeasure.top-=t,this._customData.origLeftForChildren=this._measureForChildren.left,this._customData.origTopForChildren=this._measureForChildren.top,this._customData.origLeft=this._currentMeasure.left,this._customData.origTop=this._currentMeasure.top,this._updateChildrenMeasures(this._children,e,t)},i.prototype._updateChildrenMeasures=function(e,t,i){for(var r=0;r<e.length;++r){var n=e[r];n._currentMeasure.left-=t,n._currentMeasure.top-=i,n._customData._origLeft=n._currentMeasure.left,n._customData._origTop=n._currentMeasure.top,n instanceof Vr&&n._children.length>0&&this._updateChildrenMeasures(n._children,t,i)}},i.prototype._restoreMeasures=function(){var e=0|this.leftInPixels,t=0|this.topInPixels;this._measureForChildren.left=this._customData.origLeftForChildren+e,this._measureForChildren.top=this._customData.origTopForChildren+t,this._currentMeasure.left=this._customData.origLeft+e,this._currentMeasure.top=this._customData.origTop+t},i.prototype._getTypeName=function(){return"ScrollViewerWindow"},i.prototype._additionalProcessing=function(t,i){e.prototype._additionalProcessing.call(this,t,i),this._parentMeasure=t,this._measureForChildren.left=this._currentMeasure.left,this._measureForChildren.top=this._currentMeasure.top,this._measureForChildren.width=t.width,this._measureForChildren.height=t.height},i.prototype._layout=function(t,i){return this._freezeControls?(this.invalidateRect(),!1):e.prototype._layout.call(this,t,i)},i.prototype._scrollChildren=function(e,t,i){for(var r=0;r<e.length;++r){var n=e[r];n._currentMeasure.left=n._customData._origLeft+t,n._currentMeasure.top=n._customData._origTop+i,n._isClipped=!1,n instanceof Vr&&n._children.length>0&&this._scrollChildren(n._children,t,i)}},i.prototype._scrollChildrenWithBuckets=function(e,t,i,r){for(var n=Math.max(0,Math.floor(-e/this._bucketWidth)),o=Math.floor((-e+this._parentMeasure.width-1)/this._bucketWidth),s=Math.max(0,Math.floor(-t/this._bucketHeight)),a=Math.floor((-t+this._parentMeasure.height-1)/this._bucketHeight);s<=a;){for(var h=n;h<=o;++h){var u=s*this._bucketLen+h,l=this._buckets[u];if(l)for(var c=0;c<l.length;++c){var f=l[c];f._currentMeasure.left=f._customData._origLeft+i,f._currentMeasure.top=f._customData._origTop+r,f._isClipped=!1}}s++}},i.prototype._draw=function(t,i){if(this._freezeControls){this._localDraw(t),this.clipChildren&&this._clipForChildren(t);var r=0|this.leftInPixels,n=0|this.topInPixels;this._useBuckets()&&null!==this._oldLeft&&null!==this._oldTop?(this._scrollChildrenWithBuckets(this._oldLeft,this._oldTop,r,n),this._scrollChildrenWithBuckets(r,n,r,n)):this._scrollChildren(this._children,r,n),this._oldLeft=r,this._oldTop=n;for(var o=0,s=this._children;o<s.length;o++){var a=s[o];a._intersectsRect(this._parentMeasure)&&a._render(t,this._parentMeasure)}}else e.prototype._draw.call(this,t,i)},i.prototype._postMeasure=function(){if(this._freezeControls)e.prototype._postMeasure.call(this);else{for(var t=this.parentClientWidth,i=this.parentClientHeight,r=0,n=this.children;r<n.length;r++){var o=n[r];o.isVisible&&!o.notRenderable&&(o.horizontalAlignment===Ur.HORIZONTAL_ALIGNMENT_CENTER&&o._offsetLeft(this._currentMeasure.left-o._currentMeasure.left),o.verticalAlignment===Ur.VERTICAL_ALIGNMENT_CENTER&&o._offsetTop(this._currentMeasure.top-o._currentMeasure.top),t=Math.max(t,o._currentMeasure.left-this._currentMeasure.left+o._currentMeasure.width+o.paddingRightInPixels),i=Math.max(i,o._currentMeasure.top-this._currentMeasure.top+o._currentMeasure.height+o.paddingBottomInPixels))}this._currentMeasure.width!==t&&(this._width.updateInPlace(t,Rr.UNITMODE_PIXEL),this._currentMeasure.width=t,this._rebuildLayout=!0,this._isDirty=!0),this._currentMeasure.height!==i&&(this._height.updateInPlace(i,Rr.UNITMODE_PIXEL),this._currentMeasure.height=i,this._rebuildLayout=!0,this._isDirty=!0),e.prototype._postMeasure.call(this)}},i}(Vr)),cn=function(e){function i(t){var i=e.call(this,t)||this;return i.name=t,i._background="black",i._borderColor="white",i._tempMeasure=new Nr(0,0,0,0),i}return t(i,e),Object.defineProperty(i.prototype,"borderColor",{get:function(){return this._borderColor},set:function(e){this._borderColor!==e&&(this._borderColor=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"background",{get:function(){return this._background},set:function(e){this._background!==e&&(this._background=e,this._markAsDirty())},enumerable:!1,configurable:!0}),i.prototype._getTypeName=function(){return"Scrollbar"},i.prototype._getThumbThickness=function(){return this._thumbWidth.isPixel?this._thumbWidth.getValue(this._host):this._backgroundBoxThickness*this._thumbWidth.getValue(this._host)},i.prototype._draw=function(e){e.save(),this._applyStates(e),this._prepareRenderingData("rectangle");var t=this._renderLeft,i=this._getThumbPosition();e.fillStyle=this._background,e.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height),e.fillStyle=this.color,this.isVertical?(this._tempMeasure.left=t-this._effectiveBarOffset,this._tempMeasure.top=this._currentMeasure.top+i,this._tempMeasure.width=this._currentMeasure.width,this._tempMeasure.height=this._effectiveThumbThickness):(this._tempMeasure.left=this._currentMeasure.left+i,this._tempMeasure.top=this._currentMeasure.top,this._tempMeasure.width=this._effectiveThumbThickness,this._tempMeasure.height=this._currentMeasure.height),e.fillRect(this._tempMeasure.left,this._tempMeasure.top,this._tempMeasure.width,this._tempMeasure.height),e.restore()},i.prototype._updateValueFromPointer=function(e,t){0!=this.rotation&&(this._invertTransformMatrix.transformCoordinates(e,t,this._transformedPosition),e=this._transformedPosition.x,t=this._transformedPosition.y),this._first&&(this._first=!1,this._originX=e,this._originY=t,(e<this._tempMeasure.left||e>this._tempMeasure.left+this._tempMeasure.width||t<this._tempMeasure.top||t>this._tempMeasure.top+this._tempMeasure.height)&&(this.isVertical?this.value=this.minimum+(1-(t-this._currentMeasure.top)/this._currentMeasure.height)*(this.maximum-this.minimum):this.value=this.minimum+(e-this._currentMeasure.left)/this._currentMeasure.width*(this.maximum-this.minimum)));var i=0;i=this.isVertical?-(t-this._originY)/(this._currentMeasure.height-this._effectiveThumbThickness):(e-this._originX)/(this._currentMeasure.width-this._effectiveThumbThickness),this.value+=i*(this.maximum-this.minimum),this._originX=e,this._originY=t},i.prototype._onPointerDown=function(t,i,r,n,o){return this._first=!0,e.prototype._onPointerDown.call(this,t,i,r,n,o)},i}(an),fn=function(e){function i(t){var i=e.call(this,t)||this;return i.name=t,i._thumbLength=.5,i._thumbHeight=1,i._barImageHeight=1,i._tempMeasure=new Nr(0,0,0,0),i.num90RotationInVerticalMode=1,i}return t(i,e),Object.defineProperty(i.prototype,"backgroundImage",{get:function(){return this._backgroundBaseImage},set:function(e){var t=this;this._backgroundBaseImage!==e&&(this._backgroundBaseImage=e,this.isVertical&&0!==this.num90RotationInVerticalMode?e.isLoaded?(this._backgroundImage=e._rotate90(this.num90RotationInVerticalMode,!0),this._markAsDirty()):e.onImageLoadedObservable.addOnce((function(){var i=e._rotate90(t.num90RotationInVerticalMode,!0);t._backgroundImage=i,i.isLoaded||i.onImageLoadedObservable.addOnce((function(){t._markAsDirty()})),t._markAsDirty()})):(this._backgroundImage=e,e&&!e.isLoaded&&e.onImageLoadedObservable.addOnce((function(){t._markAsDirty()})),this._markAsDirty()))},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"thumbImage",{get:function(){return this._thumbBaseImage},set:function(e){var t=this;this._thumbBaseImage!==e&&(this._thumbBaseImage=e,this.isVertical&&0!==this.num90RotationInVerticalMode?e.isLoaded?(this._thumbImage=e._rotate90(-this.num90RotationInVerticalMode,!0),this._markAsDirty()):e.onImageLoadedObservable.addOnce((function(){var i=e._rotate90(-t.num90RotationInVerticalMode,!0);t._thumbImage=i,i.isLoaded||i.onImageLoadedObservable.addOnce((function(){t._markAsDirty()})),t._markAsDirty()})):(this._thumbImage=e,e&&!e.isLoaded&&e.onImageLoadedObservable.addOnce((function(){t._markAsDirty()})),this._markAsDirty()))},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"thumbLength",{get:function(){return this._thumbLength},set:function(e){this._thumbLength!==e&&(this._thumbLength=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"thumbHeight",{get:function(){return this._thumbHeight},set:function(e){this._thumbLength!==e&&(this._thumbHeight=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"barImageHeight",{get:function(){return this._barImageHeight},set:function(e){this._barImageHeight!==e&&(this._barImageHeight=e,this._markAsDirty())},enumerable:!1,configurable:!0}),i.prototype._getTypeName=function(){return"ImageScrollBar"},i.prototype._getThumbThickness=function(){return this._thumbWidth.isPixel?this._thumbWidth.getValue(this._host):this._backgroundBoxThickness*this._thumbWidth.getValue(this._host)},i.prototype._draw=function(e){e.save(),this._applyStates(e),this._prepareRenderingData("rectangle");var t=this._getThumbPosition(),i=this._renderLeft,r=this._renderTop,n=this._renderWidth,o=this._renderHeight;this._backgroundImage&&(this._tempMeasure.copyFromFloats(i,r,n,o),this.isVertical?(this._tempMeasure.copyFromFloats(i+n*(1-this._barImageHeight)*.5,this._currentMeasure.top,n*this._barImageHeight,o),this._tempMeasure.height+=this._effectiveThumbThickness,this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure)):(this._tempMeasure.copyFromFloats(this._currentMeasure.left,r+o*(1-this._barImageHeight)*.5,n,o*this._barImageHeight),this._tempMeasure.width+=this._effectiveThumbThickness,this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure)),this._backgroundImage._draw(e)),this.isVertical?this._tempMeasure.copyFromFloats(i-this._effectiveBarOffset+this._currentMeasure.width*(1-this._thumbHeight)*.5,this._currentMeasure.top+t,this._currentMeasure.width*this._thumbHeight,this._effectiveThumbThickness):this._tempMeasure.copyFromFloats(this._currentMeasure.left+t,this._currentMeasure.top+this._currentMeasure.height*(1-this._thumbHeight)*.5,this._effectiveThumbThickness,this._currentMeasure.height*this._thumbHeight),this._thumbImage&&(this._thumbImage._currentMeasure.copyFrom(this._tempMeasure),this._thumbImage._draw(e)),e.restore()},i.prototype._updateValueFromPointer=function(e,t){0!=this.rotation&&(this._invertTransformMatrix.transformCoordinates(e,t,this._transformedPosition),e=this._transformedPosition.x,t=this._transformedPosition.y),this._first&&(this._first=!1,this._originX=e,this._originY=t,(e<this._tempMeasure.left||e>this._tempMeasure.left+this._tempMeasure.width||t<this._tempMeasure.top||t>this._tempMeasure.top+this._tempMeasure.height)&&(this.isVertical?this.value=this.minimum+(1-(t-this._currentMeasure.top)/this._currentMeasure.height)*(this.maximum-this.minimum):this.value=this.minimum+(e-this._currentMeasure.left)/this._currentMeasure.width*(this.maximum-this.minimum)));var i=0;i=this.isVertical?-(t-this._originY)/(this._currentMeasure.height-this._effectiveThumbThickness):(e-this._originX)/(this._currentMeasure.width-this._effectiveThumbThickness),this.value+=i*(this.maximum-this.minimum),this._originX=e,this._originY=t},i.prototype._onPointerDown=function(t,i,r,n,o){return this._first=!0,e.prototype._onPointerDown.call(this,t,i,r,n,o)},i}(an),dn=function(e){function i(t,i){var r=e.call(this,t)||this;return r._barSize=20,r._pointerIsOver=!1,r._wheelPrecision=.05,r._thumbLength=.5,r._thumbHeight=1,r._barImageHeight=1,r._horizontalBarImageHeight=1,r._verticalBarImageHeight=1,r._oldWindowContentsWidth=0,r._oldWindowContentsHeight=0,r._forceHorizontalBar=!1,r._forceVerticalBar=!1,r._useImageBar=i||!1,r.onDirtyObservable.add((function(){r._horizontalBarSpace.color=r.color,r._verticalBarSpace.color=r.color,r._dragSpace.color=r.color})),r.onPointerEnterObservable.add((function(){r._pointerIsOver=!0})),r.onPointerOutObservable.add((function(){r._pointerIsOver=!1})),r._grid=new Jr,r._useImageBar?(r._horizontalBar=new fn,r._verticalBar=new fn):(r._horizontalBar=new cn,r._verticalBar=new cn),r._window=new ln("scrollViewer_window"),r._window.horizontalAlignment=Ur.HORIZONTAL_ALIGNMENT_LEFT,r._window.verticalAlignment=Ur.VERTICAL_ALIGNMENT_TOP,r._grid.addColumnDefinition(1),r._grid.addColumnDefinition(0,!0),r._grid.addRowDefinition(1),r._grid.addRowDefinition(0,!0),e.prototype.addControl.call(r,r._grid),r._grid.addControl(r._window,0,0),r._verticalBarSpace=new zr,r._verticalBarSpace.horizontalAlignment=Ur.HORIZONTAL_ALIGNMENT_LEFT,r._verticalBarSpace.verticalAlignment=Ur.VERTICAL_ALIGNMENT_TOP,r._verticalBarSpace.thickness=1,r._grid.addControl(r._verticalBarSpace,0,1),r._addBar(r._verticalBar,r._verticalBarSpace,!0,Math.PI),r._horizontalBarSpace=new zr,r._horizontalBarSpace.horizontalAlignment=Ur.HORIZONTAL_ALIGNMENT_LEFT,r._horizontalBarSpace.verticalAlignment=Ur.VERTICAL_ALIGNMENT_TOP,r._horizontalBarSpace.thickness=1,r._grid.addControl(r._horizontalBarSpace,1,0),r._addBar(r._horizontalBar,r._horizontalBarSpace,!1,0),r._dragSpace=new zr,r._dragSpace.thickness=1,r._grid.addControl(r._dragSpace,1,1),r._useImageBar||(r.barColor="grey",r.barBackground="transparent"),r}return t(i,e),Object.defineProperty(i.prototype,"horizontalBar",{get:function(){return this._horizontalBar},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"verticalBar",{get:function(){return this._verticalBar},enumerable:!1,configurable:!0}),i.prototype.addControl=function(e){return e?(this._window.addControl(e),this):this},i.prototype.removeControl=function(e){return this._window.removeControl(e),this},Object.defineProperty(i.prototype,"children",{get:function(){return this._window.children},enumerable:!1,configurable:!0}),i.prototype._flagDescendantsAsMatrixDirty=function(){for(var e=0,t=this._children;e<t.length;e++){t[e]._markMatrixAsDirty()}},Object.defineProperty(i.prototype,"freezeControls",{get:function(){return this._window.freezeControls},set:function(e){this._window.freezeControls=e},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"bucketWidth",{get:function(){return this._window.bucketWidth},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"bucketHeight",{get:function(){return this._window.bucketHeight},enumerable:!1,configurable:!0}),i.prototype.setBucketSizes=function(e,t){this._window.setBucketSizes(e,t)},Object.defineProperty(i.prototype,"forceHorizontalBar",{get:function(){return this._forceHorizontalBar},set:function(e){this._grid.setRowDefinition(1,e?this._barSize:0,!0),this._horizontalBar.isVisible=e,this._forceHorizontalBar=e},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"forceVerticalBar",{get:function(){return this._forceVerticalBar},set:function(e){this._grid.setColumnDefinition(1,e?this._barSize:0,!0),this._verticalBar.isVisible=e,this._forceVerticalBar=e},enumerable:!1,configurable:!0}),i.prototype.resetWindow=function(){this._window.width="100%",this._window.height="100%"},i.prototype._getTypeName=function(){return"ScrollViewer"},i.prototype._buildClientSizes=function(){var e=this.host.idealRatio;this._window.parentClientWidth=this._currentMeasure.width-(this._verticalBar.isVisible||this.forceVerticalBar?this._barSize*e:0)-2*this.thickness,this._window.parentClientHeight=this._currentMeasure.height-(this._horizontalBar.isVisible||this.forceHorizontalBar?this._barSize*e:0)-2*this.thickness,this._clientWidth=this._window.parentClientWidth,this._clientHeight=this._window.parentClientHeight},i.prototype._additionalProcessing=function(t,i){e.prototype._additionalProcessing.call(this,t,i),this._buildClientSizes()},i.prototype._postMeasure=function(){e.prototype._postMeasure.call(this),this._updateScroller(),this._setWindowPosition(!1)},Object.defineProperty(i.prototype,"wheelPrecision",{get:function(){return this._wheelPrecision},set:function(e){this._wheelPrecision!==e&&(e<0&&(e=0),e>1&&(e=1),this._wheelPrecision=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"scrollBackground",{get:function(){return this._horizontalBarSpace.background},set:function(e){this._horizontalBarSpace.background!==e&&(this._horizontalBarSpace.background=e,this._verticalBarSpace.background=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"barColor",{get:function(){return this._barColor},set:function(e){this._barColor!==e&&(this._barColor=e,this._horizontalBar.color=e,this._verticalBar.color=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"thumbImage",{get:function(){return this._barImage},set:function(e){if(this._barImage!==e){this._barImage=e;var t=this._horizontalBar,i=this._verticalBar;t.thumbImage=e,i.thumbImage=e}},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"horizontalThumbImage",{get:function(){return this._horizontalBarImage},set:function(e){this._horizontalBarImage!==e&&(this._horizontalBarImage=e,this._horizontalBar.thumbImage=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"verticalThumbImage",{get:function(){return this._verticalBarImage},set:function(e){this._verticalBarImage!==e&&(this._verticalBarImage=e,this._verticalBar.thumbImage=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"barSize",{get:function(){return this._barSize},set:function(e){this._barSize!==e&&(this._barSize=e,this._markAsDirty(),this._horizontalBar.isVisible&&this._grid.setRowDefinition(1,this._barSize,!0),this._verticalBar.isVisible&&this._grid.setColumnDefinition(1,this._barSize,!0))},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"thumbLength",{get:function(){return this._thumbLength},set:function(e){if(this._thumbLength!==e){e<=0&&(e=.1),e>1&&(e=1),this._thumbLength=e;var t=this._horizontalBar,i=this._verticalBar;t.thumbLength=e,i.thumbLength=e,this._markAsDirty()}},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"thumbHeight",{get:function(){return this._thumbHeight},set:function(e){if(this._thumbHeight!==e){e<=0&&(e=.1),e>1&&(e=1),this._thumbHeight=e;var t=this._horizontalBar,i=this._verticalBar;t.thumbHeight=e,i.thumbHeight=e,this._markAsDirty()}},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"barImageHeight",{get:function(){return this._barImageHeight},set:function(e){if(this._barImageHeight!==e){e<=0&&(e=.1),e>1&&(e=1),this._barImageHeight=e;var t=this._horizontalBar,i=this._verticalBar;t.barImageHeight=e,i.barImageHeight=e,this._markAsDirty()}},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"horizontalBarImageHeight",{get:function(){return this._horizontalBarImageHeight},set:function(e){this._horizontalBarImageHeight!==e&&(e<=0&&(e=.1),e>1&&(e=1),this._horizontalBarImageHeight=e,this._horizontalBar.barImageHeight=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"verticalBarImageHeight",{get:function(){return this._verticalBarImageHeight},set:function(e){this._verticalBarImageHeight!==e&&(e<=0&&(e=.1),e>1&&(e=1),this._verticalBarImageHeight=e,this._verticalBar.barImageHeight=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"barBackground",{get:function(){return this._barBackground},set:function(e){if(this._barBackground!==e){this._barBackground=e;var t=this._horizontalBar,i=this._verticalBar;t.background=e,i.background=e,this._dragSpace.background=e}},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"barImage",{get:function(){return this._barBackgroundImage},set:function(e){this._barBackgroundImage,this._barBackgroundImage=e;var t=this._horizontalBar,i=this._verticalBar;t.backgroundImage=e,i.backgroundImage=e},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"horizontalBarImage",{get:function(){return this._horizontalBarBackgroundImage},set:function(e){this._horizontalBarBackgroundImage,this._horizontalBarBackgroundImage=e,this._horizontalBar.backgroundImage=e},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"verticalBarImage",{get:function(){return this._verticalBarBackgroundImage},set:function(e){this._verticalBarBackgroundImage,this._verticalBarBackgroundImage=e,this._verticalBar.backgroundImage=e},enumerable:!1,configurable:!0}),i.prototype._setWindowPosition=function(e){void 0===e&&(e=!0);var t=this.host.idealRatio,i=this._window._currentMeasure.width,r=this._window._currentMeasure.height;if(e||this._oldWindowContentsWidth!==i||this._oldWindowContentsHeight!==r){this._oldWindowContentsWidth=i,this._oldWindowContentsHeight=r;var n=this._clientWidth-i,o=this._clientHeight-r,s=this._horizontalBar.value/t*n+"px",a=this._verticalBar.value/t*o+"px";s!==this._window.left&&(this._window.left=s,this.freezeControls||(this._rebuildLayout=!0)),a!==this._window.top&&(this._window.top=a,this.freezeControls||(this._rebuildLayout=!0))}},i.prototype._updateScroller=function(){var e=this._window._currentMeasure.width,t=this._window._currentMeasure.height;this._horizontalBar.isVisible&&e<=this._clientWidth&&!this.forceHorizontalBar?(this._grid.setRowDefinition(1,0,!0),this._horizontalBar.isVisible=!1,this._horizontalBar.value=0,this._rebuildLayout=!0):!this._horizontalBar.isVisible&&(e>this._clientWidth||this.forceHorizontalBar)&&(this._grid.setRowDefinition(1,this._barSize,!0),this._horizontalBar.isVisible=!0,this._rebuildLayout=!0),this._verticalBar.isVisible&&t<=this._clientHeight&&!this.forceVerticalBar?(this._grid.setColumnDefinition(1,0,!0),this._verticalBar.isVisible=!1,this._verticalBar.value=0,this._rebuildLayout=!0):!this._verticalBar.isVisible&&(t>this._clientHeight||this.forceVerticalBar)&&(this._grid.setColumnDefinition(1,this._barSize,!0),this._verticalBar.isVisible=!0,this._rebuildLayout=!0),this._buildClientSizes();var i=this.host.idealRatio;this._horizontalBar.thumbWidth=.9*this._thumbLength*(this._clientWidth/i)+"px",this._verticalBar.thumbWidth=.9*this._thumbLength*(this._clientHeight/i)+"px"},i.prototype._link=function(t){e.prototype._link.call(this,t),this._attachWheel()},i.prototype._addBar=function(e,t,i,r){var n=this;e.paddingLeft=0,e.width="100%",e.height="100%",e.barOffset=0,e.value=0,e.maximum=1,e.horizontalAlignment=Ur.HORIZONTAL_ALIGNMENT_CENTER,e.verticalAlignment=Ur.VERTICAL_ALIGNMENT_CENTER,e.isVertical=i,e.rotation=r,e.isVisible=!1,t.addControl(e),e.onValueChangedObservable.add((function(e){n._setWindowPosition()}))},i.prototype._attachWheel=function(){var e=this;this._host&&!this._onWheelObserver&&(this._onWheelObserver=this.onWheelObservable.add((function(t){e._pointerIsOver&&(1==e._verticalBar.isVisible&&(t.y<0&&e._verticalBar.value>0?e._verticalBar.value-=e._wheelPrecision:t.y>0&&e._verticalBar.value<e._verticalBar.maximum&&(e._verticalBar.value+=e._wheelPrecision)),1==e._horizontalBar.isVisible&&(t.x<0&&e._horizontalBar.value<e._horizontalBar.maximum?e._horizontalBar.value+=e._wheelPrecision:t.x>0&&e._horizontalBar.value>0&&(e._horizontalBar.value-=e._wheelPrecision)))})))},i.prototype._renderHighlightSpecific=function(t){this.isHighlighted&&(e.prototype._renderHighlightSpecific.call(this,t),this._grid._renderHighlightSpecific(t),t.restore())},i.prototype.dispose=function(){this.onWheelObservable.remove(this._onWheelObserver),this._onWheelObserver=null,e.prototype.dispose.call(this)},i}(zr);c.RegisteredTypes["BABYLON.GUI.ScrollViewer"]=dn;var pn=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.onKeyPressObservable=new U,t.defaultButtonWidth="40px",t.defaultButtonHeight="40px",t.defaultButtonPaddingLeft="2px",t.defaultButtonPaddingRight="2px",t.defaultButtonPaddingTop="2px",t.defaultButtonPaddingBottom="2px",t.defaultButtonColor="#DDD",t.defaultButtonBackground="#070707",t.shiftButtonColor="#7799FF",t.selectedShiftThickness=1,t.shiftState=0,t._currentlyConnectedInputText=null,t._connectedInputTexts=[],t._onKeyPressObserver=null,t}return t(i,e),i.prototype._getTypeName=function(){return"VirtualKeyboard"},i.prototype._createKey=function(e,t){var i=this,r=Xr.CreateSimpleButton(e,e);return r.width=t&&t.width?t.width:this.defaultButtonWidth,r.height=t&&t.height?t.height:this.defaultButtonHeight,r.color=t&&t.color?t.color:this.defaultButtonColor,r.background=t&&t.background?t.background:this.defaultButtonBackground,r.paddingLeft=t&&t.paddingLeft?t.paddingLeft:this.defaultButtonPaddingLeft,r.paddingRight=t&&t.paddingRight?t.paddingRight:this.defaultButtonPaddingRight,r.paddingTop=t&&t.paddingTop?t.paddingTop:this.defaultButtonPaddingTop,r.paddingBottom=t&&t.paddingBottom?t.paddingBottom:this.defaultButtonPaddingBottom,r.thickness=0,r.isFocusInvisible=!0,r.shadowColor=this.shadowColor,r.shadowBlur=this.shadowBlur,r.shadowOffsetX=this.shadowOffsetX,r.shadowOffsetY=this.shadowOffsetY,r.onPointerUpObservable.add((function(){i.onKeyPressObservable.notifyObservers(e)})),r},i.prototype.addKeysRow=function(e,t){var i=new jr;i.isVertical=!1,i.isFocusInvisible=!0;for(var r=null,n=0;n<e.length;n++){var o=null;t&&t.length===e.length&&(o=t[n]);var s=this._createKey(e[n],o);(!r||s.heightInPixels>r.heightInPixels)&&(r=s),i.addControl(s)}i.height=r?r.height:this.defaultButtonHeight,this.addControl(i)},i.prototype.applyShiftState=function(e){if(this.children)for(var t=0;t<this.children.length;t++){var i=this.children[t];if(i&&i.children)for(var r=i,n=0;n<r.children.length;n++){var o=r.children[n];if(o&&o.children[0]){var s=o.children[0];"⇧"===s.text&&(o.color=e?this.shiftButtonColor:this.defaultButtonColor,o.thickness=e>1?this.selectedShiftThickness:0),s.text=e>0?s.text.toUpperCase():s.text.toLowerCase()}}}},Object.defineProperty(i.prototype,"connectedInputText",{get:function(){return this._currentlyConnectedInputText},enumerable:!1,configurable:!0}),i.prototype.connect=function(e){var t=this;if(!this._connectedInputTexts.some((function(t){return t.input===e}))){null===this._onKeyPressObserver&&(this._onKeyPressObserver=this.onKeyPressObservable.add((function(e){if(t._currentlyConnectedInputText){switch(t._currentlyConnectedInputText._host.focusedControl=t._currentlyConnectedInputText,e){case"⇧":return t.shiftState++,t.shiftState>2&&(t.shiftState=0),void t.applyShiftState(t.shiftState);case"←":return void t._currentlyConnectedInputText.processKey(8);case"↵":return void t._currentlyConnectedInputText.processKey(13)}t._currentlyConnectedInputText.processKey(-1,t.shiftState?e.toUpperCase():e),1===t.shiftState&&(t.shiftState=0,t.applyShiftState(t.shiftState))}}))),this.isVisible=!1,this._currentlyConnectedInputText=e,e._connectedVirtualKeyboard=this;var i=e.onFocusObservable.add((function(){t._currentlyConnectedInputText=e,e._connectedVirtualKeyboard=t,t.isVisible=!0})),r=e.onBlurObservable.add((function(){e._connectedVirtualKeyboard=null,t._currentlyConnectedInputText=null,t.isVisible=!1}));this._connectedInputTexts.push({input:e,onBlurObserver:r,onFocusObserver:i})}},i.prototype.disconnect=function(e){var t=this;if(e){var i=this._connectedInputTexts.filter((function(t){return t.input===e}));1===i.length&&(this._removeConnectedInputObservables(i[0]),this._connectedInputTexts=this._connectedInputTexts.filter((function(t){return t.input!==e})),this._currentlyConnectedInputText===e&&(this._currentlyConnectedInputText=null))}else this._connectedInputTexts.forEach((function(e){t._removeConnectedInputObservables(e)})),this._connectedInputTexts=[];0===this._connectedInputTexts.length&&(this._currentlyConnectedInputText=null,this.onKeyPressObservable.remove(this._onKeyPressObserver),this._onKeyPressObserver=null)},i.prototype._removeConnectedInputObservables=function(e){e.input._connectedVirtualKeyboard=null,e.input.onFocusObservable.remove(e.onFocusObserver),e.input.onBlurObservable.remove(e.onBlurObserver)},i.prototype.dispose=function(){e.prototype.dispose.call(this),this.disconnect()},i.CreateDefaultLayout=function(e){var t=new i(e);return t.addKeysRow(["1","2","3","4","5","6","7","8","9","0","←"]),t.addKeysRow(["q","w","e","r","t","y","u","i","o","p"]),t.addKeysRow(["a","s","d","f","g","h","j","k","l",";","'","↵"]),t.addKeysRow(["⇧","z","x","c","v","b","n","m",",",".","/"]),t.addKeysRow([" "],[{width:"200px"}]),t},i}(jr);c.RegisteredTypes["BABYLON.GUI.VirtualKeyboard"]=pn;var _n=function(e){function i(t){var i=e.call(this,t)||this;return i.name=t,i._cellWidth=20,i._cellHeight=20,i._minorLineTickness=1,i._minorLineColor="DarkGray",i._majorLineTickness=2,i._majorLineColor="White",i._majorLineFrequency=5,i._background="Black",i._displayMajorLines=!0,i._displayMinorLines=!0,i}return t(i,e),Object.defineProperty(i.prototype,"displayMinorLines",{get:function(){return this._displayMinorLines},set:function(e){this._displayMinorLines!==e&&(this._displayMinorLines=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"displayMajorLines",{get:function(){return this._displayMajorLines},set:function(e){this._displayMajorLines!==e&&(this._displayMajorLines=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"background",{get:function(){return this._background},set:function(e){this._background!==e&&(this._background=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"cellWidth",{get:function(){return this._cellWidth},set:function(e){this._cellWidth=e,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"cellHeight",{get:function(){return this._cellHeight},set:function(e){this._cellHeight=e,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"minorLineTickness",{get:function(){return this._minorLineTickness},set:function(e){this._minorLineTickness=e,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"minorLineColor",{get:function(){return this._minorLineColor},set:function(e){this._minorLineColor=e,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"majorLineTickness",{get:function(){return this._majorLineTickness},set:function(e){this._majorLineTickness=e,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"majorLineColor",{get:function(){return this._majorLineColor},set:function(e){this._majorLineColor=e,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"majorLineFrequency",{get:function(){return this._majorLineFrequency},set:function(e){this._majorLineFrequency=e,this._markAsDirty()},enumerable:!1,configurable:!0}),i.prototype._draw=function(e,t){if(e.save(),this._applyStates(e),this._isEnabled){this._background&&(e.fillStyle=this._background,e.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height));var i=this._currentMeasure.width/this._cellWidth,r=this._currentMeasure.height/this._cellHeight,n=this._currentMeasure.left+this._currentMeasure.width/2,o=this._currentMeasure.top+this._currentMeasure.height/2;if(this._displayMinorLines){e.strokeStyle=this._minorLineColor,e.lineWidth=this._minorLineTickness;for(var s=-i/2;s<i/2;s++){var a=n+s*this.cellWidth;e.beginPath(),e.moveTo(a,this._currentMeasure.top),e.lineTo(a,this._currentMeasure.top+this._currentMeasure.height),e.stroke()}for(var h=-r/2;h<r/2;h++){var u=o+h*this.cellHeight;e.beginPath(),e.moveTo(this._currentMeasure.left,u),e.lineTo(this._currentMeasure.left+this._currentMeasure.width,u),e.stroke()}}if(this._displayMajorLines){e.strokeStyle=this._majorLineColor,e.lineWidth=this._majorLineTickness;for(s=-i/2+this._majorLineFrequency;s<i/2;s+=this._majorLineFrequency){a=n+s*this.cellWidth;e.beginPath(),e.moveTo(a,this._currentMeasure.top),e.lineTo(a,this._currentMeasure.top+this._currentMeasure.height),e.stroke()}for(h=-r/2+this._majorLineFrequency;h<r/2;h+=this._majorLineFrequency){u=o+h*this.cellHeight;e.moveTo(this._currentMeasure.left,u),e.lineTo(this._currentMeasure.left+this._currentMeasure.width,u),e.closePath(),e.stroke()}}}e.restore()},i.prototype._getTypeName=function(){return"DisplayGrid"},i}(Ur);c.RegisteredTypes["BABYLON.GUI.DisplayGrid"]=_n;var gn=function(e){function i(t){var i=e.call(this,t)||this;return i.name=t,i._tempMeasure=new Nr(0,0,0,0),i}return t(i,e),Object.defineProperty(i.prototype,"displayThumb",{get:function(){return this._displayThumb&&null!=this.thumbImage},set:function(e){this._displayThumb!==e&&(this._displayThumb=e,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"backgroundImage",{get:function(){return this._backgroundImage},set:function(e){var t=this;this._backgroundImage!==e&&(this._backgroundImage=e,e&&!e.isLoaded&&e.onImageLoadedObservable.addOnce((function(){return t._markAsDirty()})),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"valueBarImage",{get:function(){return this._valueBarImage},set:function(e){var t=this;this._valueBarImage!==e&&(this._valueBarImage=e,e&&!e.isLoaded&&e.onImageLoadedObservable.addOnce((function(){return t._markAsDirty()})),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"thumbImage",{get:function(){return this._thumbImage},set:function(e){var t=this;this._thumbImage!==e&&(this._thumbImage=e,e&&!e.isLoaded&&e.onImageLoadedObservable.addOnce((function(){return t._markAsDirty()})),this._markAsDirty())},enumerable:!1,configurable:!0}),i.prototype._getTypeName=function(){return"ImageBasedSlider"},i.prototype._draw=function(e,t){e.save(),this._applyStates(e),this._prepareRenderingData("rectangle");var i=this._getThumbPosition(),r=this._renderLeft,n=this._renderTop,o=this._renderWidth,s=this._renderHeight;this._backgroundImage&&(this._tempMeasure.copyFromFloats(r,n,o,s),this.isThumbClamped&&this.displayThumb&&(this.isVertical?this._tempMeasure.height+=this._effectiveThumbThickness:this._tempMeasure.width+=this._effectiveThumbThickness),this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure),this._backgroundImage._draw(e)),this._valueBarImage&&(this.isVertical?this.isThumbClamped&&this.displayThumb?this._tempMeasure.copyFromFloats(r,n+i,o,s-i+this._effectiveThumbThickness):this._tempMeasure.copyFromFloats(r,n+i,o,s-i):this.isThumbClamped&&this.displayThumb?this._tempMeasure.copyFromFloats(r,n,i+this._effectiveThumbThickness/2,s):this._tempMeasure.copyFromFloats(r,n,i,s),this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure),this._valueBarImage._draw(e)),this.displayThumb&&(this.isVertical?this._tempMeasure.copyFromFloats(r-this._effectiveBarOffset,this._currentMeasure.top+i,this._currentMeasure.width,this._effectiveThumbThickness):this._tempMeasure.copyFromFloats(this._currentMeasure.left+i,this._currentMeasure.top,this._effectiveThumbThickness,this._currentMeasure.height),this._thumbImage._currentMeasure.copyFrom(this._tempMeasure),this._thumbImage._draw(e)),e.restore()},i}(an);c.RegisteredTypes["BABYLON.GUI.ImageBasedSlider"]=gn,Ur.AddHeader=function(e,t,i,r){var n=new jr("panel"),o=!r||r.isHorizontal,s=!r||r.controlFirst;n.isVertical=!o;var a=new Gr("header");return a.text=t,a.textHorizontalAlignment=Ur.HORIZONTAL_ALIGNMENT_LEFT,o?a.width=i:a.height=i,s?(n.addControl(e),n.addControl(a),a.paddingLeft="5px"):(n.addControl(a),n.addControl(e),a.paddingRight="5px"),a.shadowBlur=e.shadowBlur,a.shadowColor=e.shadowColor,a.shadowOffsetX=e.shadowOffsetX,a.shadowOffsetY=e.shadowOffsetY,n};var mn=function(){function e(e){this.name=zt.NAME_LAYER,this.scene=e,this._engine=e.getEngine(),e.layers=new Array}return e.prototype.register=function(){this.scene._beforeCameraDrawStage.registerStep(zt.STEP_BEFORECAMERADRAW_LAYER,this,this._drawCameraBackground),this.scene._afterCameraDrawStage.registerStep(zt.STEP_AFTERCAMERADRAW_LAYER,this,this._drawCameraForeground),this.scene._beforeRenderTargetDrawStage.registerStep(zt.STEP_BEFORERENDERTARGETDRAW_LAYER,this,this._drawRenderTargetBackground),this.scene._afterRenderTargetDrawStage.registerStep(zt.STEP_AFTERRENDERTARGETDRAW_LAYER,this,this._drawRenderTargetForeground)},e.prototype.rebuild=function(){for(var e=0,t=this.scene.layers;e<t.length;e++){t[e]._rebuild()}},e.prototype.dispose=function(){for(var e=this.scene.layers;e.length;)e[0].dispose()},e.prototype._draw=function(e){var t=this.scene.layers;if(t.length){this._engine.setDepthBuffer(!1);for(var i=0,r=t;i<r.length;i++){var n=r[i];e(n)&&n.render()}this._engine.setDepthBuffer(!0)}},e.prototype._drawCameraPredicate=function(e,t,i){return!e.renderOnlyInRenderTargetTextures&&e.isBackground===t&&0!=(e.layerMask&i)},e.prototype._drawCameraBackground=function(e){var t=this;this._draw((function(i){return t._drawCameraPredicate(i,!0,e.layerMask)}))},e.prototype._drawCameraForeground=function(e){var t=this;this._draw((function(i){return t._drawCameraPredicate(i,!1,e.layerMask)}))},e.prototype._drawRenderTargetPredicate=function(e,t,i,r){return e.renderTargetTextures.length>0&&e.isBackground===t&&e.renderTargetTextures.indexOf(r)>-1&&0!=(e.layerMask&i)},e.prototype._drawRenderTargetBackground=function(e){var t=this;this._draw((function(i){return t._drawRenderTargetPredicate(i,!0,t.scene.activeCamera.layerMask,e)}))},e.prototype._drawRenderTargetForeground=function(e){var t=this;this._draw((function(i){return t._drawRenderTargetPredicate(i,!1,t.scene.activeCamera.layerMask,e)}))},e.prototype.addFromContainer=function(e){var t=this;e.layers&&e.layers.forEach((function(e){t.scene.layers.push(e)}))},e.prototype.removeFromContainer=function(e,t){var i=this;void 0===t&&(t=!1),e.layers&&e.layers.forEach((function(e){var r=i.scene.layers.indexOf(e);-1!==r&&i.scene.layers.splice(r,1),t&&e.dispose()}))},e}(),vn=function(){function e(e,t,i,r,n){this.name=e,this.scale=new d(1,1),this.offset=new d(0,0),this.alphaBlendingMode=2,this.layerMask=268435455,this.renderTargetTextures=[],this.renderOnlyInRenderTargetTextures=!1,this._vertexBuffers={},this.onDisposeObservable=new U,this.onBeforeRenderObservable=new U,this.onAfterRenderObservable=new U,this.texture=t?new Re(t,i,!0):null,this.isBackground=void 0===r||r,this.color=void 0===n?new E(1,1,1,1):n,this._scene=i||V.LastCreatedScene;var o=this._scene._getComponent(zt.NAME_LAYER);o||(o=new mn(this._scene),this._scene._addComponent(o)),this._scene.layers.push(this);var s=this._scene.getEngine(),a=[];a.push(1,1),a.push(-1,1),a.push(-1,-1),a.push(1,-1);var h=new ft(s,a,ft.PositionKind,!1,!1,2);this._vertexBuffers[ft.PositionKind]=h,this._createIndexBuffer()}return Object.defineProperty(e.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!1,configurable:!0}),e.prototype._createIndexBuffer=function(){var e=this._scene.getEngine(),t=[];t.push(0),t.push(1),t.push(2),t.push(0),t.push(2),t.push(3),this._indexBuffer=e.createIndexBuffer(t)},e.prototype._rebuild=function(){var e=this._vertexBuffers[ft.PositionKind];e&&e._rebuild(),this._createIndexBuffer()},e.prototype.render=function(){var e=this._scene.getEngine(),t="";this.alphaTest&&(t="#define ALPHATEST"),this.texture&&!this.texture.gammaSpace&&(t+="\r\n#define LINEAR"),this._previousDefines!==t&&(this._previousDefines=t,this._effect=e.createEffect("layer",[ft.PositionKind],["textureMatrix","color","scale","offset"],["textureSampler"],t));var i=this._effect;if(i&&i.isReady()&&this.texture&&this.texture.isReady()){e=this._scene.getEngine();this.onBeforeRenderObservable.notifyObservers(this),e.enableEffect(i),e.setState(!1),i.setTexture("textureSampler",this.texture),i.setMatrix("textureMatrix",this.texture.getTextureMatrix()),i.setFloat4("color",this.color.r,this.color.g,this.color.b,this.color.a),i.setVector2("offset",this.offset),i.setVector2("scale",this.scale),e.bindBuffers(this._vertexBuffers,this._indexBuffer,i),this.alphaTest?e.drawElementsType(Vt.TriangleFillMode,0,6):(e.setAlphaMode(this.alphaBlendingMode),e.drawElementsType(Vt.TriangleFillMode,0,6),e.setAlphaMode(0)),this.onAfterRenderObservable.notifyObservers(this)}},e.prototype.dispose=function(){var e=this._vertexBuffers[ft.PositionKind];e&&(e.dispose(),this._vertexBuffers[ft.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this.texture&&(this.texture.dispose(),this.texture=null),this.renderTargetTextures=[];var t=this._scene.layers.indexOf(this);this._scene.layers.splice(t,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onAfterRenderObservable.clear(),this.onBeforeRenderObservable.clear()},e}(),yn=function(){function e(e){this._fontFamily="Arial",this._fontStyle="",this._fontWeight="",this._fontSize=new Rr(18,Rr.UNITMODE_PIXEL,!1),this.onChangedObservable=new U,this._host=e}return Object.defineProperty(e.prototype,"fontSize",{get:function(){return this._fontSize.toString(this._host)},set:function(e){this._fontSize.toString(this._host)!==e&&this._fontSize.fromString(e)&&this.onChangedObservable.notifyObservers(this)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fontFamily",{get:function(){return this._fontFamily},set:function(e){this._fontFamily!==e&&(this._fontFamily=e,this.onChangedObservable.notifyObservers(this))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fontStyle",{get:function(){return this._fontStyle},set:function(e){this._fontStyle!==e&&(this._fontStyle=e,this.onChangedObservable.notifyObservers(this))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fontWeight",{get:function(){return this._fontWeight},set:function(e){this._fontWeight!==e&&(this._fontWeight=e,this.onChangedObservable.notifyObservers(this))},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){this.onChangedObservable.clear()},e}(),bn=function(){function e(){}return e.ALPHA_DISABLE=0,e.ALPHA_ADD=1,e.ALPHA_COMBINE=2,e.ALPHA_SUBTRACT=3,e.ALPHA_MULTIPLY=4,e.ALPHA_MAXIMIZED=5,e.ALPHA_ONEONE=6,e.ALPHA_PREMULTIPLIED=7,e.ALPHA_PREMULTIPLIED_PORTERDUFF=8,e.ALPHA_INTERPOLATE=9,e.ALPHA_SCREENMODE=10,e.ALPHA_ONEONE_ONEONE=11,e.ALPHA_ALPHATOCOLOR=12,e.ALPHA_REVERSEONEMINUS=13,e.ALPHA_SRC_DSTONEMINUSSRCALPHA=14,e.ALPHA_ONEONE_ONEZERO=15,e.ALPHA_EXCLUSION=16,e.ALPHA_EQUATION_ADD=0,e.ALPHA_EQUATION_SUBSTRACT=1,e.ALPHA_EQUATION_REVERSE_SUBTRACT=2,e.ALPHA_EQUATION_MAX=3,e.ALPHA_EQUATION_MIN=4,e.ALPHA_EQUATION_DARKEN=5,e.DELAYLOADSTATE_NONE=0,e.DELAYLOADSTATE_LOADED=1,e.DELAYLOADSTATE_LOADING=2,e.DELAYLOADSTATE_NOTLOADED=4,e.NEVER=512,e.ALWAYS=519,e.LESS=513,e.EQUAL=514,e.LEQUAL=515,e.GREATER=516,e.GEQUAL=518,e.NOTEQUAL=517,e.KEEP=7680,e.REPLACE=7681,e.INCR=7682,e.DECR=7683,e.INVERT=5386,e.INCR_WRAP=34055,e.DECR_WRAP=34056,e.TEXTURE_CLAMP_ADDRESSMODE=0,e.TEXTURE_WRAP_ADDRESSMODE=1,e.TEXTURE_MIRROR_ADDRESSMODE=2,e.TEXTUREFORMAT_ALPHA=0,e.TEXTUREFORMAT_LUMINANCE=1,e.TEXTUREFORMAT_LUMINANCE_ALPHA=2,e.TEXTUREFORMAT_RGB=4,e.TEXTUREFORMAT_RGBA=5,e.TEXTUREFORMAT_RED=6,e.TEXTUREFORMAT_R=6,e.TEXTUREFORMAT_RG=7,e.TEXTUREFORMAT_RED_INTEGER=8,e.TEXTUREFORMAT_R_INTEGER=8,e.TEXTUREFORMAT_RG_INTEGER=9,e.TEXTUREFORMAT_RGB_INTEGER=10,e.TEXTUREFORMAT_RGBA_INTEGER=11,e.TEXTURETYPE_UNSIGNED_BYTE=0,e.TEXTURETYPE_UNSIGNED_INT=0,e.TEXTURETYPE_FLOAT=1,e.TEXTURETYPE_HALF_FLOAT=2,e.TEXTURETYPE_BYTE=3,e.TEXTURETYPE_SHORT=4,e.TEXTURETYPE_UNSIGNED_SHORT=5,e.TEXTURETYPE_INT=6,e.TEXTURETYPE_UNSIGNED_INTEGER=7,e.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=8,e.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=9,e.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=10,e.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=11,e.TEXTURETYPE_UNSIGNED_INT_24_8=12,e.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=13,e.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=14,e.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=15,e.TEXTURE_NEAREST_SAMPLINGMODE=1,e.TEXTURE_NEAREST_NEAREST=1,e.TEXTURE_BILINEAR_SAMPLINGMODE=2,e.TEXTURE_LINEAR_LINEAR=2,e.TEXTURE_TRILINEAR_SAMPLINGMODE=3,e.TEXTURE_LINEAR_LINEAR_MIPLINEAR=3,e.TEXTURE_NEAREST_NEAREST_MIPNEAREST=4,e.TEXTURE_NEAREST_LINEAR_MIPNEAREST=5,e.TEXTURE_NEAREST_LINEAR_MIPLINEAR=6,e.TEXTURE_NEAREST_LINEAR=7,e.TEXTURE_NEAREST_NEAREST_MIPLINEAR=8,e.TEXTURE_LINEAR_NEAREST_MIPNEAREST=9,e.TEXTURE_LINEAR_NEAREST_MIPLINEAR=10,e.TEXTURE_LINEAR_LINEAR_MIPNEAREST=11,e.TEXTURE_LINEAR_NEAREST=12,e.TEXTURE_EXPLICIT_MODE=0,e.TEXTURE_SPHERICAL_MODE=1,e.TEXTURE_PLANAR_MODE=2,e.TEXTURE_CUBIC_MODE=3,e.TEXTURE_PROJECTION_MODE=4,e.TEXTURE_SKYBOX_MODE=5,e.TEXTURE_INVCUBIC_MODE=6,e.TEXTURE_EQUIRECTANGULAR_MODE=7,e.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=8,e.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9,e.TEXTURE_FILTERING_QUALITY_OFFLINE=4096,e.TEXTURE_FILTERING_QUALITY_HIGH=64,e.TEXTURE_FILTERING_QUALITY_MEDIUM=16,e.TEXTURE_FILTERING_QUALITY_LOW=8,e.SCALEMODE_FLOOR=1,e.SCALEMODE_NEAREST=2,e.SCALEMODE_CEILING=3,e.MATERIAL_TextureDirtyFlag=1,e.MATERIAL_LightDirtyFlag=2,e.MATERIAL_FresnelDirtyFlag=4,e.MATERIAL_AttributesDirtyFlag=8,e.MATERIAL_MiscDirtyFlag=16,e.MATERIAL_PrePassDirtyFlag=32,e.MATERIAL_AllDirtyFlag=63,e.MATERIAL_TriangleFillMode=0,e.MATERIAL_WireFrameFillMode=1,e.MATERIAL_PointFillMode=2,e.MATERIAL_PointListDrawMode=3,e.MATERIAL_LineListDrawMode=4,e.MATERIAL_LineLoopDrawMode=5,e.MATERIAL_LineStripDrawMode=6,e.MATERIAL_TriangleStripDrawMode=7,e.MATERIAL_TriangleFanDrawMode=8,e.MATERIAL_ClockWiseSideOrientation=0,e.MATERIAL_CounterClockWiseSideOrientation=1,e.ACTION_NothingTrigger=0,e.ACTION_OnPickTrigger=1,e.ACTION_OnLeftPickTrigger=2,e.ACTION_OnRightPickTrigger=3,e.ACTION_OnCenterPickTrigger=4,e.ACTION_OnPickDownTrigger=5,e.ACTION_OnDoublePickTrigger=6,e.ACTION_OnPickUpTrigger=7,e.ACTION_OnPickOutTrigger=16,e.ACTION_OnLongPressTrigger=8,e.ACTION_OnPointerOverTrigger=9,e.ACTION_OnPointerOutTrigger=10,e.ACTION_OnEveryFrameTrigger=11,e.ACTION_OnIntersectionEnterTrigger=12,e.ACTION_OnIntersectionExitTrigger=13,e.ACTION_OnKeyDownTrigger=14,e.ACTION_OnKeyUpTrigger=15,e.PARTICLES_BILLBOARDMODE_Y=2,e.PARTICLES_BILLBOARDMODE_ALL=7,e.PARTICLES_BILLBOARDMODE_STRETCHED=8,e.MESHES_CULLINGSTRATEGY_STANDARD=0,e.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY=1,e.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION=2,e.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY=3,e.SCENELOADER_NO_LOGGING=0,e.SCENELOADER_MINIMAL_LOGGING=1,e.SCENELOADER_SUMMARY_LOGGING=2,e.SCENELOADER_DETAILED_LOGGING=3,e.PREPASS_IRRADIANCE_TEXTURE_TYPE=0,e.PREPASS_POSITION_TEXTURE_TYPE=1,e.PREPASS_VELOCITY_TEXTURE_TYPE=2,e.PREPASS_REFLECTIVITY_TEXTURE_TYPE=3,e.PREPASS_COLOR_TEXTURE_TYPE=4,e.PREPASS_DEPTHNORMAL_TEXTURE_TYPE=5,e.PREPASS_ALBEDO_TEXTURE_TYPE=6,e}(),Tn=function(e){function i(t,i,r,n,o,s,a){void 0===i&&(i=0),void 0===r&&(r=0),void 0===o&&(o=!1),void 0===s&&(s=Re.NEAREST_SAMPLINGMODE);var h=e.call(this,t,{width:i,height:r},n,o,s,bn.TEXTUREFORMAT_RGBA,a)||this;return h._isDirty=!1,h._rootContainer=new Vr("root"),h._lastControlOver={},h._lastControlDown={},h._capturingControl={},h._linkedControls=new Array,h._isFullscreen=!1,h._fullscreenViewport=new _i(0,0,1,1),h._idealWidth=0,h._idealHeight=0,h._useSmallestIdeal=!1,h._renderAtIdealSize=!1,h._blockNextFocusCheck=!1,h._renderScale=1,h._cursorChanged=!1,h._defaultMousePointerId=0,h._numLayoutCalls=0,h._numRenderCalls=0,h._clipboardData="",h.onClipboardObservable=new U,h.onControlPickedObservable=new U,h.onBeginLayoutObservable=new U,h.onEndLayoutObservable=new U,h.onBeginRenderObservable=new U,h.onEndRenderObservable=new U,h.premulAlpha=!1,h.applyYInversionOnUpdate=!0,h._useInvalidateRectOptimization=!0,h._invalidatedRectangle=null,h._clearMeasure=new Nr(0,0,0,0),h.onClipboardCopy=function(e){var t=e,i=new qr(Yr.COPY,t);h.onClipboardObservable.notifyObservers(i),t.preventDefault()},h.onClipboardCut=function(e){var t=e,i=new qr(Yr.CUT,t);h.onClipboardObservable.notifyObservers(i),t.preventDefault()},h.onClipboardPaste=function(e){var t=e,i=new qr(Yr.PASTE,t);h.onClipboardObservable.notifyObservers(i),t.preventDefault()},(n=h.getScene())&&h._texture?(h._rootElement=n.getEngine().getInputElement(),h._renderObserver=n.onBeforeCameraRenderObservable.add((function(e){return h._checkUpdate(e)})),h._preKeyboardObserver=n.onPreKeyboardObservable.add((function(e){h._focusedControl&&(e.type===Ei.KEYDOWN&&h._focusedControl.processKeyboard(e.event),e.skipOnPointerObservable=!0)})),h._rootContainer._link(h),h.hasAlpha=!0,i&&r||(h._resizeObserver=n.getEngine().onResizeObservable.add((function(){return h._onResize()})),h._onResize()),h._texture.isReady=!0,h):h}return t(i,e),Object.defineProperty(i.prototype,"numLayoutCalls",{get:function(){return this._numLayoutCalls},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"numRenderCalls",{get:function(){return this._numRenderCalls},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"renderScale",{get:function(){return this._renderScale},set:function(e){e!==this._renderScale&&(this._renderScale=e,this._onResize())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"background",{get:function(){return this._background},set:function(e){this._background!==e&&(this._background=e,this.markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"idealWidth",{get:function(){return this._idealWidth},set:function(e){this._idealWidth!==e&&(this._idealWidth=e,this.markAsDirty(),this._rootContainer._markAllAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"idealHeight",{get:function(){return this._idealHeight},set:function(e){this._idealHeight!==e&&(this._idealHeight=e,this.markAsDirty(),this._rootContainer._markAllAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"useSmallestIdeal",{get:function(){return this._useSmallestIdeal},set:function(e){this._useSmallestIdeal!==e&&(this._useSmallestIdeal=e,this.markAsDirty(),this._rootContainer._markAllAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"renderAtIdealSize",{get:function(){return this._renderAtIdealSize},set:function(e){this._renderAtIdealSize!==e&&(this._renderAtIdealSize=e,this._onResize())},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"idealRatio",{get:function(){var e=0,t=0;return this._idealWidth&&(e=this.getSize().width/this._idealWidth),this._idealHeight&&(t=this.getSize().height/this._idealHeight),this._useSmallestIdeal&&this._idealWidth&&this._idealHeight?window.innerWidth<window.innerHeight?e:t:this._idealWidth?e:this._idealHeight?t:1},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"layer",{get:function(){return this._layerToDispose},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"rootContainer",{get:function(){return this._rootContainer},enumerable:!1,configurable:!0}),i.prototype.getChildren=function(){return[this._rootContainer]},i.prototype.getDescendants=function(e,t){return this._rootContainer.getDescendants(e,t)},Object.defineProperty(i.prototype,"focusedControl",{get:function(){return this._focusedControl},set:function(e){this._focusedControl!=e&&(this._focusedControl&&this._focusedControl.onBlur(),e&&e.onFocus(),this._focusedControl=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"isForeground",{get:function(){return!this.layer||!this.layer.isBackground},set:function(e){this.layer&&this.layer.isBackground!==!e&&(this.layer.isBackground=!e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"clipboardData",{get:function(){return this._clipboardData},set:function(e){this._clipboardData=e},enumerable:!1,configurable:!0}),i.prototype.getClassName=function(){return"AdvancedDynamicTexture"},i.prototype.executeOnAllControls=function(e,t){t||(t=this._rootContainer),e(t);for(var i=0,r=t.children;i<r.length;i++){var n=r[i];n.children?this.executeOnAllControls(e,n):e(n)}},Object.defineProperty(i.prototype,"useInvalidateRectOptimization",{get:function(){return this._useInvalidateRectOptimization},set:function(e){this._useInvalidateRectOptimization=e},enumerable:!1,configurable:!0}),i.prototype.invalidateRect=function(e,t,i,r){if(this._useInvalidateRectOptimization)if(this._invalidatedRectangle){var n=Math.ceil(Math.max(this._invalidatedRectangle.left+this._invalidatedRectangle.width-1,i)),o=Math.ceil(Math.max(this._invalidatedRectangle.top+this._invalidatedRectangle.height-1,r));this._invalidatedRectangle.left=Math.floor(Math.min(this._invalidatedRectangle.left,e)),this._invalidatedRectangle.top=Math.floor(Math.min(this._invalidatedRectangle.top,t)),this._invalidatedRectangle.width=n-this._invalidatedRectangle.left+1,this._invalidatedRectangle.height=o-this._invalidatedRectangle.top+1}else this._invalidatedRectangle=new Nr(e,t,i-e+1,r-t+1)},i.prototype.markAsDirty=function(){this._isDirty=!0},i.prototype.createStyle=function(){return new yn(this)},i.prototype.addControl=function(e){return this._rootContainer.addControl(e),this},i.prototype.removeControl=function(e){return this._rootContainer.removeControl(e),this},i.prototype.dispose=function(){var t=this.getScene();t&&(this._rootElement=null,t.onBeforeCameraRenderObservable.remove(this._renderObserver),this._resizeObserver&&t.getEngine().onResizeObservable.remove(this._resizeObserver),this._pointerMoveObserver&&t.onPrePointerObservable.remove(this._pointerMoveObserver),this._pointerObserver&&t.onPointerObservable.remove(this._pointerObserver),this._preKeyboardObserver&&t.onPreKeyboardObservable.remove(this._preKeyboardObserver),this._canvasPointerOutObserver&&t.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver),this._canvasBlurObserver&&t.getEngine().onCanvasBlurObservable.remove(this._canvasBlurObserver),this._layerToDispose&&(this._layerToDispose.texture=null,this._layerToDispose.dispose(),this._layerToDispose=null),this._rootContainer.dispose(),this.onClipboardObservable.clear(),this.onControlPickedObservable.clear(),this.onBeginRenderObservable.clear(),this.onEndRenderObservable.clear(),this.onBeginLayoutObservable.clear(),this.onEndLayoutObservable.clear(),e.prototype.dispose.call(this))},i.prototype._onResize=function(){var e=this.getScene();if(e){var t=e.getEngine(),i=this.getSize(),r=t.getRenderWidth()*this._renderScale,n=t.getRenderHeight()*this._renderScale;this._renderAtIdealSize&&(this._idealWidth?(n=n*this._idealWidth/r,r=this._idealWidth):this._idealHeight&&(r=r*this._idealHeight/n,n=this._idealHeight)),i.width===r&&i.height===n||(this.scaleTo(r,n),this.markAsDirty(),(this._idealWidth||this._idealHeight)&&this._rootContainer._markAllAsDirty()),this.invalidateRect(0,0,i.width-1,i.height-1)}},i.prototype._getGlobalViewport=function(e){var t=e.getEngine();return this._fullscreenViewport.toGlobal(t.getRenderWidth(),t.getRenderHeight())},i.prototype.getProjectedPosition=function(e,t){var i=this.getScene();if(!i)return d.Zero();var r=this._getGlobalViewport(i),n=p.Project(e,t,i.getTransformMatrix(),r);return n.scaleInPlace(this.renderScale),new d(n.x,n.y)},i.prototype.getProjectedPositionWithZ=function(e,t){var i=this.getScene();if(!i)return p.Zero();var r=this._getGlobalViewport(i),n=p.Project(e,t,i.getTransformMatrix(),r);return n.scaleInPlace(this.renderScale),new p(n.x,n.y,n.z)},i.prototype._checkUpdate=function(e){if(!this._layerToDispose||0!=(e.layerMask&this._layerToDispose.layerMask)){if(this._isFullscreen&&this._linkedControls.length){var t=this.getScene();if(!t)return;for(var i=this._getGlobalViewport(t),r=function(e){if(!e.isVisible)return"continue";var r=e._linkedMesh;if(!r||r.isDisposed())return Ue.SetImmediate((function(){e.linkWithMesh(null)})),"continue";var o=r.getBoundingInfo?r.getBoundingInfo().boundingSphere.center:p.ZeroReadOnly,s=p.Project(o,r.getWorldMatrix(),t.getTransformMatrix(),i);if(s.z<0||s.z>1)return e.notRenderable=!0,"continue";e.notRenderable=!1,s.scaleInPlace(n.renderScale),e._moveToProjectedPosition(s)},n=this,o=0,s=this._linkedControls;o<s.length;o++){r(s[o])}}(this._isDirty||this._rootContainer.isDirty)&&(this._isDirty=!1,this._render(),this.update(this.applyYInversionOnUpdate,this.premulAlpha))}},i.prototype._render=function(){var e=this.getSize(),t=e.width,i=e.height,r=this.getContext();r.font="18px Arial",r.strokeStyle="white",this.onBeginLayoutObservable.notifyObservers(this);var n=new Nr(0,0,t,i);this._numLayoutCalls=0,this._rootContainer._layout(n,r),this.onEndLayoutObservable.notifyObservers(this),this._isDirty=!1,this._invalidatedRectangle?this._clearMeasure.copyFrom(this._invalidatedRectangle):this._clearMeasure.copyFromFloats(0,0,t,i),r.clearRect(this._clearMeasure.left,this._clearMeasure.top,this._clearMeasure.width,this._clearMeasure.height),this._background&&(r.save(),r.fillStyle=this._background,r.fillRect(this._clearMeasure.left,this._clearMeasure.top,this._clearMeasure.width,this._clearMeasure.height),r.restore()),this.onBeginRenderObservable.notifyObservers(this),this._numRenderCalls=0,this._rootContainer._render(r,this._invalidatedRectangle),this.onEndRenderObservable.notifyObservers(this),this._invalidatedRectangle=null},i.prototype._changeCursor=function(e){this._rootElement&&(this._rootElement.style.cursor=e,this._cursorChanged=!0)},i.prototype._registerLastControlDown=function(e,t){this._lastControlDown[t]=e,this.onControlPickedObservable.notifyObservers(e)},i.prototype._doPicking=function(e,t,i,r,n,o,s,a){var h=this.getScene();if(h){var u=h.getEngine(),l=this.getSize();if(this._isFullscreen){var c=(h.cameraToUseForPointers||h.activeCamera).viewport;e*=l.width/(u.getRenderWidth()*c.width),t*=l.height/(u.getRenderHeight()*c.height)}this._capturingControl[n]?this._capturingControl[n]._processObservables(r,e,t,i,n,o):(this._cursorChanged=!1,this._rootContainer._processPicking(e,t,i,r,n,o,s,a)||(this._changeCursor(""),r===Jt.POINTERMOVE&&this._lastControlOver[n]&&(this._lastControlOver[n]._onPointerOut(this._lastControlOver[n],i),delete this._lastControlOver[n])),this._cursorChanged||this._changeCursor(""),this._manageFocus())}},i.prototype._cleanControlAfterRemovalFromList=function(e,t){for(var i in e){if(e.hasOwnProperty(i))e[i]===t&&delete e[i]}},i.prototype._cleanControlAfterRemoval=function(e){this._cleanControlAfterRemovalFromList(this._lastControlDown,e),this._cleanControlAfterRemovalFromList(this._lastControlOver,e)},i.prototype.attach=function(){var e=this,t=this.getScene();if(t){var i=new _i(0,0,0,0);this._pointerMoveObserver=t.onPrePointerObservable.add((function(r,n){if(!t.isPointerCaptured(r.event.pointerId)&&(r.type===Jt.POINTERMOVE||r.type===Jt.POINTERUP||r.type===Jt.POINTERDOWN||r.type===Jt.POINTERWHEEL)&&t){r.type===Jt.POINTERMOVE&&r.event.pointerId&&(e._defaultMousePointerId=r.event.pointerId);var o=t.cameraToUseForPointers||t.activeCamera,s=t.getEngine();o?o.viewport.toGlobalToRef(s.getRenderWidth(),s.getRenderHeight(),i):(i.x=0,i.y=0,i.width=s.getRenderWidth(),i.height=s.getRenderHeight());var a=t.pointerX/s.getHardwareScalingLevel()-i.x,h=t.pointerY/s.getHardwareScalingLevel()-(s.getRenderHeight()-i.y-i.height);e._shouldBlockPointer=!1;var u=r.event.pointerId||e._defaultMousePointerId;e._doPicking(a,h,r,r.type,u,r.event.button,r.event.deltaX,r.event.deltaY),e._shouldBlockPointer&&(r.skipOnPointerObservable=e._shouldBlockPointer)}})),this._attachToOnPointerOut(t),this._attachToOnBlur(t)}},i.prototype.registerClipboardEvents=function(){self.addEventListener("copy",this.onClipboardCopy,!1),self.addEventListener("cut",this.onClipboardCut,!1),self.addEventListener("paste",this.onClipboardPaste,!1)},i.prototype.unRegisterClipboardEvents=function(){self.removeEventListener("copy",this.onClipboardCopy),self.removeEventListener("cut",this.onClipboardCut),self.removeEventListener("paste",this.onClipboardPaste)},i.prototype.attachToMesh=function(e,t){var i=this;void 0===t&&(t=!0);var r=this.getScene();r&&(this._pointerObserver=r.onPointerObservable.add((function(t,r){if(t.type===Jt.POINTERMOVE||t.type===Jt.POINTERUP||t.type===Jt.POINTERDOWN){var n=t.event.pointerId||i._defaultMousePointerId;if(t.pickInfo&&t.pickInfo.hit&&t.pickInfo.pickedMesh===e){var o=t.pickInfo.getTextureCoordinates();if(o){var s=i.getSize();i._doPicking(o.x*s.width,(i.applyYInversionOnUpdate?1-o.y:o.y)*s.height,t,t.type,n,t.event.button)}}else if(t.type===Jt.POINTERUP){if(i._lastControlDown[n]&&i._lastControlDown[n]._forcePointerUp(n),delete i._lastControlDown[n],i.focusedControl){var a=i.focusedControl.keepsFocusWith(),h=!0;if(a)for(var u=0,l=a;u<l.length;u++){var c=l[u];if(i!==c._host){var f=c._host;if(f._lastControlOver[n]&&f._lastControlOver[n].isAscendant(c)){h=!1;break}}}h&&(i.focusedControl=null)}}else t.type===Jt.POINTERMOVE&&(i._lastControlOver[n]&&i._lastControlOver[n]._onPointerOut(i._lastControlOver[n],t,!0),delete i._lastControlOver[n])}})),e.enablePointerMoveEvents=t,this._attachToOnPointerOut(r),this._attachToOnBlur(r))},i.prototype.moveFocusToControl=function(e){this.focusedControl=e,this._lastPickedControl=e,this._blockNextFocusCheck=!0},i.prototype._manageFocus=function(){if(this._blockNextFocusCheck)return this._blockNextFocusCheck=!1,void(this._lastPickedControl=this._focusedControl);if(this._focusedControl&&this._focusedControl!==this._lastPickedControl){if(this._lastPickedControl.isFocusInvisible)return;this.focusedControl=null}},i.prototype._attachToOnPointerOut=function(e){var t=this;this._canvasPointerOutObserver=e.getEngine().onCanvasPointerOutObservable.add((function(e){t._lastControlOver[e.pointerId]&&t._lastControlOver[e.pointerId]._onPointerOut(t._lastControlOver[e.pointerId],null),delete t._lastControlOver[e.pointerId],t._lastControlDown[e.pointerId]&&t._lastControlDown[e.pointerId]!==t._capturingControl[e.pointerId]&&(t._lastControlDown[e.pointerId]._forcePointerUp(),delete t._lastControlDown[e.pointerId])}))},i.prototype._attachToOnBlur=function(e){var t=this;this._canvasBlurObserver=e.getEngine().onCanvasBlurObservable.add((function(e){Object.entries(t._lastControlDown).forEach((function(e){e[0];e[1]._onCanvasBlur()})),t._lastControlDown={}}))},i.CreateForMesh=function(e,t,r,n,o,s){void 0===t&&(t=1024),void 0===r&&(r=1024),void 0===n&&(n=!0),void 0===o&&(o=!1);var a=new i(e.name+" AdvancedDynamicTexture",t,r,e.getScene(),!0,Re.TRILINEAR_SAMPLINGMODE,s),h=new tr("AdvancedDynamicTextureMaterial",e.getScene());return h.backFaceCulling=!1,h.diffuseColor=T.Black(),h.specularColor=T.Black(),o?(h.diffuseTexture=a,h.emissiveTexture=a,a.hasAlpha=!0):(h.emissiveTexture=a,h.opacityTexture=a),e.material=h,a.attachToMesh(e,n),a},i.CreateForMeshTexture=function(e,t,r,n,o){void 0===t&&(t=1024),void 0===r&&(r=1024),void 0===n&&(n=!0);var s=new i(e.name+" AdvancedDynamicTexture",t,r,e.getScene(),!0,Re.TRILINEAR_SAMPLINGMODE,o);return s.attachToMesh(e,n),s},i.CreateFullscreenUI=function(e,t,r,n){void 0===t&&(t=!0),void 0===r&&(r=null),void 0===n&&(n=Re.BILINEAR_SAMPLINGMODE);var o=new i(e,0,0,r,!1,n),s=new vn(e+"_layer",null,r,!t);return s.texture=o,o._layerToDispose=s,o._isFullscreen=!0,o.attach(),o},i}(He);!function(){function e(e){this.texture=e,this._captureRenderTime=!1,this._renderTime=new St,this._captureLayoutTime=!1,this._layoutTime=new St,this._onBeginRenderObserver=null,this._onEndRenderObserver=null,this._onBeginLayoutObserver=null,this._onEndLayoutObserver=null}Object.defineProperty(e.prototype,"renderTimeCounter",{get:function(){return this._renderTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"layoutTimeCounter",{get:function(){return this._layoutTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"captureRenderTime",{get:function(){return this._captureRenderTime},set:function(e){var t=this;e!==this._captureRenderTime&&(this._captureRenderTime=e,e?(this._onBeginRenderObserver=this.texture.onBeginRenderObservable.add((function(){t._renderTime.beginMonitoring()})),this._onEndRenderObserver=this.texture.onEndRenderObservable.add((function(){t._renderTime.endMonitoring(!0)}))):(this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver),this._onBeginRenderObserver=null,this.texture.onEndRenderObservable.remove(this._onEndRenderObserver),this._onEndRenderObserver=null))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"captureLayoutTime",{get:function(){return this._captureLayoutTime},set:function(e){var t=this;e!==this._captureLayoutTime&&(this._captureLayoutTime=e,e?(this._onBeginLayoutObserver=this.texture.onBeginLayoutObservable.add((function(){t._layoutTime.beginMonitoring()})),this._onEndLayoutObserver=this.texture.onEndLayoutObservable.add((function(){t._layoutTime.endMonitoring(!0)}))):(this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver),this._onBeginLayoutObserver=null,this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver),this._onEndLayoutObserver=null))},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver),this._onBeginRenderObserver=null,this.texture.onEndRenderObservable.remove(this._onEndRenderObserver),this._onEndRenderObserver=null,this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver),this._onBeginLayoutObserver=null,this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver),this._onEndLayoutObserver=null,this.texture=null}}();export{kt as AbstractMesh,Xe as ActionEvent,at as ActionManager,Tn as AdvancedDynamicTexture,lt as Animation,Si as ArcRotateCamera,Xr as Button,T as Color3,E as Color4,Ur as Control,he as Effect,Ot as Engine,rt as ExecuteCodeAction,ir as InstancedMesh,rn as Line,rr as LinesMesh,Vt as Material,Zt as Mesh,Or as MeshBuilder,Wt as MultiMaterial,Gi as Ray,zr as Rectangle,zi as Scene,Yi as ShaderMaterial,hn as Slider,tr as StandardMaterial,xt as SubMesh,Gr as TextBlock,Re as Texture,p as Vector3,_ as Vector4,ft as VertexBuffer};
//# sourceMappingURL=index.js.map
