jahresbericht2018/assets/js/libpannellum.js

1 line
21 KiB
JavaScript

"use strict";window.libpannellum=function(e,t,r){function a(a){var l,d,c,f,g,_,m,v,E,x,p,T,R,w,M,A,b=t.createElement("canvas");function I(e,t){return 1==e.level&&1!=t.level?-1:1==t.level&&1!=e.level?1:t.timestamp-e.timestamp}function C(e,t){return e.level!=t.level?e.level-t.level:e.diff-t.diff}function U(e,t,r,a,i,o){this.vertices=e,this.side=t,this.level=r,this.x=a,this.y=i,this.path=o.replace("%s",t).replace("%l",r).replace("%x",a).replace("%y",i)}function P(e,t,r,a,i){if(function(e,t){var r=S(e,t.slice(0,3)),a=S(e,t.slice(3,6)),i=S(e,t.slice(6,9)),o=S(e,t.slice(9,12)),n=r[0]+a[0]+i[0]+o[0];if(-4==n||4==n)return!1;var h=r[1]+a[1]+i[1]+o[1];return-4!=h&&4!=h&&r[2]+a[2]+i[2]+o[2]!=4}(e,t.vertices)){var o=t.vertices,n=o[0]+o[3]+o[6]+o[9],h=o[1]+o[4]+o[7]+o[10],s=o[2]+o[5]+o[8]+o[11],u=Math.sqrt(n*n+h*h+s*s),d=Math.asin(s/u),c=Math.atan2(h,n)-a;c+=c>Math.PI?-2*Math.PI:c<-Math.PI?2*Math.PI:0,c=Math.abs(c),t.diff=Math.acos(Math.sin(r)*Math.sin(d)+Math.cos(r)*Math.cos(d)*Math.cos(c));for(var f=!1,g=0;g<l.nodeCache.length;g++)if(l.nodeCache[g].path==t.path){f=!0,l.nodeCache[g].timestamp=l.nodeCacheTimestamp++,l.nodeCache[g].diff=t.diff,l.currentNodes.push(l.nodeCache[g]);break}if(f||(t.timestamp=l.nodeCacheTimestamp++,l.currentNodes.push(t),l.nodeCache.push(t)),t.level<l.level){var _=E.cubeResolution*Math.pow(2,t.level-E.maxLevel),m=Math.ceil(_*E.invTileResolution)-1,v=_%E.tileResolution*2,x=2*_%E.tileResolution;0===x&&(x=E.tileResolution),0===v&&(v=2*E.tileResolution);var p=.5;t.x!=m&&t.y!=m||(p=1-E.tileResolution/(E.tileResolution+x));var T,R=1-p,w=[],M=p,A=p,b=p,I=R,C=R,B=R;x<E.tileResolution&&(t.x==m&&t.y!=m?(A=.5,C=.5,"d"!=t.side&&"u"!=t.side||(b=.5,B=.5)):t.x!=m&&t.y==m&&(M=.5,I=.5,"l"!=t.side&&"r"!=t.side||(b=.5,B=.5))),v<=E.tileResolution&&(t.x==m&&(M=0,I=1,"l"!=t.side&&"r"!=t.side||(b=0,B=1)),t.y==m&&(A=0,C=1,"d"!=t.side&&"u"!=t.side||(b=0,B=1))),T=new U([o[0],o[1],o[2],o[0]*M+o[3]*I,o[1]*p+o[4]*R,o[2]*b+o[5]*B,o[0]*M+o[6]*I,o[1]*A+o[7]*C,o[2]*b+o[8]*B,o[0]*p+o[9]*R,o[1]*A+o[10]*C,o[2]*b+o[11]*B],t.side,t.level+1,2*t.x,2*t.y,E.fullpath),w.push(T),t.x==m&&v<=E.tileResolution||(T=new U([o[0]*M+o[3]*I,o[1]*p+o[4]*R,o[2]*b+o[5]*B,o[3],o[4],o[5],o[3]*p+o[6]*R,o[4]*A+o[7]*C,o[5]*b+o[8]*B,o[0]*M+o[6]*I,o[1]*A+o[7]*C,o[2]*b+o[8]*B],t.side,t.level+1,2*t.x+1,2*t.y,E.fullpath),w.push(T)),t.x==m&&v<=E.tileResolution||t.y==m&&v<=E.tileResolution||(T=new U([o[0]*M+o[6]*I,o[1]*A+o[7]*C,o[2]*b+o[8]*B,o[3]*p+o[6]*R,o[4]*A+o[7]*C,o[5]*b+o[8]*B,o[6],o[7],o[8],o[9]*M+o[6]*I,o[10]*p+o[7]*R,o[11]*b+o[8]*B],t.side,t.level+1,2*t.x+1,2*t.y+1,E.fullpath),w.push(T)),t.y==m&&v<=E.tileResolution||(T=new U([o[0]*p+o[9]*R,o[1]*A+o[10]*C,o[2]*b+o[11]*B,o[0]*M+o[6]*I,o[1]*A+o[7]*C,o[2]*b+o[8]*B,o[9]*M+o[6]*I,o[10]*p+o[7]*R,o[11]*b+o[8]*B,o[9],o[10],o[11]],t.side,t.level+1,2*t.x,2*t.y+1,E.fullpath),w.push(T));for(var L=0;L<w.length;L++)P(e,w[L],r,a,i)}}}function B(e,t,r){var a=Math.sin(t),i=Math.cos(t);return"x"==r?[e[0],i*e[1]+a*e[2],i*e[2]-a*e[1],e[3],i*e[4]+a*e[5],i*e[5]-a*e[4],e[6],i*e[7]+a*e[8],i*e[8]-a*e[7]]:"y"==r?[i*e[0]-a*e[2],e[1],i*e[2]+a*e[0],i*e[3]-a*e[5],e[4],i*e[5]+a*e[3],i*e[6]-a*e[8],e[7],i*e[8]+a*e[6]]:"z"==r?[i*e[0]+a*e[1],i*e[1]-a*e[0],e[2],i*e[3]+a*e[4],i*e[4]-a*e[3],e[5],i*e[6]+a*e[7],i*e[7]-a*e[6],e[8]]:void 0}function L(e){return[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]]}b.style.width=b.style.height="100%",a.appendChild(b),this.init=function(e,I,C,U,P,B,L,D){if(I===r&&(I="equirectangular"),"equirectangular"!=I&&"cubemap"!=I&&"multires"!=I)throw console.log("Error: invalid image type specified!"),{type:"config error"};if(x=I,E=e,p=C,A=D||{},l){if(c&&(d.detachShader(l,c),d.deleteShader(c)),f&&(d.detachShader(l,f),d.deleteShader(f)),d.bindBuffer(d.ARRAY_BUFFER,null),d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,null),l.texture&&d.deleteTexture(l.texture),l.nodeCache)for(var N=0;N<l.nodeCache.length;N++)d.deleteTexture(l.nodeCache[N].texture);d.deleteProgram(l),l=r}var y;v=r;var S,F=!1;if("cubemap"==x)for(y=0;y<6;y++)E[y].width>0?(S===r&&(S=E[y].width),S!=E[y].width&&console.log("Cube faces have inconsistent widths: "+S+" vs. "+E[y].width)):F=!0;function X(e){if(F){var t=e*e*4,r=new Uint8ClampedArray(t),a=D.backgroundColor?D.backgroundColor:[0,0,0];a[0]*=255,a[1]*=255,a[2]*=255;for(var i=0;i<t;i++)r[i++]=a[0],r[i++]=a[1],r[i++]=a[2];var o=new ImageData(r,e,e);for(y=0;y<6;y++)0==E[y].width&&(E[y]=o)}}if("cubemap"==x&&0!=(S&S-1)&&(navigator.userAgent.toLowerCase().match(/(iphone|ipod|ipad).* os 8_/)||navigator.userAgent.toLowerCase().match(/(iphone|ipod|ipad).* os 9_/)||navigator.userAgent.toLowerCase().match(/(iphone|ipod|ipad).* os 10_/)||navigator.userAgent.match(/Trident.*rv[ :]*11\./))||(d||(d=b.getContext("experimental-webgl",{alpha:!1,depth:!1})),d&&1286==d.getError()&&G()),!d&&("multires"==x&&E.hasOwnProperty("fallbackPath")||"cubemap"==x)&&("WebkitAppearance"in t.documentElement.style||navigator.userAgent.match(/Trident.*rv[ :]*11\./)||-1!==navigator.appVersion.indexOf("MSIE 10"))){var O;_&&a.removeChild(_),(_=t.createElement("div")).className="pnlm-world",O=E.basePath?E.basePath+E.fallbackPath:E.fallbackPath;var Y=["f","r","b","l","u","d"],W=0,k=function(){var e=t.createElement("canvas");e.className="pnlm-face pnlm-"+Y[this.side]+"face",_.appendChild(e);var r=e.getContext("2d");e.style.width=this.width+4+"px",e.style.height=this.height+4+"px",e.width=this.width+4,e.height=this.height+4,r.drawImage(this,2,2);var a,i,o=r.getImageData(0,0,e.width,e.height),n=o.data;for(a=2;a<e.width-2;a++)for(i=0;i<4;i++)n[4*(a+e.width)+i]=n[4*(a+2*e.width)+i],n[4*(a+e.width*(e.height-2))+i]=n[4*(a+e.width*(e.height-3))+i];for(a=2;a<e.height-2;a++)for(i=0;i<4;i++)n[4*(a*e.width+1)+i]=n[4*(a*e.width+2)+i],n[4*((a+1)*e.width-2)+i]=n[4*((a+1)*e.width-3)+i];for(i=0;i<4;i++)n[4*(e.width+1)+i]=n[4*(2*e.width+2)+i],n[4*(2*e.width-2)+i]=n[4*(3*e.width-3)+i],n[4*(e.width*(e.height-2)+1)+i]=n[4*(e.width*(e.height-3)+2)+i],n[4*(e.width*(e.height-1)-2)+i]=n[4*(e.width*(e.height-2)-3)+i];for(a=1;a<e.width-1;a++)for(i=0;i<4;i++)n[4*a+i]=n[4*(a+e.width)+i],n[4*(a+e.width*(e.height-1))+i]=n[4*(a+e.width*(e.height-2))+i];for(a=1;a<e.height-1;a++)for(i=0;i<4;i++)n[a*e.width*4+i]=n[4*(a*e.width+1)+i],n[4*((a+1)*e.width-1)+i]=n[4*((a+1)*e.width-2)+i];for(i=0;i<4;i++)n[i]=n[4*(e.width+1)+i],n[4*(e.width-1)+i]=n[4*(2*e.width-2)+i],n[e.width*(e.height-1)*4+i]=n[4*(e.width*(e.height-2)+1)+i],n[4*(e.width*e.height-1)+i]=n[4*(e.width*(e.height-1)-2)+i];r.putImageData(o,0,0),z.call(this)},z=function(){this.width>0?(g===r&&(g=this.width),g!=this.width&&console.log("Fallback faces have inconsistent widths: "+g+" vs. "+this.width)):F=!0,6==++W&&(g=this.width,a.appendChild(_),L())};for(F=!1,y=0;y<6;y++){var H=new Image;H.crossOrigin=A.crossOrigin?A.crossOrigin:"anonymous",H.side=y,H.onload=k,H.onerror=z,H.src="multires"==x?encodeURI(O.replace("%s",Y[y])+"."+E.extension):encodeURI(E[y].src)}X(g)}else{if(!d)throw console.log("Error: no WebGL support detected!"),{type:"no webgl"};"cubemap"==x&&X(S),E.basePath?E.fullpath=E.basePath+E.path:E.fullpath=E.path,E.invTileResolution=1/E.tileResolution;var q=[-1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,-1,1,1,1,1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,1,1,-1,1,1,1,1,-1,1,1,-1,-1];for(m=[],y=0;y<6;y++)m[y]=q.slice(12*y,12*y+12),q=[-1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,-1,1,1,1,1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,1,1,-1,1,1,1,1,-1,1,1,-1,-1];var V=0;if("equirectangular"==x){if(V=d.getParameter(d.MAX_TEXTURE_SIZE),Math.max(E.width/2,E.height)>V)throw console.log("Error: The image is too big; it's "+E.width+"px wide, but this device's maximum supported size is "+2*V+"px."),{type:"webgl size error",width:E.width,maxWidth:2*V}}else if("cubemap"==x&&S>d.getParameter(d.MAX_CUBE_MAP_TEXTURE_SIZE))throw console.log("Error: The image is too big; it's "+width+"px wide, but this device's maximum supported size is "+V+"px."),{type:"webgl size error",width:width,maxWidth:V};D===r||D.horizonPitch===r&&D.horizonRoll===r||(v=[D.horizonPitch==r?0:D.horizonPitch,D.horizonRoll==r?0:D.horizonRoll]);var j=d.TEXTURE_2D;if(d.viewport(0,0,d.drawingBufferWidth,d.drawingBufferHeight),d.getShaderPrecisionFormat){var Z=d.getShaderPrecisionFormat(d.FRAGMENT_SHADER,d.HIGH_FLOAT);Z&&Z.precision<1&&(n=n.replace("highp","mediump"))}c=d.createShader(d.VERTEX_SHADER);var K=i;"multires"==x&&(K=o),d.shaderSource(c,K),d.compileShader(c),f=d.createShader(d.FRAGMENT_SHADER);var J=s;"cubemap"==x?(j=d.TEXTURE_CUBE_MAP,J=h):"multires"==x&&(J=u),d.shaderSource(f,J),d.compileShader(f),l=d.createProgram(),d.attachShader(l,c),d.attachShader(l,f),d.linkProgram(l),d.getShaderParameter(c,d.COMPILE_STATUS)||console.log(d.getShaderInfoLog(c)),d.getShaderParameter(f,d.COMPILE_STATUS)||console.log(d.getShaderInfoLog(f)),d.getProgramParameter(l,d.LINK_STATUS)||console.log(d.getProgramInfoLog(l)),d.useProgram(l),l.drawInProgress=!1;var Q=D.backgroundColor?D.backgroundColor:[0,0,0];if(d.clearColor(Q[0],Q[1],Q[2],1),d.clear(d.COLOR_BUFFER_BIT),l.texCoordLocation=d.getAttribLocation(l,"a_texCoord"),d.enableVertexAttribArray(l.texCoordLocation),"multires"!=x){if(T||(T=d.createBuffer()),d.bindBuffer(d.ARRAY_BUFFER,T),d.bufferData(d.ARRAY_BUFFER,new Float32Array([-1,1,1,1,1,-1,-1,1,1,-1,-1,-1]),d.STATIC_DRAW),d.vertexAttribPointer(l.texCoordLocation,2,d.FLOAT,!1,0,0),l.aspectRatio=d.getUniformLocation(l,"u_aspectRatio"),d.uniform1f(l.aspectRatio,d.drawingBufferWidth/d.drawingBufferHeight),l.psi=d.getUniformLocation(l,"u_psi"),l.theta=d.getUniformLocation(l,"u_theta"),l.f=d.getUniformLocation(l,"u_f"),l.h=d.getUniformLocation(l,"u_h"),l.v=d.getUniformLocation(l,"u_v"),l.vo=d.getUniformLocation(l,"u_vo"),l.rot=d.getUniformLocation(l,"u_rot"),d.uniform1f(l.h,U/(2*Math.PI)),d.uniform1f(l.v,P/Math.PI),d.uniform1f(l.vo,B/Math.PI*2),"equirectangular"==x&&(l.backgroundColor=d.getUniformLocation(l,"u_backgroundColor"),d.uniform4fv(l.backgroundColor,Q.concat([1]))),l.texture=d.createTexture(),d.bindTexture(j,l.texture),"cubemap"==x)d.texImage2D(d.TEXTURE_CUBE_MAP_POSITIVE_X,0,d.RGB,d.RGB,d.UNSIGNED_BYTE,E[1]),d.texImage2D(d.TEXTURE_CUBE_MAP_NEGATIVE_X,0,d.RGB,d.RGB,d.UNSIGNED_BYTE,E[3]),d.texImage2D(d.TEXTURE_CUBE_MAP_POSITIVE_Y,0,d.RGB,d.RGB,d.UNSIGNED_BYTE,E[4]),d.texImage2D(d.TEXTURE_CUBE_MAP_NEGATIVE_Y,0,d.RGB,d.RGB,d.UNSIGNED_BYTE,E[5]),d.texImage2D(d.TEXTURE_CUBE_MAP_POSITIVE_Z,0,d.RGB,d.RGB,d.UNSIGNED_BYTE,E[0]),d.texImage2D(d.TEXTURE_CUBE_MAP_NEGATIVE_Z,0,d.RGB,d.RGB,d.UNSIGNED_BYTE,E[2]);else if(E.width<=V)d.uniform1i(d.getUniformLocation(l,"u_splitImage"),0),d.texImage2D(j,0,d.RGB,d.RGB,d.UNSIGNED_BYTE,E);else{d.uniform1i(d.getUniformLocation(l,"u_splitImage"),1);var $=t.createElement("canvas");$.width=E.width,$.height=E.height;var ee=$.getContext("2d");ee.drawImage(E,0,0);var te=ee.getImageData(0,0,E.width/2,E.height);d.texImage2D(j,0,d.RGB,d.RGB,d.UNSIGNED_BYTE,te),l.texture2=d.createTexture(),d.activeTexture(d.TEXTURE1),d.bindTexture(j,l.texture2),d.uniform1i(d.getUniformLocation(l,"u_image1"),1),te=ee.getImageData(E.width/2,0,E.width/2,E.height),d.texImage2D(j,0,d.RGB,d.RGB,d.UNSIGNED_BYTE,te),d.texParameteri(j,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE),d.texParameteri(j,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE),d.texParameteri(j,d.TEXTURE_MIN_FILTER,d.LINEAR),d.texParameteri(j,d.TEXTURE_MAG_FILTER,d.LINEAR),d.activeTexture(d.TEXTURE0)}d.texParameteri(j,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE),d.texParameteri(j,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE),d.texParameteri(j,d.TEXTURE_MIN_FILTER,d.LINEAR),d.texParameteri(j,d.TEXTURE_MAG_FILTER,d.LINEAR)}else l.vertPosLocation=d.getAttribLocation(l,"a_vertCoord"),d.enableVertexAttribArray(l.vertPosLocation),R||(R=d.createBuffer()),w||(w=d.createBuffer()),M||(M=d.createBuffer()),d.bindBuffer(d.ARRAY_BUFFER,w),d.bufferData(d.ARRAY_BUFFER,new Float32Array([0,0,1,0,1,1,0,1]),d.STATIC_DRAW),d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,M),d.bufferData(d.ELEMENT_ARRAY_BUFFER,new Uint16Array([0,1,2,0,2,3]),d.STATIC_DRAW),l.perspUniform=d.getUniformLocation(l,"u_perspMatrix"),l.cubeUniform=d.getUniformLocation(l,"u_cubeMatrix"),l.level=-1,l.currentNodes=[],l.nodeCache=[],l.nodeCacheTimestamp=0;var re=d.getError();if(0!==re)throw console.log("Error: Something went wrong with WebGL!",re),{type:"webgl error"};L()}},this.destroy=function(){if(a!==r&&(b!==r&&a.contains(b)&&a.removeChild(b),_!==r&&a.contains(_)&&a.removeChild(_)),d){var e=d.getExtension("WEBGL_lose_context");e&&e.loseContext()}},this.resize=function(){var t=e.devicePixelRatio||1;b.width=b.clientWidth*t,b.height=b.clientHeight*t,d&&(1286==d.getError()&&G(),d.viewport(0,0,d.drawingBufferWidth,d.drawingBufferHeight),"multires"!=x&&d.uniform1f(l.aspectRatio,b.clientWidth/b.clientHeight))},this.resize(),this.setPose=function(e,t){v=[e,t]},this.render=function(e,t,a,i){var o,n,h=0;if(i===r&&(i={}),i.roll&&(h=i.roll),v!==r){var s=v[0],u=v[1],c=e,f=t,T=Math.cos(u)*Math.sin(e)*Math.sin(s)+Math.cos(e)*(Math.cos(s)*Math.cos(t)+Math.sin(u)*Math.sin(s)*Math.sin(t)),M=-Math.sin(e)*Math.sin(u)+Math.cos(e)*Math.cos(u)*Math.sin(t),A=Math.cos(u)*Math.cos(s)*Math.sin(e)+Math.cos(e)*(-Math.cos(t)*Math.sin(s)+Math.cos(s)*Math.sin(u)*Math.sin(t));e=Math.asin(Math.max(Math.min(A,1),-1)),t=Math.atan2(M,T);var N=[Math.cos(c)*(Math.sin(u)*Math.sin(s)*Math.cos(f)-Math.cos(s)*Math.sin(f)),Math.cos(c)*Math.cos(u)*Math.cos(f),Math.cos(c)*(Math.cos(s)*Math.sin(u)*Math.cos(f)+Math.sin(f)*Math.sin(s))],S=[-Math.cos(e)*Math.sin(t),Math.cos(e)*Math.cos(t)],G=Math.acos(Math.max(Math.min((N[0]*S[0]+N[1]*S[1])/(Math.sqrt(N[0]*N[0]+N[1]*N[1]+N[2]*N[2])*Math.sqrt(S[0]*S[0]+S[1]*S[1])),1),-1));N[2]<0&&(G=2*Math.PI-G),h+=G}if(d||"multires"!=x&&"cubemap"!=x){if("multires"!=x){var F=2*Math.atan(Math.tan(.5*a)/(d.drawingBufferWidth/d.drawingBufferHeight));o=1/Math.tan(.5*F),d.uniform1f(l.psi,t),d.uniform1f(l.theta,e),d.uniform1f(l.rot,h),d.uniform1f(l.f,o),!0===p&&"equirectangular"==x&&(d.bindTexture(d.TEXTURE_2D,l.texture),d.texImage2D(d.TEXTURE_2D,0,d.RGB,d.RGB,d.UNSIGNED_BYTE,E)),d.drawArrays(d.TRIANGLES,0,6)}else{var X=function(e,t,r,a){var i=2*Math.atan(Math.tan(e/2)*d.drawingBufferHeight/d.drawingBufferWidth),o=1/Math.tan(i/2);return[o/t,0,0,0,0,o,0,0,0,0,(a+r)/(r-a),2*a*r/(r-a),0,0,-1,0]}(a,d.drawingBufferWidth/d.drawingBufferHeight,.1,100);!function(e){var t=1;for(;t<E.maxLevel&&d.drawingBufferWidth>E.tileResolution*Math.pow(2,t-1)*Math.tan(e/2)*.707;)t++;l.level=t}(a);var O=[1,0,0,0,1,0,0,0,1];O=B(O=B(O=B(O,-h,"z"),-e,"x"),t,"y"),O=[(j=O)[0],j[1],j[2],0,j[3],j[4],j[5],0,j[6],j[7],j[8],0,0,0,0,1],d.uniformMatrix4fv(l.perspUniform,!1,new Float32Array(L(X))),d.uniformMatrix4fv(l.cubeUniform,!1,new Float32Array(L(O)));var Y=(V=O,[(q=X)[0]*V[0],q[0]*V[1],q[0]*V[2],0,q[5]*V[4],q[5]*V[5],q[5]*V[6],0,q[10]*V[8],q[10]*V[9],q[10]*V[10],q[11],-V[8],-V[9],-V[10],0]);if(l.nodeCache.sort(I),l.nodeCache.length>200&&l.nodeCache.length>l.currentNodes.length+50)for(var W=l.nodeCache.splice(200,l.nodeCache.length-200),k=0;k<W.length;k++)d.deleteTexture(W[k].texture);l.currentNodes=[];var z=["f","b","u","d","l","r"];for(n=0;n<6;n++){P(Y,new U(m[n],z[n],1,0,0,E.fullpath),e,t,a)}for(l.currentNodes.sort(C),k=D.length-1;k>=0;k--)-1===l.currentNodes.indexOf(D[k].node)&&(D[k].node.textureLoad=!1,D.splice(k,1));if(0===D.length)for(k=0;k<l.currentNodes.length;k++){var H=l.currentNodes[k];if(!H.texture&&!H.textureLoad){H.textureLoad=!0,setTimeout(y,0,H);break}}!function(){if(!l.drawInProgress){l.drawInProgress=!0,d.clear(d.COLOR_BUFFER_BIT);for(var e=0;e<l.currentNodes.length;e++)l.currentNodes[e].textureLoaded>1&&(d.bindBuffer(d.ARRAY_BUFFER,R),d.bufferData(d.ARRAY_BUFFER,new Float32Array(l.currentNodes[e].vertices),d.STATIC_DRAW),d.vertexAttribPointer(l.vertPosLocation,3,d.FLOAT,!1,0,0),d.bindBuffer(d.ARRAY_BUFFER,w),d.vertexAttribPointer(l.texCoordLocation,2,d.FLOAT,!1,0,0),d.bindTexture(d.TEXTURE_2D,l.currentNodes[e].texture),d.drawElements(d.TRIANGLES,6,d.UNSIGNED_SHORT,0));l.drawInProgress=!1}}()}var q,V,j;if(i.returnImage!==r)return b.toDataURL("image/png")}else{var Z={f:"translate3d(-"+((n=g/2)+2)+"px, -"+(n+2)+"px, -"+n+"px)",b:"translate3d("+(n+2)+"px, -"+(n+2)+"px, "+n+"px) rotateX(180deg) rotateZ(180deg)",u:"translate3d(-"+(n+2)+"px, -"+n+"px, "+(n+2)+"px) rotateX(270deg)",d:"translate3d(-"+(n+2)+"px, "+n+"px, -"+(n+2)+"px) rotateX(90deg)",l:"translate3d(-"+n+"px, -"+(n+2)+"px, "+(n+2)+"px) rotateX(180deg) rotateY(90deg) rotateZ(180deg)",r:"translate3d("+n+"px, -"+(n+2)+"px, -"+(n+2)+"px) rotateY(270deg)"},K=(o=1/Math.tan(a/2))*b.clientWidth/2+"px",J="perspective("+K+") translateZ("+K+") rotateX("+e+"rad) rotateY("+t+"rad) ",Q=Object.keys(Z);for(k=0;k<6;k++){var $=_.querySelector(".pnlm-"+Q[k]+"face");$&&($.style.webkitTransform=J+Z[Q[k]],$.style.transform=J+Z[Q[k]])}}},this.isLoading=function(){if(d&&"multires"==x)for(var e=0;e<l.currentNodes.length;e++)if(!l.currentNodes[e].textureLoaded)return!0;return!1},this.getCanvas=function(){return b};var D=[],N=function(){var e,t=4,r={};function a(){var a=this;this.texture=this.callback=null,this.image=new Image,this.image.crossOrigin=e||"anonymous";var i=function(){var e,i;a.image.width>0&&a.image.height>0?(e=a.image,i=a.texture,d.bindTexture(d.TEXTURE_2D,i),d.texImage2D(d.TEXTURE_2D,0,d.RGB,d.RGB,d.UNSIGNED_BYTE,e),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,d.LINEAR),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,d.LINEAR),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE),d.bindTexture(d.TEXTURE_2D,null),a.callback(a.texture,!0)):a.callback(a.texture,!1),function(e){if(D.length){var a=D.shift();e.loadTexture(a.src,a.texture,a.callback)}else r[t++]=e}(a)};this.image.addEventListener("load",i),this.image.addEventListener("error",i)}a.prototype.loadTexture=function(e,t,r){this.texture=t,this.callback=r,this.image.src=e};for(var i=0;i<t;i++)r[i]=new a;return function(a,i,o,n){e=n;var h=d.createTexture();return t?r[--t].loadTexture(i,h,o):D.push(new function(e,t,r,a){this.node=e,this.src=t,this.texture=r,this.callback=a}(a,i,h,o)),h}}();function y(e){N(e,encodeURI(e.path+"."+E.extension),function(t,r){e.texture=t,e.textureLoaded=r?2:1},A.crossOrigin)}function S(e,t){var r=function(e,t){return[e[0]*t[0]+e[1]*t[1]+e[2]*t[2],e[4]*t[0]+e[5]*t[1]+e[6]*t[2],e[11]+e[8]*t[0]+e[9]*t[1]+e[10]*t[2],1/(e[12]*t[0]+e[13]*t[1]+e[14]*t[2])]}(e,t),a=r[0]*r[3],i=r[1]*r[3],o=r[2]*r[3],n=[0,0,0];return a<-1&&(n[0]=-1),a>1&&(n[0]=1),i<-1&&(n[1]=-1),i>1&&(n[1]=1),(o<-1||o>1)&&(n[2]=1),n}function G(){console.log("Reducing canvas size due to error 1286!"),b.width=Math.round(b.width/2),b.height=Math.round(b.height/2)}}var i=["attribute vec2 a_texCoord;","varying vec2 v_texCoord;","void main() {","gl_Position = vec4(a_texCoord, 0.0, 1.0);","v_texCoord = a_texCoord;","}"].join(""),o=["attribute vec3 a_vertCoord;","attribute vec2 a_texCoord;","uniform mat4 u_cubeMatrix;","uniform mat4 u_perspMatrix;","varying mediump vec2 v_texCoord;","void main(void) {","gl_Position = u_perspMatrix * u_cubeMatrix * vec4(a_vertCoord, 1.0);","v_texCoord = a_texCoord;","}"].join(""),n=["precision highp float;","uniform float u_aspectRatio;","uniform float u_psi;","uniform float u_theta;","uniform float u_f;","uniform float u_h;","uniform float u_v;","uniform float u_vo;","uniform float u_rot;","const float PI = 3.14159265358979323846264;","uniform sampler2D u_image0;","uniform sampler2D u_image1;","uniform bool u_splitImage;","uniform samplerCube u_imageCube;","varying vec2 v_texCoord;","uniform vec4 u_backgroundColor;","void main() {","float x = v_texCoord.x * u_aspectRatio;","float y = v_texCoord.y;","float sinrot = sin(u_rot);","float cosrot = cos(u_rot);","float rot_x = x * cosrot - y * sinrot;","float rot_y = x * sinrot + y * cosrot;","float sintheta = sin(u_theta);","float costheta = cos(u_theta);","float a = u_f * costheta - rot_y * sintheta;","float root = sqrt(rot_x * rot_x + a * a);","float lambda = atan(rot_x / root, a / root) + u_psi;","float phi = atan((rot_y * costheta + u_f * sintheta) / root);"].join("\n"),h=n+["float cosphi = cos(phi);","gl_FragColor = textureCube(u_imageCube, vec3(cosphi*sin(lambda), sin(phi), cosphi*cos(lambda)));","}"].join("\n"),s=n+["lambda = mod(lambda + PI, PI * 2.0) - PI;","vec2 coord = vec2(lambda / PI, phi / (PI / 2.0));","if(coord.x < -u_h || coord.x > u_h || coord.y < -u_v + u_vo || coord.y > u_v + u_vo)","gl_FragColor = u_backgroundColor;","else {","if(u_splitImage) {","if(coord.x < 0.0)","gl_FragColor = texture2D(u_image0, vec2((coord.x + u_h) / u_h, (-coord.y + u_v + u_vo) / (u_v * 2.0)));","else","gl_FragColor = texture2D(u_image1, vec2((coord.x + u_h) / u_h - 1.0, (-coord.y + u_v + u_vo) / (u_v * 2.0)));","} else {","gl_FragColor = texture2D(u_image0, vec2((coord.x + u_h) / (u_h * 2.0), (-coord.y + u_v + u_vo) / (u_v * 2.0)));","}","}","}"].join("\n"),u=["varying mediump vec2 v_texCoord;","uniform sampler2D u_sampler;","void main(void) {","gl_FragColor = texture2D(u_sampler, v_texCoord);","}"].join("");return{renderer:function(e,t,r,i){return new a(e,t,r,i)}}}(window,document);