1234 |
- (function(e){function t(t){for(var n,o,s=t[0],u=t[1],c=t[2],h=0,d=[];h<s.length;h++)o=s[h],Object.prototype.hasOwnProperty.call(i,o)&&i[o]&&d.push(i[o][0]),i[o]=0;for(n in u)Object.prototype.hasOwnProperty.call(u,n)&&(e[n]=u[n]);l&&l(t);while(d.length)d.shift()();return a.push.apply(a,c||[]),r()}function r(){for(var e,t=0;t<a.length;t++){for(var r=a[t],n=!0,s=1;s<r.length;s++){var u=r[s];0!==i[u]&&(n=!1)}n&&(a.splice(t--,1),e=o(o.s=r[0]))}return e}var n={},i={index:0},a=[];function o(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,o),r.l=!0,r.exports}o.m=e,o.c=n,o.d=function(e,t,r){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},o.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(o.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)o.d(r,n,function(t){return e[t]}.bind(null,n));return r},o.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="//infishwaibao.oss-cn-chengdu.aliyuncs.com/screenshow/";var s=window["webpackJsonp"]=window["webpackJsonp"]||[],u=s.push.bind(s);s.push=t,s=s.slice();for(var c=0;c<s.length;c++)t(s[c]);var l=u;a.push([0,"chunk-vendors"]),r()})({0:function(e,t,r){e.exports=r("3170")},"00cd":function(e,t,r){"use strict";var n=r("b797"),i=r("3972"),a=r("ecf1"),o=r("032c"),s=r("6b61"),u=function(e){void 0!==e&&this.setName(e),o["a"].call(this),this._invBindInSkeletonSpace=i["c"].create(),this._boneInSkeletonSpace=i["c"].create(),this._boneBoundingBox=new a["a"]};n["a"].createPrototypeNode(u,n["a"].objectInherit(o["a"].prototype,{getOrCreateDebugColor:function(){return this._boneColor||(this._boneColor=i["f"].fromValues(Math.random(),Math.random(),Math.random())),this._boneColor},getBoneBoundingBox:function(){return this._boneBoundingBox},setBoneBoundingBox:function(e){this._boneBoundingBox=e},getMatrixInSkeletonSpace:function(){return this._boneInSkeletonSpace},getInvBindMatrixInSkeletonSpace:function(){return this._invBindInSkeletonSpace},setMatrixInSkeletonSpace:function(e){i["c"].copy(this._boneInSkeletonSpace,e)},setInvBindMatrixInSkeletonSpace:function(e){i["c"].copy(this._invBindInSkeletonSpace,e)},getBoneParent:function(){for(var e=this.getParents(),t=0,r=e.length;t<r;t++){var n=e[t].getTypeID();if(n===u.getTypeID())return e[t]}},setDefaultUpdateCallback:function(e){this.addUpdateCallback(new s["a"](void 0!==e?e:this.getName()))}}),"osgAnimation","Bone"),t["a"]=u},"02b4":function(e,t,r){"use strict";var n=function(){this._pool=[],this._length=0};n.prototype={clean:function(){this._length=0,this._pool.length=0},reset:function(){this._length=0},getLength:function(){return this._length},getArray:function(){return this._pool},back:function(){return this._pool[this._length-1]},pop:function(){return this._length--,this._pool[this._length]},push:function(e){this._length===this._pool.length?this._pool.push(e):this._pool[this._length]=e,this._length++},forEach:function(e){for(var t=0;t<this._length;t++)e(this._pool[t])}},t["a"]=n},"032c":function(e,t,r){"use strict";var n=r("b797"),i=r("3972"),a=r("2449"),o=r("ede0"),s=function(){a["a"].call(this),this.matrix=i["c"].create()};n["a"].createPrototypeNode(s,n["a"].objectInherit(a["a"].prototype,{getMatrix:function(){return this.matrix},setMatrix:function(e){this.matrix=e,this.dirtyBound()},computeLocalToWorldMatrix:function(e){return this.referenceFrame===o["a"].RELATIVE_RF?i["c"].mul(e,e,this.matrix):i["c"].copy(e,this.matrix),!0},computeWorldToLocalMatrix:function(){var e=i["c"].create();return function(t){return i["c"].invert(e,this.matrix),this.referenceFrame===o["a"].RELATIVE_RF?i["c"].mul(t,e,t):i["c"].copy(t,e),!0}}()}),"osg","MatrixTransform"),t["a"]=s},"0549":function(e,t,r){"use strict";var n=r("b797"),i=r("3714"),a=r("3972"),o=function(){i["a"].call(this),this.projection=a["c"].create()};n["a"].createPrototypeNode(o,n["a"].objectInherit(i["a"].prototype,{getProjectionMatrix:function(){return this.projection},setProjectionMatrix:function(e){this.projection=e}}),"osg","Projection"),t["a"]=o},"0599":function(e,t,r){"use strict";r("d3b7"),r("fb2c"),r("907a"),r("9a8c"),r("a975"),r("735e"),r("c1ac"),r("d139"),r("3a7b"),r("d5d6"),r("82f8"),r("e91f"),r("60bd"),r("5f96"),r("3280"),r("3fcc"),r("ca91"),r("25a1"),r("cd26"),r("3c5d"),r("2954"),r("649e"),r("219c"),r("170b"),r("b39a"),r("72f7"),r("cfc3"),r("84c3"),r("fb6a");var n=r("b797"),i=r("3972"),a=r("ecf1"),o=r("1cf6"),s=r("16f6"),u=r("a214"),c=function(e,t){this._bb=new a["a"],this._first=e,this._second=t,this._nodeRayStart=i["f"].create(),this._nodeRayEnd=i["f"].create()},l=function(){this._numVertexIndices=0};l.prototype={apply:function(e){e.getAttributes().Vertex&&Object(o["a"])(e,this)},operatorPoint:function(){this._numVertexIndices+=2},operatorLine:function(){this._numVertexIndices+=3},operatorTriangle:function(){this._numVertexIndices+=4}};var h=function(e){this._buildKdTree=e,this._numIndices=0};h.prototype={apply:function(e){e.getAttributes().Vertex&&Object(o["a"])(e,this)},operatorPoint:function(e){var t=this._buildKdTree._kdTree.getVertices(),r=3*e;this._buildKdTree._kdTree.addPoint(e),this._buildKdTree._primitiveIndices[this._numIndices]=this._numIndices;var n=this._buildKdTree._centers,i=3*this._numIndices;n[i]=t[r],n[i+1]=t[r+1],n[i+2]=t[r+2],this._numIndices++},operatorLine:function(e,t){if(e!==t){var r=this._buildKdTree._kdTree.getVertices(),n=3*e,i=3*t;this._buildKdTree._kdTree.addLine(e,t);var a=this._numIndices;this._buildKdTree._primitiveIndices[a]=a;var o=3*a,s=r[n],u=r[n+1],c=r[n+2],l=r[i],h=r[i+1],d=r[i+2],f=s<l?s:l,_=u<h?u:h,p=c<d?c:d,g=s>l?s:l,m=u>h?u:h,v=c>d?c:d,b=this._buildKdTree._centers;b[o]=.5*(f+g),b[o+1]=.5*(_+m),b[o+2]=.5*(p+v),this._numIndices++}},operatorTriangle:function(e,t,r){if(e!==t&&e!==r&&t!==r){var n=this._buildKdTree._kdTree.getVertices(),i=3*e,a=3*t,o=3*r;this._buildKdTree._kdTree.addTriangle(e,t,r);var s=this._numIndices;this._buildKdTree._primitiveIndices[s]=s;var u=3*s,c=n[i],l=n[i+1],h=n[i+2],d=n[a],f=n[a+1],_=n[a+2],p=n[o],g=n[o+1],m=n[o+2],v=c<d?c<p?c:p:d<p?d:p,b=l<f?l<g?l:g:f<g?f:g,S=h<_?h<m?h:m:_<m?_:m,x=c>d?c>p?c:p:d>p?d:p,T=l>f?l>g?l:g:f>g?f:g,y=h>_?h>m?h:m:_>m?_:m,C=this._buildKdTree._centers;C[u]=.5*(v+x),C[u+1]=.5*(b+T),C[u+2]=.5*(S+y),this._numIndices++}}};var d=function(e){this._kdTree=e,this._bb=new a["a"],this._primitiveIndices=void 0,this._centers=void 0,this._axisOrder=i["f"].create(),this._stackLength=0};d.prototype={build:function(e,t){var r=e._targetNumTrianglesPerLeaf,n=t.getVertexAttributeList().Vertex;if(!n)return!1;var i=n.getElements();if(!i)return!1;var o=i.length/3;if(o<r)return!1;this._bb.copy(t.getBoundingBox()),this._kdTree.setVertices(i),this.computeDivisions(e),e._numVerticesProcessed+=o;for(var u=0,d=t.getPrimitiveSetList(),f=d.length,_=0;_<f;_++){var p=d[_],g=p.getMode();g===s["a"].TRIANGLE_STRIP||g===s["a"].TRIANGLE_FAN?u+=3*Math.abs(p.getCount()-2):u+=3*p.getCount()}var m=new l(this);m.apply(t);var v=m._numVertexIndices;this._primitiveIndices=new Uint32Array(u/3),this._centers=new Float32Array(u),this._kdTree.setPrimitiveIndices(new Uint32Array(u));var b=o>65535?new Uint32Array(v):new Uint16Array(v);this._kdTree.setVertexIndices(b);var S=new h(this);S.apply(t);var x=this._kdTree.getPrimitiveIndices().slice(0,this._kdTree.getNumPrimitiveIndices());this._kdTree.setPrimitiveIndices(x);var T=this._kdTree.getVertexIndices().slice(0,this._kdTree.getNumVertexIndices());this._kdTree.setVertexIndices(T),this._primitiveIndices=this._primitiveIndices.slice(0,S._numIndices),this._centers=this._centers.slice(0,3*S._numIndices);var y=new c(-1,this._primitiveIndices.length);y._bb.copy(this._bb);var C=this._kdTree.addNode(y),A=new a["a"];A.copy(this._bb),this.divide(e,A,C,0);var E=this._kdTree.getPrimitiveIndices();for(f=this._primitiveIndices.length,_=0;_<f;++_)this._primitiveIndices[_]=E[this._primitiveIndices[_]];return this._kdTree.setPrimitiveIndices(this._primitiveIndices),this._kdTree.getNodes().length>0},computeDivisions:function(e){this._stackLength=e._maxNumLevels;var t=this._bb._max,r=this._bb._min,n=t[0]-r[0],i=t[1]-r[1],a=t[2]-r[2],o=this._axisOrder;o[0]=n>=i&&n>=a?0:i>=a?1:2,o[2]=n<i&&n<a?0:i<a?1:2;var s=o[0]+o[2];o[1]=3===s?0:2===s?1:2},divide:function(e,t,r,n){var i=this._kdTree,a=this._primitiveIndices,o=i.getNodes(),s=o[r],u=s._first,l=s._second,h=n<this._stackLength&&u<0&&l>e._targetNumTrianglesPerLeaf,d=-u-1,f=d+l-1;if(!h)return u<0&&this.computeNodeBox(s,d,f),r;if(u>=0)return r;var _=this._axisOrder[n%3],p=t._min[_],g=t._max[_],m=.5*(p+g),v=0,b=0,S=!1,x=d,T=f,y=this._centers;while(x<T){while(x<T&&y[3*a[x]+_]<=m)++x;while(x<T&&y[3*a[T]+_]>m)--T;if(x<T){var C=a[x];a[x]=a[T],a[T]=C,++x,--T}}x===T&&(y[3*a[x]+_]<=m?++x:--T),T-d<=-1?(v=0,b=r,S=!0):f-x<=-1?(v=r,b=0,S=!0):(v=i.addNode(new c(-d-1,T-d+1)),b=i.addNode(new c(-x-1,f-x+1)));var A=t._max[_];t._max[_]=m;var E=0!==v?this.divide(e,t,v,n+1):0;t._max[_]=A,A=t._min[_],t._min[_]=m;var R=0!==b?this.divide(e,t,b,n+1):0;if(t._min[_]=A,!S){s._first=E,s._second=R,S=!0;var M=s._bb;M.init(),0!==E&&M.expandByBoundingBox(o[E]._bb),0!==R&&M.expandByBoundingBox(o[R]._bb)}return r},computeNodeBox:function(e,t,r){for(var n=1/0,i=1/0,a=1/0,o=-1/0,s=-1/0,u=-1/0,c=this._kdTree.getVertexIndices(),l=this._kdTree.getPrimitiveIndices(),h=this._kdTree.getVertices(),d=t;d<=r;++d)for(var f=l[this._primitiveIndices[d]],_=c[f++],p=0;p<_;++p){var g=3*c[f++],m=h[g],v=h[g+1],b=h[g+2];m<n&&(n=m),v<i&&(i=v),b<a&&(a=b),m>o&&(o=m),v>s&&(s=v),b>u&&(u=b)}var S=1e-6,x=e._bb,T=x._min,y=x._max;T[0]=n-S,T[1]=i-S,T[2]=a-S,y[0]=o+S,y[1]=s+S,y[2]=u+S}};var f=function(){this._vertices=null,this._kdNodes=[],this._primitiveIndices=void 0,this._vertexIndices=void 0,this._numVertexIndices=0,this._numPrimitiveIndices=0};n["a"].createPrototypeObject(f,{getVertices:function(){return this._vertices},setVertices:function(e){this._vertices=e},getNumPrimitiveIndices:function(){return this._numPrimitiveIndices},getNumVertexIndices:function(){return this._numVertexIndices},setPrimitiveIndices:function(e){this._primitiveIndices=e},getPrimitiveIndices:function(){return this._primitiveIndices},setVertexIndices:function(e){this._vertexIndices=e},getVertexIndices:function(){return this._vertexIndices},getNodes:function(){return this._kdNodes},addPoint:function(e){var t=this._numVertexIndices;this._primitiveIndices[this._numPrimitiveIndices++]=t,this._vertexIndices[this._numVertexIndices++]=1,this._vertexIndices[this._numVertexIndices++]=e},addLine:function(e,t){var r=this._numVertexIndices;this._primitiveIndices[this._numPrimitiveIndices++]=r,this._vertexIndices[this._numVertexIndices++]=2,this._vertexIndices[this._numVertexIndices++]=e,this._vertexIndices[this._numVertexIndices++]=t},addTriangle:function(e,t,r){var n=this._numVertexIndices;this._primitiveIndices[this._numPrimitiveIndices++]=n,this._vertexIndices[this._numVertexIndices++]=3,this._vertexIndices[this._numVertexIndices++]=e,this._vertexIndices[this._numVertexIndices++]=t,this._vertexIndices[this._numVertexIndices++]=r},addNode:function(e){return this._kdNodes.push(e),this._kdNodes.length-1},build:function(e,t){var r=new d(this);return r.build(e,t)},_intersectFunctor:function(e,t){var r=-t._first-1,n=r+t._second,i=this._vertexIndices;e.setVertices(this._vertices),e.setPrimitiveIndex(r);for(var a=r;a<n;++a){var o=this._primitiveIndices[a],s=i[o++];3===s?e.operatorTriangle(i[o],i[o+1],i[o+2]):2===s?e.operatorLine(i[o],i[o+1]):1===s?e.operatorPoint(i[o]):u["a"].error("KdTree::intersect() unsupported vertices count :"+s)}},intersect:function(e,t){t._first<0?this._intersectFunctor(e,t):e.enter(t._bb)&&(t._first>0&&this.intersect(e,this._kdNodes[t._first]),t._second>0&&this.intersect(e,this._kdNodes[t._second]),e.leave())},intersectLineSegment:function(e,t,r,n){if(t._first<0)this._intersectFunctor(e,t);else{var a=t._nodeRayStart,o=t._nodeRayEnd;i["f"].copy(a,r),i["f"].copy(o,n);var s,u=this._kdNodes;t._first>0&&(s=u[t._first],e.enter(s._bb,a,o)&&this.intersectLineSegment(e,s,a,o)),t._second>0&&(i["f"].copy(a,r),i["f"].copy(o,n),s=u[t._second],e.enter(s._bb,a,o)&&this.intersectLineSegment(e,s,a,o))}}},"osg","KdTree"),t["a"]=f},"05ec":function(e,t,r){"use strict";var n=r("b797"),i=r("123d"),a=r("2857"),o=function(e,t){i["a"].call(this),this._nbTarget=e,this._enable=!t,this._targetNames={},this._hashNames="",this._hash="",this._dirtyHash=!0};o.uniforms={},n["a"].createPrototypeStateAttribute(o,n["a"].objectInherit(i["a"].prototype,{attributeType:"Morph",cloneType:function(){return new o(void 0,!0)},hasTarget:function(e){return!!this._targetNames[e]},copyTargetNames:function(e){for(var t=this._targetNames,r="",n=t.length=e.length,i=0;i<n;++i){var a=e[i];t[a]=!0,r+=a}this._hashNames=r,this._dirtyHash=!0},getOrCreateUniforms:function(){var e=o,t=this.getNumTargets();return e.uniforms[t]||(e.uniforms[t]={uTargetWeights:a["a"].createFloat4("uTargetWeights")}),e.uniforms[t]},setNumTargets:function(e){this._nbTarget=e,this._dirtyHash=!0},getNumTargets:function(){return this._nbTarget},setTargetWeights:function(e){this._targetWeights=e},getTargetWeights:function(){return this._targetWeights},isEnabled:function(){return this._enable},getHash:function(){return this._dirtyHash?(this._hash=this._computeInternalHash(),this._dirtyHash=!1,this._hash):this._hash},_computeInternalHash:function(){return this.getTypeMember()+this._hashNames+this.getNumTargets()+this.isEnabled()},apply:function(){if(this._enable){var e=this.getOrCreateUniforms();e.uTargetWeights.setFloat4(this._targetWeights)}}}),"osgAnimation","MorphAttribute"),t["a"]=o},"06c5":function(e,t,r){"use strict";r("4ec9"),r("d3b7"),r("3ca3"),r("ddb0"),r("a434");var n=r("a214"),i=r("b797"),a=r("40fc"),o=r("16cb"),s=r("1ad5"),u=function(e){var t;return e instanceof i["a"].Float32Array&&(t=5126),e instanceof i["a"].Int16Array&&(t=5122),e instanceof i["a"].Uint16Array&&(t=5123),e instanceof i["a"].Int8Array&&(t=5120),e instanceof i["a"].Uint8Array&&(t=5121),e instanceof i["a"].Uint8ClampedArray&&(t=5121),e instanceof i["a"].Int32Array&&(t=5124),e instanceof i["a"].Uint32Array&&(t=5125),t},c=function e(t,r,s){o["a"].call(this),this._instanceID=a["a"].getInstanceID(),this.dirty(),this._itemSize=s,this._target="string"===typeof t?e[t]:t,this._type=void 0,this._normalize=!1,r&&(void 0===r.byteLength&&(n["a"].warn("BufferArray with non typedArray elements is deprecated"),r=this._target===e.ELEMENT_ARRAY_BUFFER?new i["a"].Uint16Array(r):new i["a"].Float32Array(r)),this.setElements(r)),this._usage=e.STATIC_DRAW};c.ELEMENT_ARRAY_BUFFER=34963,c.ARRAY_BUFFER=34962,c.STATIC_DRAW=35044,c.DYNAMIC_DRAW=35048,c.STREAM_DRAW=35040,c._sDeletedGLBufferArrayCache=new window.Map,c.deleteGLBufferArray=function(e,t){c._sDeletedGLBufferArrayCache.has(e)||c._sDeletedGLBufferArrayCache.set(e,[]),c._sDeletedGLBufferArrayCache.get(e).push(t)},c.flushDeletedGLBufferArrays=function(e,t){if(t<=0)return t;if(!c._sDeletedGLBufferArrayCache.has(e))return t;for(var r=0,n=s["a"].instance().tick(),i=c._sDeletedGLBufferArrayCache.get(e),a=i.length,o=a-1;o>=0&&r<t;o--)e.deleteBuffer(i[o]),i.splice(o,1),r=s["a"].instance().deltaS(n,s["a"].instance().tick());return t-r},c.flushAllDeletedGLBufferArrays=function(e){if(c._sDeletedGLBufferArrayCache.has(e))for(var t=c._sDeletedGLBufferArrayCache.get(e),r=t.length,n=r-1;n>=0;n--)e.deleteBuffer(t[n]),t.splice(n,1)},c.onLostContext=function(e){if(c._sDeletedGLBufferArrayCache.has(e)){var t=c._sDeletedGLBufferArrayCache.get(e);t.length=0}},i["a"].createPrototypeObject(c,i["a"].objectInherit(o["a"].prototype,{setUsage:function(e){this._usage=e},getUsage:function(){return this._usage},getInstanceID:function(){return this._instanceID},setItemSize:function(e){this._itemSize=e},isValid:function(){return!!this._buffer||!(!this._elements||!this._elements.length)},invalidate:function(){this._buffer=void 0,this.dirty()},releaseGLObjects:function(){void 0!==this._buffer&&null!==this._buffer&&void 0!==this._gl&&(c.deleteGLBufferArray(this._gl,this._buffer),o["a"].removeObject(this._gl,this)),this.invalidate()},setNormalize:function(e){this._normalize=e},getNormalize:function(){return this._normalize},bind:function(e){this._gl||this.setGraphicContext(e);var t=this._target,r=this._buffer;r?e.bindBuffer(t,r):!r&&this._elements.length>0&&(this._buffer=e.createBuffer(),this._numItems=this._elements.length/this._itemSize,e.bindBuffer(t,this._buffer))},getItemSize:function(){return this._itemSize},dirty:function(){this._dirty=!0},isDirty:function(){return this._dirty},compile:function(e){this._dirty&&(e.bufferData(this._target,this._elements,this._usage),this._dirty=!1)},getElements:function(){return this._elements},setElements:function(e){this._elements=e,this._type=u(e),this._dirty=!0},getType:function(){return this._type}}),"osg","BufferArray"),t["a"]=c},"094b":function(e,t,r){"use strict";r("ac1f"),r("1276"),r("d3b7"),r("25f0"),r("5cc6"),r("907a"),r("9a8c"),r("a975"),r("735e"),r("c1ac"),r("d139"),r("3a7b"),r("d5d6"),r("82f8"),r("e91f"),r("60bd"),r("5f96"),r("3280"),r("3fcc"),r("ca91"),r("25a1"),r("cd26"),r("3c5d"),r("2954"),r("649e"),r("219c"),r("170b"),r("b39a"),r("72f7"),r("84c3"),r("ddb0");var n=r("f684"),i=r.n(n),a=r("b797"),o=r("1c38"),s=r("11e6"),u={prefixURL:"",databasePath:"",progressXHRCallback:void 0,readNodeURL:void 0,readImageURL:void 0,readBinaryArrayURL:void 0,imageLoadingUsePromise:!0,imageOnload:void 0,imageCrossOrigin:void 0},c=u,l=r("3ee6"),h=r("a214"),d=r("4e92"),f=r("06c5"),_=r("6ec8"),p=r("d50c"),g=r("931a"),m=r("16f6"),v=a["a"].rejectObject,b=function(e,t){this._json=e;var r=t;void 0===r&&(r={}),this._identifierMap=r,this._objectRegistry={},this._cacheReadObject={},this.setOptions(a["a"].objectMix({},c))};b.imageFallback||(b.imageFallback=function(){var e=new window.Image;return e.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2P8DwQACgAD/il4QJ8AAAAASUVORK5CYII=",e}()),b.prototype={clone:function(){var e=new b;return e._objectRegistry=this._objectRegistry,e._cacheReadObject=this._cacheReadObject,e},setOptions:function(e){this._defaultOptions=e},getOptions:function(){return this._defaultOptions},setProgressXHRCallback:function(e){this._defaultOptions.progressXHRCallback=e},setReadNodeURLCallback:function(e){this._defaultOptions.readNodeURL=e},registerObject:function(e,t){this._objectRegistry[e]=t},getJSON:function(){return this._json},setJSON:function(e){return this._json=e,this},setPrefixURL:function(e){this._defaultOptions.prefixURL=e},getPrefixURL:function(){return this._defaultOptions.prefixURL},setDatabasePath:function(e){this._defaultOptions.databasePath=e},getDatabasePath:function(){return this._defaultOptions.databasePath},computeURL:function(e){return"string"===typeof this._defaultOptions.prefixURL&&this._defaultOptions.prefixURL.length>0?this._defaultOptions.prefixURL+e:e},requestFile:function(e,t){return s["a"].requestURI(e,t)},getObjectWrapper:function(e){if(this._objectRegistry[e])return new this._objectRegistry[e];for(var t={osg:o["default"]},r=e.split("."),n=0,i=r.length;n<i;n++){var a=t[r[n]];if(void 0===a)return;t=a}return this._objectRegistry[e]=t,new t},fetchImage:function(e,t,r){var n="data:image/",a=t.substring(0,n.length)===n,o=new window.Image;return!a&&r.imageCrossOrigin&&(o.crossOrigin=r.imageCrossOrigin),e.setURL(t),e.setImage(o),o.src=t,new i.a((function(n){o.onerror=function(){h["a"].warn("warning use white texture as fallback instead of "+t),e.setImage(b.imageFallback),n(e)},o.onload=function(){r.imageOnload&&r.imageOnload.call(e),n(e)}}))},readImageURL:function(e,t){if(void 0===t&&(t=this._defaultOptions),t.readImageURL)return t.readImageURL.call(this,e,t);"data:image"!==e.substr(0,10)&&(e=this.computeURL(e));var r=new d["a"];return this.fetchImage(r,e,t)},readNodeURL:function(e,t){var n=t;if(void 0===n&&(n=this._defaultOptions),n.readNodeURL)return n.readNodeURL.call(this,e,n);e=this.computeURL(e);var i=this;if(n=a["a"].objectMix({},n),!n.prefixURL){var o=i.getPrefixURL(),s=e.lastIndexOf("/");-1!==s&&(o=e.substring(0,s+1)),n.prefixURL=o}var u=r("7440").default,c=function(t){return u.parseSceneGraph(t,n).then((function(t){return h["a"].log("loaded "+e),t}))},d=function(e){function t(e){return e.length<2?"0"+e:e}function r(e){for(var r="",n=0,i=e.length;n<i;++n)r+="%"+t(e[n].toString(16));return r=decodeURIComponent(r),r}var n=e;l["a"].isGunzipBuffer(e)&&(n=l["a"].gunzip(e));var i=new Uint8Array(n),a=r(i);return a};a["a"].time("osgjs.metric:Input.readNodeURL",h["a"].INFO);var f=i.requestFile(e);return f.then((function(t){var r;try{r=JSON.parse(t)}catch(a){h["a"].error("cant parse url "+e+" try to gunzip")}if(r)return c(r);var n=i.requestFile(e,{responseType:"arraybuffer"});return n.then((function(e){var t=d(e);return r=JSON.parse(t),c(r)})).catch((function(t){var r="cant read file "+e+" status "+t;return h["a"].error(r),r}))})).catch((function(t){var r="cant get file "+e+" status "+t;return h["a"].error(r),r})).finally((function(){a["a"].timeEnd("osgjs.metric:Input.readNodeURL")}))},_unzipTypedArray:function(e){var t=new Uint8Array(e);if(31===t[0]&&139===t[1]){var n=r("a8a2");n||h["a"].error("osg failed to use a gunzip.min.js to uncompress a gz file.\n You can add this vendors to enable this feature or adds the good header in your gzip file served by your server");var i=new n.Gunzip(t),a=i.decompress();return a.buffer}return e},readBinaryArrayURL:function(e,t){if(void 0===t&&(t=this._defaultOptions),t.readBinaryArrayURL)return t.readBinaryArrayURL.call(this,e,t);if(e=this.computeURL(e),void 0!==this._identifierMap[e])return this._identifierMap[e];var r=this.requestFile(e,{responseType:"arraybuffer",progress:this._defaultOptions.progressXHRCallback}),n=this;return this._identifierMap[e]=r.then((function(e){return n._unzipTypedArray(e)})),this._identifierMap[e]},initializeBufferArray:function(e,t,r,n){if(void 0===n&&(n=this.getOptions()),n.initializeBufferArray)return n.initializeBufferArray.call(this,e,t,r);var i=e.File;return this.readBinaryArrayURL(i).then((function(n){var i,o;(function(){var e=new Uint8Array([18,52]),t=new Uint16Array(e.buffer);o="1234"===t[0].toString(16)})();var s=0;void 0!==e.Offset&&(s=e.Offset);var u=a["a"][t].BYTES_PER_ELEMENT,c=e.Size,l=r.getItemSize(),d=c*u*l;if(o){h["a"].log("big endian detected");var f=a["a"][t],_=new f(c*l),p=new DataView(n,s,d),g=0,m=_.length;if("Uint16Array"===t)for(;g<m;g++)_[g]=p.getUint16(g*u,!0);else if("Float32Array"===t)for(;g<m;g++)_[g]=p.getFloat32(g*u,!0);else if("Uint32Array"===t)for(;g<m;g++)_[g]=p.getUint32(g*u,!0);i=_,p=null}else i=new a["a"][t](n,s,l*c);return r.setElements(i),r}))},readBufferArray:function(e){var t,r,n=this.getJSON(),o=n.UniqueID;if(void 0!==o&&(t=this._identifierMap[o],void 0!==t))return t;if(void 0===e&&(e=this.getOptions()),e.readBufferArray)return e.readBufferArray.call(this);if(!n.Elements&&!n.Array||!n.ItemSize||!n.Type)return v("BufferArray",n);if(n.Elements)r=i.a.resolve(new f["a"](f["a"][n.Type],n.Elements,n.ItemSize));else if(n.Array){var s,u,c=new f["a"](f["a"][n.Type]);if(c.setItemSize(n.ItemSize),n.Array.Float32Array?(s=n.Array.Float32Array,u="Float32Array"):n.Array.Uint16Array?(s=n.Array.Uint16Array,u="Uint16Array"):n.Array.Uint8Array?(s=n.Array.Uint8Array,u="Uint8Array"):n.Array.Uint32Array&&(s=n.Array.Uint32Array,u="Uint32Array"),void 0===s)return v("Typed Array "+window.Object.keys(n.Array)[0]);s.File?r=this.initializeBufferArray(s,u,c):s.Elements&&(c.setElements(new a["a"][u](s.Elements)),r=i.a.resolve(c))}return void 0!==o&&(this._identifierMap[o]=r),r},readUserDataContainer:function(){var e,t=this.getJSON(),r=t.UniqueID;return void 0!==r&&(e=this._identifierMap[r],void 0!==e)?e.Values:(this._identifierMap[r]=t,t.Values)},readPrimitiveSet:function(){var e,t,r,n,a,o,s,u=this.getJSON(),c=u.DrawElementUShort||u.DrawElementUByte||u.DrawElementUInt||u.DrawElementsUShort||u.DrawElementsUByte||u.DrawElementsUInt,l=u.DrawArray||u.DrawArrays,h=u.DrawArrayLengths;if(c){if(e=c.UniqueID,void 0!==e&&(t=this._identifierMap[e],void 0!==t))return t;a=c.Mode?m["a"][c.Mode]:m["a"].TRIANGLES,n=new g["a"](a),this.setJSON(c.Indices),r=this.readBufferArray().then((function(e){return n.setIndices(e),n})),this.setJSON(u)}else if(l){if(e=l.UniqueID,void 0!==e&&(t=this._identifierMap[e],void 0!==t))return t;a=l.Mode||l.mode,o=void 0!==l.First?l.First:l.first,s=void 0!==l.Count?l.Count:l.count,n=new _["a"](m["a"][a],o,s),r=i.a.resolve(n)}else if(h){if(e=h.UniqueID,void 0!==e&&(t=this._identifierMap[e],void 0!==t))return t;a=h.Mode,o=h.First;var d=h.ArrayLengths;n=new p["a"](m["a"][a],o,d),r=i.a.resolve(n)}else r=v("PrimitiveSet",u);return void 0!==e&&(this._identifierMap[e]=r),r},readObject:function(){var e=this.getJSON(),t=window.Object.keys(e),n=t[0];if(!n)return v("can't find property for object "+t);var i,a=e[n].UniqueID;if(void 0!==a&&(i=this._identifierMap[a],void 0!==i))return i;var o=this.getObjectWrapper(n);if(!o)return v("can't instanciate object "+n);var s=r("7440").default,u=s.ObjectWrapper.serializers;if(this._cacheReadObject[n])u=this._cacheReadObject[n];else{for(var c=n.split("."),l=0,h=c.length;l<h;l++){var d=c[l],f=u[d];if(!f)return v("Unknown scope "+n+"("+d+")");u=f}this._cacheReadObject[n]=u}var _=u(this.setJSON(e[n]),o);return void 0!==a&&(this._identifierMap[a]=_,o._uniqueID=a),_}};t["a"]=b},"0fd6":function(e,t,r){"use strict";r("a15b"),r("ac1f"),r("00b4"),r("1276"),r("4d63"),r("c607"),r("2c3e"),r("25f0"),r("5319");var n,i=r("a214"),a=r("5fe3"),o=r("9998"),s=function(){n||(n=r("8130").default),this._checkRTT={},this._webGLExtensions={},this._webGLParameters={},this._webGLShaderMaxInt="NONE",this._webGLShaderMaxFloat="NONE",this._bugsDB={},this._webGLPlatforms={},this._webGLParameters["MAX_COMBINED_TEXTURE_IMAGE_UNITS"]=8,this._webGLParameters["MAX_CUBE_MAP_TEXTURE_SIZE"]=16,this._webGLParameters["MAX_FRAGMENT_UNIFORM_VECTORS"]=16,this._webGLParameters["MAX_RENDERBUFFER_SIZE"]=1,this._webGLParameters["MAX_TEXTURE_IMAGE_UNITS"]=8,this._webGLParameters["MAX_TEXTURE_SIZE"]=64,this._webGLParameters["MAX_VARYING_VECTORS"]=8,this._webGLParameters["MAX_VERTEX_ATTRIBS"]=8,this._webGLParameters["MAX_VERTEX_TEXTURE_IMAGE_UNITS"]=0,this._webGLParameters["MAX_VERTEX_UNIFORM_VECTORS"]=128,this._webGLParameters["MAX_VIEWPORT_DIMS"]=[1,1],this._webGLParameters["NUM_COMPRESSED_TEXTURE_FORMATS"]=0,this._webGLParameters["MAX_SHADER_PRECISION_FLOAT"]="none",this._webGLParameters["MAX_SHADER_PRECISION_INT"]="none",this._gl=void 0};s.instance=function(e,t){if(!s._instance){var r,n=e;if(!n){var u="undefined"!==typeof window&&window.gli;u&&(r=window.gli.host.inspectContext,window.gli.host.inspectContext=!1);var c=document.createElement("canvas");c.width=32,c.height=32;var l=new o["a"];l.extend({antialias:!1}),l.extendWithOptionsURL(),n=a["a"].setupWebGL(c,l,(function(){}))}s._instance=new s,n?s._instance.init(n):i["a"].warn("no support for webgl context detected."),r&&(window.gli.host.inspectContext=r)}return e&&(t||e!==s._instance.getContext())&&s._instance.initContextDependant(e),s._instance},s.prototype={getContext:function(){return this._gl},initContextDependant:function(e){this._gl=e,this._isGL2="undefined"!==typeof window.WebGL2RenderingContext&&e instanceof window.WebGL2RenderingContext,this.initWebGLExtensions(e),this.hasLinearHalfFloatRTT(e),this.hasLinearFloatRTT(e),this.hasHalfFloatRTT(e),this.hasFloatRTT(e)},init:function(e){if(this.initWebGLParameters(e),this.initPlatformSupport(),this.initBugDB(e),this.initContextDependant(e),this._isGL2)for(var t=["OES_element_index_uint","EXT_sRGB","EXT_blend_minmax","EXT_frag_depth","WEBGL_depth_texture","EXT_shader_texture_lod","OES_standard_derivatives","OES_texture_float","OES_texture_half_float","OES_texture_half_float_linear","OES_texture_float_linear","OES_vertex_array_object","WEBGL_draw_buffers","OES_fbo_render_mipmap","ANGLE_instanced_arrays"],r=s._instance.getWebGLExtensions(),n=function(){},i=0,a=t.length;i<a;i++)r[t[i]]=n},isWebGL2:function(){return this._isGL2},initBugDB:function(e){var t=this._webGLPlatforms,r=this._webGLParameters;if(t.Apple&&(r.UNMASKED_VENDOR_WEBGL&&-1===r.UNMASKED_VENDOR_WEBGL.indexOf("Intel")||(this._bugsDB["OES_standard_derivatives"]=!0)),e.getExtension("EXT_shader_texture_lod")){var n={type:"FRAGMENT_SHADER",text:["#version 100","#extension GL_EXT_shader_texture_lod : require","#ifdef GL_FRAGMENT_PRECISION_HIGH"," precision highp float;","#else"," precision mediump float;","#endif","uniform samplerCube uT0;","varying vec3 vC;","void main(void) {"," gl_FragColor = textureCubeLodEXT(uT0, vC, 1.0);","}"].join("\n")},i=this.checkShader(e,n.type,n.text);i||(this._bugsDB["EXT_shader_texture_lod"]=!0)}},checkShader:function(e,t,r){var n=t;"string"===typeof n&&(n=e[t]);var a=e.createShader(n);return e.shaderSource(a,r),e.compileShader(a),!(!e.getShaderParameter(a,e.COMPILE_STATUS)&&!e.isContextLost())||(i["a"].warn(e.getShaderInfoLog(a)),!1)},initPlatformSupport:function(){var e=this._webGLPlatforms;e.Apple=-1!==navigator.vendor.indexOf("Apple")||-1!==navigator.vendor.indexOf("OS X"),e.Mobile=/Mobi/.test(navigator.userAgent)||/ablet/.test(navigator.userAgent)},getWebGLPlatform:function(e){return this._webGLPlatforms[e]},getWebGLPlatforms:function(){return this._webGLPlatforms},getWebGLParameter:function(e){return this._webGLParameters[e]},getWebGLParameters:function(){return this._webGLParameters},getShaderMaxPrecisionFloat:function(){return this._webGLParameters.MAX_SHADER_PRECISION_FLOAT},getShaderMaxPrecisionInt:function(){return this._webGLParameters.MAX_SHADER_PRECISION_INT},checkSupportRTT:function(e,t,r){var n=t+","+r;if(this._isGL2)return!!this._webGLExtensions["EXT_color_buffer_float"];if(void 0!==this._checkRTT[n])return this._checkRTT[n];if(!e)return!1;var i=e.createTexture();e.bindTexture(e.TEXTURE_2D,i),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,2,2,0,e.RGBA,t,null),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,r),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,r);var a=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,a),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,i,0);var o=this._checkRTT[n]=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.deleteTexture(i),e.deleteFramebuffer(a),e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),o},hasLinearHalfFloatRTT:function(e){return this._webGLExtensions["OES_texture_half_float_linear"]&&this.checkSupportRTT(e,n.HALF_FLOAT_OES,n.LINEAR)},hasLinearFloatRTT:function(e){return this._webGLExtensions["OES_texture_float_linear"]&&this.checkSupportRTT(e,n.FLOAT,n.LINEAR)},hasHalfFloatRTT:function(e){return this._webGLExtensions["OES_texture_half_float"]&&this.checkSupportRTT(e,n.HALF_FLOAT_OES,n.NEAREST)},hasFloatRTT:function(e){return this._webGLExtensions["OES_texture_float"]&&this.checkSupportRTT(e,n.FLOAT,n.NEAREST)},queryPrecision:function(e,t,r){var n=e.getShaderPrecisionFormat(t,r);return!!n&&0!==n.precision},hasVAO:function(){return!!this._webGLExtensions["OES_vertex_array_object"]},getDisjointTimerQuery:function(){return this._webGLExtensions["EXT_disjoint_timer_query_webgl2"]||this._webGLExtensions["EXT_disjoint_timer_query"]},initWebGLParameters:function(e){if(e){for(var t=["MAX_COMBINED_TEXTURE_IMAGE_UNITS","MAX_CUBE_MAP_TEXTURE_SIZE","MAX_FRAGMENT_UNIFORM_VECTORS","MAX_RENDERBUFFER_SIZE","MAX_TEXTURE_IMAGE_UNITS","MAX_TEXTURE_SIZE","MAX_VARYING_VECTORS","MAX_VERTEX_ATTRIBS","MAX_VERTEX_TEXTURE_IMAGE_UNITS","MAX_VERTEX_UNIFORM_VECTORS","MAX_VIEWPORT_DIMS","SHADING_LANGUAGE_VERSION","VERSION","VENDOR","RENDERER","ALIASED_LINE_WIDTH_RANGE","ALIASED_POINT_SIZE_RANGE","RED_BITS","GREEN_BITS","BLUE_BITS","ALPHA_BITS","DEPTH_BITS","STENCIL_BITS"],r=this._webGLParameters,n=0,i=t.length;n<i;++n){var a=t[n];r[a]=e.getParameter(e[a])}this.queryPrecision(e,e.FRAGMENT_SHADER,e.HIGH_FLOAT)?r.MAX_SHADER_PRECISION_FLOAT="high":this.queryPrecision(e,e.FRAGMENT_SHADER,e.MEDIUM_FLOAT)?r.MAX_SHADER_PRECISION_FLOAT="medium":this.queryPrecision(e,e.FRAGMENT_SHADER,e.LOW_FLOAT)&&(r.MAX_SHADER_PRECISION_FLOAT="low"),this.queryPrecision(e,e.FRAGMENT_SHADER,e.HIGH_INT)?r.MAX_SHADER_PRECISION_INT="high":this.queryPrecision(e,e.FRAGMENT_SHADER,e.MEDIUM_INT)?r.MAX_SHADER_PRECISION_INT="medium":this.queryPrecision(e,e.FRAGMENT_SHADER,e.LOW_INT)&&(r.MAX_SHADER_PRECISION_INT="low");var o=e.getExtension("WEBGL_debug_renderer_info");o&&(r.UNMASKED_RENDERER_WEBGL=e.getParameter(o.UNMASKED_RENDERER_WEBGL),r.UNMASKED_VENDOR_WEBGL=e.getParameter(o.UNMASKED_VENDOR_WEBGL))}},applyExtension:function(e,t){var r=e.getExtension(t),n=t.split("_")[0],i="_"+n,a=new RegExp(n+"$"),o=new RegExp(i);for(var s in r){var u=r[s];if("function"===typeof u){var c=s.replace(a,"");void 0===e[c]&&(e[c]=r[s].bind(r))}else{var l=s.replace(o,"");void 0===e[l]&&(e[l]=r[s])}}},getWebGLExtension:function(e){return this._webGLExtensions[e]},getWebGLExtensions:function(){return this._webGLExtensions},_checkShader:function(e,t,r){var n=t;"string"===typeof n&&(n=e[t]);var i=e.createShader(n);return e.shaderSource(i,r),e.compileShader(i),!(!e.getShaderParameter(i,e.COMPILE_STATUS)&&!e.isContextLost())},_doubleCheckExtension:function(e,t){var r=["#version 100","#extension GL_%ext% : require","precision mediump float;","varying vec3 vColor;","void main() {","gl_FragColor = vec4(vColor, 1.0);","}"].join("\n");return this._checkShader(e,"FRAGMENT_SHADER",r.replace(/\%ext\%/g,t))},initWebGLExtensions:function(e,t){if(e){var r=t;void 0===r&&(r=!0);var i=e.getSupportedExtensions();if(i){for(var a=this._webGLExtensions,o=0,s=i.length;o<s;++o){var u=i[o];r&&this._bugsDB[u]||(a[u]=e.getExtension(u),this._isGL2||this.applyExtension(e,u))}if(!this._isGL2){var c="EXT_shader_texture_lod";a[c]&&!this._doubleCheckExtension(e,c)&&delete a[c]}var l=this.getWebGLExtension("EXT_texture_filter_anisotropic");l&&(n.ANISOTROPIC_SUPPORT_EXT=!0,n.ANISOTROPIC_SUPPORT_MAX=e.getParameter(l.MAX_TEXTURE_MAX_ANISOTROPY_EXT))}}}},t["a"]=s},1025:function(e,t,r){"use strict";var n=r("3972"),i=r("16f6"),a=r("931a"),o=r("6ec8"),s=[],u=[];s[i["a"].POINTS]=function(){var e=n["f"].create();return function(t,r,n,i,a){for(var o=t+r,s=t;s<o;++s){var u=3*n[s];e[0]=a[u],e[1]=a[u+1],e[2]=a[u+2],i.operatorPoint(e)}}}(),s[i["a"].LINES]=function(){var e=n["f"].create(),t=n["f"].create();return function(r,n,i,a,o){for(var s=r+n,u=r;u<s-1;u+=2){var c=3*i[u];e[0]=o[c],e[1]=o[c+1],e[2]=o[c+2],c=3*i[u+1],t[0]=o[c],t[1]=o[c+1],t[2]=o[c+2],a.operatorLine(e,t)}}}(),s[i["a"].LINE_STRIP]=function(){var e=n["f"].create(),t=n["f"].create();return function(r,n,i,a,o){for(var s=r+n,u=r;u<s-1;++u){var c=3*i[u];e[0]=o[c],e[1]=o[c+1],e[2]=o[c+2],c=3*i[u+1],t[0]=o[c],t[1]=o[c+1],t[2]=o[c+2],a.operatorLine(e,t)}}}(),s[i["a"].LINE_LOOP]=function(){var e=n["f"].create(),t=n["f"].create();return function(r,n,i,a,o){for(var s=r+n-1,u=r;u<s;++u){var c=3*i[u];e[0]=o[c],e[1]=o[c+1],e[2]=o[c+2],c=3*i[u+1],t[0]=o[c],t[1]=o[c+1],t[2]=o[c+2],a.operatorLine(e,t)}s=3*i[s],e[0]=o[s],e[1]=o[s+1],e[2]=o[s+2];var l=3*i[0];t[0]=o[l],t[1]=o[l+1],t[2]=o[l+2],a.operatorLine(e,t)}}(),s[i["a"].TRIANGLES]=function(){var e=n["f"].create(),t=n["f"].create(),r=n["f"].create();return function(n,i,a,o,s){for(var u=n+i,c=n;c<u;c+=3){var l=3*a[c];e[0]=s[l],e[1]=s[l+1],e[2]=s[l+2],l=3*a[c+1],t[0]=s[l],t[1]=s[l+1],t[2]=s[l+2],l=3*a[c+2],r[0]=s[l],r[1]=s[l+1],r[2]=s[l+2],o.operatorTriangle(e,t,r)}}}(),s[i["a"].TRIANGLE_STRIP]=function(){var e=n["f"].create(),t=n["f"].create(),r=n["f"].create();return function(n,i,a,o,s){for(var u=2,c=n;u<i;++u,++c){var l=3*a[c];e[0]=s[l],e[1]=s[l+1],e[2]=s[l+2],l=3*a[c+1],t[0]=s[l],t[1]=s[l+1],t[2]=s[l+2],l=3*a[c+2],r[0]=s[l],r[1]=s[l+1],r[2]=s[l+2],u%2?o.operatorTriangle(e,r,t):o.operatorTriangle(e,t,r)}}}(),s[i["a"].TRIANGLE_FAN]=function(){var e=n["f"].create(),t=n["f"].create(),r=n["f"].create();return function(n,i,a,o,s){for(var u=a[n],c=2,l=n+1;c<i;++c,++l){e[0]=s[u],e[1]=s[u+1],e[2]=s[u+2];var h=3*a[l];t[0]=s[h],t[1]=s[h+1],t[2]=s[h+2],h=3*a[l+1],r[0]=s[h],r[1]=s[h+1],r[2]=s[h+2],o.operatorTriangle(e,t,r)}}}(),u[i["a"].POINTS]=function(){var e=n["f"].create();return function(t,r,n,i){for(var a=t;a<t+r;++a){var o=3*a;e[0]=i[o],e[1]=i[o+1],e[2]=i[o+2],n.operatorPoint(e)}}}(),u[i["a"].LINES]=function(){var e=n["f"].create(),t=n["f"].create();return function(r,n,i,a){for(var o=r;o<r+n-1;o+=2){var s=3*o;e[0]=a[s],e[1]=a[s+1],e[2]=a[s+2],s=3*(o+1),t[0]=a[s],t[1]=a[s+1],t[2]=a[s+2],i.operatorLine(e,t)}}}(),u[i["a"].LINE_STRIP]=function(){var e=n["f"].create(),t=n["f"].create();return function(r,n,i,a){for(var o=r;o<r+n-1;++o){var s=3*o;e[0]=a[s],e[1]=a[s+1],e[2]=a[s+2],s=3*(o+1),t[0]=a[s],t[1]=a[s+1],t[2]=a[s+2],i.operatorLine(e,t)}}}(),u[i["a"].LINE_LOOP]=function(){var e=n["f"].create(),t=n["f"].create();return function(r,n,i,a){for(var o=r+n-1,s=r;s<o;++s){var u=3*s;e[0]=a[u],e[1]=a[u+1],e[2]=a[u+2],u=3*(s+1),t[0]=a[u],t[1]=a[u+1],t[2]=a[u+2],i.operatorLine(e,t)}o*=3,e[0]=a[o],e[1]=a[o+1],e[2]=a[o+2],r*=3,t[0]=a[r],t[1]=a[r+1],t[2]=a[r+2],i.operatorLine(e,t)}}(),u[i["a"].TRIANGLES]=function(){var e=n["f"].create(),t=n["f"].create(),r=n["f"].create();return function(n,i,a,o){for(var s=n;s<n+i;s+=3){var u=3*s;e[0]=o[u],e[1]=o[u+1],e[2]=o[u+2],u=3*(s+1),t[0]=o[u],t[1]=o[u+1],t[2]=o[u+2],u=3*(s+2),r[0]=o[u],r[1]=o[u+1],r[2]=o[u+2],a.operatorTriangle(e,t,r)}}}(),u[i["a"].TRIANGLE_STRIP]=function(){var e=n["f"].create(),t=n["f"].create(),r=n["f"].create();return function(n,i,a,o){for(var s=2,u=n;s<i;++s,++u){var c=3*u;e[0]=o[c],e[1]=o[c+1],e[2]=o[c+2],c=3*(u+1),t[0]=o[c],t[1]=o[c+1],t[2]=o[c+2],c=3*(u+2),r[0]=o[c],r[1]=o[c+1],r[2]=o[c+2],s%2?a.operatorTriangle(e,r,t):a.operatorTriangle(e,t,r)}}}(),u[i["a"].TRIANGLE_FAN]=function(){var e=n["f"].create(),t=n["f"].create(),r=n["f"].create();return function(n,i,a,o){for(var s=2,u=n+1;s<i;++s,++u){e[0]=o[n],e[1]=o[n+1],e[2]=o[n+2];var c=3*u;t[0]=o[c],t[1]=o[c+1],t[2]=o[c+2],c=3*(u+1),r[0]=o[c],r[1]=o[c+1],r[2]=o[c+2],a.operatorTriangle(e,t,r)}}}();var c=function(e,t,r){var n=e.getPrimitiveSetList();if(n)for(var i,c=n.length,l=0;l<c;l++){var h=n[l];if(h instanceof a["a"]){if(i=s[h.getMode()],i){var d=h.indices.getElements();i(h.getFirst()/d.BYTES_PER_ELEMENT,h.getCount(),d,t,r)}}else h instanceof o["a"]&&(i=u[h.getMode()],i&&i(h.getFirst(),h.getCount(),t,r))}};t["a"]=c},"112b":function(e,t,r){"use strict";var n=r("53ca"),i=r("a214"),a=0,o=function(){this._name="AbstractNode",this._inputs=[],this._outputs=null,this._id=a++,this._text=void 0};o.prototype={getID:function(){return this._id},getName:function(){return this._name},getType:function(){return this.type},toString:function(){var e="name : "+this._name;return this.type&&(e+=" ("+this.type+")"),e},getInputs:function(){return this._inputs},getOutputs:function(){return this._outputs},checkInputsOutputs:function(){var e,t;if(this.validInputs)for(e=0;e<this.validInputs.length;e++)if(t=this.validInputs[e],!this._inputs[t])return i["a"].error("Shader node "+this.type+" validation error input "+t+" is missing"),!1;if(this.validOutputs)for(e=0;e<this.validOutputs.length;e++)if(t=this.validOutputs[e],!this._outputs[t])return i["a"].error("Shader node "+this.type+" validation error output "+t+" is missing"),!1;return!0},inputs:function(){for(var e=0,t=arguments.length;e<t;e++){var r=arguments[e];if(!r){i["a"].error("Shader node "+this.type+" input number "+t+" is undefined ");break}if(Array.isArray(r))return this.inputs.apply(this,r),this;if("object"===Object(n["a"])(r)&&null!==r&&r instanceof o===!1)return this._inputs=r,this;this._inputs.push(r)}return this},outputs:function(e){if(this._outputs=e,this._outputs instanceof o===!0)this.autoLink(this._outputs);else for(var t in this._outputs)this.autoLink(this._outputs[t]);return this},autoLink:function(e){return void 0===e||e.inputs(this),this},computeShader:function(){return this._text},comment:function(e){this._comment="//"+e},getComment:function(){return this._comment}},t["a"]=o},"11e6":function(e,t,r){"use strict";r("4ec9"),r("d3b7"),r("3ca3"),r("ddb0"),r("2b3d"),r("9861"),r("ac1f"),r("466d"),r("c19f"),r("b0c0");var n=r("f684"),i=r.n(n),a=r("7440"),o=r("6b10"),s=r("dfa5"),u=r("a214"),c=function(e){return"string"===typeof e||e instanceof String},l=function(e){return"blob:http"===e.substr(0,9)},h=function(e){return"http://"===e.substr(0,7)||"https://"===e.substr(0,8)},d=function(e){return!!c(e)&&(l(e)||h(e))},f=window.zip,_=new window.Map,p=function(e){return new i.a((function(t,r){var n=new window.Image;n.onerror=function(){r(n)},n.onload=function(){t(n)},n.src=e}))},g=function(e){var t=window.URL.createObjectURL(e),r=p(t);return r.finally((function(){window.URL.revokeObjectURL(t)})),r},m=function(e){return new i.a((function(t,r){var n=new window.FileReader;n.onerror=function(){r(n)},n.onload=function(){t(this.result)},n.readAsArrayBuffer(e)}))},v=function(e){return Object(s["a"])(e,{responseType:"arraybuffer"})},b=function(e){return Object(s["a"])(e).then((function(e){return JSON.parse(e)}))},S=function(e){var t=JSON.parse(e);return i.a.resolve(t)},x={createJSONFromURL:b,createArrayBufferFromURL:v,createArrayBufferFromBlob:m,createImageFromBlob:g,createImageFromURL:p,requestURI:s["a"],requestResource:function(e,t){var r=x.getExtension(e),n=x.getMimeType(r),i=t&&t.responseType?t.responseType.toLowerCase():void 0;if(i)return Object(s["a"])(e,t);if(n){if(n.match("image"))return p(e);if(n.match("binary"))return v(e);if(n.match("json"))return b(e);if(n.match("text"))return Object(s["a"])(e)}return Object(s["a"])(e)},resolveData:function(e,t){var r,n,a=x.getExtension(e),o=x.getMimeType(a);return o&&(o.match("image")?c(t)?r=p:t instanceof window.Blob&&(r=g):o.match("json")?r=d(t)?b:S:o.match("binary")&&(c(t)?r=v:t instanceof window.Blob&&(r=m))),n=r?r(t):i.a.resolve(t),n},resolveFilesMap:function(e){var t=[];for(var r in e){var n=e[r],a=x.resolveData(r,n).then(function(e,t){this[e]=t}.bind(e,r));t.push(a)}return i.a.all(t).then((function(){return e}))},_unzipEntry:function(e){return new i.a((function(t){var r=e.filename,n=x.getExtension(r),i=x.getMimeType(n),a=f.BlobWriter;null===i.match("text")&&null===i.match("json")||(a=f.TextWriter),e.getData(new a(i),(function(e){t({filename:r,data:e})}))}))},unzipBlob:function(e){return new i.a((function(t,r){var n={},a=[];f.createReader(new f.BlobReader(e),(function(e){e.getEntries((function(r){for(var o=0;o<r.length;o++)if(!r[o].directory){var s=x._unzipEntry(r[o]);s.then((function(e){n[e.filename]=e.data})),a.push(s)}i.a.all(a).then((function(){e.close(),x.resolveFilesMap(n).then((function(e){t(e)}))}))}))}),(function(){r(this)}))}))},unzip:function(e){if(!window.zip)return i.a.reject("missing deps to unzip, require https://github.com/gildas-lormeau/zip.js");if(c(e))return x.requestResource(e).then((function(e){var t=new window.Blob([e],{type:_.get("zip")});return x.unzipBlob(t)}));if(e instanceof window.Blob)return x.unzipBlob(e);if(e instanceof window.ArrayBuffer){var t=new window.Blob([e],{type:_.get("zip")});return x.unzipBlob(t)}return i.a.reject("cant unzip input")},readFileList:function(e){var t,r,n={},u=[];for(r=0;r<e.length;++r){var c=x.getExtension(e[r].name),l=o["a"].instance().getReaderWriterForExtension(c);void 0===l&&"osgjs"!==c||(t=e[r].name);var h,d=x.getMimeType(c);h=d.match("image")?"blob":d.match("json")||d.match("text")?"string":"arraybuffer",u.push(Object(s["a"])(e[r],{responseType:h}))}return i.a.all(u).then((function(i){for(r=0;r<i.length;++r)n[e[r].name]=i[r];return x.resolveFilesMap(n).then((function(e){return a["default"].readNodeURL(t,{filesMap:e})}))}))},getMimeType:function(e){return _.get(e)},getExtension:function(e){return e.substr(e.lastIndexOf(".")+1)},addMimeTypeForExtension:function(e,t){void 0!==_.has(e)&&u["a"].warn("the '"+e+"' already has a mimetype: "+_.get(e)),_.set(e,t)}};_.set("bin","application/octet-binary"),_.set("b3dm","application/octet-binary"),_.set("glb","application/octet-binary"),_.set("zip","application/octet-binary"),_.set("gz","application/octet-binary"),_.set("png","image/png"),_.set("jpg","image/jpeg"),_.set("jpeg","image/jpeg"),_.set("gif","image/gif"),_.set("json","application/json"),_.set("gltf","application/json"),_.set("osgjs","application/json"),_.set("txt","text/plain"),_.set("glsl","text/plain"),t["a"]=x},"123d":function(e,t,r){"use strict";var n=r("b797"),i=r("40fc"),a=function(){i["a"].call(this)};n["a"].createPrototypeStateAttribute(a,n["a"].objectInherit(i["a"].prototype,{_attributeTypeIndex:void 0,getType:function(){return this.attributeType},getTypeMember:function(){return this.attributeType},apply:function(){},getHash:function(){return this.getType()}}),"osg","StateAttribute"),a.OFF=0,a.ON=1,a.OVERRIDE=2,a.PROTECTED=4,a.INHERIT=8,a.OVERRIDE_ON=a.OVERRIDE|a.ON,t["a"]=a},1391:function(e,t,r){"use strict";var n=function e(){e.prototype.reset.call(this)};n.prototype={reset:function(){this._computeNearFar=!0,this._nearFarRatio=.005,this._enableFrustumCulling=!1,this._settingsSourceOverrider=this,this._LODScale=1,this._clampProjectionMatrixCallback=void 0},setCullSettings:function(e){this._computeNearFar=e._computeNearFar,this._nearFarRatio=e._nearFarRatio,this._enableFrustumCulling=e._enableFrustumCulling,this._settingsSourceOverrider=e._settingsSourceOverrider,this._clampProjectionMatrixCallback=e._clampProjectionMatrixCallback},setNearFarRatio:function(e){this._nearFarRatio=e},getNearFarRatio:function(){return this._nearFarRatio},setComputeNearFar:function(e){this._computeNearFar=e},getComputeNearFar:function(){return this._computeNearFar},setEnableFrustumCulling:function(e){this._enableFrustumCulling=e},getEnableFrustumCulling:function(){return this._enableFrustumCulling},getSettingSourceOverrider:function(){return this._settingsSourceOverrider},setClampProjectionMatrixCallback:function(e){this._clampProjectionMatrixCallback=e},getClampProjectionMatrixCallback:function(){return this._clampProjectionMatrixCallback},setLODScale:function(e){this._LODScale=e},getLODScale:function(){return this._LODScale}},t["a"]=n},"16cb":function(e,t,r){"use strict";r("4ec9"),r("d3b7"),r("3ca3"),r("ddb0"),r("a434");var n=r("a214"),i=function(){this._gl=void 0,this._onLostContextCallback=void 0};i.prototype={setGraphicContext:function(e){this._gl=e,i.addObject(this._gl,this)},getGraphicContext:function(){return this._gl},setLostContextCallback:function(e){this._onLostContextCallback=e},onLostContext:function(){this.invalidate&&"function"===typeof this.invalidate&&this.invalidate(),this.invalidate&&"function"===typeof this.invalidate||n["a"].error("GLObject needs Dirty mechanism for webgl restore"),this._onLostContextCallback&&this._onLostContextCallback()}},i._sResourcesArrayCache=new window.Map,i.addObject=function(e,t){i._sResourcesArrayCache.has(e)||i._sResourcesArrayCache.set(e,[]);var r=i._sResourcesArrayCache.get(e);-1===r.indexOf(t)&&r.push(t)},i.removeObject=function(e,t){if(i._sResourcesArrayCache.has(e)){var r=i._sResourcesArrayCache.get(e),n=r.indexOf(t);-1!==n&&r.splice(n,1)}},i.onLostContext=function(e){if(i._sResourcesArrayCache.has(e))for(var t=i._sResourcesArrayCache.get(e),r=0,n=t.length;r<n;r++)t[r].onLostContext()},t["a"]=i},"16f6":function(e,t,r){"use strict";var n={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};t["a"]=n},"187b":function(e,t,r){"use strict";var n=r("b797"),i=r("3972"),a=n["a"].objectInherit(i["g"],{INSIDE:1,INTERSECT:2,OUTSIDE:3,transformProvidingInverse:function(){var e=a.create();return function(t,r){var n=t[0],i=t[1],o=t[2],s=t[3];return e[0]=r[0]*n+r[1]*i+r[2]*o+r[3]*s,e[1]=r[4]*n+r[5]*i+r[6]*o+r[7]*s,e[2]=r[8]*n+r[9]*i+r[10]*o+r[11]*s,e[3]=r[12]*n+r[13]*i+r[14]*o+r[15]*s,a.normalizeEquation(e),a.copy(e,t),t}},normalizeEquation:function(e){var t=1/Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);e[0]*=t,e[1]*=t,e[2]*=t,e[3]*=t},getNormal:function(e,t){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},setNormal:function(e,t){e[0]=t[0],e[1]=t[1],e[2]=t[2]},getDistance:function(e){return e[3]},setDistance:function(e,t){e[3]=t},distanceToPlane:function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]},intersectsOrContainsBoundingSphere:function(e,t){if(!t.valid())return a.OUTSIDE;var r=t.center(),n=t.radius(),i=this.distanceToPlane(e,r);return i<-n?a.OUTSIDE:i<=n?a.INTERSECT:a.INSIDE},instersectsBoundingSphere:function(e,t){return this.intersectsOrContainsBoundingSphere(e,t)===a.INTERSECT},intersectsOrContainsBoundingBox:function(){var e=i["f"].create();return function(t,r){var n=(t[0]>=0?1:0)|(t[1]>=0?2:0)|(t[2]>=0?4:0),i=7&~n;return this.distanceToPlane(t,r.corner(i,e))>0?a.INSIDE:this.distanceToPlane(t,r.corner(n,e))<0?a.OUTSIDE:a.INTERSECT}}(),intersectsBoundingBox:function(e,t,r){return this.intersectsOrContainsBoundingBox(e,t,r)===a.INTERSECT},intersectOrContainsVertices:function(e,t){for(var r=-1,n=0;n<t.length;n++){var i=this.distanceToPlane(e,t[n]);if(i<0){if(1===r)return a.INTERSECT;r=2}else{if(!(i>0))return a.INTERSECT;if(2===r)return a.INTERSECT;r=1}}return r>0?a.INSIDE:a.OUTSIDE},intersectVertices:function(e,t){return this.intersectOrContainsVertices(e,t)===a.INTERSECT}});t["a"]=a},1881:function(e,t,r){"use strict";var n=function(e,t,r){return Math.min(r,Math.max(t,e))},i=function(e,t,r){if(r<=e)return 0;if(r>=t)return 1;var n=(r-e)/(t-e);return n*n*(3-2*n)},a=function(e){return e!==e};t["a"]={clamp:n,smoothStep:i,isNaN:a}},"19cf":function(e,t,r){"use strict";var n=r("b797"),i=r("123d"),a=r("2857"),o=function(e,t){i["a"].call(this),this._enable=!e,this._boneUniformSize=t,this._dirtyHash=!0,this._hash=""};o.uniforms={},o.maxBoneUniformSize=1,o.maxBoneUniformAllowed=1/0,n["a"].createPrototypeStateAttribute(o,n["a"].objectInherit(i["a"].prototype,{attributeType:"Skinning",cloneType:function(){return new o(!0)},getBoneUniformSize:function(){return void 0!==this._boneUniformSize?this._boneUniformSize:o.maxBoneUniformSize},getOrCreateUniforms:function(){var e=o,t=this.getBoneUniformSize();return e.uniforms[t]||(e.uniforms[t]={uBones:a["a"].createFloat4Array("uBones",t)}),e.uniforms[t]},setMatrixPalette:function(e){this._matrixPalette=e,void 0===this._boneUniformSize&&(o.maxBoneUniformSize=Math.max(o.maxBoneUniformSize,e.length/4),o.maxBoneUniformSize=Math.min(o.maxBoneUniformAllowed,o.maxBoneUniformSize))},getMatrixPalette:function(){return this._matrixPalette},isEnabled:function(){return this._enable},getHash:function(){return this._dirtyHash?(this._hash=this._computeInternalHash(),this._dirtyHash=!0,this._hash):this._hash},_computeInternalHash:function(){return this.getTypeMember()+this.getBoneUniformSize()+this.isEnabled()},apply:function(){this._enable&&this.getOrCreateUniforms().uBones.getInternalArray().set(this._matrixPalette)}}),"osgAnimation","SkinningAttribute"),t["a"]=o},"1ad5":function(e,t,r){"use strict";(function(e){var r=function(){var t=window||e;if(void 0===t.performance)return function(){return Date.now()};var r=t.performance.now||t.performance.mozNow||t.performance.msNow||t.performance.oNow||t.performance.webkitNow||function(){return Date.now()};return function(){return r.apply(t.performance,arguments)}}(),n=function(){};n.instance=function(){return n._instance||(n._instance=new n),n._instance},n.tick=r,n.prototype={deltaS:function(e,t){return(t-e)/1e3},deltaM:function(e,t){return t-e},tick:function(){return r()}},t["a"]=n}).call(this,r("c8ba"))},"1c38":function(e,t,r){"use strict";r.r(t);var n=r("6ec3"),i=r("b797"),a=r("123d"),o=function(){a["a"].call(this),this._attributeEnable=!1};i["a"].createPrototypeStateAttribute(o,i["a"].objectInherit(a["a"].prototype,{attributeType:"Billboard",cloneType:function(){return new o},setEnabled:function(e){this._attributeEnable=e},isEnabled:function(){return this._attributeEnable},apply:function(){}}),"osg","Billboard");var s=o,u=r("65ea"),c=r("aee2"),l=r("ecf1"),h=r("a741"),d=r("06c5"),f=r("60b6"),_=r("38f3"),p=function(e,t,r,n){a["a"].call(this),this._red=!0,this._green=!0,this._blue=!0,this._alpha=!0,void 0!==e&&void 0!==t&&void 0!==r&&this.setMask(e,t,r,n)};i["a"].createPrototypeStateAttribute(p,i["a"].objectInherit(a["a"].prototype,{attributeType:"ColorMask",cloneType:function(){return new p},setMask:function(e,t,r,n){this._red=!!e,this._green=!!t,this._blue=!!r,this._alpha=!!n},apply:function(e){e.applyColorMask(this)}}),"osg","ColorMask");var g=p,m=r("bade"),v=r("c489"),b=r("b5d5"),S=r("7729"),x=r("6377"),T=r("1391"),y=r("83e3"),C=r("f3dc"),A=r("9f78"),E=r("d50c"),R=r("6ec8"),M=r("931a"),w=r("3972"),N=function e(){this._radiusEquator=e.WGS_84_RADIUS_EQUATOR,this._radiusPolar=e.WGS_84_RADIUS_POLAR,this.computeCoefficients()};N.WGS_84_RADIUS_EQUATOR=6378137,N.WGS_84_RADIUS_POLAR=6356752.3142,N.prototype={setRadiusEquator:function(e){this._radiusEquator=e,this.computeCoefficients()},getRadiusEquator:function(){return this._radiusEquator},setRadiusPolar:function(e){this._radiusPolar=e,this.computeCoefficients()},getRadiusPolar:function(){return this._radiusPolar},convertLatLongHeightToXYZ:function(e,t,r,n){var i=Math.sin(e),a=Math.cos(e),o=this._radiusEquator/Math.sqrt(1-this._eccentricitySquared*i*i),s=(o+r)*a*Math.cos(t),u=(o+r)*a*Math.sin(t),c=(o*(1-this._eccentricitySquared)+r)*i;return n[0]=s,n[1]=u,n[2]=c,n},convertXYZToLatLongHeight:function(e,t,r,n){var i=Math.sqrt(e*e+t*t),a=Math.atan2(r*this._radiusEquator,i*this._radiusPolar),o=(this._radiusEquator*this._radiusEquator-this._radiusPolar*this._radiusPolar)/(this._radiusPolar*this._radiusPolar),s=Math.sin(a),u=Math.cos(a),c=Math.atan((r+o*this._radiusPolar*s*s*s)/(i-this._eccentricitySquared*this._radiusEquator*u*u*u)),l=Math.atan2(t,e),h=Math.sin(c),d=this._radiusEquator/Math.sqrt(1-this._eccentricitySquared*h*h),f=Math.cos(c);0===f&&(f=1);var _=i/f-d;return n[0]=c,n[1]=l,n[2]=_,n},computeLocalUpVector:function(e,t,r){var n,i,a=this.convertXYZToLatLongHeight(e,t,r,w["f"].create());return n=a[0],i=a[1],[Math.cos(i)*Math.cos(n),Math.sin(i)*Math.cos(n),Math.sin(n)]},isWGS84:function(){return this._radiusEquator===N.WGS_84_RADIUS_EQUATOR&&this._radiusPolar===N.WGS_84_RADIUS_POLAR},computeCoefficients:function(){var e=(this._radiusEquator-this._radiusPolar)/this._radiusEquator;this._eccentricitySquared=2*e-e*e},computeLocalToWorldTransformFromLatLongHeight:function(e,t,r,n){var i=this.convertLatLongHeightToXYZ(e,t,r,n);return w["c"].fromTranslation(n,i),this.computeCoordinateFrame(e,t,n),n},computeLocalToWorldTransformFromXYZ:function(e,t,r){var n=this.convertXYZToLatLongHeight(e,t,r,w["f"].create()),i=w["c"].fromTranslation(w["c"].create(),w["f"].fromValues(e,t,r));return this.computeCoordinateFrame(n[0],n[1],i),i},computeCoordinateFrame:function(){var e=w["f"].create(),t=w["f"].create(),r=w["f"].create();return function(n,i,a){e[0]=Math.cos(i)*Math.cos(n),e[1]=Math.sin(i)*Math.cos(n),e[2]=Math.sin(n),t[0]=-Math.sin(i),t[1]=-Math.cos(i),w["f"].cross(r,e,t),w["c"].set(a,t[0],t[1],t[2],0,r[0],r[1],r[2],0,e[0],e[1],e[2],0,0,0,0,1)}}()};var O=N,I=r("a995"),P=r("2a7e"),D=r("9946"),L=r("16cb"),F=r("4e92"),k=r("f684"),B=r.n(k),U=function(e){F["a"].call(this,e),this._canPlayDefered=void 0};U.PAUSE=0,U.PLAYING=1,i["a"].createPrototypeObject(U,i["a"].objectInherit(F["a"].prototype,{isDirty:function(){return this._status===U.PLAYING},setImage:function(e){F["a"].prototype.setImage.call(this,e),this._status=U.STOP,e.addEventListener("ended",function(){this._imageObject.loop||this.stop()}.bind(this),!0),this.dirty()},setLooping:function(e){this._imageObject.loop=e},play:function(){this._imageObject.play(),this._status=U.PLAYING},stop:function(){this._imageObject.pause(),this._status=U.PAUSE},whenReady:function(){if(!this._imageObject)return B.a.reject();var e=this;return new B.a((function(t){e._canPlayDefered||(e._canPlayDefered=t,e._imageObject.readyState>3?e._canPlayDefered(e):e._imageObject.addEventListener("canplaythrough",e._canPlayDefered.bind(e._canPlayDefered,e),!0))}))}}),"osg","ImageStream");var V=U,G=r("0599"),z=r("977b"),j=r("875b"),H=r("3769"),W=function(e){a["a"].call(this),this.lineWidth=1,void 0!==e&&(this.lineWidth=e)};i["a"].createPrototypeStateAttribute(W,i["a"].objectInherit(a["a"].prototype,{attributeType:"LineWidth",cloneType:function(){return new W},apply:function(e){e.getGraphicContext().lineWidth(this.lineWidth)}}),"osg","LineWidth");var X=W,q=r("4388"),Y=r("6a5b"),K=r("1881"),J=r("032c"),Z=r("1ca0"),Q=r("02b4"),$=r("3453"),ee=r("3714"),te=r("5a16"),re=r("a214"),ne=r("40fc"),ie=r("9998"),ae=r("e9a6"),oe=r("5e15"),se=r("2857"),ue=function(e){a["a"].call(this),this._enable=!e,this._pointSize=1,this._circleShape=!1,this._dirtyHash=!0,this._hash=""};i["a"].createPrototypeStateAttribute(ue,i["a"].objectInherit(a["a"].prototype,{attributeType:"PointSize",cloneType:function(){return new ue(!0)},setCircleShape:function(e){this._circleShape=e,this._dirtyHash=!0},isCircleShape:function(){return this._circleShape},setEnabled:function(e){this._enable=e,this._dirtyHash=!0},isEnabled:function(){return this._enable},setPointSize:function(e){this._pointSize=e},getOrCreateUniforms:function(){var e=ue;return e.uniforms||(e.uniforms={pointSize:se["a"].createFloat(1,"uPointSize")}),e.uniforms},getHash:function(){return this._dirtyHash?(this._hash=this._computeInternalHash(),this._dirtyHash=!1,this._hash):this._hash},_computeInternalHash:function(){return this.getTypeMember()+(this.isEnabled()?"1":"0")+(this._circleShape?"1":"0")},apply:function(){if(this._enable){var e=this.getOrCreateUniforms();e.pointSize.setFloat(this._pointSize)}}}),"osg","PointSizeAttribute");var ce=ue,le=r("187b"),he=r("1025"),de=r("1cf6"),fe=r("16f6"),_e=r("c0d6"),pe=r("0549"),ge=r("c77d"),me=r("cc9d"),ve=r("4066"),be=r("308b"),Se=r("5f6c"),xe=r("d80a"),Te=r("d305"),ye=r("cb5a"),Ce=r("23f5"),Ae=r("c360"),Ee=r("8130"),Re=function(){Ee["default"].call(this),this._images={};for(var e=0;e<6;e++)this._images[Ee["default"].TEXTURE_CUBE_MAP_POSITIVE_X+e]=new F["a"]};i["a"].createPrototypeStateAttribute(Re,i["a"].objectInherit(Ee["default"].prototype,{setDefaultParameters:function(){Ee["default"].prototype.setDefaultParameters.call(this),this._textureTarget=Ee["default"].TEXTURE_CUBE_MAP,this._flipY=!1},invalidate:function(){Ee["default"].prototype.invalidate.call(this);for(var e=Ee["default"].TEXTURE_CUBE_MAP_POSITIVE_X;e<Ee["default"].TEXTURE_CUBE_MAP_POSITIVE_X+6;e++){var t=this._images[e];this._images[Ee["default"].TEXTURE_CUBE_MAP_POSITIVE_X].getImage()&&t.dirty()}this.dirty()},cloneType:function(){return new Re},setImage:function(e,t,r){var n=e;"string"===typeof n&&(n=Ee["default"][n]),this._images[n].setImage(t,r),this.setImageFormat(r),this.setTextureSize(this._images[n].getWidth(),this._images[n].getHeight()),this._textureNull=!1,this.dirty()},getImage:function(e){return this._images[e].getImage()},initCubemapContent:function(e){var t=this._internalFormat;return this.applyTexImage2D(e,e.TEXTURE_CUBE_MAP_POSITIVE_X,0,t,this._textureWidth,this._textureHeight,0,t,this._type,null),this.applyTexImage2D(e,e.TEXTURE_CUBE_MAP_NEGATIVE_X,0,t,this._textureWidth,this._textureHeight,0,t,this._type,null),this.applyTexImage2D(e,e.TEXTURE_CUBE_MAP_POSITIVE_Y,0,t,this._textureWidth,this._textureHeight,0,t,this._type,null),this.applyTexImage2D(e,e.TEXTURE_CUBE_MAP_NEGATIVE_Y,0,t,this._textureWidth,this._textureHeight,0,t,this._type,null),this.applyTexImage2D(e,e.TEXTURE_CUBE_MAP_POSITIVE_Z,0,t,this._textureWidth,this._textureHeight,0,t,this._type,null),this.applyTexImage2D(e,e.TEXTURE_CUBE_MAP_NEGATIVE_Z,0,t,this._textureWidth,this._textureHeight,0,t,this._type,null),!0},generateMipmap:function(e,t){if(this.hasMipmapFilter()){if(this._images[Ee["default"].TEXTURE_CUBE_MAP_POSITIVE_X].hasMipmap())for(var r=0;r<6;r++){var n=this._images[Ee["default"].TEXTURE_CUBE_MAP_POSITIVE_X+r];n.hasMipmap()||re["a"].error("mipmap not set correctly for TextureCubemap");for(var i=this._internalFormat,a=1;a<n.getMipmap().length;a++){var o=n.getMipmap()[a].getWidth();this.applyTexImage2D(e,e.TEXTURE_CUBE_MAP_POSITIVE_X+r,a,i,o,o,0,i,this._type,n.getMipmap()[a].getImage())}}else e.generateMipmap(t);this._dirtyMipmap=!1}},applyImageTarget:function(e,t,r){var n=this._images[r];return n.getImage()&&n.isReady()?n.isDirty()?(this.setTextureSize(n.getWidth(),n.getHeight()),n.setDirty(!1),n.isTypedArray()?this.applyTexImage2D(e,r,0,t,this._textureWidth,this._textureHeight,0,t,this._type,n.getImage()):this.applyTexImage2D(e,r,0,t,t,this._type,n.getImage()),!this._unrefImageDataAfterApply||this.hasMipmap()&&n.hasMipmap()||n.release(),1):1:0},initCubemapContentImage:function(e){var t=this._internalFormat,r=0;return r+=this.applyImageTarget(e,t,e.TEXTURE_CUBE_MAP_POSITIVE_X),r+=this.applyImageTarget(e,t,e.TEXTURE_CUBE_MAP_NEGATIVE_X),r+=this.applyImageTarget(e,t,e.TEXTURE_CUBE_MAP_POSITIVE_Y),r+=this.applyImageTarget(e,t,e.TEXTURE_CUBE_MAP_NEGATIVE_Y),r+=this.applyImageTarget(e,t,e.TEXTURE_CUBE_MAP_POSITIVE_Z),r+=this.applyImageTarget(e,t,e.TEXTURE_CUBE_MAP_NEGATIVE_Z),6===r},apply:function(e){var t=e.getGraphicContext();if(this._dirtyTextureObject&&(this.releaseGLObjects(),this.setGraphicContext(t)),void 0===this._textureObject||this.isDirty())if(this._textureNull)t.bindTexture(this._textureTarget,null);else{var r;this._textureObject||(this.computeTextureFormat(),this.init(e)),this._textureObject.bind(t),r=this._images[Ee["default"].TEXTURE_CUBE_MAP_POSITIVE_X].getImage()?this.initCubemapContentImage(t):this.initCubemapContent(t),r&&(this._dirty=!1,this.applyFilterParameter(t,this._textureTarget),this.generateMipmap(t,this._textureTarget))}else this._textureObject.bind(t),this.isDirtyMipmap()&&this.generateMipmap(t,this._textureTarget)}}),"osg","TextureCubeMap");var Me=Re,we=r("2449"),Ne=function(){},Oe=Ne.functorDrawElements=[],Ie=Ne.functorDrawArrays=[];Oe[fe["a"].TRIANGLES]=function(e,t,r,n){for(var i=e+t,a=e;a<i;a+=3)n(r[a],r[a+1],r[a+2])},Oe[fe["a"].TRIANGLE_STRIP]=function(e,t,r,n){for(var i=2,a=e;i<t;++i,++a)i%2?n(r[a],r[a+2],r[a+1]):n(r[a],r[a+1],r[a+2])},Oe[fe["a"].TRIANGLE_FAN]=function(e,t,r,n){for(var i=r[e],a=2,o=e+1;a<t;++a,++o)n(i,r[o],r[o+1])},Ie[fe["a"].TRIANGLES]=function(e,t,r){for(var n=2,i=e;n<t;n+=3,i+=3)r(i,i+1,i+2)},Ie[fe["a"].TRIANGLE_STRIP]=function(e,t,r){for(var n=2,i=e;n<t;++n,++i)n%2?r(i,i+2,i+1):r(i,i+1,i+2)},Ie[fe["a"].TRIANGLE_FAN]=function(e,t,r){for(var n=2,i=e+1;n<t;++n,++i)r(e,i,i+1)},Ne.prototype={init:function(e,t){this._geom=e,this._cb=t},apply:function(){var e=this._geom,t=e.getPrimitiveSetList();if(t)for(var r,n=this._cb,i=t.length,a=0;a<i;a++){var o=t[a];if(o instanceof M["a"]){if(r=Oe[o.getMode()],r){var s=o.indices.getElements();r(o.getFirst()/s.BYTES_PER_ELEMENT,o.getCount(),s,n)}}else o instanceof R["a"]&&(r=Ie[o.getMode()],r&&r(o.getFirst(),o.getCount(),n))}}};var Pe=Ne,De=r("82f0"),Le=r("3e45"),Fe=r("ae6b"),ke=r("ede0"),Be=r("1ad5"),Ue=r("602a"),Ve=r("8c22"),Ge=r("0fd6"),ze={};ze.AutoTransform=n["a"],ze.BillboardAttribute=s,ze.BlendColor=u["a"],ze.BlendFunc=c["a"],ze.BoundingBox=l["a"],ze.BoundingSphere=h["a"],ze.BufferArray=d["a"],ze.BufferArrayProxy=f["a"],ze.ColorMask=g,ze.Camera=_["a"],ze.ColorMask=g,ze.ComputeBoundsVisitor=m["default"],i["a"].objectMix(ze,v["a"]),ze.CullFace=b["a"],ze.FrontFace=S["a"],ze.CullingSet=x["a"],ze.CullSettings=T["a"],ze.CullStack=y["a"],ze.CullVisitor=C["a"],ze.Depth=A["a"],ze.DrawArrayLengths=E["a"],ze.DrawArrays=R["a"],ze.DrawElements=M["a"],ze.EllipsoidModel=O,ze.WGS_84_RADIUS_EQUATOR=O.WGS_84_RADIUS_EQUATOR,ze.WGS_84_RADIUS_POLAR=O.WGS_84_RADIUS_POLAR,ze.FrameBufferObject=I["a"],ze.FrameStamp=P["a"],ze.Geometry=D["a"],ze.GLObject=L["a"],ze.Image=F["a"],ze.ImageStream=V,ze.KdTree=G["a"],ze.KdTreeBuilder=z["a"],ze.Light=j["a"],ze.LightSource=H["a"],ze.LineWidth=X,ze.Lod=q["a"],ze.Material=Y["a"],i["a"].objectMix(ze,K["a"]),ze.MatrixTransform=J["a"],ze.PooledResource=Z["a"],ze.PooledArray=Q["a"],ze.PooledMap=$["a"],ze.Node=ee["a"],ze.NodeVisitor=te["a"],i["a"].objectMix(ze,re["a"]),ze.Object=ne["a"],ze.Options=ie["a"],ze.PagedLOD=ae["a"],ze.Plane=le["a"],ze.PointSizeAttribute=ce,ze.Polytope=oe["a"],ze.primitiveSet=fe["a"],ze.primitiveFunctor=he["a"],ze.primitiveIndexFunctor=de["a"],ze.Program=_e["a"],ze.Projection=pe["a"],ze.RenderBin=ge["a"],ze.RenderLeaf=me["a"],ze.RenderStage=ve["a"],ze.Shader=be["a"],i["a"].objectMix(ze,Se["a"]),ze.StackObjectPairPool=xe["a"],ze.State=Te["a"],ze.StateAttribute=a["a"],ze.StateGraph=ye["a"],ze.StateSet=Ce["a"],ze.Scissor=Fe["a"],ze.Switch=Ae["a"],ze.Texture=Ee["default"],ze.TextureCubeMap=Me,ze.Transform=we["a"],ze.TriangleIndexFunctor=Pe,ze.Uniform=se["a"],ze.UpdateVisitor=De["a"],i["a"].objectMix(ze,i["a"]),ze.Viewport=Le["a"],ze.VertexArrayObject=Ve["a"],ze.vec2=w["a"].vec2,ze.vec3=w["a"].vec3,ze.vec4=w["a"].vec4,ze.quat=w["a"].quat,ze.mat3=w["a"].mat3,ze.mat4=w["a"].mat4,ze.Transform.RELATIVE_RF=ke["a"].RELATIVE_RF,ze.Transform.ABSOLUTE_RF=ke["a"].ABSOLUTE_RF,ze.Timer=Be["a"],ze.TimerGPU=Ue["a"],ze.WebGLCaps=Ge["a"];t["default"]=ze},"1ca0":function(e,t,r){"use strict";var n=function(e){this._createFunction=e,this._pool=[],this._length=0};n.prototype={clean:function(){this._pool.length=0,this._length=0},getLength:function(){return this._length},reset:function(){this._length=0},getOrCreateObject:function(){var e;return this._length===this._pool.length?(e=this._createFunction(),this._pool.push(e)):e=this._pool[this._length],this._length++,e},forEach:function(e){for(var t=0;t<this._length;t++)e(this._pool[t])}},t["a"]=n},"1cf6":function(e,t,r){"use strict";var n=r("16f6"),i=r("931a"),a=r("6ec8"),o=[],s=[];o[n["a"].TRIANGLES]=function(e,t,r,n){for(var i=e+t,a=e;a<i;a+=3)n.operatorTriangle(r[a],r[a+1],r[a+2])},o[n["a"].TRIANGLE_STRIP]=function(e,t,r,n){for(var i=2,a=e;i<t;++i,++a)i%2?n.operatorTriangle(r[a],r[a+2],r[a+1]):n.operatorTriangle(r[a],r[a+1],r[a+2])},o[n["a"].TRIANGLE_FAN]=function(e,t,r,n){for(var i=r[e],a=2,o=e+1;a<t;++a,++o)n.operatorTriangle(i,r[o],r[o+1])},o[n["a"].POINTS]=function(e,t,r,n){for(var i=e+t,a=e;a<i;++a)n.operatorPoint(r[a])},o[n["a"].LINES]=function(e,t,r,n){for(var i=e+t,a=e;a<i;a+=2)n.operatorLine(r[a],r[a+1])},o[n["a"].LINE_STRIP]=function(e,t,r,n){for(var i=e+t,a=e;a<i;++a)n.operatorLine(r[a],r[a+1])},o[n["a"].LINE_LOOP]=function(e,t,r,n){for(var i=e+t,a=e;a<i;++a)n.operatorLine(r[a],r[a+1]);n.operatorLine(r[r.length-1],r[0])},s[n["a"].TRIANGLES]=function(e,t,r){for(var n=2,i=e;n<t;n+=3,i+=3)r.operatorTriangle(i,i+1,i+2)},s[n["a"].TRIANGLE_STRIP]=function(e,t,r){for(var n=2,i=e;n<t;++n,++i)n%2?r.operatorTriangle(i,i+2,i+1):r.operatorTriangle(i,i+1,i+2)},s[n["a"].TRIANGLE_FAN]=function(e,t,r){for(var n=2,i=e+1;n<t;++n,++i)r.operatorTriangle(e,i,i+1)},s[n["a"].POINTS]=function(e,t,r){for(var n=0,i=e;n<t;++n,++i)r.operatorPoint(i)},s[n["a"].LINES]=function(e,t,r){for(var n=1,i=e;n<t;n+=2,i+=2)r.operatorLine(i,i+1)},s[n["a"].LINE_STRIP]=function(e,t,r){for(var n=1,i=e;n<t;++n,++i)r.operatorLine(i,i+1)},s[n["a"].LINE_LOOP]=function(e,t,r){for(var n=1,i=e;n<t;++n,++i)r.operatorLine(i,i+1);r.operatorLine(e+t-1,e)};var u=function(e,t){var r=e.getPrimitiveSetList();if(r)for(var n,u=r.length,c=0;c<u;c++){var l=r[c];if(l instanceof i["a"]){if(n=o[l.getMode()],n){var h=l.indices.getElements();n(l.getFirst()/h.BYTES_PER_ELEMENT,l.getCount(),h,t)}}else l instanceof a["a"]&&(n=s[l.getMode()],n&&n(l.getFirst(),l.getCount(),t))}};t["a"]=u},"23f5":function(e,t,r){"use strict";r("a434"),r("d3b7"),r("ddb0");var n=r("40fc"),i=r("123d"),a=r("b797"),o=function(){n["a"].call(this),this._parents=[],this._attributeArray=[],this._textureAttributeArrayList=[],this._activeTextureAttributeUnit=[],this._activeAttribute=[],this._activeTextureAttribute=[],this._binName=void 0,this._binNumber=0,this._shaderGeneratorPair=null,this._updateCallbackList=[],this.uniforms={},this._hasUniform=!1,this._drawID=-1};o.AttributePair=function(e,t){this._object=e,this._value=t},o.AttributePair.prototype={getShaderGeneratorName:function(){return this._object},getAttribute:function(){return this._object},getUniform:function(){return this._object},getValue:function(){return this._value}},a["a"].createPrototypeObject(o,a["a"].objectInherit(n["a"].prototype,{setDrawID:function(e){this._drawID=e},getDrawID:function(){return this._drawID},getAttributePair:function(e,t){return new o.AttributePair(e,t)},addUniform:function(e,t){var r=void 0!==t?t:i["a"].ON,n=e.getName();this.uniforms[n]=this.getAttributePair(e,r),this._hasUniform=!0},addParent:function(e){this._parents.push(e)},removeParent:function(e){var t=this._parents.indexOf(e);-1!==t&&this._parents.splice(t,1)},removeUniform:function(e){this.removeUniformByName(e.getName())},removeUniformByName:function(e){delete this.uniforms[e],this._hasUniform=!!window.Object.keys(this.uniforms).length},hasUniform:function(){return this._hasUniform},getUniform:function(e){var t=this.uniforms;if(t[e])return t[e].getAttribute()},getUniformList:function(){return this.uniforms},setTextureAttributeAndModes:function(e,t,r){this._setTextureAttribute(e,this.getAttributePair(t,void 0!==r?r:i["a"].ON))},getNumTextureAttributeLists:function(){return this._textureAttributeArrayList.length},getTextureAttribute:function(e,t){var r=a["a"].getTextureIdFromTypeMember(t);if(void 0!==r&&this._hasTextureAttribute(e,r)){var n=this._textureAttributeArrayList[e];return n[r]?n[r].getAttribute():void 0}},removeTextureAttribute:function(e,t){var r=a["a"].getTextureIdFromTypeMember(t);if(void 0!==r&&this._hasTextureAttribute(e,r)){var n=this._textureAttributeArrayList[e];n[r]=void 0,this._computeValidTextureUnit()}},getAttribute:function(e){var t=a["a"].getIdFromTypeMember(e);if(void 0!==t&&this._hasAttribute(t))return this._attributeArray[t].getAttribute()},setAttributeAndModes:function(e,t){this._setAttribute(this.getAttributePair(e,void 0!==t?t:i["a"].ON))},setAttribute:function(e,t){this.setAttributeAndModes(e,t)},removeAttribute:function(e){var t=a["a"].getIdFromTypeMember(e);this._hasAttribute(t)&&(this._attributeArray[t]=void 0,this._computeValidAttribute())},setRenderingHint:function(e){"OPAQUE_BIN"===e?this.setRenderBinDetails(0,"RenderBin"):"TRANSPARENT_BIN"===e?this.setRenderBinDetails(10,"DepthSortedBin"):this.setRenderBinDetails(0,"")},getUpdateCallbackList:function(){return this._updateCallbackList},removeUpdateCallback:function(e){var t=this._updateCallbackList.indexOf(e);if(-1!==t&&(this._updateCallbackList.splice(t,1),0===this._updateCallbackList.length))for(var r=this._parents,n=0,i=r.length;n<i;n++){var a=r[n];a.setNumChildrenRequiringUpdateTraversal(a.getNumChildrenRequiringUpdateTraversal()-1)}},requiresUpdateTraversal:function(){return!!this._updateCallbackList.length},addUpdateCallback:function(e){var t=Boolean(this._updateCallbackList.length);if(this._updateCallbackList.push(e),!t)for(var r=this._parents,n=0,i=r.length;n<i;n++){var a=r[n];a.setNumChildrenRequiringUpdateTraversal(a.getNumChildrenRequiringUpdateTraversal()+1)}},hasUpdateCallback:function(e){return-1!==this._updateCallbackList.indexOf(e)},setRenderBinDetails:function(e,t){this._binNumber=e,this._binName=t},getAttributeMap:function(){for(var e={},t=0,r=this._attributeArray.length;t<r;t++){var n=this._attributeArray[t];if(n){var i=n.getAttribute();e[i.getTypeMember()]=n}}return e},getBinNumber:function(){return this._binNumber},getBinName:function(){return this._binName},setBinNumber:function(e){this._binNumber=e},setBinName:function(e){this._binName=e},getAttributeList:function(){for(var e=this._attributeArray,t=[],r=0,n=e.length;r<n;r++)e[r]&&t.push(e[r]);return t},setShaderGeneratorName:function(e,t){this._shaderGeneratorPair=this.getAttributePair(e,void 0!==t?t:i["a"].ON)},getShaderGeneratorPair:function(){return this._shaderGeneratorPair},getShaderGeneratorName:function(){return this._shaderGeneratorPair?this._shaderGeneratorPair.getShaderGeneratorName():void 0},releaseGLObjects:function(){for(var e=0,t=this._textureAttributeArrayList.length;e<t;e++){var r=this.getTextureAttribute(e,"Texture");r&&r.releaseGLObjects()}for(var n=this.getAttributeList(),i=0,a=n.length;i<a;i++)n[i]._object.releaseGLObjects&&n[i]._object.releaseGLObjects()},_setTextureAttribute:function(e,t){a["a"].arrayDense(e,this._textureAttributeArrayList),this._textureAttributeArrayList[e]||(this._textureAttributeArrayList[e]=[]);var r=a["a"].getOrCreateTextureStateAttributeTypeMemberIndex(t.getAttribute());a["a"].arrayDense(r,this._textureAttributeArrayList[e]),this._textureAttributeArrayList[e][r]=t,this._computeValidTextureUnit()},_computeValidTextureUnit:function(){this._activeTextureAttributeUnit.length=0,this._activeTextureAttribute.length=0;for(var e=this._textureAttributeArrayList,t=0,r=e.length;t<r;t++){var n=e[t];if(n&&n.length){for(var i=!1,a=0,o=n.length;a<o;a++)n[a]&&(i=!0,-1===this._activeTextureAttribute.indexOf(a)&&this._activeTextureAttribute.push(a));i&&this._activeTextureAttributeUnit.push(t)}}},_computeValidAttribute:function(){this._activeAttribute.length=0;for(var e=this._attributeArray,t=0,r=e.length;t<r;t++)e[t]&&this._activeAttribute.push(t)},_setAttribute:function(e){var t=a["a"].getOrCreateStateAttributeTypeMemberIndex(e.getAttribute());a["a"].arrayDense(t,this._attributeArray),this._attributeArray[t]=e,this._computeValidAttribute()},_hasAttribute:function(e){return!(e>=this._attributeArray.length)&&!!this._attributeArray[e]},_hasTextureAttribute:function(e,t){return!(e>=this._textureAttributeArrayList.length||!this._textureAttributeArrayList[e])&&(!(t>=this._textureAttributeArrayList[e].length)&&!!this._textureAttributeArrayList[e][t])}}),"osg","StateSet"),t["a"]=o},2449:function(e,t,r){"use strict";var n=r("b797"),i=r("3714"),a=r("3972"),o=r("ede0"),s=function(){i["a"].call(this),this.referenceFrame=o["a"].RELATIVE_RF};n["a"].createPrototypeNode(s,n["a"].objectInherit(i["a"].prototype,{setReferenceFrame:function(e){this.referenceFrame=e},getReferenceFrame:function(){return this.referenceFrame},computeBoundingSphere:function(){var e=a["c"].create();return function(t){return i["a"].prototype.computeBoundingSphere.call(this,t),t.valid()?(a["c"].identity(e),this.computeLocalToWorldMatrix(e),t.transformMat4(t,e),t):t}}()}),"osg","Transform"),t["a"]=s},2857:function(e,t,r){"use strict";var n=r("53ca"),i=(r("d3b7"),r("cfc3"),r("907a"),r("9a8c"),r("a975"),r("735e"),r("c1ac"),r("d139"),r("3a7b"),r("d5d6"),r("82f8"),r("e91f"),r("60bd"),r("5f96"),r("3280"),r("3fcc"),r("ca91"),r("25a1"),r("cd26"),r("3c5d"),r("2954"),r("649e"),r("219c"),r("170b"),r("b39a"),r("72f7"),r("143c"),r("a214")),a=function(e){this._data=void 0,this._transpose=!1,this._glCall="",this._cache=void 0,this._name=e,this._type=void 0,this._isMatrix=!1};a.isUniform=function(e){return"object"===Object(n["a"])(e)&&window.Object.getPrototypeOf(e)===a.prototype},a.prototype={getName:function(){return this._name},getType:function(){return this._type},apply:function(e,t){this._cache=e[this._glCall],this._isMatrix?this._cache.call(e,t,this._transpose,this._data):this._cache.call(e,t,this._data)},setInternalArray:function(e){i["a"].warn("setInternalArray deprecated, please use getInternalArray instead: "+e.length),this._data=e},getInternalArray:function(){return this._data},setFloat:function(e){this._data[0]=e},setFloat1:function(e){this._data[0]=e[0]},setFloat2:function(e){this._data[0]=e[0],this._data[1]=e[1]},setFloat3:function(e){this._data[0]=e[0],this._data[1]=e[1],this._data[2]=e[2]},setFloat4:function(e){this._data[0]=e[0],this._data[1]=e[1],this._data[2]=e[2],this._data[3]=e[3]},setFloat9:function(e){this._data[0]=e[0],this._data[1]=e[1],this._data[2]=e[2],this._data[3]=e[3],this._data[4]=e[4],this._data[5]=e[5],this._data[6]=e[6],this._data[7]=e[7],this._data[8]=e[8]},setFloat16:function(e){this._data[0]=e[0],this._data[1]=e[1],this._data[2]=e[2],this._data[3]=e[3],this._data[4]=e[4],this._data[5]=e[5],this._data[6]=e[6],this._data[7]=e[7],this._data[8]=e[8],this._data[9]=e[9],this._data[10]=e[10],this._data[11]=e[11],this._data[12]=e[12],this._data[13]=e[13],this._data[14]=e[14],this._data[15]=e[15]}},a.prototype.setVec2=a.prototype.setFloat2,a.prototype.setVec3=a.prototype.setFloat3,a.prototype.setVec4=a.prototype.setFloat4,a.prototype.setMatrix4=a.prototype.setFloat16,a.prototype.setMatrix3=a.prototype.setFloat9,a.prototype.setInt=a.prototype.setFloat,a.prototype.setInt1=a.prototype.setFloat1,a.prototype.setInt2=a.prototype.setFloat2,a.prototype.setInt3=a.prototype.setFloat3,a.prototype.setInt4=a.prototype.setFloat4;var o=function(e,t,r,n,i,o){var s=t&&t.length?e:void 0,u=new a(void 0!==s?t:e);if(u._data=r,void 0!==s)if(s.length)for(var c=0,l=s.length;c<l;++c)u._data[c]=s[c];else u._data[0]=s;return u._glCall=n,u._type=i,u._isMatrix=!!o,u},s=function(e){for(var t=new Float32Array(4*e),r=0;r<t.length;r+=4)t[r]=t[r+3]=1;return t},u=function(e){for(var t=new Float32Array(9*e),r=0;r<t.length;r+=9)t[r]=t[r+4]=t[r+8]=1;return t},c=function(e){for(var t=new Float32Array(16*e),r=0;r<t.length;r+=16)t[r]=t[r+5]=t[r+10]=t[r+15]=1;return t},l=function(e,t,r){return r&&!r.length?r:"string"!==typeof t?(t.length||1)/e:1};a.createFloat1=function(e,t){return o(e,t,new Float32Array(1*l(1,e,t)),"uniform1fv","float")},a.createFloat2=function(e,t){return o(e,t,new Float32Array(2*l(2,e,t)),"uniform2fv","vec2")},a.createFloat3=function(e,t){return o(e,t,new Float32Array(3*l(3,e,t)),"uniform3fv","vec3")},a.createFloat4=function(e,t){return o(e,t,new Float32Array(4*l(4,e,t)),"uniform4fv","vec4")},a.createInt1=function(e,t){return o(e,t,new Int32Array(1*l(1,e,t)),"uniform1iv","int")},a.createInt2=function(e,t){return o(e,t,new Int32Array(2*l(2,e,t)),"uniform2iv","vec2i")},a.createInt3=function(e,t){return o(e,t,new Int32Array(3*l(3,e,t)),"uniform3iv","vec3i")},a.createInt4=function(e,t){return o(e,t,new Int32Array(4*l(4,e,t)),"uniform4iv","vec4i")},a.createMatrix2=function(e,t){return o(e,t,s(l(4,e,t)),"uniformMatrix2fv","mat2",!0)},a.createMatrix3=function(e,t){return o(e,t,u(l(9,e,t)),"uniformMatrix3fv","mat3",!0)},a.createMatrix4=function(e,t){return o(e,t,c(l(16,e,t)),"uniformMatrix4fv","mat4",!0)},a.float=a.createFloatArray=a.createFloat=a.createFloat1,a.vec2=a.createFloat2Array=a.createFloat2,a.vec3=a.createFloat3Array=a.createFloat3,a.vec4=a.createFloat4Array=a.createFloat4,a.int=a.createIntArray=a.createInt=a.createInt1,a.vec2i=a.createInt2Array=a.createInt2,a.vec3i=a.createInt3Array=a.createInt3,a.vec4i=a.createInt4Array=a.createInt4,a.mat2=a.createMat2Array=a.createMat2=a.createMatrix2,a.mat3=a.createMat3Array=a.createMat3=a.createMatrix3,a.mat4=a.createMat4Array=a.createMat4=a.createMatrix4,t["a"]=a},"2a3f":function(e,t,r){"use strict";var n=r("b797"),i=r("40fc"),a=r("032c"),o=function(){i["a"].call(this)};o.checkPathIsAnimated=function(e){for(var t=0,r=e.length;t<r;++t){var n=e[t];if(n instanceof a["a"])for(var i=n.getUpdateCallbackList(),s=0,u=i.length;s<u;++s)if(i[s]instanceof o)return!0}return!1},n["a"].createPrototypeObject(o,n["a"].objectInherit(i["a"].prototype,{computeChannels:function(){},reset:function(){}}),"osgAnimation","AnimationUpdateCallback"),t["a"]=o},"2a3fb":function(e,t,r){"use strict";r.r(t);r("4e82");var n=r("b797"),i=r("1391"),a=r("f3dc"),o=r("40fc"),s=r("4066"),u=r("d305"),c=r("cb5a"),l=r("3972"),h=r("5d7a"),d=r("dfe6"),f=function(e){o["a"].call(this),this._state=void 0,this._camera=e,this._renderStage=void 0,this._stateGraph=void 0,this._frameStamp=void 0,this._previousCullsettings=new i["a"],this.setDefaults()};f.debugGraph=!1,n["a"].createPrototypeObject(f,n["a"].objectInherit(o["a"].prototype,{setDefaults:function(){this._state=new u["a"](new h["default"].ShaderGeneratorProxy),this._cullVisitor=new a["a"],this._cullVisitor.setRenderer(this),this._stateGraph=new c["a"],this.getCamera().setClearColor(l["g"].create()),this.setRenderStage(new s["a"]);var e=r("1c38").default,t=this.getCamera().getOrCreateStateSet();t.setAttributeAndModes(new e.Material),t.setAttributeAndModes(new e.Depth),t.setAttributeAndModes(new e.BlendFunc),t.setAttributeAndModes(new e.CullFace),t.setAttributeAndModes(new e.FrontFace)},getCullVisitor:function(){return this._cullVisitor},setCullVisitor:function(e){e&&!e.getRenderer()&&e.setRenderer(this),this._cullVisitor=e},setRenderStage:function(e){this._renderStage=e},getCamera:function(){return this._camera},setFrameStamp:function(e){this._frameStamp=e},getFrameStamp:function(){return this._frameStamp},getState:function(){return this._state},setState:function(e){this._state=e},setGraphicContext:function(e){this._state.setGraphicContext(e)},getGraphicContext:function(){return this._state.getGraphicContext()},cullAndDraw:function(){this.cull(),this.draw()},cull:function(){var e=this.getCamera(),t=e.getView();this._cullVisitor.setFrameStamp(this._frameStamp),this._cullVisitor.resetStats(),c["a"].reset(),this._stateGraph.clean(),this._renderStage.reset(),this._cullVisitor.reset(),this._cullVisitor.setStateGraph(this._stateGraph),this._cullVisitor.setRenderStage(this._renderStage),this._cullVisitor.pushStateSet(e.getStateSet()),this._previousCullsettings.reset(),this._previousCullsettings.setCullSettings(this._cullVisitor),this._cullVisitor.setCullSettings(e),this._previousCullsettings.getSettingSourceOverrider()===this._cullVisitor&&this._previousCullsettings.getEnableFrustumCulling()&&this._cullVisitor.setEnableFrustumCulling(!0),this._cullVisitor.pushCameraModelViewProjectionMatrix(e,e.getViewMatrix(),e.getProjectionMatrix()),e.getBound();var n=t.getLight(),i=r("8d89").default;if(n)switch(t.getLightingMode()){case i.LightingMode.HEADLIGHT:this._cullVisitor.addPositionedAttribute(null,n);break;case i.LightingMode.SKY_LIGHT:this._cullVisitor.addPositionedAttribute(e.getViewMatrix(),n);break;default:break}var a=e.getViewport(),o=e.getScissor();this._cullVisitor.pushViewport(a),this._renderStage.setClearDepth(e.getClearDepth()),this._renderStage.setClearColor(e.getClearColor()),this._renderStage.setClearMask(e.getClearMask()),this._renderStage.setViewport(a),this._renderStage.setScissor(o),this._cullVisitor.setDatabaseRequestHandler(this._camera.getView().getDatabasePager()),this._cullVisitor.handleCullCallbacksAndTraverse(e),this._cullVisitor.popCameraModelViewProjectionMatrix(e),this._cullVisitor.setCullSettings(this._previousCullsettings),this._cullVisitor.popViewport(),this._cullVisitor.popStateSet(),this._renderStage.sort()},draw:function(){var e=this.getState();e.resetCacheFrame(),e.resetStats(),this._renderStage.setCamera(this._camera),this._renderStage.draw(e),f.debugGraph&&(d["a"].instance().createRenderGraph(this._renderStage),f.debugGraph=!1),this._renderStage.setCamera(void 0),e.applyDefault()}}),"osgViewer","Renderer"),t["default"]=f},"2a7e":function(e,t,r){"use strict";var n=function(){this._frame=0,this._startSimulation=0,this._currentSimulation=0,this._deltaTime=0};n.prototype={setReferenceTime:function(e){this._startSimulation=e},getReferenceTime:function(){return this._startSimulation},setSimulationTime:function(e){this._currentSimulation=e},getSimulationTime:function(){return this._currentSimulation},setDeltaTime:function(e){this._deltaTime=e},getDeltaTime:function(){return this._deltaTime},setFrameNumber:function(e){this._frame=e},getFrameNumber:function(){return this._frame}},t["a"]=n},"2ba4":function(e,t,r){"use strict";r("b0c0"),r("d3b7"),r("5cc6"),r("907a"),r("9a8c"),r("a975"),r("735e"),r("c1ac"),r("d139"),r("3a7b"),r("d5d6"),r("82f8"),r("e91f"),r("60bd"),r("5f96"),r("3280"),r("3fcc"),r("ca91"),r("25a1"),r("cd26"),r("3c5d"),r("2954"),r("649e"),r("219c"),r("170b"),r("b39a"),r("72f7");var n=r("b797"),i=r("a214"),a=r("c0d6"),o=r("308b"),s=r("c247"),u=r("8bd2"),c=function(){this._cache={},this._shaderProcessor=u["a"],this._ShaderCompiler=void 0,this.setShaderCompiler(s["a"])};c.prototype={setShaderCompiler:function(e){this._ShaderCompiler=e,e._validAttributeTypeMemberCache||this._computeStateAttributeCache(e)},getShaderCompiler:function(){return this._ShaderCompiler},getShaderProcessor:function(){return this._shaderProcessor},setShaderProcessor:function(e){this._shaderProcessor=e},filterAttributeTypes:function(e){return!(!e.isEnabled||e.isEnabled())},getActiveAttributeList:function(e,t){for(var r="",n=e._attributeArray,i=this._ShaderCompiler._validAttributeTypeMemberCache,a=0,o=i.length;a<o;a++){var s=i[a],u=s<n.length?n[s]:void 0;if(u){var c=u._lastApplied;c&&!this.filterAttributeTypes(c)&&(r+=c.getHash(),t.push(c))}}return r},getActiveAttributeListCache:function(e){for(var t="",r=this._ShaderCompiler._validAttributeTypeMemberCache,n=0,i=r.length;n<i;n++){var a=r[n],o=a<e._attributeArray.length?e._attributeArray[a]:void 0;if(o){var s=o._lastApplied;if(!s||this.filterAttributeTypes(s))continue;t+=o._lastApplied.getHash()}}return t},getActiveTextureAttributeListCache:function(e){for(var t="",r=this._ShaderCompiler._validTextureAttributeTypeMemberCache,n=e._textureAttributeArrayList,i=0;i<n.length;i++){var a=n[i];if(a)for(var o=a.length,s=0;s<r.length;s++){var u=r[s],c=u<o?a[u]:void 0;if(c){var l=c._lastApplied;if(!l||this.filterAttributeTypes(l)||l.isTextureNull())continue;t+=l.getHash()}}}return t},getActiveTextureAttributeList:function(e,t){var r,n,i="",a=e._textureAttributeArrayList,o=this._ShaderCompiler._validTextureAttributeTypeMemberCache;for(r=0,n=a.length;r<n;r++){var s=a[r];if(s){t[r]=[];for(var u=0,c=o.length;u<c;u++){var l=o[u],h=l<s.length?s[l]:void 0;if(h){var d=h._lastApplied;!d||this.filterAttributeTypes(d)||d.isTextureNull()||(i+=d.getHash(),t[r].push(d))}}}}return i},getActiveUniforms:function(e,t,r){for(var n={},i=0,a=t.length;i<a;i++){var o=t[i];if(o.getOrCreateUniforms){var s=o.getOrCreateUniforms();if(void 0!==s)for(var u in s){var c=s[u];n[c.getName()]=c}}}for(var l=0,h=r.length;l<h;l++){var d=r[l];if(d)for(var f=0,_=d.length;f<_;f++){var p=d[f],g=p.getOrCreateUniforms(l);for(var m in g){var v=g[m];n[v.getName()]=v}}}return n},_computeStateAttributeCache:function(e){var t,r,a,o,s,u=e.stateAttributeConfig.attribute||[],c=[];for(r=0,a=u.length;r<a;r++)t=u[r],s=n["a"].getIdFromTypeMember(t),void 0!==s&&(-1!==c.indexOf(s)?i["a"].warn("Compiler "+e.name+" contains duplicate attribute entry "+t+", check the Compiler configuration"):c.push(s));for(o=new Uint8Array(c),e._validAttributeTypeMemberCache=o,u=e.stateAttributeConfig.textureAttribute||[],c=[],r=0,a=u.length;r<a;r++)t=u[r],s=n["a"].getTextureIdFromTypeMember(t),-1!==c.indexOf(s)?i["a"].warn("Compiler "+e.name+" contains duplicate texture attribute entry "+t+", check the Compiler configuration"):c.push(s);o=new Uint8Array(c),e._validTextureAttributeTypeMemberCache=o},_createWaitingProgram:function(e,t,r){var n="attribute vec3 Vertex;uniform mat4 uModelViewMatrix;uniform mat4 uProjectionMatrix;void main(void) { gl_Position = vec4(10.0,10.0,10.0,1.0);}\n",i="#define SHADER_NAME WaitSafe\nprecision lowp float; void main(void) { gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);}\n",s=new a["a"](new o["a"](o["a"].VERTEX_SHADER,n),new o["a"](o["a"].FRAGMENT_SHADER,i));return this.getActiveAttributeList(e,t),s.setActiveUniforms(this.getActiveUniforms(e,t,r)),s.generated=!0,s.apply(e),s},getOrCreateProgram:function(){var e=[],t=[];return function(r){var n=this.getActiveAttributeListCache(r)+this.getActiveTextureAttributeListCache(r),i=this._getProgram(n,r,t,e);if(void 0!==i)return i;var a=this._createProgram(n,r,t,e);return a}}(),_getProgram:function(e){return this._cache[e]},_createProgram:function(e,t,r,n){r.length=0,n.length=0,this.getActiveAttributeList(t,r),this.getActiveTextureAttributeList(t,n);var s=this._ShaderCompiler,u=new s(r,n,this._shaderProcessor);i["a"].debug("New Compilation ",!1,!0),i["a"].debug({Attributes:r,Texture:n,Hash:e,Compiler:u.getFragmentShaderName()},!1,!0);var c=u.createFragmentShader(),l=u.createVertexShader(),h=new a["a"](new o["a"](o["a"].VERTEX_SHADER,l),new o["a"](o["a"].FRAGMENT_SHADER,c));return h.hash=e,h.setActiveUniforms(this.getActiveUniforms(t,r,n)),h.generated=!0,this._cache[e]=h,h.apply(t),h},resetCache:function(){this._cache={}}},t["a"]=c},"308b":function(e,t,r){"use strict";r("4ec9"),r("d3b7"),r("3ca3"),r("ddb0"),r("a434"),r("ac1f"),r("466d"),r("1276"),r("5319");var n=r("a214"),i=r("b797"),a=r("1ad5"),o=r("16cb"),s=function e(t,r){o["a"].call(this);var n=t;"string"===typeof t&&(n=e[t]),this.type=n,this.setText(r)};s.VERTEX_SHADER=35633,s.FRAGMENT_SHADER=35632;var u="\n#define SHADER_NAME FailSafe";s.VS_DBG="#define _DEBUG 1\n#ifdef _DEBUG\nattribute vec3 Vertex;uniform mat4 uModelViewMatrix;uniform mat4 uProjectionMatrix;void main(void) { gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(Vertex, 1.0);}\n",s.FS_DBG="#define _DEBUG 1\n#ifdef _DEBUG\n precision lowp float; void main(void) { gl_FragColor = vec4(1.0, 0.6, 0.6, 1.0);}\n",s._sDeletedGLShaderCache=new window.Map,s.deleteGLShader=function(e,t){s._sDeletedGLShaderCache.has(e)||s._sDeletedGLShaderCache.set(e,[]),s._sDeletedGLShaderCache.get(e).push(t)},s.flushDeletedGLShaders=function(e,t){if(t<=0)return t;if(!s._sDeletedGLShaderCache.has(e))return t;for(var r=0,n=a["a"].instance().tick(),i=s._sDeletedGLShaderCache.get(e),o=i.length,u=o-1;u>=0&&r<t;u--)e.deleteShader(i[u]),i.splice(u,1),r=a["a"].instance().deltaS(n,a["a"].instance().tick());return t-r},s.flushAllDeletedGLShaders=function(e){if(s._sDeletedGLShaderCache.has(e))for(var t=s._sDeletedGLShaderCache.get(e),r=t.length,n=r-1;n>=0;n--)e.deleteShader(t[n]),t.splice(n,1)},s.onLostContext=function(e){if(s._sDeletedGLShaderCache.has(e)){var t=s._sDeletedGLShaderCache.get(e);t.length=0}},i["a"].createPrototypeObject(s,i["a"].objectInherit(o["a"].prototype,{setText:function(e){this.text=e},getText:function(){return this.text},failSafe:function(e,t){this.shader=e.createShader(this.type);var r=t.match(/#define[\s]+SHADER_NAME[\s]+([\S]+)(\n|$)/);r=r?r[1]:"";var n=this.type===s.VERTEX_SHADER?s.VS_DBG:s.FS_DBG;n+=u+r+"\n#else\n"+t+"\n#endif\n",e.shaderSource(this.shader,n),e.compileShader(this.shader)},processErrors:function(e,t){var r,i,a=/ERROR: [\d]+:([\d]+): (.+)/gim,o=t.split("\n"),s=o.length;if(0!==s)if(null===a.exec(e)&&(a=/Shader compilation errors\n\((\d+)\, \d+\): (.+)/gim),null!==a.exec(e)){a.lastIndex=0;while(null!==(i=a.exec(e))){i.index===a.lastIndex&&a.lastIndex++;var u=parseInt(i[1],10);if(!(u>s)){n["a"].error("ERROR "+i[2]+" in line "+u);var c=Math.max(0,u-7),l=Math.max(0,u-2);for(r=c;r<=l;r++)n["a"].warn(o[r].replace(/^[ \t]+/g,""));for(l=Math.max(0,u-1),n["a"].error(o[l].replace(/^[ \t]+/g,"")),c=Math.min(s,u),l=Math.min(s,u+5),r=c;r<l;r++)n["a"].warn(o[r].replace(/^[ \t]+/g,""))}}}else n["a"].error(e)},compile:function(e){this._gl||this.setGraphicContext(e),this.shader=e.createShader(this.type),e.shaderSource(this.shader,this.text),e.compileShader(this.shader)},getCompilationResult:function(e,t){if(!e.getShaderParameter(this.shader,e.COMPILE_STATUS)&&!e.isContextLost()){var r=e.getShaderInfoLog(this.shader);this.processErrors(r,this.text);for(var i=this.text.split("\n"),a="\n",o=0,s=i.length;o<s;++o)a+=o+" "+i[o]+"\n";return n["a"].errorFold("can't compile shader",a),t&&t(this.text,a,r),!1}return!0},releaseGLObjects:function(){void 0!==this._gl&&(s.deleteGLShader(this._gl,this.shader),o["a"].removeObject(this._gl,this)),this.invalidate()},invalidate:function(){this.shader=void 0}}),"osg","Shader"),t["a"]=s},3170:function(e,t,n){"use strict";n.r(t);var o={};n.r(o),n.d(o,"createMaterial",(function(){return dh})),n.d(o,"createRenderMaterial",(function(){return fh})),n.d(o,"createNativeMat2",(function(){return _h})),n.d(o,"createNativeMat",(function(){return ph})),n.d(o,"default",(function(){return mh}));n("e260"),n("e6cf"),n("cca6"),n("a79d");var u=n("7a23"),c=n("6c02"),l=n("1da1"),h=(n("96cf"),n("e9c4"),n("7522")),d=n("84d4"),f=n("8592"),p=n("8fe6"),g=n("b85c"),m=n("3835"),v=n("d4ec"),S=n("bee2"),x=n("262e"),T=n("2caf"),y=(n("ac1f"),n("5319"),n("4ec9"),n("d3b7"),n("3ca3"),n("ddb0"),n("7db0"),n("159b"),n("b0c0"),n("4fad"),n("4119"),n("257e")),C=(n("cfc3"),n("907a"),n("9a8c"),n("a975"),n("735e"),n("c1ac"),n("d139"),n("3a7b"),n("d5d6"),n("82f8"),n("e91f"),n("60bd"),n("5f96"),n("3280"),n("3fcc"),n("ca91"),n("25a1"),n("cd26"),n("3c5d"),n("2954"),n("649e"),n("219c"),n("170b"),n("b39a"),n("72f7"),n("4e82"),n("99af"),n("a434"),n("fb6a"),function(){function e(t,r,n){Object(v["a"])(this,e),this.owner=t,this.name=r,this.fn=n}return Object(S["a"])(e,[{key:"unbind",value:function(){this.owner&&(this.owner.unbind(this.name,this.fn),this.owner=null,this.name=null,this.fn=null)}},{key:"call",value:function(){this.fn&&this.fn.call(this.owner,arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6],arguments[7])}},{key:"on",value:function(e,t){return this.owner.on(e,t)}}]),e}()),A=function(){function e(t,r,n){Object(v["a"])(this,e),this.owner=t,this.name=r,this.fn=n}return Object(S["a"])(e,[{key:"unbind",value:function(){this.owner&&(this.owner.unbindWeight(this.name,this.fn),this.owner=null,this.name=null,this.fn=null)}}]),e}(),R=function(){function e(){Object(v["a"])(this,e),this._events={},this._suspendEvents=!1,this._weightEvents={}}return Object(S["a"])(e,[{key:"suspendEvents",get:function(){return this._suspendEvents},set:function(e){this._suspendEvents=!!e}},{key:"nextTick",value:function(e,t){this.on(e,function(){var e=null;return function(){e&&clearTimeout(e);for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];e=setTimeout(t.bind.apply(t,[null].concat(n)))}}())}},{key:"on",value:function(e,t){var r=this._events[e];return void 0===r?this._events[e]=[t]:-1==r.indexOf(t)&&r.push(t),new C(this,e,t)}},{key:"onHighWeight",value:function(e,t,r){var n=this._weightEvents[e];if(void 0===n)this._weightEvents[e]=[{weight:t,fn:r}];else{for(var i={weight:t,fn:r},a=n.length,o=!1,s=0;s<a;s++)if(t>n[s].weight){n.splice(s,0,i),o=!0;break}o||n.push(i)}return new A(this,e,r)}},{key:"once",value:function(e,t){var r=this,n=this.on(e,(function(e,i,a,o,s,u,c,l){t.call(r,e,i,a,o,s,u,c,l),n.unbind()}));return n}},{key:"emit",value:function(e,t,r,n,i,a,o,s,u){if(!this._suspendEvents){var c=this._events[e];if(!c)return this;c=c.slice(0);for(var l=0;l<c.length;l++)if(c[l])try{c[l].call(this,t,r,n,i,a,o,s,u)}catch(h){console.info("%c%s %c(event error)","color: #06f",e,"color: #f00"),console.error(h)}return this}}},{key:"emitHighWeight",value:function(e){if(!this._suspendHighEvents){var t=this._weightEvents[e];if(!t)return this;var r=t[0];try{for(var n,i=arguments.length,a=new Array(i>1?i-1:0),o=1;o<i;o++)a[o-1]=arguments[o];(n=r.fn).call.apply(n,[this].concat(a))}catch(s){console.info("%c%s %c(emitHighWeight error)","color: #06f",e,"color: #f00"),console.error(s)}return this}}},{key:"unbindWeight",value:function(e,t){if(!e)return this._weightEvents={},this;var r=this._weightEvents[e];if(!r)return this;if(!t)return delete this._weightEvents[e],this;var n=r.length;while(n--)if(r[n].fn==t){if(1===r.length)return delete this._weightEvents[e],this;r.splice(n,1);break}return this}},{key:"unbind",value:function(e,t){if(e){var r=this._events[e];if(!r)return this;if(t){var n=r.indexOf(t);-1!==n&&(1===r.length?delete this._events[e]:r.splice(n,1))}else delete this._events[e]}else this._events={};return this}}]),e}(),M={allowSwiftShader:!1,animationAutoplay:!0,anisotropy:!0,annotation:0,annotationTooltipVisible:!0,arkit:!1,arkitDebug:!1,asyncImage:!1,asyncShader:0,autoMaterial:0,autospin:0,autostart:!0,camera:!1,cameraConstraints:!0,cameraFollowBones:0,cardboard:0,carmel:!1,cleanShader:!1,continuousRender:!1,convertVertexColor8Bit:!0,debug3D:!1,depthMipmap:0,dofAttenuateDistance:!0,dofAttenuateSpeed:!1,dofCircle:!0,dofRes:2,dofSticky:!1,dofTransition:!0,doubleClick:!0,downloadPicture:!1,drs:!0,drsRatio:1,drsFps:15,drsMin:.8,drsTest:!1,epsilonAlpha:1e-5,floatRtt:2,forceController:"",forceControllerOrientation:-.5,forceControllerRayOrientation:-.075,forceFallback:!1,forceMs:0,forceTriangles:!1,fpsSpeed:5,grainSpeed:64,graphOptimizer:!1,imageCompression:!1,internal:!1,isApp:!1,keepEmptyGeometries:!1,materialNames:"main_material",materialPacking:!0,materialShowcase:!1,maxTextureUnits:32,maxDevicePixelRatio:3,maxTextureSize:8192,maxVertexUniforms:8192,mergeMaterials:!1,morphEpsilon:.05,morphGpu:4,navigation:"orbit",orbitPanFactor:1,orbitRotationFactor:1,orbitZoomFactor:1,panorama:!1,powerPreference:"high-performance",preload:!1,preserveDrawingBuffer:!1,processMaterial:!1,processOptions:!1,refractionRes:1,resizeTimeout:16,rgbm:!0,scale:1,scaleEpsilon:1e-5,scrollwheel:!0,shadow:!0,shadowAtlas:!0,shadowJitterOffset:"default",shadowNormalOffset:!1,shadowPCF:"1Tap(4texFetch)",shadowTextureSize:1024,share:!1,snapKeyframe:!1,soundEnable:!0,soundMute:!1,soundPreload:!1,splitLimit:65535,ssaoNormal:!1,ssrTransparent:!1,sssJitter:1,sssKernel:17,stats:!1,svgSize:2048,substanceDisplacement:!1,supersample:!0,tracking:!1,taaAnimation:!1,taaFeedbackMax:.97,taaFeedbackMin:.88,textureFrameBudget:512,transparent:!1,uiAnimations:!0,uiAnnotations:!0,uiAr:!1,uiArHelp:!0,uiArQrcode:!0,uiColor:"",uiControls:!0,uiFadeout:!1,uiFullscreen:!0,uiGeneralControls:!0,uiHelp:!0,uiHint:1,uiInfos:!1,uiInspector:!0,uiInspectorOpen:!1,uiLoading:!0,uiSettings:!0,uiSnapshots:!0,uiSound:!0,uiStart:!0,uiStop:!1,uiTheatre:!1,uiVr:!0,uiWatermark:!1,uiWatermarkLink:!0,unitRenderLocal:!1,unitRenderReporter:"html",useVao:!0,varyingSorting:!0,vrAr:!1,vrBrowserEnv:"c0022acc4f3242e2bcae8043e08df8cc",vrFade:200,vrLauncherAlphaCardFactor:1,vrMirror:!1,vrMobileMaxFaces:5e4,vrGenerateUiTextures:!0,vrForceRaf:!1,vrLinkNavigation:0,vrInNavigation:0,vrScaleRtt:0,vrStereo:!0,webglExt:!0,webglRestore:3,webglTimerGpu:!1,webglUniforms:!1,zoct:!1,zq:!0,zw:!0,zratio:50,zz:!1,annotationCycleAutostart:!1,annotationCycleDuration:5e3,sssHalfKernel:9,preferOriginalNormalMap:!1},w=n("1c38"),N={"utils/common.glsl":"#define PI 3.141593\n#define saturate(_x) clamp(_x, 0., 1.)\n","utils/functions.glsl":"// approximation such as http://chilliant.blogspot.fr/2012/08/srgb-approximations-for-hlsl.html\n// introduced slightly darker colors and more slight banding in the darks.\n\n// so we stick with the reference implementation (except we don't check if color >= 0.0):\n// https://www.khronos.org/registry/gles/extensions/EXT/EXT_sRGB.txt\n#define LIN_SRGB(x) x < 0.0031308 ? x * 12.92 : 1.055 * pow(x, 1.0/2.4) - 0.055\n#define SRGB_LIN(x) x < 0.04045 ? x * (1.0 / 12.92) : pow((x + 0.055) * (1.0 / 1.055), 2.4)\n\nfloat linearTosRGB(const in float color) { return LIN_SRGB(color); }\nvec3 linearTosRGB(const in vec3 color) { return vec3(LIN_SRGB(color.r), LIN_SRGB(color.g), LIN_SRGB(color.b)); }\nvec4 linearTosRGB(const in vec4 color) { return vec4(LIN_SRGB(color.r), LIN_SRGB(color.g), LIN_SRGB(color.b), color.a); }\n\nfloat sRGBToLinear(const in float color) { return SRGB_LIN(color); }\nvec3 sRGBToLinear(const in vec3 color) { return vec3(SRGB_LIN(color.r), SRGB_LIN(color.g), SRGB_LIN(color.b)); }\nvec4 sRGBToLinear(const in vec4 color) { return vec4(SRGB_LIN(color.r), SRGB_LIN(color.g), SRGB_LIN(color.b), color.a); }\n\n//http://graphicrants.blogspot.fr/2009/04/rgbm-color-encoding.html\nvec3 RGBMToRGB( const in vec4 rgba ) {\n const float maxRange = 8.0;\n return rgba.rgb * maxRange * rgba.a;\n}\n\nconst mat3 LUVInverse = mat3( 6.0013, -2.700, -1.7995, -1.332, 3.1029, -5.7720, 0.3007, -1.088, 5.6268 );\n\nvec3 LUVToRGB( const in vec4 vLogLuv ) {\n float Le = vLogLuv.z * 255.0 + vLogLuv.w;\n vec3 Xp_Y_XYZp;\n Xp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n Xp_Y_XYZp.z = Xp_Y_XYZp.y / vLogLuv.y;\n Xp_Y_XYZp.x = vLogLuv.x * Xp_Y_XYZp.z;\n vec3 vRGB = LUVInverse * Xp_Y_XYZp;\n return max(vRGB, 0.0);\n}\n\n// http://graphicrants.blogspot.fr/2009/04/rgbm-color-encoding.html\nvec4 encodeRGBM(const in vec3 color, const in float range) {\n if(range <= 0.0) return vec4(color, 1.0);\n vec4 rgbm;\n vec3 col = color / range;\n rgbm.a = clamp( max( max( col.r, col.g ), max( col.b, 1e-6 ) ), 0.0, 1.0 );\n rgbm.a = ceil( rgbm.a * 255.0 ) / 255.0;\n rgbm.rgb = col / rgbm.a;\n return rgbm;\n}\n\nvec3 decodeRGBM(const in vec4 color, const in float range) {\n if(range <= 0.0) return color.rgb;\n return range * color.rgb * color.a;\n}\n","shadowing/shadowReceive.glsl":"#extension GL_OES_standard_derivatives : enable\n\n%UNROLL 4%\n#ifdef HAS_SHADOW_%ID%\n uniform float uShadowReceive%ID%_bias;\n uniform float uStaticFrameNumShadow%ID%;\n uniform vec2 uShadow_Texture%ID%_depthRange;\n uniform vec3 uShadow_Texture%ID%_projection;\n uniform vec4 uShadow_Texture%ID%_viewLook;\n uniform vec4 uShadow_Texture%ID%_viewRight;\n uniform vec4 uShadow_Texture%ID%_viewUp;\n\n #ifdef _ATLAS_SHADOW\n uniform vec4 uShadow_Texture%ID%_mapSize;\n #else\n uniform vec2 uShadow_Texture%ID%_renderSize;\n #endif\n#endif // HAS_SHADOW\n%%\n\n// TODO rename sampler uniform to be better and sync with light number (e.g: sShadow0, sShadow1, etc)\n#ifdef _ATLAS_SHADOW\n uniform vec2 uShadow_Texture0_renderSize;\n uniform sampler2D Texture12;\n#else\n #ifdef HAS_SHADOW_0\n uniform sampler2D Texture12;\n #define TEX_SHADOW_0 Texture12\n #endif\n #ifdef HAS_SHADOW_1\n uniform sampler2D Texture13;\n #define TEX_SHADOW_1 Texture13\n #endif\n #ifdef HAS_SHADOW_2\n uniform sampler2D Texture14;\n #define TEX_SHADOW_2 Texture14\n #endif\n #ifdef HAS_SHADOW_3\n uniform sampler2D Texture15;\n #define TEX_SHADOW_3 Texture15\n #endif\n#endif // _ATLAS_SHADOW\n\n#ifdef _OUT_DISTANCE\n#define OPT_ARG_outDistance ,out float outDistance\n#define OPT_INSTANCE_ARG_outDistance ,outDistance\n#else\n#define OPT_ARG_outDistance\n#define OPT_INSTANCE_ARG_outDistance\n#endif\n\n#ifdef _ATLAS_SHADOW\n#define OPT_ARG_atlasSize ,const in vec4 atlasSize\n#else\n#define OPT_ARG_atlasSize\n#endif\n\n#ifdef _NORMAL_OFFSET\n#define OPT_ARG_normalBias ,const in float normalBias\n#else\n#define OPT_ARG_normalBias\n#endif\n\n#ifdef _JITTER_OFFSET\n#define OPT_ARG_jitter ,const in float jitter\n#define OPT_INSTANCE_ARG_jitter ,jitter\n#else\n#define OPT_ARG_jitter\n#define OPT_INSTANCE_ARG_jitter\n#endif\n\n#pragma include \"shadowing/tapPCF.glsl\"\n\nfloat shadowReceive(const in bool lighted,\n const in vec3 normalWorld,\n const in vec3 vertexWorld,\n\n const in sampler2D shadowTexture,\n\n const in vec2 shadowSize,\n const in vec3 shadowProjection,\n\n const in vec4 shadowViewRight,\n const in vec4 shadowViewUp,\n const in vec4 shadowViewLook,\n\n\n const in vec2 shadowDepthRange,\n const in float shadowBias\n OPT_ARG_atlasSize\n OPT_ARG_normalBias\n OPT_ARG_outDistance\n OPT_ARG_jitter) {\n\n // 0 for early out\n bool earlyOut = false;\n\n // Calculate shadow amount\n float shadow = 1.0;\n\n if (!lighted) {\n shadow = 0.0;\n#ifndef _OUT_DISTANCE\n earlyOut = true;\n#endif // _OUT_DISTANCE\n }\n\n if (shadowDepthRange.x == shadowDepthRange.y) {\n earlyOut = true;\n }\n\n vec4 shadowVertexEye;\n vec4 shadowNormalEye;\n float shadowReceiverZ = 0.0;\n vec4 shadowVertexProjected;\n vec2 shadowUV;\n float N_Dot_L;\n float invDepthRange;\n\n if (!earlyOut) {\n\n shadowVertexEye.x = dot(shadowViewRight.xyz, vertexWorld.xyz) + shadowViewRight.w;\n shadowVertexEye.y = dot(shadowViewUp.xyz, vertexWorld.xyz) + shadowViewUp.w;\n shadowVertexEye.z = dot(shadowViewLook.xyz, vertexWorld.xyz) + shadowViewLook.w;\n shadowVertexEye.w = 1.0;\n\n\n // derivated, only need z.\n //vec3 shadowLightDir = vec3(0.0, 0.0, 1.0); // in shadow view light is camera\n //shadowNormalEye = shadowViewMatrix * normalFront;\n //shadowNormalEye.x = dot(shadowViewRight.xyz, normalWorld.xyz);\n //shadowNormalEye.y = dot(shadowViewUp.xyz, normalWorld.xyz);\n shadowNormalEye.z = dot(shadowViewLook.xyz, normalWorld.xyz);\n //shadowNormalEye.w = 0.0;\n\n //N_Dot_L = dot(shadowNormalEye.xyz, shadowLightDir);\n N_Dot_L = shadowNormalEye.z;\n\n if (!earlyOut) {\n\n invDepthRange = 1.0 / (shadowDepthRange.y - shadowDepthRange.x);\n\n#ifdef _NORMAL_OFFSET\n\n // http://www.dissidentlogic.com/old/images/NormalOffsetShadows/GDC_Poster_NormalOffset.png\n float normalOffsetScale = clamp(1.0 - N_Dot_L, 0.0 , 1.0);\n normalOffsetScale *= abs((shadowVertexEye.z - shadowDepthRange.x) * invDepthRange);\n normalOffsetScale *= max(shadowProjection.x, shadowProjection.y);\n normalOffsetScale *= normalBias * invDepthRange;\n\n\n vec4 shadowNormalShift = vec4(normalWorld, 0.0) * normalOffsetScale;\n shadowNormalEye.x = dot(shadowViewRight.xyz, shadowNormalShift.xyz);\n shadowNormalEye.y = dot(shadowViewUp.xyz, shadowNormalShift.xyz);\n shadowNormalEye.z = dot(shadowViewLook.xyz, shadowNormalShift.xyz);\n shadowNormalEye.w = 0.0;\n\n vec4 viewShadow = shadowVertexEye + shadowNormalEye;\n#else\n vec4 viewShadow = shadowVertexEye;\n#endif\n\n\n if (shadowProjection.z == 0.0){\n\n // X, 0, 0, 0,\n // 0, Y, 0, 0,\n // 0, 0, -1, -1,\n // 0, 0, -2.0*znear, 0\n // mat4 shadowProjectionMatrix;\n // shadowProjectionMatrix[0] = vec4(shadowProjection.x, 0.0, 0.0, 0.0 );\n // shadowProjectionMatrix[1] = vec4(0.0, shadowProjection.y, 0.0, 0.0 );\n // shadowProjectionMatrix[2] = vec4(0.0, 0.0, -1.0, -1.0 );\n // shadowProjectionMatrix[3] = vec4(0.0, 0.0, -2.0*shadowDepthRange.x, 0.0 );\n // shadowVertexProjected = shadowProjectionMatrix * shadowVertexEye;\n\n // derivated optimisation\n shadowVertexProjected.x = shadowProjection.x * viewShadow.x;\n shadowVertexProjected.y = shadowProjection.y * viewShadow.y;\n\n shadowVertexProjected.z = - viewShadow.z - (2.0 * shadowDepthRange.x * viewShadow.w);\n shadowVertexProjected.w = - viewShadow.z;\n\n }\n else{\n // lr = 1/(left-right);\n // bt = 1/(bottom-top);\n // nf = 1/(near-far);\n // -2*lr, 0, 0, 0,\n // 0, -2*bt, 0, 0,\n // 0, 0, 2*nf, 0.0,\n // (left+right)*lr, (top+bottom)*bt, (far+near)*nf), 1\n // here left = -right && top = -bottom\n // float lr = 1.0 / (-2.0 * shadowProjection.x);\n // float bt = 1.0 / (-2.0 * shadowProjection.y);\n // float nf = 1.0 / (shadowDepthRange.x - shadowDepthRange.y);\n float nfNeg = 1.0 / (shadowDepthRange.x - shadowDepthRange.y);\n float nfPos = (shadowDepthRange.x + shadowDepthRange.y)*nfNeg;\n\n //mat4 shadowProjectionMatrix;\n //shadowProjectionMatrix[0] = vec4(1.0 / shadowProjection.x, 0.0, 0.0, 0.0 );\n //shadowProjectionMatrix[1] = vec4(0.0, 1.0 / shadowProjection.y, 0.0, 0.0 );\n //shadowProjectionMatrix[2] = vec4(0.0, 0.0, 2.0*nfNeg, 0.0 );\n //shadowProjectionMatrix[3] = vec4(0.0, 0.0, nfPos, 1.0 );\n //shadowdertexProjected = shadowProjectionMatrix * shadowVertexEye;\n\n // derivated optimisation\n shadowVertexProjected.x = viewShadow.x / shadowProjection.x;\n shadowVertexProjected.y = viewShadow.y / shadowProjection.y;\n\n shadowVertexProjected.z = 2.0 * nfNeg* viewShadow.z + nfPos * viewShadow.w;\n shadowVertexProjected.w = viewShadow.w;\n\n }\n\n\n if (shadowVertexProjected.w < 0.0) {\n earlyOut = true; // notably behind camera\n }\n\n }\n\n if (!earlyOut) {\n\n shadowUV.xy = shadowVertexProjected.xy / shadowVertexProjected.w;\n shadowUV.xy = shadowUV.xy * 0.5 + 0.5;// mad like\n\n if (any(bvec4 ( shadowUV.x > 1., shadowUV.x < 0., shadowUV.y > 1., shadowUV.y < 0.))) {\n earlyOut = true;// limits of light frustum\n }\n\n // most precision near 0, make sure we are near 0 and in [0,1]\n shadowReceiverZ = - shadowVertexEye.z;\n shadowReceiverZ = (shadowReceiverZ - shadowDepthRange.x) * invDepthRange;\n\n if(shadowReceiverZ < 0.0) {\n earlyOut = true; // notably behind camera\n }\n\n }\n }\n\n // pcf pbias to add on offset\n vec2 shadowBiasPCF = vec2 (0.);\n\n#ifdef GL_OES_standard_derivatives\n#ifdef _RECEIVERPLANEDEPTHBIAS\n vec2 biasUV;\n\n vec3 texCoordDY = dFdx(shadowVertexEye.xyz);\n vec3 texCoordDX = dFdy(shadowVertexEye.xyz);\n\n biasUV.x = texCoordDY.y * texCoordDX.z - texCoordDX.y * texCoordDY.z;\n biasUV.y = texCoordDX.x * texCoordDY.z - texCoordDY.x * texCoordDX.z;\n biasUV *= 1.0 / ((texCoordDX.x * texCoordDY.y) - (texCoordDX.y * texCoordDY.x));\n\n // Static depth biasing to make up for incorrect fractional sampling on the shadow map grid\n float fractionalSamplingError = dot(vec2(1.0, 1.0) * shadowSize.xy, abs(biasUV));\n float receiverDepthBias = min(fractionalSamplingError, 0.01);\n\n shadowBiasPCF.x = biasUV.x;\n shadowBiasPCF.y = biasUV.y;\n\n shadowReceiverZ += receiverDepthBias;\n\n#else // _RECEIVERPLANEDEPTHBIAS\n shadowBiasPCF.x = clamp(dFdx(shadowReceiverZ) * shadowSize.x, -1.0, 1.0 );\n shadowBiasPCF.y = clamp(dFdy(shadowReceiverZ) * shadowSize.y, -1.0, 1.0 );\n#endif\n\n#endif // GL_OES_standard_derivatives\n\n\n vec4 clampDimension;\n\n#ifdef _ATLAS_SHADOW\n shadowUV.xy = ((shadowUV.xy * atlasSize.zw ) + atlasSize.xy) * shadowSize.xy;\n\n // clamp uv bias/filters by half pixel to avoid point filter on border\n clampDimension.xy = atlasSize.xy + vec2(0.5);\n clampDimension.zw = (atlasSize.xy + atlasSize.zw) - vec2(0.5);\n\n clampDimension = clampDimension * shadowSize.xyxy;\n#else\n clampDimension = vec4(0.0, 0.0, 1.0, 1.0);\n#endif // _RECEIVERPLANEDEPTHBIAS\n\n\n // now that derivatives is done and we don't access any mipmapped/texgrad texture we can early out\n // see http://teknicool.tumblr.com/post/77263472964/glsl-dynamic-branching-and-texture-samplers\n if (earlyOut) {\n // empty statement because of weird gpu intel bug\n } else {\n\n // depth bias: fighting shadow acne (depth imprecsion z-fighting)\n // cosTheta is dot( n, l ), clamped between 0 and 1\n // float shadowBias = 0.005*tan(acos(N_Dot_L));\n // same but 4 cycles instead of 15\n float depthBias = 0.05 * sqrt( 1.0 - N_Dot_L * N_Dot_L) / clamp(N_Dot_L, 0.0005, 1.0);\n\n // That makes sure that plane perpendicular to light doesn't flicker due to\n // selfshadowing and 1 = dot(Normal, Light) using a min bias\n depthBias = clamp(depthBias, 0.00005, 2.0 * shadowBias);\n\n // shadowZ must be clamped to [0,1]\n // otherwise it's not comparable to shadow caster depth map\n // which is clamped to [0,1]\n // Not doing that makes ALL shadowReceiver > 1.0 black\n // because they ALL becomes behind any point in Caster depth map\n shadowReceiverZ = clamp(shadowReceiverZ, 0.0, 1.0 -depthBias) - depthBias;\n\n // Now computes Shadow\n float res = getShadowPCF(shadowTexture,\n shadowSize,\n shadowUV,\n shadowReceiverZ,\n shadowBiasPCF,\n clampDimension\n OPT_INSTANCE_ARG_outDistance\n OPT_INSTANCE_ARG_jitter);\n#ifdef _OUT_DISTANCE\n if (lighted) shadow = res;\n outDistance *= shadowDepthRange.y - shadowDepthRange.x; // world space distance\n#else\n shadow = res;\n#endif // _OUT_DISTANCE\n }\n\n return shadow;\n\n}\n","shadowing/shadowLinearSoft.glsl":"float decodeFloatRGBA(const in vec4 rgba) {\n return dot(rgba, vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n}\n\nfloat getSingleFloatFromTex(const in sampler2D depths, const in vec2 uv){\n#ifndef _FLOATTEX\n return decodeFloatRGBA(texture2D(depths, uv));\n#else\n return texture2D(depths, uv).x;\n#endif\n}\n\n// simulation of texture2Dshadow glsl call on HW\n// http://codeflow.org/entries/2013/feb/15/soft-shadow-mapping/\nfloat texture2DCompare(const in sampler2D depths,\n const in vec2 uv,\n const in float compare,\n const in vec4 clampDimension){\n float depth = getSingleFloatFromTex(depths, clamp(uv, clampDimension.xy, clampDimension.zw));\n return compare - depth;\n}\n\n#ifdef _JITTER_OFFSET\n// TODO could be in a random.glsl file\n// https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Shaders/Private/Random.ush#L27\nfloat shadowInterleavedGradientNoise(const in vec2 fragCoord, const in float frameMod) {\n vec3 magic = vec3(0.06711056, 0.00583715, 52.9829189);\n return fract(magic.z * fract(dot(fragCoord.xy + frameMod * vec2(47.0, 17.0) * 0.695, magic.xy)));\n}\n#endif\n\n// simulates linear fetch like texture2d shadow\nfloat texture2DShadowLerp(\n const in sampler2D depths,\n const in vec2 size,\n const in vec2 uv,\n const in float compare,\n const in vec4 clampDimension\n OPT_ARG_outDistance\n OPT_ARG_jitter){\n\n vec2 centroidCoord = uv / size.xy;\n\n#ifdef _JITTER_OFFSET\n if (jitter > 0.0){\n centroidCoord += shadowInterleavedGradientNoise(gl_FragCoord.xy, jitter);\n }\n#endif\n\n centroidCoord = centroidCoord + 0.5;\n vec2 f = fract(centroidCoord);\n vec2 centroidUV = floor(centroidCoord) * size.xy;\n\n vec4 fetches;\n const vec2 shift = vec2(1.0, 0.0);\n fetches.x = texture2DCompare(depths, centroidUV + size.xy * shift.yy, compare, clampDimension);\n fetches.y = texture2DCompare(depths, centroidUV + size.xy * shift.yx, compare, clampDimension);\n fetches.z = texture2DCompare(depths, centroidUV + size.xy * shift.xy, compare, clampDimension);\n fetches.w = texture2DCompare(depths, centroidUV + size.xy * shift.xx, compare, clampDimension);\n\n#ifdef _OUT_DISTANCE\n float _a = mix(fetches.x, fetches.y, f.y);\n float _b = mix(fetches.z, fetches.w, f.y);\n outDistance = mix(_a, _b, f.x);\n#endif\n\n vec4 st = step(fetches, vec4(0.0));\n\n float a = mix(st.x, st.y, f.y);\n float b = mix(st.z, st.w, f.y);\n return mix(a, b, f.x);\n}\n","shadowing/tapPCF.glsl":'#pragma include "shadowing/shadowLinearSoft.glsl"\n\nfloat getShadowPCF(\n const in sampler2D depths,\n const in vec2 size,\n const in vec2 uv,\n const in float compare,\n const in vec2 biasPCF,\n const in vec4 clampDimension\n OPT_ARG_outDistance\n OPT_ARG_jitter) {\n\n float res = 0.0;\n\n res += texture2DShadowLerp(depths, size, uv + biasPCF, compare, clampDimension OPT_INSTANCE_ARG_outDistance OPT_INSTANCE_ARG_jitter);\n\n\n#if defined(_PCFx1)\n\n#else\n\n float dx0 = -size.x;\n float dy0 = -size.y;\n float dx1 = size.x;\n float dy1 = size.y;\n\n#define TSF(o1,o2) texture2DShadowLerp(depths, size, uv + vec2(o1, o2) + biasPCF, compare, clampDimension OPT_INSTANCE_ARG_outDistance OPT_INSTANCE_ARG_jitter)\n\n res += TSF(dx0, dx0);\n res += TSF(dx0, .0);\n res += TSF(dx0, dx1);\n\n#if defined(_PCFx4)\n\n res /=4.0;\n\n#elif defined(_PCFx9)\n res += TSF(.0, dx0);\n res += TSF(.0, dx1);\n\n res += TSF(dx1, dx0);\n res += TSF(dx1, .0);\n res += TSF(dx1, dx1);\n\n\n res /=9.0;\n\n#elif defined(_PCFx25)\n\n float dx02 = 2.0*dx0;\n float dy02 = 2.0*dy0;\n float dx2 = 2.0*dx1;\n float dy2 = 2.0*dy1;\n\n // complete row above\n res += TSF(dx0, dx02);\n res += TSF(dx0, dx2);\n\n res += TSF(.0, dx02);\n res += TSF(.0, dx2);\n\n res += TSF(dx1, dx02);\n res += TSF(dx1, dx2);\n\n // two new col\n res += TSF(dx02, dx02);\n res += TSF(dx02, dx0);\n res += TSF(dx02, .0);\n res += TSF(dx02, dx1);\n res += TSF(dx02, dx2);\n\n res += TSF(dx2, dx02);\n res += TSF(dx2, dx0);\n res += TSF(dx2, .0);\n res += TSF(dx2, dx1);\n res += TSF(dx2, dx2);\n\n\n res/=25.0;\n\n#endif\n\n#undef TSF\n\n#endif\n return res;\n}\n/////// end Tap\n',"utils/lightCommon.glsl":"#define LIGHT_SPOT 0\n#define LIGHT_POINT 1\n#define LIGHT_DIRECTION 2\n#define LIGHT_HEMI 3\n\n%UNROLL 4%\n#ifdef LIGHT_TYPE_%ID%\n uniform vec4 uEditorLight%ID%_diffuse;\n\n #if LIGHT_TYPE_%ID% == LIGHT_DIRECTION\n uniform vec3 uEditorLight%ID%_viewDirection;\n #elif LIGHT_TYPE_%ID% == LIGHT_SPOT\n uniform vec3 uEditorLight%ID%_viewDirection;\n uniform vec4 uEditorLight%ID%_viewPosition;\n uniform float uEditorLight%ID%_spotBlend;\n uniform float uEditorLight%ID%_spotCutOff;\n uniform vec4 uEditorLight%ID%_attenuation;\n #elif LIGHT_TYPE_%ID% == LIGHT_POINT\n uniform vec4 uEditorLight%ID%_viewPosition;\n uniform vec4 uEditorLight%ID%_attenuation;\n #elif LIGHT_TYPE_%ID% == LIGHT_HEMI\n uniform vec4 uEditorLight%ID%_ground;\n uniform vec3 uEditorLight%ID%_viewDirection;\n #endif\n#endif // LIGHT_TYPE\n%%\n\nfloat getLightAttenuation(const in float dist, const in vec4 lightAttenuation) {\n // lightAttenuation(constantEnabled, linearEnabled, quadraticEnabled)\n // TODO find a vector alu instead of 4 scalar\n float constant = lightAttenuation.x;\n float linear = lightAttenuation.y * dist;\n float quadratic = lightAttenuation.z * dist * dist;\n return 1.0 / (constant + linear + quadratic);\n}\n\nvoid precomputeSpot(\n const in vec3 normal,\n const in vec3 viewVertex,\n \n const in vec3 lightViewDirection,\n const in vec4 lightAttenuation,\n const in vec3 lightViewPosition,\n const in float lightSpotCutOff,\n const in float lightSpotBlend,\n \n out float attenuation,\n out vec3 eyeLightDir,\n out float dotNL) {\n\n eyeLightDir = lightViewPosition - viewVertex;\n float dist = length(eyeLightDir);\n eyeLightDir = dist > 0.0 ? eyeLightDir / dist : vec3( 0.0, 1.0, 0.0 );\n\n float cosCurAngle = dot(-eyeLightDir, lightViewDirection);\n float spot = cosCurAngle * smoothstep(0.0, 1.0, (cosCurAngle - lightSpotCutOff) / lightSpotBlend);\n\n dotNL = dot(eyeLightDir, normal);\n attenuation = spot * getLightAttenuation(dist, lightAttenuation);\n}\n\nvoid precomputePoint(\n const in vec3 normal,\n const in vec3 viewVertex,\n\n const in vec4 lightAttenuation,\n const in vec3 lightViewPosition,\n\n out float attenuation,\n out vec3 eyeLightDir,\n out float dotNL) {\n\n eyeLightDir = lightViewPosition - viewVertex;\n float dist = length(eyeLightDir);\n\n attenuation = getLightAttenuation(dist, lightAttenuation);\n eyeLightDir = dist > 0.0 ? eyeLightDir / dist : vec3( 0.0, 1.0, 0.0 );\n dotNL = dot(eyeLightDir, normal);\n}\n\nvoid precomputeSun(\n const in vec3 normal,\n const in vec3 lightViewDirection,\n \n out float attenuation,\n out vec3 eyeLightDir,\n out float dotNL) {\n\n attenuation = 1.0;\n eyeLightDir = -lightViewDirection;\n dotNL = dot(eyeLightDir, normal);\n}","utils/lights.glsl":'#pragma include "utils/lightCommon.glsl"\n\n////////////////\n// COOK TORRANCE\n////////////////\nvec3 specularCookTorrance(\n const in vec3 normal,\n const in vec3 lightDir,\n const in vec3 eyeVector,\n const in float materialShininess,\n const in vec3 materialSpecular,\n const in vec3 lightSpecular) {\n \n vec3 h = normalize(eyeVector + lightDir);\n float nh = dot(normal, h);\n float specfac = 0.0;\n\n if(nh > 0.0) {\n float nv = max( dot(normal, eyeVector), 0.0 );\n float i = pow(nh, materialShininess);\n i = i / (0.1 + nv);\n specfac = i;\n }\n // ugly way to fake an energy conservation (mainly to avoid super bright stuffs with low glossiness)\n float att = materialShininess > 100.0 ? 1.0 : smoothstep(0.0, 1.0, materialShininess * 0.01);\n return specfac * materialSpecular * lightSpecular * att;\n}\n\nvec3 lambert(const in float dotNL, const in vec3 materialDiffuse, const in vec3 lightDiffuse) {\n return dotNL * materialDiffuse * lightDiffuse;\n}\n\nvoid computeLightLambertCookTorrance(\n const in vec3 normal,\n const in vec3 eyeVector,\n const in float dotNL,\n const in float attenuation,\n\n const in vec3 materialDiffuse,\n const in vec3 materialSpecular,\n const in float materialShininess,\n\n const in vec3 lightDiffuse,\n const in vec3 lightSpecular,\n const in vec3 eyeLightDir,\n\n out vec3 diffuseOut,\n out vec3 specularOut,\n out bool lighted) {\n\n lighted = dotNL > 0.0;\n if (lighted == false) {\n specularOut = diffuseOut = vec3(0.0);\n return;\n }\n\n specularOut = attenuation * specularCookTorrance(normal, eyeLightDir, eyeVector, materialShininess, materialSpecular, lightSpecular);\n diffuseOut = attenuation * lambert(dotNL, materialDiffuse, lightDiffuse);\n}\n\n///////\n// HEMI\n///////\nvoid hemiLight(\n const in vec3 normal,\n const in vec3 eyeVector,\n const in float dotNL,\n const in vec3 eyeLightDir,\n\n const in vec3 materialDiffuse,\n const in vec3 materialSpecular,\n const in float materialShininess,\n\n const in vec3 lightDiffuse,\n const in vec3 lightGround,\n\n out vec3 diffuseOut,\n out vec3 specularOut,\n out bool lighted) {\n\n lighted = false;\n float weight = 0.5 * dotNL + 0.5;\n diffuseOut = materialDiffuse * mix(lightGround, lightDiffuse, weight);\n\n // same cook-torrance as above for sky/ground\n float skyWeight = 0.5 * dot(normal, normalize(eyeVector + eyeLightDir)) + 0.5;\n float gndWeight = 0.5 * dot(normal, normalize(eyeVector - eyeLightDir)) + 0.5;\n float skySpec = pow(skyWeight, materialShininess);\n float skyGround = pow(gndWeight, materialShininess);\n float divisor = (0.1 + max( dot(normal, eyeVector), 0.0 ));\n float att = materialShininess > 100.0 ? 1.0 : smoothstep(0.0, 1.0, materialShininess * 0.01);\n \n specularOut = lightDiffuse * materialSpecular * weight * att * (skySpec + skyGround) / divisor;\n}\n',"utils/lightsPBR.glsl":'#pragma include "utils/common.glsl"\n#pragma include "utils/lightCommon.glsl"\n\nvec4 precomputeGGX(const in vec3 normal, const in vec3 eyeVector, const in float roughness) {\n float NoV = saturate(dot(normal, eyeVector));\n float r2 = roughness * roughness;\n return vec4(r2, r2 * r2, NoV, NoV * (1.0 - r2));\n}\n\n// Walter et al. 2007, "Microfacet models for refraction through rough surfaces"\nfloat D_GGX(const vec4 precomputeGGX, const float NoH) {\n float a2 = precomputeGGX.y;\n float d = (NoH * a2 - NoH) * NoH + 1.0;\n return a2 / (PI * d * d);\n}\n\n// Schlick 1994, "An Inexpensive BRDF Model for Physically-Based Rendering"\nvec3 F_Schlick(const vec3 f0, const float f90, const in float VoH) {\n float VoH5 = pow(1.0 - VoH, 5.0);\n return f90 * VoH5 + (1.0 - VoH5) * f0;\n}\n\n// greyscale f0 version (clearcoat)\nfloat F_Schlick(const float f0, const float f90, const in float VoH) {\n return f0 + (f90 - f0) * pow(1.0 - VoH, 5.0);\n}\n\n\n// Heitz 2014, "Understanding the Masking-Shadowing Function in Microfacet-Based BRDFs"\nfloat V_SmithCorrelated(const vec4 precomputeGGX, const float NoL) {\n float a = precomputeGGX.x;\n float smithV = NoL * (precomputeGGX.w + a);\n float smithL = precomputeGGX.z * (NoL * (1.0 - a) + a);\n return 0.5 / (smithV + smithL);\n // same as\n // Hammon 2017, "PBR Diffuse Lighting for GGX+Smith Microsurfaces"\n // return 0.5 / mix(2.0 * NoL * NoV, NoL + NoV, precomputeGGX.y)\n}\n\nvec3 specularLobe(const vec4 precomputeGGX, const vec3 normal, const vec3 eyeVector, const vec3 eyeLightDir, const vec3 specular, const float NoL, const float f90) {\n vec3 H = normalize(eyeVector + eyeLightDir);\n float NoH = saturate(dot(normal, H));\n float VoH = saturate(dot(eyeLightDir, H));\n\n // distribution / visibility / fresnel\n float D = D_GGX(precomputeGGX, NoH);\n float V = V_SmithCorrelated(precomputeGGX, NoL);\n vec3 F = F_Schlick(specular, f90, VoH);\n\n return (D * V * PI) * F; // we multipy by PI because our diffuse is not divided by PI\n}\n\n// pure compute Light PBR\nvoid computeLightLambertGGX(\n const in vec3 normal,\n const in vec3 eyeVector,\n const in float NoL,\n const in vec4 precomputeGGX,\n\n const in vec3 diffuse,\n const in vec3 specular,\n\n const in float attenuation,\n const in vec3 lightColor,\n const in vec3 eyeLightDir,\n const in float f90,\n\n out vec3 diffuseOut,\n out vec3 specularOut,\n out bool lighted) {\n\n lighted = NoL > 0.0;\n if (lighted == false) {\n specularOut = diffuseOut = vec3(0.0);\n return;\n }\n\n vec3 colorAttenuate = attenuation * NoL * lightColor;\n specularOut = colorAttenuate * specularLobe(precomputeGGX, normal, eyeVector, eyeLightDir, specular, NoL, f90);\n diffuseOut = colorAttenuate * diffuse;\n}\n\n/////////////\n// ANISOTROPY\n/////////////\n\nfloat V_SmithGGXCorrelated_Anisotropic(float at, float ab, float ToV, float BoV, float ToL, float BoL, float NoV, float NoL) {\n // Heitz 2014, "Understanding the Masking-Shadowing Function in Microfacet-Based BRDFs"\n // UE4 version : https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Shaders/Private/BRDF.ush#L270-L286\n float lambdaV = NoL * length(vec3(at * ToV, ab * BoV, NoV));\n float lambdaL = NoV * length(vec3(at * ToL, ab * BoL, NoL));\n return 0.5 / (lambdaV + lambdaL);\n}\n\nfloat D_GGX_Anisotropic(const float at, const float ab, const float ToH, const float BoH, const float NoH) {\n // Burley 2012, "Physically-Based Shading at Disney"\n // https://github.com/google/filament/blob/master/shaders/src/brdf.fs#L81\n // similar to UE4 version https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Shaders/Private/BRDF.ush#L232-L238\n float a2 = at * ab;\n vec3 d = vec3(ab * ToH, at * BoH, a2 * NoH);\n float x = a2 / dot(d, d);\n return a2 * (x * x) / PI;\n}\n\nvec3 anisotropicLobe(\n const vec4 precomputeGGX,\n const vec3 normal,\n const vec3 eyeVector,\n\n const vec3 eyeLightDir,\n const vec3 specular,\n const float NoL,\n const float f90,\n\n const in vec3 anisotropicT,\n const in vec3 anisotropicB,\n const in float anisotropy) {\n\n vec3 H = normalize(eyeVector + eyeLightDir);\n float NoH = saturate(dot(normal, H));\n float NoV = saturate(dot(normal, eyeVector));\n float VoH = saturate(dot(eyeLightDir, H));\n\n float ToV = dot(anisotropicT, eyeVector);\n float BoV = dot(anisotropicB, eyeVector);\n float ToL = dot(anisotropicT, eyeLightDir);\n float BoL = dot(anisotropicB, eyeLightDir);\n float ToH = dot(anisotropicT, H);\n float BoH = dot(anisotropicB, H);\n\n // slide 26, Disney 2012, "Physically Based Shading at Disney"\n // https://blog.selfshadow.com/publications/s2012-shading-course/burley/s2012_pbs_disney_brdf_notes_v3.pdf\n float aspect = sqrt(1.0 - abs(anisotropy) * 0.9);\n if (anisotropy > 0.0) aspect = 1.0 / aspect;\n float at = precomputeGGX.x * aspect;\n float ab = precomputeGGX.x / aspect;\n\n // slide 24, Kulla 2017, "Revisiting Physically Based Shading at Imageworks"\n // https://blog.selfshadow.com/publications/s2017-shading-course/imageworks/s2017_pbs_imageworks_slides_v2.pdf\n // float at = max(0.002025, precomputeGGX.x * (1.0 + anisotropy));\n // float ab = max(0.002025, precomputeGGX.x * (1.0 - anisotropy));\n\n // specular anisotropic BRDF\n float D = D_GGX_Anisotropic(at, ab, ToH, BoH, NoH);\n float V = V_SmithGGXCorrelated_Anisotropic(at, ab, ToV, BoV, ToL, BoL, NoV, NoL);\n vec3 F = F_Schlick(specular, f90, VoH);\n\n return (D * V * PI) * F;\n}\n\nvoid computeLightLambertGGXAnisotropy(\n const in vec3 normal,\n const in vec3 eyeVector,\n const in float NoL,\n const in vec4 precomputeGGX,\n\n const in vec3 diffuse,\n const in vec3 specular,\n\n const in float attenuation,\n const in vec3 lightColor,\n const in vec3 eyeLightDir,\n const in float f90,\n\n const in vec3 anisotropicT,\n const in vec3 anisotropicB,\n const in float anisotropy,\n\n out vec3 diffuseOut,\n out vec3 specularOut,\n out bool lighted) {\n\n lighted = NoL > 0.0;\n if (lighted == false) {\n specularOut = diffuseOut = vec3(0.0);\n return;\n }\n\n vec3 colorAttenuate = attenuation * NoL * lightColor;\n specularOut = colorAttenuate * anisotropicLobe(precomputeGGX, normal, eyeVector, eyeLightDir, specular, NoL, f90, anisotropicT, anisotropicB, anisotropy);\n diffuseOut = colorAttenuate * diffuse;\n}\n',"utils/lightsSSS.glsl":'#pragma include "utils/common.glsl"\n#pragma include "utils/lightCommon.glsl"\n\n///////////////////////////\n/// SUBSURFACE TRANSLUCENCY\n///////////////////////////\nvec3 computeLightSSS(\n const in float dotNL,\n const in float attenuation,\n const in float thicknessFactor,\n const in vec3 translucencyColor,\n const in float translucencyFactor,\n const in float shadowDistance,\n const in vec3 diffuse,\n const in vec3 lightColor) {\n\n // http://blog.stevemcauley.com/2011/12/03/energy-conserving-wrapped-diffuse/\n // float scatter = 0.5;\n // float wrap = saturate((dotNL + scatter) / ((1.0 + scatter) * (1.0 + scatter)));\n\n // https://github.com/iryoku/separable-sss/blob/master/SeparableSSS.h#L362\n float wrap = saturate(0.3 - dotNL);\n float thickness = max(0.0, shadowDistance / max(0.001, thicknessFactor));\n\n // http://www.crytek.com/download/2014_03_25_CRYENGINE_GDC_Schultz.pdf\n // skin approximation vec3(0.98, 0.3, 0.2)\n float finalAttenuation = translucencyFactor * attenuation * wrap;\n return finalAttenuation * lightColor * diffuse * exp(-thickness / max(translucencyColor, vec3(0.001))); \n}\n',"utils/skinning.glsl":"//////////////////////////////\n// UN-OPTIMIZED VERSION (WITH IF)\n//////////////////////////////\n\n// //http://http.developer.nvidia.com/GPUGems/gpugems_ch04.html\n// mat4 getMat4FromVec4(const int index, inout mat4 myMat) {\n// // We have to use a global variable because we can't access dynamically\n// // matrix is transpose so we should do vec * matrix\n// myMat[0] = uBones[index];\n// myMat[1] = uBones[index + 1];\n// myMat[2] = uBones[index + 2];\n// return myMat;\n// }\n\n// mat4 skinning( const in vec4 weights, const in vec4 bonesIndex ) {\n// ivec4 idx = 3 * ivec4(bonesIndex);\n// mat4 tmpMat = mat4(1.0);\n// mat4 outMat = mat4(0.0);\n\n// // we handle negative weights\n// if(all(equal(weights, vec4(0.0)))) return tmpMat;\n\n// if(weights.x != 0.0) outMat += weights.x * getMat4FromVec4(idx.x, tmpMat);\n// if(weights.y != 0.0) outMat += weights.y * getMat4FromVec4(idx.y, tmpMat);\n// if(weights.z != 0.0) outMat += weights.z * getMat4FromVec4(idx.z, tmpMat);\n// if(weights.w != 0.0) outMat += weights.w * getMat4FromVec4(idx.w, tmpMat);\n// return outMat;\n// }\n\n//////////////////////////////\n// UN-OPTIMIZED VERSION (NO IF)\n//////////////////////////////\n\nmat4 skinning(const in vec4 weights, const in vec4 bonesIndex) {\n ivec4 idx = 3 * ivec4(bonesIndex);\n mat4 tmpMat = mat4(1.0);\n\n // if sum is 0, return identity\n vec4 absWeights = -abs(weights);\n mat4 outMat = step(0.0, absWeights.x + absWeights.y + absWeights.z + absWeights.w) * tmpMat;\n\n // we handle negative weights\n // outMat[3][3] += weights.x + weights.y + weights.z + weights.w;\n\n tmpMat[0] = uBones[idx.x];\n tmpMat[1] = uBones[idx.x + 1];\n tmpMat[2] = uBones[idx.x + 2];\n outMat += weights.x * tmpMat;\n\n tmpMat[0] = uBones[idx.y];\n tmpMat[1] = uBones[idx.y + 1];\n tmpMat[2] = uBones[idx.y + 2];\n outMat += weights.y * tmpMat;\n\n tmpMat[0] = uBones[idx.z];\n tmpMat[1] = uBones[idx.z + 1];\n tmpMat[2] = uBones[idx.z + 2];\n outMat += weights.z * tmpMat;\n\n tmpMat[0] = uBones[idx.w];\n tmpMat[1] = uBones[idx.w + 1];\n tmpMat[2] = uBones[idx.w + 2];\n outMat += weights.w * tmpMat;\n\n return outMat;\n}\n","utils/morphing.glsl":"vec3 morphing(const in vec4 weights, const in vec3 vertex, const in vec3 target0) {\n return mix(vertex, target0, weights[0]);\n}\n\nvec3 morphing(const in vec4 weights, const in vec3 vertex, const in vec3 target0, const in vec3 target1) {\n vec3 vecOut = vertex * (1.0 - ( weights[0] + weights[1]));\n vecOut += target0 * weights[0];\n vecOut += target1 * weights[1];\n return vecOut;\n}\n\nvec3 morphing(const in vec4 weights, const in vec3 vertex, const in vec3 target0, const in vec3 target1, const in vec3 target2) {\n vec3 vecOut = vertex * (1.0 - ( weights[0] + weights[1] + weights[2]));\n vecOut += target0 * weights[0];\n vecOut += target1 * weights[1];\n vecOut += target2 * weights[2];\n return vecOut;\n}\n\nvec3 morphing(const in vec4 weights,const in vec3 vertex,const in vec3 target0,const in vec3 target1,const in vec3 target2,const in vec3 target3) {\n vec3 vecOut = vertex * (1.0 - ( weights[0] + weights[1] + weights[2] + weights[3]));\n vecOut += target0 * weights[0];\n vecOut += target1 * weights[1];\n vecOut += target2 * weights[2];\n vecOut += target3 * weights[3];\n return vecOut;\n}\n","utils/environment.glsl":'uniform float uEnvironmentExposure;\r\nuniform mat3 uEnvironmentTransform;\r\nuniform vec2 uTextureEnvironmentSpecularPBRLodRange;\r\nuniform vec2 uTextureEnvironmentSpecularPBRTextureSize;\r\nuniform vec3 uDiffuseSPH[9];\r\n\r\n#ifdef HAS_ENVIRONMENT_BRDF\r\nuniform sampler2D sIntegrateBRDF;\r\n#endif\r\n\r\nvec3 computeDiffuseSPH(const in vec3 normal) {\r\n vec3 n = uEnvironmentTransform * normal;\r\n // https://github.com/cedricpinson/envtools/blob/master/Cubemap.cpp#L523\r\n vec3 result =\r\n uDiffuseSPH[0] +\r\n uDiffuseSPH[1] * n.y +\r\n uDiffuseSPH[2] * n.z +\r\n uDiffuseSPH[3] * n.x +\r\n uDiffuseSPH[4] * n.y * n.x +\r\n uDiffuseSPH[5] * n.y * n.z +\r\n uDiffuseSPH[6] * (3.0 * n.z * n.z - 1.0) +\r\n uDiffuseSPH[7] * (n.z * n.x) +\r\n uDiffuseSPH[8] * (n.x * n.x - n.y * n.y);\r\n return max(result, vec3(0.0));\r\n}\r\n\r\n#ifndef HAS_LEGACY_CLASSIC\r\n\r\n// https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Shaders/Private/BRDF.ush#L202\r\nvec3 integrateBRDF(const in vec3 specular, const in float roughness, const in float NoV, const in float f90) {\r\n#ifdef HAS_ENVIRONMENT_BRDF\r\n vec4 rgba = texture2D(sIntegrateBRDF, vec2(NoV, roughness));\r\n float b = (rgba[3] * 65280.0 + rgba[2] * 255.0);\r\n float a = (rgba[1] * 65280.0 + rgba[0] * 255.0);\r\n const float div = 1.0 / 65535.0;\r\n return (specular * a + b * f90) * div;\r\n#else\r\n // https://www.unrealengine.com/blog/physically-based-shading-on-mobile\r\n // TODO should we use somehow specular f0 ?\r\n const vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\r\n const vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);\r\n vec4 r = roughness * c0 + c1;\r\n float a004 = min(r.x * r.x, exp2(-9.28 * NoV)) * r.x + r.y;\r\n vec2 AB = vec2(-1.04, 1.04) * a004 + r.zw;\r\n return specular * AB.x + AB.y * f90;\r\n#endif\r\n}\r\n\r\n// Frostbite, Lagarde paper p67\r\n// http://www.frostbite.com/wp-content/uploads/2014/11/course_notes_moving_frostbite_to_pbr.pdf\r\nfloat linRoughnessToMipmap(const in float roughnessLinear) {\r\n return sqrt(roughnessLinear);\r\n}\r\n\r\n#ifdef ENV_CUBEMAP\r\nuniform samplerCube sSpecularPBR;\r\n#pragma include "utils/cubemapLod.glsl"\r\n#endif\r\n\r\n#ifdef ENV_PANORAMA\r\nuniform sampler2D sSpecularPBR;\r\n#pragma include "utils/panoramaLod.glsl"\r\n#endif\r\n\r\nvec3 getSpecularDominantDir(const in vec3 N, const in vec3 R, const in float realRoughness) {\r\n float smoothness = 1.0 - realRoughness;\r\n float lerpFactor = smoothness * (sqrt(smoothness) + realRoughness);\r\n // The result is not normalized as we fetch in a cubemap\r\n return mix(N, R, lerpFactor);\r\n}\r\n\r\nvec3 getPrefilteredEnvMapColor(const in vec3 normal, const in vec3 eyeVector, const in float roughness, const in vec3 frontNormal) {\r\n vec3 R = reflect(-eyeVector, normal);\r\n\r\n // specular dominant dir is using the bentNormal in the anisotropy scenario\r\n // if we want to get rid of the dominant dir but still have a matching result with anisotropy=0 we could try:\r\n // R = mix(getSpecularDominantDir(normal, R, roughness), R, anisotropy);\r\n R = getSpecularDominantDir(normal, R, roughness);\r\n\r\n#ifdef ENV_CUBEMAP\r\n vec3 prefilteredColor = prefilterEnvMapCube(roughness, uEnvironmentTransform * R);\r\n#else\r\n vec3 prefilteredColor = prefilterEnvMapPanorama(roughness, uEnvironmentTransform * R);\r\n#endif\r\n\r\n // http://marmosetco.tumblr.com/post/81245981087\r\n // marmoset uses 1.3, we force it to 1.0\r\n float factor = clamp(1.0 + dot(R, frontNormal), 0.0, 1.0);\r\n prefilteredColor *= factor * factor;\r\n return prefilteredColor;\r\n}\r\n\r\nvec3 computeIBLSpecularUE4(const in vec3 normal, const in vec3 eyeVector, const in float roughness, const in vec3 specular, const in vec3 frontNormal, const in float f90) {\r\n float NoV = dot(normal, eyeVector);\r\n return getPrefilteredEnvMapColor(normal, eyeVector, roughness, frontNormal) * integrateBRDF(specular, roughness, NoV, f90);\r\n}\r\n\r\n#endif\r\n',"utils/panoramaLod.glsl":'#pragma include "utils/functions.glsl"\r\n\r\nvec2 computeUVForMipmap(const in float level, const in vec2 uv) {\r\n // width for level\r\n float widthForLevel = exp2(uTextureEnvironmentSpecularPBRLodRange.x - level);\r\n\r\n // the height locally for the level in pixel\r\n // to opimitize a bit we scale down the v by two in the inputs uv\r\n float heightForLevel = widthForLevel * 0.5;\r\n\r\n // compact version\r\n float texelSize = 1.0 / uTextureEnvironmentSpecularPBRTextureSize.x;\r\n vec2 uvSpaceLocal = vec2(1.0) + uv * vec2(widthForLevel - 2.0, heightForLevel - 2.0);\r\n uvSpaceLocal.y += uTextureEnvironmentSpecularPBRTextureSize.x - widthForLevel;\r\n return uvSpaceLocal * texelSize;\r\n}\r\n\r\n//for y up\r\nvec2 normalToPanoramaUVY(const in vec3 dir) {\r\n float n = length(dir.xz);\r\n\r\n // to avoid bleeding the max(-1.0,dir.x / n) is needed\r\n vec2 pos = vec2((n > 0.0000001) ? max(-1.0, dir.x / n) : 0.0, dir.y);\r\n\r\n // fix edge bleeding\r\n if (pos.x > 0.0) pos.x = min(0.999999, pos.x);\r\n\r\n pos = acos(pos) * 0.3183098861837907; // inv_pi\r\n\r\n pos.x = (dir.z > 0.0) ? pos.x * 0.5 : 1.0 - (pos.x * 0.5);\r\n\r\n // shift u to center the panorama to -z\r\n pos.x = mod(pos.x - 0.25 + 1.0, 1.0);\r\n pos.y = 1.0 - pos.y;\r\n return pos;\r\n}\r\n\r\nvec3 prefilterEnvMapPanorama(const in float rLinear, const in vec3 R) {\r\n float lod = min(uTextureEnvironmentSpecularPBRLodRange.x, linRoughnessToMipmap(rLinear) * uTextureEnvironmentSpecularPBRLodRange.y);\r\n vec2 uvBase = normalToPanoramaUVY(R);\r\n\r\n // // we scale down v here because it avoid to do twice in sub functions\r\n // uvBase.y *= 0.5;\r\n\r\n vec3 texel0 = LUVToRGB(texture2D(sSpecularPBR, computeUVForMipmap(floor(lod), uvBase)));\r\n vec3 texel1 = LUVToRGB(texture2D(sSpecularPBR, computeUVForMipmap(ceil(lod), uvBase)));\r\n\r\n return mix(texel0, texel1, fract(lod));\r\n}\r\n',"utils/cubemapLod.glsl":'#pragma include "utils/functions.glsl"\r\n\r\n#extension GL_EXT_shader_texture_lod : enable\r\nvec3 prefilterEnvMapCube(const in float rLinear, const in vec3 R) {\r\n vec3 dir = R;\r\n float lod = min(uTextureEnvironmentSpecularPBRLodRange.x, linRoughnessToMipmap(rLinear) * uTextureEnvironmentSpecularPBRLodRange.y);\r\n\r\n // http://seblagarde.wordpress.com/2012/06/10/amd-cubemapgen-for-physically-based-rendering/\r\n float scale = 1.0 - exp2(lod) / uTextureEnvironmentSpecularPBRTextureSize.x;\r\n vec3 absDir = abs(dir);\r\n float M = max(max(absDir.x, absDir.y), absDir.z);\r\n\r\n if (absDir.x != M) dir.x *= scale;\r\n if (absDir.y != M) dir.y *= scale;\r\n if (absDir.z != M) dir.z *= scale;\r\n\r\n return LUVToRGB(textureCubeLodEXT(sSpecularPBR, dir, lod));\r\n}\r\n',"utils/cubemap.glsl":'#pragma include "utils/functions.glsl"\n\n// used by background.frag\nvec3 textureCubeFixed(const in samplerCube tex, const in vec3 R, const in float size) {\n vec3 dir = R;\n float scale = 1.0 - 1.0 / size;\n // http://seblagarde.wordpress.com/2012/06/10/amd-cubemapgen-for-physically-based-rendering/\n vec3 absDir = abs(dir);\n float M = max(max(absDir.x, absDir.y), absDir.z);\n\n if (absDir.x != M) dir.x *= scale;\n if (absDir.y != M) dir.y *= scale;\n if (absDir.z != M) dir.z *= scale;\n\n return LUVToRGB(textureCube(tex, dir));\n}\n',"utils/rand.glsl":"\n// white vs interleaved vs blue noise\n// https://blog.demofox.org/2017/10/31/animating-noise-for-integration-over-time/\n\n// to test in a shadertoy\n// https://www.shadertoy.com/view/lsdfD4\n\n// https://www.shadertoy.com/view/4djSRW\n// most combinations are possible : in[1,2,3] -> out[1,2,3]\n#define INT_SCALE1 .1031\nfloat pseudoRandom(const in vec2 fragCoord) {\n vec3 p3 = fract(vec3(fragCoord.xyx) * INT_SCALE1);\n p3 += dot(p3, p3.yzx + 19.19);\n return fract((p3.x + p3.y) * p3.z);\n}\n\n// https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Shaders/Private/Random.ush#L27\nfloat interleavedGradientNoise(const in vec2 fragCoord, const in float frameMod) {\n vec3 magic = vec3(0.06711056, 0.00583715, 52.9829189);\n return fract(magic.z * fract(dot(fragCoord.xy + frameMod * vec2(47.0, 17.0) * 0.695, magic.xy)));\n}\n\n// https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Shaders/Private/MaterialTemplate.ush#L1863\n// we slighty change it by multiplying by 1.2 (to match with other noise), otherwise the range seems to be between [0 - 0.83]\nfloat ditheringNoise(const in vec2 fragCoord, const in float frameMod) {\n // float fm = mod(frameMod, 2.0) == 0.0 ? 1.0 : -1.0;\n float fm = frameMod;\n float dither5 = fract((fragCoord.x + fragCoord.y * 2.0 - 1.5 + fm) / 5.0);\n float noise = fract(dot(vec2(171.0, 231.0) / 71.0, fragCoord.xy));\n return (dither5 * 5.0 + noise) * (1.2 / 6.0);\n}\n\nvoid ditheringMaskingDiscard(\n const in vec4 fragCoord,\n const in int dithering,\n const in float alpha,\n const in float factor,\n\n const in float thinLayer,\n\n const in float frameMod,\n const in vec2 nearFar,\n\n const in vec4 halton) {\n\n float rnd;\n\n if (thinLayer == 0.0) {\n float linZ = (1.0 / fragCoord.w - nearFar.x) / (nearFar.y - nearFar.x);\n float sliceZ = floor(linZ * 500.0) / 500.0;\n rnd = interleavedGradientNoise(fragCoord.xy + sliceZ, frameMod);\n } else {\n rnd = pseudoRandom(fragCoord.xy + halton.xy * 1000.0 + fragCoord.z * (abs(halton.z) == 2.0 ? 1000.0 : 1.0));\n }\n\n if ((alpha * factor) < rnd) discard;\n}\n","utils/curvature.glsl":"#extension GL_OES_standard_derivatives : enable\n\nuniform float uMatcapCurvature;\nuniform mat4 uProjectionMatrix;\n\n// http://madebyevan.com/shaders/curvature/\nfloat getCurvature(const in vec3 normal) {\n#ifndef GL_OES_standard_derivatives\n return 1.0;\n#else\n if (uMatcapCurvature == 0.0) return 1.0;\n\n // Compute curvature\n vec3 dx = dFdx(normal);\n vec3 dy = dFdy(normal);\n vec3 xneg = normal - dx;\n vec3 xpos = normal + dx;\n vec3 yneg = normal - dy;\n vec3 ypos = normal + dy;\n\n float factor = uMatcapCurvature / (length(vViewVertex.xyz) * atan(-1.0 / uProjectionMatrix[2][3]));\n float curvature = (cross(xneg, xpos).y - cross(yneg, ypos).x) * factor;\n\n float curvDirt = clamp(-curvature * 1.5, 0.0, 1.0);\n float curvEdge = clamp(curvature * 2.5, 0.0, 1.0);\n\n float factorDirt = mix(1.0, 0.3, curvDirt);\n float factorEdge = 2.0;\n\n return mix(factorDirt, factorEdge, curvEdge);\n#endif\n}\n","utils/refraction.glsl":'#pragma include "utils/encodeDecode.glsl"\n#pragma include "utils/decodeDepth.glsl"\n\n// manual refract mostly to re-use dot(I, N)\nvec3 batchRefract(const in vec3 I, const in vec3 N , const in float eta, const in float dotNI) {\n float k = 1.0 - eta * eta * (1.0 - dotNI * dotNI);\n return (k < 0.0) ? vec3(0.0) : eta * I - (eta * dotNI + sqrt(k)) * N;\n}\n\nuniform float uOpacityIOR;\nuniform vec3 uOpacityRefractionColor;\n\nuniform float uBoxRadius;\nuniform int uIsVr;\nuniform sampler2D uTextureToBeRefracted;\nuniform vec2 uTextureToBeRefractedSize;\nuniform mat4 uProjectionMatrix;\nuniform vec4 uPreviousHalton;\nuniform vec2 uPreviousGlobalTexRatio;\nuniform vec2 uPreviousGlobalTexSize;\nuniform vec2 uGlobalTexSize;\n\n#ifndef HAS_REFRACTION_NORMAL_OFFSET\n uniform sampler2D uTextureMipmapDepth;\n uniform vec2 uNearFar;\n uniform vec2 uGlobalTexRatio;\n uniform mat4 uPreviousProjection;\n uniform vec4 uTaaCornersCSLeft[2];\n#endif\n\nvec3 refraction(\n const in float roughness,\n const in vec3 normalSurface,\n\n#ifdef HAS_REFRACTION_NORMAL_OFFSET\n const in vec3 normalVertex\n#else\n const in vec3 eyeVector\n#endif\n)\n\n{\n\n#ifdef HAS_REFRACTION_NORMAL_OFFSET\n // no reprojection and no depth compare for the normal offset version (not worth it as for the moment)\n vec2 uv = gl_FragCoord.xy / uGlobalTexSize.xy + (normalVertex.xy - normalSurface.xy) * (uOpacityIOR - 1.0);\n#else\n float dotNI = -dot(eyeVector, normalSurface);\n\n // compute UV at distortion point\n // https://en.wikibooks.org/wiki/GLSL_Programming/Unity/Curved_Glass\n vec3 pos = vViewVertex.xyz + uBoxRadius * batchRefract(-eyeVector, normalSurface, 1.0 / uOpacityIOR, dotNI);\n pos = (uProjectionMatrix * vec4(pos, 1.0)).xyw; // we discard z and only keep the perspective divide\n vec2 uv = 0.5 + 0.5 * pos.xy / pos.z;\n\n if (uIsVr == 1) {\n // no reprojection in vr (would require another uTaaCornersCSRight uniform)\n uv.x *= 0.5;\n if (gl_FragCoord.x > uGlobalTexSize.x * 0.5) uv.x += 0.5;\n } else {\n // we discard refraction on pixels that are in front of refracted surface by\n // comparing current pixel depth with depth at refraction point\n // if we are on the background we take the depth of the current position\n #ifdef DEPTH_MIPMAP\n vec3 pack = texture2D(uTextureMipmapDepth, uPreviousGlobalTexRatio * vec2(uv.x, (1.0 - uv.y) * 0.5)).xyz;\n float depthRefracted = pack.x == 1.0 ? (-vViewVertex.z - uNearFar.x) / (uNearFar.y - uNearFar.x) : decode24(pack);\n #else\n vec4 pack = texture2D(uTextureMipmapDepth, uGlobalTexRatio * uv);\n float depthRefracted = pack.x == 1.0 ? (-vViewVertex.z - uNearFar.x) / (uNearFar.y - uNearFar.x) : decodeDepth(pack);\n #endif\n\n // compute view space refracted position from depth\n vec4 AB = mix(uTaaCornersCSLeft[0], uTaaCornersCSLeft[1], uv.x);\n pos = vec3(mix(AB.xy, AB.zw, uv.y), 1.0) * -(uNearFar.x + (uNearFar.y - uNearFar.x) * depthRefracted);\n\n // pos is computed with last frame projection which is not entirely correct\n if (dot(pos.xyz - vViewVertex.xyz, normalSurface) > 0.00001) {\n uv = gl_FragCoord.xy / uGlobalTexSize.xy;\n } else {\n // reproject view vector\n pos = (uPreviousProjection * vec4(pos, 1.0)).xyw;\n uv.xy = 0.5 + 0.5 * pos.xy / pos.z;\n }\n }\n#endif\n\n // unjitter (so that the refraction is stable when doing supersampling)\n uv -= 0.5 * uPreviousHalton.xy / uPreviousGlobalTexSize.xy;\n\n // repeat mirror for out of screen fetches (it\'s better than a sudden cut)\n // we can\'t simply use MIRRORED_REPEAT because of manual mipmap\n uv = abs(uv); \n if (uv.x > 1.0) uv.x -= 2.0 * (uv.x - 1.0);\n if (uv.y > 1.0) uv.y -= 2.0 * (uv.y - 1.0);\n\n // adjusts roughness-to-mipmap depending of distance from surface (aka: consistent blurring even when we unzoom)\n float adjustRoughness = clamp(uProjectionMatrix[1][1] / 12.0 * uBoxRadius / -vViewVertex.z, 0.0, 1.0);\n float adjustFactor = 0.05; // the higher it is, the sharper it will be when we are far away\n adjustRoughness = (1.0 + adjustFactor) * adjustRoughness / (adjustFactor + adjustRoughness);\n\n // roughness support\n float maxLod = 7.0;\n float lodLevel = maxLod * min(0.99, roughness * adjustRoughness); // same as in pbr\n\n float lowerLevel = floor(lodLevel);\n float higherLevel = min(maxLod, lowerLevel + 1.0);\n float lerpFactor = lodLevel - lowerLevel; // [0,1]\n\n // see packMipmapRefraction.glsl\n // mipmap packing of refracted texture (the packing is not optimal and is a bit naive):\n // level0: (1-uv)/2\n // level1: (3-uv)/4\n // level2: (7-uv)/8\n // level3: (15-uv)/16\n // level4: (31-uv)/32\n // etc...\n\n float powLevel = pow(2.0, higherLevel);\n\n // border pixel issue with bilinear...\n vec2 pixelSize = 2.0 * powLevel / uTextureToBeRefractedSize;\n uv = max(pixelSize, min(1.0 - pixelSize, uv));\n\n // lower uv\n vec2 uvLower = vec2(2.0 * uv.x, powLevel - 1.0 - uv.y) * uPreviousGlobalTexRatio.xy / powLevel;\n\n // higher uv\n powLevel *= 2.0;\n vec2 uvHigher = vec2(2.0 * uv.x, powLevel - 1.0 - uv.y) * uPreviousGlobalTexRatio.xy / powLevel;\n\n // manual lerp, mixing rgbm colors exhibits visible seams\n vec3 fetch = mix(decodeRGBM(texture2D(uTextureToBeRefracted, uvLower), 7.0), decodeRGBM(texture2D(uTextureToBeRefracted, uvHigher), 7.0), lerpFactor);\n\n#ifndef HAS_REFRACTION_NORMAL_OFFSET\n // reduce bright fresnel effect, it darkens/accentuates the edges in some cases (very rough surface)\n fetch.rgb -= fetch.rgb * pow(clamp(1.0 + dotNI, 0.0, 1.0), 4.0);\n#endif\n\n return uOpacityRefractionColor * fetch.rgb;\n}\n',"utils/clearCoat.glsl":'#pragma include "utils/lightsPBR.glsl"\n\n//https://en.wikipedia.org/wiki/Beer%E2%80%93Lambert_law for translucent material absorbtion\nvec3 beerLambert(const float NoV, const float NoL, const vec3 tint, const float d) {\n // exp(tint * -distance * density)\n return exp(tint * -(d * ((NoL + NoV) / max(NoL * NoV, 1e-3))));\n}\n\nvec3 getClearCoatAbsorbtion(const in float NoV, const in float NoL, const in float clearCoatFactor) {\n return mix(vec3(1.0), beerLambert(NoV, NoL, uClearCoatTint, uClearCoatThickness), clearCoatFactor);\n}\n\n// compute Light PBR for clearCoat layer\nvoid computeLightLambertGGXClearCoat(\n const in float ccNoV,\n const in vec3 normal,\n const in vec3 eyeVector,\n const in float dotNL,\n const in vec4 precomputeGGX,\n\n const in float attenuation,\n const in vec3 lightColor,\n const in vec3 eyeLightDir,\n\n const in float clearCoatFactor,\n\n out vec3 clearCoatSpecular,\n out vec3 clearCoatAttenuation) {\n\n if (dotNL <= 0.0) {\n clearCoatSpecular = vec3(0.0);\n clearCoatAttenuation = vec3(0.0);\n return;\n }\n\n float ccNoL = saturate(dot(normal, -refract(eyeLightDir, normal, 1.0 / uClearCoatIor)));\n vec3 clearCoatAbsorption = getClearCoatAbsorbtion(ccNoV, ccNoL, clearCoatFactor);\n\n vec3 H = normalize(eyeVector + eyeLightDir);\n float NoH = saturate(dot(normal, H));\n float VoH = saturate(dot(eyeLightDir, H));\n\n // distribution / visibility / fresnel\n float D = D_GGX(precomputeGGX, NoH);\n float V = V_SmithCorrelated(precomputeGGX, ccNoL);\n float F = F_Schlick(uClearCoatF0, 1.0, VoH);\n\n clearCoatSpecular = (attenuation * dotNL * clearCoatFactor * D * V * PI * F) * lightColor;\n clearCoatAttenuation = (1.0 - F * clearCoatFactor) * clearCoatAbsorption;\n}\n',"utils/ssr.glsl":'#pragma include "utils/decodeDepth.glsl"\n#pragma include "utils/rand.glsl"\n\n#define SSR_STEPS 8\n\n#define LOD_COLOR 7.0\n#define LOD_DEPTH 5.0\n\nuniform int uDrawOpaque;\nuniform float uFrameModTaaSS;\nuniform float uQuality;\nuniform float uSsrFactor;\n\nuniform sampler2D uTextureToBeRefracted;\nuniform sampler2D uTextureMipmapDepth;\n\nuniform vec2 uTextureToBeRefractedSize;\nuniform vec2 uPreviousGlobalTexRatio;\nuniform vec2 uPreviousGlobalTexSize;\nuniform vec2 uNearFar;\nuniform vec2 uGlobalTexRatio;\nuniform vec4 uTaaCornersCSLeft[2];\n\nuniform mat4 uProjectionMatrix;\nuniform mat4 uReprojectViewProj;\nuniform mat4 uPreviousViewInvView;\nuniform mat4 uPreviousProjection; // DEPTH_MIPMAP\n\nvec3 computeLodNearestPixelSizePowLevel(const in float lodLevelIn, const in float maxLod, const in vec2 size) {\n float lodLevel = min(maxLod - 0.01, lodLevelIn);\n float lowerLevel = floor(lodLevel);\n float higherLevel = min(maxLod, lowerLevel + 1.0);\n\n float powLevel = pow(2.0, higherLevel);\n vec2 pixelSize = 2.0 * powLevel / size;\n\n if (lodLevel - lowerLevel > 0.5) powLevel *= 2.0;\n return vec3(pixelSize, powLevel);\n}\n\n// lerping between 2 mipmap is too costly (with no notable quality gain in the end)\nvec2 computeLodUVNearest(const in vec2 uvIn, const in vec3 pixelSizePowLevel) {\n // border pixel issue with bilinear...\n vec2 uv = max(pixelSizePowLevel.xy, min(1.0 - pixelSizePowLevel.xy, uvIn));\n return vec2(2.0 * uv.x, pixelSizePowLevel.z - 1.0 - uv.y) / pixelSizePowLevel.z;\n}\n\nfloat fetchDepthLod(const in vec2 uv, const in vec3 pixelSizePowLevel) {\n#ifdef DEPTH_MIPMAP\n vec2 uvNearest = computeLodUVNearest(uv, pixelSizePowLevel);\n float depth = decodeDepth(texture2D(uTextureMipmapDepth, uvNearest * uPreviousGlobalTexRatio));\n#else\n float depth = decodeDepth(texture2D(uTextureMipmapDepth, uv * uGlobalTexRatio));\n#endif\n\n if (depth >= 1.0) return -uNearFar.y * 100.0; // very far so it won\'t reflect background\n return -uNearFar.x - depth * (uNearFar.y - uNearFar.x);\n}\n\nvec4 fetchDepthLod(const in vec4 uv0, const in vec4 uv1, const in vec3 pixelSizePowLevel) {\n vec4 result = vec4(0.0);\n result.x = fetchDepthLod(uv0.xy, pixelSizePowLevel);\n result.y = fetchDepthLod(uv0.zw, pixelSizePowLevel);\n result.z = fetchDepthLod(uv1.xy, pixelSizePowLevel);\n result.w = fetchDepthLod(uv1.zw, pixelSizePowLevel);\n return result;\n}\n\nvec3 ssrViewToScreen(const in mat4 projection, const in vec3 viewVertex) {\n vec4 projected = projection * vec4(viewVertex, 1.0);\n return vec3(0.5 + 0.5 * projected.xy / projected.w, projected.w);\n}\n\nvec3 fetchColorLod(const in float level, const in vec2 uv) {\n vec3 pixelSizePowLevel = computeLodNearestPixelSizePowLevel(LOD_COLOR * level, LOD_COLOR, uPreviousGlobalTexSize); \n vec2 uvNearest = computeLodUVNearest(uv, pixelSizePowLevel);\n return decodeRGBM(texture2D(uTextureToBeRefracted, uvNearest * uPreviousGlobalTexRatio), 7.0);\n}\n\n// #define HASHSCALE1 .1031\n// #define HASHSCALE3 vec3(.1031, .1030, .0973)\n// #define HASHSCALE4 vec4(.1031, .1030, .0973, .1099)\n\n// vec2 hash23(vec3 p3)\n// {\n// p3 = fract(p3 * HASHSCALE3);\n// p3 += dot(p3, p3.yzx + 19.19);\n// return fract((p3.xx + p3.yz) * p3.zy);\n// }\n\n// https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Shaders/Private/ScreenSpaceReflections.usf#L143\n// https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Shaders/Private/MonteCarlo.ush#L169\nvec3 unrealImportanceSampling(const in float frameMod, const in vec3 tangentX, const in vec3 tangentY, const in vec3 tangentZ, const in vec3 eyeVector, const in float rough4) {\n vec2 E;\n\n // could be improved (visible patterns)\n E.x = interleavedGradientNoise(gl_FragCoord.yx, frameMod);\n E.y = fract(E.x * 52.9829189);\n // E = hash23(vec3(gl_FragCoord.xy + frameMod * 150.2420, frameMod * 100.0));\n\n // Reduces BRDF tail is noisy, we clamp it\n // https://www.slideshare.net/DICEStudio/stochastic-screenspace-reflections#p=67\n E.y = mix(E.y, 1.0, 0.7);\n\n float phi = 2.0 * 3.14159 * E.x;\n // float cosTheta = sqrt((1.0 - E.y) / (1.0 + (rough4 - 1.0) * E.y)); // ggx (long tail, more noisy)\n float cosTheta = pow(max(E.y, 0.000001), rough4 / (2.0 - rough4)); // blinn\n float sinTheta = sqrt(1.0 - cosTheta * cosTheta);\n\n vec3 h = vec3(sinTheta * cos(phi), sinTheta * sin(phi), cosTheta);\n h = h.x * tangentX + h.y * tangentY + h.z * tangentZ;\n return normalize((2.0 * dot(eyeVector, h)) * h - eyeVector);\n}\n\nfloat getStepOffset(const in float frameMod) {\n return (interleavedGradientNoise(gl_FragCoord.xy, frameMod) - 0.5);\n}\n\nvec3 computeRayDirUV(const in vec3 rayOriginUV, const in float rayLen, const in vec3 rayDirView) {\n#ifdef DEPTH_MIPMAP\n vec3 rayDirUV = ssrViewToScreen(uPreviousProjection, vViewVertex.xyz + rayDirView * rayLen);\n#else\n vec3 rayDirUV = ssrViewToScreen(uProjectionMatrix, vViewVertex.xyz + rayDirView * rayLen);\n#endif\n\n rayDirUV.z = 1.0 / rayDirUV.z;\n rayDirUV -= rayOriginUV;\n\n // clip the line to the viewport edges\n // https://github.com/godotengine/godot/blob/master/drivers/gles3/shaders/screen_space_reflection.glsl#L124\n float scaleMaxX = min(1.0, 0.99 * (1.0 - rayOriginUV.x) / max(1e-5, rayDirUV.x));\n float scaleMaxY = min(1.0, 0.99 * (1.0 - rayOriginUV.y) / max(1e-5, rayDirUV.y));\n float scaleMinX = min(1.0, 0.99 * rayOriginUV.x / max(1e-5, -rayDirUV.x));\n float scaleMinY = min(1.0, 0.99 * rayOriginUV.y / max(1e-5, -rayDirUV.y));\n return rayDirUV * min(scaleMaxX, scaleMaxY) * min(scaleMinX, scaleMinY);\n}\n\n#define SSR_RAY_FETCH(void) \\\nsampleUV = rayOriginUV + rayDirUV * diffSampleW.y; \\\ndepth = fetchDepthLod(sampleUV.xy, pixelSizePowLevel); \\\ndepthDiff = -1.0 / sampleUV.z - depth; \\\nhit = abs(depthDiff + depthTolerance) < depthTolerance; \\\ntimeLerp = clamp(diffSampleW.x / (diffSampleW.x - depthDiff), 0.0, 1.0); \\\nhitTime = hit ? (diffSampleW.y + timeLerp * invNumSteps - invNumSteps) : 1.0; \\\ndiffSampleW.z = min(diffSampleW.z, hitTime); \\\ndiffSampleW.x = depthDiff; \\\ndiffSampleW.y += invNumSteps; \\\n\n#define SSR_RAY_UNROLLED(void) \\\nSSR_RAY_FETCH() \\\nSSR_RAY_FETCH() \\\nSSR_RAY_FETCH() \\\nSSR_RAY_FETCH() \\\nSSR_RAY_FETCH() \\\nSSR_RAY_FETCH() \\\nSSR_RAY_FETCH() \\\nSSR_RAY_FETCH() \\\n\nvec4 rayTraceUnrealSimple(\n const in vec3 rayOriginUV,\n const in float rayLen,\n in float depthTolerance,\n const in vec3 rayDirView,\n\n const in float roughness,\n const in float frameMod) {\n\n vec3 pixelSizePowLevel = computeLodNearestPixelSizePowLevel(LOD_DEPTH * roughness, LOD_DEPTH, uTextureToBeRefractedSize); \n\n float invNumSteps = 1.0 / float(SSR_STEPS);\n if (uQuality > 1.0) invNumSteps /= 2.0;\n\n depthTolerance *= invNumSteps;\n\n vec3 rayDirUV = computeRayDirUV(rayOriginUV, rayLen, rayDirView);\n\n float sampleTime = getStepOffset(frameMod) * invNumSteps + invNumSteps;\n vec3 diffSampleW = vec3(0.0, sampleTime, 1.0);\n\n vec3 sampleUV;\n float depth, depthDiff, timeLerp, hitTime;\n bool hit;\n\n SSR_RAY_UNROLLED()\n if (uQuality > 1.0) { SSR_RAY_UNROLLED() }\n\n // alternative : ray refinement around the intersected cell\n // if (uQuality > 1.0) {\n // rayOriginUV = rayOriginUV + rayDirUV * diffSampleW.z - rayDirUV * invNumSteps * 0.5;\n // diffSampleW = vec3(0.0, sampleTime, 1.0);\n // rayDirUV *= invNumSteps;\n // depthTolerance *= invNumSteps;\n // SSR_RAY_UNROLLED()\n // }\n\n return vec4(rayOriginUV + rayDirUV * diffSampleW.z, 1.0 - diffSampleW.z);\n}\n\nvec4 fetchColorContribution(\n in vec4 resRay,\n const in float maskSsr,\n const in vec3 specularEnvironment,\n const in vec3 specularColor,\n const in float roughness) {\n\n // reprojection\n vec4 AB = mix(uTaaCornersCSLeft[0], uTaaCornersCSLeft[1], resRay.x);\n resRay.xyz = vec3(mix(AB.xy, AB.zw, resRay.y), 1.0) * -1.0 / resRay.z;\n resRay.xyz = (uReprojectViewProj * vec4(resRay.xyz, 1.0)).xyw;\n resRay.xy /= resRay.z;\n\n // fade edge of screen\n float maskEdge = clamp(6.0 - 6.0 * max(abs(resRay.x), abs(resRay.y)), 0.0, 1.0);\n\n resRay.xy = 0.5 + 0.5 * resRay.xy;\n\n vec3 fetchColor = specularColor * fetchColorLod(roughness * (1.0 - resRay.w), resRay.xy);\n\n // fade ray count\n // maskEdge *= resRay.w;\n\n return vec4(mix(specularEnvironment, fetchColor, maskSsr * maskEdge), 1.0);\n}\n\nvec3 ssr(const in vec3 specularEnvironment, const in vec3 specularColor, const in float roughness, const in vec3 normal, const in vec3 eyeVector) {\n\n#if (defined(HAS_OPACITY_BLEND_OR_ADDITIVE) || defined(HAS_OPACITY_REFRACTION)) && !defined(HAS_SSR_TRANSPARENT)\n // no ssr for transparent pxiels for now (mainly performance reason)\n if (uDrawOpaque == 0) return specularEnvironment;\n#endif\n\n vec4 result = vec4(0.0);\n\n // precompute importance sampling roughness^4\n float rough4 = roughness * roughness;\n rough4 = rough4 * rough4;\n\n // precompute importance sampling basis tangent\n vec3 upVector = abs(normal.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);\n vec3 tangentX = normalize(cross(upVector, normal));\n vec3 tangentY = cross(normal, tangentX);\n\n // fade ray that points toward camera\n float maskSsr = uSsrFactor * clamp(-4.0 * dot(eyeVector, normal) + 3.8, 0.0, 1.0);\n maskSsr *= clamp(4.7 - roughness * 5.0, 0.0, 1.0); // fade out ssr for high roughness values\n\n // compute ray uv origin\n vec3 rayOriginUV = ssrViewToScreen(uProjectionMatrix, vViewVertex.xyz);\n rayOriginUV.z = 1.0 / rayOriginUV.z;\n\n // direction of reflection\n vec3 rayDirView = unrealImportanceSampling(uFrameModTaaSS, tangentX, tangentY, normal, eyeVector, rough4);\n\n // if reflection is toward us, we cast [near, vertex], otherwise [vertex, far]\n float rayLen = mix(uNearFar.y + vViewVertex.z, -vViewVertex.z - uNearFar.x, rayDirView.z * 0.5 + 0.5);\n float depthTolerance = 0.5 * rayLen;\n\n // ray under the surface (normalmap or inverted normal)\n if (dot(rayDirView, normal) > 0.001 && maskSsr > 0.0) {\n vec4 resRay = rayTraceUnrealSimple(rayOriginUV, rayLen, depthTolerance, rayDirView, roughness, uFrameModTaaSS);\n if (resRay.w > 0.0) result += fetchColorContribution(resRay, maskSsr, specularEnvironment, specularColor, roughness);\n }\n\n // if (uQuality > 0.4) {\n // for (int i = 1; i < 4; ++i) {\n // float frameRay = frameMod + float(i) * 50.0;\n // rayDirView = unrealImportanceSampling(frameRay, tangentX, tangentY, normal, eyeVector, rough4);\n // rayLen = mix(uNearFar.y + vViewVertex.z, -vViewVertex.z - uNearFar.x, rayDirView.z * 0.5 + 0.5);\n // depthTolerance = 0.5 * rayLen;\n\n // if (dot(rayDirView, normal) > 0.001) {\n // vec4 resRay = rayTraceUnrealSimple(rayOriginUV, rayLen, depthTolerance, rayDirView, roughness, frameRay);\n // if (resRay.w > 0.0) result += fetchColorContribution(resRay, maskSsr, specularEnvironment, specularColor, roughness);\n // }\n // }\n // }\n\n return result.w > 0.0 ? result.rgb / result.w : specularEnvironment;\n}\n',"utils/material.glsl":'#define MIN_ROUGHNESS 0.045\n\n#pragma include "utils/functions.glsl"\n\n#ifdef HAS_OPACITY_REFRACTION\n float gRefractionRoughness; // global variable (simpler to handle in order to re-use rough/gloss fetch)\n#endif\n\n#ifdef HAS_VERTEX_COLOR\n varying vec4 vColor;\n\n vec3 getVertexColor() {\n return COLOR_CONVERT_VERTEX_COLOR(vColor.rgb);\n }\n#endif\n\n// METALNESS WORKFLOW\n#ifdef HAS_ALBEDOPBR\n uniform float uAlbedoPBRFactor;\n\n vec3 getMaterialAlbedo() {\n vec3 albedo;\n #ifdef SAMPLER_ALBEDOPBR\n albedo = uAlbedoPBRFactor * COLOR_CONVERT_ALBEDOPBR(texture2D(SAMPLER_ALBEDOPBR, UV_ALBEDOPBR).PACK_ALBEDOPBR);\n #else\n albedo = vec3(uAlbedoPBRFactor);\n #endif\n\n #ifdef HAS_VERTEX_COLOR\n albedo *= getVertexColor();\n #endif\n\n return albedo;\n }\n#endif\n\n#ifdef HAS_METALNESSPBR\n uniform float uMetalnessPBRFactor;\n\n float getMaterialMetalness() {\n #ifdef SAMPLER_METALNESSPBR\n return uMetalnessPBRFactor * COLOR_CONVERT_METALNESSPBR(texture2D(SAMPLER_METALNESSPBR, UV_METALNESSPBR).PACK_METALNESSPBR);\n #else\n return uMetalnessPBRFactor;\n #endif\n }\n#endif\n\n#ifdef HAS_SPECULARF0\n uniform float uSpecularF0Factor;\n\n float getMaterialF0() {\n #ifdef SAMPLER_SPECULARF0\n return uSpecularF0Factor * COLOR_CONVERT_SPECULARF0(texture2D(SAMPLER_SPECULARF0, UV_SPECULARF0).PACK_SPECULARF0);\n #else\n return uSpecularF0Factor;\n #endif\n }\n#endif\n\n// SPECULAR WORKFLOW\n#ifdef HAS_DIFFUSEPBR\n uniform float uDiffusePBRFactor;\n\n vec3 getMaterialDiffuse() {\n vec3 diffuse;\n #ifdef SAMPLER_DIFFUSEPBR\n diffuse = uDiffusePBRFactor * COLOR_CONVERT_DIFFUSEPBR(texture2D(SAMPLER_DIFFUSEPBR, UV_DIFFUSEPBR).PACK_DIFFUSEPBR);\n #else\n diffuse = vec3(uDiffusePBRFactor);\n #endif\n\n #ifdef HAS_VERTEX_COLOR\n diffuse *= getVertexColor();\n #endif\n\n return diffuse;\n }\n#endif\n\n#ifdef HAS_SPECULARPBR\n uniform float uSpecularPBRFactor;\n\n vec3 getMaterialSpecular() {\n #ifdef SAMPLER_SPECULARPBR\n return uSpecularPBRFactor * COLOR_CONVERT_SPECULARPBR(texture2D(SAMPLER_SPECULARPBR, UV_SPECULARPBR).PACK_SPECULARPBR);\n #else\n return vec3(uSpecularPBRFactor);\n #endif\n }\n#endif\n\n// MICROSURFACE\n#ifdef HAS_ROUGHNESSPBR\n uniform float uRoughnessPBRFactor;\n\n float getMaterialRoughness() {\n #ifdef SAMPLER_ROUGHNESSPBR\n float fetch = COLOR_CONVERT_ROUGHNESSPBR(texture2D(SAMPLER_ROUGHNESSPBR, UV_ROUGHNESSPBR).PACK_ROUGHNESSPBR);\n\n #ifdef HAS_REFRACTION_MICROSURFACE\n gRefractionRoughness *= fetch;\n #endif\n\n return uRoughnessPBRFactor * fetch;\n #else\n return uRoughnessPBRFactor;\n #endif\n }\n#endif\n\n#ifdef HAS_GLOSSINESSPBR\n uniform float uGlossinessPBRFactor;\n\n float getMaterialGlossiness() {\n #ifdef SAMPLER_GLOSSINESSPBR\n float fetch = COLOR_CONVERT_GLOSSINESSPBR(texture2D(SAMPLER_GLOSSINESSPBR, UV_GLOSSINESSPBR).PACK_GLOSSINESSPBR);\n\n #ifdef HAS_REFRACTION_MICROSURFACE\n gRefractionRoughness = mix(1.0 - fetch, 1.0, gRefractionRoughness);\n #endif\n\n return uGlossinessPBRFactor * fetch;\n #else\n return uGlossinessPBRFactor;\n #endif\n }\n#endif\n\n\n#ifdef HAS_EMITCOLOR\n uniform float uEmitColorFactor;\n uniform int uEmitMultiplicative;\n\n vec3 getMaterialEmitColor() {\n #ifdef SAMPLER_EMITCOLOR\n return uEmitColorFactor * COLOR_CONVERT_EMITCOLOR(texture2D(SAMPLER_EMITCOLOR, UV_EMITCOLOR).PACK_EMITCOLOR);\n #else\n return vec3(0.0);\n #endif\n }\n#endif\n\n#ifdef HAS_AOPBR\n uniform float uAOPBRFactor;\n uniform int uAOPBROccludeSpecular;\n\n float getMaterialAO() {\n return mix(1.0, COLOR_CONVERT_AOPBR(texture2D(SAMPLER_AOPBR, UV_AOPBR).PACK_AOPBR), uAOPBRFactor);\n }\n#endif\n\n#ifdef HAS_CAVITYPBR\n uniform float uCavityPBRFactor;\n\n float getMaterialCavity() {\n return mix(1.0, COLOR_CONVERT_CAVITYPBR(texture2D(SAMPLER_CAVITYPBR, UV_CAVITYPBR).PACK_CAVITYPBR), uCavityPBRFactor);\n }\n#endif\n\n#ifdef HAS_SUBSURFACETRANSLUCENCY\n uniform float uSubsurfaceTranslucencyFactor;\n uniform float uSubsurfaceTranslucencyThicknessFactor;\n uniform vec3 uSubsurfaceTranslucencyColor;\n\n float getMaterialTranslucency() {\n #ifdef SAMPLER_SUBSURFACETRANSLUCENCY\n return uSubsurfaceTranslucencyFactor * COLOR_CONVERT_SUBSURFACETRANSLUCENCY(texture2D(SAMPLER_SUBSURFACETRANSLUCENCY, UV_SUBSURFACETRANSLUCENCY).PACK_SUBSURFACETRANSLUCENCY);\n #else\n return uSubsurfaceTranslucencyFactor;\n #endif\n }\n#endif\n\n#ifdef HAS_NORMALMAP\n uniform float uNormalMapFactor;\n uniform int uNormalMapFlipY;\n\n vec3 getMaterialNormalMap() {\n vec3 nmap = COLOR_CONVERT_NORMALMAP(texture2D(SAMPLER_NORMALMAP, UV_NORMALMAP).PACK_NORMALMAP) * 2.0 - 1.0;\n nmap.y = uNormalMapFlipY == 1 ? -nmap.y : nmap.y;\n return nmap;\n }\n#endif\n\n#ifdef HAS_BUMPMAP\n uniform float uBumpMapFactor;\n uniform vec2 uBumpMapSize;\n\n vec2 getMaterialBumpMap() {\n vec2 bump;\n vec3 invSize = vec3(1.0 / uBumpMapSize, 0.0);\n return uBumpMapFactor * vec2(COLOR_CONVERT_BUMPMAP(texture2D(SAMPLER_BUMPMAP, UV_BUMPMAP - invSize.xz).PACK_BUMPMAP)\n - COLOR_CONVERT_BUMPMAP(texture2D(SAMPLER_BUMPMAP, UV_BUMPMAP + invSize.xz).PACK_BUMPMAP),\n COLOR_CONVERT_BUMPMAP(texture2D(SAMPLER_BUMPMAP, UV_BUMPMAP - invSize.zy).PACK_BUMPMAP)\n -COLOR_CONVERT_BUMPMAP(texture2D(SAMPLER_BUMPMAP, UV_BUMPMAP + invSize.zy).PACK_BUMPMAP));\n }\n#endif\n\n#ifdef HAS_SUBSURFACESCATTERING\n uniform float uSubsurfaceScatteringProfile;\n uniform float uSubsurfaceScatteringFactor;\n uniform float uScatteringFactorPacker;\n\n float getMaterialScattering() {\n #ifdef SAMPLER_SUBSURFACESCATTERING\n return uScatteringFactorPacker * uSubsurfaceScatteringFactor * COLOR_CONVERT_SUBSURFACESCATTERING(texture2D(SAMPLER_SUBSURFACESCATTERING, UV_SUBSURFACESCATTERING).PACK_SUBSURFACESCATTERING);\n #else\n return uScatteringFactorPacker * uSubsurfaceScatteringFactor;\n #endif\n }\n#endif\n\n#ifdef HAS_ALPHAMASK\n uniform float uAlphaMaskFactor;\n uniform int uAlphaMaskInvert;\n\n float getMaterialAlphaMask() {\n float alpha = 1.0;\n\n #ifdef SAMPLER_ALPHAMASK\n alpha = COLOR_CONVERT_ALPHAMASK(texture2D(SAMPLER_ALPHAMASK, UV_ALPHAMASK).PACK_ALPHAMASK);\n if (uAlphaMaskInvert == 1) alpha = 1.0 - alpha;\n #endif\n\n #ifdef HAS_VERTEX_ALPHA\n alpha *= vColor.a;\n #endif\n\n return alpha;\n }\n#endif\n\n#ifdef HAS_OPACITY\n uniform float uOpacityFactor;\n uniform int uOpacityInvert;\n\n #ifdef HAS_OPACITY_DITHER\n uniform float uOpacityThinLayer;\n uniform int uOpacityDithering;\n #endif\n\n #ifdef HAS_OPACITY_BLEND_OR_ADDITIVE\n uniform int uOpacityAdditive;\n #endif\n\n #ifdef HAS_OPACITY_REFRACTION\n uniform float uOpacityRoughnessFactor;\n #endif\n\n float getMaterialOpacity() {\n float alpha = 1.0;\n\n #ifdef SAMPLER_OPACITY\n alpha = COLOR_CONVERT_OPACITY(texture2D(SAMPLER_OPACITY, UV_OPACITY).PACK_OPACITY);\n if (uOpacityInvert == 1) alpha = 1.0 - alpha;\n #endif\n\n #ifndef HAS_OPACITY_DITHER\n alpha *= uOpacityFactor;\n #endif\n\n #ifdef HAS_VERTEX_ALPHA\n alpha *= vColor.a;\n #endif\n\n return alpha;\n }\n#endif // HAS_OPACITY\n\n\n#ifdef HAS_CLEARCOAT\n uniform vec3 uClearCoatTint;\n uniform float uClearCoatThickness;\n uniform float uClearCoatIor;\n uniform float uClearCoatFactor;\n uniform float uClearCoatF0;\n\n float getMaterialClearCoat() {\n #ifdef SAMPLER_CLEARCOAT\n return uClearCoatFactor * COLOR_CONVERT_CLEARCOAT(texture2D(SAMPLER_CLEARCOAT, UV_CLEARCOAT).PACK_CLEARCOAT);\n #else\n return uClearCoatFactor;\n #endif\n }\n#endif\n\n#ifdef HAS_CLEARCOATROUGHNESS\n uniform float uClearCoatRoughnessFactor;\n\n float getMaterialClearCoatRoughness() {\n #ifdef SAMPLER_CLEARCOATROUGHNESS\n return uClearCoatRoughnessFactor * COLOR_CONVERT_CLEARCOATROUGHNESS(texture2D(SAMPLER_CLEARCOATROUGHNESS, UV_CLEARCOATROUGHNESS).PACK_CLEARCOATROUGHNESS);\n #else\n return uClearCoatRoughnessFactor;\n #endif\n }\n#endif\n\n#ifdef HAS_CLEARCOATNORMALMAP\n uniform float uClearCoatNormalMapFactor;\n uniform int uClearCoatNormalMapFlipY;\n\n vec3 getMaterialClearCoatNormal() {\n vec3 nmap = COLOR_CONVERT_CLEARCOATNORMALMAP(texture2D(SAMPLER_CLEARCOATNORMALMAP, UV_CLEARCOATNORMALMAP).PACK_CLEARCOATNORMALMAP) * 2.0 - 1.0;\n nmap.y = uClearCoatNormalMapFlipY == 1 ? -nmap.y : nmap.y;\n return nmap;\n }\n#endif\n\n#ifdef HAS_ANISOTROPY\n uniform float uAnisotropyFactor;\n uniform float uAnisotropyDirection;\n uniform int uAnisotropyFlipXY;\n\n #ifdef SAMPLER_ANISOTROPY\n vec2 getMaterialDirectionAnisotropy() {\n vec2 dir = COLOR_CONVERT_ANISOTROPY(texture2D(SAMPLER_ANISOTROPY, UV_ANISOTROPY).PACK_ANISOTROPY) * 2.0 - 1.0;\n if (uAnisotropyFlipXY == 1) dir.xy = dir.yx;\n return dir;\n }\n #endif\n\n#endif\n\n\n#ifdef HAS_SHEEN\n\nuniform float uSheenFactor;\nuniform vec3 uSheenColorFactor;\nuniform float uSheenRoughnessFactor;\n\n\nfloat sheenLobe(const float sheenRoughness, const float NdotV, const float NdotL, const float NdotH) {\n // Charlie Sheen distribution, Conty Estevez and Kulla Production Friendly Microfacet Sheen BRDF\n float r = sheenRoughness * sheenRoughness;\n float invAlpha = 1.0 / r;\n float cos2h = NdotH * NdotH;\n // 0.0078125 => 2^(-14/2), so sin2h^2 > 0 in fp16\n float sin2h = max(1.0 - cos2h, 0.0078125);\n float D = (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n\n // Sheen visibility (much faster than charlie sheen distribution)\n // Ashikhmin and Premoze Distribution-based Brdfs\n // also Neubelt and Pettineo Crafting a Next-gen Material Pipeline for The Order\n float V = clamp(1.0 / (4.0 * (NdotL + NdotV - NdotL * NdotV)), 0.0, 1.0);\n return (D * V);\n}\n\nfloat getMaterialSheenRoughness(){\n#if defined(SAMPLER_SHEENROUGHNESS)\n return uSheenRoughnessFactor * texture2D(SAMPLER_SHEENROUGHNESS, UV_SHEENROUGHNESS).PACK_SHEENROUGHNESS;\n#else\n return uSheenRoughnessFactor;\n#endif\n}\n\nvec3 computeSheen(const vec3 normal, const vec3 lightDir, const vec3 eyeVector, const float sheenRoughness){\n\n float NdotL = dot(normal, lightDir);\n float NdotV = dot(normal, eyeVector);\n vec3 H = normalize(lightDir + eyeVector);\n float NdotH = dot(normal, H);\n\n float sheenContribution = sheenLobe(max(0.04, sheenRoughness), NdotV, NdotL, NdotH);\n\n#if defined(SAMPLER_SHEEN)\n vec3 sheenColor = uSheenFactor * uSheenColorFactor * COLOR_CONVERT_SHEEN(texture2D(SAMPLER_SHEEN, UV_SHEEN).PACK_SHEEN);\n#else\n vec3 sheenColor = uSheenFactor * uSheenColorFactor;\n#endif\n\n return max(vec3(0.0), sheenContribution * sheenColor);\n}\n\n#endif\n\n\n\n\n\n/////////////////\n// LEGACY CLASSIC\n/////////////////\n#ifdef HAS_LEGACY_CLASSIC\n uniform vec2 uTextureEnvironmentSpecularTextureSize;\n uniform samplerCube sEnvironmentSpecular;\n uniform mat3 uEnvironmentTransform;\n\n uniform float uReflection;\n\n uniform float uDiffuseColorFactor;\n uniform float uDiffuseIntensityFactor;\n vec3 getMaterialLegacyDiffuse() {\n vec3 diffuse = vec3(0.0);\n #if defined(SAMPLER_DIFFUSECOLOR)\n diffuse = uDiffuseColorFactor * COLOR_CONVERT_DIFFUSECOLOR(texture2D(SAMPLER_DIFFUSECOLOR, UV_DIFFUSECOLOR).PACK_DIFFUSECOLOR);\n #elif defined(HAS_DIFFUSECOLOR)\n diffuse = vec3(uDiffuseColorFactor);\n #endif\n\n #ifdef HAS_VERTEX_COLOR\n diffuse *= getVertexColor();\n #endif\n\n #ifdef HAS_DIFFUSEINTENSITY\n #ifdef SAMPLER_DIFFUSEINTENSITY\n diffuse *= uDiffuseIntensityFactor * COLOR_CONVERT_DIFFUSEINTENSITY(texture2D(SAMPLER_DIFFUSEINTENSITY, UV_DIFFUSEINTENSITY).PACK_DIFFUSEINTENSITY);\n #else\n diffuse *= uDiffuseIntensityFactor;\n #endif\n #endif\n\n return diffuse;\n }\n\n uniform float uSpecularColorFactor;\n vec3 getMaterialLegacySpecular() {\n #if defined(SAMPLER_SPECULARCOLOR)\n return uSpecularColorFactor * COLOR_CONVERT_SPECULARCOLOR(texture2D(SAMPLER_SPECULARCOLOR, UV_SPECULARCOLOR).PACK_SPECULARCOLOR);\n #elif defined(HAS_SPECULARCOLOR)\n return vec3(uSpecularColorFactor);\n #else\n return vec3(0.0);\n #endif\n }\n\n uniform float uSpecularHardnessFactor;\n float getMaterialLegacyShininess() {\n #if defined(SAMPLER_SPECULARHARDNESS)\n return uSpecularHardnessFactor * COLOR_CONVERT_SPECULARHARDNESS(texture2D(SAMPLER_SPECULARHARDNESS, UV_SPECULARHARDNESS).PACK_SPECULARHARDNESS);\n #elif defined(HAS_SPECULARHARDNESS)\n return uSpecularHardnessFactor;\n #else\n return 0.0;\n #endif\n }\n\n#endif\n',"utils/normalBump.glsl":"// version for vertex shader\nvec3 bumpMap(const in vec4 tangent, const in vec3 normal, const in vec2 gradient) {\n vec3 tang = normalize(tangent.xyz);\n vec3 binormal = tangent.w * normalize(cross(normal, tang));\n return normalize(normal + gradient.x * tang + gradient.y * binormal);\n}\n\n// #define transformNormal(f, tn, tex, b, n) n = f * n.xy; n = normalize(tex.x * t.xyz + tex.y * b + tex.z * n)\nvec3 transformNormal(const in float factor, in vec3 normal, const in vec3 t, const in vec3 b, in vec3 n) {\n normal.xy = factor * normal.xy;\n return normalize(normal.x * t + normal.y * b + normal.z * n);\n}\n\n// anisotropy transform\nvec3 transformTangent(in vec2 tangent, const in vec3 t, const in vec3 b) {\n return normalize(tangent.x * t + tangent.y * b);\n}\n\n// #define transformBump(tex, t, b, n) n = normalize(tex.x * t.xyz + tex.y * b + n)\nvec3 transformBump(in vec2 bump, const in vec3 t, const in vec3 b, in vec3 n) {\n return normalize(bump.x * t + bump.y * b + n);\n}\n","utils/checkerboard.glsl":"float checkerboard(const in vec2 uv, const in vec4 halton) {\n vec2 flooredUV = floor(uv);\n return mod((halton.z < 0.0 ? 0.0 : 1.0) + flooredUV.x + flooredUV.y, 2.0);\n}\n","utils/decodeDepth.glsl":"int decodeProfile(const in vec4 pack) {\n float packValue = floor(pack.b * 255.0 + 0.5);\n // we extract the 2 lowest bits\n float profile = mod(packValue, 2.0);\n profile += mod(packValue - profile, 4.0);\n return int(profile);\n}\n\nfloat decodeDepth(const in vec4 pack) {\n if(decodeProfile(pack) == 0){\n const vec3 decode = 1.0 / vec3(1.0, 255.0, 65025.0);\n return dot(pack.rgb, decode);\n }\n\n return pack.r + pack.g / 255.0;\n}\n\nfloat decodeScatter(const in vec4 pack) {\n // avoid huge number, summation, division and associated loss of precision\n // by deriving the whole computation to the end\n // As floor is with mod(x,y) = x - y * floor(x/y)\n\n // float scatter = pack.b - mod(pack.b, 4.0 / 255.0);\n // float scatter = pack.b - pack.b + (4.0 /255.0) * floor(pack.b / (4.0 /255.0));\n // float scatter = (4.0 /255.0) * floor(pack.b / (4.0 / 255.0));\n float scatter = (4.0 / 255.0) * floor(pack.b * 255.0 * 0.25);\n\n //return scatter * 255.0 / 4.0 / 63.0;\n return scatter * 1.0119047619;\n}\n\nfloat decodeAlpha(const in vec4 pack) {\n return pack.a;\n}\n\nfloat distanceToDepth(const in sampler2D depth, const in vec2 uv, const in vec4 viewPos, const vec2 nearFar) {\n float fragDepth = clamp( (-viewPos.z * viewPos.w - nearFar.x) / (nearFar.y - nearFar.x), 0.0, 1.0);\n return fragDepth - decodeDepth(texture2D(depth, uv));\n}\n","utils/encodeDepth.glsl":"// random links on packing :\n// cesium attributes packing\n// https://cesiumjs.org/2015/05/18/Vertex-Compression/\n\n// float packing in 24 bits or 32 bits\n// https://skytiger.wordpress.com/2010/12/01/packing-depth-into-color/\n\nvec4 encodeDepthAlphaProfileScatter(const in float depth, const in float alpha, const in float profile, const in float scatter) {\n vec4 pack = vec4(0.0);\n\n // opacity in alpha\n pack.a = alpha;\n\n if(profile == 0.0) {\n const vec3 code = vec3(1.0, 255.0, 65025.0);\n pack.rgb = vec3(code * depth);\n pack.gb = fract(pack.gb);\n pack.rg -= pack.gb * (1.0 / 256.0);\n } else {\n // depth in rg\n pack.g = fract(depth * 255.0);\n pack.r = depth - pack.g / 255.0;\n\n // scatter 6 bits\n pack.b = floor(0.5 + scatter * 63.0) * 4.0 / 255.0;\n }\n\n // profile on 2 lower bits\n pack.b -= mod(pack.b, 4.0 / 255.0);\n pack.b += profile / 255.0; // 3 profile possible for sss\n\n return pack;\n}\n","utils/encodeDecode.glsl":"vec3 encode24(const in float x){\n const vec3 code = vec3(1.0, 255.0, 65025.0);\n vec3 pack = vec3(code * x);\n pack.gb = fract(pack.gb);\n pack.rg -= pack.gb * (1.0 / 256.0);\n return pack;\n}\n\nfloat decode24(const in vec3 x) {\n const vec3 decode = 1.0 / vec3(1.0, 255.0, 65025.0);\n return dot(x, decode);\n}\n","utils/getLuminance.glsl":"float getLuminance(const in vec3 color) {\n // http://stackoverflow.com/questions/596216/formula-to-determine-brightness-of-rgb-color\n const vec3 colorBright = vec3(0.2126, 0.7152, 0.0722);\n return dot(color, colorBright);\n}\n","base.vert":'uniform float uDisplay2D;\nuniform float uPointSize;\n\nuniform vec2 uGlobalTexRatio;\nuniform vec2 uGlobalTexSize;\nuniform vec4 uHalton;\n\nuniform mat3 uModelNormalMatrix;\nuniform mat3 uModelViewNormalMatrix;\n\nuniform mat4 uProjectionMatrix;\nuniform mat4 uModelMatrix;\nuniform mat4 uViewMatrix;\nuniform mat4 uModelViewMatrix;\n\n// in case of srgbToLinear texfetch\n#ifdef HAS_DISPLACEMENT\n#pragma include "utils/functions.glsl"\n#endif\n\n#ifdef IS_IOS\ninvariant gl_Position;\n#endif\n\n\n#if defined(HAS_COMPRESSION) && !defined(HAS_MORPHING)\n #define HAS_POSITION_COMPRESSION\n#endif\n\n/////////////////////////////////////\n// ATTRIBUTES (NORMAL/VERTEX/TANGENT)\n/////////////////////////////////////\n\n#ifdef HAS_ZW_COMPRESSION\n attribute vec4 Vertex;\n#else\n attribute vec3 Vertex;\n#endif\n\n// need normal to displace vertex\n#if defined(HAS_VIEW_NORMAL) || defined(HAS_MODEL_NORMAL) || defined(HAS_EDITOR_DISPLACEMENT)\n\n #ifdef HAS_POSITION_COMPRESSION\n attribute vec2 Normal;\n #else\n attribute vec3 Normal;\n #endif\n\n #define NEED_LOCAL_NORMAL\n#endif\n\n// if no normalmap, correct the normal with displacement (as bump)\n#if defined(HAS_DISPLACEMENT) && !defined(HAS_NORMALMAP) && (defined(HAS_MODEL_NORMAL) || defined(HAS_VIEW_NORMAL))\n #define CORRECT_BUMP_NORMAL\n#endif\n\n// need tangent to correct normal\n#if defined(HAS_VIEW_TANGENT) || defined(HAS_MODEL_TANGENT) || defined(CORRECT_BUMP_NORMAL)\n\n #ifdef HAS_POSITION_COMPRESSION\n attribute vec3 Tangent;\n #else\n attribute vec4 Tangent;\n #endif\n\n #define NEED_LOCAL_TANGENT\n#endif\n\n#ifdef HAS_VERTEX_COLOR\n attribute vec4 Color;\n#endif\n\n////////////////////\n// VARYING/VARIABLES\n////////////////////\n\n// view\n#ifdef HAS_VIEW_VERTEX\n varying vec4 vViewVertex;\n#else\n vec4 vViewVertex;\n#endif\n\n#ifdef HAS_VIEW_NORMAL\n varying vec3 vViewNormal;\n#endif\n\n#ifdef HAS_VIEW_TANGENT\n varying vec4 vViewTangent;\n#endif\n\n// model\n#if defined(HAS_MODEL_VERTEX)\n varying vec3 vModelVertex;\n#elif defined(HAS_DISPLACEMENT)\n vec3 vModelVertex;\n#endif\n\n#if defined(HAS_MODEL_NORMAL)\n varying vec3 vModelNormal;\n#elif defined(HAS_EDITOR_DISPLACEMENT)\n vec3 vModelNormal;\n#endif\n\n#if defined(HAS_MODEL_TANGENT)\n varying vec3 vModelTangent;\n#endif\n\n#ifdef HAS_VERTEX_COLOR\n varying vec4 vColor;\n uniform float uArrayColorEnabled;\n#endif\n\n////////////\n// ANIMATION\n////////////\n\n#ifdef HAS_MORPHING\n uniform vec4 uTargetWeights;\n\n%UNROLL 4%\n #if NUM_TARGETS > %ID%\n attribute vec3 Vertex_%ID%;\n #define ARG_MORPH_VERTEX_%ID% , Vertex_%ID%\n\n #ifdef HAS_MORPHING_NORMAL\n attribute vec3 Normal_%ID%;\n #define ARG_MORPH_NORMAL_%ID% , Normal_%ID%\n #endif\n\n #ifdef HAS_MORPHING_TANGENT\n attribute vec3 Tangent_%ID%;\n #define ARG_MORPH_TANGENT_%ID% , Tangent_%ID%.xyz\n #endif\n #else\n #define ARG_MORPH_VERTEX_%ID%\n #define ARG_MORPH_NORMAL_%ID%\n #define ARG_MORPH_TANGENT_%ID%\n #endif\n%%\n\n #pragma include "utils/morphing.glsl"\n#endif\n\n#ifdef HAS_SKINNING\n #ifndef NUM_BONES\n #define NUM_BONES 1\n #endif\n\n attribute vec4 Bones;\n attribute vec4 Weights;\n uniform vec4 uBones[NUM_BONES];\n\n #pragma include "utils/skinning.glsl"\n#endif\n\n#ifdef HAS_DISPLACEMENT\n uniform float uDisplacementFactor;\n#endif\n\n#ifdef CORRECT_BUMP_NORMAL\n uniform float uDisplacementNormal;\n uniform vec2 uDisplacementSize;\n #pragma include "utils/normalBump.glsl"\n#endif\n\n#ifdef HAS_POSITION_COMPRESSION\n uniform vec3 uQVT;\n uniform vec3 uQVS;\n\n #ifdef HAS_OCT_COMPRESSION\n #define UNCOMPRESS_DIR(n) n.z = 1.0 - abs(n.x) - abs(n.y); n.xy = n.z >= 0.0 ? n.xy : (1.0 - abs(n.yx)) * sign(n.xy);\n #else\n #define UNCOMPRESS_DIR(n) n.z = dot(n.xy, n.xy); n.xyz = vec3(2.0 * n.xy * sqrt(1.0 - n.z), 1.0 - 2.0 * n.z);\n #endif\n#endif\n\n// attribute -> morph -> skin -> model -> displace -> view -> screen\n// localVertex = skin(morph(Vertex))\n// modelVertex = displacement(modelMatrix * localVertex)\n// viewVertex = viewMatrix * modelVertex\n\nvoid main() {\n#ifdef ASSIGN_UV\n ASSIGN_UV\n#endif\n\n#ifdef HAS_VERTEX_COLOR\n vColor = uArrayColorEnabled == 1.0 ? Color : vec4(1.0);\n#endif\n\n#ifdef HAS_SKINNING\n mat4 boneMatrix = skinning(Weights, Bones);\n#endif\n\n /////////////////////\n // LOCAL/MODEL VERTEX\n /////////////////////\n vec3 localVertex = Vertex.xyz;\n#ifdef HAS_POSITION_COMPRESSION\n #ifdef HAS_ZW_COMPRESSION\n localVertex += Vertex.w;\n #endif\n localVertex = localVertex * uQVS RAND_SCALE + uQVT;\n#endif\n\n#ifdef HAS_MORPHING\n localVertex = morphing(uTargetWeights, localVertex ARG_MORPH_VERTEX_0 ARG_MORPH_VERTEX_1 ARG_MORPH_VERTEX_2 ARG_MORPH_VERTEX_3);\n#endif\n\n#ifdef HAS_SKINNING\n localVertex = (vec4(localVertex, 1.0) * boneMatrix).xyz;\n#endif\n\n#if defined(HAS_MODEL_VERTEX) || defined(HAS_DISPLACEMENT)\n vModelVertex = (uModelMatrix * vec4(localVertex, 1.0)).xyz;\n#endif\n\n#if (defined(NEED_LOCAL_NORMAL) && defined(HAS_MORPHING_NORMAL)) || (defined(NEED_LOCAL_TANGENT) && defined(HAS_MORPHING_TANGENT))\n // normalize weights for direction morphing\n vec4 nTargetWeights = abs(uTargetWeights);\n nTargetWeights = uTargetWeights / max(1.0, nTargetWeights.x + nTargetWeights.y + nTargetWeights.z + nTargetWeights.w);\n#endif\n\n /////////\n // NORMAL\n /////////\n#ifdef NEED_LOCAL_NORMAL\n #ifdef HAS_POSITION_COMPRESSION\n vec3 localNormal = Normal.xyy;\n UNCOMPRESS_DIR(localNormal);\n #else\n vec3 localNormal = Normal;\n #endif\n\n #ifdef HAS_MORPHING_NORMAL\n localNormal = morphing(nTargetWeights, localNormal ARG_MORPH_NORMAL_0 ARG_MORPH_NORMAL_1 ARG_MORPH_NORMAL_2 ARG_MORPH_NORMAL_3);\n #endif\n\n #ifdef HAS_SKINNING\n localNormal = (vec4(localNormal, 0.0) * boneMatrix).xyz;\n #endif\n\n #if defined(HAS_MORPHING) || defined(HAS_SKINNING)\n localNormal.xyz = normalize(localNormal);\n #endif\n\n #if defined(HAS_MODEL_NORMAL) || defined(HAS_EDITOR_DISPLACEMENT)\n vModelNormal = uModelNormalMatrix * localNormal;\n #endif\n\n // view normal computed later if we need to correct it (displacement)\n #if defined(HAS_VIEW_NORMAL) && !defined(CORRECT_BUMP_NORMAL)\n vViewNormal = uModelViewNormalMatrix * localNormal;\n #endif\n#endif\n\n //////////\n // TANGENT\n //////////\n#ifdef NEED_LOCAL_TANGENT\n #ifdef HAS_POSITION_COMPRESSION\n vec4 localTangent = Tangent.xyzz;\n UNCOMPRESS_DIR(localTangent);\n #else\n vec4 localTangent = Tangent;\n #endif\n\n #ifdef HAS_MORPHING_TANGENT\n localTangent.xyz = morphing(nTargetWeights, localTangent.xyz ARG_MORPH_TANGENT_0 ARG_MORPH_TANGENT_1 ARG_MORPH_TANGENT_2 ARG_MORPH_TANGENT_3);\n #endif\n\n #ifdef HAS_SKINNING\n localTangent.xyz = (vec4(localTangent.xyz, 0.0) * boneMatrix).xyz;\n #endif\n\n #if defined(HAS_MORPHING) || defined(HAS_SKINNING)\n localTangent.xyz = normalize(localTangent.xyz);\n #endif\n\n #ifdef HAS_MODEL_TANGENT\n vModelTangent = vec4(uModelNormalMatrix * localTangent.xyz, localTangent.w).xyz;\n #endif\n\n #ifdef HAS_VIEW_TANGENT\n vViewTangent = vec4(uModelViewNormalMatrix * localTangent.xyz, localTangent.w);\n #endif\n#endif\n\n //////////////////\n // DISPLACE VERTEX\n //////////////////\n#ifdef HAS_DISPLACEMENT\n // we multiply by 1 - uDisplay2D here as we don\'t want the displacement to appear in the 2D view of the inspector\n float displacement = (COLOR_CONVERT_DISPLACEMENT(texture2D(SAMPLER_DISPLACEMENT, UV_DISPLACEMENT).PACK_DISPLACEMENT) - 0.5) * uDisplacementFactor * (1.0 - uDisplay2D);\n #ifdef HAS_EDITOR_DISPLACEMENT\n vModelVertex += normalize(vModelNormal) * displacement;\n #else\n vModelVertex += vec3(0.0, 0.0, 1.0) * (vModelVertex.z > 0.01 ? displacement : 0.0);\n #endif\n vViewVertex = uViewMatrix * vec4(vModelVertex, 1.0);\n#else\n vViewVertex = uModelViewMatrix * vec4(localVertex, 1.0);\n#endif\n\n //////////////////\n // DISPLACE NORMAL\n //////////////////\n#ifdef CORRECT_BUMP_NORMAL\n // if there is no normal map, use displacement to correct normal\n vec3 invSize = vec3(1.0 / uDisplacementSize, 0.0);\n vec2 gradient = vec2(COLOR_CONVERT_DISPLACEMENT(texture2D(SAMPLER_DISPLACEMENT, UV_DISPLACEMENT - invSize.xz).PACK_DISPLACEMENT)\n - COLOR_CONVERT_DISPLACEMENT(texture2D(SAMPLER_DISPLACEMENT, UV_DISPLACEMENT + invSize.xz).PACK_DISPLACEMENT),\n COLOR_CONVERT_DISPLACEMENT(texture2D(SAMPLER_DISPLACEMENT, UV_DISPLACEMENT - invSize.zy).PACK_DISPLACEMENT)\n -COLOR_CONVERT_DISPLACEMENT(texture2D(SAMPLER_DISPLACEMENT, UV_DISPLACEMENT + invSize.zy).PACK_DISPLACEMENT));\n\n localNormal = bumpMap(localTangent, localNormal, uDisplacementNormal * gradient);\n\n #if defined(HAS_VIEW_NORMAL)\n vModelNormal = uModelNormalMatrix * localNormal;\n #endif\n\n #ifdef HAS_VIEW_NORMAL\n vViewNormal = uModelViewNormalMatrix * localNormal;\n #endif\n#endif\n\n ///////////////////////\n // PROJECTION JITTERING (could be done on the CPU)\n ///////////////////////\n mat4 jitteredProjection = uProjectionMatrix;\n#if defined(WIREFRAME)\n vViewVertex.w += 0.005 / uProjectionMatrix[1][1];\n#elif defined(SHADOW_CAST)\n float doPersp = jitteredProjection[3][3] == 0.0 ? 1.0 : 0.0;\n vec2 jitter = (abs(uHalton.z) == 2.0 ? 1.0 : 0.0) * (uHalton.xy / uShadowMapSize.xy);\n jitteredProjection[2].xy += doPersp * jitter;\n jitteredProjection[3].xy += (1.0 - doPersp) * jitter;\n#elif !defined(NO_JITTER)\n jitteredProjection[2].xy += (1.0 - uDisplay2D) * (uHalton.xy * uGlobalTexRatio.xy / uGlobalTexSize.xy);\n#endif\n\n gl_Position = jitteredProjection * vViewVertex;\n\n#ifdef HAS_POINT_SIZE\n gl_PointSize = min(64.0, max(1.0, -uPointSize / vViewVertex.z));\n#else\n gl_PointSize = 1.0;\n#endif\n\n// probably not the best solution (in case you need custom things while including base.vert)\n#ifdef INJECT_VERT\n INJECT_VERT\n#endif\n}\n',"earlyz.vert":'#define HAS_VIEW_VERTEX\n#pragma include "base.vert"\n',"pbr.vert":'#define HAS_VIEW_NORMAL\n#define HAS_VIEW_VERTEX\n#pragma include "base.vert"\n',"pbr.frag":'uniform float uRGBMRange;\nuniform int uOutputLinear;\n\n// stuffs (ssr, opacity, scattering)\nuniform vec4 uHalton;\nuniform vec2 uNearFar;\nuniform float uFrameMod;\nuniform int uDrawOpaque;\n\n// shadow signature...\n#ifdef HAS_SUBSURFACETRANSLUCENCY\n #define _OUT_DISTANCE\n #define OPT_DISTANCE shadowDistance,\n#else\n #define OPT_DISTANCE\n#endif\n\n//////////\n// VARYING\n//////////\nvarying vec4 vViewVertex;\nvarying vec3 vViewNormal;\n\n#ifdef HAS_SHADOW\n varying vec3 vModelNormal;\n varying vec3 vModelVertex;\n#endif\n\n#ifdef HAS_VIEW_TANGENT\n varying vec4 vViewTangent;\n#endif\n\n#pragma include "utils/common.glsl"\n\n#pragma include "utils/functions.glsl"\n\n#pragma include "utils/material.glsl"\n\n// TODO ifdef around pragma include can result in error (files being included multiple times can be ignored)\n#pragma include "utils/decodeDepth.glsl"\n\n#pragma include "utils/rand.glsl"\n\n#if defined(HAS_NORMALMAP) || defined(HAS_BUMPMAP) || defined(HAS_CLEARCOATNORMALMAP) || defined(SAMPLER_ANISOTROPY)\n#pragma include "utils/normalBump.glsl"\n#endif\n\n#ifdef HAS_SHADOW\n#pragma include "shadowing/shadowReceive.glsl"\n#endif\n\n// /!\\ (lightsPBR is also included in clearcoat file, and ifdef around pragma include is not reliable)\n#if defined(HAS_LIGHT) || defined(HAS_CLEARCOAT) || defined(HAS_SHEEN)\n#pragma include "utils/lightsPBR.glsl"\n#endif\n\n#ifdef HAS_ENVIRONMENT\n#pragma include "utils/environment.glsl"\n#endif\n\n#ifdef HAS_SUBSURFACETRANSLUCENCY\n#pragma include "utils/lightsSSS.glsl"\n#endif\n\n#ifdef HAS_SUBSURFACESCATTERING\n#pragma include "utils/checkerboard.glsl"\n#endif\n\n#ifdef HAS_CLEARCOAT\n#pragma include "utils/clearCoat.glsl"\n#endif\n\n// #ifdef HAS_OPACITY_DITHER\n// #pragma include "utils/rand.glsl"\n// #endif\n\n#ifdef HAS_OPACITY_REFRACTION\n#pragma include "utils/refraction.glsl"\n#endif\n\n#ifdef HAS_SSR\n#pragma include "utils/ssr.glsl"\n#endif\n\nfloat specularOcclusion(const in int occlude, const in float ao, const in vec3 normal, const in vec3 eyeVector) {\n if (occlude == 0) return 1.0;\n // Yoshiharu Gotanda\'s specular occlusion approximation:\n // cf http://research.tri-ace.com/Data/cedec2011_RealtimePBR_Implementation_e.pptx pg59\n float d = dot(normal, eyeVector) + ao;\n return clamp((d * d) - 1.0 + ao, 0.0, 1.0);\n}\n\nfloat adjustRoughnessNormalMap(const in float roughness, const in vec3 normal) {\n // Based on The Order : 1886 SIGGRAPH course notes implementation (page 21 notes)\n float nlen2 = dot(normal, normal);\n if (nlen2 < 1.0) {\n float nlen = sqrt(nlen2);\n float kappa = (3.0 * nlen - nlen2 * nlen) / (1.0 - nlen2);\n // http://www.frostbite.com/2014/11/moving-frostbite-to-pbr/\n // page 91 : they use 0.5/kappa instead\n return min(1.0, sqrt(roughness * roughness + 1.0 / kappa));\n }\n return roughness;\n}\n\nvec3 computeAnisotropicBentNormal(const in vec3 normal, const in vec3 eyeVector, const in float roughness, const in vec3 anisotropicT, const in vec3 anisotropicB, const in float anisotropy) {\n vec3 anisotropyDirection = anisotropy >= 0.0 ? anisotropicB : anisotropicT;\n vec3 anisotropicTangent = cross(anisotropyDirection, eyeVector);\n vec3 anisotropicNormal = cross(anisotropicTangent, anisotropyDirection);\n float bendFactor = abs(anisotropy) * clamp(5.0 * roughness, 0.0, 1.0);\n return normalize(mix(normal, anisotropicNormal, bendFactor));\n}\n\nvoid main() {\n //////////////////\n // OPACITY DISCARD\n //////////////////\n#ifdef HAS_POINT_CIRCLE\n if (length(2.0 * gl_PointCoord - 1.0) > 1.0) discard;\n#endif\n\n#ifdef HAS_ALPHAMASK\n if (getMaterialAlphaMask() < uAlphaMaskFactor) discard;\n#endif\n#ifdef HAS_OPACITY_DITHER\n ditheringMaskingDiscard(gl_FragCoord, uOpacityDithering, getMaterialOpacity(), uOpacityFactor, uOpacityThinLayer, uFrameMod, uNearFar, uHalton);\n#endif\n\n#ifdef HAS_OPACITY_BLEND_OR_ADDITIVE\n float alpha = getMaterialOpacity();\n float alphaFinal = alpha * float(1 - uOpacityAdditive);\n if (alpha == 0.0 || (uDrawOpaque == 1 && alphaFinal < EPSILON_ALPHA) || (uDrawOpaque == 0 && alphaFinal >= EPSILON_ALPHA)) discard;\n#endif\n\n // /!\\ because of refraction roughness, this part should be done before the call to getMetalness/getSpecular\n#ifdef HAS_OPACITY_REFRACTION\n gRefractionRoughness = uOpacityRoughnessFactor;\n float alphaRefraction = getMaterialOpacity();\n if ((uDrawOpaque == 1 && alphaRefraction < EPSILON_ALPHA) || (uDrawOpaque == 0 && alphaRefraction >= EPSILON_ALPHA)) discard;\n#endif\n\n ///////////\n // GEOMETRY\n ///////////\n // https://twitter.com/pyalot/status/711956736639418369\n vec3 eyeVector = -normalize(vViewVertex.xyz);\n vec3 frontNormal = normalize(gl_FrontFacing ? vViewNormal : -vViewNormal);\n\n#ifdef HAS_VIEW_TANGENT\n vec4 tangent;\n tangent = vViewTangent;\n\n tangent = gl_FrontFacing ? tangent : -tangent;\n tangent.xyz = normalize(tangent.xyz);\n vec3 binormal = normalize(cross(frontNormal, tangent.xyz)) * tangent.w;\n#endif\n\n ///////////\n // MATERIAL\n ///////////\n#if defined(HAS_LEGACY_CLASSIC)\n vec3 materialDiffuse = getMaterialLegacyDiffuse();\n vec3 materialSpecular = getMaterialLegacySpecular();\n#elif defined(HAS_METALNESSPBR)\n float f0 = 0.08 * getMaterialF0();\n float metal = getMaterialMetalness();\n\n #ifdef HAS_OPACITY_REFRACTION\n metal *= alphaRefraction;\n #endif\n\n vec3 materialDiffuse = getMaterialAlbedo();\n vec3 materialSpecular = mix(vec3(f0), materialDiffuse, metal);\n materialDiffuse *= 1.0 - metal;\n#else\n vec3 materialSpecular = getMaterialSpecular();\n vec3 materialDiffuse = getMaterialDiffuse();\n\n #ifdef HAS_OPACITY_REFRACTION\n materialSpecular *= mix(0.08, 1.0, alphaRefraction);\n #endif\n#endif // HAS_METALNESSPBR\n\n#if defined(HAS_ENVIRONMENT) || defined(HAS_LIGHT)\n float materialF90 = clamp(50.0 * materialSpecular.g, 0.0, 1.0);\n#endif\n\n#if defined(HAS_LEGACY_CLASSIC)\n float materialShininess = getMaterialLegacyShininess();\n float materialRoughness = 0.0;\n#elif defined(HAS_ROUGHNESSPBR)\n float materialRoughness = getMaterialRoughness();\n#else\n float materialRoughness = 1.0 - getMaterialGlossiness();\n#endif // HAS_ROUGHNESSPBR\n\n#ifdef HAS_AOPBR\n float materialAO = getMaterialAO();\n#endif\n\n#ifdef HAS_EMITCOLOR\n vec3 materialEmit = getMaterialEmitColor();\n#endif\n\n#ifdef HAS_CAVITYPBR\n float materialCavity = getMaterialCavity();\n#endif\n\n#ifdef HAS_SUBSURFACETRANSLUCENCY\n float materialTranslucency = getMaterialTranslucency();\n#endif\n\n vec3 materialNormal = frontNormal;\n#ifdef HAS_NORMALMAP\n materialNormal = getMaterialNormalMap();\n materialRoughness = adjustRoughnessNormalMap(materialRoughness, materialNormal);\n materialNormal = transformNormal(uNormalMapFactor, materialNormal, tangent.xyz, binormal, frontNormal);\n#endif\n\n#ifdef HAS_BUMPMAP\n materialNormal = transformBump(getMaterialBumpMap(), tangent.xyz, binormal, frontNormal);\n#endif\n\n#ifdef HAS_CLEARCOAT\n float materialClearCoat = getMaterialClearCoat();\n float materialClearCoatRoughness = getMaterialClearCoatRoughness();\n #ifdef HAS_CLEARCOATNORMALMAP\n vec3 materialClearCoatNormal = transformNormal(uClearCoatNormalMapFactor, getMaterialClearCoatNormal(), tangent.xyz, binormal, frontNormal);\n #else\n vec3 materialClearCoatNormal = frontNormal;\n #endif\n#endif\n\n#if defined(HAS_ANISOTROPY) && (defined(HAS_LIGHT) || defined(HAS_ENVIRONMENT))\n float anisotropy = uAnisotropyFactor;\n\n #ifdef SAMPLER_ANISOTROPY\n vec2 aniso = getMaterialDirectionAnisotropy();\n vec3 anisotropicT = transformTangent(aniso, tangent.xyz, binormal);\n // reproject tangent/binormal on the material normal plane\n anisotropicT = normalize(anisotropicT - materialNormal * dot(anisotropicT, materialNormal));\n vec3 anisotropicB = normalize(cross(materialNormal, anisotropicT.xyz));\n\n anisotropy *= length(aniso);\n #else\n #if defined(HAS_NORMALMAP) || defined(HAS_BUMPMAP)\n // reproject tangent/binormal on the material normal plane\n tangent.xyz = normalize(tangent.xyz - materialNormal * dot(tangent.xyz, materialNormal));\n binormal = normalize(cross(materialNormal, tangent.xyz)) * tangent.w;\n #endif\n\n vec3 anisotropicT = normalize(mix(tangent.xyz, binormal, uAnisotropyDirection));\n vec3 anisotropicB = normalize(mix(binormal, -tangent.xyz, uAnisotropyDirection));\n #endif\n#endif\n\n vec3 diffuse = vec3(0.0);\n vec3 specular = vec3(0.0);\n\n#if (defined(HAS_ENVIRONMENT) || defined(HAS_LIGHT))\n #if defined(HAS_CLEARCOAT)\n float ccNoV = saturate(dot(materialClearCoatNormal, -refract(eyeVector, materialClearCoatNormal, 1.0 / uClearCoatIor)));\n #endif\n #if defined(HAS_SHEEN)\n float sheenRoughness = getMaterialSheenRoughness();\n #endif\n#endif\n //////////////\n // ENVIRONMENT\n //////////////\n#ifdef HAS_ENVIRONMENT\n\n #ifdef HAS_ANISOTROPY\n vec3 bentAnisotropicNormal = computeAnisotropicBentNormal(materialNormal, eyeVector, materialRoughness, anisotropicT, anisotropicB, anisotropy);\n #else\n vec3 bentAnisotropicNormal = materialNormal;\n #endif\n\n\n diffuse = materialDiffuse * computeDiffuseSPH(materialNormal);\n\n #ifdef HAS_SHEEN\n diffuse += computeSheen(materialNormal, getSpecularDominantDir(materialNormal, reflect(-eyeVector, materialNormal), sheenRoughness), eyeVector, sheenRoughness);\n #endif\n\n #ifdef HAS_LEGACY_CLASSIC\n specular = materialSpecular * textureCubeFixed(sEnvironmentSpecular, uEnvironmentTransform * normalize((2.0 * clamp(dot(materialNormal, eyeVector), 0.0, 1.0)) * materialNormal - eyeVector), uTextureEnvironmentSpecularTextureSize.x);\n #else\n specular = computeIBLSpecularUE4(bentAnisotropicNormal, eyeVector, materialRoughness, materialSpecular, frontNormal, materialF90);\n #endif\n\n #ifdef HAS_CLEARCOAT\n float ccF0 = materialClearCoat * F_Schlick(uClearCoatF0, 1.0, ccNoV);\n vec3 ccAbsorbtion = getClearCoatAbsorbtion(ccNoV, ccNoV, materialClearCoat);\n specular = mix(specular * ccAbsorbtion, getPrefilteredEnvMapColor(materialClearCoatNormal, eyeVector, materialClearCoatRoughness, frontNormal), ccF0);\n diffuse *= ccAbsorbtion * (1.0 - ccF0);\n #endif\n\n float aoSpec = 1.0;\n #ifdef HAS_LEGACY_CLASSIC\n aoSpec = uReflection;\n specular *= aoSpec;\n #endif\n\n #ifdef HAS_AOPBR\n diffuse *= uEnvironmentExposure * materialAO;\n aoSpec = specularOcclusion(uAOPBROccludeSpecular, materialAO, materialNormal, eyeVector);\n specular *= uEnvironmentExposure * aoSpec;\n #else\n diffuse *= uEnvironmentExposure;\n specular *= uEnvironmentExposure;\n #endif // HAS_AOPBR\n\n #ifdef HAS_SSR\n #ifdef HAS_CLEARCOAT\n vec3 normalSsr = normalize(mix(bentAnisotropicNormal, materialClearCoatNormal, materialClearCoat * 0.5));\n float roughnessSsr = mix(materialRoughness, materialClearCoatRoughness, materialClearCoat);\n vec3 specularSsr = aoSpec * materialSpecular * mix(vec3(1.0), ccAbsorbtion, materialClearCoat);\n specular = ssr(specular, specularSsr, roughnessSsr, normalSsr, eyeVector);\n #else\n specular = ssr(specular, materialSpecular * aoSpec, materialRoughness, bentAnisotropicNormal, eyeVector);\n #endif\n #endif // HAS_SSR\n#endif // HAS_ENVIRONMENT\n\n /////////////////////////\n // LIGHTING AND SHADOWING\n /////////////////////////\n#ifdef HAS_LIGHT\n float attenuation, dotNL;\n vec3 eyeLightDir;\n bool lighted;\n vec3 lightSpecular;\n vec3 lightDiffuse;\n vec4 prepGGX = precomputeGGX(materialNormal, eyeVector, max(MIN_ROUGHNESS, materialRoughness));\n\n #ifdef HAS_CLEARCOAT\n vec4 prepGGXClearCoat = precomputeGGX(materialClearCoatNormal, eyeVector, materialClearCoatRoughness);\n vec3 ccSpecular;\n vec3 ccAttenuation;\n #endif\n#endif\n\n#ifdef HAS_SHADOW\n float shadow;\n vec3 modelNormal = normalize(gl_FrontFacing ? vModelNormal : -vModelNormal);\n\n #ifdef HAS_SUBSURFACETRANSLUCENCY\n float shadowDistance;\n #endif\n#endif // HAS_SHADOW\n\n\n%UNROLL 4%\n#ifdef LIGHT_TYPE_%ID%\n\n #if LIGHT_TYPE_%ID% == LIGHT_SPOT\n precomputeSpot(materialNormal, vViewVertex.xyz, uEditorLight%ID%_viewDirection, uEditorLight%ID%_attenuation, uEditorLight%ID%_viewPosition.xyz, uEditorLight%ID%_spotCutOff, uEditorLight%ID%_spotBlend, attenuation, eyeLightDir, dotNL);\n #elif LIGHT_TYPE_%ID% == LIGHT_POINT\n precomputePoint(materialNormal, vViewVertex.xyz, uEditorLight%ID%_attenuation, uEditorLight%ID%_viewPosition.xyz, attenuation, eyeLightDir, dotNL);\n #elif LIGHT_TYPE_%ID% == LIGHT_DIRECTION\n precomputeSun(materialNormal, uEditorLight%ID%_viewDirection, attenuation, eyeLightDir, dotNL);\n #elif LIGHT_TYPE_%ID% == LIGHT_HEMI\n precomputeSun(materialNormal, uEditorLight%ID%_viewDirection, attenuation, eyeLightDir, dotNL);\n #endif\n\n #ifdef HAS_LEGACY_CLASSIC\n #if LIGHT_TYPE_%ID% == LIGHT_HEMI\n hemiLight(materialNormal, eyeVector, dotNL, eyeLightDir, materialDiffuse, materialSpecular, materialShininess, uEditorLight%ID%_diffuse.rgb, uEditorLight%ID%_ground.rgb, lightDiffuse, lightSpecular, lighted);\n #else\n computeLightLambertCookTorrance(materialNormal, eyeVector, dotNL, attenuation, materialDiffuse, materialSpecular, materialShininess, uEditorLight%ID%_diffuse.rgb, uEditorLight%ID%_diffuse.rgb, eyeLightDir, lightDiffuse, lightSpecular, lighted);\n #endif\n #else\n #ifdef HAS_ANISOTROPY\n computeLightLambertGGXAnisotropy(materialNormal, eyeVector, dotNL, prepGGX, materialDiffuse, materialSpecular, attenuation, uEditorLight%ID%_diffuse.rgb, eyeLightDir, materialF90, anisotropicT, anisotropicB, anisotropy, lightDiffuse, lightSpecular, lighted);\n #else\n computeLightLambertGGX(materialNormal, eyeVector, dotNL, prepGGX, materialDiffuse, materialSpecular, attenuation, uEditorLight%ID%_diffuse.rgb, eyeLightDir, materialF90, lightDiffuse, lightSpecular, lighted);\n #endif\n #endif\n\n #ifdef HAS_CLEARCOAT\n computeLightLambertGGXClearCoat(ccNoV, materialClearCoatNormal, eyeVector, dot(materialClearCoatNormal, eyeLightDir), prepGGXClearCoat, attenuation, uEditorLight%ID%_diffuse.rgb, eyeLightDir, materialClearCoat, ccSpecular, ccAttenuation);\n lightDiffuse *= ccAttenuation;\n lightSpecular = ccSpecular + lightSpecular * ccAttenuation;\n #endif\n\n #ifdef HAS_SHEEN\n lightDiffuse += computeSheen(materialNormal, eyeLightDir, eyeVector, sheenRoughness);\n #endif\n\n\n\n #ifdef HAS_SHADOW_%ID%\n #ifdef _ATLAS_SHADOW\n shadow = shadowReceive(lighted, modelNormal, vModelVertex, Texture7, uShadow_Texture0_renderSize, uShadow_Texture%ID%_projection, uShadow_Texture%ID%_viewRight, uShadow_Texture%ID%_viewUp, uShadow_Texture%ID%_viewLook, uShadow_Texture%ID%_depthRange, uShadowReceive%ID%_bias, uShadow_Texture%ID%_mapSize, OPT_DISTANCE uStaticFrameNumShadow%ID%);\n #else\n shadow = shadowReceive(lighted, modelNormal, vModelVertex, TEX_SHADOW_%ID%, uShadow_Texture%ID%_renderSize, uShadow_Texture%ID%_projection, uShadow_Texture%ID%_viewRight, uShadow_Texture%ID%_viewUp, uShadow_Texture%ID%_viewLook, uShadow_Texture%ID%_depthRange, uShadowReceive%ID%_bias, OPT_DISTANCE uStaticFrameNumShadow%ID%);\n #endif // _ATLAS_SHADOW\n\n lightDiffuse *= shadow;\n lightSpecular *= shadow;\n\n #ifdef HAS_SUBSURFACETRANSLUCENCY\n lightDiffuse += computeLightSSS(dotNL, attenuation, uSubsurfaceTranslucencyThicknessFactor, uSubsurfaceTranslucencyColor, materialTranslucency, shadowDistance, materialDiffuse, uEditorLight%ID%_diffuse.rgb);\n #endif\n #endif // HAS_SHADOW\n\n diffuse += lightDiffuse;\n specular += lightSpecular;\n#endif // LIGHT_TYPE\n%%\n\n /////////////\n // REFRACTION\n /////////////\n#ifdef HAS_OPACITY_REFRACTION\n #ifdef HAS_REFRACTION_NORMAL_OFFSET\n vec3 refractLight = refraction(gRefractionRoughness, materialNormal, frontNormal);\n #else\n vec3 refractLight = refraction(gRefractionRoughness, materialNormal, eyeVector);\n #endif\n\n #ifdef HAS_REFRACTION_ALBEDO_TINT\n refractLight *= materialDiffuse;\n #endif\n\n diffuse = mix(refractLight, diffuse, alphaRefraction);\n#endif // HAS_OPACITY_REFRACTION\n\n //////////////////////\n // SCATTERING AND EMIT\n //////////////////////\n#ifdef HAS_SUBSURFACESCATTERING\n #ifdef HAS_EMITCOLOR\n diffuse = uEmitMultiplicative == 1 ? diffuse * materialEmit : diffuse + materialEmit;\n if (uEmitMultiplicative == 1) specular *= materialEmit;\n #endif\n vec3 frag = mix(specular, diffuse, checkerboard(gl_FragCoord.xy, uHalton));\n#else\n vec3 frag = diffuse + specular;\n #ifdef HAS_EMITCOLOR\n frag = uEmitMultiplicative == 1 ? frag * materialEmit : frag + materialEmit;\n #endif\n#endif // HAS_SUBSURFACESCATTERING\n\n#ifdef HAS_CAVITYPBR\n frag *= materialCavity;\n#endif\n\n // premult\n#ifdef HAS_OPACITY_BLEND_OR_ADDITIVE\n frag *= alpha;\n#endif\n\n if (uOutputLinear != 1) frag = linearTosRGB(frag);\n\n#ifdef HAS_OPACITY_BLEND_OR_ADDITIVE\n gl_FragColor = uDrawOpaque == 1 ? encodeRGBM(frag, uRGBMRange) : vec4(frag, alphaFinal);\n#else\n gl_FragColor = encodeRGBM(frag, uRGBMRange);\n#endif\n}\n',"outline.vert":'#define NO_JITTER 1\n#pragma include "baseVert.glsl"\n',"outline.frag":"uniform vec3 uOutlineColor;\n\nvoid main() {\n#ifdef HAS_POINT_CIRCLE\n if (length(2.0 * gl_PointCoord - 1.0) > 1.0) discard;\n#endif\n\n gl_FragColor = vec4(uOutlineColor, 1.0);\n}\n","matcap.vert":'#define HAS_VIEW_NORMAL\n#define HAS_VIEW_VERTEX\n#pragma include "base.vert"\n',"matcap.frag":'uniform float uRGBMRange;\nuniform int uOutputLinear;\n\n// stuffs (ssr, opacity, scattering)\nuniform vec4 uHalton;\nuniform vec2 uNearFar;\nuniform float uFrameMod;\nuniform int uDrawOpaque;\n\nuniform vec3 uMatcapColor;\n\nuniform int uInspectorView; // see globalUniforms\n\n//////////\n// VARYING\n//////////\nvarying vec4 vViewVertex;\nvarying vec3 vViewNormal;\n\n#ifdef HAS_VIEW_TANGENT\nvarying vec4 vViewTangent;\n#endif\n\n#pragma include "utils/common.glsl"\n\n#pragma include "utils/functions.glsl"\n\n#pragma include "utils/material.glsl"\n\n#pragma include "utils/curvature.glsl"\n\n// TODO ifdef around pragma include can result in error (files being included multiple times can be ignored)\n#pragma include "utils/decodeDepth.glsl"\n\n#pragma include "utils/rand.glsl"\n\n#ifdef HAS_VIEW_TANGENT\n#pragma include "utils/normalBump.glsl"\n#endif\n\n#ifdef HAS_OPACITY_REFRACTION\n#pragma include "utils/refraction.glsl"\n#endif\n\nvoid main() {\n //////////////////\n // OPACITY DISCARD\n //////////////////\n#ifdef HAS_POINT_CIRCLE\n if (length(2.0 * gl_PointCoord - 1.0) > 1.0) discard;\n#endif\n\n#ifdef HAS_ALPHAMASK\n if (getMaterialAlphaMask() < uAlphaMaskFactor) discard;\n#endif\n#ifdef HAS_OPACITY_DITHER\n ditheringMaskingDiscard(gl_FragCoord, uOpacityDithering, getMaterialOpacity(), uOpacityFactor, uOpacityThinLayer, uFrameMod, uNearFar, uHalton);\n#endif\n\n#ifdef HAS_OPACITY_BLEND_OR_ADDITIVE\n float alpha = getMaterialOpacity();\n float alphaFinal = alpha * float(1 - uOpacityAdditive);\n if (alpha == 0.0 || (uDrawOpaque == 1 && alphaFinal < EPSILON_ALPHA) || (uDrawOpaque == 0 && alphaFinal >= EPSILON_ALPHA)) discard;\n#endif\n\n// /!\\ because of refraction roughness, this part should be done before the call to getMetalness/getSpecular\n#ifdef HAS_OPACITY_REFRACTION\n gRefractionRoughness = uOpacityRoughnessFactor;\n float alphaRefraction = getMaterialOpacity();\n if ((uDrawOpaque == 1 && alphaRefraction < EPSILON_ALPHA) || (uDrawOpaque == 0 && alphaRefraction >= EPSILON_ALPHA)) discard;\n#endif\n\n ///////////\n // GEOMETRY\n ///////////\n vec3 eyeVector = -normalize(vViewVertex.xyz);\n vec3 frontNormal = normalize(gl_FrontFacing ? vViewNormal : -vViewNormal);\n\n#ifdef HAS_VIEW_TANGENT\n vec4 tangent = gl_FrontFacing ? vViewTangent : -vViewTangent;\n tangent.xyz = normalize(tangent.xyz);\n vec3 binormal = normalize(cross(frontNormal, tangent.xyz)) * tangent.w;\n#endif\n\n ///////////\n // MATERIAL\n ///////////\n vec3 materialNormal = frontNormal;\n#ifdef HAS_NORMALMAP\n materialNormal = getMaterialNormalMap();\n materialNormal = transformNormal(uNormalMapFactor, materialNormal, tangent.xyz, binormal, frontNormal);\n#endif\n\n#ifdef HAS_BUMPMAP\n materialNormal = transformBump(getMaterialBumpMap(), tangent.xyz, binormal, frontNormal);\n#endif\n\n vec3 materialDiffuse = uMatcapColor;\n#ifdef HAS_VERTEX_COLOR\n materialDiffuse *= getVertexColor();\n#endif\n\n vec3 nm_x = vec3(-eyeVector.z, 0.0, eyeVector.x);\n vec3 nm_y = cross(nm_x, eyeVector);\n vec2 uvMatcap = vec2(dot(materialNormal.xz, -nm_x.xz), dot(materialNormal, nm_y)) * 0.5 + 0.5;\n vec3 diffuse = materialDiffuse * sRGBToLinear(texture2D(SAMPLER_MATCAP, uvMatcap).rgb) * getCurvature(materialNormal);\n\n /////////////\n // REFRACTION\n /////////////\n#ifdef HAS_OPACITY_REFRACTION\n\n#ifdef HAS_REFRACTION_NORMAL_OFFSET\n vec3 refractLight = refraction(uOpacityRoughnessFactor, materialNormal, frontNormal);\n#else\n vec3 refractLight = refraction(uOpacityRoughnessFactor, materialNormal, eyeVector);\n#endif\n\n#ifdef HAS_REFRACTION_ALBEDO_TINT\n refractLight *= materialDiffuse;\n#endif\n\n diffuse = mix(refractLight, diffuse, alphaRefraction);\n#endif // HAS_OPACITY_REFRACTION\n\n vec3 frag = diffuse;\n\n if (uInspectorView == 2) {\n frag = vec3(0.9, 0.75, 0.5) * max(0.25, dot(materialNormal.xyz, vec3(0.15, 0.3, 0.9)));\n }\n\n// premult\n#ifdef HAS_OPACITY_BLEND_OR_ADDITIVE\n frag *= alpha;\n#endif\n\n if (uOutputLinear != 1) frag = linearTosRGB(frag);\n\n#ifdef HAS_OPACITY_BLEND_OR_ADDITIVE\n gl_FragColor = uDrawOpaque == 1 ? encodeRGBM(frag, uRGBMRange) : vec4(frag, alphaFinal);\n#else\n gl_FragColor = encodeRGBM(frag, uRGBMRange);\n#endif\n}\n',"shadeless.vert":'#pragma include "pbr.vert"\n',"shadeless.frag":'uniform float uRGBMRange;\nuniform int uOutputLinear;\n\n// stuffs (ssr, opacity, scattering)\nuniform vec4 uHalton;\nuniform vec2 uNearFar;\nuniform float uFrameMod;\nuniform int uDrawOpaque;\n\n//////////\n// VARYING\n//////////\n\n#ifdef HAS_OPACITY_REFRACTION\n varying vec3 vViewNormal;\n varying vec4 vViewVertex;\n#endif\n\n#pragma include "utils/common.glsl"\n#pragma include "utils/functions.glsl"\n#pragma include "utils/material.glsl"\n#pragma include "utils/decodeDepth.glsl"\n#pragma include "utils/rand.glsl"\n\n#ifdef HAS_OPACITY_REFRACTION\n #pragma include "utils/refraction.glsl"\n#endif\n\nvoid main() {\n //////////////////\n // OPACITY DISCARD\n //////////////////\n#ifdef HAS_POINT_CIRCLE\n if (length(2.0 * gl_PointCoord - 1.0) > 1.0) discard;\n#endif\n\n#ifdef HAS_ALPHAMASK\n if (getMaterialAlphaMask() < uAlphaMaskFactor) discard;\n#endif\n\n#ifdef HAS_OPACITY_DITHER\n ditheringMaskingDiscard(gl_FragCoord, uOpacityDithering, getMaterialOpacity(), uOpacityFactor, uOpacityThinLayer, uFrameMod, uNearFar, uHalton);\n#endif\n\n#ifdef HAS_OPACITY_BLEND_OR_ADDITIVE\n float alpha = getMaterialOpacity();\n float alphaFinal = alpha * float(1 - uOpacityAdditive);\n if (alpha == 0.0 || (uDrawOpaque == 1 && alphaFinal < EPSILON_ALPHA) || (uDrawOpaque == 0 && alphaFinal >= EPSILON_ALPHA)) discard;\n#endif\n\n // /!\\ because of refraction roughness, this part should be done before the call to getMetalness/getSpecular\n#ifdef HAS_OPACITY_REFRACTION\n gRefractionRoughness = uOpacityRoughnessFactor;\n float alphaRefraction = getMaterialOpacity();\n if ((uDrawOpaque == 1 && alphaRefraction < EPSILON_ALPHA) || (uDrawOpaque == 0 && alphaRefraction >= EPSILON_ALPHA)) discard;\n#endif\n\n ///////////\n // GEOMETRY\n ///////////\n#ifdef HAS_OPACITY_REFRACTION\n vec3 eyeVector = -normalize(vViewVertex.xyz);\n vec3 frontNormal = normalize(gl_FrontFacing ? vViewNormal : -vViewNormal);\n#endif\n\n ///////////\n // MATERIAL\n ///////////\n#if defined(HAS_LEGACY_CLASSIC)\n vec3 materialDiffuse = getMaterialLegacyDiffuse();\n#elif defined(HAS_ALBEDOPBR)\n vec3 materialDiffuse = getMaterialAlbedo();\n#else\n vec3 materialDiffuse = getMaterialDiffuse();\n#endif\n\n#ifdef HAS_AOPBR\n float materialAO = getMaterialAO();\n#endif\n\n#ifdef HAS_EMITCOLOR\n vec3 materialEmit = getMaterialEmitColor();\n#endif\n\n#ifdef HAS_CAVITYPBR\n float materialCavity = getMaterialCavity();\n#endif\n\n vec3 diffuse = materialDiffuse;\n\n#ifdef HAS_AOPBR\n diffuse *= materialAO;\n#endif\n\n /////////////\n // REFRACTION\n /////////////\n#ifdef HAS_OPACITY_REFRACTION\n #ifdef HAS_REFRACTION_NORMAL_OFFSET\n vec3 refractLight = refraction(uOpacityRoughnessFactor, frontNormal, frontNormal);\n #else\n vec3 refractLight = refraction(uOpacityRoughnessFactor, frontNormal, eyeVector);\n #endif\n\n #ifdef HAS_REFRACTION_ALBEDO_TINT\n refractLight *= materialDiffuse;\n #endif\n\n diffuse = mix(refractLight, diffuse, alphaRefraction);\n#endif // HAS_OPACITY_REFRACTION\n\n vec3 frag = diffuse;\n\n#ifdef HAS_EMITCOLOR\n frag = uEmitMultiplicative == 1 ? frag * materialEmit : frag + materialEmit;\n#endif\n\n#ifdef HAS_CAVITYPBR\n frag *= materialCavity;\n#endif\n\n // premult\n#ifdef HAS_OPACITY_BLEND_OR_ADDITIVE\n frag *= alpha;\n#endif\n\n if (uOutputLinear != 1) frag = linearTosRGB(frag);\n\n#ifdef HAS_OPACITY_BLEND_OR_ADDITIVE\n gl_FragColor = uDrawOpaque == 1 ? encodeRGBM(frag, uRGBMRange) : vec4(frag, alphaFinal);\n#else\n gl_FragColor = encodeRGBM(frag, uRGBMRange);\n#endif\n}\n',"wireframe.vert":'#define WIREFRAME\n#pragma include "base.vert"\n',"wireframe.frag":"uniform vec4 uColor;\n\nvoid main() {\n gl_FragColor = vec4(uColor.rgb * uColor.a, uColor.a);\n}\n","inspector/inspector.vert":'#pragma include "base.vert"\n',"inspector/inspector.frag":'uniform float uRGBMRange;\nuniform int uOutputLinear;\n\n// stuffs (ssr, opacity, scattering)\nuniform vec4 uHalton;\nuniform vec2 uNearFar;\nuniform float uFrameMod;\nuniform int uDrawOpaque;\n\nuniform float uDisplay2D;\nuniform int uInspectorView; // see globalUniforms\n\nuniform float uInspectorFactor;\nuniform int uInspectorInvert;\nuniform float uInspectorMaskThreshold;\nuniform vec3 uInspectorColor;\n\nuniform vec2 uHoverUV;\nuniform int uInspectorSelected;\nuniform int uInspectorWireframe;\n\n#ifdef FEEDBACK_UV\n vec3 colorHoverUV(const in vec3 frag) {\n if (uInspectorSelected == 0) return frag;\n return mix(vec3(1.0, 0.0, 0.0), frag, smoothstep(0.01, 0.02, distance(FEEDBACK_UV, uHoverUV)));\n }\n#endif\n\n#pragma include "utils/functions.glsl"\n#pragma include "utils/material.glsl"\n#pragma include "utils/rand.glsl"\n\nvoid main() {\n //////////////////\n // OPACITY DISCARD\n //////////////////\n#ifdef HAS_POINT_CIRCLE\n if (length(2.0 * gl_PointCoord - 1.0) > 1.0) discard;\n#endif\n\n#ifdef HAS_ALPHAMASK\n if (getMaterialAlphaMask() < uAlphaMaskFactor) discard;\n#endif\n#ifdef HAS_OPACITY_DITHER\n if (uDisplay2D == 0.0) ditheringMaskingDiscard(gl_FragCoord, uOpacityDithering, getMaterialOpacity(), uOpacityFactor, uOpacityThinLayer, uFrameMod, uNearFar, uHalton);\n#endif\n\n#ifdef HAS_OPACITY_BLEND_OR_ADDITIVE\n float alpha = 1.0;\n float alphaFinal = 1.0;\n\n if (uDisplay2D == 0.0) {\n alpha = getMaterialOpacity();\n alphaFinal = alpha * float(1 - uOpacityAdditive);\n }\n\n if (alpha == 0.0 || (uDrawOpaque == 1 && alphaFinal < EPSILON_ALPHA) || (uDrawOpaque == 0 && alphaFinal >= EPSILON_ALPHA)) discard;\n#endif\n\n ///////////\n // MATERIAL\n ///////////\n vec3 frag = vec3(0.0);\n#ifdef HAS_INSPECTOR\n frag = uInspectorFactor * COLOR_CONVERT_INSPECTOR(texture2D(SAMPLER_INSPECTOR, UV_INSPECTOR).PACK_INSPECTOR);\n if (uInspectorInvert == 1) frag = 1.0 - frag;\n\n if (uInspectorMaskThreshold > 0.0 && uDisplay2D == 0.0) frag = frag.x < uInspectorMaskThreshold ? vec3(0.0) : vec3(1.0);\n\n #ifdef HAS_VERTEX_COLOR\n #ifdef HAS_VERTEX_ALPHA\n frag *= getVertexColor();\n #else\n frag *= uInspectorView == 1 ? sRGBToLinear(vColor.aaa) : getVertexColor();\n #endif\n #endif\n\n // we want to display the linear textures as srgb textures, see comment in channelFactoryViewModel\n #ifdef CONVERT_INSPECTOR_TO_LINEAR\n frag = sRGBToLinear(frag);\n #endif\n\n #ifdef HAS_INSPECTOR_TEXTURE\n frag *= uInspectorColor;\n #endif\n\n frag = colorHoverUV(frag);\n#endif\n\n // premult\n#ifdef HAS_OPACITY_BLEND_OR_ADDITIVE\n frag *= alpha;\n#endif\n\n if (uOutputLinear != 1) frag = linearTosRGB(frag);\n\n if (uDisplay2D == 1.0) {\n gl_FragColor = vec4(frag, 1.0);\n return;\n }\n\n#ifdef HAS_OPACITY_BLEND_OR_ADDITIVE\n gl_FragColor = uDrawOpaque == 1 ? encodeRGBM(frag, uRGBMRange) : vec4(frag, alphaFinal);\n#else\n gl_FragColor = encodeRGBM(frag, uRGBMRange);\n#endif\n}\n',"shadowing/shadowCast.vert":'uniform vec2 uShadowMapSize;\n#define SHADOW_CAST\n#define HAS_VIEW_VERTEX\n#pragma include "baseVert.glsl"\n',"shadowing/shadowCast.frag":'// opacity\nuniform vec4 uHalton;\nuniform vec2 uNearFar;\nuniform float uFrameMod;\nuniform int uDrawOpaque;\n\nuniform vec4 uShadowDepthRange;\n\nvarying vec4 vViewVertex;\n\n#pragma include "utils/material.glsl"\n\n#ifdef HAS_OPACITY\n#pragma include "utils/material.glsl"\n#pragma include "utils/rand.glsl"\n#endif\n\nvec4 encodeFloatRGBA( float v ) {\n vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * v;\n enc = fract(enc);\n enc -= enc.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\n return enc;\n}\n\nvoid main() {\n#ifdef HAS_ALPHAMASK\n if (getMaterialAlphaMask() < uAlphaMaskFactor) discard;\n#endif\n#ifdef HAS_OPACITY_DITHER\n ditheringMaskingDiscard(gl_FragCoord, uOpacityDithering, getMaterialOpacity(), uOpacityFactor, uOpacityThinLayer, uFrameMod, uNearFar, uHalton);\n#endif\n\n#if defined(HAS_OPACITY_BLEND_OR_ADDITIVE) || defined(HAS_OPACITY_REFRACTION)\n if (getMaterialOpacity() < EPSILON_ALPHA) discard;\n#endif\n\n gl_FragColor = encodeFloatRGBA((-vViewVertex.z - uShadowDepthRange.x) / (uShadowDepthRange.y - uShadowDepthRange.x));\n}\n',"ARKit/shadowAr.vert":'#pragma include "base.vert"\n',"ARKit/shadowAr.frag":'\n#pragma include "shadowing/shadowReceive.glsl"\n\nvarying vec3 vModelNormal;\nvarying vec3 vModelVertex;\n\nvoid main() {\n vec3 modelNormal = normalize(gl_FrontFacing ? vModelNormal : -vModelNormal);\n #ifdef _ATLAS_SHADOW\n float shadow = shadowReceive(true, modelNormal, vModelVertex, Texture7, uShadow_Texture0_renderSize, uShadow_Texture0_projection, uShadow_Texture0_viewRight, uShadow_Texture0_viewUp, uShadow_Texture0_viewLook, uShadow_Texture0_depthRange, uShadowReceive0_bias, uShadow_Texture0_mapSize, uStaticFrameNumShadow0);\n #else\n float shadow = shadowReceive(true, modelNormal, vModelVertex, Texture12, uShadow_Texture0_renderSize, uShadow_Texture0_projection, uShadow_Texture0_viewRight, uShadow_Texture0_viewUp, uShadow_Texture0_viewLook, uShadow_Texture0_depthRange, uShadowReceive0_bias, uStaticFrameNumShadow0);\n #endif\n\n // not much blending, so no need to convert to srgb\n // gl_FragColor = vec4(0.0, 0.0, 0.0, linearTosRGB(0.5 - shadow));\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.5 - shadow);\n}\n',"webVR/controller.vert":'#define HAS_VERTEX_COLOR\n#define HAS_VIEW_VERTEX\n#define HAS_VIEW_NORMAL\n#pragma include "base.vert"\n',"webVR/controller.frag":'#define MIN_ROUGHNESS 0.045\n\nuniform float uRGBMRange;\nuniform int uOutputLinear;\n\nvarying vec4 vViewVertex;\nvarying vec3 vViewNormal;\nvarying vec4 vColor;\n\nuniform float uNormalSign;\nuniform vec3 uAlbedo;\nuniform float uRoughness;\nuniform float uMetalness;\n\nvec3 lightDir = normalize(vec3(0.0, 0.3, 0.9));\nvec3 lightColor = vec3(0.7, 0.7, 0.9);\n\n#pragma include "utils/functions.glsl"\n\n#pragma include "utils/lightsPBR.glsl"\n\nvoid main() {\n vec3 eyeVector = -normalize(vViewVertex.xyz);\n vec3 materialNormal = uNormalSign * normalize(gl_FrontFacing ? vViewNormal : -vViewNormal);\n\n // material\n float f0 = 0.04;\n vec3 materialDiffuse = uAlbedo * vColor.r;\n vec3 materialSpecular = mix(vec3(f0), materialDiffuse, uMetalness);\n materialDiffuse *= 1.0 - uMetalness;\n float materialRoughness = max(MIN_ROUGHNESS, uRoughness);\n float materialF90 = clamp(50.0 * materialSpecular.g, 0.0, 1.0);\n\n // precompute light\n float attenuation, dotNL;\n vec3 eyeLightDir;\n bool lighted;\n vec3 lightSpecular;\n vec3 lightDiffuse;\n vec4 prepGGX = precomputeGGX(materialNormal, eyeVector, materialRoughness);\n\n // shading\n attenuation = 1.0;\n dotNL = dot(lightDir, materialNormal);\n computeLightLambertGGX(materialNormal, eyeVector, dotNL, prepGGX, materialDiffuse, materialSpecular, attenuation, lightColor, lightDir, materialF90, lightDiffuse, lightSpecular, lighted);\n\n vec3 frag = lightDiffuse + lightSpecular;\n if (uOutputLinear != 1) frag = linearTosRGB(frag);\n gl_FragColor = encodeRGBM(frag, uRGBMRange);\n}\n',"debug/boneBox.vert":'#define HAS_VIEW_NORMAL\n#pragma include "base.vert"\n',"debug/boneBox.frag":'uniform float uRGBMRange;\n\nvarying vec3 vViewNormal;\n\n#pragma include "utils/functions.glsl"\n\nvoid main(void) {\n gl_FragColor = encodeRGBM(0.5 * vec3(abs(dot(vViewNormal.xyz, vec3(0.3, 0.6, 0.9)))), uRGBMRange);\n}\n',"debug/normal.vert":'attribute float Offset;\nuniform float uScale;\n\n#define HAS_MODEL_VERTEX\n#define HAS_MODEL_NORMAL\n\n#define INJECT_VERT gl_Position = uProjectionMatrix * uViewMatrix * vec4(Offset == 1.0 ? vModelVertex + normalize(vModelNormal) * uScale : vModelVertex, 1.0);\n\n#pragma include "base.vert"\n',"debug/normal.frag":"uniform vec3 uColorDebug;\n\nvoid main(void) {\n gl_FragColor = vec4(uColorDebug, 1.0);\n}\n","debug/tangent.vert":'attribute float Offset;\nuniform float uScale;\n\n#define HAS_MODEL_VERTEX\n#define HAS_MODEL_TANGENT\n\n#define INJECT_VERT gl_Position = uProjectionMatrix * uViewMatrix * vec4(Offset == 1.0 ? vModelVertex + normalize(vModelTangent) * uScale : vModelVertex, 1.0);\n\n#pragma include "base.vert"\n',"debug/tangent.frag":"uniform vec3 uColorDebug;\n\nvoid main(void) {\n gl_FragColor = vec4(uColorDebug, 1.0);\n}\n","debug/skinning.vert":'attribute vec3 BonesColor;\nvarying vec3 vBonesColor;\n\n#define NO_JITTER\n#define INJECT_VERT vBonesColor = BonesColor;\n\n#pragma include "base.vert"\n',"debug/skinning.frag":"varying vec3 vBonesColor;\n\nvoid main(void) {\n gl_FragColor = vec4(vBonesColor, 1.0);\n}\n","debug/geometry.vert":'#define NO_JITTER\n#pragma include "base.vert"\n',"debug/geometry.frag":"uniform vec3 uColorDebug;\n\nvoid main(void) {\n gl_FragColor = vec4(uColorDebug, 1.0);\n}\n","ground/ground.vert":'#pragma include "base.vert"\n',"ground/ground.frag":'#pragma include "utils/encodeDepth.glsl"\nuniform vec2 uNearFar;\nvarying vec4 vViewVertex;\n\nuniform float uGroundFade;\nuniform float uGroundOpacity;\nuniform float uChanging;\n\nvarying vec2 vTexCoord0;\n\n#ifdef PASS_THROUGH\n float getShadow(){\n return 1.0;\n }\n#endif\n\n#ifdef SHADOW_CATCHER\n\n varying vec3 vModelNormal;\n varying vec3 vModelVertex;\n\n #define OPT_DISTANCE\n #pragma include "shadowing/shadowReceive.glsl"\n\n #pragma include "utils/getLuminance.glsl"\n\n %UNROLL 4%\n #ifdef LIGHT_TYPE_%ID%\n uniform vec4 uEditorLight%ID%_diffuse;\n #endif\n %%\n\n\n float getShadow(){\n float shadow = 0.0;\n vec3 modelNormal = normalize(gl_FrontFacing ? vModelNormal : -vModelNormal);\n bool lighted = true;\n\n float weight;\n float sumWeights = 0.0;\n\n %UNROLL 4%\n #ifdef LIGHT_TYPE_%ID%\n #ifdef HAS_SHADOW_%ID%\n weight = getLuminance(uEditorLight%ID%_diffuse.rgb);\n #ifdef _ATLAS_SHADOW\n shadow += weight * shadowReceive(lighted, modelNormal, vModelVertex, Texture7, uShadow_Texture0_renderSize, uShadow_Texture%ID%_projection, uShadow_Texture%ID%_viewRight, uShadow_Texture%ID%_viewUp, uShadow_Texture%ID%_viewLook, uShadow_Texture%ID%_depthRange, uShadowReceive%ID%_bias, uShadow_Texture%ID%_mapSize, OPT_DISTANCE uStaticFrameNumShadow%ID%);\n #else\n shadow += weight * shadowReceive(lighted, modelNormal, vModelVertex, TEX_SHADOW_%ID%, uShadow_Texture%ID%_renderSize, uShadow_Texture%ID%_projection, uShadow_Texture%ID%_viewRight, uShadow_Texture%ID%_viewUp, uShadow_Texture%ID%_viewLook, uShadow_Texture%ID%_depthRange, uShadowReceive%ID%_bias, OPT_DISTANCE uStaticFrameNumShadow%ID%);\n #endif // _ATLAS_SHADOW\n sumWeights += weight;\n #endif // HAS_SHADOW\n #endif // LIGHT_TYPE\n %%\n\n #ifdef HAS_SHADOW\n shadow /= sumWeights;\n #else\n shadow = 1.0;\n #endif\n\n return shadow;\n }\n#endif\n\n#ifdef BAKED_AO\n #pragma include "utils/encodeDecode.glsl"\n uniform sampler2D uTexture;\n\n float getShadow(){\n return decode24(texture2D(uTexture, vTexCoord0).rgb);\n }\n#endif\n\n#ifdef DISPLAY_PLANE\n const float gridSize = 10.0;\n const vec4 overlayColor = vec4(0.109,0.664,0.848,1.0);\n#endif\n\nuniform float uWidgetFade;\n\nvoid main() {\n float shadow = getShadow();\n #ifndef DISPLAY_PLANE\n\t if (shadow >= 0.99) discard;\n #endif\n vec2 centerUV = vTexCoord0 * 2.0 - 1.0;\n float fade = clamp(1.0 - dot(centerUV, centerUV) * (pow(10.0, uGroundFade) - 1.0) , 0.0, 1.0);\n\n float alpha = (1.0 - shadow) * uGroundOpacity * fade;\n gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0) * uGroundOpacity * fade * alpha;\n\n\n #ifdef DISPLAY_PLANE\n float gridValue = clamp(step(0.03,fract(vTexCoord0.x * gridSize))\n * step(0.03,fract(vTexCoord0.y * gridSize)),0.0,1.0)\n * step(vTexCoord0.x,0.997)\n * step(vTexCoord0.y,0.997);\n\n gl_FragColor = mix(overlayColor * fade, gl_FragColor, uWidgetFade) * vec4(gridValue,gridValue,gridValue,1.0);\n #endif\n\n}\n',"ground/bakeShadowMap.vert":'#pragma include "base.vert"\n',"ground/bakeShadowMap.frag":'#pragma include "utils/encodeDecode.glsl"\n\n// opacity\nuniform vec4 uHalton;\nuniform vec2 uNearFar;\nuniform float uFrameMod;\nuniform int uDrawOpaque;\n\n#ifdef HAS_OPACITY\n#pragma include "utils/material.glsl"\n#pragma include "utils/rand.glsl"\n#endif\n\nvoid main(void) {\n\n #ifdef HAS_ALPHAMASK\n if (getMaterialAlphaMask() < uAlphaMaskFactor) discard;\n #endif\n #ifdef HAS_OPACITY_DITHER\n ditheringMaskingDiscard(gl_FragCoord, uOpacityDithering, getMaterialOpacity(), uOpacityFactor, uOpacityThinLayer, uFrameMod, uNearFar, uHalton);\n #endif\n\n #if defined(HAS_OPACITY_BLEND_OR_ADDITIVE) || defined(HAS_OPACITY_REFRACTION)\n if (getMaterialOpacity() < EPSILON_ALPHA) discard;\n #endif\n\n // Depth in clip space\n float depth = gl_FragCoord.z / gl_FragCoord.w;\n gl_FragColor.rgb = encode24(depth);\n gl_FragColor.a = 1.0;\n\n}\n'},O={"passThrough.glsl":'#ifdef VR_DISTORTION\nuniform vec2 uDistortion;\nuniform vec4 uProjectionLeft;\nuniform vec4 uUnprojectionLeft;\n\n#pragma include "distortion.glsl"\n#endif\n\n#ifdef ASCII_FOOL\n#pragma include "ascii.glsl"\n#endif\n\nuniform sampler2D TextureInput;\n\nvec4 passThrough() {\n#ifdef VR_DISTORTION\n gTexCoord = distortion(gTexCoord);\n#endif\n\n#ifdef ASCII_FOOL\n return ascii(gTexCoord.xy);\n#else\n return TEXTURE_2D_TextureInput(gTexCoord);\n#endif\n}\n',"setDepthAlpha.glsl":'#pragma include "utils/decodeDepth.glsl"\n\nuniform sampler2D TextureInput;\nuniform sampler2D TextureDepth;\n\nuniform sampler2D TextureRefraction;\nuniform vec2 uTextureRefractionSize;\nuniform vec2 uTextureRefractionRatio;\n\n// no background scenario\nvec4 setDepthAlpha(const in vec4 color) {\n#ifdef REFRACTION_FORCE_ALPHA_ONE\n // detect if we are on a refraction pixel\n vec2 uvRef = min(gTexCoord, 1.0 - 1.0 / uTextureRefractionSize.xy);\n if (texture2D(TextureRefraction, uvRef * uTextureRefractionRatio).a > 0.0) return vec4(color.rgb, 1.0);\n#endif\n\n float alpha = decodeAlpha(TEXTURE_2D_TextureDepth(gTexCoord));\n return vec4(color.rgb, alpha);\n}',"combineOpacity.glsl":"uniform sampler2D TextureTransparent; \nfloat gTransparentAlpha;\n\nvec4 combineOpacity(const in vec4 color) {\n\t// should be replaced with TEXTURE_2D_TextureTransparent as is can make sense\n vec4 transparent = TEXTURE_2D_TextureTransparent(gTexCoord); \n gTransparentAlpha = transparent.a; \n return vec4(color.rgb * (1.0 - transparent.a) + transparent.rgb, 1.0);\n}","combineRefraction.glsl":"uniform sampler2D TextureInput;\nuniform sampler2D TextureRefraction;\n\nuniform vec2 uTextureRefractionSize;\nuniform vec2 uTextureRefractionRatio;\nuniform float uRGBMRange;\n\nvec4 combineRefraction() {\n // manual fetch to check m value of rgba : we use m 0 (invalid of rgbm) as masking\n vec2 uv = min(gTexCoord, 1.0 - 1.0 / uTextureRefractionSize.xy);\n vec4 rgbmRefraction = texture2D(TextureRefraction, uv * uTextureRefractionRatio);\n\n vec4 background = TEXTURE_2D_TextureInput(gTexCoord);\n if (rgbmRefraction.a == 0.0) return background;\n return vec4(decodeRGBM(rgbmRefraction, uRGBMRange), 1.0);\n}","packMipmapRefraction.glsl":"uniform sampler2D TextureRefractionBlur0;\nuniform sampler2D TextureRefractionBlur1;\nuniform sampler2D TextureRefractionBlur2;\nuniform sampler2D TextureRefractionBlur3;\nuniform sampler2D TextureRefractionBlur4;\nuniform sampler2D TextureRefractionBlur5;\nuniform sampler2D TextureRefractionBlur6;\nuniform sampler2D TextureRefractionBlur7;\nuniform vec2 uTextureOutputRatio;\n\nvec4 packMipmapRefraction() {\n vec4 result = vec4(0.0, 0.0, 0.0, 1.0);\n\n // see _hookComposerResize in NodePostProcess.js (mipmap)\n gTexCoord.y /= uTextureOutputRatio.y;\n\n float levelLog = -log2(1.0 - gTexCoord.y) + 1.0;\n float level = floor(levelLog) - 1.0;\n\n float pLevel = pow(2.0, level + 1.0); // 2, 4, 8, 16...\n gTexCoord.x = pLevel * gTexCoord.x * 0.5;\n gTexCoord.y = pLevel * (1.0 - gTexCoord.y) - 1.0;\n\n // unused part of the texture\n if (gTexCoord.x > 1.0 || gTexCoord.y > 1.0) return result;\n\n if (level < 0.1) result.rgb = TEXTURE_2D_TextureRefractionBlur0(gTexCoord).rgb;\n else if (level < 1.1) result.rgb = TEXTURE_2D_TextureRefractionBlur1(gTexCoord).rgb;\n else if (level < 2.1) result.rgb = TEXTURE_2D_TextureRefractionBlur2(gTexCoord).rgb;\n else if (level < 3.1) result.rgb = TEXTURE_2D_TextureRefractionBlur3(gTexCoord).rgb;\n else if (level < 4.1) result.rgb = TEXTURE_2D_TextureRefractionBlur4(gTexCoord).rgb;\n else if (level < 5.1) result.rgb = TEXTURE_2D_TextureRefractionBlur5(gTexCoord).rgb;\n else if (level < 6.1) result.rgb = TEXTURE_2D_TextureRefractionBlur6(gTexCoord).rgb;\n else if (level < 7.1) result.rgb = TEXTURE_2D_TextureRefractionBlur7(gTexCoord).rgb;\n\n return result;\n}\n","sssCommon.glsl":'#pragma include "utils/checkerboard.glsl"\n\n// blur jimenez\n// https://github.com/iryoku/separable-sss/blob/master/SeparableSSS.h#L454\n\n// blur UE4 (based on jimenez)\n// https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Shaders/SeparableSSS.usf\n\n// UE 4 pre/post passes (down/upsample/checkerboard)\n// https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Shaders/PostProcessSubsurface.usf\n\n// https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Shaders/Common.usf#L501\n// also solution 2 of http://stackoverflow.com/questions/596216/formula-to-determine-brightness-of-rgb-color\nfloat luminanceLinear(const in vec3 color) {\n return dot(color, vec3(0.3, 0.59, 0.11));\n}\n\n// https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Shaders/PostProcessSubsurface.usf#L247\nvoid uncheckerboard(out vec3 diffuse, out vec3 specular) {\n\n vec2 coordCenter = floor(gTexCoord * uTextureSSSColorSize) + 0.5;\n vec2 uvCenter = coordCenter / uTextureSSSColorSize;\n // not precomputing offset as 1.0/uTextureSSSColorSize.xy\n // to make sure we don\'t loose precision and end up with ABCD being same texel\n // on low precision gpu\n vec3 offset = vec3(1.0, 1.0, 0.0);\n\n vec3 A = TEXTURE_2D_TextureSSSColor((coordCenter + offset.xz)/ uTextureSSSColorSize.xy).rgb;\n vec3 B = TEXTURE_2D_TextureSSSColor((coordCenter - offset.xz)/ uTextureSSSColorSize.xy).rgb;\n vec3 C = TEXTURE_2D_TextureSSSColor((coordCenter + offset.zy)/ uTextureSSSColorSize.xy).rgb;\n vec3 D = TEXTURE_2D_TextureSSSColor((coordCenter - offset.zy)/ uTextureSSSColorSize.xy).rgb;\n\n // Luminance could be green channel only\n float a = luminanceLinear(A);\n float b = luminanceLinear(B);\n float c = luminanceLinear(C);\n float d = luminanceLinear(D);\n\n float ab = abs(a - b);\n float cd = abs(c - d);\n\n // take the average in the direction that avoids dither pattern\n vec3 quant1 = 0.5 * mix(A + B, C + D, ab > cd ? 1.0 : 0.0);\n vec3 quant0 = TEXTURE_2D_TextureSSSColor(uvCenter).rgb;\n\n float checker = checkerboard(coordCenter, uHalton);\n diffuse = mix(quant1, quant0, checker);\n specular = mix(quant0, quant1, checker);\n}\n\n',"sssExtract.glsl":'#pragma include "utils/decodeDepth.glsl"\n\nuniform sampler2D TextureSSSColor;\nuniform sampler2D TextureDepth;\nuniform vec2 uTextureSSSColorSize;\n\nuniform vec4 uHalton;\n\n#pragma include "sssCommon.glsl"\n\n// hacky line to force the composerPostprocess to\n// hook texture funciton in sssCommon because pragma defines\n// aren\'t handled directly\n\n// TEXTURE_2D_TextureSSSColor(whatever)\nvec4 sssExtract() {\n vec4 pack = TEXTURE_2D_TextureDepth(gTexCoord);\n vec3 specular;\n vec3 diffuse;\n uncheckerboard(diffuse, specular);\n\n // force depth "0.0" to tell sss blur to skip the pixel when blurring\n // make sure to return float not bool cast to float implicitely\n // not all glsl compiler support that\n float bgOrNotSSS = (decodeProfile(pack) == 0 || pack.x == 1.0) ? 0.0 : 1.0;\n return vec4(diffuse, bgOrNotSSS * decodeDepth(pack));\n}\n',"sssBlur.glsl":'#pragma include "utils/functions.glsl"\n#pragma include "utils/decodeDepth.glsl"\n#pragma include "utils/rand.glsl"\n\nuniform sampler2D TextureSSSBlur;\nuniform sampler2D TextureDepth;\nuniform sampler2D TextureSSSKernel;\n\nuniform vec2 uNearFar;\n\nuniform vec2 uBlurDir;\nuniform float uProjFactor;\nuniform float uScatteringFactorPacker;\nuniform float uFrameModTaaSS;\n\n#ifndef SSS_JITTER\n#define SSS_JITTER 1.0\n#endif\n\n#ifndef SSS_HALF_KERNEL_SIZE\n#define SSS_HALF_KERNEL_SIZE 11\n#endif\n\n#ifndef SSS_PROFILE_COUNT\n#define SSS_PROFILE_COUNT 1\n#endif\n\n#define SSS_FOLLOW_SURFACE\n\n// if we want to do it branchless\nvec3 sssFetchColorBranchless(const in vec2 uv, const in vec4 colorM, const in float depthNormBias){\n vec4 fetch = TEXTURE_2D_TextureSSSBlur(uv);\n\n#ifdef SSS_FOLLOW_SURFACE\n float mixer = smoothstep(0.0, 0.05, abs(colorM.a - fetch.a) * depthNormBias);\n mixer = mix(mixer, 1.0, step(fetch.a, 0.0)); // force to 1 if fetch.a is 0 (background)\n fetch.rgb = mix(fetch.rgb, colorM.rgb, mixer);\n#endif\n\n // uv inside box\n // https://stackoverflow.com/questions/12751080/glsl-point-inside-box-test\n vec2 s = step(vec2(0.0), uv) - step(vec2(1.0), uv);\n return mix(colorM.rgb, fetch.rgb, s.x * s.y);\n}\n\nvec3 sssFetchColor(const in vec2 uv, const in vec4 colorM, const in float depthNormBias){\n if (uv.x < 0.0 || uv.y < 0.0 || uv.x > 1.0 || uv.y > 1.0) {\n return colorM.rgb;\n }\n\n // ignore sss with big depth difference, original jimenez is clamp(dDiff, 0.0, 1.0)\n // we use a much more aggressive function\n vec4 fetch = TEXTURE_2D_TextureSSSBlur(uv);\n\n#ifdef SSS_FOLLOW_SURFACE\n if (fetch.a == 0.0) return colorM.rgb;\n return mix(fetch.rgb, colorM.rgb, smoothstep(0.0, 0.05, abs(colorM.a - fetch.a) * depthNormBias));\n#else\n return fetch.rgb;\n#endif\n}\n\nvec4 sssBlur() {\n vec4 colorM = TEXTURE_2D_TextureSSSBlur(gTexCoord);\n\n vec4 pack = TEXTURE_2D_TextureDepth(gTexCoord);\n\n // background or not sss stuffs\n if (pack.x == 1.0) {\n return colorM;\n }\n\n int profile = decodeProfile(pack);\n float scatter = decodeScatter(pack);\n if (scatter == 0.0) {\n return colorM;\n }\n\n float scatterWorld = scatter / uScatteringFactorPacker;\n float depthRange = (uNearFar.y - uNearFar.x);\n\n // for follow surface\n // factor to get a normalized depth difference depending of scatter but not of camera position\n float depthNormBias = depthRange * 0.05 / scatterWorld;\n\n float worldPos = uNearFar.x + depthRange * colorM.a;\n // uScatteringFactorPacker is just a unpacking factor because subsurface factor \n // is a world space value but written in 8 bit texture\n vec2 finalStep = uBlurDir * uProjFactor * scatterWorld / worldPos;\n finalStep *= 1.0 / 3.0;\n\n float yProfile = 1.0 - (float(profile) - 0.5) / float(SSS_PROFILE_COUNT);\n float xKernelSize = 1.0 / float(SSS_HALF_KERNEL_SIZE);\n\n vec3 kernel0 = texture2D(TextureSSSKernel, vec2(xKernelSize * 0.5, yProfile)).rgb;\n vec3 colorBlurred = colorM.rgb * kernel0;\n\n // force nearest sample for sss texture kernel color\n vec2 offKernelNearest = vec2(0.5 * xKernelSize, 0.0);\n\n // randomize the sss texture alpha weight a bit\n float rnd = interleavedGradientNoise(gl_FragCoord.xy, uFrameModTaaSS);\n rnd = mix(0.5, rnd, SSS_JITTER);\n vec2 offKernelJitter = vec2(rnd * xKernelSize, 0.0);\n\n for (int i = 1; i < SSS_HALF_KERNEL_SIZE; i++) {\n vec2 uvKernel = vec2(float(i) * xKernelSize, yProfile);\n\n vec3 kernel = texture2D(TextureSSSKernel, uvKernel + offKernelNearest).rgb;\n float kernelDither = texture2D(TextureSSSKernel, uvKernel + offKernelJitter).a;\n\n vec2 offset = kernelDither * finalStep;\n\n vec3 fetch = sssFetchColor(gTexCoord + offset, colorM, depthNormBias);\n fetch += sssFetchColor(gTexCoord - offset, colorM, depthNormBias);\n\n colorBlurred += kernel.rgb * fetch;\n }\n\n return vec4(colorBlurred, colorM.a);\n}\n',"sssCombine.glsl":'#pragma include "utils/decodeDepth.glsl"\n\nuniform sampler2D TextureSSSColor;\nuniform vec2 uTextureSSSColorSize;\n\nuniform vec4 uHalton;\nuniform vec2 uNearFar;\nuniform float uProjFactor;\nuniform float uScatteringFactorPacker;\n\n#pragma include "sssCommon.glsl"\n\nuniform sampler2D TextureSSSBlur;\nuniform sampler2D TextureDepth;\n\nvec4 sssCombine() {\n\n // full res - not SSS\n vec4 pack = TEXTURE_2D_TextureDepth(gTexCoord);\n int profile = decodeProfile(pack);\n // black pixels for background or non sss surfaces\n if (pack.x == 1.0 || profile == 0) {\n return TEXTURE_2D_TextureSSSColor(gTexCoord);\n }\n\n vec3 specular;\n vec3 diffuse;\n uncheckerboard(diffuse, specular);\n\n // try to retain high res detail as much as possible (same ad dof)\n // make sure to use a factor that is independent from bounding box\n float scatterWorld = decodeScatter(pack) / uScatteringFactorPacker;\n float worldPos = uNearFar.x + (uNearFar.y - uNearFar.x) * decodeDepth(pack);\n float factor = uProjFactor * scatterWorld / worldPos;\n\n // magic factor 10 (can be tweaked, e.g: if sss effects disappears too fast when we are far away)\n factor = smoothstep(0.05, 0.3, factor * 10.0);\n // return vec4(vec3(factor), 1.0);\n\n diffuse = mix(diffuse, TEXTURE_2D_TextureSSSBlur(gTexCoord).rgb, factor);\n\n return vec4(diffuse + specular, 1.0);\n}\n',"packMipmapDepth.glsl":'#pragma include "utils/encodeDecode.glsl"\n#pragma include "utils/decodeDepth.glsl"\n\nuniform sampler2D TextureDepth0;\nuniform sampler2D TextureDepth1;\nuniform sampler2D TextureDepth2;\nuniform sampler2D TextureDepth3;\nuniform sampler2D TextureDepth4;\nuniform sampler2D TextureDepth5;\nuniform vec2 uTextureOutputRatio;\n\nvec4 packMipmapDepth() {\n vec4 result = vec4(0.0, 0.0, 0.0, 0.0);\n\n // see _hookComposerResize in NodePostProcess.js (mipmap)\n gTexCoord.y /= uTextureOutputRatio.y;\n\n float levelLog = -log2(1.0 - gTexCoord.y) + 1.0;\n float level = floor(levelLog) - 1.0;\n\n float pLevel = pow(2.0, level + 1.0); // 2, 4, 8, 16...\n gTexCoord.x = pLevel * gTexCoord.x * 0.5;\n gTexCoord.y = pLevel * (1.0 - gTexCoord.y) - 1.0;\n\n // unused part of the texture\n if (gTexCoord.x > 1.0 || gTexCoord.y > 1.0) return result;\n\n if (level < 0.1) result.rgba = vec4(encode24(decodeDepth(TEXTURE_2D_TextureDepth0(gTexCoord))), 1.0);\n else if (level < 1.1) result.rgba = TEXTURE_2D_TextureDepth1(gTexCoord);\n else if (level < 2.1) result.rgba = TEXTURE_2D_TextureDepth2(gTexCoord);\n else if (level < 3.1) result.rgba = TEXTURE_2D_TextureDepth3(gTexCoord);\n else if (level < 4.1) result.rgba = TEXTURE_2D_TextureDepth4(gTexCoord);\n else if (level < 5.1) result.rgba = TEXTURE_2D_TextureDepth5(gTexCoord);\n\n return result;\n}\n',"depthMipmap.glsl":'#pragma include "utils/encodeDecode.glsl"\n#pragma include "utils/decodeDepth.glsl"\n\nuniform sampler2D TextureDepth;\nuniform int uFirstDepth;\n\nuniform vec2 uTextureDepthSize;\nuniform vec2 uTextureOutputSize;\n\n// For some reasons it requires unpacking *and* repacking to avoid transition between mipmap\nvec4 depthMipmap() {\n vec2 invSize = 1.0 / uTextureDepthSize;\n vec4 depths;\n vec2 offDepth = vec2(0.25, -0.25);\n if (uFirstDepth == 1) {\n depths.x = decodeDepth(TEXTURE_2D_TextureDepth(gTexCoord + offDepth.yy * invSize));\n depths.y = decodeDepth(TEXTURE_2D_TextureDepth(gTexCoord + offDepth.xy * invSize));\n depths.z = decodeDepth(TEXTURE_2D_TextureDepth(gTexCoord + offDepth.yx * invSize));\n depths.w = decodeDepth(TEXTURE_2D_TextureDepth(gTexCoord + offDepth.xx * invSize));\n } else {\n depths.x = decode24(TEXTURE_2D_TextureDepth(gTexCoord + offDepth.yy * invSize).xyz);\n depths.y = decode24(TEXTURE_2D_TextureDepth(gTexCoord + offDepth.xy * invSize).xyz);\n depths.z = decode24(TEXTURE_2D_TextureDepth(gTexCoord + offDepth.yx * invSize).xyz);\n depths.w = decode24(TEXTURE_2D_TextureDepth(gTexCoord + offDepth.xx * invSize).xyz);\n }\n\n return vec4(encode24(min(min(depths.x, depths.y), min(depths.z, depths.w))), 1.0);\n}\n',"ssaoExtract.glsl":'#pragma include "utils/encodeDecode.glsl"\n#pragma include "utils/rand.glsl"\n\nuniform sampler2D TextureMipmapDepth;\nuniform vec2 uTextureMipmapDepthSize;\nuniform vec2 uTextureMipmapDepthRatio;\n\nuniform float uQuality; // mipmap usage\n\nuniform vec2 uTextureOutputSize;\n\nuniform float uSsaoRadius;\nuniform float uSsaoIntensity;\nuniform float uSsaoBias;\nuniform vec4 uSsaoProjectionInfo;\nuniform float uSsaoProjectionScale;\n\nuniform vec2 uNearFar;\n\nuniform float uFrameModTaaSS;\n\n// Constant used to scale the depth view value that is given to the blur pass\n#define MIN_RADIUS 1.0\n#define NB_SPIRAL_TURNS 3.0\n\nvec4 fetchDepthPackLevel(const in vec2 uv, const in float level){\n float maxLod = 5.0;\n float powLevel = pow(2.0, min(maxLod, floor(level)) + 1.0);\n vec2 pixelSize = 2.0 * powLevel / uTextureMipmapDepthSize;\n\n vec2 uvFetch = max(pixelSize, min(1.0 - pixelSize, uv));\n uvFetch = vec2(2.0 * uvFetch.x, powLevel - 1.0 - uvFetch.y) * uTextureMipmapDepthRatio.xy / powLevel;\n\n return texture2D(TextureMipmapDepth, uvFetch);\n}\n\nfloat fetchDepthLevel(const in vec2 uv, const in float level){\n return decode24(fetchDepthPackLevel(uv, level).xyz);\n}\n\nfloat zValueFromScreenSpacePosition(const in float depth) {\n return uNearFar.x + (uNearFar.y - uNearFar.x) * depth;\n}\n\nvec3 reconstructCSPosition(const in vec2 ssP, const in float z) {\n return vec3((ssP.xy * uSsaoProjectionInfo.xy + uSsaoProjectionInfo.zw) * z, z);\n}\n\nvec3 getPosition(const in vec2 uv) {\n return reconstructCSPosition(uv * uTextureOutputSize, zValueFromScreenSpacePosition(fetchDepthLevel(uv, 0.0)));\n}\n\n#define MAX_MIP_LEVEL 5\n// Determines at which point we should switch mip level\n// if number is too small (~3) will lead to flashing (bad variance as many taps give same pixel)\n// if number is too high, mip level are not used well and the cache is not used efficiently\n#define LOG_MAX_OFFSET 3\n\nvec3 getOffsetedPixelPos(\n const in vec2 uv,\n const in vec2 unitOffset,\n const in float screenSpaceRadius) {\n\n float mipLevel = clamp(floor(log2(screenSpaceRadius)) - float(LOG_MAX_OFFSET), 0.0, float(MAX_MIP_LEVEL));\n vec2 uvOff = uv + floor(screenSpaceRadius * unitOffset) / uTextureOutputSize;\n\n float d = zValueFromScreenSpacePosition(fetchDepthLevel(uvOff, mipLevel));\n return reconstructCSPosition(uvOff * uTextureOutputSize, d);\n}\n\n#define PIOVER8 0.39269908169\nvec3 unpackNormal1(const in float pack1) {\n float pack8 = floor(pack1 * 255.0);\n float th = PIOVER8 * float(pack8 / 16.0);\n float len = sqrt(mod(float(pack8), 16.0) / 15.001);\n vec2 nv = vec2(cos(th), sin(th)) * len;\n return -vec3(nv.x, nv.y, sqrt(max(0.0, 1.0 - nv.x * nv.x - nv.y * nv.y)));\n}\n\nvec3 unpackNormal2(const in vec2 pack2) {\n vec3 nv = pack2.rgg * 2.0 - 1.0;\n return -vec3(nv.x, nv.y, sqrt(max(0.0, 1.0 - nv.x * nv.x - nv.y * nv.y)));\n}\n\n#define SSAO_TAP_EXTRACT(id) screenSpaceRadius = (float(id) + 0.5) * (1.0 / nbSamples); \\\n angle = screenSpaceRadius * (NB_SPIRAL_TURNS * 6.28) + randomAngle; \\\n screenSpaceRadius = max(0.75, screenSpaceRadius * ssRadius); \\\n offsetUnitVec = vec2(cos(angle), sin(angle)); \\\n occludingPoint = getOffsetedPixelPos(uv, offsetUnitVec, screenSpaceRadius); \\\n occludingPoint -= cameraSpacePosition; \\\n vv = dot(occludingPoint, occludingPoint); \\\n vn = dot(occludingPoint, normal); \\\n contrib += max(1.0 - vv * invRadius2, 0.0) * max((vn - uSsaoBias) * inversesqrt(vv), 0.0); \\\n\n#define SSAO_DO_TAPS(void) SSAO_TAP_EXTRACT(offset + 0); \\\n SSAO_TAP_EXTRACT(offset + 1); \\\n SSAO_TAP_EXTRACT(offset + 2); \\\n SSAO_TAP_EXTRACT(offset + 3); \\\n SSAO_TAP_EXTRACT(offset + 4); \\\n SSAO_TAP_EXTRACT(offset + 5); \\\n SSAO_TAP_EXTRACT(offset + 6); \\\n SSAO_TAP_EXTRACT(offset + 7); \\\n SSAO_TAP_EXTRACT(offset + 8); \\\n SSAO_TAP_EXTRACT(offset + 9); \\\n SSAO_TAP_EXTRACT(offset + 10); \\\n offset += 11; \\\n\n\nvec4 ssaoExtract() {\n vec2 uv = gTexCoord;\n\n vec3 depthPacked = fetchDepthPackLevel(uv, 0.0).xyz;\n\n vec3 cameraSpacePosition = getPosition(uv);\n float ssRadius = -uSsaoProjectionScale * uSsaoRadius / cameraSpacePosition.z;\n\n#ifdef SSAO_NORMAL\n vec3 normal = unpackNormal2(TEXTURE_2D_TextureDepth(uv).ba); // g buffer normal 2 component on ba\n#elif defined(GL_OES_standard_derivatives) && !defined(MOBILE)\n vec3 normal = cross(dFdy(cameraSpacePosition), dFdx(cameraSpacePosition));\n#else\n vec2 offDepth = vec2(1.0, 0.0);\n vec3 depthLeft = getPosition(uv - offDepth.xy / uTextureMipmapDepthSize);\n vec3 depthRight = getPosition(uv + offDepth.xy / uTextureMipmapDepthSize);\n vec3 depthBottom = getPosition(uv - offDepth.yx / uTextureMipmapDepthSize);\n vec3 depthTop = getPosition(uv + offDepth.yx / uTextureMipmapDepthSize);\n vec3 normal = cross(depthLeft - depthRight, depthTop - depthBottom);\n#endif\n\n // early returns should be done derivatives usage to avoid bad edges\n\n // early return background\n if (depthPacked.x == 1.0) {\n return vec4(depthPacked, 1.0);\n }\n\n // early return radius too small (note: needs to be in separate conditional because of nvidia/osx bug)\n if (ssRadius < MIN_RADIUS) {\n return vec4(depthPacked, 1.0);\n }\n\n normal = normalize(normal);\n float nFalloff = mix(1.0, max(0.0, 1.5 * normal.z), 0.35);\n\n // needs to be > 2PI\n float randomAngle = 6.28 * interleavedGradientNoise(gl_FragCoord.xy, uFrameModTaaSS);\n float invRadius2 = 1.0 / (uSsaoRadius * uSsaoRadius);\n float contrib = 0.0;\n\n float vv;\n float vn;\n float screenSpaceRadius;\n float angle;\n vec3 occludingPoint;\n vec2 offsetUnitVec;\n int offset = 0;\n\n float nbSamples = 11.0;\n\n if (uQuality > 0.33) nbSamples += 11.0;\n#ifndef MOBILE\n if (uQuality > 0.66) nbSamples += 11.0;\n#endif\n\n SSAO_DO_TAPS();\n if (uQuality > 0.33) { SSAO_DO_TAPS(); }\n#ifndef MOBILE\n if (uQuality > 0.66) { SSAO_DO_TAPS(); }\n#endif\n\n float aoValue = max(0.0, 1.0 - sqrt(contrib * nFalloff / nbSamples));\n aoValue = pow(aoValue, 10.0 * uSsaoIntensity);\n\n vec4 aoDepth;\n aoDepth.rgb = depthPacked;\n aoDepth.a = mix(1.0, aoValue, clamp(ssRadius - MIN_RADIUS, 0.0, 1.0));\n\n return aoDepth;\n}\n',"ssaoBlur.glsl":'#pragma include "utils/encodeDecode.glsl"\n\nuniform sampler2D TextureBlurInput;\nuniform vec2 uTextureBlurInputSize;\n\n#define SSAO_FILTER_RADIUS 3\n\n#define SSAO_TAP_BLUR(id, absid) sampleTex = TEXTURE_2D_TextureBlurInput(uv + axis * float(id) * 2.0); \\\n z = decode24(sampleTex.xyz); \\\n weight = max(0.0, 1.0 - sharpnessFactor * abs(z - initialZ)) * (0.3 + gaussian[absid]); \\\n sum += weight * sampleTex.a; \\\n totalWeight += weight;\n\nvec4 ssaoBlur(const in vec2 axis) {\n vec2 uv = gTexCoord;\n\n vec4 aoDepth = TEXTURE_2D_TextureBlurInput(uv);\n\n // background\n if(aoDepth.x == 1.0){\n return aoDepth;\n }\n\n float initialZ = decode24(aoDepth.xyz);\n\n float gaussian[SSAO_FILTER_RADIUS + 2]; // dummy because of intel off-by-one bug\n gaussian[0] = 0.153170;\n gaussian[1] = 0.144893;\n gaussian[2] = 0.122649;\n gaussian[3] = 0.092902;\n gaussian[4] = 0.0;\n\n float totalWeight = gaussian[0];\n float sum = aoDepth.a * totalWeight;\n float sharpnessFactor = 400.0;\n\n // ---- UNROLL ----\n vec2 ofs;\n float z;\n float weight;\n vec4 sampleTex;\n\n SSAO_TAP_BLUR(-3, 3);\n SSAO_TAP_BLUR(-2, 2);\n SSAO_TAP_BLUR(-1, 1);\n SSAO_TAP_BLUR(1, 1);\n SSAO_TAP_BLUR(2, 2);\n SSAO_TAP_BLUR(3, 3);\n // ---- UNROLL ----\n\n aoDepth.a = sum / totalWeight;\n return aoDepth;\n}\n\n#ifdef SSAO_BLUR_H\nvec4 ssaoBlurH() {\n return ssaoBlur(vec2(1.0, 0.0) / uTextureBlurInputSize);\n}\n#else\nvec4 ssaoBlurV() {\n vec3 color = TEXTURE_2D_TextureInput(gTexCoord).rgb;\n return vec4(color * ssaoBlur(vec2(0.0, 1.0) / uTextureBlurInputSize).aaa, 1.0);\n}\n#endif',"dofCommon.glsl":'#pragma include "utils/decodeDepth.glsl"\n\nconst float MAX_BLUR = 16.0;\nconst float EPS_EARLY_OUT = 0.01; // early out (typically when we move the camera fast and the dof might be not effective)\n\nfloat texDepthToCoC(const in vec4 fetch) {\n // background should be always max blurred so that the near blur can expand onto the background (because of special dilate background codepath below)\n if(fetch.x == 1.0) return max(uDofBlurNearFarFocal.x, uDofBlurNearFarFocal.y);\n\n float coc = decodeDepth(fetch);\n coc = clamp((coc - uDofBlurNearFarFocal.z) / coc, -1.0, 1.0);\n return (coc < 0.0 ? coc * uDofBlurNearFarFocal.x : coc * uDofBlurNearFarFocal.y);\n}',"dofCoC.glsl":'uniform vec3 uDofBlurNearFarFocal;\n\n#pragma include "dofCommon.glsl"\n\nuniform sampler2D TextureDepth;\n\nvec4 dofCoC() {\n if(uDofBlurNearFarFocal.x < EPS_EARLY_OUT && uDofBlurNearFarFocal.y < EPS_EARLY_OUT){\n return vec4(0.0);\n }\n\n return vec4(vec3(0.0), texDepthToCoC(TEXTURE_2D_TextureDepth(gTexCoord)) * 0.5 + 0.5);\n}',"dofNearDilate.glsl":'uniform vec3 uDofBlurNearFarFocal;\n\n#pragma include "dofCommon.glsl"\n\nuniform sampler2D TextureDofCoC;\nuniform vec2 uTextureDofCoCSize;\nuniform sampler2D TextureDepth;\n\nuniform float uDofScale;\n\nvec4 dilateNear(const in vec2 offset) {\n if(uDofBlurNearFarFocal.x < EPS_EARLY_OUT && uDofBlurNearFarFocal.y < EPS_EARLY_OUT){\n return vec4(0.0);\n }\n\n // TODO DOF both the weights and the formula can be tweaked, also we could add a bit of jitter or something\n vec2 uv = gTexCoord;\n bool isBG = TEXTURE_2D_TextureDepth(uv).x == 1.0;\n\n float coc = 0.0;\n vec2 ofs = MAX_BLUR * offset / 5.0;\n\n float coc0 = TEXTURE_2D_TextureDofCoC(uv).a * 2.0 - 1.0;\n float coc1 = TEXTURE_2D_TextureDofCoC(uv - 5.0 * ofs).a * 2.0 - 1.0;\n float coc2 = TEXTURE_2D_TextureDofCoC(uv - 4.0 * ofs).a * 2.0 - 1.0;\n float coc3 = TEXTURE_2D_TextureDofCoC(uv - 3.0 * ofs).a * 2.0 - 1.0;\n float coc4 = TEXTURE_2D_TextureDofCoC(uv - 2.0 * ofs).a * 2.0 - 1.0;\n float coc5 = TEXTURE_2D_TextureDofCoC(uv - 1.0 * ofs).a * 2.0 - 1.0;\n float coc6 = TEXTURE_2D_TextureDofCoC(uv + 1.0 * ofs).a * 2.0 - 1.0;\n float coc7 = TEXTURE_2D_TextureDofCoC(uv + 2.0 * ofs).a * 2.0 - 1.0;\n float coc8 = TEXTURE_2D_TextureDofCoC(uv + 3.0 * ofs).a * 2.0 - 1.0;\n float coc9 = TEXTURE_2D_TextureDofCoC(uv + 4.0 * ofs).a * 2.0 - 1.0;\n float coc10 = TEXTURE_2D_TextureDofCoC(uv + 5.0 * ofs).a * 2.0 - 1.0;\n\n if(isBG == true){\n // avoid "shrink" effect on the out of focus far part on the model edges\n // gaussian weights (sigma 10), (doesn\'t have to be gaussian though), but the sum must be 1.0\n // http://dev.theomader.com/gaussian-kernel-calculator/\n coc = abs(coc0) * 0.095474 +\n (abs(coc1) + abs(coc10)) * 0.084264 +\n (abs(coc2) + abs(coc9)) * 0.088139 +\n (abs(coc3) + abs(coc8)) * 0.091276 +\n (abs(coc4) + abs(coc7)) * 0.093585 +\n (abs(coc5) + abs(coc6)) * 0.094998;\n } else {\n // blur only near field (expand)\n coc = min(coc0, 0.0);\n coc = min(coc1 * 0.3, coc);\n coc = min(coc2 * 0.5, coc);\n coc = min(coc3 * 0.75, coc);\n coc = min(coc4 * 0.8, coc);\n coc = min(coc5 * 0.95, coc);\n coc = min(coc6 * 0.95, coc);\n coc = min(coc7 * 0.8, coc);\n coc = min(coc8 * 0.75, coc);\n coc = min(coc9 * 0.5, coc);\n coc = min(coc10 * 0.3, coc);\n if(abs(coc0) > abs(coc)) coc = coc0;\n }\n\n return vec4(0.0, 0.0, 0.0, coc * 0.5 + 0.5);\n}\n\nvec4 dofNearDilateH() {\n vec2 offset = vec2(uDofScale / uTextureDofCoCSize.x, 0.0);\n return dilateNear(offset);\n}\n\nvec4 dofNearDilateV() {\n vec2 offset = vec2(0.0, uDofScale / uTextureDofCoCSize.y);\n return dilateNear(offset);\n}',"dofDownsampleColor.glsl":"uniform sampler2D TextureInput;\n\n#ifdef COLOR_WITH_COC\nuniform sampler2D TextureDofCoC;\n#endif\n\nvec4 dofDownsampleColor() {\n vec2 uv = gTexCoord;\n\n vec4 color = TEXTURE_2D_NEAREST_TextureInput(uv);\n\n// premult with coc buffer\n#ifdef COLOR_WITH_COC\n color.a = abs(TEXTURE_2D_TextureDofCoC(uv).a * 2.0 - 1.0);\n color.a *= color.a * color.a;\n color.rgb *= color.a;\n#endif\n\n return color;\n}","dofBlurCircular.glsl":'#pragma include "utils/rand.glsl"\n\nuniform vec3 uDofBlurNearFarFocal;\n#pragma include "dofCommon.glsl"\n\nuniform sampler2D TextureDofColor;\nuniform vec2 uTextureDofColorSize;\n\n#ifndef COLOR_WITH_COC\nuniform sampler2D TextureDofCoC;\nuniform vec2 uTextureDofCoCSize;\n#endif\n\nuniform float uDofScale;\nuniform float uQuality;\n\nuniform float uFrameModTaaSS;\n\n#ifdef COLOR_WITH_COC\n#define DOF_TAP(id) ofs = fTaps_Poisson[id]; \\\n ofs = gTexCoord + blurDist * vec2(dot(ofs, basis.xy), dot(ofs, basis.zw) ); \\\n sumcol += TEXTURE_2D_TextureDofColor(ofs);\n#else\n#define DOF_TAP(id) ofs = fTaps_Poisson[id]; \\\n ofs = gTexCoord + blurDist * vec2(dot(ofs, basis.xy), dot(ofs, basis.zw) ); \\\n cocWeight = abs(TEXTURE_2D_TextureDofCoC(ofs).a * 2.0 - 1.0); \\\n cocWeight *= cocWeight * cocWeight; \\\n sumcol.rgb += TEXTURE_2D_TextureDofColor(ofs).rgb * cocWeight; \\\n sumcol.a += cocWeight;\n#endif\n\nvec4 dofBlur16(const in vec2 blurDist, const in float ntime) {\n float rnd = 6.28 * ditheringNoise(gl_FragCoord.xy, uFrameModTaaSS + ntime);\n\n float cosa = cos(rnd);\n float sina = sin(rnd);\n vec4 basis = vec4(cosa, -sina, sina, cosa);\n\n vec4 sumcol = vec4(0.0);\n\n float total = 0.0;\n\n vec2 fTaps_Poisson[17];\n // https://github.com/bartwronski/PoissonSamplingGenerator\n fTaps_Poisson[0] = vec2(0.343280198355, 0.921191856785);\n fTaps_Poisson[1] = vec2(-0.116859107262, 0.873056831344);\n fTaps_Poisson[2] = vec2(-0.646421287853, 0.760425284853);\n fTaps_Poisson[3] = vec2(-0.0437332058416, 0.47196719804);\n fTaps_Poisson[4] = vec2(0.48240473891, 0.464894594736);\n fTaps_Poisson[5] = vec2(-0.718897237297, 0.352191304304);\n fTaps_Poisson[6] = vec2(-0.939061387886, -0.0387376698953);\n fTaps_Poisson[7] = vec2(0.546569494557, -0.0169516524446);\n fTaps_Poisson[8] = vec2(-0.182644095652, -0.0702667761349);\n fTaps_Poisson[9] = vec2(-0.576191305396, -0.252368997099);\n fTaps_Poisson[10] = vec2(0.921914032366, -0.366530187909);\n fTaps_Poisson[11] = vec2(-0.0582053944545, -0.510617206206);\n fTaps_Poisson[12] = vec2(-0.783101528934, -0.601411360136);\n fTaps_Poisson[13] = vec2(0.430604354377, -0.729559481383);\n fTaps_Poisson[14] = vec2(-0.350716524868, -0.809522919973);\n fTaps_Poisson[15] = vec2(0.0600898835968, -0.952568587297);\n fTaps_Poisson[16] = vec2(0.0, 0.0); // dummy because of intel off-by-one bug\n\n vec2 ofs;\n vec4 sampleTex;\n float cocWeight;\n\n DOF_TAP(0);\n DOF_TAP(1);\n DOF_TAP(2);\n DOF_TAP(3);\n DOF_TAP(4);\n DOF_TAP(5);\n DOF_TAP(6);\n DOF_TAP(7);\n DOF_TAP(8);\n DOF_TAP(9);\n DOF_TAP(10);\n DOF_TAP(11);\n DOF_TAP(12);\n DOF_TAP(13);\n DOF_TAP(14);\n DOF_TAP(15);\n\n return sumcol;\n}\n\nvec4 dofBlurCircular() {\n if(uDofBlurNearFarFocal.x < EPS_EARLY_OUT && uDofBlurNearFarFocal.y < EPS_EARLY_OUT) {\n return vec4(0.0);\n }\n\n float factor = MAX_BLUR * uDofScale;\n\n#ifdef COLOR_WITH_COC\n vec2 blurDist = factor * pow(TEXTURE_2D_TextureDofColor(gTexCoord).a, 0.333) / uTextureDofColorSize;\n#else\n vec2 blurDist = factor * abs(TEXTURE_2D_TextureDofCoC(gTexCoord).a * 2.0 - 1.0) / uTextureDofCoCSize;\n#endif\n\n // TODO optimize dofBlur16 (unroll...)\n vec4 sumcol = dofBlur16(blurDist, 0.0); // 16\n if (uQuality > 0.33) sumcol += dofBlur16(blurDist, 3.0); // 32\n if (uQuality > 0.66) sumcol += dofBlur16(blurDist, 5.0); // 48\n\n return vec4(sumcol.rgb / sumcol.a, 1.0);\n}\n',"dofCombine.glsl":'uniform vec3 uDofBlurNearFarFocal;\n\n#pragma include "dofCommon.glsl"\n\nuniform sampler2D TextureInput;\nuniform sampler2D TextureDofBlurCircular;\nuniform sampler2D TextureDofNearDilateV;\nuniform sampler2D TextureDepth;\n\nuniform vec2 uTextureDofNearDilateVSize;\nuniform vec2 uTextureDofBlurCircularSize;\n\nuniform float uDofScale;\n\nvec4 dofCombine() {\n vec2 uv = gTexCoord;\n vec3 color = TEXTURE_2D_TextureInput(uv).rgb;\n\n if(uDofBlurNearFarFocal.x < EPS_EARLY_OUT && uDofBlurNearFarFocal.y < EPS_EARLY_OUT){\n return vec4(color, 1.0);\n }\n\n vec4 depthPacked = TEXTURE_2D_TextureDepth(uv);\n\n // half res color\n vec3 blur;\n // no bilinear for background pixels because it can displays artefacts on low frequency due to rgbm bilinear fetching\n if (depthPacked.x == 1.0) {\n blur = TEXTURE_2D_NEAREST_TextureDofBlurCircular(uv).rgb;\n vec2 off = vec2(1.0, -1.0) * uDofScale;\n blur += TEXTURE_2D_NEAREST_TextureDofBlurCircular(uv + off.xx / uTextureDofBlurCircularSize).rgb;\n blur += TEXTURE_2D_NEAREST_TextureDofBlurCircular(uv + off.yy / uTextureDofBlurCircularSize).rgb;\n blur += TEXTURE_2D_NEAREST_TextureDofBlurCircular(uv + off.xy / uTextureDofBlurCircularSize).rgb;\n blur += TEXTURE_2D_NEAREST_TextureDofBlurCircular(uv + off.yx / uTextureDofBlurCircularSize).rgb;\n blur /= 5.0;\n } else {\n blur = TEXTURE_2D_TextureDofBlurCircular(uv).rgb;\n vec2 off = vec2(1.0, -1.0) * uDofScale;\n blur += TEXTURE_2D_TextureDofBlurCircular(uv + off.xx / uTextureDofBlurCircularSize).rgb;\n blur += TEXTURE_2D_TextureDofBlurCircular(uv + off.yy / uTextureDofBlurCircularSize).rgb;\n blur += TEXTURE_2D_TextureDofBlurCircular(uv + off.xy / uTextureDofBlurCircularSize).rgb;\n blur += TEXTURE_2D_TextureDofBlurCircular(uv + off.yx / uTextureDofBlurCircularSize).rgb;\n blur /= 5.0;\n }\n\n // merge full res and half res coc\n vec2 uvNearest = (floor(uv * uTextureDofNearDilateVSize) + 0.5) / uTextureDofNearDilateVSize;\n float coc = abs(min(TEXTURE_2D_TextureDofNearDilateV(uvNearest).a * 2.0 - 1.0, texDepthToCoC(depthPacked)));\n\n // merge half res blurred color and full res pixels\n float cocLower = 0.05;\n float cocHigher = 0.3;\n\n return vec4(mix(color, blur, smoothstep(cocLower, cocHigher, coc)), 1.0);\n}\n\n',"bloomExtract.glsl":'#pragma include "utils/getLuminance.glsl"\n#pragma include "utils/decodeDepth.glsl"\n\nuniform sampler2D TextureInput;\n\n#ifdef HAS_BACKGROUND\nuniform sampler2D TextureDepth;\n#endif\n\nuniform float uBloomThreshold;\n\nvec3 extractBright(const in vec3 color) {\n // TODO manage hdr pixel with high frequency? (use derivative??), for now we clamp the extracted pixel :(\n return clamp(color * clamp(getLuminance(color) - uBloomThreshold, 0.0, 1.0), 0.0, 1.0);\n}\n\nvec4 bloomExtract() {\n vec3 color = TEXTURE_2D_TextureInput(gTexCoord).rgb;\n\n#ifdef HAS_BACKGROUND\n\tfloat alpha = decodeAlpha(TEXTURE_2D_TextureDepth(gTexCoord));\n\tif(alpha == 0.0) {\n\t\treturn vec4(vec3(0.0), 1.0);\n }\n#else\n\tfloat alpha = 1.0;\n#endif\n\n\treturn vec4(extractBright(color * alpha), 1.0);\n}',"bloomCombine.glsl":"uniform sampler2D TextureInput;\nuniform sampler2D TextureBloomBlur1;\nuniform sampler2D TextureBloomBlur2;\nuniform sampler2D TextureBloomBlur3;\nuniform sampler2D TextureBloomBlur4;\nuniform sampler2D TextureBloomBlur5;\n\nuniform float uBloomRadius;\nuniform float uBloomFactor;\n\nfloat getRadiusFactored(const float value, const float middle) {\n return mix(value, middle * 2.0 - value, uBloomRadius);\n}\n\nvec4 bloomCombine() {\n vec3 bloom = vec3(0.0);\n\n const float midVal = 0.6;\n\n const float factor1 = 1.1;\n const float factor2 = 0.9;\n const float factor3 = 0.6;\n const float factor4 = 0.3;\n const float factor5 = 0.1;\n\n bloom += TEXTURE_2D_TextureBloomBlur1(gTexCoord).rgb * getRadiusFactored(factor1, midVal);\n bloom += TEXTURE_2D_TextureBloomBlur2(gTexCoord).rgb * getRadiusFactored(factor2, midVal);\n bloom += TEXTURE_2D_TextureBloomBlur3(gTexCoord).rgb * getRadiusFactored(factor3, midVal);\n bloom += TEXTURE_2D_TextureBloomBlur4(gTexCoord).rgb * getRadiusFactored(factor4, midVal);\n bloom += TEXTURE_2D_TextureBloomBlur5(gTexCoord).rgb * getRadiusFactored(factor5, midVal);\n\n vec3 color = TEXTURE_2D_TextureInput(gTexCoord).rgb;\n return vec4(color + (bloom * uBloomFactor), 1.0);\n}","chromaticAberration.glsl":"uniform sampler2D TextureInput;\n\nuniform float uChromaFactor;\n\nvec4 chromaticAberration() {\n vec2 uv = gTexCoord;\n\n vec2 dist = uv - 0.5;\n vec2 offset = uChromaFactor * dist * length(dist);\n vec3 col;\n col.r = TEXTURE_2D_TextureInput(uv - offset).r;\n col.g = TEXTURE_2D_TextureInput(uv).g;\n col.b = TEXTURE_2D_TextureInput(uv + offset).b;\n\n return vec4(col, 1.0);\n}","vignette.glsl":'#pragma include "utils/decodeDepth.glsl"\n#pragma include "utils/rand.glsl"\n\nuniform vec2 uLensRadius;\nuniform float uFrameMod;\n\nfloat vignetteDithered() {\n vec2 lens = uLensRadius;\n // smoothesp is not realiable with edge0 == edge1\n lens.y = min(lens.y, lens.x - 1e-4);\n\n float jitter = interleavedGradientNoise(gl_FragCoord.xy, uFrameMod);\n\n // jitter a bit the uv to remove the banding in some cases\n // (lens.x - lens.y) reduce flickering when the vignette is harder (hardness)\n // (lens.x + lens.y) reduce the flickering when the vignette has a strong radius\n jitter = (lens.x - lens.y) * (lens.x + lens.y) * 0.07 * (jitter - 0.5);\n return smoothstep(lens.x, lens.y, jitter + distance(gTexCoord, vec2(0.5)));\n}\n\nvec4 vignette(const in vec4 color) {\n float factor = vignetteDithered();\n return vec4(linearTosRGB(sRGBToLinear(color.rgb) * factor), clamp(color.a + (1.0 - factor), 0.0, 1.0));\n}',"toneMapping.glsl":'#pragma include "utils/getLuminance.glsl"\n#pragma include "utils/decodeDepth.glsl"\n\nuniform float uToneExposure;\nuniform float uToneBrightness;\nuniform float uToneContrast;\nuniform float uToneSaturation;\nuniform int uToneMethod;\n\n#ifdef HAS_FIXED_BACKGROUND\nuniform sampler2D TextureDepth;\n#endif\n\nvec3 toneMapping(const in vec3 color) {\n if (gTransparentAlpha > 0.999) return color; \n vec3 col = color * uToneExposure;\n float luminance = dot(col * (1.0 + uToneBrightness), vec3(0.2126, 0.7152, 0.0722));\n col = mix(vec3(luminance), col * (1.0 + uToneBrightness), vec3(uToneSaturation));\n\n // contrast is annoying and require special treatment in case of fixed background\n // because it doesn\'t output black when the input is black\n float toneContrast = uToneContrast;\n#ifdef HAS_FIXED_BACKGROUND\n float alpha = decodeAlpha(TEXTURE_2D_TextureDepth(gTexCoord));\n if(alpha == 0.0) toneContrast *= luminance;\n#endif\n col = max(vec3(0.0), col * (1.0 + toneContrast) - 0.5 * toneContrast);\n\n // simple reinhard and filmic\n // http://filmicgames.com/archives/190\n if(uToneMethod == 1) { // reinhard (on luminance)\n col /= 1.0 + getLuminance(col);\n } else if( uToneMethod == 2) { // filmic\n vec3 x = max(vec3(0.0), col - 0.004);\n col = (x * (6.2 * x + 0.5) ) / ( x * (6.2 * x + 1.7) + 0.06);\n col = pow(col, vec3(2.2)); // filmic curve already encode srgb to linear\n }\n\n return col;\n}\n\nvec4 toneMapping(const in vec4 color) {\n return vec4(toneMapping(color.rgb), 1.0);\n}\n',"colorBalance.glsl":"uniform vec3 uColorBalanceLow;\nuniform vec3 uColorBalanceMid;\nuniform vec3 uColorBalanceHigh;\n\nfloat RGBToL(const in vec3 color) {\n float fmin = min(min(color.r, color.g), color.b);\n float fmax = max(max(color.r, color.g), color.b);\n return (fmax + fmin) / 2.0;\n}\n\nvec3 colorBalance(const in vec3 color) {\n vec3 lrgb = uColorBalanceLow;\n vec3 mrgb = uColorBalanceMid;\n vec3 hrgb = uColorBalanceHigh;\n\n float cLen = length(color);\n if(cLen < 1e-5)\n return color;\n\n // TODO : I have no idea what I am doing, we should use a curve widge\n float lightness = RGBToL(color);\n // ' lightness=(lightness*0.9-1.0)/(lightness*2.0+1.0) +1.0;\n lightness = (1.5 * lightness) / (lightness + 0.5);\n // https://github.com/liovch/GPUImage/blob/master/framework/Source/GPUImageColorBalanceFilter\n float a = 0.25;\n float b = 0.333;\n float scale = 0.7;\n vec3 low = lrgb * clamp((lightness - b) / -a + 0.5, 0.0, 1.0);\n vec3 mid = mrgb * clamp((lightness - b) / a + 0.5, 0.0, 1.0) * clamp((lightness + b - 1.0) / -a + 0.5, 0.0, 1.0);\n vec3 high = hrgb * clamp((lightness + b - 1.0) / a + 0.5, 0.0, 1.0);\n vec3 newColor = max(color + (low + mid + high) * scale, vec3(0.0));\n // newColor can be negative\n float len = length(newColor);\n return len < 1e-5 ? newColor * cLen : newColor * cLen / len;\n}\n\nvec4 colorBalance(const in vec4 color) {\n return vec4(colorBalance(color.rgb), 1.0);\n}","supersample.glsl":"uniform vec4 uHalton;\n\nuniform float uSSAARestart;\nuniform sampler2D TexturePrevious;\nuniform vec2 uTexturePreviousSize;\n\n// static in place amortized supersampling\nvec4 supersample() {\n vec4 currFragColor = TEXTURE_2D_TextureInput(gTexCoord).rgba;\n\n float haltz = abs(uHalton.z);\n if (haltz == 1.0) {\n // just return the color.\n return currFragColor;\n }\n\n // same pixel for same projected interpolated vertex on prev frame\n vec4 accumColorN = TEXTURE_2D_NEAREST_TexturePrevious(gTexCoord).rgba;\n\n // mix frames\n float lerpFac = 1.0 / uHalton.w;\n\n // if uTaaSSSRestart is 0.0, then we used the previous TAAed image to start supersampling\n // we do that to avoid a sudden re-aliasing of the image (which is perceptible)\n if (uHalton.w == 1.0) lerpFac = uSSAARestart;\n\n if (haltz == 3.0) {\n // No supersample, crude motion blur by accumulation\n return mix(currFragColor, accumColorN, lerpFac);\n }\n\n // Supsersample, accumulation + jittering\n // http://en.wikipedia.org/wiki/Moving_average#Cumulative_moving_average\n // cumulative moving average over frameNum (which starts at 2)\n // n is previous frame\n // accumColorN = Accum(n)\n // return value is accumColor( n +1 )\n // Accum(n+1) = Accum(n) + ((x(n+1) - Accum(n)) / (n + 1)))\n // formula above is equal to glsl mix\n return mix(accumColorN, currFragColor, lerpFac);\n}\n","supersampleTaa.glsl":'#pragma include "utils/getLuminance.glsl"\n#pragma include "utils/decodeDepth.glsl"\n#pragma include "supersample.glsl"\n\nuniform sampler2D TextureInput;\nuniform vec2 uTextureInputSize;\nuniform sampler2D TexturePrevious;\nuniform vec2 uTexturePreviousSize;\nuniform sampler2D TextureDepth;\n\nuniform vec4 uHalton;\nuniform vec2 uNearFar;\n\nuniform float uTaaEnabled;\nuniform mat4 uTaaInvViewMatrixLeft;\nuniform mat4 uTaaCurrentFramePVLeft;\nuniform mat4 uTaaLastFramePVLeft;\nuniform vec4 uTaaCornersCSLeft[2];\n\n#ifdef VR_ENABLED\nuniform mat4 uTaaInvViewMatrixRight;\nuniform mat4 uTaaCurrentFramePVRight;\nuniform mat4 uTaaLastFramePVRight;\nuniform vec4 uTaaCornersCSRight[2];\n#endif\n\nvec3 reconstructWSPosition(const in vec2 uv, const in vec4 corners0, const in vec4 corners1, const in mat4 invView, const in float depth) {\n vec2 finalUv = uv;\n#ifdef VR_ENABLED\n float xViewportOffset = uv.x >= 0.5 ? -0.5 : 0.0;\n finalUv.x = ( uv.x + xViewportOffset ) * 2.0;\n#endif\n\n // the corners are in view space, it means if we interpolate between them we can retrieve the view space direction of the fragment\n vec4 AB = mix(corners0, corners1, vec4(finalUv.x));\n\n // multiply this view space direction by the depth gives us the view space position\n vec3 vsPos = vec3(mix(AB.xy, AB.zw, vec2(finalUv.y)), 1.0) * depth;\n\n // multiply by the inverse of the view matrix gives us the world space position\n return (invView * vec4(vsPos, 1.0)).xyz;\n}\n\n#define NEIGHBOUR_SET_IF_DMIN_Z_GREATER(d, x, y) if(d < dmin.z) dmin = vec3(x, y, d);\n#define NEIGHBOUR_CREATE_FROM_OFFSET(d, x, y) d = decodeDepth(TEXTURE_2D_TextureDepth(uv + vec2(x,y)));\n#define FIND_NEIGHBOUR_MIN(d, x, y) NEIGHBOUR_CREATE_FROM_OFFSET(d, x, y); NEIGHBOUR_SET_IF_DMIN_Z_GREATER(d, x, y)\n\n\n// Neighborhood clamping from Tiago Sousa\n// 4tap(decent) comment t, ml, mr, b\n// https://github.com/playdeadgames/temporal/blob/9e6a7704e69bb73f29fe393390e545b21ddfd42d/Assets/Shaders/IncDepth.cginc#L111\n// 9Tap(good) slower but nicer\n// https://github.com/playdeadgames/temporal/blob/9e6a7704e69bb73f29fe393390e545b21ddfd42d/Assets/Shaders/IncDepth.cginc#L37\n//#define CLOSEST_9TAP\nvec3 closestFragment(const in vec2 uv, const in vec2 texelSize) {\n\n float d;\n vec2 size = 2.0 * texelSize;\n vec3 dmin = vec3(0.0, 0.0, 0.0);\n\n // 5Tap\n NEIGHBOUR_CREATE_FROM_OFFSET(dmin.z, 0.0, 0.0);\n FIND_NEIGHBOUR_MIN(d, -size.x, size.y);\n FIND_NEIGHBOUR_MIN(d, size.x, size.y);\n FIND_NEIGHBOUR_MIN(d, -size.x, -size.y);\n FIND_NEIGHBOUR_MIN(d, size.x, -size.y);\n\n#ifdef CLOSEST_9TAP\n FIND_NEIGHBOUR_MIN(d, 0.0, size.y);\n FIND_NEIGHBOUR_MIN(d, -size.x, 0.0);\n FIND_NEIGHBOUR_MIN(d, size.x, 0.0);\n FIND_NEIGHBOUR_MIN(d, 0.0, -size.y);\n#endif\n\n return vec3(uv + dmin.xy, dmin.z);\n}\n\n// note: only clips towards aabb center (but fast!)\n// same as https://github.com/gokselgoktas/temporal-anti-aliasing/blob/master/Assets/Resources/Shaders/TemporalAntiAliasing.cginc#L199\n// which is adapted from https://github.com/playdeadgames/temporal\n// using the mathematical similar version of https://twitter.com/Stubbesaurus/status/890154773726580736\n// exhibits numerical issue (in a consistent way on intel/nvidia at least)\nvec4 clip_aabb_opti(const in vec4 minimum, const in vec4 maximum, const in vec4 color) {\n const float eps = 0.00000001;\n\n vec4 center = 0.5 * (maximum + minimum);\n vec4 extents = 0.5 * (maximum - minimum) + eps;\n vec4 offset = color - center;\n\n vec4 ts = abs(offset / extents);\n float t = max(max(ts.r, ts.g), max(ts.b, ts.a));\n return center + offset / max(1.0, t);\n // return t > 1.0 : center + offset / t : color;\n}\n\nvec4 taa(const in vec2 ssVel, const in vec2 texelSize) {\n vec2 uv = gTexCoord;\n\n vec4 tl = TEXTURE_2D_TextureInput(uv + vec2(-texelSize.x, texelSize.y));\n vec4 t = TEXTURE_2D_TextureInput(uv + vec2(0.0, texelSize.y));\n vec4 tr = TEXTURE_2D_TextureInput(uv + vec2(texelSize.x, texelSize.y));\n\n vec4 ml = TEXTURE_2D_TextureInput(uv + vec2(-texelSize.x, 0.0));\n vec4 m = TEXTURE_2D_TextureInput(uv);\n vec4 mr = TEXTURE_2D_TextureInput(uv + vec2(texelSize.x, 0.0));\n\n vec4 bl = TEXTURE_2D_TextureInput(uv + vec2(-texelSize.x, -texelSize.y));\n vec4 b = TEXTURE_2D_TextureInput(uv + vec2(0.0, -texelSize.y));\n vec4 br = TEXTURE_2D_TextureInput(uv + vec2(texelSize.x, -texelSize.y));\n\n // sharpen\n // https://github.com/Unity-Technologies/PostProcessing/blob/v1/PostProcessing/Resources/Shaders/TAA.cginc#L143\n // reduces blurring, but increases flickering with dense geometry\n vec4 corners = 2.0 * (tr + bl + br + tl) - 2.0 * m;\n m += (m - (corners * 0.166667)) * 2.718282 * 0.3;\n m = max(vec4(0.0), m);\n\n // Brian Karis neighbourhood rounding: http://advances.realtimerendering.com/s2014/epic/TemporalAA.pptx\n // average of rounded pattern with cross pattern\n vec4 cmin5 = min(mr, min(m, min(ml, min(t, b))));\n vec4 cmin = min(cmin5, min(tl, min(tr, min(bl, br))));\n\n vec4 cmax5 = max(mr, max(m, max(ml, max(t, b))));\n vec4 cmax = max(cmax5, max(tl, max(tr, max(bl, br))));\n\n cmin = 0.5 * (cmin + cmin5);\n cmax = 0.5 * (cmax + cmax5);\n\n vec4 previousColor = TEXTURE_2D_TexturePrevious(uv - ssVel);\n previousColor = clip_aabb_opti(cmin, cmax, previousColor);\n\n float lum0 = getLuminance(m.rgb);\n float lum1 = getLuminance(previousColor.rgb);\n float diff = abs(lum0 - lum1) / max(lum0, max(lum1, 0.2));\n float unbiased_weight = 1.0 - diff;\n float feedback = mix(FEEDBACK_MIN, FEEDBACK_MAX, unbiased_weight * unbiased_weight);\n\n return mix(m, previousColor, feedback);\n}\n\nvec2 computeSSVelocity(const in vec3 wsPos, const in mat4 currentFrameProjView, const in mat4 lastFrameProjView, const in bool rightEye)\n{\n vec4 ssCurrentPos = currentFrameProjView * vec4(wsPos, 1.0);\n vec4 ssPrevPos = lastFrameProjView * vec4(wsPos, 1.0);\n\n vec2 ndcCurrent = ssCurrentPos.xy / ssCurrentPos.w;\n vec2 ndcPrev = ssPrevPos.xy / ssPrevPos.w;\n\n //ndcPrev = clamp(ndcPrev, vec2(-1.0), vec2(1.0));\n if(ndcPrev.x >= 1.0 || ndcPrev.x <= -1.0 || ndcPrev.x >= 1.0 || ndcPrev.y <= -1.0)\n return vec2(0.0);\n\n#ifdef VR_ENABLED\n ndcCurrent.x /= 2.0;\n ndcPrev.x /= 2.0;\n\n if (rightEye) {\n ndcCurrent.x += 0.5;\n ndcPrev.x += 0.5;\n }\n#endif\n\n return 0.5 * (ndcCurrent - ndcPrev);\n}\n\n\nvec4 computeTaa(const in mat4 invView, const in mat4 currentFrameProjView, const in mat4 lastFrameProjView, const in vec4 corners0, const in vec4 corners1) {\n vec2 uv = gTexCoord;\n float haltz = abs(uHalton.z);\n if (haltz == 1.0) {\n vec2 texelSize = vec2(1.0) / uTextureInputSize;\n vec3 closest = closestFragment(uv, texelSize);\n\n // discard background fragments to save fillrate\n // make sure the mesh isn\'t transparent\n if (closest.z >= 1.0\n#ifdef TAA_TRANSPARENT\n && decodeAlpha(TEXTURE_2D_TextureDepth(closest.xy)) == 0.0\n#endif\n ) {\n // unjitter for fixed background with highres pattern or text\n return TEXTURE_2D_TextureInput(uv - 0.5 * uHalton.xy * texelSize);\n }\n\n float depth = -(uNearFar.x + (uNearFar.y - uNearFar.x) * closest.z);\n vec3 ws = reconstructWSPosition(closest.xy, corners0, corners1, invView, depth);\n\n vec2 ssVel = computeSSVelocity(ws, currentFrameProjView, lastFrameProjView, uv.x >= 0.5);\n return taa(ssVel, texelSize);\n }\n\n return supersample();\n}\n\n// temporal anti-aliasing from Playdead\'s Inside\n// slides: http://www.gdcvault.com/play/1022970/Temporal-Reprojection-Anti-Aliasing-in\n// sources: https://github.com/playdeadgames/temporal\nvec4 supersampleTaa() {\n if (uTaaEnabled == 0.0) {\n return supersample();\n }\n\n#ifdef VR_ENABLED\n // left and right eyes have different matrices\n if (gTexCoord.x >= 0.5) {\n return computeTaa(uTaaInvViewMatrixRight, uTaaCurrentFramePVRight, uTaaLastFramePVRight, uTaaCornersCSRight[0], uTaaCornersCSRight[1]);\n }\n#endif\n\n return computeTaa(uTaaInvViewMatrixLeft, uTaaCurrentFramePVLeft, uTaaLastFramePVLeft, uTaaCornersCSLeft[0], uTaaCornersCSLeft[1]);\n}',"composeExtra.glsl":"uniform sampler2D TextureExtra;\r\n\r\n// LINEAR should be deduce from TEXTURE_2D_TextureExtra with user data\r\nvec4 composeExtra(const in vec4 color) {\r\n#ifdef LINEAR_EXTRA\r\n\tvec4 extra = sRGBToLinear(TEXTURE_2D_TextureExtra(gTexCoord));\r\n#else\r\n\tvec4 extra = TEXTURE_2D_TextureExtra(gTexCoord);\r\n#endif\r\n\treturn extra + vec4(color) * (1.0 - extra.a);\r\n}","composeFixedBackground.glsl":'#pragma include "utils/decodeDepth.glsl"\r\n\r\nuniform sampler2D TextureFixed;\r\nuniform vec2 uFixedScale;\r\n\r\nuniform sampler2D TextureDepth;\r\nuniform vec2 uTextureOutputSize;\r\n\r\nuniform vec4 uHalton;\r\nuniform float uSplitView;\r\n\r\nvec4 composeBackground(const in vec3 color, const in float alpha) {\r\n vec2 jitter = uHalton.xy * 0.5 / uTextureOutputSize;\r\n vec2 uv = (gTexCoord - 0.5 + jitter) * uFixedScale + 0.5;\r\n\r\n // we recenter and unstretch the background\r\n if (uSplitView == 1.0) uv.x = uv.x * 0.5 + 0.25;\r\n\r\n // composer can\'t guess based on user data, so SRGBToLinear should be defined (or not) by TEXTURE_2D_XXXXXXX\r\n vec3 backgroundColor = sRGBToLinear(texture2D(TextureFixed, uv).rgb);\r\n return vec4(color.rgb + backgroundColor * (1.0 - alpha), 1.0);\r\n}\r\n\r\nuniform sampler2D TextureInput;\r\nuniform vec2 uTextureInputSize;\r\nuniform vec2 uTextureInputRatio;\r\n\r\nuniform sampler2D TextureRefraction;\r\nuniform vec2 uTextureRefractionSize;\r\nuniform vec2 uTextureRefractionRatio;\r\nuniform float uRGBMRange;\r\n\r\nvec4 composeFixedBackground(const in vec4 color) {\r\n#ifdef REFRACTION_COMPOSITING_EXCLUSION\r\n // detect if we are on a refraction pixel\r\n vec2 uvRef = min(gTexCoord, 1.0 - 1.0 / uTextureRefractionSize.xy);\r\n if (texture2D(TextureRefraction, uvRef * uTextureRefractionRatio).a > 0.0) return color;\r\n#endif\r\n\r\n float alpha = decodeAlpha(TEXTURE_2D_TextureDepth(gTexCoord));\r\n return composeBackground(color.rgb, alpha);\r\n}\r\n\r\nvec4 composeFixedBackgroundRefraction() {\r\n vec3 color = TEXTURE_2D_TextureInput(gTexCoord).rgb;\r\n float alpha = decodeAlpha(TEXTURE_2D_TextureDepth(gTexCoord));\r\n return composeBackground(color.rgb, alpha);\r\n}',"fxaa.glsl":'#ifdef VR_DISTORTION\nuniform vec2 uDistortion;\nuniform vec4 uProjectionLeft;\nuniform vec4 uUnprojectionLeft;\n\n#pragma include "distortion.glsl"\n#endif\n\n#ifdef ASCII_FOOL\n#pragma include "ascii.glsl"\n#endif\n\nuniform sampler2D TextureInput;\nuniform vec2 uTextureInputSize;\n\n// G3D version of FXAA\n// green (y) as luma\n// Quality 12\nvec4 fxaa() {\n#ifdef VR_DISTORTION\n gTexCoord = distortion(gTexCoord);\n#endif\n\n vec2 fxaaQualityRcpFrame = 1.0 / uTextureInputSize;\n float fxaaQualitySubpix = 0.75;\n float fxaaQualityEdgeThreshold = 0.125;\n float fxaaQualityEdgeThresholdMin = 0.0625;\n\n vec2 posM = gTexCoord;\n vec4 rgbyM = TEXTURE_2D_TextureInput(posM);\n float lumaM = rgbyM.y;\n\n // Swizzler Offseter Util\n vec4 sw = vec4(-1.0, 1.0, 1.0, -1.0) * fxaaQualityRcpFrame.xxyy;\n\n float lumaS = TEXTURE_2D_TextureInput(posM + vec2(0.0, sw.z)).y;\n float lumaE = TEXTURE_2D_TextureInput(posM + vec2(sw.y, 0.0)).y;\n float lumaN = TEXTURE_2D_TextureInput(posM + vec2(0.0, sw.w)).y;\n float lumaW = TEXTURE_2D_TextureInput(posM + vec2(sw.x, 0.0)).y;\n\n float maxSM = max(lumaS, lumaM);\n float minSM = min(lumaS, lumaM);\n\n float maxESM = max(lumaE, maxSM);\n float minESM = min(lumaE, minSM);\n\n float maxWN = max(lumaN, lumaW);\n float minWN = min(lumaN, lumaW);\n\n float rangeMax = max(maxWN, maxESM);\n float rangeMin = min(minWN, minESM);\n\n float rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;\n float range = rangeMax - rangeMin;\n float rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);\n\n bool earlyExit = range < rangeMaxClamped;\n\n if (earlyExit) {\n#ifdef ASCII_FOOL\n return ascii(posM);\n#else\n return rgbyM;\n#endif\n }\n\n float lumaNW = TEXTURE_2D_TextureInput(posM + sw.xw).y;\n float lumaSE = TEXTURE_2D_TextureInput(posM + sw.yz).y;\n float lumaNE = TEXTURE_2D_TextureInput(posM + sw.yw).y;\n float lumaSW = TEXTURE_2D_TextureInput(posM + sw.xy).y;\n\n float lumaNS = lumaN + lumaS;\n float lumaWE = lumaW + lumaE;\n float subpixRcpRange = 1.0/range;\n float subpixNSWE = lumaNS + lumaWE;\n float edgeHorz1 = (-2.0 * lumaM) + lumaNS;\n float edgeVert1 = (-2.0 * lumaM) + lumaWE;\n\n float lumaNESE = lumaNE + lumaSE;\n float lumaNWNE = lumaNW + lumaNE;\n float edgeHorz2 = (-2.0 * lumaE) + lumaNESE;\n float edgeVert2 = (-2.0 * lumaN) + lumaNWNE;\n\n float lumaNWSW = lumaNW + lumaSW;\n float lumaSWSE = lumaSW + lumaSE;\n float edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);\n float edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);\n float edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;\n float edgeVert3 = (-2.0 * lumaS) + lumaSWSE;\n float edgeHorz = abs(edgeHorz3) + edgeHorz4;\n float edgeVert = abs(edgeVert3) + edgeVert4;\n\n float subpixNWSWNESE = lumaNWSW + lumaNESE;\n float lengthSign = fxaaQualityRcpFrame.x;\n bool horzSpan = edgeHorz >= edgeVert;\n float subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;\n\n if(!horzSpan) lumaN = lumaW;\n if(!horzSpan) lumaS = lumaE;\n if(horzSpan) lengthSign = fxaaQualityRcpFrame.y;\n float subpixB = (subpixA * (1.0/12.0)) - lumaM;\n\n float gradientN = lumaN - lumaM;\n float gradientS = lumaS - lumaM;\n float lumaNN = lumaN + lumaM;\n float lumaSS = lumaS + lumaM;\n bool pairN = abs(gradientN) >= abs(gradientS);\n float gradient = max(abs(gradientN), abs(gradientS));\n if(pairN) lengthSign = -lengthSign;\n float subpixC = clamp(abs(subpixB) * subpixRcpRange, 0.0, 1.0);\n\n vec2 posB = posM.xy;\n vec2 offNP;\n offNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;\n offNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;\n if(!horzSpan) posB.x += lengthSign * 0.5;\n if( horzSpan) posB.y += lengthSign * 0.5;\n\n vec2 posN;\n posN.x = posB.x - offNP.x;\n posN.y = posB.y - offNP.y;\n vec2 posP;\n posP.x = posB.x + offNP.x;\n posP.y = posB.y + offNP.y;\n float subpixD = ((-2.0)*subpixC) + 3.0;\n float lumaEndN = TEXTURE_2D_TextureInput(posN).y;\n float subpixE = subpixC * subpixC;\n float lumaEndP = TEXTURE_2D_TextureInput(posP).y;\n\n if(!pairN) lumaNN = lumaSS;\n float gradientScaled = gradient * 1.0/4.0;\n float lumaMM = lumaM - lumaNN * 0.5;\n float subpixF = subpixD * subpixE;\n bool lumaMLTZero = lumaMM < 0.0;\n\n lumaEndN -= lumaNN * 0.5;\n lumaEndP -= lumaNN * 0.5;\n bool doneN = abs(lumaEndN) >= gradientScaled;\n bool doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * 1.5;\n if(!doneN) posN.y -= offNP.y * 1.5;\n bool doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * 1.5;\n if(!doneP) posP.y += offNP.y * 1.5;\n\n if(doneNP) {\n if(!doneN) lumaEndN = TEXTURE_2D_TextureInput(posN.xy).y;\n if(!doneP) lumaEndP = TEXTURE_2D_TextureInput(posP.xy).y;\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * 2.0;\n if(!doneN) posN.y -= offNP.y * 2.0;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * 2.0;\n if(!doneP) posP.y += offNP.y * 2.0;\n\n if(doneNP) {\n if(!doneN) lumaEndN = TEXTURE_2D_TextureInput(posN.xy).y;\n if(!doneP) lumaEndP = TEXTURE_2D_TextureInput(posP.xy).y;\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * 4.0;\n if(!doneN) posN.y -= offNP.y * 4.0;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * 4.0;\n if(!doneP) posP.y += offNP.y * 4.0;\n\n if(doneNP) {\n if(!doneN) lumaEndN = TEXTURE_2D_TextureInput(posN.xy).y;\n if(!doneP) lumaEndP = TEXTURE_2D_TextureInput(posP.xy).y;\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * 12.0;\n if(!doneN) posN.y -= offNP.y * 12.0;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * 12.0;\n if(!doneP) posP.y += offNP.y * 12.0;\n\n }\n\n }\n\n }\n\n float dstN = posM.x - posN.x;\n float dstP = posP.x - posM.x;\n if(!horzSpan) dstN = posM.y - posN.y;\n if(!horzSpan) dstP = posP.y - posM.y;\n\n bool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;\n float spanLength = (dstP + dstN);\n bool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;\n float spanLengthRcp = 1.0/spanLength;\n\n bool directionN = dstN < dstP;\n float dst = min(dstN, dstP);\n bool goodSpan = directionN ? goodSpanN : goodSpanP;\n float subpixG = subpixF * subpixF;\n float pixelOffset = (dst * (-spanLengthRcp)) + 0.5;\n float subpixH = subpixG * fxaaQualitySubpix;\n\n float pixelOffsetGood = goodSpan ? pixelOffset : 0.0;\n float pixelOffsetSubpix = max(pixelOffsetGood, subpixH);\n if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;\n if( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;\n\n \n#ifdef ASCII_FOOL\n return ascii(posM);\n#else\n return TEXTURE_2D_TextureInput(posM);\n#endif\n}\n',"grain.glsl":'#pragma include "utils/rand.glsl"\n\nuniform float uTimeGrain;\nuniform float uGrainFactor;\n\nfloat nrandTriangle() {\n float nrnd0 = pseudoRandom(gl_FragCoord.xy + 1000.0 * fract(uTimeGrain));\n\n // Convert uniform distribution into triangle-shaped distribution.\n float orig = nrnd0 * 2.0 - 1.0;\n nrnd0 = orig * inversesqrt(abs(orig));\n nrnd0 = max(-1.0, nrnd0); // Nerf the NaN generated by 0 * rsqrt(0). Thanks @FioraAeterna!\n nrnd0 = nrnd0 - sign(orig) + 0.5;\n\n // Result is range [-0.5,1.5] which is useful for actual dithering. convert to [0,1] for histogram.\n return (nrnd0 + 0.5) * 0.5;\n // return nrnd0;\n}\n\nvec4 grain(const in vec4 color) {\n float grainFactor = nrandTriangle();\n return vec4(mix(color.rgb, color.rgb * (color.rgb + (1.0 - color.rgb) * 2.0 * grainFactor), uGrainFactor), color.a);\n}',"sharpen.glsl":'#pragma include "utils/decodeDepth.glsl"\n\nuniform sampler2D TextureInput;\nuniform vec2 uTextureInputSize;\n\n#ifdef HAS_BACKGROUND\nuniform sampler2D TextureDepth;\n#endif\n\nuniform float uSharpFactor;\n\nuniform vec2 uPixelRatio;\n\nvec3 sharpColorFactor(const in vec3 color, const float sharp) {\n vec2 off = uPixelRatio.xy / uTextureInputSize.xy;\n\n // use useAA, 4 texFetch already in cache. perhaps we could cache ourself.\n vec3 rgbNW = TEXTURE_2D_TextureInput(gTexCoord + off * vec2(-1.0, -1.0)).rgb; \n vec3 rgbSE = TEXTURE_2D_TextureInput(gTexCoord + off * vec2(1.0, 1.0)).rgb;\n vec3 rgbNE = TEXTURE_2D_TextureInput(gTexCoord + off * vec2(1.0, -1.0)).rgb;\n vec3 rgbSW = TEXTURE_2D_TextureInput(gTexCoord + off * vec2(-1.0, 1.0)).rgb;\n\n return color + sharp * (4.0 * color - rgbNW - rgbNE - rgbSW - rgbSE);\n}\n\nvec4 sharpen(const in vec4 color) {\n#ifdef HAS_BACKGROUND\n\tfloat alpha = decodeAlpha(TEXTURE_2D_TextureDepth(gTexCoord));\n\tif( alpha == 0.0 ) {\n\t\treturn vec4(color.rgb,1.0);\n }\n#else\n\tfloat alpha = 1.0;\n#endif\n\n return vec4(sharpColorFactor(color.rgb, uSharpFactor * alpha), color.a);\n}\n\nvec4 sharpen() {\n return sharpen(TEXTURE_2D_TextureInput(gTexCoord));\n}',"dofCross.glsl":"uniform vec2 uTextureInputSize;\nuniform vec3 uDofCross;\n\nuniform vec2 uPixelRatio;\n\nvec4 dofCross(const in vec4 color) {\n float ratio = uTextureInputSize.y / uTextureInputSize.x;\n float dist = distance(vec2(uDofCross.x, uDofCross.y * ratio), gTexCoord * vec2(1.0, ratio));\n float widthCircle = uPixelRatio.x / uTextureInputSize.x;\n return vec4(mix(color.rgb, vec3(1.0), abs(dist - 60.0 * widthCircle) > widthCircle ? 0.0 : uDofCross.z), color.a);\n}","distortion.glsl":"// https://github.com/borismus/webvr-boilerplate/blob/master/src/distortion/barrel-distortion-fragment-v2.js\n\nvec2 barrel(const in vec2 v, const in vec4 projection, const in vec4 unprojection) {\n vec2 w = (v + unprojection.zw) / unprojection.xy;\n float val = dot(w, w);\n // float poly = (showCenter == 1 && val < 0.00010) ? 10000.0 : 1.0 + (uDistortion.x + uDistortion.y * val) * val;\n float poly = 1.0 + (uDistortion.x + uDistortion.y * val) * val;\n return projection.xy * (poly * w) - projection.zw;\n}\n\nvec2 distortion(const in vec2 texCoord) {\n\n if (abs(texCoord.x - 0.5) < .001) {\n discard;\n }\n\n vec2 a;\n\n if (texCoord.x < 0.5){\n a = barrel(vec2(texCoord.x / 0.5, texCoord.y), uProjectionLeft, uUnprojectionLeft);\n } else {\n // right projections are shifted and vertically mirrored relative to left\n const vec3 swi = vec3(1.0, -1.0, 0.0);\n vec4 projectionRight = (uProjectionLeft + swi.zzxz) * swi.xxyx;\n vec4 unprojectionRight = (uUnprojectionLeft + swi.zzxz) * swi.xxyx;\n a = barrel(vec2((texCoord.x - 0.5) / 0.5, texCoord.y), projectionRight, unprojectionRight);\n }\n\n if (a.x < 0.0 || a.x > 1.0 || a.y < 0.0 || a.y > 1.0) {\n discard;\n }\n\n return vec2(a.x * 0.5 + (texCoord.x < 0.5 ? 0.0 : 0.5), a.y);\n}","ascii.glsl":'//original shader : https://www.shadertoy.com/view/lssGDj by @movAX13h\n// Here\'s a little tool for new characters: thrill-project.com/archiv/coding/bitmap/\n\nfloat character(const in float n, vec2 p)\n{\n p = floor(p*vec2(4.0, -4.0) + 2.5);\n if (clamp(p.x, 0.0, 4.0) == p.x && clamp(p.y, 0.0, 4.0) == p.y)\n {\n if (int(mod(n/exp2(p.x + 5.0 * p.y), 2.0)) == 1) return 1.5;\n }\n return 0.2;\n}\n\nuniform vec2 uTextureInputSize;\n\nvec4 ascii( const in vec2 coord )\n{\n vec2 pix = coord*uTextureInputSize.xy;\n vec3 col = TEXTURE_2D_TextureInput(floor(pix/16.0)*16.0/uTextureInputSize.xy).rgb;\n\n float gray = 0.3 * col.r + 0.59 * col.g + 0.11 * col.b;\n\n // 458144 fish\n // 473536 square\n // 33408895 empty round\n // a 469450 33095217\n // p 469448 33095184\n // r 32078482\n // i 14815374\n // l 8659215\n\n/*\n float n = 4096.0; // .\n if (gray > 0.2) n = 65600.0; // :\n if (gray > 0.3) n = 332772.0; // *\n if (gray > 0.4) n = 15255086.0; // o\n if (gray > 0.5) n = 23385164.0; // &\n if (gray > 0.6) n = 15252014.0; // 8\n if (gray > 0.7) n = 13199452.0; // @\n if (gray > 0.8) n = 11512810.0; // #\n*/\n\n // letters are APRIL\n // "emojii" are fish, square, hollow round\n float n = 14815374.0; // I\n if (gray > 0.2) n = 473536.0; // square\n if (gray > 0.3) n = 15255086.0; // round o\n if (gray > 0.4) n = 458144.0; // fish\n if (gray > 0.5) n = 10955200.0; // A\n if (gray > 0.6) n = 1113663.0; // P\n if (gray > 0.7) n = 5356847.0; // R\n if (gray > 0.8) n = 15762465.0; // L\n\n vec2 p = mod(pix / 8.0, 2.0) - vec2(1.0);\n col = col * vec3(character(n, p));\n return vec4(col, 1.0);\n}\n',"fadeVr.glsl":"uniform float uVrFadeFactor;\r\n\r\nvec4 fadeVr(const in vec4 color) {\r\n\treturn vec4(mix(color.rgb, vec3(0.0), clamp(uVrFadeFactor, 0.0, 1.0)), color.a);\r\n}","veilVr.glsl":"uniform float uVrVeilFactor;\r\n\r\nvec4 veilVr(const in vec4 color) {\r\n\treturn vec4(color.rgb * uVrVeilFactor, 1.0);\r\n}","outline.glsl":"uniform float uOutlineFactor;\nuniform vec2 uPixelRatio;\nuniform float uHighlightFactor;\nuniform float uLineWidth;\n\nuniform sampler2D TextureOutline;\nuniform vec2 uTextureOutlineSize;\n\nvec4 outline() {\n float fac0 = 2.0;\n float fac1 = 1.0;\n float offsetx = uPixelRatio.x / uTextureOutlineSize[0] * uLineWidth;\n float offsety = uPixelRatio.y / uTextureOutlineSize[1] * uLineWidth;\n\n vec4 texel0 = TEXTURE_2D_TextureOutline(gTexCoord + vec2(offsetx, offsety));\n vec4 texel1 = TEXTURE_2D_TextureOutline(gTexCoord + vec2(offsetx, 0.0));\n vec4 texel2 = TEXTURE_2D_TextureOutline(gTexCoord + vec2(offsetx, -offsety));\n vec4 texel3 = TEXTURE_2D_TextureOutline(gTexCoord + vec2(0.0, -offsety));\n vec4 texel4 = TEXTURE_2D_TextureOutline(gTexCoord + vec2(-offsetx, -offsety));\n vec4 texel5 = TEXTURE_2D_TextureOutline(gTexCoord + vec2(-offsetx, 0.0));\n vec4 texel6 = TEXTURE_2D_TextureOutline(gTexCoord + vec2(-offsetx, offsety));\n vec4 texel7 = TEXTURE_2D_TextureOutline(gTexCoord + vec2(0.0, offsety));\n\n vec4 rowx = -fac0 * texel5 + fac0 * texel1 + -fac1 * texel6 + fac1 * texel0 + -fac1 * texel4 + fac1 * texel2;\n vec4 rowy = -fac0 * texel3 + fac0 * texel7 + -fac1 * texel4 + fac1 * texel6 + -fac1 * texel2 + fac1 * texel0;\n\n float magSqr = sqrt(dot(rowy, rowy) + dot(rowx, rowx));\n bool infMag = magSqr < 1.0 / 65025.0;\n\n vec3 texelCenter = TEXTURE_2D_TextureOutline(gTexCoord).rgb;\n if (texelCenter == vec3(0.0) || (uHighlightFactor == 0.0 && infMag)) {\n discard;\n }\n\n float finalFactor = infMag ? uHighlightFactor : min(1.0, sqrt(magSqr) * uOutlineFactor);\n\n return finalFactor * vec4(texelCenter, 1.0);\n}\n","finalPremultAlpha.glsl":"vec4 finalPremultAlpha(const in vec4 color) {\n return vec4(linearTosRGB(sRGBToLinear(color.rgb) * color.a), color.a);\n}"},I=n("2a3fb"),D=n("8d89"),L=(n("a9e3"),n("a214")),F=n("3972"),k=n("9998"),B=n("f684"),U=n.n(B),V=n("1ad5"),G=n("602a"),z=n("82f0"),j=n("b797"),H=n("16cb"),W=n("a995"),X=n("06c5"),q=n("8c22"),Y=n("308b"),K=n("c0d6"),J=n("8130"),Z=(n("4c53"),n("a741")),Q=function e(t){t&&(this._boundStrategy=t.boundStrategy,this.setInputManager(t.inputManager)),void 0===this._boundStrategy&&(this._boundStrategy=e.COMPUTE_HOME_USING_SPHERE),this._controllerList={},this._inverseMatrix=F["c"].create(),this._camera=void 0,this._node=void 0,this._frustum={},this._computeBoundNodeMaskOverride=-1,this._tmpSphere=new Z["a"]};Q.prototype={setCamera:function(e){this._camera=e},getCamera:function(){return this._camera},setNode:function(e){this._node=e},setComputeBoundNodeMaskOverride:function(e){this._computeBoundNodeMaskOverride=e},getComputeBoundNodeMaskOverride:function(){return this._computeBoundNodeMaskOverride},setInputManager:function(e){this._inputManager=e},getInputManager:function(){return this._inputManager},getHomeBoundingSphere:function(e){var t=this._node;if(t){var r=void 0!==e?e:this._boundStrategy;if(r&Q.COMPUTE_HOME_USING_BBOX){var i;if(-1===this._computeBoundNodeMaskOverride)i=t.getBoundingBox();else{var a=n("bade").default,o=new a;o.setNodeMaskOverride(this._computeBoundNodeMaskOverride),o.reset(),o.apply(t),i=o.getBoundingBox()}if(!i.valid())return t.getBoundingSphere();if(r&Q.COMPUTE_HOME_USING_SPHERE){var s=t.getBoundingSphere();if(s.valid()&&s.volume()<i.volume())return s}return this._tmpSphere.copyBoundingBox(i),this._tmpSphere}return t.getBoundingSphere()}},getHomeBound:function(e){return L["a"].warn("Please use getHomeBoundingSphere instead"),this.getHomeBoundingSphere(e)},getHomeDistance:function(e){var t=this._frustum,r=e.radius();if(this._camera&&F["c"].getFrustum(t,this._camera.getProjectionMatrix())){var n=Math.abs(t.right-t.left)/t.zNear/2,i=Math.abs(t.top-t.bottom)/t.zNear/2;r/=Math.sin(Math.atan2(i<n?i:n,1))}else r*=1.5;return r},update:function(){},getInverseMatrix:function(){return this._inverseMatrix},getControllerList:function(){return this._controllerList}},Q.COMPUTE_HOME_USING_SPHERE=1,Q.COMPUTE_HOME_USING_BBOX=2;var $=Q,ee=function(e){this._manipulator=e,this._enable=!0};ee.prototype={isEnabled:function(){return this._enable},setEnable:function(e){this._enable=e}};var te=ee,re={SCENE:"scene",MANIPULATORS:"scene.manipulators",ORBIT_MANIPULATOR:"scene.manipulators.orbit",ORBIT_MANIPULATOR_MOUSEKEYBOARD:"scene.manipulators.orbit.mousekeyboard",ORBIT_MANIPULATOR_RESETTOHOME:"scene.manipulators.orbit.mousekeyboard.home",ORBIT_MANIPULATOR_TOUCH:"scene.manipulators.orbit.touch",ORBIT_MANIPULATOR_WEBVR:"scene.manipulators.orbit.webvr",ORBIT_MANIPULATOR_DEVICEORIENTATION:"scene.manipulators.orbit.deviceorientation",ORBIT_MANIPULATOR_GAMEPAD:"scene.manipulators.orbit.gamepad",FPS_MANIPULATOR:"scene.manipulators.fps",FPS_MANIPULATOR_MOUSEKEYBOARD:"scene.manipulators.fps.mousekeyboard",FPS_MANIPULATOR_RESETTOHOME:"scene.manipulators.fps.mousekeyboard.home",FPS_MANIPULATOR_TOUCH:"scene.manipulators.fps.touch",FPS_MANIPULATOR_WEBVR:"scene.manipulators.fps.webvr",FPS_MANIPULATOR_DEVICEORIENTATION:"scene.manipulators.fps.deviceorientation",FPS_MANIPULATOR_GAMEPAD:"scene.manipulators.fps.gamepad",CAD_MANIPULATOR:"scene.manipulators.cad",CAD_MANIPULATOR_MOUSEKEYBOARD:"scene.manipulators.cad.mousekeyboard",CAD_MANIPULATOR_RESETTOHOME:"scene.manipulators.cad.mousekeyboard.home",CAD_MANIPULATOR_TOUCH:"scene.manipulators.cad.touch",NODE_GIZMO:"scene.nodegizmo",UI:"ui",STATS:"ui.stats"},ne=re,ie=Math.PI/180,ae=function(e,t,r,n,i){var a=Math.cos(t/2),o=Math.cos(r/2),s=Math.cos(n/2),u=Math.sin(t/2),c=Math.sin(r/2),l=Math.sin(n/2);return"XYZ"===i?(e[0]=u*o*s+a*c*l,e[1]=a*c*s-u*o*l,e[2]=a*o*l+u*c*s,e[3]=a*o*s-u*c*l):"YXZ"===i?(e[0]=u*o*s+a*c*l,e[1]=a*c*s-u*o*l,e[2]=a*o*l-u*c*s,e[3]=a*o*s+u*c*l):"ZXY"===i?(e[0]=u*o*s-a*c*l,e[1]=a*c*s+u*o*l,e[2]=a*o*l+u*c*s,e[3]=a*o*s-u*c*l):"ZYX"===i?(e[0]=u*o*s-a*c*l,e[1]=a*c*s+u*o*l,e[2]=a*o*l-u*c*s,e[3]=a*o*s+u*c*l):"YZX"===i?(e[0]=u*o*s+a*c*l,e[1]=a*c*s+u*o*l,e[2]=a*o*l-u*c*s,e[3]=a*o*s-u*c*l):"XZY"===i&&(e[0]=u*o*s-a*c*l,e[1]=a*c*s-u*o*l,e[2]=a*o*l+u*c*s,e[3]=a*o*s+u*c*l),e},oe=function(e){te.call(this,e),this.init()};oe.computeQuaternion=function(){var e=F["d"].create(),t=F["d"].fromValues(-Math.sqrt(.5),0,0,Math.sqrt(.5));return function(r,n,i){var a=n.alpha*ie,o=n.beta*ie,s=n.gamma*ie,u=i*ie;ae(r,o,a,-s,"YXZ");var c=-u/2;e[1]=Math.sin(c),e[3]=Math.cos(c),F["d"].mul(r,r,e),F["d"].mul(r,r,t);var l=r[1];return r[1]=-r[2],r[2]=l,r}}(),j["a"].createPrototypeObject(oe,j["a"].objectInherit(te.prototype,{init:function(){this._quat=F["d"].create(),this._pos=F["f"].create(),this._deviceOrientation=void 0,this._screenOrientation=void 0;var e=this._manipulator.getInputManager();e.group(ne.FPS_MANIPULATOR_DEVICEORIENTATION).addMappings({setDeviceOrientation:"deviceorientation",setScreenOrientation:"orientationchange"},this),e.setEnable(ne.FPS_MANIPULATOR_DEVICEORIENTATION,!1)},setDeviceOrientation:function(e){this._deviceOrientation||(this._deviceOrientation={}),this._deviceOrientation.alpha=e.alpha,this._deviceOrientation.beta=e.beta,this._deviceOrientation.gamma=e.gamma,e.screenOrientation?this.setScreenOrientation(e):this._update()},setScreenOrientation:function(e){this._screenOrientation=e.screenOrientation,this._update()},_update:function(){this._deviceOrientation&&this._screenOrientation&&(oe.computeQuaternion(this._quat,this._deviceOrientation,this._screenOrientation),this._manipulator.setPoseVR(this._quat,this._pos))}}));var se=oe,ue=function(e){te.call(this,e),this.init()};j["a"].createPrototypeObject(ue,j["a"].objectInherit(te.prototype,{init:function(){this._quat=F["d"].create(),this._pos=F["f"].create(),this._deviceOrientation=void 0,this._screenOrientation=void 0;var e=this._manipulator.getInputManager();e.group(ne.ORBIT_MANIPULATOR_DEVICEORIENTATION).addMappings({setDeviceOrientation:"deviceorientation",setScreenOrientation:"orientationchange"},this),e.setEnable(ne.ORBIT_MANIPULATOR_DEVICEORIENTATION,!1)},setDeviceOrientation:function(e){this._deviceOrientation||(this._deviceOrientation={}),this._deviceOrientation.alpha=e.alpha,this._deviceOrientation.beta=e.beta,this._deviceOrientation.gamma=e.gamma,e.screenOrientation?this.setScreenOrientation(e):this._update()},setScreenOrientation:function(e){this._screenOrientation=e.screenOrientation,this._update()},_update:function(){this._deviceOrientation&&this._screenOrientation&&(se.computeQuaternion(this._quat,this._deviceOrientation,this._screenOrientation),this._manipulator.setPoseVR(this._quat,this._pos))}}));var ce=ue,le=function(e){te.call(this,e),this.init()};j["a"].createPrototypeObject(le,j["a"].objectInherit(te.prototype,{init:function(){this._delay=.15,this._zoomFactor=.5,this._rotateFactor=5,this._panFactor=10,this._rotate=this._manipulator.getRotateInterpolator(),this._zoom=this._manipulator.getZoomInterpolator(),this._pan=this._manipulator.getPanInterpolator(),this._rotate.setDelay(this._delay),this._zoom.setDelay(this._delay),this._pan.setDelay(this._delay);var e=this._manipulator.getInputManager();e.group(ne.ORBIT_MANIPULATOR_GAMEPAD).addMappings({addZoom:"axis 3",addRotateX:"axis 0",addRotateY:"axis 1"},this),e.group(ne.ORBIT_MANIPULATOR_GAMEPAD).addMappings({panUp:"buttonvalue 12"},this.pan.bind(this,F["e"].fromValues(0,1))),e.group(ne.ORBIT_MANIPULATOR_GAMEPAD).addMappings({panDown:"buttonvalue 13"},this.pan.bind(this,F["e"].fromValues(0,-1))),e.group(ne.ORBIT_MANIPULATOR_GAMEPAD).addMappings({panLeft:"buttonvalue 14"},this.pan.bind(this,F["e"].fromValues(1,0))),e.group(ne.ORBIT_MANIPULATOR_GAMEPAD).addMappings({panRight:"buttonvalue 15"},this.pan.bind(this,F["e"].fromValues(-1,0)))},pan:function(e){var t=this._pan.getTarget();this._pan.setTarget(t[0]-e[0]*this._panFactor,t[1]+e[1]*this._panFactor)},addZoom:function(e){this._zoom.addTarget(-e.value*this._zoomFactor)},addRotateX:function(e){this._rotate.addTarget(-e.value*this._rotateFactor)},addRotateY:function(e){this._rotate.addTarget(0,e.value*this._rotateFactor)}}));var he=le,de=n("1881"),fe=function(e){te.call(this,e),this.init()};j["a"].createPrototypeObject(fe,j["a"].objectInherit(te.prototype,{init:function(){this._panFactor=[],this._panFactor[0]=1,this._panFactor[1]=-this._panFactor[0],this._rotateFactor=[],this._rotateFactor[0]=1.2,this._rotateFactor[1]=-this._rotateFactor[0],this._zoomFactor=5,this._lastScale=0,this._zooming=!1,this._dragStarted=!1,this._initInputs(ne.ORBIT_MANIPULATOR_TOUCH)},_initInputs:function(e){var t=this._manipulator.getInputManager();t.group(e).addMappings({pinchEnd:"pinchend",pinchStart:"pinchstart",pinchInOut:["pinchin","pinchout"],startPan:["panstart 2"],startRotate:["panstart 1"],pan:["panmove 2"],rotate:["panmove 1"],endMotion:["touchend 2","touchcancel 2","touchend 1","touchcancel 1"]},this)},startPan:function(e){this._panning=!0,this.startMotion(this._manipulator.getPanInterpolator(),this._panFactor,e)},startRotate:function(e){this._rotating=!0,this.startMotion(this._manipulator.getRotateInterpolator(),this._rotateFactor,e)},pan:function(e){this._panning||(this.endMotion(),this.startPan(e)),this.move(this._manipulator.getPanInterpolator(),this._panFactor,e)},rotate:function(e){this._rotating||(this.endMotion(),this.startPan(e)),this.move(this._manipulator.getRotateInterpolator(),this._rotateFactor,e)},startMotion:function(e,t,r){if(!this._zooming){e.reset();var n=r.canvasX*t[0],i=r.canvasY*t[1];e.set(n,i)}},move:function(e,t,r){var n=r.canvasX*t[0],i=r.canvasY*t[1];e.setTarget(n,i)},endMotion:function(){(this._panning||this._rotating)&&(this._panning=!1,this._rotating=!1)},pinchStart:function(e){this._zooming=!0,this._lastScale=e.scale;var t=this._manipulator.getZoomInterpolator();t.reset(),t.set(this._lastScale)},pinchEnd:function(){this._zooming=!1},pinchInOut:function(e){if(this._zooming){var t=e.scale>this._lastScale?this._zoomFactor:3*this._zoomFactor,r=0,n=.5,i=-Math.abs(e.velocity)+(r+n);t*=de["a"].smoothStep(r,n,i);var a=(e.scale-this._lastScale)*t;this._lastScale=e.scale;var o=this._manipulator.getZoomInterpolator();o.setTarget(o.getTarget()[0]-a)}},setManipulator:function(e){this._manipulator=e}}));var _e=fe,pe={ROTATE:0,PAN:1,ZOOM:2},ge=function(e){te.call(this,e),this._zoomFactor=1,this.init()};j["a"].createPrototypeObject(ge,j["a"].objectInherit(te.prototype,{init:function(){this._mode=void 0,this._inMotion=!1,this._initInputs(ne.ORBIT_MANIPULATOR_MOUSEKEYBOARD,ne.ORBIT_MANIPULATOR_RESETTOHOME)},_initInputs:function(e,t){var r=this._manipulator.getInputManager(),n=this.setMode.bind(this,pe.ROTATE,this._manipulator.getRotateInterpolator()),i=this.setMode.bind(this,pe.PAN,this._manipulator.getPanInterpolator()),a=this.setMode.bind(this,pe.ZOOM,this._manipulator.getZoomInterpolator());r.group(e).addMappings({move:"mousemove",startPan:["mousedown shift 0","mousedown 1","mousedown 2"],startZoom:["mousedown ctrl 0","mousedown ctrl 2"],startRotate:"mousedown 0 !shift !ctrl",stopMotion:["mouseup","mouseout","keyup a","keyup s","keyup d"],zoom:"wheel"},this),r.group(t).addMappings({reset:"keydown space"},this),r.group(e).addMappings({setRotationMode:"keydown a"},n),r.group(e).addMappings({setPanMode:"keydown d"},i),r.group(e).addMappings({setZoomMode:"keydown s"},a)},getMode:function(){return this._mode},setMode:function(e,t){this.getMode()!==e&&(this._mode=e,t.reset(),this._inMotion=!0)},setManipulator:function(e){this._manipulator=e},getZoomFactor:function(){return this._zoomFactor},setZoomFactor:function(e){this._zoomFactor=e},move:function(e){if(!1!==this._inMotion){var t=e.canvasX,r=-e.canvasY,n=this._manipulator;if(!1===de["a"].isNaN(t)&&!1===de["a"].isNaN(r)){var i=this.getMode();if(i===pe.ROTATE)n.getRotateInterpolator().setTarget(t,r);else if(i===pe.PAN)n.getPanInterpolator().setTarget(t,r);else if(i===pe.ZOOM){var a=n.getZoomInterpolator();a.isReset()&&(a.setStart(r),a.set(0));var o=r-a.getStart();a.setStart(r);var s=a.getTarget()[0];a.setTarget(s-o/20)}}}},startPan:function(e){var t=this._manipulator.getPanInterpolator();this.setMode(pe.PAN,t),t.reset(),t.set(e.canvasX,-e.canvasY)},startRotate:function(e){var t=this._manipulator.getRotateInterpolator();this.setMode(pe.ROTATE,t),t.reset(),t.set(e.canvasX,-e.canvasY)},startZoom:function(e){var t=this._manipulator.getZoomInterpolator();this.setMode(pe.ZOOM,t),t.setStart(-e.canvasY),t.set(0)},stopMotion:function(){this._inMotion=!1,this._mode=void 0},zoom:function(e){var t=e.deltaY/this._zoomFactor,r=this._manipulator,n=r.getZoomInterpolator().getTarget()[0]-t;r.getZoomInterpolator().setTarget(n)},reset:function(){this._manipulator.computeHomePosition()}}));var me=ge,ve=F["d"].create(),be=F["f"].create(),Se=function(e){te.call(this,e),this.init()};j["a"].createPrototypeObject(Se,j["a"].objectInherit(te.prototype,{init:function(){this._pos=F["f"].create(),this._quat=F["d"].create();var e=this._manipulator.getInputManager();e.group(ne.ORBIT_MANIPULATOR_WEBVR).addMappings({update:"vrdisplayposechanged"},this),e.setEnable(ne.ORBIT_MANIPULATOR_WEBVR,!1)},update:function(e){var t=e.pose.orientation;t&&(e.sitToStandMatrix&&(t=F["c"].getRotation(ve,e.sitToStandMatrix),F["d"].mul(t,t,e.pose.orientation)),this._quat[0]=t[0],this._quat[1]=-t[2],this._quat[2]=t[1],this._quat[3]=t[3]);var r=e.pose.position;r&&(e.sitToStandMatrix&&(r=F["f"].transformMat4(be,r,e.sitToStandMatrix)),this._pos[0]=r[0]*e.worldFactor,this._pos[1]=-r[2]*e.worldFactor,this._pos[2]=r[1]*e.worldFactor),this._manipulator.setPoseVR(this._quat,this._pos)}}));var xe=Se,Te=function(e,t,r){this._current=new Float32Array(e),this._target=new Float32Array(e),this._delta=new Float32Array(e),this._delay=void 0!==t?t:.15,this._reset=!1,this._start=0,this._redrawCB=r,this.reset()};Te.prototype={setDelay:function(e){this._delay=e},reset:function(){for(var e=0,t=this._current.length;e<t;e++)this._current[e]=this._target[e]=0;this._reset=!0},update:function(e){for(var t=Math.min(1,this._delay*e*60),r=0,n=this._current.length;r<n;r++){var i=(this._target[r]-this._current[r])*t;this._delta[r]=i,this._current[r]+=i}return this._delta},set:function(){for(var e=0,t=this._current.length;e<t;e++)this._current[e]=this._target[e]=arguments[e];this._reset=!1},isReset:function(){return this._reset},getCurrent:function(){return this._current},setTarget:function(){for(var e=0,t=this._target.length;e<t;e++)this._reset?this._target[e]=this._current[e]=arguments[e]:this._target[e]=arguments[e];this._reset=!1},addTarget:function(){for(var e=0;e<arguments.length;e++)this._target[e]+=arguments[e]},getTarget:function(){return this._target},getDelta:function(){return this._delta},getStart:function(){return this._start},setStart:function(e){this._start=e}};var ye=Te,Ce=function(e){$.call(this,e),this._homePosition=F["f"].create(),this._frustum={},this._redrawCB=e.redrawCB,this.init()};Ce.AvailableControllerList=["StandardMouseKeyboard","GamePad","Hammer","DeviceOrientation","WebVR"],Ce.ControllerList=["StandardMouseKeyboard","GamePad","Hammer","DeviceOrientation","WebVR"];var Ae=2*Math.PI,Ee=function(e,t){return e<t+1e-5},Re=1e-4,Me=1/0;j["a"].createPrototypeObject(Ce,j["a"].objectInherit($.prototype,{init:function(){this._distance=25,this._target=F["f"].create(),this._upz=F["f"].fromValues(0,0,1),F["f"].init(this._target);var e=F["c"].fromRotation(F["c"].create(),-Math.PI,this._upz),t=F["c"].fromRotation(F["c"].create(),Math.PI/10,F["f"].fromValues(1,0,0));this._rotation=F["c"].create(),F["c"].mul(this._rotation,e,t),this._time=0,this._vrMatrix=F["c"].create(),this._rotate=new ye(2,void 0,this._redrawCB),this._pan=new ye(2,void 0,this._redrawCB),this._zoom=new ye(1,void 0,this._redrawCB),this._minSpeed=1e-4,this._scaleMouseMotion=1,this._inverseMatrix=F["c"].create(),this._autoPushTarget=!0,this._limitPitchUp=.5*Math.PI*.9,this._limitPitchDown=-this._limitPitchUp,this._limitYawLeft=-Math.PI,this._limitYawRight=-this._limitYawLeft,this._limitZoomIn=Re,this._limitZoomOut=Me,this._constrainYaw=!1,this._constrainPitch=!1,this._constrainYaw=!1,this._constrainZoom=!1,this._panFactor=.002,this._rotationFactor=.1,this._zoomFactor=.1;var r=this;Ce.ControllerList.forEach((function(e){void 0!==Ce[e]&&(r._controllerList[e]?r._controllerList[e].init():r._controllerList[e]=new Ce[e](r))}))},setZoomFactor:function(e){this._zoomFactor=.1*e},setRotationFactor:function(e){this._rotationFactor=.1*e},setPanFactor:function(e){this._panFactor=.002*e},setLimitPitchUp:function(e){this._limitPitchUp=e},setLimitPitchDown:function(e){this._limitPitchDown=e},setLimitYawLeft:function(e){this._limitYawLeft=e,this._constrainYaw=!0},setLimitYawRight:function(e){this._limitYawRight=e,this._constrainYaw=!0},setLimitZoomOut:function(e){this._limitZoomOut=e,this._constrainZoom=!0},setLimitZoomIn:function(e){this._limitZoomIn=e,this._constrainZoom=!0},setConstrainPitch:function(e){this._constrainPitch=e,this._previousPitch=void 0},isConstrainPitch:function(){return this._constrainPitch},setConstrainYaw:function(e){this._constrainYaw=e,this._previousYaw=void 0},isConstrainYaw:function(){return this._constrainYaw},setConstrainZoom:function(e){this._constrainZoom=e},isConstrainZoom:function(){return this._constrainZoom},setDelay:function(e){this._rotate.setDelay(e),this._pan.setDelay(e),this._zoom.setDelay(e)},reset:function(){this.init()},setTarget:function(e){F["f"].copy(this._target,e);var t=F["f"].create();this.getEyePosition(t),this._distance=F["f"].distance(e,t)},setEyePosition:function(){var e=F["f"].create(),t=F["f"].create(),r=F["f"].create();return function(n){var i=this._rotation,a=this._target;F["f"].sub(e,n,a),F["f"].normalize(e,e),F["f"].cross(t,e,this._upz),F["f"].normalize(t,t),F["f"].cross(r,t,e),F["f"].normalize(r,r),i[0]=t[0],i[1]=e[0],i[2]=r[0],i[3]=0,i[4]=t[1],i[5]=e[1],i[6]=r[1],i[7]=0,i[8]=t[2],i[9]=e[2],i[10]=r[2],i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,this._distance=F["f"].distance(a,n)}}(),setEnable:function(e){this.getInputManager().setEnable(ne.ORBIT_MANIPULATOR,e)},computeHomePosition:function(e){var t=this.getHomeBoundingSphere(e);t&&t.valid()&&(this.setDistance(this.getHomeDistance(t)),this.setTarget(t.center()))},getHomePosition:function(){if(void 0!==this._node){var e=this._target,t=this.getDistance();this.computeEyePosition(e,t,this._homePosition)}return this._homePosition},setMinSpeed:function(e){this._minSpeed=e},getMinSpeed:function(){return this._minSpeed},setDistance:function(e){this._distance=e},getDistance:function(){return this._distance},getSpeedFactor:function(){return Math.max(this._distance,this._minSpeed)},computePan:function(){var e=F["c"].create(),t=F["f"].create(),r=F["f"].create();return function(n,i){var a=this._camera.getProjectionMatrix(),o=1===a[15]?1:2/a[5],s=this.getSpeedFactor()*o;i*=s,n*=s,F["c"].invert(e,this._rotation),t[0]=e[0],t[1]=e[1],t[2]=e[2],F["f"].normalize(t,t),r[0]=e[8],r[1]=e[9],r[2]=e[10],F["f"].normalize(r,r),F["f"].scale(t,t,-n),F["f"].scale(r,r,i),F["f"].add(this._target,this._target,t),F["f"].add(this._target,this._target,r)}}(),computeRotation:function(){var e=F["f"].fromValues(1,0,0);return function(t,r){var n=Math.atan(-this._rotation[6]/this._rotation[5]);isNaN(n)&&(n=0);var i=this._computePitch(n,r),a=t/10,o=Math.atan2(this._rotation[4],this._rotation[0]),s=this._computeYaw(o,a);F["c"].fromRotation(this._rotation,-i,e),F["c"].rotate(this._rotation,this._rotation,-s,this._upz)}}(),_computePitch:function(e,t){var r=e+t/10;return Math.min(Math.max(r,this._limitPitchDown),this._limitPitchUp)},_computeYaw:function(e,t){var r=e+t,n=this._limitYawLeft,i=this._limitYawRight;if(this._constrainYaw){if(i<n&&(r>Math.PI&&(e-=Ae,r-=Ae),r<-Math.PI&&(e+=Ae,r+=Ae)),0===t){var a=!1;a=n>i?r<n&&r>i:r<n||r>i,a&&(r=Math.abs(r-n)>Math.abs(r-i)?i:n)}t>0&&Ee(e,i)&&r>i?r=i:t<0&&Ee(n,e)&&r<n&&(r=n)}return r},computeZoom:function(e){this.zoom(e)},setAutoPushTarget:function(e){this._autoPushTarget=e},zoom:function(){var e=F["f"].create();return function(t){var r=this._distance+this.getSpeedFactor()*(t-1);this._autoPushTarget&&r<this._limitZoomIn&&(F["f"].sub(e,this._target,this.getEyePosition(e)),F["f"].normalize(e,e),F["f"].scale(e,e,this._limitZoomIn-r),F["f"].add(this._target,this._target,e));var n=this._constrainZoom?this._limitZoomIn:Re,i=this._constrainZoom?this._limitZoomOut:Me;this._distance=Math.max(n,Math.min(i,r))}}(),getRotateInterpolator:function(){return this._rotate},getPanInterpolator:function(){return this._pan},getZoomInterpolator:function(){return this._zoom},getTarget:function(e){return F["f"].copy(e,this._target)},getEyePosition:function(e){return this.computeEyePosition(this._target,this._distance,e),e},computeEyePosition:function(){var e=F["f"].create(),t=F["c"].create();return function(r,n,i){F["c"].invert(t,this._rotation),e[1]=n,F["f"].transformMat4(i,e,t),F["f"].add(i,r,i)}}(),update:function(){var e=F["f"].create();return function(t){var r,n=t.getFrameStamp().getDeltaTime();r=this._rotate.update(n),this.computeRotation(-r[0]*this._rotationFactor*this._scaleMouseMotion,-r[1]*this._rotationFactor*this._scaleMouseMotion);var i=.002;r=this._pan.update(n),this.computePan(-r[0]*i,-r[1]*i),r=this._zoom.update(n),this.computeZoom(1+r[0]/10);var a=this._target,o=this._distance;F["c"].invert(this._inverseMatrix,this._rotation),F["c"].mul(this._inverseMatrix,this._vrMatrix,this._inverseMatrix),F["f"].set(e,0,o,0),F["f"].transformMat4(e,e,this._inverseMatrix),F["c"].lookAt(this._inverseMatrix,F["f"].add(e,a,e),a,this._upz)}}(),setPoseVR:function(e){F["c"].fromQuat(this._vrMatrix,e)}}),"osgGA","OrbitManipulator"),Ce.DeviceOrientation=ce,Ce.GamePad=he,Ce.Hammer=_e,Ce.WebVR=xe,Ce.StandardMouseKeyboard=me;var we=Ce,Ne=n("5fe3"),Oe=n("53ca"),Ie=(n("25f0"),n("a15b"),n("12a8"),n("e71b"),n("b64b"),function(){var e=function(e){window.console&&window.console.log&&window.console.log(e)},t=function(t){window.console&&window.console.error?window.console.error(t):e(t)},r={enable:{1:{0:!0}},disable:{1:{0:!0}},getParameter:{1:{0:!0}},drawArrays:{3:{0:!0}},drawElements:{4:{0:!0,2:!0}},createShader:{1:{0:!0}},getShaderParameter:{2:{1:!0}},getProgramParameter:{2:{1:!0}},getShaderPrecisionFormat:{2:{0:!0,1:!0}},getVertexAttrib:{2:{1:!0}},vertexAttribPointer:{6:{2:!0}},bindTexture:{2:{0:!0}},activeTexture:{1:{0:!0}},getTexParameter:{2:{0:!0,1:!0}},texParameterf:{3:{0:!0,1:!0}},texParameteri:{3:{0:!0,1:!0,2:!0}},copyTexImage2D:{8:{0:!0,2:!0}},copyTexSubImage2D:{8:{0:!0}},generateMipmap:{1:{0:!0}},bindBuffer:{2:{0:!0}},getBufferParameter:{2:{0:!0,1:!0}},pixelStorei:{2:{0:!0,1:!0}},bindRenderbuffer:{2:{0:!0}},bindFramebuffer:{2:{0:!0}},checkFramebufferStatus:{1:{0:!0}},framebufferRenderbuffer:{4:{0:!0,1:!0,2:!0}},framebufferTexture2D:{5:{0:!0,1:!0,2:!0}},getFramebufferAttachmentParameter:{3:{0:!0,1:!0,2:!0}},getRenderbufferParameter:{2:{0:!0,1:!0}},renderbufferStorage:{4:{0:!0,1:!0}},clear:{1:{0:{enumBitwiseOr:["COLOR_BUFFER_BIT","DEPTH_BUFFER_BIT","STENCIL_BUFFER_BIT"]}}},depthFunc:{1:{0:!0}},blendFunc:{2:{0:!0,1:!0}},blendFuncSeparate:{4:{0:!0,1:!0,2:!0,3:!0}},blendEquation:{1:{0:!0}},blendEquationSeparate:{2:{0:!0,1:!0}},stencilFunc:{3:{0:!0}},stencilFuncSeparate:{4:{0:!0,1:!0}},stencilMaskSeparate:{2:{0:!0}},stencilOp:{3:{0:!0,1:!0,2:!0}},stencilOpSeparate:{4:{0:!0,1:!0,2:!0,3:!0}},cullFace:{1:{0:!0}},frontFace:{1:{0:!0}},drawArraysInstancedANGLE:{4:{0:!0}},drawElementsInstancedANGLE:{5:{0:!0,2:!0}},blendEquationEXT:{1:{0:!0}},bufferData:{3:{0:!0,2:!0},4:{0:!0,2:!0},5:{0:!0,2:!0}},bufferSubData:{3:{0:!0},4:{0:!0},5:{0:!0}},copyBufferSubData:{5:{0:!0,1:!0}},getBufferSubData:{3:{0:!0},4:{0:!0},5:{0:!0}},blitFramebuffer:{10:{8:{enumBitwiseOr:["COLOR_BUFFER_BIT","DEPTH_BUFFER_BIT","STENCIL_BUFFER_BIT"]},9:!0}},framebufferTextureLayer:{5:{0:!0,1:!0}},invalidateFramebuffer:{2:{0:!0}},invalidateSubFramebuffer:{6:{0:!0}},readBuffer:{1:{0:!0}},getInternalformatParameter:{3:{0:!0,1:!0,2:!0}},renderbufferStorageMultisample:{5:{0:!0,2:!0}},texStorage2D:{5:{0:!0,2:!0}},texStorage3D:{6:{0:!0,2:!0}},texImage2D:{9:{0:!0,2:!0,6:!0,7:!0},6:{0:!0,2:!0,3:!0,4:!0},10:{0:!0,2:!0,6:!0,7:!0}},texImage3D:{10:{0:!0,2:!0,7:!0,8:!0},11:{0:!0,2:!0,7:!0,8:!0}},texSubImage2D:{9:{0:!0,6:!0,7:!0},7:{0:!0,4:!0,5:!0},10:{0:!0,6:!0,7:!0}},texSubImage3D:{11:{0:!0,8:!0,9:!0},12:{0:!0,8:!0,9:!0}},copyTexSubImage3D:{9:{0:!0}},compressedTexImage2D:{7:{0:!0,2:!0},8:{0:!0,2:!0},9:{0:!0,2:!0}},compressedTexImage3D:{8:{0:!0,2:!0},9:{0:!0,2:!0},10:{0:!0,2:!0}},compressedTexSubImage2D:{8:{0:!0,6:!0},9:{0:!0,6:!0},10:{0:!0,6:!0}},compressedTexSubImage3D:{10:{0:!0,8:!0},11:{0:!0,8:!0},12:{0:!0,8:!0}},vertexAttribIPointer:{5:{2:!0}},drawArraysInstanced:{4:{0:!0}},drawElementsInstanced:{5:{0:!0,2:!0}},drawRangeElements:{6:{0:!0,4:!0}},readPixels:{7:{4:!0,5:!0},8:{4:!0,5:!0}},clearBufferfv:{3:{0:!0},4:{0:!0}},clearBufferiv:{3:{0:!0},4:{0:!0}},clearBufferuiv:{3:{0:!0},4:{0:!0}},clearBufferfi:{4:{0:!0}},beginQuery:{2:{0:!0}},endQuery:{1:{0:!0}},getQuery:{2:{0:!0,1:!0}},getQueryParameter:{2:{1:!0}},samplerParameteri:{3:{1:!0,2:!0}},samplerParameterf:{3:{1:!0}},getSamplerParameter:{2:{1:!0}},fenceSync:{2:{0:!0,1:{enumBitwiseOr:[]}}},clientWaitSync:{3:{1:{enumBitwiseOr:["SYNC_FLUSH_COMMANDS_BIT"]}}},waitSync:{3:{1:{enumBitwiseOr:[]}}},getSyncParameter:{2:{1:!0}},bindTransformFeedback:{2:{0:!0}},beginTransformFeedback:{1:{0:!0}},transformFeedbackVaryings:{3:{2:!0}},bindBufferBase:{3:{0:!0}},bindBufferRange:{5:{0:!0}},getIndexedParameter:{2:{0:!0}},getActiveUniforms:{3:{2:!0}},getActiveUniformBlockParameter:{3:{2:!0}}},n=null,i=null;function a(e){if(null==n)for(var t in n={},i={},e)"number"===typeof e[t]&&(n[e[t]]=t,i[t]=e[t])}function o(){if(null==n)throw"WebGLDebugUtils.init(ctx) not called"}function s(e){return o(),void 0!==n[e]}function u(e){o();var t=n[e];return void 0!==t?"gl."+t:"/*UNKNOWN WebGL ENUM*/ 0x"+e.toString(16)}function c(e,t,n,a){var o=r[e];if(void 0!==o){o=o[t];if(void 0!==o&&o[n]){if("object"===Object(Oe["a"])(o[n])&&void 0!==o[n]["enumBitwiseOr"]){for(var s=o[n]["enumBitwiseOr"],c=0,l=[],h=0;h<s.length;++h){var d=i[s[h]];0!==(a&d)&&(c|=d,l.push(u(d)))}return c===a?l.join(" | "):u(a)}return u(a)}}return null===a?"null":void 0===a?"undefined":a.toString()}function l(e,t){for(var r="",n=t.length,i=0;i<n;++i)r+=(0==i?"":", ")+c(e,n,i,t[i]);return r}function h(e,t,r){e.__defineGetter__(r,(function(){return t[r]})),e.__defineSetter__(r,(function(e){t[r]=e}))}function d(e,r,n,i){i=i||e,a(e),r=r||function(e,r,n){for(var i="",a=n.length,o=0;o<a;++o)i+=(0==o?"":", ")+c(r,a,o,n[o]);t("WebGL error "+u(e)+" in "+r+"("+i+")")};var o={};function s(e,t){return function(){n&&n(t,arguments);var a=e[t].apply(e,arguments),s=i.getError();return 0!=s&&(o[s]=!0,r(s,t,arguments)),a}}var l={};for(var f in e)if("function"===typeof e[f])if("getExtension"!=f)l[f]=s(e,f);else{var _=s(e,f);l[f]=function(){var t=_.apply(e,arguments);return t?d(t,r,n,i):null}}else h(l,e,f);return l.getError=function(){for(var t in o)if(o.hasOwnProperty(t)&&o[t])return o[t]=!1,t;return e.NO_ERROR},l}function f(e){var t=!!e.createTransformFeedback;t&&e.bindVertexArray(null);var r=e.getParameter(e.MAX_VERTEX_ATTRIBS),n=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,n);for(var i=0;i<r;++i)e.disableVertexAttribArray(i),e.vertexAttribPointer(i,4,e.FLOAT,!1,0,0),e.vertexAttrib1f(i,0),t&&e.vertexAttribDivisor(i,0);e.deleteBuffer(n);var a=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS);for(i=0;i<a;++i)e.activeTexture(e.TEXTURE0+i),e.bindTexture(e.TEXTURE_CUBE_MAP,null),e.bindTexture(e.TEXTURE_2D,null),t&&(e.bindTexture(e.TEXTURE_2D_ARRAY,null),e.bindTexture(e.TEXTURE_3D,null),e.bindSampler(i,null));if(e.activeTexture(e.TEXTURE0),e.useProgram(null),e.bindBuffer(e.ARRAY_BUFFER,null),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindRenderbuffer(e.RENDERBUFFER,null),e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.DITHER),e.disable(e.SCISSOR_TEST),e.blendColor(0,0,0,0),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.clearColor(0,0,0,0),e.clearDepth(1),e.clearStencil(-1),e.colorMask(!0,!0,!0,!0),e.cullFace(e.BACK),e.depthFunc(e.LESS),e.depthMask(!0),e.depthRange(0,1),e.frontFace(e.CCW),e.hint(e.GENERATE_MIPMAP_HINT,e.DONT_CARE),e.lineWidth(1),e.pixelStorei(e.PACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.UNPACK_COLORSPACE_CONVERSION_WEBGL&&e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.BROWSER_DEFAULT_WEBGL),e.polygonOffset(0,0),e.sampleCoverage(1,!1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilMask(4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.viewport(0,0,e.canvas.width,e.canvas.height),e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT|e.STENCIL_BUFFER_BIT),t){e.drawBuffers([e.BACK]),e.readBuffer(e.BACK),e.bindBuffer(e.COPY_READ_BUFFER,null),e.bindBuffer(e.COPY_WRITE_BUFFER,null),e.bindBuffer(e.PIXEL_PACK_BUFFER,null),e.bindBuffer(e.PIXEL_UNPACK_BUFFER,null);var o=e.getParameter(e.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS);for(i=0;i<o;++i)e.bindBufferBase(e.TRANSFORM_FEEDBACK_BUFFER,i,null);var s=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);for(i=0;i<s;++i)e.bindBufferBase(e.UNIFORM_BUFFER,i,null);e.disable(e.RASTERIZER_DISCARD),e.pixelStorei(e.UNPACK_IMAGE_HEIGHT,0),e.pixelStorei(e.UNPACK_SKIP_IMAGES,0),e.pixelStorei(e.UNPACK_ROW_LENGTH,0),e.pixelStorei(e.UNPACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_SKIP_PIXELS,0),e.pixelStorei(e.PACK_ROW_LENGTH,0),e.pixelStorei(e.PACK_SKIP_ROWS,0),e.pixelStorei(e.PACK_SKIP_PIXELS,0),e.hint(e.FRAGMENT_SHADER_DERIVATIVE_HINT,e.DONT_CARE)}while(e.getError());}function _(e){var t,r,n=[],i=[],a={},o=1,s=!1,u=[],c=0,l=0,d=!1,_=0,p={};function g(e){return"function"===typeof e?e:function(t){e.handleEvent(t)}}e.getContext=function(n){return function(){var i=n.apply(e,arguments);if(i instanceof WebGLRenderingContext||window.WebGL2RenderingContext&&i instanceof WebGL2RenderingContext){if(i!=t){if(t)throw"got different context";r=window.WebGL2RenderingContext&&i instanceof WebGL2RenderingContext,t=i,a=A(t)}return a}return i}}(e.getContext);var m=function(e){n.push(g(e))},v=function(e){i.push(g(e))};function b(e){var t=e.addEventListener;e.addEventListener=function(r,n,i){switch(r){case"webglcontextlost":m(n);break;case"webglcontextrestored":v(n);break;default:t.apply(e,arguments)}}}function S(){for(var e=Object.keys(p),t=0;t<e.length;++t)delete p[e[t]]}function x(){++l,s||c==l&&e.loseContext()}function T(e,t){var r=e[t];return function(){if(x(),!s){var t=r.apply(e,arguments);return t}}}function y(){for(var e=0;e<u.length;++e){var n=u[e];n instanceof WebGLBuffer?t.deleteBuffer(n):n instanceof WebGLFramebuffer?t.deleteFramebuffer(n):n instanceof WebGLProgram?t.deleteProgram(n):n instanceof WebGLRenderbuffer?t.deleteRenderbuffer(n):n instanceof WebGLShader?t.deleteShader(n):n instanceof WebGLTexture?t.deleteTexture(n):r&&(n instanceof WebGLQuery?t.deleteQuery(n):n instanceof WebGLSampler?t.deleteSampler(n):n instanceof WebGLSync?t.deleteSync(n):n instanceof WebGLTransformFeedback?t.deleteTransformFeedback(n):n instanceof WebGLVertexArrayObject&&t.deleteVertexArray(n))}}function C(e){return{statusMessage:e,preventDefault:function(){d=!0}}}return b(e),e.loseContext=function(){if(!s){s=!0,c=0,++o;while(t.getError());S(),p[t.CONTEXT_LOST_WEBGL]=!0;var r=C("context lost"),i=n.slice();setTimeout((function(){for(var t=0;t<i.length;++t)i[t](r);_>=0&&setTimeout((function(){e.restoreContext()}),_)}),0)}},e.restoreContext=function(){s&&i.length&&setTimeout((function(){if(!d)throw"can not restore. webglcontestlost listener did not call event.preventDefault";y(),f(t),s=!1,l=0,d=!1;for(var e=i.slice(),r=C("context restored"),n=0;n<e.length;++n)e[n](r)}),0)},e.loseContextInNCalls=function(e){if(s)throw"You can not ask a lost contet to be lost";c=l+e},e.getNumCalls=function(){return l},e.setRestoreTimeout=function(e){_=e},e;function A(e){for(var n in e)"function"===typeof e[n]?a[n]=T(e,n):h(a,e,n);a.getError=function(){if(x(),!s)while(e=t.getError())p[e]=!0;for(var e in p)if(p[e])return delete p[e],e;return a.NO_ERROR};var i=["createBuffer","createFramebuffer","createProgram","createRenderbuffer","createShader","createTexture"];r&&i.push("createQuery","createSampler","fenceSync","createTransformFeedback","createVertexArray");for(var c=0;c<i.length;++c){var l=i[c];a[l]=function(t){return function(){if(x(),s)return null;var r=t.apply(e,arguments);return r.__webglDebugContextLostId__=o,u.push(r),r}}(e[l])}var d=["getActiveAttrib","getActiveUniform","getBufferParameter","getContextAttributes","getAttachedShaders","getFramebufferAttachmentParameter","getParameter","getProgramParameter","getProgramInfoLog","getRenderbufferParameter","getShaderParameter","getShaderInfoLog","getShaderSource","getTexParameter","getUniform","getUniformLocation","getVertexAttrib"];r&&d.push("getInternalformatParameter","getQuery","getQueryParameter","getSamplerParameter","getSyncParameter","getTransformFeedbackVarying","getIndexedParameter","getUniformIndices","getActiveUniforms","getActiveUniformBlockParameter","getActiveUniformBlockName");for(c=0;c<d.length;++c){l=d[c];a[l]=function(t){return function(){return x(),s?null:t.apply(e,arguments)}}(a[l])}var f=["isBuffer","isEnabled","isFramebuffer","isProgram","isRenderbuffer","isShader","isTexture"];r&&f.push("isQuery","isSampler","isSync","isTransformFeedback","isVertexArray");for(c=0;c<f.length;++c){l=f[c];a[l]=function(t){return function(){return x(),!s&&t.apply(e,arguments)}}(a[l])}return a.checkFramebufferStatus=function(t){return function(){return x(),s?a.FRAMEBUFFER_UNSUPPORTED:t.apply(e,arguments)}}(a.checkFramebufferStatus),a.getAttribLocation=function(t){return function(){return x(),s?-1:t.apply(e,arguments)}}(a.getAttribLocation),a.getVertexAttribOffset=function(t){return function(){return x(),s?0:t.apply(e,arguments)}}(a.getVertexAttribOffset),a.isContextLost=function(){return s},r&&(a.getFragDataLocation=function(t){return function(){return x(),s?-1:t.apply(e,arguments)}}(a.getFragDataLocation),a.clientWaitSync=function(t){return function(){return x(),s?a.WAIT_FAILED:t.apply(e,arguments)}}(a.clientWaitSync),a.getUniformBlockIndex=function(t){return function(){return x(),s?a.INVALID_INDEX:t.apply(e,arguments)}}(a.getUniformBlockIndex)),a}}return{init:a,mightBeEnum:s,glEnumToString:u,glFunctionArgToString:c,glFunctionArgsToString:l,makeDebugContext:d,makeLostContextSimulatingCanvas:_,resetToInitialState:f}}()),Pe=Ie,De=(n("b680"),n("1276"),n("8ba4"),n("aee2")),Le=n("38f3"),Fe=n("b5d5"),ke=n("9f78"),Be=n("032c"),Ue=n("2449"),Ve=(n("84c3"),n("9946")),Ge=n("16f6"),ze=n("931a"),je=n("6ec8"),He=function e(){this._values=new Float32Array(e.maxGraphValue),this._index=0,this._maxValue=0,this._x=0,this._y=0};He.maxGraphValue=120,He.prototype={getIndex:function(){return this._index},getValues:function(){return this._values},setDisplayPosition:function(e,t){this._x=e,this._y=t},getX:function(){return this._x},getY:function(){return this._y},addValue:function(e,t){var r=this._index;this._maxValue=e>this._maxValue?e:this._maxValue,this._maxValue*=.99,this._values[r]=e/(1.1*this._maxValue),t&&(this._values[r]+=t),this._index=(this._index+1)%He.maxGraphValue}};var We=He,Xe=function(){this._usageHint=X["a"].DYNAMIC_DRAW;var e=6560;this._nbVertexes=0,this._maxNbVertexes=0,this._captionNbVertexes=0,this._valuesNbVertexes=0,this._graphsNbVertexes=0,this.resize(e)};Xe.backgroundColor=10,Xe.redColor=7,Xe.greyColor=4,Xe.whiteColor=1,j["a"].createPrototypeObject(Xe,{getGeometry:function(){return this._geometry},generateBackground:function(e,t,r,n){var i=this._vertexes;this._nbVertexes+=4,i[0]=e,i[1]=t,i[2]=0,i[3]=Xe.backgroundColor;var a=e+r,o=t+n;i[4]=e,i[5]=o,i[6]=0,i[7]=Xe.backgroundColor,i[8]=a,i[9]=o,i[10]=0,i[11]=Xe.backgroundColor,i[12]=a,i[13]=t,i[14]=0,i[15]=Xe.backgroundColor},generateCharacter:function(e,t,r,n,i,a,o){var s=this._vertexes,u=this._nbVertexes;this._nbVertexes+=4;var c=4*u;s[c++]=e,s[c++]=t,s[c++]=i,s[c++]=-(0+o);var l=e+r,h=t+n;s[c++]=e,s[c++]=h,s[c++]=i,s[c++]=-(1+o),s[c++]=l,s[c++]=h,s[c++]=a,s[c++]=-(1+o),s[c++]=l,s[c++]=t,s[c++]=a,s[c++]=-(0+o)},generateText:function(e,t,r,n,i){var a=r.length;this._nbVertexes+4*a>=this._maxNbVertexes&&this.resize(2*this._maxNbVertexes);for(var o=n._characterSizeUV,s=n._characterWidth,u=n._characterHeight,c=0;c<a;c++){var l=r.charCodeAt(c),h=n.getCharacterUV(l);this.generateCharacter(e,t,s,u,h,h+o,i),e+=s}return a*s},generateGraph:function(e,t){this._nbVertexes+2*We.maxGraphValue>=this._maxNbVertexes&&this.resize(2*this._maxNbVertexes);var r=this._vertexes,n=this._nbVertexes,i=e.getValues(),a=i.length,o=e.getIndex(),s=e.getX(),u=e.getY();this._nbVertexes+=2*a;for(var c=0;c<a;c++){var l=(o+c)%a,h=i[l],d=n+2*c,f=4*d,_=h,p=Xe.greyColor;_>=Xe.redColor&&(p=Xe.redColor,_-=Xe.redColor),_>1&&(_=1),_*=t,_<1&&(_=1),r[f]=s+2*c,r[f+1]=u,r[f+2]=0,r[f+3]=p,r[f+4]=s+2*c,r[f+5]=u+_,r[f+6]=0,r[f+7]=p}},resize:function(e){L["a"].log("resize buffer to "+e),this._maxNbVertexes=e;var t=new Float32Array(4*e);this._vertexes&&t.set(this._vertexes),this._vertexes=t;var r=Math.ceil(e/4);this._indexes=new Uint16Array(6*r);for(var n=0,i=0;n<r;n++)this._indexes[i++]=4*n+0,this._indexes[i++]=4*n+1,this._indexes[i++]=4*n+3,this._indexes[i++]=4*n+3,this._indexes[i++]=4*n+1,this._indexes[i++]=4*n+2;if(this._geometry)return this._geometry.getAttributes().Vertex.setElements(this._vertexes),void this._characterPrimitive.getIndices().setElements(this._indexes);this._geometry=new Ve["a"],this._geometry.setName("osgStats-Stats"),this._geometry.getAttributes().Vertex=new X["a"](X["a"].ARRAY_BUFFER,this._vertexes,4,!0);var a=new X["a"](X["a"].ELEMENT_ARRAY_BUFFER,this._indexes,1);this._geometry.getAttributes().Vertex.setUsage(this._usageHint);var o=new ze["a"](Ge["a"].TRIANGLES,a);this._characterPrimitive=o,this._geometry.getPrimitives().push(this._characterPrimitive);var s=new je["a"](Ge["a"].LINES,0,0);this._graphPrimitive=s,this._geometry.getPrimitives().push(this._graphPrimitive)},update:function(){var e=this._captionNbVertexes+this._valuesNbVertexes;this._characterPrimitive.setCount(e/4*6),this._graphPrimitive.setCount(this._graphsNbVertexes),this._graphPrimitive.setFirst(e),this._geometry.getAttributes().Vertex.dirty()},resetCaptions:function(){this._nbVertexes=0,this._captionNbVertexes=0},resetValues:function(){this._nbVertexes=this._captionNbVertexes,this._valuesNbVertexes=0,this._graphsNbVertexes=0},captionsEnd:function(){this._captionNbVertexes=this._nbVertexes},valuesEnd:function(){this._valuesNbVertexes=this._nbVertexes-this._captionNbVertexes},graphsEnd:function(){this._graphsNbVertexes=this._nbVertexes-(this._valuesNbVertexes+this._captionNbVertexes)},getCharacterPrimitive:function(){return this._characterPrimitive},getGraphPrimitive:function(){return this._graphPrimitive},getNbVertexes:function(){return this._nbVertexes}});var qe=Xe,Ke=window.performance,Je=function(e){this._caption=e.caption,this._accumValue=0,this._accumSamples=0,this._accumStart=0,this._value=0,this._averageValue=0,this._time=0,this._avgMs=0,this._over=e.over>0?e.over:0,this._below=e.below>0?e.below:0,this._graph=!!e.graph,e.average&&(this._avgMs=e.avgMs?e.avgMs:1e3),this._display=!1};j["a"].createPrototypeObject(Je,{isDisplayable:function(){return this._display},setDisplayable:function(e){this._display=e},getOver:function(){return this._over},getBelow:function(){return this._below},getGraph:function(){return this._graph},getAverageMs:function(){return this._avgMs},getAverageValue:function(){return this._averageValue},getValue:function(){return this._value},average:function(e){if(this._avgMs){this._accumValue+=e,this._accumSamples++;var t=Ke.now();t-this._accumStart>this._avgMs&&(this._averageValue=this._accumValue/this._accumSamples,this._accumValue=0,this._accumStart=t,this._accumSamples=0)}},start:function(){this._display=!0,this._time=Ke.now()},end:function(){this._value=Ke.now()-this._time,this.average(this._value)},set:function(e){this._display=!0,this._value=e,this.average(e)},tick:function(){this.end(),this.start()},frame:function(){var e=Ke.now()-this._time;this.set(1e3/e),this.start()}});var Ze=Je,Qe="Courier New",$e=function(e){var t=document.getElementsByTagName("body")[0],r=document.createElement("div"),n=document.createTextNode("M");r.appendChild(n),r.setAttribute("style",e),t.appendChild(r);var i=r.offsetHeight;return t.removeChild(r),i},et=function(e){return new U.a((function(t,r){window.WebFontConfig={google:{families:[e+":200"]},active:function(){t(e)},inactive:function(e){r("loadFont error:"+e)}};var n=document.createElement("script"),i=document.scripts[0];n.src="https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js",n.async=!0,n.onerror=function(){r()},i.parentNode.insertBefore(n,i)}))},tt=function(){this._canvas=void 0,this._characterHeight=0,this._characterWidth=0,this._fontSize=16,this._fontFamily="Source Code Pro",this._characterFirstCode=" ".charCodeAt(),this._characterLastCode="z".charCodeAt(),this._characterSizeUV=0,this._backgroundColor="rgba(0,0,0,0.0)",this._createCanvas()};j["a"].createPrototypeObject(tt,{setFontSize:function(e){this._fontSize=e},getCharacterWidth:function(){return this._characterWidth},getCharacterHeight:function(){return this._characterHeight},getCanvas:function(){return this._promise},getCharacterUV:function(e){var t=e-this._characterFirstCode;return t*this._characterSizeUV},_fillCanvas:function(e,t){var r=t+"px",n="font-family: "+e+"; font-size: "+r+";",i=$e(n);L["a"].debug(e+" "+r+" ==> "+i+" pixels high."),this._characterHeight=Math.ceil(i);var a=t+"px '"+e+"'",o=document.createElement("canvas"),s=o.getContext("2d");this._canvas=o,s.font=a,s.textBaseline="middle",this._characterWidth=s.measureText(" ").width,this._characterWidth=Math.ceil(this._characterWidth);var u=this._characterLastCode-this._characterFirstCode+1;L["a"].info("Stats character size "+this._characterWidth+" x "+this._characterHeight+" texture width "+this._characterWidth*u),o.width=Math.ceil(this._characterWidth*u),o.height=this._characterHeight,this._characterSizeUV=this._characterWidth/o.width,s.font=a,s.textBaseline="middle",s.fillStyle="rgb(255,255,255)";for(var c=this._characterFirstCode,l=0;c<=this._characterLastCode;c++,l++){var h=String.fromCharCode(c),d=l*this._characterWidth,f=this._characterHeight/2;s.fillText(h,d,f)}return o},_createCanvas:function(){this._promise=et(this._fontFamily).then(function(e){return this._fillCanvas(e,this._fontSize)}.bind(this)).catch(function(){return this._fillCanvas(Qe,this._fontSize)}.bind(this))}});var rt=tt,nt=n("a1bc"),it=n("f662"),at=n("5f6c"),ot=n("ecf1"),st=32768,ut=function(){var e=["attribute vec4 Vertex;","uniform mat4 uModelViewMatrix;","uniform mat4 uProjectionMatrix;","","varying vec2 vTexCoord0;","","void main(void) {"," vTexCoord0 = Vertex.zw;"," gl_Position = uProjectionMatrix * (uModelViewMatrix * vec4(Vertex.xy,0.0, 1.0));","}"].join("\n"),t=["#define SHADER_NAME STATS","varying vec2 vTexCoord0;","uniform sampler2D Texture0;","void main(void) {"," vec4 color = vec4(1.0);"," vec2 uv = vTexCoord0;"," int isText = 0;"," if ( uv.y < 0.0 ) {"," isText = 1;"," uv.y = -uv.y;"," }"," if ( uv.y >= "+(qe.backgroundColor-1).toFixed(1)+" ) {"," color = vec4(0.0,0.0,0.0,0.5);"," uv.y -= "+qe.backgroundColor.toFixed(1)+";"," } else if ( uv.y >= "+(qe.redColor-1).toFixed(1)+" ) {"," color = vec4(1.0,0.0,0.0,1.0);"," uv.y -= "+qe.redColor.toFixed(1)+";"," } else if ( uv.y == "+(qe.greyColor-1).toFixed(1)+" ) {"," color = vec4(0.5,0.5,0.5,1.0);"," uv.y -= "+qe.greyColor.toFixed(1)+";"," } else {"," uv.y -= "+qe.whiteColor.toFixed(1)+";"," }"," if ( isText == 1 ) {"," color *= texture2D( Texture0, uv.xy);"," }"," gl_FragColor = color;","}"].join("\n");return new K["a"](new Y["a"]("VERTEX_SHADER",e),new Y["a"]("FRAGMENT_SHADER",t))},ct=function(e,t){this._captionsBuffer=void 0,this._valuesBuffer=void 0,this._dirtyCaptions=!0,this._dirtyValues=!0,this._viewer=e,this._labelMaxWidth=0,this._viewport=e.getCamera().getViewport(),this._node=void 0,this._text=void 0,this._offsetGroup=void 0,this._counters={},this._groups={},this._updates=[],this._displayableCounters={},this._x=0,this._y=0,this._width=0,this._height=0,this._maxCaptionTextLength=32,this._lineFactor=1.1,this._displayFilter=[],this._backgroundWidth=0,this._backgroundHeight=0,this._bufferStats=new qe,this._historyGraph={},this._graphToDisplay=[],this._valuesMaxWidth=72,this._showGraph=!1,this._backgroundPicking=at["a"].createTexturedQuadGeometry(0,0,0,10,0,0,0,10,0),this._backgroundPicking.setName("osgStats-Background-picking"),this._dragStop=F["e"].create(),this._dragStart=F["e"].create(),this._startTransformation=F["c"].create(),this._init(t)};j["a"].createPrototypeObject(ct,{getCounter:function(e){return this._counters[e]||(this._counters[e]=new Ze({caption:e,average:!0})),this._counters[e]},getBufferStats:function(){return this._bufferStats},addConfig:function(e){if(!e.init||e.init()){for(var t in e.values){var r=e.values[t],n=new Ze(r);this._counters[t]=n}if(e.groups)for(var i=0;i<e.groups.length;i++){var a=e.groups[i],o={caption:a.caption,values:a.values,textCursorY:new Float32Array(a.values.length)},s=a.name?a.name:a.caption;this._groups[s]=o}e.update&&this._updates.push(e.update)}},reset:function(){this._bufferStats.resetCaptions(),this._bufferStats.resetValues(),this._dirtyCaptions=!0,this._dirtyValue=!0,this._bufferStats.resize(this._bufferStats._maxNbVertexes)},update:function(){for(var e=0;e<this._updates.length;e++)this._updates[e](this);this._dirtyValues=!0,(this._checkViewportChanged()||this._checkCounterDisplayableChanged())&&(this._dirtyCaptions=!0),this._dirtyCaptions&&(this._bufferStats.resetCaptions(),this._generateCaptions(),this._dirtyCaptions=!1),this._dirtyValues&&(this._bufferStats.resetValues(),this._generateValues(),this._dirtyValues=!1)},getNode:function(){return this._node},setShowFilter:function(e){this._dirtyCaptions=!0,e?this._displayFilter=e.slice():this._displayFilter.length=0},_init:function(e){var t=new Le["a"];t.setRenderOrder(Le["a"].POST_RENDER,0),t.setReferenceFrame(Ue["a"].ABSOLUTE_RF),t.setClearMask(0);var r=new Be["a"];r.setName("StatsNode"),r.addChild(this._backgroundPicking),this._nodeTransform=r,this._backgroundPicking.setNodeMask(0),t.addChild(r),t.setName("osgStats"),t.setViewport(this._viewport),this._node=t,this._text=new rt;var n=12;if(e){var i=e.getString("statsFilter");if(i){var a=i.split(";");this.setShowFilter(a)}var o=e.getNumber("statsFontSize");void 0!==o&&(n=o),this._showGraph=e.getBoolean("statsShowGraph")}var s=new J["default"];s.setMinFilter(J["default"].NEAREST),s.setMagFilter(J["default"].NEAREST),this._text.setFontSize(n*this._viewer.getCanvasPixelRatio()),this._text.getCanvas().then(function(e){this._dirtyCaptions=!0;var t=this._bufferStats.getGeometry();t.setNodeMask(~st),r.addChild(t),s.setImage(e),t.setBound(new ot["a"])}.bind(this)),r.getOrCreateStateSet().setAttributeAndModes(ut()),r.getOrCreateStateSet().setAttributeAndModes(new Fe["a"](Fe["a"].DISABLE));var u=new De["a"]("SRC_ALPHA","ONE_MINUS_SRC_ALPHA");r.getOrCreateStateSet().setAttributeAndModes(u),r.getOrCreateStateSet().setAttributeAndModes(new ke["a"](ke["a"].DISABLE)),r.getOrCreateStateSet().setTextureAttributeAndModes(0,s);var c=this._viewer.getGraphicContext().canvas;this._canvas=c;var l=this._viewer.getInputManager();l.group(ne.STATS).addMappings({onMouseMove:["mousemove","touchmove"],onMouseDown:["mousedown","touchstart"],onMouseUp:["mouseup","mouseout","touchend","touchcancel"]},this),l.setPriority(ne.STATS,l.getHigherPriority(ne.SCENE))},onMouseDown:function(e){var t=this.computeNearestIntersection(e);this._onStats=!!t.length,this._onStats&&(this._viewer.getInputManager().setEnable(ne.SCENE,!1),F["c"].copy(this._startTransformation,this._nodeTransform.getMatrix()),F["e"].set(this._dragStart,e.canvasX,e.canvasY),this._dragStop[1]=this._dragStart[1])},onMouseMove:function(){var e=F["f"].create();return function(t){if(this._onStats){F["e"].set(this._dragStop,t.canvasX,t.canvasY);var r=this._dragStop[1]-this._dragStart[1];F["c"].translate(this._nodeTransform.getMatrix(),this._startTransformation,F["f"].set(e,0,-r,0))}}}(),onMouseUp:function(){this._viewer.getInputManager().setEnable(ne.SCENE,!0),this._onStats=!1},computeNearestIntersection:function(){var e=new it["a"],t=F["f"].create(),r=F["f"].create(),n=new nt["a"];return n.setIntersector(e),function(i){var a=i.glX,o=i.glY;e.reset(),e.set(F["f"].set(t,a,o,0),F["f"].set(r,a,o,1)),n.reset(),this._backgroundPicking.setNodeMask(st),n.setTraversalMask(st),this._node.accept(n);var s=e.getIntersections();return this._backgroundPicking.setNodeMask(0),s}}(),_updateBackgroundPicking:function(e,t,r,n){var i=this._backgroundPicking.getVertexAttributeList().Vertex.getElements();i[0]=e,i[1]=t+n,i[3]=e,i[4]=t,i[6]=e+r,i[7]=t,i[9]=e+r,i[10]=t+n,this._backgroundPicking.getVertexAttributeList().Vertex.dirty(),this._backgroundPicking.dirtyBound()},_generateCaptions:function(){var e=0,t=this._text.getCharacterHeight(),r=e,n=this._viewport.height()-t;this._labelMaxWidth=0,this._bufferStats.generateBackground(0,this._viewport.height()-this._backgroundHeight,this._backgroundWidth,this._backgroundHeight),this._updateBackgroundPicking(0,this._viewport.height()-this._backgroundHeight,this._backgroundWidth,this._backgroundHeight);var i=this._displayFilter;for(var a in this._groups)if(!a||!i.length||-1!==i.indexOf(a)){var o=this._groups[a],s="--- "+o.caption+" ---",u=this._bufferStats.generateText(r,n,s,this._text,qe.whiteColor);this._labelMaxWidth=Math.max(u,this._labelMaxWidth),r=e,n-=this._lineFactor*t;for(var c=0;c<o.values.length;c++){var l=o.values[c],h=this._counters[l];if(h&&h.isDisplayable()){o.textCursorY[c]=n;for(var d=h._caption,f=d.length/this._maxCaptionTextLength,_=0;_<f;_++){var p=_*this._maxCaptionTextLength,g=d.substr(p,this._maxCaptionTextLength);u=this._bufferStats.generateText(r,n,g,this._text,qe.whiteColor),this._labelMaxWidth=Math.max(u,this._labelMaxWidth),n-=t,r=e}}}n-=t}this._bufferStats.captionsEnd()},_generateValues:function(){var e,t=this._text.getCharacterWidth(),r=this._labelMaxWidth+2*t,n=this._valuesMaxWidth+2*t,i=this._text.getCharacterHeight(),a=r,o=this._displayFilter,s=0;for(var u in this._groups)if(!u||!o.length||-1!==o.indexOf(u)){var c=this._groups[u];a=r;for(var l=0;l<c.values.length;l++){var h=c.values[l],d=this._counters[h];if(d&&d.isDisplayable()){var f,_=d.getAverageMs()?d.getAverageValue():d.getValue();f=Number.isInteger(_)?_.toString():_.toFixed(2),e=c.textCursorY[l];var p=qe.whiteColor,g=d.getOver(),m=d.getBelow();0!==g?p=_>g?qe.redColor:p:0!==m&&(p=_<m?qe.redColor:p);var v=this._bufferStats.generateText(a,e,f,this._text,p);s=Math.max(v,s),this._showGraph&&d._graph&&(this._historyGraph[h]||(this._historyGraph[h]=new We),this._graphToDisplay.push(this._historyGraph[h]),this._historyGraph[h].setDisplayPosition(r+n,e),this._historyGraph[h].addValue(_,p)),a=r}}}this._bufferStats.valuesEnd(),this._valuesMaxWidth=s;for(var b=0;b<this._graphToDisplay.length;b++){var S=this._graphToDisplay[b];this._bufferStats.generateGraph(S,i-2)}var x=r+n;this._graphToDisplay.length&&(x+=2*We.maxGraphValue+1);var T=this._viewport.height()-e;this._backgroundWidth===x&&this._backgroundHeight===T||(this._backgroundWidth=x,this._backgroundHeight=T,this._dirtyCaptions=!0),this._graphToDisplay.length=0,this._bufferStats.graphsEnd(),this._bufferStats.update()},_checkCounterDisplayableChanged:function(){var e=!1;for(var t in this._counters){var r=this._counters[t];this._displayableCounters[t]!==r.isDisplayable()&&(this._displayableCounters[t]=r.isDisplayable(),e=!0)}return e},_checkViewportChanged:function(){var e=this._viewport.x(),t=this._viewport.y(),r=this._viewport.width(),n=this._viewport.height();if(e!==this._x||t!==this._y||r!==this._width||n!==this._height){this._x=e,this._y=t,this._width=r,this._height=n;var i=this._node;return F["c"].ortho(i.getProjectionMatrix(),this._x,this._width,this._y,this._height,-5,5),!0}return!1}});var lt=ct,ht={frame:{caption:"Total frame time",over:16,average:!0,graph:!0,max:4},stats:{caption:"stats",over:1,graph:!0},fps:{caption:"Framerate (FPS)",below:30,average:!0},raf:{caption:"Time since last rAF",average:!0,avgMs:500},update:{caption:"update",average:!0,graph:!0},cull:{caption:"cull",average:!0,graph:!0,max:16},render:{caption:"render",average:!0,graph:!0},glframe:{caption:"glframe",average:!0,graph:!0},textureused:{caption:"texture used"},texturereserved:{caption:"texture reserved"},texturetotal:{caption:"texture total"},pushstateset:{caption:"num pushStateSet"},applyStateSet:{caption:"num applyStateSet"},updatecallback:{caption:"num updateCallback"},cullcamera:{caption:"camera"},cullmatrixtransform:{caption:"matrixTransform"},cullprojection:{caption:"projection"},cullnode:{caption:"node"},culllightsource:{caption:"lightSource"},cullgeometry:{caption:"geometry"}},dt=[{name:"framerate",caption:"Framerate",values:["fps","raf"]},{name:"frameBudget",caption:"Frame Budget",base:"frame",values:["frame","update","cull","render","glframe","stats"]},{name:"sceneGraph",caption:"Scene Graph ",values:["pushstateset","updatecallback","applyStateSet"]},{name:"cullVisitor",caption:"Cull",values:["cullnode","cullmatrixtransform","cullcamera","culllighsource","cullprojection","cullgeometry"]},{name:"texture",caption:"Texture Memory",values:["texturereserved","textureused","texturetotal"]}],ft={values:ht,groups:dt},_t=ft,pt=window.WebGLRenderingContext,gt=window.WebGL2RenderingContext,mt=[pt,gt],vt=function(e,t){return function(){t.apply(this,arguments),e.apply(this,arguments)}},bt=0,St=0,xt=0,Tt=0,yt=0,Ct=0,At=0,Et=0,Rt=0,Mt=0,wt=function(){for(var e=!1,t=0;t<mt.length;t++){var r=mt[t];r&&(e=!0,r.prototype.drawArrays=vt(r.prototype.drawArrays,(function(){bt++,arguments[0]===this.POINTS?Ct+=arguments[2]:yt+=arguments[2]})),r.prototype.drawElements=vt(r.prototype.drawElements,(function(){St++,Tt+=arguments[1]/3,yt+=arguments[1]})),r.prototype.useProgram=vt(r.prototype.useProgram,(function(){xt++})),r.prototype.bindTexture=vt(r.prototype.bindTexture,(function(){At++})))}return e},Nt=function(e){var t=e.getBufferStats(),r=t.getNbVertexes(),n=t.getCharacterPrimitive(),i=t.getGraphPrimitive();St-=1,i.getCount()&&(bt-=1),At-=2,xt-=1,yt-=n.getCount()+i.getCount(),Tt-=n.getCount()/3,Et=r,Rt=n.getCount()/3,Mt=i.getCount()/2,e.getCounter("glDrawCalls").set(St+bt),e.getCounter("glDrawElements").set(St),e.getCounter("glDrawArrays").set(bt),e.getCounter("glBindTexture").set(At),e.getCounter("glUseProgram").set(xt),e.getCounter("glFaces").set(Tt),e.getCounter("glVertices").set(yt),e.getCounter("glPoints").set(Ct),e.getCounter("statsVertices").set(Et),e.getCounter("statsFaces").set(Rt),e.getCounter("statsLines").set(Mt),Et=0,Rt=0,Mt=0,bt=0,St=0,xt=0,Tt=0,yt=0,Ct=0,At=0}.bind(void 0),Ot={values:{glDrawCalls:{caption:"drawCalls"},glDrawElements:{caption:"drawElements"},glDrawArrays:{caption:"drawArrays"},glBindTexture:{caption:"bindTexture"},glUseProgram:{caption:"useProgram"},glFaces:{caption:"totalFaces"},glVertices:{caption:"totalVertices"},glPoints:{caption:"totalPoints"},statsFaces:{caption:"statsFaces"},statsVertices:{caption:"statsVertices"},statsLines:{caption:"statsLines"}},groups:[{name:"webgl",caption:"WebGL",values:["glDrawCalls","glDrawElements","glDrawArrays","glUseProgram","glBindTexture","glFaces","glVertices","glPoints","statsVertices","statsFaces","statsLines"]}],update:Nt,init:wt},It=Ot,Pt=void 0,Dt=Math.log(1024),Lt=function(e){var t=100,r=Math.floor(Math.log(e)/Dt);return 0===e&&(r=1),Math.round(e*t/Math.pow(1024,r))/t},Ft=function(){return window.performance&&window.performance.memory&&(Pt=window.performance.memory),Pt&&0!==Pt.totalJSHeapSize||L["a"].warn("Stats will not report memory, not supported by your browse"),!!Pt},kt=function(e){var t=0,r=0;Pt&&(t=Lt(Pt.usedJSHeapSize),r=Lt(Pt.totalJSHeapSize)),e.getCounter("browserMemory").set(t),e.getCounter("browserMemoryTotal").set(r)},Bt={values:{browserMemory:{caption:"Used Memory",average:!0,avgMs:1e3},browserMemoryTotal:{caption:"Total Memory"}},groups:[{name:"browser",caption:"Browser",values:["browserMemory","browserMemoryTotal"]}],update:kt,init:Ft},Ut=Bt,Vt=10,Gt=["shift","alt","ctrl","meta"],zt=function(e,t){this._enabled=!0,this._name=t,this._mask=[],this._events={},this._mappings={},this._inputManager=e,this._boundCallback=this._collectNativeEvents.bind(this),this._priority=Vt,this._hasSources=!1};zt.prototype={addMappings:function(e,t){for(var r in e)e[this._name+":"+r]=e[r],delete e[r];this._inputManager.addMappings(e,t)},_collectNativeEvents:function(e){if(this._enabled&&!this._mask.length){var t=this._mappings[e.type];if(t)for(var r=0;r<t.length;r++){var n=t[r];if(!n._source.isEventRegistered||n._source.isEventRegistered(e,n._parsedEvent)){if(n._source.populateEvent(e,n),n._nativeEvents||(n._nativeEvents=[]),!n._nativeEvents.length){var i=this._inputManager._queues[n._priority];i||(i=[],this._inputManager._queues[n._priority]=i),i.push(n)}n._nativeEvents.push(e)}}}},_addEvent:function(e,t){var r,n=this._name+":"+t,i=!1,a=this._mappings[e.name];a?r=this._findEvent(a,n,e.raw):(a=[],this._mappings[e.name]=a,i=!0);var o=this._events[t];o||(o=[],this._events[t]=o),r||(r=new Event(n),a.push(r),o.push(r)),r._parsedEvent=e,r._priority=Vt;var s=this._inputManager._getSource(e.name);s&&(this._enabled&&i&&s.setEnable(e.name,this._boundCallback,!0),this._hasSources=!0,r._source=s)},_findEvent:function(e,t,r){for(var n=0;n<e.length;n++){var i=e[n];if(i.type===t&&i._parsedEvent.raw===r)return i}},_setEnable:function(e){for(var t in this._enabled=e,this._mappings){var r=this._mappings[t],n=r[0];n._source&&n._source.setEnable(t,this._boundCallback,e)}}};var jt=function(){this._groups={},this._sources=[],this._queues=[],this._queues[Vt]=[],this._callbacks={},this._params={},this._maskedGroups=[],window.dumpInputGroups=this._dumpInputGroups.bind(this),window.dumpEventSequence=this._dumpEventSequence.bind(this)};jt.prototype={registerInputSource:function(e){if(!e.setEnable||!e.supportsEvent||!e.getName)throw"Invalid input target "+JSON.stringify(e);this._sources.push(e),e.setInputManager(this)},getInputSource:function(e){for(var t=0;t<this._sources.length;t++){var r=this._sources[t];if(r.getName()===e)return r}},addMappings:function(e,t){for(var r in e){var n=e[r],i=r.split(":");if(2!==i.length)throw"Mapping should be of the form 'group:methodName': ['nativeevent1’, 'nativeevent2',...] ";var a,o,s=this._getOrCreateGroup(i[0]),u=i[1];if(t)if("object"===Object(Oe["a"])(t)){if(a=t[u],!a||"function"!==typeof a)throw"Cannot find method "+u+" on "+t;a=a.bind(t)}else{if("function"!==typeof t)throw"Invalid listener "+t;a=t}if("string"===typeof n)o=this._parseNativeEvent(n),s._addEvent(o,u);else for(var c=0;c<n.length;c++){var l=n[c];o=this._parseNativeEvent(l),s._addEvent(o,u)}this._callbacks[s._name+":"+u]=a}},group:function(e){return this._getOrCreateGroup(e)},setEnable:function(e,t){var r,n=this._groups[e];for(var i in n&&n._setEnable(t),this._groups)n=this._groups[i],t?(r=n._mask.indexOf(e),r>=0&&(n._mask.splice(r,1),this._maskedGroups.splice(this._maskedGroups.indexOf(e),1))):(r=n._name.indexOf(e),0===r&&"."===n._name[r+e.length]&&(n._mask.push(e),this._maskedGroups.push(e)));if(!t)for(var a=0;a<this._queues.length;a++){var o=this._queues[a];if(o)for(var s=o.length-1;s>=0;s--){var u=o[s];u.type.indexOf(e)>=0&&(o.splice(s,1),u._nativeEvents.length=0)}}},setPriority:function(e,t){var r=e.split(":");if(t<0)throw"priority must be a positive number";var n,i,a,o=this._groups[r[0]];if(o&&r[1]){for(i=o._events[r[1]],a=0;a<i.length;a++)n=i[a],n._priority=t;o._priority>t&&(o._priority=t)}else for(var s in this._groups)if(o=this._groups[s],o._name.indexOf(e)>=0)for(var u in o._events)for(i=o._events[u],a=0;a<i.length;a++)n=i[a],n._priority=t},getHigherPriority:function(e){var t=Vt;for(var r in this._groups){var n=this._groups[r];n._name.indexOf(e)>=0&&n._priority<t&&(t=n._priority)}return t>0?t-1:0},getParam:function(e){return this._params[e]},setParam:function(e,t){this._params[e]=t},cleanup:function(){for(var e in this._groups){var t=this._groups[e];t._setEnable(!1)}},_parseNativeEvent:function(e){var t,r=e.split(" "),n={};for(n.name=r[0],t=1;t<r.length;t++){var i=r[t],a=!0;0===i.indexOf("!")&&(a=!1,i=i.substring(1,i.length)),Gt.indexOf(i)>=0?n[i]=a:n.action=i.toLowerCase()}if(n.action)for(t=0;t<Gt.length;t++){var o=Gt[t];0===n.action.indexOf(o)&&(n[o]=!0)}return 0===n.name.indexOf("key")&&!n.action&&r.length>1&&(n.action=r[r.length-1]),n.raw=e,n},_getOrCreateGroup:function(e){var t=this._groups[e];if(!t){t=new zt(this,e),this._groups[e]=t;for(var r=0;r<this._maskedGroups.length;r++){var n=this._maskedGroups[r];0===e.indexOf(n)&&t._mask.push(n)}}return t},update:function(){var e;for(e=0;e<this._sources.length;e++){var t=this._sources[e];t.poll&&t.poll()}for(e=0;e<this._queues.length;e++){var r=this._queues[e];if(r){for(var n=0;n<r.length;n++){var i=r[n];this._callbacks[i.type](i),i._nativeEvents.length=0}r.length=0}}},_getSource:function(e){for(var t=0;t<this._sources.length;t++){var r=this._sources[t];if(r.supportsEvent(e))return r}},_dumpInputGroups:function(e,t){for(var r in!0===e&&(t=e,e=void 0),this._groups)if(!(e&&r.indexOf(e)<0)){var n=this._groups[r],i=n._enabled&&!n._mask.length&&n._hasSources;if(!t||i){for(var a in L["a"].groupCollapsed("%c"+r+(i?" (enabled)":" (disabled)"),i?"":"color: #888888"),L["a"].log("enabled:",n._enabled),L["a"].log("masks:",n._mask),L["a"].log("input sources:",n._hasSources),L["a"].group("events"),n._events){L["a"].groupCollapsed(a);for(var o=n._events[a],s=0;s<o.length;s++){var u=o[s],c="%c"+u._parsedEvent.raw+" ("+(u._source?u._source.getName():"unknown source")+")",l=u._source?"":"color: #888888";L["a"].log(c,l)}L["a"].groupCollapsed("function"),L["a"].log(this._callbacks[n._name+":"+a]),L["a"].groupEnd(),L["a"].groupEnd()}L["a"].groupEnd(),L["a"].groupEnd()}}},_dumpEventSequence:function(e,t){var r,n=[];for(var i in!0===e&&(t=e,e=void 0),this._groups){var a=this._groups[i];if(r=a._enabled&&!a._mask.length&&a._hasSources,!t||r)for(var o in a._events){var s=a._events[o],u=n[s[0]._priority];u||(u=[],n[s[0]._priority]=u);for(var c=0;c<s.length;c++){var l=s[c];(!e||e&&l._parsedEvent.raw.indexOf(e)>=0)&&u.push({name:l.type,group:a._name,on:l._parsedEvent.raw,enabled:a._enabled&&!a._mask.length&&!!l._source,source:l._source?"("+l._source.getName()+")":"(unknown source)"})}}}for(var h=0;h<n.length;h++){var d=n[h];if(d){var f;L["a"].group("priority "+h);for(var _=0;_<d.length;_++){var p=d[_];if(0!==_&&f!==p.name&&L["a"].groupEnd(),f!==p.name){var g=this._groups[p.group];r=g._enabled&&!g._mask.length&&g._hasSources,L["a"].groupCollapsed("%c"+p.name,r?"":"color:#888888")}f=p.name,L["a"].groupCollapsed("%c"+p.on+" "+p.source,p.enabled?"":"color:#888888"),L["a"].log(this._callbacks[p.name]),L["a"].groupEnd()}L["a"].groupEnd(),L["a"].groupEnd()}}}};var Ht=jt,Wt=function(e){this._target=e,this._supportedEvents=[]};Wt.prototype={supportsEvent:function(e){for(var t=0;t<this._supportedEvents.length;t++){var r=this._supportedEvents[t];if(0===e.indexOf(r))return!0}return!1},setInputManager:function(e){this._inputManager=e}};var Xt=Wt,qt=120,Yt=0===navigator.platform.indexOf("Mac")?-1:-3,Kt=function(e,t){Xt.call(this,e),this._defaultRatio=F["e"].fromValues(1,1),this._supportedEvents=["click","contextmenu","dblclick","mousedown","mouseenter","mouseleave","mousemove","mouseover","mouseout","mouseup"],t&&!1===t.scrollwheel||this._supportedEvents.push("wheel")};j["a"].createPrototypeObject(Kt,j["a"].objectInherit(Xt.prototype,{getName:function(){return"Mouse"},setEnable:function(e,t,r){r?this._target.addEventListener(e,t):this._target.removeEventListener(e,t)},populateEvent:function(e,t){t.canvasX=void 0===e.offsetX?e.layerX:e.offsetX,t.canvasY=void 0===e.offsetY?e.layerY:e.offsetY;var r=this._inputManager.getParam("pixelRatio");r||(r=this._defaultRatio),t.glX=t.canvasX*r[0],t.glY=(this._target.clientHeight-t.canvasY)*r[1],t.clientX=e.clientX,t.clientY=e.clientY,t.screenX=e.screenX,t.screenX=e.screenX,t.pageX=e.pageX,t.pageY=e.pageY,t.ctrlKey=e.ctrlKey,t.shiftKey=e.shiftKey,t.altKey=e.altKey,t.metaKey=e.metaKey,t.button=e.button,t.buttons=e.buttons,"wheel"===e.type&&(void 0!==e.wheelDelta?t.deltaY=e.wheelDelta/qt:1===e.deltaMode?t.deltaY=e.deltaY/Yt:t.deltaY=e.deltaY/(10*Yt),t.deltaMode=e.deltaMode,t.deltaX=e.deltaX,t.deltaZ=e.deltaZ)},isEventRegistered:function(e,t){return e.preventDefault(),(!t.action||e.button===parseInt(t.action))&&((void 0===t.ctrl||e.ctrlKey===t.ctrl)&&((void 0===t.shift||e.shiftKey===t.shift)&&((void 0===t.alt||e.altKey===t.alt)&&(void 0===t.meta||e.metaKey===t.meta))))}}),"osgViewer","InputSourceMouse");var Jt=Kt,Zt=(n("38cf"),function(e){Xt.call(this,e),this._supportedEvents=["keydown","keyup","keypress"]});j["a"].createPrototypeObject(Zt,j["a"].objectInherit(Xt.prototype,{getName:function(){return"Keyboard"},setEnable:function(e,t,r){r?this._target.addEventListener(e,t):this._target.removeEventListener(e,t)},populateEvent:function(e,t){t.key=e.key,t.keyCode=e.keyCode,t.code=e.code,t.location=e.location,t.repeat=e.repeat,t.ctrlKey=e.ctrlKey,t.shiftKey=e.shiftKey,t.altKey=e.altKey,t.metaKey=e.metaKey},isEventRegistered:function(e,t){return!t.action||(!e.key||e.key.toLowerCase()===t.action||e.code.toLowerCase()===t.action)&&((void 0===t.ctrl||e.ctrlKey===t.ctrl)&&((void 0===t.shift||e.shiftKey===t.shift)&&((void 0===t.alt||e.altKey===t.alt)&&(void 0===t.meta||e.metaKey===t.meta))))}}),"osgViewer","InputSourceKeyboard");var Qt=Zt,$t=function(e,t){Xt.call(this),this._supportedEvents=["vrdisplayposechanged","vrdisplayconnected","vrdisplaynotfound","vrdisplaydisconnected"],this._callbacks={},this._events={};for(var r=0;r<this._supportedEvents.length;r++){var n=this._supportedEvents[r],i=new Event(n);this._events[n]=i}this._nbCallbacks=0,this._pollInterval=t&&void 0!==t.pollInterval?t.pollInterval:3e3};j["a"].createPrototypeObject($t,j["a"].objectInherit(Xt.prototype,{getName:function(){return"WebVR"},setEnable:function(e,t,r){var n=this._callbacks[e];n||(n=[],this._callbacks[e]=n);var i=n.indexOf(t);r?i<0&&(n.push(t),this._nbCallbacks++,this._schedulePolling()):i>=0&&(n.splice(i,1),this._nbCallbacks--,this._nbCallbacks||this._cancelPolling())},populateEvent:function(e,t){e.vrDisplay?t.vrDisplay=e.vrDisplay:(t.pose=e.pose,t.sitToStandMatrix=e.sitToStandMatrix,t.worldFactor=this._inputManager.getParam("worldFactor"),t.worldFactor||(t.worldFactor=1))},_schedulePolling:function(){this._pollInterval>0&&void 0===this._pollingTimeout&&(this._pollingTimeout=setInterval(this.pollHeadset.bind(this),this._pollInterval))},_cancelPolling:function(){void 0!==this._pollingTimeout&&clearInterval(this._pollingTimeout)},pollHeadset:function(){if(!navigator.getVRDisplays)return this._hmd=void 0,this._frameData=void 0,void this.triggerNotFoundEvent();var e=this;navigator.getVRDisplays().then(function(t){if(0!==t.length){if(e._hmd!==t[0]){L["a"].log("Found a VR display");var r=e._events["vrdisplaydisconnected"];r.vrDisplay=e._hmd,this._dispatchEvent(r,e._callbacks["vrdisplaydisconnected"]),r=e._events["vrdisplayconnected"],r.vrDisplay=t[0],this._dispatchEvent(r,e._callbacks["vrdisplayconnected"]),e._hmd=t[0],e._frameData=new window.VRFrameData}}else this.triggerNotFoundEvent()}.bind(this)).catch((function(e){this._hmd=void 0,this._frameData=void 0,this.triggerNotFoundEvent(),L["a"].warn(e.message)}))},triggerNotFoundEvent:function(){if(!(this._pollInterval>0)){var e=this._events["vrdisplaynotfound"];this._dispatchEvent(e,this._callbacks["vrdisplaynotfound"])}},setPollInterval:function(e){this._pollInterval=e},_dispatchEvent:function(e,t){if(t)for(var r=0;r<t.length;r++){var n=t[r];n(e)}},poll:function(){if(this._hmd){var e=this._callbacks["vrdisplayposechanged"];if(e&&e.length){this._hmd.getFrameData(this._frameData);var t=this._frameData.pose;if(t){var r=this._hmd.stageParameters&&this._hmd.stageParameters.sittingToStandingTransform,n=this._events["vrdisplayposechanged"];n.pose=t,n.sitToStandMatrix=r,this._dispatchEvent(n,e)}}}}}),"osgViewer","InputSourceWebVR");var er=$t,tr=function(){Xt.call(this),this._target=window,this._supportedEvents=["buttondown","buttonup","buttonvalue","axis","gamepadconnected","gamepaddisconnected"],this._callbacks={},this._nbCallbacks=0,this._gamePadState=[],this._valueThreshold=.05,window.addEventListener("gamepadconnected",function(e){this._newGamePad(e.gamepad),this._onConnectionStateChange(e,"gamepadconnected")}.bind(this)),window.addEventListener("gamepaddisconnected",function(e){this._previousState[e.gamepad.index]=void 0,this._onConnectionStateChange(e,"gamepaddisconnected")}.bind(this))};j["a"].createPrototypeObject(tr,j["a"].objectInherit(Xt.prototype,{getName:function(){return"GamePad"},setEnable:function(e,t,r){var n=this._callbacks[e];n||(n=[],this._callbacks[e]=n);var i=n.indexOf(t);r?i<0&&(n.push(t),this._nbCallbacks++):i>=0&&(n.splice(i,1),this._nbCallbacks--)},_onConnectionStateChange:function(e,t){var r=this._callbacks[t];r&&r(e)},_newGamePad:function(e){var t,r={buttons:[]};for(r._buttonEvents=[],r._axisEvents=[],t=0;t<e.buttons.length;t++)r._buttonEvents[t]={buttondown:this._initEvent("buttondown",t,e.index,"button"),buttonup:this._initEvent("buttonup",t,e.index,"button"),buttonvalue:this._initEvent("buttonvalue",t,e.index,"button")};for(t=0;t<e.axes.length;t++)r._axisEvents[t]={axis:this._initEvent("axis",t,e.index,"axis")};this._gamePadState[e.index]=r},setValueThreshold:function(e){this._valueThreshold=e},_initEvent:function(e,t,r,n){var i=new Event(e);return i[n]=t,i.gamepadIndex=r,i},populateEvent:function(e,t){t.gamepadIndex=e.gamepadIndex,void 0!==e.button&&(t.button=e.button,t.value=e.value),void 0!==e.axis&&(t.axis=e.axis,t.value=e.value)},isEventRegistered:function(e,t){if(!t.action)return!0;var r=parseInt(t.action);return(void 0===e.button||e.button===r)&&(void 0===e.axis||e.axis===r)},_fireCallbacks:function(e,t){for(var r=0;r<e.length;r++)e[r](t)},poll:function(){if(this._nbCallbacks){var e=navigator.getGamepads();if(e)for(var t=0;t<e.length;t++){var r=e[t];if(r){var n=this._gamePadState[t];if(n){var i=this._callbacks["buttondown"],a=this._callbacks["buttonup"],o=this._callbacks["buttonvalue"];if(i||a||o)for(var s=0;s<r.buttons.length;s++){var u=r.buttons[s],c=n._buttonEvents[s].buttondown;c.value=u.value;var l=n._buttonEvents[s].buttonup;if(l.value=u.value,u.pressed&&!n.buttons[s]&&(i&&i.length&&this._fireCallbacks(i,c),n.buttons[s]=u.pressed),!u.pressed&&n.buttons[s]&&(a&&a.length&&this._fireCallbacks(a,l),n.buttons[s]=!1),u.pressed&&o&&o.length){var h=n._buttonEvents[s].buttonvalue;h.value=u.value,Math.abs(u.value)>=this._valueThreshold&&this._fireCallbacks(o,h)}}var d=this._callbacks["axis"];if(d)for(s=0;s<r.axes.length;s++){var f=r.axes[s],_=n._axisEvents[s].axis;_.value=f,Math.abs(f)>=this._valueThreshold&&this._fireCallbacks(d,_)}}}}}}}),"osgViewer","InputSourceGamePad");var rr=tr,nr=function(){Xt.call(this),this._target=window,this._callbacks=[],this._nbCallbacks=0,this._event=new Event("deviceorientation"),this._supportedEvents=["deviceorientation","orientationchange"],this._update=this.onDeviceOrientation.bind(this)};j["a"].createPrototypeObject(nr,j["a"].objectInherit(Xt.prototype,{getName:function(){return"DeviceOrientation"},setEnable:function(e,t,r){if("orientationchange"!==e){var n=this._callbacks,i=n.indexOf(t);r?i<0&&(n.push(t),this._nbCallbacks++):i>=0&&(n.splice(i,1),this._nbCallbacks--),1===this._nbCallbacks&&window.addEventListener(e,this._update),0===this._nbCallbacks&&window.removeEventListener(e,this._update)}else r?this._target.addEventListener(e,t):this._target.removeEventListener(e,t)},onDeviceOrientation:function(e){this.populateEvent(e,this._event)},populateEvent:function(e,t){t.absolute=e.absolute,t.alpha=e.alpha,t.beta=e.beta,t.gamma=e.gamma,t.screenOrientation=window.orientation},isEventRegistered:function(e){if("deviceorientation"===e.type){if(null===e.alpha||void 0===e.alpha)return!1}else if(null===window.orientation||void 0===window.orientation)return!1;return!0},poll:function(){if(this._nbCallbacks)for(var e=0;e<this._callbacks.length;e++)this._callbacks[e](this._event)}}),"osgViewer","InputSourceDeviceOrientation");var ir=nr,ar=n("c8b5"),or=n.n(ar),sr=function(e){Xt.call(this,e),this._defaultRatio=F["e"].fromValues(1,1),this._hammerEvents=["pan","pinch","press","rotate","swipe","doubletap","doubletap2fingers","singletap"],this._supportedEvents=["touchstart","touchend","touchcancel","touchmove"],this._hammer=new or.a.Manager(e),this._hammer.add(new or.a.Pan),this._hammer.add(new or.a.Pinch),this._hammer.get("pan").set({threshold:0,pointers:0});var t=this._hammer.get("pinch");t.set({threshold:.1,enable:!1}),t.recognizeWith(this._hammer.get("pan")),this._hammer.add(new or.a.Tap({event:"doubletap",pointers:1,taps:2,time:250,interval:450,threshold:5,posThreshold:50})),this._hammer.add(new or.a.Tap({event:"doubletap2fingers",pointers:2,taps:2,time:250,interval:450,threshold:5,posThreshold:50})),this._hammer.add(new or.a.Tap({event:"singletap",pointers:1,taps:1,time:250,interval:450,threshold:5,posThreshold:20}))};j["a"].createPrototypeObject(sr,j["a"].objectInherit(Xt.prototype,{getName:function(){return"TouchScreen"},setEnable:function(e,t,r){this._isNativeEvent(e)?r?this._target.addEventListener(e,t):this._target.removeEventListener(e,t):(e.indexOf("pinch")>=0&&r&&this._hammer.get("pinch").set({enable:!0}),r?this._hammer.on(e,t):this._hammer.off(e,t))},populateEvent:function(e,t){if(this._isNativeEvent(e.type)){t.canvasX=t.canvasY=0;for(var r=e.touches.length?e.touches:e.changedTouches,n=r.length,i=0;i<n;++i)t.canvasX+=r[i].clientX/n,t.canvasY+=r[i].clientY/n;t.ctrlKey=e.ctrlKey,t.shiftKey=e.shiftKey,t.altKey=e.altKey,t.metaKey=e.metaKey,t.pointers=e.touches}else t.canvasX=e.center.x,t.canvasY=e.center.y,t.scale=e.scale,t.rotation=e.rotation,t.deltaX=e.deltaX,t.deltaY=e.deltaY,t.deltaTime=e.deltaTime,t.direction=e.direction,t.offsetDirection=e.offsetDirection,t.pointers=e.pointers,t.velocity=e.velocity;var a=this._target.getBoundingClientRect();t.canvasX+=-a.left,t.canvasY+=-a.top;var o=this._inputManager.getParam("pixelRatio");o||(o=this._defaultRatio),t.glX=t.canvasX*o[0],t.glY=(this._target.clientHeight-t.canvasY)*o[1]},_isNativeEvent:function(e){return this._supportedEvents.indexOf(e)>=0},isEventRegistered:function(e,t){if(e.preventDefault(),e.pointerType&&"touch"!==e.pointerType)return!1;if(!t.action)return!0;if(isNaN(t.action))throw"touch action should be a number representing the number of touches";var r=e.pointers;r||(r=e.touches);var n=parseInt(t.action);if("touchend"===e.type||"touchcancel"===e.type){if(r.length>=n)return!1}else if(r.length!==n)return!1;return!0},supportsEvent:function(e){var t=Xt.prototype.supportsEvent.call(this,e);if(t)return t;for(var r=0;r<this._hammerEvents.length;r++){var n=this._hammerEvents[r];if(0===e.indexOf(n))return!0}return!1},getHammer:function(){return this._hammer}}),"osgViewer","InputSourceTouchScreen");var ur=sr,cr=n("c77d"),lr=n("4066"),hr=n("cb5a"),dr=function(e,t,r){D["default"].call(this),this._startTick=V["a"].instance().tick(),this._stats=void 0,this._done=!1,this._canvas=e;var n=this.initOptions(t),i=this.initWebGLContext(e,n,r);if(!i)throw"No WebGL implementation found";this._updateVisitor=new z["a"],this.setUpView(i.canvas,n),this.initInputManager(n,e),this.initStats(n,e),this._hmd=null,this._requestAnimationFrame=window.requestAnimationFrame.bind(window),this._options=n,this._contextLost=!1,this._forceRestoreContext=!0,this.renderBinded=this.render.bind(this)};j["a"].createPrototypeObject(dr,j["a"].objectInherit(D["default"].prototype,{initInputManager:function(e,t){var r=new Ht;this._inputManager=r,this._initInputSource(Jt,"Mouse",t,e),this._initInputSource(Qt,"Keyboard",document,e),window,this._initInputSource(ur,"TouchScreen",t,e),this._initInputSource(er,"WebVR",void 0,e),this._initInputSource(ir,"DeviceOrientation",void 0,e),navigator.getGamepads&&this._initInputSource(rr,"GamePad",void 0,e),r.addMappings({"viewer.internals:hmdConnect":"vrdisplayconnected"},function(e){this.setVRDisplay(e.vrDisplay)}.bind(this)),r.setParam("pixelRatio",[this._devicePixelRatio,this._devicePixelRatio])},_initInputSource:function(e,t,r,n){var i=n.InputSources?n.InputSources[t]:void 0;if(i){if(!1!==i.enable){var a=i.sourceElement||r;this._inputManager.registerInputSource(new e(a,i))}}else this._inputManager.registerInputSource(new e(r))},getInputManager:function(){return this._inputManager},initOptions:function(e){var t=new k["a"];return e&&t.extend(e),t.extendWithOptionsURL(),!0===t.getBoolean("traceLogCall")&&(L["a"].traceLogCall=!0),!0===t.getBoolean("enableFrustumCulling")&&this.getCamera().getRenderer().getCullVisitor().setEnableFrustumCulling(!0),t},initWebGLContext:function(e,t,r){t.get("SimulateWebGLLostContext")&&(e=Pe.makeLostContextSimulatingCanvas(e),e.loseContextInNCalls(t.get("SimulateWebGLLostContext")),this._canvas=e);var n=Ne["a"].setupWebGL(e,t,r);return e.addEventListener("webglcontextlost",function(e){this.contextLost(),!1!==this._forceRestoreContext&&e.preventDefault()}.bind(this),!1),e.addEventListener("webglcontextrestored",function(){this.contextRestored()}.bind(this),!1),(L["a"].reportWebGLError||t.get("reportWebGLError"))&&(n=Pe.makeDebugContext(n)),this.initWebGLCaps(n),this.setGraphicContext(n),n},setContextLostCallback:function(e){this._contextLostCallback=e,this._contextLost&&(this._forceRestoreContext=e())},setContextRestoreCallback:function(e){this._contextRestoreCallback=e},contextLost:function(){L["a"].log("webgl context lost"),this._contextLostCallback&&(this._forceRestoreContext=this._contextLostCallback()),this._contextLost=!0,window.cancelAnimationFrame(this._requestID)},contextRestored:function(){!1!==this._forceRestoreContext?(this.restoreContext(),L["a"].log("webgl context restored")):L["a"].log("webgl context restore not supported - please reload the page - ")},restoreContext:function(){var e=this.getGraphicContext();Y["a"].onLostContext(e),K["a"].onLostContext(e),X["a"].onLostContext(e),q["a"].onLostContext(e),W["a"].onLostContext(e),J["default"].getTextureManager(e).onLostContext(e),H["a"].onLostContext(e),this.getCamera().getRenderer().getState().resetCaches(),this.initWebGLCaps(e,!0),this.setGraphicContext(e),G["a"].instance(this.getGraphicContext(),!0),this._stats&&this._stats.reset(),this._contextLost=!1,this._requestRedraw=!0,this._contextRestoreCallback&&this._contextRestoreCallback(e),this._runImplementation()},init:function(){},getUpdateVisitor:function(){return this._updateVisitor},getState:function(){return this.getCamera().getRenderer().getState()},initStats:function(e){var t=G["a"].instance(this.getGraphicContext());e.getBoolean("stats")?(this._stats=new lt(this,e),this._stats.addConfig(_t),this._stats.addConfig(It),this._stats.addConfig(Ut),this.getCamera().addChild(this._stats.getNode()),t.setCallback(this.callbackTimerGPU.bind(this))):t.disable()},callbackTimerGPU:function(e,t){this._stats&&this._stats.getCounter(t).set(e/1e6)},getViewerStats:function(){return this._stats},renderingTraversal:function(){if(this.getState()._frameStamp=this._frameStamp,this.getScene().getSceneData()&&this.getScene().getSceneData().getBound(),this.getCamera()){var e=this._stats,t=G["a"].instance(this.getGraphicContext()),r=this.getCamera().getRenderer();if(e&&e.getCounter("cull").start(),r.cull(),e&&e.getCounter("cull").end(),t.pollQueries(),t.start("glframe"),e&&e.getCounter("render").start(),r.draw(),e&&e.getCounter("render").end(),t.end("glframe"),e){var n=r.getCullVisitor();e.getCounter("cullcamera").set(n._numCamera),e.getCounter("cullmatrixtransform").set(n._numMatrixTransform),e.getCounter("cullprojection").set(n._numProjection),e.getCounter("cullnode").set(n._numNode),e.getCounter("culllightsource").set(n._numLightSource),e.getCounter("cullgeometry").set(n._numGeometry),e.getCounter("pushstateset").set(r.getState()._numPushStateSet),e.getCounter("applyStateSet").set(r.getState()._numApply)}}},updateTraversal:function(){var e=this._stats;e&&e.getCounter("update").start(),this._updateVisitor.resetStats(),this.getScene().updateSceneGraph(this._updateVisitor),e&&e.getCounter("updatecallback").set(this._updateVisitor._numUpdateCallback),this.getDatabasePager().releaseGLExpiredSubgraphs(.005),this.flushDeletedGLObjects(.005),e&&e.getCounter("update").end()},advance:function(e){var t=e;void 0===t&&(t=Number.MAX_VALUE);var r=this._frameStamp,n=r.getFrameNumber();r.setFrameNumber(n+1);var i=V["a"].instance().deltaS(this._startTick,V["a"].instance().tick());r.setReferenceTime(i);var a=r.getSimulationTime();r.setSimulationTime(t===Number.MAX_VALUE?i:t),r.setDeltaTime(r.getSimulationTime()-a)},beginFrame:function(){var e=this._stats;e&&(e.getCounter("frame").start(),e.getCounter("raf").tick(),e.getCounter("fps").frame())},endFrame:function(){var e=this.getFrameStamp().getFrameNumber();this._stats&&(J["default"].getTextureManager(this.getGraphicContext()).updateStats(e,this._stats),this._stats.getCounter("stats").start(),this._stats.update(),this._stats.getCounter("stats").end(),this._stats.getCounter("frame").end())},checkNeedToDoFrame:function(){return this._requestContinousUpdate||this._requestRedraw},frame:function(){if(!this._contextLost){this.beginFrame(),this.advance();var e=this.updateViewport();this._inputManager.update(),this._updateVisitor.setFrameStamp(this.getFrameStamp()),this.getManipulator()&&(this.getManipulator().update(this._updateVisitor),F["c"].copy(this.getCamera().getViewMatrix(),this.getManipulator().getInverseMatrix())),(this.checkNeedToDoFrame()||e)&&(this._requestRedraw=!1,this.updateTraversal(),this.renderingTraversal()),this.endFrame(),this._hmd&&this._hmd.isPresenting&&this._hmd.submitFrame()}},setDone:function(e){this._done=e},done:function(){return this._done},render:function(){this.done()||(this._requestID=this._requestAnimationFrame(this.renderBinded,this._canvas),this.frame())},_runImplementation:function(){this.render()},run:function(){this._runImplementation()},setVRDisplay:function(e){this._hmd=e},getVRDisplay:function(){return this._hmd},setPresentVR:function(e){if(!this._hmd)return L["a"].warn("no hmd device provided to the viewer!"),U.a.reject();if(!this._hmd.capabilities.canPresent)return U.a.reject();if(e){this._requestAnimationFrame=this._hmd.requestAnimationFrame.bind(this._hmd);var t=[{source:this.getGraphicContext().canvas}];return this._hmd.requestPresent(t)}return this._requestAnimationFrame=window.requestAnimationFrame.bind(window),this._hmd.exitPresent()},setupManipulator:function(e){void 0===e&&(e=new we({inputManager:this._inputManager})),void 0!==e.setNode?e.setNode(this.getSceneData()):e.view=this,e.setCamera(this.getCamera()),this.setManipulator(e)},updateViewport:function(){var e=this.getGraphicContext(),t=e.canvas,r=this.computeCanvasSize(t);if(!r)return!1;var n=this.getCamera(),i=n.getViewport(),a=i.width(),o=i.height(),s=t.width/a,u=t.height/o,c=s/u;return i.setViewport(Math.round(i.x()*s),Math.round(i.y()*u),Math.round(i.width()*s),Math.round(i.height()*u)),1!==c&&F["c"].mul(n.getProjectionMatrix(),n.getProjectionMatrix(),F["c"].fromScaling(F["c"].create(),[1/c,1,1])),!0},setManipulator:function(e){this.setEnableManipulator(!1),e.getCamera()||e.setCamera(this.getCamera()),e.setEnable(!0),D["default"].prototype.setManipulator.call(this,e)},setEnableManipulator:function(e){this._manipulator&&this._manipulator.setEnable(e)},dispose:function(){cr["a"].clean(),lr["a"].clean(),hr["a"].pooledStateGraph.clean()}}),"osgViewer","Viewer");var fr=dr,_r=n("b690"),pr={};pr.Renderer=I["default"],pr.View=D["default"],pr.Viewer=fr,pr.Scene=_r["a"],pr.InputGroups=ne;var gr=pr,mr=gr.InputGroups;mr.GLOBAL_ACTIONS=mr.SCENE+".globalactions",mr.GLOBAL_FOCUS="focuscanvas",mr.SCENE_VIEWERAPI=mr.SCENE+".viewerapi",mr.SCENE_VIEWERAPI_1_4=mr.SCENE+".viewerapi_1_4",mr.FOCUS_INSPECTOR="focus.inspector",mr.SCENE_INSPECTOR=mr.SCENE+".inspector",mr.UI_INSPECTOR=mr.UI+".inspector",mr.SCENE_INSPECTOR_ZOOM=mr.SCENE_INSPECTOR+".zoom",mr.UI_INSPECTOR_ZOOM=mr.UI_INSPECTOR+".zoom",mr.ENVIRONMENT=mr.SCENE+".environment",mr.DEBUG="debug",mr.DEBUG_TRIPICK="debug.tripick",mr.DEBUG_GEOMPICK="debug.geompick",mr.AUTOSPIN=mr.SCENE+".autospin",mr.HOTSPOT=mr.SCENE+".hotspot",mr.HOTSPOT_VIEWER=mr.HOTSPOT+".viewer",mr.HOTSPOT_EDITOR=mr.HOTSPOT+".editor",mr.CAMERA=mr.SCENE+".camera",mr.CAMERA_GIZMO=mr.CAMERA+".gizmo",mr.SOUND=mr.SCENE+".sound",mr.SOUND_GIZMO=mr.SOUND+".gizmo",mr.WEBVR=mr.SCENE+".webvr",mr.WEBVREDITOR=mr.SCENE+"webvreditor",mr.WEBVR_NAVIGATION=mr.WEBVR+".navigation",mr.WEBVR_DISPLAY=mr.WEBVR+".display",mr.AR="ar",mr.AR_DEBUG=mr.AR+".debug",mr.STICKER="sticker";var vr=function(){function e(){Object(v["a"])(this,e),this._manager=null}return Object(S["a"])(e,[{key:"init",value:function(e){this._manager=e}},{key:"initGlobalClickEvents",value:function(e,t){var r=0,n=0,i=0;this._manager.group(mr.GLOBAL_ACTIONS).addMappings({onDoubleClick:["doubletap","doubletap2fingers","dblclick"],onSingleClick:"singletap"},e),this._manager.group(mr.GLOBAL_ACTIONS).addMappings({preventclick:"mousedown"},(function(e){i=0,r=e.clientX,n=e.clientY})),this._manager.group(mr.GLOBAL_ACTIONS).addMappings({preventmousemove:"mousemove"},(function(e){i=Math.max(i,Math.abs(r-e.clientX)+Math.abs(n-e.clientY))})),this._manager.group(mr.GLOBAL_ACTIONS).addMappings({fallbacksingleclick:"mouseup"},(function(t){i<2&&e.onSingleClick(t)})),this._manager.group("focuscanvas").addMappings({focus:"mousedown"},(function(){t.focus({preventScroll:!0})})),this._manager.setPriority("focuscanvas",0)}},{key:"initEnvironment",value:function(e){this._manager.group(mr.ENVIRONMENT).addMappings({startRotate:["mousedown alt","touchstart 3"],endRotate:["mouseup","mouseout","touchend","touchcancel"]},e),this._manager.setPriority(mr.ENVIRONMENT,this._manager.getHigherPriority(mr.MANIPULATORS))}},{key:"initSticker",value:function(e){var t=0,r=0,n=0;this._manager.group(mr.STICKER).addMappings({mousedown:"mousedown",mousemove:"mousemove",mouseup:["mouseup","mouseout"],doubleclick:["dblclick","doubletap"],singleclick:["singletap"]},e),this._manager.group(mr.STICKER).addMappings({onPreventMouseMove:"mousemove"},(function(e){var i=Math.abs(t-e.clientX)+Math.abs(r-e.clientY);n=Math.max(n,i)})),this._manager.group(mr.STICKER).addMappings({onFallbackSingleClick:"mouseup"},(function(t){n<2&&e.singleclick(t)})),this._manager.group(mr.STICKER).addMappings({onPreventClick:"mousedown"},(function(e){n=0,t=e.clientX,r=e.clientY})),this._manager.setPriority(mr.STICKER,this._manager.getHigherPriority(mr.STICKER))}},{key:"initHotspot",value:function(e){}},{key:"initCamera",value:function(e){this._manager.group(mr.CAMERA_GIZMO).addMappings({motion:"mousemove",startDrag:"mousedown",endDrag:["mouseleave","mouseup"]},e),this._manager.setPriority(mr.CAMERA_GIZMO,this._manager.getHigherPriority(mr.MANIPULATORS))}}]),e}(),br={OPAQUE:0,OPAQUE_NO_EARLYZ:1,BACKGROUND:1,REFRACTION:2,TRANSPARENT_CUSTOM_EARLYZ:8,TRANSPARENT_NO_EARLYZ_PRE:9,TRANSPARENT:10,TRANSPARENT_NO_EARLYZ_POST:11,EXTRA:19,EDITOR_GIZMO:20,HOTSPOT:20,GRID:21,TOOLTIP:21,VR_MENU:21,WIREFRAME:22,VR_CURSOR:22,OUTLINE:23,DEBUG:24,DEBUG_2:25},Sr={DEPTH_LESS_WRITE:new w["default"].Depth(w["default"].Depth.LESS,0,1,!0),DEPTH_LESS_NO_WRITE:new w["default"].Depth(w["default"].Depth.LESS,0,1,!1),DEPTH_DISABLE:new w["default"].Depth(w["default"].Depth.DISABLE,0,1,!0),DEPTH_ALWAYS:new w["default"].Depth(w["default"].Depth.ALWAYS,0,1,!0),DEPTH_NEVER:new w["default"].Depth(w["default"].Depth.NEVER,0,1,!1),DEPTH_LEQUAL_BACKGROUND_NO_WRITE:new w["default"].Depth(w["default"].Depth.LEQUAL,1,1,!1),DEPTH_LEQUAL_WRITE:new w["default"].Depth(w["default"].Depth.LEQUAL,0,1,!0),DEPTH_LEQUAL_NO_WRITE:new w["default"].Depth(w["default"].Depth.LEQUAL,0,1,!1),DEPTH_EQUAL_NO_WRITE:new w["default"].Depth(w["default"].Depth.EQUAL,0,1,!1),COLOR_MASK_NONE:new w["default"].ColorMask(!1,!1,!1,!1),COLOR_MASK_ALPHA:new w["default"].ColorMask(!1,!1,!1,!0),COLOR_MASK_RGBA:new w["default"].ColorMask(!0,!0,!0,!0),BLEND_DISABLE:new w["default"].BlendFunc,BLEND_SUBSTRACTIVE:new w["default"].BlendFunc(w["default"].BlendFunc.ONE,w["default"].BlendFunc.ONE_MINUS_SRC_ALPHA),BLEND_ADDITIVE:new w["default"].BlendFunc(w["default"].BlendFunc.ONE,w["default"].BlendFunc.ONE),CULL_BACK:new w["default"].CullFace(w["default"].CullFace.BACK),CULL_FRONT:new w["default"].CullFace(w["default"].CullFace.FRONT),CULL_DISABLE:new w["default"].CullFace(w["default"].CullFace.DISABLE)},xr={PICK_GEOMETRY_FIXED:1,PICK_GEOMETRY_ANIMATED:2,PICK_GEOMETRY_RIG_BOX:4,PICK_GIZMO_LIGHT:8,SHADOW_CAST:16,SHADOW_BOUNDS:32};xr.PICK_GEOMETRY_SLOW=xr.PICK_GEOMETRY_FIXED|xr.PICK_GEOMETRY_ANIMATED,xr.PICK_GEOMETRY_FAST=xr.PICK_GEOMETRY_FIXED|xr.PICK_GEOMETRY_RIG_BOX,xr.PICK_GEOMETRY=xr.PICK_GEOMETRY_FIXED|xr.PICK_GEOMETRY_ANIMATED|xr.PICK_GEOMETRY_RIG_BOX,xr.PICK=xr.PICK_GEOMETRY|xr.PICK_GIZMO_LIGHT,xr.SHADOW=xr.SHADOW_BOUNDS|xr.SHADOW_CAST,xr.PICK_GEOMETRY_SHADOW=xr.PICK_GEOMETRY|xr.SHADOW,xr.NO_SHADOW=~xr.SHADOW,xr.NO_PICK=~xr.PICK,xr.NO_PICK_NO_SHADOW_CAST=~(xr.PICK|xr.SHADOW_CAST),xr.NO_PICK_NO_SHADOW_BOUNDS=~(xr.PICK|xr.SHADOW_BOUNDS),xr.NO_PICK_NO_SHADOW=~(xr.PICK|xr.SHADOW);var Tr=xr,yr=n("45eb"),Cr=n("7e84"),Ar=(n("4de4"),n("466d"),n("3714")),Er=n("2857"),Rr=n("23f5"),Mr=n("3e45"),wr=n("ede0"),Nr=n("8bd2"),Or=function(e){Ar["a"].call(this),this._functionsFile=e||"functions.glsl",this._feedbackSwapped=!1,this._syncFeedbackUniforms=!1,this._syncOnNextFrame=!1,this._lastXratio=1,this._lastYratio=1,this._xViewportRatio=1,this._yViewportRatio=1,this._xTextureRatio=1,this._yTextureRatio=1,this._finalPassUpScaleToScreen=!0,this._methodWrapUV=0,this._thresholdWrapUV=1,this._texInfos=void 0,this._screenWidth=this._screenHeight=0,this._shaderProcessor=Nr["a"],this._feedbackData={},this._cameras=[],this._stateSets=[],this._textureUniforms=[],this._programs={},this._externalTextures={},this._internalPasses=[],this._textures={},this._userTextures={},this._currentPoolIndex=0,this._texturePool={},this._firstTexture="";var t=this.getOrCreateStateSet();t.setAttributeAndModes(new ke["a"](ke["a"].DISABLE)),t.setAttributeAndModes(new Fe["a"](Fe["a"].BACK)),this.setCullCallback(this)};Or.VertexShader=["attribute vec3 Vertex;","void main(void) {"," gl_Position = vec4(Vertex * 2.0 - 1.0, 1.0);","}","","#define SHADER_NAME %name%",""].join("\n"),Or.FragmentShader=["#ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n#else\n precision mediump float;\n#endif","uniform float uRGBMRange;","vec2 gTexCoord;","%uniforms%","",'#pragma include "$FUNCTION_FILE$"',"","%header%","","%texturesColorSpace%","","%functionBodies%","","void main() {","\tgTexCoord = gl_FragCoord.xy / uTextureOutputSize.xy;","\tvec4 color = %firstFunc%(%firstArg%);","%optionalFuncs%","%colorSpaces%","\tgl_FragColor = color;","}","","#define SHADER_NAME %name%",""].join("\n"),j["a"].createPrototypeObject(Or,j["a"].objectInherit(Ar["a"].prototype,{clear:function(){for(var e in this._textures={},this._internalPasses.length=0,this._firstTexture="",this._texturePool)this._texturePool[e].usage=-1;this._feedbackData={},this._cameras.length=0,this._stateSets.length=0,this._textureUniforms.length=0,this.removeChildren()},clearShaderCache:function(){this._programs={}},getGlobalXRatio:function(){return this._xViewportRatio*this._xTextureRatio},getGlobalYRatio:function(){return this._yViewportRatio*this._yTextureRatio},setFinalPassUpScaleToScreen:function(e){this._finalPassUpScaleToScreen=e},_enforceFromInputParameter:function(e,t){var r=t.name,n=this._textures[r],i=this._textures[r+"FeedbackTexture"],a=t[e];void 0!==a&&(void 0!==n[e]&&n[e]!==a&&console.error("Mismatch on parameter "+e+" : "+r),n[e]=a,i&&(i[e]=a))},_updatePassInfoFromInputs:function(e,t,r){var n=this._textures[t],i=r.srgb;r.srgb=void 0;for(var a=0;a<e.textures.length;a++){var o=e.textures[a];this._renameTextureAlias(o,t,r.name);var s=o.name;if(!this._externalTextures[s]){this._usages[s]=(this._usages[s]||0)+1;var u=o.srgb;this._enforceFromInputParameter("filter",o),this._enforceFromInputParameter("rgbm",o),this._enforceFromInputParameter("srgb",o);var c=this._textures[s];if(!c){var l=s.substring(0,s.indexOf("FeedbackTexture"));c=this._textures[l]}void 0!==i&&void 0!==u&&i!==u&&(c.encodeSRGB=!0),this._setInferredParameter("rgbmInferred","rgbm",n,c),this._setInferredParameter("srgbInferred","srgb",n,c)}}void 0===r.srgb&&(r.srgb=void 0===n.srgb?n.srgbInferred:n.srgb)},_setInferredParameter:function(e,t,r,n){void 0===r[e]&&(r[e]=void 0===n[t]?n[e]:n[t])},_createTextureOut:function(e,t,r){var n={srgb:e.out.srgb,rgbm:e.out.rgbm,filter:e.out.filter,type:e.out.type},i=e.out.type!==J["default"].UNSIGNED_BYTE;return void 0===n.rgbm&&(r||i)&&(n.rgbm=!1),void 0===n.srgb&&(r?n.srgb=!0:(n.rgbm||i)&&(n.srgb=!1)),n},_processUserPasses:function(e){e=this._internalPasses.concat(e);for(var t=this._preprocessUserPasses(e),r=t.length,n=[],i={name:this._firstTexture,srgb:void 0},a={},o=0;o<r;o++){var s=t[o],u=o===r-1;if(u||!this._collapsePasses(s,t[o+1])){var c=s.out.name,l="%next"===c;l&&(c=s.funcs.join("_"),a[c]?c+=a[c]++:a[c]=1);var h=this._createTextureOut(s,c,u);this._textures[c]=h,this._updatePassInfoFromInputs(s,c,i),s.feedbackLoop&&(this._textures[c+"FeedbackTexture"]={srgb:h.srgb,rgbm:h.rgbm,srgbInferred:h.srgbInferred,rgbmInferred:h.rgbmInferred,filter:h.filter}),l&&(i.name=c,s.out.name=c),n.push(s)}else t.splice(o+1,1),r--,o--}return n},_hasFreeTexture:function(e,t,r){if(e===r.name&&this._texturePool[e])return e;if(!r.immuable)for(var n in this._texturePool){var i=this._texturePool[n];if(i.reusable&&(!(i.usage>0)&&i.texture.divisor===r.divisor&&i.texture.getInternalFormatType()===r.type)){if(-1===i.usage)return i.texture.getMinFilter()!==t&&(i.texture.setMinFilter(t),i.texture.setMagFilter(t)),n;if(i.texture.getMinFilter()===t)return n}}},_setOrCreateTextureKey:function(e,t,r){var n="linear"===this._textures[t].filter,i=n?J["default"].LINEAR:J["default"].NEAREST,a=this._hasFreeTexture(t,i,r);if(a)return this._texturePool[a].usage=e,void(this._textures[t].key=a);a=r.immuable?t:"key"+this._currentPoolIndex++,this._texturePool[a]={usage:e,texture:this._createTexture(t,r.divisor,r.type,i),immuable:r.immuable,reusable:r.reusable},-1===r.divisor&&(this._texturePool[a].width=r.width,this._texturePool[a].height=r.height),this._textures[t].key=a},_addStateSet:function(e,t){for(var r=0;r<e.funcs.length;r++){var n=e.funcs[r].name;this._stateSets[n]=t}},_addTextureToStateSet:function(e,t,r,n,i){t.addUniform(Er["a"].createInt1(r,e.uniformName));var a,o=e.name;if(void 0!==this._textures[o]){var s=this._textures[o].key;a=this._texturePool[s].texture}else a=this._externalTextures[o];if(this._addTextureUniforms(e.uniformName,a,t,n,i),"TexturePrevious"===e.uniformName)return r;t.setTextureAttributeAndModes(r,a)},_getUniformName:function(e){return"u"+e[0].toUpperCase()+e.slice(1)},_addTextureUniforms:function(e,t,r,n,i){var a=this._getUniformName(e),o=Er["a"].createFloat2(a+"Size"),s=Er["a"].createFloat2(a+"Ratio");r.addUniform(o),r.addUniform(s),n.push(o),n.push(s),this._textureUniforms.push({size:o,ratio:s,texture:t,isFeedback:!!i})},_checkInferredParameters:function(){for(var e in this._textures){var t=this._textures[e];void 0===t.srgb&&(t.srgb=t.srgbInferred),void 0===t.rgbm&&(t.rgbm=t.rgbmInferred)}},_buildPass:function(e,t){var r=t[e],n=r.out.name;this._setOrCreateTextureKey(this._usages[n],n,r.out);var i=r.out.name+"FeedbackTexture";if(r.feedbackLoop&&this._setOrCreateTextureKey(this._usages[i],i,r.out),r.funcs.length){var a,o=new Rr["a"];for(this._addStateSet(r,o),a=0;a<r.uniforms.length;a++)o.addUniform(r.uniforms[a]);var s=[],u=void 0;for(a=0;a<r.textures.length;a++){var c=r.textures[a],l=c.name===i;if(!l&&!this._externalTextures[c.name]){var h=this._textures[c.name].key;this._texturePool[h].usage--}var d=this._addTextureToStateSet(c,o,a,s,l);if(void 0!==d&&(u=d),void 0!==this._feedbackData[c.name]){var f={stateSet:o,textureUnit:a};this._feedbackData[c.name].nextPasses.push(f)}}var _=void 0;if(e!==t.length-1){var p=this._textures[n].key;_=this._texturePool[p].texture}this._addTextureUniforms("TextureOutput",_,o,s),o.setAttributeAndModes(this._createProgram(r,s)),r.feedbackLoop?this._feedbackData[n]=this._createFeedbackLoopCameras(n,o,_,u):this.addChild(this._createCamera(n,o,_))}else{var g=this._textures[n].key;this._userTextures[n]=this._texturePool[g].texture}},_buildGraphFromPasses:function(e){for(var t=0;t<e.length;t++)this._buildPass(t,e)},build:function(e){this._usages={};var t=this._processUserPasses(e);this._checkInferredParameters(t),this._buildGraphFromPasses(t),this.resize(this._screenWidth,this._screenHeight)},_createFeedbackLoopCameras:function(e,t,r,n){var i=this._textures[e+"FeedbackTexture"].key,a=this._texturePool[i].texture,o=new Ar["a"];o.setStateSet(t);var s=this._createFeedbackLoopCamera(e,r,a,n),u=this._createFeedbackLoopCamera(e+"FeedbackTexture",a,r,n);u.setNodeMask(0),o.addChild(s),o.addChild(u),this.addChild(o);var c={};return c.camera1=s,c.camera2=u,c.texture1=r,c.texture2=a,c.nextPasses=[],c},_createFeedbackLoopCamera:function(e,t,r,n){var i=new Rr["a"];i.setTextureAttributeAndModes(n,r);var a=this._createCamera(e,i,t);return a.setStateSet(i),a},_createCamera:function(e,t,r){var n=new Le["a"];n.setName(e),n.setStateSet(t),n.setClearMask(0),n.setReferenceFrame(wr["a"].ABSOLUTE_RF),r&&(n.setRenderOrder(Le["a"].PRE_RENDER,0),n.attachTexture(W["a"].COLOR_ATTACHMENT0,r)),n.setViewport(new Mr["a"]);var i=at["a"].createTexturedFullScreenFakeQuadGeometry(this.getInstanceID());return i.setName("composer layer"),n.addChild(i),this._cameras.push(n),n},swapFeedbackLoopTextures:function(e){for(var t in this._feedbackData){var r=this._feedbackData[t];r.camera1.setNodeMask(e?-1:0),r.camera2.setNodeMask(e?0:-1);for(var n=e?r.texture1:r.texture2,i=0;i<r.nextPasses.length;i++){var a=r.nextPasses[i];a.stateSet.setTextureAttributeAndModes(a.textureUnit,n)}}this._feedbackSwapped=!0},_createFuncFromUserData:function(e){var t="string"===typeof e?{name:e,file:e+".glsl"}:e;return t.toString=function(){return this.name},t},_createTextureInfoFromUserData:function(e){var t={name:"",uniformName:"",rgbm:void 0,srgb:void 0,filter:void 0};return"string"===typeof e?t.name=e:(t.name=e.name,e.uniformName&&(t.uniformName=e.uniformName),void 0!==e.rgbm&&(t.rgbm=e.rgbm),void 0!==e.srgb&&(t.srgb=e.srgb),void 0!==e.filter&&(t.filter=e.filter)),t},_preprocessUserPasses:function(e){for(var t=[],r=0;r<e.length;r++){var n=e[r],i={funcs:[]};if(n.func&&i.funcs.push(this._createFuncFromUserData(n.func)),i.textures=[],i.feedbackLoop=!1,void 0!==n.textures){Array.isArray(n.textures)||(n.textures=[n.textures]);for(var a=0;a<n.textures.length;a++){var o=this._createTextureInfoFromUserData(n.textures[a]);"%previous"===o.name&&(i.feedbackLoop=!0),i.textures.push(o)}}"string"===typeof n.header?i.header=[n.header]:i.header=n.header||[],void 0!==n.uniforms?Array.isArray(n.uniforms)?i.uniforms=n.uniforms:i.uniforms=[n.uniforms]:i.uniforms=[],i.out=n.out,i.out.divisor=i.out.divisor||1,i.out.type=i.out.type||J["default"].UNSIGNED_BYTE,void 0===i.out.immuable&&(i.out.immuable=!1),void 0===i.out.reusable&&(i.out.reusable=!0),(i.feedbackLoop||-1===i.out.divisor)&&(i.out.immuable=!0,i.out.reusable=!1),i.collapsible=n.collapsible||!1,t.push(i)}return t},_canBeCollapsed:function(e,t){return e.funcs.length&&t.collapsible&&"%next"===e.out.name&&e.out.divisor===t.out.divisor&&e.out.width===e.out.width&&e.out.height===e.out.height},_collapsePasses:function(e,t){return!!this._canBeCollapsed(e,t)&&(e.funcs=e.funcs.concat(t.funcs),e.header=e.header.concat(t.header),e.textures=this._mergeWithoutDuplicates(e.textures,t.textures,(function(e,t){return e.name===t.name})),e.uniforms=this._mergeWithoutDuplicates(e.uniforms,t.uniforms,(function(e,t){return e.getName()===t.getName()})),!0)},_renameTextureAlias:function(e,t,r){"%last"===e.name?(e.name=r,e.uniformName=e.uniformName||"TextureInput"):"%previous"===e.name?(e.name=t+"FeedbackTexture",e.uniformName=e.uniformName||"TexturePrevious"):e.uniformName||(e.uniformName=e.name)},_createTexture:function(e,t,r,n){var i=new J["default"];return i.setTextureSize(1,1),i.setInternalFormatType(r),i.setInternalFormat(J["default"].RGBA),i.setMinFilter(n),i.setMagFilter(n),i.divisor=t,i.setName(e),i},_computeHashFromPass:function(e){for(var t="",r=0;r<e.funcs.length;r++)t+=e.funcs[r].name+"_"+e.funcs[r].file+"_";for(e.header&&(t+=e.header.join("_")),r=0;r<e.textures.length;r++)t+=!!e.textures[r].rgbm+"_"+!!e.textures[r].srgb+"_";return t+=!!e.out.encodeSRGB+"_",t+=!!this._textures[e.out.name].rgbm+"_",t},_writeDeclarations:function(e,t,r,n){var i,a="uniform sampler2D TextureInput;\n";for(i=0;i<r.length;i++){var o=r[i].uniformName||r[i].name;a+="uniform sampler2D "+o+";\n"}for(i=0;i<t.length;i++){var s=t[i];a+="uniform "+s.getType()+" "+s.getName()+";\n"}return e=e.replace("%uniforms%",a),n&&(e=e.replace("%header%",n.join("\n"))),e},setMethodWrapUV:function(e,t){void 0!==e&&(this._methodWrapUV=e),void 0!==t&&(this._thresholdWrapUV=t),this._texInfos=void 0},_getInfos:function(){if(this._texInfos)return this._texInfos;var e="texture2D(%tex, (uv) * %ratio)",t="texture2D(%tex, (floor((uv) * %size) + 0.5) * %ratio / %size, -99999.0)",r="texture2D(%tex, (uv) * %ratio)",n=this._thresholdWrapUV.toExponential();if(1===this._methodWrapUV){var i="min(uv, 1.0 - "+n+" / %size.xy)";e=e.replace(/(uv)/g,i),t=t.replace(/(uv)/g,i),r=r.replace(/(uv)/g,i)}else if(2===this._methodWrapUV){var a="step((uv).x, 1.0 - "+n+" / %size.x) *";a+="step((uv).y, 1.0 - "+n+" / %size.y) * ",e=a+e,t=a+t,r=a+r}return this._texInfos={TEXTURE_2D:{signature:"TEXTURE_2D_%tex(uv)",body:e},TEXTURE_2D_NEAREST:{signature:"TEXTURE_2D_NEAREST_%tex(uv)",body:t},TEXTURE_2D_BIAS:{signature:"TEXTURE_2D_BIAS_%tex(uv, bias)",body:r}},this._texInfos},_extractTextures:function(e){var t=this._getInfos(),r=e.match(/TEXTURE_2D(?:_BIAS|_NEAREST)?_\w+\(/g);if(!r)return{};for(var n={},i=0;i<r.length;i++){var a=r[i].match(/((TEXTURE_2D(?:_BIAS|_NEAREST)?)_(\w+))\(/),o=t[a[2]];n[a[1]]={name:a[3],signature:o.signature,body:o.body}}return n},_writeFunctionBodies:function(e,t,r,n){for(var i=[],a="",o={},s=0;s<t.length;s++){var u=this._shaderProcessor.getShaderTextPure(t[s].file);a+=u+"\n"}var c=[this._functionsFile];a=this._shaderProcessor.processIncludes(a,c);var l=this._extractTextures(a);if(n){var h=this._getInfos().TEXTURE_2D;l.TEXTURE_2D_TextureInput={name:"TextureInput",signature:h.signature,body:h.body}}for(var d in l)if(!o[d]){o[d]=!0;for(var f=l[d],_=f.name,p=!1,g=0;g<r.length;g++){var m=r[g];if(m.uniformName===_){var v=this._textures[m.name];if(v&&v.rgbm){p=v.rgbm;break}}}var b=f.body;p&&(b="vec4(decodeRGBM("+b+", uRGBMRange), 1.0)"),b="#define "+f.signature+" ("+b+")";var S=this._getUniformName(_);b=b.replace(/%size/g,S+"Size"),b=b.replace(/%ratio/g,S+"Ratio"),b=b.replace(/%tex/g,_),i.push(b)}return e=e.replace("%texturesColorSpace%",i.join("\n")),e.replace("%functionBodies%",a.replace(/\\\n/g,""))},_writeMainFunction:function(e,t,r,n){e=e.replace("%firstFunc%",t[0].name);var i=r?"TEXTURE_2D_TextureInput(gTexCoord)":"";e=e.replace("%firstArg%",i);for(var a="",o=1;o<t.length;o++)a+="\tcolor = "+t[o].name+"(color);\n";if(e=e.replace("%optionalFuncs%",a),!0===this._textures[n].encodeSRGB){var s=this._textures[n].srgb?"linearTosRGB":"sRGBToLinear";a="\tcolor.rgb = "+s+"(color.rgb);\n"}else a="";return this._textures[n].rgbm?a+="\tcolor = encodeRGBM(color.rgb, uRGBMRange);":a+="",e.replace("%colorSpaces%",a)},_removeDuplicatedUniforms:function(e){for(var t=e.split("\n"),r={},n=t.length,i=0;i<n;i++){var a=t[i].match(/uniform(?:\s+){1,}\w+(?:\s+){1,}(\w+)/);if(null!==a){var o=a[1];void 0!==r[o]?(t.splice(i,1),n--,i--):r[o]=!0}}return t.join("\n")},_createProgram:function(e,t){var r=this._computeHashFromPass(e);if(void 0!==this._programs[r])return this._programs[r];var n=Or.FragmentShader.replace("$FUNCTION_FILE$",this._functionsFile),i=this._writeDeclarations(n,t,e.textures,e.header);i=this._writeFunctionBodies(i,e.funcs,e.textures,e.collapsible),i=this._writeMainFunction(i,e.funcs,e.collapsible,e.out.name),i=i.replace("%name%",e.out.name),i=this._removeDuplicatedUniforms(i);var a=Or.VertexShader.replace("%name%",e.out.name),o=new K["a"](new Y["a"](Y["a"].VERTEX_SHADER,a),new Y["a"](Y["a"].FRAGMENT_SHADER,i));return this._programs[r]=o,o},resize:function(e,t){for(var r in this.setScreenSize(e,t),this._texturePool){var n=this._texturePool[r].texture;void 0===this._texturePool[r].width?n.setTextureSize(this._getTextureSize(e,n.divisor),this._getTextureSize(t,n.divisor)):n.setTextureSize(this._texturePool[r].width,this._texturePool[r].height)}this.resizeRatio()},resizeRatio:function(e,t,r,n){void 0!==e&&(this._xViewportRatio=e),void 0!==t&&(this._yViewportRatio=t),void 0!==r&&(this._xTextureRatio=r),void 0!==n&&(this._yTextureRatio=n),this._resizeViewports(),this._resizeTextureUniforms()},_resizeViewports:function(){for(var e=this.getGlobalXRatio(),t=this.getGlobalYRatio(),r=this._cameras,n=0;n<r.length;++n){var i=r[n],a=i.isRenderToTextureCamera(),o=1;if(a){var s=i.getAttachments()[W["a"].COLOR_ATTACHMENT0];o=s.texture.divisor}if(n===r.length-1&&this._finalPassUpScaleToScreen&&(e=this._xViewportRatio,t=this._yViewportRatio),-1!==o){var u=this._getTextureSize(this._screenWidth,o/e),c=this._getTextureSize(this._screenHeight,o/t);i.getViewport().setViewport(0,0,u,c)}}},_resizeTextureUniforms:function(){var e=this.getGlobalXRatio(),t=this.getGlobalYRatio(),r=this._finalPassUpScaleToScreen?this._xViewportRatio:e,n=this._finalPassUpScaleToScreen?this._yViewportRatio:t;this._syncFeedbackUniforms=!0;for(var i=this._textureUniforms,a=0;a<i.length;++a){var o=i[a],s=o.size.getInternalArray(),u=o.ratio.getInternalArray();if(!o.isFeedback||!s[0]){u[0]=e,u[1]=t;var c=o.texture;c?!c.divisor||c.divisor<0?(s[0]=c.getWidth(),s[1]=c.getHeight(),u[0]=u[1]=1):(s[0]=e*c.getWidth(),s[1]=t*c.getHeight()):(s[0]=this._screenWidth*r,s[1]=this._screenHeight*n)}}},_resizeFeedbackTextureUniforms:function(){for(var e=this._lastXratio,t=this._lastYratio,r=this._textureUniforms,n=0;n<r.length;++n){var i=r[n];if(i.isFeedback){var a=i.size.getInternalArray(),o=i.ratio.getInternalArray(),s=i.texture;o[0]=e,o[1]=t,a[0]=e*s.getWidth(),a[1]=t*s.getHeight()}}},cull:function(){return this._syncOnNextFrame&&(this._resizeFeedbackTextureUniforms(),this._syncOnNextFrame=!1),this._syncFeedbackUniforms&&this._feedbackSwapped&&(this._syncFeedbackUniforms=!1,this._syncOnNextFrame=!0,this._lastXratio=this.getGlobalXRatio(),this._lastYratio=this.getGlobalYRatio()),this._feedbackSwapped=!1,!0},_mergeWithoutDuplicates:function(e,t,r){for(var n=0;n<t.length;n++){for(var i=t[n],a=!0,o=0;o<e.length;o++)if(r(e[o],i)){a=!1;break}a&&e.push(i)}return e},_getTextureSize:function(e,t){return Math.max(1,Math.round(e/t))},setScreenSize:function(e,t){this._screenWidth=e,this._screenHeight=t},setShaderProcessor:function(e){this._shaderProcessor=e},addInternalTexture:function(e){this._internalPasses.push({out:{name:e.name,divisor:e.divisor,type:e.type,filter:e.filter,srgb:e.srgb,rgbm:e.rgbm,immuable:e.immuable,reusable:e.reusable}})},addExternalTexture:function(e,t){this._externalTextures[e]=t},setInputTexture:function(e){this._firstTexture=e},getCameras:function(){return this._cameras},getStateSetPass:function(e){return this._stateSets[e]},getInternalTexture:function(e){return this._userTextures[e]}}),"osgUtil","ComposerPostProcess");var Ir,Pr,Dr,Lr=Or,Fr=function(e,t){var r,n;t?(r=t[0],n=t[1]):(r=e[14]/(e[10]-1),n=e[14]/(1+e[10]));var i=r*(e[8]-1)/e[0],a=r*(1+e[8])/e[0],o=r*(1+e[9])/e[5],s=r*(e[9]-1)/e[5],u=n*(e[8]-1)/e[0],c=n*(1+e[8])/e[0],l=n*(1+e[9])/e[5],h=n*(e[9]-1)/e[5],d=this.getAttributes().Vertex,f=d.getElements();f[0]=i,f[1]=s,f[2]=-r,f[3]=a,f[4]=s,f[5]=-r,f[6]=a,f[7]=o,f[8]=-r,f[9]=i,f[10]=o,f[11]=-r,f[12]=u,f[13]=h,f[14]=-n,f[15]=c,f[16]=h,f[17]=-n,f[18]=c,f[19]=l,f[20]=-n,f[21]=u,f[22]=l,f[23]=-n,d.dirty()},kr=function(){var e=at["a"].createBoundingBoxGeometry();return e.updateGeometry=Fr,e},Br={createDebugFrustumGeometry:kr},Ur=n("3e4d"),Vr=n("37be"),Gr=n("dfe6"),zr=n("773c"),jr=n("cfa7"),Hr=n("ceab"),Wr=n("5a16"),Xr=["#ifdef GL_ES","precision highp float;","#endif"].join("\n"),qr=function(){if(Ir)return Ir;var e="#define SHADER_NAME GizmoLine3D",t=[Xr,"attribute vec3 Vertex;","uniform mat4 uModelViewMatrix;","uniform mat4 uProjectionMatrix;",e,"","void main(void) {"," gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(Vertex, 1.0);","}"].join("\n"),r=[Xr,"uniform vec4 uColor;",e,"","void main(void) {"," gl_FragColor = uColor;","}"].join("\n");return Ir=new K["a"](new Y["a"](Y["a"].VERTEX_SHADER,t),new Y["a"](Y["a"].FRAGMENT_SHADER,r)),Ir},Yr=function(){if(Pr)return Pr;var e="#define SHADER_NAME GizmoLine2D",t=[Xr,"attribute vec2 Vertex;",e,"","void main(void) {"," gl_Position = vec4(Vertex, 0.0, 1.0);","}"].join("\n"),r=[Xr,e,"","void main(void) {"," gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);","}"].join("\n");return Pr=new K["a"](new Y["a"](Y["a"].VERTEX_SHADER,t),new Y["a"](Y["a"].FRAGMENT_SHADER,r)),Pr},Kr=function(){if(Dr)return Dr;var e="#define SHADER_NAME GizmoQuadCircle",t=[Xr,"attribute vec3 Vertex;","uniform mat4 uModelViewMatrix;","uniform mat4 uProjectionMatrix;","varying vec3 vViewVertex;",e,"","void main(void) {"," vViewVertex = Vertex;"," gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(Vertex, 1.0);","}"].join("\n"),r=[Xr,"uniform float uAngle;","uniform vec3 uBase;","varying vec3 vViewVertex;","const float PI = 3.14159265358979323846264;","const float PI2 = PI * 2.0;",e,"","void main(void) {"," if(length(vViewVertex) > 0.5)"," discard;"," vec3 vn = normalize(vViewVertex);"," float angle = atan(uBase.y * vn.x - uBase.x * vn.y, dot(uBase, vn));"," if(angle > 0.0) {"," if(uAngle >= 0.0 && angle > uAngle) discard;"," if(uAngle < -PI && angle < uAngle + PI2) discard;"," if(uAngle < 0.0 && uAngle > -PI) discard;"," }"," if(angle < 0.0) {"," if(uAngle <= 0.0 && angle < uAngle) discard;"," if(uAngle > PI && angle > uAngle - PI2) discard;"," if(uAngle > 0.0 && uAngle < PI) discard;"," }"," gl_FragColor = vec4(1.0, 1.0, 0.0, 0.5);","}"].join("\n");return Dr=new K["a"](new Y["a"](Y["a"].VERTEX_SHADER,t),new Y["a"](Y["a"].FRAGMENT_SHADER,r)),Dr},Jr=function(){Ir=void 0,Pr=void 0,Dr=void 0},Zr=function(){var e=new Ve["a"];e.getAttributes().Vertex=new X["a"](X["a"].ARRAY_BUFFER,new Float32Array(4),2);var t=new je["a"](Ge["a"].LINES,0,2);return e.getPrimitives().push(t),e.getOrCreateStateSet().setAttributeAndModes(Yr()),e},Qr=function(e,t,r,n,i){var a=void 0!==e?e:1,o=void 0!==t?t:.2,s=void 0!==r?r:6,u=void 0!==n?n:64,c=void 0!==i?i:2*Math.PI,l=(s+1)*(u+1),h=s*u*2,d=new Ve["a"],f=new Float32Array(3*l),_=new Uint16Array(3*h);c=c||2*Math.PI;var p=0,g=0,m=0,v=0;for(v=0;v<=s;++v)for(m=0;m<=u;++m){var b=m/u*c,S=v/s*Math.PI*2;g=3*p,f[g]=(a+o*Math.cos(S))*Math.cos(b),f[g+1]=(a+o*Math.cos(S))*Math.sin(b),f[g+2]=o*Math.sin(S),p++}for(p=0,v=1;v<=s;++v)for(m=1;m<=u;++m)g=6*p,_[g]=(u+1)*v+m-1,_[g+1]=_[g+3]=(u+1)*(v-1)+m-1,_[g+2]=_[g+5]=(u+1)*v+m,_[g+4]=(u+1)*(v-1)+m,p++;return d.getAttributes().Vertex=new X["a"](X["a"].ARRAY_BUFFER,f,3),d.getOrCreateStateSet().setAttributeAndModes(qr()),d.getPrimitives().push(new ze["a"](Ge["a"].TRIANGLES,new X["a"](X["a"].ELEMENT_ARRAY_BUFFER,_,1))),d},$r=function(e,t,r,n,i,a,o){var s=void 0!==e?e:1,u=void 0!==t?t:1,c=void 0!==r?r:5,l=void 0!==n?n:32,h=void 0!==i?i:1,d=void 0===a||a,f=void 0===o||o;d=d&&s>0,f=f&&u>0;var _=.5*c,p=(h+1)*(l+1),g=h*l*2;d&&(p+=1,g+=l),f&&(p+=1,g+=l);var m,v=new Ve["a"],b=new Float32Array(3*p),S=new Uint16Array(3*g),x=0,T=0,y=0,C=0;for(y=0;y<=h;y++){var A=y/h,E=A*(u-s)+s;for(C=0;C<=l;C++){var R=C/l;T=3*x,b[T]=E*Math.sin(R*Math.PI*2),b[T+1]=E*Math.cos(R*Math.PI*2),b[T+2]=-A*c+_,x++}}for(x=0,C=0;C<l;C++)for(y=0;y<h;y++)T=6*x,S[T]=(l+1)*y+C,S[T+1]=S[T+3]=(l+1)*(y+1)+C,S[T+2]=S[T+5]=(l+1)*y+C+1,S[T+4]=(l+1)*(y+1)+C+1,x++;if(x*=2,d)for(m=(f?b.length-6:b.length-3)/3,b[3*m+2]=_,C=0;C<l;C++)T=3*x,S[T]=C,S[T+1]=C+1,S[T+2]=m,x++;if(f){m=(b.length-3)/3,b[3*m+2]=-_;var M=(l+1)*y;for(C=0;C<l;C++)T=3*x,S[T]=M+C+1,S[T+1]=M+C,S[T+2]=m,x++}return v.getAttributes().Vertex=new X["a"](X["a"].ARRAY_BUFFER,b,3),v.getOrCreateStateSet().setAttributeAndModes(qr()),v.getPrimitives().push(new ze["a"](Ge["a"].TRIANGLES,new X["a"](X["a"].ELEMENT_ARRAY_BUFFER,S,1))),v},en=function(e,t,r){for(var n=new Ve["a"],i=new Float32Array(3*e),a=r||2*Math.PI,o=0;o<e;++o){var s=3*o,u=a*o/e;i[s]=Math.cos(u)*t,i[s+1]=Math.sin(u)*t}n.getAttributes().Vertex=new X["a"](X["a"].ARRAY_BUFFER,i,3);var c=new je["a"](Ge["a"].LINE_STRIP,0,e);return n.getOrCreateStateSet().setAttributeAndModes(qr()),n.getPrimitives().push(c),n},tn=function(e,t){var r=e?.5*e:.5,n=t?.5*t:.5,i=new Ve["a"],a=new Float32Array(12);a[0]=-r,a[1]=-n,a[3]=r,a[4]=-n,a[6]=-r,a[7]=n,a[9]=r,a[10]=n,i.getAttributes().Vertex=new X["a"](X["a"].ARRAY_BUFFER,a,3);var o=new je["a"](Ge["a"].TRIANGLE_STRIP,0,4);return i.getOrCreateStateSet().setAttributeAndModes(qr()),i.getPrimitives().push(o),i},rn=function(){var e=tn();return e.getOrCreateStateSet().setAttributeAndModes(Kr()),e},nn={};nn.createCircleGeometry=en,nn.createCylinderGeometry=$r,nn.createTorusGeometry=Qr,nn.createDebugLineGeometry=Zr,nn.createPlaneGeometry=tn,nn.createQuadCircleGeometry=rn,nn.resetPrograms=Jr;var an=nn,on=function(){};on.prototype={cull:function(){return!1}};var sn=new De["a"](De["a"].SRC_ALPHA,De["a"].ONE_MINUS_SRC_ALPHA),un=function(e){this._testPlane=e,this._inter=F["f"].create(),it["a"].call(this)};j["a"].createPrototypeObject(un,j["a"].objectInherit(it["a"].prototype,{setTestPlane:function(e){this._testPlane=e},getTranslateDistance:function(){return this._inter},enter:function(){var e=F["f"].create(),t=F["f"].create();return function(r){if(void 0===r._nbAxis)return!0;if(F["f"].init(e),e[r._nbAxis]=1,this._testPlane){var n=F["f"].dot(this._iStart,e),i=F["f"].dot(this._iEnd,e);if(n===i)return!1;var a=-n/(i-n);this._inter[0]=this._iStart[0]+(this._iEnd[0]-this._iStart[0])*a,this._inter[1]=this._iStart[1]+(this._iEnd[1]-this._iStart[1])*a,this._inter[2]=this._iStart[2]+(this._iEnd[2]-this._iStart[2])*a}else{F["f"].normalize(t,F["f"].sub(t,this._iEnd,this._iStart));var o=-F["f"].dot(t,e),s=F["f"].dot(this._iStart,t),u=Math.abs(1-o*o),c=-F["f"].dot(this._iStart,e);F["f"].init(this._inter),this._inter[r._nbAxis]=(o*s-c)/u}return!1}}(),intersectTriangle:function(){},intersectLine:function(){},intersectPoint:function(){}}),"osgUtil","LineCustomIntersector");var cn=F["c"].create(),ln=function(e){Be["a"].call(this),this._tmask=1,this._autoInsertMT=!1,this._correctPivotOnAutoInsert=!1,this._viewer=e,this._canvas=e.getGraphicContext().canvas,this._rotateNode=new Be["a"],this._translateNode=new Be["a"],this._planeNode=new Be["a"],this._rotateInLocal=!0,this._translateInLocal=!0,this._showAngle=new Be["a"],this._downCanvasCoord=F["e"].create(),this._hoverNode=null,this._keepHoverColor=F["g"].create(),this._isEditing=!1,this._editLineOrigin=F["f"].create(),this._editLineDirection=F["f"].create(),this._editOffset=F["f"].create(),this._editLocal=F["c"].create(),this._editWorldTrans=F["c"].create(),this._editWorldScaleRot=F["c"].create(),this._editInvWorldScaleRot=F["c"].create(),this._debugNode=new Ar["a"],this._lastDistToEye=0,this._attachedNode=null,this._pivotOffset=F["f"].create(),this.attachToNode(null),this._lsi=new un,this._origIntersect=F["f"].create(),this._dstIntersect=F["f"].create(),this._iv=new nt["a"],this._iv.setIntersector(this._lsi),this.init()};ln.NO_PICK=1,ln.PICK_ARC_X=2,ln.PICK_ARC_Y=4,ln.PICK_ARC_Z=8,ln.PICK_ARROW_X=16,ln.PICK_ARROW_Y=32,ln.PICK_ARROW_Z=64,ln.PICK_PLANE_X=128,ln.PICK_PLANE_Y=256,ln.PICK_PLANE_Z=512,ln.NO_FULL_CIRCLE=1024,ln.CORRECT_PIVOT=2048,ln.PICK_ARC=ln.PICK_ARC_X|ln.PICK_ARC_Y|ln.PICK_ARC_Z,ln.PICK_ARROW=ln.PICK_ARROW_X|ln.PICK_ARROW_Y|ln.PICK_ARROW_Z,ln.PICK_PLANE=ln.PICK_PLANE_X|ln.PICK_PLANE_Y|ln.PICK_PLANE_Z,ln.PICK_GIZMO=ln.PICK_ARC|ln.PICK_ARROW|ln.PICK_PLANE;var hn=function(){Wr["a"].call(this,Wr["a"].TRAVERSE_PARENTS),this._editableNode=null};j["a"].createPrototypeObject(hn,j["a"].objectInherit(Wr["a"].prototype,{reset:function(){Wr["a"].prototype.reset.call(this),this._editableNode=null},getEditableNode:function(){return this._editableNode},apply:function(e){if(!this._editableNode){var t=e.editMask;t&&t&ln.PICK_GIZMO?this._editableNode=e:this.traverse(e)}}})),j["a"].createPrototypeNode(ln,j["a"].objectInherit(Be["a"].prototype,{setRotateInLocal:function(e){this._rotateInLocal=e},setTranslateInLocal:function(e){this._translateInLocal=e},setTraversalMask:function(e){this._tmask=e},setAutoMatrixTransformInsertion:function(e){this._autoInsertMT=e},setCorrectPivotOnAutoInsert:function(e){this._correctPivotOnAutoInsert=e},isEditing:function(){return this._isEditing},getAttachedNode:function(){return this._attachedNode},init:function(){this.getOrCreateStateSet().setAttributeAndModes(new ke["a"](ke["a"].DISABLE)),this.getOrCreateStateSet().setAttributeAndModes(new Fe["a"](Fe["a"].DISABLE)),this.addUpdateCallback(this),this.addChild(this.initNodeTranslate()),this.addChild(this.initNodeTranslatePlane()),this.addChild(this.initNodeRotate()),this._debugNode&&(this._debugNode.addChild(an.createDebugLineGeometry()),this.addChild(this._debugNode),this._debugNode.setNodeMask(0));var e=this._viewer.getInputManager();e.group(ne.NODE_GIZMO).addMappings({onMouseMove:["mousemove","touchmove"],onMouseDown:["mousedown","touchstart"],onMouseUp:["mouseup","mouseout","touchend","touchcancel"]},this),e.setPriority(ne.NODE_GIZMO,e.getHigherPriority(ne.MANIPULATORS))},_insertEditNode:function(e,t){var r=new Be["a"];return r.editMask=ln.PICK_GIZMO,this._correctPivotOnAutoInsert&&(r.editMask|=ln.CORRECT_PIVOT),e.addChild(r),e.removeChild(t),r.addChild(t),r._isInserted=!0,r},_findEditNodeFromNodePath:function(e){if(!e)return null;var t=e[e.length-1];if(t.editMask)return t;if(!this._autoInsertMT){for(var r=e.length-1;r>=0;--r){var n=e[r].editMask;if(n&&n&ln.PICK_GIZMO)return e[r]}return null}var i=e[e.length-2];return i.editMask?i:this._insertEditNode(i,t)},_findEditNodeFromNode:function(e){if(!e)return null;if(e.editMask)return e;if(this._autoInsertMT){for(var t=e.getParents(),r=0;r<t.length;++r){var n=t[r].editMask;if(n&&n&ln.PICK_GIZMO)return t[r]}return this._insertEditNode(t[0],e)}return this._getEditNodeVisitor?this._getEditNodeVisitor.reset():this._getEditNodeVisitor=new hn,e.accept(this._getEditNodeVisitor),this._getEditNodeVisitor.getEditableNode()},attachToNodePath:function(e){var t=this._findEditNodeFromNodePath(e);this._attachEditNode(t,e&&e[e.length-1])},attachToNode:function(e){var t=this._findEditNodeFromNode(e);this._attachEditNode(t,e)},_attachEditNode:function(e,t){this._attachedNode=e,e&&t&&t!==e&&e.editMask&ln.CORRECT_PIVOT&&F["f"].copy(this._pivotOffset,t.getBoundingSphere().center()),this.updateGizmoMask()},updateGizmoMask:function(){if(!this._attachedNode)return F["f"].init(this._pivotOffset),void this.setNodeMask(0);var e=this._attachedNode.editMask;this.setNodeMask(e&ln.PICK_GIZMO?ln.NO_PICK:0),this._translateNode.setNodeMask(e&ln.PICK_ARROW?ln.PICK_ARROW:0),this._rotateNode.setNodeMask(e&ln.PICK_ARC?ln.PICK_ARC:0),this._planeNode.setNodeMask(e&ln.PICK_PLANE?ln.PICK_PLANE:0);var t=this._translateNode.getChildren();t[0].setNodeMask(e&ln.PICK_ARROW_X?ln.PICK_ARROW_X:0),t[1].setNodeMask(e&ln.PICK_ARROW_Y?ln.PICK_ARROW_Y:0),t[2].setNodeMask(e&ln.PICK_ARROW_Z?ln.PICK_ARROW_Z:0);var r=this._rotateNode.getChildren();r[0].setNodeMask(e&ln.NO_FULL_CIRCLE?0:ln.NO_PICK),r[1].setNodeMask(e&ln.PICK_ARC_X?ln.PICK_ARC_X:0),r[2].setNodeMask(e&ln.PICK_ARC_Y?ln.PICK_ARC_Y:0),r[3].setNodeMask(e&ln.PICK_ARC_Z?ln.PICK_ARC_Z:0);var n=this._planeNode.getChildren();n[0].setNodeMask(e&ln.PICK_PLANE_X?ln.PICK_PLANE_X:0),n[1].setNodeMask(e&ln.PICK_PLANE_Y?ln.PICK_PLANE_Y:0),n[2].setNodeMask(e&ln.PICK_PLANE_Z?ln.PICK_PLANE_Z:0)},onNodeHovered:function(){var e=F["g"].fromValues(1,1,0,1);return function(t){if(this._hoverNode&&this._hoverNode.getStateSet().getUniform("uColor").setFloat4(this._keepHoverColor),t){var r=t._nodePath,n=r.length-1,i=r[n];while(void 0===i._nbAxis){if(0===n)return;i=r[--n]}var a=i.getStateSet().getUniform("uColor");this._hoverNode=i,F["g"].copy(this._keepHoverColor,a.getInternalArray()),a.setFloat4(e)}else this._hoverNode=null}}(),initNodeRotate:function(){var e=an.createTorusGeometry(1,.01,6,64,2*Math.PI),t=an.createTorusGeometry(1,.01,6,64,Math.PI),r=an.createTorusGeometry(1,.1,6,64,Math.PI),n=new Be["a"],i=new Be["a"],a=new Be["a"],o=new Be["a"];i._nbAxis=0,a._nbAxis=1,o._nbAxis=2;var s=new Ar["a"];s.setCullCallback(new on),s.addChild(r),e.setNodeMask(ln.NO_PICK),t.setNodeMask(ln.NO_PICK),i.setNodeMask(ln.PICK_ARC_X),a.setNodeMask(ln.PICK_ARC_Y),o.setNodeMask(ln.PICK_ARC_Z),n.addChild(e),i.addChild(t),a.addChild(t),o.addChild(t),i.addChild(s),a.addChild(s),o.addChild(s),n.getOrCreateStateSet().addUniform(Er["a"].createFloat4(F["g"].fromValues(.2,.2,.2,1),"uColor")),i.getOrCreateStateSet().addUniform(Er["a"].createFloat4(F["g"].fromValues(1,0,0,1),"uColor")),a.getOrCreateStateSet().addUniform(Er["a"].createFloat4(F["g"].fromValues(0,1,0,1),"uColor")),o.getOrCreateStateSet().addUniform(Er["a"].createFloat4(F["g"].fromValues(0,0,1,1),"uColor"));var u=this._showAngle;u.getOrCreateStateSet().setAttributeAndModes(sn),u.setNodeMask(0),u.getOrCreateStateSet().addUniform(Er["a"].createFloat3(F["f"].fromValues(1,0,0),"uBase")),u.getOrCreateStateSet().addUniform(Er["a"].createFloat(0,"uAngle")),u.addChild(an.createQuadCircleGeometry());var c=this._rotateNode;return c.setNodeMask(ln.PICK_ARC),c.addChild(n),c.addChild(i),c.addChild(a),c.addChild(o),c.addChild(u),c},initNodeTranslate:function(){var e=1.5,t=.3,r=.5,n=1.1*(e-r+t),i=new Be["a"];F["c"].fromTranslation(i.getMatrix(),F["f"].fromValues(0,0,e+.5*t)),i.addChild(an.createCylinderGeometry(0,.07,t,32,1,!0,!0));var a=new Be["a"];F["c"].fromTranslation(a.getMatrix(),F["f"].fromValues(0,0,.5*e)),a.addChild(an.createCylinderGeometry(.01,.01,e,32,1,!0,!0));var o=new Ar["a"];o.addChild(a),o.addChild(i);var s=an.createCylinderGeometry(.1,.1,n,32,1,!0,!0),u=new Be["a"],c=new Be["a"],l=new Be["a"];u._nbAxis=0,c._nbAxis=1,l._nbAxis=2,F["c"].fromRotation(u.getMatrix(),.5*Math.PI,F["f"].fromValues(0,1,0)),F["c"].fromRotation(c.getMatrix(),.5*-Math.PI,F["f"].fromValues(1,0,0));var h=new Be["a"];h.setCullCallback(new on),F["c"].fromTranslation(h.getMatrix(),F["f"].fromValues(0,0,r+.5*n)),h.addChild(s),o.setNodeMask(ln.NO_PICK),u.setNodeMask(ln.PICK_ARROW_X),c.setNodeMask(ln.PICK_ARROW_Y),l.setNodeMask(ln.PICK_ARROW_Z),u.addChild(o),c.addChild(o),l.addChild(o),u.addChild(h),c.addChild(h),l.addChild(h),u.getOrCreateStateSet().addUniform(Er["a"].createFloat4(F["g"].fromValues(1,0,0,1),"uColor")),c.getOrCreateStateSet().addUniform(Er["a"].createFloat4(F["g"].fromValues(0,1,0,1),"uColor")),l.getOrCreateStateSet().addUniform(Er["a"].createFloat4(F["g"].fromValues(0,0,1,1),"uColor"));var d=this._translateNode;return d.setNodeMask(ln.PICK_ARROW),d.addChild(u),d.addChild(c),d.addChild(l),d},initNodeTranslatePlane:function(){var e=new Be["a"];F["c"].fromTranslation(e.getMatrix(),F["f"].fromValues(.5,.5,0)),F["c"].mul(e.getMatrix(),F["c"].fromScaling(F["c"].create(),F["f"].fromValues(.5,.5,1)),e.getMatrix()),e.addChild(an.createPlaneGeometry());var t=new Be["a"],r=new Be["a"],n=new Be["a"];t._nbAxis=0,r._nbAxis=1,n._nbAxis=2,F["c"].fromRotation(t.getMatrix(),.5*-Math.PI,F["f"].fromValues(0,1,0)),F["c"].fromRotation(r.getMatrix(),.5*Math.PI,F["f"].fromValues(1,0,0)),t.setNodeMask(ln.PICK_PLANE_X),r.setNodeMask(ln.PICK_PLANE_Y),n.setNodeMask(ln.PICK_PLANE_Z),t.addChild(e),r.addChild(e),n.addChild(e),t.getOrCreateStateSet().addUniform(Er["a"].createFloat4(F["g"].fromValues(1,0,0,.3),"uColor")),r.getOrCreateStateSet().addUniform(Er["a"].createFloat4(F["g"].fromValues(0,1,0,.3),"uColor")),n.getOrCreateStateSet().addUniform(Er["a"].createFloat4(F["g"].fromValues(0,0,1,.3),"uColor"));var i=this._planeNode;return i.setNodeMask(ln.PICK_PLANE),i.getOrCreateStateSet().setAttributeAndModes(sn),i.addChild(t),i.addChild(r),i.addChild(n),i},updateArcRotation:function(){var e=F["d"].create(),t=F["d"].setAxisAngle(F["d"].create(),[0,1,0],.5*-Math.PI),r=F["d"].setAxisAngle(F["d"].create(),[1,0,0],.5*-Math.PI);return function(n){var i=this._rotateNode,a=i.getChildren();e[0]=-n[1],e[1]=n[0],e[2]=0,e[3]=1+n[2],F["d"].normalize(e,e),F["c"].fromQuat(a[0].getMatrix(),e),F["d"].setAxisAngle(e,[1,0,0],Math.atan2(n[2],n[1])),F["d"].mul(e,e,t),F["c"].fromQuat(a[1].getMatrix(),e),F["d"].setAxisAngle(e,[0,1,0],Math.atan2(-n[0],-n[2])),F["d"].mul(e,e,r),F["c"].fromQuat(a[2].getMatrix(),e),F["d"].setAxisAngle(e,[0,0,1],Math.atan2(-n[0],n[1])),F["c"].fromQuat(a[3].getMatrix(),e),a[1].dirtyBound(),a[2].dirtyBound(),a[3].dirtyBound()}}(),getTransformType:function(e){var t=e;while(t.getParents().length>0){var r=t.referenceFrame;if(void 0!==r&&r===wr["a"].ABSOLUTE_RF)return wr["a"].ABSOLUTE_RF;t=t.getParents()[0]}return wr["a"].RELATIVE_RF},getAttachedNodeWorldMatrix:function(){var e=this._attachedNode.getWorldMatrix(void 0,cn);return F["c"].translate(e,e,this._pivotOffset)},update:function(){var e=F["f"].create(),t=F["f"].create(),r=F["f"].create(),n=F["c"].create();return function(){if(this._attachedNode){var i=this.getTransformType(this._attachedNode);this.setReferenceFrame(i),this.setCullingActive(i===wr["a"].RELATIVE_RF);var a=this.getAttachedNodeWorldMatrix();F["c"].getTranslation(t,a);var o=3;if(i===wr["a"].ABSOLUTE_RF)e[0]=e[1]=e[2]=0;else{var s=this._viewer.getCamera().getProjectionMatrix(),u=.023*this._canvas.clientWidth*s[0];this._viewer.getManipulator().getEyePosition(e),this._lastDistToEye=this._isEditing?this._lastDistToEye:F["f"].distance(t,e),o*=this._lastDistToEye/u}var c=this.getMatrix();if(F["c"].fromTranslation(c,t),F["f"].set(r,o,o,o),F["c"].mul(c,c,F["c"].fromScaling(n,r)),F["f"].sub(e,e,t),F["f"].normalize(e,e),this._rotateInLocal||this._translateInLocal){F["c"].getScale(r,a);var l=F["c"].fromScaling(n,r);F["c"].invert(l,l);var h=F["c"].mul(a,a,l);h[12]=h[13]=h[14]=0,this._translateInLocal&&(F["c"].copy(this._translateNode.getMatrix(),h),F["c"].copy(this._planeNode.getMatrix(),h)),this._rotateInLocal&&(F["c"].copy(this._rotateNode.getMatrix(),h),F["c"].invert(h,h),F["f"].transformMat4(e,e,h))}else F["c"].identity(this._rotateNode.getMatrix());this.updateArcRotation(e),this._rotateNode.dirtyBound(),this._translateNode.dirtyBound(),this._planeNode.dirtyBound(),this._isEditing&&F["c"].copy(this._showAngle.getMatrix(),this._hoverNode.getMatrix())}}}(),computeNearestIntersection:function(){var e=function(e,t){return e._ratio-t._ratio};return function(t,r){var n=this._viewer,i=this._canvas,a=t.canvasX*(n._canvasWidth/i.clientWidth),o=(i.clientHeight-t.canvasY)*(n._canvasHeight/i.clientHeight),s=this._viewer.computeIntersections(a,o,r);if(0!==s.length)return s.sort(e),s[0]}}(),setOnlyGizmoPicking:function(){this._viewer.getCamera().addChild(this),this._viewer.getSceneData().setNodeMask(0),this.setNodeMask(-1)},setOnlyScenePicking:function(){this._viewer.getCamera().removeChild(this),this._viewer.getSceneData().setNodeMask(-1),this.setNodeMask(ln.NO_PICK)},pickGizmo:function(e,t){this.setOnlyGizmoPicking();var r=this.computeNearestIntersection(e,t);return this.setOnlyScenePicking(),r},getCanvasPositionFromWorldPoint:function(){var e=F["c"].create();return function(t,r){var n=this._viewer.getCamera(),i=r;n.getViewport()?n.getViewport().computeWindowMatrix(e):F["c"].identity(e),F["c"].mul(e,e,n.getProjectionMatrix()),this.getReferenceFrame()===wr["a"].RELATIVE_RF&&F["c"].mul(e,e,n.getViewMatrix()),F["f"].transformMat4(i,t,e);var a=this._viewer,o=this._canvas;return i[0]=i[0]/(a._canvasWidth/o.clientWidth),i[1]=o.clientHeight-i[1]/(a._canvasHeight/o.clientHeight),i}}(),onMouseDown:function(e){if(F["e"].set(this._downCanvasCoord,e.canvasX,e.canvasY),this._hoverNode&&this._attachedNode){this._viewer.setEnableManipulator(!1),this.saveEditMatrices();var t=this._hoverNode.getParents()[0].getNodeMask();this._isEditing=!0,t&ln.PICK_ARC?(this._translateNode.setNodeMask(0),this._planeNode.setNodeMask(0),this.startRotateEdit(e)):t&ln.PICK_ARROW?(this._rotateNode.setNodeMask(0),this._planeNode.setNodeMask(0),this.startTranslateEdit(e)):t&ln.PICK_PLANE&&(this._rotateNode.setNodeMask(0),this._translateNode.setNodeMask(0),this.startPlaneEdit(e))}},saveEditMatrices:function(){F["c"].copy(this._editLocal,this._attachedNode.getMatrix());var e=this.getAttachedNodeWorldMatrix();F["c"].fromTranslation(this._editWorldTrans,F["f"].fromValues(e[12],e[13],e[14])),F["c"].copy(this._editWorldScaleRot,e),this._editWorldScaleRot[12]=this._editWorldScaleRot[13]=this._editWorldScaleRot[14]=0,F["c"].invert(this._editInvWorldScaleRot,this._editWorldScaleRot)},startRotateEdit:function(e){var t=this._rotateNode.getWorldMatrix(void 0,cn),r=F["f"].create();F["f"].transformMat4(r,r,t),this.getCanvasPositionFromWorldPoint(r,r);var n=this.pickGizmo(e,this._hoverNode.getNodeMask()|ln.PICK_ARC);if(n){var i=0===this._hoverNode._nbAxis?-1:1,a=F["f"].create();a[0]=i*n._localIntersectionPoint[1],a[1]=-i*n._localIntersectionPoint[0],a[2]=n._localIntersectionPoint[2];var o=F["f"].create();F["f"].transformMat4(o,a,this._hoverNode.getMatrix()),F["f"].transformMat4(o,o,t),this.getCanvasPositionFromWorldPoint(o,o);var s=this._editLineDirection;F["e"].sub(s,o,r),F["e"].normalize(s,s),this._showAngle.setNodeMask(ln.NO_PICK),n._localIntersectionPoint[2]=0;var u=this._showAngle.getStateSet();u.getUniform("uAngle").setFloat(0),u.getUniform("uBase").setVec3(F["f"].normalize(n._localIntersectionPoint,n._localIntersectionPoint)),this._editLineOrigin[0]=e.canvasX,this._editLineOrigin[1]=e.canvasY}},startTranslateEdit:function(e){var t=this._editLineOrigin,r=this._editLineDirection,n=this._translateNode.getWorldMatrix(void 0,cn);F["c"].getTranslation(t,n),F["f"].init(r),r[this._hoverNode._nbAxis]=1,this._translateInLocal&&(F["f"].transformMat4(r,r,this._editWorldScaleRot),F["f"].normalize(r,r)),F["f"].add(r,t,r),this.getCanvasPositionFromWorldPoint(t,t),this.getCanvasPositionFromWorldPoint(r,r),F["e"].sub(r,r,t),F["e"].normalize(r,r);var i=this._editOffset;F["e"].set(i,e.canvasX,e.canvasY),F["e"].sub(i,i,t)},startPlaneEdit:function(e){var t=this._editLineOrigin,r=this._planeNode.getWorldMatrix(void 0,cn);F["c"].getTranslation(t,r),this.getCanvasPositionFromWorldPoint(t,t);var n=this._editOffset;F["e"].set(n,e.canvasX,e.canvasY),F["e"].sub(n,n,t)},drawLineCanvasDebug:function(e,t,r,n){this._debugNode.setNodeMask(ln.NO_PICK);var i=this._debugNode.getChildren()[0].getAttributes().Vertex;i.getElements()[0]=e/this._canvas.clientWidth*2-1,i.getElements()[1]=(this._canvas.clientHeight-t)/this._canvas.clientHeight*2-1,i.getElements()[2]=r/this._canvas.clientWidth*2-1,i.getElements()[3]=(this._canvas.clientHeight-n)/this._canvas.clientHeight*2-1,i.dirty()},pickAndSelect:function(e){this.setNodeMask(0);var t=this.computeNearestIntersection(e,this._tmask);this.attachToNodePath(t?t._nodePath:t)},onMouseUp:function(e){this._viewer.setEnableManipulator(!0),this._debugNode&&this._debugNode.setNodeMask(0);var t=F["e"].fromValues(e.canvasX,e.canvasY);0===F["e"].distance(t,this._downCanvasCoord)&&this.pickAndSelect(e),this._showAngle.setNodeMask(0),this._isEditing=!1,this._hoverNode&&this.updateGizmoMask()},onMouseMove:function(e){if(this._attachedNode){var t;if(!1===this._isEditing)return t=this.pickGizmo(e,ln.PICK_GIZMO),void this.onNodeHovered(t);if(this._hoverNode){var r=this._hoverNode.getParents()[0];r===this._rotateNode?this.updateRotateEdit(e):r===this._translateNode?this.updateTranslateEdit(e):r===this._planeNode&&this.updatePlaneEdit(e)}}},updateRotateEdit:function(){var e=F["c"].create(),t=F["e"].create(),r=F["f"].fromValues(1,0,0),n=F["f"].fromValues(0,1,0),i=F["f"].fromValues(0,0,1),a=F["f"].create();return function(o){var s=this._editLineOrigin,u=this._editLineDirection;F["e"].set(t,o.canvasX,o.canvasY),F["e"].sub(t,t,s);var c=F["e"].dot(t,u);if(this._debugNode){var l=s[0],h=s[1];this.drawLineCanvasDebug(l,h,l+u[0]*c,h+u[1]*c)}var d=Math.min(this._canvas.clientWidth,this._canvas.clientHeight),f=7*c/d;f%=2*Math.PI;var _=this._hoverNode._nbAxis;0===_?F["c"].fromRotation(e,-f,r):1===_?F["c"].fromRotation(e,-f,n):2===_&&F["c"].fromRotation(e,-f,i);var p=this._showAngle.getOrCreateStateSet().getUniform("uAngle");p.setFloat(0===_?-f:f),this._rotateInLocal||(F["c"].mul(e,this._editInvWorldScaleRot,e),F["c"].mul(e,e,this._editWorldScaleRot));var g=this._attachedNode.getMatrix();F["c"].translate(g,this._editLocal,this._pivotOffset),F["c"].mul(g,g,e),F["c"].translate(g,g,F["f"].negate(a,this._pivotOffset)),this._attachedNode.dirtyBound()}}(),updateTranslateEdit:function(){var e=F["e"].create(),t=F["f"].create();return function(r){var n=this._editLineOrigin,i=this._editLineDirection;F["e"].set(e,r.canvasX,r.canvasY),F["e"].sub(e,e,n),F["e"].sub(e,e,this._editOffset);var a=F["e"].dot(e,i);e[0]=n[0]+i[0]*a,e[1]=n[1]+i[1]*a,this._debugNode&&this.drawLineCanvasDebug(n[0],n[1],e[0],e[1]);var o=this._viewer,s=this._canvas,u=e[0]*(o._canvasWidth/s.clientWidth),c=(s.clientHeight-e[1])*(o._canvasHeight/s.clientHeight);if(this._lsi.reset(),this._lsi.setTestPlane(!1),this._lsi.set(F["f"].set(this._origIntersect,u,c,0),F["f"].set(this._dstIntersect,u,c,1)),this._iv.reset(),this._iv.setTraversalMask(this._hoverNode.getNodeMask()),F["c"].copy(this.getMatrix(),this._editWorldTrans),this.setOnlyGizmoPicking(),this._viewer._camera.accept(this._iv),this.setOnlyScenePicking(),this._translateInLocal){F["c"].getScale(t,this._editInvWorldScaleRot);var l=this._lsi.getTranslateDistance();F["f"].mul(t,t,l)}else F["f"].transformMat4(t,this._lsi.getTranslateDistance(),this._editInvWorldScaleRot);F["c"].translate(this._attachedNode.getMatrix(),this._editLocal,t),this._attachedNode.dirtyBound()}}(),updatePlaneEdit:function(){var e=F["e"].create(),t=F["f"].create();return function(r){F["e"].set(e,r.canvasX,r.canvasY),F["e"].sub(e,e,this._editOffset);var n=this._viewer,i=this._canvas,a=e[0]*(n._canvasWidth/i.clientWidth),o=(i.clientHeight-e[1])*(n._canvasHeight/i.clientHeight);if(this._lsi.reset(),this._lsi.setTestPlane(!0),this._lsi.set(F["f"].set(this._origIntersect,a,o,0),F["f"].set(this._dstIntersect,a,o,1)),this._iv.reset(),this._iv.setTraversalMask(this._hoverNode.getNodeMask()),F["c"].copy(this.getMatrix(),this._editWorldTrans),this.setOnlyGizmoPicking(),this._viewer._camera.accept(this._iv),this.setOnlyScenePicking(),this._translateInLocal){F["c"].getScale(t,this._editInvWorldScaleRot);var s=this._lsi.getTranslateDistance();F["f"].mul(t,t,s)}else F["f"].transformMat4(t,this._lsi.getTranslateDistance(),this._editInvWorldScaleRot);F["c"].translate(this._attachedNode.getMatrix(),this._editLocal,t),this._attachedNode.dirtyBound()}}()}),"osgUtil","NodeGizmo");var dn=ln,fn=n("5e15"),_n=n("187b"),pn=function(){zr["a"].Intersection.call(this),this._intersectionPoints=[],this._distance=0,this._maxDistance=0,this._numIntersectionPoints=0},gn=function(){zr["a"].call(this),this._src=[],this._dest=[],this._maxNumIntersectionsPoints=6};j["a"].createPrototypeObject(gn,j["a"].objectInherit(zr["a"].prototype,{reset:function(){zr["a"].prototype.reset.call(this),this._src=[],this._dest=[]},enter:function(e){return!!this._intersector.getPolytope().containsBoundingBox(e)&&(this._intersector.getPolytope().pushCurrentMask(),!0)},leave:function(){this._intersector.getPolytope().popCurrentMask()},addIntersection:function(){this._src=j["a"].arrayUniq(this._src);for(var e=this._src,t=F["f"].create(),r=-Number.MAX_VALUE,n=this._intersector._iReferencePlane,i=0;i<e.length;++i){F["f"].add(t,t,e[i]);var a=_n["a"].distanceToPlane(n,e[i]);a>r&&(r=a)}F["f"].scale(t,t,1/e.length);var o=this.initIntersection(new pn);o._distance=_n["a"].distanceToPlane(n,t),o._maxDistance=r,F["f"].copy(o._localIntersectionPoint,t);var s=this._maxNumIntersectionsPoints;for(o._numIntersectionPoints=e.length<s?e.length:s,i=0;i<o._numIntersectionPoints;++i)o._intersectionPoints.push(F["f"].clone(this._src[i]))},contains:function(){var e=this._intersector.getPolytope(),t=e.getPlanes(),r=e.getCurrentMask();if(!r)return!0;for(var n=1,i=0;i<t.length;++i)if(r&0===n)n<<=1;else{this._dest=[];for(var a=t[i],o=this._src[0],s=_n["a"].distanceToPlane(a,o),u=1;u<this._src.length;++u){var c=this._src[u],l=_n["a"].distanceToPlane(a,c);if(s>=0&&this._dest.push(F["f"].clone(o)),s*l<0){var h=s-l,d=s/h,f=F["f"].add(F["f"].create(),F["f"].scale(F["f"].create(),o,1-d),F["f"].scale(F["f"].create(),c,d));this._dest.push(f)}s=l,o=c}if(s>=0&&this._dest.push(F["f"].clone(o)),this._dest.length<=1)return!1;var _=this._src.slice();this._src=this._dest.slice(),this._dest=_}return!0},containsPoint:function(e){return!!this._intersector.getPolytope().containsVertex(e)&&(this._src=[],this._src[0]=e,!0)},containsLine:function(e,t){return this._src=[],this._src[0]=e,this._src[1]=t,this._src[2]=e,this.contains()},containsTriangle:function(e,t,r){return this._src=[],this._src[0]=e,this._src[1]=t,this._src[2]=r,this._src[3]=e,this.contains()},intersectPoint:function(e){this.containsPoint(e)&&this.addIntersection()},intersectLine:function(e,t){this.containsLine(e,t)&&this.addIntersection()},intersectTriangle:function(e,t,r){this.containsTriangle(e,t,r)&&this.addIntersection()}}),"osgUtil","PolytopeIntersectFunctor");var mn=gn,vn=function(){jr["a"].call(this),this._index=0,this._polytope=new fn["a"],this._iPolytope=new fn["a"],this._referencePlane=F["g"].create(),this._iReferencePlane=F["g"].create()},bn=function(e,t,r){var n=t[0],i=t[1],a=t[2],o=t[3];e[0]=r[0]*n+r[1]*i+r[2]*a+r[3]*o,e[1]=r[4]*n+r[5]*i+r[6]*a+r[7]*o,e[2]=r[8]*n+r[9]*i+r[10]*a+r[11]*o,e[3]=r[12]*n+r[13]*i+r[14]*a+r[15]*o};j["a"].createPrototypeObject(vn,j["a"].objectInherit(jr["a"].prototype,{setPolytope:function(e){this._polytope.setPlanes(e);for(var t=[],r=0;r<e.length;++r){var n=e[r];t[r]=F["g"].copy(this._iPolytope.getPlanes()[r]||_n["a"].create(),n)}this._iPolytope.setPlanes(t),F["g"].copy(this._referencePlane,e[e.length-1]),F["g"].copy(this._iReferencePlane,this._referencePlane)},getPolytope:function(){return this._iPolytope},setPolytopeFromWindowCoordinates:function(e,t,r,n){this.setPolytope([F["g"].fromValues(1,0,0,-e),F["g"].fromValues(-1,0,0,r),F["g"].fromValues(0,1,0,-t),F["g"].fromValues(0,-1,0,n),F["g"].fromValues(0,0,1,0)])},intersectBoundingBox:function(e){return this._iPolytope.containsBoundingBox(e)},intersectBoundingSphere:function(e){return this._iPolytope.containsBoundingSphere(e)},intersect:function(){var e=new mn;return function(t,r){e.setGeometry(r),e.setIntersectionVisitor(t),e.setIntersector(this);var n=r.getShape();n?n.intersect(e,n.getNodes()[0]):(r.computeTransformedVertices&&e.setVertices(r.computeTransformedVertices()),e.apply(r)),e.reset()}}(),setCurrentTransformation:function(e){for(var t=this._polytope.getPlanes(),r=this._iPolytope.getPlanes(),n=0,i=t.length;n<i;n++){var a=r[n]=r[n]||F["g"].create();bn(a,t[n],e),F["g"].scale(a,a,1/F["f"].len(a))}bn(this._iReferencePlane,this._referencePlane,e),F["g"].scale(this._iReferencePlane,this._iReferencePlane,1/F["f"].len(this._iReferencePlane))}}),"osgUtil","PolytopeIntersector");var Sn=vn,xn=function(){zr["a"].Intersection.call(this),this._localIntersectionNormal=F["f"].clone(F["f"].ONE),this._i1=-1,this._i2=-1,this._i3=-1,this._r1=0,this._r2=0,this._r3=0},Tn=function(){zr["a"].apply(this),this._center=void 0,this._radius=0};j["a"].createPrototypeObject(Tn,j["a"].objectInherit(zr["a"].prototype,{set:function(e,t){this._center=e,this._radius=t},enter:function(e){for(var t=this._radius*this._radius,r=0,n=e.getMin(),i=e.getMax(),a=0,o=0;o<3;o++)this._center[o]<n[o]?(a=this._center[o]-n[o],r+=a*a):this._center[o]>i[o]&&(a=this._center[o]-i[o],r+=a*a);return r<=t},intersectPoint:function(e,t){var r=F["f"].sqrDist(e,this._center);if(!(r>this._radius*this._radius)){var n=this.initIntersection(new xn);n._i1=t,n._r1=1,F["f"].copy(n._localIntersectionPoint,e),n._ratio=Math.sqrt(r)/this._radius}},intersectLine:function(){var e=F["f"].create(),t=F["f"].create();return function(r,n,i,a){F["f"].sub(e,this._center,r),F["f"].sub(t,n,r);var o=F["f"].dot(e,t)/F["f"].sqrLen(t),s=1;if(s=o<0?F["f"].sqrLen(e):o>1?F["f"].sqrDist(this._center,n):F["f"].sqrLen(F["f"].scaleAndAdd(e,e,t,-o)),!(s>this._radius*this._radius)){var u=this.initIntersection(new xn);u._i1=i,u._i2=a,u._r1=1-o,u._r2=o,F["f"].scaleAndAdd(u._localIntersectionPoint,r,t,o),u._ratio=Math.sqrt(s)/this._radius}}}(),intersectTriangle:function(){var e=F["f"].create(),t=F["f"].create(),r=F["f"].create();return function(n,i,a,o,s,u){if(!this._limitOneIntersection||!this._hit){F["f"].sub(e,i,n),F["f"].sub(t,a,n);var c=F["f"].sqrLen(e),l=F["f"].dot(e,t),h=F["f"].sqrLen(t);F["f"].sub(r,n,this._center);var d=F["f"].dot(r,e),f=F["f"].dot(r,t),_=F["f"].sqrLen(r),p=Math.abs(c*h-l*l);if(!(p<1e-10)){var g,m,v,b,S,x=l*f-h*d,T=l*d-c*f,y=4;if(x+T<=p)if(x<0)T<0?(y=4,d<0?(T=0,-d>=c?(x=1,g=c+2*d+_):(x=-d/c,g=d*x+_)):(x=0,f>=0?(T=0,g=_):-f>=h?(T=1,g=h+2*f+_):(T=-f/h,g=f*T+_))):(y=3,x=0,f>=0?(T=0,g=_):-f>=h?(T=1,g=h+2*f+_):(T=-f/h,g=f*T+_));else if(T<0)y=5,T=0,d>=0?(x=0,g=_):-d>=c?(x=1,g=c+2*d+_):(x=-d/c,g=d*x+_);else{y=0;var C=1/p;x*=C,T*=C,g=x*(c*x+l*T+2*d)+T*(l*x+h*T+2*f)+_}else x<0?(y=2,m=l+d,v=h+f,v>m?(b=v-m,S=c-2*l+h,b>=S?(x=1,T=0,g=c+2*d+_):(x=b/S,T=1-x,g=x*(c*x+l*T+2*d)+T*(l*x+h*T+2*f)+_)):(x=0,v<=0?(T=1,g=h+2*f+_):f>=0?(T=0,g=_):(T=-f/h,g=f*T+_))):T<0?(y=6,m=l+f,v=c+d,v>m?(b=v-m,S=c-2*l+h,b>=S?(T=1,x=0,g=h+2*f+_):(T=b/S,x=1-T,g=x*(c*x+l*T+2*d)+T*(l*x+h*T+2*f)+_)):(T=0,v<=0?(x=1,g=c+2*d+_):d>=0?(x=0,g=_):(x=-d/c,g=d*x+_))):(y=1,b=h+f-l-d,b<=0?(x=0,T=1,g=h+2*f+_):(S=c-2*l+h,b>=S?(x=1,T=0,g=c+2*d+_):(x=b/S,T=1-x,g=x*(c*x+l*T+2*d)+T*(l*x+h*T+2*f)+_)));if(!(g>this._radius*this._radius)){var A=F["f"].create(),E=this.initIntersection(new xn);E._i1=o,E._i2=s,E._i3=u,E._r1=1-x-T,E._r2=x,E._r3=T;var R=E._localIntersectionPoint;F["f"].scaleAndAdd(R,F["f"].scaleAndAdd(R,n,e,x),t,T),F["f"].cross(E._localIntersectionNormal,e,t),F["f"].normalize(A,E._localIntersectionNormal),E._ratio=Math.sqrt(g)/this._radius,E._zone=y}}}}}()}),"osgUtil","SphereIntersectFunctor");var yn=Tn,Cn=function(){jr["a"].call(this),this._center=F["f"].create(),this._iCenter=F["f"].create(),this._radius=1,this._iRadius=1};j["a"].createPrototypeObject(Cn,j["a"].objectInherit(jr["a"].prototype,{set:function(e,t){F["f"].copy(this._center,e),F["f"].copy(this._iCenter,e),this._radius=this._iRadius=t,this.reset()},setCenter:function(e){F["f"].copy(this._center,e),F["f"].copy(this._iCenter,e)},setRadius:function(e){this._radius=this._iRadius=e},intersectNode:function(e){return this.intersectBoundingSphere(e.getBoundingSphere())},intersectBoundingSphere:function(e){if(!e.valid())return!1;var t=this._iRadius+e.radius();return F["f"].sqrDist(e.center(),this._iCenter)<=t*t},intersect:function(){var e=new yn;return function(t,r){e.setGeometry(r),e.setIntersectionVisitor(t),e.setIntersector(this),e.set(this._iCenter,this._iRadius);var n=r.getShape();n?n.intersect(e,n.getNodes()[0]):(r.computeTransformedVertices&&e.setVertices(r.computeTransformedVertices()),e.apply(r)),e.reset()}}(),setCurrentTransformation:function(){var e=F["f"].create();return function(t){F["c"].invert(t,t),F["f"].transformMat4(this._iCenter,this._center,t),F["c"].getScale(e,t);var r=e[0],n=e[1],i=e[2],a=r>n?r>i?r:i:n>i?n:i;this._iRadius=this._radius*a}}()}),"osgUtil","SphereIntersector");var An=Cn,En=function(){Wr["a"].call(this),this._T=void 0,this._B=void 0,this._N=void 0,this._texCoordUnit=0};j["a"].createPrototypeObject(En,j["a"].objectInherit(Wr["a"].prototype,{apply:function(e){e.getTypeID()===Ve["a"].getTypeID()?this.generate(e,this._texCoordUnit):this.traverse(e)},setTexCoordUnit:function(e){this._texCoordUnit=e},computePrimitiveSet:function(e,t){if(t.getIndices){var r,n=t.getNumIndices(),i=e.getAttributes().Vertex,a=e.getAttributes().Normal,o=e.getAttributes()["TexCoord"+this._texCoordUnit];if(t.getMode()===Ge["a"].TRIANGLES)for(r=0;r<n;r+=3)this.compute(t,i,a,o,r,r+1,r+2);else if(t.getMode()===Ge["a"].TRIANGLE_STRIP)for(r=0;r<n-2;++r)r%2===0?this.compute(t,i,a,o,r,r+1,r+2):this.compute(t,i,a,o,r+1,r,r+2)}},generate:function(e,t){if(this._texCoordUnit=t,void 0===this._texCoordUnit&&(this._texCoordUnit=0),e.getAttributes()["TexCoord"+this._texCoordUnit]){var r=e.getAttributes().Vertex.getElements().length;this._T=new j["a"].Float32Array(r),this._B=new j["a"].Float32Array(r),this._N=new j["a"].Float32Array(r),e.getPrimitiveSetList().forEach((function(t){this.computePrimitiveSet(e,t)}),this);for(var n=r/3,i=new j["a"].Float32Array(4*n),a=F["f"].create(),o=F["f"].create(),s=F["f"].create(),u=0;u<n;u++){var c=this._T.subarray(3*u,3*u+3),l=this._N.subarray(3*u,3*u+3),h=this._B.subarray(3*u,3*u+3);F["f"].normalize(l,l);var d=F["f"].dot(l,c);F["f"].scale(o,l,d),F["f"].sub(a,c,o),F["f"].normalize(s,a),F["f"].cross(a,l,c);var f=F["f"].dot(a,h);f=f<0?-1:0,i[4*u]=s[0],i[4*u+1]=s[1],i[4*u+2]=s[2],i[4*u+3]=f}e.getAttributes().Normal.setElements(this._N),e.getAttributes().Tangent=new X["a"]("ARRAY_BUFFER",i,4)}},compute:function(e,t,r,n,i,a,o){var s,u,c=e.index(i),l=e.index(a),h=e.index(o),d=t.getElements().subarray(3*c,3*c+3),f=t.getElements().subarray(3*l,3*l+3),_=t.getElements().subarray(3*h,3*h+3),p=r.getElements().subarray(3*c,3*c+3),g=r.getElements().subarray(3*l,3*l+3),m=r.getElements().subarray(3*h,3*h+3),v=n.getElements().subarray(2*c,2*c+2),b=n.getElements().subarray(2*l,2*l+2),S=n.getElements().subarray(2*h,2*h+2),x=F["f"].create(),T=F["f"].create(),y=F["f"].create(),C=F["f"].create(),A=F["f"].create(),E=F["f"].create(),R=F["f"].create(),M=F["f"].create(),w=F["f"].create();F["f"].set(M,f[0]-d[0],b[0]-v[0],b[1]-v[1]),F["f"].set(w,_[0]-d[0],S[0]-v[0],S[1]-v[1]),F["f"].cross(x,M,w),0!==x[0]&&(F["f"].normalize(x,x),u=-x[1]/x[0],s=-x[2]/x[0],A[0]+=u,T[0]+=s,E[0]+=u,y[0]+=s,R[0]+=u,C[0]+=s),F["f"].set(M,f[1]-d[1],b[0]-v[0],b[1]-v[1]),F["f"].set(w,_[1]-d[1],S[0]-v[0],S[1]-v[1]),F["f"].cross(x,M,w),0!==x[0]&&(F["f"].normalize(x,x),u=-x[1]/x[0],s=-x[2]/x[0],A[1]+=u,T[1]+=s,E[1]+=u,y[1]+=s,R[1]+=u,C[1]+=s),F["f"].set(M,f[2]-d[2],b[0]-v[0],b[1]-v[1]),F["f"].set(w,_[2]-d[2],S[0]-v[0],S[1]-v[1]),F["f"].cross(x,M,w),0!==x[0]&&(F["f"].normalize(x,x),u=-x[1]/x[0],s=-x[2]/x[0],A[2]+=u,T[2]+=s,E[2]+=u,y[2]+=s,R[2]+=u,C[2]+=s);var N,O,I,P=F["f"].create(),D=F["f"].create();F["f"].cross(P,p,A),F["f"].cross(D,P,p),N=this._T.subarray(3*c,3*c+3),F["f"].add(N,D,N),F["f"].cross(P,T,p),F["f"].cross(D,p,P),O=this._B.subarray(3*c,3*c+3),F["f"].add(O,D,O),F["f"].cross(P,g,E),F["f"].cross(D,P,g),N=this._T.subarray(3*l,3*l+3),F["f"].add(N,D,N),F["f"].cross(P,y,g),F["f"].cross(D,g,P),O=this._B.subarray(3*l,3*l+3),F["f"].add(O,D,O),F["f"].cross(P,m,R),F["f"].cross(D,P,m),N=this._T.subarray(3*h,3*h+3),F["f"].add(N,D,N),F["f"].cross(P,C,m),F["f"].cross(D,m,P),O=this._B.subarray(3*h,3*h+3),F["f"].add(O,D,O),I=this._N.subarray(3*c,3*c+3),F["f"].add(I,p,I),I=this._N.subarray(3*l,3*l+3),F["f"].add(I,g,I),I=this._N.subarray(3*h,3*h+3),F["f"].add(I,m,I)}}),"osgUtil","TangentSpaceGenerator");var Rn=En,Mn={},wn=function(e,t,r,n,i){this._viewer=e,this._rttScene=t,this._hmdConfig=r,this._root=n,this._canvas=i,this._width=i.width,this._height=i.height};wn.prototype={update:function(){var e=this._canvas,t=e.width,r=e.height;if(t!==this._width||r!==this._height){this._root.removeChildren();var n=this._hmdConfig;n&&n.isCardboard&&(n.hResolution=t,n.vResolution=r),this._width=t,this._height=r,Mn.createScene(this._viewer,this._rttScene,n,this._root)}return!0}};var Nn=function(e,t){this._rootView=e,this._offsetView=t};Nn.prototype={update:function(e){var t=e.getViewMatrix();return F["c"].mul(t,this._offsetView,this._rootView),!0}};var On=function(e,t,r,n){var i=t.hResolution/(2*t.vResolution),a=-1-4*(.25*t.hScreenSize-.5*t.lensSeparationDistance)/t.hScreenSize,o=t.distortionK[0]+t.distortionK[1]*Math.pow(a,2)+t.distortionK[2]*Math.pow(a,4)+t.distortionK[3]*Math.pow(a,6),s=180/Math.PI*2*Math.atan2(t.vScreenSize*o,2*t.eyeToScreenDistance),u=F["c"].perspective(F["c"].create(),Math.PI/180*s,i,.3,1e4),c=4*(.25*t.hScreenSize-.5*t.interpupillaryDistance)/t.hScreenSize,l=4*(.25*t.hScreenSize-.5*t.lensSeparationDistance)/t.hScreenSize,h=F["c"].create(),d=F["c"].create();n.projectionLeft=F["c"].mul(h,F["c"].fromTranslation(h,F["f"].fromValues(c,0,0)),u),n.projectionRight=F["c"].mul(d,F["c"].fromTranslation(d,F["f"].fromValues(-c,0,0)),u),n.viewLeft=F["c"].fromTranslation(F["c"].create(),F["f"].fromValues(e*t.interpupillaryDistance*.5,0,0)),n.viewRight=F["c"].fromTranslation(F["c"].create(),F["f"].fromValues(-e*t.interpupillaryDistance*.5,0,0)),r.lensCenterLeft=F["e"].fromValues(l,0),r.lensCenterRight=F["e"].fromValues(-l,0),r.hmdWarpParam=t.distortionK,r.chromAbParam=t.chromaAbParameter,r.scaleIn=F["e"].fromValues(1,1/i),r.scale=F["e"].fromValues(1/o,1*i/o)},In=function(){var e=["","#ifdef GL_ES","precision highp float;","#endif","uniform vec2 uScale;","uniform vec2 uScaleIn;","uniform vec2 uLensCenter;","uniform vec4 uHmdWarpParam;","uniform vec4 uChromAbParam;","uniform sampler2D Texture0;","varying vec2 vTexCoord0;","void main(void) {"," vec2 uv = (vTexCoord0 * 2.0) - 1.0;"," vec2 theta = (uv - uLensCenter) * uScaleIn;"," float rSq = theta.x * theta.x + theta.y * theta.y;"," vec2 rvector = theta * (uHmdWarpParam.x + uHmdWarpParam.y * rSq + uHmdWarpParam.z * rSq * rSq + uHmdWarpParam.w * rSq * rSq * rSq);"," vec2 rBlue = rvector * (uChromAbParam.z + uChromAbParam.w * rSq);"," vec2 tcBlue = (uLensCenter + uScale * rBlue);"," tcBlue = (tcBlue + 1.0) * 0.5;"," if (any(bvec2(clamp(tcBlue, vec2(0.0, 0.0), vec2(1.0, 1.0)) - tcBlue))) {"," gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);"," return;"," }"," vec2 tcGreen = uLensCenter + uScale * rvector;"," tcGreen = (tcGreen + 1.0) * 0.5;"," vec2 rRed = rvector * (uChromAbParam.x + uChromAbParam.y * rSq);"," vec2 tcRed = uLensCenter + uScale * rRed;"," tcRed = (tcRed + 1.0) * 0.5;"," gl_FragColor = vec4(texture2D(Texture0, tcRed).r, texture2D(Texture0, tcGreen).g, texture2D(Texture0, tcBlue).b, 1);","}",""].join("\n");return new K["a"](new Y["a"](Y["a"].VERTEX_SHADER,["attribute vec3 Vertex;","varying vec2 vTexCoord0;","void main(void) {"," gl_Position = vec4(Vertex * 2.0 - 1.0, 1.0);"," vTexCoord0 = Vertex.xy;","}","","#define SHADER_NAME VRpostProcessing",""].join("\n")),new Y["a"](Y["a"].FRAGMENT_SHADER,e))},Pn=function(e){var t=new J["default"];return t.setTextureSize(e[0],e[1]),t.setMinFilter("LINEAR"),t.setMagFilter("LINEAR"),t},Dn=function(e,t,r,n,i,a){var o=new Le["a"],s=t[0],u=t[1],c=r[0],l=r[1];!0===n?e?o.setViewport(new Mr["a"](0,0,c/2,l)):o.setViewport(new Mr["a"](c/2,0,c/2,l)):e?o.setViewport(new Mr["a"](.5*c-s,.5*(l-u),s,u)):o.setViewport(new Mr["a"](.5*c,.5*(l-u),s,u)),F["c"].ortho(o.getProjectionMatrix(),-.5,.5,-.5,.5,-5,5),o.setRenderOrder(Le["a"].NESTED_RENDER,0),o.setReferenceFrame(Ue["a"].ABSOLUTE_RF);var h=o.getOrCreateStateSet();return h.setTextureAttributeAndModes(0,i),h.setAttributeAndModes(In()),h.addUniform(Er["a"].createFloat2(a.scale,"uScale")),h.addUniform(Er["a"].createFloat2(a.scaleIn,"uScaleIn")),h.addUniform(Er["a"].createFloat2(e?a.lensCenterLeft:a.lensCenterRight,"uLensCenter")),h.addUniform(Er["a"].createFloat4(a.hmdWarpParam,"uHmdWarpParam")),h.addUniform(Er["a"].createFloat4(a.chromAbParam,"uChromAbParam")),o},Ln=function(e,t){var r=new Le["a"];return r.setName("rtt camera"),r.setViewport(new Mr["a"](0,0,e.getWidth(),e.getHeight())),r.setProjectionMatrix(t),r.setClearColor(F["g"].fromValues(.3,.3,.3,0)),r.setRenderOrder(Le["a"].POST_RENDER,0),r.attachTexture(W["a"].COLOR_ATTACHMENT0,e),r.attachRenderBuffer(W["a"].DEPTH_ATTACHMENT,W["a"].DEPTH_COMPONENT16),r.setReferenceFrame(Ue["a"].ABSOLUTE_RF),r};Mn.createScene=function(e,t,r,n,i){var a=Mn.getDefaultConfig(r),o=F["e"].fromValues(.5*a.hResolution,a.vResolution),s=F["e"].fromValues(.5*a.hResolution,a.vResolution),u=e.getCamera().getViewport(),c=F["e"].fromValues(u.width(),u.height()),l=e.getGraphicContext().canvas;a.isCardboard&&(c[0]=l.width,c[1]=l.height);var h=void 0!==i?i:1,d={},f={};On(h,a,d,f);var _=e.getCamera().getViewMatrix(),p=n||new Ar["a"];p.addUpdateCallback(new wn(e,t,r,p,l));var g=Pn(o),m=Ln(g,f.projectionLeft),v=Dn(!0,s,c,a.isCardboard,g,d);m.addUpdateCallback(new Nn(_,f.viewLeft));var b=Pn(o),S=Ln(b,f.projectionRight),x=Dn(!1,s,c,a.isCardboard,b,d);return S.addUpdateCallback(new Nn(_,f.viewRight)),m.addChild(t),S.addChild(t),v.addChild(at["a"].createTexturedFullScreenFakeQuadGeometry()),x.addChild(at["a"].createTexturedFullScreenFakeQuadGeometry()),p.addChild(m),p.addChild(S),p.addChild(v),p.addChild(x),p},Mn.getDefaultConfig=function(e){var t={hResolution:1920,vResolution:1080,hScreenSize:.1296,vScreenSize:.0729,interpupillaryDistance:.064,lensSeparationDistance:.0635,eyeToScreenDistance:.04,distortionK:F["g"].fromValues(1,.22,.13,.02),chromaAbParameter:F["g"].fromValues(.996,-.004,1.014,0),isCardboard:!1};return 2===e||void 0===e?t:1===e?(t.hResolution=1280,t.vResolution=800,t.hScreenSize=.14976,t.vScreenSize=.0936,t.lensSeparationDistance=.064,t.eyeToScreenDistance=.041,t.distortionK=F["g"].fromValues(1,.22,.24,0),t):(void 0!==e.hResolution&&(t.hResolution=e.hResolution),void 0!==e.vResolution&&(t.vResolution=e.vResolution),void 0!==e.hScreenSize&&(t.hScreenSize=e.hScreenSize),void 0!==e.vScreenSize&&(t.vScreenSize=e.vScreenSize),void 0!==e.interpupillaryDistance&&(t.interpupillaryDistance=e.interpupillaryDistance),void 0!==e.lensSeparationDistance&&(t.lensSeparationDistance=e.lensSeparationDistance),void 0!==e.eyeToScreenDistance&&(t.eyeToScreenDistance=e.eyeToScreenDistance),void 0!==e.distortionK&&(t.distortionK=e.distortionK),void 0!==e.chromaAbParameter&&(t.chromaAbParameter=e.chromaAbParameter),void 0!==e.isCardboard&&(t.isCardboard=e.isCardboard),t)};var Fn=Mn,kn=function(e,t){this._rootView=e,this._offsetView=t};kn.prototype={update:function(e){var t=e.getViewMatrix();return F["c"].mul(t,this._offsetView,this._rootView),!0}};var Bn=function(e){var t=new J["default"];return t.setTextureSize(e.width,e.height),t.setMinFilter("LINEAR"),t.setMagFilter("LINEAR"),t},Un=function(){var e=["#ifdef GL_ES"," precision highp float;","#endif","varying vec2 vTexCoord0;","uniform sampler2D TextureLeft;","uniform sampler2D TextureRight;","void main() {"," if (vTexCoord0.x < 0.5)"," gl_FragColor = texture2D(TextureLeft, vec2(vTexCoord0.x * 2.0, vTexCoord0.y));"," else"," gl_FragColor = texture2D(TextureRight, vec2(vTexCoord0.x * 2.0 - 1.0, vTexCoord0.y));","}"].join("\n");return new K["a"](new Y["a"](Y["a"].VERTEX_SHADER,["attribute vec3 Vertex;","varying vec2 vTexCoord0;","void main(void) {"," gl_Position = vec4(Vertex * 2.0 - 1.0, 1.0);"," vTexCoord0 = Vertex.xy;","}","","#define SHADER_NAME VRpostProcessing",""].join("\n")),new Y["a"](Y["a"].FRAGMENT_SHADER,e))},Vn=function(e,t,r){var n=new Le["a"];n.setViewport(r),n.setRenderOrder(Le["a"].NESTED_RENDER,0),n.setReferenceFrame(Ue["a"].ABSOLUTE_RF),F["c"].ortho(n.getProjectionMatrix(),0,1,0,1,-5,5);var i=n.getOrCreateStateSet();return i.addUniform(Er["a"].createInt(0,"TextureLeft")),i.addUniform(Er["a"].createInt(1,"TextureRight")),i.setTextureAttributeAndModes(0,e),i.setTextureAttributeAndModes(1,t),i.setAttributeAndModes(Un()),n.addChild(at["a"].createTexturedFullScreenFakeQuadGeometry()),n},Gn=function(e,t){var r=new Le["a"];return r.setName("rtt camera"),r.setViewport(new Mr["a"](0,0,e.getWidth(),e.getHeight())),r.setProjectionMatrix(t),r.setClearColor(F["g"].fromValues(.3,.3,.3,0)),r.setRenderOrder(Le["a"].POST_RENDER,0),r.attachTexture(W["a"].COLOR_ATTACHMENT0,e),r.attachRenderBuffer(W["a"].DEPTH_ATTACHMENT,W["a"].DEPTH_COMPONENT16),r.setReferenceFrame(Ue["a"].ABSOLUTE_RF),r},zn={createScene:function(e,t,r,n,i){var a=n||new Ar["a"];return r.requestAnimationFrame((function(){var n=void 0!==i?i:1,o=r.getEyeParameters("left"),s=r.getEyeParameters("right"),u=new window.VRFrameData;r.getFrameData(u);var c=F["c"].fromTranslation(F["c"].create(),F["f"].fromValues(-n*o.offset[0],o.offset[1],o.offset[2])),l=F["c"].fromTranslation(F["c"].create(),F["f"].fromValues(-n*s.offset[0],s.offset[1],s.offset[2])),h={width:Math.max(o.renderWidth,s.renderWidth),height:Math.max(o.renderHeight,s.renderHeight)},d=Bn(h),f=Bn(h),_=Gn(d,u.leftProjectionMatrix),p=Gn(f,u.rightProjectionMatrix),g=e.getCamera().getViewMatrix();_.addUpdateCallback(new kn(g,c)),p.addUpdateCallback(new kn(g,l));var m=Vn(d,f,e.getCamera().getViewport());_.addChild(t),p.addChild(t),a.addChild(_),a.addChild(p),a.addChild(m)})),a}},jn=zn,Hn=n("e8f9"),Wn={};Wn.ComposerPostProcess=Lr,j["a"].objectMix(Wn,Br),Wn.DelayInterpolator=ye,Wn.DisplayNormalVisitor=Ur["a"],Wn.DisplayGeometryVisitor=Vr["a"],Wn.DisplayGraph=Gr["a"],Wn.IntersectFunctor=zr["a"],Wn.Intersector=jr["a"],Wn.IntersectionVisitor=nt["a"],Wn.LineSegmentIntersector=it["a"],Wn.LineSegmentIntersectFunctor=Hr["a"],Wn.NodeGizmo=dn,Wn.GizmoGeometry=an,Wn.WebVRCustom=Fn,Wn.PolytopeIntersector=Sn,Wn.PolytopeIntersectFunctor=mn,Wn.SphereIntersector=An,Wn.TangentSpaceGenerator=Rn,Wn.WebVR=jn,Wn.NO_LIMIT=Hn["a"].NO_LIMIT,Wn.LIMIT_ONE_PER_DRAWABLE=Hn["a"].LIMIT_ONE_PER_DRAWABLE,Wn.LIMIT_ONE=Hn["a"].LIMIT_ONE,Wn.POINT_PRIMITIVES=Hn["a"].POINT_PRIMITIVES,Wn.LINE_PRIMITIVES=Hn["a"].LINE_PRIMITIVES,Wn.TRIANGLE_PRIMITIVES=Hn["a"].TRIANGLE_PRIMITIVES,Wn.ALL_PRIMITIVES=Hn["a"].ALL_PRIMITIVES;var Xn=Wn,qn=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(e){var n;return Object(v["a"])(this,r),n=t.call(this,e.getViewerOSGJS()),n._appviewer=e,n._forcePicking=!1,n._event={},n}return Object(S["a"])(r,[{key:"setForcePicking",value:function(e){this._forcePicking=e}},{key:"clearEvent",value:function(){this._event={}}},{key:"onMouseUp",value:function(e){this.isEditing()&&(this._appviewer._frameManager.draw(),this._event.onFinished&&this._event.onFinished(t));var t=this._attachedNode;Xn.NodeGizmo.prototype.onMouseUp.call(this,e),t!==this._attachedNode&&this._appviewer._frameManager.draw(),this._forcePicking&&!this._attachedNode&&(this._attachedNode=t)}},{key:"onMouseMove",value:function(e){var t=this._hoverNode;Xn.NodeGizmo.prototype.onMouseMove.call(this,e),this.isEditing()&&(this._appviewer._frameManager.redrawShadow(),this._event.onChanged&&this._event.onChanged(this._attachedNode)),t!==this._hoverNode&&this._appviewer._frameManager.draw()}},{key:"attachToNode",value:function(e){return Object(yr["a"])(Object(Cr["a"])(r.prototype),"attachToNode",this).call(this,e),this._event={onChanged:null,onFinished:null,clear:this.clearEvent.bind(this)},this._event}}]),r}(Xn.NodeGizmo);j["a"].createPrototypeNode(qn,qn.prototype,"Editor","NodeGizmo");var Yn=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(){var e;return Object(v["a"])(this,r),e=t.call(this),e._minBox=new w["default"].BoundingBox,e._visitedBuffers={},e}return Object(S["a"])(r,[{key:"getPreciseBox",value:function(){return this._minBox}},{key:"apply",value:function(e){if(e instanceof w["default"].Transform)this.applyTransform(e);else{if(e instanceof w["default"].Geometry){var t=this._matrixStack.getLength()>0?this._matrixStack.back():w["default"].mat4.IDENTITY,r=e.getVertexAttributeList().Vertex,n=this._visitedBuffers[r.getInstanceID()];if(n&&w["default"].mat4.exactEquals(n.matrix,t))return;var i=e.computeTransformedVertices?e.computeTransformedVertices():r.getElements();this._visitedBuffers[r.getInstanceID()]={buffer:i,matrix:w["default"].mat4.copy(w["default"].mat4.create(),t)};for(var a=t[0],o=t[1],s=t[2],u=t[3],c=t[4],l=t[5],h=t[6],d=t[7],f=t[8],_=t[9],p=t[10],g=t[11],m=t[12],v=t[13],b=t[14],S=t[15],x=this._minBox.getMin(),T=this._minBox.getMax(),y=x[0],C=x[1],A=x[2],E=T[0],R=T[1],M=T[2],N=0,O=i.length;N<O;N+=3){var I=i[N],P=i[N+1],D=i[N+2],L=u*I+d*P+g*D+S||1,F=(a*I+c*P+f*D+m)/L,k=(o*I+l*P+_*D+v)/L,B=(s*I+h*P+p*D+b)/L;F<y&&(y=F),k<C&&(C=k),B<A&&(A=B),F>E&&(E=F),k>R&&(R=k),B>M&&(M=B)}x[0]=y,x[1]=C,x[2]=A,T[0]=E,T[1]=R,T[2]=M}this.traverse(e)}}}]),r}(w["default"].ComputeBoundsVisitor),Kn=Yn,Jn=function(){function e(){Object(v["a"])(this,e),this.modelboxWidthDisplacement=null,this.modelboxWithoutDisplacement=null,this._maxWorldDisplacement=0,this.BIAS_MIN=.9,this.BIAS_MAX=1.1}return Object(S["a"])(e,[{key:"updateMaxWorldDisplacement",value:function(e){e<=this._maxWorldDisplacement||(this._maxWorldDisplacement=e,this._updateModelBoxes())}},{key:"getModelBoxWithDisplacement",value:function(){return this.modelboxWidthDisplacement}},{key:"getModelBoxWithoutDisplacement",value:function(){return this.modelboxWithoutDisplacement}},{key:"_updateModelBoxes",value:function(){if(this.modelboxWidthDisplacement){var e=this.modelboxWidthDisplacement.getMin(),t=this.modelboxWidthDisplacement.getMax(),r=w["default"].vec3.fromValues(this._maxWorldDisplacement,this._maxWorldDisplacement,this._maxWorldDisplacement);w["default"].vec3.add(t,t,r),w["default"].vec3.sub(e,e,r)}}},{key:"computePreciseBox",value:function(e){var t=new Kn;e.accept(t),this.modelboxWidthDisplacement=t.getPreciseBox(),this.modelboxWithoutDisplacement=(new w["default"].BoundingBox).copy(this.modelboxWidthDisplacement),this._updateModelBoxes()}},{key:"getMaxDistanceFromOrigin",value:function(){var e=w["default"].vec3.length(this.modelboxWithoutDisplacement.getMin()),t=w["default"].vec3.length(this.modelboxWithoutDisplacement.getMax());return Math.max(e,t)}}]),e}(),Zn=Jn,Qn=function(){function e(){Object(v["a"])(this,e),this._shaderCache={}}return Object(S["a"])(e,[{key:"getOrCreateShader",value:function(e,t,r,n,i){var a="";i&&(a=i.toString());var o=r+a,s=this._shaderCache[o];return s||(s=this._createShader(e,t,r,n,i),this._shaderCache[o]=s),s}},{key:"_createShader",value:function(e,t,r,n,i){if(n="#define SHADER_NAME "+n+"\n",i)if(Array.isArray(i))for(var a=0;a<i.length;a++)n+="#define "+i[a]+"\n";else n+="#define "+i+"\n";var o={};return o[r+"-vert"]=n+e,o[r+"-frag"]=n+t,Nr["a"].addShaders(o),new w["default"].Program(new w["default"].Shader(w["default"].Shader.VERTEX_SHADER,Nr["a"].getShader(r+"-vert")),new w["default"].Shader(w["default"].Shader.FRAGMENT_SHADER,Nr["a"].getShader(r+"-frag")))}},{key:"clearCache",value:function(){this._shaderCache={}}}]),e}(),$n=new Qn,ei=$n,ti=(n("65ea"),n("b942")),ri=n.n(ti),ni="attribute vec3 Vertex;\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\n\nvoid main(void) {\n gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(Vertex, 1.0);\n}\n",ii="uniform vec4 uColor;void main(void) {gl_FragColor = vec4(uColor.xyz * uColor.a, uColor.a);}",ai="attribute vec3 Vertex;\nattribute vec4 Color;\nvarying vec4 vColor;\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\n\nvoid main(void) {\n vColor = Color;\n gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(Vertex, 1.0);\n}\n",oi="uniform vec4 uColor;\nvarying vec4 vColor;\n\nvoid main(void) {\n gl_FragColor = vec4( vec3(vColor) * uColor.a, uColor.a);\n}\n",si="\n attribute vec3 Vertex;\n attribute vec2 TexCoord0; \n varying vec2 vTexCoord0;\n uniform mat4 uModelViewMatrix;\n uniform mat4 uProjectionMatrix;\n void main(void) {\n vTexCoord0 = TexCoord0;\n gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(Vertex, 1.0);\n }\n",ui="\n varying vec2 vTexCoord0;\n uniform sampler2D uTexture;\n void main(void) {\n vec4 tex = texture2D(uTexture, vTexCoord0);\n gl_FragColor = tex;\n }\n",ci=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(){var e;Object(v["a"])(this,r),e=t.call(this),e._timeGrid=0;var n=w["default"].Uniform.createFloat4(w["default"].vec4.fromValues(.5,.5,.5,1),"uColor"),i=e.getOrCreateStateSet();return i.setAttributeAndModes(Sr.DEPTH_LEQUAL_WRITE),i.setAttributeAndModes(Sr.BLEND_SUBSTRACTIVE),i.setRenderBinDetails(br.GRID,"RenderBin"),i.addUniform(n),e._grid=w["default"].createGridGeometry(-1e3,-1e3,-5,2e3,0,0,0,2e3,0,19,19),e._axis=w["default"].createAxisGeometry(100),e._plane=w["default"].createTexturedQuadGeometry(-600,-600,-1,1200,0,0,0,1200,0),e.addChild(e._grid),e.addChild(e._axis),e.addChild(e._plane),e._grid.getOrCreateStateSet().setAttributeAndModes(ei.getOrCreateShader(ni,ii,"orientation-grid","Grid")),e._axis.getOrCreateStateSet().setAttributeAndModes(ei.getOrCreateShader(ai,oi,"orientation-axis","OrientationAxis")),e._invalidateNodeBound(e._grid),e._invalidateNodeBound(e._axis),e._invalidateNodeBound(Object(y["a"])(e)),e.setEnable(!1),e}return Object(S["a"])(r,[{key:"setEnable",value:function(e){if(e){if(!this._texture){this._texture=new w["default"].Texture,this._texture.setName("TextureGrid");var t=new Image;t.crossOrigin="Anonymous",t.src=ri.a,t.onload=function(){this._texture.setImage(t),this._texture.setTextureSize(t.width,t.height),this._texture.setMinFilter(w["default"].Texture.LINEAR_MIPMAP_LINEAR),this._texture.setMagFilter(w["default"].Texture.LINEAR)}.bind(this);var r=this._plane.getOrCreateStateSet();r.addUniform(w["default"].Uniform.createInt(1,"uTexture")),r.setTextureAttributeAndModes(1,this._texture),r.setAttributeAndModes(ei.getOrCreateShader(si,ui,"textured-plane","TexturePLane"))}this.setNodeMask(Tr.NO_PICK_NO_SHADOW)}else this.setNodeMask(0)}},{key:"_invalidateNodeBound",value:function(e){e.dirtyBound(),e.getBoundingBox().init(),e.getBoundingSphere().init()}}]),r}(Be["a"]),li=function(){function e(t){Object(v["a"])(this,e),this._app=t,this._viewerOSGJS=t.getViewerOSGJS(),this._urlOptions=t.options||{},this._features=t.getFeatures(),this._canvas=t.getCanvas(),this._nodeGizmo=null,this._nodeGrid=null}return Object(S["a"])(e,[{key:"getFeatures",value:function(){return this._features}},{key:"getCanvas",value:function(){return this._canvas}},{key:"getApp",value:function(){return this._app}},{key:"getViewerOSGJS",value:function(){return this._viewerOSGJS}},{key:"getRootModel",value:function(){return this._app.getRootModel()}},{key:"getWorldNode",value:function(){return this._features.autospin.getNode()}},{key:"getTextureDepth",value:function(){return this._features.postProcess.getCamera()._textureDepth}},{key:"getViewport3d",value:function(){return this._features.postProcess.getCamera().getViewport()}},{key:"getPixelRatio",value:function(){var e=this._app._canvas,t=e.width/e.clientWidth,r=e.height/e.clientHeight;return[t,r]}},{key:"getIconScaleFov",value:function(e){e||(e=this._viewerOSGJS.getCamera().getProjectionMatrix());var t=Math.sqrt(e[0]*e[0]+e[4]*e[4]+e[8]*e[8]);return.02*this.getViewport3d().width()*t/this.getPixelRatio()[0]}},{key:"getResourceManager",value:function(){return this._resourceManager||ResourceManager.instance}},{key:"getCurrentTabName",value:function(){if(this._urlOptions.widgetAPI)return this._urlOptions.widgetAPI.getTabbedWidget().get()}},{key:"getTargetAndEyeFocusFromBound",value:function(){}},{key:"focusOnBound",value:function(){}},{key:"focusOnTargetAndEye",value:function(){}},{key:"focusOnHomePosition",value:function(e){var t=this._features.camera;if(t&&t.getModel()){var r=t.getManipulator().getCurrentManipulator(),n=r.getHomeBoundingSphere(),i=n.center(),a=r.getEyePosition(w["default"].vec3.create());w["default"].vec3.sub(a,i,a),w["default"].vec3.normalize(a,a),w["default"].vec3.scale(a,a,r.getHomeDistance(n)),w["default"].vec3.sub(a,i,a),this.focusOnTargetAndEye(i,a,e)}}},{key:"focusOnSavedCamera",value:function(e){}},{key:"updateFocusOnAutoHit",value:function(){}},{key:"setInitialAnimation",value:function(){}},{key:"focusOnHit",value:function(e,t,r){}},{key:"_focusDof",value:function(e,t){}},{key:"onSingleClick",value:function(e){}},{key:"_singleClickOnInspector",value:function(e){}},{key:"onDoubleClick",value:function(e){}},{key:"preloadMaxBackground",value:function(){}},{key:"applyAutospinToCamera",value:function(e,t){}},{key:"getCameraWithoutAutospin",value:function(e,t){}},{key:"enableGizmo",value:function(e){this._nodeGizmo&&this._nodeGizmo.setTraversalMask(e?Tr.PICK:0)}},{key:"enableGrid",value:function(e){this._nodeGrid&&this._nodeGrid.setEnable(e)}},{key:"createWorldGrid",value:function(){return this._nodeGrid=new ci,this._nodeGrid.setName("WorldGrid"),this._nodeGrid}},{key:"createGizmoNode",value:function(){var e=new w["default"].Camera;e.setName("Camera-Gizmo"),e.getOrCreateStateSet().setRenderBinDetails(br.EDITOR_GIZMO,"RenderBin");var t=this._nodeGizmo=new qn(this._app);return t.setTraversalMask(Tr.PICK_GIZMO_LIGHT),e.addChild(t),t.attachToNode(null),e}},{key:"setManipulatorNode",value:function(e){this._features.camera?this._features.camera.getModel().set("node",e):this._viewerOSGJS.getManipulator().setNode(e)}},{key:"getNodeGizmo",value:function(){return this._nodeGizmo}},{key:"getNodeGrid",value:function(){return this._nodeGrid}},{key:"getBoundingSphere",value:function(){return this._boundingSphere}},{key:"initializePreciseBoundManager",value:function(e){var t=new Zn;t.computePreciseBox(e);var r=t.getModelBoxWithDisplacement();e.getBoundingBox().copy(r);var n=e.getBoundingSphere();n.set(r.center(n.center()),r.radius()),this._boundingSphere=n}},{key:"initGraph",value:function(e){var t=this._features,r=new w["default"].Node;r.getOrCreateStateSet().setAttributeAndModes(Sr.CULL_DISABLE),r.setName("FeatureManager - Root");var n=t.orientation,i=t.autospin,a=t.outline,o=t.ground,s=t.environment,u=t.lighting,c=t.camera,l=t.sound,h=t.hotspot,d=t.postProcess,f=t.webVR,_=t.ARKit,p=t.inspector,g=u.getNodeShadow(),m=r;d&&(r.addChild(d.getNodeIn()),m=d.getNodeOut()),m.addChild(this.createGizmoNode()),m.addChild(this.createWorldGrid()),m.addChild(g),m=g,t=[c,s,u,l,f,h,p,a,i,_,o,n];for(var v=0;v<t.length;++v){var b=t[v];if(b){var S=b.getNodeIn?b.getNodeIn():b.getNode(),x=b.getNodeOut?b.getNodeOut():b.getNode();m.addChild(S),m=x}}return m.addChild(e),r}},{key:"addGlobalUniforms",value:function(){var e=this._features.postProcess.getNodeIn().getOrCreateStateSet();for(var t in this._app.globalUniform)e.addUniform(this._app.globalUniform[t])}},{key:"finished",value:function(e){var t=this._features,r=this.getRootModel();r.setNodeMask(Tr.PICK_GEOMETRY_SHADOW),r.setName("Scene - RootModel"),this._app.nodeRootModel=r;var n=this._viewerOSGJS.getCamera(),i=this.initGraph(r);e.addChild(i),this.preloadMaxBackground();var a=t.lighting,o=t.environment;return o&&o.getNode().init(n,a.getNodeShadow()),this._app._canvasPixelRatio.init(this._canvas,this._viewerOSGJS.getCanvasPixelRatio()),this.focusOnSavedCamera(),this._features.camera&&this._features.camera.getModel().saveCameraPosition(),this._app._featureEventManager.initGlobalClickEvents(this,this._canvas),this._viewerOSGJS.getInputManager().setEnable("global_click_events",!0),this.addGlobalUniforms(),this._app.drawFrame(),this.initializePreciseBoundManager(r),t.lighting&&t.lighting.getModel().set("forceShadowRedraw",!0),this._app.drawFrame(),t.lighting&&t.lighting.getModel().set("forceShadowRedraw",!1),window.addEventListener("beforeunload",this.onBeforeUnload.bind(this)),i}},{key:"_registerCollection",value:function(){}},{key:"registerOptionsJSON",value:function(){}},{key:"getUnsavedChanges",value:function(){}},{key:"getUnsavedMessage",value:function(){}},{key:"onBeforeUnload",value:function(){}},{key:"_hashChanged",value:function(){}},{key:"getShadowForcedUpdate",value:function(){return!!M.shadow&&(!!this._app._frameManager.getShadowForcedUpdate()||!!this._app.getSuperSample().isEnabled()||!!this._features.lighting.getModel().get("forceShadowRedraw"))}}]),e}(),hi=(n("bf19"),n("ab5c")),di={"三点光源":[{type:"DIRECTION",enable:!0,matrix:w["default"].mat4.fromValues(-.9815804500275482,.1909922167095499,-.004668327333101102,0,-.13044442805044293,-.6878553985005321,-.7140302528214524,0,-.13958535494209104,-.7002691796088462,.700099282084794,0,0,0,0,1),color:w["default"].vec3.fromValues(1,1,1),intensity:1},{type:"DIRECTION",enable:!0,matrix:w["default"].mat4.fromValues(.7755211495104662,-.0666602860002539,.6277924441503967,0,.2690483737361956,.9344846523281437,-.233133882464682,0,-.5711216326246741,.3497067926613838,.7426474533145686,0,0,0,0,1),color:w["default"].vec3.fromValues(1,1,1),intensity:1},{type:"DIRECTION",enable:!0,matrix:w["default"].mat4.fromValues(.6903299131022926,-.7076363669144057,-.15064986988498263,0,-.011089698239978026,.19785137301620165,-.9801692980238416,0,.7234097246160907,.6783108479272498,.12873524736872857,0,0,0,0,1),color:w["default"].vec3.fromValues(1,1,1),intensity:1}],"三点顶部":[{type:"DIRECTION",enable:!0,matrix:w["default"].mat4.fromValues(.9997395789367833,.0037284998571004493,-.02251383121813605,0,-.003172416108909601,.9996902441347245,.024685047253076783,0,.02259889562202194,-.024607195505995896,.9994417320914686,0,0,0,0,1),color:w["default"].vec3.fromValues(1,1,1),intensity:1},{type:"DIRECTION",enable:!0,matrix:w["default"].mat4.fromValues(-.03668489915909917,.6173399031571284,-.7858407358642296,0,-.3405482968780687,-.7470238271733634,-.5709485608430127,0,-.9395110833125567,.24667153383641294,.23763854638433113,0,0,0,0,1),color:w["default"].vec3.fromValues(1,1,1),intensity:1},{type:"DIRECTION",enable:!0,matrix:w["default"].mat4.fromValues(.5165535747993983,-.2459126458378022,-.8201825254045677,0,-.40819067915319995,.771302442076031,-.48833688402577136,0,.7526970000035951,.5870430252243886,.29803978378898704,0,0,0,0,1),color:w["default"].vec3.fromValues(1,1,1),intensity:1}],"两侧光源":[{type:"DIRECTION",enable:!0,matrix:w["default"].mat4.fromValues(Math.SQRT1_2,0,Math.SQRT1_2,0,-0,1,0,0,-Math.SQRT1_2,-0,Math.SQRT1_2,0,0,0,0,1),color:w["default"].vec3.fromValues(1,1,1),intensity:1},{enable:!0,type:"DIRECTION",matrix:w["default"].mat4.fromValues(Math.SQRT1_2,0,-Math.SQRT1_2,0,0,1,0,0,Math.SQRT1_2,0,Math.SQRT1_2,0,0,0,0,1),color:w["default"].vec3.fromValues(1,1,1),intensity:1},{type:"NONE",enable:!0}],"头顶光":[{type:"DIRECTION",enable:!0,matrix:w["default"].mat4.fromValues(.9997395789367833,.0037284998571004493,-.02251383121813605,0,-.003172416108909601,.9996902441347245,.024685047253076783,0,.02259889562202194,-.024607195505995896,.9994417320914686,0,0,0,0,1),color:w["default"].vec3.fromValues(1,1,1),intensity:1},{type:"NONE",enable:!0},{type:"NONE",enable:!0}]},fi="#ifdef ICON\nattribute vec2 TexCoord0;\nvarying vec2 vTexCoord0;\n#endif\n\n#ifdef HEMI\nvarying vec3 vLocalVertex;\n#endif\n\nattribute vec3 Vertex;\n\nvarying vec4 vViewPos;\n\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\n\nvoid main(void) {\n#ifdef ICON\n vTexCoord0 = TexCoord0;\n#endif\n\n#ifdef HEMI\n vLocalVertex = Vertex;\n#endif\n\n vViewPos = uModelViewMatrix * vec4(Vertex.xyz, 1.0);\n gl_Position = uProjectionMatrix * vViewPos;\n}\n",_i='#pragma include "utils/functions.glsl"\n#pragma include "utils/decodeDepth.glsl"\n\n#ifdef HEMI\nuniform vec4 uGround;\nvarying vec3 vLocalVertex;\nuniform float uRadius;\n#endif\n\n#ifdef ICON\nuniform sampler2D uTextureIcon;\nvarying vec2 vTexCoord0;\nuniform int uEnable;\n#endif\n\nvarying vec4 vViewPos;\nuniform vec2 uNearFar;\nuniform sampler2D uTextureDepth;\nuniform vec2 uGlobalTexSize;\nuniform vec2 uGlobalTexRatio;\n\nuniform vec4 uColor;\n\nvoid main(void) {\n float distDepth = distanceToDepth(uTextureDepth, uGlobalTexRatio * gl_FragCoord.xy / uGlobalTexSize, vViewPos, uNearFar);\n float alpha = distDepth < 0.0 ? 1.0 : 0.1;\n\n // handles colors with values higher than 1\n vec3 normColor = uColor.rgb / max(max(1.0, uColor.r), max(uColor.g, uColor.b));\n\n#ifdef HEMI\n gl_FragColor = vec4(mix(uGround.rgb, normColor, vLocalVertex.z / uRadius), alpha);\n#endif\n\n#ifdef LINE\n gl_FragColor = vec4(normColor, alpha);\n#endif\n\n#ifdef ICON\n gl_FragColor = vec4(float(uEnable) * normColor, alpha) * texture2D(uTextureIcon, vTexCoord0);\n#endif\n\n gl_FragColor.rgb *= gl_FragColor.a;\n\n gl_FragColor.rgb = sRGBToLinear(gl_FragColor.rgb);\n}\n',pi={createIconGeometry:function(e){var t=w["default"].createTexturedQuadGeometry(-.5,-.5,0,1,0,0,0,1,0),r=t.getOrCreateStateSet();r.setTextureAttributeAndModes(1,e),r.addUniform(w["default"].Uniform.createInt(1,"uTextureIcon")),r.setAttributeAndModes(Sr.BLEND_SUBSTRACTIVE);var n=ei.getOrCreateShader(fi,_i,"icon","LightingIcon","ICON");return r.setAttributeAndModes(n),t.setLightType=function(t){r.setTextureAttributeAndModes(1,e)},t},createDirectionalGeometry:function(e){for(var t=void 0===e?-1:-e,r=t/15,n=2*Math.PI,i=new Float32Array(180),a=0;a<5;++a){var o=6*a,s=n*a/5;i[o]=i[o+3]=Math.cos(s)*r,i[o+1]=i[o+4]=Math.sin(s)*r,i[o+5]=t}var u=new w["default"].DrawArrays(w["default"].primitiveSet.LINES,0,30),c=new w["default"].Geometry;return c.getAttributes().Vertex=new w["default"].BufferArray(w["default"].BufferArray.ARRAY_BUFFER,i,3),c.getPrimitives().push(u),c.getOrCreateStateSet().setAttributeAndModes(ei.getOrCreateShader(fi,_i,"line","LightingLineGizmo","LINE")),c.getOrCreateStateSet().setAttributeAndModes(Sr.BLEND_SUBSTRACTIVE),c},createSpotGeometry:function(e){var t=void 0===e?-1:-e,r=50,n=2*Math.PI,i=new w["default"].Geometry,a=new Float32Array(300),o=i.getAttributes().Vertex=new w["default"].BufferArray(w["default"].BufferArray.ARRAY_BUFFER,a,3),s=0,u=new Uint16Array(r);for(s=0;s<r;++s)u[s]=2*s+1;var c=new w["default"].DrawElements(w["default"].primitiveSet.LINE_LOOP,new w["default"].BufferArray(w["default"].BufferArray.ELEMENT_ARRAY_BUFFER,u,1)),l=new Uint16Array(10);for(s=0;s<5;++s)l[2*s]=20*s,l[2*s+1]=20*s+1;var h=new w["default"].DrawElements(w["default"].primitiveSet.LINES,new w["default"].BufferArray(w["default"].BufferArray.ELEMENT_ARRAY_BUFFER,l,1));return i.getPrimitives().push(h,c),i.getOrCreateStateSet().setAttributeAndModes(za()),i.getOrCreateStateSet().setAttributeAndModes(ja),i.updateCone=function(e,u){var c=u?2*-u:t,l=Math.cos(e)*c,h=Math.sin(e)*c;for(s=0;s<r;++s){var d=6*s,f=n*s/r;a[d+3]=Math.cos(f)*h,a[d+4]=Math.sin(f)*h,a[d+5]=l}o.dirty(),i.dirtyBound()},i.updateCone(.1),i},createHemiGeometry:function(e){for(var t=void 0===e?-1:-e,r=50,n=new w["default"].Geometry,i=new Float32Array(450),a=Math.PI,o=150,s=0;s<r;++s){var u=3*s,c=a*s/49,l=Math.cos(c),h=Math.sin(c);i[u]=l*t,i[u+2]=-h*t,i[o+u+1]=l*t,i[o+u+2]=-h*t,c=2*a*s/49,i[300+u]=Math.cos(c)*t,i[300+u+1]=Math.sin(c)*t}n.getAttributes().Vertex=new w["default"].BufferArray(w["default"].BufferArray.ARRAY_BUFFER,i,3);var d=new w["default"].DrawArrays(w["default"].primitiveSet.LINE_STRIP,0,r),f=new w["default"].DrawArrays(w["default"].primitiveSet.LINE_STRIP,r,r),_=new w["default"].DrawArrays(w["default"].primitiveSet.LINE_STRIP,100,r);n.getPrimitives().push(d,f,_);var p=n.getOrCreateStateSet();return p.setAttributeAndModes(Ha("HEMI","LightingHemiGizmo")),p.setAttributeAndModes(ja),p.addUniform(w["default"].Uniform.createFloat(-t,"uRadius")),n},createPointGeometry:function(){var e=2*Math.PI,t=50,r=new w["default"].Geometry,n=new Float32Array(1350),i=r.getAttributes().Vertex=new w["default"].BufferArray(w["default"].BufferArray.ARRAY_BUFFER,n,3),a=new w["default"].DrawArrays(w["default"].primitiveSet.LINE_STRIP,0,t),o=new w["default"].DrawArrays(w["default"].primitiveSet.LINE_STRIP,t,t),s=new w["default"].DrawArrays(w["default"].primitiveSet.LINE_STRIP,100,t);return r.getPrimitives().push(a,o,s),r.getOrCreateStateSet().setAttributeAndModes(za()),r.getOrCreateStateSet().setAttributeAndModes(ja),r.updateRadius=function(a){for(var o=0;o<t;++o){var s=3*o,u=e*o/49;n[s]=n[150+s]=n[300+s+1]=Math.cos(u)*a,n[s+1]=n[150+s+2]=n[300+s+2]=Math.sin(u)*a}i.dirty(),r.dirtyBound()},r.updateRadius(1),r}},gi=new w["default"].Texture;gi.setTextureSize(1,1);var mi=gi,vi=(n("5cc6"),function(){var e={},t=new U.a((function(t,r){e.resolve=t,e.reject=r}));return t.resolve=e.resolve,t.reject=e.reject,t.promise=t,t}),bi=vi,Si=n("11e6"),xi=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(){var e;return Object(v["a"])(this,r),e=t.call(this),e._imageProxy=void 0,e}return Object(S["a"])(r,[{key:"getHash",value:function(){return"osgCustomTexture"}}]),r}(w["default"].TextureCubeMap);xi.dummyTexture=new w["default"].TextureCubeMap,xi.dummyTexture.setTextureSize(1,1);var Ti=xi,yi=null,Ci=function(){function e(){Object(v["a"])(this,e),this._cache={},this._enableCache=!0}return Object(S["a"])(e,[{key:"setCache",value:function(e){this._enableCache=e}},{key:"createTextureFromColor",value:function(e,t,r){var n="";if("number"===typeof e&&(n=""+e),"object"===Object(Oe["a"])(e)&&(n=e.reduce((function(e,t){return e+t}),n)),n+=t,this._enableCache){var i=this._cache[n];if(i)return i.texture}var a=e,o=new w["default"].Uint8Array(4);"number"===typeof a&&(a=[a]);var s=a.slice(0);3===s.length&&s.push(1),1===s.length&&(s.push(s[0]),s.push(s[0]),s.push(1)),s.forEach((function(e,r){o[r]=t?Math.floor(255*linear2Srgb(e)):Math.floor(255*e)}));var u=r;return u||(u=new w["default"].Texture),u.setTextureSize(1,1),u.setImage(o),this._enableCache&&(this._cache[n]={texture:u}),u}},{key:"dirty",value:function(){this._cache={}}},{key:"setOptions",value:function(e,t){t.setMinFilter(e.minFilter),t.setMagFilter(e.magFilter),t.setWrapT(e.wrapT),t.setWrapS(e.wrapS),e.minFilter===w["default"].Texture.LINEAR_MIPMAP_LINEAR&&e.anisotropy&&t.setMaxAnisotropy(16),t.setInternalFormat(e.internalFormat)}},{key:"loadImage",value:function(e,t){if(t.panoramaLUV||t.integrateBRDFLUV)return this.loadLUV(e,t);if(t.cubemapLUV)return this.loadCubemapLUV(e,t);var r=new w["default"].Image,n=new Image,i=bi();return n.crossOrigin="anonymous",n.addEventListener("load",(function(){i.resolve(r)})),n.onerror=function(){i.reject(r)},n.src=e,r.setImage(n),i}},{key:"loadLUV",value:function(e,t){var r=this;return Si["a"].requestURI(e,{responseType:"arraybuffer"}).then((function(e){var n,i=Math.sqrt(e.byteLength/4);n=t.integrateBRDFLUV?new Uint8Array(e):r.deinterleaveImage4(i,new Uint8Array(e),new Uint8Array(e.byteLength));var a=new w["default"].Image;a.setImage(n),a.setWidth(i),a.setHeight(i);var o=bi();return o.resolve(a),o}))}},{key:"loadCubemapLUV",value:function(e,t){var r=this;return Si["a"].requestURI(e,{responseType:"arraybuffer"}).then((function(e){for(var n=Math.log(t.size)/Math.LN2,i=0,a={},o=0;o<=n&&!(i>=e.byteLength);o++)for(var s=Math.pow(2,n-o),u=0;u<6;u++){a[w["default"].Texture.TEXTURE_CUBE_MAP_POSITIVE_X+u]||(a[w["default"].Texture.TEXTURE_CUBE_MAP_POSITIVE_X+u]=[]);var c=s*s*4,l=new Uint8Array(c);r.deinterleaveImage4(s,new Uint8Array(e,i,c),l);var h=new w["default"].Image;h.setImage(l),h.setWidth(s),h.setHeight(s),a[w["default"].Texture.TEXTURE_CUBE_MAP_POSITIVE_X+u].push(h),i+=c}var d=bi();return d.resolve(a),d}))}},{key:"deinterleaveImage4",value:function(e,t,r){for(var n=e*e,i=2*e*e,a=3*e*e,o=0,s=0;s<n;s++)r[o++]=t[s],r[o++]=t[s+n],r[o++]=t[s+i],r[o++]=t[s+a];return r}},{key:"getOrCreateTexture",value:function(t,r){var n,i=t+e.getSortedKeyValueString(r);if(this._enableCache){var a=this._cache[i];if(a)return a}n=r.cubemap?new Ti:new w["default"].Texture,n.setTextureSize(1,1),this.setOptions(r,n);var o=bi();this.loadImage(t,r).then((function(e){if(r.cubemap){for(var t=0;t<6;t++){var i=w["default"].Texture.TEXTURE_CUBE_MAP_POSITIVE_X+t;n.setImage(i,e[i],"RGBA")}o.resolve(n)}else n.setImage(e),o.resolve(n)}));var s={promise:o,texture:n};return this._enableCache&&(this._cache[i]=s),s}}],[{key:"getInstance",value:function(){return null===yi&&(yi=new e),yi}},{key:"getSortedKeyValueString",value:function(e){var t=[];for(var r in e){var n=e[r];n&&t.push(r)}t.sort();for(var i="",a=0;a<t.length;a++)r=t[a],i+=r+e[r];return i}}]),e}(),Ai=n("d110"),Ei=n.n(Ai),Ri=function(e,t,r,n){t.attributeType=n,j["a"].objectLibraryClass(t,r,n),j["a"].setTypeID(e),t.attributeTypeId=j["a"].getOrCreateStateAttributeTypeId(e)},Mi=Ri,wi=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(e){return Object(v["a"])(this,r),t.call(this,e)}return Object(S["a"])(r,[{key:"isDirectionLight",value:function(){return 0===this._position[3]&&(-1===this._ground[3]||0===this._ground[3])}}]),r}(w["default"].Light);Mi(wi,wi.prototype,"osgEditor","EditorLight"),wi.DIRECTION=w["default"].Light.DIRECTION,wi.SPOT=w["default"].Light.SPOT,wi.POINT=w["default"].Light.POINT,wi.HEMI=w["default"].Light.HEMI;var Ni=w["default"].vec3.create();w["default"].LightSource.prototype.computeBoundingSphere=function(e){if(w["default"].Node.prototype.computeBoundingSphere.call(this,e),!e.valid())return e;if(void 0!==this._light&&this._referenceFrame===w["default"].Transform.RELATIVE_RF){var t=this._light.getPosition();0!==t[3]&&e.expandByVec3(w["default"].vec3.scale(Ni,t,1/t[3]))}return e};var Oi=wi,Ii=n("123d"),Pi=function(e,t){Ii["a"].call(this),this._enable=!e,this._shadowReceiveAttribute=t,this._dirtyHash=!0,this._hash=""};j["a"].createPrototypeStateAttribute(Pi,j["a"].objectInherit(Ii["a"].prototype,{attributeType:"ShadowCast",cloneType:function(){return new Pi(!0)},setReceiveAttribute:function(e){this._shadowReceiveAttribute=e},getReceiveAttribute:function(){return this._shadowReceiveAttribute},getDefines:function(){return this._shadowReceiveAttribute.getDefines()},_computeInternalHash:function(){return"ShadowCast"+this._enable+this._shadowReceiveAttribute.getPrecision()},getHash:function(){var e=!1;return this._shadowReceiveAttribute&&this._shadowReceiveAttribute._dirtyHash&&(this._receiveAttributeDirty=!0),this._dirtyHash||e?(this._hash=this._computeInternalHash(),this._dirtyHash=!1,this._hash):this._hash},isEnabled:function(){return this._enable}}),"osgShadow","ShadowCastAttribute");var Di=Pi,Li=n("4fd1"),Fi=n("8155"),ki=n("875b"),Bi=n("3769"),Ui=function(e){Wr["a"].call(this),this._noCastMask=e,this._nodeList=[]};j["a"].createPrototypeObject(Ui,j["a"].objectInherit(Wr["a"].prototype,{reset:function(){this._nodeList=[]},removeNodeFromCasting:function(e){var t=e.getNodeMask();-1===t?(t=this._noCastMask,e.setNodeMask(t),this._nodeList.push(e)):0!==(t&~this._noCastMask)&&(e.setNodeMask(t|this._noCastMask),this._nodeList.push(e))},apply:function(e){var t=e.getStateSet();if(t){var r=t.getAttribute("BlendFunc");if(void 0!==r&&r.getSource()!==De["a"].DISABLE){var n=t.getAttribute("Depth");if(n&&(n.getFunc()===ke["a"].DISABLE||!1===n.getWriteMask()))return void this.removeNodeFromCasting(e)}}e.getTypeID()!==ki["a"].typeID&&e.getTypeID()!==Bi["a"].typeID?e.getTypeID()===Le["a"].typeID&&e.isRenderToTextureCamera()?this.removeNodeFromCasting(e):this.traverse(e):this.removeNodeFromCasting(e)},setNoCastMask:function(e){this._noCastMask=e},restore:function(){for(var e=0,t=this._nodeList.length;e<t;e++){var r=this._nodeList[e],n=r.getNodeMask();n===this._noCastMask?r.setNodeMask(-1):r.setNodeMask(n&~this._noCastMask)}}}),"osgShadow","ShadowCasterVisitor");var Vi=Ui,Gi=n("1ca0"),zi=n("02b4"),ji=function(){Wr["a"].call(this,Wr["a"].TRAVERSE_ALL_CHILDREN),this._pooledMatrix=new Gi["a"](F["c"].create),this._matrixStack=new zi["a"],this._matrixStack.push(F["c"].IDENTITY),this._bb=new ot["a"],this._bs=new Z["a"]};j["a"].createPrototypeObject(ji,j["a"].objectInherit(Wr["a"].prototype,{reset:function(e,t,r,n,i){this.setTraversalMask(e),this._cameraFrustum=r,this._lightFrustum=i,this.getCameraPlaneMaskForLightNear(t,r,n?6:4),this._pooledMatrix.reset(),this._matrixStack.reset(),this._matrixStack.push(F["c"].IDENTITY),this._bb.init()},getBoundingBox:function(){return this._bb},getCameraPlaneMaskForLightNear:function(e,t,r){var n,i=1,a=15;for(n=0;n<r;++n)a=a<<1|1;var o=t.getPlanes();for(n=0;n<r;++n)_n["a"].distanceToPlane(o[n],e)<0&&(a^=i),i<<=1;return this._cameraPlaneMaskedByLightNear=a,t.setResultMask(a),t.pushCurrentMask(a),a},applyTransform:function(e){var t=this._pooledMatrix.getOrCreateObject();F["c"].copy(t,this._matrixStack.back()),e.computeLocalToWorldMatrix(t,this);var r=this._bs;e.getBound().transformMat4(this._bs,t),(0===this._cameraFrustum.getCurrentMask()||this._cameraFrustum.containsBoundingSphere(r))&&(0===this._lightFrustum.getCurrentMask()||this._lightFrustum.containsBoundingSphere(r))&&(this._cameraFrustum.pushCurrentMask(),this._lightFrustum.pushCurrentMask(),this.pushMatrix(t),this.traverse(e),this._cameraFrustum.popCurrentMask(),this._lightFrustum.popCurrentMask(),this.popMatrix())},applyBoundingBox:function(){var e=new ot["a"];return function(t){var r=this._matrixStack.back();F["c"].exactEquals(r,F["c"].IDENTITY)?this._bb.expandByBoundingBox(t):t.valid()&&(t.transformMat4(e,r),this._bb.expandByBoundingBox(e))}}(),apply:function(e){var t=e.getTypeID();if(e instanceof Be["a"])this.applyTransform(e);else if(t!==Ve["a"].getTypeID())t===Le["a"].getTypeID()||ki["a"].getTypeID(),this.traverse(e);else{var r=this._bs;if(e.getBound().transformMat4(r,this._matrixStack.back()),0!==this._cameraFrustum.getCurrentMask()&&!this._cameraFrustum.containsBoundingSphere(r))return;if(0!==this._lightFrustum.getCurrentMask()&&!this._lightFrustum.containsBoundingSphere(r))return;this.applyBoundingBox(e.getBoundingBox())}},pushMatrix:function(e){this._matrixStack.push(e)},popMatrix:function(){this._matrixStack.pop()}}),"osgShadow","ComputeMultiFrustumBoundsVisitor");var Hi=ji,Wi=n("f3dc"),Xi=n("0fd6"),qi=function(e,t){Ii["a"].call(this),this._lightNumber=e,this._bias=.001,this._normalBias=void 0,this._precision="UNSIGNED_BYTE",this._kernelSizePCF=void 0,this._fakePCF=!0,this._jitterOffset="none",this._enable=!t,this._isAtlasTexture=!1,this._dirtyHash=!0,this._hash=""};qi.uniforms={},j["a"].createPrototypeStateAttribute(qi,j["a"].objectInherit(Ii["a"].prototype,{attributeType:"ShadowReceive",cloneType:function(){return new qi(this._lightNumber,!0)},getTypeMember:function(){return this.attributeType+this.getLightNumber()},getLightNumber:function(){return this._lightNumber},getUniformName:function(e){var t=this.getType()+this.getLightNumber().toString();return"u"+t+"_"+e},getAtlas:function(){return this._isAtlasTexture},setAtlas:function(e){this._isAtlasTexture=e},setBias:function(e){this._bias=e},getBias:function(){return this._bias},setNormalBias:function(e){this._normalBias=e},getNormalBias:function(){return this._normalBias},setJitterOffset:function(e){this._jitterOffset=e},getJitterOffset:function(){return this._jitterOffset},getKernelSizePCF:function(){return this._kernelSizePCF},setKernelSizePCF:function(e){this._kernelSizePCF=e,this._dirtyHash=!0},setPrecision:function(e){this._precision=e,this._dirtyHash=!0},getPrecision:function(){return this._precision},setLightNumber:function(e){this._lightNumber=e,this._dirtyHash=!0},getOrCreateUniforms:function(){var e=qi,t=this.getTypeMember();return e.uniforms[t]||(e.uniforms[t]={bias:Er["a"].createFloat(this.getUniformName("bias")),normalBias:Er["a"].createFloat(this.getUniformName("normalBias"))}),e.uniforms[t]},getDefines:function(){var e=[],t=this.getKernelSizePCF();switch(t){case"4Tap(16texFetch)":e.push("#define _PCFx4");break;case"9Tap(36texFetch)":e.push("#define _PCFx9");break;case"16Tap(64texFetch)":e.push("#define _PCFx25");break;default:case"1Tap(4texFetch)":e.push("#define _PCFx1");break}return"UNSIGNED_BYTE"!==this.getPrecision()&&e.push("#define _FLOATTEX"),this.getAtlas()&&e.push("#define _ATLAS_SHADOW"),this.getNormalBias()&&e.push("#define _NORMAL_OFFSET"),"none"!==this.getJitterOffset()&&e.push("#define _JITTER_OFFSET"),e},apply:function(){if(this._enable){var e=this.getOrCreateUniforms();e.normalBias.setFloat(this._normalBias),e.bias.setFloat(this._bias)}},isEnabled:function(){return this._enable},getHash:function(){return this._dirtyHash?(this._hash=this._computeInternalHash(),this._dirtyHash=!1,this._hash):this._hash},_computeInternalHash:function(){return this.getTypeMember()+"_"+this.getKernelSizePCF()}}),"osgShadow","ShadowReceiveAttribute");var Yi=qi,Ki=n("40fc"),Ji=function(){Ki["a"].call(this),this._shadowedScene=void 0,this._dirty=!1,this._continuousUpdate=!0,this._needRedraw=!0};j["a"].createPrototypeObject(Ji,j["a"].objectInherit(Ki["a"].prototype,{dirty:function(){this._dirty=!0},getShadowedScene:function(){return this._shadowedScene},setContinuousUpdate:function(e){this._continuousUpdate=e},isContinuousUpdate:function(){return this._continuousUpdate},needRedraw:function(){return this._needRedraw},requestRedraw:function(){this._needRedraw=!0},setShadowedScene:function(e){this._shadowedScene=e},init:function(){L["a"].log("No ShadowTechnique activated: normal rendering activated")},valid:function(){return!1},updateShadowTechnique:function(){},cullShadowCasting:function(){},cleanSceneGraph:function(){L["a"].log("No ShadowTechnique activated: normal rendering activated")}}),"osgShadow","ShadowTechnique");var Zi=Ji,Qi=function(){J["default"].call(this),this._uniforms={},this._mapSize=F["g"].create(),this._renderSize=F["e"].create(),this._lightNumber=-1,this._dirtyHash=!0,this._hash=""};Qi.uniforms={},j["a"].createPrototypeStateAttribute(Qi,j["a"].objectInherit(J["default"].prototype,{cloneType:function(){return new Qi},invalidate:function(){J["default"].prototype.invalidate.call(this),this.dirty()},hasLightNumber:function(e){return this._lightNumber===e},setLightNumber:function(e){this._lightNumber=e,this._dirtyHash=!0},getLightNumber:function(){return this._lightNumber},getUniformName:function(e){var t="Shadow_"+this.getType()+this._lightNumber.toString();return"u"+t+"_"+e},setInternalFormatType:function(e){J["default"].prototype.setInternalFormatType.call(this,e),this._dirtyHash=!0},getOrCreateUniforms:function(e){var t=Qi;if(L["a"].assert(void 0!==e),L["a"].assert(-1!==this._lightNumber),void 0!==t.uniforms[e])return t.uniforms[e];var r=t.uniforms[e]={ViewRight:Er["a"].createFloat4(this.getUniformName("viewRight")),ViewUp:Er["a"].createFloat4(this.getUniformName("viewUp")),ViewLook:Er["a"].createFloat4(this.getUniformName("viewLook")),Projection:Er["a"].createFloat3(this.getUniformName("projection")),DepthRange:Er["a"].createFloat2(this.getUniformName("depthRange")),MapSize:Er["a"].createFloat4(this.getUniformName("mapSize")),RenderSize:Er["a"].createFloat2(this.getUniformName("renderSize"))},n="Texture"+e,i=Er["a"].createInt1(e,n);return r[n]=i,t.uniforms[e]},setViewMatrix:function(e){this._viewMatrix=e},setProjection:function(e){this._projection=e},setDepthRange:function(e){this._depthRange=e},setTextureSize:function(e,t){J["default"].prototype.setTextureSize.call(this,e,t),this.dirty(),this._mapSize[0]=e,this._mapSize[1]=t,this._mapSize[2]=1/e,this._mapSize[3]=1/t,this._renderSize[0]=1/e,this._renderSize[1]=1/t},_updateViewMatrixUniforms:function(e,t,r,n){var i,a=e;i=t.getInternalArray(),i[0]=a[0],i[1]=a[4],i[2]=a[8],i[3]=a[12],i=r.getInternalArray(),i[0]=a[1],i[1]=a[5],i[2]=a[9],i[3]=a[13],i=n.getInternalArray(),i[0]=a[2],i[1]=a[6],i[2]=a[10],i[3]=a[14]},apply:function(e,t){if(J["default"].prototype.apply.call(this,e,t),-1!==this._lightNumber){var r=this.getOrCreateUniforms(t);this._updateViewMatrixUniforms(this._viewMatrix,r.ViewRight,r.ViewUp,r.ViewLook),r.Projection.setFloat3(this._projection),r.DepthRange.setFloat2(this._depthRange),r.MapSize.setFloat4(this._mapSize),r.RenderSize.setFloat2(this._renderSize)}},getHash:function(){return this._dirtyHash?(this._hash=this._computeInternalHash(),this._dirtyHash=!1,this._hash):this._hash},_computeInternalHash:function(){return this.getTypeMember()+"_"+this._lightNumber+"_"+this._type}}),"osgShadow","ShadowTexture");var $i=Qi,ea=n("ae6b"),ta=function(e){this._shadowTechnique=e};j["a"].createPrototypeObject(ta,{cull:function(e,t){this._shadowTechnique.getShadowedScene().nodeTraverse(t);var r=t.getCurrentCullingSet(),n=t.getCurrentProjectionMatrix(),i=t.getComputedNear(),a=t.getComputedFar();return i===1/0&&a===-1/0?(this._shadowTechnique.markSceneAsNoShadow(),!1):(F["c"].getFrustumPlanes(r.getFrustum().getPlanes(),n,t.getCurrentModelViewMatrix(),!1),r.getFrustum().setupMask(6),this._shadowTechnique.setLightFrustum(r.getFrustum(),i,a),!1)}},"osgShadow","CameraCullCallback");var ra=function(e,t){Zi.call(this),this._projectionMatrix=F["c"].create(),this._projection=F["f"].create(),this._viewMatrix=F["c"].create(),this._lightNumberArrayIndex=-1,this._lightUp=F["f"].fromValues(0,0,1),this._light=e.light,this._cameraShadow=new Le["a"],this._cameraShadow.setCullCallback(new ta(this)),this._cameraShadow.setRenderOrder(Le["a"].PRE_RENDER,0),this._cameraShadow.setReferenceFrame(Ue["a"].ABSOLUTE_RF),this._cameraShadow.setClearColor(F["g"].fromValues(1,1,1,1)),t?this._texture=t:(this._texture=new $i,this._textureUnitBase=4,this._textureUnit=this._textureUnitBase,this._textureMagFilter=void 0,this._textureMinFilter=void 0),this._textureSize=256;var r=Er["a"].createFloat2("RenderSize");this._texelSizeUniform=Er["a"].createFloat1(1/this._textureSize,"texelSize"),this._renderSize=r.getInternalArray(),this._renderSize[0]=this._renderSize[1]=this._textureSize,this._receivingStateset=void 0,this._casterStateSet=new Rr["a"],this._casterStateSet.addUniform(Er["a"].createFloat1(0,"exponent0")),this._casterStateSet.addUniform(Er["a"].createFloat1(0,"exponent1")),this._casterStateSet.addUniform(Er["a"].createFloat1(.005,"bias")),this._casterStateSet.addUniform(this._texelSizeUniform),this._casterStateSet.addUniform(r),this._casterStateSet.setAttributeAndModes(new ke["a"](ke["a"].LESS),Ii["a"].ON|Ii["a"].OVERRIDE),this._casterStateSet.setAttributeAndModes(new De["a"],Ii["a"].ON|Ii["a"].OVERRIDE),this._shadowReceiveAttribute=new Yi(this._light.getLightNumber()),this._casterStateSet.setAttributeAndModes(this._shadowReceiveAttribute,Ii["a"].ON|Ii["a"].OVERRIDE),this._shadowCastShaderGeneratorName="ShadowCast";var n=.001,i=1e3,a=Er["a"].createFloat4("uShadowDepthRange");this._casterStateSet.addUniform(a),this._depthRange=a.getInternalArray(),this._depthRange[0]=n,this._depthRange[1]=i,this._worldLightPos=F["g"].create(),this._worldLightPos[3]=0,this._worldLightDir=F["g"].create(),this._worldLightDir[3]=1,this._castsShadowDrawTraversalMask=4294967295,this._castsShadowBoundsTraversalMask=4294967295,this._shaderProcessor=void 0,this._tmpVec=F["f"].create(),this._tmpVecBis=F["f"].create(),this._tmpVecTercio=F["f"].create(),this._tmpMatrix=F["c"].create(),e&&this.setShadowSettings(e),this._infiniteFrustum=!0;var o=new Di(!1,this._shadowReceiveAttribute);this._casterStateSet.setAttributeAndModes(o,Ii["a"].ON|Ii["a"].OVERRIDE),this._casterStateSet.setShaderGeneratorName(this._shadowCastShaderGeneratorName,Ii["a"].OVERRIDE|Ii["a"].ON),this._debug=!1};j["a"].createPrototypeObject(ra,j["a"].objectInherit(Zi.prototype,{getDepthRange:function(){return this._depthRange},setLightFrustum:function(e,t,r){this._lightFrustum=e,this._depthRange[0]=t,this._depthRange[1]=r,this.nearFarBounding(),this._debug&&(this._debugGeomFrustum.updateGeometry(this._projectionMatrix,this._depthRange),F["c"].invert(this._debugNodeFrustum.getMatrix(),this._viewMatrix))},getCamera:function(){return this._cameraShadow},getTexture:function(){return this._texture},isDirty:function(){return this._dirty},setTextureUnitBase:function(e){this._textureUnitBase=e,this._textureUnit=e},setShadowSettings:function(e){e&&(this._light=e.light,this._shadowCastShaderGeneratorName=e.getShadowCastShaderGeneratorName(),this.setCastsShadowDrawTraversalMask(e.castsShadowDrawTraversalMask),this.setCastsShadowBoundsTraversalMask(e.castsShadowBoundsTraversalMask),this.setLight(this._light),this.setTextureSize(e.textureSize),this.setTexturePrecision(e.textureType),this.setKernelSizePCF(e.kernelSizePCF),this.setBias(e.bias),this.setNormalBias(e.normalBias))},setCastsShadowDrawTraversalMask:function(e){this._castsShadowDrawTraversalMask=e},getCastsShadowDrawTraversalMask:function(){return this._castsDrawShadowTraversalMask},setCastsShadowBoundsTraversalMask:function(e){this._castsShadowBoundsTraversalMask=e},getCastsShadowBoundsTraversalMask:function(){return this._castsShadowBoundsTraversalMask},getNormalBias:function(){return this._shadowReceiveAttribute.getNormalBias()},setNormalBias:function(e){this._shadowReceiveAttribute.setNormalBias(e)},getJitterOffset:function(){return this._shadowReceiveAttribute.getJitterOffset()},setJitterOffset:function(e){this._shadowReceiveAttribute.setJitterOffset(e)},getBias:function(){return this._shadowReceiveAttribute.getBias()},setBias:function(e){this._shadowReceiveAttribute.setBias(e);var t=this._casterStateSet.getUniformList().bias.getUniform();t.setFloat(e)},getKernelSizePCF:function(){return this._shadowReceiveAttribute.getKernelSizePCF()},setKernelSizePCF:function(e){this._shadowReceiveAttribute.setKernelSizePCF(e)},setShadowedScene:function(e){Zi.prototype.setShadowedScene.call(this,e),this._receivingStateset=this._shadowedScene.getReceivingStateSet(),this.dirty()},checkLightNumber:function(){var e=this._light.getLightNumber();this._shadowReceiveAttribute.getLightNumber()!==e&&this._receivingStateset.getAttribute(this._shadowReceiveAttribute.getTypeMember())===this._shadowReceiveAttribute&&this._receivingStateset.removeAttribute(this._shadowReceiveAttribute.getTypeMember()),L["a"].assert(this._shadowReceiveAttribute.getTypeMember()===this._shadowReceiveAttribute.attributeType+e,"TypeMember isnt reflecting light number"+this._shadowReceiveAttribute.getTypeMember()+" !== "+this._shadowReceiveAttribute.attributeType+e),this._texture&&!this._texture.hasLightNumber(e)&&this._receivingStateset.getTextureAttribute(this._textureUnit,this._texture.getTypeMember())===this._texture&&this._receivingStateset.removeTextureAttribute(this._textureUnit,this._texture.getTypeMember())},_rebindFbo:function(){this._cameraShadow.detachAll(),this._cameraShadow.attachTexture(W["a"].COLOR_ATTACHMENT0,this._texture),this._cameraShadow.attachRenderBuffer(W["a"].DEPTH_ATTACHMENT,W["a"].DEPTH_COMPONENT16)},init:function(e,t,r){if(this._shadowedScene){this._needRedraw=!0,this.checkLightNumber();var n=this._light.getLightNumber();e?(this._texture=e,this._lightNumberArrayIndex=t,this._textureUnit=r,this._shadowReceiveAttribute.setAtlas(!0)):(this.initTexture(),this._rebindFbo(),this._textureUnit=this._textureUnitBase+n,this._texture.setLightNumber(n),this._texture.setName("ShadowTexture"+this._textureUnit),this._shadowReceiveAttribute.setAtlas(!1)),this._cameraShadow.setName("light_shadow_camera"+this._light.getName()),this._shadowReceiveAttribute.setLightNumber(n);var i=Ii["a"].OVERRIDE|Ii["a"].ON;this._receivingStateset.setAttributeAndModes(this._shadowReceiveAttribute,i),this._preventTextureBindingDuringShadowCasting(),this._casterStateSet.setTextureAttributeAndModes(this._textureUnit,J["default"].textureNull,Ii["a"].PROTECTED),this._receivingStateset.setTextureAttributeAndModes(this._textureUnit,this._texture,i),this._dirty=!1}},_preventTextureBindingDuringShadowCasting:function(){for(var e=Xi["a"].instance().getWebGLParameter("MAX_TEXTURE_IMAGE_UNITS"),t=0;t<e;t++)this._casterStateSet.setTextureAttributeAndModes(t,J["default"].textureNull,Ii["a"].OVERRIDE)},valid:function(){return!0},updateShadowTechnique:function(e,t,r){var n=this._cameraShadow,i=this._texture;if(n&&i){var a=n.getViewport();if(a||(a=new Mr["a"],n.setViewport(a)),t){var o=n.getScissor();o||(o=new ea["a"](t[0],t[1],t[2],t[3]),n.setScissor(o)),a.x()===t[0]&&a.y()===t[1]&&a.width()===t[2]&&a.height()===t[3]||(n.setFrameBufferObject(r),a.setViewport(t[0],t[1],t[2],t[3]),o.setScissor(t[0],t[1],t[2],t[3]))}else a.width()===i.getWidth()&&a.height()===i.getHeight()||(this._rebindFbo(),a.setViewport(0,0,i.getWidth(),i.getHeight()))}},updateShadowTechnic:function(){L["a"].log("ShadowMap.updateShadowTechnic() is deprecated, use updateShadowTechnique instead"),this.updateShadowTechnique()},setTextureFiltering:function(){var e,t=this.getTexturePrecision();switch(t){case"HALF_FLOAT":e=J["default"].HALF_FLOAT;break;case"FLOAT":e=J["default"].FLOAT;break;default:case"UNSIGNED_BYTE":e=J["default"].UNSIGNED_BYTE;break}this._texture.setInternalFormatType(e),this._texture.setMinFilter(J["default"].NEAREST),this._texture.setMagFilter(J["default"].NEAREST),this._textureMagFilter=J["default"].NEAREST,this._textureMinFilter=J["default"].NEAREST},initTexture:function(){var e;this._dirty&&(this._texture||(this._texture=new $i,this._textureUnit=this._textureUnitBase),this._texture.setTextureSize(this._textureSize,this._textureSize),this._texelSizeUniform.setFloat(1/this._textureSize),this._renderSize[0]=this._textureSize,this._renderSize[1]=this._textureSize,e=J["default"].RGBA,this.setTextureFiltering(),this._texture.setInternalFormat(e),this._texture.setWrapS(J["default"].CLAMP_TO_EDGE),this._texture.setWrapT(J["default"].CLAMP_TO_EDGE),this._texture.dirty())},setTexturePrecision:function(e){e!==this._shadowReceiveAttribute.getPrecision()&&(this._shadowReceiveAttribute.setPrecision(e),this.dirty())},getTexturePrecision:function(){return this._shadowReceiveAttribute.getPrecision()},setTextureSize:function(e){e!==this._textureSize&&(this._textureSize=e,this.dirty())},getCasterStateSet:function(){return this._casterStateSet},setLight:function(e){e&&e!==this._light&&(this._light=e,this.dirty())},getUp:function(e){return Math.abs(F["f"].dot(this._lightUp,e))>=1&&(1===this._lightUp[0]?(this._lightUp[0]=0,this._lightUp[1]=1,this._lightUp[2]=0):(this._lightUp[0]=1,this._lightUp[1]=0,this._lightUp[2]=0)),this._lightUp},nearFarBounding:function(){var e=this._depthRange[0],t=this._depthRange[1],r=ra.EPSILON;t<e-r?(this._emptyCasterScene=!0,t=1,e=r):e<r&&(e=r),this._depthRange[0]=e,this._depthRange[1]=t},makePerspectiveFromBoundingBox:function(e,t,r,n,i,a){var o=e.center(this._tmpVec),s=e.radius(),u=ra.EPSILON,c=u,l=1;this._radius=s;var h=F["f"].distance(o,r);h<=s?(c=u,l=h+s):(c=h-s,l=h+s),this._depthRange[0]=c,this._depthRange[1]=l,this.nearFarBounding();var d=this._depthRange[0]*Math.tan(t*Math.PI/180);d=d>s?s:d;var f=d,_=-f,p=d,g=-p,m=this.getUp(n);this._infiniteFrustum?F["c"].infiniteFrustum(a,g,p,_,f,this._depthRange[0]):F["c"].frustum(a,g,p,_,f,this._depthRange[0],this._depthRange[1]),this._projection[0]=this._projectionMatrix[0],this._projection[1]=this._projectionMatrix[5],this._projection[2]=0,F["c"].lookAtDirection(i,r,n,m)},makeOrthoFromBoundingBox:function(e,t,r,n){var i=e.center(this._tmpVecTercio),a=e.radius(),o=a+a,s=1e-4,u=o+1e-4,c=this._tmpVec;F["f"].scaleAndAdd(c,i,t,-o),s=a,u+=a;var l=.001;s<u*l&&(s=u*l);var h,d,f=this.getUp(t);F["c"].lookAtDirection(r,c,t,f),d=a,h=d,F["c"].ortho(n,-h,h,-d,d,s,u),this._projection[0]=h,this._projection[1]=d,this._projection[2]=1,this._depthRange[0]=s,this._depthRange[1]=u},aimShadowCastingCamera:function(e,t){var r=this._light;if(r){var n=this._cameraShadow,i=this._worldLightPos,a=this._worldLightDir;F["c"].copy(this._projectionMatrix,n.getProjectionMatrix()),F["c"].copy(this._viewMatrix,n.getViewMatrix());for(var o,s=this._projectionMatrix,u=this._viewMatrix,c=e.getCurrentRenderBin().getPositionedAttribute(),l=c.getArray(),h=0;h<c.getLength();h++){var d=l[h],f=d[1],_=d[0];if(f===r){o=_;break}}if(void 0===o)return L["a"].warn("light isnt inside children of shadowedScene Node"),void(this._emptyCasterScene=!0);var p=this._tmpMatrix;if(F["c"].invert(p,e.getCurrentModelViewMatrix()),this._light.isDirectionLight())F["g"].transformMat4(i,r.getPosition(),o),F["g"].transformMat4(i,i,p),F["f"].scale(i,i,-1),F["f"].normalize(i,i),this.makeOrthoFromBoundingBox(t,i,u,s),this._debug&&F["c"].invert(this._debugNodeFrustum.getMatrix(),u);else{F["c"].mul(this._tmpMatrix,p,o);var g=this._tmpMatrix;F["f"].transformMat4(i,r.getPosition(),g),g[12]=0,g[13]=0,g[14]=0,F["c"].invert(g,g),F["c"].transpose(g,g),F["f"].copy(a,r.getDirection()),F["g"].transformMat4(a,a,g),F["f"].normalize(a,a),this.makePerspectiveFromBoundingBox(t,r.getSpotCutoff(),i,a,u,s)}F["c"].copy(n.getProjectionMatrix(),this._projectionMatrix),F["c"].copy(n.getViewMatrix(),this._viewMatrix)}else this._emptyCasterScene=!0},frameShadowCastingFrustum:function(e){this._infiniteFrustum||Wi["a"].prototype.clampProjectionMatrix(this._projectionMatrix,this._depthRange[0],this._depthRange[1],e.getNearFarRatio(),this._depthRange);var t=this._cameraShadow;F["c"].copy(t.getProjectionMatrix(),this._projectionMatrix),F["c"].copy(t.getViewMatrix(),this._viewMatrix),this.setShadowUniformsReceive(!1)},setShadowUniformsReceive:function(e){if(e&&F["e"].set(this._depthRange,0,0),-1!==this._lightNumberArrayIndex){var t=this._light.getLightNumber();this._texture.setViewMatrix(t,this._viewMatrix),this._texture.setProjection(t,this._projection),this._texture.setDepthRange(t,this._depthRange)}else this._texture.setViewMatrix(this._viewMatrix),this._texture.setProjection(this._projection),this._texture.setDepthRange(this._depthRange)},markSceneAsNoShadow:function(){this.setShadowUniformsReceive(!0),this._needRedraw=!1},cullShadowCasting:function(e,t){if(this._debug){var r=t.getMin(),n=t.getMax();t.center(this._tmpVec);var i=this._debugNodeSceneCast.getMatrix();F["c"].fromScaling(i,[n[0]-r[0],n[1]-r[1],n[2]-r[2],1]),F["c"].setTranslation(i,this._tmpVec)}if(this._emptyCasterScene=!1,this.aimShadowCastingCamera(e,t),this._emptyCasterScene)this.markSceneAsNoShadow();else{var a=e.getTraversalMask();e.setTraversalMask(this._castsShadowDrawTraversalMask),e.pushStateSet(this._casterStateSet),this._cameraShadow.setEnableFrustumCulling(!0),this._cameraShadow.setComputeNearFar(!0),this._debug&&this._debugNode.accept(e),this._cameraShadow.accept(e),this.nearFarBounding(),this.frameShadowCastingFrustum(e),this._cameraShadow.setComputeNearFar(!1),e.popStateSet(),e.setTraversalMask(a),this._needRedraw=!1}},cleanReceivingStateSet:function(e){if(this._receivingStateset){if(this._receivingStateset.getAttribute(this._shadowReceiveAttribute.getTypeMember())===this._shadowReceiveAttribute&&this._receivingStateset.removeAttribute(this._shadowReceiveAttribute.getTypeMember()),e)return;this._texture&&this._receivingStateset.getTextureAttribute(this._textureUnit,this._texture.getTypeMember())===this._texture&&this._receivingStateset.removeTextureAttribute(this._textureUnit,this._texture.getTypeMember())}},cleanSceneGraph:function(e){this._needRedraw=!0,this.cleanReceivingStateSet(e),this._texture=void 0,this._shadowedScene=void 0},setDebug:function(e){e&&!this._debug&&(this._debugNode||(this._debugGeomFrustum=Br.createDebugFrustumGeometry(),this._debugGeomSceneCast=at["a"].createBoundingBoxGeometry(),this._debugGeomSceneCast.getPrimitives()[0].mode=Ge["a"].LINES,this._debugNode=new Be["a"],this._debugNodeFrustum=new Be["a"],this._debugNodeSceneCast=new Be["a"],this._debugNodeFrustum.addChild(this._debugGeomFrustum),this._debugNodeSceneCast.addChild(this._debugGeomSceneCast),this._debugNode.addChild(this._debugNodeFrustum),this._debugNode.addChild(this._debugNodeSceneCast))),this._debug=e},getDebug:function(){return this._debug},getLightNumber:function(){return this._light.getLightNumber()},getLight:function(){return this._light}}),"osgShadow","ShadowMap"),ra.EPSILON=.005;var na=ra,ia=function(){J["default"].call(this),this._uniforms={},this._lightNumberArray=[],this._viewMatrices=[],this._projection=[],this._depthRanges=[],this._mapSizes=[],this._renderSize=F["e"].create(),this._dirtyHash=!0,this._hash=""};ia.uniforms={},j["a"].createPrototypeStateAttribute(ia,j["a"].objectInherit(J["default"].prototype,{cloneType:function(){return new ia},getLightNumberArray:function(){return this._lightNumberArray},hasLightNumber:function(e){return-1!==this._lightNumberArray.indexOf(e)},setLightNumberArray:function(e){this._lightNumberArray=e,this._dirtyHash=!0},getUniformName:function(e,t){var r="Shadow_"+this.getType()+e.toString();return"u"+r+"_"+t},setInternalFormatType:function(e){J["default"].prototype.setInternalFormatType.call(this,e),this._dirtyHash=!0},createUniforms:function(e,t){t["ViewRight_"+e]=Er["a"].createFloat4(this.getUniformName(e,"viewRight")),t["ViewUp_"+e]=Er["a"].createFloat4(this.getUniformName(e,"viewUp")),t["ViewLook_"+e]=Er["a"].createFloat4(this.getUniformName(e,"viewLook")),t["Projection_"+e]=Er["a"].createFloat3(this.getUniformName(e,"projection")),t["DepthRange_"+e]=Er["a"].createFloat2(this.getUniformName(e,"depthRange")),t["MapSize_"+e]=Er["a"].createFloat4(this.getUniformName(e,"mapSize")),t["RenderSize_"+e]=t["RenderSize"]},getOrCreateUniforms:function(e){var t=ia;if(L["a"].assert(void 0!==e||0!==this._lightNumberArray.length),void 0!==t.uniforms[e])return t.uniforms[e];var r=t.uniforms[e]={},n=Er["a"].createFloat2(this.getUniformName(0,"renderSize"));r["RenderSize"]=n;for(var i=0,a=this._lightNumberArray.length;i<a;i++)this.createUniforms(this._lightNumberArray[i],r);var o="Texture"+e,s=Er["a"].createInt1(e,o);return r[o]=s,t.uniforms[e]},setViewMatrix:function(e,t){this._viewMatrices[e]=t},setProjection:function(e,t){this._projection[e]=t},setDepthRange:function(e,t){this._depthRanges[e]=t},setLightShadowMapSize:function(e,t){this._mapSizes[e]=t},apply:function(e,t){if(J["default"].prototype.apply.call(this,e,t),0!==this._lightNumberArray.length){for(var r=this.getOrCreateUniforms(t),n=0,i=this._lightNumberArray.length;n<i;n++){var a=this._lightNumberArray[n];r["ViewRight_"+a]||this.createUniforms(a,r),$i.prototype._updateViewMatrixUniforms.call(this,this._viewMatrices[a],r["ViewRight_"+a],r["ViewUp_"+a],r["ViewLook_"+a]),r["Projection_"+a].setFloat3(this._projection[a]),r["DepthRange_"+a].setFloat2(this._depthRanges[a]),r["MapSize_"+a].setFloat4(this._mapSizes[a])}r["RenderSize"].setFloat2(this._renderSize)}},setTextureSize:function(e,t){this._renderSize[0]=1/e,this._renderSize[1]=1/t,J["default"].prototype.setTextureSize.call(this,e,t),this.dirty()},_computeInternalHash:function(){for(var e=this.getTypeMember(),t=0,r=this._lightNumberArray.length;t<r;t++)e+="_"+this._lightNumberArray[t];return e+="_"+this._type,e},getHash:function(){return this._dirtyHash?(this._hash=this._computeInternalHash(),this._dirtyHash=!1,this._hash):this._hash}}),"osgShadow","ShadowTextureAtlas");var aa=ia,oa=function(e){this._lights=[],this._shadowMaps=[],this._viewportDimension=[],Zi.apply(this,arguments),this._shadowSettings=e,this._texture=new aa,this._textureUnitBase=4,this._textureUnit=this._textureUnitBase,this._textureMagFilter=void 0,this._textureMinFilter=void 0,this._textureSize=1024,this._shadowMapSize=256,this._receivingStateset=void 0,this._shaderProcessor=void 0,e&&(this.setShadowSettings(e),e.atlasSize&&(this._textureSize=e.atlasSize),e.textureSize&&(this._shadowMapSize=e.textureSize)),this._texelSizeUniform=Er["a"].createFloat1(1/this._textureSize,"texelSize");var t=Er["a"].createFloat2("RenderSize");this._renderSize=t.getInternalArray(),this._renderSize[0]=this._renderSize[1]=this._textureSize,this._numShadowWidth=this._textureSize/this._shadowMapSize,this._numShadowHeight=this._textureSize/this._shadowMapSize,this._cameraClear=new Le["a"],this._cameraClear.setName("shadowAtlasCameraClear"),this._cameraClear.setRenderOrder(Le["a"].PRE_RENDER,0),this._cameraClear.setClearColor(F["g"].fromValues(1,1,1,1)),this._cameraClear.setFrameBufferObject(new W["a"]),this._cameraClear.setClearMask(0)};j["a"].createPrototypeObject(oa,j["a"].objectInherit(Zi.prototype,{getTexture:function(){return this._texture},isDirty:function(e){if(void 0!==e)return this._shadowMaps[e].isDirty();for(var t=0,r=this._shadowMaps.length;t<r;t++)if(this._shadowMaps[t].isDirty())return!0;return!1},setTextureUnitBase:function(e){this._textureUnitBase=e,this._textureUnit=e;for(var t=0,r=this._shadowMaps.length;t<r;t++)this._shadowMaps[t].setTextureUnitBase(e)},setShadowSettings:function(e){if(e){this._shadowSettings=e;for(var t=0,r=this._shadowMaps.length;t<r;t++)this._shadowMaps[t].setShadowSettings(e);this.setTextureSize(e.textureSize),this.setTexturePrecision(e.textureType)}},setCastsShadowDrawTraversalMask:function(e){for(var t=0,r=this._shadowMaps.length;t<r;t++)this._shadowMaps[t].setCastsShadowDrawTraversalMask(e)},getCastsShadowDrawTraversalMask:function(e){return void 0!==e?this._shadowMaps[e].getCastsShadowDrawTraversalMask():0!==this._shadowMaps.length?this._shadowMaps[0].getCastsShadowDrawTraversalMask():void 0},setCastsShadowBoundsTraversalMask:function(e){for(var t=0,r=this._shadowMaps.length;t<r;t++)this._shadowMaps[t].setCastsShadowBoundsTraversalMask(e)},getCastsShadowBoundsTraversalMask:function(e){return void 0!==e?this._shadowMaps[e].getCastsShadowDrawTraversalMask():0!==this._shadowMaps.length?this._shadowMaps[0].getCastsShadowDrawTraversalMask():void 0},getNormalBias:function(e){return void 0!==e?this._shadowMaps[e].getNormalBias():0!==this._shadowMaps.length?this._shadowMaps[0].getNormalBias():void 0},setNormalBias:function(e){for(var t=0,r=this._shadowMaps.length;t<r;t++)this._shadowMaps[t].setNormalBias(e)},getBias:function(e){return void 0!==e?this._shadowMaps[e].getBias():0!==this._shadowMaps.length?this._shadowMaps[0].getBias():void 0},setBias:function(e){for(var t=0,r=this._shadowMaps.length;t<r;t++)this._shadowMaps[t].setBias(e)},getKernelSizePCF:function(e){return void 0!==e?this._shadowMaps[e].getKernelSizePCF():1!==this._shadowMaps.length?this._shadowMaps[0].getKernelSizePCF():void 0},setKernelSizePCF:function(e){for(var t=0,r=this._shadowMaps.length;t<r;t++)this._shadowMaps[t].setKernelSizePCF(e)},setShadowedScene:function(e){Zi.prototype.setShadowedScene.call(this,e),this._receivingStateset=this._shadowedScene.getReceivingStateSet();for(var t=0,r=this._shadowMaps.length;t<r;t++)this._shadowMaps[t].setShadowedScene(e)},setTexturePrecision:function(e){for(var t=0,r=this._shadowMaps.length;t<r;t++)this._shadowMaps[t].setTexturePrecision(e)},getTexturePrecision:function(e){return void 0!==e?this._shadowMaps[e].getTexturePrecision():1!==this._shadowMaps.length?this._shadowMaps[0].getTexturePrecision():void 0},setTextureSize:function(e){e!==this._textureSize&&(this._shadowMapSize=e,this._numShadowWidth=this._textureSize/this._shadowMapSize,this._numShadowHeight=this._textureSize/this._shadowMapSize,this.dirty())},getShadowMap:function(e){return this._shadowMaps[e]},addLight:function(e){if(!e||-1!==this._lights.indexOf(e))return L["a"].warn("no light or light already added"),-1;var t=this._lights.length;if(t!==this._numShadowWidth*this._numShadowHeight){this._lights.push(e),this._shadowSettings.setLight(e);var r=new na(this._shadowSettings,this._texture);return this._shadowMaps.push(r),this._shadowedScene&&r.setShadowedScene(this._shadowedScene),this.recomputeViewports(),r}L["a"].warn("can't allocate shadow for light "+e.getLightNumber()+" ShadowAtlas already full ")},init:function(){if(this._shadowedScene){this.initTexture();for(var e=[],t=0;t<this._lights.length;t++)e.push(this._lights[t].getLightNumber());this._texture.setLightNumberArray(e),this._textureUnit=this._textureUnitBase,this._texture.setName("ShadowTexture"+this._textureUnit);var r=Er["a"].createFloat2("RenderSize");this._texelSizeUniform=Er["a"].createFloat1(1/this._textureSize,"texelSize"),this._renderSize=r.getInternalArray(),this._renderSize[0]=this._renderSize[1]=this._textureSize,this.recomputeViewports();for(var n=0,i=this._shadowMaps.length;n<i;n++){var a=this._shadowMaps[n];this._shadowedScene||(this._shadowedScene=a.getShadowedScene(this._shadowedScene)),this._shadowedScene&&a.setShadowedScene(this._shadowedScene),a.init(this._texture,n,this._textureUnitBase)}}},recomputeViewports:function(){for(var e=this._shadowMaps.length,t=e>2?Math.sqrt(2*Math.ceil(e/2)):e,r=t,n=this._textureSize/r,i=this._textureSize/t,a=this._textureSize/n,o=this._textureSize/i,s=0;s<e;s++){var u=this._shadowMaps[s],c=n*(s%a),l=i*Math.floor(s/o);this._viewportDimension.length<=s?this._viewportDimension.push(F["g"].fromValues(c,l,n,i)):F["g"].set(this._viewportDimension[s],c,l,n,i),this._texture.setLightShadowMapSize(this._lights[s].getLightNumber(),this._viewportDimension[s]),u.dirty()}},valid:function(){return!0},updateCameraClear:function(){var e=this._cameraClear,t=this._texture;if(e&&t){var r=e.getViewport();r||(r=new Mr["a"],e.setViewport(r)),r.width()===t.getWidth()&&r.height()===t.getHeight()||(e.detachAll(),e.attachTexture(W["a"].COLOR_ATTACHMENT0,t),e.attachRenderBuffer(W["a"].DEPTH_ATTACHMENT,W["a"].DEPTH_COMPONENT16),e.getViewport().setViewport(0,0,t.getWidth(),t.getHeight()))}},updateShadowTechnique:function(e){this.updateCameraClear();for(var t=this._cameraClear.getFrameBufferObject(),r=0,n=this._shadowMaps.length;r<n;r++)this._shadowMaps[r].updateShadowTechnique(e,this._viewportDimension[r],t)},initTexture:function(){var e;this._dirty&&(this._texture||(this._texture=new aa,this._textureUnit=this._textureUnitBase),this._texture.setTextureSize(this._textureSize,this._textureSize),this._texelSizeUniform.setFloat(1/this._textureSize),this._renderSize[0]=this._textureSize,this._renderSize[1]=this._textureSize,e=J["default"].RGBA,na.prototype.setTextureFiltering.call(this),this._texture.setInternalFormat(e),this._texture.setWrapS(J["default"].CLAMP_TO_EDGE),this._texture.setWrapT(J["default"].CLAMP_TO_EDGE),this._texture.dirty())},cullShadowCasting:function(e,t){this._cameraClear.accept(e);for(var r=0,n=this._shadowMaps.length;r<n;r++){var i=this._shadowMaps[r];(i.isContinuousUpdate()||i.needRedraw())&&i.cullShadowCasting(e,t)}},isContinuousUpdate:function(){for(var e=0,t=this._shadowMaps.length;e<t;e++)if(this._shadowMaps[e].isContinuousUpdate())return!0;return!1},needRedraw:function(){for(var e=0,t=this._shadowMaps.length;e<t;e++)if(this._shadowMaps[e].needRedraw())return!0;return!1},removeShadowMap:function(e){if(this._shadowMaps.length>0){var t=this._shadowMaps.indexOf(e);if(-1!==t){this._shadowMaps[t].valid()&&this._shadowMaps[t].cleanSceneGraph(!0),this._shadowMaps.splice(t,1);var r=this._texture.getLightNumberArray();t=r.indexOf(e.getLightNumber()),-1!==t&&r.splice(t,1);var n=e.getLight();t=this._lights.indexOf(n),-1!==t&&this._lights.splice(t,1),this._viewportDimension.length>t&&this._viewportDimension.splice(t,1),this.recomputeViewports()}}},addShadowMap:function(e){if(!(this._shadowMaps.length>0&&-1!==this._shadowMaps.indexOf(e))){this._shadowMaps.push(e);var t=e.getLight();-1===this._lights.indexOf(t)&&this._lights.push(t),this._shadowedScene&&e.setShadowedScene(this._shadowedScene);var r=this._texture.getLightNumberArray();-1===r.indexOf(e.getLightNumber())&&r.push(t.getLightNumber()),this.recomputeViewports()}},cleanReceivingStateSet:function(){if(this._receivingStateset){this._texture&&this._receivingStateset.getTextureAttribute(this._textureUnit,this._texture.getTypeMember())===this._texture&&this._receivingStateset.removeTextureAttribute(this._textureUnit,this._texture.getTypeMember());for(var e=0,t=this._shadowMaps.length;e<t;e++)this._shadowMaps[e].cleanReceivingStateSet()}},cleanSceneGraph:function(){this._texture=void 0,this._shadowedScene=void 0},setDebug:function(e,t){if(t)this._shadowMaps[t].setDebug(e);else for(var r=0,n=this._shadowMaps.length;r<n;r++)this._shadowMaps[r].setDebug(e)},markSceneAsNoShadow:function(){for(var e=0,t=this._shadowMaps.length;e<t;e++)this._shadowMaps[e].markSceneAsNoShadow()}}),"osgShadow","ShadowMapAtlas");var sa=oa,ua=["1Tap(4texFetch)","4Tap(16texFetch)","9Tap(36texFetch)","16Tap(64texFetch)"],ca=function(e){this.castsShadowDrawTraversalMask=4294967295,this.castsShadowBoundsTraversalMask=4294967295,this.textureSize=1024,this.textureType="UNSIGNED_BYTE",this.textureFormat=J["default"].RGBA,this.shadowProjection="fov",this.fov=50,this.kernelSizePCF="4Tap(4texFetch)",this.bias=.005,this.normalBias=void 0,this.shadowCastShaderGeneratorName="ShadowCast",j["a"].objectMix(this,e)};ca.kernelSizeList=ua,ca.prototype={setCastsShadowDrawTraversalMask:function(e){this.castsShadowDrawTraversalMask=e},getCastsShadowDrawTraversalMask:function(){return this.castsDrawShadowTraversalMask},setCastsShadowBoundsTraversalMask:function(e){this.castsShadowBoundsTraversalMask=e},getCastsShadowBoundsTraversalMask:function(){return this.castsShadowBoundsTraversalMask},setLight:function(e){this.light=e},getLight:function(){return this.light},setTextureSize:function(e){this.textureSize=e},getTextureSize:function(){return this.textureSize},setTextureType:function(e){this.textureType=e},getTextureType:function(){return this.textureType},setTextureFormat:function(e){this.textureFormat=e},getTextureFormat:function(){return this.textureFormat},setShadowCastShaderGeneratorName:function(e){this.shadowCastShaderGeneratorName=e},getShadowCastShaderGeneratorName:function(){return this.shadowCastShaderGeneratorName}};var la=ca,ha=n("bade"),da=function(e){Ar["a"].call(this),this._shadowTechniques=[],this._optimizedFrustum=!1,this._frustumReceivers=[F["g"].create(),F["g"].create(),F["g"].create(),F["g"].create(),F["g"].create(),F["g"].create()],this._tmpMat=F["c"].create(),this._receivingStateset=new Rr["a"],this._computeBoundsVisitor=new ha["default"],this._castsShadowDrawTraversalMask=4294967295,this._castsShadowBoundsTraversalMask=4294967295,e&&this.setShadowSettings(e)};j["a"].createPrototypeNode(da,j["a"].objectInherit(Ar["a"].prototype,{getReceivingStateSet:function(){return this._receivingStateset},getShadowTechniques:function(){return this._shadowTechniques},addShadowTechnique:function(e){this._shadowTechniques.length>0&&-1!==this._shadowTechniques.indexOf(e)||(this._shadowTechniques.push(e),e.valid()&&(e.setShadowedScene(this),e.dirty()))},removeShadowTechnique:function(e){if(this._shadowTechniques.length>0){var t=this._shadowTechniques.indexOf(e);-1!==t&&(this._shadowTechniques[t].valid()&&this._shadowTechniques[t].cleanSceneGraph(),this._shadowTechniques.splice(t,1))}},cleanSceneGraph:function(){for(var e=0,t=this._shadowTechniques.length;e<t;e++)this._shadowTechniques[e]&&this._shadowTechniques[e].valid()&&this._shadowTechniques[e].cleanSceneGraph()},dirty:function(){for(var e=0;e<this._shadowTechniques.length;e++)this._shadowTechniques[e].dirty()},nodeTraverse:function(e){Ar["a"].prototype.traverse.call(this,e)},setShadowSettings:function(e){this._settings=e,this.setCastsShadowDrawTraversalMask(e.castsShadowDrawTraversalMask),this.setCastsShadowBoundsTraversalMask(e.castsShadowBoundsTraversalMask),!1!==e.userShadowCasterVisitor&&(this._removeNodesNeverCastingVisitor=e.userShadowCasterVisitor||new Vi(this._castsShadowTraversalMask))},setCastsShadowDrawTraversalMask:function(e){this._castsShadowDrawTraversalMask=e},getCastsShadowDrawTraversalMask:function(){return this._castsDrawShadowTraversalMask},setCastsShadowBoundsTraversalMask:function(e){this._castsShadowBoundsTraversalMask=e},getCastsShadowBoundsTraversalMask:function(){return this._castsShadowBoundsTraversalMask},computeShadowedSceneBounds:function(){this._removeNodesNeverCastingVisitor&&(this._removeNodesNeverCastingVisitor.setNoCastMask(~(this._castsShadowBoundsTraversalMask|this._castsShadowDrawTraversalMask)),this._removeNodesNeverCastingVisitor.reset(),this.accept(this._removeNodesNeverCastingVisitor)),this._computeBoundsVisitor.setTraversalMask(this._castsShadowBoundsTraversalMask),this._computeBoundsVisitor.reset(),this.accept(this._computeBoundsVisitor);var e=this._computeBoundsVisitor.getBoundingBox();return!!e.valid()||(this._removeNodesNeverCastingVisitor&&this._removeNodesNeverCastingVisitor.restore(),!1)},traverse:function(e){if(e.getVisitorType()===Wr["a"].CULL_VISITOR){var t,r,n=this._shadowTechniques.length;n&&e.pushStateSet(this._receivingStateset),this.nodeTraverse(e),n&&e.popStateSet();var i=!1;for(t=0;t<n;t++)r=this._shadowTechniques[t],r&&r.valid()&&(r.isDirty()&&(i=!0,r.init()),(r.isContinuousUpdate()||r.needRedraw())&&(i=!0));if(!i)return;var a=this.computeShadowedSceneBounds(e);if(!a){for(t=0;t<n;t++)r=this._shadowTechniques[t],r.markSceneAsNoShadow();return}var o=this._computeBoundsVisitor.getBoundingBox(),s=e.getCurrentModelMatrix();for(o.transformMat4(o,s),t=0;t<n;t++)r=this._shadowTechniques[t],(r.isContinuousUpdate()||r.needRedraw())&&(r.updateShadowTechnique(e),r.cullShadowCasting(e,o));this._removeNodesNeverCastingVisitor&&this._removeNodesNeverCastingVisitor.restore()}else this.nodeTraverse(e)}}),"osgShadow","ShadowedScene"),Wi["a"].registerApplyFunction(da.nodeTypeID,Wi["a"].getApplyFunction(Ar["a"].nodeTypeID));var fa=da,_a={};_a.ShadowCastAttribute=Di,_a.ShadowCastCompiler=Li["a"],_a.ShadowReceiveAttribute=Yi,_a.ShadowCasterVisitor=Vi,_a.ShadowFrustumIntersection=Hi,_a.ShadowMap=na,_a.ShadowMapAtlas=sa,_a.ShadowedScene=fa,_a.ShadowSettings=la,_a.ShadowCastShaderGenerator=Fi["a"],_a.ShadowTechnique=Zi,_a.ShadowTexture=$i,_a.ShadowTextureAtlas=aa;var pa=_a,ga=function(){var e=w["default"].WebGLCaps.instance().getWebGLParameter("MAX_TEXTURE_IMAGE_UNITS");return Math.min(e,M.maxTextureUnits)},ma=n("ade3"),va=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(){var e;return Object(v["a"])(this,r),e=t.call(this),e._enableVertexColor=!1,e._hasClearcoat=!1,e._hasNormalMap=!1,e._hasOpacityMap=!1,e._opacityFactor=1,e._normalFactor=1,e._normalFlipY=0,e._depthWrite=!0,e._onlyDepthMaskNoShading=!1,e._displacementAmount=1,e._cullFace=w["default"].CullFace.DISABLE,e._unlit=!1,e._invertAlpha=!1,e._metalnessWorkFlow=!0,e._clearcoatParam=[1,.3],e}return Object(S["a"])(r,[{key:"getHash",value:function(){return this.getType()+(this._enableVertexColor?"VertexColor":"")+(this._hasNormalMap?"NormalMap":"")+(this._hasOpacityMap?"HasOpacityMap":"")+(this._hasAOMap?"HasAOMap":"")+(this._hasDisplacementMap?"HasDisplacementMap":"")+(this._onlyDepthMaskNoShading?"OnlyDepthMaskNoShading":"")+(this._unlit?"UnLit":"")+(this._invertAlpha?"InvertAlpha":"")+(this._metalnessWorkFlow?"MetalnessWorkFlow":"")}},{key:"cloneType",value:function(){return new r}},{key:"getType",value:function(){return this.attributeType}},{key:"getTypeMember",value:function(){return this.attributeType}},{key:"getMetalnessWorkFlow",value:function(){return this._metalnessWorkFlow}},{key:"setMetalnessWorkFlow",value:function(e){this._metalnessWorkFlow=e}},{key:"getVertexColorEnable",value:function(){return this._enableVertexColor}},{key:"setVertexColorEnable",value:function(e){this._enableVertexColor=e}},{key:"getHasNormalMap",value:function(){return this._hasNormalMap}},{key:"setHasNormalMap",value:function(e){this._hasNormalMap=e}},{key:"getHasClearcoat",value:function(){return this._hasClearcoat}},{key:"setHasClaercoat",value:function(e){this._hasClearcoat=e}},{key:"getOnlyDepthMaskNoShading",value:function(){return this._onlyDepthMaskNoShading}},{key:"setOnlyDepthMaskNoShading",value:function(e){this._onlyDepthMaskNoShading=e}},{key:"getDepthWrite",value:function(){return this._depthWrite}},{key:"getCullFace",value:function(){return this._cullFace}},{key:"setHasOpacityMap",value:function(e){this._hasOpacityMap=e,this.updateOpacity()}},{key:"getHasOpacityMap",value:function(){return this._hasOpacityMap}},{key:"setOpacityFactor",value:function(e){this._opacityFactor=e,this.updateOpacity()}},{key:"getOpacityFactor",value:function(){return this._opacityFactor}},{key:"setNormalFactor",value:function(e){this._normalFactor=e}},{key:"getNormalFactor",value:function(){return this._normalFactor}},{key:"setDisplacementAmount",value:function(e){this._displacementAmount=e}},{key:"getDisplacementAmount",value:function(){return this._displacementAmount}},{key:"setNormalFlipY",value:function(e){this._normalFlipY=e?1:0}},{key:"getNormalFlipY",value:function(){return!!this._normalFlipY}},{key:"updateOpacity",value:function(){this._depthWrite=!0,this._opacityFactor<1?this._depthWrite=!1:1===this._opacityFactor&&this._hasOpacityMap&&(this._depthWrite=!0)}},{key:"setHasAOMap",value:function(e){this._hasAOMap=e}},{key:"getHasAOMap",value:function(){return this._hasAOMap}},{key:"setHasDisplacementMap",value:function(e){this._hasDisplacementMap=e}},{key:"getHasDisplacementMap",value:function(){return this._hasDisplacementMap}},{key:"setUnLit",value:function(e){this._unlit=e}},{key:"getUnLit",value:function(){return this._unlit}},{key:"enableInvertAlpha",value:function(e){this._invertAlpha=e}},{key:"getOrCreateUniforms",value:function(){if(r.uniforms)return r.uniforms;var e=r.uniforms={opacityFactor:w["default"].Uniform.createFloat("uOpacityFactor"),normalFactor:w["default"].Uniform.createFloat("uNormalMapFactor"),normalFlipY:w["default"].Uniform.createInt("uNormalMapFlipY"),displacementAmount:w["default"].Uniform.createFloat("uDisplacementAmount"),clearcoatParam:w["default"].Uniform.createFloat2("uClearcoatParam")};return e}},{key:"apply",value:function(){var e=this.getOrCreateUniforms();e.opacityFactor.setFloat(this._opacityFactor),e.normalFactor.setFloat(this._normalFactor),e.normalFlipY.setInt(this._normalFlipY),e.displacementAmount.setFloat(this._displacementAmount),e.clearcoatParam.setFloat2(this._clearcoatParam)}}]),r}(Ii["a"]);Mi(va,va.prototype,"osgEditor","PBRMaterial");var ba=va,Sa=(n("90d7"),function(e){return 0!==e&&(e&1+~e)===e}),xa=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(e){var n;return Object(v["a"])(this,r),n=t.call(this),n._attributeEnable=!1,n._valid=!1,n._texture=e,n.caclLod(),n._targetColor=w["default"].vec3.fromValues(.5,.5,.5),n._sourceLod=0,n._useMask=1,n._maskRange=w["default"].vec3.fromValues(30,.5,.5),n._useSourceColor=!1,n._sourceColor=w["default"].vec3.fromValues(.5,.5,.5),n}return Object(S["a"])(r,[{key:"caclLod",value:function(){var e=this._texture;if(e&&"Texture"===e.className()){this._valid=!0;var t=e.getWidth(),r=e.getHeight();t===r&&Sa(t)&&Sa(r)?(this._valid=!0,this._sourceLod=Math.max(Math.log2(t),0)):this._valid=!1}}},{key:"cloneType",value:function(){return new r(new w["default"].Texture)}},{key:"getHash",value:function(){return this.getType()+(this._attributeEnable?1:0)+(this._valid?1:0)+(this._useSourceColor?1:0)}},{key:"setEnabled",value:function(e){this._attributeEnable=e}},{key:"isEnabled",value:function(){return this._attributeEnable}},{key:"setTexture",value:function(e){this._texture=e,this.caclLod()}},{key:"setTargetColor",value:function(e){w["default"].vec3.copy(this._targetColor,e)}},{key:"enableMask",value:function(e){this._useMask=e?1:0}},{key:"setMaskRange",value:function(e){w["default"].vec3.copy(this._maskRange,e)}},{key:"enableSourceColor",value:function(e){this._useSourceColor=!!e}},{key:"isUseSourceColor",value:function(){return this._useSourceColor}},{key:"setSourceColor",value:function(e){w["default"].vec3.copy(this._sourceColor,e)}},{key:"getOrCreateUniforms",value:function(){return r.uniforms||(r.uniforms={maskRange:w["default"].Uniform.createFloat3("uMaskRange"),targetColor:w["default"].Uniform.createFloat3("uTargetColor"),sourceColor:w["default"].Uniform.createFloat3("uSourceColor"),mask:w["default"].Uniform.createFloat("uMask"),sourceLod:w["default"].Uniform.createFloat("uSourceLod")}),r.uniforms}},{key:"apply",value:function(){if(this._attributeEnable&&this._valid){var e=this.getOrCreateUniforms();e.maskRange.setFloat3(this._maskRange),e.targetColor.setFloat3(this._targetColor),e.mask.setFloat(this._useMask),this._useSourceColor?e.sourceColor.setFloat3(this._sourceColor):e.sourceLod.setFloat(this._sourceLod)}}}]),r}(Ii["a"]);Mi(xa,xa.prototype,"osgEditor","ChangeColorAttribute");var Ta=xa,ya=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(){var e;return Object(v["a"])(this,r),e=t.call(this),e._enabled=!1,e._brightness=1,e._scale=1,e}return Object(S["a"])(r,[{key:"scale",get:function(){return this._scale},set:function(e){this._scale=e}},{key:"brightness",get:function(){return this._brightness},set:function(e){this._brightness=e}},{key:"getHash",value:function(){return"DiamondAttribute"+(this._enabled?1:0)}},{key:"cloneType",value:function(){return new r}},{key:"setEnabled",value:function(e){this._enabled=e}},{key:"isEnabled",value:function(){return this._enabled}},{key:"getOrCreateUniforms",value:function(){var e=r;return e.uniforms||(e.uniforms={brightness:w["default"].Uniform.createFloat1("uBrightness"),scale:w["default"].Uniform.createFloat1("uScale")}),e.uniforms}},{key:"apply",value:function(){if(this._enabled){var e=this.getOrCreateUniforms();e.brightness.setFloat(this._brightness),e.scale.setFloat(this._scale)}}}]),r}(Ii["a"]);Mi(ya,ya.prototype,"osgEditor","DiamondAttribute");var Ca={hdr:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/photo_studio_01_8k.hdr",size:100350789},thumbnail:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/thumbnail_256.jpg",size:15905},order:0,_id:"60c317bca9e97d73e92ccd1f",createTime:"2021-06-11T07:58:52.718Z",name:"工作室",config:{textures:[{images:[{width:256,file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/thumbnail_256.jpg",height:128,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/thumbnail_256.jpg",size:"15905"}}],encoding:"srgb",type:"thumbnail",format:"panorama"},{images:[{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.0_luv.bin.gz",sizeUncompressed:6291456,sizeCompressed:1779853,height:512,width:512,samples:2048,blur:0,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.0_luv.bin.gz",size:"1779853"}},{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.02_luv.bin.gz",sizeUncompressed:6291456,sizeCompressed:1200968,height:512,width:512,samples:2048,blur:.02,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.02_luv.bin.gz",size:"1200968"}},{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_256.0_0.055_luv.bin.gz",sizeUncompressed:1572864,sizeCompressed:317622,height:256,width:256,samples:2048,blur:.055,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_256.0_0.055_luv.bin.gz",size:"317622"}},{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_128.0_0.1_luv.bin.gz",sizeUncompressed:393216,sizeCompressed:97956,height:128,width:128,samples:2048,blur:.1,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_128.0_0.1_luv.bin.gz",size:"97956"}},{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_64.0_0.15_luv.bin.gz",sizeUncompressed:98304,sizeCompressed:29064,height:64,width:64,samples:2048,blur:.15,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_64.0_0.15_luv.bin.gz",size:"29064"}}],encoding:"luv",type:"background",format:"cubemap"},{images:[{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.0_rgbm.bin.gz",sizeUncompressed:6291456,sizeCompressed:2977192,height:512,width:512,samples:2048,blur:0,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.0_rgbm.bin.gz",size:"2977192"}},{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.02_rgbm.bin.gz",sizeUncompressed:6291456,sizeCompressed:1858076,height:512,width:512,samples:2048,blur:.02,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.02_rgbm.bin.gz",size:"1858076"}},{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_256.0_0.055_rgbm.bin.gz",sizeUncompressed:1572864,sizeCompressed:487212,height:256,width:256,samples:2048,blur:.055,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_256.0_0.055_rgbm.bin.gz",size:"487212"}},{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_128.0_0.1_rgbm.bin.gz",sizeUncompressed:393216,sizeCompressed:149136,height:128,width:128,samples:2048,blur:.1,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_128.0_0.1_rgbm.bin.gz",size:"149136"}},{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_64.0_0.15_rgbm.bin.gz",sizeUncompressed:98304,sizeCompressed:46566,height:64,width:64,samples:2048,blur:.15,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_64.0_0.15_rgbm.bin.gz",size:"46566"}}],encoding:"rgbm",type:"background",format:"cubemap"},{images:[{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.0_rgbe.bin.gz",sizeUncompressed:6291456,sizeCompressed:3043958,height:512,width:512,samples:2048,blur:0,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.0_rgbe.bin.gz",size:"3043958"}},{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.02_rgbe.bin.gz",sizeUncompressed:6291456,sizeCompressed:1766005,height:512,width:512,samples:2048,blur:.02,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.02_rgbe.bin.gz",size:"1766005"}},{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_256.0_0.055_rgbe.bin.gz",sizeUncompressed:1572864,sizeCompressed:473185,height:256,width:256,samples:2048,blur:.055,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_256.0_0.055_rgbe.bin.gz",size:"473185"}},{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_128.0_0.1_rgbe.bin.gz",sizeUncompressed:393216,sizeCompressed:149500,height:128,width:128,samples:2048,blur:.1,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_128.0_0.1_rgbe.bin.gz",size:"149500"}},{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_64.0_0.15_rgbe.bin.gz",sizeUncompressed:98304,sizeCompressed:49221,height:64,width:64,samples:2048,blur:.15,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_64.0_0.15_rgbe.bin.gz",size:"49221"}}],encoding:"rgbe",type:"background",format:"cubemap"},{images:[{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.0_float.bin.gz",sizeUncompressed:18874368,sizeCompressed:16116615,height:512,width:512,samples:2048,blur:0,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.0_float.bin.gz",size:"16116615"}},{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.02_float.bin.gz",sizeUncompressed:18874368,sizeCompressed:16067477,height:512,width:512,samples:2048,blur:.02,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.02_float.bin.gz",size:"16067477"}},{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_256.0_0.055_float.bin.gz",sizeUncompressed:4718592,sizeCompressed:4041881,height:256,width:256,samples:2048,blur:.055,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_256.0_0.055_float.bin.gz",size:"4041881"}},{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_128.0_0.1_float.bin.gz",sizeUncompressed:1179648,sizeCompressed:1020352,height:128,width:128,samples:2048,blur:.1,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_128.0_0.1_float.bin.gz",size:"1020352"}},{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_64.0_0.15_float.bin.gz",sizeUncompressed:294912,sizeCompressed:258568,height:64,width:64,samples:2048,blur:.15,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_64.0_0.15_float.bin.gz",size:"258568"}}],encoding:"float",type:"background",format:"cubemap"},{images:[{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_panorama_ue4_1024_luv.bin.gz",sizeUncompressed:4194304,samples:2048,height:1024,width:1024,sizeCompressed:673838,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_panorama_ue4_1024_luv.bin.gz",size:"673838"}}],limitSize:32,encoding:"luv",type:"specular_ue4",format:"panorama"},{images:[{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_panorama_ue4_1024_rgbm.bin.gz",sizeUncompressed:4194304,samples:2048,height:1024,width:1024,sizeCompressed:1095123,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_panorama_ue4_1024_rgbm.bin.gz",size:"1095123"}}],limitSize:32,encoding:"rgbm",type:"specular_ue4",format:"panorama"},{images:[{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_panorama_ue4_1024_rgbe.bin.gz",sizeUncompressed:4194304,samples:2048,height:1024,width:1024,sizeCompressed:1130918,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_panorama_ue4_1024_rgbe.bin.gz",size:"1130918"}}],limitSize:32,encoding:"rgbe",type:"specular_ue4",format:"panorama"},{images:[{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_panorama_ue4_1024_float.bin.gz",sizeUncompressed:12582912,samples:2048,height:1024,width:1024,sizeCompressed:7099449,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_panorama_ue4_1024_float.bin.gz",size:"7099449"}}],limitSize:32,encoding:"float",type:"specular_ue4",format:"panorama"},{images:[{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_cubemap_ue4_256_luv.bin.gz",sizeUncompressed:2097144,samples:2048,height:256,width:256,sizeCompressed:635016,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_cubemap_ue4_256_luv.bin.gz",size:"635016"}}],limitSize:8,encoding:"luv",type:"specular_ue4",format:"cubemap"},{images:[{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_cubemap_ue4_256_rgbm.bin.gz",sizeUncompressed:2097144,samples:2048,height:256,width:256,sizeCompressed:1055995,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_cubemap_ue4_256_rgbm.bin.gz",size:"1055995"}}],limitSize:8,encoding:"rgbm",type:"specular_ue4",format:"cubemap"},{images:[{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_cubemap_ue4_256_rgbe.bin.gz",sizeUncompressed:2097144,samples:2048,height:256,width:256,sizeCompressed:1109686,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_cubemap_ue4_256_rgbe.bin.gz",size:"1109686"}}],limitSize:8,encoding:"rgbe",type:"specular_ue4",format:"cubemap"},{images:[{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_cubemap_ue4_256_float.bin.gz",sizeUncompressed:6291432,samples:2048,height:256,width:256,sizeCompressed:5417781,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_cubemap_ue4_256_float.bin.gz",size:"5417781"}}],limitSize:8,encoding:"float",type:"specular_ue4",format:"cubemap"},{images:[{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/brdf_ue4.bin.gz",sizeUncompressed:65536,samples:2048,height:128,width:128,sizeCompressed:59665,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/brdf_ue4.bin.gz",size:"59665"}}],encoding:"rg16",type:"brdf_ue4",format:"lut"}],writeByChannel:!0,lights:[{direction:[.0331058,-.82285,.567294],lum_ratio:.0797674,color:[43.9513,47.0473,49.9592],luminosity:508.628,sum:.74215,area:{y:.192383,x:.490723,w:.0166016,h:.0878906},error:0,variance:71996e-8}],diffuseSPH:[2.52177,2.6475,2.71793,-.970495,-1.03103,-1.07638,-.517793,-.556958,-.594671,-.335999,-.36003,-.390184,.14915,.157474,.170339,.305085,.325537,.345122,-786492e-9,-.00349557,-.00655254,-955614e-9,-445611e-9,.00699492,-.00675775,-.0107802,-.0170637,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-.0128212,-.0135017,-.0145362,.0321759,.0344156,.0357341,.010143,.0108799,.0117446,.0164007,.0178076,.0192644,.0183598,.0198073,.0203541,.00825731,.00872035,.0094819,.0411866,.044173,.0463374,.0160459,.0171311,.0176568,-.0096879,-.0103498,-.00986728]}},Aa=n("7440"),Ea=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(){var e;return Object(v["a"])(this,r),e=t.call(this),e._attributeEnable=!1,e._transform=w["default"].vec4.fromValues(1,0,0,0),e}return Object(S["a"])(r,[{key:"getHash",value:function(){return this.getType()+(this._attributeEnable?1:0)}},{key:"cloneType",value:function(){return new r}},{key:"setEnabled",value:function(e){this._attributeEnable=e}},{key:"isEnabled",value:function(){return this._attributeEnable}},{key:"setTransform",value:function(e,t,r,n){w["default"].vec4.set(this._transform,e,t,r,n)}},{key:"getTransform",value:function(){return{scale:this._transform[0],ration:this._transform[1],offsetx:this._transform[2],offsety:this._transform[3]}}},{key:"getOrCreateUniforms",value:function(){var e=r;return e.uniforms||(e.uniforms={transform:w["default"].Uniform.createFloat4("uUVTransform")}),e.uniforms}},{key:"apply",value:function(){if(this._attributeEnable){var e=this.getOrCreateUniforms();e.transform.setFloat4(this._transform)}}}]),r}(Ii["a"]);Mi(Ea,Ea.prototype,"osgEditor","UVTransformAttribute");n("d81d");var Ra=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(e,n){var i;return Object(v["a"])(this,r),i=t.call(this),Object(ma["a"])(Object(y["a"])(i),"geoms",[]),Object(ma["a"])(Object(y["a"])(i),"includeShadow",!1),Object(ma["a"])(Object(y["a"])(i),"map",{}),Object(ma["a"])(Object(y["a"])(i),"compGeoms",{}),Object(ma["a"])(Object(y["a"])(i),"_meshIndex",0),Object(ma["a"])(Object(y["a"])(i),"_nameIndex",{}),i.cb=e,i.geoms=[],i.map={},i.includeShadow=n,i}return Object(S["a"])(r,[{key:"apply",value:function(e){if(e instanceof Ve["a"]){var t=this.getNodeName(e);if(this.cb&&this.cb(e,t),"shadow"==t&&(this.shadow=e),!this.includeShadow&&t&&"shadow"!=t||this.includeShadow){var r=e.getOrCreateStateSet(),n=r._uniqueID,i=this.geoms.find((function(e){return e.node==t&&e.matId==n}));if(!i){this.compGeoms[t]||(this.compGeoms[t]=[]);var a=this.compGeoms[t],o={node:t,matId:n,geom:e,index:a.length};a.push(o),this.geoms.push(o),this.map[t]=e}console.log("xxxxxxxxxxx",t,n)}}this.traverse(e)}},{key:"getNodeName",value:function(e){var t=e.getName();if(t||e._parents&&e._parents.length&&(t=e._parents[0].getName()),!t){var r=this._meshIndex+1;return this._meshIndex=r,"未定义@"+r}var n=t.split("_");n=n.length>1?n.slice(0,n.length-1):n;var i=n.join("_");return i||(i=t),i=i.toLowerCase(),void 0==this._nameIndex[i]?(this._nameIndex[i]=0,i):(this._nameIndex[i]=this._nameIndex[i]+1,i+"@"+this._nameIndex[i])}}]),r}(Wr["a"]),Ma=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(e,n){var i;return Object(v["a"])(this,r),i=t.call(this),Object(ma["a"])(Object(y["a"])(i),"geoms",[]),Object(ma["a"])(Object(y["a"])(i),"includeShadow",!1),Object(ma["a"])(Object(y["a"])(i),"map",{}),Object(ma["a"])(Object(y["a"])(i),"compGeoms",{}),Object(ma["a"])(Object(y["a"])(i),"_meshIndex",0),Object(ma["a"])(Object(y["a"])(i),"_nameIndex",{}),i.cb=e,i.geoms=[],i.map={},i.includeShadow=n,i}return Object(S["a"])(r,[{key:"apply",value:function(e){if(e instanceof Ve["a"]){var t=this.getNodeNameV3(e);if(this.cb&&this.cb(e,t),"shadow"==t&&(this.shadow=e),!this.includeShadow&&t&&"shadow"!=t||this.includeShadow){var r=this.getNodeNameV1(e),n=e.getOrCreateStateSet(),i=n._uniqueID,a=this.geoms.find((function(e){return e.node==t&&e.matId==i}));if(!a){this.compGeoms[t]||(this.compGeoms[t]=[]);var o=this.compGeoms[t],s={node:t,matId:i,geom:e,index:o.length,v1Name:r};o.push(s),this.geoms.push(s),this.map[t]=e}console.log("v3 name=>",t,"v1 name=>",r)}}this.traverse(e)}},{key:"getNodeNameV3",value:function(e){var t=e.getName();return t||e._parents&&e._parents.length&&(t=e._parents[0].getName()),t}},{key:"getNodeNameV1",value:function(e){var t=e.getName();if(t||e._parents&&e._parents.length&&(t=e._parents[0].getName()),!t){var r=this._meshIndex+1;return this._meshIndex=r,"未定义@"+r}var n=t.split("_");n=n.length>1?n.slice(0,n.length-1):n;var i=n.join("_");return i||(i=t),i=i.toLowerCase(),void 0==this._nameIndex[i]?(this._nameIndex[i]=0,i):(this._nameIndex[i]=this._nameIndex[i]+1,i+"@"+this._nameIndex[i])}}]),r}(Wr["a"]),wa=(n("07ac"),function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(){var e;return Object(v["a"])(this,r),e=t.call(this),e._attributeEnable=!1,e._mode=r.ProjectionMode.TRIPLANAR,e._triplanarBlendWeight=.1,e}return Object(S["a"])(r,[{key:"getHash",value:function(){return this.getMode()+(this._attributeEnable?1:0)}},{key:"cloneType",value:function(){return new r}},{key:"setEnabled",value:function(e){this._attributeEnable=e}},{key:"isEnabled",value:function(){return this._attributeEnable}},{key:"getMode",value:function(){return this._mode}},{key:"setMode",value:function(e){var t=Object.values(r.ProjectionMode);-1==t.indexOf(e)&&console.error("invalid uv projection mode"),this._mode=e}},{key:"setTriplanarBlendWeight",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:.1;this._triplanarBlendWeight=e}},{key:"getOrCreateUniforms",value:function(){var e=r;return e.uniforms||(e.uniforms={uTriplanarBlendWeight:w["default"].Uniform.createFloat1("uTriplanarBlendWeight")}),e.uniforms}},{key:"apply",value:function(){if(this._attributeEnable){var e=this.getOrCreateUniforms();e.uTriplanarBlendWeight.setFloat(this._triplanarBlendWeight)}}}]),r}(Ii["a"]));Mi(wa,wa.prototype,"osgEditor","UVProjectionAttribute"),wa.ProjectionMode={TRIPLANAR:"TRIPLANAR_PROJECTION",POLAR:"POLAR_PROJECTION",ORTHOGONAL:"ORTHOGONAL_PROJECTION"};var Na=function(){function e(){Object(v["a"])(this,e)}return Object(S["a"])(e,null,[{key:"loadModel",value:function(){var e=Object(l["a"])(regeneratorRuntime.mark((function e(t){var r,n,i,a,o,s=arguments;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return r=s.length>1&&void 0!==s[1]?s[1]:{uvproject:!0,version:"1.0"},window.noForceHttps||(n="http://",0==t.indexOf(n)&&(t="https://"+t.substr(n.length))),e.next=4,Aa["default"].readNodeURL(t);case 4:if(i=e.sent,"string"!=typeof i){e.next=8;break}return console.error(i),e.abrupt("return",null);case 8:return a="3.0"==r.version?Ma:Ra,o=new a((function(e){Ba.resetGeometryStateSet(e);var t=new Ea;if(e.getOrCreateStateSet().setAttributeAndModes(t),r&&r.uvproject){var n=new wa;e.getOrCreateStateSet().setAttributeAndModes(n)}})),i.accept(o),e.abrupt("return",i);case 12:case"end":return e.stop()}}),e)})));function t(t){return e.apply(this,arguments)}return t}()}]),e}(),Oa=(n("9861"),n("841c"),n("e9a9")),Ia=function(){function e(t){Object(v["a"])(this,e),Object(ma["a"])(this,"useCdn",!0),this.useCdn=t}return Object(S["a"])(e,[{key:"Parse",value:function(e){-1!=e.indexOf("unknown")&&console.log("error=>",e,factor,textureConfig,enable,targetColor,uint);var t=new URLSearchParams(location.search),r=!1,n="?t=texture";return"true"!==t.get("phonetexture")&&Object(Oa["a"])()||(n="?x-image-process=image/resize,m_lfit,h_512,w_512",r=!0),-1==e.indexOf("?")&&0!==e.indexOf("blob:http")&&0!==e.indexOf("data:")&&(e+=n),!r&&this.useCdn&&(e=e.replace("sku3d-test.obs.cn-east-3.myhuaweicloud.com","obs.sku3d.com"),0==e.indexOf("https:")?e=e.substr(6):0==e.indexOf("http:")&&(e=e.substr(5))),e}}]),e}(),Pa={TextureResolver:new Ia(!0)};function Da(e,t){var r=t,n=e.getOrCreateStateSet();return function(e,t,i,a){var o={hasMap:!1,promise:void 0};if(!1===i)return n.removeTextureAttribute(r,"Texture"),o;var s=t?t.file?t.file.url:t.url?t.url:null:null;if(s){s=Pa.TextureResolver.Parse(s);var u=Ci.getInstance().getOrCreateTexture(s,{minFilter:r===Ba.DISPLACEMENT_TEXTURE_UNIT?w["default"].Texture.LINEAR:w["default"].Texture.LINEAR_MIPMAP_LINEAR,magFilter:w["default"].Texture.LINEAR,internalFormat:w["default"].Texture.RGB,wrapS:w["default"].Texture.REPEAT,wrapT:w["default"].Texture.REPEAT,anisotropy:16});return u.texture.setFlipY(!0),u.texture.setImageFormat("RGB"),r===Ba.OPACITY_TEXTURE_UNIT&&n.setTextureAttributeAndModes(r,Ci.getInstance().createTextureFromColor(0,!1)),u.promise.then((function(){if(r===Ba.ALBEDO_TEXTURE_UNIT&&a){var e=n.getAttribute("ChangeColorAttribute");e||(e=new Ta,n.setAttributeAndModes(e)),e.setTexture(u.texture),e.setEnabled(!0),e.setTargetColor(a)}n.setTextureAttributeAndModes(r,u.texture)})),o.hasMap=!0,o.promise=u.promise,o}if(null!=e){var c=Ci.getInstance().createTextureFromColor(e,!1);c.setFlipY(!0),c.setWrapS(w["default"].Texture.REPEAT),c.setWrapT(w["default"].Texture.REPEAT),c.setMagFilter(w["default"].Texture.LINEAR),c.setMinFilter(w["default"].Texture.LINEAR_MIPMAP_LINEAR),c.setImageFormat("RGB"),n.setTextureAttributeAndModes(r,c),o.promise=bi(),o.promise.resolve()}else n.removeTextureAttribute(r,"Texture");return o}}var La={url:"",size:0},Fa={classType:"pbr",cullFace:"",metalnessWorkFlow:!0,channels:{Diamond:{color:[.4,.4,.4],brightness:1,scaleX:1,scaleY:1},Albedo:{color:[.509803950786591,.474509835243225,.474509835243225],texture:La},Roughness:{factor:1,invert:!1,texture:La},Emissive:{color:[0,0,0],factor:1,enable:!1},NormalMap:{enable:!1,factor:1,flipY:!1,texture:La},BumpMap:{enable:!1,factor:1,texture:La},Opacity:{enable:!1,type:"ALPHA_BLEND",factor:1,invert:!1,sampleChannel:"a",refractionTint:[1,1,1],refractUseDiffuse:!1,refractUseShininessMap:!1,IOR:1,roughnessFactor:0,texture:La},AO:{enable:!1,occludeSpecular:!1,factor:0,texture:La},MetalnessPBR:{factor:0,texture:La},SpecularF0:.5,ClearCoat:{enable:!1,thickness:5,intensity:1,color:[1,1,1],reflectivity:0,roughness:{factor:.04},normalmap:{factor:1,flipY:!1}},Displacement:{enable:!1,factor:1,texture:La},CavityMap:{enable:!1,factor:0}}},ka={classType:"pbr",cullFace:"",metalnessWorkFlow:!0,channels:{Diamond:{color:[.4,.4,.4],brightness:1,scaleX:1,scaleY:1},Albedo:{color:[.753,.753,.753],texture:La},Roughness:{factor:.3,invert:!1,texture:La},Emissive:{color:[0,0,0],factor:1,enable:!1},NormalMap:{enable:!1,factor:1,flipY:!1,texture:La},BumpMap:{enable:!1,factor:1,texture:La},Opacity:{enable:!1,type:"ALPHA_BLEND",factor:1,invert:!1,sampleChannel:"a",refractionTint:[1,1,1],refractUseDiffuse:!1,refractUseShininessMap:!1,IOR:1,roughnessFactor:0,texture:La},AO:{enable:!1,occludeSpecular:!1,factor:0,texture:La},MetalnessPBR:{factor:1,texture:La},SpecularF0:.5,ClearCoat:{enable:!1,thickness:5,intensity:1,color:[1,1,1],reflectivity:0,roughness:{factor:.04},normalmap:{factor:1,flipY:!1}},Displacement:{enable:!1,factor:1,texture:La},CavityMap:{enable:!1,factor:0}}},Ba=function(){function e(){Object(v["a"])(this,e)}return Object(S["a"])(e,null,[{key:"captureMaterial",value:function(){var t=Object(l["a"])(regeneratorRuntime.mark((function t(r){var n,i,a,o;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:if(r|=Fa,Ci.getInstance().setCache(!1),e.capApp){t.next=11;break}if("undefined"!==typeof OffscreenCanvas){t.next=5;break}throw new Error("OffscreenCanvas is not supported");case 5:n=new OffscreenCanvas(512,512),e.capApp=new kl(n),e.capApp._viewer.setupManipulator(e.capApp._switchManipulator),e.capApp.setEnvironmentModel(Ca.config),e.capApp.setBackgroundMode("none"),e.capApp.start();case 11:return t.next=13,Na.loadModel("https://sku3d-test.obs.cn-east-3.myhuaweicloud.com/upload/osgjs/16630502469853QVNZg_1663050233489.glb.osgjs");case 13:return i=t.sent,a=new Ra((function(t){e.resetGeometryStateSet(t);var n=new Ea;t.getOrCreateStateSet().setAttributeAndModes(n);var i=new wa;t.getOrCreateStateSet().setAttributeAndModes(i),"fabric@1"===a.getNodeName(t)?e.attachMaterial(t,r):e.attachMaterial(t,ka)})),i.accept(a),e.capApp.scene.addChild(i),e.capApp._rootScene.dirtyBound(),e.capApp._viewer.getManipulator().computeHomePosition(),t.next=21,new Promise((function(t,r){setTimeout((function(){try{var n=e.capApp.takeScreenShot(512,512);t(n)}catch(i){r(i)}}),500)}));case 21:return o=t.sent,Ci.getInstance().setCache(!0),t.abrupt("return",o);case 24:case"end":return t.stop()}}),t)})));function r(e){return t.apply(this,arguments)}return r}()},{key:"resetGeometryStateSet",value:function(){var t=Object(l["a"])(regeneratorRuntime.mark((function t(r){var n,i,a;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return n=r.getOrCreateStateSet(),i=e.attachMaterial(r),a=e.createPBRMaterial(i),n.setAttributeAndModes(a),n.setRenderBinDetails(br.OPAQUE,"RenderBin"),t.next=7,Promise.all(i.promises);case 7:return t.abrupt("return",t.sent);case 8:case"end":return t.stop()}}),t)})));function r(e){return t.apply(this,arguments)}return r}()},{key:"updateGeomMaterial",value:function(){var t=Object(l["a"])(regeneratorRuntime.mark((function t(r,n){var i,a;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return i=e.attachMaterial(r,n),a=e.configMaterial(r.getOrCreateStateSet(),i),n&&"diamond"==n.classType&&(a._depthWrite=!0),t.prev=3,t.next=6,Promise.all(i.promises);case 6:return t.abrupt("return",t.sent);case 9:t.prev=9,t.t0=t["catch"](3);case 11:case"end":return t.stop()}}),t,null,[[3,9]])})));function r(e,r){return t.apply(this,arguments)}return r}()},{key:"attachMaterialSync",value:function(){var t=Object(l["a"])(regeneratorRuntime.mark((function t(r,n){var i,a,o,s,u,c,l,h,d,f,_,p,g,m,v,b,S,x,T,y,C;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return i=n||Fa,a=i.uvtransform,a&&(o=[a.scale,Math.PI*a.rotate/180,a.offsetX,a.offsetY],s=1===o[0]&&0===o[1]&&0===o[2]&&0===o[3],u=r.getOrCreateStateSet().getAttribute("UVTransformAttribute"),u&&(u.setEnabled(!s),u.setTransform.apply(u,o))),c=r.getOrCreateStateSet().getAttribute("UVProjectionAttribute"),c&&c.setEnabled(i.uvProjection),l={promises:[]},l.metalnessWorkFlow=i.metalnessWorkFlow,l.cullFace="DISABLE"==i.cullFace?"":i.cullFace,l.vertexColor=void 0!==r.getAttributes().Color,h=Da(r,e.ALBEDO_TEXTURE_UNIT),d=h(i.channels.Albedo.color,i.channels.Albedo.texture,!0),t.next=13,d.promise;case 13:return f=Da(r,e.METALLIC_TEXTURE_UNIT),_=f(i.channels.MetalnessPBR.factor,i.channels.MetalnessPBR.texture,!0),t.next=17,_.promise;case 17:return p=Da(r,e.ROUGHNESS_TEXTURE_UNIT),g=p(i.channels.Roughness.factor,i.channels.Roughness.texture,!0),t.next=21,g.promise;case 21:if(m=Da(r,e.NORMAL_TEXTURE_UNIT),v=m(null,i.channels.NormalMap.texture,i.channels.NormalMap.enable),l.normalMap=v.hasMap,!v.hasMap||!v.promise){t.next=27;break}return t.next=27,v.promise;case 27:if(l.normalFactor=i.channels.NormalMap.factor,l.normalFlipY=i.channels.NormalMap.flipY,b=Da(r,e.AO_TEXTURE_UNIT),S=b(i.channels.AO.factor,i.channels.AO.texture,i.channels.AO.enable),l.aoMap=S.hasMap,!S.hasMap||!S.promise){t.next=35;break}return t.next=35,S.promise;case 35:if(x=Da(r,e.OPACITY_TEXTURE_UNIT),T=x(null,i.channels.Opacity.texture,i.channels.Opacity.enable),l.hasOpacityMap=T.hasMap,!T.hasMap||!T.promise){t.next=41;break}return t.next=41,T.promise;case 41:return l.opacityFactor=i.channels.Opacity.factor,i.channels.Opacity.enable||(l.opacityFactor=1),y=Da(r,e.DISPLACEMENT_TEXTURE_UNIT),C=y(0,i.channels.Displacement.texture,!0),l.hasDisplacementMap=C.hasMap,l.displacementFactor=i.channels.Displacement.factor,t.next=49,C.promise;case 49:return t.abrupt("return",l);case 50:case"end":return t.stop()}}),t)})));function r(e,r){return t.apply(this,arguments)}return r}()},{key:"attachMaterial",value:function(t,r){var n=r||Fa,i=n.uvtransform;if(i){var a=[i.scale,Math.PI*i.rotate/180,i.offsetX,i.offsetY],o=1===a[0]&&0===a[1]&&0===a[2]&&0===a[3],s=t.getOrCreateStateSet().getAttribute("UVTransformAttribute");s&&(s.setEnabled(!o),s.setTransform.apply(s,a))}var u=t.getOrCreateStateSet().getAttribute("UVProjectionAttribute");u&&u.setEnabled(n.uvProjection);var c=t.getOrCreateStateSet().getAttribute("DiamondAttribute");c||(c=new ya,t.getOrCreateStateSet().setAttributeAndModes(c)),"diamond"==n.classType?(c.setEnabled(!0),n.channels.Albedo.texture={url:"https://sku3d-test.obs.cn-east-3.myhuaweicloud.com/queen.textures/colours.png"},n.channels.MetalnessPBR.texture={url:"https://sku3d-test.obs.cn-east-3.myhuaweicloud.com/queen.textures/triangles.png"},n.channels.NormalMap.texture={url:"https://sku3d-test.obs.cn-east-3.myhuaweicloud.com/queen.textures/normals.png"},n.channels.Roughness.texture={url:"https://sku3d-test.obs.cn-east-3.myhuaweicloud.com/queen.textures/points.png"},n.channels.Opacity.factor=0,n.channels.Opacity.enable=!0,n.cullFace="back"):c.setEnabled(!1);var l={promises:[]};l.metalnessWorkFlow=n.metalnessWorkFlow,l.cullFace="DISABLE"==n.cullFace?"":n.cullFace,l.vertexColor=void 0!==t.getAttributes().Color;var h=Da(t,e.ALBEDO_TEXTURE_UNIT),d=h(n.channels.Albedo.color,n.channels.Albedo.texture,!0);l.promises.push(d.promise);var f=Da(t,e.METALLIC_TEXTURE_UNIT),_=f(n.channels.MetalnessPBR.factor,n.channels.MetalnessPBR.texture,!0);l.promises.push(_.promise);var p=Da(t,e.ROUGHNESS_TEXTURE_UNIT),g=p(n.channels.Roughness.factor,n.channels.Roughness.texture,!0);l.promises.push(g.promise);var m=Da(t,e.NORMAL_TEXTURE_UNIT),v=m(null,n.channels.NormalMap.texture,n.channels.NormalMap.enable);l.normalMap=v.hasMap,v.hasMap&&v.promise&&l.promises.push(v.promise),l.normalFactor=n.channels.NormalMap.factor,l.normalFlipY=n.channels.NormalMap.flipY;var b=Da(t,e.AO_TEXTURE_UNIT),S=b(n.channels.AO.factor,n.channels.AO.texture,n.channels.AO.enable);l.aoMap=S.hasMap,S.hasMap&&S.promise&&l.promises.push(S.promise);var x=Da(t,e.OPACITY_TEXTURE_UNIT),T=x(null,n.channels.Opacity.texture,n.channels.Opacity.enable);l.hasOpacityMap=T.hasMap,T.hasMap&&T.promise&&l.promises.push(T.promise),l.opacityFactor=n.channels.Opacity.factor,n.channels.Opacity.enable||(l.opacityFactor=1);var y=Da(t,e.DISPLACEMENT_TEXTURE_UNIT),C=y(0,n.channels.Displacement.texture,!0);return l.hasDisplacementMap=C.hasMap,l.displacementFactor=n.channels.Displacement.factor,l.promises.push(C.promise),l}},{key:"configMaterial",value:function(t,r){var n=t.getAttribute("PBRMaterial");if(n)void 0!==r.normalMap&&n.setHasNormalMap(r.normalMap),void 0!==r.hasOpacityMap&&n.setHasOpacityMap(r.hasOpacityMap),void 0!==r.opacityFactor&&n.setOpacityFactor(r.opacityFactor),void 0!==r.aoMap&&n.setHasAOMap(r.aoMap),void 0!==r.hasDisplacementMap&&(n.setHasDisplacementMap(r.hasDisplacementMap),n.setDisplacementAmount(r.displacementFactor)),void 0!==r.normalFlipY&&n.setNormalFlipY(r.normalFlipY),void 0!==r.normalFactor&&n.setNormalFactor(r.normalFactor),r.cullFace?n._cullFace=e.cullFaceEnum[r.cullFace]:n._cullFace=w["default"].CullFace.DISABLE,n.setMetalnessWorkFlow(!1!==r.metalnessWorkFlow);else{n=e.createPBRMaterial(r);t.setAttributeAndModes(n)}return r.cullFace?t.setAttributeAndModes(new w["default"].CullFace(e.cullFaceEnum[r.cullFace])):t.setAttributeAndModes(new w["default"].CullFace(w["default"].CullFace.DISABLE)),n.getHasOpacityMap()||n.getOpacityFactor()<1?t.setRenderBinDetails(br.TRANSPARENT,"DepthSortedBin"):t.setRenderBinDetails(br.OPAQUE,"RenderBin"),n}},{key:"createPBRMaterial",value:function(e){var t=new ba;return e?(void 0!==e.normalMap&&t.setHasNormalMap(e.normalMap),void 0!==e.vertexColor&&t.setVertexColorEnable(e.vertexColor),void 0!==e.hasOpacityMap&&t.setHasOpacityMap(e.hasOpacityMap),void 0!==e.opacityFactor&&t.setOpacityFactor(e.opacityFactor),void 0!==e.aoMap&&t.setHasAOMap(e.aoMap),void 0!==e.hasDisplacementMap&&(t.setHasDisplacementMap(e.hasDisplacementMap),t.setDisplacementAmount(e.displacementFactor)),void 0!==e.normalFlipY&&t.setNormalFlipY(e.normalFlipY),void 0!==e.normalFactor&&t.setNormalFactor(e.normalFactor),t.setMetalnessWorkFlow(!1!==e.metalnessWorkFlow),t):t}}]),e}();Object(ma["a"])(Ba,"AO_TEXTURE_UNIT",1),Object(ma["a"])(Ba,"ALBEDO_TEXTURE_UNIT",2),Object(ma["a"])(Ba,"METALLIC_TEXTURE_UNIT",3),Object(ma["a"])(Ba,"ROUGHNESS_TEXTURE_UNIT",4),Object(ma["a"])(Ba,"NORMAL_TEXTURE_UNIT",5),Object(ma["a"])(Ba,"ENV_SPECUAR_TEXTURE_UNIT",6),Object(ma["a"])(Ba,"OPACITY_TEXTURE_UNIT",7),Object(ma["a"])(Ba,"ENV_BRDF_TEXTURE_UNIT",8),Object(ma["a"])(Ba,"DISPLACEMENT_TEXTURE_UNIT",13),Object(ma["a"])(Ba,"STICKER_TEXTURE_UNIT",9),Object(ma["a"])(Ba,"SHADOW_TEXTURE_UNIT",12),Object(ma["a"])(Ba,"DefaultMaterial",Fa),Object(ma["a"])(Ba,"capApp",void 0),Object(ma["a"])(Ba,"cullFaceEnum",{front:w["default"].CullFace.FRONT,back:w["default"].CullFace.BACK,both:w["default"].CullFace.FRONT_AND_BACK});var Ua=function(e){var t=new pa.ShadowSettings;return t.setLight(e),t.setShadowCastShaderGeneratorName("shadowcast"),t.setCastsShadowDrawTraversalMask(Tr.SHADOW),t.setCastsShadowBoundsTraversalMask(Tr.SHADOW_BOUNDS),t.userShadowCasterVisitor=!1,t.kernelSizePCF=M.shadowPCF,t.fakePCF=!1,t.setTextureSize(M.shadowTextureSize),t},Va=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(){return Object(v["a"])(this,r),t.apply(this,arguments)}return Object(S["a"])(r,[{key:"defaults",value:function(){return{enable:!0,matrix:w["default"].mat4.create(),type:"DIRECTION",color:w["default"].vec3.fromValues(1,1,1),intensity:1,matrixPrev:w["default"].mat4.create()}}},{key:"initialize",value:function(){this.bind("change:mask",this.dirty,this)}},{key:"init",value:function(e,t){this.createNode(e,t)}},{key:"createNode",value:function(e,t){this._mtLight=new w["default"].MatrixTransform,this._mtLight.setName("Lighting - Mt");var r=t.createLight("Lighting",e);this._shadowMap=r.shadowMap,this._light=r.light,this._lightSource=r.lightSource,this._node=r.node,this._mtQuad=new w["default"].MatrixTransform,this._mtQuad.setName("Lighting - TransformIcon "+e),this._quadGeom=pi.createIconGeometry(Ci.getInstance().getOrCreateTexture(Ei.a,{internalFormat:w["default"].Texture.RGBA,magFilter:w["default"].Texture.LINEAR,minFilter:w["default"].Texture.LINEAR_MIPMAP_LINEAR,wrapS:w["default"].Texture.CLAMP_TO_EDGE,wrapT:w["default"].Texture.CLAMP_TO_EDGE}).texture),this._quadGeom.setName("Lighting - GeomIcon "+e),this._dirGeom=new pi.createDirectionalGeometry(5),this._scale=new w["default"].MatrixTransform,this._scale.setName("Lighting - ScaleIcon "+e),this._mtEditLight=new w["default"].MatrixTransform,this._mtEditLight.getOrCreateStateSet().setTextureAttributeAndModes(0,mi),this._mtEditLight.setName("Lighting - MtEditLight "+e);var n=this._mtEditLight.getOrCreateStateSet();n.addUniform(w["default"].Uniform.createFloat4(w["default"].vec4.fromValues(1,1,1,1),"uColor")),n.addUniform(w["default"].Uniform.createInt(1,"uEnable")),n.addUniform(w["default"].Uniform.createInt(0,"uTextureDepth")),this._node.addChild(this._mtLight),this._node.addChild(this._mtEditLight),this._mtLight.addChild(this._lightSource),this._mtEditLight.addChild(this._scale),this._scale.addChild(this._mtQuad),this._scale.addChild(this._dirGeom),this._mtQuad.addChild(this._quadGeom),this._dirty=!0,this._updateMatrixOnToggleCamera=!0,this._scene=null}},{key:"setDepthTexture",value:function(e){e&&this._mtEditLight.getOrCreateStateSet().setTextureAttributeAndModes(0,e)}},{key:"setScene",value:function(e){this._scene=e}},{key:"getShadowMap",value:function(){return this._shadowMap}},{key:"getLightSource",value:function(){return this._lightSource}},{key:"getNodeScale",value:function(){return this._scale}},{key:"getNodeQuad",value:function(){return this._mtQuad}},{key:"getNode",value:function(){return this._node}},{key:"getNodeLight",value:function(){return this._mtLight}},{key:"getNodeEditLight",value:function(){return this._mtEditLight}},{key:"dirty",value:function(){this._dirty=!0}},{key:"isDirty",value:function(){return this._dirty}},{key:"updateNode",value:function(){if(this._dirty){this._dirty=!1;var e=this._node,t=this._light,r=this.get("type");if("NONE"===r)return e.setNodeMask(0),t.setEnabled(!1),void(this._mtEditLight.editMask=0);e.setNodeMask(-1),this._mtEditLight.editMask=Xn.NodeGizmo.PICK_GIZMO;var n=this.get("enable");t.setLightType(r),t.setEnabled(n),w["default"].mat4.copy(this._mtLight.getMatrix(),this.get("matrix")),this._mtLight.dirtyBound(),this._mtEditLight.dirtyBound(),w["default"].vec3.scale(t.getDiffuse(),this.get("color"),this.get("intensity")),w["default"].vec3.copy(t.getSpecular(),t.getDiffuse());var i=this.getShadowMap();i&&(i.setTextureSize(M.shadowTextureSize),i.setBias(.005)),this._mtLight.setReferenceFrame(w["default"].Transform.RELATIVE_RF),this._mtLight.setCullingActive(!0),this._dirGeom.setNodeMask(n&&"DIRECTION"===r?Tr.NO_PICK_NO_SHADOW:0),w["default"].vec3.copy(this._mtEditLight.getOrCreateStateSet().getUniform("uColor").getInternalArray(),this.get("color"));var a=this._mtEditLight.getOrCreateStateSet();a.getUniform("uEnable").setInt(0|n),this._quadGeom.setLightType(r)}}},{key:"setLightUnit",value:function(e){this._light.getLightNumber()!==e&&(this._light.setLightNumber(e),this._light.setName("osg"+this._light.getTypeMember()),this._shadowMap.dirty())}},{key:"setIconVisibility",value:function(e){this._mtEditLight.setNodeMask(e?Tr.PICK_GIZMO_LIGHT:0)}},{key:"setUpdateMatrixOnToggleCamera",value:function(e){this._updateMatrixOnToggleCamera=e}},{key:"setJSON",value:function(e){this.set(e)}},{key:"getJSON",value:function(){return this.toJSON()}}]),r}(hi["Model"]),Ga=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(){return Object(v["a"])(this,r),t.apply(this,arguments)}return Object(S["a"])(r,[{key:"defaults",value:function(){return{select:-1,lights:[new Va,new Va,new Va],forceShadowRedraw:!1}}},{key:"getName",value:function(){return"Lighting"}},{key:"dirtyScene",value:function(){var e=new Zn;e.computePreciseBox(this._app.getRootModel());for(var t=e.getModelBoxWithDisplacement(),r=this.get("lights"),n=w["default"].vec3.fromValues(0,0,.8*t.radius()),i=t.center(w["default"].vec3.create()),a=0;a<3;++a){var o=r[a],s=o.get("matrix");s[12]=i[0],s[13]=i[1],s[14]=i[2],w["default"].mat4.translate(s,s,n),o.dirty()}}},{key:"init",value:function(e,t){this._app=e,this._lightingFeature=t,this._root=this._app.getRootModel(),this.initLights(),this._app._finishPromise.then(this.initDepthTexture.bind(this))}},{key:"initDepthTexture",value:function(){for(var e=this._app.getFeaturesManager().getTextureDepth(),t=this.get("lights"),r=0;r<3;++r)t[r].setDepthTexture(e)}},{key:"initLights",value:function(){for(var e=this.get("lights"),t=0;t<3;++t)e[t].setScene(this._root),e[t].init(t,this._lightingFeature)}},{key:"getJSON",value:function(){var e={},t=this.get("lights");return e.enable=this.get("enable"),e.lights=[t[0].getJSON(),t[1].getJSON(),t[2].getJSON()],e}},{key:"setJSON",value:function(e,t){var r=this.get("lights");this.set("enable",e.enable);for(var n=0;n<3;++n){var i=e.lights[n];if(i){var a=r[n];a.setUpdateMatrixOnToggleCamera(!1),a.setJSON(i),a.setUpdateMatrixOnToggleCamera(!0),t&&this.dirtyScene()}}}}]),r}(hi["Model"]),Wa=function(){function e(t){Object(v["a"])(this,e),this._app=t;var r=t.globalUniform.uShadowMapSize.getInternalArray();r[0]=M.shadowTextureSize,r[1]=M.shadowTextureSize,this._viewerOSGJS=this._app.getViewerOSGJS(),this._manipulator=this._viewerOSGJS.getManipulator(),this._isScreenshot=!1,this.model=new Ga,this.model.bind("change:select",this.onSelectChanged,this),this.model.bind("change:enable",this.onEnableChanged,this),this.model.bind("change",this._app.redraw,this._app),M.shadowAtlas&&(this._shadowAtlasSetting=Ua(),this._shadowAtlasSetting.atlasSize=2*M.shadowTextureSize,this._shadowAtlasSetting.setTextureSize(M.shadowTextureSize),this._shadowMapAtlas=new pa.ShadowMapAtlas(this._shadowAtlasSetting),this._shadowMapAtlas.setTextureUnitBase(Ba.SHADOW_TEXTURE_UNIT)),this.model.init(this._app,this),this._nodeFeature=new w["default"].Node,this._nodeFeature.setName("Feature - Lighting"),this._shadowNode=new pa.ShadowedScene(Ua()),this._shadowNode.setName("Shadowed scene"),this._lightNode=new w["default"].Camera,this._lightNode.setName("Lighting - Camera"),this._lightNode.setNearFarRatio(5e-5);var n=this._lightNode.getOrCreateStateSet();n.setRenderBinDetails(br.EDITOR_GIZMO,"RenderBin"),this._lightNode.setNodeMask(Tr.NO_SHADOW),this.initLightNode(),this.onEnableChanged(),this._nodeFeature.addChild(this._lightNode),this._showLighting=!1,this._onLightGizmoEditing=null}return Object(S["a"])(e,[{key:"addShadowMap",value:function(e,t){M.shadow&&(t.setContinuousUpdate(!1),M.shadowAtlas?(e.addShadowTechnique(this._shadowMapAtlas),this._shadowMapAtlas.addShadowMap(t)):e.addShadowTechnique(t))}},{key:"removeShadowMap",value:function(e,t){M.shadowAtlas?this._shadowMapAtlas.removeShadowMap(t):e.removeShadowTechnique(t)}},{key:"createLight",value:function(e,t,r){var n=new w["default"].MatrixTransform;n.setName(e+" - LightNode "+t),n.getOrCreateStateSet().setAttributeAndModes(Sr.DEPTH_DISABLE);var i=new Oi(t);r&&i.setLightType(r),i.setName(e+" - Light "+t),w["default"].vec3.copy(i.getAmbient(),w["default"].vec3.ZERO),w["default"].vec3.copy(i.getSpecular(),w["default"].vec3.ZERO),i.setLinearAttenuation(0);var a,o,s=new w["default"].LightSource;return s.setName(e+" - LightSource "+t),s.setLight(i),M.shadow?(this._shadowMapAtlas?(o=this._shadowAtlasSetting,a=this._shadowMapAtlas.addLight(i)):(o=Ua(i),a=new pa.ShadowMap(o),a.setTextureUnitBase(Ba.SHADOW_TEXTURE_UNIT),a.setContinuousUpdate(!1),a.setTextureSize(M.shadowTextureSize)),a.setJitterOffset(M.shadowJitterOffset),{node:n,light:i,lightSource:s,shadowSettings:o,shadowMap:a,enableShadow:M.shadow&&ga()>Ba.SHADOW_TEXTURE_UNIT}):{node:n,light:i,lightSource:s,shadowSettings:this._shadowMapAtlas?this._shadowAtlasSetting:Ua(i),enableShadow:!1}}},{key:"getNode",value:function(){return this._nodeFeature}},{key:"getNodeLight",value:function(){return this._lightNode}},{key:"getNodeShadow",value:function(){return this._shadowNode}},{key:"enable",value:function(e){this.model.set("enable",e)}},{key:"getModel",value:function(){return this.model}},{key:"setSelect",value:function(e){this.model.set("select",e)}},{key:"isLightNone",value:function(e){return-1===e||"NONE"===this.model.get("lights")[e].get("type")}},{key:"showLighting",value:function(e){this._showLighting=e,this._app.redraw()}},{key:"onEnableChanged",value:function(){var e=this.model.get("enable");if(this._lightNode.setNodeMask(e?Tr.NO_SHADOW:0),!e){var t=this.getGizmo();t&&t.attachToNode(null)}for(var r=this.model.get("lights"),n=0,i=r.length;n<i;++n){var a=r[n],o=e&&a.get("enable");a.getLightSource().getLight().setEnabled(o),M.shadowAtlas&&!o&&this.removeShadowMap(this._shadowNode,a.getShadowMap())}e&&this._updateLightsAndIcons()}},{key:"initLightNode",value:function(){this._nodeFeature.addUpdateCallback(this);for(var e=this.model.get("lights"),t=0,r=e.length;t<r;++t){var n=e[t];n.setLightUnit(t),n.bind("change",n.dirty,n),n.bind("change",this._app.redraw,this._app),this._lightNode.addChild(n.getNode())}}},{key:"getGizmo",value:function(){var e=this._app.getFeaturesManager();return e?e.getNodeGizmo():null}},{key:"onSelectChanged",value:function(){var e=this.getGizmo();if(e){var t=this.model.get("select");this.isLightNone(t)?e.attachToNode(null):e.attachToNode(this.model.get("lights")[t].getNodeEditLight())}}},{key:"updateSelection",value:function(){var e=this.getGizmo();if(e&&!e._isEditing){var t=e._attachedNode;if(!this.isLightNone(this.model.get("select"))||t)for(var r=this.model.get("lights"),n=0;n<3;++n)if(r[n].getNodeEditLight()===t){e.updateGizmoMask(),this.model.set("select",n);break}}}},{key:"setLightGizmoEditingCallback",value:function(e){this._onLightGizmoEditing=e}},{key:"updateLightIcons",value:function(){var e=w["default"].vec4.create(),t=w["default"].vec3.create(),r=w["default"].vec3.create(),n=w["default"].quat.create(),i=this.model.get("lights"),a=this._app.getCamera(),o=this._app.getFeaturesManager().getIconScaleFov();this._manipulator.getEyePosition(r);for(var s=this.getGizmo(),u=0;u<3;++u){var c=i[u];if("NONE"!==c.get("type")){var l=c.getNodeEditLight(),h=c.getNodeLight(),d=c.getNodeQuad(),f=c.getNodeScale(),_=s._isEditing&&s._attachedNode===l,p=d.getMatrix(),g=l.getMatrix(),m=h.getMatrix();_?(w["default"].mat4.copy(m,g),this._onLightGizmoEditing&&this._onLightGizmoEditing(m)):w["default"].mat4.copy(g,m),w["default"].mat4.copy(c.get("matrix"),m),l.getWorldMatrix(void 0,p),w["default"].mat4.getTranslation(t,p);var v=w["default"].vec3.dist(r,t)/o;w["default"].mat4.fromScaling(f.getMatrix(),w["default"].vec3.set(e,v,v,v)),w["default"].mat4.multiply(p,a.getViewMatrix(),p),w["default"].mat4.invert(p,p),w["default"].mat4.fromQuat(p,w["default"].mat4.getRotation(n,p)),d.dirtyBound(),h.dirtyBound(),f.dirtyBound()}}}},{key:"setIsScreenshot",value:function(e){this._isScreenshot=e}},{key:"_updateLightsAndIcons",value:function(){if(this._lightNode.getNodeMask()&&this._shadowNode.getChildren().length){for(var e=this._app.getFeaturesManager().getShadowForcedUpdate(),t=this.model.get("lights"),r=!this._isScreenshot&&this._showLighting,n=0;n<3;++n){var i=t[n],a=i.isDirty()||e;i.updateNode();var o=i.getShadowMap();if(o)if(i.get("enable")&&!this.isLightNone(n)){if(!(a=a||e)){for(var s=i.get("matrix"),u=i.get("matrixPrev"),c=0;c<16;c++)if(s[c]!==u[c]){a=!0;break}w["default"].mat4.copy(u,s)}a&&o.requestRedraw(),this.addShadowMap(this._shadowNode,o)}else a&&this.removeShadowMap(this._shadowNode,o);i.setIconVisibility(r)}r&&(this.updateLightIcons(),this.updateSelection())}}},{key:"update",value:function(e,t){return e.getNumChildrenRequiringUpdateTraversal()>0&&t.traverse(e),this._updateLightsAndIcons(),!1}},{key:"prepareForScreenShot",value:function(){this.setIsScreenshot(!0)}},{key:"resetAfterScreenShot",value:function(){this.setIsScreenshot(!1)}}]),e}(),Xa=(n("4d63"),n("c607"),n("2c3e"),function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(e){var n;return Object(v["a"])(this,r),n=t.call(this),n._separateVR=!1,n._isEnv=!1,n._isRootModel=!1,n._app=e,n}return Object(S["a"])(r,[{key:"popCameraModelViewProjectionMatrix",value:function(e){this.popModelViewMatrix(),this.popProjectionMatrix(e)}},{key:"reset",value:function(){w["default"].CullVisitor.prototype.reset.call(this),this._minNear=this._computedNear,this._maxFar=this._computedFar}},{key:"updateNearFar",value:function(){this._minNear=Math.min(this._minNear,this._computedNear),this._maxFar=Math.max(this._maxFar,this._computedFar)}},{key:"_handleMainCamera",value:function(e){var t=this.getCurrentProjectionMatrix(),n=this._computedNear,i=this._computedFar,a=this._nearFarRatio,o=this._projectionMatrixStack.getArray()[0];w["default"].mat4.copy(o,t),this.clampProjectionMatrix(o,this._minNear,this._maxFar,1e-5),r.vrConfig.doVR&&(this.clampProjectionMatrix(r.vrConfig.leftProjection,n,i,a),this.clampProjectionMatrix(r.vrConfig.rightProjection,n,i,a));var s=this._app.globalUniform.uNearFar.getInternalArray();this.clampProjectionMatrix(t,n,i,a,s),e.clampedProjectionMatrix?w["default"].mat4.copy(e.clampedProjectionMatrix,t):e.clampedProjectionMatrix=w["default"].mat4.clone(t)}},{key:"popProjectionMatrix",value:function(e){if(!0===this._computeNearFar&&this._computedFar>=this._computedNear){var t=e===this._app.cameraMain;(t||e.getReferenceFrame()===w["default"].Transform.RELATIVE_RF&&!e.isRenderToTextureCamera())&&this.updateNearFar(),t?this._handleMainCamera(e):this.clampProjectionMatrix(this.getCurrentProjectionMatrix(),this._computedNear,this._computedFar,this._nearFarRatio)}w["default"].CullStack.prototype.popProjectionMatrix.call(this)}},{key:"handleCullCallbacksAndTraverse",value:function(e){e===this._app.nodePostProcessOut?this._separateVR=r.vrConfig.doVR:e===this._app.cameraEnvironment?this._isEnv=!0:e===this._app.nodeRootModel&&(this._isRootModel=!0);var t=e.getCullCallback();t&&!t.cull(e,this)||this.traverse(e),e===this._app.nodePostProcessOut?this._separateVR=!1:e===this._app.cameraEnvironment?this._isEnv=!1:e===this._app.nodeRootModel&&(this._isRootModel=!1)}},{key:"pushLeaf",value:function(e,t){var n=this._currentStateGraph._leafs;0===n.getLength()&&this._currentRenderBin.addStateGraph(this._currentStateGraph);var i=this._separateVR&&this.traversalMask!==Tr.SHADOW,a=this.createOrReuseRenderLeaf();if(a.isVR=i,i){var o=this._isEnv,s=this.getCurrentModelViewMatrix(),u=this.getCurrentViewMatrix();a.leftProjection=r.vrConfig.leftProjection,a.rightProjection=r.vrConfig.rightProjection;var c=a.leftModelView||w["default"].mat4.create(),l=a.rightModelView||w["default"].mat4.create();a.leftModelView=o?w["default"].mat4.copy(c,s):w["default"].mat4.multiply(c,r.vrConfig.leftOffsetView,s),a.rightModelView=o?w["default"].mat4.copy(l,s):w["default"].mat4.multiply(l,r.vrConfig.rightOffsetView,s);var h=a.leftView||w["default"].mat4.create(),d=a.rightView||w["default"].mat4.create();a.leftView=o?w["default"].mat4.copy(h,u):w["default"].mat4.multiply(h,r.vrConfig.leftOffsetView,u),a.rightView=o?w["default"].mat4.copy(d,u):w["default"].mat4.multiply(d,r.vrConfig.rightOffsetView,u)}a.init(this._currentStateGraph,e,this.getCurrentProjectionMatrix(),this.getCurrentViewMatrix(),this.getCurrentModelViewMatrix(),this.getCurrentModelMatrix(),t),n.push(a)}},{key:"updateCalculatedNearFar",value:function(e,t){return w["default"].CullVisitor.prototype.updateCalculatedNearFar.call(this,e,t)}}]),r}(w["default"].CullVisitor));Xa.vrConfig={doVR:!1,framebufferWidth:0,framebufferHeight:0,leftRenderWidth:0,rightRenderWidth:0,leftRenderHeight:0,rightRenderHeight:0,rightProjection:w["default"].mat4.create(),leftProjection:w["default"].mat4.create(),leftOffsetView:w["default"].mat4.create(),rightOffsetView:w["default"].mat4.create()};var qa=Xa,Ya=n("b1f8"),Ka=n("5d7a"),Ja=(n("2ca0"),{DEFAULT:1,EARLYZ_OPAQUE:2,EARLYZ_TRANSPARENT:4,OPAQUE_SHADING:8,TRANSPARENT_SHADING:16,REFRACTION:32,EXTRA:64,SHADOWMAP:128});Ja.ANY_OPAQUE=Ja.EARLYZ_OPAQUE|Ja.OPAQUE_SHADING,Ja.ANY_TRANSPARENT=Ja.REFRACTION|Ja.EARLYZ_TRANSPARENT|Ja.TRANSPARENT_SHADING;var Za=Ja,Qa=w["default"].RenderLeaf.prototype.drawGeometry,$a=w["default"].getOrCreateStateAttributeTypeMemberIndexFromName("PBRMaterial"),eo=function(e,t,r){if(!r)return t.applyAttribute(Sr.CULL_DISABLE),void Qa.call(e,t);var n=!1,i=t.getUserData().RenderInfo;if(i.currentPass===Za.TRANSPARENT_SHADING){var a=t._attributeArray[$a],o=a?a._lastApplied:void 0;o&&(n=o.getCullFace()===w["default"].CullFace.DISABLE)}n&&t.applyAttribute(Sr.CULL_FRONT),Qa.call(e,t),n&&(t.applyAttribute(Sr.CULL_BACK),e._geometry.drawImplementation(t))};function to(e){var t=e._attributeArray[$a],r=t?t._lastApplied:void 0;if(!r)return!0;var n=e.getUserData().RenderInfo,i=n.currentPass;if(!r.getDepthWrite()&&i&Za.ANY_OPAQUE)return!1;if(r.getOnlyDepthMaskNoShading()&&i&Za.OPAQUE_SHADING)return!1;if(i!==Za.EARLYZ_TRANSPARENT)return!0;var a=Sr.BLEND_SUBSTRACTIVE;return e.applyAttribute(a),!0}function ro(e,t,r,n){var i=t&&t.uDrawOpaque;if(void 0!==i){var a=n.getUserData(),o=a.RenderInfo,s=a.app,u=a.uniformCacheByInstanceId,c=o.currentPass,l=s.globalUniform.uDrawOpaque,h=l.getInternalArray(),d=c&Za.ANY_TRANSPARENT?0:1;h[0]=d,l.apply(e,i);var f=r.getInstanceID();u[f]!==d&&(u[f]=d,l.apply(e,i))}}function no(e){for(var t=e.getPrimitiveSetList(),r=0,n=t.length;r<n;++r)if(t[r].getMode()>=w["default"].primitiveSet.TRIANGLES)return!0;return!1}w["default"].RenderLeaf.prototype.drawGeometry=function(e){if(to(e)){var t=e.getUserData().ForceAttribute;t.depth&&e.applyAttribute(t.depth),t.blend&&e.applyAttribute(t.blend),t.colorMask&&e.applyAttribute(t.colorMask);var r=e.getGraphicContext(),n=e.getLastProgramApplied(),i=n.getUniformsCache();e.getUserData();ro(r,i,n,e);var a=no(this._geometry);eo(this,e,a)}};var io=function(e,t){return e._binNum-t._binNum},ao=function(e,t){var r=t?t._parent:void 0,n=0;while(r)r._stateset&&n++,r=r._parent;return n>1&&n--,e.getStateSetStackSize()-n},oo=w["default"].StateAttribute.OVERRIDE_ON,so=function(){var e=new w["default"].StateSet;return e.setShaderGeneratorName("earlyz",oo),e}(),uo=w["default"].vec4.fromValues(1,1,1,0),co=w["default"].vec4.fromValues(0,0,0,0),lo=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(e){var n;return Object(v["a"])(this,r),n=t.call(this),n._binArraySorted=[],n._app=e,n}return Object(S["a"])(r,[{key:"init",value:function(){return w["default"].RenderStage.prototype.init.call(this),this._binArraySorted.length=0,this._renderBufferDepthAttachment=void 0,this}},{key:"isMainCamera",value:function(){var e=this.getCamera();return!(!e||this._app.cameraMain!==e)}},{key:"isShadowCasterCamera",value:function(){var e=this.getCamera(),t=e&&e.getName();return!(!t||!t.startsWith("light_shadow_camera"))}},{key:"sortBinArray",value:function(){var e=this._binArraySorted;e.length=0,this._bins.forEach((function(t,r){e.push(r)})),e.sort(io)}},{key:"bindDepthRTT",value:function(e){this.getCamera().fboDepth.apply(e)}},{key:"bindTransparencyRTT",value:function(e){this.getCamera().fboTransparent.apply(e)}},{key:"bindRefractionRTT",value:function(e){this.getCamera().fboRefraction.apply(e)}},{key:"bindOpaqueRTT",value:function(e){this.getCamera().fboOpaque.apply(e)}},{key:"bindExtraRTT",value:function(e){this.getCamera().fboExtra.apply(e)}},{key:"createFBO",value:function(e,t){if(t){var r=new w["default"].FrameBufferObject,n=this._renderBufferDepthAttachment;n||(n={attachment:w["default"].FrameBufferObject.DEPTH_ATTACHMENT,format:w["default"].FrameBufferObject.DEPTH_COMPONENT16,width:t.getWidth(),height:t.getHeight()},this._renderBufferDepthAttachment=n),r.setAttachment(n);var i={attachment:w["default"].FrameBufferObject.COLOR_ATTACHMENT0,textureTarget:w["default"].Texture.TEXTURE_2D,texture:t};return r.setAttachment(i),r.apply(e),r}}},{key:"createCamera2RTT",value:function(e){var t;t=this.createFBO(e,this.getCamera()._textureOpaque),this.getCamera().frameBufferObject=t,t=this.createFBO(e,this.getCamera()._textureTransparent),this.getCamera().frameBufferObjectTransparent=t}},{key:"clearCameraColorDepth",value:function(e){e.clearColor(this._app.clearOpaqueRGBA),e.depthMask(!0),e.clearDepth(this.getClearDepth()),e.clear(w["default"].Camera.COLOR_BUFFER_BIT|w["default"].Camera.DEPTH_BUFFER_BIT)}},{key:"clearCameraColor",value:function(e){e.clearColor(this._app.clearOpaqueRGBA),e.clear(w["default"].Camera.COLOR_BUFFER_BIT)}},{key:"setClearDepth",value:function(e){this._clearDepth=e}},{key:"getClearDepth",value:function(){return this._clearDepth}},{key:"isWritingDepth",value:function(){return!!this.getCamera()._textureDepth}},{key:"getDoEarlyZ",value:function(){return!0}},{key:"drawExtraBin",value:function(e,t){for(var r,n=t,i=this._binArraySorted,a=0,o=i.length;a<o;a++)r=i[a],r.getBinNumber()>=br.EXTRA&&(n=r.draw(e,n));return n}},{key:"drawExtra",value:function(e,t){var r=e.getUserData().RenderInfo;r.currentPass=Za.EXTRA;var n=this.drawExtraBin(e,t);return r.currentPass=Za.DEFAULT,n}},{key:"drawTransparentBin",value:function(e,t){for(var r,n=t,i=this._binArraySorted,a=0,o=i.length,s=e.getUserData().RenderInfo,u=e.getUserData().ForceAttribute,c=s.currentPass===Za.EARLYZ_TRANSPARENT;a<o;a++){var l=(r=i[a]).getBinNumber();if(l!==br.TRANSPARENT){if(!c&&(l===br.TRANSPARENT_NO_EARLYZ_POST||l===br.TRANSPARENT_NO_EARLYZ_PRE)){var h=u.depth;u.depth=void 0,n=r.draw(e,n),u.depth=h}}else n=r.draw(e,n)}return n}},{key:"drawOpaqueBin",value:function(e,t){for(var r,n=this.getDoEarlyZ(),i=t,a=this._binArraySorted,o=e.getUserData().ForceAttribute,s=e.getUserData().RenderInfo,u=0;u<a.length;u++){if(r=a[u],r.getBinNumber()>0)break;i=r.draw(e,i)}i=this.drawLeafs(e,i);for(var c=s.currentPass===Za.OPAQUE_SHADING;u<a.length;u++){r=a[u];var l=r.getBinNumber();if(l===br.OPAQUE||l===br.REFRACTION||n&&l===br.TRANSPARENT)i=r.draw(e,i);else if(c&&l===br.OPAQUE_NO_EARLYZ){var h=o.depth;o.depth=void 0,s.currentPass=Za.DEFAULT,i=r.draw(e,i),s.currentPass=Za.OPAQUE_SHADING,o.depth=h}}return i}},{key:"drawOpaqueShading",value:function(e,t){var r=e.getUserData().ForceAttribute,n=e.getUserData().RenderInfo;n.currentPass=Za.OPAQUE_SHADING,r.depth=this.getDoEarlyZ()?Sr.DEPTH_EQUAL_NO_WRITE:Sr.DEPTH_LESS_WRITE,r.blend=Sr.BLEND_DISABLE;t=this.drawOpaqueBin(e,t);return r.blend=void 0,r.depth=void 0,n.currentPass=Za.DEFAULT,t}},{key:"drawEarlyOpaque",value:function(e,t){var r=e.getUserData().ForceAttribute,n=e.getUserData().RenderInfo;n.currentPass=Za.EARLYZ_OPAQUE,r.depth=Sr.DEPTH_LESS_WRITE,r.blend=Sr.BLEND_DISABLE,r.colorMask=this.isWritingDepth()?Sr.COLOR_MASK_RGBA:Sr.COLOR_MASK_NONE;var i=this.drawOpaqueBin(e,t);return r.colorMask=void 0,r.blend=void 0,r.depth=void 0,n.currentPass=Za.DEFAULT,i}},{key:"drawTransparentShading",value:function(e,t){var r=e.getUserData().ForceAttribute,n=e.getUserData().RenderInfo;n.currentPass=Za.TRANSPARENT_SHADING,r.depth=Sr.DEPTH_LEQUAL_NO_WRITE,r.blend=Sr.BLEND_SUBSTRACTIVE;var i=this.drawTransparentBin(e,t);return r.blend=void 0,r.depth=void 0,n.currentPass=Za.DEFAULT,i}},{key:"drawEarlyAlpha",value:function(e,t){var r=e.getUserData().ForceAttribute,n=e.getUserData().RenderInfo;n.currentPass=Za.EARLYZ_TRANSPARENT,r.depth=Sr.DEPTH_LESS_NO_WRITE,r.colorMask=Sr.COLOR_MASK_ALPHA;var i=this.drawTransparentBin(e,t);return r.colorMask=void 0,r.depth=void 0,n.currentPass=Za.DEFAULT,i}},{key:"drawImplementationEditor",value:function(e,t){var r=e.getGraphicContext(),n=t,i=this.getCamera(),a=!!i._textureDepth;if(a?(this.bindDepthRTT(e),e.clearColor(uo)):(this.bindOpaqueRTT(e),e.clearColor(this._app.clearOpaqueRGBA)),e.depthMask(!0),e.clearDepth(this.getClearDepth()),e.clear(r.COLOR_BUFFER_BIT|r.DEPTH_BUFFER_BIT),this.getDoEarlyZ()){var o=ao(e,t);e.insertStateSet(o,so),n=this.drawEarlyOpaque(e,n);var s=a&&i._textureTransparent;s&&(n=this.drawEarlyAlpha(e,n)),e.removeStateSet(o),e.applyAttribute(Sr.COLOR_MASK_RGBA)}return a&&(this.bindOpaqueRTT(e),e.clearColor(this._app.clearOpaqueRGBA),e.clear(r.COLOR_BUFFER_BIT)),n=this.drawOpaqueShading(e,n),e.clearColor(co),i._textureTransparent&&(this.bindTransparencyRTT(e),e.clear(r.COLOR_BUFFER_BIT),n=this.drawTransparentShading(e,n)),i._textureExtra&&(this.bindExtraRTT(e),e.clear(r.COLOR_BUFFER_BIT),n=this.drawExtra(e,n)),n}},{key:"drawImplementation",value:function(e,t){var r={depth:void 0,blend:void 0,colorMask:void 0},n={LAST_LEAF:void 0,passTypes:Za,forceAttribute:r,currentPass:Za.DEFAULT},i=e.getUserData();if(i||e.setUserData({uniformCacheByInstanceId:{},app:this._app,ForceAttribute:r,RenderInfo:n}),!this.isMainCamera()){this.isShadowCasterCamera()&&(n.currentPass=Za.SHADOWMAP);var a=w["default"].RenderStage.prototype.drawImplementation.call(this,e,t);return n.currentPass=Za.DEFAULT,a}var o=this.getCamera();if(!o._textureOpaque)return t;o.fboOpaque||(o.fboOpaque=this.createFBO(e,o._textureOpaque)),o.fboTransparent||(o.fboTransparent=this.createFBO(e,o._textureTransparent)),o.fboDepth||(o.fboDepth=this.createFBO(e,o._textureDepth)),o.fboExtra||(o.fboExtra=this.createFBO(e,o._textureExtra));var s=this.getViewport();return void 0===s&&console.log("RenderStage does not have a valid viewport"),e.applyAttribute(s),this._scissor&&e.applyAttribute(this._scissor),0!==this._positionedAttribute.getLength()&&this.applyPositionedAttribute(e,this._positionedAttribute),this.sortBinArray(),t=this.drawImplementationEditor(e,t),t}}]),r}(w["default"].RenderStage),ho=lo,fo=function(e){var t=0;return e<.0031308?e>0&&(t=12.92*e):t=1.055*Math.pow(e,1/2.4)-.055,t},_o=function(e){var t=0;return e<.04045?e>=0&&(t=e*(1/12.92)):t=Math.pow((e+.055)*(1/1.055),2.4),t},po={linearToSrgb1:fo,srgbToLinear1:_o,linearToSrgb:function(e,t){var r=t||new Array(e.length);return r[0]=fo(e[0]),r[1]=fo(e[1]),r[2]=fo(e[2]),r.length>3&&e.length>3&&(r[3]=e[3]),r},srgbToLinear:function(e,t){var r=t||new Array(e.length);return r[0]=_o(e[0]),r[1]=_o(e[1]),r[2]=_o(e[2]),r.length>3&&e.length>3&&(r[3]=e[3]),r},encodeRGBM:function(e,t,r){r[3]=Math.min(1,Math.max(e[0]/t,r[1]/t,r[2]/t,1e-6)),r[3]=Math.ceil(255*r[3])/255;var n=1/(t*r[3]);return r[0]=e[0]*n,r[1]=e[1]*n,r[2]=e[2]*n,r},decodeRGBM:function(e,t,r){var n=t*e[3];return r[0]=n*r[0],r[1]=n*r[1],r[2]=n*r[2],r},rgbToHex:function(e){var t=Math.round(255*e.r),r=Math.round(255*e.g);return"#"+(16777216|Math.round(255*e.b)|r<<8|t<<16).toString(16).substr(1)}},go=Ka["default"].NextShaderProcessor,mo=function(e,t,r,n,i){for(var a=2,o=w["default"].Uniform.createFloat2(w["default"].vec2.fromValues(0,1),"uBlurDir"),s=w["default"].Uniform.createFloat2(w["default"].vec2.fromValues(1,0),"uBlurDir"),u={},c=t,l=0;l<n.length;l++){var h=n[l]+1,d="gaussianBlur"+l;go.hasShader(d)||(u[d]=Generate(h,i)),e.push({func:{name:"gaussianBlur",file:d},uniforms:o,textures:{name:c,uniformName:"TextureBlurInput"},out:{name:"TextureBlurTemp"+l,divisor:a,filter:"linear"}}),Object(Ya["a"])("textureName"),e.push({func:{name:"gaussianBlur",file:d},uniforms:s,textures:{name:"TextureBlurTemp"+l,uniformName:"TextureBlurInput"},out:{name:c,divisor:a,filter:"linear"}}),Object(Ya["a"])("divisor")}go.addShaders(u)},vo=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(e){var n;Object(v["a"])(this,r),n=t.call(this),n.setName("PostProcess - node In"),n._view3d=e,n._camera=e._camera,n._effectiveConfig=e._effectiveConfig,n._app=e._app,n._viewerOSGJS=e._viewerOSGJS,n._model=e.getModel(),n._app.getCamera().getRenderer().setRenderStage(new ho(n._app)),n._app.getEventEmitter().on("pingPongTexture0",n.onPingPongTexture0.bind(Object(y["a"])(n)));var i=n.getBackgroundModel();return i.bind("backgroundUpdated",n.onBackgroundUpdated,Object(y["a"])(n)),i.bind("change:color",n.onBackgroundColor,Object(y["a"])(n)),n._composer=void 0,n}return Object(S["a"])(r,[{key:"getModel",value:function(){return this._model}},{key:"getNodeBackground",value:function(){return this._app.getFeatures().environment.getNode().getBackground()}},{key:"getBackgroundModel",value:function(){return this._app.getFeatures().background.getModel()}},{key:"getBackgroundType",value:function(){return this.getBackgroundModel().get("enable")}},{key:"onPingPongTexture0",value:function(e){this._composer&&this._composer.swapFeedbackLoopTextures(e)}},{key:"_replaceTexture",value:function(e,t,r){var n=this._composer.getStateSetPass(t);if(n){var i=n.getUniform(r);i&&n.setTextureAttributeAndModes(i.getInternalArray()[0],e)}}},{key:"onBackgroundUpdated",value:function(e){this._composer&&"fixed"===this._effectiveConfig.bgType&&(this._replaceTexture(e,"composeFixedBackground","TextureFixed"),this._replaceTexture(e,"composeFixedBackgroundRefraction","TextureFixed"))}},{key:"onBackgroundColor",value:function(){var e=this._app.clearOpaqueRGBA;if("color"===this.getBackgroundType()){w["default"].vec3.copy(e,this.getBackgroundModel().get("color")),e[3]=1,1===this._app.globalUniform.uOutputLinear.getInternalArray()[0]&&po.srgbToLinear(e,e);var t=this._app.globalUniform.uRGBMRange.getInternalArray()[0];t>0&&po.encodeRGBM(e,t,e)}else w["default"].vec4.set(e,0,0,0,0);this._app._frameManager.draw()}},{key:"_getSupportedLinearFloatTexture",value:function(){var e=w["default"].WebGLCaps.instance();return 0===M.floatRtt?w["default"].Texture.UNSIGNED_BYTE:e.hasLinearHalfFloatRTT()?w["default"].Texture.HALF_FLOAT:this._model.get("webVR")&&2===M.floatRtt?w["default"].Texture.UNSIGNED_BYTE:e.hasLinearFloatRTT()?w["default"].Texture.FLOAT:w["default"].Texture.UNSIGNED_BYTE}},{key:"_getSupportedFloatTexture",value:function(){var e=w["default"].WebGLCaps.instance(),t=!1;return 0===M.floatRtt?w["default"].Texture.UNSIGNED_BYTE:e.hasLinearHalfFloatRTT()||e.hasHalfFloatRTT()?w["default"].Texture.HALF_FLOAT:t&&2===M.floatRtt?w["default"].Texture.UNSIGNED_BYTE:e.hasLinearFloatRTT()||e.hasFloatRTT()?w["default"].Texture.FLOAT:w["default"].Texture.UNSIGNED_BYTE}},{key:"_updateEffectiveConfig",value:function(){return this._effectiveConfig.useTransparency=!0,this._effectiveConfig.useExtra=!0,this._effectiveConfig.useDepth=this._needDepthTexture(),this._effectiveConfig.hasBG="none"!=this.getBackgroundType(),this._effectiveConfig.useFxaa=!0,this._effectiveConfig.useToneMapping=!0,this._effectiveConfig.bgType=this.getBackgroundType(),this._effectiveConfig.useSsao=this._model.get("ssaoEnable")&&this._model.get("ssaoIntensity")>=.01,this._effectiveConfig}},{key:"_needDepthTexture",value:function(){var e=this._effectiveConfig;if(e.useRefraction||e.useSsr||e.useDof||e.useBloom||e.useSharpen||e.useSsao||e.useSss||e.useTaa||!e.useFxaa)return!0;var t=this.getBackgroundType();return"none"===t||"fixed"===t}},{key:"_addInternalTextures",value:function(e,t,r){e.addInternalTexture({name:"TextureOpaque",immuable:!0,srgb:r,rgbm:!r}),e.setInputTexture("TextureOpaque"),(t.useRefraction||t.useSsr)&&e.addInternalTexture({name:"TextureToBeRefracted",divisor:M.refractionRes,immuable:!0,reusable:!1,srgb:!1,rgbm:!0}),t.useRefraction&&e.addInternalTexture({name:"TextureRefraction",immuable:!0,srgb:!1,rgbm:!0}),(t.useSsr||t.useSsao)&&e.addInternalTexture({name:"TextureMipmapDepth",immuable:!0,reusable:!1,srgb:!1,rgbm:!1}),t.useDepth&&e.addInternalTexture({name:"TextureDepth",filter:"nearest",immuable:!0,srgb:!1,rgbm:!1}),t.useTransparency&&e.addInternalTexture({name:"TextureTransparent",filter:"nearest",immuable:!0,type:this._getSupportedFloatTexture(),rgbm:!1,srgb:!1}),t.useExtra&&e.addInternalTexture({name:"TextureExtra",filter:"nearest",immuable:!0,srgb:!t.webVR,rgbm:!1})}},{key:"_addSss",value:function(e,t){var r=this._getSupportedLinearFloatTexture();t.addExternalTexture("TextureSSSKernel",this._view3d._sssTexKernel),e.push({func:"sssExtract",textures:[{name:"%last",uniformName:"TextureSSSColor"},"TextureDepth"],out:{name:"TextureSSSExtract",rgbm:!1,divisor:2,type:r,filter:"linear"}});var n=[];n.push("#define SSS_HALF_KERNEL_SIZE "+M.sssHalfKernel),n.push("#define SSS_PROFILE_COUNT "+this._model.get("sssProfiles").length),n.push("#define SSS_JITTER "+M.sssJitter.toExponential());var i=this._model.useSSSLookupFloat()?"1.0":this._model.getSSSWeightRange().toExponential();n.push("#define SSS_BYTE_RANGE "+i);var a=w["default"].Uniform.createFloat2(w["default"].vec2.fromValues(0,1),"uBlurDir");e.push({func:"sssBlur",header:n,textures:[{name:"TextureSSSExtract",uniformName:"TextureSSSBlur"},"TextureDepth","TextureSSSKernel"],uniforms:a,out:{name:"TextureSSSBlur1",divisor:2,type:r,rgbm:!1,filter:"linear"}});var o=w["default"].Uniform.createFloat2(w["default"].vec2.fromValues(1,0),"uBlurDir");e.push({func:"sssBlur",header:n,textures:[{name:"TextureSSSBlur1",uniformName:"TextureSSSBlur"},"TextureDepth","TextureSSSKernel"],uniforms:o,out:{name:"TextureSSSBlur2",divisor:2,rgbm:!0,filter:"linear"}}),e.push({func:"sssCombine",textures:[{name:"TextureSSSBlur2",uniformName:"TextureSSSBlur"},{name:"%last",uniformName:"TextureSSSColor"},"TextureDepth"],out:{name:"%next"}})}},{key:"_packMipmapDepth",value:function(e){for(var t=w["default"].Uniform.createInt(1,"uFirstDepth"),r=w["default"].Uniform.createInt(0,"uFirstDepth"),n=1;n<=5;n++){var i=1<<n+1,a=1===n?"TextureDepth":"TextureDepth"+(n-1),o="TextureDepth"+n;e.push({func:"depthMipmap",textures:[{name:a,uniformName:"TextureDepth"}],uniforms:1===n?t:r,out:{name:o,divisor:i,filter:"linear"}})}e.push({func:"packMipmapDepth",textures:[{name:"TextureDepth",uniformName:"TextureDepth0"},"TextureDepth1","TextureDepth2","TextureDepth3","TextureDepth4","TextureDepth5"],out:{name:"TextureMipmapDepth",filter:"linear"}})}},{key:"_addSsao",value:function(e){var t=[["#extension GL_OES_standard_derivatives : enable"]];M.ssaoNormal&&t.push("#define SSAO_NORMAL"),t.push("#define MOBILE"),e.push({func:"ssaoExtract",header:t,textures:"TextureMipmapDepth",out:{name:"TextureSsaoExtract",filter:"linear"}}),e.push({func:{name:"ssaoBlurH",file:"ssaoBlur.glsl"},header:"#define SSAO_BLUR_H",textures:{name:"TextureSsaoExtract",uniformName:"TextureBlurInput"},out:{name:"TextureSsaoBlurH",filter:"nearest"}}),e.push({func:{name:"ssaoBlurV",file:"ssaoBlur.glsl"},header:"#define SSAO_BLUR_V",textures:[{name:"%last",filter:"linear"},{name:"TextureSsaoBlurH",uniformName:"TextureBlurInput"}],out:{name:"%next"}})}},{key:"_addCombineOpacity",value:function(e){e.push({func:"combineOpacity",textures:[{name:"%last",filter:"nearest"},"TextureTransparent"],out:{name:"%next"},collapsible:!0})}},{key:"_packMipmapColor",value:function(e,t,r){var n=this._addFixedBackgroundRefraction(e,t,r);return mo(e,n,"TextureRefractionBlur",[3,5,7,9,11,13,15],!0),e.push({func:"packMipmapRefraction",textures:[{name:n,uniformName:"TextureRefractionBlur0"},"TextureRefractionBlur1","TextureRefractionBlur2","TextureRefractionBlur3","TextureRefractionBlur4","TextureRefractionBlur5","TextureRefractionBlur6","TextureRefractionBlur7"],out:{name:"TextureToBeRefracted",filter:"linear"}}),e.length}},{key:"_addRefraction",value:function(e){e.push({func:"combineRefraction",textures:["%last","TextureRefraction"],out:{name:"%next"}})}},{key:"_addDof",value:function(e){var t=M.dofRes;e.push({func:"dofCoC",textures:"TextureDepth",out:{name:"TextureDofCoC",divisor:t,filter:"nearest"}}),e.push({func:{name:"dofNearDilateH",file:"dofNearDilate.glsl"},textures:["TextureDofCoC","TextureDepth"],out:{name:"TextureDofNearDilateH",divisor:t,filter:"linear"}}),e.push({func:{name:"dofNearDilateV",file:"dofNearDilate.glsl"},textures:[{name:"TextureDofNearDilateH",uniformName:"TextureDofCoC"},"TextureDepth"],out:{name:"TextureDofNearDilateV",divisor:t,filter:"nearest"}});var r=this._getSupportedFloatTexture()===w["default"].Texture.HALF_FLOAT,n=r?"#define COLOR_WITH_COC":"",i=["%last"];r&&i.push({name:"TextureDofNearDilateV",uniformName:"TextureDofCoC"}),e.push({func:"dofDownsampleColor",header:n,textures:i,out:{name:"TextureDofDownsampleColor",divisor:t,filter:"nearest",type:r?w["default"].Texture.HALF_FLOAT:w["default"].Texture.UNSIGNED_BYTE}}),i=[{name:"TextureDofDownsampleColor",uniformName:"TextureDofColor",rgbm:!r}],r||a.push({name:"TextureDofNearDilateV",uniformName:"TextureDofCoC"}),e.push({func:"dofBlurCircular",header:n,textures:i,out:{name:"TextureDofBlurCircular",divisor:t,filter:"linear",rgbm:!0}}),e.push({func:"dofCombine",textures:[{name:"%last",filter:"linear"},"TextureDofBlurCircular","TextureDofNearDilateV","TextureDepth"],out:{name:"%next"}})}},{key:"_addBloom",value:function(e,t){var r,n=["%last"];t.hasBG&&(r="#define HAS_BACKGROUND",n.push("TextureDepth")),e.push({func:"bloomExtract",textures:n,header:r,out:{name:"TextureBloomExtract",filter:"linear"}}),mo(e,"TextureBloomExtract","TextureBloomBlur",[3,5,7,9,11]),e.push({func:"bloomCombine",textures:[{name:"%last"},"TextureBloomBlur1","TextureBloomBlur2","TextureBloomBlur3","TextureBloomBlur4","TextureBloomBlur5"],out:{name:"%next"}})}},{key:"_addMergeable",value:function(e,t){if(t.useChromaticAberration&&e.push({func:"chromaticAberration",textures:[{name:"%last",filter:"nearest"}],out:{name:"%next"}}),t.useColorBalance&&e.push({func:"colorBalance",textures:[{name:"%last",filter:"nearest"}],out:{name:"%next"},collapsible:!0}),t.useToneMapping){var r=[{name:"%last",filter:"nearest"}],n="";"fixed"!==t.bgType||t.useRefraction||t.useSsr||(n="#define HAS_FIXED_BACKGROUND",r.push("TextureDepth")),e.push({func:"toneMapping",header:n,textures:r,out:{name:"%next"},collapsible:!0})}t.webVR&&t.useExtra&&(e.push({func:"veilVr",textures:"%last",out:{name:"%next",filter:"nearest"},collapsible:!0}),e.push({func:"composeExtra",header:"#define LINEAR_EXTRA",textures:["%last","TextureExtra"],out:{name:"%next",filter:"nearest"},collapsible:!0}))}},{key:"_addSuperSample",value:function(e,t){if(!t.hasBG){var r=["%last","TextureDepth"];if(t.useRefraction&&r.push("TextureRefraction"),e.push({func:"setDepthAlpha",header:t.useRefraction?"#define REFRACTION_FORCE_ALPHA_ONE":"",textures:r,out:{name:"%next"},collapsible:!0}),t.AR)return}if(t.useTaa){var n=[];t.useTaaTransparent&&n.push("#define TAA_TRANSPARENT"),n.push("#define FEEDBACK_MIN "+M.taaFeedbackMin),n.push("#define FEEDBACK_MAX "+M.taaFeedbackMax),qa.vrConfig.doVR&&n.push("#define VR_ENABLED"),e.push({func:"supersampleTaa",textures:[{name:"%last",filter:"linear",rgbm:!1,srgb:!0},"%previous","TextureDepth"],header:n,out:{name:"%next",filter:"linear"}})}else e.push({func:"supersample",textures:[{name:"%last",filter:"linear",rgbm:!1,srgb:!0},"%previous"],out:{name:"%next",filter:"linear"}})}},{key:"_addFinalPass",value:function(e,t){var r=[],n=[{name:"%last",filter:"linear",srgb:!0,rgbm:!1}];if(t.useDistortionVR&&r.push("#define VR_DISTORTION"),t.useFxaa?e.push({func:"fxaa",header:r,textures:n,out:{name:"%next"}}):e.push({func:"passThrough",header:r,textures:n,out:{name:"%next"}}),t.useSharpen){var i=[],a=["%last"];t.hasBG&&(i.push("#define HAS_BACKGROUND"),a.push("TextureDepth")),e.push({func:"sharpen",header:i,textures:a,out:{name:"%next"},collapsible:!0})}t.useVignette&&e.push({func:"vignette",textures:[{name:"%last",filter:"nearest"}],out:{name:"%next"},collapsible:!0}),t.useGrain&&e.push({func:"grain",textures:"%last",out:{name:"%next"},collapsible:!0}),t.useDof&&e.push({func:"dofCross",textures:"%last",out:{name:"%next"},collapsible:!0}),t.webVR?e.push({func:"fadeVr",textures:"%last",out:{name:"%next"},collapsible:!0}):t.useExtra&&e.push({func:"composeExtra",textures:["%last","TextureExtra"],out:{name:"%next"},collapsible:!0}),t.hasBG||e.push({func:"finalPremultAlpha",textures:"%last",out:{name:"%next"},collapsible:!0})}},{key:"_addFixedBackground",value:function(e,t,r){if("fixed"===t.bgType){var n=this.getNodeBackground().getBackground()||mi;n.divisor=-1,r.addExternalTexture("TextureFixed",n);var i=["%last","TextureFixed","TextureDepth"],a=[];t.useRefraction&&(i.push("TextureRefraction"),a.push("#define REFRACTION_COMPOSITING_EXCLUSION")),e.push({func:"composeFixedBackground",header:a,textures:i,uniforms:[this._app.backgroundUniform.scale],out:{name:"%next"},collapsible:!0})}}},{key:"_addFixedBackgroundRefraction",value:function(e,t,r){if(!t.useRefraction||"fixed"!==t.bgType)return"%last";var n=this.getNodeBackground().getBackground()||mi;return n.divisor=-1,r.addExternalTexture("TextureFixed",n),e.push({func:{name:"composeFixedBackgroundRefraction",file:"composeFixedBackground.glsl"},textures:["%last","TextureFixed","TextureDepth"],uniforms:[this._app.backgroundUniform.scale],out:{name:"TextureWithBackground"}}),"TextureWithBackground"}},{key:"_addPassThrough",value:function(e){e.push({func:"passThrough",textures:"%last",out:{name:"%next"}})}},{key:"_createComposer",value:function(){var e=this._updateEffectiveConfig(),t=this._composer||new Xn.ComposerPostProcess;void 0===this._composer&&this._initComposer(t),t.clear();var r=[],n=e.useSsr&&M.depthMipmap||e.useSsao,i=e.useSsr||e.useRefraction,a=0;n&&this._packMipmapDepth(r),e.useSsao&&this._addSsao(r),e.useSss&&this._addSss(r,t),e.useTransparency&&this._addCombineOpacity(r),i&&(a=this._packMipmapColor(r,e,t)),e.useRefraction&&this._addRefraction(r,e,t),e.useDof&&this._addDof(r),e.useBloom&&this._addBloom(r,e),this._addMergeable(r,e),this._addFixedBackground(r,e,t),a>0&&r.length===a&&this._addPassThrough(r);var o=0===r.length;if(this._addSuperSample(r,e),this._addFinalPass(r,e),this._addInternalTextures(t,e,o),t.build(r),this._assignInternalTextureToCamera(),this._app.globalUniform.uOutputLinear.setInt(o?0:1),this._app.globalUniform.uRGBMRange.setFloat(o?-1:7),this.onBackgroundColor(),e.useRefraction||e.useSsr){var s=this.getOrCreateStateSet(),u=t.getInternalTexture("TextureToBeRefracted");s.setTextureAttributeAndModes(5,u),s.addUniform(w["default"].Uniform.createInt(5,"uTextureToBeRefracted")),u=M.depthMipmap?t.getInternalTexture("TextureMipmapDepth"):t.getInternalTexture("TextureDepth"),s.setTextureAttributeAndModes(4,u),s.addUniform(w["default"].Uniform.createInt(4,"uTextureMipmapDepth"))}}},{key:"_assignInternalTextureToCamera",value:function(){var e=this._composer,t=this._effectiveConfig,r=this._camera;r._textureOpaque=e.getInternalTexture("TextureOpaque"),t.useDepth&&(r._textureDepth=e.getInternalTexture("TextureDepth")),t.useTransparency&&(r._textureTransparent=e.getInternalTexture("TextureTransparent")),t.useRefraction&&(r._textureRefraction=e.getInternalTexture("TextureRefraction")),t.useExtra&&(r._textureExtra=e.getInternalTexture("TextureExtra"))}},{key:"_resizeMipmapHeight",value:function(e,t,r){var n=e.getInternalTexture(t);if(n){var i=e._screenWidth,a=e._screenHeight,o=e._getTextureSize(i,n.divisor),s=e._getTextureSize(a,.5*n.divisor);n.setTextureSize(o,s);var u=e.getStateSetPass(r);if(u){u.getUniform("uTextureOutputSize").getInternalArray()[1]=s;for(var c=e.getCameras(),l=0;l<c.length;++l){var h=c[l];if(h.getName()===t)return void h.getViewport().setViewport(0,0,o,s)}}}}},{key:"_hookComposerResize",value:function(e){var t=this,r=Xn.ComposerPostProcess.prototype;e.resizeRatio=function(n,i,a,o){r.resizeRatio.call(e,n,i,a,o),t._resizeMipmapHeight(e,"TextureToBeRefracted","packMipmapRefraction"),t._resizeMipmapHeight(e,"TextureMipmapDepth","packMipmapDepth")}}},{key:"_initComposer",value:function(e){e.setScreenSize(this._viewerOSGJS.getCanvasWidth(),this._viewerOSGJS.getCanvasHeight()),e.setMethodWrapUV(1,1),this._hookComposerResize(e),this._app.getEventEmitter().on("resizeCanvas",e.resize.bind(e)),this._app.getEventEmitter().on("resizeRatio",e.resizeRatio.bind(e)),e.setNodeMask(Tr.NO_PICK_NO_SHADOW),e.setName("PostProcess - Composer"),this.addChild(e),this._composer=e;var t=e.getOrCreateStateSet();for(var r in this._app.postProcessUniform)t.addUniform(this._app.postProcessUniform[r])}},{key:"resetCameraAttachments",value:function(){var e=this._camera;e.resetAttachments(),e.fboOpaque&&(e.fboOpaque.reset(),e.fboOpaque=void 0),e.fboTransparent&&(e.fboTransparent.reset(),e.fboTransparent=void 0),e.fboRefraction&&(e.fboRefraction.reset(),e.fboRefraction=void 0),e.fboDepth&&(e.fboDepth.reset(),e.fboDepth=void 0),e.fboExtra&&(e.fboExtra.reset(),e.fboExtra=void 0),e.attachRenderBuffer(w["default"].FrameBufferObject.DEPTH_ATTACHMENT,w["default"].FrameBufferObject.DEPTH_COMPONENT16)}},{key:"createPathStandard",value:function(){this._createComposer(),this.resetCameraAttachments()}}]),r}(w["default"].Node),bo=function(){function e(t){Object(v["a"])(this,e),this.RESIZE_OBSERVABLE=null,this.CLIENT_WIDTH,this.CLIENT_HEIGHT,this._dirty=!0,this._postProcessFeature=t,this._effectiveConfig=t._effectiveConfig,this._app=t._app,this._viewerOSGJS=t._viewerOSGJS;var r=!0;this._interpolatorDofFocusPoint=new Xn.DelayInterpolator(3,r?.15:1),this._interpolatorDofBlurNear=new Xn.DelayInterpolator(1,r?.15:1),this._interpolatorDofBlurFar=new Xn.DelayInterpolator(1,r?.15:1),this._interpolatorDofCross=new Xn.DelayInterpolator(1,r?.08:1),this._interpolatorDofCross._epsilon=-.01,this._dofInitialized=!1,this._dofAutoFocus=!1,this._currentEye=w["default"].vec3.create(),this._lastEye=w["default"].vec3.create(),this._currentRot=w["default"].quat.create(),this._lastRot=w["default"].quat.create(),this._dofLastPos=w["default"].vec3.create(),this._dofLastFocal=0,this._firstFrame=!0,this._cullConfig=qa.vrConfig,this._skipTaaFrames=0,this._lastUpdateTime=this._viewerOSGJS.getFrameStamp().getSimulationTime(),this._width=-1,this._height=-1;this.dirty.bind(this);this.canvasRatioModel=new hi["Model"]({viewerToCanvasRatio:1}),this.getBackgroundModel().bind("change",this.dirty.bind(this)),this._hookViewerCheckNeedToDoFrame(),this._hookViewerFrame(),this._hookViewerComputeCanvasSize(),this._app.getEventEmitter().on("resetTaa",this.onResetTaa.bind(this)),M.dofCircle||(this.showDofCross=function(){})}return Object(S["a"])(e,[{key:"dirty",value:function(){this._dirty=!0}},{key:"onResetTaa",value:function(){this._skipTaaFrames=2}},{key:"getMainCamera",value:function(){return this._postProcessFeature._camera}},{key:"getNodeIn",value:function(){return this._postProcessFeature._nodeIn}},{key:"getCurrentComposer",value:function(){return this._postProcessFeature._nodeIn._composer}},{key:"getBackgroundModel",value:function(){return this._app.getFeatures().background.getModel()}},{key:"updateTargetDofBlurNear",value:function(){this._interpolatorDofBlurNear.setTarget(this._model.get("dofBlurNear"))}},{key:"updateTargetDofBlurFar",value:function(){this._interpolatorDofBlurFar.setTarget(this._model.get("dofBlurFar"))}},{key:"getClampedProjectionMatrix",value:function(){var e=this.getMainCamera();return e.clampedProjectionMatrix||e.getProjectionMatrix()}},{key:"onEffectChanged",value:function(){return this._app._frameManager.draw(),this.getNodeIn().createPathStandard()}},{key:"_toggleComposerCameras",value:function(e){this._app.getSuperSample().setSwitch(e);var t=e?-1:0;this.getMainCamera().setNodeMask(t);var r=this.getCurrentComposer(),n=r?r.getCameras():void 0;if(void 0!==n)for(var i=0;i<n.length-1;i++)n[i].setNodeMask(t)}},{key:"_hookViewerCheckNeedToDoFrame",value:function(){var e=this._viewerOSGJS,t=e.checkNeedToDoFrame.bind(e),r=this;e.checkNeedToDoFrame=function(){this._requestContinousUpdate&&r._app._frameManager.draw();var e=t();return!!e||(r._toggleComposerCameras(!0),!1)}}},{key:"_hookViewerFrame",value:function(){var e=this.getMainCamera(),t=this._viewerOSGJS,r=this._app.getSuperSample(),n=M.vrMirror,i=this,a=t.frame.bind(t);t.frame=function(t,o){a(t,o),i._app._frameManager.setShadowForcedUpdate(!1),e.setNodeMask(-1),i._hmd&&i._hmd.isPresenting&&n&&(r.setSwitch(!1),e.setNodeMask(0),i.getCamera().getRenderer().draw())}}},{key:"_hookViewerComputeCanvasSize",value:function(){this._resizeCanvasTimeout=-1,this._doResizeCanvas=!1,this._overrideCanvasWidth=-1,this._overrideCanvasHeight=-1,this._app.getEventEmitter().on("resizeViewer",this._onResizeCanvas.bind(this)),this._app.getEventEmitter().on("resizeViewerOnNextFrame",this._onForceResizeCanvas.bind(this)),this._cbEnableResizeCanvas=this._enableResizeCanvas.bind(this);var e=this._viewerOSGJS,t=this._app.getCanvas();this._originalCanvasResize=e.computeCanvasSize.bind(e,t),e.computeCanvasSize=this._computeCanvasSize.bind(e,t,this)}},{key:"_onResizeCanvas",value:function(e,t){this._overrideCanvasWidth=e,this._overrideCanvasHeight=t,this._app._frameManager.draw()}},{key:"_onForceResizeCanvas",value:function(e,t){this._enableResizeCanvas(),this._onResizeCanvas(e,t)}},{key:"_enableResizeCanvas",value:function(){this._doResizeCanvas=!0}},{key:"_resetResizeCanvas",value:function(){this._doResizeCanvas=!1,window.clearTimeout(this._resizeCanvasTimeout)}},{key:"_computeCanvasSize",value:function(e,t){var r=this,n=t._overrideCanvasWidth,i=t._overrideCanvasHeight;if(n>0){var a=!1;return this._canvasWidth!==n&&(e.width=n,this._canvasWidth=n,a=!0),this._canvasHeight!==i&&(e.height=i,this._canvasHeight=i,a=!0),a}if(t._doResizeCanvas)return t._postProcessFeature.canvasRatioModel.set("viewerToCanvasRatio",1),t._resetResizeCanvas(),t._originalCanvasResize();var o="undefined"!==typeof OffscreenCanvas;o&&e instanceof OffscreenCanvas?(this.CLIENT_WIDTH=e.width,this.CLIENT_HEIGHT=e.height):window.ResizeObserver?this.RESIZE_OBSERVABLE||(this.RESIZE_OBSERVABLE=new window.ResizeObserver((function(){r.CLIENT_WIDTH=e.clientWidth,r.CLIENT_HEIGHT=e.clientHeight})),this.RESIZE_OBSERVABLE.observe(e),this.CLIENT_WIDTH=e.clientWidth,this.CLIENT_HEIGHT=e.clientHeight):(this.CLIENT_WIDTH=e.clientWidth,this.CLIENT_HEIGHT=e.clientHeight);var s=Math.max(1,Math.floor(this.CLIENT_WIDTH*this._devicePixelRatio))/Math.max(1,Math.floor(this.CLIENT_HEIGHT*this._devicePixelRatio))/(this._canvasWidth/this._canvasHeight);return s===t._postProcessFeature.canvasRatioModel.get("viewerToCanvasRatio")||(t._postProcessFeature.canvasRatioModel.set("viewerToCanvasRatio",s),t._resetResizeCanvas(),t._resizeCanvasTimeout=window.setTimeout(t._cbEnableResizeCanvas,M.resizeTimeout)),!1}},{key:"updateDirtyEffect",value:function(){var e=this._viewerOSGJS.getCanvasWidth(),t=this._viewerOSGJS.getCanvasHeight();this._width&&this._height||(this._width=this._height=-1),this._dirty&&(this.onEffectChanged(),this._dirty=!1),e===this._width&&t===this._height||(this._app.getEventEmitter().trigger("resizeCanvas",e,t),this.getCurrentComposer().resize(e,t),this.getNodeIn().resetCameraAttachments(),this._width=e,this._height=t,this._app._frameManager.draw())}},{key:"updateNearFarRatio",value:function(){}},{key:"updateGlobalTexUniforms",value:function(){var e=this._app.getFeaturesManager(),t=this._app.globalUniform.uGlobalTexSize.getInternalArray(),r=this._app.globalUniform.uGlobalTexRatio.getInternalArray(),n=this._app.globalUniform.uHalton.getInternalArray();this._app.globalUniform.uPreviousGlobalTexSize.setFloat2(t),this._app.globalUniform.uPreviousGlobalTexRatio.setFloat2(r),this._app.globalUniform.uPreviousHalton.setFloat4(n);var i=e.getViewport3d();t[0]=i.width(),t[1]=i.height();var a=this.getCurrentComposer();r[0]=a.getGlobalXRatio(),r[1]=a.getGlobalYRatio(),a.getInternalTexture("TextureToBeRefracted")}},{key:"_shadowJitterUpdate",value:function(e){var t=1+e;this._app.globalUniform.uStaticFrameNumShadow0.setFloat(t),this._app.globalUniform.uStaticFrameNumShadow1.setFloat(t),this._app.globalUniform.uStaticFrameNumShadow2.setFloat(t),this._app.globalUniform.uStaticFrameNumShadow3.setFloat(t)}},{key:"updateSsao",value:function(){if(this._postProcessFeature.model.get("ssaoEnable")&&this._postProcessFeature.model.get("ssaoIntensity")>=.01){var e=this._app.globalUniform.uNearFar.getInternalArray();if(!(e[0]>e[1])){var t=this._app.getFeaturesManager().getViewport3d(),r=this.getClampedProjectionMatrix(),n=1===r[15]?1:2/r[5],i=-2*Math.tan(.5*n);this._app.postProcessUniform.uSsaoProjectionScale.setFloat(t.height()/i);var a=this._app.postProcessUniform.uSsaoProjectionInfo.getInternalArray();a[0]=-2/(t.width()*r[0]),a[1]=-2/(t.height()*r[5]),a[2]=(1-r[8])/r[0],a[3]=(1-r[9])/r[5]}}}},{key:"updateGlobalUniforms",value:function(e){this.updateNearFarRatio(),this.updateGlobalTexUniforms(),this._app.globalUniform.uTimeViewer.setFloat(e.getSimulationTime()/1e3),this._app.globalUniform.uPixelRatio.setFloat2(this._app._canvasPixelRatio.getPixelRatio());var t=this._app.getSuperSample(),r=(e.getFrameNumber()+t.getFrameNumber())%16;this._shadowJitterUpdate(r),this._app.globalUniform.uFrameMod.setFloat(r);var n=t.isEnabled()||this._app.postProcessUniform.uTaaEnabled.getInternalArray()[0];this._app.globalUniform.uFrameModTaaSS.setFloat(n?r:0);var i=this._app.globalUniform.uReprojectViewProj.getInternalArray(),a=this._app.globalUniform.uPreviousProjection.getInternalArray(),o=this._app.globalUniform.uPreviousViewInvView.getInternalArray(),s=this._app.getCamera().getViewMatrix(),u=this._cullConfig.doVR?this._cullConfig.leftProjection:this.getClampedProjectionMatrix();this._tmpView?(w["default"].mat4.invert(o,s),w["default"].mat4.mul(o,this._tmpView,o),w["default"].mat4.mul(i,this._tmpProjection,o),w["default"].mat4.copy(a,this._tmpProjection),w["default"].mat4.copy(this._tmpView,s),w["default"].mat4.copy(this._tmpProjection,u)):(this._tmpView=w["default"].mat4.clone(s),this._tmpProjection=w["default"].mat4.clone(u),w["default"].mat4.copy(i,u))}},{key:"cull",value:function(e,t){t.traverse(e);var r=t.getFrameStamp();return this.updateSsao(r),this.updateDirtyEffect(),this.updateGlobalUniforms(r),!1}}]),e}(),So=function(){function e(t){Object(v["a"])(this,e),this._app=t,this.canvasRatioModel=new hi["Model"]({viewerToCanvasRatio:1}),this.canvasRatioModel.on("change:viewerToCanvasRatio",this._onViewerToCanvasRatio,this);var r=function(e){if(e=new RegExp("[?&]"+encodeURIComponent(e)+"=([^&]*)").exec(location.search))return decodeURIComponent(e[1])},n=navigator.userAgent.toLowerCase();n.indexOf("android"),r("ssao");this.model=new hi["Model"]({toneMappingExposure:1,toneMappingBrightness:0,toneMappingContrast:0,toneMappingSaturation:1,toneMappingMethod:1,ssaoRadius:4,ssaoIntensity:.5,ssaoBias:.8,ssaoEnable:!1}),this.model.on("change:toneMappingExposure",this.onToneMappingExposureChanged,this),this.model.on("change:toneMappingBrightness",this.onToneMappingBrightnessChanged,this),this.model.on("change:toneMappingContrast",this.onToneMappingContrastChanged,this),this.model.on("change:toneMappingSaturation",this.onToneMappingSaturationChanged,this),this.model.on("change:toneMappingMethod",this.onToneMappingMethodChanged,this),this.model.on("change:ssaoEnable",this.checkSsaoEnable,this),this.model.on("change:ssaoIntensity",this.onSsaoIntensity,this),this.model.on("change:ssaoRadius",this.onSsaoRadius,this),this.model.on("change:ssaoBias",this.onSsaoBias,this),this._effectiveConfig={},this._viewerOSGJS=this._app.getViewerOSGJS(),this._sssTexKernel=new w["default"].Texture,this._sssTexKernel.divisor=-1,this._camera=this._createMainCamera(),this._nodeIn=new vo(this),this._nodeOut=this._createNodeOut(),this._nodeIn.addChild(this._camera),this._camera.addChild(this._nodeOut),this._callbackPostProcess=new bo(this),this._nodeIn.setCullCallback(this._callbackPostProcess),this._initUniforms(),this._app.getEventEmitter().bind("resizeCanvas",this._updateViewports,this)}return Object(S["a"])(e,[{key:"_onViewerToCanvasRatio",value:function(){this._updateViewports(),this._app._frameManager.draw()}},{key:"_updateViewports",value:function(){var e=this._app.getFeatures(),t=this._app.getCamera(),r=e.postProcess.getCamera().getViewport(),n=t.getViewport(),i=n.width(),a=n.height();r.setViewport(0,0,i,a);var o=this.canvasRatioModel.get("viewerToCanvasRatio"),s=t.getProjectionMatrix();s[0]=s[5]*a/(i*o)}},{key:"getModel",value:function(){return this.model}},{key:"dirty",value:function(){this._callbackPostProcess.dirty()}},{key:"_initUniforms",value:function(){var e=this.model.attributes;for(var t in e)this.model.trigger("change:"+t)}},{key:"_createNodeOut",value:function(){var e=new w["default"].Node;return e.setName("PostProcess - node Out"),this._app.nodePostProcessOut=e,e}},{key:"_createMainCamera",value:function(){var e=new w["default"].Camera,t=this._viewerOSGJS.getCanvasWidth(),r=this._viewerOSGJS.getCanvasHeight();return e.setViewport(new w["default"].Viewport(0,0,t,r)),e.setName("PostProcess - MainCamera"),e.setRenderOrder(w["default"].Camera.PRE_RENDER,0),e.attachRenderBuffer(w["default"].FrameBufferObject.DEPTH_ATTACHMENT,w["default"].FrameBufferObject.DEPTH_COMPONENT16),this._app.cameraMain=e,e}},{key:"methodToInt",value:function(e){return"reinhard"===e?1:"filmic"===e?2:0}},{key:"checkGrainEnable",value:function(){this._effectiveConfig.useGrain!==this.model.isEffectiveGrain()&&this.dirty()}},{key:"checkSharpenEnable",value:function(){this._effectiveConfig.useSharpen!==this.model.isEffectiveSharpen()&&this.dirty()}},{key:"checkChromaticAberrationEnable",value:function(){this._effectiveConfig.useChromaticAberration!==this.model.isEffectiveChromaticAberration()&&this.dirty()}},{key:"checkVignetteEnable",value:function(){this._effectiveConfig.useVignette!==this.model.isEffectiveVignette()&&this.dirty()}},{key:"checkBloomEnable",value:function(){this._effectiveConfig.useBloom!==this.model.isEffectiveBloom()&&this.dirty()}},{key:"checkDofEnable",value:function(){this._effectiveConfig.useDof!==this.model.isEffectiveDof()&&this.dirty()}},{key:"checkSsaoEnable",value:function(){this._effectiveConfig.useSsao!==(this.model.get("ssaoEnable")&&this.model.get("ssaoIntensity")>=.01)&&this.dirty()}},{key:"checkSsrEnable",value:function(){this._effectiveConfig.useSsr!==this.model.isEffectiveSsr()&&this.dirty()}},{key:"checkTaaEnable",value:function(){this._effectiveConfig.useTaa!==this.model.get("taaEnable")&&this.dirty()}},{key:"checkTaaTransparentEnable",value:function(){this._effectiveConfig.useTaaTransparent!==(this.model.get("taaEnable")&&this.model.get("taaTransparent"))&&this.dirty()}},{key:"onDistortionChanged",value:function(){this._app.postProcessUniform.uDistortion.setFloat2(this.model.get("distortion"))}},{key:"onProjectionLeftChanged",value:function(){this._app.postProcessUniform.uProjectionLeft.setFloat4(this.model.get("projectionLeft"))}},{key:"onUnprojectionLeftChanged",value:function(){this._app.postProcessUniform.uUnprojectionLeft.setFloat4(this.model.get("unprojectionLeft"))}},{key:"onGrainFactor",value:function(){this._app.postProcessUniform.uGrainFactor.setFloat(this.model.get("grainFactor")),this.checkGrainEnable()}},{key:"onSharpenFactor",value:function(){this._app.postProcessUniform.uSharpFactor.setFloat(this.model.get("sharpenFactor")),this.checkSharpenEnable()}},{key:"onChromaticAberrationFactor",value:function(){this._app.postProcessUniform.uChromaFactor.setFloat(this.model.get("chromaticAberrationFactor")),this.checkChromaticAberrationEnable()}},{key:"onVignetteLensChanged",value:function(){var e=this._app.postProcessUniform.uLensRadius.getInternalArray(),t=this.model.get("vignetteAmount"),r=this.model.get("vignetteHardness");e[0]=2-t-r,e[1]=r-t,this.checkVignetteEnable()}},{key:"onBloomFactorChanged",value:function(){this._app.postProcessUniform.uBloomFactor.setFloat(this.model.get("bloomFactor")),this.checkBloomEnable()}},{key:"onBloomThresholdChanged",value:function(){this._app.postProcessUniform.uBloomThreshold.setFloat(this.model.get("bloomThreshold")),this.checkBloomEnable()}},{key:"onBloomRadiusChanged",value:function(){this._app.postProcessUniform.uBloomRadius.setFloat(this.model.get("bloomRadius")),this.checkBloomEnable()}},{key:"onColorBalanceShiftChanged",value:function(){this._app.postProcessUniform.uColorBalanceLow.setFloat3(this.model.get("colorBalanceLow")),this._app.postProcessUniform.uColorBalanceMid.setFloat3(this.model.get("colorBalanceMid")),this._app.postProcessUniform.uColorBalanceHigh.setFloat3(this.model.get("colorBalanceHigh"))}},{key:"onToneMappingExposureChanged",value:function(){this._app.postProcessUniform.uToneExposure.setFloat(this.model.get("toneMappingExposure"))}},{key:"onToneMappingBrightnessChanged",value:function(){this._app.postProcessUniform.uToneBrightness.setFloat(this.model.get("toneMappingBrightness"))}},{key:"onToneMappingContrastChanged",value:function(){this._app.postProcessUniform.uToneContrast.setFloat(this.model.get("toneMappingContrast"))}},{key:"onToneMappingSaturationChanged",value:function(){this._app.postProcessUniform.uToneSaturation.setFloat(this.model.get("toneMappingSaturation"))}},{key:"onToneMappingMethodChanged",value:function(){this._app.postProcessUniform.uToneMethod.setInt(this.model.get("toneMappingMethod"))}},{key:"onDofFocusPoint",value:function(){this._callbackPostProcess.updateDofFocusPoint()}},{key:"onDofBlurNear",value:function(){this._callbackPostProcess.updateTargetDofBlurNear(),this.checkDofEnable()}},{key:"onDofBlurFar",value:function(){this._callbackPostProcess.updateTargetDofBlurFar(),this.checkDofEnable()}},{key:"hideDofCross",value:function(){}},{key:"onSsaoRadius",value:function(){this._app.postProcessUniform.uSsaoRadius.setFloat(this.model.get("ssaoRadius")),this.checkSsaoEnable()}},{key:"onSsaoIntensity",value:function(){this._app.postProcessUniform.uSsaoIntensity.setFloat(this.model.get("ssaoIntensity")),this.checkSsaoEnable()}},{key:"onSsaoBias",value:function(){this._app.postProcessUniform.uSsaoBias.setFloat(this.model.get("ssaoBias"))}},{key:"onSsrFactor",value:function(){this._app.globalUniform.uSsrFactor.setFloat(this.model.get("ssrFactor")),this.checkSsrEnable()}},{key:"getNodeIn",value:function(){return this._nodeIn}},{key:"getNodeOut",value:function(){return this._nodeOut}},{key:"getCamera",value:function(){return this._camera}},{key:"getCurrentComposer",value:function(){return this._nodeIn._composer}},{key:"prepareForScreenShot",value:function(){this._app.globalUniform.uSSAARestart.setFloat(1),this.hideDofCross()}},{key:"resetAfterScreenShot",value:function(){this._app.globalUniform.uSSAARestart.setFloat(0)}}]),e}(),xo="attribute vec3 Vertex;\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\n\nuniform vec4 uHalton;\nuniform vec2 uGlobalTexSize;\nuniform vec2 uGlobalTexRatio;\n\nvarying vec3 vLocalVertex;\n\nvoid main(void)\n{\n vLocalVertex = Vertex.rgb;\n\n mat4 projectionMatrix = uProjectionMatrix;\n vec2 halt = uGlobalTexRatio.xy * uHalton.xy / uGlobalTexSize.xy;\n projectionMatrix[2][0] += halt.x;\n projectionMatrix[2][1] += halt.y;\n\n gl_Position = (projectionMatrix * (uModelViewMatrix * vec4(Vertex, 1.0))).xyww;\n}\n",To='varying vec3 vLocalVertex;\n\n// common stuffs\nuniform int uOutputLinear;\nuniform float uRGBMRange;\n\nuniform float uEnvironmentExposure;\nuniform float uBackgroundExposure;\n\nuniform vec3 uDiffuseSPH[9];\nuniform samplerCube uTexture0;\nuniform float uSize;\nuniform int uAmbient;\n\nuniform float uFrameModTaaSS;\n\n#pragma include "utils/functions.glsl"\n#pragma include "utils/cubemap.glsl"\n#pragma include "utils/rand.glsl"\n\n// sph env\nvec3 evaluateDiffuseSphericalHarmonics(const in vec3 s[9], const in vec3 n) {\n // https://github.com/cedricpinson/envtools/blob/master/Cubemap.cpp#L523\n vec3 result = (s[0]+s[1]*n.y+s[2]*n.z+s[3]*n.x+s[4]*n.y*n.x+s[5]*n.y*n.z+s[6]*(3.0*n.z*n.z-1.0)+s[7]*(n.z*n.x)+s[8]*(n.x*n.x-n.y*n.y));\n return max(result, vec3(0.0));\n}\n\nvoid main(void) {\n\n vec3 color;\n if (uAmbient == 1) {\n vec3 normal = normalize(vLocalVertex + mix(-0.5/255.0, 0.5/255.0, pseudoRandom(gl_FragCoord.xy))*2.0);\n // vec3 normal = normalize(vLocalVertex + (interleavedGradientNoise(gl_FragCoord.xy, uFrameModTaaSS) - 0.5) * 0.4);\n color = evaluateDiffuseSphericalHarmonics(uDiffuseSPH, normal);\n } else {\n color = textureCubeFixed(uTexture0, normalize(vLocalVertex), uSize);\n }\n\n color *= uEnvironmentExposure * uBackgroundExposure;\n\n if (uOutputLinear == 0 ) color = linearTosRGB(color);\n\n gl_FragColor = encodeRGBM(color, uRGBMRange);\n}\n',yo=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(e){var n;return Object(v["a"])(this,r),n=t.call(this),n._geometry=w["default"].createTexturedBoxGeometry(0,0,0,5,5,5),n._show="COLOR",n._bgEnv=null,n._bgFixed=null,n._texRatio=1,n._canvasWidth=1,n._canvasHidth=1,n._app=e,n.init(),n.hide(),n}return Object(S["a"])(r,[{key:"init",value:function(){var e=this._geometry,t=e.getOrCreateStateSet();for(var r in t.setAttributeAndModes(Sr.DEPTH_LEQUAL_BACKGROUND_NO_WRITE,w["default"].StateAttribute.PROTECTED),t.setRenderBinDetails(br.BACKGROUND,"RenderBin"),t.setAttributeAndModes(ei.getOrCreateShader(xo,To,"environment-background","Environment")),t.setTextureAttributeAndModes(0,Ti.dummyTexture),this._app.backgroundUniform)t.addUniform(this._app.backgroundUniform[r]);this.addChild(e)}},{key:"rescale",value:function(e,t){e&&(this._canvasWidth=e),t&&(this._canvasHeight=t);var r=this._canvasWidth/this._canvasHeight,n=this._app.backgroundUniform.scale.getInternalArray();r>=this._texRatio?(n[0]=1,n[1]=this._texRatio/r):(n[0]=r/this._texRatio,n[1]=1)}},{key:"getBackground",value:function(){return this._bgFixed}},{key:"getEnvironment",value:function(){return this._bgEnv}},{key:"hide",value:function(){this._show="NONE",this._update()}},{key:"showColor",value:function(){this._show="COLOR",this._update()}},{key:"showEnvironment",value:function(){this._show="ENV",this._update()}},{key:"setEnvironment",value:function(e,t){this._bgEnv=e,void 0!==t&&this._app.backgroundUniform.size.setFloat(t),this._update()}},{key:"setExposure",value:function(e){this._app.backgroundUniform.backgroundExposure.setFloat(e)}},{key:"showAmbient",value:function(){this._show="AMBIENT",this._update()}},{key:"showBackground",value:function(){this._show="FIXED",this._update()}},{key:"setBackground",value:function(e){this._texRatio=e.getWidth()/e.getHeight(),this._bgFixed=e,this._update()}},{key:"_update",value:function(){this._app._frameManager.draw(),"ENV"===this._show||"AMBIENT"===this._show?(this._geometry.setNodeMask(-1),this._app.backgroundUniform.ambient.getInternalArray()[0]="AMBIENT"===this._show,this._bgEnv&&"ENV"===this._show&&this._geometry.getOrCreateStateSet().setTextureAttributeAndModes(0,this._bgEnv)):this._geometry.setNodeMask(0)}}]),r}(w["default"].Node),Co=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(e,n){var i;return Object(v["a"])(this,r),i=t.call(this),i._textureNull=void 0,i._texture=e,i._channel=n||"Specular",i._isCubemap=!1,i._hash="Specular"===n?"EnvSpec":"SpecularPBR"===n?"EnvSpecPBR":"EnvBRDF",i}return Object(S["a"])(r,[{key:"getUniformName",value:function(e){return"uTextureEnvironment"+this.getChannel()+e}},{key:"getOrCreateUniforms",value:function(){var e=r.uniforms,t=this.getChannel();if(e[t])return e[t];var n=this._texture;return e[t]={size:w["default"].Uniform.createFloat2([n.getWidth(),n.getHeight()],this.getUniformName("TextureSize"))}}},{key:"setIsCubemap",value:function(e){this._isCubemap=e}},{key:"getIsCubemap",value:function(){return this._isCubemap}},{key:"getTexture",value:function(){return this._texture}},{key:"getChannel",value:function(){return this._channel}},{key:"cloneType",value:function(){return new r(new w["default"].Texture)}},{key:"getHash",value:function(){return this._hash}},{key:"updateLodRange",value:function(e){var t=this.getOrCreateUniforms(),r=Math.log(this._texture.getWidth())/Math.LN2,n=r-Math.log(e)/Math.LN2;if(t.lodRange){var i=t.lodRange.getInternalArray();i[0]=r,i[1]=n}else t.lodRange=w["default"].Uniform.createFloat2([r,n],this.getUniformName("LodRange"))}},{key:"apply",value:function(e,t){var r=this._texture;void 0!==r&&r.apply(e);var n=this.getOrCreateUniforms(t).size.getInternalArray();n[0]=r.getWidth(),n[1]=r.getHeight()}},{key:"releaseGLObjects",value:function(){this._texture.releaseGLObjects()}}]),r}(w["default"].Texture);w["default"].objectLibraryClass(Co.prototype,"osgEditor","TextureEnvironment"),w["default"].setTypeID(Co),Co.prototype.attributeType="Texture",Co.prototype.channelType=["Specular","SpecularPBR","IntegrateBRDF"],Co.uniforms={};var Ao=Co,Eo=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(e){var n;Object(v["a"])(this,r),n=t.call(this),n.getOrCreateStateSet(),n._enable=!1,n._app=e,n._isPBR=!1,n._textureSpecular=void 0,n._textureSpecularUnit=Ba.ENV_SPECUAR_TEXTURE_UNIT,n._textureSpecularPBR=void 0,n._textureIntegrateBRDF=void 0,n._textureSpecularPBRUnit=Ba.ENV_SPECUAR_TEXTURE_UNIT,n._textureIntegrateBRDFUnit=Ba.ENV_BRDF_TEXTURE_UNIT,n._nodeBackground=new yo(e),n._adjustRotation=w["default"].mat4.fromXRotation(w["default"].mat4.create(),Math.PI/2),n._root=new w["default"].MatrixTransform,w["default"].mat4.multiply(n._root.getMatrix(),n._root.getMatrix(),n._adjustRotation),n._defaultExposure=1,n._lightProbes=[];var i=n._app._features.lighting.createLight("Environment",3,Oi.DIRECTION);return n._light=i.light,n._mtLight=i.node,n._shadow=i.shadowMap,n._mtLight.addChild(i.lightSource),n._lightIntensity=1,n._lightShadowEnabled=!1,n._shadowBias=.005,n._shadowedScene=void 0,n._lightNodeRoot=new w["default"].MatrixTransform,n._lightNodeRoot.setName("Env Lighting - Light"),w["default"].mat4.copy(n._lightNodeRoot.getMatrix(),n._root.getMatrix()),n._lightNodeRoot.addChild(n._mtLight),n.addUpdateCallback(Object(y["a"])(n)),n}return Object(S["a"])(r,[{key:"getBackground",value:function(){return this._nodeBackground}},{key:"enable",value:function(){this._enable=!0,this.setTexturesStateSet(),this._app._frameManager.draw()}},{key:"disable",value:function(){this._enable=!1,this.removeTexturesStateSet(),this._app._frameManager.draw()}},{key:"setBackgroundExposure",value:function(e){this._nodeBackground.setExposure(e),this._app._frameManager.draw()}},{key:"setBackgroundTexture",value:function(e,t){this._nodeBackground.setEnvironment(e,t),this._app._frameManager.draw()}},{key:"createCameraNode",value:function(){var e={},t=this,r=w["default"].mat4.create(),n=this._app.envUniform.environmentTransform.getInternalArray(),i=new w["default"].Camera;return i.setName("Environment - Camera"),i.setCullCallback(new function(){this.cull=function(i,a){w["default"].mat4.getPerspective(e,t._mainCamera.getProjectionMatrix()),w["default"].mat4.perspective(a.getCurrentProjectionMatrix(),e.fovy*Math.PI/180,e.aspectRatio,1,1e3),w["default"].mat4.copy(a.getCurrentModelViewMatrix(),t._mainCamera.getViewMatrix()),w["default"].mat4.setTranslation(a.getCurrentModelViewMatrix(),w["default"].vec3.ZERO);var o=a.getCurrentModelViewMatrix();return w["default"].mat4.multiply(r,o,t._root.getMatrix()),w["default"].mat3.fromMat4(n,r),w["default"].mat3.transpose(n,n),!0}}),i.setReferenceFrame(w["default"].Transform.ABSOLUTE_RF),this._app.cameraEnvironment=i,i}},{key:"init",value:function(e,t){for(var r in this._mainCamera=e,this._shadowedScene=t,this._shadowedScene.addChild(this._lightNodeRoot),this._app.envUniform)this.getStateSet().addUniform(this._app.envUniform[r]);var n=this.createCameraNode();n.setNodeMask(Tr.NO_PICK_NO_SHADOW),this.addChild(n),n.addChild(this._root),this._root.addChild(this._nodeBackground),this.updateTextureUnits(),this.updateLightShadow()}},{key:"setLightShadowEnabled",value:function(e){this._lightShadowEnabled=e&&M.shadow,this.updateLightShadow()}},{key:"setLightIntensity",value:function(e){this._lightIntensity=e,this.updateLightColorAndIntensity(),this._app._frameManager.draw()}},{key:"setShadowBias",value:function(e){this._shadowBias=e,this._shadow&&(this._shadow.setBias(e),this._shadow.requestRedraw(),this._app._frameManager.draw())}},{key:"setLightProbes",value:function(e){this._lightProbes=e,this.updateLightShadow()}},{key:"removeTexturesStateSet",value:function(){var e=this.getStateSet();e&&(this._isPBR?(this._textureSpecularPBR&&e.removeTextureAttribute(this._textureSpecularPBRUnit,this._textureSpecularPBR.getTypeMember()),this._textureIntegrateBRDF&&e.removeTextureAttribute(this._textureIntegrateBRDFUnit,this._textureIntegrateBRDF.getTypeMember())):this._textureSpecular&&e.removeTextureAttribute(this._textureSpecularUnit,this._textureSpecular.getTypeMember()))}},{key:"setTexturesStateSet",value:function(){var e=this.getStateSet();e&&(this._isPBR?(this._textureSpecularPBR&&e.setTextureAttributeAndModes(this._textureSpecularPBRUnit,this._textureSpecularPBR),this._textureIntegrateBRDF&&e.setTextureAttributeAndModes(this._textureIntegrateBRDFUnit,this._textureIntegrateBRDF)):this._textureSpecular&&e.setTextureAttributeAndModes(this._textureSpecularUnit,this._textureSpecular))}},{key:"updateLightColorAndIntensity",value:function(){if(this._light&&0!==this._lightProbes.length){var e=this._app.envUniform.exposure.getInternalArray()[0]/this._defaultExposure,t=this._lightProbes[0].color;w["default"].vec3.normalize(t,t),w["default"].vec3.scale(this._light.getDiffuse(),t,this._lightIntensity*e)}}},{key:"setDefaultExposure",value:function(e){this._defaultExposure=e}},{key:"setExposure",value:function(e){this._app.envUniform.exposure.setFloat(e),this.updateLightColorAndIntensity()}},{key:"updateLightFromProbes",value:function(){var e=this._lightProbes[0].direction,t=Math.abs(e[2])>.999?w["default"].vec3.fromValues(0,1,0):w["default"].vec3.fromValues(0,0,1),r=this._mtLight.getMatrix();w["default"].mat4.lookAtDirection(r,w["default"].vec3.ZERO,e,t),w["default"].mat4.invert(r,r),this.updateLightColorAndIntensity(),M.debugEnvShadow&&this._debugShadow()}},{key:"_debugShadow",value:function(){if(!this._debugDone){this._debugDone=!0;var e=w["default"].createAxisGeometry(),t=new w["default"].MatrixTransform;t.setMatrix(w["default"].mat4.fromScaling(w["default"].mat4.create(),[100,100,-500])),w["default"].mat4.setTranslation(t.getMatrix(),[0,0,500]),t.addChild(e);var r=new pi.createDirectionalGeometry(5);t.addChild(r),t.setNodeMask(Tr.NO_PICK_NO_SHADOW),this._mtLight.addChild(t)}}},{key:"isUsingLightShadow",value:function(){return this._lightShadowEnabled&&this._lightProbes.length>0}},{key:"updateLightShadow",value:function(){if(this._shadowedScene){var e=this.isUsingLightShadow();if(this._light.setEnabled(e),this._app._features.lighting.removeShadowMap(this._shadowedScene,this._shadow),e){var t=ga();(M.shadowAtlas&&t>12||t>12)&&this._app._features.lighting.addShadowMap(this._shadowedScene,this._shadow),this._shadow.setBias(this._shadowBias),w["default"].mat4.copy(this._lightNodeRoot.getMatrix(),this._root.getMatrix()),this.updateLightFromProbes(),this._shadow.requestRedraw(),this._app._frameManager.draw()}}}},{key:"update",value:function(e,t){if(e.getNumChildrenRequiringUpdateTraversal()>0&&t.traverse(e),!this._light||!this._shadow)return!1;var r=this._app.getFeaturesManager();return r&&r.getShadowForcedUpdate()&&this._shadow.requestRedraw(),!1}},{key:"updateShadow",value:function(){this._light&&this._shadow&&this._shadow.requestRedraw()}},{key:"updateRotation",value:function(e){w["default"].mat4.fromZRotation(this._root.getMatrix(),-e),w["default"].mat4.multiply(this._root.getMatrix(),this._root.getMatrix(),this._adjustRotation),w["default"].mat4.copy(this._lightNodeRoot.getMatrix(),this._root.getMatrix()),this._shadow&&this._shadow.requestRedraw()}},{key:"setDiffuseSPH",value:function(e){for(var t=this._app.envUniform.diffuseSPH.getInternalArray(),r=1/(2*Math.sqrt(Math.PI)),n=-.5*Math.sqrt(3/Math.PI),i=-n,a=n,o=.5*Math.sqrt(15/Math.PI),s=-o,u=.25*Math.sqrt(5/Math.PI),c=s,l=.25*Math.sqrt(15/Math.PI),h=[r,r,r,n,n,n,i,i,i,a,a,a,o,o,o,s,s,s,u,u,u,c,c,c,l,l,l],d=0;d<27;++d)t[d]=e[d]*h[d]}},{key:"setSpecularTexture",value:function(e){this._enable&&(this._textureSpecular=new Ao(e,"Specular"),this._textureSpecular.setIsCubemap(!0),this.updateTextureUnits(),this._app.envUniform.textureSpecular.setInt(this._textureSpecularUnit),this._app._frameManager.draw())}},{key:"setSpecularPBRTexture",value:function(e,t){if(this._enable){this._textureSpecularPBR=new Ao(e,"SpecularPBR");var r="TextureCubeMap"===e.className();this._textureSpecularPBR.setIsCubemap(r),this._textureSpecularPBR.updateLodRange(t),this.updateTextureUnits(),this._app.envUniform.textureSpecularPBR.setInt(this._textureSpecularPBRUnit),this._app._frameManager.draw()}}},{key:"setIntegrateBRDFTexture",value:function(e){this._enable&&(this._textureIntegrateBRDF=new Ao(e,"IntegrateBRDF"),this.updateTextureUnits(),this._app.envUniform.textureIntegrateBRDF.setInt(this._textureIntegrateBRDFUnit),this._app._frameManager.draw())}},{key:"updateTextureUnits",value:function(){this.setTexturesStateSet()}},{key:"setIsPBR",value:function(e){this._isPBR=e}}]),r}(w["default"].Node),Ro=Eo,Mo=w["default"].mat4.create(),wo=w["default"].mat4.create(),No=function(){function e(t){Object(v["a"])(this,e),this._app=t,this._inputManager=this._app.getInputManager(),this._nodeEnvironment=new Ro(this._app),this._nodeEnvironment.setName("Feature - Environment"),this._backgroundLoaded={},this.model=new hi["Model"]({enable:!0,shadowEnable:!0,shadowBias:.0052,lightIntensity:.877,blurLevel:.1,exposure:1,backgroundExposure:1,rotation:0,env:null}),this.model.bind("change:enable",this.onEnableChanged,this),this.model.bind("change:exposure",this.onExposureChanged,this),this.model.bind("change:backgroundExposure",this.onExposureChanged,this),this.model.bind("change:rotation",this.onRotationChanged,this),this.model.bind("updateBackground",this.onBackgroundEnableChanged,this),this.model.bind("change:blur",this.onBlurChanged,this),this.model.bind("change:env",this.onEnvironmentChanged,this),this.model.bind("change",this._app._frameManager.draw.bind(this._app._frameManager)),this._resourceDefer=bi(),this.model.bind("change:shadowEnable",this.onShadowEnable,this),this.model.bind("change:shadowBias",this.onShadowBiasChanged,this),this.model.bind("change:lightIntensity",this.onLightIntensityChanged,this),this.initEnvironment(),this.initRotateEnvironment()}return Object(S["a"])(e,[{key:"getModel",value:function(){return this.model}},{key:"getBackgroundEnableType",value:function(){var e=this._app.getFeatures().background;return e?e.getModel().get("enable"):"none"}},{key:"isBackgroundEnvironment",value:function(){return"environment"===this.getBackgroundEnableType()}},{key:"initEnvironment",value:function(){this.onRotationChanged(),this.onExposureChanged(),this.onEnableChanged()}},{key:"initRotateEnvironment",value:function(){this._app.getViewerOSGJS()&&(this._rotEnv=!1,this.lastCanvasX=0,this._app._featureEventManager.initEnvironment(this))}},{key:"startRotate",value:function(e){this._rotEnv=!0,this.lastCanvasX=e.canvasX,this._inputManager.setEnable(gr.InputGroups.MANIPULATORS,!1)}},{key:"_computeDelta",value:function(e){this._app._frameManager.draw();var t=(e.canvasX-this.lastCanvasX)/100;return this.lastCanvasX=e.canvasX,t}},{key:"rotateEnv",value:function(e,t){if(this._rotEnv){t||(t=this._computeDelta(e));var r=(this.model.get("rotation")+t)%(2*Math.PI);this.model.set("rotation",r<0?r+2*Math.PI:r)}}},{key:"rotateLight",value:function(e,t){if(this._rotEnv){t||(t=this._computeDelta(e));var r=this._app._features.lighting;if(r){var n=this._app.getFeaturesManager().getWorldNode().getMinimumBound().center();w["default"].mat4.fromZRotation(Mo,-t%(2*Math.PI)),w["default"].vec3.negate(n,n),w["default"].mat4.multiply(Mo,Mo,w["default"].mat4.fromTranslation(wo,n)),w["default"].vec3.negate(n,n),w["default"].mat4.multiply(Mo,w["default"].mat4.fromTranslation(wo,n),Mo);for(var i=r.getModel().get("lights"),a=0,o=i.length;a<o;++a)i[a]}}}},{key:"rotateEnvAndLight",value:function(e){if(this._rotEnv){var t=this._computeDelta(e);this.rotateEnv(e,t),this.rotateLight(e,t)}}},{key:"endRotate",value:function(){this._rotEnv&&(this._rotEnv=!1,this._inputManager.setEnable(gr.InputGroups.MANIPULATORS,!0))}},{key:"onUIDChanged",value:function(){this.onEnvironmentChanged(),this.onBackgroundEnableChanged()}},{key:"getRotating",value:function(){return this._rotEnv}},{key:"getNode",value:function(){return this._nodeEnvironment}},{key:"getNodeEnvironment",value:function(){return this._nodeEnvironment}},{key:"getResourceManager",value:function(){return null}},{key:"onEnableChanged",value:function(){this.model.get("enable")?(this._nodeEnvironment.enable(),this._nodeEnvironment.setLightShadowEnabled(this.model.get("shadowEnable")),this._nodeEnvironment.setLightIntensity(this.model.get("lightIntensity")),this._nodeEnvironment.setShadowBias(this.model.get("shadowBias"))):(this._nodeEnvironment.disable(),this._nodeEnvironment.setLightShadowEnabled(!1)),this.onEnvironmentChanged()}},{key:"onShadowEnable",value:function(){var e=this.getEnvironment().lights;this.model.get("shadowEnable")||e&&0!==e.length?this._nodeEnvironment.setLightShadowEnabled(this.model.get("shadowEnable")):this.model.set("shadowEnable",!1)}},{key:"onShadowBiasChanged",value:function(){this._nodeEnvironment.setShadowBias(this.model.get("shadowBias"))}},{key:"onLightIntensityChanged",value:function(){this._nodeEnvironment.setLightIntensity(this.model.get("lightIntensity"))}},{key:"onExposureChanged",value:function(){this._nodeEnvironment.setExposure(this.model.get("exposure")),this._nodeEnvironment.setBackgroundExposure(this.model.get("backgroundExposure"))}},{key:"onRotationChanged",value:function(){this._nodeEnvironment.updateRotation(this.model.get("rotation"))}},{key:"onBlurChanged",value:function(){this.isBackgroundEnvironment()&&this.setBackgroundTexture()}},{key:"onBackgroundEnableChanged",value:function(){var e=this.getBackgroundEnableType();"environment"===e?this.setBackgroundTexture():"ambient"===e&&this.setBackgroundAmbient()}},{key:"onEnvironmentChanged",value:function(){var e=this,t=this.getEnvironment();if(t){var r=this.setEnvironment(t);P.all(r).then((function(){e._resourceDefer.resolve()}))}}},{key:"getEnvironment",value:function(){return this.model.get("env")}},{key:"getName",value:function(){return"Environment3D"}},{key:"setEnvironment",value:function(e){var t=[],r=!0;this._nodeEnvironment.setIsPBR(r),this._nodeEnvironment.setDiffuseSPH(e.diffuseSPH);var n=e.lights||[];return this._nodeEnvironment.setLightProbes(n),this.model.get("shadowEnable")&&(this.model.set("shadowEnable",n.length>0),this._nodeEnvironment.setDefaultExposure(1)),r?this.setEnvironmentPBR(e,t):this.setEnvironmentOld(e,t),this.isBackgroundEnvironment()&&t.push(this.setBackgroundTexture()),t}},{key:"findTexture",value:function(e,t){return e.find((function(e){var r=!0;return t.encoding&&e.encoding!==t.encoding&&(r=!1),t.type&&e.type!==t.type&&(r=!1),t.format&&e.format!==t.format&&(r=!1),r}))}},{key:"setEnvironmentPBR",value:function(e,t){var r=this,n=this._nodeEnvironment,i=e.textures,a=!1;w["default"].WebGLCaps.instance().getWebGLExtension("EXT_shader_texture_lod")&&(a=!0),M.panorama&&(a=!1);var o=this.findTexture(i,{encoding:"luv",type:"specular_ue4",format:a?"cubemap":"panorama"}),s=this.getImageRes(o),u={cubemap:a,panoramaLUV:!a,cubemapLUV:a,size:s.width,minFilter:a?w["default"].Texture.LINEAR_MIPMAP_LINEAR:w["default"].Texture.LINEAR,magFilter:w["default"].Texture.LINEAR,wrapS:w["default"].Texture.CLAMP_TO_EDGE,wrapT:w["default"].Texture.CLAMP_TO_EDGE,transferToGPU:!0,internalFormat:w["default"].Texture.RGBA},c=Ci.getInstance().getOrCreateTexture(s.file,u);c.texture.setFlipY(!a),n.setSpecularPBRTexture(c.texture,o.limitSize);var l=this.getPromiseTexture(c);l.then(n.setSpecularPBRTexture.bind(n,c.texture,o.limitSize)).then((function(){r._app._frameManager.draw()})),t.push(l);var h=ga();if(h>8){o=this.findTexture(i,{type:"brdf_ue4"});s=this.getImageRes(o),u={integrateBRDFLUV:!0,minFilter:w["default"].Texture.NEAREST,magFilter:w["default"].Texture.NEAREST,wrapS:w["default"].Texture.CLAMP_TO_EDGE,wrapT:w["default"].Texture.CLAMP_TO_EDGE,transferToGPU:!0,internalFormat:w["default"].Texture.RGBA};c=Ci.getInstance().getOrCreateTexture(s.file,u);c.texture.setFlipY(!1),n.setIntegrateBRDFTexture(c.texture);l=this.getPromiseTexture(c);l.then(n.setIntegrateBRDFTexture.bind(n,c.texture)),t.push(l)}}},{key:"getBackgroundResource",value:function(e,t,r){var n=this.findTexture(e,{encoding:"luv",type:"background",format:"cubemap"}),i=r?this.getClosestBlur(n,r):this.getImageRes(n,512);return t.cubemap=!0,t.cubemapLUV=!0,t.size=i.width,t.minFilter=w["default"].Texture.LINEAR,t.magFilter=w["default"].Texture.LINEAR,t.wrapS=w["default"].Texture.CLAMP_TO_EDGE,t.wrapT=w["default"].Texture.CLAMP_TO_EDGE,t.transferToGPU=!0,t.internalFormat=w["default"].Texture.RGBA,i}},{key:"setEnvironmentOld",value:function(e,t){}},{key:"setBackgroundTexture",value:function(){var e=this.getEnvironment(),t={},r=this.getBackgroundResource(e["textures"],t),n=this._backgroundLoaded,i=this._nodeEnvironment,a=Ci.getInstance().getOrCreateTexture(r.file,t),o=this.getPromiseTexture(a);return o.then((function(){i.setBackgroundTexture(a.texture,r.width),n[r.file]=a})),o}},{key:"setProgress",value:function(e,t){}},{key:"setBackgroundAmbient",value:function(){var e=this.getEnvironment();return e?(this._nodeEnvironment.setDiffuseSPH(e.diffuseSPH),bi().resolve()):bi().reject(new Error)}},{key:"getPromiseTexture",value:function(e){return e.promise}},{key:"getImageRes",value:function(e,t){return e.images[0]}},{key:"getClosestBlur",value:function(e,t){var r=e.images,n=0,a=1/0;for(i=0,length=r.length;i<length;++i){var o=Math.abs(r[i].blur-t);o<a&&(n=i,a=o)}return r[n]}}]),e}(),Oo=function(){function e(t){Object(v["a"])(this,e),this._app=t,this.model=new hi["Model"]({enable:"color",color:[.93,.93,.93],fixed:null}),this.model.bind("change:enable",this.onEnableChanged,this),this.model.bind("change:fixed",this.onBackgroundChanged,this),this.model.bind("change",this._app._frameManager.draw.bind(this._app._frameManager));var r=t.getFeatures().environment;r&&(this._modelEnvironment=r.getModel(),this._nodeBackground=r.getNodeEnvironment().getBackground(),this._nodeBackground.addUpdateCallback(this),this.onEnableChanged(),this._viewer=t.getViewerOSGJS())}return Object(S["a"])(e,[{key:"getModel",value:function(){return this.model}},{key:"getNode",value:function(){return this._nodeBackground}},{key:"getResourceManager",value:function(){return this._resourceManager||s.Z.instance}},{key:"onBackgroundChanged",value:function(){var e=this.model.get("fixed");if(e)return this.getResources(e)}},{key:"getResources",value:function(e){var t=this,r={minFilter:w["default"].Texture.LINEAR,magFilter:w["default"].Texture.LINEAR,transferToGPU:!0,convertNPOT:!1,internalFormat:w["default"].Texture.RGB},n=Ci.getInstance().getOrCreateTexture(e,r);return n.promise.then((function(){t._nodeBackground.setBackground(n.texture),t._nodeBackground.rescale(t._viewWidth,t._viewHeight),t.model.trigger("backgroundUpdated",n.texture),"fixed"===t.model.get("enable")&&t._nodeBackground.showBackground(),t._app._frameManager.draw()})),n.promise}},{key:"onEnableChanged",value:function(){var e=this.model.get("enable");"color"===e?this._nodeBackground.showColor():"fixed"===e?this._nodeBackground.getBackground()?this._nodeBackground.showBackground():void 0!==this.model.get("fixed")&&this.onBackgroundChanged():"environment"===e?(this._modelEnvironment.trigger("updateBackground"),this._nodeBackground.showEnvironment()):"ambient"===e?(this._modelEnvironment.trigger("updateBackground"),this._nodeBackground.showAmbient()):"none"===e&&this._nodeBackground.hide(),this._resourceDefer&&(this._resourceDefer.resolve(),this._resourceDefer=void 0)}},{key:"requireBiggerTexture",value:function(){return!0}},{key:"update",value:function(){if("fixed"!==this.model.get("enable"))return!0;var e=this._viewer.getCamera().getViewport(),t=e.width(),r=e.height();return this._viewWidth===t&&this._viewHeight===r||(this._viewWidth=t,this._viewHeight=r,!0===this.requireBiggerTexture()&&this.onBackgroundChanged(),this._nodeBackground.rescale(t,r)),!0}}]),e}(),Io=new Uint8Array(18e4),Po=document.createElement("canvas"),Do=document.createElement("canvas"),Lo=function(e,t,r,n){n||(n=Do),Po.width===t&&Po.height===r||(n.width=t,n.height=r,Po.width=t,Po.height=r,Io=new Uint8Array(4*t*r));var i=e.getGraphicContext();if(i.checkFramebufferStatus(i.FRAMEBUFFER)!==i.FRAMEBUFFER_COMPLETE)return console.error("FRAMEBUFFER status invalid.");i.flush(),i.finish(),i.readPixels(0,0,t,r,i.RGBA,i.UNSIGNED_BYTE,Io);var a=Po.getContext("2d"),o=a.getImageData(0,0,t,r);o.data.set(Io),a.putImageData(o,0,0);var s=n.getContext("2d");return s.clearRect(0,0,t,r),s.fillStyle="transparent",s.fillRect(0,0,t,r),s.save(),s.globalCompositeOperation="copy",s.scale(1,-1),s.drawImage(Po,0,0,t,r,0,-r,t,r),s.restore(),n},Fo=function(e){e.getScene().updateSceneGraph(e.getUpdateVisitor());var t=e.getCamera().getRenderer();t.cull(),t.draw()},ko=function(){function e(){Object(v["a"])(this,e)}return Object(S["a"])(e,[{key:"getScreenShot",value:function(e,t,r){var n=r.getSuperSample(),i=r.getViewerOSGJS();e&&t||(e=i.getCanvasWidth(),t=i.getCanvasHeight());var a,o=r.getFeatures(),s=i.getCamera(),u=r.getFeaturesManager().getNodeGizmo();for(var c in u&&u.getNodeMask&&(a=u.getNodeMask(),u.setNodeMask(0)),o)o[c].prepareForScreenShot&&o[c].prepareForScreenShot();if(r.getEventEmitter().trigger("resizeViewer",e,t),i.updateViewport(),r._frameManager.setPoseForScreenshot(!0),i.checkNeedToDoFrame(),Fo(i),s.setFinalDrawCallback((function(r){n.isEnabled()||Lo(r,e,t)})),n.canBeEnabled())for(n.forceEnable();n.isEnabled();)n.updateFrame(),Fo(i);else Fo(i);for(var c in r._frameManager.setPoseForScreenshot(!1),s.setFinalDrawCallback(),o)o[c].resetAfterScreenShot&&o[c].resetAfterScreenShot();return a&&u&&u.setNodeMask(a),r.getEventEmitter().trigger("resizeViewerOnNextFrame",-1,-1),i.updateViewport(),r.getFeatures().postProcess.canvasRatioModel.trigger("change:viewerToCanvasRatio"),Do}}]),e}(),Bo=n("2909"),Uo=(n("c740"),n("0481"),n("4069"),n("2ef0")),Vo=n.n(Uo),Go=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(){var e;return Object(v["a"])(this,r),e=t.call(this),e._attributeEnable=!1,e._hitPoint=w["default"].vec3.create(),e._hitNormal=w["default"].vec3.create(),e}return Object(S["a"])(r,[{key:"getHash",value:function(){return this.getType()+(this.isEnabled?1:0)+this._feature._stickers.length}},{key:"cloneType",value:function(){return new r}},{key:"setEnabled",value:function(e){this._attributeEnable=e}},{key:"isEnabled",value:function(){return this._attributeEnable}},{key:"getOrCreateUniforms",value:function(){var e=r,t=this._feature._stickers.length;if(e.uniforms[t])return e.uniforms[t];var n=e.uniforms[t]={};return n["uHighlight"]=w["default"].Uniform.createFloatArray("uHighlight",t),n["uMat"]=w["default"].Uniform.createMat3Array("uMat",t),n["uT"]=w["default"].Uniform.createMat4Array("uT",t),n["uBoundSphere"]=w["default"].Uniform.createFloat4Array("uBoundSphere",t),n["uPos"]=w["default"].Uniform.createFloat3Array("uPos",t),n["uNormal"]=w["default"].Uniform.createFloat3Array("uNormal",t),n["uVisible"]=w["default"].Uniform.createFloatArray("uVisible",t),n["uAnchors"]=w["default"].Uniform.createFloatArray("uAnchors",8),n}},{key:"apply",value:function(){if(this.isEnabled()&&0!=this._feature._stickers.length){var e=this.getOrCreateUniforms();this._feature._stickers.forEach((function(t,r){var n=e["uHighlight"]._data,i=t.getHighlight();i&&e["uAnchors"]._data.set(t._anchors.flat(1)),n.set([i?1:0],r),n=e["uMat"]._data,n.set(t.getInvTransform(),9*r),n=e["uT"]._data,n.set(t.getInvQuatMat(),16*r),n=e["uBoundSphere"]._data;var a=t.getBoundingSphere();n.set([].concat(Object(Bo["a"])(a.center()),[a.radius()]),4*r),n=e["uPos"]._data,n.set(t.getWorldPos(),3*r),n=e["uNormal"]._data,n.set(t.getWorldNormal(),3*r),n=e["uVisible"]._data,n.set([t.getVisible()?1:0],r)}))}}}]),r}(Ii["a"]);Go.uniforms={},Mi(Go,Go.prototype,"osgEditor","StickerAttribute");var zo=w["default"].vec3.create(),jo=w["default"].vec3.create(),Ho=w["default"].vec3.create(),Wo=w["default"].vec2.create(),Xo=(new w["default"].BoundingSphere,w["default"].mat3.create()),qo=function(){function e(t,r,n,i){var a=Object(m["a"])(n,2),o=a[0],s=a[1];Object(v["a"])(this,e),Object(ma["a"])(this,"rotationTo",function(){var e=w["default"].vec3.create(),t=w["default"].vec3.fromValues(1,0,0),r=w["default"].vec3.fromValues(0,-1,0);return function(n,i,a){var o=w["default"].vec3.dot(i,a);return o<-.999999?(w["default"].vec3.cross(e,t,i),w["default"].vec3.length(e)<1e-6&&w["default"].vec3.cross(e,r,i),w["default"].vec3.normalize(e,e),w["default"].quat.setAxisAngle(n,e,Math.PI),n):o>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(w["default"].vec3.cross(e,i,a),n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=1+o,w["default"].quat.normalize(n,n))}}()),this._state="idle",this._visible=!0,this._id=t,this._highlight=!1,this._invTransform=w["default"].mat3.create(),this._invQuatMat=w["default"].mat4.create(),this._texture=r,this._originalImage=r.getImage().getImage(),this._boundingSphere=new w["default"].BoundingSphere,this._globalBoundingSphere=new w["default"].BoundingSphere,this._globalBoundingSphere.copy(i),this._scale=[1,1],this._mirror=[1,1],this._rotation=0,this._worldPos=w["default"].vec3.create(),this._worldNormal=w["default"].vec3.create(),this._anchors=[[0,1],[1,1],[1,0],[0,0]],this._ref0=w["default"].vec3.copy(w["default"].vec3.create(),o),this._ref1=w["default"].vec3.copy(w["default"].vec3.create(),s),this._useGBP=!1,this._dirty=!0,this._canvas=document.createElement("canvas")}return Object(S["a"])(e,[{key:"toJson",value:function(){var e=this.getInvTransform(),t=this.getInvQuatMat(),r=this.getBoundingSphere(),n=this.getWorldPos(),i=this.getWorldNormal();return{config:{boundingSphere:[].concat(Object(Bo["a"])(r.center()),[r.radius()]),invTransform:e,invQuatMat:t,worldPos:n,worldNormal:i,anchors:this._anchors,ref0:this._ref0,ref1:this._ref1},id:this._id,visible:this._visible,img:this._originalImage.src,scale:this.getScale(),mirror:this.getMirror(),rotation:this.getRotation()}}},{key:"fromJson",value:function(e){var t=e.config,r=t.boundingSphere;this._boundingSphere.set((r[0],r[1],r[2]),r[3]),w["default"].mat3.copy(this._invTransform,t.invTransform),w["default"].mat4.copy(this._invQuatMat,t.invQuatMat),w["default"].vec3.copy(this._worldPos,t.worldPos),w["default"].vec3.copy(this._worldNormal,t.worldNormal),this._anchors=Vo.a.cloneDeep(t.anchors),this._renderWithAnchor(1),w["default"].vec2.copy(this._ref0,t.ref0),w["default"].vec2.copy(this._ref1,t.ref1),w["default"].vec2.copy(this._scale,e.scale),w["default"].vec2.copy(this._mirror,e.mirror),this._rotation=e.rotation,this._dirty=!1,this._visible=e.visible}},{key:"getVisible",value:function(){return this._visible}},{key:"setVisible",value:function(e){this._visible=e}},{key:"setAnchors",value:function(e){this._anchors=e}},{key:"ref0",value:function(){return this._ref0}},{key:"ref1",value:function(){return this._ref1}},{key:"getScale",value:function(){return w["default"].vec2.clone(this._scale)}},{key:"setScale",value:function(e){w["default"].vec2.copy(this._scale,e),this._dirty=!0}},{key:"getMirror",value:function(){return w["default"].vec2.clone(this._mirror)}},{key:"setMirror",value:function(e){w["default"].vec2.copy(this._mirror,e),this._dirty=!0}},{key:"getRotation",value:function(){return this._rotation}},{key:"setRotation",value:function(e){this._rotation=e,this._dirty=!0}},{key:"state",get:function(){return this._state},set:function(e){this._state=e}},{key:"getHighlight",value:function(){return this._highlight}},{key:"getBoundingSphere",value:function(){if(this._useGBP)return this._globalBoundingSphere;var e=this.ref0(),t=this.ref1(),r=w["default"].vec3.create();w["default"].vec3.sub(r,t,e),w["default"].vec3.normalize(r,r);var n,i=this._worldPos,a=w["default"].vec3.dot(w["default"].vec3.subtract(w["default"].vec3.create(),i,e),r);if(a<0)n=e;else{var o=Math.abs(a);n=o>w["default"].vec3.distance(e,t)?t:w["default"].vec3.scaleAndAdd(w["default"].vec3.create(),e,r,o)}var s=w["default"].vec3.distance(n,i);return this._boundingSphere.set(n,s),this._boundingSphere}},{key:"setBoundingSphere",value:function(e){this._boundingSphere.copy(e)}},{key:"setHighlight",value:function(e){this._highlight=e}},{key:"getInvTransform",value:function(){return this.updateInvTransform()}},{key:"_getDynamicScale",value:function(){return 40/w["default"].vec3.length(w["default"].vec3.subtract(zo,this._worldPos,this.getBoundingSphere().center()))}},{key:"updateInvTransform",value:function(){if(!this._dirty)return this._invTransform;this._dirty=!0;var e=Object(m["a"])(this._scale,2),t=e[0],r=e[1],n=this._mirror,i=1,a=1;if(this._originalImage){var o=this._originalImage.width,s=this._originalImage.height;o>s?a=s/o:i=o/s}var u=this._getDynamicScale();t*=n[0]*i*u,r*=n[1]*a*u;var c=this._rotation*Math.PI/180;return w["default"].mat3.identity(this._invTransform),w["default"].mat3.translate(this._invTransform,this._invTransform,[0,.5*Math.PI]),w["default"].mat3.rotate(this._invTransform,this._invTransform,c),w["default"].mat3.scale(this._invTransform,this._invTransform,[t,r]),w["default"].mat3.translate(this._invTransform,this._invTransform,[-.5,-.5]),w["default"].mat3.invert(this._invTransform,this._invTransform),this._invTransform}},{key:"getInvQuatMat",value:function(){return this._invQuatMat}},{key:"getWorldPos",value:function(){return this._worldPos}},{key:"getWorldNormal",value:function(){return this._worldNormal}},{key:"updatePosition",value:function(e,t){w["default"].vec3.copy(this._worldPos,e),w["default"].vec3.copy(this._worldNormal,t),w["default"].vec3.subtract(Ho,e,this.getBoundingSphere().center()),w["default"].vec3.normalize(Ho,Ho);var r=w["default"].quat.create(),n=w["default"].vec3.fromValues(0,0,1),i=w["default"].vec3.fromValues(1,0,0),a=w["default"].vec3.cross(w["default"].vec3.create(),Ho,n),o=w["default"].vec3.cross(w["default"].vec3.create(),i,a),s=w["default"].vec3.fromValues(Ho[0],Ho[1],0);w["default"].vec3.normalize(s,s),this.rotationTo(r,i,s);var u=this.rotationTo(w["default"].quat.create(),s,Ho);w["default"].quat.multiply(r,u,r);var c=w["default"].vec3.dot(i,Ho),l=Math.acos(c);o[2]<0&&(l=2*Math.PI-l,w["default"].vec3.negate(o,o)),w["default"].mat4.fromQuat(this._invQuatMat,r),w["default"].mat4.invert(this._invQuatMat,this._invQuatMat),this.updateInvTransform()}},{key:"getUV",value:function(e,t){return w["default"].vec3.normalize(t,t),e[0]=Math.atan2(t[1],t[0]),e[1]=Math.PI-Math.acos(t[2]),e}},{key:"transferToUVSpace",value:function(e){var t=this.getBoundingSphere(),r=w["default"].vec3.subtract(w["default"].vec3.create(),e,t.center()),n=w["default"].vec3.transformMat4(r,r,this._invQuatMat);return this.getUV(Wo,n),w["default"].vec2.transformMat3(Wo,Wo,this._invTransform),Wo}},{key:"selectAndActiveAnchor",value:function(e){var t=this.transferToUVSpace(e),r=w["default"].vec2.create(),n=this._anchors.findIndex((function(e){return w["default"].vec2.length(w["default"].vec2.sub(r,t,e))<.08}));return this._activeAnchor=n,this._activeAnchor}},{key:"render",value:function(){var e,t,r,n,i,a,o,s,u=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,c=this._originalImage,l=this._corners,h=function(e,t,r){return[e[0]+(t[0]-e[0])*r,e[1]+(t[1]-e[1])*r]},d=c.width-1,f=c.height-1,_=this._canvas;_.width=d,_.height=f;var p=_.getContext("2d");p.clearRect(0,0,_.width,_.height);for(var g=0;g<f;g+=u)for(var m=0;m<d;m+=u)i=h(l[0],l[3],g/f),a=h(l[1],l[2],g/f),o=h(l[0],l[3],(g+u)/f),s=h(l[1],l[2],(g+u)/f),e=h(i,a,m/d),t=h(i,a,(m+u)/d),r=h(o,s,(m+u)/d),n=h(o,s,m/d),p.drawImage(c,m,g,u,u,e[0],e[1],Math.ceil(Math.max(u,Math.abs(t[0]-e[0]),Math.abs(n[0]-r[0])))+1,Math.ceil(Math.max(u,Math.abs(e[1]-n[1]),Math.abs(t[1]-r[1])))+1);this._texture.setImage(_)}},{key:"_renderWithAnchor",value:function(e){var t=this._texture.getWidth(),r=this._texture.getHeight();this._corners=this._anchors.map((function(e){return[e[0]*t,(1-e[1])*r]})),this.render(e)}},{key:"updateAnchor",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(-1!=this._activeAnchor){var r=this.transferToUVSpace(e),n=Object(m["a"])(r,2),i=n[0],a=n[1];w["default"].vec2.copy(this._anchors[this._activeAnchor],[i,a]),this._renderWithAnchor(t)}}}]),e}(),Yo=4,Ko=function(){function e(t){Object(v["a"])(this,e),this._app=t,this._app._featureEventManager.initSticker(this),this._previousDraggingPoint=w["default"].vec3.create(),this._stickerTextures=[],this._stickerAttribute=new Go,this._stickerAttribute.setEnabled(!0),this._app.getRootModel().getOrCreateStateSet().setAttributeAndModes(this._stickerAttribute),this._uHighlight=w["default"].Uniform.createFloat("uHighlight"),this._boundingSphere=new w["default"].BoundingSphere,this._uMat=w["default"].Uniform.createMat3("uMat"),this._uT=w["default"].Uniform.createMat4("uT"),this._invTransform=w["default"].mat3.create(),this._invQuatMat=w["default"].mat4.create(),this._selected=!1,this._enable=!0,this._stickers=[],this._stickerAttribute._feature=this,this._activeSticker=null,this._maximumSelectedNum=1,this._setupStickersByModelsBound=this.setup.bind(this)}return Object(S["a"])(e,[{key:"setHighlight",value:function(e){this._uHighlight.setFloat(e?1:0)}},{key:"calculateReferPoints",value:function(){var e=this._app.getRootModel().getBoundingBox(),t=e.yMax()-e.yMin(),r=(e.xMax(),e.xMin(),e.zMax()-e.zMin()),n=w["default"].vec3.create(),i=w["default"].vec3.create();return n.set([0,0-.05*t,t/10]),i.set([0,0+.4*t,e.zMin()+r-.3*t]),[n,i]}},{key:"setup",value:function(e){var t=this,r=e.map((function(e){return e.img.url})),n=r.map((function(e){return Ci.getInstance().loadImage(e,{})}));Promise.all(n).then((function(r){t._stickers=r.map((function(r,n){var i=e[n],a=i.config,o=t._createTexture();o.setImage(r);var s=new qo(i.id,o,[a.ref0,a.ref1],t._app.getRootModel().getBoundingSphere());return s.fromJson(i),s})),t._updateStickerSlot()}))}},{key:"isInUnitSquare",value:function(e){var t=Object(m["a"])(e,2),r=t[0],n=t[1];return 0<=r&&r<=1&&0<=n&&n<=1}},{key:"pick",value:function(e,t,r,n){var i=this._app.pick(e,t,(function(){}),!0);if(!i)return!1;var a=w["default"].computeLocalToWorld(i._nodePath);return w["default"].mat3.normalFromMat4(Xo,a),w["default"].vec3.transformMat4(r,i._localIntersectionPoint,a),w["default"].vec3.transformMat3(n,i._localIntersectionNormal,Xo),!0}},{key:"getStickers",value:function(){return this._stickers}},{key:"getStickerById",value:function(e){return this._stickers.find((function(t){return t._id==e}))}},{key:"removeSticker",value:function(e){var t=this._stickers.findIndex((function(t){return t._id===e}));return t>-1&&(this._stickers.splice(t,1),this._updateStickerSlot(),!0)}},{key:"_createTexture",value:function(){var e={minFilter:w["default"].Texture.LINEAR,magFilter:w["default"].Texture.LINEAR,internalFormat:w["default"].Texture.RGBA},t=new w["default"].Texture;return t.setMinFilter(e.minFilter),t.setMagFilter(e.magFilter),e.minFilter===w["default"].Texture.LINEAR_MIPMAP_LINEAR&&e.anisotropy&&t.setMaxAnisotropy(16),t.setInternalFormat(e.internalFormat),t}},{key:"_updateStickerSlot",value:function(){for(var e=0;e<this._stickers.length;e++){var t=this._stickers[e]._texture;this._app.getRootModel().getOrCreateStateSet().setTextureAttributeAndModes(Ba.STICKER_TEXTURE_UNIT+e,t)}}},{key:"updateStickerPosition",value:function(e,t,r){var n=w["default"].vec3.create(),i=w["default"].vec3.create(),a=this.pick(t,r,n,i);return!!a&&(e.updatePosition(n,i),!0)}},{key:"addSticker",value:function(e){var t=this,r=e.id,n=e.img,i=e.x,a=e.y;if(!(this._stickers.length>=Yo)){var o=w["default"].vec3.create(),s=w["default"].vec3.create(),u=this.pick(i,a,o,s);if(!u)return!1;var c=this.getStickerById(r);return c?(console.error("existed sticker id"),!1):(Ci.getInstance().loadImage(n,{}).then((function(e){var n=t._createTexture();n.setImage(e);var i=new qo(r,n,t.calculateReferPoints(),t._app.getRootModel().getBoundingSphere());i.updatePosition(o,s),t._stickers.push(i),t._updateStickerSlot(),t._app.redraw()})),!0)}}},{key:"doubleclick",value:function(e){}},{key:"hitStickersByPos",value:function(e){for(var t=[],r=0;r<this._stickers.length;r++){var n=this._stickers[r],i=n.transferToUVSpace(e);this.isInUnitSquare(i)&&t.push(n)}return t}},{key:"setActiveSticker",value:function(e){e&&!e.getVisible()||(this._activeSticker&&this._activeSticker.setHighlight(!1),this._activeSticker=e,this._activeSticker&&e.setHighlight(!0),this._app.emit("StickerFeature:ActiveSticker",e?e._id:null),this._app.redraw())}},{key:"singleclick",value:function(e,t){var r=this.pick(e.canvasX,e.canvasY,zo,jo,Ho);if(r){var n=this.hitStickersByPos(zo);n.length>0&&this.setActiveSticker(n[0])}else this.setActiveSticker(null);this._app.redraw()}},{key:"mousedown",value:function(e){if(this._enable&&this._activeSticker){var t=this.pick(e.canvasX,e.canvasY,zo,jo,Ho);if(t){var r=this._activeSticker.selectAndActiveAnchor(zo);if(r>-1)this._activeSticker.state="dragging_anchor";else{var n=this.hitStickersByPos(zo);if(-1==n.indexOf(this._activeSticker))return;this._activeSticker.state="dragging"}this.enableManipulator(!1),w["default"].vec3.copy(this._previousDraggingPoint,zo)}}}},{key:"mouseup",value:function(e,t){this._activeSticker&&this._activeSticker.state.indexOf("dragging")>-1&&("dragging_anchor"==this._activeSticker.state&&this._activeSticker.render(1),this._activeSticker.state="idle",this.enableManipulator(!0),this._app.redraw())}},{key:"enableManipulator",value:function(e){var t,r=null===(t=this._app)||void 0===t?void 0:t._switchManipulator;r.getCurrentManipulator().setEnable(e)}},{key:"mousemove",value:function(e,t){if(this._activeSticker&&"idle"!=this._activeSticker.state){var r=this.pick(e.canvasX,e.canvasY,zo,jo);r&&("dragging"==this._activeSticker.state?this._activeSticker.updatePosition(zo,jo):"dragging_anchor"==this._activeSticker.state&&(this._app.emit("StickerFeature:DraggingAnchor",this._activeSticker._id),this._activeSticker.updateAnchor(zo,8),this._app.redraw()),this._app.redraw())}}}]),e}(),Jo=n("b507"),Zo=n("3d8f"),Qo={},$o=function(e,t,r,n,i,a){var o=r[0],s=r[r.length-1];return a.start=o,a.keys=t,a.end=s,a.times=r,a.type=e,a.duration=s-o,a.target=n,a.name=i,a},es=function(e,t,r,n,i){return $o(Zo["a"].Vec3,e,t,r,n,i||{})},ts=function(e,t,r,n,i){return $o(Zo["a"].Float,e,t,r,n,i||{})},rs=function(e,t,r,n,i){return $o(Zo["a"].Quat,e,t,r,n,i||{})},ns=function(e,t,r,n,i){return $o(Zo["a"].QuatSlerp,e,t,r,n,i||{})},is=function(e,t,r,n,i){return $o(Zo["a"].FloatCubicBezier,e,t,r,n,i||{})},as=function(e,t,r,n,i){return $o(Zo["a"].Vec3CubicBezier,e,t,r,n,i||{})},os={create:function(){return 0}},ss={create:function(){return F["f"].create32()}},us={create:function(){return F["d"].create32()}},cs=function(e,t){return{channel:t,value:e.create(),targetID:Jo["a"].InvalidTargetID,weight:1,key:0,start:0,end:0}},ls=function(e){return cs(ss,e)},hs=function(e){return cs(us,e)},ds=function(e){return cs(os,e)},fs=function(e){return cs(os,e)},_s=function(e){return cs(ss,e)},ps=function(e){return Qo[e.type](e)};Qo.createInstanceChannel=ps,Qo.createInstanceVec3Channel=ls,Qo.createInstanceQuatChannel=hs,Qo.createInstanceQuatSlerpChannel=hs,Qo.createInstanceFloatChannel=ds,Qo.createInstanceFloatCubicBezierChannel=fs,Qo.createInstanceVec3CubicBezierChannel=_s,Qo.createVec3Channel=es,Qo.createQuatChannel=rs,Qo.createQuatSlerpChannel=ns,Qo.createFloatChannel=ts,Qo.createFloatCubicBezierChannel=is,Qo.createVec3CubicBezierChannel=as,Qo[Zo["a"].Vec3]=ls,Qo[Zo["a"].Quat]=hs,Qo[Zo["a"].QuatSlerp]=hs,Qo[Zo["a"].Float]=ds,Qo[Zo["a"].FloatCubicBezier]=fs,Qo[Zo["a"].Vec3CubicBezier]=_s,Qo.ChannelType=Zo["a"];var gs=Qo,ms=0,vs=function(e,t){for(var r=1/0,n=-1/0,i=0;i<e.length;i++)r=Math.min(r,e[i].start),n=Math.max(n,e[i].end);var a=n-r,o=t||"animation"+ms.toString();return ms++,{channels:e,duration:a,name:o,start:r}},bs=function(e){for(var t=[],r=0;r<e.channels.length;r++){var n=gs.createInstanceChannel(e.channels[r]);t.push(n)}return{channels:t,duration:e.duration,start:0,name:e.name,firstKeyTime:e.start}},Ss=function(){};Ss.createAnimation=vs,Ss.createInstanceAnimation=bs;var xs=Ss,Ts=n("19cf"),ys=n("2a3f"),Cs=function(e,t,r){r[0]=t[e++],r[1]=t[e++],r[2]=t[e++]},As=function(e,t,r){r[0]=t[e++],r[1]=t[e++],r[2]=t[e++],r[3]=t[e++]},Es=function(e,t){var r=t.channel,n=t.value,i=r.keys,a=r.times;if(e>=a[a.length-1])return t.key=0,void Cs(i.length-3,i,n);if(e<=a[0])return t.key=0,void Cs(0,i,n);var o=t.key;if(e>a[o])while(a[o+1]<e)o++;else if(e<a[o])while(a[o]>e)o--;var s=a[o],u=a[o+1],c=3*o,l=i[c++],h=i[c++],d=i[c++],f=i[c++],_=i[c++],p=i[c++],g=(e-s)/(u-s);n[0]=l+(f-l)*g,n[1]=h+(_-h)*g,n[2]=d+(p-d)*g,t.key=o},Rs=function(){var e=F["d"].create32(),t=F["d"].create32();return function(r,n){var i=n.channel,a=n.value,o=i.keys,s=i.times;if(r>=s[s.length-1])return n.key=0,void As(o.length-4,o,a);if(r<=s[0])return n.key=0,void As(0,o,a);var u=n.key;if(r>s[u])while(s[u+1]<r)u++;else if(r<s[u])while(s[u]>r)u--;var c=s[u],l=s[u+1],h=4*u;e[0]=o[h++],e[1]=o[h++],e[2]=o[h++],e[3]=o[h++],t[0]=o[h++],t[1]=o[h++],t[2]=o[h++],t[3]=o[h++];var d=(r-c)/(l-c);F["d"].nlerp(a,e,t,d),n.key=u}}(),Ms=function(){var e=F["d"].create32(),t=F["d"].create32();return function(r,n){var i=n.channel,a=n.value,o=i.keys,s=i.times;if(r>=s[s.length-1])return n.key=0,void As(o.length-4,o,a);if(r<=s[0])return n.key=0,void As(0,o,a);var u=n.key;if(r>s[u])while(s[u+1]<r)u++;else if(r<s[u])while(s[u]>r)u--;var c=s[u],l=s[u+1],h=4*u;e[0]=o[h++],e[1]=o[h++],e[2]=o[h++],e[3]=o[h++],t[0]=o[h++],t[1]=o[h++],t[2]=o[h++],t[3]=o[h++];var d=(r-c)/(l-c);F["d"].slerp(a,e,t,d),n.key=u}}(),ws=function(e,t){var r=t.channel,n=t.value,i=r.keys,a=r.times;if(e>=a[a.length-1])return t.key=0,void(t.value=i[i.length-1]);if(e<=a[0])return t.key=0,void(t.value=i[0]);var o=t.key;if(e>a[o])while(a[o+1]<e)o++;else if(e<a[o])while(a[o]>e)o--;var s=a[o],u=a[o+1],c=o,l=i[c++],h=i[c++],d=(e-s)/(u-s);n=l+(h-l)*d,t.key=o,t.value=n},Ns=function(e,t){var r=t.channel,n=t.value,i=r.keys,a=r.times;if(e>=a[a.length-1])return t.key=0,void(t.value=i[i.length-3]);if(e<=a[0])return t.key=0,void(t.value=i[0]);var o=t.key;if(e>a[o])while(a[o+1]<e)o++;else if(e<a[o])while(a[o]>e)o--;var s=(e-a[o])/(a[o+1]-a[o]),u=1-s,c=u*u,l=c*u,h=s*s,d=3*o,f=i[d]*l,_=i[d+1]*(3*s*c),p=i[d+2]*(3*h*u),g=i[d+3]*(h*s);n=f+_+p+g,t.key=o,t.value=n},Os=function(){var e=F["f"].create(),t=F["f"].create(),r=F["f"].create(),n=F["f"].create();return function(i,a){var o=a.channel,s=a.value,u=o.keys,c=o.times;if(i>=c[c.length-1])return a.key=0,void Cs(u.length-9,u,s);if(i<=c[0])return a.key=0,void Cs(0,u,s);var l=a.key;if(i>c[l])while(c[l+1]<i)l++;else if(i<c[l])while(c[l]>i)l--;var h=(i-c[l])/(c[l+1]-c[l]),d=1-h,f=d*d,_=f*d,p=h*h,g=9*l;F["f"].scale(e,F["f"].set(e,u[g++],u[g++],u[g++]),_),F["f"].scale(t,F["f"].set(t,u[g++],u[g++],u[g++]),3*h*f),F["f"].scale(r,F["f"].set(r,u[g++],u[g++],u[g++]),3*p*d),F["f"].scale(n,F["f"].set(n,u[g++],u[g++],u[g++]),p*h),s[0]=e[0]+t[0]+r[0]+n[0],s[1]=e[1]+t[1]+r[1]+n[1],s[2]=e[2]+t[2]+r[2]+n[2],a.key=l}}(),Is=gs.ChannelType,Ps={};Ps[Is.Vec3]=Es,Ps[Is.Quat]=Rs,Ps[Is.QuatSlerp]=Ms,Ps[Is.Float]=ws,Ps[Is.FloatCubicBezier]=Ns,Ps[Is.Vec3CubicBezier]=Os,Ps.Vec3LerpInterpolator=Es,Ps.QuatLerpInterpolator=Rs,Ps.QuatSlerpInterpolator=Ms,Ps.FloatLerpInterpolator=ws,Ps.FloatCubicBezierInterpolator=Ns,Ps.Vec3CubicBezierInterpolator=Os;var Ds=Ps,Ls=function(){Wr["a"].call(this),this._animationUpdateCallback={}};j["a"].createPrototypeObject(Ls,j["a"].objectInherit(Wr["a"].prototype,{getAnimationUpdateCallbackMap:function(){return this._animationUpdateCallback},apply:function(e){for(var t=e.getUpdateCallbackList(),r=0,n=t.length;r<n;r++){var i=t[r];i instanceof ys["a"]&&(this._animationUpdateCallback[i.getInstanceID()]=i)}this.traverse(e)}}),"osgAnimation","CollectAnimationUpdateCallbackVisitor");var Fs=Ls,ks=n("fce7"),Bs=n("6b61"),Us=n("ae6a"),Vs={lerp:function(e,t,r){return e+(t-e)*r},init:function(){return 0},copy:function(e,t){return t},create:function(){return 0}},Gs=[];Gs[gs.ChannelType.Float]=1,Gs[gs.ChannelType.FloatCubicBezier]=1,Gs[gs.ChannelType.Vec3]=3,Gs[gs.ChannelType.Vec3CubicBezier]=3,Gs[gs.ChannelType.Quat]=4,Gs[gs.ChannelType.QuatSlerp]=4,Gs[gs.ChannelType.Matrix]=16;var zs=[];zs.length=gs.ChannelType.Count,zs[gs.ChannelType.Vec3]=F["f"],zs[gs.ChannelType.Quat]=F["d"],zs[gs.ChannelType.QuatSlerp]=F["d"],zs[gs.ChannelType.Float]=Vs,zs[gs.ChannelType.FloatCubicBezier]=Vs,zs[gs.ChannelType.Vec3CubicBezier]=F["f"],zs[gs.ChannelType.Matrix]=F["c"];var js=function(){Ki["a"].call(this),this._simulationTime=0,this._pauseTime=0,this._timeFactor=1,this._startTime=0,this._instanceAnimations={},this._startAnimations={},this._targets=[],this._targetsMap={},this._targetsByTypes=[],this._targetsByTypes.length=gs.ChannelType.Count;for(var e=0,t=this._targetsByTypes.length;e<t;e++)this._targetsByTypes[e]=[];this._activeAnimations={},this._activeAnimationList=[],this._activeChannelsByTypes=[],this._activeChannelsByTypes.length=gs.ChannelType.Count;for(var r=0,n=this._activeChannelsByTypes.length;r<n;r++)this._activeChannelsByTypes[r]=[];this._animationsUpdateCallback={},this._animationsUpdateCallbackArray=[],this._animationsToRegister=[],this._pause=!1,this._dirty=!1,this._seekTime=-1};j["a"].createPrototypeObject(js,j["a"].objectInherit(Ki["a"].prototype,{init:function(e){this._simulationTime=0,this._pauseTime=0,this._timeFactor=1,this._startTime=0,this._instanceAnimations={},this._startAnimations={},this._resetTargets(),this._activeAnimations={},this._activeAnimationList.length=0;for(var t=0,r=this._activeChannelsByTypes.length;t<r;t++)this._activeChannelsByTypes[t].length=0;this._animationsUpdateCallback={},this._animationsUpdateCallbackArray.length=0,this._pause=!1,this._seekTime=-1,this.addAnimations(e)},addAnimations:function(e){var t=this._addAnimation(e);Array.prototype.push.apply(this._animationsToRegister,t),this._dirty=!0,this._registerAnimations()},update:function(e,t){this._dirty&&(this._findAnimationUpdateCallback(e),this._registerTargetFoundInAnimationCallback(),this._registerAnimations());var r=t.getFrameStamp().getSimulationTime();return-1!==this._seekTime&&(this._pauseTime=-this._seekTime+this._startTime+r),this._seekTime=-1,this._pause?this._pauseTime=r-this._simulationTime+this._startTime:this._simulationTime=this._startTime+(r-this._pauseTime),this.updateManager(this._simulationTime*this._timeFactor),!0},updateManager:function(e){this._processStartAnimation(e);for(var t=gs.ChannelType.Count,r=0;r<t;r++){var n=this._activeChannelsByTypes[r];this._updateChannelsType(e,n,Ds[r])}for(var i=0;i<t;i++){var a=this._targetsByTypes[i];this._updateTargetType(a,zs[i])}for(var o=0,s=this._animationsUpdateCallbackArray.length;o<s;o++){var u=this._animationsUpdateCallbackArray[o];u.computeChannels()}this._removeFinishedAnimation(e)},togglePause:function(){this._pause=!this._pause,this._pause||(this._seekTime=this._simulationTime)},getSimulationTime:function(){return this._simulationTime},setSimulationTime:function(e){this._simulationTime=e},setSeekTime:function(e){this._simulationTime=e,this._seekTime=e},stopAnimation:function(e){for(var t=this._activeAnimationList,r=0,n=t.length;r<n;++r)if(t[r].name===e)return this._removeActiveChannels(this._instanceAnimations[e]),this._activeAnimations[e]=void 0,void t.splice(r,1)},stopAllAnimation:function(){for(var e=this._activeAnimationList,t=0,r=e.length;t<r;++t){var n=e[t].name;this._removeActiveChannels(this._instanceAnimations[n]),this._activeAnimations[n]=void 0}e.length=0},setTimeFactor:function(e){var t=e/this._timeFactor;this._startTime+=(this._simulationTime-this._simulationTime*t)/t,this._timeFactor=e,this._pause&&(this._simulationTime+=(this._simulationTime-this._simulationTime*t)/t)},getTimeFactor:function(){return this._timeFactor},isPlaying:function(e){return!!this._activeAnimations[e]},playAnimationObject:function(e){var t=this._instanceAnimations[e.name];t?this.isPlaying(e.name)||(t.priority=void 0===e.priority?0:e.priority,t.weight=void 0===e.weight?1:e.weight,t.loop=void 0===e.loop||e.loop,this._startAnimations[t.name]=t):L["a"].info("no animation "+e.name+" found")},playAnimation:function(e,t,r,n){var i;return i="object"===Object(Oe["a"])(e)?e:{name:e,priority:r,weight:n,loop:t},this.playAnimationObject(i)},getAnimations:function(){return this._instanceAnimations},_registerAnimations:function(){if(this._targets.length){for(var e=0,t=this._animationsToRegister.length;e<t;e++){var r=this._animationsToRegister[e];this._registerInstanceAnimation(r)}this._animationsToRegister.length=0,this._dirty=!1}},_registerInstanceAnimation:function(e){for(var t=e.channels,r=0,n=t.length;r<n;r++){var i=t[r],a=i.channel.target,o=i.channel.name,s=a+"."+o;this._targetMap[s]?i.targetID=this._targetMap[s].id:L["a"].warn("registerInstanceAnimation did not find targetName ("+s+") in the scene graph")}return!0},_findAnimationUpdateCallback:function(e){var t=new Fs;e.accept(t),this._animationsUpdateCallback=t.getAnimationUpdateCallbackMap()},_registerTargetFoundInAnimationCallback:function(){this._resetTargets();var e,t,r,n=0,i=this._targetMap,a=this._targets,o=function(e,t){if(i[e])t!==i[e]&&L["a"].warn("detected differents target instance with the same name ("+e+")");else{i[e]=t,t.id=n++,a.push(t);var r=t.type;this._targetsByTypes[r].push(t)}}.bind(this);for(var s in this._animationsUpdateCallback){var u=this._animationsUpdateCallback[s];if(u instanceof Us["a"]||u instanceof Bs["a"]){var c=u.getStackedTransforms(),l=c.length;if(!l)continue;this._animationsUpdateCallbackArray.push(u);for(var h=0;h<l;h++){var d=c[h];e=d.getTarget(),t=d.getName(),r=u.getName()+"."+t,o(r,e,t)}}else if(u instanceof ks["a"]){var f=u.getNumTarget();if(!f)continue;this._animationsUpdateCallbackArray.push(u);for(var _=0;_<f;_++)t=u.getTargetName(_),r=t+"."+_,e=u.getTarget(_),o(r,e,t)}}},_addAnimation:function(e){for(var t=[],r=0,n=e.length;r<n;r++){var i=e[r],a=i.name;if(!this._instanceAnimations[a]){var o=xs.createInstanceAnimation(i);this._instanceAnimations[a]=o,t.push(o)}}return t},_addActiveChannels:function(e,t){for(var r=t.channels,n=0,i=r.length;n<i;n++){var a=r[n],o=a.channel.type;a.t=e,a.instanceAnimation=t;var s=a.targetID;s!==Jo["a"].InvalidTargetID&&(this._activeChannelsByTypes[o].push(a),this._targets[s].channels.push(a))}},_removeActiveChannels:function(e){for(var t=e.channels,r=0,n=t.length;r<n;r++){var i=t[r],a=i.channel.type,o=i.targetID;if(o!==Jo["a"].InvalidTargetID){var s=this._targets[o].channels,u=s.indexOf(i);s.splice(u,1);var c=this._activeChannelsByTypes[a],l=c.indexOf(i);c.splice(l,1)}}},_updateTargetType:function(e,t){for(var r=0,n=e.length;r<n;r++){var i=e[r],a=i.channels,o=a.length;if(0===o)i.value=t.copy(i.value,i.defaultValue);else if(1===o)i.value=t.copy(i.value,a[0].value);else{i.value=t.init(i.value);for(var s=0,u=0,c=a.length;u<c;u++){var l=a[u],h=l.weight;if(s+=h,0!==s&&0!==h){var d=h/s;i.value=t.lerp(i.value,i.value,l.value,d)}}}}},_updateChannelsType:function(e,t,r){for(var n=0,i=t.length;n<i;n++){var a=t[n],o=a.instanceAnimation,s=o.loop,u=e-a.t;s&&o.duration>0&&(u%=o.duration),r(u+o.firstKeyTime,a)}},_removeFinishedAnimation:function(e){var t=this._activeAnimationList,r=0;while(r<t.length){var n=t[r],i=n.name;e>n.end&&!1===n.loop?(this._removeActiveChannels(n),this._activeAnimations[i]=void 0,t.splice(r,1)):r++}},_addActiveAnimation:function(e,t){this._activeAnimations[t.name]=t;var r=this._instanceAnimations[t.name];r.start=e,r.end=e+r.duration,this._addActiveChannels(e,r),this._activeAnimationList.push(r)},_processStartAnimation:function(e){if(this._targets.length){var t;for(t in this._startAnimations){var r=this._startAnimations[t],n=r.name;this.isPlaying(n)||this._addActiveAnimation(e,r)}void 0!==t&&(this._startAnimations={})}},_resetTargets:function(){this._targetMap={},this._targets.length=0;for(var e=0,t=this._targetsByTypes.length;e<t;e++)this._targetsByTypes[e].length=0},resetUpdateCallbacks:function(){for(var e=this._animationsUpdateCallbackArray,t=0,r=e.length;t<r;t++)e[t].reset()},resetAllStackedTransforms:function(){L["a"].warn("Uses resetUpdateCallback instead"),this.resetUpdateCallbacks()},setAnimationLerpEndStart:function(e,t){var r=e.channels;void 0===e.originalDuration&&(e.originalDuration=e.duration),e.duration=e.originalDuration+t;for(var n=e.firstKeyTime,i=e.originalDuration,a=0,o=r.length;a<o;++a){var s=r[a].channel;if(!(Math.abs(s.start-n)>.01||Math.abs(s.duration-i)>.01)){void 0===s.originalEnd&&(s.originalEnd=s.end),s.end=s.originalEnd+t;var u=Gs[s.type],c=s.times.buffer.byteLength/4;if(0===t)s.keys=new Float32Array(s.keys.buffer,0,(c-1)*u),s.times=new Float32Array(s.times.buffer,0,c-1);else{s.keys=new Float32Array(s.keys.buffer,0,c*u);for(var l=(c-1)*u,h=0;h<u;++h)s.keys[l+h]=s.keys[h];s.times=new Float32Array(s.times.buffer,0,c),s.times[c-1]=s.times[c-2]+t}}}}}),"osgAnimation","BasicAnimationManager"),js.TypeToSize=Gs;var Hs=js,Ws=n("00cd");function Xs(e){return e}function qs(e){return e*e}function Ys(e){return e*e*e}function Ks(e){return e*e*e*e}function Js(e){return e*e*e*e*e}function Zs(e){return e*e*e*e*e*e}function Qs(e){return e*e*e*e*e*e*e}function $s(e){return e*e*e*e*e*e*e*e}function eu(e){var t=e-1;return 1-t*t}function tu(e){var t=e-1;return 1+t*t*t}function ru(e){var t=e-1;return 1-t*t*t*t}function nu(e){var t=e-1;return 1+t*t*t*t*t}function iu(e){var t=e-1;return 1-t*t*t*t*t*t}function au(e){var t=e-1;return 1+t*t*t*t*t*t*t}function ou(e){var t=e-1;return 1-t*t*t*t*t*t*t*t}function su(e){var t=e-1,r=2*e;return r<1?e*r:1-t*t*2}function uu(e){var t=e-1,r=2*e;return r<1?e*r*r:1+t*t*t*4}function cu(e){var t=e-1,r=2*e;return r<1?e*r*r*r:1-t*t*t*t*8}function lu(e){var t=e-1,r=2*e;return r<1?e*r*r*r*r:1+t*t*t*t*t*16}function hu(e){var t=e-1,r=2*e;return r<1?e*r*r*r*r*r:1-t*t*t*t*t*t*32}function du(e){var t=e-1,r=2*e;return r<1?e*r*r*r*r*r*r:1+t*t*t*t*t*t*t*64}function fu(e){var t=e-1,r=2*e;return r<1?e*r*r*r*r*r*r*r:1-t*t*t*t*t*t*t*t*128}function _u(e){var t=1.70158;return e*e*(e*(t+1)-t)}function pu(e){var t=e-1,r=2*e,n=2.5949095;return e<.5?e*r*(r*(n+1)-n):1+2*t*t*(2*t*(n+1)+n)}function gu(e){var t=e-1,r=1.70158;return 1+t*t*(t*(r+1)+r)}function mu(e){return 1-Math.sqrt(1-e*e)}function vu(e){var t=e-1,r=2*e;return r<1?.5*(1-Math.sqrt(1-r*r)):.5*(Math.sqrt(1-4*t*t)+1)}function bu(e){var t=e-1;return Math.sqrt(1-t*t)}function Su(e){return-1*Math.pow(2,10*e)*Math.sin(2*(e-1-.075)*Math.PI/.3)}function xu(e){return Math.pow(2,-10*e)*Math.sin((e-.075)*(2*Math.PI)/.3)+1}function Tu(e){return(e*=2)<1?1*Math.pow(2,10*e)*-.5*Math.sin(2*(e-1-.45)*Math.PI/.45):1*Math.pow(2,-10*(e-=1))*Math.sin(2*(e-.45)*Math.PI/.45)*.5+1}function yu(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375}function Cu(e){return(e=1-e)<1/2.75?1-7.5625*e*e:e<2/2.75?1-(7.5625*(e-=1.5/2.75)*e+.75):e<2.5/2.75?1-(7.5625*(e-=2.25/2.75)*e+.9375):1-(7.5625*(e-=2.625/2.75)*e+.984375)}function Au(e){var t;return e<.5?(t=!0,e=1-2*e):e=2*e-1,e<1/2.75?e*=7.5625*e:e=e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375,t?.5*(1-e):.5*e+.5}var Eu={easeLinear:Xs,easeOutQuad:eu,easeInQuad:qs,easeInOutQuad:su,easeOutCubic:tu,easeInCubic:Ys,easeInOutCubic:uu,easeOutQuart:ru,easeInQuart:Ks,easeInOutQuart:cu,easeOutQuintic:nu,easeInQuintic:Js,easeInOutQuintic:lu,easeOutSextic:iu,easeInSextic:Zs,easeInOutSextic:hu,easeOutSeptic:au,easeInSeptic:Qs,easeInOutSeptic:du,easeOutOctic:ou,easeInOctic:$s,easeInOutOctic:fu,easeOutBack:gu,easeInBack:_u,easeInOutBack:pu,easeOutCircle:bu,easeInCircle:mu,easeInOutCircle:vu,easeOutElastic:xu,easeInElastic:Su,easeInOutElastic:Tu,easeOutBounce:yu,easeInBounce:Cu,easeInOutBounce:Au},Ru=n("05ec"),Mu=n("9874"),wu=n("e74e"),Nu=n("f991"),Ou=function(e,t){Ki["a"].call(this),this._target=Jo["a"].createMatrixTarget(t||F["c"].IDENTITY),e&&this.setName(e)};j["a"].createPrototypeObject(Ou,j["a"].objectInherit(Ki["a"].prototype,{init:function(e){this.setMatrix(e),F["c"].copy(this._target.defaultValue,e)},getTarget:function(){return this._target},getMatrix:function(){return this._target.value},setMatrix:function(e){F["c"].copy(this._target.value,e)},resetToDefaultValue:function(){this.setMatrix(this._target.defaultValue)},applyToMatrix:function(e){F["c"].mul(e,e,this._target.value)}}),"osgAnimation","StackedMatrix");var Iu=Ou,Pu=F["d"].create(),Du=function(e,t){Ki["a"].call(this),this._target=Jo["a"].createQuatTarget(t||Pu),e&&this.setName(e)};j["a"].createPrototypeObject(Du,j["a"].objectInherit(Ki["a"].prototype,{init:function(e){this.setQuaternion(e),F["d"].copy(this._target.defaultValue,e)},setQuaternion:function(e){F["d"].copy(this._target.value,e)},getTarget:function(){return this._target},resetToDefaultValue:function(){this.setQuaternion(this._target.defaultValue)},applyToMatrix:function(){var e=F["c"].create();return function(t){var r=e;F["c"].fromQuat(r,this._target.value),F["c"].mul(t,t,r)}}()}),"osgAnimation","StackedQuaternion");var Lu=Du,Fu=function(e,t,r){Ki["a"].call(this),this._axis=F["f"].fromValues(0,0,1),t&&F["f"].copy(this._axis,t),this._target=Jo["a"].createFloatTarget("number"===typeof r?r:0),e&&this.setName(e)};j["a"].createPrototypeObject(Fu,j["a"].objectInherit(Ki["a"].prototype,{init:function(e,t){this.setAxis(e),this.setAngle(t),this._target.defaultValue=t},setAxis:function(e){F["f"].copy(this._axis,e)},setAngle:function(e){this._target.value=e},getTarget:function(){return this._target},resetToDefaultValue:function(){this.setAngle(this._target.defaultValue)},applyToMatrix:function(){var e=F["c"].create(),t=F["d"].create();return function(r){var n=this._axis,i=t,a=e,o=this._target.value;F["d"].setAxisAngle(i,n,o),F["c"].fromQuat(a,i),F["c"].mul(r,r,a)}}()}),"osgAnimation","StackedRotateAxis");var ku=Fu,Bu=function(e,t){Ki["a"].call(this),this._target=Jo["a"].createVec3Target(t||F["f"].ONE),e&&this.setName(e)};j["a"].createPrototypeObject(Bu,j["a"].objectInherit(Ki["a"].prototype,{init:function(e){this.setScale(e),F["f"].copy(this._target.defaultValue,e)},setScale:function(e){F["f"].copy(this._target.value,e)},getTarget:function(){return this._target},resetToDefaultValue:function(){this.setScale(this._target.defaultValue)},applyToMatrix:function(e){var t=this._target.value;F["c"].scale(e,e,t)}}),"osgAnimation","StackedScale");var Uu=Bu,Vu=function(e,t){Ki["a"].call(this),this._target=Jo["a"].createVec3Target(t||F["f"].ZERO),e&&this.setName(e)};j["a"].createPrototypeObject(Vu,j["a"].objectInherit(Ki["a"].prototype,{init:function(e){this.setTranslate(e),F["f"].copy(this._target.defaultValue,e)},setTranslate:function(e){F["f"].copy(this._target.value,e)},getTarget:function(){return this._target},resetToDefaultValue:function(){this.setTranslate(this._target.defaultValue)},applyToMatrix:function(e){F["c"].translate(e,e,this._target.value)}}),"osgAnimation","StackedTranslate");var Gu=Vu,zu=n("fbe0"),ju={};j["a"].objectMix(ju,Eu),j["a"].objectMix(ju,Ds),ju.Animation=xs,ju.SkinningAttribute=Ts["a"],ju.AnimationUpdateCallback=ys["a"],ju.BasicAnimationManager=Hs,ju.Bone=Ws["a"],ju.Channel=gs,ju.CollectAnimationUpdateCallbackVisitor=Fs,ju.MorphAttribute=Ru["a"],ju.MorphGeometry=Mu["a"],ju.RigGeometry=wu["a"],ju.Skeleton=Nu["a"],ju.StackedMatrix=Iu,ju.StackedQuaternion=Lu,ju.StackedRotateAxis=ku,ju.StackedScale=Uu,ju.StackedTranslate=Gu,ju.UpdateBone=Bs["a"],ju.UpdateMatrixTransform=Us["a"],ju.UpdateMorph=ks["a"],ju.UpdateSkeleton=zu["a"];var Hu=ju,Wu=function(e){for(var t=0,r=e.length;t<r;++t){var n,i=e[t];if(i instanceof Hu.Bone)n=Hu.UpdateBone;else{if(!(i instanceof w["default"].MatrixTransform))continue;n=Hu.UpdateMatrixTransform}for(var a=i.getUpdateCallbackList(),o=0;o<a.length;++o)if(a[o]instanceof n)return!0}return!1},Xu=Xn.ComposerPostProcess,qu=function(){function e(t){Object(v["a"])(this,e),this._path=t}return Object(S["a"])(e,[{key:"update",value:function(t){return t.setMatrix(w["default"].computeLocalToWorld(this._path)),e}}]),e}(),Yu=w["default"].StateAttribute.OVERRIDE_ON,Ku=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(e){var n;Object(v["a"])(this,r),n=t.call(this),n._app=e,n._viewerOSGJS=e.getViewerOSGJS(),n._durationOutline=5e3,n._timerOutline=void 0,n._durationHighlight=5e3,n._timerHighlight=void 0,n._nodeProxy=new w["default"].Node,n._nodeProxy.setName("Outline Node Proxy"),n._outlineScene=new w["default"].Node,n._outlineScene.setName("Outline Scene Node"),n._paths=void 0,n._cbHideHighlight=n.hideHighlight.bind(Object(y["a"])(n)),n._cbHideOutline=n.hideOutline.bind(Object(y["a"])(n));var i=Sr.DEPTH_DISABLE;return n._stateSetSelection=new w["default"].StateSet,n._uColorSelection=w["default"].Uniform.createFloat3("uOutlineColor"),n._stateSetSelection.addUniform(n._uColorSelection),n._stateSetSelection.setAttributeAndModes(i,Yu),n._stateSetHover=new w["default"].StateSet,n._uColorHover=w["default"].Uniform.createFloat3("uOutlineColor"),n._stateSetHover.addUniform(n._uColorHover),n._stateSetHover.setAttributeAndModes(i,Yu),n._uOutlineFactor=w["default"].Uniform.createFloat(.25,"uOutlineFactor"),n._uHighlightFactor=w["default"].Uniform.createFloat(0,"uHighlightFactor"),n._uLineWidth=w["default"].Uniform.createFloat(1,"uLineWidth"),n.init(),n}return Object(S["a"])(r,[{key:"getComposer",value:function(){return this._composer}},{key:"setColorSelection",value:function(e){w["default"].vec3.copy(this._uColorSelection.getInternalArray(),e)}},{key:"setColorHover",value:function(e){w["default"].vec3.copy(this._uColorHover.getInternalArray(),e)}},{key:"setDurationHighlight",value:function(e){this._durationHighlight=e}},{key:"setDurationOutline",value:function(e){this._durationOutline=e}},{key:"setOutlineWidth",value:function(e){this._uLineWidth.getInternalArray()[0]=e}},{key:"showOutline",value:function(){this._nodeProxy.setNodeMask(Tr.NO_PICK_NO_SHADOW),this._clearTimeoutOutline(),this._durationOutline>=0&&(this._timerOutline=setTimeout(this._cbHideOutline,this._durationOutline)),this._uHighlightFactor.setFloat(0!==this._durationHighlight?.15:0),this._clearTimeoutHighlight(),this._durationHighlight>=0&&this._durationHighlight<this._durationOutline&&(this._timerHighlight=setTimeout(this._cbHideHighlight,this._durationHighlight)),this._app._frameManager.draw()}},{key:"hideOutline",value:function(){this._nodeProxy.setNodeMask(0),this._clearTimeoutOutline(),this.hideHighlight(),this._app._frameManager.draw()}},{key:"hideHighlight",value:function(){this._uHighlightFactor.setFloat(0),this._clearTimeoutHighlight(),this._app._frameManager.draw()}},{key:"_clearTimeoutOutline",value:function(){void 0!==this._timerOutline&&(clearTimeout(this._timerOutline),this._timerOutline=void 0)}},{key:"_clearTimeoutHighlight",value:function(){void 0!==this._timerHighlight&&(clearTimeout(this._timerHighlight),this._timerHighlight=void 0)}},{key:"clearOutlineScene",value:function(){for(var e=this._outlineScene,t=e.getChildren(),r=0,n=t.length;r<n;++r){var i=t[r];i.getChildren()[0].removeChildren(),i.removeChildren()}e.removeChildren()}},{key:"_getMaterialNode",value:function(e){var t=e.getStateSet();return t&&t.getAttribute("PBRMaterial")?t:void 0}},{key:"_getLastMaterialPath",value:function(e,t){for(var r=t||0,n=e.length-1;n>=r;--n){var i=this._getMaterialNode(e[n]);if(i)return i}}},{key:"addPaths",value:function(e,t){for(var r=this._outlineScene,n=t?this._stateSetHover:this._stateSetSelection,i=0,a=e.length;i<a;++i){var o=e[i],s=new w["default"].MatrixTransform,u=new w["default"].Node;r.addChild(s),s.addChild(u);var c=o[o.length-1];u.addChild(c),s.setStateSet(n),this._getMaterialNode(c)||u.setStateSet(this._getLastMaterialPath(o)),Wu(o)?s.addUpdateCallback(new qu(o)):s.setMatrix(w["default"].computeLocalToWorld(o))}}},{key:"addPathsHover",value:function(e){this.addPaths(e,!0)}},{key:"createSubSceneRtt",value:function(e){var t=new w["default"].Camera;t.setName("Outline Camera"),t.setClearColor(w["default"].vec4.create()),t.setRenderOrder(w["default"].Camera.PRE_RENDER,0),t.attachTexture(w["default"].FrameBufferObject.COLOR_ATTACHMENT0,e);var r=t.getOrCreateStateSet();return r.setShaderGeneratorName("outline",Yu),t}},{key:"init",value:function(){var e=Sr.CULL_DISABLE;this._outlineScene.getOrCreateStateSet().setAttributeAndModes(e,Yu);var t=this._createComposer();this._composer=t;var r=t.getInternalTexture("TextureOutline"),n=this.createSubSceneRtt(r);this._cameraRtt=n,n.addChild(this._outlineScene),this._nodeProxy.addChild(n),this._nodeProxy.addChild(t),this.addChild(this._nodeProxy),this._nodeProxy.setNodeMask(0)}},{key:"_createComposer",value:function(){var e=new Xu,t=this._viewerOSGJS;e.setMethodWrapUV(1,1),e.setScreenSize(t.getCanvasWidth(),t.getCanvasHeight()),e.setFinalPassUpScaleToScreen(!1),e.addInternalTexture({name:"TextureOutline",immuable:!0,srgb:!0,rgbm:!1}),e.build({func:"outline",textures:["TextureOutline"],uniforms:[this._uOutlineFactor,this._uHighlightFactor,this._uLineWidth],out:{name:"%next"}});var r=e.getStateSetPass("outline"),n=Sr.BLEND_SUBSTRACTIVE;return r.setAttributeAndModes(n),r.setRenderBinDetails(br.OUTLINE,"RenderBin"),this._app.getEventEmitter().on("resizeCanvas",e.resize.bind(e)),this._app.getEventEmitter().on("resizeRatio",e.resizeRatio.bind(e)),e}}]),r}(w["default"].Node),Ju=new w["default"].BoundingBox,Zu=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(e){var n;return Object(v["a"])(this,r),n=t.call(this),n._paths=[],n.setStateSet(e),n}return Object(S["a"])(r,[{key:"reset",value:function(){w["default"].ComputeBoundsVisitor.prototype.reset.call(this),this._pushIfGeo=!1,this._paths.length=0,this._bonesBoxMatrix={},this._usedBones={}}},{key:"setStateSet",value:function(e){this.reset(),this._stateSet=e}},{key:"getBoundingBox",value:function(){for(var e in this._usedBones){var t=this._bonesBoxMatrix[e];t&&(Ju.copy(t.box),Ju.transformMat4(Ju,t.matrix),this._bb.expandByBoundingBox(Ju))}return this._bb}},{key:"apply",value:function(e){var t=e.getStateSet(),r=this._pushIfGeo;if(t&&(this._pushIfGeo=t===this._stateSet),this._pushIfGeo&&e instanceof w["default"].Geometry&&(this._paths.push(this.nodePath.slice(0)),e instanceof Hu.RigGeometry)){var n=e.getBoneNameID();for(var i in n)this._usedBones[i]=1}w["default"].ComputeBoundsVisitor.prototype.apply.call(this,e),this._pushIfGeo=r}},{key:"pushMatrix",value:function(e){var t=this.nodePath[this.nodePath.length-1];if(t instanceof Hu.Bone){var r=t.getBoneBoundingBox();r.valid()&&(this._bonesBoxMatrix[t.getName()]={matrix:w["default"].mat4.clone(e),box:r})}w["default"].ComputeBoundsVisitor.prototype.pushMatrix.call(this,e)}},{key:"applyBoundingBox",value:function(e){this._pushIfGeo&&w["default"].ComputeBoundsVisitor.prototype.applyBoundingBox.call(this,e)}}]),r}(w["default"].ComputeBoundsVisitor),Qu=new Zu,$u=function(){function e(t){Object(v["a"])(this,e),this._viewer=t,this._viewerOSGJS=this._viewer.getViewerOSGJS();var r=new hi["Model"]({colorHover:[1,0,0],outlineWidth:2,colorSelection:[1,1,0],durationOutline:2e3,durationHighlight:2e3});this.model=r,r.on("change:colorSelection",this.onColorSelectionChanged,this),r.on("change:colorHover",this.onColorHoverChanged,this),r.on("change:outlineWidth",this.onOutlineWiddthChanged,this),r.on("hideOutline",this.onHideOutline,this),r.on("hideHighlight",this.onHideHighlight,this),r.on("clearFocusTimeout",this.onClearFocusTimeout,this),this._nodeOutline=new Ku(this._viewer),this._nodeOutline.setName("Feature - Outline"),this.onColorSelectionChanged(),this.onColorHoverChanged(),this.onOutlineWiddthChanged(),this.model.on("displayOutlineFocus",this._onMaterialChange.bind(this,!0)),this.model.on("displayOutlineNoFocus",this._onMaterialChange.bind(this,!1))}return Object(S["a"])(e,[{key:"getNode",value:function(){return this._nodeOutline}},{key:"getNodeOutline",value:function(){return this._nodeOutline}},{key:"onColorSelectionChanged",value:function(){this._nodeOutline.setColorSelection(this.model.get("colorSelection"))}},{key:"onColorHoverChanged",value:function(){this._nodeOutline.setColorHover(this.model.get("colorHover"))}},{key:"onOutlineWiddthChanged",value:function(){this._nodeOutline.setOutlineWidth(this.model.get("outlineWidth"))}},{key:"onHideOutline",value:function(){this._nodeOutline.hideOutline()}},{key:"onHideHighlight",value:function(){this._nodeOutline.hideHighlight()}},{key:"onClearFocusTimeout",value:function(){this._timer&&(window.clearTimeout(this._timer),this._timer=void 0)}},{key:"_focusOnBound",value:function(e){var t=this._viewer.getFeaturesManager(),r=e.getBoundingBox(),n=this._nodeOutline;this.onClearFocusTimeout(),this._timer=window.setTimeout((function(){t.focusOnBound(r,1)||t.focusOnHomePosition(1),n.showOutline()}),200)}},{key:"_onMaterialChange",value:function(e,t,r){var n=this._viewer.getFeaturesManager();if(n){Qu.setStateSet(t||r),n.getRootModel().accept(Qu);var i=Qu._paths;0!==i.length?(e&&this._focusOnBound(Qu),this._nodeOutline.clearOutlineScene(),t?(this._nodeOutline.addPaths(i),r&&(Qu.setStateSet(r),n.getRootModel().accept(Qu),this._nodeOutline.addPathsHover(Qu._paths))):this._nodeOutline.addPathsHover(i),this._nodeOutline.setDurationOutline(this.model.get("durationOutline")),this._nodeOutline.setDurationHighlight(this.model.get("durationHighlight")),e||this._nodeOutline.showOutline()):w["default"].warn()}}},{key:"prepareForScreenShot",value:function(){return this.getNode().hideOutline(),!1}}]),e}(),ec=function(){function e(){Object(v["a"])(this,e),this.mFrame=-1,this.duration=0,this.poseForScreenShot=!1,this.viewer=null,this.preTick=w["default"].Timer.instance().tick(),this.frameTimeAverage=40,this.shadowForcedUpdate=!1,this.superSample=null,window.setTimeout(this.SuperSampleTrigger.bind(this),this.frameTimeAverage)}return Object(S["a"])(e,[{key:"SuperSampleTrigger",value:function(){if(window.setTimeout(this.SuperSampleTrigger.bind(this),this.frameTimeAverage),this.viewer&&this.superSample&&!this.poseForScreenShot&&!this.viewer._requestRedraw){if(w["default"].Timer.instance().tick()-this.preTick-this.frameTimeAverage<=this.frameTimeAverage)return;this.superSample.enable(),this.mFrame=-1}}},{key:"_drawImpl",value:function(e){if(this.viewer&&!this.poseForScreenShot){var t=this.viewer._requestRedraw;if(t||this.viewer.requestRedraw(),this.superSample&&!e&&(this.superSample.reset(),!t)){var r=w["default"].Timer.instance().tick();this.duration+=r-this.preTick,0===++this.mFrame?(this.mFrame=0,this.duration=0):4===this.mFrame&&(this.frameTimeAverage=Math.min(200,Math.max(16,this.duration/this.mFrame)),this.mFrame=0,this.duration=0),this.preTick=r}}}},{key:"setPoseForScreenshot",value:function(e){this.poseForScreenShot=e}},{key:"draw",value:function(){this._drawImpl()}},{key:"drawNoJitter",value:function(){this._doJitter=!1,this._drawImpl()}},{key:"drawSameFrame",value:function(){this._drawImpl(!0)}},{key:"redrawShadow",value:function(){this.shadowForcedUpdate=!0,this._drawImpl()}},{key:"redrawShadowNextFrame",value:function(){window.setTimeout(this.redrawShadow.bind(this),0)}},{key:"getShadowForcedUpdate",value:function(){return this.shadowForcedUpdate}},{key:"setShadowForcedUpdate",value:function(e){this.shadowForcedUpdate=e}},{key:"setViewer",value:function(e){this.viewer=e}},{key:"setSuperSample",value:function(e){this.superSample=e}},{key:"getSuperSample",value:function(){return this.superSample}},{key:"getFrameTimeAverage",value:function(){return this.frameTimeAverage}}]),e}(),tc=(n("2af1"),[[.263385,-.0252475],[-.38545,.054485],[-.139795,-.5379925],[-.2793775,.6875475],[.7139025,.4710925],[.90044,-.16422],[.4481775,-.82799],[-.9253375,-.2910625],[.3468025,1.02292],[-1.13742,.33522],[-.7676225,-.9123175],[-.2005775,-1.1774125],[-.926525,.96876],[1.12909,-.7500325],[.9603,1.14625]]),rc=function(){function e(t){Object(v["a"])(this,e),this._canBeEnabled=!0,this._app=t,this._sampleCount=15,this._isFakeSupersampling=!1,this._isSupersampling=!1,this._frameNum=1,this._frameNumTaa=0,this._switch=!0,this._jitter=this._app.globalUniform.uHalton.getInternalArray(),this._jitter[2]=1}return Object(S["a"])(e,[{key:"getSampleCount",value:function(){return this._sampleCount}},{key:"canBeEnabled",value:function(){return this._canBeEnabled}},{key:"getSortedJitterTable",value:function(){return tc}},{key:"getBackgroundModel",value:function(){return this._app.getFeatures().background.getModel()}},{key:"getAnimationModel",value:function(){return this._app.getFeatures().animation.getModel()}},{key:"getWireframeAttenuation",value:function(){var e=this._app.getOrCreateScene().getWireframeNodes();if(!e.length||0===e[0].getNodeMask())return 1;var t=e[0].getStateSet().getUniform("uColor").getInternalArray()[3];return 1-t+.05*t}},{key:"updateUniforms",value:function(e,t){var r=e%this._sampleCount,n=this.getSortedJitterTable()[r],i=t?.05:1;this._jitter[0]=n[0]*i,this._jitter[1]=n[1]*i,this._jitter[3]=r}},{key:"setSwitch",value:function(e){this._switch=e}},{key:"isTaaJitter",value:function(){return!1}},{key:"updateFrame",value:function(){if(this._jitter[2]=-this._jitter[2],this._app.getEventEmitter().trigger("pingPongTexture0",this._jitter[2]>0),!this._isSupersampling)return this._jitter[2]=Math.sign(this._jitter[2]),this._app._frameManager._doJitter&&this.isTaaJitter()?(this.updateUniforms(this._frameNumTaa,!0),this._frameNumTaa++):(this._jitter[0]=0,this._jitter[1]=0,this._frameNum=1,this._frameNumTaa=0),this._app._frameManager._doJitter=!0,!1;this._app._frameManager._doJitter=!0;var e=this._frameNum%this._sampleCount;return this.updateUniforms(e),this._frameNum++,this.isSupersampled()&&(this._isSupersampling=!1),this._isFakeSupersampling=!1,this._isSupersampling}},{key:"getFrameNumber",value:function(){return this._frameNum%this._sampleCount}},{key:"update",value:function(e,t){if(!this._switch)return!0;var r=t.getFrameStamp().getFrameNumber();return this._lastUpdateFrame===r||(this._lastUpdateFrame=r,!this._postProcess&&(this._postProcess=this._app.getFeatures().postProcess,!this._postProcess)||(this.updateFrame()&&this._app._frameManager.drawSameFrame(),!0))}},{key:"isSupersampled",value:function(){return this._frameNum>=this._sampleCount}},{key:"isEnabled",value:function(){return this._isSupersampling}},{key:"isFakeEnabled",value:function(){return this._isFakeSupersampling}},{key:"forceEnable",value:function(){this._isSupersampling=!0,this._jitter[0]=0,this._jitter[1]=0,this._jitter[2]=2*Math.sign(this._jitter[2]),this._jitter[3]=0,this._frameNum=1,this._app._frameManager.drawSameFrame()}},{key:"enable",value:function(){if(!this.canBeEnabled())return!!this._isFakeSupersampling||(this._app._frameManager.drawSameFrame(),this._isFakeSupersampling=!0);1===this._frameNum&&this.forceEnable()}},{key:"reset",value:function(){this._jitter[2]=Math.sign(this._jitter[2]),this._frameNum=1,this._isSupersampling=!1,this._isFakeSupersampling=!1}},{key:"setRoot",value:function(e){var t=new w["default"].Node;e.addChild(t),t.addUpdateCallback(this)}}]),e}(),nc=n("c489"),ic=function(e){me.call(this,e),this._timer=!1},ac=10,oc=200;j["a"].createPrototypeObject(ic,j["a"].objectInherit(me.prototype,{_initInputs:function(){me.prototype._initInputs.call(this,ne.CAD_MANIPULATOR_MOUSEKEYBOARD,ne.CAD_MANIPULATOR_RESETTOHOME);var e=this._manipulator.getInputManager();e.group(ne.CAD_MANIPULATOR_MOUSEKEYBOARD).addMappings({savePosition:"mousemove"},this)},zoom:function(e){var t=-e.deltaY/this._zoomFactor,r=this._manipulator,n=r.getZoomInterpolator().getTarget()[0]-t;if(r.getZoomInterpolator().setTarget(n),!1===this._timer){this._timer=!0;var i=this;this._timerRef&&clearTimeout(this._timerRef),this._timerRef=setTimeout((function(){i._timer=!1}),oc),r.computeIntersections(e.glX,e.glY)}},savePosition:function(e){this._lastX=e.glX,this._lastY=e.glY},setMode:function(e,t,r){this._inMotion||this._manipulator.computeIntersections(this._lastX,this._lastY),me.prototype.setMode.call(this,e,t,r)},center:function(e){var t=this._manipulator;t.getZoomInterpolator().set(0);var r=t.getZoomInterpolator().getTarget()[0]-ac;t.getZoomInterpolator().setTarget(r),t.computeIntersections(e.glX,e.glY)}}));var sc=ic,uc=function(e){_e.call(this,e),this._timer=!1};j["a"].createPrototypeObject(uc,j["a"].objectInherit(_e.prototype,{_initInputs:function(){_e.prototype._initInputs.call(this,ne.CAD_MANIPULATOR_TOUCH)},startMotion:function(e,t,r){_e.prototype.startMotion.call(this,e,t,r),this._manipulator.computeIntersections(r.glX,r.glY)}}));var cc=uc,lc=function(e){$.call(this,e),this._tmpHomePosition=F["f"].create(),this._intersectionVisitor=new nt["a"],this._lineSegmentIntersector=new it["a"],this._polytopeIntersector=void 0,this._usePolytopeIntersector=!1,this._primitiveMask=Hn["a"].ALL_PRIMITIVES,this.init()};lc.Interpolator=function(){this._current=F["e"].create(),this._target=F["e"].create(),this._delta=F["e"].create(),this._reset=!1,this.reset(),this._width=void 0,this._height=void 0},lc.Interpolator.prototype={setWidth:function(e){this._width=e},setHeight:function(e){this._height=e},reset:function(){for(var e=0,t=this._current.length;e<t;e++)this._current[e]=this._target[e]=0;this._reset=!0},update:function(){var e,t;return e=void 0===this._width?0:(this._target[0]-this._current[0])/this._width,this._delta[0]=e,this._current[0]=this._target[0],t=void 0===this._height?0:(this._target[1]-this._current[1])/this._height,this._delta[1]=t,this._current[1]=this._target[1],this._delta},set:function(){for(var e=0,t=this._current.length;e<t;e++)this._current[e]=this._target[e]=arguments[e];this._reset=!1},isReset:function(){return this._reset},getCurrent:function(){return this._current},setTarget:function(){for(var e=0,t=this._target.length;e<t;e++)this._reset?this._target[e]=this._current[e]=arguments[e]:this._target[e]=arguments[e];this._reset=!1},addTarget:function(){for(var e=0;e<arguments.length;e++)this._target[e]+=arguments[e]},getTarget:function(){return this._target},getDelta:function(){return this._delta}},lc.AvailableControllerList=["StandardMouseKeyboard","Hammer"],lc.ControllerList=["StandardMouseKeyboard","Hammer"],j["a"].createPrototypeObject(lc,j["a"].objectInherit($.prototype,{init:function(){this._distance=25,this._target=F["f"].create(),this._upz=F["f"].fromValues(0,0,1),this._right=F["f"].fromValues(1,0,0),F["f"].init(this._target);var e=F["c"].fromRotation(F["c"].create(),-Math.PI,this._upz),t=F["c"].fromRotation(F["c"].create(),Math.PI/10,this._right);this._rotation=F["c"].create(),F["c"].mul(this._rotation,e,t),this._time=0,this._rotate=new lc.Interpolator,this._pan=new lc.Interpolator,this._zoom=new ye(1),this._panFactor=1.5,this._rotateFactor=1,this._zoomFactor=1,this._inverseMatrix=F["c"].create(),this._homeEye=void 0,this._homeCenter=void 0,this._homeUp=F["f"].fromValues(0,0,1),this._orientation=F["d"].create(),this._pivotPoint=F["f"].create(),this._eye=void 0,this._zoomDir=F["f"].create();var r=this;lc.ControllerList.forEach((function(e){void 0!==lc[e]&&(r._controllerList[e]?r._controllerList[e].init():r._controllerList[e]=new lc[e](r))}))},setViewer:function(e){this._viewer=e},reset:function(){this.init()},setEnable:function(e){this.getInputManager().setEnable(ne.CAD_MANIPULATOR,e)},setNode:function(e){this._node=e},setPivotPoint:function(e){F["f"].copy(this._pivotPoint,e)},setTarget:function(){var e=F["f"].create();return function(t){F["f"].copy(this._target,t),this.getEyePosition(e),this._distance=F["f"].distance(t,e)}}(),setEyePosition:function(e){F["f"].copy(this._eye,e),this._distance=F["f"].distance(this._target,e)},setHomePosition:function(e,t,r){this._homeEye=e,this._homeCenter=t,this._homeUp=r},computeHomePosition:function(){var e=F["f"].create(),t=F["f"].create(),r=F["f"].create(),n=F["c"].create();return function(i){var a=this.getHomeBoundingSphere(i);if(a){this.setDistance(this.getHomeDistance(a)),this.setTarget(a.center()),this.setPivotPoint(a.center()),void 0===this._homeEye&&(this._homeEye=F["f"].create(),this.getEyePosition(this._homeEye)),void 0===this._homeCenter&&(this._homeCenter=F["f"].create(),F["f"].copy(this._homeCenter,a.center())),void 0===this._eye&&(this._eye=F["f"].create()),F["f"].copy(this._eye,this._homeEye),F["f"].copy(this._target,this._homeCenter),F["f"].copy(this._upz,this._homeUp),F["c"].copy(n,this._rotation);var o=this._target,s=this._eye;F["f"].sub(e,o,s),F["f"].normalize(e,e),F["f"].cross(t,e,this._upz),F["f"].normalize(t,t),F["f"].cross(r,t,e),F["f"].normalize(r,r),n[0]=t[0],n[1]=r[0],n[2]=-e[0],n[3]=0,n[4]=t[1],n[5]=r[1],n[6]=-e[1],n[7]=0,n[8]=t[2],n[9]=r[2],n[10]=-e[2],n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,F["c"].getRotation(this._orientation,n),F["d"].invert(this._orientation,this._orientation)}}}(),setZoomFactor:function(e){this._zoomFactor=e},setRotateFactor:function(e){this._rotateFactor=e},setPanFactor:function(e){this._panFactor=e},setDistance:function(e){this._distance=e},setUsePolytopeIntersector:function(e){this._usePolytopeIntersector=e},getUsePolytopeIntersector:function(){return this._usePolytopeIntersector},getDistance:function(){return this._distance},zoom:function(e){this._distance=e},getRotateInterpolator:function(){return this._rotate},getPanInterpolator:function(){return this._pan},getZoomInterpolator:function(){return this._zoom},getIntersectionVisitor:function(){return this._intersectionVisitor},getLineSegmentIntersector:function(){return this._lineSegmentIntersector},getOrCreatePolytopeIntersector:function(){return void 0===this._polytopeIntersector&&(this._polytopeIntersector=new Sn,this._polytopeIntersector.setIntersectionLimit(Hn["a"].LIMIT_ONE_PER_DRAWABLE),this._polytopeIntersector.setPrimitiveMask(Hn["a"].POINT_PRIMITIVES|Hn["a"].LINE_PRIMITIVES)),this._polytopeIntersector},getTarget:function(e){return F["f"].copy(e,this._target),e},getEyePosition:function(e){void 0===this._eye?this.computeEyePosition(this._target,this._distance,e):F["f"].copy(e,this._eye)},computeEyePosition:function(){var e=F["f"].create(),t=F["c"].create();return function(r,n,i){F["c"].invert(t,this._rotation),e[1]=n,F["f"].transformMat4(i,e,t),F["f"].add(i,r,i)}}(),computePan:function(){var e=F["f"].create(),t=F["f"].create(),r=F["f"].create();return function(n,i,a){var o=F["f"].length(F["f"].sub(r,this._eye,this._pivotPoint))/this._panFactor;o<10&&(o=10),e[0]=n*o/2,e[1]=i*o/2,e[2]=0,F["f"].transformMat4(t,e,a),F["f"].add(this._eye,this._eye,t)}}(),computeZoom:function(){var e=F["f"].create(),t=F["f"].create();return function(r){var n=r*this._zoomFactor;F["f"].sub(e,this._pivotPoint,this._eye),F["f"].add(this._eye,this._eye,F["f"].scale(t,e,n))}}(),computeRotation:function(){var e=F["f"].create(),t=F["f"].create(),r=F["f"].create(),n=F["f"].create(),i=F["d"].create(),a=F["d"].create(),o=F["d"].create(),s=F["f"].create(),u=F["f"].create();return function(c,l){F["f"].transformQuat(t,this._right,this._orientation),F["f"].normalize(e,t),F["f"].sub(r,this._eye,this._pivotPoint);var h=F["f"].dot(e,r);F["f"].sub(n,r,F["f"].scale(u,e,h));var d=F["f"].fromValues(-n[0],-n[1],0),f=Math.atan2(-n[2],F["f"].length(d));l=Math.max(-Math.PI/2+.01,Math.min(Math.PI/2-.01,f+l))-f,F["d"].setAxisAngle(i,t,l*this._rotateFactor),F["d"].setAxisAngle(a,this._upz,c*this._rotateFactor),F["d"].mul(o,a,i),F["f"].transformQuat(s,r,o),F["f"].add(this._eye,s,this._pivotPoint),F["d"].mul(this._orientation,a,this._orientation),F["f"].transformQuat(t,this._right,this._orientation),F["d"].setAxisAngle(i,t,l*this._rotateFactor),F["d"].mul(this._orientation,i,this._orientation)}}(),update:function(){var e=F["c"].create(),t=F["c"].create();return function(r){var n=r.getFrameStamp().getDeltaTime(),i=10,a=this._rotate.update();this.computeRotation(-a[0]*i,a[1]*i),F["c"].fromQuat(e,this._orientation);var o=this._pan.update();this.computePan(-o[0]*i,-o[1]*i,e),a=this._zoom.update(n),this.computeZoom(-a[0]/10),F["c"].fromTranslation(t,this._eye),F["c"].mul(this._inverseMatrix,t,e),F["c"].invert(this._inverseMatrix,this._inverseMatrix)}}(),getInverseMatrix:function(){return this._inverseMatrix},computeIntersections:function(){var e=[],t=F["f"].create();return function(r,n){var i,a,o=this._camera.getView(),s=this._camera,u=s.getViewport().width(),c=s.getViewport().height();if(this._rotate.setWidth(u),this._rotate.setHeight(c),this._pan.setWidth(u),this._pan.setHeight(c),0!==(this._primitiveMask&Hn["a"].TRIANGLE_PRIMITIVES)&&(e=o.computeIntersections(r,n),e.length>0&&(i=e[0]._localIntersectionPoint,e[0]._nodePath.shift(),a=nc["a"].computeLocalToWorld(e[0]._nodePath),F["f"].transformMat4(t,i,a),this.setPivotPoint(t))),0===e.length&&this._usePolytopeIntersector){var l=this.getOrCreatePolytopeIntersector();l.reset(),l.setPolytopeFromWindowCoordinates(r-5,n-5,r+5,n+5);var h=this._intersectionVisitor;h.setIntersector(l),o.getCamera().accept(h),e=l.getIntersections(),e.sort((function(e,t){return e._distance-t._distance})),e.length>0&&(i=e[0]._localIntersectionPoint,e[0]._nodePath.shift(),a=nc["a"].computeLocalToWorld(e[0]._nodePath),F["f"].transformMat4(t,i,a),this.setPivotPoint(t))}}}(),getPositionRelativeToCanvas:function(){var e=F["e"].create(),t=F["e"].create();return function(r,n){var i=this._camera._graphicContext.canvas;this.getOffsetRect(i,e);var a=i.width/i.clientWidth,o=i.height/i.clientHeight;return t[0]=(r-e[1])*a,t[1]=(i.clientHeight-(n-e[0]))*o,t}}(),getCanvasCenter:function(){var e=F["e"].create(),t=F["e"].create();return function(){var r=this._camera.getGraphicContext().canvas;this.getOffsetRect(r,e);var n=r.width/r.clientWidth,i=r.height/r.clientHeight;return t[0]=r.clientWidth/2*n,t[1]=r.clientHeight/2*i,t}}(),getOffsetRect:function(e,t){var r=e.getBoundingClientRect(),n=document.body,i=document.documentElement,a=window.pageYOffset||i.scrollTop||n.scrollTop,o=window.pageXOffset||i.scrollLeft||n.scrollLeft,s=i.clientTop||n.clientTop||0,u=i.clientLeft||n.clientLeft||0,c=r.top+a-s,l=r.left+o-u;return t[0]=Math.round(c),t[1]=Math.round(l),t}}),"osgGA","CADManipulator"),lc.StandardMouseKeyboard=sc,lc.Hammer=cc;var hc=lc,dc=function(e){_e.call(this,e),this._timer=!1};j["a"].createPrototypeObject(dc,j["a"].objectInherit(_e.prototype,{_initInputs:function(){_e.prototype._initInputs.call(this,ne.FPS_MANIPULATOR_TOUCH)}}));var fc=dc,_c=F["d"].create(),pc=F["f"].create(),gc=function(e){te.call(this,e),this.init()};j["a"].createPrototypeObject(gc,j["a"].objectInherit(te.prototype,{init:function(){this._pos=F["f"].create(),this._quat=F["d"].create();var e=this._manipulator.getInputManager();e.group(ne.FPS_MANIPULATOR_WEBVR).addMappings({update:"vrdisplayposechanged"},this),e.setEnable(ne.FPS_MANIPULATOR_WEBVR,!1)},update:function(e){var t=e.pose.orientation;t&&(e.sitToStandMatrix&&(t=F["c"].getRotation(_c,e.sitToStandMatrix),F["d"].mul(t,t,e.pose.orientation)),this._quat[0]=t[0],this._quat[1]=-t[2],this._quat[2]=t[1],this._quat[3]=t[3]);var r=e.pose.position;r&&(e.sitToStandMatrix&&(r=F["f"].transformMat4(pc,r,e.sitToStandMatrix)),this._pos[0]=r[0]*e.worldFactor,this._pos[1]=-r[2]*e.worldFactor,this._pos[2]=r[1]*e.worldFactor),this._manipulator.setPoseVR(this._quat,this._pos)}}));var mc=gc,vc=function(e){te.call(this,e),this.init()};j["a"].createPrototypeObject(vc,j["a"].objectInherit(te.prototype,{init:function(){this._delay=.15,this._stepFactor=1,this._looking=!1;var e=this._manipulator.getInputManager();e.group(ne.FPS_MANIPULATOR_MOUSEKEYBOARD).addMappings({startLookAt:"mousedown",lookAt:"mousemove",stopLookAt:["mouseup","mouseout"],goForward:["keydown w","keydown z","keydown ArrowUp"],goBackward:["keydown s","keydown ArrowDown"],goLeft:["keydown a","keydown q","keydown ArrowLeft"],goRight:["keydown d","keydown ArrowRight"],stopMoving:["keyup w","keyup z","keyup ArrowUp","keyup s","keyup ArrowDown"],stopStrafing:["keyup a","keyup q","keyup ArrowLeft","keyup d","keyup ArrowRight"],changeStepFactor:"wheel"},this),e.group(ne.FPS_MANIPULATOR_RESETTOHOME).addMappings({reset:"keydown space"},this)},setEnable:function(e){e||(this._buttonup=!0),te.prototype.setEnable.call(this,e)},setManipulator:function(e){this._manipulator=e,this._manipulator.setStepFactor(this._stepFactor)},stopLookAt:function(){this._looking=!1},startLookAt:function(e){var t=this._manipulator;t.getLookPositionInterpolator().set(e.canvasX,-e.canvasY),this._looking=!0},lookAt:function(e){this._looking&&(this._manipulator.getLookPositionInterpolator().setDelay(this._delay),this._manipulator.getLookPositionInterpolator().setTarget(e.canvasX,-e.canvasY))},changeStepFactor:function(e){this._stepFactor=Math.min(Math.max(.001,this._stepFactor+.01*e.deltaY),4),this._manipulator.setStepFactor(this._stepFactor)},reset:function(){this._manipulator.computeHomePosition()},goForward:function(){this._manipulator.getForwardInterpolator().setDelay(this._delay),this._manipulator.getForwardInterpolator().setTarget(1)},goBackward:function(){this._manipulator.getForwardInterpolator().setDelay(this._delay),this._manipulator.getForwardInterpolator().setTarget(-1)},goLeft:function(){this._manipulator.getSideInterpolator().setDelay(this._delay),this._manipulator.getSideInterpolator().setTarget(-1)},goRight:function(){this._manipulator.getSideInterpolator().setDelay(this._delay),this._manipulator.getSideInterpolator().setTarget(1)},stopMoving:function(){this._manipulator.getForwardInterpolator().setDelay(this._delay),this._manipulator.getForwardInterpolator().setTarget(0)},stopStrafing:function(){this._manipulator.getSideInterpolator().setDelay(this._delay),this._manipulator.getSideInterpolator().setTarget(0)}}));var bc=vc,Sc=function(e){$.call(this,e),this._redrawCB=e.redrawCB,this.init()};Sc.AvailableControllerList=["StandardMouseKeyboard","WebVR","DeviceOrientation","Hammer"],Sc.ControllerList=["StandardMouseKeyboard","WebVR","DeviceOrientation","Hammer"],j["a"].createPrototypeObject(Sc,j["a"].objectInherit($.prototype,{computeHomePosition:function(e){var t=this.getHomeBoundingSphere(e);if(t&&t.valid()){this._distance=this.getHomeDistance(t);var r=t.center();F["f"].scale(this._eye,this._direction,-this._distance),F["f"].add(this._eye,r,this._eye),this.setTarget(r)}},init:function(){this._direction=F["f"].fromValues(0,1,0),this._eye=F["f"].fromValues(0,25,10),this._up=F["f"].fromValues(0,0,1),this._distance=1,this._forward=new ye(1,void 0,this._redrawCB),this._side=new ye(1,void 0,this._redrawCB),this._lookPosition=new ye(2,void 0,this._redrawCB),this._pan=new ye(2,void 0,this._redrawCB),this._zoom=new ye(1,void 0,this._redrawCB),this._stepFactor=1,this._angleVertical=0,this._angleHorizontal=0,this._tmpGetTargetDir=F["f"].create(),this._vrEnable=!1,this._vrRot=F["d"].create(),this._vrPos=F["f"].create(),this._vrTrans=F["f"].create();var e=this;this._controllerList={},Sc.ControllerList.forEach((function(t){void 0!==Sc[t]&&(e._controllerList[t]?e._controllerList[t].init():e._controllerList[t]=new Sc[t](e))}))},setDelay:function(e){this._forward.setDelay(e),this._side.setDelay(e),this._lookPosition.setDelay(e),this._pan.setDelay(e),this._zoom.setDelay(e)},getEyePosition:function(e){return e[0]=this._eye[0],e[1]=this._eye[1],e[2]=this._eye[2],e},setEyePosition:function(e){return this._eye[0]=e[0],this._eye[1]=e[1],this._eye[2]=e[2],this},getTarget:function(e){var t=F["f"].scale(this._tmpGetTargetDir,this._direction,this._distance);return F["f"].add(e,this._eye,t),e},setEnable:function(e){this.getInputManager().setEnable(ne.FPS_MANIPULATOR,e)},setTarget:function(e){var t=this._tmpGetTargetDir;F["f"].sub(t,e,this._eye),t[2]=0,F["f"].normalize(t,t),this._angleHorizontal=Math.acos(t[1]),t[0]<0&&(this._angleHorizontal=-this._angleHorizontal),F["f"].sub(t,e,this._eye),F["f"].normalize(t,t),this._angleVertical=-Math.asin(t[2]),F["f"].copy(this._direction,t)},getLookPositionInterpolator:function(){return this._lookPosition},getSideInterpolator:function(){return this._side},getForwardInterpolator:function(){return this._forward},getPanInterpolator:function(){return this._pan},getZoomInterpolator:function(){return this._zoom},getRotateInterpolator:function(){return this._lookPosition},computeRotation:function(){var e=F["c"].create(),t=F["c"].create(),r=F["f"].fromValues(1,0,0),n=F["f"].fromValues(0,1,0),i=F["f"].fromValues(0,0,1),a=.5*Math.PI;return function(o,s){this._angleVertical+=.01*s,this._angleHorizontal-=.01*o,this._angleVertical>a?this._angleVertical=a:this._angleVertical<-a&&(this._angleVertical=-a),this._vrEnable?(F["f"].transformQuat(this._direction,n,this._vrRot),F["f"].normalize(this._direction,this._direction),F["f"].transformQuat(this._up,i,this._vrRot)):(F["c"].fromRotation(e,-this._angleVertical,r),F["c"].fromRotation(t,-this._angleHorizontal,i),F["c"].mul(t,t,e),F["f"].transformMat4(this._direction,n,t),F["f"].normalize(this._direction,this._direction),F["f"].transformMat4(this._up,i,t))}}(),reset:function(){this.init()},setDistance:function(e){this._distance=e},getDistance:function(){return this._distance},setStepFactor:function(e){this._stepFactor=e},computePosition:function(){var e=F["e"].create();return function(t){this._forward.update(t),this._side.update(t);var r=this._distance<.001?.001:this._distance,n=this._camera.getProjectionMatrix(),i=1===n[15]?1:2/n[5];e[0]=this._forward.getCurrent()[0],e[1]=this._side.getCurrent()[0];var a=F["e"].sqrLen(e);a>1&&F["e"].scale(e,e,1/Math.sqrt(a));var o=this._pan.update(t),s=this._zoom.update(t),u=this._stepFactor*r*i*t,c=this._stepFactor*r*i*.005;this.moveForward(e[0]*u-s[0]*c*20),this.strafe(e[1]*u-o[0]*c),this.strafeVertical(-o[1]*c),this._vrEnable&&(F["f"].add(this._eye,this._eye,this._vrTrans),F["f"].init(this._vrTrans))}}(),update:function(){var e=F["f"].create();return function(t){var r=t.getFrameStamp().getDeltaTime(),n=this._lookPosition.update(r);this.computeRotation(.5*-n[0],.5*-n[1]),this.computePosition(r),F["f"].add(e,this._eye,this._direction),F["c"].lookAt(this._inverseMatrix,this._eye,e,this._up),this._vrEnable=!1}}(),setPoseVR:function(e,t){this._vrEnable=!0,F["d"].copy(this._vrRot,e),F["f"].sub(this._vrTrans,t,this._vrPos),F["f"].copy(this._vrPos,t)},moveForward:function(){var e=F["f"].create();return function(t){F["f"].normalize(e,this._direction),F["f"].scale(e,e,t),F["f"].add(this._eye,this._eye,e)}}(),strafe:function(){var e=F["f"].create();return function(t){F["f"].cross(e,this._direction,this._up),F["f"].normalize(e,e),F["f"].scale(e,e,t),F["f"].add(this._eye,this._eye,e)}}(),strafeVertical:function(){var e=F["f"].create();return function(t){F["f"].normalize(e,this._up),F["f"].scale(e,e,t),F["f"].add(this._eye,this._eye,e)}}()}),"osgGA","FirstPersonManipulator"),Sc.DeviceOrientation=se,Sc.Hammer=fc,Sc.WebVR=mc,Sc.StandardMouseKeyboard=bc;var xc=Sc,Tc=function(e){this._manipulatorList=[],this._currentManipulator=void 0,this._inputManager=e};Tc.prototype={getCamera:function(){return this.getCurrentManipulator().getCamera()},setCamera:function(e){for(var t=this.getManipulatorList(),r=0,n=t.length;r<n;++r)t[r].setCamera(e)},update:function(e){var t=this.getCurrentManipulator();if(void 0!==t)return t.update(e)},getInputManager:function(){return this._inputManager},setEnable:function(e){this.getCurrentManipulator().setEnable(e)},getNode:function(){return this.getCurrentManipulator()._node},setNode:function(e){for(var t=this.getManipulatorList(),r=0,n=t.length;r<n;++r)t[r].setNode(e)},getControllerList:function(){return this.getCurrentManipulator().getControllerList()},getNumManipulator:function(){return this._manipulatorList.length},addManipulator:function(e){this._manipulatorList.push(e),void 0===this._currentManipulator&&this.setManipulatorIndex(0)},getManipulatorList:function(){return this._manipulatorList},setManipulatorIndex:function(e){this._currentManipulator=e},getCurrentManipulatorIndex:function(){return this._currentManipulator},getCurrentManipulator:function(){return this._manipulatorList[this._currentManipulator]},reset:function(){this.getCurrentManipulator().reset()},computeHomePosition:function(e){var t=this.getCurrentManipulator();void 0!==t&&t.computeHomePosition(e)},getInverseMatrix:function(){var e=this.getCurrentManipulator();if(void 0!==e)return e.getInverseMatrix()},getHomeBound:function(e){return L["a"].warn("Please use getHomeBoundingSphere instead"),this.getHomeBoundingSphere(e)},getHomeBoundingSphere:function(e){return this.getCurrentManipulator().getHomeBoundingSphere(e)},getHomeDistance:function(e){return this.getCurrentManipulator().getHomeDistance(e)}};var yc=Tc,Cc={};or.a.NO_MOUSEEVENTS=!0,Cc.CADManipulator=hc,Cc.getCADManipulatorStandardMouseKeyboardController=function(){return sc},Cc.getCADManipulatorHammerController=function(){return cc},Cc.FirstPersonManipulator=xc,Cc.getFirstPersonDeviceOrientationController=function(){return se},Cc.getFirstPersonManipulatorHammerController=function(){return fc},Cc.getFirstPersonStandardMouseKeyboardControllerClass=function(){return bc},Cc.getFirstPersonWebVRControllerClass=function(){return mc},Cc.Manipulator=$,Cc.OrbitManipulator=we,Cc.getOrbitManipulatorDeviceOrientationController=function(){return ce},Cc.getOrbitManipulatorGamePadController=function(){return he},Cc.getOrbitManipulatorHammerController=function(){return _e},Cc.getOrbitManipulatorStandardMouseKeyboardController=function(){return me},Cc.getOrbitManipulatorWebVRController=function(){return xe},Cc.SwitchManipulator=yc,Cc.OrbitManipulator.Rotate=pe.ROTATE,Cc.OrbitManipulator.Pan=pe.PAN,Cc.OrbitManipulator.Zoom=pe.ZOOM,Cc.Controller=te;var Ac=Cc,Ec=.99,Rc=.5*Math.PI*.99,Mc=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(e){var n;return Object(v["a"])(this,r),n=t.call(this,e),n.setLimitPitchUp(Rc),n.setLimitPitchDown(-Rc),n._enableRecenter=!0,n._zoomEMA=0,n._pitchEMA=0,n._yawEMA=0,n._panVEMA=0,n._panHEMA=0,n._constrainPan=!1,n._constrainedTarget=w["default"].vec3.create(),n._scaleMouseMotion=.5,n._noPan=!1,n._noZoom=!1,n._noRotation=!1,n.setDelay(.1),n}return Object(S["a"])(r,[{key:"setEyePosition",value:function(e,t){var r=w["default"].vec3.create(),n=w["default"].vec3.create(),i=w["default"].vec3.create(),a=this._rotation,o=this._target;if(w["default"].vec3.sub(r,e,o),w["default"].vec3.normalize(r,r),t){var s=w["default"].vec3.dot(r,this._upz);if(Math.abs(s)>Ec){var u=Math.sqrt((1-.9801)/(r[0]*r[0]+r[1]*r[1]));r[0]*=u,r[1]*=u,r[2]=Ec*Math.sign(s)}}w["default"].vec3.cross(n,r,this._upz),w["default"].vec3.normalize(n,n),w["default"].vec3.cross(i,n,r),w["default"].vec3.normalize(i,i),a[0]=n[0],a[1]=r[0],a[2]=i[0],a[3]=0,a[4]=n[1],a[5]=r[1],a[6]=i[1],a[7]=0,a[8]=n[2],a[9]=r[2],a[10]=i[2],a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,this._distance=w["default"].vec3.dist(o,e)}},{key:"enableRecenter",value:function(e){this._enableRecenter=e}},{key:"computeHomePosition",value:function(e){this._enableRecenter&&Ac.OrbitManipulator.prototype.computeHomePosition.call(this,e);var t=this.getHomeBoundingSphere();t&&(this.setLimitZoomIn(t.radius()/1.5),this.setLimitZoomOut(5*t.radius()))}},{key:"_computeEMA",value:function(e,t){return 0===t?e:.2*e+.8*t}},{key:"_getLimitReached",value:function(e,t,r){return Math.abs(e-r)<.001?r:Math.abs(e-t)<.001?t:void 0}},{key:"computeZoom",value:function(e){if(!this._noZoom&&(Ac.OrbitManipulator.prototype.computeZoom.call(this,e),this._constrainZoom)){(e-=!1)&&(e=-e,-1);this.getSpeedFactor();var t=this._getLimitReached(this.getDistance(),this._limitZoomIn,this._limitZoomOut);void 0!==t&&(this._zoom.reset(),this._prevDistance>t?this._distance=t+this._distance/100:this._distance=t-this._distance/100,void 0==this._prevDistance&&(this._prevDistance=t)),this._prevDistance=this._distance}}},{key:"_computePitch",value:function(e,t){if(!this._noRotation){e=void 0!==this._previousPitch?this._previousPitch:e;var r=Ac.OrbitManipulator.prototype._computePitch.call(this,e,t);if(!this._constrainPitch||0===t)return this._previousPitch=void 0,r;this._previousPitch=r;var n=t/10;n=n/(1+n)*.5;var i=this._getLimitReached(r,this._limitPitchUp,this._limitPitchDown);return void 0!==i&&(this._pitchEMA=this._computeEMA(n,this._pitchEMA),r=i+this._pitchEMA),Math.max(Math.min(r,Rc),-Rc)}}},{key:"_computeYaw",value:function(e,t){if(!this._noRotation){var r;if(e=void 0!==this._previousYaw?this._previousYaw:e,r=Ac.OrbitManipulator.prototype._computeYaw.call(this,e,t),!this._constrainYaw||0===t)return this._previousYaw=void 0,r;this._previousYaw=r;var n=t/10;n=n/(1+n)*3;var i=this._getLimitReached(r,this._limitYawLeft,this._limitYawRight);return void 0!==i&&(this._yawEMA=this._computeEMA(n,this._yawEMA),r=i+this._yawEMA),r}}},{key:"computePan",value:function(e,t){this._noPan||(!this._constrainPan||0===e&&0===t||(this._panVEMA=this._computeEMA(e/(1+e)*.5,this._panVEMA),this._panHEMA=this._computeEMA(t/(1+t)*.5,this._panHEMA),e=this._panVEMA,t=this._panHEMA,w["default"].vec3.copy(this._target,this._constrainedTarget)),Ac.OrbitManipulator.prototype.computePan.call(this,e,t))}},{key:"setConstrainPan",value:function(e){this._constrainPan=e}},{key:"isConstrainPan",value:function(){return this._constrainPan}},{key:"setPanConstraintTarget",value:function(e){w["default"].vec3.copy(this._constrainedTarget,e)}},{key:"setNoPan",value:function(e){this._noPan=e}},{key:"setNoZoom",value:function(e){this._noZoom=e}},{key:"setNoRotation",value:function(e){this._noRotation=e}}]),r}(Ac.OrbitManipulator),wc=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(e){var n;return Object(v["a"])(this,r),n=t.call(this,e),n._stepFactor=Math.max(0,Math.min(4,M.fpsSpeed/25)),n.getControllerList().StandardMouseKeyboard._stepFactor=n._stepFactor,n._postMultRotate=w["default"].quat.create(),n._resetInitialVR=!1,n._lookPosition._delay=.25,n}return Object(S["a"])(r,[{key:"getPostMultRotate",value:function(){return this._postMultRotate}},{key:"setResetInitialRotationVR",value:function(e){}},{key:"setNode",value:function(e){}},{key:"setInitialPoseVR",value:function(e,t){}},{key:"setPoseVR",value:function(e,t){}}]),r}(Ac.FirstPersonManipulator),Nc=Xn.DelayInterpolator.prototype,Oc=Nc.set;Nc.set=function(){Oc.apply(this,arguments),this._epsilon>=0&&!this.isDone()&&this._redrawCB(!0)};var Ic=Nc.setTarget;Nc.setTarget=function(){Ic.apply(this,arguments),this._epsilon>=0&&!this.isDone()&&this._redrawCB(!0)};var Pc=Nc.addTarget;Nc.addTarget=function(){Pc.apply(this,arguments),this._epsilon>=0&&!this.isDone()&&this._redrawCB(!0)},Nc.isDone=function(e){e=e||1;for(var t=Math.abs(this._epsilon),r=0,n=this._current.length;r<n;++r)if(Math.abs(this._target[r]-this._current[r])>t*e)return!1;return!0};var Dc=Nc.update;Nc.update=function(e){var t=Dc.call(this,e);if(this._epsilon>=0)if(this.isDone())for(var r=0,n=this._current.length;r<n;++r)this._current[r]=this._target[r];else this._redrawCB(),this.isDone(100)?this._redrawCB(!0):this._redrawCB("noJitter");return t};var Lc=function(){for(var e=Math.abs(this._epsilon),t=0,r=this._current.length;t<r;++t)if(1===Math.abs(this._target[t])||Math.abs(this._target[t]-this._current[t])>e)return!1;return!0},Fc=function(e){e.isDone=Lc.bind(e)},kc=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(e,n){var i;return Object(v["a"])(this,r),i=t.call(this),i._redrawCB=n,i._boundStrategy=Ac.Manipulator.COMPUTE_HOME_USING_SPHERE|Ac.Manipulator.COMPUTE_HOME_USING_BBOX,i._inputManager=e,i.init(),i._upz=w["default"].vec3.fromValues(0,0,1),i._autoRotating=!1,i._autoRotateMode=!1,i}return Object(S["a"])(r,[{key:"init",value:function(){var e=this;this._startAutoRotate=_.debounce((function(){e._autoRotating=!0}),3e3,{trailing:!0}),this._stopAutoRotate=_.debounce((function(){e._autoRotating=!1}),3e3,{leading:!0}),Ac.SwitchManipulator.prototype.setManipulatorIndex.call(this,0);var t=new Mc({boundStrategy:this._boundStrategy,inputManager:this._inputManager,redrawCB:function(t){e._redrawCB(t),e._autoRotateMode&&(e._stopAutoRotate(),e._startAutoRotate())}});t.getRotateInterpolator()._epsilon=.1,t.getPanInterpolator()._epsilon=.1,t.getZoomInterpolator()._epsilon=.001,t.setZoomFactor(M.orbitZoomFactor),t.setRotationFactor(M.orbitRotationFactor),t.setPanFactor(M.orbitPanFactor),t.getPanInterpolator()._isOrbitPan=!0;var r=new wc({boundStrategy:this._boundStrategy,inputManager:this._inputManager,redrawCB:this._redrawCB});r.getLookPositionInterpolator()._epsilon=.1,r.getSideInterpolator()._epsilon=.001,Fc(r.getSideInterpolator()),r.getForwardInterpolator()._epsilon=.001,Fc(r.getForwardInterpolator()),r.getPanInterpolator()._epsilon=.001,Fc(r.getPanInterpolator()),r.getZoomInterpolator()._epsilon=.001,Fc(r.getZoomInterpolator()),this.addManipulator(t,"ORBIT"),this.addManipulator(r,"FPS"),void 0!==M.cameraEasing&&this.setDelay(1-M.cameraEasing)}},{key:"getOrbitManipulator",value:function(){return this._manipulatorList[r.ORBIT]}},{key:"getFirstPersonManipulator",value:function(){return this._manipulatorList[r.FPS]}},{key:"_setManipulatorDelay",value:function(e,t){e.setDelay(t);var r=e._controllerList;for(var n in r){var i=r[n];void 0!==i._delay&&(i._delay=t)}}},{key:"setDelay",value:function(e){this._setManipulatorDelay(this._manipulatorList[r.ORBIT],e),this._setManipulatorDelay(this._manipulatorList[r.FPS],e)}},{key:"addManipulator",value:function(e,t){Ac.SwitchManipulator.prototype.addManipulator.call(this,e),t&&(r[t]=this.getManipulatorList().length-1)}},{key:"setManipulatorIndex",value:function(e){var t=w["default"].vec3.create(),r=w["default"].vec3.create();if(e!==this.getCurrentManipulatorIndex()){var n=this.getCurrentManipulator();Ac.SwitchManipulator.prototype.setManipulatorIndex.call(this,e),this.setTargetAndEye(n.getTarget(t),n.getEyePosition(r))}}},{key:"setTargetAndEye",value:function(e,t){var n=this.getCurrentManipulator();this.getCurrentManipulatorIndex()===r.ORBIT?(e&&n.setTarget(e),t&&n.setEyePosition(t)):(t&&n.setEyePosition(t),e&&n.setTarget(e)),this._redrawCB(!0)}},{key:"setEyePosition",value:function(e,t){this.getCurrentManipulator().setEyePosition(e,t),this._redrawCB(!0)}},{key:"getEyePosition",value:function(e){return this.getCurrentManipulator().getEyePosition(e)}},{key:"setTarget",value:function(e){this.getCurrentManipulator().setTarget(e),this._redrawCB(!0)}},{key:"getTarget",value:function(e){return this.getCurrentManipulator().getTarget(e)}},{key:"setDistance",value:function(e){this.getCurrentManipulatorIndex()===r.ORBIT&&(this.getCurrentManipulator().setDistance(e),this._redrawCB(!0))}},{key:"getDistance",value:function(){return this.getCurrentManipulator().getDistance()}},{key:"computeHomePosition",value:function(e){Ac.SwitchManipulator.prototype.computeHomePosition.call(this,e),this._redrawCB(!0)}},{key:"setViewMode",value:function(e,t){var r=this.getCurrentManipulator()._rotation;switch(e){case"front":var n=w["default"].mat4.fromRotation(w["default"].mat4.create(),-Math.PI,this._upz),i=w["default"].mat4.fromRotation(w["default"].mat4.create(),Math.PI/10,w["default"].vec3.fromValues(1,0,0));w["default"].mat4.mul(r,n,i);break;case"back":n=w["default"].mat4.fromRotation(w["default"].mat4.create(),0,this._upz),i=w["default"].mat4.fromRotation(w["default"].mat4.create(),Math.PI/10,w["default"].vec3.fromValues(-1,0,0));w["default"].mat4.mul(r,n,i);break;case"right":n=w["default"].mat4.fromRotation(w["default"].mat4.create(),Math.PI/2,this._upz),i=w["default"].mat4.fromRotation(w["default"].mat4.create(),Math.PI/10,w["default"].vec3.fromValues(0,1,0));w["default"].mat4.mul(r,n,i);break;case"left":n=w["default"].mat4.fromRotation(w["default"].mat4.create(),-Math.PI/2,this._upz),i=w["default"].mat4.fromRotation(w["default"].mat4.create(),Math.PI/10,w["default"].vec3.fromValues(0,-1,0));w["default"].mat4.mul(r,n,i);break;case"top":n=w["default"].mat4.fromRotation(w["default"].mat4.create(),-Math.PI,this._upz),i=w["default"].mat4.fromRotation(w["default"].mat4.create(),Math.PI/2-1e-4,w["default"].vec3.fromValues(1,0,0));w["default"].mat4.mul(r,n,i);break;case"bottom":n=w["default"].mat4.fromRotation(w["default"].mat4.create(),-Math.PI,this._upz),i=w["default"].mat4.fromRotation(w["default"].mat4.create(),-Math.PI/2+1e-4,w["default"].vec3.fromValues(1,0,0));w["default"].mat4.mul(r,n,i);break;case"right-top":n=w["default"].mat4.fromRotation(w["default"].mat4.create(),2*Math.PI/3,this._upz),i=w["default"].mat4.fromRotation(w["default"].mat4.create(),Math.PI/9,w["default"].vec3.fromValues(1,1,0));w["default"].mat4.mul(r,n,i);break;case"left-top":n=w["default"].mat4.fromRotation(w["default"].mat4.create(),2*-Math.PI/3,this._upz),i=w["default"].mat4.fromRotation(w["default"].mat4.create(),Math.PI/9,w["default"].vec3.fromValues(1,-1,0));w["default"].mat4.mul(r,n,i);break}var a=this.getHomeBoundingSphere();if(a&&a.valid()){this.setDistance(t||this.getHomeDistance(a)),this.setTarget(a.center());var o=this.getCurrentManipulator().getHomePosition();this.setEyePosition(o)}}},{key:"update",value:function(e){if(this._autoRotating){var t=w["default"].vec3.create(),n=w["default"].vec3.create();this.getEyePosition(t),this.getTarget(n),w["default"].vec3.rotateZ(t,t,n,Math.PI/6*e._frameStamp._deltaTime),this.setTargetAndEye(n,t)}Object(yr["a"])(Object(Cr["a"])(r.prototype),"update",this).call(this,e)}},{key:"setAutoRotateMode",value:function(e){this._autoRotateMode=!!e,this._autoRotating=this._autoRotateMode}}]),r}(Ac.SwitchManipulator),Bc=["Inspector","Matcap","Displacement","AlphaMask","Opacity","SubsurfaceScattering","SubsurfaceTranslucency","DiffuseColor","DiffusePBR","AlbedoPBR","ClearCoat","ClearCoatRoughness","ClearCoatNormalMap","SpecularColor","DiffuseIntensity","SpecularPBR","MetalnessPBR","GlossinessPBR","RoughnessPBR","NormalMap","BumpMap","AOPBR","EmitColor","CavityPBR","SpecularHardness","SpecularF0","Anisotropy","Sheen","SheenRoughness"],Uc=function(e){switch(e){case"DiffuseColor":case"DiffuseIntensity":case"SpecularColor":case"NormalMap":case"EmitColor":case"DiffusePBR":case"AlbedoPBR":case"SpecularPBR":case"Matcap":case"Inspector":case"ClearCoatNormalMap":case"Anisotropy":case"Sheen":return w["default"].Texture.RGB;case"SpecularHardness":case"BumpMap":case"GlossinessPBR":case"RoughnessPBR":case"MetalnessPBR":case"SheenRoughness":case"SpecularF0":case"AOPBR":case"CavityPBR":case"Displacement":case"SubsurfaceScattering":case"SubsurfaceTranslucency":case"ClearCoat":case"ClearCoatRoughness":return w["default"].Texture.LUMINANCE;case"Opacity":case"AlphaMask":return w["default"].Texture.ALPHA;default:return console.error("unknown channel: "+e),w["default"].Texture.RGB}},Vc=function(e){if("Anisotropy"===e)return"rg";var t=Uc(e);return t===w["default"].Texture.RGB?"rgb":t===w["default"].Texture.LUMINANCE?"r":t===w["default"].Texture.ALPHA?"a":"rgba"},Gc=function(e){for(var t={},r=0,n=Bc.length;r<n;++r){var i=Bc[r];t[i]=e(i)}return function(e){return t[e]}},zc={CLASSIC:10,CLASSIC_LIT:2,CLASSIC_SHADELESS:8,INSPECTOR:32,LIT:3,MATCAP:16,PBR:5,PBR_LIT:1,PBR_SHADELESS:4,SHADELESS:12};Bc.getShadingMask=Gc((function(e){switch(e){case"Matcap":return zc.MATCAP;case"SubsurfaceScattering":case"SubsurfaceTranslucency":return zc.LIT;case"Opacity":case"AlphaMask":case"Displacement":return zc.LIT|zc.SHADELESS|zc.MATCAP|zc.INSPECTOR;case"EmitColor":return zc.LIT|zc.SHADELESS;case"NormalMap":case"BumpMap":return zc.LIT|zc.MATCAP;case"DiffusePBR":case"AlbedoPBR":case"AOPBR":case"CavityPBR":return zc.PBR;case"SpecularPBR":case"MetalnessPBR":case"GlossinessPBR":case"RoughnessPBR":case"SpecularF0":case"ClearCoat":case"ClearCoatRoughness":case"ClearCoatNormalMap":case"Anisotropy":case"Sheen":case"SheenRoughness":return zc.PBR_LIT;case"DiffuseColor":case"DiffuseIntensity":return zc.CLASSIC;case"SpecularColor":case"SpecularHardness":return zc.CLASSIC_LIT;case"Inspector":return zc.INSPECTOR}})),Bc.isSRGB=Gc((function(e){switch(e){case"DiffuseColor":case"DiffusePBR":case"AlbedoPBR":case"EmitColor":case"SpecularColor":case"SpecularPBR":case"Matcap":case"Inspector":case"Sheen":return!0;default:return!1}})),Bc.getDefaultFormatEnum=Gc(Uc),Bc.getDefaultFormatComponent=Gc(Vc),Bc.getDefaultFormatString=Gc((function(e){var t=Uc(e);return t===w["default"].Texture.RGB?"RGB":t===w["default"].Texture.LUMINANCE?"LUMINANCE":t===w["default"].Texture.ALPHA?"ALPHA":"RGBA"})),Bc.getDefaultComponentCount=Gc((function(e){return Vc(e).length})),Bc.getPossibleFormat=Gc((function(e){var t={};switch(e){case"NormalMap":case"SpecularPBR":case"ClearCoatNormalMap":case"Anisotropy":case"Sheen":t.RGB="RGB";break;case"SpecularHardness":case"BumpMap":case"GlossinessPBR":case"RoughnessPBR":case"MetalnessPBR":case"SpecularF0":case"AOPBR":case"CavityPBR":case"Displacement":case"SubsurfaceScattering":case"SubsurfaceTranslucency":case"ClearCoat":case"ClearCoatRoughness":case"SheenRoughness":t.LUMINANCE="Luminance";break;case"DiffuseColor":case"DiffuseIntensity":case"SpecularColor":case"EmitColor":case"DiffusePBR":case"AlbedoPBR":case"Matcap":case"Inspector":t.LUMINANCE="Luminance",t.RGB="RGB";break;case"AlphaMask":case"Opacity":t.ALPHA="Alpha",t.LUMINANCE="Luminance";break;default:return console.error("unknown channel: "+e),w["default"].Texture.RGB}return t})),Bc.getPossibleFiltering=Gc((function(e){var t={};return"Displacement"!==e&&(t.LINEAR_MIPMAP_LINEAR="Trilinear (best)",t.NEAREST_MIPMAP_LINEAR="Nearest (mipmap)"),t.LINEAR="Bilinear",t.NEAREST="Nearest",t})),Bc.getColorPacking=Gc((function(e){switch(e){case"DiffuseColor":case"DiffusePBR":case"AlbedoPBR":case"Inspector":return 0;case"EmitColor":return 1;case"SpecularColor":case"SpecularPBR":return 2;case"DiffuseIntensity":return 3;default:return-1}})),Bc.getBoxFactor=Gc((function(e){return"SubsurfaceScattering"===e||"SubsurfaceTranslucency"===e?.2:"Displacement"===e?1:-1}));var jc=function(e){Object(x["a"])(n,e);var t=Object(T["a"])(n);function n(){var e;return Object(v["a"])(this,n),e=t.call(this),e._channelMapping={},e._materialModel=void 0,e._stateSetContext=void 0,e._additive=!1,e._depthWrite=!0,e._castShadows=!0,e._hashes=["",""],e._dirtyUniforms=!0,e._activeChannels=[],e}return Object(S["a"])(n,[{key:"dirtyMaterial",value:function(){for(var e=0;e<this._hashes.length;++e)this._hashes[e]="";this._dirtyUniforms=!0}},{key:"getHash",value:function(){if(!this._materialModel)return"";var e=this._hashes[n.CURRENT_COMPILER];if(e)return e;e=this.attributeType,n.CURRENT_COMPILER!==n.WIREFRAME_COMPILER&&(e+=this.getVertexAlphaEnable()?"1":"0"),n.CURRENT_COMPILER===n.SHADING_COMPILER&&(e+=this.getShadeless()?"1":"0",e+=this.getVertexColorEnable()?"1":"0",e+=this.getHasOnlyPoints()?"1":"0",e+="srgb"===this.getVertexColorColorSpace()?"1":"0",e+=a.Z.get("hasSsr")?"1":"0");for(var t=n.CURRENT_COMPILER===n.SHADOWCAST_COMPILER,r=this._materialModel.getChannels(),i=n.compilerChannels[n.CURRENT_COMPILER],o=this._channelMapping,s=0;s<i.length;++s){var u=i[s],c=r[u];if(c.isEnableEffective())if(!t||this._castShadows){var l=o[u];e+=".",e+=l<0?"":l,e+=c.getShaderHash(),e+=this.getChannelPacking(u)}else e+=".0";else e+=".0"}return this._hashes[n.CURRENT_COMPILER]=e,e}},{key:"setMaterialModel",value:function(e){this._materialModel=e}},{key:"setStateSetContext",value:function(e){this._stateSetContext=e}},{key:"setChannelMapping",value:function(e,t){this._channelMapping[e]=t}},{key:"getChannelPacking",value:function(e){return this._stateSetContext?this._stateSetContext.getChannelPacking(e):""}},{key:"updateOpacity",value:function(){this._additive=!1,this._depthWrite=!0,this._castShadows=!0;var e=this._materialModel.getChannels().Opacity;if(e.isEffective()){var t=e.getTransparency();if("dithering"!==t){if("additive"===t)return this._additive=!0,this._depthWrite=!1,void(this._castShadows=!1);var r=!1;return 1===e.getFactor()&&(r=e.getTextureModel()||this.getVertexAlphaEnable()),r?void 0:(this._depthWrite=!1,void(this._castShadows=!1))}}}},{key:"cloneType",value:function(){return new n}},{key:"getType",value:function(){return this.attributeType}},{key:"getTypeMember",value:function(){return this.attributeType}},{key:"getMaterialModel",value:function(){return this._materialModel}},{key:"getShadeless",value:function(){return this._materialModel&&this._materialModel.get("shadeless")}},{key:"getReflection",value:function(){return this._materialModel&&this._materialModel.get("reflection")}},{key:"getVertexColorEnable",value:function(){return this._materialModel&&this._materialModel.get("vertexColorEnable")}},{key:"getVertexAlphaEnable",value:function(){return this._materialModel&&this._materialModel.get("vertexAlphaEnable")}},{key:"getVertexColorColorSpace",value:function(){return this._materialModel&&this._materialModel.get("vertexColorColorSpace")}},{key:"getCullFace",value:function(){return this._materialModel&&this._materialModel.get("cullFace")}},{key:"getHasOnlyPoints",value:function(){return this._materialModel&&this._materialModel.hasOnlyPoints()}},{key:"getAdditive",value:function(){return this._additive}},{key:"getDepthWrite",value:function(){return this._depthWrite}},{key:"getCastShadows",value:function(){return this._castShadows}},{key:"getChannelMapping",value:function(e){return this._channelMapping[e]}},{key:"getOrCreateUniforms",value:function(){if(n.uniforms)return n.uniforms;var e=n.uniforms={};e.uReflection=w["default"].Uniform.createFloat("uReflection");for(var t=i("egBR").Z,a=zc.length,o=0;o<a;++o){var s=r.Z[o],u=t[s].model;u.prototype.addUniforms.call(u,e,s)}return e}},{key:"_cacheChannelUniforms",value:function(){var e=this.getOrCreateUniforms(),t=this._materialModel.getChannels(),n=zc.length,i=this._activeChannels;i.length=0;for(var a=0;a<n;++a){var o=t[r.Z[a]];w["default"].isEnableEffective()&&(w["default"].cacheUniforms(e),i.push(o))}}},{key:"apply",value:function(){if(this._materialModel){this._dirtyUniforms&&(this._dirtyUniforms=!1,this._cacheChannelUniforms()),this.getOrCreateUniforms().uReflection.setFloat(this.getReflection());for(var e=this._activeChannels,t=0;t<e.length;++t)e[t].updateUniforms()}}}]),n}(w["default"].StateAttribute);jc.prototype.attributeType="EditorMaterial",jc.SHADING_COMPILER=0,jc.EARLYZ_COMPILER=1,jc.SHADOWCAST_COMPILER=2,jc.WIREFRAME_COMPILER=3,jc.CURRENT_COMPILER=jc.SHADING_COMPILER,jc.compilerChannels=[],jc[jc.SHADING_COMPILER]=Bc,jc.compilerChannels[jc.EARLYZ_COMPILER]=["AlphaMask","Opacity","Displacement","SubsurfaceScattering"],jc.compilerChannels[jc.SHADOWCAST_COMPILER]=["Displacement","AlphaMask","Opacity"],jc.compilerChannels[jc.WIREFRAME_COMPILER]=["Displacement"],jc.hasVertexColor=!1,jc.hasVertexAlpha=!1;var Hc=jc,Wc=Ka["default"].NextShaderProcessor,Xc=function(){function e(t,r){Object(v["a"])(this,e),this._vertDefines=[],this._fragDefines=[],this._vertAssignUV=[],this._envBrdf,this._envSpecular,this._compression,this._material,this._skinning,this._morphing,this._pointSize,this._lights=[],this._shadows=[],this._shadowsTextures=[],this._targetByUnit=[],this.initAttributes(t),this.initTextureAttributes(r),this.defineShaderName(),this.initDefines()}return Object(S["a"])(e,[{key:"getCompilerName",value:function(){return"PBR"}},{key:"getFragmentMain",value:function(){return"pbr.frag"}},{key:"getVertexMain",value:function(){return"pbr.vert"}},{key:"initAttributes",value:function(e){for(var t=this._lights,r=this._shadows,n=0;n<e.length;n++){var i=e[n].className();"Light"===i?t.push(e[n]):"Material"===i?this._material=e[n]:"ShadowReceiveAttribute"===i?r.push(e[n]):"SkinningAttribute"===i?this._skinning=e[n]:"MorphAttribute"===i?this._morphing=e[n]:"PointSizeAttribute"===i?this._pointSize=e[n]:"VertexCompression"===i&&(this._compression=e[n])}}},{key:"initTextureAttributes",value:function(e){for(var t=0;t<e.length;t++){var r=e[t];if(r)for(var n=0;n<r.length;n++){var i=r[n];this._targetByUnit[t]=i;var a=i.className();if("TextureEnvironment"===a){var o=i.getChannel();"SpecularPBR"===o||"Specular"===o?this._envSpecular=i:"IntegrateBRDF"===o&&(this._envBrdf=i)}"ShadowTexture"!==a&&"ShadowTextureAtlas"!==a||this._shadowsTextures.push(i)}}}},{key:"defineShaderName",value:function(){this._vertDefines.push("#define SHADER_NAME "+this.getVertexShaderName()),this._fragDefines.push("#define SHADER_NAME "+this.getFragmentShaderName());var e=(1-M.epsilonAlpha).toExponential();this._fragDefines.push("#define EPSILON_ALPHA "+e)}},{key:"getFragmentShaderName",value:function(){var e=this.getCompilerName(),t=this._material&&this._material.getName();t&&(e+="("+(t=t.replace(/[^a-zA-Z0-9]+/g,"_").slice(0,20))+")");var r,n=this._channels&&this._channels.Opacity,i=n&&n.isEffective()&&n.get("type");if(r="alphaBlend"===i||"additive"===i?"Blend":"refraction"===i?"Refract":"dithering"===i?"Dither":"Opaque",this._channels&&this._channels.AlphaMask&&this._channels.AlphaMask.isEffective()&&(r="AlphaMask"+r),r){var a=this.getCompilerName();e=e.replace(a,a+"_"+r)}return e}},{key:"getVertexShaderName",value:function(){return this.getFragmentShaderName()}},{key:"getDebugIdentifier",value:function(){var e=this.getVertexShaderName(),t=this.getFragmentShaderName();return e===t?t:e+"|"+t}},{key:"createShader",value:function(e){var t=e?this.getFragmentMain():this.getVertexMain(),r=e?this._fragDefines:this._vertDefines;e||r.push("#define ASSIGN_UV "+this._vertAssignUV.join(" ")),r=Wc.getSortedUnique(r);for(var n="",i=0;i<r.length;++i)r[i]&&(n+=r[i]+"\n");return n=(n="#define SHADER_NAME "+this.getFragmentShaderName()+"\n"+n)+'#pragma include "'+t+'"',Wc.processShader(n)}},{key:"createFragmentShader",value:function(){return this.createShader(!0)}},{key:"createVertexShader",value:function(){return this.createShader(!1)}},{key:"declareAndAssignTexCoord",value:function(e,t){var r="TexCoord"+e;if(this._vertDefines.push("attribute vec2 "+r+";"),t&&!this._compression)return r;var n="vTexCoord"+e,i="varying vec2 "+n+";",a="vec2 "+n+";";if(t)-1===this._vertDefines.indexOf(i)&&this._vertDefines.push("vec2 "+n+";");else{this._fragDefines.push(i),this._vertDefines.push(i);var o=this._vertDefines.indexOf(a);-1!==o&&this._vertDefines.splice(o,1)}var s=n+" = ";if(this._compression){var u="uQUV"+e;this._vertDefines.push("uniform vec4 "+u+";"),s+=r+".xy * "+u+".zw + "+u+".xy;"}else s+=r+";";return-1===this._vertAssignUV.indexOf(s)&&this._vertAssignUV.push(s),n}},{key:"_getTexCoordTransforms",value:function(e,t){var r="u"+t;return e="vec2( mat2("+r+"UVTransforms) * "+e,e+" + "+r+"UVOffset)"}},{key:"getChannelUV",value:function(e){var t=e.getName();if(!e.getTextureModel()){var r=E.Z.getColorPacking(t);return 0===r?"vec2(0.125, 0.5)":1===r?"vec2(0.375, 0.5)":2===r?"vec2(0.625, 0.5)":"vec2(0.875, 0.5)"}var n="Displacement"===e.get("name"),i=this.declareAndAssignTexCoord(e.getTexCoordUnit(),n);return e.getNonIdentityUvTransform()&&(i=this._getTexCoordTransforms(i,e.get("name"))),i}},{key:"defineOpacity",value:function(e){var t=e.get("type");"alphaBlend"!==t&&"additive"!==t?"dithering"!==t?(this._fragDefines.push("#define HAS_OPACITY_REFRACTION"),e.get("useNormalOffset")&&this._fragDefines.push("#define HAS_REFRACTION_NORMAL_OFFSET"),e.get("useAlbedoTint")&&this._fragDefines.push("#define HAS_REFRACTION_ALBEDO_TINT"),e.get("useMicrosurfaceTexture")&&this._fragDefines.push("#define HAS_REFRACTION_MICROSURFACE"),M.depthMipmap&&this._fragDefines.push("#define DEPTH_MIPMAP")):this._fragDefines.push("#define HAS_OPACITY_DITHER"):this._fragDefines.push("#define HAS_OPACITY_BLEND_OR_ADDITIVE")}},{key:"defineChannel",value:function(e){var t=e.getName();if(e.isEnableEffectiveHardware(this._material)){var r="Displacement"===t?this._vertDefines:this._fragDefines,n=t.toUpperCase();if(r.push("#define HAS_"+n),"NormalMap"!==t&&"Inspector"!==t||this._vertDefines.push("#define HAS_"+n),e.isEffective()){"NormalMap"!==t&&"BumpMap"!==t&&"ClearCoatNormalMap"!==t&&"Anisotropy"!==t||(this._fragDefines.push("#define HAS_VIEW_TANGENT"),this._vertDefines.push("#define HAS_VIEW_TANGENT")),"Opacity"===t&&this.defineOpacity(e),"Displacement"===t&&((0,b.Z)().substanceDisplacement?r.push("#define HAS_SUBSTANCE_DISPLACEMENT"):r.push("#define HAS_EDITOR_DISPLACEMENT"));var i=E.Z.getColorPacking(t);if(e.getTextureModel()||!(i<0)){var a=this._material.getChannelMapping(t);if(!(void 0===a||a<0)){var o=this._targetByUnit[a],s=o.getName(),u=o.getChannelPacking(t),c=e.getSRGB()?"sRGBToLinear":"",l=t.toUpperCase(),h=this.getChannelUV(e);r.push("uniform sampler2D "+s+";"),r.push("uniform vec4 u"+t+"UVTransforms;"),r.push("uniform vec2 u"+t+"UVOffset;"),r.push("#define SAMPLER_"+l+" "+s),r.push("#define PACK_"+l+" "+u),r.push("#define UV_"+l+" "+h),r.push("#define COLOR_CONVERT_"+l+" "+c)}}}}}},{key:"defineVertexColorAndAlpha",value:function(){if(this._material&&this._material.getVertexColorEnable()){this._fragDefines.push("#define HAS_VERTEX_COLOR"),this._vertDefines.push("#define HAS_VERTEX_COLOR");var e="srgb"===this._material.getVertexColorColorSpace()?"sRGBToLinear":"";this._fragDefines.push("#define COLOR_CONVERT_VERTEX_COLOR "+e),this._material.getVertexAlphaEnable()&&(this._fragDefines.push("#define HAS_VERTEX_ALPHA"),this._vertDefines.push("#define HAS_VERTEX_ALPHA"))}}},{key:"defineLights",value:function(){var e=this._lights;if(e.length){for(var t=0;t<e.length;++t){var r=e[t],n=r.getLightNumber(),i="LIGHT_"+r.getLightType();this._fragDefines.push("#define LIGHT_TYPE_"+n+" "+i)}this._fragDefines.push("#define HAS_LIGHT")}}},{key:"defineShadows",value:function(){var e=this._shadows;if(e.length){for(var t=0;t<e.length;++t){var r=e[t];this._fragDefines.push("#define HAS_SHADOW_"+r.getLightNumber()),this._fragDefines.push.apply(this._fragDefines,r.getDefines())}this._fragDefines.push("#define HAS_SHADOW"),this._vertDefines.push("#define HAS_MODEL_VERTEX"),this._vertDefines.push("#define HAS_MODEL_NORMAL")}}},{key:"defineEnvironment",value:function(){this._envSpecular&&(this._fragDefines.push("#define HAS_ENVIRONMENT"),this._envSpecular.getIsCubemap()?this._fragDefines.push("#define ENV_CUBEMAP"):this._fragDefines.push("#define ENV_PANORAMA")),this._envBrdf&&this._fragDefines.push("#define HAS_ENVIRONMENT_BRDF")}},{key:"defineSsr",value:function(){}},{key:"defineSkinning",value:function(){this._skinning&&(this._vertDefines.push("#define HAS_SKINNING"),this._vertDefines.push("#define NUM_BONES "+this._skinning.getBoneUniformSize()))}},{key:"defineMorphing",value:function(){this._morphing&&this._morphing.hasTarget("Vertex")&&(this._vertDefines.push("#define HAS_MORPHING"),this._vertDefines.push("#define NUM_TARGETS "+this._morphing.getNumTargets()),this._morphing.hasTarget("Normal")&&this._vertDefines.push("#define HAS_MORPHING_NORMAL"),this._morphing.hasTarget("Tangent")&&this._vertDefines.push("#define HAS_MORPHING_TANGENT"))}},{key:"defineChannels",value:function(){var e=this._channels;for(var t in e)this.defineChannel(e[t])}},{key:"_randHardcodedScale",value:function(){var e,t=w["default"].BufferArray.randa,r=t[0],n=t[1],i=t[2];Ye>.5?e="* ":(e="/ ",r=1/r,n=1/n,i=1/i),r=r.toExponential(),n=n.toExponential(),i=i.toExponential();var a=Math.random();return a<.33?e+"vec3("+i+","+r+","+n+").yzx":a<.66?e+"vec3("+n+","+i+","+r+").zxy":e+"vec3("+i+","+r+","+n+").yzx"}},{key:"defineCompression",value:function(){this._compression&&(0,b.Z)().zz&&(this._vertDefines.push("#define RAND_SCALE "+this._randHardcodedScale()),this._vertDefines.push("#define HAS_COMPRESSION"),(0,b.Z)().zoct&&this._vertDefines.push("#define HAS_OCT_COMPRESSION"),(0,b.Z)().zw&&this._vertDefines.push("#define HAS_ZW_COMPRESSION"))}},{key:"definePointSize",value:function(){this._pointSize&&(this._vertDefines.push("#define HAS_POINT_SIZE"),this._pointSize.isCircleShape()&&this._fragDefines.push("#define HAS_POINT_CIRCLE"))}},{key:"initDefines",value:function(){this.defineChannels(),this.defineVertexColorAndAlpha(),this.defineLights(),this.defineShadows(),this.defineEnvironment(),this.defineSsr(),this.defineMorphing(),this.defineSkinning(),this.defineCompression(),this.definePointSize()}}]),e}();w["default"].setStateAttributeConfig(Xc,{attribute:["VertexCompression","EditorLight0","EditorLight1","EditorLight2","EditorLight3","ShadowReceive0","ShadowReceive1","ShadowReceive2","ShadowReceive3","PBRMaterial","Morph","Skinning","PointSize"],textureAttribute:["Texture"]});var qc=Xc,Yc=function(){return!!navigator.userAgent.match(/Mobile/i)||(!!navigator.userAgent.match(/Android/i)||(!!navigator.userAgent.match(/iPhone/i)||(!!navigator.userAgent.match(/iPad/i)||(!!navigator.userAgent.match(/iPod/i)||(!!navigator.userAgent.match(/BlackBerry/i)||!!navigator.userAgent.match(/Windows Phone/i))))))}(),Kc='\n\n#extension GL_EXT_shader_texture_lod : enable\n#extension GL_OES_standard_derivatives : enable\nprecision highp float;\nuniform mat4 uViewMatrix;\nvarying vec2 vTexCoord0;\nvarying vec3 vModelNormal;\nvarying vec3 vModelVertex;\nvarying vec3 vAutoUVCoord;\nvarying vec3 vWorldNormal;\nvarying vec4 vViewTangent;\nuniform int uToneMethod;\n\nuniform float uBrightness;\nuniform float uScale;\n\nuniform sampler2D albedoMap; // tcolors\nuniform sampler2D metallicMap; // tspec - triangles\nuniform sampler2D normalMap;\nuniform sampler2D roughnessMap; // tpoints\n\n\n#pragma include "triplanar_projection.glsl"\nvec4 fetchTexture(sampler2D texture, vec2 yz, vec2 xz, vec2 yx) {\n vec4 color;\n // vec3 coord = vAutoUVCoord * .1;\n if (vWorldNormal.x < 0.) yz.x = 1.0 - yz.x;\n if (vWorldNormal.y > 0.) xz.x = 1.0 - xz.x;\n if (vWorldNormal.z > 0.) yx.x = 1.0 - yx.x;\n color = triplanlar_projection(yz, xz, yx, texture);\n return color;\n}\n\nvec3 gAutoUVCoord;\n\n#define FragColor gl_FragColor\nconst float REC_PI = 0.31830988618;\nconst float REC_PI2 = 0.15915494;\nvoid getNormal(out vec3 n1, out vec3 n2, out vec3 n3, out vec3 n4) {\n vec3 pos_dx = dFdx(vModelVertex.xyz);\n vec3 pos_dy = dFdy(vModelVertex.xyz);\n vec2 tex_dx = dFdx(vTexCoord0);\n vec2 tex_dy = dFdy(vTexCoord0);\n vec3 t = normalize(pos_dx * tex_dy.t - pos_dy * tex_dx.t);\n vec3 b = normalize(-pos_dx * tex_dy.s + pos_dy * tex_dx.s);\n mat3 tbn = mat3(t, b, normalize(vModelNormal));\n\n vec4 tangent = vViewTangent; \n // my tbn \n vec3 tang = vec3(0.0, 1.0, 0.0);\n if (length(tangent.xyz) != 0.0) {\n tang = normalize(tangent.xyz);\n }\n vec3 B = tangent.w * cross(vModelNormal, tang);\n tbn = mat3(tang, B, normalize(vModelNormal));\n\n n4 = normalize((uViewMatrix * vec4(vModelNormal, 0.0)).xyz);\n\n vec2 yz = gAutoUVCoord.yz * 0.5;\n vec2 xz = gAutoUVCoord.xz * 0.5;\n vec2 yx = gAutoUVCoord.yx * 0.5;\n yz.x += n4.x * 0.3;\n yz.y += n4.y * 0.3;\n yz.x += n4.z * 0.6;\n \n xz.x += n4.x * 0.3;\n xz.y += n4.y * 0.3;\n xz.x += n4.z * 0.6;\n\n yx.x += n4.x * 0.3;\n yx.y += n4.y * 0.3;\n yx.x += n4.z * 0.6;\n\n n1 = fetchTexture(normalMap, yz, xz, yx).rgb * 2.0 - 1.0;\n\n //-------\n yz = gAutoUVCoord.yz * 1.;\n xz = gAutoUVCoord.xz * 1.;\n yx = gAutoUVCoord.yx * 1.;\n\n yz.x += n4.x * 0.2;\n yz.y += n4.y * 0.3;\n yz.y += n4.z * 0.3;\n \n xz.x += n4.x * 0.2;\n xz.y += n4.y * 0.3;\n xz.y += n4.z * 0.3;\n\n yx.x += n4.x * 0.2;\n yx.y += n4.y * 0.3;\n yx.y += n4.z * 0.3; \n\n n2 = fetchTexture(normalMap, yz, xz, yx).rgb * 2.0 - 1.0;\n // ---------\n\n yz = gAutoUVCoord.yz * 1.6;\n xz = gAutoUVCoord.xz * 1.6;\n yx = gAutoUVCoord.yx * 1.6; \n\n yz.x += n4.y * -0.4;\n yz.y += n4.x * 0.4;\n yz.x += n4.z * 0.2;\n\n xz.x += n4.y * -0.4;\n xz.y += n4.x * 0.4;\n xz.x += n4.z * 0.2;\n\n yx.x += n4.y * -0.4;\n yx.y += n4.x * 0.4;\n yx.x += n4.z * 0.2;\n n3 = fetchTexture(normalMap, yz, xz, yx).rgb * 2.0 - 1.0;\n\n // ------\n\n n1 = normalize((uViewMatrix * vec4(normalize(tbn * n1), 0.0)).xyz); \n n2 = normalize((uViewMatrix * vec4(normalize(tbn * n2), 0.0)).xyz);\n n3 = normalize((uViewMatrix * vec4(normalize(tbn * n3), 0.0)).xyz);\n \n}\n\n\nfloat sRGBToLinear(const in float color) {\n return color < 0.04045 ? color * (1.0 / 12.92) : pow((color + 0.055) * (1.0 / 1.055), 2.4);\n}\nvec3 sRGBToLinear(const in vec3 color) {\n return vec3( color.r < 0.04045 ? color.r * (1.0 / 12.92) : pow((color.r + 0.055) * (1.0 / 1.055), 2.4), color.g < 0.04045 ? color.g * (1.0 / 12.92) : pow((color.g + 0.055) * (1.0 / 1.055), 2.4), color.b < 0.04045 ? color.b * (1.0 / 12.92) : pow((color.b + 0.055) * (1.0 / 1.055), 2.4));\n}\nvec4 sRGBToLinear(const in vec4 color) {\n return vec4( color.r < 0.04045 ? color.r * (1.0 / 12.92) : pow((color.r + 0.055) * (1.0 / 1.055), 2.4), color.g < 0.04045 ? color.g * (1.0 / 12.92) : pow((color.g + 0.055) * (1.0 / 1.055), 2.4), color.b < 0.04045 ? color.b * (1.0 / 12.92) : pow((color.b + 0.055) * (1.0 / 1.055), 2.4), color.a);\n}\n\nfloat getLuminance(const in vec3 color) {\n const vec3 colorBright = vec3(0.2126, 0.7152, 0.0722);\n return dot(color, colorBright);\n}\n\nvoid main() {\n \n gTriWeight = calculateTriplanlartriweight(vWorldNormal);\n gAutoUVCoord = vAutoUVCoord * 0.1 * uScale;\n\n float ior = 2.5;\n float radius = 1.0;\n // vec3 dir1 = normalize(vViewDir);\n vec3 normal1 = normalize(vModelNormal);\n vec3 n1;\n vec3 n2;\n vec3 n3;\n vec3 n4;\n getNormal(n1, n2, n3, n4);\n //float isTop = step(0.99, dot(vec3(0, 1, 0), vModelNormal2));\n //float isLookingDown = smoothstep(0.8, 1.0, dot(vec3(0, -1, 0), dir1));\n float isTop = 0.0;\n float isLookingDown = 0.0;\n vec3 color = vec3(0.4);\n\n vec2 yz = gAutoUVCoord.yz * 0.8 + n2.xy * 0.5;\n vec2 xz = gAutoUVCoord.xz * 0.8 + n2.xy * 0.5;\n vec2 yx = gAutoUVCoord.yx * 0.8 + n2.xy * 0.5; \n color += fetchTexture(metallicMap, yz, xz, yx).rgb * 0.4;\n\n vec2 uv3 = vTexCoord0 * 1.3 + n3.xy * 0.4 + n3.z * 0.2;\n color += texture2D(roughnessMap, uv3).rgb * 0.5 * (1.0 - isTop);\n\n yz = gAutoUVCoord.yz * 1.3 + n3.xy * 0.4 + n3.z * 0.2;\n xz = gAutoUVCoord.xz * 1.3 + n3.xy * 0.4 + n3.z * 0.2;\n yx = gAutoUVCoord.yx * 1.3 + n3.xy * 0.4 + n3.z * 0.2; \n color += fetchTexture(roughnessMap, yz, xz, yx).rgb * 0.5 * (1.0 - isTop); \n\n yz = gAutoUVCoord.yz * 0.3 + n4.xy * 1.5 + n4.z * 0.8;\n xz = gAutoUVCoord.xz * 0.3 + n4.xy * 1.5 + n4.z * 0.8;\n yx = gAutoUVCoord.yx * 0.3 + n4.xy * 1.5 + n4.z * 0.8; \n color += fetchTexture(metallicMap, yz, xz, yx).rgb * 0.8 * isTop * (1.0 - 0.7 * isLookingDown); // DING DING DING \n \n yz = gAutoUVCoord.yz * 0.6 + n2.xy * 0.3 + n2.z * 0.2;\n xz = gAutoUVCoord.xz * 0.6 + n2.xy * 0.3 + n2.z * 0.2;\n yx = gAutoUVCoord.yx * 0.6 + n2.xy * 0.3 + n2.z * 0.2; \n color += fetchTexture(metallicMap, yz, xz, yx).rgb * 0.5 * (1. - isTop); \n \n yz = gAutoUVCoord.yz * 0.5 + n1.xy * 0.6 + n1.z * 0.1;\n xz = gAutoUVCoord.xz * 0.5 + n1.xy * 0.6 + n1.z * 0.1;\n yx = gAutoUVCoord.yx * 0.5 + n1.xy * 0.6 + n1.z * 0.1;\n color += fetchTexture(albedoMap, yz, xz, yx).rgb * 0.5;\n\n color = pow(color, vec3(1.2)) * 1.1;\n //float alpha = step(dot(vec3(0, 1, 0), vModelNormal2), 0.99);\n float alpha = pow(color.g, 1.0); \n \n color = mix(color, vec3(0.970, 0.926, 0.917), 0.22);\n FragColor.rgb = color * uBrightness;// * vec3(uBrightness * 1.2);\n\n // my handle\n FragColor.rgb *= alpha; \n // FragColor.rgb *= 1.0 + getLuminance(FragColor.rgb); \n FragColor.a = 1.0;\n \n // if (uToneMethod > 0) {\n // FragColor.rgb = vec3(1., 0., 0.);\n // }\n FragColor.rgb = sRGBToLinear(FragColor.rgb); \n\n\n}\n\n',Jc=Ka["default"].NextShaderProcessor,Zc=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(e,n){var i;return Object(v["a"])(this,r),i=t.call(this,e,n),i._changeColorAttribute,i}return Object(S["a"])(r,[{key:"getCompilerName",value:function(){return"PBR"}},{key:"getFragmentMain",value:function(){return"pbrFrag.glsl"}},{key:"getVertexMain",value:function(){return"baseVert.glsl"}},{key:"initAttributes",value:function(e){for(var t=0;t<e.length;t++){var r=e[t].className();"PBRMaterial"===r?this._material=e[t]:"EditorLight"==r?this._lights.push(e[t]):"Material"===r?this._originMaterial=e[t]:"SkinningAttribute"===r?this._skinning=e[t]:"MorphAttribute"===r?this._morphing=e[t]:"UVTransformAttribute"==r?this._uvTransform=e[t]:"UVProjectionAttribute"==r?this._uvProjection=e[t]:"StickerAttribute"==r?this._sticker=e[t]:"ShadowReceiveAttribute"==r?this._shadows.push(e[t]):"ChangeColorAttribute"===r?this._changeColorAttribute=e[t]:"DiamondAttribute"===r&&(this._diamondAttribute=e[t])}}},{key:"initTextureAttributes",value:function(e){for(var t=0;t<e.length;t++){var r=e[t];if(r)for(var n=0;n<r.length;n++){var i=r[n];this._targetByUnit[t]=i;var a=i.className();if("TextureEnvironment"===a){var o=i.getChannel();"SpecularPBR"===o?this._envSpecular=i:"IntegrateBRDF"===o&&(this._envBrdf=i)}"ShadowTexture"!==a&&"ShadowTextureAtlas"!==a||this._shadowsTextures.push(i)}}}},{key:"defineShaderName",value:function(){this._vertDefines.push("#define SHADER_NAME "+this.getVertexShaderName()),this._fragDefines.push("#define SHADER_NAME "+this.getFragmentShaderName())}},{key:"getFragmentShaderName",value:function(){var e=this.getCompilerName(),t=this._originMaterial&&this._originMaterial.getName();return t&&(e+="("+(t=t.replace(/[^a-zA-Z0-9]+/g,"_").slice(0,20))+")"),e+=this._material.getHasOpacityMap()||this._material.getOpacityFactor()<1?"_BLEND":"_OPAQUE",e}},{key:"getVertexShaderName",value:function(){return this.getFragmentShaderName()}},{key:"getDebugIdentifier",value:function(){var e=this.getVertexShaderName(),t=this.getFragmentShaderName();return e===t?t:e+"|"+t}},{key:"createShader",value:function(e){var t=e?this.getFragmentMain():this.getVertexMain(),r=e?this._fragDefines:this._vertDefines;r=Jc.getSortedUnique(r);for(var n="",i=0;i<r.length;++i)r[i]&&(n+=r[i]+"\n");return n="#define SHADER_NAME "+this.getFragmentShaderName()+"\n"+n,e&&this._diamondAttribute?n+=Kc:n+='#pragma include "'+t+'"',Jc.processShader(n)}},{key:"createFragmentShader",value:function(){return this.createShader(!0)}},{key:"createVertexShader",value:function(){return this.createShader(!1)}},{key:"declareAndAssignTexCoord",value:function(e,t){}},{key:"_getTexCoordTransforms",value:function(e,t){}},{key:"getChannelUV",value:function(e){}},{key:"defineOpacity",value:function(){this._material.getHasOpacityMap()&&this._fragDefines.push("#define HAS_OPACITYMAP"),this._material._invertAlpha&&this._fragDefines.push("#define INVERT_ALPHA")}},{key:"defineChannel",value:function(e){e.getName()}},{key:"defineVertexColorAndAlpha",value:function(){this._material&&this._material.getVertexColorEnable()&&(this._fragDefines.push("#define HAS_VERTEX_COLOR"),this._vertDefines.push("#define HAS_VERTEX_COLOR"))}},{key:"defineEnvironment",value:function(){this._envSpecular&&(this._fragDefines.push("#define LUV"),this._envSpecular.getIsCubemap()?this._fragDefines.push("#define ENV_CUBEMAP"):this._fragDefines.push("#define ENV_PANORAMA"))}},{key:"defineSsr",value:function(){}},{key:"defineSkinning",value:function(){this._skinning&&(this._vertDefines.push("#define HAS_SKINNING"),this._vertDefines.push("#define NUM_BONES "+this._skinning.getBoneUniformSize()))}},{key:"defineMorphing",value:function(){this._morphing&&(this._morphing.hasTarget("Vertex")&&(this._vertDefines.push("#define HAS_MORPHING"),this._vertDefines.push("#define NUM_TARGETS "+this._morphing.getNumTargets())),this._morphing.hasTarget("Normal")&&this._vertDefines.push("#define HAS_MORPHING_NORMAL"),this._morphing.hasTarget("Tangent")&&this._vertDefines.push("#define HAS_MORPHING_TANGENT"))}},{key:"defineChannels",value:function(){var e=this._channels;for(var t in e)this.defineChannel(e[t]);this._changeColorAttribute&&(this._fragDefines.push("#define CHANGE_COLOR"),this._changeColorAttribute.isUseSourceColor()?this._fragDefines.push("#define CHANGE_COLOR_SOURCE"):this._fragDefines.push("#define FETCH_LOD")),this._material.getHasNormalMap()&&this._fragDefines.push("#define HAS_NORMALMAP"),this._material.getHasClearcoat()&&this._fragDefines.push("#define HAS_CLEARCOAT"),this._material.getHasAOMap()&&this._fragDefines.push("#define HAS_AOMAP"),this._material.getHasDisplacementMap()&&(this._vertDefines.push("#define HAS_DISPLACEMENT"),this._vertDefines.push("#define HAS_MODEL_NORMAL")),this._material.getMetalnessWorkFlow()||this._fragDefines.push("#define SPECULAR_GLOSSINESS")}},{key:"defineUV",value:function(){if(this._uvTransform&&(this._fragDefines.push("#define UV_TRANSFORM"),this._vertDefines.push("#define UV_TRANSFORM")),this._uvProjection){var e=this._uvProjection.getMode();this._fragDefines.push("#define "+e),this._vertDefines.push("#define "+e)}}},{key:"defineSticker",value:function(){if(this._sticker){var e=this._sticker._feature._stickers.length;e>0&&(this._fragDefines.push("#define HAS_STICKER "),this._fragDefines.push("#define STICKER_NUM "+e))}}},{key:"defineCompression",value:function(){}},{key:"definePointSize",value:function(){}},{key:"defineUnLit",value:function(){this._material.getUnLit()&&this._fragDefines.push("#define UNLIT")}},{key:"initDefines",value:function(){Yc&&this._fragDefines.push("#define MOBILE"),this.defineChannels(),this.defineLights(),this.defineShadows(),this.defineEnvironment(),this.defineMorphing(),this.defineSkinning(),this.defineUV(),this.defineOpacity(),this.defineSticker(),this.defineUnLit()}}]),r}(qc);w["default"].setStateAttributeConfig(Zc,{attribute:["PBRMaterial","EditorLight0","EditorLight1","EditorLight2","EditorLight3","ShadowReceive0","ShadowReceive1","ShadowReceive2","ShadowReceive3","Material","Morph","Skinning","UVTransformAttribute","UVProjectionAttribute","StickerAttribute","ChangeColorAttribute","DiamondAttribute"],textureAttribute:["Texture"]});var Qc=Zc,$c=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(e,n){return Object(v["a"])(this,r),t.call(this,e,n)}return Object(S["a"])(r,[{key:"getCompilerName",value:function(){return"OutLine"}},{key:"getFragmentMain",value:function(){return"outline.frag"}},{key:"getVertexMain",value:function(){return"outline.vert"}},{key:"getFragmentShaderName",value:function(){var e=this.getCompilerName();return e}}]),r}(Qc);w["default"].setStateAttributeConfig($c,{attribute:["VertexCompression","PBRMaterial","Morph","Skinning","PointSize","UVTransformAttribute","UVProjectionAttribute"],textureAttribute:["Texture"]});var el=$c,tl=Ka["default"].NextShaderProcessor,rl=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(e,n){return Object(v["a"])(this,r),t.call(this,e,n)}return Object(S["a"])(r,[{key:"getCompilerName",value:function(){return"EarlyZ"}},{key:"getFragmentMain",value:function(){return"earlyZFrag.glsl"}},{key:"initDefines",value:function(){Object(yr["a"])(Object(Cr["a"])(r.prototype),"initDefines",this).call(this),this._material.getOnlyDepthMaskNoShading()&&this._fragDefines.push("#define ONLY_DEPTH_NO_SHADE"),this._diamondAttribute&&this._fragDefines.push("#define DIAMOND")}},{key:"createShader",value:function(e){var t=e?this.getFragmentMain():this.getVertexMain(),r=e?this._fragDefines:this._vertDefines;r=tl.getSortedUnique(r);for(var n="",i=0;i<r.length;++i)r[i]&&(n+=r[i]+"\n");return n="#define SHADER_NAME "+this.getFragmentShaderName()+"\n"+n,n+='#pragma include "'+t+'"',tl.processShader(n)}}]),r}(Qc);w["default"].setStateAttributeConfig(rl,{attribute:["PBRMaterial","Material","Morph","Skinning","UVTransformAttribute","UVProjectionAttribute","DiamondAttribute"],textureAttribute:["Texture"]});var nl=rl,il=Ka["default"].NextShaderProcessor,al=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(e,n){return Object(v["a"])(this,r),t.call(this,e,n)}return Object(S["a"])(r,[{key:"getCompilerName",value:function(){return"ShadowCast"}},{key:"getFragmentMain",value:function(){return"shadowCastFrag.glsl"}},{key:"getVertexMain",value:function(){return"shadowing/shadowCast.vert"}},{key:"initAttributes",value:function(e){for(var t=0;t<e.length;t++){var r=e[t].className();"PBRMaterial"===r?this._material=e[t]:"EditorLight"==r?this._lights.push(e[t]):"Material"===r?this._originMaterial=e[t]:"SkinningAttribute"===r?this._skinning=e[t]:"MorphAttribute"===r?this._morphing=e[t]:"UVTransformAttribute"==r?this._uvTransform=e[t]:"UVProjectionAttribute"==r?this._uvProjection=e[t]:"StickerAttribute"==r?this._sticker=e[t]:"ShadowReceiveAttribute"==r&&this._shadows.push(e[t])}}},{key:"initTextureAttributes",value:function(e){for(var t=0;t<e.length;t++){var r=e[t];if(r)for(var n=0;n<r.length;n++){var i=r[n];this._targetByUnit[t]=i;var a=i.className();if("TextureEnvironment"===a){var o=i.getChannel();"SpecularPBR"===o?this._envSpecular=i:"IntegrateBRDF"===o&&(this._envBrdf=i)}"ShadowTexture"!==a&&"ShadowTextureAtlas"!==a||this._shadowsTextures.push(i)}}}},{key:"defineShaderName",value:function(){this._vertDefines.push("#define SHADER_NAME "+this.getVertexShaderName()),this._fragDefines.push("#define SHADER_NAME "+this.getFragmentShaderName())}},{key:"getFragmentShaderName",value:function(){var e=this.getCompilerName(),t=this._originMaterial&&this._originMaterial.getName();return t&&(e+="("+(t=t.replace(/[^a-zA-Z0-9]+/g,"_").slice(0,20))+")"),e+=this._material.getHasOpacityMap()||this._material.getOpacityFactor()<1?"_BLEND":"_OPAQUE",e}},{key:"getVertexShaderName",value:function(){return this.getFragmentShaderName()}},{key:"getDebugIdentifier",value:function(){var e=this.getVertexShaderName(),t=this.getFragmentShaderName();return e===t?t:e+"|"+t}},{key:"createShader",value:function(e){var t=e?this.getFragmentMain():this.getVertexMain(),r=e?this._fragDefines:this._vertDefines;r=il.getSortedUnique(r);for(var n="",i=0;i<r.length;++i)r[i]&&(n+=r[i]+"\n");return n="#define SHADER_NAME "+this.getFragmentShaderName()+"\n"+n,n+='#pragma include "'+t+'"',il.processShader(n)}},{key:"createFragmentShader",value:function(){return this.createShader(!0)}},{key:"createVertexShader",value:function(){return this.createShader(!1)}},{key:"declareAndAssignTexCoord",value:function(e,t){}},{key:"_getTexCoordTransforms",value:function(e,t){}},{key:"getChannelUV",value:function(e){}},{key:"defineOpacity",value:function(){this._material.getHasOpacityMap()&&this._fragDefines.push("#define HAS_OPACITYMAP"),this._material._invertAlpha&&this._fragDefines.push("#define INVERT_ALPHA")}},{key:"defineChannel",value:function(e){e.getName()}},{key:"defineVertexColorAndAlpha",value:function(){this._material&&this._material.getVertexColorEnable()&&(this._fragDefines.push("#define HAS_VERTEX_COLOR"),this._vertDefines.push("#define HAS_VERTEX_COLOR"))}},{key:"defineEnvironment",value:function(){this._envSpecular&&(this._fragDefines.push("#define LUV"),this._envSpecular.getIsCubemap()?this._fragDefines.push("#define ENV_CUBEMAP"):this._fragDefines.push("#define ENV_PANORAMA"))}},{key:"defineSsr",value:function(){}},{key:"defineSkinning",value:function(){this._skinning&&(this._vertDefines.push("#define HAS_SKINNING"),this._vertDefines.push("#define NUM_BONES "+this._skinning.getBoneUniformSize()))}},{key:"defineMorphing",value:function(){this._morphing&&(this._morphing.hasTarget("Vertex")&&(this._vertDefines.push("#define HAS_MORPHING"),this._vertDefines.push("#define NUM_TARGETS "+this._morphing.getNumTargets())),this._morphing.hasTarget("Normal")&&this._vertDefines.push("#define HAS_MORPHING_NORMAL"),this._morphing.hasTarget("Tangent")&&this._vertDefines.push("#define HAS_MORPHING_TANGENT"))}},{key:"defineChannels",value:function(){var e=this._channels;for(var t in e)this.defineChannel(e[t]);this._material.getHasNormalMap()&&this._fragDefines.push("#define HAS_NORMALMAP"),this._material.getHasAOMap()&&this._fragDefines.push("#define HAS_AOMAP")}},{key:"defineUV",value:function(){if(this._uvTransform&&this._fragDefines.push("#define UV_TRANSFORM"),this._uvProjection){var e=this._uvProjection.getMode();switch(e){case UVProjectionAttribute.ProjectionMode.POLAR:this._fragDefines.push("#define "+e);break;case UVProjectionAttribute.ProjectionMode.TRIPLANAR:this._fragDefines.push("#define "+e);break;case UVProjectionAttribute.ProjectionMode.ORTHOGONAL:this._fragDefines.push("#define "+e);break;default:break}}}},{key:"defineCompression",value:function(){}},{key:"definePointSize",value:function(){}},{key:"initDefines",value:function(){Yc&&this._fragDefines.push("#define MOBILE"),this.defineMorphing(),this.defineSkinning(),this.defineUV(),this.defineOpacity()}}]),r}(qc);w["default"].setStateAttributeConfig(al,{attribute:["ShadowCastCompiler","VertexCompression","PBRMaterial","Morph","Skinning","ShadowCast"],textureAttribute:["Texture"]});var ol=al,sl=Ka["default"].ShaderGenerator,ul=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(e,n){var i;return Object(v["a"])(this,r),i=t.call(this),i.compilingProgramNum=-1,i.setShaderCompiler(e),i._materialHashCompiler=n||Hc.SHADING_COMPILER,i}return Object(S["a"])(r,[{key:"getOrCreateProgram",value:function(e){return Hc.CURRENT_COMPILER=this._materialHashCompiler,sl.prototype.getOrCreateProgram.call(this,e)}},{key:"_getProgram",value:function(e,t,r,n){var i=this._cache[e];return i&&-1===i.getAsyncCompiling()?i:i?i.getAsyncLinkingStatus()?(i.getLinkResult(t.getGraphicContext()),this.compilingProgramNum-=1,r.length=0,n.length=0,this.getActiveAttributeList(t,r),this.getActiveTextureAttributeList(t,n),i.setActiveUniforms(this.getActiveUniforms(t,r,n)),i):(t.getUserData().app._frameManager.draw(),i._placeHolder):void 0}},{key:"_createProgram",value:function(e,t,r,n){var i=sl.prototype._createProgram.call(this,e,t,r,n);return-1!==i.getAsyncCompiling()?(this._waitingProgram||(this._waitingProgram=this._createWaitingProgram(t,r,n),this._waitingProgram._name="placeHolder"),i.enableAsyncCompilation(this._waitingProgram,t._frameStamp._frame),compilingProgramNum+=1,this._waitingProgram):i}}]),r}(sl),cl=function(e,t,r,n){e.addShaderGenerator(t,new ul(r,n))},ll=function(e){e.HAS_REGISTED||(e.HAS_REGISTED=!0,cl(e,"outline",el,Hc.SHADOWCAST_COMPILER),cl(e,"earlyz",nl,Hc.EARLYZ_COMPILER),cl(e,"PBR",Qc),cl(e,"shadowcast",ol,Hc.SHADOWCAST_COMPILER))},hl=ll,dl=[0,0],fl=function(){function e(){Object(v["a"])(this,e)}return Object(S["a"])(e,[{key:"init",value:function(e,t){this._dynamicResolutionScaling=[1,1],this._canvasPixelRatio=t,this._canvas=e,this._pixelRatio=[1,1]}},{key:"getCanvasCoord",value:function(e,t){if(t=t||dl,e.center||e.touches){if(e.center)t[0]=e.center.x,t[1]=e.center.y;else{t[0]=t[1]=0;for(var r=e.touches.length,n=0;n<r;++n)t[0]+=e.touches[n].clientX/r,t[1]+=e.touches[n].clientY/r}var i=e.target.getBoundingClientRect();t[0]+=-i.left,t[1]+=-i.top}else t[0]=void 0===e.offsetX?e.layerX:e.offsetX,t[1]=void 0===e.offsetY?e.layerY:e.offsetY;return t}},{key:"getPixelRatio",value:function(){var e=this._dynamicResolutionScaling;return this._pixelRatio[0]=this._canvasPixelRatio*e[0],this._pixelRatio[1]=this._canvasPixelRatio*e[1],this._pixelRatio}},{key:"canvasCoordToGL",value:function(e,t,r){var n=this._canvas;return r=r||w["default"].vec2.create(),pixelratio=this.getPixelRatio(),r[0]=e*pixelratio[0],r[1]=(n.clientHeight-t)*pixelratio[1],r}},{key:"glCoordToCanvas",value:function(e,t,r){var n=this._canvas;r=r||w["default"].vec2.create();var i=this.getPixelRatio();return r[0]=e/i[0],r[1]=n.clientHeight-t/i[1],r}}]),e}(),_l='vec4 encodeDepthAlphaProfileScatter(const in float depth, const in float alpha, const in float profile, const in float scatter) {\r\n vec4 pack = vec4(0.0);\r\n pack.a = alpha;\r\n if(profile == 0.0) {\r\n const vec3 code = vec3(1.0, 255.0, 65025.0);\r\n pack.rgb = vec3(code * depth);\r\n pack.gb = fract(pack.gb);\r\n pack.rg -= pack.gb * (1.0 / 256.0);\r\n }\r\n else {\r\n pack.g = fract(depth * 255.0);\r\n pack.r = depth - pack.g / 255.0;\r\n pack.b = floor(0.5 + scatter * 63.0) * 4.0 / 255.0;\r\n }\r\n pack.b -= mod(pack.b, 4.0 / 255.0);\r\n pack.b += profile / 255.0;\r\n return pack;\r\n}\r\nuniform int uDrawOpaque;\r\nuniform float uOpacityFactor;\r\nuniform vec2 uNearFar;\r\nvarying vec3 vViewVertex;\r\nvarying vec3 vViewNormal;\r\nvarying vec2 vTexCoord0;\r\nvarying vec4 vViewTangent;\r\nvarying vec4 vVertexColor;\r\nvarying vec3 vAutoUVCoord;\r\nvarying vec3 vWorldNormal;\r\n\r\n\r\nvec2 uv;\r\n\r\n#ifdef UV_TRANSFORM\r\nuniform vec4 uUVTransform;\r\n#endif\r\n\r\nvec2 transformUV(vec2 uv) { \r\n\r\n #ifdef UV_TRANSFORM \r\n vec3 transformeduv = mat3(\r\n uUVTransform.x * cos(uUVTransform.y), uUVTransform.x * sin(uUVTransform.y), 0.,\r\n -uUVTransform.x * sin(uUVTransform.y), uUVTransform.x * cos(uUVTransform.y), 0.,\r\n uUVTransform.z, uUVTransform.w, 1.) * vec3(uv, 1.0);\r\n\r\n return transformeduv.xy;\r\n #else\r\n return uv;\r\n #endif\r\n\r\n}\r\n\r\nuniform sampler2D opacityMap;\r\n\r\n#pragma include "utils/functions.glsl"\r\n\r\n\r\n#ifdef TRIPLANAR_PROJECTION\r\n#pragma include "triplanar_projection.glsl"\r\n#endif\r\n\r\n\r\nvec4 fetchTexture(sampler2D texture, vec2 uv) {\r\n\r\n vec4 color;\r\n\r\n #ifdef TRIPLANAR_PROJECTION\r\n vec3 coord = vAutoUVCoord * 0.01;\r\n color = triplanlar_projection(transformUV(coord.zy), transformUV(coord.xz), transformUV(coord.xy), texture);\r\n #else\r\n color = texture2D(texture, uv);\r\n #endif\r\n\r\n return color;\r\n\r\n}\r\n\r\n\r\nfloat getMaterialOpacity() {\r\n float alpha = 1.0;\r\n#ifdef HAS_OPACITYMAP\r\n alpha = fetchTexture(opacityMap, uv).r;\r\n#endif\r\n alpha *= uOpacityFactor;\r\n#ifdef INVERT_ALPHA\r\n alpha = 1.0 - alpha;\r\n#endif\r\n return alpha;\r\n}\r\n\r\nvoid main(void) {\r\n\r\n uv = vTexCoord0;\r\n \r\n #ifdef UV_TRANSFORM\r\n uv = transformUV(uv);\r\n #endif\r\n\r\n \r\n #ifdef TRIPLANAR_PROJECTION\r\n gTriWeight = calculateTriplanlartriweight(vWorldNormal);\r\n #endif\r\n\r\n\r\n float depth = (-vViewVertex.z - uNearFar.x) / (uNearFar.y - uNearFar.x);\r\n float scatter = 0.0;\r\n float profile = 0.0;\r\n float alpha = getMaterialOpacity();\r\n \r\n #ifndef DIAMOND\r\n if (uDrawOpaque == 1 && alpha < 9.9999e-1) discard;\r\n alpha = uDrawOpaque == 1 ? 1.0 : alpha;\r\n #ifdef ONLY_DEPTH_NO_SHADE\r\n alpha = 0.0;\r\n #endif\r\n #else\r\n alpha = 1.0;\r\n #endif\r\n gl_FragColor = encodeDepthAlphaProfileScatter(depth, alpha, profile, scatter);\r\n}\r\n',pl='uniform samplerCube sSpecularPBR;\r\n\r\nuniform mat3 uEnvironmentTransform;\r\nuniform float uLod;\r\nuniform float uEnvironmentExposure;\r\nuniform vec2 uTextureEnvironmentSpecularPBRLodRange;\r\n#ifdef ENV_CUBEMAP\r\n#extension GL_EXT_shader_texture_lod : enable\r\n#endif\r\nuniform vec2 uTextureEnvironmentSpecularPBRTextureSize;\r\n\r\nvarying vec3 vViewVertex;\r\nvarying vec3 vViewNormal;\r\nvarying vec2 vTexCoord0;\r\nvarying vec3 vLocalVertex;\r\n\r\n#pragma include "cubemapSampler.glsl"\r\n#pragma include "utils/functions.glsl"\r\n\r\n\r\nvoid main() {\r\n vec3 direction = normalize( vViewNormal);\r\n //direction = normalize(vViewVertex.xyz); // for cube geometry\r\n direction = uEnvironmentTransform * direction;\r\n#ifdef ENV_CUBEMAP\r\n vec3 color = uEnvironmentExposure * textureCubeLodEXTFixed(sSpecularPBR, direction, uLod ).rgb;\r\n#else\r\n vec3 color = uEnvironmentExposure * textureCubeFixed( sSpecularPBR, direction ).rgb;\r\n#endif\r\n //color = textureCube(uEnvironment, direction ).rgb;\r\n gl_FragColor = vec4( linearTosRGB(color ), 1.0);\r\n}\r\n',gl='#pragma include "utils/functions.glsl"\r\n\r\n\r\n\r\nvec3 scaleDirection(const in float scale, const in vec3 dirIn)\r\n{\r\n vec3 dir = dirIn;\r\n float M = max(max(abs(dir.x), abs(dir.y)), abs(dir.z));\r\n if (abs(dir.x) != M) dir.x *= scale;\r\n if (abs(dir.y) != M) dir.y *= scale;\r\n if (abs(dir.z) != M) dir.z *= scale;\r\n return dir;\r\n}\r\n\r\nvec3 textureCubemapLod(const in samplerCube tex, const in vec3 dir, const in float lod )\r\n{\r\n#ifdef ENV_CUBEMAP\r\n vec4 rgba = textureCubeLodEXT( tex, dir, lod );\r\n#else\r\n vec4 rgba = textureCube( tex, dir );\r\n#endif\r\n#ifdef FLOAT\r\n return rgba.rgb;\r\n#endif\r\n#ifdef RGBE\r\n return RGBEToRGB( rgba );\r\n#endif\r\n#ifdef RGBM\r\n return RGBMToRGB( rgba );\r\n#endif\r\n#ifdef LUV\r\n return LUVToRGB( rgba );\r\n#endif\r\n}\r\n\r\nvec3 textureCubemap(const in samplerCube tex, const in vec3 dir )\r\n{\r\n vec4 rgba = textureCube( tex, dir );\r\n#ifdef FLOAT\r\n return rgba.rgb;\r\n#endif\r\n#ifdef RGBE\r\n return RGBEToRGB( rgba );\r\n#endif\r\n#ifdef RGBM\r\n return RGBMToRGB( rgba );\r\n#endif\r\n#ifdef LUV\r\n return LUVToRGB( rgba );\r\n#else\r\n return rgba.rgb;\r\n#endif\r\n}\r\n\r\n\r\n\r\nvec3 cubemapSeamlessFixDirection(const in vec3 direction, const in float scale )\r\n{\r\n vec3 dir = direction;\r\n // http://seblagarde.wordpress.com/2012/06/10/amd-cubemapgen-for-physically-based-rendering/\r\n float M = max(max(abs(dir.x), abs(dir.y)), abs(dir.z));\r\n\r\n if (abs(dir.x) != M) dir.x *= scale;\r\n if (abs(dir.y) != M) dir.y *= scale;\r\n if (abs(dir.z) != M) dir.z *= scale;\r\n\r\n return dir;\r\n}\r\n\r\nvec3 textureCubeLodEXTFixed(const in samplerCube tex, const in vec3 direction, const in float lodInput )\r\n{\r\n\r\n float lod = min( uTextureEnvironmentSpecularPBRLodRange[0], lodInput );\r\n\r\n // http://seblagarde.wordpress.com/2012/06/10/amd-cubemapgen-for-physically-based-rendering/\r\n float scale = 1.0 - exp2(lod) / uTextureEnvironmentSpecularPBRTextureSize[0];\r\n vec3 dir = cubemapSeamlessFixDirection( direction, scale);\r\n\r\n return textureCubemapLod( tex, dir, lod ).rgb;\r\n}\r\n\r\n\r\n// seamless cubemap for background ( no lod )\r\nvec3 textureCubeFixed(const in samplerCube tex, const in vec3 direction )\r\n{\r\n // http://seblagarde.wordpress.com/2012/06/10/amd-cubemapgen-for-physically-based-rendering/\r\n float scale = 1.0 - 1.0 / uTextureEnvironmentSpecularPBRTextureSize[0];\r\n vec3 dir = cubemapSeamlessFixDirection( direction, scale);\r\n return textureCubemap( tex, dir );\r\n}\r\n',ml="attribute vec3 Vertex;\r\nattribute vec3 Normal;\r\nattribute vec2 TexCoord0;\r\nattribute vec4 Tangent;\r\n\r\nuniform mat4 uModelViewMatrix;\r\nuniform mat4 uModelMatrix;\r\nuniform mat4 uProjectionMatrix;\r\nuniform mat3 uModelViewNormalMatrix;\r\n\r\nvarying vec3 vViewVertex;\r\nvarying vec3 vViewNormal;\r\nvarying vec4 vViewTangent;\r\nvarying vec2 vTexCoord0;\r\nvarying vec3 vLocalVertex;\r\n\r\nvoid main(void) {\r\n\r\n vViewVertex = vec3(uModelViewMatrix * vec4(Vertex, 1.0));\r\n vViewNormal = uModelViewNormalMatrix * Normal;\r\n vLocalVertex = Vertex;\r\n\r\n vViewTangent = vec4(uModelViewNormalMatrix * Tangent.xyz, Tangent.w);\r\n vTexCoord0 = TexCoord0;\r\n\r\n gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(Vertex,1.0);\r\n}\r\n",vl="\r\n#define PI 3.1415926535897932384626433832795\r\n#define PI_2 (2.0*3.1415926535897932384626433832795)\r\n#define INV_PI 1.0/PI\r\n#define INV_LOG2 1.4426950408889634073599246810019\r\n",bl="uniform vec3 uMaskRange;\r\nuniform vec3 uTargetColor;\r\nuniform float uMask;\r\nuniform float uSourceLod;\r\nuniform vec3 uSourceColor;\r\n\r\nfloat deltaE94(vec3 labA, vec3 labB) {\r\n \r\n float deltaL = labA.x - labB.x;\r\n float deltaA = labA.y - labB.y;\r\n float deltaB = labA.z - labB.z;\r\n\r\n float c1 = length(labA.yz);\r\n float c2 = length(labB.yz);\r\n vec2 deltaAB = vec2(deltaA, deltaB);\r\n float deltaC = c1 - c2;\r\n float deltaH = dot(deltaAB, deltaAB) - deltaC * deltaC;\r\n deltaH = (deltaH > 0.)? sqrt(deltaH) : 0.;\r\n float sc = 1. + 0.045 * c1;\r\n float sh = 1. + 0.015 * c1;\r\n \r\n vec3 diffVector;\r\n diffVector.x = deltaL;\r\n diffVector.y = deltaC / sc;\r\n diffVector.z = deltaH / sh;\r\n return length(diffVector);\r\n}\r\n\r\nfloat histogram_scan(float gray, float position, float contrast) {\r\n\r\n float t = 1.0 - position;\r\n float A = (max(t, 0.5) - 0.5) * 2.0;\r\n float B = min(t * 2.0, 1.0);\r\n \r\n float X = clamp(contrast * 0.5, 0., 1.);\r\n float minInput = mix(A, B, X); //0.95 /2\r\n float maxInput = mix(B, A, X); // 1- 0.95 /2\r\n\r\n return clamp((gray - minInput) / (maxInput - minInput), 0., 1.);\r\n}\r\n\r\nfloat deltaE2000(vec3 labA, vec3 labB) {\r\n \r\n \r\n float lBarPrime = 0.5 * (labA.x + labB.x);\r\n float c1 = length(labA.yz);\r\n float c2 = length(labB.yz);\r\n float cBar = 0.5 * (c1 + c2);\r\n float cBar7 = pow(cBar, 7.0);\r\n float g = 0.5 * (1.0 - sqrt(cBar7 / (cBar7 + 6103515625.0)));\r\n float a1Prime = labA.y * (1.0 + g);\r\n float a2Prime = labB.y * (1.0 + g);\r\n float c1Prime = sqrt(a1Prime * a1Prime + labA.z * labA.z);\r\n float c2Prime = sqrt(a2Prime * a2Prime + labB.z * labB.z);\r\n float cBarPrime = 0.5 * (c1Prime + c2Prime);\r\n float h1Prime = atan(labA.z, a1Prime); //rad\r\n float dhPrime;\r\n\r\n if (h1Prime < 0.0) {\r\n h1Prime += PI_2;\r\n }\r\n \r\n float h2Prime = atan(labB.z, a2Prime);\r\n if (h2Prime < 0.0) {\r\n h2Prime += PI_2;\r\n }\r\n \r\n float hBarPrime = (abs(h1Prime - h2Prime) > PI) ? (0.5 * (h1Prime + h2Prime + PI_2)) : (0.5 * (h1Prime + h2Prime));\r\n float t = 1.0 - 0.17 * cos(hBarPrime - PI / 6.0) + 0.24 * cos(2.0 * hBarPrime) + 0.32 * cos(3.0 * hBarPrime + PI / 30.0) - 0.20 * cos(4.0 * hBarPrime - 0.35 * PI);\r\n \r\n if (abs(h2Prime - h1Prime) <= PI) {\r\n dhPrime = h2Prime - h1Prime;\r\n }\r\n else {\r\n dhPrime = (h2Prime <= h1Prime) ? (h2Prime - h1Prime + PI_2) : (h2Prime - h1Prime - PI_2);\r\n }\r\n \r\n float dLPrime = labB.x - labA.x;\r\n float dCPrime = c2Prime - c1Prime;\r\n float dHPrime = 2.0 * sqrt(c1Prime * c2Prime) * sin(0.5 * dhPrime);\r\n float sL = 1.0 + (0.015 * (lBarPrime - 50.0) * (lBarPrime - 50.0)) / sqrt(20.0 + (lBarPrime - 50.0) * (lBarPrime - 50.0));\r\n float sC = 1.0 + 0.045 * cBarPrime;\r\n float sH = 1.0 + 0.015 * cBarPrime * t;\r\n float temp = (hBarPrime - (275.0 * PI / 180.)) / (25.0 * PI / 180.);\r\n float dTheta = PI / 3.0 * exp(-(temp * temp));\r\n float cBarPrime7 = pow(cBarPrime, 7.0);\r\n float rC = sqrt(cBarPrime7 / (cBarPrime7 + 6103515625.0));\r\n float rT = -2.0 * rC * sin(dTheta);\r\n return sqrt((dLPrime / sL) * (dLPrime / sL) + (dCPrime / sC) * (dCPrime / sC) + (dHPrime / sH) * (dHPrime / sH) + (dCPrime / sC) * (dHPrime / sH) * rT);\r\n \r\n}\r\n\r\nvec3 Lab2LCHab(vec3 X) {\r\n \r\n float l = X.x;\r\n float c = length(X.yz);\r\n float h = 180.0 * atan(X.z, X.y) / PI;\r\n if (h < 0.0) {\r\n h += 360.0;\r\n }\r\n return vec3(l, c, h);\r\n}\r\n\r\nvec3 XYZ2Lab(vec3 X) {\r\n vec3 Y = X / vec3(0.95047, 1.0, 1.08883); //D65\r\n vec3 Z;\r\n float powN = 1./3.;\r\n float constN = 16./116.;\r\n Z.x = (Y.x > 0.008856)? pow(Y.x, powN) : (7.787 * Y.x) + constN;\r\n Z.y = (Y.y > 0.008856)? pow(Y.y, powN) : (7.787 * Y.y) + constN;\r\n Z.z = (Y.z > 0.008856)? pow(Y.z, powN) : (7.787 * Y.z) + constN;\r\n return vec3((116. * Z.y) - 16., 500. * (Z.x - Z.y), 200. * (Z.y - Z.z));\r\n}\r\nvec3 sRGB2XYZ(vec3 X) {\r\n vec3 linear = sRGBToLinear(X);\r\n return linear * mat3(0.4124, 0.3576, 0.1805, 0.2126, 0.7152, 0.0722, 0.0193, 0.1192, 0.9505);\r\n}\r\n\r\nvec3 sRGB2Lab(vec3 X) { \r\n return XYZ2Lab(sRGB2XYZ(X));\r\n}\r\n\r\nvec3 sRGB2LCHab(vec3 X) {\r\n return Lab2LCHab(sRGB2Lab(X));\r\n}\r\n\r\nvec3 LCHab2Lab(vec3 X) {\r\n \r\n float l = X.x;\r\n float a = X.y * cos(X.z * PI / 180.0);\r\n float b = X.y * sin(X.z * PI / 180.0);\r\n return vec3(l, a, b);\r\n}\r\n\r\nvec3 Lab2XYZ(vec3 X) {\r\n float fy = (X.x + 16.0) / 116.0;\r\n float fx = 0.002 * X.y + fy;\r\n float fz = fy - 0.005 * X.z;\r\n \r\n float fx3 = fx * fx * fx;\r\n float fz3 = fz * fz * fz;\r\n \r\n float m_kE = 216.0 / 24389.0;\r\n float m_kK = 24389.0 / 27.0;\r\n\r\n float xr = (fx3 > m_kE) ? fx3 : ((116.0 * fx - 16.0) / m_kK);\r\n float yr = (X.x > 8.0) ? pow((X.x + 16.0) / 116.0, 3.0) : (X.x / m_kK);\r\n float zr = (fz3 > m_kE) ? fz3 : ((116.0 * fz - 16.0) / m_kK);\r\n \r\n return vec3(xr, yr, zr) * vec3(0.95047, 1.0, 1.08883);\r\n \r\n}\r\n\r\nvec3 XYZ2sRGB(vec3 X) {\r\n \r\n vec3 linear = X * mat3(3.2404542, -1.5371385, -0.4985314, -0.9692660, 1.8760108, 0.0415560, 0.0556434, -0.2040259, 1.0572252);\r\n return linearTosRGB(linear);\r\n}\r\n\r\nvec3 LCHab2sRGB(vec3 X) {\r\n return XYZ2sRGB(Lab2XYZ(LCHab2Lab(X)));\r\n}\r\n\r\n\r\nfloat luma(vec3 X){\r\n float linearY = dot(sRGBToLinear(X), vec3(0.2126, 0.7152, 0.0722));\r\n return linearTosRGB(linearY);\r\n}\r\n\r\n\r\n// vec3 RGBtoHCL(vec3 RGB)\r\n// {\r\n// vec3 HCL;\r\n// float H = 0.;\r\n// float U = min(RGB.r, min(RGB.g, RGB.b));\r\n// float V = max(RGB.r, max(RGB.g, RGB.b));\r\n// float Q = 0.03;\r\n// HCL.y = V - U;\r\n// if (HCL.y != 0.)\r\n// {\r\n// H = atan(RGB.g - RGB.b, RGB.r - RGB.g) / PI;\r\n// Q *= U / V;\r\n// }\r\n// Q = exp(Q);\r\n// HCL.x = fract(H / 2. - min(fract(H), fract(-H)) / 6.);\r\n// HCL.y *= Q;\r\n// HCL.z = mix(-U, V, Q) / (0.530454533953517 * 2.);\r\n// return HCL;\r\n// }\r\n\r\n \r\n// vec3 HCLtoRGB(vec3 HCL)\r\n// {\r\n// vec3 RGB = vec3(0.);\r\n// if (HCL.z != 0.)\r\n// {\r\n// float H = HCL.x;\r\n// float C = HCL.y;\r\n// float L = HCL.z * 0.530454533953517;\r\n// float Q = exp((1. - C / (2. * L)) * 0.03);\r\n// float U = (2. * L - C) / (2. * Q - 1.);\r\n// float V = C / Q;\r\n// float A = (H + min(fract(2. * H) / 4., fract(-2. * H) / 8.)) * PI * 2.;\r\n// float T;\r\n// H *= 6.;\r\n// if (H <= 0.999)\r\n// {\r\n// T = tan(A);\r\n// RGB.r = 1.;\r\n// RGB.g = T / (1. + T);\r\n// }\r\n// else if (H <= 1.001)\r\n// {\r\n// RGB.r = 1.;\r\n// RGB.g = 1.;\r\n// }\r\n// else if (H <= 2.)\r\n// {\r\n// T = tan(A);\r\n// RGB.r = (1. + T) / T;\r\n// RGB.g = 1.;\r\n// }\r\n// else if (H <= 3.)\r\n// {\r\n// T = tan(A);\r\n// RGB.g = 1.;\r\n// RGB.b = 1. + T;\r\n// }\r\n// else if (H <= 3.999)\r\n// {\r\n// T = tan(A);\r\n// RGB.g = 1. / (1. + T);\r\n// RGB.b = 1.;\r\n// }\r\n// else if (H <= 4.001)\r\n// {\r\n// RGB.g = 0.;\r\n// RGB.b = 1.;\r\n// }\r\n// else if (H <= 5.)\r\n// {\r\n// T = tan(A);\r\n// RGB.r = -1. / T;\r\n// RGB.b = 1.;\r\n// }\r\n// else\r\n// {\r\n// T = tan(A);\r\n// RGB.r = 1.;\r\n// RGB.b = -T;\r\n// }\r\n// RGB = RGB * V + U;\r\n// }\r\n// return RGB;\r\n// }\r\nvec3 RGB2HCL(vec3 X){\r\n float L = dot(X, vec3(0.299, 0.587, 0.114));\r\n float M = max(X.r, max(X.g, X.b));\r\n float m = min(X.r, min(X.g, X.b));\r\n float C = M - m;\r\n float H;\r\n if(abs(C) <= 0.0001) {\r\n H = 0.0;\r\n } \r\n else if(abs(M - X.r) <= 0.0001) {\r\n H = mod((X.g - X.b) / C, 6.0);\r\n } \r\n else if(abs(M - X.g) <= 0.0001) {\r\n H = (X.b - X.r) / C + 2.0;\r\n } \r\n else if(abs(M - X.b) <= 0.0001) {\r\n H = (X.r - X.g) / C + 4.0;\r\n } else {\r\n H = 1.0;\r\n }\r\n \r\n H = H / 6.0;\r\n return vec3(H, C, L);\r\n}\r\n\r\nvec3 HCL2RGB(vec3 X) { \r\n\r\n float H6 = X.x * 6.0;\r\n float temp = (1.0 - abs(mod(H6, 2.0) - 1.0)) * X.y;\r\n vec3 tempRGB;\r\n\r\n if(0.0 <= H6 && H6 <= 1.0) {\r\n tempRGB = vec3(X.y, temp, 0.0);\r\n } \r\n else if(1.0 < H6 && H6 <= 2.0){\r\n tempRGB = vec3(temp, X.y, 0.0);\r\n }\r\n else if(2.0 < H6 && H6 <= 3.0){\r\n tempRGB = vec3(0.0, X.y, temp);\r\n }\r\n else if(3.0 < H6 && H6 <= 4.0){\r\n tempRGB = vec3(0.0, temp, X.y);\r\n }\r\n else if(4.0 < H6 && H6 <= 5.0){\r\n tempRGB = vec3(temp, 0.0, X.y);\r\n }\r\n else if(5.0 < H6 && H6 <= 6.0){\r\n tempRGB = vec3(X.y, 0.0, temp);\r\n } else {\r\n tempRGB= vec3(0.0);\r\n }\r\n float tempLuma = dot(tempRGB, vec3(0.299, 0.587, 0.114));\r\n vec3 RGB = tempRGB + vec3(X.z - tempLuma);\r\n return RGB;\r\n}\r\n\r\n\r\nvec3 changeColor(vec3 originalColor, vec3 sourceColor) {\r\n\r\n vec3 ohcl = RGB2HCL(originalColor);\r\n vec3 shcl = RGB2HCL(sourceColor);\r\n \r\n vec3 deltaHcl = ohcl - shcl;\r\n float absDeltaH = abs(deltaHcl.x);\r\n\r\n float deltaH = min(1.0 - absDeltaH, absDeltaH);\r\n float deltaC = abs(deltaHcl.y);\r\n float deltaL = abs(deltaHcl.z);\r\n \r\n float hRange = uMaskRange.x / 720.0;\r\n float cRange = uMaskRange.y * 0.5;\r\n float lRange = uMaskRange.z * 0.5;\r\n \r\n if(uMask == 1.0 && ((deltaH > hRange) || (deltaC > cRange) || (deltaL > lRange))) {\r\n return originalColor;\r\n } else {\r\n vec3 thcl = RGB2HCL(uTargetColor);\r\n float H = mod(thcl.x, 1.0);\r\n float C = max(deltaHcl.y + thcl.y, 0.0);\r\n float L = max(deltaHcl.z + thcl.z, 0.0);\r\n return HCL2RGB(vec3(H, C, L));\r\n }\r\n \r\n}\r\n",Sl='#pragma include "math.glsl"\r\n#pragma include "utils/functions.glsl"\r\n\r\nvec2 computeUVForMipmap( const in float level, const in vec2 uv, const in float size, const in float maxLOD ) {\r\n\r\n // width for level\r\n float widthForLevel = exp2( maxLOD-level);\r\n\r\n // the height locally for the level in pixel\r\n // to opimitize a bit we scale down the v by two in the inputs uv\r\n float heightForLevel = widthForLevel * 0.5;\r\n\r\n\r\n#if 0\r\n float texelSize = 1.0 / size;\r\n\r\n float resizeX = (widthForLevel - 2.0) * texelSize;\r\n float resizeY = (heightForLevel - 2.0) * texelSize;\r\n\r\n float uvSpaceLocalX = texelSize + uv.x * resizeX;\r\n float uvSpaceLocalY = texelSize + uv.y * resizeY;\r\n\r\n uvSpaceLocalY += (size - widthForLevel ) / size;\r\n\r\n return vec2( uvSpaceLocalX, uvSpaceLocalY);\r\n\r\n#else\r\n // compact version\r\n float texelSize = 1.0/size;\r\n vec2 uvSpaceLocal = vec2(1.0) + uv * vec2(widthForLevel - 2.0, heightForLevel - 2.0);\r\n uvSpaceLocal.y += size - widthForLevel;\r\n return uvSpaceLocal * texelSize;\r\n#endif\r\n\r\n}\r\n\r\n//for y up\r\nvec2 normalToPanoramaUVY( const in vec3 dir )\r\n{\r\n float n = length(dir.xz);\r\n\r\n // to avoid bleeding the max(-1.0,dir.x / n) is needed\r\n vec2 pos = vec2( (n>0.0000001) ? max(-1.0,dir.x / n) : 0.0, dir.y);\r\n\r\n // fix edge bleeding\r\n if ( pos.x > 0.0 ) pos.x = min( 0.999999, pos.x );\r\n\r\n pos = acos(pos)*INV_PI;\r\n\r\n pos.x = (dir.z > 0.0) ? pos.x*0.5 : 1.0-(pos.x*0.5);\r\n\r\n // shift u to center the panorama to -z\r\n pos.x = mod(pos.x-0.25+1.0, 1.0 );\r\n pos.y = 1.0-pos.y;\r\n return pos;\r\n}\r\n\r\n\r\n// for z up\r\nvec2 normalToPanoramaUVZ( const in vec3 dir )\r\n{\r\n float n = length(dir.xy);\r\n\r\n // to avoid bleeding the max(-1.0,dir.x / n) is needed\r\n vec2 pos = vec2( (n>0.0000001) ? max(-1.0,dir.x / n) : 0.0, dir.z);\r\n\r\n // fix edge bleeding\r\n if ( pos.x > 0.0 ) pos.x = min( 0.999999, pos.x );\r\n\r\n pos = acos(pos)*INV_PI;\r\n\r\n // to avoid bleeding the limit must be set to 0.4999999 instead of 0.5\r\n pos.x = (dir.y > 0.0) ? pos.x*0.5 : 1.0-(pos.x*0.5);\r\n\r\n // shift u to center the panorama to -y\r\n pos.x = mod(pos.x-0.25+1.0, 1.0 );\r\n pos.y = 1.0-pos.y;\r\n return pos;\r\n}\r\n\r\n#define normalToPanoramaUV normalToPanoramaUVY\r\n\r\n\r\nvec3 texturePanorama(const in sampler2D tex, const in vec2 uv)\r\n{\r\n vec4 rgba = texture2D(tex, uv );\r\n#ifdef FLOAT\r\n return rgba.rgb;\r\n#endif\r\n#ifdef RGBE\r\n return RGBEToRGB( rgba );\r\n#endif\r\n#ifdef RGBM\r\n return RGBMToRGB( rgba );\r\n#endif\r\n#ifdef LUV\r\n return LUVToRGB( rgba );\r\n#else\r\n return rgba.rgb;\r\n#endif\r\n}\r\n\r\nvec3 texturePanoramaLod(const in sampler2D tex,\r\n const in vec2 size ,\r\n const in vec3 direction,\r\n const in float lodInput,\r\n const in float maxLOD ) {\r\n\r\n float lod = min( maxLOD, lodInput );\r\n vec2 uvBase = normalToPanoramaUV( direction );\r\n\r\n // // we scale down v here because it avoid to do twice in sub functions\r\n // uvBase.y *= 0.5;\r\n\r\n float lod0 = floor(lod);\r\n vec2 uv0 = computeUVForMipmap(lod0, uvBase, size.x, maxLOD );\r\n vec3 texel0 = texturePanorama( tex, uv0.xy);\r\n\r\n float lod1 = ceil(lod);\r\n vec2 uv1 = computeUVForMipmap(lod1, uvBase, size.x, maxLOD );\r\n vec3 texel1 = texturePanorama( tex, uv1.xy);\r\n\r\n return mix(texel0, texel1, fract( lod ) );\r\n}\r\n\r\n',xl='\r\n// require:\r\n// uniform int uEnvironmentMaxLod\r\n// samplerCube uEnvironmentCube\r\n// uniform sampler2D sIntegrateBRDF;\r\n// #pragma include "sphericalHarmonics.glsl"\r\n\r\n\r\n// frostbite, lagarde paper p67\r\n// http://www.frostbite.com/wp-content/uploads/2014/11/course_notes_moving_frostbite_to_pbr.pdf\r\nfloat linRoughnessToMipmap( float roughnessLinear )\r\n{\r\n //return roughnessLinear;\r\n return sqrt(roughnessLinear);\r\n}\r\n\r\nvec3 prefilterEnvMap( float roughnessLinear, const in vec3 R )\r\n{\r\n#ifdef ENV_CUBEMAP\r\n\r\n float lod = linRoughnessToMipmap(roughnessLinear) * uTextureEnvironmentSpecularPBRLodRange[1]; //( uEnvironmentMaxLod - 1.0 );\r\n return textureCubeLodEXTFixed( sSpecularPBR, R, lod ).rgb;\r\n\r\n#elif defined(ENV_PANORAMA)\r\n float lod = linRoughnessToMipmap(roughnessLinear) * uTextureEnvironmentSpecularPBRLodRange[1];\r\n\r\n vec2 uvBase = normalToPanoramaUV( R );\r\n vec3 texel = texturePanoramaLod( sSpecularPBR,\r\n uTextureEnvironmentSpecularPBRTextureSize,\r\n R,\r\n lod,\r\n uTextureEnvironmentSpecularPBRLodRange[0] );\r\n return texel;\r\n#else \r\n return vec3(1.0);\r\n#endif\r\n\r\n\r\n// #endif\r\n}\r\n\r\nvec3 integrateBRDF(const in vec3 specular, float r, float NoV ,const in float f90)\r\n{\r\n vec4 rgba = texture2D( sIntegrateBRDF, vec2(NoV, r ) );\r\n\r\n const float div = 1.0/65535.0;\r\n float b = (rgba[3] * 65280.0 + rgba[2] * 255.0);\r\n float a = (rgba[1] * 65280.0 + rgba[0] * 255.0);\r\n\r\n return (specular * a + b * f90) * div;\r\n}\r\n\r\n// https://www.unrealengine.com/blog/physically-based-shading-on-mobile\r\nvec3 integrateBRDFApprox( const in vec3 specular, float roughness, float NoV )\r\n{\r\n const vec4 c0 = vec4( -1, -0.0275, -0.572, 0.022 );\r\n const vec4 c1 = vec4( 1, 0.0425, 1.04, -0.04 );\r\n vec4 r = roughness * c0 + c1;\r\n float a004 = min( r.x * r.x, exp2( -9.28 * NoV ) ) * r.x + r.y;\r\n vec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\r\n return specular * AB.x + AB.y;\r\n}\r\n\r\nvec3 approximateSpecularIBL( const in vec3 specularColor,\r\n float rLinear,\r\n const in vec3 N,\r\n const in vec3 V,\r\n const in float f90)\r\n{\r\n float roughnessLinear = max( rLinear, 0.0);\r\n float NoV = dot( N, V );\r\n vec3 R = normalize( (2.0 * NoV ) * N - V);\r\n\r\n\r\n // From Sebastien Lagarde Moving Frostbite to PBR page 69\r\n // so roughness = linRoughness * linRoughness\r\n vec3 dominantR = getSpecularDominantDir( N, R, roughnessLinear*roughnessLinear );\r\n\r\n vec3 dir = uEnvironmentTransform * dominantR;\r\n vec3 prefilteredColor = prefilterEnvMap( roughnessLinear, dir );\r\n\r\n\r\n // marmoset tricks specular occlusion\r\n // prefilteredColor *= occlusionHorizon( dominantR, vViewNormal, ao );\r\n\r\n#ifdef MOBILE\r\n return uEnvironmentExposure * prefilteredColor * integrateBRDFApprox( specularColor, roughnessLinear, NoV );\r\n#else\r\n vec3 envBRDF = integrateBRDF(specularColor, roughnessLinear, NoV, f90 );\r\n return uEnvironmentExposure * prefilteredColor * envBRDF;\r\n#endif\r\n}\r\n\r\n\r\nvec3 computeIBL_UE4( const in vec3 normal,\r\n const in vec3 view,\r\n const in vec3 albedo,\r\n const in float roughness,\r\n const in vec3 specular,\r\n const in float ao,\r\n const in float f90)\r\n{\r\n\r\n vec3 color = vec3(0.0);\r\n if ( albedo != color ) { // skip if no diffuse\r\n color += uEnvironmentExposure * albedo * ao * evaluateDiffuseSphericalHarmonics(normal,\r\n view );\r\n }\r\n\r\n color += approximateSpecularIBL(specular, roughness, normal, view, f90);\r\n\r\n return color;\r\n}',Tl='#define PI 3.1415926535897932384626433832795\r\n#define PI_2 (2.0*3.1415926535897932384626433832795)\r\n#define INV_PI 1.0/PI\r\n#define INV_LOG2 1.4426950408889634073599246810019\r\n\r\n\r\nuniform mat3 uEnvironmentTransform;\r\nuniform float uRGBMRange;\r\n#ifdef ENV_CUBEMAP\r\nuniform samplerCube sSpecularPBR;\r\n#elif defined(ENV_PANORAMA)\r\nuniform sampler2D sSpecularPBR;\r\n#endif\r\n\r\n#if defined(ENV_CUBEMAP) || defined(FETCH_LOD)\r\n#extension GL_EXT_shader_texture_lod : enable\r\n#endif\r\n\r\n\r\nuniform int uDrawOpaque;\r\nuniform vec2 uTextureEnvironmentSpecularPBRTextureSize;\r\nuniform vec2 uTextureEnvironmentSpecularPBRLodRange;\r\nuniform float uEnvironmentExposure;\r\n\r\nuniform sampler2D sIntegrateBRDF; // ue4\r\n\r\nuniform vec3 uDiffuseSPH[9];\r\n\r\nvarying vec3 vViewVertex;\r\nvarying vec3 vViewNormal;\r\nvarying vec3 vWorldNormal;\r\nvarying vec2 vTexCoord0;\r\nvarying vec4 vViewTangent;\r\nvarying vec4 vVertexColor;\r\n#ifdef HAS_SHADOW\r\n varying vec3 vModelNormal;\r\n varying vec3 vModelVertex;\r\n#endif\r\nvarying vec3 vAutoUVCoord;\r\n\r\nuniform float uOpacityFactor;\r\n#define uNormalMapFactor 1.0\r\n// uniform float uNormalMapFactor;\r\nuniform int uNormalMapFlipY;\r\nuniform sampler2D albedoMap;\r\n\r\n\r\nuniform sampler2D metallicMap;\r\nuniform sampler2D roughnessMap;\r\nuniform sampler2D normalMap;\r\nuniform sampler2D opacityMap;\r\nuniform sampler2D aoMap;\r\n\r\n// uniform sampler2D emissiveMap;\r\n// uniform float uGlossinessFactor;\r\n// uniform int uSpecularPeak;\r\n// uniform int uOcclusionHorizon;\r\n\r\n#pragma include "sphericalHarmonics.glsl"\r\n#pragma include "utils/functions.glsl"\r\n\r\n#ifdef CHANGE_COLOR\r\n#pragma include "changeColor.glsl"\r\n#endif\r\n\r\n#if defined(HAS_LIGHT)\r\n#pragma include "utils/lightsPBR.glsl"\r\n#endif\r\n\r\n#ifdef HAS_SHADOW\r\n#define OPT_DISTANCE\r\n#pragma include "shadowing/shadowReceive.glsl"\r\n#endif\r\n\r\n#ifdef HAS_STICKER\r\n#pragma include "sticker.glsl"\r\n#endif\r\n\r\n// From Sebastien Lagarde Moving Frostbite to PBR page 69\r\n// We have a better approximation of the off specular peak\r\n// but due to the other approximations we found this one performs better.\r\n// N is the normal direction\r\n// R is the mirror vector\r\n// This approximation works fine for G smith correlated and uncorrelated\r\nvec3 getSpecularDominantDir(const in vec3 N, const in vec3 R, const in float realRoughness)\r\n{\r\n vec3 dominant;\r\n // if ( uSpecularPeak == 1 ) {\r\n float smoothness = 1.0 - realRoughness;\r\n float lerpFactor = smoothness * (sqrt(smoothness) + realRoughness);\r\n // The result is not normalized as we fetch in a cubemap\r\n dominant = mix(N, R, lerpFactor);\r\n // } else {\r\n // dominant = R;\r\n // }\r\n return dominant;\r\n}\r\n\r\n\r\nvec2 uv;\r\n#ifdef UV_TRANSFORM\r\nuniform vec4 uUVTransform;\r\n#endif\r\n\r\nvec2 transformUV(vec2 uv) {\r\n\r\n #ifdef UV_TRANSFORM \r\n vec3 transformeduv = mat3(\r\n uUVTransform.x * cos(uUVTransform.y), uUVTransform.x * sin(uUVTransform.y), 0.,\r\n -uUVTransform.x * sin(uUVTransform.y), uUVTransform.x * cos(uUVTransform.y), 0.,\r\n uUVTransform.z, uUVTransform.w, 1.) * vec3(uv, 1.0);\r\n\r\n return transformeduv.xy;\r\n #else\r\n return uv;\r\n #endif\r\n\r\n}\r\n\r\n\r\n#ifdef TRIPLANAR_PROJECTION\r\n#pragma include "triplanar_projection.glsl"\r\n#endif\r\n\r\n\r\n// #define TRIPLANAR_PROJECTION\r\nvec4 fetchTexture(sampler2D texture, vec2 uv) {\r\n\r\n vec4 color;\r\n\r\n #ifdef TRIPLANAR_PROJECTION\r\n vec3 coord = vAutoUVCoord * 0.01;\r\n vec2 yz = transformUV(coord.yz);\r\n vec2 xz = transformUV(coord.xz);\r\n vec2 yx = transformUV(coord.yx);\r\n if (vWorldNormal.x < 0.) yz.x = 1.0 - yz.x;\r\n if (vWorldNormal.y > 0.) xz.x = 1.0 - xz.x;\r\n if (vWorldNormal.z > 0.) yx.x = 1.0 - yx.x;\r\n color = triplanlar_projection(yz, xz, yx, texture);\r\n #else\r\n color = texture2D(texture, uv);\r\n #endif\r\n return color;\r\n}\r\n\r\n#ifdef FETCH_LOD\r\n#ifdef TRIPLANAR_PROJECTION\r\nvec4 triplanlar_projection_lod(vec2 x, vec2 y, vec2 z, sampler2D texture, float lod)\r\n{\r\n vec3 triweight = gTriWeight;\r\n\r\n vec4 color = vec4(0);\r\n\r\n if (triweight.x > 0.0) {\r\n color += triweight.x * texture2DLodEXT(texture, x, lod); // yz\r\n }\r\n if (triweight.y > 0.0) {\r\n color += triweight.y * texture2DLodEXT(texture, y, lod); // xy\r\n }\r\n if (triweight.z > 0.0) {\r\n color += triweight.z * texture2DLodEXT(texture, z, lod); // yx\r\n }\r\n return color;\r\n}\r\n#endif\r\nvec4 fetchTextureLod(sampler2D texture, vec2 uv, float lod) {\r\n\r\n vec4 color;\r\n\r\n #ifdef TRIPLANAR_PROJECTION\r\n vec3 coord = vAutoUVCoord * 0.01;\r\n vec2 yz = transformUV(coord.yz);\r\n vec2 xz = transformUV(coord.xz);\r\n vec2 yx = transformUV(coord.yx);\r\n if (vWorldNormal.x < 0.) yz.x = 1.0 - yz.x;\r\n if (vWorldNormal.y > 0.) xz.x = 1.0 - xz.x;\r\n if (vWorldNormal.z > 0.) yx.x = 1.0 - yx.x;\r\n color = triplanlar_projection_lod(yz, xz, yx, texture, lod);\r\n #else\r\n color = texture2DLodEXT(texture, uv, lod);\r\n #endif\r\n return color;\r\n}\r\n#endif\r\n\r\n\r\nfloat occlusionHorizon( const in vec3 R, const in vec3 normal, const in float ao)\r\n{\r\n // if ( uOcclusionHorizon == 0)\r\n return 1.0;\r\n\r\n // http://marmosetco.tumblr.com/post/81245981087\r\n // marmoset uses 1.3, we force it to 1.0\r\n // float factor = clamp( 1.0 + dot(R, normal), 0.0, 1.0 );\r\n // return factor * factor;\r\n float d = dot(normal, R) + ao;\r\n return clamp((d * d) - 1.0 + ao, 0.0, 1.0);\r\n}\r\n\r\n\r\nvec3 evaluateDiffuseSphericalHarmonics( const in vec3 N,\r\n const in vec3 V ) {\r\n return sphericalHarmonics( uDiffuseSPH, uEnvironmentTransform * N );\r\n}\r\n\r\n\r\n#ifdef ENV_CUBEMAP\r\n#pragma include "cubemapSampler.glsl"\r\n#else\r\n#pragma include "panoramaSampler.glsl"\r\n#endif\r\n// \r\n\r\n\r\n\r\n#pragma include "pbr_ue4.glsl"\r\n\r\n\r\nvec3 computeNormalFromTangentSpaceNormalMap(const in vec4 tangent, const in vec3 normal, in vec3 texnormal)\r\n{\r\n vec3 tang = vec3(0.0,1.0,0.0);\r\n if (length(tangent.xyz) != 0.0) {\r\n tang = normalize(tangent.xyz);\r\n }\r\n vec3 B = tangent.w * cross(normal, tang);\r\n texnormal.xy = uNormalMapFactor * texnormal.xy;\r\n vec3 outnormal = texnormal.x*tang + texnormal.y*B + texnormal.z*normal;\r\n return normalize(outnormal);\r\n}\r\n\r\nvec3 textureNormal(const in vec3 rgb) {\r\n vec3 n = normalize((rgb-vec3(0.5)));\r\n n.y = uNormalMapFlipY == 1 ? -n.y : n.y;\r\n return n;\r\n}\r\n\r\nfloat adjustRoughness( const in float roughness, const in vec3 normal ) {\r\n // Based on The Order : 1886 SIGGRAPH course notes implementation (page 21 notes)\r\n float normalLen = length(normal*2.0-1.0);\r\n if ( normalLen < 1.0) {\r\n float normalLen2 = normalLen * normalLen;\r\n float kappa = ( 3.0 * normalLen - normalLen2 * normalLen )/( 1.0 - normalLen2 );\r\n // http://www.frostbite.com/2014/11/moving-frostbite-to-pbr/\r\n // page 91 : they use 0.5/kappa instead\r\n return min(1.0, sqrt( roughness * roughness + 1.0/kappa ));\r\n }\r\n return roughness;\r\n}\r\n\r\nfloat getMaterialOpacity() {\r\n float alpha = 1.0;\r\n#ifdef HAS_OPACITYMAP\r\n alpha = (fetchTexture(opacityMap, uv).r);\r\n#endif\r\n alpha *= uOpacityFactor;\r\n#ifdef INVERT_ALPHA\r\n alpha = 1.0 - alpha;\r\n#endif\r\n return alpha;\r\n}\r\n\r\n\r\nfloat GTR1(float NdotH, float a)\r\n{\r\n if (a >= 1.) return 1./PI;\r\n float a2 = a*a;\r\n float t = 1. + (a2-1.)*NdotH*NdotH;\r\n return (a2-1.) / (PI*log(a2)*t);\r\n}\r\n\r\nfloat smithG_GGX(float NdotV, float alphaG)\r\n{\r\n float a = alphaG*alphaG;\r\n float b = NdotV*NdotV;\r\n return 1. / (NdotV + sqrt(a + b - a*b));\r\n}\r\n\r\n#ifdef HAS_CLEARCOAT\r\n\r\nuniform vec2 uClearcoatParam;\r\n\r\nvec3 clearcoatBRDF(float clearcoatRoughness, vec3 eyeVector, vec3 eyeLightDir, vec3 normal) { \r\n vec3 H = normalize(eyeVector + eyeLightDir);\r\n float NdotH = clamp(dot(normal, H), 0., 1.);\r\n float NdotV = clamp(dot(normal, eyeVector), 0., 1.);\r\n float NdotL = clamp(dot(normal, eyeLightDir), 0., 1.);\r\n float LdotH = clamp(dot(eyeLightDir, H), 0., 1.);\r\n // clearcoat (ior = 1.5 -> F0 = 0.04)\r\n float Dr = GTR1(NdotH, mix(.001, 0.1, clearcoatRoughness));\r\n vec3 Fr = F_Schlick(vec3(.04), 1.0, LdotH);\r\n float Gr = smithG_GGX(NdotL, .25) * smithG_GGX(NdotV, .25);\r\n return vec3(.25 * uClearcoatParam.x * Gr * Dr) * Fr;\r\n}\r\n#endif\r\n\r\n#ifdef HAS_SHEEN\r\nfloat sheenLobe(const float sheenRoughness, const float NdotV, const float NdotL, const float NdotH) {\r\n float r = sheenRoughness * sheenRoughness;\r\n float invAlpha = 1.0 / r;\r\n float cos2h = NdotH * NdotH;\r\n float sin2h = max(1.0 - cos2h, 0.0078125);\r\n float D = (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * 3.141593);\r\n float V = clamp(1.0 / (4.0 * (NdotL + NdotV - NdotL * NdotV)), 0.0, 1.0);\r\n return (D * V);\r\n}\r\nvec3 sheenColor = vec3(0.);\r\n#define uSheenColorFactor vec3(1.0, 1.0, 1.0)\r\n#define uSheenFactor 1.0\r\n#define uSheenRoughnessFactor 1.0\r\nfloat getMaterialSheenRoughness() {\r\n return uSheenRoughnessFactor;\r\n}\r\nvec3 computeSheen(const vec3 normal, const vec3 lightDir, const vec3 eyeVector, const float sheenRoughness) {\r\n float NdotL = dot(normal, lightDir);\r\n float NdotV = dot(normal, eyeVector);\r\n vec3 H = normalize(lightDir + eyeVector);\r\n float NdotH = dot(normal, H);\r\n float sheenContribution = sheenLobe(max(0.04, sheenRoughness), NdotV, NdotL, NdotH);\r\n vec3 sheenColor = uSheenFactor * uSheenColorFactor;\r\n return max(vec3(0.0), sheenContribution * sheenColor);\r\n}\r\n#endif\r\n\r\nvoid main(void) {\r\n\r\n vec3 normal = normalize(gl_FrontFacing ? vViewNormal : -vViewNormal);\r\n vec3 eye = -normalize(vViewVertex);\r\n vec4 tangent = vViewTangent;\r\n uv = vTexCoord0.xy; \r\n uv = transformUV(uv); \r\n \r\n #ifdef TRIPLANAR_PROJECTION\r\n gTriWeight = calculateTriplanlartriweight(vWorldNormal);\r\n #endif\r\n\r\n float alpha = 1.0;\r\n alpha = getMaterialOpacity();\r\n if (alpha == 0.0 || (uDrawOpaque == 1 && alpha < 9.9999e-1) || (uDrawOpaque == 0 && alpha >= 9.9999e-1)) discard; \r\n const vec3 dielectricColor = vec3(0.04);\r\n float minRoughness = 1.e-4;\r\n vec4 albedoSource = fetchTexture( albedoMap, uv );\r\n\r\n#ifdef CHANGE_COLOR\r\n #ifdef CHANGE_COLOR_SOURCE\r\n albedoSource.rgb = changeColor(albedoSource.rgb, uSourceColor);\r\n #else\r\n albedoSource.rgb = changeColor(albedoSource.rgb, fetchTextureLod(albedoMap, uv, uSourceLod).rgb);\r\n #endif\r\n#endif\r\n vec3 albedo = sRGBToLinear( albedoSource.rgb );\r\n\r\n\r\n#ifdef HAS_VERTEX_COLOR\r\n vec3 vertexColorLinear = sRGBToLinear( vVertexColor.rgb );\r\n // Check non zero non completely transparent\r\n if(vertexColorLinear.rgb != vec3(0.0) && vVertexColor.a != 0.0){\r\n albedo *= vertexColorLinear;\r\n albedoSource.a *= vVertexColor.a;\r\n }\r\n#endif\r\n\r\n#ifdef HAS_NORMALMAP\r\n vec3 normalTexel;\r\n #ifdef TRIPLANAR_PROJECTION \r\n normalTexel = fetchTexture(normalMap, uv).rgb;\r\n if ( length(normalTexel) > 0.0001 ) {\r\n vec3 realNormal = textureNormal( normalTexel );\r\n normal = computeNormalFromTangentSpaceNormalMap( tangent, normal, realNormal );\r\n }\r\n \r\n #else \r\n normalTexel = texture2D( normalMap, uv ).rgb;\r\n if ( length(normalTexel) > 0.0001 ) {\r\n vec3 realNormal = textureNormal( normalTexel );\r\n normal = computeNormalFromTangentSpaceNormalMap( tangent, normal, realNormal );\r\n }\r\n #endif\r\n\r\n#endif\r\n\r\n#ifdef SPECULAR_GLOSSINESS\r\n float roughness = fetchTexture( roughnessMap, uv ).g;\r\n roughness = 1.0 - roughness;\r\n#else\r\n float roughness = fetchTexture( roughnessMap, uv ).g;\r\n#endif\r\n roughness = max( minRoughness , roughness );\r\n float ao = 1.0;\r\n\r\n#ifdef HAS_NORMALMAP\r\n roughness = adjustRoughness( roughness, normalTexel);\r\n#endif\r\n\r\n#ifdef HAS_AOMAP\r\n ao = fetchTexture( aoMap, uv ).r;\r\n#endif\r\n vec3 specular;\r\n\r\n #ifdef SPECULAR_GLOSSINESS\r\n specular = sRGBToLinear( fetchTexture( metallicMap, uv ) ).rgb;\r\n #else \r\n float metallic = fetchTexture( metallicMap, uv ).g;\r\n vec3 albedoReduced = albedo * (1.0 - metallic);\r\n specular = mix( dielectricColor, albedo, metallic);\r\n albedo = albedoReduced;\r\n #endif\r\n\r\n #ifdef UNLIT\r\n vec3 resultIBL = albedo;\r\n #else\r\n float materialF90 = clamp(50.0 * specular.g, 0.0, 1.0);\r\n vec3 resultIBL = computeIBL_UE4( normal, eye, albedo, roughness, specular, ao, materialF90 );\r\n\r\n #ifdef HAS_CLEARCOAT\r\n // float clearcoatRoughness\r\n // clearcoat \r\n float uClearcoatIntensity = uClearcoatParam.x;\r\n float uClearcoatRoughness = uClearcoatParam.y;\r\n float clearCoatPerceptualRoughness = clamp(uClearcoatRoughness, 0.089, 1.0);\r\n float clearcoatRoughness = clearCoatPerceptualRoughness * clearCoatPerceptualRoughness;\r\n resultIBL += approximateSpecularIBL(vec3(0.04), clearcoatRoughness, normal, eye, 1.0) * uClearcoatIntensity; \r\n #endif\r\n\r\n #ifdef HAS_SHEEN\r\n float sheenRoughness = getMaterialSheenRoughness();\r\n resultIBL += computeSheen(normal, getSpecularDominantDir(normal, reflect(-eye, normal), sheenRoughness), eye, sheenRoughness); \r\n #endif\r\n\r\n #ifdef HAS_LIGHT\r\n float attenuation, dotNL;\r\n vec3 eyeLightDir;\r\n bool lighted;\r\n vec3 lightSpecular;\r\n vec3 lightDiffuse;\r\n vec4 prepGGX = precomputeGGX(normal, eye, max(0.045, roughness));\r\n #endif\r\n\r\n #ifdef HAS_SHADOW\r\n float shadow;\r\n vec3 modelNormal = normalize(gl_FrontFacing ? vModelNormal : -vModelNormal);\r\n #endif\r\n\r\n %UNROLL 4%\r\n #ifdef LIGHT_TYPE_%ID%\r\n\r\n #if LIGHT_TYPE_%ID% == LIGHT_DIRECTION\r\n precomputeSun(normal, uEditorLight%ID%_viewDirection, attenuation, eyeLightDir, dotNL);\r\n #endif\r\n\r\n computeLightLambertGGX(normal, eye, dotNL, prepGGX, albedo, specular, attenuation, uEditorLight%ID%_diffuse.rgb, eyeLightDir, materialF90, lightDiffuse, lightSpecular, lighted);\r\n #ifdef HAS_CLEARCOAT\r\n lightSpecular += clearcoatBRDF(clearcoatRoughness, eye, eyeLightDir, normal);\r\n #endif\r\n\r\n #ifdef HAS_SHADOW_%ID%\r\n #ifdef _ATLAS_SHADOW\r\n shadow = shadowReceive(lighted, modelNormal, vModelVertex, Texture12, uShadow_Texture0_renderSize, uShadow_Texture%ID%_projection, uShadow_Texture%ID%_viewRight, uShadow_Texture%ID%_viewUp, uShadow_Texture%ID%_viewLook, uShadow_Texture%ID%_depthRange, uShadowReceive%ID%_bias, uShadow_Texture%ID%_mapSize, OPT_DISTANCE uStaticFrameNumShadow%ID%);\r\n #else\r\n shadow = shadowReceive(lighted, modelNormal, vModelVertex, TEX_SHADOW_%ID%, uShadow_Texture%ID%_renderSize, uShadow_Texture%ID%_projection, uShadow_Texture%ID%_viewRight, uShadow_Texture%ID%_viewUp, uShadow_Texture%ID%_viewLook, uShadow_Texture%ID%_depthRange, uShadowReceive%ID%_bias, OPT_DISTANCE uStaticFrameNumShadow%ID%);\r\n #endif \r\n\r\n lightDiffuse *= shadow;\r\n lightSpecular *= shadow;\r\n\r\n #endif\r\n\r\n resultIBL += lightDiffuse;\r\n resultIBL += lightSpecular;\r\n #endif // LIGHT_TYPE\r\n %% \r\n #endif\r\n\r\n\r\n\r\n// #ifdef EMISSIVE\r\n// vec3 emissiveChannel = sRGBToLinear( texture2D( emissiveMap, uv ) ).rgb;\r\n// resultIBL = resultIBL + emissiveChannel;\r\n// #endif\r\n //vec4 result = vec4( resultIBL, albedoSource.a );\r\n // vec3 frag = linearTosRGB(resultIBL );\r\n \r\n #if HAS_STICKER\r\n resultIBL = getStickColor(vec4(resultIBL, alpha)).rgb;\r\n #endif \r\n resultIBL *= alpha;\r\n gl_FragColor = uDrawOpaque == 1 ? encodeRGBM(resultIBL, uRGBMRange) : vec4(resultIBL, alpha);\r\n}\r\n',yl='#ifdef GL_ES\r\nprecision highp float;\r\n#endif\r\nattribute vec3 Vertex;\r\nattribute vec3 Normal;\r\nattribute vec2 TexCoord0;\r\nattribute vec4 Tangent;\r\nattribute vec4 Color;\r\nuniform float uDisplay2D;\r\nuniform mat4 uModelViewMatrix;\r\nuniform mat4 uProjectionMatrix;\r\nuniform mat4 uModelMatrix;\r\nuniform mat3 uModelViewNormalMatrix;\r\nuniform mat3 uModelNormalMatrix;\r\nuniform mat4 uViewMatrix;\r\nuniform vec2 uGlobalTexRatio;\r\nuniform vec2 uGlobalTexSize;\r\nuniform vec4 uHalton;\r\nvarying vec3 vViewVertex;\r\nvarying vec3 vViewNormal;\r\nvarying vec3 vWorldNormal;\r\nvarying vec4 vViewTangent;\r\nvarying vec2 vTexCoord0;\r\nvarying vec4 vVertexColor;\r\nvarying vec3 vNormalObject;\r\nvarying vec3 vAutoUVCoord;\r\n\r\n#if defined(HAS_MODEL_VERTEX) || defined(HAS_DISPLACEMENT)\r\n varying vec3 vModelVertex;\r\n#endif\r\n\r\n#if defined(HAS_DISPLACEMENT)\r\n uniform float uDisplacementAmount;\r\n uniform sampler2D displacementMap;\r\n#endif\r\n\r\nvec2 uv;\r\n\r\n#ifdef UV_TRANSFORM\r\nuniform vec4 uUVTransform;\r\n#endif\r\n\r\nvec2 transformUV(vec2 uv) { \r\n\r\n #ifdef UV_TRANSFORM \r\n vec3 transformeduv = mat3(\r\n uUVTransform.x * cos(uUVTransform.y), uUVTransform.x * sin(uUVTransform.y), 0.,\r\n -uUVTransform.x * sin(uUVTransform.y), uUVTransform.x * cos(uUVTransform.y), 0.,\r\n uUVTransform.z, uUVTransform.w, 1.) * vec3(uv, 1.0);\r\n\r\n return transformeduv.xy;\r\n #else\r\n return uv;\r\n #endif\r\n\r\n}\r\n\r\n#ifdef TRIPLANAR_PROJECTION\r\n#pragma include "triplanar_projection.glsl"\r\n#endif\r\n\r\n\r\n// #define TRIPLANAR_PROJECTION\r\nvec4 fetchTexture(sampler2D texture, vec2 uv) {\r\n\r\n vec4 color;\r\n\r\n #ifdef TRIPLANAR_PROJECTION\r\n vec3 coord = vAutoUVCoord * 0.01;\r\n vec2 yz = transformUV(coord.yz);\r\n vec2 xz = transformUV(coord.xz);\r\n vec2 yx = transformUV(coord.yx);\r\n if (vWorldNormal.x < 0.) yz.x = 1.0 - yz.x;\r\n if (vWorldNormal.y > 0.) xz.x = 1.0 - xz.x;\r\n if (vWorldNormal.z > 0.) yx.x = 1.0 - yx.x;\r\n color = triplanlar_projection(yz, xz, yx, texture);\r\n #else\r\n color = texture2D(texture, uv);\r\n #endif\r\n return color;\r\n}\r\n\r\n\r\n#if defined(HAS_MODEL_NORMAL)\r\n varying vec3 vModelNormal;\r\n#endif\r\n\r\n\r\nuniform mat4 uInverseScopeModelMatrix;\r\n\r\n\r\n\r\nvoid main(void) {\r\n\r\n vec3 localVertex = Vertex.xyz;\r\n\r\n #if defined(HAS_MODEL_VERTEX) || defined(HAS_DISPLACEMENT)\r\n vModelVertex = (uModelMatrix * vec4(localVertex, 1.0)).xyz;\r\n #endif\r\n\r\n vec3 localNormal = Normal;\r\n #if defined(HAS_MODEL_NORMAL)\r\n vModelNormal = uModelNormalMatrix * localNormal;\r\n #endif \r\n\r\n vViewNormal = uModelViewNormalMatrix * localNormal;\r\n vViewTangent = vec4(uModelViewNormalMatrix * Tangent.xyz, Tangent.w);\r\n\r\n vTexCoord0 = TexCoord0;\r\n uv = vTexCoord0.xy; \r\n uv = transformUV(uv);\r\n \r\n vVertexColor = Color;\r\n \r\n //vWorldNormal = (uModelMatrix * vec4(Normal, 0.)).rgb;\r\n vWorldNormal = mat3(uInverseScopeModelMatrix) * uModelNormalMatrix * Normal; \r\n vAutoUVCoord = vec3(uInverseScopeModelMatrix * uModelMatrix * vec4(localVertex, 1.0));\r\n #ifdef TRIPLANAR_PROJECTION\r\n gTriWeight = calculateTriplanlartriweight(vWorldNormal);\r\n #endif\r\n mat4 jitteredProjection = uProjectionMatrix;\r\n #if defined(SHADOW_CAST)\r\n float doPersp = jitteredProjection[3][3] == 0.0 ? 1.0 : 0.0;\r\n vec2 jitter = (abs(uHalton.z) == 2.0 ? 1.0 : 0.0) * (uHalton.xy / uShadowMapSize.xy);\r\n jitteredProjection[2].xy += doPersp * jitter;\r\n jitteredProjection[3].xy += (1.0 - doPersp) * jitter;\r\n #elif !defined(NO_JITTER)\r\n jitteredProjection[2].xy += (1.0 - uDisplay2D) * (uHalton.xy * uGlobalTexRatio.xy / uGlobalTexSize.xy);\r\n #endif\r\n\r\n\r\n #if defined(HAS_DISPLACEMENT)\r\n float displacement = (fetchTexture(displacementMap, uv).g - 0.5) * uDisplacementAmount * (1.0 - uDisplay2D);\r\n // float displacement = (COLOR_CONVERT_DISPLACEMENT(texture2D(SAMPLER_DISPLACEMENT, UV_DISPLACEMENT).PACK_DISPLACEMENT) - 0.5) * uDisplacementAmount * (1.0 - uDisplay2D);\r\n vModelVertex += normalize(vModelNormal) * displacement;\r\n vViewVertex = vec3(uViewMatrix * vec4(vModelVertex, 1.0));\r\n #else\r\n vViewVertex = vec3(uModelViewMatrix * vec4(localVertex, 1.0));\r\n #endif\r\n\r\n gl_Position = jitteredProjection * vec4(vViewVertex, 1.0);\r\n}\r\n',Cl="#ifdef DEBUG\r\n#define PI 3.1415926535897932384626433832795\r\n\r\nvec3 shCoefs[9];\r\n\r\nvoid createCoef() {\r\n\r\n // vec3( 1.0/(2.0*sqrt(PI) ) ),\r\n\r\n // vec3( -( sqrt(3.0/PI)*0.5 * y ) ),\r\n // vec3( ( sqrt(3.0/PI)*0.5 * z ) ),\r\n // vec3( -( sqrt(3.0/PI)*0.5 * x ) ),\r\n\r\n // vec3( ( sqrt(15.0/PI)*0.5 * x * y ) ),\r\n // vec3( -( sqrt(15.0/PI)*0.5 * y * z ) ),\r\n // vec3( ( sqrt(5.0/PI)* 0.25 * ( 3.0*z*z - 1.0) ) ),\r\n // vec3( -( sqrt(15.0/PI)* 0.5 * x *z ) ),\r\n // vec3( ( sqrt(15.0/PI) * 0.25 * (x*x - y*y )) ),\r\n\r\n shCoefs[0] = vec3( 1.0/(2.0*sqrt(PI) ) );\r\n\r\n shCoefs[1] = vec3( -( sqrt(3.0/PI)*0.5 ) );\r\n shCoefs[2] = -shCoefs[1];\r\n shCoefs[3] = shCoefs[1];\r\n\r\n shCoefs[4] = vec3( sqrt(15.0/PI)*0.5 );\r\n shCoefs[5] = -shCoefs[4];\r\n shCoefs[6] = vec3( sqrt(5.0/PI)* 0.25 );\r\n shCoefs[7] = shCoefs[5];\r\n shCoefs[8] = vec3( sqrt(15.0/PI) * 0.25 );\r\n\r\n}\r\n\r\nvec3 sphericalHarmonics( const in vec3 normal )\r\n{\r\n float x = normal.x;\r\n float y = normal.y;\r\n float z = normal.z;\r\n\r\n createCoef();\r\n vec3 result = (\r\n shCoefs[0] * uSph[0] +\r\n\r\n shCoefs[1] * uSph[1] * y +\r\n shCoefs[2] * uSph[2] * z +\r\n shCoefs[3] * uSph[3] * x +\r\n\r\n shCoefs[4] * uSph[4] * y * x +\r\n shCoefs[5] * uSph[5] * y * z +\r\n shCoefs[6] * uSph[6] * (3.0 * z * z - 1.0) +\r\n shCoefs[7] * uSph[7] * (z * x) +\r\n shCoefs[8] * uSph[8] * (x*x - y*y)\r\n );\r\n}\r\n\r\n#else\r\n// expect shCoefs uniform\r\n// https://github.com/cedricpinson/envtools/blob/master/Cubemap.cpp#L523\r\nvec3 sphericalHarmonics( const vec3 sph[9], const in vec3 normal )\r\n{\r\n float x = normal.x;\r\n float y = normal.y;\r\n float z = normal.z;\r\n\r\n vec3 result = (\r\n sph[0] +\r\n\r\n sph[1] * y +\r\n sph[2] * z +\r\n sph[3] * x +\r\n\r\n sph[4] * y * x +\r\n sph[5] * y * z +\r\n sph[6] * (3.0 * z * z - 1.0) +\r\n sph[7] * (z * x) +\r\n sph[8] * (x*x - y*y)\r\n );\r\n\r\n return max(result, vec3(0.0));\r\n}\r\n\r\n#endif\r\n",Al='\r\nvarying vec3 vViewNormal;\r\nvarying vec3 vLocalVertex;\r\n\r\nuniform vec3 uDiffuseSPH[9];\r\nuniform mat3 uEnvironmentTransform;\r\n\r\n\r\n#pragma include "utils/functions.glsl"\r\n#pragma include "sphericalHarmonics.glsl"\r\n\r\n\r\nvoid main() {\r\n\r\n vec3 n = normalize( vViewNormal );\r\n n = uEnvironmentTransform * n;\r\n vec3 color = sphericalHarmonics( uDiffuseSPH, n );\r\n gl_FragColor = vec4( linearTosRGB(color), 1.0);\r\n\r\n}\r\n',El="attribute vec3 Vertex;\r\nattribute vec3 Normal;\r\nattribute vec2 TexCoord0;\r\nattribute vec4 Tangent;\r\n\r\nuniform mat4 uModelViewMatrix;\r\nuniform mat4 uProjectionMatrix;\r\nuniform mat3 uModelViewNormalMatrix;\r\n\r\n\r\nvarying vec3 vViewVertex;\r\nvarying vec3 vViewNormal;\r\nvarying vec4 vViewTangent;\r\nvarying vec2 vTexCoord0;\r\nvarying vec3 vLocalVertex;\r\n\r\n\r\nvoid main(void) {\r\n\r\n vViewVertex = vec3(uModelViewMatrix * vec4(Vertex, 1.0));\r\n vViewNormal = uModelViewNormalMatrix * Normal;\r\n vLocalVertex = Vertex;\r\n\r\n vViewTangent = vec4(uModelViewNormalMatrix * Tangent.xyz, Tangent.w);\r\n vTexCoord0 = TexCoord0;\r\n\r\n gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(Vertex,1.0);\r\n}\r\n",Rl="\r\nvec3 gTriWeight;\r\n\r\nuniform float uTriplanarBlendWeight;\r\n\r\nvec3 calculateTriplanlartriweight(vec3 triNormal) { \r\n\r\n float blendIntensity = uTriplanarBlendWeight;\r\n vec3 triweight = vec3(0.0, 0.0, 0.0);\r\n\r\n triNormal = vec3(abs(triNormal.x), abs(triNormal.y), abs(triNormal.z));\r\n triNormal /= (triNormal.x + triNormal.y + triNormal.z);\r\n float blendLimit = 0.5 * (1.0 + blendIntensity);\r\n\r\n if (triNormal.x > blendLimit * (triNormal.x + triNormal.y) && triNormal.x > blendLimit * (triNormal.x + triNormal.z)) {\r\n triweight.x = 1.0;\r\n }\r\n else if (triNormal.y > blendLimit * (triNormal.x + triNormal.y) && triNormal.y > blendLimit * (triNormal.y + triNormal.z)) {\r\n triweight.y = 1.0;\r\n }\r\n else if (triNormal.z > blendLimit * (triNormal.x + triNormal.z) && triNormal.z > blendLimit * (triNormal.y + triNormal.z)) {\r\n triweight.z = 1.0;\r\n }\r\n else if (blendIntensity > 0.0) {\r\n if (triNormal.z < (1.0 - blendLimit) * (triNormal.y + triNormal.x)) {\r\n triweight.x = triNormal.x / (triNormal.x + triNormal.y);\r\n triweight.x = clamp((triweight.x - 0.5 * (1.0 - blendIntensity)) / blendIntensity, 0.0, 1.0);\r\n triweight.y = 1.0 - triweight.x;\r\n } else if (triNormal.x < (1.0 - blendLimit) * (triNormal.y + triNormal.z)) {\r\n triweight.y = triNormal.y / (triNormal.y + triNormal.z);\r\n triweight.y = clamp((triweight.y - 0.5 * (1.0 - blendIntensity)) / blendIntensity, 0.0, 1.0);\r\n triweight.z = 1.0 - triweight.y;\r\n }\r\n else if (triNormal.y < (1.0 - blendLimit) * (triNormal.x + triNormal.z)) {\r\n triweight.x = triNormal.x / (triNormal.x + triNormal.z);\r\n triweight.x = clamp((triweight.x - 0.5 * (1.0 - blendIntensity)) / blendIntensity, 0.0, 1.0);\r\n triweight.z = 1.0 - triweight.x;\r\n }\r\n else {\r\n triweight.x = ((2.0 - blendLimit) * triNormal.x + (blendLimit - 1.0)) / (2.0 * blendLimit - 1.0);\r\n triweight.y = ((2.0 - blendLimit) * triNormal.y + (blendLimit - 1.0)) / (2.0 * blendLimit - 1.0);\r\n triweight.z = ((2.0 - blendLimit) * triNormal.z + (blendLimit - 1.0)) / (2.0 * blendLimit - 1.0);\r\n }\r\n } else {\r\n triweight.x = 1.0;\r\n }\r\n return triweight;\r\n}\r\n\r\n\r\nvec4 triplanlar_projection(vec2 x, vec2 y, vec2 z, sampler2D texture)\r\n{\r\n vec3 triweight = gTriWeight;\r\n\r\n vec4 color = vec4(0);\r\n\r\n if (triweight.x > 0.0) {\r\n color += triweight.x * texture2D(texture, x); // yz\r\n }\r\n if (triweight.y > 0.0) {\r\n color += triweight.y * texture2D(texture, y); // xy\r\n }\r\n if (triweight.z > 0.0) {\r\n color += triweight.z * texture2D(texture, z); // yx\r\n }\r\n return color;\r\n}\r\n",Ml='\r\nuniform int uDrawOpaque;\r\nuniform float uOpacityFactor;\r\nuniform vec2 uNearFar;\r\nuniform vec4 uShadowDepthRange;\r\nvarying vec3 vViewVertex;\r\nvarying vec3 vViewNormal;\r\nvarying vec2 vTexCoord0;\r\nvarying vec4 vViewTangent;\r\nvarying vec4 vVertexColor;\r\nvarying vec3 vAutoUVCoord;\r\nvarying vec3 vWorldNormal;\r\n\r\n\r\nvec2 uv;\r\n\r\n#ifdef UV_TRANSFORM\r\nuniform vec4 uUVTransform;\r\n#endif\r\n\r\nvec2 transformUV(vec2 uv) { \r\n\r\n #ifdef UV_TRANSFORM \r\n vec3 transformeduv = mat3(\r\n uUVTransform.x * cos(uUVTransform.y), uUVTransform.x * sin(uUVTransform.y), 0.,\r\n -uUVTransform.x * sin(uUVTransform.y), uUVTransform.x * cos(uUVTransform.y), 0.,\r\n uUVTransform.z, uUVTransform.w, 1.) * vec3(uv, 1.0);\r\n\r\n return transformeduv.xy;\r\n #else\r\n return uv;\r\n #endif\r\n\r\n}\r\n\r\nuniform sampler2D opacityMap;\r\n\r\n#pragma include "utils/functions.glsl"\r\n\r\n\r\n#ifdef TRIPLANAR_PROJECTION\r\n#pragma include "triplanar_projection.glsl"\r\n#endif\r\n\r\nvec4 encodeFloatRGBA( float v ) {\r\n vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * v;\r\n enc = fract(enc);\r\n enc -= enc.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\r\n return enc;\r\n}\r\nvec4 fetchTexture(sampler2D texture, vec2 uv) {\r\n\r\n vec4 color;\r\n\r\n #ifdef TRIPLANAR_PROJECTION\r\n vec3 coord = vAutoUVCoord * 0.01;\r\n color = triplanlar_projection(transformUV(coord.zy), transformUV(coord.xz), transformUV(coord.xy), texture);\r\n #else\r\n color = texture2D(texture, uv);\r\n #endif\r\n\r\n return color;\r\n\r\n}\r\n\r\n\r\n\r\nfloat getMaterialOpacity() {\r\n float alpha = 1.0;\r\n#ifdef HAS_OPACITYMAP\r\n alpha = fetchTexture(opacityMap, uv).r;\r\n#endif\r\n alpha *= uOpacityFactor;\r\n#ifdef INVERT_ALPHA\r\n alpha = 1.0 - alpha;\r\n#endif\r\n return alpha;\r\n}\r\n\r\nvoid main(void) {\r\n\r\n uv = vTexCoord0;\r\n \r\n #ifdef UV_TRANSFORM\r\n uv = transformUV(uv);\r\n #endif\r\n\r\n \r\n #ifdef TRIPLANAR_PROJECTION\r\n gTriWeight = calculateTriplanlartriweight(vWorldNormal);\r\n #endif\r\n\r\n if (getMaterialOpacity() < 9.9999e-1) discard;\r\n gl_FragColor = encodeFloatRGBA((-vViewVertex.z - uShadowDepthRange.x) / (uShadowDepthRange.y - uShadowDepthRange.x));\r\n}\r\n',wl="#ifdef STICKER_NUM\r\n\r\n#extension GL_OES_standard_derivatives:enable\r\n\r\nuniform float uHighlight[STICKER_NUM];\r\nuniform mat3 uMat[STICKER_NUM];\r\nuniform mat4 uT[STICKER_NUM];\r\nuniform vec4 uBoundSphere[STICKER_NUM];\r\nuniform sampler2D uStickerMap[STICKER_NUM];\r\nuniform vec3 uPos[STICKER_NUM];\r\nuniform vec3 uNormal[STICKER_NUM];\r\nuniform float uVisible[STICKER_NUM];\r\n\r\nuniform float uAnchors[8];\r\n\r\n\r\nvec2 sphericalMapping(vec3 n) {\r\n float phi = acos(n.z);\r\n float theta = atan(n.y,n.x);\r\n return vec2(theta, PI - phi);\r\n}\r\n\r\nfloat sign(vec2 p1,vec2 p2,vec2 p3) {\r\n return (p1.x-p3.x)*(p2.y-p3.y)-(p2.x-p3.x)*(p1.y-p3.y);\r\n}\r\n\r\nint pointInTriangle(vec2 pt,vec2 v1,vec2 v2,vec2 v3) {\r\n float d1,d2,d3;\r\n d1=sign(pt,v1,v2);\r\n d2=sign(pt,v2,v3);\r\n d3=sign(pt,v3,v1);\r\n \r\n int result=0;\r\n if(!(((d1<0.)||(d2<0.)||(d3<0.))&&((d1>0.)||(d2>0.)||(d3>0.)))){\r\n result=1;\r\n }\r\n return result;\r\n}\r\n\r\nfloat getSignedDist(vec2 uv) {\r\n vec2 d = abs(uv - vec2(0.5)) - vec2(0.5);\r\n return length(max(d, vec2(0.))) + min(max(d.x, d.y), 0.0);\r\n}\r\n\r\nfloat sdfArchers( vec2 p0, vec2 p1, vec2 p2, vec2 p3, float r )\r\n{\r\n return min(min(length(p0) - r, length(p1) - r), min(length(p2) - r, length(p3) - r));\r\n}\r\n\r\nvec4 getStickColor(vec4 backcolor){\r\n \r\n vec4 finalColor = backcolor;\r\n\r\n // ---- UNROLL ---- \r\n for (int id = 0; id < STICKER_NUM; id++) {\r\n if (uVisible[id] > 0.5) {\r\n vec3 n = (normalize(vAutoUVCoord - uBoundSphere[id].xyz));\r\n n = (uT[id] * vec4(n, 0.)).xyz;\r\n vec2 uv = (uMat[id] * vec3(sphericalMapping(n), 1.0)).xy;\r\n vec4 tex = texture2D(uStickerMap[id], uv);\r\n vec3 P = uPos[id];\r\n vec3 N = uNormal[id];\r\n //N = normalize(gl_FrontFacing ? N : -N);\r\n vec3 worldN = normalize(gl_FrontFacing ? vWorldNormal : -vWorldNormal);\r\n \r\n float d = length(P - vAutoUVCoord);\r\n if (dot(worldN, N) >= 0.) {\r\n\r\n tex.rgb = sRGBToLinear(tex.rgb);\r\n float highlight = uHighlight[id];\r\n float l = getSignedDist(uv);\r\n\r\n if (d <= uBoundSphere[id].w && l <= highlight * 0.02) {\r\n if (l <= 0.0) { \r\n finalColor.rgb = mix(finalColor.rgb, tex.rgb, tex.a);\r\n finalColor.a = clamp(finalColor.a * (1.0 - tex.a) + tex.a, 0., 1.); \r\n } else {\r\n finalColor = vec4(0.102, 0.5922, 0.8, 1.0); \r\n }\r\n }\r\n\r\n if (highlight > 0.0) {\r\n float archer = sdfArchers(\r\n uv - vec2(uAnchors[0], uAnchors[1]),\r\n uv - vec2(uAnchors[2], uAnchors[3]),\r\n uv - vec2(uAnchors[4], uAnchors[5]),\r\n uv - vec2(uAnchors[6], uAnchors[7]),\r\n 0.01); \r\n if (archer <= 0.02)\r\n finalColor = vec4(0.0, 0.0, 1.0, 1.0);\r\n }\r\n }\r\n } \r\n }\r\n // ---- UNROLL ---- \r\n\r\n return finalColor;\r\n \r\n}\r\n\r\n#endif",Nl=n("977b"),Ol=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(){var e;return Object(v["a"])(this,r),e=t.call(this),e._root=null,e.nodeGrid=null,e.nodeGizmo=null,e.nodeRuler=null,e.shoes=[],e.mainShoe=null,e.initRoot(),e}return Object(S["a"])(r,[{key:"initRoot",value:function(){this._root=new w["default"].MatrixTransform,this._root.setMatrix(w["default"].mat4.fromValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1));var e=this._root.getOrCreateStateSet();this._uInverseMat=w["default"].Uniform.createMatrix4("uInverseScopeModelMatrix"),e.addUniform(this._uInverseMat),e.setShaderGeneratorName("PBR"),e.addUniform(w["default"].Uniform.createInt(Ba.AO_TEXTURE_UNIT,"aoMap")),e.addUniform(w["default"].Uniform.createInt(Ba.ALBEDO_TEXTURE_UNIT,"albedoMap")),e.addUniform(w["default"].Uniform.createInt(Ba.METALLIC_TEXTURE_UNIT,"metallicMap")),e.addUniform(w["default"].Uniform.createInt(Ba.ROUGHNESS_TEXTURE_UNIT,"roughnessMap")),e.addUniform(w["default"].Uniform.createInt(Ba.NORMAL_TEXTURE_UNIT,"normalMap")),e.addUniform(w["default"].Uniform.createInt(Ba.OPACITY_TEXTURE_UNIT,"opacityMap")),e.addUniform(w["default"].Uniform.createInt(Ba.DISPLACEMENT_TEXTURE_UNIT,"displacementMap"));var t=Ba.STICKER_TEXTURE_UNIT;e.addUniform(w["default"].Uniform.createIntArray([t,t+1,t+2,t+3],"uStickerMap"))}},{key:"showGrid",value:function(e){}},{key:"gizmoAttach",value:function(e){}},{key:"showGizmo",value:function(e){}},{key:"showRuler",value:function(e){}},{key:"isShoeInScene",value:function(e,t){var r=this.shoes,n=r.length;while(n--)if(r[n].shoe==e&&r[n].isLeft==t)return!0;return!1}},{key:"addChildShoe",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=Date.now();this.shoes.push({id:r,shoe:e,isLeft:t});var n=t?e.nodeLeft:e.nodeRight,i=n.getUserData()||{};return i["shoeId"]=r,n.setUserData(i),this.addChild(n),n}},{key:"removeChildShoe",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=t?e.nodeLeft:e.nodeRight,n=this.shoes.length;while(n--)if(this.shoes[n].shoe==e&&this.shoes[n].isLeft==t){this.shoes.splice(n,1);break}this.removeChild(r)}},{key:"shoeTest",value:function(e){}},{key:"addChild",value:function(e){var t=this._root;t.setNodeMask(0),t.addChild(e),t.setNodeMask(-1),t.dirtyBound(),this.emit("change")}},{key:"removeChild",value:function(e){var t=this._root;t.setNodeMask(0),t.removeChild(e),t.setNodeMask(-1),t.dirtyBound(),this.emit("change")}},{key:"clean",value:function(){this._root.removeChildren()}},{key:"updateKdTree",value:function(){var e=this._root,t=new Nl["a"]({_numVerticesProcessed:0,_targetNumTrianglesPerLeaf:50,_maxNumLevels:20});t.apply(e)}}]),r}(R),Il=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(e){var n;return Object(v["a"])(this,r),n=t.call(this),n._explodeCenter=e||[0,0,0],n}return Object(S["a"])(r,[{key:"setCenter",value:function(e){this._explodeCenter=e}},{key:"apply",value:function(e){if(e instanceof Ve["a"]){var t,r=e.getParents();r.length>1&&console.warn("insert explode node has more than one parent"),r[0]instanceof Be["a"]&&r[0].explode&&r[0].getUserData().uniqueID===e._uniqueID?t=r[0]:(t=new Be["a"],t.explode=!0,r.forEach((function(r){r.addChild(t),r.removeChild(e)})),t.addChild(e),t.setUserData(Object.assign(t.getUserData()||{},{uniqueID:e._uniqueID})));var n=w["default"].mat4.create(),i=w["default"].vec3.create(),a=w["default"].vec3.create(),o=w["default"].vec3.create();t.getWorldMatrix(void 0,n);var s=t.getBoundingSphere();s.transformMat4(s,n);var u=w["default"].vec3.clone(s.center());w["default"].mat4.getTranslation(i,n),w["default"].vec3.sub(a,u,i),w["default"].vec3.sub(o,u,this._explodeCenter),t.setUserData(Object.assign(t.getUserData()||{},{offset:a,dir:o,explodeCenter:this._explodeCenter}))}this.traverse(e)}}]),r}(Wr["a"]),Pl=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(){var e;return Object(v["a"])(this,r),e=t.call(this),e._scale=1,e}return Object(S["a"])(r,[{key:"setScale",value:function(e){this._scale=e}},{key:"apply",value:function(e){if(!0===e.explode){var t=e.getUserData(),r=w["default"].vec3.create(),n=w["default"].vec3.create(),i=w["default"].vec3.create();w["default"].vec3.scale(n,t.dir,this._scale),w["default"].vec3.add(r,t.explodeCenter,n),w["default"].vec3.sub(i,r,t.offset);var a=w["default"].mat4.create(),o=e.getParents();1!==o.length&&console.warn("explode error: explode node has more than one parent");var s=o[0];s.getWorldMatrix(void 0,a);var u=w["default"].mat4.clone(a);w["default"].mat4.setTranslation(u,i),w["default"].mat4.invert(a,a);var c=w["default"].mat4.create();w["default"].mat4.mul(c,a,u),e.setMatrix(c)}this.traverse(e)}}]),r}(Wr["a"]),Dl=Object.assign({"earlyZFrag.glsl":_l,"cubemapFragment.glsl":pl,"cubemapSampler.glsl":gl,"cubemapVertex.glsl":ml,"math.glsl":vl,"changeColor.glsl":bl,"panoramaSampler.glsl":Sl,"pbr_ue4.glsl":xl,"pbrFrag.glsl":Tl,"baseVert.glsl":yl,"sphericalHarmonics.glsl":Cl,"sphericalHarmonicsFragment.glsl":Al,"sphericalHarmonicsVertex.glsl":El,"triplanar_projection.glsl":Rl,"shadowCastFrag.glsl":Ml,"sticker.glsl":wl},N,O),Ll=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(e){return Object(v["a"])(this,r),t.call(this,e)}return Object(S["a"])(r,[{key:"apply",value:function(e){e.releaseGLObjects(),this.traverse(e)}}]),r}(Wr["a"]),Fl=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(e,n){var i;Object(v["a"])(this,r),i=t.call(this),i._releaseVisitor=new Ll,i._explodeSetup=new Il,i._explode=new Pl,i._explodeRoot=void 0,i._canvasPixelRatio=new fl,i.backgroundUniform={ambient:w["default"].Uniform.createInt1(0,"uAmbient"),texture0:w["default"].Uniform.createInt1(0,"uTexture0"),backgroundExposure:w["default"].Uniform.createFloat(1,"uBackgroundExposure"),size:w["default"].Uniform.createFloat(1,"uSize"),color:w["default"].Uniform.createFloat3(w["default"].vec3.fromValues(0,0,1),"uBackgroundColor"),scale:w["default"].Uniform.createFloat2(w["default"].vec2.fromValues(1,1),"uFixedScale")},i._finishPromise=bi(),i.envUniform={environmentTransform:w["default"].Uniform.createMatrix3("uEnvironmentTransform"),exposure:w["default"].Uniform.createFloat1(1,"uEnvironmentExposure"),diffuseSPH:w["default"].Uniform.createFloat3Array(new Float32Array(27),"uDiffuseSPH"),textureSpecularPBR:w["default"].Uniform.createInt1("sSpecularPBR"),textureIntegrateBRDF:w["default"].Uniform.createInt1("sIntegrateBRDF"),factorShadowEnv0:w["default"].Uniform.createFloat(0,"uFactorShadowEnv0")},i.postProcessUniform={uProjFactor:w["default"].Uniform.createFloat("uProjFactor"),uSsaoRadius:w["default"].Uniform.createFloat("uSsaoRadius"),uSsaoIntensity:w["default"].Uniform.createFloat("uSsaoIntensity"),uSsaoBias:w["default"].Uniform.createFloat("uSsaoBias"),uSsaoProjectionInfo:w["default"].Uniform.createFloat4("uSsaoProjectionInfo"),uSsaoProjectionScale:w["default"].Uniform.createFloat(1,"uSsaoProjectionScale"),uDofBlurNearFarFocal:w["default"].Uniform.createFloat3("uDofBlurNearFarFocal"),uDofCross:w["default"].Uniform.createFloat3(w["default"].vec3.create(),"uDofCross"),uDofScale:w["default"].Uniform.createFloat(1,"uDofScale"),uBloomFactor:w["default"].Uniform.createFloat("uBloomFactor"),uBloomThreshold:w["default"].Uniform.createFloat("uBloomThreshold"),uBloomRadius:w["default"].Uniform.createFloat("uBloomRadius"),uChromaFactor:w["default"].Uniform.createFloat("uChromaFactor"),uColorBalanceLow:w["default"].Uniform.createFloat3("uColorBalanceLow"),uColorBalanceMid:w["default"].Uniform.createFloat3("uColorBalanceMid"),uColorBalanceHigh:w["default"].Uniform.createFloat3("uColorBalanceHigh"),uToneExposure:w["default"].Uniform.createFloat("uToneExposure"),uToneBrightness:w["default"].Uniform.createFloat("uToneBrightness"),uToneContrast:w["default"].Uniform.createFloat("uToneContrast"),uToneSaturation:w["default"].Uniform.createFloat("uToneSaturation"),uToneMethod:w["default"].Uniform.createInt("uToneMethod"),uDistortion:w["default"].Uniform.createFloat2("uDistortion"),uProjectionLeft:w["default"].Uniform.createFloat4("uProjectionLeft"),uUnprojectionLeft:w["default"].Uniform.createFloat4("uUnprojectionLeft"),uSharpFactor:w["default"].Uniform.createFloat("uSharpFactor"),uLensRadius:w["default"].Uniform.createFloat2("uLensRadius"),uTimeGrain:w["default"].Uniform.createFloat("uTimeGrain"),uGrainFactor:w["default"].Uniform.createFloat("uGrainFactor"),uTaaInvViewMatrixLeft:w["default"].Uniform.createMatrix4("uTaaInvViewMatrixLeft"),uTaaCurrentFramePVLeft:w["default"].Uniform.createMatrix4("uTaaCurrentFramePVLeft"),uTaaLastFramePVLeft:w["default"].Uniform.createMatrix4("uTaaLastFramePVLeft"),uTaaCornersCSLeft:w["default"].Uniform.createFloat4Array("uTaaCornersCSLeft",2),uTaaEnabled:w["default"].Uniform.createFloat(1,"uTaaEnabled"),uTaaInvViewMatrixRight:w["default"].Uniform.createMatrix4("uTaaInvViewMatrixRight"),uTaaCurrentFramePVRight:w["default"].Uniform.createMatrix4("uTaaCurrentFramePVRight"),uTaaLastFramePVRight:w["default"].Uniform.createMatrix4("uTaaLastFramePVRight"),uTaaCornersCSRight:w["default"].Uniform.createFloat4Array("uTaaCornersCSRight",2),uVrFadeFactor:w["default"].Uniform.createFloat(0,"uVrFadeFactor"),uVrVeilFactor:w["default"].Uniform.createFloat(1,"uVrVeilFactor")},i.globalUniform={uInverseScopeModelMatrix:w["default"].Uniform.createMatrix4("uInverseScopeModelMatrix"),uDrawOpaque:w["default"].Uniform.createInt(-1,"uDrawOpaque"),uEarlyZ:w["default"].Uniform.createInt(0,"uEarlyZ"),uQVT:w["default"].Uniform.createFloat3("uQVT"),uQVS:w["default"].Uniform.createFloat3("uQVS"),uQW:w["default"].Uniform.createFloat2("uQW"),uQUV0:w["default"].Uniform.createFloat4("uQUV0"),uNearFar:w["default"].Uniform.createFloat2("uNearFar"),uBoxRadius:w["default"].Uniform.createFloat("uBoxRadius"),uOutputLinear:w["default"].Uniform.createInt(1,"uOutputLinear"),uRGBMRange:w["default"].Uniform.createFloat("uRGBMRange"),uGlobalTexSize:w["default"].Uniform.createFloat2("uGlobalTexSize"),uGlobalTexRatio:w["default"].Uniform.createFloat2("uGlobalTexRatio"),uPixelRatio:w["default"].Uniform.createFloat2("uPixelRatio"),uPreviousGlobalTexSize:w["default"].Uniform.createFloat2("uPreviousGlobalTexSize"),uPreviousGlobalTexRatio:w["default"].Uniform.createFloat2("uPreviousGlobalTexRatio"),uPreviousHalton:w["default"].Uniform.createFloat4("uPreviousHalton"),uReprojectViewProj:w["default"].Uniform.createMatrix4("uReprojectViewProj"),uTaaCornersCSLeft:i.postProcessUniform.uTaaCornersCSLeft,uPreviousProjection:w["default"].Uniform.createMatrix4("uPreviousProjection"),uPreviousViewInvView:w["default"].Uniform.createMatrix4("uPreviousViewInvView"),uTextureToBeRefractedSize:w["default"].Uniform.createFloat2("uTextureToBeRefractedSize"),uHoverUV:w["default"].Uniform.createFloat2(w["default"].vec2.fromValues(1e6,1e6),"uHoverUV"),uDisplay2D:w["default"].Uniform.createFloat(0,"uDisplay2D"),uSplitView:w["default"].Uniform.createFloat(0,"uSplitView"),uInspectorView:w["default"].Uniform.createInt(0,"uInspectorView"),uTimeViewer:w["default"].Uniform.createFloat("uTimeViewer"),uHalton:w["default"].Uniform.createFloat4("uHalton"),uSSAARestart:w["default"].Uniform.createFloat(0,"uSSAARestart"),uScatteringFactorPacker:w["default"].Uniform.createFloat("uScatteringFactorPacker"),uNormalizeFactorThickness:w["default"].Uniform.createFloat("uNormalizeFactorThickness"),uStaticFrameNumShadow0:w["default"].Uniform.createFloat("uStaticFrameNumShadow0"),uStaticFrameNumShadow1:w["default"].Uniform.createFloat("uStaticFrameNumShadow1"),uStaticFrameNumShadow2:w["default"].Uniform.createFloat("uStaticFrameNumShadow2"),uStaticFrameNumShadow3:w["default"].Uniform.createFloat("uStaticFrameNumShadow3"),uShadowMapSize:w["default"].Uniform.createFloat2("uShadowMapSize"),uIsVr:w["default"].Uniform.createInt("uIsVr"),uFrameMod:w["default"].Uniform.createFloat(0,"uFrameMod"),uFrameModTaaSS:w["default"].Uniform.createFloat(0,"uFrameModTaaSS"),uSsrFactor:w["default"].Uniform.createFloat(1,"uSsrFactor"),uQuality:w["default"].Uniform.createFloat(0,"uQuality")},i.clearOpaqueRGBA=w["default"].vec4.fromValues(0,0,0,0),i.cameraMain=void 0,i.cameraEnvironment=void 0,i.nodePostProcessOut=void 0,i.nodeRootModel=void 0,i._canvas=e,i._shaderProcessor=Nr["a"],i.readShaders(),i._viewer=new gr.Viewer(i._canvas,{powerPreference:"high-performance",antialias:!0,depth:!1,stencil:!1,alpha:!0,premultipliedAlpha:!0,fullscreen:!1,preserveDrawingBuffer:!1,enableFrustumCulling:!1,maxDevicePixelRatio:M.maxDevicePixelRatio||1.5,InputSources:{Mouse:{scrollwheel:!0},WebVR:{pollInterval:-1},GamePad:{enable:!1}}}),i._rootScene=new w["default"].MatrixTransform,i._rootScene.setName("root"),i._features={},i._featuresManager=null,i._eventEmiiter=new hi["Model"],i._viewer.init(),i._viewer.getCamera().setClearColor([0,0,0,0]),i._viewer.requestContinuousUpdate(!1),hl(i._viewer.getState().getShaderGeneratorProxy());var a=i.getCamera();a.getRenderer().setCullVisitor(new qa(Object(y["a"])(i)));var o=Object(y["a"])(i);return i._switchManipulator=new kc(i._viewer.getInputManager(),(function(e){e&&("noJitter"===e?i._frameManager.drawNoJitter():i._frameManager.draw())})),i._viewer.setupManipulator(i._switchManipulator),i._featureEventManager=new vr,i._featureEventManager.init(i._viewer.getInputManager()),i._superSample=new rc(Object(y["a"])(i)),i._frameManager=new ec,i._frameManager.setViewer(i._viewer),i._frameManager.setSuperSample(i._superSample),i._superSample.setRoot(i._rootScene),i._viewer.setSceneData(i._rootScene),i._viewer.getManipulator().computeHomePosition(),i.createScene(),i._features.lighting=new Wa(Object(y["a"])(i)),i._features.environment=new No(Object(y["a"])(i)),i._features.background=new Oo(Object(y["a"])(i)),i._features.postProcess=new So(Object(y["a"])(i)),i._features.outline=new $u(Object(y["a"])(i)),i._features.screenShot=new ko(Object(y["a"])(i)),i._features.sticker=new Ko(Object(y["a"])(i)),i._viewer.renderBinded=function(){o.emit("viewport:update",0),this.render()}.bind(i._viewer),i}return Object(S["a"])(r,[{key:"displayGraph",value:function(){var e=this._rootScene,t=Xn.DisplayGraph.instance();t.setDisplayGraphRenderer(!0),t.createGraph(e)}},{key:"getRootModel",value:function(){return this.scene._root}},{key:"featureFinished",value:function(e){return this._featuresManager=new li(this),this._finishPromise.resolve(),this._featuresManager.finished(e)}},{key:"_launchViewer",value:function(e,t){this.featureFinished(this._rootScene)}},{key:"createCamera",value:function(e){var t=new w["default"].Camera;t.setName("composer2D"),t.setReferenceFrame(w["default"].Transform.ABSOLUTE_RF);var r=w["default"].createTexturedQuadGeometry(-1,-1,0,2,0,0,0,2,0);return r.getOrCreateStateSet().setTextureAttributeAndModes(0,e),t.addChild(r),t}},{key:"getFeaturesManager",value:function(){return this._featuresManager}},{key:"getSuperSample",value:function(){return this._superSample}},{key:"getCamera",value:function(){return this._viewer.getCamera()}},{key:"getInputManager",value:function(){return this._viewer.getInputManager()}},{key:"drawFrame",value:function(){this._viewer.requestRedraw(),this._viewer.frame()}},{key:"getCanvas",value:function(){return this._viewer._canvas}},{key:"getFeatures",value:function(){return this._features}},{key:"getViewerOSGJS",value:function(){return this._viewer}},{key:"pick",value:function(e,t,r,n){var i=this._canvas,a=i.width/i.clientWidth,o=i.height/i.clientHeight,s=this._viewer.computeIntersections(e*a,(i.clientHeight-t)*o,Tr.PICK_GEOMETRY_FAST);if(s.length>0){s.sort((function(e,t){return e._ratio-t._ratio}));var u=n?s[0]:s[0]._drawable;return r&&r(u),u}return r&&r(),null}},{key:"setOutLine",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=this._features.outline.model;t.colorSelection&&r.set("colorSelection",t.colorSelection),t.durationOutline&&r.set("durationOutline",t.durationOutline),t.durationHighlight&&r.set("durationHighlight",t.durationHighlight),t.outlineWidth&&r.set("outlineWidth",t.outlineWidth),r.trigger("displayOutlineNoFocus",e),this._frameManager.draw()}},{key:"setEnvironmentRotation",value:function(e){this._features.environment.getModel().set("rotation",e)}},{key:"setBackgroundColor",value:function(){var e;e=arguments.length>1?w["default"].vec3.fromValues(arguments[0],arguments[1],arguments[2]):w["default"].vec3.fromValues(arguments[0][0],arguments[0][1],arguments[0][2]),this._features.background.getModel().set("color",e)}},{key:"setBackgroundMode",value:function(e){this._features.background.getModel().set("enable",e)}},{key:"setBackgroundFixed",value:function(e){this._features.background.getModel().set("fixed",e)}},{key:"setEnvironmentExposure",value:function(e){this._features.environment.getModel().set("exposure",e)}},{key:"setEnvironmentModel",value:function(e){this._features.environment.getModel().set("env",e)}},{key:"setToneMappingExposure",value:function(e){this._features.postProcess.getModel().set("toneMappingExposure",e)}},{key:"setToneMappingBrightness",value:function(e){this._features.postProcess.getModel().set("toneMappingBrightness",e)}},{key:"setToneMappingContrast",value:function(e){this._features.postProcess.getModel().set("toneMappingContrast",e)}},{key:"setToneMappingSaturation",value:function(e){this._features.postProcess.getModel().set("toneMappingSaturation",e)}},{key:"setToneMappingMethod",value:function(e){this._features.postProcess.getModel().set("toneMappingMethod",e)}},{key:"setViewMode",value:function(e,t){this._viewer.getManipulator().setViewMode(e,t)}},{key:"setNoPan",value:function(e){this._viewer.getManipulator().getCurrentManipulator().setNoPan(e)}},{key:"setNoZoom",value:function(e){this._viewer.getManipulator().getCurrentManipulator().setNoZoom(e)}},{key:"takeScreenShot",value:function(e,t){var r=this._features.screenShot.getScreenShot(e,t,this);return r}},{key:"readShaders",value:function(){this._shaderProcessor.addShaders(Dl)}},{key:"getEventEmitter",value:function(){return this._eventEmiiter}},{key:"redraw",value:function(){this._frameManager.draw()}},{key:"createScene",value:function(){this.scene=new Ol}},{key:"resize",value:function(e,t){}},{key:"start",value:function(){this._launchViewer(),this._viewer.run()}},{key:"captureMaterial",value:function(e){Ba.captureMaterial(e)}},{key:"destory",value:function(e){this._viewer.setDone(!0),this._viewer.dispose(),ei.clearCache(),e&&Ci.getInstance().dirty(),this._rootScene.accept(this._releaseVisitor),this._rootScene.removeChildren(),this._rootScene=null,this._viewer.flushAllDeletedGLObjects()}},{key:"getLightPresets",value:function(){return di}},{key:"setThreeLightsJson",value:function(e,t){var r=this._features.lighting.model;return r.setJSON({enable:r.get("enable"),lights:e},t),!0}},{key:"setLightingEnable",value:function(e){var t=this._features.lighting.model;return t.set("enable",e),!0}},{key:"setEditLightingMode",value:function(e){return this._features.lighting.showLighting(e),!0}},{key:"setLightSelect",value:function(e){this._features.lighting.setSelect(e)}},{key:"setLightDir",value:function(e,t,r){var n=this._features.lighting.model.get("lights")[e],i=n.get("matrix"),a=w["default"].mat4.create();w["default"].mat4.fromYRotation(a,Math.PI*t/180);var o=w["default"].mat4.create();w["default"].mat4.fromZRotation(o,Math.PI*r/180),w["default"].mat4.mul(i,o,a),n.dirty(),this._features.lighting.model.dirtyScene(),this.redraw()}},{key:"setAutoRotateMode",value:function(e){this._switchManipulator.setAutoRotateMode(e)}},{key:"initExplode",value:function(e){this._explodeRoot=e;var t=w["default"].vec3.clone(this._explodeRoot.getBoundingSphere().center());this._explodeSetup.setCenter(t),this._explodeSetup.apply(this._explodeRoot)}},{key:"explode",value:function(e){this._explodeRoot&&(e<1&&(e=1),this._explode.setScale(e),this._explode.apply(this._explodeRoot),this.redraw())}}]),r}(R),kl=Fl,Bl=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(){var e;return Object(v["a"])(this,r),e=t.call(this),e.root=null,e._hooks={},e}return Object(S["a"])(r,[{key:"method",value:function(e,t){if(void 0!==this._hooks[e])throw new Error("can't override hook: "+e);this._hooks[e]=t}},{key:"methodRemove",value:function(e){delete this._hooks[e]}},{key:"call",value:function(e){if(this._hooks[e]){var t=Array.prototype.slice.call(arguments,1);try{return this._hooks[e].apply(null,t)}catch(r){console.info("%c%s %c(editor.method error)","color: #06f",e,"color: #f00"),console.error(r)}}return null}}]),r}(R),Ul=n("094b"),Vl=n("850d"),Gl=j["a"].rejectObject,zl={Object:function(e,t){var r=e.getJSON();if(r.Name&&t.setName(r.Name),r.UserDataContainer){var n=e.setJSON(r.UserDataContainer).readUserDataContainer();void 0!==n&&t.setUserData(n)}return t},Node:function(e,t){var r=e.getJSON();zl.Object(e,t);var n=[];if(r.UpdateCallbacks)for(var i=t.addUpdateCallback.bind(t),a=0,o=r.UpdateCallbacks.length;a<o;a++){var s=e.setJSON(r.UpdateCallbacks[a]).readObject();n.push(s),s.then(i)}if(r.StateSet){var u=e.setJSON(r.StateSet).readObject();n.push(u),u.then(t.setStateSet.bind(t))}var c=[];if(r.Children)for(var l=0,h=r.Children.length;l<h;l++)c.push(e.setJSON(r.Children[l]).readObject());return U.a.all(n).then((function(){return U.a.all(c).then((function(e){for(var r=e.length,n=0;n<r;n++)t.addChild(e[n]);return t}))}))},StateSet:function(e,t){var r=e.getJSON();zl.Object(e,t),void 0!==r.RenderingHint&&t.setRenderingHint(r.RenderingHint);var n=[],i=function(r){var i=e.setJSON(r).readObject();i.isRejected()||(n.push(i),i.then(t.setAttributeAndModes.bind(t)))};if(void 0!==r.AttributeList)for(var a=0,o=r.AttributeList.length;a<o;a++)i(r.AttributeList[a]);var s=function(r,i){var a=e.setJSON(i).readObject();a.isRejected()||(n.push(a),a.then(t.setTextureAttributeAndModes.bind(t,r)))};if(r.TextureAttributeList)for(var u=r.TextureAttributeList,c=0,l=u.length;c<l;c++)for(var h=u[c],d=0,f=h.length;d<f;d++)s(c,h[d]);return U.a.all(n).then((function(){return t}))},Material:function(e,t){var r=e.getJSON();return r.Diffuse&&r.Emission&&r.Specular&&void 0!==r.Shininess?(zl.Object(e,t),t.setAmbient(r.Ambient),t.setDiffuse(r.Diffuse),t.setEmission(r.Emission),t.setSpecular(r.Specular),t.setShininess(r.Shininess),U.a.resolve(t)):Gl("Material",r)},BlendFunc:function(e,t){var r=e.getJSON();return r.SourceRGB&&r.SourceAlpha&&r.DestinationRGB&&r.DestinationAlpha?(zl.Object(e,t),t.setSourceRGB(r.SourceRGB),t.setSourceAlpha(r.SourceAlpha),t.setDestinationRGB(r.DestinationRGB),t.setDestinationAlpha(r.DestinationAlpha),U.a.resolve(t)):Gl("BlendFunc",r)},CullFace:function(e,t){var r=e.getJSON();return void 0===r.Mode?Gl("CullFace",r):(zl.Object(e,t),t.setMode(r.Mode),U.a.resolve(t))},BlendColor:function(e,t){var r=e.getJSON();return r.ConstantColor?(zl.Object(e,t),t.setConstantColor(r.ConstantColor),U.a.resolve(t)):Gl("BlendColor",r)},Light:function(e,t){var r=e.getJSON();return r.Ambient&&r.Diffuse&&r.Direction&&r.Position&&r.Specular&&void 0!==r.LightNum&&void 0!==r.SpotCutoff&&void 0!==r.LinearAttenuation&&void 0!==r.ConstantAttenuation&&void 0!==r.QuadraticAttenuation?(zl.Object(e,t),t.setAmbient(r.Ambient),t.setConstantAttenuation(r.ConstantAttenuation),t.setDiffuse(r.Diffuse),t.setDirection(r.Direction),t.setLightNumber(r.LightNum),t.setLinearAttenuation(r.LinearAttenuation),t.setPosition(r.Position),t.setQuadraticAttenuation(r.QuadraticAttenuation),t.setSpecular(r.Specular),t.setSpotCutoff(r.SpotCutoff),t.setSpotBlend(.01),void 0!==r.SpotExponent&&t.setSpotBlend(r.SpotExponent/128),U.a.resolve(t)):Gl("Light",r)},Texture:function(e,t){var r=e.getJSON();zl.Object(e,t),r.MinFilter&&t.setMinFilter(r.MinFilter),r.MagFilter&&t.setMagFilter(r.MagFilter),r.WrapT&&t.setWrapT(r.WrapT),r.WrapS&&t.setWrapS(r.WrapS);var n=r.File;return void 0===n&&(n="no-image-provided"),e.readImageURL(n).then((function(e){return t.setImage(e),t}))},Projection:function(e,t){var r=e.getJSON();if(!r.Matrix)return Gl("Projection",r);var n=zl.Node(e,t);return t.setMatrix(r.Matrix),n},MatrixTransform:function(e,t){var r=e.getJSON();if(!r.Matrix)return Gl("MatrixTransform",r);var n=zl.Node(e,t);return t.setMatrix(r.Matrix),n},LightSource:function(e,t){var r=e.getJSON();if(!r.Light)return Gl("LightSource",r);var n=zl.Node(e,t);return U.a.all([e.setJSON(r.Light).readObject(),n]).then((function(e){var n=e[0];return t.setLight(n),"ABSOLUTE_RF"===r.ReferenceFrame&&t.setReferenceFrame(wr["a"].ABSOLUTE_RF),t}))},functionSortAttributes:function(e,t){return-1!==e.indexOf("TexCoord")&&-1!==t.indexOf("TexCoord")?parseInt(e.substr(8),10)-parseInt(t.substr(8),10):e<t?-1:e>t?1:0},Geometry:function(e,t){var r=e.getJSON();if(!r.VertexAttributeList)return Gl("Geometry",r);r.PrimitiveSetList=r.PrimitiveSetList||[];var n=[];n.push(zl.Node(e,t));var i=t.getPrimitives(),a=i.push.bind(i),o=0,s=r.PrimitiveSetList.length;for(o=0;o<s;o++){var u=e.setJSON(r.PrimitiveSetList[o]).readPrimitiveSet();n.push(u),u.then(a)}var c=function(e,t){this.getVertexAttributeList()[e]=t},l=r.VertexAttributeList,h=window.Object.keys(l);for(h.sort(zl.functionSortAttributes),s=h.length,o=0;o<s;o++){var d=h[o],f=e.setJSON(l[d]).readBufferArray();n.push(f),f.then(c.bind(t,d))}return U.a.all(n).then((function(){return t}))},PagedLOD:function(e,t){var r,n=e.getJSON();zl.Object(e,t),"USE_BOUNDING_SPHERE_CENTER"===n.CenterMode?t.setCenterMode(0):"UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED"===n.CenterMode&&t.setCenterMode(2),t.setCenter([n.UserCenter[0],n.UserCenter[1],n.UserCenter[2]]),t.setRadius(n.UserCenter[3]),"PIXEL_SIZE_ON_SCREEN"===n.RangeMode&&t.setRangeMode(1);for(var i=n.RangeList,a=0;a<window.Object.keys(i).length;a++){r="Range "+a;var o=i[r];t.setRange(a,o[0],o[1])}for(i=n.RangeDataList,a=0;a<window.Object.keys(i).length;a++)r="File "+a,t.setFileName(a,i[r]);t.setDatabasePath(e.getDatabasePath());var s=[];if(n.Children)for(var u=0,c=n.Children.length;u<c;u++)s.push(e.setJSON(n.Children[u]).readObject());return U.a.all(s).then((function(e){var r=e.length;for(a=0;a<r;a++)t.addChildNode(e[a]);return t}))}},jl=zl,Hl=(n("c19f"),j["a"].rejectObject),Wl={},Xl=function(){},ql=Aa["default"].registry();ql.registerObject("osgAnimation.Vec3LerpChannel",Xl),ql.registerObject("osgAnimation.FloatLerpChannel",Xl),ql.registerObject("osgAnimation.QuatSlerpChannel",Xl),ql.registerObject("osgAnimation.QuatLerpChannel",Xl),ql.registerObject("osgAnimation.FloatCubicBezierChannel",Xl),ql.registerObject("osgAnimation.Vec3CubicBezierChannel",Xl),ql.registerObject("osgAnimation.StackedMatrixElement",Iu),ql.registerObject("osgAnimation.StackedScaleElement",Uu),Wl.Animation=function(e){var t=e.getJSON();if(void 0===t.Name||!t.Channels||0===t.Channels.length)return Hl("Animation",t);for(var r=[],n=0,i=t.Channels.length;n<i;n++){var a=e.setJSON(t.Channels[n]).readObject();r.push(a)}return U.a.all(r).then((function(e){return xs.createAnimation(e,t.Name)}))},Wl.StandardVec3Channel=function(e,t,r){var n=e.getJSON();if(void 0===n.TargetName||!n.KeyFrames||!n.Name||!n.KeyFrames.Time||!n.KeyFrames.Key||3!==n.KeyFrames.Key.length)return Hl("StandardVec3Channel",n);var i=e.setJSON(n.KeyFrames.Time).readBufferArray(),a=e.setJSON(n.KeyFrames.Key[0]).readBufferArray(),o=e.setJSON(n.KeyFrames.Key[1]).readBufferArray(),s=e.setJSON(n.KeyFrames.Key[2]).readBufferArray();return U.a.all([i,a,o,s]).then((function(e){for(var i=e[0].getElements(),a=e[1].getElements(),o=e[2].getElements(),s=e[3].getElements(),u=i.length,c=new Float32Array(new ArrayBuffer(4*(u+1)*3),0,3*u),l=new Float32Array(new ArrayBuffer(4*(u+1)),0,u),h=0;h<u;h++){var d=3*h;l[h]=i[h],c[d++]=a[h],c[d++]=o[h],c[d]=s[h]}return r(c,l,n.TargetName,n.Name,t),t}))},Wl.StandardQuatChannel=function(e,t,r){var n=e.getJSON();if(void 0===n.TargetName||!n.KeyFrames||!n.Name||!n.KeyFrames.Time||!n.KeyFrames.Key||4!==n.KeyFrames.Key.length)return Hl("StandardQuatChannel",n);var i=e.setJSON(n.KeyFrames.Time).readBufferArray(),a=e.setJSON(n.KeyFrames.Key[0]).readBufferArray(),o=e.setJSON(n.KeyFrames.Key[1]).readBufferArray(),s=e.setJSON(n.KeyFrames.Key[2]).readBufferArray(),u=e.setJSON(n.KeyFrames.Key[3]).readBufferArray();return U.a.all([i,a,o,s,u]).then((function(e){for(var i=e[0].getElements(),a=e[1].getElements(),o=e[2].getElements(),s=e[3].getElements(),u=e[4].getElements(),c=i.length,l=new Float32Array(new ArrayBuffer(4*(c+1)*4),0,4*c),h=new Float32Array(new ArrayBuffer(4*(c+1)),0,c),d=0;d<c;d++){var f=4*d;h[d]=i[d],l[f++]=a[d],l[f++]=o[d],l[f++]=s[d],l[f]=u[d]}return r(l,h,n.TargetName,n.Name,t),t}))},Wl.StandardFloatChannel=function(e,t,r){var n=e.getJSON();if(void 0===n.TargetName||!n.KeyFrames||!n.Name||!n.KeyFrames.Time||!n.KeyFrames.Key)return Hl("StandardFloatChannel",n);var i=e.setJSON(n.KeyFrames.Time).readBufferArray(),a=e.setJSON(n.KeyFrames.Key).readBufferArray();return U.a.all([i,a]).then((function(e){for(var i=e[0].getElements(),a=e[1].getElements(),o=i.length,s=new Float32Array(new ArrayBuffer(4*(o+1)),0,o),u=new Float32Array(new ArrayBuffer(4*(o+1)),0,o),c=0;c<o;c++)u[c]=i[c],s[c]=a[c];return r(s,u,n.TargetName,n.Name,t),t}))},Wl.Vec3LerpChannel=function(e,t){return Wl.StandardVec3Channel(e,t,gs.createVec3Channel)},Wl.QuatLerpChannel=function(e,t){return Wl.StandardQuatChannel(e,t,gs.createQuatChannel)},Wl.QuatSlerpChannel=function(e,t){return Wl.StandardQuatChannel(e,t,gs.createQuatChannel)},Wl.FloatLerpChannel=function(e,t){return Wl.StandardFloatChannel(e,t,gs.createFloatChannel)},Wl.FloatCubicBezierChannel=function(e,t){var r=e.getJSON();if(void 0===r.TargetName||!r.KeyFrames||!r.Name||!r.KeyFrames.Time||!r.KeyFrames.Position||!r.KeyFrames.ControlPointOut||!r.KeyFrames.ControlPointIn)return Hl("FloatCubicBezierChannel",r);var n,i=[],a=window.Object.keys(r.KeyFrames);for(n=0;n<a.length;n++)i.push(e.setJSON(r.KeyFrames[a[n]]).readBufferArray());return U.a.all(i).then((function(e){var i=e[0].getElements(),a=e[1].getElements(),o=e[2].getElements(),s=e[3].getElements(),u=s.length,c=new Float32Array(new ArrayBuffer(4*(u+1)*3),0,3*u),l=new Float32Array(new ArrayBuffer(4*(u+1)),0,u);for(n=0;n<u;n++){var h=3*n;l[n]=s[n],c[h++]=o[n],c[h++]=i[n],c[h]=a[n]}return gs.createFloatCubicBezierChannel(c,l,r.TargetName,r.Name,t),t}))},Wl.Vec3CubicBezierChannel=function(e,t){var r=e.getJSON();if(void 0===r.TargetName||!r.KeyFrames||!r.Name||!r.KeyFrames.Time||!r.KeyFrames.Position||!r.KeyFrames.ControlPointOut||!r.KeyFrames.ControlPointIn||3!==r.KeyFrames.Position.length||3!==r.KeyFrames.ControlPointIn.length||3!==r.KeyFrames.ControlPointOut.length)return Hl("Vec3CubicBezierChannel",r);var n,i=[],a=window.Object.keys(r.KeyFrames);for(n=0;n<a.length;n++){var o=a[n],s=r.KeyFrames[o];"Time"!==o?(i.push(e.setJSON(s[0]).readBufferArray()),i.push(e.setJSON(s[1]).readBufferArray()),i.push(e.setJSON(s[2]).readBufferArray())):i.push(e.setJSON(s).readBufferArray())}return U.a.all(i).then((function(e){var i=e[0].getElements(),a=e[1].getElements(),o=e[2].getElements(),s=e[3].getElements(),u=e[4].getElements(),c=e[5].getElements(),l=e[6].getElements(),h=e[7].getElements(),d=e[8].getElements(),f=e[9].getElements(),_=f.length,p=new Float32Array(new ArrayBuffer(4*(_+1)*9),0,9*_),g=new Float32Array(new ArrayBuffer(4*(_+1)),0,_);for(n=0;n<_;n++){var m=9*n;g[n]=f[n],p[m++]=l[n],p[m++]=h[n],p[m++]=d[n],p[m++]=i[n],p[m++]=a[n],p[m++]=o[n],p[m++]=s[n],p[m++]=u[n],p[m]=c[n]}return gs.createVec3CubicBezierChannel(p,g,r.TargetName,r.Name,t),t}))},Wl.BasicAnimationManager=function(e,t){var r=e.getJSON();if(!r.Animations)return Hl("BasicAnimationManager",r);jl.Object(e,t);for(var n=[],i=0,a=r.Animations.length;i<a;i++){var o=e.setJSON(r.Animations[i]).readObject();o.isRejected()?L["a"].warn("An Animation failed on the parsing!"):n.push(o)}return U.a.all(n).then((function(e){return t.init(e),t}))},Wl.UpdateMatrixTransform=function(e,t){var r=e.getJSON();if(
- /*!jsonObj.Name ||*/
- !r.StackedTransforms)return Hl("UpdateMatrixTransform",r);jl.Object(e,t);var n,i,a=[];for(n=0,i=r.StackedTransforms.length;n<i;n++){var o=e.setJSON(r.StackedTransforms[n]).readObject();o.isRejected()?L["a"].warn("A stacked transforms failed on the parsing!"):a.push(o)}return U.a.all(a).then((function(e){var r=t.getStackedTransforms();for(n=0,i=e.length;n<i;n++)r.push(e[n]);return t.computeChannels(),t}))},Wl.StackedTranslate=function(e,t){var r=e.getJSON();return r.Name&&r.Translate?(jl.Object(e,t),t.init(r.Translate),U.a.resolve(t)):Hl("StackedTranslate",r)},Wl.StackedQuaternion=function(e,t){var r=e.getJSON();return r.Name&&r.Quaternion?(jl.Object(e,t),t.init(r.Quaternion),U.a.resolve(t)):Hl("StackedQuaternion",r)},Wl.StackedRotateAxis=function(e,t){var r=e.getJSON();return r.Axis&&void 0!==r.Angle?(jl.Object(e,t),t.init(r.Axis,r.Angle),U.a.resolve(t)):Hl("StackedRotateAxis",r)},Wl.StackedMatrix=function(e,t){var r=e.getJSON();return r.Name&&r.Matrix?(jl.Object(e,t),t.init(r.Matrix),U.a.resolve(t)):Hl("StackedMatrix",r)},Wl.StackedScale=function(e,t){var r=e.getJSON();return r.Name&&r.Scale?(jl.Object(e,t),t.init(r.Scale),U.a.resolve(t)):Hl("StackedScale",r)},Wl.Bone=function(e,t){var r=e.getJSON();if(!r.InvBindMatrixInSkeletonSpace)return Hl("Bone",r);var n=jl.MatrixTransform(e,t);if(t.setInvBindMatrixInSkeletonSpace(r.InvBindMatrixInSkeletonSpace),r.BoundingBox){var i=t.getBoneBoundingBox();i.setMax(r.BoundingBox.max),i.setMin(r.BoundingBox.min)}return n},Wl.UpdateBone=Wl.UpdateMatrixTransform,Wl.UpdateSkeleton=function(e,t){return jl.Object(e,t),U.a.resolve(t)},Wl.Skeleton=jl.MatrixTransform,Wl.RigGeometry=function(e,t){var r=e.getJSON();if(!r.SourceGeometry)return Hl("RigGeometry",r);r.BoneMap||L["a"].warn("No boneMap found in a RigGeometry !");var n=jl.Geometry(e,t);t._boneNameID=r.BoneMap;var i,a=r.SourceGeometry["osg.Geometry"];return a?(e.setJSON(a),t.setSourceGeometry(new Ve["a"]),i=jl.Geometry(e,t.getSourceGeometry())):(a=r.SourceGeometry["osgAnimation.MorphGeometry"],a?(e.setJSON(a),t.setSourceGeometry(new Mu["a"]),i=Wl.MorphGeometry(e,t.getSourceGeometry())):L["a"].warn("SourceGeometry type no recognized")),void 0===t._uniqueID&&(t._uniqueID=a.UniqueID),U.a.all([n,i]).then((function(){return t.mergeChildrenData(),t}))},Wl.MorphGeometry=function(e,t){var r=e.getJSON();if(!r.MorphTargets)return Hl("MorphGeometry",r);var n=r.MorphTargets,i=[];i.push(jl.Geometry(e,t));for(var a=0,o=n.length;a<o;a++)i.push(e.setJSON(n[a]).readObject());return U.a.all(i).then((function(e){for(var t=e[0],r=t.getMorphTargets(),n=1,i=e.length;n<i;n++)r.push(e[n]);return t.mergeChildrenVertexAttributeList(),t}))},Wl.UpdateMorph=function(e,t){var r=e.getJSON();if(!r.TargetMap)return Hl("UpdateMorph",r);jl.Object(e,t);for(var n=window.Object.keys(r.TargetMap),i=0,a=n.length;i<a;i++){var o=n[i];t.addTarget(r.TargetMap[o],parseInt(o,10))}return U.a.resolve(t)},Wl.StackedMatrixElement=Wl.StackedMatrix,Wl.StackedScaleElement=Wl.StackedScale;var Yl=Wl,Kl=n("6ec3"),Jl=function e(t){Kl["a"].call(this),this._canvas=document.createElement("canvas"),this._context=this._canvas.getContext("2d"),this._matrixTransform=new Be["a"],this.addChild(this._matrixTransform),this._text="",void 0!==t&&(this._text=t),this._font="monospace",this._color=F["g"].fromValues(0,0,0,1),this._fillStyle="rgba( 0, 0, 0, 1 )",this._context.textAlign="center",this._textX=void 0,this._context.baseLine="middle",this._textY=void 0,this._characterSize=1,this._characterSizeMode=e.OBJECT_COORDS,this._fontSize=32,this._geometry=void 0,this._autoRotateToScreen=!1,this._position=F["f"].create(),this._layout=e.LEFT_TO_RIGHT,this._alignment=e.CENTER_CENTER,this._forcePowerOfTwo=!1,this._texture=new J["default"],this.drawText(),this._dirty=!1,this._previousModelView=F["c"].create()};Jl.OBJECT_COORDS=0,Jl.SCREEN_COORDS=1,Jl.OBJECT_COORDS_WITH_MAXIMUM_SCREEN_SIZE_CAPPED_BY_FONT_HEIGHT=2,Jl.LEFT_TO_RIGHT="ltr",Jl.RIGHT_TO_LEFT="rtl",Jl.LEFT_TOP=0,Jl.LEFT_CENTER=1,Jl.LEFT_BOTTOM=2,Jl.CENTER_TOP=3,Jl.CENTER_CENTER=4,Jl.CENTER_BOTTOM=5,Jl.RIGHT_TOP=6,Jl.RIGHT_CENTER=7,Jl.RIGHT_BOTTOM=8,j["a"].createPrototypeNode(Jl,j["a"].objectInherit(Kl["a"].prototype,{drawText:function(){if(void 0!==this._geometry&&(this._matrixTransform.removeChild(this._geometry),this._geometry.releaseGLObjects()),this._text){this.setTextProperties(),this._canvas.width=this._context.measureText(this._text).width,this._canvas.height=2*this._fontSize,this._forcePowerOfTwo&&(this._canvas.width=this._nextPowerOfTwo(this._canvas.width),this._canvas.height=this._nextPowerOfTwo(this._canvas.height)),this.setTextProperties(),this._context.clearRect(0,0,this._canvas.width,this._canvas.height),this._context.fillText(this._text,this._textX,this._textY);var e=this._canvas.width/this._canvas.height,t=this._characterSize*e;this._geometry=at["a"].createTexturedQuadGeometry(-t/2,-this._characterSize/2,0,t,0,0,0,this._characterSize,0),this._texture.setTextureSize(this._canvas.width,this._canvas.height),this._texture.setMinFilter("LINEAR"),this._texture.setMagFilter("LINEAR"),this._texture.setImage(this._canvas);var r=this._geometry.getOrCreateStateSet();r.setTextureAttributeAndModes(0,this._texture),r.setRenderingHint("TRANSPARENT_BIN"),r.setAttributeAndModes(new De["a"](De["a"].ONE,De["a"].ONE_MINUS_SRC_ALPHA)),this._matrixTransform.addChild(this._geometry),this.dirtyBound()}},setText:function(e){this._text=e,this._dirty=!0},getText:function(){return this._text},setFont:function(e){this._font=e,this._dirty=!0},setColor:function(e){this._color=e,this._fillStyle="rgba("+Math.round(255*e[0])+","+Math.round(255*e[1])+","+Math.round(255*e[2])+","+e[3]+")",this._context.fillStyle=this._fillStyle,this._context.fillText(this._text,this._textX,this._textY)},getColor:function(){return this._color},setCharacterSize:function(e){this._characterSize=e,this._characterSizeMode!==Jl.OBJECT_COORDS&&(F["c"].fromScaling(this._matrixTransform.getMatrix(),[this._characterSize,this._characterSize,this._characterSize]),this._characterSizeMode===Jl.OBJECT_COORDS_WITH_MAXIMUM_SCREEN_SIZE_CAPPED_BY_FONT_HEIGHT&&this.setMaximumScale(this._characterSize)),this._dirty=!0},getCharacterSize:function(){return this._characterSize},setCharacterSizeMode:function(e){this._characterSizeMode=e,this._characterSizeMode!==Jl.OBJECT_COORDS?(F["c"].fromScaling(this._matrixTransform.getMatrix(),[this._characterSize,this._characterSize,this._characterSize]),this.setAutoScaleToScreen(!0),this.setMaximumScale(Number.MAX_VALUE),this._characterSizeMode===Jl.OBJECT_COORDS_WITH_MAXIMUM_SCREEN_SIZE_CAPPED_BY_FONT_HEIGHT&&this.setMaximumScale(this._characterSize)):(this._matrixTransform.setMatrix(F["c"].create()),this.setAutoScaleToScreen(!1)),this._dirty=!0},getCharacterSizeMode:function(){return this._characterSizeMode},setFontResolution:function(e){this._fontSize=e,this._dirty=!0},getFontResolution:function(){return this._fontSize},setPosition:function(e){this._position=e,F["c"].fromTranslation(this.getMatrix(),e)},getPosition:function(){return this._position},setTextProperties:function(){this._context.fillStyle=this._fillStyle,this._setAlignmentValues(this._alignment),this._context.font=this._fontSize+"px "+this._font,this._context.direction=this._layout},setAutoRotateToScreen:function(e){Kl["a"].prototype.setAutoRotateToScreen.call(this,e),this._dirty=!0},getAutoRotateToScreen:function(){return this._autoRotateToScreen},setLayout:function(e){this._layout="string"===typeof e?Jl[e]:e,this._dirty=!0},getLayout:function(){return this._layout},setAlignment:function(e){this._alignment="string"===typeof e?Jl[e]:e,this._dirty=!0},getAlignment:function(){return this._alignment},accept:function(){return function(e){if(this._dirty&&(this.drawText(),this._dirty=!1),e.getVisitorType()===Wr["a"].CULL_VISITOR){var t=e.getViewport().width(),r=e.getViewport().height(),n=e.getCurrentProjectionMatrix(),i=e.getCurrentModelViewMatrix(),a=this._position,o=this._firstTimeToInitEyePoint;if(this._firstTimeToInitEyePoint||(F["c"].exactEquals(i,this._previousModelView)?t!==this._previousWidth||r!==this._previousHeight?o=!0:F["c"].exactEquals(n,this._previousProjection)&&F["f"].exactEquals(a,this._previousPosition)||(o=!0):o=!0),this._firstTimeToInitEyePoint=!1,o){if(this._autoScaleToScreen){var s=e.getViewport(),u=this.computePixelSizeVector(s,n,i),c=F["g"].fromValues(this._position[0],this._position[1],this._position[2],1),l=F["g"].dot(c,u);l=.48/l;var h=1/l;if(this._autoScaleTransitionWidthRatio>0){var d,f,_;if(this._minimumScale>0){var p=this._minimumScale,g=this._maximumScale<Number.MAX_VALUE?this._minimumScale+(this._maximumScale-this._minimumScale)*this._autoScaleTransitionWidthRatio:this._minimumScale*(1+this._autoScaleTransitionWidthRatio);d=1/(4*(g-p)),f=1-2*d*g,_=p+f*f/(4*d);var m=-f/(2*d);h<m?h=this._minimumScale:h<g&&(h=_+f*h+d*(h*h))}if(this._maximumScale<Number.MAX_VALUE){var v=this._maximumScale,b=this._minimumScale>0?this._maximumScale+(this._minimumScale-this._maximumScale)*this._autoScaleTransitionWidthRatio:this._maximumScale*(1-this._autoScaleTransitionWidthRatio);d=1/(4*(b-v)),f=1-2*d*b,_=v+f*f/(4*d);var S=-f/(2*d);h>S?h=this._maximumScale:h>b&&(h=_+f*h+d*(h*h))}}this.setScale(h)}if(this._autoRotateToScreen){var x=F["d"].create(),T=e.getCurrentModelViewMatrix();F["c"].getRotation(x,T),this.setRotation(F["d"].invert(x,x))}this._previousWidth=t,this._previousHeight=r,F["f"].copy(this._previousPosition,a),F["c"].copy(this._previousProjection,n),F["c"].copy(this._previousModelView,i)}}Ar["a"].prototype.accept.call(this,e)}}(),_setAlignmentValues:function(e){switch(e){case Jl.LEFT_TOP:this._context.textAlign="left",this._textX=0,this._context.textBaseline="top",this._textY=0;break;case Jl.LEFT_CENTER:this._context.textAlign="left",this._textX=0,this._context.textBaseline="middle",this._textY=this._canvas.height/2;break;case Jl.LEFT_BOTTOM:this._context.textAlign="left",this._textX=0,this._context.textBaseline="bottom",this._textY=this._canvas.height;break;case Jl.CENTER_TOP:this._context.textAlign="center",this._textX=this._canvas.width/2,this._context.textBaseline="top",this._textY=0;break;case Jl.CENTER_CENTER:this._context.textAlign="center",this._textX=this._canvas.width/2,this._context.textBaseline="middle",this._textY=this._canvas.height/2;break;case Jl.CENTER_BOTTOM:this._context.textAlign="center",this._textX=this._canvas.width/2,this._context.textBaseline="bottom",this._textY=this._canvas.height;break;case Jl.RIGHT_TOP:this._context.textAlign="right",this._textX=this._canvas.width,this._context.textBaseline="top",this._textY=0;break;case Jl.RIGHT_CENTER:this._context.textAlign="right",this._textX=this._canvas.width,this._context.textBaseline="middle",this._textY=this._canvas.height/2;break;case Jl.RIGHT_BOTTOM:this._context.textAlign="right",this._textX=this._canvas.width,this._context.textBaseline="bottom",this._textY=this._canvas.height;break}},setForcePowerOfTwo:function(e){this._forcePowerOfTwo=e},getForcePowerOfTwo:function(){return this._forcePowerOfTwo},_nextPowerOfTwo:function(e){var t=e;return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,t++,t}}),"osgText","Text"),Wi["a"].registerApplyFunction(Jl.nodeTypeID,Wi["a"].getApplyFunction(Kl["a"].nodeTypeID));var Zl=Jl,Ql={Text:function(e,t){var r=e.getJSON();if(!r.Text)return U.a.reject();var n=jl.Node(e,t);if(t.setColor(r.Color),t.setText(r.Text),t.setAutoRotateToScreen(r.AutoRotateToScreen),t.setPosition(r.Position),t.setCharacterSize(r.CharacterSize),"VERTICAL"===r.Layout)return L["a"].error("Vertical Alignment not supported"),U.a.reject();var i=r.Alignment;return r.Alignment.indexOf("BASE_LINE")>-1&&("LEFT_BASE_LINE"===r.Alignment?i=Zl.LEFT_CENTER:"CENTER_BASE_LINE"===r.Alignment?i=Zl.CENTER_CENTER:"RIGHT_BASE_LINE"===r.Alignment?i=Zl.RIGHT_CENTER:"LEFT_BOTTOM_BASE_LINE"===r.Alignment?i=Zl.LEFT_BOTTOM:"CENTER_BOTTOM_BASE_LINE"===r.Alignment?i=Zl.CENTER_BOTTOM:"RIGHT_BOTTOM_BASE_LINE"===r.Alignment&&(i=Zl.RIGHT_BOTTOM),L["a"].log("Base line alignments not supported, alignment converted")),t.setAlignment(i),t.setLayout(r.Layout),n}},$l=Ql,eh=n("6b10"),th=n("dfa5"),rh=n("3ee6"),nh={};nh.Input=Ul["a"],j["a"].objectMix(nh,Aa["default"]),nh.DatabasePager=Vl["a"],nh.ObjectWrapper.serializers.osg=jl,nh.ObjectWrapper.serializers.osgAnimation=Yl,nh.ObjectWrapper.serializers.osgText=$l,nh.Registry=eh["a"],nh.fileHelper=Si["a"],nh.requestFile=th["a"],j["a"].objectMix(nh,rh["a"]);Wr["a"],n("2b3d"),n("0949");var ih=n("15fd"),ah=n("5530"),oh=["texture","useTexture"],sh=["cullFace","MetalnessWorkFlow","uvtransform"],uh=[.509803950786591,.474509835243225,.474509835243225],ch={url:"",size:0},lh={uvtransform:"uvtransform",NormalMap:"normal",Albedo:"albedo",MetalnessPBR:"metalness",Roughness:"roughness",Opacity:"opacity",SpecularMap:"specular"},hh={type:"meta",diffuse:{color:uh,texture:ch,useTexture:!1},specular:{color:uh,texture:ch,useTexture:!1},gloss:{factor:0,texture:ch,useTexture:!1},albedo:{color:uh,texture:ch,useTexture:!1},cullFace:"",metalness:{factor:0,texture:ch,useTexture:!1},normal:{factor:1,texture:ch},displace:{enable:!1,factor:1,texture:ch},opacity:{enable:!1,factor:1,texture:ch},roughness:{factor:1,texture:ch,useTexture:!1},uv:{scale:1,rotate:0,offsetX:0,offsetY:0},uvProjection:!0,uvMap:"box"};function dh(e){var t={},r=JSON.parse(JSON.stringify(hh));if(!e)return r;for(var n in r){var i=e[n];if("object"==Object(Oe["a"])(i)){var a;null!==i&&void 0!==i&&null!==(a=i.texture)&&void 0!==a&&a.url&&null==(null===i||void 0===i?void 0:i.useTexture)&&(i.useTexture=!0);var o=r[n];for(var s in i)void 0==i[s]&&null==i[s]||(o[s]=i[s]);t[n]=Object(ah["a"])({},o)}else i&&(t[n]=i)}return Object(ah["a"])(Object(ah["a"])({},e),t)}function fh(e){var t={AO:{},cullFace:"",MetalnessWorkFlow:!1};for(var r in lh){var n=lh[r];if(n){var i=e[n]||hh[n]||{},a=i.texture,o=i.useTexture,s=Object(ih["a"])(i,oh);t[r]=a&&o?Object(ah["a"])({texture:a},s):s}}var u=t.cullFace,c=t.MetalnessWorkFlow,l=t.uvtransform,h=Object(ih["a"])(t,sh);return{cullFace:u,MetalnessWorkFlow:c,uvtransform:l,channels:h}}function _h(e){var t=mh({url:"",size:0});if(!e)return t;var r=e;if(t.metalnessWorkFlow="spec"!=r.type,"spec"==r.type?(t.channels.Albedo.color=r.diffuse.color,r.diffuse.useTexture&&(t.channels.Albedo.texture=r.diffuse.texture),t.channels.Roughness.factor=r.gloss.factor,r.gloss.useTexture&&(t.channels.Roughness.texture=r.gloss.texture),t.channels.MetalnessPBR.factor=r.specular.color||[0,0,0],r.specular.useTexture&&(t.channels.MetalnessPBR.texture=r.specular.texture)):(t.channels.Albedo.color=r.albedo.color,r.albedo.useTexture&&(t.channels.Albedo.texture=r.albedo.texture),t.channels.Roughness.factor=r.roughness.factor,"number"!==typeof r.roughness.factor&&(t.channels.Roughness.factor=1),r.roughness.useTexture&&(t.channels.Roughness.texture=r.roughness.texture),t.channels.MetalnessPBR.factor=r.metalness.factor||0,r.metalness.useTexture&&(t.channels.MetalnessPBR.texture=r.metalness.texture)),r.uv&&(t.uvtransform=r.uv),r.cusUv&&(r.cusUv.offsetX&&(t.uvtransform.offsetX+=r.cusUv.offsetX),r.cusUv.offsetY&&(t.uvtransform.offsetY+=r.cusUv.offsetY),r.cusUv.rotate&&(t.uvtransform.rotate+=r.cusUv.rotate),r.cusUv.scale)){var n=t.uvtransform.scale,i=r.cusUv.scale;i=i<0?(1-.9*i)*n:n*(1-.09*i),t.uvtransform.scale=i}return r.normal&&(t.channels.NormalMap.enable=!0,t.channels.NormalMap.texture=r.normal.texture),r.displace&&r.displace.enable&&(t.channels.Displacement.enable=!0,t.channels.Displacement.texture=r.displace.texture,t.channels.Displacement.factor=r.displace.factor),r.opacity&&r.opacity.enable&&(t.channels.Opacity.enable=!0,t.channels.Opacity.factor=r.opacity.factor,t.channels.Opacity.texture=r.opacity.texture),t.uvProjection=r.uvProjection,void 0==t.uvProjection&&(r.uvMap?t.uvProjection="box"==r.uvMap:t.uvProjection=!0),t}function ph(e){var t=e,r=mh(null===t||void 0===t?void 0:t.baseMap);if(!e)return r;if(r.metalnessWorkFlow="spec"!=t.type,t.uv&&(r.uvtransform=t.uv),t.cusUv&&(t.cusUv.offsetX&&(r.uvtransform.offsetX+=t.cusUv.offsetX),t.cusUv.offsetY&&(r.uvtransform.offsetY+=t.cusUv.offsetY),t.cusUv.rotate&&(r.uvtransform.rotate+=t.cusUv.rotate),t.cusUv.scale)){var n=r.uvtransform.scale,i=t.cusUv.scale;i=i<0?(1-.9*i)*n:n*(1-.09*i),r.uvtransform.scale=i}return console.log("uvtransform=>",r.uvtransform),r.channels.Albedo.color=t.baseColor,t.normalMap&&t.normalMap.url&&(r.channels.NormalMap.enable=!0,r.channels.NormalMap.texture=t.normalMap),t.roughMap&&(r.channels.Roughness.texture=t.roughMap),r.channels.Roughness.factor="number"===typeof t.roughFactor?t.roughFactor:1,t.metalMap&&(r.channels.MetalnessPBR.texture=t.metalMap),r.channels.MetalnessPBR.factor="number"===typeof t.metalFactor?t.metalFactor:0,t.normal&&t.normal.url&&(r.channels.NormalMap.enable=!0,r.channels.NormalMap.texture=t.normal),t.displaceMap&&t.displaceMap.url&&(r.channels.Displacement.enable=!0,r.channels.Displacement.texture=t.displaceMap,r.channels.Displacement.factor=t.displaceFactor),"spec"==t.type&&(r.channels.Albedo.color=t.diffuseColor,r.channels.Albedo.texture=t.diffuseMap,r.channels.Roughness.factor="number"===typeof t.glossFactor?t.glossFactor:0,r.channels.Roughness.texture=t.glossMap,r.channels.MetalnessPBR.factor=t.specColor instanceof Array?t.specColor:[0,0,0],r.channels.MetalnessPBR.texture=t.specMap),r.channels.Opacity.factor=1,r.channels.Opacity.enable=!1,void 0!=t.opacFactor&&null!=t.opacFactor&&t.opacFactor<1&&(r.channels.Opacity.enable=!0,r.channels.Opacity.factor=t.opacFactor),t.opacMap&&t.opacMap.url&&(r.channels.Opacity.enable=!0,r.channels.Opacity.texture=t.opacMap),r.uvProjection=t.uvProjection,void 0==r.uvProjection&&(t.uvMap?r.uvProjection="box"==t.uvMap:r.uvProjection=!0),r}var gh={url:"",size:0};function mh(e){return{cullFace:"",metalnessWorkFlow:!0,uvProjection:!0,uvtransform:{offsetX:0,offsetY:0,rotate:0,scale:1},channels:{Albedo:{color:[.509803950786591,.474509835243225,.474509835243225],texture:e},Roughness:{factor:1,invert:!1,texture:Object(ah["a"])({},gh)},Emissive:{color:[0,0,0],factor:1,enable:!1},NormalMap:{enable:!0,factor:1,flipY:!1,texture:Object(ah["a"])({},gh)},BumpMap:{enable:!1,factor:1,texture:Object(ah["a"])({},gh)},Opacity:{enable:!1,type:"ALPHA_BLEND",factor:1,invert:!1,sampleChannel:"a",refractionTint:[1,1,1],refractUseDiffuse:!1,refractUseShininessMap:!1,IOR:1,roughnessFactor:0,texture:Object(ah["a"])({},gh)},AO:{enable:!1,occludeSpecular:!1,factor:0,texture:Object(ah["a"])({},gh)},MetalnessPBR:{factor:0,texture:Object(ah["a"])({},gh)},SpecularF0:.5,ClearCoat:{enable:!1,thickness:5,intensity:1,color:[1,1,1],reflectivity:0,roughness:{factor:.04},normalmap:{factor:1,flipY:!1}},Displacement:{enable:!1,factor:0,texture:Object(ah["a"])({},gh)},CavityMap:{enable:!1,factor:0}}}}function vh(){return{id:"1",name:"工作室",cusNum:"",thumbnail:{url:"",size:0},createTime:null,hdr:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/photo_studio_01_8k.hdr",size:100350789},config:{textures:[{images:[{width:256,file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/thumbnail_256.jpg",height:128,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/thumbnail_256.jpg",size:"15905"}}],encoding:"srgb",type:"thumbnail",format:"panorama"},{images:[{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.0_luv.bin.gz",sizeUncompressed:6291456,sizeCompressed:1779853,height:512,width:512,samples:2048,blur:0,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.0_luv.bin.gz",size:"1779853"}},{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.02_luv.bin.gz",sizeUncompressed:6291456,sizeCompressed:1200968,height:512,width:512,samples:2048,blur:.02,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.02_luv.bin.gz",size:"1200968"}},{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_256.0_0.055_luv.bin.gz",sizeUncompressed:1572864,sizeCompressed:317622,height:256,width:256,samples:2048,blur:.055,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_256.0_0.055_luv.bin.gz",size:"317622"}},{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_128.0_0.1_luv.bin.gz",sizeUncompressed:393216,sizeCompressed:97956,height:128,width:128,samples:2048,blur:.1,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_128.0_0.1_luv.bin.gz",size:"97956"}},{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_64.0_0.15_luv.bin.gz",sizeUncompressed:98304,sizeCompressed:29064,height:64,width:64,samples:2048,blur:.15,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_64.0_0.15_luv.bin.gz",size:"29064"}}],encoding:"luv",type:"background",format:"cubemap"},{images:[{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.0_rgbm.bin.gz",sizeUncompressed:6291456,sizeCompressed:2977192,height:512,width:512,samples:2048,blur:0,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.0_rgbm.bin.gz",size:"2977192"}},{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.02_rgbm.bin.gz",sizeUncompressed:6291456,sizeCompressed:1858076,height:512,width:512,samples:2048,blur:.02,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.02_rgbm.bin.gz",size:"1858076"}},{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_256.0_0.055_rgbm.bin.gz",sizeUncompressed:1572864,sizeCompressed:487212,height:256,width:256,samples:2048,blur:.055,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_256.0_0.055_rgbm.bin.gz",size:"487212"}},{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_128.0_0.1_rgbm.bin.gz",sizeUncompressed:393216,sizeCompressed:149136,height:128,width:128,samples:2048,blur:.1,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_128.0_0.1_rgbm.bin.gz",size:"149136"}},{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_64.0_0.15_rgbm.bin.gz",sizeUncompressed:98304,sizeCompressed:46566,height:64,width:64,samples:2048,blur:.15,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_64.0_0.15_rgbm.bin.gz",size:"46566"}}],encoding:"rgbm",type:"background",format:"cubemap"},{images:[{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.0_rgbe.bin.gz",sizeUncompressed:6291456,sizeCompressed:3043958,height:512,width:512,samples:2048,blur:0,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.0_rgbe.bin.gz",size:"3043958"}},{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.02_rgbe.bin.gz",sizeUncompressed:6291456,sizeCompressed:1766005,height:512,width:512,samples:2048,blur:.02,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.02_rgbe.bin.gz",size:"1766005"}},{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_256.0_0.055_rgbe.bin.gz",sizeUncompressed:1572864,sizeCompressed:473185,height:256,width:256,samples:2048,blur:.055,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_256.0_0.055_rgbe.bin.gz",size:"473185"}},{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_128.0_0.1_rgbe.bin.gz",sizeUncompressed:393216,sizeCompressed:149500,height:128,width:128,samples:2048,blur:.1,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_128.0_0.1_rgbe.bin.gz",size:"149500"}},{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_64.0_0.15_rgbe.bin.gz",sizeUncompressed:98304,sizeCompressed:49221,height:64,width:64,samples:2048,blur:.15,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_64.0_0.15_rgbe.bin.gz",size:"49221"}}],encoding:"rgbe",type:"background",format:"cubemap"},{images:[{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.0_float.bin.gz",sizeUncompressed:18874368,sizeCompressed:16116615,height:512,width:512,samples:2048,blur:0,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.0_float.bin.gz",size:"16116615"}},{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.02_float.bin.gz",sizeUncompressed:18874368,sizeCompressed:16067477,height:512,width:512,samples:2048,blur:.02,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_512.0_0.02_float.bin.gz",size:"16067477"}},{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_256.0_0.055_float.bin.gz",sizeUncompressed:4718592,sizeCompressed:4041881,height:256,width:256,samples:2048,blur:.055,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_256.0_0.055_float.bin.gz",size:"4041881"}},{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_128.0_0.1_float.bin.gz",sizeUncompressed:1179648,sizeCompressed:1020352,height:128,width:128,samples:2048,blur:.1,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_128.0_0.1_float.bin.gz",size:"1020352"}},{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_64.0_0.15_float.bin.gz",sizeUncompressed:294912,sizeCompressed:258568,height:64,width:64,samples:2048,blur:.15,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/background_cubemap_64.0_0.15_float.bin.gz",size:"258568"}}],encoding:"float",type:"background",format:"cubemap"},{images:[{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_panorama_ue4_1024_luv.bin.gz",sizeUncompressed:4194304,samples:2048,height:1024,width:1024,sizeCompressed:673838,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_panorama_ue4_1024_luv.bin.gz",size:"673838"}}],limitSize:32,encoding:"luv",type:"specular_ue4",format:"panorama"},{images:[{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_panorama_ue4_1024_rgbm.bin.gz",sizeUncompressed:4194304,samples:2048,height:1024,width:1024,sizeCompressed:1095123,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_panorama_ue4_1024_rgbm.bin.gz",size:"1095123"}}],limitSize:32,encoding:"rgbm",type:"specular_ue4",format:"panorama"},{images:[{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_panorama_ue4_1024_rgbe.bin.gz",sizeUncompressed:4194304,samples:2048,height:1024,width:1024,sizeCompressed:1130918,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_panorama_ue4_1024_rgbe.bin.gz",size:"1130918"}}],limitSize:32,encoding:"rgbe",type:"specular_ue4",format:"panorama"},{images:[{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_panorama_ue4_1024_float.bin.gz",sizeUncompressed:12582912,samples:2048,height:1024,width:1024,sizeCompressed:7099449,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_panorama_ue4_1024_float.bin.gz",size:"7099449"}}],limitSize:32,encoding:"float",type:"specular_ue4",format:"panorama"},{images:[{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_cubemap_ue4_256_luv.bin.gz",sizeUncompressed:2097144,samples:2048,height:256,width:256,sizeCompressed:635016,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_cubemap_ue4_256_luv.bin.gz",size:"635016"}}],limitSize:8,encoding:"luv",type:"specular_ue4",format:"cubemap"},{images:[{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_cubemap_ue4_256_rgbm.bin.gz",sizeUncompressed:2097144,samples:2048,height:256,width:256,sizeCompressed:1055995,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_cubemap_ue4_256_rgbm.bin.gz",size:"1055995"}}],limitSize:8,encoding:"rgbm",type:"specular_ue4",format:"cubemap"},{images:[{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_cubemap_ue4_256_rgbe.bin.gz",sizeUncompressed:2097144,samples:2048,height:256,width:256,sizeCompressed:1109686,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_cubemap_ue4_256_rgbe.bin.gz",size:"1109686"}}],limitSize:8,encoding:"rgbe",type:"specular_ue4",format:"cubemap"},{images:[{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_cubemap_ue4_256_float.bin.gz",sizeUncompressed:6291432,samples:2048,height:256,width:256,sizeCompressed:5417781,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/specular_cubemap_ue4_256_float.bin.gz",size:"5417781"}}],limitSize:8,encoding:"float",type:"specular_ue4",format:"cubemap"},{images:[{file:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/brdf_ue4.bin.gz",sizeUncompressed:65536,samples:2048,height:128,width:128,sizeCompressed:59665,oss:{url:"https://3dqueen-test.oss-cn-chengdu.aliyuncs.com/env3d/photo_studio/brdf_ue4.bin.gz",size:"59665"}}],encoding:"rg16",type:"brdf_ue4",format:"lut"}],writeByChannel:!0,lights:[{direction:[.0331058,-.82285,.567294],lum_ratio:.0797674,color:[43.9513,47.0473,49.9592],luminosity:508.628,sum:.74215,area:{y:.192383,x:.490723,w:.0166016,h:.0878906},error:0,variance:71996e-8}],diffuseSPH:[2.52177,2.6475,2.71793,-.970495,-1.03103,-1.07638,-.517793,-.556958,-.594671,-.335999,-.36003,-.390184,.14915,.157474,.170339,.305085,.325537,.345122,-786492e-9,-.00349557,-.00655254,-955614e-9,-445611e-9,.00699492,-.00675775,-.0107802,-.0170637,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-.0128212,-.0135017,-.0145362,.0321759,.0344156,.0357341,.010143,.0108799,.0117446,.0164007,.0178076,.0192644,.0183598,.0198073,.0203541,.00825731,.00872035,.0094819,.0411866,.044173,.0463374,.0160459,.0171311,.0176568,-.0096879,-.0103498,-.00986728]},options:{rotation:202,exposure:1.2},toneMap:{method:1,exposure:1,brightness:.1,contrast:.06,saturation:1},background:null,userData:{}}}function bh(){return{version:"1.0",mats:[{id:"1",thumbnail:null,name:"基础色",cusNum:"xx",normalMap:null,displaceMap:null,displaceFactor:0,baseMap:null,baseColor:[0,1,0],roughMap:null,roughFactor:.5,metalMap:null,metalFactor:0,diffuseMap:null,diffuseColor:[0,0,0],glossMap:null,glossFactor:0,specMap:null,specColor:null,techMaterial:null,images:[],opacMap:null,opacFactor:1,type:"meta",uv:null,cusUv:null,userData:{}}],geoms:[{id:"1",name:"cube",thumbnail:{url:"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/QueenTree/image/jpeg/1654055769653AUoutq_mf6O4k.image/jpeg",size:1},osgjs:{url:"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/upload/osgjs/1654056232504W6qHX6_1654056227380.glb.osgjs",size:2},file:{url:"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/QueenTree/fbx/1654075876597asa7I2_box.fbx",size:26284},glb:{url:"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/QueenTree/glb/1654075876532OlNLjF_1654075872416.glb",size:4240},shadow:{url:"",size:0},boundingBox:{max:{x:100,y:100.00001629206662,z:100.00001629206662},min:{x:-100,y:-100.00001629206662,z:-100.00001629206662}}}],env3ds:[vh()],products:[{id:"1",geomId:"1",name:"cube",cusNum:"bh001",type:"shoe",thumbnail:{url:"",size:0},components:[],userData:{}}],scenes:[{id:"001",name:"scene01",thumbnail:{url:"",size:0},envId:"1",lights:[],products:[{id:"1",prodId:"1",transform:{pos:[0,0,0],scale:[1,1,1],rotation:[0,0,0,1]},visible:!0,userData:{}}],userData:null}],userData:{}}}var Sh=function(){function e(t){Object(v["a"])(this,e),this._app=t}return Object(S["a"])(e,[{key:"app",get:function(){return this._app.getAppInstance()}},{key:"setDefaultEnv3d",value:function(){this.setEnv3d(Ca.config)}},{key:"setEnv3d",value:function(e){this.app&&(this.app.setEnvironmentModel(e),this.app.redraw())}},{key:"setRotation",value:function(e){this.app&&(this.app.setEnvironmentRotation(e*Math.PI/180),this.app.redraw())}},{key:"setExposure",value:function(e){this.app&&(this.app.setEnvironmentExposure(e),this.app.redraw())}},{key:"setEnv3dOption",value:function(e,t){this.app&&(this.app.setEnvironmentRotation(e*Math.PI/180),this.app.setEnvironmentExposure(t),this.app.redraw())}},{key:"setEnvToneMap",value:function(e){this.app&&(this.app.setToneMappingExposure(void 0==e.exposure?1:e.exposure),this.app.setToneMappingBrightness(void 0==e.brightness?0:e.brightness),this.app.setToneMappingContrast(void 0==e.contrast?0:e.contrast),this.app.setToneMappingSaturation(void 0==e.saturation?1:e.saturation),this.app.setToneMappingMethod(void 0==e.method?1:e.method),this.app.redraw())}}]),e}(),xh=function(){function e(t,r){Object(v["a"])(this,e),this._touchTime=0,this._touchPos={},this._target=null,this._rect=null,this._picking=!1,this.enable=!0,this._app=t,this.initEvent(),this.options=r}return Object(S["a"])(e,[{key:"initEvent",value:function(){var e=this,t=!Object(Oa["a"])(),r={start:t?"touchstart":"mousedown",end:t?"touchend":"mouseup"};this._app.setOutLine(null,{durationHighlight:300}),window.addEventListener("contextmenu",(function(e){e.preventDefault()})),this._app._canvas.addEventListener(r.start,(function(t){t.preventDefault(),e.enable&&(e._touchTime=Date.now(),window.addEventListener(r.end,n,!1),e._touchPos=i(t),e.setCanvasRect(),document.activeElement&&"input"===document.activeElement.tagName.toLowerCase()&&document.activeElement.blur())}));var n=function t(n){if(window.removeEventListener(r.end,t,!1),e.enable){var a=i(n);Date.now()-e._touchTime<=300&&Math.abs(a.clientX-e._touchPos.clientX)<2&&Math.abs(a.clientY-e._touchPos.clientY)<2&&e.pick(!0),e._target&&setTimeout((function(){e._target=null}),1e3)}};function i(e){return t?e.changedTouches[0]:e}}},{key:"setTouchPos",value:function(e){this._touchPos=e}},{key:"getCanvsPos",value:function(){var e=this._rect,t=this._touchPos;return[t.clientX-e.left,t.clientY-e.top]}},{key:"setCanvasRect",value:function(){this._rect=this._app._canvas.getBoundingClientRect()}},{key:"getPickTarget",value:function(){return this._target}},{key:"clearPickTarget",value:function(){this._target=null}},{key:"pick",value:function(){var e,t,r=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=null===(e=this.options)||void 0===e?void 0:e.clickedOutline;if(!this._picking){this._picking=!0;var i=this;(t=this._app).pick.apply(t,Object(Bo["a"])(this.getCanvsPos()).concat([function(e){i._picking=!1,i._target!==e&&(e&&n&&i._app.setOutLine(e.getOrCreateStateSet()),i._target=e,i._app.emit("tap:click",e,r))}]))}}}]),e}();var Th=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(){var e;return Object(v["a"])(this,r),e=t.apply(this,arguments),e._app=null,e.canvas=null,e.env3d=new Sh(Object(y["a"])(e)),e}return Object(S["a"])(r,[{key:"getAppInstance",value:function(){return this._app}},{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{clickedOutline:!0,enablePicker:!0};if(this._app&&this._app.destory(),this.canvas=e,this._app=new kl(e),this.picker=new xh(this._app,t),this._app.start(),this.getDefaultEnvHandle){var r=this.getDefaultEnvHandle();this.env3d.setEnv3d(r)}else this.env3d.setDefaultEnv3d();this.emit("app:initialized")}},{key:"setTransparntBg",value:function(){var e=this.getAppInstance();null===e||void 0===e||e.setBackgroundMode("none")}},{key:"destory",value:function(){this._app&&this._app.destory(!0),this._app=null,this.canvas=null,this.emit("app:destoryed")}},{key:"afterInit",value:function(e){this._app?e():this.once("app:initialized",e)}},{key:"redraw",value:function(){var e;null===(e=this._app)||void 0===e||e.redraw()}},{key:"setOutLine",value:function(e){var t;null===(t=this._app)||void 0===t||t.setOutLine(e.getOrCreateStateSet())}},{key:"showGrid",value:function(e){var t,r;null===(t=this._app)||void 0===t||null===(r=t.getFeaturesManager())||void 0===r||r.enableGrid(e),this.redraw()}},{key:"showGizmo",value:function(e){var t,r;null===(t=this._app)||void 0===t||null===(r=t.getFeaturesManager())||void 0===r||r.enableGizmo(e)}},{key:"gizmoAttach",value:function(e){var t,r,n;return null===(t=this._app)||void 0===t||null===(r=t.getFeaturesManager())||void 0===r||null===(n=r.getNodeGizmo())||void 0===n?void 0:n.attachToNode(e)}},{key:"updateController",value:function(){var e,t,r=null===(e=this._app)||void 0===e?void 0:e._viewer;r&&(r.setupManipulator(null===(t=this._app)||void 0===t?void 0:t._switchManipulator),r.getManipulator().computeHomePosition())}},{key:"setControllerZoom",value:function(e,t){var r,n=null===(r=this._app)||void 0===r?void 0:r._viewer;if(n){n.getManipulator().computeHomePosition();var i=n.getManipulator().getCurrentManipulator(),a=i.getHomeBoundingSphere(),o=e||1.5,s=t||6;i.setLimitZoomIn(a.radius()/o),i.setLimitZoomOut(a.radius()*s)}}},{key:"setControllerTarget",value:function(e){var t,r=null===(t=this._app)||void 0===t?void 0:t._viewer;if(r){var n=r.getManipulator().getCurrentManipulator();n.setTarget(e)}}},{key:"getControllerTarget",value:function(e){var t,r=null===(t=this._app)||void 0===t?void 0:t._viewer;if(r){var n=r.getManipulator().getCurrentManipulator();n.getTarget(e)}}},{key:"addChild",value:function(e){var t,r;null===(t=this._app)||void 0===t||null===(r=t.scene)||void 0===r||r.addChild(e),this.redraw()}},{key:"removeChild",value:function(e){var t,r;null===(t=this._app)||void 0===t||null===(r=t.scene)||void 0===r||r.removeChild(e),this.redraw()}}]),r}(Bl);var yh=function(){function e(t,r,n){Object(v["a"])(this,e),this.id="",this.geom=new Be["a"],this._InverseModelMatrix=w["default"].Uniform.createMatrix4("uInverseScopeModelMatrix"),this._tempMatrix=F["c"].create(),this._version=n,this.id=t,this.geomVisitor="3.0"==n?new Ma(null,!0):new Ra(null,!0),this.geomVisitor.apply(r),this.geom.addChild(r),this.geomVisitor.geoms.forEach((function(e){var t=e.geom,r=t.getUserData()||{};r.name=e.node,r.index=e.index,t.setUserData(r)})),this.geom.setName("meshobjRoot"),this.geom.editMask=Xn.NodeGizmo.PICK_GIZMO;for(var i=r.getUpdateCallbackList(),a=0;a<i.length;a++)r.removeUpdateCallback(i[a]);r.getOrCreateStateSet().addUniform(this._InverseModelMatrix),r.addUpdateCallback(this)}return Object(S["a"])(e,[{key:"update",value:function(){F["c"].invert(this._tempMatrix,this.geom.getMatrix()),this._InverseModelMatrix.setMatrix4(this._tempMatrix)}},{key:"getGeoms",value:function(){return this.geomVisitor.geoms.map((function(e){return e}))}},{key:"getGeomByName",value:function(e){var t;return null===(t=this.geomVisitor.geoms.find((function(t){return t.node===e})))||void 0===t?void 0:t.geom}},{key:"setGeomMat",value:function(e,t){var r=this.getGeomByName(e);if(r)return Ba.updateGeomMaterial(r,t)}},{key:"setGeomVisible",value:function(e,t){var r=this.getGeomByName(e);r&&r.setNodeMask(t?-1:0)}},{key:"transform",value:function(){var e=F["c"].create();F["c"].translate(e,e,[10,0,0]),this.geom.setMatrix(e)}}]),e}(),Ch=function(){function e(){Object(v["a"])(this,e)}return Object(S["a"])(e,[{key:"load",value:function(){var e=Object(l["a"])(regeneratorRuntime.mark((function e(t){var r,n,i,a=arguments;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return r=!(a.length>1&&void 0!==a[1])||a[1],n=a.length>2&&void 0!==a[2]?a[2]:"",e.next=4,Na.loadModel(t.url,{uvproject:r,version:n});case 4:return i=e.sent,e.abrupt("return",new yh(t.id,i,n));case 6:case"end":return e.stop()}}),e)})));function t(t){return e.apply(this,arguments)}return t}()}]),e}(),Ah=function(){function e(){Object(v["a"])(this,e)}return Object(S["a"])(e,[{key:"load",value:function(){var e=Object(l["a"])(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.abrupt("return",void 0);case 1:case"end":return e.stop()}}),e)})));function t(t){return e.apply(this,arguments)}return t}()}]),e}(),Eh=function(){function e(t){Object(v["a"])(this,e),this.resMap=new Map,this.loader=t}return Object(S["a"])(e,[{key:"load",value:function(){var e=Object(l["a"])(regeneratorRuntime.mark((function e(t,r){var n;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:if(!this.resMap.has(t)){e.next=4;break}return e.abrupt("return",this.resMap.get(t));case 4:return e.next=6,this.loader.load(r);case 6:return n=e.sent,n&&this.resMap.set(t,n),e.abrupt("return",n);case 9:case"end":return e.stop()}}),e,this)})));function t(t,r){return e.apply(this,arguments)}return t}()},{key:"set",value:function(e,t){return this.resMap.set(e,t)}},{key:"get",value:function(e){return this.resMap.get(e)}},{key:"delete",value:function(e){this.resMap.delete(e)}},{key:"clear",value:function(){this.resMap.clear()}}]),e}(),Rh=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(e){var n;Object(v["a"])(this,r),n=t.call(this);var i=e.width||300,a=e.height||400,o=e.position||[0,0,0],s=Ci.getInstance().getOrCreateTexture(e.file,{minFilter:w["default"].Texture.LINEAR_MIPMAP_LINEAR,magFilter:w["default"].Texture.LINEAR,internalFormat:w["default"].Texture.RGB,wrapS:w["default"].Texture.CLAMP_TO_EDGE,wrapT:w["default"].Texture.CLAMP_TO_EDGE,anisotropy:16});n._texture=s.texture,e.onLoad&&s.promise&&s.promise.then((function(){e.onLoad()})),n.setNodeMask(Tr.NO_PICK_NO_SHADOW),n._geometry=w["default"].createTexturedQuadGeometry(-i/2+o[0],-a/2+o[1],o[2],i,0,0,0,a,0),n._geometry.setBound(new w["default"].BoundingBox),n._geometry.setName("Ground - Geometry"),n._geometry.setNodeMask(0),n.addChild(n._geometry);var u=new ba;u._cullFace=w["default"].CullFace.BACK,u.setUnLit(!0),u.setHasOpacityMap(!0),u.enableInvertAlpha(!0);var c=n._geometry.getOrCreateStateSet();c.setAttributeAndModes(u);var l=new w["default"].Material;return l.setName("ground_shadow"),c.setAttributeAndModes(l),c.setName("Ground"),c.setShaderGeneratorName("PBR"),c.setRenderBinDetails(br.TRANSPARENT,"DepthSortedBin"),c.setAttribute(new w["default"].CullFace(w["default"].CullFace.BACK)),c.addUniform(w["default"].Uniform.createInt(Ba.OPACITY_TEXTURE_UNIT,"opacityMap")),c.setTextureAttributeAndModes(Ba.OPACITY_TEXTURE_UNIT,n._texture),n._visiable=!1,n.setVisiable(!0),n}return Object(S["a"])(r,[{key:"setVisiable",value:function(e){this._visiable=!!e,this._geometry.setNodeMask(e?-1:0)}},{key:"isVisiable",value:function(){return this._visiable}}]),r}(Be["a"]),Mh={MatrixTransform:Be["a"],Node:Ar["a"],osg:w["default"],osgUtil:Xn,GroundShadow:Rh,Util:o,createMaterial:dh,createRenderMaterial:fh,createDefaultScenePackage:bh,UrlConfig:Pa,DefaultUrlResolver:Ia},wh=Mh.MatrixTransform,Nh=Mh.osgUtil,Oh=Mh.osg,Ih=Mh.GroundShadow,Ph=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(e,n){var i,a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";Object(v["a"])(this,r),i=t.call(this),i.mesh=e,i.node=new wh,i.node.editMask=Nh.NodeGizmo.PICK_GIZMO;var s={sceneProdId:n};i.node.setUserData(s),a&&e.geom.removeParents(),i.node.addChild(e.geom);var u=Object(y["a"])(i);if(o)if(-1!=o.indexOf("tree-shadow-")){var c=1.5,l=o.split("/");l=l[l.length-1];var h=l.split("-");if(h.length>4){var d=parseFloat(h[2]);d>1.5&&(c=d)}var f=i.node.getBoundingBox(),_=f.yMax()-f.yMin(),p=f.xMax()-f.xMin(),g=Math.max(p,_)*c,m=new Ih({width:g,height:g,position:[f.xMin()+.5*p,f.yMin()+.5*_,f.zMin()],file:o,onLoad:function(){u.emit("onload")}});m._geometry.setBound(new Oh.BoundingBox),i.nodeShadow=m,i.node.addChild(m)}else{var b=new Ih({width:300,height:400,position:[0,50,0],file:o,onLoad:function(){u.emit("onload")}});b._geometry.setBound(new Oh.BoundingBox),i.nodeShadow=b,i.node.addChild(b)}return i}return Object(S["a"])(r,[{key:"updateTransform",value:function(e){var t,r,n,i=(t=Oh.vec3).fromValues.apply(t,Object(Bo["a"])(e.pos)),a=(r=Oh.vec3).fromValues.apply(r,Object(Bo["a"])(e.scale)),o=(n=Oh.quat).fromValues.apply(n,Object(Bo["a"])(e.rotation)),s=Oh.mat4.fromRotationTranslationScale(Oh.mat4.create(),o,i,a);this.node.setMatrix(s)}}]),r}(R),Dh={diffuseSPH:[2.52177000045776,2.64750003814697,2.71793007850647,-.970494985580444,-1.03103005886078,-1.07638001441956,-.517792999744415,-.556958019733429,-.594671010971069,-.335999011993408,-.360029995441437,-.390183985233307,.149149999022484,.157473996281624,.170339003205299,.305085003376007,.325536996126175,.345122009515762,-.000786492018960416,-.00349557003937662,-.0065525402314961,-.00095561402849853,-.000445610989117995,.00699491985142231,-.00675775017589331,-.0107802003622055,-.0170636996626854,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-.0128212003037333,-.013501700013876,-.0145362000912428,.0321758985519409,.0344155989587307,.0357340984046459,.0101429997012019,.0108799003064632,.011744599789381,.0164007004350424,.017807599157095,.0192644000053406,.0183598008006811,.0198072995990515,.0203540995717049,.00825730990618467,.00872035045176744,.00948190037161112,.0411866009235382,.0441729985177517,.0463373996317387,.0160459000617266,.0171310994774103,.0176567994058132,-.00968789961189032,-.0103497998788953,-.00986727979034185],lights:[{area:{h:.0878906026482582,w:.016601599752903,x:.490723013877869,y:.192383006215096},color:[43.951301574707,47.0472984313965,49.9592018127441],direction:[.0331058017909527,-.822849988937378,.567294001579285],lum_ratio:.0797673985362053,luminosity:508.627990722656,sum:.742150008678436,variance:.000719960022252053}],textures:[{encoding:"srgb",format:"panorama",images:[{file:"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/thumbnail_256.jpg",height:128,width:256}],type:"thumbnail"},{encoding:"luv",format:"cubemap",images:[{file:"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_512.0_0.0_luv.bin.gz",height:512,samples:2048,sizeCompressed:1779853,sizeUncompressed:6291456,width:512},{blur:.019999999552965164,file:"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_512.0_0.02_luv.bin.gz",height:512,samples:2048,sizeCompressed:1200968,sizeUncompressed:6291456,width:512},{blur:.054999999701976776,file:"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_256.0_0.055_luv.bin.gz",height:256,samples:2048,sizeCompressed:317622,sizeUncompressed:1572864,width:256},{blur:.10000000149011612,file:"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_128.0_0.1_luv.bin.gz",height:128,samples:2048,sizeCompressed:97956,sizeUncompressed:393216,width:128},{blur:.15000000596046448,file:"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_64.0_0.15_luv.bin.gz",height:64,samples:2048,sizeCompressed:29064,sizeUncompressed:98304,width:64}],type:"background"},{encoding:"rgbm",format:"cubemap",images:[{file:"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_512.0_0.0_rgbm.bin.gz",height:512,samples:2048,sizeCompressed:2977192,sizeUncompressed:6291456,width:512},{blur:.019999999552965164,file:"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_512.0_0.02_rgbm.bin.gz",height:512,samples:2048,sizeCompressed:1858076,sizeUncompressed:6291456,width:512},{blur:.054999999701976776,file:"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_256.0_0.055_rgbm.bin.gz",height:256,samples:2048,sizeCompressed:487212,sizeUncompressed:1572864,width:256},{blur:.10000000149011612,file:"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_128.0_0.1_rgbm.bin.gz",height:128,samples:2048,sizeCompressed:149136,sizeUncompressed:393216,width:128},{blur:.15000000596046448,file:"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_64.0_0.15_rgbm.bin.gz",height:64,samples:2048,sizeCompressed:46566,sizeUncompressed:98304,width:64}],type:"background"},{encoding:"rgbe",format:"cubemap",images:[{file:"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_512.0_0.0_rgbe.bin.gz",height:512,samples:2048,sizeCompressed:3043958,sizeUncompressed:6291456,width:512},{blur:.019999999552965164,file:"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_512.0_0.02_rgbe.bin.gz",height:512,samples:2048,sizeCompressed:1766005,sizeUncompressed:6291456,width:512},{blur:.054999999701976776,file:"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_256.0_0.055_rgbe.bin.gz",height:256,samples:2048,sizeCompressed:473185,sizeUncompressed:1572864,width:256},{blur:.10000000149011612,file:"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_128.0_0.1_rgbe.bin.gz",height:128,samples:2048,sizeCompressed:149500,sizeUncompressed:393216,width:128},{blur:.15000000596046448,file:"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_64.0_0.15_rgbe.bin.gz",height:64,samples:2048,sizeCompressed:49221,sizeUncompressed:98304,width:64}],type:"background"},{encoding:"float",format:"cubemap",images:[{file:"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_512.0_0.0_float.bin.gz",height:512,samples:2048,sizeCompressed:16116615,sizeUncompressed:18874368,width:512},{blur:.019999999552965164,file:"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_512.0_0.02_float.bin.gz",height:512,samples:2048,sizeCompressed:16067477,sizeUncompressed:18874368,width:512},{blur:.054999999701976776,file:"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_256.0_0.055_float.bin.gz",height:256,samples:2048,sizeCompressed:4041881,sizeUncompressed:4718592,width:256},{blur:.10000000149011612,file:"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_128.0_0.1_float.bin.gz",height:128,samples:2048,sizeCompressed:1020352,sizeUncompressed:1179648,width:128},{blur:.15000000596046448,file:"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/background_cubemap_64.0_0.15_float.bin.gz",height:64,samples:2048,sizeCompressed:258568,sizeUncompressed:294912,width:64}],type:"background"},{encoding:"luv",format:"panorama",images:[{file:"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/specular_panorama_ue4_1024_luv.bin.gz",height:1024,samples:2048,sizeCompressed:673838,sizeUncompressed:4194304,width:1024}],limitSize:32,type:"specular_ue4"},{encoding:"rgbm",format:"panorama",images:[{file:"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/specular_panorama_ue4_1024_rgbm.bin.gz",height:1024,samples:2048,sizeCompressed:1095123,sizeUncompressed:4194304,width:1024}],limitSize:32,type:"specular_ue4"},{encoding:"rgbe",format:"panorama",images:[{file:"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/specular_panorama_ue4_1024_rgbe.bin.gz",height:1024,samples:2048,sizeCompressed:1130918,sizeUncompressed:4194304,width:1024}],limitSize:32,type:"specular_ue4"},{encoding:"float",format:"panorama",images:[{file:"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/specular_panorama_ue4_1024_float.bin.gz",height:1024,samples:2048,sizeCompressed:7099449,sizeUncompressed:12582912,width:1024}],limitSize:32,type:"specular_ue4"},{encoding:"luv",format:"cubemap",images:[{file:"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/specular_cubemap_ue4_256_luv.bin.gz",height:256,samples:2048,sizeCompressed:635016,sizeUncompressed:2097144,width:256}],limitSize:8,type:"specular_ue4"},{encoding:"rgbm",format:"cubemap",images:[{file:"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/specular_cubemap_ue4_256_rgbm.bin.gz",height:256,samples:2048,sizeCompressed:1055995,sizeUncompressed:2097144,width:256}],limitSize:8,type:"specular_ue4"},{encoding:"rgbe",format:"cubemap",images:[{file:"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/specular_cubemap_ue4_256_rgbe.bin.gz",height:256,samples:2048,sizeCompressed:1109686,sizeUncompressed:2097144,width:256}],limitSize:8,type:"specular_ue4"},{encoding:"float",format:"cubemap",images:[{file:"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/specular_cubemap_ue4_256_float.bin.gz",height:256,samples:2048,sizeCompressed:5417781,sizeUncompressed:6291432,width:256}],limitSize:8,type:"specular_ue4"},{encoding:"rg16",format:"lut",images:[{file:"//sku3d-test.obs.cn-east-3.myhuaweicloud.com/assets/env3d/db/6194da0119af54f894c53644/brdf_ue4.bin.gz",height:128,samples:2048,sizeCompressed:59665,sizeUncompressed:65536,width:128}],type:"brdf_ue4"}],writeByChannel:!0};function Lh(e,t,r){var n,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(Fh(e,t,r.envId),i){var a=e.getAppInstance();null===a||void 0===a||a.setBackgroundMode("none")}else kh(e,r.background);Bh(e,null===(n=r.lights)||void 0===n?void 0:n.list)}function Fh(e,t,r){if(r){var n=t.env3ds.find((function(e){return e.id==r}));n&&(e.env3d.setEnv3d(n.config||Dh),e.env3d.setEnv3dOption(n.options.rotation,n.options.exposure),e.env3d.setEnvToneMap(n.toneMap))}else e.env3d.setEnv3d(Dh)}function kh(e,t){var r=t,n=r.type,i=r.color,a=r.image?r.image.url:void 0,o=e.getAppInstance();1==n?(o.setBackgroundMode("color"),o.setBackgroundColor(i),o.redraw()):2==n?(o.setBackgroundFixed(a),o.setBackgroundMode("fixed"),o.redraw()):3==n&&(o.setBackgroundMode("environment"),o.redraw())}function Bh(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=e.getAppInstance();t&&t.length?(n.setLightingEnable(!0),n.setThreeLightsJson(Object(Uo["cloneDeep"])(t),r),r&&Object.assign(t,n._features.lighting.getModel().getJSON().lights)):n.setLightingEnable(!1)}function Uh(e,t,r){return Vh.apply(this,arguments)}function Vh(){return Vh=Object(l["a"])(regeneratorRuntime.mark((function e(t,r,n){var i,a,o,s,u,c;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:i=window.noForceHttps,window.noForceHttps=!0,a=t,o=a.products||[],s=[],r.products.forEach((function(e){if(0!=e.visible){var t=o.find((function(t){return t.id==e.prodId})),r=a.geoms.find((function(e){return e.id==(null===t||void 0===t?void 0:t.geomId)})),n=s.find((function(e){return e.id==(null===r||void 0===r?void 0:r.id)}));n||s.push(r)}})),u=s.length;case 7:if(!u--){e.next=14;break}return e.next=10,n.load(s[u].osgjs.url,s[u]);case 10:c=e.sent,c&&c.geom.removeParents(),e.next=7;break;case 14:window.noForceHttps=i;case 15:case"end":return e.stop()}}),e)}))),Vh.apply(this,arguments)}function Gh(e,t){return zh.apply(this,arguments)}function zh(){return zh=Object(l["a"])(regeneratorRuntime.mark((function e(t,r){var n,i;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return n=window.noForceHttps,window.noForceHttps=!0,e.next=4,r.load(t.geom.osgjs.url,t.geom);case 4:if(i=e.sent,!i){e.next=8;break}return i.geom.removeParents(),e.abrupt("return",i);case 8:window.noForceHttps=n;case 9:case"end":return e.stop()}}),e)}))),zh.apply(this,arguments)}var jh=n("cef7"),Hh=n.n(jh),Wh=n("b331"),Xh=n.n(Wh),qh=(n("abaf"),n("d464"),n("6cdf")),Yh=n.n(qh),Kh=n("9527"),Jh=n.n(Kh),Zh=(n("dc8a"),function(){function e(){Object(v["a"])(this,e),this._inputFilter=Yh.a.LINEAR,this._inputWrap=Yh.a.REPEAT,this._outputSize=[16,16],this._downSampler=Xh()({fs:"\n precision highp float;\n #define SHADER_NAME MEAN_DOWN_SAMPLE\n uniform vec2 size;\n uniform sampler2D tex;\n void main () {\n gl_FragColor = texture2D(tex, gl_FragCoord.xy / size);\n }\n "}),this._mipmapSampler=Xh()({fs:"\n #extension GL_EXT_shader_texture_lod : enable\n #define SHADER_NAME MEAN_MIPMAP\n precision highp float;\n uniform sampler2D tex;\n uniform vec2 size;\n void main () {\n gl_FragColor = texture2DLodEXT(tex, gl_FragCoord.xy / size, 4.);\n }\n "}),this._downSamplerTarget=new Hh.a(new Jh.a(this._outputSize[0],this._outputSize[1],{mipMaping:!0,magFilter:Yh.a.LINEAR,minFilter:Yh.a.LINEAR,wrapS:Yh.a.REPEAT,wrapT:Yh.a.REPEAT})),this._output=Hh.a.createU84(this._outputSize[0],this._outputSize[1])}return Object(S["a"])(e,[{key:"render",value:function(e,t){return t.magFilter=this._inputFilter,t.minFilter=this._inputFilter,t.wrapS=this._inputWrap,t.wrapT=this._inputWrap,e.context.bindRenderTarget(this._downSamplerTarget),e.draw(this._downSampler,{uniforms:{size:this._outputSize,tex:t}}),e.context.renderTargetMipmap(this._downSamplerTarget),e.context.bindRenderTarget(this._output),e.draw(this._mipmapSampler,{uniforms:{size:this._outputSize,tex:this._downSamplerTarget.colorTexture}}),this._output.colorTexture}},{key:"release",value:function(){this._downSamplerTarget.release(),this._output.release()}}]),e}()),Qh=function(){function e(t){Object(v["a"])(this,e),t=t||{},this._inputFilter=t.filter||Yh.a.NEAREST,this._inputWrap=t.wrap||Yh.a.REPEAT,this._outputSize=t.size||[2048,2048],this._draw=Xh()({fs:"\n precision highp float;\n #define SHADER_NAME DIRECTIONAL_BLUR\n uniform sampler2D tex;\n uniform float intensity;\n uniform float angle;\n uniform vec2 size;\n const int sample = 128;\n vec4 directional_blur(sampler2D tex, vec2 uv, float intensity, float angle) {\n vec2 offset = vec2(cos(-angle) * intensity / float(sample), sin(-angle) * intensity / float(sample));\n vec4 color = vec4(0.);\n for (int k = -sample; k < sample + 1; k ++){\n color += texture2D(tex, uv + offset * float(k));\n }\n\n return color / float(2 * sample + 1);\n }\n void main() {\n vec2 uv = gl_FragCoord.xy / size; \n gl_FragColor = directional_blur(tex, uv, intensity, angle); \n }\n "}),this._output=Hh.a.createU84(this._outputSize[0],this._outputSize[1])}return Object(S["a"])(e,[{key:"render",value:function(e,t,r){var n=r.angle,i=r.intensity;return n=void 0===n?0:n*Math.PI/180,i=void 0===i?10/256:i/256,t.wrapS=this._inputWrap,t.wrapT=this._inputWrap,t.minFilter=this._inputFilter,t.magFilter=this._inputFilter,e.context.bindRenderTarget(this._output),e.draw(this._draw,{uniforms:{size:this._outputSize,tex:t,intensity:i,angle:n}}),this._output.colorTexture}},{key:"release",value:function(){this._output.release()}}]),e}(),$h=function(){function e(t){Object(v["a"])(this,e),t=t||{},this._inputFilter=t.filter||Yh.a.NEAREST,this._inputWrap=t.wrap||Yh.a.REPEAT,this._outputSize=t.size||[2048,2048],this._draw=Xh()({fs:"\n precision highp float;\n #define SHADER_NAME BLUR_HQ\n uniform vec2 size;\n uniform sampler2D tex1;\n uniform sampler2D tex2;\n uniform float quality;\n \n void main () {\n vec2 uv = gl_FragCoord.xy / size;\n vec4 color1 = texture2D(tex1, uv);\n vec4 color2 = texture2D(tex2, uv);\n gl_FragColor = mix(color1, (color1 + color2) / 2., quality);\n }\n "}),this._blurIn=new Qh({size:this._outputSize}),this._blurOut1=new Qh({size:this._outputSize}),this._blurOut2=new Qh({size:this._outputSize}),this._output=Hh.a.createU84(this._outputSize[0],this._outputSize[1])}return Object(S["a"])(e,[{key:"render",value:function(e,t,r){var n=r.intensity,i=r.quality;if(n=void 0===n?10:n,i=void 0===i?0:i,t.wrapS=this._inputWrap,t.wrapT=this._inputWrap,t.minFilter=this._inputFilter,t.magFilter=this._inputFilter,0===n)return t;n=2*n/3;var a=this._blurIn.render(e,t,{intensity:n,angle:0});a=this._blurOut1.render(e,a,{intensity:n,angle:45}),a=this._blurIn.render(e,a,{intensity:n,angle:90}),a=this._blurOut1.render(e,a,{intensity:n,angle:135});var o=a;return 0!==i&&(o=this._blurIn.render(e,t,{intensity:n,angle:22.5}),o=this._blurOut2.render(e,o,{intensity:n,angle:157.5}),o=this._blurIn.render(e,o,{intensity:n,angle:67.5}),o=this._blurOut2.render(e,o,{intensity:n,angle:112.5})),e.context.bindRenderTarget(this._output),e.draw(this._draw,{uniforms:{size:this._outputSize,tex1:a,tex2:o}}),this._output.colorTexture}},{key:"release",value:function(){this._blurIn.release(),this._blurOut1.release(),this._blurOut2.release(),this._output.release()}}]),e}(),ed=function(){function e(t){Object(v["a"])(this,e),t=t||{},this._inputFilter=t.filter||Yh.a.NEAREST,this._inputWrap=t.wrap||Yh.a.REPEAT,this._outputSize=t.size||[2048,2048],this._computeTarget=Xh()({fs:"\n #define SHADER_NAME COLOR_MATCH_COUMPUTE_TARGET\n precision highp float; \n uniform sampler2D tex;\n uniform vec2 size;\n #ifdef HAS_SOURCE_TEX\n uniform sampler2D sourceTexture;\n #else\n uniform vec3 sourceColor;\n #endif\n uniform vec3 targetColor;\n uniform float mask_hue;\n uniform float mask_chroma;\n uniform float mask_luma;\n uniform float color_variation_hue;\n uniform float color_variation_chroma;\n uniform float color_variation_luma;\n vec3 hcl2rgb(vec3 X) { \n\n float H6 = X.x * 6.0;\n float temp = (1.0 - abs(mod(H6, 2.0) - 1.0)) * X.y;\n vec3 tempRGB;\n \n if(0.0 <= H6 && H6 <= 1.0) {\n tempRGB = vec3(X.y, temp, 0.0);\n } \n else if(1.0 < H6 && H6 <= 2.0){\n tempRGB = vec3(temp, X.y, 0.0);\n }\n else if(2.0 < H6 && H6 <= 3.0){\n tempRGB = vec3(0.0, X.y, temp);\n }\n else if(3.0 < H6 && H6 <= 4.0){\n tempRGB = vec3(0.0, temp, X.y);\n }\n else if(4.0 < H6 && H6 <= 5.0){\n tempRGB = vec3(temp, 0.0, X.y);\n }\n else if(5.0 < H6 && H6 <= 6.0){\n tempRGB = vec3(X.y, 0.0, temp);\n } else {\n tempRGB= vec3(0.0);\n }\n float tempLuma = dot(tempRGB, vec3(0.299, 0.587, 0.114));\n vec3 RGB = tempRGB + vec3(X.z - tempLuma);\n return RGB;\n }\n\n vec3 rgb2hcl(vec3 X){\n float L = dot(X, vec3(0.299, 0.587, 0.114));\n float M = max(X.r, max(X.g, X.b));\n float m = min(X.r, min(X.g, X.b));\n float C = M - m;\n float H;\n if(abs(C) <= 0.0001) {\n H = 0.0;\n } \n else if(abs(M - X.r) <= 0.0001) {\n H = mod((X.g - X.b) / C, 6.0);\n } \n else if(abs(M - X.g) <= 0.0001) {\n H = (X.b - X.r) / C + 2.0;\n } \n else if(abs(M - X.b) <= 0.0001) {\n H = (X.r - X.g) / C + 4.0;\n } else {\n H = 1.0;\n }\n \n H = H / 6.0;\n return vec3(H, C, L);\n }\n void main() {\n vec2 uv = gl_FragCoord.xy / size;\n vec3 ohcl = rgb2hcl(texture2D(tex, uv).rgb);\n #ifdef HAS_SOURCE_TEX\n vec3 shcl = rgb2hcl(texture2D(sourceTexture, uv).rgb);\n #else\n vec3 shcl = rgb2hcl(sourceColor);\n #endif\n \n vec3 deltaHcl = ohcl - shcl;\n float absDeltaH = abs(deltaHcl.x);\n \n float deltaH = min(1. - absDeltaH, absDeltaH);\n float deltaC = abs(deltaHcl.y);\n float deltaL = abs(deltaHcl.z);\n \n float hRange = mask_hue / 360. * 0.5 ;\n float cRange = mask_chroma * 0.5;\n float lRange = mask_luma * 0.5;\n \n float alpha = 0.5;\n if(deltaH <= hRange && deltaC <= cRange && deltaL <= lRange) {\n alpha = 1.;\n } else {\n alpha = 0.;\n } \n vec3 variation_hcl = vec3(color_variation_hue / 360., color_variation_chroma, color_variation_luma) * deltaHcl;\n vec3 thcl = rgb2hcl(targetColor);\n thcl += variation_hcl;\n float H = mod(thcl.x, 1.);\n float C = max(thcl.y, 0.);\n float L = max(thcl.z, 0.);\n gl_FragColor = vec4(hcl2rgb(vec3(H, C, L)), alpha);\n }"}),this._splitAlpha=Xh()({fs:"\n precision highp float;\n #define SHADER_NAME COLOR_MATCH_SPLIT_ALPHA\n uniform sampler2D tex;\n uniform vec2 size;\n void main () {\n float alpha = texture2D(tex, gl_FragCoord.xy / size).a;\n gl_FragColor = vec4(alpha, alpha, alpha, 1.);\n }\n "}),this._histogram_scan_shader=Xh()({fs:"\n #define SHADER_NAME COLOR_MATCH_HISTOGRAM_SCAN\n precision highp float;\n float histogram_scan(float gray, float position, float contrast) {\n\n float t = 1.0 - position;\n float A = (max(t, 0.5) - 0.5) * 2.0;\n float B = min(t * 2.0, 1.0);\n \n float X = clamp(contrast * 0.5, 0., 1.);\n float minInput = mix(A, B, X); //0.95 /2\n float maxInput = mix(B, A, X); // 1- 0.95 /2\n \n return clamp((gray - minInput) / (maxInput - minInput), 0., 1.);\n }\n uniform sampler2D tex;\n uniform vec2 size;\n void main() {\n vec2 uv = gl_FragCoord.xy / size;\n float gray = texture2D(tex, uv).r;\n gray = histogram_scan(gray, 0.5, 0.95);\n gl_FragColor = vec4(gray, gray, gray, 1.);\n }\n "}),this._withoutMaskBlit=Xh()({fs:"\n #define SHADER_NAME COLOR_MATCH_WITHOUT_MASK_BLIT\n precision highp float;\n uniform sampler2D targetTex;\n uniform sampler2D tex;\n uniform vec2 size;\n \n void main() {\n vec2 uv = gl_FragCoord.xy / size;\n gl_FragColor = vec4(texture2D(targetTex, uv).rgb, texture2D(tex, uv).a);\n }\n "}),this._maskBlit=Xh()({fs:"\n #define SHADER_NAME COLOR_MATCH_MASK_BLIT\n precision highp float;\n uniform sampler2D targetTex;\n uniform sampler2D tex;\n uniform sampler2D opacityTex;\n uniform vec2 size;\n \n void main() {\n vec2 uv = gl_FragCoord.xy / size;\n vec4 background = texture2D(tex, uv);\n vec4 foreground = vec4(texture2D(targetTex, uv).rgb, background.a);\n float opacity = texture2D(opacityTex, uv).r;\n gl_FragColor = mix(background, foreground, opacity);\n }\n "}),this._mean=new Zh,this._target=Hh.a.createU84(this._outputSize[0],this._outputSize[1]),this._targetAlpha=Hh.a.createU84(this._outputSize[0],this._outputSize[1]),this._blurHQ=new $h({size:this._outputSize}),this._scan=Hh.a.createU84(this._outputSize[0],this._outputSize[1]),this._output=Hh.a.createU84(this._outputSize[0],this._outputSize[1])}return Object(S["a"])(e,[{key:"render",value:function(t,r,n){var i=n.sourceMode,a=void 0===i?e.AVERAGE:i,o=n.sourceColor,s=void 0===o?[.5,.5,.5]:o,u=n.sourceTexture,c=n.targetColor,l=void 0===c?[.5,.5,.5]:c,h=n.color_variation_hue,d=void 0===h?0:h,f=n.color_variation_chroma,_=void 0===f?1:f,p=n.color_variation_luma,g=void 0===p?1:p,m=n.useMask,v=void 0===m||m,b=n.mask_hue,S=void 0===b?30:b,x=n.mask_chroma,T=void 0===x?.5:x,y=n.mask_luma,C=void 0===y?.5:y,A=n.mask_blur,E=void 0===A?0:A,R=n.mask_smoothness,M=void 0===R?0:R;if(a==e.AVERAGE&&(u=this._mean.render(t,r)),a!=e.TEXTURE||u||console.error("no source texture with source-texture-mode"),u?(this._computeTarget.defines="#define HAS_SOURCE_TEX\n",u.wrapS=this._inputWrap,u.wrapT=this._inputWrap,u.minFilter=this._inputFilter,u.magFilter=this._inputFilter):this._computeTarget.defines="",r.wrapS=this._inputWrap,r.wrapT=this._inputWrap,r.minFilter=this._inputFilter,r.magFilter=this._inputFilter,t.context.bindRenderTarget(this._target),t.draw(this._computeTarget,{uniforms:{size:this._outputSize,tex:r,sourceColor:s,sourceTexture:u,targetColor:l,mask_hue:S,mask_chroma:T,mask_luma:C,color_variation_hue:d,color_variation_chroma:_,color_variation_luma:g}}),this._target.colorTexture.wrapS=this._inputWrap,this._target.colorTexture.wrapT=this._inputWrap,this._target.colorTexture.minFilter=this._inputFilter,this._target.colorTexture.magFilter=this._inputFilter,v){t.context.bindRenderTarget(this._targetAlpha),t.draw(this._splitAlpha,{uniforms:{size:this._outputSize,tex:this._target.colorTexture}});var w=this._blurHQ.render(t,this._targetAlpha.colorTexture,{intensity:M,quality:1});w.wrapS=this._inputWrap,w.wrapT=this._inputWrap,w.minFilter=this._inputFilter,w.magFilter=this._inputFilter,t.context.bindRenderTarget(this._scan),t.draw(this._histogram_scan_shader,{uniforms:{size:this._outputSize,tex:w}});var N=this._blurHQ.render(t,this._scan.colorTexture,{intensity:E,quality:1});N.wrapS=this._inputWrap,N.wrapT=this._inputWrap,N.minFilter=this._inputFilter,N.magFilter=this._inputFilter,t.context.bindRenderTarget(this._output),t.draw(this._maskBlit,{uniforms:{size:this._outputSize,tex:r,targetTex:this._target.colorTexture,opacityTex:N}})}else t.context.bindRenderTarget(this._output),t.draw(this._withoutMaskBlit,{uniforms:{size:this._outputSize,tex:r,targetTex:this._target.colorTexture}});return this._output.colorTexture}},{key:"release",value:function(){this._mean.release(),this._target.release(),this._targetAlpha.release(),this._blurHQ.release(),this._scan.release(),this._output.release()}}]),e}();ed.AVERAGE=0,ed.COLOR=1,ed.TEXTURE=2;var td={sourceMode:ed.AVERAGE,sourceColor:[.5,.5,.5],targetColor:[.5,.5,.5],color_variation_hue:0,color_variation_chroma:1,color_variation_luma:1,useMask:!0,mask_hue:30,mask_chroma:.5,mask_luma:.5,mask_blur:0,mask_smoothness:0},rd=(Object(ah["a"])({},td),n("e1bd"));function nd(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"PackSource";return"".concat(e,"_").concat(Object(rd["a"])())}function id(){return{url:"",size:0}}function ad(){return{brightness:1,color:[.4,.4,.4],scaleX:1,scaleY:1}}function od(){return{scale:1,rotate:0,offsetX:.5,offsetY:0}}function sd(e){return Object.assign({texture:id(),useTexture:!1},e)}var ud=n("9072"),cd=(n("6062"),n("7039"),function(){function e(){Object(v["a"])(this,e)}return Object(S["a"])(e,[{key:"onInit",value:function(e){}},{key:"isHashEqual",value:function(e){var t={excludeKeys:["id","origin"]},r=hd(this,t),n=hd(e,t);return Object(Uo["isEqual"])(r,n)}}],[{key:"create",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(t instanceof this)return t;t.id||(t.id=nd(this.prototype.constructor.name));var r=new this;return Object.assign(r,t),null===(e=r.onInit)||void 0===e||e.call(r,t),r}},{key:"createOrigin",value:function(e){var t=Object(Uo["cloneDeep"])(e);return t.id=nd(this.prototype.constructor.name),t.origin={sourceId:e.id},t}},{key:"createGroup",value:function(e){var t=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(){return Object(v["a"])(this,r),t.apply(this,arguments)}return Object(S["a"])(r)}(ld);t.prototype.sourceType=this;var r=new t;return r.init(e),r}}]),e}()),ld=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(){return Object(v["a"])(this,r),t.apply(this,arguments)}return Object(S["a"])(r,[{key:"init",value:function(e){var t=this;this.length=0,e&&this.push.apply(this,Object(Bo["a"])(e.map((function(e){return t.sourceType.create(e)}))))}},{key:"add",value:function(e){var t;if(null!==(t=e.origin)&&void 0!==t&&t.sourceId){var r=e.origin.sourceId,n=this.find((function(t){var n;if((r===t.id||r===(null===(n=t.origin)||void 0===n?void 0:n.sourceId))&&t.isHashEqual(e))return!0}));if(n)return n}return this.push(e),e}}]),r}(Object(ud["a"])(Array));function hd(e,t){var r,n=new Set(Object.getOwnPropertyNames(e));null===t||void 0===t||null===(r=t.excludeKeys)||void 0===r||r.forEach((function(e){n.delete(e)}));var i={};return n.forEach((function(t){i[t]=e[t]})),i}var dd=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(){var e;return Object(v["a"])(this,r),e=t.apply(this,arguments),e.name="未命名",e.cusNum="未命名",e.thumbnail=id(),e.classType="pbr",e.type="meta",e.uvMap="box",e.cullFace="",e.diamond=ad(),e.normal=sd({factor:1}),e.metalness=sd({factor:0}),e.roughness=sd({factor:1}),e.gloss=sd({factor:1}),e.albedo=sd({color:[0,1,0]}),e.diffuse=sd({color:[0,1,0]}),e.specular=sd({color:[1,1,1]}),e.displace=sd({factor:1,enable:!1}),e.opacity=sd({factor:1,enable:!1}),e.uv=od(),e.cusUv=od(),e}return Object(S["a"])(r)}(cd),fd=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(){var e;return Object(v["a"])(this,r),e=t.apply(this,arguments),e.matId="",e.groupId="",e.uvMap=id(),e.uvsize={width:0,height:0},e.name="",e.index=0,e.visible=!0,e.locked=!1,e}return Object(S["a"])(r)}(cd),_d={url:"",size:0};function pd(e){return{cullFace:"",metalnessWorkFlow:!0,classType:"pbr",uvProjection:!0,uvtransform:{offsetX:0,offsetY:0,rotate:0,scale:1},channels:{Diamond:{brightness:1,color:[.4,.4,.4],scaleX:1,scaleY:1},Albedo:{color:[.509803950786591,.474509835243225,.474509835243225],texture:e},Roughness:{factor:1,invert:!1,texture:Object(ah["a"])({},_d)},Emissive:{color:[0,0,0],factor:1,enable:!1},NormalMap:{enable:!0,factor:1,flipY:!1,texture:Object(ah["a"])({},_d)},BumpMap:{enable:!1,factor:1,texture:Object(ah["a"])({},_d)},Opacity:{enable:!1,type:"ALPHA_BLEND",factor:1,invert:!1,sampleChannel:"a",refractionTint:[1,1,1],refractUseDiffuse:!1,refractUseShininessMap:!1,IOR:1,roughnessFactor:0,texture:Object(ah["a"])({},_d)},AO:{enable:!1,occludeSpecular:!1,factor:0,texture:Object(ah["a"])({},_d)},MetalnessPBR:{factor:0,texture:Object(ah["a"])({},_d)},SpecularF0:.5,ClearCoat:{enable:!1,thickness:5,intensity:1,color:[1,1,1],reflectivity:0,roughness:{factor:.04},normalmap:{factor:1,flipY:!1}},Displacement:{enable:!1,factor:0,texture:Object(ah["a"])({},_d)},CavityMap:{enable:!1,factor:0}}}}var gd=function(){function e(){Object(v["a"])(this,e)}return Object(S["a"])(e,null,[{key:"createNativeMat",value:function(e){var t=pd({url:"",size:0});if(!e)return t;var r=e;if(t.metalnessWorkFlow="spec"!=r.type,t.classType=r.classType||"pbr","diamond"==t.classType)return t.channels.Diamond=Object(ah["a"])({},e.diamond),t;if("spec"==r.type)t.channels.Albedo.color=r.diffuse.color,r.diffuse.useTexture&&(t.channels.Albedo.texture=r.diffuse.texture),t.channels.Roughness.factor=r.gloss.factor,r.gloss.useTexture&&(t.channels.Roughness.texture=r.gloss.texture),t.channels.MetalnessPBR.factor=r.specular.color||[0,0,0],r.specular.useTexture&&(t.channels.MetalnessPBR.texture=r.specular.texture);else{var n,i,a,o,s,u;if(t.channels.Albedo.color=(null===(n=r.albedo)||void 0===n?void 0:n.color)||[0,1,0],null!==(i=r.albedo)&&void 0!==i&&i.useTexture&&(t.channels.Albedo.texture=r.albedo.texture),r.roughness)t.channels.Roughness.factor=null===(s=r.roughness)||void 0===s?void 0:s.factor,"number"!==typeof(null===(u=r.roughness)||void 0===u?void 0:u.factor)&&(t.channels.Roughness.factor=1),r.roughness.useTexture&&(t.channels.Roughness.texture=r.roughness.texture);t.channels.MetalnessPBR.factor=(null===(a=r.metalness)||void 0===a?void 0:a.factor)||0,null!==(o=r.metalness)&&void 0!==o&&o.useTexture&&(t.channels.MetalnessPBR.texture=r.metalness.texture)}if(r.uv&&(t.uvtransform=Object(ah["a"])({},r.uv)),r.cusUv&&(r.cusUv.offsetX&&(t.uvtransform.offsetX+=r.cusUv.offsetX),r.cusUv.offsetY&&(t.uvtransform.offsetY+=r.cusUv.offsetY),r.cusUv.rotate&&(t.uvtransform.rotate+=r.cusUv.rotate),r.cusUv.scale)){var c=t.uvtransform.scale,l=r.cusUv.scale;l=l<0?(1-.9*l)*c:c*(1-.09*l),t.uvtransform.scale=l}return r.normal&&(t.channels.NormalMap.enable=!0,t.channels.NormalMap.texture=r.normal.texture),r.displace&&r.displace.enable&&(t.channels.Displacement.enable=!0,t.channels.Displacement.texture=r.displace.texture,t.channels.Displacement.factor=r.displace.factor),r.opacity&&r.opacity.enable&&(t.channels.Opacity.enable=!0,t.channels.Opacity.factor=r.opacity.factor,t.channels.Opacity.texture=r.opacity.texture),t.uvProjection=r.uvProjection,void 0==t.uvProjection&&(r.uvMap?t.uvProjection="box"==r.uvMap:t.uvProjection=!0),t}}]),e}(),md=function(e){Object(x["a"])(r,e);var t=Object(T["a"])(r);function r(){return Object(v["a"])(this,r),t.apply(this,arguments)}return Object(S["a"])(r,[{key:"load",value:function(){var e=Object(l["a"])(regeneratorRuntime.mark((function e(t){var r;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return r=t.osgjs.url,r=r.replace("sku3d-test.obs.cn-east-3.myhuaweicloud.com","obs.sku3d.com"),e.abrupt("return",(new Ch).load({id:t.id,url:r},!0,"3.0"));case 3:case"end":return e.stop()}}),e)})));function t(t){return e.apply(this,arguments)}return t}()}]),r}(Ah),vd=function(){function e(){var t=this;Object(v["a"])(this,e),this.queen3d=new Th,this.store=Object(u["u"])({showLoading:!0}),this.geomsCacher=new Eh(new md),this.nativeProductMap=new Map,this.nativeMatMap=new Map,this.config={defaultAlbeoColor:[0,1,0]},this.destroy=function(){t.queen3d.destory()}}return Object(S["a"])(e,[{key:"init",value:function(e){var t=this.queen3d;t.init(e,{enablePicker:!0,clickedOutline:!0}),t.afterInit((function(){t.showGizmo(!1),t.gizmoAttach(null),t.picker&&(t.picker.enable=!1)}))}},{key:"loadPackSource",value:function(){var e=Object(l["a"])(regeneratorRuntime.mark((function e(t){var r,n,i;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return this.packSource=t,e.prev=1,n=this.queen3d,null===(r=n.getAppInstance().scene)||void 0===r||r.clean(),i=t.scenes[0],Lh(n,t,i,!0),e.next=8,Uh(t,i,this.geomsCacher);case 8:return e.next=10,this.initSceneProducts(i);case 10:return n.updateController(),n.getAppInstance().setViewMode("left-top"),n.redraw(),e.next=15,this.initSceneMats(i);case 15:this.queen3d.redraw();case 16:return e.prev=16,e.finish(16);case 18:case"end":return e.stop()}}),e,this,[[1,,16,18]])})));function t(t){return e.apply(this,arguments)}return t}()},{key:"loadMatSource",value:function(){var e=Object(l["a"])(regeneratorRuntime.mark((function e(t){var r,n,i,a;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return n=this.queen3d,null===(r=n.getAppInstance().scene)||void 0===r||r.clean(),e.next=4,Gh(t,this.geomsCacher);case 4:return i=e.sent,n.addChild(i.geom),n.updateController(),n.getAppInstance().setViewMode("left-top"),n.redraw(),a=this.createNativeMat(t.mat),e.next=12,i.setGeomMat("fabric",a);case 12:n.redraw();case 13:case"end":return e.stop()}}),e,this)})));function t(t){return e.apply(this,arguments)}return t}()},{key:"initSceneProducts",value:function(){var e=Object(l["a"])(regeneratorRuntime.mark((function e(t){var r,n,i;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:r=0;case 1:if(!(r<t.products.length)){e.next=14;break}if(n=t.products[r],0!=n.visible){e.next=5;break}return e.abrupt("continue",11);case 5:return e.next=7,this.createSceneProductObj(n);case 7:if(i=e.sent,i){e.next=10;break}return e.abrupt("continue",11);case 10:this.queen3d.addChild(i.node);case 11:r++,e.next=1;break;case 14:case"end":return e.stop()}}),e,this)})));function t(t){return e.apply(this,arguments)}return t}()},{key:"findGeomDef",value:function(e){return this.packSource.geoms.find((function(t){return t.id==e}))}},{key:"findProductDef",value:function(e){return this.packSource.products.find((function(t){return t.id==e}))}},{key:"createProductObj",value:function(){var e=Object(l["a"])(regeneratorRuntime.mark((function e(t,r){var n,i,a,o;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:if(i=this.findProductDef(t),i){e.next=3;break}return e.abrupt("return");case 3:if(a=this.findGeomDef(i.geomId),a){e.next=6;break}return e.abrupt("return");case 6:return e.next=8,this.geomsCacher.load(a.osgjs.url,a);case 8:return o=e.sent,e.abrupt("return",o?new Ph(o,r,!1,null===(n=a.shadow)||void 0===n?void 0:n.url):void 0);case 10:case"end":return e.stop()}}),e,this)})));function t(t,r){return e.apply(this,arguments)}return t}()},{key:"addMat",value:function(e){return this.packSource.mats.push(e)}},{key:"createSceneProductObj",value:function(){var e=Object(l["a"])(regeneratorRuntime.mark((function e(t){var r,n,i,a,o,s,u,c,l,h,d,f,_,p=this;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,this.createProductObj(t.prodId,t.id);case 2:if(r=e.sent,r){e.next=5;break}return e.abrupt("return");case 5:r.on("onload",(function(){p.queen3d.redraw()})),this.nativeProductMap.set(t.id,r),r.nodeShadow&&r.nodeShadow.setNodeMask(t.noShadow?0:-1),n=this.findProductDef(t.prodId),i=dd.create(),i.albedo.color=this.config.defaultAlbeoColor||[1,1,0],null===n||void 0===n||!n.components||n.components.length<1?(this.addMat(i),a=fd.createGroup(),o=r.mesh.getGeoms(),o.forEach((function(e){a.add(fd.create({name:e.node,matId:i.id,index:e.index,visible:!0,userData:null}))})),n&&(n.components=a)):(s=r.mesh.getGeoms(),u=fd.createGroup(),s.forEach((function(e){var t=null===n||void 0===n?void 0:n.components.find((function(t){return t.name==e.node}));t?(u.push(t),void 0===t.visible&&(t.visible=!0)):(u.push(fd.create({name:e.node,matId:i.id,index:e.index,visible:!0,userData:null})),p.addMat(i))})),n&&(n.components=u),null===n||void 0===n||n.components.forEach((function(e){e.matId||(e.matId=i.id),void 0===e.visible&&(e.visible=!0)}))),this.nativeProductMap.set(t.prodId,r),r.updateTransform(t.transform),r.node.setNodeMask(t.visible?-1:0),c=this.findProductDef(t.prodId),l=(null===c||void 0===c?void 0:c.components)||[],h=l.length,d=0;case 19:if(!(d<h)){e.next=28;break}return f=l[d],!1===f.visible&&r.mesh.setGeomVisible(f.name,!1),_=this.createNativeMat(i),e.next=25,r.mesh.setGeomMat(f.name,_);case 25:d++,e.next=19;break;case 28:return e.abrupt("return",r);case 29:case"end":return e.stop()}}),e,this)})));function t(t){return e.apply(this,arguments)}return t}()},{key:"createNativeMat",value:function(e){return gd.createNativeMat(e)}},{key:"initSceneMats",value:function(){var e=Object(l["a"])(regeneratorRuntime.mark((function e(t){var r,n;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:r=this.initNativeMatMap(t),e.t0=regeneratorRuntime.keys(r);case 2:if((e.t1=e.t0()).done){e.next=9;break}return n=e.t1.value,this.nativeMatMap.set(n,{nodes:r[n]}),e.next=7,this.initSceneMat(n);case 7:e.next=2;break;case 9:case"end":return e.stop()}}),e,this)})));function t(t){return e.apply(this,arguments)}return t}()},{key:"initNativeMatMap",value:function(e){var t=this,r={};return this.nativeMatMap.clear(),e.products.forEach((function(e){var n=t.nativeProductMap.get(e.id),i=t.findProductDef(e.prodId);n&&i&&i.components.forEach((function(t){var n=r[t.matId]||(r[t.matId]={}),i=n[e.id]||(n[e.id]=[]);i.push(t.name)}))})),Object.entries(r).forEach((function(e){var r=Object(m["a"])(e,2),n=r[0],i=r[1];t.nativeMatMap.set(n,{nodes:i})})),r}},{key:"findMatDef",value:function(e){return this.packSource.mats.find((function(t){return t.id==e}))}},{key:"initSceneMat",value:function(){var e=Object(l["a"])(regeneratorRuntime.mark((function e(t){var r,n,i,a,o,s,u,c,l;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:if(n=this.findMatDef(t),i=null===(r=this.nativeMatMap.get(t))||void 0===r?void 0:r.nodes,i&&n){e.next=4;break}return e.abrupt("return");case 4:this.initPackMat(n),n.cusUv=null,a=this.createNativeMat(n),e.t0=regeneratorRuntime.keys(i);case 8:if((e.t1=e.t0()).done){e.next=32;break}if(o=e.t1.value,s=this.nativeProductMap.get(o),s){e.next=13;break}return e.abrupt("continue",8);case 13:u=Object(g["a"])(i[o]),e.prev=14,u.s();case 16:if((c=u.n()).done){e.next=22;break}return l=c.value,e.next=20,s.mesh.setGeomMat(l,a);case 20:e.next=16;break;case 22:e.next=27;break;case 24:e.prev=24,e.t2=e["catch"](14),u.e(e.t2);case 27:return e.prev=27,u.f(),e.finish(27);case 30:e.next=8;break;case 32:this.queen3d.redraw();case 33:case"end":return e.stop()}}),e,this,[[14,24,27,30]])})));function t(t){return e.apply(this,arguments)}return t}()},{key:"initPackMat",value:function(e){void 0===e.type&&(e.type="meta"),void 0===e.classType&&(e.classType="pbr"),e.cusUv=null}}]),e}(),bd=Object(u["i"])({props:{src:Object(d["a"])().isRequired},setup:function(e){var t=Object(u["u"])({loading:!1}),r=Object(u["v"])(),n=function(){var n=Object(l["a"])(regeneratorRuntime.mark((function n(){var i;return regeneratorRuntime.wrap((function(n){while(1)switch(n.prev=n.next){case 0:return t.loading=!0,i=new vd,i.init(r.value),n.next=5,i.loadPackSource(e.src);case 5:t.loading=!1;case 6:case"end":return n.stop()}}),n)})));return function(){return n.apply(this,arguments)}}();return Object(u["r"])((function(){n()})),function(){return Object(u["h"])("div",{class:Sd},[t.loading&&Object(u["h"])(f["a"],{class:xd,indicator:Object(u["h"])(p["a"],{style:{fontSize:"40px",color:"#fff"}},null)},null),Object(u["h"])("canvas",{ref:r},null)])}}}),Sd="c1e0zl9j",xd="l12ccz8n";n("6177");var Td=Object(u["i"])({props:{src:Object(d["a"])().isRequired},setup:function(e){var t=e.src.source,r=t.geoms[0];if(!r)return function(){return Object(u["h"])("div",null,[Object(u["g"])("数据错误!")])};var n={background:{color:[.749,.749,.749],type:1},id:"001",products:[{id:"1",prodId:t.products[0].id,transform:{pos:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1]},visible:!0}]};return t.scenes=[n],r.osgjs.url?function(){return Object(u["h"])(bd,{src:t},null)}:function(){return Object(u["h"])("div",{class:yd},[Object(u["g"])("不支持的单品格式")])}}}),yd="cwuhi4d";function Cd(e,t,r){var n=Object(u["v"])(),i=Object(Uo["debounce"])(a,200);function a(){var i=n.value,a=r.value,o=i.clientWidth,s=i.clientHeight;if(e){var u=o/s,c=2*t;a.style=u>e?"height:".concat(s-c,"px;width:").concat((s-c)*e,"px"):"width:".concat(o-c,"px;height:").concat((o-c)/e,"px")}else a.style=""}return Object(u["r"])((function(){window.addEventListener("resize",i)})),Object(u["s"])((function(){window.removeEventListener("resize",i)})),n}n("ae22");var Ad=Object(u["i"])({props:{src:Object(d["a"])().isRequired},setup:function(e){var t=Object(u["u"])({loading:!1}),r=Object(u["v"])(),n=Cd(0,0,r),i=function(){var n=Object(l["a"])(regeneratorRuntime.mark((function n(){var i;return regeneratorRuntime.wrap((function(n){while(1)switch(n.prev=n.next){case 0:return t.loading=!0,i=new vd,i.init(r.value),n.next=5,i.loadPackSource(e.src);case 5:t.loading=!1;case 6:case"end":return n.stop()}}),n)})));return function(){return n.apply(this,arguments)}}();return Object(u["r"])((function(){i()})),function(){return Object(u["h"])("div",{class:Ed,ref:n},[t.loading&&Object(u["h"])(f["a"],{class:Rd,indicator:Object(u["h"])(p["a"],{style:{fontSize:"40px",color:"#fff"}},null)},null),Object(u["h"])("canvas",{ref:r},null)])}}}),Ed="cyfieek",Rd="lje6630";n("5f4e");var Md=Object(u["i"])({props:{src:Object(d["a"])().isRequired},setup:function(e){var t=e.src,r=t.source,n=r.geoms[0];return n?n.osgjs.url?function(){return Object(u["h"])(Ad,{src:r},null)}:function(){return Object(u["h"])("div",{class:wd},[Object(u["g"])("不支持的场景格式")])}:function(){return Object(u["h"])("div",null,[Object(u["g"])("数据错误!")])}}}),wd="c11ml4pn";n("d499");var Nd=Object(u["i"])({props:{src:Object(d["a"])().isRequired},setup:function(e){var t=Object(u["u"])({loading:!1}),r=Object(u["v"])(),n=function(){var n=Object(l["a"])(regeneratorRuntime.mark((function n(){var i;return regeneratorRuntime.wrap((function(n){while(1)switch(n.prev=n.next){case 0:return t.loading=!0,i=new vd,i.init(r.value),n.next=5,i.loadMatSource(e.src);case 5:t.loading=!1;case 6:case"end":return n.stop()}}),n)})));return function(){return n.apply(this,arguments)}}();return Object(u["r"])((function(){n()})),function(){return Object(u["h"])("div",{class:Od},[t.loading&&Object(u["h"])(f["a"],{class:Id,indicator:Object(u["h"])(p["a"],{style:{fontSize:"40px",color:"#fff"}},null)},null),Object(u["h"])("canvas",{ref:r},null)])}}}),Od="ctk4eb2",Id="l1mi9dz2";n("9908");var Pd=Object(u["i"])({props:{src:Object(d["a"])().isRequired},setup:function(e){Object(u["u"])({loading:!1}),Object(u["v"])();var t,r,n=e.src.source,i=n.mat;return i?null!==i&&void 0!==i&&null!==(t=i.albedo)&&void 0!==t&&null!==(r=t.texture)&&void 0!==r&&r.url?function(){return Object(u["h"])(Nd,{src:n},null)}:function(){return Object(u["h"])("div",{class:Dd},[Object(u["g"])("不支持的材质格式")])}:function(){return Object(u["h"])("div",null,[Object(u["g"])("数据错误!")])}}}),Dd="c1kvi1js";n("d8db");var Ld=Object(u["i"])({props:{src:Object(d["b"])().isRequired},setup:function(e){return function(){return Object(u["h"])("div",{class:Fd},[Object(u["h"])("img",{src:e.src},null)])}}}),Fd="c1k0h6io";n("9a96");var kd=Object(u["i"])({setup:function(e){var t=Object(u["v"])(),r=Object(u["u"])({assetType:"",loaded:!1,previewId:""});function n(){return r.assetType==h["a"].Mesh.id?Object(u["h"])(Td,{src:t.value,key:r.previewId},null):r.assetType==h["a"].Scene.id?Object(u["h"])(Md,{src:t.value,key:r.previewId},null):r.assetType==h["a"].Mat.id?Object(u["h"])(Pd,{src:t.value,key:r.previewId},null):r.assetType==h["a"].Image.id?Object(u["h"])(Ld,{src:t.value,key:r.previewId},null):Object(u["h"])("div",null,null)}return Object(u["r"])(Object(l["a"])(regeneratorRuntime.mark((function e(){var n;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:window.addEventListener("message",(function(e){try{if(!e.data||"string"!=typeof e.data)return;var n=JSON.parse(e.data);r.assetType=n.assetType,t.value=n.data,r.previewId=Date.now()+"",console.log("preview=>",n)}catch(e){console.error(e)}})),null===(n=window.parent)||void 0===n||n.postMessage(JSON.stringify({type:"ready"}),"*");case 2:case"end":return e.stop()}}),e)})))),function(){return Object(u["h"])("div",{class:Bd},[n()])}}}),Bd="c142sydk";n("4e33");n("fd87"),n("8b09"),n("fb2c");var Ud=n("4e92"),Vd=gs.createQuatChannel,Gd=gs.createVec3Channel,zd=gs.createFloatChannel,jd=function(){this._filesMap=void 0,this._loadedFiles=void 0,this._bufferViewCache=void 0,this._basicAnimationManager=void 0,this._visitedNodes=void 0,this._animatedNodes=void 0,this._bones=void 0,this._skeletonToInfluenceMap=void 0,this._inputImgReader=void 0,this._localPath="",this._extensions=[],this._nodeAnimationTypes=void 0,this.init()};function Hd(e){for(var t=window.atob(e),r=t.length,n=new Uint8Array(r),i=0;i<r;i++)n[i]=t.charCodeAt(i);return n.buffer}jd.WEBGL_COMPONENT_TYPES={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},jd.TYPE_TABLE={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},jd.ATTRIBUTE_OSGJS_TABLE={POSITION:"Vertex",NORMAL:"Normal",TANGENT:"Tangent",TEXCOORD_0:"TexCoord0",TEXCOORD_1:"TexCoord1",TEXCOORD_2:"TexCoord2",TEXCOORD_3:"TexCoord3",TEXCOORD_4:"TexCoord4",TEXCOORD_5:"TexCoord5",TEXCOORD_6:"TexCoord6",TEXCOORD_7:"TexCoord7",TEXCOORD_8:"TexCoord8",TEXCOORD_9:"TexCoord9",TEXCOORD_10:"TexCoord10",TEXCOORD_11:"TexCoord11",TEXCOORD_12:"TexCoord12",TEXCOORD_13:"TexCoord13",TEXCOORD_14:"TexCoord14",TEXCOORD_15:"TexCoord15",COLOR_0:"Color",JOINTS_0:"Bones",WEIGHTS_0:"Weights"},jd.TEXTURE_FORMAT={6406:J["default"].ALPHA,6407:J["default"].RGB,6408:J["default"].RGBA,6409:J["default"].LUMINANCE,6410:J["default"].LUMINANCE_ALPHA},jd.TYPE_CHANNEL_PATH={translation:{VEC3:Gd},scale:{VEC3:Gd},rotation:{VEC4:Vd},weights:{SCALAR:zd}},jd.TYPE_STACKED_TRANSFORMS={translation:Gu,scale:Uu,rotation:Lu},jd.PBR_SPEC_EXT="KHR_materials_pbrSpecularGlossiness",jd.PBR_SPEC_MODE="PBR_specular_glossiness",jd.PBR_METAL_MODE="PBR_metal_roughness",jd.ALBEDO_TEXTURE_UNIT=2,jd.DIFFUSE_TEXTURE_UNIT=2,jd.SPECULAR_GLOSSINESS_TEXTURE_UNIT=3,jd.METALLIC_ROUGHNESS_TEXTURE_UNIT=3,jd.SPECULAR_TEXTURE_UNIT=4,jd.NORMAL_TEXTURE_UNIT=5,jd.AO_TEXTURE_UNIT=6,jd.EMISSIVE_TEXTURE_UNIT=7,jd.ALBEDO_UNIFORM="albedoMap",jd.METALLIC_ROUGHNESS_UNIFORM="metallicRoughnessMap",jd.SPECULAR_UNIFORM="specularMap",jd.NORMAL_UNIFORM="normalMap",jd.AO_UNIFORM="aoMap",jd.EMISSIVE_UNIFORM="emissiveMap",jd.prototype={init:function(){this._glTFJSON=void 0,this._nodeAnimationTypes=[],this._bufferViewCache={},this._basicAnimationManager=void 0,this._localPath="",this._visitedNodes={},this._animatedNodes={},this._bones={},this._skeletonToInfluenceMap={},this._stateSetMap={},this._filesMap={},this._inputReader=new Ul["a"],this._rootStateSet=new Rr["a"],this._defaultBlendFunc=new De["a"],this._transparentBlendFunc=new De["a"]("SRC_ALPHA","ONE_MINUS_SRC_ALPHA"),this._defaultCullFace=new Fe["a"],this._doubleSideCullFace=new Fe["a"](Fe["a"].DISABLE)},_preProcessNodes:function(){for(var e,t=this._gltfJSON.nodes,r=this._gltfJSON.meshes,n=0;n<t.length;n++){var i=t[n];e=i.name||"",e+="_"+n.toString(),i.osgjsNodeName=e;var a=i.children;if(a)for(var o=0;o<a.length;o++){var s=a[o];t[s].parent=n}}for(var u=0;u<r.length;u++){var c=r[u];e=c.name||"",e+="_"+u.toString(),c.osgjsNodeName=e}},loadBuffers:U.a.method((function(){for(var e=[],t=this._gltfJSON.buffers,r=0;r<t.length;r++){var n=t[r];e.push(this.loadURI(n.uri,{responseType:"arraybuffer"}).then((function(e){n.data=e})))}return U.a.all(e)})),loadBufferViews:function(){for(var e=this._gltfJSON.buffers,t=this._gltfJSON.bufferViews,r=0;r<t.length;r++){var n=t[r],i=n.buffer,a=e[i],o=n.byteLength||0,s=n.byteOffset||0;n.data=a.data.slice(s,s+o)}},loadAccessors:function(){for(var e=this._gltfJSON.bufferViews,t=this._gltfJSON.accessors,r=0;r<t.length;r++){var n,i=t[r],a=i.bufferView,o=e[a],s=jd.TYPE_TABLE[i.type],u=jd.WEBGL_COMPONENT_TYPES[i.componentType],c=u.BYTES_PER_ELEMENT,l=c*s,h=o.byteStride,d=!0===i.normalized;if(h&&h!==l)L["a"].warn("GLTF interleaved accessors not supported");else{var f=new u(o.data,i.byteOffset,i.count*s);n=new X["a"](void 0,f,s),n.setNormalize(d)}i.data=n}},_computeNodeMatrix:function(e){var t;if(e.matrix)t=F["c"].clone(e.matrix);else if(e.translation||e.rotation||e.scale){var r=F["c"].IDENTITY,n=F["c"].IDENTITY,i=F["c"].IDENTITY;e.translation&&(r=F["c"].fromTranslation(F["c"].create(),e.translation)),e.rotation&&(n=F["c"].fromQuat(F["c"].create(),e.rotation)),e.scale&&(i=F["c"].fromScaling(F["c"].create(),e.scale)),t=F["c"].create(),F["c"].multiply(t,n,i),F["c"].multiply(t,r,t)}return t},loadNodes:function(){for(var e=this._gltfJSON.nodes,t=this._gltfJSON.skins,r=this._gltfJSON.meshes,n=0;n<e.length;n++){var i=e[n];if(!i.usedAsBone){if(void 0!==i.skin){var a=t[i.skin],o=a.osgjsNode;a.osgjsNodeAttached||(i.osgjsNode=o,a.osgjsNodeAttached=n);var s=r[i.mesh];s.osgjsGeometry.setBoneNameID(a.osgjsBoneMapID),o.addChild(s.osgjsGeometry)}else(i.matrix||i.translation||i.rotation||i.scale)&&(i.osgjsNode=this._createMatrixTransform(n)),void 0!==i.mesh&&(i.osgjsNode?i.osgjsNode.addChild(r[i.mesh].osgjsGeometry):i.osgjsNode=r[i.mesh].osgjsGeometry),i.osgjsNode||(i.osgjsNode=new Ar["a"]);i.name&&i.osgjsNode.setName(i.name)}}},_linkNodes:function(e){var t=this._gltfJSON.nodes,r=e.children;if(r)for(var n=0;n<r.length;n++){var i=t[r[n]];if(!i.usedAsBone){var a=i.osgjsNode;a&&!e.osgjsNode.hasChild(a)&&(e.osgjsNode.addChild(a),this._linkNodes(i))}}},loadSkins:function(){var e=this._gltfJSON.skins;if(e)for(var t=0;t<e.length;t++)this._processSkin(t)},loadScenes:function(){var e=this._gltfJSON.nodes,t=this._gltfJSON.scenes;this._osgjsScene=[];for(var r=0;r<t.length;r++){for(var n=t[r],i=n.nodes,a=[],o=0;o<i.length;o++){var s=e[i[o]];this._linkNodes(s),a.push(s.osgjsNode)}var u=a[0];if(a.length>1){u=new Ar["a"];for(var c=0;c<a.length;c++)u.addChild(a[c])}this._osgjsScene.push(u)}},_assignGeometryAttributes:function(e,t,r){var n=this._gltfJSON.accessors;for(var i in t){var a=t[i],o=n[a],s=jd.ATTRIBUTE_OSGJS_TABLE[i];void 0!==r&&(s+="_"+r.toString()),e.getVertexAttributeList()[s]=o.data,o.data._target=X["a"].ARRAY_BUFFER}},_assignGeometryPrimitives:function(e,t){var r=this._gltfJSON.accessors,n=r[t.indices];n.data._target=X["a"].ELEMENT_ARRAY_BUFFER;var i=void 0!==t.mode?t.mode:Ge["a"].TRIANGLES,a=new ze["a"](i,n.data);e.getPrimitiveSetList().push(a)},_getMorphTargetName:function(e,t){return e.osgjsNodeName+"_target_"+t.toString()},_computeAbsoluteMorphData:function(e,t){var r=this._gltfJSON.accessors;for(var n in t){var i=t[n],a=r[i];if(!a.morphAbsoluteComputed){a.morphAbsoluteComputed=!0;for(var o=e[n],s=r[o],u=s.data.getElements(),c=a.data.getElements(),l=u.length,h=0;h<l;h++)c[h]+=u[h]}}},_processMorphGeometry:function(e,t){var r=e.primitives[t],n=new Mu["a"],i=new ks["a"];i.setName(e.osgjsNodeName),n.setName(e.osgjsNodeName);for(var a=0;a<r.targets.length;a++){this._computeAbsoluteMorphData(r.attributes,r.targets[a]);var o=this._getMorphTargetName(e,a),s=new Ve["a"];s.setName(o),i.addTarget(o,a),this._assignGeometryAttributes(s,r.targets[a]),n.getMorphTargets().push(s)}this._assignGeometryAttributes(n,r.attributes),this._assignGeometryPrimitives(n,r),n.mergeChildrenVertexAttributeList(),e.osgjsMorphGeometry=n,e.osgjsUpdateMorph=i},loadMeshes:function(){for(var e=this._gltfJSON.meshes,t=this._gltfJSON.materials,r=0;r<e.length;r++){for(var n=e[r],i=n.name,a=[],o=0;o<n.primitives.length;o++){var s=void 0,u=n.primitives[o],c=void 0;if(u.targets&&u.targets.length&&(this._processMorphGeometry(n,o),s=n.osgjsMorphGeometry,c=n.osgjsUpdateMorph),u.attributes.JOINTS_0){var l=new wu["a"];s||(s=new Ve["a"],this._assignGeometryAttributes(s,u.attributes),this._assignGeometryPrimitives(s,u));var h=new ot["a"];s.computeBoundingBox(h),l.setBound(h),l.setSourceGeometry(s),l.mergeChildrenData(),s=l}s||(s=new Ve["a"],this._assignGeometryAttributes(s,u.attributes),this._assignGeometryPrimitives(s,u)),i&&s.setName(i),c&&s.addUpdateCallback(c);var d=t[u.material].osgjsStateSet;s.setStateSet(d),s.setUserData(d.getUserData()),a.push(s)}if(a.length>1){for(var f=new Ar["a"],_=0;_<a.length;_++)f.addChild(a[_]);s=f}n.osgjsGeometry=s}},loadImages:function(){var e=this._gltfJSON.images;if(!e)return U.a.resolve();for(var t=[],r=0;r<e.length;r++){var n=e[r],i=window.decodeURI(n.uri),a=this.loadURI(i).then(function(e){var t=new Ud["a"];t.setImage(e),this.osgjsImage=t}.bind(n));t.push(a)}return U.a.all(t)},_texture:function(e){var t=this._gltfJSON.textures,r=this._gltfJSON.images,n=t[e.index],i=r[n.source];if(n.osgjsTexture)return n.osgjsTexture;var a=new J["default"];if(n.osgjsTexture=a,a.setFlipY(!1),a.setWrapS("REPEAT"),a.setWrapT("REPEAT"),i.osgjsImage){var o=jd.TEXTURE_FORMAT[n.format];a.setImage(i.osgjsImage,o)}return a},_pbrMetallicRoughnessTextureUniforms:function(){var e=this._rootStateSet;if(!e.getUniformList()[jd.ALBEDO_UNIFORM]){var t=Er["a"].createInt(jd.ALBEDO_TEXTURE_UNIT,jd.ALBEDO_UNIFORM),r=Er["a"].createInt(jd.METALLIC_ROUGHNESS_TEXTURE_UNIT,jd.METALLIC_ROUGHNESS_UNIFORM);e.addUniform(t),e.addUniform(r)}},_pbrMetallicRoughness:function(e,t){var r;if(t.setUserData({pbrWorklow:jd.PBR_METAL_MODE}),this._pbrMetallicRoughnessTextureUniforms(),e.baseColorTexture)r=this._texture(e.baseColorTexture),t.setTextureAttributeAndModes(jd.ALBEDO_TEXTURE_UNIT,r);else if(e.baseColorFactor){var n=Er["a"].createFloat4(e.baseColorFactor,"uBaseColorFactor");t.addUniform(n)}if(void 0!==e.metallicFactor){var i=Er["a"].createFloat1(e.metallicFactor,"uMetallicFactor");t.addUniform(i)}if(void 0!==e.roughnessFactor){var a=Er["a"].createFloat1(e.roughnessFactor,"uRoughnessFactor");t.addUniform(a)}e.metallicRoughnessTexture&&(r=this._texture(e.metallicRoughnessTexture),t.setTextureAttributeAndModes(jd.METALLIC_ROUGHNESS_TEXTURE_UNIT,r))},_KHR_materials_pbrSpecularGlossinessTextureUniforms:function(){if(!this._extensions["KHR_materials_pbrSpecularGlossinessTextureUniforms"]){this._extensions["KHR_materials_pbrSpecularGlossinessTextureUniforms"]=!0;var e=this._rootStateSet,t=Er["a"].createInt(jd.DIFFUSE_TEXTURE_UNIT,jd.ALBEDO_UNIFORM),r=Er["a"].createInt(jd.SPECULAR_GLOSSINESS_TEXTURE_UNIT,jd.METALLIC_ROUGHNESS_UNIFORM),n=Er["a"].createInt(jd.SPECULAR_TEXTURE_UNIT,jd.SPECULAR_UNIFORM);e.addUniform(t),e.addUniform(r),e.addUniform(n)}},_KHR_materials_pbrSpecularGlossiness:function(e,t){var r,n;if(t.setUserData({pbrWorklow:jd.PBR_SPEC_MODE}),this._KHR_materials_pbrSpecularGlossinessTextureUniforms(),e.diffuseTexture?(r=this._texture(e.diffuseTexture),t.setTextureAttributeAndModes(jd.DIFFUSE_TEXTURE_UNIT,r)):e.diffuseFactor&&(n=Er["a"].createFloat4(e.diffuseFactor,"uBaseColorFactor"),t.addUniform(n)),e.specularFactor&&(n=Er["a"].createFloat3(e.specularFactor,"uSpecularFactor"),t.addUniform(n)),void 0!==e.glossinessFactor){var i=Er["a"].createFloat(e.glossinessFactor,"uGlossinessFactor");t.addUniform(i)}e.specularGlossinessTexture&&(r=this._texture(e.specularGlossinessTexture),t.setTextureAttributeAndModes(jd.SPECULAR_GLOSSINESS_TEXTURE_UNIT,r))},loadMaterials:function(){var e=this._gltfJSON.materials,t=!1,r=!1,n=this._rootStateSet;n.addUniform(Er["a"].createInt(jd.EMISSIVE_TEXTURE_UNIT,jd.EMISSIVE_UNIFORM)),n.addUniform(Er["a"].createInt(jd.AO_TEXTURE_UNIT,jd.AO_UNIFORM)),n.addUniform(Er["a"].createInt(jd.NORMAL_TEXTURE_UNIT,jd.NORMAL_UNIFORM)),n.addUniform(Er["a"].createFloat3(F["f"].ZERO,"uEmissiveFactor"));for(var i=0;i<e.length;i++){var a,o=e[i],s=new Rr["a"];o.osgjsStateSet=s,o.pbrMetallicRoughness?this._pbrMetallicRoughness(o.pbrMetallicRoughness,s):o.extensions.KHR_materials_pbrSpecularGlossiness&&this._KHR_materials_pbrSpecularGlossiness(o.extensions.KHR_materials_pbrSpecularGlossiness,s),o.normalTexture&&(a=this._texture(o.normalTexture),s.setTextureAttributeAndModes(jd.NORMAL_TEXTURE_UNIT,a)),o.occlusionTexture&&(a=this._texture(o.occlusionTexture),s.setTextureAttributeAndModes(jd.AO_TEXTURE_UNIT,a)),o.emissiveTexture&&(a=this._texture(o.emissiveTexture),s.setTextureAttributeAndModes(jd.EMISSIVE_TEXTURE_UNIT,a)),o.emissiveFactor&&s.addUniform(Er["a"].createFloat3(o.emissiveFactor,"uEmissiveFactor")),"BLEND"===o.alphaMode&&(t=!0,s.setAttributeAndModes(this._transparentBlendFunc),s.setRenderingHint("TRANSPARENT_BIN")),o.doubleSided&&(r=!0,s.setAttributeAndModes(this._doubleSideCullFace))}t&&n.setAttributeAndModes(this._defaultBlendFunc),r&&n.setAttributeAndModes(this._defaultCullFace)},_createBone:function(e){var t=this._gltfJSON.nodes,r=t[e];r.usedAsBone=!0;var n=this._nodeAnimationTypes,i=new Ws["a"],a=r.osgjsNodeName;i.setName(a);var o=this._computeNodeMatrix(r)||F["c"].IDENTITY;i.setMatrix(o);var s=new Bs["a"];if(s.setName(i.getName()),i.addUpdateCallback(s),n[e]){var u=s.getStackedTransforms();for(var c in n[e]){var l=jd.TYPE_STACKED_TRANSFORMS[c],h=new l(c);u.push(h)}}return s.setMatrix(o),i},_createMatrixTransform:function(e){var t=this._gltfJSON.nodes,r=t[e],n=this._nodeAnimationTypes,i=new Be["a"],a=r.osgjsNodeName;i.setName(a);var o=this._computeNodeMatrix(r)||F["c"].IDENTITY;if(i.setMatrix(o),n[e]){var s=new Us["a"];s.setName(i.getName()),i.addUpdateCallback(s),s.setMatrix(o);var u=s.getStackedTransforms();for(var c in n[e]){var l=jd.TYPE_STACKED_TRANSFORMS[c],h=new l(c);u.push(h)}}return i},_processSkin:function(e){var t,r,n=this._gltfJSON.skins,i=this._gltfJSON.nodes,a=n[e],o=a.joints;void 0!==a.inverseBindMatrices&&(t=this._gltfJSON.accessors[a.inverseBindMatrices].data,r=t.getElements().buffer);var s,u=new Nu["a"];a.osgjsNode=u,u.setName("skin ID "+e);for(var c,l,h={},d={},f=0;f<o.length;f++){if(s=o[f],l=this._createBone(s),void 0!==a.inverseBindMatrices){var _=new Float32Array(r,16*f*4,16);l.setInvBindMatrixInSkeletonSpace(_)}h[s]=l,d[l.getName()]=f}for(var p in a.osgjsBoneMapID=d,h){c=i[p];var g=c.parent;if(l=h[p],void 0===g||-1===o.indexOf(g))u.addChild(l);else{var m=h[g];m.addChild(l)}}},loadAnimations:function(){var e=this._gltfJSON.animations;if(e){for(var t=this._gltfJSON.accessors,r=this._nodeAnimationTypes,n=this._gltfJSON.nodes,i=this._gltfJSON.meshes,a=[],o=0;o<e.length;o++){for(var s=e[o].channels,u=e[o].samplers,c=[],l=0;l<s.length;l++){var h=s[l],d=u[h.sampler],f=t[d.input].data.getElements(),_=t[d.output],p=_.data.getElements(),g=h.target,m=jd.TYPE_CHANNEL_PATH[g.path][_.type],v=void 0!==g.node?g.node:g.id,b=n[v],S=g.path,x=n[v].osgjsNodeName;if("weights"===S)for(var T=i[b.mesh],y=T.primitives[0].targets.length,C=f.length,A=0;A<y;A++){for(var E=new Float32Array(C),R=0;R<C;R++)E[R]=p[R*y+A];x=this._getMorphTargetName(T,A),c.push(m(E,f,x,A))}else c.push(m(p,f,x,S));r[v]||(r[v]={}),r[v][S]=!0}var M="animation-"+o.toString();a.push(xs.createAnimation(c,M))}var w=new Hs;w.init(a),this._animationManager=w}},loadURI:U.a.method((function(e,t){if("data:"===e.substr(0,5))return Hd(e);var r=this._filesMap[e];return void 0!==r?r:Si["a"].requestURI(e,t)})),readNodeURL:function(e,t){var r=this;if(this.init(),t&&void 0!==t.filesMap&&Object.keys(t.filesMap).length>0){this._filesMap=t.filesMap;var n=this._filesMap[e];return this.readJSON(n,e)}var i=e.lastIndexOf("/");return this._localPath=-1===i?"":e.substr(0,i+1),Si["a"].requestURI(e).then((function(e){return r.readJSON(e)}))},readJSON:U.a.method((function(e,t){return this._gltfJSON=e,U.a.all([this.loadBuffers(),this.loadImages()]).then(function(){this.loadBufferViews(),this.loadAccessors(),this._preProcessNodes(),this.loadMaterials(),this.loadMeshes(),this.loadAnimations(),this.loadSkins(),this.loadNodes(),this.loadScenes();var e=new Be["a"];return e.addChild(this._osgjsScene[0]),e.setName(t),this._animationManager&&e.addUpdateCallback(this._animationManager),e.setStateSet(this._rootStateSet),e}.bind(this))}))},eh["a"].instance().addReaderWriter("gltf",new jd);var Wd=jd,Xd=window.JSZip,qd=function(){this._options=void 0,this._filesMap={},this._fileName=""};qd.prototype={readNodeURL:function(e,t){if(void 0===Xd)return L["a"].error("You need to add JSZip as a dependency"),U.a.reject(this);L["a"].log("starting to read: "+e);var r=this;if(t&&void 0!==t.filesMap&&void 0!==t.filesMap[e]){var n=t.filesMap[e];return this.readZipFile(n).then((function(){return r._fileName?Aa["default"].readNodeURL(r._fileName,{filesMap:r._filesMap}):U.a.reject(r)}))}var i=Si["a"].requestURI(e,{responseType:"blob"});return i.then((function(e){r.readZipFile(e).then((function(){return Aa["default"].readNodeURL(r._fileName,{filesMap:r._filesMap})}))}))},readZipFile:function(e){Si["a"].unzip(e).then(function(e){for(var t in e){var r=Si["a"].getExtension(t),n=eh["a"].instance().getReaderWriterForExtension(r);if(void 0!==n||"osgjs"===r){this._fileName=t;break}}}.bind(this))}},eh["a"].instance().addReaderWriter("zip",new qd);var Yd=qd,Kd=gs.createQuatChannel,Jd=gs.createVec3Channel,Zd=gs.createFloatChannel,Qd=function(){this._filesMap=void 0,this._loadedFiles=void 0,this._bufferViewCache=void 0,this._basicAnimationManager=void 0,this._visitedNodes=void 0,this._animatedNodes=void 0,this._bones=void 0,this._skeletonToInfluenceMap=void 0,this._inputImgReader=void 0,this._localPath="",this._extensions=[],this._nodeAnimationTypes=void 0,this.init()};function $d(e){try{return new U.a((function(t,r){var n=new Request(e,{credentials:"include"});fetch(n).then((function(e){200!==e.status&&0!==e.status||e.arrayBuffer().then((function(e){t(e)}))}))}))}catch(t){console.error("Error decoding string:",t)}return new Uint8Array(0)}Qd.WEBGL_COMPONENT_TYPES={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Qd.TYPE_TABLE={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Qd.ATTRIBUTE_OSGJS_TABLE={POSITION:"Vertex",NORMAL:"Normal",TANGENT:"Tangent",TEXCOORD_0:"TexCoord0",TEXCOORD_1:"TexCoord1",TEXCOORD_2:"TexCoord2",TEXCOORD_3:"TexCoord3",TEXCOORD_4:"TexCoord4",TEXCOORD_5:"TexCoord5",TEXCOORD_6:"TexCoord6",TEXCOORD_7:"TexCoord7",TEXCOORD_8:"TexCoord8",TEXCOORD_9:"TexCoord9",TEXCOORD_10:"TexCoord10",TEXCOORD_11:"TexCoord11",TEXCOORD_12:"TexCoord12",TEXCOORD_13:"TexCoord13",TEXCOORD_14:"TexCoord14",TEXCOORD_15:"TexCoord15",COLOR_0:"Color",JOINTS_0:"Bones",WEIGHTS_0:"Weights"},Qd.TEXTURE_FORMAT={6406:J["default"].ALPHA,6407:J["default"].RGB,6408:J["default"].RGBA,6409:J["default"].LUMINANCE,6410:J["default"].LUMINANCE_ALPHA},Qd.TYPE_CHANNEL_PATH={translation:{VEC3:Jd},scale:{VEC3:Jd},rotation:{VEC4:Kd},weights:{SCALAR:Zd}},Qd.TYPE_STACKED_TRANSFORMS={translation:Gu,scale:Uu,rotation:Lu},Qd.PBR_SPEC_EXT="KHR_materials_pbrSpecularGlossiness",Qd.PBR_SPEC_MODE="PBR_specular_glossiness",Qd.PBR_METAL_MODE="PBR_metal_roughness",Qd.ALBEDO_TEXTURE_UNIT=2,Qd.DIFFUSE_TEXTURE_UNIT=2,Qd.SPECULAR_GLOSSINESS_TEXTURE_UNIT=3,Qd.METALLIC_ROUGHNESS_TEXTURE_UNIT=3,Qd.SPECULAR_TEXTURE_UNIT=4,Qd.NORMAL_TEXTURE_UNIT=5,Qd.AO_TEXTURE_UNIT=6,Qd.EMISSIVE_TEXTURE_UNIT=7,Qd.ALBEDO_UNIFORM="albedoMap",Qd.METALLIC_ROUGHNESS_UNIFORM="metallicRoughnessMap",Qd.SPECULAR_UNIFORM="specularMap",Qd.NORMAL_UNIFORM="normalMap",Qd.AO_UNIFORM="aoMap",Qd.EMISSIVE_UNIFORM="emissiveMap",Qd.prototype={init:function(){this._glTFJSON=void 0,this._nodeAnimationTypes=[],this._bufferViewCache={},this._basicAnimationManager=void 0,this._localPath="",this._visitedNodes={},this._animatedNodes={},this._bones={},this._skeletonToInfluenceMap={},this._stateSetMap={},this._filesMap={},this._inputReader=new Ul["a"],this._rootStateSet=new Rr["a"],this._defaultBlendFunc=new De["a"],this._transparentBlendFunc=new De["a"]("SRC_ALPHA","ONE_MINUS_SRC_ALPHA"),this._defaultCullFace=new Fe["a"],this._doubleSideCullFace=new Fe["a"](Fe["a"].DISABLE)},_preProcessNodes:function(){for(var e,t=this._gltfJSON.nodes,r=this._gltfJSON.meshes,n=0;n<t.length;n++){var i=t[n];e=i.name||"",e+="_"+n.toString(),i.osgjsNodeName=e;var a=i.children;if(a)for(var o=0;o<a.length;o++){var s=a[o];t[s].parent=n}}for(var u=0;u<r.length;u++){var c=r[u];e=c.name||"",e+="_"+u.toString(),c.osgjsNodeName=e}},loadBuffers:U.a.method((function(){for(var e=[],t=this._gltfJSON.buffers,r=0;r<t.length;r++){var n=t[r];e.push(this.loadURI(n.uri,{responseType:"arraybuffer"}).then((function(e){n.data=e})))}return U.a.all(e)})),loadBufferViews:function(){for(var e=this._gltfJSON.buffers,t=this._gltfJSON.bufferViews,r=0;r<t.length;r++){var n=t[r],i=n.buffer,a=e[i],o=n.byteLength||0,s=n.byteOffset||0;n.data=a.data.slice(s,s+o)}},loadAccessors:function(){for(var e=this._gltfJSON.bufferViews,t=this._gltfJSON.accessors,r=0;r<t.length;r++){var n,i=t[r],a=i.bufferView,o=e[a],s=Qd.TYPE_TABLE[i.type],u=Qd.WEBGL_COMPONENT_TYPES[i.componentType],c=u.BYTES_PER_ELEMENT,l=c*s,h=o.byteStride,d=!0===i.normalized;if(h&&h!==l)L["a"].warn("GLTF interleaved accessors not supported");else{var f=new u(o.data,i.byteOffset,i.count*s);n=new X["a"](void 0,f,s),n.setNormalize(d)}i.data=n}},_computeNodeMatrix:function(e){var t;if(e.matrix)t=F["c"].clone(e.matrix);else if(e.translation||e.rotation||e.scale){var r=F["c"].IDENTITY,n=F["c"].IDENTITY,i=F["c"].IDENTITY;e.translation&&(r=F["c"].fromTranslation(F["c"].create(),e.translation)),e.rotation&&(n=F["c"].fromQuat(F["c"].create(),e.rotation)),e.scale&&(i=F["c"].fromScaling(F["c"].create(),e.scale)),t=F["c"].create(),F["c"].multiply(t,n,i),F["c"].multiply(t,r,t)}return t},loadNodes:function(){for(var e=this._gltfJSON.nodes,t=this._gltfJSON.skins,r=this._gltfJSON.meshes,n=0;n<e.length;n++){var i=e[n];if(!i.usedAsBone){if(void 0!==i.skin){var a=t[i.skin],o=a.osgjsNode;a.osgjsNodeAttached||(i.osgjsNode=o,a.osgjsNodeAttached=n);var s=r[i.mesh];s.osgjsGeometry.setBoneNameID(a.osgjsBoneMapID),o.addChild(s.osgjsGeometry)}else(i.matrix||i.translation||i.rotation||i.scale)&&(i.osgjsNode=this._createMatrixTransform(n)),void 0!==i.mesh&&(i.osgjsNode?i.osgjsNode.addChild(r[i.mesh].osgjsGeometry):i.osgjsNode=r[i.mesh].osgjsGeometry),i.osgjsNode||(i.osgjsNode=new Ar["a"]);i.name&&i.osgjsNode.setName(i.name)}}},_linkNodes:function(e){var t=this._gltfJSON.nodes,r=e.children;if(r)for(var n=0;n<r.length;n++){var i=t[r[n]];if(!i.usedAsBone){var a=i.osgjsNode;a&&!e.osgjsNode.hasChild(a)&&(e.osgjsNode.addChild(a),this._linkNodes(i))}}},loadSkins:function(){var e=this._gltfJSON.skins;if(e)for(var t=0;t<e.length;t++)this._processSkin(t)},loadScenes:function(){var e=this._gltfJSON.nodes,t=this._gltfJSON.scenes;this._osgjsScene=[];for(var r=0;r<t.length;r++){for(var n=t[r],i=n.nodes,a=[],o=0;o<i.length;o++){var s=e[i[o]];this._linkNodes(s),a.push(s.osgjsNode)}var u=a[0];if(a.length>1){u=new Ar["a"];for(var c=0;c<a.length;c++)u.addChild(a[c])}this._osgjsScene.push(u)}},_assignGeometryAttributes:function(e,t,r){var n=this._gltfJSON.accessors;for(var i in t){var a=t[i],o=n[a],s=Qd.ATTRIBUTE_OSGJS_TABLE[i];void 0!==r&&(s+="_"+r.toString()),e.getVertexAttributeList()[s]=o.data,o.data._target=X["a"].ARRAY_BUFFER}},_assignGeometryPrimitives:function(e,t){var r=this._gltfJSON.accessors,n=r[t.indices];n.data._target=X["a"].ELEMENT_ARRAY_BUFFER;var i=void 0!==t.mode?t.mode:Ge["a"].TRIANGLES,a=new ze["a"](i,n.data);e.getPrimitiveSetList().push(a)},_getMorphTargetName:function(e,t){return e.osgjsNodeName+"_target_"+t.toString()},_computeAbsoluteMorphData:function(e,t){var r=this._gltfJSON.accessors;for(var n in t){var i=t[n],a=r[i];if(!a.morphAbsoluteComputed){a.morphAbsoluteComputed=!0;for(var o=e[n],s=r[o],u=s.data.getElements(),c=a.data.getElements(),l=u.length,h=0;h<l;h++)c[h]+=u[h]}}},_processMorphGeometry:function(e,t){var r=e.primitives[t],n=new Mu["a"],i=new ks["a"];i.setName(e.osgjsNodeName),n.setName(e.osgjsNodeName);for(var a=0;a<r.targets.length;a++){this._computeAbsoluteMorphData(r.attributes,r.targets[a]);var o=this._getMorphTargetName(e,a),s=new Ve["a"];s.setName(o),i.addTarget(o,a),this._assignGeometryAttributes(s,r.targets[a]),n.getMorphTargets().push(s)}this._assignGeometryAttributes(n,r.attributes),this._assignGeometryPrimitives(n,r),n.mergeChildrenVertexAttributeList(),e.osgjsMorphGeometry=n,e.osgjsUpdateMorph=i},loadMeshes:function(){for(var e=this._gltfJSON.meshes,t=this._gltfJSON.materials,r=0;r<e.length;r++){for(var n=e[r],i=n.name,a=[],o=0;o<n.primitives.length;o++){var s=void 0,u=n.primitives[o],c=void 0;if(u.targets&&u.targets.length&&(this._processMorphGeometry(n,o),s=n.osgjsMorphGeometry,c=n.osgjsUpdateMorph),u.attributes.JOINTS_0){var l=new wu["a"];s||(s=new Ve["a"],this._assignGeometryAttributes(s,u.attributes),this._assignGeometryPrimitives(s,u));var h=new ot["a"];s.computeBoundingBox(h),l.setBound(h),l.setSourceGeometry(s),l.mergeChildrenData(),s=l}s||(s=new Ve["a"],this._assignGeometryAttributes(s,u.attributes),this._assignGeometryPrimitives(s,u)),i&&s.setName(i),c&&s.addUpdateCallback(c);var d=t[u.material].osgjsStateSet;s.setStateSet(d),s.setUserData(d.getUserData()),a.push(s)}if(a.length>1){for(var f=new Ar["a"],_=0;_<a.length;_++)f.addChild(a[_]);s=f}n.osgjsGeometry=s}},loadImages:function(){var e=this._gltfJSON.images;if(!e)return U.a.resolve();for(var t=[],r=0;r<e.length;r++){var n=e[r];if(n.uri){var i=window.decodeURI(n.uri),a=this.loadURI(i).then(function(e){var t=new Ud["a"];t.setImage(e),this.osgjsImage=t}.bind(n));t.push(a)}}return U.a.all(t)},_texture:function(e){var t=this._gltfJSON.textures,r=this._gltfJSON.images,n=t[e.index],i=r[n.source];if(n.osgjsTexture)return n.osgjsTexture;var a=new J["default"];if(n.osgjsTexture=a,a.setFlipY(!1),a.setWrapS("REPEAT"),a.setWrapT("REPEAT"),i.osgjsImage){var o=Qd.TEXTURE_FORMAT[n.format];a.setImage(i.osgjsImage,o)}return a},_pbrMetallicRoughnessTextureUniforms:function(){var e=this._rootStateSet;if(!e.getUniformList()[Qd.ALBEDO_UNIFORM]){var t=Er["a"].createInt(Qd.ALBEDO_TEXTURE_UNIT,Qd.ALBEDO_UNIFORM),r=Er["a"].createInt(Qd.METALLIC_ROUGHNESS_TEXTURE_UNIT,Qd.METALLIC_ROUGHNESS_UNIFORM);e.addUniform(t),e.addUniform(r)}},_pbrMetallicRoughness:function(e,t){var r;if(t.setUserData({pbrWorklow:Qd.PBR_METAL_MODE}),this._pbrMetallicRoughnessTextureUniforms(),e.baseColorTexture)r=this._texture(e.baseColorTexture),t.setTextureAttributeAndModes(Qd.ALBEDO_TEXTURE_UNIT,r);else if(e.baseColorFactor){var n=Er["a"].createFloat4(e.baseColorFactor,"uBaseColorFactor");t.addUniform(n)}if(void 0!==e.metallicFactor){var i=Er["a"].createFloat1(e.metallicFactor,"uMetallicFactor");t.addUniform(i)}if(void 0!==e.roughnessFactor){var a=Er["a"].createFloat1(e.roughnessFactor,"uRoughnessFactor");t.addUniform(a)}e.metallicRoughnessTexture&&(r=this._texture(e.metallicRoughnessTexture),t.setTextureAttributeAndModes(Qd.METALLIC_ROUGHNESS_TEXTURE_UNIT,r))},_KHR_materials_pbrSpecularGlossinessTextureUniforms:function(){if(!this._extensions["KHR_materials_pbrSpecularGlossinessTextureUniforms"]){this._extensions["KHR_materials_pbrSpecularGlossinessTextureUniforms"]=!0;var e=this._rootStateSet,t=Er["a"].createInt(Qd.DIFFUSE_TEXTURE_UNIT,Qd.ALBEDO_UNIFORM),r=Er["a"].createInt(Qd.SPECULAR_GLOSSINESS_TEXTURE_UNIT,Qd.METALLIC_ROUGHNESS_UNIFORM),n=Er["a"].createInt(Qd.SPECULAR_TEXTURE_UNIT,Qd.SPECULAR_UNIFORM);e.addUniform(t),e.addUniform(r),e.addUniform(n)}},_KHR_materials_pbrSpecularGlossiness:function(e,t){var r,n;if(t.setUserData({pbrWorklow:Qd.PBR_SPEC_MODE}),this._KHR_materials_pbrSpecularGlossinessTextureUniforms(),e.diffuseTexture?(r=this._texture(e.diffuseTexture),t.setTextureAttributeAndModes(Qd.DIFFUSE_TEXTURE_UNIT,r)):e.diffuseFactor&&(n=Er["a"].createFloat4(e.diffuseFactor,"uBaseColorFactor"),t.addUniform(n)),e.specularFactor&&(n=Er["a"].createFloat3(e.specularFactor,"uSpecularFactor"),t.addUniform(n)),void 0!==e.glossinessFactor){var i=Er["a"].createFloat(e.glossinessFactor,"uGlossinessFactor");t.addUniform(i)}e.specularGlossinessTexture&&(r=this._texture(e.specularGlossinessTexture),t.setTextureAttributeAndModes(Qd.SPECULAR_GLOSSINESS_TEXTURE_UNIT,r))},loadMaterials:function(){var e=this._gltfJSON.materials,t=!1,r=!1,n=this._rootStateSet;n.addUniform(Er["a"].createInt(Qd.EMISSIVE_TEXTURE_UNIT,Qd.EMISSIVE_UNIFORM)),n.addUniform(Er["a"].createInt(Qd.AO_TEXTURE_UNIT,Qd.AO_UNIFORM)),n.addUniform(Er["a"].createInt(Qd.NORMAL_TEXTURE_UNIT,Qd.NORMAL_UNIFORM)),n.addUniform(Er["a"].createFloat3(F["f"].ZERO,"uEmissiveFactor"));for(var i=0;i<e.length;i++){var a,o=e[i],s=new Rr["a"];o.osgjsStateSet=s,o.pbrMetallicRoughness?this._pbrMetallicRoughness(o.pbrMetallicRoughness,s):o.extensions.KHR_materials_pbrSpecularGlossiness&&this._KHR_materials_pbrSpecularGlossiness(o.extensions.KHR_materials_pbrSpecularGlossiness,s),o.normalTexture&&(a=this._texture(o.normalTexture),s.setTextureAttributeAndModes(Qd.NORMAL_TEXTURE_UNIT,a)),o.occlusionTexture&&(a=this._texture(o.occlusionTexture),s.setTextureAttributeAndModes(Qd.AO_TEXTURE_UNIT,a)),o.emissiveTexture&&(a=this._texture(o.emissiveTexture),s.setTextureAttributeAndModes(Qd.EMISSIVE_TEXTURE_UNIT,a)),o.emissiveFactor&&s.addUniform(Er["a"].createFloat3(o.emissiveFactor,"uEmissiveFactor")),"BLEND"===o.alphaMode&&(t=!0,s.setAttributeAndModes(this._transparentBlendFunc),s.setRenderingHint("TRANSPARENT_BIN")),o.doubleSided&&(r=!0,s.setAttributeAndModes(this._doubleSideCullFace))}t&&n.setAttributeAndModes(this._defaultBlendFunc),r&&n.setAttributeAndModes(this._defaultCullFace)},_createBone:function(e){var t=this._gltfJSON.nodes,r=t[e];r.usedAsBone=!0;var n=this._nodeAnimationTypes,i=new Ws["a"],a=r.osgjsNodeName;i.setName(a);var o=this._computeNodeMatrix(r)||F["c"].IDENTITY;i.setMatrix(o);var s=new Bs["a"];if(s.setName(i.getName()),i.addUpdateCallback(s),n[e]){var u=s.getStackedTransforms();for(var c in n[e]){var l=Qd.TYPE_STACKED_TRANSFORMS[c],h=new l(c);u.push(h)}}return s.setMatrix(o),i},_createMatrixTransform:function(e){var t=this._gltfJSON.nodes,r=t[e],n=this._nodeAnimationTypes,i=new Be["a"],a=r.osgjsNodeName;i.setName(a);var o=this._computeNodeMatrix(r)||F["c"].IDENTITY;if(i.setMatrix(o),n[e]){var s=new Us["a"];s.setName(i.getName()),i.addUpdateCallback(s),s.setMatrix(o);var u=s.getStackedTransforms();for(var c in n[e]){var l=Qd.TYPE_STACKED_TRANSFORMS[c],h=new l(c);u.push(h)}}return i},_processSkin:function(e){var t,r,n=this._gltfJSON.skins,i=this._gltfJSON.nodes,a=n[e],o=a.joints;void 0!==a.inverseBindMatrices&&(t=this._gltfJSON.accessors[a.inverseBindMatrices].data,r=t.getElements().buffer);var s,u=new Nu["a"];a.osgjsNode=u,u.setName("skin ID "+e);for(var c,l,h={},d={},f=0;f<o.length;f++){if(s=o[f],l=this._createBone(s),void 0!==a.inverseBindMatrices){var _=new Float32Array(r,16*f*4,16);l.setInvBindMatrixInSkeletonSpace(_)}h[s]=l,d[l.getName()]=f}for(var p in a.osgjsBoneMapID=d,h){c=i[p];var g=c.parent;if(l=h[p],void 0===g||-1===o.indexOf(g))u.addChild(l);else{var m=h[g];m.addChild(l)}}},loadAnimations:function(){var e=this._gltfJSON.animations;if(e){for(var t=this._gltfJSON.accessors,r=this._nodeAnimationTypes,n=this._gltfJSON.nodes,i=this._gltfJSON.meshes,a=[],o=0;o<e.length;o++){for(var s=e[o].channels,u=e[o].samplers,c=[],l=0;l<s.length;l++){var h=s[l],d=u[h.sampler],f=t[d.input].data.getElements(),_=t[d.output],p=_.data.getElements(),g=h.target,m=Qd.TYPE_CHANNEL_PATH[g.path][_.type],v=void 0!==g.node?g.node:g.id,b=n[v],S=g.path,x=n[v].osgjsNodeName;if("weights"===S)for(var T=i[b.mesh],y=T.primitives[0].targets.length,C=f.length,A=0;A<y;A++){for(var E=new Float32Array(C),R=0;R<C;R++)E[R]=p[R*y+A];x=this._getMorphTargetName(T,A),c.push(m(E,f,x,A))}else c.push(m(p,f,x,S));r[v]||(r[v]={}),r[v][S]=!0}var M="animation-"+o.toString();a.push(xs.createAnimation(c,M))}var w=new Hs;w.init(a),this._animationManager=w}},loadURI:U.a.method((function(e,t){if("data:"===e.substr(0,5))return $d(e);var r=this._filesMap[e];return void 0!==r?r:Si["a"].requestURI(e,t)})),readNodeURL:function(e,t){var r=this;if(this.init(),t&&void 0!==t.filesMap&&Object.keys(t.filesMap).length>0){this._filesMap=t.filesMap;var n=this._filesMap[e];return this.readJSON(n,e)}var i=e.lastIndexOf("/");return this._localPath=-1===i?"":e.substr(0,i+1),Si["a"].requestURI(e).then((function(e){return r.readJSON(e)}))},readJSON:U.a.method((function(e,t){return"string"==typeof e&&(e=JSON.parse(e)),this._gltfJSON=e,U.a.all([this.loadBuffers(),this.loadImages()]).then(function(){this.loadBufferViews(),this.loadAccessors(),this._preProcessNodes(),this.loadMaterials(),this.loadMeshes(),this.loadAnimations(),this.loadSkins(),this.loadNodes(),this.loadScenes();var e=new Be["a"];return e.addChild(this._osgjsScene[0]),e.setName(t),this._animationManager&&e.addUpdateCallback(this._animationManager),e.setStateSet(this._rootStateSet),e}.bind(this))}))},eh["a"].instance().addReaderWriter("queen",new Qd);var ef=Qd,tf={};tf.ReaderWriterGLTF=Wd,tf.ReaderWriterZIP=Yd,tf.ReaderWriterQueen=ef;var rf=tf;function nf(){var e=Aa["default"].readNodeURL("/dotqueen/dotqueen.queen");return"string"==typeof e?(console.error(e),null):e}window.osgPlugins=rf;var af=Object(u["i"])({setup:function(e){function t(){return Object(u["h"])("div",null,[Object(u["g"])(".queen文件加载")])}return Object(u["r"])((function(){nf()})),function(){return Object(u["h"])("div",{class:of},[t()])}}}),of="cwonz6i";n("c0cf");var sf=[{path:"/",name:"preview",component:kd},{path:"/dotqueen",name:"dotqueen",component:af}],uf=Object(c["a"])({history:Object(c["b"])(),routes:sf}),cf=uf,lf=Object(u["i"])({setup:function(){return function(){return Object(u["h"])(Object(u["w"])("router-view"),null,null)}}}),hf=Object(u["f"])(lf);hf.use(cf),hf.mount("#app")},3453:function(e,t,r){"use strict";var n=r("02b4"),i=function(){this._keys=new n["a"],this._map={}};i.prototype={reset:function(){for(var e=this._keys.getArray(),t=this._keys.getLength(),r=0;r<t;r++){var n=e[r];this._map[n]=void 0}this._keys.reset()},set:function(e,t){this._keys.push(e),this._map[e]=t},hasKey:function(e){return void 0!==this._map[e]},getMap:function(){return this._map},getKeys:function(){return this._keys},forEach:function(e){for(var t=this._keys.getArray(),r=this._keys.getLength(),n=0;n<r;n++){var i=t[n];e(i,this._map[i])}}},t["a"]=i},3714:function(e,t,r){"use strict";r("a434"),r("fb6a");var n=r("b797"),i=r("40fc"),a=r("ecf1"),o=r("a741"),s=r("23f5"),u=r("5a16"),c=r("3972"),l=r("1ca0"),h=r("c489"),d=r("ede0"),f=function(){i["a"].call(this),this.children=[],this._parents=[],this.nodeMask=-1,this._boundingSphere=new o["a"],this._boundingSphereComputed=!1,this._boundingBox=new a["a"],this._boundingBoxComputed=!1,this._updateCallbacks=[],this._cullCallback=void 0,this._cullingActive=!0,this._numChildrenWithCullingDisabled=0,this._numChildrenRequiringUpdateTraversal=0,this._tmpBox=new a["a"]},_=new l["a"](c["c"].create),p=function(){var e=_.getOrCreateObject();return c["c"].identity(e)};n["a"].createPrototypeNode(f,n["a"].objectInherit(i["a"].prototype,{getOrCreateStateSet:function(){return this.stateset||this.setStateSet(new s["a"]),this.stateset},getStateSet:function(){return this.stateset},accept:function(e){e.validNodeMask(this)&&(e.pushOntoNodePath(this),e.apply(this),e.popFromNodePath())},dirtyBound:function(){if(!0===this._boundingSphereComputed||!0===this._boundingBoxComputed){this._boundingSphereComputed=!1,this._boundingBoxComputed=!1;for(var e=this._parents,t=0,r=e.length;t<r;t++)e[t].dirtyBound()}},setNodeMask:function(e){this.nodeMask=e},getNodeMask:function(){return this.nodeMask},setStateSet:function(e){if(this.stateset!==e){var t=0;this.stateset&&(this.stateset.requiresUpdateTraversal()&&t--,this.stateset.removeParent(this)),e&&(e.addParent(this),e.requiresUpdateTraversal()&&++t),0!==t&&this.setNumChildrenRequiringUpdateTraversal(this.getNumChildrenRequiringUpdateTraversal()+t),this.stateset=e}},_updateNumChildrenRequeringUpdateTraversal:function(e){if(0===this._numChildrenRequiringUpdateTraversal&&this._parents.length)for(var t=0,r=this._parents.length;t<r;t++){var n=this._parents[t],i=n.getNumChildrenRequiringUpdateTraversal();n.setNumChildrenRequiringUpdateTraversal(i+e)}},setNumChildrenRequiringUpdateTraversal:function(e){if(this._numChildrenRequiringUpdateTraversal!==e){if(!this._updateCallbacks.length&&this._parents.length){var t=0;if(this._numChildrenRequiringUpdateTraversal>0&&--t,e>0&&++t,0!==t)for(var r=this._parents,n=0,i=r.length;n<i;n++){var a=r[n],o=a.getNumChildrenRequiringUpdateTraversal();a.setNumChildrenRequiringUpdateTraversal(o+t)}}this._numChildrenRequiringUpdateTraversal=e}},getNumChildrenRequiringUpdateTraversal:function(){return this._numChildrenRequiringUpdateTraversal},getUpdateCallback:function(){return this._updateCallbacks[0]},addUpdateCallback:function(e){var t=Boolean(this._updateCallbacks.length);this._updateCallbacks.push(e),t||this._updateNumChildrenRequeringUpdateTraversal(1)},removeUpdateCallback:function(e){var t=this._updateCallbacks.indexOf(e);-1!==t&&(this._updateCallbacks.splice(t,1),this._updateCallbacks.length||this._updateNumChildrenRequeringUpdateTraversal(-1))},getUpdateCallbackList:function(){return this._updateCallbacks},setCullCallback:function(e){this._cullCallback=e},getCullCallback:function(){return this._cullCallback},hasChild:function(e){for(var t=0,r=this.children.length;t<r;t++)if(this.children[t]===e)return!0;return!1},addChild:function(e){if(-1===this.children.indexOf(e))return this.children.push(e),e.addParent(this),this.dirtyBound(),(e.getNumChildrenRequiringUpdateTraversal()>0||e.getUpdateCallbackList().length)&&this.setNumChildrenRequiringUpdateTraversal(this.getNumChildrenRequiringUpdateTraversal()+1),(e.getNumChildrenWithCullingDisabled()>0||!1===e.getCullingActive())&&this.setNumChildrenWithCullingDisabled(this.getNumChildrenWithCullingDisabled()+1),e},getChildren:function(){return this.children},getNumChildren:function(){return this.children.length},getChild:function(e){return this.children[e]},getParents:function(){return this._parents},addParent:function(e){this._parents.push(e)},removeParents:function(){this._parents=[]},removeParent:function(e){var t=this._parents.indexOf(e);-1!==t&&this._parents.splice(t,1)},removeChildren:function(){var e=this.children,t=e.length;if(t){for(var r=0,n=0;n<t;n++){var i=e[n];i.removeParent(this),(i.getNumChildrenRequiringUpdateTraversal()>0||i.getUpdateCallbackList().length)&&++r}e.length=0,r&&this.setNumChildrenRequiringUpdateTraversal(this.getNumChildrenRequiringUpdateTraversal()-r),this.dirtyBound()}},removeChild:function(e){var t=this.children,r=t.indexOf(e);-1!==r&&(e.removeParent(this),t.splice(r,1),this.dirtyBound(),(e.getNumChildrenRequiringUpdateTraversal()>0||e.getUpdateCallbackList().length)&&this.setNumChildrenRequiringUpdateTraversal(this.getNumChildrenRequiringUpdateTraversal()-1))},traverse:function(e){for(var t=this.children,r=0,n=t.length;r<n;r++){var i=t[r];i.accept(e)}},ascend:function(e){for(var t=this._parents,r=0,n=t.length;r<n;r++){var i=t[r];i.accept(e)}},getBoundingBox:function(){return this._boundingBoxComputed||(this.computeBoundingBox(this._boundingBox),this._boundingBoxComputed=!0),this._boundingBox},computeBoundingBox:function(e){var t=r("bade").default,n=t.instance=t.instance||new t;return n.setNodeMaskOverride(-1),n.reset(),n.apply(this),e.copy(n.getBoundingBox()),e},getBoundingSphere:function(){return this.getBound()},getBound:function(){return this._boundingSphereComputed||(this.computeBoundingSphere(this._boundingSphere),this._boundingSphereComputed=!0),this._boundingSphere},computeBoundingSphere:function(e){var t,r,n=this.children,i=n.length;if(e.init(),0===i)return e;var a=this._tmpBox;for(a.init(),r=0;r<i;r++)t=n[r],t.referenceFrame!==d["a"].ABSOLUTE_RF&&a.expandByBoundingSphere(t.getBound());if(!a.valid())return e;for(e.set(a.center(e.center()),0),r=0;r<i;r++)t=n[r],t.referenceFrame!==d["a"].ABSOLUTE_RF&&e.expandRadiusBySphere(t.getBound());return e},getWorldMatrices:function(){var e=function(){this.nodePaths=[],this.halt=void 0,u["a"].call(this,u["a"].TRAVERSE_PARENTS)};e.prototype=n["a"].objectInherit(u["a"].prototype,{reset:function(){this.nodePath.length=0,this.nodePaths.length=0},apply:function(e){0===e._parents.length||e===this.halt||e.referenceFrame===d["a"].ABSOLUTE_RF?this.nodePaths.push(this.nodePath.slice(0)):this.traverse(e)}});var t=new e;return t.setNodeMaskOverride(-1),function(e,r){t.reset(),t.halt=e,this.accept(t);for(var n=[],i=r||c["c"].create,a=0,o=t.nodePaths.length;a<o;a++){var s=t.nodePaths[a],u=i();0!==s.length&&h["a"].computeLocalToWorld(s,!0,u),n.push(u)}return n}}(),getWorldMatrix:function(e,t){var r=this.getWorldMatrices(e,p);return 0===r.length?c["c"].identity(t):c["c"].copy(t,r[0]),_.reset(),t},setCullingActive:function(e){if(this._cullingActive!==e){if(0===this._numChildrenWithCullingDisabled&&this._parents.length>0){var t=0;if(this._cullingActive||--t,e||++t,0!==t)for(var r=0,n=this._parents.length;r<n;r++)this._parents[r].setNumChildrenWithCullingDisabled(this._parents[r].getNumChildrenWithCullingDisabled()+t)}this._cullingActive=e}},getCullingActive:function(){return this._cullingActive},isCullingActive:function(){return 0===this._numChildrenWithCullingDisabled&&this._cullingActive&&this.getBound().valid()},setNumChildrenWithCullingDisabled:function(e){if(this._numChildrenWithCullingDisabled!==e){if(this._cullingActive&&this._parents.length>0){var t=0;if(this._numChildrenWithCullingDisabled>0&&--t,e>0&&++t,0!==t)for(var r=0,n=this._parents.length;r<n;r++)this._parents[r].setNumChildrenWithCullingDisabled(this._parents[r].getNumChildrenWithCullingDisabled()+t)}this._numChildrenWithCullingDisabled=e}},getNumChildrenWithCullingDisabled:function(){return this._numChildrenWithCullingDisabled},releaseGLObjects:function(){void 0!==this.stateset&&this.stateset.releaseGLObjects()}}),"osg","Node"),t["a"]=f},3769:function(e,t,r){"use strict";var n=r("b797"),i=r("3714"),a=r("ede0"),o=r("3972"),s=function(){i["a"].call(this),this.setCullingActive(!1),this._light=void 0,this._referenceFrame=a["a"].RELATIVE_RF};n["a"].createPrototypeNode(s,n["a"].objectInherit(i["a"].prototype,{getLight:function(){return this._light},setLight:function(e){this._light=e},setReferenceFrame:function(e){this._referenceFrame=e},getReferenceFrame:function(){return this._referenceFrame},computeBoundingSphere:function(){var e=o["f"].create();return function(t){if(i["a"].prototype.computeBoundingSphere.call(this,t),void 0!==this._light&&this._referenceFrame===a["a"].RELATIVE_RF){var r=this._light.getPosition();0!==r[3]&&t.expandByVec3(o["f"].scale(e,r,1/r[3]))}return t}}()}),"osg","LightSource"),t["a"]=s},"37be":function(e,t,r){"use strict";r("d3b7"),r("cfc3"),r("907a"),r("9a8c"),r("a975"),r("735e"),r("c1ac"),r("d139"),r("3a7b"),r("d5d6"),r("82f8"),r("e91f"),r("60bd"),r("5f96"),r("3280"),r("3fcc"),r("ca91"),r("25a1"),r("cd26"),r("3c5d"),r("2954"),r("649e"),r("219c"),r("170b"),r("b39a"),r("72f7");var n=r("b797"),i=r("5a16"),a=r("9946"),o=r("e74e"),s=r("2857"),u=r("23f5"),c=r("3972"),l=r("2ba4"),h=r("c247"),d=r("06c5"),f=r("6ec8"),_=r("16f6"),p=r("032c"),g=r("9f78"),m=function(){h["a"].apply(this,arguments)},v=h["a"].cloneStateAttributeConfig(h["a"]);v.textureAttribute=[],v.attribute=["PointSize","Morph","Skinning"],h["a"].setStateAttributeConfig(m,v),n["a"].createPrototypeObject(m,n["a"].objectInherit(h["a"].prototype,{getCompilerName:function(){return"CompilerDebugGeometry"},initTextureAttributes:function(){},createFragmentShaderGraph:function(){var e=this.getNode("glFragColor");return this.getNode("SetAlpha").inputs({color:this.getOrCreateUniform("vec3","uColorDebug"),alpha:this.createVariable("float").setValue("1.0")}).outputs({result:e}),[e]}}),"osgUtil","CompilerColorGeometry");var b=function(){l["a"].apply(this,arguments),this.setShaderCompiler(m)};n["a"].createPrototypeObject(b,n["a"].objectInherit(l["a"].prototype,{}),"osgUtil","ShaderGeneratorCompilerColorGeometry");var S=function(){h["a"].apply(this,arguments)},x=h["a"].cloneStateAttributeConfig(h["a"]);x.textureAttribute=[],h["a"].setStateAttributeConfig(S,x),n["a"].createPrototypeObject(S,n["a"].objectInherit(h["a"].prototype,{getCompilerName:function(){return"CompilerDebugSkinning"},initTextureAttributes:function(){},createFragmentShaderGraph:function(){var e=this.getNode("glFragColor");return this.getNode("SetAlpha").inputs({color:this.getOrCreateVarying("vec3","vBonesColor"),alpha:this.createVariable("float").setValue("1.0")}).outputs({result:e}),[e]},declareVertexVaryings:function(e){var t=this.getOrCreateVarying("vec3","vBonesColor");return this.getNode("SetFromNode").inputs(this.getOrCreateAttribute("vec3","BonesColor")).outputs(t),h["a"].prototype.declareVertexVaryings.call(this,e)}}),"osgUtil","CompilerColorSkinning");var T=function(){l["a"].apply(this,arguments),this.setShaderCompiler(S)};n["a"].createPrototypeObject(T,n["a"].objectInherit(l["a"].prototype,{}),"osgUtil","ShaderGeneratorCompilerColorSkinning");var y=function(){i["a"].call(this),this._debugColor=!0,this._debugSkinning=!1,this._stCenter=new u["a"],this._stCenter.setShaderGeneratorName("debugGeometry")};y.CompilerColorGeometry=m,y.ShaderGeneratorCompilerColorGeometry=b,y.CompilerSkinningGeometry=S,y.ShaderGeneratorCompilerColorSkinning=T,n["a"].createPrototypeObject(y,n["a"].objectInherit(i["a"].prototype,{setGeometryDebug:function(e){this._stCenter.setAttributeAndModes(new g["a"](g["a"].ALWAYS)),this._debugColor=!0,this._debugSkinning=!1,this.apply(e)},setSkinningDebug:function(e){this._stCenter.setAttributeAndModes(new g["a"](g["a"].NEVER)),this._debugColor=!1,this._debugSkinning=!0,this.apply(e)},disableDebug:function(e){this._stCenter.setAttributeAndModes(new g["a"](g["a"].NEVER)),this._debugColor=!1,this._debugSkinning=!1,this.apply(e)},_debugCenterGeometry:function(e,t){var r=e.getBound(),n=new Float32Array(18),i=.1*r.radius();n[0]=i,n[3]=-i,n[7]=i,n[10]=-i,n[14]=i,n[17]=-i;var o=new a["a"];o.getAttributes().Vertex=new d["a"](d["a"].ARRAY_BUFFER,n,3);var u=new f["a"](_["a"].LINES,0,6);o.getPrimitives().push(u);var l=new p["a"],h=r.center();l.getMatrix()[12]=h[0],l.getMatrix()[13]=h[1],l.getMatrix()[14]=h[2],l.addChild(o),this.nodePath[this.nodePath.length-2].addChild(l),t=c["f"].fromValues(.8*t[0],.8*t[1],.8*t[2]),o.getOrCreateStateSet().addUniform(s["a"].createFloat3(t,"uColorDebug")),l.setStateSet(this._stCenter),l._isCenterDebug=!0},_debugRigGeometry:function(e){var t=e.getVertexAttributeList();if(!t.BonesColor){for(var r=t.Bones.getElements(),n=t.Weights.getElements(),i=e._rigTransformImplementation._bones,a=r.length/4,o=new Float32Array(3*a),s=0;s<a;++s){var u=4*s,c=i[r[u]].getOrCreateDebugColor(),l=i[r[u+1]].getOrCreateDebugColor(),h=i[r[u+2]].getOrCreateDebugColor(),f=i[r[u+3]].getOrCreateDebugColor(),_=n[u],p=n[u+1],g=n[u+2],m=n[u+3],v=3*s;o[v]=_*c[0]+p*l[0]+g*h[0]+m*f[0],o[v+1]=_*c[1]+p*l[1]+g*h[1]+m*f[1],o[v+2]=_*c[2]+p*l[2]+g*h[2]+m*f[2]}t.BonesColor=new d["a"](d["a"].ARRAY_BUFFER,o,3)}},_debugGeometry:function(e){var t=this._debugColor,r=this._debugSkinning&&e instanceof o["a"];if(t||r){void 0===e._originalStateSet&&(e._originalStateSet=e.getStateSet()||null);var n=new u["a"];if(e.setStateSet(n),r)return n.setShaderGeneratorName("debugSkinning"),void this._debugRigGeometry(e);var i=c["f"].fromValues(Math.random(),Math.random(),Math.random());n.addUniform(s["a"].createFloat3(i,"uColorDebug")),n.setShaderGeneratorName("debugGeometry"),this._debugCenterGeometry(e,i)}else void 0!==e._originalStateSet&&e.setStateSet(e._originalStateSet||void 0)},apply:function(e){e._isNormalDebug||e._isCenterDebug||(e instanceof a["a"]&&this._debugGeometry(e),this.traverse(e))}}),"osgUtil","GeometryColorDebugVisitor"),t["a"]=y},"38f3":function(e,t,r){"use strict";r("d3b7"),r("ddb0");var n=r("b797"),i=r("2449"),a=r("1391"),o=r("3972"),s=r("8130"),u=r("ede0"),c=function e(){i["a"].call(this),a["a"].call(this),this.viewport=void 0,this._graphicContext=void 0,this._scissor=void 0,this.setClearColor(o["g"].fromValues(0,0,0,1)),this.setClearDepth(1),this.setClearMask(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT),this.setViewMatrix(o["c"].create()),this.setProjectionMatrix(o["c"].create()),this.renderOrder=e.NESTED_RENDER,this.renderOrderNum=0,this._view=void 0,this._renderer=void 0,this._attachments={}};c.PRE_RENDER=0,c.NESTED_RENDER=1,c.POST_RENDER=2,c.COLOR_BUFFER_BIT=16384,c.DEPTH_BUFFER_BIT=256,c.STENCIL_BUFFER_BIT=1024,n["a"].createPrototypeNode(c,n["a"].objectInherit(a["a"].prototype,n["a"].objectInherit(i["a"].prototype,{getView:function(){return this._view},setView:function(e){this._view=e},getRenderer:function(){return this._renderer},setRenderer:function(e){this._renderer=e},setFinalDrawCallback:function(e){this._finalDrawCallback=e},getFinalDrawCallback:function(){return this._finalDrawCallback},setInitialDrawCallback:function(e){this._initialDrawCallback=e},getInitialDrawCallback:function(){return this._initialDrawCallback},getAttachments:function(){return this._attachments},setGraphicContext:function(e){this._graphicContext=e},getGraphicContext:function(){return this._graphicContext},setClearDepth:function(e){this.clearDepth=e},getClearDepth:function(){return this.clearDepth},setClearMask:function(e){this.clearMask=e},getClearMask:function(){return this.clearMask},setClearColor:function(e){this.clearColor=e},getClearColor:function(){return this.clearColor},setViewport:function(e){this.viewport=e,this.getOrCreateStateSet().setAttributeAndModes(e)},getViewport:function(){return this.viewport},setScissor:function(e){this._scissor=e,this.getOrCreateStateSet().setAttributeAndModes(this._scissor)},getScissor:function(){return this._scissor},setViewMatrix:function(e){this.modelviewMatrix=e},setViewMatrixAsLookAt:function(e,t,r){o["c"].lookAt(this.getViewMatrix(),e,t,r)},setProjectionMatrix:function(e){this.projectionMatrix=e},setProjectionMatrixAsOrtho:function(e,t,r,n,i,a){o["c"].ortho(this.getProjectionMatrix(),e,t,r,n,i,a)},isRenderToTextureCamera:function(){return window.Object.keys(this._attachments).length>0},getViewMatrix:function(){return this.modelviewMatrix},getProjectionMatrix:function(){return this.projectionMatrix},getRenderOrder:function(){return this.renderOrder},setRenderOrder:function(e,t){this.renderOrder=e,this.renderOrderNum=t},getFrameBufferObject:function(){return this.frameBufferObject},setFrameBufferObject:function(e){this.frameBufferObject=e},detachAll:function(){this._attachments={},this.frameBufferObject&&this.frameBufferObject.dirty()},resetAttachments:function(){this.frameBufferObject&&(this.frameBufferObject.reset(),this.frameBufferObject=0),this._attachments={}},attachTexture:function(e,t,r){this.frameBufferObject&&this.frameBufferObject.dirty(),r||(r=s["default"].TEXTURE_2D),this._attachments[e]={attachment:e,texture:t,textureTarget:r}},attachRenderBuffer:function(e,t){this.frameBufferObject&&this.frameBufferObject.dirty(),this._attachments[e]={format:t,attachment:e}},computeLocalToWorldMatrix:function(e){return this.referenceFrame===u["a"].RELATIVE_RF?o["c"].mul(e,e,this.modelviewMatrix):o["c"].copy(e,this.modelviewMatrix),!0},computeWorldToLocalMatrix:function(){var e=o["c"].create();return function(t){return o["c"].invert(e,this.modelviewMatrix),this.referenceFrame===u["a"].RELATIVE_RF?o["c"].mul(t,e,t):o["c"].copy(t,e),!0}}()})),"osg","Camera"),t["a"]=c},3972:function(e,t,r){"use strict";r.d(t,"a",(function(){return i})),r.d(t,"b",(function(){return l})),r.d(t,"c",(function(){return c})),r.d(t,"d",(function(){return h})),r.d(t,"e",(function(){return o})),r.d(t,"f",(function(){return s})),r.d(t,"g",(function(){return u}));r("d3b7"),r("cfc3"),r("907a"),r("9a8c"),r("a975"),r("735e"),r("c1ac"),r("d139"),r("3a7b"),r("d5d6"),r("82f8"),r("e91f"),r("60bd"),r("5f96"),r("3280"),r("3fcc"),r("ca91"),r("25a1"),r("cd26"),r("3c5d"),r("2954"),r("649e"),r("219c"),r("170b"),r("b39a"),r("72f7"),r("4a9b");var n=r("1881"),i=r("fc98"),a={ArrayType:Float64Array};i["glMatrix"].setMatrixArrayType(a.ArrayType),i["glMatrix"].EPSILON=1e-9;var o=i["vec2"],s=i["vec3"],u=i["vec4"],c=i["mat4"],l=i["mat3"],h=i["quat"];s.create32=function(){return new Float32Array(3)},s.create64=function(){return new Float64Array(3)},s.fromValues32=function(e,t,r){var n=new Float32Array(3);return n[0]=e,n[1]=t,n[2]=r,n},s.fromValues64=function(e,t,r){var n=new Float64Array(3);return n[0]=e,n[1]=t,n[2]=r,n},s.init=function(e){return s.set(e,0,0,0)},s.transformMat4Rotate=function(e,t,r){var n=t[0],i=t[1],a=t[2];return e[0]=r[0]*n+r[1]*i+r[2]*a,e[1]=r[4]*n+r[5]*i+r[6]*a,e[2]=r[8]*n+r[9]*i+r[10]*a,e},s.valid=function(e){return!n["a"].isNaN(e[0])&&(!n["a"].isNaN(e[1])&&!n["a"].isNaN(e[2]))},s.neg=s.negate,s.ZERO=s.create(),s.ONE=s.fromValues(1,1,1),s.INFINITY=s.fromValues(1/0,1/0,1/0),s.NEGATIVE_INFINITY=s.fromValues(-1/0,-1/0,-1/0),o.create32=function(){return new Float32Array(2)},o.create64=function(){return new Float64Array(2)},o.fromValues32=function(e,t){var r=new Float32Array(2);return r[0]=e,r[1]=t,r},o.fromValues64=function(e,t){var r=new Float64Array(2);return r[0]=e,r[1]=t,r},o.init=function(e){return o.set(e,0,0)},o.valid=function(e){return!n["a"].isNaN(e[0])&&!n["a"].isNaN(e[1])},o.abs=function(e,t){return e[0]=Math.abs(t[0]),e[1]=Math.abs(t[1]),e},o.ZERO=o.create(),o.ONE=o.fromValues(1,1),o.INFINITY=o.fromValues(1/0,1/0),o.NEGATIVE_INFINITY=o.fromValues(-1/0,-1/0),u.create32=function(){return new Float32Array(4)},u.create64=function(){return new Float64Array(4)},u.fromValues32=function(e,t,r,n){var i=new Float32Array(4);return i[0]=e,i[1]=t,i[2]=r,i[3]=n,i},u.fromValues64=function(e,t,r,n){var i=new Float64Array(4);return i[0]=e,i[1]=t,i[2]=r,i[3]=n,i},u.init=function(e){return u.set(e,0,0,0,0)},u.valid=function(e){return!n["a"].isNaN(e[0])&&(!n["a"].isNaN(e[1])&&(!n["a"].isNaN(e[2])&&!n["a"].isNaN(e[3])))},u.neg=u.negate,u.ZERO=u.create(),u.ONE=u.fromValues(1,1,1,1),u.INFINITY=u.fromValues(1/0,1/0,1/0,1/0),u.NEGATIVE_INFINITY=u.fromValues(-1/0,-1/0,-1/0,-1/0),h.IDENTITY=h.create(),h.zeroRotation=function(e){return 0===e[0]&&0===e[1]&&0===e[2]&&1===e[3]},h.create32=function(){var e=new Float32Array(4);return e[3]=1,e},h.create64=function(){var e=new Float64Array(4);return e[3]=1,e},h.fromEuler=function(e,t,r,n){var i=.5*Math.PI/180;t*=i,r*=i,n*=i;var a=Math.sin(t),o=Math.cos(t),s=Math.sin(r),u=Math.cos(r),c=Math.sin(n),l=Math.cos(n);return e[0]=a*u*l-o*s*c,e[1]=o*s*l+a*u*c,e[2]=o*u*c-a*s*l,e[3]=o*u*l+a*s*c,e},h.getEulerDeprecated=function(e,t){var r=t[0],n=t[1],i=t[2],a=t[3],o=r*r,s=n*n,u=i*i,c=a*a,l=o+s+u+c,h=r*a-n*i;return h>.499995*l?(e[0]=Math.PI/2,e[1]=2*Math.atan2(n,r),e[2]=0):h<-.499995*l?(e[0]=-Math.PI/2,e[1]=2*Math.atan2(n,r),e[2]=0):(e[0]=Math.asin(2*(r*i-a*n)),e[1]=Math.atan2(2*(r*a+n*i),1-2*(u+c)),e[2]=Math.atan2(2*(r*n+i*a),1-2*(s+u))),e},h.getEuler=function(e,t){var r,n,i,a=t[0],o=t[1],s=t[2],u=t[3],c=2*(u*o-a*s);return c<=-.99999?(r=2*Math.atan2(a,u),n=-Math.PI/2,i=0):c>=.99999?(r=2*Math.atan2(a,u),n=Math.PI/2,i=0):(r=Math.atan2(2*(u*a+o*s),1-2*(a*a+o*o)),n=Math.asin(c),i=Math.atan2(2*(u*s+a*o),1-2*(o*o+s*s))),e[0]=180*r/Math.PI,e[1]=180*n/Math.PI,e[2]=180*i/Math.PI,e},h.fromValues32=u.fromValues32,h.fromValues64=u.fromValues64,h.init=h.identity,h.nlerp=function(e,t,r,n){var i,a,o,s,u=t[0],c=t[1],l=t[2],h=t[3],d=r[0],f=r[1],_=r[2],p=r[3],g=u*d+c*f+l*_+h*p,m=1-n;g<0?(i=u*m-d*n,a=c*m-f*n,o=l*m-_*n,s=h*m-p*n):(i=u*m+d*n,a=c*m+f*n,o=l*m+_*n,s=h*m+p*n);var v=1/Math.sqrt(i*i+a*a+o*o+s*s);return e[0]=i*v,e[1]=a*v,e[2]=o*v,e[3]=s*v,e},l.IDENTITY=l.create(),l.create32=function(){var e=new Float32Array(9);return e[0]=e[4]=e[8]=1,e},l.create64=function(){var e=new Float64Array(9);return e[0]=e[4]=e[8]=1,e},c.IDENTITY=c.create(),c.create32=function(){var e=new Float32Array(16);return e[0]=e[5]=e[10]=e[15]=1,e},c.create64=function(){var e=new Float64Array(16);return e[0]=e[5]=e[10]=e[15]=1,e},c.setTranslation=function(e,t){return e[12]=t[0],e[13]=t[1],e[14]=t[2],e},c.getFrustum=function(e,t){var r,n,i=0,a=0,o=0,s=0;if(0!==t[3]||0!==t[7]||-1!==t[11]||0!==t[15])return!1;var u=t[14]/(t[10]-1),c=t[14]/(1+t[10]);return a=u*(t[8]-1)/t[0],i=u*(1+t[8])/t[0],o=u*(1+t[9])/t[5],s=u*(t[9]-1)/t[5],r=u,n=c,e.left=a,e.right=i,e.top=o,e.bottom=s,e.zNear=r,e.zFar=n,!0},c.getPerspective=function(){var e={right:0,left:0,top:0,bottom:0,zNear:0,zFar:0};return function(t,r){var n=c.getFrustum(e,r);return n&&(t.fovy=180/Math.PI*(Math.atan(e.top/e.zNear)-Math.atan(e.bottom/e.zNear)),t.aspectRatio=(e.right-e.left)/(e.top-e.bottom)),t.zNear=e.zNear,t.zFar=e.zFar,t}}(),c.getLookAt=function(){var e=c.create(),t=s.create(),r=s.fromValues(0,1,0),n=s.fromValues(0,0,-1);return function(i,a,o,u,l){var h=void 0!==l?l:1;c.invert(e,u),c.getTranslation(i,e),s.transformMat4Rotate(o,r,u),s.transformMat4Rotate(a,n,u),s.normalize(a,a),s.add(a,s.scale(t,a,h),i)}}(),c.getFrustumPlanes=function(){var e=c.create();return function(t,r,n,i){c.mul(e,r,n);var a=!!i,o=t[0];o[0]=e[3]-e[0],o[1]=e[7]-e[4],o[2]=e[11]-e[8],o[3]=e[15]-e[12];var s=t[1];s[0]=e[3]+e[0],s[1]=e[7]+e[4],s[2]=e[11]+e[8],s[3]=e[15]+e[12];var u=t[2];u[0]=e[3]+e[1],u[1]=e[7]+e[5],u[2]=e[11]+e[9],u[3]=e[15]+e[13];var l=t[3];l[0]=e[3]-e[1],l[1]=e[7]-e[5],l[2]=e[11]-e[9],l[3]=e[15]-e[13];var h=4;if(a){h=6;var d=t[4];d[0]=e[3]-e[2],d[1]=e[7]-e[6],d[2]=e[11]-e[10],d[3]=e[15]-e[14];var f=t[5];f[0]=e[3]+e[2],f[1]=e[7]+e[6],f[2]=e[11]+e[10],f[3]=e[15]+e[14]}for(var _=0;_<h;_++){var p=t[_],g=1/Math.sqrt(p[0]*p[0]+p[1]*p[1]+p[2]*p[2]);p[0]*=g,p[1]*=g,p[2]*=g,p[3]*=g}}}(),c.infiniteFrustum=function(e,t,r,n,i,a){var o=2*a/(r-t),s=2*a/(i-n),u=(r+t)/(r-t),c=(i+n)/(i-n),l=-1;return e[0]=o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=u,e[9]=c,e[10]=l,e[11]=-1,e[12]=0,e[13]=0,e[14]=-2*a,e[15]=0,e},c.lookAtDirection=function(){var e=s.create(),t=s.create(),r=s.create();return function(n,i,a,o){var u=a;return s.cross(e,u,o),s.normalize(e,e),s.cross(t,e,u),s.normalize(t,t),n[0]=e[0],n[1]=t[0],n[2]=-u[0],n[3]=0,n[4]=e[1],n[5]=t[1],n[6]=-u[1],n[7]=0,n[8]=e[2],n[9]=t[2],n[10]=-u[2],n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,c.translate(n,n,s.neg(r,i))}}(),c.getScale=function(){var e=s.create(),t=s.create(),r=s.create();return function(n,i){return e[0]=i[0],e[1]=i[4],e[2]=i[8],t[0]=i[1],t[1]=i[5],t[2]=i[9],r[0]=i[2],r[1]=i[6],r[2]=i[10],n[0]=s.length(e),n[1]=s.length(t),n[2]=s.length(r),n}}(),c.getSqrScale=function(){var e=s.create(),t=s.create(),r=s.create();return function(n,i){return e[0]=i[0],e[1]=i[4],e[2]=i[8],t[0]=i[1],t[1]=i[5],t[2]=i[9],r[0]=i[2],r[1]=i[6],r[2]=i[10],n[0]=s.sqrLen(e),n[1]=s.sqrLen(t),n[2]=s.sqrLen(r),n}}();var d=c.rotate;c.rotate=function(e,t,r,n){return d(e,t,r,n)||c.identity(e)};var f=c.fromRotation;c.fromRotation=function(e,t,r){return f(e,t,r)||c.identity(e)}},"3d8f":function(e,t,r){"use strict";t["a"]={Vec3:0,Quat:1,Float:2,FloatCubicBezier:3,Vec3CubicBezier:4,QuatSlerp:5,Matrix:6,Count:7}},"3e45":function(e,t,r){"use strict";var n=r("b797"),i=r("123d"),a=r("3972"),o=function(e,t,r,n){i["a"].call(this),this._x=void 0!==e?e:0,this._y=void 0!==t?t:0,this._width=void 0!==r?r:800,this._height=void 0!==n?n:600};n["a"].createPrototypeStateAttribute(o,n["a"].objectInherit(i["a"].prototype,{attributeType:"Viewport",cloneType:function(){return new o},setViewport:function(e,t,r,n){this._x=e,this._y=t,this._width=r,this._height=n},x:function(){return this._x},y:function(){return this._y},width:function(){return this._width},height:function(){return this._height},computeWindowMatrix:function(){var e=a["c"].create(),t=a["c"].create(),r=a["f"].create();return function(n){a["c"].fromTranslation(e,a["f"].ONE),a["c"].fromScaling(t,[.5*this._width,.5*this._height,.5]);var i=a["c"].fromTranslation(n,a["f"].set(r,this._x,this._y,0));return a["c"].mul(i,i,a["c"].mul(t,t,e))}}(),apply:function(e){e.applyViewport(this)}}),"osg","Viewport"),t["a"]=o},"3e4d":function(e,t,r){"use strict";r("d3b7"),r("cfc3"),r("907a"),r("9a8c"),r("a975"),r("735e"),r("c1ac"),r("d139"),r("3a7b"),r("d5d6"),r("82f8"),r("e91f"),r("60bd"),r("5f96"),r("3280"),r("3fcc"),r("ca91"),r("25a1"),r("cd26"),r("3c5d"),r("2954"),r("649e"),r("219c"),r("170b"),r("b39a"),r("72f7");var n=r("b797"),i=r("5a16"),a=r("9946"),o=r("06c5"),s=r("6ec8"),u=r("16f6"),c=r("23f5"),l=r("2857"),h=r("9f78"),d=r("3972"),f=r("2ba4"),_=r("c247"),p=r("e74e"),g=r("9874"),m=r("fce7"),v=function(){_["a"].apply(this,arguments)},b=_["a"].cloneStateAttributeConfig(_["a"]);b.textureAttribute=[],_["a"].setStateAttributeConfig(v,b),n["a"].createPrototypeObject(v,n["a"].objectInherit(_["a"].prototype,{getCompilerName:function(){return"CompilerOffsetNormal"},initTextureAttributes:function(){},createFragmentShaderGraph:function(){var e=this.getNode("glFragColor");return this.getNode("SetAlpha").inputs({color:this.getOrCreateUniform("vec3","uColorDebug"),alpha:this.createVariable("float").setValue("1.0")}).outputs({result:e}),[e]},getOffsetDirection:function(){return this.getOrCreateModelNormal()},getOrCreateModelVertex:function(){var e=this.getVariable("vertexOffset");if(e)return e;e=this.createVariable("vec3","vertexOffset");var t="%out = %offset == 1.0 ? %vertex + normalize(%direction.xyz) * %scale: %vertex;";return this.getNode("InlineCode").code(t).inputs({offset:this.getOrCreateAttribute("float","Offset"),direction:this.getOffsetDirection(),vertex:_["a"].prototype.getOrCreateModelVertex.call(this),scale:this.getOrCreateUniform("float","uScale")}).outputs({out:e}),e},getOrCreateViewVertex:function(){var e=this._variables.FragEyeVector;return e&&!e.isEmpty()||(e=this._varyings.FragEyeVector||this.createVariable("vec4","FragEyeVector"),this.getNode("MatrixMultPosition").inputs({matrix:this.getOrCreateUniform("mat4","uViewMatrix"),vec:this.getOrCreateModelVertex()}).outputs({vec:e})),e}}),"osgUtil","CompilerOffsetNormal");var S=function(){f["a"].apply(this,arguments),this.setShaderCompiler(v)};n["a"].createPrototypeObject(S,n["a"].objectInherit(f["a"].prototype,{}),"osgUtil","ShaderGeneratorCompilerOffsetNormal");var x=function(){v.apply(this,arguments)},T=b;_["a"].setStateAttributeConfig(x,T),n["a"].createPrototypeObject(x,n["a"].objectInherit(v.prototype,{getCompilerName:function(){return"CompilerOffsetTangent"},getOffsetDirection:function(){return this.getOrCreateModelTangent()}}),"osgUtil","CompilerOffsetTangent");var y=function(){f["a"].apply(this,arguments),this.setShaderCompiler(x)};n["a"].createPrototypeObject(y,n["a"].objectInherit(f["a"].prototype,{}),"osgUtil","ShaderGeneratorCompilerOffsetTangent");var C=function(){i["a"].call(this),this._unifScale=l["a"].createFloat(1,"uScale");var e=this._normalStateSet=new c["a"];e.addUniform(l["a"].createFloat3(d["f"].fromValues(1,0,0),"uColorDebug")),e.addUniform(this._unifScale),e.setAttributeAndModes(new h["a"](h["a"].NEVER)),e.setShaderGeneratorName("debugNormal");var t=this._tangentStateSet=new c["a"];t.addUniform(l["a"].createFloat3(d["f"].fromValues(0,1,0),"uColorDebug")),t.addUniform(this._unifScale),t.setAttributeAndModes(new h["a"](h["a"].NEVER)),t.setShaderGeneratorName("debugTangent")};C.CompilerOffsetNormal=v,C.CompilerOffsetTangent=x,C.ShaderGeneratorCompilerOffsetNormal=S,C.ShaderGeneratorCompilerOffsetTangent=y,n["a"].createPrototypeObject(C,n["a"].objectInherit(i["a"].prototype,{setScale:function(e){this._unifScale.setFloat(e)},setTangentVisibility:function(e){this._tangentStateSet.setAttributeAndModes(new h["a"](e?h["a"].LESS:h["a"].NEVER))},setNormalVisibility:function(e){this._normalStateSet.setAttributeAndModes(new h["a"](e?h["a"].LESS:h["a"].NEVER))},apply:function(e){if(!e._isVisitedNormalDebug){if(e._isVisitedNormalDebug=!0,e instanceof a["a"])return this._createDebugGeom(e,"Normal",this._normalStateSet),void this._createDebugGeom(e,"Tangent",this._tangentStateSet);this.traverse(e);for(var t=e.getUpdateCallbackList(),r=0,n=t.length;r<n;++r)t[r]instanceof m["a"]&&t[r].init(e)}},_createDoubleOffsetArray:function(e){for(var t=new Float32Array(2*e),r=0;r<e;++r)t[2*r]=1;return new o["a"](o["a"].ARRAY_BUFFER,t,1)},_createDoubledBufferArray:function(e){e.getInitialBufferArray&&(e=e.getInitialBufferArray());for(var t=e.getItemSize(),r=e.getElements(),n=r.length/t,i=r.constructor,a=new i(2*r.length),s=0;s<n;++s)for(var u=s*t,c=2*u,l=0;l<t;++l)a[c+l]=a[c+l+t]=r[u+l];return new o["a"](o["a"].ARRAY_BUFFER,a,t)},_addMorphTargets:function(e,t,r){var n=t.getMorphTargets();t.setName(e.getName());for(var i=e.getMorphTargets(),o=0,s=i.length;o<s;++o){var u=i[o],c=u.getVertexAttributeList(),l=new a["a"];l.setName(u.getName());var h=l.getVertexAttributeList();h.Vertex=this._createDoubledBufferArray(c.Vertex),c[r]&&(h[r]=this._createDoubledBufferArray(c[r])),n.push(l)}return t.mergeChildrenVertexAttributeList(),t},_createDebugGeom:function(e,t,r){var n=e.getAttributes(),i=n[t];if(i){var o=n.Vertex;if(o){var c;e instanceof g["a"]?c=e:e.getSourceGeometry&&e.getSourceGeometry()instanceof g["a"]&&(c=e.getSourceGeometry());var l,h=o.getElements().length/o.getItemSize(),d=c?new g["a"]:new a["a"];if(d.getAttributes().Vertex=this._createDoubledBufferArray(o),d.getAttributes().Offset=this._createDoubleOffsetArray(h),d.getAttributes()[t]=this._createDoubledBufferArray(i),d.getPrimitives().push(new s["a"](u["a"].LINES,0,2*h)),c&&this._addMorphTargets(c,d,t),e instanceof p["a"]){var f=new p["a"];f.setSourceGeometry(d),f.getVertexAttributeList().Bones=this._createDoubledBufferArray(n.Bones),f.getVertexAttributeList().Weights=this._createDoubledBufferArray(n.Weights),f._rigTransformImplementation=e._rigTransformImplementation,f._stateSetAnimation=e._stateSetAnimation,f.mergeChildrenData(),l=f}else l=d;var _=e.getParents(),m=_.length;l._isVisitedNormalDebug=!0,l._isNormalDebug=!0,l.setStateSet(r);for(var v=0;v<m;++v)_[v].addChild(l);return l}}}}),"osgUtil","DisplayNormalVisitor"),t["a"]=C},"3ee6":function(e,t,r){"use strict";r("d3b7"),r("5cc6"),r("907a"),r("9a8c"),r("a975"),r("735e"),r("c1ac"),r("d139"),r("3a7b"),r("d5d6"),r("82f8"),r("e91f"),r("60bd"),r("5f96"),r("3280"),r("3fcc"),r("ca91"),r("25a1"),r("cd26"),r("3c5d"),r("2954"),r("649e"),r("219c"),r("170b"),r("b39a"),r("72f7");var n=r("a214"),i=function(e){var t=new Uint8Array(e);return 31===t[0]&&139===t[1]},a=function(e){var t=new Uint8Array(e),i=r("a8a2");i||n["a"].error("osg failed to use a gunzip.min.js to uncompress a gz file.\n You can add this vendors to enable this feature or get it at https://github.com/imaya/zlib.js/blob/master/bin/gunzip.min.js");var a=new i.Gunzip(t),o=a.decompress();return o.buffer};t["a"]={isGunzipBuffer:i,gunzip:a}},4066:function(e,t,r){"use strict";r("a434"),r("4e82");var n=r("b797"),i=r("38f3"),a=r("a995"),o=r("a214"),s=r("c77d"),u=r("3972"),c=r("1ca0"),l=function e(){s["a"].call(this),this._clearColor=u["g"].create(),this._clearDepth=void 0,this._clearMask=void 0,this._camera=void 0,this._viewport=void 0,this._scissor=void 0,this._preRenderList=[],this._postRenderList=[],e.prototype.init.call(this)},h=function(){return{renderStage:null,order:null}},d=new c["a"](h);n["a"].createPrototypeObject(l,n["a"].objectInherit(s["a"].prototype,{init:function(){return s["a"].prototype.init.call(this),this._clearDepth=1,u["g"].set(this._clearColor,0,0,0,1),this._clearMask=i["a"].COLOR_BUFFER_BIT|i["a"].DEPTH_BUFFER_BIT,this._camera=void 0,this._viewport=void 0,this._scissor=void 0,this._renderStage=this,l.prototype._initInternal.call(this),this},_initInternal:function(){this._preRenderList.length=0,this._postRenderList.length=0},reset:function(){d.reset(),s["a"].prototype.reset.call(this),l.prototype._initInternal.call(this)},setClearDepth:function(e){this._clearDepth=e},getClearDepth:function(){return this._clearDepth},setClearColor:function(e){u["g"].copy(this._clearColor,e)},getClearColor:function(){return this._clearColor},setClearMask:function(e){this._clearMask=e},getClearMask:function(){return this._clearMask},setViewport:function(e){this._viewport=e},getViewport:function(){return this._viewport},setScissor:function(e){this._scissor=e},getScissor:function(){return this._scissor},setCamera:function(e){this._camera=e},getCamera:function(){return this._camera},getPreRenderStageList:function(){return this._preRenderList},getPostRenderStageList:function(){return this._postRenderList},addPreRenderStage:function(e,t){for(var r=0,n=this._preRenderList.length;r<n;r++){var i=this._preRenderList[r];if(t<i.order)break}var a=d.getOrCreateObject();a.order=t,a.renderStage=e,r<this._preRenderList.length?this._preRenderList.splice(r,0,a):this._preRenderList.push(a)},addPostRenderStage:function(e,t){for(var r=0,n=this._postRenderList.length;r<n;r++){var i=this._postRenderList[r];if(t<i.order)break}var a=d.getOrCreateObject();a.order=t,a.renderStage=e,r<this._postRenderList.length?this._postRenderList.splice(r,0,a):this._postRenderList.push(a)},drawPreRenderStages:function(e,t){for(var r=t,n=0,i=this._preRenderList.length;n<i;++n){var a=this._preRenderList[n].renderStage;r=a.draw(e,r)}return r},draw:function(e,t){this._camera&&this._camera.getInitialDrawCallback()&&this._camera.getInitialDrawCallback()(e);var r=this.drawPreRenderStages(e,t);return r=this.drawImplementation(e,r),r=this.drawPostRenderStages(e,r),this._camera&&this._camera.getFinalDrawCallback()&&this._camera.getFinalDrawCallback()(e),r},sort:function(){for(var e=0,t=this._preRenderList.length;e<t;++e)this._preRenderList[e].renderStage.sort();s["a"].prototype.sort.call(this);for(var r=0,n=this._postRenderList.length;r<n;++r)this._postRenderList[r].renderStage.sort()},drawPostRenderStages:function(e,t){for(var r=t,n=0,i=this._postRenderList.length;n<i;++n){var a=this._postRenderList[n].renderStage;r=a.draw(e,r)}return r},applyCamera:function(e){var t=e.getGraphicContext();if(void 0!==this._camera){var r=this._camera.getViewport(),n=this._camera.frameBufferObject;if(n||(n=new a["a"],this._camera.frameBufferObject=n),n.isDirty()){var i,o,s=this._camera.getAttachments(),u=s[a["a"].COLOR_ATTACHMENT0];for(var c in u&&u.texture&&(i=u.texture.getWidth(),o=u.texture.getHeight()),s){u=s[c];var l={};l.attachment=u.attachment,void 0===u.texture?(l.format=u.format,l.width=void 0!==i?i:r.width(),l.height=void 0!==o?o:r.height()):(l.texture=u.texture,l.textureTarget=u.textureTarget,u.format&&(l.format=u.format)),n.setAttachment(l)}}n.apply(e)}else t.bindFramebuffer(t.FRAMEBUFFER,null)},drawImplementation:function(e,t){var r=e.getGraphicContext();this.applyCamera(e),void 0===this._viewport&&o["a"].log("RenderStage does not have a valid viewport"),e.applyAttribute(this._viewport),this._scissor&&e.applyAttribute(this._scissor),0!==this._clearMask&&(this._clearMask&r.COLOR_BUFFER_BIT&&e.clearColor(this._clearColor),this._clearMask&r.DEPTH_BUFFER_BIT&&(e.depthMask(!0),e.clearDepth(this._clearDepth)),e.clear(this._clearMask)),0!==this._positionedAttribute.getLength()&&this.applyPositionedAttribute(e,this._positionedAttribute);var n=s["a"].prototype.drawImplementation.call(this,e,t);return n}}),"osg","RenderStage"),l.clean=function(){d.clean()},t["a"]=l},"40fc":function(e,t,r){"use strict";var n=r("b797"),i=function e(){this._name=void 0,this._userdata=void 0,this._instanceID=e.getInstanceID()};n["a"].createPrototypeObject(i,{cloneType:function(){var e=this.constructor;return new e},getInstanceID:function(){return this._instanceID},setName:function(e){this._name=e},getName:function(){return this._name},setUserData:function(e){this._userdata=e},getUserData:function(){return this._userdata}},"osg","Object");var a=0;i.getInstanceID=function(){return a+=1,a},t["a"]=i},4119:function(e,t,r){var n=r("7037").default;if(r("d3b7"),r("6062"),r("3ca3"),r("ddb0"),r("4ec9"),r("8a59"),r("907a"),r("9a8c"),r("a975"),r("735e"),r("c1ac"),r("d139"),r("3a7b"),r("d5d6"),r("82f8"),r("e91f"),r("60bd"),r("5f96"),r("3280"),r("3fcc"),r("ca91"),r("25a1"),r("cd26"),r("3c5d"),r("2954"),r("649e"),r("219c"),r("170b"),r("b39a"),r("72f7"),r("2af1"),r("90d7"),r("6b93"),r("8a79"),r("fb6a"),r("2ca0"),r("cfc3"),r("fd87"),r("5cc6"),r("8b09"),r("84c3"),r("143c"),r("fb2c"),r("4a9b"),window.Set&&window.Map&&window.Uint8ClampedArray){if(Math.sign||(Math.sign=function(e){return e>0?1:e<0?-1:0}),Math.log2||(Math.log2=function(e){return Math.log(e)*Math.LOG2E}),Math.log10||(Math.log10=function(e){return Math.log(e)*Math.LOG10E}),String.prototype.endsWith||(String.prototype.endsWith=function(e){return this.slice(-e.length)===e}),String.prototype.startsWith||(String.prototype.startsWith=function(e){return this.slice(0,e.length)===e}),!Float32Array.prototype.slice){var i=function(e,t){return new this.constructor(this.subarray(e,t))};Int8Array.prototype.slice=i,Uint8Array.prototype.slice=i,Uint8ClampedArray.prototype.slice=i,Int16Array.prototype.slice=i,Uint16Array.prototype.slice=i,Int32Array.prototype.slice=i,Uint32Array.prototype.slice=i,Float32Array.prototype.slice=i,Float64Array.prototype.slice=i}var a=new window.Set(["test"]),o=a.has("test");if(!o){var s=window.Set;window.Set=function(e){var t=new s;if(e)for(var r=0;r<e.length;++r)t.add(e[r]);return t}}if("object"===n(window.Event)){function u(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var r=document.createEvent("CustomEvent");return r.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),r}u.prototype=window.Event.prototype,window.Event=u}}},4388:function(e,t,r){"use strict";var n=r("b797"),i=r("3714"),a=r("5a16"),o=r("3972"),s=r("a741"),u=function e(){i["a"].call(this),this._radius=-1,this._range=[],this._rangeMode=e.DISTANCE_FROM_EYE_POINT,this._userDefinedCenter=[],this._centerMode=e.USE_BOUNDING_SPHERE_CENTER};u.DISTANCE_FROM_EYE_POINT=0,u.PIXEL_SIZE_ON_SCREEN=1,u.USE_BOUNDING_SPHERE_CENTER=0,u.USER_DEFINED_CENTER=1,u.UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED=2,n["a"].createPrototypeNode(u,n["a"].objectInherit(i["a"].prototype,{getRadius:function(){return this._radius},setRadius:function(e){this._radius=e},setCenter:function(e){this._centerMode!==u.UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED&&(this._centerMode=u.USER_DEFINED_CENTER),this._userDefinedCenter=e},getCenter:function(){return this._centerMode===u.USER_DEFINED_CENTER||this._centerMode===u.UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED?this._userDefinedCenter:this.getBound().center()},setCenterMode:function(e){this._centerMode=e},computeBoundingSphere:function(e){if(this._centerMode===u.USER_DEFINED_CENTER&&this._radius>=0)return e.set(this._userDefinedCenter,this._radius),e;if(this._centerMode===u.UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED&&this._radius>=0){e.set(this._userDefinedCenter,this._radius);var t=new s["a"];return e.expandByBoundingSphere(i["a"].prototype.computeBoundingSphere.call(this,t)),e}return i["a"].prototype.computeBoundingSphere.call(this,e),e},projectBoundingSphere:function(){var e=o["f"].create();return function(t,r,n){o["f"].transformMat4(e,t.center(),r);var i=t.radius2(),a=e[2]*e[2],s=o["f"].sqrLen(e),u=-Math.PI*n*n*i*Math.sqrt(Math.abs((s-i)/(i-a)))/(i-a);return u}}(),setRangeMode:function(e){this._rangeMode=e},addChildNode:function(e){if(i["a"].prototype.addChild.call(this,e),this.children.length>this._range.length){var t=[],r=0;this._range.lenght>0&&(r=this._range[this._range.length-1][1]),t.push(o["e"].fromValues(r,r)),this._range.push(t)}return!0},addChild:function(e,t,r){if(i["a"].prototype.addChild.call(this,e),this.children.length>this._range.length){var n=[];n.push(o["e"].fromValues(t,t)),this._range.push(n)}return this._range[this.children.length-1][0]=t,this._range[this.children.length-1][1]=r,!0},traverse:function(){var e=o["f"].create(),t=o["f"].create(),r=o["c"].create();return function(n){var i=n.traversalMode;switch(i){case a["a"].TRAVERSE_ALL_CHILDREN:for(var s=0;s<this.children.length;s++)this.children[s].accept(n);break;case a["a"].TRAVERSE_ACTIVE_CHILDREN:var c=0,l=n.getCurrentModelViewMatrix();if(o["c"].invert(r,l),this._rangeMode===u.DISTANCE_FROM_EYE_POINT){o["f"].transformMat4(t,e,r);var h=o["f"].distance(this.getBound().center(),t);c=h*n.getLODScale()}else{var d=n.getCurrentProjectionMatrix();c=this.projectBoundingSphere(this.getBound(),l,d[0]),c=c*n.getViewport().width()*n.getViewport().width()*.25/n.getLODScale()}var f=this.children.length;this._range.length<f&&(f=this._range.length);for(var _=0;_<f;++_)this._range[_][0]<=c&&c<this._range[_][1]&&this.children[_].accept(n);break;default:break}}}()}),"osg","Lod"),t["a"]=u},"4e33":function(e,t,r){},"4e92":function(e,t,r){"use strict";r("d3b7"),r("5cc6"),r("907a"),r("9a8c"),r("a975"),r("735e"),r("c1ac"),r("d139"),r("3a7b"),r("d5d6"),r("82f8"),r("e91f"),r("60bd"),r("5f96"),r("3280"),r("3fcc"),r("ca91"),r("25a1"),r("cd26"),r("3c5d"),r("2954"),r("649e"),r("219c"),r("170b"),r("b39a"),r("72f7"),r("cfc3"),r("84c3");var n=r("a214"),i=r("b797"),a=r("40fc"),o=window.ImageBitmap||function(){},s=function(e){a["a"].call(this),this._imageObject=void 0,this._url=void 0,this._width=void 0,this._height=void 0,this._dirty=!0,this._mipmap=[],e&&this.setImage(e),this._isGreyscale=void 0};i["a"].createPrototypeObject(s,i["a"].objectInherit(a["a"].prototype,{dirty:function(){this._isGreyscale=void 0,this._dirty=!0},isDirty:function(){return this._dirty},setDirty:function(e){this._dirty=e},getImage:function(){return this._imageObject instanceof s?this._imageObject.getImage():this._imageObject},getURL:function(){return this._url},setURL:function(e){this._url=e},useOrCreateImage:function(e){return e instanceof s===!1?new s(e):e},setImage:function(e){if(!this._url&&e&&(e.src||e.currentSrc)&&(this._url=e.src||e.currentSrc),this._mipmap.length=0,Array.isArray(e)){for(var t=0,r=e.length;t<r;t++)this._mipmap.push(this.useOrCreateImage(e[t]));this.setWidth(this._mipmap[0].getWidth()),this.setHeight(this._mipmap[0].getHeight())}else this._mipmap.push(e);this._imageObject=this._mipmap[0],this.dirty()},isCanvas:function(){return this.getImage()instanceof window.HTMLCanvasElement},isBitmap:function(){return this.getImage()instanceof o},isVideo:function(){return this.getImage()instanceof window.HTMLVideoElement},isImage:function(){return this.getImage()instanceof window.Image},isTypedArray:function(){var e=this.getImage();return e instanceof Uint8Array||e instanceof Float32Array||e instanceof Uint16Array},setWidth:function(e){this._width=e},setHeight:function(e){this._height=e},getWidth:function(){var e=this.getImage();return this.isImage()?e.naturalWidth:this.isVideo()?e.videoWidth:this.isCanvas()||this.isBitmap()?e.width:this._width},getHeight:function(){var e=this.getImage();return this.isImage()?e.naturalHeight:this.isVideo()?e.videoHeight:this.isCanvas()||this.isBitmap()?e.height:this._height},isGreyscale:function(e){if(void 0!==this._isGreyscale)return this._isGreyscale;if(void 0!==this._imageObject&&this.isReady()&&void 0===this._isGreyscale){var t=this._imageObject;this.isCanvas()||(t=document.createElement("canvas"));var r,n,i=t.getContext("2d");t.width=this._imageObject.width,t.height=this._imageObject.height,i.drawImage(this._imageObject,0,0),e||(r=t.width,n=t.height),e>0&&(e=Math.min(Math.min(t.width,t.height),e),r=n=e);for(var a=!0,o=t.width/r,s=t.height/n,u=0;u<r;u++)for(var c=0;c<n;c++){var l=Math.floor(o*(u+.5)),h=Math.floor(s*(c+.5)),d=i.getImageData(l,h,1,1).data;if(d[0]!==d[1]||d[0]!==d[2]){a=!1;break}}this._isGreyscale=a}return this._isGreyscale},isReady:function(){if(this._imageObject&&this._imageObject instanceof s)return this._imageObject.isReady();if(this.isCanvas()||this.isTypedArray()||this.isBitmap())return!0;if(this.isImage()){var e=this.getImage();if(e.complete)return void 0===e.naturalWidth||0!==e.naturalWidth}if(this.isVideo()&&0!==this.getWidth())return!0;var t=this.getImage();return t.complete?void 0===t.naturalWidth||0!==t.naturalWidth:(n["a"].warn("Warning can't detect image object "),!1)},getMipmap:function(){return this._mipmap},hasMipmap:function(){return this._mipmap.length>1},release:function(){this._mipmap.length=0,this._imageObject=void 0}}),"osg","Image"),t["a"]=s},"4fd1":function(e,t,r){"use strict";var n=r("b797"),i=r("c247"),a=function(){i["a"].apply(this,arguments)},o=i["a"].cloneStateAttributeConfig(i["a"]);o.attribute=["ShadowCast","Morph","Skinning","PointSize"],i["a"].setStateAttributeConfig(a,o),n["a"].createPrototypeObject(a,n["a"].objectInherit(i["a"].prototype,{getCompilerName:function(){return"ShadowCast"},initAttributes:function(){for(var e=this._attributes,t=0,r=e.length;t<r;t++){var n=e[t].className();"ShadowCastAttribute"===n?this._shadowCastAttribute=e[t]:"Billboard"===n?this._isBillboard=!!e[t]:"SkinningAttribute"===n?this._skinningAttribute=e[t]:"MorphAttribute"===n?this._morphAttribute=e[t]:"PointSizeAttribute"===n&&(this._pointSizeAttribute=e[t])}},registerTextureAttributes:function(){},createShadowCastDepth:function(e){var t=this._shadowCastAttribute.getDefines(),r=this.getNode("ShadowCast").inputs({shadowDepthRange:this.getOrCreateUniform("vec4","uShadowDepthRange"),fragEye:this.getOrCreateViewVertex()}).outputs({result:e});return r.getDefines=function(){return t},e},createFragmentShaderGraph:function(){var e=this.getNode("glFragColor");return[this.createShadowCastDepth(e)]}}),"osgShader","CompilerShadowCast"),t["a"]=a},"5a16":function(e,t,r){"use strict";var n=function e(t){this.traversalMask=-1,this.nodeMaskOverride=0,this.traversalMode=t,void 0===t&&(this.traversalMode=e.TRAVERSE_ALL_CHILDREN),this.nodePath=[],this.visitorType=e.NODE_VISITOR,this._databaseRequestHandler=void 0,this._frameStamp=void 0,this.traverse=e._traversalFunctions[this.traversalMode],this.pushOntoNodePath=e._pushOntoNodePath[this.traversalMode],this.popFromNodePath=e._popFromNodePath[this.traversalMode]};n.TRAVERSE_PARENTS=1,n.TRAVERSE_ALL_CHILDREN=2,n.TRAVERSE_ACTIVE_CHILDREN=3,n.NODE_VISITOR=0,n.UPDATE_VISITOR=1,n.CULL_VISITOR=2;var i=function(e){e.ascend(this)},a=function(e){e.traverse(this)};n._traversalFunctions=[void 0,i,a,a];var o=function(e){this.nodePath.unshift(e)},s=function(e){this.nodePath.push(e)};n._pushOntoNodePath=[void 0,o,s,s];var u=function(){return this.nodePath.shift()},c=function(){this.nodePath.pop()};n._popFromNodePath=[void 0,u,c,c],n.prototype={reset:function(){this.nodePath.length=0},setFrameStamp:function(e){this._frameStamp=e},getFrameStamp:function(){return this._frameStamp},setNodeMaskOverride:function(e){this.nodeMaskOverride=e},getNodeMaskOverride:function(){return this.nodeMaskOverride},setTraversalMask:function(e){this.traversalMask=e},getTraversalMask:function(){return this.traversalMask},getNodePath:function(){return this.nodePath},validNodeMask:function(e){var t=e.getNodeMask();return 0!==(this.traversalMask&(this.nodeMaskOverride|t))},apply:function(e){this.traverse(e)},getVisitorType:function(){return this.visitorType},setDatabaseRequestHandler:function(e){this._databaseRequestHandler=e},getDatabaseRequestHandler:function(){return this._databaseRequestHandler}},t["a"]=n},"5d7a":function(e,t,r){"use strict";r.r(t);r("d3b7"),r("159b");var n=r("c247"),i=r("2ba4"),a=r("a214"),o=r("8155"),s=r("3e4d"),u=r("37be"),c=function(){return this._generators={},this.addShaderGenerator("default",new i["a"]),this.addShaderGenerator("ShadowCast",new o["a"]),this.addShaderGenerator("debugNormal",new s["a"].ShaderGeneratorCompilerOffsetNormal),this.addShaderGenerator("debugTangent",new s["a"].ShaderGeneratorCompilerOffsetTangent),this.addShaderGenerator("debugGeometry",new u["a"].ShaderGeneratorCompilerColorGeometry),this.addShaderGenerator("debugSkinning",new u["a"].ShaderGeneratorCompilerColorSkinning),this};c.prototype={getShaderGenerator:function(e){if(!e)return this._generators.default;var t=this._generators[e];return t||(a["a"].error("ShaderGenerator "+e+" does not exist in ShaderGeneratorProxy"),this._generators.default)},addShaderGenerator:function(e,t){this._generators[e]=t}};var l=c,h=(r("ac1f"),r("5319"),r("1276"),r("d81d"),r("00b4"),r("4de4"),r("4e82"),r("4d63"),r("c607"),r("2c3e"),r("25f0"),r("a15b"),r("466d"),r("a63c")),d=r("d710"),f=r("0fd6"),_=function e(t){if(!t){if(e.instance)return e.instance;e.instance=this}return this.addShaders(h["a"]),this.addShaders(d["a"]),this};_.prototype={_shadersText:{},_shadersList:{},_globalDefaultprecision:"#ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n #else\n precision mediump float;\n#endif",_debugLines:!1,_includeR:/#pragma include "([^"]+)"/g,_includeCondR:/#pragma include (["^+"]?["\ "[a-zA-Z_0-9](.*)"]*?)/g,_defineR:/\#define\s+([a-zA-Z_0-9]+)/,_precisionR:/precision\s+(high|low|medium)p\s+float/,addShaders:function(e){for(var t in e)this._shadersList[t]=t,this._shadersText[t]=e[t]},instrumentShaderlines:function(e,t){return"\n#line 0 "+t+"\n"+e},hasShader:function(e){return void 0!==this._shadersText[e]},getShaderTextPure:function(e){var t=this._shadersText[e];return t||(a["a"].error("shader file/text: "+e+" not registered"),t=""),t},getShader:function(e,t,r,n){var i=this.getShaderTextPure(e);return this.processShader(i,t,r,n)},preprocess:function(e,t,r,n){var i=this;return e.replace(this._includeCondR,function(e,a){var o=a.split(" "),s=o[0].replace(/"/g,"");if(o.length>1&&n){for(var u=!1,c=n.map((function(e){return i._defineR.test(e)&&e.replace(/\s+/g," ").split(" ")[1]})),l=1;l<o.length&&!u;l++)for(var h=o[l].replace(/"/g,""),d=0;d<c.length&&!u;d++)if(!1!==c[d]&&c[d]===h){u=!0;break}if(!u)return""}if(-1!==r.indexOf(s))return"";var f=this.getShaderTextPure(s);return r.push(s),this._debugLines&&(f=this.instrumentShaderlines(f,t)),t++,f=this.preprocess(f,t,r,n),f}.bind(this))},_getSortedUnique:function(){var e=function(e,t,r){return!t||e!==r[t-1]};return function(t){return t&&t.sort().filter(e)}}(),_convertExtensionsToWebGL2:function(){var e=function(e,t){return"core_"+t},t=function(e,t){return"#define "+t},r="(GL_EXT_shader_texture_lod|GL_OES_standard_derivatives|GL_EXT_draw_buffers|GL_EXT_frag_depth)",n=new RegExp("#\\s*extension\\s+"+r+".*","g"),i=new RegExp(r,"g");return function(r){return r=r.replace(n,t),r=r.replace(i,e),r}}(),_convertToWebGL2:function(){var e=[],t=function(t,r){var n="glFragData_"+r;return e[r]="layout(location = "+r+") out vec4 "+n+";",n};return function(r,n){return r?(r=r.replace(/attribute\s+/g,"in "),r=r.replace(/varying\s+/g,n?"in ":"out "),r=r.replace(/(texture2D|textureCube)\s*\(/g,"texture("),r=r.replace(/(textureCubeLodEXT)\s*\(/g,"textureLod("),r=this._convertExtensionsToWebGL2(r),n&&(e.length=0,r=r.replace(/gl_FragData\s*\[\s*(\d+)\s*\]/g,t),e.length||e.push("out vec4 glFragColor_0;"),r=r.replace(/gl_FragColor/g,"glFragColor_0"),r=r.replace(/void\s+main\s*\(/g,e.join("\n")+"\nvoid main(")),r):r}}(),_hasVersion:function(e){var t=e.match(/^#(.*)$/m);return t&&-1!==t[0].indexOf("version")},processShader:function(e,t,r,n){if(this._hasVersion(e))return e;var i=[],a=e,o=0;this._debugLines&&(a=this.instrumentShaderlines(a,o),o++),t=this._getSortedUnique(t),r=this._getSortedUnique(r);var s=this.preprocess(a,o,i,t,n);s=s.replace(/#pragma DECLARE_FUNCTION/g,"//#pragma DECLARE_FUNCTION");var u=-1===s.indexOf("gl_Position"),c=f["a"].instance().isWebGL2(),l=c?"#version 300 es":"#version 100";l+="\n";var h=r?r.join("\n")+"\n":"",d=t?t.join("\n")+"\n":"";c?(h=this._convertExtensionsToWebGL2(h),d=this._convertToWebGL2(d,u),s=this._convertToWebGL2(s,u)):(d=d.replace(/\\\n/g,""),s=s.replace(/\\\n/g,""));var _="";return this._globalDefaultprecision&&!this._precisionR.test(s)&&(_=this._globalDefaultprecision+"\n"),l+h+_+d+s}};var p=_,g=r("8bd2"),m=r("a27e"),v=r("112b"),b=r("f53d"),S={};S.Compiler=n["a"],S.ShaderGenerator=i["a"],S.ShaderGeneratorProxy=l,S.NextShaderProcessor=g["a"],S.ShaderProcessor=p,S.nodeFactory=m["a"],S.utils=b["a"],S.node={},S.node.Node=v["a"],m["a"]._nodes.forEach((function(e,t){S.node[t]=e})),S.debugShaderNode=!1,S.debugShaderNode=!0;t["default"]=S},"5e15":function(e,t,r){"use strict";var n=r("40fc"),i=r("187b"),a=r("b797"),o=r("3972"),s=r("02b4"),u=function(){this._clippingMask=0,this._planeList=[i["a"].create(),i["a"].create(),i["a"].create(),i["a"].create(),i["a"].create(),i["a"].create()],this._vertexList=[],this._maskStack=new s["a"],this._resultMask=0,this._maskStack.push(this._resultMask)};a["a"].createPrototypeObject(u,a["a"].objectInherit(n["a"].prototype,{getPlanes:function(){return this._planeList},setPlanes:function(e){this._planeList=e,this.setupMask()},clear:function(){if(this._clippingMask=0,this._planeList)for(var e=0,t=this._planeList.length;e<t;++e)i["a"].init(this._planeList[e]);this._vertexList=[],this.setupMask()},setToUnitFrustum:function(e,t){void 0===e&&(e=!0),void 0===t&&(t=!0),this._planeList.length=0,this._planeList.push(o["g"].set(i["a"].create(),1,0,0,1)),this._planeList.push(o["g"].set(i["a"].create(),-1,0,0,1)),this._planeList.push(o["g"].set(i["a"].create(),0,1,0,1)),this._planeList.push(o["g"].set(i["a"].create(),0,-1,0,1)),e&&this._planeList.push(o["g"].set(i["a"].create(),0,0,1,1)),t&&this._planeList.push(o["g"].set(i["a"].create(),0,0,-1,1)),this.setupMask()},setToBoundingBox:function(e){this._planeList.length=0,this._planeList.push(o["g"].set(i["a"].create(),1,0,0,-e.getMin()[0])),this._planeList.push(o["g"].set(i["a"].create(),-1,0,0,e.getMax()[0])),this._planeList.push(o["g"].set(i["a"].create(),0,1,0,-e.getMin()[1])),this._planeList.push(o["g"].set(i["a"].create(),0,-1,0,e.getMax()[1])),this._planeList.push(o["g"].set(i["a"].create(),0,0,1,-e.getMin()[2])),this._planeList.push(o["g"].set(i["a"].create(),0,0,-1,e.getMax()[2])),this.setupMask()},setAndTransformProvidingInverse:function(e,t){this._referenceVertexList=e._referenceVertexList;var r=this._maskStack.getLength()-1,n=e._maskStack[r];if(0===n)return this._maskStack.getArray()[r]=0,this._resultMask=0,void(this._planeList.length=0);var a,o=1,s=0;for(a=0;a!==e._planeList.length;++a)n&o&&++s,o<<=1;this._planeList.length=s,this._resultMask=0,o=1;var u=0;for(a=0;a!==e._planeList.length;++a)n&o&&(this._planeList[u]=e._planeList[a],i["a"].transformProvidingInverse(this._planeList[u++],t),this._resultMask=this._resultMask<<1|1),o<<=1;this._maskStack.getArray()[r]=this._resultMask},voidset:function(e){this._planeList=e,this.setupMask()},add:function(e){this._planeList.push(e),this.setupMask()},empty:function(){return 0===this._planeList.length},setReferenceVertexList:function(e){this._referenceVertexList=e},getReferenceVertexList:function(){return this._referenceVertexList},setupMask:function(e){this._resultMask=0;for(var t=void 0!==e?e:this._planeList.length,r=0;r<t;++r)this._resultMask=this._resultMask<<1|1;this._maskStack.reset(),this._maskStack.push(this._resultMask)},getCurrentMask:function(){return this._maskStack.back()},setResultMask:function(e){this._resultMask=e},getResultMask:function(){return this._resultMask},getMaskStack:function(){return this._maskStack},pushCurrentMask:function(){this._maskStack.push(this._resultMask)},popCurrentMask:function(){return this._maskStack.pop()},containsVertex:function(e){var t=this._maskStack.back();if(!t)return!0;for(var r=1,n=0;n<this._planeList.length;++n){if(t&r&&i["a"].distanceToPlane(this._planeList[n],e)<0)return!1;r<<=1}return!0},containsVertices:function(e){var t=this._maskStack.back();if(!t)return!0;this._resultMask=t;for(var r=0;r<e.length;++r){for(var n=e[r],a=!1,o=1,s=0;!a&&s<this._planeList.length;++s)t&o&&i["a"].distanceToPlane(this._planeList[s],n)<0&&(a=!0),o<<=1;if(!a)return!0}return!1},containsBoundingSphere:function(e){var t=this._maskStack.back();if(!t||!e.valid())return!0;this._resultMask=t;for(var r=1,n=0;n<this._planeList.length;++n){if(this._resultMask&r){var a=i["a"].intersectsOrContainsBoundingSphere(this._planeList[n],e);if(i["a"].OUTSIDE===a)return!1;i["a"].INSIDE===a&&(this._resultMask^=r)}r<<=1}return!0},containsBoundingBox:function(e){var t=this._maskStack.back();if(!t)return!0;this._resultMask=t;for(var r=1,n=0;n<this._planeList.length;++n){if(this._resultMask&r){var a=i["a"].intersectsOrContainsBoundingBox(this._planeList[n],e);if(i["a"].OUTSIDE===a)return!1;i["a"].INSIDE===a&&(this._resultMask^=r)}r<<=1}return!0},containsAllOfVertices:function(e){var t=this._maskStack.back();if(!t)return!1;this._resultMask=t;for(var r=1,n=0;n<this._planeList.length;++n){if(this._resultMask&r){var a=i["a"].intersectsOrContainsVertices(this._planeList[n],e);if(a<1)return!1;this._resultMask^=r}r<<=1}return!0},containsAllOfBoundingSphere:function(e){var t=this._maskStack.back();if(!t)return!1;this._resultMask=t;for(var r=1,n=0;n<this._planeList.length;++n){if(this._resultMask&r){var a=i["a"].intersectsOrContainsBoundingSphere(this._planeList[n],e);if(a<1)return!1;this._resultMask^=r}r<<=1}return!0},containsAllOfBoundingBox:function(e){var t=this._maskStack.back();if(!t)return!1;this._resultMask=t;for(var r=1,n=0;n<this._planeList.length;++n){if(this._resultMask&r){var a=i["a"].intersectsOrContainsBoundingBox(this._planeList[n],e);if(a<1)return!1;this._resultMask^=r}r<<=1}return!0},transformProvidingInverse:function(e){var t=this._maskStack.back();if(t){this._resultMask=t;for(var r=1,n=0;n<this._planeList.length;++n)t&r&&i["a"].transformProvidingInverse(this._planeList[n],e),r<<=1}}}),"osg","Polytope"),t["a"]=u},"5f4e":function(e,t,r){},"5f6c":function(e,t,r){"use strict";r("a15b"),r("d3b7"),r("cfc3"),r("907a"),r("9a8c"),r("a975"),r("735e"),r("c1ac"),r("d139"),r("3a7b"),r("d5d6"),r("82f8"),r("e91f"),r("60bd"),r("5f96"),r("3280"),r("3fcc"),r("ca91"),r("25a1"),r("cd26"),r("3c5d"),r("2954"),r("649e"),r("219c"),r("170b"),r("b39a"),r("72f7");var n=r("3972"),i=r("06c5"),a=r("9946"),o=r("16f6"),s=r("6ec8"),u=r("931a"),c=r("c0d6"),l=r("308b"),h=r("b797"),d=function(e,t,r,n,s,c){var l,d,f,_=void 0!==e?e:0,p=void 0!==t?t:0,g=void 0!==r?r:0,m=void 0!==n?n:1,v=void 0!==s?s:1,b=void 0!==c?c:1,S=new a["a"];l=m/2,d=v/2,f=b/2;var x=new h["a"].Float32Array(72),T=new h["a"].Float32Array(48),y=new h["a"].Float32Array(72);x[0]=_-l,x[1]=p-d,x[2]=g+f,y[0]=0,y[1]=-1,y[2]=0,T[0]=0,T[1]=1,x[3]=_-l,x[4]=p-d,x[5]=g-f,y[3]=0,y[4]=-1,y[5]=0,T[2]=0,T[3]=0,x[6]=_+l,x[7]=p-d,x[8]=g-f,y[6]=0,y[7]=-1,y[8]=0,T[4]=1,T[5]=0,x[9]=_+l,x[10]=p-d,x[11]=g+f,y[9]=0,y[10]=-1,y[11]=0,T[6]=1,T[7]=1,x[12]=_+l,x[13]=p+d,x[14]=g+f,y[12]=0,y[13]=1,y[14]=0,T[8]=0,T[9]=1,x[15]=_+l,x[16]=p+d,x[17]=g-f,y[15]=0,y[16]=1,y[17]=0,T[10]=0,T[11]=0,x[18]=_-l,x[19]=p+d,x[20]=g-f,y[18]=0,y[19]=1,y[20]=0,T[12]=1,T[13]=0,x[21]=_-l,x[22]=p+d,x[23]=g+f,y[21]=0,y[22]=1,y[23]=0,T[14]=1,T[15]=1,x[24]=_+l,x[25]=p-d,x[26]=g+f,y[24]=1,y[25]=0,y[26]=0,T[16]=0,T[17]=1,x[27]=_+l,x[28]=p-d,x[29]=g-f,y[27]=1,y[28]=0,y[29]=0,T[18]=0,T[19]=0,x[30]=_+l,x[31]=p+d,x[32]=g-f,y[30]=1,y[31]=0,y[32]=0,T[20]=1,T[21]=0,x[33]=_+l,x[34]=p+d,x[35]=g+f,y[33]=1,y[34]=0,y[35]=0,T[22]=1,T[23]=1,x[36]=_-l,x[37]=p+d,x[38]=g+f,y[36]=-1,y[37]=0,y[38]=0,T[24]=0,T[25]=1,x[39]=_-l,x[40]=p+d,x[41]=g-f,y[39]=-1,y[40]=0,y[41]=0,T[26]=0,T[27]=0,x[42]=_-l,x[43]=p-d,x[44]=g-f,y[42]=-1,y[43]=0,y[44]=0,T[28]=1,T[29]=0,x[45]=_-l,x[46]=p-d,x[47]=g+f,y[45]=-1,y[46]=0,y[47]=0,T[30]=1,T[31]=1,x[48]=_-l,x[49]=p+d,x[50]=g+f,y[48]=0,y[49]=0,y[50]=1,T[32]=0,T[33]=1,x[51]=_-l,x[52]=p-d,x[53]=g+f,y[51]=0,y[52]=0,y[53]=1,T[34]=0,T[35]=0,x[54]=_+l,x[55]=p-d,x[56]=g+f,y[54]=0,y[55]=0,y[56]=1,T[36]=1,T[37]=0,x[57]=_+l,x[58]=p+d,x[59]=g+f,y[57]=0,y[58]=0,y[59]=1,T[38]=1,T[39]=1,x[60]=_+l,x[61]=p+d,x[62]=g-f,y[60]=0,y[61]=0,y[62]=-1,T[40]=0,T[41]=1,x[63]=_+l,x[64]=p-d,x[65]=g-f,y[63]=0,y[64]=0,y[65]=-1,T[42]=0,T[43]=0,x[66]=_-l,x[67]=p-d,x[68]=g-f,y[66]=0,y[67]=0,y[68]=-1,T[44]=1,T[45]=0,x[69]=_-l,x[70]=p+d,x[71]=g-f,y[69]=0,y[70]=0,y[71]=-1,T[46]=1,T[47]=1;var C=new h["a"].Uint16Array(36);C[0]=0,C[1]=1,C[2]=2,C[3]=0,C[4]=2,C[5]=3,C[6]=4,C[7]=5,C[8]=6,C[9]=4,C[10]=6,C[11]=7,C[12]=8,C[13]=9,C[14]=10,C[15]=8,C[16]=10,C[17]=11,C[18]=12,C[19]=13,C[20]=14,C[21]=12,C[22]=14,C[23]=15,C[24]=16,C[25]=17,C[26]=18,C[27]=16,C[28]=18,C[29]=19,C[30]=20,C[31]=21,C[32]=22,C[33]=20,C[34]=22,C[35]=23,S.getAttributes().Vertex=new i["a"](i["a"].ARRAY_BUFFER,x,3),S.getAttributes().Normal=new i["a"](i["a"].ARRAY_BUFFER,y,3),S.getAttributes().TexCoord0=new i["a"](i["a"].ARRAY_BUFFER,T,2);var A=new u["a"](o["a"].TRIANGLES,new i["a"](i["a"].ELEMENT_ARRAY_BUFFER,C,1));return S.getPrimitives().push(A),S},f=function(){var e={},t=function(){var e=new a["a"],t=new h["a"].Float32Array([4,-1,-1,4,-1,-1]),r=new i["a"](i["a"].ARRAY_BUFFER,t,2);e.getAttributes().Vertex=r,e.getAttributes().TexCoord0=r;var n=new s["a"](o["a"].TRIANGLES,0,3);return e.getPrimitives().push(n),e};return function(r){return e[r]||(e[r]=t()),e[r]}}(),_=function(e,t,r,s,c,l,d,f,_,p,g,m,v){void 0===m&&void 0===v&&(m=p,v=g,p=0,g=0);var b=new a["a"],S=new h["a"].Float32Array(12);S[0]=e+d,S[1]=t+f,S[2]=r+_,S[3]=e,S[4]=t,S[5]=r,S[6]=e+s,S[7]=t+c,S[8]=r+l,S[9]=e+s+d,S[10]=t+c+f,S[11]=r+l+_,void 0===m&&(m=1),void 0===v&&(v=1);var x=new h["a"].Float32Array(8);x[0]=p,x[1]=v,x[2]=p,x[3]=g,x[4]=m,x[5]=g,x[6]=m,x[7]=v;var T=n["f"].fromValues(s,c,l);n["f"].cross(T,T,n["f"].fromValues(d,f,_)),n["f"].normalize(T,T);var y=new h["a"].Float32Array(12);y[0]=T[0],y[1]=T[1],y[2]=T[2],y[3]=T[0],y[4]=T[1],y[5]=T[2],y[6]=T[0],y[7]=T[1],y[8]=T[2],y[9]=T[0],y[10]=T[1],y[11]=T[2];var C=new h["a"].Uint16Array(6);C[0]=0,C[1]=1,C[2]=2,C[3]=0,C[4]=2,C[5]=3,b.getAttributes().Vertex=new i["a"](i["a"].ARRAY_BUFFER,S,3),b.getAttributes().Normal=new i["a"](i["a"].ARRAY_BUFFER,y,3),b.getAttributes().TexCoord0=new i["a"](i["a"].ARRAY_BUFFER,x,2);var A=new u["a"](o["a"].TRIANGLES,new i["a"](i["a"].ELEMENT_ARRAY_BUFFER,C,1));return b.getPrimitives().push(A),b},p=function e(t){void 0===t&&(t=1),void 0===e.getShader&&(e.getShader=function(){if(void 0===e.getShader.program){var t=["#ifdef GL_ES","precision highp float;","#endif","attribute vec3 Vertex;","attribute vec4 Color;","uniform mat4 uModelViewMatrix;","uniform mat4 uProjectionMatrix;","","varying vec4 vColor;","","void main(void) {"," gl_Position = uProjectionMatrix * (uModelViewMatrix * vec4(Vertex, 1.0));"," vColor = Color;","}"].join("\n"),r=["#ifdef GL_ES","precision highp float;","#endif","varying vec4 vColor;","void main(void) {","gl_FragColor = vColor;","}"].join("\n"),n=new c["a"](new l["a"]("VERTEX_SHADER",t),new l["a"]("FRAGMENT_SHADER",r));e.getShader.program=n}return e.getShader.program});var r=new a["a"],n=new h["a"].Float32Array(18);n[3]=t,n[10]=t,n[17]=t;var u=new h["a"].Float32Array(24);u[0]=u[3]=1,u[4]=u[7]=1,u[9]=u[11]=1,u[13]=u[15]=1,u[18]=u[19]=1,u[22]=u[23]=1,r.getAttributes().Vertex=new i["a"](i["a"].ARRAY_BUFFER,n,3),r.getAttributes().Color=new i["a"](i["a"].ARRAY_BUFFER,u,4);var d=new s["a"](o["a"].LINES,0,6);return r.getPrimitives().push(d),r.getOrCreateStateSet().setAttributeAndModes(e.getShader()),r},g=function(e,t,r,c,l,d,f){e=e||1,c=void 0!==c?c:0,l=void 0!==l?l:2*Math.PI,d=void 0!==d?d:0,f=void 0!==f?f:Math.PI;for(var _=Math.max(3,Math.floor(t)||8),p=Math.max(2,Math.floor(r)||6),g=_*p/3>=65536,m=g?_*p*6:_*p*4,v=new h["a"].Float32Array(3*m),b=new h["a"].Float32Array(3*m),S=new h["a"].Float32Array(2*m),x=g?void 0:new h["a"].Uint16Array(_*p*6),T=0,y=0,C=new h["a"].Float32Array(3),A=new h["a"].Float32Array(3),E=new h["a"].Float32Array(3),R=new h["a"].Float32Array(3),M=new h["a"].Float32Array(3),w=new h["a"].Float32Array(3),N=new h["a"].Float32Array(3),O=new h["a"].Float32Array(3),I=new h["a"].Float32Array(2),P=new h["a"].Float32Array(2),D=new h["a"].Float32Array(2),L=new h["a"].Float32Array(2),F=function(t,r,i,a,o){i[0]=-e*Math.cos(c+t*l)*Math.sin(d+r*f),i[1]=e*Math.cos(d+r*f),i[2]=e*Math.sin(c+t*l)*Math.sin(d+r*f),n["f"].normalize(a,i),o[0]=t,o[1]=1-r},k=0;k<p;k++)for(var B=0;B<_;B++){F((B+1)/_,k/p,C,M,I),F(B/_,k/p,A,w,P),F(B/_,(k+1)/p,E,N,D),F((B+1)/_,(k+1)/p,R,O,L);var U=3*T;v[U]=C[0],v[U+1]=C[1],v[U+2]=C[2],v[U+3]=A[0],v[U+4]=A[1],v[U+5]=A[2],v[U+6]=E[0],v[U+7]=E[1],v[U+8]=E[2],b[U]=M[0],b[U+1]=M[1],b[U+2]=M[2],b[U+3]=w[0],b[U+4]=w[1],b[U+5]=w[2],b[U+6]=N[0],b[U+7]=N[1],b[U+8]=N[2];var V=2*T;if(S[V]=I[0],S[V+1]=I[1],S[V+2]=P[0],S[V+3]=P[1],S[V+4]=D[0],S[V+5]=D[1],T+=3,g)U=3*T,v[U]=C[0],v[U+1]=C[1],v[U+2]=C[2],v[U+3]=E[0],v[U+4]=E[1],v[U+5]=E[2],v[U+6]=R[0],v[U+7]=R[1],v[U+8]=R[2],b[U]=M[0],b[U+1]=M[1],b[U+2]=M[2],b[U+3]=N[0],b[U+4]=N[1],b[U+5]=N[2],b[U+6]=O[0],b[U+7]=O[1],b[U+8]=O[2],V=2*T,S[V]=I[0],S[V+1]=I[1],S[V+2]=D[0],S[V+3]=D[1],S[V+4]=L[0],S[V+5]=L[1],T+=3;else{U=3*T,v[U]=R[0],v[U+1]=R[1],v[U+2]=R[2],b[U]=O[0],b[U+1]=O[1],b[U+2]=O[2],V=2*T,S[V]=L[0],S[V+1]=L[1];var G=3*y,z=T-3;x[G]=z,x[G+1]=z+1,x[G+2]=z+2,x[G+3]=z,x[G+4]=z+2,x[G+5]=z+3,y+=2,T+=1}}var j=new a["a"];return j.getAttributes().Vertex=new i["a"]("ARRAY_BUFFER",v,3),j.getAttributes().Normal=new i["a"]("ARRAY_BUFFER",b,3),j.getAttributes().TexCoord0=new i["a"]("ARRAY_BUFFER",S,2),g?j.getPrimitives().push(new s["a"](o["a"].TRIANGLES,0,v.length/3)):j.getPrimitives().push(new u["a"](o["a"].TRIANGLES,new i["a"]("ELEMENT_ARRAY_BUFFER",x,1))),j},m=function(e,t,r,n,u,c,l,h,d,f,_){e=void 0!==e?e:-.5,t=void 0!==t?t:-.5,r=void 0!==r?r:0,n=void 0!==n?n:1,u=void 0!==u?u:0,c=void 0!==c?c:0,l=void 0!==l?l:0,h=void 0!==h?h:1,d=void 0!==d?d:0,f=void 0!==f?f:5,_=void 0!==_?_:f,f+=2,_+=2;var p=new a["a"],g=new Float32Array(2*(f+_)*3),m=0,v=0,b=n/(f-1),S=u/(f-1),x=c/(f-1),T=e+n+l,y=t+u+h,C=r+c+d;for(m=0;m<f;++m)v=6*m,g[v]=e+b*m,g[v+1]=t+S*m,g[v+2]=r+x*m,g[v+3]=T-b*(f-m-1),g[v+4]=y-S*(f-m-1),g[v+5]=C-x*(f-m-1);for(b=l/(_-1),S=h/(_-1),x=d/(_-1),m=0;m<_;++m)v=6*(f+m),g[v]=e+b*m,g[v+1]=t+S*m,g[v+2]=r+x*m,g[v+3]=T-b*(_-m-1),g[v+4]=y-S*(_-m-1),g[v+5]=C-x*(_-m-1);p.getAttributes().Vertex=new i["a"](i["a"].ARRAY_BUFFER,g,3);var A=new s["a"](o["a"].LINES,0,2*(f+_));return p.getPrimitives().push(A),p},v=function(e){var t=new a["a"],r=new Float32Array([-.5,-.5,-.5,.5,-.5,-.5,.5,.5,-.5,-.5,.5,-.5,-.5,-.5,.5,.5,-.5,.5,.5,.5,.5,-.5,.5,.5]);t.getAttributes().Vertex=new i["a"](i["a"].ARRAY_BUFFER,r,3),e||(e=[1,0,0,1]);for(var n=new h["a"].Float32Array(32),s=0;s<8;s++)for(var c=0;c<4;c++)n[3*s+c]=e[c];t.getAttributes().Color=new i["a"](i["a"].ARRAY_BUFFER,n,4);var l=new h["a"].Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]);return t.getPrimitives().push(new u["a"](o["a"].LINES,new i["a"]("ELEMENT_ARRAY_BUFFER",l,1))),t};t["a"]={createTexturedBoxGeometry:d,createTexturedQuadGeometry:_,createTexturedSphereGeometry:g,createTexturedFullScreenFakeQuadGeometry:f,createAxisGeometry:p,createTexturedSphere:g,createGridGeometry:m,createBoundingBoxGeometry:v}},"5fe3":function(e,t,r){"use strict";var n=function(){var e=function(e){return'<div style="margin: auto; width:500px;z-index:10000;margin-top:20em;text-align:center;">'+e+"</div>"},t='This page requires a browser that supports WebGL.<br/><a href="http://get.webgl.org">Click here to upgrade your browser.</a>',r='It doesn\'t appear your computer can support WebGL.<br/><a href="http://get.webgl.org">Click here for more information.</a>',n=!0,i=function(i,a,s){function u(i){if(n){var a=document.getElementsByTagName("body")[0];if(a){var o=window.WebGLRenderingContext?r:t;i&&(o+="<br/><br/>Status: "+i),a.innerHTML=e(o)}}}s=s||u,i.addEventListener&&i.addEventListener("webglcontextcreationerror",(function(e){s(e.statusMessage)}),!1);var c=o(i,a);return c||s(""),c},a=function(e,t,r){for(var n=null,i=0;i<r.length;++i){try{n=e.getContext(r[i],t)}catch(a){}if(n)break}return n},o=function(e,t){var r;if(t&&t.webgl2){if(n=!1,r=a(e,t,["webgl2","experimental-webgl2"]),r)return r;n=!0}return a(e,t,["webgl","experimental-webgl","webkit-3d","moz-webgl"])};return{create3DContext:o,setupWebGL:i}}();window.requestAnimationFrame||(window.requestAnimationFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(e,t){window.setTimeout(e,1e3/60)}}()),window.cancelRequestAnimFrame||(window.cancelAnimationFrame=function(){return window.cancelAnimationFrame||window.webkitCancelRequestAnimationFrame||window.mozCancelRequestAnimationFrame||window.oCancelRequestAnimationFrame||window.msCancelRequestAnimationFrame||clearTimeout}()),Date.now||(Date.now=function(){return(new Date).getTime()}),t["a"]=n},"602a":function(e,t,r){"use strict";var n=r("a214"),i=r("0fd6"),a=function(e){this._enabled=!1,this.reset(e)};a.FRAME_COUNT=0,a.instance=function(e,t){return a._instance?e&&(a._instance.getContext()!==e||t)&&(a._instance.setContext(e),a._instance.reset(e)):a._instance=new a(e),a._instance},a.prototype={reset:function(e){if(e){var t=i["a"].instance(e).getDisjointTimerQuery();if(!t)return this;if(e.getQueryParameter||(e.getQueryParameter=t.getQueryObjectEXT.bind(t)),this._hasTimeElapsed=e.getQuery(t.TIME_ELAPSED_EXT,t.QUERY_COUNTER_BITS_EXT)>=30,this._hasTimeStamp=e.getQuery(t.TIMESTAMP_EXT,t.QUERY_COUNTER_BITS_EXT)>=30,!this._hasTimeElapsed&&!this._hasTimeStamp)return this;this._hasTimeStamp||n["a"].debug("Warning: do not use interleaved GPU query"),this._ext=t,this._gl=e,this._enabled=!0}this._frameAverageCount=10,this._glQueries=[],this._queriesByID={},this._userQueries=[],this._queryCount=0,this._nbOpened=0},getContext:function(){return this._gl},setContext:function(e){this._gl=e},setFrameAverageCount:function(e){this._frameAverageCount=e},clearQueries:function(){for(var e=this._glQueries,t=0,r=e.length;t<r;++t){var n=e[t];this._gl.deleteQuery(n._pollingStartQuery),n._pollingEndQuery&&this._gl.deleteQuery(n)}this._userQueries.length=0,this._glQueries.length=0,this._queriesByID={}},supportTimeStamp:function(){return this._hasTimeStamp},enable:function(){this._enabled=!!this._ext},disable:function(){this._enabled=!1},isEnabled:function(){return this._enabled},setCallback:function(e){this._callback=e},createUserQuery:function(e){var t;return t=this._hasTimeStamp?this.createGLQuery():{_startIndex:0,_endIndex:0},t._id=e,t._frame=a.FRAME_COUNT,t._isOpened=!0,t._siblings=[],t},createGLQuery:function(){var e={_isWaiting:!1,_pollingStartQuery:void 0,_pollingEndQuery:void 0,_averageTimer:0,_resultCount:0};return this._hasTimeStamp&&(e._pollingEndQuery=this._gl.createQuery()),e._pollingStartQuery=this._gl.createQuery(),this._glQueries.push(e),e},getOrCreateLastGLQuery:function(){var e=this._glQueries[this._queryCount-1];return e||(e=this._glQueries[this._queryCount-1]=this.createGLQuery(),e)},beginCurrentQuery:function(){if(0!==this._nbOpened){this._queryCount++;var e=this.getOrCreateLastGLQuery();e._isWaiting||this._gl.beginQuery(this._ext.TIME_ELAPSED_EXT,e._pollingStartQuery)}},endCurrentQuery:function(){0!==this._nbOpened&&(this.getOrCreateLastGLQuery()._isWaiting||this._gl.endQuery(this._ext.TIME_ELAPSED_EXT))},getAvailableQueryByID:function(e){var t=this._queriesByID[e];if(!t)return t=this._queriesByID[e]=this.createUserQuery(e),this._userQueries.push(t),t;if(t._frame===a.FRAME_COUNT){if(t._isOpened)return t;for(var r=t._siblings,n=0,i=r.length;n<i;++n){var o=r[n];if(o._frame!==a.FRAME_COUNT||o._isOpened)return o._frame=a.FRAME_COUNT,o}var s=this.createUserQuery();return r.push(s),s}return t._frame=a.FRAME_COUNT,t},start:function(e){if(this._enabled){var t=this.getAvailableQueryByID(e);t._isOpened=!0,this._hasTimeStamp?t._isWaiting||this._ext.queryCounterEXT(t._pollingStartQuery,this._ext.TIMESTAMP_EXT):(this.endCurrentQuery(),this._nbOpened++,t._startIndex=this._queryCount,this.beginCurrentQuery())}},end:function(e){if(this._enabled){var t=this.getAvailableQueryByID(e);t._isOpened=!1,this._hasTimeStamp?t._isWaiting||this._ext.queryCounterEXT(t._pollingEndQuery,this._ext.TIMESTAMP_EXT):(this.endCurrentQuery(),t._endIndex=this._queryCount,this._nbOpened--,this.beginCurrentQuery())}},computeQueryAverageTime:function(e){for(var t=0,r=this._glQueries,n=e._startIndex;n<e._endIndex;++n){var i=r[n]._averageTimer;if(i<0)return-1;t+=i}return t},computeFullAverageTime:function(e){var t=this.computeQueryAverageTime(e);if(t<0)return-1;for(var r=e._siblings,n=0,i=r.length;n<i;++n){var o=r[n];if(o._frame===a.FRAME_COUNT-1){var s=this.computeQueryAverageTime(o);if(s<0)return-1;t+=s}}return t},pollQueries:function(){if(a.FRAME_COUNT++,this._queryCount=0,this._nbOpened=0,this._enabled&&this._callback){var e,t=this._glQueries,r=t.length,n=this._gl.getParameter(this._ext.GPU_DISJOINT_EXT);if(n)for(e=0;e<r;++e)t[e]._isWaiting=!1;else{for(e=0;e<r;++e)this.pollQuery(t[e]);var i=this._userQueries,o=i.length;for(e=0;e<o;++e){var s=i[e],u=this.computeFullAverageTime(s);u>0&&this._callback(u,s._id)}}}},pollQuery:function(e){e._isWaiting=!1;var t,r=this._hasTimeStamp?e._pollingEndQuery:e._pollingStartQuery,n=this._gl.getQueryParameter(r,this._gl.QUERY_RESULT_AVAILABLE);if(!n)return e._isWaiting=!0,0;if(this._hasTimeStamp){var i=this._gl.getQueryParameter(e._pollingStartQuery,this._gl.QUERY_RESULT),a=this._gl.getQueryParameter(r,this._gl.QUERY_RESULT);t=a-i}else t=this._gl.getQueryParameter(r,this._gl.QUERY_RESULT);return e._resultCount++,e._resultCount>this._frameAverageCount&&(e._averageTimer=0,e._resultCount=1),e._averageTimer=e._averageTimer+(t-e._averageTimer)/e._resultCount,e._averageTimer}},t["a"]=a},"60b6":function(e,t,r){"use strict";var n=r("06c5"),i=function(e){this._initialBufferArray=void 0,this._bufferArray=void 0,e&&(this.setBufferArray(e),this.setInitialBufferArray(e))},a={setInitialBufferArray:function(e){this._initialBufferArray=e},getInitialBufferArray:function(){return this._initialBufferArray},setBufferArray:function(e){this._bufferArray=e.getBufferArray?e.getBufferArray():e},getBufferArray:function(){return this._bufferArray}},o=function(e){return function(){return e.apply(this._bufferArray,arguments)}};for(var s in n["a"].prototype)a[s]=o(n["a"].prototype[s]);i.prototype=a,t["a"]=i},6177:function(e,t,r){},6377:function(e,t,r){"use strict";var n=r("5e15"),i=function e(){this._mask=e.DEFAULT_CULLING,this._frustum=new n["a"]};i.prototype={reset:function(){this._mask=i.DEFAULT_CULLING,this._frustum.clear()},setCullingMask:function(e){this._mask=e},getCullingMask:function(){return this._mask},setFrustum:function(e){this._frustum=e},getFrustum:function(){return this._frustum},getCurrentResultMask:function(){return this._frustum.getCurrentMask()},pushCurrentMask:function(){this._frustum.pushCurrentMask()},popCurrentMask:function(){this._frustum.popCurrentMask()},resetCullingMask:function(){this._frustum.setResultMask(this._frustum.getCurrentMask())},isBoundingBoxCulled:function(e){return!(!(this._mask&i.VIEW_FRUSTUM_CULLING)||this._frustum.containsBoundingBox(e))},isBoundingSphereCulled:function(e){return!(!(this._mask&i.VIEW_FRUSTUM_CULLING)||this._frustum.containsBoundingSphere(e))},isVerticesCulled:function(e){return!(!(this._mask&i.VIEW_FRUSTUM_CULLING)||this._frustum.containsVertices(e))}},i.NO_CULLING=0,i.VIEW_FRUSTUM_LEFT_CULLING=1,i.VIEW_FRUSTUM_RIGHT_CULLING=2,i.VIEW_FRUSTUM_TOP_CULLING=3,i.VIEW_FRUSTUM_BOTTOM_CULLING=4,i.NEAR_PLANE_CULLING=5,i.FAR_PLANE_CULLING=6,i.VIEW_FRUSTUM_SIDES_CULLING=i.VIEW_FRUSTUM_LEFT_CULLING|i.VIEW_FRUSTUM_RIGHT_CULLING|i.VIEW_FRUSTUM_BOTTOM_CULLING|i.VIEW_FRUSTUM_TOP_CULLING,i.VIEW_FRUSTUM_CULLING=i.VIEW_FRUSTUM_SIDES_CULLING|i.NEAR_PLANE_CULLING|i.FAR_PLANE_CULLING,i.DEFAULT_CULLING=i.VIEW_FRUSTUM_SIDES_CULLING,i.ENABLE_ALL_CULLING=i.VIEW_FRUSTUM_CULLING,t["a"]=i},"65ea":function(e,t,r){"use strict";var n=r("b797"),i=r("123d"),a=r("3972"),o=function(e){i["a"].call(this),this._constantColor=a["g"].create(),a["g"].set(this._constantColor,1,1,1,1),void 0!==e&&this.setConstantColor(e)};n["a"].createPrototypeStateAttribute(o,n["a"].objectInherit(i["a"].prototype,{attributeType:"BlendColor",cloneType:function(){return new o},setConstantColor:function(e){a["g"].copy(this._constantColor,e)},getConstantColor:function(){return this._constantColor},apply:function(e){var t=e.getGraphicContext();t.blendColor(this._constantColor[0],this._constantColor[1],this._constantColor[2],this._constantColor[3])}}),"osg","BlendColor"),t["a"]=o},"6a5b":function(e,t,r){"use strict";var n=r("b797"),i=r("123d"),a=r("3972"),o=r("2857"),s=function(){i["a"].call(this),this._ambient=a["g"].fromValues(.2,.2,.2,1),this._diffuse=a["g"].fromValues(.8,.8,.8,1),this._specular=a["g"].fromValues(0,0,0,1),this._emission=a["g"].fromValues(0,0,0,1),this._shininess=12.5};n["a"].createPrototypeStateAttribute(s,n["a"].objectInherit(i["a"].prototype,{attributeType:"Material",cloneType:function(){return new s},getParameterName:function(e){return"u"+this.getType()+"_"+e},getOrCreateUniforms:function(){var e=s;return e.uniforms||(e.uniforms={ambient:o["a"].createFloat4("uMaterialAmbient"),diffuse:o["a"].createFloat4("uMaterialDiffuse"),specular:o["a"].createFloat4("uMaterialSpecular"),emission:o["a"].createFloat4("uMaterialEmission"),shininess:o["a"].createFloat1("uMaterialShininess")}),e.uniforms},setEmission:function(e){a["g"].copy(this._emission,e)},getEmission:function(){return this._emission},setAmbient:function(e){a["g"].copy(this._ambient,e)},getAmbient:function(){return this._ambient},setSpecular:function(e){a["g"].copy(this._specular,e)},getSpecular:function(){return this._specular},setDiffuse:function(e){a["g"].copy(this._diffuse,e)},getDiffuse:function(){return this._diffuse},setShininess:function(e){this._shininess=e},getShininess:function(){return this._shininess},setTransparency:function(e){this._diffuse[3]=1-e},getTransparency:function(){return this._diffuse[3]},apply:function(){var e=this.getOrCreateUniforms();e.ambient.setFloat4(this._ambient),e.diffuse.setFloat4(this._diffuse),e.specular.setFloat4(this._specular),e.emission.setFloat4(this._emission),e.shininess.setFloat(this._shininess)}}),"osg","Material"),t["a"]=s},"6b10":function(e,t,r){"use strict";r("4ec9"),r("d3b7"),r("3ca3"),r("ddb0");var n=r("a214"),i={instance:function(){return i._instance||(i._instance=i,i._instance.plugins=new window.Map),i._instance},addReaderWriter:function(e,t){void 0!==i.instance().plugins.get(e)&&n["a"].warn("the '"+e+"' plugin already exists"),i.instance().plugins.set(e,t)},getReaderWriterForExtension:function(e){return i.instance().plugins.get(e)}};t["a"]=i},"6b61":function(e,t,r){"use strict";var n=r("b797"),i=r("a214"),a=r("ae6a"),o=r("3972"),s=r("5a16"),u=function(){a["a"].call(this)};n["a"].createPrototypeObject(u,n["a"].objectInherit(a["a"].prototype,{update:function(e,t){if(t.getVisitorType()===s["a"].UPDATE_VISITOR){if(e.className&&"Bone"!==e.className())return i["a"].warn("Warning: UpdateBone set on non-Bone object."),!1;var r=e;a["a"].prototype.update.call(this,e),r.setMatrix(r.getMatrix());var n=r.getMatrix(),u=r.getBoneParent();u?o["c"].mul(r.getMatrixInSkeletonSpace(),u.getMatrixInSkeletonSpace(),n):r.setMatrixInSkeletonSpace(n)}return!0}}),"osgAnimation","UpdateBone"),t["a"]=u},"6ec3":function(e,t,r){"use strict";r("a9e3");var n=r("a214"),i=r("b797"),a=r("2449"),o=r("3972"),s=r("5a16"),u=r("ede0"),c=r("3714"),l=function(){a["a"].call(this),this._matrix=o["c"].create(),this._position=o["f"].create(),this._matrixDirty=!0,this._scale=o["f"].fromValues(1,1,1),this._minimumScale=0,this._maximumScale=Number.MAX_VALUE,this._rotation=o["d"].create(),this._pivotPoint=o["f"].create(),this._autoScaleToScreen=!1,this._autoRotateToScreen=!1,this._cachedMatrix=o["c"].create(),this._firstTimeToInitEyePoint=!0,this._autoScaleTransitionWidthRatio=.25,this._billboardAttribute=void 0,this._previousWidth=0,this._previousHeight=0,this._previousProjection=o["c"].create(),this._previousModelView=o["c"].create(),this._previousPosition=o["f"].create()};i["a"].createPrototypeNode(l,i["a"].objectInherit(a["a"].prototype,{getMatrix:function(){return this._matrix},setMatrix:function(e){this._matrix=e,this.dirtyBound()},setPosition:function(e){this._position=e,this._matrixDirty=!0,this.dirtyBound()},getPosition:function(){return this._position},setRotation:function(e){this._rotation=e,this._matrixDirty=!0,this.dirtyBound()},getRotation:function(){return this._rotation},setScale:function(e){this.setScaleFromVec3(o["f"].fromValues(e,e,e))},setScaleFromvec3:function(e){n["a"].warn("deprecated, use setScaleFromVec3"),this.setScaleFromVec3(e)},setScaleFromVec3:function(e){this._scale=e,this._matrixDirty=!0,this.dirtyBound()},getScale:function(){return this._scale},setMinimumScale:function(e){this._minimumScale=e},getMinimumScale:function(){return this._minimumScale},setMaximumScale:function(e){this._maximumScale=e},getMaximumScale:function(){return this._maximumScale},setAutoScaleToScreen:function(e){this._autoScaleToScreen=e,this._matrixDirty=!0},getAutoScaleToScreen:function(){return this._autoScaleToScreen},setAutoRotateToScreen:function(e){this._autoRotateToScreen=e},getAutoRotateToScreen:function(){return this._autoRotateToScreen},setAutoScaleTransitionWidthRatio:function(e){this._autoScaleTransitionWidthRatio=e},getAutoScaleTransitionWidthRatio:function(){return this._autoScaleTransitionWidthRatio},computeLocalToWorldMatrix:function(e){this._matrixDirty&&this.computeMatrix(),this.referenceFrame===u["a"].RELATIVE_RF?o["c"].mul(e,e,this._matrix):o["c"].copy(e,this._matrix)},computeMatrix:function(){var e=o["f"].create(),t=o["c"].create();return function(){this._matrixDirty&&(o["c"].fromQuat(this._matrix,this._rotation),o["c"].fromTranslation(t,this._position),o["c"].mul(this._matrix,t,this._matrix),o["c"].scale(this._matrix,this._matrix,this._scale),o["c"].translate(this._matrix,this._matrix,o["f"].neg(e,this._pivotPoint)),this._matrixDirty=!1)}}(),computeWorldToLocalMatrix:function(){var e=o["f"].create(),t=o["d"].create(),r=o["f"].create(),n=o["c"].create();return function(i){return(0!==this.scale[0]||0!==this.scale[1]||0!==this.scale[2])&&(r[0]=1/this._scale[0],r[1]=1/this._scale[1],r[2]=1/this._scale[2],this.referenceFrame===u["a"].RELATIVE_RF?(o["c"].fromTranslation(n,o["f"].neg(e,this._position)),o["c"].mul(i,n,i),o["d"].zeroRotation(this._rotation)||(o["c"].fromQuat(n,o["d"].invert(t,this._rotation)),o["c"].mul(i,n,i)),o["c"].fromScaling(n,r),o["c"].mul(i,n,i),o["c"].fromTranslation(n,this._pivotPoint),o["c"].mul(i,n,i)):(o["c"].fromQuat(this._matrix,o["d"].invert(t,this._rotation)),o["c"].translate(i,i,o["f"].neg(e,this._position)),o["c"].fromScaling(n,r),o["c"].mul(i,n,i),o["c"].fromTranslation(n,this._pivotPoint),o["c"].mul(i,n,i)),!0)}}(),computeBound:function(){var e=o["c"].create();return function(t){return this._autoScaleToScreen&&this._firstTimeToInitEyePoint?t:(c["a"].prototype.computeBound.call(this,t),t.valid()?(o["c"].identity(e),this.computeLocalToWorldMatrix(e),t.transformMat4(t,e),t):t)}}(),accept:function(){return function(e){if(e.getVisitorType()===s["a"].CULL_VISITOR){var t=e.getViewport().width(),r=e.getViewport().height(),n=e.getCurrentProjectionMatrix(),i=e.getCurrentModelViewMatrix(),a=this._position,u=this._firstTimeToInitEyePoint;if(this._firstTimeToInitEyePoint||(t!==this._previousWidth||r!==this._previousHeight?u=!0:o["c"].exactEquals(n,this._previousProjection)&&o["c"].exactEquals(i,this._previousModelView)&&o["f"].exactEquals(a,this._previousPosition)||(u=!0)),this._firstTimeToInitEyePoint=!1,u){if(this._autoScaleToScreen){var l=e.getViewport(),h=this.computePixelSizeVector(l,n,i),d=o["g"].fromValues(this._position[0],this._position[1],this._position[2],1),f=o["g"].dot(d,h);f=.48/f;var _=1/f;if(this._autoScaleTransitionWidthRatio>0){var p,g,m;if(this._minimumScale>0){var v=this._minimumScale,b=this._maximumScale<Number.MAX_VALUE?this._minimumScale+(this._maximumScale-this._minimumScale)*this._autoScaleTransitionWidthRatio:this._minimumScale*(1+this._autoScaleTransitionWidthRatio);p=1/(4*(b-v)),g=1-2*p*b,m=v+g*g/(4*p);var S=-g/(2*p);_<S?_=this._minimumScale:_<b&&(_=m+g*_+p*(_*_))}if(this._maximumScale<Number.MAX_VALUE){var x=this._maximumScale,T=this._minimumScale>0?this._maximumScale+(this._minimumScale-this._maximumScale)*this._autoScaleTransitionWidthRatio:this._maximumScale*(1-this._autoScaleTransitionWidthRatio);p=1/(4*(T-x)),g=1-2*p*T,m=x+g*g/(4*p);var y=-g/(2*p);_>y?_=this._maximumScale:_>T&&(_=m+g*_+p*(_*_))}}this.setScale(_)}if(this._autoRotateToScreen){var C=o["d"].create();o["c"].getRotation(C,i),this.setRotation(o["d"].invert(C,C))}this._previousWidth=t,this._previousHeight=r,o["f"].copy(this._previousPosition,a),o["c"].copy(this._previousProjection,n),o["c"].copy(this._previousModelView,i)}}c["a"].prototype.accept.call(this,e)}}(),computePixelSizeVector:function(){var e=o["f"].create(),t=o["f"].create();return function(r,n,i){var a=n[0]*r.width()*.5,s=n[8]*r.width()*.5+n[11]*r.width()*.5;o["f"].set(e,i[0]*a+i[2]*s,i[4]*a+i[6]*s,i[8]*a+i[10]*s);var u=n[5]*r.height()*.5,c=n[9]*r.height()*.5+n[11]*r.height()*.5;o["f"].set(t,i[1]*u+i[2]*c,i[5]*u+i[6]*c,i[9]*u+i[10]*c);var l=n[11],h=n[15],d=o["g"].fromValues(i[2]*l,i[6]*l,i[10]*l,i[14]*l+i[15]*h),f=.7071067811/Math.sqrt(o["f"].sqrLen(e)+o["f"].sqrLen(t));return o["g"].scale(d,d,f),d}}()}),"osg","AutoTransform"),t["a"]=l},"6ec8":function(e,t,r){"use strict";var n=r("16f6"),i=function(e,t,r){this.mode=e,void 0!==e&&("string"===typeof e&&(e=n["a"][e]),this.mode=e),this.first=t,this.count=r};i.prototype={draw:function(e){if(0!==this.count){var t=e.getGraphicContext();t.drawArrays(this.mode,this.first,this.count)}},getMode:function(){return this.mode},setCount:function(e){this.count=e},getCount:function(){return this.count},setFirst:function(e){this.first=e},getFirst:function(){return this.first},getNumIndices:function(){return this.count},index:function(e){return this.first+e}},t["a"]=i},7440:function(e,t,r){"use strict";r.r(t);var n=r("a214"),i=r("b797"),a=r("2857"),o=r("aee2"),s=r("9946"),u=r("06c5"),c=r("16f6"),l=r("6ec8"),h=r("931a"),d=r("23f5"),f=r("3714"),_=r("3972"),p=r("032c"),g=r("0549"),m=r("6b10"),v=r("094b"),b=r("8130"),S=r("6a5b"),x={ObjectWrapper:{}};x.ObjectWrapper.serializers={},x.readImage=function(e,t){return x.registry().readImageURL(e,t)},x.readImageURL=x.readImage,x.readBinaryArrayURL=function(e,t){return x.registry().readBinaryArrayURL(e,t)},x.readNodeURL=function(e,t){var r=e.substr(e.lastIndexOf(".")+1),n=m["a"].instance().getReaderWriterForExtension(r);return void 0!==n?n.readNodeURL(e,t):x.registry().readNodeURL(e,t)},x.registry=function(){return void 0===x.registry._input&&(x.registry._input=new v["a"]),x.registry._input},x.parseSceneGraph=function(e,t){if(!(void 0!==e.Version&&e.Version>0)){i["a"].time("osgjs.metric:ReaderParser.parseSceneGraphDeprecated",n["a"].INFO);var r=x.parseSceneGraphDeprecated(e);return i["a"].timeEnd("osgjs.metric:ReaderParser.parseSceneGraphDeprecated",n["a"].INFO),r}var a;for(var o in i["a"].time("osgjs.metric:ReaderParser.parseSceneGraph",n["a"].INFO),e)if("Generator"!==o&&"Version"!==o){a=o;break}if(a){var s={};s[a]=e[a];var u=x.registry().clone();u.setJSON(s);var c=i["a"].objectMix(i["a"].objectMix({},x.registry().getOptions()),t||{});u.setOptions(c);var l=u.readObject();return i["a"].timeEnd("osgjs.metric:ReaderParser.parseSceneGraph",n["a"].INFO),l}n["a"].log("can't parse scenegraph "+e,n["a"].INFO)},x.parseSceneGraphDeprecated=function(e){var t,r=function(e,t){var r=t[e];return void 0===r&&(r=t[e.toLowerCase()]),r},m=function(e,t){var n=r("Name",t);n&&void 0!==e.setName&&e.setName(n)},v=function(e,t){m(e,t),e.setAmbient(r("Ambient",t)),e.setDiffuse(r("Diffuse",t)),e.setEmission(r("Emission",t)),e.setSpecular(r("Specular",t)),e.setShininess(r("Shininess",t))},T=function(e,t){m(e,t),e.setSourceRGB(t.SourceRGB),e.setSourceAlpha(t.SourceAlpha),e.setDestinationRGB(t.DestinationRGB),e.setDestinationAlpha(t.DestinationAlpha)},y=function(e,t){var i=t.MagFilter||t["mag_filter"]||void 0;i&&e.setMagFilter(i);var a=t.MinFilter||t["min_filter"]||void 0;a&&e.setMinFilter(a);var o=t.WrapT||t["wrap_t"]||void 0;o&&e.setWrapT(o);var s=t.WrapS||t["wrap_s"]||void 0;s&&e.setWrapS(s);var u=r("File",t);x.readImage(u).then((function(t){e.setImage(t)})).catch((function(){n["a"].log("Can't read image")}))},C=function(e,t){m(e,t);var i=r("Textures",t)||r("TextureAttributeList",t)||void 0;if(i)for(var s=0,u=i.length;s<u;s++){var c=r("File",i[s]);if(c){var l=new b["default"];y(l,i[s]),e.setTextureAttributeAndModes(s,l),e.addUniform(a["a"].createInt1(s,"Texture"+s))}else n["a"].log("no texture on unit "+s+" skip it")}var h=r("BlendFunc",t);if(h){var d=new o["a"];T(d,h),e.setAttributeAndModes(d)}var f=r("Material",t);if(f){var _=new S["a"];v(_,f),e.setAttributeAndModes(_)}},A=e.children,E=e._primitives||e.primitives||e.Primitives||void 0,R=e._attributes||e.attributes||e.Attributes||void 0;if(E||R){var M=new s["a"];m(M,e),M.stateset=e.stateset,e=M;for(var w=0,N=E.length;w<N;w++){var O=E[w].mode;if(E[w].indices){var I=E[w].indices;I=new u["a"](u["a"][I.type],I.elements,I.itemSize),O=O?c["a"][O]:"TRIANGLES",M.getPrimitiveSetList().push(new h["a"](O,I))}else{O=c["a"][O];var P=E[w].first,D=E[w].count;M.getPrimitiveSetList().push(new l["a"](O,P,D))}}for(var L in R){var F=R[L];M.getVertexAttributeList()[L]=new u["a"](F.type,F.elements,F.itemSize)}}var k=r("StateSet",e);if(k){var B=new d["a"];C(B,k),e.stateset=B}var U=e.matrix||e.Matrix||void 0;U&&(t=new p["a"],m(t,e),i["a"].extend(t,e),_["c"].copy(t.getMatrix(),U),e=t);var V=e.projection||e.Projection||void 0;if(V&&(t=new g["a"],m(t,e),i["a"].extend(t,e),_["c"].copy(t.setProjectionMatrix(),V),e=t),void 0===e.typeID&&(t=new f["a"],m(t,e),i["a"].extend(t,e),e=t),A){e.children=[];for(var G=0,z=A.length;G<z;G++)e.addChild(x.parseSceneGraphDeprecated(A[G]))}return e},t["default"]=x},7729:function(e,t,r){"use strict";var n=r("b797"),i=r("123d"),a=function e(t){i["a"].call(this),this.setMode(void 0!==t?t:e.CCW)};a.CW=2304,a.CCW=2305,n["a"].createPrototypeStateAttribute(a,n["a"].objectInherit(i["a"].prototype,{attributeType:"FrontFace",cloneType:function(){return new a},setMode:function(e){var t=e;"string"===typeof t&&(t=a[t]),this._mode=t},getMode:function(){return this._mode},apply:function(e){e.applyFrontFace(this)}}),"osg","FrontFace"),t["a"]=a},"773c":function(e,t,r){"use strict";r("fb6a");var n=r("3972"),i=r("1cf6"),a=r("e8f9"),o=function(){this._hit=!1,this._primitiveIndex=0,this._vertices=void 0,this._geometry=void 0,this._intersectionVisitor=void 0,this._intersector=void 0,this._limitOneIntersection=!1,this._primitiveMask=a["a"].ALL_PRIMITIVES};o.Intersection=function(){this._nodePath=void 0,this._drawable=void 0,this._matrix=void 0,this._primitiveIndex=void 0,this._ratio=0,this._backface=!1,this._localIntersectionPoint=n["f"].create()},o.prototype={reset:function(){this._hit=!1,this._vertices=void 0,this._primitiveIndex=0},setPrimitiveIndex:function(e){this._primitiveIndex=e},setGeometry:function(e){this._geometry=e,this._primitiveIndex=0,this._vertices=e.getAttributes().Vertex.getElements()},setVertices:function(e){this._vertices=e},setIntersectionVisitor:function(e){this._intersectionVisitor=e},setIntersector:function(e){this._intersector=e,this._primitiveMask=e.getPrimitiveMask();var t=e.getIntersectionLimit();this._limitOneIntersection=t===a["a"].LIMIT_ONE_PER_DRAWABLE||t===a["a"].LIMIT_ONE},setLimitOneIntersection:function(e){this._limitOneIntersection=e},leave:function(){},enter:function(){},initIntersection:function(e){return e._matrix=n["c"].clone(this._intersectionVisitor.getModelMatrix()),e._nodePath=this._intersectionVisitor.getNodePath().slice(),e._primitiveIndex=this._primitiveIndex,e._drawable=this._geometry,this._intersector.getIntersections().push(e),this._hit=!0,e},intersectPoint:function(){},intersectLine:function(){},intersectTriangle:function(){},operatorPoint:function(){var e=n["f"].create();return function(t){if((!this._limitOneIntersection||!this._hit)&&0!==(this._primitiveMask&a["a"].POINT_PRIMITIVES)){var r=this._vertices;n["f"].set(e,r[3*t],r[3*t+1],r[3*t+2]),this.intersectPoint(e,t),this._primitiveIndex++}}}(),operatorLine:function(){var e=n["f"].create(),t=n["f"].create();return function(r,i){if((!this._limitOneIntersection||!this._hit)&&0!==(this._primitiveMask&a["a"].LINE_PRIMITIVES)){var o=this._vertices;n["f"].set(e,o[3*r],o[3*r+1],o[3*r+2]),n["f"].set(t,o[3*i],o[3*i+1],o[3*i+2]),this.intersectLine(e,t,r,i),this._primitiveIndex++}}}(),operatorTriangle:function(){var e=n["f"].create(),t=n["f"].create(),r=n["f"].create();return function(i,o,s){if((!this._limitOneIntersection||!this._hit)&&0!==(this._primitiveMask&a["a"].TRIANGLE_PRIMITIVES)){var u=this._vertices;n["f"].set(e,u[3*i],u[3*i+1],u[3*i+2]),n["f"].set(t,u[3*o],u[3*o+1],u[3*o+2]),n["f"].set(r,u[3*s],u[3*s+1],u[3*s+2]),this.intersectTriangle(e,t,r,i,o,s),this._primitiveIndex++}}}(),apply:function(e){e.getAttributes().Vertex&&Object(i["a"])(e,this)}},t["a"]=o},8130:function(e,t,r){"use strict";r.r(t);r("4ec9"),r("d3b7"),r("3ca3"),r("ddb0"),r("a434"),r("5cc6"),r("907a"),r("9a8c"),r("a975"),r("735e"),r("c1ac"),r("d139"),r("3a7b"),r("d5d6"),r("82f8"),r("e91f"),r("60bd"),r("5f96"),r("3280"),r("3fcc"),r("ca91"),r("25a1"),r("cd26"),r("3c5d"),r("2954"),r("649e"),r("219c"),r("170b"),r("b39a"),r("72f7"),r("84c3"),r("cfc3"),r("fb6a");var n=r("a214"),i=r("b797"),a=r("123d"),o=r("2857"),s=r("4e92"),u=r("16cb"),c=(r("159b"),r("1ad5")),l=function(e,t,r,n){this._target=e,this._internalFormat=t,this._width=r,this._height=n,this._size=0,this.computeSize()};l.prototype={match:function(e){return e._target===this._target&&e._internalFormat===this._internalFormat&&e._width===this._width&&e._height===this._height},computeSize:function(){var e=r("8130").default,t=0;switch(this._internalFormat){case 1:t=8;break;case e.ALPHA:t=8;break;case e.LUMINANCE:t=8;break;case e.LUMINANCE_ALPHA:t=16;break;case 2:t=16;break;case e.RGB:t=24;break;case 3:t=24;break;case e.RGBA:t=32;break;case 4:t=32;break}var n=Math.ceil(this._width*this._height*t)/8;this._target===e.TEXTURE_CUBE_MAP&&(n*=6),n+=n/3,this._size=n},getSize:function(){return this._size}},l.getHash=function(){var e=Array.prototype.slice.call(arguments),t="";return e.forEach((function(e){t+=e})),t};var h=function(e,t,r){this._texture=e,this._id=t,this._textureSet=r};h.prototype={target:function(){return this._textureSet._profile._target},id:function(){return this._id},getTextureSet:function(){return this._textureSet},reset:function(){this._textureObject=null,this._texture=void 0},bind:function(e){e.bindTexture(this.target(),this._id)}};var d=function(e){this._profile=e,this._usedTextureObjects=[],this._orphanedTextureObjects=[]};d.prototype={getProfile:function(){return this._profile},getUsedTextureObjects:function(){return this._usedTextureObjects},getOrphanedTextureObjects:function(){return this._orphanedTextureObjects},takeOrGenerate:function(e,t){var r;if(this._orphanedTextureObjects.length>0)return r=this.takeFromOrphans(),r._texture=t,this._usedTextureObjects.push(r),r;var n=e.createTexture();return r=new h(t,n,this),this._usedTextureObjects.push(r),r},takeFromOrphans:function(){if(this._orphanedTextureObjects.length)return this._orphanedTextureObjects.pop()},orphan:function(e){var t=this._usedTextureObjects.indexOf(e);-1!==t&&(this._orphanedTextureObjects.push(this._usedTextureObjects[t]),this._usedTextureObjects.splice(t,1))},flushDeletedTextureObjects:function(e,t){if(t<=0)return t;var r,n=this._orphanedTextureObjects.length,i=0,a=c["a"].instance().tick();for(r=0;r<n&&i<t;r++)e.deleteTexture(this._orphanedTextureObjects[r].id()),this._orphanedTextureObjects[r].reset(),i=c["a"].instance().deltaS(a,c["a"].instance().tick());return this._orphanedTextureObjects.splice(0,r),t-i},flushAllDeletedTextureObjects:function(e){for(var t=this._orphanedTextureObjects.length,r=this.getProfile().getSize(),i=0,a=t;i<a;++i)e.deleteTexture(this._orphanedTextureObjects[i].id()),this._orphanedTextureObjects[i].reset();this._orphanedTextureObjects.length=0,n["a"].info("TextureManager: released "+t+" with "+t*r/1048576+" MB")},onLostContext:function(){var e,t;for(t=this._orphanedTextureObjects.length,e=0;e<t;++e)this._orphanedTextureObjects[e].reset();for(this._orphanedTextureObjects.length=0,t=this._usedTextureObjects.length,e=0;e<t;++e)this._usedTextureObjects[e].reset();this._usedTextureObjects.length=0}};var f=function(){this._textureSetMap={}};f.prototype={generateTextureObject:function(e,t,r,n,i,a){var o=l.getHash(r,n,i,a);void 0===this._textureSetMap[o]&&(this._textureSetMap[o]=new d(new l(r,n,i,a)));var s=this._textureSetMap[o],u=s.takeOrGenerate(e,t);return u},updateStats:function(e,t){var r=0,n=0;for(var i in this._textureSetMap){var a=this._textureSetMap[i].getProfile(),o=a.getSize(),s=this._textureSetMap[i].getUsedTextureObjects().length,u=this._textureSetMap[i].getOrphanedTextureObjects().length;r+=s*o,n+=u*o}var c=1048576;t.getCounter("textureused").set(r/c),t.getCounter("texturereserved").set(n/c),t.getCounter("texturetotal").set((r+n)/c)},reportStats:function(){var e=0;for(var t in this._textureSetMap){var r=this._textureSetMap[t].getProfile(),i=r.getSize()/1048576,a=this._textureSetMap[t].getUsedTextureObjects().length;i*=a,e+=i,n["a"].notice(String(i)+" MB with "+a+" texture of "+r._width+"x"+r._height+" "+r._internalFormat)}n["a"].notice(String(e)+" MB in total")},flushAllDeletedTextureObjects:function(e){for(var t in this._textureSetMap)this._textureSetMap[t].flushAllDeletedTextureObjects(e)},onLostContext:function(e){for(var t in this._textureSetMap)this._textureSetMap[t].onLostContext(e)},flushDeletedTextureObjects:function(e,t){var r=t;for(var n in this._textureSetMap)if(r=this._textureSetMap[n].flushDeletedTextureObjects(e,r),r<=0)break;return r},releaseTextureObject:function(e){if(e){var t=e.getTextureSet();t.orphan(e)}}};var _=f,p=r("0fd6"),g=window.ImageBitmap||function(){},m=function(e){return 0!==e&&(e&1+~e)===e},v=function(){a["a"].call(this),u["a"].call(this),this.setDefaultParameters(),this._dirty=!0,this._dirtyMipmap=!0,this._applyTexImage2DCallbacks=[],this._textureObject=void 0,this._textureNull=!0},b=function(e,t){var r=v[e];return void 0===r?(n["a"].warn("bad Texture enum argument "+e+"\nfallback to "+t),t):r};v.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443,v.UNPACK_FLIP_Y_WEBGL=37440,v.BROWSER_DEFAULT_WEBGL=37444,v.NONE=0,v.DEPTH_COMPONENT=6402,v.DEPTH_COMPONENT16=33189,v.DEPTH_STENCIL=34041,v.DEPTH24_STENCIL8=35056,v.DEPTH_COMPONENT24=33190,v.DEPTH_COMPONENT32F=36012,v.COMPRESSED_RGB_S3TC_DXT1_EXT=33776,v.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777,v.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778,v.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779,v.COMPRESSED_RGB_ATC_WEBGL=35986,v.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35987,v.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798,v.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840,v.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841,v.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842,v.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843,v.COMPRESSED_RGB_ETC1_WEBGL=36196,v.LINEAR=9729,v.NEAREST=9728,v.NEAREST_MIPMAP_NEAREST=9984,v.LINEAR_MIPMAP_NEAREST=9985,v.NEAREST_MIPMAP_LINEAR=9986,v.LINEAR_MIPMAP_LINEAR=9987,v.TEXTURE_MAX_ANISOTROPY_EXT=34046,v.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047,v.CLAMP_TO_EDGE=33071,v.REPEAT=10497,v.MIRRORED_REPEAT=33648,v.TEXTURE_2D=3553,v.TEXTURE_CUBE_MAP=34067,v.TEXTURE_BINDING_CUBE_MAP=34068,v.TEXTURE_CUBE_MAP_POSITIVE_X=34069,v.TEXTURE_CUBE_MAP_NEGATIVE_X=34070,v.TEXTURE_CUBE_MAP_POSITIVE_Y=34071,v.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072,v.TEXTURE_CUBE_MAP_POSITIVE_Z=34073,v.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074,v.MAX_CUBE_MAP_TEXTURE_SIZE=34076,v.UNSIGNED_BYTE=5121,v.UNSIGNED_SHORT=5123,v.UNSIGNED_SHORT_4_4_4_4=32819,v.UNSIGNED_SHORT_5_5_5_1=32820,v.UNSIGNED_SHORT_5_6_5=33635,v.FLOAT=5126,v.HALF_FLOAT_OES=36193,v.HALF_FLOAT=5131,v.UNSIGNED_INT_10F_11F_11F_REV=35899,v.UNSIGNED_INT_24_8=34042,v.ALPHA=6406,v.RGB=6407,v.RGBA=6408,v.LUMINANCE=6409,v.LUMINANCE_ALPHA=6410,v.RED_INTEGER=36244,v.RGB_INTEGER=36248,v.RGBA_INTEGER=36249,v.RG_INTEGER=33320,v.RED=6403,v.R8=33321,v.R8UI=33330,v.RG8=33323,v.RG8UI=33336,v.RGB8=36758,v.RGB565=36194,v.RGB9_E5=35901,v.RGB8UI=36221,v.RGBA8=32856,v.RGB5_A1=32855,v.RGBA4=32854,v.RGBA8UI=36220,v.SRGB8_ALPHA8=35907,v.SRGB8=35905,v.R16F=33325,v.RG16F=33327,v.RGB16F=34843,v.RGBA16F=34842,v.R11F_G11F_B10F=35898,v.R32F=33326,v.RG32F=33328,v.RGB32F=34837,v.RGBA32F=34836;var S=function(){var e={};return e[v.R8]=v.LUMINANCE,e[v.R8UI]=v.LUMINANCE,e[v.R16F]=v.LUMINANCE,e[v.R32F]=v.LUMINANCE,e[v.SRGB8]=v.LUMINANCE,e[v.RG8]=v.RGB,e[v.RG8UI]=v.RGB,e[v.RG16F]=v.RGB,e[v.RG32F]=v.RGB,e[v.RGB8]=v.RGB,e[v.RGB565]=v.RGB,e[v.RGB9_E5]=v.RGB,e[v.RGB8UI]=v.RGB,e[v.RGB5_A1]=v.RGB,e[v.RGB16F]=v.RGB,e[v.RGB32F]=v.RGB,e[v.RGBA8]=v.RGBA,e[v.R11F_G11F_B10F]=v.RGBA,e[v.RGBA16F]=v.RGBA,e[v.RGBA32F]=v.RGBA,e[v.SRGB8_ALPHA8]=v.RGBA,e},x=function(){var e={},t={},r={},n={},i={},a={};return e[v.FLOAT]=t,e[v.HALF_FLOAT]=e[v.HALF_FLOAT_OES]=r,e[v.UNSIGNED_SHORT]=n,e[v.UNSIGNED_INT]=i,e[v.UNSIGNED_INT_24_8]=a,r[v.LUMINANCE]=v.R16F,r[v.RGB]=v.RGB16F,r[v.RGBA]=v.RGBA16F,t[v.LUMINANCE]=v.R32F,t[v.RGB]=v.RGB32F,t[v.RGBA]=v.RGBA32F,n[v.DEPTH_COMPONENT]=v.DEPTH_COMPONENT16,i[v.DEPTH_COMPONENT]=v.DEPTH_COMPONENT32F,a[v.DEPTH_STENCIL]=v.DEPTH24_STENCIL8,e},T=S(),y=x();v._sTextureManager=new window.Map,v.getTextureManager=function(e){return v._sTextureManager.has(e)||v._sTextureManager.set(e,new _),v._sTextureManager.get(e)},v.getEnumFromString=function(e){var t=e;return"string"===typeof t&&(t=b(t,e)),t},i["a"].createPrototypeStateAttribute(v,i["a"].objectInherit(u["a"].prototype,i["a"].objectInherit(a["a"].prototype,{attributeType:"Texture",cloneType:function(){return new v},invalidate:function(){this._textureObject=void 0,this._gl=void 0,this.dirty()},dirty:function(){this._dirty=!0},isDirty:function(){return this._dirty},isTextureNull:function(){return this._textureNull},getOrCreateUniforms:function(e){if(void 0===v.uniforms&&(v.uniforms=[]),void 0===v.uniforms[e]){var t=this.getType()+e;v.uniforms[e]={texture:o["a"].createInt1(e,t)}}return v.uniforms[e]},setDefaultParameters:function(){this._image=void 0,this._magFilter=v.LINEAR,this._minFilter=v.LINEAR,this._maxAnisotropy=1,this._wrapS=v.REPEAT,this._wrapT=v.REPEAT,this._textureWidth=0,this._textureHeight=0,this._unrefImageDataAfterApply=!1,this._internalFormat=void 0,this._dirtyMipmap=!0,this._textureTarget=v.TEXTURE_2D,this.setInternalFormatType(v.UNSIGNED_BYTE),this._isCompressed=!1,this._flipY=!0,this._colorSpaceConversion=v.NONE},setColorSpaceConversion:function(e){this._colorSpaceConversion=e},setFlipY:function(e){this._flipY=e},getTextureTarget:function(){return this._textureTarget},getTextureObject:function(){return this._textureObject},setTextureSize:function(e,t){var r=p["a"].instance().getWebGLParameter("MAX_TEXTURE_SIZE");e===this._textureWidth&&t===this._textureHeight||this.dirty(),void 0!==e&&(e>r?(n["a"].error("width ("+e+') too big for GPU. Max Texture Size is "'+r+'"'),this._textureWidth=r):this._textureWidth=e),void 0!==t&&(t>r?(n["a"].error("height ("+t+') too big for GPU. Max Texture Size is "'+r+'"'),this._textureHeight=r):this._textureHeight=t),this._textureNull=!1},init:function(e){this._gl||this.setGraphicContext(e.getGraphicContext()),this._textureObject||(this._textureObject=v.getTextureManager(this._gl).generateTextureObject(this._gl,this,this._textureTarget,this._internalFormat,this._textureWidth,this._textureHeight),this.dirty(),this._dirtyTextureObject=!1,this._textureNull=!1)},addApplyTexImage2DCallback:function(e){var t=this._applyTexImage2DCallbacks.indexOf(e);t<0&&this._applyTexImage2DCallbacks.push(e)},removeApplyTexImage2DCallback:function(e){var t=this._applyTexImage2DCallbacks.indexOf(e);t>=0&&this._applyTexImage2DCallbacks.splice(t,1)},getWidth:function(){return this._textureWidth},getHeight:function(){return this._textureHeight},releaseGLObjects:function(){void 0!==this._textureObject&&null!==this._textureObject&&void 0!==this._gl&&(v.getTextureManager(this._gl).releaseTextureObject(this._textureObject),u["a"].removeObject(this._gl,this)),this.invalidate()},getWrapT:function(){return this._wrapT},getWrapS:function(){return this._wrapS},setWrapS:function(e){this._wrapS="string"===typeof e?b(e,v.CLAMP_TO_EDGE):e,this.dirtyTextureParameters()},setWrapT:function(e){this._wrapT="string"===typeof e?b(e,v.CLAMP_TO_EDGE):e,this.dirtyTextureParameters()},dirtyTextureParameters:function(){this.dirty(),this.dirtyMipmap(),this.dirtyTextureObject()},dirtyTextureObject:function(){this._dirtyTextureObject=!0,this.dirtyMipmap(),this.dirty()},getMinFilter:function(){return this._minFilter},getMagFilter:function(){return this._magFilter},setMaxAnisotropy:function(e){this._maxAnisotropy=e,this.dirtyTextureParameters()},getMaxAnisotropy:function(){return this._maxAnisotropy},setMinFilter:function(e){this._minFilter="string"===typeof e?b(e,v.LINEAR):e,this.dirtyTextureParameters()},setMagFilter:function(e){this._magFilter="string"===typeof e?b(e,v.LINEAR):e,this.dirtyTextureParameters()},setImage:function(e,t){var r=e;(e instanceof window.Image||e instanceof HTMLCanvasElement||e instanceof g||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Float32Array)&&(r=new s["a"](e)),this._image=r,this.setImageFormat(t),r&&(r.getWidth&&r.getHeight?this.setTextureSize(r.getWidth(),r.getHeight()):r.width&&r.height&&this.setTextureSize(r.width,r.height)),this._textureNull=!1,this.dirty()},getImage:function(){return this._image},setImageFormat:function(e){var t=e;t?("string"===typeof t&&(t=v[t]),this._imageFormat=t):this._imageFormat=v.RGBA},setInternalFormatType:function(e){this._type="string"===typeof e?v[e]:e},getInternalFormatType:function(){return this._type},setUnrefImageDataAfterApply:function(e){this._unrefImageDataAfterApply=e},checkIsCompressed:function(e){var t=e||this._internalFormat;switch(t){case v.COMPRESSED_RGB_S3TC_DXT1_EXT:case v.COMPRESSED_RGBA_S3TC_DXT1_EXT:case v.COMPRESSED_RGBA_S3TC_DXT3_EXT:case v.COMPRESSED_RGBA_S3TC_DXT5_EXT:case v.COMPRESSED_RGB_ATC_WEBGL:case v.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL:case v.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL:case v.COMPRESSED_RGB_PVRTC_4BPPV1_IMG:case v.COMPRESSED_RGB_PVRTC_2BPPV1_IMG:case v.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:case v.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:case v.COMPRESSED_RGB_ETC1_WEBGL:return!0;default:return!1}},setInternalFormat:function(e){var t=e;t?("string"===typeof t&&(t=v[t]),this._isCompressed=this.checkIsCompressed(t)):(this._isCompressed=!1,t=v.RGBA),this._internalFormat=t},getInternalFormat:function(){return this._internalFormat},isDirtyMipmap:function(){return this._dirtyMipmap},dirtyMipmap:function(){this._dirtyMipmap=!0},applyFilterParameter:function(e,t){var r=m(this._textureWidth)&&m(this._textureHeight);if(r||(this._wrapT=v.CLAMP_TO_EDGE,this._wrapS=v.CLAMP_TO_EDGE,this._minFilter!==v.LINEAR_MIPMAP_LINEAR&&this._minFilter!==v.LINEAR_MIPMAP_NEAREST||(this._minFilter=v.LINEAR)),e.texParameteri(t,e.TEXTURE_MAG_FILTER,this._magFilter),e.texParameteri(t,e.TEXTURE_MIN_FILTER,this._minFilter),this._maxAnisotropy>1&&v.ANISOTROPIC_SUPPORT_EXT){var n=this._maxAnisotropy<v.ANISOTROPIC_SUPPORT_MAX?this._maxAnisotropy:v.ANISOTROPIC_SUPPORT_MAX;e.texParameterf(t,v.TEXTURE_MAX_ANISOTROPY_EXT,n)}e.texParameteri(t,e.TEXTURE_WRAP_S,this._wrapS),e.texParameteri(t,e.TEXTURE_WRAP_T,this._wrapT)},generateMipmap:function(e,t){if(this._dirtyMipmap=!1,this.hasMipmapFilter()){var r=this._image;if(r&&r.hasMipmap())for(var n=this._getInternalFormatGL(),i=r.getMipmap(),a=1,o=i.length;a<o;a++){var s=i[a];this._isCompressed?this.applyTexImage2D(e,this._textureTarget,a,n,s.getWidth(),s.getHeight(),0,s.getImage()):this.applyTexImage2D(e,this._textureTarget,a,n,s.getWidth(),s.getHeight(),0,this._internalFormat,this._type,s.getImage())}else e.generateMipmap(t)}},hasMipmapFilter:function(){return this._minFilter===v.NEAREST_MIPMAP_NEAREST||this._minFilter===v.LINEAR_MIPMAP_NEAREST||this._minFilter===v.NEAREST_MIPMAP_LINEAR||this._minFilter===v.LINEAR_MIPMAP_LINEAR},applyTexImage2D:function(e){var t=Array.prototype.slice.call(arguments,1);e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,this._flipY),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,this._colorSpaceConversion),this._isCompressed?e.compressedTexImage2D.apply(e,t):e.texImage2D.apply(e,t);var r=this._applyTexImage2DCallbacks.length;if(r>0)for(var n=0,i=r;n<i;n++)this._applyTexImage2DCallbacks[n].call(this)},computeTextureFormat:function(){this._internalFormat||(this._internalFormat=this._imageFormat||v.RGBA),this._imageFormat=this._internalFormat},applyImage:function(e){var t=this._getInternalFormatGL(),r=this._image||null,n=r&&this._image.getImage(),i=this._getTypeGL();this._isCompressed?this.applyTexImage2D(e,this._textureTarget,0,t,this._textureWidth,this._textureHeight,0,n):!n||r.isTypedArray()?this.applyTexImage2D(e,this._textureTarget,0,t,this._textureWidth,this._textureHeight,0,this._internalFormat,i,n):this.applyTexImage2D(e,this._textureTarget,0,t,this._internalFormat,i,n),r&&r.setDirty(!1)},apply:function(e){var t=e.getGraphicContext();if(this._dirtyTextureObject&&(this.releaseGLObjects(),this._dirtyTextureObject=!1,this.setGraphicContext(t)),void 0===this._textureObject||this.isDirty())if(this._textureNull)t.bindTexture(this._textureTarget,null);else{var r=this._image;if(void 0!==r)if(r.isReady()){this.computeTextureFormat();var n=r.getWidth()||this._textureWidth,i=r.getHeight()||this._textureHeight;this.setTextureSize(n,i),this._textureObject||this.init(e),this._textureObject.bind(t),this.applyImage(t),this.applyFilterParameter(t,this._textureTarget),this.generateMipmap(t,this._textureTarget),this._unrefImageDataAfterApply&&(this._image=void 0),this._dirty=!1}else t.bindTexture(this._textureTarget,null);else 0!==this._textureHeight&&0!==this._textureWidth&&(this.computeTextureFormat(),this._textureObject||this.init(e),this._textureObject.bind(t),this.applyImage(t),this.applyFilterParameter(t,this._textureTarget),this.generateMipmap(t,this._textureTarget),this._dirty=!1)}else this._textureObject.bind(t),void 0!==this._image&&this._image.isDirty()&&(this.applyImage(t),this.dirtyMipmap()),this.isDirtyMipmap()&&this.generateMipmap(t,this._textureTarget)},_getInternalFormatGL:function(){var e=this._internalFormat;if(!p["a"].instance().isWebGL2())return T[e]||e;var t=y[this._type];return t&&t[e]||e},_getTypeGL:function(){return this._type!==v.HALF_FLOAT||p["a"].instance().isWebGL2()?this._type:v.HALF_FLOAT_OES}})),"osg","Texture"),v.textureNull=new v,v.createFromImage=function(e,t){var r=new v;return r.setImage(e,t),r},v.createFromCanvas=function(e,t){return v.createFromImage(e,t)};t["default"]=v},8155:function(e,t,r){"use strict";var n=r("2ba4"),i=r("4fd1"),a=function(){n["a"].apply(this,arguments),this.setShaderCompiler(i["a"])};a.prototype=n["a"].prototype,t["a"]=a},"82f0":function(e,t,r){"use strict";var n=r("b797"),i=r("5a16"),a=function(){i["a"].call(this),this.visitorType=i["a"].UPDATE_VISITOR,this._numUpdateCallback=0};n["a"].createPrototypeObject(a,n["a"].objectInherit(i["a"].prototype,{resetStats:function(){this._numUpdateCallback=0},apply:function(e){var t=e.getStateSet();if(t&&t.requiresUpdateTraversal()){var r=t.getUpdateCallbackList(),n=r.length;if(n){this._numUpdateCallback+=n;for(var i=0,a=n;i<a;i++)r[i].update(t,this)}}for(var o=e.getUpdateCallbackList(),s=o.length,u=0;u<s;u++)if(this._numUpdateCallback++,!o[u].update(e,this))return;e.getNumChildrenRequiringUpdateTraversal()>0&&this.traverse(e)}}),"osg","NodeVisitor"),t["a"]=a},"83e3":function(e,t,r){"use strict";var n=r("b797"),i=r("a741"),a=r("38f3"),o=r("c489"),s=r("1391"),u=r("6377"),c=r("3972"),l=r("187b"),h=r("2449"),d=r("ede0"),f=r("02b4"),_=r("1ca0"),p=r("3453"),g=function(){return new u["a"]},m=function(){this._modelViewMatrixStack=new f["a"],this._projectionMatrixStack=new f["a"],this._viewportStack=new f["a"],this._cullingSetStack=new f["a"],this._frustumVolume=-1,this._bbCornerFar=0,this._bbCornerNear=0,this._pooledMatrix=new _["a"](c["c"].create),this._pooledCullingSet=new _["a"](g),this._cameraIndexStack=new f["a"],this._cameraModelViewIndexStack=new f["a"],this._cameraMatrixInverse=new p["a"],this._cameraMatrixInverseRoot=void 0};n["a"].createPrototypeObject(m,n["a"].objectInherit(s["a"].prototype,{reset:function(){this._modelViewMatrixStack.reset(),this._projectionMatrixStack.reset(),this._cullingSetStack.reset(),this._pooledMatrix.reset(),this._pooledCullingSet.reset(),this._cameraModelViewIndexStack.reset(),this._cameraIndexStack.reset(),this._cameraMatrixInverse.reset(),this._cameraMatrixInverseRoot=void 0},getProjectionMatrixStack:function(){return this._projectionMatrixStack},getCurrentProjectionMatrix:function(){return this._projectionMatrixStack.back()},getCurrentModelViewMatrix:function(){return this._modelViewMatrixStack.back()},getCameraInverseMatrix:function(){if(!this._cameraIndexStack.getLength())return this._cameraMatrixInverseRoot;var e=this._cameraIndexStack.back(),t=this.getNodePath()[e],r=t.getInstanceID(),n=this._cameraMatrixInverse.getMap(),i=n[r];if(void 0===i){var a=this._cameraModelViewIndexStack.back(),o=this._modelViewMatrixStack.getArray()[a];i=this._pooledMatrix.getOrCreateObject(),c["c"].invert(i,o),this._cameraMatrixInverse.set(r,i)}return i},getCurrentModelMatrix:function(){var e=this.getCameraInverseMatrix(),t=this._pooledMatrix.getOrCreateObject(),r=c["c"].mul(t,e,this.getCurrentModelViewMatrix());return r},getCurrentViewMatrix:function(){var e=this._modelViewMatrixStack.getArray();return this._cameraIndexStack.getLength()?e[this._cameraModelViewIndexStack.back()]:e[0]},getViewport:function(){if(0!==this._viewportStack.getLength())return this._viewportStack.back()},getLookVectorLocal:function(e){var t=this.getCurrentModelViewMatrix();return c["f"].set(e,-t[2],-t[6],-t[10])},pushViewport:function(e){this._viewportStack.push(e)},popViewport:function(){this._viewportStack.pop()},getFrustumPlanes:function(){var e=c["c"].create();return function(t,r,n,i){c["c"].mul(e,r,n);var a=!!i,o=t[0];o[0]=e[3]-e[0],o[1]=e[7]-e[4],o[2]=e[11]-e[8],o[3]=e[15]-e[12];var s=t[1];s[0]=e[3]+e[0],s[1]=e[7]+e[4],s[2]=e[11]+e[8],s[3]=e[15]+e[12];var u=t[2];u[0]=e[3]+e[1],u[1]=e[7]+e[5],u[2]=e[11]+e[9],u[3]=e[15]+e[13];var h=t[3];if(h[0]=e[3]-e[1],h[1]=e[7]-e[5],h[2]=e[11]-e[9],h[3]=e[15]-e[13],a){var d=t[4];d[0]=e[3]-e[2],d[1]=e[7]-e[6],d[2]=e[11]-e[10],d[3]=e[15]-e[14];var f=t[5];f[0]=e[3]+e[2],f[1]=e[7]+e[6],f[2]=e[11]+e[10],f[3]=e[15]+e[14]}for(var _=i?6:4,p=0;p<_;p++)l["a"].normalizeEquation(t[p])}}(),pushCullingSet:function(){var e=this._pooledCullingSet.getOrCreateObject();this._enableFrustumCulling&&(c["c"].getFrustumPlanes(e.getFrustum().getPlanes(),this.getCurrentProjectionMatrix(),this.getCurrentModelViewMatrix(),!1),e.getFrustum().setupMask(4)),this._cullingSetStack.push(e)},popCullingSet:function(){return this._cullingSetStack.pop()},getCurrentCullingSet:function(){return this._cullingSetStack.back()},pushCurrentMask:function(){var e=this.getCurrentCullingSet();e&&e.pushCurrentMask()},popCurrentMask:function(){var e=this.getCurrentCullingSet();e&&e.popCurrentMask()},isVerticesCulled:function(e){return!!this._enableFrustumCulling&&this.getCurrentCullingSet().isVerticesCulled(e)},isBoundingBoxCulled:function(e){return!!this._enableFrustumCulling&&(e.valid()&&this.getCurrentCullingSet().isBoundingBoxCulled(e))},isBoundingSphereCulled:function(e){return!!this._enableFrustumCulling&&(e.valid()&&this.getCurrentCullingSet().isBoundingSphereCulled(e))},isCulled:function(){var e=new i["a"];return function(t,r){if(!this._enableFrustumCulling)return!1;if(t.isCullingActive()){if(0===this.getCurrentCullingSet().getCurrentResultMask())return!1;var n=this._pooledMatrix.getOrCreateObject();c["c"].identity(n);var i=r.length;return t instanceof h["a"]&&i--,o["a"].computeLocalToWorld(r,!0,n,i),t.getBound().transformMat4(e,n),this.getCurrentCullingSet().isBoundingSphereCulled(e)}return this.getCurrentCullingSet().resetCullingMask(),!1}}(),pushModelViewMatrix:function(){var e=c["f"].create();return function(t){var r=this.getNodePath(),n=r.length;if(n){var i=n-1;r[i].getTypeID()===a["a"].getTypeID()&&r[i].getReferenceFrame()===d["a"].ABSOLUTE_RF&&(this._cameraIndexStack.push(i),this._cameraModelViewIndexStack.push(this._modelViewMatrixStack.getLength()))}else{var o=this._pooledMatrix.getOrCreateObject();c["c"].invert(o,t),this._cameraMatrixInverseRoot=o}this._modelViewMatrixStack.push(t),this.getLookVectorLocal(e),this._bbCornerFar=(e[0]>=0?1:0)|(e[1]>=0?2:0)|(e[2]>=0?4:0),this._bbCornerNear=7&~this._bbCornerFar}}(),popModelViewMatrix:function(){var e=c["f"].create();return function(){var t=this.getNodePath(),r=t.length-1;this._cameraIndexStack.getLength()&&r===this._cameraIndexStack.back()&&(this._cameraIndexStack.pop(),this._cameraModelViewIndexStack.pop()),this._modelViewMatrixStack.pop(),this._modelViewMatrixStack.getLength()?this.getLookVectorLocal(e):c["f"].set(e,0,0,-1),this._bbCornerFar=(e[0]>=0?1:0)|(e[1]>=0?2:0)|(e[2]>=0?4:0),this._bbCornerNear=7&~this._bbCornerFar}}(),pushProjectionMatrix:function(e){this._projectionMatrixStack.push(e),this._frustumVolume=-1,this.pushCullingSet()},popProjectionMatrix:function(){this._projectionMatrixStack.pop(),this._frustumVolume=-1,this.popCullingSet()}}),"osg","CullStack"),t["a"]=m},"850d":function(e,t,r){"use strict";r("d3b7"),r("6062"),r("3ca3"),r("ddb0"),r("4e82"),r("159b");var n=r("f684"),i=r.n(n),a=r("b797"),o=r("5a16"),s=r("e9a6"),u=r("1ad5"),c=function(){o["a"].call(this,o["a"].TRAVERSE_ALL_CHILDREN),this._activePagedLODList=void 0,this._frameNumber=0};a["a"].createPrototypeObject(c,a["a"].objectInherit(o["a"].prototype,{apply:function(e){e.getTypeID()===s["a"].getTypeID()&&(e.setFrameNumberOfLastTraversal(this._frameNumber),this._activePagedLODList.add(e)),this.traverse(e)},set:function(e,t){this._activePagedLODList=e,this._frameNumber=t}}),"osgDB","FindPagedLODsVisitor");var l=function(){o["a"].call(this,o["a"].TRAVERSE_ALL_CHILDREN)};a["a"].createPrototypeObject(l,a["a"].objectInherit(o["a"].prototype,{apply:function(e){e.releaseGLObjects(),this.traverse(e)}}),"osgDB","ReleaseVisitor");var h=function(){o["a"].call(this,o["a"].TRAVERSE_ALL_CHILDREN),this._childrenList=[]};a["a"].createPrototypeObject(h,a["a"].objectInherit(o["a"].prototype,{apply:function(e){e.getTypeID()===s["a"].getTypeID()&&(this._childrenList.push(e),this._markRequestsExpired(e)),this.traverse(e)},removeExpiredChildrenAndFindPagedLODs:function(e,t,r,n){if(!e.children.length)return!1;var i=n.length;e.removeExpiredChildren(t,r,n);for(var a=i;a<n.length;a++)n[a].accept(this);return i!==n.length},_markRequestsExpired:function(e){for(var t,r=e._perRangeDataList.length,n=0;n<r;n++)t=e.getDatabaseRequest(n),void 0!==t&&(t._groupExpired=!0,t._loadedModel=null)},reset:function(){this._childrenList.length=0}}),"osgDB","ExpiredPagedLODVisitor");var d=function(e,t){return t._timeStamp-e._timeStamp},f=function(e,t){var r=e._timeStamp-t._timeStamp;return 0===r&&(r=e._priority-t._priority),r},_=function(){this._pendingRequests=[],this._pendingNodes=[],this._loading=!1,this._progressCallback=void 0,this._lastCB=!0,this._activePagedLODList=new Set,this._childrenToRemoveList=new Set,this._downloadingRequestsNumber=0,this._maxRequestsPerFrame=10,this._acceptNewRequests=!0,this._releaseVisitor=new l,this._expiredPagedLODVisitor=new h,this._findPagedLODsVisitor=new c,this._targetMaximumNumberOfPagedLOD=75,this._elapsedTime=0,this._beginTime=0,this._availableTime=0},p=function(){this._loadedModel=void 0,this._group=void 0,this._url=void 0,this._function=void 0,this._timeStamp=0,this._groupExpired=!1,this._priority=0};a["a"].createPrototypeObject(_,{setTargetMaximumNumberOfPageLOD:function(e){this._targetMaximumNumberOfPagedLOD=e},getTargetMaximumNumberOfPageLOD:function(){return this._targetMaximumNumberOfPagedLOD},setAcceptNewDatabaseRequests:function(e){this._acceptNewRequests=e},getAcceptNewDatabaseRequests:function(){return this._acceptNewRequests},reset:function(){this._pendingRequests=[],this._pendingNodes=[],this._loading=!1,this._lastCB=!0,this._activePagedLODList.clear(),this._childrenToRemoveList.clear(),this._downloadingRequestsNumber=0,this._maxRequestsPerFrame=10,this._acceptNewRequests=!0,this._targetMaximumNumberOfPagedLOD=75},updateSceneGraph:function(e){void 0!==this._progressCallback&&this.executeProgressCallback(),this.removeExpiredSubgraphs(e,.0025),this.takeRequests(),this.addLoadedDataToSceneGraph(e,.005)},executeProgressCallback:function(){this._pendingRequests.length>0||this._pendingNodes.length>0?(this._progressCallback(this._pendingRequests.length+this._downloadingRequestsNumber,this._pendingNodes.length),this._lastCB=!1):this._lastCB||(this._progressCallback(this._pendingRequests.length+this._downloadingRequestsNumber,this._pendingNodes.length),this._lastCB=!0)},setMaxRequestsPerFrame:function(e){this._maxRequestsPerFrame=e},getMaxRequestsPerFrame:function(){return this._maxRequestsPerFrame},getRequestListSize:function(){return this._pendingRequests.length+this._downloadingRequestsNumber},setProgressCallback:function(e){this._progressCallback=e},addLoadedDataToSceneGraph:function(e,t){if(!this._pendingNodes.length||t<=0)return 0;var r=0,n=u["a"].instance().tick();this._pendingNodes.sort(d);for(var i=0;i<this._pendingNodes.length;i++){if(r>t)return 0;var a=this._pendingNodes.shift(),o=e.getFrameNumber(),s=e.getSimulationTime();if(!1===a._groupExpired){var c=a._group;c.setTimeStamp(c.children.length,s),c.setFrameNumber(c.children.length,o),c.addChildNode(a._loadedModel),this._activePagedLODList.has(c)?this.registerPagedLODs(a._loadedModel,o):this.registerPagedLODs(c,o)}else a._loadedModel=void 0,a=void 0;r=u["a"].instance().deltaS(n,u["a"].instance().tick())}return t-=r,t},isLoading:function(){return this._loading},registerPagedLODs:function(e,t){e&&(this._findPagedLODsVisitor.set(this._activePagedLODList,t),e.accept(this._findPagedLODsVisitor))},requestNodeFile:function(e,t,r,n,i){if(this._acceptNewRequests){var a=new p;return a._group=r,a._function=e,a._url=t,a._timeStamp=n,a._priority=i,this._pendingRequests.push(a),a}},takeRequests:function(){if(this._pendingRequests.length){var e=Math.min(this._maxRequestsPerFrame,this._pendingRequests.length);this._pendingRequests.sort(f);for(var t=0;t<e;t++)this._downloadingRequestsNumber++,this.processRequest(this._pendingRequests.shift())}},processRequest:function(e){this._loading=!0;var t=this;if(e._groupExpired)return t._downloadingRequestsNumber--,void(this._loading=!1);void 0!==e._function?this.loadNodeFromFunction(e._function,e._group).then((function(r){t._downloadingRequestsNumber--,e._loadedModel=r,t._pendingNodes.push(e),t._loading=!1})):""!==e._url&&this.loadNodeFromURL(e._url).then((function(r){t._downloadingRequestsNumber--,e._loadedModel=r,t._pendingNodes.push(e),t._loading=!1}))},loadNodeFromFunction:function(e,t){var r=e(t);return r?r&&r.then?r:i.a.resolve(r):i.a.reject()},loadNodeFromURL:function(e){var t=r("7440").default;return t.readNodeURL(e)},releaseGLExpiredSubgraphs:function(e){return this._availableTime=e,!this._childrenToRemoveList.size||e<=0?0:(this._elapsedTime=0,this._beginTime=u["a"].instance().tick(),this._childrenToRemoveList.forEach(this._releaseExpiredSubgraphs,this),this._availableTime-=this._elapsedTime,this._availableTime)},_releaseExpiredSubgraphs:function(e){this._elapsedTime>this._availableTime||(this._childrenToRemoveList.delete(e),e.accept(this._releaseVisitor),e.removeChildren(),e=null,this._elapsedTime=u["a"].instance().deltaS(this._beginTime,u["a"].instance().tick()))},removeExpiredSubgraphs:function(e,t){if(0===e.getFrameNumber())return 0;var r=this._activePagedLODList.size-this._targetMaximumNumberOfPagedLOD,n=e.getSimulationTime()-.1,i=e.getFrameNumber()-1;return r>0&&(t=this.removeExpiredChildren(r,n,i,t)),t},removeExpiredChildren:function(e,t,r,n){var i=0,a=u["a"].instance().tick(),o=this,s=[],c=this._expiredPagedLODVisitor;return c.reset(),this._activePagedLODList.forEach((function(l){if(i>n)return 0;if(e<0)return n;if(r<l.getFrameNumberOfLastTraversal())return n;c.removeExpiredChildrenAndFindPagedLODs(l,t,r,s);for(var h=0;h<c._childrenList.length;h++)o._activePagedLODList.delete(c._childrenList[h]),e--;for(h=0;h<s.length;h++)o._childrenToRemoveList.add(s[h]);c._childrenList.length=0,s.length=0,i=u["a"].instance().deltaS(a,u["a"].instance().tick())})),n-=i,n}},"osgDB","DatabasePager"),t["a"]=_},"875b":function(e,t,r){"use strict";r("d3b7"),r("25f0");var n=r("b797"),i=r("123d"),a=r("2857"),o=r("3972"),s=function(e,t){i["a"].call(this);var r=void 0!==e?e:0;this._ambient=o["g"].fromValues(.2,.2,.2,1),this._diffuse=o["g"].fromValues(.8,.8,.8,1),this._specular=o["g"].fromValues(.2,.2,.2,1),this._position=o["g"].fromValues(0,0,1,0),this._direction=o["f"].fromValues(0,0,-1),this._ground=o["g"].fromValues(.2,.2,.2,-1),this._spotCutoff=180,this._spotBlend=.01,this._attenuation=o["g"].fromValues(1,0,0,0),this._lightNumber=r,this._enable=!t,this._dirtyHash=!0,this._hash=""};s.DIRECTION="DIRECTION",s.SPOT="SPOT",s.POINT="POINT",s.HEMI="HEMI",s.uniforms={},n["a"].createPrototypeStateAttribute(s,n["a"].objectInherit(i["a"].prototype,{attributeType:"Light",cloneType:function(){return new s(this._lightNumber,!0)},getTypeMember:function(){return this.attributeType+this._lightNumber},getUniformName:function(e){return"u"+this.getTypeMember()+"_"+e},getHash:function(){return this._dirtyHash?(this._hash=this._computeInternalHash(),this._dirtyHash=!1,this._hash):this._hash},_computeInternalHash:function(){return this.getTypeMember()+this.getLightType()+this.isEnabled().toString()},getOrCreateUniforms:function(){var e=s,t=this.getTypeMember();return e.uniforms[t]||(e.uniforms[t]={viewPosition:a["a"].createFloat4(this.getUniformName("viewPosition")),viewDirection:a["a"].createFloat3(this.getUniformName("viewDirection")),modelViewMatrix:a["a"].createMatrix4(this.getUniformName("modelViewMatrix")),modelViewNormalMatrix:a["a"].createMatrix3(this.getUniformName("modelViewNormalMatrix")),ambient:a["a"].createFloat4(this.getUniformName("ambient")),diffuse:a["a"].createFloat4(this.getUniformName("diffuse")),specular:a["a"].createFloat4(this.getUniformName("specular")),attenuation:a["a"].createFloat4(this.getUniformName("attenuation")),spotCutOff:a["a"].createFloat1(this.getUniformName("spotCutOff")),spotBlend:a["a"].createFloat1(this.getUniformName("spotBlend")),ground:a["a"].createFloat4(this.getUniformName("ground"))}),e.uniforms[t]},isEnabled:function(){return this._enable},setEnabled:function(e){this._enable=e,this._dirtyHash=!0},setAmbient:function(e){o["g"].copy(this._ambient,e)},getAmbient:function(){return this._ambient},setDiffuse:function(e){o["g"].copy(this._diffuse,e)},getDiffuse:function(){return this._diffuse},setSpecular:function(e){o["g"].copy(this._specular,e)},getSpecular:function(){return this._specular},setPosition:function(e){o["g"].copy(this._position,e)},getPosition:function(){return this._position},setDirection:function(e){o["f"].copy(this._direction,e)},getDirection:function(){return this._direction},setSpotCutoff:function(e){this._spotCutoff=e},getSpotCutoff:function(){return this._spotCutoff},setSpotBlend:function(e){this._spotBlend=e},getSpotBlend:function(){return this._spotBlend},setGround:function(e){o["f"].copy(this._ground,e)},getGround:function(){return this._ground},setConstantAttenuation:function(e){this._attenuation[0]=e},getConstantAttenuation:function(){return this._attenuation[0]},setLinearAttenuation:function(e){this._attenuation[1]=e},getLinearAttenuation:function(){return this._attenuation[1]},setQuadraticAttenuation:function(e){this._attenuation[2]=e},getQuadraticAttenuation:function(){return this._attenuation[2]},setLightType:function(e){return e===s.DIRECTION?this.setLightAsDirection():e===s.SPOT?this.setLightAsSpot():e===s.HEMI?this.setLightAsHemi():this.setLightAsPoint()},getLightType:function(){return this.isDirectionLight()?s.DIRECTION:this.isSpotLight()?s.SPOT:this.isHemiLight()?s.HEMI:s.POINT},setLightAsSpot:function(){o["g"].set(this._position,0,0,0,1),o["f"].set(this._direction,0,0,-1),this._ground[3]=-1,this._spotCutoff=90,this._dirtyHash=!0},setLightAsPoint:function(){o["g"].set(this._position,0,0,0,1),o["f"].set(this._direction,0,0,-1),this._ground[3]=-1,this._dirtyHash=!0},setLightAsDirection:function(){o["g"].set(this._position,0,0,1,0),this._spotCutoff=180,this._ground[3]=-1,this._dirtyHash=!0},setLightAsHemi:function(){o["g"].set(this._position,0,0,1,0),this._spotCutoff=180,this._ground[3]=1,this._dirtyHash=!0},setLightNumber:function(e){this._lightNumber=e,this._dirtyHash=!0},getLightNumber:function(){return this._lightNumber},isSpotLight:function(){return this._spotCutoff<180},isDirectionLight:function(){return 0===this._position[3]&&-1===this._ground[3]},isHemiLight:function(){return 1===this._ground[3]},applyPositionedUniform:function(e){var t=this.getOrCreateUniforms(),r=t.modelViewMatrix.getInternalArray(),n=t.modelViewNormalMatrix.getInternalArray(),i=t.viewPosition.getInternalArray(),a=t.viewDirection.getInternalArray();o["c"].copy(r,e),o["b"].normalFromMat4(n,e),o["g"].transformMat4(i,this._position,r),o["f"].transformMat3(a,this._direction,n)},apply:function(){if(this._enable){var e=this.getOrCreateUniforms();if(this.isSpotLight()){var t=Math.cos(this._spotCutoff*Math.PI/180);e.spotCutOff.setFloat(t),e.spotBlend.setFloat((1-t)*this._spotBlend)}this.isHemiLight()&&e.ground.setFloat4(this._ground),e.attenuation.setFloat4(this._attenuation),e.diffuse.setFloat4(this._diffuse),e.specular.setFloat4(this._specular),e.ambient.setFloat4(this._ambient)}}}),"osg","Light"),t["a"]=s},"8bd2":function(module,__webpack_exports__,__webpack_require__){"use strict";var D_work_files_queen3d_node_modules_babel_runtime_helpers_esm_typeof_js__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__("53ca"),core_js_modules_es_regexp_constructor_js__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__("4d63"),core_js_modules_es_regexp_constructor_js__WEBPACK_IMPORTED_MODULE_1___default=__webpack_require__.n(core_js_modules_es_regexp_constructor_js__WEBPACK_IMPORTED_MODULE_1__),core_js_modules_es_regexp_dot_all_js__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__("c607"),core_js_modules_es_regexp_dot_all_js__WEBPACK_IMPORTED_MODULE_2___default=__webpack_require__.n(core_js_modules_es_regexp_dot_all_js__WEBPACK_IMPORTED_MODULE_2__),core_js_modules_es_regexp_exec_js__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__("ac1f"),core_js_modules_es_regexp_exec_js__WEBPACK_IMPORTED_MODULE_3___default=__webpack_require__.n(core_js_modules_es_regexp_exec_js__WEBPACK_IMPORTED_MODULE_3__),core_js_modules_es_regexp_sticky_js__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__("2c3e"),core_js_modules_es_regexp_sticky_js__WEBPACK_IMPORTED_MODULE_4___default=__webpack_require__.n(core_js_modules_es_regexp_sticky_js__WEBPACK_IMPORTED_MODULE_4__),core_js_modules_es_regexp_to_string_js__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__("25f0"),core_js_modules_es_regexp_to_string_js__WEBPACK_IMPORTED_MODULE_5___default=__webpack_require__.n(core_js_modules_es_regexp_to_string_js__WEBPACK_IMPORTED_MODULE_5__),core_js_modules_es_string_replace_js__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__("5319"),core_js_modules_es_string_replace_js__WEBPACK_IMPORTED_MODULE_6___default=__webpack_require__.n(core_js_modules_es_string_replace_js__WEBPACK_IMPORTED_MODULE_6__),core_js_modules_es_array_join_js__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__("a15b"),core_js_modules_es_array_join_js__WEBPACK_IMPORTED_MODULE_7___default=__webpack_require__.n(core_js_modules_es_array_join_js__WEBPACK_IMPORTED_MODULE_7__),core_js_modules_es_array_filter_js__WEBPACK_IMPORTED_MODULE_8__=__webpack_require__("4de4"),core_js_modules_es_array_filter_js__WEBPACK_IMPORTED_MODULE_8___default=__webpack_require__.n(core_js_modules_es_array_filter_js__WEBPACK_IMPORTED_MODULE_8__),core_js_modules_es_object_to_string_js__WEBPACK_IMPORTED_MODULE_9__=__webpack_require__("d3b7"),core_js_modules_es_object_to_string_js__WEBPACK_IMPORTED_MODULE_9___default=__webpack_require__.n(core_js_modules_es_object_to_string_js__WEBPACK_IMPORTED_MODULE_9__),core_js_modules_es_array_sort_js__WEBPACK_IMPORTED_MODULE_10__=__webpack_require__("4e82"),core_js_modules_es_array_sort_js__WEBPACK_IMPORTED_MODULE_10___default=__webpack_require__.n(core_js_modules_es_array_sort_js__WEBPACK_IMPORTED_MODULE_10__),core_js_modules_es_regexp_test_js__WEBPACK_IMPORTED_MODULE_11__=__webpack_require__("00b4"),core_js_modules_es_regexp_test_js__WEBPACK_IMPORTED_MODULE_11___default=__webpack_require__.n(core_js_modules_es_regexp_test_js__WEBPACK_IMPORTED_MODULE_11__),core_js_modules_es_string_starts_with_js__WEBPACK_IMPORTED_MODULE_12__=__webpack_require__("2ca0"),core_js_modules_es_string_starts_with_js__WEBPACK_IMPORTED_MODULE_12___default=__webpack_require__.n(core_js_modules_es_string_starts_with_js__WEBPACK_IMPORTED_MODULE_12__),core_js_modules_es_string_match_js__WEBPACK_IMPORTED_MODULE_13__=__webpack_require__("466d"),core_js_modules_es_string_match_js__WEBPACK_IMPORTED_MODULE_13___default=__webpack_require__.n(core_js_modules_es_string_match_js__WEBPACK_IMPORTED_MODULE_13__),core_js_modules_es_string_split_js__WEBPACK_IMPORTED_MODULE_14__=__webpack_require__("1276"),core_js_modules_es_string_split_js__WEBPACK_IMPORTED_MODULE_14___default=__webpack_require__.n(core_js_modules_es_string_split_js__WEBPACK_IMPORTED_MODULE_14__),core_js_modules_es_string_trim_js__WEBPACK_IMPORTED_MODULE_15__=__webpack_require__("498a"),core_js_modules_es_string_trim_js__WEBPACK_IMPORTED_MODULE_15___default=__webpack_require__.n(core_js_modules_es_string_trim_js__WEBPACK_IMPORTED_MODULE_15__),core_js_modules_es_array_splice_js__WEBPACK_IMPORTED_MODULE_16__=__webpack_require__("a434"),core_js_modules_es_array_splice_js__WEBPACK_IMPORTED_MODULE_16___default=__webpack_require__.n(core_js_modules_es_array_splice_js__WEBPACK_IMPORTED_MODULE_16__),core_js_modules_es_object_keys_js__WEBPACK_IMPORTED_MODULE_17__=__webpack_require__("b64b"),core_js_modules_es_object_keys_js__WEBPACK_IMPORTED_MODULE_17___default=__webpack_require__.n(core_js_modules_es_object_keys_js__WEBPACK_IMPORTED_MODULE_17__),_osg_WebGLCaps__WEBPACK_IMPORTED_MODULE_18__=__webpack_require__("0fd6"),_osg_notify__WEBPACK_IMPORTED_MODULE_19__=__webpack_require__("a214"),_shaderLib__WEBPACK_IMPORTED_MODULE_20__=__webpack_require__("a63c"),_osgShadow_shaderLib__WEBPACK_IMPORTED_MODULE_21__=__webpack_require__("d710"),replaceCallback=function(e,t){return"core_"+t},r=function(e,t){return"#define "+t},shaderExtension="(GL_EXT_shader_texture_lod|GL_OES_standard_derivatives|GL_EXT_draw_buffers|GL_EXT_frag_depth;)",regExt=new RegExp("#\\s*extension\\s+"+shaderExtension+".*","g"),globalReg=new RegExp(shaderExtension,"g"),decalrs=[],fragData=function(e,t){var r="glFragData_"+t;return decalrs[t]="layout(location = "+t+") out vec4 "+r+";",r},convert2WebGL2=function(e,t){return e=function(e){return(e=e.replace(regExt,r)).replace(globalReg,replaceCallback)}(e=(e=(e=(e=e.replace(/attribute\s+/g,"in ")).replace(/varying\s+/g,t?"in ":"out ")).replace(/(texture2D|textureCube)\s*\(/g,"texture(")).replace(/(textureCubeLodEXT)\s*\(/g,"textureLod(")),t&&(decalrs.length=0,e=e.replace(/gl_FragData\s*\[\s*(\d+)\s*\]/g,fragData),decalrs.length||decalrs.push("out vec4 glFragColor_0;"),e=(e=e.replace(/gl_FragColor/g,"glFragColor_0")).replace(/void\s+main\s*\(/g,decalrs.join("\n")+"\nvoid main(")),e},NextShaderProcessor={},cbFilterDuplicate=function(e,t,r){return!t||e!==r[t-1]};NextShaderProcessor.getSortedUnique=function(e){return e.sort().filter(cbFilterDuplicate)};var isStringInteger=function(e){return/^[\+|\-]?\d+$/.test(e)},getFinalDefinedValue=function(e,t){for(;e[t]&&t!==e[t];)t=e[t];return t},testIf=function testIf(defines,line){if(line.startsWith("#ifdef"))return void 0!==defines[line.substr(7-line.length)];if(line.startsWith("#ifndef"))return void 0===defines[line.substr(8-line.length)];if(line.startsWith("#else"))return!0;for(var txt=line.match(/[#elif|#if]\s+(.*)/)[1],tokens=txt.split(/\b\d+\b|\W+|defined+/g),i=0;i<tokens.length;++i){var tok=tokens[i];if(tok){var value=getFinalDefinedValue(defines,defines[tok]);void 0===value||isStringInteger(value)||(value=!0),txt=txt.replace(tok,value)}}return eval("var defined = function(x) { return x !== undefined | 0; };\n"+txt)},processBranch=function(e,t,r,n){for(var i=[1],a=t;a<e.length;++a){var o=e[a].trim();if(o.startsWith("#endif"))i.length--;else if(o.startsWith("#el")){var s=i.length-1;0===i[s]?i[s]=testIf(r,o)?1:0:1===i[s]&&(i[s]=2)}else if(o.startsWith("#if"))i.push(testIf(r,o)?1:0);else{for(var u=!0,c=i.length;c--;)u=u&&1===i[c];if(u)if(o.startsWith("#"))if(o.startsWith("#extension"))n.push(o);else if(o.startsWith("#undef"))r[o.match(/#undef\s+(\w+)/)[1]]=void 0,n.push(o);else if(o.startsWith("#define")){var l=o.match(/#define\s+(\w+)\s*(.*)/);-1!==o.indexOf(l[1]+"(")?r[l[1]]={args:o.match(/\(.*?\)/)[0].match(/\w+/g),body:o.match(/\)(.*)/)[1]}:r[l[1]]=l[2]}else console.error("unknown preprocessor line: "+o);else n.push(o)}}},fixIndent=function(e){for(var t=(e=e.replace(/(\n\s*\n)+/g,"\n\n")).split("\n"),r="",n=0;n<t.length;++n){var i=t[n].trim(),a=-1!==i.indexOf("{"),o=-1!==i.indexOf("}");!a&&o&&(r=r.substr(4)),t[n]=r+i,a&&!o&&(r+=" ")}return t.join("\n")},cleanDeclarations=function(e,t){for(var r=0;r<t.length;++r)e=e.replace(t[r],""),t[r]=t[r].replace(/\s+/g," ").replace(/\s+;/,";");return e},handleVaryings=function(e){var t=e.match(/varying\s.*?;/g);if(!t)return e;e=cleanDeclarations(e,t),t=NextShaderProcessor.getSortedUnique(t);for(var r=0;r<t.length;++r)if(-1!==t[r].indexOf("vViewNormal;")){var n=t[0];t[0]=t[r],t[r]=n;break}return"\n"+t.join("\n")+"\n"+e},handleUniforms=function(e){var t=e.match(/uniform\s.*?;/g);return t?(e=cleanDeclarations(e,t),"\n"+(t=NextShaderProcessor.getSortedUnique(t)).join("\n")+"\n"+e):e},handleAttributes=function(e){var t=e.match(/attribute\s.*?;/g);if(!t)return e;e=cleanDeclarations(e,t),t=NextShaderProcessor.getSortedUnique(t);for(var r=0;r<t.length;++r)if(-1!==t[r].indexOf(" Vertex;")){t.unshift(t[r]),t.splice(r+1,1);break}return"\n"+t.join("\n")+"\n"+e},handlePrecision=function(e){var t=e.match(/precision\s+(high|low|medium)p\s+float\s*;/);return t?t[0]+"\n"+e.replace(t[0],""):"precision "+_osg_WebGLCaps__WEBPACK_IMPORTED_MODULE_18__["a"].instance().getShaderMaxPrecisionFloat()+"p float;\n"+e},addExtensions=function(e){var t=e.match(/#extension\s(\w+)\s:\s(\w+)/g);if(!t)return e;t=NextShaderProcessor.getSortedUnique(t);for(var r=0;r<t.length;++r)e=e.replace(t[r],"");return t.join("\n")+"\n"+e},addVersion=function(e){return(_osg_WebGLCaps__WEBPACK_IMPORTED_MODULE_18__["a"].instance().isWebGL2()?"#version 300 es\n":"#version 100\n")+e},hasVersion=function(e){return e.match(/^#\s*version/m)},cbUnroll=function(e,t,r){t=parseInt(t);for(var n="",i=0;i<t;++i)n+=r.replace(/%ID%/g,i);return n},unrollReplace=function(e){return e.replace(/%UNROLL ([0-9]+)%([\s\S]+?)%%/g,cbUnroll)},glslPreprocessShader=function(e){return window.glslesPreprocessor(e,{debugExperimental:!1,defines:[],doStats:!1,extensions:[],pruneComments:!0,logCounts:!1,minify:!1,output:0,preprocess:!0,profileTimeEach:!1,profileTimeGlobal:!1,pruneUnused:!0,pruneDefines:!0,replaceDefine:!0,optimize:!0,tabs:4,whitespace:!0})},extractArguments=function(e,t){for(var r=[""],n=0,i=t;i<e.length;++i){if("("===e[i])n++;else if(")"===e[i]){if(0===n)return[r,i+1];if(0===--n){r[r.length-1]+=e[i];continue}}","!==e[i]||0!==n?r[r.length-1]+=e[i]:r.push("")}},replaceRange=function(e,t,r,n){return e.substring(0,t)+n+e.substring(r)},resolveDefineFunction=function(e,t,r){var n=new RegExp("\\b"+t+"\\b\\s*\\(","g"),i=e.match(n);if(!i)return e;for(var a=r.args,o=r.body,s=0;s<i.length;++s){var u=i[s],c=e.indexOf(u),l=c+u.length,h=extractArguments(e,l),d=h[0],f=o.replace(/\w+/g,(function(e){var t=a.indexOf(e);return-1!==t?d[t]:e}));e=replaceRange(e,c,h[1],f)}return e},resolveDefines=function(e,t){for(var r=Object.keys(t),n=0;n<r.length;++n){for(var i=r[n],a=t[i],o="object"==Object(D_work_files_queen3d_node_modules_babel_runtime_helpers_esm_typeof_js__WEBPACK_IMPORTED_MODULE_0__["a"])(a),s=!o&&new RegExp("\\b"+i+"\\b","g"),u=n+1;u<r.length;++u){var c=r[u],l=t[c];void 0!==l&&("object"==Object(D_work_files_queen3d_node_modules_babel_runtime_helpers_esm_typeof_js__WEBPACK_IMPORTED_MODULE_0__["a"])(l)?l.body=o?resolveDefineFunction(l.body,i,a):l.body.replace(s,a):t[c]=o?resolveDefineFunction(l,i,a):l.replace(s,a))}e=o?resolveDefineFunction(e,i,a):e.replace(s,a)}return e},extensions=["EXT_shader_texture_lod","EXT_draw_buffers","EXT_frag_depth","OES_standard_derivatives"],getDefaultDefines=function(){for(var e={},t=_osg_WebGLCaps__WEBPACK_IMPORTED_MODULE_18__["a"].instance(),r=t.getWebGLExtensions(),n=0;n<extensions.length;++n){var i=extensions[n];r[i]&&(e["GL_"+i]="GL_"+i)}return"high"===t.getShaderMaxPrecisionFloat()&&(e.GL_FRAGMENT_PRECISION_HIGH="GL_FRAGMENT_PRECISION_HIGH"),e},fastPreprocess=function(e){e=e.replace(/(\/\*([\s\S]*?)\*\/)|(\/\/(.*)$)/gm,"");var t=getDefaultDefines(),r=[];return processBranch(e.split("\n"),0,t,r,!0),resolveDefines(r.join("\n"),t)},preprocess=function(e){var t=e.match("#define SHADER_NAME .*"),r=!1;return e=r&&window.glslesPreprocessor?glslPreprocessShader(e):fastPreprocess(e),t?t[0]+"\n"+e:e};NextShaderProcessor.processIncludes=function(e,t){return e.replace(/#pragma include (["^+"]?["\ "[a-zA-Z_0-9](.*)"]*?)/g,(function(e,r){var n=r.split(" ")[0].replace(/"/g,"");return-1!==t.indexOf(n)?"":(t.push(n),NextShaderProcessor.processIncludes(NextShaderProcessor.getShaderTextPure(n),t))}))},NextShaderProcessor.processShader=function(e){if(hasVersion(e))return e;var t=NextShaderProcessor.processIncludes(e,[]),r=-1===t.indexOf("gl_Position");return t=t.replace(/#pragma DECLARE_FUNCTION/g,"//#pragma DECLARE_FUNCTION"),t=t.replace(/\\\n/g,""),t=unrollReplace(t),t=preprocess(t),t=handleVaryings(t),t=handleUniforms(t),t=handleAttributes(t),t=fixIndent(t),_osg_WebGLCaps__WEBPACK_IMPORTED_MODULE_18__["a"].instance().isWebGL2()&&convert2WebGL2(t,r),t=handlePrecision(t),t=addExtensions(t),addVersion(t)};var shadersText={};NextShaderProcessor.addShaders=function(e){for(var t in e)shadersText[t]=e[t]},NextShaderProcessor.hasShader=function(e){return void 0!==shadersText[e]},NextShaderProcessor.getShaderTextPure=function(e){var t=shadersText[e];return t||_osg_notify__WEBPACK_IMPORTED_MODULE_19__["a"].error("shader file/text: "+e+" not registered"),t},NextShaderProcessor.getShader=function(e){var t=NextShaderProcessor.getShaderTextPure(e);return NextShaderProcessor.processShader(t)},NextShaderProcessor.addShaders(_shaderLib__WEBPACK_IMPORTED_MODULE_20__["a"]),NextShaderProcessor.addShaders(_osgShadow_shaderLib__WEBPACK_IMPORTED_MODULE_21__["a"]),__webpack_exports__["a"]=NextShaderProcessor},"8c22":function(e,t,r){"use strict";r("4ec9"),r("d3b7"),r("3ca3"),r("ddb0"),r("a434");var n=r("b797"),i=r("40fc"),a=r("16cb"),o=r("1ad5"),s=function(){a["a"].call(this),this._instanceID=i["a"].getInstanceID(),this._vaoObject=void 0,this.dirty()};s._sDeletedGLVertexArrayObjectCache=new window.Map,s.deleteGLVertexArrayObject=function(e,t){s._sDeletedGLVertexArrayObjectCache.has(e)||s._sDeletedGLVertexArrayObjectCache.set(e,[]),s._sDeletedGLVertexArrayObjectCache.get(e).push(t)},s.flushDeletedGLVertexArrayObjects=function(e,t){if(t<=0)return t;if(!s._sDeletedGLVertexArrayObjectCache.has(e))return t;for(var r=0,n=o["a"].instance().tick(),i=s._sDeletedGLVertexArrayObjectCache.get(e),a=i.length,u=a-1;u>=0&&r<t;u--)e.deleteVertexArray(i[u]),i.splice(u,1),r=o["a"].instance().deltaS(n,o["a"].instance().tick());return t-r},s.flushAllDeletedGLVertexArrayObjects=function(e){if(s._sDeletedGLVertexArrayObjectCache.has(e))for(var t=s._sDeletedGLVertexArrayObjectCache.get(e),r=t.length,n=r-1;n>=0;n--)e.deleteVertexArray(t[n]),t.splice(n,1)},s.onLostContext=function(e){if(s._sDeletedGLVertexArrayObjectCache.has(e)){var t=s._sDeletedGLVertexArrayObjectCache.get(e);t.length=0}},n["a"].createPrototypeObject(s,n["a"].objectInherit(a["a"].prototype,{getInstanceID:function(){return this._instanceID},invalidate:function(){this._vaoObject=void 0,this.dirty()},releaseGLObjects:function(){void 0!==this._vaoObject&&void 0!==this._gl&&(s.deleteGLVertexArrayObject(this._gl,this._vaoObject),a["a"].removeObject(this._gl,this)),this.invalidate()},create:function(e){this._vaoObject=e.createVertexArray(),this._dirty=!1},bind:function(e){this._gl||this.setGraphicContext(e);var t=this._vaoObject;t&&e.bindVertexArray(this._vaoObject)},dirty:function(){this._dirty=!0},isDirty:function(){return this._dirty}}),"osg","VertexArrayObject"),t["a"]=s},"8d89":function(e,t,r){"use strict";r.r(t);var n=r("06c5"),i=r("38f3"),a=r("2a7e"),o=r("a995"),s=r("875b"),u=r("3972"),c=r("8130"),l=r("c0d6"),h=r("308b"),d=r("ae6b"),f=r("3e45"),_=r("8c22"),p=r("0fd6"),g=r("a1bc"),m=r("f662"),v=r("2a3fb"),b=r("b690"),S=r("dfe6"),x=r("a214"),T=function e(){this._camera=new i["a"],this._camera.setName("OSGJS camera"),this._scene=new b["a"],this._camera.setName("OSGJS Scene"),this._frameStamp=new a["a"],this._lightingMode=void 0,this._manipulator=void 0,this._canvasWidth=0,this._canvasHeight=0,this._clientWidth,this._clientHeight,this._sizeObserver,this._requestContinousUpdate=!0,this._requestRedraw=!0,this.setLightingMode(e.LightingMode.HEADLIGHT);var t=this.createRenderer(this.getCamera());t.setFrameStamp(this._frameStamp),this.getCamera().setRenderer(t),this.getCamera().setView(this)};T.LightingMode={NO_LIGHT:0,HEADLIGHT:1,SKY_LIGHT:2},T.prototype={requestRedraw:function(){this._requestRedraw=!0},requestContinuousUpdate:function(e){this._requestContinousUpdate=e},createRenderer:function(e){var t=new v["default"](e);return t},setGraphicContext:function(e){this.getCamera().getRenderer().getState().setGraphicContext(e)},getGraphicContext:function(){return this.getCamera().getRenderer().getState().getGraphicContext()},initWebGLCaps:function(e,t){p["a"].instance(e,t)},computeCanvasSize:function(e){var t="undefined"!==typeof OffscreenCanvas;t&&e instanceof OffscreenCanvas?(this._clientWidth=e.width,this._clientHeight=e.height):this._sizeObserver||(window.ResizeObserver?(this._sizeObserver=new ResizeObserver(function(){this._clientWidth=e.clientWidth,this._clientHeight=e.clientHeight}.bind(this)),this._sizeObserver.observe(e),this._clientWidth=e.clientWidth,this._clientHeight=e.clientHeight):(this._clientWidth=e.clientWidth,this._clientHeight=e.clientHeight)),this._clientWidth<1&&(this._clientWidth=1),this._clientHeight<1&&(this._clientHeight=1);var r=this._devicePixelRatio,n=Math.floor(this._clientWidth*r),i=Math.floor(this._clientHeight*r),a=!1;return this._canvasWidth!==n&&(e.width=n,this._canvasWidth=n,a=!0),this._canvasHeight!==i&&(e.height=i,this._canvasHeight=i,a=!0),a},getCanvasWidth:function(){return this._canvasWidth},getCanvasHeight:function(){return this._canvasHeight},getCanvasClientWidth:function(){return Math.ceil(this._canvasWidth/this._devicePixelRatio)},getCanvasClientHeight:function(){return Math.ceil(this._canvasHeight/this._devicePixelRatio)},getCanvasPixelRatio:function(){return this._devicePixelRatio},setUpView:function(e,t){var r=window.devicePixelRatio||1,n=t.getNumber("overrideDevicePixelRatio"),i=t.getNumber("maxDevicePixelRatio")||-1;"number"===typeof n?r=n:-1!==i&&(r=Math.min(r,i)),this._devicePixelRatio=r,this.computeCanvasSize(e);var a=e.width,o=e.height,s=a/o;if(this._camera.setViewport(new f["a"](0,0,a,o)),this._camera.setScissor(new d["a"]),this._camera.setGraphicContext(this.getGraphicContext()),u["c"].lookAt(this._camera.getViewMatrix(),u["f"].fromValues(0,0,-10),u["f"].create(),u["f"].fromValues(0,1,0)),u["c"].perspective(this._camera.getProjectionMatrix(),Math.PI/180*27,s,1,1e3),t&&t.enableFrustumCulling&&this.getCamera().getRenderer().getCullVisitor().setEnableFrustumCulling(!0),t&&t.debugGraph){var c=this.getCamera();S["a"].instance().refreshGraph=function(){var e=S["a"].instance();e.setDisplayGraphRenderer(!0),e.createGraph(c)},x["a"].log("to refresh the graphs type in the console:\nOSG.osgUtil.DisplayGraph.instance().refreshGraph()")}},computeIntersections:function(e,t,r){return void 0===r&&(r=-1),this._lsi?this._lsi.reset():this._lsi=new m["a"],this._origIntersect||(this._origIntersect=u["f"].create(),this._dstIntersect=u["f"].create()),this._lsi.set(u["f"].set(this._origIntersect,e,t,0),u["f"].set(this._dstIntersect,e,t,1)),this._iv?this._iv.reset():(this._iv=new g["a"],this._iv.setIntersector(this._lsi)),this._iv.setTraversalMask(r),this._camera.accept(this._iv),this._lsi.getIntersections()},setFrameStamp:function(e){this._frameStamp=e},getFrameStamp:function(){return this._frameStamp},setCamera:function(e){this._camera=e},getCamera:function(){return this._camera},setSceneData:function(e){var t=this._scene.getSceneData();if(e!==t){this._scene.setSceneData(e);for(var r=this._camera.getChildren(),n=void 0,i=0,a=r.length;i<a;i++)if("osgStats"===r[i].getName()){n=r[i];break}this._camera.removeChildren(),this._camera.addChild(e),n&&this._camera.addChild(n)}},getSceneData:function(){return this._scene.getSceneData()},setDatabasePager:function(e){this._scene.setDatabasePager(e)},getDatabasePager:function(){return this._scene.getDatabasePager()},getScene:function(){return this._scene},getManipulator:function(){return this._manipulator},setManipulator:function(e){this._manipulator=e},getLight:function(){return this._light},setLight:function(e){this._light=e,this._lightingMode!==T.LightingMode.NO_LIGHT&&this._scene.getOrCreateStateSet().setAttributeAndModes(this._light)},getLightingMode:function(){return this._lightingMode},setLightingMode:function(e){this._lightingMode!==e&&(this._lightingMode=e,this._lightingMode!==T.LightingMode.NO_LIGHT?this._light||(this._light=new s["a"]):this._light=void 0)},flushDeletedGLObjects:function(e){var t=this.getGraphicContext(),r=e;r=n["a"].flushDeletedGLBufferArrays(t,r),r=_["a"].flushDeletedGLVertexArrayObjects(t,r),r=c["default"].getTextureManager(t).flushDeletedTextureObjects(t,r),r=l["a"].flushDeletedGLPrograms(t,r),r=h["a"].flushDeletedGLShaders(t,r),r=o["a"].flushDeletedGLFrameBuffers(t,r),o["a"].flushDeletedGLRenderBuffers(t,r)},flushAllDeletedGLObjects:function(){var e=this.getGraphicContext();_["a"].flushAllDeletedGLVertexArrayObjects(e),n["a"].flushAllDeletedGLBufferArrays(e),c["default"].getTextureManager(e).flushAllDeletedTextureObjects(e),l["a"].flushAllDeletedGLPrograms(e),h["a"].flushAllDeletedGLShaders(e),o["a"].flushAllDeletedGLFrameBuffers(e),o["a"].flushAllDeletedGLRenderBuffers(e)}},t["default"]=T},"931a":function(e,t,r){"use strict";var n=r("16f6"),i=function e(t,r){this.mode=n["a"].POINTS,void 0!==t&&("string"===typeof t&&(t=n["a"][t]),this.mode=t),this.count=0,this.offset=0,this.indices=r,this.uType=e.UNSIGNED_SHORT,void 0!==r&&this.setIndices(r)};i.UNSIGNED_BYTE=5121,i.UNSIGNED_SHORT=5123,i.UNSIGNED_INT=5125,i.prototype={getMode:function(){return this.mode},draw:function(e){0!==this.count&&(e.setIndexArray(this.indices),this.drawElements(e))},drawElements:function(e){var t=e.getGraphicContext();t.drawElements(this.mode,this.count,this.uType,this.offset)},setIndices:function(e){this.indices=e;var t=e.getElements();this.count=t.length;var r=t.BYTES_PER_ELEMENT;1===r?this.uType=i.UNSIGNED_BYTE:2===r?this.uType=i.UNSIGNED_SHORT:4===r&&(this.uType=i.UNSIGNED_INT)},getIndices:function(){return this.indices},setFirst:function(e){this.offset=e},getFirst:function(){return this.offset},setCount:function(e){this.count=e},getCount:function(){return this.count},getNumIndices:function(){return this.indices.getElements().length},index:function(e){return this.indices.getElements()[e]}},t["a"]=i},"977b":function(e,t,r){"use strict";var n=r("b797"),i=r("5a16"),a=r("0599"),o=function(e){if(i["a"].call(this),this._buildOptions={_numVerticesProcessed:0,_targetNumTrianglesPerLeaf:50,_maxNumLevels:20},e){var t=e._targetNumTrianglesPerLeaf,r=e._maxNumLevels;void 0!==t&&(this._buildOptions._targetNumTrianglesPerLeaf=t),void 0!==r&&(this._buildOptions._maxNumLevels=r)}};n["a"].createPrototypeObject(o,n["a"].objectInherit(i["a"].prototype,{apply:function(e){if(e.getShape){var t=e.getShape();if(void 0===t){var r=new a["a"];r.build(this._buildOptions,e)&&e.setShape(r)}}this.traverse(e)}}),"osg","KdTreeBuilder"),t["a"]=o},9874:function(e,t,r){"use strict";r("d3b7"),r("cfc3"),r("907a"),r("9a8c"),r("a975"),r("735e"),r("c1ac"),r("d139"),r("3a7b"),r("d5d6"),r("82f8"),r("e91f"),r("60bd"),r("5f96"),r("3280"),r("3fcc"),r("ca91"),r("25a1"),r("cd26"),r("3c5d"),r("2954"),r("649e"),r("219c"),r("170b"),r("b39a"),r("72f7"),r("ddb0");var n=r("b797"),i=r("60b6"),a=r("a214"),o=r("3972"),s=r("9946"),u=r("23f5"),c=r("05ec"),l=r("123d"),h=r("ecf1"),d=function e(){s["a"].call(this),this._shape=null,this._targets=[],this._stateSetAnimation=new u["a"],this._targetWeights=new Float32Array(e.MAX_MORPH_GPU),this._morphAttribute=void 0,this._morphTargetNames=void 0,this._maxMorphGPU=e.MAX_MORPH_GPU,this._isInitialized=!1};d.EFFECTIVE_EPS=.05,d.MAX_MORPH_GPU=4,n["a"].createPrototypeNode(d,n["a"].objectInherit(s["a"].prototype,{init:function(){return this._morphAttribute?(this._isInitialized=!0,!1):(this._morphAttribute=new c["a"](Math.min(this._maxMorphGPU,this.getMorphTargets().length)),this.getStateSetAnimation().setAttributeAndModes(this._morphAttribute,l["a"].ON),this._morphAttribute.setTargetWeights(this.getTargetsWeight()),this._targets[0]?(this._morphTargetNames=window.Object.keys(this._targets[0].getVertexAttributeList()),this._morphAttribute.copyTargetNames(this._morphTargetNames)):(this._morphTargetNames=[],a["a"].error("No Targets in the MorphGeometry !")),this._isInitialized=!0,!0)},getMaximumPossibleMorphGPU:function(){return this._maxMorphGPU},setMaximumPossibleMorphGPU:function(e){this._maxMorphGPU=e,this._isInitialized=!1,this._morphAttribute&&this._morphAttribute.setNumTargets(e)},getMorphTargetNames:function(){return this._morphTargetNames},getStateSetAnimation:function(){return this._stateSetAnimation},getMorphTargets:function(){return this._targets},isInitialized:function(){return this._isInitialized},getTargetsWeight:function(){return this._targetWeights},computeBoundingBox:function(){var e=new h["a"];return function(t){s["a"].prototype.computeBoundingBox.call(this,t);for(var r=0,n=this._targets.length;r<n;r++)t.expandByBoundingBox(this._targets[r].computeBoundingBox(e));return t}}(),mergeChildrenVertexAttributeList:function(){for(var e=0,t=this._targets.length;e<t;e++){var r=this._targets[e],n=r.getVertexAttributeList();for(var a in n){var o=n[a];o&&!o.getBufferArray&&(n[a]=new i["a"](o))}s["a"].appendVertexAttributeToList(r.getVertexAttributeList(),this.getVertexAttributeList(),e)}},_computeEffectiveSumWeights:function(){for(var e=0,t=this._targetWeights,r=0,n=t.length;r<n;++r){var i=t[r];Math.abs(i)<=d.EFFECTIVE_EPS||(e+=i)}var a=1e-5;return Math.abs(e)>a?e:e<0?-a:a},computeTransformedVertex:function(e,t){t=t||o["f"].create();var r=3*e,n=this._targetWeights,i=this.getVertexAttributeList(),a=i.Vertex.getElements(),s=1-this._computeEffectiveSumWeights();t[0]=s*a[r],t[1]=s*a[r+1],t[2]=s*a[r+2];for(var u=0,c=n.length;u<c;++u){var l=n[u];if(!(Math.abs(l)<=d.EFFECTIVE_EPS)){var h=i["Vertex_"+u].getElements();t[0]+=l*h[r],t[1]+=l*h[r+1],t[2]+=l*h[r+2]}}return t},computeTransformedVertices:function(){for(var e=this._targetWeights,t=this.getVertexAttributeList(),r=t.Vertex.getElements(),n=r.length,i=this._morphedVerts=this._morphedVerts||new Float32Array(n),a=1-this._computeEffectiveSumWeights(),o=0;o<n;++o)i[o]=a*r[o];for(var s=0,u=e.length;s<u;++s){var c=e[s];if(!(Math.abs(c)<=d.EFFECTIVE_EPS))for(var l=t["Vertex_"+s].getElements(),h=0;h<n;++h)i[h]+=c*l[h]}return i}}),"osgAnimation","MorphGeometry"),t["a"]=d},9908:function(e,t,r){},9946:function(e,t,r){"use strict";r("99af"),r("a15b"),r("4c53");var n=r("b797"),i=r("a214"),a=r("3714"),o=r("0fd6"),s=r("931a"),u=r("60b6"),c=r("8c22"),l=r("1025"),h=r("3972"),d=function(){a["a"].call(this),this._attributes={},this._primitives=[],this._cacheDrawCall={},this._useVAO=void 0,this._vao={},this._cacheVertexAttributeBufferList={},this._shape=void 0};d.enableVAO=!0,n["a"].createPrototypeNode(d,n["a"].objectInherit(a["a"].prototype,{releaseGLObjects:function(){for(var e in void 0!==this.stateset&&this.stateset.releaseGLObjects(),this._attributes){var t=this._attributes[e];t.releaseGLObjects()}for(var r=0,n=this._primitives.length;r<n;r++){var i=this._primitives[r];void 0!==i.getIndices&&void 0!==i.getIndices()&&null!==i.getIndices()&&i.indices.releaseGLObjects()}this.releaseVAO()},releaseVAO:function(){if(this._useVAO&&this._glContext)for(var e in this._vao)this._vao[e]&&(this._vao[e].releaseGLObjects(),this._vao[e]=void 0)},dirty:function(){this._cacheDrawCall={},this.releaseVAO()},getPrimitives:function(){return this.getPrimitiveSetList()},getAttributes:function(){return this.getVertexAttributeList()},getShape:function(){return this._shape},setShape:function(e){this._shape=e},getVertexAttributeList:function(){return this._attributes},getPrimitiveSetList:function(){return this._primitives},setVertexAttribArray:function(e,t){this._attributes[e]!==t&&(this._attributes[e]=t,this.dirty())},_generateVertexSetup:function(e,t,r){for(var n=["//generated by Geometry::implementation","state.lazyDisablingOfVertexAttributes();","var attr;"],i=0,a=e.length;i<a;i++)n.push("attr = this._attributes['"+e[i]+"'];"),n.push("if ( attr.BufferArrayProxy ) attr = attr.getBufferArray();"),n.push("if ( !attr.isValid() ) return;"),n.push("state.setVertexAttribArray("+t[i]+", attr, attr.getNormalize() );");return n.push("state.applyDisablingOfVertexAttributes();"),r&&n.push("state.setIndexArray( this._primitives[ 0 ].getIndices() );"),n},_generatePrimitives:function(e,t,r){var n=[t?"state.enableVertexColor();":"state.disableVertexColor();"];if(r)return n.concat(["var primitive = this._primitives[ "+e[0]+" ];","var indexes = primitive.getIndices();","if ( indexes.isDirty() ) {;"," indexes.bind( gl );"," indexes.compile( gl );","};","primitive.drawElements( state );"]);n.push("var primitives = this._primitives;");for(var i=0,a=e.length;i<a;i++)n.push("primitives["+e[i]+"].draw(state);");return n},generateDrawCommand:function(){var e=[],t=[];return function(r,n,i,a){var o,l,h,d,f=n._attributesCache,_=this.getVertexAttributeList();t.length=0,e.length=0;var p,g,m=this._useVAO,v=m?[]:void 0,b=!1;for(var S in f)if(o=f[S],d=_[S],void 0!==d){var x=this._attributes[S];if(x instanceof u["a"]&&(x=x.getBufferArray(),m=!1),!x.isValid())return;m&&v.push(x),b||"Color"!==S||(b=!0),t.push(S),e.push(o)}if(m){this._cacheVertexAttributeBufferList[i]=v;var T=1===a.length&&this._primitives[a[0]]instanceof s["a"],y=this._generateVertexSetup(t,e,T);r.clearVertexAttribCache();var C=r.getGraphicContext(),A=new c["a"](C);A.create(C),r.setVertexArrayObject(A),this._vao[i]=A;var E=new Function("state",y.join("\n"));E.call(this,r);var R=["var gl = state.getGraphicContext();","var vao = this._vao[ "+i+" ] ","var hasChanged = state.setVertexArrayObject( vao );","if ( hasChanged ) {"," var vaList = this._cacheVertexAttributeBufferList[ "+i+" ];"," var va;"];for(l=0,h=v.length;l<h;l++)R.push(" va = vaList[ "+l+"];"),R.push(" if ( va.isDirty() ) {;"),R.push(" va.bind( gl );"),R.push(" va.compile( gl );"),R.push(" };");R.push("}"),p=R.concat(this._generatePrimitives(a,b,T)).join("\n"),g="GeometryDrawImplementationCacheVAO"}else p=this._generateVertexSetup(t,e,!1).concat(this._generatePrimitives(a,b,!1)).join("\n"),g="GeometryDrawImplementationCache";var M=new Function("state","return function "+g+"( state ) { "+p+"}")();return this._cacheDrawCall[i]=M,M}}(),_getValidPrimitives:function(){for(var e=[],t=0;t<this._primitives.length;t++){var r=this._primitives[t];r.getCount()?e.push(t):this._warnInvalidPrimitives||(i["a"].warn("geometry with instanceID "+this._instanceID+" has invalid primitives"),this._warnInvalidPrimitives=!0)}return e},drawImplementation:function(e){var t=e.getLastProgramApplied(),r=t.getInstanceID();e.drawGeometry(this);var n=this._cacheDrawCall[r];if(this._vao[r]?this._vao[r].isDirty()&&(n=void 0):e.setVertexArrayObject(null),n)n.call(this,e);else if(this._primitives.length){var a=this._getValidPrimitives();a.length&&(void 0===this._useVAO&&d.enableVAO&&(this._useVAO=o["a"].instance().hasVAO(),this._glContext=e.getGraphicContext()),n=this.generateDrawCommand(e,t,r,a),n.call(this,e),e.setVertexArrayObject(null))}else this._warnNoPrimitives||(i["a"].warn("geometry with instanceID "+this._instanceID+" has no primitives"),this._warnNoPrimitives=!0)},setBound:function(e){this._boundingBox=e,this._boundingBoxComputed=!0},computeCentroid:function(){if(!0===this._centroidComputed)return h["f"].clone(this._centroid);this._centroid=h["f"].create();var e=1/3,t=0,r=h["f"].create(),n=h["f"].create(),i=this.getVertexAttributeList().Vertex.getElements(),a={operatorTriangle:function(i,a,o){h["f"].sub(r,a,i),h["f"].sub(n,o,i);var s=h["f"].dot(r,n)/2;h["f"].add(r,i,a),h["f"].add(n,o,r),h["f"].scale(r,n,e*s),t+=s,h["f"].add(this._centroid,this._centroid,r)}.bind(this)};return Object(l["a"])(this,a,i),h["f"].scale(this._centroid,this._centroid,1/t),this._centroidComputed=!0,h["f"].clone(this._centroid)},computeBoundingBox:function(e){e.init();var t=this.getVertexAttributeList().Vertex;if(t&&t.getElements()&&t.getItemSize()>2){for(var r=t.getElements(),n=t.getItemSize(),i=e.getMin(),a=e.getMax(),o=i[0],s=i[1],u=i[2],c=a[0],l=a[1],h=a[2],d=0,f=r.length;d<f;d+=n){var _=r[d],p=r[d+1],g=r[d+2];_<o&&(o=_),_>c&&(c=_),p<s&&(s=p),p>l&&(l=p),g<u&&(u=g),g>h&&(h=g)}i[0]=o,i[1]=s,i[2]=u,a[0]=c,a[1]=l,a[2]=h}return e},computeBoundingSphere:function(e){e.init();var t=this.getBoundingBox();return e.expandByBoundingBox(t),e}}),"osg","Geometry"),d.appendVertexAttributeToList=function(e,t,r){for(var n in e){var i=n;void 0!==r&&(i+="_"+r),t[i]=e[n]}},t["a"]=d},9998:function(e,t,r){"use strict";r("ac1f"),r("841c"),r("1276"),r("fb6a"),r("a15b"),r("d3b7"),r("a9e3"),r("25f0");var n,i=r("a214"),a=r("b797"),o={antialias:!0,fullscreen:!0,enableFrustumCulling:!1,scrollwheel:!0,webgl2:!1,powerPreference:"high-performance",shaderStats:!1,stats:!1},s=function(){for(var e in o)this[e]=o[e]};s.getOptionsURL=function(){if(n)return n;if(n={},!window.location.search)return n;for(var e,t=[],r=window.location.search.slice(1).split("&"),a=0;a<r.length;a++){e=r[a].split("=");var o=e[0];t.push(o);var s=e[1];"0"!==s&&"false"!==s&&(void 0===s&&(s="1"),n[o]=s)}if(void 0!==n.log){var u=n.log.toLowerCase();switch(u){case"debug":i["a"].setNotifyLevel(i["a"].DEBUG);break;case"info":i["a"].setNotifyLevel(i["a"].INFO);break;case"notice":i["a"].setNotifyLevel(i["a"].NOTICE);break;case"warn":i["a"].setNotifyLevel(i["a"].WARN);break;case"error":i["a"].setNotifyLevel(i["a"].ERROR);break;case"html":var c=[],l=document.createElement("div"),h=document.createElement("pre");document.addEventListener("DOMContentLoaded",(function(){document.body.insertBefore(l,document.body.firstChild),l.appendChild(h)}));var d=function(e){c.unshift(e),h.innerHTML=c.join("\n")};l.style.overflow="hidden",l.style.position="absolute",l.style.zIndex="10000",l.style.height="100%",l.style.maxWidth="600px",l.style.pointerEvents="none",h.style.overflow="scroll",h.style.width="105%",h.style.height="100%",h.style.fontSize="10px",h.style.pointerEvents="none",["log","error","warn","info","debug"].forEach((function(e){window.console[e]=d}));break}}return n},s.prototype={extend:function(e){return a["a"].objectMix(this,e),this},get:function(e){return this[e]},getBoolean:function(e){var t=this.getString(e);if(t)return"false"!==t&&"0"!==t},getNumber:function(e){var t=this[e];if(t)return Number(t)},getString:function(e){var t=this[e];if(void 0!==t)return this[e].toString()},extendWithOptionsURL:function(){this.extend(s.getOptionsURL())}},t["a"]=s},"9a96":function(e,t,r){},"9f78":function(e,t,r){"use strict";var n=r("b797"),i=r("123d"),a=function e(t,r,n,a){i["a"].call(this),this._func=e.LESS,this._near=0,this._far=1,this._writeMask=!0,void 0!==t&&(this._func="string"===typeof t?e[t]:t),void 0!==r&&(this._near=r),void 0!==n&&(this._far=n),void 0!==a&&(this._writeMask=a)};a.DISABLE=0,a.NEVER=512,a.LESS=513,a.EQUAL=514,a.LEQUAL=515,a.GREATER=516,a.NOTEQUAL=517,a.GEQUAL=518,a.ALWAYS=519,n["a"].createPrototypeStateAttribute(a,n["a"].objectInherit(i["a"].prototype,{attributeType:"Depth",cloneType:function(){return new a},setRange:function(e,t){this._near=e,this._far=t},setWriteMask:function(e){this._writeMask=e},getWriteMask:function(){return this._writeMask},getFunc:function(){return this._func},apply:function(e){e.applyDepth(this)}}),"osg","Depth"),t["a"]=a},a1bc:function(e,t,r){"use strict";var n=r("b797"),i=r("5a16"),a=r("3972"),o=r("1ca0"),s=r("02b4"),u=r("ede0"),c=function(){i["a"].call(this),this._intersector=void 0,this._projectionStack=new s["a"],this._modelStack=new s["a"],this._viewStack=new s["a"],this._windowStack=new s["a"],this._pooledMatrix=new o["a"](a["c"].create),this.reset()};n["a"].createPrototypeObject(c,n["a"].objectInherit(i["a"].prototype,{reset:function(){this._pooledMatrix.reset(),this._viewStack.reset(),this._modelStack.reset(),this._projectionStack.reset(),this._windowStack.reset(),this._viewStack.push(a["c"].IDENTITY),this._modelStack.push(a["c"].IDENTITY),this._projectionStack.push(a["c"].IDENTITY),this._windowStack.push(a["c"].IDENTITY)},setIntersector:function(e){this._intersector=e},getIntersector:function(){return this._intersector},pushModelMatrix:function(e){this._modelStack.push(e)},getModelMatrix:function(){return this._modelStack.back()},popModelMatrix:function(){return this._modelStack.pop()},pushViewMatrix:function(e){this._viewStack.push(e)},getViewMatrix:function(){return this._viewStack.back()},popViewMatrix:function(){return this._viewStack.pop()},pushProjectionMatrix:function(e){this._projectionStack.push(e)},getProjectionMatrix:function(){return this._projectionStack.back()},popProjectionMatrix:function(){return this._projectionStack.pop()},pushWindowMatrix:function(e){this._windowStack.push(e)},pushWindowMatrixUsingViewport:function(e){this._windowStack.push(e.computeWindowMatrix(this._pooledMatrix.getOrCreateObject()))},getWindowMatrix:function(){return this._windowStack.back()},popWindowMatrix:function(){return this._windowStack.pop()},getTransformation:function(){var e=a["c"].create64();return function(){return a["c"].copy(e,this.getWindowMatrix()),a["c"].mul(e,e,this.getProjectionMatrix()),a["c"].mul(e,e,this.getViewMatrix()),a["c"].mul(e,e,this.getModelMatrix()),e}}(),enter:function(e){return this._intersector.enter(e)},apply:function(e){e.getViewMatrix?this.applyCamera(e):e.getMatrix?this.applyTransform(e):this.applyNode(e)},applyCamera:function(e){var t,r,n,i=e.getViewport();void 0!==i&&this.pushWindowMatrixUsingViewport(i),e.getReferenceFrame()===u["a"].RELATIVE_RF&&this.getViewMatrix()&&this.getProjectionMatrix()?(t=a["c"].mul(this._pooledMatrix.getOrCreateObject(),this.getProjectionMatrix(),e.getProjectionMatrix()),r=this.getViewMatrix(),n=a["c"].mul(this._pooledMatrix.getOrCreateObject(),this.getModelMatrix(),e.getViewMatrix())):(t=e.getProjectionMatrix(),r=e.getViewMatrix(),n=a["c"].identity(this._pooledMatrix.getOrCreateObject())),this.pushProjectionMatrix(t),this.pushViewMatrix(r),this.pushModelMatrix(n),this._intersector.setCurrentTransformation(this.getTransformation()),this.traverse(e),this.popModelMatrix(),this.popViewMatrix(),this.popProjectionMatrix(),void 0!==i&&this.popWindowMatrix(),this._intersector.setCurrentTransformation(this.getTransformation())},applyNode:function(e){this.enter(e)&&(e.getPrimitiveSetList?this._intersector.intersect(this,e):e.traverse&&this.traverse(e))},applyTransform:function(e){if(this.enter(e)){if(e.getReferenceFrame()===u["a"].ABSOLUTE_RF){var t=this._pooledMatrix.getOrCreateObject();this.pushViewMatrix(a["c"].identity(t)),this.pushModelMatrix(e.getMatrix())}else if(this._modelStack.getLength()>0){var r=a["c"].copy(this._pooledMatrix.getOrCreateObject(),this.getModelMatrix());a["c"].mul(r,r,e.getMatrix()),this.pushModelMatrix(r)}else this.pushModelMatrix(e.getMatrix());this._intersector.setCurrentTransformation(this.getTransformation()),this.traverse(e),this.popModelMatrix(),e.getReferenceFrame()===u["a"].ABSOLUTE_RF&&this.popViewMatrix(),this._intersector.setCurrentTransformation(this.getTransformation())}}}),"osgUtil","IntersectionVisitor"),t["a"]=c},a214:function(e,t,r){"use strict";r("fb6a"),r("a434");var n={};function i(){var e=arguments[0];if(n.console&&!(e>n.currentNotifyLevel)){var t=arguments[1],r=Array.prototype.slice.call(arguments);r=r.splice(2,arguments.length),n.console[t].apply(n.console,r),n.traceLogCall&&e!==n.ERROR&&console.trace()}}function a(e,t,r,i){!n.console||e>n.currentNotifyLevel||(n.console.groupCollapsed&&n.console.groupCollapsed(r),n.console[t](i),n.traceLogCall&&e!==n.ERROR&&console.trace(),n.console.groupEnd&&n.console.groupEnd())}function o(e,t){return t?[e.slice(0,4),e.slice(4,8),e.slice(8,12),e.slice(12,16)]:[[e[0],e[4],e[8],e[12]],[e[1],e[5],e[9],e[13]],[e[2],e[6],e[10],e[14]],[e[3],e[7],e[11],e[15]]]}function s(e,t,r){e>n.currentNotifyLevel||n.console.table&&i("table",o(t,r))}function u(e,t,r,i){e>n.currentNotifyLevel||n.console.table&&a("table",t,o(r,i))}n.ALWAYS=0,n.FATAL=n.ERROR=1,n.WARN=2,n.NOTICE=n.LOG=3,n.INFO=4,n.DEBUG=5,n.currentNotifyLevel=n.LOG,n.console=window.console;for(var c=["error","warn","log","info","debug"],l=0;l<c.length;++l){var h=c[l],d=n[h.toUpperCase()];n[h]=i.bind(n,d,h),n[h+"Fold"]=a.bind(n,d,h),n[h+"Matrix"]=s.bind(n,d),n[h+"MatrixFold"]=u.bind(n,d)}n.group=i.bind(n,n.LOG,"group"),n.groupCollapsed=i.bind(n,n.LOG,"groupCollapsed"),n.groupEnd=n.console.groupEnd,n.notice=n.log,n.noticeFold=n.logFold,n.noticeMatrix=n.logMatrix,n.noticeMatrixFold=n.logMatrixFold,n.timeStamp=function(){},n.console&&n.console.timeStamp?n.timeStamp=function(e){n.console.timeStamp(e)}:n.timeStamp=function(){},n.assert=function(e,t){void 0===this.console||e||this.console.assert(e,t)},n.setNotifyLevel=function(e,t){n.currentNotifyLevel=e,void 0!==t&&(n.traceLogCall=t)},n.getNotifyLevel=function(){return n.currentNotifyLevel},n.reportWebGLError=!1,n.setConsole=function(e){n.console=e},t["a"]=n},a27e:function(e,t,r){"use strict";r("4ec9"),r("d3b7"),r("3ca3"),r("ddb0"),r("fb6a");var n=r("a214"),i=r("b797"),a=r("f53d"),o=r("112b"),s=a["a"].sprintf,u=function(e,t){o["a"].call(this),this._name="Variable",this._prefix=t,this._type=e,this._value=void 0};i["a"].createPrototypeObject(u,i["a"].objectInherit(o["a"].prototype,{getType:function(){return this._type},getVariable:function(){return this._prefix},setValue:function(e){return this._value=e,this},toString:function(){var e=this._name+" "+this._prefix;return this._type&&(e+=" ("+this._type+")"),e+=" - id:"+this._id,e},declare:function(){return void 0!==this._value?s("%s %s = %s;",[this._type,this.getVariable(),this._value]):s("%s %s;",[this._type,this.getVariable()])},isEmpty:function(){return void 0===this._value&&0===this._inputs.length},reset:function(){this._inputs=[],this._outputs=null,this._value=void 0,this._text=void 0}}),"osgShader","Variable");var c=function(e,t){u.call(this,e,t)};i["a"].createPrototypeObject(c,i["a"].objectInherit(u.prototype,{declare:function(){return s("const %s %s = %s;",[this._type,this.getVariable(),this._value])}}),"osgShader","Constant");var l=function(e,t,r){u.call(this,e,t),this._size=r};i["a"].createPrototypeObject(l,i["a"].objectInherit(u.prototype,{declare:function(){},globalDeclaration:function(){return this._size?s("uniform %s %s[%s];",[this._type,this.getVariable(),this._size]):s("uniform %s %s;",[this._type,this.getVariable()])}}),"osgShader","Uniform");var h=function(e,t){u.call(this,e,t)};i["a"].createPrototypeObject(h,i["a"].objectInherit(u.prototype,{declare:function(){},globalDeclaration:function(){return s("attribute %s %s;",[this._type,this.getVariable()])}}),"osgShader","Attribute");var d=function(e,t){u.call(this,e,t)};i["a"].createPrototypeObject(d,i["a"].objectInherit(u.prototype,{declare:function(){},globalDeclaration:function(){return s("varying %s %s;",[this._type,this.getVariable()])}}),"osgShader","Varying");var f=function(e,t){u.call(this,e,t)};i["a"].createPrototypeObject(f,i["a"].objectInherit(u.prototype,{declare:function(){},globalDeclaration:function(){return s("uniform %s %s;",[this._type,this.getVariable()])}}),"osgShader","Sampler");var _=function(e,t){u.call(this,e,t)};i["a"].createPrototypeObject(_,i["a"].objectInherit(u.prototype,{_unique:!0,isUnique:function(){return this._unique},outputs:function(){return this},getVariable:function(){return this._prefix}}),"osgShader","Output");var p=function(){_.call(this,"vec4","gl_FragColor"),this._name="glFragColor"};i["a"].createPrototypeObject(p,i["a"].objectInherit(_.prototype,{}),"osgShader","glFragColor");var g=function(){_.call(this,"vec4","gl_Position"),this._name="glPosition"};i["a"].createPrototypeObject(g,i["a"].objectInherit(_.prototype,{}),"osgShader","glPosition");var m=function(){_.call(this,"float","gl_PointSize"),this._name="glPointSize"};i["a"].createPrototypeObject(m,i["a"].objectInherit(_.prototype,{}),"osgShader","glPointSize");var v=function(e){o["a"].call(this),this._defineName=e,this._defineValue=""};i["a"].createPrototypeObject(v,i["a"].objectInherit(o["a"].prototype,{type:"Define",setValue:function(e){return this._defineValue=e,this},getDefines:function(){return["#define "+this._defineName+" "+this._defineValue]}}),"osgShader","Define");var b={Output:_,glPointSize:m,glPosition:g,glFragColor:p,Sampler:f,Variable:u,Constant:c,Attribute:h,Varying:d,Uniform:l,Define:v},S=(r("4d63"),r("c607"),r("ac1f"),r("2c3e"),r("25f0"),r("466d"),r("6062"),r("5319"),function(){o["a"].call(this)});S.prototype=o["a"].prototype;var x=function(){S.call(this)};i["a"].createPrototypeObject(x,i["a"].objectInherit(S.prototype,{type:"Add",operator:"+",_getFirstVariableCast:function(){var e=this._inputs[0].getVariable(),t=this._inputs[0].getType(),r=this._outputs.getType();return r===t?e:"float"===t?r+"("+e+")":"vec3"===r?e+".rgb":"vec2"===r?e+".rg":"float"===r?e+".r":(n["a"].error("Mismatch type : "+r+" with "+t+", "+e),e)},computeShader:function(){var e=this._outputs.getType(),t="";"vec4"===e?t=".rgba":"vec3"===e?t=".rgb":"vec2"===e&&(t=".rg");for(var r=this._getFirstVariableCast(),n=this._outputs.getVariable()+" = "+r,i=1,a=this._inputs.length;i<a;i++){var o=this._inputs[i];n+=this.operator+o.getVariable();var s=o.getType();"float"!==s&&s!==e&&(n+=t)}return n+=";",n}}),"osgShader","Add");var T=function(){x.call(this)};i["a"].createPrototypeObject(T,i["a"].objectInherit(x.prototype,{type:"Mult",operator:"*"}),"osgShader","Mult");var y=function(){x.call(this)};i["a"].createPrototypeObject(y,i["a"].objectInherit(x.prototype,{type:"SetFromNode"}),"osgShader","SetFromNode");var C=function(){x.call(this),this._overwriteW=!0,this._forceComplement=!0,this._inverseOp=!1};i["a"].createPrototypeObject(C,i["a"].objectInherit(x.prototype,{type:"MatrixMultDirection",operator:"*",validInputs:["vec","matrix"],validOutputs:["vec"],complement:"0.",setInverse:function(e){return this._inverseOp=e,this},setForceComplement:function(e){return this._forceComplement=e,this},setOverwriteW:function(e){return this._overwriteW=e,this},computeShader:function(){var e=this._inputs.vec.getVariable(),t=this._inputs.matrix.getVariable(),r=this._outputs.vec.getVariable(),n=this._inputs.vec.getType(),i=this._outputs.vec.getType(),a=this._inputs.matrix.getType(),o=r;if("mat4"===a){o+=" = ","vec4"!==i&&(o+=i+"(");var s=e;(this._forceComplement||"vec4"!==n)&&(s="vec4("+e+".xyz, "+this.complement+")"),o+=this._inverseOp?s+this.operator+t:t+this.operator+s,"vec4"!==i&&(o+=")"),o+=";",this._overwriteW||"vec4"!==n||(o+="\n"+r+".a = "+e+".a;")}else{"vec4"===i&&(o+=".xyz"),o+=" = ";var u=e+".xyz";o+=(this._inverseOp?u+this.operator+t:t+this.operator+u)+";",this._overwriteW||"vec4"!==i||"vec4"!==n||(o+="\n"+r+".a = "+e+".a;")}return o}}),"osgShader","MatrixMultDirection");var A=function(){C.call(this),this._forceComplement=!1};i["a"].createPrototypeObject(A,i["a"].objectInherit(C.prototype,{type:"MatrixMultPosition",complement:"1."}),"osgShader","MatrixMultPosition");var E=function(){S.apply(this),this._mode="MIX"};i["a"].createPrototypeObject(E,i["a"].objectInherit(S.prototype,{type:"Blend",mode:function(e){return this._mode=e,this},computeShader:function(){return this[void 0===this._mode?"MIX":this._mode]()},ADD:function(){return this._outputs.getVariable()+" = "+this._inputs[0].getVariable()+" + ("+this._inputs[1].getVariable()+" * "+this._inputs[2].getVariable()+");"},MIX:function(){return this._outputs.getVariable()+" = mix("+this._inputs[0].getVariable()+", "+this._inputs[1].getVariable()+", "+this._inputs[2].getVariable()+");"},MULTIPLY:function(){return this._outputs.getVariable()+" = "+this._inputs[0].getVariable()+" * mix( "+this._inputs[0].getType()+"(1.0), "+this._inputs[1].getVariable()+", "+this._inputs[2].getVariable()+");"}}));var R=function(){o["a"].call(this)};i["a"].createPrototypeObject(R,i["a"].objectInherit(o["a"].prototype,{type:"InlineCode",code:function(e){return this._text=e,this},computeShader:function(){var e=i["a"].objectMix({},this._inputs);e=i["a"].objectMix(e,this._outputs);for(var t=new RegExp("%[A-Za-z0-9_]+","gm"),r=this._text,a=this._text.match(t),o=new Set,s=0;s<a.length;s++){var u=a[s].substr(1);if(!o.has(u)){e[u]||(n["a"].error("error with inline code\n"+this._text),n["a"].error("input "+u+" not provided for "+a[s]));var c=new RegExp(a[s].toString(),"gm");r=r.replace(c,e[u].getVariable()),o.add(u)}}return r}}),"osgShader","InlineCode");var M={BaseOperator:S,Mult:T,MatrixMultPosition:A,MatrixMultDirection:C,Add:x,Blend:E,InlineCode:R,SetFromNode:y},w=r("a63c"),N=r("d710"),O=function(){this._nodes=new window.Map,this.extractFunctions(w["a"],"lights.glsl"),this.extractFunctions(w["a"],"lightCommon.glsl"),this.extractFunctions(w["a"],"skinning.glsl"),this.extractFunctions(w["a"],"morphing.glsl"),this.extractFunctions(w["a"],"billboard.glsl"),this.extractFunctions(w["a"],"functions.glsl"),this.extractFunctions(w["a"],"textures.glsl"),this.extractFunctions(N["a"],"shadowCast.glsl"),this.extractFunctions(N["a"],"shadowReceive.glsl"),this.registerNodes(b),this.registerNodes(M)};O.prototype={registerNodes:function(e){for(var t in e)this.registerNode(t,e[t])},registerNode:function(e,t){this._nodes.has(e)&&n["a"].warn("Node "+e+" already registered"),this._nodes.set(e,t)},extractFunctions:function(e,t){this.registerNodes(a["a"].extractFunctions(e,t))},getNode:function(e){var t=this._nodes.get(e);if(t){var r=window.Object.create(t.prototype);return t.apply(r,Array.prototype.slice.call(arguments,1)),r}n["a"].warn("Node "+e+" does not exist")}};var I=new O;t["a"]=I},a63c:function(e,t,r){"use strict";var n="#define PI 3.141593\r\n#define saturate(_x) clamp(_x, 0., 1.)\r\n",i="// approximation such as http://chilliant.blogspot.fr/2012/08/srgb-approximations-for-hlsl.html\r\n// introduced slightly darker colors and more slight banding in the darks.\r\n\r\n// so we stick with the reference implementation (except we don't check if color >= 0.0):\r\n// https://www.khronos.org/registry/gles/extensions/EXT/EXT_sRGB.txt\r\n#define LIN_SRGB(x) x < 0.0031308 ? x * 12.92 : 1.055 * pow(x, 1.0/2.4) - 0.055\r\n#define SRGB_LIN(x) x < 0.04045 ? x * (1.0 / 12.92) : pow((x + 0.055) * (1.0 / 1.055), 2.4)\r\n\r\n#pragma DECLARE_FUNCTION\r\nfloat linearTosRGB(const in float color) { return LIN_SRGB(color); }\r\n\r\n#pragma DECLARE_FUNCTION\r\nvec3 linearTosRGB(const in vec3 color) { return vec3(LIN_SRGB(color.r), LIN_SRGB(color.g), LIN_SRGB(color.b)); }\r\n\r\n#pragma DECLARE_FUNCTION\r\nvec4 linearTosRGB(const in vec4 color) { return vec4(LIN_SRGB(color.r), LIN_SRGB(color.g), LIN_SRGB(color.b), color.a); }\r\n\r\n#pragma DECLARE_FUNCTION NODE_NAME:sRGBToLinear\r\nfloat sRGBToLinear(const in float color) { return SRGB_LIN(color); }\r\n\r\n#pragma DECLARE_FUNCTION NODE_NAME:sRGBToLinear\r\nvec3 sRGBToLinear(const in vec3 color) { return vec3(SRGB_LIN(color.r), SRGB_LIN(color.g), SRGB_LIN(color.b)); }\r\n\r\n#pragma DECLARE_FUNCTION NODE_NAME:sRGBToLinear\r\nvec4 sRGBToLinear(const in vec4 color) { return vec4(SRGB_LIN(color.r), SRGB_LIN(color.g), SRGB_LIN(color.b), color.a); }\r\n\r\n//http://graphicrants.blogspot.fr/2009/04/rgbm-color-encoding.html\r\nvec3 RGBMToRGB( const in vec4 rgba ) {\r\n const float maxRange = 8.0;\r\n return rgba.rgb * maxRange * rgba.a;\r\n}\r\n\r\nconst mat3 LUVInverse = mat3( 6.0013, -2.700, -1.7995, -1.332, 3.1029, -5.7720, 0.3007, -1.088, 5.6268 );\r\n\r\nvec3 LUVToRGB( const in vec4 vLogLuv ) {\r\n float Le = vLogLuv.z * 255.0 + vLogLuv.w;\r\n vec3 Xp_Y_XYZp;\r\n Xp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\r\n Xp_Y_XYZp.z = Xp_Y_XYZp.y / vLogLuv.y;\r\n Xp_Y_XYZp.x = vLogLuv.x * Xp_Y_XYZp.z;\r\n vec3 vRGB = LUVInverse * Xp_Y_XYZp;\r\n return max(vRGB, 0.0);\r\n}\r\n\r\n// http://graphicrants.blogspot.fr/2009/04/rgbm-color-encoding.html\r\n#pragma DECLARE_FUNCTION\r\nvec4 encodeRGBM(const in vec3 color, const in float range) {\r\n if(range <= 0.0) return vec4(color, 1.0);\r\n vec4 rgbm;\r\n vec3 col = color / range;\r\n rgbm.a = clamp( max( max( col.r, col.g ), max( col.b, 1e-6 ) ), 0.0, 1.0 );\r\n rgbm.a = ceil( rgbm.a * 255.0 ) / 255.0;\r\n rgbm.rgb = col / rgbm.a;\r\n return rgbm;\r\n}\r\n\r\n#pragma DECLARE_FUNCTION\r\nvec3 decodeRGBM(const in vec4 color, const in float range) {\r\n if(range <= 0.0) return color.rgb;\r\n return range * color.rgb * color.a;\r\n}\r\n\r\n// https://twitter.com/pyalot/status/711956736639418369\r\n// https://github.com/mrdoob/three.js/issues/10331\r\n#pragma DECLARE_FUNCTION NODE_NAME:FrontNormal\r\n#define _frontNormal(normal) gl_FrontFacing ? normal : -normal\r\n\r\n#pragma DECLARE_FUNCTION NODE_NAME:Normalize\r\n#define _normalize(vec) normalize(vec)\r\n\r\n#pragma DECLARE_FUNCTION\r\nvec4 preMultAlpha(const in vec3 color, const in float alpha) { return vec4(color.rgb * alpha, alpha); }\r\n\r\n#pragma DECLARE_FUNCTION\r\nvec4 preMultAlpha(const in vec4 color) { return vec4(color.rgb * color.a, color.a); }\r\n\r\n#pragma DECLARE_FUNCTION\r\nvec4 setAlpha(const in vec3 color, const in float alpha) { return vec4(color, alpha); }\r\n\r\n#pragma DECLARE_FUNCTION\r\nvec4 setAlpha(const in vec3 color, const in vec4 alpha) { return vec4(color, alpha.a); }\r\n",a="float getLightAttenuation(const in float dist, const in vec4 lightAttenuation) {\r\n // lightAttenuation(constantEnabled, linearEnabled, quadraticEnabled)\r\n // TODO find a vector alu instead of 4 scalar\r\n float constant = lightAttenuation.x;\r\n float linear = lightAttenuation.y * dist;\r\n float quadratic = lightAttenuation.z * dist * dist;\r\n return 1.0 / (constant + linear + quadratic);\r\n}\r\n\r\n#pragma DECLARE_FUNCTION\r\nvoid precomputeSpot(\r\n const in vec3 normal,\r\n const in vec3 viewVertex,\r\n \r\n const in vec3 lightViewDirection,\r\n const in vec4 lightAttenuation,\r\n const in vec3 lightViewPosition,\r\n const in float lightSpotCutOff,\r\n const in float lightSpotBlend,\r\n \r\n out float attenuation,\r\n out vec3 eyeLightDir,\r\n out float dotNL) {\r\n\r\n eyeLightDir = lightViewPosition - viewVertex;\r\n float dist = length(eyeLightDir);\r\n eyeLightDir = dist > 0.0 ? eyeLightDir / dist : vec3( 0.0, 1.0, 0.0 );\r\n\r\n float cosCurAngle = dot(-eyeLightDir, lightViewDirection);\r\n float spot = cosCurAngle * smoothstep(0.0, 1.0, (cosCurAngle - lightSpotCutOff) / lightSpotBlend);\r\n\r\n dotNL = dot(eyeLightDir, normal);\r\n attenuation = spot * getLightAttenuation(dist, lightAttenuation);\r\n}\r\n\r\n#pragma DECLARE_FUNCTION\r\nvoid precomputePoint(\r\n const in vec3 normal,\r\n const in vec3 viewVertex,\r\n\r\n const in vec4 lightAttenuation,\r\n const in vec3 lightViewPosition,\r\n\r\n out float attenuation,\r\n out vec3 eyeLightDir,\r\n out float dotNL) {\r\n\r\n eyeLightDir = lightViewPosition - viewVertex;\r\n float dist = length(eyeLightDir);\r\n\r\n attenuation = getLightAttenuation(dist, lightAttenuation);\r\n eyeLightDir = dist > 0.0 ? eyeLightDir / dist : vec3( 0.0, 1.0, 0.0 );\r\n dotNL = dot(eyeLightDir, normal);\r\n}\r\n\r\n#pragma DECLARE_FUNCTION\r\nvoid precomputeSun(\r\n const in vec3 normal,\r\n const in vec3 lightViewDirection,\r\n \r\n out float attenuation,\r\n out vec3 eyeLightDir,\r\n out float dotNL) {\r\n\r\n attenuation = 1.0;\r\n eyeLightDir = -lightViewDirection;\r\n dotNL = dot(eyeLightDir, normal);\r\n}",o='#pragma include "lightCommon.glsl"\r\n\r\n////////////////\r\n// COOK TORRANCE\r\n////////////////\r\nvec3 specularCookTorrance(\r\n const in vec3 normal,\r\n const in vec3 lightDir,\r\n const in vec3 eyeVector,\r\n const in float materialShininess,\r\n const in vec3 materialSpecular,\r\n const in vec3 lightSpecular) {\r\n \r\n vec3 h = normalize(eyeVector + lightDir);\r\n float nh = dot(normal, h);\r\n float specfac = 0.0;\r\n\r\n if(nh > 0.0) {\r\n float nv = max( dot(normal, eyeVector), 0.0 );\r\n float i = pow(nh, materialShininess);\r\n i = i / (0.1 + nv);\r\n specfac = i;\r\n }\r\n // ugly way to fake an energy conservation (mainly to avoid super bright stuffs with low glossiness)\r\n float att = materialShininess > 100.0 ? 1.0 : smoothstep(0.0, 1.0, materialShininess * 0.01);\r\n return specfac * materialSpecular * lightSpecular * att;\r\n}\r\n\r\nvec3 lambert(const in float dotNL, const in vec3 materialDiffuse, const in vec3 lightDiffuse) {\r\n return dotNL * materialDiffuse * lightDiffuse;\r\n}\r\n\r\n#pragma DECLARE_FUNCTION\r\nvoid computeLightLambertCookTorrance(\r\n const in vec3 normal,\r\n const in vec3 eyeVector,\r\n const in float dotNL,\r\n const in float attenuation,\r\n\r\n const in vec3 materialDiffuse,\r\n const in vec3 materialSpecular,\r\n const in float materialShininess,\r\n\r\n const in vec3 lightDiffuse,\r\n const in vec3 lightSpecular,\r\n const in vec3 eyeLightDir,\r\n\r\n out vec3 diffuseOut,\r\n out vec3 specularOut,\r\n out bool lighted) {\r\n\r\n lighted = dotNL > 0.0;\r\n if (lighted == false) {\r\n specularOut = diffuseOut = vec3(0.0);\r\n return;\r\n }\r\n\r\n specularOut = attenuation * specularCookTorrance(normal, eyeLightDir, eyeVector, materialShininess, materialSpecular, lightSpecular);\r\n diffuseOut = attenuation * lambert(dotNL, materialDiffuse, lightDiffuse);\r\n}\r\n\r\n///////\r\n// HEMI\r\n///////\r\n#pragma DECLARE_FUNCTION\r\nvoid hemiLight(\r\n const in vec3 normal,\r\n const in vec3 eyeVector,\r\n const in float dotNL,\r\n const in vec3 eyeLightDir,\r\n\r\n const in vec3 materialDiffuse,\r\n const in vec3 materialSpecular,\r\n const in float materialShininess,\r\n\r\n const in vec3 lightDiffuse,\r\n const in vec3 lightGround,\r\n\r\n out vec3 diffuseOut,\r\n out vec3 specularOut,\r\n out bool lighted) {\r\n\r\n lighted = false;\r\n float weight = 0.5 * dotNL + 0.5;\r\n diffuseOut = materialDiffuse * mix(lightGround, lightDiffuse, weight);\r\n\r\n // same cook-torrance as above for sky/ground\r\n float skyWeight = 0.5 * dot(normal, normalize(eyeVector + eyeLightDir)) + 0.5;\r\n float gndWeight = 0.5 * dot(normal, normalize(eyeVector - eyeLightDir)) + 0.5;\r\n float skySpec = pow(skyWeight, materialShininess);\r\n float skyGround = pow(gndWeight, materialShininess);\r\n float divisor = (0.1 + max( dot(normal, eyeVector), 0.0 ));\r\n float att = materialShininess > 100.0 ? 1.0 : smoothstep(0.0, 1.0, materialShininess * 0.01);\r\n \r\n specularOut = lightDiffuse * materialSpecular * weight * att * (skySpec + skyGround) / divisor;\r\n}\r\n',s="//////////////////////////////\r\n// OPTIMIZED VERSION (NO IF)\r\n//////////////////////////////\r\n#pragma DECLARE_FUNCTION\r\nmat4 skinning( const in vec4 weights, const in vec4 bonesIndex ) {\r\n mat4 outMat_1;\r\n mat4 tmpMat_2;\r\n highp ivec4 tmpvar_3;\r\n tmpvar_3 = (3 * ivec4(bonesIndex));\r\n tmpMat_2 = mat4(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0);\r\n vec4 tmpvar_4;\r\n tmpvar_4 = -(abs(weights));\r\n tmpMat_2[0] = uBones[tmpvar_3.x];\r\n tmpMat_2[1] = uBones[(tmpvar_3.x + 1)];\r\n tmpMat_2[2] = uBones[(tmpvar_3.x + 2)];\r\n outMat_1 = ((float(\r\n ((tmpvar_4.x + tmpvar_4.y) >= -((tmpvar_4.z + tmpvar_4.w)))\r\n ) * mat4(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0)) + (weights.x * tmpMat_2));\r\n tmpMat_2[0] = uBones[tmpvar_3.y];\r\n tmpMat_2[1] = uBones[(tmpvar_3.y + 1)];\r\n tmpMat_2[2] = uBones[(tmpvar_3.y + 2)];\r\n outMat_1 = (outMat_1 + (weights.y * tmpMat_2));\r\n tmpMat_2[0] = uBones[tmpvar_3.z];\r\n tmpMat_2[1] = uBones[(tmpvar_3.z + 1)];\r\n tmpMat_2[2] = uBones[(tmpvar_3.z + 2)];\r\n outMat_1 = (outMat_1 + (weights.z * tmpMat_2));\r\n tmpMat_2[0] = uBones[tmpvar_3.w];\r\n tmpMat_2[1] = uBones[(tmpvar_3.w + 1)];\r\n tmpMat_2[2] = uBones[(tmpvar_3.w + 2)];\r\n outMat_1 = (outMat_1 + (weights.w * tmpMat_2));\r\n\r\n return outMat_1;\r\n}\r\n\r\n//////////////////////////////\r\n// UN-OPTIMIZED VERSION (WITH IF)\r\n//////////////////////////////\r\n\r\n// //http://http.developer.nvidia.com/GPUGems/gpugems_ch04.html\r\n// mat4 getMat4FromVec4( const int index, inout mat4 myMat ) {\r\n// // We have to use a global variable because we can't access dynamically\r\n// // matrix is transpose so we should do vec * matrix\r\n// myMat[0] = uBones[ index ];\r\n// myMat[1] = uBones[ index + 1];\r\n// myMat[2] = uBones[ index + 2];\r\n// return myMat;\r\n// }\r\n\r\n// mat4 skinning( const in vec4 weights, const in vec4 bonesIndex ) {\r\n// ivec4 idx = 3 * ivec4(bonesIndex);\r\n// mat4 tmpMat = mat4(1.0);\r\n// mat4 outMat = mat4(0.0);\r\n\r\n// // we handle negative weights\r\n// if(all(equal(weights, vec4(0.0)))) return tmpMat;\r\n\r\n// if(weights.x != 0.0) outMat += weights.x * getMat4FromVec4( idx.x, tmpMat );\r\n// if(weights.y != 0.0) outMat += weights.y * getMat4FromVec4( idx.y, tmpMat );\r\n// if(weights.z != 0.0) outMat += weights.z * getMat4FromVec4( idx.z, tmpMat );\r\n// if(weights.w != 0.0) outMat += weights.w * getMat4FromVec4( idx.w, tmpMat );\r\n// return outMat;\r\n// }\r\n\r\n//////////////////////////////\r\n// UN-OPTIMIZED VERSION (NO IF)\r\n//////////////////////////////\r\n\r\n// mat4 skinning( const in vec4 weights, const in vec4 bonesIndex ) {\r\n// ivec4 idx = 3 * ivec4(bonesIndex);\r\n// mat4 tmpMat = mat4(1.0);\r\n\r\n// // if sum is 0, return identity\r\n// vec4 absWeights = -abs(weights);\r\n// mat4 outMat = step(0.0, absWeights.x + absWeights.y + absWeights.z + absWeights.w) * tmpMat;\r\n\r\n// // we handle negative weights\r\n// // outMat[3][3] += weights.x + weights.y + weights.z + weights.w;\r\n\r\n// tmpMat[0] = uBones[ idx.x ];\r\n// tmpMat[1] = uBones[ idx.x + 1];\r\n// tmpMat[2] = uBones[ idx.x + 2];\r\n// outMat += weights.x * tmpMat;\r\n\r\n// tmpMat[0] = uBones[ idx.y ];\r\n// tmpMat[1] = uBones[ idx.y + 1];\r\n// tmpMat[2] = uBones[ idx.y + 2];\r\n// outMat += weights.y * tmpMat;\r\n\r\n// tmpMat[0] = uBones[ idx.z ];\r\n// tmpMat[1] = uBones[ idx.z + 1];\r\n// tmpMat[2] = uBones[ idx.z + 2];\r\n// outMat += weights.z * tmpMat;\r\n\r\n// tmpMat[0] = uBones[ idx.w ];\r\n// tmpMat[1] = uBones[ idx.w + 1];\r\n// tmpMat[2] = uBones[ idx.w + 2];\r\n// outMat += weights.w * tmpMat;\r\n\r\n// return outMat;\r\n// }\r\n",u="#pragma DECLARE_FUNCTION\r\nvec3 morphing(\r\n const in vec4 weights,\r\n const in vec3 vertex,\r\n const in vec3 target0) {\r\n\r\n return mix(vertex, target0, weights[0]);\r\n}\r\n\r\n#pragma DECLARE_FUNCTION\r\nvec3 morphing(\r\n const in vec4 weights,\r\n const in vec3 vertex,\r\n const in vec3 target0,\r\n const in vec3 target1) {\r\n\r\n vec3 vecOut = vertex * (1.0 - ( weights[0] + weights[1]));\r\n vecOut += target0 * weights[0];\r\n vecOut += target1 * weights[1];\r\n return vecOut;\r\n}\r\n\r\n#pragma DECLARE_FUNCTION\r\nvec3 morphing(\r\n const in vec4 weights,\r\n const in vec3 vertex,\r\n const in vec3 target0,\r\n const in vec3 target1,\r\n const in vec3 target2) {\r\n \r\n vec3 vecOut = vertex * (1.0 - ( weights[0] + weights[1] + weights[2]));\r\n vecOut += target0 * weights[0];\r\n vecOut += target1 * weights[1];\r\n vecOut += target2 * weights[2];\r\n return vecOut;\r\n}\r\n\r\n#pragma DECLARE_FUNCTION\r\nvec3 morphing(\r\n const in vec4 weights,\r\n const in vec3 vertex,\r\n const in vec3 target0,\r\n const in vec3 target1,\r\n const in vec3 target2,\r\n const in vec3 target3) {\r\n\r\n vec3 vecOut = vertex * (1.0 - ( weights[0] + weights[1] + weights[2] + weights[3]));\r\n vecOut += target0 * weights[0];\r\n vecOut += target1 * weights[1];\r\n vecOut += target2 * weights[2];\r\n vecOut += target3 * weights[3];\r\n return vecOut;\r\n}\r\n",c="#pragma DECLARE_FUNCTION\r\nvec3 textureRGB(const in sampler2D tex, const in vec2 uv) {\r\n return texture2D(tex, uv.xy).rgb;\r\n}\r\n\r\n#pragma DECLARE_FUNCTION\r\nvec4 textureRGBA(const in sampler2D tex, const in vec2 uv) {\r\n return texture2D(tex, uv.xy).rgba;\r\n}\r\n\r\n#pragma DECLARE_FUNCTION\r\nfloat textureIntensity(const in sampler2D tex, const in vec2 uv) {\r\n return texture2D(tex, uv).r;\r\n}\r\n\r\n#pragma DECLARE_FUNCTION\r\nfloat textureAlpha(const in sampler2D tex, const in vec2 uv) {\r\n return texture2D(tex, uv.xy).a;\r\n}\r\n",l="\r\nfloat decodeFloatRGBA( vec4 rgba ) {\r\n return dot( rgba, vec4(1.0, 1.0/255.0, 1.0/65025.0, 1.0/16581375.0) );\r\n}\r\n\r\nvec4 encodeFloatRGBA( float v ) {\r\n vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * v;\r\n enc = fract(enc);\r\n enc -= enc.yzww * vec4(1.0/255.0,1.0/255.0,1.0/255.0,0.0);\r\n return enc;\r\n}\r\n\r\nvec2 decodeHalfFloatRGBA( vec4 rgba ) {\r\n return vec2(rgba.x + (rgba.y / 255.0), rgba.z + (rgba.w / 255.0));\r\n}\r\n\r\nvec4 encodeHalfFloatRGBA( vec2 v ) {\r\n const vec2 bias = vec2(1.0 / 255.0, 0.0);\r\n vec4 enc;\r\n enc.xy = vec2(v.x, fract(v.x * 255.0));\r\n enc.xy = enc.xy - (enc.yy * bias);\r\n\r\n enc.zw = vec2(v.y, fract(v.y * 255.0));\r\n enc.zw = enc.zw - (enc.ww * bias);\r\n return enc;\r\n}\r\n",h="vec3 getScale( const in mat4 matrix ) {\r\n // Only working with positive scales.\r\n float xs = matrix[0][0] * matrix[0][1] * matrix[0][2] * matrix[0][3] < 0. ? -1. : 1.;\r\n float ys = matrix[1][0] * matrix[1][1] * matrix[1][2] * matrix[1][3] < 0. ? -1. : 1.;\r\n float zs = matrix[2][0] * matrix[2][1] * matrix[2][2] * matrix[2][3] < 0. ? -1. : 1.;\r\n vec3 scale;\r\n scale.x = xs * sqrt( matrix[0][0] * matrix[0][0] + matrix[0][1] * matrix[0][1] + matrix[0][2] * matrix[0][2]);\r\n scale.y = ys * sqrt( matrix[1][0] * matrix[1][0] + matrix[1][1] * matrix[1][1] + matrix[1][2] * matrix[1][2]);\r\n scale.z = zs * sqrt( matrix[2][0] * matrix[2][0] + matrix[2][1] * matrix[2][1] + matrix[2][2] * matrix[2][2]);\r\n return scale;\r\n}\r\n\r\n#pragma DECLARE_FUNCTION\r\nvec4 billboard( const in vec3 vertex, const in mat4 modelViewMatrix, const in mat4 projectionMatrix ) {\r\n vec3 scale = getScale( modelViewMatrix );\r\n return projectionMatrix * ( vec4( scale.x* vertex.x , scale.y * vertex.y, scale.z * vertex.z, 1.0 ) + vec4( modelViewMatrix[ 3 ].xyz, 0.0 ) );\r\n}\r\n";t["a"]={"common.glsl":n,"functions.glsl":i,"lightCommon.glsl":a,"lights.glsl":o,"skinning.glsl":s,"morphing.glsl":u,"textures.glsl":c,"colorEncode.glsl":l,"billboard.glsl":h}},a741:function(e,t,r){"use strict";r("4c53");var n=r("a214"),i=r("b797"),a=r("ecf1"),o=r("3972"),s=function(){this._center=o["f"].create(),this._radius=-1};i["a"].createPrototypeObject(s,{init:function(){o["f"].init(this._center),this._radius=-1},valid:function(){return this._radius>=0},set:function(e,t){this._center=e,this._radius=t},center:function(){return this._center},radius:function(){return this._radius},radius2:function(){return this._radius*this._radius},volume:function(){var e=this._radius;return e*e*e*Math.PI*4/3},copy:function(e){this._radius=e._radius,o["f"].copy(this._center,e._center)},copyBoundingBox:function(e){e.center(this._center),this._radius=e.radius()},expandByBoundingBox:function(){var e=o["f"].create(),t=new a["a"];return function(r){if(r.valid())if(this.valid()){o["f"].copy(t._min,r._min),o["f"].copy(t._max,r._max);for(var n=0;n<8;n++)o["f"].sub(e,r.corner(n,e),this._center),o["f"].normalize(e,e),o["f"].scaleAndAdd(e,this._center,e,-this._radius),t.expandByVec3(e);t.center(this._center),this._radius=t.radius()}else this.copyBoundingBox(r)}}(),expandByvec3:function(e){n["a"].warn("deprecated, use expandByVec3"),this.expandByVec3(e)},expandByVec3:function(){var e=o["f"].create();return function(t){if(this.valid()){o["f"].sub(e,t,this.center(e));var r=o["f"].length(e);if(r>this.radius()){var n=.5*(r-this.radius());this._center[0]+=e[0]*(n/r),this._center[1]+=e[1]*(n/r),this._center[2]+=e[2]*(n/r),this._radius+=n}}else this._center[0]=t[0],this._center[1]=t[1],this._center[2]=t[2],this._radius=0}}(),expandRadiusBySphere:function(e){if(e.valid())if(this.valid()){var t=o["f"].distance(this._center,e._center)+e._radius;t>this._radius&&(this._radius=t)}else o["f"].copy(this._center,e._center),this._radius=e._radius},expandByBoundingSphere:function(e){if(e.valid()){if(!this.valid())return this._center[0]=e._center[0],this._center[1]=e._center[1],this._center[2]=e._center[2],void(this._radius=e.radius());var t=o["f"].distance(e.center(),this.center());if(!(t+e.radius()<=this.radius())){if(t+this.radius()<=e.radius())return this._center[0]=e._center[0],this._center[1]=e._center[1],this._center[2]=e._center[2],void(this._radius=e._radius);var r=.5*(this.radius()+t+e.radius()),n=(r-this.radius())/t;this._center[0]+=(e._center[0]-this._center[0])*n,this._center[1]+=(e._center[1]-this._center[1])*n,this._center[2]+=(e._center[2]-this._center[2])*n,this._radius=r}}},contains:function(e){return!!this.valid()&&o["f"].sqrDist(this.center(),e)<=this.radius2()},intersects:function(e){if(!this.valid()||!e.valid())return!1;var t=this.radius()+e.radius();return o["f"].sqrDist(e.center(),this.center())<=t*t},transformMat4:function(){var e=o["f"].create();return function(t,r){if(!this.valid())return t;t._center!==this._center&&(o["f"].copy(t._center,this._center),t._radius=this._radius);var n=t._center,i=t._radius;o["c"].getSqrScale(e,r);var a=Math.sqrt(Math.max(Math.max(e[0],e[1]),e[2]));return i*=a,t._radius=i,o["f"].transformMat4(n,n,r),t}}()},"osg","BoundingSphere"),t["a"]=s},a995:function(e,t,r){"use strict";r("4ec9"),r("d3b7"),r("3ca3"),r("ddb0"),r("a434"),r("25f0");var n=r("a214"),i=r("b797"),a=r("16cb"),o=r("123d"),s=r("1ad5"),u=r("0fd6"),c=function(){a["a"].call(this),o["a"].call(this),this._fbo=void 0,this._rbo=void 0,this._attachments=[],this._buffers=[],this._dirty=!0,this._hasMRT=u["a"].instance().getWebGLExtension("WEBGL_draw_buffers")};c.COLOR_ATTACHMENT0=36064,c.DEPTH_ATTACHMENT=36096,c.DEPTH_COMPONENT16=33189,c._sDeletedGLFrameBufferCache=new window.Map,c.deleteGLFrameBuffer=function(e,t){c._sDeletedGLFrameBufferCache.has(e)||c._sDeletedGLFrameBufferCache.set(e,[]),c._sDeletedGLFrameBufferCache.get(e).push(t)},c.flushDeletedGLFrameBuffers=function(e,t){if(t<=0)return t;if(!c._sDeletedGLFrameBufferCache.has(e))return t;var r=c._sDeletedGLFrameBufferCache.get(e);if(0===r.length)return t;for(var n=0,i=s["a"].instance().tick(),a=r.length,o=a-1;o>=0&&n<t;o--)e.deleteFramebuffer(r[o]),r.splice(o,1),n=s["a"].instance().deltaS(i,s["a"].instance().tick());return t-n},c.flushAllDeletedGLFrameBuffers=function(e){if(c._sDeletedGLFrameBufferCache.has(e)){var t=c._sDeletedGLFrameBufferCache.get(e);if(0!==t.length)for(var r=t.length,n=r-1;n>=0;n--)e.deleteFramebuffer(t[n]),t.splice(n,1)}},c._sDeletedGLRenderBufferCache=new window.Map,c.deleteGLRenderBuffer=function(e,t){c._sDeletedGLRenderBufferCache.has(e)||c._sDeletedGLRenderBufferCache.set(e,[]),c._sDeletedGLRenderBufferCache.get(e).push(t)},c.flushDeletedGLRenderBuffers=function(e,t){if(t<=0)return t;if(!c._sDeletedGLRenderBufferCache.has(e))return t;for(var r=0,n=s["a"].instance().tick(),i=c._sDeletedGLRenderBufferCache.get(e),a=i.length,o=a-1;o>=0&&r<t;o--)e.deleteRenderbuffer(i[o]),i.splice(o,1),r=s["a"].instance().deltaS(n,s["a"].instance().tick());return t-r},c.flushAllDeletedGLRenderBuffers=function(e){if(c._sDeletedGLRenderBufferCache.has(e))for(var t=c._sDeletedGLRenderBufferCache.get(e),r=t.length,n=r-1;n>=0;n--)e.deleteRenderbuffer(t[n]),t.splice(n,1)},c.onLostContext=function(e){if(c._sDeletedGLFrameBufferCache.has(e)){var t=c._sDeletedGLFrameBufferCache.get(e);t.length=0,c._sDeletedGLRenderBufferCache.has(e)&&(t=c._sDeletedGLRenderBufferCache.get(e),t.length=0)}},i["a"].createPrototypeStateAttribute(c,i["a"].objectInherit(a["a"].prototype,i["a"].objectInherit(o["a"].prototype,{attributeType:"FrameBufferObject",cloneType:function(){return new c},invalidate:function(){if(this._rbo&&this._attachments){for(var e=0,t=this._attachments.length;e<t;++e){var r=this._attachments[e];r.texture||(r.renderBufferObject=void 0)}this._rbo=void 0}this._fbo=void 0,this._buffers.length=0,this._dirty=!0},dirty:function(){this._buffers.length=0,this._dirty=!0},isDirty:function(){return this._dirty},setAttachment:function(e){this._attachments.push(e)},getAttachment:function(e){if(this._attachments)for(var t=0,r=this._attachments.length;t<r;++t){var n=this._attachments[t];if(n.attachment===e)return n}},releaseGLObjects:function(){void 0!==this._fbo&&void 0!==this._gl&&c.deleteGLFrameBuffer(this._gl,this._fbo),this._fbo=void 0,void 0!==this._rbo&&void 0!==this._gl&&c.deleteGLRenderBuffer(this._gl,this._rbo),this.invalidate()},_reportFrameBufferError:function(e){switch(e){case 36054:n["a"].debug("FRAMEBUFFER_INCOMPLETE_ATTACHMENT");break;case 36055:n["a"].debug("FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT");break;case 36057:n["a"].debug("FRAMEBUFFER_INCOMPLETE_DIMENSIONS");break;case 36061:n["a"].debug("FRAMEBUFFER_UNSUPPORTED");break;default:n["a"].debug("FRAMEBUFFER unknown error "+e.toString(16))}},reset:function(){this.releaseGLObjects(),this._attachments=[]},getFrameBufferObject:function(){return this._fbo},getRenderBufferObject:function(){return this._rbo},createFrameBufferObject:function(e){this.setGraphicContext(e.getGraphicContext()),this._fbo=this._gl.createFramebuffer()},createRenderBuffer:function(e,t,r){var n=this._gl,i=n.createRenderbuffer();return n.bindRenderbuffer(n.RENDERBUFFER,i),n.renderbufferStorage(n.RENDERBUFFER,e,t,r),i},framebufferRenderBuffer:function(e,t){var r=this._gl;r.bindRenderbuffer(r.RENDERBUFFER,t),r.framebufferRenderbuffer(r.FRAMEBUFFER,e,r.RENDERBUFFER,t),void 0!==r.rawgl&&n["a"].log("FBO: renderBuffer: "+this._fbo.trackedObject.defaultName)},framebufferTexture2D:function(e,t,r,i){var a=this._gl;if(e.applyTextureAttribute(1,i),i.isDirty()||!i.getTextureObject())return!1;var o=a.DRAW_FRAMEBUFFER||a.FRAMEBUFFER;return a.framebufferTexture2D(o,t,r,i.getTextureObject().id(),0),void 0!==a.rawgl&&n["a"].log("FBO: texture: "+i.getName()+" : "+i.getTextureObject().id().trackedObject.defaultName+" fbo: "+this._fbo.trackedObject.defaultName),!0},bindFrameBufferObject:function(){var e=this._gl;e.bindFramebuffer(e.FRAMEBUFFER,this._fbo)},checkStatus:function(){var e=this._gl,t=e.checkFramebufferStatus(e.FRAMEBUFFER);t!==e.FRAMEBUFFER_COMPLETE&&this._reportFrameBufferError(t)},_checkAllowedSize:function(e,t){var r=u["a"].instance().getWebGLParameter("MAX_RENDERBUFFER_SIZE");return!(0===e||0===t||t>r||e>r)||(n["a"].error("width ("+e+") or height ("+e+') makes frame buffer not bindable. Max RenderBuffer is "'+r+'"'),!1)},apply:function(e){this._gl||this.setGraphicContext(e.getGraphicContext());var t=this._gl,r=this._attachments,i=r.length;if(0!==i||this._fbo){var a=0;if(!this.isDirty()){for(a=0;a<i;++a){var o=r[a].texture;o&&o.isDirty()&&e.applyTextureAttribute(1,o)}return t.bindFramebuffer(t.FRAMEBUFFER,this._fbo),void(!0===n["a"].reportWebGLError&&this.checkStatus())}this._fbo||this.createFrameBufferObject(e),this.bindFrameBufferObject();var s=this._hasMRT?this._buffers:void 0,u=!1;for(a=0;a<i;++a){var c=r[a];if(c.texture){var l=c.texture;if(!this._checkAllowedSize(l.getWidth(),l.getHeight()))return void this.releaseGLObjects();if(this._hasMRT&&c.attachment>=t.COLOR_ATTACHMENT0&&c.attachment<=t.COLOR_ATTACHMENT15&&-1===s.indexOf(c.attachment)&&s.push(c.attachment),!this.framebufferTexture2D(e,c.attachment,c.textureTarget,l))return void this.releaseGLObjects()}else{if(!this._checkAllowedSize(c.width,c.height))return void this.releaseGLObjects();c.renderBufferObject?this._rbo=c.renderBufferObject:(this._rbo=this.createRenderBuffer(c.format,c.width,c.height),c.renderBufferObject=this._rbo),this.framebufferRenderBuffer(c.attachment,this._rbo),u=!0}}s&&s.length>0&&t.drawBuffers(s),this.checkStatus(),u&&t.bindRenderbuffer(t.RENDERBUFFER,null),this._dirty=!1}else t.bindFramebuffer(t.FRAMEBUFFER,null)}})),"osg","FrameBufferObject"),t["a"]=c},ae22:function(e,t,r){},ae6a:function(e,t,r){"use strict";var n=r("b797"),i=r("3972"),a=r("2a3f"),o=function(){a["a"].call(this),this._stackedTransforms=[],this._matrix=i["c"].create(),this._dirty=!1};n["a"].createPrototypeObject(o,n["a"].objectInherit(a["a"].prototype,{getStackedTransforms:function(){return this._stackedTransforms},setMatrix:function(e){i["c"].copy(this._matrix,e),this._dirty=!0},getMatrix:function(){return this._matrix},computeChannels:function(){this._dirty=!0;var e=this._matrix;i["c"].identity(e);for(var t=this._stackedTransforms,r=0,n=t.length;r<n;r++){var a=t[r];a.applyToMatrix(e)}},reset:function(){for(var e=this._stackedTransforms,t=0,r=e.length;t<r;t++)e[t].resetToDefaultValue();this.computeChannels()},update:function(e){return i["c"].copy(e.getMatrix(),this._matrix),this._dirty&&(e.dirtyBound(),this._dirty=!1),!0}}),"osgAnimation","UpdateMatrixTransform"),t["a"]=o},ae6b:function(e,t,r){"use strict";var n=r("b797"),i=r("123d"),a=function(e,t,r,n){i["a"].call(this),this._x=void 0!==e?e:-1,this._y=void 0!==t?t:-1,this._width=void 0!==r?r:-1,this._height=void 0!==n?n:-1};n["a"].createPrototypeStateAttribute(a,n["a"].objectInherit(i["a"].prototype,{attributeType:"Scissor",cloneType:function(){return new a},setScissor:function(e,t,r,n){this._x=e,this._y=t,this._width=r,this._height=n},x:function(){return this._x},y:function(){return this._y},width:function(){return this._width},height:function(){return this._height},apply:function(e){e.applyScissor(this)}}),"osg","Scissor"),t["a"]=a},aee2:function(e,t,r){"use strict";var n=r("b797"),i=r("123d"),a=function e(t,r,n,a){i["a"].call(this),this._sourceFactor=e.DISABLE,this._destinationFactor=e.DISABLE,this._sourceFactorAlpha=this._sourceFactor,this._destinationFactorAlpha=this._destinationFactor,this._separate=!1,void 0!==t&&this.setSource(t),void 0!==r&&this.setDestination(r),void 0!==n&&this.setSourceAlpha(n),void 0!==a&&this.setDestinationAlpha(a)};a.DISABLE=-1,a.ZERO=0,a.ONE=1,a.SRC_COLOR=768,a.ONE_MINUS_SRC_COLOR=769,a.SRC_ALPHA=770,a.ONE_MINUS_SRC_ALPHA=771,a.DST_ALPHA=772,a.ONE_MINUS_DST_ALPHA=773,a.DST_COLOR=774,a.ONE_MINUS_DST_COLOR=775,a.SRC_ALPHA_SATURATE=776,a.BLEND_DST_RGB=32968,a.BLEND_SRC_RGB=32969,a.BLEND_DST_ALPHA=32970,a.BLEND_SRC_ALPHA=32971,a.CONSTANT_COLOR=32769,a.ONE_MINUS_CONSTANT_COLOR=32770,a.CONSTANT_ALPHA=32771,a.ONE_MINUS_CONSTANT_ALPHA=32772,a.BLEND_COLOR=32773,n["a"].createPrototypeStateAttribute(a,n["a"].objectInherit(i["a"].prototype,{attributeType:"BlendFunc",cloneType:function(){return new a},setSource:function(e){this.setSourceRGB(e),this.setSourceAlpha(e)},getSource:function(){return this._sourceFactor},setDestination:function(e){this.setDestinationRGB(e),this.setDestinationAlpha(e)},getDestination:function(){return this._destinationFactor},getSeparate:function(){return this._separate},checkSeparate:function(){return this._sourceFactor!==this._sourceFactorAlpha||this._destinationFactor!==this._destinationFactorAlpha},setSourceRGB:function(e){this._sourceFactor="string"===typeof e?a[e]:e,this._separate=this.checkSeparate()},getSourceRGB:function(){return this._sourceFactor},setSourceAlpha:function(e){this._sourceFactorAlpha="string"===typeof e?a[e]:e,this._separate=this.checkSeparate()},getSourceAlpha:function(){return this._sourceFactorAlpha},setDestinationRGB:function(e){this._destinationFactor="string"===typeof e?a[e]:e,this._separate=this.checkSeparate()},getDestinationRGB:function(){return this._destinationFactor},setDestinationAlpha:function(e){this._destinationFactorAlpha="string"===typeof e?a[e]:e,this._separate=this.checkSeparate()},getDestinationAlpha:function(){return this._destinationFactorAlpha},apply:function(e){e.applyBlendFunc(this)}}),"osg","BlendFunc"),t["a"]=a},b507:function(e,t,r){"use strict";var n=r("3972"),i=r("3d8f"),a={InvalidTargetID:-1},o=function(e,t,r){return{type:e,id:a.InvalidTargetID,channels:[],value:t,defaultValue:r}},s=function(e){return o(i["a"].Quat,n["d"].copy(n["d"].create(),e),n["d"].copy(n["d"].create(),e))},u=function(e){return o(i["a"].Matrix,n["c"].copy(n["c"].create(),e),n["c"].copy(n["c"].create(),e))},c=function(e){return o(i["a"].Vec3,n["f"].copy(n["f"].create(),e),n["f"].copy(n["f"].create(),e))},l=function(e){return o(i["a"].Float,e,e)};a.createQuatTarget=s,a.createVec3Target=c,a.createFloatTarget=l,a.createMatrixTarget=u,t["a"]=a},b5d5:function(e,t,r){"use strict";var n=r("b797"),i=r("123d"),a=function e(t){i["a"].call(this),this.setMode(void 0!==t?t:e.BACK)};a.DISABLE=0,a.FRONT=1028,a.BACK=1029,a.FRONT_AND_BACK=1032,n["a"].createPrototypeStateAttribute(a,n["a"].objectInherit(i["a"].prototype,{attributeType:"CullFace",cloneType:function(){return new a},setMode:function(e){var t=e;"string"===typeof t&&(t=a[t]),this._mode=t},getMode:function(){return this._mode},apply:function(e){e.applyCullFace(this)}}),"osg","CullFace"),t["a"]=a},b690:function(e,t,r){"use strict";var n=r("b797"),i=r("40fc"),a=r("850d"),o=function(){i["a"].call(this),this._databasePager=new a["a"],this._sceneData=void 0};n["a"].createPrototypeObject(o,n["a"].objectInherit(i["a"].prototype,{getSceneData:function(){return this._sceneData},setSceneData:function(e){this._sceneData=e},setDatabasePager:function(e){this._databasePager=e},getDatabasePager:function(){return this._databasePager},updateSceneGraph:function(e){this._databasePager&&this._databasePager.updateSceneGraph(e.getFrameStamp()),this._sceneData&&this._sceneData.accept(e)}}),"osgViewer","Scene"),t["a"]=o},b797:function(e,t,r){"use strict";var n=r("53ca"),i=(r("d3b7"),r("25f0"),r("fd87"),r("907a"),r("9a8c"),r("a975"),r("735e"),r("c1ac"),r("d139"),r("3a7b"),r("d5d6"),r("82f8"),r("e91f"),r("60bd"),r("5f96"),r("3280"),r("3fcc"),r("ca91"),r("25a1"),r("cd26"),r("3c5d"),r("2954"),r("649e"),r("219c"),r("170b"),r("b39a"),r("72f7"),r("5cc6"),r("8a59"),r("8b09"),r("84c3"),r("143c"),r("fb2c"),r("cfc3"),r("4a9b"),r("b64b"),r("159b"),r("1ad5")),a=r("a214"),o={extend:function(){var e,t,r,i,a=window.Object.prototype.toString,s=window.Object.prototype.hasOwnProperty,u=function(e){return"[object Function]"===a.call(e)},c=o.isArray,l=function(e){if(!e||"[object Object]"!==a.call(e)||e.nodeType||e.setInterval)return!1;if(e.constructor&&!s.call(e,"constructor")&&!s.call(e.constructor.prototype,"isPrototypeOf"))return!1;var t;for(t in e);return void 0===t||s.call(e,t)},h=arguments[0]||{},d=1,f=arguments.length,_=!1;for("boolean"===typeof h&&(_=h,h=arguments[1]||{},d=2),"object"===Object(n["a"])(h)||u(h)||(h={}),f===d&&(h=this,--d);d<f;d++)if(null!==(e=arguments[d]))for(t in e)if(r=h[t],i=e[t],h!==i)if(_&&i&&(l(i)||c(i))){var p=r&&(l(r)||c(r))?r:c(i)?[]:{};h[t]=o.extend(_,p,i)}else void 0!==i&&(h[t]=i);return h},objectInherit:function(e){function t(){}t.prototype=e;for(var r=new t,n=1;n<arguments.length;n++)o.objectMix(r,arguments[n],!1);return r},objectMix:function(e,t,r){for(var n in t)r&&e[n]||(e[n]=t[n]);return e},objectType:{}};o.objectType.type=0,o.arrayDense=function(e,t,r){var n=t.length;if(e>=n)for(var i=n;i<=e;i++)t.push(r?r():null)},o.objectLibraryClass=function(e,t,r){e.className=function(){return r},e.libraryName=function(){return t};var n=t+"::"+r;return e.libraryClassName=function(){return n},e},o.setTypeID=function(e){var t=e.prototype.libraryClassName(),r=o.generateId(o.objectType,t),n=function(){return r};e.typeID=e.prototype.typeID=r,e.getTypeID=e.prototype.getTypeID=n},o.createPrototypeObject=function(e,t,r,n){t.hasOwnProperty("getTypeID")&&(t=o.objectInherit(t,{})),e.prototype!==t&&(e.prototype=t),t.constructor=e,r&&n&&(o.objectLibraryClass(t,r,n),o.setTypeID(e))},o.generateId=function(e,t){if(void 0!==e[t])return a["a"].error(t+" is already defined, change class name or library name"),-1;var r=e.type;return e[r]=t,e[t]=r,e.type+=1,r},o.objectNodeType={},o.objectNodeType.type=0,o.setNodeTypeID=function(e){var t=e.prototype.libraryClassName(),r=o.generateId(o.objectNodeType,t),n=function(){return r};e.nodeTypeID=e.prototype.nodeTypeID=r,e.getNodeTypeID=e.prototype.getNodeTypeID=n},o.createPrototypeNode=function(e,t,n,i){var a=r("fca2").default,s=t.nodeTypeID;if(o.createPrototypeObject(e,t,n,i),n&&i){o.setNodeTypeID(e);var u=e.nodeTypeID;o.arrayDense(u,a.applyFunctionArray),a.registerApplyFunction(u,a.getApplyFunction(s))}};var s=0,u=0,c={},l={},h=0,d={};o.getStateAttributeTypeNameToTypeId=function(){return d},o.createPrototypeStateAttribute=function(e,t,r,n){o.createPrototypeObject(e,t,r,n);var i=o.getOrCreateStateAttributeTypeId(e);e.prototype.attributeTypeId=i},o.getMaxStateAttributeTypeID=function(){return h},o.getOrCreateStateAttributeTypeId=function(e){var t=e.prototype.getType();if(d[t])return d[t];var r=h++;return d[t]=r,r},o.getOrCreateStateAttributeTypeMemberIndex=function(e){if(void 0!==e._attributeTypeIndex)return e._attributeTypeIndex;var t=e.getTypeMember();return e._attributeTypeIndex=o.getOrCreateStateAttributeTypeMemberIndexFromName(t),e._attributeTypeIndex},o.getOrCreateStateAttributeTypeMemberIndexFromName=function(e){var t=c[e];return void 0!==t||(t=s++,c[e]=t),t},o.getOrCreateTextureStateAttributeTypeMemberIndex=function(e){if(void 0!==e._attributeTypeIndex)return e._attributeTypeIndex;var t=e.getTypeMember();return e._attributeTypeIndex=o.getOrCreateTextureStateAttributeTypeMemberIndexFromName(t),e._attributeTypeIndex},o.getOrCreateTextureStateAttributeTypeMemberIndexFromName=function(e){var t=l[e];return void 0!==t||(t=u++,l[e]=t),t},o.getIdFromTypeMember=function(e){return c[e]},o.getTextureIdFromTypeMember=function(e){return l[e]},o.Int8Array=window.Int8Array,o.Uint8Array=window.Uint8Array,o.Uint8ClampedArray=window.Uint8ClampedArray,o.Int16Array=window.Int16Array,o.Uint16Array=window.Uint16Array,o.Int32Array=window.Int32Array,o.Uint32Array=window.Uint32Array,o.Float32Array=window.Float32Array,o.Float64Array=window.Float64Array;var f={},_={};o.logTime=(a["a"].console.time||function(e){f[e]=i["a"].instance().tick()}).bind(a["a"].console),o.logTimeEnd=(a["a"].console.timeEnd||function(e){if(void 0!==f[e]){var t=i["a"].instance().deltaM(f[e],i["a"].instance().tick());a["a"].log(e+": "+t+"ms"),f[e]=void 0}}).bind(a["a"].console),o.time=function(e,t){var r=t;void 0===r&&(r=a["a"].NOTICE),r>a["a"].getNotifyLevel()||(_[e]=1,o.logTime(e))},o.timeEnd=function(e){void 0!==_[e]&&o.logTimeEnd(e)},o.profile=(a["a"].console.profile||function(){}).bind(a["a"].console),o.profileEnd=(a["a"].console.profileEnd||function(){}).bind(a["a"].console),o.arrayUniq=function(e){for(var t=e.length,r={},n=[],i=0,a=0;a<t;a++){var o=e[a];1!==r[o]&&(r[o]=1,n[i++]=o)}return n},o.rejectObject=function(e,t){return t&&(e="Invalid json "+e+" "+Object.keys(t)),a["a"].warn(e),P.reject(e)},o.setStateAttributeConfig=function(e,t){e.stateAttributeConfig=t,t.attribute.forEach(o.getOrCreateStateAttributeTypeMemberIndexFromName),t.textureAttribute.forEach(o.getOrCreateTextureStateAttributeTypeMemberIndexFromName),e.validAttributeTypeMember=t.attribute,e.validTextureAttributeTypeMember=t.textureAttribute},t["a"]=o},b942:function(e,t,r){e.exports=r.p+"img/grid.89ba7a31.png"},bade:function(e,t,r){"use strict";r.r(t);var n=r("ecf1"),i=r("9946"),a=r("3972"),o=r("2449"),s=r("5a16"),u=r("b797"),c=r("02b4"),l=r("1ca0"),h=function(e){s["a"].call(this,e),this._pooledMatrix=new l["a"](a["c"].create),this._matrixStack=new c["a"],this._matrixStack.push(a["c"].IDENTITY),this._bb=new n["a"]};u["a"].createPrototypeObject(h,u["a"].objectInherit(s["a"].prototype,{reset:function(){this._pooledMatrix.reset(),this._matrixStack.reset(),this._matrixStack.push(a["c"].IDENTITY),this._bb.init()},getBoundingBox:function(){return this._bb},applyTransform:function(e){var t=this._pooledMatrix.getOrCreateObject();a["c"].copy(t,this._matrixStack.back()),e.computeLocalToWorldMatrix(t,this),this.pushMatrix(t),this.traverse(e),this.popMatrix()},apply:function(e){e instanceof o["a"]?this.applyTransform(e):e instanceof i["a"]?this.applyBoundingBox(e.getBoundingBox()):this.traverse(e)},pushMatrix:function(e){this._matrixStack.push(e)},popMatrix:function(){this._matrixStack.pop()},applyBoundingBox:function(){var e=new n["a"];return function(t){t.valid()&&(t.transformMat4(e,this._matrixStack.back()),this._bb.expandByBoundingBox(e))}}(),getMatrixStack:function(){return this._matrixStack}}),"osg","ComputeBoundsVisitor"),t["default"]=h},c0cf:function(e,t,r){},c0d6:function(e,t,r){"use strict";r("d3b7"),r("5cc6"),r("907a"),r("9a8c"),r("a975"),r("735e"),r("c1ac"),r("d139"),r("3a7b"),r("d5d6"),r("82f8"),r("e91f"),r("60bd"),r("5f96"),r("3280"),r("3fcc"),r("ca91"),r("25a1"),r("cd26"),r("3c5d"),r("2954"),r("649e"),r("219c"),r("170b"),r("b39a"),r("72f7"),r("ac1f"),r("4ec9"),r("3ca3"),r("ddb0"),r("a434"),r("466d"),r("9911"),r("b680");var n,i=r("b797"),a=r("a214"),o=r("9998"),s=r("16cb"),u=r("123d"),c=r("8bd2"),l=r("1ad5"),h=o["a"].getOptionsURL().shaderStats?{}:void 0,d=o["a"].getOptionsURL().syncCompile,f=new Uint8Array(4),_=function(e){e.flush(),e.finish(),e.readPixels(0,0,1,1,e.RGBA,e.UNSIGNED_BYTE,f)},p=c["a"],g=/uniform\s+\w+\s+(\w+)((\s)?\[(.*?)\])?/g,m=/(in|attribute)\s+\w+\s+(\w+)\s*;/g,v=function(e){var t,r,n={};while(null!==(t=m.exec(e)))r=t[2],n[r]=!0;return n},b=function(e){var t,r={};while(null!==(t=g.exec(e))){var n=t[1];r[n]=!0}return r},S=function(e,t){s["a"].call(this),u["a"].call(this),this._program=null,this._nullProgram=!0,this._vertex=void 0,this._fragment=void 0,this._uniformsCache=void 0,this._attributesCache=void 0,this._activeUniforms=void 0,this._foreignUniforms=void 0,this._trackAttributes=void 0,this._asyncCompilation=void 0,this._compileClean=void 0,e&&this.setVertexShader(e),t&&this.setFragmentShader(t),this._dirty=!0};S._sDeletedGLProgramCache=new window.Map,S.deleteGLProgram=function(e,t){S._sDeletedGLProgramCache.has(e)||S._sDeletedGLProgramCache.set(e,[]),S._sDeletedGLProgramCache.get(e).push(t)},S.flushDeletedGLPrograms=function(e,t){if(t<=0)return t;if(!S._sDeletedGLProgramCache.has(e))return t;for(var r=0,n=l["a"].instance().tick(),i=S._sDeletedGLProgramCache.get(e),a=i.length,o=a-1;o>=0&&r<t;o--)e.deleteProgram(i[o]),i.splice(o,1),r=l["a"].instance().deltaS(n,l["a"].instance().tick());return t-r},S.flushAllDeletedGLPrograms=function(e){if(S._sDeletedGLProgramCache.has(e))for(var t=S._sDeletedGLProgramCache.get(e),r=t.length,n=r-1;n>=0;n--)e.deleteProgram(t[n]),t.splice(n,1)},S.onLostContext=function(e){if(S._sDeletedGLProgramCache.has(e)){var t=S._sDeletedGLProgramCache.get(e);t.length=0}},i["a"].createPrototypeStateAttribute(S,i["a"].objectInherit(s["a"].prototype,i["a"].objectInherit(u["a"].prototype,{attributeType:"Program",cloneType:function(){return new S},setVertexShader:function(e){this._vertex=e,this._nullProgram=!1,e.setText(p.processShader(e.getText()))},setFragmentShader:function(e){this._fragment=e,this._nullProgram=!1,e.setText(p.processShader(e.getText()))},getVertexShader:function(){return this._vertex},getFragmentShader:function(){return this._fragment},getProgram:function(){return this._program},setActiveUniforms:function(e){this._activeUniforms=e},getActiveUniforms:function(){return this._activeUniforms},setForeignUniforms:function(e){this._foreignUniforms=e},getForeignUniforms:function(){return this._foreignUniforms},setUniformsCache:function(e){this._uniformsCache=e},getUniformsCache:function(){return this._uniformsCache},setAttributesCache:function(e){this._attributesCache=e},getAttributesCache:function(){return this._attributesCache},setTrackAttributes:function(e){this._trackAttributes=e},getTrackAttributes:function(){return this._trackAttributes},releaseGLObjects:function(){void 0!==this._vertex&&this._vertex.releaseGLObjects(),void 0!==this._fragment&&this._fragment.releaseGLObjects(),null!==this._program&&(void 0!==this._gl&&(S.deleteGLProgram(this._gl,this._program),s["a"].removeObject(this._gl,this)),this.invalidate())},dirty:function(){this._program=void 0},invalidate:function(){this._cacheUniformId=void 0,this._uniformsCache=void 0,this._attributesCache=void 0,this._foreignUniforms=void 0,this._trackAttributes=void 0,this._compileClean=void 0,this._program=void 0},_rebuildProgramFromSpector:function(e,t,r,n){this._dirty=!0,this._vertex.invalidate(),this._fragment.invalidate(),this.invalidate(),this._vertex.setText(e),this._fragment.setText(t),this._program=null,this._spectorOnCompiled=r,this._spectorOnError=n,this._compileClean=void 0},_onErrorToSpector:function(e){return!!this._spectorOnError&&(this._spectorOnError(e),!0)},_onCompilationToSpector:function(){this._spectorOnCompiled&&this._spectorOnCompiled(this._program)},_bindProgramToSpector:function(){window&&window.spector&&!this._program.__SPECTOR_rebuildProgram&&(this._program.__SPECTOR_rebuildProgram=this._rebuildProgramFromSpector.bind(this))},_logDebugShaders:function(e,t){if("Failed to create D3D shaders.\n"===t){var r=void 0!==e.rawgl?e.rawgl:e;void 0!==r&&void 0===r.getExtension&&(r=r.getExtension("WEBGL_debug_shaders"),r&&(a["a"].error(r.getTranslatedShaderSource(this._vertex.shader)),a["a"].error(r.getTranslatedShaderSource(this._fragment.shader))))}},_activateFailSafe:function(e){var t=e.createProgram();this._vertex.failSafe(e,this._vertex.getText()),this._fragment.failSafe(e,this._fragment.getText()),this._glAttachAndLink(e,t,this._vertex,this._fragment),a["a"].warn("FailSafe shader Activated "),this._program=t},_glAttachAndLink:function(e,t,r,n){e.attachShader(t,r.shader),e.attachShader(t,n.shader),e.linkProgram(t)},_glShaderCompile:function(e,t){t.shader||(h&&(t===this._vertex?h.vert=l["a"].tick():h.frag=l["a"].tick()),t.compile(e,n))},_glShaderCompilationResult:function(e,t){var r=t.getCompilationResult(e,n);return h&&(void 0===this._asyncCompilation&&_(e),t===this._vertex?h.vert=l["a"].tick()-h.vert:h.frag=l["a"].tick()-h.frag),r},compile:function(){var e=this._gl,t=this._fragment.getText(),r=this._vertex.getText();this._attributeMap=v(r),this._uniformMap=b(t+"\n"+r),this._glShaderCompile(e,this._vertex),this._glShaderCompile(e,this._fragment)},getShaderName:function(){if(this._shaderName)return this._shaderName;if(this._fragment&&this._fragment.getText()){var e=this._fragment.getText().match(/^#define\s+SHADER_NAME\s+(.*)$/m);return this._shaderName=e&&e[1]?e[1]:"",this._shaderName}},getCompilationResultAndLink:function(e){return!!this._compileClean||(h&&(h.vert=0,h.frag=0,h.link=0,h.total=0,void 0===this._asyncCompilation&&_(e),h.total=l["a"].tick(),a["a"].log(this.getShaderName()+" start"),a["a"].timeStamp(this.getShaderName()+" start")),this._compileClean=this._glShaderCompilationResult(e,this._vertex),this._compileClean=this._glShaderCompilationResult(e,this._fragment)&&this._compileClean,h&&(a["a"].log(this.getShaderName()+" compilation"),a["a"].timeStamp(this.getShaderName()+" compilation")),!!this._compileClean&&(this._program=e.createProgram(),this._attributeMap.Vertex&&e.bindAttribLocation(this._program,0,"Vertex"),this._glAttachAndLink(e,this._program,this._vertex,this._fragment),!0))},getAsyncCompiling:function(){return this._asyncCompilation},_logShaderStats:function(e){if(void 0===this._asyncCompilation&&_(e),h.link=l["a"].tick()-h.link,h.link){h.total=l["a"].tick()-h.total,this._placeHolder&&(h.total=h.vert+h.frag+h.link);var t=(this._placeHolder?"Async":"")+this.getShaderName()+" - "+h.total.toFixed(2)+"ms";a["a"].group(t),a["a"].log("vertex : "+h.vert.toFixed(2)+"ms"),a["a"].log("fragment : "+h.frag.toFixed(2)+"ms"),a["a"].log("link : "+h.link.toFixed(2)+"ms"),a["a"].log("total : "+h.total.toFixed(2)+"ms"),a["a"].groupEnd(t)}},getLinkResult:function(e){if(this._compileClean){h&&(h.link=l["a"].tick(),a["a"].log(this.getShaderName()+" link"),a["a"].timeStamp(this.getShaderName()+" link"));var t=e.getProgramParameter(this._program,e.LINK_STATUS);if(h&&this._logShaderStats(e),t||e.isContextLost()){this._gl.validateProgram(this._program);var r=this._gl.getProgramInfoLog(this._program);r&&""!==r&&a["a"].log(this.getShaderName()+"\n"+r),this._onCompilationToSpector(this._program)}else{var i=e.getProgramInfoLog(this._program);if(a["a"].errorFold(i,"can't link program\nvertex shader:\n"+this._vertex.text+"\n fragment shader:\n"+this._fragment.text),this._logDebugShaders(e,i),n&&n(this._vertex.text,this._fragment.text,i),this._compileClean=!1,this._onErrorToSpector(i))return}}return this._dirty=!1,this._asyncCompilation=-1,this._placeHolder=void 0,this._uniformsCache={},this._attributesCache={},this._compileClean?(this.cacheAttributeList(e,window.Object.keys(this._attributeMap)),this.cacheUniformList(e,window.Object.keys(this._uniformMap))):this._activateFailSafe(e),this._bindProgramToSpector(),this._compileClean},enableAsyncCompilation:function(e,t){this._placeHolder=e,this._asyncCompilation=t},apply:function(e){if(!this._nullProgram)if(this._gl||this.setGraphicContext(e.getGraphicContext()),!this._program||this._dirty)if(this._placeHolder)this._placeHolder.apply(e);else{if(this.compile(),d||-1===this._fragment.getText().indexOf("#pragma compilationAsync"))return this.getCompilationResultAndLink(this._gl),this.getLinkResult(this._gl),e.applyProgram(this._program),void(this._dirty=!1);this._asyncCompilation=1}else e.applyProgram(this._program)},cacheUniformList:function(e,t){for(var r=this._uniformsCache,n=0,i=t.length;n<i;n++){var a=t[n],o=e.getUniformLocation(this._program,a);void 0!==o&&null!==o&&void 0===r[a]&&(r[a]=o)}},cacheAttributeList:function(e,t){for(var r=this._attributesCache,n=0,i=t.length;n<i;n++){var a=t[n],o=e.getAttribLocation(this._program,a);-1!==o&&void 0!==o&&void 0===r[a]&&(r[a]=o)}}})),"osg","Program"),S.registerErrorCallback=function(e){n=e},t["a"]=S},c247:function(e,t,r){"use strict";r("e9c4"),r("d3b7"),r("159b"),r("fb6a"),r("ac1f"),r("5319"),r("a15b"),r("25f0"),r("ddb0"),r("4e82"),r("a434");var n=r("a214"),i=r("2857"),a=r("a27e"),o=r("b797"),s={_createVertexShader:function(){var e=this.declareVertexMain(),t=this.getVertexShaderName();t&&e.push(this.getNode("Define","SHADER_NAME").setValue(t));var r=this.createShaderFromGraphs(e);return n["a"].debug(this.getDebugIdentifier()),n["a"].debug(r),r},declareVertexMain:function(){var e=[this.declarePointSize(),this.declareVertexPosition()];return this.declareVertexVaryings(e),e},declarePointSize:function(){var e=this.getNode("glPointSize");return this._pointSizeAttribute&&this._pointSizeAttribute.isEnabled()?(this.getNode("InlineCode").code("%pointSize = min(64.0, max(1.0, -%size / %position.z));").inputs({position:this.getOrCreateViewVertex(),size:this.getOrCreateUniform("float","uPointSize")}).outputs({pointSize:e}),e):(this.getNode("SetFromNode").inputs(this.getOrCreateConstantOne("float")).outputs(e),e)},declareVertexVaryings:function(e){var t=this._varyings;for(var r in t.vModelVertex&&this.getNode("SetFromNode").inputs(this.getOrCreateModelVertex()).outputs(t.vModelVertex),t.vModelNormal&&this.getNode("SetFromNode").inputs(this.getOrCreateModelNormal()).outputs(t.vModelNormal),t.vModelTangent&&this.getNode("SetFromNode").inputs(this.getOrCreateModelTangent()).outputs(t.vModelTangent),t.vViewVertex&&this.getNode("SetFromNode").inputs(this.getOrCreateViewVertex()).outputs(t.vViewVertex),t.vViewNormal&&this.getNode("SetFromNode").inputs(this.getOrCreateViewNormal()).outputs(t.vViewNormal),t.vViewTangent&&this.getNode("SetFromNode").inputs(this.getOrCreateViewTangent()).outputs(t.vViewTangent),t.vVertexColor&&this.getNode("InlineCode").code("%vcolor = %venabled == 1.0 ? %acolor : vec4(1.0, 1.0, 1.0, 1.0);").inputs({venabled:this.getOrCreateUniform("float","uArrayColorEnabled"),acolor:this.getOrCreateAttribute("vec4","Color")}).outputs({vcolor:this.getOrCreateVarying("vec4","vVertexColor")}),t){var n=t[r];e.push(n);var i=n.getVariable();-1!==i.indexOf("vTexCoord")&&this.getNode("SetFromNode").inputs(this.getOrCreateAttribute("vec2",i.substring(1))).outputs(n)}},declareVertexPosition:function(){var e=this.getNode("glPosition");return this._isBillboard?this.declareVertexTransformBillboard(e):this.declareScreenVertex(e),e},declareScreenVertex:function(e){this.getNode("MatrixMultPosition").inputs({matrix:this.getOrCreateProjectionMatrix(),vec:this.getOrCreateViewVertex()}).outputs({vec:e})},declareVertexTransformBillboard:function(e){this.getNode("Billboard").inputs({Vertex:this.getOrCreateAttribute("vec3","Vertex"),ModelViewMatrix:this.getOrCreateUniform("mat4","uModelViewMatrix"),ProjectionMatrix:this.getOrCreateUniform("mat4","uProjectionMatrix")}).outputs({result:e})},getOrCreateBoneMatrix:function(){var e=this._variables.boneMatrix;if(e)return e;e=this.createVariable("mat4","boneMatrix");var t=this.getOrCreateAttribute("vec4","Weights"),r=this.getOrCreateAttribute("vec4","Bones"),n=this.getOrCreateUniform("vec4","uBones",this._skinningAttribute.getBoneUniformSize());return this.getNode("Skinning").inputs({weights:t,bonesIndex:r,matrixPalette:n}).outputs({result:e}),e},getTarget:function(e,t){var r=-1!==e.indexOf("Tangent")?"vec4":"vec3";return this.getOrCreateAttribute(r,e+"_"+t)},morphTangentApproximation:function(e,t){var r=this.getOrCreateLocalNormal();return this._skinningAttribute&&(r=this.createVariable("vec3"),this.getNode("Normalize").inputs({vec:this.getOrCreateMorphNormal()}).outputs({result:r})),this.getNode("InlineCode").code("%out = %tangent.rgb - dot(%tangent.rgb, %normal) * %normal;").inputs({tangent:e,normal:r}).outputs({out:t}),t},getTargetWeights:function(e){var t=this.getOrCreateUniform("vec4","uTargetWeights");if(-1===e.indexOf("Normal")&&-1===e.indexOf("Tangent"))return t;var r=this.getVariable("nTargetWeights");if(r)return r;r=this.createVariable("vec4","nTargetWeights");var n="%output = abs(%wts)\n;";return n+="%output = %wts / max(1.0, %output.x + %output.y + %output.z + %output.w);",this.getNode("InlineCode").code(n).inputs({wts:t}).outputs({output:r}),r},morphTransformVec3:function(e,t){for(var r={vertex:e,weights:this.getTargetWeights(e.getVariable())},n=this._morphAttribute.getNumTargets(),i=0;i<n;i++)r["target"+i]=this.getTarget(e.getVariable(),i);return this.getNode("Morphing").inputs(r).outputs({result:t}),t},skinTransformVertex:function(e,t){return this.getNode("MatrixMultPosition").setInverse(!0).inputs({matrix:this.getOrCreateBoneMatrix(),vec:e}).outputs({vec:t}),t},skinTransformNormal:function(e,t){return this.getNode("MatrixMultDirection").setInverse(!0).inputs({matrix:this.getOrCreateBoneMatrix(),vec:e}).outputs({vec:t}),t},getOrCreateMorphVertex:function(){var e=this.getVariable("morphVertex");if(e)return e;var t=this.getOrCreateAttribute("vec3","Vertex");return this._morphAttribute&&this._morphAttribute.hasTarget("Vertex")?this.morphTransformVec3(t,this.createVariable("vec3","morphVertex")):t},getOrCreateMorphNormal:function(){var e=this.getVariable("morphNormal");if(e)return e;var t=this.getOrCreateAttribute("vec3","Normal");return this._morphAttribute&&this._morphAttribute.hasTarget("Normal")?this.morphTransformVec3(t,this.createVariable("vec3","morphNormal")):t},getOrCreateMorphTangent:function(){var e=this.getVariable("morphTangent");if(e)return e;var t=this.getOrCreateAttribute("vec4","Tangent"),r=this._morphAttribute&&this._morphAttribute.hasTarget("Tangent");return r?this.morphTransformVec3(t,this.createVariable("vec3","morphTangent")):t},getOrCreateSkinVertex:function(){var e=this.getVariable("skinVertex");if(e)return e;var t=this.getOrCreateMorphVertex();return this._skinningAttribute?this.skinTransformVertex(t,this.createVariable("vec3","skinVertex")):t},getOrCreateSkinNormal:function(){var e=this.getVariable("skinNormal");if(e)return e;var t=this.getOrCreateMorphNormal();return this._skinningAttribute?this.skinTransformNormal(t,this.createVariable("vec3","skinNormal")):t},getOrCreateSkinTangent:function(){var e=this.getVariable("skinTangent");if(e)return e;var t=this.getOrCreateMorphTangent();return this._skinningAttribute?this.skinTransformNormal(t,this.createVariable("vec3","skinTangent")):t},getOrCreateLocalVertex:function(){return this.getOrCreateSkinVertex()},getOrCreateLocalNormal:function(){var e=this.getVariable("localNormal");if(e)return e;var t=this.getOrCreateSkinNormal();return t===this.getOrCreateAttribute("vec3","Normal")?t:(e=this.createVariable("vec3","localNormal"),this.getNode("Normalize").inputs({vec:t}).outputs({result:e}),e)},getOrCreateLocalTangent:function(){var e=this.getVariable("localTangent");if(e)return e;var t=this.getOrCreateAttribute("vec4","Tangent"),r=this.getOrCreateSkinTangent();return r===t?r:this.normalizeAndSetAlpha(r,t,this.createVariable("vec4","localTangent"))},normalizeAndSetAlpha:function(e,t,r){var n=this.createVariable("vec3");return this.getNode("Normalize").inputs({vec:e}).outputs({result:n}),this.getNode("SetAlpha").inputs({color:n,alpha:t}).outputs({result:r}),r}},u=function(e,t){return function(){return this._fragmentShaderMode&&this.logError("This function should not be called from fragment shader : "+t),e.apply(this,arguments)}};for(var c in s)s[c]=u(s[c],c);var l=s,h=r("875b"),d={_createFragmentShader:function(){var e=this.createFragmentShaderGraph(),t=this.getFragmentShaderName();t&&e.push(this.getNode("Define","SHADER_NAME").setValue(t));var r=this.createShaderFromGraphs(e);return n["a"].debug(this.getDebugIdentifier()),n["a"].debug(r),this.cleanAfterFragment(),r},applyPointSizeCircle:function(e){return this._pointSizeAttribute&&this._pointSizeAttribute.isEnabled()&&this._pointSizeAttribute.isCircleShape()?(this.getNode("InlineCode").code("if (length(2.0 * gl_PointCoord - 1.0) > %radius) discard;").inputs({radius:this.getOrCreateConstantOne("float")}).outputs({output:e}),e):e},cleanAfterFragment:function(){for(var e in this._variables={},this._activeNodeMap={},this._texturesByName)this._texturesByName[e].variable=void 0;for(var t in this._varyings){var r=this._varyings[t];r.reset(),this._activeNodeMap[r.getID()]=r,this._variables[t]=r}},createDefaultFragmentShaderGraph:function(){var e=this.getOrCreateConstant("vec4","fofd").setValue("vec4(1.0, 0.0, 1.0, 0.7)"),t=this.getNode("glFragColor");return this.getNode("SetFromNode").inputs(e).outputs(t),t},createFragmentShaderGraph:function(){var e=[];if(!this._material)return e.push(this.createDefaultFragmentShaderGraph()),e;var t=this._lights.length>0?this.getLighting():this.getOrCreateMaterialDiffuseColor(),r=this.getOrCreateMaterialEmission();if(r){var n=this.createVariable("vec3");this.getNode("Add").inputs(t,r).outputs(n),t=n}var i=this.getDiffuseColorFromTextures();if(i){var a=this.createVariable("vec3");this.getNode("Mult").inputs(t,i).outputs(a),t=a}var o=this.getAlpha();t=this.getPremultAlpha(t,o);var s=this.getNode("glFragColor");return this.applyPointSizeCircle(s),this.getNode("SetAlpha").inputs({color:t,alpha:o}).outputs({result:s}),e.push(s),e},getAlpha:function(){var e=this.createVariable("float"),t=this.getFirstValidTexture(),r={color:this.getOrCreateMaterialDiffuseColor()};t&&(r.texelAlpha=t);var n=t?"%alpha = %color.a * %texelAlpha.a;":"%alpha = %color.a;";return this._isBillboard&&(n+="if ( %alpha == 0.0) discard;"),this.getNode("InlineCode").code(n).inputs(r).outputs({alpha:e}),e},getOrCreateFrontViewTangent:function(){var e=this._variables.frontViewTangent;return e||(e=this.createVariable("vec4","frontViewTangent"),this.getNode("FrontNormal").inputs({normal:this.getOrCreateViewTangent()}).outputs({result:e}),e)},getOrCreateFrontViewNormal:function(){var e=this._variables.frontViewNormal;return e||(e=this.createVariable("vec3","frontViewNormal"),this.getNode("FrontNormal").inputs({normal:this.getOrCreateViewNormal()}).outputs({result:e}),e)},getOrCreateNormalizedViewEyeDirection:function(){var e=this._variables.eyeVector;return e||(e=this.createVariable("vec3","eyeVector"),this.getNode("SetFromNode").inputs(this.getOrCreateViewVertex()).outputs(e),this.getNode("Normalize").inputs({vec:e}).outputs({result:e}),this.getNode("Mult").inputs(e,this.createVariable("float").setValue("-1.0")).outputs(e),e)},getOrCreateNormalizedFrontViewNormal:function(){var e=this._variables.nFrontViewNormal;return e||(e=this.createVariable("vec3","nFrontViewNormal"),this.getNode("Normalize").inputs({vec:this.getOrCreateFrontViewNormal()}).outputs({result:e}),e)},getOrCreateFrontModelNormal:function(){var e=this._variables.frontModelNormal;return e||(e=this.createVariable("vec3","frontModelNormal"),this.getNode("FrontNormal").inputs({normal:this.getOrCreateModelNormal()}).outputs({result:e}),e)},getOrCreateNormalizedFrontModelNormal:function(){var e=this._variables.nFrontModelNormal;return e||(e=this.createVariable("vec3","nFrontModelNormal"),this.getNode("Normalize").inputs({vec:this.getOrCreateFrontModelNormal()}).outputs({result:e}),e)},getPremultAlpha:function(e,t){if(void 0===t)return e;var r=this.createVariable("vec4");return this.getNode("PreMultAlpha").inputs({color:e,alpha:t}).outputs({result:r}),r},getColorsRGB:function(e){var t=this.createVariable("vec3");return this.getNode("LinearTosRGB").inputs({color:e}).outputs({color:t}),t},multiplyDiffuseWithVertexColor:function(e){var t=this.getOrCreateVarying("vec4","vVertexColor"),r=this.getOrCreateUniform("float","uArrayColorEnabled"),n=this.createVariable("vec4"),i=["","%color = %diffuse;","if ( %hasVertexColor == 1.0)"," %color *= %vertexColor;"].join("\n");return this.getNode("InlineCode").code(i).inputs({diffuse:e,hasVertexColor:r,vertexColor:t}).outputs({color:n}).comment("diffuse color = diffuse color * vertex color"),n},getDiffuseColorFromTextures:function(){var e=[],t=this._texturesByName;for(var r in t){var n=t[r];n.shadow||e.push(this.getTextureByName(r).variable)}if(e.length>1){var i=this.createVariable("vec3","texDiffuseAccum");return this.getNode("Mult").inputs(e).outputs(i),i}if(1===e.length)return e[0]},getFirstValidTexture:function(){for(var e=this._textures,t=0,r=e.length;t<r;++t){var n=e[t];if(n)return this.getTextureByName(n.getName()).variable}},_getShadowReceiveAttributeFromLightNum:function(e,t){for(var r=0;r<e.length;r++){var n=e[r];if(n&&n.getLightNumber()===t)return n}},_getShadowTextureFromLightNum:function(e,t){for(var r=0;r<e.length;r++){var n=e[r];if(n&&n.hasLightNumber(t))return n}},getInputsFromShadow:function(e,t,r,n){var i=e.getOrCreateUniforms(),a=this._shadowsTextures.indexOf(t),o=t.getOrCreateUniforms(a),s=e.getAtlas()?"_"+n:"",u={lighted:r,normalWorld:this.getOrCreateNormalizedFrontModelNormal(),vertexWorld:this.getOrCreateModelVertex(),shadowTexture:this.getOrCreateSampler("sampler2D","Texture"+a),shadowSize:this.getOrCreateUniform(o["RenderSize"]),shadowProjection:this.getOrCreateUniform(o["Projection"+s]),shadowViewRight:this.getOrCreateUniform(o["ViewRight"+s]),shadowViewUp:this.getOrCreateUniform(o["ViewUp"+s]),shadowViewLook:this.getOrCreateUniform(o["ViewLook"+s]),shadowDepthRange:this.getOrCreateUniform(o["DepthRange"+s]),shadowBias:this.getOrCreateUniform(i.bias)};return e.getAtlas()&&(u.atlasSize=this.getOrCreateUniform(o["MapSize"+s])),e.getNormalBias()&&(u.normalBias=this.getOrCreateUniform(i.normalBias)),u},getOrCreateDistanceShadow:function(e){if(this._computeShadowOutDistance){var t="shadowDistance"+e,r=this.getVariable(t);return r||(r=this.createVariable("float",t).setValue("0.0")),r}},getOrCreateJitterShadow:function(){return!1},hasLightShadow:function(e){var t=this._getShadowTextureFromLightNum(this._shadowsTextures,e),r=this._getShadowReceiveAttributeFromLightNum(this._shadows,e);return!!t&&!!r},createShadowingLight:function(e,t){var r=e.getLightNumber(),n=this._getShadowTextureFromLightNum(this._shadowsTextures,r),i=this._getShadowReceiveAttributeFromLightNum(this._shadows,r);if(n&&i){var a=this.getInputsFromShadow(i,n,t,r),o=this.createVariable("float"),s={result:o},u=i.getDefines(),c=this.getOrCreateDistanceShadow(r);c&&(s.outDistance=c,u.push("#define _OUT_DISTANCE"));var l=this.getOrCreateJitterShadow(r);return l&&(a.jitter=l),this.getNode("ShadowReceive").inputs(a).outputs(s).addDefines(u),o}},getOrCreateMaterialNormal:function(){return this.getOrCreateNormalizedFrontViewNormal()},getOrCreateMaterialDiffuseColor:function(){var e=this.getVariable("materialDiffuseColor");if(e)return e;e=this.createVariable("vec4","materialDiffuseColor");var t=this.getOrCreateUniform(this._material.getOrCreateUniforms().diffuse);return this.getNode("Mult").inputs(this.multiplyDiffuseWithVertexColor(t)).outputs(e),e},getOrCreateMaterialEmission:function(){return this.getOrCreateUniform(this._material.getOrCreateUniforms().emission)},getOrCreateMaterialSpecularColor:function(){return this.getOrCreateUniform(this._material.getOrCreateUniforms().specular)},getOrCreateMaterialSpecularHardness:function(){return this.getOrCreateUniform(this._material.getOrCreateUniforms().shininess)},getOrCreateMaterialAmbient:function(){return this.getOrCreateUniform(this._material.getOrCreateUniforms().ambient)},getLighting:function(){if(0!==this._lights.length){var e=this.getLightingSeparate(),t=this.createVariable("vec3");return this.getNode("Add").inputs(e.diffuse,e.specular).outputs(t),t}},getLightingSeparate:function(){if(0!==this._lights.length){for(var e,t,r=[],n=[],i=0;i<this._lights.length;i++){var a=this._lights[i],o=this.getLightSeparate(a);r.push(o.diffuseOut),n.push(o.specularOut)}return 1===this._lights.length?(e=r[0],t=n[0]):(e=this.createVariable("vec3"),this.getNode("Add").inputs(r).outputs(e),t=this.createVariable("vec3"),this.getNode("Add").inputs(n).outputs(t)),{diffuse:e,specular:t}}},getLightSeparate:function(e){var t=this.getPrecomputeLight(e),r=this.getLightWithPrecompute(e,t),n=this.createShadowingLight(e,r.lighted);n&&(this.getNode("Mult").inputs(r.diffuseOut,n).outputs(r.diffuseOut),this.getNode("Mult").inputs(r.specularOut,n).outputs(r.specularOut));var i=this.getAmbientLight(e);return i&&this.getNode("Add").inputs(r.diffuseOut,i).outputs(r.diffuseOut),{diffuseOut:r.diffuseOut,specularOut:r.specularOut,lighted:r.lighted,attenuation:t.attenuation,eyeLightDir:t.eyeLightDir,dotNL:t.dotNL}},getPrecomputeLight:function(e){var t,r=e.getOrCreateUniforms(),n={attenuation:this.createVariable("float"),eyeLightDir:this.createVariable("vec3"),dotNL:this.createVariable("float")},i={normal:this.getOrCreateMaterialNormal()},a=e.getLightType();return a===h["a"].POINT?(t="PrecomputePoint",i.viewVertex=this.getOrCreateViewVertex(),i.lightAttenuation=this.getOrCreateUniform(r.attenuation),i.lightViewPosition=this.getOrCreateUniform(r.viewPosition)):a===h["a"].SPOT?(t="PrecomputeSpot",i.viewVertex=this.getOrCreateViewVertex(),i.lightViewDirection=this.getOrCreateUniform(r.viewDirection),i.lightAttenuation=this.getOrCreateUniform(r.attenuation),i.lightSpotCutOff=this.getOrCreateUniform(r.spotCutOff),i.lightSpotBlend=this.getOrCreateUniform(r.spotBlend),i.lightViewPosition=this.getOrCreateUniform(r.viewPosition)):(t="PrecomputeSun",i.lightViewDirection=this.getOrCreateUniform(r.viewDirection)),this.getNode(t).inputs(i).outputs(n),n},getLightWithPrecompute:function(e,t){var r=e.getOrCreateUniforms(),n={normal:this.getOrCreateMaterialNormal(),eyeVector:this.getOrCreateNormalizedViewEyeDirection(),dotNL:t.dotNL,attenuation:t.attenuation,materialDiffuse:this.getOrCreateMaterialDiffuseColor(),materialSpecular:this.getOrCreateMaterialSpecularColor(),materialShininess:this.getOrCreateMaterialSpecularHardness(),lightDiffuse:this.getOrCreateUniform(r.diffuse),lightSpecular:this.getOrCreateUniform(r.specular),eyeLightDir:t.eyeLightDir},i="ComputeLightLambertCookTorrance";e.getLightType()===h["a"].HEMI&&(n.lightGround=this.getOrCreateUniform(r.ground),i="HemiLight");var a=this.getOutputsFromLight();return this.getNode(i).inputs(n).outputs(a),a},getAmbientLight:function(e){var t=this.createVariable("vec3"),r=this.getOrCreateUniform(e.getOrCreateUniforms().ambient),n=this.getOrCreateMaterialAmbient();return this.getNode("Mult").inputs(n,r).outputs(t),t},getOutputsFromLight:function(){var e={diffuseOut:this.createVariable("vec3"),specularOut:this.createVariable("vec3"),lighted:this.createVariable("bool")};return e.lighted.silenceWarning=!0,e},createTextureRGBA:function(e,t,r){var n=this.createVariable("vec4");return this.getNode("TextureRGBA").inputs({tex:t,uv:r}).outputs({result:n}),n}},f=function(e,t){return function(){return this._fragmentShaderMode||this.logError("This function should not be called from vertex shader : "+t),e.apply(this,arguments)}};for(var _ in d)d[_]=f(d[_],_);var p=d,g=r("8bd2"),m=function(e,t,r){this._attributes=e,this._textureAttributes=t,this._fragmentShaderMode=!1,this._activeNodeMap={},this._compiledNodeMap={},this._traversedNodeMap={},this._variables={},this._varyings={},this._vertexShader=[],this._fragmentShader=[],this._shaderProcessor=g["a"],this._texturesByName={},this._shadowsTextures=[],this._lights=[],this._shadows=[],this._textures=[],this._material=null,this._invariantPosition=!1,this._isBillboard=!1,this._customVertexShader=!1,this._customFragmentShader=!1,this.initAttributes(),this.initTextureAttributes()};m.cloneStateAttributeConfig=function(e){return JSON.parse(JSON.stringify(e.stateAttributeConfig))},m.setStateAttributeConfig=function(e,t){e.stateAttributeConfig=t,t.attribute.forEach(o["a"].getOrCreateStateAttributeTypeMemberIndexFromName),t.textureAttribute.forEach(o["a"].getOrCreateTextureStateAttributeTypeMemberIndexFromName),e.validAttributeTypeMember=t.attribute,e.validTextureAttributeTypeMember=t.textureAttribute},m.setStateAttributeConfig(m,{attribute:["Light0","ShadowReceive0","Light1","ShadowReceive1","Light2","ShadowReceive2","Light3","ShadowReceive3","Light4","Light5","Light6","Light7","Material","PointSize","Billboard","Morph","Skinning"],textureAttribute:["Texture"]}),m.prototype=o["a"].extend({},l,p,{constructor:m,createFragmentShader:function(){return this._fragmentShaderMode=!0,this._createFragmentShader()},createVertexShader:function(){return this._fragmentShaderMode=!1,this._createVertexShader()},getOrCreateProjectionMatrix:function(){return this.getOrCreateUniform("mat4","uProjectionMatrix")},getCompilerName:function(){return this._material?"CompilerOSGJS":"NoMaterialCompilerOSGJS"},getFragmentShaderName:function(){var e=this.getCompilerName(),t=this._material&&this._material.getName();return t&&(t=t.replace(/[^a-zA-Z0-9]+/g,"_").slice(0,20),e+="("+t+")"),e},getVertexShaderName:function(){return this.getFragmentShaderName()},getDebugIdentifier:function(){var e=this.getVertexShaderName(),t=this.getFragmentShaderName();return e===t?t:e+"|"+t},logError:function(e){n["a"].error(this.getDebugIdentifier()+" : "+e)},logWarn:function(e){n["a"].warn(this.getDebugIdentifier()+" : "+e)},getOrCreateConstantOne:function(e){return this.getOrCreateConstant(e,e+"White").setValue(e+"(1.0)")},getOrCreateConstantZero:function(e){return this.getOrCreateConstant(e,e+"Black").setValue(e+"(0.0)")},initAttributes:function(){for(var e=this._attributes,t=this._lights,r=this._shadows,n=0,i=e.length;n<i;n++){var a=e[n].className();"Light"===a?t.push(e[n]):"Material"===a?this._material=e[n]:"ShadowReceiveAttribute"===a?r.push(e[n]):"Billboard"===a?this._isBillboard=!!e[n]:"SkinningAttribute"===a?this._skinningAttribute=e[n]:"MorphAttribute"===a?this._morphAttribute=e[n]:"PointSizeAttribute"===a&&(this._pointSizeAttribute=e[n])}},initTextureAttributes:function(){var e=this._textureAttributes,t=e.length;this._textures.length=this._shadowsTextures.length=t;for(var r=0;r<t;r++){var n=e[r];if(void 0!==n)for(var i=0,a=n.length;i<a;i++)this.registerTextureAttributes(n[i],r)}},registerTextureAttributes:function(e,t){var r=e.className();return"Texture"===r?this.registerTexture(e,t):-1!==r.indexOf("ShadowTexture")?this.registerTextureShadow(e,t):void 0},registerTexture:function(e,t){var r=e.getName();r||(r="Texture"+t,e.setName(r)),this._textures[t]=e,this._texturesByName[r]={texture:e,variable:void 0,textureUnit:t}},registerTextureShadow:function(e,t){var r=e.getName();r||(r="Texture"+t,e.setName(r)),this._shadowsTextures[t]=e,this._texturesByName[r]={texture:e,variable:void 0,textureUnit:t,shadow:!0}},getTextureByName:function(e){var t=this._texturesByName[e];if(!t||t.variable)return t;var r,n=t.texture,i=t.textureUnit,a=n.className(),o="Texture"+i;if("Texture"===a)r=this.getOrCreateSampler("sampler2D",o);else{if("TextureCubeMap"!==a)return;r=this.getOrCreateSampler("samplerCube",o)}var s=this._fragmentShaderMode?this.getOrCreateVarying("vec2","vTexCoord"+i):this.getOrCreateAttribute("vec2","TexCoord"+i);return t.variable=this.createTextureRGBA(n,r,s),t},createShaderFromGraphs:function(e){this._compiledNodeMap={};var t=[];for(var r in this._variables){var n=this._variables[r],i=n.declare();i&&t.push(i)}var a=this.evaluateExtensions(e),o=this.evaluateDefines(e),s=[];s.push("\n"),s.push(this.evaluateGlobalVariableDeclaration(e)),this._invariantPosition&&!this._fragmentShaderMode&&s.push("\ninvariant gl_Position;"),s.push("\n"),s.push(this.evaluateGlobalFunctionDeclaration(e)),s.push("void main() {"),0!==t.length&&(s.push("// vars\n"),s.push(t.join(" ")),s.push("\n// end vars\n")),0===e.length&&this.logError("shader without any final Node output (need at least one)"),s.push(this.evaluate(e)),s.push("}");var u=s.join("\n"),c=this._shaderProcessor.processShader(u,o,a,this._fragmentShaderMode?"fragment":"vertex"),l=this._compiledNodeMap,h=this._activeNodeMap,d=[];for(var f in h)if(!l[f]){var _=h[f];if(!_.silenceWarning){for(var p="["+_.toString()+"]:",g=_.getInputs(),m=0;m<g.length;++m){var v=g[m];p+="\n - Computed by "+v.getType();var b=v.getOutputs();for(var S in b)b[S]===_&&(p+=" - as "+S)}d.push(p)}}return d.length&&this.logWarn("Nodes requested, but not compiled:\n"+d.join("\n\n")),c},_logLookForVariable:function(e,t){var r=[];for(var n in e)e[n]===t&&r.push(n);return r},getNode:function(){var e=a["a"].getNode.apply(a["a"],arguments);e||n["a"].error("Unknown Node type : "+arguments[0]);var t=e.getID();return this._activeNodeMap[t]=e,e},getVariable:function(e){return this._variables[e]},getAttributeType:function(e){for(var t=0;t<this._attributes.length;t++)if(this._attributes[t].getType()===e)return this._attributes[t]},createVariable:function(e,t,r){var n=t;if(void 0===n){var i=window.Object.keys(this._variables).length;n="tmp_"+i}else if(this._variables[n]){if(n+=r,void 0===r)return this.createVariable(e,t,1);if(this._variables[n])return r++,this.createVariable(e,t,r)}var a=this.getNode("Variable",e,n);return this._variables[n]=a,a},getOrCreateUniform:function(e,t,r){var n=t;if(e instanceof i["a"]){var a=e;e=a.getType(),n=a.getName()}else void 0===n&&this.logError("Cannot create unamed Uniform");var o=this._variables[n];if(o){if(o.getType()===e)return o;"sampler2D"===o.getType()&&"sampler2D"!==e&&this.logError("Same uniform, but different type ("+e+", "+o.getType()+", "+o.getVariable()+")")}var s=this.getNode("Uniform",e,n,r);return this._variables[n]=s,s},getOrCreateSampler:function(e,t){void 0===t&&this.logError("No name given for sampler type : "+e);var r=this._variables[t];if(r)return r;var n=this.getNode("Sampler",e,t);return this._variables[t]=n,n},getOrCreateAttribute:function(e,t){this._fragmentShaderMode&&this.logError("No Vertex Attribute in Fragment Shader");var r=this._variables[t];if(r)return r.getType()!==e&&this.logError("Same attribute, but different type"),r;var n=this.getNode("Attribute",e,t);return this._variables[t]=n,n},getOrCreateConstant:function(e,t){var r=t;if(void 0===r){var n=window.Object.keys(this._variables).length;r="tmp_"+n}else{var i=this._variables[r];if(i)return i.getType()!==e&&this.logError("Same constant name, but different type"),i}var a=this.getNode("Constant",e,r);return this._variables[r]=a,a},getOrCreateVarying:function(e,t){void 0===t&&this.logError("Error: Mandatory to name varying (as you need to retrieve them)");var r=this._variables[t];return r?(this._varyings[t]||this.logError("Error: requesting a varying not declared with getOrCreateVarying previously"),r.getType()!==e&&this.logError("Error: Same varying, but different type"),r):(this._fragmentShaderMode||this._customFragmentShader||this.logError("Error: requesting a varying not declared in Fragment Shader Graph (for Custom Vertex Shader, add this._customFragmentShader to the processor): "+t+" "+e),r=this._variables[t]=this._varyings[t]=this.getNode("Varying",e,t),r)},markNodeAsVisited:function(e){var t=e.getID();this._activeNodeMap[t]===e?this._compiledNodeMap[t]=e:this.logWarn("Node not requested by using Compiler getNode and/or not registered in nodeFactory "+e.toString())},checkOrMarkNodeAsTraversed:function(e){var t=e.getID();return!!this._traversedNodeMap[t]||(this._traversedNodeMap[t]=e,!1)},traverse:function(e,t){if(!this.checkOrMarkNodeAsTraversed(t)){var r=t.getInputs();if(!Array.isArray(r)){var n=[];for(var i in r)n.push(r[i]);r=n}for(var a=0,o=r.length;a<o;a++){t.checkInputsOutputs();var s=r[a];s&&s!==t&&this.traverse(e,s)}e.call(e,t),this.markNodeAsVisited(t)}},_getAndInitFunctor:function(e){this._traversedNodeMap={};var t={},r=[];return e=e.bind(this,t,r),e._map=t,e._text=r,e},_functorEvaluateAndGatherField:function(e,t,r,n){var i=n.getType();void 0!==i&&""!==i||this.logError("Your node "+n+" has no type"),n[e]&&!t[i]&&(t[i]=!0,Array.prototype.push.apply(r,n[e]()))},evaluateAndGatherField:function(e,t){for(var r=this._getAndInitFunctor(this._functorEvaluateAndGatherField.bind(this,t)),n=0,i=e.length;n<i;n++)this.traverse(r,e[n]);return r._text},_functorEvaluateGlobalFunctionDeclaration:function(e,t,r){var n=r.getType();if(void 0!==n&&""!==n||this.logError("Your node "+r+" has no type"),r.globalFunctionDeclaration&&!e[n]){e[n]=!0;var i=r.globalFunctionDeclaration();i&&t.push(i)}},evaluateGlobalFunctionDeclaration:function(e){for(var t=this._getAndInitFunctor(this._functorEvaluateGlobalFunctionDeclaration),r=0,n=e.length;r<n;r++)this.traverse(t,e[r]);return t._text.join("\n")},_functorEvaluateGlobalVariableDeclaration:function(e,t,r){var n=r.getID();if(r.globalDeclaration&&!e[n]){e[n]=!0;var i=r.globalDeclaration();i&&t.push(i)}},evaluateGlobalVariableDeclaration:function(e){var t=this._getAndInitFunctor(this._functorEvaluateGlobalVariableDeclaration),r=0,n=e.length;for(r=0;r<n;r++)this.traverse(t,e[r]);var i=t._text,a=i.length;if(a>0){this.sortDeclarations(i);var o=i[0][0];for(r=0;r<a;++r){var s=i[r][0];s!==o&&(o=s,i[r-1]+="\n")}}return i.join("\n")},sortDeclarations:function(e){if(e.sort(),!this._fragmentShaderMode)for(var t=0,r=e.length;t<r;++t){var n=e[t];if("a"!==n[0])break;if(-1!==n.indexOf("Vertex")){e.splice(t,1),e.unshift(n);break}}},_functorEvaluate:function(e,t,r){var n=r.getID();if(!e[n]){e[n]=!0;var i=r.computeShader();if(i){var a=r.getComment&&r.getComment();a&&t.push(a),t.push(i)}}},evaluate:function(e){for(var t=this._getAndInitFunctor(this._functorEvaluate),r=0,n=e.length;r<n;r++)this.traverse(t,e[r]);return t._text.join("\n")},evaluateDefines:function(e){return this.evaluateAndGatherField(e,"getDefines")},evaluateExtensions:function(e){return this.evaluateAndGatherField(e,"getExtensions")},getOrCreateModelVertex:function(){if(this._fragmentShaderMode)return this.getOrCreateVarying("vec3","vModelVertex");var e=this._variables.modelVertex;return e||(e=this.createVariable("vec3","modelVertex"),this.getNode("MatrixMultPosition").inputs({matrix:this.getOrCreateUniform("mat4","uModelMatrix"),vec:this.getOrCreateLocalVertex()}).outputs({vec:e}),e)},getOrCreateModelNormal:function(){if(this._fragmentShaderMode)return this.getOrCreateVarying("vec3","vModelNormal");var e=this._variables.modelNormal;return e||(e=this.createVariable("vec3","modelNormal"),this.getNode("MatrixMultDirection").inputs({matrix:this.getOrCreateUniform("mat3","uModelNormalMatrix"),vec:this.getOrCreateLocalNormal()}).outputs({vec:e}),e)},getOrCreateModelTangent:function(){if(this._fragmentShaderMode)return this.getOrCreateVarying("vec4","vModelTangent");var e=this._variables.modelTangent;return e||(e=this.createVariable("vec4","modelTangent"),this.getNode("MatrixMultDirection").setOverwriteW(!1).inputs({matrix:this.getOrCreateUniform("mat3","uModelNormalMatrix"),vec:this.getOrCreateLocalTangent()}).outputs({vec:e}),e)},getOrCreateViewVertex:function(){if(this._fragmentShaderMode)return this.getOrCreateVarying("vec4","vViewVertex");var e=this._variables.viewVertex;return e||(e=this.createVariable("vec4","viewVertex"),this.getNode("MatrixMultPosition").inputs({matrix:this.getOrCreateUniform("mat4","uModelViewMatrix"),vec:this.getOrCreateLocalVertex()}).outputs({vec:e}),e)},getOrCreateViewNormal:function(){if(this._fragmentShaderMode)return this.getOrCreateVarying("vec3","vViewNormal");var e=this._variables.viewNormal;return e||(e=this.createVariable("vec3","viewNormal"),this.getNode("MatrixMultDirection").inputs({matrix:this.getOrCreateUniform("mat3","uModelViewNormalMatrix"),vec:this.getOrCreateLocalNormal()}).outputs({vec:e}),e)},getOrCreateViewTangent:function(){if(this._fragmentShaderMode)return this.getOrCreateVarying("vec4","vViewTangent");var e=this._variables.viewTangent;return e||(e=this.createVariable("vec4","viewTangent"),this.getNode("MatrixMultDirection").setOverwriteW(!1).inputs({matrix:this.getOrCreateUniform("mat3","uModelViewNormalMatrix"),vec:this.getOrCreateLocalTangent()}).outputs({vec:e}),e)}});t["a"]=m},c360:function(e,t,r){"use strict";var n=r("b797"),i=r("3714"),a=r("5a16"),o=function(){i["a"].call(this),this._values=[]};n["a"].createPrototypeNode(o,n["a"].objectInherit(i["a"].prototype,{addChild:function(e,t){return i["a"].prototype.addChild.call(this,e),void 0===t&&(t=!0),this.children.length>this._values.length?this._values.push(t):this._values[this.children.length-1]=t,!0},setValue:function(e,t){e<this._values.length&&(this._values[e]=t)},getValue:function(e){if(e<this._values.length)return this._values[e]},setAllChildrenOff:function(){for(var e=0;e<this._values.length;++e)this._values[e]=!1},setAllChildrenOn:function(){for(var e=0;e<this._values.length;++e)this._values[e]=!0},traverse:function(){return function(e){var t=e.traversalMode;switch(t){case a["a"].TRAVERSE_ALL_CHILDREN:for(var r=0;r<this.children.length;++r)this.children[r].accept(e);break;case a["a"].TRAVERSE_ACTIVE_CHILDREN:var n=this.children.length;for(this._values.length<n&&(n=this._values.length),r=0;r<n;++r)!0===this._values[r]&&this.children[r].accept(e);break;default:break}}}()}),"osg","Switch"),t["a"]=o},c489:function(e,t,r){"use strict";var n=r("3972"),i=r("ede0"),a=function(e,t,r,a){var o=t,s=void 0!==a?a:e.length;void 0===o&&(o=!0);var u=r||n["c"].create(),c=0;if(o){for(c=s-1;c>=0;c--){var l=e[c];if("Camera"===l.className()&&(l.getReferenceFrame()!==i["a"].RELATIVE_RF||0===l.getParents().length))break}c+=1}for(var h=c,d=s;h<d;h++){var f=e[h];f.computeLocalToWorldMatrix&&f.computeLocalToWorldMatrix(u)}return u};t["a"]={computeLocalToWorld:a}},c77d:function(e,t,r){"use strict";r("4e82");var n=r("b797"),i=r("a214"),a=r("40fc"),o=r("1881"),s=r("1ca0"),u=r("02b4"),c=r("3453"),l=function(){return[null,null]},h=function e(t){a["a"].call(this),this._renderStage=void 0,this._parent=void 0,this._binNum=0,this._sorted=!1,this._sortMode=void 0!==t?t:e.defaultSortMode,this._drawCallback=void 0,this._leafs=[],this._pooledPositionedAttribute=new s["a"](l),this._positionedAttribute=new u["a"],this._stateGraphList=new u["a"],this._bins=new c["a"],e.prototype.init.call(this,t)};h.SORT_BY_STATE=0,h.SORT_BACK_TO_FRONT=1,h.SORT_FRONT_TO_BACK=2,h.defaultSortMode=h.SORT_BY_STATE;var d=function(){return new h},f=new s["a"](d);h.BinPrototypes={RenderBin:function(){return f.getOrCreateObject().init()},DepthSortedBin:function(){return f.getOrCreateObject().init(h.SORT_BACK_TO_FRONT)}};var _=function(e,t){return t._depth-e._depth},p=function(e,t){return e._depth-t._depth},g=function(e,t){return e._binNum-t._binNum};n["a"].createPrototypeObject(h,n["a"].objectInherit(a["a"].prototype,{init:function(e){return this._renderStage=void 0,this._parent=void 0,this._binNum=0,this._sortMode=void 0!==e?e:h.defaultSortMode,this._drawCallback=void 0,h.prototype._initInternal.call(this),this},_initInternal:function(){this._bins.reset(),this._stateGraphList.reset(),this._positionedAttribute.reset(),this._pooledPositionedAttribute.reset(),this._leafs.length=0,this._sorted=!1},_createRenderBin:function(e){var t=h.BinPrototypes.RenderBin;return e&&h.BinPrototypes[e]&&(t=h.BinPrototypes[e]),t()},addPositionAttribute:function(e,t){var r=this._pooledPositionedAttribute.getOrCreateObject();r[0]=e,r[1]=t,this._positionedAttribute.push(r)},getStateGraphList:function(){return this._stateGraphList},getPositionedAttribute:function(){return this._positionedAttribute},copyLeavesFromStateGraphListToRenderLeafList:function(){this._leafs.length=0;for(var e=!1,t=this._stateGraphList.getArray(),r=this._stateGraphList.getLength(),n=0;n<r;n++)for(var a=t[n]._leafs,s=a.getArray(),u=a.getLength(),c=0;c<u;c++){var l=s[c];o["a"].isNaN(l._depth)?e=!0:this._leafs.push(l)}e&&i["a"].debug("warning: RenderBin::copyLeavesFromStateGraphListToRenderLeafList() detected NaN depth values, database may be corrupted."),this._stateGraphList.reset()},getSortMode:function(){return this._sortMode},sortBackToFront:function(){this.copyLeavesFromStateGraphListToRenderLeafList(),this._leafs.sort(_)},sortFrontToBack:function(){this.copyLeavesFromStateGraphListToRenderLeafList(),this._leafs.sort(p)},sortImplementation:function(){var e=h;switch(this._sortMode){case e.SORT_BACK_TO_FRONT:this.sortBackToFront();break;case e.SORT_FRONT_TO_BACK:this.sortFrontToBack();break;case e.SORT_BY_STATE:break}},sort:function(){if(!this._sorted){for(var e=this._bins.getKeys(),t=this._bins.getMap(),r=e.getArray(),n=e.getLength(),i=0;i<n;i++){var a=r[i];t[a].sort()}this.sortImplementation(),this._sorted=!0}},setParent:function(e){this._parent=e},getParent:function(){return this._parent},getBinNumber:function(){return this._binNum},findOrInsert:function(e,t){var r=this._bins.getMap(),n=r[e];return n||(n=this._createRenderBin(t),n._parent=this,n._binNum=e,n._renderStage=this._renderStage,this._bins.set(e,n)),n},getStage:function(){return this._renderStage},addStateGraph:function(e){this._stateGraphList.push(e)},reset:function(){h.prototype._initInternal.call(this)},draw:function(e,t){var r=t;return r=this._drawCallback&&this._drawCallback.drawImplementation?this._drawCallback.drawImplementation(this,e,r):this.drawImplementation(e,r),r},applyPositionedAttribute:function(e,t){for(var r=t.getArray(),n=t.getLength(),i=0,a=n;i<a;i++){var o=r[i],s=o[1],u=o[0];e.setGlobalDefaultAttribute(s),s.apply(e),s.applyPositionedUniform(u,e),e.haveAppliedAttribute(s)}},drawImplementation:function(e,t){for(var r=t,n=[],i=this._bins.getMap(),a=this._bins.getKeys(),o=a.getLength(),s=a.getArray(),u=0;u<o;u++){var c=s[u];n.push(i[c])}n.sort(g);for(var l,h=0,d=n.length;h<d;h++){if(l=n[h],l.getBinNumber()>0)break;r=l.draw(e,r)}for(r=this.drawLeafs(e,r);h<d;h++)l=n[h],r=l.draw(e,r);return r},drawLeafs:function(e,t){for(var r,n=this._stateGraphList.getArray(),i=this._stateGraphList.getLength(),a=this._leafs,o=t,s=0,u=a.length;s<u;s++)r=a[s],r.render(e,o),o=r;for(var c=0,l=i;c<l;c++)for(var h=n[c],d=h._leafs.getArray(),f=h._leafs.getLength(),_=0;_<f;_++)r=d[_],r.render(e,o),o=r;return o}}),"osg","RenderBin"),h.reset=function(){f.reset()},h.clean=function(){f.clean()},t["a"]=h},cb5a:function(e,t,r){"use strict";var n=r("b797"),i=r("02b4"),a=r("3453"),o=r("1ca0"),s=function(){this._depth=0,this._children=new a["a"],this._leafs=new i["a"],this._stateset=void 0,this._parent=void 0},u=function(){return new s};s.pooledStateGraph=new o["a"](u),s.statsNbMoveStateGraph=0,s.reset=function(){s.pooledStateGraph.reset(),s.statsNbMoveStateGraph=0},n["a"].createPrototypeObject(s,{clean:function(){this._leafs.reset(),this._children.reset(),this._depth=0,this._stateset=void 0,this._parent=void 0},getStateSet:function(){return this._stateset},getLeafs:function(){return this._leafs},getParent:function(){return this._parent},findOrInsert:function(e){var t=e.getInstanceID(),r=this._children.getMap(),n=r[t];return n||(n=s.pooledStateGraph.getOrCreateObject(),n.clean(),n._parent=this,n._depth=this._depth+1,n._stateset=e,this._children.set(t,n)),n}},"osg","StateGraph"),s.moveStateGraph=function(){var e=new i["a"],t=e.getArray();return function(r,n,i){s.statsNbMoveStateGraph++,e.reset();var a,o,u=i,c=n;if(u!==c&&void 0!==u)if(void 0!==c){if(c._parent===u._parent)return void 0!==c._stateset&&r.popStateSet(),void(void 0!==u._stateset&&r.pushStateSet(u._stateset));while(c._depth>u._depth)void 0!==c._stateset&&r.popStateSet(),c=c._parent;e.reset();while(u._depth>c._depth)void 0!==u._stateset&&e.push(u._stateset),u=u._parent;while(c!==u)void 0!==c._stateset&&r.popStateSet(),c=c._parent,void 0!==u._stateset&&e.push(u._stateset),u=u._parent;for(a=e._length-1,o=0;a>=o;--a)r.pushStateSet(t[a])}else{do{void 0!==u._stateset&&e.push(u._stateset),u=u._parent}while(u);for(a=e._length-1,o=0;a>=o;--a)r.pushStateSet(t[a])}}}(),t["a"]=s},cc9d:function(e,t,r){"use strict";var n=r("cb5a"),i=[function(e,t,r,n,i){e.applyModelViewMatrix(t,r),e.applyProjectionMatrix(i)},function(e,t,r,n,i){var a=e.getGraphicContext(),o=e.applyModelViewMatrix(t,r);if(e.applyProjectionMatrix(i),o){var s=e._modelMatrix;s.setMatrix4(r),s.apply(a,this.modelUniform)}},function(e,t,r,n,i){var a=e.getGraphicContext(),o=e.applyModelViewMatrix(t,r);if(e.applyProjectionMatrix(i),o){var s=e._viewMatrix;s.setMatrix4(n),s.apply(a,this.viewUniform)}},function(e,t,r,n,i){var a=e.getGraphicContext(),o=e.applyModelViewMatrix(t,r);if(e.applyProjectionMatrix(i),o){var s=e._modelMatrix;s.setMatrix4(r),s.apply(a,this.modelUniform);var u=e._viewMatrix;u.setMatrix4(n),u.apply(a,this.viewUniform)}}],a=function(e,t){this.modelUniform=t._uniformsCache[e._modelMatrix.getName()],this.viewUniform=t._uniformsCache[e._viewMatrix.getName()];var r=0;this.modelUniform&&(r=1),this.viewUniform&&(r|=2),this.apply=i[r]},o=function(){this._parent=void 0,this._geometry=void 0,this._depth=0,this._projection=void 0,this._view=void 0,this._model=void 0,this._modelView=void 0};o.prototype={reset:function(){this._parent=void 0,this._geometry=void 0,this._depth=0,this._projection=void 0,this._view=void 0,this._model=void 0,this._modelView=void 0},init:function(e,t,r,n,i,a,o){this._parent=e,this._geometry=t,this._depth=o,this._projection=r,this._view=n,this._model=a,this._modelView=i},drawGeometry:function(){return function(e){var t=e.getLastProgramApplied(),r=t.getInstanceID(),n=e.getCacheUniformsApplyRenderLeaf(),i=n[r];i||(i=new a(e,t),n[r]=i),i.apply(e,this._modelView,this._model,this._view,this._projection),this._geometry.drawImplementation(e)}}(),render:function(){var e=0,t=-1;return function(r,i){var a,o,s=this._parent,u=s._parent,c=s._stateset;void 0!==i?(a=i._parent,o=a._parent,o!==u?(n["a"].moveStateGraph(r,o,u),r.applyStateSet(c)):(s!==a||r._stateSetStackChanged(e,t))&&r.applyStateSet(c)):(n["a"].moveStateGraph(r,void 0,u),r.applyStateSet(c)),r._setStateSetsDrawID(++e),t=r.getStateSetStackSize(),this.drawGeometry(r)}}()},t["a"]=o},ceab:function(e,t,r){"use strict";r("4c53");var n=r("b797"),i=r("3972"),a=r("773c"),o=function(){a["a"].Intersection.call(this),this._localIntersectionNormal=i["f"].clone(i["f"].ONE),this._i1=-1,this._i2=-1,this._i3=-1,this._r1=0,this._r2=0,this._r3=0},s=function(){a["a"].call(this),this._threshold=0,this._d=i["f"].create(),this._length=0,this._invLength=0,this._start=i["f"].create(),this._end=i["f"].create(),this._dInvX=i["f"].create(),this._dInvY=i["f"].create(),this._dInvZ=i["f"].create(),this._hit=!1};n["a"].createPrototypeObject(s,n["a"].objectInherit(a["a"].prototype,{set:function(e,t,r){this._start=e,this._end=t,i["f"].sub(this._d,t,e),this._length=i["f"].length(this._d),this._invLength=0!==this._length?1/this._length:0,i["f"].scale(this._d,this._d,this._invLength),0!==this._d[0]&&i["f"].scale(this._dInvX,this._d,1/this._d[0]),0!==this._d[1]&&i["f"].scale(this._dInvY,this._d,1/this._d[1]),0!==this._d[2]&&i["f"].scale(this._dInvZ,this._d,1/this._d[2]),void 0!==r&&(this._threshold=r)},enter:function(e,t,r){var n=e._min,a=n[0],o=n[1],s=n[2],u=e._max,c=u[0],l=u[1],h=u[2],d=this._dInvX,f=this._dInvY,_=this._dInvZ;if(t[0]<=r[0]){if(r[0]<a)return!1;if(t[0]>c)return!1;t[0]<a&&i["f"].scaleAndAdd(t,t,d,a-t[0]),r[0]>c&&i["f"].scaleAndAdd(r,t,d,c-t[0])}else{if(t[0]<a)return!1;if(r[0]>c)return!1;r[0]<a&&i["f"].scaleAndAdd(r,t,d,a-t[0]),t[0]>c&&i["f"].scaleAndAdd(t,t,d,c-t[0])}if(t[1]<=r[1]){if(r[1]<o)return!1;if(t[1]>l)return!1;t[1]<o&&i["f"].scaleAndAdd(t,t,f,o-t[1]),r[1]>l&&i["f"].scaleAndAdd(r,t,f,l-t[1])}else{if(t[1]<o)return!1;if(r[1]>l)return!1;r[1]<o&&i["f"].scaleAndAdd(r,t,f,o-t[1]),t[1]>l&&i["f"].scaleAndAdd(t,t,f,l-t[1])}if(t[2]<=r[2]){if(r[2]<s)return!1;if(t[2]>h)return!1;t[2]<s&&i["f"].scaleAndAdd(t,t,_,s-t[2]),r[2]>h&&i["f"].scaleAndAdd(r,t,_,h-t[2])}else{if(t[2]<s)return!1;if(r[2]>h)return!1;r[2]<s&&i["f"].scaleAndAdd(r,t,_,s-t[2]),t[2]>h&&i["f"].scaleAndAdd(t,t,_,h-t[2])}return!0},intersectPoint:function(){var e=i["f"].create(),t=i["f"].create();return function(r,n){var a=this._start;i["f"].sub(e,r,a),i["f"].sub(t,this._end,a);var s=i["f"].dot(e,t)*this._invLength*this._invLength,u=1;if(u=s<0?i["f"].sqrLen(e):s>1?i["f"].sqrDist(r,this._end):i["f"].sqrLen(i["f"].scaleAndAdd(e,e,t,-s)),!(u>this._threshold*this._threshold)){var c=this.initIntersection(new o);c._i1=n,c._r1=1,i["f"].scaleAndAdd(c._localIntersectionPoint,a,t,s),c._ratio=s}}}(),intersectLine:function(){var e=i["f"].create(),t=i["f"].create(),r=i["f"].create(),n=i["f"].create(),a=i["f"].create();return function(s,u,c,l){var h=1e-8;i["f"].sub(e,u,s),i["f"].sub(t,this._end,this._start),i["f"].sub(r,s,this._start);var d,f,_=i["f"].dot(e,e),p=i["f"].dot(e,t),g=i["f"].dot(t,t),m=i["f"].dot(e,r),v=i["f"].dot(t,r),b=_*g-p*p,S=b,x=b;b<h?(d=0,S=1,f=v,x=g):(d=p*v-g*m,f=_*v-p*m,d<0?(d=0,f=v,x=g):d>S&&(d=S,f=v+p,x=g)),f<0?(f=0,-m<0?d=0:-m>_?d=S:(d=-m,S=_)):f>x&&(f=x,-m+p<0?d=0:-m+p>_?d=S:(d=-m+p,S=_));var T=Math.abs(d)<h?0:d/S,y=Math.abs(f)<h?0:f/x;i["f"].scaleAndAdd(n,s,e,T),i["f"].scaleAndAdd(a,this._start,t,y);var C=i["f"].sqrDist(n,a);if(!(C>this._threshold*this._threshold)){var A=this.initIntersection(new o);A._i1=c,A._i2=l,A._r1=1-y,A._r2=y,i["f"].copy(A._localIntersectionPoint,a),A._ratio=y}}}(),intersectTriangle:function(){var e=i["f"].create(),t=i["f"].create(),r=i["f"].create(),n=i["f"].create(),a=i["f"].create(),s=i["f"].create(),u=1e-20;return function(c,l,h,d,f,_){var p=this._d;i["f"].sub(t,h,c),i["f"].sub(r,l,c),i["f"].cross(a,p,t);var g=i["f"].dot(a,r);if(!(g>-u&&g<u)){var m=1/g;i["f"].sub(n,this._start,c);var v=i["f"].dot(a,n)*m;if(!(v<0||v>1)){i["f"].cross(s,n,r);var b=i["f"].dot(s,p)*m;if(!(b<0||v+b>1)){var S=i["f"].dot(s,t)*m;if(!(S<u||S>this._length)){var x=1-v-b,T=v,y=b,C=S*this._invLength,A=c[0]*x+l[0]*T+h[0]*y,E=c[1]*x+l[1]*T+h[1]*y,R=c[2]*x+l[2]*T+h[2]*y;i["f"].cross(e,r,t),i["f"].normalize(e,e);var M=this.initIntersection(new o);M._i1=d,M._i2=f,M._i3=_,M._r1=x,M._r2=T,M._r3=y,i["f"].set(M._localIntersectionPoint,A,E,R),i["f"].copy(M._localIntersectionNormal,e),M._ratio=C,M._backface=i["c"].determinant(M._matrix)*g<0}}}}}}(),operatorPoint:function(e){this._threshold<=0||a["a"].prototype.operatorPoint.call(this,e)},operatorLine:function(e,t){this._threshold<=0||a["a"].prototype.operatorLine.call(this,e,t)}}),"osgUtil","LineSegmentIntersectFunctor"),t["a"]=s},cfa7:function(e,t,r){"use strict";var n=r("e8f9"),i=function(){this._intersections=[],this._primitiveMask=n["a"].ALL_PRIMITIVES,this._intersectionLimit=n["a"].NO_LIMIT};i.prototype={reset:function(){this._intersections.length=0},enter:function(e){return!this.reachedLimit()&&(!e.isCullingActive()||this.intersectNode(e))},intersectNode:function(e){return this.intersectBoundingSphere(e.getBoundingSphere())||this.intersectBoundingBox(e.getBoundingBox())},intersectBoundingSphere:function(){return!1},intersectBoundingBox:function(){return!1},getIntersections:function(){return this._intersections},setIntersectionLimit:function(e){this._intersectionLimit=e},getIntersectionLimit:function(){return this._intersectionLimit},setPrimitiveMask:function(e){this._primitiveMask=e},getPrimitiveMask:function(){return this._primitiveMask},reachedLimit:function(){return this._intersectionLimit===n["a"].LIMIT_ONE&&this._intersections.length>0},setCurrentTransformation:function(){},intersect:function(){}},t["a"]=i},d110:function(e,t){e.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAQAAAAAYLlVAAAER0lEQVR4AezYQUgdxx/AcRukRAM1HrSCkB4tOSQhLxRC2iQYL2JLRIKKnnJoexAphtJbeOmtF2slIr3UsyAxgQZD/qf/IYb/IW1e0cMLheag8uAdtJGmNH/f81NYloEl+4xxTdNCv3OZmZ2d/e7s7G9mt+5f9o6jrnvoqbt61e017flEp20JuPrXCxQkaXmVAl2u6UrUNMGmExrNA2Pp52QXGLYJWDcQanvgdpTtA24I5xiwDtg0nE2gU4JwT71wM8peBG4J9y5JZxaBOSjIWwaWdiGwBMvyCsBcFoEStKnTagPo31lAP2xoVacNKGURWIX2KDsGlDWnC0SezcrCjGwHVrMIzMJMlK1XBCbiTBAIFE1AUX10ZAaYzSJwDqpyUaFbIE0g0B3V51SBc9lew0VYjAsLgLI5eWejujZD8uaUAQvCieHULALHVGEwKnQom3SqRtNTJpV1RPlBoOrYywu85VCiPAIrGqLCwZ16C8cbrAAjwsM0a1XJnM6dBPr8BH4MK9xJj4AhoZkDckZNmXfHvCmjcg4Ixw0BPHIyGsVFAQzXEvhUAA+877hHUHElNDpiXMnzlIw7ElpdUYkVjKhKsllLYBue+E3gPjzTFzc4bNqW2myZdjgM5jMBVTPatSkAXWkCF+Cegxp96XcAlXD589a8mDXng0IFsCgX1+WBa2kCecIRR8zahjD4l1XsjorL4UGwYjBcotXyziPAY++Gig/84Ptw+W27ZzsoDGmIc/XGbADrtebACvzf15riijc0xoNf8XJUnE903a0oMFBL4EOAsk+E18pha16etTAdOywILOnaKQ6c9D+AgjNx5bS9MR2HpjJAWf9uImGPIjAZT8cte2MrjguTwITm3a8FRcQxf9zeGY/XCFDc/WLUBuU46JbsnVI8k8pA204CLcbccCtOYSuXk42csLUUer9hTEtS4KrnyEcHRmVjNI5xKVwVBHqRJKx+U7IxFYejVHrFAndhXp+LQoof2LxszIsmVaLnPvPAXbHAU2hMnY93ZONOaq+NwFOxwEM4kdJwX0YgJZ0AHooFrsOm224Kydl9nANnEz3ftglcFwsctfUa3oItR4XX8LSCJPsfB5IUnJaMhJr06I3TK4mEofceTX/ztaDZxCtZDXcp0K8MlB2UfT/QZANYdOzFAl2WABZ07MuO6D2/CnzmzZ0EBgCKukNl9j1hi29VAVb01hZYhw1j6uOKBkPZdsUhHfdfgY/TBbpgWWuoGLSS8btgzHfeDv1d8hiopAtcg3xcyFncpy+jJ74ID77RfeBCzREoaNNuRpVA9m/Dn10U7hLy6XNgU5KqEdm/jgH/cUbOL2kjENKwQHhvs/8fuPSc72rtONBpTsmqWef28Q/JIZ8T+MNHr+Mf0Tu+cs8D3+j4R/0l+3P0Hyek/0gp/ceK6T9aPlTmC+g/Y0L/OSP6z5rRdd5wxM2c0mbumP4QAJ9CBEfGUf7qAAAAAElFTkSuQmCC"},d305:function(e,t,r){"use strict";var n=r("3972"),i=r("a214"),a=r("40fc"),o=r("c0d6"),s=r("123d"),u=r("02b4"),c=r("d80a"),l=r("2857"),h=r("b797"),d=r("0fd6"),f=r("9f78"),_=r("aee2"),p=r("b5d5"),g=r("7729"),m=function(){return{buffer:{separate:!1,enable:!1,sourceFactor:_["a"].ONE,destinationFactor:_["a"].ZERO,sourceFactorAlpha:_["a"].ONE,destinationFactorAlpha:_["a"].ZERO},state:{separate:void 0,enable:!1,sourceFactor:void 0,destinationFactor:void 0,sourceFactorAlpha:void 0,destinationFactorAlpha:void 0},changed:!0}},v=function(){return{buffer:{func:f["a"].LESS,enable:!1,near:0,far:1},state:{func:void 0,enable:!1,near:void 0,far:void 0},changed:!0}},b=function(){return{buffer:{mode:g["a"].CCW},state:{mode:void 0},changed:!0}},S=function(){return{buffer:{enable:!1,mode:p["a"].BACK},state:{enable:!1,mode:void 0},changed:!0}},x=function(){return{buffer:{enable:!1,x:0,y:0,width:640,height:480},state:{enable:!1,x:void 0,y:void 0,width:void 0,height:void 0},changed:!0}},T=function(){return{buffer:{red:!0,green:!0,blue:!0,alpha:!0},state:{red:void 0,green:void 0,blue:void 0,alpha:void 0},changed:!0}},y=function(){return{buffer:{x:0,y:0,width:640,height:480},state:{x:void 0,y:void 0,width:void 0,height:void 0},changed:!0}},C=function(){return{state:{value:!0},buffer:{value:void 0},changed:!0}},A=function(){return{buffer:{value:1},state:{value:void 0},changed:!0}},E=function(){return{buffer:{red:0,green:0,blue:0,alpha:0},state:{red:void 0,green:void 0,blue:void 0,alpha:void 0},changed:!0}},R=function(){this._stateClearColor=E(),this._stateClearDepth=A(),this._stateDepthMask=C(),this._stateViewport=y(),this._stateColorMask=T(),this._stateScissor=x(),this._stateDepth=v(),this._stateFrontFace=b(),this._stateCullFace=S(),this._stateBlendFunc=m()};R.prototype={clearColor:function(e){var t=this._stateClearColor,r=t.buffer,n=t.state;t.changed=!1,r.red=e[0],r.green=e[1],r.blue=e[2],r.alpha=e[3],n.red===e[0]&&n.green===e[1]&&n.blue===e[2]&&n.alpha===e[3]||(t.changed=!0)},applyClearColor:function(e){var t=this._stateClearColor,r=t.state,n=t.buffer;t.changed=!1,r.red=n.red,r.green=n.green,r.blue=n.blue,r.alpha=n.alpha,e.clearColor(r.red,r.green,r.blue,r.alpha)},clearDepth:function(e){var t=this._stateClearDepth,r=t.buffer,n=t.state;t.changed=!1,r.value=e,n.value!==e&&(t.changed=!0)},applyClearDepth:function(e){var t=this._stateClearDepth,r=t.buffer,n=t.state;t.changed=!1,n.value=r.value,e.clearDepth(n.value)},depthMask:function(e){var t=this._stateDepthMask,r=t.buffer,n=t.state;t.changed=!1,r.value=e,n.value!==e&&(t.changed=!0)},applyDepthMask:function(e){var t=this._stateDepthMask,r=t.buffer,n=t.state;t.changed=!1,n.value=r.value,e.depthMask(n.value)},applyViewportAttribute:function(e){this.viewport(e._x,e._y,e._width,e._height)},viewport:function(e,t,r,n){var i=this._stateViewport,a=i.buffer,o=i.state;i.changed=!1,a.x=e,a.y=t,a.width=r,a.height=n,o.x===e&&o.y===t&&o.width===r&&o.height===n||(i.changed=!0)},applyViewport:function(e){var t=this._stateViewport,r=t.buffer,n=t.state;t.changed=!1,n.x=r.x,n.y=r.y,n.width=r.width,n.height=r.height,e.viewport(n.x,n.y,n.width,n.height)},applyColorMaskAttribute:function(e){var t=this._stateColorMask,r=t.buffer,n=t.state;t.changed=!1,r.red=e._red,r.green=e._green,r.blue=e._blue,r.alpha=e._alpha,n.red===e._red&&n.green===e._green&&n.blue===e._blue&&n.alpha===e._alpha||(t.changed=!0)},applyColorMask:function(e){var t=this._stateColorMask,r=t.buffer,n=t.state;t.changed=!1,n.red=r.red,n.green=r.green,n.blue=r.blue,n.alpha=r.alpha,e.colorMask(n.red,n.green,n.blue,n.alpha)},applyScissorAttribute:function(e){var t=-1!==e._x,r=this._stateScissor,n=r.buffer,i=r.state;r.changed=!1,n.enable=t,n.x=e._x,n.y=e._y,n.width=e._width,n.height=e._height,i.enable===t&&i.x===e._x&&i.y===e._y&&i.width===e._width&&i.height===e._height||(r.changed=!0)},applyScissor:function(e){var t=this._stateScissor,r=t.buffer,n=t.state;t.changed=!1,n.enable!==r.enable&&(n.enable=r.enable,n.enable?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)),n.enable&&(n.x===r.x&&n.y===r.y&&n.width===r.width&&n.height===r.height||(n.x=r.x,n.y=r.y,n.width=r.width,n.height=r.height,e.scissor(n.x,n.y,n.width,n.height)))},applyFrontFaceAttribute:function(e){var t=this._stateFrontFace,r=t.buffer,n=t.state;t.changed=!1,r.mode=e._mode,n.mode!==e._mode&&(t.changed=!0)},applyFrontFace:function(e){var t=this._stateFrontFace,r=t.buffer,n=t.state;t.changed=!1,n.mode!==r.mode&&(n.mode=r.mode,e.frontFace(n.mode))},applyCullFaceAttribute:function(e){var t=this._stateCullFace,r=t.buffer,n=t.state,i=e._mode!==p["a"].DISABLE;t.changed=!1,r.enable=i,r.mode=e._mode,n.enable===i&&n.mode===e._mode||(t.changed=!0)},applyCullFace:function(e){var t=this._stateCullFace,r=t.buffer,n=t.state;t.changed=!1,n.enable!==r.enable&&(n.enable=r.enable,n.enable?e.enable(e.CULL_FACE):e.disable(e.CULL_FACE)),n.enable&&n.mode!==r.mode&&(n.mode=r.mode,e.cullFace(n.mode))},applyDepthAttribute:function(e){var t=e._func!==f["a"].DISABLE,r=this._stateDepth,n=r.buffer,i=r.state;r.changed=!1,n.enable=t,n.func=e._func,n.far=e._far,n.near=e._near,i.enable===t&&i.func===e._func&&i.near===e._near&&i.far===e._far||(r.changed=!0),this.depthMask(e._writeMask)},applyDepth:function(e){var t=this._stateDepth,r=t.buffer,n=t.state;t.changed=!1,n.enable!==r.enable&&(n.enable=r.enable,n.enable?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST)),n.enable&&(n.func!==r.func&&(n.func=r.func,e.depthFunc(n.func)),n.near===r.near&&n.far===r.far||(n.far=r.far,n.near=r.near,e.depthRange(n.near,n.far)))},applyBlendFuncAttribute:function(e){var t=this._stateBlendFunc,r=t.buffer,n=t.state,i=e._sourceFactor!==_["a"].DISABLE&&e._destinationFactor!==_["a"].DISABLE;t.changed=!1,r.enable=i,r.separate=e._separate,r.sourceFactor=e._sourceFactor,r.destinationFactor=e._destinationFactor,r.sourceFactorAlpha=e._sourceFactorAlpha,r.destinationFactorAlpha=e._destinationFactorAlpha,n.enable===i&&n.sourceFactor===e._sourceFactor&&n.destinationFactor===e._destinationFactor&&n.sourceFactorAlpha===e._sourceFactorAlpha&&n.destinationFactorAlpha===e._destinationFactorAlpha||(t.changed=!0)},applyBlendFunc:function(e){var t=this._stateBlendFunc,r=t.buffer,n=t.state;t.changed=!1,n.enable!==r.enable&&(n.enable=r.enable,n.enable?e.enable(e.BLEND):e.disable(e.BLEND)),n.enable&&(n.separate=r.separate,n.separate?n.sourceFactor===r.sourceFactor&&n.destinationFactor===r.destinationFactor&&n.sourceFactorAlpha===r.sourceFactorAlpha&&n.destinationFactorAlpha===r.destinationFactorAlpha||(n.sourceFactor=r.sourceFactor,n.destinationFactor=r.destinationFactor,n.sourceFactorAlpha=r.sourceFactorAlpha,n.destinationFactorAlpha=r.destinationFactorAlpha,e.blendFuncSeparate(n.sourceFactor,n.destinationFactor,n.sourceFactorAlpha,n.destinationFactorAlpha)):n.sourceFactor===r.sourceFactor&&n.destinationFactor===r.destinationFactor||(n.sourceFactor=r.sourceFactor,n.destinationFactor=r.destinationFactor,e.blendFunc(n.sourceFactor,n.destinationFactor)))},applyClearStates:function(e){this._stateDepthMask.changed&&this.applyDepthMask(e),this._stateScissor.changed&&this.applyScissor(e),this._stateClearColor.changed&&this.applyClearColor(e),this._stateClearDepth.changed&&this.applyClearDepth(e),this._stateColorMask.changed&&this.applyColorMask(e)},applyDrawStates:function(e){this._stateViewport.changed&&this.applyViewport(e),this._stateScissor.changed&&this.applyScissor(e),this._stateDepth.changed&&this.applyDepth(e),this._stateDepthMask.changed&&this.applyDepthMask(e),this._stateFrontFace.changed&&this.applyFrontFace(e),this._stateCullFace.changed&&this.applyCullFace(e),this._stateBlendFunc.changed&&this.applyBlendFunc(e),this._stateColorMask.changed&&this.applyColorMask(e)},clear:function(e,t){this.applyClearStates(e),e.clear(t)},drawGeometry:function(e){this.applyDrawStates(e)}};var M=R,w=[void 0,function(e,t){return e[0]===t[0]||(t[0]=e[0],!1)},function(e,t){return e[0]===t[0]&&e[1]===t[1]||(t[0]=e[0],t[1]=e[1],!1)},function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]||(t[0]=e[0],t[1]=e[1],t[2]=e[2],!1)},function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]||(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],!1)}],N=function(e){a["a"].call(this),this._excludeUniforms={uProjectionMatrix:!0,uModelMatrix:!0,uViewMatrix:!0,uModelViewMatrix:!0,uModelNormalMatrix:!0,uModelViewNormalMatrix:!0,uArrayColorEnabled:!0},this._graphicContext=void 0,this._shaderGeneratorProxy=e,void 0===e&&console.break(),this._currentVAO=null,this._currentIndexVBO=null,this._stateSets=new u["a"],this._shaderGeneratorNames=new c["a"],this._uniforms={},this._textureAttributeArrayList=[],this._attributeArray=[],this._projectionMatrix=l["a"].createMatrix4(n["c"].create(),"uProjectionMatrix"),this._modelMatrix=l["a"].createMatrix4(n["c"].create(),"uModelMatrix"),this._viewMatrix=l["a"].createMatrix4(n["c"].create(),"uViewMatrix"),this._modelViewMatrix=l["a"].createMatrix4(n["c"].create(),"uModelViewMatrix"),this._modelNormalMatrix=l["a"].createMatrix3(n["b"].create(),"uModelNormalMatrix"),this._modelViewNormalMatrix=l["a"].createMatrix3(n["b"].create(),"uModelViewNormalMatrix");var t=new c["a"];t._globalDefault=l["a"].createFloat1(0,"uArrayColorEnabled"),this._uniforms.ArrayColorEnabled=t,this._previousColorAttribPair={},this._vertexAttribMap={},this._vertexAttribMap._disable=[],this._vertexAttribMap._keys=[],this._frameStamp=void 0,this._programCommonUniformsCache={},this._lastAppliedModelViewMatrix=void 0,this._lastAppliedProjectionMatrix=void 0,this._program=void 0;var r=new o["a"];this.applyAttribute(r),this._programType=h["a"].getOrCreateStateAttributeTypeMemberIndex(r),this._programAttribute=this._attributeArray[this._programType],this._numPushStateSet=0,this._numApply=0,this._programUniformCache=[],this._cacheUniformId=0,this._stateCache=new M,this.resetStats()};h["a"].createPrototypeObject(N,h["a"].objectInherit(a["a"].prototype,{getExcludeUniforms:function(){return this._excludeUniforms},resetCaches:function(){this._currentVAO=null,this._currentIndexVBO=null,this._previousColorAttribPair={},this._vertexAttribMap={},this._vertexAttribMap._disable=[],this._vertexAttribMap._keys=[],this._programCommonUniformsCache={}},applyColorMask:function(e){this._stateCache.applyColorMaskAttribute(e)},applyBlendFunc:function(e){this._stateCache.applyBlendFuncAttribute(e)},applyCullFace:function(e){this._stateCache.applyCullFaceAttribute(e)},applyFrontFace:function(e){this._stateCache.applyFrontFaceAttribute(e)},applyDepth:function(e){this._stateCache.applyDepthAttribute(e)},applyViewport:function(e){this._stateCache.applyViewportAttribute(e)},applyScissor:function(e){this._stateCache.applyScissorAttribute(e)},viewport:function(e,t,r,n){this._stateCache.viewport(e,t,r,n)},depthMask:function(e){this._stateCache.depthMask(e)},clearDepth:function(e){this._stateCache.clearDepth(e)},clearColor:function(e){this._stateCache.clearColor(e)},clear:function(e){this._stateCache.clear(this._graphicContext,e)},drawGeometry:function(e){this._stateCache.drawGeometry(this._graphicContext,e)},getCacheUniformsApplyRenderLeaf:function(){return this._programCommonUniformsCache},setGraphicContext:function(e){this._graphicContext=e,this._extVAO=d["a"].instance(e).getWebGLExtension("OES_vertex_array_object")},getGraphicContext:function(){return this._graphicContext},getShaderGeneratorProxy:function(){return this._shaderGeneratorProxy},pushCheckOverride:function(e,t,r){var n=this._evaluateOverrideObjectOnStack(e,t,r);n!==t?e.push(n,e._back.value):e.push(t,r)},_evaluateOverrideObjectOnStack:function(e,t,r){var n=e._back;return 0===e._length?t:n.value&s["a"].OVERRIDE&&!(r&s["a"].PROTECTED)?n.object:t},pushStateSet:function(e){this._numPushStateSet++,this._stateSets.push(e),this.pushAttributeMap(this._attributeArray,e._attributeArray,e._activeAttribute);for(var t=e._textureAttributeArrayList,r=e._activeTextureAttributeUnit,n=e._activeTextureAttribute,i=0,a=r.length;i<a;i++){var o=r[i],s=t[o],u=this.getOrCreateTextureAttributeArray(o);this.pushAttributeMap(u,s,n)}e.hasUniform()&&this.pushUniformsList(this._uniforms,e.getUniformList());var c=e.getShaderGeneratorPair();c&&this.pushCheckOverride(this._shaderGeneratorNames,c.getShaderGeneratorName(),c.getValue())},getStateSetStackSize:function(){return this._stateSets.getLength()},insertStateSet:function(){var e=new u["a"],t=e.getArray();return function(r,n){e.reset();var i=this.getStateSetStackSize();while(i>r)e.push(this._stateSets.back()),this.popStateSet(),i--;this.pushStateSet(n);for(var a=e._length-1;a>=0;a--)this.pushStateSet(t[a])}}(),removeStateSet:function(){var e=new u["a"],t=e.getArray();return function(r){var n=this.getStateSetStackSize();if(r>=n)i["a"].warn("Warning State:removeStateSet "+r+" out of range");else{e.reset();while(n-1>r)e.push(this._stateSets.back()),this.popStateSet(),n--;this.popStateSet();for(var a=e._length-1;a>=0;a--)this.pushStateSet(t[a])}}}(),resetCacheFrame:function(){this._lastAppliedModelViewMatrix=this._lastAppliedProjectionMatrix=void 0},resetStats:function(){this._numApply=0,this._numPushStateSet=0},applyProgram:function(e){this._program!==e&&(this._program=e,this.getGraphicContext().useProgram(e))},applyModelViewMatrix:function(){var e=n["b"].create();return function(t,r){if(this._lastAppliedModelViewMatrix===t)return!1;var i,a=this.getLastProgramApplied(),o=a.getUniformsCache(),s=this._modelViewMatrix,u=o.uModelViewMatrix,c=this.getGraphicContext();if(u&&(s.setMatrix4(t),s.apply(c,u)),this._lastAppliedModelViewMatrix){for(var l=this._lastAppliedModelViewMatrix,h=0;h<11;h++)if(t[h]!==l[h]){i=!0;break}}else i=!0;return i&&(s=this._modelViewNormalMatrix,u=o.uModelViewNormalMatrix,u&&(n["b"].normalFromMat4(e,t),s.setMatrix3(e),s.apply(c,u)),u=o.uModelNormalMatrix,u&&(n["b"].normalFromMat4(e,r),s.setMatrix3(e),s.apply(c,u))),this._lastAppliedModelViewMatrix=t,!0}}(),applyProjectionMatrix:function(e){if(this._lastAppliedProjectionMatrix!==e){this._lastAppliedProjectionMatrix=e;var t=this.getLastProgramApplied(),r=this._projectionMatrix,n=t.getUniformsCache()[r.getName()];n&&(r.setMatrix4(e),r.apply(this.getGraphicContext(),n))}},getCurrentShaderGeneratorStateSet:function(e){var t=this._programAttribute,r=e._attributeArray[this._programType];if(!(0!==t._length&&t._back.value!==s["a"].OFF||r&&r.getValue()!==s["a"].OFF)){var n,i=e.getShaderGeneratorPair(),a=this._shaderGeneratorNames;if(i){var o=i.getValue(),u=i.getShaderGeneratorName();n=this._evaluateOverrideObjectOnStack(this._shaderGeneratorNames,u,o)}else a._length&&(n=a._back.object);var c=n,l=this._shaderGeneratorProxy.getShaderGenerator(c);return l}},_applyAttributeMapStateSet:function(e,t){for(var r=e.length>t.length?e.length:t.length,n=0,i=r;n<i;n++){var a,o=n,s=o<e.length?e[o]:void 0,u=o<t.length?t[o]:void 0,c=!!s,l=c&&s._changed;if(u||l){var h=u?u.getAttribute():void 0;if(c)if(h){var d=u.getValue();a=this._evaluateOverrideObjectOnStack(s,h,d),a!==h?s._changed&&(this._applyAttributeStack(a,s),s._changed=!1):this._applyAttributeStack(a,s)&&(s._changed=!0)}else s._length?(s._changed=!1,this._applyAttributeStack(s._back.object,s)):(s._changed=!1,this._applyAttributeStack(s._globalDefault,s));else s=this._createAttributeStack(e,o,h.cloneType()),s._changed=!0,this._applyAttributeStack(h,s)}}},_applyTextureAttributeMapListStateSet:function(e,t){for(var r,n,i,a=16,o=0,s=a;o<s;o++){var u=o;r=u<e.length?e[u]:void 0;var c=u<t.length?t[u]:void 0;if(r||c){n=i=0,r?(i=r.length,c&&(n=c.length)):(r=this.getOrCreateTextureAttributeArray(u),n=c.length);for(var l=i>n?i:n,h=0;h<l;h++){var d,f=h,_=f<i?r[f]:void 0,p=c&&f<c.length?c[f]:void 0,g=!!_,m=g&&_._changed;if(p||m){var v=p?p.getAttribute():void 0;if(g)if(v){var b=p.getValue();d=this._evaluateOverrideObjectOnStack(_,v,b),d!==v?_._changed&&(this._applyTextureAttribute(u,d,_),_._changed=!1):this._applyTextureAttribute(u,d,_)&&(_._changed=!0)}else _._length?(_._changed=!1,this._applyTextureAttribute(u,_._back.object,_)):(_._changed=!1,this._applyTextureAttribute(u,_._globalDefault,_));else d=p.getAttribute(),_=this._createAttributeStack(r,f,d.cloneType()),_._changed=!0,this._applyTextureAttribute(u,d,_)}}}}},applyStateSet:function(e){this._numApply++;var t,r=this.getLastProgramApplied();if(this._currentShaderGenerator=this.getCurrentShaderGeneratorStateSet(e),this._applyAttributeMapStateSet(this._attributeArray,e._attributeArray),this._applyTextureAttributeMapListStateSet(this._textureAttributeArrayList,e._textureAttributeArrayList),this._currentShaderGenerator){var n=this._currentShaderGenerator.getOrCreateProgram(this);this.applyAttribute(n),t=n,this._applyGeneratedProgramUniforms(n,e)}else t=this.getLastProgramApplied(),this._applyCustomProgramUniforms(t,e);r!==t&&(this._lastAppliedModelViewMatrix=void 0,this._lastAppliedProjectionMatrix=void 0)},popAllStateSets:function(){while(this._stateSets._length)this.popStateSet()},popStateSet:function(){if(this._stateSets._length){var e=this._stateSets.pop();this.popAttributeMap(this._attributeArray,e._attributeArray,e._activeAttribute);for(var t=e._textureAttributeArrayList,r=e._activeTextureAttributeUnit,n=e._activeTextureAttribute,i=0,a=r.length;i<a;i++){var o=r[i],s=t[o],u=this._textureAttributeArrayList[o];this.popAttributeMap(u,s,n)}e.hasUniform()&&this.popUniformsList(this._uniforms,e.getUniformList()),e.getShaderGeneratorPair()&&this._shaderGeneratorNames.pop()}},_createAttributeStack:function(e,t,r){h["a"].arrayDense(t,e);var n=new c["a"];return n._globalDefault=r,e[t]=n,n},haveAppliedAttribute:function(e){if(e){var t=this._attributeArray,r=h["a"].getOrCreateStateAttributeTypeMemberIndex(e),n=r<t.length?t[r]:void 0;n||(n=this._createAttributeStack(t,r,e.cloneType())),n._lastApplied=e,n._changed=!0}},applyAttribute:function(e){var t=h["a"].getOrCreateStateAttributeTypeMemberIndex(e),r=this._attributeArray,n=t<r.length?r[t]:void 0;n||(n=this._createAttributeStack(r,t,e.cloneType())),n._changed=!0,this._applyAttributeStack(e,n)},_applyAttributeStack:function(e,t){return t._lastApplied!==e&&(e.apply&&e.apply(this),t._lastApplied=e,!0)},_applyTextureAttribute:function(e,t,r){if(r._lastApplied===t)return!1;if(r._lastApplied=t,!t.apply)return!0;var n=this.getGraphicContext();return n.activeTexture(n.TEXTURE0+e),t.apply(this,e),!0},applyTextureAttribute:function(e,t){var r=h["a"].getOrCreateTextureStateAttributeTypeMemberIndex(t),n=this.getOrCreateTextureAttributeArray(e),i=n[r];i||(i=this._createAttributeStack(n,r,t.cloneType())),i._changed=!0,this._applyTextureAttribute(e,t,i)},getLastProgramApplied:function(){return this._programAttribute._lastApplied},applyDefault:function(){this.popAllStateSets(),this._currentShaderGenerator=void 0,this.applyAttributeMap(this._attributeArray),this.applyTextureAttributeMapList(this._textureAttributeArrayList)},applyAttributeMap:function(e){for(var t,r=0,n=e.length;r<n;r++){var i;if(t=e[r],t)i=t._length?t._back.object:t._globalDefault,t._changed&&(t._lastApplied!==i&&(i.apply&&i.apply(this),t._lastApplied=i),t._changed=!1)}},pushUniformsList:function(e,t){var r,n;for(var i in t){var a=t[i];n=a.getUniform(),r=n.getName(),e[r]||this._createAttributeStack(e,r,n),this.pushCheckOverride(e[r],n,a.getValue())}},popUniformsList:function(e,t){for(var r in t)e[r].pop()},applyTextureAttributeMapList:function(e){for(var t,r=this._graphicContext,n=0,i=e.length;n<i;n++)if(t=e[n],t)for(var a=0,o=t.length;a<o;a++){var s,u=t[a];if(u)s=u._length?u._back.object:u._globalDefault,u._changed&&(u._lastApplied!==s&&(r.activeTexture(r.TEXTURE0+n),s.apply(this,n),u._lastApplied=s),u._changed=!1)}},setGlobalDefaultAttribute:function(e){var t=h["a"].getOrCreateStateAttributeTypeMemberIndex(e);t>=this._attributeArray.length||!this._attributeArray[t]?this._createAttributeStack(this._attributeArray,t,e):this._attributeArray[t]._globalDefault=e},getGlobalDefaultAttribute:function(e){var t=this._attributeArray,r=h["a"].getIdFromTypeMember(e);if(!(void 0===r||r>=t.length))return t[r]?t[r]._globalDefault:void 0},setGlobalDefaultTextureAttribute:function(e,t){var r=this.getOrCreateTextureAttributeArray(e),n=h["a"].getOrCreateTextureStateAttributeTypeMemberIndex(t);n>=r.length||!r[n]?this._createAttributeStack(r,n,t):r[n]._globalDefault=t},getGlobalDefaultTextureAttribute:function(e,t){var r=this.getOrCreateTextureAttributeArray(e),n=h["a"].getTextureIdFromTypeMember(t);if(!(void 0===n||n>=r.length))return r[n]?r[n]._globalDefault:void 0},getOrCreateTextureAttributeArray:function(e){return h["a"].arrayDense(e,this._textureAttributeArrayList),this._textureAttributeArrayList[e]||(this._textureAttributeArrayList[e]=[]),this._textureAttributeArrayList[e]},pushAttributeMap:function(e,t,r){for(var n,i=t.length,a=e.length,o=0,s=r.length;o<s;o++){var u=r[o],c=u<i?t[u]:void 0,l=c.getAttribute();n=u<a?e[u]:void 0,n||(n=this._createAttributeStack(e,u,l.cloneType())),this.pushCheckOverride(n,l,c.getValue()),n._changed=!0}},popAttributeMap:function(e,t,r){for(var n=0,i=r.length;n<i;n++){var a=r[n],o=e[a];o.pop(),o._changed=!0}},setIndexArray:function(e){var t=this._graphicContext;this._currentIndexVBO!==e&&(e.bind(t),this._currentIndexVBO=e),e.isDirty()&&e.compile(t)},lazyDisablingOfVertexAttributes:function(){for(var e=this._vertexAttribMap._keys,t=0,r=e.length;t<r;t++){var n=e[t];this._vertexAttribMap[n]&&(this._vertexAttribMap._disable[n]=!0)}},enableVertexColor:function(){var e=this._programAttribute._lastApplied;if(e.getUniformsCache().uArrayColorEnabled&&e.getAttributesCache().Color){var t=this._uniforms.ArrayColorEnabled._globalDefault,r=this._previousColorAttribPair[e.getInstanceID()];r||(t.setFloat(1),t.apply(this.getGraphicContext(),e.getUniformsCache().uArrayColorEnabled),this._previousColorAttribPair[e.getInstanceID()]=!0)}},disableVertexColor:function(){var e=this._programAttribute._lastApplied;if(e.getUniformsCache().uArrayColorEnabled&&e.getAttributesCache().Color){var t=this._uniforms.ArrayColorEnabled._globalDefault,r=this._previousColorAttribPair[e.getInstanceID()];r&&(t.setFloat(0),t.apply(this.getGraphicContext(),e.getUniformsCache().uArrayColorEnabled),this._previousColorAttribPair[e.getInstanceID()]=!1)}},applyDisablingOfVertexAttributes:function(){for(var e=this._vertexAttribMap._keys,t=0,r=e.length;t<r;t++)if(!0===this._vertexAttribMap._disable[e[t]]){var n=e[t];this._graphicContext.disableVertexAttribArray(n),this._vertexAttribMap._disable[n]=!1,this._vertexAttribMap[n]=!1}},clearVertexAttribCache:function(){for(var e=this._vertexAttribMap,t=e._keys,r=0,n=t.length;r<n;r++){var i=t[r];e[i]=void 0,e._disable[i]=!1}this._vertexAttribMap._disable.length=0,this._vertexAttribMap._keys.length=0},setVertexArrayObject:function(e){return this._currentVAO!==e&&(this._currentVAO=e,e?e.bind(this._graphicContext):(this._graphicContext.bindVertexArray(null),this.clearVertexAttribCache()),this._currentIndexVBO=void 0,!0)},setVertexAttribArray:function(e,t,r){var n=this._vertexAttribMap;n._disable[e]=!1;var i=this._graphicContext,a=!1;t.isDirty()&&(t.bind(i),t.compile(i),a=!0);var o=n[e];o!==t&&(a||t.bind(i),o||(i.enableVertexAttribArray(e),void 0===o&&n._keys.push(e)),n[e]=t,i.vertexAttribPointer(e,t.getItemSize(),t.getType(),r,0,0))},_getActiveUniformsFromProgramAttributes:function(e,t){var r=this._attributeArray,n=e.getTrackAttributes().attributeKeys;if(n.length>0)for(var i=0,a=n.length;i<a;i++){var o=n[i],s=this.typeMember[o],u=r[s];if(u){var c=u._globalDefault;if(c.getOrCreateUniforms){var l=c.getOrCreateUniforms();for(var h in l)t.push(l[h])}}}},_getActiveUniformsFromProgramTextureAttributes:function(e,t){var r=e.getTrackAttributes().textureAttributeKeys;if(r)for(var n=0,i=r.length;n<i;n++){var a=r[n];if(a){var o=this._textureAttributeArrayList[n];if(o)for(var s=0,u=a.length;s<u;s++){var c=a[s],l=o[c];if(l){var h=l._globalDefault;if(h.getOrCreateUniforms){var d=h.getOrCreateUniforms();for(var f in d)t.push(d[f])}}}}}},_cacheUniformsForCustomProgram:function(e,t){this._getActiveUniformsFromProgramAttributes(e,t),this._getActiveUniformsFromProgramTextureAttributes(e,t);for(var r=this._graphicContext,n={},i=0,a=t.length;i<a;i++){var o=t[i],s=o.getName(),u=r.getUniformLocation(e._program,s);void 0!==u&&null!==u&&(n[s]=o)}e.trackUniforms=n},_applyCustomProgramUniforms:function(){var e=[];return function(t,r){e.length=0,void 0!==t.getTrackAttributes()&&void 0===t.trackUniforms&&this._cacheUniformsForCustomProgram(t,e);var n,i,a=t.getUniformsCache(),o=this._uniforms;for(var s in t.trackUniforms&&(n=t.trackUniforms),a){var u=a[s],c=o[s],l=r&&r.uniforms[s];if(c||l)if(l){var h=r.uniforms[s],d=h.getValue(),f=h.getUniform();i=c?this._evaluateOverrideObjectOnStack(c,f,d):f}else i=c._length?c._back.object:c._globalDefault;else{if(void 0===n){this._checkErrorUniform(s);continue}i=n[s]}i.apply(this._graphicContext,u)}}}(),_checkErrorUniform:function(e){var t=e.substr(7);this._textureAttributeArrayList[t]&&e==="Texture"+t||this._excludeUniforms[e]||(this._excludeUniforms[e]=1,i["a"].error("Uniform not in the scene hierarchy : "+e))},_computeForeignUniforms:function(e,t){var r=[];for(var n in e){var i=e[n];void 0!==i&&void 0===t[n]&&(this._excludeUniforms[n]||r.push(n))}return r},_removeUniformsNotRequiredByProgram:function(e,t){for(var r in e){var n=t[r];void 0!==n&&null!==n||delete e[r]}},_cacheUniformsForGeneratedProgram:function(e){var t=e.getUniformsCache(),r=e.getActiveUniforms(),n=this._computeForeignUniforms(t,r);e.setForeignUniforms(n),this._removeUniformsNotRequiredByProgram(r,t)},_copyUniformEntry:function(e){var t,r=e.getInternalArray();return r.length<16&&(t=new r.constructor(r.length)),t},_initUniformCache:function(e){var t,r,n,i,a,o,s=e.getActiveUniforms(),u=e.getForeignUniforms(),c=this._uniforms,l=[],h=[];if(e._cacheUniformId=this._cacheUniformId++,this._programUniformCache[e._cacheUniformId]={},u.length)for(n=l,t=0,r=u.length;t<r;t++){i=u[t];var d=c[i];d&&(o=d._globalDefault,a=this._copyUniformEntry(o),n.push(a))}for(var f in s)o=s[f],a=this._copyUniformEntry(o),h.push(a);this._programUniformCache[e._cacheUniformId].foreign=l,this._programUniformCache[e._cacheUniformId].active=h},_checkCacheAndApplyUniform:function(e,t,r,n,i){var a,o=e.getInternalArray(),s=o.length;if(s<=4){var u=t[r];a=w[s](o,u)}else a=!1;if(!a){var c=n[i];e.apply(this._graphicContext,c)}},_applyGeneratedProgramUniforms:function(e,t){var r,n,i,a,o=this._uniforms,s=e.getForeignUniforms();if(!s){if(this._cacheUniformsForGeneratedProgram(e),s=e.getForeignUniforms(),t){var u=t.uniforms;for(a=0;a<s.length;a++)n=s[a],o[n]||u[n]&&(r=u[n].getUniform(),this._createAttributeStack(o,n,r))}this._initUniformCache(e)}var c=e.getUniformsCache(),l=e.getActiveUniforms(),h=this._programUniformCache[e._cacheUniformId].active,d=this._programUniformCache[e._cacheUniformId].foreign,f=0;for(var _ in l)r=l[_],this._checkCacheAndApplyUniform(r,h,f,c,_),f++;f=0;var p=s.length;for(a=0;a<p;a++){n=s[a],i=o[n];var g=t&&t.uniforms[n];if(g||i){if(g){var m=t.uniforms[n],v=m.getValue(),b=m.getUniform();r=this._evaluateOverrideObjectOnStack(i,b,v)}else i._length?r=i._back.object:(r=i._globalDefault,this._checkErrorUniform(n));this._checkCacheAndApplyUniform(r,d,f,c,n),f++}else this._checkErrorUniform(n)}},_setStateSetsDrawID:function(e){for(var t=this._stateSets.getArray(),r=0,n=this._stateSets.length;r<n;r++)t[r].setDrawID(e)},_stateSetStackChanged:function(e,t){var r=this._stateSets.getArray(),n=this._stateSets.length;if(t!==n)return!0;for(var i=0;i<n;i++)if(e!==r[i].getDrawID())return!0;return!1}}),"osg","State");t["a"]=N},d499:function(e,t,r){},d50c:function(e,t,r){"use strict";r("fb6a");var n=function(e,t,r){this._mode=e,this._first=t,this._arrayLengths=r.slice(0)};n.prototype={draw:function(e){for(var t=e.getGraphicContext(),r=this._mode,n=this._first,i=this._arrayLengths,a=0,o=i.length;a<o;a++){var s=i[a];t.drawArrays(r,n,s),n+=s}},getMode:function(){return this._mode},getNumIndices:function(){for(var e=0,t=this._arrayLengths,r=0,n=t.length;r<n;r++)e+=t[r];return e},getCount:function(){return this.getNumIndices()},getArrayLengths:function(){return this._arrayLengths},getFirst:function(){return this._first},setFirst:function(e){this._first=e}},t["a"]=n},d710:function(e,t,r){"use strict";var n='#pragma include "colorEncode.glsl"\r\n\r\n#pragma DECLARE_FUNCTION\r\nvec4 shadowCast(const in vec4 fragEye, const in vec2 shadowDepthRange){\r\n // distance to camera (we make sure we are near 0 and in [0,1])\r\n float depth = (-fragEye.z * fragEye.w - shadowDepthRange.x) / (shadowDepthRange.y - shadowDepthRange.x);\r\n\r\n#ifdef _FLOATTEX\r\n return vec4(depth, 0.0, 0.0, 1.0);\r\n#else\r\n return encodeFloatRGBA(depth);\r\n#endif\r\n}\r\n',i="#ifdef _OUT_DISTANCE\r\n#define OPT_ARG_outDistance ,out float outDistance\r\n#define OPT_INSTANCE_ARG_outDistance ,outDistance\r\n#else\r\n#define OPT_ARG_outDistance\r\n#define OPT_INSTANCE_ARG_outDistance\r\n#endif\r\n\r\n#ifdef _ATLAS_SHADOW\r\n#define OPT_ARG_atlasSize ,const in vec4 atlasSize\r\n#else\r\n#define OPT_ARG_atlasSize\r\n#endif\r\n\r\n#ifdef _NORMAL_OFFSET\r\n#define OPT_ARG_normalBias ,const in float normalBias\r\n#else\r\n#define OPT_ARG_normalBias\r\n#endif\r\n\r\n#ifdef _JITTER_OFFSET\r\n#define OPT_ARG_jitter ,const in float jitter\r\n#define OPT_INSTANCE_ARG_jitter ,jitter\r\n#else\r\n#define OPT_ARG_jitter\r\n#define OPT_INSTANCE_ARG_jitter\r\n#endif\r\n\r\n#pragma include \"tapPCF.glsl\"\r\n\r\n#pragma DECLARE_FUNCTION DERIVATIVES:enable\r\nfloat shadowReceive(const in bool lighted,\r\n const in vec3 normalWorld,\r\n const in vec3 vertexWorld,\r\n\r\n const in sampler2D shadowTexture,\r\n\r\n const in vec2 shadowSize,\r\n const in vec3 shadowProjection,\r\n\r\n const in vec4 shadowViewRight,\r\n const in vec4 shadowViewUp,\r\n const in vec4 shadowViewLook,\r\n\r\n\r\n const in vec2 shadowDepthRange,\r\n const in float shadowBias\r\n OPT_ARG_atlasSize\r\n OPT_ARG_normalBias\r\n OPT_ARG_outDistance\r\n OPT_ARG_jitter) {\r\n\r\n // 0 for early out\r\n bool earlyOut = false;\r\n\r\n // Calculate shadow amount\r\n float shadow = 1.0;\r\n\r\n if (!lighted) {\r\n shadow = 0.0;\r\n#ifndef _OUT_DISTANCE\r\n earlyOut = true;\r\n#endif // _OUT_DISTANCE\r\n }\r\n\r\n if (shadowDepthRange.x == shadowDepthRange.y) {\r\n earlyOut = true;\r\n }\r\n\r\n vec4 shadowVertexEye;\r\n vec4 shadowNormalEye;\r\n float shadowReceiverZ = 0.0;\r\n vec4 shadowVertexProjected;\r\n vec2 shadowUV;\r\n float N_Dot_L;\r\n float invDepthRange;\r\n\r\n if (!earlyOut) {\r\n\r\n shadowVertexEye.x = dot(shadowViewRight.xyz, vertexWorld.xyz) + shadowViewRight.w;\r\n shadowVertexEye.y = dot(shadowViewUp.xyz, vertexWorld.xyz) + shadowViewUp.w;\r\n shadowVertexEye.z = dot(shadowViewLook.xyz, vertexWorld.xyz) + shadowViewLook.w;\r\n shadowVertexEye.w = 1.0;\r\n\r\n\r\n // derivated, only need z.\r\n //vec3 shadowLightDir = vec3(0.0, 0.0, 1.0); // in shadow view light is camera\r\n //shadowNormalEye = shadowViewMatrix * normalFront;\r\n //shadowNormalEye.x = dot(shadowViewRight.xyz, normalWorld.xyz);\r\n //shadowNormalEye.y = dot(shadowViewUp.xyz, normalWorld.xyz);\r\n shadowNormalEye.z = dot(shadowViewLook.xyz, normalWorld.xyz);\r\n //shadowNormalEye.w = 0.0;\r\n\r\n //N_Dot_L = dot(shadowNormalEye.xyz, shadowLightDir);\r\n N_Dot_L = shadowNormalEye.z;\r\n\r\n if (!earlyOut) {\r\n\r\n invDepthRange = 1.0 / (shadowDepthRange.y - shadowDepthRange.x);\r\n\r\n#ifdef _NORMAL_OFFSET\r\n\r\n // http://www.dissidentlogic.com/old/images/NormalOffsetShadows/GDC_Poster_NormalOffset.png\r\n float normalOffsetScale = clamp(1.0 - N_Dot_L, 0.0 , 1.0);\r\n normalOffsetScale *= abs((shadowVertexEye.z - shadowDepthRange.x) * invDepthRange);\r\n normalOffsetScale *= max(shadowProjection.x, shadowProjection.y);\r\n normalOffsetScale *= normalBias * invDepthRange;\r\n\r\n\r\n vec4 shadowNormalShift = vec4(normalWorld, 0.0) * normalOffsetScale;\r\n shadowNormalEye.x = dot(shadowViewRight.xyz, shadowNormalShift.xyz);\r\n shadowNormalEye.y = dot(shadowViewUp.xyz, shadowNormalShift.xyz);\r\n shadowNormalEye.z = dot(shadowViewLook.xyz, shadowNormalShift.xyz);\r\n shadowNormalEye.w = 0.0;\r\n\r\n vec4 viewShadow = shadowVertexEye + shadowNormalEye;\r\n#else\r\n vec4 viewShadow = shadowVertexEye;\r\n#endif\r\n\r\n\r\n if (shadowProjection.z == 0.0){\r\n\r\n // X, 0, 0, 0,\r\n // 0, Y, 0, 0,\r\n // 0, 0, -1, -1,\r\n // 0, 0, -2.0*znear, 0\r\n // mat4 shadowProjectionMatrix;\r\n // shadowProjectionMatrix[0] = vec4(shadowProjection.x, 0.0, 0.0, 0.0 );\r\n // shadowProjectionMatrix[1] = vec4(0.0, shadowProjection.y, 0.0, 0.0 );\r\n // shadowProjectionMatrix[2] = vec4(0.0, 0.0, -1.0, -1.0 );\r\n // shadowProjectionMatrix[3] = vec4(0.0, 0.0, -2.0*shadowDepthRange.x, 0.0 );\r\n // shadowVertexProjected = shadowProjectionMatrix * shadowVertexEye;\r\n\r\n // derivated optimisation\r\n shadowVertexProjected.x = shadowProjection.x * viewShadow.x;\r\n shadowVertexProjected.y = shadowProjection.y * viewShadow.y;\r\n\r\n shadowVertexProjected.z = - viewShadow.z - (2.0 * shadowDepthRange.x * viewShadow.w);\r\n shadowVertexProjected.w = - viewShadow.z;\r\n\r\n }\r\n else{\r\n // lr = 1/(left-right);\r\n // bt = 1/(bottom-top);\r\n // nf = 1/(near-far);\r\n // -2*lr, 0, 0, 0,\r\n // 0, -2*bt, 0, 0,\r\n // 0, 0, 2*nf, 0.0,\r\n // (left+right)*lr, (top+bottom)*bt, (far+near)*nf), 1\r\n // here left = -right && top = -bottom\r\n // float lr = 1.0 / (-2.0 * shadowProjection.x);\r\n // float bt = 1.0 / (-2.0 * shadowProjection.y);\r\n // float nf = 1.0 / (shadowDepthRange.x - shadowDepthRange.y);\r\n float nfNeg = 1.0 / (shadowDepthRange.x - shadowDepthRange.y);\r\n float nfPos = (shadowDepthRange.x + shadowDepthRange.y)*nfNeg;\r\n\r\n //mat4 shadowProjectionMatrix;\r\n //shadowProjectionMatrix[0] = vec4(1.0 / shadowProjection.x, 0.0, 0.0, 0.0 );\r\n //shadowProjectionMatrix[1] = vec4(0.0, 1.0 / shadowProjection.y, 0.0, 0.0 );\r\n //shadowProjectionMatrix[2] = vec4(0.0, 0.0, 2.0*nfNeg, 0.0 );\r\n //shadowProjectionMatrix[3] = vec4(0.0, 0.0, nfPos, 1.0 );\r\n //shadowdertexProjected = shadowProjectionMatrix * shadowVertexEye;\r\n\r\n // derivated optimisation\r\n shadowVertexProjected.x = viewShadow.x / shadowProjection.x;\r\n shadowVertexProjected.y = viewShadow.y / shadowProjection.y;\r\n\r\n shadowVertexProjected.z = 2.0 * nfNeg* viewShadow.z + nfPos * viewShadow.w;\r\n shadowVertexProjected.w = viewShadow.w;\r\n\r\n }\r\n\r\n\r\n if (shadowVertexProjected.w < 0.0) {\r\n earlyOut = true; // notably behind camera\r\n }\r\n\r\n }\r\n\r\n if (!earlyOut) {\r\n\r\n shadowUV.xy = shadowVertexProjected.xy / shadowVertexProjected.w;\r\n shadowUV.xy = shadowUV.xy * 0.5 + 0.5;// mad like\r\n\r\n if (any(bvec4 ( shadowUV.x > 1., shadowUV.x < 0., shadowUV.y > 1., shadowUV.y < 0.))) {\r\n earlyOut = true;// limits of light frustum\r\n }\r\n\r\n // most precision near 0, make sure we are near 0 and in [0,1]\r\n shadowReceiverZ = - shadowVertexEye.z;\r\n shadowReceiverZ = (shadowReceiverZ - shadowDepthRange.x) * invDepthRange;\r\n\r\n if(shadowReceiverZ < 0.0) {\r\n earlyOut = true; // notably behind camera\r\n }\r\n\r\n }\r\n }\r\n\r\n // pcf pbias to add on offset\r\n vec2 shadowBiasPCF = vec2 (0.);\r\n\r\n#ifdef GL_OES_standard_derivatives\r\n#ifdef _RECEIVERPLANEDEPTHBIAS\r\n vec2 biasUV;\r\n\r\n vec3 texCoordDY = dFdx(shadowVertexEye.xyz);\r\n vec3 texCoordDX = dFdy(shadowVertexEye.xyz);\r\n\r\n biasUV.x = texCoordDY.y * texCoordDX.z - texCoordDX.y * texCoordDY.z;\r\n biasUV.y = texCoordDX.x * texCoordDY.z - texCoordDY.x * texCoordDX.z;\r\n biasUV *= 1.0 / ((texCoordDX.x * texCoordDY.y) - (texCoordDX.y * texCoordDY.x));\r\n\r\n // Static depth biasing to make up for incorrect fractional sampling on the shadow map grid\r\n float fractionalSamplingError = dot(vec2(1.0, 1.0) * shadowSize.xy, abs(biasUV));\r\n float receiverDepthBias = min(fractionalSamplingError, 0.01);\r\n\r\n shadowBiasPCF.x = biasUV.x;\r\n shadowBiasPCF.y = biasUV.y;\r\n\r\n shadowReceiverZ += receiverDepthBias;\r\n\r\n#else // _RECEIVERPLANEDEPTHBIAS\r\n shadowBiasPCF.x = clamp(dFdx(shadowReceiverZ) * shadowSize.x, -1.0, 1.0 );\r\n shadowBiasPCF.y = clamp(dFdy(shadowReceiverZ) * shadowSize.y, -1.0, 1.0 );\r\n#endif\r\n\r\n#endif // GL_OES_standard_derivatives\r\n\r\n\r\n vec4 clampDimension;\r\n\r\n#ifdef _ATLAS_SHADOW\r\n shadowUV.xy = ((shadowUV.xy * atlasSize.zw ) + atlasSize.xy) * shadowSize.xy;\r\n\r\n // clamp uv bias/filters by half pixel to avoid point filter on border\r\n clampDimension.xy = atlasSize.xy + vec2(0.5);\r\n clampDimension.zw = (atlasSize.xy + atlasSize.zw) - vec2(0.5);\r\n\r\n clampDimension = clampDimension * shadowSize.xyxy;\r\n#else\r\n clampDimension = vec4(0.0, 0.0, 1.0, 1.0);\r\n#endif // _RECEIVERPLANEDEPTHBIAS\r\n\r\n\r\n // now that derivatives is done and we don't access any mipmapped/texgrad texture we can early out\r\n // see http://teknicool.tumblr.com/post/77263472964/glsl-dynamic-branching-and-texture-samplers\r\n if (earlyOut) {\r\n // empty statement because of weird gpu intel bug\r\n } else {\r\n\r\n // depth bias: fighting shadow acne (depth imprecsion z-fighting)\r\n // cosTheta is dot( n, l ), clamped between 0 and 1\r\n // float shadowBias = 0.005*tan(acos(N_Dot_L));\r\n // same but 4 cycles instead of 15\r\n float depthBias = 0.05 * sqrt( 1.0 - N_Dot_L * N_Dot_L) / clamp(N_Dot_L, 0.0005, 1.0);\r\n\r\n // That makes sure that plane perpendicular to light doesn't flicker due to\r\n // selfshadowing and 1 = dot(Normal, Light) using a min bias\r\n depthBias = clamp(depthBias, 0.00005, 2.0 * shadowBias);\r\n\r\n // shadowZ must be clamped to [0,1]\r\n // otherwise it's not comparable to shadow caster depth map\r\n // which is clamped to [0,1]\r\n // Not doing that makes ALL shadowReceiver > 1.0 black\r\n // because they ALL becomes behind any point in Caster depth map\r\n shadowReceiverZ = clamp(shadowReceiverZ, 0.0, 1.0 -depthBias) - depthBias;\r\n\r\n // Now computes Shadow\r\n float res = getShadowPCF(shadowTexture,\r\n shadowSize,\r\n shadowUV,\r\n shadowReceiverZ,\r\n shadowBiasPCF,\r\n clampDimension\r\n OPT_INSTANCE_ARG_outDistance\r\n OPT_INSTANCE_ARG_jitter);\r\n#ifdef _OUT_DISTANCE\r\n if (lighted) shadow = res;\r\n outDistance *= shadowDepthRange.y - shadowDepthRange.x; // world space distance\r\n#else\r\n shadow = res;\r\n#endif // _OUT_DISTANCE\r\n }\r\n\r\n return shadow;\r\n\r\n}\r\n",a='#pragma include "floatFromTex.glsl"\r\n\r\n// simulation of texture2Dshadow glsl call on HW\r\n// http://codeflow.org/entries/2013/feb/15/soft-shadow-mapping/\r\nfloat texture2DCompare(const in sampler2D depths,\r\n const in vec2 uv,\r\n const in float compare,\r\n const in vec4 clampDimension){\r\n float depth = getSingleFloatFromTex(depths, clamp(uv, clampDimension.xy, clampDimension.zw));\r\n return compare - depth;\r\n}\r\n\r\n#ifdef _JITTER_OFFSET\r\n// TODO could be in a random.glsl file\r\n// https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Shaders/Private/Random.ush#L27\r\nfloat shadowInterleavedGradientNoise(const in vec2 fragCoord, const in float frameMod) {\r\n vec3 magic = vec3(0.06711056, 0.00583715, 52.9829189);\r\n return fract(magic.z * fract(dot(fragCoord.xy + frameMod * vec2(47.0, 17.0) * 0.695, magic.xy)));\r\n}\r\n#endif\r\n\r\n// simulates linear fetch like texture2d shadow\r\nfloat texture2DShadowLerp(\r\n const in sampler2D depths,\r\n const in vec2 size,\r\n const in vec2 uv,\r\n const in float compare,\r\n const in vec4 clampDimension\r\n OPT_ARG_outDistance\r\n OPT_ARG_jitter){\r\n\r\n vec2 centroidCoord = uv / size.xy;\r\n\r\n#ifdef _JITTER_OFFSET\r\n if (jitter > 0.0){\r\n centroidCoord += shadowInterleavedGradientNoise(gl_FragCoord.xy, jitter);\r\n }\r\n#endif\r\n\r\n centroidCoord = centroidCoord + 0.5;\r\n vec2 f = fract(centroidCoord);\r\n vec2 centroidUV = floor(centroidCoord) * size.xy;\r\n\r\n vec4 fetches;\r\n const vec2 shift = vec2(1.0, 0.0);\r\n fetches.x = texture2DCompare(depths, centroidUV + size.xy * shift.yy, compare, clampDimension);\r\n fetches.y = texture2DCompare(depths, centroidUV + size.xy * shift.yx, compare, clampDimension);\r\n fetches.z = texture2DCompare(depths, centroidUV + size.xy * shift.xy, compare, clampDimension);\r\n fetches.w = texture2DCompare(depths, centroidUV + size.xy * shift.xx, compare, clampDimension);\r\n\r\n\r\n\r\n#ifdef _OUT_DISTANCE\r\n float _a = mix(fetches.x, fetches.y, f.y);\r\n float _b = mix(fetches.z, fetches.w, f.y);\r\n outDistance = mix(_a, _b, f.x);\r\n#endif\r\n\r\n vec4 st = step(fetches, vec4(0.0));\r\n\r\n float a = mix(st.x, st.y, f.y);\r\n float b = mix(st.z, st.w, f.y);\r\n return mix(a, b, f.x);\r\n}\r\n',o='#pragma include "colorEncode.glsl"\r\n\r\n// end Float codec\r\nfloat getSingleFloatFromTex(const in sampler2D depths, const in vec2 uv){\r\n#ifndef _FLOATTEX\r\n return decodeFloatRGBA(texture2D(depths, uv));\r\n#else\r\n return texture2D(depths, uv).x;\r\n#endif\r\n}\r\n\r\nvec2 getDoubleFloatFromTex(const in sampler2D depths, const in vec2 uv){\r\n#ifndef _FLOATTEX\r\n return decodeHalfFloatRGBA(texture2D(depths, uv));\r\n#else\r\n return texture2D(depths, uv).xy;\r\n#endif\r\n}\r\n\r\nvec4 getQuadFloatFromTex(const in sampler2D depths, const in vec2 uv){\r\n return texture2D(depths, uv).xyzw;\r\n}\r\n// end Float codec\r\n',s='#pragma include "shadowLinearSoft.glsl"\r\n\r\nfloat getShadowPCF(\r\n const in sampler2D depths,\r\n const in vec2 size,\r\n const in vec2 uv,\r\n const in float compare,\r\n const in vec2 biasPCF,\r\n const in vec4 clampDimension\r\n OPT_ARG_outDistance\r\n OPT_ARG_jitter) {\r\n\r\n float res = 0.0;\r\n\r\n res += texture2DShadowLerp(depths, size, uv + biasPCF, compare, clampDimension OPT_INSTANCE_ARG_outDistance OPT_INSTANCE_ARG_jitter);\r\n\r\n\r\n#if defined(_PCFx1)\r\n\r\n#else\r\n\r\n float dx0 = -size.x;\r\n float dy0 = -size.y;\r\n float dx1 = size.x;\r\n float dy1 = size.y;\r\n\r\n#define TSF(o1,o2) texture2DShadowLerp(depths, size, uv + vec2(o1, o2) + biasPCF, compare, clampDimension OPT_INSTANCE_ARG_outDistance OPT_INSTANCE_ARG_jitter)\r\n\r\n res += TSF(dx0, dx0);\r\n res += TSF(dx0, .0);\r\n res += TSF(dx0, dx1);\r\n\r\n#if defined(_PCFx4)\r\n\r\n res /=4.0;\r\n\r\n#elif defined(_PCFx9)\r\n res += TSF(.0, dx0);\r\n res += TSF(.0, dx1);\r\n\r\n res += TSF(dx1, dx0);\r\n res += TSF(dx1, .0);\r\n res += TSF(dx1, dx1);\r\n\r\n\r\n res /=9.0;\r\n\r\n#elif defined(_PCFx25)\r\n\r\n float dx02 = 2.0*dx0;\r\n float dy02 = 2.0*dy0;\r\n float dx2 = 2.0*dx1;\r\n float dy2 = 2.0*dy1;\r\n\r\n // complete row above\r\n res += TSF(dx0, dx02);\r\n res += TSF(dx0, dx2);\r\n\r\n res += TSF(.0, dx02);\r\n res += TSF(.0, dx2);\r\n\r\n res += TSF(dx1, dx02);\r\n res += TSF(dx1, dx2);\r\n\r\n // two new col\r\n res += TSF(dx02, dx02);\r\n res += TSF(dx02, dx0);\r\n res += TSF(dx02, .0);\r\n res += TSF(dx02, dx1);\r\n res += TSF(dx02, dx2);\r\n\r\n res += TSF(dx2, dx02);\r\n res += TSF(dx2, dx0);\r\n res += TSF(dx2, .0);\r\n res += TSF(dx2, dx1);\r\n res += TSF(dx2, dx2);\r\n\r\n\r\n res/=25.0;\r\n\r\n#endif\r\n\r\n#undef TSF\r\n\r\n#endif\r\n return res;\r\n}\r\n/////// end Tap\r\n';t["a"]={"shadowCast.glsl":n,"shadowReceive.glsl":i,"shadowLinearSoft.glsl":a,"floatFromTex.glsl":o,"tapPCF.glsl":s}},d80a:function(e,t,r){"use strict";var n=function(){this._globalDefault=void 0,this._lastApplied=void 0,this._changed=!1,this._values=[],this._back=void 0,this._length=0};n.prototype={getLength:function(){return this._length},push:function(e,t){var r;this._length===this._values.length?(r={object:e,value:t},this._values.push(r)):(r=this._values[this._length],r.object=e,r.value=t),this._back=r,this._length++},pop:function(){if(this._length){var e=this._values;this._length--;var t=e[this._length];return this._back=this._length?e[this._length-1]:void 0,t}}},t["a"]=n},d8db:function(e,t,r){},dfa5:function(e,t,r){"use strict";var n=r("f684"),i=r.n(n),a=function(e,t){return new i.a((function(r,n){var i=new XMLHttpRequest;i.open("GET",e,!0);var a=t&&t.responseType?t.responseType.toLowerCase():void 0;a&&(i.responseType=a),t&&t.progress&&i.addEventListener("progress",t.progress,!1),i.addEventListener("error",n,!1),i.addEventListener("load",(function(){"arraybuffer"===i.responseType||"blob"===i.responseType?r(i.response):r(i.responseText)})),i.send(null)}))},o=function(e,t){return new i.a((function(r){var n=t&&t.responseType?t.responseType.toLowerCase():void 0,i=new window.FileReader;i.onload=function(e){r(e.target.result)},n?"arraybuffer"===n?i.readAsArrayBuffer(e):"blob"===n?r(e):"string"===n?i.readAsText(e):i.readAsDataURL(e):i.readAsText(e)}))},s=function(e,t){return"string"===typeof e?a(e,t):o(e,t)};t["a"]=s},dfe6:function(e,t,r){"use strict";r("a15b"),r("4ec9"),r("d3b7"),r("3ca3"),r("ddb0"),r("a4d3"),r("e01a"),r("cb29"),r("6062"),r("159b"),r("25f0");var n=r("b797"),i=r("5a16"),a=r("9874"),o=function(e){i["a"].call(this,i["a"].TRAVERSE_ALL_CHILDREN),this._selectables=e,this._nodeList=[],this._linkList=[],this._uniqueNodes=new window.Set,this._uniqueEdges=new window.Set};n["a"].createPrototypeObject(o,n["a"].objectInherit(i["a"].prototype,{getColorFromClassName:function(e){switch(e){case"ShadowedScene":return"#3D3D3D";case"Camera":return"#AB7BCF";case"RenderBin":return"#59778B";case"LightSource":return"#53967D";case"RenderStage":return"#DDCC55";case"RenderLeaf":case"Geometry":return"#FFCC55";case"RigGeometry":return"#DD8800";case"MorphGeometry":return"#AA5500";case"MatrixTransform":return"#CE697E";case"StateSet":return"#0099FF";case"StateGraph":case"Skeleton":return"#96999E";case"Bone":return"#A9DEAA";case"Node":return"#FFFFFF";default:return"#FF00AA"}},createGraph:function(e){this.reset(),e.accept(this)},reset:function(){this._nodeList.length=0,this._linkList.length=0,this._uniqueNodes.clear(),this._uniqueEdges.clear()},apply:function(e){if(!e._isNormalDebug){if(this._uniqueNodes.has(e.getInstanceID())||(this._uniqueNodes.add(e.getInstanceID()),this._nodeList.push(e)),this.nodePath.length>=2){var t=this.nodePath[this.nodePath.length-2].getInstanceID(),r=e.getInstanceID(),n=t+"+"+r;this._uniqueEdges.has(n)||(this._linkList.push({parentNode:t,childrenNode:r}),this._uniqueEdges.add(n))}this.traverse(e)}},createMatrixGrid:function(e,t){var r="";return r+="<table><tr><td>"+t[0]+"</td>",r+="<td>"+t[4]+"</td>",r+="<td>"+t[8]+"</td>",r+="<td>"+t[12]+"</td></tr>",r+="<tr><td>"+t[1]+"</td>",r+="<td>"+t[5]+"</td>",r+="<td>"+t[9]+"</td>",r+="<td>"+t[13]+"</td></tr>",r+="<tr><td>"+t[2]+"</td>",r+="<td>"+t[6]+"</td>",r+="<td>"+t[10]+"</td>",r+="<td>"+t[14]+"</td></tr>",r+="<tr><td>"+t[3]+"</td>",r+="<td>"+t[7]+"</td>",r+="<td>"+t[11]+"</td>",r+="<td>"+t[15]+"</td></tr></table>",r},getLabel:function(e){var t=e.className()+" ("+e.getInstanceID()+")";return e.getName&&e.getName()&&(t+="\n"+e.getName()),t},generateNode:function(e,t){var r="";t.getMatrix&&t.getMatrix()&&(r+="<br /><br />"+this.createMatrixGrid(t,t.getMatrix())),this._selectables.set(t.getInstanceID().toString(),t),e.addNode(t.getInstanceID(),{label:this.getLabel(t),description:r,style:"fill: "+this.getColorFromClassName(t.className())+";stroke-width: 0px;"})},generateStateSet:function(e,t){var r=t.getStateSet(),n=r.getInstanceID(),i=this.getLabel(r);i+="\nNbTexture : "+r.getNumTextureAttributeLists(),e.hasNode(n)||(this._selectables.set(n.toString(),r),e.addNode(n,{label:i,style:"fill: "+this.getColorFromClassName(r.className())+";stroke-width: 0px;"})),e.addEdge(null,t.getInstanceID(),n,{style:"stroke: "+this.getColorFromClassName(r.className())+";"})},generateSourceGeometry:function(e,t){var r=t.getSourceGeometry(),n=r.getInstanceID();this._selectables.set(n.toString(),r),e.addNode(n,{label:this.getLabel(r),style:"fill: "+this.getColorFromClassName(r.className())+";stroke-width: 0px;"}),e.addEdge(null,t.getInstanceID(),n,{style:"stroke: "+this.getColorFromClassName(r.className())+";"})},generateNodeAndLink:function(e){for(var t=0,r=this._nodeList.length;t<r;t++){var n=this._nodeList[t];this.generateNode(e,n),n.getStateSet()&&this.generateStateSet(e,n),n.getSourceGeometry&&n.getSourceGeometry()instanceof a["a"]&&this.generateSourceGeometry(e,n)}for(var i=0,o=this._linkList.length;i<o;i++)e.addEdge(null,this._linkList[i].parentNode,this._linkList[i].childrenNode)}}),"osgUtil","DisplayGraphNode");var s=o,u=r("c77d"),c=function(e){this._selectables=e,this._nodeList=[],this._linkList=[],this._renderBinMap=new window.Map,this._renderBinStack=[],this._generatorID=0,this._refID=0,this._uniqueEdges=new window.Set};c.prototype={getColorFromClassName:s.prototype.getColorFromClassName,createGraph:function(e){this.reset(),this.apply(e)},reset:function(){this._renderBinMap.clear(),this._renderBinStack.length=0,this._generatorID=0,this._refID++,this._nodeList.length=0,this._linkList.length=0,this._uniqueEdges.clear()},apply:function(e){var t=e.getInstanceID();if(this._renderBinMap.has(t)||this._renderBinMap.set(t,e),this._renderBinStack.push(e),e.getPreRenderStageList)for(var r=e.getPreRenderStageList(),n=0,i=r.length;n<i;++n)this.apply(r[n].renderStage);if(this.registerNode(e),e.getPostRenderStageList)for(var a=e.getPostRenderStageList(),o=0,s=a.length;o<s;++o)this.apply(a[o].renderStage);this._renderBinStack.pop()},registerNode:function(e){var t=e.getInstanceID();this._nodeList.push(e);var r=e._bins;if(r.forEach(function(e,t){this.apply(t)}.bind(this)),e._leafs.length)for(var n=0,i=e._leafs.length;n<i;n++)this.createNodeAndSetID(t,e._leafs[n]);var a=this,o={},s=function(e){a.createNodeAndSetID(this.stateGraphID,e)}.bind(o),u=function(e){a.createNodeAndSetID(t,e);var r=e._instanceID,n=e.getLeafs();o.stateGraphID=r,n.forEach(s)},c=e.getStateGraphList();if(c.forEach(u),!(this._renderBinStack.length<2)){var l=this._renderBinStack[this._renderBinStack.length-2].getInstanceID();this.createLink(l,t)}},createLink:function(e,t){var r=e+"+"+t;this._uniqueEdges.has(r)||(this._linkList.push({parentNode:e,childrenNode:t}),this._uniqueEdges.add(r))},createNodeAndSetID:function(e,t){this._nodeList.push(t),(void 0===t._instanceID||t._instanceID<0&&t._refID!==this._refID)&&(t._instanceID=-1-this._generatorID++,t._refID=this._refID),this.createLink(e,t._instanceID)},generateRenderLeaf:function(e,t){var r=t._instanceID,n="RenderLeaf",i=t._geometry&&t._geometry.getName()?"\n"+t._geometry.getName():"Geometry",a=n+" ( "+t._instanceID+" )";a+="\n"+i+" ( "+t._geometry.getInstanceID()+" )",this._selectables.set(r.toString(),t),e.addNode(r,{label:a,description:"",style:"fill: "+this.getColorFromClassName(n)+";stroke-width: 0px;"})},generateStateGraph:function(e,t){var r=t._instanceID,n="StateGraph",i=n+" ( "+t._instanceID+" )";i+="\n"+t._leafs._length+" leafs",this._selectables.set(r.toString(),t),e.addNode(r,{label:i,description:"",style:"fill: "+this.getColorFromClassName(n)+";stroke-width: 0px;"})},generateRenderStage:function(e,t){var r=t.className()+" ( "+t._instanceID+" )";t.getName()&&(r+="\n"+t.getName()),r+="\nViewport ( "+t.getViewport().width()+" x "+t.getViewport().height()+" )",this._selectables.set(t.getInstanceID().toString(),t),e.addNode(t.getInstanceID(),{label:r,description:"",style:"fill: "+this.getColorFromClassName(t.className())+";stroke-width: 0px;"})},generateRenderBin:function(e,t){var r=t.className()+" ( "+t.getInstanceID()+" )";t.getName()&&(r+="\n"+t.getName());var n="";t.getSortMode()===u["a"].SORT_BACK_TO_FRONT&&(n="SortMode: BackToFront");var i="BinNumber: "+t.getBinNumber()+"\n"+n;this._selectables.set(t.getInstanceID().toString(),t),e.addNode(t.getInstanceID(),{label:r,description:i,style:"fill: "+this.getColorFromClassName(t.className())+";stroke-width: 0px;"})},generateNodeAndLink:function(e){for(var t=0,r=this._nodeList.length;t<r;t++){var n=this._nodeList[t];n._geometry&&void 0!==n._depth?this.generateRenderLeaf(e,n):"StateGraph"===n.className()?this.generateStateGraph(e,n):"RenderStage"===n.className()?this.generateRenderStage(e,n):this.generateRenderBin(e,n)}for(var i=0,a=this._linkList.length;i<a;i++)e.addEdge(null,this._linkList[i].parentNode,this._linkList[i].childrenNode)}};var l=c,h=r("a214"),d=r("1157"),f=r.n(d),_=function(){f.a||h["a"].warn("You will not be able to use osgUtil.DisplayGraph until you add jQuery in your page")},p=function(e){this.options=e;var t=document.createElement("style");t.type="text/css",t.innerHTML=[".osgDebugSimpleTooltip {","display: none;","position: absolute;","margin-left: 10px;","border-radius: 4px;","padding: 10px;","background: rgba(0,0,0,.9);","color: #ffffff;","}",".osgDebugSimpleTooltip:before {","content: ",";","position: absolute;","left: -10px;","top: 8px;","border: 10px solid transparent;","border-width: 10px 10px 10px 0;","border-right-color: rgba(0,0,0,.9);","}"].join("\n"),document.getElementsByTagName("head")[0].appendChild(t),this.el=document.createElement("div"),this.el.className="osgDebugSimpleTooltip",document.body.appendChild(this.el);for(var r=document.querySelectorAll(this.options.selector),n=0;n<r.length;n++)r[n].addEventListener("mouseover",this.showTooltip.bind(this),!1),r[n].addEventListener("mouseout",this.hideTooltip.bind(this),!1)};p.prototype={showTooltip:function(e){if(f.a){var t=e.currentTarget;this.el.innerHTML=t.getAttribute("title"),this.el.style.display="block",this.el.style.left=f()(t).position().left+f()(t).get(0).getBoundingClientRect().width+"px",this.el.style.top=f()(t).position().top+"px"}},hideTooltip:function(){this.el.style.display="none"}};var g=function(){_(),f.a&&(this._selectables=new window.Map,this._graphNode=new s(this._selectables),this._graphRender=new l(this._selectables),this._displayNode=!0,this._displayRenderer=!1,this._cbSelect=void 0,this._focusedElement="graph",this._idToDomElement=new window.Map,this._$svg=f()("<svg width=100% height=100%></svg>"),f()("body").append(this._$svg),this._css=".node {text-align: center;cursor: pointer;}.node rect {stroke: #FFF;}.edgePath path {stroke: #FFF;fill: none;}table {text-align: right;}svg {position: absolute;left: 0px;top: 0px;}.osgDebugButton {position: absolute;left: 15px;top: 15px;z-index: 5;border: 0;background: #65a9d7;background: -webkit-gradient(linear, left top, left bottom, from(#3e779d), to(#65a9d7));background: -webkit-linear-gradient(top, #3e779d, #65a9d7);background: -moz-linear-gradient(top, #3e779d, #65a9d7);background: -ms-linear-gradient(top, #3e779d, #65a9d7);background: -o-linear-gradient(top, #3e779d, #65a9d7);padding: 5px 10px;-webkit-border-radius: 7px;-moz-border-radius: 7px;border-radius: 7px;-webkit-box-shadow: rgba(0,0,0,1) 0 1px 0;-moz-box-shadow: rgba(0,0,0,1) 0 1px 0;box-shadow: rgba(0,0,0,1) 0 1px 0;text-shadow: rgba(0,0,0,.4) 0 1px 0;color: white;font-size: 15px;font-family: Helvetica, Arial, Sans-Serif;text-decoration: none;vertical-align: middle;}.osgDebugButton:hover {border-top-color: #28597a;background: #28597a;color: #ccc;}.osgDebugButton:active {border-top-color: #1b435e;background: #1b435e;}.osgDebugSimpleTooltip .osgDebugName {font-weight: bold;color: #60b1fc;margin: 0;}.osgDebugSimpleTooltip .osgDebugDescription {margin: 0;}")};g.instance=function(){return g._instance||(g._instance=new g),g._instance},g.prototype={getColorFromClassName:s.prototype.getColorFromClassName,setCallbackSelect:function(e){this._cbSelect=e},reset:function(){f.a&&(this._selectables.clear(),this._$svg.empty(),this._focusedElement="scene",f()(".osgDebugButton").hide())},setDisplayGraphRenderer:function(e){this._displayRenderer=e},createRenderGraph:function(e){this._graphRender.createGraph(e),this.displayGraph()},createGraph:function(e){f.a&&(this.reset(),this._displayNode=!!e,e&&this._graphNode.createGraph(e),this._displayRenderer?r("2a3fb").default.debugGraph=!0:this.displayGraph())},displayGraph:function(){if(f.a)if(window.d3&&window.dagreD3)this._createGraphApply();else{var e="//cdnjs.cloudflare.com/ajax/libs/d3/3.4.13/d3.min.js",t="//cdn.jsdelivr.net/dagre-d3/0.2.9/dagre-d3.min.js",r=this._createGraphApply.bind(this);f.a.getScript(e).done((function(){f.a.getScript(t).done(r)}))}},_createGraphApply:function(){var e=new window.dagreD3.Digraph;this._displayNode&&this._graphNode.generateNodeAndLink(e),this._displayRenderer&&this._graphRender.generateNodeAndLink(e),this.injectStyleElement(),f()(".osgDebugButton").show();var t=this.renderer=new window.dagreD3.Renderer,r=window.d3.select(this._$svg.get(0)),n=r.append("g"),i=.75,a=t.zoom();t.zoom((function(e,t){var r=a(e,t);return r.scale(i).event(t),r}));var o=function(e,t){return'<p class="osgDebugName">'+e+'</p><pre class="osgDebugDescription">'+t+"</pre>"},s=this._idToDomElement,u=t.drawNodes();t.drawNodes((function(e,t){var r=u(e,t);return r.attr("title",(function(t){return s.set(t,this),o(t,e.node(t).description||"")})),r})),t.run(e,n),this.tooltip=new p({selector:".node"}),f()(".node").click(this.onNodeSelect.bind(this)),this.focusOnGraph()},selectNode:function(e){var t=e.getInstanceID(),r=this._idToDomElement.get(t);r&&f()(r).click()},onNodeSelect:function(e){var t=e.currentTarget,r=f()(t.getAttribute("title"))[0].innerHTML,n=this._selectables;this.lastNode&&(this.lastNode.style.fill=this.lastColor);var i=n.get(r);i&&(this.lastNode=t.childNodes[0],this.lastColor=this.lastNode.style.fill,t.childNodes[0].style.fill="#f00",window.activeNode=i,h["a"].info("window.activeNode is set with the node below !"),h["a"].log(window.activeNode),h["a"].log("\n"),this._cbSelect&&this._cbSelect(i))},focusOnScene:function(){f()(".osgDebugButton").text("Access to the graph"),this._$svg.css("zIndex","-2"),this._focusedElement="scene"},focusOnGraph:function(){f()(".osgDebugButton").text("Access to the scene"),this._$svg.css("zIndex","2"),f()(".osgDebugSimpleTooltip").css("zIndex","3"),this._focusedElement="graph"},injectStyleElement:function(){if(!this._cssInjected){this._cssInjected=!0,f()("body").append('<button class="osgDebugButton">Access to the scene</button>'),f()(".osgDebugButton").click(function(){"scene"===this._focusedElement?this.focusOnGraph():this.focusOnScene()}.bind(this));var e=document.createElement("style");e.type="text/css",e.innerHTML=this._css,document.getElementsByTagName("head")[0].appendChild(e)}}};t["a"]=g},e74e:function(e,t,r){"use strict";r("d3b7"),r("cfc3"),r("907a"),r("9a8c"),r("a975"),r("735e"),r("c1ac"),r("d139"),r("3a7b"),r("d5d6"),r("82f8"),r("e91f"),r("60bd"),r("5f96"),r("3280"),r("3fcc"),r("ca91"),r("25a1"),r("cd26"),r("3c5d"),r("2954"),r("649e"),r("219c"),r("170b"),r("b39a"),r("72f7");var n=r("b797"),i=r("3972"),a=r("9946"),o=r("a214"),s=r("23f5"),u=r("9874"),c=r("40fc"),l=(r("fb6a"),r("5a16")),h=r("f991"),d=function(){l["a"].call(this,l["a"].TRAVERSE_PARENTS),this._root=void 0,this._pathToRoot=void 0};n["a"].createPrototypeObject(d,n["a"].objectInherit(l["a"].prototype,{apply:function(e){if(!this._root)return e.typeID===h["a"].typeID?(this._root=e,void(this._pathToRoot=this.nodePath.slice(1))):void this.traverse(e)}}),"osgAnimation","FindNearestParentSkeleton");var f=d,_=function(){c["a"].call(this)};n["a"].createPrototypeObject(_,n["a"].objectInherit(c["a"].prototype,{init:function(e){var t=new f;e.getParents().length>1&&o["a"].warn("A RigGeometry should not have multi parent ( "+e.getName()+" )"),e.getParents()[0].accept(t),t._root?(e.setSkeleton(t._root),e.setPathToSkeleton(t._pathToRoot)):o["a"].warn("A RigGeometry did not find a parent skeleton for RigGeometry ( "+e.getName()+" )")},update:function(e){if(e&&"RigGeometry"!==e.className())return!0;var t=e;return t.getSkeleton()||0===t.getParents().length||this.init(t),!t.getSkeleton()||(t.getNeedToComputeMatrix()&&t.computeMatrixFromRootSkeleton(),t.update(),!0)}}),"osgAnimation","UpdateRigGeometry");var p=_,g=r("123d"),m=r("19cf"),v=r("00cd"),b=function(){l["a"].call(this,l["a"].TRAVERSE_ALL_CHILDREN),this._boneMap={}};n["a"].createPrototypeObject(b,n["a"].objectInherit(l["a"].prototype,{apply:function(e){if(e.typeID===v["a"].typeID){var t=e.getName();t?this._boneMap[t]=e:o["a"].warn("found Bone without name")}this.traverse(e)},getBoneMap:function(){return this._boneMap}}),"osgAnimation","CollectBoneVisitor");var S=b,x=function(){this._isInitialized=!1,this._bones=[]};x.prototype={computeBonePalette:function(e,t){var r=this._bones;for(var n in e){var i=t[n],a=e[n];void 0!==i&&(r[i]=a)}return r},init:function(e){var t=new S;e.getSkeleton().accept(t);var r=t.getBoneMap();this.computeBonePalette(r,e._boneNameID);var n=3*this._bones.length,i=this._skinningAttribute=new m["a"];return i.setMatrixPalette(new Float32Array(4*n)),e.getStateSetAnimation().setAttributeAndModes(i,g["a"].ON),this._isInitialized=!0,!0},computeMatrixPalette:function(){var e=i["c"].create();return function(t,r){for(var n=this._bones,a=this._skinningAttribute.getMatrixPalette(),o=0,s=0,u=n.length;s<u;s++){var c=n[s],l=c.getInvBindMatrixInSkeletonSpace(),h=c.getMatrixInSkeletonSpace();i["c"].mul(e,h,l),i["c"].mul(e,r,e),i["c"].mul(e,e,t),a[o++]=e[0],a[o++]=e[4],a[o++]=e[8],a[o++]=e[12],a[o++]=e[1],a[o++]=e[5],a[o++]=e[9],a[o++]=e[13],a[o++]=e[2],a[o++]=e[6],a[o++]=e[10],a[o++]=e[14]}}}(),update:function(e){this._isInitialized||this.init(e),this.computeMatrixPalette(e.getMatrixFromSkeletonToGeometry(),e.getInvMatrixFromSkeletonToGeometry())}};var T=x,y=r("2a3f"),C=r("c489"),A=function(){a["a"].call(this),this._shape=null,this.addUpdateCallback(new p),this._root=void 0,this._pathToRoot=void 0,this._isAnimatedPath=!1,this._boneNameID={},this._matrixFromSkeletonToGeometry=i["c"].create(),this._invMatrixFromSkeletonToGeometry=i["c"].create(),this._rigTransformImplementation=new T,this._geometry=void 0,this._stateSetAnimation=new s["a"],this._needToComputeMatrix=!0};n["a"].createPrototypeNode(A,n["a"].objectInherit(a["a"].prototype,{getStateSetAnimation:function(){return this._stateSetAnimation},getSkeleton:function(){return this._root},setSkeleton:function(e){this._root=e},setPathToSkeleton:function(e){this._pathToRoot=e,this._isAnimatedPath=y["a"].checkPathIsAnimated(e)},setNeedToComputeMatrix:function(e){this._needToComputeMatrix=e},getNeedToComputeMatrix:function(){return this._needToComputeMatrix},computeBoundingBox:function(e){e.init();var t=this.getVertexAttributeList().Vertex,r=this.getVertexAttributeList().Weights;if(t&&r&&t.getElements()&&t.getItemSize()>2){for(var n=r.getElements(),i=t.getElements(),a=t.getItemSize(),o=e.getMin(),s=e.getMax(),u=o[0],c=o[1],l=o[2],h=s[0],d=s[1],f=s[2],_=0,p=0,g=i.length;_<g;_+=a,p+=4)if(0===n[_]&&0===n[_+1]&&0===n[_+2]&&0===n[_+3]){var m=i[_],v=i[_+1],b=i[_+2];m<u&&(u=m),m>h&&(h=m),v<c&&(c=v),v>d&&(d=v),b<l&&(l=b),b>f&&(f=b)}o[0]=u,o[1]=c,o[2]=l,s[0]=h,s[1]=d,s[2]=f}return e},computeMatrixFromRootSkeleton:function(){this._root?(i["c"].identity(this._matrixFromSkeletonToGeometry),C["a"].computeLocalToWorld(this._pathToRoot,!0,this._matrixFromSkeletonToGeometry),i["c"].invert(this._invMatrixFromSkeletonToGeometry,this._matrixFromSkeletonToGeometry),this._isAnimatedPath||(this._needToComputeMatrix=!1)):o["a"].warn("Warning "+this.className()+".computeMatrixFromRootSkeleton if you have this message it means you miss to call buildTransformer( root ), or your RigGeometry ("+this.getName()+") is not attached to a Skeleton subgraph")},getMatrixFromSkeletonToGeometry:function(){return this._matrixFromSkeletonToGeometry},getInvMatrixFromSkeletonToGeometry:function(){return this._invMatrixFromSkeletonToGeometry},getSourceGeometry:function(){return this._geometry},setSourceGeometry:function(e){this._geometry=e},getBoneNameID:function(){return this._boneNameID},setBoneNameID:function(e){this._boneNameID=e},mergeChildrenVertexAttributeList:function(){this._geometry instanceof u["a"]&&this._geometry.mergeChildrenVertexAttributeList();var e=this._geometry.getVertexAttributeList();a["a"].appendVertexAttributeToList(e,this.getVertexAttributeList())},mergeChildrenData:function(){this.mergeChildrenVertexAttributeList();var e=this._geometry.getPrimitiveSetList();this.getPrimitiveSetList().length=0;for(var t=0,r=e.length;t<r;t++)this.getPrimitiveSetList()[t]=e[t];this.getStateSet()&&console.error("A stateset in the rig is already present : "+this.getStateSet()),this.setStateSet(this._geometry.getStateSet())},update:function(){this._rigTransformImplementation.update(this)},computeTransformedVertex:function(e,t){t=t||i["f"].create();var r=this.getVertexAttributeList(),n=r.Weights.getElements(),a=r.Bones.getElements(),o=0,s=0,u=0;if(this._geometry.computeTransformedVertex)this._geometry.computeTransformedVertex(e,t),o=t[0],s=t[1],u=t[2];else{var c=r.Vertex.getElements();o=c[3*e],s=c[3*e+1],u=c[3*e+2]}for(var l=4*e,h=this._rigTransformImplementation._skinningAttribute.getMatrixPalette(),d=0,f=0,_=0,p=0,g=0,m=0,v=0,b=0,S=0,x=0,T=0,y=0,C=0,A=!1,E=0;E<4;++E){var R=n[l+E];if(0!==R){var M=12*a[l+E];d+=h[M+0]*R,p+=h[M+1]*R,v+=h[M+2]*R,x+=h[M+3]*R,f+=h[M+4]*R,g+=h[M+5]*R,b+=h[M+6]*R,T+=h[M+7]*R,_+=h[M+8]*R,m+=h[M+9]*R,S+=h[M+10]*R,y+=h[M+11]*R,C+=R,A=!0}}A||(t[0]=o,t[1]=s,t[2]=u);var w=1/C;return t[0]=(d*o+p*s+v*u+x)*w,t[1]=(f*o+g*s+b*u+T)*w,t[2]=(_*o+m*s+S*u+y)*w,t},computeTransformedVertices:function(){for(var e=this.getVertexAttributeList(),t=this._geometry.computeTransformedVertices?this._geometry.computeTransformedVertices():e.Vertex.getElements(),r=e.Weights.getElements(),n=e.Bones.getElements(),i=this._riggedVerts||new Float32Array(t.length),a=this._rigTransformImplementation._skinningAttribute.getMatrixPalette(),o=0,s=0,u=t.length;o<u;o+=3,s+=4){var c,l=0,h=0,d=0,f=0,_=0,p=0,g=0,m=0,v=0,b=0,S=0,x=0,T=0,y=!1,C=r[s];0!==C&&(c=12*n[s],l+=a[c+0]*C,f+=a[c+1]*C,g+=a[c+2]*C,b+=a[c+3]*C,h+=a[c+4]*C,_+=a[c+5]*C,m+=a[c+6]*C,S+=a[c+7]*C,d+=a[c+8]*C,p+=a[c+9]*C,v+=a[c+10]*C,x+=a[c+11]*C,T+=C,y=!0),C=r[s+1],0!==C&&(c=12*n[s+1],l+=a[c+0]*C,f+=a[c+1]*C,g+=a[c+2]*C,b+=a[c+3]*C,h+=a[c+4]*C,_+=a[c+5]*C,m+=a[c+6]*C,S+=a[c+7]*C,d+=a[c+8]*C,p+=a[c+9]*C,v+=a[c+10]*C,x+=a[c+11]*C,T+=C,y=!0),C=r[s+2],0!==C&&(c=12*n[s+2],l+=a[c+0]*C,f+=a[c+1]*C,g+=a[c+2]*C,b+=a[c+3]*C,h+=a[c+4]*C,_+=a[c+5]*C,m+=a[c+6]*C,S+=a[c+7]*C,d+=a[c+8]*C,p+=a[c+9]*C,v+=a[c+10]*C,x+=a[c+11]*C,T+=C,y=!0),C=r[s+3],0!==C&&(c=12*n[s+3],l+=a[c+0]*C,f+=a[c+1]*C,g+=a[c+2]*C,b+=a[c+3]*C,h+=a[c+4]*C,_+=a[c+5]*C,m+=a[c+6]*C,S+=a[c+7]*C,d+=a[c+8]*C,p+=a[c+9]*C,v+=a[c+10]*C,x+=a[c+11]*C,T+=C,y=!0);var A=t[o],E=t[o+1],R=t[o+2];if(y){var M=1/T;i[o]=(l*A+f*E+g*R+b)*M,i[o+1]=(h*A+_*E+m*R+S)*M,i[o+2]=(d*A+p*E+v*R+x)*M}else i[o]=A,i[o+1]=E,i[o+2]=R}return i}}),"osgAnimation","RigGeometry");t["a"]=A},e8f9:function(e,t,r){"use strict";t["a"]={NO_LIMIT:0,LIMIT_ONE_PER_DRAWABLE:1,LIMIT_ONE:2,POINT_PRIMITIVES:1,LINE_PRIMITIVES:2,TRIANGLE_PRIMITIVES:4,ALL_PRIMITIVES:7}},e9a6:function(e,t,r){"use strict";var n=r("b797"),i=r("4388"),a=r("5a16"),o=r("3972"),s=function(){i["a"].call(this),this._perRangeDataList=[],this._loading=!1,this._expiryTime=0,this._expiryFrame=0,this._centerMode=i["a"].USER_DEFINED_CENTER,this._frameNumberOfLastTraversal=0,this._databasePath="",this._numChildrenThatCannotBeExpired=0},u=function(){this.filename="",this.function=void 0,this.loaded=!1,this.timeStamp=0,this.frameNumber=0,this.frameNumberOfLastTraversal=0,this.dbrequest=void 0};n["a"].createPrototypeNode(s,n["a"].objectInherit(i["a"].prototype,{setRange:function(e,t,r){if(e>=this._range.length){var n=[];n.push([t,t]),this._range.push(n)}this._range[e][0]=t,this._range[e][1]=r},setExpiryTime:function(e){this._expiryTime=e},setDatabasePath:function(e){this._databasePath=e},getDatabasePath:function(){return this._databasePath},setFileName:function(e,t){if(e>=this._perRangeDataList.length){var r=new u;r.filename=t,this._perRangeDataList.push(r)}else this._perRangeDataList[e].filename=t},setFunction:function(e,t){if(e>=this._perRangeDataList.length){var r=new u;r.function=t,this._perRangeDataList.push(r)}else this._perRangeDataList[e].function=t},addChild:function(e,t,r){i["a"].prototype.addChild.call(this,e,t,r),this._perRangeDataList.push(new u)},addChildNode:function(e){i["a"].prototype.addChildNode.call(this,e)},setFrameNumberOfLastTraversal:function(e){this._frameNumberOfLastTraversal=e},getFrameNumberOfLastTraversal:function(){return this._frameNumberOfLastTraversal},setTimeStamp:function(e,t){this._perRangeDataList[e].timeStamp=t},setFrameNumber:function(e,t){this._perRangeDataList[e].frameNumber=t},setNumChildrenThatCannotBeExpired:function(e){this._numChildrenThatCannotBeExpired=e},getNumChildrenThatCannotBeExpired:function(){return this._numChildrenThatCannotBeExpired},getDatabaseRequest:function(e){return this._perRangeDataList[e].dbrequest},removeExpiredChildren:function(e,t,r){if(!(this.children.length<=this._numChildrenThatCannotBeExpired)){var n,i,a=this.children.length-1;n=this._perRangeDataList[a].timeStamp+this._expiryTime,i=this._perRangeDataList[a].frameNumber+this._expiryFrame,n<e&&i<t&&(this._perRangeDataList[a].filename.length>0||void 0!==this._perRangeDataList[a].function)&&(r.push(this.children[a]),this.removeChild(this.children[a]),this._perRangeDataList[a].loaded=!1,void 0!==this._perRangeDataList[a].dbrequest&&(this._perRangeDataList[a].dbrequest._groupExpired=!0))}},traverse:function(){var e=o["f"].create(),t=o["f"].create(),r=o["c"].create();return function(n){var s=n.traversalMode,u=!1;switch(n.getVisitorType()===a["a"].CULL_VISITOR&&(this._frameNumberOfLastTraversal=n.getFrameStamp().getFrameNumber(),u=!0),s){case a["a"].TRAVERSE_ALL_CHILDREN:for(var c=0;c<this.children.length;c++)this.children[c].accept(n);break;case a["a"].TRAVERSE_ACTIVE_CHILDREN:var l=0,h=n.getCurrentModelViewMatrix();if(o["c"].invert(r,h),this._rangeMode===i["a"].DISTANCE_FROM_EYE_POINT){o["f"].transformMat4(t,e,r);var d=o["f"].distance(this.getBound().center(),t);l=d*n.getLODScale()}else{var f=n.getCurrentProjectionMatrix();l=this.projectBoundingSphere(this.getBound(),h,f[0]),l=l*n.getViewport().width()*n.getViewport().width()*.25/n.getLODScale(),l<0&&(l=this._range[this._range.length-1][0])}for(var _=!1,p=-1,g=0;g<this._range.length;++g)this._range[g][0]<=l&&l<this._range[g][1]&&(g<this.children.length?(u&&(this._perRangeDataList[g].timeStamp=n.getFrameStamp().getSimulationTime(),this._perRangeDataList[g].frameNumber=n.getFrameStamp().getFrameNumber()),this.children[g].accept(n),p=g):_=!0);if(_){var m=this.children.length;if(m>0&&m-1!==p&&(u&&(this._perRangeDataList[m-1].timeStamp=n.getFrameStamp().getSimulationTime(),this._perRangeDataList[m-1].frameNumber=n.getFrameStamp().getFrameNumber()),this.children[m-1].accept(n)),m<this._perRangeDataList.length){var v=(this._range[m][0]-l)/(this._range[m][1]-this._range[m][0]);this._rangeMode===i["a"].PIXEL_SIZE_ON_SCREEN&&(v=-v);var b=n.nodePath[n.nodePath.length-1];if(!1===this._perRangeDataList[m].loaded){this._perRangeDataList[m].loaded=!0;var S=n.getDatabaseRequestHandler();this._perRangeDataList[m].dbrequest=S.requestNodeFile(this._perRangeDataList[m].function,this._databasePath+this._perRangeDataList[m].filename,b,n.getFrameStamp().getSimulationTime(),v)}else void 0!==this._perRangeDataList[m].dbrequest?(this._perRangeDataList[m].dbrequest._timeStamp=n.getFrameStamp().getSimulationTime(),this._perRangeDataList[m].dbrequest._priority=v):this._perRangeDataList[m].loaded=!1}}break;default:break}}}()}),"osg","PagedLOD"),t["a"]=s},ecf1:function(e,t,r){"use strict";var n=r("a214"),i=r("b797"),a=r("3972"),o=function(){this._min=a["f"].create(),this._max=a["f"].create(),this.init()};i["a"].createPrototypeObject(o,{init:function(){a["f"].copy(this._min,a["f"].INFINITY),a["f"].copy(this._max,a["f"].NEGATIVE_INFINITY)},volume:function(){var e=this._max[0]-this._min[0];return e*=this._max[1]-this._min[1],e*=this._max[2]-this._min[2],e},copy:function(e){a["f"].copy(this._min,e._min),a["f"].copy(this._max,e._max)},valid:function(){return this._max[0]>=this._min[0]&&this._max[1]>=this._min[1]&&this._max[2]>=this._min[2]},expandByBoundingSphere:function(e){if(e.valid()){var t=this._max,r=this._min,n=e._radius,i=e._center[0],a=e._center[1],o=e._center[2];r[0]=Math.min(r[0],i-n),r[1]=Math.min(r[1],a-n),r[2]=Math.min(r[2],o-n),t[0]=Math.max(t[0],i+n),t[1]=Math.max(t[1],a+n),t[2]=Math.max(t[2],o+n)}},expandByvec3:function(e){n["a"].warn("deprecated, use expandByVec3"),this.expandByVec3(e)},expandByVec3:function(e){var t=this._min,r=this._max;t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.min(t[2],e[2]),r[0]=Math.max(r[0],e[0]),r[1]=Math.max(r[1],e[1]),r[2]=Math.max(r[2],e[2])},expandByBoundingBox:function(e){if(e.valid()){var t=this._min,r=this._max,n=e._min,i=e._max;n[0]<t[0]&&(t[0]=n[0]),i[0]>r[0]&&(r[0]=i[0]),n[1]<t[1]&&(t[1]=n[1]),i[1]>r[1]&&(r[1]=i[1]),n[2]<t[2]&&(t[2]=n[2]),i[2]>r[2]&&(r[2]=i[2])}},center:function(e){var t=this._min,r=this._max;return e[0]=.5*(t[0]+r[0]),e[1]=.5*(t[1]+r[1]),e[2]=.5*(t[2]+r[2]),e},radius:function(){return Math.sqrt(this.radius2())},radius2:function(){var e=this._min,t=this._max,r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2];return.25*(r*r+n*n+i*i)},getMin:function(){return this._min},getMax:function(){return this._max},setMin:function(e){return a["f"].copy(this._min,e),this},setMax:function(e){return a["f"].copy(this._max,e),this},xMax:function(){return this._max[0]},yMax:function(){return this._max[1]},zMax:function(){return this._max[2]},xMin:function(){return this._min[0]},yMin:function(){return this._min[1]},zMin:function(){return this._min[2]},corner:function(e,t){return t[0]=1&e?this._max[0]:this._min[0],t[1]=2&e?this._max[1]:this._min[1],t[2]=4&e?this._max[2]:this._min[2],t},transformMat4:function(){var e=a["f"].create(),t=a["f"].create();return function(r,n){var i=this.getMin(),o=this.getMax();a["c"].getTranslation(e,n),a["f"].copy(t,e);for(var s=0;s<3;++s)for(var u=4*s,c=i[s],l=o[s],h=0;h<3;++h){var d=n[u+h],f=d*l,_=d*c;f<_?(e[h]+=f,t[h]+=_):(e[h]+=_,t[h]+=f)}var p=r.getMax(),g=r.getMin();return p[0]=t[0],p[1]=t[1],p[2]=t[2],g[0]=e[0],g[1]=e[1],g[2]=e[2],r}}()},"osg","BoundingBox"),t["a"]=o},ede0:function(e,t,r){"use strict";t["a"]={RELATIVE_RF:0,ABSOLUTE_RF:1}},f3dc:function(e,t,r){"use strict";r("a9e3");var n=r("a214"),i=r("b797"),a=r("1881"),o=r("5a16"),s=r("1391"),u=r("83e3"),c=r("3972"),l=r("032c"),h=r("6ec3"),d=r("0549"),f=r("3769"),_=r("fca2"),p=r("9946"),g=r("cc9d"),m=r("c77d"),v=r("4066"),b=r("3714"),S=r("4388"),x=r("c360"),T=r("e9a6"),y=r("38f3"),C=r("ede0"),A=r("f991"),E=r("e74e"),R=r("00cd"),M=r("9874"),w=r("02b4"),N=r("1ca0"),O=function(){return new g["a"]},I=function(){return new s["a"]},P=function(){o["a"].call(this,o["a"].TRAVERSE_ACTIVE_CHILDREN),s["a"].call(this),u["a"].call(this),this._rootStateGraph=void 0,this._currentStateGraph=void 0,this._currentRenderBin=void 0,this._currentRenderStage=void 0,this._rootRenderStage=void 0,this._computedNear=Number.POSITIVE_INFINITY,this._computedFar=Number.NEGATIVE_INFINITY,this._camera=void 0,this._pooledLeaf=new N["a"](O),this._pooledRenderStages={},this._pooledCullSettings=new N["a"](I),this._renderBinStack=new w["a"],this.visitorType=o["a"].CULL_VISITOR,this._identityMatrix=c["c"].create(),this._renderer=void 0,this._renderStageType=v["a"],this._numCamera=0,this._numMatrixTransform=0,this._numProjection=0,this._numNode=0,this._numLightSource=0,this._numGeometry=0};P.registerApplyFunction=_["default"].registerApplyFunction,P.getApplyFunction=_["default"].getApplyFunction,i["a"].createPrototypeObject(P,i["a"].objectInherit(u["a"].prototype,i["a"].objectInherit(o["a"].prototype,{applyFunctionArray:_["default"].applyFunctionArray,distance:function(e,t){return-(e[0]*t[2]+e[1]*t[6]+e[2]*t[10]+t[14])},getComputedNear:function(){return this._computedNear},getComputedFar:function(){return this._computedFar},resetStats:function(){this._numCamera=0,this._numMatrixTransform=0,this._numProjection=0,this._numNode=0,this._numLightSource=0,this._numGeometry=0},handleCullCallbacksAndTraverse:function(e){var t=e.getCullCallback();t&&!t.cull(e,this)||this.traverse(e)},getCurrentCamera:function(){return this._currentRenderBin.getStage().getCamera()},updateCalculatedNearFar:function(){var e=c["f"].create(),t=c["f"].create();return function(r,n){var i,a,o=n.getBoundingBox();if(i=this.distance(o.corner(this._bbCornerNear,e),r),a=this.distance(o.corner(this._bbCornerFar,t),r),i>a){var s=i;i=a,a=s}return!(a<0)&&(i<this._computedNear&&(this._computedNear=i),a>this._computedFar&&(this._computedFar=a),!0)}}(),setStateGraph:function(e){this._rootStateGraph=e,this._currentStateGraph=e},setRenderStage:function(e){this._rootRenderStage=e,this._currentRenderBin=e},setRenderer:function(e){this._renderer=e},getRenderer:function(){return this._renderer},reset:function(){for(var e in u["a"].prototype.reset.call(this),this._pooledLeaf.reset(),this._pooledCullSettings.reset(),this._pooledRenderStages)this._pooledRenderStages[e].reset();m["a"].reset(),this._computedNear=Number.POSITIVE_INFINITY,this._computedFar=Number.NEGATIVE_INFINITY},getCurrentRenderBin:function(){return this._currentRenderBin},setCurrentRenderBin:function(e){this._currentRenderBin=e},addPositionedAttribute:function(e,t){var r=e||this._identityMatrix;this._currentRenderBin.getStage().addPositionAttribute(r,t)},pushStateSet:function(e){if(this._currentStateGraph=this._currentStateGraph.findOrInsert(e),void 0!==e.getBinName()){var t=this._renderBinStack,r=this._currentRenderBin;t.push(r),this._currentRenderBin=r.getStage().findOrInsert(e.getBinNumber(),e.getBinName())}},popStateSet:function(){var e=this._currentStateGraph,t=e.getStateSet();if(this._currentStateGraph=e.getParent(),void 0!==t.getBinName()){var r=this._renderBinStack;0===r.getLength()?this._currentRenderBin=this._currentRenderBin.getStage():this._currentRenderBin=r.pop()}},popProjectionMatrix:function(){if(!0===this._computeNearFar&&this._computedFar>=this._computedNear){var e=this.getCurrentProjectionMatrix();void 0!==this._clampProjectionMatrixCallback?this._clampProjectionMatrixCallback(e,this._computedNear,this._computedFar,this._nearFarRatio):this.clampProjectionMatrix(e,this._computedNear,this._computedFar,this._nearFarRatio)}u["a"].prototype.popProjectionMatrix.call(this)},clampProjectionMatrix:function(e,t,r,i,a){var o,s,u=1e-6;if(r<t-u)return n["a"].log("clampProjectionMatrix not applied, invalid depth range, znear = "+t+" zfar = "+r,!1,!0),!1;if(r<t+u){var c=.5*(t+r);t=c-u,r=c+u}if(Math.abs(e[3])<u&&Math.abs(e[7])<u&&Math.abs(e[11])<u){var l=.02*(r-t);l<1&&(l=1),o=t-l,s=r+l,t=o,r=s,e[10]=-2/(s-o),e[14]=-(s+o)/(s-o)}else{var h=1.02,d=.98;o=t*d,s=r*h;var f=r*i;o<f&&(o=f),t=o,r=s;var _=e[10],p=e[14],g=e[11],m=e[15],v=(-o*_+p)/(-o*g+m),b=(-s*_+p)/(-s*g+m),S=Math.abs(2/(v-b)),x=-(v+b)/2,T=x*S;e[2]=e[2]*S+e[3]*T,e[6]=e[6]*S+e[7]*T,e[10]=_*S+g*T,e[14]=p*S+m*T}return void 0!==a&&(a[0]=t,a[1]=r),!0},popCameraModelViewProjectionMatrix:function(){this.popModelViewMatrix(),this.popProjectionMatrix()},pushCameraModelViewProjectionMatrix:function(e,t,r){this.pushModelViewMatrix(t),this.pushProjectionMatrix(r)},apply:function(e){this.applyFunctionArray[e.nodeTypeID].call(this,e)},createOrReuseRenderLeaf:function(){return this._pooledLeaf.getOrCreateObject()},createOrReuseRenderStage:function(e){var t=e?e.className():"RenderStage";if(!this._pooledRenderStages[t]){var r=e?e.constructor:v["a"],n=function(){return new r(e._app)};this._pooledRenderStages[t]=new N["a"](n)}return this._pooledRenderStages[t].getOrCreateObject().init()},postPushGeometry:function(e,t){var r,n;t instanceof E["a"]?(n=t.getStateSetAnimation(),n&&e.pushStateSet(n),r=t.getSourceGeometry(),r instanceof M["a"]&&(n=r.getStateSetAnimation(),n&&e.pushStateSet(n))):t instanceof M["a"]&&(n=t.getStateSetAnimation(),n&&e.pushStateSet(n))},prePopGeometry:function(e,t){if(t instanceof E["a"]){var r=t.getSourceGeometry();r instanceof M["a"]&&r.getStateSetAnimation()&&e.popStateSet(),t.getStateSetAnimation()&&e.popStateSet()}else t instanceof M["a"]&&t.getStateSetAnimation()&&e.popStateSet()},pushLeaf:function(e,t){var r=this._currentStateGraph.getLeafs();r.getLength()||this._currentRenderBin.addStateGraph(this._currentStateGraph);var n=this.createOrReuseRenderLeaf();n.init(this._currentStateGraph,e,this.getCurrentProjectionMatrix(),this.getCurrentViewMatrix(),this.getCurrentModelViewMatrix(),this.getCurrentModelMatrix(),t),r.push(n)}})),"osg","CullVisitor");var D=function(e){this._numCamera++;var t=e.getStateSet();t&&this.pushStateSet(t);var r=this._pooledMatrix.getOrCreateObject(),n=this._pooledMatrix.getOrCreateObject();if(e.getReferenceFrame()===C["a"].RELATIVE_RF){var i=this.getCurrentProjectionMatrix();c["c"].mul(n,i,e.getProjectionMatrix());var a=this.getCurrentModelViewMatrix();c["c"].mul(r,a,e.getViewMatrix())}else c["c"].copy(r,e.getViewMatrix()),c["c"].copy(n,e.getProjectionMatrix());var o=this._computedNear,s=this._computedFar,u=this._pooledCullSettings.getOrCreateObject();if(u.reset(),u.setCullSettings(this),this._computedNear=Number.POSITIVE_INFINITY,this._computedFar=Number.NEGATIVE_INFINITY,this.setCullSettings(e),u.getSettingSourceOverrider()===this&&u.getEnableFrustumCulling()&&this.setEnableFrustumCulling(!0),this.pushCameraModelViewProjectionMatrix(e,r,n),e.getViewport()&&this.pushViewport(e.getViewport()),e.getRenderOrder()===y["a"].NESTED_RENDER)this.handleCullCallbacksAndTraverse(e);else{var l=this.getCurrentRenderBin(),h=l.getStage(),d=this.createOrReuseRenderStage(this._rootRenderStage);d.setCamera(e),d.setClearDepth(e.getClearDepth()),d.setClearColor(e.getClearColor()),d.setClearMask(e.getClearMask());var f=e.getViewport()?e.getViewport():h.getViewport(),_=e.getScissor()?e.getScissor():h.getScissor();d.setViewport(f),d.setScissor(_),this.setCurrentRenderBin(d),this.handleCullCallbacksAndTraverse(e),this.setCurrentRenderBin(l),e.getRenderOrder()===y["a"].PRE_RENDER?this.getCurrentRenderBin().getStage().addPreRenderStage(d,e.renderOrderNum):this.getCurrentRenderBin().getStage().addPostRenderStage(d,e.renderOrderNum)}this.popCameraModelViewProjectionMatrix(e),e.getViewport()&&this.popViewport(),this.setCullSettings(u),this._computedNear=o,this._computedFar=s,t&&this.popStateSet()},L=function(e){if(this._numMatrixTransform++,!this.isCulled(e,this.nodePath)){this.pushCurrentMask();var t=this._pooledMatrix.getOrCreateObject(),r=this.getCurrentModelViewMatrix();c["c"].copy(t,r),e.computeLocalToWorldMatrix(t),this.pushModelViewMatrix(t);var n=e.getStateSet();n&&this.pushStateSet(n),this.handleCullCallbacksAndTraverse(e),n&&this.popStateSet(),this.popModelViewMatrix(),this.popCurrentMask()}},F=function(e){this._numProjection++;var t=this.getCurrentProjectionMatrix(),r=this._pooledMatrix.getOrCreateObject();c["c"].mul(r,t,e.getProjectionMatrix()),this.pushProjectionMatrix(r);var n=e.getStateSet();n&&this.pushStateSet(n),this.handleCullCallbacksAndTraverse(e),n&&this.popStateSet(),this.popProjectionMatrix()},k=function(e){if(this._numNode++,!this.isCulled(e,this.nodePath)){this.pushCurrentMask();var t=e.getStateSet();t&&this.pushStateSet(t),this.handleCullCallbacksAndTraverse(e),t&&this.popStateSet(),this.popCurrentMask()}},B=function(e){this._numLightSource++;var t=e.getStateSet();t&&this.pushStateSet(t);var r=e.getLight();r&&(e.getReferenceFrame()===C["a"].RELATIVE_RF?this.addPositionedAttribute(this.getCurrentModelViewMatrix(),r):this.addPositionedAttribute(null,r)),this.handleCullCallbacksAndTraverse(e),t&&this.popStateSet()},U=c["f"].create(),V=!1,G=function(e){this._numGeometry++;var t=this.getCurrentModelViewMatrix(),r=e.getBoundingBox();if(!this._computeNearFar||!r.valid()||this.updateCalculatedNearFar(t,e)){var i=e.getCullCallback();if(!i||i.cull(e,this)){var o=e.getStateSet();o&&this.pushStateSet(o),this.postPushGeometry(this,e);var s=0;r.valid()&&(s=this.distance(r.center(U),t)),a["a"].isNaN(s)?V||(n["a"].warn("warning geometry has a NaN depth, "+t+" center "+U),V=!0):this.pushLeaf(e,s),this.prePopGeometry(this,e),o&&this.popStateSet()}}};_["default"].registerApplyFunction(b["a"].nodeTypeID,k),_["default"].registerApplyFunction(x["a"].nodeTypeID,k),_["default"].registerApplyFunction(T["a"].nodeTypeID,k),_["default"].registerApplyFunction(y["a"].nodeTypeID,D),_["default"].registerApplyFunction(l["a"].nodeTypeID,L),_["default"].registerApplyFunction(d["a"].nodeTypeID,F),_["default"].registerApplyFunction(p["a"].nodeTypeID,G),_["default"].registerApplyFunction(A["a"].nodeTypeID,L),_["default"].registerApplyFunction(R["a"].nodeTypeID,L),_["default"].registerApplyFunction(h["a"].nodeTypeID,L),_["default"].registerApplyFunction(S["a"].nodeTypeID,k),_["default"].registerApplyFunction(f["a"].nodeTypeID,B),_["default"].registerApplyFunction(E["a"].nodeTypeID,G),_["default"].registerApplyFunction(M["a"].nodeTypeID,G),t["a"]=P},f53d:function(e,t,r){"use strict";r("ac1f"),r("5319"),r("a15b"),r("466d"),r("1276"),r("498a"),r("b0c0"),r("b64b");var n=r("b797"),i=r("a214"),a=r("112b"),o=function(e,t){if(!e||!t)return"";var r;for(var n in t)r=t[n],void 0!==r&&(r.getVariable&&(r=r.getVariable()),e=e.replace("%s",r));return e},s=function(e,t){var r=e,n=[],i=t;void 0===t&&(i="");for(var a=0,o=r.length;a<o;a++){var s,u=r[a];s=void 0===u?"undefined":"string"===typeof u?u:u.getType?u.getType()+" "+u.getVariable():u.getVariable(),n.push(i+s)}return n},u=function(e,t,n){var i=r("5d7a").default,a=[],o="";if(i.debugShaderNode&&(a.push("\n// output"),Array.prototype.push.apply(a,s([t],"// "))),t&&(o=(t.getVariable?t.getVariable():t)+" = "),o=o+e+"( ",n&&n.length>0){i.debugShaderNode&&(a.push("// inputs"),Array.prototype.push.apply(a,s(n,"// ")));for(var u=0,c=n.length;u<c;u++)o+=n[u].getVariable?n[u].getVariable():n[u],u!==c-1&&(o+=", ")}return o+=" );\n",i.debugShaderNode?a.join("\n")+"\n"+o:o},c=function(e){var t=e.match(/([^\s]+):([^\s]+)/g),r={};if(!t)return r;for(var n=0;n<t.length;++n){var i=t[n].split(":");r[i[0]]=i[1]}return r},l=function(e,t){var r=t.indexOf("("),n=t.indexOf(")"),i=t.substring(0,r);i=i.replace(/[\r\n|\r|\n]/g,"").trim().replace(/\s+/g," ");var a=i.split(/\s/),o=a[0],s=a[1],u=c(e),l=u.result||"result",h=u.NODE_NAME;h||(h=s[0].toUpperCase()+s.substring(1));var d=[];u.DERIVATIVES&&d.push("#extension GL_OES_standard_derivatives : "+u.DERIVATIVES);var f,_=[],p="#define"===o;"void"!==o&&(f={name:l,type:!p&&o},_.push(f));var g=t.substring(r+1,n);g=g.replace(/[\r\n|\r|\n]/g,"");for(var m=g.split(/OPT_ARG_|,/),v=-1!==g.indexOf("OPT_ARG_"),b=[],S=[],x=0;x<m.length;++x){var T=m[x];if(T){var y=T.trim().replace(/\s+/g," ").split("[")[0],C=y.split(/\s/),A=C.length,E=A>=3&&-1!==C[A-3].indexOf("out"),R=C[A-1],M={isOutput:E,type:C[A-2],name:u[R]||R,optional:v&&-1!==g.indexOf("OPT_ARG_"+R)};S.push(M),M.optional||(E?_.push(M):b.push(M))}}return{nodeName:h,functionName:s,signature:{returnVariable:f,orderedArgs:S,outputs:_,inputs:b,extensions:d}}},h=function(e,t){var r=function(){a["a"].call(this),this._defines=[],this._extensions=[],this._missingArgs=!1};return n["a"].createPrototypeObject(r,n["a"].objectInherit(a["a"].prototype,{type:e.nodeName,signatures:[e.signature],globalDeclare:'#pragma include "'+t+'"',checkInputsOutputs:function(){},globalFunctionDeclaration:function(){return this.globalDeclare},addExtensions:function(e){return this._extensions.push.apply(this._extensions,e),this},getExtensions:function(){return this.getOrCreateSignature(),this._extensions},addDefines:function(e){return this._defines.push.apply(this._defines,e),this},getDefines:function(){return this._defines},_validateSameVariables:function(e,t){for(var r=e.length,n=0;n<r;++n)if(!t[e[n].name])return!1;return e.length===Object.keys(t).length},_validateSameType:function(e,t){for(var r=e.length,n=0;n<r;++n){var i=t[e[n].name];if(i.getType()!==e[n].type)return!1}return!0},_getSignatureBestMatch:function(){if(1===this.signatures.length)return this.signatures[0];for(var e=[],t=[],r=[],n=this.signatures.length,i=0;i<n;++i){var a=this.signatures[i];this._validateSameVariables(a.outputs,this._outputs)&&(this._validateSameVariables(a.inputs,this._inputs)&&(e.push(a),this._validateSameType(a.outputs,this._outputs)&&(t.push(a),this._validateSameType(a.inputs,this._inputs)&&r.push(a))))}return e.length?1!==e.length&&t.length?1!==t.length&&r.length?r[0]:t[0]:e[0]:this.signatures[0]},getOrCreateSignature:function(){return this._signature||(this._signature=this._getSignatureBestMatch(),this.addExtensions(this._signature.extensions)),this._signature},_typeDownCast:function(t){var r;if(t.optional){if(r=this._inputs[t.name]||this._outputs[t.name],!r)return}else r=t.isOutput?this._outputs[t.name]:this._inputs[t.name];if(!r){var n=t.isOutput?"output":"input";return i["a"].error("missing "+n+" "+t.name+" on NodeCustom "+e.nodeName),void(this._missingArgs=!0)}var a=r.getType(),o=t.type;return o&&o!==a?"vec3"===o?r.getVariable()+".rgb":"vec2"===o?r.getVariable()+".rg":"float"===o?r.getVariable()+".r":r:r},computeShader:function(){var t=this.getOrCreateSignature(),r=t.returnVariable&&t.returnVariable.name,n=r?this._outputs[r]:void 0;r&&!n&&(i["a"].error("missing output "+r+" on NodeCustom "+e.nodeName),this._missingArgs=!0);for(var a=[],o=0;o<t.orderedArgs.length;++o){var s=this._typeDownCast(t.orderedArgs[o]);s&&a.push(s)}return this._missingArgs?"":u(e.functionName,n,a)}}),"osgShader",e.nodeName),r},d={},f=function(e,t){for(var r=e[t].split(/#pragma DECLARE_FUNCTION(.*)[\r\n|\r|\n]/),n=(r.length-1)/2,i={},a=0;a<n;++a){var o=l(r[2*a+1],r[2*a+2]),s=o.nodeName,u=i[s];u?u.prototype.signatures.push(o.signature):(u=d[s],u?(u.prototype.signatures=[o.signature],u.prototype.globalDeclare='#pragma include "'+t+'"'):u=h(o,t),i[s]=u,d[s]=u)}return i};t["a"]={callFunction:u,checkVariableType:s,sprintf:o,extractFunctions:f}},f662:function(e,t,r){"use strict";r("4c53");var n=r("b797"),i=r("3972"),a=r("cfa7"),o=r("ceab"),s=function(){a["a"].call(this),this._start=i["f"].create(),this._iStart=i["f"].create(),this._end=i["f"].create(),this._iEnd=i["f"].create(),this._threshold=0,this._iThreshold=0};n["a"].createPrototypeObject(s,n["a"].objectInherit(a["a"].prototype,{set:function(e,t,r){i["f"].copy(this._start,e),i["f"].copy(this._iStart,e),i["f"].copy(this._end,t),i["f"].copy(this._iEnd,t),void 0!==r&&(this._threshold=this._iThreshold=r)},setStart:function(e){i["f"].copy(this._start,e),i["f"].copy(this._iStart,e)},setEnd:function(e){i["f"].copy(this._end,e),i["f"].copy(this._iEnd,e)},intersectNode:function(e){return this.intersectBoundingSphere(e.getBoundingSphere())},intersectBoundingSphere:function(){var e=i["f"].create(),t=i["f"].create();return function(r){if(!r.valid())return!1;i["f"].sub(e,this._iStart,r.center());var n=i["f"].sqrLen(e)-r.radius2();if(n<=0)return!0;i["f"].sub(t,this._iEnd,this._iStart);var a=i["f"].sqrLen(t),o=2*i["f"].dot(e,t),s=o*o-4*a*n;if(s<0)return!1;s=Math.sqrt(s);var u=.5/a,c=(-o-s)*u,l=(-o+s)*u;return!(c<=0&&l<=0)&&!(c>1&&l>1)}}(),intersect:function(){var e=new o["a"];return function(t,r){e.setGeometry(r),e.setIntersectionVisitor(t),e.setIntersector(this),e.set(this._iStart,this._iEnd,this._iThreshold);var n=r.getShape();n?n.intersectLineSegment(e,n.getNodes()[0],this._iStart,this._iEnd,this._iThreshold):(r.computeTransformedVertices&&e.setVertices(r.computeTransformedVertices()),e.apply(r),e.reset())}}(),setCurrentTransformation:function(e){if(i["c"].invert(e,e),this._threshold>0){var t=this._iStart;i["c"].getScale(t,e);var r=t[0],n=t[1],a=t[2];this._iThreshold=this._threshold*(r>n?r>a?r:a:n>a?n:a)}i["f"].transformMat4(this._iStart,this._start,e),i["f"].transformMat4(this._iEnd,this._end,e)}}),"osgUtil","LineSegmentIntersector"),t["a"]=s},f991:function(e,t,r){"use strict";var n=r("b797"),i=r("032c"),a=r("fbe0"),o=r("5a16"),s=r("ae6a"),u=r("00cd"),c=function(){o["a"].call(this,o["a"].TRAVERSE_ALL_CHILDREN)};n["a"].createPrototypeObject(c,n["a"].objectInherit(o["a"].prototype,{apply:function(e){if(e.getTypeID()===u["a"].getTypeID()){var t=e.getUpdateCallback();if(t instanceof s["a"]){for(var r=t._stackedTransforms,n=0,i=r.length;n<i;n++){var a=r[n];a.resetToDefaultValue()}t.computeChannels()}}this.traverse(e)}}),"osgAnimation","ResetRestPoseVisitor");var l=new c,h=function(){i["a"].call(this)};n["a"].createPrototypeNode(h,n["a"].objectInherit(i["a"].prototype,{setDefaultUpdateCallback:function(){this.addUpdateCallback(new a["a"])},setRestPose:function(){this.accept(l)}}),"osgAnimation","Skeleton"),t["a"]=h},fbe0:function(e,t,r){"use strict";r("4e82");var n=r("b797"),i=r("00cd"),a=r("5a16"),o=r("a214"),s=r("40fc"),u=function(){a["a"].call(this)};n["a"].createPrototypeObject(u,n["a"].objectInherit(a["a"].prototype,{apply:function(e){if(e.getTypeID()===i["a"].getTypeID()){for(var t=!1,r=e.getChildren(),n=0,a=e.getChildren().length;n<a;n++){var s=r[n];if(s.getTypeID()===i["a"].getTypeID()){if(t)return void o["a"].warn("Warning: a Bone was found after a non-Bone child within a Skeleton. Children of a Bone must be ordered with all child Bones first for correct update order.")}else t=!0}this.traverse(e)}}}),"osgAnimation","ValidateSkeletonVisitor");var c=function(e,t){var r=e instanceof i["a"]?0:1,n=t instanceof i["a"]?0:1;return r-n},l=function(){this._needValidate=!0};n["a"].createPrototypeObject(l,n["a"].objectInherit(s["a"].prototype,{needToValidate:function(){return this._needValidate},update:function(e,t){if(this._needValidate&&t.getVisitorType()===a["a"].UPDATE_VISITOR&&e.className&&"Skeleton"===e.className()){for(var r=new u,n=e.getChildren(),i=0,o=n.length;i<o;i++){var s=n[i];s.accept(r)}n.sort(c),this._needValidate=!1}return!0}}),"osgAnimation","UpdateSkeleton"),t["a"]=l},fca2:function(e,t,r){"use strict";r.r(t);var n=[],i=function(e,t){n[e]=t},a=function(e){return n[e]};t["default"]={applyFunctionArray:n,registerApplyFunction:i,getApplyFunction:a}},fce7:function(e,t,r){"use strict";r("d3b7"),r("cfc3"),r("907a"),r("9a8c"),r("a975"),r("735e"),r("c1ac"),r("d139"),r("3a7b"),r("d5d6"),r("82f8"),r("e91f"),r("60bd"),r("5f96"),r("3280"),r("3fcc"),r("ca91"),r("25a1"),r("cd26"),r("3c5d"),r("2954"),r("649e"),r("219c"),r("170b"),r("b39a"),r("72f7"),r("fb2c"),r("4e82"),r("fb6a");var n=r("b797"),i=r("06c5"),a=r("e74e"),o=r("2a3f"),s=r("b507"),u=r("9874"),c=function(){o["a"].call(this),this._targets=[],this._targetNames=[],this._morphs=[],this._weights=new Float32Array(u["a"].MAX_MORPH_GPU),this._indexMap=new Uint32Array(u["a"].MAX_MORPH_GPU),this._gpuMorphed=[],this._maxMorphGPU=-1},l=function(e,t){return Math.abs(t.value)-Math.abs(e.value)};n["a"].createPrototypeObject(c,n["a"].objectInherit(o["a"].prototype,{_initNode:function(e){var t;e instanceof u["a"]?t=e:e instanceof a["a"]&&e.getSourceGeometry()instanceof u["a"]&&(t=e.getSourceGeometry()),t&&t.getName()===this.getName()&&(t.isInitialized()||t.init(),this._morphs.push(t),this._maxMorphGPU=Math.min(this._maxMorphGPU,t.getMaximumPossibleMorphGPU()))},init:function(e){this._maxMorphGPU=u["a"].MAX_MORPH_GPU,this._morphs.length=0;var t=e.getChildren();if(t.length)for(var r=0,n=t.length;r<n;r++)this._initNode(t[r]);else this._initNode(e)},isInitialized:function(){var e=this._morphs,t=e.length;if(!t)return!1;for(var r=0;r<t;++r)if(!e[r].isInitialized())return!1;return!0},getNumTarget:function(){return this._targets.length},getTarget:function(e){return this._targets[e]},getTargetName:function(e){return this._targetNames[e]},addTarget:function(e,t){this._targets[t]=s["a"].createFloatTarget(0),this._targetNames[t]=e},_remapBufferArrays:function(){for(var e=this._indexMap,t=this._morphs,r=0;r<this._maxMorphGPU;++r)for(var n=e[r],i="_"+r,a="_"+n,o=0,s=t.length;o<s;++o)for(var u=t[o],c=u.getVertexAttributeList(),l=u.getMorphTargetNames(),h=0,d=l.length;h<d;++h){var f=l[h];c[f+i].setBufferArray(c[f+a].getInitialBufferArray())}},_mergeExtraMorphTarget:function(e,t,r){var n=0,a=this._gpuMorphed,o=e[t],s=o.getElements().length,c=s/o.getItemSize(),l=o.getItemSize();o._cpuMorph=o._cpuMorph||new i["a"](i["a"].ARRAY_BUFFER,new Float32Array(s),l);var h=o._cpuMorph.getElements();for(n=0;n<s;++n)h[n]=0;for(var d=this._targets,f=0,_=d.length;f<_;++f)if(!0!==a[f]){var p=d[f].value;if(!(Math.abs(p)<=u["a"].EFFECTIVE_EPS)){p/=r;var g=e[t+"_"+f].getInitialBufferArray().getElements();for(n=0;n<c;++n){var m=n*l;h[m]+=p*g[m],h[m+1]+=p*g[m+1],h[m+2]+=p*g[m+2]}}}e[t+"_"+(this._maxMorphGPU-1)].setBufferArray(o._cpuMorph),o._cpuMorph.dirty()},_computeExtraWeightsSum:function(){for(var e=this._gpuMorphed,t=0,r=this._targets,n=0,i=r.length;n<i;++n)if(!0!==e[n]){var a=r[n].value;Math.abs(a)<=u["a"].EFFECTIVE_EPS||(t+=a)}var o=1e-5;return Math.abs(t)>o?t:t<0?-o:o},_morphBufferArrayCPU:function(){for(var e=this._weights[this._maxMorphGPU-1]=this._computeExtraWeightsSum(),t={},r=this._morphs,n=0,i=r.length;n<i;++n)for(var a=r[n],o=a.getVertexAttributeList(),s=a.getMorphTargetNames(),u=0,c=s.length;u<c;++u){var l=s[u],h=o[l];h&&!t[h.getInstanceID()]&&(t[h.getInstanceID()]=!0,this._mergeExtraMorphTarget(o,l,e))}},updateWeights:function(){if(0!==this._maxMorphGPU){var e=0,t=this._targets,r=t.length,n=this._weights;if(n[0]=n[1]=n[2]=n[3]=0,r<=this._maxMorphGPU)for(e=0;e<r;++e)n[e]=t[e].value;else{var i=this._indexMap;i[0]=i[1]=i[2]=i[3]=0;var a=this._gpuMorphed;for(a.length=r,e=0;e<r;++e)a[e]=!1;var o=t.slice(0).sort(l);for(e=0;e<this._maxMorphGPU;++e){var s=t.indexOf(o[e]);a[s]=!0,i[e]=s,n[e]=o[e].value}var c=Math.abs(o[this._maxMorphGPU].value),h=c>u["a"].EFFECTIVE_EPS;a[i[this._maxMorphGPU-1]]=!h,this._remapBufferArrays(),h&&this._morphBufferArrayCPU()}}},reset:function(){for(var e=this._targets,t=0,r=e.length;t<r;++t)e[t].value=e[t].defaultValue},update:function(e){this.isInitialized()||this.init(e),this.updateWeights();for(var t=this._weights,r=Math.min(this._maxMorphGPU,this._targets.length),n=this._morphs,i=0,a=n.length;i<a;++i)for(var o=n[i].getTargetsWeight(),s=0;s<r;s++)o[s]=t[s];return!0}}),"osgAnimation","UpdateMorph"),t["a"]=c}});
- //# sourceMappingURL=index.bc94f35d.js.map
|