>>8&255;m[n++]=l&255;m[n++]=l>>>8&255;if(B)m.set(f,n),n+=f.length,m=m.subarray(0,n);else{s=0;for(p=f.length;sz)for(;0z?z:138,D>z-3&&D=D?(I[G++]=17,I[G++]=D-3,M[17]++):(I[G++]=18,I[G++]=D-11,M[18]++),z-=D;else if(I[G++]=J[w],M[J[w]]++,z--,3>z)for(;0z?z:6,D>z-3&&DC;C++)wa[C]=oa[pb[C]];for(Z=19;4=a:return[265,a-11,1];case 14>=a:return[266,a-13,1];case 16>=a:return[267,a-15,1];case 18>=a:return[268,a-17,1];case 22>=a:return[269,a-19,2];case 26>=a:return[270,a-23,2];case 30>=a:return[271,a-27,2];case 34>=a:return[272,a-31,2];case 42>=a:return[273,a-35,3];case 50>=a:return[274,a-43,3];case 58>=a:return[275,a-51,3];case 66>=a:return[276,a-59,3];case 82>=a:return[277,a-67,4];case 98>=a:return[278,a-83,4];case 114>=a:return[279,a-99,4];case 130>=a:return[280,a-115,4];case 162>=a:return[281,a-131,5];case 194>=a:return[282,a-163,5];case 226>=a:return[283,a-195,5];case 257>=a:return[284,a-227,5];case 258===a:return[285,a-258,0];default:q("invalid length: "+a)}}var a=[],c,d;for(c=3;258>=c;c++)d=b(c),a[c]=d[2]<<24|d[1]<<16|d[0];return a}(),Aa=B?new Uint32Array(ya):ya;function ta(b,a){function c(a,c){var b=a.Q,d=[],e=0,f;f=Aa[a.length];d[e++]=f&65535;d[e++]=f>>16&255;d[e++]=f>>24;var g;switch(u){case 1===b:g=[0,b-1,0];break;case 2===b:g=[1,b-2,0];break;case 3===b:g=[2,b-3,0];break;case 4===b:g=[3,b-4,0];break;case 6>=b:g=[4,b-5,1];break;case 8>=b:g=[5,b-7,1];break;case 12>=b:g=[6,b-9,2];break;case 16>=b:g=[7,b-13,2];break;case 24>=b:g=[8,b-17,3];break;case 32>=b:g=[9,b-25,3];break;case 48>=b:g=[10,b-33,4];break;case 64>=b:g=[11,b-49,4];break;case 96>=b:g=[12,b-
+65,5];break;case 128>=b:g=[13,b-97,5];break;case 192>=b:g=[14,b-129,6];break;case 256>=b:g=[15,b-193,6];break;case 384>=b:g=[16,b-257,7];break;case 512>=b:g=[17,b-385,7];break;case 768>=b:g=[18,b-513,8];break;case 1024>=b:g=[19,b-769,8];break;case 1536>=b:g=[20,b-1025,9];break;case 2048>=b:g=[21,b-1537,9];break;case 3072>=b:g=[22,b-2049,10];break;case 4096>=b:g=[23,b-3073,10];break;case 6144>=b:g=[24,b-4097,11];break;case 8192>=b:g=[25,b-6145,11];break;case 12288>=b:g=[26,b-8193,12];break;case 16384>=b:g=[27,b-12289,12];break;case 24576>=b:g=[28,b-16385,13];break;case 32768>=b:g=[29,b-24577,13];break;default:q("invalid distance")}f=g;d[e++]=f[0];d[e++]=f[1];d[e++]=f[2];var h,k;h=0;for(k=d.length;h=f;)v[f++]=0;for(f=0;29>=f;)x[f++]=0}v[256]=1;d=0;for(e=a.length;d=e){p&&c(p,-1);f=0;for(g=e-d;fg&&a+gf&&(e=d,f=g);if(258===g)break}return new xa(f,a-e)}
+function ua(b,a){var c=b.length,d=new la(572),e=new(B?Uint8Array:Array)(c),f,g,k,h,l;if(!B)for(h=0;h2*e[n-1]+f[n]&&(e[n]=2*e[n-1]+f[n]),k[n]=Array(e[n]),h[n]=Array(e[n]);for(m=0;mb[m]?(k[n][r]=v,h[n][r]=a,x+=2):(k[n][r]=b[m],h[n][r]=m,++m);l[n]=0;1===f[n]&&d(n)}return g}
+function va(b){var a=new(B?Uint16Array:Array)(b.length),c=[],d=[],e=0,f,g,k,h;f=0;for(g=b.length;f>>=1}return a};function Da(b,a){this.input=b;this.b=this.c=0;this.i={};a&&(a.flags&&(this.i=a.flags),"string"===typeof a.filename&&(this.filename=a.filename),"string"===typeof a.comment&&(this.A=a.comment),a.deflateOptions&&(this.l=a.deflateOptions));this.l||(this.l={})}
+Da.prototype.g=function(){var b,a,c,d,e,f,g,k,h=new(B?Uint8Array:Array)(32768),l=0,s=this.input,p=this.c,m=this.filename,n=this.A;h[l++]=31;h[l++]=139;h[l++]=8;b=0;this.i.fname&&(b|=Ea);this.i.fcomment&&(b|=Fa);this.i.fhcrc&&(b|=Ga);h[l++]=b;a=(Date.now?Date.now():+new Date)/1E3|0;h[l++]=a&255;h[l++]=a>>>8&255;h[l++]=a>>>16&255;h[l++]=a>>>24&255;h[l++]=0;h[l++]=Ha;if(this.i.fname!==t){g=0;for(k=m.length;g>>8&255),h[l++]=f&255;h[l++]=0}if(this.i.comment){g=0;for(k=n.length;g>>8&255),h[l++]=f&255;h[l++]=0}this.i.fhcrc&&(c=ja(h,0,l)&65535,h[l++]=c&255,h[l++]=c>>>8&255);this.l.outputBuffer=h;this.l.outputIndex=l;e=new na(s,this.l);h=e.g();l=e.b;B&&(l+8>h.buffer.byteLength?(this.a=new Uint8Array(l+8),this.a.set(new Uint8Array(h.buffer)),h=this.a):h=new Uint8Array(h.buffer));d=ja(s,t,t);h[l++]=d&255;h[l++]=d>>>8&255;h[l++]=d>>>16&255;h[l++]=d>>>24&255;k=s.length;h[l++]=k&255;h[l++]=k>>>8&255;h[l++]=k>>>16&255;h[l++]=k>>>24&255;this.c=p;B&&l>>=1;switch(b){case 0:var a=this.input,c=this.c,d=this.a,e=this.b,f=a.length,g=t,k=t,h=d.length,l=t;this.e=this.j=0;c+1>=f&&q(Error("invalid uncompressed block header: LEN"));g=a[c++]|a[c++]<<8;c+1>=f&&q(Error("invalid uncompressed block header: NLEN"));k=a[c++]|a[c++]<<8;g===~k&&q(Error("invalid uncompressed block header: length verify"));c+g>a.length&&q(Error("input buffer is broken"));switch(this.r){case Ja:for(;e+g>d.length;){l=h-e;g-=l;if(B)d.set(a.subarray(c,c+l),e),e+=l,c+=l;else for(;l--;)d[e++]=a[c++];this.b=e;d=this.f();e=this.b}break;case Ia:for(;e+g>d.length;)d=this.f({F:2});break;default:q(Error("invalid inflate mode"))}if(B)d.set(a.subarray(c,c+g),e),e+=g,c+=g;else for(;g--;)d[e++]=a[c++];this.c=c;this.b=e;this.a=d;break;case 1:this.s(Za,$a);break;case 2:ab(this);break;default:q(Error("unknown BTYPE: "+b))}}return this.B()};var bb=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],cb=B?new Uint16Array(bb):bb,db=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258],eb=B?new Uint16Array(db):db,fb=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0],gb=B?new Uint8Array(fb):fb,hb=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],ib=B?new Uint16Array(hb):hb,jb=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],kb=B?new Uint8Array(jb):jb,lb=new(B?Uint8Array:Array)(288),V,mb;V=0;for(mb=lb.length;V=V?8:255>=V?9:279>=V?7:8;var Za=ma(lb),nb=new(B?Uint8Array:Array)(30),ob,qb;ob=0;for(qb=nb.length;ob=g&&q(Error("input buffer is broken")),c|=e[f++]<>>a;b.e=d-a;b.c=f;return k}
+function rb(b,a){for(var c=b.j,d=b.e,e=b.input,f=b.c,g=e.length,k=a[0],h=a[1],l,s;d=g);)c|=e[f++]<>>16;b.j=c>>s;b.e=d-s;b.c=f;return l&65535}
+function ab(b){function a(a,b,c){var d,e=this.J,f,g;for(g=0;gf)d>=e&&(this.b=d,c=this.f(),d=this.b),c[d++]=f;else{g=f-257;h=eb[g];0=e&&(this.b=d,c=this.f(),d=this.b);for(;h--;)c[d]=c[d++-k]}for(;8<=this.e;)this.e-=8,this.c--;this.b=d};T.prototype.T=function(b,a){var c=this.a,d=this.b;this.C=b;for(var e=c.length,f,g,k,h;256!==(f=rb(this,b));)if(256>f)d>=e&&(c=this.f(),e=c.length),c[d++]=f;else{g=f-257;h=eb[g];0e&&(c=this.f(),e=c.length);for(;h--;)c[d]=c[d++-k]}for(;8<=this.e;)this.e-=8,this.c--;this.b=d};T.prototype.f=function(){var b=new(B?Uint8Array:Array)(this.b-32768),a=this.b-32768,c,d,e=this.a;if(B)b.set(e.subarray(32768,b.length));else{c=0;for(d=b.length;cc;++c)e[c]=e[a+c];this.b=32768;return e};T.prototype.U=function(b){var a,c=this.input.length/this.c+1|0,d,e,f,g=this.input,k=this.a;b&&("number"===typeof b.F&&(c=b.F),"number"===typeof b.P&&(c+=b.P));2>c?(d=(g.length-this.c)/this.C[2],f=258*(d/2)|0,e=fa&&(this.a.length=a),b=this.a);return this.buffer=b};function sb(b){this.input=b;this.c=0;this.t=[];this.D=!1}sb.prototype.X=function(){this.D||this.h();return this.t.slice()};sb.prototype.h=function(){for(var b=this.input.length;this.c>>0;ja(e,t,t)!==s&&q(Error("invalid CRC-32 checksum: 0x"+ja(e,t,t).toString(16)+" / 0x"+s.toString(16)));a.da=c=(p[m++]|p[m++]<<8|p[m++]<<16|p[m++]<<24)>>>0;(e.length&4294967295)!==c&&q(Error("invalid input size: "+(e.length&4294967295)+" / "+c));this.t.push(a);this.c=m}this.D=u;var n=this.t,r,v,x=0,Q=0,y;r=0;for(v=n.length;r>>0;b=a}for(var e=1,f=0,g=b.length,k,h=0;0>>0};function ub(b,a){var c,d;this.input=b;this.c=0;if(a||!(a={}))a.index&&(this.c=a.index),a.verify&&(this.$=a.verify);c=b[this.c++];d=b[this.c++];switch(c&15){case vb:this.method=vb;break;default:q(Error("unsupported compression method"))}0!==((c<<8)+d)%31&&q(Error("invalid fcheck flag:"+((c<<8)+d)%31));d&32&&q(Error("fdict flag is not supported"));this.L=new T(b,{index:this.c,bufferSize:a.bufferSize,bufferType:a.bufferType,resize:a.resize})}
+ub.prototype.h=function(){var b=this.input,a,c;a=this.L.h();this.c=this.L.c;this.$&&(c=(b[this.c++]<<24|b[this.c++]<<16|b[this.c++]<<8|b[this.c++])>>>0,c!==tb(a)&&q(Error("invalid adler-32 checksum")));return a};var vb=8;function wb(b,a){this.input=b;this.a=new(B?Uint8Array:Array)(32768);this.k=W.o;var c={},d;if((a||!(a={}))&&"number"===typeof a.compressionType)this.k=a.compressionType;for(d in a)c[d]=a[d];c.outputBuffer=this.a;this.K=new na(this.input,c)}var W=ra;wb.prototype.g=function(){var b,a,c,d,e,f,g,k=0;g=this.a;b=vb;switch(b){case vb:a=Math.LOG2E*Math.log(32768)-8;break;default:q(Error("invalid compression method"))}c=a<<4|b;g[k++]=c;switch(b){case vb:switch(this.k){case W.NONE:e=0;break;case W.v:e=1;break;case W.o:e=2;break;default:q(Error("unsupported compression type"))}break;default:q(Error("invalid compression method"))}d=e<<6|0;g[k++]=d|31-(256*c+d)%31;f=tb(this.input);this.K.b=k;g=this.K.g();k=g.length;B&&(g=new Uint8Array(g.buffer),g.length<=k+4&&(this.a=new Uint8Array(g.length+4),this.a.set(g),g=this.a),g=g.subarray(0,k+4));g[k++]=f>>24&255;g[k++]=f>>16&255;g[k++]=f>>8&255;g[k++]=f&255;return g};function xb(b,a){var c,d,e,f;if(Object.keys)c=Object.keys(a);else for(d in c=[],e=0,a)c[e++]=d;e=0;for(f=c.length;e0){this.scene=this.readScene(response,this.header);this.body=this.readBody(response,this.header);}
+this._mesh={};};x3dom.glTF.glTFLoader.prototype.getScene=function(shape,shaderProgram,gl,sceneName)
+{this.reset(shape,gl);if(sceneName==null)
+{sceneName=this.scene["scene"];}
+var scene=this.scene.scenes[sceneName];this.updateScene(shape,shaderProgram,gl,scene);};x3dom.glTF.glTFLoader.prototype.getMesh=function(shape,shaderProgram,gl,meshName)
+{this.reset(shape,gl);var mesh;if(meshName==null)
+{mesh=Object.keys(this.scene.meshes)[0];}else
+{for(var key in this.scene.meshes){if(this.scene.meshes.hasOwnProperty(key)&&key==meshName)
+{mesh=this.scene.meshes[key];break;}}}
+this.updateMesh(shape,shaderProgram,gl,mesh);};x3dom.glTF.glTFLoader.prototype.reset=function(shape,gl)
+{this._mesh._numCoords=0;this._mesh._numFaces=0;shape._webgl.externalGeometry=-1;if(this.loaded.bufferViews==null)
+this.loaded.bufferViews=this.loadBufferViews(shape,gl);};x3dom.glTF.glTFLoader.prototype.updateScene=function(shape,shaderProgram,gl,scene)
+{var nodes=scene["nodes"];for(var i=0;i0)
+for(var i=0;i-1);this.backend=this.x3dElem.getAttribute('backend');this.backend=(this.backend)?this.backend.toLowerCase():'none';this.canvas=this._createHTMLCanvas(x3dElem);this.canvas.parent=this;this.gl=this._initContext(this.canvas,(this.backend.search("desktop")>=0),(this.backend.search("mobile")>=0),(this.backend.search("flashie")>=0),(this.backend.search("webgl2")>=0));this.backend='webgl';if(this.gl==null)
+{this.hasRuntime=false;this._createInitFailedDiv(x3dElem);return;}
+x3dom.caps.BACKEND=this.backend;var runtimeEnabled=x3dElem.getAttribute("runtimeEnabled");if(runtimeEnabled!==null)
+{this.hasRuntime=(runtimeEnabled.toLowerCase()=="true");}
+else
+{this.hasRuntime=x3dElem.hasRuntime;}
+this.showStat=x3dElem.getAttribute("showStat");this.stateViewer=new x3dom.States(x3dElem);if(this.showStat!==null&&this.showStat=="true")
+{this.stateViewer.display(true);}
+this.x3dElem.appendChild(this.stateViewer.viewer);this.showProgress=x3dElem.getAttribute("showProgress");this.progressDiv=this._createProgressDiv();this.progressDiv.style.display=(this.showProgress!==null&&this.showProgress=="true")?"inline":"none";this.x3dElem.appendChild(this.progressDiv);this.showTouchpoints=x3dElem.getAttribute("showTouchpoints");this.showTouchpoints=this.showTouchpoints?this.showTouchpoints:false;this.disableTouch=x3dElem.getAttribute("disableTouch");this.disableTouch=this.disableTouch?(this.disableTouch.toLowerCase()=="true"):false;this.disableKeys=x3dElem.getAttribute("keysEnabled");this.disableKeys=this.disableKeys?(this.disableKeys.toLowerCase()=="true"):false;this.disableRightDrag=x3dElem.getAttribute("disableRightDrag");this.disableRightDrag=this.disableRightDrag?(this.disableRightDrag.toLowerCase()=="true"):false;this.disableLeftDrag=x3dElem.getAttribute("disableLeftDrag");this.disableLeftDrag=this.disableLeftDrag?(this.disableLeftDrag.toLowerCase()=="true"):false;this.disableMiddleDrag=x3dElem.getAttribute("disableMiddleDrag");this.disableMiddleDrag=this.disableMiddleDrag?(this.disableMiddleDrag.toLowerCase()=="true"):false;this.bindEventListeners();};x3dom.X3DCanvas.prototype.bindEventListeners=function(){var that=this;this.onMouseDown=function(evt){if(!this.isMulti){this.focus();this.classList.add('x3dom-canvas-mousedown');switch(evt.button){case 0:this.mouse_button=1;break;case 1:this.mouse_button=4;break;case 2:this.mouse_button=2;break;default:this.mouse_button=0;break;}
+if(evt.shiftKey){this.mouse_button=1;}
+if(evt.ctrlKey){this.mouse_button=4;}
+if(evt.altKey){this.mouse_button=2;}
+var pos=this.parent.mousePosition(evt);this.mouse_drag_x=pos.x;this.mouse_drag_y=pos.y;this.mouse_dragging=true;this.parent.doc.onMousePress(that.gl,this.mouse_drag_x,this.mouse_drag_y,this.mouse_button);this.parent.doc.needRender=true;}}
+this.onMouseUp=function(evt){if(!this.isMulti){var prev_mouse_button=this.mouse_button;this.classList.remove('x3dom-canvas-mousedown');this.mouse_button=0;this.mouse_dragging=false;this.parent.doc.onMouseRelease(that.gl,this.mouse_drag_x,this.mouse_drag_y,this.mouse_button,prev_mouse_button);this.parent.doc.needRender=true;}}
+this.onMouseOver=function(evt){if(!this.isMulti){this.mouse_button=0;this.mouse_dragging=false;this.parent.doc.onMouseOver(that.gl,this.mouse_drag_x,this.mouse_drag_y,this.mouse_button);this.parent.doc.needRender=true;}}
+this.onMouseAlt=function(evt){if(!this.isMulti){this.mouse_button=0;this.mouse_dragging=false;this.classList.remove('x3dom-canvas-mousedown');this.parent.doc.onMouseOut(that.gl,this.mouse_drag_x,this.mouse_drag_y,this.mouse_button);this.parent.doc.needRender=true;}}
+this.onDoubleClick=function(evt){if(!this.isMulti){this.mouse_button=0;var pos=this.parent.mousePosition(evt);this.mouse_drag_x=pos.x;this.mouse_drag_y=pos.y;this.mouse_dragging=false;this.parent.doc.onDoubleClick(that.gl,this.mouse_drag_x,this.mouse_drag_y);this.parent.doc.needRender=true;}}
+this.onMouseMove=function(evt){if(!this.isMulti){var pos=this.parent.mousePosition(evt);if(pos.x!=that.lastMousePos.x||pos.y!=that.lastMousePos.y){that.lastMousePos=pos;if(evt.shiftKey){this.mouse_button=1;}
+if(evt.ctrlKey){this.mouse_button=4;}
+if(evt.altKey){this.mouse_button=2;}
+this.mouse_drag_x=pos.x;this.mouse_drag_y=pos.y;if(this.mouse_dragging){if(this.mouse_button==1&&!this.parent.disableLeftDrag||this.mouse_button==2&&!this.parent.disableRightDrag||this.mouse_button==4&&!this.parent.disableMiddleDrag)
+{this.parent.doc.onDrag(that.gl,this.mouse_drag_x,this.mouse_drag_y,this.mouse_button);}}
+else{this.parent.doc.onMove(that.gl,this.mouse_drag_x,this.mouse_drag_y,this.mouse_button);}
+this.parent.doc.needRender=true;evt.preventDefault();evt.stopPropagation();}}}
+this.onDOMMouseScroll=function(evt){if(!this.isMulti){this.focus();var originalY=this.parent.mousePosition(evt).y;this.mouse_drag_y+=2*evt.detail;this.parent.doc.onWheel(that.gl,this.mouse_drag_x,this.mouse_drag_y,originalY);this.parent.doc.needRender=true;evt.preventDefault();evt.stopPropagation();}}
+this.onKeyPress=function(evt){if(!this.parent.disableKeys){this.parent.doc.onKeyPress(evt.charCode);}
+this.parent.doc.needRender=true;}
+this.onMouseWheel=function(evt){if(!this.isMulti){this.focus();var originalY=this.parent.mousePosition(evt).y;this.mouse_drag_y-=0.1*evt.wheelDelta;this.parent.doc.onWheel(that.gl,this.mouse_drag_x,this.mouse_drag_y,originalY);this.parent.doc.needRender=true;evt.preventDefault();evt.stopPropagation();}}
+this.onKeyUp=function(evt){if(!this.parent.disableKeys){this.parent.doc.onKeyUp(evt.keyCode);}
+this.parent.doc.needRender=true;}
+this.onKeyDown=function(evt){if(!this.parent.disableKeys){this.parent.doc.onKeyDown(evt.keyCode);}
+this.parent.doc.needRender=true;}
+if(this.canvas!==null&&this.gl!==null&&this.hasRuntime){this.canvas.mouse_dragging=false;this.canvas.mouse_button=0;this.canvas.mouse_drag_x=0;this.canvas.mouse_drag_y=0;this.canvas.isMulti=false;this.canvas.oncontextmenu=function(evt){evt.preventDefault();evt.stopPropagation();return false;};this.canvas.addEventListener("webglcontextlost",function(event){x3dom.debug.logError("WebGL context lost");event.preventDefault();},false);this.canvas.addEventListener("webglcontextrestored",function(event){x3dom.debug.logError("recover WebGL state and resources on context lost NYI");event.preventDefault();},false);this.canvas.addEventListener('mousedown',this.onMouseDown,false);this.canvas.addEventListener('mouseup',this.onMouseUp,false);this.canvas.addEventListener('mouseover',this.onMouseOver,false);this.canvas.addEventListener('mouseout',this.onMouseOut,false);this.canvas.addEventListener('dblclick',this.onDoubleClick,false);this.canvas.addEventListener('mousemove',this.onMouseMove,false);this.canvas.addEventListener('DOMMouseScroll',this.onDOMMouseScroll,false);this.canvas.addEventListener('mousewheel',this.onMouseWheel,false);this.canvas.addEventListener('keypress',this.onKeyPress,true);this.canvas.addEventListener('keyup',this.onKeyUp,true);this.canvas.addEventListener('keydown',this.onKeyDown,true);var touches={numTouches:0,firstTouchTime:new Date().getTime(),firstTouchPoint:new x3dom.fields.SFVec2f(0,0),lastPos:new x3dom.fields.SFVec2f(),lastDrag:new x3dom.fields.SFVec2f(),lastMiddle:new x3dom.fields.SFVec2f(),lastSquareDistance:0,lastAngle:0,lastLayer:[],examineNavType:1,calcAngle:function(vector)
+{var rotation=vector.normalize().dot(new x3dom.fields.SFVec2f(1,0));rotation=Math.acos(rotation);if(vector.y<0)
+rotation=Math.PI+(Math.PI-rotation);return rotation;},disableTouch:this.disableTouch,visMarker:this.showTouchpoints,visMarkerBag:[],visualizeTouches:function(evt)
+{if(!this.visMarker)
+return;var touchBag=[];var marker=null;for(var i=0;i=0){marker=document.getElementById("visMarker"+id);marker.style.left=(evt.touches[i].pageX)+"px";marker.style.top=(evt.touches[i].pageY)+"px";}
+else{marker=document.createElement("div");marker.appendChild(document.createTextNode("#"+id));marker.id="visMarker"+id;marker.className="x3dom-touch-marker";document.body.appendChild(marker);index=this.visMarkerBag.length;this.visMarkerBag[index]=id;}
+touchBag.push(id);}
+for(var j=this.visMarkerBag.length-1;j>=0;j--){var oldId=this.visMarkerBag[j];if(touchBag.indexOf(oldId)<0){this.visMarkerBag.splice(j,1);marker=document.getElementById("visMarker"+oldId);document.body.removeChild(marker);}}}};var touchStartHandler=function(evt,doc)
+{this.isMulti=true;evt.preventDefault();touches.visualizeTouches(evt);this.focus();if(doc==null)
+doc=this.parent.doc;var navi=doc._scene.getNavigationInfo();switch(navi.getType()){case"examine":touches.examineNavType=1;break;case"turntable":touches.examineNavType=2;break;default:touches.examineNavType=0;break;}
+touches.lastLayer=[];var i,pos;for(i=0;i=2){touches.numTouches=2;var touch0=new x3dom.fields.SFVec2f(evt.touches[0].screenX,evt.touches[0].screenY);var touch1=new x3dom.fields.SFVec2f(evt.touches[1].screenX,evt.touches[1].screenY);var distance=touch1.subtract(touch0);var middle=distance.multiply(0.5).add(touch0);var squareDistance=distance.dot(distance);touches.lastMiddle=middle;touches.lastSquareDistance=squareDistance;touches.lastAngle=touches.calcAngle(distance);touches.lastPos=this.parent.mousePosition(evt.touches[0]);}
+doc._scene.updateVolume();if(touches.examineNavType==1){for(i=0;i=2){touch0=new x3dom.fields.SFVec2f(evt.touches[0].screenX,evt.touches[0].screenY);touch1=new x3dom.fields.SFVec2f(evt.touches[1].screenX,evt.touches[1].screenY);distance=touch1.subtract(touch0);middle=distance.multiply(0.5).add(touch0);squareDistance=distance.dot(distance);deltaMiddle=middle.subtract(touches.lastMiddle);deltaZoom=squareDistance-touches.lastSquareDistance;deltaMove=new x3dom.fields.SFVec3f(deltaMiddle.x/screen.width,-deltaMiddle.y/screen.height,deltaZoom/(screen.width*screen.height*0.2));var rotation=touches.calcAngle(distance);var angleDelta=touches.lastAngle-rotation;touches.lastAngle=rotation;rotMatrix=x3dom.fields.SFMatrix4f.rotationZ(angleDelta);touches.lastMiddle=middle;touches.lastSquareDistance=squareDistance;doc.onMoveView(that.gl,evt,touches,deltaMove,rotMatrix);}}
+else if(evt.touches.length){if(touches.examineNavType==2&&evt.touches.length>=2){touch0=new x3dom.fields.SFVec2f(evt.touches[0].screenX,evt.touches[0].screenY);touch1=new x3dom.fields.SFVec2f(evt.touches[1].screenX,evt.touches[1].screenY);distance=touch1.subtract(touch0);squareDistance=distance.dot(distance);deltaZoom=(squareDistance-touches.lastSquareDistance)/(0.1*(screen.width+screen.height));touches.lastPos.y+=deltaZoom;touches.lastSquareDistance=squareDistance;doc.onDrag(that.gl,touches.lastPos.x,touches.lastPos.y,2);}
+else{pos=this.parent.mousePosition(evt.touches[0]);doc.onDrag(that.gl,pos.x,pos.y,1);}}
+doc.needRender=true;};var touchEndHandler=function(evt,doc)
+{this.isMulti=false;evt.preventDefault();touches.visualizeTouches(evt);if(doc==null)
+doc=this.parent.doc;doc._viewarea._isMoving=false;if(touches.numTouches==2&&evt.touches.length==1)
+touches.lastDrag=new x3dom.fields.SFVec2f(evt.touches[0].screenX,evt.touches[0].screenY);var dblClick=false;if(evt.touches.length<2){if(touches.numTouches==1)
+dblClick=true;touches.numTouches=evt.touches.length;}
+if(touches.examineNavType==1){for(var i=0;i=0){x3dom.debug.logWarning("The width attribute is to be specified in pixels not in percent.");}
+canvas.style.width=w;canvas.setAttribute("width",w);}
+if((h=x3dElem.getAttribute("height"))!==null){if(h.indexOf("%")>=0){x3dom.debug.logWarning("The height attribute is to be specified in pixels not in percent.");}
+canvas.style.height=h;canvas.setAttribute("height",h);}
+canvas.setAttribute("tabindex","0");return canvas;};x3dom.X3DCanvas.prototype._watchForResize=function(){var new_dim=[parseInt(x3dom.getStyle(this.canvas,"width")),parseInt(x3dom.getStyle(this.canvas,"height"))];if((this._current_dim[0]!=new_dim[0])||(this._current_dim[1]!=new_dim[1])){this._current_dim=new_dim;this.x3dElem.setAttribute("width",new_dim[0]+"px");this.x3dElem.setAttribute("height",new_dim[1]+"px");}};x3dom.X3DCanvas.prototype._createProgressDiv=function(){var progressDiv=document.createElement('div');progressDiv.setAttribute("class","x3dom-progress");var _text=document.createElement('strong');_text.appendChild(document.createTextNode('Loading...'));progressDiv.appendChild(_text);var _inner=document.createElement('span');_inner.setAttribute('style',"width: 25%;");_inner.appendChild(document.createTextNode(' '));progressDiv.appendChild(_inner);progressDiv.oncontextmenu=progressDiv.onmousedown=function(evt){evt.preventDefault();evt.stopPropagation();return false;};return progressDiv;};x3dom.X3DCanvas.prototype.mousePosition=function(evt)
+{var rect=evt.target.getBoundingClientRect();var offsetX=Math.round(evt.clientX-rect.left)*this.devicePixelRatio;var offsetY=Math.round(evt.clientY-rect.top)*this.devicePixelRatio;return new x3dom.fields.SFVec2f(offsetX,offsetY);};x3dom.X3DCanvas.prototype.tick=function(timestamp)
+{var that=this;this._elapsedTime=(this._totalTime)?timestamp-this._totalTime:0;this._totalTime=timestamp;var runtime=this.x3dElem.runtime;var d=new Date().getTime();var diff=d-this.lastTimeFPSWasTaken;var fps=1000.0/(d-this.fps_t0);this.fps_t0=d;this.doc.advanceTime(d/1000.0);var animD=new Date().getTime()-d;if(this.doc.needRender){if(diff>=1000){runtime.fps=this.framesSinceLastTime/(diff/1000.0);runtime.addMeasurement('FPS',runtime.fps);this.framesSinceLastTime=0;this.lastTimeFPSWasTaken=d;}
+this.framesSinceLastTime++;runtime.addMeasurement('ANIM',animD);if(runtime.isReady==false){runtime.ready();runtime.isReady=true;}
+runtime.enterFrame({"total":this._totalTime,"elapsed":this._elapsedTime});this.doc.needRender=false;this.doc.render(this.gl);if(!this.doc._scene._vf.doPickPass)
+{runtime.removeMeasurement('PICKING');}
+runtime.exitFrame({"total":this._totalTime,"elapsed":this._elapsedTime});}
+if(this.progressDiv){if(this.doc.downloadCount>0){runtime.addInfo("#LOADS:",this.doc.downloadCount);}else{runtime.removeInfo("#LOADS:");}
+if(this.doc.properties.getProperty("showProgress")!=='false'){if(this.progressDiv){this.progressDiv.childNodes[0].textContent='Loading: '+(+this.doc.downloadCount);if(this.doc.downloadCount>0){this.progressDiv.style.display='inline';}else{this.progressDiv.style.display='none';}}}else{this.progressDiv.style.display='none';}}
+if(this.doc.downloadCount==0&&this.doc.previousDownloadCount>0)
+{var evt;if(document.createEvent){evt=document.createEvent("Events");evt.initEvent("downloadsfinished",true,true);that.x3dElem.dispatchEvent(evt);}else if(document.createEventObject){evt=document.createEventObject();that.x3dElem.fireEvent("ondownloadsfinished",evt);}}
+this.doc.previousDownloadCount=this.doc.downloadCount;};x3dom.X3DCanvas.prototype.load=function(uri,sceneElemPos,settings){this.doc=new x3dom.X3DDocument(this.canvas,this.gl,settings);var x3dCanvas=this;this.doc.onload=function(){if(x3dCanvas.hasRuntime){(function mainloop(timestamp){if(x3dCanvas.doc&&x3dCanvas.x3dElem.runtime){x3dCanvas._watchForResize();x3dCanvas.tick(timestamp);window.requestAnimFrame(mainloop,x3dCanvas);}})();}else{x3dCanvas.tick();}};this.x3dElem.render=function(){if(x3dCanvas.hasRuntime){x3dCanvas.doc.needRender=true;}else{x3dCanvas.doc.render(x3dCanvas.gl);}};this.x3dElem.context=x3dCanvas.gl.ctx3d;this.doc.onerror=function(){alert('Failed to load X3D document');};this.doc.load(uri,sceneElemPos);};x3dom.runtime={};x3dom.Runtime=function(doc,canvas){this.doc=doc;this.canvas=canvas;this.config={};this.isReady=false;this.fps=0;this.states={measurements:[],infos:[]};};x3dom.Runtime.prototype.addMeasurement=function(title,value){this.states.measurements[title]=value;};x3dom.Runtime.prototype.removeMeasurement=function(title){if(this.states.measurements[title]){delete this.states.measurements[title];}};x3dom.Runtime.prototype.addInfo=function(title,value){this.states.infos[title]=value;};x3dom.Runtime.prototype.removeInfo=function(title){delete this.states.infos[title];};x3dom.Runtime.prototype.initialize=function(doc,canvas){this.doc=doc;this.canvas=canvas;this.config={};this.isReady=false;this.fps=0;};x3dom.Runtime.prototype.noBackendFound=function(){x3dom.debug.logInfo('No backend found. Unable to render.');};x3dom.Runtime.prototype.ready=function(){x3dom.debug.logInfo('System ready.');};x3dom.Runtime.prototype.enterFrame=function(){};x3dom.Runtime.prototype.exitFrame=function(){};x3dom.Runtime.prototype.triggerRedraw=function(){this.canvas.doc.needRender=true;};x3dom.Runtime.prototype.getActiveBindable=function(typeName){var stacks;var i,current,result;var type;stacks=this.canvas.doc._bindableBag._stacks;result=[];type=x3dom.nodeTypesLC[typeName.toLowerCase()];if(!type){x3dom.debug.logError('No node of type "'+typeName+'" found.');return null;}
+for(i=0;i0){this.canvas.doc._viewarea.animateTo(this.canvas.doc._viewarea.getLightMatrix()[0],this.canvas.doc._scene.getViewpoint());return true;}else{x3dom.debug.logInfo("No lights to navigate to.");return false;}};x3dom.Runtime.prototype.uprightView=function(){this.canvas.doc._viewarea.uprightView();};x3dom.Runtime.prototype.fitAll=function(updateCenterOfRotation)
+{if(updateCenterOfRotation===undefined){updateCenterOfRotation=true;}
+var scene=this.canvas.doc._scene;scene.updateVolume();this.canvas.doc._viewarea.fit(scene._lastMin,scene._lastMax,updateCenterOfRotation);};x3dom.Runtime.prototype.fitObject=function(obj,updateCenterOfRotation)
+{if(obj&&obj._x3domNode)
+{if(updateCenterOfRotation===undefined){updateCenterOfRotation=true;}
+var min=x3dom.fields.SFVec3f.MAX();var max=x3dom.fields.SFVec3f.MIN();var vol=obj._x3domNode.getVolume();vol.getBounds(min,max);var mat=obj._x3domNode.getCurrentTransform();min=mat.multMatrixPnt(min);max=mat.multMatrixPnt(max);if(x3dom.isa(obj._x3domNode,x3dom.nodeTypes.X3DTransformNode))
+{var invMat=obj._x3domNode._trafo.inverse();min=invMat.multMatrixPnt(min);max=invMat.multMatrixPnt(max);}
+this.canvas.doc._viewarea.fit(min,max,updateCenterOfRotation);}};x3dom.Runtime.prototype.showAll=function(axis,updateCenterOfRotation){this.canvas.doc._viewarea.showAll(axis,updateCenterOfRotation);};x3dom.Runtime.prototype.showObject=function(obj,axis)
+{if(obj&&obj._x3domNode)
+{var min=x3dom.fields.SFVec3f.MAX();var max=x3dom.fields.SFVec3f.MIN();var vol=obj._x3domNode.getVolume();vol.getBounds(min,max);var mat=obj._x3domNode.getCurrentTransform();min=mat.multMatrixPnt(min);max=mat.multMatrixPnt(max);var viewarea=this.canvas.doc._viewarea;var focalLen=(viewarea._widthx3dom.fields.Eps){focalLen/=ta;}
+var w=viewarea._width-1;var h=viewarea._height-1;var frame=0.25;var minScreenPos=new x3dom.fields.SFVec2f(frame*w,frame*h);frame=0.75;var maxScreenPos=new x3dom.fields.SFVec2f(frame*w,frame*h);var dia2=max.subtract(min).multiply(0.5);var rw=dia2.length();var pc=min.add(dia2);var vc=maxScreenPos.subtract(minScreenPos).multiply(0.5);var rs=1.5*vc.length();vc=vc.add(minScreenPos);var dist=1.0;if(rs>x3dom.fields.Eps){dist=(rw/rs)*Math.sqrt(vc.x*vc.x+vc.y*vc.y+focalLen*focalLen);}
+n0=mat.multMatrixVec(n0).normalize();n0=n0.multiply(dist);var p0=pc.add(n0);var qDir=x3dom.fields.Quaternion.rotateFromTo(new x3dom.fields.SFVec3f(0,0,1),n0);var R=qDir.toMatrix();var T=x3dom.fields.SFMatrix4f.translation(p0.negate());var M=x3dom.fields.SFMatrix4f.translation(p0);M=M.mult(R).mult(T).mult(M);var viewmat=M.inverse();viewarea.animateTo(viewmat,viewpoint);}};x3dom.Runtime.prototype.getCenter=function(domNode){if(domNode&&domNode._x3domNode&&(this.isA(domNode,"X3DShapeNode")||this.isA(domNode,"X3DGeometryNode")))
+{return domNode._x3domNode.getCenter();}
+return null;};x3dom.Runtime.prototype.getCurrentTransform=function(domNode){if(domNode&&domNode._x3domNode)
+{return domNode._x3domNode.getCurrentTransform();}
+return null;};x3dom.Runtime.prototype.getBBox=function(domNode){if(domNode&&domNode._x3domNode&&this.isA(domNode,"X3DBoundedObject"))
+{var vol=domNode._x3domNode.getVolume();return{min:x3dom.fields.SFVec3f.copy(vol.min),max:x3dom.fields.SFVec3f.copy(vol.max)}}
+return null;};x3dom.Runtime.prototype.getSceneBBox=function(){var scene=this.canvas.doc._scene;scene.updateVolume();return{min:x3dom.fields.SFVec3f.copy(scene._lastMin),max:x3dom.fields.SFVec3f.copy(scene._lastMax)}};x3dom.Runtime.prototype.debug=function(show){var doc=this.canvas.doc;if(doc._viewarea._visDbgBuf===undefined)
+doc._viewarea._visDbgBuf=(doc._x3dElem.getAttribute("showLog")==='true');if(arguments.length>0){if(show===true){doc._viewarea._visDbgBuf=true;x3dom.debug.logContainer.style.display="block";}
+else{doc._viewarea._visDbgBuf=false;x3dom.debug.logContainer.style.display="none";}}
+else{doc._viewarea._visDbgBuf=!doc._viewarea._visDbgBuf;x3dom.debug.logContainer.style.display=(doc._viewarea._visDbgBuf==true)?"block":"none";}
+doc.needRender=true;return doc._viewarea._visDbgBuf;};x3dom.Runtime.prototype.navigationType=function(){return this.canvas.doc._scene.getNavigationInfo().getType();};x3dom.Runtime.prototype.noNav=function(){this.canvas.doc._scene.getNavigationInfo().setType("none");};x3dom.Runtime.prototype.examine=function(){this.canvas.doc._scene.getNavigationInfo().setType("examine");};x3dom.Runtime.prototype.turnTable=function(){this.canvas.doc._scene.getNavigationInfo().setType("turntable");};x3dom.Runtime.prototype.fly=function(){this.canvas.doc._scene.getNavigationInfo().setType("fly");};x3dom.Runtime.prototype.freeFly=function(){this.canvas.doc._scene.getNavigationInfo().setType("freefly");};x3dom.Runtime.prototype.lookAt=function(){this.canvas.doc._scene.getNavigationInfo().setType("lookat");};x3dom.Runtime.prototype.lookAround=function(){this.canvas.doc._scene.getNavigationInfo().setType("lookaround");};x3dom.Runtime.prototype.walk=function(){this.canvas.doc._scene.getNavigationInfo().setType("walk");};x3dom.Runtime.prototype.game=function(){this.canvas.doc._scene.getNavigationInfo().setType("game");};x3dom.Runtime.prototype.helicopter=function(){this.canvas.doc._scene.getNavigationInfo().setType("helicopter");};x3dom.Runtime.prototype.resetExamin=function(){var viewarea=this.canvas.doc._viewarea;viewarea._rotMat=x3dom.fields.SFMatrix4f.identity();viewarea._transMat=x3dom.fields.SFMatrix4f.identity();viewarea._movement=new x3dom.fields.SFVec3f(0,0,0);viewarea._needNavigationMatrixUpdate=true;this.canvas.doc.needRender=true;};x3dom.Runtime.prototype.disableKeys=function(){this.canvas.disableKeys=true;};x3dom.Runtime.prototype.enableKeys=function(){this.canvas.disableKeys=false;};x3dom.Runtime.prototype.disableLeftDrag=function(){this.canvas.disableLeftDrag=true;};x3dom.Runtime.prototype.enableLeftDrag=function(){this.canvas.disableLeftDrag=false;};x3dom.Runtime.prototype.disableRightDrag=function(){this.canvas.disableRightDrag=true;};x3dom.Runtime.prototype.enableRightDrag=function(){this.canvas.disableRightDrag=false;};x3dom.Runtime.prototype.disableMiddleDrag=function(){this.canvas.disableMiddleDrag=true;};x3dom.Runtime.prototype.enableMiddleDrag=function(){this.canvas.disableMiddleDrag=false;};x3dom.Runtime.prototype.togglePoints=function(lines){var doc=this.canvas.doc;var mod=(lines===true)?3:2;doc._viewarea._points=++doc._viewarea._points%mod;doc.needRender=true;return doc._viewarea._points;};x3dom.Runtime.prototype.pickRect=function(x1,y1,x2,y2){return this.canvas.doc.onPickRect(this.canvas.gl,x1,y1,x2,y2);};x3dom.Runtime.prototype.pickMode=function(options){if(options&&options.internal===true){return this.canvas.doc._scene._vf.pickMode;}
+return this.canvas.doc._scene._vf.pickMode.toLowerCase();};x3dom.Runtime.prototype.changePickMode=function(type){type=type.toLowerCase();switch(type){case'idbuf':type='idBuf';break;case'idbuf24':type='idBuf24';break;case'idbufid':type='idBufId';break;case'texcoord':type='texCoord';break;case'color':type='color';break;case'box':type='box';break;default:x3dom.debug.logWarning("Switch pickMode to "+type+' unknown intersect type');type=undefined;}
+if(type!==undefined){this.canvas.doc._scene._vf.pickMode=type;x3dom.debug.logInfo("Switched pickMode to '"+type+"'.");return true;}
+return false;};x3dom.Runtime.prototype.speed=function(newSpeed){var navi=this.canvas.doc._scene.getNavigationInfo();if(newSpeed){navi._vf.speed=newSpeed;x3dom.debug.logInfo("Changed navigation speed to "+navi._vf.speed);}
+return navi._vf.speed;};x3dom.Runtime.prototype.zoom=function(zoomAmount){this.canvas.doc._viewarea.zoom(zoomAmount);this.canvas.doc.needRender=true;};x3dom.Runtime.prototype.statistics=function(mode){var states=this.canvas.stateViewer;if(states){this.canvas.doc.needRender=true;if(mode===true){states.display(mode);return true;}
+else if(mode===false){states.display(mode);return false;}
+else{states.display(!states.active);return states.active;}}
+return false;};x3dom.Runtime.prototype.processIndicator=function(mode){var processDiv=this.canvas.progressDiv;if(processDiv){if(mode===true){processDiv.style.display='inline';return true;}
+else if(mode===false){processDiv.style.display='none';return false;}
+return processDiv.style.display!='none'}
+return false;};x3dom.Runtime.prototype.properties=function(){return this.canvas.doc.properties;};x3dom.Runtime.prototype.backendName=function(){return this.canvas.backend;};x3dom.Runtime.prototype.getFPS=function(){return this.fps;};x3dom.Runtime.prototype.isA=function(domNode,nodeType){var inherits=false;if(nodeType&&domNode&&domNode._x3domNode){if(nodeType===""){nodeType="X3DNode";}
+inherits=x3dom.isa(domNode._x3domNode,x3dom.nodeTypesLC[nodeType.toLowerCase()]);}
+return inherits;};x3dom.Runtime.prototype.getPixelScale=function(){var vp=this.viewpoint();if(!x3dom.isa(vp,x3dom.nodeTypes.OrthoViewpoint)){x3dom.debug.logError("getPixelScale is only implemented for orthographic Viewpoints");return null;}
+var zoomLevel=vp.getZoom();var left=zoomLevel[0];var bottom=zoomLevel[1];var right=zoomLevel[2];var top=zoomLevel[3];var x=right-left;var y=top-bottom;var pixelScaleX=x/this.getWidth();var pixelScaleY=y/this.getHeight();return new x3dom.fields.SFVec3f(pixelScaleX,pixelScaleY,0.0);};x3dom.Runtime.prototype.toggleProjection=function(perspViewID,orthoViewID)
+{var dist;var factor=2.2;var runtime=document.getElementById("x3d").runtime;var navInfo=runtime.canvas.doc._scene.getNavigationInfo();var speed=navInfo._vf.transitionTime;var persp=document.getElementById(perspViewID)._x3domNode;var ortho=document.getElementById(orthoViewID)._x3domNode;navInfo._vf.transitionTime=0;ortho._bindAnimation=false;persp._bindAnimation=false;if(persp._vf.isActive){ortho._viewMatrix=persp._viewMatrix;document.getElementById(orthoViewID).setAttribute("set_bind","true");dist=persp._viewMatrix.e3().length()/factor;ortho.setZoom(dist);}
+else if(ortho._vf.isActive){persp._viewMatrix=ortho._viewMatrix;document.getElementById(perspViewID).setAttribute("set_bind","true");dist=ortho._fieldOfView[2]*factor;var translation=ortho._viewMatrix.e3().normalize().multiply(dist);persp._viewMatrix.setTranslate(translation);}
+navInfo._vf.transitionTime=speed;ortho._bindAnimation=true;persp._bindAnimation=true;return(persp._vf.isActive)?0:1;};x3dom.userAgentFeature={supportsDOMAttrModified:false};(function loadX3DOM(){"use strict";var onload=function(){var i,j;var x3ds_unfiltered=document.getElementsByTagName('X3D');var x3ds=[];for(i=0;i"
++x3dom.versionInfo.revision+", "+"Date "+x3dom.versionInfo.date);}
+x3dom.debug.logInfo("Found "+x3ds.length+" X3D and nodes...");var x3d_element;var x3dcanvas;var altDiv,altP,aLnk,altImg;var t0,t1;for(i=0;i2.3)
+{font_size=2.3;}}
+var textX,textY;var paragraph=this.node._vf.string;var maxExtent=this.node._vf.maxExtent;var lengths=[];var text_canvas=document.createElement('canvas');text_canvas.dir=leftToRight;var x3dToPx=42;var textHeight=font_size*x3dToPx;var textAlignment=font_justify;document.body.appendChild(text_canvas);var text_ctx=text_canvas.getContext('2d');text_ctx.font=font_style+" "+textHeight+"px "+font_family;var maxWidth=0,pWidth,pLength;var i,j;for(i=0;imaxWidth){maxWidth=pWidth;}
+pLength=this.node._vf.length[i]|0;if(maxExtent>0&&(pLength>maxExtent||pLength==0)){pLength=maxExtent;}
+lengths[i]=pLength<=0?pWidth:pLength*x3dToPx;}
+var canvas_extra=0.1*textHeight;var txtW=maxWidth;var txtH=textHeight*font_spacing*paragraph.length+canvas_extra;textX=0;textY=0;var x_offset=0,y_offset=0,baseLine='top';switch(font_justify){case"center":x_offset=-txtW/2;textX=txtW/2;break;case"left":x_offset=leftToRight=='ltr'?0:-txtW;textX=0;break;case"right":x_offset=leftToRight=='ltr'?-txtW:0;textX=txtW;break;}
+switch(minor_alignment){case"MIDDLE":y_offset=txtH/2;break;case"BEGIN":y_offset=topToBottom?0:txtH-canvas_extra;baseLine=topToBottom?'top':'bottom';textY=topToBottom?0:textHeight;break;case"FIRST":y_offset=topToBottom?textHeight:txtH-canvas_extra;baseLine=topToBottom?'alphabetic':'bottom';textY=topToBottom?textHeight:textHeight;break;case"END":y_offset=topToBottom?txtH-canvas_extra:0;baseLine=topToBottom?'bottom':'top';textY=topToBottom?textHeight:0;break;}
+var pxToX3d=1/42.0;var w=txtW*pxToX3d;var h=txtH*pxToX3d;x_offset*=pxToX3d;y_offset*=pxToX3d;text_canvas.width=txtW*oversample;text_canvas.height=txtH*oversample;text_canvas.dir=leftToRight;text_ctx.scale(oversample,oversample);text_ctx.fillStyle='rgba(0,0,0,0)';text_ctx.fillRect(0,0,text_ctx.canvas.width,text_ctx.canvas.height);text_ctx.fillStyle='white';text_ctx.textBaseline=baseLine;text_ctx.font=font_style+" "+textHeight+"px "+font_family;text_ctx.textAlign=textAlignment;for(i=0;i1){x3dom.debug.logError("X3D element has more than one Scene child (has "+
+x3dElem.childNodes.length+").");}
+else{return sceneElems[0];}
+return null;};x3dom.X3DDocument.prototype._setup=function(sceneDoc,uriDocs,sceneElemPos){var doc=this;function cleanNodeBag(bag,node){for(var i=0,n=bag.length;i0){this._viewarea.animateTo(this._viewarea.getLightMatrix()[0],this._scene.getViewpoint());}
+break;case 117:this._viewarea.uprightView();break;case 118:var that=this;(function(){var viewpoint=that._viewarea._scene.getViewpoint();var mat_view=that._viewarea.getViewMatrix().inverse();var rotation=new x3dom.fields.Quaternion(0,0,1,0);rotation.setValue(mat_view);var rot=rotation.toAxisAngle();var translation=mat_view.e3();x3dom.debug.logInfo('\n<Viewpoint position="'+translation.x.toFixed(5)+' '
++translation.y.toFixed(5)+' '+translation.z.toFixed(5)+'" '+'orientation="'+rot[0].x.toFixed(5)+' '+rot[0].y.toFixed(5)+' '
++rot[0].z.toFixed(5)+' '+rot[1].toFixed(5)+'" \n\t'+'zNear="'+viewpoint.getNear().toFixed(5)+'" '+'zFar="'+viewpoint.getFar().toFixed(5)+'" '+'description="'+viewpoint._vf.description+'">'+'</Viewpoint>');})();break;case 119:nav.setType("walk",this._viewarea);break;case 121:nav.setType("freefly",this._viewarea);break;default:}};x3dom.X3DDocument.prototype.shutdown=function(ctx)
+{if(!ctx){return;}
+ctx.shutdown(this._viewarea);};x3dom.MatrixMixer=function(beginTime,endTime)
+{this.beginTime=beginTime||0;this.endTime=endTime||1;this.isMixing=false;this._beginMat=x3dom.fields.SFMatrix4f.identity();this._beginInvMat=x3dom.fields.SFMatrix4f.identity();this._beginLogMat=x3dom.fields.SFMatrix4f.identity();this._endMat=x3dom.fields.SFMatrix4f.identity();this._endLogMat=x3dom.fields.SFMatrix4f.identity();this._beginRot=new x3dom.fields.Quaternion();this._endRot=new x3dom.fields.Quaternion();this._beginPos=new x3dom.fields.SFVec3f();this._endPos=new x3dom.fields.SFVec3f();this._result=x3dom.fields.SFMatrix4f.identity();this._useQuaternion=false;};x3dom.MatrixMixer.prototype._calcFraction=function(time)
+{var fraction=(time-this.beginTime)/(this.endTime-this.beginTime);return(Math.sin((fraction*Math.PI)-(Math.PI/2))+1)/2.0;};x3dom.MatrixMixer.prototype._isValid=function()
+{var angles=this._beginMat.inverse().mult(this._endMat).getEulerAngles();return(Math.abs(angles[0])!=Math.PI&&Math.abs(angles[1])!=Math.PI&&Math.abs(angles[2])!=Math.PI);};x3dom.MatrixMixer.prototype._prepareQuaternionAnimation=function()
+{this._beginRot.setValue(this._beginMat);this._endRot.setValue(this._endMat);this._beginPos=this._beginMat.e3();this._endPos=this._endMat.e3();this._useQuaternion=true;};x3dom.MatrixMixer.prototype._reset=function()
+{this.beginTime=0;this.endTime=0;this._useQuaternion=false;this.isMixing=false;};x3dom.MatrixMixer.prototype.isActive=function()
+{return(this.beginTime>0);};x3dom.MatrixMixer.prototype.setBeginMatrix=function(mat)
+{this._beginMat.setValues(mat);this._beginInvMat=mat.inverse();this._beginLogMat=x3dom.fields.SFMatrix4f.zeroMatrix();};x3dom.MatrixMixer.prototype.setEndMatrix=function(mat)
+{this._endMat.setValues(mat);if(!this._isValid())
+{this._prepareQuaternionAnimation();}
+this._endLogMat=this._endMat.mult(this._beginInvMat).log();this._logDiffMat=this._endLogMat.addScaled(this._beginLogMat,-1);};x3dom.MatrixMixer.prototype._mixQuaternion=function(fraction)
+{var rotation=this._beginRot.slerp(this._endRot,fraction);var translation=this._beginPos.addScaled(this._endPos.subtract(this._beginPos),fraction);this._result.setRotate(rotation);this._result.setTranslate(translation);return this._result.copy();};x3dom.MatrixMixer.prototype._mixMatrix=function(fraction)
+{return this._logDiffMat.multiply(fraction).add(this._beginLogMat).exp().mult(this._beginMat);};x3dom.MatrixMixer.prototype.mix=function(time)
+{if(time<=this.beginTime)
+{return this._beginMat;}
+else if(time>=this.endTime)
+{this._reset();return this._endMat;}
+else
+{this.isMixing=true;var fraction=this._calcFraction(time);if(this._useQuaternion)
+{return this._mixQuaternion(fraction);}
+else
+{return this._mixMatrix(fraction);}}};x3dom.InputTypes={NAVIGATION:1,INTERACTION:2};x3dom.Viewarea=function(document,scene){this._doc=document;this._scene=scene;document._nodeBag.viewarea.push(this);this._pickingInfo={pickPos:new x3dom.fields.SFVec3f(0,0,0),pickNorm:new x3dom.fields.SFVec3f(0,0,1),pickObj:null,firstObj:null,lastObj:null,lastClickObj:null,shadowObjectId:-1};this._currentInputType=x3dom.InputTypes.NAVIGATION;this._rotMat=x3dom.fields.SFMatrix4f.identity();this._transMat=x3dom.fields.SFMatrix4f.identity();this._movement=new x3dom.fields.SFVec3f(0,0,0);this._needNavigationMatrixUpdate=true;this._deltaT=0;this._flyMat=null;this._pitch=0;this._yaw=0;this._eyePos=new x3dom.fields.SFVec3f(0,0,0);this._width=400;this._height=300;this._dx=0;this._dy=0;this._lastX=-1;this._lastY=-1;this._pressX=-1;this._pressY=-1;this._lastButton=0;this._points=0;this._numRenderedNodes=0;this._pick=new x3dom.fields.SFVec3f(0,0,0);this._pickNorm=new x3dom.fields.SFVec3f(0,0,1);this._isAnimating=false;this._isMoving=false;this._lastTS=0;this._mixer=new x3dom.MatrixMixer();this._interpolator=new x3dom.FieldInterpolator();this.arc=null;};x3dom.Viewarea.prototype.tick=function(timeStamp)
+{var needMixAnim=false;var env=this._scene.getEnvironment();if(env._vf.enableARC&&this.arc==null)
+{this.arc=new x3dom.arc.AdaptiveRenderControl(this._scene);}
+if(this._mixer.isActive())
+{var mat=this._mixer.mix(timeStamp);this._scene.getViewpoint().setView(mat);}
+if(this._interpolator.isActive())
+{var value=this._interpolator.interpolate(timeStamp);this._scene.getViewpoint().setZoom(value);}
+var needNavAnim=this.navigateTo(timeStamp);var lastIsAnimating=this._isAnimating;this._lastTS=timeStamp;this._isAnimating=(this._mixer.isMixing||this._interpolator.isInterpolating||needNavAnim);if(this.arc!=null)
+{this.arc.update(this.isMovingOrAnimating()?1:0,this._doc._x3dElem.runtime.getFPS());}
+return(this._isAnimating||lastIsAnimating);};x3dom.Viewarea.prototype.isMoving=function()
+{return this._isMoving;};x3dom.Viewarea.prototype.isAnimating=function()
+{return this._isAnimating;};x3dom.Viewarea.prototype.isMovingOrAnimating=function()
+{return(this._isMoving||this._isAnimating);};x3dom.Viewarea.prototype.navigateTo=function(timeStamp)
+{var navi=this._scene.getNavigationInfo();return navi._impl.navigateTo(this,timeStamp);};x3dom.Viewarea.prototype.moveFwd=function()
+{var navi=this._scene.getNavigationInfo();navi._impl.moveForward(this);};x3dom.Viewarea.prototype.moveBwd=function()
+{var navi=this._scene.getNavigationInfo();navi._impl.moveBackwards(this);};x3dom.Viewarea.prototype.strafeRight=function()
+{var navi=this._scene.getNavigationInfo();navi._impl.strafeRight(this);};x3dom.Viewarea.prototype.strafeLeft=function()
+{var navi=this._scene.getNavigationInfo();navi._impl.strafeLeft(this);};x3dom.Viewarea.prototype.animateTo=function(target,prev,dur)
+{var navi=this._scene.getNavigationInfo();navi._impl.animateTo(this,target,prev,dur);};x3dom.Viewarea.prototype.orthoAnimateTo=function(target,prev,duration)
+{var navi=this._scene.getNavigationInfo();navi._impl.orthoAnimateTo(this,target,prev,duration);};x3dom.Viewarea.prototype.zoom=function(zoomAmount)
+{var navi=this._scene.getNavigationInfo();navi._impl.zoom(this,zoomAmount);};x3dom.Viewarea.prototype.getLights=function(){var enabledLights=[];for(var i=0;i0.0){return true;}}
+return false;};x3dom.Viewarea.prototype.updateSpecialNavigation=function(viewpoint,mat_viewpoint){var navi=this._scene.getNavigationInfo();var navType=navi.getType();if(navType=="helicopter"&&!navi._heliUpdated)
+{var typeParams=navi.getTypeParams();var theta=typeParams[0];var currViewMat=viewpoint.getViewMatrix().mult(mat_viewpoint.inverse()).inverse();this._from=currViewMat.e3();this._at=this._from.subtract(currViewMat.e2());this._up=new x3dom.fields.SFVec3f(0,1,0);this._from.y=typeParams[1];this._at.y=this._from.y;var sv=currViewMat.e0();var q=x3dom.fields.Quaternion.axisAngle(sv,theta);var temp=q.toMatrix();var fin=x3dom.fields.SFMatrix4f.translation(this._from);fin=fin.mult(temp);temp=x3dom.fields.SFMatrix4f.translation(this._from.negate());fin=fin.mult(temp);this._at=fin.multMatrixPnt(this._at);this._flyMat=x3dom.fields.SFMatrix4f.lookAt(this._from,this._at,this._up);this._scene.getViewpoint().setView(this._flyMat.inverse());navi._heliUpdated=true;}};x3dom.Viewarea.prototype.getViewpointMatrix=function()
+{var viewpoint=this._scene.getViewpoint();var mat_viewpoint=viewpoint.getCurrentTransform();this.updateSpecialNavigation(viewpoint,mat_viewpoint);return viewpoint.getViewMatrix().mult(mat_viewpoint.inverse());};x3dom.Viewarea.prototype.getViewMatrix=function()
+{return this.getViewpointMatrix().mult(this._transMat).mult(this._rotMat);};x3dom.Viewarea.prototype.getLightMatrix=function()
+{var lights=this._doc._nodeBag.lights;var i,n=lights.length;if(n>0)
+{var vol=this._scene.getVolume();if(vol.isValid())
+{var min=x3dom.fields.SFVec3f.MAX();var max=x3dom.fields.SFVec3f.MIN();vol.getBounds(min,max);var l_arr=[];var viewpoint=this._scene.getViewpoint();var fov=viewpoint.getFieldOfView();var dia=max.subtract(min);var dist1=(dia.y/2.0)/Math.tan(fov/2.0)+(dia.z/2.0);var dist2=(dia.x/2.0)/Math.tan(fov/2.0)+(dia.z/2.0);dia=min.add(dia.multiply(0.5));for(i=0;idist2?dist1:dist2)));}
+l_arr[i]=lights[i].getViewMatrix(dia);}
+return l_arr;}}
+return[this.getViewMatrix()];};x3dom.Viewarea.prototype.getWCtoLCMatrix=function(lMat)
+{var proj=this.getProjectionMatrix();var view;if(arguments.length===0){view=this.getLightMatrix()[0];}
+else{view=lMat;}
+return proj.mult(view);};x3dom.Viewarea.prototype.getWCtoLCMatricesPointLight=function(view,lightNode,mat_proj)
+{var zNear=lightNode._vf.zNear;var zFar=lightNode._vf.zFar;var proj=this.getLightProjectionMatrix(view,zNear,zFar,false,mat_proj);proj._00=1;proj._11=1;var matrices=[];matrices[0]=proj.mult(view);var rotationMatrix;for(var i=1;i<=3;i++){rotationMatrix=x3dom.fields.SFMatrix4f.rotationY(i*Math.PI/2);matrices[i]=proj.mult(rotationMatrix.mult(view));}
+rotationMatrix=x3dom.fields.SFMatrix4f.rotationX(Math.PI/2);matrices[4]=proj.mult(rotationMatrix.mult(view));rotationMatrix=x3dom.fields.SFMatrix4f.rotationX(3*Math.PI/2);matrices[5]=proj.mult(rotationMatrix.mult(view));return matrices;};x3dom.Viewarea.prototype.getWCtoLCMatricesCascaded=function(view,lightNode,mat_proj)
+{var numCascades=Math.max(1,Math.min(lightNode._vf.shadowCascades,6));var splitFactor=Math.max(0,Math.min(lightNode._vf.shadowSplitFactor,1));var splitOffset=Math.max(0,Math.min(lightNode._vf.shadowSplitOffset,1));var isSpotLight=x3dom.isa(lightNode,x3dom.nodeTypes.SpotLight);var zNear=lightNode._vf.zNear;var zFar=lightNode._vf.zFar;var proj=this.getLightProjectionMatrix(view,zNear,zFar,true,mat_proj);if(isSpotLight){proj._00=1;proj._11=1;}
+var viewProj=proj.mult(view);var matrices=[];if(numCascades==1){matrices[0]=viewProj;return matrices;}
+var cascadeSplits=this.getShadowSplitDepths(numCascades,splitFactor,splitOffset,true,mat_proj);for(var i=0;i0||zFar>0){var lightPos=lMat.inverse().e3();var nearScale=0.8;var farScale=1.2;var min=x3dom.fields.SFVec3f.copy(this._scene._lastMin);var max=x3dom.fields.SFVec3f.copy(this._scene._lastMax);var dia=max.subtract(min);var sRad=dia.length()/2;var sCenter=min.add(dia.multiply(0.5));var vDist=(lightPos.subtract(sCenter)).length();var near,far;if(sRad){if(vDist>sRad)
+near=(vDist-sRad)*nearScale;else
+near=1;far=(vDist+sRad)*farScale;}
+if(zNear>0)near=zNear;if(zFar>0)far=zFar;proj._22=-(far+near)/(far-near);proj._23=-2.0*far*near/(far-near);return proj;}
+else{var cropMatrix=this.getLightCropMatrix(proj.mult(lMat));return cropMatrix.mult(proj);}};x3dom.Viewarea.prototype.getProjectionMatrix=function()
+{var viewpoint=this._scene.getViewpoint();return viewpoint.getProjectionMatrix(this._width/this._height);};x3dom.Viewarea.prototype.getViewfrustum=function(clipMat)
+{var env=this._scene.getEnvironment();if(env._vf.frustumCulling==true)
+{if(arguments.length==0){var proj=this.getProjectionMatrix();var view=this.getViewMatrix();return new x3dom.fields.FrustumVolume(proj.mult(view));}
+else{return new x3dom.fields.FrustumVolume(clipMat);}}
+return null;};x3dom.Viewarea.prototype.getWCtoCCMatrix=function()
+{var view=this.getViewMatrix();var proj=this.getProjectionMatrix();return proj.mult(view);};x3dom.Viewarea.prototype.getCCtoWCMatrix=function()
+{var mat=this.getWCtoCCMatrix();return mat.inverse();};x3dom.Viewarea.prototype.calcViewRay=function(x,y,mat)
+{var cctowc=mat?mat:this.getCCtoWCMatrix();var rx=x/(this._width-1.0)*2.0-1.0;var ry=(this._height-1.0-y)/(this._height-1.0)*2.0-1.0;var from=cctowc.multFullMatrixPnt(new x3dom.fields.SFVec3f(rx,ry,-1));var at=cctowc.multFullMatrixPnt(new x3dom.fields.SFVec3f(rx,ry,1));var dir=at.subtract(from);return new x3dom.fields.Ray(from,dir);};x3dom.Viewarea.prototype.showAll=function(axis,updateCenterOfRotation)
+{if(axis===undefined)
+axis="negZ";if(updateCenterOfRotation===undefined){updateCenterOfRotation=false;}
+var scene=this._scene;scene.updateVolume();var min=x3dom.fields.SFVec3f.copy(scene._lastMin);var max=x3dom.fields.SFVec3f.copy(scene._lastMax);var x="x",y="y",z="z";var sign=1;var to,from=new x3dom.fields.SFVec3f(0,0,-1);switch(axis){case"posX":sign=-1;case"negX":z="x";x="y";y="z";to=new x3dom.fields.SFVec3f(sign,0,0);break;case"posY":sign=-1;case"negY":z="y";x="z";y="x";to=new x3dom.fields.SFVec3f(0,sign,0);break;case"posZ":sign=-1;case"negZ":default:to=new x3dom.fields.SFVec3f(0,0,-sign);break;}
+var viewpoint=scene.getViewpoint();var fov=viewpoint.getFieldOfView();var isOrtho=x3dom.isa(viewpoint,x3dom.nodeTypes.OrthoViewpoint);var dia=max.subtract(min);var dia2=dia.multiply(0.5);var center=min.add(dia2);if(updateCenterOfRotation){viewpoint.setCenterOfRotation(center);}
+var diaz2=dia[z]/2.0,tanfov2=Math.tan(fov/2.0);var dist1=(dia[y]/2.0)/tanfov2+diaz2;var dist2=(dia[x]/2.0)/tanfov2+diaz2;dia=min.add(dia.multiply(0.5));if(isOrtho)
+{dia[z]+=sign*(dist1>dist2?dist1:dist2)*3.01;}
+else
+{dia[z]+=sign*(dist1>dist2?dist1:dist2)*1.01;}
+var quat=x3dom.fields.Quaternion.rotateFromTo(from,to);var viewmat=quat.toMatrix();viewmat=viewmat.mult(x3dom.fields.SFMatrix4f.translation(dia.negate()));if(isOrtho)
+{this.orthoAnimateTo(dist1,Math.abs(viewpoint._fieldOfView[0]));this.animateTo(viewmat,viewpoint);}
+else
+{this.animateTo(viewmat,viewpoint);}};x3dom.Viewarea.prototype.fit=function(min,max,updateCenterOfRotation)
+{if(updateCenterOfRotation===undefined){updateCenterOfRotation=true;}
+var dia2=max.subtract(min).multiply(0.5);var center=min.add(dia2);var bsr=dia2.length();var viewpoint=this._scene.getViewpoint();var fov=viewpoint.getFieldOfView();var viewmat=x3dom.fields.SFMatrix4f.copy(this.getViewMatrix());var rightDir=new x3dom.fields.SFVec3f(viewmat._00,viewmat._01,viewmat._02);var upDir=new x3dom.fields.SFVec3f(viewmat._10,viewmat._11,viewmat._12);var viewDir=new x3dom.fields.SFVec3f(viewmat._20,viewmat._21,viewmat._22);var tanfov2=Math.tan(fov/2.0);var dist=bsr/tanfov2;var eyePos=center.add(viewDir.multiply(dist));viewmat._03=-rightDir.dot(eyePos);viewmat._13=-upDir.dot(eyePos);viewmat._23=-viewDir.dot(eyePos);if(updateCenterOfRotation){viewpoint.setCenterOfRotation(center);}
+if(x3dom.isa(viewpoint,x3dom.nodeTypes.OrthoViewpoint))
+{this.orthoAnimateTo(dist/2.01,Math.abs(viewpoint._fieldOfView[0]));this.animateTo(viewmat,viewpoint);}
+else
+{this.animateTo(viewmat,viewpoint);}};x3dom.Viewarea.prototype.resetView=function()
+{var navi=this._scene.getNavigationInfo();navi._impl.resetView(this);};x3dom.Viewarea.prototype.resetNavHelpers=function()
+{this._rotMat=x3dom.fields.SFMatrix4f.identity();this._transMat=x3dom.fields.SFMatrix4f.identity();this._movement=new x3dom.fields.SFVec3f(0,0,0);this._needNavigationMatrixUpdate=true;};x3dom.Viewarea.prototype.uprightView=function()
+{var mat=this.getViewMatrix().inverse();var from=mat.e3();var at=from.subtract(mat.e2());var up=new x3dom.fields.SFVec3f(0,1,0);var s=mat.e2().cross(up).normalize();var v=s.cross(up).normalize();at=from.add(v);mat=x3dom.fields.SFMatrix4f.lookAt(from,at,up);mat=mat.inverse();this.animateTo(mat,this._scene.getViewpoint());};x3dom.Viewarea.prototype.callEvtHandler=function(node,eventType,event)
+{if(!node||!node._xmlNode)
+return null;try{var attrib=node._xmlNode[eventType];if(typeof(attrib)==="function"){attrib.call(node._xmlNode,event);}
+else{var funcStr=node._xmlNode.getAttribute(eventType);var func=new Function('event',funcStr);func.call(node._xmlNode,event);}
+var list=node._listeners[event.type];if(list){for(var it=0;it0&&func!==undefined)
+{for(i=0;i=0)&&navType==="lookat"&&this._pressX===x&&this._pressY===y)
+{var step=(this._lastButton&2)?-1:1;var dist=this._pickingInfo.pickPos.subtract(this._from).length()/tDist;var laMat=new x3dom.fields.SFMatrix4f();laMat.setValues(this.getViewMatrix());laMat=laMat.inverse();var from=laMat.e3();var at=from.subtract(laMat.e2());var up=laMat.e1();dir=this._pickingInfo.pickPos.subtract(from);var len=dir.length();dir=dir.normalize();var newAt=from.addScaled(dir,len);var s=dir.cross(up).normalize();dir=s.cross(up).normalize();if(step<0){dist=(0.5+len+dist)*2;}
+var newFrom=newAt.addScaled(dir,dist);laMat=x3dom.fields.SFMatrix4f.lookAt(newFrom,newAt,up);laMat=laMat.inverse();dist=newFrom.subtract(from).length();var dur=Math.max(0.5,Math.log((1+dist)/navi._vf.speed));this.animateTo(laMat,this._scene.getViewpoint(),dur);}
+this._dx=0;this._dy=0;this._lastX=x;this._lastY=y;this._lastButton=buttonState;this._isMoving=false;};x3dom.Viewarea.prototype.onMouseOver=function(x,y,buttonState)
+{this._dx=0;this._dy=0;this._lastButton=0;this._isMoving=false;this._lastX=x;this._lastY=y;this._deltaT=0;};x3dom.Viewarea.prototype.onMouseOut=function(x,y,buttonState)
+{this._dx=0;this._dy=0;this._lastButton=0;this._isMoving=false;this._lastX=x;this._lastY=y;this._deltaT=0;var i;var affectedPointingSensorsList=this._doc._nodeBag.affectedPointingSensors;for(i=0;i0)
+{this._currentInputType=x3dom.InputTypes.INTERACTION;}
+else
+{this._currentInputType=x3dom.InputTypes.NAVIGATION;}};x3dom.Viewarea.prototype.getRenderMode=function()
+{return this._points;};x3dom.Viewarea.prototype.getShadowedLights=function()
+{var shadowedLights=[];var shadowIndex=0;var slights=this.getLights();for(var i=0;i0.0){shadowedLights[shadowIndex]=slights[i];shadowIndex++;}}
+return shadowedLights;};x3dom.Viewarea.prototype.getShadowSplitDepths=function(numCascades,splitFactor,splitOffset,postProject,mat_proj)
+{var logSplit;var practSplit=[];var viewPoint=this._scene.getViewpoint();var zNear=viewPoint.getNear();var zFar=viewPoint.getFar();practSplit[0]=zNear;zNear=zNear+splitOffset*(zFar-zNear)/10;for(var i=1;i1.0||xMax<-1.0){xMin=-1.0;xMax=1.0;}else{xMin=Math.max(xMin,-1.0);xMax=Math.min(xMax,1.0);}
+if(yMin>1.0||yMax<-1.0){yMin=-1.0;yMax=1.0;}else{yMin=Math.max(yMin,-1.0);yMax=Math.min(yMax,1.0);}
+if(zMin>1.0||zMax<-1.0){zMin=-1.0;zMax=1.0;}else{zMin=Math.max(zMin,-1.0);zMax=Math.min(zMax,1.0);}
+var minValues=new x3dom.fields.SFVec3f(xMin,yMin,zMin);var maxValues=new x3dom.fields.SFVec3f(xMax,yMax,zMax);return new x3dom.fields.BoxVolume(minValues,maxValues);}
+var frustumBB=clip(minFrustum,maxFrustum);var scaleX=2.0/(frustumBB.max.x-frustumBB.min.x);var scaleY=2.0/(frustumBB.max.y-frustumBB.min.y);var offsetX=-(scaleX*(frustumBB.max.x+frustumBB.min.x))/2.0;var offsetY=-(scaleY*(frustumBB.max.y+frustumBB.min.y))/2.0;var fittingMatrix=x3dom.fields.SFMatrix4f.identity();fittingMatrix._00=scaleX;fittingMatrix._11=scaleY;fittingMatrix._03=offsetX;fittingMatrix._13=offsetY;return fittingMatrix;};x3dom.Mesh=function(parent)
+{this._parent=parent;this._vol=new x3dom.fields.BoxVolume();this._invalidate=true;this._numFaces=0;this._numCoords=0;this._primType='TRIANGLES';this._positions=[];this._normals=[];this._texCoords=[];this._colors=[];this._indices=[];this._positions[0]=[];this._normals[0]=[];this._texCoords[0]=[];this._colors[0]=[];this._indices[0]=[];};x3dom.Mesh.prototype._dynamicFields={};x3dom.Mesh.prototype._numPosComponents=3;x3dom.Mesh.prototype._numTexComponents=2;x3dom.Mesh.prototype._numColComponents=3;x3dom.Mesh.prototype._numNormComponents=3;x3dom.Mesh.prototype._lit=true;x3dom.Mesh.prototype._vol=null;x3dom.Mesh.prototype._invalidate=true;x3dom.Mesh.prototype._numFaces=0;x3dom.Mesh.prototype._numCoords=0;x3dom.Mesh.prototype.setMeshData=function(positions,normals,texCoords,colors,indices)
+{this._positions[0]=positions;this._normals[0]=normals;this._texCoords[0]=texCoords;this._colors[0]=colors;this._indices[0]=indices;this._invalidate=true;this._numFaces=this._indices[0].length/3;this._numCoords=this._positions[0].length/3;};x3dom.Mesh.prototype.getVolume=function()
+{if(this._invalidate==true&&!this._vol.isValid())
+{var coords=this._positions[0];var n=coords.length;if(n>3)
+{var initVal=new x3dom.fields.SFVec3f(coords[0],coords[1],coords[2]);this._vol.setBounds(initVal,initVal);for(var i=3;icoords[i]){this._vol.min.x=coords[i];}
+if(this._vol.min.y>coords[i+1]){this._vol.min.y=coords[i+1];}
+if(this._vol.min.z>coords[i+2]){this._vol.min.z=coords[i+2];}
+if(this._vol.max.xm)?this._posSize/3:m/3;num=3*((num-Math.floor(num)>0)?Math.floor(num+1):num);for(i=0;ix3dom.fields.Eps)
+{for(i=0;i=0);if(k){this._indices[i]=indices.slice(i*MAX,(i+1)*MAX);}else{this._indices[i]=indices.slice(i*MAX);}
+if(!isMultiInd){if(i){var m=i*MAX;for(var j=0,l=this._indices[i].length;j++i*MAX*3);};x3dom.Mesh.prototype.calcTexCoords=function(mode)
+{this._texCoords[0]=[];if(mode.toLowerCase()==="sphere-local")
+{for(var i=0,j=0,n=this._normals[0].length;i=dia.y)
+{if(dia.x>=dia.z)
+{S=0;T=dia.y>=dia.z?1:2;}
+else
+{S=2;T=0;}}
+else
+{if(dia.y>=dia.z)
+{S=1;T=dia.x>=dia.z?0:2;}
+else
+{S=2;T=1;}}
+var sDenom=1,tDenom=1;var sMin=0,tMin=0;switch(S){case 0:sDenom=dia.x;sMin=min.x;break;case 1:sDenom=dia.y;sMin=min.y;break;case 2:sDenom=dia.z;sMin=min.z;break;}
+switch(T){case 0:tDenom=dia.x;tMin=min.x;break;case 1:tDenom=dia.y;tMin=min.y;break;case 2:tDenom=dia.z;tMin=min.z;break;}
+for(var k=0,l=0,m=this._positions[0].length;k=16)
+{if(!needTranspose){return new x3dom.fields.SFMatrix4f(arr[0],arr[1],arr[2],arr[3],arr[4],arr[5],arr[6],arr[7],arr[8],arr[9],arr[10],arr[11],arr[12],arr[13],arr[14],arr[15]);}
+else{return new x3dom.fields.SFMatrix4f(arr[0],arr[4],arr[8],arr[12],arr[1],arr[5],arr[9],arr[13],arr[2],arr[6],arr[10],arr[14],arr[3],arr[7],arr[11],arr[15]);}}
+else if(arr.length===6){return new x3dom.fields.SFMatrix4f(arr[0],arr[1],0,arr[4],arr[2],arr[3],0,arr[5],0,0,1,0,0,0,0,1);}
+else{x3dom.debug.logWarning("SFMatrix4f - can't parse string: "+str);return x3dom.fields.SFMatrix4f.identity();}};x3dom.fields.SFMatrix4f.prototype.mult=function(that){return new x3dom.fields.SFMatrix4f(this._00*that._00+this._01*that._10+this._02*that._20+this._03*that._30,this._00*that._01+this._01*that._11+this._02*that._21+this._03*that._31,this._00*that._02+this._01*that._12+this._02*that._22+this._03*that._32,this._00*that._03+this._01*that._13+this._02*that._23+this._03*that._33,this._10*that._00+this._11*that._10+this._12*that._20+this._13*that._30,this._10*that._01+this._11*that._11+this._12*that._21+this._13*that._31,this._10*that._02+this._11*that._12+this._12*that._22+this._13*that._32,this._10*that._03+this._11*that._13+this._12*that._23+this._13*that._33,this._20*that._00+this._21*that._10+this._22*that._20+this._23*that._30,this._20*that._01+this._21*that._11+this._22*that._21+this._23*that._31,this._20*that._02+this._21*that._12+this._22*that._22+this._23*that._32,this._20*that._03+this._21*that._13+this._22*that._23+this._23*that._33,this._30*that._00+this._31*that._10+this._32*that._20+this._33*that._30,this._30*that._01+this._31*that._11+this._32*that._21+this._33*that._31,this._30*that._02+this._31*that._12+this._32*that._22+this._33*that._32,this._30*that._03+this._31*that._13+this._32*that._23+this._33*that._33);};x3dom.fields.SFMatrix4f.prototype.multMatrixPnt=function(vec){return new x3dom.fields.SFVec3f(this._00*vec.x+this._01*vec.y+this._02*vec.z+this._03,this._10*vec.x+this._11*vec.y+this._12*vec.z+this._13,this._20*vec.x+this._21*vec.y+this._22*vec.z+this._23);};x3dom.fields.SFMatrix4f.prototype.multMatrixVec=function(vec){return new x3dom.fields.SFVec3f(this._00*vec.x+this._01*vec.y+this._02*vec.z,this._10*vec.x+this._11*vec.y+this._12*vec.z,this._20*vec.x+this._21*vec.y+this._22*vec.z);};x3dom.fields.SFMatrix4f.prototype.multFullMatrixPnt=function(vec){var w=this._30*vec.x+this._31*vec.y+this._32*vec.z+this._33;if(w){w=1.0/w;}
+return new x3dom.fields.SFVec3f((this._00*vec.x+this._01*vec.y+this._02*vec.z+this._03)*w,(this._10*vec.x+this._11*vec.y+this._12*vec.z+this._13)*w,(this._20*vec.x+this._21*vec.y+this._22*vec.z+this._23)*w);};x3dom.fields.SFMatrix4f.prototype.multMatrixPlane=function(plane){var normal=new x3dom.fields.SFVec3f(plane.x,plane.y,plane.z);var memberPnt=normal.multiply(-plane.w);memberPnt=this.multMatrixPnt(memberPnt);var invTranspose=this.inverse().transpose();normal=invTranspose.multMatrixVec(normal);var d=-normal.dot(memberPnt);return new x3dom.fields.SFVec4f(normal.x,normal.y,normal.z,d);};x3dom.fields.SFMatrix4f.prototype.transpose=function(){return new x3dom.fields.SFMatrix4f(this._00,this._10,this._20,this._30,this._01,this._11,this._21,this._31,this._02,this._12,this._22,this._32,this._03,this._13,this._23,this._33);};x3dom.fields.SFMatrix4f.prototype.negate=function(){return new x3dom.fields.SFMatrix4f(-this._00,-this._01,-this._02,-this._03,-this._10,-this._11,-this._12,-this._13,-this._20,-this._21,-this._22,-this._23,-this._30,-this._31,-this._32,-this._33);};x3dom.fields.SFMatrix4f.prototype.multiply=function(s){return new x3dom.fields.SFMatrix4f(s*this._00,s*this._01,s*this._02,s*this._03,s*this._10,s*this._11,s*this._12,s*this._13,s*this._20,s*this._21,s*this._22,s*this._23,s*this._30,s*this._31,s*this._32,s*this._33);};x3dom.fields.SFMatrix4f.prototype.add=function(that){return new x3dom.fields.SFMatrix4f(this._00+that._00,this._01+that._01,this._02+that._02,this._03+that._03,this._10+that._10,this._11+that._11,this._12+that._12,this._13+that._13,this._20+that._20,this._21+that._21,this._22+that._22,this._23+that._23,this._30+that._30,this._31+that._31,this._32+that._32,this._33+that._33);};x3dom.fields.SFMatrix4f.prototype.addScaled=function(that,s){return new x3dom.fields.SFMatrix4f(this._00+s*that._00,this._01+s*that._01,this._02+s*that._02,this._03+s*that._03,this._10+s*that._10,this._11+s*that._11,this._12+s*that._12,this._13+s*that._13,this._20+s*that._20,this._21+s*that._21,this._22+s*that._22,this._23+s*that._23,this._30+s*that._30,this._31+s*that._31,this._32+s*that._32,this._33+s*that._33);};x3dom.fields.SFMatrix4f.prototype.setValues=function(that){this._00=that._00;this._01=that._01;this._02=that._02;this._03=that._03;this._10=that._10;this._11=that._11;this._12=that._12;this._13=that._13;this._20=that._20;this._21=that._21;this._22=that._22;this._23=that._23;this._30=that._30;this._31=that._31;this._32=that._32;this._33=that._33;};x3dom.fields.SFMatrix4f.prototype.setValue=function(v1,v2,v3,v4){this._00=v1.x;this._01=v2.x;this._02=v3.x;this._10=v1.y;this._11=v2.y;this._12=v3.y;this._20=v1.z;this._21=v2.z;this._22=v3.z;this._30=0;this._31=0;this._32=0;if(arguments.length>3){this._03=v4.x;this._13=v4.y;this._23=v4.z;this._33=1;}};x3dom.fields.SFMatrix4f.prototype.setFromArray=function(a){this._00=a[0];this._01=a[4];this._02=a[8];this._03=a[12];this._10=a[1];this._11=a[5];this._12=a[9];this._13=a[13];this._20=a[2];this._21=a[6];this._22=a[10];this._23=a[14];this._30=a[3];this._31=a[7];this._32=a[11];this._33=a[15];};x3dom.fields.SFMatrix4f.prototype.toGL=function(){return[this._00,this._10,this._20,this._30,this._01,this._11,this._21,this._31,this._02,this._12,this._22,this._32,this._03,this._13,this._23,this._33];};x3dom.fields.SFMatrix4f.prototype.at=function(i,j){var field="_"+i+j;return this[field];};x3dom.fields.SFMatrix4f.prototype.sqrt=function(){var Y=x3dom.fields.SFMatrix4f.identity();var result=x3dom.fields.SFMatrix4f.copy(this);for(var i=0;i<6;i++)
+{var iX=result.inverse();var iY=(i==0)?x3dom.fields.SFMatrix4f.identity():Y.inverse();var rd=result.det(),yd=Y.det();var g=Math.abs(Math.pow(rd*yd,-0.125));var ig=1.0/g;result=result.multiply(g);result=result.addScaled(iY,ig);result=result.multiply(0.5);Y=Y.multiply(g);Y=Y.addScaled(iX,ig);Y=Y.multiply(0.5);}
+return result;};x3dom.fields.SFMatrix4f.prototype.normInfinity=function(){var t=0,m=0;if((t=Math.abs(this._00))>m){m=t;}
+if((t=Math.abs(this._01))>m){m=t;}
+if((t=Math.abs(this._02))>m){m=t;}
+if((t=Math.abs(this._03))>m){m=t;}
+if((t=Math.abs(this._10))>m){m=t;}
+if((t=Math.abs(this._11))>m){m=t;}
+if((t=Math.abs(this._12))>m){m=t;}
+if((t=Math.abs(this._13))>m){m=t;}
+if((t=Math.abs(this._20))>m){m=t;}
+if((t=Math.abs(this._21))>m){m=t;}
+if((t=Math.abs(this._22))>m){m=t;}
+if((t=Math.abs(this._23))>m){m=t;}
+if((t=Math.abs(this._30))>m){m=t;}
+if((t=Math.abs(this._31))>m){m=t;}
+if((t=Math.abs(this._32))>m){m=t;}
+if((t=Math.abs(this._33))>m){m=t;}
+return m;};x3dom.fields.SFMatrix4f.prototype.norm1_3x3=function(){var max=Math.abs(this._00)+
+Math.abs(this._10)+
+Math.abs(this._20);var t=0;if((t=Math.abs(this._01)+
+Math.abs(this._11)+
+Math.abs(this._21))>max){max=t;}
+if((t=Math.abs(this._02)+
+Math.abs(this._12)+
+Math.abs(this._22))>max){max=t;}
+return max;};x3dom.fields.SFMatrix4f.prototype.normInf_3x3=function(){var max=Math.abs(this._00)+
+Math.abs(this._01)+
+Math.abs(this._02);var t=0;if((t=Math.abs(this._10)+
+Math.abs(this._11)+
+Math.abs(this._12))>max){max=t;}
+if((t=Math.abs(this._20)+
+Math.abs(this._21)+
+Math.abs(this._22))>max){max=t;}
+return max;};x3dom.fields.SFMatrix4f.prototype.adjointT_3x3=function(){var result=x3dom.fields.SFMatrix4f.identity();result._00=this._11*this._22-this._12*this._21;result._01=this._12*this._20-this._10*this._22;result._02=this._10*this._21-this._11*this._20;result._10=this._21*this._02-this._22*this._01;result._11=this._22*this._00-this._20*this._02;result._12=this._20*this._01-this._21*this._00;result._20=this._01*this._12-this._02*this._11;result._21=this._02*this._10-this._00*this._12;result._22=this._00*this._11-this._01*this._10;return result;};x3dom.fields.SFMatrix4f.prototype.equals=function(that){var eps=0.000000000001;return Math.abs(this._00-that._00)4){m=x3dom.fields.SFMatrix4f.translation(center.negate());m=m.mult(this);var c=x3dom.fields.SFMatrix4f.translation(center);m=m.mult(c);}
+else{m=x3dom.fields.SFMatrix4f.copy(this);}
+var flip=m.decompose(translation,rotation,scaleFactor,scaleOrientation);scaleFactor.setValues(scaleFactor.multiply(flip));};x3dom.fields.SFMatrix4f.prototype.decompose=function(t,r,s,so)
+{var A=x3dom.fields.SFMatrix4f.copy(this);var Q=x3dom.fields.SFMatrix4f.identity(),S=x3dom.fields.SFMatrix4f.identity(),SO=x3dom.fields.SFMatrix4f.identity();t.x=A._03;t.y=A._13;t.z=A._23;A._03=0.0;A._13=0.0;A._23=0.0;A._30=0.0;A._31=0.0;A._32=0.0;var det=A.polarDecompose(Q,S);var f=1.0;if(det<0.0){Q=Q.negate();f=-1.0;}
+r.setValue(Q);S.spectralDecompose(SO,s);so.setValue(SO);return f;};x3dom.fields.SFMatrix4f.prototype.polarDecompose=function(Q,S)
+{var TOL=0.000000000001;var Mk=this.transpose();var Ek=x3dom.fields.SFMatrix4f.identity();var Mk_one=Mk.norm1_3x3();var Mk_inf=Mk.normInf_3x3();var MkAdjT;var MkAdjT_one,MkAdjT_inf;var Ek_one,Mk_det;do
+{MkAdjT=Mk.adjointT_3x3();Mk_det=Mk._00*MkAdjT._00+
+Mk._01*MkAdjT._01+
+Mk._02*MkAdjT._02;if(Mk_det==0.0)
+{x3dom.debug.logWarning("polarDecompose: Mk_det == 0.0");break;}
+MkAdjT_one=MkAdjT.norm1_3x3();MkAdjT_inf=MkAdjT.normInf_3x3();var gamma=Math.sqrt(Math.sqrt((MkAdjT_one*MkAdjT_inf)/(Mk_one*Mk_inf))/Math.abs(Mk_det));var g1=0.5*gamma;var g2=0.5/(gamma*Mk_det);Ek.setValues(Mk);Mk=Mk.multiply(g1);Mk=Mk.addScaled(MkAdjT,g2);Ek=Ek.addScaled(Mk,-1.0);Ek_one=Ek.norm1_3x3();Mk_one=Mk.norm1_3x3();Mk_inf=Mk.normInf_3x3();}while(Ek_one>(Mk_one*TOL));Q.setValues(Mk.transpose());S.setValues(Mk.mult(this));for(var i=0;i<3;++i)
+{for(var j=i;j<3;++j)
+{S['_'+j+i]=0.5*(S['_'+j+i]+S['_'+i+j]);S['_'+i+j]=0.5*(S['_'+j+i]+S['_'+i+j]);}}
+return Mk_det;};x3dom.fields.SFMatrix4f.prototype.spectralDecompose=function(SO,k)
+{var next=[1,2,0];var maxIterations=20;var diag=[this._00,this._11,this._22];var offDiag=[this._12,this._20,this._01];for(var iter=0;iter=0;--i)
+{var p=next[i];var q=next[p];var absOffDiag=Math.abs(offDiag[i]);var g=100.0*absOffDiag;if(absOffDiag>0.0)
+{var t=0,h=diag[q]-diag[p];var absh=Math.abs(h);if(absh+g==absh)
+{t=offDiag[i]/h;}
+else
+{var theta=0.5*h/offDiag[i];t=1.0/(Math.abs(theta)+Math.sqrt(theta*theta+1.0));t=theta<0.0?-t:t;}
+var c=1.0/Math.sqrt(t*t+1.0);var s=t*c;var tau=s/(c+1.0);var ta=t*offDiag[i];offDiag[i]=0.0;diag[p]-=ta;diag[q]+=ta;var offDiagq=offDiag[q];offDiag[q]-=s*(offDiag[p]+tau*offDiagq);offDiag[p]+=s*(offDiagq-tau*offDiag[p]);for(var j=2;j>=0;--j)
+{var a=SO['_'+j+p];var b=SO['_'+j+q];SO['_'+j+p]-=s*(b+tau*a);SO['_'+j+q]+=s*(a-tau*b);}}}}
+k.x=diag[0];k.y=diag[1];k.z=diag[2];};x3dom.fields.SFMatrix4f.prototype.log=function(){var maxiter=12;var eps=1e-12;var A=x3dom.fields.SFMatrix4f.copy(this),Z=x3dom.fields.SFMatrix4f.copy(this);Z._00-=1;Z._11-=1;Z._22-=1;Z._33-=1;var k=0;while(Z.normInfinity()>0.5)
+{A=A.sqrt();Z.setValues(A);Z._00-=1;Z._11-=1;Z._22-=1;Z._33-=1;k++;}
+A._00-=1;A._11-=1;A._22-=1;A._33-=1;A=A.negate();Z.setValues(A);var result=x3dom.fields.SFMatrix4f.copy(A);var i=1;while(Z.normInfinity()>eps&&i0.0001){theta_1=-Math.asin(this._20);theta_2=Math.PI-theta_1;cos_theta_1=Math.cos(theta_1);cos_theta_2=Math.cos(theta_2);psi_1=Math.atan2(this._21/cos_theta_1,this._22/cos_theta_1);psi_2=Math.atan2(this._21/cos_theta_2,this._22/cos_theta_2);phi_1=Math.atan2(this._10/cos_theta_1,this._00/cos_theta_1);phi_2=Math.atan2(this._10/cos_theta_2,this._00/cos_theta_2);return[psi_1,theta_1,phi_1,psi_2,theta_2,phi_2];}
+else{phi=0;if(this._20==-1.0){theta=Math.PI/2.0;psi=phi+Math.atan2(this._01,this._02);}
+else{theta=-(Math.PI/2.0);psi=-phi+Math.atan2(-this._01,-this._02);}
+return[psi,theta,phi,psi,theta,phi];}};x3dom.fields.SFMatrix4f.prototype.toString=function(){return'\n'+
+this._00.toFixed(6)+', '+this._01.toFixed(6)+', '+
+this._02.toFixed(6)+', '+this._03.toFixed(6)+', \n'+
+this._10.toFixed(6)+', '+this._11.toFixed(6)+', '+
+this._12.toFixed(6)+', '+this._13.toFixed(6)+', \n'+
+this._20.toFixed(6)+', '+this._21.toFixed(6)+', '+
+this._22.toFixed(6)+', '+this._23.toFixed(6)+', \n'+
+this._30.toFixed(6)+', '+this._31.toFixed(6)+', '+
+this._32.toFixed(6)+', '+this._33.toFixed(6);};x3dom.fields.SFMatrix4f.prototype.setValueByStr=function(str){var needTranspose=false;var val=/matrix.*\((.+)\)/;if(val.exec(str)){str=RegExp.$1;needTranspose=true;}
+var arr=Array.map(str.split(/[,\s]+/),function(n){return+n;});if(arr.length>=16)
+{if(!needTranspose){this._00=arr[0];this._01=arr[1];this._02=arr[2];this._03=arr[3];this._10=arr[4];this._11=arr[5];this._12=arr[6];this._13=arr[7];this._20=arr[8];this._21=arr[9];this._22=arr[10];this._23=arr[11];this._30=arr[12];this._31=arr[13];this._32=arr[14];this._33=arr[15];}
+else{this._00=arr[0];this._01=arr[4];this._02=arr[8];this._03=arr[12];this._10=arr[1];this._11=arr[5];this._12=arr[9];this._13=arr[13];this._20=arr[2];this._21=arr[6];this._22=arr[10];this._23=arr[14];this._30=arr[3];this._31=arr[7];this._32=arr[11];this._33=arr[15];}}
+else if(arr.length===6){this._00=arr[0];this._01=arr[1];this._02=0;this._03=arr[4];this._10=arr[2];this._11=arr[3];this._12=0;this._13=arr[5];this._20=0;this._21=0;this._22=1;this._23=0;this._30=0;this._31=0;this._32=0;this._33=1;}
+else{x3dom.debug.logWarning("SFMatrix4f - can't parse string: "+str);}
+return this;};x3dom.fields.SFVec2f=function(x,y){if(arguments.length===0){this.x=0;this.y=0;}
+else{this.x=x;this.y=y;}};x3dom.fields.SFVec2f.copy=function(v){return new x3dom.fields.SFVec2f(v.x,v.y);};x3dom.fields.SFVec2f.parse=function(str){var m=/^\s*([+\-]?\d*\.*\d*[eE]?[+\-]?\d*?)\s*,?\s*([+\-]?\d*\.*\d*[eE]?[+\-]?\d*?)\s*$/.exec(str);return new x3dom.fields.SFVec2f(+m[1],+m[2]);};x3dom.fields.SFVec2f.prototype.copy=function(){return x3dom.fields.SFVec2f.copy(this);};x3dom.fields.SFVec2f.prototype.setValues=function(that){this.x=that.x;this.y=that.y;};x3dom.fields.SFVec2f.prototype.at=function(i){switch(i){case 0:return this.x;case 1:return this.y;default:return this.x;}};x3dom.fields.SFVec2f.prototype.add=function(that){return new x3dom.fields.SFVec2f(this.x+that.x,this.y+that.y);};x3dom.fields.SFVec2f.prototype.subtract=function(that){return new x3dom.fields.SFVec2f(this.x-that.x,this.y-that.y);};x3dom.fields.SFVec2f.prototype.negate=function(){return new x3dom.fields.SFVec2f(-this.x,-this.y);};x3dom.fields.SFVec2f.prototype.dot=function(that){return this.x*that.x+this.y*that.y;};x3dom.fields.SFVec2f.prototype.reflect=function(n){var d2=this.dot(n)*2;return new x3dom.fields.SFVec2f(this.x-d2*n.x,this.y-d2*n.y);};x3dom.fields.SFVec2f.prototype.normalize=function(){var n=this.length();if(n){n=1.0/n;}
+return new x3dom.fields.SFVec2f(this.x*n,this.y*n);};x3dom.fields.SFVec2f.prototype.multComponents=function(that){return new x3dom.fields.SFVec2f(this.x*that.x,this.y*that.y);};x3dom.fields.SFVec2f.prototype.multiply=function(n){return new x3dom.fields.SFVec2f(this.x*n,this.y*n);};x3dom.fields.SFVec2f.prototype.divideComponents=function(that){return new x3dom.fields.SFVec2f(this.x/that.x,this.y/that.y);};x3dom.fields.SFVec2f.prototype.divide=function(n){var denom=n?(1.0/n):1.0;return new x3dom.fields.SFVec2f(this.x*denom,this.y*denom);};x3dom.fields.SFVec2f.prototype.equals=function(that,eps){return Math.abs(this.x-that.x)x3dom.fields.Eps)
+{var s=Math.sin(a/2)/t;var c=Math.cos(a/2);return new x3dom.fields.Quaternion(axis.x*s,axis.y*s,axis.z*s,c);}
+else
+{return new x3dom.fields.Quaternion(0,0,0,1);}};x3dom.fields.Quaternion.prototype.copy=function(){return x3dom.fields.Quaternion.copy(this);};x3dom.fields.Quaternion.prototype.toMatrix=function(){var xx=this.x*this.x;var xy=this.x*this.y;var xz=this.x*this.z;var yy=this.y*this.y;var yz=this.y*this.z;var zz=this.z*this.z;var wx=this.w*this.x;var wy=this.w*this.y;var wz=this.w*this.z;return new x3dom.fields.SFMatrix4f(1-2*(yy+zz),2*(xy-wz),2*(xz+wy),0,2*(xy+wz),1-2*(xx+zz),2*(yz-wx),0,2*(xz-wy),2*(yz+wx),1-2*(xx+yy),0,0,0,0,1);};x3dom.fields.Quaternion.prototype.toAxisAngle=function()
+{var x=0,y=0,z=0;var s=0,a=0;var that=this;if(this.w>1)
+{that=x3dom.fields.Quaternion.normalize(this);}
+a=2*Math.acos(that.w);s=Math.sqrt(1-that.w*that.w);if(s==0)
+{x=that.x;y=that.y;z=that.z;}
+else
+{x=that.x/s;y=that.y/s;z=that.z/s;}
+return[new x3dom.fields.SFVec3f(x,y,z),a];};x3dom.fields.Quaternion.prototype.angle=function()
+{return 2*Math.acos(this.w);};x3dom.fields.Quaternion.prototype.setValue=function(matrix)
+{var tr,s=1;var qt=[0,0,0];var i=0,j=0,k=0;var nxt=[1,2,0];tr=matrix._00+matrix._11+matrix._22;if(tr>0.0)
+{s=Math.sqrt(tr+1.0);this.w=s*0.5;s=0.5/s;this.x=(matrix._21-matrix._12)*s;this.y=(matrix._02-matrix._20)*s;this.z=(matrix._10-matrix._01)*s;}
+else
+{if(matrix._11>matrix._00){i=1;}
+else{i=0;}
+if(matrix._22>matrix.at(i,i)){i=2;}
+j=nxt[i];k=nxt[j];s=Math.sqrt(matrix.at(i,i)-(matrix.at(j,j)+matrix.at(k,k))+1.0);qt[i]=s*0.5;s=0.5/s;this.w=(matrix.at(k,j)-matrix.at(j,k))*s;qt[j]=(matrix.at(j,i)+matrix.at(i,j))*s;qt[k]=(matrix.at(k,i)+matrix.at(i,k))*s;this.x=qt[0];this.y=qt[1];this.z=qt[2];}
+if(this.w>1.0||this.w<-1.0)
+{var errThreshold=1+(x3dom.fields.Eps*100);if(this.w>errThreshold||this.w<-errThreshold)
+{x3dom.debug.logInfo("MatToQuat: BUG: |quat[4]| ("+this.w+") >> 1.0 !");}
+if(this.w>1.0){this.w=1.0;}
+else{this.w=-1.0;}}};x3dom.fields.Quaternion.prototype.setFromEuler=function(alpha,beta,gamma){var sx=Math.sin(alpha*0.5);var cx=Math.cos(alpha*0.5);var sy=Math.sin(beta*0.5);var cy=Math.cos(beta*0.5);var sz=Math.sin(gamma*0.5);var cz=Math.cos(gamma*0.5);this.x=(sx*cy*cz)-(cx*sy*sz);this.y=(cx*sy*cz)+(sx*cy*sz);this.z=(cx*cy*sz)-(sx*sy*cz);this.w=(cx*cy*cz)+(sx*sy*sz);};x3dom.fields.Quaternion.prototype.dot=function(that){return this.x*that.x+this.y*that.y+this.z*that.z+this.w*that.w;};x3dom.fields.Quaternion.prototype.add=function(that){return new x3dom.fields.Quaternion(this.x+that.x,this.y+that.y,this.z+that.z,this.w+that.w);};x3dom.fields.Quaternion.prototype.subtract=function(that){return new x3dom.fields.Quaternion(this.x-that.x,this.y-that.y,this.z-that.z,this.w-that.w);};x3dom.fields.Quaternion.prototype.setValues=function(that){this.x=that.x;this.y=that.y;this.z=that.z;this.w=that.w;};x3dom.fields.Quaternion.prototype.equals=function(that,eps){return(this.dot(that)>=1.0-eps);};x3dom.fields.Quaternion.prototype.multScalar=function(s){return new x3dom.fields.Quaternion(this.x*s,this.y*s,this.z*s,this.w*s);};x3dom.fields.Quaternion.prototype.normalize=function(that){var d2=this.dot(that);var id=1.0;if(d2){id=1.0/Math.sqrt(d2);}
+return new x3dom.fields.Quaternion(this.x*id,this.y*id,this.z*id,this.w*id);};x3dom.fields.Quaternion.prototype.negate=function(){return new x3dom.fields.Quaternion(-this.x,-this.y,-this.z,-this.w);};x3dom.fields.Quaternion.prototype.inverse=function(){return new x3dom.fields.Quaternion(-this.x,-this.y,-this.z,this.w);};x3dom.fields.Quaternion.prototype.slerp=function(that,t){var cosom=this.dot(that);var rot1;if(cosom<0.0)
+{cosom=-cosom;rot1=that.negate();}
+else
+{rot1=new x3dom.fields.Quaternion(that.x,that.y,that.z,that.w);}
+var scalerot0,scalerot1;if((1.0-cosom)>0.00001)
+{var omega=Math.acos(cosom);var sinom=Math.sin(omega);scalerot0=Math.sin((1.0-t)*omega)/sinom;scalerot1=Math.sin(t*omega)/sinom;}
+else
+{scalerot0=1.0-t;scalerot1=t;}
+return this.multScalar(scalerot0).add(rot1.multScalar(scalerot1));};x3dom.fields.Quaternion.rotateFromTo=function(fromVec,toVec){var from=fromVec.normalize();var to=toVec.normalize();var cost=from.dot(to);if(cost>0.99999)
+{return new x3dom.fields.Quaternion(0,0,0,1);}
+else if(cost<-0.99999)
+{var cAxis=new x3dom.fields.SFVec3f(1,0,0);var tmp=from.cross(cAxis);if(tmp.length()<0.00001)
+{cAxis.x=0;cAxis.y=1;cAxis.z=0;tmp=from.cross(cAxis);}
+tmp=tmp.normalize();return x3dom.fields.Quaternion.axisAngle(tmp,Math.PI);}
+var axis=fromVec.cross(toVec);axis=axis.normalize();var s=Math.sqrt(0.5*(1.0-cost));axis=axis.multiply(s);s=Math.sqrt(0.5*(1.0+cost));return new x3dom.fields.Quaternion(axis.x,axis.y,axis.z,s);};x3dom.fields.Quaternion.prototype.toGL=function(){var val=this.toAxisAngle();return[val[0].x,val[0].y,val[0].z,val[1]];};x3dom.fields.Quaternion.prototype.toString=function(){return this.x+" "+this.y+" "+this.z+", "+this.w;};x3dom.fields.Quaternion.prototype.setValueByStr=function(str){var m=/^\s*([+\-]?\d*\.*\d*[eE]?[+\-]?\d*?)\s*,?\s*([+\-]?\d*\.*\d*[eE]?[+\-]?\d*?)\s*,?\s*([+\-]?\d*\.*\d*[eE]?[+\-]?\d*?)\s*,?\s*([+\-]?\d*\.*\d*[eE]?[+\-]?\d*?)\s*$/.exec(str);var quat=x3dom.fields.Quaternion.axisAngle(new x3dom.fields.SFVec3f(+m[1],+m[2],+m[3]),+m[4]);this.x=quat.x;this.y=quat.y;this.z=quat.z;this.w=quat.w;return this;};x3dom.fields.SFColor=function(r,g,b){if(arguments.length===0){this.r=0;this.g=0;this.b=0;}
+else{this.r=r;this.g=g;this.b=b;}};x3dom.fields.SFColor.parse=function(str){try{var m=/^\s*([+\-]?\d*\.*\d*[eE]?[+\-]?\d*?)\s*,?\s*([+\-]?\d*\.*\d*[eE]?[+\-]?\d*?)\s*,?\s*([+\-]?\d*\.*\d*[eE]?[+\-]?\d*?)\s*$/.exec(str);return new x3dom.fields.SFColor(+m[1],+m[2],+m[3]);}
+catch(e){return x3dom.fields.SFColor.colorParse(str);}};x3dom.fields.SFColor.copy=function(that){return new x3dom.fields.SFColor(that.r,that.g,that.b);};x3dom.fields.SFColor.prototype.copy=function(){return x3dom.fields.SFColor.copy(this);};x3dom.fields.SFColor.prototype.setHSV=function(h,s,v){x3dom.debug.logWarning("SFColor.setHSV() NYI");};x3dom.fields.SFColor.prototype.getHSV=function(){var h=0,s=0,v=0;x3dom.debug.logWarning("SFColor.getHSV() NYI");return[h,s,v];};x3dom.fields.SFColor.prototype.setValues=function(color){this.r=color.r;this.g=color.g;this.b=color.b;};x3dom.fields.SFColor.prototype.equals=function(that,eps){return Math.abs(this.r-that.r)>>0;};x3dom.fields.SFColorRGBA.colorParse=function(color){var red=0,green=0,blue=0,alpha=0;var color_names={aliceblue:'f0f8ff',antiquewhite:'faebd7',aqua:'00ffff',aquamarine:'7fffd4',azure:'f0ffff',beige:'f5f5dc',bisque:'ffe4c4',black:'000000',blanchedalmond:'ffebcd',blue:'0000ff',blueviolet:'8a2be2',brown:'a52a2a',burlywood:'deb887',cadetblue:'5f9ea0',chartreuse:'7fff00',chocolate:'d2691e',coral:'ff7f50',cornflowerblue:'6495ed',cornsilk:'fff8dc',crimson:'dc143c',cyan:'00ffff',darkblue:'00008b',darkcyan:'008b8b',darkgoldenrod:'b8860b',darkgray:'a9a9a9',darkgreen:'006400',darkkhaki:'bdb76b',darkmagenta:'8b008b',darkolivegreen:'556b2f',darkorange:'ff8c00',darkorchid:'9932cc',darkred:'8b0000',darksalmon:'e9967a',darkseagreen:'8fbc8f',darkslateblue:'483d8b',darkslategray:'2f4f4f',darkturquoise:'00ced1',darkviolet:'9400d3',deeppink:'ff1493',deepskyblue:'00bfff',dimgray:'696969',dodgerblue:'1e90ff',feldspar:'d19275',firebrick:'b22222',floralwhite:'fffaf0',forestgreen:'228b22',fuchsia:'ff00ff',gainsboro:'dcdcdc',ghostwhite:'f8f8ff',gold:'ffd700',goldenrod:'daa520',gray:'808080',green:'008000',greenyellow:'adff2f',honeydew:'f0fff0',hotpink:'ff69b4',indianred:'cd5c5c',indigo:'4b0082',ivory:'fffff0',khaki:'f0e68c',lavender:'e6e6fa',lavenderblush:'fff0f5',lawngreen:'7cfc00',lemonchiffon:'fffacd',lightblue:'add8e6',lightcoral:'f08080',lightcyan:'e0ffff',lightgoldenrodyellow:'fafad2',lightgrey:'d3d3d3',lightgreen:'90ee90',lightpink:'ffb6c1',lightsalmon:'ffa07a',lightseagreen:'20b2aa',lightskyblue:'87cefa',lightslateblue:'8470ff',lightslategray:'778899',lightsteelblue:'b0c4de',lightyellow:'ffffe0',lime:'00ff00',limegreen:'32cd32',linen:'faf0e6',magenta:'ff00ff',maroon:'800000',mediumaquamarine:'66cdaa',mediumblue:'0000cd',mediumorchid:'ba55d3',mediumpurple:'9370d8',mediumseagreen:'3cb371',mediumslateblue:'7b68ee',mediumspringgreen:'00fa9a',mediumturquoise:'48d1cc',mediumvioletred:'c71585',midnightblue:'191970',mintcream:'f5fffa',mistyrose:'ffe4e1',moccasin:'ffe4b5',navajowhite:'ffdead',navy:'000080',oldlace:'fdf5e6',olive:'808000',olivedrab:'6b8e23',orange:'ffa500',orangered:'ff4500',orchid:'da70d6',palegoldenrod:'eee8aa',palegreen:'98fb98',paleturquoise:'afeeee',palevioletred:'d87093',papayawhip:'ffefd5',peachpuff:'ffdab9',peru:'cd853f',pink:'ffc0cb',plum:'dda0dd',powderblue:'b0e0e6',purple:'800080',red:'ff0000',rosybrown:'bc8f8f',royalblue:'4169e1',saddlebrown:'8b4513',salmon:'fa8072',sandybrown:'f4a460',seagreen:'2e8b57',seashell:'fff5ee',sienna:'a0522d',silver:'c0c0c0',skyblue:'87ceeb',slateblue:'6a5acd',slategray:'708090',snow:'fffafa',springgreen:'00ff7f',steelblue:'4682b4',tan:'d2b48c',teal:'008080',thistle:'d8bfd8',tomato:'ff6347',turquoise:'40e0d0',violet:'ee82ee',violetred:'d02090',wheat:'f5deb3',white:'ffffff',whitesmoke:'f5f5f5',yellow:'ffff00',yellowgreen:'9acd32'};if(color_names[color]){color="#"+color_names[color]+"ff";}
+if(color.substr&&color.substr(0,1)==="#"){color=color.substr(1);var len=color.length;if(len===8){red=parseInt("0x"+color.substr(0,2),16)/255.0;green=parseInt("0x"+color.substr(2,2),16)/255.0;blue=parseInt("0x"+color.substr(4,2),16)/255.0;alpha=parseInt("0x"+color.substr(6,2),16)/255.0;}
+else if(len===6){red=parseInt("0x"+color.substr(0,2),16)/255.0;green=parseInt("0x"+color.substr(2,2),16)/255.0;blue=parseInt("0x"+color.substr(4,2),16)/255.0;alpha=1.0;}
+else if(len===4){red=parseInt("0x"+color.substr(0,1),16)/15.0;green=parseInt("0x"+color.substr(1,1),16)/15.0;blue=parseInt("0x"+color.substr(2,1),16)/15.0;alpha=parseInt("0x"+color.substr(3,1),16)/15.0;}
+else if(len===3){red=parseInt("0x"+color.substr(0,1),16)/15.0;green=parseInt("0x"+color.substr(1,1),16)/15.0;blue=parseInt("0x"+color.substr(2,1),16)/15.0;alpha=1.0;}}
+return new x3dom.fields.SFColorRGBA(red,green,blue,alpha);};x3dom.fields.SFImage=function(w,h,c,arr){if(arguments.length===0||!(arr&&arr.map)){this.width=0;this.height=0;this.comp=0;this.array=[];}
+else{this.width=w;this.height=h;this.comp=c;var that=this.array;arr.map(function(v){that.push(v);},this.array);}};x3dom.fields.SFImage.parse=function(str){var img=new x3dom.fields.SFImage();img.setValueByStr(str);return img;};x3dom.fields.SFImage.copy=function(that){var destination=new x3dom.fields.SFImage();destination.width=that.width;destination.height=that.height;destination.comp=that.comp;destination.setPixels(that.getPixels());return destination;};x3dom.fields.SFImage.prototype.copy=function(){return x3dom.fields.SFImage.copy(this);};x3dom.fields.SFImage.prototype.setValueByStr=function(str){var mc=str.match(/(\w+)/g);var n=mc.length;var c2=0;var hex="0123456789ABCDEF";this.array=[];if(n>2){this.width=+mc[0];this.height=+mc[1];this.comp=+mc[2];c2=2*this.comp;}else{this.width=0;this.height=0;this.comp=0;return;}
+var len,i;for(i=3;i>8&255;g=inp&255;this.array.push(r,g);}
+else if(this.comp===3){r=inp>>16&255;g=inp>>8&255;b=inp&255;this.array.push(r,g,b);}
+else if(this.comp===4){r=inp>>24&255;g=inp>>16&255;b=inp>>8&255;a=inp&255;this.array.push(r,g,b,a);}}
+else if(mc[i].substr(1,1).toLowerCase()==="x"){mc[i]=mc[i].substr(2);len=mc[i].length;if(len===c2){if(this.comp===1){r=parseInt("0x"+mc[i].substr(0,2),16);this.array.push(r);}
+else if(this.comp===2){r=parseInt("0x"+mc[i].substr(0,2),16);g=parseInt("0x"+mc[i].substr(2,2),16);this.array.push(r,g);}
+else if(this.comp===3){r=parseInt("0x"+mc[i].substr(0,2),16);g=parseInt("0x"+mc[i].substr(2,2),16);b=parseInt("0x"+mc[i].substr(4,2),16);this.array.push(r,g,b);}
+else if(this.comp===4){r=parseInt("0x"+mc[i].substr(0,2),16);g=parseInt("0x"+mc[i].substr(2,2),16);b=parseInt("0x"+mc[i].substr(4,2),16);a=parseInt("0x"+mc[i].substr(6,2),16);this.array.push(r,g,b,a);}}}}};x3dom.fields.SFImage.prototype.setPixel=function(x,y,color){var startIdx=(y*this.width+x)*this.comp;if(this.comp===1&&startIdx0);}
+return false;};x3dom.fields.MFNode.prototype.addLink=function(node){this.nodes.push(node);return true;};x3dom.fields.MFNode.prototype.rmLink=function(node){for(var i=0,n=this.nodes.length;ix3dom.fields.Eps)
+{r=1.0/this.dir.x;te=(low.x-this.pos.x)*r;tl=(high.x-this.pos.x)*r;if(tlisect){isect=te;}}
+else if(this.dir.x<-x3dom.fields.Eps)
+{r=1.0/this.dir.x;te=(high.x-this.pos.x)*r;tl=(low.x-this.pos.x)*r;if(tlisect){isect=te;}}
+else if(this.pos.xhigh.x)
+{return false;}
+if(this.dir.y>x3dom.fields.Eps)
+{r=1.0/this.dir.y;te=(low.y-this.pos.y)*r;tl=(high.y-this.pos.y)*r;if(tlisect){isect=te;}
+if(isect-out>=x3dom.fields.Eps){return false;}}
+else if(this.dir.y<-x3dom.fields.Eps)
+{r=1.0/this.dir.y;te=(high.y-this.pos.y)*r;tl=(low.y-this.pos.y)*r;if(tlisect){isect=te;}
+if(isect-out>=x3dom.fields.Eps){return false;}}
+else if(this.pos.yhigh.y)
+{return false;}
+if(this.dir.z>x3dom.fields.Eps)
+{r=1.0/this.dir.z;te=(low.z-this.pos.z)*r;tl=(high.z-this.pos.z)*r;if(tlisect){isect=te;}}
+else if(this.dir.z<-x3dom.fields.Eps)
+{r=1.0/this.dir.z;te=(high.z-this.pos.z)*r;tl=(low.z-this.pos.z)*r;if(tlisect){isect=te;}}
+else if(this.pos.zhigh.z)
+{return false;}
+this.enter=isect;this.exit=out;return(isect-outmin.x){this.min.x=min.x;}
+if(this.min.y>min.y){this.min.y=min.y;}
+if(this.min.z>min.z){this.min.z=min.z;}
+if(this.max.x=b){xmax+=a;xmin+=b;}
+else{xmax+=b;xmin+=a;}
+a=this.max.y*m._01;b=this.min.y*m._01;if(a>=b){xmax+=a;xmin+=b;}
+else{xmax+=b;xmin+=a;}
+a=this.max.z*m._02;b=this.min.z*m._02;if(a>=b){xmax+=a;xmin+=b;}
+else{xmax+=b;xmin+=a;}
+a=this.max.x*m._10;b=this.min.x*m._10;if(a>=b){ymax+=a;ymin+=b;}
+else{ymax+=b;ymin+=a;}
+a=this.max.y*m._11;b=this.min.y*m._11;if(a>=b){ymax+=a;ymin+=b;}
+else{ymax+=b;ymin+=a;}
+a=this.max.z*m._12;b=this.min.z*m._12;if(a>=b){ymax+=a;ymin+=b;}
+else{ymax+=b;ymin+=a;}
+a=this.max.x*m._20;b=this.min.x*m._20;if(a>=b){zmax+=a;zmin+=b;}
+else{zmax+=b;zmin+=a;}
+a=this.max.y*m._21;b=this.min.y*m._21;if(a>=b){zmax+=a;zmin+=b;}
+else{zmax+=b;zmin+=a;}
+a=this.max.z*m._22;b=this.min.z*m._22;if(a>=b){zmax+=a;zmin+=b;}
+else{zmax+=b;zmin+=a;}
+this.min.x=xmin;this.min.y=ymin;this.min.z=zmin;this.max.x=xmax;this.max.y=ymax;this.max.z=zmax;this.updateInternals();};x3dom.fields.BoxVolume.prototype.transformFrom=function(m,other)
+{var xmin,ymin,zmin;var xmax,ymax,zmax;xmin=xmax=m._03;ymin=ymax=m._13;zmin=zmax=m._23;var a=other.max.x*m._00;var b=other.min.x*m._00;if(a>=b){xmax+=a;xmin+=b;}
+else{xmax+=b;xmin+=a;}
+a=other.max.y*m._01;b=other.min.y*m._01;if(a>=b){xmax+=a;xmin+=b;}
+else{xmax+=b;xmin+=a;}
+a=other.max.z*m._02;b=other.min.z*m._02;if(a>=b){xmax+=a;xmin+=b;}
+else{xmax+=b;xmin+=a;}
+a=other.max.x*m._10;b=other.min.x*m._10;if(a>=b){ymax+=a;ymin+=b;}
+else{ymax+=b;ymin+=a;}
+a=other.max.y*m._11;b=other.min.y*m._11;if(a>=b){ymax+=a;ymin+=b;}
+else{ymax+=b;ymin+=a;}
+a=other.max.z*m._12;b=other.min.z*m._12;if(a>=b){ymax+=a;ymin+=b;}
+else{ymax+=b;ymin+=a;}
+a=other.max.x*m._20;b=other.min.x*m._20;if(a>=b){zmax+=a;zmin+=b;}
+else{zmax+=b;zmin+=a;}
+a=other.max.y*m._21;b=other.min.y*m._21;if(a>=b){zmax+=a;zmin+=b;}
+else{zmax+=b;zmin+=a;}
+a=other.max.z*m._22;b=other.min.z*m._22;if(a>=b){zmax+=a;zmin+=b;}
+else{zmax+=b;zmin+=a;}
+this.min.x=xmin;this.min.y=ymin;this.min.z=zmin;this.max.x=xmax;this.max.y=ymax;this.max.z=zmax;this.updateInternals();this.valid=true;};x3dom.fields.FrustumVolume=function(clipMat)
+{this.planeNormals=[];this.planeDistances=[];this.directionIndex=[];if(arguments.length===0){return;}
+var planeEquation=[];for(var i=0;i<6;i++){this.planeNormals[i]=new x3dom.fields.SFVec3f(0,0,0);this.planeDistances[i]=0;this.directionIndex[i]=0;planeEquation[i]=new x3dom.fields.SFVec4f(0,0,0,0);}
+planeEquation[0].x=clipMat._30-clipMat._00;planeEquation[0].y=clipMat._31-clipMat._01;planeEquation[0].z=clipMat._32-clipMat._02;planeEquation[0].w=clipMat._33-clipMat._03;planeEquation[1].x=clipMat._30+clipMat._00;planeEquation[1].y=clipMat._31+clipMat._01;planeEquation[1].z=clipMat._32+clipMat._02;planeEquation[1].w=clipMat._33+clipMat._03;planeEquation[2].x=clipMat._30+clipMat._10;planeEquation[2].y=clipMat._31+clipMat._11;planeEquation[2].z=clipMat._32+clipMat._12;planeEquation[2].w=clipMat._33+clipMat._13;planeEquation[3].x=clipMat._30-clipMat._10;planeEquation[3].y=clipMat._31-clipMat._11;planeEquation[3].z=clipMat._32-clipMat._12;planeEquation[3].w=clipMat._33-clipMat._13;planeEquation[4].x=clipMat._30+clipMat._20;planeEquation[4].y=clipMat._31+clipMat._21;planeEquation[4].z=clipMat._32+clipMat._22;planeEquation[4].w=clipMat._33+clipMat._23;planeEquation[5].x=clipMat._30-clipMat._20;planeEquation[5].y=clipMat._31-clipMat._21;planeEquation[5].z=clipMat._32-clipMat._22;planeEquation[5].w=clipMat._33-clipMat._23;for(i=0;i<6;i++){var vectorLength=Math.sqrt(planeEquation[i].x*planeEquation[i].x+
+planeEquation[i].y*planeEquation[i].y+
+planeEquation[i].z*planeEquation[i].z);planeEquation[i].x/=vectorLength;planeEquation[i].y/=vectorLength;planeEquation[i].z/=vectorLength;planeEquation[i].w/=-vectorLength;}
+var updateDirectionIndex=function(normalVec){var ind=0;if(normalVec.x>0)ind|=1;if(normalVec.y>0)ind|=2;if(normalVec.z>0)ind|=4;return ind;};this.planeNormals[3].setValues(planeEquation[0]);this.planeDistances[3]=planeEquation[0].w;this.directionIndex[3]=updateDirectionIndex(this.planeNormals[3]);this.planeNormals[2].setValues(planeEquation[1]);this.planeDistances[2]=planeEquation[1].w;this.directionIndex[2]=updateDirectionIndex(this.planeNormals[2]);this.planeNormals[5].setValues(planeEquation[2]);this.planeDistances[5]=planeEquation[2].w;this.directionIndex[5]=updateDirectionIndex(this.planeNormals[5]);this.planeNormals[4].setValues(planeEquation[3]);this.planeDistances[4]=planeEquation[3].w;this.directionIndex[4]=updateDirectionIndex(this.planeNormals[4]);this.planeNormals[0].setValues(planeEquation[4]);this.planeDistances[0]=planeEquation[4].w;this.directionIndex[0]=updateDirectionIndex(this.planeNormals[0]);this.planeNormals[1].setValues(planeEquation[5]);this.planeDistances[1]=planeEquation[5].w;this.directionIndex[1]=updateDirectionIndex(this.planeNormals[1]);};x3dom.fields.FrustumVolume.prototype.intersect=function(vol,planeMask)
+{if(this.planeNormals.length<6){x3dom.debug.logWarning("FrustumVolume not initialized!");return false;}
+var that=this;var min=vol.min,max=vol.max;var setDirectionIndexPoint=function(index){var pnt=new x3dom.fields.SFVec3f(0,0,0);if(index&1){pnt.x=min.x;}
+else{pnt.x=max.x;}
+if(index&2){pnt.y=min.y;}
+else{pnt.y=max.y;}
+if(index&4){pnt.z=min.z;}
+else{pnt.z=max.z;}
+return pnt;};var pntIsInHalfSpace=function(i,pnt){var s=that.planeNormals[i].dot(pnt)-that.planeDistances[i];return(s>=0);};var isInHalfSpace=function(i){var p=setDirectionIndexPoint(that.directionIndex[i]);return pntIsInHalfSpace(i,p);};var isOutHalfSpace=function(i){var p=setDirectionIndexPoint(that.directionIndex[i]^7);return!pntIsInHalfSpace(i,p);};var mask=1;if(planeMask<0)planeMask=0;for(var i=0;i<6;i++,mask<<=1){if((planeMask&mask)!=0)
+continue;if(isOutHalfSpace(i))
+return-1;if(isInHalfSpace(i))
+planeMask|=mask;}
+return planeMask;};x3dom.docs={};x3dom.docs.specURLMap={CADGeometry:"CADGeometry.html",Core:"core.html",DIS:"dis.html",CubeMapTexturing:"env_texture.html",EnvironmentalEffects:"enveffects.html",EnvironmentalSensor:"envsensor.html",Followers:"followers.html",Geospatial:"geodata.html",Geometry2D:"geometry2D.html",Geometry3D:"geometry3D.html",Grouping:"group.html","H-Anim":"hanim.html",Interpolation:"interp.html",KeyDeviceSensor:"keyboard.html",Layering:"layering.html",Layout:"layout.html",Lighting:"lighting.html",Navigation:"navigation.html",Networking:"networking.html",NURBS:"nurbs.html",ParticleSystems:"particle_systems.html",Picking:"picking.html",PointingDeviceSensor:"pointingsensor.html",Rendering:"rendering.html",RigidBodyPhysics:"rigid_physics.html",Scripting:"scripting.html",Shaders:"shaders.html",Shape:"shape.html",Sound:"sound.html",Text:"text.html",Texturing3D:"texture3D.html",Texturing:"texturing.html",Time:"time.html",EventUtilities:"utils.html",VolumeRendering:"volume.html"};x3dom.docs.specBaseURL="http://www.web3d.org/x3d/specifications/ISO-IEC-19775-1.2-X3D-AbstractSpecification/Part01/components/";x3dom.docs.getNodeTreeInfo=function(){var tn,t;var types="";var objInArray=function(array,obj){for(var i=0;i"+
+t+" "+
+x3dom.nodeTypes[t]._compName+"
";for(var i in x3dom.nodeTypes[t].childTypes[t]){dump(x3dom.nodeTypes[t].childTypes[t][i],indent+1);}};for(tn in x3dom.nodeTypes){var t=x3dom.nodeTypes[tn];if(t.childTypes===undefined){t.childTypes={};}
+while(t.superClass){if(t.superClass.childTypes[t.superClass._typeName]===undefined){t.superClass.childTypes[t.superClass._typeName]=[];}
+if(!objInArray(t.superClass.childTypes[t.superClass._typeName],t._typeName)){t.superClass.childTypes[t.superClass._typeName].push(t._typeName);}
+t=t.superClass;}}
+dump("X3DNode",0);return""+types+"
";};x3dom.docs.getComponentInfo=function(){var components=[];var component;var result="";var c,cn;for(c in x3dom.components){components.push(c);}
+components.sort();for(cn in components){c=components[cn];component=x3dom.components[c];result+="";result+="";for(var t in component){result+="- "+
+t+"
";}
+result+="
";}
+return result;};x3dom.shader={};x3dom.shader.PICKING="picking";x3dom.shader.PICKING_24="picking24";x3dom.shader.PICKING_ID="pickingId";x3dom.shader.PICKING_COLOR="pickingColor";x3dom.shader.PICKING_TEXCOORD="pickingTexCoord";x3dom.shader.FRONTGROUND_TEXTURE="frontgroundTexture";x3dom.shader.BACKGROUND_TEXTURE="backgroundTexture";x3dom.shader.BACKGROUND_SKYTEXTURE="backgroundSkyTexture";x3dom.shader.BACKGROUND_CUBETEXTURE="backgroundCubeTexture";x3dom.shader.BLUR="blur";x3dom.shader.DEPTH="depth";x3dom.shader.NORMAL="normal";x3dom.shader.TEXTURE_REFINEMENT="textureRefinement";x3dom.shader.SSAO="ssao";x3dom.shader.material=function(){var shaderPart="uniform vec3 diffuseColor;\n"+"uniform vec3 specularColor;\n"+"uniform vec3 emissiveColor;\n"+"uniform float shininess;\n"+"uniform float transparency;\n"+"uniform float ambientIntensity;\n";return shaderPart;};x3dom.shader.twoSidedMaterial=function(){var shaderPart="uniform vec3 backDiffuseColor;\n"+"uniform vec3 backSpecularColor;\n"+"uniform vec3 backEmissiveColor;\n"+"uniform float backShininess;\n"+"uniform float backTransparency;\n"+"uniform float backAmbientIntensity;\n";return shaderPart;};x3dom.shader.fog=function(){var shaderPart="uniform vec3 fogColor;\n"+"uniform float fogType;\n"+"uniform float fogRange;\n"+"varying vec3 fragEyePosition;\n"+"float calcFog(in vec3 eye) {\n"+" float f0 = 0.0;\n"+" if(fogType == 0.0) {\n"+" if(length(eye) < fogRange){\n"+" f0 = (fogRange-length(eye)) / fogRange;\n"+" }\n"+" }else{\n"+" if(length(eye) < fogRange){\n"+" f0 = exp(-length(eye) / (fogRange-length(eye) ) );\n"+" }\n"+" }\n"+" f0 = clamp(f0, 0.0, 1.0);\n"+" return f0;\n"+"}\n";return shaderPart;};x3dom.shader.clipPlanes=function(numClipPlanes){var shaderPart="",c;for(c=0;c= lCutOffAngle) return 0.0;\n"+" else if(spotAngle <= lBeamWidth) return attenuation;\n"+" else return attenuation * (spotAngle - lCutOffAngle) / (lBeamWidth - lCutOffAngle);\n"+" }\n"+"}\n";shaderPart+="void getShadowValues(inout vec4 shadowMapValues, inout float viewSampleDepth, in mat4 lightMatrix, in vec4 worldCoords, in sampler2D shadowMap){\n"+" vec4 lightSpaceCoords = lightMatrix*worldCoords;\n"+" vec3 lightSpaceCoordsCart = lightSpaceCoords.xyz / lightSpaceCoords.w;\n"+" vec2 textureCoords = (lightSpaceCoordsCart.xy + 1.0)*0.5;\n"+" viewSampleDepth = lightSpaceCoordsCart.z;\n"+" shadowMapValues = texture2D(shadowMap, textureCoords);\n";if(!x3dom.caps.FP_TEXTURES||x3dom.caps.MOBILE)
+shaderPart+=" shadowMapValues = vec4(1.0,1.0,unpackDepth(shadowMapValues),1.0);\n";shaderPart+="}\n";shaderPart+="void getShadowValuesPointLight(inout vec4 shadowMapValues, inout float viewSampleDepth, in vec3 lLocation, in vec4 worldCoords, in mat4 lightViewMatrix,"+"in mat4 lMatrix_0, in mat4 lMatrix_1, in mat4 lMatrix_2, in mat4 lMatrix_3, in mat4 lMatrix_4, in mat4 lMatrix_5,"+"in sampler2D shadowMap_0, in sampler2D shadowMap_1, in sampler2D shadowMap_2, in sampler2D shadowMap_3,"+"in sampler2D shadowMap_4, in sampler2D shadowMap_5){\n"+" vec4 transformed = lightViewMatrix * worldCoords;\n"+" vec3 lightVec = normalize(transformed.xyz/transformed.w);\n"+" vec3 lightVecAbs = abs(lightVec);\n"+" float maximum = max(max(lightVecAbs.x, lightVecAbs.y),lightVecAbs.z);\n"+" if (lightVecAbs.x == maximum) {\n"+" if (lightVec.x < 0.0) getShadowValues(shadowMapValues, viewSampleDepth, lMatrix_3,worldCoords,shadowMap_3);\n"+" else getShadowValues(shadowMapValues, viewSampleDepth, lMatrix_1,worldCoords,shadowMap_1);\n"+" }\n"+" else if (lightVecAbs.y == maximum) {\n"+" if (lightVec.y < 0.0) getShadowValues(shadowMapValues, viewSampleDepth, lMatrix_4,worldCoords,shadowMap_4);\n"+" else getShadowValues(shadowMapValues, viewSampleDepth, lMatrix_5,worldCoords,shadowMap_5);\n"+" }\n"+" else if (lightVec.z < 0.0) getShadowValues(shadowMapValues, viewSampleDepth, lMatrix_0,worldCoords,shadowMap_0);\n"+" else getShadowValues(shadowMapValues, viewSampleDepth, lMatrix_2,worldCoords,shadowMap_2);\n"+"}\n";shaderPart+="void getShadowValuesCascaded(inout vec4 shadowMapValues, inout float viewSampleDepth, in vec4 worldCoords, in float eyeDepth, in mat4 lMatrix_0, in mat4 lMatrix_1, in mat4 lMatrix_2,"+"in mat4 lMatrix_3, in mat4 lMatrix_4, in mat4 lMatrix_5, in sampler2D shadowMap_0, in sampler2D shadowMap_1, in sampler2D shadowMap_2,"+"in sampler2D shadowMap_3, in sampler2D shadowMap_4, in sampler2D shadowMap_5, in float split_0, in float split_1, in float split_2, in float split_3, in float split_4){\n"+" if (eyeDepth < split_0) getShadowValues(shadowMapValues, viewSampleDepth, lMatrix_0, worldCoords, shadowMap_0);\n"+" else if (eyeDepth < split_1) getShadowValues(shadowMapValues, viewSampleDepth, lMatrix_1, worldCoords, shadowMap_1);\n"+" else if (eyeDepth < split_2) getShadowValues(shadowMapValues, viewSampleDepth, lMatrix_2, worldCoords, shadowMap_2);\n"+" else if (eyeDepth < split_3) getShadowValues(shadowMapValues, viewSampleDepth, lMatrix_3, worldCoords, shadowMap_3);\n"+" else if (eyeDepth < split_4) getShadowValues(shadowMapValues, viewSampleDepth, lMatrix_4, worldCoords, shadowMap_4);\n"+" else getShadowValues(shadowMapValues, viewSampleDepth, lMatrix_5, worldCoords, shadowMap_5);\n"+"}\n";shaderPart+="float ESM(float shadowMapDepth, float viewSampleDepth, float offset){\n";if(!x3dom.caps.FP_TEXTURES||x3dom.caps.MOBILE)
+shaderPart+=" return exp(-80.0*(1.0-offset)*(viewSampleDepth - shadowMapDepth));\n";else shaderPart+=" return shadowMapDepth * exp(-80.0*(1.0-offset)*viewSampleDepth);\n";shaderPart+="}\n";shaderPart+="float VSM(vec2 moments, float viewSampleDepth, float offset){\n"+" viewSampleDepth = (viewSampleDepth + 1.0) * 0.5;\n"+" if (viewSampleDepth <= moments.x) return 1.0;\n"+" float variance = moments.y - moments.x * moments.x;\n"+" variance = max(variance, 0.00002 + offset*0.01);\n"+" float d = viewSampleDepth - moments.x;\n"+" return variance/(variance + d*d);\n"+"}\n";return shaderPart;};x3dom.shader.light=function(numLights){var shaderPart="";for(var l=0;l= lCutOffAngle) spot = 0.0;\n"+" else if(spotAngle <= lBeamWidth) spot = 1.0;\n"+" else spot = (spotAngle - lCutOffAngle ) / (lBeamWidth - lCutOffAngle);\n"+" }\n"+" }\n"+" vec3 H = normalize( L + V );\n"+" float NdotL = clamp(dot(L, N), 0.0, 1.0);\n"+" float NdotH = clamp(dot(H, N), 0.0, 1.0);\n"+" float ambientFactor = lAmbientIntensity * ambIntensity;\n"+" float diffuseFactor = lIntensity * NdotL;\n"+" float specularFactor = lIntensity * pow(NdotH, shin*128.0);\n"+" return vec3(ambientFactor, diffuseFactor, specularFactor) * attentuation * spot;\n"+"}\n";return shaderPart;};x3dom.shader.TBNCalculation=function(){var shaderPart="";shaderPart+="mat3 cotangent_frame(vec3 N, vec3 p, vec2 uv)\n"+"{\n"+" // get edge vectors of the pixel triangle\n"+" vec3 dp1 = dFdx( p );\n"+" vec3 dp2 = dFdy( p );\n"+" vec2 duv1 = dFdx( uv );\n"+" vec2 duv2 = dFdy( uv );\n"+"\n"+" // solve the linear system\n"+" vec3 dp2perp = cross( dp2, N );\n"+" vec3 dp1perp = cross( N, dp1 );\n"+" vec3 T = dp2perp * duv1.x + dp1perp * duv2.x;\n"+" vec3 B = dp2perp * duv1.y + dp1perp * duv2.y;\n"+"\n"+" // construct a scale-invariant frame\n"+" float invmax = inversesqrt( max( dot(T,T), dot(B,B) ) );\n"+" return mat3( T * invmax, B * invmax, N );\n"+"}\n\n";shaderPart+="vec3 perturb_normal( vec3 N, vec3 V, vec2 texcoord )\n"+"{\n"+" // assume N, the interpolated vertex normal and\n"+" // V, the view vector (vertex to eye)\n"+" vec3 map = texture2D(normalMap, texcoord ).xyz;\n"+" map = 2.0 * map - 1.0;\n"+" mat3 TBN = cotangent_frame(N, -V, texcoord);\n"+" return normalize(TBN * map);\n"+"}\n\n";return shaderPart;};x3dom.shader.DynamicShader=function(gl,properties)
+{this.program=gl.createProgram();var vertexShader=this.generateVertexShader(gl,properties);var fragmentShader=this.generateFragmentShader(gl,properties);gl.attachShader(this.program,vertexShader);gl.attachShader(this.program,fragmentShader);gl.bindAttribLocation(this.program,0,"position");gl.linkProgram(this.program);return this.program;};x3dom.shader.DynamicShader.prototype.generateVertexShader=function(gl,properties)
+{var shader="";shader+="uniform mat4 modelViewMatrix;\n";shader+="uniform mat4 modelViewProjectionMatrix;\n";if(properties.POSCOMPONENTS==3){shader+="attribute vec3 position;\n";}else if(properties.POSCOMPONENTS==4){shader+="attribute vec4 position;\n";}
+if(properties.IMAGEGEOMETRY){shader+="uniform vec3 IG_bboxMin;\n";shader+="uniform vec3 IG_bboxMax;\n";shader+="uniform float IG_coordTextureWidth;\n";shader+="uniform float IG_coordTextureHeight;\n";shader+="uniform vec2 IG_implicitMeshSize;\n";for(var i=0;i= PG_numAnchorVertices) {\n";shader+=" vertPosition = floor(vertPosition / PG_powPrecision) * PG_powPrecision;\n";shader+=" vertPosition /= (65536.0 - PG_powPrecision);\n";shader+="}\n";shader+="else {\n";shader+=" vertPosition /= bgPrecisionMax;\n";shader+="}\n";shader+="vertPosition = (vertPosition + offsetVec + PG_bbMin) * PG_maxBBSize;\n";}
+else if(properties.REQUIREBBOX){shader+="vertPosition = bgCenter + bgSize * vertPosition / bgPrecisionMax;\n";}
+if(properties.LIGHTS){if(properties.NORCOMPONENTS==2){if(properties.POSCOMPONENTS==4){shader+="vec3 vertNormal = vec3(position.w / 256.0); \n";shader+="vertNormal.x = floor(vertNormal.x) / 255.0; \n";shader+="vertNormal.y = fract(vertNormal.y) * 1.00392156862745; \n";}
+else if(properties.REQUIREBBOXNOR){shader+="vec3 vertNormal = vec3(normal.xy, 0.0) / bgPrecisionNorMax;\n";}
+shader+="vec2 thetaPhi = 3.14159265358979 * vec2(vertNormal.x, vertNormal.y*2.0-1.0); \n";shader+="vec4 sinCosThetaPhi = sin( vec4(thetaPhi, thetaPhi + 1.5707963267949) ); \n";shader+="vertNormal.x = sinCosThetaPhi.x * sinCosThetaPhi.w; \n";shader+="vertNormal.y = sinCosThetaPhi.x * sinCosThetaPhi.y; \n";shader+="vertNormal.z = sinCosThetaPhi.z; \n";}else{if(properties.NORMALMAP&&properties.NORMALSPACE=="OBJECT"){}else{shader+="vec3 vertNormal = normal;\n";if(properties.REQUIREBBOXNOR){shader+="vertNormal = vertNormal / bgPrecisionNorMax;\n";}
+if(properties.POPGEOMETRY){shader+="vertNormal = 2.0*vertNormal - 1.0;\n";}}}}
+if(properties.VERTEXCOLOR){shader+="fragColor = color;\n";if(properties.REQUIREBBOXCOL){shader+="fragColor = fragColor / bgPrecisionColMax;\n";}}
+if((properties.TEXTURED)&&!properties.SPHEREMAPPING){if(properties.IS_PARTICLE){shader+="vec2 vertTexCoord = vec2(0.0);\n";}
+else{shader+="vec2 vertTexCoord = texcoord;\n";if(properties.REQUIREBBOXTEX){shader+="vertTexCoord = vertTexCoord / bgPrecisionTexMax;\n";}}}}
+if(properties.LIGHTS){if((properties.DISPLACEMENTMAP||properties.DIFFPLACEMENTMAP)&&!properties.NORMALMAP){shader+="float dx = 1.0 / displacementWidth;\n";shader+="float dy = 1.0 / displacementHeight;\n";if(properties.DISPLACEMENTMAP)
+{shader+="float s1 = texture2D(displacementMap, vec2(vertTexCoord.x - dx, 1.0 - vertTexCoord.y)).r;\n";shader+="float s2 = texture2D(displacementMap, vec2(vertTexCoord.x, 1.0 - vertTexCoord.y - dy)).r;\n";shader+="float s3 = texture2D(displacementMap, vec2(vertTexCoord.x + dx, 1.0 - vertTexCoord.y)).r;\n";shader+="float s4 = texture2D(displacementMap, vec2(vertTexCoord.x, 1.0 - vertTexCoord.y + dy)).r;\n";}
+else if(properties.DIFFPLACEMENTMAP)
+{shader+="float s1 = texture2D(diffuseDisplacementMap, vec2(vertTexCoord.x - dx, 1.0 - vertTexCoord.y)).a;\n";shader+="float s2 = texture2D(diffuseDisplacementMap, vec2(vertTexCoord.x, 1.0 - vertTexCoord.y - dy)).a;\n";shader+="float s3 = texture2D(diffuseDisplacementMap, vec2(vertTexCoord.x + dx, 1.0 - vertTexCoord.y)).a;\n";shader+="float s4 = texture2D(diffuseDisplacementMap, vec2(vertTexCoord.x, 1.0 - vertTexCoord.y + dy)).a;\n";}
+shader+="float coef = displacementFactor;\n";shader+="vec3 calcNormal;\n";shader+="if (displacementAxis == 0.0) {\n";shader+="calcNormal = vec3((s1 - s3) * coef, -5.0, (s2 - s4) * coef);\n";shader+="} else if(displacementAxis == 1.0) {\n";shader+="calcNormal = vec3((s1 - s3) * coef, -5.0, (s2 - s4) * coef);\n";shader+="} else {\n";shader+="calcNormal = vec3((s1 - s3) * coef, -(s2 - s4) * coef, 5.0);\n";shader+="}\n";shader+="calcNormal = normalize(calcNormal);\n";shader+="fragNormal = (normalMatrix * vec4(calcNormal, 0.0)).xyz;\n";}
+else if(properties.NORMALMAP&&properties.NORMALSPACE=="OBJECT"){}
+else
+{shader+="fragNormal = (normalMatrix * vec4(vertNormal, 0.0)).xyz;\n";}}
+if(properties.TEXTURED){if(properties.CUBEMAP){shader+="fragViewDir = (viewMatrix[3].xyz);\n";}
+if(properties.SPHEREMAPPING){shader+=" fragTexcoord = 0.5 + fragNormal.xy / 2.0;\n";}else if(properties.TEXTRAFO){shader+=" fragTexcoord = (texTrafoMatrix * vec4(vertTexCoord, 1.0, 1.0)).xy;\n";}else{shader+=" fragTexcoord = vertTexCoord;\n";if(properties.POPGEOMETRY&&x3dom.debug.usePrecisionLevelAsTexCoord===true)
+shader+="fragTexcoord = vec2(0.03125 + 0.9375 * (PG_precisionLevel / 16.0), 1.0);";}
+if(properties.NORMALMAP&&properties.NORMALSPACE=="TANGENT"&&!x3dom.caps.STD_DERIVATIVES){shader+="fragTangent = (normalMatrix * vec4(tangent, 0.0)).xyz;\n";shader+="fragBinormal = (normalMatrix * vec4(binormal, 0.0)).xyz;\n";}}
+if(properties.LIGHTS||properties.FOG||properties.CLIPPLANES){shader+="fragPosition = (modelViewMatrix * vec4(vertPosition, 1.0));\n";if(properties.FOG){shader+="fragEyePosition = eyePosition - fragPosition.xyz;\n";}}
+if(properties.MULTIDIFFALPMAP){shader+="fragID = id;\n";}
+if(properties.DISPLACEMENTMAP){shader+="vertPosition += normalize(vertNormal) * texture2D(displacementMap, vec2(fragTexcoord.x, 1.0-fragTexcoord.y)).r * displacementFactor;\n";}
+else if(properties.DIFFPLACEMENTMAP)
+{shader+="vertPosition += normalize(vertNormal) * texture2D(diffuseDisplacementMap, vec2(fragTexcoord.x, 1.0-fragTexcoord.y)).a * displacementFactor;\n";}
+shader+="gl_Position = modelViewProjectionMatrix * vec4(vertPosition, 1.0);\n";if(properties.IS_PARTICLE){shader+="float spriteDist = (gl_Position.w > 0.000001) ? gl_Position.w : 0.000001;\n";shader+="float pointSize = floor(length(particleSize) * 256.0 / spriteDist + 0.5);\n";shader+="gl_PointSize = clamp(pointSize, 2.0, 256.0);\n";}
+else{shader+="gl_PointSize = 2.0;\n";}
+shader+="}\n";var vertexShader=gl.createShader(gl.VERTEX_SHADER);gl.shaderSource(vertexShader,shader);gl.compileShader(vertexShader);if(!gl.getShaderParameter(vertexShader,gl.COMPILE_STATUS)){x3dom.debug.logInfo("VERTEX:\n"+shader);x3dom.debug.logError("VertexShader "+gl.getShaderInfoLog(vertexShader));}
+return vertexShader;};x3dom.shader.DynamicShader.prototype.generateFragmentShader=function(gl,properties)
+{var shader="#ifdef GL_FRAGMENT_PRECISION_HIGH\n";shader+=" precision highp float;\n";shader+="#else\n";shader+=" precision mediump float;\n";shader+="#endif\n\n";shader+="uniform mat4 modelMatrix;\n";shader+="uniform mat4 modelViewMatrix;\n";shader+="uniform mat4 viewMatrixInverse;\n";shader+=x3dom.shader.material();if(properties.TWOSIDEDMAT){shader+=x3dom.shader.twoSidedMaterial();}
+if(properties.VERTEXCOLOR){if(properties.COLCOMPONENTS==3){shader+="varying vec3 fragColor; \n";}else if(properties.COLCOMPONENTS==4){shader+="varying vec4 fragColor; \n";}}
+if(properties.CUBEMAP||properties.CLIPPLANES)
+{shader+="uniform mat4 modelViewMatrixInverse;\n";}
+if(properties.VERTEXID){shader+="varying float fragID;\n";if(properties.MULTIDIFFALPMAP){shader+="uniform sampler2D multiDiffuseAlphaMap;\n";shader+="uniform float multiDiffuseAlphaWidth;\n";shader+="uniform float multiDiffuseAlphaHeight;\n";}
+if(properties.MULTIEMIAMBMAP){shader+="uniform sampler2D multiEmissiveAmbientMap;\n";shader+="uniform float multiEmissiveAmbientWidth;\n";shader+="uniform float multiEmissiveAmbientHeight;\n";}
+if(properties.MULTISPECSHINMAP){shader+="uniform sampler2D multiSpecularShininessMap;\n";shader+="uniform float multiSpecularShininessWidth;\n";shader+="uniform float multiSpecularShininessHeight;\n";}
+if(properties.MULTIVISMAP){shader+="uniform sampler2D multiVisibilityMap;\n";shader+="uniform float multiVisibilityWidth;\n";shader+="uniform float multiVisibilityHeight;\n";}}
+if(properties.TEXTURED){shader+="varying vec2 fragTexcoord;\n";if((properties.TEXTURED||properties.DIFFUSEMAP)){shader+="uniform sampler2D diffuseMap;\n";}
+if(properties.CUBEMAP){shader+="uniform samplerCube environmentMap;\n";shader+="varying vec3 fragViewDir;\n";shader+="uniform float environmentFactor;\n";}
+if(properties.SPECMAP){shader+="uniform sampler2D specularMap;\n";}
+if(properties.SHINMAP){shader+="uniform sampler2D shininessMap;\n";}
+if(properties.DISPLACEMENTMAP){shader+="uniform sampler2D displacementMap;\n";shader+="uniform float displacementWidth;\n";shader+="uniform float displacementHeight;\n";}
+if(properties.DIFFPLACEMENTMAP){shader+="uniform sampler2D diffuseDisplacementMap;\n";shader+="uniform float displacementWidth;\n";shader+="uniform float displacementHeight;\n";}
+if(properties.NORMALMAP){shader+="uniform sampler2D normalMap;\n";if(properties.NORMALSPACE=="TANGENT"){if(x3dom.caps.STD_DERIVATIVES){shader+="#extension GL_OES_standard_derivatives:enable\n";shader+=x3dom.shader.TBNCalculation();}else{shader+="varying vec3 fragTangent;\n";shader+="varying vec3 fragBinormal;\n";}}else if(properties.NORMALSPACE=="OBJECT"){shader+="uniform mat4 normalMatrix;\n";}}}
+if(properties.FOG){shader+=x3dom.shader.fog();}
+if(properties.LIGHTS||properties.CLIPPLANES)
+{shader+="varying vec4 fragPosition;\n";shader+="uniform float isOrthoView;\n";}
+if(properties.LIGHTS){if(properties.NORMALMAP&&properties.NORMALSPACE=="OBJECT"){}else{shader+="varying vec3 fragNormal;\n";}
+shader+=x3dom.shader.light(properties.LIGHTS);}
+if(properties.CLIPPLANES){shader+=x3dom.shader.clipPlanes(properties.CLIPPLANES);}
+shader+=x3dom.shader.gammaCorrectionDecl(properties);shader+="void main(void) {\n";if(properties.CLIPPLANES)
+{shader+="vec3 cappingColor = calculateClipPlanes();\n";}
+shader+="vec4 color;\n";shader+="color.rgb = "+x3dom.shader.decodeGamma(properties,"diffuseColor")+";\n";shader+="color.a = 1.0 - transparency;\n";shader+="vec3 _emissiveColor = emissiveColor;\n";shader+="float _shininess = shininess;\n";shader+="vec3 _specularColor = specularColor;\n";shader+="float _ambientIntensity = ambientIntensity;\n";shader+="float _transparency = transparency;\n";if(properties.MULTIVISMAP||properties.MULTIDIFFALPMAP||properties.MULTISPECSHINMAP||properties.MULTIEMIAMBMAP){shader+="vec2 idCoord;\n";shader+="float roundedIDVisibility = floor(fragID+0.5);\n";shader+="float roundedIDMaterial = floor(fragID+0.5);\n";shader+="if(!gl_FrontFacing) {\n";shader+=" roundedIDMaterial = floor(fragID + (multiDiffuseAlphaWidth*multiDiffuseAlphaWidth) + 0.5);\n";shader+="}\n";}
+if(properties.MULTIVISMAP){shader+="idCoord.x = mod(roundedIDVisibility, multiVisibilityWidth) * (1.0 / multiVisibilityWidth) + (0.5 / multiVisibilityWidth);\n";shader+="idCoord.y = floor(roundedIDVisibility / multiVisibilityWidth) * (1.0 / multiVisibilityHeight) + (0.5 / multiVisibilityHeight);\n";shader+="vec4 visibility = texture2D( multiVisibilityMap, idCoord );\n";shader+="if (visibility.r < 1.0) discard; \n";}
+if(properties.MULTIDIFFALPMAP){shader+="idCoord.x = mod(roundedIDMaterial, multiDiffuseAlphaWidth) * (1.0 / multiDiffuseAlphaWidth) + (0.5 / multiDiffuseAlphaWidth);\n";shader+="idCoord.y = floor(roundedIDMaterial / multiDiffuseAlphaWidth) * (1.0 / multiDiffuseAlphaHeight) + (0.5 / multiDiffuseAlphaHeight);\n";shader+="vec4 diffAlpha = texture2D( multiDiffuseAlphaMap, idCoord );\n";shader+="color.rgb = "+x3dom.shader.decodeGamma(properties,"diffAlpha.rgb")+";\n";shader+="_transparency = 1.0 - diffAlpha.a;\n";shader+="color.a = diffAlpha.a;\n";}
+if(properties.MULTIEMIAMBMAP){shader+="idCoord.x = mod(roundedIDMaterial, multiDiffuseAlphaWidth) * (1.0 / multiDiffuseAlphaWidth) + (0.5 / multiDiffuseAlphaWidth);\n";shader+="idCoord.y = floor(roundedIDMaterial / multiDiffuseAlphaWidth) * (1.0 / multiDiffuseAlphaHeight) + (0.5 / multiDiffuseAlphaHeight);\n";shader+="vec4 emiAmb = texture2D( multiEmissiveAmbientMap, idCoord );\n";shader+="_emissiveColor = emiAmb.rgb;\n";shader+="_ambientIntensity = emiAmb.a;\n";}
+if(properties.VERTEXCOLOR){if(properties.COLCOMPONENTS===3){shader+="color.rgb = "+x3dom.shader.decodeGamma(properties,"fragColor")+";\n";}else if(properties.COLCOMPONENTS===4){shader+="color = "+x3dom.shader.decodeGamma(properties,"fragColor")+";\n";}}
+if(properties.LIGHTS){shader+="vec3 ambient = vec3(0.0, 0.0, 0.0);\n";shader+="vec3 diffuse = vec3(0.0, 0.0, 0.0);\n";shader+="vec3 specular = vec3(0.0, 0.0, 0.0);\n";shader+="vec3 eye;\n";shader+="if ( isOrthoView > 0.0 ) {\n";shader+=" eye = vec3(0.0, 0.0, 1.0);\n";shader+="} else {\n";shader+=" eye = -fragPosition.xyz;\n";shader+="}\n";if(properties.NORMALMAP&&properties.NORMALSPACE=="OBJECT"){shader+="vec3 normal = vec3(0.0, 0.0, 0.0);\n";}else{shader+="vec3 normal = normalize(fragNormal);\n";}
+if(properties.NORMALMAP){if(properties.NORMALSPACE=="TANGENT"){shader+="vec3 n = normal;\n";if(x3dom.caps.STD_DERIVATIVES){shader+="normal = perturb_normal( n, fragPosition.xyz, vec2(fragTexcoord.x, 1.0-fragTexcoord.y) );\n";}else{shader+="vec3 t = normalize( fragTangent );\n";shader+="vec3 b = normalize( fragBinormal );\n";shader+="mat3 tangentToWorld = mat3(t, b, n);\n";shader+="normal = texture2D( normalMap, vec2(fragTexcoord.x, 1.0-fragTexcoord.y) ).rgb;\n";shader+="normal = 2.0 * normal - 1.0;\n";shader+="normal = normalize( normal * tangentToWorld );\n";shader+="normal.y = -normal.y;\n";shader+="normal.x = -normal.x;\n";}}else if(properties.NORMALSPACE=="OBJECT"){shader+="normal = texture2D( normalMap, vec2(fragTexcoord.x, 1.0-fragTexcoord.y) ).rgb;\n";shader+="normal = 2.0 * normal - 1.0;\n";shader+="normal = (normalMatrix * vec4(normal, 0.0)).xyz;\n";shader+="normal = normalize(normal);\n";}}
+if(properties.SHINMAP){shader+="_shininess = texture2D( shininessMap, vec2(fragTexcoord.x, 1.0-fragTexcoord.y) ).r;\n";}
+if(properties.SPECMAP){shader+="_specularColor = "+x3dom.shader.decodeGamma(properties,"texture2D(specularMap, vec2(fragTexcoord.x, 1.0-fragTexcoord.y)).rgb")+";\n";}
+if(properties.MULTISPECSHINMAP){shader+="idCoord.x = mod(roundedIDMaterial, multiSpecularShininessWidth) * (1.0 / multiSpecularShininessWidth) + (0.5 / multiSpecularShininessWidth);\n";shader+="idCoord.y = floor(roundedIDMaterial / multiSpecularShininessWidth) * (1.0 / multiSpecularShininessHeight) + (0.5 / multiSpecularShininessHeight);\n";shader+="vec4 specShin = texture2D( multiSpecularShininessMap, idCoord );\n";shader+="_specularColor = specShin.rgb;\n";shader+="_shininess = specShin.a;\n";}
+if(!properties.SOLID||properties.TWOSIDEDMAT){shader+="if (dot(normal, eye) < 0.0) {\n";shader+=" normal *= -1.0;\n";shader+="}\n";}
+if(properties.SEPARATEBACKMAT){shader+=" if(!gl_FrontFacing) {\n";shader+=" color.rgb = "+x3dom.shader.decodeGamma(properties,"backDiffuseColor")+";\n";shader+=" color.a = 1.0 - backTransparency;\n";shader+=" _transparency = 1.0 - backTransparency;\n";shader+=" _shininess = backShininess;\n";shader+=" _emissiveColor = backEmissiveColor;\n";shader+=" _specularColor = backSpecularColor;\n";shader+=" _ambientIntensity = backAmbientIntensity;\n";shader+=" }\n";}
+if(properties.LIGHTS){shader+="vec3 ads;\n";for(var l=0;l= PG_numAnchorVertices) {\n";shader+=" vertPosition = floor(vertPosition / PG_powPrecision) * PG_powPrecision;\n";shader+=" vertPosition /= (65536.0 - PG_powPrecision);\n";shader+="}\n";shader+="else {\n";shader+=" vertPosition /= bgPrecisionMax;\n";shader+="}\n";shader+="vertPosition = (vertPosition + offsetVec + PG_bbMin) * PG_maxBBSize;\n";}
+else if(properties.REQUIREBBOX){shader+="vertPosition = bgCenter + bgSize * vertPosition / bgPrecisionMax;\n";}
+if(!properties.POINTLINE2D){if(properties.NORCOMPONENTS==2){if(properties.POSCOMPONENTS==4){shader+="vec3 vertNormal = vec3(position.w / 256.0); \n";shader+="vertNormal.x = floor(vertNormal.x) / 255.0; \n";shader+="vertNormal.y = fract(vertNormal.y) * 1.00392156862745; \n";}else if(properties.REQUIREBBOXNOR){shader+="vec3 vertNormal = vec3(normal.xy, 0.0) / bgPrecisionNorMax;\n";}else{shader+="vec3 vertNormal = vec3(normal.xy, 0.0);\n";}
+shader+="vec2 thetaPhi = 3.14159265358979 * vec2(vertNormal.x, vertNormal.y*2.0-1.0); \n";shader+="vec4 sinCosThetaPhi = vec4(thetaPhi, thetaPhi + 1.5707963267949); \n";shader+="vec4 thetaPhiPow2 = sinCosThetaPhi * sinCosThetaPhi; \n";shader+="vec4 thetaPhiPow3 = thetaPhiPow2 * sinCosThetaPhi; \n";shader+="vec4 thetaPhiPow5 = thetaPhiPow3 * thetaPhiPow2; \n";shader+="vec4 thetaPhiPow7 = thetaPhiPow5 * thetaPhiPow2; \n";shader+="vec4 thetaPhiPow9 = thetaPhiPow7 * thetaPhiPow2; \n";shader+="sinCosThetaPhi += -0.16666666667 * thetaPhiPow3; \n";shader+="sinCosThetaPhi += 0.00833333333 * thetaPhiPow5; \n";shader+="sinCosThetaPhi += -0.000198412698 * thetaPhiPow7; \n";shader+="sinCosThetaPhi += 0.0000027557319 * thetaPhiPow9; \n";shader+="vertNormal.x = sinCosThetaPhi.x * sinCosThetaPhi.w; \n";shader+="vertNormal.y = sinCosThetaPhi.x * sinCosThetaPhi.y; \n";shader+="vertNormal.z = sinCosThetaPhi.z; \n";}else{shader+="vec3 vertNormal = normal;\n";if(properties.REQUIREBBOXNOR){shader+="vertNormal = vertNormal / bgPrecisionNorMax;\n";}
+if(properties.POPGEOMETRY){shader+="vertNormal = 2.0*vertNormal - 1.0;\n";}}}
+if(properties.VERTEXCOLOR){if(properties.COLCOMPONENTS==3){shader+="vec3 vertColor = color;";}else if(properties.COLCOMPONENTS==4){shader+="vec4 vertColor = color;";}
+if(properties.REQUIREBBOXCOL){shader+="vertColor = vertColor / bgPrecisionColMax;\n";}}
+if(properties.TEXTURED){shader+="vec2 vertTexCoord = texcoord;\n";if(properties.REQUIREBBOXTEX){shader+="vertTexCoord = vertTexCoord / bgPrecisionTexMax;\n";}}}
+shader+="vec3 positionMV = (modelViewMatrix * vec4(vertPosition, 1.0)).xyz;\n";if(!properties.POINTLINE2D){shader+="vec3 normalMV = normalize( (normalMatrix * vec4(vertNormal, 0.0)).xyz );\n";}
+shader+="vec3 eye = -positionMV;\n";if(properties.VERTEXCOLOR){shader+="vec3 rgb = vertColor.rgb;\n";if(properties.COLCOMPONENTS==4){shader+="float alpha = vertColor.a;\n";}else if(properties.COLCOMPONENTS==3){shader+="float alpha = 1.0 - transparency;\n";}}else{shader+="vec3 rgb = diffuseColor;\n";shader+="float alpha = 1.0 - transparency;\n";}
+if(properties.TEXTURED){if(properties.CUBEMAP){shader+="fragViewDir = viewMatrix[3].xyz;\n";shader+="fragNormal = normalMV;\n";}else if(properties.SPHEREMAPPING){shader+=" fragTexcoord = 0.5 + normalMV.xy / 2.0;\n";}else if(properties.TEXTRAFO){shader+=" fragTexcoord = (texTrafoMatrix * vec4(vertTexCoord, 1.0, 1.0)).xy;\n";}else{shader+=" fragTexcoord = vertTexCoord;\n";if(properties.POPGEOMETRY&&x3dom.debug.usePrecisionLevelAsTexCoord===true)
+shader+="fragTexcoord = vec2(0.03125 + 0.9375 * (PG_precisionLevel / 16.0), 1.0);";}}
+if(properties.LIGHTS){shader+="vec3 ambient = vec3(0.0, 0.0, 0.0);\n";shader+="vec3 diffuse = vec3(0.0, 0.0, 0.0);\n";shader+="vec3 specular = vec3(0.0, 0.0, 0.0);\n";shader+="float _shininess = shininess;\n";shader+="vec3 _specularColor = specularColor;\n";shader+="vec3 _emissiveColor = emissiveColor;\n";shader+="float _ambientIntensity = ambientIntensity;\n";if(!properties.SOLID||properties.TWOSIDEDMAT){shader+="if (dot(normalMV, eye) < 0.0) {\n";shader+=" normalMV *= -1.0;\n";if(properties.SEPARATEBACKMAT){shader+=" rgb = backDiffuseColor;\n";shader+=" alpha = 1.0 - backTransparency;\n";shader+=" _shininess = backShininess;\n";shader+=" _emissiveColor = backEmissiveColor;\n";shader+=" _specularColor = backSpecularColor;\n";shader+=" _ambientIntensity = backAmbientIntensity;\n";}
+shader+=" }\n";}
+if(properties.LIGHTS){shader+="vec3 ads;\n";for(var l=0;l= 0.0) ? val : -1.0 * val);\n"+"}"+"\n"+"void main(void) {\n"+" vec3 normal = -reflect(normalize(fragNormal), vec3(0.0,0.0,1.0));\n"+" if (magn(normal.y) >= magn(normal.x) && magn(normal.y) >= magn(normal.z))\n"+" normal.xz = -normal.xz;\n"+" gl_FragColor = textureCube(tex, normal);\n"+"}\n";var fragmentShader=gl.createShader(gl.FRAGMENT_SHADER);gl.shaderSource(fragmentShader,shader);gl.compileShader(fragmentShader);if(!gl.getShaderParameter(fragmentShader,gl.COMPILE_STATUS)){x3dom.debug.logError("[BackgroundCubeTextureShader] FragmentShader "+gl.getShaderInfoLog(fragmentShader));}
+return fragmentShader;};x3dom.shader.ShadowRenderingShader=function(gl,shadowedLights)
+{this.program=gl.createProgram();var vertexShader=this.generateVertexShader(gl);var fragmentShader=this.generateFragmentShader(gl,shadowedLights);gl.attachShader(this.program,vertexShader);gl.attachShader(this.program,fragmentShader);gl.bindAttribLocation(this.program,0,"position");gl.linkProgram(this.program);return this.program;};x3dom.shader.ShadowRenderingShader.prototype.generateVertexShader=function(gl)
+{var shader="";shader+="attribute vec2 position;\n";shader+="varying vec2 vPosition;\n";shader+="void main(void) {\n";shader+=" vPosition = position;\n";shader+=" gl_Position = vec4(position, -1.0, 1.0);\n";shader+="}\n";var vertexShader=gl.createShader(gl.VERTEX_SHADER);gl.shaderSource(vertexShader,shader);gl.compileShader(vertexShader);if(!gl.getShaderParameter(vertexShader,gl.COMPILE_STATUS)){x3dom.debug.logError("[ShadowRendering] VertexShader "+gl.getShaderInfoLog(vertexShader));}
+return vertexShader;};x3dom.shader.ShadowRenderingShader.prototype.generateFragmentShader=function(gl,shadowedLights)
+{var shader="#ifdef GL_FRAGMENT_PRECISION_HIGH\n";shader+="precision highp float;\n";shader+="#else\n";shader+=" precision mediump float;\n";shader+="#endif\n\n";shader+="uniform mat4 inverseViewProj;\n";shader+="uniform mat4 inverseProj;\n";shader+="varying vec2 vPosition;\n";shader+="uniform sampler2D sceneMap;\n";for(var i=0;i<5;i++)
+shader+="uniform float cascade"+i+"_Depth;\n";for(var l=0;l 0.0 ) {\n";shader+=" eye = vec3(0.0, 0.0, 1.0);\n";shader+="} else {\n";shader+=" eye = -v_eye.xyz;\n";shader+="}\n";shader+="vec3 ads;\n";for(var l=0;l=0||navigator.appVersion.indexOf("Mobile")>-1||x3dom.caps.MAX_VARYING_VECTORS<=8||x3dom.caps.MAX_VERTEX_TEXTURE_IMAGE_UNITS<2){x3dom.caps.MOBILE=true;}
+if(x3dom.caps.MOBILE){if(forbidMobileShaders){x3dom.caps.MOBILE=false;x3dom.debug.logWarning("Detected mobile graphics card! "+"But being forced to desktop shaders which might not work!");}
+else{x3dom.debug.logWarning("Detected mobile graphics card! "+"Using low quality shaders without ImageGeometry support!");}}
+else{if(forceMobileShaders){x3dom.caps.MOBILE=true;x3dom.debug.logWarning("Detected desktop graphics card! "+"But being forced to mobile shaders with lower quality!");}}}
+catch(ex){x3dom.debug.logWarning("Your browser probably supports an older WebGL version. "+"Please try the old mobile runtime instead:\n"+"http://www.x3dom.org/x3dom/src_mobile/x3dom.js");newCtx=null;}
+return newCtx;}}
+catch(e){x3dom.debug.logWarning(e);}}
+return null;}
+Context.prototype.setupShape=function(gl,drawable,viewarea){var q=0,q6;var textures,t;var vertices,positionBuffer;var texCoordBuffer,normalBuffer,colorBuffer;var indicesBuffer,indexArray;var shape=drawable.shape;var geoNode=shape._cf.geometry.node;if(shape._webgl!==undefined){var needFullReInit=false;if(shape._dirty.colors===true&&shape._webgl.shader.color===undefined&&geoNode._mesh._colors[0].length){needFullReInit=true;}
+if(needFullReInit&&shape._cleanupGLObjects){shape._cleanupGLObjects(true,false);}
+if(shape._dirty.texture===true){if(shape._webgl.texture.length!=shape.getTextures().length){for(t=0;t65535)){indexArray=new Uint32Array(shape._webgl.indexes[q]);shape._webgl.indexType=gl.UNSIGNED_INT;}
+else{indexArray=new Uint16Array(shape._webgl.indexes[q]);shape._webgl.indexType=gl.UNSIGNED_SHORT;}
+gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,indicesBuffer);gl.bufferData(gl.ELEMENT_ARRAY_BUFFER,indexArray,gl.STATIC_DRAW);indexArray=null;shape._webgl.positions[q]=geoNode._mesh._positions[q];gl.deleteBuffer(shape._webgl.buffers[q6+1]);positionBuffer=gl.createBuffer();shape._webgl.buffers[q6+1]=positionBuffer;gl.bindBuffer(gl.ARRAY_BUFFER,positionBuffer);gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,shape._webgl.buffers[q6]);vertices=new Float32Array(shape._webgl.positions[q]);gl.bufferData(gl.ARRAY_BUFFER,vertices,gl.STATIC_DRAW);gl.bindBuffer(gl.ARRAY_BUFFER,positionBuffer);gl.vertexAttribPointer(shape._webgl.shader.position,geoNode._mesh._numPosComponents,shape._webgl.coordType,false,shape._coordStrideOffset[0],shape._coordStrideOffset[1]);vertices=null;}
+shape._dirty.positions=false;shape._dirty.indexes=false;}
+if(shape._dirty.colors==true){if(shape._webgl.shader.color!==undefined){shape._webgl.colors[q]=geoNode._mesh._colors[q];gl.deleteBuffer(shape._webgl.buffers[q6+4]);colorBuffer=gl.createBuffer();shape._webgl.buffers[q6+4]=colorBuffer;colors=new Float32Array(shape._webgl.colors[q]);gl.bindBuffer(gl.ARRAY_BUFFER,colorBuffer);gl.bufferData(gl.ARRAY_BUFFER,colors,gl.STATIC_DRAW);gl.vertexAttribPointer(shape._webgl.shader.color,geoNode._mesh._numColComponents,shape._webgl.colorType,false,shape._colorStrideOffset[0],shape._colorStrideOffset[1]);colors=null;}
+shape._dirty.colors=false;}
+if(shape._dirty.normals==true){if(shape._webgl.shader.normal!==undefined){shape._webgl.normals[q]=geoNode._mesh._normals[q];gl.deleteBuffer(shape._webgl.buffers[q6+2]);normalBuffer=gl.createBuffer();shape._webgl.buffers[q6+2]=normalBuffer;normals=new Float32Array(shape._webgl.normals[q]);gl.bindBuffer(gl.ARRAY_BUFFER,normalBuffer);gl.bufferData(gl.ARRAY_BUFFER,normals,gl.STATIC_DRAW);gl.vertexAttribPointer(shape._webgl.shader.normal,geoNode._mesh._numNormComponents,shape._webgl.normalType,false,shape._normalStrideOffset[0],shape._normalStrideOffset[1]);normals=null;}
+shape._dirty.normals=false;}
+if(shape._dirty.texcoords==true){if(shape._webgl.shader.texcoord!==undefined){shape._webgl.texcoords[q]=geoNode._mesh._texCoords[q];gl.deleteBuffer(shape._webgl.buffers[q6+3]);texCoordBuffer=gl.createBuffer();shape._webgl.buffers[q6+3]=texCoordBuffer;texCoords=new Float32Array(shape._webgl.texcoords[q]);gl.bindBuffer(gl.ARRAY_BUFFER,texCoordBuffer);gl.bufferData(gl.ARRAY_BUFFER,texCoords,gl.STATIC_DRAW);gl.vertexAttribPointer(shape._webgl.shader.texCoord,geoNode._mesh._numTexComponents,shape._webgl.texCoordType,false,shape._texCoordStrideOffset[0],shape._texCoordStrideOffset[1]);texCoords=null;}
+shape._dirty.texcoords=false;}
+if(shape._dirty.specialAttribs==true){if(shape._webgl.shader.particleSize!==undefined){var szArr=geoNode._vf.size.toGL();if(szArr.length){gl.deleteBuffer(shape._webgl.buffers[q6+5]);shape._webgl.buffers[q6+5]=gl.createBuffer();gl.bindBuffer(gl.ARRAY_BUFFER,shape._webgl.buffers[q6+5]);gl.bufferData(gl.ARRAY_BUFFER,new Float32Array(szArr),gl.STATIC_DRAW);}
+shape._dirty.specialAttribs=false;}}}}
+else
+{}
+if(shape._webgl.imageGeometry!=0){for(t=0;t0&&force)||this._parentNodes.length==0))
+{var sp=this._webgl.shader;for(var q=0;q65535)){indexArray=new Uint32Array(shape._webgl.indexes[q]);shape._webgl.indexType=gl.UNSIGNED_INT;}
+else{indexArray=new Uint16Array(shape._webgl.indexes[q]);shape._webgl.indexType=gl.UNSIGNED_SHORT;}
+gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,indicesBuffer);gl.bufferData(gl.ELEMENT_ARRAY_BUFFER,indexArray,gl.STATIC_DRAW);indexArray=null;positionBuffer=gl.createBuffer();shape._webgl.buffers[q6+1]=positionBuffer;gl.bindBuffer(gl.ARRAY_BUFFER,positionBuffer);vertices=new Float32Array(shape._webgl.positions[q]);gl.bufferData(gl.ARRAY_BUFFER,vertices,gl.STATIC_DRAW);gl.bindBuffer(gl.ARRAY_BUFFER,positionBuffer);gl.vertexAttribPointer(sp.position,geoNode._mesh._numPosComponents,shape._webgl.coordType,false,shape._coordStrideOffset[0],shape._coordStrideOffset[1]);gl.enableVertexAttribArray(sp.position);vertices=null;}
+if(sp.normal!==undefined||shape._webgl.normals[q]){normalBuffer=gl.createBuffer();shape._webgl.buffers[q6+2]=normalBuffer;var normals=new Float32Array(shape._webgl.normals[q]);gl.bindBuffer(gl.ARRAY_BUFFER,normalBuffer);gl.bufferData(gl.ARRAY_BUFFER,normals,gl.STATIC_DRAW);gl.vertexAttribPointer(sp.normal,geoNode._mesh._numNormComponents,shape._webgl.normalType,false,shape._normalStrideOffset[0],shape._normalStrideOffset[1]);gl.enableVertexAttribArray(sp.normal);normals=null;}
+if(sp.texcoord!==undefined){var texcBuffer=gl.createBuffer();shape._webgl.buffers[q6+3]=texcBuffer;var texCoords=new Float32Array(shape._webgl.texcoords[q]);gl.bindBuffer(gl.ARRAY_BUFFER,texcBuffer);gl.bufferData(gl.ARRAY_BUFFER,texCoords,gl.STATIC_DRAW);gl.vertexAttribPointer(sp.texcoord,geoNode._mesh._numTexComponents,shape._webgl.texCoordType,false,shape._texCoordStrideOffset[0],shape._texCoordStrideOffset[1]);gl.enableVertexAttribArray(sp.texcoord);texCoords=null;}
+if(sp.color!==undefined){colorBuffer=gl.createBuffer();shape._webgl.buffers[q6+4]=colorBuffer;var colors=new Float32Array(shape._webgl.colors[q]);gl.bindBuffer(gl.ARRAY_BUFFER,colorBuffer);gl.bufferData(gl.ARRAY_BUFFER,colors,gl.STATIC_DRAW);gl.vertexAttribPointer(sp.color,geoNode._mesh._numColComponents,shape._webgl.colorType,false,shape._colorStrideOffset[0],shape._colorStrideOffset[1]);gl.enableVertexAttribArray(sp.color);colors=null;}
+if(sp.particleSize!==undefined){var sizeArr=geoNode._vf.size.toGL();if(sizeArr.length){var sizeBuffer=gl.createBuffer();shape._webgl.buffers[q6+5]=sizeBuffer;gl.bindBuffer(gl.ARRAY_BUFFER,sizeBuffer);gl.bufferData(gl.ARRAY_BUFFER,new Float32Array(sizeArr),gl.STATIC_DRAW);}}}
+for(var df in geoNode._mesh._dynamicFields)
+{if(!geoNode._mesh._dynamicFields.hasOwnProperty(df))
+continue;var attrib=geoNode._mesh._dynamicFields[df];shape._webgl.dynamicFields[currAttribs]={buf:{},name:df,numComponents:attrib.numComponents};if(sp[df]!==undefined){var attribBuffer=gl.createBuffer();shape._webgl.dynamicFields[currAttribs++].buf=attribBuffer;var attribs=new Float32Array(attrib.value);gl.bindBuffer(gl.ARRAY_BUFFER,attribBuffer);gl.bufferData(gl.ARRAY_BUFFER,attribs,gl.STATIC_DRAW);gl.vertexAttribPointer(sp[df],attrib.numComponents,gl.FLOAT,false,0,0);attribs=null;}}}};Context.prototype.setupScene=function(gl,bgnd){var sphere=null;var texture=null;var that=this;if(bgnd._webgl!==undefined){if(!bgnd._dirty){return;}
+if(bgnd._webgl.texture!==undefined&&bgnd._webgl.texture){gl.deleteTexture(bgnd._webgl.texture);}
+if(bgnd._cleanupGLObjects){bgnd._cleanupGLObjects();}
+bgnd._webgl={};}
+bgnd._dirty=false;var url=bgnd.getTexUrl();var i=0;var w=1,h=1;if(url.length>0&&url[0].length>0){if(url.length>=6&&url[1].length>0&&url[2].length>0&&url[3].length>0&&url[4].length>0&&url[5].length>0){sphere=new x3dom.nodeTypes.Sphere();bgnd._webgl={positions:sphere._mesh._positions[0],indexes:sphere._mesh._indices[0],buffers:[{},{}]};bgnd._webgl.primType=gl.TRIANGLES;bgnd._webgl.shader=this.cache.getShader(gl,x3dom.shader.BACKGROUND_CUBETEXTURE);bgnd._webgl.texture=x3dom.Utils.createTextureCube(gl,bgnd._nameSpace.doc,url,true,bgnd._vf.crossOrigin,true,false);}
+else{bgnd._webgl={positions:[-w,-h,0,-w,h,0,w,-h,0,w,h,0],indexes:[0,1,2,3],buffers:[{},{}]};url=bgnd._nameSpace.getURL(url[0]);bgnd._webgl.texture=x3dom.Utils.createTexture2D(gl,bgnd._nameSpace.doc,url,true,bgnd._vf.crossOrigin,false,false);bgnd._webgl.primType=gl.TRIANGLE_STRIP;bgnd._webgl.shader=this.cache.getShader(gl,x3dom.shader.BACKGROUND_TEXTURE);}}
+else{if(bgnd.getSkyColor().length>1||bgnd.getGroundColor().length){sphere=new x3dom.nodeTypes.Sphere();texture=gl.createTexture();bgnd._webgl={positions:sphere._mesh._positions[0],texcoords:sphere._mesh._texCoords[0],indexes:sphere._mesh._indices[0],buffers:[{},{},{}],texture:texture,primType:gl.TRIANGLES};var N=x3dom.Utils.nextHighestPowerOfTwo(bgnd.getSkyColor().length+bgnd.getGroundColor().length+2);N=(N<512)?512:N;var n=bgnd._vf.groundAngle.length;var tmp=[],arr=[];var colors=[],sky=[0];for(i=0;i0||bgnd._vf.groundColor.length==1){if(sky[sky.length-1]=0;i--){if((i==n-1)&&(Math.PI-bgnd._vf.groundAngle[i]<=Math.PI/2)){sky[sky.length]=Math.PI/2;colors[colors.length]=bgnd._vf.groundColor[bgnd._vf.groundColor.length-1];}
+sky[sky.length]=Math.PI-bgnd._vf.groundAngle[i];colors[colors.length]=bgnd._vf.groundColor[i+1];}
+if(n==0&&bgnd._vf.groundColor.length==1){sky[sky.length]=Math.PI/2;colors[colors.length]=bgnd._vf.groundColor[0];}
+sky[sky.length]=Math.PI;colors[colors.length]=bgnd._vf.groundColor[0];}
+else{if(sky[sky.length-1]viewport.y)
+{ratio=viewport.x/texture.x
+texture.x=viewport.x;texture.y=texture.y*ratio;}
+else
+{ratio=viewport.y/texture.y
+texture.y=viewport.y;texture.x=texture.x*ratio;}
+var scale=viewport.divideComponents(texture);var translation=texture.subtract(viewport).multiply(0.5).divideComponents(texture);}
+else
+{var scale=new x3dom.fields.SFVec2f(1.0,1.0);var translation=new x3dom.fields.SFVec2f(0.0,0.0);}
+sp.scale=scale.toGL();sp.translation=translation.toGL();}
+gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,bgnd._webgl.buffers[0]);gl.bindBuffer(gl.ARRAY_BUFFER,bgnd._webgl.buffers[1]);gl.vertexAttribPointer(sp.position,3,gl.FLOAT,false,0,0);gl.enableVertexAttribArray(sp.position);gl.drawElements(bgnd._webgl.primType,bgnd._webgl.indexes.length,gl.UNSIGNED_SHORT,0);gl.disableVertexAttribArray(sp.position);gl.activeTexture(gl.TEXTURE0);if(bgnd._webgl.texture.textureCubeReady){gl.bindTexture(gl.TEXTURE_CUBE_MAP,null);}
+else{gl.bindTexture(gl.TEXTURE_2D,null);}
+gl.clear(gl.DEPTH_BUFFER_BIT);}};};Context.prototype.setupFgnds=function(gl,scene){if(scene._fgnd!==undefined){return;}
+var that=this;var w=1,h=1;scene._fgnd={};scene._fgnd._webgl={positions:[-w,-h,0,-w,h,0,w,-h,0,w,h,0],indexes:[0,1,2,3],buffers:[{},{}]};scene._fgnd._webgl.primType=gl.TRIANGLE_STRIP;scene._fgnd._webgl.shader=this.cache.getShader(gl,x3dom.shader.FRONTGROUND_TEXTURE);var sp=scene._fgnd._webgl.shader;var positionBuffer=gl.createBuffer();scene._fgnd._webgl.buffers[1]=positionBuffer;gl.bindBuffer(gl.ARRAY_BUFFER,positionBuffer);var vertices=new Float32Array(scene._fgnd._webgl.positions);gl.bufferData(gl.ARRAY_BUFFER,vertices,gl.STATIC_DRAW);gl.bindBuffer(gl.ARRAY_BUFFER,positionBuffer);gl.vertexAttribPointer(sp.position,3,gl.FLOAT,false,0,0);var indicesBuffer=gl.createBuffer();scene._fgnd._webgl.buffers[0]=indicesBuffer;var indexArray=new Uint16Array(scene._fgnd._webgl.indexes);gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,indicesBuffer);gl.bufferData(gl.ELEMENT_ARRAY_BUFFER,indexArray,gl.STATIC_DRAW);vertices=null;indexArray=null;scene._fgnd._webgl.render=function(gl,tex){scene._fgnd._webgl.texture=tex;that.stateManager.frontFace(gl.CCW);that.stateManager.disable(gl.CULL_FACE);that.stateManager.disable(gl.DEPTH_TEST);that.stateManager.useProgram(sp);if(!sp.tex){sp.tex=0;}
+gl.activeTexture(gl.TEXTURE0);gl.bindTexture(gl.TEXTURE_2D,scene._fgnd._webgl.texture);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MAG_FILTER,gl.NEAREST);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,gl.NEAREST);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_S,gl.CLAMP_TO_EDGE);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_T,gl.CLAMP_TO_EDGE);gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,scene._fgnd._webgl.buffers[0]);gl.bindBuffer(gl.ARRAY_BUFFER,scene._fgnd._webgl.buffers[1]);gl.vertexAttribPointer(sp.position,3,gl.FLOAT,false,0,0);gl.enableVertexAttribArray(sp.position);gl.drawElements(scene._fgnd._webgl.primType,scene._fgnd._webgl.indexes.length,gl.UNSIGNED_SHORT,0);gl.disableVertexAttribArray(sp.position);gl.activeTexture(gl.TEXTURE0);gl.bindTexture(gl.TEXTURE_2D,null);};};Context.prototype.renderShadowPass=function(gl,viewarea,mat_scene,mat_view,targetFbo,camOffset,isCameraView)
+{var scene=viewarea._scene;var indicesReady=false;this.stateManager.bindFramebuffer(gl.FRAMEBUFFER,targetFbo.fbo);this.stateManager.viewport(0,0,targetFbo.width,targetFbo.height);gl.clearColor(1.0,1.0,1.0,0.0);gl.clearDepth(1.0);gl.clear(gl.COLOR_BUFFER_BIT|gl.DEPTH_BUFFER_BIT);this.stateManager.depthFunc(gl.LEQUAL);this.stateManager.enable(gl.DEPTH_TEST);this.stateManager.enable(gl.CULL_FACE);this.stateManager.disable(gl.BLEND);var bgCenter=x3dom.fields.SFVec3f.NullVector.toGL();var bgSize=x3dom.fields.SFVec3f.OneVector.toGL();var env=scene.getEnvironment();var excludeTrans=env._vf.shadowExcludeTransparentObjects;var i,n=scene.drawableCollection.length;for(i=0;i0||s_gl.popGeometry>0)){for(v=0,offset=0,v_n=s_geo._vf.vertexCount.length;v>>8)/255.0;sp.from=from.toGL();sp.sceneSize=sceneSize;if((s_gl.binaryGeometry!=0||s_gl.externalGeometry!=0)&&s_geo._vf["idsPerVertex"]==true){sp.shadowIDs=(shape._vf.idOffset+x3dom.nodeTypes.Shape.objectID+2);}
+if(s_gl.coordType!=gl.FLOAT){if(!s_gl.popGeometry&&(x3dom.Utils.isUnsignedType(s_geo._vf.coordType))){sp.bgCenter=s_geo.getMin().toGL();}
+else{sp.bgCenter=s_geo._vf.position.toGL();}
+sp.bgSize=s_geo._vf.size.toGL();sp.bgPrecisionMax=s_geo.getPrecisionMax('coordType');}
+if(pickMode==1&&s_gl.colorType!=gl.FLOAT){sp.bgPrecisionColMax=s_geo.getPrecisionMax('colorType');}
+if(pickMode==2&&s_gl.texCoordType!=gl.FLOAT){sp.bgPrecisionTexMax=s_geo.getPrecisionMax('texCoordType');}
+if(shape._clipPlanes){sp.modelViewMatrix=mat_view.mult(trafo).toGL();sp.viewMatrixInverse=mat_view.inverse().toGL();for(var cp=0;cp0||s_gl.popGeometry>0)){for(v=0,offset=0,v_n=s_geo._vf.vertexCount.length;v0)
+polyMode=(renderMode==1)?gl.POINTS:gl.LINES;mesh.render(gl,polyMode);}
+else
+if(!(sp.position!==undefined&&s_gl.buffers[q6+1]&&s_gl.indexes[q]))
+continue;indicesReady=false;if(s_gl.externalGeometry==0){if(!(sp.position!==undefined&&s_gl.buffers[q6+1]&&(s_gl.indexes[q])))
+continue;if(s_gl.buffers[q6]){if(isParticleSet&&s_geo.drawOrder()!="any"){var indexArray,zPos=[];var pnts=s_geo._cf.coord.node.getPoints();var pn=(pnts.length==s_gl.indexes[q].length)?s_gl.indexes[q].length:0;for(var i=0;i65535)){indexArray=new Uint32Array(shape._webgl.indexes[q]);shape._webgl.indexType=gl.UNSIGNED_INT;}
+else{indexArray=new Uint16Array(shape._webgl.indexes[q]);shape._webgl.indexType=gl.UNSIGNED_SHORT;}
+gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,s_gl.buffers[q6]);gl.bufferData(gl.ELEMENT_ARRAY_BUFFER,indexArray,gl.DYNAMIC_DRAW);indexArray=null;}
+gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,s_gl.buffers[q6]);indicesReady=true;}
+this.setVertexAttribPointerPosition(gl,shape,q6,q);this.setVertexAttribPointerNormal(gl,shape,q6,q);this.setVertexAttribPointerTexCoord(gl,shape,q6,q);this.setVertexAttribPointerColor(gl,shape,q6,q);if((sp.id!==undefined||sp.particleSize!==undefined)&&shape._webgl.buffers[q6+5]){gl.bindBuffer(gl.ARRAY_BUFFER,shape._webgl.buffers[q6+5]);if((s_gl.binaryGeometry!=0||s_gl.externalGeometry!=0)&&s_geo._vf["idsPerVertex"]==true){gl.vertexAttribPointer(sp.id,1,gl.FLOAT,false,4,0);gl.enableVertexAttribArray(sp.id);}
+else if(isParticleSet){gl.vertexAttribPointer(sp.particleSize,3,gl.FLOAT,false,0,0);gl.enableVertexAttribArray(sp.particleSize);}}
+if(s_gl.popGeometry!=0&&s_gl.buffers[q6+5]){gl.bindBuffer(gl.ARRAY_BUFFER,s_gl.buffers[q6+5]);gl.vertexAttribPointer(sp.PG_vertexID,1,gl.FLOAT,false,4,0);gl.enableVertexAttribArray(sp.PG_vertexID);}
+var indOff,renderMode=viewarea.getRenderMode();if(renderMode>0){var polyMode=(renderMode==1)?gl.POINTS:gl.LINES;if(indicesReady&&(s_gl.binaryGeometry>0||s_gl.popGeometry>0)){for(v=0,offset=0,v_n=s_geo._vf.vertexCount.length;v0||s_gl.popGeometry>0)){for(v=0,offset=0,v_n=s_geo._vf.vertexCount.length;v0){var viewpoint=scene.getViewpoint();var imgPlaneHeightAtDistOne=viewpoint.getImgPlaneHeightAtDistOne();var near=viewpoint.getNear();var center=model_view.multMatrixPnt(popGeo._vf.position);var tightRad=model_view.multMatrixVec(popGeo._vf.size).length()*0.5;var largestRad=model_view.multMatrixVec(popGeo._vf.maxBBSize).length()*0.5;var dist=Math.max(-center.z-tightRad,near);var projPixelLength=dist*(imgPlaneHeightAtDistOne/viewarea._height);var arg=(2*largestRad)/(tol*projPixelLength);currentLOD=Math.ceil(Math.log(arg)/0.693147180559945);currentLOD=(currentLOD<1)?1:((currentLOD>16)?16:currentLOD);}
+var minPrec=popGeo._vf.minPrecisionLevel,maxPrec=popGeo._vf.maxPrecisionLevel;currentLOD=(minPrec!=-1&¤tLODmaxPrec)?maxPrec:currentLOD;var currentLOD_min=(s_gl.levelsAvailable4){mat_view=viewMat;mat_scene=sceneMat;}
+else{mat_view=viewarea._last_mat_view;mat_scene=viewarea._last_mat_scene;}
+var min=x3dom.fields.SFVec3f.copy(scene._lastMin);var max=x3dom.fields.SFVec3f.copy(scene._lastMax);var from=mat_view.inverse().e3();var _min=x3dom.fields.SFVec3f.copy(from);var _max=x3dom.fields.SFVec3f.copy(from);if(_min.x>min.x){_min.x=min.x;}
+if(_min.y>min.y){_min.y=min.y;}
+if(_min.z>min.z){_min.z=min.z;}
+if(_max.x0&&shapeId>>8,buttonState&255);if(objId>=baseID){objId-=baseID;var hitObject;if(pickMode!=4){viewarea._pickingInfo.pickPos=pickPos;viewarea._pick.setValues(pickPos);viewarea._pickingInfo.pickNorm=pickNorm;viewarea._pickNorm.setValues(pickNorm);viewarea._pickingInfo.pickObj=null;viewarea._pickingInfo.lastClickObj=null;hitObject=scene._xmlNode;}
+else{viewarea._pickingInfo.pickObj=x3dom.nodeTypes.Shape.idMap.nodeID[shapeId];hitObject=viewarea._pickingInfo.pickObj._xmlNode;}
+if(scene._multiPartMap){var mp,multiPart;for(mp=0;mp=multiPart._minId&&objId<=multiPart._maxId)
+{hitObject=multiPart._xmlNode;event={target:multiPart._xmlNode,button:button,mouseup:((buttonState>>>8)>0),layerX:x,layerY:y,pickedId:objId,worldX:pickPos.x,worldY:pickPos.y,worldZ:pickPos.z,normalX:pickNorm.x,normalY:pickNorm.y,normalZ:pickNorm.z,hitPnt:pickPos.toGL(),hitObject:hitObject,cancelBubble:false,stopPropagation:function(){this.cancelBubble=true;},preventDefault:function(){this.cancelBubble=true;}};multiPart.handleEvents(event);}
+else
+{event={target:multiPart._xmlNode,button:button,mouseup:((buttonState>>>8)>0),layerX:x,layerY:y,pickedId:-1,cancelBubble:false,stopPropagation:function(){this.cancelBubble=true;},preventDefault:function(){this.cancelBubble=true;}};multiPart.handleEvents(event);}}}
+shadowObjectIdChanged=(viewarea._pickingInfo.shadowObjectId!=objId);viewarea._pickingInfo.lastShadowObjectId=viewarea._pickingInfo.shadowObjectId;viewarea._pickingInfo.shadowObjectId=objId;if((shadowObjectIdChanged||button)&&scene._xmlNode&&(scene._xmlNode["on"+eventType]||scene._xmlNode.hasAttribute("on"+eventType)||scene._listeners[eventType]))
+{event={target:scene._xmlNode,type:eventType,button:button,mouseup:((buttonState>>>8)>0),layerX:x,layerY:y,shadowObjectId:objId,worldX:pickPos.x,worldY:pickPos.y,worldZ:pickPos.z,normalX:pickNorm.x,normalY:pickNorm.y,normalZ:pickNorm.z,hitPnt:pickPos.toGL(),hitObject:hitObject,cancelBubble:false,stopPropagation:function(){this.cancelBubble=true;},preventDefault:function(){this.cancelBubble=true;}};scene.callEvtHandler(("on"+eventType),event);}
+if(scene._shadowIdMap&&scene._shadowIdMap.mapping&&objId>>8)>0),layerX:x,layerY:y,pickedId:-1,cancelBubble:false,stopPropagation:function(){this.cancelBubble=true;},preventDefault:function(){this.cancelBubble=true;}};multiPart.handleEvents(event);}}
+shadowObjectIdChanged=(viewarea._pickingInfo.shadowObjectId!=-1);viewarea._pickingInfo.shadowObjectId=-1;if(shadowObjectIdChanged&&scene._xmlNode&&(scene._xmlNode["on"+eventType]||scene._xmlNode.hasAttribute("on"+eventType)||scene._listeners[eventType]))
+{event={target:scene._xmlNode,type:eventType,button:button,mouseup:((buttonState>>>8)>0),layerX:x,layerY:y,shadowObjectId:viewarea._pickingInfo.shadowObjectId,cancelBubble:false,stopPropagation:function(){this.cancelBubble=true;},preventDefault:function(){this.cancelBubble=true;}};scene.callEvtHandler(("on"+eventType),event);}
+if(objId>0){viewarea._pickingInfo.pickPos=pickPos;viewarea._pickingInfo.pickNorm=pickNorm;viewarea._pickingInfo.pickObj=x3dom.nodeTypes.Shape.idMap.nodeID[objId];}
+else{viewarea._pickingInfo.pickObj=null;viewarea._pickingInfo.lastClickObj=null;}}}
+var pickTime=x3dom.Utils.stopMeasure("picking");this.x3dElem.runtime.addMeasurement('PICKING',pickTime);return true;};Context.prototype.pickRect=function(viewarea,x1,y1,x2,y2)
+{var gl=this.ctx3d;var scene=viewarea?viewarea._scene:null;if(!gl||!scene||!scene._webgl||!scene.drawableCollection)
+return false;var from=viewarea._last_mat_view.inverse().e3();var sceneSize=scene._lastMax.subtract(scene._lastMin).length();var x=(x1<=x2)?x1:x2;var y=(y1>=y2)?y1:y2;var width=(1+Math.abs(x2-x1))*scene._webgl.pickScale;var height=(1+Math.abs(y2-y1))*scene._webgl.pickScale;this.renderPickingPass(gl,scene,viewarea._last_mat_view,viewarea._last_mat_scene,from,sceneSize,0,x,y,(width<1)?1:width,(height<1)?1:height);var index;var pickedObjects=[];for(index=0;scene._webgl.fboPick.pixelData&&index0)
+pickedObjects.push(objId);}
+pickedObjects.sort();var pickedObjectsTemp=(function(arr){var a=[],l=arr.length;for(var i=0;i=baseID)
+{objId-=baseID;if(scene._multiPartMap){var mp,multiPart,colorMap,emissiveMap,specularMap,visibilityMap,partID;for(mp=0;mp=multiPart._minId&&objId<=multiPart._maxId){partID=multiPart._idMap.mapping[objId-multiPart._minId].name;hitObject=new x3dom.Parts(multiPart,[objId],colorMap,emissiveMap,specularMap,visibilityMap);pickedNode={"partID":partID,"part":hitObject};pickedNodes.push(pickedNode);}}}}
+else
+{hitObject=x3dom.nodeTypes.Shape.idMap.nodeID[objId];hitObject=(hitObject&&hitObject._xmlNode)?hitObject._xmlNode:null;if(hitObject)
+pickedNodes.push(hitObject);}}
+return pickedNodes;};Context.prototype.renderScene=function(viewarea)
+{var gl=this.ctx3d;var scene=viewarea._scene;if(gl===null||scene===null){return;}
+var rentex=viewarea._doc._nodeBag.renderTextures;var rt_tex,rtl_i,rtl_n=rentex.length;var texProp=null;var type=gl.UNSIGNED_BYTE;var shadowType=gl.UNSIGNED_BYTE;var nearestFilt=false;if(x3dom.caps.FP_TEXTURES&&!x3dom.caps.MOBILE){type=gl.FLOAT;shadowType=gl.FLOAT;if(!x3dom.caps.FPL_TEXTURES){nearestFilt=true;}}
+var shadowedLights,numShadowMaps;var i,j,n,size,sizeAvailable;var texType,refinementPos;var vertices=[-1,-1,1,-1,-1,1,-1,1,1,-1,1,1];scene.updateVolume();if(!scene._webgl)
+{scene._webgl={};this.setupFgnds(gl,scene);scene._webgl.pickScale=0.5;scene._webgl._currFboWidth=Math.round(this.canvas.width*scene._webgl.pickScale);scene._webgl._currFboHeight=Math.round(this.canvas.height*scene._webgl.pickScale);scene._webgl.fboPick=x3dom.Utils.initFBO(gl,scene._webgl._currFboWidth,scene._webgl._currFboHeight,gl.UNSIGNED_BYTE,false,true);scene._webgl.fboPick.pixelData=null;scene._webgl.normalShader=this.cache.getShader(gl,x3dom.shader.NORMAL);scene._webgl.fboShadow=[];shadowedLights=viewarea.getShadowedLights();n=shadowedLights.length;for(i=0;i0||x3dom.SSAO.isEnabled(scene))
+scene._webgl.fboScene=x3dom.Utils.initFBO(gl,this.canvas.width,this.canvas.height,shadowType,false,true);scene._webgl.fboBlur=[];for(i=0;i0)&&typeof scene._webgl.fboScene=="undefined"||scene._webgl.fboScene&&(this.canvas.width!=scene._webgl.fboScene.width||this.canvas.height!=scene._webgl.fboScene.height)){scene._webgl.fboScene=x3dom.Utils.initFBO(gl,this.canvas.width,this.canvas.height,shadowType,false,true);}}
+var env=scene.getEnvironment();env.checkSanity();var bgnd=scene.getBackground();this.setupScene(gl,bgnd);this.numFaces=0;this.numCoords=0;this.numDrawCalls=0;var mat_proj=viewarea.getProjectionMatrix();var mat_view=viewarea.getViewMatrix();if(!this._calledViewpointChangedHandler||!viewarea._last_mat_view.equals(mat_view)){var e_viewpoint=scene.getViewpoint();var e_eventType="viewpointChanged";try{if(e_viewpoint._xmlNode&&(e_viewpoint._xmlNode["on"+e_eventType]||e_viewpoint._xmlNode.hasAttribute("on"+e_eventType)||e_viewpoint._listeners[e_eventType])){var e_viewtrafo=e_viewpoint.getCurrentTransform();e_viewtrafo=e_viewtrafo.inverse().mult(mat_view);var e_mat=e_viewtrafo.inverse();var e_rotation=new x3dom.fields.Quaternion(0,0,1,0);e_rotation.setValue(e_mat);var e_translation=e_mat.e3();var e_event={target:e_viewpoint._xmlNode,type:e_eventType,matrix:e_viewtrafo,position:e_translation,orientation:e_rotation.toAxisAngle(),cancelBubble:false,stopPropagation:function(){this.cancelBubble=true;},preventDefault:function(){this.cancelBubble=true;}};e_viewpoint.callEvtHandler(("on"+e_eventType),e_event);this._calledViewpointChangedHandler=true;}}
+catch(e_e){x3dom.debug.logException(e_e);}}
+viewarea._last_mat_view=mat_view;viewarea._last_mat_proj=mat_proj;var mat_scene=mat_proj.mult(mat_view);viewarea._last_mat_scene=mat_scene;scene.drawableCollection=null;if(!scene.drawableCollection)
+{var drawableCollectionConfig={viewArea:viewarea,sortTrans:env._vf.sortTrans,viewMatrix:mat_view,projMatrix:mat_proj,sceneMatrix:mat_scene,frustumCulling:true,smallFeatureThreshold:env._smallFeatureThreshold,context:this,gl:gl};scene.drawableCollection=new x3dom.DrawableCollection(drawableCollectionConfig);x3dom.Utils.startMeasure('traverse');scene.collectDrawableObjects(x3dom.fields.SFMatrix4f.identity(),scene.drawableCollection,true,false,0,[]);var traverseTime=x3dom.Utils.stopMeasure('traverse');this.x3dElem.runtime.addMeasurement('TRAVERSE',traverseTime);}
+x3dom.Utils.startMeasure('sorting');scene.drawableCollection.sort();var sortTime=x3dom.Utils.stopMeasure('sorting');this.x3dElem.runtime.addMeasurement('SORT',sortTime);var slights=viewarea.getLights();var numLights=slights.length;var mat_light;var WCToLCMatrices=[];var lMatrices=[];var shadowCount=0;x3dom.Utils.startMeasure('shadow');for(var p=0;p0.0){var lightMatrix=viewarea.getLightMatrix()[p];shadowMaps=scene._webgl.fboShadow[shadowCount];var offset=Math.max(0.0,Math.min(1.0,slights[p]._vf.shadowOffset));if(!x3dom.isa(slights[p],x3dom.nodeTypes.PointLight)){var numCascades=Math.max(1,Math.min(slights[p]._vf.shadowCascades,6));mat_light=viewarea.getWCtoLCMatricesCascaded(lightMatrix,slights[p],mat_proj);for(i=0;i0||x3dom.SSAO.isEnabled(scene)){this.renderShadowPass(gl,viewarea,mat_scene,mat_view,scene._webgl.fboScene,0.0,true);var shadowTime=x3dom.Utils.stopMeasure('shadow');this.x3dElem.runtime.addMeasurement('SHADOW',shadowTime);}
+else{this.x3dElem.runtime.removeMeasurement('SHADOW');}
+mat_light=viewarea.getWCtoLCMatrix(viewarea.getLightMatrix()[0]);for(rtl_i=0;rtl_i0)
+this.renderShadows(gl,viewarea,shadowedLights,WCToLCMatrices,lMatrices,mat_view,mat_proj,mat_scene);this.stateManager.disable(gl.BLEND);this.stateManager.disable(gl.DEPTH_TEST);viewarea._numRenderedNodes=n;if(x3dom.SSAO.isEnabled(scene))
+x3dom.SSAO.renderSSAO(this.stateManager,gl,scene,this.canvas);if(viewarea._visDbgBuf!==undefined&&viewarea._visDbgBuf)
+{var pm=scene._vf.pickMode.toLowerCase();if(pm.indexOf("idbuf")==0||pm=="color"||pm=="texcoord"){this.stateManager.viewport(0,3*this.canvas.height/4,this.canvas.width/4,this.canvas.height/4);scene._fgnd._webgl.render(gl,scene._webgl.fboPick.tex);}
+if(shadowCount>0||x3dom.SSAO.isEnabled(scene)){this.stateManager.viewport(this.canvas.width/4,3*this.canvas.height/4,this.canvas.width/4,this.canvas.height/4);scene._fgnd._webgl.render(gl,scene._webgl.fboScene.tex);}
+var row=3,col=2;for(i=0;i1){sp.lastTex=1;gl.activeTexture(gl.TEXTURE1);gl.bindTexture(gl.TEXTURE_2D,rt._webgl.fbo.tex);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MAG_FILTER,gl.NEAREST);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,gl.NEAREST);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_S,gl.CLAMP_TO_EDGE);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_T,gl.CLAMP_TO_EDGE);}
+sp.curTex=2;gl.activeTexture(gl.TEXTURE2);gl.bindTexture(gl.TEXTURE_2D,rt._webgl.texture);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MAG_FILTER,gl.NEAREST);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,gl.NEAREST);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_S,gl.CLAMP_TO_EDGE);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_T,gl.CLAMP_TO_EDGE);sp.mode=rt._currLoadLevel-1;sp.repeat=rt._repeat.toGL();gl.drawArrays(gl.TRIANGLES,0,6);this.stateManager.bindFramebuffer(gl.FRAMEBUFFER,rt._webgl.fbo.fbo);gl.clear(gl.COLOR_BUFFER_BIT|gl.DEPTH_BUFFER_BIT);sp.mode=0;sp.curTex=2;gl.activeTexture(gl.TEXTURE2);gl.bindTexture(gl.TEXTURE_2D,refinementFbo.tex);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MAG_FILTER,gl.NEAREST);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,gl.NEAREST);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_S,gl.CLAMP_TO_EDGE);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_T,gl.CLAMP_TO_EDGE);gl.drawArrays(gl.TRIANGLES,0,6);gl.activeTexture(gl.TEXTURE0);gl.bindTexture(gl.TEXTURE_2D,null);gl.disableVertexAttribArray(sp.position);this.stateManager.bindFramebuffer(gl.FRAMEBUFFER,null);this.stateManager.viewport(0,0,this.canvas.width,this.canvas.height);if(rt._vf.autoRefinement)
+rt.nextLevel();if(rt._currLoadLevel==rt._vf.maxLevel)
+rt._currLoadLevel++;if(rt._webgl.fbo.mipMap){gl.bindTexture(gl.TEXTURE_2D,rt._webgl.fbo.tex);gl.generateMipmap(gl.TEXTURE_2D);gl.bindTexture(gl.TEXTURE_2D,null);}
+if(!rt.requirePingPong()){gl.deleteTexture(rt._webgl.texture);delete rt._webgl.texture;rt._cleanupGLObjects(true);}
+rt._renderedImage++;};Context.prototype.renderRTPass=function(gl,viewarea,rt)
+{if(x3dom.isa(rt,x3dom.nodeTypes.RefinementTexture)){if(rt.requirePingPong()){this.renderPingPongPass(gl,viewarea,rt);}
+return;}
+switch(rt._vf.update.toUpperCase()){case"NONE":return;case"NEXT_FRAME_ONLY":if(!rt._needRenderUpdate){return;}
+rt._needRenderUpdate=false;break;case"ALWAYS":default:break;}
+var scene=viewarea._scene;var bgnd=null;var mat_view=rt.getViewMatrix();var mat_proj=rt.getProjectionMatrix();var mat_scene=mat_proj.mult(mat_view);var lightMatrix=viewarea.getLightMatrix()[0];var mat_light=viewarea.getWCtoLCMatrix(lightMatrix);var i,n,m=rt._cf.excludeNodes.nodes.length;var arr=new Array(m);for(i=0;i0||s_gl.popGeometry>0){for(v=0,offset=0,v_n=s_geo._vf.vertexCount.length;vtexLimit){renderSplit[renderSplit.length]=i;texUnits=7;}}
+renderSplit[renderSplit.length]=shadowedLights.length;var n=renderSplit.length-1;var mat_proj_inv=mat_proj.inverse();var mat_scene_inv=mat_scene.inverse();this.stateManager.enable(gl.BLEND);this.stateManager.blendFunc(gl.DST_COLOR,gl.ZERO);for(var s=0;s=0)?url.substr(0,i+1):"";x3dom.debug.logInfo("setBaseURL: "+this.baseURL);};x3dom.NodeNameSpace.prototype.getURL=function(url){if(url===undefined||!url.length){return"";}
+else{return((url[0]==='/')||(url.indexOf(":")>=0))?url:(this.baseURL+url);}};x3dom.hasElementAttribute=function(attrName)
+{var ok=this.__hasAttribute(attrName);if(!ok&&attrName){ok=this.__hasAttribute(attrName.toLowerCase());}
+return ok;};x3dom.getElementAttribute=function(attrName)
+{var attrib=this.__getAttribute(attrName);if(!attrib&&attrib!=""&&attrName){attrib=this.__getAttribute(attrName.toLowerCase());}
+if(attrib||!this._x3domNode){return attrib;}
+else{return this._x3domNode._vf[attrName];}};x3dom.setElementAttribute=function(attrName,newVal)
+{this.__setAttribute(attrName,newVal);var x3dNode=this._x3domNode;if(x3dNode){x3dNode.updateField(attrName,newVal);x3dNode._nameSpace.doc.needRender=true;}};x3dom.getFieldValue=function(fieldName)
+{var x3dNode=this._x3domNode;if(x3dNode&&(x3dNode._vf[fieldName]!==undefined)){var fieldValue=x3dNode._vf[fieldName];if(fieldValue instanceof Object&&'copy'in fieldValue)
+{return x3dNode._vf[fieldName].copy();}
+else
+{return x3dNode._vf[fieldName];}}
+return null;};x3dom.setFieldValue=function(fieldName,fieldvalue){var x3dNode=this._x3domNode;if(x3dNode&&(x3dNode._vf[fieldName]!==undefined)){if(fieldvalue instanceof Object&&'copy'in fieldvalue)
+{x3dNode._vf[fieldName]=fieldvalue.copy();}
+else
+x3dNode._vf[fieldName]=fieldvalue;x3dNode.fieldChanged(fieldName);x3dNode._nameSpace.doc.needRender=true;}};x3dom.requestFieldRef=function(fieldName)
+{var x3dNode=this._x3domNode;if(x3dNode&&x3dNode._vf[fieldName])
+{return x3dNode._vf[fieldName];}
+return null;};x3dom.releaseFieldRef=function(fieldName)
+{var x3dNode=this._x3domNode;if(x3dNode&&x3dNode._vf[fieldName])
+{x3dNode.fieldChanged(fieldName);x3dNode._nameSpace.doc.needRender=true;}};x3dom.NodeNameSpace.prototype.setupTree=function(domNode,parent){var n=null;parent=parent||null;if(x3dom.isX3DElement(domNode)){if(domNode._x3domNode){x3dom.debug.logWarning('Tree is already initialized');return null;}
+if((domNode.tagName!==undefined)&&(!domNode.__addEventListener)&&(!domNode.__removeEventListener))
+{domNode.__addEventListener=domNode.addEventListener;domNode.addEventListener=function(type,func,phase){if(!this._x3domNode._listeners[type]){this._x3domNode._listeners[type]=[];}
+this._x3domNode._listeners[type].push(func);this.__addEventListener(type,func,phase);};domNode.__removeEventListener=domNode.removeEventListener;domNode.removeEventListener=function(type,func,phase){var list=this._x3domNode._listeners[type];if(list){for(var it=0;it=2){var otherNS=this;while(otherNS){if(otherNS.name==nsName[0])
+n=otherNS.defMap[nsName[1]];if(n)
+otherNS=null;else
+otherNS=otherNS.parent;}
+if(!n){n=null;x3dom.debug.logWarning('Could not USE: '+domNode.getAttribute('USE'));}}}
+if(n){domNode._x3domNode=n;}
+return n;}
+else{if(domNode.localName.toLowerCase()==='route'){var route=domNode;var fnAtt=route.getAttribute('fromNode')||route.getAttribute('fromnode');var tnAtt=route.getAttribute('toNode')||route.getAttribute('tonode');var fromNode=this.defMap[fnAtt];var toNode=this.defMap[tnAtt];if(!(fromNode&&toNode)){x3dom.debug.logWarning("Broken route - can't find all DEFs for "+fnAtt+" -> "+tnAtt);}
+else{fnAtt=route.getAttribute('fromField')||route.getAttribute('fromfield');tnAtt=route.getAttribute('toField')||route.getAttribute('tofield');fromNode.setupRoute(fnAtt,toNode,tnAtt);route._nodeNameSpace=this;}
+return null;}
+domNode.requestFieldRef=x3dom.requestFieldRef;domNode.releaseFieldRef=x3dom.releaseFieldRef;domNode.getFieldValue=x3dom.getFieldValue;domNode.setFieldValue=x3dom.setFieldValue;var nodeType=x3dom.nodeTypesLC[domNode.localName.toLowerCase()];if(nodeType===undefined){x3dom.debug.logWarning("Unrecognised X3D element <"+domNode.localName+">.");}
+else{if((x3dom.userAgentFeature.supportsDOMAttrModified===false)&&(domNode instanceof Element)){if(domNode.setAttribute&&!domNode.__setAttribute){domNode.__setAttribute=domNode.setAttribute;domNode.setAttribute=x3dom.setElementAttribute;}
+if(domNode.getAttribute&&!domNode.__getAttribute){domNode.__getAttribute=domNode.getAttribute;domNode.getAttribute=x3dom.getElementAttribute;}
+if(domNode.hasAttribute&&!domNode.__hasAttribute){domNode.__hasAttribute=domNode.hasAttribute;domNode.hasAttribute=x3dom.hasElementAttribute;}}
+var ctx={doc:this.doc,xmlNode:domNode,nameSpace:this};n=new nodeType(ctx);if(domNode.hasAttribute('DEF')){n._DEF=domNode.getAttribute('DEF');this.defMap[n._DEF]=n;}
+else{if(domNode.hasAttribute('id')){n._DEF=domNode.getAttribute('id');this.defMap[n._DEF]=n;}}
+if(domNode.highlight===undefined)
+{domNode.highlight=function(enable,colorStr){var color=x3dom.fields.SFColor.parse(colorStr);this._x3domNode.highlight(enable,color);this._x3domNode._nameSpace.doc.needRender=true;};}
+n._xmlNode=domNode;domNode._x3domNode=n;var that=this;Array.forEach(domNode.childNodes,function(childDomNode){var c=that.setupTree(childDomNode,n);if(c){n.addChild(c,childDomNode.getAttribute("containerField"));}});n.nodeChanged();return n;}}}
+else if(domNode.localName)
+{if(parent&&domNode.localName.toLowerCase()=="x3dommetagroup")
+{Array.forEach(domNode.childNodes,function(childDomNode){var c=this.setupTree(childDomNode,parent);if(c){parent.addChild(c,childDomNode.getAttribute("containerField"));}}.bind(this));}
+else
+{x3dom.debug.logWarning("Unrecognised X3D element <"+domNode.localName+">.");n=null;}}
+return n;};x3dom.registerNodeType("X3DNode","Core",defineClass(null,function(ctx){this._xmlNode=null;this._DEF=null;this._nameSpace=(ctx&&ctx.nameSpace)?ctx.nameSpace:null;this._vf={};this._vfFieldTypes={};this._cf={};this._cfFieldTypes={};this._fieldWatchers={};this._routes={};this._listeners={};this._parentNodes=[];this._childNodes=[];this.addField_SFNode('metadata',x3dom.nodeTypes.X3DMetadataObject);},{type:function(){return this.constructor;},typeName:function(){return this.constructor._typeName;},addChild:function(node,containerFieldName){if(node){var field=null;if(containerFieldName){field=this._cf[containerFieldName];}
+else{for(var fieldName in this._cf){if(this._cf.hasOwnProperty(fieldName)){var testField=this._cf[fieldName];if(x3dom.isa(node,testField.type)){field=testField;break;}}}}
+if(field&&field.addLink(node)){node._parentNodes.push(this);this._childNodes.push(node);node.parentAdded(this);return true;}}
+return false;},removeChild:function(node){if(node){for(var fieldName in this._cf){if(this._cf.hasOwnProperty(fieldName)){var field=this._cf[fieldName];if(field.rmLink(node)){for(var i=node._parentNodes.length-1;i>=0;i--){if(node._parentNodes[i]===this){node._parentNodes.splice(i,1);node.parentRemoved(this);}}
+for(var j=this._childNodes.length-1;j>=0;j--){if(this._childNodes[j]===node){node.onRemove();this._childNodes.splice(j,1);return true;}}}}}}
+return false;},onRemove:function(){},parentAdded:function(parent){},parentRemoved:function(parent){for(var i=0,n=this._childNodes.length;i=1){return this.transformMatrix(this._parentNodes[0].getCurrentTransform());}
+else{return x3dom.fields.SFMatrix4f.identity();}},transformMatrix:function(transform){return transform;},getVolume:function(){return null;},invalidateVolume:function(){},invalidateCache:function(){},volumeValid:function(){return false;},collectDrawableObjects:function(transform,drawableCollection,singlePath,invalidateCache,planeMask,clipPlanes){},highlight:function(enable,color)
+{if(this._vf.hasOwnProperty("diffuseColor"))
+{if(enable){if(this._actDiffuseColor===undefined){this._actDiffuseColor=new x3dom.fields.SFColor();this._highlightOn=false;}
+if(!this._highlightOn){this._actDiffuseColor.setValues(this._vf.diffuseColor);this._highlightOn=true;}
+this._vf.diffuseColor.setValues(color);}
+else{if(this._actDiffuseColor!==undefined){this._vf.diffuseColor.setValues(this._actDiffuseColor);this._highlightOn=false;delete this._actDiffuseColor;}}}
+for(var i=0,n=this._childNodes.length;i0){fieldName=fromField.substr(0,fromField.length-post.length);if(this._vf[fieldName]){fromField=fieldName;}}}}
+if(!toNode._vf[toField]){pos=toField.indexOf(pre);if(pos===0){fieldName=toField.substr(pre.length,toField.length-1);if(toNode._vf[fieldName]){toField=fieldName;}}
+else{pos=toField.indexOf(post);if(pos>0){fieldName=toField.substr(0,toField.length-post.length);if(toNode._vf[fieldName]){toField=fieldName;}}}}
+var where=this._DEF+"&"+fromField+"&"+toNode._DEF+"&"+toField;if(!this._routes[where]){if(!this._fieldWatchers[fromField]){this._fieldWatchers[fromField]=[];}
+this._fieldWatchers[fromField].push(function(msg){toNode.postMessage(toField,msg);});if(!toNode._fieldWatchers[toField]){toNode._fieldWatchers[toField]=[];}
+toNode._fieldWatchers[toField].push(function(msg){toNode._vf[toField]=msg;toNode.fieldChanged(toField);});this._routes[where]={from:this._fieldWatchers[fromField].length-1,to:toNode._fieldWatchers[toField].length-1};}},removeRoute:function(fromField,toNode,toField){var pos;var fieldName;var pre="set_",post="_changed";if(!this._vf[fromField]){pos=fromField.indexOf(pre);if(pos===0){fieldName=fromField.substr(pre.length,fromField.length-1);if(this._vf[fieldName]){fromField=fieldName;}}else{pos=fromField.indexOf(post);if(pos>0){fieldName=fromField.substr(0,fromField.length-post.length);if(this._vf[fieldName]){fromField=fieldName;}}}}
+if(!toNode._vf[toField]){pos=toField.indexOf(pre);if(pos===0){fieldName=toField.substr(pre.length,toField.length-1);if(toNode._vf[fieldName]){toField=fieldName;}}
+else{pos=toField.indexOf(post);if(pos>0){fieldName=toField.substr(0,toField.length-post.length);if(toNode._vf[fieldName]){toField=fieldName;}}}}
+var where=this._DEF+"&"+fromField+"&"+toNode._DEF+"&"+toField;if(this._routes[where]){this._fieldWatchers[fromField].splice(this._routes[where].from,1);toNode._fieldWatchers[toField].splice(this._routes[where].to,1);delete this._routes[where];}},fieldChanged:function(fieldName){},nodeChanged:function(){},callEvtHandler:function(eventType,event){var node=this;if(!node._xmlNode){return event.cancelBubble;}
+try{var attrib=node._xmlNode[eventType];event.target=node._xmlNode;if(typeof(attrib)==="function"){attrib.call(node._xmlNode,event);}
+else{var funcStr=node._xmlNode.getAttribute(eventType);var func=new Function('event',funcStr);func.call(node._xmlNode,event);}
+var list=node._listeners[event.type];if(list){for(var it=0;it=0){this.bind(this._vf.bind);}},nodeChanged:function(){this._stack=this._nameSpace.doc._bindableBag.addBindable(this);}}));x3dom.registerNodeType("X3DInfoNode","Core",defineClass(x3dom.nodeTypes.X3DChildNode,function(ctx){x3dom.nodeTypes.X3DInfoNode.superClass.call(this,ctx);}));x3dom.registerNodeType("WorldInfo","Core",defineClass(x3dom.nodeTypes.X3DInfoNode,function(ctx){x3dom.nodeTypes.WorldInfo.superClass.call(this,ctx);this.addField_MFString(ctx,'info',[]);this.addField_SFString(ctx,'title',"");x3dom.debug.logInfo(this._vf.info);x3dom.debug.logInfo(this._vf.title);}));x3dom.registerNodeType("X3DSensorNode","Core",defineClass(x3dom.nodeTypes.X3DChildNode,function(ctx){x3dom.nodeTypes.X3DSensorNode.superClass.call(this,ctx);this.addField_SFBool(ctx,'enabled',true);}));x3dom.registerNodeType("Param","Core",defineClass(x3dom.nodeTypes.X3DNode,function(ctx){x3dom.nodeTypes.Param.superClass.call(this,ctx);x3dom.debug.logWarning('DEPRECATED: Param element needs to be child of X3D element '
++'[DOCS]');}));x3dom.registerNodeType("X3DBoundedObject","Grouping",defineClass(x3dom.nodeTypes.X3DChildNode,function(ctx){x3dom.nodeTypes.X3DBoundedObject.superClass.call(this,ctx);this.addField_SFBool(ctx,'render',true);this.addField_SFVec3f(ctx,'bboxCenter',0,0,0);this.addField_SFVec3f(ctx,'bboxSize',-1,-1,-1);this._graph={boundedNode:this,localMatrix:x3dom.fields.SFMatrix4f.identity(),globalMatrix:null,volume:new x3dom.fields.BoxVolume(),lastVolume:new x3dom.fields.BoxVolume(),worldVolume:new x3dom.fields.BoxVolume(),center:new x3dom.fields.SFVec3f(0,0,0),coverage:-1,needCulling:true};},{fieldChanged:function(fieldName){if(this._vf.hasOwnProperty(fieldName)){this.invalidateVolume();}},nodeChanged:function(){this.invalidateVolume();},parentAdded:function(parent){this.invalidateVolume();},getVolume:function()
+{var vol=this._graph.volume;if(!this.volumeValid()&&this._vf.render)
+{for(var i=0,n=this._childNodes.length;i1))
+singlePath=false;if(singlePath&&(invalidateCache=invalidateCache||this.cacheInvalid()))
+this.invalidateCache();planeMask=drawableCollection.cull(transform,this.graphState(),singlePath,planeMask);if(planeMask<0){return;}
+var cnode,childTransform;if(singlePath){if(!this._graph.globalMatrix){this._graph.globalMatrix=this.transformMatrix(transform);}
+childTransform=this._graph.globalMatrix;}
+else{childTransform=this.transformMatrix(transform);}
+var n=this._childNodes.length;if(x3dom.nodeTypes.ClipPlane.count>0){var localClipPlanes=[];for(var j=0;j=0&&this._vf.whichChoice1))
+singlePath=false;if(singlePath&&(invalidateCache=invalidateCache||this.cacheInvalid()))
+this.invalidateCache();if(this._vf.whichChoice<0||this._vf.whichChoice>=this._childNodes.length||(planeMask=drawableCollection.cull(transform,this.graphState(),singlePath,planeMask))<0){return;}
+var cnode,childTransform;if(singlePath){if(!this._graph.globalMatrix){this._graph.globalMatrix=this.transformMatrix(transform);}
+childTransform=this._graph.globalMatrix;}
+else{childTransform=this.transformMatrix(transform);}
+if((cnode=this._childNodes[this._vf.whichChoice])){cnode.collectDrawableObjects(childTransform,drawableCollection,singlePath,invalidateCache,planeMask,clipPlanes);}},doIntersect:function(line)
+{if(this._vf.whichChoice<0||this._vf.whichChoice>=this._childNodes.length){return false;}
+var child=this._childNodes[this._vf.whichChoice];if(child){return child.doIntersect(line);}
+return false;}}));x3dom.registerNodeType("X3DTransformNode","Grouping",defineClass(x3dom.nodeTypes.X3DGroupingNode,function(ctx){x3dom.nodeTypes.X3DTransformNode.superClass.call(this,ctx);if(ctx)
+ctx.doc._nodeBag.trans.push(this);else
+x3dom.debug.logWarning("X3DTransformNode: No runtime context found!");this._trafo=null;this._needCssStyleUpdates=true;},{tick:function(t)
+{var dom=this._xmlNode;if(dom&&(dom['ontransform']||dom.hasAttribute('ontransform')||this._listeners['transform'])){var transMatrix=this.getCurrentTransform();var event={target:dom,type:'transform',worldX:transMatrix._03,worldY:transMatrix._13,worldZ:transMatrix._23,cancelBubble:false,stopPropagation:function(){this.cancelBubble=true;}};this.callEvtHandler("ontransform",event);}
+if(this._needCssStyleUpdates&&dom){var trans=x3dom.getStyle(dom,"-webkit-transform")||x3dom.getStyle(dom,"-moz-transform")||x3dom.getStyle(dom,"-ms-transform")||x3dom.getStyle(dom,"transform");if(trans&&(trans!='none')){this._trafo.setValueByStr(trans);this.invalidateVolume();return true;}
+this._needCssStyleUpdates=false;}
+return false;},transformMatrix:function(transform){return transform.mult(this._trafo);},getVolume:function()
+{var vol=this._graph.volume;if(!this.volumeValid()&&this._vf.render)
+{this._graph.localMatrix=this._trafo;for(var i=0,n=this._childNodes.length;i1))
+singlePath=false;if(singlePath&&(invalidateCache=invalidateCache||this.cacheInvalid()))
+this.invalidateCache();planeMask=drawableCollection.cull(transform,this.graphState(),singlePath,planeMask);if(planeMask<0){return;}
+var cnode,childTransform;if(singlePath){if(!this._graph.globalMatrix){this._graph.globalMatrix=this.transformMatrix(transform);}
+childTransform=this._graph.globalMatrix;}
+else{childTransform=this.transformMatrix(transform);}
+if(this.needBvhRebuild)
+{var drawableCollectionConfig={viewArea:drawableCollection.viewarea,sortTrans:drawableCollection.sortTrans,viewMatrix:drawableCollection.viewMatrix,projMatrix:drawableCollection.projMatrix,sceneMatrix:drawableCollection.sceneMatrix,frustumCulling:false,smallFeatureThreshold:0,context:drawableCollection.context};this.drawableCollection=new x3dom.DrawableCollection(drawableCollectionConfig);var i,n=this._childNodes.length;for(i=0;i0)
+{that._idList=[];var arr=x3dom.fields.MFString.parse(evt.data);var n=Math.min(arr.length,Math.abs(that._vf.maxRenderedIds));for(var i=0;i0){nodeName=nodeName.substring(0,starInd);matchNameBegin=true;}
+if(nodeName.length<=1)
+continue;if((matchNameBegin&&this._vf.label[i].indexOf(nodeName)==0)||this._vf.label[i]==nodeName){this._visibleList[i]=false;break;}}}
+else{this._visibleList[i]=false;}}
+this.invalidateVolume();}
+else if(fieldName=="render"){this.invalidateVolume();}},getNumRenderedObjects:function(len,isMoving)
+{var n=len;if(this._vf.maxRenderedIds>0)
+{var num=Math.max(this._vf.maxRenderedIds,16);var scale=1;if(isMoving)
+scale=Math.min(this._vf.scaleRenderedIdsOnMove,1);num=Math.max(Math.round(scale*num),0);n=Math.min(n,num);}
+return n;},collectDrawableObjects:function(transform,drawableCollection,singlePath,invalidateCache,planeMask,clipPlanes)
+{if(singlePath&&(this._parentNodes.length>1))
+singlePath=false;if(singlePath&&(invalidateCache=invalidateCache||this.cacheInvalid()))
+this.invalidateCache();planeMask=drawableCollection.cull(transform,this.graphState(),singlePath,planeMask);if(planeMask<=0){return;}
+var viewarea=this._nameSpace.doc._viewarea;var isMoving=viewarea.isMovingOrAnimating();var ts=new Date().getTime();var maxLiveTime=10000;var i,n,numChild=this._childNodes.length;if(!this._vf.enableCulling)
+{n=this.getNumRenderedObjects(numChild,isMoving);var cnt=0;for(i=0;i0&&ts-this._createTime[i]>maxLiveTime&&shape._cleanupGLObjects)
+{shape._cleanupGLObjects(true);this._createTime[i]=0;}}}
+return;}
+if(this._websocket)
+this._websocket.updateCamera();if(this._vf.label.length)
+{n=this.getNumRenderedObjects(this._idList.length,isMoving);for(i=0;i0&&ts-this._createTime[i]>maxLiveTime&&this._childNodes[i]._cleanupGLObjects)
+{this._childNodes[i]._cleanupGLObjects(true);this._createTime[i]=0;}}}}}));x3dom.registerNodeType("Scene","Grouping",defineClass(x3dom.nodeTypes.X3DGroupingNode,function(ctx){x3dom.nodeTypes.Scene.superClass.call(this,ctx);this.addField_SFString(ctx,'pickMode',"idBuf");this.addField_SFBool(ctx,'doPickPass',true);this.addField_SFString(ctx,'shadowObjectIdMapping',"");this._lastMin=new x3dom.fields.SFVec3f(0,0,0);this._lastMax=new x3dom.fields.SFVec3f(1,1,1);this._shadowIdMap=null;this.loadMapping();this._multiPartMap=null;},{fieldChanged:function(fieldName)
+{if(fieldName=="shadowObjectIdMapping")
+{this.loadMapping();}},updateVolume:function()
+{var vol=this.getVolume();if(vol.isValid())
+{this._lastMin=x3dom.fields.SFVec3f.copy(vol.min);this._lastMax=x3dom.fields.SFVec3f.copy(vol.max);}},loadMapping:function()
+{this._shadowIdMap=null;if(this._vf.shadowObjectIdMapping.length==0){return;}
+var that=this;var xhr=new XMLHttpRequest();xhr.open("GET",this._nameSpace.getURL(this._vf.shadowObjectIdMapping),true);x3dom.RequestManager.addRequest(xhr);xhr.onload=function()
+{that._shadowIdMap=eval("("+xhr.response+")");if(!that._shadowIdMap||!that._shadowIdMap.mapping){x3dom.debug.logWarning("Invalid ID map: "+that._vf.shadowObjectIdMapping);}
+else{x3dom.debug.assert(that._shadowIdMap.maxID<=that._shadowIdMap.mapping.length,"Too few ID map entries in "+that._vf.shadowObjectIdMapping+", "+"length of mapping array is only "+that._shadowIdMap.mapping.length+" instead of "+that._shadowIdMap.ids.length+"!");}};}}));x3dom.BindableStack=function(doc,type,defaultType,getter){this._doc=doc;this._type=type;this._defaultType=defaultType;this._defaultRoot=null;this._getter=getter;this._bindBag=[];this._bindStack=[];};x3dom.BindableStack.prototype.top=function(){return((this._bindStack.length>0)?this._bindStack[this._bindStack.length-1]:null);};x3dom.BindableStack.prototype.push=function(bindable){var top=this.top();if(top===bindable){return;}
+if(top){top.deactivate();}
+this._bindStack.push(bindable);bindable.activate(top);};x3dom.BindableStack.prototype.replaceTop=function(bindable){var top=this.top();if(top===bindable){return;}
+if(top){top.deactivate();this._bindStack[this._bindStack.length-1]=bindable;bindable.activate(top);}};x3dom.BindableStack.prototype.pop=function(bindable){var top;if(bindable){top=this.top();if(bindable!==top){return null;}}
+top=this._bindStack.pop();if(top){top.deactivate();}
+return top;};x3dom.BindableStack.prototype.switchTo=function(target){var last=this.getActive();var n=this._bindBag.length;var toBind=0;var i=0,lastIndex=-1;if(n<=1){return;}
+switch(target)
+{case'first':toBind=this._bindBag[0];break;case'last':toBind=this._bindBag[n-1];break;default:for(i=0;i=0){i=lastIndex;while(!toBind){if(target=='next'){i=(i<(n-1))?(i+1):0;}else{i=(i>0)?(i-1):(n-1);}
+if(i==lastIndex){break;}
+if(this._bindBag[i]._vf.description.length>=0){toBind=this._bindBag[i];}}}
+break;}
+if(toBind){this.replaceTop(toBind);}else{x3dom.debug.logWarning('Cannot switch bindable; no other bindable with description found.');}};x3dom.BindableStack.prototype.getActive=function(){if(this._bindStack.length===0){if(this._bindBag.length===0){if(this._defaultRoot){x3dom.debug.logInfo('create new '+this._defaultType._typeName+' for '+this._type._typeName+'-stack');var obj=new this._defaultType({doc:this._doc,nameSpace:this._defaultRoot._nameSpace,autoGen:true});this._defaultRoot.addChild(obj);obj.nodeChanged();}
+else{x3dom.debug.logError('stack without defaultRoot');}}
+else{x3dom.debug.logInfo('activate first '+this._type._typeName+' for '+this._type._typeName+'-stack');}
+this._bindStack.push(this._bindBag[0]);this._bindBag[0].activate();}
+return this._bindStack[this._bindStack.length-1];};x3dom.BindableBag=function(doc){this._stacks=[];this.addType("X3DViewpointNode","Viewpoint","getViewpoint",doc);this.addType("X3DNavigationInfoNode","NavigationInfo","getNavigationInfo",doc);this.addType("X3DBackgroundNode","Background","getBackground",doc);this.addType("X3DFogNode","Fog","getFog",doc);this.addType("X3DEnvironmentNode","Environment","getEnvironment",doc);};x3dom.BindableBag.prototype.addType=function(typeName,defaultTypeName,getter,doc){var type=x3dom.nodeTypes[typeName];var defaultType=x3dom.nodeTypes[defaultTypeName];if(type&&defaultType){var stack=new x3dom.BindableStack(doc,type,defaultType,getter);this._stacks.push(stack);}
+else{x3dom.debug.logWarning('Invalid Bindable type/defaultType: '+
+typeName+'/'+defaultType);}};x3dom.BindableBag.prototype.setRefNode=function(node){Array.forEach(this._stacks,function(stack){stack._defaultRoot=node;node[stack._getter]=function(){return stack.getActive();};});};x3dom.BindableBag.prototype.addBindable=function(node){for(var i=0,n=this._stacks.length;i=0;return(this._vf.lit&&hasTris);}}));x3dom.registerNodeType("Mesh","Rendering",defineClass(x3dom.nodeTypes.X3DGeometryNode,function(ctx){x3dom.nodeTypes.Mesh.superClass.call(this,ctx);this.addField_SFString(ctx,'primType',"triangle");this.addField_MFInt32(ctx,'index',[]);this.addField_MFNode('vertexAttributes',x3dom.nodeTypes.X3DVertexAttributeNode);},{nodeChanged:function()
+{var time0=new Date().getTime();var i,n=this._cf.vertexAttributes.nodes.length;for(i=0;i=0;j--){this._mesh._indices[0].push(cnt++,cnt);if(j==0)cnt++;}}},fieldChanged:function(fieldName){if(fieldName=="coord"){var pnts=this._cf.coord.node.getPoints();this._mesh._positions[0]=pnts.toGL();this.invalidateVolume();Array.forEach(this._parentNodes,function(node){node._dirty.positions=true;node.invalidateVolume();});}
+else if(fieldName=="color"){var cols=this._cf.color.node._vf.color;this._mesh._colors[0]=cols.toGL();Array.forEach(this._parentNodes,function(node){node._dirty.colors=true;});}}}));x3dom.registerNodeType("IndexedLineSet","Rendering",defineClass(x3dom.nodeTypes.X3DGeometryNode,function(ctx){x3dom.nodeTypes.IndexedLineSet.superClass.call(this,ctx);this.addField_SFBool(ctx,'colorPerVertex',true);this.addField_MFNode('attrib',x3dom.nodeTypes.X3DVertexAttributeNode);this.addField_SFNode('coord',x3dom.nodeTypes.X3DCoordinateNode);this.addField_SFNode('color',x3dom.nodeTypes.X3DColorNode);this.addField_MFInt32(ctx,'coordIndex',[]);this.addField_MFInt32(ctx,'colorIndex',[]);this._mesh._primType='LINES';x3dom.Utils.needLineWidth=true;},{_buildGeometry:function()
+{var time0=new Date().getTime();var indexes=this._vf.coordIndex;var colorInd=this._vf.colorIndex;var hasColor=false,hasColorInd=false;var colPerVert=this._vf.colorPerVertex;if(colorInd.length==indexes.length)
+{hasColorInd=true;}
+var positions,colors;var coordNode=this._cf.coord.node;x3dom.debug.assert(coordNode);positions=coordNode.getPoints();var numColComponents=3;var colorNode=this._cf.color.node;if(colorNode)
+{hasColor=true;colors=colorNode._vf.color;if(x3dom.isa(colorNode,x3dom.nodeTypes.ColorRGBA)){numColComponents=4;}}
+else{hasColor=false;}
+this._mesh._indices[0]=[];this._mesh._positions[0]=[];this._mesh._colors[0]=[];var i,t,cnt,lineCnt;var p0,p1,c0,c1;if((hasColor&&hasColorInd)||positions.length>x3dom.Utils.maxIndexableCoords)
+{t=0;cnt=0;lineCnt=0;for(i=0;ipositions.length-1)
+{continue;}
+if(indexes[i]===-1){t=0;continue;}
+if(hasColorInd){x3dom.debug.assert(colorInd[i]!=-1);}
+switch(t)
+{case 0:p0=+indexes[i];if(hasColorInd&&colPerVert){c0=+colorInd[i];}
+else{c0=p0;}
+t=1;break;case 1:p1=+indexes[i];if(hasColorInd&&colPerVert){c1=+colorInd[i];}
+else if(hasColorInd&&!colPerVert){c1=+colorInd[lineCnt];}
+else{c1=p1;}
+this._mesh._indices[0].push(cnt++,cnt++);this._mesh._positions[0].push(positions[p0].x);this._mesh._positions[0].push(positions[p0].y);this._mesh._positions[0].push(positions[p0].z);this._mesh._positions[0].push(positions[p1].x);this._mesh._positions[0].push(positions[p1].y);this._mesh._positions[0].push(positions[p1].z);if(hasColor){if(!colPerVert){c0=c1;}
+this._mesh._colors[0].push(colors[c0].r);this._mesh._colors[0].push(colors[c0].g);this._mesh._colors[0].push(colors[c0].b);this._mesh._colors[0].push(colors[c1].r);this._mesh._colors[0].push(colors[c1].g);this._mesh._colors[0].push(colors[c1].b);}
+t=2;lineCnt++;break;case 2:p0=p1;c0=c1;p1=+indexes[i];if(hasColorInd&&colPerVert){c1=+colorInd[i];}
+else if(hasColorInd&&!colPerVert){c1=+colorInd[lineCnt];}
+else{c1=p1;}
+this._mesh._indices[0].push(cnt++,cnt++);this._mesh._positions[0].push(positions[p0].x);this._mesh._positions[0].push(positions[p0].y);this._mesh._positions[0].push(positions[p0].z);this._mesh._positions[0].push(positions[p1].x);this._mesh._positions[0].push(positions[p1].y);this._mesh._positions[0].push(positions[p1].z);if(hasColor){if(!colPerVert){c0=c1;}
+this._mesh._colors[0].push(colors[c0].r);this._mesh._colors[0].push(colors[c0].g);this._mesh._colors[0].push(colors[c0].b);this._mesh._colors[0].push(colors[c1].r);this._mesh._colors[0].push(colors[c1].g);this._mesh._colors[0].push(colors[c1].b);}
+lineCnt++;break;default:}}
+if(positions.length>x3dom.Utils.maxIndexableCoords)
+this._mesh.splitMesh(2);}
+else
+{var n=indexes.length;t=0;for(i=0;i0){positions.push(positions.length-1);}
+posMax=positions.length;if(!normPerVert||!colPerVert||posMax>x3dom.Utils.maxIndexableCoords)
+{t=0;cnt=0;faceCnt=0;this._mesh._multiIndIndices=[];this._mesh._posSize=positions.length;for(i=0;i0)&&(i%3===0)){t=0;faceCnt++;}
+switch(t)
+{case 0:p0=+indexes[i];if(normPerVert){n0=p0;}else if(!normPerVert){n0=faceCnt;}
+t0=p0;if(colPerVert){c0=p0;}else if(!colPerVert){c0=faceCnt;}
+t=1;break;case 1:p1=+indexes[i];if(normPerVert){n1=p1;}else if(!normPerVert){n1=faceCnt;}
+t1=p1;if(colPerVert){c1=p1;}else if(!colPerVert){c1=faceCnt;}
+t=2;break;case 2:p2=+indexes[i];if(normPerVert){n2=p2;}else if(!normPerVert){n2=faceCnt;}
+t2=p2;if(colPerVert){c2=p2;}else if(!colPerVert){c2=faceCnt;}
+t=3;this._mesh._indices[0].push(cnt++,cnt++,cnt++);this._mesh._positions[0].push(positions[p0].x);this._mesh._positions[0].push(positions[p0].y);this._mesh._positions[0].push(positions[p0].z);this._mesh._positions[0].push(positions[p1].x);this._mesh._positions[0].push(positions[p1].y);this._mesh._positions[0].push(positions[p1].z);this._mesh._positions[0].push(positions[p2].x);this._mesh._positions[0].push(positions[p2].y);this._mesh._positions[0].push(positions[p2].z);if(hasNormal){this._mesh._normals[0].push(normals[n0].x);this._mesh._normals[0].push(normals[n0].y);this._mesh._normals[0].push(normals[n0].z);this._mesh._normals[0].push(normals[n1].x);this._mesh._normals[0].push(normals[n1].y);this._mesh._normals[0].push(normals[n1].z);this._mesh._normals[0].push(normals[n2].x);this._mesh._normals[0].push(normals[n2].y);this._mesh._normals[0].push(normals[n2].z);}
+else{this._mesh._multiIndIndices.push(p0,p1,p2);}
+if(hasColor){this._mesh._colors[0].push(colors[c0].r);this._mesh._colors[0].push(colors[c0].g);this._mesh._colors[0].push(colors[c0].b);if(numColComponents===4){this._mesh._colors[0].push(colors[c0].a);}
+this._mesh._colors[0].push(colors[c1].r);this._mesh._colors[0].push(colors[c1].g);this._mesh._colors[0].push(colors[c1].b);if(numColComponents===4){this._mesh._colors[0].push(colors[c1].a);}
+this._mesh._colors[0].push(colors[c2].r);this._mesh._colors[0].push(colors[c2].g);this._mesh._colors[0].push(colors[c2].b);if(numColComponents===4){this._mesh._colors[0].push(colors[c2].a);}}
+if(hasTexCoord){this._mesh._texCoords[0].push(texCoords[t0].x);this._mesh._texCoords[0].push(texCoords[t0].y);if(numTexComponents===3){this._mesh._texCoords[0].push(texCoords[t0].z);}
+this._mesh._texCoords[0].push(texCoords[t1].x);this._mesh._texCoords[0].push(texCoords[t1].y);if(numTexComponents===3){this._mesh._texCoords[0].push(texCoords[t1].z);}
+this._mesh._texCoords[0].push(texCoords[t2].x);this._mesh._texCoords[0].push(texCoords[t2].y);if(numTexComponents===3){this._mesh._texCoords[0].push(texCoords[t2].z);}}
+break;default:}}
+if(!hasNormal){this._mesh.calcNormals(normPerVert?Math.PI:0);}
+if(!hasTexCoord){this._mesh.calcTexCoords(texMode);}
+this._mesh.splitMesh();}
+else
+{faceCnt=0;for(i=0;i0)&&(i%3===0)){faceCnt++;}
+this._mesh._indices[0].push(indexes[i]);if(!normPerVert&&hasNormal){this._mesh._normals[0].push(normals[faceCnt].x);this._mesh._normals[0].push(normals[faceCnt].y);this._mesh._normals[0].push(normals[faceCnt].z);}
+if(!colPerVert&&hasColor){this._mesh._colors[0].push(colors[faceCnt].r);this._mesh._colors[0].push(colors[faceCnt].g);this._mesh._colors[0].push(colors[faceCnt].b);if(numColComponents===4){this._mesh._colors[0].push(colors[faceCnt].a);}}}
+this._mesh._positions[0]=positions.toGL();if(hasNormal){this._mesh._normals[0]=normals.toGL();}
+else{this._mesh.calcNormals(normPerVert?Math.PI:0,ccw);}
+if(hasTexCoord){this._mesh._texCoords[0]=texCoords.toGL();this._mesh._numTexComponents=numTexComponents;}
+else{this._mesh.calcTexCoords(texMode);}
+if(hasColor&&colPerVert){this._mesh._colors[0]=colors.toGL();this._mesh._numColComponents=numColComponents;}}
+this.invalidateVolume();this._mesh._numFaces=0;this._mesh._numCoords=0;for(i=0;ix3dom.Utils.maxIndexableCoords)
+{x3dom.debug.logWarning("IndexedTriangleSet: fieldChanged with "+"too many coordinates not yet implemented!");return;}
+if(fieldName=="coord")
+{this._mesh._positions[0]=pnts.toGL();this.invalidateVolume();Array.forEach(this._parentNodes,function(node){node._dirty.positions=true;node.invalidateVolume();});}
+else if(fieldName=="color")
+{pnts=this._cf.color.node._vf.color;if(this._vf.colorPerVertex){this._mesh._colors[0]=pnts.toGL();}else if(!this._vf.colorPerVertex){var faceCnt=0;var numColComponents=3;if(x3dom.isa(this._cf.color.node,x3dom.nodeTypes.ColorRGBA)){numColComponents=4;}
+this._mesh._colors[0]=[];var indexes=this._vf.index;for(var i=0;i0)&&(i%3===0)){faceCnt++;}
+this._mesh._colors[0].push(pnts[faceCnt].r);this._mesh._colors[0].push(pnts[faceCnt].g);this._mesh._colors[0].push(pnts[faceCnt].b);if(numColComponents===4){this._mesh._colors[0].push(pnts[faceCnt].a);}}}
+Array.forEach(this._parentNodes,function(node){node._dirty.colors=true;});}
+else if(fieldName=="normal")
+{pnts=this._cf.normal.node._vf.vector;if(this._vf.normalPerVertex){this._mesh._normals[0]=pnts.toGL();}else if(!this._vf.normalPerVertex){var indexes=this._vf.index;this._mesh._normals[0]=[];var faceCnt=0;for(var i=0;i0)&&(i%3===0)){faceCnt++;}
+this._mesh._normals[0].push(pnts[faceCnt].x);this._mesh._normals[0].push(pnts[faceCnt].y);this._mesh._normals[0].push(pnts[faceCnt].z);}}
+Array.forEach(this._parentNodes,function(node){node._dirty.normals=true;});}
+else if(fieldName=="texCoord")
+{var texCoordNode=this._cf.texCoord.node;if(x3dom.isa(texCoordNode,x3dom.nodeTypes.MultiTextureCoordinate)){if(texCoordNode._cf.texCoord.nodes.length)
+texCoordNode=texCoordNode._cf.texCoord.nodes[0];}
+pnts=texCoordNode._vf.point;this._mesh._texCoords[0]=pnts.toGL();Array.forEach(this._parentNodes,function(node){node._dirty.texcoords=true;});}}}));x3dom.registerNodeType("IndexedTriangleStripSet","Rendering",defineClass(x3dom.nodeTypes.X3DComposedGeometryNode,function(ctx){x3dom.nodeTypes.IndexedTriangleStripSet.superClass.call(this,ctx);this.addField_MFInt32(ctx,'index',[]);this._hasIndexOffset=false;this._indexOffset=null;},{hasIndexOffset:function(){return this._hasIndexOffset;},nodeChanged:function()
+{this.handleAttribs();var hasNormal=false,hasTexCoord=false,hasColor=false;var colPerVert=this._vf.colorPerVertex;var normPerVert=this._vf.normalPerVertex;var indexes=this._vf.index;if(indexes.length&&indexes[indexes.length-1]!=-1)
+{indexes.push(-1);}
+var positions,normals,texCoords,colors;var coordNode=this._cf.coord.node;x3dom.debug.assert(coordNode);positions=coordNode._vf.point;var normalNode=this._cf.normal.node;if(normalNode){hasNormal=true;normals=normalNode._vf.vector;}
+else{hasNormal=false;}
+var texMode="",numTexComponents=2;var texCoordNode=this._cf.texCoord.node;if(x3dom.isa(texCoordNode,x3dom.nodeTypes.MultiTextureCoordinate)){if(texCoordNode._cf.texCoord.nodes.length)
+texCoordNode=texCoordNode._cf.texCoord.nodes[0];}
+if(texCoordNode){if(texCoordNode._vf.point){hasTexCoord=true;texCoords=texCoordNode._vf.point;if(x3dom.isa(texCoordNode,x3dom.nodeTypes.TextureCoordinate3D)){numTexComponents=3;}}
+else if(texCoordNode._vf.mode){texMode=texCoordNode._vf.mode;}}
+else{hasTexCoord=false;}
+this._mesh._numTexComponents=numTexComponents;var numColComponents=3;var colorNode=this._cf.color.node;if(colorNode){hasColor=true;colors=colorNode._vf.color;if(x3dom.isa(colorNode,x3dom.nodeTypes.ColorRGBA)){numColComponents=4;}}
+else{hasColor=false;}
+this._mesh._numColComponents=numColComponents;this._mesh._indices[0]=[];this._mesh._positions[0]=[];this._mesh._normals[0]=[];this._mesh._texCoords[0]=[];this._mesh._colors[0]=[];this.invalidateVolume();this._mesh._numFaces=0;this._mesh._numCoords=0;var faceCnt=0,cnt=0;if(hasNormal&&positions.length<=x3dom.Utils.maxIndexableCoords)
+{this._hasIndexOffset=true;this._indexOffset=[];this._mesh._primType='TRIANGLESTRIP';var indexOffset=[0];for(i=0;ix3dom.Utils.maxIndexableCoords))
+{if(fieldName=="coord"){this._mesh._positions[0]=[];this._mesh._indices[0]=[];this._mesh._normals[0]=[];this._mesh._texCoords[0]=[];var hasNormal=false,hasTexCoord=false,hasColor=false;var colPerVert=this._vf.colorPerVertex;var normPerVert=this._vf.normalPerVertex;var indexes=this._vf.index;var positions,normals,texCoords,colors;var coordNode=this._cf.coord.node;x3dom.debug.assert(coordNode);positions=coordNode._vf.point;var normalNode=this._cf.normal.node;if(normalNode){hasNormal=true;normals=normalNode._vf.vector;}
+else{hasNormal=false;}
+var texMode="",numTexComponents=2;var texCoordNode=this._cf.texCoord.node;if(x3dom.isa(texCoordNode,x3dom.nodeTypes.MultiTextureCoordinate)){if(texCoordNode._cf.texCoord.nodes.length)
+texCoordNode=texCoordNode._cf.texCoord.nodes[0];}
+if(texCoordNode){if(texCoordNode._vf.point){hasTexCoord=true;texCoords=texCoordNode._vf.point;if(x3dom.isa(texCoordNode,x3dom.nodeTypes.TextureCoordinate3D)){numTexComponents=3;}}
+else if(texCoordNode._vf.mode){texMode=texCoordNode._vf.mode;}}
+else{hasTexCoord=false;}
+this._mesh._numTexComponents=numTexComponents;var numColComponents=3;var colorNode=this._cf.color.node;if(colorNode){hasColor=true;colors=colorNode._vf.color;if(x3dom.isa(colorNode,x3dom.nodeTypes.ColorRGBA)){numColComponents=4;}}
+else{hasColor=false;}
+this._mesh._numColComponents=numColComponents;this._mesh._indices[0]=[];this._mesh._positions[0]=[];this._mesh._normals[0]=[];this._mesh._texCoords[0]=[];this._mesh._colors[0]=[];var faceCnt=0,cnt=0;var p1,p2,p3,n1,n2,n3,t1,t2,t3,c1,c2,c3;var swapOrder=false;if(hasNormal||hasTexCoord||hasColor){for(var i=1;i0){positions.pop();}
+this._mesh._indices[0]=new Array(positions.length);this._mesh._positions[0]=[];this._mesh._normals[0]=[];this._mesh._texCoords[0]=[];this._mesh._colors[0]=[];var posMax=positions.length/3;var faceCnt,i=0;for(faceCnt=0;faceCnt0||this._cf.material.node._vf.backTransparency&&this._cf.material.node._vf.backTransparency>0)){this._vf.sortType='transparent';}
+else if(this._cf.texture.node&&this._cf.texture.node._vf.url.length){if(this._cf.texture.node._vf.url[0].toLowerCase().indexOf('.'+'png')>=0){this._vf.sortType='transparent';}
+else{this._vf.sortType='opaque';}}
+else{this._vf.sortType='opaque';}}},texTransformMatrix:function(){if(this._cf.textureTransform.node===null){return x3dom.fields.SFMatrix4f.identity();}
+else{return this._cf.textureTransform.node.texTransformMatrix();}},parentAdded:function(parent){if(this!=x3dom.nodeTypes.Appearance._defaultNode){parent.setAppDirty();}}}));x3dom.nodeTypes.Appearance.defaultNode=function(){if(!x3dom.nodeTypes.Appearance._defaultNode){x3dom.nodeTypes.Appearance._defaultNode=new x3dom.nodeTypes.Appearance();x3dom.nodeTypes.Appearance._defaultNode.nodeChanged();}
+return x3dom.nodeTypes.Appearance._defaultNode;};x3dom.registerNodeType("X3DAppearanceChildNode","Shape",defineClass(x3dom.nodeTypes.X3DNode,function(ctx){x3dom.nodeTypes.X3DAppearanceChildNode.superClass.call(this,ctx);}));x3dom.registerNodeType("BlendMode","Shape",defineClass(x3dom.nodeTypes.X3DAppearanceChildNode,function(ctx){x3dom.nodeTypes.BlendMode.superClass.call(this,ctx);this.addField_SFString(ctx,'srcFactor',"src_alpha");this.addField_SFString(ctx,'destFactor',"one_minus_src_alpha");this.addField_SFColor(ctx,'color',1,1,1);this.addField_SFFloat(ctx,'colorTransparency',0);this.addField_SFString(ctx,'alphaFunc',"none");this.addField_SFFloat(ctx,'alphaFuncValue',0);this.addField_SFString(ctx,'equation',"none");}));x3dom.registerNodeType("DepthMode","Shape",defineClass(x3dom.nodeTypes.X3DAppearanceChildNode,function(ctx){x3dom.nodeTypes.DepthMode.superClass.call(this,ctx);this.addField_SFBool(ctx,'enableDepthTest',true);this.addField_SFString(ctx,'depthFunc',"none");this.addField_SFBool(ctx,'readOnly',false);this.addField_SFFloat(ctx,'zNearRange',-1);this.addField_SFFloat(ctx,'zFarRange',-1);}));x3dom.registerNodeType("ColorMaskMode","Shape",defineClass(x3dom.nodeTypes.X3DAppearanceChildNode,function(ctx){x3dom.nodeTypes.ColorMaskMode.superClass.call(this,ctx);this.addField_SFBool(ctx,'maskR',true);this.addField_SFBool(ctx,'maskG',true);this.addField_SFBool(ctx,'maskB',true);this.addField_SFBool(ctx,'maskA',true);}));x3dom.registerNodeType("LineProperties","Shape",defineClass(x3dom.nodeTypes.X3DAppearanceChildNode,function(ctx){x3dom.nodeTypes.LineProperties.superClass.call(this,ctx);this.addField_SFBool(ctx,'applied',true);this.addField_SFInt32(ctx,'linetype',1);this.addField_SFFloat(ctx,'linewidthScaleFactor',0);}));x3dom.registerNodeType("X3DMaterialNode","Shape",defineClass(x3dom.nodeTypes.X3DAppearanceChildNode,function(ctx){x3dom.nodeTypes.X3DMaterialNode.superClass.call(this,ctx);}));x3dom.registerNodeType("Material","Shape",defineClass(x3dom.nodeTypes.X3DMaterialNode,function(ctx){x3dom.nodeTypes.Material.superClass.call(this,ctx);this.addField_SFFloat(ctx,'ambientIntensity',0.2);this.addField_SFColor(ctx,'diffuseColor',0.8,0.8,0.8);this.addField_SFColor(ctx,'emissiveColor',0,0,0);this.addField_SFFloat(ctx,'shininess',0.2);this.addField_SFColor(ctx,'specularColor',0,0,0);this.addField_SFFloat(ctx,'transparency',0);},{fieldChanged:function(fieldName){if(fieldName=="ambientIntensity"||fieldName=="diffuseColor"||fieldName=="emissiveColor"||fieldName=="shininess"||fieldName=="specularColor"||fieldName=="transparency")
+{Array.forEach(this._parentNodes,function(app){Array.forEach(app._parentNodes,function(shape){shape._dirty.material=true;});app.checkSortType();});}}}));x3dom.nodeTypes.Material.defaultNode=function(){if(!x3dom.nodeTypes.Material._defaultNode){x3dom.nodeTypes.Material._defaultNode=new x3dom.nodeTypes.Material();x3dom.nodeTypes.Material._defaultNode.nodeChanged();}
+return x3dom.nodeTypes.Material._defaultNode;};x3dom.registerNodeType("TwoSidedMaterial","Shape",defineClass(x3dom.nodeTypes.Material,function(ctx){x3dom.nodeTypes.TwoSidedMaterial.superClass.call(this,ctx);this.addField_SFFloat(ctx,'backAmbientIntensity',0.2);this.addField_SFColor(ctx,'backDiffuseColor',0.8,0.8,0.8);this.addField_SFColor(ctx,'backEmissiveColor',0,0,0);this.addField_SFFloat(ctx,'backShininess',0.2);this.addField_SFColor(ctx,'backSpecularColor',0,0,0);this.addField_SFFloat(ctx,'backTransparency',0);this.addField_SFBool(ctx,'separateBackColor',false);},{fieldChanged:function(fieldName){if(fieldName=="ambientIntensity"||fieldName=="diffuseColor"||fieldName=="emissiveColor"||fieldName=="shininess"||fieldName=="specularColor"||fieldName=="transparency"||fieldName=="backAmbientIntensity"||fieldName=="backDiffuseColor"||fieldName=="backEmissiveColor"||fieldName=="backShininess"||fieldName=="backSpecularColor"||fieldName=="backTransparency"||fieldName=="separateBackColor")
+{Array.forEach(this._parentNodes,function(app){Array.forEach(app._parentNodes,function(shape){shape._dirty.material=true;});app.checkSortType();});}}}));x3dom.registerNodeType("X3DShapeNode","Shape",defineClass(x3dom.nodeTypes.X3DBoundedObject,function(ctx){x3dom.nodeTypes.X3DShapeNode.superClass.call(this,ctx);this.addField_SFBool(ctx,'isPickable',true);this.addField_SFInt32(ctx,'idOffset',0);this.addField_SFNode('appearance',x3dom.nodeTypes.X3DAppearanceNode);this.addField_SFNode('geometry',x3dom.nodeTypes.X3DGeometryNode);this._objectID=0;this._shaderProperties=null;this._clipPlanes=[];this._cleanupGLObjects=null;this._dirty={positions:true,normals:true,texcoords:true,colors:true,specialAttribs:true,indexes:true,texture:true,material:true,text:true,shader:true,ids:true};this._coordStrideOffset=[0,0];this._normalStrideOffset=[0,0];this._texCoordStrideOffset=[0,0];this._colorStrideOffset=[0,0];this._idStrideOffset=[0,0];this._tessellationProperties=[];},{collectDrawableObjects:function(transform,drawableCollection,singlePath,invalidateCache,planeMask,clipPlanes)
+{var graphState=this.graphState();if(singlePath&&(this._parentNodes.length>1))
+singlePath=false;if(singlePath&&(invalidateCache=invalidateCache||this.cacheInvalid()))
+this.invalidateCache();if(!this._cf.geometry.node||drawableCollection.cull(transform,graphState,singlePath,planeMask)<=0){return false;}
+if(singlePath&&!this._graph.globalMatrix)
+this._graph.globalMatrix=transform;if(this._clipPlanes.length!=clipPlanes.length)
+{this._dirty.shader=true;}
+this._clipPlanes=clipPlanes;drawableCollection.addShape(this,transform,graphState);return true;},getVolume:function()
+{var vol=this._graph.volume;if(!this.volumeValid()&&this._vf.render)
+{var geo=this._cf.geometry.node;var childVol=geo?geo.getVolume():null;if(childVol&&childVol.isValid())
+vol.extendBounds(childVol.min,childVol.max);}
+return vol;},getCenter:function(){var geo=this._cf.geometry.node;return(geo?geo.getCenter():new x3dom.fields.SFVec3f(0,0,0));},getDiameter:function(){var geo=this._cf.geometry.node;return(geo?geo.getDiameter():0);},doIntersect:function(line){return this._cf.geometry.node.doIntersect(line);},forceUpdateCoverage:function()
+{var geo=this._cf.geometry.node;return(geo?geo.forceUpdateCoverage():false);},tessellationProperties:function()
+{var geo=this._cf.geometry.node;if(geo&&geo._indexOffset)
+return geo._indexOffset;else
+return this._tessellationProperties;},isLit:function(){return this._cf.geometry.node._vf.lit;},isSolid:function(){var twoSidedMat=(this._cf.appearance.node&&this._cf.appearance.node._cf.material.node&&x3dom.isa(this._cf.appearance.node._cf.material.node,x3dom.nodeTypes.TwoSidedMaterial));return this._cf.geometry.node._vf.solid&&!twoSidedMat;},isCCW:function(){return this._cf.geometry.node._vf.ccw;},parentRemoved:function(parent){for(var i=0,n=this._childNodes.length;i0)
+this.invalidateVolume();if(this._cleanupGLObjects){this._cleanupGLObjects();}},unsetDirty:function(){this._dirty.positions=false;this._dirty.normals=false;this._dirty.texcoords=false;this._dirty.colors=false;this._dirty.specialAttribs=false;this._dirty.indexes=false;this._dirty.texture=false;this._dirty.material=false;this._dirty.text=false;this._dirty.shader=false;},unsetGeoDirty:function(){this._dirty.positions=false;this._dirty.normals=false;this._dirty.texcoords=false;this._dirty.colors=false;this._dirty.specialAttribs=false;this._dirty.indexes=false;},setAllDirty:function(){this._dirty.positions=true;this._dirty.normals=true;this._dirty.texcoords=true;this._dirty.colors=true;this._dirty.specialAttribs=true;this._dirty.indexes=true;this._dirty.texture=true;this._dirty.material=true;this._dirty.text=true;this._dirty.shader=true;this.invalidateVolume();},setAppDirty:function(){this._dirty.texture=true;this._dirty.material=true;this._dirty.shader=true;},setGeoDirty:function(){this._dirty.positions=true;this._dirty.normals=true;this._dirty.texcoords=true;this._dirty.colors=true;this._dirty.specialAttribs=true;this._dirty.indexes=true;this.invalidateVolume();},getShaderProperties:function(viewarea)
+{if(this._shaderProperties==null||this._dirty.shader==true||(this._webgl!==undefined&&this._webgl.dirtyLighting!=x3dom.Utils.checkDirtyLighting(viewarea))||x3dom.Utils.checkDirtyEnvironment(viewarea,this._shaderProperties)==true)
+{this._shaderProperties=x3dom.Utils.generateProperties(viewarea,this);this._dirty.shader=false;if(this._webgl!==undefined)
+{this._webgl.dirtyLighting=x3dom.Utils.checkDirtyLighting(viewarea);}}
+return this._shaderProperties;},getTextures:function(){var textures=[];var appearance=this._cf.appearance.node;if(appearance){var tex=appearance._cf.texture.node;if(tex){if(x3dom.isa(tex,x3dom.nodeTypes.MultiTexture)){textures=textures.concat(tex.getTextures());}
+else{textures.push(tex);}}
+var shader=appearance._cf.shaders.nodes[0];if(shader){if(x3dom.isa(shader,x3dom.nodeTypes.CommonSurfaceShader)){textures=textures.concat(shader.getTextures());}}}
+var geometry=this._cf.geometry.node;if(geometry){if(x3dom.isa(geometry,x3dom.nodeTypes.ImageGeometry)){textures=textures.concat(geometry.getTextures());}
+else if(x3dom.isa(geometry,x3dom.nodeTypes.Text)){textures=textures.concat(geometry);}}
+return textures;}}));x3dom.registerNodeType("Shape","Shape",defineClass(x3dom.nodeTypes.X3DShapeNode,function(ctx){x3dom.nodeTypes.Shape.superClass.call(this,ctx);},{nodeChanged:function(){if(!this._cf.appearance.node){}
+if(!this._cf.geometry.node){if(this._DEF)
+x3dom.debug.logError("No geometry given in Shape/"+this._DEF);}
+else if(!this._objectID){this._objectID=++x3dom.nodeTypes.Shape.objectID;x3dom.nodeTypes.Shape.idMap.nodeID[this._objectID]=this;}
+this.invalidateVolume();}}));x3dom.nodeTypes.Shape.shaderPartID=0;x3dom.nodeTypes.Shape.objectID=0;x3dom.nodeTypes.Shape.idMap={nodeID:{},remove:function(obj){for(var prop in this.nodeID){if(this.nodeID.hasOwnProperty(prop)){var val=this.nodeID[prop];if(val._objectID&&obj._objectID&&val._objectID===obj._objectID)
+{delete this.nodeID[prop];x3dom.debug.logInfo("Unreg "+val._objectID);}}}}};x3dom.registerNodeType("ExternalShape","Shape",defineClass(x3dom.nodeTypes.X3DShapeNode,function(ctx){x3dom.nodeTypes.ExternalShape.superClass.call(this,ctx);this.addField_MFString(ctx,'url',[]);this._currentURLIdx=0;this._cf.geometry.node=new x3dom.nodeTypes.X3DSpatialGeometryNode(ctx);this.loaded=false;},{update:function(shape,shaderProgram,gl,viewarea,context){var that=this;if(this._vf['url'].length==0||this._currentURLIdx>=this._vf['url'].length)
+{return;}
+var xhr=new XMLHttpRequest();xhr.open("GET",this._nameSpace.getURL(this._vf['url'][this._currentURLIdx]),true);xhr.responseType="arraybuffer";xhr.send(null);xhr.onerror=function(){x3dom.debug.logError("Unable to load SRC data from URL \""+that._vf['url'][that._currentURLIdx]+"\"");};xhr.onload=function(){if((xhr.status==200||xhr.status==0)){var glTF=new x3dom.glTF.glTFLoader(xhr.response);if(glTF.header.sceneLength>0)
+{glTF.loaded={};glTF.loaded.meshes={};glTF.loaded.meshCount=0;that.glTF=glTF;var url=that._vf['url'][that._currentURLIdx];if(url.includes('#'))
+{var split=url.split('#');var meshName=split[split.length-1];glTF.getMesh(shape,shaderProgram,gl,meshName);}
+else
+{glTF.getScene(shape,shaderProgram,gl);}
+for(var key in glTF._mesh){if(!glTF._mesh.hasOwnProperty(key))continue;that._cf.geometry.node._mesh[key]=glTF._mesh[key];}}
+else
+{if((that._currentURLIdx+1)1))
+singlePath=false;if(singlePath&&(invalidateCache=invalidateCache||this.cacheInvalid()))
+this.invalidateCache();if(singlePath&&!this._graph.globalMatrix)
+this._graph.globalMatrix=transform;if(this._clipPlanes.length!=clipPlanes.length)
+{this._dirty.shader=true;}
+this._clipPlanes=clipPlanes;drawableCollection.addShape(this,transform,graphState);return true;},getShaderProperties:function(viewarea)
+{var properties=x3dom.Utils.generateProperties(viewarea,this);properties.CSHADER=-1;properties.LIGHTS=viewarea.getLights().length+(viewarea._scene.getNavigationInfo()._vf.headlight);properties.EMPTY_SHADER=1;return properties;},nodeChanged:function()
+{if(!this._objectID){this._objectID=++x3dom.nodeTypes.Shape.objectID;x3dom.nodeTypes.Shape.idMap.nodeID[this._objectID]=this;}}}));x3dom.registerNodeType("X3DLightNode","Lighting",defineClass(x3dom.nodeTypes.X3DChildNode,function(ctx){x3dom.nodeTypes.X3DLightNode.superClass.call(this,ctx);if(ctx)
+ctx.doc._nodeBag.lights.push(this);else
+x3dom.debug.logWarning("X3DLightNode: No runtime context found!");this._lightID=0;this._dirty=true;this.addField_SFFloat(ctx,'ambientIntensity',0);this.addField_SFColor(ctx,'color',1,1,1);this.addField_SFFloat(ctx,'intensity',1);this.addField_SFBool(ctx,'global',false);this.addField_SFBool(ctx,'on',true);this.addField_SFFloat(ctx,'shadowIntensity',0);this.addField_SFInt32(ctx,'shadowMapSize',1024);this.addField_SFInt32(ctx,'shadowFilterSize',0);this.addField_SFFloat(ctx,'shadowOffset',0);this.addField_SFFloat(ctx,'zNear',-1);this.addField_SFFloat(ctx,'zFar',-1);},{getViewMatrix:function(vec){return x3dom.fields.SFMatrix4f.identity;},nodeChanged:function(){if(!this._lightID){this._lightID=++x3dom.nodeTypes.X3DLightNode.lightID;}},fieldChanged:function(fieldName)
+{if(this._vf.hasOwnProperty(fieldName)){this._dirty=true;}},parentRemoved:function(parent)
+{if(this._parentNodes.length===1&&this._parentNodes[0]==parent){var doc=this.findX3DDoc();for(var i=0,n=doc._nodeBag.lights.length;i=this._vf.duration){return 1;}
+return this.stepResponseCore(t/this._vf.duration);},stepResponseCore:function(T)
+{return 0.5-0.5*Math.cos(T*Math.PI);}}));x3dom.registerNodeType("X3DChaserNode","Followers",defineClass(x3dom.nodeTypes.X3DFollowerNode,function(ctx){x3dom.nodeTypes.X3DChaserNode.superClass.call(this,ctx);this.addField_SFTime(ctx,'duration',1);this._initDone=false;this._stepTime=0;this._currTime=0;this._bufferEndTime=0;this._numSupports=60;}));x3dom.registerNodeType("X3DDamperNode","Followers",defineClass(x3dom.nodeTypes.X3DFollowerNode,function(ctx){x3dom.nodeTypes.X3DDamperNode.superClass.call(this,ctx);this.addField_SFTime(ctx,'tau',0.3);this.addField_SFFloat(ctx,'tolerance',-1);this.addField_SFInt32(ctx,'order',3);this._eps=this._vf.tolerance<0?this._eps:this._vf.tolerance;this._lastTick=0;}));x3dom.registerNodeType("ColorChaser","Followers",defineClass(x3dom.nodeTypes.X3DChaserNode,function(ctx){x3dom.nodeTypes.ColorChaser.superClass.call(this,ctx);this.addField_SFColor(ctx,'initialDestination',0.8,0.8,0.8);this.addField_SFColor(ctx,'initialValue',0.8,0.8,0.8);this.addField_SFColor(ctx,'value',0,0,0);this.addField_SFColor(ctx,'destination',0,0,0);this._buffer=new x3dom.fields.MFColor();this._previousValue=new x3dom.fields.SFColor(0,0,0);this._value=new x3dom.fields.SFColor(0,0,0);this.initialize();},{fieldChanged:function(fieldName)
+{if(fieldName.indexOf("destination")>=0)
+{this.initialize();this.updateBuffer(this._currTime);if(!this._vf.isActive){this.postMessage('isActive',true);}}
+else if(fieldName.indexOf("value")>=0)
+{this.initialize();this._previousValue.setValues(this._vf.value);for(var C=1;C=0;C--)
+{DeltaIn=this._buffer[C].subtract(this._buffer[C+1]);DeltaOut=DeltaIn.multiply(this.stepResponse((C+Frac)*this._stepTime));Output=Output.add(DeltaOut);}
+if(!Output.equals(this._value,this._eps)){this._value.setValues(Output);this.postMessage('value',this._value);}
+else{this.postMessage('isActive',false);}
+return this._vf.isActive;},updateBuffer:function(now)
+{var Frac=(now-this._bufferEndTime)/this._stepTime;var C;var NumToShift;var Alpha;if(Frac>=1)
+{NumToShift=Math.floor(Frac);Frac-=NumToShift;if(NumToShift=NumToShift;C--){this._buffer[C]=this._buffer[C-NumToShift];}
+for(C=0;C=0)
+{if(!this._value0.equals(this._vf.destination,this._eps)){this._value0=this._vf.destination;if(!this._vf.isActive){this.postMessage('isActive',true);}}}
+else if(fieldName.indexOf("value")>=0)
+{this._value1.setValues(this._vf.value);this._value2.setValues(this._vf.value);this._value3.setValues(this._vf.value);this._value4.setValues(this._vf.value);this._value5.setValues(this._vf.value);this._lastTick=0;this.postMessage('value',this._value5);if(!this._vf.isActive){this._lastTick=0;this.postMessage('isActive',true);}}},initialize:function()
+{this._value0.setValues(this._vf.initialDestination);this._value1.setValues(this._vf.initialValue);this._value2.setValues(this._vf.initialValue);this._value3.setValues(this._vf.initialValue);this._value4.setValues(this._vf.initialValue);this._value5.setValues(this._vf.initialValue);this._lastTick=0;var active=!this._value0.equals(this._value1,this._eps);if(this._vf.isActive!==active){this.postMessage('isActive',active);}},distance:function(a,b)
+{var diff=a.subtract(b);return Math.sqrt(diff.r*diff.r+diff.g*diff.g+diff.b*diff.b);},tick:function(now)
+{if(!this._lastTick)
+{this._lastTick=now;return false;}
+var delta=now-this._lastTick;var alpha=Math.exp(-delta/this._vf.tau);this._value1=this._vf.order>0&&this._vf.tau?this._value0.add(this._value1.subtract(this._value0).multiply(alpha)):new x3dom.fields.SFColor(this._value0.r,this._value0.g,this._value0.b);this._value2=this._vf.order>1&&this._vf.tau?this._value1.add(this._value2.subtract(this._value1).multiply(alpha)):new x3dom.fields.SFColor(this._value1.r,this._value1.g,this._value1.b);this._value3=this._vf.order>2&&this._vf.tau?this._value2.add(this._value3.subtract(this._value2).multiply(alpha)):new x3dom.fields.SFColor(this._value2.r,this._value2.g,this._value2.b);this._value4=this._vf.order>3&&this._vf.tau?this._value3.add(this._value4.subtract(this._value3).multiply(alpha)):new x3dom.fields.SFColor(this._value3.r,this._value3.g,this._value3.b);this._value5=this._vf.order>4&&this._vf.tau?this._value4.add(this._value5.subtract(this._value4).multiply(alpha)):new x3dom.fields.SFColor(this._value4.r,this._value4.g,this._value4.b);var dist=this.distance(this._value1,this._value0);if(this._vf.order>1)
+{var dist2=this.distance(this._value2,this._value1);if(dist2>dist){dist=dist2;}}
+if(this._vf.order>2)
+{var dist3=this.distance(this._value3,this._value2);if(dist3>dist){dist=dist3;}}
+if(this._vf.order>3)
+{var dist4=this.distance(this._value4,this._value3);if(dist4>dist){dist=dist4;}}
+if(this._vf.order>4)
+{var dist5=this.distance(this._value5,this._value4);if(dist5>dist){dist=dist5;}}
+if(dist<=this._eps)
+{this._value1.setValues(this._value0);this._value2.setValues(this._value0);this._value3.setValues(this._value0);this._value4.setValues(this._value0);this._value5.setValues(this._value0);this.postMessage('value',this._value0);this.postMessage('isActive',false);this._lastTick=0;return false;}
+this.postMessage('value',this._value5);this._lastTick=now;return true;}}));x3dom.registerNodeType("OrientationChaser","Followers",defineClass(x3dom.nodeTypes.X3DChaserNode,function(ctx){x3dom.nodeTypes.OrientationChaser.superClass.call(this,ctx);this.addField_SFRotation(ctx,'initialDestination',0,1,0,0);this.addField_SFRotation(ctx,'initialValue',0,1,0,0);this.addField_SFRotation(ctx,'value',0,1,0,0);this.addField_SFRotation(ctx,'destination',0,1,0,0);this._numSupports=30;this._buffer=new x3dom.fields.MFRotation();this._previousValue=new x3dom.fields.Quaternion(0,1,0,0);this._value=new x3dom.fields.Quaternion(0,1,0,0);this.initialize();},{fieldChanged:function(fieldName)
+{if(fieldName.indexOf("destination")>=0)
+{this.initialize();this.updateBuffer(this._currTime);if(!this._vf.isActive){this.postMessage('isActive',true);}}
+else if(fieldName.indexOf("value")>=0)
+{this.initialize();this._previousValue.setValues(this._vf.value);for(var C=1;C=0;C--)
+{DeltaIn=this._buffer[C+1].inverse().multiply(this._buffer[C]);Output=Output.slerp(Output.multiply(DeltaIn),this.stepResponse((C+Frac)*this._stepTime));}
+if(!Output.equals(this._value,this._eps)){Output=Output.normalize(Output);this._value.setValues(Output);this.postMessage('value',this._value);}
+else{this.postMessage('isActive',false);}
+return this._vf.isActive;},updateBuffer:function(now)
+{var Frac=(now-this._bufferEndTime)/this._stepTime;var C;var NumToShift;var Alpha;if(Frac>=1)
+{NumToShift=Math.floor(Frac);Frac-=NumToShift;if(NumToShift=NumToShift;C--){this._buffer[C]=x3dom.fields.Quaternion.copy(this._buffer[C-NumToShift]);}
+for(C=0;C=0)
+{if(!this._value0.equals(this._vf.destination,this._eps)){this._value0=this._vf.destination;if(!this._vf.isActive){this.postMessage('isActive',true);}}}
+else if(fieldName.indexOf("value")>=0)
+{this._value1.setValues(this._vf.value);this._value2.setValues(this._vf.value);this._value3.setValues(this._vf.value);this._value4.setValues(this._vf.value);this._value5.setValues(this._vf.value);this._lastTick=0;this.postMessage('value',this._value5);if(!this._vf.isActive){this._lastTick=0;this.postMessage('isActive',true);}}},initialize:function()
+{this._value0.setValues(this._vf.initialDestination);this._value1.setValues(this._vf.initialValue);this._value2.setValues(this._vf.initialValue);this._value3.setValues(this._vf.initialValue);this._value4.setValues(this._vf.initialValue);this._value5.setValues(this._vf.initialValue);this._lastTick=0;var active=!this._value0.equals(this._value1,this._eps);if(this._vf.isActive!==active){this.postMessage('isActive',active);}},tick:function(now)
+{if(!this._lastTick)
+{this._lastTick=now;return false;}
+var delta=now-this._lastTick;var alpha=Math.exp(-delta/this._vf.tau);this._value1=this._vf.order>0&&this._vf.tau?this._value0.slerp(this._value1,alpha):new x3dom.fields.Quaternion(this._value0.x,this._value0.y,this._value0.z,this._value0.w);this._value2=this._vf.order>1&&this._vf.tau?this._value1.slerp(this._value2,alpha):new x3dom.fields.Quaternion(this._value1.x,this._value1.y,this._value1.z,this._value1.w);this._value3=this._vf.order>2&&this._vf.tau?this._value2.slerp(this._value3,alpha):new x3dom.fields.Quaternion(this._value2.x,this._value2.y,this._value2.z,this._value2.w);this._value4=this._vf.order>3&&this._vf.tau?this._value3.slerp(this._value4,alpha):new x3dom.fields.Quaternion(this._value3.x,this._value3.y,this._value3.z,this._value3.w);this._value5=this._vf.order>4&&this._vf.tau?this._value4.slerp(this._value5,alpha):new x3dom.fields.Quaternion(this._value4.x,this._value4.y,this._value4.z,this._value4.w);var dist=Math.abs(this._value1.inverse().multiply(this._value0).angle());if(this._vf.order>1)
+{var dist2=Math.abs(this._value2.inverse().multiply(this._value1).angle());if(dist2>dist){dist=dist2;}}
+if(this._vf.order>2)
+{var dist3=Math.abs(this._value3.inverse().multiply(this._value2).angle());if(dist3>dist){dist=dist3;}}
+if(this._vf.order>3)
+{var dist4=Math.abs(this._value4.inverse().multiply(this._value3).angle());if(dist4>dist){dist=dist4;}}
+if(this._vf.order>4)
+{var dist5=Math.abs(this._value5.inverse().multiply(this._value4).angle());if(dist5>dist){dist=dist5;}}
+if(dist<=this._eps)
+{this._value1.setValues(this._value0);this._value2.setValues(this._value0);this._value3.setValues(this._value0);this._value4.setValues(this._value0);this._value5.setValues(this._value0);this.postMessage('value',this._value0);this.postMessage('isActive',false);this._lastTick=0;return false;}
+this.postMessage('value',this._value5);this._lastTick=now;return true;}}));x3dom.registerNodeType("PositionChaser","Followers",defineClass(x3dom.nodeTypes.X3DChaserNode,function(ctx){x3dom.nodeTypes.PositionChaser.superClass.call(this,ctx);this.addField_SFVec3f(ctx,'initialDestination',0,0,0);this.addField_SFVec3f(ctx,'initialValue',0,0,0);this.addField_SFVec3f(ctx,'value',0,0,0);this.addField_SFVec3f(ctx,'destination',0,0,0);this._buffer=new x3dom.fields.MFVec3f();this._previousValue=new x3dom.fields.SFVec3f(0,0,0);this._value=new x3dom.fields.SFVec3f(0,0,0);this.initialize();},{fieldChanged:function(fieldName)
+{if(fieldName.indexOf("destination")>=0)
+{this.initialize();this.updateBuffer(this._currTime);if(!this._vf.isActive){this.postMessage('isActive',true);}}
+else if(fieldName.indexOf("value")>=0)
+{this.initialize();this._previousValue.setValues(this._vf.value);for(var C=1;C=0;C--)
+{DeltaIn=this._buffer[C].subtract(this._buffer[C+1]);DeltaOut=DeltaIn.multiply(this.stepResponse((C+Frac)*this._stepTime));Output=Output.add(DeltaOut);}
+if(!Output.equals(this._value,this._eps)){this._value.setValues(Output);this.postMessage('value',this._value);}
+else{this.postMessage('isActive',false);}
+return this._vf.isActive;},updateBuffer:function(now)
+{var Frac=(now-this._bufferEndTime)/this._stepTime;var C;var NumToShift;var Alpha;if(Frac>=1)
+{NumToShift=Math.floor(Frac);Frac-=NumToShift;if(NumToShift=NumToShift;C--){this._buffer[C]=x3dom.fields.SFVec3f.copy(this._buffer[C-NumToShift]);}
+for(C=0;C=0)
+{this.initialize();this.updateBuffer(this._currTime);if(!this._vf.isActive){this.postMessage('isActive',true);}}
+else if(fieldName.indexOf("value")>=0)
+{this.initialize();this._previousValue.setValues(this._vf.value);for(var C=1;C=0;C--)
+{DeltaIn=this._buffer[C].subtract(this._buffer[C+1]);DeltaOut=DeltaIn.multiply(this.stepResponse((C+Frac)*this._stepTime));Output=Output.add(DeltaOut);}
+if(!Output.equals(this._value,this._eps)){this._value.setValues(Output);this.postMessage('value',this._value);}
+else{this.postMessage('isActive',false);}
+return this._vf.isActive;},updateBuffer:function(now)
+{var Frac=(now-this._bufferEndTime)/this._stepTime;var C;var NumToShift;var Alpha;if(Frac>=1)
+{NumToShift=Math.floor(Frac);Frac-=NumToShift;if(NumToShift=NumToShift;C--){this._buffer[C]=x3dom.fields.SFVec2f.copy(this._buffer[C-NumToShift]);}
+for(C=0;C=0)
+{if(!this._value0.equals(this._vf.destination,this._eps)){this._value0=this._vf.destination;if(!this._vf.isActive){this.postMessage('isActive',true);}}}
+else if(fieldName.indexOf("value")>=0)
+{this._value1.setValues(this._vf.value);this._value2.setValues(this._vf.value);this._value3.setValues(this._vf.value);this._value4.setValues(this._vf.value);this._value5.setValues(this._vf.value);this._lastTick=0;this.postMessage('value',this._value5);if(!this._vf.isActive){this._lastTick=0;this.postMessage('isActive',true);}}},initialize:function()
+{this._value0.setValues(this._vf.initialDestination);this._value1.setValues(this._vf.initialValue);this._value2.setValues(this._vf.initialValue);this._value3.setValues(this._vf.initialValue);this._value4.setValues(this._vf.initialValue);this._value5.setValues(this._vf.initialValue);this._lastTick=0;var active=!this._value0.equals(this._value1,this._eps);if(this._vf.isActive!==active){this.postMessage('isActive',active);}},tick:function(now)
+{if(!this._lastTick)
+{this._lastTick=now;return false;}
+var delta=now-this._lastTick;var alpha=Math.exp(-delta/this._vf.tau);this._value1=this._vf.order>0&&this._vf.tau?this._value0.add(this._value1.subtract(this._value0).multiply(alpha)):new x3dom.fields.SFVec3f(this._value0.x,this._value0.y,this._value0.z);this._value2=this._vf.order>1&&this._vf.tau?this._value1.add(this._value2.subtract(this._value1).multiply(alpha)):new x3dom.fields.SFVec3f(this._value1.x,this._value1.y,this._value1.z);this._value3=this._vf.order>2&&this._vf.tau?this._value2.add(this._value3.subtract(this._value2).multiply(alpha)):new x3dom.fields.SFVec3f(this._value2.x,this._value2.y,this._value2.z);this._value4=this._vf.order>3&&this._vf.tau?this._value3.add(this._value4.subtract(this._value3).multiply(alpha)):new x3dom.fields.SFVec3f(this._value3.x,this._value3.y,this._value3.z);this._value5=this._vf.order>4&&this._vf.tau?this._value4.add(this._value5.subtract(this._value4).multiply(alpha)):new x3dom.fields.SFVec3f(this._value4.x,this._value4.y,this._value4.z);var dist=this._value1.subtract(this._value0).length();if(this._vf.order>1)
+{var dist2=this._value2.subtract(this._value1).length();if(dist2>dist){dist=dist2;}}
+if(this._vf.order>2)
+{var dist3=this._value3.subtract(this._value2).length();if(dist3>dist){dist=dist3;}}
+if(this._vf.order>3)
+{var dist4=this._value4.subtract(this._value3).length();if(dist4>dist){dist=dist4;}}
+if(this._vf.order>4)
+{var dist5=this._value5.subtract(this._value4).length();if(dist5>dist){dist=dist5;}}
+if(dist<=this._eps)
+{this._value1.setValues(this._value0);this._value2.setValues(this._value0);this._value3.setValues(this._value0);this._value4.setValues(this._value0);this._value5.setValues(this._value0);this.postMessage('value',this._value0);this.postMessage('isActive',false);this._lastTick=0;return false;}
+this.postMessage('value',this._value5);this._lastTick=now;return true;}}));x3dom.registerNodeType("PositionDamper2D","Followers",defineClass(x3dom.nodeTypes.X3DDamperNode,function(ctx){x3dom.nodeTypes.PositionDamper2D.superClass.call(this,ctx);this.addField_SFVec2f(ctx,'initialDestination',0,0);this.addField_SFVec2f(ctx,'initialValue',0,0);this.addField_SFVec2f(ctx,'value',0,0);this.addField_SFVec2f(ctx,'destination',0,0);this._value0=new x3dom.fields.SFVec2f(0,0);this._value1=new x3dom.fields.SFVec2f(0,0);this._value2=new x3dom.fields.SFVec2f(0,0);this._value3=new x3dom.fields.SFVec2f(0,0);this._value4=new x3dom.fields.SFVec2f(0,0);this._value5=new x3dom.fields.SFVec2f(0,0);this.initialize();},{fieldChanged:function(fieldName)
+{if(fieldName==="tolerance")
+{this._eps=this._vf.tolerance<0?0.001:this._vf.tolerance;}
+else if(fieldName.indexOf("destination")>=0)
+{if(!this._value0.equals(this._vf.destination,this._eps)){this._value0=this._vf.destination;if(!this._vf.isActive){this.postMessage('isActive',true);}}}
+else if(fieldName.indexOf("value")>=0)
+{this._value1.setValues(this._vf.value);this._value2.setValues(this._vf.value);this._value3.setValues(this._vf.value);this._value4.setValues(this._vf.value);this._value5.setValues(this._vf.value);this._lastTick=0;this.postMessage('value',this._value5);if(!this._vf.isActive){this._lastTick=0;this.postMessage('isActive',true);}}},initialize:function()
+{this._value0.setValues(this._vf.initialDestination);this._value1.setValues(this._vf.initialValue);this._value2.setValues(this._vf.initialValue);this._value3.setValues(this._vf.initialValue);this._value4.setValues(this._vf.initialValue);this._value5.setValues(this._vf.initialValue);this._lastTick=0;var active=!this._value0.equals(this._value1,this._eps);if(this._vf.isActive!==active){this.postMessage('isActive',active);}},tick:function(now)
+{if(!this._lastTick)
+{this._lastTick=now;return false;}
+var delta=now-this._lastTick;var alpha=Math.exp(-delta/this._vf.tau);this._value1=this._vf.order>0&&this._vf.tau?this._value0.add(this._value1.subtract(this._value0).multiply(alpha)):new x3dom.fields.SFVec2f(this._value0.x,this._value0.y,this._value0.z);this._value2=this._vf.order>1&&this._vf.tau?this._value1.add(this._value2.subtract(this._value1).multiply(alpha)):new x3dom.fields.SFVec2f(this._value1.x,this._value1.y,this._value1.z);this._value3=this._vf.order>2&&this._vf.tau?this._value2.add(this._value3.subtract(this._value2).multiply(alpha)):new x3dom.fields.SFVec2f(this._value2.x,this._value2.y,this._value2.z);this._value4=this._vf.order>3&&this._vf.tau?this._value3.add(this._value4.subtract(this._value3).multiply(alpha)):new x3dom.fields.SFVec2f(this._value3.x,this._value3.y,this._value3.z);this._value5=this._vf.order>4&&this._vf.tau?this._value4.add(this._value5.subtract(this._value4).multiply(alpha)):new x3dom.fields.SFVec2f(this._value4.x,this._value4.y,this._value4.z);var dist=this._value1.subtract(this._value0).length();if(this._vf.order>1)
+{var dist2=this._value2.subtract(this._value1).length();if(dist2>dist){dist=dist2;}}
+if(this._vf.order>2)
+{var dist3=this._value3.subtract(this._value2).length();if(dist3>dist){dist=dist3;}}
+if(this._vf.order>3)
+{var dist4=this._value4.subtract(this._value3).length();if(dist4>dist){dist=dist4;}}
+if(this._vf.order>4)
+{var dist5=this._value5.subtract(this._value4).length();if(dist5>dist){dist=dist5;}}
+if(dist<=this._eps)
+{this._value1.setValues(this._value0);this._value2.setValues(this._value0);this._value3.setValues(this._value0);this._value4.setValues(this._value0);this._value5.setValues(this._value0);this.postMessage('value',this._value0);this.postMessage('isActive',false);this._lastTick=0;return false;}
+this.postMessage('value',this._value5);this._lastTick=now;return true;}}));x3dom.registerNodeType("ScalarChaser","Followers",defineClass(x3dom.nodeTypes.X3DChaserNode,function(ctx){x3dom.nodeTypes.ScalarChaser.superClass.call(this,ctx);this.addField_SFFloat(ctx,'initialDestination',0);this.addField_SFFloat(ctx,'initialValue',0);this.addField_SFFloat(ctx,'value',0);this.addField_SFFloat(ctx,'destination',0);this._buffer=[];this._previousValue=0;this._value=0;this.initialize();},{fieldChanged:function(fieldName)
+{if(fieldName.indexOf("destination")>=0)
+{this.initialize();this.updateBuffer(this._currTime);if(!this._vf.isActive){this.postMessage('isActive',true);}}
+else if(fieldName.indexOf("value")>=0)
+{this.initialize();this._previousValue=this._vf.value;for(var C=1;Cthis._eps);if(this._vf.isActive!==active){this.postMessage('isActive',active);}}},tick:function(now)
+{this.initialize();this._currTime=now;if(!this._bufferEndTime)
+{this._bufferEndTime=now;this._value=this._vf.initialValue;this.postMessage('value',this._value);return true;}
+var Frac=this.updateBuffer(now);var Output=this._previousValue;var DeltaIn=this._buffer[this._buffer.length-1]-this._previousValue;var DeltaOut=DeltaIn*(this.stepResponse((this._buffer.length-1+Frac)*this._stepTime));Output=Output+DeltaOut;for(var C=this._buffer.length-2;C>=0;C--)
+{DeltaIn=this._buffer[C]-this._buffer[C+1];DeltaOut=DeltaIn*(this.stepResponse((C+Frac)*this._stepTime));Output=Output+DeltaOut;}
+if(Math.abs(Output-this._value)>this._eps){this._value=Output;this.postMessage('value',this._value);}
+else{this.postMessage('isActive',false);}
+return this._vf.isActive;},updateBuffer:function(now)
+{var Frac=(now-this._bufferEndTime)/this._stepTime;var C;var NumToShift;var Alpha;if(Frac>=1)
+{NumToShift=Math.floor(Frac);Frac-=NumToShift;if(NumToShift=NumToShift;C--){this._buffer[C]=this._buffer[C-NumToShift];}
+for(C=0;C=0)
+{if(Math.abs(this._value0-this._vf.destination)>this._eps){this._value0=this._vf.destination;if(!this._vf.isActive){this.postMessage('isActive',true);}}}
+else if(fieldName.indexOf("value")>=0)
+{this._value1=this._vf.value;this._value2=this._vf.value;this._value3=this._vf.value;this._value4=this._vf.value;this._value5=this._vf.value;this._lastTick=0;this.postMessage('value',this._value5);if(!this._vf.isActive){this._lastTick=0;this.postMessage('isActive',true);}}},initialize:function()
+{this._value0=this._vf.initialDestination;this._value1=this._vf.initialValue;this._value2=this._vf.initialValue;this._value3=this._vf.initialValue;this._value4=this._vf.initialValue;this._value5=this._vf.initialValue;this._lastTick=0;var active=(Math.abs(this._value0-this._value1)>this._eps);if(this._vf.isActive!==active){this.postMessage('isActive',active);}},tick:function(now)
+{if(!this._lastTick)
+{this._lastTick=now;return false;}
+var delta=now-this._lastTick;var alpha=Math.exp(-delta/this._vf.tau);this._value1=this._vf.order>0&&this._vf.tau?this._value0+alpha*(this._value1-this._value0):this._value0;this._value2=this._vf.order>1&&this._vf.tau?this._value1+alpha*(this._value2-this._value1):this._value1;this._value3=this._vf.order>2&&this._vf.tau?this._value2+alpha*(this._value3-this._value2):this._value2;this._value4=this._vf.order>3&&this._vf.tau?this._value3+alpha*(this._value4-this._value3):this._value3;this._value5=this._vf.order>4&&this._vf.tau?this._value4+alpha*(this._value5-this._value4):this._value4;var dist=Math.abs(this._value1-this._value0);if(this._vf.order>1)
+{var dist2=Math.abs(this._value2-this._value1);if(dist2>dist){dist=dist2;}}
+if(this._vf.order>2)
+{var dist3=Math.abs(this._value3-this._value2);if(dist3>dist){dist=dist3;}}
+if(this._vf.order>3)
+{var dist4=Math.abs(this._value4-this._value3);if(dist4>dist){dist=dist4;}}
+if(this._vf.order>4)
+{var dist5=Math.abs(this._value5-this._value4);if(dist5>dist){dist=dist5;}}
+if(dist<=this._eps)
+{this._value1=this._value0;this._value2=this._value0;this._value3=this._value0;this._value4=this._value0;this._value5=this._value0;this.postMessage('value',this._value0);this.postMessage('isActive',false);this._lastTick=0;return false;}
+this.postMessage('value',this._value5);this._lastTick=now;return true;}}));x3dom.registerNodeType("CoordinateDamper","Followers",defineClass(x3dom.nodeTypes.X3DDamperNode,function(ctx){x3dom.nodeTypes.CoordinateDamper.superClass.call(this,ctx);this.addField_MFVec3f(ctx,'initialDestination',[]);this.addField_MFVec3f(ctx,'initialValue',[]);this.addField_MFVec3f(ctx,'value',[]);this.addField_MFVec3f(ctx,'destination',[]);x3dom.debug.logWarning("CoordinateDamper NYI");}));x3dom.registerNodeType("TexCoordDamper2D","Followers",defineClass(x3dom.nodeTypes.X3DDamperNode,function(ctx){x3dom.nodeTypes.TexCoordDamper2D.superClass.call(this,ctx);this.addField_MFVec2f(ctx,'initialDestination',[]);this.addField_MFVec2f(ctx,'initialValue',[]);this.addField_MFVec2f(ctx,'value',[]);this.addField_MFVec2f(ctx,'destination',[]);x3dom.debug.logWarning("TexCoordDamper2D NYI");}));x3dom.registerNodeType("X3DInterpolatorNode","Interpolation",defineClass(x3dom.nodeTypes.X3DChildNode,function(ctx){x3dom.nodeTypes.X3DInterpolatorNode.superClass.call(this,ctx);this.addField_MFFloat(ctx,'key',[]);this.addField_SFFloat(ctx,'set_fraction',0);},{linearInterp:function(time,interp){if(time<=this._vf.key[0])
+return this._vf.keyValue[0];else if(time>=this._vf.key[this._vf.key.length-1])
+return this._vf.keyValue[this._vf.key.length-1];for(var i=0;i0?this._vf.key.length:1;var len=arr.length/key;for(var i=0;i=2)||(this._vf.keyVelocity.length==0));if(!sane)
+x3dom.debug.logWarning("SplinePositionInterpolator Node: 'key' , 'keyValue' and/or 'keyVelocity' fields have inappropriate sizes");};this.calcDtot=function()
+{this.dtot=0.0;for(var i=0;i2)
+{for(i=0;i0.0){if(this._vf.set_fraction<=this._vf.key[0])
+value=x3dom.fields.SFVec3f.copy(this._vf.keyValue[0]);else if(this._vf.set_fraction>=this._vf.key[this._vf.key.length-1])
+value=x3dom.fields.SFVec3f.copy(this._vf.keyValue[this._vf.key.length-1]);}
+for(var i=0;i0){this._updateCycleStopTime();}
+this._backupStartTime=this._vf.startTime;this._backupStopTime=this._vf.stopTime;this._backupCycleInterval=this._vf.cycleInterval;},{tick:function(time)
+{if(!this._vf.enabled){this._lastTime=time;return false;}
+var isActive=(this._vf.cycleInterval>0&&time>=this._vf.startTime&&(time=this._vf.pauseTime&&this._vf.pauseTime>this._vf.resumeTime);if(isPaused&&!this._vf.isPaused){this.postMessage('isPaused',true);this.postMessage('pauseTime',time);}else if(!isPaused&&this._vf.isPaused){this.postMessage('isPaused',false);this.postMessage('resumeTime',time);}
+if(!isPaused){var cycleFrac=this._getCycleAt(time);var cycle=Math.floor(cycleFrac);var cycleTime=this._vf.startTime+cycle*this._vf.cycleInterval;var adjustTime=0;if(this._vf.stopTime>this._vf.startTime&&this._lastTime=this._vf.stopTime)
+adjustTime=this._vf.stopTime;else if(this._lastTime=cycleTime)
+adjustTime=cycleTime;if(adjustTime>0){time=adjustTime;cycleFrac=this._getCycleAt(time);cycle=Math.floor(cycleFrac);}
+var fraction=cycleFrac-cycle;if(fraction=0)
+anchor=url.slice(aPos+1);var param=this._vf.parameter.length?this._vf.parameter[0]:"";var tPos=param.search("target=");var target="";if(tPos>=0)
+target=param.slice(tPos+7);x3dom.debug.logInfo("Anchor url="+url+", target="+target+", #viewpoint="+anchor);if(target.length!=0||target!="_self"){window.open(this._nameSpace.getURL(url),target);}
+else{window.location=this._nameSpace.getURL(url);}}}));x3dom.registerNodeType("Inline","Networking",defineClass(x3dom.nodeTypes.X3DGroupingNode,function(ctx){x3dom.nodeTypes.Inline.superClass.call(this,ctx);this.addField_MFString(ctx,'url',[]);this.addField_SFBool(ctx,'load',true);this.addField_MFString(ctx,'nameSpaceName',[]);this.addField_SFBool(ctx,'mapDEFToID',false);this.initDone=false;this.count=0;this.numRetries=x3dom.nodeTypes.Inline.MaximumRetries;},{fieldChanged:function(fieldName)
+{if(fieldName=="url"){for(var i=0;i=1)
+{node.removeChild(node.firstChild);}}}
+this.loadInline();}
+else if(fieldName=="render"){this.invalidateVolume();}},nodeChanged:function()
+{if(!this.initDone){this.initDone=true;this.loadInline();}},fireEvents:function(eventType)
+{if(this._xmlNode&&(this._xmlNode['on'+eventType]||this._xmlNode.hasAttribute('on'+eventType)||this._listeners[eventType]))
+{var event={target:this._xmlNode,type:eventType,error:(eventType=="error")?"XMLHttpRequest Error":"",cancelBubble:false,stopPropagation:function(){this.cancelBubble=true;}};try{var attrib=this._xmlNode["on"+eventType];if(typeof(attrib)==="function"){attrib.call(this._xmlNode,event);}
+else{var funcStr=this._xmlNode.getAttribute("on"+eventType);var func=new Function('event',funcStr);func.call(this._xmlNode,event);}
+var list=this._listeners[eventType];if(list){for(var i=0;i=0))
+nameSpace.setBaseURL(url);else
+nameSpace.setBaseURL(that._nameSpace.baseURL+url);newScene=nameSpace.setupTree(inlScene);that._nameSpace.addSpace(nameSpace);if(that._vf.nameSpaceName.length!=0)
+{Array.forEach(inlScene.childNodes,function(childDomNode)
+{if(childDomNode instanceof Element)
+{setNamespace(that._vf.nameSpaceName,childDomNode,that._vf.mapDEFToID);that._xmlNode.appendChild(childDomNode);}});}}
+else{if(xml&&xml.localName)
+x3dom.debug.logError('No Scene in '+xml.localName);else
+x3dom.debug.logError('No Scene in resource');}
+var global=x3dom.getGlobal();if(that._childNodes.length>0&&that._childNodes[0]&&that._childNodes[0]._nameSpace)
+that._nameSpace.removeSpace(that._childNodes[0]._nameSpace);while(that._childNodes.length!==0)
+global['_remover']=that.removeChild(that._childNodes[0]);delete global['_remover'];if(newScene)
+{that.addChild(newScene);that.invalidateVolume();that._nameSpace.doc.downloadCount-=1;that._nameSpace.doc.needRender=true;x3dom.debug.logInfo('Inline: added '+that._vf.url[0]+' to scene.');var theScene=that._nameSpace.doc._scene;if(theScene){theScene.invalidateVolume();window.setTimeout(function(){that.invalidateVolume();theScene.updateVolume();that._nameSpace.doc.needRender=true;},1000);}
+that.fireEvents("load");}
+newScene=null;nameSpace=null;inlScene=null;xml=null;return xhr;};if(this._vf.url.length&&this._vf.url[0].length)
+{var xhrURI=this._nameSpace.getURL(this._vf.url[0]);xhr.open('GET',xhrURI,true);this._nameSpace.doc.downloadCount+=1;try{x3dom.RequestManager.addRequest(xhr);}
+catch(ex){this.fireEvents("error");x3dom.debug.logError(this._vf.url[0]+": "+ex);}}}}));x3dom.nodeTypes.Inline.AwaitTranscoding=202;x3dom.nodeTypes.Inline.MaximumRetries=15;function setNamespace(prefix,childDomNode,mapDEFToID)
+{if(childDomNode instanceof Element&&childDomNode.__setAttribute!==undefined){if(childDomNode.hasAttribute('id')){childDomNode.__setAttribute('id',prefix.toString().replace(' ','')+'__'+childDomNode.getAttribute('id'));}else if(childDomNode.hasAttribute('DEF')&&mapDEFToID){childDomNode.__setAttribute('id',prefix.toString().replace(' ','')+'__'+childDomNode.getAttribute('DEF'));if(!childDomNode.id)
+childDomNode.id=childDomNode.__getAttribute('id');}}
+if(childDomNode.hasChildNodes()){Array.forEach(childDomNode.childNodes,function(children){setNamespace(prefix,children,mapDEFToID);});}}
+x3dom.registerNodeType("MultiPart","Networking",defineClass(x3dom.nodeTypes.Inline,function(ctx){x3dom.nodeTypes.MultiPart.superClass.call(this,ctx);this.addField_MFString(ctx,'urlIDMap',[]);this.addField_SFBool(ctx,'isPickable',true);this.addField_SFString(ctx,'sortType','auto');this.addField_SFBool(ctx,'solid',false);this.addField_SFInt32(ctx,'sortKey',0);this.addField_SFString(ctx,'initialVisibility','auto');this._idMap=null;this._inlineNamespace=null;this._highlightedParts=[];this._minId=0;this._maxId=0;this._lastId=-1;this._lastClickedId=-1;this._lastButton=0;this._identifierToPartId=[];this._identifierToAppId=[];this._visiblePartsPerShape=[];this._partVolume=[];this._partVisibility=[];this._originalColor=[];this._materials=[];},{fieldChanged:function(fieldName)
+{if(fieldName=="url"){if(this._vf.nameSpaceName.length!=0){var node=this._xmlNode;if(node&&node.hasChildNodes())
+{while(node.childNodes.length>=1)
+{node.removeChild(node.firstChild);}}}
+this.loadInline();}
+else if(fieldName=="render"){this.invalidateVolume();}},nodeChanged:function()
+{if(!this.initDone){this.initDone=true;this.loadIDMap();}},getVolume:function()
+{var vol=this._graph.volume;if(!this.volumeValid()&&this._vf.render)
+{for(var i=0;i0)
+selection.push(id);}
+var colorMap=multiPart._inlineNamespace.defMap["MultiMaterial_ColorMap"];var emissiveMap=multiPart._inlineNamespace.defMap["MultiMaterial_EmissiveMap"];var specularMap=multiPart._inlineNamespace.defMap["MultiMaterial_SpecularMap"];var visibilityMap=multiPart._inlineNamespace.defMap["MultiMaterial_VisibilityMap"];if(selection.length==0){return null;}else{return new x3dom.Parts(multiPart,selection,colorMap,emissiveMap,specularMap,visibilityMap);}};},loadInline:function()
+{var that=this;var xhr=new window.XMLHttpRequest();if(xhr.overrideMimeType)
+xhr.overrideMimeType('text/xml');xhr.onreadystatechange=function()
+{if(xhr.readyState!=4){return xhr;}
+if(xhr.status===x3dom.nodeTypes.Inline.AwaitTranscoding){if(that.count=0))
+{that._inlineNamespace.setBaseURL(url);}
+else
+{that._inlineNamespace.setBaseURL(that._nameSpace.baseURL+url);}
+that.replaceMaterials(inlScene);newScene=that._inlineNamespace.setupTree(inlScene);that._nameSpace.addSpace(that._inlineNamespace);if(that._vf.nameSpaceName.length!=0)
+{Array.forEach(inlScene.childNodes,function(childDomNode)
+{if(childDomNode instanceof Element)
+{setNamespace(that._vf.nameSpaceName,childDomNode,that._vf.mapDEFToID);that._xmlNode.appendChild(childDomNode);}});}}
+else{if(xml&&xml.localName){x3dom.debug.logError('No Scene in '+xml.localName);}else{x3dom.debug.logError('No Scene in resource');}}
+var global=x3dom.getGlobal();if(that._childNodes.length>0&&that._childNodes[0]&&that._childNodes[0]._nameSpace){that._nameSpace.removeSpace(that._childNodes[0]._nameSpace);}
+while(that._childNodes.length!==0){global['_remover']=that.removeChild(that._childNodes[0]);}
+delete global['_remover'];if(newScene)
+{that.addChild(newScene);that.invalidateVolume();that._nameSpace.doc.downloadCount-=1;that._nameSpace.doc.needRender=true;x3dom.debug.logInfo('Inline: added '+that._vf.url[0]+' to scene.');var theScene=that._nameSpace.doc._scene;if(theScene){theScene.invalidateVolume();window.setTimeout(function(){that.invalidateVolume();theScene.updateVolume();that._nameSpace.doc.needRender=true;},1000);}
+that.appendAPI();that.fireEvents("load");}
+newScene=null;inlScene=null;xml=null;return xhr;};if(this._vf.url.length&&this._vf.url[0].length)
+{var xhrURI=this._nameSpace.getURL(this._vf.url[0]);xhr.open('GET',xhrURI,true);this._nameSpace.doc.downloadCount+=1;try{x3dom.RequestManager.addRequest(xhr);}
+catch(ex){this.fireEvents("error");x3dom.debug.logError(this._vf.url[0]+": "+ex);}}}}));x3dom.registerNodeType("X3DBackgroundNode","EnvironmentalEffects",defineClass(x3dom.nodeTypes.X3DBindableNode,function(ctx){x3dom.nodeTypes.X3DBackgroundNode.superClass.call(this,ctx);var trans=(ctx&&ctx.autoGen)?1:0;this.addField_SFString(ctx,'crossOrigin','');this.addField_MFColor(ctx,'groundColor',[]);this.addField_MFFloat(ctx,'groundAngle',[]);this.addField_MFColor(ctx,'skyColor',[new x3dom.fields.SFColor(0,0,0)]);this.addField_MFFloat(ctx,'skyAngle',[]);this.addField_SFFloat(ctx,'transparency',trans);this._dirty=true;},{getSkyColor:function(){return new x3dom.fields.SFColor(0,0,0);},getTransparency:function(){return 0;},getTexUrl:function(){return[];}}));x3dom.registerNodeType("X3DFogNode","EnvironmentalEffects",defineClass(x3dom.nodeTypes.X3DBindableNode,function(ctx){x3dom.nodeTypes.X3DFogNode.superClass.call(this,ctx);this.addField_SFColor(ctx,'color',1,1,1);this.addField_SFString(ctx,'fogType',"LINEAR");this.addField_SFFloat(ctx,'visibilityRange',0);},{}));x3dom.registerNodeType("Fog","EnvironmentalEffects",defineClass(x3dom.nodeTypes.X3DFogNode,function(ctx){x3dom.nodeTypes.Fog.superClass.call(this,ctx);},{}));x3dom.registerNodeType("Background","EnvironmentalEffects",defineClass(x3dom.nodeTypes.X3DBackgroundNode,function(ctx){x3dom.nodeTypes.Background.superClass.call(this,ctx);this.addField_MFString(ctx,'backUrl',[]);this.addField_MFString(ctx,'bottomUrl',[]);this.addField_MFString(ctx,'frontUrl',[]);this.addField_MFString(ctx,'leftUrl',[]);this.addField_MFString(ctx,'rightUrl',[]);this.addField_MFString(ctx,'topUrl',[]);this.addField_SFBool(ctx,'scaling',false);},{fieldChanged:function(fieldName)
+{if(fieldName.indexOf("Url")>0||fieldName=="transparency"||fieldName.search("sky")>=0||fieldName.search("ground")>=0){this._dirty=true;}
+else if(fieldName.indexOf("bind")>=0){this.bind(this._vf.bind);}},getSkyColor:function(){return this._vf.skyColor;},getGroundColor:function(){return this._vf.groundColor;},getTransparency:function(){return this._vf.transparency;},getTexUrl:function(){return[this._nameSpace.getURL(this._vf.backUrl[0]),this._nameSpace.getURL(this._vf.frontUrl[0]),this._nameSpace.getURL(this._vf.bottomUrl[0]),this._nameSpace.getURL(this._vf.topUrl[0]),this._nameSpace.getURL(this._vf.leftUrl[0]),this._nameSpace.getURL(this._vf.rightUrl[0])];}}));x3dom.registerNodeType("X3DEnvironmentNode","EnvironmentalEffects",defineClass(x3dom.nodeTypes.X3DBindableNode,function(ctx){x3dom.nodeTypes.X3DEnvironmentNode.superClass.call(this,ctx);}));x3dom.registerNodeType("Environment","EnvironmentalEffects",defineClass(x3dom.nodeTypes.X3DEnvironmentNode,function(ctx){x3dom.nodeTypes.Environment.superClass.call(this,ctx);this.addField_SFBool(ctx,'sortTrans',true);this.addField_SFBool(ctx,'shadowExcludeTransparentObjects',false);this.addField_SFString(ctx,'gammaCorrectionDefault',"linear");this.addField_SFBool(ctx,'frustumCulling',true);this.addField_SFBool(ctx,'smallFeatureCulling',false);this.addField_SFFloat(ctx,'smallFeatureThreshold',1.0);this.addField_SFBool(ctx,'occlusionCulling',false);this.addField_SFFloat(ctx,'occlusionVisibilityThreshold',0.0);this.addField_SFBool(ctx,'lowPriorityCulling',false);this.addField_SFFloat(ctx,'lowPriorityThreshold',1.0);this.addField_SFBool(ctx,'tessellationDetailCulling',false);this.addField_SFFloat(ctx,'tessellationErrorThreshold',0.0);this.addField_SFBool(ctx,'enableARC',false);this.addField_SFFloat(ctx,'minFrameRate',1.0);this.addField_SFFloat(ctx,'maxFrameRate',62.5);this.addField_SFFloat(ctx,'userDataFactor',-1);this.addField_SFFloat(ctx,'smallFeatureFactor',-1);this.addField_SFFloat(ctx,'occlusionVisibilityFactor',-1);this.addField_SFFloat(ctx,'lowPriorityFactor',-1);this.addField_SFFloat(ctx,'tessellationErrorFactor',-1);this.addField_SFBool(ctx,'SSAO',false);this.addField_SFFloat(ctx,'SSAOradius',0.7);this.addField_SFFloat(ctx,'SSAOamount',0.3);this.addField_SFInt32(ctx,'SSAOrandomTextureSize',4);this.addField_SFInt32(ctx,'SSAOblurDepthTreshold',1);this._validGammaCorrectionTypes=["none","fastlinear","linear"];this.checkSanity();},{checkSanity:function()
+{var checkParam=function(flag,value,defaultOn,defaultOff)
+{if(flag&&(value==defaultOff))
+return defaultOn;if(!flag&&(value!=defaultOff))
+return defaultOff;return value;};this._smallFeatureThreshold=checkParam(this._vf.smallFeatureCulling,this._vf.smallFeatureThreshold,10,0);this._lowPriorityThreshold=checkParam(this._vf.lowPriorityCulling,this._vf.lowPriorityThreshold,0.5,1);this._occlusionVisibilityThreshold=checkParam(this._vf.occlusionCulling,this._vf.occlusionVisibilityThreshold,1,0);this._tessellationErrorThreshold=checkParam(this._vf.tessellationDetailCulling,this._vf.tessellationErrorThreshold,1,0);var checkGamma=function(field,that){field=field.toLowerCase();if(that._validGammaCorrectionTypes.indexOf(field)>-1){return field;}
+else{x3dom.debug.logWarning(field+" gammaCorrectionDefault may only be linear (default), fastLinear, or none");return that._validGammaCorrectionTypes[0];}};this._vf.gammaCorrectionDefault=checkGamma(this._vf.gammaCorrectionDefault,this);}}));x3dom.registerNodeType("X3DViewpointNode","Navigation",defineClass(x3dom.nodeTypes.X3DBindableNode,function(ctx){x3dom.nodeTypes.X3DViewpointNode.superClass.call(this,ctx);if(ctx&&ctx.xmlNode){var domNode=ctx.xmlNode;if(!domNode.resetView&&!domNode.getFieldOfView&&!domNode.getNear&&!domNode.getFar)
+{domNode.resetView=function(){var that=this._x3domNode;that.resetView();that._nameSpace.doc.needRender=true;};domNode.getFieldOfView=function(){return this._x3domNode.getFieldOfView();};domNode.getNear=function(){return this._x3domNode.getNear();};domNode.getFar=function(){return this._x3domNode.getFar();};}}},{activate:function(prev){var viewarea=this._nameSpace.doc._viewarea;if(prev&&this._bindAnimation){viewarea.animateTo(this,prev._autoGen?null:prev);}
+viewarea._needNavigationMatrixUpdate=true;x3dom.nodeTypes.X3DBindableNode.prototype.activate.call(this,prev);},deactivate:function(prev){x3dom.nodeTypes.X3DBindableNode.prototype.deactivate.call(this,prev);},getTransformation:function(){return this.getCurrentTransform();},getCenterOfRotation:function(){return new x3dom.fields.SFVec3f(0,0,0);},setCenterOfRotation:function(cor){this._vf.centerOfRotation.setValues(cor);},getFieldOfView:function(){return 1.57079633;},setView:function(newView){var mat=this.getCurrentTransform();this._viewMatrix=newView.mult(mat);},setViewAbsolute:function(newView)
+{this._viewMatrix=newView;},setProjectionMatrix:function(matrix)
+{},resetView:function(){},getNear:function(){return 0.1;},getFar:function(){return 10000;},getImgPlaneHeightAtDistOne:function(){return 2.0;},getViewMatrix:function(){return null;},getProjectionMatrix:function(aspect){return null;},setZoom:function(value){}}));x3dom.registerNodeType("Viewpoint","Navigation",defineClass(x3dom.nodeTypes.X3DViewpointNode,function(ctx){x3dom.nodeTypes.Viewpoint.superClass.call(this,ctx);this.addField_SFFloat(ctx,'fieldOfView',0.785398);this.addField_SFVec3f(ctx,'position',0,0,10);this.addField_SFRotation(ctx,'orientation',0,0,0,1);this.addField_SFVec3f(ctx,'centerOfRotation',0,0,0);this.addField_SFFloat(ctx,'zNear',-1);this.addField_SFFloat(ctx,'zFar',-1);this._viewMatrix=x3dom.fields.SFMatrix4f.translation(this._vf.position).mult(this._vf.orientation.toMatrix()).inverse();this._projMatrix=null;this._lastAspect=1.0;this._zRatio=10000;this._zNear=this._vf.zNear;this._zFar=this._vf.zFar;this._imgPlaneHeightAtDistOne=2.0*Math.tan(this._vf.fieldOfView/2.0);},{fieldChanged:function(fieldName){if(fieldName=="position"||fieldName=="orientation"){this.resetView();}
+else if(fieldName=="fieldOfView"||fieldName=="zNear"||fieldName=="zFar"){this._projMatrix=null;this._zNear=this._vf.zNear;this._zFar=this._vf.zFar;this._imgPlaneHeightAtDistOne=2.0*Math.tan(this._vf.fieldOfView/2.0);}
+else if(fieldName.indexOf("bind")>=0){this.bind(this._vf.bind);}},setProjectionMatrix:function(matrix)
+{this._projMatrix=matrix;},getCenterOfRotation:function(){return this.getCurrentTransform().multMatrixPnt(this._vf.centerOfRotation);},getViewMatrix:function(){return this._viewMatrix;},getFieldOfView:function(){return this._vf.fieldOfView;},resetView:function(){this._viewMatrix=x3dom.fields.SFMatrix4f.translation(this._vf.position).mult(this._vf.orientation.toMatrix()).inverse();if(this._vf.isActive&&this._nameSpace&&this._nameSpace.doc._viewarea){this._nameSpace.doc._viewarea.resetNavHelpers();}},getNear:function(){return this._zNear;},getFar:function(){return this._zFar;},getImgPlaneHeightAtDistOne:function(){return this._imgPlaneHeightAtDistOne;},getProjectionMatrix:function(aspect)
+{var fovy=this._vf.fieldOfView;var zfar=this._vf.zFar;var znear=this._vf.zNear;if(znear<=0||zfar<=0)
+{var nearScale=0.8,farScale=1.2;var viewarea=this._nameSpace.doc._viewarea;var scene=viewarea._scene;var min=x3dom.fields.SFVec3f.copy(scene._lastMin);var max=x3dom.fields.SFVec3f.copy(scene._lastMax);var dia=max.subtract(min);var sRad=dia.length()/2;var mat=viewarea.getViewMatrix().inverse();var vp=mat.e3();var translation=new x3dom.fields.SFVec3f(0,0,0),scaleFactor=new x3dom.fields.SFVec3f(1,1,1);var rotation=new x3dom.fields.Quaternion(0,0,1,0),scaleOrientation=new x3dom.fields.Quaternion(0,0,1,0);mat.getTransform(translation,rotation,scaleFactor,scaleOrientation);var minScal=scaleFactor.x,maxScal=scaleFactor.x;if(maxScalscaleFactor.y)minScal=scaleFactor.y;if(maxScalscaleFactor.z)minScal=scaleFactor.z;if(maxScal>1)
+nearScale/=maxScal;else if(minScal>x3dom.fields.Eps&&minScal<1)
+farScale/=minScal;var sCenter=min.add(dia.multiply(0.5));var vDist=(vp.subtract(sCenter)).length();if(sRad){if(vDist>sRad)
+znear=(vDist-sRad)*nearScale;else
+znear=0;zfar=(vDist+sRad)*farScale;}
+else{znear=0.1;zfar=100000;}
+var zNearLimit=zfar/this._zRatio;znear=Math.max(znear,Math.max(x3dom.fields.Eps,zNearLimit));if(zfar>this._vf.zNear&&this._vf.zNear>0)
+znear=this._vf.zNear;if(this._vf.zFar>znear)
+zfar=this._vf.zFar;if(zfar<=znear)
+zfar=znear+1;}
+if(this._projMatrix==null)
+{this._projMatrix=x3dom.fields.SFMatrix4f.perspective(fovy,aspect,znear,zfar);}
+else if(this._zNear!=znear||this._zFar!=zfar)
+{var div=znear-zfar;this._projMatrix._22=(znear+zfar)/div;this._projMatrix._23=2*znear*zfar/div;}
+else if(this._lastAspect!=aspect)
+{this._projMatrix._00=(1/Math.tan(fovy/2))/aspect;this._lastAspect=aspect;}
+this._zNear=znear;this._zFar=zfar;return this._projMatrix;}}));x3dom.registerNodeType("OrthoViewpoint","Navigation",defineClass(x3dom.nodeTypes.X3DViewpointNode,function(ctx){x3dom.nodeTypes.OrthoViewpoint.superClass.call(this,ctx);this.addField_MFFloat(ctx,'fieldOfView',[-1,-1,1,1]);this.addField_SFVec3f(ctx,'position',0,0,10);this.addField_SFRotation(ctx,'orientation',0,0,0,1);this.addField_SFVec3f(ctx,'centerOfRotation',0,0,0);this.addField_SFFloat(ctx,'zNear',-1);this.addField_SFFloat(ctx,'zFar',-1);this._viewMatrix=null;this._projMatrix=null;this._lastAspect=1.0;this._zRatio=10000;this._zNear=this._vf.zNear;this._zFar=this._vf.zFar;this._fieldOfView=this._vf.fieldOfView.slice(0);this.resetView();},{fieldChanged:function(fieldName){if(fieldName=="position"||fieldName=="orientation"){this.resetView();}
+else if(fieldName=="fieldOfView")
+{this._fieldOfView=this._vf.fieldOfView;this._projMatrix=null;}
+else if(fieldName=="zNear"||fieldName=="zFar"){this._projMatrix=null;this.resetView();}
+else if(fieldName.indexOf("bind")>=0){this.bind(this._vf.bind);}},getCenterOfRotation:function(){return this.getCurrentTransform().multMatrixPnt(this._vf.centerOfRotation);},getViewMatrix:function(){return this._viewMatrix;},resetView:function(){var offset=x3dom.fields.SFMatrix4f.translation(new x3dom.fields.SFVec3f((this._vf.fieldOfView[0]+this._vf.fieldOfView[2])/2,(this._vf.fieldOfView[1]+this._vf.fieldOfView[3])/2,0));this._viewMatrix=x3dom.fields.SFMatrix4f.translation(this._vf.position).mult(this._vf.orientation.toMatrix());this._viewMatrix=this._viewMatrix.inverse();this._projMatrix=null;if(this._vf.isActive&&this._nameSpace&&this._nameSpace.doc._viewarea){this._nameSpace.doc._viewarea.resetNavHelpers();}},getNear:function(){return this._vf.zNear;},getFar:function(){return this._vf.zFar;},getFieldOfView:function(){return 0.785;},setZoom:function(value){this._fieldOfView[0]=-value;this._fieldOfView[1]=-value;this._fieldOfView[2]=value;this._fieldOfView[3]=value;this._projMatrix=null;},getZoom:function(value){return this._fieldOfView;},getProjectionMatrix:function(aspect)
+{var fov=this.getFieldOfView();var zfar=this._vf.zFar;var znear=this._vf.zNear;if(znear<=0||zfar<=0)
+{var scene=this._nameSpace.doc._viewarea._scene;var min=x3dom.fields.SFVec3f.copy(scene._lastMin);var max=x3dom.fields.SFVec3f.copy(scene._lastMax);var dia=max.subtract(min);var tanfov2=Math.tan(fov/2.0);var dist1=(dia.y/2.0)/tanfov2+dia.z;var dist2=(dia.x/2.0)/tanfov2+dia.z;znear=0.00001;zfar=(dist1>dist2)?dist1*4:dist2*4;}
+if(this._projMatrix==null||this._lastAspect!=aspect||this._zNear!=znear||this._zFar!=zfar)
+{var near=this._zNear=znear;var far=this._zFar=zfar;var left=this._fieldOfView[0];var bottom=this._fieldOfView[1];var right=this._fieldOfView[2];var top=this._fieldOfView[3];this._projMatrix=x3dom.fields.SFMatrix4f.ortho(left,right,bottom,top,near,far,aspect);}
+this._lastAspect=aspect;return this._projMatrix;}}));x3dom.registerNodeType("Viewfrustum","Navigation",defineClass(x3dom.nodeTypes.X3DViewpointNode,function(ctx){x3dom.nodeTypes.Viewfrustum.superClass.call(this,ctx);this.addField_SFMatrix4f(ctx,'modelview',1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);this.addField_SFMatrix4f(ctx,'projection',1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);this._viewMatrix=this._vf.modelview.transpose().inverse();this._projMatrix=this._vf.projection.transpose();this._centerOfRotation=new x3dom.fields.SFVec3f(0,0,0);},{fieldChanged:function(fieldName){if(fieldName=="modelview"){this.resetView();}
+else if(fieldName=="projection"){this._projMatrix=this._vf.projection.transpose();}
+else if(fieldName.indexOf("bind")>=0){this.bind(this._vf.bind);}},getCenterOfRotation:function(){return this.getCurrentTransform().multMatrixPnt(this._centerOfRotation);},setCenterOfRotation:function(cor){this._centerOfRotation.setValues(cor);},getViewMatrix:function(){return this._viewMatrix;},getFieldOfView:function(){return(2.0*Math.atan(1.0/this._projMatrix._11));},getImgPlaneHeightAtDistOne:function(){return 2.0/this._projMatrix._11;},resetView:function(){this._viewMatrix=this._vf.modelview.transpose().inverse();this._centerOfRotation=new x3dom.fields.SFVec3f(0,0,0);},getProjectionMatrix:function(aspect){return this._projMatrix;}}));x3dom.registerNodeType("X3DNavigationInfoNode","Navigation",defineClass(x3dom.nodeTypes.X3DBindableNode,function(ctx){x3dom.nodeTypes.X3DNavigationInfoNode.superClass.call(this,ctx);}));x3dom.registerNodeType("NavigationInfo","Navigation",defineClass(x3dom.nodeTypes.X3DNavigationInfoNode,function(ctx){x3dom.nodeTypes.NavigationInfo.superClass.call(this,ctx);this.addField_SFBool(ctx,'headlight',true);this.addField_MFString(ctx,'type',["EXAMINE","ANY"]);this.addField_MFFloat(ctx,'typeParams',[-0.4,60,0.05,2.8]);this.addField_SFString(ctx,'explorationMode','all');this.addField_MFFloat(ctx,'avatarSize',[0.25,1.6,0.75]);this.addField_SFFloat(ctx,'visibilityLimit',0.0);this.addField_SFFloat(ctx,'speed',1.0);this.addField_SFTime(ctx,'transitionTime',1.0);this.addField_MFString(ctx,'transitionType',["LINEAR"]);this._validTypes=["none","examine","turntable","fly","freefly","lookat","lookaround","walk","game","helicopter","any"];this._typeMapping={"default":x3dom.DefaultNavigation,"turntable":x3dom.TurntableNavigation};this._heliUpdated=false;var type=this.setType(this.getType());x3dom.debug.logInfo("NavType: "+type);},{fieldChanged:function(fieldName){if(fieldName=="typeParams"){this._heliUpdated=false;}
+else if(fieldName=="type"){this.setType(this.getType());}},setType:function(type,viewarea){var navType=this.checkType(type.toLowerCase());var oldType=this.checkType(this.getType());if(oldType!==navType||this._impl==null){if(this._typeMapping[navType]==null)
+this._impl=new this._typeMapping['default'](this);else
+this._impl=new this._typeMapping[navType](this);switch(navType){case'game':if(viewarea)
+viewarea.initMouseState();else
+this._nameSpace.doc._viewarea.initMouseState();break;case'helicopter':this._heliUpdated=false;break;case"turntable":if(viewarea){viewarea.initMouseState();}
+else if(this._nameSpace.doc._viewarea){this._nameSpace.doc._viewarea.initMouseState();}
+break;default:break;}
+if(this._nameSpace.doc._viewarea)
+this._impl.init(this._nameSpace.doc._viewarea,false);}
+this._vf.type[0]=navType;x3dom.debug.logInfo("Switch to "+navType+" mode.");},getType:function(){var type=this._vf.type[0].toLowerCase();if(type.length<=1)
+type="none";else if(type=="any")
+type="examine";return type;},getTypeParams:function(){var length=this._vf.typeParams.length;var theta=(length>=1)?this._vf.typeParams[0]:-0.4;var height=(length>=2)?this._vf.typeParams[1]:60.0;var minAngle=(length>=3)?this._vf.typeParams[2]:x3dom.fields.Eps;var maxAngle=(length>=4)?this._vf.typeParams[3]:Math.PI-x3dom.fields.Eps;var params=[theta,height,minAngle,maxAngle];if(length>=5)
+{params=params.concat(this._vf.typeParams.slice(4));}
+console.log(params);return params;},setTypeParams:function(params){for(var i=0;i-1){return type;}
+else{x3dom.debug.logWarning(type+" is no valid navigation type, use one of "+
+this._validTypes.toString());return"examine";}},getExplorationMode:function(){switch(this._vf.explorationMode.toLowerCase()){case"all":return 7;case"rotate":return 1;case"zoom":return 2;case"pan":return 4;case"none":return 0;default:return 7;}}}));x3dom.registerNodeType("Billboard","Navigation",defineClass(x3dom.nodeTypes.X3DGroupingNode,function(ctx){x3dom.nodeTypes.Billboard.superClass.call(this,ctx);this.addField_SFVec3f(ctx,'axisOfRotation',0,1,0);this._eye=new x3dom.fields.SFVec3f(0,0,0);this._eyeViewUp=new x3dom.fields.SFVec3f(0,0,0);this._eyeLook=new x3dom.fields.SFVec3f(0,0,0);},{collectDrawableObjects:function(transform,drawableCollection,singlePath,invalidateCache,planeMask,clipPlanes)
+{if(singlePath&&(this._parentNodes.length>1))
+singlePath=false;if(singlePath&&(invalidateCache=invalidateCache||this.cacheInvalid()))
+this.invalidateCache();planeMask=drawableCollection.cull(transform,this.graphState(),singlePath,planeMask);if(planeMask<0){return;}
+singlePath=false;var vol=this.getVolume();var min=x3dom.fields.SFVec3f.MAX();var max=x3dom.fields.SFVec3f.MIN();vol.getBounds(min,max);var mat_view=drawableCollection.viewMatrix;var center=new x3dom.fields.SFVec3f(0,0,0);center=mat_view.inverse().multMatrixPnt(center);var mat_view_model=mat_view.mult(transform);this._eye=transform.inverse().multMatrixPnt(center);this._eyeViewUp=new x3dom.fields.SFVec3f(mat_view_model._10,mat_view_model._11,mat_view_model._12);this._eyeLook=new x3dom.fields.SFVec3f(mat_view_model._20,mat_view_model._21,mat_view_model._22);var rotMat=x3dom.fields.SFMatrix4f.identity();var mid=max.add(min).multiply(0.5);var billboard_to_viewer=this._eye.subtract(mid);if(this._vf.axisOfRotation.equals(new x3dom.fields.SFVec3f(0,0,0),x3dom.fields.Eps)){var rot1=x3dom.fields.Quaternion.rotateFromTo(billboard_to_viewer,new x3dom.fields.SFVec3f(0,0,1));rotMat=rot1.toMatrix().transpose();var yAxis=rotMat.multMatrixPnt(new x3dom.fields.SFVec3f(0,1,0)).normalize();var zAxis=rotMat.multMatrixPnt(new x3dom.fields.SFVec3f(0,0,1)).normalize();if(!this._eyeViewUp.equals(new x3dom.fields.SFVec3f(0,0,0),x3dom.fields.Eps)){var rot2=x3dom.fields.Quaternion.rotateFromTo(this._eyeLook,zAxis);var rotatedyAxis=rot2.toMatrix().transpose().multMatrixVec(yAxis);var rot3=x3dom.fields.Quaternion.rotateFromTo(this._eyeViewUp,rotatedyAxis);rotMat=rot2.toMatrix().transpose().mult(rotMat);rotMat=rot3.toMatrix().transpose().mult(rotMat);}}
+else{var normalPlane=this._vf.axisOfRotation.cross(billboard_to_viewer).normalize();if(this._eye.z<0){normalPlane=normalPlane.multiply(-1);}
+var degreesToRotate=Math.asin(normalPlane.dot(new x3dom.fields.SFVec3f(0,0,1)));if(this._eye.z<0){degreesToRotate+=Math.PI;}
+rotMat=x3dom.fields.SFMatrix4f.parseRotation(this._vf.axisOfRotation.x+", "+this._vf.axisOfRotation.y+", "+
+this._vf.axisOfRotation.z+", "+degreesToRotate*(-1));}
+var childTransform=this.transformMatrix(transform.mult(rotMat));for(var i=0,i_n=this._childNodes.length;i1))
+singlePath=false;if(singlePath&&(invalidateCache=invalidateCache||this.cacheInvalid()))
+this.invalidateCache();planeMask=drawableCollection.cull(transform,this.graphState(),singlePath,planeMask);if(planeMask<0){return;}
+var cnode,childTransform;if(singlePath){if(!this._graph.globalMatrix){this._graph.globalMatrix=this.transformMatrix(transform);}
+childTransform=this._graph.globalMatrix;}
+else{childTransform=this.transformMatrix(transform);}
+for(var i=0,n=this._childNodes.length;i1))
+singlePath=false;if(singlePath&&(invalidateCache=invalidateCache||this.cacheInvalid()))
+this.invalidateCache();planeMask=drawableCollection.cull(transform,this.graphState(),singlePath,planeMask);if(planeMask<0){return;}
+singlePath=false;this.visitChildren(transform,drawableCollection,singlePath,invalidateCache,planeMask,clipPlanes);},visitChildren:function(transform,drawableCollection,singlePath,invalidateCache,planeMask,clipPlanes){}}));x3dom.registerNodeType("LOD","Navigation",defineClass(x3dom.nodeTypes.X3DLODNode,function(ctx){x3dom.nodeTypes.LOD.superClass.call(this,ctx);this.addField_MFFloat(ctx,"range",[]);this._lastRangePos=-1;},{visitChildren:function(transform,drawableCollection,singlePath,invalidateCache,planeMask,clipPlanes)
+{var i=0,n=this._childNodes.length;var mat_view=drawableCollection.viewMatrix;var center=new x3dom.fields.SFVec3f(0,0,0);center=mat_view.inverse().multMatrixPnt(center);this._eye=transform.inverse().multMatrixPnt(center);var len=this._vf.center.subtract(this._eye).length();while(ithis._vf.range[i]){i++;}
+if(i&&i>=n){i=n-1;}
+this._lastRangePos=i;var cnode=this._childNodes[i];if(n&&cnode)
+{var childTransform=this.transformMatrix(transform);cnode.collectDrawableObjects(childTransform,drawableCollection,singlePath,invalidateCache,planeMask,clipPlanes);}},getVolume:function()
+{var vol=this._graph.volume;if(!this.volumeValid()&&this._vf.render)
+{var child,childVol;if(this._lastRangePos>=0){child=this._childNodes[this._lastRangePos];childVol=(child&&child._vf.render===true)?child.getVolume():null;if(childVol&&childVol.isValid())
+vol.extendBounds(childVol.min,childVol.max);}
+else{for(var i=0,n=this._childNodes.length;ix3dom.fields.Eps&&len*this._vf.subScale<=this._vf.size.length()){if(this._childNodes.length<=1){var offset=new Array(new x3dom.fields.SFVec3f(-0.25*this._vf.size.x,0.25*this._vf.size.y,0),new x3dom.fields.SFVec3f(0.25*this._vf.size.x,0.25*this._vf.size.y,0),new x3dom.fields.SFVec3f(-0.25*this._vf.size.x,-0.25*this._vf.size.y,0),new x3dom.fields.SFVec3f(0.25*this._vf.size.x,-0.25*this._vf.size.y,0));for(l=0;l<4;l++){var node=new x3dom.nodeTypes.DynamicLOD();node._nameSpace=this._nameSpace;node._eye.setValues(this._eye);node.level=this.level+1;node.quadrant=l;node.cell=this.cell+l;node._vf.urlHead=this._vf.urlHead;node._vf.urlCenter=this._vf.urlCenter;node._vf.urlTail=this._vf.urlTail;node._vf.center=this._vf.center.add(offset[l]);node._vf.size=this._vf.size.multiply(0.5);node._vf.subdivision.setValues(this._vf.subdivision);var app=new x3dom.nodeTypes.Appearance();var tex=new x3dom.nodeTypes.ImageTexture();tex._nameSpace=this._nameSpace;tex._vf.url[0]=this._vf.urlHead+node.quadrant+this._vf.urlCenter+node.cell+this._vf.urlTail;app.addChild(tex);tex.nodeChanged();var shape=new x3dom.nodeTypes.Shape();shape._nameSpace=this._nameSpace;shape.addChild(app);app.nodeChanged();node.addChild(shape,"root");shape.nodeChanged();this.addChild(node);node.nodeChanged();}}
+else{for(l=1;l=6){var min=-navi._vf.typeParams[5];var max=navi._vf.typeParams[4];view._movement.z=Math.min(Math.max(view._movement.z,min),max);}
+view._movement=view._movement.add(vec);mat=view.getViewpointMatrix().mult(view._transMat);view._transMat=mat.inverse().mult(x3dom.fields.SFMatrix4f.translation(view._movement)).mult(mat);}}
+x3dom.DefaultNavigation.prototype.moveForward=function(view)
+{var navi=this.navi;if(navi.getType()==="game")
+{var avatarRadius=0.25;var avatarHeight=1.6;if(navi._vf.avatarSize.length>2){avatarRadius=navi._vf.avatarSize[0];avatarHeight=navi._vf.avatarSize[1];}
+var speed=5*view._deltaT*navi._vf.speed;var yRotRad=(view._yaw/180*Math.PI);var xRotRad=(view._pitch/180*Math.PI);var dist=0;var fMat=view._flyMat.inverse();view._scene._nameSpace.doc.ctx.pickValue(view,view._width/2,view._height/2,view._lastButton);if(view._pickingInfo.pickObj)
+{dist=view._pickingInfo.pickPos.subtract(fMat.e3()).length();if(dist<=2*avatarRadius){}
+else{view._eyePos.x-=Math.sin(yRotRad)*speed;view._eyePos.z+=Math.cos(yRotRad)*speed;view._eyePos.y+=Math.sin(xRotRad)*speed;}}}};x3dom.DefaultNavigation.prototype.moveBackwards=function(view)
+{var navi=this.navi;if(navi.getType()==="game")
+{var speed=5*view._deltaT*navi._vf.speed;var yRotRad=(view._yaw/180*Math.PI);var xRotRad=(view._pitch/180*Math.PI);view._eyePos.x+=Math.sin(yRotRad)*speed;view._eyePos.z-=Math.cos(yRotRad)*speed;view._eyePos.y-=Math.sin(xRotRad)*speed;}};x3dom.DefaultNavigation.prototype.strafeLeft=function(view)
+{var navi=this.navi;if(navi.getType()==="game")
+{var speed=5*view._deltaT*navi._vf.speed;var yRotRad=(view._yaw/180*Math.PI);view._eyePos.x+=Math.cos(yRotRad)*speed;view._eyePos.z+=Math.sin(yRotRad)*speed;}};x3dom.DefaultNavigation.prototype.strafeRight=function(view)
+{var navi=this.navi;if(navi.getType()==="game")
+{var speed=5*view._deltaT*navi._vf.speed;var yRotRad=(view._yaw/180*Math.PI);view._eyePos.x-=Math.cos(yRotRad)*speed;view._eyePos.z-=Math.sin(yRotRad)*speed;}};x3dom.DefaultNavigation.prototype.navigateTo=function(view,timeStamp)
+{var navi=this.navi;var navType=navi.getType();var savedPickingInfo=null;var needNavAnim=(view._currentInputType==x3dom.InputTypes.NAVIGATION)&&(navType==="game"||(view._lastButton>0&&(navType.indexOf("fly")>=0||navType==="walk"||navType==="helicopter"||navType.substr(0,5)==="looka")));view._deltaT=timeStamp-view._lastTS;var removeZeroMargin=function(val,offset){if(val>0){if(val<=offset){return 0;}else{return val-offset;}}else if(val<=0){if(val>=-offset){return 0;}else{return val+offset;}}};var humanizeDiff=function(scale,diff){return((diff<0)?-1:1)*Math.pow(scale*Math.abs(diff),1.65);};if(needNavAnim)
+{if(view._pickingInfo.pickObj!==null){savedPickingInfo={pickPos:view._pickingInfo.pickPos,pickNorm:view._pickingInfo.pickNorm,pickObj:view._pickingInfo.pickObj,firstObj:view._pickingInfo.firstObj,lastObj:view._pickingInfo.lastObj,lastClickObj:view._pickingInfo.lastClickObj,shadowObjectId:view._pickingInfo.shadowObjectId};}
+var avatarRadius=0.25;var avatarHeight=1.6;var avatarKnee=0.75;if(navi._vf.avatarSize.length>2){avatarRadius=navi._vf.avatarSize[0];avatarHeight=navi._vf.avatarSize[1];avatarKnee=navi._vf.avatarSize[2];}
+var currViewMat=view.getViewMatrix();var dist=0;var screenSize=Math.min(view._width,view._height);var rdeltaX=removeZeroMargin((view._pressX-view._lastX)/screenSize,0.01);var rdeltaY=removeZeroMargin((view._pressY-view._lastY)/screenSize,0.01);var userXdiff=humanizeDiff(1,rdeltaX);var userYdiff=humanizeDiff(1,rdeltaY);var step=(view._lastButton&2)?-1:1;step*=(view._deltaT*navi._vf.speed);var userXstep=view._deltaT*navi._vf.speed*userXdiff;var userYstep=view._deltaT*navi._vf.speed*userYdiff;var phi=Math.PI*view._deltaT*userXdiff;var theta=Math.PI*view._deltaT*userYdiff;if(view._needNavigationMatrixUpdate===true)
+{view._needNavigationMatrixUpdate=false;view._rotMat=x3dom.fields.SFMatrix4f.identity();view._transMat=x3dom.fields.SFMatrix4f.identity();view._movement=new x3dom.fields.SFVec3f(0,0,0);var angleX=0;var angleY=Math.asin(currViewMat._02);var C=Math.cos(angleY);if(Math.abs(C)>0.0001){angleX=Math.atan2(-currViewMat._12/C,currViewMat._22/C);}
+view._flyMat=currViewMat.inverse();view._from=view._flyMat.e3();view._at=view._from.subtract(view._flyMat.e2());if(navType==="helicopter")
+view._at.y=view._from.y;view._up=view._flyMat.e1();view._pitch=angleX*180/Math.PI;view._yaw=angleY*180/Math.PI;view._eyePos=view._from.negate();}
+var tmpAt=null,tmpUp=null,tmpMat=null;var q,temp,fin;var lv,sv,up;if(navType==="game")
+{view._pitch+=view._dy;view._yaw+=view._dx;if(view._pitch>=89)view._pitch=89;if(view._pitch<=-89)view._pitch=-89;if(view._yaw>=360)view._yaw-=360;if(view._yaw<0)view._yaw=360+view._yaw;view._dx=0;view._dy=0;var xMat=x3dom.fields.SFMatrix4f.rotationX(view._pitch/180*Math.PI);var yMat=x3dom.fields.SFMatrix4f.rotationY(view._yaw/180*Math.PI);var fPos=x3dom.fields.SFMatrix4f.translation(view._eyePos);view._flyMat=xMat.mult(yMat).mult(fPos);var flyMat=view._flyMat.inverse();var tmpFrom=flyMat.e3();tmpUp=new x3dom.fields.SFVec3f(0,-1,0);tmpAt=tmpFrom.add(tmpUp);tmpUp=flyMat.e0().cross(tmpUp).normalize();tmpMat=x3dom.fields.SFMatrix4f.lookAt(tmpFrom,tmpAt,tmpUp);tmpMat=tmpMat.inverse();view._scene._nameSpace.doc.ctx.pickValue(view,view._width/2,view._height/2,view._lastButton,tmpMat,view.getProjectionMatrix().mult(tmpMat));if(view._pickingInfo.pickObj)
+{dist=view._pickingInfo.pickPos.subtract(tmpFrom).length();tmpFrom.y+=(avatarHeight-dist);flyMat.setTranslate(tmpFrom);view._eyePos=flyMat.e3().negate();view._flyMat=flyMat.inverse();view._pickingInfo.pickObj=null;}
+view._scene.getViewpoint().setView(view._flyMat);return needNavAnim;}
+else if(navType==="helicopter"){var typeParams=navi.getTypeParams();if(view._lastButton&2)
+{var stepUp=200*userYstep;typeParams[1]+=stepUp;navi.setTypeParams(typeParams);}
+if(view._lastButton&1){step=300*userYstep;}
+else{step=0;}
+theta=typeParams[0];view._from.y=typeParams[1];view._at.y=view._from.y;q=x3dom.fields.Quaternion.axisAngle(view._up,phi);temp=q.toMatrix();fin=x3dom.fields.SFMatrix4f.translation(view._from);fin=fin.mult(temp);temp=x3dom.fields.SFMatrix4f.translation(view._from.negate());fin=fin.mult(temp);view._at=fin.multMatrixPnt(view._at);lv=view._at.subtract(view._from).normalize();sv=lv.cross(view._up).normalize();up=sv.cross(lv).normalize();lv=lv.multiply(step);view._from=view._from.add(lv);view._at=view._at.add(lv);q=x3dom.fields.Quaternion.axisAngle(sv,theta);temp=q.toMatrix();fin=x3dom.fields.SFMatrix4f.translation(view._from);fin=fin.mult(temp);temp=x3dom.fields.SFMatrix4f.translation(view._from.negate());fin=fin.mult(temp);var at=fin.multMatrixPnt(view._at);view._flyMat=x3dom.fields.SFMatrix4f.lookAt(view._from,at,up);view._scene.getViewpoint().setView(view._flyMat.inverse());return needNavAnim;}
+q=x3dom.fields.Quaternion.axisAngle(view._up,phi);temp=q.toMatrix();fin=x3dom.fields.SFMatrix4f.translation(view._from);fin=fin.mult(temp);temp=x3dom.fields.SFMatrix4f.translation(view._from.negate());fin=fin.mult(temp);view._at=fin.multMatrixPnt(view._at);lv=view._at.subtract(view._from).normalize();sv=lv.cross(view._up).normalize();up=sv.cross(lv).normalize();q=x3dom.fields.Quaternion.axisAngle(sv,theta);temp=q.toMatrix();fin=x3dom.fields.SFMatrix4f.translation(view._from);fin=fin.mult(temp);temp=x3dom.fields.SFMatrix4f.translation(view._from.negate());fin=fin.mult(temp);view._at=fin.multMatrixPnt(view._at);if(navType.substr(0,5)!=="looka")
+{var currProjMat=view.getProjectionMatrix();if(navType!=="freefly"){if(step<0){tmpMat=new x3dom.fields.SFMatrix4f();tmpMat.setValue(view._last_mat_view.e0(),view._last_mat_view.e1(),view._last_mat_view.e2().negate(),view._last_mat_view.e3());view._scene._nameSpace.doc.ctx.pickValue(view,view._width/2,view._height/2,view._lastButton,tmpMat,currProjMat.mult(tmpMat));}
+else{view._scene._nameSpace.doc.ctx.pickValue(view,view._width/2,view._height/2,view._lastButton);}
+if(view._pickingInfo.pickObj)
+{dist=view._pickingInfo.pickPos.subtract(view._from).length();if(dist<=avatarRadius){step=0;}}}
+lv=view._at.subtract(view._from).normalize().multiply(step);view._at=view._at.add(lv);view._from=view._from.add(lv);if(navType==="walk")
+{tmpAt=view._from.addScaled(up,-1.0);tmpUp=sv.cross(up.negate()).normalize();tmpMat=x3dom.fields.SFMatrix4f.lookAt(view._from,tmpAt,tmpUp);tmpMat=tmpMat.inverse();view._scene._nameSpace.doc.ctx.pickValue(view,view._width/2,view._height/2,view._lastButton,tmpMat,currProjMat.mult(tmpMat));if(view._pickingInfo.pickObj)
+{dist=view._pickingInfo.pickPos.subtract(view._from).length();view._at=view._at.add(up.multiply(avatarHeight-dist));view._from=view._from.add(up.multiply(avatarHeight-dist));}}
+view._pickingInfo.pickObj=null;}
+view._flyMat=x3dom.fields.SFMatrix4f.lookAt(view._from,view._at,up);view._scene.getViewpoint().setView(view._flyMat.inverse());if(savedPickingInfo!==null){view._pickingInfo=savedPickingInfo;}}
+return needNavAnim;};x3dom.DefaultNavigation.prototype.animateTo=function(view,target,prev,dur)
+{var navi=this.navi;if(x3dom.isa(target,x3dom.nodeTypes.X3DViewpointNode)){target=target.getViewMatrix().mult(target.getCurrentTransform().inverse());}
+if(navi._vf.transitionType[0].toLowerCase()!=="teleport"&&dur!=0&&navi.getType()!=="game")
+{if(prev&&x3dom.isa(prev,x3dom.nodeTypes.X3DViewpointNode)){prev=prev.getViewMatrix().mult(prev.getCurrentTransform().inverse()).mult(view._transMat).mult(view._rotMat);view._mixer.beginTime=view._lastTS;if(arguments.length>=4&&arguments[3]!=null){view._mixer.endTime=view._lastTS+dur;}
+else{view._mixer.endTime=view._lastTS+navi._vf.transitionTime;}
+view._mixer.setBeginMatrix(prev);view._mixer.setEndMatrix(target);view._scene.getViewpoint().setView(prev);}
+else{view._scene.getViewpoint().setView(target);}}
+else
+{view._scene.getViewpoint().setView(target);}
+view._rotMat=x3dom.fields.SFMatrix4f.identity();view._transMat=x3dom.fields.SFMatrix4f.identity();view._movement=new x3dom.fields.SFVec3f(0,0,0);view._needNavigationMatrixUpdate=true;};x3dom.DefaultNavigation.prototype.orthoAnimateTo=function(view,target,prev,duration)
+{var navi=this.navi;duration=duration||navi._vf.transitionTime;view._interpolator.beginValue=prev;view._interpolator.endValue=target;view._interpolator.beginTime=view._lastTS;view._interpolator.endTime=view._lastTS+duration;};x3dom.DefaultNavigation.prototype.resetView=function(view)
+{var navi=this.navi;if(navi._vf.transitionType[0].toLowerCase()!=="teleport"&&navi.getType()!=="game")
+{var viewpoint=view._scene.getViewpoint();view._mixer.beginTime=view._lastTS;view._mixer.endTime=view._lastTS+navi._vf.transitionTime;view._mixer.setBeginMatrix(view.getViewMatrix());if(x3dom.isa(viewpoint,x3dom.nodeTypes.OrthoViewpoint))
+{this.orthoAnimateTo(view,Math.abs(viewpoint._vf.fieldOfView[0]),Math.abs(viewpoint._fieldOfView[0]));}
+var target=view._scene.getViewpoint();target.resetView();target=target.getViewMatrix().mult(target.getCurrentTransform().inverse());view._mixer.setEndMatrix(target);}else
+{view._scene.getViewpoint().resetView();}
+view.resetNavHelpers();navi._heliUpdated=false;};x3dom.DefaultNavigation.prototype.onDrag=function(view,x,y,buttonState)
+{var navi=this.navi;var navType=navi.getType();var navRestrict=navi.getExplorationMode();if(navType==="none"||navRestrict==0){return;}
+var viewpoint=view._scene.getViewpoint();var dx=x-view._lastX;var dy=y-view._lastY;var d,vec,cor,mat=null;var alpha,beta;buttonState=(!navRestrict||(navRestrict!=7&&buttonState==1))?navRestrict:buttonState;if(buttonState&1)
+{alpha=(dy*2*Math.PI)/view._width;beta=(dx*2*Math.PI)/view._height;mat=view.getViewMatrix();var mx=x3dom.fields.SFMatrix4f.rotationX(alpha);var my=x3dom.fields.SFMatrix4f.rotationY(beta);var center=viewpoint.getCenterOfRotation();mat.setTranslate(new x3dom.fields.SFVec3f(0,0,0));view._rotMat=view._rotMat.mult(x3dom.fields.SFMatrix4f.translation(center)).mult(mat.inverse()).mult(mx).mult(my).mult(mat).mult(x3dom.fields.SFMatrix4f.translation(center.negate()));}
+if(buttonState&4)
+{d=(view._scene._lastMax.subtract(view._scene._lastMin)).length();d=((d=6){var min=-navi._vf.typeParams[5];var max=navi._vf.typeParams[4];view._movement.z=Math.min(Math.max(view._movement.z,min),max);}
+view._movement=view._movement.add(vec);mat=view.getViewpointMatrix().mult(view._transMat);view._transMat=mat.inverse().mult(x3dom.fields.SFMatrix4f.translation(view._movement)).mult(mat);}}
+view._isMoving=true;view._dx=dx;view._dy=dy;view._lastX=x;view._lastY=y;};x3dom.DefaultNavigation.prototype.onTouchStart=function(view,evt,touches)
+{};x3dom.DefaultNavigation.prototype.onTouchDrag=function(view,evt,touches,translation,rotation)
+{if(view._currentInputType==x3dom.InputTypes.NAVIGATION)
+{var navi=this.navi;var viewpoint=view._scene.getViewpoint();if(navi.getType()==="examine")
+{if(translation)
+{var distance=(view._scene._lastMax.subtract(view._scene._lastMin)).length();distance=((distancebbox.max.y||cor.ybbox.max.x||cor.x0&&phinavi._vf.typeParams[5])phi=navi._vf.typeParams[4];else if(beta<0&&phi>navi._vf.typeParams[5]&&phi=4&&arguments[3]!=null){view._mixer.endTime=view._lastTS+dur;}
+else{view._mixer.endTime=view._lastTS+navi._vf.transitionTime;}
+view._mixer.setBeginMatrix(prev);view._mixer.setEndMatrix(targetMat.inverse());view._scene.getViewpoint().setView(prev);}
+else{view._scene.getViewpoint().setView(targetMat.inverse());}}
+else
+{view._scene.getViewpoint().setView(target);}
+view._rotMat=x3dom.fields.SFMatrix4f.identity();view._transMat=x3dom.fields.SFMatrix4f.identity();view._movement=new x3dom.fields.SFVec3f(0,0,0);view._needNavigationMatrixUpdate=true;this.updateFlyMat(view,target);}
+x3dom.TurntableNavigation.prototype.onTouchStart=function(view,evt,touches)
+{console.log("touchStart "+evt.touches.length);console.log(evt);view._numTouches=evt.touches.length;view._lastX=evt.touches[0].screenX;view._lastY=evt.touches[0].screenY;};x3dom.TurntableNavigation.prototype.onTouchDrag=function(view,evt,touches,translation,rotation)
+{if(view._currentInputType==x3dom.InputTypes.NAVIGATION)
+{if(evt.touches.length==1)
+{var dx=(evt.touches[0].screenX-view._lastX);var dy=(evt.touches[0].screenY-view._lastY);var alpha=(dy*2*Math.PI)/view._height;var beta=(dx*2*Math.PI)/view._width;this.rotate(view,alpha,beta);view._lastX=evt.touches[0].screenX;view._lastY=evt.touches[0].screenY;}
+else if(evt.touches.length>=2)
+{if(this.panEnabled==true)
+this.pan(view,-translation.x*4.0,-translation.y*4.0);this.zoom(view,translation.z*4.0);}}};x3dom.TurntableNavigation.prototype.onTouchEnd=function(view,evt,touches)
+{console.log("touchEnd "+evt.touches.length);console.log(evt);if(view._numTouches==2&&evt.touches.length==1){view._lastX=evt.touches[0].screenX;view._lastY=evt.touches[0].screenY;}
+view._numTouches=evt.touches.length;};x3dom.TurntableNavigation.prototype.onDoubleClick=function(view,x,y)
+{};x3dom.TurntableNavigation.prototype.setPanTarget=function(target)
+{this.target=target;};x3dom.TurntableNavigation.prototype.setPanAxis=function(a,b)
+{this.panAxisX=a;this.panAxisY=b;};x3dom.TurntableNavigation.prototype.setPanEnabled=function(enabled)
+{this.panEnabled=enabled;};x3dom.registerNodeType("X3DFontStyleNode","Text",defineClass(x3dom.nodeTypes.X3DNode,function(ctx){x3dom.nodeTypes.X3DFontStyleNode.superClass.call(this,ctx);}));x3dom.registerNodeType("FontStyle","Text",defineClass(x3dom.nodeTypes.X3DFontStyleNode,function(ctx){x3dom.nodeTypes.FontStyle.superClass.call(this,ctx);this.addField_MFString(ctx,'family',['SERIF']);this.addField_SFBool(ctx,'horizontal',true);this.addField_MFString(ctx,'justify',['MIDDLE','MIDDLE']);this.addField_SFString(ctx,'language',"");this.addField_SFBool(ctx,'leftToRight',true);this.addField_SFFloat(ctx,'size',1.0);this.addField_SFFloat(ctx,'spacing',1.0);this.addField_SFString(ctx,'style',"PLAIN");this.addField_SFBool(ctx,'topToBottom',true);this.addField_SFFloat(ctx,'quality',2.0);},{fieldChanged:function(fieldName){if(fieldName=='family'||fieldName=='horizontal'||fieldName=='justify'||fieldName=='language'||fieldName=='leftToRight'||fieldName=='size'||fieldName=='spacing'||fieldName=='style'||fieldName=='topToBottom'){Array.forEach(this._parentNodes,function(node){Array.forEach(node._parentNodes,function(textnode){textnode.setAllDirty();});});}}}));x3dom.nodeTypes.FontStyle.defaultNode=function(){if(!x3dom.nodeTypes.FontStyle._defaultNode){x3dom.nodeTypes.FontStyle._defaultNode=new x3dom.nodeTypes.FontStyle();x3dom.nodeTypes.FontStyle._defaultNode.nodeChanged();}
+return x3dom.nodeTypes.FontStyle._defaultNode;};x3dom.registerNodeType("Text","Text",defineClass(x3dom.nodeTypes.X3DGeometryNode,function(ctx){x3dom.nodeTypes.Text.superClass.call(this,ctx);this.addField_MFString(ctx,'string',[]);this.addField_MFFloat(ctx,'length',[]);this.addField_SFFloat(ctx,'maxExtent',0.0);this.addField_SFNode('fontStyle',x3dom.nodeTypes.X3DFontStyleNode);this._mesh._positions[0]=[0,0,0,1,0,0,1,1,0,0,1,0];this._mesh._normals[0]=[0,0,1,0,0,1,0,0,1,0,0,1];this._mesh._texCoords[0]=[0,0,1,0,1,1,0,1];this._mesh._colors[0]=[];this._mesh._indices[0]=[0,1,2,2,3,0];this._mesh._invalidate=true;this._mesh._numFaces=2;this._mesh._numCoords=4;},{nodeChanged:function(){if(!this._cf.fontStyle.node){this.addChild(x3dom.nodeTypes.FontStyle.defaultNode());}
+this.invalidateVolume();},fieldChanged:function(fieldName){if(fieldName=='string'||fieldName=='length'||fieldName=='maxExtent'){this.invalidateVolume();Array.forEach(this._parentNodes,function(node){node.setAllDirty();});}}}));x3dom.registerNodeType("X3DSoundNode","Sound",defineClass(x3dom.nodeTypes.X3DChildNode,function(ctx){x3dom.nodeTypes.X3DSoundNode.superClass.call(this,ctx);}));x3dom.registerNodeType("Sound","Sound",defineClass(x3dom.nodeTypes.X3DSoundNode,function(ctx){x3dom.nodeTypes.Sound.superClass.call(this,ctx);this.addField_SFNode('source',x3dom.nodeTypes.X3DSoundSourceNode);},{nodeChanged:function()
+{if(this._cf.source.node||!this._xmlNode){return;}
+x3dom.debug.logInfo("No AudioClip child node given, searching for <audio> elements...");try{Array.forEach(this._xmlNode.childNodes,function(childDomNode){if(childDomNode.nodeType===1)
+{x3dom.debug.logInfo("### Found <"+childDomNode.nodeName+"> tag.");if(childDomNode.localName.toLowerCase()==="audio")
+{var loop=childDomNode.getAttribute("loop");loop=loop?(loop.toLowerCase()==="loop"):false;var newNode=childDomNode.cloneNode(false);childDomNode.parentNode.removeChild(childDomNode);childDomNode=null;if(navigator.appName!="Microsoft Internet Explorer"){document.body.appendChild(newNode);}
+var startAudio=function(){newNode.play();};var audioDone=function(){if(loop){newNode.play();}};newNode.addEventListener("canplaythrough",startAudio,true);newNode.addEventListener("ended",audioDone,true);}}});}
+catch(e){x3dom.debug.logException(e);}}}));x3dom.registerNodeType("X3DSoundSourceNode","Sound",defineClass(x3dom.nodeTypes.X3DTimeDependentNode,function(ctx){x3dom.nodeTypes.X3DSoundSourceNode.superClass.call(this,ctx);}));x3dom.registerNodeType("AudioClip","Sound",defineClass(x3dom.nodeTypes.X3DSoundSourceNode,function(ctx){x3dom.nodeTypes.AudioClip.superClass.call(this,ctx);this.addField_MFString(ctx,'url',[]);this.addField_SFBool(ctx,'enabled',false);this.addField_SFBool(ctx,'loop',false);this._audio=document.createElement('audio');if(navigator.appName!="Microsoft Internet Explorer"){document.body.appendChild(this._audio);}
+this._sources=[];},{nodeChanged:function()
+{this._createSources=function()
+{this._sources=[];for(var i=0;i=0&&pos=3,"RenderedTexture.dimensions requires at least 3 entries.");this._clearParents=true;this._needRenderUpdate=true;this.checkDepthTextureSupport=function(){if(this._vf.depthMap&&x3dom.caps.DEPTH_TEXTURE===null)
+x3dom.debug.logWarning("RenderedTexture Node: depth texture extension not supported");};this.checkDepthTextureSupport();},{nodeChanged:function()
+{this._clearParents=true;this._needRenderUpdate=true;},fieldChanged:function(fieldName)
+{switch(fieldName)
+{case"excludeNodes":this._clearParents=true;break;case"update":if(this._vf.update.toUpperCase()=="NEXT_FRAME_ONLY"||this._vf.update.toUpperCase()=="ALWAYS"){this._needRenderUpdate=true;}
+break;case"depthMap":this.checkDepthTextureSupport();this._x3domTexture.updateTexture();this._needRenderUpdate=true;default:break;}},getViewMatrix:function()
+{if(this._clearParents&&this._cf.excludeNodes.nodes.length){var that=this;Array.forEach(this._cf.excludeNodes.nodes,function(node){for(var i=0,n=node._parentNodes.length;i11)?11:this._vf.iterations;this._vf.iterations=(this._vf.iterations<3)?3:this._vf.iterations;this._vf.maxLevel=(this._vf.maxLevel>11)?11:this._vf.maxLevel;this._vf.maxLevel=(this._vf.maxLevel<3)?3:this._vf.maxLevel;this._vf.maxLevel=(this._vf.maxLevel>this._vf.iterations)?this._vf.iterations:this._vf.maxLevel;var repeatConfig=[{x:4,y:8},{x:8,y:8},{x:8,y:16},{x:16,y:16},{x:16,y:32},{x:32,y:32},{x:32,y:64},{x:64,y:64},{x:64,y:128}];this._repeat=new x3dom.fields.SFVec2f(this._vf.dimensions[0]/repeatConfig[this._vf.iterations-3].x,this._vf.dimensions[1]/repeatConfig[this._vf.iterations-3].y);this._renderedImage=0;this._currLoadLevel=0;this._loadLevel=1;},{nextLevel:function(){if(this._loadLevel"+"http://x3dom.org/x3dom/doc/help/composedShader.html