(function(e){function t(t){for(var n,o,s=t[0],u=t[1],c=t[2],h=0,d=[];hl?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=cd?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(o65535?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;_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]=ne._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(xm)--T;if(xo&&(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;a0&&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=0&&r=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=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;n0))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=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=0&&r=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;rn[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;l1?i-1:0),o=1;o= 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()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;eMath.PI&&(e-=Ae,r-=Ae),r<-Math.PI&&(e+=Ae,r+=Ae)),0===t){var a=!1;a=n>i?ri:ri,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=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;nthis._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=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=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;n0?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;ig?qe.redColor:p:0!==m&&(p=_=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=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;at&&(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=0&&n._priority0?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=0?n[i]=a:n.action=i.toLowerCase()}if(n.action)for(t=0;t1&&(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=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=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=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=this._valueThreshold&&this._fireCallbacks(o,h)}}var d=this._callbacks["axis"];if(d)for(s=0;s=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=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=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;r0)&&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 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=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;r0){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;ir&&(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=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;ri[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;r0?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;NE&&(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=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=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;ts?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;s2?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;s0){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;e0&&-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;e1?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;n0&&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=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=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;a0)break;i=r.draw(e,i)}i=this.drawLeafs(e,i);for(var c=s.currentPass===Za.OPAQUE_SHADING;u0&&(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;l0&&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<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;l0){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;a0),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.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;g1&&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=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;r0&&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=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--;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--;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--;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--;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--;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--;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;r0&&(u%=o.duration),r(u+o.firstKeyTime,a)}},_removeFinishedAnimation:function(e){var t=this._activeAnimationList,r=0;while(rn.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.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=0&&(this._timerOutline=setTimeout(this._cbHideOutline,this._durationOutline)),this._uHighlightFactor.setFloat(0!==this._durationHighlight?.15:0),this._clearTimeoutHighlight(),this._durationHighlight>=0&&this._durationHighlight=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;i0),!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;e0&&(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;rEc){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;rt*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;re)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.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;t0&&(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;i1&&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;at?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;o0){var d,f,_;if(this._minimumScale>0){var p=this._minimumScale,g=this._maximumScale0?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;a1&&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(!(re?"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;i1){u=new Ar["a"];for(var c=0;c1){for(var f=new Ar["a"],_=0;_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;n1){u=new Ar["a"];for(var c=0;c1){for(var f=new Ar["a"],_=0;_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;r0&&--t,e>0&&++t,0!==t)for(var r=this._parents,n=0,i=r.length;n0||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;n0||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;r0){var t=0;if(this._cullingActive||--t,e||++t,0!==t)for(var r=0,n=this._parents.length;r0){var t=0;if(this._numChildrenWithCullingDisabled>0&&--t,e>0&&++t,0!==t)for(var r=0,n=this._parents.length;r0},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;_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=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;s0&&(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;u1},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;t1&&n){for(var u=!1,c=n.map((function(e){return i._defineR.test(e)&&e.replace(/\s+/g," ").split(" ")[1]})),l=1;l=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'+e+""},t='This page requires a browser that supports WebGL.
Click here to upgrade your browser.',r='It doesn\'t appear your computer can support WebGL.
Click here for more information.',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+="

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=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;t0&&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._maximumScale0?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;s0)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;rr?(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._maxAnisotropy0)for(var n=0,i=r;n0&&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;a0||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;it)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;tthis._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=0&&r=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;ia?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;u2){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;dc&&(c=_),pl&&(l=p),gh&&(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;a0){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=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=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=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;er||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=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)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=0&&r=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 %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;t0){this.sortDeclarations(i);var o=i[0][0];for(r=0;rthis._values.length?this._values.push(t):this._values[this.children.length-1]=t,!0},setValue:function(e,t){e=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;h0)break;r=l.draw(e,r)}for(r=this.drawLeafs(e,r);hu._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]c)return!1;t[0]c&&i["f"].scaleAndAdd(r,t,d,c-t[0])}else{if(t[0]c)return!1;r[0]c&&i["f"].scaleAndAdd(t,t,d,c-t[0])}if(t[1]<=r[1]){if(r[1]l)return!1;t[1]l&&i["f"].scaleAndAdd(r,t,f,l-t[1])}else{if(t[1]l)return!1;r[1]l&&i["f"].scaleAndAdd(t,t,f,l-t[1])}if(t[2]<=r[2]){if(r[2]h)return!1;t[2]h&&i["f"].scaleAndAdd(r,t,_,h-t[2])}else{if(t[2]h)return!1;r[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;bS&&(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)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&&g1)){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(!(Sthis._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;ir)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;nn?i:n,h=0;h=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;o0)for(var i=0,a=n.length;i 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+="",r+="",r+="",r+="",r+="",r+="",r+="",r+="",r+="",r+="",r+="",r+="",r+="",r+="",r+="",r+="
"+t[0]+""+t[4]+""+t[8]+""+t[12]+"
"+t[1]+""+t[5]+""+t[9]+""+t[13]+"
"+t[2]+""+t[6]+""+t[10]+""+t[14]+"
"+t[3]+""+t[7]+""+t[11]+""+t[15]+"
",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+="

"+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"),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'

'+e+'

'+t+"
"},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(''),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;s2){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;_h&&(h=m),vd&&(d=v),bf&&(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=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,n0||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;c0&&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._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]r[0]&&(r[0]=i[0]),n[1]r[1]&&(r[1]=i[1]),n[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)&&(ithis._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(r0){i.debugShaderNode&&(a.push("// inputs"),Array.prototype.push.apply(a,s(n,"// ")));for(var u=0,c=n.length;u=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;n1&&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;no?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;nu["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