diff --git a/CHANGELOG.md b/CHANGELOG.md index 37138a0b..33fd4844 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +Use [`vesin`](https://luthaf.fr/vesin/latest/index.html#) for accelerated neighbour list construction. + +Add `ase_calculator` method to `GraphPESModel` for easy access to an ASE calculator wrapping the model. + +Update the `mace` interfaces to use the default torch dtype if none is specified. + Add `ruff` check to CI. ## [0.0.22] - 2025-02-05 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ac52d71a..47bbbb05 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -21,7 +21,7 @@ Alternatively, you can use [`uv`](https://docs.astral.sh/uv/): ```bash git clone https://github.com//graph-pes.git cd graph-pes -uv sync --extra test +uv sync --all-extras ``` --- @@ -34,7 +34,7 @@ Next verify the tests all pass: ```bash pip install pytest -pytest src/ # or uv run pytest src/ +pytest tests/ # or uv run pytest tests/ ``` Then push your changes back to your fork of the repository: diff --git a/docs/source/models/root.rst b/docs/source/models/root.rst index b2f306fb..4051d7f4 100644 --- a/docs/source/models/root.rst +++ b/docs/source/models/root.rst @@ -10,7 +10,6 @@ Models :show-inheritance: - Loading Models ============== diff --git a/docs/source/quickstart/implement-a-model.ipynb b/docs/source/quickstart/implement-a-model.ipynb index d45266cf..9751a9b5 100644 --- a/docs/source/quickstart/implement-a-model.ipynb +++ b/docs/source/quickstart/implement-a-model.ipynb @@ -507,10 +507,9 @@ "from ase import units\n", "from ase.build import molecule\n", "from ase.md.langevin import Langevin\n", - "from graph_pes.utils.calculator import GraphPESCalculator\n", "\n", "# set up calculator and structure\n", - "calculator = GraphPESCalculator(model)\n", + "calculator = model.ase_calculator()\n", "structure = molecule(\"CH4\")\n", "structure.center(vacuum=3.0) # place in a large unit cell\n", "structure.pbc = True\n", @@ -830,7 +829,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.18" + "version": "3.9.21" } }, "nbformat": 4, diff --git a/docs/source/tools/ase.ipynb b/docs/source/tools/ase.ipynb index 883db40e..0fa10d21 100644 --- a/docs/source/tools/ase.ipynb +++ b/docs/source/tools/ase.ipynb @@ -18,7 +18,7 @@ "source": [ "!rm trajectory.xyz\n", "!rm -rf phonons\n", - "!pip install graph-pes" + "# !pip install graph-pes" ] }, { @@ -82,11 +82,25 @@ "cell_type": "code", "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "GraphPESCalculator(\n", + " model=LennardJones(epsilon=0.14, sigma=2.27, cutoff=5.0),\n", + " device=cpu,\n", + " skin=1.0\n", + ")" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "from graph_pes.utils.calculator import GraphPESCalculator\n", - "\n", - "calculator = GraphPESCalculator(model)" + "calculator = model.ase_calculator() # equivalent to GraphPESCalculator(model)\n", + "calculator" ] }, { @@ -220,11 +234,11 @@ " [-0.0000000e+00, 1.5019208e+05, -1.1695950e+05],\n", " [-0.0000000e+00, -1.5019208e+05, -1.1695950e+05],\n", " [-0.0000000e+00, -1.9921422e-01, -4.2235555e+04],\n", - " [-0.0000000e+00, 1.9988680e-01, 4.2235555e+04],\n", + " [-0.0000000e+00, 1.9921875e-01, 4.2235555e+04],\n", " [-0.0000000e+00, 3.6874703e+04, 1.4250874e+04],\n", " [-3.1934238e+04, -1.8437250e+04, 1.4250783e+04],\n", " [ 3.1934238e+04, -1.8437250e+04, 1.4250783e+04],\n", - " [-0.0000000e+00, -3.6874699e+04, -1.4250874e+04],\n", + " [-0.0000000e+00, -3.6874703e+04, -1.4250874e+04],\n", " [-3.1934238e+04, 1.8437250e+04, -1.4250783e+04],\n", " [ 3.1934238e+04, 1.8437250e+04, -1.4250783e+04]], dtype=float32)}" ] @@ -252,7 +266,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -261,7 +275,7 @@ "Atoms(symbols='Cu4', pbc=True, cell=[3.61, 3.61, 3.61])" ] }, - "execution_count": 4, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -275,9 +289,17 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 9, "metadata": {}, "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "WARNING, 3 imaginary frequencies at q = ( 0.00, 0.00, 0.00) ; (omega_q = 1.204e-07*i)\n", + "WARNING, 3 imaginary frequencies at q = ( 0.00, 0.00, 0.00) ; (omega_q = 1.204e-07*i)\n" + ] + }, { "data": { "image/svg+xml": [ @@ -289,11 +311,11 @@ " \n", " \n", " \n", - " 2024-11-01T16:44:49.669434\n", + " 2025-02-15T10:31:47.741063\n", " image/svg+xml\n", " \n", " \n", - " Matplotlib v3.7.5, https://matplotlib.org/\n", + " Matplotlib v3.9.4, https://matplotlib.org/\n", " \n", " \n", " \n", @@ -324,12 +346,12 @@ " \n", " \n", " \n", - " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -353,7 +375,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -383,7 +405,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -414,7 +436,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -427,7 +449,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -470,7 +492,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -496,7 +518,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -511,12 +533,12 @@ " \n", " \n", " \n", - " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -563,7 +585,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -607,7 +629,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -640,7 +662,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -657,7 +679,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -700,7 +722,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -717,7 +739,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -961,1149 +983,1149 @@ " \n", " \n", + "\" clip-path=\"url(#pa4a5a3257e)\" style=\"fill: none; stroke: #808080; stroke-width: 1.5; stroke-linecap: square\"/>\n", " \n", " \n", " \n", + "\" clip-path=\"url(#pa4a5a3257e)\" style=\"fill: none; stroke: #808080; stroke-width: 1.5; stroke-linecap: square\"/>\n", " \n", " \n", " \n", + "\" clip-path=\"url(#pa4a5a3257e)\" style=\"fill: none; stroke: #808080; stroke-width: 1.5; stroke-linecap: square\"/>\n", " \n", " \n", " \n", + "\" clip-path=\"url(#pa4a5a3257e)\" style=\"fill: none; stroke: #808080; stroke-width: 1.5; stroke-linecap: square\"/>\n", " \n", " \n", " \n", + "\" clip-path=\"url(#pa4a5a3257e)\" style=\"fill: none; stroke: #808080; stroke-width: 1.5; stroke-linecap: square\"/>\n", " \n", " \n", " \n", + "\" clip-path=\"url(#pa4a5a3257e)\" style=\"fill: none; stroke-dasharray: 1.5,2.475; stroke-dashoffset: 0; stroke: #000000; stroke-width: 1.5\"/>\n", " \n", " \n", - " \n", + " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", - " \n", + "L 169.804666 133.643637 \n", + "L 175.446603 152.752447 \n", + "L 182.499024 177.31922 \n", + "L 193.615003 137.089525 \n", + "L 199.172993 117.713856 \n", + "L 204.730982 99.248229 \n", + "L 208.899475 86.196505 \n", + "L 210.288972 82.026468 \n", + "L 211.67847 82.314588 \n", + "L 217.236459 87.058606 \n", + "L 225.573444 94.206353 \n", + "L 229.741936 97.441955 \n", + "L 232.520931 99.352918 \n", + "L 235.299926 101.005391 \n", + "L 238.078921 102.350249 \n", + "L 240.857916 103.344784 \n", + "L 243.636911 103.9557 \n", + "L 246.415905 104.161748 \n", + "L 251.90937 104.044141 \n", + "L 257.402835 103.705359 \n", + "L 264.269666 103.032752 \n", + "L 288.990258 100.276628 \n", + "L 294.483722 100.004524 \n", + "L 298.603821 99.941638 \n", + "L 298.603821 104.064813 \n", + "L 335.50625 104.161748 \n", + "L 335.50625 104.161748 \n", + "\" clip-path=\"url(#pa4a5a3257e)\" style=\"fill: none; stroke: #008000; stroke-width: 1.5; stroke-linecap: square\"/>\n", " \n", " \n", - " \n", + " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -2170,16 +2192,16 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "-3.7550206184387207" + "-3.7550203800201416" ] }, - "execution_count": 6, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -2193,37 +2215,43 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - " Step Time Energy fmax\n", - "BFGS: 0 16:44:49 -3.755020 2.3329\n", - "BFGS: 1 16:44:49 -3.913639 1.6164\n", - "BFGS: 2 16:44:49 -4.147000 0.6284\n", - "BFGS: 3 16:44:49 -4.203425 0.3997\n", - "BFGS: 4 16:44:49 -4.214466 0.3173\n", - "BFGS: 5 16:44:49 -4.221203 0.2834\n", - "BFGS: 6 16:44:49 -4.229444 0.1693\n", - "BFGS: 7 16:44:49 -4.231928 0.0666\n", - "BFGS: 8 16:44:49 -4.232348 0.0442\n", - "BFGS: 9 16:44:49 -4.232435 0.0360\n", - "BFGS: 10 16:44:49 -4.232537 0.0273\n", - "BFGS: 11 16:44:49 -4.232614 0.0190\n", - "BFGS: 12 16:44:49 -4.232644 0.0110\n", - "BFGS: 13 16:44:49 -4.232650 0.0081\n" + " Step Time Energy fmax\n", + "BFGS: 0 10:31:49 -3.755020 2.332890\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "BFGS: 1 10:31:49 -3.913639 1.616382\n", + "BFGS: 2 10:31:49 -4.147001 0.628381\n", + "BFGS: 3 10:31:49 -4.203425 0.399706\n", + "BFGS: 4 10:31:49 -4.214467 0.317304\n", + "BFGS: 5 10:31:49 -4.221203 0.283429\n", + "BFGS: 6 10:31:49 -4.229444 0.169319\n", + "BFGS: 7 10:31:49 -4.231928 0.066617\n", + "BFGS: 8 10:31:49 -4.232348 0.044161\n", + "BFGS: 9 10:31:49 -4.232435 0.035994\n", + "BFGS: 10 10:31:49 -4.232536 0.027330\n", + "BFGS: 11 10:31:49 -4.232615 0.018950\n", + "BFGS: 12 10:31:49 -4.232644 0.011048\n", + "BFGS: 13 10:31:49 -4.232650 0.008053\n" ] }, { "data": { "text/plain": [ - "-4.232650259216035" + "-4.232650279998779" ] }, - "execution_count": 7, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -2247,7 +2275,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -2264,7 +2292,7 @@ " */\n", "var x3dom={canvases:[],x3dNS:\"http://www.web3d.org/specifications/x3d-namespace\",x3dextNS:\"http://philip.html5.org/x3d/ext\",xsltNS:\"http://www.w3.org/1999/XSL/x3dom.Transform\",xhtmlNS:\"http://www.w3.org/1999/xhtml\"};function defineClass(e,t,i){if(e){function o(){}o.prototype=e.prototype,t.prototype=new o,t.prototype.constructor=t,t.superClass=e}if(i)for(var s in i)t.prototype[s]=i[s];return t}function array_to_object(e){for(var t={},i=0;ix3dom.debug.maxLinesToLog))){var i=document.createElement(\"p\");switch(i.style.margin=0,t){case x3dom.debug.INFO:i.style.color=\"#00ff00\";break;case x3dom.debug.WARNING:i.style.color=\"#cd853f\";break;case x3dom.debug.ERROR:i.style.color=\"#ff4500\";break;case x3dom.debug.EXCEPTION:i.style.color=\"#ffff00\";break;default:i.style.color=\"#00ff00\"}try{i.innerHTML=t+\": \"+e,x3dom.debug.logContainer.insertBefore(i,x3dom.debug.logContainer.firstChild)}catch(t){void 0!==window.console.firebug&&window.console.warn(e)}if(x3dom.debug.isFirebugAvailable)switch(t){case x3dom.debug.INFO:window.console.info(e);break;case x3dom.debug.WARNING:window.console.warn(e);break;case x3dom.debug.ERROR:window.console.error(e);break;case x3dom.debug.EXCEPTION:window.console.debug(e)}x3dom.debug.numLinesLogged++}},logInfo:function(e){x3dom.debug.doLog(e,x3dom.debug.INFO)},logWarning:function(e){x3dom.debug.doLog(e,x3dom.debug.WARNING)},logError:function(e){x3dom.debug.doLog(e,x3dom.debug.ERROR)},logException:function(e){x3dom.debug.doLog(e,x3dom.debug.EXCEPTION)},assert:function(e,t){e||x3dom.debug.doLog(\"Assertion failed in \"+x3dom.debug.assert.caller.name+\": \"+t,x3dom.debug.ERROR)},typeOf:function(e){var t=typeof e;return\"object\"!==t||e?t:\"null\"},exists:function(e,t,i){return i=i||\"function\",(e?this.typeOf(e[t]):\"null\")===i},dumpFields:function(e){var t=\"\";for(var i in e)t+=i+\", \";return t+=\"\\n\",x3dom.debug.logInfo(t),t}},x3dom.debug.setup(),x3dom.X3DCanvas=function(e,t){var i=this;if(this._canvasIdx=t,this.x3dElem=e,this._current_dim=[0,0],this.fps_t0=(new Date).getTime(),this.lastTimeFPSWasTaken=0,this.framesSinceLastTime=0,this._totalTime=0,this._elapsedTime=0,this.doc=null,this.isSessionSupportedPromise=null,this.xrSession=null,this.xrReferenceSpace=null,this.supportsPassiveEvents=!1,this.devicePixelRatio=window.devicePixelRatio||1,this.lastMousePos={x:0,y:0},x3dom.caps.DOMNodeInsertedEvent_perSubtree=!(-1!=navigator.userAgent.indexOf(\"MSIE\")||-1!=navigator.userAgent.indexOf(\"Trident\")),e.__setAttribute=e.setAttribute,e.setAttribute=function(e,t){switch(this.__setAttribute(e,t),t=parseInt(t),e){case\"width\":i.canvas.setAttribute(\"width\",t*i.devicePixelRatio),i.doc&&i.doc._viewarea&&(i.doc._viewarea._width=parseInt(i.canvas.getAttribute(\"width\"),0),i.doc.needRender=!0);break;case\"height\":i.canvas.setAttribute(\"height\",t*i.devicePixelRatio),i.doc&&i.doc._viewarea&&(i.doc._viewarea._height=parseInt(i.canvas.getAttribute(\"height\"),0),i.doc.needRender=!0)}},this.backend=this.x3dElem.getAttribute(\"backend\"),this.backend=this.backend?this.backend.toLowerCase():\"none\",this.canvas=this._createHTMLCanvas(e),x3dom.debug.appendElement(e),this.canvas.parent=this,this.gl=this._initContext(this.canvas),this.backend=\"webgl\",null==this.gl)return this.hasRuntime=!1,void this._createInitFailedDiv(e);x3dom.caps.BACKEND=this.backend;var o=e.getAttribute(\"runtimeEnabled\");this.hasRuntime=null!==o?\"true\"==o.toLowerCase():e.hasRuntime,this.showStat=e.getAttribute(\"showStat\"),this.stateViewer=new x3dom.States(e),null!==this.showStat&&\"true\"==this.showStat&&this.stateViewer.display(!0),this.x3dElem.appendChild(this.stateViewer.viewer),this.showProgress=e.getAttribute(\"showProgress\"),this.progressDiv=this._createProgressDiv(),this.progressDiv.style.display=null!==this.showProgress&&\"true\"==this.showProgress?\"flex\":\"none\",this.x3dElem.appendChild(this.progressDiv),this.vrDiv=this._createVRDiv(),this.x3dElem.appendChild(this.vrDiv),this.showTouchpoints=e.getAttribute(\"showTouchpoints\"),this.showTouchpoints=!!this.showTouchpoints&&this.showTouchpoints,this.disableTouch=e.getAttribute(\"disableTouch\"),this.disableTouch=!!this.disableTouch&&\"true\"==this.disableTouch.toLowerCase(),this.disableKeys=e.getAttribute(\"disableKeys\"),this.disableKeys=!!this.disableKeys&&\"true\"==this.disableKeys.toLowerCase(),this.disableRightDrag=e.getAttribute(\"disableRightDrag\"),this.disableRightDrag=!!this.disableRightDrag&&\"true\"==this.disableRightDrag.toLowerCase(),this.disableLeftDrag=e.getAttribute(\"disableLeftDrag\"),this.disableLeftDrag=!!this.disableLeftDrag&&\"true\"==this.disableLeftDrag.toLowerCase(),this.disableMiddleDrag=e.getAttribute(\"disableMiddleDrag\"),this.disableMiddleDrag=!!this.disableMiddleDrag&&\"true\"==this.disableMiddleDrag.toLowerCase(),this.detectPassiveEvents(),this.bindEventListeners()},x3dom.X3DCanvas.prototype.detectPassiveEvents=function(){if(\"undefined\"!=typeof window&&\"function\"==typeof window.addEventListener){var e=!1,t=Object.defineProperty({},\"passive\",{get:function(){e=!0}}),i=function(){};window.addEventListener(\"testPassiveEventSupport\",i,t),window.removeEventListener(\"testPassiveEventSupport\",i,t),this.supportsPassiveEvents=e}},x3dom.X3DCanvas.prototype.bindEventListeners=function(){var e=this;if(this.onMouseDown=function(t){if(!this.isMulti){switch(this.focus(),this.classList.add(\"x3dom-canvas-mousedown\"),t.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}t.shiftKey&&(this.mouse_button=1),t.ctrlKey&&(this.mouse_button=4),t.altKey&&(this.mouse_button=2);var i=this.parent.mousePosition(t);this.mouse_drag_x=i.x,this.mouse_drag_y=i.y,this.mouse_dragging=!0,this.parent.doc.onMousePress(e.gl,this.mouse_drag_x,this.mouse_drag_y,this.mouse_button),this.parent.doc.needRender=!0}},this.onMouseUp=function(t){if(!this.isMulti){var i=this.mouse_button;this.classList.remove(\"x3dom-canvas-mousedown\"),this.mouse_button=0,this.mouse_dragging=!1,this.parent.doc.onMouseRelease(e.gl,this.mouse_drag_x,this.mouse_drag_y,this.mouse_button,i),this.parent.doc.needRender=!0}},this.onMouseOver=function(t){this.isMulti||(this.mouse_button=0,this.mouse_dragging=!1,this.parent.doc.onMouseOver(e.gl,this.mouse_drag_x,this.mouse_drag_y,this.mouse_button),this.parent.doc.needRender=!0)},this.onMouseOut=function(t){this.isMulti||(this.mouse_button=0,this.mouse_dragging=!1,this.classList.remove(\"x3dom-canvas-mousedown\"),this.parent.doc.onMouseOut(e.gl,this.mouse_drag_x,this.mouse_drag_y,this.mouse_button),this.parent.doc.needRender=!0)},this.onDoubleClick=function(t){if(!this.isMulti){this.mouse_button=0;var i=this.parent.mousePosition(t);this.mouse_drag_x=i.x,this.mouse_drag_y=i.y,this.mouse_dragging=!1,this.parent.doc.onDoubleClick(e.gl,this.mouse_drag_x,this.mouse_drag_y),this.parent.doc.needRender=!0}},this.onMouseMove=function(t){if(!this.isMulti){var i=this.parent.mousePosition(t);i.x==e.lastMousePos.x&&i.y==e.lastMousePos.y||(e.lastMousePos=i,this.mouse_drag_x=i.x,this.mouse_drag_y=i.y,this.mouse_dragging?(t.shiftKey&&(this.mouse_button=1),t.ctrlKey&&(this.mouse_button=4),t.altKey&&(this.mouse_button=2),(1==this.mouse_button&&!this.parent.disableLeftDrag||2==this.mouse_button&&!this.parent.disableRightDrag||4==this.mouse_button&&!this.parent.disableMiddleDrag)&&this.parent.doc.onDrag(e.gl,this.mouse_drag_x,this.mouse_drag_y,this.mouse_button)):this.parent.doc.onMove(e.gl,this.mouse_drag_x,this.mouse_drag_y,this.mouse_button),this.parent.doc.needRender=!0,t.preventDefault(),t.stopPropagation())}},this.onDOMMouseScroll=function(t){if(!this.isMulti){this.focus();var i=this.parent.mousePosition(t).y;1==this.parent.doc._scene.getNavigationInfo()._vf.reverseScroll?this.mouse_drag_y-=2*t.detail:this.mouse_drag_y+=2*t.detail,this.parent.doc.onWheel(e.gl,this.mouse_drag_x,this.mouse_drag_y,i),this.parent.doc.needRender=!0,t.preventDefault(),t.stopPropagation()}},this.onKeyPress=function(e){this.parent.disableKeys||(e.preventDefault(),this.parent.doc.onKeyPress(e.charCode)),this.parent.doc.needRender=!0},this.onMouseWheel=function(t){if(!this.isMulti){this.focus();var i=this.parent.mousePosition(t).y;1==this.parent.doc._scene.getNavigationInfo()._vf.reverseScroll?this.mouse_drag_y+=.1*t.wheelDelta:this.mouse_drag_y-=.1*t.wheelDelta,this.parent.doc.onWheel(e.gl,this.mouse_drag_x,this.mouse_drag_y,i),this.parent.doc.needRender=!0,t.preventDefault(),t.stopPropagation()}},this.onKeyUp=function(e){this.parent.disableKeys||this.parent.doc.onKeyUp(e.keyCode),this.parent.doc.needRender=!0},this.onKeyDown=function(e){this.parent.disableKeys||this.parent.doc.onKeyDown(e.keyCode),this.parent.doc.needRender=!0},null!==this.canvas&&null!==this.gl&&this.hasRuntime){this.canvas.mouse_dragging=!1,this.canvas.mouse_button=0,this.canvas.mouse_drag_x=0,this.canvas.mouse_drag_y=0,this.canvas.isMulti=!1,this.canvas.oncontextmenu=function(e){return e.preventDefault(),e.stopPropagation(),!1},this.canvas.addEventListener(\"webglcontextlost\",(function(e){x3dom.debug.logError(\"WebGL context lost\"),e.preventDefault()}),!1),this.canvas.addEventListener(\"webglcontextrestored\",(function(e){x3dom.debug.logError(\"recover WebGL state and resources on context lost NYI\"),e.preventDefault()}),!1),this.canvas.addEventListener(\"mousedown\",this.onMouseDown,!1),this.canvas.addEventListener(\"mouseup\",this.onMouseUp,!1),this.canvas.addEventListener(\"mouseover\",this.onMouseOver,!1),this.canvas.addEventListener(\"mouseout\",this.onMouseOut,!1),this.canvas.addEventListener(\"dblclick\",this.onDoubleClick,!1),this.canvas.addEventListener(\"mousemove\",this.onMouseMove,!1),this.canvas.addEventListener(\"DOMMouseScroll\",this.onDOMMouseScroll,!1),this.canvas.addEventListener(\"mousewheel\",this.onMouseWheel,!!this.supportsPassiveEvents&&{passive:!1}),this.canvas.addEventListener(\"keypress\",this.onKeyPress,!0),this.canvas.addEventListener(\"keyup\",this.onKeyUp,!0),this.canvas.addEventListener(\"keydown\",this.onKeyDown,!0);var t={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(e){var t=e.normalize().dot(new x3dom.fields.SFVec2f(1,0));return t=Math.acos(t),e.y<0&&(t=Math.PI+(Math.PI-t)),t},disableTouch:this.disableTouch,visMarker:this.showTouchpoints,visMarkerBag:[],visualizeTouches:function(e){if(this.visMarker){for(var t=[],i=null,o=0;o=0?((i=document.getElementById(\"visMarker\"+s)).style.left=e.touches[o].pageX+\"px\",i.style.top=e.touches[o].pageY+\"px\"):((i=document.createElement(\"div\")).appendChild(document.createTextNode(\"#\"+s)),i.id=\"visMarker\"+s,i.className=\"x3dom-touch-marker\",document.body.appendChild(i),r=this.visMarkerBag.length,this.visMarkerBag[r]=s),t.push(s)}for(var n=this.visMarkerBag.length-1;n>=0;n--){var a=this.visMarkerBag[n];t.indexOf(a)<0&&(this.visMarkerBag.splice(n,1),i=document.getElementById(\"visMarker\"+a),document.body.removeChild(i))}}}};this.disableTouch||(this.canvas.addEventListener(\"touchstart\",(function(i,o){var s,r;switch(this.isMulti=!0,i.preventDefault(),t.visualizeTouches(i),this.focus(),null==o&&(o=this.parent.doc),o._scene.getNavigationInfo().getType()){case\"examine\":t.examineNavType=1;break;case\"turntable\":t.examineNavType=2;break;default:t.examineNavType=0}for(t.lastLayer=[],s=0;s=2){t.numTouches=2;var n=new x3dom.fields.SFVec2f(i.touches[0].screenX,i.touches[0].screenY),a=new x3dom.fields.SFVec2f(i.touches[1].screenX,i.touches[1].screenY).subtract(n),d=a.multiply(.5).add(n),l=a.dot(a);t.lastMiddle=d,t.lastSquareDistance=l,t.lastAngle=t.calcAngle(a),t.lastPos=this.parent.mousePosition(i.touches[0])}if(o._scene.updateVolume(),1==t.examineNavType)for(s=0;s=2){s=new x3dom.fields.SFVec2f(i.touches[0].screenX,i.touches[0].screenY),n=(r=new x3dom.fields.SFVec2f(i.touches[1].screenX,i.touches[1].screenY).subtract(s)).multiply(.5).add(s),a=r.dot(r),d=n.subtract(t.lastMiddle),l=a-t.lastSquareDistance,h=new x3dom.fields.SFVec3f(d.x/screen.width,-d.y/screen.height,l/(screen.width*screen.height*.2));var x=t.calcAngle(r),g=t.lastAngle-x;t.lastAngle=x,u=x3dom.fields.SFMatrix4f.rotationZ(g),t.lastMiddle=n,t.lastSquareDistance=a,o.onMoveView(e.gl,i,t,h,u)}}else i.touches.length&&(2==t.examineNavType&&i.touches.length>=2?(s=new x3dom.fields.SFVec2f(i.touches[0].screenX,i.touches[0].screenY),l=((a=(r=new x3dom.fields.SFVec2f(i.touches[1].screenX,i.touches[1].screenY).subtract(s)).dot(r))-t.lastSquareDistance)/(.1*(screen.width+screen.height)),t.lastPos.y+=l,t.lastSquareDistance=a,o.onDrag(e.gl,t.lastPos.x,t.lastPos.y,2)):(f=this.parent.mousePosition(i.touches[0]),o.onDrag(e.gl,f.x,f.y,1)));o.needRender=!0}),!this.supportsPassiveEvents||{passive:!1}),this.canvas.addEventListener(\"touchend\",(function(i,o){if(this.isMulti=!1,i.cancelable&&i.preventDefault(),t.visualizeTouches(i),null==o&&(o=this.parent.doc),o._viewarea._isMoving=!1,2==t.numTouches&&1==i.touches.length&&(t.lastDrag=new x3dom.fields.SFVec2f(i.touches[0].screenX,i.touches[0].screenY)),0==i.touches.length){for(var s=o._nodeBag.affectedPointingSensors,r=0;r=0&&x3dom.debug.logWarning(\"The width attribute is to be specified in pixels not in percent.\"),t.style.width=a,e.style.width=a,t.setAttribute(\"width\",a)),null!==(d=e.getAttribute(\"height\"))&&(d.indexOf(\"%\")>=0&&x3dom.debug.logWarning(\"The height attribute is to be specified in pixels not in percent.\"),t.style.height=d,e.style.height=d,t.setAttribute(\"height\",d)),t.setAttribute(\"tabindex\",\"0\"),t},x3dom.X3DCanvas.prototype._watchForResize=function(){if(!this.xrSession){var e=[parseInt(x3dom.getStyle(this.canvas,\"width\"))||0,parseInt(x3dom.getStyle(this.canvas,\"height\"))||0];this._current_dim[0]==e[0]&&this._current_dim[1]==e[1]||(this._current_dim=e,this.x3dElem.setAttribute(\"width\",e[0]+\"px\"),this.x3dElem.setAttribute(\"height\",e[1]+\"px\"))}},x3dom.X3DCanvas.prototype._createProgressDiv=function(){var e=document.createElement(\"div\");e.setAttribute(\"class\",\"x3dom-progress\");var t=document.createElement(\"div\");t.setAttribute(\"class\",\"x3dom-progress-spinner\"),e.appendChild(t);var i=document.createElement(\"div\");return i.setAttribute(\"id\",\"x3domProgessCount\"),i.appendChild(document.createTextNode(\"Loading...\")),e.appendChild(i),e.oncontextmenu=e.onmousedown=function(e){return e.preventDefault(),e.stopPropagation(),!1},e},x3dom.X3DCanvas.prototype._createVRDiv=function(){var e=document.createElement(\"div\");return e.setAttribute(\"class\",\"x3dom-vr\"),e.onclick=e=>{this.x3dElem.runtime.toggleVR()},e.oncontextmenu=function(e){return e.preventDefault(),e.stopPropagation(),!1},e.title=\"Toggle VR\",e},x3dom.X3DCanvas.prototype.mousePosition=function(e){var t=e.target.getBoundingClientRect(),i=Math.round(e.clientX-t.left)*this.devicePixelRatio,o=Math.round(e.clientY-t.top)*this.devicePixelRatio;return new x3dom.fields.SFVec2f(i,o)},x3dom.X3DCanvas.prototype.tick=function(e,t){this._elapsedTime=this._totalTime?e-this._totalTime:0,this._totalTime=e;var i=this.x3dElem.runtime,o=(new Date).getTime(),s=o-this.lastTimeFPSWasTaken;this.fps_t0;this.fps_t0=o,this.doc.advanceTime(o/1e3);var r,n=(new Date).getTime()-o;if(this.doc.hasAnimationStateChanged()&&(this.doc.isAnimating()?i.onAnimationStarted():i.onAnimationFinished()),(this.doc.needRender||t)&&(s>=1e3&&(i.fps=this.framesSinceLastTime/(s/1e3),i.addMeasurement(\"FPS\",i.fps),this.framesSinceLastTime=0,this.lastTimeFPSWasTaken=o),this.framesSinceLastTime++,i.addMeasurement(\"ANIM\",n),0==i.isReady&&(i.ready(),i.isReady=!0),i.enterFrame({total:this._totalTime,elapsed:this._elapsedTime}),t||(this.doc.needRender=!1),this.doc.render(this.gl,this.getVRFrameData(t)),this.doc._scene._vf.doPickPass||i.removeMeasurement(\"PICKING\"),i.exitFrame({total:this._totalTime,elapsed:this._elapsedTime})),this.progressDiv)if(this.doc.downloadCount>0?i.addInfo(\"#LOADS:\",this.doc.downloadCount):i.removeInfo(\"#LOADS:\"),\"false\"!==this.doc.properties.getProperty(\"showProgress\")){if(this.progressDiv){var a=Math.max(+this.doc.downloadCount,0);this.progressDiv.childNodes[1].textContent=\"\"+a,this.doc.downloadCount>0?this.progressDiv.style.opacity=\"1\":this.progressDiv.style.opacity=\"0\"}}else this.progressDiv.style.opacity=\"0\";this.doc.downloadCount<=0&&this.doc.previousDownloadCount>0&&(document.createEvent?((r=document.createEvent(\"Events\")).initEvent(\"downloadsfinished\",!0,!0),this.x3dElem.dispatchEvent(r)):document.createEventObject&&(r=document.createEventObject(),this.x3dElem.fireEvent(\"ondownloadsfinished\",r)));this.doc.previousDownloadCount=this.doc.downloadCount},x3dom.X3DCanvas.prototype.mainloop=function(e,t){this.doc&&this.x3dElem.runtime&&(this._watchForResize(),this.tick(e,t),this.xrSession?this.xrSession.requestAnimationFrame(this.mainloop):window.requestAnimFrame(this.mainloop))},x3dom.X3DCanvas.prototype.load=function(e,t,i){this.doc=new x3dom.X3DDocument(this.canvas,this.gl,i),this.doc.onload=()=>{this.mainloop=this.mainloop.bind(this),this.checkForVRSupport(),this.hasRuntime?this.mainloop():this.tick()},this.x3dElem.render=()=>{this.hasRuntime?this.doc.needRender=!0:this.doc.render(x3dCanvas.gl)},this.x3dElem.context=this.gl.ctx3d,this.doc.onerror=function(){alert(\"Failed to load X3D document\")},this.doc.load(e,t)},x3dom.X3DCanvas.prototype.checkForVRSupport=function(){navigator.xr&&navigator.xr.isSessionSupported(\"immersive-vr\").then(e=>{e&&(this.vrDiv.style.display=\"block\")})},x3dom.X3DCanvas.prototype.enterVR=function(){this.xrSession||this.gl.ctx3d.makeXRCompatible().then(()=>{navigator.xr.requestSession(\"immersive-vr\").then(e=>{e.requestReferenceSpace(\"local\").then(t=>{const i=new XRWebGLLayer(e,this.gl.ctx3d);e.updateRenderState({baseLayer:i}),this._oldCanvasWidth=this.canvas.width,this._oldCanvasHeight=this.canvas.height,this.canvas.width=i.framebufferWidth,this.canvas.height=i.framebufferHeight,this.gl.VRMode=2,this.xrReferenceSpace=t,this.xrSession=e,this.doc.needRender=!0;var o=this.doc._viewarea.getViewMatrix(),s=new x3dom.fields.Quaternion(0,0,1,0);s.normalize(),s.setValue(o);var r=o.e3();const n=new XRRigidTransform({x:r.x,y:r.y,z:r.z},{x:s.x,y:s.y,z:s.z,w:s.w});this.xrReferenceSpace=this.xrReferenceSpace.getOffsetReferenceSpace(n),this.xrSession.addEventListener(\"end\",()=>{this.exitVR()}),e.requestAnimationFrame(this.mainloop)})})})},x3dom.X3DCanvas.prototype.exitVR=function(){this.xrSession&&(this.xrSession.end(),this.xrSession=void 0,this.xrReferenceSpace=void 0,this.canvas.width=this._oldCanvasWidth,this.canvas.height=this._oldCanvasHeight,this.gl.VRMode=1,this.doc.needRender=!0,window.requestAnimationFrame(this.mainloop))},x3dom.X3DCanvas.prototype.getVRFrameData=function(e){if(!e)return;const t=e.getViewerPose(this.xrReferenceSpace);if(!t)return;const i={framebuffer:e.session.renderState.baseLayer.framebuffer,controllers:{}};for(const e of t.views)\"left\"===e.eye?(i.leftViewMatrix=e.transform.inverse.matrix,i.leftProjectionMatrix=e.projectionMatrix):\"right\"===e.eye&&(i.rightViewMatrix=e.transform.inverse.matrix,i.rightProjectionMatrix=e.projectionMatrix);for(const t of e.session.inputSources)if(t.gripSpace){const o=e.getPose(t.gripSpace,this.xrReferenceSpace);null!==o&&null!==o.transform&&(i.controllers[t.handedness]={gamepad:t.gamepad,type:t.profiles[0],pose:{position:[o.transform.position.x,o.transform.position.y,o.transform.position.z],orientation:[o.transform.orientation.x,o.transform.orientation.y,o.transform.orientation.z,o.transform.orientation.w]}})}return i},x3dom.InputTypes={NAVIGATION:1,INTERACTION:2},x3dom.Viewarea=function(e,t){this._doc=e,this._scene=t,e._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=!0,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=!1,this._isMoving=!1,this._lastTS=0,this._mixer=new x3dom.MatrixMixer,this._interpolator=new x3dom.FieldInterpolator,this._animationStateChanged=!1,this.vrFrameData=null,this.gamepads=null,this.vrLeftViewMatrix=new x3dom.fields.SFMatrix4f,this.vrRightViewMatrix=new x3dom.fields.SFMatrix4f,this.vrLeftProjMatrix=new x3dom.fields.SFMatrix4f,this.vrRightProjMatrix=new x3dom.fields.SFMatrix4f,this.vrControllerManager=new x3dom.VRControllerManager(this._doc),this._inverseDevicePixelRatio=1/window.devicePixelRatio,this.arc=null},x3dom.Viewarea.prototype.setVRFrameData=function(e,t){this.vrFrameData=t,this.vrFrameData&&(this.vrLeftViewMatrix.setFromArray(this.vrFrameData.leftViewMatrix),this.vrRightViewMatrix.setFromArray(this.vrFrameData.rightViewMatrix),this.vrLeftProjMatrix.setFromArray(this.vrFrameData.leftProjectionMatrix),this.vrRightProjMatrix.setFromArray(this.vrFrameData.rightProjectionMatrix))},x3dom.Viewarea.prototype.updateGamepads=function(e){this.vrControllerManager.update(this,e)},x3dom.Viewarea.prototype.tick=function(e){if(this._scene.getEnvironment()._vf.enableARC&&null==this.arc&&(this.arc=new x3dom.arc.AdaptiveRenderControl(this._scene)),this._mixer.isActive()){if(this._mixer._isVPtarget){var t=this._scene.getViewpoint();t.resetView();var i=t.getViewMatrix().mult(t.getCurrentTransform().inverse());this._mixer.setEndMatrix(i)}var o=this._mixer.mix(e);this._scene.getViewpoint().setView(o)}if(this._interpolator.isActive()){var s=this._interpolator.interpolate(e);this._scene.getViewpoint().setZoom(s)}var r=this.navigateTo(e),n=this._isAnimating;return this._lastTS=e,this._isAnimating=this._mixer.isMixing||this._interpolator.isInterpolating||r,this._isAnimating!=n?this._animationStateChanged=!0:this._animationStateChanged=!1,null!=this.arc&&this.arc.update(this.isMovingOrAnimating()?1:0,this._doc._x3dElem.runtime.getFPS()),this._isAnimating||n},x3dom.Viewarea.prototype.isMoving=function(){return this._isMoving},x3dom.Viewarea.prototype.isAnimating=function(){return this._isAnimating},x3dom.Viewarea.prototype.hasAnimationStateChanged=function(){return this._animationStateChanged},x3dom.Viewarea.prototype.isMovingOrAnimating=function(){return this._isMoving||this._isAnimating},x3dom.Viewarea.prototype.navigateTo=function(e){return this._scene.getNavigationInfo()._impl.navigateTo(this,e)},x3dom.Viewarea.prototype.moveFwd=function(){this._scene.getNavigationInfo()._impl.moveForward(this)},x3dom.Viewarea.prototype.moveBwd=function(){this._scene.getNavigationInfo()._impl.moveBackwards(this)},x3dom.Viewarea.prototype.strafeRight=function(){this._scene.getNavigationInfo()._impl.strafeRight(this)},x3dom.Viewarea.prototype.strafeLeft=function(){this._scene.getNavigationInfo()._impl.strafeLeft(this)},x3dom.Viewarea.prototype.animateTo=function(e,t,i){this._scene.getNavigationInfo()._impl.animateTo(this,e,t,i)},x3dom.Viewarea.prototype.orthoAnimateTo=function(e,t,i){this._scene.getNavigationInfo()._impl.orthoAnimateTo(this,e,t,i)},x3dom.Viewarea.prototype.zoom=function(e){this._scene.getNavigationInfo()._impl.zoom(this,e)},x3dom.Viewarea.prototype.getLights=function(){for(var e=[],t=0;t0&&e[t]._vf.on)return!0;return!1},x3dom.Viewarea.prototype.hasPhysicalEnvironmentLight=function(){for(var e=0;e0){var o=this._scene.getVolume();if(o.isValid()){var s=x3dom.fields.SFVec3f.MAX(),r=x3dom.fields.SFVec3f.MIN();o.getBounds(s,r);var n=[],a=this._scene.getViewpoint().getFieldOfView(),d=r.subtract(s),l=d.y/2/Math.tan(a/2)+d.z/2,h=d.x/2/Math.tan(a/2)+d.z/2;for(d=s.add(d.multiply(.5)),t=0;th?l:h)))}n.push(f.getViewMatrix(d))}return n}}return Array(i||1).fill(this.getViewMatrix())},x3dom.Viewarea.prototype.getWCtoLCMatrix=function(e){var t,i=this.getProjectionMatrix();return t=0===arguments.length?this.getLightMatrix()[0]:e,i.mult(t)},x3dom.Viewarea.prototype.getWCtoLCMatricesPointLight=function(e,t,i){var o=t._vf.zNear,s=t._vf.zFar,r=this.getLightProjectionMatrix(e,o,s,!1,i);r._00=1,r._11=1;var n,a=[];a[0]=r.mult(e);for(var d=1;d<=3;d++)n=x3dom.fields.SFMatrix4f.rotationY(d*Math.PI/2),a[d]=r.mult(n.mult(e));return n=x3dom.fields.SFMatrix4f.rotationX(Math.PI/2),a[4]=r.mult(n.mult(e)),n=x3dom.fields.SFMatrix4f.rotationX(3*Math.PI/2),a[5]=r.mult(n.mult(e)),a},x3dom.Viewarea.prototype.getWCtoLCMatricesCascaded=function(e,t,i){var o=Math.max(1,Math.min(t._vf.shadowCascades,6)),s=Math.max(0,Math.min(t._vf.shadowSplitFactor,1)),r=Math.max(0,Math.min(t._vf.shadowSplitOffset,1)),n=x3dom.isa(t,x3dom.nodeTypes.SpotLight),a=t._vf.zNear,d=t._vf.zFar,l=this.getLightProjectionMatrix(e,a,d,!0,i);n&&(l._00=1,l._11=1);var h=l.mult(e),f=[];if(1==o)return f[0]=h,f;for(var u=this.getShadowSplitDepths(o,s,r,!0,i),c=0;c0||i>0){var n,a,d=e.inverse().e3(),l=x3dom.fields.SFVec3f.copy(this._scene._lastMin),h=x3dom.fields.SFVec3f.copy(this._scene._lastMax).subtract(l),f=h.length()/2,u=l.add(h.multiply(.5)),c=d.subtract(u).length();return f&&(n=c>f?.8*(c-f):1,a=1.2*(c+f)),t>0&&(n=t),i>0&&(a=i),r._22=-(a+n)/(a-n),r._23=-2*a*n/(a-n),r}return this.getLightCropMatrix(r.mult(e)).mult(r)},x3dom.Viewarea.prototype.getProjectionMatrix=function(){return this.vrFrameData?this.vrLeftProjMatrix:this._scene.getViewpoint().getProjectionMatrix(this._width/this._height)},x3dom.Viewarea.prototype.getProjectionMatrices=function(){if(this.vrFrameData)return[this.vrLeftProjMatrix,this.vrRightProjMatrix];var e=this._scene.getViewpoint().getProjectionMatrix(this._width/this._height);return[e,e]},x3dom.Viewarea.prototype.getViewfrustum=function(e){var t=this._scene.getEnvironment();if(1==t._vf.frustumCulling){if(0==arguments.length){var i=this.getProjectionMatrix(),o=this.getViewMatrix();return new x3dom.fields.FrustumVolume(i.mult(o))}return new x3dom.fields.FrustumVolume(e)}return null},x3dom.Viewarea.prototype.getWCtoCCMatrix=function(){var e=this.getViewMatrix();return this.getProjectionMatrix().mult(e)},x3dom.Viewarea.prototype.getCCtoWCMatrix=function(){return this.getWCtoCCMatrix().inverse()},x3dom.Viewarea.prototype.calcViewRay=function(e,t,i){var o=i||this.getCCtoWCMatrix(),s=e/(this._width-1)*2-1,r=(this._height-1-t)/(this._height-1)*2-1,n=o.multFullMatrixPnt(new x3dom.fields.SFVec3f(s,r,-1)),a=o.multFullMatrixPnt(new x3dom.fields.SFVec3f(s,r,1)).subtract(n);return new x3dom.fields.Ray(n,a)},x3dom.Viewarea.prototype.showAll=function(e,t){void 0===e&&(e=\"negZ\"),void 0===t&&(t=!1);var i=this._scene;i.updateVolume();var o,s=x3dom.fields.SFVec3f.copy(i._lastMin),r=x3dom.fields.SFVec3f.copy(i._lastMax),n=\"x\",a=\"y\",d=\"z\",l=1,h=new x3dom.fields.SFVec3f(0,0,-1);switch(e){case\"posX\":l=-1;case\"negX\":d=\"x\",n=\"y\",a=\"z\",o=new x3dom.fields.SFVec3f(l,0,0);break;case\"posY\":l=-1;case\"negY\":d=\"y\",n=\"z\",a=\"x\",o=new x3dom.fields.SFVec3f(0,l,0);break;case\"posZ\":l=-1;case\"negZ\":default:o=new x3dom.fields.SFVec3f(0,0,-l)}var f=i.getViewpoint(),u=f.getFieldOfView(),c=x3dom.isa(f,x3dom.nodeTypes.OrthoViewpoint),_=r.subtract(s),m=_.multiply(.5),p=s.add(m);t&&f.setCenterOfRotation(p);var x=Math.min(this._width/this._height,1),g=_[d]/2,v=Math.tan(u/2),y=_[a]/2/v+g,T=_[n]/2/v+g;(_=s.add(_.multiply(.5)))[d]+=c?l*(y>T?y:T)*3.01:l*(y>T?y:T)*1.01,_[d]/=x;var b=x3dom.fields.Quaternion.rotateFromTo(h,o).toMatrix();b=b.mult(x3dom.fields.SFMatrix4f.translation(_.negate())),c?(this.orthoAnimateTo(y,Math.abs(f._fieldOfView[0])),this.animateTo(b,f)):this.animateTo(b,f)},x3dom.Viewarea.prototype.fit=function(e,t,i){var o=this._scene.getViewpoint(),s=this.getFitViewMatrix(e,t,o,i);x3dom.isa(o,x3dom.nodeTypes.OrthoViewpoint)?(this.orthoAnimateTo(dist/2.01,Math.abs(o._fieldOfView[0])),this.animateTo(s,o)):this.animateTo(s,o)},x3dom.Viewarea.prototype.getFitViewMatrix=function(e,t,i,o){void 0===o&&(o=!0);var s=t.subtract(e).multiply(.5),r=e.add(s),n=s.length(),a=i.getFieldOfView(),d=x3dom.fields.SFMatrix4f.copy(this.getViewMatrix()),l=new x3dom.fields.SFVec3f(d._00,d._01,d._02),h=new x3dom.fields.SFVec3f(d._10,d._11,d._12),f=new x3dom.fields.SFVec3f(d._20,d._21,d._22),u=Math.min(this._width/this._height,1),c=n/Math.tan(a/2)/u,_=r.add(f.multiply(c));return d._03=-l.dot(_),d._13=-h.dot(_),d._23=-f.dot(_),o&&i.setCenterOfRotation(r),d},x3dom.Viewarea.prototype.resetView=function(){this._scene.getNavigationInfo()._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=!0},x3dom.Viewarea.prototype.uprightView=function(){var e=this.getViewMatrix().inverse(),t=e.e3(),i=t.subtract(e.e2()),o=new x3dom.fields.SFVec3f(0,1,0),s=e.e2().cross(o).normalize().cross(o).normalize();i=t.add(s),e=(e=x3dom.fields.SFMatrix4f.lookAt(t,i,o)).inverse(),this.animateTo(e,this._scene.getViewpoint())},x3dom.Viewarea.prototype.callEvtHandler=function(e,t,i){if(!e||!e._xmlNode)return null;try{var o=e._xmlNode,s=o[t];if(\"function\"==typeof s)s.call(o,i);else if(o.hasAttribute(t)){var r=o.getAttribute(t);new Function(\"event\",r).call(o,i)}var n=e._listeners[i.type];if(n)for(var a=0;a0&&void 0!==i)for(t=0;t=0)&&\"lookat\"===d&&this._pressX===e&&this._pressY===t){var g=2&this._lastButton?-1:1,v=this._pickingInfo.pickPos.subtract(this._from).length()/3,y=new x3dom.fields.SFMatrix4f;y.setValues(this.getViewMatrix());var T=(y=y.inverse()).e3(),b=(T.subtract(y.e2()),y.e1()),S=(r=this._pickingInfo.pickPos.subtract(T)).length();r=r.normalize();var F=T.addScaled(r,S),E=r.cross(b).normalize();r=E.cross(b).normalize(),g<0&&(v=2*(.5+S+v));var M=F.addScaled(r,v);y=(y=x3dom.fields.SFMatrix4f.lookAt(M,F,b)).inverse(),v=M.subtract(T).length();var C=Math.max(.5,Math.log((1+v)/a._vf.speed));this.animateTo(y,this._scene.getViewpoint(),C)}this._dx=0,this._dy=0,this._lastX=e,this._lastY=t,this._lastButton=i,this._isMoving=!1},x3dom.Viewarea.prototype.onMouseOver=function(e,t,i){this._dx=0,this._dy=0,this._lastButton=0,this._isMoving=!1,this._lastX=e,this._lastY=t,this._deltaT=0},x3dom.Viewarea.prototype.onMouseOut=function(e,t,i){var o;this._dx=0,this._dy=0,this._lastButton=0,this._isMoving=!1,this._lastX=e,this._lastY=t,this._deltaT=0;var s=this._doc._nodeBag.affectedPointingSensors;for(o=0;o0?this._currentInputType=x3dom.InputTypes.INTERACTION:this._currentInputType=x3dom.InputTypes.NAVIGATION},x3dom.Viewarea.prototype.getRenderMode=function(){return this._points},x3dom.Viewarea.prototype.getShadowedLights=function(){for(var e=[],t=0,i=this.getLights(),o=0;o0&&(e[t]=i[o],t++);return e},x3dom.Viewarea.prototype.getShadowSplitDepths=function(e,t,i,o,s){var r,n=[],a=this._scene.getViewpoint(),d=a.getNear(),l=a.getFar();n[0]=d,d+=i*(l-d)/10;for(var h=1;h1||r<-1?(i=-1,r=1):(i=Math.max(i,-1),r=Math.min(r,1)),o>1||n<-1?(o=-1,n=1):(o=Math.max(o,-1),n=Math.min(n,1)),s>1||a<-1?(s=-1,a=1):(s=Math.max(s,-1),a=Math.min(a,1));var d=new x3dom.fields.SFVec3f(i,o,s),l=new x3dom.fields.SFVec3f(r,n,a);return new x3dom.fields.BoxVolume(d,l)}(d,l),f=2/(h.max.x-h.min.x),u=2/(h.max.y-h.min.y),c=-f*(h.max.x+h.min.x)/2,_=-u*(h.max.y+h.min.y)/2,m=x3dom.fields.SFMatrix4f.identity();return m._00=f,m._11=u,m._03=c,m._13=_,m},x3dom.fields={};var VecMath=x3dom.fields;function _colorParse(e){var t=0,i=0,o=0,s=1,r={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\"},n=/^rgb\\((\\d{1,3}),\\s{0,1}(\\d{1,3}),\\s{0,1}(\\d{1,3})\\)$/.exec(e);null!==n&&(t=n[1]/255,i=n[2]/255,o=n[3]/255);var a=/^rgba\\((\\d{1,3}),\\s{0,1}(\\d{1,3}),\\s{0,1}(\\d{1,3}),(0+\\.?\\d*|1\\.?0*)\\)$/.exec(e);if(null!==a&&(t=a[1]/255,i=a[2]/255,o=a[3]/255,s=+a[4]),r[e]&&(e=r[e]),e.substr&&\"#\"===e.substr(0,1)){var d=e.substr(1),l=d.length;8===l?(t=parseInt(\"0x\"+d.substr(0,2),16)/255,i=parseInt(\"0x\"+d.substr(2,2),16)/255,o=parseInt(\"0x\"+d.substr(4,2),16)/255,s=parseInt(\"0x\"+d.substr(6,2),16)/255):6===l?(t=parseInt(\"0x\"+d.substr(0,2),16)/255,i=parseInt(\"0x\"+d.substr(2,2),16)/255,o=parseInt(\"0x\"+d.substr(4,2),16)/255):4===l?(t=parseInt(\"0x\"+d.substr(0,1),16)/15,i=parseInt(\"0x\"+d.substr(1,1),16)/15,o=parseInt(\"0x\"+d.substr(2,1),16)/15,s=parseInt(\"0x\"+d.substr(3,1),16)/15):3===l&&(t=parseInt(\"0x\"+d.substr(0,1),16)/15,i=parseInt(\"0x\"+d.substr(1,1),16)/15,o=parseInt(\"0x\"+d.substr(2,1),16)/15)}return{r:t,g:i,b:o,a:s}}function startDashVideo(e,t){var i,o,s,r=function(){var e={};window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi,(function(t,i,o){e[i]=o}));return e},n=e;r&&r.hasOwnProperty(\"url\")&&(n=r.url),i=document.querySelector(t),o=new Dash.di.DashContext,(s=new MediaPlayer(o)).startup(),s.attachView(i),s.setAutoPlay(!1),s.attachSource(n)}function setNamespace(e,t,i){t instanceof Element&&void 0!==t.__setAttribute&&(t.hasAttribute(\"id\")?t.__setAttribute(\"id\",e.toString().replace(\" \",\"\")+\"__\"+t.getAttribute(\"id\")):t.hasAttribute(\"DEF\")&&i&&(t.__setAttribute(\"id\",e.toString().replace(\" \",\"\")+\"__\"+t.getAttribute(\"DEF\")),t.id||(t.id=t.__getAttribute(\"id\")))),t.hasChildNodes()&&t.childNodes.forEach((function(t){setNamespace(e,t,i)}))}x3dom.fields.Eps=1e-6,x3dom.fields.SFMatrix4f=function(e,t,i,o,s,r,n,a,d,l,h,f,u,c,_,m){0===arguments.length?(this._00=1,this._01=0,this._02=0,this._03=0,this._10=0,this._11=1,this._12=0,this._13=0,this._20=0,this._21=0,this._22=1,this._23=0,this._30=0,this._31=0,this._32=0,this._33=1):(this._00=e,this._01=t,this._02=i,this._03=o,this._10=s,this._11=r,this._12=n,this._13=a,this._20=d,this._21=l,this._22=h,this._23=f,this._30=u,this._31=c,this._32=_,this._33=m)},x3dom.fields.SFMatrix4f.prototype.e0=function(){return new x3dom.fields.SFVec3f(this._00,this._10,this._20).normalize()},x3dom.fields.SFMatrix4f.prototype.e1=function(){return new x3dom.fields.SFVec3f(this._01,this._11,this._21).normalize()},x3dom.fields.SFMatrix4f.prototype.e2=function(){return new x3dom.fields.SFVec3f(this._02,this._12,this._22).normalize()},x3dom.fields.SFMatrix4f.prototype.e3=function(){return new x3dom.fields.SFVec3f(this._03,this._13,this._23)},x3dom.fields.SFMatrix4f.copy=function(e){return new x3dom.fields.SFMatrix4f(e._00,e._01,e._02,e._03,e._10,e._11,e._12,e._13,e._20,e._21,e._22,e._23,e._30,e._31,e._32,e._33)},x3dom.fields.SFMatrix4f.prototype.copy=function(){return x3dom.fields.SFMatrix4f.copy(this)},x3dom.fields.SFMatrix4f.identity=function(){return new x3dom.fields.SFMatrix4f(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)},x3dom.fields.SFMatrix4f.zeroMatrix=function(){return new x3dom.fields.SFMatrix4f(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)},x3dom.fields.SFMatrix4f.translation=function(e){return new x3dom.fields.SFMatrix4f(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1)},x3dom.fields.SFMatrix4f.rotationX=function(e){var t=Math.cos(e),i=Math.sin(e);return new x3dom.fields.SFMatrix4f(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1)},x3dom.fields.SFMatrix4f.rotationY=function(e){var t=Math.cos(e),i=Math.sin(e);return new x3dom.fields.SFMatrix4f(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1)},x3dom.fields.SFMatrix4f.rotationZ=function(e){var t=Math.cos(e),i=Math.sin(e);return new x3dom.fields.SFMatrix4f(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1)},x3dom.fields.SFMatrix4f.scale=function(e){return new x3dom.fields.SFMatrix4f(e.x,0,0,0,0,e.y,0,0,0,0,e.z,0,0,0,0,1)},x3dom.fields.SFMatrix4f.lookAt=function(e,t,i){var o=e.subtract(t).normalize(),s=i.normalize().cross(o).normalize();if(s.dot(s)=16?t?new x3dom.fields.SFMatrix4f(i[0],i[4],i[8],i[12],i[1],i[5],i[9],i[13],i[2],i[6],i[10],i[14],i[3],i[7],i[11],i[15]):new x3dom.fields.SFMatrix4f(i[0],i[1],i[2],i[3],i[4],i[5],i[6],i[7],i[8],i[9],i[10],i[11],i[12],i[13],i[14],i[15]):6===i.length?new x3dom.fields.SFMatrix4f(i[0],i[1],0,i[4],i[2],i[3],0,i[5],0,0,1,0,0,0,0,1):(x3dom.debug.logWarning(\"SFMatrix4f - can't parse string: \"+e),x3dom.fields.SFMatrix4f.identity())},x3dom.fields.SFMatrix4f.prototype.mult=function(e){return new x3dom.fields.SFMatrix4f(this._00*e._00+this._01*e._10+this._02*e._20+this._03*e._30,this._00*e._01+this._01*e._11+this._02*e._21+this._03*e._31,this._00*e._02+this._01*e._12+this._02*e._22+this._03*e._32,this._00*e._03+this._01*e._13+this._02*e._23+this._03*e._33,this._10*e._00+this._11*e._10+this._12*e._20+this._13*e._30,this._10*e._01+this._11*e._11+this._12*e._21+this._13*e._31,this._10*e._02+this._11*e._12+this._12*e._22+this._13*e._32,this._10*e._03+this._11*e._13+this._12*e._23+this._13*e._33,this._20*e._00+this._21*e._10+this._22*e._20+this._23*e._30,this._20*e._01+this._21*e._11+this._22*e._21+this._23*e._31,this._20*e._02+this._21*e._12+this._22*e._22+this._23*e._32,this._20*e._03+this._21*e._13+this._22*e._23+this._23*e._33,this._30*e._00+this._31*e._10+this._32*e._20+this._33*e._30,this._30*e._01+this._31*e._11+this._32*e._21+this._33*e._31,this._30*e._02+this._31*e._12+this._32*e._22+this._33*e._32,this._30*e._03+this._31*e._13+this._32*e._23+this._33*e._33)},x3dom.fields.SFMatrix4f.prototype.multMatrixPnt=function(e){return new x3dom.fields.SFVec3f(this._00*e.x+this._01*e.y+this._02*e.z+this._03,this._10*e.x+this._11*e.y+this._12*e.z+this._13,this._20*e.x+this._21*e.y+this._22*e.z+this._23)},x3dom.fields.SFMatrix4f.prototype.multMatrixVec=function(e){return new x3dom.fields.SFVec3f(this._00*e.x+this._01*e.y+this._02*e.z,this._10*e.x+this._11*e.y+this._12*e.z,this._20*e.x+this._21*e.y+this._22*e.z)},x3dom.fields.SFMatrix4f.prototype.multFullMatrixPnt=function(e){var t=this._30*e.x+this._31*e.y+this._32*e.z+this._33;return t&&(t=1/t),new x3dom.fields.SFVec3f((this._00*e.x+this._01*e.y+this._02*e.z+this._03)*t,(this._10*e.x+this._11*e.y+this._12*e.z+this._13)*t,(this._20*e.x+this._21*e.y+this._22*e.z+this._23)*t)},x3dom.fields.SFMatrix4f.prototype.multMatrixPlane=function(e){var t=new x3dom.fields.SFVec3f(e.x,e.y,e.z),i=t.multiply(-e.w);i=this.multMatrixPnt(i);var o=-(t=this.inverse().transpose().multMatrixVec(t)).dot(i);return new x3dom.fields.SFVec4f(t.x,t.y,t.z,o)},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(e){return new x3dom.fields.SFMatrix4f(e*this._00,e*this._01,e*this._02,e*this._03,e*this._10,e*this._11,e*this._12,e*this._13,e*this._20,e*this._21,e*this._22,e*this._23,e*this._30,e*this._31,e*this._32,e*this._33)},x3dom.fields.SFMatrix4f.prototype.add=function(e){return new x3dom.fields.SFMatrix4f(this._00+e._00,this._01+e._01,this._02+e._02,this._03+e._03,this._10+e._10,this._11+e._11,this._12+e._12,this._13+e._13,this._20+e._20,this._21+e._21,this._22+e._22,this._23+e._23,this._30+e._30,this._31+e._31,this._32+e._32,this._33+e._33)},x3dom.fields.SFMatrix4f.prototype.addScaled=function(e,t){return new x3dom.fields.SFMatrix4f(this._00+t*e._00,this._01+t*e._01,this._02+t*e._02,this._03+t*e._03,this._10+t*e._10,this._11+t*e._11,this._12+t*e._12,this._13+t*e._13,this._20+t*e._20,this._21+t*e._21,this._22+t*e._22,this._23+t*e._23,this._30+t*e._30,this._31+t*e._31,this._32+t*e._32,this._33+t*e._33)},x3dom.fields.SFMatrix4f.prototype.setValues=function(e){this._00=e._00,this._01=e._01,this._02=e._02,this._03=e._03,this._10=e._10,this._11=e._11,this._12=e._12,this._13=e._13,this._20=e._20,this._21=e._21,this._22=e._22,this._23=e._23,this._30=e._30,this._31=e._31,this._32=e._32,this._33=e._33},x3dom.fields.SFMatrix4f.prototype.setValue=function(e,t,i,o){this._00=e.x,this._01=t.x,this._02=i.x,this._10=e.y,this._11=t.y,this._12=i.y,this._20=e.z,this._21=t.z,this._22=i.z,this._30=0,this._31=0,this._32=0,arguments.length>3&&(this._03=o.x,this._13=o.y,this._23=o.z,this._33=1)},x3dom.fields.SFMatrix4f.prototype.setFromArray=function(e){return this._00=e[0],this._01=e[4],this._02=e[8],this._03=e[12],this._10=e[1],this._11=e[5],this._12=e[9],this._13=e[13],this._20=e[2],this._21=e[6],this._22=e[10],this._23=e[14],this._30=e[3],this._31=e[7],this._32=e[11],this._33=e[15],this},x3dom.fields.SFMatrix4f.fromArray=function(e){var t=new x3dom.fields.SFMatrix4f;return t._00=e[0],t._01=e[4],t._02=e[8],t._03=e[12],t._10=e[1],t._11=e[5],t._12=e[9],t._13=e[13],t._20=e[2],t._21=e[6],t._22=e[10],t._23=e[14],t._30=e[3],t._31=e[7],t._32=e[11],t._33=e[15],t},x3dom.fields.SFMatrix4f.prototype.fromRotationTranslationScale=function(e,t,i){t=t||new x3dom.fields.SFVec3f,e=e||new x3dom.fields.Quaternion,i=i||new x3dom.fields.SFVec3f(1,1,1);var o=e.x,s=e.y,r=e.z,n=e.w,a=o+o,d=s+s,l=r+r,h=o*a,f=o*d,u=o*l,c=s*d,_=s*l,m=r*l,p=n*a,x=n*d,g=n*l;return this._00=(1-(c+m))*i.x,this._10=(f+g)*i.x,this._20=(u-x)*i.x,this._30=0,this._01=(f-g)*i.y,this._11=(1-(h+m))*i.y,this._21=(_+p)*i.y,this._31=0,this._02=(u+x)*i.z,this._12=(_-p)*i.z,this._22=(1-(h+c))*i.z,this._32=0,this._03=t.x,this._13=t.y,this._23=t.z,this._33=1,this},x3dom.fields.SFMatrix4f.fromRotationTranslationScale=function(e,t,i){t=t||new x3dom.fields.SFVec3f,e=e||new x3dom.fields.Quaternion,i=i||new x3dom.fields.SFVec3f(1,1,1);var o=new x3dom.fields.SFMatrix4f,s=e.x,r=e.y,n=e.z,a=e.w,d=s+s,l=r+r,h=n+n,f=s*d,u=s*l,c=s*h,_=r*l,m=r*h,p=n*h,x=a*d,g=a*l,v=a*h;return o._00=(1-(_+p))*i.x,o._10=(u+v)*i.x,o._20=(c-g)*i.x,o._30=0,o._01=(u-v)*i.y,o._11=(1-(f+p))*i.y,o._21=(m+x)*i.y,o._31=0,o._02=(c+g)*i.z,o._12=(m-x)*i.z,o._22=(1-(f+_))*i.z,o._32=0,o._03=t.x,o._13=t.y,o._23=t.z,o._33=1,o},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.fromGL=function(e){var t=new x3dom.fields.SFMatrix4f;return t._00=e[0],t._01=e[4],t._02=e[8],t._03=e[12],t._10=e[1],t._11=e[5],t._12=e[9],t._13=e[13],t._20=e[2],t._21=e[6],t._22=e[10],t._23=e[14],t._30=e[3],t._31=e[7],t._32=e[11],t._33=e[15],t},x3dom.fields.SFMatrix4f.prototype.at=function(e,t){return this[\"_\"+e+t]},x3dom.fields.SFMatrix4f.prototype.setAt=function(e,t,i){return this[\"_\"+e+t]=i,this},x3dom.fields.SFMatrix4f.prototype.sqrt=function(){for(var e=x3dom.fields.SFMatrix4f.identity(),t=x3dom.fields.SFMatrix4f.copy(this),i=0;i<6;i++){var o=t.inverse(),s=0==i?x3dom.fields.SFMatrix4f.identity():e.inverse(),r=t.det(),n=e.det(),a=Math.abs(Math.pow(r*n,-.125)),d=1/a;t=(t=(t=t.multiply(a)).addScaled(s,d)).multiply(.5),e=(e=(e=e.multiply(a)).addScaled(o,d)).multiply(.5)}return t},x3dom.fields.SFMatrix4f.prototype.normInfinity=function(){var e=0,t=0;return(e=Math.abs(this._00))>t&&(t=e),(e=Math.abs(this._01))>t&&(t=e),(e=Math.abs(this._02))>t&&(t=e),(e=Math.abs(this._03))>t&&(t=e),(e=Math.abs(this._10))>t&&(t=e),(e=Math.abs(this._11))>t&&(t=e),(e=Math.abs(this._12))>t&&(t=e),(e=Math.abs(this._13))>t&&(t=e),(e=Math.abs(this._20))>t&&(t=e),(e=Math.abs(this._21))>t&&(t=e),(e=Math.abs(this._22))>t&&(t=e),(e=Math.abs(this._23))>t&&(t=e),(e=Math.abs(this._30))>t&&(t=e),(e=Math.abs(this._31))>t&&(t=e),(e=Math.abs(this._32))>t&&(t=e),(e=Math.abs(this._33))>t&&(t=e),t},x3dom.fields.SFMatrix4f.prototype.norm1_3x3=function(){var e=Math.abs(this._00)+Math.abs(this._10)+Math.abs(this._20),t=0;return(t=Math.abs(this._01)+Math.abs(this._11)+Math.abs(this._21))>e&&(e=t),(t=Math.abs(this._02)+Math.abs(this._12)+Math.abs(this._22))>e&&(e=t),e},x3dom.fields.SFMatrix4f.prototype.normInf_3x3=function(){var e=Math.abs(this._00)+Math.abs(this._01)+Math.abs(this._02),t=0;return(t=Math.abs(this._10)+Math.abs(this._11)+Math.abs(this._12))>e&&(e=t),(t=Math.abs(this._20)+Math.abs(this._21)+Math.abs(this._22))>e&&(e=t),e},x3dom.fields.SFMatrix4f.prototype.adjointT_3x3=function(){var e=x3dom.fields.SFMatrix4f.identity();return e._00=this._11*this._22-this._12*this._21,e._01=this._12*this._20-this._10*this._22,e._02=this._10*this._21-this._11*this._20,e._10=this._21*this._02-this._22*this._01,e._11=this._22*this._00-this._20*this._02,e._12=this._20*this._01-this._21*this._00,e._20=this._01*this._12-this._02*this._11,e._21=this._02*this._10-this._00*this._12,e._22=this._00*this._11-this._01*this._10,e},x3dom.fields.SFMatrix4f.prototype.equals=function(e){var t=1e-12;return Math.abs(this._00-e._00)4){r=(r=x3dom.fields.SFMatrix4f.translation(s.negate())).mult(this);var n=x3dom.fields.SFMatrix4f.translation(s);r=r.mult(n)}else r=x3dom.fields.SFMatrix4f.copy(this);var a=r.decompose(e,t,i,o);i.setValues(i.multiply(a))},x3dom.fields.SFMatrix4f.prototype.decompose=function(e,t,i,o){var s=x3dom.fields.SFMatrix4f.copy(this),r=x3dom.fields.SFMatrix4f.identity(),n=x3dom.fields.SFMatrix4f.identity(),a=x3dom.fields.SFMatrix4f.identity();e.x=s._03,e.y=s._13,e.z=s._23,s._03=0,s._13=0,s._23=0,s._30=0,s._31=0,s._32=0;var d=1;return s.polarDecompose(r,n)<0&&(r=r.negate(),d=-1),t.setValue(r),n.spectralDecompose(a,i),o.setValue(a),d},x3dom.fields.SFMatrix4f.prototype.polarDecompose=function(e,t){var i,o,s,r,n,a=this.transpose(),d=x3dom.fields.SFMatrix4f.identity(),l=a.norm1_3x3(),h=a.normInf_3x3();do{if(i=a.adjointT_3x3(),0==(n=a._00*i._00+a._01*i._01+a._02*i._02)){x3dom.debug.logWarning(\"polarDecompose: Mk_det == 0.0\");break}o=i.norm1_3x3(),s=i.normInf_3x3();var f=Math.sqrt(Math.sqrt(o*s/(l*h))/Math.abs(n)),u=.5*f,c=.5/(f*n);d.setValues(a),a=(a=a.multiply(u)).addScaled(i,c),r=(d=d.addScaled(a,-1)).norm1_3x3(),l=a.norm1_3x3(),h=a.normInf_3x3()}while(r>1e-12*l);e.setValues(a.transpose()),t.setValues(a.mult(this));for(var _=0;_<3;++_)for(var m=_;m<3;++m)t.setAt(m,_,.5*(t.at(m,_)+t.at(_,m))),t.setAt(_,m,.5*(t.at(m,_)+t.at(_,m)));return n},x3dom.fields.SFMatrix4f.prototype.spectralDecompose=function(e,t){for(var i=[1,2,0],o=[this._00,this._11,this._22],s=[this._12,this._20,this._01],r=0;r<20;++r){if(0==Math.abs(s[0])+Math.abs(s[1])+Math.abs(s[2]))break;for(var n=2;n>=0;--n){var a=i[n],d=i[a],l=Math.abs(s[n]),h=100*l;if(l>0){var f=0,u=o[d]-o[a],c=Math.abs(u);if(c+h==c)f=s[n]/u;else{var _=.5*u/s[n];f=1/(Math.abs(_)+Math.sqrt(_*_+1)),f=_<0?-f:f}var m=1/Math.sqrt(f*f+1),p=f*m,x=p/(m+1),g=f*s[n];s[n]=0,o[a]-=g,o[d]+=g;var v=s[d];s[d]-=p*(s[a]+x*v),s[a]+=p*(v-x*s[a]);for(var y=2;y>=0;--y){var T=e.at(y,a),b=e.at(y,d);e.setAt(y,a,e.at(y,a)-p*(b+x*T)),e.setAt(y,d,e.at(y,d)+p*(T-x*b))}}}}t.x=o[0],t.y=o[1],t.z=o[2]},x3dom.fields.SFMatrix4f.prototype.log=function(){var e=x3dom.fields.SFMatrix4f.copy(this),t=x3dom.fields.SFMatrix4f.copy(this);t._00-=1,t._11-=1,t._22-=1,t._33-=1;for(var i=0;t.normInfinity()>.5;)e=e.sqrt(),t.setValues(e),t._00-=1,t._11-=1,t._22-=1,t._33-=1,i++;e._00-=1,e._11-=1,e._22-=1,e._33-=1,e=e.negate(),t.setValues(e);for(var o=x3dom.fields.SFMatrix4f.copy(e),s=1;t.normInfinity()>1e-12&&s<12;)t=t.mult(e),s++,o=o.addScaled(t,1/s);return o.multiply(-(1<1e-4?(e=-Math.asin(this._20),t=Math.PI-e,n=Math.cos(e),a=Math.cos(t),o=Math.atan2(this._21/n,this._22/n),s=Math.atan2(this._21/a,this._22/a),[o,e,Math.atan2(this._10/n,this._00/n),s,t,Math.atan2(this._10/a,this._00/a)]):(0,-1==this._20?(i=Math.PI/2,r=0+Math.atan2(this._01,this._02)):(i=-Math.PI/2,r=-0+Math.atan2(-this._01,-this._02)),[r,i,0,r,i,0])},x3dom.fields.SFMatrix4f.prototype.toString=function(){return this._00.toFixed(6)+\" \"+this._10.toFixed(6)+\" \"+this._20.toFixed(6)+\" \"+this._30.toFixed(6)+\" \"+this._01.toFixed(6)+\" \"+this._11.toFixed(6)+\" \"+this._21.toFixed(6)+\" \"+this._31.toFixed(6)+\" \"+this._02.toFixed(6)+\" \"+this._12.toFixed(6)+\" \"+this._22.toFixed(6)+\" \"+this._32.toFixed(6)+\" \"+this._03.toFixed(6)+\" \"+this._13.toFixed(6)+\" \"+this._23.toFixed(6)+\" \"+this._33.toFixed(6)},x3dom.fields.SFMatrix4f.prototype.setValueByStr=function(e){var t=!1;/matrix.*\\((.+)\\)/.exec(e)&&(e=RegExp.$1,t=!0);var i=e.split(/[,\\s]+/).map((function(e){return+e}));return i.length>=16?t?(this._00=i[0],this._01=i[4],this._02=i[8],this._03=i[12],this._10=i[1],this._11=i[5],this._12=i[9],this._13=i[13],this._20=i[2],this._21=i[6],this._22=i[10],this._23=i[14],this._30=i[3],this._31=i[7],this._32=i[11],this._33=i[15]):(this._00=i[0],this._01=i[1],this._02=i[2],this._03=i[3],this._10=i[4],this._11=i[5],this._12=i[6],this._13=i[7],this._20=i[8],this._21=i[9],this._22=i[10],this._23=i[11],this._30=i[12],this._31=i[13],this._32=i[14],this._33=i[15]):6===i.length?(this._00=i[0],this._01=i[1],this._02=0,this._03=i[4],this._10=i[2],this._11=i[3],this._12=0,this._13=i[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):x3dom.debug.logWarning(\"SFMatrix4f - can't parse string: \"+e),this},x3dom.fields.SFVec2f=function(e,t){0===arguments.length?(this.x=0,this.y=0):(this.x=e,this.y=t)},x3dom.fields.SFVec2f.copy=function(e){return new x3dom.fields.SFVec2f(e.x,e.y)},x3dom.fields.SFVec2f.parse=function(e){var t=/^\\s*([+\\-]?\\d*\\.*\\d*[eE]?[+\\-]?\\d*?)\\s*,?\\s*([+\\-]?\\d*\\.*\\d*[eE]?[+\\-]?\\d*?)\\s*$/.exec(e);return null===t?new x3dom.fields.SFVec2f:new x3dom.fields.SFVec2f(+t[1],+t[2])},x3dom.fields.SFVec2f.prototype.copy=function(){return x3dom.fields.SFVec2f.copy(this)},x3dom.fields.SFVec2f.prototype.setValues=function(e){return this.x=e.x,this.y=e.y,this},x3dom.fields.SFVec2f.prototype.at=function(e){switch(e){case 0:return this.x;case 1:return this.y;default:return this.x}},x3dom.fields.SFVec2f.prototype.add=function(e){return new x3dom.fields.SFVec2f(this.x+e.x,this.y+e.y)},x3dom.fields.SFVec2f.prototype.subtract=function(e){return new x3dom.fields.SFVec2f(this.x-e.x,this.y-e.y)},x3dom.fields.SFVec2f.prototype.negate=function(){return new x3dom.fields.SFVec2f(-this.x,-this.y)},x3dom.fields.SFVec2f.prototype.dot=function(e){return this.x*e.x+this.y*e.y},x3dom.fields.SFVec2f.prototype.reflect=function(e){var t=2*this.dot(e);return new x3dom.fields.SFVec2f(this.x-t*e.x,this.y-t*e.y)},x3dom.fields.SFVec2f.prototype.normalize=function(){var e=this.length();return e&&(e=1/e),new x3dom.fields.SFVec2f(this.x*e,this.y*e)},x3dom.fields.SFVec2f.prototype.multComponents=function(e){return new x3dom.fields.SFVec2f(this.x*e.x,this.y*e.y)},x3dom.fields.SFVec2f.prototype.multiply=function(e){return new x3dom.fields.SFVec2f(this.x*e,this.y*e)},x3dom.fields.SFVec2f.prototype.divideComponents=function(e){return new x3dom.fields.SFVec2f(this.x/e.x,this.y/e.y)},x3dom.fields.SFVec2f.prototype.divide=function(e){var t=e?1/e:1;return new x3dom.fields.SFVec2f(this.x*t,this.y*t)},x3dom.fields.SFVec2f.prototype.equals=function(e,t){return Math.abs(this.x-e.x)x3dom.fields.Eps){var o=Math.sin(t/2)/i,s=Math.cos(t/2);return new x3dom.fields.Quaternion(e.x*o,e.y*o,e.z*o,s)}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 e=this.x*this.x,t=this.x*this.y,i=this.x*this.z,o=this.y*this.y,s=this.y*this.z,r=this.z*this.z,n=this.w*this.x,a=this.w*this.y,d=this.w*this.z;return new x3dom.fields.SFMatrix4f(1-2*(o+r),2*(t-d),2*(i+a),0,2*(t+d),1-2*(e+r),2*(s-n),0,2*(i-a),2*(s+n),1-2*(e+o),0,0,0,0,1)},x3dom.fields.Quaternion.prototype.toAxisAngle=function(){var e,t,i=0,o=0,s=0;return this.w>1&&this.normalize(),t=2*Math.acos(this.w),0==(e=Math.sqrt(1-this.w*this.w))?(i=this.x,o=this.y,s=this.z):(i=this.x/e,o=this.y/e,s=this.z/e),[new x3dom.fields.SFVec3f(i,o,s),t]},x3dom.fields.Quaternion.prototype.angle=function(){return 2*Math.acos(this.w)},x3dom.fields.Quaternion.prototype.setValue=function(e){var t,i=1,o=[0,0,0],s=0,r=0,n=0,a=[1,2,0];if((t=e._00+e._11+e._22)>0?(i=Math.sqrt(t+1),this.w=.5*i,i=.5/i,this.x=(e._21-e._12)*i,this.y=(e._02-e._20)*i,this.z=(e._10-e._01)*i):(s=e._11>e._00?1:0,e._22>e.at(s,s)&&(s=2),n=a[r=a[s]],i=Math.sqrt(e.at(s,s)-(e.at(r,r)+e.at(n,n))+1),o[s]=.5*i,i=.5/i,this.w=(e.at(n,r)-e.at(r,n))*i,o[r]=(e.at(r,s)+e.at(s,r))*i,o[n]=(e.at(n,s)+e.at(s,n))*i,this.x=o[0],this.y=o[1],this.z=o[2]),this.w>1||this.w<-1){var d=1+100*x3dom.fields.Eps;(this.w>d||this.w<-d)&&x3dom.debug.logInfo(\"MatToQuat: BUG: |quat[4]| (\"+this.w+\") >> 1.0 !\"),this.w>1?this.w=1:this.w=-1}},x3dom.fields.Quaternion.prototype.setFromEuler=function(e,t,i){var o=Math.sin(.5*e),s=Math.cos(.5*e),r=Math.sin(.5*t),n=Math.cos(.5*t),a=Math.sin(.5*i),d=Math.cos(.5*i);return this.x=o*n*d-s*r*a,this.y=s*r*d+o*n*a,this.z=s*n*a-o*r*d,this.w=s*n*d+o*r*a,this},x3dom.fields.Quaternion.prototype.dot=function(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w},x3dom.fields.Quaternion.prototype.add=function(e){return new x3dom.fields.Quaternion(this.x+e.x,this.y+e.y,this.z+e.z,this.w+e.w)},x3dom.fields.Quaternion.prototype.subtract=function(e){return new x3dom.fields.Quaternion(this.x-e.x,this.y-e.y,this.z-e.z,this.w-e.w)},x3dom.fields.Quaternion.prototype.setValues=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this},x3dom.fields.Quaternion.prototype.equals=function(e,t){return this.dot(e)>=1-t},x3dom.fields.Quaternion.prototype.multScalar=function(e){return new x3dom.fields.Quaternion(this.x*e,this.y*e,this.z*e,this.w*e)},x3dom.fields.Quaternion.prototype.normalize=function(){var e=this.dot(this),t=1;return e&&(t=1/Math.sqrt(e)),this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},x3dom.fields.Quaternion.normalize=function(e){var t=e.dot(e),i=1;return t&&(i=1/Math.sqrt(t)),e.x*=i,e.y*=i,e.z*=i,e.w*=i,e},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(){var e=new x3dom.fields.Quaternion(-this.x,-this.y,-this.z,this.w);if(\"SFRotation\"in this){var t=e.toAxisAngle();return new x3dom.fields.SFRotation(t[0].x,t[0].y,t[0].z,t[1])}return e},x3dom.fields.Quaternion.prototype.slerp=function(e,t){var i,o,s,r=this.dot(e);if(r<0?(r=-r,i=e.negate()):i=new x3dom.fields.Quaternion(e.x,e.y,e.z,e.w),1-r>1e-5){var n=Math.acos(r),a=Math.sin(n);o=Math.sin((1-t)*n)/a,s=Math.sin(t*n)/a}else o=1-t,s=t;var d=this.multScalar(o).add(i.multScalar(s));if(\"SFRotation\"in this){var l=d.toAxisAngle();return new x3dom.fields.SFRotation(l[0].x,l[0].y,l[0].z,l[1])}return d},x3dom.fields.Quaternion.rotateFromTo=function(e,t){var i=e.normalize(),o=t.normalize(),s=i.dot(o);if(s>.99999)return new x3dom.fields.Quaternion(0,0,0,1);if(s<-.99999){var r=new x3dom.fields.SFVec3f(1,0,0),n=i.cross(r);return n.length()<1e-5&&(r.x=0,r.y=1,r.z=0,n=i.cross(r)),n=n.normalize(),x3dom.fields.Quaternion.axisAngle(n,Math.PI)}var a=e.cross(t);a=a.normalize();var d=Math.sqrt(.5*(1-s));return a=a.multiply(d),d=Math.sqrt(.5*(1+s)),new x3dom.fields.Quaternion(a.x,a.y,a.z,d)},x3dom.fields.Quaternion.prototype.toGL=function(){var e=this.toAxisAngle();return[e[0].x,e[0].y,e[0].z,e[1]]},x3dom.fields.Quaternion.prototype.toString=function(){return\"SFRotation\"in this?this.SFRotation.x+\" \"+this.SFRotation.y+\" \"+this.SFRotation.z+\" \"+this.SFRotation.angle:this.x+\" \"+this.y+\" \"+this.z+\", \"+this.w},x3dom.fields.Quaternion.prototype.setValueByStr=function(e){var t=/^\\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(e);t=t||[0,1,0,0,0];var i=x3dom.fields.Quaternion.axisAngle(new x3dom.fields.SFVec3f(+t[1],+t[2],+t[3]),+t[4]);return this.x=i.x,this.y=i.y,this.z=i.z,this.w=i.w,this},x3dom.fields.SFColor=function(e,t,i){0===arguments.length?(this.r=0,this.g=0,this.b=0):(this.r=e,this.g=t,this.b=i)},x3dom.fields.SFColor.parse=function(e){try{var t=/^\\s*([+\\-]?\\d*\\.*\\d*[eE]?[+\\-]?\\d*?)\\s*,?\\s*([+\\-]?\\d*\\.*\\d*[eE]?[+\\-]?\\d*?)\\s*,?\\s*([+\\-]?\\d*\\.*\\d*[eE]?[+\\-]?\\d*?)\\s*$/.exec(e);return new x3dom.fields.SFColor(+t[1],+t[2],+t[3])}catch(t){return x3dom.fields.SFColor.colorParse(e)}},x3dom.fields.SFColor.copy=function(e){return new x3dom.fields.SFColor(e.r,e.g,e.b)},x3dom.fields.SFColor.prototype.copy=function(){return x3dom.fields.SFColor.copy(this)},x3dom.fields.SFColor.prototype.setHSV=function(e,t,i){var o,s,r,n,a,d=0,l=0,h=0;switch(r=i*(1-t),n=i*(1-t*(s=e/60-(o=Math.floor(e/60)))),a=i*(1-t*(1-s)),o){case 0:case 6:d=i,l=a,h=r;break;case 1:d=n,l=i,h=r;break;case 2:d=r,l=i,h=a;break;case 3:d=r,l=n,h=i;break;case 4:d=a,l=r,h=i;break;case 5:d=i,l=r,h=n;break;default:x3dom.debug.logWarning(\"Using black for invalid case in setHSV: \"+o)}return this.r=d,this.g=l,this.b=h,this},x3dom.fields.SFColor.prototype.getHSV=function(){var e,t=0,i={},o=this.r;if(i.name=\"red\",i.value=this.r,this.gi.value&&(i.name=\"green\",i.value=this.g),this.b>i.value&&(i.name=\"blue\",i.value=this.b),0==(e=i.value-o))t=0;else if(\"red\"==i.name)t=(this.g-this.b)/e%6*60;else if(\"green\"==i.name)t=60*((this.b-this.r)/e+2);else{if(\"blue\"!=i.name)throw\"Unknown maximum component: \"+i.name;t=60*((this.r-this.g)/e+4)}return t<0&&(t+=360),[t,0==i.value?0:e/i.value,i.value]},x3dom.fields.SFColor.prototype.setValues=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},x3dom.fields.SFColor.prototype.equals=function(e,t){return Math.abs(this.r-e.r)>>0},x3dom.fields.SFColor.prototype.setFromUint=function(e){return this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e>>0&255)/255,this},x3dom.fields.SFColor.prototype.toGL=function(){return[this.r,this.g,this.b]},x3dom.fields.SFColor.prototype.toString=function(){return this.r+\" \"+this.g+\" \"+this.b},x3dom.fields.SFColor.prototype.setValueByStr=function(e){try{var t=/^\\s*([+\\-]?\\d*\\.*\\d*[eE]?[+\\-]?\\d*?)\\s*,?\\s*([+\\-]?\\d*\\.*\\d*[eE]?[+\\-]?\\d*?)\\s*,?\\s*([+\\-]?\\d*\\.*\\d*[eE]?[+\\-]?\\d*?)\\s*$/.exec(e);this.r=+t[1],this.g=+t[2],this.b=+t[3]}catch(t){var i=x3dom.fields.SFColor.colorParse(e);this.r=i.r,this.g=i.g,this.b=i.b}return this},x3dom.fields.SFColor.colorParse=function(e){var t=_colorParse(e);return new x3dom.fields.SFColor(t.r,t.g,t.b)},x3dom.fields.SFColorRGBA=function(e,t,i,o){0===arguments.length?(this.r=0,this.g=0,this.b=0,this.a=1):(this.r=e,this.g=t,this.b=i,this.a=o)},x3dom.fields.SFColorRGBA.parse=function(e){try{var t=/^([+\\-]?\\d*\\.*\\d*[eE]?[+\\-]?\\d*?)\\s*,?\\s*([+\\-]?\\d*\\.*\\d*[eE]?[+\\-]?\\d*?)\\s*,?\\s*([+\\-]?\\d*\\.*\\d*[eE]?[+\\-]?\\d*?)\\s*,?\\s*([+\\-]?\\d*\\.*\\d*[eE]?[+\\-]?\\d*?)$/.exec(e);return new x3dom.fields.SFColorRGBA(+t[1],+t[2],+t[3],+t[4])}catch(t){return x3dom.fields.SFColorRGBA.colorParse(e)}},x3dom.fields.SFColorRGBA.copy=function(e){return new x3dom.fields.SFColorRGBA(e.r,e.g,e.b,e.a)},x3dom.fields.SFColorRGBA.prototype.copy=function(){return x3dom.fields.SFColorRGBA.copy(this)},x3dom.fields.SFColorRGBA.prototype.setHSV=x3dom.fields.SFColor.prototype.setHSV,x3dom.fields.SFColorRGBA.prototype.getHSV=x3dom.fields.SFColor.prototype.getHSV,x3dom.fields.SFColorRGBA.prototype.setValues=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this.a=e.a,this},x3dom.fields.SFColorRGBA.prototype.equals=function(e,t){return Math.abs(this.r-e.r)>>0},x3dom.fields.SFColorRGBA.prototype.setFromUint=function(e){return this.r=(e>>24&255)/255,this.g=(e>>16&255)/255,this.b=(e>>8&255)/255,this.a=(e>>0&255)/255,this},x3dom.fields.SFColorRGBA.colorParse=function(e){var t=_colorParse(e);return new x3dom.fields.SFColorRGBA(t.r,t.g,t.b,t.a)},x3dom.fields.SFImage=function(e,t,i,o){if(0!==arguments.length&&o&&o.map){this.width=e,this.height=t,this.comp=i;var s=this.array;o.map((function(e){s.push(e)}),this.array)}else this.width=0,this.height=0,this.comp=0,this.array=[]},x3dom.fields.SFImage.parse=function(e){var t=new x3dom.fields.SFImage;return t.setValueByStr(e),t},x3dom.fields.SFImage.copy=function(e){var t=new x3dom.fields.SFImage;return t.width=e.width,t.height=e.height,t.comp=e.comp,t.setPixels(e.getPixels()),t},x3dom.fields.SFImage.prototype.copy=function(){return x3dom.fields.SFImage.copy(this)},x3dom.fields.SFImage.prototype.setValueByStr=function(e){var t,i,o,s,r,n=e.match(/(\\w+)/g),a=n.length;if(this.array=[],!(a>2))return this.width=0,this.height=0,void(this.comp=0);this.width=+n[0],this.height=+n[1],this.comp=+n[2];var d=10;for(t=3;t>8&255,o=255&l,this.array.push(i,o)):3===this.comp?(i=l>>16&255,o=l>>8&255,s=255&l,this.array.push(i,o,s)):4===this.comp&&(i=l>>24&255,o=l>>16&255,s=l>>8&255,r=255&l,this.array.push(i,o,s,r))}},x3dom.fields.SFImage.prototype.setPixel=function(e,t,i){var o=(t*this.width+e)*this.comp;return 1===this.comp&&o0;for(var t=0,i=this.nodes.length;tx3dom.fields.Eps)i=1/this.dir.x,o=(e.x-this.pos.x)*i,(s=(t.x-this.pos.x)*i)r&&(r=o);else if(this.dir.x<-x3dom.fields.Eps)i=1/this.dir.x,o=(t.x-this.pos.x)*i,(s=(e.x-this.pos.x)*i)r&&(r=o);else if(this.pos.xt.x)return!1;if(this.dir.y>x3dom.fields.Eps){if(i=1/this.dir.y,o=(e.y-this.pos.y)*i,(s=(t.y-this.pos.y)*i)r&&(r=o),r-n>=x3dom.fields.Eps)return!1}else if(this.dir.y<-x3dom.fields.Eps){if(i=1/this.dir.y,o=(t.y-this.pos.y)*i,(s=(e.y-this.pos.y)*i)r&&(r=o),r-n>=x3dom.fields.Eps)return!1}else if(this.pos.yt.y)return!1;if(this.dir.z>x3dom.fields.Eps)i=1/this.dir.z,o=(e.z-this.pos.z)*i,(s=(t.z-this.pos.z)*i)r&&(r=o);else if(this.dir.z<-x3dom.fields.Eps)i=1/this.dir.z,o=(t.z-this.pos.z)*i,(s=(e.z-this.pos.z)*i)r&&(r=o);else if(this.pos.zt.z)return!1;return this.enter=r,this.exit=n,r-ne.x&&(this.min.x=e.x),this.min.y>e.y&&(this.min.y=e.y),this.min.z>e.z&&(this.min.z=e.z),this.max.x=d?(s+=a,t+=d):(s+=d,t+=a),(a=this.max.y*e._01)>=(d=this.min.y*e._01)?(s+=a,t+=d):(s+=d,t+=a),(a=this.max.z*e._02)>=(d=this.min.z*e._02)?(s+=a,t+=d):(s+=d,t+=a),(a=this.max.x*e._10)>=(d=this.min.x*e._10)?(r+=a,i+=d):(r+=d,i+=a),(a=this.max.y*e._11)>=(d=this.min.y*e._11)?(r+=a,i+=d):(r+=d,i+=a),(a=this.max.z*e._12)>=(d=this.min.z*e._12)?(r+=a,i+=d):(r+=d,i+=a),(a=this.max.x*e._20)>=(d=this.min.x*e._20)?(n+=a,o+=d):(n+=d,o+=a),(a=this.max.y*e._21)>=(d=this.min.y*e._21)?(n+=a,o+=d):(n+=d,o+=a),(a=this.max.z*e._22)>=(d=this.min.z*e._22)?(n+=a,o+=d):(n+=d,o+=a),this.min.x=t,this.min.y=i,this.min.z=o,this.max.x=s,this.max.y=r,this.max.z=n,this.updateInternals()},x3dom.fields.BoxVolume.prototype.transformFrom=function(e,t){var i,o,s,r,n,a;i=r=e._03,o=n=e._13,s=a=e._23;var d=t.max.x*e._00,l=t.min.x*e._00;d>=l?(r+=d,i+=l):(r+=l,i+=d),(d=t.max.y*e._01)>=(l=t.min.y*e._01)?(r+=d,i+=l):(r+=l,i+=d),(d=t.max.z*e._02)>=(l=t.min.z*e._02)?(r+=d,i+=l):(r+=l,i+=d),(d=t.max.x*e._10)>=(l=t.min.x*e._10)?(n+=d,o+=l):(n+=l,o+=d),(d=t.max.y*e._11)>=(l=t.min.y*e._11)?(n+=d,o+=l):(n+=l,o+=d),(d=t.max.z*e._12)>=(l=t.min.z*e._12)?(n+=d,o+=l):(n+=l,o+=d),(d=t.max.x*e._20)>=(l=t.min.x*e._20)?(a+=d,s+=l):(a+=l,s+=d),(d=t.max.y*e._21)>=(l=t.min.y*e._21)?(a+=d,s+=l):(a+=l,s+=d),(d=t.max.z*e._22)>=(l=t.min.z*e._22)?(a+=d,s+=l):(a+=l,s+=d),this.min.x=i,this.min.y=o,this.min.z=s,this.max.x=r,this.max.y=n,this.max.z=a,this.updateInternals(),this.valid=!0},x3dom.fields.FrustumVolume=function(e){if(this.planeNormals=[],this.planeDistances=[],this.directionIndex=[],0!==arguments.length){for(var t=[],i=0;i<6;i++)this.planeNormals[i]=new x3dom.fields.SFVec3f(0,0,0),this.planeDistances[i]=0,this.directionIndex[i]=0,t[i]=new x3dom.fields.SFVec4f(0,0,0,0);for(t[0].x=e._30-e._00,t[0].y=e._31-e._01,t[0].z=e._32-e._02,t[0].w=e._33-e._03,t[1].x=e._30+e._00,t[1].y=e._31+e._01,t[1].z=e._32+e._02,t[1].w=e._33+e._03,t[2].x=e._30+e._10,t[2].y=e._31+e._11,t[2].z=e._32+e._12,t[2].w=e._33+e._13,t[3].x=e._30-e._10,t[3].y=e._31-e._11,t[3].z=e._32-e._12,t[3].w=e._33-e._13,t[4].x=e._30+e._20,t[4].y=e._31+e._21,t[4].z=e._32+e._22,t[4].w=e._33+e._23,t[5].x=e._30-e._20,t[5].y=e._31-e._21,t[5].z=e._32-e._22,t[5].w=e._33-e._23,i=0;i<6;i++){var o=Math.sqrt(t[i].x*t[i].x+t[i].y*t[i].y+t[i].z*t[i].z);t[i].x/=o,t[i].y/=o,t[i].z/=o,t[i].w/=-o}var s=function(e){var t=0;return e.x>0&&(t|=1),e.y>0&&(t|=2),e.z>0&&(t|=4),t};this.planeNormals[3].setValues(t[0]),this.planeDistances[3]=t[0].w,this.directionIndex[3]=s(this.planeNormals[3]),this.planeNormals[2].setValues(t[1]),this.planeDistances[2]=t[1].w,this.directionIndex[2]=s(this.planeNormals[2]),this.planeNormals[5].setValues(t[2]),this.planeDistances[5]=t[2].w,this.directionIndex[5]=s(this.planeNormals[5]),this.planeNormals[4].setValues(t[3]),this.planeDistances[4]=t[3].w,this.directionIndex[4]=s(this.planeNormals[4]),this.planeNormals[0].setValues(t[4]),this.planeDistances[0]=t[4].w,this.directionIndex[0]=s(this.planeNormals[0]),this.planeNormals[1].setValues(t[5]),this.planeDistances[1]=t[5].w,this.directionIndex[1]=s(this.planeNormals[1])}},x3dom.fields.FrustumVolume.prototype.intersect=function(e,t){if(this.planeNormals.length<6)return x3dom.debug.logWarning(\"FrustumVolume not initialized!\"),!1;var i=this,o=e.min,s=e.max,r=function(e){var t=new x3dom.fields.SFVec3f(0,0,0);return t.x=1&e?o.x:s.x,t.y=2&e?o.y:s.y,t.z=4&e?o.z:s.z,t},n=function(e,t){return i.planeNormals[e].dot(t)-i.planeDistances[e]>=0},a=function(e){var t=r(i.directionIndex[e]);return n(e,t)},d=function(e){var t=r(7^i.directionIndex[e]);return!n(e,t)},l=1;t<0&&(t=0);for(var h=0;h<6;h++,l<<=1)if(0==(t&l)){if(d(h))return-1;a(h)&&(t|=l)}return t},x3dom.BindableStack=function(e,t,i,o){this._doc=e,this._type=t,this._defaultType=i,this._defaultRoot=null,this._getter=o,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(e){var t=this.top();t!==e&&(t&&t.deactivate(),this._bindStack.push(e),e.activate(t))},x3dom.BindableStack.prototype.replaceTop=function(e){var t=this.top();t!==e&&t&&(t.deactivate(),this._bindStack[this._bindStack.length-1]=e,e.activate(t))},x3dom.BindableStack.prototype.pop=function(e){var t;return e&&e!==(t=this.top())?null:((t=this._bindStack.pop())&&t.deactivate(),t)},x3dom.BindableStack.prototype.switchTo=function(e){var t=this.getActive(),i=this._bindBag.length,o=0,s=0,r=-1;if(!(i<=1)){switch(e){case\"first\":o=this._bindBag[0];break;case\"last\":o=this._bindBag[i-1];break;default:for(s=0;s=0)for(s=r;!o&&(s=\"next\"==e?s0?s-1:i-1)!=r;)this._bindBag[s]._vf.description.length>=0&&(o=this._bindBag[s])}o?this.replaceTop(o):x3dom.debug.logWarning(\"Cannot switch bindable; no other bindable with description found.\")}},x3dom.BindableStack.prototype.getActive=function(){if(0===this._bindStack.length){if(0===this._bindBag.length)if(this._defaultRoot){x3dom.debug.logInfo(\"create new \"+this._defaultType._typeName+\" for \"+this._type._typeName+\"-stack\");var e=new this._defaultType({doc:this._doc,nameSpace:this._defaultRoot._nameSpace,autoGen:!0});this._defaultRoot.addChild(e),e.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()}var t=this._bindStack[this._bindStack.length-1];return null==t._nameSpace&&(this.pop(),t=this.getActive()),t},x3dom.BindableBag=function(e){this._stacks=[],this.addType(\"X3DViewpointNode\",\"Viewpoint\",\"getViewpoint\",e),this.addType(\"X3DNavigationInfoNode\",\"NavigationInfo\",\"getNavigationInfo\",e),this.addType(\"X3DBackgroundNode\",\"Background\",\"getBackground\",e),this.addType(\"X3DFogNode\",\"Fog\",\"getFog\",e),this.addType(\"X3DEnvironmentNode\",\"Environment\",\"getEnvironment\",e)},x3dom.BindableBag.prototype.addType=function(e,t,i,o){var s=x3dom.nodeTypes[e],r=x3dom.nodeTypes[t];if(s&&r){var n=new x3dom.BindableStack(o,s,r,i);this._stacks.push(n)}else x3dom.debug.logWarning(\"Invalid Bindable type/defaultType: \"+e+\"/\"+r)},x3dom.BindableBag.prototype.setRefNode=function(e){this._stacks.forEach((function(t){t._defaultRoot=e,e[t._getter]=function(){return t.getActive()}}))},x3dom.BindableBag.prototype.addBindable=function(e){for(var t=0,i=this._stacks.length;t=0?e.substr(0,t+1):\"\",x3dom.debug.logInfo(\"setBaseURL: \"+this.baseURL)},x3dom.NodeNameSpace.prototype.getURL=function(e){return void 0!==e&&e.length?\"/\"===e[0]||e.indexOf(\":\")>=0?e:this.baseURL+e:\"\"},x3dom.hasElementAttribute=function(e){var t=this.__hasAttribute(e);return!t&&e&&(t=this.__hasAttribute(e.toLowerCase())),t},x3dom.getElementAttribute=function(e){var t=this.__getAttribute(e);return!t&&\"\"!=t&&e&&(t=this.__getAttribute(e.toLowerCase())),null==t&&this._x3domNode?this._x3domNode._vf[e]:t},x3dom.setElementAttribute=function(e,t){this.__setAttribute(e,t);var i=this._x3domNode;i&&(x3dom.userAgentFeature.supportsMutationObserver||i.updateField(e,t),i._nameSpace.doc.needRender=!0)},x3dom.getFieldValue=function(e){var t=this._x3domNode;if(t&&void 0!==t._vf[e]){var i=t._vf[e];return i instanceof Object&&\"copy\"in i?t._vf[e].copy():t._vf[e]}return null},x3dom.setFieldValue=function(e,t){var i=this._x3domNode;i&&void 0!==i._vf[e]&&i._nameSpace&&(t instanceof Object&&\"copy\"in t?i._vf[e]=t.copy():i._vf[e]=t,i.fieldChanged(e),i._nameSpace.doc.needRender=!0)},x3dom.requestFieldRef=function(e){var t=this._x3domNode;return t&&t._vf[e]?t._vf[e]:null},x3dom.releaseFieldRef=function(e){var t=this._x3domNode;t&&t._vf[e]&&t._nameSpace&&(t.fieldChanged(e),t._nameSpace.doc.needRender=!0)},x3dom.attachFieldAccess=function(e){e.requestFieldRef=x3dom.requestFieldRef,e.releaseFieldRef=x3dom.releaseFieldRef,e.getFieldValue=x3dom.getFieldValue,e.setFieldValue=x3dom.setFieldValue},x3dom.NodeNameSpace.prototype.setupTree=function(e,t){var i=null;if(t=t||null,x3dom.isX3DElement(e)){if(e._x3domNode)return x3dom.debug.logWarning(\"Tree is already initialized\"),null;if(void 0===e.tagName||e.__addEventListener||e.__removeEventListener||(e.__addEventListener=e.addEventListener,e.addEventListener=function(e,t,i){this._x3domNode._listeners[e]||(this._x3domNode._listeners[e]=[]),this._x3domNode._listeners[e].push(t),this.__addEventListener(e,t,i)},e.__removeEventListener=e.removeEventListener,e.removeEventListener=function(e,t,i){var o=this._x3domNode._listeners[e];if(o)for(var s=0;s=2){for(var s=this;s;)s.name==o[0]&&(i=s.defMap[o[1]]),s=i?null:s.parent;i||(i=null,x3dom.debug.logWarning(\"Could not USE: \"+e.getAttribute(\"USE\")))}}return i&&(e._x3domNode=i,x3dom.attachFieldAccess(e)),i}if(\"route\"===e.localName.toLowerCase()){var r=e,n=r.getAttribute(\"fromNode\")||r.getAttribute(\"fromnode\"),a=r.getAttribute(\"toNode\")||r.getAttribute(\"tonode\"),d=this.defMap[n],l=this.defMap[a],h=r.getAttribute(\"fromField\")||r.getAttribute(\"fromfield\"),f=r.getAttribute(\"toField\")||r.getAttribute(\"tofield\");return d&&l?(d.setupRoute(h,l,f),r._nodeNameSpace=this):(x3dom.debug.logWarning(\"not yet available route - can't find all DEFs for \"+h+\" -> \"+f),this.lateRoutes.push({route:r,fnDEF:n,tnDEF:a,fnAtt:h,tnAtt:f})),null}if(\"import\"===e.localName.toLowerCase()){var u=e.getAttribute(\"inlineDEF\")||e.getAttribute(\"inlinedef\"),c=e.getAttribute(\"importedDEF\")||e.getAttribute(\"importeddef\"),_=e.getAttribute(\"AS\")||e.getAttribute(\"as\");if(!u||!c)return null;if(_||(_=c),this.imports.get(u)||this.imports.set(u,new Map),this.imports.get(u).set(_,c),e._nodeNameSpace=this,this.defMap[u]&&this.defMap[u]._childNodes[0]&&this.defMap[u]._childNodes[0]._nameSpace){var m=this.defMap[u]._childNodes[0]._nameSpace;if(x=m.exports.get(c)){var p=m.defMap[x];p&&(this.defMap[_]=p,this.routeLateRoutes())}}return null}if(\"export\"===e.localName.toLowerCase()){var x=e.getAttribute(\"localDEF\")||e.getAttribute(\"localdef\");_=e.getAttribute(\"AS\")||e.getAttribute(\"as\");return x?(_||(_=x),this.exports.set(_,x),e._nodeNameSpace=this,this.superInlineNode&&this.superInlineNode._nameSpace&&this.superInlineNode._nameSpace.importNodes(this),null):null}x3dom.attachFieldAccess(e);var g=x3dom.nodeTypesLC[e.localName.toLowerCase()];if(void 0!==g){!1===x3dom.userAgentFeature.supportsDOMAttrModified&&e instanceof Element&&(e.setAttribute&&!e.__setAttribute&&(e.__setAttribute=e.setAttribute,e.setAttribute=x3dom.setElementAttribute),e.getAttribute&&!e.__getAttribute&&(e.__getAttribute=e.getAttribute,e.getAttribute=x3dom.getElementAttribute),e.hasAttribute&&!e.__hasAttribute&&(e.__hasAttribute=e.hasAttribute,e.hasAttribute=x3dom.hasElementAttribute));var v={doc:this.doc,runtime:this.doc._x3dElem.runtime,xmlNode:e,nameSpace:this};return i=new g(v),e.hasAttribute(\"DEF\")?(i._DEF=e.getAttribute(\"DEF\"),this.defMap[i._DEF]=i):e.hasAttribute(\"id\")&&(i._DEF=e.getAttribute(\"id\"),i._DEF in this.defMap||(this.defMap[i._DEF]=i)),void 0===e.highlight&&(e.highlight=function(e,t){var i=x3dom.fields.SFColor.parse(t);this._x3domNode.highlight(e,i),this._x3domNode._nameSpace.doc.needRender=!0}),i._xmlNode=e,e._x3domNode=i,e.querySelectorAll(\":scope > *\").forEach((function(t){var i=t.localName.toLowerCase();\"protodeclare\"==i?this.protoDeclare(t):\"externprotodeclare\"==i?this.externProtoDeclare(t):\"protoinstance\"==i&&this.protoInstance(t,e)}),this),e.childNodes.forEach((function(e){var t=this.setupTree(e,i);t&&i.addChild(t,e.getAttribute(\"containerField\"))}),this),i.nodeChanged(),i}x3dom.debug.logWarning(\"Unrecognised X3D element <\"+e.localName+\">.\")}else if(e.localName){var y=e.localName.toLowerCase(),T=this.protos.find((function(e){return y==e.name.toLowerCase()&&e.isExternProto}));t&&\"x3dommetagroup\"==y?e.childNodes.forEach(function(e){var i=this.setupTree(e,t);i&&t.addChild(i,e.getAttribute(\"containerField\"))}.bind(this)):\"protodeclare\"==y||\"externprotodeclare\"==y||\"protoinstance\"==y?i=null:\"is\"==e.localName.toLowerCase()?0==e.querySelectorAll(\"connect\").length&&x3dom.debug.logWarning(\"IS statement without connect link: \"+e.parentElement.localName):T?this.loadExternProtoAsync(T,e,e,e.parentElement):(x3dom.debug.logWarning(\"Unrecognised X3D element <\"+e.localName+\">.\"),i=null)}return i},x3dom.NodeNameSpace.prototype.importNodes=function(e){if(e&&e.superInlineNode&&e.superInlineNode._nameSpace==this){var t=this,i=e.superInlineNode._DEF,o=t.imports,s=e.exports,r=0;i&&o.get(i)&&(o.get(i).forEach((function(i,o){var n=s.get(i);if(n){var a=e.defMap[n];a&&(t.defMap[o]=a,r++)}})),r>0&&t.routeLateRoutes())}},x3dom.NodeNameSpace.prototype.routeLateRoutes=function(){var e=this;e.lateRoutes.forEach((function(t){var i=e.defMap[t.fnDEF],o=e.defMap[t.tnDEF];i&&o&&(x3dom.debug.logInfo(\"fixed ROUTE: from=\"+i._DEF+\", to=\"+o._DEF),i.setupRoute(t.fnAtt,o,t.tnAtt),t.route._nodeNameSpace=e)}))},x3dom.NodeNameSpace.prototype.protoInstance=function(e,t){if(e.localName&&!e._x3dom){var i=e.getAttribute(\"name\");if(e.hasAttribute(\"USE\")){var o=e.getAttribute(\"USE\"),s=this.defMap[o];i=s?s.constructor._typeName:t.getRootNode().querySelector(\"[DEF=\"+o+\"]\").getAttribute(\"name\")}var r=this.protos.find((function(e){return e.name==i}));if(null!=r){var n=document.createElement(i);if(e.hasAttribute(\"DEF\")?n.setAttribute(\"DEF\",e.getAttribute(\"DEF\")):e.hasAttribute(\"USE\")&&n.setAttribute(\"USE\",e.getAttribute(\"USE\")),e.hasAttribute(\"containerField\")&&n.setAttribute(\"containerField\",e.getAttribute(\"containerField\")),e.querySelectorAll(\":scope > fieldValue , :scope > fieldvalue\").forEach((function(e){var t=e.getAttribute(\"name\"),i=e.querySelectorAll(\":scope > *\");if(i.length>0)i.forEach((function(e){e.setAttribute(\"containerField\",t),n.appendChild(e)}));else{var o=e.getAttribute(\"value\");o&&n.setAttribute(t,o)}})),r.isExternProto&&r.needsLoading)this.loadExternProtoAsync(r,n,e,t);else{this.doc.mutationObserver.disconnect(),e.insertAdjacentElement(\"afterend\",n);var a=this.doc._x3dElem;this.doc._scene&&(a=this.doc._scene._xmlNode),this.doc.mutationObserver.observe(a,{attributes:!0,attributeOldValue:!0,childList:!0,subtree:!0}),e._x3dom=n}}else x3dom.debug.logWarning(\"ProtoInstance without a ProtoDeclaration \"+i)}},x3dom.NodeNameSpace.prototype.loadExternProtoAsync=function(e,t,i,o){e.instanceQueue.push({protoInstanceDom:t,domNode:i,parentDom:o,targetChildIndex:o._x3domNode._childNodes.length+e.instanceQueue.length}),i._x3dom=t;var s=this,r=0;!function t(){var i=s.getURL(e.url[r]);s.doc.incrementDownloads(),fetch(i).then((function(e){if(!e.ok)throw new Error(\"Network response was not OK: \"+e.status);return e.text()})).then((function(t){var o=new DOMParser,r=o.parseFromString(t,\"application/xml\"),n=r.querySelector(\"X3D\");null==n&&(n=(r=o.parseFromString(t,\"text/html\")).querySelector(\"X3D\"));var a=i.includes(\"#\")?i.split(\"#\").slice(-1)[0]:\"\",d=\"\"==a?\"ProtoDeclare\":\"ProtoDeclare[name='\"+a+\"']\",l=n.querySelector(d);l.setAttribute(\"name\",e.name),s.confNameSpace=new x3dom.NodeNameSpace(e.name,s.doc),s.confNameSpace.setBaseURL(s.baseURL+e.name),s.confNameSpace.setupTree(n.querySelector(\"Scene\"),n),s.confNameSpace.protos.forEach((function(e){s.protos.push(e)}));var h,f=s.protos.findIndex((function(t){return t==e}));for(s.protos.splice(f,1),s.protoDeclare(l);h=e.instanceQueue.shift();){var u=h.parentDom,c=u._x3domNode,_=h.protoInstanceDom,m=h.targetChildIndex;s.doc.mutationObserver.disconnect(),h.domNode!==_&&h.domNode.insertAdjacentElement(\"afterend\",_),s.doc.mutationObserver.observe(s.doc._scene._xmlNode,{attributes:!0,attributeOldValue:!0,childList:!0,subtree:!0}),s.doc.onNodeAdded(_,u);var p=c._childNodes,x=p.length-1;if(m!==x){var g=p[m],v=p[x];p[m]=v,p[x]=g;var y=(T=u.getAttribute(\"containerField\"))in c._cf&&c._cf[T];if(!y)for(var T in c._cf){var b=c._cf[T];if(x3dom.isa(v,b.type)){y=b;break}}y[m]=v,y[x]=g}s.lateRoutes.forEach((function(e){var t=s.defMap[e.fnDEF],i=s.defMap[e.tnDEF];t&&i&&(x3dom.debug.logInfo(\"fixed ROUTE: from=\"+t._DEF+\", to=\"+i._DEF),t.setupRoute(e.fnAtt,i,e.tnAtt),e.route._nodeNameSpace=s)})),s.superInlineNode&&s.superInlineNode._nameSpace&&s.superInlineNode._nameSpace.importNodes(s)}e.needsLoading=!1,s.doc.decrementDownloads()})).catch((function(o){if(x3dom.debug.logWarning(i+\": ExternProto fetch failed: \"+o),s.doc.decrementDownloads(),!(++r *\")})}));var s=e.querySelector(\"ProtoBody\");if(s){s._ISRoutes={},s.querySelectorAll(\"IS\").forEach((function(e){for(var t=e.parentElement;\"protobody\"!==t.localName.toLowerCase();)t=t.parentElement;t===s&&e.querySelectorAll(\"connect\").forEach((function(t){var i=e.parentElement;if(0==i.hasAttribute(\"DEF\")){var o=\"_proto_\"+i.tagName+\"_\"+x3dom.protoISDEFuid++;i.setAttribute(\"DEF\",o),\"protoinstance\"==i.localName.toLowerCase()&&i._x3domNode&&(i._x3domNode._DEF=o,i._x3domNode.typeNode._nameSpace.defMap[o]=i._x3domNode)}var r=t.getAttribute(\"protoField\"),n=i.getAttribute(\"DEF\"),a=t.getAttribute(\"nodeField\");s._ISRoutes[r]||(s._ISRoutes[r]=[]),s._ISRoutes[r].push({nodeDEF:n,nodeField:a})}))}));var r=new x3dom.ProtoDeclaration(this,t,s,o);r.registerNode(),this.protos.push(r)}else x3dom.debug.logWarning(\"ProtoDeclare without a ProtoBody definition: \"+e.name);return\"ProtoDeclare\"},x3dom.protoISDEFuid=0,x3dom.gfx_webgl=function(){\"use strict\";function e(e,t,i,o){this.ctx3d=e,this.canvas=t,this.name=i,this.x3dElem=o,this.IG_PositionBuffer=null,this.cache=new x3dom.Cache,this.stateManager=new x3dom.StateManager(e),this.VRMode=1,this.BUFFER_IDX={INDEX:0,POSITION:1,NORMAL:2,TEXCOORD:3,TEXCOORD_0:3,COLOR:4,TANGENT:6,BITANGENT:7,TEXCOORD_1:8,ID:9}}return e.prototype.getName=function(){return this.name},e.prototype.setupShape=function(e,t,i){var o,s,r,n,a,d,l,h,f,u,c,_,m=0,p=t.shape,x=p._cf.geometry.node;if(void 0!==p._webgl){var g=!1;if(!0===p._dirty.colors&&void 0===p._webgl.shader.color&&x._mesh._colors[0].length&&(g=!0),g&&p._cleanupGLObjects&&p._cleanupGLObjects(!0,!1),!0===p._dirty.texture){if(p._webgl.texture.length!=p.getTextures().length){for(r=0;r65535?(u=new Uint32Array(p._webgl.indexes[m]),p._webgl.indexType=e.UNSIGNED_INT):(u=new Uint16Array(p._webgl.indexes[m]),p._webgl.indexType=e.UNSIGNED_SHORT),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,f),e.bufferData(e.ELEMENT_ARRAY_BUFFER,u,e.STATIC_DRAW),u=null,p._webgl.positions[m]=x._mesh._positions[m],e.deleteBuffer(p._webgl.buffers[o+x3dom.BUFFER_IDX.POSITION]),a=e.createBuffer(),p._webgl.buffers[o+x3dom.BUFFER_IDX.POSITION]=a,e.bindBuffer(e.ARRAY_BUFFER,a),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,p._webgl.buffers[o+x3dom.BUFFER_IDX.INDEX]),n=new Float32Array(p._webgl.positions[m]),e.bufferData(e.ARRAY_BUFFER,n,e.STATIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,a),e.vertexAttribPointer(p._webgl.shader.position,x._mesh._numPosComponents,p._webgl.coordType,!1,p._coordStrideOffset[0],p._coordStrideOffset[1]),n=null),p._dirty.positions=!1,p._dirty.indexes=!1),1==p._dirty.colors&&(void 0!==p._webgl.shader.color&&(p._webgl.colors[m]=x._mesh._colors[m],e.deleteBuffer(p._webgl.buffers[o+x3dom.BUFFER_IDX.COLOR]),_=e.createBuffer(),p._webgl.buffers[o+x3dom.BUFFER_IDX.COLOR]=_,M=new Float32Array(p._webgl.colors[m]),e.bindBuffer(e.ARRAY_BUFFER,_),e.bufferData(e.ARRAY_BUFFER,M,e.STATIC_DRAW),e.vertexAttribPointer(p._webgl.shader.color,x._mesh._numColComponents,p._webgl.colorType,!1,p._colorStrideOffset[0],p._colorStrideOffset[1]),M=null),p._dirty.colors=!1),1==p._dirty.normals&&(void 0!==p._webgl.shader.normal&&(p._webgl.normals[m]=x._mesh._normals[m],e.deleteBuffer(p._webgl.buffers[o+x3dom.BUFFER_IDX.NORMAL]),c=e.createBuffer(),p._webgl.buffers[o+x3dom.BUFFER_IDX.NORMAL]=c,S=new Float32Array(p._webgl.normals[m]),e.bindBuffer(e.ARRAY_BUFFER,c),e.bufferData(e.ARRAY_BUFFER,S,e.STATIC_DRAW),e.vertexAttribPointer(p._webgl.shader.normal,x._mesh._numNormComponents,p._webgl.normalType,!1,p._normalStrideOffset[0],p._normalStrideOffset[1]),S=null),p._dirty.normals=!1),1==p._dirty.texcoords&&(void 0!==p._webgl.shader.texcoord&&(p._webgl.texcoords[m]=x._mesh._texCoords[m],e.deleteBuffer(p._webgl.buffers[o+x3dom.BUFFER_IDX.TEXCOORD]),d=e.createBuffer(),p._webgl.buffers[o+x3dom.BUFFER_IDX.TEXCOORD]=d,E=new Float32Array(p._webgl.texcoords[m]),e.bindBuffer(e.ARRAY_BUFFER,d),e.bufferData(e.ARRAY_BUFFER,E,e.STATIC_DRAW),e.vertexAttribPointer(p._webgl.shader.texCoord,x._mesh._numTexComponents,p._webgl.texCoordType,!1,p._texCoordStrideOffset[0],p._texCoordStrideOffset[1]),E=null),p._dirty.texcoords=!1),1==p._dirty.specialAttribs&&void 0!==p._webgl.shader.particleSize){var v=x._vf.size.toGL();v.length&&(e.deleteBuffer(p._webgl.buffers[o+x3dom.BUFFER_IDX.ID]),p._webgl.buffers[o+x3dom.BUFFER_IDX.ID]=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,p._webgl.buffers[o+x3dom.BUFFER_IDX.ID]),e.bufferData(e.ARRAY_BUFFER,new Float32Array(v),e.STATIC_DRAW)),p._dirty.specialAttribs=!1}if(!g)return}else if(!(x3dom.isa(x,x3dom.nodeTypes.Text)||x3dom.isa(x,x3dom.nodeTypes.BinaryGeometry)||x3dom.isa(x,x3dom.nodeTypes.PopGeometry)||x3dom.isa(x,x3dom.nodeTypes.BufferGeometry))&&(!x||x._mesh._positions[0].length<1))return void x3dom.debug.logError(\"NO VALID MESH OR NO VERTEX POSITIONS SET!\");for(p.unsetDirty(),p._cleanupGLObjects||(p._cleanupGLObjects=function(t,i){if(this._webgl&&(arguments.length>0&&t||0==this._parentNodes.length)){for(var o=this._webgl.shader,s=0;s65535?(u=new Uint32Array(p._webgl.indexes[m]),p._webgl.indexType=e.UNSIGNED_INT):(u=new Uint16Array(p._webgl.indexes[m]),p._webgl.indexType=e.UNSIGNED_SHORT),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,f),e.bufferData(e.ELEMENT_ARRAY_BUFFER,u,e.STATIC_DRAW),u=null,a=e.createBuffer(),p._webgl.buffers[o+x3dom.BUFFER_IDX.POSITION]=a,e.bindBuffer(e.ARRAY_BUFFER,a),n=new Float32Array(p._webgl.positions[m]),e.bufferData(e.ARRAY_BUFFER,n,e.STATIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,a),e.vertexAttribPointer(y.position,x._mesh._numPosComponents,p._webgl.coordType,!1,p._coordStrideOffset[0],p._coordStrideOffset[1]),e.enableVertexAttribArray(y.position),n=null),p._webgl.normals[m]){c=e.createBuffer(),p._webgl.buffers[o+x3dom.BUFFER_IDX.NORMAL]=c;var S=new Float32Array(p._webgl.normals[m]);e.bindBuffer(e.ARRAY_BUFFER,c),e.bufferData(e.ARRAY_BUFFER,S,e.STATIC_DRAW),e.vertexAttribPointer(y.normal,x._mesh._numNormComponents,p._webgl.normalType,!1,p._normalStrideOffset[0],p._normalStrideOffset[1]),e.enableVertexAttribArray(y.normal),S=null}if(p._webgl.texcoords[m]){var F=e.createBuffer();p._webgl.buffers[o+x3dom.BUFFER_IDX.TEXCOORD]=F;var E=new Float32Array(p._webgl.texcoords[m]);e.bindBuffer(e.ARRAY_BUFFER,F),e.bufferData(e.ARRAY_BUFFER,E,e.STATIC_DRAW),e.vertexAttribPointer(y.texcoord,x._mesh._numTexComponents,p._webgl.texCoordType,!1,p._texCoordStrideOffset[0],p._texCoordStrideOffset[1]),e.enableVertexAttribArray(y.texcoord),E=null}if(p._webgl.colors[m]){_=e.createBuffer(),p._webgl.buffers[o+x3dom.BUFFER_IDX.COLOR]=_;var M=new Float32Array(p._webgl.colors[m]);e.bindBuffer(e.ARRAY_BUFFER,_),e.bufferData(e.ARRAY_BUFFER,M,e.STATIC_DRAW),e.vertexAttribPointer(y.color,x._mesh._numColComponents,p._webgl.colorType,!1,p._colorStrideOffset[0],p._colorStrideOffset[1]),e.enableVertexAttribArray(y.color),M=null}if(void 0!==y.particleSize){var C=x._vf.size.toGL();if(C.length){var A=e.createBuffer();p._webgl.buffers[o+x3dom.BUFFER_IDX.ID]=A,e.bindBuffer(e.ARRAY_BUFFER,A),e.bufferData(e.ARRAY_BUFFER,new Float32Array(C),e.STATIC_DRAW)}}if(p._webgl.tangents[m]){l=e.createBuffer(),p._webgl.buffers[o+x3dom.BUFFER_IDX.TANGENT]=l;var w=new Float32Array(p._webgl.tangents[m]);e.bindBuffer(e.ARRAY_BUFFER,l),e.bufferData(e.ARRAY_BUFFER,w,e.STATIC_DRAW),e.vertexAttribPointer(y.tangent,x._mesh._numTangentComponents,p._webgl.tangentType,!1,p._tangentStrideOffset[0],p._tangentStrideOffset[1]),e.enableVertexAttribArray(y.tangent),w=null}if(p._webgl.binormals[m]){h=e.createBuffer(),p._webgl.buffers[o+x3dom.BUFFER_IDX.BITANGENT]=h;var R=new Float32Array(p._webgl.binormals[m]);e.bindBuffer(e.ARRAY_BUFFER,h),e.bufferData(e.ARRAY_BUFFER,R,e.STATIC_DRAW),e.vertexAttribPointer(y.binormal,x._mesh._numBinormalComponents,p._webgl.binormalType,!1,p._binormalStrideOffset[0],p._binormalStrideOffset[1]),e.enableVertexAttribArray(y.tangent),R=null}}for(var D in x._mesh._dynamicFields)if(x._mesh._dynamicFields.hasOwnProperty(D)){var N=x._mesh._dynamicFields[D];if(p._webgl.dynamicFields[T]={buf:{},name:D,numComponents:N.numComponents},void 0!==y[D]){var I=e.createBuffer();p._webgl.dynamicFields[T++].buf=I;var P=new Float32Array(N.value);e.bindBuffer(e.ARRAY_BUFFER,I),e.bufferData(e.ARRAY_BUFFER,P,e.STATIC_DRAW),e.vertexAttribPointer(y[D],N.numComponents,e.FLOAT,!1,0,0),P=null}}}},e.prototype.setupScene=function(e,t){var i=null,o=null,s=this;if(void 0!==t._webgl){if(!t._dirty)return;void 0!==t._webgl.texture&&t._webgl.texture&&e.deleteTexture(t._webgl.texture),t._cleanupGLObjects&&t._cleanupGLObjects(),t._webgl={}}t._dirty=!1;var r=t.getTexUrl(),n=0;if(r.length>0&&r[0].length>0)r.length>=6&&r[1].length>0&&r[2].length>0&&r[3].length>0&&r[4].length>0&&r[5].length>0||-1!=r[0].indexOf(\".dds\")?(i=new x3dom.nodeTypes.Sphere,t._webgl={positions:i._mesh._positions[0],indexes:i._mesh._indices[0],buffers:[{},{}]},t._webgl.primType=e.TRIANGLES,-1!=r[0].indexOf(\".dds\")?(t._webgl.shader=this.cache.getShader(e,x3dom.shader.BACKGROUND_CUBETEXTURE_DDS),t._webgl.texture=x3dom.Utils.createTextureCube(e,t._nameSpace.doc,[r[0]],!1,t._vf.crossOrigin,!0,!1,!1)):(t._webgl.shader=this.cache.getShader(e,x3dom.shader.BACKGROUND_CUBETEXTURE_DDS),t._webgl.texture=x3dom.Utils.createTextureCube(e,t._nameSpace.doc,r,!1,t._vf.crossOrigin,!0,!1))):(t._webgl={positions:[-1,-1,0,-1,1,0,1,-1,0,1,1,0],indexes:[0,1,2,3],buffers:[{},{}]},r=t._nameSpace.getURL(r[0]),t._webgl.texture=x3dom.Utils.createTexture2D(e,t._nameSpace.doc,r,!0,t._vf.crossOrigin,!1,!1),t._webgl.primType=e.TRIANGLE_STRIP,t._webgl.shader=s.cache.getShader(e,x3dom.shader.BACKGROUND_TEXTURE));else if(t.getSkyColor().length>1||t.getGroundColor().length){i=new x3dom.nodeTypes.Sphere,o=e.createTexture(),t._webgl={positions:i._mesh._positions[0],texcoords:i._mesh._texCoords[0],indexes:i._mesh._indices[0],buffers:[{},{},{}],texture:o,primType:e.TRIANGLES};var a=x3dom.Utils.nextHighestPowerOfTwo(t.getSkyColor().length+t.getGroundColor().length+2);a=a<512?512:a;var d=t._vf.groundAngle.length,l=[],h=[],f=[],u=[0];for(n=0;n0||1==t._vf.groundColor.length){for(u[u.length-1]=0;n--)n==d-1&&Math.PI-t._vf.groundAngle[n]<=Math.PI/2&&(u[u.length]=Math.PI/2,f[f.length]=t._vf.groundColor[t._vf.groundColor.length-1]),u[u.length]=Math.PI-t._vf.groundAngle[n],f[f.length]=t._vf.groundColor[n+1];0==d&&1==t._vf.groundColor.length&&(u[u.length]=Math.PI/2,f[f.length]=t._vf.groundColor[0]),u[u.length]=Math.PI,f[f.length]=t._vf.groundColor[0]}else u[u.length-1]_.y?(c=_.x/m.x,m.x=_.x,m.y=m.y*c):(c=_.y/m.y,m.y=_.y,m.x=m.x*c);var p=_.divideComponents(m),x=m.subtract(_).multiply(.5).divideComponents(m)}else p=new x3dom.fields.SFVec2f(1,1),x=new x3dom.fields.SFVec2f(0,0);n.scale=p.toGL(),n.translation=x.toGL()}if(n.isVR=-1,n.screenWidth=s.canvas.width,s.setTonemappingOperator(r,n),2==s.VRMode){var g=r.getViewMatrices()[1],v=g.e3();g._03=0,g._13=0,g._23=0;var y=r.getProjectionMatrices()[1].mult(g);n.modelViewProjectionMatrix2=y.toGL(),g._03=v.x,g._13=v.y,g._23=v.z,n.isVR=1}s.setVertexAttribEyeIdx(e,n),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t._webgl.buffers[x3dom.BUFFER_IDX.INDEX]),e.bindBuffer(e.ARRAY_BUFFER,t._webgl.buffers[x3dom.BUFFER_IDX.POSITION]),e.vertexAttribPointer(n.position,3,e.FLOAT,!1,0,0),e.enableVertexAttribArray(n.position),s.drawElements(e,t._webgl.primType,t._webgl.indexes.length,e.UNSIGNED_SHORT,0),e.disableVertexAttribArray(n.position),s.disableVertexAttribEyeIdx(e,n),e.activeTexture(e.TEXTURE0),t._webgl.texture.textureCubeReady?e.bindTexture(e.TEXTURE_CUBE_MAP,null):e.bindTexture(e.TEXTURE_2D,null),e.clear(e.DEPTH_BUFFER_BIT)}}},e.prototype.setupFgnds=function(e,t){if(void 0===t._fgnd){var i=this;t._fgnd={},t._fgnd._webgl={positions:[-1,-1,0,-1,1,0,1,-1,0,1,1,0],indexes:[0,1,2,3],buffers:[{},{}]},t._fgnd._webgl.primType=e.TRIANGLE_STRIP,t._fgnd._webgl.shader=this.cache.getShader(e,x3dom.shader.FRONTGROUND_TEXTURE);var o=t._fgnd._webgl.shader,s=e.createBuffer();t._fgnd._webgl.buffers[x3dom.BUFFER_IDX.POSITION]=s,e.bindBuffer(e.ARRAY_BUFFER,s);var r=new Float32Array(t._fgnd._webgl.positions);e.bufferData(e.ARRAY_BUFFER,r,e.STATIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,s),e.vertexAttribPointer(o.position,3,e.FLOAT,!1,0,0);var n=e.createBuffer();t._fgnd._webgl.buffers[x3dom.BUFFER_IDX.INDEX]=n;var a=new Uint16Array(t._fgnd._webgl.indexes);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n),e.bufferData(e.ELEMENT_ARRAY_BUFFER,a,e.STATIC_DRAW),r=null,a=null,t._fgnd._webgl.render=function(e,s){t._fgnd._webgl.texture=s,i.stateManager.frontFace(e.CCW),i.stateManager.disable(e.CULL_FACE),i.stateManager.disable(e.DEPTH_TEST),i.stateManager.useProgram(o),o.tex||(o.tex=0),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,t._fgnd._webgl.texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t._fgnd._webgl.buffers[x3dom.BUFFER_IDX.INDEX]),e.bindBuffer(e.ARRAY_BUFFER,t._fgnd._webgl.buffers[x3dom.BUFFER_IDX.POSITION]),e.vertexAttribPointer(o.position,3,e.FLOAT,!1,0,0),e.enableVertexAttribArray(o.position),i.drawElements(e,t._fgnd._webgl.primType,t._fgnd._webgl.indexes.length,e.UNSIGNED_SHORT,0,1),e.disableVertexAttribArray(o.position),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,null)}}},e.prototype.renderShadowPass=function(e,t,i,o,s,r,n){var a=t._scene,d=!1;this.stateManager.bindFramebuffer(e.FRAMEBUFFER,s.fbo),this.stateManager.viewport(0,0,s.width,s.height),e.clearColor(1,1,1,0),e.clearDepth(1),e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT),this.stateManager.depthFunc(e.LEQUAL),this.stateManager.enable(e.DEPTH_TEST),this.stateManager.enable(e.CULL_FACE),this.stateManager.disable(e.BLEND);x3dom.fields.SFVec3f.NullVector.toGL(),x3dom.fields.SFVec3f.OneVector.toGL();var l,h=a.getEnvironment()._vf.shadowExcludeTransparentObjects,f=a.drawableCollection.length;for(l=0;l0||p.popGeometry>0))for(R=0,N=0,D=x._vf.vertexCount.length;R>>8)/255,A.from=s.toGL(),A.sceneSize=r,0!=F.binaryGeometry&&1==E._vf.idsPerVertex&&(A.shadowIDs=b._vf.idOffset+x3dom.nodeTypes.Shape.objectID+2),F.coordType!=e.FLOAT&&(!F.popGeometry&&x3dom.Utils.isUnsignedType(E._vf.coordType)?A.bgCenter=E.getMin().toGL():A.bgCenter=E._vf.position.toGL(),A.bgSize=E._vf.size.toGL(),A.bgPrecisionMax=E.getPrecisionMax(\"coordType\")),1==n&&F.colorType!=e.FLOAT&&(A.bgPrecisionColMax=E.getPrecisionMax(\"colorType\")),2==n&&F.texCoordType!=e.FLOAT&&(A.bgPrecisionTexMax=E.getPrecisionMax(\"texCoordType\")),b._clipPlanes){A.modelViewMatrix=i.mult(T).toGL(),A.viewMatrixInverse=i.inverse().toGL(),2==this.VRMode&&(A.modelViewMatrix2=w.mult(T).toGL(),A.viewMatrixInverse2=w.inverse().toGL());for(var D=0;D0||F.popGeometry>0))for(G=0,H=0,z=E._vf.vertexCount.length;G0)this.drawElements(e,F.primType[0],E._vf.vertexCount[0],F.indexType,b._indexOffset);else if(F.bufferGeometry<0)this.drawArrays(e,F.primType[0],0,E._vf.vertexCount[0]);else if(E.hasIndexOffset()){var W=b.tessellationProperties();for(G=0,z=W.length;G65535?(me=new Uint32Array(h._webgl.indexes[ce]),h._webgl.indexType=d.UNSIGNED_INT):(me=new Uint16Array(h._webgl.indexes[ce]),h._webgl.indexType=d.UNSIGNED_SHORT),d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,c.buffers[_e+x3dom.BUFFER_IDX.INDEX]),d.bufferData(d.ELEMENT_ARRAY_BUFFER,me,d.DYNAMIC_DRAW),me=null}d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,c.buffers[_e+x3dom.BUFFER_IDX.INDEX]),l=!0}this.setVertexAttribEyeIdx(d,_),this.setVertexAttribPointerPosition(d,h,_e,ce),this.setVertexAttribPointerNormal(d,h,_e,ce),this.setVertexAttribPointerTexCoord(d,h,_e,ce),this.setVertexAttribPointerTexCoord2(d,h,_e,ce),this.setVertexAttribPointerColor(d,h,_e,ce),this.setVertexAttribPointerTangent(d,h,_e,ce),this.setVertexAttribPointerBinormal(d,h,_e,ce),void 0===_.id&&void 0===_.particleSize||!h._webgl.buffers[_e+x3dom.BUFFER_IDX.ID]||(d.bindBuffer(d.ARRAY_BUFFER,h._webgl.buffers[_e+x3dom.BUFFER_IDX.ID]),0!=c.binaryGeometry&&1==x._vf.idsPerVertex?(d.vertexAttribPointer(_.id,1,d.FLOAT,!1,4,0),d.enableVertexAttribArray(_.id)):he&&(d.vertexAttribPointer(_.particleSize,3,d.FLOAT,!1,0,0),d.enableVertexAttribArray(_.particleSize))),0!=c.popGeometry&&c.buffers[_e+x3dom.BUFFER_IDX.ID]&&(d.bindBuffer(d.ARRAY_BUFFER,c.buffers[_e+x3dom.BUFFER_IDX.ID]),d.vertexAttribPointer(_.PG_vertexID,1,d.FLOAT,!1,4,0),d.enableVertexAttribArray(_.PG_vertexID));var Te,be=t.getRenderMode(),Se=!!S&&(S._vf.transparency>0&&!h.isSolid()),Fe=function(e,t){e.frontFace(h.isCCW()?d.CCW:d.CW),e.enable(d.CULL_FACE),e.cullFace(d.FRONT),t(),e.cullFace(d.BACK),t(),e.disable(d.CULL_FACE)};if(be>0){var Ee=1==be?d.POINTS:d.LINES;if(l&&(c.binaryGeometry>0||c.popGeometry>0))for(se=0,ne=0,re=x._vf.vertexCount.length;se0)this.drawElements(d,c.primType[0],x._vf.vertexCount[0],c.indexType,h._indexOffset);else if(c.bufferGeometry<0)this.drawArrays(d,c.primType[0],0,x._vf.vertexCount[0]);else if(x.hasIndexOffset())for(se=0,re=(Te=h.tessellationProperties()).length;se0||c.popGeometry>0))for(se=0,ne=0,re=x._vf.vertexCount.length;se0)this.drawElements(d,c.primType[0],x._vf.vertexCount[0],c.indexType,h._indexOffset);else if(c.bufferGeometry<0)this.drawArrays(d,c.primType[0],0,x._vf.vertexCount[0]);else if(x.hasIndexOffset())for(se=0,re=(Te=h.tessellationProperties()).length;se0){var h=s.getViewpoint(),f=h.getImgPlaneHeightAtDistOne(),u=h.getNear(),c=r.multMatrixPnt(t._vf.position),_=.5*r.multMatrixVec(t._vf.size).length(),m=2*(.5*r.multMatrixVec(t._vf.maxBBSize).length())/(d*(Math.max(-c.z-_,u)*(f/n._height)));l=(l=Math.ceil(Math.log(m)/.693147180559945))<1?1:l>16?16:l}var p=t._vf.minPrecisionLevel,x=t._vf.maxPrecisionLevel;l=-1!=p&&lx?x:l;var g=o.levelsAvailable4?(d=s,l=r):(d=e._last_mat_view,l=e._last_mat_scene);var u=x3dom.fields.SFVec3f.copy(n._lastMin),c=x3dom.fields.SFVec3f.copy(n._lastMax),_=d.inverse().e3(),m=x3dom.fields.SFVec3f.copy(_),p=x3dom.fields.SFVec3f.copy(_);m.x>u.x&&(m.x=u.x),m.y>u.y&&(m.y=u.y),m.z>u.z&&(m.z=u.z),p.x0&&T>>8,255&o);if(R>=v){var O;R-=v;var B=t*e._inverseDevicePixelRatio,U=i*e._inverseDevicePixelRatio;if(4!=f?(e._pickingInfo.pickPos=C,e._pick.setValues(C),e._pickingInfo.pickNorm=A,e._pickNorm.setValues(A),e._pickingInfo.pickObj=null,e._pickingInfo.lastClickObj=null,O=n._xmlNode):(e._pickingInfo.pickObj=x3dom.nodeTypes.Shape.idMap.nodeID[T],O=e._pickingInfo.pickObj._xmlNode),I=e._pickingInfo.shadowObjectId!=R,e._pickingInfo.lastShadowObjectId=e._pickingInfo.shadowObjectId,e._pickingInfo.shadowObjectId=R,(I||L)&&n._xmlNode&&(n._xmlNode[\"on\"+V]||n._xmlNode.hasAttribute(\"on\"+V)||n._listeners[V])&&(P={target:n._xmlNode,type:V,button:L,mouseup:o>>>8>0,layerX:B,layerY:U,shadowObjectId:R,worldX:C.x,worldY:C.y,worldZ:C.z,normalX:A.x,normalY:A.y,normalZ:A.z,hitPnt:C.toGL(),hitObject:O,cancelBubble:!1,stopPropagation:function(){this.cancelBubble=!0},preventDefault:function(){this.cancelBubble=!0}},n.callEvtHandler(\"on\"+V,P)),n._shadowIdMap&&n._shadowIdMap.mapping&&R>>8>0,layerX:B,layerY:U,shadowObjectId:e._pickingInfo.shadowObjectId,cancelBubble:!1,stopPropagation:function(){this.cancelBubble=!0},preventDefault:function(){this.cancelBubble=!0}},n.callEvtHandler(\"on\"+V,P)),R>0?(e._pickingInfo.pickPos=C,e._pickingInfo.pickNorm=A,e._pickingInfo.pickObj=x3dom.nodeTypes.Shape.idMap.nodeID[R]):(e._pickingInfo.pickObj=null,e._pickingInfo.lastClickObj=null)}var H=x3dom.Utils.stopMeasure(\"picking\");return this.x3dElem.runtime.addMeasurement(\"PICKING\",H),!0},e.prototype.pickRect=function(e,t,i,o,s){var r=this.ctx3d,n=e?e._scene:null;if(!(r&&n&&n._webgl&&n.drawableCollection))return!1;var a,d=e._last_mat_view.inverse().e3(),l=n._lastMax.subtract(n._lastMin).length(),h=t<=o?t:o,f=i>=s?i:s,u=(1+Math.abs(o-t))*n._webgl.pickScale,c=(1+Math.abs(s-i))*n._webgl.pickScale;this.renderPickingPass(r,n,e._last_mat_view,e._last_mat_scene,d,l,0,h,f,u<1?1:u,c<1?1:c);var _=[];for(a=0;n._webgl.fboPick.pixelData&&a0&&_.push(m)}_.sort(),_=function(e){for(var t=[],i=e.length,o=0;o=g?m-=g:(p=(p=x3dom.nodeTypes.Shape.idMap.nodeID[m])&&p._xmlNode?p._xmlNode:null)&&x.push(p);return x},e.prototype.renderScene=function(e,t){var i=this.ctx3d,o=e._scene;if(null!==i&&null!==o){var s,r,n,a,d,l,h,f,u,c,_,m=e._doc._nodeBag.renderTextures,p=m.length,x=null,g=i.UNSIGNED_BYTE,v=i.UNSIGNED_BYTE;x3dom.caps.FP_TEXTURES&&(g=i.FLOAT,v=i.FLOAT,x3dom.caps.FPL_TEXTURES||!0);var y=[-1,-1,1,-1,-1,1,-1,1,1,-1,1,1];if(o.updateVolume(),o._webgl){var T=Math.round(this.canvas.width*o._webgl.pickScale),b=Math.round(this.canvas.height*o._webgl.pickScale);for(o._webgl._currFboWidth===T&&o._webgl._currFboHeight===b||(o._webgl._currFboWidth=T,o._webgl._currFboHeight=b,o._webgl.fboPick=x3dom.Utils.initFBO(i,T,b,o._webgl.fboPick.type,!1,!0),o._webgl.fboPick.pixelData=null,x3dom.debug.logInfo(\"Refreshed picking FBO to size (\"+T+\", \"+b+\")\")),r=0;r0)&&void 0===o._webgl.fboScene||o._webgl.fboScene&&(this.canvas.width!=o._webgl.fboScene.width||this.canvas.height!=o._webgl.fboScene.height))&&(o._webgl.fboScene=x3dom.Utils.initFBO(i,this.canvas.width,this.canvas.height,v,!1,!0))}else{for(o._webgl={},this.setupFgnds(i,o),o._webgl.pickScale=.5,o._webgl._currFboWidth=Math.round(this.canvas.width*o._webgl.pickScale),o._webgl._currFboHeight=Math.round(this.canvas.height*o._webgl.pickScale),o._webgl.fboPick=x3dom.Utils.initFBO(i,o._webgl._currFboWidth,o._webgl._currFboHeight,i.UNSIGNED_BYTE,!1,!0),o._webgl.fboPick.pixelData=null,o._webgl.normalShader=this.cache.getShader(i,x3dom.shader.NORMAL),o._webgl.fboShadow=[],h=(n=e.getShadowedLights()).length,d=0;d0||x3dom.SSAO.isEnabled(o))&&(o._webgl.fboScene=x3dom.Utils.initFBO(i,this.canvas.width,this.canvas.height,v,!1,!0)),o._webgl.fboBlur=[],d=0;d0){var W=H[j],Y=o._webgl.fboShadow[z],q=Math.max(0,Math.min(1,U[j]._vf.shadowOffset));if(x3dom.isa(U[j],x3dom.nodeTypes.PointLight))for(B=e.getWCtoLCMatricesPointLight(W,U[j],E),d=0;d<6;d++)this.renderShadowPass(i,e,B[d],M,Y[d],q,!1);else{var Q=Math.max(1,Math.min(U[j]._vf.shadowCascades,6));for(B=e.getWCtoLCMatricesCascaded(W,U[j],E),d=0;d0||x3dom.SSAO.isEnabled(o)){this.renderShadowPass(i,e,P,M,o._webgl.fboScene,0,!0);var K=x3dom.Utils.stopMeasure(\"shadow\");this.x3dElem.runtime.addMeasurement(\"SHADOW\",K)}else this.x3dElem.runtime.removeMeasurement(\"SHADOW\");for(B=e.getWCtoLCMatrix(e.getLightMatrix()[0]),r=0;r0&&this.renderShadows(i,e,n,k,G,M,E,P),this.stateManager.disable(i.BLEND),this.stateManager.disable(i.DEPTH_TEST),e._numRenderedNodes=h,x3dom.SSAO.isEnabled(o)&&x3dom.SSAO.renderSSAO(this.stateManager,i,o,this.canvas),void 0!==e._visDbgBuf&&e._visDbgBuf){var J=o._vf.pickMode.toLowerCase();0!=J.indexOf(\"idbuf\")&&\"color\"!=J&&\"texcoord\"!=J||(this.stateManager.viewport(0,3*this.canvas.height/4,this.canvas.width/4,this.canvas.height/4),o._fgnd._webgl.render(i,o._webgl.fboPick.tex)),(z>0||x3dom.SSAO.isEnabled(o))&&(this.stateManager.viewport(this.canvas.width/4,3*this.canvas.height/4,this.canvas.width/4,this.canvas.height/4),o._fgnd._webgl.render(i,o._webgl.fboScene.tex));var $=3,ee=2;for(d=0;d1&&(a.lastTex=1,e.activeTexture(e.TEXTURE1),e.bindTexture(e.TEXTURE_2D,i._webgl.fbo.tex),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)),a.curTex=2,e.activeTexture(e.TEXTURE2),e.bindTexture(e.TEXTURE_2D,i._webgl.texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),a.mode=i._currLoadLevel-1,a.repeat=i._repeat.toGL(),e.drawArrays(e.TRIANGLES,0,6),this.stateManager.bindFramebuffer(e.FRAMEBUFFER,i._webgl.fbo.fbo),e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT),a.mode=0,a.curTex=2,e.activeTexture(e.TEXTURE2),e.bindTexture(e.TEXTURE_2D,r.tex),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.drawArrays(e.TRIANGLES,0,6),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,null),e.disableVertexAttribArray(a.position),this.stateManager.bindFramebuffer(e.FRAMEBUFFER,null),this.stateManager.viewport(0,0,this.canvas.width,this.canvas.height),i._vf.autoRefinement&&i.nextLevel(),i._currLoadLevel==i._vf.maxLevel&&i._currLoadLevel++,i._webgl.fbo.mipMap&&(e.bindTexture(e.TEXTURE_2D,i._webgl.fbo.tex),e.generateMipmap(e.TEXTURE_2D),e.bindTexture(e.TEXTURE_2D,null)),i.requirePingPong()||(e.deleteTexture(i._webgl.texture),delete i._webgl.texture,i._cleanupGLObjects(!0)),i._renderedImage++}},e.prototype.renderRTPass=function(e,t,i){if(x3dom.isa(i,x3dom.nodeTypes.RefinementTexture))i.requirePingPong()&&this.renderPingPongPass(e,t,i);else{switch(i._vf.update.toUpperCase()){case\"NONE\":return;case\"NEXT_FRAME_ONLY\":if(!i._needRenderUpdate)return;i._needRenderUpdate=!1}var o,s,r=t._scene,n=null,a=i.getViewMatrix(),d=i.getProjectionMatrix(),l=d.mult(a),h=t.getLightMatrix()[0],f=t.getWCtoLCMatrix(h),u=i._cf.excludeNodes.nodes,c=u.length,_=new Array(c);for(o=0;o0||u.popGeometry>0)for(g=0,y=0,v=c._vf.vertexCount.length;g0)this.drawElements(e,u.primType[0],c._vf.vertexCount[0],u.indexType,f._indexOffset);else if(u.bufferGeometry<0)this.drawArrays(e,u.primType[0],0,c._vf.vertexCount[0]);else if(c.hasIndexOffset()){var b=f.tessellationProperties();for(g=0,v=b.length;gl&&(p[p.length]=u,m=7)}p[p.length]=i.length;var g=p.length-1,v=n.inverse(),y=a.inverse();this.stateManager.enable(e.BLEND),this.stateManager.blendFunc(e.DST_COLOR,e.ZERO);for(var T=0;T0?1:0;var M,C,A=this.cache.getShadowRenderingShader(e,F,E);this.stateManager.useProgram(A),e.bindBuffer(e.ARRAY_BUFFER,d._webgl.ppBuffer),e.vertexAttribPointer(A.position,2,e.FLOAT,!1,0,0),e.enableVertexAttribArray(A.position),A.sceneMap=0,e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,d._webgl.fboScene.tex),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),A.inverseProj=v.toGL(),A.inverseViewProj=y.toGL();for(var w=0,R=0,D=F.length;Rt.x?s[0]:t.x,t.y=s[1]>t.y?s[1]:t.y}return{x:e.x,y:e.y,width:t.x-e.x,height:t.y-e.y}},x3dom.Runtime.prototype.calcClientPos=function(e,t,i){var o=this.canvas.canvas.offsetParent;if(!o)return x3dom.debug.logError(\"Can't calc client pos without offsetParent.\"),[0,0];var s=o.getBoundingClientRect(),r=this.calcCanvasPos(e,t,i),n=document.defaultView.getComputedStyle(o,null),a=parseFloat(n.getPropertyValue(\"padding-left\")),d=parseFloat(n.getPropertyValue(\"border-left-width\")),l=parseFloat(n.getPropertyValue(\"padding-top\")),h=parseFloat(n.getPropertyValue(\"border-top-width\"));return[s.left+a+d+r[0],s.top+l+h+r[1]]},x3dom.Runtime.prototype.getScreenshot=function(){var e=\"\",t=this.canvas.backend,i=this.canvas.canvas;if(i)if(\"flash\"==t)e=i.getScreenshot();else{var o=document.createElement(\"canvas\");o.width=i.width,o.height=i.height;var s=o.getContext(\"2d\");s.drawImage(i,0,0,i.width,i.height),s.scale(1,-1),s.translate(0,-i.height),e=o.toDataURL()}return e},x3dom.Runtime.prototype.getCanvas=function(){return this.canvas.canvas},x3dom.Runtime.prototype.lightMatrix=function(){this.canvas.doc._viewarea.getLightMatrix()},x3dom.Runtime.prototype.resetView=function(){this.canvas.doc._viewarea.resetView()},x3dom.Runtime.prototype.lightView=function(){return this.canvas.doc._nodeBag.lights.length>0?(this.canvas.doc._viewarea.animateTo(this.canvas.doc._viewarea.getLightMatrix()[0],this.canvas.doc._scene.getViewpoint()),!0):(x3dom.debug.logInfo(\"No lights to navigate to.\"),!1)},x3dom.Runtime.prototype.uprightView=function(){this.canvas.doc._viewarea.uprightView()},x3dom.Runtime.prototype.fitAll=function(e){void 0===e&&(e=!0);var t=this.canvas.doc._scene;t.updateVolume(),this.canvas.doc._viewarea.fit(t._lastMin,t._lastMax,e)},x3dom.Runtime.prototype.fitObject=function(e,t){if(e&&e._x3domNode){void 0===t&&(t=!0);var i=x3dom.fields.SFVec3f.MAX(),o=x3dom.fields.SFVec3f.MIN();e._x3domNode.getVolume().getBounds(i,o);var s=e._x3domNode.getCurrentTransform();if(i=s.multMatrixPnt(i),o=s.multMatrixPnt(o),x3dom.isa(e._x3domNode,x3dom.nodeTypes.X3DTransformNode)){var r=e._x3domNode._trafo.inverse();i=r.multMatrixPnt(i),o=r.multMatrixPnt(o)}this.canvas.doc._viewarea.fit(i,o,t)}},x3dom.Runtime.prototype.showAll=function(e,t){this.canvas.doc._viewarea.showAll(e,t)},x3dom.Runtime.prototype.showObject=function(e,t){if(e&&e._x3domNode){void 0===t&&(t=\"negZ\");var i=x3dom.fields.SFVec3f.MAX(),o=x3dom.fields.SFVec3f.MIN();e._x3domNode.getVolume().getBounds(i,o);var s=e._x3domNode.getCurrentTransform();i=s.multMatrixPnt(i),o=s.multMatrixPnt(o);var r,n=this.canvas.doc._viewarea,a=n._widthx3dom.fields.Eps&&(a/=h);var f=n._width-1,u=n._height-1,c=.25,_=new x3dom.fields.SFVec2f(c*f,c*u);c=.75;var m=new x3dom.fields.SFVec2f(c*f,c*u),p=o.subtract(i).multiply(.5),x=p.length(),g=i.add(p),v=m.subtract(_).multiply(.5),y=1.5*v.length();v=v.add(_);var T=1;y>x3dom.fields.Eps&&(T=x/y*Math.sqrt(v.x*v.x+v.y*v.y+a*a)),r=(r=s.multMatrixVec(r).normalize()).multiply(T);var b=g.add(r),S=x3dom.fields.Quaternion.rotateFromTo(new x3dom.fields.SFVec3f(0,0,1),r).toMatrix(),F=x3dom.fields.SFMatrix4f.translation(b.negate()),E=x3dom.fields.SFMatrix4f.translation(b),M=(E=E.mult(S).mult(F).mult(E)).inverse();n.animateTo(M,d)}},x3dom.Runtime.prototype.animateViewpointTo=function(e,t){var i=this.canvas.doc._viewarea,o=this.canvas.doc._scene.getViewpoint();null!=e._x3domNode&&(e=e._x3domNode),i.animateTo(e,o,t)},x3dom.Runtime.prototype.getCenter=function(e){return e&&e._x3domNode&&(this.isA(e,\"X3DShapeNode\")||this.isA(e,\"X3DGeometryNode\"))?e._x3domNode.getCenter():null},x3dom.Runtime.prototype.getCurrentTransform=function(e){return e&&e._x3domNode?e._x3domNode.getCurrentTransform():null},x3dom.Runtime.prototype.getBBox=function(e){if(e&&e._x3domNode&&this.isA(e,\"X3DBoundedObject\")){var t=e._x3domNode.getVolume();return{min:x3dom.fields.SFVec3f.copy(t.min),max:x3dom.fields.SFVec3f.copy(t.max)}}return null},x3dom.Runtime.prototype.getSceneBBox=function(){var e=this.canvas.doc._scene;return e.updateVolume(),{min:x3dom.fields.SFVec3f.copy(e._lastMin),max:x3dom.fields.SFVec3f.copy(e._lastMax)}},x3dom.Runtime.prototype.debug=function(e){var t=this.canvas.doc;return void 0===t._viewarea._visDbgBuf&&(t._viewarea._visDbgBuf=\"true\"===t._x3dElem.getAttribute(\"showLog\")),arguments.length>0?!0===e?(t._viewarea._visDbgBuf=!0,x3dom.debug.logContainer.style.display=\"block\"):(t._viewarea._visDbgBuf=!1,x3dom.debug.logContainer.style.display=\"none\"):(t._viewarea._visDbgBuf=!t._viewarea._visDbgBuf,x3dom.debug.logContainer.style.display=1==t._viewarea._visDbgBuf?\"block\":\"none\"),t.needRender=!0,t._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 e=this.canvas.doc._viewarea;e._rotMat=x3dom.fields.SFMatrix4f.identity(),e._transMat=x3dom.fields.SFMatrix4f.identity(),e._movement=new x3dom.fields.SFVec3f(0,0,0),e._needNavigationMatrixUpdate=!0,this.canvas.doc.needRender=!0},x3dom.Runtime.prototype.disableKeys=function(){this.canvas.disableKeys=!0},x3dom.Runtime.prototype.enableKeys=function(){this.canvas.disableKeys=!1},x3dom.Runtime.prototype.disableLeftDrag=function(){this.canvas.disableLeftDrag=!0},x3dom.Runtime.prototype.enableLeftDrag=function(){this.canvas.disableLeftDrag=!1},x3dom.Runtime.prototype.disableRightDrag=function(){this.canvas.disableRightDrag=!0},x3dom.Runtime.prototype.enableRightDrag=function(){this.canvas.disableRightDrag=!1},x3dom.Runtime.prototype.disableMiddleDrag=function(){this.canvas.disableMiddleDrag=!0},x3dom.Runtime.prototype.enableMiddleDrag=function(){this.canvas.disableMiddleDrag=!1},x3dom.Runtime.prototype.togglePoints=function(e){var t=this.canvas.doc,i=!0===e?3:2;return t._viewarea._points=++t._viewarea._points%i,t.needRender=!0,t._viewarea._points},x3dom.Runtime.prototype.pickRect=function(e,t,i,o){return this.canvas.doc.onPickRect(this.canvas.gl,e,t,i,o)},x3dom.Runtime.prototype.pickMode=function(e){return e&&!0===e.internal?this.canvas.doc._scene._vf.pickMode:this.canvas.doc._scene._vf.pickMode.toLowerCase()},x3dom.Runtime.prototype.changePickMode=function(e){switch(e=e.toLowerCase()){case\"idbuf\":e=\"idBuf\";break;case\"idbuf24\":e=\"idBuf24\";break;case\"idbufid\":e=\"idBufId\";break;case\"texcoord\":e=\"texCoord\";break;case\"color\":e=\"color\";break;case\"box\":e=\"box\";break;default:x3dom.debug.logWarning(\"Switch pickMode to \"+e+\" unknown intersect type\"),e=void 0}return void 0!==e&&(this.canvas.doc._scene._vf.pickMode=e,x3dom.debug.logInfo(\"Switched pickMode to '\"+e+\"'.\"),!0)},x3dom.Runtime.prototype.speed=function(e){var t=this.canvas.doc._scene.getNavigationInfo();return e&&(t._vf.speed=e,x3dom.debug.logInfo(\"Changed navigation speed to \"+t._vf.speed)),t._vf.speed},x3dom.Runtime.prototype.zoom=function(e){this.canvas.doc._viewarea.zoom(e),this.canvas.doc.needRender=!0},x3dom.Runtime.prototype.statistics=function(e){var t=this.canvas.stateViewer;return!!t&&(this.canvas.doc.needRender=!0,!0===e?(t.display(e),!0):!1===e?(t.display(e),!1):(t.display(!t.active),t.active))},x3dom.Runtime.prototype.processIndicator=function(e){var t=this.canvas.progressDiv;return!!t&&(!0===e?(t.style.display=\"flex\",!0):!1===e?(t.style.display=\"none\",!1):\"none\"!=t.style.display)},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(e,t){var i=!1;return t&&e&&e._x3domNode&&(\"\"===t&&(t=\"X3DNode\"),i=x3dom.isa(e._x3domNode,x3dom.nodeTypesLC[t.toLowerCase()])),i},x3dom.Runtime.prototype.getPixelScale=function(){var e=this.viewpoint();if(!x3dom.isa(e,x3dom.nodeTypes.OrthoViewpoint))return x3dom.debug.logError(\"getPixelScale is only implemented for orthographic Viewpoints\"),null;var t=e.getZoom(),i=t[0],o=t[1],s=t[2],r=t[3]-o,n=(s-i)/this.getWidth(),a=r/this.getHeight();return new x3dom.fields.SFVec3f(n,a,0)},x3dom.Runtime.prototype.onAnimationStarted=function(){},x3dom.Runtime.prototype.onAnimationFinished=function(){},x3dom.Runtime.prototype.enterVR=function(){this.canvas.enterVR()},x3dom.Runtime.prototype.exitVR=function(){this.canvas.exitVR()},x3dom.Runtime.prototype.toggleVR=function(){this.canvas.xrSession?this.canvas.xrSession&&this.exitVR():this.enterVR()},x3dom.Runtime.prototype.toggleProjection=function(e,t){var i,o=document.getElementById(\"x3d\").runtime.canvas.doc._scene.getNavigationInfo(),s=o._vf.transitionTime,r=document.getElementById(e)._x3domNode,n=document.getElementById(t)._x3domNode;if(o._vf.transitionTime=0,n._bindAnimation=!1,r._bindAnimation=!1,r._vf.isActive)n._viewMatrix=r._viewMatrix,document.getElementById(t).setAttribute(\"set_bind\",\"true\"),i=r._viewMatrix.e3().length()/2.2,n.setZoom(i);else if(n._vf.isActive){r._viewMatrix=n._viewMatrix,document.getElementById(e).setAttribute(\"set_bind\",\"true\"),i=-2.2*n._fieldOfView[2];var a=n._viewMatrix.e2().normalize().multiply(i);r._viewMatrix.setTranslate(a)}return o._vf.transitionTime=s,n._bindAnimation=!0,r._bindAnimation=!0,r._vf.isActive?0:1},x3dom.Runtime.prototype.replaceWorld=function(e){var t,i,o;for(t=\"X3D\"===e.localName.toUpperCase()?e.cloneNode(!1):this.doc.cloneNode(!1);i=e.firstChild;)\"HEAD\"==(o=1===i.nodeType?i.localName.toUpperCase():null)||\"SCENE\"==o?t.appendChild(i):i.remove();this.doc.parentNode.replaceChild(t,this.doc),this.doc=t,x3dom.reload()},x3dom.Runtime.prototype.createX3DFromJS=function(e,t){return t&&(e=x3dom.protoExpander.prototypeExpander(t,e)),(new x3dom.JSONParser).parseJavaScript(e)},x3dom.Runtime.prototype.createX3DFromString=function(e,t){try{var i=JSON.parse(e);return this.createX3DFromJS(i,t)}catch(t){var o=new DOMParser,s=o.parseFromString(e,\"application/xml\"),r=s.querySelector(\"X3D\");return null==r&&(r=(s=o.parseFromString(e,\"text/html\")).querySelector(\"X3D\")),r}},x3dom.Runtime.prototype.createX3DFromURLPromise=function(e,t){this.canvas.doc.incrementDownloads();var i=this;return fetch(e).then((function(e){return e.text()})).then((function(e){return i.canvas.doc.decrementDownloads(),i.createX3DFromString(e,t)})).catch((function(e){return i.canvas.doc.decrementDownloads(),x3dom.debug.logError(\"fetch failed: \"+e),null}))},x3dom.Runtime.prototype.loadURL=function(e,t){var i=this;this.createX3DFromURLPromise(e,t).then((function(t){null!=t?i.replaceWorld(t):x3dom.debug.logError(\"loadURL: could not fetch or parse \"+e)}))},x3dom.userAgentFeature={supportsDOMAttrModified:!1,supportsMutationObserver:!0},function(){\"use strict\";var e=function(){var e,t,i,o=document.getElementsByTagName(\"X3D\"),s=[];for(e=0;e\"+x3dom.about.revision+\", Date: \"+x3dom.about.date),x3dom.debug.logInfo(\"Found \"+s.length+\" X3D and nodes...\"),e=0;e0&&x3dom.canvases[0].doc){for(var e=0;e2.3&&(r=2.3)}var _,m,p=this.node._vf.string,x=this.node._vf.maxExtent,g=[],v=s,y=document.createElement(\"canvas\");y.dir=h;var T=32*r;document.body.appendChild(y);var b=y.getContext(\"2d\");b.font=o+\" \"+T+\"px \"+i;var S,F,E,M=0;for(E=0;EM&&(M=S),F=0|this.node._vf.length[E],x>0&&(F>x||0==F)&&(F=x),g[E]=F<=0?S:32*F;var C=.25*T,A=M+C,w=T+T*n*(p.length-1)+C;_=0,m=0;var R=0,D=0,N=\"alphabetic\";switch(s){case\"center\":R=-A/2,_=A/2;break;case\"left\":R=0,_=0;break;case\"right\":R=-A,_=A}switch(d){case\"MIDDLE\":D=w/2-C/2,N=\"middle\",m=T/2;break;case\"BEGIN\":D=f?0:w-C,N=f?\"top\":\"bottom\",m=f?0:T;break;case\"FIRST\":D=f?T:w-C,N=f?\"alphabetic\":\"bottom\",m=T;break;case\"END\":D=f?w-C:0,N=f?\"bottom\":\"top\",m=f?T:0}var I=A*(1/32),P=w*(1/32),V=x3dom.caps.MAX_TEXTURE_SIZE>>2;R*=1/32,D*=1/32,y.width=Math.min(x3dom.Utils.nextHighestPowerOfTwo(A*a),V),y.height=Math.min(x3dom.Utils.nextHighestPowerOfTwo(w*a),V),y.dir=h,b.scale(y.width/A,y.height/w),b.fillStyle=\"rgba(0,0,0,0)\",b.fillRect(0,0,b.canvas.width,b.canvas.height),b.fillStyle=\"white\",b.textBaseline=N,b.font=o+\" \"+T+\"px \"+i,b.textAlign=v;var L={font_style:o,font_family:i,font_spacing:n,paragraph:p,topToBottom:f,leftToRight:h,textX:_,textY:m,textHeight:T,lengths:g};this.renderScaledText(b,1,L),null===this.texture&&(this.texture=e.createTexture()),e.bindTexture(this.type,this.texture),this.uploadTextMipmap(y,L),e.bindTexture(this.type,null),document.body.removeChild(y),this.node._mesh._positions[0]=[0+R,-P+D,0,I+R,-P+D,0,I+R,0+D,0,0+R,0+D,0],this.node.invalidateVolume(),this.node._parentNodes.forEach((function(e){e.setAllDirty()}))},x3dom.Texture.prototype.renderScaledText=function(e,t,i){e.font=i.font_style+\" \"+i.textHeight/t+\"px \"+i.font_family;for(var o=i.textY,s=0;s>1),d=Math.max(1,d>>1),l.clearRect(0,0,o,s),n*=2,this.renderScaledText(l,n,t)},x3dom.X3DDocument=function(e,t,i){this.canvas=e,this.ctx=t,this.properties=i,this.needRender=!0,this._x3dElem=null,this._scene=null,this._viewarea=null,this.downloadCount=0,this.previousDownloadCount=0,this.mutationObserver=new MutationObserver(this.onMutation.bind(this)),this.X3DMutationObserver=new MutationObserver(this.onX3DMutation.bind(this)),this._nodeBag={timer:[],lights:[],clipPlanes:[],followers:[],trans:[],renderTextures:[],viewarea:[],affectedPointingSensors:[]},this.onload=function(){},this.onerror=function(){}},x3dom.X3DDocument.prototype.load=function(e,t){var i={},o=[e],s=this;!function r(){if(0===o.length)return s._setup(i[e],i,t),void s.onload();var n=o.shift();!x3dom.isX3DElement(n)||\"x3d\"!==n.localName.toLowerCase()&&\"websg\"!==n.localName.toLowerCase()||(i[n]=n,s._x3dElem=n,r())}()},x3dom.findScene=function(e){for(var t=[],i=0;i1?(x3dom.debug.logError(\"X3D element has more than one Scene child (has \"+e.childNodes.length+\").\"),null):t[0]},x3dom.X3DDocument.prototype._setup=function(e){var t=x3dom.findScene(e);this.X3DMutationObserver.observe(document,{attributes:!1,attributeOldValue:!1,childList:!0,subtree:!0}),this.mutationObserver.observe(e,{attributes:!1,attributeOldValue:!1,childList:!0,subtree:!1}),this.mutationObserver.observe(t,{attributes:!0,attributeOldValue:!0,childList:!0,subtree:!0}),this._bindableBag=new x3dom.BindableBag(this);var i=new x3dom.NodeNameSpace(\"scene\",this).setupTree(t);this._scene=i,this._bindableBag.setRefNode(i),this._viewarea=new x3dom.Viewarea(this,i),this._viewarea._width=this.canvas.width,this._viewarea._height=this.canvas.height},x3dom.X3DDocument.prototype.advanceTime=function(e){var t=0;if(this._nodeBag.timer.length)for(t=0;t0&&this._viewarea.animateTo(this._viewarea.getLightMatrix()[0],this._scene.getViewpoint());break;case 117:this._viewarea.uprightView();break;case 118:var s=this;!function(){var e=s._viewarea._scene.getViewpoint(),t=s._viewarea.getViewMatrix().inverse(),i=new x3dom.fields.Quaternion(0,0,1,0);i.setValue(t);var o=i.toAxisAngle(),r=t.e3(),n=e.getCenterOfRotation();x3dom.debug.logInfo('\\n<Viewpoint position=\"'+r.x.toFixed(5)+\" \"+r.y.toFixed(5)+\" \"+r.z.toFixed(5)+'\" orientation=\"'+o[0].x.toFixed(5)+\" \"+o[0].y.toFixed(5)+\" \"+o[0].z.toFixed(5)+\" \"+o[1].toFixed(5)+'\" \\n\\tzNear=\"'+e.getNear().toFixed(5)+'\" zFar=\"'+e.getFar().toFixed(5)+'\" centerOfRotation=\"'+n.x.toFixed(5)+\" \"+n.y.toFixed(5)+\" \"+n.z.toFixed(5)+'\" fieldOfView=\"'+e.getFieldOfView().toFixed(5)+'\" description=\"'+e._vf.description+'\"></Viewpoint>')}();break;case 119:t.setType(\"walk\",this._viewarea);break;case 121:t.setType(\"freefly\",this._viewarea)}},x3dom.X3DDocument.prototype.shutdown=function(e){e&&e.shutdown(this._viewarea)},x3dom.X3DDocument.prototype.hasAnimationStateChanged=function(){return!!this._viewarea&&this._viewarea.hasAnimationStateChanged()},x3dom.X3DDocument.prototype.isAnimating=function(){return!!this._viewarea&&this._viewarea.isAnimating()},x3dom.X3DDocument.prototype.incrementDownloads=function(){this.downloadCount++},x3dom.X3DDocument.prototype.decrementDownloads=function(){this.downloadCount--},x3dom.X3DDocument.prototype.cleanNodeBag=function(e,t){for(var i=0,o=e.length;i0},x3dom.MatrixMixer.prototype.setBeginMatrix=function(e){this._beginMat.setValues(e),this._beginInvMat=e.inverse(),this._beginLogMat=x3dom.fields.SFMatrix4f.zeroMatrix()},x3dom.MatrixMixer.prototype.getBeginMatrix=function(e){return this._beginMat},x3dom.MatrixMixer.prototype.setEndMatrix=function(e){this._endMat.setValues(e),this._isValid()||this._prepareQuaternionAnimation(),this._endLogMat=this._endMat.mult(this._beginInvMat).log(),this._logDiffMat=this._endLogMat.addScaled(this._beginLogMat,-1)},x3dom.MatrixMixer.prototype.getEndMatrix=function(e){return this._endMat},x3dom.MatrixMixer.prototype._mixQuaternion=function(e){var t=this._beginRot.slerp(this._endRot,e),i=this._beginPos.addScaled(this._endPos.subtract(this._beginPos),e);return this._result.setRotate(t),this._result.setTranslate(i),this._result.copy()},x3dom.MatrixMixer.prototype._mixMatrix=function(e){return this._logDiffMat.multiply(e).add(this._beginLogMat).exp().mult(this._beginMat)},x3dom.MatrixMixer.prototype.mix=function(e){if(e<=this.beginTime)return this._beginMat;if(e>=this.endTime)return this.reset(),this._endMat;this.isMixing=!0;var t=this._calcFraction(e);return this._useQuaternion?this._mixQuaternion(t):this._mixMatrix(t)},x3dom.Mesh=function(e){this._parent=e,this._vol=new x3dom.fields.BoxVolume,this._invalidate=!0,this._numFaces=0,this._numCoords=0,this._primType=\"TRIANGLES\",this._positions=[],this._normals=[],this._texCoords=[],this._texCoords2=[],this._colors=[],this._indices=[],this._tangents=[],this._binormals=[],this._positions[0]=[],this._normals[0]=[],this._texCoords[0]=[],this._texCoords2[0]=[],this._colors[0]=[],this._indices[0]=[],this._tangents[0]=[],this._binormals[0]=[]},x3dom.Mesh.prototype._dynamicFields={},x3dom.Mesh.prototype._numPosComponents=3,x3dom.Mesh.prototype._numTexComponents=2,x3dom.Mesh.prototype._numTex2Components=2,x3dom.Mesh.prototype._numColComponents=3,x3dom.Mesh.prototype._numNormComponents=3,x3dom.Mesh.prototype._numTangentComponents=3,x3dom.Mesh.prototype._numBinormalComponents=3,x3dom.Mesh.prototype._lit=!0,x3dom.Mesh.prototype._vol=null,x3dom.Mesh.prototype._invalidate=!0,x3dom.Mesh.prototype._numFaces=0,x3dom.Mesh.prototype._numCoords=0,x3dom.Mesh.prototype.getVolume=function(){if(1==this._invalidate&&!this._vol.isValid()){var e=this._positions[0],t=e.length;if(t>=3){var i=new x3dom.fields.SFVec3f(e[0],e[1],e[2]);this._vol.setBounds(i,i);for(var o=3;oe[o]&&(this._vol.min.x=e[o]),this._vol.min.y>e[o+1]&&(this._vol.min.y=e[o+1]),this._vol.min.z>e[o+2]&&(this._vol.min.z=e[o+2]),this._vol.max.xf?this._posSize/3:f/3;for(c=3*(c-Math.floor(c)>0?Math.floor(c+1):c),i=0;ix3dom.fields.Eps)for(i=0;i=0;if(this._indices[u]=c?l.slice(u*s,(u+1)*s):l.slice(u*s),o)for(m=0,p=this._indices[u].length;m++u*s*3)}},x3dom.Mesh.prototype.calcTexCoords=function(e){if(this._texCoords[0]=[],\"sphere-local\"===e.toLowerCase())for(var t=0,i=0,o=this._normals[0].length;t=l.y?l.x>=l.z?(h=0,f=l.y>=l.z?1:2):(h=2,f=0):l.y>=l.z?(h=1,f=l.x>=l.z?0:2):(h=2,f=1);var u=1,c=0,_=0;switch(h){case 0:u=l.x,c=a.x;break;case 1:u=l.y,c=a.y;break;case 2:u=l.z,c=a.z}switch(f){case 0:l.x,_=a.x;break;case 1:l.y,_=a.y;break;case 2:l.z,_=a.z}for(s=0,r=0,n=this._positions[0].length;s\"+e+\"   \"+x3dom.nodeTypes[e]._compName+\"
\",x3dom.nodeTypes[e].childTypes[e])o(x3dom.nodeTypes[e].childTypes[e][s],i+1)};for(e in x3dom.nodeTypes){var s;for(void 0===(s=x3dom.nodeTypes[e]).childTypes&&(s.childTypes={});s.superClass;)void 0===s.superClass.childTypes[s.superClass._typeName]&&(s.superClass.childTypes[s.superClass._typeName]=[]),i(s.superClass.childTypes[s.superClass._typeName],s._typeName)||s.superClass.childTypes[s.superClass._typeName].push(s._typeName),s=s.superClass}return o(\"X3DNode\",0),\"
\"+t+\"
\"},x3dom.docs.getComponentInfo=function(){var e,t,i,o=[],s=\"\";for(t in x3dom.components)o.push(t);for(i in o.sort(),o){for(var r in t=o[i],e=x3dom.components[t],s+=\"

\"+t+\"

\",s+=\"
    \",e){if(s+=\"
  • \"+r+\"
      \",!r.startsWith(\"X3D\")){try{var n=new x3dom.nodeTypes[r];for(var a in s+=\"-- basic fields --\",n._vf)s+=\"
    • \"+a+\": \"+n._vf[a],s+=\"
    • \"}catch(e){}try{for(var d in s+=\"-- node fields --\",n._cf)s+=\"
    • \"+d+\": \"+JSON.stringify(n._cf[d]),s+=\"
    • \"}catch(e){}}s+=\"
  • \"}s+=\"
\"}return s},x3dom.arc={},x3dom.arc.instance=null,x3dom.arc.Limits=function(e,t,i){this._min=e,this._max=t,this.getValue=function(e){return e=this._min+(this._max-this._min)*e,this._max>=e?this._min<=e?e:this._min:this._max}},x3dom.arc.ARF=function(e,t,i,o,s,r,n,a){this._name=e,this._stateValue=[.5,.5],this._limits=new x3dom.arc.Limits(t,i),this._factorGetterFunc=s,this._factorSetterFunc=r,this._setterFunc=a,this._getterFunc=n,this._dirFac=o,this.getFactor=function(){return this._factorGetterFunc()},this.update=function(e,t){var i=this._stateValue[e]+t*this._dirFac;this._stateValue[e]=0<=i?1>=i?i:1:0,this._setterFunc(this._limits.getValue(this._stateValue[e]))},this.reset=function(){this._stateValue[0]=.5,this._stateValue[1]=.5}},x3dom.arc.AdaptiveRenderControl=defineClass(null,(function(e){x3dom.arc.instance=this,this._scene=e,this._targetFrameRate=[],this._targetFrameRate[0]=this._scene._vf.minFrameRate,this._targetFrameRate[1]=this._scene._vf.maxFrameRate,this._currentState=0;var t=this._scene.getEnvironment();this._arfs=[],this._arfs.push(new x3dom.arc.ARF(\"smallFeatureCulling\",0,10,-1,(function(){return t._vf.smallFeatureFactor}),(function(e){t._vf.smallFeatureFactor=e}),(function(){return t._vf.smallFeatureThreshold}),(function(e){t._vf.smallFeatureThreshold=e}))),this._arfs.push(new x3dom.arc.ARF(\"lowPriorityCulling\",0,100,1,(function(){return t._vf.lowPriorityFactor}),(function(e){t._vf.lowPriorityFactor=e}),(function(){return 100*t._vf.lowPriorityThreshold}),(function(e){t._vf.lowPriorityThreshold=e/100}))),this._arfs.push(new x3dom.arc.ARF(\"tessellationDetailCulling\",1,12,-1,(function(){return t._vf.tessellationErrorFactor}),(function(e){t._vf.tessellationErrorFactor=e}),(function(){return t.tessellationErrorThreshold}),(function(e){t.tessellationErrorThreshold=e}))),this._stepWidth=.1}),{update:function(e,t){this._currentState=e;var i=t-this._targetFrameRate[e];this._stepWidth=Math.abs(i)>10?.1:.01;var o,s=0,r=[],n=this._arfs.length;for(o=0;o0&&(s+=r[o]);var a=i<0?-1:1;for(o=0;o0&&(r[o]/=s,this._arfs[o].update(e,this._stepWidth*r[o]*a))},reset:function(){for(var e=0,t=this._arfs.length;ethis.maxParallelRequests)){var e=this.requests.pop();e&&(this.activeRequests.push(e),e.send(null),this._sendRequest())}},x3dom.RequestManager._getCounters=function(){return{loaded:this.loadedRequests,active:this.activeRequests.length,failed:this.failedRequests,total:this.totalRequests}},x3dom.RequestManager.addRequest=function(e){if(e instanceof XMLHttpRequest){this.totalRequests++,e.withCredentials=this.withCredentials;for(var t=0;t1?(e.prev.next=e.next,e.next.prev=e.prev,e==this.first&&(this.first=e.next),e==this.last&&(this.last=e.prev)):(this.first=null,this.last=null),e.prev=null,e.next=null,this.length--},x3dom.DoublyLinkedList.prototype.getNode=function(e){var t=null;if(e>this.length)return t;for(var i=0;i0}(e,0,x,i),v=o(e,0,x,i,!0,g),y=[];if(!v)return y;p&&(v=function(e,t,i,r){var n,a,d,l,u,_=[];for(n=0,a=t.length;n80*i){n=d=e[0],a=l=e[1];for(var T=i;Td&&(d=u),_>l&&(l=_);m=Math.max(d-n,l-a)}r(v,y,i,n,a,m),!1===g&&y.reverse();return y}(e,t,i);function o(e,t,i,o,s,r){var n,a;if(s===r)for(n=t;n=t;n-=o)a=T(n,e[n],e[n+1],a);return a}function s(e,t){if(!e)return e;t||(t=e);var i,o=e;do{if(i=!1,o.steiner||!x(o,o.next)&&0!==p(o.prev,o,o.next))o=o.next;else{if(b(o),(o=t=o.prev)===o.next)return null;i=!0}}while(i||o!==t);return t}function r(e,t,i,o,h,f,c){if(e){!c&&f&&function(e,t,i,o){var s=e;do{null===s.z&&(s.z=u(s.x,s.y,t,i,o)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next}while(s!==e);s.prevZ.nextZ=null,s.prevZ=null,function(e){var t,i,o,s,r,n,a,d,l=1;do{for(i=e,e=null,r=null,n=0;i;){for(n++,o=i,a=0,t=0;t0||d>0&&o;)0===a?(s=o,o=o.nextZ,d--):0!==d&&o?i.z<=o.z?(s=i,i=i.nextZ,a--):(s=o,o=o.nextZ,d--):(s=i,i=i.nextZ,a--),r?r.nextZ=s:e=s,s.prevZ=r,r=s;i=o}r.nextZ=null,l*=2}while(n>1)}(s)}(e,o,h,f);for(var _,m,p=e;e.prev!==e.next;)if(_=e.prev,m=e.next,f?a(e,o,h,f):n(e))t.push(_.i/i),t.push(e.i/i),t.push(m.i/i),b(e),e=m.next,p=m.next;else if((e=m)===p){c?1===c?r(e=d(e,t,i),t,i,o,h,f,2):2===c&&l(e,t,i,o,h,f):r(s(e),t,i,o,h,f,1);break}}}function n(e){var t=e.prev,i=e,o=e.next;if(p(t,i,o)>=0)return!1;for(var s=e.next.next;s!==e.prev;){if(_(t.x,t.y,i.x,i.y,o.x,o.y,s.x,s.y)&&p(s.prev,s,s.next)>=0)return!1;s=s.next}return!0}function a(e,t,i,o){var s=e.prev,r=e,n=e.next;if(p(s,r,n)>=0)return!1;for(var a=s.xr.x?s.x>n.x?s.x:n.x:r.x>n.x?r.x:n.x,h=s.y>r.y?s.y>n.y?s.y:n.y:r.y>n.y?r.y:n.y,f=u(a,d,t,i,o),c=u(l,h,t,i,o),m=e.nextZ;m&&m.z<=c;){if(m!==e.prev&&m!==e.next&&_(s.x,s.y,r.x,r.y,n.x,n.y,m.x,m.y)&&p(m.prev,m,m.next)>=0)return!1;m=m.nextZ}for(m=e.prevZ;m&&m.z>=f;){if(m!==e.prev&&m!==e.next&&_(s.x,s.y,r.x,r.y,n.x,n.y,m.x,m.y)&&p(m.prev,m,m.next)>=0)return!1;m=m.prevZ}return!0}function d(e,t,i){var o=e;do{var s=o.prev,r=o.next.next;g(s,o,o.next,r)&&v(s,r)&&v(r,s)&&(t.push(s.i/i),t.push(o.i/i),t.push(r.i/i),b(o),b(o.next),o=e=r),o=o.next}while(o!==e);return o}function l(e,t,i,o,n,a){var d=e;do{for(var l=d.next.next;l!==d.prev;){if(d.i!==l.i&&m(d,l)){var h=y(d,l);return d=s(d,d.next),h=s(h,h.next),r(d,t,i,o,n,a),void r(h,t,i,o,n,a)}l=l.next}d=d.next}while(d!==e)}function h(e,t){return e.x-t.x}function f(e,t){if(t=function(e,t){var i,o=t,s=e.x,r=e.y,n=-1/0;do{if(r<=o.y&&r>=o.next.y){var a=o.x+(r-o.y)*(o.next.x-o.x)/(o.next.y-o.y);a<=s&&a>n&&(n=a,i=o.x=o.x&&o.x>=i.x&&_(ri.x)&&v(o,e)&&(i=o,h=d),o=o.next;return i}(e,t)){var i=y(t,e);s(i,i.next)}}function u(e,t,i,o,s){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-i)/s)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-o)/s)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function c(e){var t=e,i=e;do{t.x=0&&(e-n)*(o-a)-(i-n)*(t-a)>=0&&(i-n)*(r-a)-(s-n)*(o-a)>=0}function m(e,t){return x(e,t)||e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&g(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&v(e,t)&&v(t,e)&&function(e,t){var i=e,o=!1,s=(e.x+t.x)/2,r=(e.y+t.y)/2;do{i.y>r!=i.next.y>r&&s<(i.next.x-i.x)*(r-i.y)/(i.next.y-i.y)+i.x&&(o=!o),i=i.next}while(i!==e);return o}(e,t)}function p(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function x(e,t){return e.x===t.x&&e.y===t.y}function g(e,t,i,o){return p(e,t,i)>0!=p(e,t,o)>0&&p(i,o,e)>0!=p(i,o,t)>0}function v(e,t){return p(e.prev,e,e.next)<0?p(e,t,e.next)>=0&&p(e,e.prev,t)>=0:p(e,t,e.prev)<0||p(e,e.next,t)<0}function y(e,t){var i=new S(e.i,e.x,e.y),o=new S(t.i,t.x,t.y),s=e.next,r=t.prev;return e.next=t,t.prev=e,i.next=s,s.prev=i,o.next=i,i.prev=o,r.next=o,o.prev=r,o}function T(e,t,i,o){var s=new S(e,t,i);return o?(s.next=o.next,s.prev=o,o.next.prev=s,o.next=s):(s.prev=s,s.next=s),s}function b(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function S(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}}},x3dom.FieldInterpolator=function(e,t,i,o){this.beginTime=e||0,this.endTime=t||1,this.beginValue=i||0,this.endValue=o||0,this.isInterpolating=!1},x3dom.FieldInterpolator.prototype.isActive=function(){return this.beginTime>0},x3dom.FieldInterpolator.prototype.calcFraction=function(e){var t=(e-this.beginTime)/(this.endTime-this.beginTime);return(Math.sin(t*Math.PI-Math.PI/2)+1)/2},x3dom.FieldInterpolator.prototype.reset=function(){this.isInterpolating=!1,this.beginTime=0,this.endTime=1,this.beginValue=0,this.endValue=0},x3dom.FieldInterpolator.prototype.interpolate=function(e){if(e=this.endTime){var t=this.endValue;return this.reset(),t}return this.isInterpolating=!0,this.beginValue+(this.endValue-this.beginValue)*this.calcFraction(e)},x3dom.Utils={},x3dom.Utils.maxIndexableCoords=65535,x3dom.Utils.needLineWidth=!1,x3dom.Utils.measurements=[],window.performance=window.performance||{},performance.now=performance.now||performance.mozNow||performance.msNow||performance.oNow||performance.webkitNow||function(){return(new Date).getTime()},x3dom.Utils.startMeasure=function(e){var t=e.toUpperCase();x3dom.Utils.measurements[t]||(x3dom.Utils.measurements[t]=performance.now())},x3dom.Utils.stopMeasure=function(e){var t=e.toUpperCase();if(x3dom.Utils.measurements[t]){var i=x3dom.Utils.measurements[t];return delete x3dom.Utils.measurements[t],performance.now()-i}return 0},x3dom.Utils.isNumber=function(e){return!isNaN(parseFloat(e))&&isFinite(e)},x3dom.Utils.createTexture2D=function(e,t,i,o,s,r,n,a,d){a=a||!1;var l=e.createTexture(),h=new Uint8Array([0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255]);e.bindTexture(e.TEXTURE_2D,l),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,2,2,0,e.RGBA,e.UNSIGNED_BYTE,h),n&&e.generateMipmap(e.TEXTURE_2D),e.bindTexture(e.TEXTURE_2D,null),l.ready=!1;var f=0;if(null==i||\"\"==i)return l;var u=new Image;switch(s.toLowerCase()){case\"anonymous\":u.crossOrigin=\"anonymous\";break;case\"use-credentials\":u.crossOrigin=\"use-credentials\";break;case\"none\":break;default:x3dom.Utils.forbiddenBySOP(i)&&(u.crossOrigin=\"anonymous\")}var c=function(){if(d&&0===d.getOrigChannelCount()){var e=new XMLHttpRequest;e.open(\"GET\",i),e.onloadstart=function(){e.responseType=\"arraybuffer\"},e.onload=function(){var t=e.getResponseHeader(\"Content-Type\"),i=new Uint8Array(e.response),o=x3dom.Utils.detectChannelCount(i,t);o&&d.setOrigChannelCount(o),u.src=x3dom.Utils.arrayBufferToObjectURL(i,t)},e.onerror=function(){x3dom.debug.logError(\"[Utils|createTexture2D] Can't http request: \"+i),u.src=i},x3dom.RequestManager.addRequest(e)}else u.src=i;t.incrementDownloads()};return c(),u.onload=function(){l.originalWidth=u.width,l.originalHeight=u.height,r&&(u=x3dom.Utils.scaleImage(u)),1!=o&&1!=a||e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!0),e.bindTexture(e.TEXTURE_2D,l),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,u),n&&e.generateMipmap(e.TEXTURE_2D),e.bindTexture(e.TEXTURE_2D,null),1!=o&&1!=a||e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),l.width=u.width,l.height=u.height,l.ready=!0,t.decrementDownloads(),t.needRender=!0},u.onerror=function(o){x3dom.Utils.tryDDSLoading(l,e,t,i,n,a,d).then((function(){t.decrementDownloads(),t.needRender=!0}),(function(){x3dom.debug.logError(\"[Utils|createTexture2D] Can't load Image: \"+i),t.decrementDownloads(),f++,d&&f33779?t.texImage2D(+o,d,i.format.internal,s,r,0,i.format.format,i.format.type,a[d]):(t.compressedTexImage2D(+o,d,i.format.internal,s,r,0,a[d]),i.generateMipmaps=!1);i.generateMipmaps&&t.generateMipmap(i.type),t.bindTexture(i.type,null),e.width=i.width,e.height=i.height,e.ready=!0,e.textureCubeReady=!0,n&&i.channelCount&&n.setOrigChannelCount(i.channelCount)}}))},x3dom.Utils.createTextureCube=function(e,t,i,o,s,r,n,a){var d,l=new Uint8Array([0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255]),h=e.createTexture();d=o?[e.TEXTURE_CUBE_MAP_POSITIVE_Z,e.TEXTURE_CUBE_MAP_NEGATIVE_Z,e.TEXTURE_CUBE_MAP_POSITIVE_Y,e.TEXTURE_CUBE_MAP_NEGATIVE_Y,e.TEXTURE_CUBE_MAP_POSITIVE_X,e.TEXTURE_CUBE_MAP_NEGATIVE_X]:[e.TEXTURE_CUBE_MAP_NEGATIVE_Z,e.TEXTURE_CUBE_MAP_POSITIVE_Z,e.TEXTURE_CUBE_MAP_NEGATIVE_Y,e.TEXTURE_CUBE_MAP_POSITIVE_Y,e.TEXTURE_CUBE_MAP_NEGATIVE_X,e.TEXTURE_CUBE_MAP_POSITIVE_X],h.ready=!1,h.pendingTextureLoads=-1,h.textureCubeReady=!1;for(var f=0,u=0,c=0;ce.byteLength)return;if(s>=7&&(192==o||194==o))return e[t+7];t+=s}}else t+=1},x3dom.Utils.detectChannelCountPNG=function(e){if(!(e.byteLength<29)&&137==e[0]&&80==e[1]&&78==e[2]&&71==e[3]&&13==e[4]&&10==e[5]&&26==e[6]&&10==e[7]&&73==e[12]&&72==e[13]&&68==e[14]&&82==e[15])return 0==e[25]?1:2==e[25]?3:4==e[25]?2:6==e[25]?4:void 0},x3dom.Utils.detectChannelCountGIF=function(e){if(71==e[0]&&73==e[1]&&70==e[2]&&56==e[3]&&(55==e[4]||57==e[4])&&97==e[5]&&1&e[10]){for(var t=224&e[10],i=13;i-1?e.substr(e.lastIndexOf(\"/\")+1):e.lastIndexOf(\"\\\\\")>-1?e.substr(e.lastIndexOf(\"\\\\\")+1):e},x3dom.Utils.isWebGL2Enabled=function(){var e=document.createElement(\"canvas\");return!!(e.getContext(\"webgl2\")||e.getContext(\"experimental-webgl2\"))},x3dom.Utils.findTextureByName=function(e,t){for(var i=0;i>t;return e+1},x3dom.Utils.nextBestPowerOfTwo=function(e){var t=Math.log(e)/.693147180559945;return Math.pow(2,Math.round(t))},x3dom.Utils.getDataTypeSize=function(e){switch(e){case\"Int8\":case\"Uint8\":return 1;case\"Int16\":case\"Uint16\":return 2;case\"Int32\":case\"Uint32\":case\"Float32\":return 4;case\"Float64\":default:return 8}},x3dom.Utils.getOffsetMultiplier=function(e,t){switch(e){case t.UNSIGNED_SHORT:return 1;case t.UNSIGNED_INT:return 2;case t.UNSIGNED_BYTE:return.5;default:return 1}},x3dom.Utils.getByteAwareOffset=function(e,t,i){switch(t){case i.UNSIGNED_SHORT:return 2*e;case i.UNSIGNED_INT:return 4*e;case i.UNSIGNED_BYTE:return e;default:return 2*e}},x3dom.Utils.getVertexAttribType=function(e,t){var i=t.NONE;switch(e){case\"Int8\":i=t.BYTE;break;case\"Uint8\":i=t.UNSIGNED_BYTE;break;case\"Int16\":i=t.SHORT;break;case\"Uint16\":i=t.UNSIGNED_SHORT;break;case\"Int32\":i=t.INT;break;case\"Uint32\":i=t.UNSIGNED_INT;break;case\"Float32\":i=t.FLOAT;break;case\"Float64\":default:x3dom.debug.logError(\"Can't find this.gl data type for \"+e+\", getting FLOAT...\"),i=t.FLOAT}return i},x3dom.Utils.getArrayBufferView=function(e,t){var i=null;switch(e){case\"Int8\":i=new Int8Array(t);break;case\"Uint8\":i=new Uint8Array(t);break;case\"Int16\":i=new Int16Array(t);break;case\"Uint16\":i=new Uint16Array(t);break;case\"Int32\":i=new Int32Array(t);break;case\"Uint32\":i=new Uint32Array(t);break;case\"Float32\":i=new Float32Array(t);break;case\"Float64\":i=new Float64Array(t);break;default:x3dom.debug.logError(\"Can't create typed array view of type \"+e+\", trying Float32...\"),i=new Float32Array(t)}return i},x3dom.Utils.isUnsignedType=function(e){return\"Uint8\"==e||\"Uint16\"==e||\"Uint16\"==e||\"Uint32\"==e},x3dom.Utils.checkDirtyLighting=function(e){return e.getLights().length+e._scene.getNavigationInfo()._vf.headlight+(e._scene.getFog()._vf.visibilityRange>0)},x3dom.Utils.checkDirtyPhysicalEnvironmentLight=function(e,t){return!!t.PHYSICALENVLIGHT!=e.hasPhysicalEnvironmentLight()},x3dom.Utils.checkDirtyEnvironment=function(e,t){var i=e._scene.getEnvironment();return t.GAMMACORRECTION!=i._vf.gammaCorrectionDefault},x3dom.Utils.minFilterDic=function(e,t){switch(t.toUpperCase()){case\"NEAREST\":return e.NEAREST;case\"LINEAR\":return e.LINEAR;case\"NEAREST_MIPMAP_NEAREST\":return e.NEAREST_MIPMAP_NEAREST;case\"NEAREST_MIPMAP_LINEAR\":return e.NEAREST_MIPMAP_LINEAR;case\"LINEAR_MIPMAP_NEAREST\":return e.LINEAR_MIPMAP_NEAREST;case\"LINEAR_MIPMAP_LINEAR\":return e.LINEAR_MIPMAP_LINEAR;case\"AVG_PIXEL\":return e.LINEAR;case\"AVG_PIXEL_AVG_MIPMAP\":return e.LINEAR_MIPMAP_LINEAR;case\"AVG_PIXEL_NEAREST_MIPMAP\":return e.LINEAR_MIPMAP_NEAREST;case\"DEFAULT\":return e.LINEAR_MIPMAP_LINEAR;case\"FASTEST\":case\"NEAREST_PIXEL\":return e.NEAREST;case\"NEAREST_PIXEL_AVG_MIPMAP\":return e.NEAREST_MIPMAP_LINEAR;case\"NEAREST_PIXEL_NEAREST_MIPMAP\":return e.NEAREST_MIPMAP_NEAREST;case\"NICEST\":return e.LINEAR_MIPMAP_LINEAR;default:return e.LINEAR}},x3dom.Utils.minFilterDicX3D=function(e){switch(e){case 9728:return\"NEAREST\";case 9729:return\"LINEAR\";case 9984:return\"NEAREST_MIPMAP_NEAREST\";case 9985:return\"LINEAR_MIPMAP_NEAREST\";case 9986:return\"NEAREST_MIPMAP_LINEAR\";case 9987:default:return\"LINEAR_MIPMAP_LINEAR\"}},x3dom.Utils.magFilterDic=function(e,t){switch(t.toUpperCase()){case\"NEAREST\":return e.NEAREST;case\"LINEAR\":case\"AVG_PIXEL\":case\"DEFAULT\":return e.LINEAR;case\"FASTEST\":case\"NEAREST_PIXEL\":return e.NEAREST;case\"NICEST\":default:return e.LINEAR}},x3dom.Utils.magFilterDicX3D=function(e){switch(e){case 9728:return\"NEAREST\";case 9729:default:return\"LINEAR\"}},x3dom.Utils.boundaryModesDicX3D=function(e){switch(e){case 10497:return\"REPEAT\";case 33071:return\"CLAMP_TO_EDGE\";case 33648:return\"MIRRORED_REPEAT\";default:return\"REPEAT\"}},x3dom.Utils.boundaryModesDic=function(e,t){switch(t.toUpperCase()){case\"CLAMP\":case\"CLAMP_TO_EDGE\":case\"CLAMP_TO_BOUNDARY\":return e.CLAMP_TO_EDGE;case\"MIRRORED_REPEAT\":return e.MIRRORED_REPEAT;case\"REPEAT\":default:return e.REPEAT}},x3dom.Utils.primTypeDic=function(e,t){switch(t.toUpperCase()){case\"POINTS\":return e.POINTS;case\"LINES\":return e.LINES;case\"LINELOOP\":return e.LINE_LOOP;case\"LINESTRIP\":return e.LINE_STRIP;case\"TRIANGLES\":return e.TRIANGLES;case\"TRIANGLESTRIP\":return e.TRIANGLE_STRIP;case\"TRIANGLEFAN\":return e.TRIANGLE_FAN;default:return e.TRIANGLES}},x3dom.Utils.depthFunc=function(e,t){switch(t.toUpperCase()){case\"NEVER\":return e.NEVER;case\"ALWAYS\":return e.ALWAYS;case\"LESS\":return e.LESS;case\"EQUAL\":return e.EQUAL;case\"LEQUAL\":return e.LEQUAL;case\"GREATER\":return e.GREATER;case\"GEQUAL\":return e.GEQUAL;case\"NOTEQUAL\":return e.NOTEQUAL;default:return e.LEQUAL}},x3dom.Utils.blendFunc=function(e,t){switch(t.toLowerCase()){case\"zero\":return e.ZERO;case\"one\":return e.ONE;case\"dst_color\":return e.DST_COLOR;case\"dst_alpha\":return e.DST_ALPHA;case\"src_color\":return e.SRC_COLOR;case\"src_alpha\":return e.SRC_ALPHA;case\"one_minus_dst_color\":return e.ONE_MINUS_DST_COLOR;case\"one_minus_dst_alpha\":return e.ONE_MINUS_DST_ALPHA;case\"one_minus_src_color\":return e.ONE_MINUS_SRC_COLOR;case\"one_minus_src_alpha\":return e.ONE_MINUS_SRC_ALPHA;case\"src_alpha_saturate\":return e.SRC_ALPHA_SATURATE;case\"constant_color\":return e.CONSTANT_COLOR;case\"constant_alpha\":return e.CONSTANT_ALPHA;case\"one_minus_constant_color\":return e.ONE_MINUS_CONSTANT_COLOR;case\"one_minus_constant_alpha\":return e.ONE_MINUS_CONSTANT_ALPHA;default:return 0}},x3dom.Utils.blendEquation=function(e,t){switch(t.toLowerCase()){case\"func_add\":return e.FUNC_ADD;case\"func_subtract\":return e.FUNC_SUBTRACT;case\"func_reverse_subtract\":return e.FUNC_REVERSE_SUBTRACT;case\"min\":case\"max\":case\"logic_op\":default:return 0}},x3dom.Utils.generateProperties=function(e,t){var i={},o=t._cf.geometry.node,s=t._cf.appearance.node,r=s?s._cf.texture.node:null,n=s?s._cf.material.node:null,a=e._scene.getEnvironment();return s&&s._shader&&x3dom.isa(s._shader,x3dom.nodeTypes.ComposedShader)?i.CSHADER=s._shader._id:o&&(i.CSHADER=-1,i.APPMAT=s&&(n||i.CSSHADER)?1:0,i.SOLID=t.isSolid()?1:0,i.TEXT=x3dom.isa(o,x3dom.nodeTypes.Text)?1:0,i.POPGEOMETRY=x3dom.isa(o,x3dom.nodeTypes.PopGeometry)?1:0,i.BUFFERGEOMETRY=x3dom.isa(o,x3dom.nodeTypes.BufferGeometry)?1:0,i.BINARYGEOMETRY=x3dom.isa(o,x3dom.nodeTypes.BinaryGeometry)?1:0,i.POINTLINE2D=o.needLighting()?0:1,i.VERTEXID=i.BINARYGEOMETRY&&o._vf.idsPerVertex?1:0,i.IS_PARTICLE=x3dom.isa(o,x3dom.nodeTypes.ParticleSet)?1:0,i.POINTPROPERTIES=s&&s._cf.pointProperties.node?1:0,i.TANGENTDATA=o._mesh._tangents[0].length>0&&o._mesh._binormals[0].length>0?1:0,i.PBR_MATERIAL=i.APPMAT&&x3dom.isa(n,x3dom.nodeTypes.PhysicalMaterial)?1:0,i.TWOSIDEDMAT=i.APPMAT&&x3dom.isa(n,x3dom.nodeTypes.TwoSidedMaterial)?1:0,i.SEPARATEBACKMAT=i.TWOSIDEDMAT&&n._vf.separateBackColor?1:0,i.SHADOW=e.getLightsShadow()?1:0,i.FOG=e._scene.getFog()._vf.visibilityRange>0?1:0,i.CSSHADER=s&&s._shader&&x3dom.isa(s._shader,x3dom.nodeTypes.CommonSurfaceShader)?1:0,i.LIGHTS=!i.POINTLINE2D&&s&&t.isLit()&&(n||i.CSSHADER)?e.getLights().length+e._scene.getNavigationInfo()._vf.headlight:0,i.TEXTURED=r||i.TEXT||i.CSSHADER&&s._shader.needTexcoords()||i.PBR_MATERIAL&&n.hasTextures()?1:0,i.CUBEMAP=r&&x3dom.isa(r,x3dom.nodeTypes.X3DEnvironmentTextureNode)||i.CSSHADER&&s._shader.getEnvironmentMap()?1:0,i.PIXELTEX=r&&x3dom.isa(r,x3dom.nodeTypes.PixelTexture)?1:0,i.TEXTRAFO=s&&s._cf.textureTransform.node?1:0,i.DIFFUSEMAP=r&&!x3dom.isa(r,x3dom.nodeTypes.X3DEnvironmentTextureNode)||i.CSSHADER&&s._shader.getDiffuseMap()||i.PBR_MATERIAL&&n._cf.baseColorTexture.node?1:0,i.NORMALMAP=i.CSSHADER&&s._shader.getNormalMap()||i.PBR_MATERIAL&&n._cf.normalTexture.node?1:0,i.SPECMAP=i.CSSHADER&&s._shader.getSpecularMap()?1:0,i.SHINMAP=i.CSSHADER&&s._shader.getShininessMap()?1:0,i.EMISSIVEMAP=i.PBR_MATERIAL&&n._cf.emissiveTexture.node?1:0,i.OCCLUSIONMAP=i.PBR_MATERIAL&&n._cf.occlusionTexture.node?1:0,i.DISPLACEMENTMAP=i.CSSHADER&&s._shader.getDisplacementMap()?1:0,i.DIFFPLACEMENTMAP=i.CSSHADER&&s._shader.getDiffuseDisplacementMap()?1:0,i.ALPHAMODE=i.PBR_MATERIAL?n._vf.alphaMode:\"BLEND\",i.ISROUGHNESSMETALLIC=i.PBR_MATERIAL&&\"roughnessMetallic\"==n._vf.model?1:0,i.ROUGHNESSMETALLICMAP=i.PBR_MATERIAL&&n._cf.roughnessMetallicTexture.node?1:0,i.SPECULARGLOSSINESSMAP=i.PBR_MATERIAL&&n._cf.specularGlossinessTexture.node?1:0,i.OCCLUSIONROUGHNESSMETALLICMAP=i.PBR_MATERIAL&&n._cf.occlusionRoughnessMetallicTexture.node?1:0,i.PHYSICALENVLIGHT=e.hasPhysicalEnvironmentLight()?1:0,i.NORMALSPACE=i.NORMALMAP&&i.CSSHADER?s._shader._vf.normalSpace.toUpperCase():i.NORMALMAP&&i.PBR_MATERIAL?n._vf.normalSpace.toUpperCase():\"TANGENT\",i.BLENDING=i.TEXT||i.CUBEMAP||i.CSSHADER||i.PBR_MATERIAL||r&&r._blending?1:0,i.REQUIREBBOX=void 0!==o._vf.coordType&&\"Float32\"!=o._vf.coordType?1:0,i.REQUIREBBOXNOR=void 0!==o._vf.normalType&&\"Float32\"!=o._vf.normalType?1:0,i.REQUIREBBOXCOL=void 0!==o._vf.colorType&&\"Float32\"!=o._vf.colorType?1:0,i.REQUIREBBOXTEX=void 0!==o._vf.texCoordType&&\"Float32\"!=o._vf.texCoordType?1:0,i.COLCOMPONENTS=o._mesh._numColComponents,i.NORCOMPONENTS=o._mesh._numNormComponents,i.POSCOMPONENTS=o._mesh._numPosComponents,i.SPHEREMAPPING=void 0!==o._cf.texCoord&&null!==o._cf.texCoord.node&&o._cf.texCoord.node._vf.mode&&\"sphere\"==o._cf.texCoord.node._vf.mode.toLowerCase()?1:0,i.VERTEXCOLOR=o._mesh._colors[0].length>0||i.POPGEOMETRY&&o.hasColor()||i.BUFFERGEOMETRY&&o.hasColor()||void 0!==o._vf.color&&o._vf.color.length>0?1:0,i.CLIPPLANES=t._clipPlanes.length,i.ALPHATHRESHOLD=s?s._vf.alphaClipThreshold.toFixed(2):.1,i.MULTITEXCOORD=i.BUFFERGEOMETRY&&o.hasMultiTexCoord()?1:0,i.DIFFUSEMAPCHANNEL=i.PBR_MATERIAL&&i.DIFFUSEMAP&&1===n._cf.baseColorTexture.node._vf.channel?1:0,i.NORMALMAPCHANNEL=i.PBR_MATERIAL&&i.NORMALMAP&&1===n._cf.normalTexture.node._vf.channel?1:0,i.EMISSIVEMAPCHANNEL=i.PBR_MATERIAL&&i.EMISSIVEMAP&&1===n._cf.emissiveTexture.node._vf.channel?1:0,i.OCCLUSIONMAPCHANNEL=i.PBR_MATERIAL&&i.OCCLUSIONMAP&&1===n._cf.occlusionTexture.node._vf.channel?1:0,i.ROUGHNESSMETALLICMAPCHANNEL=i.PBR_MATERIAL&&i.ROUGHNESSMETALLICMAP&&1===n._cf.roughnessMetallicTexture.node._vf.channel?1:0,i.OCCLUSIONROUGHNESSMETALLICMAPCHANNEL=i.PBR_MATERIAL&&i.OCCLUSIONROUGHNESSMETALLICMAP&&1===n._cf.occlusionRoughnessMetallicTexture.node._vf.channel?1:0,i.SPECULARGLOSSINESSMAPCHANNEL=i.PBR_MATERIAL&&i.SPECULARGLOSSINESSMAP&&1===n._cf.specularGlossinessTexture.node._vf.channel?1:0,i.ALPHAMASK=i.PBR_MATERIAL&&\"MASK\"==n._vf.alphaMode?1:0,i.UNLIT=i.PBR_MATERIAL&&n._vf.unlit?1:0,i.GAMMACORRECTION=a._vf.gammaCorrectionDefault,i.KHR_MATERIAL_COMMONS=0),i.toIdentifier=function(){delete this.id;var e=\"\";for(var t in this)this[t]!=this.toIdentifier&&this[t]!=this.toString&&(e+=this[t]);return this.id=e,e},i.toString=function(){var e=\"\";for(var t in this)this[t]!=this.toIdentifier&&this[t]!=this.toString&&(e+=t+\": \"+this[t]+\", \");return e},i.toIdentifier(),i},x3dom.Utils.lerp=function(e,t,i){return e+(t-e)*(i=(i=i<0?0:i)>1?1:i)},x3dom.Utils.wrapProgram=function(e,t,i){var o,s,r={shaderID:i,program:t,bind:function(){e.useProgram(t)}},n=null,a=null,d=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(o=0;o>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(n);break;case 12:case 13:a=e[s++],o+=String.fromCharCode((31&n)<<6|63&a);break;case 14:a=e[s++],d=e[s++],o+=String.fromCharCode((15&n)<<12|(63&a)<<6|(63&d)<<0)}return JSON.parse(o)},x3dom.Utils.arrayBufferToObjectURL=function(e,t){return URL.createObjectURL(new Blob([new Uint8Array(e)],{type:t}))},x3dom.Utils.dataURIToObjectURL=function(e){if(-1==e.indexOf(\"data:\"))return e;for(var t=e.split(\",\"),i=t[0].split(\":\")[1].split(\";\")[0],o=t[1],s=window.atob(o),r=s.length,n=new Uint8Array(r),a=0;at||(e=e>1?1:e,t=t>1?1:t,this.states.depthRange.zNear==e&&this.states.depthRange.zFar==t||(this.gl.depthRange(e,t),this.states.depthRange.zNear=e,this.states.depthRange.zFar=t))},x3dom.StateManager.prototype.viewport=function(e,t,i,o){this.states.viewport.x==e&&this.states.viewport.y==t&&this.states.viewport.width==i&&this.states.viewport.height==o||(this.gl.viewport(e,t,i,o),this.states.viewport.x=e,this.states.viewport.y=t,this.states.viewport.width=i,this.states.viewport.height=o)},x3dom.StateManager.prototype.bindFramebuffer=function(e,t){this.gl.bindFramebuffer(e,t),this.initStates()},x3dom.BinaryContainerLoader={outOfMemory:!1,checkError:function(e){var t=e.getError();t&&(t==e.OUT_OF_MEMORY?(this.outOfMemory=!0,x3dom.debug.logError(\"GL-Error \"+t+\" on loading binary container (out of memory).\"),console.error(\"WebGL: OUT_OF_MEMORY\")):x3dom.debug.logError(\"GL-Error \"+t+\" on loading binary container.\"))}},x3dom.BinaryContainerLoader.setupBinGeo=function(e,t,i,o,s){if(!this.outOfMemory){var r=(new Date).getTime(),n=this,a=e._cf.geometry.node;e._webgl.binaryGeometry=-1,e._webgl.internalDownloadCount=(a._vf.index.length>0?1:0)+(a._hasStrideOffset&&a._vf.coord.length>0?1:0)+(!a._hasStrideOffset&&a._vf.coord.length>0?1:0)+(!a._hasStrideOffset&&a._vf.normal.length>0?1:0)+(!a._hasStrideOffset&&a._vf.texCoord.length>0?1:0)+(!a._hasStrideOffset&&a._vf.color.length>0?1:0);var d=0==a._vf.normalPerVertex||a._vf.index.length>0&&(\"Int32\"==a._vf.indexType||\"Uint32\"==a._vf.indexType&&!x3dom.caps.INDEX_UINT);if(e._webgl.makeSeparateTris={index:null,coord:null,normal:null,texCoord:null,color:null,pushBuffer:function(t,i){this[t]=i,0==--e._webgl.internalDownloadCount&&(this.coord&&this.createMesh(),e._nameSpace.doc.needRender=!0),0==--e._nameSpace.doc.downloadCount&&(e._nameSpace.doc.needRender=!0)},createMesh:function(){var r=a;if(r._hasStrideOffset)x3dom.debug.logError(r._vf.indexType+\" index type and per-face normals not supported for interleaved arrays.\");else{for(var d=0;d3&&x.push(this.coord[m+3]),this.color&&(y.push(this.color[m]),y.push(this.color[m+1]),y.push(this.color[m+2]),u>3&&y.push(this.color[m+3])),this.texCoord&&(p=c*(this.index?this.index[_]:_),v.push(this.texCoord[p]),v.push(this.texCoord[p+1]),c>3&&(v.push(this.texCoord[p+2]),v.push(this.texCoord[p+3]))),m=u*(this.index?this.index[_+1]:_+1);var S=new x3dom.fields.SFVec3f(l.x*this.coord[m]/h,l.y*this.coord[m+1]/h,l.z*this.coord[m+2]/h);x.push(this.coord[m]),x.push(this.coord[m+1]),x.push(this.coord[m+2]),u>3&&x.push(this.coord[m+3]),this.color&&(y.push(this.color[m]),y.push(this.color[m+1]),y.push(this.color[m+2]),u>3&&y.push(this.color[m+3])),this.texCoord&&(p=c*(this.index?this.index[_+1]:_+1),v.push(this.texCoord[p]),v.push(this.texCoord[p+1]),c>3&&(v.push(this.texCoord[p+2]),v.push(this.texCoord[p+3]))),m=u*(this.index?this.index[_+2]:_+2);var F=new x3dom.fields.SFVec3f(l.x*this.coord[m]/h,l.y*this.coord[m+1]/h,l.z*this.coord[m+2]/h);x.push(this.coord[m]),x.push(this.coord[m+1]),x.push(this.coord[m+2]),u>3&&x.push(this.coord[m+3]),this.color&&(y.push(this.color[m]),y.push(this.color[m+1]),y.push(this.color[m+2]),u>3&&y.push(this.color[m+3])),this.texCoord&&(p=c*(this.index?this.index[_+2]:_+2),v.push(this.texCoord[p]),v.push(this.texCoord[p+1]),c>3&&(v.push(this.texCoord[p+2]),v.push(this.texCoord[p+3])));var E=b.subtract(S),M=S.subtract(F),C=E.cross(M).normalize();for(m=0;m<3;m++)g.push(C.x),g.push(C.y),g.push(C.z)}var A=i.createBuffer();e._webgl.buffers[x3dom.BUFFER_IDX.POSITION]=A,i.bindBuffer(i.ARRAY_BUFFER,A),i.bufferData(i.ARRAY_BUFFER,x3dom.Utils.getArrayBufferView(r._vf.coordType,x),i.STATIC_DRAW),i.vertexAttribPointer(t.position,r._mesh._numPosComponents,e._webgl.coordType,!1,e._coordStrideOffset[0],e._coordStrideOffset[1]),i.enableVertexAttribArray(t.position),A=i.createBuffer(),e._webgl.buffers[x3dom.BUFFER_IDX.NORMAL]=A,i.bindBuffer(i.ARRAY_BUFFER,A),i.bufferData(i.ARRAY_BUFFER,new Float32Array(g),i.STATIC_DRAW),i.vertexAttribPointer(t.normal,r._mesh._numNormComponents,e._webgl.normalType,!1,e._normalStrideOffset[0],e._normalStrideOffset[1]),i.enableVertexAttribArray(t.normal),this.texCoord&&(A=i.createBuffer(),e._webgl.buffers[x3dom.BUFFER_IDX.TEXCOORD]=A,i.bindBuffer(i.ARRAY_BUFFER,A),i.bufferData(i.ARRAY_BUFFER,x3dom.Utils.getArrayBufferView(r._vf.texCoordType,v),i.STATIC_DRAW),i.vertexAttribPointer(t.texcoord,r._mesh._numTexComponents,e._webgl.texCoordType,!1,e._texCoordStrideOffset[0],e._texCoordStrideOffset[1]),i.enableVertexAttribArray(t.texcoord)),this.color&&(A=i.createBuffer(),e._webgl.buffers[x3dom.BUFFER_IDX.COLOR]=A,i.bindBuffer(i.ARRAY_BUFFER,A),i.bufferData(i.ARRAY_BUFFER,x3dom.Utils.getArrayBufferView(r._vf.colorType,y),i.STATIC_DRAW),i.vertexAttribPointer(t.color,r._mesh._numColComponents,e._webgl.colorType,!1,e._colorStrideOffset[0],e._colorStrideOffset[1]),i.enableVertexAttribArray(t.color)),r._vf.vertexCount=[],r._vf.vertexCount[0]=x.length/u,r._mesh._numCoords=r._vf.vertexCount[0],r._mesh._numFaces=r._vf.vertexCount[0]/3,e._webgl.primType=[],e._webgl.primType[0]=i.TRIANGLES,x=null,g=null,v=null,y=null,this.index=null,this.coord=null,this.normal=null,this.texCoord=null,this.color=null,n.checkError(i),delete e._webgl.shader,e._webgl.shader=s.cache.getDynamicShader(i,o,e)}}},a._vf.index.length>0){e._webgl.binaryGeometry=1;var l=new XMLHttpRequest;l.open(\"GET\",e._nameSpace.getURL(a._vf.index),!0),l.responseType=\"arraybuffer\",e._nameSpace.doc.incrementDownloads(),x3dom.RequestManager.addRequest(l),l.onload=function(){if(e._nameSpace.doc.decrementDownloads(),e._webgl.internalDownloadCount-=1,200==l.status){if(e._webgl)if(a._vf.compressed)x3dom.debug.logError(\"x3dom 1.8.2+ do not support compressed BinaryGeometries anymore\");else{var t=l.response,o=a,s=o._vf.indexType,h=x3dom.Utils.getArrayBufferView(s,t);if(d)e._webgl.makeSeparateTris.pushBuffer(\"index\",h);else{var f=i.createBuffer();x3dom.caps.INDEX_UINT&&\"Uint32\"==s?e._webgl.indexType=i.UNSIGNED_INT:e._webgl.indexType=i.UNSIGNED_SHORT,i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,f),i.bufferData(i.ELEMENT_ARRAY_BUFFER,h,i.STATIC_DRAW),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,null),0==o._vf.vertexCount[0]&&(o._vf.vertexCount[0]=h.length),o._mesh._numFaces=0;for(var u=0;u0){var h=new XMLHttpRequest;h.open(\"GET\",e._nameSpace.getURL(a._vf.coord),!0),h.responseType=\"arraybuffer\",e._nameSpace.doc.incrementDownloads(),x3dom.RequestManager.addRequest(h),h.onload=function(){if(e._nameSpace.doc.decrementDownloads(),e._webgl.internalDownloadCount-=1,200==h.status){if(e._webgl)if(a._vf.compressed)x3dom.debug.logError(\"x3dom 1.8.2+ do not support compressed BinaryGeometries anymore\");else{var o=h.response,s=a,d=s._vf.coordType;e._webgl.coordType=x3dom.Utils.getVertexAttribType(d,i),e._webgl.normalType=e._webgl.coordType,e._webgl.texCoordType=e._webgl.coordType,e._webgl.colorType=e._webgl.coordType;var l=x3dom.Utils.getArrayBufferView(d,o),f=e._coordStrideOffset[0]/x3dom.Utils.getDataTypeSize(d);if(f&&(s._mesh._numCoords=l.length/f),0==s._vf.index.length)for(var u=0;u0&&(e._webgl.buffers[x3dom.BUFFER_IDX.NORMAL]=c,i.bindBuffer(i.ARRAY_BUFFER,c),i.bufferData(i.ARRAY_BUFFER,l,i.STATIC_DRAW),i.vertexAttribPointer(t.normal,s._mesh._numNormComponents,e._webgl.normalType,!1,e._normalStrideOffset[0],e._normalStrideOffset[1]),i.enableVertexAttribArray(t.normal)),s._vf.texCoord.length>0&&(e._webgl.buffers[x3dom.BUFFER_IDX.TEXCOORD]=c,i.bindBuffer(i.ARRAY_BUFFER,c),i.bufferData(i.ARRAY_BUFFER,l,i.STATIC_DRAW),i.vertexAttribPointer(t.texcoord,s._mesh._numTexComponents,e._webgl.texCoordType,!1,e._texCoordStrideOffset[0],e._texCoordStrideOffset[1]),i.enableVertexAttribArray(t.texcoord)),s._vf.color.length>0&&(e._webgl.buffers[x3dom.BUFFER_IDX.COLOR]=c,i.bindBuffer(i.ARRAY_BUFFER,c),i.bufferData(i.ARRAY_BUFFER,l,i.STATIC_DRAW),i.vertexAttribPointer(t.color,s._mesh._numColComponents,e._webgl.colorType,!1,e._colorStrideOffset[0],e._colorStrideOffset[1]),i.enableVertexAttribArray(t.color)),l=null,0==e._webgl.internalDownloadCount&&(e._nameSpace.doc.needRender=!0),n.checkError(i);var _=(new Date).getTime()-r;x3dom.debug.logInfo(\"XHR/ interleaved array load time: \"+_+\" ms\"),e._webgl.buffers[x3dom.BUFFER_IDX.POSITION]=c}}else x3dom.debug.logError(\"XHR1/ interleaved array load failed with status: \"+h.status)}}if(!a._hasStrideOffset&&a._vf.coord.length>0){var f=new XMLHttpRequest;f.open(\"GET\",e._nameSpace.getURL(a._vf.coord),!0),f.responseType=\"arraybuffer\",e._nameSpace.doc.incrementDownloads(),x3dom.RequestManager.addRequest(f),f.onload=function(){if(e._nameSpace.doc.decrementDownloads(),e._webgl.internalDownloadCount-=1,200==f.status){if(e._webgl)if(a._vf.compressed)x3dom.debug.logError(\"x3dom 1.8.2+ do not support compressed BinaryGeometries anymore\");else{var o=f.response,s=a,l=0,h=s._vf.coordType;e._webgl.coordType=x3dom.Utils.getVertexAttribType(h,i);var u=x3dom.Utils.getArrayBufferView(h,o);if(d)e._webgl.makeSeparateTris.pushBuffer(\"coord\",u);else{i.bindAttribLocation(t.program,0,\"position\");var c=i.createBuffer();if(i.bindBuffer(i.ARRAY_BUFFER,c),i.bufferData(i.ARRAY_BUFFER,u,i.STATIC_DRAW),i.bindBuffer(i.ARRAY_BUFFER,null),s._mesh._numCoords=u.length/s._mesh._numPosComponents,0==s._vf.index.length)for(l=0;lu[l+0]&&(_.x=u[l+0]),_.y>u[l+1]&&(_.y=u[l+1]),_.z>u[l+2]&&(_.z=u[l+2]),m.x0){var u=new XMLHttpRequest;u.open(\"GET\",e._nameSpace.getURL(a._vf.normal),!0),u.responseType=\"arraybuffer\",e._nameSpace.doc.incrementDownloads(),x3dom.RequestManager.addRequest(u),u.onload=function(){if(e._nameSpace.doc.decrementDownloads(),e._webgl.internalDownloadCount-=1,200==u.status){if(e._webgl)if(a._vf.compressed)x3dom.debug.logError(\"x3dom 1.8.2+ do not support compressed BinaryGeometries anymore\");else{var t=u.response,o=a._vf.normalType;e._webgl.normalType=x3dom.Utils.getVertexAttribType(o,i);var s=x3dom.Utils.getArrayBufferView(o,t);if(d)e._webgl.makeSeparateTris.pushBuffer(\"normal\",s);else{var l=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,l),i.bufferData(i.ARRAY_BUFFER,s,i.STATIC_DRAW),i.bindBuffer(i.ARRAY_BUFFER,null),s=null,0==e._webgl.internalDownloadCount&&(e._nameSpace.doc.needRender=!0),n.checkError(i);var h=(new Date).getTime()-r;x3dom.debug.logInfo(\"XHR2/ normal load time: \"+h+\" ms\"),e._webgl.buffers[x3dom.BUFFER_IDX.NORMAL]=l}}}else x3dom.debug.logError(\"XHR2/ normal load failed with status: \"+u.status)}}if(!a._hasStrideOffset&&a._vf.texCoord.length>0){var c=new XMLHttpRequest;c.open(\"GET\",e._nameSpace.getURL(a._vf.texCoord),!0),c.responseType=\"arraybuffer\",e._nameSpace.doc.incrementDownloads(),x3dom.RequestManager.addRequest(c),c.onload=function(){var t,o;if(e._nameSpace.doc.decrementDownloads(),e._webgl.internalDownloadCount-=1,200==c.status){if(e._webgl)if(a._vf.compressed)x3dom.debug.logError(\"x3dom 1.8.2+ do not support compressed BinaryGeometries anymore\");else{var s=c.response,l=a._vf.texCoordType;e._webgl.texCoordType=x3dom.Utils.getVertexAttribType(l,i);var h=x3dom.Utils.getArrayBufferView(l,s);if(d)e._webgl.makeSeparateTris.pushBuffer(\"texCoord\",h);else{if(a._vf.idsPerVertex){var f=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,f);var u=x3dom.Utils.getArrayBufferView(\"Float32\",h.length/2);for(t=0,o=0;t0){var _=new XMLHttpRequest;_.open(\"GET\",e._nameSpace.getURL(a._vf.color),!0),_.responseType=\"arraybuffer\",e._nameSpace.doc.incrementDownloads(),x3dom.RequestManager.addRequest(_),_.onload=function(){if(e._nameSpace.doc.decrementDownloads(),e._webgl.internalDownloadCount-=1,200==_.status){if(e._webgl)if(a._vf.compressed)x3dom.debug.logError(\"x3dom 1.8.2+ do not support compressed BinaryGeometries anymore\");else{var t=_.response,o=a._vf.colorType;e._webgl.colorType=x3dom.Utils.getVertexAttribType(o,i);var s=x3dom.Utils.getArrayBufferView(o,t);if(d)e._webgl.makeSeparateTris.pushBuffer(\"color\",s);else{var l=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,l),i.bufferData(i.ARRAY_BUFFER,s,i.STATIC_DRAW),i.bindBuffer(i.ARRAY_BUFFER,null),s=null,0==e._webgl.internalDownloadCount&&(e._nameSpace.doc.needRender=!0),n.checkError(i);var h=(new Date).getTime()-r;x3dom.debug.logInfo(\"XHR4/ color load time: \"+h+\" ms\"),e._webgl.buffers[x3dom.BUFFER_IDX.COLOR]=l}}}else x3dom.debug.logError(\"XHR4/ color load failed with status: \"+_.status)}}if(!a._hasStrideOffset&&a._vf.tangent.length>0){var m=new XMLHttpRequest;m.open(\"GET\",e._nameSpace.getURL(a._vf.normal),!0),m.responseType=\"arraybuffer\",e._nameSpace.doc.incrementDownloads(),x3dom.RequestManager.addRequest(m),m.onload=function(){if(e._nameSpace.doc.decrementDownloads(),e._webgl.internalDownloadCount-=1,200==m.status){if(e._webgl)if(a._vf.compressed)x3dom.debug.logError(\"x3dom 1.8.2+ do not support compressed BinaryGeometries anymore\");else{var t=m.response,o=a._vf.tangentType;e._webgl.tangentType=x3dom.Utils.getVertexAttribType(o,i);var s=x3dom.Utils.getArrayBufferView(o,t);if(d)e._webgl.makeSeparateTris.pushBuffer(\"tangent\",s);else{var l=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,l),i.bufferData(i.ARRAY_BUFFER,s,i.STATIC_DRAW),i.bindBuffer(i.ARRAY_BUFFER,null),s=null,0==e._webgl.internalDownloadCount&&(e._nameSpace.doc.needRender=!0),n.checkError(i);var h=(new Date).getTime()-r;x3dom.debug.logInfo(\"XHR5/ normal load time: \"+h+\" ms\"),e._webgl.buffers[x3dom.BUFFER_IDX.TANGENT]=l}}}else x3dom.debug.logError(\"XHR2/ normal load failed with status: \"+m.status)}}if(!a._hasStrideOffset&&a._vf.binormal.length>0){var p=new XMLHttpRequest;p.open(\"GET\",e._nameSpace.getURL(a._vf.normal),!0),p.responseType=\"arraybuffer\",e._nameSpace.doc.incrementDownloads(),x3dom.RequestManager.addRequest(p),p.onload=function(){if(e._nameSpace.doc.decrementDownloads(),e._webgl.internalDownloadCount-=1,200==p.status){if(e._webgl)if(a._vf.compressed)x3dom.debug.logError(\"x3dom 1.8.2+ do not support compressed BinaryGeometries anymore\");else{var t=p.response,o=a._vf.binormalType;e._webgl.binormalType=x3dom.Utils.getVertexAttribType(o,i);var s=x3dom.Utils.getArrayBufferView(o,t);if(d)e._webgl.makeSeparateTris.pushBuffer(\"binormal\",s);else{var l=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,l),i.bufferData(i.ARRAY_BUFFER,s,i.STATIC_DRAW),i.bindBuffer(i.ARRAY_BUFFER,null),s=null,0==e._webgl.internalDownloadCount&&(e._nameSpace.doc.needRender=!0),n.checkError(i);var h=(new Date).getTime()-r;x3dom.debug.logInfo(\"XHR6/ normal load time: \"+h+\" ms\"),e._webgl.buffers[x3dom.BUFFER_IDX.BITANGENT]=l}}}else x3dom.debug.logError(\"XHR6/ normal load failed with status: \"+p.status)}}}},x3dom.BinaryContainerLoader.setupPopGeo=function(e,t,i,o,s){if(!this.outOfMemory){var r=e._cf.geometry.node;if(r.hasIndex()){e._webgl.popGeometry=1,e._webgl.buffers[x3dom.BUFFER_IDX.INDEX]=i.createBuffer(),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e._webgl.buffers[x3dom.BUFFER_IDX.INDEX]),i.bufferData(i.ELEMENT_ARRAY_BUFFER,2*r.getTotalNumberOfIndices(),i.STATIC_DRAW),e._webgl.buffers[x3dom.BUFFER_IDX.ID]=i.createBuffer();var n=new Float32Array(r._vf.vertexBufferSize);!function(){for(var e=0;e0){n=!0;var a=new Uint8Array(t,0,s);i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e._webgl.buffers[x3dom.BUFFER_IDX.INDEX]),function(){for(var e=0,t=0;t0){n=!0;var l=new Uint8Array(t,s,d);i.bindBuffer(i.ARRAY_BUFFER,e._webgl.buffers[x3dom.BUFFER_IDX.POSITION]),r.hasIndex()?i.bufferSubData(i.ARRAY_BUFFER,r.getVertexDataBufferOffset(o)*r.getAttributeStride(),l):i.bufferSubData(i.ARRAY_BUFFER,e._webgl.currentNumVertices*r.getAttributeStride(),l),e._webgl.numVerticesAtLevel[o]=d/r.getAttributeStride(),e._webgl.currentNumVertices+=e._webgl.numVerticesAtLevel[o]}!function(){for(var t=0,i=e._webgl.levelsAvailable;i-1&&o.shapes.splice(r,1),o.shapes.length>0||i.call(this,e,t)}}(x3dom.BinaryContainerLoader.bufferGeoCache[n]),f&&u.destroy(_),x3dom.BinaryContainerLoader.bufferGeoCache[n].decrementDownload&&(x3dom.BinaryContainerLoader.bufferGeoCache[n].decrementDownload=!1,e._nameSpace.doc.decrementDownloads(),e._nameSpace.doc.needRender=!0)}else x3dom.BinaryContainerLoader.bufferGeoCache[n]=void 0})).catch((function(){x3dom.BinaryContainerLoader.bufferGeoCache[n].decrementDownload&&(x3dom.BinaryContainerLoader.bufferGeoCache[n].decrementDownload=!1,e._nameSpace.doc.decrementDownloads())})))},x3dom.BinaryContainerLoader.setupBufferInterpolator=function(e){var t=function(e,t,i){for(var o=e._cf.views.nodes[t._vf.view],s=t._vf.byteOffset+o._vf.byteOffset,r=t._vf.count*t._vf.components,n=t._vf.componentType,a=x3dom.BinaryContainerLoader.getArrayBufferFromType(n,i,s,r),d=0,l=a.length;d0&&i._lowPriorityThreshold<1,this.sortTrans=e.sortTrans,this.prioLevels=10,this.maxTreshold=100,this.sortBySortKey=!1,this.sortByPriority=!1,this.numberOfNodes=0,this.length=0},x3dom.DrawableCollection.prototype.cull=function(e,t,i,o){var s=t.boundedNode;if(!s||!s.renderFlag())return-1;var r,n=s.getVolume();if(this.frustumCulling&&t.needCulling){if(i&&!t.worldVolume.isValid()?(t.worldVolume.transformFrom(e,n),r=t.worldVolume):o<63&&(this.worldVol.transformFrom(e,n),r=this.worldVol),o<63&&(o=this.viewFrustum.intersect(r,o)),-1==o)return-1}else o=63;if(t.coverage=-1,this.smallFeatureThreshold>0||s.forceUpdateCoverage()){var a=this.viewMatrix.mult(e);t.center=a.multMatrixPnt(n.getCenter());var d=a.multMatrixVec(n.getRadialVec()).length(),l=Math.max(-t.center.z-d,this.near)*this.pixelHeightAtDistOne;if(t.coverage=2*d/l,this.smallFeatureThreshold>0&&t.coverage0)o.zPos=i.center.z;else{var r=t.multMatrixPnt(e.getCenter());r=this.viewMatrix.multMatrixPnt(r),o.zPos=r.z}this.sortBySortKey||0==o.sortKey||(this.sortBySortKey=!0),void 0===this.collection[o.sortType]&&(this.collection[o.sortType]=[]),this.collection[o.sortType].push(o),this.length++,this.context&&this.gl&&this.context.setupShape(this.gl,o,this.viewarea)},x3dom.DrawableCollection.prototype.addDrawable=function(e){e.shaderID=e.shape.getShaderProperties(this.viewarea).id;var t=e.shape._cf.appearance.node;if(e.sortType=t?t._vf.sortType.toLowerCase():\"opaque\",e.sortKey=t?t._vf.sortKey:0,\"transparent\"==e.sortType){var i=e.transform.multMatrixPnt(e.shape.getCenter());i=this.viewMatrix.multMatrixPnt(i),e.zPos=i.z}this.sortBySortKey||0==e.sortKey||(this.sortBySortKey=!0),void 0===this.collection[e.sortType]&&(this.collection[e.sortType]=[]),this.collection[e.sortType].push(e),this.length++,this.context&&this.gl&&this.context.setupShape(this.gl,e,this.viewarea)},x3dom.DrawableCollection.prototype.calculatePriority=function(e){var t=Math.max(0,e.coverage),i=this.prioLevels-1;return t=Math.min(Math.round(t/(this.maxTreshold/i)),i)},x3dom.DrawableCollection.prototype.concat=function(){var e=void 0!==this.collection.opaque?this.collection.opaque:[],t=void 0!==this.collection.transparent?this.collection.transparent:[];this.collection=e.concat(t)},x3dom.DrawableCollection.prototype.get=function(e){return this.collection[e]},x3dom.DrawableCollection.prototype.sort=function(){var e=[],t=[],i=this;void 0!==this.collection.opaque&&(this.sortOpaque&&this.collection.opaque.sort((function(e,t){return e.sortKey!=t.sortKey&&i.sortBySortKey?e.sortKey-t.sortKey:t.priority-e.priority})),e=this.collection.opaque),void 0!==this.collection.transparent&&(this.sortTrans&&this.collection.transparent.sort((function(e,t){return e.sortKey!=t.sortKey&&i.sortBySortKey?e.sortKey-t.sortKey:e.priority!=t.priority&&i.sortByPriority?t.priority-e.priority:e.zPos-t.zPos})),t=this.collection.transparent),this.collection=e.concat(t)},x3dom.DrawableCollection.prototype.forEach=function(e,t){var i,o,s,r;for(t=void 0!==t?Math.min(t,this.prioLevels):this.prioLevels,i=0;i0;--o)if(void 0!==this.collection.opaque[i][o])for(s in this.collection.opaque[i][o])for(r=0;r0;--o)if(void 0!==this.collection.transparent[i][o])for(var n in this.collection.transparent[i][o])for(this.collection.transparent[i][o][n].sort((function(e,t){return e.zPos-t.zPos})),r=0;r0&&4!=o._buttonState){var a=o._gridSize*Math.round(n.x/o._gridSize),d=o._gridSize*Math.round(n.y/o._gridSize),l=o._gridSize*Math.round(n.z/o._gridSize);n=new x3dom.fields.SFVec3f(a,d,l)}o._matrixTrafo?(4==o._buttonState?o._matrixTrafo.setRotate(n):o._matrixTrafo.setTranslate(n),o._moveable.setAttribute(\"matrix\",o._matrixTrafo.toGL().toString())):4==o._buttonState?o._moveable.setAttribute(\"rotation\",n.toAxisAngle().toString()):o._moveable.setAttribute(\"translation\",n.toString()),o._callback&&o._callback(o._moveable,n)}o._lastX=s[0],o._lastY=s[1]}}},x3dom.Moveable.prototype.stop=function(e){for(var t=0,i=this._iMove.length;t1e5&&(r=s=-1),i.setAttribute(\"DEF\",e),i.setAttribute(\"fieldOfView\",o),i.setAttribute(\"zNear\",s),i.setAttribute(\"zFar\",r),i.setAttribute(\"position\",\"0 0 0\"),i},x3dom.glTF2Loader.prototype._generateX3DOrthoViewpoint=function(e,t){var i=document.createElement(\"orthoviewpoint\");this._generateX3DMetadata(t,i);var o=t.xmag||1,s=t.ymag||1,r=t.znear||-1,n=t.zfar||-1,a=[-o,-s,o,s];return i.setAttribute(\"DEF\",e),i.setAttribute(\"fieldOfView\",a),i.setAttribute(\"zNear\",r),i.setAttribute(\"zFar\",n),i.setAttribute(\"position\",\"0 0 0\"),i},x3dom.glTF2Loader.prototype._generateX3DShape=function(e){var t=document.createElement(\"shape\");this._generateX3DMetadata(e,t);var i=null!=e.material?this._gltf.materials[e.material]:{name:\"DEFAULT\"};null==i.name&&(i.name=e.material),t.appendChild(this._generateX3DAppearance(i));var o=null;return e.extensions&&e.extensions.KHR_draco_mesh_compression&&(o=e.extensions.KHR_draco_mesh_compression),o&&!x3dom.DracoDecoderModule?t:(t.appendChild(this._generateX3DBufferGeometry(e,o)),t)},x3dom.glTF2Loader.prototype._generateX3DAppearance=function(e){var t=document.createElement(\"appearance\");return this._generateX3DMetadata(e,t),\"BLEND\"===e.alphaMode?t.setAttribute(\"sortType\",\"transparent\"):t.setAttribute(\"sortType\",\"opaque\"),t.setAttribute(\"alphaClipThreshold\",0),t.appendChild(this._generateX3DPhysicalMaterial(e)),this._textureTransform&&(t.appendChild(this._textureTransform),this._textureTransform=void 0),t},x3dom.glTF2Loader.prototype._generateX3DPhysicalMaterial=function(e){var t=document.createElement(\"physicalmaterial\");if(this._USEorDEF(t,\"glTF_MATERIAL_\"+e.name))return t;var i,o,s=[1,1,1,1],r=e.emissiveFactor||[0,0,0],n=1,a=1,d=e.alphaMode||\"OPAQUE\",l=e.alphaCutoff||.5,h=!0,f=void 0,u=void 0,c=0;if(e.pbrMetallicRoughness?(u=e.pbrMetallicRoughness,f=\"roughnessMetallic\"):e.extensions&&e.extensions.KHR_materials_pbrSpecularGlossiness&&(u=e.extensions.KHR_materials_pbrSpecularGlossiness,f=\"specularGlossiness\"),\"roughnessMetallic\"==f){s=u.baseColorFactor||[1,1,1,1],n=null!=u.metallicFactor?u.metallicFactor:1,a=null!=u.roughnessFactor?u.roughnessFactor:1;u.baseColorTexture&&(c=u.baseColorTexture.texCoord?1:0,i=this._gltf.textures[u.baseColorTexture.index],o=u.baseColorTexture.extensions&&u.baseColorTexture.extensions.KHR_texture_transform?u.baseColorTexture.extensions.KHR_texture_transform:void 0,t.appendChild(this._generateX3DImageTexture(i,\"baseColorTexture\",c,o))),u.metallicRoughnessTexture&&(c=u.metallicRoughnessTexture.texCoord?1:0,i=this._gltf.textures[u.metallicRoughnessTexture.index],o=u.metallicRoughnessTexture.extensions&&u.metallicRoughnessTexture.extensions.KHR_texture_transform?u.metallicRoughnessTexture.extensions.KHR_texture_transform:void 0,e.occlusionTexture&&e.occlusionTexture.index==u.metallicRoughnessTexture.index?(h=!1,t.appendChild(this._generateX3DImageTexture(i,\"occlusionRoughnessMetallicTexture\",c,o))):t.appendChild(this._generateX3DImageTexture(i,\"roughnessMetallicTexture\",c,o))),t.setAttribute(\"baseColorFactor\",s.join(\" \")),t.setAttribute(\"metallicFactor\",n),t.setAttribute(\"roughnessFactor\",a)}else if(\"specularGlossiness\"==f){var _=u.diffuseFactor||[1,1,1,1],m=u.specularFactor||[1,1,1],p=null!=u.glossinessFactor?u.glossinessFactor:1;u.diffuseTexture&&(c=u.diffuseTexture.texCoord?1:0,i=this._gltf.textures[u.diffuseTexture.index],o=u.diffuseTexture.extensions&&u.diffuseTexture.extensions.KHR_texture_transform?u.diffuseTexture.extensions.KHR_texture_transform:void 0,t.appendChild(this._generateX3DImageTexture(i,\"baseColorTexture\",c,o))),u.specularGlossinessTexture&&(c=u.specularGlossinessTexture.texCoord?1:0,i=this._gltf.textures[u.specularGlossinessTexture.index],o=u.specularGlossinessTexture.extensions&&u.specularGlossinessTexture.extensions.KHR_texture_transform?u.specularGlossinessTexture.extensions.KHR_texture_transform:void 0,t.appendChild(this._generateX3DImageTexture(i,\"specularGlossinessTexture\",c,o))),t.setAttribute(\"diffuseFactor\",_.join(\" \")),t.setAttribute(\"specularFactor\",m.join(\" \")),t.setAttribute(\"glossinessFactor\",p)}return e.normalTexture&&(c=e.normalTexture.texCoord?1:0,i=this._gltf.textures[e.normalTexture.index],o=e.normalTexture.extensions&&e.normalTexture.extensions.KHR_texture_transform?e.normalTexture.extensions.KHR_texture_transform:void 0,t.appendChild(this._generateX3DImageTexture(i,\"normalTexture\",c,o))),e.emissiveTexture&&(c=e.emissiveTexture.texCoord?1:0,i=this._gltf.textures[e.emissiveTexture.index],o=e.emissiveTexture.extensions&&e.emissiveTexture.extensions.KHR_texture_transform?e.emissiveTexture.extensions.KHR_texture_transform:void 0,t.appendChild(this._generateX3DImageTexture(i,\"emissiveTexture\",c,o))),e.occlusionTexture&&h&&(c=e.occlusionTexture.texCoord?1:0,i=this._gltf.textures[e.occlusionTexture.index],o=e.occlusionTexture.extensions&&e.occlusionTexture.extensions.KHR_texture_transform?e.occlusionTexture.extensions.KHR_texture_transform:void 0,t.appendChild(this._generateX3DImageTexture(i,\"occlusionTexture\",c,o))),e.extensions&&e.extensions.KHR_materials_unlit&&t.setAttribute(\"unlit\",!0),t.setAttribute(\"emissiveFactor\",r.join(\" \")),t.setAttribute(\"alphaMode\",d),t.setAttribute(\"alphaCutoff\",l),t.setAttribute(\"model\",f),t},x3dom.glTF2Loader.prototype._generateX3DImageTexture=function(e,t,i,o){var s=this._gltf.images[e.source],r=document.createElement(\"imagetexture\");if(this._generateX3DMetadata(e,r),r.setAttribute(\"origChannelCount\",\"2\"),r.setAttribute(\"flipY\",\"true\"),t&&r.setAttribute(\"containerField\",t),null!=s.uri&&r.setAttribute(\"url\",x3dom.Utils.dataURIToObjectURL(s.uri)),null!=e.sampler){var n=this._gltf.samplers[e.sampler];r.appendChild(this._createX3DTextureProperties(n))}return i&&r.setAttribute(\"channel\",\"1\"),o&&(this._textureTransform=this._createX3DTextureTransform(r,o)),r},x3dom.glTF2Loader.prototype._createX3DTextureProperties=function(e){var t=document.createElement(\"textureproperties\");return t.setAttribute(\"boundaryModeS\",x3dom.Utils.boundaryModesDicX3D(e.wrapS)),t.setAttribute(\"boundaryModeT\",x3dom.Utils.boundaryModesDicX3D(e.wrapT)),t.setAttribute(\"magnificationFilter\",x3dom.Utils.magFilterDicX3D(e.magFilter)),t.setAttribute(\"minificationFilter\",x3dom.Utils.minFilterDicX3D(e.minFilter)),(null==e.minFilter||e.minFilter>=9984&&e.minFilter<=9987)&&t.setAttribute(\"generateMipMaps\",\"true\"),t},x3dom.glTF2Loader.prototype._createX3DTextureTransform=function(e,t){var i=document.createElement(\"matrixtexturetransform\"),o=t.offset||[0,0],s=t.rotation||0,r=t.scale||[1,1],n=new x3dom.fields.SFVec3f(-0,-0,0),a=new x3dom.fields.SFVec3f(0,0,0),d=new x3dom.fields.SFVec3f(o[0],o[1],0),l=new x3dom.fields.SFVec3f(r[0],r[1],0),h=x3dom.fields.SFMatrix4f.translation(a.add(d)).mult(x3dom.fields.SFMatrix4f.rotationZ(-1*s)).mult(x3dom.fields.SFMatrix4f.scale(l)).mult(x3dom.fields.SFMatrix4f.translation(n));return i.setAttribute(\"matrix\",h.toString()),t.texCoord&&e.setAttribute(\"channel\",texCoord),i},x3dom.glTF2Loader.prototype._generateX3DBufferGeometry=function(e,t){var i,o,s,r,n=[],a=document.createElement(\"buffergeometry\"),d=this._getCenterAndSize(e);(i=t?x3dom.Utils.dataURIToObjectURL(this._gltf.buffers[this._gltf.bufferViews[t.bufferView].buffer].uri):this._bufferURI(e),a.setAttribute(\"buffer\",i),a.setAttribute(\"position\",d.center.join(\" \")),a.setAttribute(\"size\",d.size.join(\" \")),a.setAttribute(\"vertexCount\",this._getVertexCount(e)),a.setAttribute(\"primType\",this._primitiveType(e.mode)),a.setAttribute(\"draco\",null!==t),null!=e.material)&&(this._gltf.materials[e.material].doubleSided&&a.setAttribute(\"solid\",\"false\"));null!=e.indices&&(r=this._gltf.accessors[e.indices],t?((o=Object.assign({},this._gltf.bufferViews[t.bufferView])).idx=t.bufferView,o.target=34963,s=n.push(o)-1):((o=Object.assign({},this._gltf.bufferViews[r.bufferView])).idx=r.bufferView,o.target=34963,s=n.indexOf(o),null!=o.target&&-1==s&&(s=n.push(o)-1)),a.appendChild(this._generateX3DBufferAccessor(\"INDEX\",r,s)));var l=t?t.attributes:e.attributes;for(var h in l)r=this._gltf.accessors[e.attributes[h]],t?((o=Object.assign({},this._gltf.bufferViews[t.bufferView])).target=34962,o.idx=t.bufferView,o.dracoUniqueId=t.attributes[h],s=n.push(o)-1):((o=Object.assign({},this._gltf.bufferViews[r.bufferView])).target=34962,o.idx=r.bufferView,s=n.indexOf(o),null!=o.target&&-1==s&&(s=n.push(o)-1)),a.appendChild(this._generateX3DBufferAccessor(h,r,s));for(var f=0;f>8&255,e>>16&255,e>>24&255).replace(/[\\x00]/g,\"\")},x3dom.DDSLoader.R8G8B8_To_B8G8R8=function(e){for(var t=new Uint8Array(e.length),i=0;i>15&1,i=e>>10&1023,o=e&Math.pow(2,10)-1;return 0!==i?Math.pow(-1,t)*(1+o/Math.pow(2,10))*Math.pow(2,i-15):0===o?0:Math.pow(-1,t)*o/Math.pow(2,10)*Math.pow(2,-14)},x3dom.DDSLoader.UI16_To_UI8_2=function(e){var t=x3dom.DDSLoader.UI16_To_F16(e);return t/(t+1)},x3dom.DDSLoader.A4R4G4B4_To_A4B4G4R4=function(e){for(var t,i,o,s,r=new Uint16Array(e.length),n=0;n>12&15,i=e[n]>>8&15,o=e[n]>>4&15,s=15&e[n],r[n]=i<<12&o<<8&s<<4&t;return r},x3dom.DDSLoader.A1R5G5B5_To_A1B5G5R5=function(e){for(var t,i,o,s,r=new Uint16Array(e.length),n=0;n>15&1,i=e[n]>>10&31,o=e[n]>>5&95,s=95&e[n],r[n]=i<<11&o<<6&s<<1&t;return r},x3dom.VRControllerManager=function(e){this.leftInline=void 0,this.leftTransform=void 0,this.rightInline=void 0,this.rightTransform=void 0,this.wasPresenting=!1,this.modelsAdded=!1,this._doc=e,this._controllers={\"htc-vive\":{left:\"https://x3dom.org/download/assets/vr/vive.glb\",right:\"https://x3dom.org/download/assets/vr/vive.glb\",scaleFactor:new x3dom.fields.SFVec3f(40,40,40),offset:new x3dom.fields.SFVec3f,axesScale:[1,1]},\"oculus-touch\":{left:\"https://x3dom.org/download/assets/vr/oculus-touch-left.glb\",right:\"https://x3dom.org/download/assets/vr/oculus-touch-right.glb\",scaleFactor:new x3dom.fields.SFVec3f(39.5,39.5,39.5),offset:new x3dom.fields.SFVec3f,axesScale:[1,1]},\"oculus-go\":{left:\"https://x3dom.org/download/assets/vr/oculus-go.glb\",right:\"https://x3dom.org/download/assets/vr/oculus-go.glb\",scaleFactor:new x3dom.fields.SFVec3f(1,1,1),offset:new x3dom.fields.SFVec3f(.2,-.3,-.3),axesScale:[-1,1]}},this._addInlines()},x3dom.VRControllerManager.prototype._addInlines=function(){var e=document.querySelector(\"scene\")||document.querySelector(\"Scene\");e&&(this.leftTransform=document.createElement(\"matrixtransform\"),this.leftInline=document.createElement(\"inline\"),this.rightTransform=document.createElement(\"matrixtransform\"),this.rightInline=document.createElement(\"inline\"),this.leftInline.setAttribute(\"render\",\"false\"),this.rightInline.setAttribute(\"render\",\"false\"),this.leftTransform.appendChild(this.leftInline),this.rightTransform.appendChild(this.rightInline),e.appendChild(this.leftTransform),e.appendChild(this.rightTransform))},x3dom.VRControllerManager.prototype._addControllerModels=function(e){if(!this.modelsAdded){if(e.left){const t=this._getControllerModelURL(e.left.type,\"left\");this.leftInline.setAttribute(\"url\",t)}if(e.right){const t=this._getControllerModelURL(e.right.type,\"right\");this.rightInline.setAttribute(\"url\",t)}this.modelsAdded=!0}},x3dom.VRControllerManager.prototype._getControllerAxesScale=function(e){return void 0===this._controllers[e]?[1,1]:this._controllers[e].axesScale},x3dom.VRControllerManager.prototype._getControllerDirection=function(e){return(e.orientation?x3dom.fields.Quaternion.fromArray(e.orientation):new x3dom.fields.Quaternion).toMatrix().e2()},x3dom.VRControllerManager.prototype._getControllerModelURL=function(e,t){return void 0===this._controllers[e]?\"\":this._controllers[e][t]},x3dom.VRControllerManager.prototype._getControllerOffset=function(e){return void 0===this._controllers[e]?[0,0,0]:this._controllers[e].offset},x3dom.VRControllerManager.prototype._getControllerScaleFactor=function(e){return void 0===this._controllers[e]?[1,1,1]:this._controllers[e].scaleFactor},x3dom.VRControllerManager.prototype.fit=function(e){var t=e._scene._lastMin,i=e._scene._lastMax.subtract(t).multiply(.5).length(),o=e.vrLeftViewMatrix.e2(),s=Math.min(e._width/e._height,1),r=i/Math.tan(.5*Math.PI/2)/s;e._movement=o.multiply(-.001*r)},x3dom.VRControllerManager.prototype.update=function(e,t){t?(this.wasPresenting||(this.leftInline.setAttribute(\"render\",\"true\"),this.rightInline.setAttribute(\"render\",\"true\"),this.fit(e),this.wasPresenting=!0),this._addControllerModels(t.controllers),this._updateMatrices(e,t.controllers),this._updateControllerModels(e,t.controllers)):this.wasPresenting&&(this.leftInline.setAttribute(\"render\",\"false\"),this.rightInline.setAttribute(\"render\",\"false\"),this.wasPresenting=!1)},x3dom.VRControllerManager.prototype._updateMatrices=function(e,t){var i=new x3dom.fields.SFMatrix4f,o=new x3dom.fields.SFMatrix4f,s=[0,0];if(t.left){var r=this._getControllerAxesScale(t.left.type);if(s[0]+=t.left.gamepad.axes[0]*r[0],s[1]+=t.left.gamepad.axes[1]*r[1],t.left.gamepad.buttons[0].pressed){const i=t.left.pose,o=this._getControllerDirection(i),s=this._getViewAreaZoom(e);e._movement=e._movement.add(o.multiply(s))}}if(t.right){r=this._getControllerAxesScale(t.right.type);if(s[0]+=t.right.gamepad.axes[0]*r[0],s[1]+=t.right.gamepad.axes[1]*r[1],t.right.gamepad.buttons[0].pressed){const i=t.right.pose,o=this._getControllerDirection(i),s=this._getViewAreaZoom(e);e._movement=e._movement.add(o.multiply(s))}}var n=5*s[0],a=5*s[1],d=e.vrLeftViewMatrix.e2(),l=e.vrLeftViewMatrix.e0(),h=e._scene._lastMax.subtract(e._scene._lastMin).length();h=h\").replace(/&/g,\"&\");do{o=(i=o).replace(/'([^'\\r\\n]*)\\n([^']*)'/g,\"'$1\\\\n$2'\")}while(o!=i);var s=\"\n", - "
\n", + "
\n", " \n", "\n", "\n", @@ -4761,10 +4789,8 @@ " is interacting in a click-and-drag manner, and toggles the rotation\n", " when the user clicks on the scene\n", "\n", - "This script is modified before use to replace all instances of the string\n", - "\"uid\" with a unique (and variable-name allowable) identifier. This is to\n", - "ensure that the script can be used multiple times on the same page without\n", - "conflicting with itself.\n", + "This script is modified before use to replace the config object with the\n", + "actual configuration.\n", "\n", "See load_atoms.visualise for how exactly this is done.\n", "*/\n", @@ -4773,7 +4799,7 @@ "// and to allow for multiple instances of this script\n", "(function () {\n", " // start of replace me\n", - " const config = {\"id\": \"bhdaefagijiddigc\", \"currentlyRotating\": true, \"rotationSpeed\": 0.3};\n", + " const config = {\"id\": \"bhdjgbffbajiefaf\", \"currentlyRotating\": true, \"rotationSpeed\": 0.3};\n", "\n", " // ~~~~~~~~\n", " // ROTATION\n", @@ -4840,7 +4866,7 @@ "" ] }, - "execution_count": 8, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -4855,7 +4881,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 13, "metadata": {}, "outputs": [ { @@ -4872,7 +4898,7 @@ " */\n", "var x3dom={canvases:[],x3dNS:\"http://www.web3d.org/specifications/x3d-namespace\",x3dextNS:\"http://philip.html5.org/x3d/ext\",xsltNS:\"http://www.w3.org/1999/XSL/x3dom.Transform\",xhtmlNS:\"http://www.w3.org/1999/xhtml\"};function defineClass(e,t,i){if(e){function o(){}o.prototype=e.prototype,t.prototype=new o,t.prototype.constructor=t,t.superClass=e}if(i)for(var s in i)t.prototype[s]=i[s];return t}function array_to_object(e){for(var t={},i=0;ix3dom.debug.maxLinesToLog))){var i=document.createElement(\"p\");switch(i.style.margin=0,t){case x3dom.debug.INFO:i.style.color=\"#00ff00\";break;case x3dom.debug.WARNING:i.style.color=\"#cd853f\";break;case x3dom.debug.ERROR:i.style.color=\"#ff4500\";break;case x3dom.debug.EXCEPTION:i.style.color=\"#ffff00\";break;default:i.style.color=\"#00ff00\"}try{i.innerHTML=t+\": \"+e,x3dom.debug.logContainer.insertBefore(i,x3dom.debug.logContainer.firstChild)}catch(t){void 0!==window.console.firebug&&window.console.warn(e)}if(x3dom.debug.isFirebugAvailable)switch(t){case x3dom.debug.INFO:window.console.info(e);break;case x3dom.debug.WARNING:window.console.warn(e);break;case x3dom.debug.ERROR:window.console.error(e);break;case x3dom.debug.EXCEPTION:window.console.debug(e)}x3dom.debug.numLinesLogged++}},logInfo:function(e){x3dom.debug.doLog(e,x3dom.debug.INFO)},logWarning:function(e){x3dom.debug.doLog(e,x3dom.debug.WARNING)},logError:function(e){x3dom.debug.doLog(e,x3dom.debug.ERROR)},logException:function(e){x3dom.debug.doLog(e,x3dom.debug.EXCEPTION)},assert:function(e,t){e||x3dom.debug.doLog(\"Assertion failed in \"+x3dom.debug.assert.caller.name+\": \"+t,x3dom.debug.ERROR)},typeOf:function(e){var t=typeof e;return\"object\"!==t||e?t:\"null\"},exists:function(e,t,i){return i=i||\"function\",(e?this.typeOf(e[t]):\"null\")===i},dumpFields:function(e){var t=\"\";for(var i in e)t+=i+\", \";return t+=\"\\n\",x3dom.debug.logInfo(t),t}},x3dom.debug.setup(),x3dom.X3DCanvas=function(e,t){var i=this;if(this._canvasIdx=t,this.x3dElem=e,this._current_dim=[0,0],this.fps_t0=(new Date).getTime(),this.lastTimeFPSWasTaken=0,this.framesSinceLastTime=0,this._totalTime=0,this._elapsedTime=0,this.doc=null,this.isSessionSupportedPromise=null,this.xrSession=null,this.xrReferenceSpace=null,this.supportsPassiveEvents=!1,this.devicePixelRatio=window.devicePixelRatio||1,this.lastMousePos={x:0,y:0},x3dom.caps.DOMNodeInsertedEvent_perSubtree=!(-1!=navigator.userAgent.indexOf(\"MSIE\")||-1!=navigator.userAgent.indexOf(\"Trident\")),e.__setAttribute=e.setAttribute,e.setAttribute=function(e,t){switch(this.__setAttribute(e,t),t=parseInt(t),e){case\"width\":i.canvas.setAttribute(\"width\",t*i.devicePixelRatio),i.doc&&i.doc._viewarea&&(i.doc._viewarea._width=parseInt(i.canvas.getAttribute(\"width\"),0),i.doc.needRender=!0);break;case\"height\":i.canvas.setAttribute(\"height\",t*i.devicePixelRatio),i.doc&&i.doc._viewarea&&(i.doc._viewarea._height=parseInt(i.canvas.getAttribute(\"height\"),0),i.doc.needRender=!0)}},this.backend=this.x3dElem.getAttribute(\"backend\"),this.backend=this.backend?this.backend.toLowerCase():\"none\",this.canvas=this._createHTMLCanvas(e),x3dom.debug.appendElement(e),this.canvas.parent=this,this.gl=this._initContext(this.canvas),this.backend=\"webgl\",null==this.gl)return this.hasRuntime=!1,void this._createInitFailedDiv(e);x3dom.caps.BACKEND=this.backend;var o=e.getAttribute(\"runtimeEnabled\");this.hasRuntime=null!==o?\"true\"==o.toLowerCase():e.hasRuntime,this.showStat=e.getAttribute(\"showStat\"),this.stateViewer=new x3dom.States(e),null!==this.showStat&&\"true\"==this.showStat&&this.stateViewer.display(!0),this.x3dElem.appendChild(this.stateViewer.viewer),this.showProgress=e.getAttribute(\"showProgress\"),this.progressDiv=this._createProgressDiv(),this.progressDiv.style.display=null!==this.showProgress&&\"true\"==this.showProgress?\"flex\":\"none\",this.x3dElem.appendChild(this.progressDiv),this.vrDiv=this._createVRDiv(),this.x3dElem.appendChild(this.vrDiv),this.showTouchpoints=e.getAttribute(\"showTouchpoints\"),this.showTouchpoints=!!this.showTouchpoints&&this.showTouchpoints,this.disableTouch=e.getAttribute(\"disableTouch\"),this.disableTouch=!!this.disableTouch&&\"true\"==this.disableTouch.toLowerCase(),this.disableKeys=e.getAttribute(\"disableKeys\"),this.disableKeys=!!this.disableKeys&&\"true\"==this.disableKeys.toLowerCase(),this.disableRightDrag=e.getAttribute(\"disableRightDrag\"),this.disableRightDrag=!!this.disableRightDrag&&\"true\"==this.disableRightDrag.toLowerCase(),this.disableLeftDrag=e.getAttribute(\"disableLeftDrag\"),this.disableLeftDrag=!!this.disableLeftDrag&&\"true\"==this.disableLeftDrag.toLowerCase(),this.disableMiddleDrag=e.getAttribute(\"disableMiddleDrag\"),this.disableMiddleDrag=!!this.disableMiddleDrag&&\"true\"==this.disableMiddleDrag.toLowerCase(),this.detectPassiveEvents(),this.bindEventListeners()},x3dom.X3DCanvas.prototype.detectPassiveEvents=function(){if(\"undefined\"!=typeof window&&\"function\"==typeof window.addEventListener){var e=!1,t=Object.defineProperty({},\"passive\",{get:function(){e=!0}}),i=function(){};window.addEventListener(\"testPassiveEventSupport\",i,t),window.removeEventListener(\"testPassiveEventSupport\",i,t),this.supportsPassiveEvents=e}},x3dom.X3DCanvas.prototype.bindEventListeners=function(){var e=this;if(this.onMouseDown=function(t){if(!this.isMulti){switch(this.focus(),this.classList.add(\"x3dom-canvas-mousedown\"),t.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}t.shiftKey&&(this.mouse_button=1),t.ctrlKey&&(this.mouse_button=4),t.altKey&&(this.mouse_button=2);var i=this.parent.mousePosition(t);this.mouse_drag_x=i.x,this.mouse_drag_y=i.y,this.mouse_dragging=!0,this.parent.doc.onMousePress(e.gl,this.mouse_drag_x,this.mouse_drag_y,this.mouse_button),this.parent.doc.needRender=!0}},this.onMouseUp=function(t){if(!this.isMulti){var i=this.mouse_button;this.classList.remove(\"x3dom-canvas-mousedown\"),this.mouse_button=0,this.mouse_dragging=!1,this.parent.doc.onMouseRelease(e.gl,this.mouse_drag_x,this.mouse_drag_y,this.mouse_button,i),this.parent.doc.needRender=!0}},this.onMouseOver=function(t){this.isMulti||(this.mouse_button=0,this.mouse_dragging=!1,this.parent.doc.onMouseOver(e.gl,this.mouse_drag_x,this.mouse_drag_y,this.mouse_button),this.parent.doc.needRender=!0)},this.onMouseOut=function(t){this.isMulti||(this.mouse_button=0,this.mouse_dragging=!1,this.classList.remove(\"x3dom-canvas-mousedown\"),this.parent.doc.onMouseOut(e.gl,this.mouse_drag_x,this.mouse_drag_y,this.mouse_button),this.parent.doc.needRender=!0)},this.onDoubleClick=function(t){if(!this.isMulti){this.mouse_button=0;var i=this.parent.mousePosition(t);this.mouse_drag_x=i.x,this.mouse_drag_y=i.y,this.mouse_dragging=!1,this.parent.doc.onDoubleClick(e.gl,this.mouse_drag_x,this.mouse_drag_y),this.parent.doc.needRender=!0}},this.onMouseMove=function(t){if(!this.isMulti){var i=this.parent.mousePosition(t);i.x==e.lastMousePos.x&&i.y==e.lastMousePos.y||(e.lastMousePos=i,this.mouse_drag_x=i.x,this.mouse_drag_y=i.y,this.mouse_dragging?(t.shiftKey&&(this.mouse_button=1),t.ctrlKey&&(this.mouse_button=4),t.altKey&&(this.mouse_button=2),(1==this.mouse_button&&!this.parent.disableLeftDrag||2==this.mouse_button&&!this.parent.disableRightDrag||4==this.mouse_button&&!this.parent.disableMiddleDrag)&&this.parent.doc.onDrag(e.gl,this.mouse_drag_x,this.mouse_drag_y,this.mouse_button)):this.parent.doc.onMove(e.gl,this.mouse_drag_x,this.mouse_drag_y,this.mouse_button),this.parent.doc.needRender=!0,t.preventDefault(),t.stopPropagation())}},this.onDOMMouseScroll=function(t){if(!this.isMulti){this.focus();var i=this.parent.mousePosition(t).y;1==this.parent.doc._scene.getNavigationInfo()._vf.reverseScroll?this.mouse_drag_y-=2*t.detail:this.mouse_drag_y+=2*t.detail,this.parent.doc.onWheel(e.gl,this.mouse_drag_x,this.mouse_drag_y,i),this.parent.doc.needRender=!0,t.preventDefault(),t.stopPropagation()}},this.onKeyPress=function(e){this.parent.disableKeys||(e.preventDefault(),this.parent.doc.onKeyPress(e.charCode)),this.parent.doc.needRender=!0},this.onMouseWheel=function(t){if(!this.isMulti){this.focus();var i=this.parent.mousePosition(t).y;1==this.parent.doc._scene.getNavigationInfo()._vf.reverseScroll?this.mouse_drag_y+=.1*t.wheelDelta:this.mouse_drag_y-=.1*t.wheelDelta,this.parent.doc.onWheel(e.gl,this.mouse_drag_x,this.mouse_drag_y,i),this.parent.doc.needRender=!0,t.preventDefault(),t.stopPropagation()}},this.onKeyUp=function(e){this.parent.disableKeys||this.parent.doc.onKeyUp(e.keyCode),this.parent.doc.needRender=!0},this.onKeyDown=function(e){this.parent.disableKeys||this.parent.doc.onKeyDown(e.keyCode),this.parent.doc.needRender=!0},null!==this.canvas&&null!==this.gl&&this.hasRuntime){this.canvas.mouse_dragging=!1,this.canvas.mouse_button=0,this.canvas.mouse_drag_x=0,this.canvas.mouse_drag_y=0,this.canvas.isMulti=!1,this.canvas.oncontextmenu=function(e){return e.preventDefault(),e.stopPropagation(),!1},this.canvas.addEventListener(\"webglcontextlost\",(function(e){x3dom.debug.logError(\"WebGL context lost\"),e.preventDefault()}),!1),this.canvas.addEventListener(\"webglcontextrestored\",(function(e){x3dom.debug.logError(\"recover WebGL state and resources on context lost NYI\"),e.preventDefault()}),!1),this.canvas.addEventListener(\"mousedown\",this.onMouseDown,!1),this.canvas.addEventListener(\"mouseup\",this.onMouseUp,!1),this.canvas.addEventListener(\"mouseover\",this.onMouseOver,!1),this.canvas.addEventListener(\"mouseout\",this.onMouseOut,!1),this.canvas.addEventListener(\"dblclick\",this.onDoubleClick,!1),this.canvas.addEventListener(\"mousemove\",this.onMouseMove,!1),this.canvas.addEventListener(\"DOMMouseScroll\",this.onDOMMouseScroll,!1),this.canvas.addEventListener(\"mousewheel\",this.onMouseWheel,!!this.supportsPassiveEvents&&{passive:!1}),this.canvas.addEventListener(\"keypress\",this.onKeyPress,!0),this.canvas.addEventListener(\"keyup\",this.onKeyUp,!0),this.canvas.addEventListener(\"keydown\",this.onKeyDown,!0);var t={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(e){var t=e.normalize().dot(new x3dom.fields.SFVec2f(1,0));return t=Math.acos(t),e.y<0&&(t=Math.PI+(Math.PI-t)),t},disableTouch:this.disableTouch,visMarker:this.showTouchpoints,visMarkerBag:[],visualizeTouches:function(e){if(this.visMarker){for(var t=[],i=null,o=0;o=0?((i=document.getElementById(\"visMarker\"+s)).style.left=e.touches[o].pageX+\"px\",i.style.top=e.touches[o].pageY+\"px\"):((i=document.createElement(\"div\")).appendChild(document.createTextNode(\"#\"+s)),i.id=\"visMarker\"+s,i.className=\"x3dom-touch-marker\",document.body.appendChild(i),r=this.visMarkerBag.length,this.visMarkerBag[r]=s),t.push(s)}for(var n=this.visMarkerBag.length-1;n>=0;n--){var a=this.visMarkerBag[n];t.indexOf(a)<0&&(this.visMarkerBag.splice(n,1),i=document.getElementById(\"visMarker\"+a),document.body.removeChild(i))}}}};this.disableTouch||(this.canvas.addEventListener(\"touchstart\",(function(i,o){var s,r;switch(this.isMulti=!0,i.preventDefault(),t.visualizeTouches(i),this.focus(),null==o&&(o=this.parent.doc),o._scene.getNavigationInfo().getType()){case\"examine\":t.examineNavType=1;break;case\"turntable\":t.examineNavType=2;break;default:t.examineNavType=0}for(t.lastLayer=[],s=0;s=2){t.numTouches=2;var n=new x3dom.fields.SFVec2f(i.touches[0].screenX,i.touches[0].screenY),a=new x3dom.fields.SFVec2f(i.touches[1].screenX,i.touches[1].screenY).subtract(n),d=a.multiply(.5).add(n),l=a.dot(a);t.lastMiddle=d,t.lastSquareDistance=l,t.lastAngle=t.calcAngle(a),t.lastPos=this.parent.mousePosition(i.touches[0])}if(o._scene.updateVolume(),1==t.examineNavType)for(s=0;s=2){s=new x3dom.fields.SFVec2f(i.touches[0].screenX,i.touches[0].screenY),n=(r=new x3dom.fields.SFVec2f(i.touches[1].screenX,i.touches[1].screenY).subtract(s)).multiply(.5).add(s),a=r.dot(r),d=n.subtract(t.lastMiddle),l=a-t.lastSquareDistance,h=new x3dom.fields.SFVec3f(d.x/screen.width,-d.y/screen.height,l/(screen.width*screen.height*.2));var x=t.calcAngle(r),g=t.lastAngle-x;t.lastAngle=x,u=x3dom.fields.SFMatrix4f.rotationZ(g),t.lastMiddle=n,t.lastSquareDistance=a,o.onMoveView(e.gl,i,t,h,u)}}else i.touches.length&&(2==t.examineNavType&&i.touches.length>=2?(s=new x3dom.fields.SFVec2f(i.touches[0].screenX,i.touches[0].screenY),l=((a=(r=new x3dom.fields.SFVec2f(i.touches[1].screenX,i.touches[1].screenY).subtract(s)).dot(r))-t.lastSquareDistance)/(.1*(screen.width+screen.height)),t.lastPos.y+=l,t.lastSquareDistance=a,o.onDrag(e.gl,t.lastPos.x,t.lastPos.y,2)):(f=this.parent.mousePosition(i.touches[0]),o.onDrag(e.gl,f.x,f.y,1)));o.needRender=!0}),!this.supportsPassiveEvents||{passive:!1}),this.canvas.addEventListener(\"touchend\",(function(i,o){if(this.isMulti=!1,i.cancelable&&i.preventDefault(),t.visualizeTouches(i),null==o&&(o=this.parent.doc),o._viewarea._isMoving=!1,2==t.numTouches&&1==i.touches.length&&(t.lastDrag=new x3dom.fields.SFVec2f(i.touches[0].screenX,i.touches[0].screenY)),0==i.touches.length){for(var s=o._nodeBag.affectedPointingSensors,r=0;r=0&&x3dom.debug.logWarning(\"The width attribute is to be specified in pixels not in percent.\"),t.style.width=a,e.style.width=a,t.setAttribute(\"width\",a)),null!==(d=e.getAttribute(\"height\"))&&(d.indexOf(\"%\")>=0&&x3dom.debug.logWarning(\"The height attribute is to be specified in pixels not in percent.\"),t.style.height=d,e.style.height=d,t.setAttribute(\"height\",d)),t.setAttribute(\"tabindex\",\"0\"),t},x3dom.X3DCanvas.prototype._watchForResize=function(){if(!this.xrSession){var e=[parseInt(x3dom.getStyle(this.canvas,\"width\"))||0,parseInt(x3dom.getStyle(this.canvas,\"height\"))||0];this._current_dim[0]==e[0]&&this._current_dim[1]==e[1]||(this._current_dim=e,this.x3dElem.setAttribute(\"width\",e[0]+\"px\"),this.x3dElem.setAttribute(\"height\",e[1]+\"px\"))}},x3dom.X3DCanvas.prototype._createProgressDiv=function(){var e=document.createElement(\"div\");e.setAttribute(\"class\",\"x3dom-progress\");var t=document.createElement(\"div\");t.setAttribute(\"class\",\"x3dom-progress-spinner\"),e.appendChild(t);var i=document.createElement(\"div\");return i.setAttribute(\"id\",\"x3domProgessCount\"),i.appendChild(document.createTextNode(\"Loading...\")),e.appendChild(i),e.oncontextmenu=e.onmousedown=function(e){return e.preventDefault(),e.stopPropagation(),!1},e},x3dom.X3DCanvas.prototype._createVRDiv=function(){var e=document.createElement(\"div\");return e.setAttribute(\"class\",\"x3dom-vr\"),e.onclick=e=>{this.x3dElem.runtime.toggleVR()},e.oncontextmenu=function(e){return e.preventDefault(),e.stopPropagation(),!1},e.title=\"Toggle VR\",e},x3dom.X3DCanvas.prototype.mousePosition=function(e){var t=e.target.getBoundingClientRect(),i=Math.round(e.clientX-t.left)*this.devicePixelRatio,o=Math.round(e.clientY-t.top)*this.devicePixelRatio;return new x3dom.fields.SFVec2f(i,o)},x3dom.X3DCanvas.prototype.tick=function(e,t){this._elapsedTime=this._totalTime?e-this._totalTime:0,this._totalTime=e;var i=this.x3dElem.runtime,o=(new Date).getTime(),s=o-this.lastTimeFPSWasTaken;this.fps_t0;this.fps_t0=o,this.doc.advanceTime(o/1e3);var r,n=(new Date).getTime()-o;if(this.doc.hasAnimationStateChanged()&&(this.doc.isAnimating()?i.onAnimationStarted():i.onAnimationFinished()),(this.doc.needRender||t)&&(s>=1e3&&(i.fps=this.framesSinceLastTime/(s/1e3),i.addMeasurement(\"FPS\",i.fps),this.framesSinceLastTime=0,this.lastTimeFPSWasTaken=o),this.framesSinceLastTime++,i.addMeasurement(\"ANIM\",n),0==i.isReady&&(i.ready(),i.isReady=!0),i.enterFrame({total:this._totalTime,elapsed:this._elapsedTime}),t||(this.doc.needRender=!1),this.doc.render(this.gl,this.getVRFrameData(t)),this.doc._scene._vf.doPickPass||i.removeMeasurement(\"PICKING\"),i.exitFrame({total:this._totalTime,elapsed:this._elapsedTime})),this.progressDiv)if(this.doc.downloadCount>0?i.addInfo(\"#LOADS:\",this.doc.downloadCount):i.removeInfo(\"#LOADS:\"),\"false\"!==this.doc.properties.getProperty(\"showProgress\")){if(this.progressDiv){var a=Math.max(+this.doc.downloadCount,0);this.progressDiv.childNodes[1].textContent=\"\"+a,this.doc.downloadCount>0?this.progressDiv.style.opacity=\"1\":this.progressDiv.style.opacity=\"0\"}}else this.progressDiv.style.opacity=\"0\";this.doc.downloadCount<=0&&this.doc.previousDownloadCount>0&&(document.createEvent?((r=document.createEvent(\"Events\")).initEvent(\"downloadsfinished\",!0,!0),this.x3dElem.dispatchEvent(r)):document.createEventObject&&(r=document.createEventObject(),this.x3dElem.fireEvent(\"ondownloadsfinished\",r)));this.doc.previousDownloadCount=this.doc.downloadCount},x3dom.X3DCanvas.prototype.mainloop=function(e,t){this.doc&&this.x3dElem.runtime&&(this._watchForResize(),this.tick(e,t),this.xrSession?this.xrSession.requestAnimationFrame(this.mainloop):window.requestAnimFrame(this.mainloop))},x3dom.X3DCanvas.prototype.load=function(e,t,i){this.doc=new x3dom.X3DDocument(this.canvas,this.gl,i),this.doc.onload=()=>{this.mainloop=this.mainloop.bind(this),this.checkForVRSupport(),this.hasRuntime?this.mainloop():this.tick()},this.x3dElem.render=()=>{this.hasRuntime?this.doc.needRender=!0:this.doc.render(x3dCanvas.gl)},this.x3dElem.context=this.gl.ctx3d,this.doc.onerror=function(){alert(\"Failed to load X3D document\")},this.doc.load(e,t)},x3dom.X3DCanvas.prototype.checkForVRSupport=function(){navigator.xr&&navigator.xr.isSessionSupported(\"immersive-vr\").then(e=>{e&&(this.vrDiv.style.display=\"block\")})},x3dom.X3DCanvas.prototype.enterVR=function(){this.xrSession||this.gl.ctx3d.makeXRCompatible().then(()=>{navigator.xr.requestSession(\"immersive-vr\").then(e=>{e.requestReferenceSpace(\"local\").then(t=>{const i=new XRWebGLLayer(e,this.gl.ctx3d);e.updateRenderState({baseLayer:i}),this._oldCanvasWidth=this.canvas.width,this._oldCanvasHeight=this.canvas.height,this.canvas.width=i.framebufferWidth,this.canvas.height=i.framebufferHeight,this.gl.VRMode=2,this.xrReferenceSpace=t,this.xrSession=e,this.doc.needRender=!0;var o=this.doc._viewarea.getViewMatrix(),s=new x3dom.fields.Quaternion(0,0,1,0);s.normalize(),s.setValue(o);var r=o.e3();const n=new XRRigidTransform({x:r.x,y:r.y,z:r.z},{x:s.x,y:s.y,z:s.z,w:s.w});this.xrReferenceSpace=this.xrReferenceSpace.getOffsetReferenceSpace(n),this.xrSession.addEventListener(\"end\",()=>{this.exitVR()}),e.requestAnimationFrame(this.mainloop)})})})},x3dom.X3DCanvas.prototype.exitVR=function(){this.xrSession&&(this.xrSession.end(),this.xrSession=void 0,this.xrReferenceSpace=void 0,this.canvas.width=this._oldCanvasWidth,this.canvas.height=this._oldCanvasHeight,this.gl.VRMode=1,this.doc.needRender=!0,window.requestAnimationFrame(this.mainloop))},x3dom.X3DCanvas.prototype.getVRFrameData=function(e){if(!e)return;const t=e.getViewerPose(this.xrReferenceSpace);if(!t)return;const i={framebuffer:e.session.renderState.baseLayer.framebuffer,controllers:{}};for(const e of t.views)\"left\"===e.eye?(i.leftViewMatrix=e.transform.inverse.matrix,i.leftProjectionMatrix=e.projectionMatrix):\"right\"===e.eye&&(i.rightViewMatrix=e.transform.inverse.matrix,i.rightProjectionMatrix=e.projectionMatrix);for(const t of e.session.inputSources)if(t.gripSpace){const o=e.getPose(t.gripSpace,this.xrReferenceSpace);null!==o&&null!==o.transform&&(i.controllers[t.handedness]={gamepad:t.gamepad,type:t.profiles[0],pose:{position:[o.transform.position.x,o.transform.position.y,o.transform.position.z],orientation:[o.transform.orientation.x,o.transform.orientation.y,o.transform.orientation.z,o.transform.orientation.w]}})}return i},x3dom.InputTypes={NAVIGATION:1,INTERACTION:2},x3dom.Viewarea=function(e,t){this._doc=e,this._scene=t,e._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=!0,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=!1,this._isMoving=!1,this._lastTS=0,this._mixer=new x3dom.MatrixMixer,this._interpolator=new x3dom.FieldInterpolator,this._animationStateChanged=!1,this.vrFrameData=null,this.gamepads=null,this.vrLeftViewMatrix=new x3dom.fields.SFMatrix4f,this.vrRightViewMatrix=new x3dom.fields.SFMatrix4f,this.vrLeftProjMatrix=new x3dom.fields.SFMatrix4f,this.vrRightProjMatrix=new x3dom.fields.SFMatrix4f,this.vrControllerManager=new x3dom.VRControllerManager(this._doc),this._inverseDevicePixelRatio=1/window.devicePixelRatio,this.arc=null},x3dom.Viewarea.prototype.setVRFrameData=function(e,t){this.vrFrameData=t,this.vrFrameData&&(this.vrLeftViewMatrix.setFromArray(this.vrFrameData.leftViewMatrix),this.vrRightViewMatrix.setFromArray(this.vrFrameData.rightViewMatrix),this.vrLeftProjMatrix.setFromArray(this.vrFrameData.leftProjectionMatrix),this.vrRightProjMatrix.setFromArray(this.vrFrameData.rightProjectionMatrix))},x3dom.Viewarea.prototype.updateGamepads=function(e){this.vrControllerManager.update(this,e)},x3dom.Viewarea.prototype.tick=function(e){if(this._scene.getEnvironment()._vf.enableARC&&null==this.arc&&(this.arc=new x3dom.arc.AdaptiveRenderControl(this._scene)),this._mixer.isActive()){if(this._mixer._isVPtarget){var t=this._scene.getViewpoint();t.resetView();var i=t.getViewMatrix().mult(t.getCurrentTransform().inverse());this._mixer.setEndMatrix(i)}var o=this._mixer.mix(e);this._scene.getViewpoint().setView(o)}if(this._interpolator.isActive()){var s=this._interpolator.interpolate(e);this._scene.getViewpoint().setZoom(s)}var r=this.navigateTo(e),n=this._isAnimating;return this._lastTS=e,this._isAnimating=this._mixer.isMixing||this._interpolator.isInterpolating||r,this._isAnimating!=n?this._animationStateChanged=!0:this._animationStateChanged=!1,null!=this.arc&&this.arc.update(this.isMovingOrAnimating()?1:0,this._doc._x3dElem.runtime.getFPS()),this._isAnimating||n},x3dom.Viewarea.prototype.isMoving=function(){return this._isMoving},x3dom.Viewarea.prototype.isAnimating=function(){return this._isAnimating},x3dom.Viewarea.prototype.hasAnimationStateChanged=function(){return this._animationStateChanged},x3dom.Viewarea.prototype.isMovingOrAnimating=function(){return this._isMoving||this._isAnimating},x3dom.Viewarea.prototype.navigateTo=function(e){return this._scene.getNavigationInfo()._impl.navigateTo(this,e)},x3dom.Viewarea.prototype.moveFwd=function(){this._scene.getNavigationInfo()._impl.moveForward(this)},x3dom.Viewarea.prototype.moveBwd=function(){this._scene.getNavigationInfo()._impl.moveBackwards(this)},x3dom.Viewarea.prototype.strafeRight=function(){this._scene.getNavigationInfo()._impl.strafeRight(this)},x3dom.Viewarea.prototype.strafeLeft=function(){this._scene.getNavigationInfo()._impl.strafeLeft(this)},x3dom.Viewarea.prototype.animateTo=function(e,t,i){this._scene.getNavigationInfo()._impl.animateTo(this,e,t,i)},x3dom.Viewarea.prototype.orthoAnimateTo=function(e,t,i){this._scene.getNavigationInfo()._impl.orthoAnimateTo(this,e,t,i)},x3dom.Viewarea.prototype.zoom=function(e){this._scene.getNavigationInfo()._impl.zoom(this,e)},x3dom.Viewarea.prototype.getLights=function(){for(var e=[],t=0;t0&&e[t]._vf.on)return!0;return!1},x3dom.Viewarea.prototype.hasPhysicalEnvironmentLight=function(){for(var e=0;e0){var o=this._scene.getVolume();if(o.isValid()){var s=x3dom.fields.SFVec3f.MAX(),r=x3dom.fields.SFVec3f.MIN();o.getBounds(s,r);var n=[],a=this._scene.getViewpoint().getFieldOfView(),d=r.subtract(s),l=d.y/2/Math.tan(a/2)+d.z/2,h=d.x/2/Math.tan(a/2)+d.z/2;for(d=s.add(d.multiply(.5)),t=0;th?l:h)))}n.push(f.getViewMatrix(d))}return n}}return Array(i||1).fill(this.getViewMatrix())},x3dom.Viewarea.prototype.getWCtoLCMatrix=function(e){var t,i=this.getProjectionMatrix();return t=0===arguments.length?this.getLightMatrix()[0]:e,i.mult(t)},x3dom.Viewarea.prototype.getWCtoLCMatricesPointLight=function(e,t,i){var o=t._vf.zNear,s=t._vf.zFar,r=this.getLightProjectionMatrix(e,o,s,!1,i);r._00=1,r._11=1;var n,a=[];a[0]=r.mult(e);for(var d=1;d<=3;d++)n=x3dom.fields.SFMatrix4f.rotationY(d*Math.PI/2),a[d]=r.mult(n.mult(e));return n=x3dom.fields.SFMatrix4f.rotationX(Math.PI/2),a[4]=r.mult(n.mult(e)),n=x3dom.fields.SFMatrix4f.rotationX(3*Math.PI/2),a[5]=r.mult(n.mult(e)),a},x3dom.Viewarea.prototype.getWCtoLCMatricesCascaded=function(e,t,i){var o=Math.max(1,Math.min(t._vf.shadowCascades,6)),s=Math.max(0,Math.min(t._vf.shadowSplitFactor,1)),r=Math.max(0,Math.min(t._vf.shadowSplitOffset,1)),n=x3dom.isa(t,x3dom.nodeTypes.SpotLight),a=t._vf.zNear,d=t._vf.zFar,l=this.getLightProjectionMatrix(e,a,d,!0,i);n&&(l._00=1,l._11=1);var h=l.mult(e),f=[];if(1==o)return f[0]=h,f;for(var u=this.getShadowSplitDepths(o,s,r,!0,i),c=0;c0||i>0){var n,a,d=e.inverse().e3(),l=x3dom.fields.SFVec3f.copy(this._scene._lastMin),h=x3dom.fields.SFVec3f.copy(this._scene._lastMax).subtract(l),f=h.length()/2,u=l.add(h.multiply(.5)),c=d.subtract(u).length();return f&&(n=c>f?.8*(c-f):1,a=1.2*(c+f)),t>0&&(n=t),i>0&&(a=i),r._22=-(a+n)/(a-n),r._23=-2*a*n/(a-n),r}return this.getLightCropMatrix(r.mult(e)).mult(r)},x3dom.Viewarea.prototype.getProjectionMatrix=function(){return this.vrFrameData?this.vrLeftProjMatrix:this._scene.getViewpoint().getProjectionMatrix(this._width/this._height)},x3dom.Viewarea.prototype.getProjectionMatrices=function(){if(this.vrFrameData)return[this.vrLeftProjMatrix,this.vrRightProjMatrix];var e=this._scene.getViewpoint().getProjectionMatrix(this._width/this._height);return[e,e]},x3dom.Viewarea.prototype.getViewfrustum=function(e){var t=this._scene.getEnvironment();if(1==t._vf.frustumCulling){if(0==arguments.length){var i=this.getProjectionMatrix(),o=this.getViewMatrix();return new x3dom.fields.FrustumVolume(i.mult(o))}return new x3dom.fields.FrustumVolume(e)}return null},x3dom.Viewarea.prototype.getWCtoCCMatrix=function(){var e=this.getViewMatrix();return this.getProjectionMatrix().mult(e)},x3dom.Viewarea.prototype.getCCtoWCMatrix=function(){return this.getWCtoCCMatrix().inverse()},x3dom.Viewarea.prototype.calcViewRay=function(e,t,i){var o=i||this.getCCtoWCMatrix(),s=e/(this._width-1)*2-1,r=(this._height-1-t)/(this._height-1)*2-1,n=o.multFullMatrixPnt(new x3dom.fields.SFVec3f(s,r,-1)),a=o.multFullMatrixPnt(new x3dom.fields.SFVec3f(s,r,1)).subtract(n);return new x3dom.fields.Ray(n,a)},x3dom.Viewarea.prototype.showAll=function(e,t){void 0===e&&(e=\"negZ\"),void 0===t&&(t=!1);var i=this._scene;i.updateVolume();var o,s=x3dom.fields.SFVec3f.copy(i._lastMin),r=x3dom.fields.SFVec3f.copy(i._lastMax),n=\"x\",a=\"y\",d=\"z\",l=1,h=new x3dom.fields.SFVec3f(0,0,-1);switch(e){case\"posX\":l=-1;case\"negX\":d=\"x\",n=\"y\",a=\"z\",o=new x3dom.fields.SFVec3f(l,0,0);break;case\"posY\":l=-1;case\"negY\":d=\"y\",n=\"z\",a=\"x\",o=new x3dom.fields.SFVec3f(0,l,0);break;case\"posZ\":l=-1;case\"negZ\":default:o=new x3dom.fields.SFVec3f(0,0,-l)}var f=i.getViewpoint(),u=f.getFieldOfView(),c=x3dom.isa(f,x3dom.nodeTypes.OrthoViewpoint),_=r.subtract(s),m=_.multiply(.5),p=s.add(m);t&&f.setCenterOfRotation(p);var x=Math.min(this._width/this._height,1),g=_[d]/2,v=Math.tan(u/2),y=_[a]/2/v+g,T=_[n]/2/v+g;(_=s.add(_.multiply(.5)))[d]+=c?l*(y>T?y:T)*3.01:l*(y>T?y:T)*1.01,_[d]/=x;var b=x3dom.fields.Quaternion.rotateFromTo(h,o).toMatrix();b=b.mult(x3dom.fields.SFMatrix4f.translation(_.negate())),c?(this.orthoAnimateTo(y,Math.abs(f._fieldOfView[0])),this.animateTo(b,f)):this.animateTo(b,f)},x3dom.Viewarea.prototype.fit=function(e,t,i){var o=this._scene.getViewpoint(),s=this.getFitViewMatrix(e,t,o,i);x3dom.isa(o,x3dom.nodeTypes.OrthoViewpoint)?(this.orthoAnimateTo(dist/2.01,Math.abs(o._fieldOfView[0])),this.animateTo(s,o)):this.animateTo(s,o)},x3dom.Viewarea.prototype.getFitViewMatrix=function(e,t,i,o){void 0===o&&(o=!0);var s=t.subtract(e).multiply(.5),r=e.add(s),n=s.length(),a=i.getFieldOfView(),d=x3dom.fields.SFMatrix4f.copy(this.getViewMatrix()),l=new x3dom.fields.SFVec3f(d._00,d._01,d._02),h=new x3dom.fields.SFVec3f(d._10,d._11,d._12),f=new x3dom.fields.SFVec3f(d._20,d._21,d._22),u=Math.min(this._width/this._height,1),c=n/Math.tan(a/2)/u,_=r.add(f.multiply(c));return d._03=-l.dot(_),d._13=-h.dot(_),d._23=-f.dot(_),o&&i.setCenterOfRotation(r),d},x3dom.Viewarea.prototype.resetView=function(){this._scene.getNavigationInfo()._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=!0},x3dom.Viewarea.prototype.uprightView=function(){var e=this.getViewMatrix().inverse(),t=e.e3(),i=t.subtract(e.e2()),o=new x3dom.fields.SFVec3f(0,1,0),s=e.e2().cross(o).normalize().cross(o).normalize();i=t.add(s),e=(e=x3dom.fields.SFMatrix4f.lookAt(t,i,o)).inverse(),this.animateTo(e,this._scene.getViewpoint())},x3dom.Viewarea.prototype.callEvtHandler=function(e,t,i){if(!e||!e._xmlNode)return null;try{var o=e._xmlNode,s=o[t];if(\"function\"==typeof s)s.call(o,i);else if(o.hasAttribute(t)){var r=o.getAttribute(t);new Function(\"event\",r).call(o,i)}var n=e._listeners[i.type];if(n)for(var a=0;a0&&void 0!==i)for(t=0;t=0)&&\"lookat\"===d&&this._pressX===e&&this._pressY===t){var g=2&this._lastButton?-1:1,v=this._pickingInfo.pickPos.subtract(this._from).length()/3,y=new x3dom.fields.SFMatrix4f;y.setValues(this.getViewMatrix());var T=(y=y.inverse()).e3(),b=(T.subtract(y.e2()),y.e1()),S=(r=this._pickingInfo.pickPos.subtract(T)).length();r=r.normalize();var F=T.addScaled(r,S),E=r.cross(b).normalize();r=E.cross(b).normalize(),g<0&&(v=2*(.5+S+v));var M=F.addScaled(r,v);y=(y=x3dom.fields.SFMatrix4f.lookAt(M,F,b)).inverse(),v=M.subtract(T).length();var C=Math.max(.5,Math.log((1+v)/a._vf.speed));this.animateTo(y,this._scene.getViewpoint(),C)}this._dx=0,this._dy=0,this._lastX=e,this._lastY=t,this._lastButton=i,this._isMoving=!1},x3dom.Viewarea.prototype.onMouseOver=function(e,t,i){this._dx=0,this._dy=0,this._lastButton=0,this._isMoving=!1,this._lastX=e,this._lastY=t,this._deltaT=0},x3dom.Viewarea.prototype.onMouseOut=function(e,t,i){var o;this._dx=0,this._dy=0,this._lastButton=0,this._isMoving=!1,this._lastX=e,this._lastY=t,this._deltaT=0;var s=this._doc._nodeBag.affectedPointingSensors;for(o=0;o0?this._currentInputType=x3dom.InputTypes.INTERACTION:this._currentInputType=x3dom.InputTypes.NAVIGATION},x3dom.Viewarea.prototype.getRenderMode=function(){return this._points},x3dom.Viewarea.prototype.getShadowedLights=function(){for(var e=[],t=0,i=this.getLights(),o=0;o0&&(e[t]=i[o],t++);return e},x3dom.Viewarea.prototype.getShadowSplitDepths=function(e,t,i,o,s){var r,n=[],a=this._scene.getViewpoint(),d=a.getNear(),l=a.getFar();n[0]=d,d+=i*(l-d)/10;for(var h=1;h1||r<-1?(i=-1,r=1):(i=Math.max(i,-1),r=Math.min(r,1)),o>1||n<-1?(o=-1,n=1):(o=Math.max(o,-1),n=Math.min(n,1)),s>1||a<-1?(s=-1,a=1):(s=Math.max(s,-1),a=Math.min(a,1));var d=new x3dom.fields.SFVec3f(i,o,s),l=new x3dom.fields.SFVec3f(r,n,a);return new x3dom.fields.BoxVolume(d,l)}(d,l),f=2/(h.max.x-h.min.x),u=2/(h.max.y-h.min.y),c=-f*(h.max.x+h.min.x)/2,_=-u*(h.max.y+h.min.y)/2,m=x3dom.fields.SFMatrix4f.identity();return m._00=f,m._11=u,m._03=c,m._13=_,m},x3dom.fields={};var VecMath=x3dom.fields;function _colorParse(e){var t=0,i=0,o=0,s=1,r={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\"},n=/^rgb\\((\\d{1,3}),\\s{0,1}(\\d{1,3}),\\s{0,1}(\\d{1,3})\\)$/.exec(e);null!==n&&(t=n[1]/255,i=n[2]/255,o=n[3]/255);var a=/^rgba\\((\\d{1,3}),\\s{0,1}(\\d{1,3}),\\s{0,1}(\\d{1,3}),(0+\\.?\\d*|1\\.?0*)\\)$/.exec(e);if(null!==a&&(t=a[1]/255,i=a[2]/255,o=a[3]/255,s=+a[4]),r[e]&&(e=r[e]),e.substr&&\"#\"===e.substr(0,1)){var d=e.substr(1),l=d.length;8===l?(t=parseInt(\"0x\"+d.substr(0,2),16)/255,i=parseInt(\"0x\"+d.substr(2,2),16)/255,o=parseInt(\"0x\"+d.substr(4,2),16)/255,s=parseInt(\"0x\"+d.substr(6,2),16)/255):6===l?(t=parseInt(\"0x\"+d.substr(0,2),16)/255,i=parseInt(\"0x\"+d.substr(2,2),16)/255,o=parseInt(\"0x\"+d.substr(4,2),16)/255):4===l?(t=parseInt(\"0x\"+d.substr(0,1),16)/15,i=parseInt(\"0x\"+d.substr(1,1),16)/15,o=parseInt(\"0x\"+d.substr(2,1),16)/15,s=parseInt(\"0x\"+d.substr(3,1),16)/15):3===l&&(t=parseInt(\"0x\"+d.substr(0,1),16)/15,i=parseInt(\"0x\"+d.substr(1,1),16)/15,o=parseInt(\"0x\"+d.substr(2,1),16)/15)}return{r:t,g:i,b:o,a:s}}function startDashVideo(e,t){var i,o,s,r=function(){var e={};window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi,(function(t,i,o){e[i]=o}));return e},n=e;r&&r.hasOwnProperty(\"url\")&&(n=r.url),i=document.querySelector(t),o=new Dash.di.DashContext,(s=new MediaPlayer(o)).startup(),s.attachView(i),s.setAutoPlay(!1),s.attachSource(n)}function setNamespace(e,t,i){t instanceof Element&&void 0!==t.__setAttribute&&(t.hasAttribute(\"id\")?t.__setAttribute(\"id\",e.toString().replace(\" \",\"\")+\"__\"+t.getAttribute(\"id\")):t.hasAttribute(\"DEF\")&&i&&(t.__setAttribute(\"id\",e.toString().replace(\" \",\"\")+\"__\"+t.getAttribute(\"DEF\")),t.id||(t.id=t.__getAttribute(\"id\")))),t.hasChildNodes()&&t.childNodes.forEach((function(t){setNamespace(e,t,i)}))}x3dom.fields.Eps=1e-6,x3dom.fields.SFMatrix4f=function(e,t,i,o,s,r,n,a,d,l,h,f,u,c,_,m){0===arguments.length?(this._00=1,this._01=0,this._02=0,this._03=0,this._10=0,this._11=1,this._12=0,this._13=0,this._20=0,this._21=0,this._22=1,this._23=0,this._30=0,this._31=0,this._32=0,this._33=1):(this._00=e,this._01=t,this._02=i,this._03=o,this._10=s,this._11=r,this._12=n,this._13=a,this._20=d,this._21=l,this._22=h,this._23=f,this._30=u,this._31=c,this._32=_,this._33=m)},x3dom.fields.SFMatrix4f.prototype.e0=function(){return new x3dom.fields.SFVec3f(this._00,this._10,this._20).normalize()},x3dom.fields.SFMatrix4f.prototype.e1=function(){return new x3dom.fields.SFVec3f(this._01,this._11,this._21).normalize()},x3dom.fields.SFMatrix4f.prototype.e2=function(){return new x3dom.fields.SFVec3f(this._02,this._12,this._22).normalize()},x3dom.fields.SFMatrix4f.prototype.e3=function(){return new x3dom.fields.SFVec3f(this._03,this._13,this._23)},x3dom.fields.SFMatrix4f.copy=function(e){return new x3dom.fields.SFMatrix4f(e._00,e._01,e._02,e._03,e._10,e._11,e._12,e._13,e._20,e._21,e._22,e._23,e._30,e._31,e._32,e._33)},x3dom.fields.SFMatrix4f.prototype.copy=function(){return x3dom.fields.SFMatrix4f.copy(this)},x3dom.fields.SFMatrix4f.identity=function(){return new x3dom.fields.SFMatrix4f(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)},x3dom.fields.SFMatrix4f.zeroMatrix=function(){return new x3dom.fields.SFMatrix4f(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)},x3dom.fields.SFMatrix4f.translation=function(e){return new x3dom.fields.SFMatrix4f(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1)},x3dom.fields.SFMatrix4f.rotationX=function(e){var t=Math.cos(e),i=Math.sin(e);return new x3dom.fields.SFMatrix4f(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1)},x3dom.fields.SFMatrix4f.rotationY=function(e){var t=Math.cos(e),i=Math.sin(e);return new x3dom.fields.SFMatrix4f(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1)},x3dom.fields.SFMatrix4f.rotationZ=function(e){var t=Math.cos(e),i=Math.sin(e);return new x3dom.fields.SFMatrix4f(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1)},x3dom.fields.SFMatrix4f.scale=function(e){return new x3dom.fields.SFMatrix4f(e.x,0,0,0,0,e.y,0,0,0,0,e.z,0,0,0,0,1)},x3dom.fields.SFMatrix4f.lookAt=function(e,t,i){var o=e.subtract(t).normalize(),s=i.normalize().cross(o).normalize();if(s.dot(s)=16?t?new x3dom.fields.SFMatrix4f(i[0],i[4],i[8],i[12],i[1],i[5],i[9],i[13],i[2],i[6],i[10],i[14],i[3],i[7],i[11],i[15]):new x3dom.fields.SFMatrix4f(i[0],i[1],i[2],i[3],i[4],i[5],i[6],i[7],i[8],i[9],i[10],i[11],i[12],i[13],i[14],i[15]):6===i.length?new x3dom.fields.SFMatrix4f(i[0],i[1],0,i[4],i[2],i[3],0,i[5],0,0,1,0,0,0,0,1):(x3dom.debug.logWarning(\"SFMatrix4f - can't parse string: \"+e),x3dom.fields.SFMatrix4f.identity())},x3dom.fields.SFMatrix4f.prototype.mult=function(e){return new x3dom.fields.SFMatrix4f(this._00*e._00+this._01*e._10+this._02*e._20+this._03*e._30,this._00*e._01+this._01*e._11+this._02*e._21+this._03*e._31,this._00*e._02+this._01*e._12+this._02*e._22+this._03*e._32,this._00*e._03+this._01*e._13+this._02*e._23+this._03*e._33,this._10*e._00+this._11*e._10+this._12*e._20+this._13*e._30,this._10*e._01+this._11*e._11+this._12*e._21+this._13*e._31,this._10*e._02+this._11*e._12+this._12*e._22+this._13*e._32,this._10*e._03+this._11*e._13+this._12*e._23+this._13*e._33,this._20*e._00+this._21*e._10+this._22*e._20+this._23*e._30,this._20*e._01+this._21*e._11+this._22*e._21+this._23*e._31,this._20*e._02+this._21*e._12+this._22*e._22+this._23*e._32,this._20*e._03+this._21*e._13+this._22*e._23+this._23*e._33,this._30*e._00+this._31*e._10+this._32*e._20+this._33*e._30,this._30*e._01+this._31*e._11+this._32*e._21+this._33*e._31,this._30*e._02+this._31*e._12+this._32*e._22+this._33*e._32,this._30*e._03+this._31*e._13+this._32*e._23+this._33*e._33)},x3dom.fields.SFMatrix4f.prototype.multMatrixPnt=function(e){return new x3dom.fields.SFVec3f(this._00*e.x+this._01*e.y+this._02*e.z+this._03,this._10*e.x+this._11*e.y+this._12*e.z+this._13,this._20*e.x+this._21*e.y+this._22*e.z+this._23)},x3dom.fields.SFMatrix4f.prototype.multMatrixVec=function(e){return new x3dom.fields.SFVec3f(this._00*e.x+this._01*e.y+this._02*e.z,this._10*e.x+this._11*e.y+this._12*e.z,this._20*e.x+this._21*e.y+this._22*e.z)},x3dom.fields.SFMatrix4f.prototype.multFullMatrixPnt=function(e){var t=this._30*e.x+this._31*e.y+this._32*e.z+this._33;return t&&(t=1/t),new x3dom.fields.SFVec3f((this._00*e.x+this._01*e.y+this._02*e.z+this._03)*t,(this._10*e.x+this._11*e.y+this._12*e.z+this._13)*t,(this._20*e.x+this._21*e.y+this._22*e.z+this._23)*t)},x3dom.fields.SFMatrix4f.prototype.multMatrixPlane=function(e){var t=new x3dom.fields.SFVec3f(e.x,e.y,e.z),i=t.multiply(-e.w);i=this.multMatrixPnt(i);var o=-(t=this.inverse().transpose().multMatrixVec(t)).dot(i);return new x3dom.fields.SFVec4f(t.x,t.y,t.z,o)},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(e){return new x3dom.fields.SFMatrix4f(e*this._00,e*this._01,e*this._02,e*this._03,e*this._10,e*this._11,e*this._12,e*this._13,e*this._20,e*this._21,e*this._22,e*this._23,e*this._30,e*this._31,e*this._32,e*this._33)},x3dom.fields.SFMatrix4f.prototype.add=function(e){return new x3dom.fields.SFMatrix4f(this._00+e._00,this._01+e._01,this._02+e._02,this._03+e._03,this._10+e._10,this._11+e._11,this._12+e._12,this._13+e._13,this._20+e._20,this._21+e._21,this._22+e._22,this._23+e._23,this._30+e._30,this._31+e._31,this._32+e._32,this._33+e._33)},x3dom.fields.SFMatrix4f.prototype.addScaled=function(e,t){return new x3dom.fields.SFMatrix4f(this._00+t*e._00,this._01+t*e._01,this._02+t*e._02,this._03+t*e._03,this._10+t*e._10,this._11+t*e._11,this._12+t*e._12,this._13+t*e._13,this._20+t*e._20,this._21+t*e._21,this._22+t*e._22,this._23+t*e._23,this._30+t*e._30,this._31+t*e._31,this._32+t*e._32,this._33+t*e._33)},x3dom.fields.SFMatrix4f.prototype.setValues=function(e){this._00=e._00,this._01=e._01,this._02=e._02,this._03=e._03,this._10=e._10,this._11=e._11,this._12=e._12,this._13=e._13,this._20=e._20,this._21=e._21,this._22=e._22,this._23=e._23,this._30=e._30,this._31=e._31,this._32=e._32,this._33=e._33},x3dom.fields.SFMatrix4f.prototype.setValue=function(e,t,i,o){this._00=e.x,this._01=t.x,this._02=i.x,this._10=e.y,this._11=t.y,this._12=i.y,this._20=e.z,this._21=t.z,this._22=i.z,this._30=0,this._31=0,this._32=0,arguments.length>3&&(this._03=o.x,this._13=o.y,this._23=o.z,this._33=1)},x3dom.fields.SFMatrix4f.prototype.setFromArray=function(e){return this._00=e[0],this._01=e[4],this._02=e[8],this._03=e[12],this._10=e[1],this._11=e[5],this._12=e[9],this._13=e[13],this._20=e[2],this._21=e[6],this._22=e[10],this._23=e[14],this._30=e[3],this._31=e[7],this._32=e[11],this._33=e[15],this},x3dom.fields.SFMatrix4f.fromArray=function(e){var t=new x3dom.fields.SFMatrix4f;return t._00=e[0],t._01=e[4],t._02=e[8],t._03=e[12],t._10=e[1],t._11=e[5],t._12=e[9],t._13=e[13],t._20=e[2],t._21=e[6],t._22=e[10],t._23=e[14],t._30=e[3],t._31=e[7],t._32=e[11],t._33=e[15],t},x3dom.fields.SFMatrix4f.prototype.fromRotationTranslationScale=function(e,t,i){t=t||new x3dom.fields.SFVec3f,e=e||new x3dom.fields.Quaternion,i=i||new x3dom.fields.SFVec3f(1,1,1);var o=e.x,s=e.y,r=e.z,n=e.w,a=o+o,d=s+s,l=r+r,h=o*a,f=o*d,u=o*l,c=s*d,_=s*l,m=r*l,p=n*a,x=n*d,g=n*l;return this._00=(1-(c+m))*i.x,this._10=(f+g)*i.x,this._20=(u-x)*i.x,this._30=0,this._01=(f-g)*i.y,this._11=(1-(h+m))*i.y,this._21=(_+p)*i.y,this._31=0,this._02=(u+x)*i.z,this._12=(_-p)*i.z,this._22=(1-(h+c))*i.z,this._32=0,this._03=t.x,this._13=t.y,this._23=t.z,this._33=1,this},x3dom.fields.SFMatrix4f.fromRotationTranslationScale=function(e,t,i){t=t||new x3dom.fields.SFVec3f,e=e||new x3dom.fields.Quaternion,i=i||new x3dom.fields.SFVec3f(1,1,1);var o=new x3dom.fields.SFMatrix4f,s=e.x,r=e.y,n=e.z,a=e.w,d=s+s,l=r+r,h=n+n,f=s*d,u=s*l,c=s*h,_=r*l,m=r*h,p=n*h,x=a*d,g=a*l,v=a*h;return o._00=(1-(_+p))*i.x,o._10=(u+v)*i.x,o._20=(c-g)*i.x,o._30=0,o._01=(u-v)*i.y,o._11=(1-(f+p))*i.y,o._21=(m+x)*i.y,o._31=0,o._02=(c+g)*i.z,o._12=(m-x)*i.z,o._22=(1-(f+_))*i.z,o._32=0,o._03=t.x,o._13=t.y,o._23=t.z,o._33=1,o},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.fromGL=function(e){var t=new x3dom.fields.SFMatrix4f;return t._00=e[0],t._01=e[4],t._02=e[8],t._03=e[12],t._10=e[1],t._11=e[5],t._12=e[9],t._13=e[13],t._20=e[2],t._21=e[6],t._22=e[10],t._23=e[14],t._30=e[3],t._31=e[7],t._32=e[11],t._33=e[15],t},x3dom.fields.SFMatrix4f.prototype.at=function(e,t){return this[\"_\"+e+t]},x3dom.fields.SFMatrix4f.prototype.setAt=function(e,t,i){return this[\"_\"+e+t]=i,this},x3dom.fields.SFMatrix4f.prototype.sqrt=function(){for(var e=x3dom.fields.SFMatrix4f.identity(),t=x3dom.fields.SFMatrix4f.copy(this),i=0;i<6;i++){var o=t.inverse(),s=0==i?x3dom.fields.SFMatrix4f.identity():e.inverse(),r=t.det(),n=e.det(),a=Math.abs(Math.pow(r*n,-.125)),d=1/a;t=(t=(t=t.multiply(a)).addScaled(s,d)).multiply(.5),e=(e=(e=e.multiply(a)).addScaled(o,d)).multiply(.5)}return t},x3dom.fields.SFMatrix4f.prototype.normInfinity=function(){var e=0,t=0;return(e=Math.abs(this._00))>t&&(t=e),(e=Math.abs(this._01))>t&&(t=e),(e=Math.abs(this._02))>t&&(t=e),(e=Math.abs(this._03))>t&&(t=e),(e=Math.abs(this._10))>t&&(t=e),(e=Math.abs(this._11))>t&&(t=e),(e=Math.abs(this._12))>t&&(t=e),(e=Math.abs(this._13))>t&&(t=e),(e=Math.abs(this._20))>t&&(t=e),(e=Math.abs(this._21))>t&&(t=e),(e=Math.abs(this._22))>t&&(t=e),(e=Math.abs(this._23))>t&&(t=e),(e=Math.abs(this._30))>t&&(t=e),(e=Math.abs(this._31))>t&&(t=e),(e=Math.abs(this._32))>t&&(t=e),(e=Math.abs(this._33))>t&&(t=e),t},x3dom.fields.SFMatrix4f.prototype.norm1_3x3=function(){var e=Math.abs(this._00)+Math.abs(this._10)+Math.abs(this._20),t=0;return(t=Math.abs(this._01)+Math.abs(this._11)+Math.abs(this._21))>e&&(e=t),(t=Math.abs(this._02)+Math.abs(this._12)+Math.abs(this._22))>e&&(e=t),e},x3dom.fields.SFMatrix4f.prototype.normInf_3x3=function(){var e=Math.abs(this._00)+Math.abs(this._01)+Math.abs(this._02),t=0;return(t=Math.abs(this._10)+Math.abs(this._11)+Math.abs(this._12))>e&&(e=t),(t=Math.abs(this._20)+Math.abs(this._21)+Math.abs(this._22))>e&&(e=t),e},x3dom.fields.SFMatrix4f.prototype.adjointT_3x3=function(){var e=x3dom.fields.SFMatrix4f.identity();return e._00=this._11*this._22-this._12*this._21,e._01=this._12*this._20-this._10*this._22,e._02=this._10*this._21-this._11*this._20,e._10=this._21*this._02-this._22*this._01,e._11=this._22*this._00-this._20*this._02,e._12=this._20*this._01-this._21*this._00,e._20=this._01*this._12-this._02*this._11,e._21=this._02*this._10-this._00*this._12,e._22=this._00*this._11-this._01*this._10,e},x3dom.fields.SFMatrix4f.prototype.equals=function(e){var t=1e-12;return Math.abs(this._00-e._00)4){r=(r=x3dom.fields.SFMatrix4f.translation(s.negate())).mult(this);var n=x3dom.fields.SFMatrix4f.translation(s);r=r.mult(n)}else r=x3dom.fields.SFMatrix4f.copy(this);var a=r.decompose(e,t,i,o);i.setValues(i.multiply(a))},x3dom.fields.SFMatrix4f.prototype.decompose=function(e,t,i,o){var s=x3dom.fields.SFMatrix4f.copy(this),r=x3dom.fields.SFMatrix4f.identity(),n=x3dom.fields.SFMatrix4f.identity(),a=x3dom.fields.SFMatrix4f.identity();e.x=s._03,e.y=s._13,e.z=s._23,s._03=0,s._13=0,s._23=0,s._30=0,s._31=0,s._32=0;var d=1;return s.polarDecompose(r,n)<0&&(r=r.negate(),d=-1),t.setValue(r),n.spectralDecompose(a,i),o.setValue(a),d},x3dom.fields.SFMatrix4f.prototype.polarDecompose=function(e,t){var i,o,s,r,n,a=this.transpose(),d=x3dom.fields.SFMatrix4f.identity(),l=a.norm1_3x3(),h=a.normInf_3x3();do{if(i=a.adjointT_3x3(),0==(n=a._00*i._00+a._01*i._01+a._02*i._02)){x3dom.debug.logWarning(\"polarDecompose: Mk_det == 0.0\");break}o=i.norm1_3x3(),s=i.normInf_3x3();var f=Math.sqrt(Math.sqrt(o*s/(l*h))/Math.abs(n)),u=.5*f,c=.5/(f*n);d.setValues(a),a=(a=a.multiply(u)).addScaled(i,c),r=(d=d.addScaled(a,-1)).norm1_3x3(),l=a.norm1_3x3(),h=a.normInf_3x3()}while(r>1e-12*l);e.setValues(a.transpose()),t.setValues(a.mult(this));for(var _=0;_<3;++_)for(var m=_;m<3;++m)t.setAt(m,_,.5*(t.at(m,_)+t.at(_,m))),t.setAt(_,m,.5*(t.at(m,_)+t.at(_,m)));return n},x3dom.fields.SFMatrix4f.prototype.spectralDecompose=function(e,t){for(var i=[1,2,0],o=[this._00,this._11,this._22],s=[this._12,this._20,this._01],r=0;r<20;++r){if(0==Math.abs(s[0])+Math.abs(s[1])+Math.abs(s[2]))break;for(var n=2;n>=0;--n){var a=i[n],d=i[a],l=Math.abs(s[n]),h=100*l;if(l>0){var f=0,u=o[d]-o[a],c=Math.abs(u);if(c+h==c)f=s[n]/u;else{var _=.5*u/s[n];f=1/(Math.abs(_)+Math.sqrt(_*_+1)),f=_<0?-f:f}var m=1/Math.sqrt(f*f+1),p=f*m,x=p/(m+1),g=f*s[n];s[n]=0,o[a]-=g,o[d]+=g;var v=s[d];s[d]-=p*(s[a]+x*v),s[a]+=p*(v-x*s[a]);for(var y=2;y>=0;--y){var T=e.at(y,a),b=e.at(y,d);e.setAt(y,a,e.at(y,a)-p*(b+x*T)),e.setAt(y,d,e.at(y,d)+p*(T-x*b))}}}}t.x=o[0],t.y=o[1],t.z=o[2]},x3dom.fields.SFMatrix4f.prototype.log=function(){var e=x3dom.fields.SFMatrix4f.copy(this),t=x3dom.fields.SFMatrix4f.copy(this);t._00-=1,t._11-=1,t._22-=1,t._33-=1;for(var i=0;t.normInfinity()>.5;)e=e.sqrt(),t.setValues(e),t._00-=1,t._11-=1,t._22-=1,t._33-=1,i++;e._00-=1,e._11-=1,e._22-=1,e._33-=1,e=e.negate(),t.setValues(e);for(var o=x3dom.fields.SFMatrix4f.copy(e),s=1;t.normInfinity()>1e-12&&s<12;)t=t.mult(e),s++,o=o.addScaled(t,1/s);return o.multiply(-(1<1e-4?(e=-Math.asin(this._20),t=Math.PI-e,n=Math.cos(e),a=Math.cos(t),o=Math.atan2(this._21/n,this._22/n),s=Math.atan2(this._21/a,this._22/a),[o,e,Math.atan2(this._10/n,this._00/n),s,t,Math.atan2(this._10/a,this._00/a)]):(0,-1==this._20?(i=Math.PI/2,r=0+Math.atan2(this._01,this._02)):(i=-Math.PI/2,r=-0+Math.atan2(-this._01,-this._02)),[r,i,0,r,i,0])},x3dom.fields.SFMatrix4f.prototype.toString=function(){return this._00.toFixed(6)+\" \"+this._10.toFixed(6)+\" \"+this._20.toFixed(6)+\" \"+this._30.toFixed(6)+\" \"+this._01.toFixed(6)+\" \"+this._11.toFixed(6)+\" \"+this._21.toFixed(6)+\" \"+this._31.toFixed(6)+\" \"+this._02.toFixed(6)+\" \"+this._12.toFixed(6)+\" \"+this._22.toFixed(6)+\" \"+this._32.toFixed(6)+\" \"+this._03.toFixed(6)+\" \"+this._13.toFixed(6)+\" \"+this._23.toFixed(6)+\" \"+this._33.toFixed(6)},x3dom.fields.SFMatrix4f.prototype.setValueByStr=function(e){var t=!1;/matrix.*\\((.+)\\)/.exec(e)&&(e=RegExp.$1,t=!0);var i=e.split(/[,\\s]+/).map((function(e){return+e}));return i.length>=16?t?(this._00=i[0],this._01=i[4],this._02=i[8],this._03=i[12],this._10=i[1],this._11=i[5],this._12=i[9],this._13=i[13],this._20=i[2],this._21=i[6],this._22=i[10],this._23=i[14],this._30=i[3],this._31=i[7],this._32=i[11],this._33=i[15]):(this._00=i[0],this._01=i[1],this._02=i[2],this._03=i[3],this._10=i[4],this._11=i[5],this._12=i[6],this._13=i[7],this._20=i[8],this._21=i[9],this._22=i[10],this._23=i[11],this._30=i[12],this._31=i[13],this._32=i[14],this._33=i[15]):6===i.length?(this._00=i[0],this._01=i[1],this._02=0,this._03=i[4],this._10=i[2],this._11=i[3],this._12=0,this._13=i[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):x3dom.debug.logWarning(\"SFMatrix4f - can't parse string: \"+e),this},x3dom.fields.SFVec2f=function(e,t){0===arguments.length?(this.x=0,this.y=0):(this.x=e,this.y=t)},x3dom.fields.SFVec2f.copy=function(e){return new x3dom.fields.SFVec2f(e.x,e.y)},x3dom.fields.SFVec2f.parse=function(e){var t=/^\\s*([+\\-]?\\d*\\.*\\d*[eE]?[+\\-]?\\d*?)\\s*,?\\s*([+\\-]?\\d*\\.*\\d*[eE]?[+\\-]?\\d*?)\\s*$/.exec(e);return null===t?new x3dom.fields.SFVec2f:new x3dom.fields.SFVec2f(+t[1],+t[2])},x3dom.fields.SFVec2f.prototype.copy=function(){return x3dom.fields.SFVec2f.copy(this)},x3dom.fields.SFVec2f.prototype.setValues=function(e){return this.x=e.x,this.y=e.y,this},x3dom.fields.SFVec2f.prototype.at=function(e){switch(e){case 0:return this.x;case 1:return this.y;default:return this.x}},x3dom.fields.SFVec2f.prototype.add=function(e){return new x3dom.fields.SFVec2f(this.x+e.x,this.y+e.y)},x3dom.fields.SFVec2f.prototype.subtract=function(e){return new x3dom.fields.SFVec2f(this.x-e.x,this.y-e.y)},x3dom.fields.SFVec2f.prototype.negate=function(){return new x3dom.fields.SFVec2f(-this.x,-this.y)},x3dom.fields.SFVec2f.prototype.dot=function(e){return this.x*e.x+this.y*e.y},x3dom.fields.SFVec2f.prototype.reflect=function(e){var t=2*this.dot(e);return new x3dom.fields.SFVec2f(this.x-t*e.x,this.y-t*e.y)},x3dom.fields.SFVec2f.prototype.normalize=function(){var e=this.length();return e&&(e=1/e),new x3dom.fields.SFVec2f(this.x*e,this.y*e)},x3dom.fields.SFVec2f.prototype.multComponents=function(e){return new x3dom.fields.SFVec2f(this.x*e.x,this.y*e.y)},x3dom.fields.SFVec2f.prototype.multiply=function(e){return new x3dom.fields.SFVec2f(this.x*e,this.y*e)},x3dom.fields.SFVec2f.prototype.divideComponents=function(e){return new x3dom.fields.SFVec2f(this.x/e.x,this.y/e.y)},x3dom.fields.SFVec2f.prototype.divide=function(e){var t=e?1/e:1;return new x3dom.fields.SFVec2f(this.x*t,this.y*t)},x3dom.fields.SFVec2f.prototype.equals=function(e,t){return Math.abs(this.x-e.x)x3dom.fields.Eps){var o=Math.sin(t/2)/i,s=Math.cos(t/2);return new x3dom.fields.Quaternion(e.x*o,e.y*o,e.z*o,s)}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 e=this.x*this.x,t=this.x*this.y,i=this.x*this.z,o=this.y*this.y,s=this.y*this.z,r=this.z*this.z,n=this.w*this.x,a=this.w*this.y,d=this.w*this.z;return new x3dom.fields.SFMatrix4f(1-2*(o+r),2*(t-d),2*(i+a),0,2*(t+d),1-2*(e+r),2*(s-n),0,2*(i-a),2*(s+n),1-2*(e+o),0,0,0,0,1)},x3dom.fields.Quaternion.prototype.toAxisAngle=function(){var e,t,i=0,o=0,s=0;return this.w>1&&this.normalize(),t=2*Math.acos(this.w),0==(e=Math.sqrt(1-this.w*this.w))?(i=this.x,o=this.y,s=this.z):(i=this.x/e,o=this.y/e,s=this.z/e),[new x3dom.fields.SFVec3f(i,o,s),t]},x3dom.fields.Quaternion.prototype.angle=function(){return 2*Math.acos(this.w)},x3dom.fields.Quaternion.prototype.setValue=function(e){var t,i=1,o=[0,0,0],s=0,r=0,n=0,a=[1,2,0];if((t=e._00+e._11+e._22)>0?(i=Math.sqrt(t+1),this.w=.5*i,i=.5/i,this.x=(e._21-e._12)*i,this.y=(e._02-e._20)*i,this.z=(e._10-e._01)*i):(s=e._11>e._00?1:0,e._22>e.at(s,s)&&(s=2),n=a[r=a[s]],i=Math.sqrt(e.at(s,s)-(e.at(r,r)+e.at(n,n))+1),o[s]=.5*i,i=.5/i,this.w=(e.at(n,r)-e.at(r,n))*i,o[r]=(e.at(r,s)+e.at(s,r))*i,o[n]=(e.at(n,s)+e.at(s,n))*i,this.x=o[0],this.y=o[1],this.z=o[2]),this.w>1||this.w<-1){var d=1+100*x3dom.fields.Eps;(this.w>d||this.w<-d)&&x3dom.debug.logInfo(\"MatToQuat: BUG: |quat[4]| (\"+this.w+\") >> 1.0 !\"),this.w>1?this.w=1:this.w=-1}},x3dom.fields.Quaternion.prototype.setFromEuler=function(e,t,i){var o=Math.sin(.5*e),s=Math.cos(.5*e),r=Math.sin(.5*t),n=Math.cos(.5*t),a=Math.sin(.5*i),d=Math.cos(.5*i);return this.x=o*n*d-s*r*a,this.y=s*r*d+o*n*a,this.z=s*n*a-o*r*d,this.w=s*n*d+o*r*a,this},x3dom.fields.Quaternion.prototype.dot=function(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w},x3dom.fields.Quaternion.prototype.add=function(e){return new x3dom.fields.Quaternion(this.x+e.x,this.y+e.y,this.z+e.z,this.w+e.w)},x3dom.fields.Quaternion.prototype.subtract=function(e){return new x3dom.fields.Quaternion(this.x-e.x,this.y-e.y,this.z-e.z,this.w-e.w)},x3dom.fields.Quaternion.prototype.setValues=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this},x3dom.fields.Quaternion.prototype.equals=function(e,t){return this.dot(e)>=1-t},x3dom.fields.Quaternion.prototype.multScalar=function(e){return new x3dom.fields.Quaternion(this.x*e,this.y*e,this.z*e,this.w*e)},x3dom.fields.Quaternion.prototype.normalize=function(){var e=this.dot(this),t=1;return e&&(t=1/Math.sqrt(e)),this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},x3dom.fields.Quaternion.normalize=function(e){var t=e.dot(e),i=1;return t&&(i=1/Math.sqrt(t)),e.x*=i,e.y*=i,e.z*=i,e.w*=i,e},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(){var e=new x3dom.fields.Quaternion(-this.x,-this.y,-this.z,this.w);if(\"SFRotation\"in this){var t=e.toAxisAngle();return new x3dom.fields.SFRotation(t[0].x,t[0].y,t[0].z,t[1])}return e},x3dom.fields.Quaternion.prototype.slerp=function(e,t){var i,o,s,r=this.dot(e);if(r<0?(r=-r,i=e.negate()):i=new x3dom.fields.Quaternion(e.x,e.y,e.z,e.w),1-r>1e-5){var n=Math.acos(r),a=Math.sin(n);o=Math.sin((1-t)*n)/a,s=Math.sin(t*n)/a}else o=1-t,s=t;var d=this.multScalar(o).add(i.multScalar(s));if(\"SFRotation\"in this){var l=d.toAxisAngle();return new x3dom.fields.SFRotation(l[0].x,l[0].y,l[0].z,l[1])}return d},x3dom.fields.Quaternion.rotateFromTo=function(e,t){var i=e.normalize(),o=t.normalize(),s=i.dot(o);if(s>.99999)return new x3dom.fields.Quaternion(0,0,0,1);if(s<-.99999){var r=new x3dom.fields.SFVec3f(1,0,0),n=i.cross(r);return n.length()<1e-5&&(r.x=0,r.y=1,r.z=0,n=i.cross(r)),n=n.normalize(),x3dom.fields.Quaternion.axisAngle(n,Math.PI)}var a=e.cross(t);a=a.normalize();var d=Math.sqrt(.5*(1-s));return a=a.multiply(d),d=Math.sqrt(.5*(1+s)),new x3dom.fields.Quaternion(a.x,a.y,a.z,d)},x3dom.fields.Quaternion.prototype.toGL=function(){var e=this.toAxisAngle();return[e[0].x,e[0].y,e[0].z,e[1]]},x3dom.fields.Quaternion.prototype.toString=function(){return\"SFRotation\"in this?this.SFRotation.x+\" \"+this.SFRotation.y+\" \"+this.SFRotation.z+\" \"+this.SFRotation.angle:this.x+\" \"+this.y+\" \"+this.z+\", \"+this.w},x3dom.fields.Quaternion.prototype.setValueByStr=function(e){var t=/^\\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(e);t=t||[0,1,0,0,0];var i=x3dom.fields.Quaternion.axisAngle(new x3dom.fields.SFVec3f(+t[1],+t[2],+t[3]),+t[4]);return this.x=i.x,this.y=i.y,this.z=i.z,this.w=i.w,this},x3dom.fields.SFColor=function(e,t,i){0===arguments.length?(this.r=0,this.g=0,this.b=0):(this.r=e,this.g=t,this.b=i)},x3dom.fields.SFColor.parse=function(e){try{var t=/^\\s*([+\\-]?\\d*\\.*\\d*[eE]?[+\\-]?\\d*?)\\s*,?\\s*([+\\-]?\\d*\\.*\\d*[eE]?[+\\-]?\\d*?)\\s*,?\\s*([+\\-]?\\d*\\.*\\d*[eE]?[+\\-]?\\d*?)\\s*$/.exec(e);return new x3dom.fields.SFColor(+t[1],+t[2],+t[3])}catch(t){return x3dom.fields.SFColor.colorParse(e)}},x3dom.fields.SFColor.copy=function(e){return new x3dom.fields.SFColor(e.r,e.g,e.b)},x3dom.fields.SFColor.prototype.copy=function(){return x3dom.fields.SFColor.copy(this)},x3dom.fields.SFColor.prototype.setHSV=function(e,t,i){var o,s,r,n,a,d=0,l=0,h=0;switch(r=i*(1-t),n=i*(1-t*(s=e/60-(o=Math.floor(e/60)))),a=i*(1-t*(1-s)),o){case 0:case 6:d=i,l=a,h=r;break;case 1:d=n,l=i,h=r;break;case 2:d=r,l=i,h=a;break;case 3:d=r,l=n,h=i;break;case 4:d=a,l=r,h=i;break;case 5:d=i,l=r,h=n;break;default:x3dom.debug.logWarning(\"Using black for invalid case in setHSV: \"+o)}return this.r=d,this.g=l,this.b=h,this},x3dom.fields.SFColor.prototype.getHSV=function(){var e,t=0,i={},o=this.r;if(i.name=\"red\",i.value=this.r,this.gi.value&&(i.name=\"green\",i.value=this.g),this.b>i.value&&(i.name=\"blue\",i.value=this.b),0==(e=i.value-o))t=0;else if(\"red\"==i.name)t=(this.g-this.b)/e%6*60;else if(\"green\"==i.name)t=60*((this.b-this.r)/e+2);else{if(\"blue\"!=i.name)throw\"Unknown maximum component: \"+i.name;t=60*((this.r-this.g)/e+4)}return t<0&&(t+=360),[t,0==i.value?0:e/i.value,i.value]},x3dom.fields.SFColor.prototype.setValues=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},x3dom.fields.SFColor.prototype.equals=function(e,t){return Math.abs(this.r-e.r)>>0},x3dom.fields.SFColor.prototype.setFromUint=function(e){return this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e>>0&255)/255,this},x3dom.fields.SFColor.prototype.toGL=function(){return[this.r,this.g,this.b]},x3dom.fields.SFColor.prototype.toString=function(){return this.r+\" \"+this.g+\" \"+this.b},x3dom.fields.SFColor.prototype.setValueByStr=function(e){try{var t=/^\\s*([+\\-]?\\d*\\.*\\d*[eE]?[+\\-]?\\d*?)\\s*,?\\s*([+\\-]?\\d*\\.*\\d*[eE]?[+\\-]?\\d*?)\\s*,?\\s*([+\\-]?\\d*\\.*\\d*[eE]?[+\\-]?\\d*?)\\s*$/.exec(e);this.r=+t[1],this.g=+t[2],this.b=+t[3]}catch(t){var i=x3dom.fields.SFColor.colorParse(e);this.r=i.r,this.g=i.g,this.b=i.b}return this},x3dom.fields.SFColor.colorParse=function(e){var t=_colorParse(e);return new x3dom.fields.SFColor(t.r,t.g,t.b)},x3dom.fields.SFColorRGBA=function(e,t,i,o){0===arguments.length?(this.r=0,this.g=0,this.b=0,this.a=1):(this.r=e,this.g=t,this.b=i,this.a=o)},x3dom.fields.SFColorRGBA.parse=function(e){try{var t=/^([+\\-]?\\d*\\.*\\d*[eE]?[+\\-]?\\d*?)\\s*,?\\s*([+\\-]?\\d*\\.*\\d*[eE]?[+\\-]?\\d*?)\\s*,?\\s*([+\\-]?\\d*\\.*\\d*[eE]?[+\\-]?\\d*?)\\s*,?\\s*([+\\-]?\\d*\\.*\\d*[eE]?[+\\-]?\\d*?)$/.exec(e);return new x3dom.fields.SFColorRGBA(+t[1],+t[2],+t[3],+t[4])}catch(t){return x3dom.fields.SFColorRGBA.colorParse(e)}},x3dom.fields.SFColorRGBA.copy=function(e){return new x3dom.fields.SFColorRGBA(e.r,e.g,e.b,e.a)},x3dom.fields.SFColorRGBA.prototype.copy=function(){return x3dom.fields.SFColorRGBA.copy(this)},x3dom.fields.SFColorRGBA.prototype.setHSV=x3dom.fields.SFColor.prototype.setHSV,x3dom.fields.SFColorRGBA.prototype.getHSV=x3dom.fields.SFColor.prototype.getHSV,x3dom.fields.SFColorRGBA.prototype.setValues=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this.a=e.a,this},x3dom.fields.SFColorRGBA.prototype.equals=function(e,t){return Math.abs(this.r-e.r)>>0},x3dom.fields.SFColorRGBA.prototype.setFromUint=function(e){return this.r=(e>>24&255)/255,this.g=(e>>16&255)/255,this.b=(e>>8&255)/255,this.a=(e>>0&255)/255,this},x3dom.fields.SFColorRGBA.colorParse=function(e){var t=_colorParse(e);return new x3dom.fields.SFColorRGBA(t.r,t.g,t.b,t.a)},x3dom.fields.SFImage=function(e,t,i,o){if(0!==arguments.length&&o&&o.map){this.width=e,this.height=t,this.comp=i;var s=this.array;o.map((function(e){s.push(e)}),this.array)}else this.width=0,this.height=0,this.comp=0,this.array=[]},x3dom.fields.SFImage.parse=function(e){var t=new x3dom.fields.SFImage;return t.setValueByStr(e),t},x3dom.fields.SFImage.copy=function(e){var t=new x3dom.fields.SFImage;return t.width=e.width,t.height=e.height,t.comp=e.comp,t.setPixels(e.getPixels()),t},x3dom.fields.SFImage.prototype.copy=function(){return x3dom.fields.SFImage.copy(this)},x3dom.fields.SFImage.prototype.setValueByStr=function(e){var t,i,o,s,r,n=e.match(/(\\w+)/g),a=n.length;if(this.array=[],!(a>2))return this.width=0,this.height=0,void(this.comp=0);this.width=+n[0],this.height=+n[1],this.comp=+n[2];var d=10;for(t=3;t>8&255,o=255&l,this.array.push(i,o)):3===this.comp?(i=l>>16&255,o=l>>8&255,s=255&l,this.array.push(i,o,s)):4===this.comp&&(i=l>>24&255,o=l>>16&255,s=l>>8&255,r=255&l,this.array.push(i,o,s,r))}},x3dom.fields.SFImage.prototype.setPixel=function(e,t,i){var o=(t*this.width+e)*this.comp;return 1===this.comp&&o0;for(var t=0,i=this.nodes.length;tx3dom.fields.Eps)i=1/this.dir.x,o=(e.x-this.pos.x)*i,(s=(t.x-this.pos.x)*i)r&&(r=o);else if(this.dir.x<-x3dom.fields.Eps)i=1/this.dir.x,o=(t.x-this.pos.x)*i,(s=(e.x-this.pos.x)*i)r&&(r=o);else if(this.pos.xt.x)return!1;if(this.dir.y>x3dom.fields.Eps){if(i=1/this.dir.y,o=(e.y-this.pos.y)*i,(s=(t.y-this.pos.y)*i)r&&(r=o),r-n>=x3dom.fields.Eps)return!1}else if(this.dir.y<-x3dom.fields.Eps){if(i=1/this.dir.y,o=(t.y-this.pos.y)*i,(s=(e.y-this.pos.y)*i)r&&(r=o),r-n>=x3dom.fields.Eps)return!1}else if(this.pos.yt.y)return!1;if(this.dir.z>x3dom.fields.Eps)i=1/this.dir.z,o=(e.z-this.pos.z)*i,(s=(t.z-this.pos.z)*i)r&&(r=o);else if(this.dir.z<-x3dom.fields.Eps)i=1/this.dir.z,o=(t.z-this.pos.z)*i,(s=(e.z-this.pos.z)*i)r&&(r=o);else if(this.pos.zt.z)return!1;return this.enter=r,this.exit=n,r-ne.x&&(this.min.x=e.x),this.min.y>e.y&&(this.min.y=e.y),this.min.z>e.z&&(this.min.z=e.z),this.max.x=d?(s+=a,t+=d):(s+=d,t+=a),(a=this.max.y*e._01)>=(d=this.min.y*e._01)?(s+=a,t+=d):(s+=d,t+=a),(a=this.max.z*e._02)>=(d=this.min.z*e._02)?(s+=a,t+=d):(s+=d,t+=a),(a=this.max.x*e._10)>=(d=this.min.x*e._10)?(r+=a,i+=d):(r+=d,i+=a),(a=this.max.y*e._11)>=(d=this.min.y*e._11)?(r+=a,i+=d):(r+=d,i+=a),(a=this.max.z*e._12)>=(d=this.min.z*e._12)?(r+=a,i+=d):(r+=d,i+=a),(a=this.max.x*e._20)>=(d=this.min.x*e._20)?(n+=a,o+=d):(n+=d,o+=a),(a=this.max.y*e._21)>=(d=this.min.y*e._21)?(n+=a,o+=d):(n+=d,o+=a),(a=this.max.z*e._22)>=(d=this.min.z*e._22)?(n+=a,o+=d):(n+=d,o+=a),this.min.x=t,this.min.y=i,this.min.z=o,this.max.x=s,this.max.y=r,this.max.z=n,this.updateInternals()},x3dom.fields.BoxVolume.prototype.transformFrom=function(e,t){var i,o,s,r,n,a;i=r=e._03,o=n=e._13,s=a=e._23;var d=t.max.x*e._00,l=t.min.x*e._00;d>=l?(r+=d,i+=l):(r+=l,i+=d),(d=t.max.y*e._01)>=(l=t.min.y*e._01)?(r+=d,i+=l):(r+=l,i+=d),(d=t.max.z*e._02)>=(l=t.min.z*e._02)?(r+=d,i+=l):(r+=l,i+=d),(d=t.max.x*e._10)>=(l=t.min.x*e._10)?(n+=d,o+=l):(n+=l,o+=d),(d=t.max.y*e._11)>=(l=t.min.y*e._11)?(n+=d,o+=l):(n+=l,o+=d),(d=t.max.z*e._12)>=(l=t.min.z*e._12)?(n+=d,o+=l):(n+=l,o+=d),(d=t.max.x*e._20)>=(l=t.min.x*e._20)?(a+=d,s+=l):(a+=l,s+=d),(d=t.max.y*e._21)>=(l=t.min.y*e._21)?(a+=d,s+=l):(a+=l,s+=d),(d=t.max.z*e._22)>=(l=t.min.z*e._22)?(a+=d,s+=l):(a+=l,s+=d),this.min.x=i,this.min.y=o,this.min.z=s,this.max.x=r,this.max.y=n,this.max.z=a,this.updateInternals(),this.valid=!0},x3dom.fields.FrustumVolume=function(e){if(this.planeNormals=[],this.planeDistances=[],this.directionIndex=[],0!==arguments.length){for(var t=[],i=0;i<6;i++)this.planeNormals[i]=new x3dom.fields.SFVec3f(0,0,0),this.planeDistances[i]=0,this.directionIndex[i]=0,t[i]=new x3dom.fields.SFVec4f(0,0,0,0);for(t[0].x=e._30-e._00,t[0].y=e._31-e._01,t[0].z=e._32-e._02,t[0].w=e._33-e._03,t[1].x=e._30+e._00,t[1].y=e._31+e._01,t[1].z=e._32+e._02,t[1].w=e._33+e._03,t[2].x=e._30+e._10,t[2].y=e._31+e._11,t[2].z=e._32+e._12,t[2].w=e._33+e._13,t[3].x=e._30-e._10,t[3].y=e._31-e._11,t[3].z=e._32-e._12,t[3].w=e._33-e._13,t[4].x=e._30+e._20,t[4].y=e._31+e._21,t[4].z=e._32+e._22,t[4].w=e._33+e._23,t[5].x=e._30-e._20,t[5].y=e._31-e._21,t[5].z=e._32-e._22,t[5].w=e._33-e._23,i=0;i<6;i++){var o=Math.sqrt(t[i].x*t[i].x+t[i].y*t[i].y+t[i].z*t[i].z);t[i].x/=o,t[i].y/=o,t[i].z/=o,t[i].w/=-o}var s=function(e){var t=0;return e.x>0&&(t|=1),e.y>0&&(t|=2),e.z>0&&(t|=4),t};this.planeNormals[3].setValues(t[0]),this.planeDistances[3]=t[0].w,this.directionIndex[3]=s(this.planeNormals[3]),this.planeNormals[2].setValues(t[1]),this.planeDistances[2]=t[1].w,this.directionIndex[2]=s(this.planeNormals[2]),this.planeNormals[5].setValues(t[2]),this.planeDistances[5]=t[2].w,this.directionIndex[5]=s(this.planeNormals[5]),this.planeNormals[4].setValues(t[3]),this.planeDistances[4]=t[3].w,this.directionIndex[4]=s(this.planeNormals[4]),this.planeNormals[0].setValues(t[4]),this.planeDistances[0]=t[4].w,this.directionIndex[0]=s(this.planeNormals[0]),this.planeNormals[1].setValues(t[5]),this.planeDistances[1]=t[5].w,this.directionIndex[1]=s(this.planeNormals[1])}},x3dom.fields.FrustumVolume.prototype.intersect=function(e,t){if(this.planeNormals.length<6)return x3dom.debug.logWarning(\"FrustumVolume not initialized!\"),!1;var i=this,o=e.min,s=e.max,r=function(e){var t=new x3dom.fields.SFVec3f(0,0,0);return t.x=1&e?o.x:s.x,t.y=2&e?o.y:s.y,t.z=4&e?o.z:s.z,t},n=function(e,t){return i.planeNormals[e].dot(t)-i.planeDistances[e]>=0},a=function(e){var t=r(i.directionIndex[e]);return n(e,t)},d=function(e){var t=r(7^i.directionIndex[e]);return!n(e,t)},l=1;t<0&&(t=0);for(var h=0;h<6;h++,l<<=1)if(0==(t&l)){if(d(h))return-1;a(h)&&(t|=l)}return t},x3dom.BindableStack=function(e,t,i,o){this._doc=e,this._type=t,this._defaultType=i,this._defaultRoot=null,this._getter=o,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(e){var t=this.top();t!==e&&(t&&t.deactivate(),this._bindStack.push(e),e.activate(t))},x3dom.BindableStack.prototype.replaceTop=function(e){var t=this.top();t!==e&&t&&(t.deactivate(),this._bindStack[this._bindStack.length-1]=e,e.activate(t))},x3dom.BindableStack.prototype.pop=function(e){var t;return e&&e!==(t=this.top())?null:((t=this._bindStack.pop())&&t.deactivate(),t)},x3dom.BindableStack.prototype.switchTo=function(e){var t=this.getActive(),i=this._bindBag.length,o=0,s=0,r=-1;if(!(i<=1)){switch(e){case\"first\":o=this._bindBag[0];break;case\"last\":o=this._bindBag[i-1];break;default:for(s=0;s=0)for(s=r;!o&&(s=\"next\"==e?s0?s-1:i-1)!=r;)this._bindBag[s]._vf.description.length>=0&&(o=this._bindBag[s])}o?this.replaceTop(o):x3dom.debug.logWarning(\"Cannot switch bindable; no other bindable with description found.\")}},x3dom.BindableStack.prototype.getActive=function(){if(0===this._bindStack.length){if(0===this._bindBag.length)if(this._defaultRoot){x3dom.debug.logInfo(\"create new \"+this._defaultType._typeName+\" for \"+this._type._typeName+\"-stack\");var e=new this._defaultType({doc:this._doc,nameSpace:this._defaultRoot._nameSpace,autoGen:!0});this._defaultRoot.addChild(e),e.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()}var t=this._bindStack[this._bindStack.length-1];return null==t._nameSpace&&(this.pop(),t=this.getActive()),t},x3dom.BindableBag=function(e){this._stacks=[],this.addType(\"X3DViewpointNode\",\"Viewpoint\",\"getViewpoint\",e),this.addType(\"X3DNavigationInfoNode\",\"NavigationInfo\",\"getNavigationInfo\",e),this.addType(\"X3DBackgroundNode\",\"Background\",\"getBackground\",e),this.addType(\"X3DFogNode\",\"Fog\",\"getFog\",e),this.addType(\"X3DEnvironmentNode\",\"Environment\",\"getEnvironment\",e)},x3dom.BindableBag.prototype.addType=function(e,t,i,o){var s=x3dom.nodeTypes[e],r=x3dom.nodeTypes[t];if(s&&r){var n=new x3dom.BindableStack(o,s,r,i);this._stacks.push(n)}else x3dom.debug.logWarning(\"Invalid Bindable type/defaultType: \"+e+\"/\"+r)},x3dom.BindableBag.prototype.setRefNode=function(e){this._stacks.forEach((function(t){t._defaultRoot=e,e[t._getter]=function(){return t.getActive()}}))},x3dom.BindableBag.prototype.addBindable=function(e){for(var t=0,i=this._stacks.length;t=0?e.substr(0,t+1):\"\",x3dom.debug.logInfo(\"setBaseURL: \"+this.baseURL)},x3dom.NodeNameSpace.prototype.getURL=function(e){return void 0!==e&&e.length?\"/\"===e[0]||e.indexOf(\":\")>=0?e:this.baseURL+e:\"\"},x3dom.hasElementAttribute=function(e){var t=this.__hasAttribute(e);return!t&&e&&(t=this.__hasAttribute(e.toLowerCase())),t},x3dom.getElementAttribute=function(e){var t=this.__getAttribute(e);return!t&&\"\"!=t&&e&&(t=this.__getAttribute(e.toLowerCase())),null==t&&this._x3domNode?this._x3domNode._vf[e]:t},x3dom.setElementAttribute=function(e,t){this.__setAttribute(e,t);var i=this._x3domNode;i&&(x3dom.userAgentFeature.supportsMutationObserver||i.updateField(e,t),i._nameSpace.doc.needRender=!0)},x3dom.getFieldValue=function(e){var t=this._x3domNode;if(t&&void 0!==t._vf[e]){var i=t._vf[e];return i instanceof Object&&\"copy\"in i?t._vf[e].copy():t._vf[e]}return null},x3dom.setFieldValue=function(e,t){var i=this._x3domNode;i&&void 0!==i._vf[e]&&i._nameSpace&&(t instanceof Object&&\"copy\"in t?i._vf[e]=t.copy():i._vf[e]=t,i.fieldChanged(e),i._nameSpace.doc.needRender=!0)},x3dom.requestFieldRef=function(e){var t=this._x3domNode;return t&&t._vf[e]?t._vf[e]:null},x3dom.releaseFieldRef=function(e){var t=this._x3domNode;t&&t._vf[e]&&t._nameSpace&&(t.fieldChanged(e),t._nameSpace.doc.needRender=!0)},x3dom.attachFieldAccess=function(e){e.requestFieldRef=x3dom.requestFieldRef,e.releaseFieldRef=x3dom.releaseFieldRef,e.getFieldValue=x3dom.getFieldValue,e.setFieldValue=x3dom.setFieldValue},x3dom.NodeNameSpace.prototype.setupTree=function(e,t){var i=null;if(t=t||null,x3dom.isX3DElement(e)){if(e._x3domNode)return x3dom.debug.logWarning(\"Tree is already initialized\"),null;if(void 0===e.tagName||e.__addEventListener||e.__removeEventListener||(e.__addEventListener=e.addEventListener,e.addEventListener=function(e,t,i){this._x3domNode._listeners[e]||(this._x3domNode._listeners[e]=[]),this._x3domNode._listeners[e].push(t),this.__addEventListener(e,t,i)},e.__removeEventListener=e.removeEventListener,e.removeEventListener=function(e,t,i){var o=this._x3domNode._listeners[e];if(o)for(var s=0;s=2){for(var s=this;s;)s.name==o[0]&&(i=s.defMap[o[1]]),s=i?null:s.parent;i||(i=null,x3dom.debug.logWarning(\"Could not USE: \"+e.getAttribute(\"USE\")))}}return i&&(e._x3domNode=i,x3dom.attachFieldAccess(e)),i}if(\"route\"===e.localName.toLowerCase()){var r=e,n=r.getAttribute(\"fromNode\")||r.getAttribute(\"fromnode\"),a=r.getAttribute(\"toNode\")||r.getAttribute(\"tonode\"),d=this.defMap[n],l=this.defMap[a],h=r.getAttribute(\"fromField\")||r.getAttribute(\"fromfield\"),f=r.getAttribute(\"toField\")||r.getAttribute(\"tofield\");return d&&l?(d.setupRoute(h,l,f),r._nodeNameSpace=this):(x3dom.debug.logWarning(\"not yet available route - can't find all DEFs for \"+h+\" -> \"+f),this.lateRoutes.push({route:r,fnDEF:n,tnDEF:a,fnAtt:h,tnAtt:f})),null}if(\"import\"===e.localName.toLowerCase()){var u=e.getAttribute(\"inlineDEF\")||e.getAttribute(\"inlinedef\"),c=e.getAttribute(\"importedDEF\")||e.getAttribute(\"importeddef\"),_=e.getAttribute(\"AS\")||e.getAttribute(\"as\");if(!u||!c)return null;if(_||(_=c),this.imports.get(u)||this.imports.set(u,new Map),this.imports.get(u).set(_,c),e._nodeNameSpace=this,this.defMap[u]&&this.defMap[u]._childNodes[0]&&this.defMap[u]._childNodes[0]._nameSpace){var m=this.defMap[u]._childNodes[0]._nameSpace;if(x=m.exports.get(c)){var p=m.defMap[x];p&&(this.defMap[_]=p,this.routeLateRoutes())}}return null}if(\"export\"===e.localName.toLowerCase()){var x=e.getAttribute(\"localDEF\")||e.getAttribute(\"localdef\");_=e.getAttribute(\"AS\")||e.getAttribute(\"as\");return x?(_||(_=x),this.exports.set(_,x),e._nodeNameSpace=this,this.superInlineNode&&this.superInlineNode._nameSpace&&this.superInlineNode._nameSpace.importNodes(this),null):null}x3dom.attachFieldAccess(e);var g=x3dom.nodeTypesLC[e.localName.toLowerCase()];if(void 0!==g){!1===x3dom.userAgentFeature.supportsDOMAttrModified&&e instanceof Element&&(e.setAttribute&&!e.__setAttribute&&(e.__setAttribute=e.setAttribute,e.setAttribute=x3dom.setElementAttribute),e.getAttribute&&!e.__getAttribute&&(e.__getAttribute=e.getAttribute,e.getAttribute=x3dom.getElementAttribute),e.hasAttribute&&!e.__hasAttribute&&(e.__hasAttribute=e.hasAttribute,e.hasAttribute=x3dom.hasElementAttribute));var v={doc:this.doc,runtime:this.doc._x3dElem.runtime,xmlNode:e,nameSpace:this};return i=new g(v),e.hasAttribute(\"DEF\")?(i._DEF=e.getAttribute(\"DEF\"),this.defMap[i._DEF]=i):e.hasAttribute(\"id\")&&(i._DEF=e.getAttribute(\"id\"),i._DEF in this.defMap||(this.defMap[i._DEF]=i)),void 0===e.highlight&&(e.highlight=function(e,t){var i=x3dom.fields.SFColor.parse(t);this._x3domNode.highlight(e,i),this._x3domNode._nameSpace.doc.needRender=!0}),i._xmlNode=e,e._x3domNode=i,e.querySelectorAll(\":scope > *\").forEach((function(t){var i=t.localName.toLowerCase();\"protodeclare\"==i?this.protoDeclare(t):\"externprotodeclare\"==i?this.externProtoDeclare(t):\"protoinstance\"==i&&this.protoInstance(t,e)}),this),e.childNodes.forEach((function(e){var t=this.setupTree(e,i);t&&i.addChild(t,e.getAttribute(\"containerField\"))}),this),i.nodeChanged(),i}x3dom.debug.logWarning(\"Unrecognised X3D element <\"+e.localName+\">.\")}else if(e.localName){var y=e.localName.toLowerCase(),T=this.protos.find((function(e){return y==e.name.toLowerCase()&&e.isExternProto}));t&&\"x3dommetagroup\"==y?e.childNodes.forEach(function(e){var i=this.setupTree(e,t);i&&t.addChild(i,e.getAttribute(\"containerField\"))}.bind(this)):\"protodeclare\"==y||\"externprotodeclare\"==y||\"protoinstance\"==y?i=null:\"is\"==e.localName.toLowerCase()?0==e.querySelectorAll(\"connect\").length&&x3dom.debug.logWarning(\"IS statement without connect link: \"+e.parentElement.localName):T?this.loadExternProtoAsync(T,e,e,e.parentElement):(x3dom.debug.logWarning(\"Unrecognised X3D element <\"+e.localName+\">.\"),i=null)}return i},x3dom.NodeNameSpace.prototype.importNodes=function(e){if(e&&e.superInlineNode&&e.superInlineNode._nameSpace==this){var t=this,i=e.superInlineNode._DEF,o=t.imports,s=e.exports,r=0;i&&o.get(i)&&(o.get(i).forEach((function(i,o){var n=s.get(i);if(n){var a=e.defMap[n];a&&(t.defMap[o]=a,r++)}})),r>0&&t.routeLateRoutes())}},x3dom.NodeNameSpace.prototype.routeLateRoutes=function(){var e=this;e.lateRoutes.forEach((function(t){var i=e.defMap[t.fnDEF],o=e.defMap[t.tnDEF];i&&o&&(x3dom.debug.logInfo(\"fixed ROUTE: from=\"+i._DEF+\", to=\"+o._DEF),i.setupRoute(t.fnAtt,o,t.tnAtt),t.route._nodeNameSpace=e)}))},x3dom.NodeNameSpace.prototype.protoInstance=function(e,t){if(e.localName&&!e._x3dom){var i=e.getAttribute(\"name\");if(e.hasAttribute(\"USE\")){var o=e.getAttribute(\"USE\"),s=this.defMap[o];i=s?s.constructor._typeName:t.getRootNode().querySelector(\"[DEF=\"+o+\"]\").getAttribute(\"name\")}var r=this.protos.find((function(e){return e.name==i}));if(null!=r){var n=document.createElement(i);if(e.hasAttribute(\"DEF\")?n.setAttribute(\"DEF\",e.getAttribute(\"DEF\")):e.hasAttribute(\"USE\")&&n.setAttribute(\"USE\",e.getAttribute(\"USE\")),e.hasAttribute(\"containerField\")&&n.setAttribute(\"containerField\",e.getAttribute(\"containerField\")),e.querySelectorAll(\":scope > fieldValue , :scope > fieldvalue\").forEach((function(e){var t=e.getAttribute(\"name\"),i=e.querySelectorAll(\":scope > *\");if(i.length>0)i.forEach((function(e){e.setAttribute(\"containerField\",t),n.appendChild(e)}));else{var o=e.getAttribute(\"value\");o&&n.setAttribute(t,o)}})),r.isExternProto&&r.needsLoading)this.loadExternProtoAsync(r,n,e,t);else{this.doc.mutationObserver.disconnect(),e.insertAdjacentElement(\"afterend\",n);var a=this.doc._x3dElem;this.doc._scene&&(a=this.doc._scene._xmlNode),this.doc.mutationObserver.observe(a,{attributes:!0,attributeOldValue:!0,childList:!0,subtree:!0}),e._x3dom=n}}else x3dom.debug.logWarning(\"ProtoInstance without a ProtoDeclaration \"+i)}},x3dom.NodeNameSpace.prototype.loadExternProtoAsync=function(e,t,i,o){e.instanceQueue.push({protoInstanceDom:t,domNode:i,parentDom:o,targetChildIndex:o._x3domNode._childNodes.length+e.instanceQueue.length}),i._x3dom=t;var s=this,r=0;!function t(){var i=s.getURL(e.url[r]);s.doc.incrementDownloads(),fetch(i).then((function(e){if(!e.ok)throw new Error(\"Network response was not OK: \"+e.status);return e.text()})).then((function(t){var o=new DOMParser,r=o.parseFromString(t,\"application/xml\"),n=r.querySelector(\"X3D\");null==n&&(n=(r=o.parseFromString(t,\"text/html\")).querySelector(\"X3D\"));var a=i.includes(\"#\")?i.split(\"#\").slice(-1)[0]:\"\",d=\"\"==a?\"ProtoDeclare\":\"ProtoDeclare[name='\"+a+\"']\",l=n.querySelector(d);l.setAttribute(\"name\",e.name),s.confNameSpace=new x3dom.NodeNameSpace(e.name,s.doc),s.confNameSpace.setBaseURL(s.baseURL+e.name),s.confNameSpace.setupTree(n.querySelector(\"Scene\"),n),s.confNameSpace.protos.forEach((function(e){s.protos.push(e)}));var h,f=s.protos.findIndex((function(t){return t==e}));for(s.protos.splice(f,1),s.protoDeclare(l);h=e.instanceQueue.shift();){var u=h.parentDom,c=u._x3domNode,_=h.protoInstanceDom,m=h.targetChildIndex;s.doc.mutationObserver.disconnect(),h.domNode!==_&&h.domNode.insertAdjacentElement(\"afterend\",_),s.doc.mutationObserver.observe(s.doc._scene._xmlNode,{attributes:!0,attributeOldValue:!0,childList:!0,subtree:!0}),s.doc.onNodeAdded(_,u);var p=c._childNodes,x=p.length-1;if(m!==x){var g=p[m],v=p[x];p[m]=v,p[x]=g;var y=(T=u.getAttribute(\"containerField\"))in c._cf&&c._cf[T];if(!y)for(var T in c._cf){var b=c._cf[T];if(x3dom.isa(v,b.type)){y=b;break}}y[m]=v,y[x]=g}s.lateRoutes.forEach((function(e){var t=s.defMap[e.fnDEF],i=s.defMap[e.tnDEF];t&&i&&(x3dom.debug.logInfo(\"fixed ROUTE: from=\"+t._DEF+\", to=\"+i._DEF),t.setupRoute(e.fnAtt,i,e.tnAtt),e.route._nodeNameSpace=s)})),s.superInlineNode&&s.superInlineNode._nameSpace&&s.superInlineNode._nameSpace.importNodes(s)}e.needsLoading=!1,s.doc.decrementDownloads()})).catch((function(o){if(x3dom.debug.logWarning(i+\": ExternProto fetch failed: \"+o),s.doc.decrementDownloads(),!(++r *\")})}));var s=e.querySelector(\"ProtoBody\");if(s){s._ISRoutes={},s.querySelectorAll(\"IS\").forEach((function(e){for(var t=e.parentElement;\"protobody\"!==t.localName.toLowerCase();)t=t.parentElement;t===s&&e.querySelectorAll(\"connect\").forEach((function(t){var i=e.parentElement;if(0==i.hasAttribute(\"DEF\")){var o=\"_proto_\"+i.tagName+\"_\"+x3dom.protoISDEFuid++;i.setAttribute(\"DEF\",o),\"protoinstance\"==i.localName.toLowerCase()&&i._x3domNode&&(i._x3domNode._DEF=o,i._x3domNode.typeNode._nameSpace.defMap[o]=i._x3domNode)}var r=t.getAttribute(\"protoField\"),n=i.getAttribute(\"DEF\"),a=t.getAttribute(\"nodeField\");s._ISRoutes[r]||(s._ISRoutes[r]=[]),s._ISRoutes[r].push({nodeDEF:n,nodeField:a})}))}));var r=new x3dom.ProtoDeclaration(this,t,s,o);r.registerNode(),this.protos.push(r)}else x3dom.debug.logWarning(\"ProtoDeclare without a ProtoBody definition: \"+e.name);return\"ProtoDeclare\"},x3dom.protoISDEFuid=0,x3dom.gfx_webgl=function(){\"use strict\";function e(e,t,i,o){this.ctx3d=e,this.canvas=t,this.name=i,this.x3dElem=o,this.IG_PositionBuffer=null,this.cache=new x3dom.Cache,this.stateManager=new x3dom.StateManager(e),this.VRMode=1,this.BUFFER_IDX={INDEX:0,POSITION:1,NORMAL:2,TEXCOORD:3,TEXCOORD_0:3,COLOR:4,TANGENT:6,BITANGENT:7,TEXCOORD_1:8,ID:9}}return e.prototype.getName=function(){return this.name},e.prototype.setupShape=function(e,t,i){var o,s,r,n,a,d,l,h,f,u,c,_,m=0,p=t.shape,x=p._cf.geometry.node;if(void 0!==p._webgl){var g=!1;if(!0===p._dirty.colors&&void 0===p._webgl.shader.color&&x._mesh._colors[0].length&&(g=!0),g&&p._cleanupGLObjects&&p._cleanupGLObjects(!0,!1),!0===p._dirty.texture){if(p._webgl.texture.length!=p.getTextures().length){for(r=0;r65535?(u=new Uint32Array(p._webgl.indexes[m]),p._webgl.indexType=e.UNSIGNED_INT):(u=new Uint16Array(p._webgl.indexes[m]),p._webgl.indexType=e.UNSIGNED_SHORT),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,f),e.bufferData(e.ELEMENT_ARRAY_BUFFER,u,e.STATIC_DRAW),u=null,p._webgl.positions[m]=x._mesh._positions[m],e.deleteBuffer(p._webgl.buffers[o+x3dom.BUFFER_IDX.POSITION]),a=e.createBuffer(),p._webgl.buffers[o+x3dom.BUFFER_IDX.POSITION]=a,e.bindBuffer(e.ARRAY_BUFFER,a),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,p._webgl.buffers[o+x3dom.BUFFER_IDX.INDEX]),n=new Float32Array(p._webgl.positions[m]),e.bufferData(e.ARRAY_BUFFER,n,e.STATIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,a),e.vertexAttribPointer(p._webgl.shader.position,x._mesh._numPosComponents,p._webgl.coordType,!1,p._coordStrideOffset[0],p._coordStrideOffset[1]),n=null),p._dirty.positions=!1,p._dirty.indexes=!1),1==p._dirty.colors&&(void 0!==p._webgl.shader.color&&(p._webgl.colors[m]=x._mesh._colors[m],e.deleteBuffer(p._webgl.buffers[o+x3dom.BUFFER_IDX.COLOR]),_=e.createBuffer(),p._webgl.buffers[o+x3dom.BUFFER_IDX.COLOR]=_,M=new Float32Array(p._webgl.colors[m]),e.bindBuffer(e.ARRAY_BUFFER,_),e.bufferData(e.ARRAY_BUFFER,M,e.STATIC_DRAW),e.vertexAttribPointer(p._webgl.shader.color,x._mesh._numColComponents,p._webgl.colorType,!1,p._colorStrideOffset[0],p._colorStrideOffset[1]),M=null),p._dirty.colors=!1),1==p._dirty.normals&&(void 0!==p._webgl.shader.normal&&(p._webgl.normals[m]=x._mesh._normals[m],e.deleteBuffer(p._webgl.buffers[o+x3dom.BUFFER_IDX.NORMAL]),c=e.createBuffer(),p._webgl.buffers[o+x3dom.BUFFER_IDX.NORMAL]=c,S=new Float32Array(p._webgl.normals[m]),e.bindBuffer(e.ARRAY_BUFFER,c),e.bufferData(e.ARRAY_BUFFER,S,e.STATIC_DRAW),e.vertexAttribPointer(p._webgl.shader.normal,x._mesh._numNormComponents,p._webgl.normalType,!1,p._normalStrideOffset[0],p._normalStrideOffset[1]),S=null),p._dirty.normals=!1),1==p._dirty.texcoords&&(void 0!==p._webgl.shader.texcoord&&(p._webgl.texcoords[m]=x._mesh._texCoords[m],e.deleteBuffer(p._webgl.buffers[o+x3dom.BUFFER_IDX.TEXCOORD]),d=e.createBuffer(),p._webgl.buffers[o+x3dom.BUFFER_IDX.TEXCOORD]=d,E=new Float32Array(p._webgl.texcoords[m]),e.bindBuffer(e.ARRAY_BUFFER,d),e.bufferData(e.ARRAY_BUFFER,E,e.STATIC_DRAW),e.vertexAttribPointer(p._webgl.shader.texCoord,x._mesh._numTexComponents,p._webgl.texCoordType,!1,p._texCoordStrideOffset[0],p._texCoordStrideOffset[1]),E=null),p._dirty.texcoords=!1),1==p._dirty.specialAttribs&&void 0!==p._webgl.shader.particleSize){var v=x._vf.size.toGL();v.length&&(e.deleteBuffer(p._webgl.buffers[o+x3dom.BUFFER_IDX.ID]),p._webgl.buffers[o+x3dom.BUFFER_IDX.ID]=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,p._webgl.buffers[o+x3dom.BUFFER_IDX.ID]),e.bufferData(e.ARRAY_BUFFER,new Float32Array(v),e.STATIC_DRAW)),p._dirty.specialAttribs=!1}if(!g)return}else if(!(x3dom.isa(x,x3dom.nodeTypes.Text)||x3dom.isa(x,x3dom.nodeTypes.BinaryGeometry)||x3dom.isa(x,x3dom.nodeTypes.PopGeometry)||x3dom.isa(x,x3dom.nodeTypes.BufferGeometry))&&(!x||x._mesh._positions[0].length<1))return void x3dom.debug.logError(\"NO VALID MESH OR NO VERTEX POSITIONS SET!\");for(p.unsetDirty(),p._cleanupGLObjects||(p._cleanupGLObjects=function(t,i){if(this._webgl&&(arguments.length>0&&t||0==this._parentNodes.length)){for(var o=this._webgl.shader,s=0;s65535?(u=new Uint32Array(p._webgl.indexes[m]),p._webgl.indexType=e.UNSIGNED_INT):(u=new Uint16Array(p._webgl.indexes[m]),p._webgl.indexType=e.UNSIGNED_SHORT),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,f),e.bufferData(e.ELEMENT_ARRAY_BUFFER,u,e.STATIC_DRAW),u=null,a=e.createBuffer(),p._webgl.buffers[o+x3dom.BUFFER_IDX.POSITION]=a,e.bindBuffer(e.ARRAY_BUFFER,a),n=new Float32Array(p._webgl.positions[m]),e.bufferData(e.ARRAY_BUFFER,n,e.STATIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,a),e.vertexAttribPointer(y.position,x._mesh._numPosComponents,p._webgl.coordType,!1,p._coordStrideOffset[0],p._coordStrideOffset[1]),e.enableVertexAttribArray(y.position),n=null),p._webgl.normals[m]){c=e.createBuffer(),p._webgl.buffers[o+x3dom.BUFFER_IDX.NORMAL]=c;var S=new Float32Array(p._webgl.normals[m]);e.bindBuffer(e.ARRAY_BUFFER,c),e.bufferData(e.ARRAY_BUFFER,S,e.STATIC_DRAW),e.vertexAttribPointer(y.normal,x._mesh._numNormComponents,p._webgl.normalType,!1,p._normalStrideOffset[0],p._normalStrideOffset[1]),e.enableVertexAttribArray(y.normal),S=null}if(p._webgl.texcoords[m]){var F=e.createBuffer();p._webgl.buffers[o+x3dom.BUFFER_IDX.TEXCOORD]=F;var E=new Float32Array(p._webgl.texcoords[m]);e.bindBuffer(e.ARRAY_BUFFER,F),e.bufferData(e.ARRAY_BUFFER,E,e.STATIC_DRAW),e.vertexAttribPointer(y.texcoord,x._mesh._numTexComponents,p._webgl.texCoordType,!1,p._texCoordStrideOffset[0],p._texCoordStrideOffset[1]),e.enableVertexAttribArray(y.texcoord),E=null}if(p._webgl.colors[m]){_=e.createBuffer(),p._webgl.buffers[o+x3dom.BUFFER_IDX.COLOR]=_;var M=new Float32Array(p._webgl.colors[m]);e.bindBuffer(e.ARRAY_BUFFER,_),e.bufferData(e.ARRAY_BUFFER,M,e.STATIC_DRAW),e.vertexAttribPointer(y.color,x._mesh._numColComponents,p._webgl.colorType,!1,p._colorStrideOffset[0],p._colorStrideOffset[1]),e.enableVertexAttribArray(y.color),M=null}if(void 0!==y.particleSize){var C=x._vf.size.toGL();if(C.length){var A=e.createBuffer();p._webgl.buffers[o+x3dom.BUFFER_IDX.ID]=A,e.bindBuffer(e.ARRAY_BUFFER,A),e.bufferData(e.ARRAY_BUFFER,new Float32Array(C),e.STATIC_DRAW)}}if(p._webgl.tangents[m]){l=e.createBuffer(),p._webgl.buffers[o+x3dom.BUFFER_IDX.TANGENT]=l;var w=new Float32Array(p._webgl.tangents[m]);e.bindBuffer(e.ARRAY_BUFFER,l),e.bufferData(e.ARRAY_BUFFER,w,e.STATIC_DRAW),e.vertexAttribPointer(y.tangent,x._mesh._numTangentComponents,p._webgl.tangentType,!1,p._tangentStrideOffset[0],p._tangentStrideOffset[1]),e.enableVertexAttribArray(y.tangent),w=null}if(p._webgl.binormals[m]){h=e.createBuffer(),p._webgl.buffers[o+x3dom.BUFFER_IDX.BITANGENT]=h;var R=new Float32Array(p._webgl.binormals[m]);e.bindBuffer(e.ARRAY_BUFFER,h),e.bufferData(e.ARRAY_BUFFER,R,e.STATIC_DRAW),e.vertexAttribPointer(y.binormal,x._mesh._numBinormalComponents,p._webgl.binormalType,!1,p._binormalStrideOffset[0],p._binormalStrideOffset[1]),e.enableVertexAttribArray(y.tangent),R=null}}for(var D in x._mesh._dynamicFields)if(x._mesh._dynamicFields.hasOwnProperty(D)){var N=x._mesh._dynamicFields[D];if(p._webgl.dynamicFields[T]={buf:{},name:D,numComponents:N.numComponents},void 0!==y[D]){var I=e.createBuffer();p._webgl.dynamicFields[T++].buf=I;var P=new Float32Array(N.value);e.bindBuffer(e.ARRAY_BUFFER,I),e.bufferData(e.ARRAY_BUFFER,P,e.STATIC_DRAW),e.vertexAttribPointer(y[D],N.numComponents,e.FLOAT,!1,0,0),P=null}}}},e.prototype.setupScene=function(e,t){var i=null,o=null,s=this;if(void 0!==t._webgl){if(!t._dirty)return;void 0!==t._webgl.texture&&t._webgl.texture&&e.deleteTexture(t._webgl.texture),t._cleanupGLObjects&&t._cleanupGLObjects(),t._webgl={}}t._dirty=!1;var r=t.getTexUrl(),n=0;if(r.length>0&&r[0].length>0)r.length>=6&&r[1].length>0&&r[2].length>0&&r[3].length>0&&r[4].length>0&&r[5].length>0||-1!=r[0].indexOf(\".dds\")?(i=new x3dom.nodeTypes.Sphere,t._webgl={positions:i._mesh._positions[0],indexes:i._mesh._indices[0],buffers:[{},{}]},t._webgl.primType=e.TRIANGLES,-1!=r[0].indexOf(\".dds\")?(t._webgl.shader=this.cache.getShader(e,x3dom.shader.BACKGROUND_CUBETEXTURE_DDS),t._webgl.texture=x3dom.Utils.createTextureCube(e,t._nameSpace.doc,[r[0]],!1,t._vf.crossOrigin,!0,!1,!1)):(t._webgl.shader=this.cache.getShader(e,x3dom.shader.BACKGROUND_CUBETEXTURE_DDS),t._webgl.texture=x3dom.Utils.createTextureCube(e,t._nameSpace.doc,r,!1,t._vf.crossOrigin,!0,!1))):(t._webgl={positions:[-1,-1,0,-1,1,0,1,-1,0,1,1,0],indexes:[0,1,2,3],buffers:[{},{}]},r=t._nameSpace.getURL(r[0]),t._webgl.texture=x3dom.Utils.createTexture2D(e,t._nameSpace.doc,r,!0,t._vf.crossOrigin,!1,!1),t._webgl.primType=e.TRIANGLE_STRIP,t._webgl.shader=s.cache.getShader(e,x3dom.shader.BACKGROUND_TEXTURE));else if(t.getSkyColor().length>1||t.getGroundColor().length){i=new x3dom.nodeTypes.Sphere,o=e.createTexture(),t._webgl={positions:i._mesh._positions[0],texcoords:i._mesh._texCoords[0],indexes:i._mesh._indices[0],buffers:[{},{},{}],texture:o,primType:e.TRIANGLES};var a=x3dom.Utils.nextHighestPowerOfTwo(t.getSkyColor().length+t.getGroundColor().length+2);a=a<512?512:a;var d=t._vf.groundAngle.length,l=[],h=[],f=[],u=[0];for(n=0;n0||1==t._vf.groundColor.length){for(u[u.length-1]=0;n--)n==d-1&&Math.PI-t._vf.groundAngle[n]<=Math.PI/2&&(u[u.length]=Math.PI/2,f[f.length]=t._vf.groundColor[t._vf.groundColor.length-1]),u[u.length]=Math.PI-t._vf.groundAngle[n],f[f.length]=t._vf.groundColor[n+1];0==d&&1==t._vf.groundColor.length&&(u[u.length]=Math.PI/2,f[f.length]=t._vf.groundColor[0]),u[u.length]=Math.PI,f[f.length]=t._vf.groundColor[0]}else u[u.length-1]_.y?(c=_.x/m.x,m.x=_.x,m.y=m.y*c):(c=_.y/m.y,m.y=_.y,m.x=m.x*c);var p=_.divideComponents(m),x=m.subtract(_).multiply(.5).divideComponents(m)}else p=new x3dom.fields.SFVec2f(1,1),x=new x3dom.fields.SFVec2f(0,0);n.scale=p.toGL(),n.translation=x.toGL()}if(n.isVR=-1,n.screenWidth=s.canvas.width,s.setTonemappingOperator(r,n),2==s.VRMode){var g=r.getViewMatrices()[1],v=g.e3();g._03=0,g._13=0,g._23=0;var y=r.getProjectionMatrices()[1].mult(g);n.modelViewProjectionMatrix2=y.toGL(),g._03=v.x,g._13=v.y,g._23=v.z,n.isVR=1}s.setVertexAttribEyeIdx(e,n),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t._webgl.buffers[x3dom.BUFFER_IDX.INDEX]),e.bindBuffer(e.ARRAY_BUFFER,t._webgl.buffers[x3dom.BUFFER_IDX.POSITION]),e.vertexAttribPointer(n.position,3,e.FLOAT,!1,0,0),e.enableVertexAttribArray(n.position),s.drawElements(e,t._webgl.primType,t._webgl.indexes.length,e.UNSIGNED_SHORT,0),e.disableVertexAttribArray(n.position),s.disableVertexAttribEyeIdx(e,n),e.activeTexture(e.TEXTURE0),t._webgl.texture.textureCubeReady?e.bindTexture(e.TEXTURE_CUBE_MAP,null):e.bindTexture(e.TEXTURE_2D,null),e.clear(e.DEPTH_BUFFER_BIT)}}},e.prototype.setupFgnds=function(e,t){if(void 0===t._fgnd){var i=this;t._fgnd={},t._fgnd._webgl={positions:[-1,-1,0,-1,1,0,1,-1,0,1,1,0],indexes:[0,1,2,3],buffers:[{},{}]},t._fgnd._webgl.primType=e.TRIANGLE_STRIP,t._fgnd._webgl.shader=this.cache.getShader(e,x3dom.shader.FRONTGROUND_TEXTURE);var o=t._fgnd._webgl.shader,s=e.createBuffer();t._fgnd._webgl.buffers[x3dom.BUFFER_IDX.POSITION]=s,e.bindBuffer(e.ARRAY_BUFFER,s);var r=new Float32Array(t._fgnd._webgl.positions);e.bufferData(e.ARRAY_BUFFER,r,e.STATIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,s),e.vertexAttribPointer(o.position,3,e.FLOAT,!1,0,0);var n=e.createBuffer();t._fgnd._webgl.buffers[x3dom.BUFFER_IDX.INDEX]=n;var a=new Uint16Array(t._fgnd._webgl.indexes);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n),e.bufferData(e.ELEMENT_ARRAY_BUFFER,a,e.STATIC_DRAW),r=null,a=null,t._fgnd._webgl.render=function(e,s){t._fgnd._webgl.texture=s,i.stateManager.frontFace(e.CCW),i.stateManager.disable(e.CULL_FACE),i.stateManager.disable(e.DEPTH_TEST),i.stateManager.useProgram(o),o.tex||(o.tex=0),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,t._fgnd._webgl.texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t._fgnd._webgl.buffers[x3dom.BUFFER_IDX.INDEX]),e.bindBuffer(e.ARRAY_BUFFER,t._fgnd._webgl.buffers[x3dom.BUFFER_IDX.POSITION]),e.vertexAttribPointer(o.position,3,e.FLOAT,!1,0,0),e.enableVertexAttribArray(o.position),i.drawElements(e,t._fgnd._webgl.primType,t._fgnd._webgl.indexes.length,e.UNSIGNED_SHORT,0,1),e.disableVertexAttribArray(o.position),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,null)}}},e.prototype.renderShadowPass=function(e,t,i,o,s,r,n){var a=t._scene,d=!1;this.stateManager.bindFramebuffer(e.FRAMEBUFFER,s.fbo),this.stateManager.viewport(0,0,s.width,s.height),e.clearColor(1,1,1,0),e.clearDepth(1),e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT),this.stateManager.depthFunc(e.LEQUAL),this.stateManager.enable(e.DEPTH_TEST),this.stateManager.enable(e.CULL_FACE),this.stateManager.disable(e.BLEND);x3dom.fields.SFVec3f.NullVector.toGL(),x3dom.fields.SFVec3f.OneVector.toGL();var l,h=a.getEnvironment()._vf.shadowExcludeTransparentObjects,f=a.drawableCollection.length;for(l=0;l0||p.popGeometry>0))for(R=0,N=0,D=x._vf.vertexCount.length;R>>8)/255,A.from=s.toGL(),A.sceneSize=r,0!=F.binaryGeometry&&1==E._vf.idsPerVertex&&(A.shadowIDs=b._vf.idOffset+x3dom.nodeTypes.Shape.objectID+2),F.coordType!=e.FLOAT&&(!F.popGeometry&&x3dom.Utils.isUnsignedType(E._vf.coordType)?A.bgCenter=E.getMin().toGL():A.bgCenter=E._vf.position.toGL(),A.bgSize=E._vf.size.toGL(),A.bgPrecisionMax=E.getPrecisionMax(\"coordType\")),1==n&&F.colorType!=e.FLOAT&&(A.bgPrecisionColMax=E.getPrecisionMax(\"colorType\")),2==n&&F.texCoordType!=e.FLOAT&&(A.bgPrecisionTexMax=E.getPrecisionMax(\"texCoordType\")),b._clipPlanes){A.modelViewMatrix=i.mult(T).toGL(),A.viewMatrixInverse=i.inverse().toGL(),2==this.VRMode&&(A.modelViewMatrix2=w.mult(T).toGL(),A.viewMatrixInverse2=w.inverse().toGL());for(var D=0;D0||F.popGeometry>0))for(G=0,H=0,z=E._vf.vertexCount.length;G0)this.drawElements(e,F.primType[0],E._vf.vertexCount[0],F.indexType,b._indexOffset);else if(F.bufferGeometry<0)this.drawArrays(e,F.primType[0],0,E._vf.vertexCount[0]);else if(E.hasIndexOffset()){var W=b.tessellationProperties();for(G=0,z=W.length;G65535?(me=new Uint32Array(h._webgl.indexes[ce]),h._webgl.indexType=d.UNSIGNED_INT):(me=new Uint16Array(h._webgl.indexes[ce]),h._webgl.indexType=d.UNSIGNED_SHORT),d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,c.buffers[_e+x3dom.BUFFER_IDX.INDEX]),d.bufferData(d.ELEMENT_ARRAY_BUFFER,me,d.DYNAMIC_DRAW),me=null}d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,c.buffers[_e+x3dom.BUFFER_IDX.INDEX]),l=!0}this.setVertexAttribEyeIdx(d,_),this.setVertexAttribPointerPosition(d,h,_e,ce),this.setVertexAttribPointerNormal(d,h,_e,ce),this.setVertexAttribPointerTexCoord(d,h,_e,ce),this.setVertexAttribPointerTexCoord2(d,h,_e,ce),this.setVertexAttribPointerColor(d,h,_e,ce),this.setVertexAttribPointerTangent(d,h,_e,ce),this.setVertexAttribPointerBinormal(d,h,_e,ce),void 0===_.id&&void 0===_.particleSize||!h._webgl.buffers[_e+x3dom.BUFFER_IDX.ID]||(d.bindBuffer(d.ARRAY_BUFFER,h._webgl.buffers[_e+x3dom.BUFFER_IDX.ID]),0!=c.binaryGeometry&&1==x._vf.idsPerVertex?(d.vertexAttribPointer(_.id,1,d.FLOAT,!1,4,0),d.enableVertexAttribArray(_.id)):he&&(d.vertexAttribPointer(_.particleSize,3,d.FLOAT,!1,0,0),d.enableVertexAttribArray(_.particleSize))),0!=c.popGeometry&&c.buffers[_e+x3dom.BUFFER_IDX.ID]&&(d.bindBuffer(d.ARRAY_BUFFER,c.buffers[_e+x3dom.BUFFER_IDX.ID]),d.vertexAttribPointer(_.PG_vertexID,1,d.FLOAT,!1,4,0),d.enableVertexAttribArray(_.PG_vertexID));var Te,be=t.getRenderMode(),Se=!!S&&(S._vf.transparency>0&&!h.isSolid()),Fe=function(e,t){e.frontFace(h.isCCW()?d.CCW:d.CW),e.enable(d.CULL_FACE),e.cullFace(d.FRONT),t(),e.cullFace(d.BACK),t(),e.disable(d.CULL_FACE)};if(be>0){var Ee=1==be?d.POINTS:d.LINES;if(l&&(c.binaryGeometry>0||c.popGeometry>0))for(se=0,ne=0,re=x._vf.vertexCount.length;se0)this.drawElements(d,c.primType[0],x._vf.vertexCount[0],c.indexType,h._indexOffset);else if(c.bufferGeometry<0)this.drawArrays(d,c.primType[0],0,x._vf.vertexCount[0]);else if(x.hasIndexOffset())for(se=0,re=(Te=h.tessellationProperties()).length;se0||c.popGeometry>0))for(se=0,ne=0,re=x._vf.vertexCount.length;se0)this.drawElements(d,c.primType[0],x._vf.vertexCount[0],c.indexType,h._indexOffset);else if(c.bufferGeometry<0)this.drawArrays(d,c.primType[0],0,x._vf.vertexCount[0]);else if(x.hasIndexOffset())for(se=0,re=(Te=h.tessellationProperties()).length;se0){var h=s.getViewpoint(),f=h.getImgPlaneHeightAtDistOne(),u=h.getNear(),c=r.multMatrixPnt(t._vf.position),_=.5*r.multMatrixVec(t._vf.size).length(),m=2*(.5*r.multMatrixVec(t._vf.maxBBSize).length())/(d*(Math.max(-c.z-_,u)*(f/n._height)));l=(l=Math.ceil(Math.log(m)/.693147180559945))<1?1:l>16?16:l}var p=t._vf.minPrecisionLevel,x=t._vf.maxPrecisionLevel;l=-1!=p&&lx?x:l;var g=o.levelsAvailable4?(d=s,l=r):(d=e._last_mat_view,l=e._last_mat_scene);var u=x3dom.fields.SFVec3f.copy(n._lastMin),c=x3dom.fields.SFVec3f.copy(n._lastMax),_=d.inverse().e3(),m=x3dom.fields.SFVec3f.copy(_),p=x3dom.fields.SFVec3f.copy(_);m.x>u.x&&(m.x=u.x),m.y>u.y&&(m.y=u.y),m.z>u.z&&(m.z=u.z),p.x0&&T>>8,255&o);if(R>=v){var O;R-=v;var B=t*e._inverseDevicePixelRatio,U=i*e._inverseDevicePixelRatio;if(4!=f?(e._pickingInfo.pickPos=C,e._pick.setValues(C),e._pickingInfo.pickNorm=A,e._pickNorm.setValues(A),e._pickingInfo.pickObj=null,e._pickingInfo.lastClickObj=null,O=n._xmlNode):(e._pickingInfo.pickObj=x3dom.nodeTypes.Shape.idMap.nodeID[T],O=e._pickingInfo.pickObj._xmlNode),I=e._pickingInfo.shadowObjectId!=R,e._pickingInfo.lastShadowObjectId=e._pickingInfo.shadowObjectId,e._pickingInfo.shadowObjectId=R,(I||L)&&n._xmlNode&&(n._xmlNode[\"on\"+V]||n._xmlNode.hasAttribute(\"on\"+V)||n._listeners[V])&&(P={target:n._xmlNode,type:V,button:L,mouseup:o>>>8>0,layerX:B,layerY:U,shadowObjectId:R,worldX:C.x,worldY:C.y,worldZ:C.z,normalX:A.x,normalY:A.y,normalZ:A.z,hitPnt:C.toGL(),hitObject:O,cancelBubble:!1,stopPropagation:function(){this.cancelBubble=!0},preventDefault:function(){this.cancelBubble=!0}},n.callEvtHandler(\"on\"+V,P)),n._shadowIdMap&&n._shadowIdMap.mapping&&R>>8>0,layerX:B,layerY:U,shadowObjectId:e._pickingInfo.shadowObjectId,cancelBubble:!1,stopPropagation:function(){this.cancelBubble=!0},preventDefault:function(){this.cancelBubble=!0}},n.callEvtHandler(\"on\"+V,P)),R>0?(e._pickingInfo.pickPos=C,e._pickingInfo.pickNorm=A,e._pickingInfo.pickObj=x3dom.nodeTypes.Shape.idMap.nodeID[R]):(e._pickingInfo.pickObj=null,e._pickingInfo.lastClickObj=null)}var H=x3dom.Utils.stopMeasure(\"picking\");return this.x3dElem.runtime.addMeasurement(\"PICKING\",H),!0},e.prototype.pickRect=function(e,t,i,o,s){var r=this.ctx3d,n=e?e._scene:null;if(!(r&&n&&n._webgl&&n.drawableCollection))return!1;var a,d=e._last_mat_view.inverse().e3(),l=n._lastMax.subtract(n._lastMin).length(),h=t<=o?t:o,f=i>=s?i:s,u=(1+Math.abs(o-t))*n._webgl.pickScale,c=(1+Math.abs(s-i))*n._webgl.pickScale;this.renderPickingPass(r,n,e._last_mat_view,e._last_mat_scene,d,l,0,h,f,u<1?1:u,c<1?1:c);var _=[];for(a=0;n._webgl.fboPick.pixelData&&a0&&_.push(m)}_.sort(),_=function(e){for(var t=[],i=e.length,o=0;o=g?m-=g:(p=(p=x3dom.nodeTypes.Shape.idMap.nodeID[m])&&p._xmlNode?p._xmlNode:null)&&x.push(p);return x},e.prototype.renderScene=function(e,t){var i=this.ctx3d,o=e._scene;if(null!==i&&null!==o){var s,r,n,a,d,l,h,f,u,c,_,m=e._doc._nodeBag.renderTextures,p=m.length,x=null,g=i.UNSIGNED_BYTE,v=i.UNSIGNED_BYTE;x3dom.caps.FP_TEXTURES&&(g=i.FLOAT,v=i.FLOAT,x3dom.caps.FPL_TEXTURES||!0);var y=[-1,-1,1,-1,-1,1,-1,1,1,-1,1,1];if(o.updateVolume(),o._webgl){var T=Math.round(this.canvas.width*o._webgl.pickScale),b=Math.round(this.canvas.height*o._webgl.pickScale);for(o._webgl._currFboWidth===T&&o._webgl._currFboHeight===b||(o._webgl._currFboWidth=T,o._webgl._currFboHeight=b,o._webgl.fboPick=x3dom.Utils.initFBO(i,T,b,o._webgl.fboPick.type,!1,!0),o._webgl.fboPick.pixelData=null,x3dom.debug.logInfo(\"Refreshed picking FBO to size (\"+T+\", \"+b+\")\")),r=0;r0)&&void 0===o._webgl.fboScene||o._webgl.fboScene&&(this.canvas.width!=o._webgl.fboScene.width||this.canvas.height!=o._webgl.fboScene.height))&&(o._webgl.fboScene=x3dom.Utils.initFBO(i,this.canvas.width,this.canvas.height,v,!1,!0))}else{for(o._webgl={},this.setupFgnds(i,o),o._webgl.pickScale=.5,o._webgl._currFboWidth=Math.round(this.canvas.width*o._webgl.pickScale),o._webgl._currFboHeight=Math.round(this.canvas.height*o._webgl.pickScale),o._webgl.fboPick=x3dom.Utils.initFBO(i,o._webgl._currFboWidth,o._webgl._currFboHeight,i.UNSIGNED_BYTE,!1,!0),o._webgl.fboPick.pixelData=null,o._webgl.normalShader=this.cache.getShader(i,x3dom.shader.NORMAL),o._webgl.fboShadow=[],h=(n=e.getShadowedLights()).length,d=0;d0||x3dom.SSAO.isEnabled(o))&&(o._webgl.fboScene=x3dom.Utils.initFBO(i,this.canvas.width,this.canvas.height,v,!1,!0)),o._webgl.fboBlur=[],d=0;d0){var W=H[j],Y=o._webgl.fboShadow[z],q=Math.max(0,Math.min(1,U[j]._vf.shadowOffset));if(x3dom.isa(U[j],x3dom.nodeTypes.PointLight))for(B=e.getWCtoLCMatricesPointLight(W,U[j],E),d=0;d<6;d++)this.renderShadowPass(i,e,B[d],M,Y[d],q,!1);else{var Q=Math.max(1,Math.min(U[j]._vf.shadowCascades,6));for(B=e.getWCtoLCMatricesCascaded(W,U[j],E),d=0;d0||x3dom.SSAO.isEnabled(o)){this.renderShadowPass(i,e,P,M,o._webgl.fboScene,0,!0);var K=x3dom.Utils.stopMeasure(\"shadow\");this.x3dElem.runtime.addMeasurement(\"SHADOW\",K)}else this.x3dElem.runtime.removeMeasurement(\"SHADOW\");for(B=e.getWCtoLCMatrix(e.getLightMatrix()[0]),r=0;r0&&this.renderShadows(i,e,n,k,G,M,E,P),this.stateManager.disable(i.BLEND),this.stateManager.disable(i.DEPTH_TEST),e._numRenderedNodes=h,x3dom.SSAO.isEnabled(o)&&x3dom.SSAO.renderSSAO(this.stateManager,i,o,this.canvas),void 0!==e._visDbgBuf&&e._visDbgBuf){var J=o._vf.pickMode.toLowerCase();0!=J.indexOf(\"idbuf\")&&\"color\"!=J&&\"texcoord\"!=J||(this.stateManager.viewport(0,3*this.canvas.height/4,this.canvas.width/4,this.canvas.height/4),o._fgnd._webgl.render(i,o._webgl.fboPick.tex)),(z>0||x3dom.SSAO.isEnabled(o))&&(this.stateManager.viewport(this.canvas.width/4,3*this.canvas.height/4,this.canvas.width/4,this.canvas.height/4),o._fgnd._webgl.render(i,o._webgl.fboScene.tex));var $=3,ee=2;for(d=0;d1&&(a.lastTex=1,e.activeTexture(e.TEXTURE1),e.bindTexture(e.TEXTURE_2D,i._webgl.fbo.tex),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)),a.curTex=2,e.activeTexture(e.TEXTURE2),e.bindTexture(e.TEXTURE_2D,i._webgl.texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),a.mode=i._currLoadLevel-1,a.repeat=i._repeat.toGL(),e.drawArrays(e.TRIANGLES,0,6),this.stateManager.bindFramebuffer(e.FRAMEBUFFER,i._webgl.fbo.fbo),e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT),a.mode=0,a.curTex=2,e.activeTexture(e.TEXTURE2),e.bindTexture(e.TEXTURE_2D,r.tex),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.drawArrays(e.TRIANGLES,0,6),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,null),e.disableVertexAttribArray(a.position),this.stateManager.bindFramebuffer(e.FRAMEBUFFER,null),this.stateManager.viewport(0,0,this.canvas.width,this.canvas.height),i._vf.autoRefinement&&i.nextLevel(),i._currLoadLevel==i._vf.maxLevel&&i._currLoadLevel++,i._webgl.fbo.mipMap&&(e.bindTexture(e.TEXTURE_2D,i._webgl.fbo.tex),e.generateMipmap(e.TEXTURE_2D),e.bindTexture(e.TEXTURE_2D,null)),i.requirePingPong()||(e.deleteTexture(i._webgl.texture),delete i._webgl.texture,i._cleanupGLObjects(!0)),i._renderedImage++}},e.prototype.renderRTPass=function(e,t,i){if(x3dom.isa(i,x3dom.nodeTypes.RefinementTexture))i.requirePingPong()&&this.renderPingPongPass(e,t,i);else{switch(i._vf.update.toUpperCase()){case\"NONE\":return;case\"NEXT_FRAME_ONLY\":if(!i._needRenderUpdate)return;i._needRenderUpdate=!1}var o,s,r=t._scene,n=null,a=i.getViewMatrix(),d=i.getProjectionMatrix(),l=d.mult(a),h=t.getLightMatrix()[0],f=t.getWCtoLCMatrix(h),u=i._cf.excludeNodes.nodes,c=u.length,_=new Array(c);for(o=0;o0||u.popGeometry>0)for(g=0,y=0,v=c._vf.vertexCount.length;g0)this.drawElements(e,u.primType[0],c._vf.vertexCount[0],u.indexType,f._indexOffset);else if(u.bufferGeometry<0)this.drawArrays(e,u.primType[0],0,c._vf.vertexCount[0]);else if(c.hasIndexOffset()){var b=f.tessellationProperties();for(g=0,v=b.length;gl&&(p[p.length]=u,m=7)}p[p.length]=i.length;var g=p.length-1,v=n.inverse(),y=a.inverse();this.stateManager.enable(e.BLEND),this.stateManager.blendFunc(e.DST_COLOR,e.ZERO);for(var T=0;T0?1:0;var M,C,A=this.cache.getShadowRenderingShader(e,F,E);this.stateManager.useProgram(A),e.bindBuffer(e.ARRAY_BUFFER,d._webgl.ppBuffer),e.vertexAttribPointer(A.position,2,e.FLOAT,!1,0,0),e.enableVertexAttribArray(A.position),A.sceneMap=0,e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,d._webgl.fboScene.tex),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),A.inverseProj=v.toGL(),A.inverseViewProj=y.toGL();for(var w=0,R=0,D=F.length;Rt.x?s[0]:t.x,t.y=s[1]>t.y?s[1]:t.y}return{x:e.x,y:e.y,width:t.x-e.x,height:t.y-e.y}},x3dom.Runtime.prototype.calcClientPos=function(e,t,i){var o=this.canvas.canvas.offsetParent;if(!o)return x3dom.debug.logError(\"Can't calc client pos without offsetParent.\"),[0,0];var s=o.getBoundingClientRect(),r=this.calcCanvasPos(e,t,i),n=document.defaultView.getComputedStyle(o,null),a=parseFloat(n.getPropertyValue(\"padding-left\")),d=parseFloat(n.getPropertyValue(\"border-left-width\")),l=parseFloat(n.getPropertyValue(\"padding-top\")),h=parseFloat(n.getPropertyValue(\"border-top-width\"));return[s.left+a+d+r[0],s.top+l+h+r[1]]},x3dom.Runtime.prototype.getScreenshot=function(){var e=\"\",t=this.canvas.backend,i=this.canvas.canvas;if(i)if(\"flash\"==t)e=i.getScreenshot();else{var o=document.createElement(\"canvas\");o.width=i.width,o.height=i.height;var s=o.getContext(\"2d\");s.drawImage(i,0,0,i.width,i.height),s.scale(1,-1),s.translate(0,-i.height),e=o.toDataURL()}return e},x3dom.Runtime.prototype.getCanvas=function(){return this.canvas.canvas},x3dom.Runtime.prototype.lightMatrix=function(){this.canvas.doc._viewarea.getLightMatrix()},x3dom.Runtime.prototype.resetView=function(){this.canvas.doc._viewarea.resetView()},x3dom.Runtime.prototype.lightView=function(){return this.canvas.doc._nodeBag.lights.length>0?(this.canvas.doc._viewarea.animateTo(this.canvas.doc._viewarea.getLightMatrix()[0],this.canvas.doc._scene.getViewpoint()),!0):(x3dom.debug.logInfo(\"No lights to navigate to.\"),!1)},x3dom.Runtime.prototype.uprightView=function(){this.canvas.doc._viewarea.uprightView()},x3dom.Runtime.prototype.fitAll=function(e){void 0===e&&(e=!0);var t=this.canvas.doc._scene;t.updateVolume(),this.canvas.doc._viewarea.fit(t._lastMin,t._lastMax,e)},x3dom.Runtime.prototype.fitObject=function(e,t){if(e&&e._x3domNode){void 0===t&&(t=!0);var i=x3dom.fields.SFVec3f.MAX(),o=x3dom.fields.SFVec3f.MIN();e._x3domNode.getVolume().getBounds(i,o);var s=e._x3domNode.getCurrentTransform();if(i=s.multMatrixPnt(i),o=s.multMatrixPnt(o),x3dom.isa(e._x3domNode,x3dom.nodeTypes.X3DTransformNode)){var r=e._x3domNode._trafo.inverse();i=r.multMatrixPnt(i),o=r.multMatrixPnt(o)}this.canvas.doc._viewarea.fit(i,o,t)}},x3dom.Runtime.prototype.showAll=function(e,t){this.canvas.doc._viewarea.showAll(e,t)},x3dom.Runtime.prototype.showObject=function(e,t){if(e&&e._x3domNode){void 0===t&&(t=\"negZ\");var i=x3dom.fields.SFVec3f.MAX(),o=x3dom.fields.SFVec3f.MIN();e._x3domNode.getVolume().getBounds(i,o);var s=e._x3domNode.getCurrentTransform();i=s.multMatrixPnt(i),o=s.multMatrixPnt(o);var r,n=this.canvas.doc._viewarea,a=n._widthx3dom.fields.Eps&&(a/=h);var f=n._width-1,u=n._height-1,c=.25,_=new x3dom.fields.SFVec2f(c*f,c*u);c=.75;var m=new x3dom.fields.SFVec2f(c*f,c*u),p=o.subtract(i).multiply(.5),x=p.length(),g=i.add(p),v=m.subtract(_).multiply(.5),y=1.5*v.length();v=v.add(_);var T=1;y>x3dom.fields.Eps&&(T=x/y*Math.sqrt(v.x*v.x+v.y*v.y+a*a)),r=(r=s.multMatrixVec(r).normalize()).multiply(T);var b=g.add(r),S=x3dom.fields.Quaternion.rotateFromTo(new x3dom.fields.SFVec3f(0,0,1),r).toMatrix(),F=x3dom.fields.SFMatrix4f.translation(b.negate()),E=x3dom.fields.SFMatrix4f.translation(b),M=(E=E.mult(S).mult(F).mult(E)).inverse();n.animateTo(M,d)}},x3dom.Runtime.prototype.animateViewpointTo=function(e,t){var i=this.canvas.doc._viewarea,o=this.canvas.doc._scene.getViewpoint();null!=e._x3domNode&&(e=e._x3domNode),i.animateTo(e,o,t)},x3dom.Runtime.prototype.getCenter=function(e){return e&&e._x3domNode&&(this.isA(e,\"X3DShapeNode\")||this.isA(e,\"X3DGeometryNode\"))?e._x3domNode.getCenter():null},x3dom.Runtime.prototype.getCurrentTransform=function(e){return e&&e._x3domNode?e._x3domNode.getCurrentTransform():null},x3dom.Runtime.prototype.getBBox=function(e){if(e&&e._x3domNode&&this.isA(e,\"X3DBoundedObject\")){var t=e._x3domNode.getVolume();return{min:x3dom.fields.SFVec3f.copy(t.min),max:x3dom.fields.SFVec3f.copy(t.max)}}return null},x3dom.Runtime.prototype.getSceneBBox=function(){var e=this.canvas.doc._scene;return e.updateVolume(),{min:x3dom.fields.SFVec3f.copy(e._lastMin),max:x3dom.fields.SFVec3f.copy(e._lastMax)}},x3dom.Runtime.prototype.debug=function(e){var t=this.canvas.doc;return void 0===t._viewarea._visDbgBuf&&(t._viewarea._visDbgBuf=\"true\"===t._x3dElem.getAttribute(\"showLog\")),arguments.length>0?!0===e?(t._viewarea._visDbgBuf=!0,x3dom.debug.logContainer.style.display=\"block\"):(t._viewarea._visDbgBuf=!1,x3dom.debug.logContainer.style.display=\"none\"):(t._viewarea._visDbgBuf=!t._viewarea._visDbgBuf,x3dom.debug.logContainer.style.display=1==t._viewarea._visDbgBuf?\"block\":\"none\"),t.needRender=!0,t._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 e=this.canvas.doc._viewarea;e._rotMat=x3dom.fields.SFMatrix4f.identity(),e._transMat=x3dom.fields.SFMatrix4f.identity(),e._movement=new x3dom.fields.SFVec3f(0,0,0),e._needNavigationMatrixUpdate=!0,this.canvas.doc.needRender=!0},x3dom.Runtime.prototype.disableKeys=function(){this.canvas.disableKeys=!0},x3dom.Runtime.prototype.enableKeys=function(){this.canvas.disableKeys=!1},x3dom.Runtime.prototype.disableLeftDrag=function(){this.canvas.disableLeftDrag=!0},x3dom.Runtime.prototype.enableLeftDrag=function(){this.canvas.disableLeftDrag=!1},x3dom.Runtime.prototype.disableRightDrag=function(){this.canvas.disableRightDrag=!0},x3dom.Runtime.prototype.enableRightDrag=function(){this.canvas.disableRightDrag=!1},x3dom.Runtime.prototype.disableMiddleDrag=function(){this.canvas.disableMiddleDrag=!0},x3dom.Runtime.prototype.enableMiddleDrag=function(){this.canvas.disableMiddleDrag=!1},x3dom.Runtime.prototype.togglePoints=function(e){var t=this.canvas.doc,i=!0===e?3:2;return t._viewarea._points=++t._viewarea._points%i,t.needRender=!0,t._viewarea._points},x3dom.Runtime.prototype.pickRect=function(e,t,i,o){return this.canvas.doc.onPickRect(this.canvas.gl,e,t,i,o)},x3dom.Runtime.prototype.pickMode=function(e){return e&&!0===e.internal?this.canvas.doc._scene._vf.pickMode:this.canvas.doc._scene._vf.pickMode.toLowerCase()},x3dom.Runtime.prototype.changePickMode=function(e){switch(e=e.toLowerCase()){case\"idbuf\":e=\"idBuf\";break;case\"idbuf24\":e=\"idBuf24\";break;case\"idbufid\":e=\"idBufId\";break;case\"texcoord\":e=\"texCoord\";break;case\"color\":e=\"color\";break;case\"box\":e=\"box\";break;default:x3dom.debug.logWarning(\"Switch pickMode to \"+e+\" unknown intersect type\"),e=void 0}return void 0!==e&&(this.canvas.doc._scene._vf.pickMode=e,x3dom.debug.logInfo(\"Switched pickMode to '\"+e+\"'.\"),!0)},x3dom.Runtime.prototype.speed=function(e){var t=this.canvas.doc._scene.getNavigationInfo();return e&&(t._vf.speed=e,x3dom.debug.logInfo(\"Changed navigation speed to \"+t._vf.speed)),t._vf.speed},x3dom.Runtime.prototype.zoom=function(e){this.canvas.doc._viewarea.zoom(e),this.canvas.doc.needRender=!0},x3dom.Runtime.prototype.statistics=function(e){var t=this.canvas.stateViewer;return!!t&&(this.canvas.doc.needRender=!0,!0===e?(t.display(e),!0):!1===e?(t.display(e),!1):(t.display(!t.active),t.active))},x3dom.Runtime.prototype.processIndicator=function(e){var t=this.canvas.progressDiv;return!!t&&(!0===e?(t.style.display=\"flex\",!0):!1===e?(t.style.display=\"none\",!1):\"none\"!=t.style.display)},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(e,t){var i=!1;return t&&e&&e._x3domNode&&(\"\"===t&&(t=\"X3DNode\"),i=x3dom.isa(e._x3domNode,x3dom.nodeTypesLC[t.toLowerCase()])),i},x3dom.Runtime.prototype.getPixelScale=function(){var e=this.viewpoint();if(!x3dom.isa(e,x3dom.nodeTypes.OrthoViewpoint))return x3dom.debug.logError(\"getPixelScale is only implemented for orthographic Viewpoints\"),null;var t=e.getZoom(),i=t[0],o=t[1],s=t[2],r=t[3]-o,n=(s-i)/this.getWidth(),a=r/this.getHeight();return new x3dom.fields.SFVec3f(n,a,0)},x3dom.Runtime.prototype.onAnimationStarted=function(){},x3dom.Runtime.prototype.onAnimationFinished=function(){},x3dom.Runtime.prototype.enterVR=function(){this.canvas.enterVR()},x3dom.Runtime.prototype.exitVR=function(){this.canvas.exitVR()},x3dom.Runtime.prototype.toggleVR=function(){this.canvas.xrSession?this.canvas.xrSession&&this.exitVR():this.enterVR()},x3dom.Runtime.prototype.toggleProjection=function(e,t){var i,o=document.getElementById(\"x3d\").runtime.canvas.doc._scene.getNavigationInfo(),s=o._vf.transitionTime,r=document.getElementById(e)._x3domNode,n=document.getElementById(t)._x3domNode;if(o._vf.transitionTime=0,n._bindAnimation=!1,r._bindAnimation=!1,r._vf.isActive)n._viewMatrix=r._viewMatrix,document.getElementById(t).setAttribute(\"set_bind\",\"true\"),i=r._viewMatrix.e3().length()/2.2,n.setZoom(i);else if(n._vf.isActive){r._viewMatrix=n._viewMatrix,document.getElementById(e).setAttribute(\"set_bind\",\"true\"),i=-2.2*n._fieldOfView[2];var a=n._viewMatrix.e2().normalize().multiply(i);r._viewMatrix.setTranslate(a)}return o._vf.transitionTime=s,n._bindAnimation=!0,r._bindAnimation=!0,r._vf.isActive?0:1},x3dom.Runtime.prototype.replaceWorld=function(e){var t,i,o;for(t=\"X3D\"===e.localName.toUpperCase()?e.cloneNode(!1):this.doc.cloneNode(!1);i=e.firstChild;)\"HEAD\"==(o=1===i.nodeType?i.localName.toUpperCase():null)||\"SCENE\"==o?t.appendChild(i):i.remove();this.doc.parentNode.replaceChild(t,this.doc),this.doc=t,x3dom.reload()},x3dom.Runtime.prototype.createX3DFromJS=function(e,t){return t&&(e=x3dom.protoExpander.prototypeExpander(t,e)),(new x3dom.JSONParser).parseJavaScript(e)},x3dom.Runtime.prototype.createX3DFromString=function(e,t){try{var i=JSON.parse(e);return this.createX3DFromJS(i,t)}catch(t){var o=new DOMParser,s=o.parseFromString(e,\"application/xml\"),r=s.querySelector(\"X3D\");return null==r&&(r=(s=o.parseFromString(e,\"text/html\")).querySelector(\"X3D\")),r}},x3dom.Runtime.prototype.createX3DFromURLPromise=function(e,t){this.canvas.doc.incrementDownloads();var i=this;return fetch(e).then((function(e){return e.text()})).then((function(e){return i.canvas.doc.decrementDownloads(),i.createX3DFromString(e,t)})).catch((function(e){return i.canvas.doc.decrementDownloads(),x3dom.debug.logError(\"fetch failed: \"+e),null}))},x3dom.Runtime.prototype.loadURL=function(e,t){var i=this;this.createX3DFromURLPromise(e,t).then((function(t){null!=t?i.replaceWorld(t):x3dom.debug.logError(\"loadURL: could not fetch or parse \"+e)}))},x3dom.userAgentFeature={supportsDOMAttrModified:!1,supportsMutationObserver:!0},function(){\"use strict\";var e=function(){var e,t,i,o=document.getElementsByTagName(\"X3D\"),s=[];for(e=0;e\"+x3dom.about.revision+\", Date: \"+x3dom.about.date),x3dom.debug.logInfo(\"Found \"+s.length+\" X3D and nodes...\"),e=0;e0&&x3dom.canvases[0].doc){for(var e=0;e2.3&&(r=2.3)}var _,m,p=this.node._vf.string,x=this.node._vf.maxExtent,g=[],v=s,y=document.createElement(\"canvas\");y.dir=h;var T=32*r;document.body.appendChild(y);var b=y.getContext(\"2d\");b.font=o+\" \"+T+\"px \"+i;var S,F,E,M=0;for(E=0;EM&&(M=S),F=0|this.node._vf.length[E],x>0&&(F>x||0==F)&&(F=x),g[E]=F<=0?S:32*F;var C=.25*T,A=M+C,w=T+T*n*(p.length-1)+C;_=0,m=0;var R=0,D=0,N=\"alphabetic\";switch(s){case\"center\":R=-A/2,_=A/2;break;case\"left\":R=0,_=0;break;case\"right\":R=-A,_=A}switch(d){case\"MIDDLE\":D=w/2-C/2,N=\"middle\",m=T/2;break;case\"BEGIN\":D=f?0:w-C,N=f?\"top\":\"bottom\",m=f?0:T;break;case\"FIRST\":D=f?T:w-C,N=f?\"alphabetic\":\"bottom\",m=T;break;case\"END\":D=f?w-C:0,N=f?\"bottom\":\"top\",m=f?T:0}var I=A*(1/32),P=w*(1/32),V=x3dom.caps.MAX_TEXTURE_SIZE>>2;R*=1/32,D*=1/32,y.width=Math.min(x3dom.Utils.nextHighestPowerOfTwo(A*a),V),y.height=Math.min(x3dom.Utils.nextHighestPowerOfTwo(w*a),V),y.dir=h,b.scale(y.width/A,y.height/w),b.fillStyle=\"rgba(0,0,0,0)\",b.fillRect(0,0,b.canvas.width,b.canvas.height),b.fillStyle=\"white\",b.textBaseline=N,b.font=o+\" \"+T+\"px \"+i,b.textAlign=v;var L={font_style:o,font_family:i,font_spacing:n,paragraph:p,topToBottom:f,leftToRight:h,textX:_,textY:m,textHeight:T,lengths:g};this.renderScaledText(b,1,L),null===this.texture&&(this.texture=e.createTexture()),e.bindTexture(this.type,this.texture),this.uploadTextMipmap(y,L),e.bindTexture(this.type,null),document.body.removeChild(y),this.node._mesh._positions[0]=[0+R,-P+D,0,I+R,-P+D,0,I+R,0+D,0,0+R,0+D,0],this.node.invalidateVolume(),this.node._parentNodes.forEach((function(e){e.setAllDirty()}))},x3dom.Texture.prototype.renderScaledText=function(e,t,i){e.font=i.font_style+\" \"+i.textHeight/t+\"px \"+i.font_family;for(var o=i.textY,s=0;s>1),d=Math.max(1,d>>1),l.clearRect(0,0,o,s),n*=2,this.renderScaledText(l,n,t)},x3dom.X3DDocument=function(e,t,i){this.canvas=e,this.ctx=t,this.properties=i,this.needRender=!0,this._x3dElem=null,this._scene=null,this._viewarea=null,this.downloadCount=0,this.previousDownloadCount=0,this.mutationObserver=new MutationObserver(this.onMutation.bind(this)),this.X3DMutationObserver=new MutationObserver(this.onX3DMutation.bind(this)),this._nodeBag={timer:[],lights:[],clipPlanes:[],followers:[],trans:[],renderTextures:[],viewarea:[],affectedPointingSensors:[]},this.onload=function(){},this.onerror=function(){}},x3dom.X3DDocument.prototype.load=function(e,t){var i={},o=[e],s=this;!function r(){if(0===o.length)return s._setup(i[e],i,t),void s.onload();var n=o.shift();!x3dom.isX3DElement(n)||\"x3d\"!==n.localName.toLowerCase()&&\"websg\"!==n.localName.toLowerCase()||(i[n]=n,s._x3dElem=n,r())}()},x3dom.findScene=function(e){for(var t=[],i=0;i1?(x3dom.debug.logError(\"X3D element has more than one Scene child (has \"+e.childNodes.length+\").\"),null):t[0]},x3dom.X3DDocument.prototype._setup=function(e){var t=x3dom.findScene(e);this.X3DMutationObserver.observe(document,{attributes:!1,attributeOldValue:!1,childList:!0,subtree:!0}),this.mutationObserver.observe(e,{attributes:!1,attributeOldValue:!1,childList:!0,subtree:!1}),this.mutationObserver.observe(t,{attributes:!0,attributeOldValue:!0,childList:!0,subtree:!0}),this._bindableBag=new x3dom.BindableBag(this);var i=new x3dom.NodeNameSpace(\"scene\",this).setupTree(t);this._scene=i,this._bindableBag.setRefNode(i),this._viewarea=new x3dom.Viewarea(this,i),this._viewarea._width=this.canvas.width,this._viewarea._height=this.canvas.height},x3dom.X3DDocument.prototype.advanceTime=function(e){var t=0;if(this._nodeBag.timer.length)for(t=0;t0&&this._viewarea.animateTo(this._viewarea.getLightMatrix()[0],this._scene.getViewpoint());break;case 117:this._viewarea.uprightView();break;case 118:var s=this;!function(){var e=s._viewarea._scene.getViewpoint(),t=s._viewarea.getViewMatrix().inverse(),i=new x3dom.fields.Quaternion(0,0,1,0);i.setValue(t);var o=i.toAxisAngle(),r=t.e3(),n=e.getCenterOfRotation();x3dom.debug.logInfo('\\n<Viewpoint position=\"'+r.x.toFixed(5)+\" \"+r.y.toFixed(5)+\" \"+r.z.toFixed(5)+'\" orientation=\"'+o[0].x.toFixed(5)+\" \"+o[0].y.toFixed(5)+\" \"+o[0].z.toFixed(5)+\" \"+o[1].toFixed(5)+'\" \\n\\tzNear=\"'+e.getNear().toFixed(5)+'\" zFar=\"'+e.getFar().toFixed(5)+'\" centerOfRotation=\"'+n.x.toFixed(5)+\" \"+n.y.toFixed(5)+\" \"+n.z.toFixed(5)+'\" fieldOfView=\"'+e.getFieldOfView().toFixed(5)+'\" description=\"'+e._vf.description+'\"></Viewpoint>')}();break;case 119:t.setType(\"walk\",this._viewarea);break;case 121:t.setType(\"freefly\",this._viewarea)}},x3dom.X3DDocument.prototype.shutdown=function(e){e&&e.shutdown(this._viewarea)},x3dom.X3DDocument.prototype.hasAnimationStateChanged=function(){return!!this._viewarea&&this._viewarea.hasAnimationStateChanged()},x3dom.X3DDocument.prototype.isAnimating=function(){return!!this._viewarea&&this._viewarea.isAnimating()},x3dom.X3DDocument.prototype.incrementDownloads=function(){this.downloadCount++},x3dom.X3DDocument.prototype.decrementDownloads=function(){this.downloadCount--},x3dom.X3DDocument.prototype.cleanNodeBag=function(e,t){for(var i=0,o=e.length;i0},x3dom.MatrixMixer.prototype.setBeginMatrix=function(e){this._beginMat.setValues(e),this._beginInvMat=e.inverse(),this._beginLogMat=x3dom.fields.SFMatrix4f.zeroMatrix()},x3dom.MatrixMixer.prototype.getBeginMatrix=function(e){return this._beginMat},x3dom.MatrixMixer.prototype.setEndMatrix=function(e){this._endMat.setValues(e),this._isValid()||this._prepareQuaternionAnimation(),this._endLogMat=this._endMat.mult(this._beginInvMat).log(),this._logDiffMat=this._endLogMat.addScaled(this._beginLogMat,-1)},x3dom.MatrixMixer.prototype.getEndMatrix=function(e){return this._endMat},x3dom.MatrixMixer.prototype._mixQuaternion=function(e){var t=this._beginRot.slerp(this._endRot,e),i=this._beginPos.addScaled(this._endPos.subtract(this._beginPos),e);return this._result.setRotate(t),this._result.setTranslate(i),this._result.copy()},x3dom.MatrixMixer.prototype._mixMatrix=function(e){return this._logDiffMat.multiply(e).add(this._beginLogMat).exp().mult(this._beginMat)},x3dom.MatrixMixer.prototype.mix=function(e){if(e<=this.beginTime)return this._beginMat;if(e>=this.endTime)return this.reset(),this._endMat;this.isMixing=!0;var t=this._calcFraction(e);return this._useQuaternion?this._mixQuaternion(t):this._mixMatrix(t)},x3dom.Mesh=function(e){this._parent=e,this._vol=new x3dom.fields.BoxVolume,this._invalidate=!0,this._numFaces=0,this._numCoords=0,this._primType=\"TRIANGLES\",this._positions=[],this._normals=[],this._texCoords=[],this._texCoords2=[],this._colors=[],this._indices=[],this._tangents=[],this._binormals=[],this._positions[0]=[],this._normals[0]=[],this._texCoords[0]=[],this._texCoords2[0]=[],this._colors[0]=[],this._indices[0]=[],this._tangents[0]=[],this._binormals[0]=[]},x3dom.Mesh.prototype._dynamicFields={},x3dom.Mesh.prototype._numPosComponents=3,x3dom.Mesh.prototype._numTexComponents=2,x3dom.Mesh.prototype._numTex2Components=2,x3dom.Mesh.prototype._numColComponents=3,x3dom.Mesh.prototype._numNormComponents=3,x3dom.Mesh.prototype._numTangentComponents=3,x3dom.Mesh.prototype._numBinormalComponents=3,x3dom.Mesh.prototype._lit=!0,x3dom.Mesh.prototype._vol=null,x3dom.Mesh.prototype._invalidate=!0,x3dom.Mesh.prototype._numFaces=0,x3dom.Mesh.prototype._numCoords=0,x3dom.Mesh.prototype.getVolume=function(){if(1==this._invalidate&&!this._vol.isValid()){var e=this._positions[0],t=e.length;if(t>=3){var i=new x3dom.fields.SFVec3f(e[0],e[1],e[2]);this._vol.setBounds(i,i);for(var o=3;oe[o]&&(this._vol.min.x=e[o]),this._vol.min.y>e[o+1]&&(this._vol.min.y=e[o+1]),this._vol.min.z>e[o+2]&&(this._vol.min.z=e[o+2]),this._vol.max.xf?this._posSize/3:f/3;for(c=3*(c-Math.floor(c)>0?Math.floor(c+1):c),i=0;ix3dom.fields.Eps)for(i=0;i=0;if(this._indices[u]=c?l.slice(u*s,(u+1)*s):l.slice(u*s),o)for(m=0,p=this._indices[u].length;m++u*s*3)}},x3dom.Mesh.prototype.calcTexCoords=function(e){if(this._texCoords[0]=[],\"sphere-local\"===e.toLowerCase())for(var t=0,i=0,o=this._normals[0].length;t=l.y?l.x>=l.z?(h=0,f=l.y>=l.z?1:2):(h=2,f=0):l.y>=l.z?(h=1,f=l.x>=l.z?0:2):(h=2,f=1);var u=1,c=0,_=0;switch(h){case 0:u=l.x,c=a.x;break;case 1:u=l.y,c=a.y;break;case 2:u=l.z,c=a.z}switch(f){case 0:l.x,_=a.x;break;case 1:l.y,_=a.y;break;case 2:l.z,_=a.z}for(s=0,r=0,n=this._positions[0].length;s\"+e+\"   \"+x3dom.nodeTypes[e]._compName+\"
\",x3dom.nodeTypes[e].childTypes[e])o(x3dom.nodeTypes[e].childTypes[e][s],i+1)};for(e in x3dom.nodeTypes){var s;for(void 0===(s=x3dom.nodeTypes[e]).childTypes&&(s.childTypes={});s.superClass;)void 0===s.superClass.childTypes[s.superClass._typeName]&&(s.superClass.childTypes[s.superClass._typeName]=[]),i(s.superClass.childTypes[s.superClass._typeName],s._typeName)||s.superClass.childTypes[s.superClass._typeName].push(s._typeName),s=s.superClass}return o(\"X3DNode\",0),\"
\"+t+\"
\"},x3dom.docs.getComponentInfo=function(){var e,t,i,o=[],s=\"\";for(t in x3dom.components)o.push(t);for(i in o.sort(),o){for(var r in t=o[i],e=x3dom.components[t],s+=\"

\"+t+\"

\",s+=\"
    \",e){if(s+=\"
  • \"+r+\"
      \",!r.startsWith(\"X3D\")){try{var n=new x3dom.nodeTypes[r];for(var a in s+=\"-- basic fields --\",n._vf)s+=\"
    • \"+a+\": \"+n._vf[a],s+=\"
    • \"}catch(e){}try{for(var d in s+=\"-- node fields --\",n._cf)s+=\"
    • \"+d+\": \"+JSON.stringify(n._cf[d]),s+=\"
    • \"}catch(e){}}s+=\"
  • \"}s+=\"
\"}return s},x3dom.arc={},x3dom.arc.instance=null,x3dom.arc.Limits=function(e,t,i){this._min=e,this._max=t,this.getValue=function(e){return e=this._min+(this._max-this._min)*e,this._max>=e?this._min<=e?e:this._min:this._max}},x3dom.arc.ARF=function(e,t,i,o,s,r,n,a){this._name=e,this._stateValue=[.5,.5],this._limits=new x3dom.arc.Limits(t,i),this._factorGetterFunc=s,this._factorSetterFunc=r,this._setterFunc=a,this._getterFunc=n,this._dirFac=o,this.getFactor=function(){return this._factorGetterFunc()},this.update=function(e,t){var i=this._stateValue[e]+t*this._dirFac;this._stateValue[e]=0<=i?1>=i?i:1:0,this._setterFunc(this._limits.getValue(this._stateValue[e]))},this.reset=function(){this._stateValue[0]=.5,this._stateValue[1]=.5}},x3dom.arc.AdaptiveRenderControl=defineClass(null,(function(e){x3dom.arc.instance=this,this._scene=e,this._targetFrameRate=[],this._targetFrameRate[0]=this._scene._vf.minFrameRate,this._targetFrameRate[1]=this._scene._vf.maxFrameRate,this._currentState=0;var t=this._scene.getEnvironment();this._arfs=[],this._arfs.push(new x3dom.arc.ARF(\"smallFeatureCulling\",0,10,-1,(function(){return t._vf.smallFeatureFactor}),(function(e){t._vf.smallFeatureFactor=e}),(function(){return t._vf.smallFeatureThreshold}),(function(e){t._vf.smallFeatureThreshold=e}))),this._arfs.push(new x3dom.arc.ARF(\"lowPriorityCulling\",0,100,1,(function(){return t._vf.lowPriorityFactor}),(function(e){t._vf.lowPriorityFactor=e}),(function(){return 100*t._vf.lowPriorityThreshold}),(function(e){t._vf.lowPriorityThreshold=e/100}))),this._arfs.push(new x3dom.arc.ARF(\"tessellationDetailCulling\",1,12,-1,(function(){return t._vf.tessellationErrorFactor}),(function(e){t._vf.tessellationErrorFactor=e}),(function(){return t.tessellationErrorThreshold}),(function(e){t.tessellationErrorThreshold=e}))),this._stepWidth=.1}),{update:function(e,t){this._currentState=e;var i=t-this._targetFrameRate[e];this._stepWidth=Math.abs(i)>10?.1:.01;var o,s=0,r=[],n=this._arfs.length;for(o=0;o0&&(s+=r[o]);var a=i<0?-1:1;for(o=0;o0&&(r[o]/=s,this._arfs[o].update(e,this._stepWidth*r[o]*a))},reset:function(){for(var e=0,t=this._arfs.length;ethis.maxParallelRequests)){var e=this.requests.pop();e&&(this.activeRequests.push(e),e.send(null),this._sendRequest())}},x3dom.RequestManager._getCounters=function(){return{loaded:this.loadedRequests,active:this.activeRequests.length,failed:this.failedRequests,total:this.totalRequests}},x3dom.RequestManager.addRequest=function(e){if(e instanceof XMLHttpRequest){this.totalRequests++,e.withCredentials=this.withCredentials;for(var t=0;t1?(e.prev.next=e.next,e.next.prev=e.prev,e==this.first&&(this.first=e.next),e==this.last&&(this.last=e.prev)):(this.first=null,this.last=null),e.prev=null,e.next=null,this.length--},x3dom.DoublyLinkedList.prototype.getNode=function(e){var t=null;if(e>this.length)return t;for(var i=0;i0}(e,0,x,i),v=o(e,0,x,i,!0,g),y=[];if(!v)return y;p&&(v=function(e,t,i,r){var n,a,d,l,u,_=[];for(n=0,a=t.length;n80*i){n=d=e[0],a=l=e[1];for(var T=i;Td&&(d=u),_>l&&(l=_);m=Math.max(d-n,l-a)}r(v,y,i,n,a,m),!1===g&&y.reverse();return y}(e,t,i);function o(e,t,i,o,s,r){var n,a;if(s===r)for(n=t;n=t;n-=o)a=T(n,e[n],e[n+1],a);return a}function s(e,t){if(!e)return e;t||(t=e);var i,o=e;do{if(i=!1,o.steiner||!x(o,o.next)&&0!==p(o.prev,o,o.next))o=o.next;else{if(b(o),(o=t=o.prev)===o.next)return null;i=!0}}while(i||o!==t);return t}function r(e,t,i,o,h,f,c){if(e){!c&&f&&function(e,t,i,o){var s=e;do{null===s.z&&(s.z=u(s.x,s.y,t,i,o)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next}while(s!==e);s.prevZ.nextZ=null,s.prevZ=null,function(e){var t,i,o,s,r,n,a,d,l=1;do{for(i=e,e=null,r=null,n=0;i;){for(n++,o=i,a=0,t=0;t0||d>0&&o;)0===a?(s=o,o=o.nextZ,d--):0!==d&&o?i.z<=o.z?(s=i,i=i.nextZ,a--):(s=o,o=o.nextZ,d--):(s=i,i=i.nextZ,a--),r?r.nextZ=s:e=s,s.prevZ=r,r=s;i=o}r.nextZ=null,l*=2}while(n>1)}(s)}(e,o,h,f);for(var _,m,p=e;e.prev!==e.next;)if(_=e.prev,m=e.next,f?a(e,o,h,f):n(e))t.push(_.i/i),t.push(e.i/i),t.push(m.i/i),b(e),e=m.next,p=m.next;else if((e=m)===p){c?1===c?r(e=d(e,t,i),t,i,o,h,f,2):2===c&&l(e,t,i,o,h,f):r(s(e),t,i,o,h,f,1);break}}}function n(e){var t=e.prev,i=e,o=e.next;if(p(t,i,o)>=0)return!1;for(var s=e.next.next;s!==e.prev;){if(_(t.x,t.y,i.x,i.y,o.x,o.y,s.x,s.y)&&p(s.prev,s,s.next)>=0)return!1;s=s.next}return!0}function a(e,t,i,o){var s=e.prev,r=e,n=e.next;if(p(s,r,n)>=0)return!1;for(var a=s.xr.x?s.x>n.x?s.x:n.x:r.x>n.x?r.x:n.x,h=s.y>r.y?s.y>n.y?s.y:n.y:r.y>n.y?r.y:n.y,f=u(a,d,t,i,o),c=u(l,h,t,i,o),m=e.nextZ;m&&m.z<=c;){if(m!==e.prev&&m!==e.next&&_(s.x,s.y,r.x,r.y,n.x,n.y,m.x,m.y)&&p(m.prev,m,m.next)>=0)return!1;m=m.nextZ}for(m=e.prevZ;m&&m.z>=f;){if(m!==e.prev&&m!==e.next&&_(s.x,s.y,r.x,r.y,n.x,n.y,m.x,m.y)&&p(m.prev,m,m.next)>=0)return!1;m=m.prevZ}return!0}function d(e,t,i){var o=e;do{var s=o.prev,r=o.next.next;g(s,o,o.next,r)&&v(s,r)&&v(r,s)&&(t.push(s.i/i),t.push(o.i/i),t.push(r.i/i),b(o),b(o.next),o=e=r),o=o.next}while(o!==e);return o}function l(e,t,i,o,n,a){var d=e;do{for(var l=d.next.next;l!==d.prev;){if(d.i!==l.i&&m(d,l)){var h=y(d,l);return d=s(d,d.next),h=s(h,h.next),r(d,t,i,o,n,a),void r(h,t,i,o,n,a)}l=l.next}d=d.next}while(d!==e)}function h(e,t){return e.x-t.x}function f(e,t){if(t=function(e,t){var i,o=t,s=e.x,r=e.y,n=-1/0;do{if(r<=o.y&&r>=o.next.y){var a=o.x+(r-o.y)*(o.next.x-o.x)/(o.next.y-o.y);a<=s&&a>n&&(n=a,i=o.x=o.x&&o.x>=i.x&&_(ri.x)&&v(o,e)&&(i=o,h=d),o=o.next;return i}(e,t)){var i=y(t,e);s(i,i.next)}}function u(e,t,i,o,s){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-i)/s)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-o)/s)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function c(e){var t=e,i=e;do{t.x=0&&(e-n)*(o-a)-(i-n)*(t-a)>=0&&(i-n)*(r-a)-(s-n)*(o-a)>=0}function m(e,t){return x(e,t)||e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&g(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&v(e,t)&&v(t,e)&&function(e,t){var i=e,o=!1,s=(e.x+t.x)/2,r=(e.y+t.y)/2;do{i.y>r!=i.next.y>r&&s<(i.next.x-i.x)*(r-i.y)/(i.next.y-i.y)+i.x&&(o=!o),i=i.next}while(i!==e);return o}(e,t)}function p(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function x(e,t){return e.x===t.x&&e.y===t.y}function g(e,t,i,o){return p(e,t,i)>0!=p(e,t,o)>0&&p(i,o,e)>0!=p(i,o,t)>0}function v(e,t){return p(e.prev,e,e.next)<0?p(e,t,e.next)>=0&&p(e,e.prev,t)>=0:p(e,t,e.prev)<0||p(e,e.next,t)<0}function y(e,t){var i=new S(e.i,e.x,e.y),o=new S(t.i,t.x,t.y),s=e.next,r=t.prev;return e.next=t,t.prev=e,i.next=s,s.prev=i,o.next=i,i.prev=o,r.next=o,o.prev=r,o}function T(e,t,i,o){var s=new S(e,t,i);return o?(s.next=o.next,s.prev=o,o.next.prev=s,o.next=s):(s.prev=s,s.next=s),s}function b(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function S(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}}},x3dom.FieldInterpolator=function(e,t,i,o){this.beginTime=e||0,this.endTime=t||1,this.beginValue=i||0,this.endValue=o||0,this.isInterpolating=!1},x3dom.FieldInterpolator.prototype.isActive=function(){return this.beginTime>0},x3dom.FieldInterpolator.prototype.calcFraction=function(e){var t=(e-this.beginTime)/(this.endTime-this.beginTime);return(Math.sin(t*Math.PI-Math.PI/2)+1)/2},x3dom.FieldInterpolator.prototype.reset=function(){this.isInterpolating=!1,this.beginTime=0,this.endTime=1,this.beginValue=0,this.endValue=0},x3dom.FieldInterpolator.prototype.interpolate=function(e){if(e=this.endTime){var t=this.endValue;return this.reset(),t}return this.isInterpolating=!0,this.beginValue+(this.endValue-this.beginValue)*this.calcFraction(e)},x3dom.Utils={},x3dom.Utils.maxIndexableCoords=65535,x3dom.Utils.needLineWidth=!1,x3dom.Utils.measurements=[],window.performance=window.performance||{},performance.now=performance.now||performance.mozNow||performance.msNow||performance.oNow||performance.webkitNow||function(){return(new Date).getTime()},x3dom.Utils.startMeasure=function(e){var t=e.toUpperCase();x3dom.Utils.measurements[t]||(x3dom.Utils.measurements[t]=performance.now())},x3dom.Utils.stopMeasure=function(e){var t=e.toUpperCase();if(x3dom.Utils.measurements[t]){var i=x3dom.Utils.measurements[t];return delete x3dom.Utils.measurements[t],performance.now()-i}return 0},x3dom.Utils.isNumber=function(e){return!isNaN(parseFloat(e))&&isFinite(e)},x3dom.Utils.createTexture2D=function(e,t,i,o,s,r,n,a,d){a=a||!1;var l=e.createTexture(),h=new Uint8Array([0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255]);e.bindTexture(e.TEXTURE_2D,l),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,2,2,0,e.RGBA,e.UNSIGNED_BYTE,h),n&&e.generateMipmap(e.TEXTURE_2D),e.bindTexture(e.TEXTURE_2D,null),l.ready=!1;var f=0;if(null==i||\"\"==i)return l;var u=new Image;switch(s.toLowerCase()){case\"anonymous\":u.crossOrigin=\"anonymous\";break;case\"use-credentials\":u.crossOrigin=\"use-credentials\";break;case\"none\":break;default:x3dom.Utils.forbiddenBySOP(i)&&(u.crossOrigin=\"anonymous\")}var c=function(){if(d&&0===d.getOrigChannelCount()){var e=new XMLHttpRequest;e.open(\"GET\",i),e.onloadstart=function(){e.responseType=\"arraybuffer\"},e.onload=function(){var t=e.getResponseHeader(\"Content-Type\"),i=new Uint8Array(e.response),o=x3dom.Utils.detectChannelCount(i,t);o&&d.setOrigChannelCount(o),u.src=x3dom.Utils.arrayBufferToObjectURL(i,t)},e.onerror=function(){x3dom.debug.logError(\"[Utils|createTexture2D] Can't http request: \"+i),u.src=i},x3dom.RequestManager.addRequest(e)}else u.src=i;t.incrementDownloads()};return c(),u.onload=function(){l.originalWidth=u.width,l.originalHeight=u.height,r&&(u=x3dom.Utils.scaleImage(u)),1!=o&&1!=a||e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!0),e.bindTexture(e.TEXTURE_2D,l),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,u),n&&e.generateMipmap(e.TEXTURE_2D),e.bindTexture(e.TEXTURE_2D,null),1!=o&&1!=a||e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),l.width=u.width,l.height=u.height,l.ready=!0,t.decrementDownloads(),t.needRender=!0},u.onerror=function(o){x3dom.Utils.tryDDSLoading(l,e,t,i,n,a,d).then((function(){t.decrementDownloads(),t.needRender=!0}),(function(){x3dom.debug.logError(\"[Utils|createTexture2D] Can't load Image: \"+i),t.decrementDownloads(),f++,d&&f33779?t.texImage2D(+o,d,i.format.internal,s,r,0,i.format.format,i.format.type,a[d]):(t.compressedTexImage2D(+o,d,i.format.internal,s,r,0,a[d]),i.generateMipmaps=!1);i.generateMipmaps&&t.generateMipmap(i.type),t.bindTexture(i.type,null),e.width=i.width,e.height=i.height,e.ready=!0,e.textureCubeReady=!0,n&&i.channelCount&&n.setOrigChannelCount(i.channelCount)}}))},x3dom.Utils.createTextureCube=function(e,t,i,o,s,r,n,a){var d,l=new Uint8Array([0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255]),h=e.createTexture();d=o?[e.TEXTURE_CUBE_MAP_POSITIVE_Z,e.TEXTURE_CUBE_MAP_NEGATIVE_Z,e.TEXTURE_CUBE_MAP_POSITIVE_Y,e.TEXTURE_CUBE_MAP_NEGATIVE_Y,e.TEXTURE_CUBE_MAP_POSITIVE_X,e.TEXTURE_CUBE_MAP_NEGATIVE_X]:[e.TEXTURE_CUBE_MAP_NEGATIVE_Z,e.TEXTURE_CUBE_MAP_POSITIVE_Z,e.TEXTURE_CUBE_MAP_NEGATIVE_Y,e.TEXTURE_CUBE_MAP_POSITIVE_Y,e.TEXTURE_CUBE_MAP_NEGATIVE_X,e.TEXTURE_CUBE_MAP_POSITIVE_X],h.ready=!1,h.pendingTextureLoads=-1,h.textureCubeReady=!1;for(var f=0,u=0,c=0;ce.byteLength)return;if(s>=7&&(192==o||194==o))return e[t+7];t+=s}}else t+=1},x3dom.Utils.detectChannelCountPNG=function(e){if(!(e.byteLength<29)&&137==e[0]&&80==e[1]&&78==e[2]&&71==e[3]&&13==e[4]&&10==e[5]&&26==e[6]&&10==e[7]&&73==e[12]&&72==e[13]&&68==e[14]&&82==e[15])return 0==e[25]?1:2==e[25]?3:4==e[25]?2:6==e[25]?4:void 0},x3dom.Utils.detectChannelCountGIF=function(e){if(71==e[0]&&73==e[1]&&70==e[2]&&56==e[3]&&(55==e[4]||57==e[4])&&97==e[5]&&1&e[10]){for(var t=224&e[10],i=13;i-1?e.substr(e.lastIndexOf(\"/\")+1):e.lastIndexOf(\"\\\\\")>-1?e.substr(e.lastIndexOf(\"\\\\\")+1):e},x3dom.Utils.isWebGL2Enabled=function(){var e=document.createElement(\"canvas\");return!!(e.getContext(\"webgl2\")||e.getContext(\"experimental-webgl2\"))},x3dom.Utils.findTextureByName=function(e,t){for(var i=0;i>t;return e+1},x3dom.Utils.nextBestPowerOfTwo=function(e){var t=Math.log(e)/.693147180559945;return Math.pow(2,Math.round(t))},x3dom.Utils.getDataTypeSize=function(e){switch(e){case\"Int8\":case\"Uint8\":return 1;case\"Int16\":case\"Uint16\":return 2;case\"Int32\":case\"Uint32\":case\"Float32\":return 4;case\"Float64\":default:return 8}},x3dom.Utils.getOffsetMultiplier=function(e,t){switch(e){case t.UNSIGNED_SHORT:return 1;case t.UNSIGNED_INT:return 2;case t.UNSIGNED_BYTE:return.5;default:return 1}},x3dom.Utils.getByteAwareOffset=function(e,t,i){switch(t){case i.UNSIGNED_SHORT:return 2*e;case i.UNSIGNED_INT:return 4*e;case i.UNSIGNED_BYTE:return e;default:return 2*e}},x3dom.Utils.getVertexAttribType=function(e,t){var i=t.NONE;switch(e){case\"Int8\":i=t.BYTE;break;case\"Uint8\":i=t.UNSIGNED_BYTE;break;case\"Int16\":i=t.SHORT;break;case\"Uint16\":i=t.UNSIGNED_SHORT;break;case\"Int32\":i=t.INT;break;case\"Uint32\":i=t.UNSIGNED_INT;break;case\"Float32\":i=t.FLOAT;break;case\"Float64\":default:x3dom.debug.logError(\"Can't find this.gl data type for \"+e+\", getting FLOAT...\"),i=t.FLOAT}return i},x3dom.Utils.getArrayBufferView=function(e,t){var i=null;switch(e){case\"Int8\":i=new Int8Array(t);break;case\"Uint8\":i=new Uint8Array(t);break;case\"Int16\":i=new Int16Array(t);break;case\"Uint16\":i=new Uint16Array(t);break;case\"Int32\":i=new Int32Array(t);break;case\"Uint32\":i=new Uint32Array(t);break;case\"Float32\":i=new Float32Array(t);break;case\"Float64\":i=new Float64Array(t);break;default:x3dom.debug.logError(\"Can't create typed array view of type \"+e+\", trying Float32...\"),i=new Float32Array(t)}return i},x3dom.Utils.isUnsignedType=function(e){return\"Uint8\"==e||\"Uint16\"==e||\"Uint16\"==e||\"Uint32\"==e},x3dom.Utils.checkDirtyLighting=function(e){return e.getLights().length+e._scene.getNavigationInfo()._vf.headlight+(e._scene.getFog()._vf.visibilityRange>0)},x3dom.Utils.checkDirtyPhysicalEnvironmentLight=function(e,t){return!!t.PHYSICALENVLIGHT!=e.hasPhysicalEnvironmentLight()},x3dom.Utils.checkDirtyEnvironment=function(e,t){var i=e._scene.getEnvironment();return t.GAMMACORRECTION!=i._vf.gammaCorrectionDefault},x3dom.Utils.minFilterDic=function(e,t){switch(t.toUpperCase()){case\"NEAREST\":return e.NEAREST;case\"LINEAR\":return e.LINEAR;case\"NEAREST_MIPMAP_NEAREST\":return e.NEAREST_MIPMAP_NEAREST;case\"NEAREST_MIPMAP_LINEAR\":return e.NEAREST_MIPMAP_LINEAR;case\"LINEAR_MIPMAP_NEAREST\":return e.LINEAR_MIPMAP_NEAREST;case\"LINEAR_MIPMAP_LINEAR\":return e.LINEAR_MIPMAP_LINEAR;case\"AVG_PIXEL\":return e.LINEAR;case\"AVG_PIXEL_AVG_MIPMAP\":return e.LINEAR_MIPMAP_LINEAR;case\"AVG_PIXEL_NEAREST_MIPMAP\":return e.LINEAR_MIPMAP_NEAREST;case\"DEFAULT\":return e.LINEAR_MIPMAP_LINEAR;case\"FASTEST\":case\"NEAREST_PIXEL\":return e.NEAREST;case\"NEAREST_PIXEL_AVG_MIPMAP\":return e.NEAREST_MIPMAP_LINEAR;case\"NEAREST_PIXEL_NEAREST_MIPMAP\":return e.NEAREST_MIPMAP_NEAREST;case\"NICEST\":return e.LINEAR_MIPMAP_LINEAR;default:return e.LINEAR}},x3dom.Utils.minFilterDicX3D=function(e){switch(e){case 9728:return\"NEAREST\";case 9729:return\"LINEAR\";case 9984:return\"NEAREST_MIPMAP_NEAREST\";case 9985:return\"LINEAR_MIPMAP_NEAREST\";case 9986:return\"NEAREST_MIPMAP_LINEAR\";case 9987:default:return\"LINEAR_MIPMAP_LINEAR\"}},x3dom.Utils.magFilterDic=function(e,t){switch(t.toUpperCase()){case\"NEAREST\":return e.NEAREST;case\"LINEAR\":case\"AVG_PIXEL\":case\"DEFAULT\":return e.LINEAR;case\"FASTEST\":case\"NEAREST_PIXEL\":return e.NEAREST;case\"NICEST\":default:return e.LINEAR}},x3dom.Utils.magFilterDicX3D=function(e){switch(e){case 9728:return\"NEAREST\";case 9729:default:return\"LINEAR\"}},x3dom.Utils.boundaryModesDicX3D=function(e){switch(e){case 10497:return\"REPEAT\";case 33071:return\"CLAMP_TO_EDGE\";case 33648:return\"MIRRORED_REPEAT\";default:return\"REPEAT\"}},x3dom.Utils.boundaryModesDic=function(e,t){switch(t.toUpperCase()){case\"CLAMP\":case\"CLAMP_TO_EDGE\":case\"CLAMP_TO_BOUNDARY\":return e.CLAMP_TO_EDGE;case\"MIRRORED_REPEAT\":return e.MIRRORED_REPEAT;case\"REPEAT\":default:return e.REPEAT}},x3dom.Utils.primTypeDic=function(e,t){switch(t.toUpperCase()){case\"POINTS\":return e.POINTS;case\"LINES\":return e.LINES;case\"LINELOOP\":return e.LINE_LOOP;case\"LINESTRIP\":return e.LINE_STRIP;case\"TRIANGLES\":return e.TRIANGLES;case\"TRIANGLESTRIP\":return e.TRIANGLE_STRIP;case\"TRIANGLEFAN\":return e.TRIANGLE_FAN;default:return e.TRIANGLES}},x3dom.Utils.depthFunc=function(e,t){switch(t.toUpperCase()){case\"NEVER\":return e.NEVER;case\"ALWAYS\":return e.ALWAYS;case\"LESS\":return e.LESS;case\"EQUAL\":return e.EQUAL;case\"LEQUAL\":return e.LEQUAL;case\"GREATER\":return e.GREATER;case\"GEQUAL\":return e.GEQUAL;case\"NOTEQUAL\":return e.NOTEQUAL;default:return e.LEQUAL}},x3dom.Utils.blendFunc=function(e,t){switch(t.toLowerCase()){case\"zero\":return e.ZERO;case\"one\":return e.ONE;case\"dst_color\":return e.DST_COLOR;case\"dst_alpha\":return e.DST_ALPHA;case\"src_color\":return e.SRC_COLOR;case\"src_alpha\":return e.SRC_ALPHA;case\"one_minus_dst_color\":return e.ONE_MINUS_DST_COLOR;case\"one_minus_dst_alpha\":return e.ONE_MINUS_DST_ALPHA;case\"one_minus_src_color\":return e.ONE_MINUS_SRC_COLOR;case\"one_minus_src_alpha\":return e.ONE_MINUS_SRC_ALPHA;case\"src_alpha_saturate\":return e.SRC_ALPHA_SATURATE;case\"constant_color\":return e.CONSTANT_COLOR;case\"constant_alpha\":return e.CONSTANT_ALPHA;case\"one_minus_constant_color\":return e.ONE_MINUS_CONSTANT_COLOR;case\"one_minus_constant_alpha\":return e.ONE_MINUS_CONSTANT_ALPHA;default:return 0}},x3dom.Utils.blendEquation=function(e,t){switch(t.toLowerCase()){case\"func_add\":return e.FUNC_ADD;case\"func_subtract\":return e.FUNC_SUBTRACT;case\"func_reverse_subtract\":return e.FUNC_REVERSE_SUBTRACT;case\"min\":case\"max\":case\"logic_op\":default:return 0}},x3dom.Utils.generateProperties=function(e,t){var i={},o=t._cf.geometry.node,s=t._cf.appearance.node,r=s?s._cf.texture.node:null,n=s?s._cf.material.node:null,a=e._scene.getEnvironment();return s&&s._shader&&x3dom.isa(s._shader,x3dom.nodeTypes.ComposedShader)?i.CSHADER=s._shader._id:o&&(i.CSHADER=-1,i.APPMAT=s&&(n||i.CSSHADER)?1:0,i.SOLID=t.isSolid()?1:0,i.TEXT=x3dom.isa(o,x3dom.nodeTypes.Text)?1:0,i.POPGEOMETRY=x3dom.isa(o,x3dom.nodeTypes.PopGeometry)?1:0,i.BUFFERGEOMETRY=x3dom.isa(o,x3dom.nodeTypes.BufferGeometry)?1:0,i.BINARYGEOMETRY=x3dom.isa(o,x3dom.nodeTypes.BinaryGeometry)?1:0,i.POINTLINE2D=o.needLighting()?0:1,i.VERTEXID=i.BINARYGEOMETRY&&o._vf.idsPerVertex?1:0,i.IS_PARTICLE=x3dom.isa(o,x3dom.nodeTypes.ParticleSet)?1:0,i.POINTPROPERTIES=s&&s._cf.pointProperties.node?1:0,i.TANGENTDATA=o._mesh._tangents[0].length>0&&o._mesh._binormals[0].length>0?1:0,i.PBR_MATERIAL=i.APPMAT&&x3dom.isa(n,x3dom.nodeTypes.PhysicalMaterial)?1:0,i.TWOSIDEDMAT=i.APPMAT&&x3dom.isa(n,x3dom.nodeTypes.TwoSidedMaterial)?1:0,i.SEPARATEBACKMAT=i.TWOSIDEDMAT&&n._vf.separateBackColor?1:0,i.SHADOW=e.getLightsShadow()?1:0,i.FOG=e._scene.getFog()._vf.visibilityRange>0?1:0,i.CSSHADER=s&&s._shader&&x3dom.isa(s._shader,x3dom.nodeTypes.CommonSurfaceShader)?1:0,i.LIGHTS=!i.POINTLINE2D&&s&&t.isLit()&&(n||i.CSSHADER)?e.getLights().length+e._scene.getNavigationInfo()._vf.headlight:0,i.TEXTURED=r||i.TEXT||i.CSSHADER&&s._shader.needTexcoords()||i.PBR_MATERIAL&&n.hasTextures()?1:0,i.CUBEMAP=r&&x3dom.isa(r,x3dom.nodeTypes.X3DEnvironmentTextureNode)||i.CSSHADER&&s._shader.getEnvironmentMap()?1:0,i.PIXELTEX=r&&x3dom.isa(r,x3dom.nodeTypes.PixelTexture)?1:0,i.TEXTRAFO=s&&s._cf.textureTransform.node?1:0,i.DIFFUSEMAP=r&&!x3dom.isa(r,x3dom.nodeTypes.X3DEnvironmentTextureNode)||i.CSSHADER&&s._shader.getDiffuseMap()||i.PBR_MATERIAL&&n._cf.baseColorTexture.node?1:0,i.NORMALMAP=i.CSSHADER&&s._shader.getNormalMap()||i.PBR_MATERIAL&&n._cf.normalTexture.node?1:0,i.SPECMAP=i.CSSHADER&&s._shader.getSpecularMap()?1:0,i.SHINMAP=i.CSSHADER&&s._shader.getShininessMap()?1:0,i.EMISSIVEMAP=i.PBR_MATERIAL&&n._cf.emissiveTexture.node?1:0,i.OCCLUSIONMAP=i.PBR_MATERIAL&&n._cf.occlusionTexture.node?1:0,i.DISPLACEMENTMAP=i.CSSHADER&&s._shader.getDisplacementMap()?1:0,i.DIFFPLACEMENTMAP=i.CSSHADER&&s._shader.getDiffuseDisplacementMap()?1:0,i.ALPHAMODE=i.PBR_MATERIAL?n._vf.alphaMode:\"BLEND\",i.ISROUGHNESSMETALLIC=i.PBR_MATERIAL&&\"roughnessMetallic\"==n._vf.model?1:0,i.ROUGHNESSMETALLICMAP=i.PBR_MATERIAL&&n._cf.roughnessMetallicTexture.node?1:0,i.SPECULARGLOSSINESSMAP=i.PBR_MATERIAL&&n._cf.specularGlossinessTexture.node?1:0,i.OCCLUSIONROUGHNESSMETALLICMAP=i.PBR_MATERIAL&&n._cf.occlusionRoughnessMetallicTexture.node?1:0,i.PHYSICALENVLIGHT=e.hasPhysicalEnvironmentLight()?1:0,i.NORMALSPACE=i.NORMALMAP&&i.CSSHADER?s._shader._vf.normalSpace.toUpperCase():i.NORMALMAP&&i.PBR_MATERIAL?n._vf.normalSpace.toUpperCase():\"TANGENT\",i.BLENDING=i.TEXT||i.CUBEMAP||i.CSSHADER||i.PBR_MATERIAL||r&&r._blending?1:0,i.REQUIREBBOX=void 0!==o._vf.coordType&&\"Float32\"!=o._vf.coordType?1:0,i.REQUIREBBOXNOR=void 0!==o._vf.normalType&&\"Float32\"!=o._vf.normalType?1:0,i.REQUIREBBOXCOL=void 0!==o._vf.colorType&&\"Float32\"!=o._vf.colorType?1:0,i.REQUIREBBOXTEX=void 0!==o._vf.texCoordType&&\"Float32\"!=o._vf.texCoordType?1:0,i.COLCOMPONENTS=o._mesh._numColComponents,i.NORCOMPONENTS=o._mesh._numNormComponents,i.POSCOMPONENTS=o._mesh._numPosComponents,i.SPHEREMAPPING=void 0!==o._cf.texCoord&&null!==o._cf.texCoord.node&&o._cf.texCoord.node._vf.mode&&\"sphere\"==o._cf.texCoord.node._vf.mode.toLowerCase()?1:0,i.VERTEXCOLOR=o._mesh._colors[0].length>0||i.POPGEOMETRY&&o.hasColor()||i.BUFFERGEOMETRY&&o.hasColor()||void 0!==o._vf.color&&o._vf.color.length>0?1:0,i.CLIPPLANES=t._clipPlanes.length,i.ALPHATHRESHOLD=s?s._vf.alphaClipThreshold.toFixed(2):.1,i.MULTITEXCOORD=i.BUFFERGEOMETRY&&o.hasMultiTexCoord()?1:0,i.DIFFUSEMAPCHANNEL=i.PBR_MATERIAL&&i.DIFFUSEMAP&&1===n._cf.baseColorTexture.node._vf.channel?1:0,i.NORMALMAPCHANNEL=i.PBR_MATERIAL&&i.NORMALMAP&&1===n._cf.normalTexture.node._vf.channel?1:0,i.EMISSIVEMAPCHANNEL=i.PBR_MATERIAL&&i.EMISSIVEMAP&&1===n._cf.emissiveTexture.node._vf.channel?1:0,i.OCCLUSIONMAPCHANNEL=i.PBR_MATERIAL&&i.OCCLUSIONMAP&&1===n._cf.occlusionTexture.node._vf.channel?1:0,i.ROUGHNESSMETALLICMAPCHANNEL=i.PBR_MATERIAL&&i.ROUGHNESSMETALLICMAP&&1===n._cf.roughnessMetallicTexture.node._vf.channel?1:0,i.OCCLUSIONROUGHNESSMETALLICMAPCHANNEL=i.PBR_MATERIAL&&i.OCCLUSIONROUGHNESSMETALLICMAP&&1===n._cf.occlusionRoughnessMetallicTexture.node._vf.channel?1:0,i.SPECULARGLOSSINESSMAPCHANNEL=i.PBR_MATERIAL&&i.SPECULARGLOSSINESSMAP&&1===n._cf.specularGlossinessTexture.node._vf.channel?1:0,i.ALPHAMASK=i.PBR_MATERIAL&&\"MASK\"==n._vf.alphaMode?1:0,i.UNLIT=i.PBR_MATERIAL&&n._vf.unlit?1:0,i.GAMMACORRECTION=a._vf.gammaCorrectionDefault,i.KHR_MATERIAL_COMMONS=0),i.toIdentifier=function(){delete this.id;var e=\"\";for(var t in this)this[t]!=this.toIdentifier&&this[t]!=this.toString&&(e+=this[t]);return this.id=e,e},i.toString=function(){var e=\"\";for(var t in this)this[t]!=this.toIdentifier&&this[t]!=this.toString&&(e+=t+\": \"+this[t]+\", \");return e},i.toIdentifier(),i},x3dom.Utils.lerp=function(e,t,i){return e+(t-e)*(i=(i=i<0?0:i)>1?1:i)},x3dom.Utils.wrapProgram=function(e,t,i){var o,s,r={shaderID:i,program:t,bind:function(){e.useProgram(t)}},n=null,a=null,d=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(o=0;o>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(n);break;case 12:case 13:a=e[s++],o+=String.fromCharCode((31&n)<<6|63&a);break;case 14:a=e[s++],d=e[s++],o+=String.fromCharCode((15&n)<<12|(63&a)<<6|(63&d)<<0)}return JSON.parse(o)},x3dom.Utils.arrayBufferToObjectURL=function(e,t){return URL.createObjectURL(new Blob([new Uint8Array(e)],{type:t}))},x3dom.Utils.dataURIToObjectURL=function(e){if(-1==e.indexOf(\"data:\"))return e;for(var t=e.split(\",\"),i=t[0].split(\":\")[1].split(\";\")[0],o=t[1],s=window.atob(o),r=s.length,n=new Uint8Array(r),a=0;at||(e=e>1?1:e,t=t>1?1:t,this.states.depthRange.zNear==e&&this.states.depthRange.zFar==t||(this.gl.depthRange(e,t),this.states.depthRange.zNear=e,this.states.depthRange.zFar=t))},x3dom.StateManager.prototype.viewport=function(e,t,i,o){this.states.viewport.x==e&&this.states.viewport.y==t&&this.states.viewport.width==i&&this.states.viewport.height==o||(this.gl.viewport(e,t,i,o),this.states.viewport.x=e,this.states.viewport.y=t,this.states.viewport.width=i,this.states.viewport.height=o)},x3dom.StateManager.prototype.bindFramebuffer=function(e,t){this.gl.bindFramebuffer(e,t),this.initStates()},x3dom.BinaryContainerLoader={outOfMemory:!1,checkError:function(e){var t=e.getError();t&&(t==e.OUT_OF_MEMORY?(this.outOfMemory=!0,x3dom.debug.logError(\"GL-Error \"+t+\" on loading binary container (out of memory).\"),console.error(\"WebGL: OUT_OF_MEMORY\")):x3dom.debug.logError(\"GL-Error \"+t+\" on loading binary container.\"))}},x3dom.BinaryContainerLoader.setupBinGeo=function(e,t,i,o,s){if(!this.outOfMemory){var r=(new Date).getTime(),n=this,a=e._cf.geometry.node;e._webgl.binaryGeometry=-1,e._webgl.internalDownloadCount=(a._vf.index.length>0?1:0)+(a._hasStrideOffset&&a._vf.coord.length>0?1:0)+(!a._hasStrideOffset&&a._vf.coord.length>0?1:0)+(!a._hasStrideOffset&&a._vf.normal.length>0?1:0)+(!a._hasStrideOffset&&a._vf.texCoord.length>0?1:0)+(!a._hasStrideOffset&&a._vf.color.length>0?1:0);var d=0==a._vf.normalPerVertex||a._vf.index.length>0&&(\"Int32\"==a._vf.indexType||\"Uint32\"==a._vf.indexType&&!x3dom.caps.INDEX_UINT);if(e._webgl.makeSeparateTris={index:null,coord:null,normal:null,texCoord:null,color:null,pushBuffer:function(t,i){this[t]=i,0==--e._webgl.internalDownloadCount&&(this.coord&&this.createMesh(),e._nameSpace.doc.needRender=!0),0==--e._nameSpace.doc.downloadCount&&(e._nameSpace.doc.needRender=!0)},createMesh:function(){var r=a;if(r._hasStrideOffset)x3dom.debug.logError(r._vf.indexType+\" index type and per-face normals not supported for interleaved arrays.\");else{for(var d=0;d3&&x.push(this.coord[m+3]),this.color&&(y.push(this.color[m]),y.push(this.color[m+1]),y.push(this.color[m+2]),u>3&&y.push(this.color[m+3])),this.texCoord&&(p=c*(this.index?this.index[_]:_),v.push(this.texCoord[p]),v.push(this.texCoord[p+1]),c>3&&(v.push(this.texCoord[p+2]),v.push(this.texCoord[p+3]))),m=u*(this.index?this.index[_+1]:_+1);var S=new x3dom.fields.SFVec3f(l.x*this.coord[m]/h,l.y*this.coord[m+1]/h,l.z*this.coord[m+2]/h);x.push(this.coord[m]),x.push(this.coord[m+1]),x.push(this.coord[m+2]),u>3&&x.push(this.coord[m+3]),this.color&&(y.push(this.color[m]),y.push(this.color[m+1]),y.push(this.color[m+2]),u>3&&y.push(this.color[m+3])),this.texCoord&&(p=c*(this.index?this.index[_+1]:_+1),v.push(this.texCoord[p]),v.push(this.texCoord[p+1]),c>3&&(v.push(this.texCoord[p+2]),v.push(this.texCoord[p+3]))),m=u*(this.index?this.index[_+2]:_+2);var F=new x3dom.fields.SFVec3f(l.x*this.coord[m]/h,l.y*this.coord[m+1]/h,l.z*this.coord[m+2]/h);x.push(this.coord[m]),x.push(this.coord[m+1]),x.push(this.coord[m+2]),u>3&&x.push(this.coord[m+3]),this.color&&(y.push(this.color[m]),y.push(this.color[m+1]),y.push(this.color[m+2]),u>3&&y.push(this.color[m+3])),this.texCoord&&(p=c*(this.index?this.index[_+2]:_+2),v.push(this.texCoord[p]),v.push(this.texCoord[p+1]),c>3&&(v.push(this.texCoord[p+2]),v.push(this.texCoord[p+3])));var E=b.subtract(S),M=S.subtract(F),C=E.cross(M).normalize();for(m=0;m<3;m++)g.push(C.x),g.push(C.y),g.push(C.z)}var A=i.createBuffer();e._webgl.buffers[x3dom.BUFFER_IDX.POSITION]=A,i.bindBuffer(i.ARRAY_BUFFER,A),i.bufferData(i.ARRAY_BUFFER,x3dom.Utils.getArrayBufferView(r._vf.coordType,x),i.STATIC_DRAW),i.vertexAttribPointer(t.position,r._mesh._numPosComponents,e._webgl.coordType,!1,e._coordStrideOffset[0],e._coordStrideOffset[1]),i.enableVertexAttribArray(t.position),A=i.createBuffer(),e._webgl.buffers[x3dom.BUFFER_IDX.NORMAL]=A,i.bindBuffer(i.ARRAY_BUFFER,A),i.bufferData(i.ARRAY_BUFFER,new Float32Array(g),i.STATIC_DRAW),i.vertexAttribPointer(t.normal,r._mesh._numNormComponents,e._webgl.normalType,!1,e._normalStrideOffset[0],e._normalStrideOffset[1]),i.enableVertexAttribArray(t.normal),this.texCoord&&(A=i.createBuffer(),e._webgl.buffers[x3dom.BUFFER_IDX.TEXCOORD]=A,i.bindBuffer(i.ARRAY_BUFFER,A),i.bufferData(i.ARRAY_BUFFER,x3dom.Utils.getArrayBufferView(r._vf.texCoordType,v),i.STATIC_DRAW),i.vertexAttribPointer(t.texcoord,r._mesh._numTexComponents,e._webgl.texCoordType,!1,e._texCoordStrideOffset[0],e._texCoordStrideOffset[1]),i.enableVertexAttribArray(t.texcoord)),this.color&&(A=i.createBuffer(),e._webgl.buffers[x3dom.BUFFER_IDX.COLOR]=A,i.bindBuffer(i.ARRAY_BUFFER,A),i.bufferData(i.ARRAY_BUFFER,x3dom.Utils.getArrayBufferView(r._vf.colorType,y),i.STATIC_DRAW),i.vertexAttribPointer(t.color,r._mesh._numColComponents,e._webgl.colorType,!1,e._colorStrideOffset[0],e._colorStrideOffset[1]),i.enableVertexAttribArray(t.color)),r._vf.vertexCount=[],r._vf.vertexCount[0]=x.length/u,r._mesh._numCoords=r._vf.vertexCount[0],r._mesh._numFaces=r._vf.vertexCount[0]/3,e._webgl.primType=[],e._webgl.primType[0]=i.TRIANGLES,x=null,g=null,v=null,y=null,this.index=null,this.coord=null,this.normal=null,this.texCoord=null,this.color=null,n.checkError(i),delete e._webgl.shader,e._webgl.shader=s.cache.getDynamicShader(i,o,e)}}},a._vf.index.length>0){e._webgl.binaryGeometry=1;var l=new XMLHttpRequest;l.open(\"GET\",e._nameSpace.getURL(a._vf.index),!0),l.responseType=\"arraybuffer\",e._nameSpace.doc.incrementDownloads(),x3dom.RequestManager.addRequest(l),l.onload=function(){if(e._nameSpace.doc.decrementDownloads(),e._webgl.internalDownloadCount-=1,200==l.status){if(e._webgl)if(a._vf.compressed)x3dom.debug.logError(\"x3dom 1.8.2+ do not support compressed BinaryGeometries anymore\");else{var t=l.response,o=a,s=o._vf.indexType,h=x3dom.Utils.getArrayBufferView(s,t);if(d)e._webgl.makeSeparateTris.pushBuffer(\"index\",h);else{var f=i.createBuffer();x3dom.caps.INDEX_UINT&&\"Uint32\"==s?e._webgl.indexType=i.UNSIGNED_INT:e._webgl.indexType=i.UNSIGNED_SHORT,i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,f),i.bufferData(i.ELEMENT_ARRAY_BUFFER,h,i.STATIC_DRAW),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,null),0==o._vf.vertexCount[0]&&(o._vf.vertexCount[0]=h.length),o._mesh._numFaces=0;for(var u=0;u0){var h=new XMLHttpRequest;h.open(\"GET\",e._nameSpace.getURL(a._vf.coord),!0),h.responseType=\"arraybuffer\",e._nameSpace.doc.incrementDownloads(),x3dom.RequestManager.addRequest(h),h.onload=function(){if(e._nameSpace.doc.decrementDownloads(),e._webgl.internalDownloadCount-=1,200==h.status){if(e._webgl)if(a._vf.compressed)x3dom.debug.logError(\"x3dom 1.8.2+ do not support compressed BinaryGeometries anymore\");else{var o=h.response,s=a,d=s._vf.coordType;e._webgl.coordType=x3dom.Utils.getVertexAttribType(d,i),e._webgl.normalType=e._webgl.coordType,e._webgl.texCoordType=e._webgl.coordType,e._webgl.colorType=e._webgl.coordType;var l=x3dom.Utils.getArrayBufferView(d,o),f=e._coordStrideOffset[0]/x3dom.Utils.getDataTypeSize(d);if(f&&(s._mesh._numCoords=l.length/f),0==s._vf.index.length)for(var u=0;u0&&(e._webgl.buffers[x3dom.BUFFER_IDX.NORMAL]=c,i.bindBuffer(i.ARRAY_BUFFER,c),i.bufferData(i.ARRAY_BUFFER,l,i.STATIC_DRAW),i.vertexAttribPointer(t.normal,s._mesh._numNormComponents,e._webgl.normalType,!1,e._normalStrideOffset[0],e._normalStrideOffset[1]),i.enableVertexAttribArray(t.normal)),s._vf.texCoord.length>0&&(e._webgl.buffers[x3dom.BUFFER_IDX.TEXCOORD]=c,i.bindBuffer(i.ARRAY_BUFFER,c),i.bufferData(i.ARRAY_BUFFER,l,i.STATIC_DRAW),i.vertexAttribPointer(t.texcoord,s._mesh._numTexComponents,e._webgl.texCoordType,!1,e._texCoordStrideOffset[0],e._texCoordStrideOffset[1]),i.enableVertexAttribArray(t.texcoord)),s._vf.color.length>0&&(e._webgl.buffers[x3dom.BUFFER_IDX.COLOR]=c,i.bindBuffer(i.ARRAY_BUFFER,c),i.bufferData(i.ARRAY_BUFFER,l,i.STATIC_DRAW),i.vertexAttribPointer(t.color,s._mesh._numColComponents,e._webgl.colorType,!1,e._colorStrideOffset[0],e._colorStrideOffset[1]),i.enableVertexAttribArray(t.color)),l=null,0==e._webgl.internalDownloadCount&&(e._nameSpace.doc.needRender=!0),n.checkError(i);var _=(new Date).getTime()-r;x3dom.debug.logInfo(\"XHR/ interleaved array load time: \"+_+\" ms\"),e._webgl.buffers[x3dom.BUFFER_IDX.POSITION]=c}}else x3dom.debug.logError(\"XHR1/ interleaved array load failed with status: \"+h.status)}}if(!a._hasStrideOffset&&a._vf.coord.length>0){var f=new XMLHttpRequest;f.open(\"GET\",e._nameSpace.getURL(a._vf.coord),!0),f.responseType=\"arraybuffer\",e._nameSpace.doc.incrementDownloads(),x3dom.RequestManager.addRequest(f),f.onload=function(){if(e._nameSpace.doc.decrementDownloads(),e._webgl.internalDownloadCount-=1,200==f.status){if(e._webgl)if(a._vf.compressed)x3dom.debug.logError(\"x3dom 1.8.2+ do not support compressed BinaryGeometries anymore\");else{var o=f.response,s=a,l=0,h=s._vf.coordType;e._webgl.coordType=x3dom.Utils.getVertexAttribType(h,i);var u=x3dom.Utils.getArrayBufferView(h,o);if(d)e._webgl.makeSeparateTris.pushBuffer(\"coord\",u);else{i.bindAttribLocation(t.program,0,\"position\");var c=i.createBuffer();if(i.bindBuffer(i.ARRAY_BUFFER,c),i.bufferData(i.ARRAY_BUFFER,u,i.STATIC_DRAW),i.bindBuffer(i.ARRAY_BUFFER,null),s._mesh._numCoords=u.length/s._mesh._numPosComponents,0==s._vf.index.length)for(l=0;lu[l+0]&&(_.x=u[l+0]),_.y>u[l+1]&&(_.y=u[l+1]),_.z>u[l+2]&&(_.z=u[l+2]),m.x0){var u=new XMLHttpRequest;u.open(\"GET\",e._nameSpace.getURL(a._vf.normal),!0),u.responseType=\"arraybuffer\",e._nameSpace.doc.incrementDownloads(),x3dom.RequestManager.addRequest(u),u.onload=function(){if(e._nameSpace.doc.decrementDownloads(),e._webgl.internalDownloadCount-=1,200==u.status){if(e._webgl)if(a._vf.compressed)x3dom.debug.logError(\"x3dom 1.8.2+ do not support compressed BinaryGeometries anymore\");else{var t=u.response,o=a._vf.normalType;e._webgl.normalType=x3dom.Utils.getVertexAttribType(o,i);var s=x3dom.Utils.getArrayBufferView(o,t);if(d)e._webgl.makeSeparateTris.pushBuffer(\"normal\",s);else{var l=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,l),i.bufferData(i.ARRAY_BUFFER,s,i.STATIC_DRAW),i.bindBuffer(i.ARRAY_BUFFER,null),s=null,0==e._webgl.internalDownloadCount&&(e._nameSpace.doc.needRender=!0),n.checkError(i);var h=(new Date).getTime()-r;x3dom.debug.logInfo(\"XHR2/ normal load time: \"+h+\" ms\"),e._webgl.buffers[x3dom.BUFFER_IDX.NORMAL]=l}}}else x3dom.debug.logError(\"XHR2/ normal load failed with status: \"+u.status)}}if(!a._hasStrideOffset&&a._vf.texCoord.length>0){var c=new XMLHttpRequest;c.open(\"GET\",e._nameSpace.getURL(a._vf.texCoord),!0),c.responseType=\"arraybuffer\",e._nameSpace.doc.incrementDownloads(),x3dom.RequestManager.addRequest(c),c.onload=function(){var t,o;if(e._nameSpace.doc.decrementDownloads(),e._webgl.internalDownloadCount-=1,200==c.status){if(e._webgl)if(a._vf.compressed)x3dom.debug.logError(\"x3dom 1.8.2+ do not support compressed BinaryGeometries anymore\");else{var s=c.response,l=a._vf.texCoordType;e._webgl.texCoordType=x3dom.Utils.getVertexAttribType(l,i);var h=x3dom.Utils.getArrayBufferView(l,s);if(d)e._webgl.makeSeparateTris.pushBuffer(\"texCoord\",h);else{if(a._vf.idsPerVertex){var f=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,f);var u=x3dom.Utils.getArrayBufferView(\"Float32\",h.length/2);for(t=0,o=0;t0){var _=new XMLHttpRequest;_.open(\"GET\",e._nameSpace.getURL(a._vf.color),!0),_.responseType=\"arraybuffer\",e._nameSpace.doc.incrementDownloads(),x3dom.RequestManager.addRequest(_),_.onload=function(){if(e._nameSpace.doc.decrementDownloads(),e._webgl.internalDownloadCount-=1,200==_.status){if(e._webgl)if(a._vf.compressed)x3dom.debug.logError(\"x3dom 1.8.2+ do not support compressed BinaryGeometries anymore\");else{var t=_.response,o=a._vf.colorType;e._webgl.colorType=x3dom.Utils.getVertexAttribType(o,i);var s=x3dom.Utils.getArrayBufferView(o,t);if(d)e._webgl.makeSeparateTris.pushBuffer(\"color\",s);else{var l=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,l),i.bufferData(i.ARRAY_BUFFER,s,i.STATIC_DRAW),i.bindBuffer(i.ARRAY_BUFFER,null),s=null,0==e._webgl.internalDownloadCount&&(e._nameSpace.doc.needRender=!0),n.checkError(i);var h=(new Date).getTime()-r;x3dom.debug.logInfo(\"XHR4/ color load time: \"+h+\" ms\"),e._webgl.buffers[x3dom.BUFFER_IDX.COLOR]=l}}}else x3dom.debug.logError(\"XHR4/ color load failed with status: \"+_.status)}}if(!a._hasStrideOffset&&a._vf.tangent.length>0){var m=new XMLHttpRequest;m.open(\"GET\",e._nameSpace.getURL(a._vf.normal),!0),m.responseType=\"arraybuffer\",e._nameSpace.doc.incrementDownloads(),x3dom.RequestManager.addRequest(m),m.onload=function(){if(e._nameSpace.doc.decrementDownloads(),e._webgl.internalDownloadCount-=1,200==m.status){if(e._webgl)if(a._vf.compressed)x3dom.debug.logError(\"x3dom 1.8.2+ do not support compressed BinaryGeometries anymore\");else{var t=m.response,o=a._vf.tangentType;e._webgl.tangentType=x3dom.Utils.getVertexAttribType(o,i);var s=x3dom.Utils.getArrayBufferView(o,t);if(d)e._webgl.makeSeparateTris.pushBuffer(\"tangent\",s);else{var l=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,l),i.bufferData(i.ARRAY_BUFFER,s,i.STATIC_DRAW),i.bindBuffer(i.ARRAY_BUFFER,null),s=null,0==e._webgl.internalDownloadCount&&(e._nameSpace.doc.needRender=!0),n.checkError(i);var h=(new Date).getTime()-r;x3dom.debug.logInfo(\"XHR5/ normal load time: \"+h+\" ms\"),e._webgl.buffers[x3dom.BUFFER_IDX.TANGENT]=l}}}else x3dom.debug.logError(\"XHR2/ normal load failed with status: \"+m.status)}}if(!a._hasStrideOffset&&a._vf.binormal.length>0){var p=new XMLHttpRequest;p.open(\"GET\",e._nameSpace.getURL(a._vf.normal),!0),p.responseType=\"arraybuffer\",e._nameSpace.doc.incrementDownloads(),x3dom.RequestManager.addRequest(p),p.onload=function(){if(e._nameSpace.doc.decrementDownloads(),e._webgl.internalDownloadCount-=1,200==p.status){if(e._webgl)if(a._vf.compressed)x3dom.debug.logError(\"x3dom 1.8.2+ do not support compressed BinaryGeometries anymore\");else{var t=p.response,o=a._vf.binormalType;e._webgl.binormalType=x3dom.Utils.getVertexAttribType(o,i);var s=x3dom.Utils.getArrayBufferView(o,t);if(d)e._webgl.makeSeparateTris.pushBuffer(\"binormal\",s);else{var l=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,l),i.bufferData(i.ARRAY_BUFFER,s,i.STATIC_DRAW),i.bindBuffer(i.ARRAY_BUFFER,null),s=null,0==e._webgl.internalDownloadCount&&(e._nameSpace.doc.needRender=!0),n.checkError(i);var h=(new Date).getTime()-r;x3dom.debug.logInfo(\"XHR6/ normal load time: \"+h+\" ms\"),e._webgl.buffers[x3dom.BUFFER_IDX.BITANGENT]=l}}}else x3dom.debug.logError(\"XHR6/ normal load failed with status: \"+p.status)}}}},x3dom.BinaryContainerLoader.setupPopGeo=function(e,t,i,o,s){if(!this.outOfMemory){var r=e._cf.geometry.node;if(r.hasIndex()){e._webgl.popGeometry=1,e._webgl.buffers[x3dom.BUFFER_IDX.INDEX]=i.createBuffer(),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e._webgl.buffers[x3dom.BUFFER_IDX.INDEX]),i.bufferData(i.ELEMENT_ARRAY_BUFFER,2*r.getTotalNumberOfIndices(),i.STATIC_DRAW),e._webgl.buffers[x3dom.BUFFER_IDX.ID]=i.createBuffer();var n=new Float32Array(r._vf.vertexBufferSize);!function(){for(var e=0;e0){n=!0;var a=new Uint8Array(t,0,s);i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e._webgl.buffers[x3dom.BUFFER_IDX.INDEX]),function(){for(var e=0,t=0;t0){n=!0;var l=new Uint8Array(t,s,d);i.bindBuffer(i.ARRAY_BUFFER,e._webgl.buffers[x3dom.BUFFER_IDX.POSITION]),r.hasIndex()?i.bufferSubData(i.ARRAY_BUFFER,r.getVertexDataBufferOffset(o)*r.getAttributeStride(),l):i.bufferSubData(i.ARRAY_BUFFER,e._webgl.currentNumVertices*r.getAttributeStride(),l),e._webgl.numVerticesAtLevel[o]=d/r.getAttributeStride(),e._webgl.currentNumVertices+=e._webgl.numVerticesAtLevel[o]}!function(){for(var t=0,i=e._webgl.levelsAvailable;i-1&&o.shapes.splice(r,1),o.shapes.length>0||i.call(this,e,t)}}(x3dom.BinaryContainerLoader.bufferGeoCache[n]),f&&u.destroy(_),x3dom.BinaryContainerLoader.bufferGeoCache[n].decrementDownload&&(x3dom.BinaryContainerLoader.bufferGeoCache[n].decrementDownload=!1,e._nameSpace.doc.decrementDownloads(),e._nameSpace.doc.needRender=!0)}else x3dom.BinaryContainerLoader.bufferGeoCache[n]=void 0})).catch((function(){x3dom.BinaryContainerLoader.bufferGeoCache[n].decrementDownload&&(x3dom.BinaryContainerLoader.bufferGeoCache[n].decrementDownload=!1,e._nameSpace.doc.decrementDownloads())})))},x3dom.BinaryContainerLoader.setupBufferInterpolator=function(e){var t=function(e,t,i){for(var o=e._cf.views.nodes[t._vf.view],s=t._vf.byteOffset+o._vf.byteOffset,r=t._vf.count*t._vf.components,n=t._vf.componentType,a=x3dom.BinaryContainerLoader.getArrayBufferFromType(n,i,s,r),d=0,l=a.length;d0&&i._lowPriorityThreshold<1,this.sortTrans=e.sortTrans,this.prioLevels=10,this.maxTreshold=100,this.sortBySortKey=!1,this.sortByPriority=!1,this.numberOfNodes=0,this.length=0},x3dom.DrawableCollection.prototype.cull=function(e,t,i,o){var s=t.boundedNode;if(!s||!s.renderFlag())return-1;var r,n=s.getVolume();if(this.frustumCulling&&t.needCulling){if(i&&!t.worldVolume.isValid()?(t.worldVolume.transformFrom(e,n),r=t.worldVolume):o<63&&(this.worldVol.transformFrom(e,n),r=this.worldVol),o<63&&(o=this.viewFrustum.intersect(r,o)),-1==o)return-1}else o=63;if(t.coverage=-1,this.smallFeatureThreshold>0||s.forceUpdateCoverage()){var a=this.viewMatrix.mult(e);t.center=a.multMatrixPnt(n.getCenter());var d=a.multMatrixVec(n.getRadialVec()).length(),l=Math.max(-t.center.z-d,this.near)*this.pixelHeightAtDistOne;if(t.coverage=2*d/l,this.smallFeatureThreshold>0&&t.coverage0)o.zPos=i.center.z;else{var r=t.multMatrixPnt(e.getCenter());r=this.viewMatrix.multMatrixPnt(r),o.zPos=r.z}this.sortBySortKey||0==o.sortKey||(this.sortBySortKey=!0),void 0===this.collection[o.sortType]&&(this.collection[o.sortType]=[]),this.collection[o.sortType].push(o),this.length++,this.context&&this.gl&&this.context.setupShape(this.gl,o,this.viewarea)},x3dom.DrawableCollection.prototype.addDrawable=function(e){e.shaderID=e.shape.getShaderProperties(this.viewarea).id;var t=e.shape._cf.appearance.node;if(e.sortType=t?t._vf.sortType.toLowerCase():\"opaque\",e.sortKey=t?t._vf.sortKey:0,\"transparent\"==e.sortType){var i=e.transform.multMatrixPnt(e.shape.getCenter());i=this.viewMatrix.multMatrixPnt(i),e.zPos=i.z}this.sortBySortKey||0==e.sortKey||(this.sortBySortKey=!0),void 0===this.collection[e.sortType]&&(this.collection[e.sortType]=[]),this.collection[e.sortType].push(e),this.length++,this.context&&this.gl&&this.context.setupShape(this.gl,e,this.viewarea)},x3dom.DrawableCollection.prototype.calculatePriority=function(e){var t=Math.max(0,e.coverage),i=this.prioLevels-1;return t=Math.min(Math.round(t/(this.maxTreshold/i)),i)},x3dom.DrawableCollection.prototype.concat=function(){var e=void 0!==this.collection.opaque?this.collection.opaque:[],t=void 0!==this.collection.transparent?this.collection.transparent:[];this.collection=e.concat(t)},x3dom.DrawableCollection.prototype.get=function(e){return this.collection[e]},x3dom.DrawableCollection.prototype.sort=function(){var e=[],t=[],i=this;void 0!==this.collection.opaque&&(this.sortOpaque&&this.collection.opaque.sort((function(e,t){return e.sortKey!=t.sortKey&&i.sortBySortKey?e.sortKey-t.sortKey:t.priority-e.priority})),e=this.collection.opaque),void 0!==this.collection.transparent&&(this.sortTrans&&this.collection.transparent.sort((function(e,t){return e.sortKey!=t.sortKey&&i.sortBySortKey?e.sortKey-t.sortKey:e.priority!=t.priority&&i.sortByPriority?t.priority-e.priority:e.zPos-t.zPos})),t=this.collection.transparent),this.collection=e.concat(t)},x3dom.DrawableCollection.prototype.forEach=function(e,t){var i,o,s,r;for(t=void 0!==t?Math.min(t,this.prioLevels):this.prioLevels,i=0;i0;--o)if(void 0!==this.collection.opaque[i][o])for(s in this.collection.opaque[i][o])for(r=0;r0;--o)if(void 0!==this.collection.transparent[i][o])for(var n in this.collection.transparent[i][o])for(this.collection.transparent[i][o][n].sort((function(e,t){return e.zPos-t.zPos})),r=0;r0&&4!=o._buttonState){var a=o._gridSize*Math.round(n.x/o._gridSize),d=o._gridSize*Math.round(n.y/o._gridSize),l=o._gridSize*Math.round(n.z/o._gridSize);n=new x3dom.fields.SFVec3f(a,d,l)}o._matrixTrafo?(4==o._buttonState?o._matrixTrafo.setRotate(n):o._matrixTrafo.setTranslate(n),o._moveable.setAttribute(\"matrix\",o._matrixTrafo.toGL().toString())):4==o._buttonState?o._moveable.setAttribute(\"rotation\",n.toAxisAngle().toString()):o._moveable.setAttribute(\"translation\",n.toString()),o._callback&&o._callback(o._moveable,n)}o._lastX=s[0],o._lastY=s[1]}}},x3dom.Moveable.prototype.stop=function(e){for(var t=0,i=this._iMove.length;t1e5&&(r=s=-1),i.setAttribute(\"DEF\",e),i.setAttribute(\"fieldOfView\",o),i.setAttribute(\"zNear\",s),i.setAttribute(\"zFar\",r),i.setAttribute(\"position\",\"0 0 0\"),i},x3dom.glTF2Loader.prototype._generateX3DOrthoViewpoint=function(e,t){var i=document.createElement(\"orthoviewpoint\");this._generateX3DMetadata(t,i);var o=t.xmag||1,s=t.ymag||1,r=t.znear||-1,n=t.zfar||-1,a=[-o,-s,o,s];return i.setAttribute(\"DEF\",e),i.setAttribute(\"fieldOfView\",a),i.setAttribute(\"zNear\",r),i.setAttribute(\"zFar\",n),i.setAttribute(\"position\",\"0 0 0\"),i},x3dom.glTF2Loader.prototype._generateX3DShape=function(e){var t=document.createElement(\"shape\");this._generateX3DMetadata(e,t);var i=null!=e.material?this._gltf.materials[e.material]:{name:\"DEFAULT\"};null==i.name&&(i.name=e.material),t.appendChild(this._generateX3DAppearance(i));var o=null;return e.extensions&&e.extensions.KHR_draco_mesh_compression&&(o=e.extensions.KHR_draco_mesh_compression),o&&!x3dom.DracoDecoderModule?t:(t.appendChild(this._generateX3DBufferGeometry(e,o)),t)},x3dom.glTF2Loader.prototype._generateX3DAppearance=function(e){var t=document.createElement(\"appearance\");return this._generateX3DMetadata(e,t),\"BLEND\"===e.alphaMode?t.setAttribute(\"sortType\",\"transparent\"):t.setAttribute(\"sortType\",\"opaque\"),t.setAttribute(\"alphaClipThreshold\",0),t.appendChild(this._generateX3DPhysicalMaterial(e)),this._textureTransform&&(t.appendChild(this._textureTransform),this._textureTransform=void 0),t},x3dom.glTF2Loader.prototype._generateX3DPhysicalMaterial=function(e){var t=document.createElement(\"physicalmaterial\");if(this._USEorDEF(t,\"glTF_MATERIAL_\"+e.name))return t;var i,o,s=[1,1,1,1],r=e.emissiveFactor||[0,0,0],n=1,a=1,d=e.alphaMode||\"OPAQUE\",l=e.alphaCutoff||.5,h=!0,f=void 0,u=void 0,c=0;if(e.pbrMetallicRoughness?(u=e.pbrMetallicRoughness,f=\"roughnessMetallic\"):e.extensions&&e.extensions.KHR_materials_pbrSpecularGlossiness&&(u=e.extensions.KHR_materials_pbrSpecularGlossiness,f=\"specularGlossiness\"),\"roughnessMetallic\"==f){s=u.baseColorFactor||[1,1,1,1],n=null!=u.metallicFactor?u.metallicFactor:1,a=null!=u.roughnessFactor?u.roughnessFactor:1;u.baseColorTexture&&(c=u.baseColorTexture.texCoord?1:0,i=this._gltf.textures[u.baseColorTexture.index],o=u.baseColorTexture.extensions&&u.baseColorTexture.extensions.KHR_texture_transform?u.baseColorTexture.extensions.KHR_texture_transform:void 0,t.appendChild(this._generateX3DImageTexture(i,\"baseColorTexture\",c,o))),u.metallicRoughnessTexture&&(c=u.metallicRoughnessTexture.texCoord?1:0,i=this._gltf.textures[u.metallicRoughnessTexture.index],o=u.metallicRoughnessTexture.extensions&&u.metallicRoughnessTexture.extensions.KHR_texture_transform?u.metallicRoughnessTexture.extensions.KHR_texture_transform:void 0,e.occlusionTexture&&e.occlusionTexture.index==u.metallicRoughnessTexture.index?(h=!1,t.appendChild(this._generateX3DImageTexture(i,\"occlusionRoughnessMetallicTexture\",c,o))):t.appendChild(this._generateX3DImageTexture(i,\"roughnessMetallicTexture\",c,o))),t.setAttribute(\"baseColorFactor\",s.join(\" \")),t.setAttribute(\"metallicFactor\",n),t.setAttribute(\"roughnessFactor\",a)}else if(\"specularGlossiness\"==f){var _=u.diffuseFactor||[1,1,1,1],m=u.specularFactor||[1,1,1],p=null!=u.glossinessFactor?u.glossinessFactor:1;u.diffuseTexture&&(c=u.diffuseTexture.texCoord?1:0,i=this._gltf.textures[u.diffuseTexture.index],o=u.diffuseTexture.extensions&&u.diffuseTexture.extensions.KHR_texture_transform?u.diffuseTexture.extensions.KHR_texture_transform:void 0,t.appendChild(this._generateX3DImageTexture(i,\"baseColorTexture\",c,o))),u.specularGlossinessTexture&&(c=u.specularGlossinessTexture.texCoord?1:0,i=this._gltf.textures[u.specularGlossinessTexture.index],o=u.specularGlossinessTexture.extensions&&u.specularGlossinessTexture.extensions.KHR_texture_transform?u.specularGlossinessTexture.extensions.KHR_texture_transform:void 0,t.appendChild(this._generateX3DImageTexture(i,\"specularGlossinessTexture\",c,o))),t.setAttribute(\"diffuseFactor\",_.join(\" \")),t.setAttribute(\"specularFactor\",m.join(\" \")),t.setAttribute(\"glossinessFactor\",p)}return e.normalTexture&&(c=e.normalTexture.texCoord?1:0,i=this._gltf.textures[e.normalTexture.index],o=e.normalTexture.extensions&&e.normalTexture.extensions.KHR_texture_transform?e.normalTexture.extensions.KHR_texture_transform:void 0,t.appendChild(this._generateX3DImageTexture(i,\"normalTexture\",c,o))),e.emissiveTexture&&(c=e.emissiveTexture.texCoord?1:0,i=this._gltf.textures[e.emissiveTexture.index],o=e.emissiveTexture.extensions&&e.emissiveTexture.extensions.KHR_texture_transform?e.emissiveTexture.extensions.KHR_texture_transform:void 0,t.appendChild(this._generateX3DImageTexture(i,\"emissiveTexture\",c,o))),e.occlusionTexture&&h&&(c=e.occlusionTexture.texCoord?1:0,i=this._gltf.textures[e.occlusionTexture.index],o=e.occlusionTexture.extensions&&e.occlusionTexture.extensions.KHR_texture_transform?e.occlusionTexture.extensions.KHR_texture_transform:void 0,t.appendChild(this._generateX3DImageTexture(i,\"occlusionTexture\",c,o))),e.extensions&&e.extensions.KHR_materials_unlit&&t.setAttribute(\"unlit\",!0),t.setAttribute(\"emissiveFactor\",r.join(\" \")),t.setAttribute(\"alphaMode\",d),t.setAttribute(\"alphaCutoff\",l),t.setAttribute(\"model\",f),t},x3dom.glTF2Loader.prototype._generateX3DImageTexture=function(e,t,i,o){var s=this._gltf.images[e.source],r=document.createElement(\"imagetexture\");if(this._generateX3DMetadata(e,r),r.setAttribute(\"origChannelCount\",\"2\"),r.setAttribute(\"flipY\",\"true\"),t&&r.setAttribute(\"containerField\",t),null!=s.uri&&r.setAttribute(\"url\",x3dom.Utils.dataURIToObjectURL(s.uri)),null!=e.sampler){var n=this._gltf.samplers[e.sampler];r.appendChild(this._createX3DTextureProperties(n))}return i&&r.setAttribute(\"channel\",\"1\"),o&&(this._textureTransform=this._createX3DTextureTransform(r,o)),r},x3dom.glTF2Loader.prototype._createX3DTextureProperties=function(e){var t=document.createElement(\"textureproperties\");return t.setAttribute(\"boundaryModeS\",x3dom.Utils.boundaryModesDicX3D(e.wrapS)),t.setAttribute(\"boundaryModeT\",x3dom.Utils.boundaryModesDicX3D(e.wrapT)),t.setAttribute(\"magnificationFilter\",x3dom.Utils.magFilterDicX3D(e.magFilter)),t.setAttribute(\"minificationFilter\",x3dom.Utils.minFilterDicX3D(e.minFilter)),(null==e.minFilter||e.minFilter>=9984&&e.minFilter<=9987)&&t.setAttribute(\"generateMipMaps\",\"true\"),t},x3dom.glTF2Loader.prototype._createX3DTextureTransform=function(e,t){var i=document.createElement(\"matrixtexturetransform\"),o=t.offset||[0,0],s=t.rotation||0,r=t.scale||[1,1],n=new x3dom.fields.SFVec3f(-0,-0,0),a=new x3dom.fields.SFVec3f(0,0,0),d=new x3dom.fields.SFVec3f(o[0],o[1],0),l=new x3dom.fields.SFVec3f(r[0],r[1],0),h=x3dom.fields.SFMatrix4f.translation(a.add(d)).mult(x3dom.fields.SFMatrix4f.rotationZ(-1*s)).mult(x3dom.fields.SFMatrix4f.scale(l)).mult(x3dom.fields.SFMatrix4f.translation(n));return i.setAttribute(\"matrix\",h.toString()),t.texCoord&&e.setAttribute(\"channel\",texCoord),i},x3dom.glTF2Loader.prototype._generateX3DBufferGeometry=function(e,t){var i,o,s,r,n=[],a=document.createElement(\"buffergeometry\"),d=this._getCenterAndSize(e);(i=t?x3dom.Utils.dataURIToObjectURL(this._gltf.buffers[this._gltf.bufferViews[t.bufferView].buffer].uri):this._bufferURI(e),a.setAttribute(\"buffer\",i),a.setAttribute(\"position\",d.center.join(\" \")),a.setAttribute(\"size\",d.size.join(\" \")),a.setAttribute(\"vertexCount\",this._getVertexCount(e)),a.setAttribute(\"primType\",this._primitiveType(e.mode)),a.setAttribute(\"draco\",null!==t),null!=e.material)&&(this._gltf.materials[e.material].doubleSided&&a.setAttribute(\"solid\",\"false\"));null!=e.indices&&(r=this._gltf.accessors[e.indices],t?((o=Object.assign({},this._gltf.bufferViews[t.bufferView])).idx=t.bufferView,o.target=34963,s=n.push(o)-1):((o=Object.assign({},this._gltf.bufferViews[r.bufferView])).idx=r.bufferView,o.target=34963,s=n.indexOf(o),null!=o.target&&-1==s&&(s=n.push(o)-1)),a.appendChild(this._generateX3DBufferAccessor(\"INDEX\",r,s)));var l=t?t.attributes:e.attributes;for(var h in l)r=this._gltf.accessors[e.attributes[h]],t?((o=Object.assign({},this._gltf.bufferViews[t.bufferView])).target=34962,o.idx=t.bufferView,o.dracoUniqueId=t.attributes[h],s=n.push(o)-1):((o=Object.assign({},this._gltf.bufferViews[r.bufferView])).target=34962,o.idx=r.bufferView,s=n.indexOf(o),null!=o.target&&-1==s&&(s=n.push(o)-1)),a.appendChild(this._generateX3DBufferAccessor(h,r,s));for(var f=0;f>8&255,e>>16&255,e>>24&255).replace(/[\\x00]/g,\"\")},x3dom.DDSLoader.R8G8B8_To_B8G8R8=function(e){for(var t=new Uint8Array(e.length),i=0;i>15&1,i=e>>10&1023,o=e&Math.pow(2,10)-1;return 0!==i?Math.pow(-1,t)*(1+o/Math.pow(2,10))*Math.pow(2,i-15):0===o?0:Math.pow(-1,t)*o/Math.pow(2,10)*Math.pow(2,-14)},x3dom.DDSLoader.UI16_To_UI8_2=function(e){var t=x3dom.DDSLoader.UI16_To_F16(e);return t/(t+1)},x3dom.DDSLoader.A4R4G4B4_To_A4B4G4R4=function(e){for(var t,i,o,s,r=new Uint16Array(e.length),n=0;n>12&15,i=e[n]>>8&15,o=e[n]>>4&15,s=15&e[n],r[n]=i<<12&o<<8&s<<4&t;return r},x3dom.DDSLoader.A1R5G5B5_To_A1B5G5R5=function(e){for(var t,i,o,s,r=new Uint16Array(e.length),n=0;n>15&1,i=e[n]>>10&31,o=e[n]>>5&95,s=95&e[n],r[n]=i<<11&o<<6&s<<1&t;return r},x3dom.VRControllerManager=function(e){this.leftInline=void 0,this.leftTransform=void 0,this.rightInline=void 0,this.rightTransform=void 0,this.wasPresenting=!1,this.modelsAdded=!1,this._doc=e,this._controllers={\"htc-vive\":{left:\"https://x3dom.org/download/assets/vr/vive.glb\",right:\"https://x3dom.org/download/assets/vr/vive.glb\",scaleFactor:new x3dom.fields.SFVec3f(40,40,40),offset:new x3dom.fields.SFVec3f,axesScale:[1,1]},\"oculus-touch\":{left:\"https://x3dom.org/download/assets/vr/oculus-touch-left.glb\",right:\"https://x3dom.org/download/assets/vr/oculus-touch-right.glb\",scaleFactor:new x3dom.fields.SFVec3f(39.5,39.5,39.5),offset:new x3dom.fields.SFVec3f,axesScale:[1,1]},\"oculus-go\":{left:\"https://x3dom.org/download/assets/vr/oculus-go.glb\",right:\"https://x3dom.org/download/assets/vr/oculus-go.glb\",scaleFactor:new x3dom.fields.SFVec3f(1,1,1),offset:new x3dom.fields.SFVec3f(.2,-.3,-.3),axesScale:[-1,1]}},this._addInlines()},x3dom.VRControllerManager.prototype._addInlines=function(){var e=document.querySelector(\"scene\")||document.querySelector(\"Scene\");e&&(this.leftTransform=document.createElement(\"matrixtransform\"),this.leftInline=document.createElement(\"inline\"),this.rightTransform=document.createElement(\"matrixtransform\"),this.rightInline=document.createElement(\"inline\"),this.leftInline.setAttribute(\"render\",\"false\"),this.rightInline.setAttribute(\"render\",\"false\"),this.leftTransform.appendChild(this.leftInline),this.rightTransform.appendChild(this.rightInline),e.appendChild(this.leftTransform),e.appendChild(this.rightTransform))},x3dom.VRControllerManager.prototype._addControllerModels=function(e){if(!this.modelsAdded){if(e.left){const t=this._getControllerModelURL(e.left.type,\"left\");this.leftInline.setAttribute(\"url\",t)}if(e.right){const t=this._getControllerModelURL(e.right.type,\"right\");this.rightInline.setAttribute(\"url\",t)}this.modelsAdded=!0}},x3dom.VRControllerManager.prototype._getControllerAxesScale=function(e){return void 0===this._controllers[e]?[1,1]:this._controllers[e].axesScale},x3dom.VRControllerManager.prototype._getControllerDirection=function(e){return(e.orientation?x3dom.fields.Quaternion.fromArray(e.orientation):new x3dom.fields.Quaternion).toMatrix().e2()},x3dom.VRControllerManager.prototype._getControllerModelURL=function(e,t){return void 0===this._controllers[e]?\"\":this._controllers[e][t]},x3dom.VRControllerManager.prototype._getControllerOffset=function(e){return void 0===this._controllers[e]?[0,0,0]:this._controllers[e].offset},x3dom.VRControllerManager.prototype._getControllerScaleFactor=function(e){return void 0===this._controllers[e]?[1,1,1]:this._controllers[e].scaleFactor},x3dom.VRControllerManager.prototype.fit=function(e){var t=e._scene._lastMin,i=e._scene._lastMax.subtract(t).multiply(.5).length(),o=e.vrLeftViewMatrix.e2(),s=Math.min(e._width/e._height,1),r=i/Math.tan(.5*Math.PI/2)/s;e._movement=o.multiply(-.001*r)},x3dom.VRControllerManager.prototype.update=function(e,t){t?(this.wasPresenting||(this.leftInline.setAttribute(\"render\",\"true\"),this.rightInline.setAttribute(\"render\",\"true\"),this.fit(e),this.wasPresenting=!0),this._addControllerModels(t.controllers),this._updateMatrices(e,t.controllers),this._updateControllerModels(e,t.controllers)):this.wasPresenting&&(this.leftInline.setAttribute(\"render\",\"false\"),this.rightInline.setAttribute(\"render\",\"false\"),this.wasPresenting=!1)},x3dom.VRControllerManager.prototype._updateMatrices=function(e,t){var i=new x3dom.fields.SFMatrix4f,o=new x3dom.fields.SFMatrix4f,s=[0,0];if(t.left){var r=this._getControllerAxesScale(t.left.type);if(s[0]+=t.left.gamepad.axes[0]*r[0],s[1]+=t.left.gamepad.axes[1]*r[1],t.left.gamepad.buttons[0].pressed){const i=t.left.pose,o=this._getControllerDirection(i),s=this._getViewAreaZoom(e);e._movement=e._movement.add(o.multiply(s))}}if(t.right){r=this._getControllerAxesScale(t.right.type);if(s[0]+=t.right.gamepad.axes[0]*r[0],s[1]+=t.right.gamepad.axes[1]*r[1],t.right.gamepad.buttons[0].pressed){const i=t.right.pose,o=this._getControllerDirection(i),s=this._getViewAreaZoom(e);e._movement=e._movement.add(o.multiply(s))}}var n=5*s[0],a=5*s[1],d=e.vrLeftViewMatrix.e2(),l=e.vrLeftViewMatrix.e0(),h=e._scene._lastMax.subtract(e._scene._lastMin).length();h=h\").replace(/&/g,\"&\");do{o=(i=o).replace(/'([^'\\r\\n]*)\\n([^']*)'/g,\"'$1\\\\n$2'\")}while(o!=i);var s=\"\n", - "
\n", + "
\n", " \n", "\n", "\n", @@ -4927,7 +4953,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -4935,7 +4961,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -4943,7 +4969,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -4951,7 +4977,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -4959,7 +4985,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -4967,7 +4993,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -4975,7 +5001,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -4983,7 +5009,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -4991,7 +5017,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -4999,7 +5025,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -5007,7 +5033,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -5015,7 +5041,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -5023,7 +5049,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -5031,7 +5057,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -5039,7 +5065,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -5047,7 +5073,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -5055,7 +5081,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -5063,7 +5089,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -5071,7 +5097,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -5079,7 +5105,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -5087,7 +5113,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -5095,7 +5121,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -5103,7 +5129,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -5111,7 +5137,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -5119,7 +5145,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -5127,7 +5153,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -5135,7 +5161,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -5143,7 +5169,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -5151,7 +5177,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -5159,7 +5185,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -5167,7 +5193,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -5175,7 +5201,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -5185,1843 +5211,1963 @@ " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", @@ -7049,10 +7195,8 @@ " is interacting in a click-and-drag manner, and toggles the rotation\n", " when the user clicks on the scene\n", "\n", - "This script is modified before use to replace all instances of the string\n", - "\"uid\" with a unique (and variable-name allowable) identifier. This is to\n", - "ensure that the script can be used multiple times on the same page without\n", - "conflicting with itself.\n", + "This script is modified before use to replace the config object with the\n", + "actual configuration.\n", "\n", "See load_atoms.visualise for how exactly this is done.\n", "*/\n", @@ -7061,7 +7205,7 @@ "// and to allow for multiple instances of this script\n", "(function () {\n", " // start of replace me\n", - " const config = {\"id\": \"bhdaefagjcfhcehf\", \"currentlyRotating\": true, \"rotationSpeed\": 0.3};\n", + " const config = {\"id\": \"bhdjgbffbdjgcjaf\", \"currentlyRotating\": true, \"rotationSpeed\": 0.3};\n", "\n", " // ~~~~~~~~\n", " // ROTATION\n", @@ -7128,7 +7272,7 @@ "" ] }, - "execution_count": 9, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -7156,7 +7300,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 14, "metadata": {}, "outputs": [ { @@ -7165,16 +7309,16 @@ "\n", "\n", - "\n", + "\n", " \n", " \n", " \n", " \n", - " 2024-11-01T16:44:52.707537\n", + " 2025-02-15T10:31:54.107492\n", " image/svg+xml\n", " \n", " \n", - " Matplotlib v3.7.5, https://matplotlib.org/\n", + " Matplotlib v3.9.4, https://matplotlib.org/\n", " \n", " \n", " \n", @@ -7186,434 +7330,434 @@ " \n", " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", "\n" @@ -7661,25 +7805,27 @@ "source": [ ".. dropdown:: Details\n", "\n", - " Generating a neighbour list is an expensive operation. In contrast, trimming edges longer than ``model.cutoff`` from an existing neighbour list is relatively cheap, as is checking the extent of changes in a structure's positions and cell.\n", + " Generating a neighbour list is an expensive operation (especially for larger systems). We therefore attempt to minimise the:\n", "\n", - " We therefore attempt to minimise the number of neighbour list generations by using a neighbourlist with a larger cutoff (``model.cutoff + skin``) and checking if the atoms or cell have moved more than ``skin / 2`` Å from their original positions. If this is not the case, we can re-use the existing neighbour list (and ensure we trim edges which are longer than ``model.cutoff``) to save on flops.\n" + " - **number of neighbour list generations**: by using a neighbourlist with a larger cutoff (``model.cutoff + skin``) and checking if the atoms or cell have moved more than ``skin / 2`` Å from their original positions. This check is relatively cheap relative to generating a new neighbour list, and so helps save on flops.\n", + " - **time that each neighbour list generation takes**: we do this by relying on the fantastic [vesin](https://luthaf.fr/vesin/latest/index.html) library to generate neighbour lists by passing down this task to a C++ library.\n" ] }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Skin: 0.00, Duration: 7.44s, Cache hits: 0.0%\n", - "Skin: 0.05, Duration: 7.18s, Cache hits: 5.6%\n", - "Skin: 0.10, Duration: 4.65s, Cache hits: 42.7%\n", - "Skin: 0.20, Duration: 3.16s, Cache hits: 64.1%\n", - "Skin: 0.40, Duration: 1.98s, Cache hits: 81.4%\n" + "Skin: 0.00, Duration: 3.86s, Total time calculating NL: 1789ms, Cache hits: 0.0%\n", + "Skin: 0.05, Duration: 3.71s, Total time calculating NL: 1476ms, Cache hits: 3.2%\n", + "Skin: 0.10, Duration: 3.56s, Total time calculating NL: 1307ms, Cache hits: 15.4%\n", + "Skin: 0.20, Duration: 2.98s, Total time calculating NL: 740ms, Cache hits: 56.5%\n", + "Skin: 0.40, Duration: 2.73s, Total time calculating NL: 396ms, Cache hits: 76.2%\n", + "Skin: 0.80, Duration: 2.62s, Total time calculating NL: 223ms, Cache hits: 89.0%\n" ] }, { @@ -7688,16 +7834,16 @@ "\n", "\n", - "\n", + "\n", " \n", " \n", " \n", " \n", - " 2024-11-01T16:45:17.173090\n", + " 2025-02-15T10:32:23.739295\n", " image/svg+xml\n", " \n", " \n", - " Matplotlib v3.7.5, https://matplotlib.org/\n", + " Matplotlib v3.9.4, https://matplotlib.org/\n", " \n", " \n", " \n", @@ -7709,18 +7855,18 @@ " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", @@ -7728,17 +7874,17 @@ " \n", " \n", " \n", - " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", " \n", - " \n", + " \n", " \n", " \n", - " \n", + " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", - " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", " \n", " \n", - " \n", " \n", " \n", - " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", "\n" @@ -8495,7 +8656,7 @@ "\n", "def speed_test(calculator) -> float:\n", " \"\"\"Time how long it takes to run 500 steps of MD.\"\"\"\n", - " structure = bulk(\"Cu\", cubic=True).repeat((2, 2, 2))\n", + " structure = bulk(\"Cu\", cubic=True).repeat(5) # a big unit cell!\n", " structure.calc = calculator\n", " dynamics = Langevin(\n", " structure,\n", @@ -8511,12 +8672,13 @@ "\n", "skins, durations, cache_hits = [], [], []\n", "\n", - "for skin in [0, 0.05, 0.1, 0.2, 0.4]:\n", - " calculator = GraphPESCalculator(model, skin=skin)\n", + "for skin in [0, 0.05, 0.1, 0.2, 0.4, 0.8]:\n", + " calculator = model.ase_calculator(skin=skin)\n", " duration = speed_test(calculator)\n", " print(\n", " f\"Skin: {skin:0.2f}\",\n", " f\"Duration: {duration:0.2f}s\",\n", + " f\"Total time calculating NL: {int(calculator.total_nl_timing*1000):>4}ms\",\n", " f\"Cache hits: {calculator.cache_hit_rate:.1%}\",\n", " sep=\", \",\n", " )\n", @@ -8528,7 +8690,7 @@ "plt.figure(figsize=(4, 3))\n", "plt.plot(skins, durations, marker=\"o\")\n", "plt.xlabel(\"Skin (Å)\")\n", - "plt.ylabel(\"Duration (s)\");\n" + "plt.ylabel(\"Duration (s)\");" ] } ], @@ -8548,7 +8710,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.18" + "version": "3.9.21" } }, "nbformat": 4, diff --git a/pyproject.toml b/pyproject.toml index c0339a8e..2e5550fa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,13 +29,13 @@ dependencies = [ "wandb", "data2objects>=0.1.0", "pyright>=1.1.394", + "vesin>=0.3.2", ] requires-python = ">=3.9" [project.optional-dependencies] test = ["pytest", "pytest-cov"] -dev = ["ruff", "sphinx-autobuild"] docs = [ "sphinx", "furo", @@ -129,3 +129,6 @@ filterwarnings = [ "ignore:.*The TorchScript type system doesn't support instance-level annotations on empty non-base types.*", ] norecursedirs = "tests/helpers" + +[dependency-groups] +dev = ["notebook>=7.3.2", "ruff", "sphinx-autobuild"] diff --git a/src/graph_pes/atomic_graph.py b/src/graph_pes/atomic_graph.py index b6d9ed88..e2757325 100644 --- a/src/graph_pes/atomic_graph.py +++ b/src/graph_pes/atomic_graph.py @@ -19,7 +19,7 @@ import torch import torch.multiprocessing import torch.utils.data -from ase.neighborlist import neighbor_list +import vesin from ase.stress import voigt_6_to_full_3x3_stress from load_atoms.utils import remove_calculator from typing_extensions import TypeAlias @@ -376,7 +376,9 @@ def from_ase( cell = torch.tensor(structure.cell.array, dtype=_float) # neighbour list - i, j, offsets = neighbor_list("ijS", structure, cutoff) + i, j, offsets = vesin.ase_neighbor_list("ijS", structure, float(cutoff)) + i = i.astype(np.int64) + j = j.astype(np.int64) neighbour_list = torch.tensor(np.vstack([i, j]), dtype=torch.long) neighbour_cell_offsets = torch.tensor(offsets, dtype=_float) diff --git a/src/graph_pes/graph_pes_model.py b/src/graph_pes/graph_pes_model.py index 4e303d9f..8624de77 100644 --- a/src/graph_pes/graph_pes_model.py +++ b/src/graph_pes/graph_pes_model.py @@ -2,7 +2,7 @@ import warnings from abc import ABC, abstractmethod -from typing import Any, Final, Sequence, final +from typing import TYPE_CHECKING, Any, Final, Sequence, final import torch from ase.data import chemical_symbols @@ -23,6 +23,9 @@ from .utils.misc import differentiate, differentiate_all from .utils.nn import PerElementParameter +if TYPE_CHECKING: + from graph_pes.utils.calculator import GraphPESCalculator + class GraphPESModel(nn.Module, ABC): r""" @@ -569,3 +572,27 @@ def extra_state(self, state: Any) -> None: :meth:`~graph_pes.GraphPESModel.extra_state` property. """ pass + + @torch.jit.unused + def ase_calculator( + self, device: torch.device | str | None = None, skin: float = 1.0 + ) -> "GraphPESCalculator": + """ + Return an ASE calculator wrapping this model. See + :class:`~graph_pes.utils.calculator.GraphPESCalculator` for more + information. + + Parameters + ---------- + device + The device to use for the calculator. If ``None``, the device of the + model will be used. + skin + The skin to use for the neighbour list. If all atoms have moved less + than half of this distance between calls to `calculate`, the + neighbour list will be reused, saving (in some cases) significant + computation time. + """ + from graph_pes.utils.calculator import GraphPESCalculator + + return GraphPESCalculator(self, device=device, skin=skin) diff --git a/src/graph_pes/interfaces/_mace.py b/src/graph_pes/interfaces/_mace.py index f444db53..49896cdf 100644 --- a/src/graph_pes/interfaces/_mace.py +++ b/src/graph_pes/interfaces/_mace.py @@ -132,8 +132,7 @@ def predict( return {k: v for k, v in predictions.items() if k in properties} -def _fix_precision(model: torch.nn.Module, precision: str) -> None: - dtype = {"float32": torch.float32, "float64": torch.float64}[precision] +def _fix_dtype(model: torch.nn.Module, dtype: torch.dtype) -> None: for tensor in chain( model.parameters(), model.buffers(), @@ -142,9 +141,17 @@ def _fix_precision(model: torch.nn.Module, precision: str) -> None: tensor.data = tensor.data.to(dtype) +def _get_dtype( + precision: Literal["float32", "float64"] | None, +) -> torch.dtype: + if precision is None: + return torch.get_default_dtype() + return {"float32": torch.float32, "float64": torch.float64}[precision] + + def mace_mp( model: Literal["small", "medium", "large"], - precision: Literal["float32", "float64"] = "float64", + precision: Literal["float32", "float64"] | None = None, ) -> MACEWrapper: """ Donwload a MACE-MP model and convert it for use with ``graph-pes``. @@ -167,24 +174,29 @@ def mace_mp( model The size of the MACE-MP model to download. precision - The precision of the model. + The precision of the model. If ``None``, the default precision + of torch will be used (you can set this when using ``graph-pes-train`` + via ``general/torch/dtype``) """ # noqa: E501 from mace.calculators.foundations_models import mace_mp + dtype = _get_dtype(precision) + precision_str = {torch.float32: "float32", torch.float64: "float64"}[dtype] + mace_torch_model = mace_mp( model, device="cpu", - default_dtype=precision, + default_dtype=precision_str, return_raw_model=True, ) assert isinstance(mace_torch_model, torch.nn.Module) - _fix_precision(mace_torch_model, precision) + _fix_dtype(mace_torch_model, dtype) return MACEWrapper(mace_torch_model) def mace_off( model: Literal["small", "medium", "large"], - precision: Literal["float32", "float64"] = "float64", + precision: Literal["float32", "float64"] | None = None, ) -> MACEWrapper: """ Download a MACE-OFF model and convert it for use with ``graph-pes``. @@ -200,19 +212,22 @@ def mace_off( """ # noqa: E501 from mace.calculators.foundations_models import mace_off + dtype = _get_dtype(precision) + precision_str = {torch.float32: "float32", torch.float64: "float64"}[dtype] + mace_torch_model = mace_off( model, device="cpu", - default_dtype=precision, + default_dtype=precision_str, return_raw_model=True, ) assert isinstance(mace_torch_model, torch.nn.Module) - _fix_precision(mace_torch_model, precision) + _fix_dtype(mace_torch_model, dtype) return MACEWrapper(mace_torch_model) def go_mace_23( - precision: Literal["float32", "float64"] = "float32", + precision: Literal["float32", "float64"] | None = None, ) -> MACEWrapper: """ Download the `GO-MACE-23 model `__ @@ -241,6 +256,8 @@ def go_mace_23( """ # noqa: E501 + dtype = _get_dtype(precision) + url = "https://github.com/zakmachachi/GO-MACE-23/raw/refs/heads/main/models/fitting/potential/iter-12-final-model/go-mace-23.pt" save_path = Path.home() / ".graph-pes" / "go-mace-23.pt" save_path.parent.mkdir(parents=True, exist_ok=True) @@ -258,11 +275,7 @@ def go_mace_23( save_path, weights_only=False, map_location=torch.device("cpu") ) for p in mace_torch_model.parameters(): - p.data = p.data.to( - dtype={"float32": torch.float32, "float64": torch.float64}[ - precision - ] - ) + p.data = p.data.to(dtype) model = MACEWrapper(mace_torch_model) return model diff --git a/src/graph_pes/utils/calculator.py b/src/graph_pes/utils/calculator.py index 69030cb6..ff4528d9 100644 --- a/src/graph_pes/utils/calculator.py +++ b/src/graph_pes/utils/calculator.py @@ -1,5 +1,6 @@ from __future__ import annotations +import time import warnings from typing import Iterable, TypeVar, overload @@ -11,7 +12,7 @@ from graph_pes.atomic_graph import AtomicGraph, PropertyKey, has_cell, to_batch from graph_pes.graph_pes_model import GraphPESModel -from graph_pes.utils.misc import groups_of, pairs +from graph_pes.utils.misc import groups_of, pairs, uniform_repr class GraphPESCalculator(Calculator): @@ -67,9 +68,10 @@ def __init__( self._cached_cell: numpy.ndarray | None = None self.skin = skin - # cache stats + # stats self.cache_hits = 0 self.total_calls = 0 + self.nl_timings = [] def calculate( self, @@ -125,9 +127,12 @@ def calculate( # cache miss if graph is None: + tick = time.perf_counter() graph = AtomicGraph.from_ase( self.atoms, self.model.cutoff.item() + self.skin ).to(self.model.device) + tock = time.perf_counter() + self.nl_timings.append(tock - tick) self._cached_graph = graph self._cached_R = graph.R.detach().cpu().numpy() self._cached_cell = graph.cell.detach().cpu().numpy() @@ -161,10 +166,21 @@ def cache_hit_rate(self) -> float: return 0.0 return self.cache_hits / self.total_calls + @property + def average_nl_timing(self) -> float: + """The average time taken to calculate the neighbour list in seconds.""" + return numpy.mean(self.nl_timings).item() + + @property + def total_nl_timing(self) -> float: + """The total time taken to calculate the neighbour list in seconds.""" + return sum(self.nl_timings) + def reset_cache_stats(self): """Reset the :attr:`cache_hit_rate` statistic.""" self.cache_hits = 0 self.total_calls = 0 + self.nl_timings = [] def calculate_all( self, @@ -224,6 +240,14 @@ def calculate_all( return results + def __repr__(self): + return uniform_repr( + self.__class__.__name__, + model=self.model, + device=self.model.device, + skin=self.skin, + ) + ## utils ## diff --git a/tests/utils/test_calculator.py b/tests/utils/test_calculator.py index f61e7732..c3b26f8c 100644 --- a/tests/utils/test_calculator.py +++ b/tests/utils/test_calculator.py @@ -22,7 +22,7 @@ def test_calc(): def test_calc_all(): - calc = GraphPESCalculator(LennardJones()) + calc = LennardJones().ase_calculator() molecules = [molecule(s) for s in "CH4 H2O CH3CH2OH C2H6".split()] # add cell info so we can test stresses diff --git a/uv.lock b/uv.lock index 0098819d..4693f21a 100644 --- a/uv.lock +++ b/uv.lock @@ -180,6 +180,61 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/46/eb/e7f063ad1fec6b3178a3cd82d1a3c4de82cccf283fc42746168188e1cdd5/anyio-4.8.0-py3-none-any.whl", hash = "sha256:b5011f270ab5eb0abf13385f851315585cc37ef330dd88e27ec3d34d651fd47a", size = 96041 }, ] +[[package]] +name = "appnope" +version = "0.1.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/35/5d/752690df9ef5b76e169e68d6a129fa6d08a7100ca7f754c89495db3c6019/appnope-0.1.4.tar.gz", hash = "sha256:1de3860566df9caf38f01f86f65e0e13e379af54f9e4bee1e66b48f2efffd1ee", size = 4170 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/81/29/5ecc3a15d5a33e31b26c11426c45c501e439cb865d0bff96315d86443b78/appnope-0.1.4-py2.py3-none-any.whl", hash = "sha256:502575ee11cd7a28c0205f379b525beefebab9d161b7c964670864014ed7213c", size = 4321 }, +] + +[[package]] +name = "argon2-cffi" +version = "23.1.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "argon2-cffi-bindings" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/31/fa/57ec2c6d16ecd2ba0cf15f3c7d1c3c2e7b5fcb83555ff56d7ab10888ec8f/argon2_cffi-23.1.0.tar.gz", hash = "sha256:879c3e79a2729ce768ebb7d36d4609e3a78a4ca2ec3a9f12286ca057e3d0db08", size = 42798 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a4/6a/e8a041599e78b6b3752da48000b14c8d1e8a04ded09c88c714ba047f34f5/argon2_cffi-23.1.0-py3-none-any.whl", hash = "sha256:c670642b78ba29641818ab2e68bd4e6a78ba53b7eff7b4c3815ae16abf91c7ea", size = 15124 }, +] + +[[package]] +name = "argon2-cffi-bindings" +version = "21.2.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "cffi" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/b9/e9/184b8ccce6683b0aa2fbb7ba5683ea4b9c5763f1356347f1312c32e3c66e/argon2-cffi-bindings-21.2.0.tar.gz", hash = "sha256:bb89ceffa6c791807d1305ceb77dbfacc5aa499891d2c55661c6459651fc39e3", size = 1779911 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d4/13/838ce2620025e9666aa8f686431f67a29052241692a3dd1ae9d3692a89d3/argon2_cffi_bindings-21.2.0-cp36-abi3-macosx_10_9_x86_64.whl", hash = "sha256:ccb949252cb2ab3a08c02024acb77cfb179492d5701c7cbdbfd776124d4d2367", size = 29658 }, + { url = "https://files.pythonhosted.org/packages/b3/02/f7f7bb6b6af6031edb11037639c697b912e1dea2db94d436e681aea2f495/argon2_cffi_bindings-21.2.0-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9524464572e12979364b7d600abf96181d3541da11e23ddf565a32e70bd4dc0d", size = 80583 }, + { url = "https://files.pythonhosted.org/packages/ec/f7/378254e6dd7ae6f31fe40c8649eea7d4832a42243acaf0f1fff9083b2bed/argon2_cffi_bindings-21.2.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b746dba803a79238e925d9046a63aa26bf86ab2a2fe74ce6b009a1c3f5c8f2ae", size = 86168 }, + { url = "https://files.pythonhosted.org/packages/74/f6/4a34a37a98311ed73bb80efe422fed95f2ac25a4cacc5ae1d7ae6a144505/argon2_cffi_bindings-21.2.0-cp36-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:58ed19212051f49a523abb1dbe954337dc82d947fb6e5a0da60f7c8471a8476c", size = 82709 }, + { url = "https://files.pythonhosted.org/packages/74/2b/73d767bfdaab25484f7e7901379d5f8793cccbb86c6e0cbc4c1b96f63896/argon2_cffi_bindings-21.2.0-cp36-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:bd46088725ef7f58b5a1ef7ca06647ebaf0eb4baff7d1d0d177c6cc8744abd86", size = 83613 }, + { url = "https://files.pythonhosted.org/packages/4f/fd/37f86deef67ff57c76f137a67181949c2d408077e2e3dd70c6c42912c9bf/argon2_cffi_bindings-21.2.0-cp36-abi3-musllinux_1_1_i686.whl", hash = "sha256:8cd69c07dd875537a824deec19f978e0f2078fdda07fd5c42ac29668dda5f40f", size = 84583 }, + { url = "https://files.pythonhosted.org/packages/6f/52/5a60085a3dae8fded8327a4f564223029f5f54b0cb0455a31131b5363a01/argon2_cffi_bindings-21.2.0-cp36-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:f1152ac548bd5b8bcecfb0b0371f082037e47128653df2e8ba6e914d384f3c3e", size = 88475 }, + { url = "https://files.pythonhosted.org/packages/8b/95/143cd64feb24a15fa4b189a3e1e7efbaeeb00f39a51e99b26fc62fbacabd/argon2_cffi_bindings-21.2.0-cp36-abi3-win32.whl", hash = "sha256:603ca0aba86b1349b147cab91ae970c63118a0f30444d4bc80355937c950c082", size = 27698 }, + { url = "https://files.pythonhosted.org/packages/37/2c/e34e47c7dee97ba6f01a6203e0383e15b60fb85d78ac9a15cd066f6fe28b/argon2_cffi_bindings-21.2.0-cp36-abi3-win_amd64.whl", hash = "sha256:b2ef1c30440dbbcba7a5dc3e319408b59676e2e039e2ae11a8775ecf482b192f", size = 30817 }, + { url = "https://files.pythonhosted.org/packages/5a/e4/bf8034d25edaa495da3c8a3405627d2e35758e44ff6eaa7948092646fdcc/argon2_cffi_bindings-21.2.0-cp38-abi3-macosx_10_9_universal2.whl", hash = "sha256:e415e3f62c8d124ee16018e491a009937f8cf7ebf5eb430ffc5de21b900dad93", size = 53104 }, +] + +[[package]] +name = "arrow" +version = "1.3.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "python-dateutil" }, + { name = "types-python-dateutil" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/2e/00/0f6e8fcdb23ea632c866620cc872729ff43ed91d284c866b515c6342b173/arrow-1.3.0.tar.gz", hash = "sha256:d4540617648cb5f895730f1ad8c82a65f2dad0166f57b75f3ca54759c4d67a85", size = 131960 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f8/ed/e97229a566617f2ae958a6b13e7cc0f585470eac730a73e9e82c32a3cdd2/arrow-1.3.0-py3-none-any.whl", hash = "sha256:c728b120ebc00eb84e01882a6f5e7927a53960aa990ce7dd2b10f39005a67f80", size = 66419 }, +] + [[package]] name = "ase" version = "3.24.0" @@ -206,6 +261,18 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/25/8a/c46dcc25341b5bce5472c718902eb3d38600a903b14fa6aeecef3f21a46f/asttokens-3.0.0-py3-none-any.whl", hash = "sha256:e3078351a059199dd5138cb1c706e6430c05eff2ff136af5eb4790f9d28932e2", size = 26918 }, ] +[[package]] +name = "async-lru" +version = "2.0.4" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "typing-extensions", marker = "python_full_version < '3.11'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/80/e2/2b4651eff771f6fd900d233e175ddc5e2be502c7eb62c0c42f975c6d36cd/async-lru-2.0.4.tar.gz", hash = "sha256:b8a59a5df60805ff63220b2a0c5b5393da5521b113cd5465a44eb037d81a5627", size = 10019 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/fa/9f/3c3503693386c4b0f245eaf5ca6198e3b28879ca0a40bde6b0e319793453/async_lru-2.0.4-py3-none-any.whl", hash = "sha256:ff02944ce3c288c5be660c42dbcca0742b32c3b279d6dceda655190240b99224", size = 6111 }, +] + [[package]] name = "async-timeout" version = "5.0.1" @@ -760,6 +827,35 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/1c/c4/f418f0c12bb7badadec326f3609464cfad71f5c8f2378074979b4ae39017/data2objects-0.1.0-py3-none-any.whl", hash = "sha256:21c2ed613651895064d31bd881dabcf56b0a342fde513208518745498b33d9a6", size = 9256 }, ] +[[package]] +name = "debugpy" +version = "1.8.12" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/68/25/c74e337134edf55c4dfc9af579eccb45af2393c40960e2795a94351e8140/debugpy-1.8.12.tar.gz", hash = "sha256:646530b04f45c830ceae8e491ca1c9320a2d2f0efea3141487c82130aba70dce", size = 1641122 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/56/19/dd58334c0a1ec07babf80bf29fb8daf1a7ca4c1a3bbe61548e40616ac087/debugpy-1.8.12-cp310-cp310-macosx_14_0_x86_64.whl", hash = "sha256:a2ba7ffe58efeae5b8fad1165357edfe01464f9aef25e814e891ec690e7dd82a", size = 2076091 }, + { url = "https://files.pythonhosted.org/packages/4c/37/bde1737da15f9617d11ab7b8d5267165f1b7dae116b2585a6643e89e1fa2/debugpy-1.8.12-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cbbd4149c4fc5e7d508ece083e78c17442ee13b0e69bfa6bd63003e486770f45", size = 3560717 }, + { url = "https://files.pythonhosted.org/packages/d9/ca/bc67f5a36a7de072908bc9e1156c0f0b272a9a2224cf21540ab1ffd71a1f/debugpy-1.8.12-cp310-cp310-win32.whl", hash = "sha256:b202f591204023b3ce62ff9a47baa555dc00bb092219abf5caf0e3718ac20e7c", size = 5180672 }, + { url = "https://files.pythonhosted.org/packages/c1/b9/e899c0a80dfa674dbc992f36f2b1453cd1ee879143cdb455bc04fce999da/debugpy-1.8.12-cp310-cp310-win_amd64.whl", hash = "sha256:9649eced17a98ce816756ce50433b2dd85dfa7bc92ceb60579d68c053f98dff9", size = 5212702 }, + { url = "https://files.pythonhosted.org/packages/af/9f/5b8af282253615296264d4ef62d14a8686f0dcdebb31a669374e22fff0a4/debugpy-1.8.12-cp311-cp311-macosx_14_0_universal2.whl", hash = "sha256:36f4829839ef0afdfdd208bb54f4c3d0eea86106d719811681a8627ae2e53dd5", size = 2174643 }, + { url = "https://files.pythonhosted.org/packages/ef/31/f9274dcd3b0f9f7d1e60373c3fa4696a585c55acb30729d313bb9d3bcbd1/debugpy-1.8.12-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a28ed481d530e3138553be60991d2d61103ce6da254e51547b79549675f539b7", size = 3133457 }, + { url = "https://files.pythonhosted.org/packages/ab/ca/6ee59e9892e424477e0c76e3798046f1fd1288040b927319c7a7b0baa484/debugpy-1.8.12-cp311-cp311-win32.whl", hash = "sha256:4ad9a94d8f5c9b954e0e3b137cc64ef3f579d0df3c3698fe9c3734ee397e4abb", size = 5106220 }, + { url = "https://files.pythonhosted.org/packages/d5/1a/8ab508ab05ede8a4eae3b139bbc06ea3ca6234f9e8c02713a044f253be5e/debugpy-1.8.12-cp311-cp311-win_amd64.whl", hash = "sha256:4703575b78dd697b294f8c65588dc86874ed787b7348c65da70cfc885efdf1e1", size = 5130481 }, + { url = "https://files.pythonhosted.org/packages/ba/e6/0f876ecfe5831ebe4762b19214364753c8bc2b357d28c5d739a1e88325c7/debugpy-1.8.12-cp312-cp312-macosx_14_0_universal2.whl", hash = "sha256:7e94b643b19e8feb5215fa508aee531387494bf668b2eca27fa769ea11d9f498", size = 2500846 }, + { url = "https://files.pythonhosted.org/packages/19/64/33f41653a701f3cd2cbff8b41ebaad59885b3428b5afd0d93d16012ecf17/debugpy-1.8.12-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:086b32e233e89a2740c1615c2f775c34ae951508b28b308681dbbb87bba97d06", size = 4222181 }, + { url = "https://files.pythonhosted.org/packages/32/a6/02646cfe50bfacc9b71321c47dc19a46e35f4e0aceea227b6d205e900e34/debugpy-1.8.12-cp312-cp312-win32.whl", hash = "sha256:2ae5df899732a6051b49ea2632a9ea67f929604fd2b036613a9f12bc3163b92d", size = 5227017 }, + { url = "https://files.pythonhosted.org/packages/da/a6/10056431b5c47103474312cf4a2ec1001f73e0b63b1216706d5fef2531eb/debugpy-1.8.12-cp312-cp312-win_amd64.whl", hash = "sha256:39dfbb6fa09f12fae32639e3286112fc35ae976114f1f3d37375f3130a820969", size = 5267555 }, + { url = "https://files.pythonhosted.org/packages/cf/4d/7c3896619a8791effd5d8c31f0834471fc8f8fb3047ec4f5fc69dd1393dd/debugpy-1.8.12-cp313-cp313-macosx_14_0_universal2.whl", hash = "sha256:696d8ae4dff4cbd06bf6b10d671e088b66669f110c7c4e18a44c43cf75ce966f", size = 2485246 }, + { url = "https://files.pythonhosted.org/packages/99/46/bc6dcfd7eb8cc969a5716d858e32485eb40c72c6a8dc88d1e3a4d5e95813/debugpy-1.8.12-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:898fba72b81a654e74412a67c7e0a81e89723cfe2a3ea6fcd3feaa3395138ca9", size = 4218616 }, + { url = "https://files.pythonhosted.org/packages/03/dd/d7fcdf0381a9b8094da1f6a1c9f19fed493a4f8576a2682349b3a8b20ec7/debugpy-1.8.12-cp313-cp313-win32.whl", hash = "sha256:22a11c493c70413a01ed03f01c3c3a2fc4478fc6ee186e340487b2edcd6f4180", size = 5226540 }, + { url = "https://files.pythonhosted.org/packages/25/bd/ecb98f5b5fc7ea0bfbb3c355bc1dd57c198a28780beadd1e19915bf7b4d9/debugpy-1.8.12-cp313-cp313-win_amd64.whl", hash = "sha256:fdb3c6d342825ea10b90e43d7f20f01535a72b3a1997850c0c3cefa5c27a4a2c", size = 5267134 }, + { url = "https://files.pythonhosted.org/packages/89/37/a3333c5b69c086465ea3c073424ef2775e52a6c17276f642f64209c4a082/debugpy-1.8.12-cp39-cp39-macosx_14_0_x86_64.whl", hash = "sha256:b5c6c967d02fee30e157ab5227706f965d5c37679c687b1e7bbc5d9e7128bd41", size = 2077275 }, + { url = "https://files.pythonhosted.org/packages/50/1d/99f6a0a78b4b513ff2b0d0e44c1e705f7ee34e3aba0e8add617d339d97dc/debugpy-1.8.12-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:88a77f422f31f170c4b7e9ca58eae2a6c8e04da54121900651dfa8e66c29901a", size = 3555956 }, + { url = "https://files.pythonhosted.org/packages/b8/86/c624665aaa807d065da2016b05e9f2fb4fa56872d67a5fbd7751e77f7f88/debugpy-1.8.12-cp39-cp39-win32.whl", hash = "sha256:a4042edef80364239f5b7b5764e55fd3ffd40c32cf6753da9bda4ff0ac466018", size = 5181535 }, + { url = "https://files.pythonhosted.org/packages/72/c7/d59a0f845ce1677b5c2bb170f08cc1cc3531625a5fdce9c67bd31116540a/debugpy-1.8.12-cp39-cp39-win_amd64.whl", hash = "sha256:f30b03b0f27608a0b26c75f0bb8a880c752c0e0b01090551b9d87c7d783e2069", size = 5213601 }, + { url = "https://files.pythonhosted.org/packages/38/c4/5120ad36405c3008f451f94b8f92ef1805b1e516f6ff870f331ccb3c4cc0/debugpy-1.8.12-py2.py3-none-any.whl", hash = "sha256:274b6a2040349b5c9864e475284bce5bb062e63dce368a394b8cc865ae3b00c6", size = 5229490 }, +] + [[package]] name = "decorator" version = "5.1.1" @@ -909,6 +1005,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/bf/ff/44934a031ce5a39125415eb405b9efb76fe7f9586b75291d66ae5cbfc4e6/fonttools-4.56.0-py3-none-any.whl", hash = "sha256:1088182f68c303b50ca4dc0c82d42083d176cba37af1937e1a976a31149d4d14", size = 1089800 }, ] +[[package]] +name = "fqdn" +version = "1.5.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/30/3e/a80a8c077fd798951169626cde3e239adeba7dab75deb3555716415bd9b0/fqdn-1.5.1.tar.gz", hash = "sha256:105ed3677e767fb5ca086a0c1f4bb66ebc3c100be518f0e0d755d9eae164d89f", size = 6015 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/cf/58/8acf1b3e91c58313ce5cb67df61001fc9dcd21be4fadb76c1a2d540e09ed/fqdn-1.5.1-py3-none-any.whl", hash = "sha256:3a179af3761e4df6eb2e026ff9e1a3033d3587bf980a0b1b2e1e5d08d7358014", size = 9121 }, +] + [[package]] name = "frozenlist" version = "1.5.0" @@ -1065,14 +1170,11 @@ dependencies = [ { name = "rich" }, { name = "scikit-learn" }, { name = "torch" }, + { name = "vesin" }, { name = "wandb" }, ] [package.optional-dependencies] -dev = [ - { name = "ruff" }, - { name = "sphinx-autobuild" }, -] docs = [ { name = "furo" }, { name = "nbsphinx" }, @@ -1091,6 +1193,13 @@ test = [ { name = "pytest-cov" }, ] +[package.dev-dependencies] +dev = [ + { name = "notebook" }, + { name = "ruff" }, + { name = "sphinx-autobuild" }, +] + [package.metadata] requires-dist = [ { name = "ase" }, @@ -1108,18 +1217,24 @@ requires-dist = [ { name = "pytest-cov", marker = "extra == 'test'" }, { name = "pytorch-lightning" }, { name = "rich" }, - { name = "ruff", marker = "extra == 'dev'" }, { name = "scikit-learn" }, { name = "sphinx", marker = "extra == 'docs'" }, - { name = "sphinx-autobuild", marker = "extra == 'dev'" }, { name = "sphinx-copybutton", marker = "extra == 'docs'" }, { name = "sphinx-design", marker = "extra == 'docs'" }, { name = "sphinxext-opengraph", marker = "extra == 'docs'" }, { name = "torch" }, { name = "twine", marker = "extra == 'publish'" }, + { name = "vesin", specifier = ">=0.3.2" }, { name = "wandb" }, ] +[package.metadata.requires-dev] +dev = [ + { name = "notebook", specifier = ">=7.3.2" }, + { name = "ruff" }, + { name = "sphinx-autobuild" }, +] + [[package]] name = "h11" version = "0.14.0" @@ -1166,6 +1281,34 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/b2/ab/4db20b08a70c3cd88aab63f46c62a97eaf978bd000eb10e303d3b3ceb38e/h5py-3.12.1-cp39-cp39-win_amd64.whl", hash = "sha256:62be1fc0ef195891949b2c627ec06bc8e837ff62d5b911b6e42e38e0f20a897d", size = 3000291 }, ] +[[package]] +name = "httpcore" +version = "1.0.7" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "certifi" }, + { name = "h11" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/6a/41/d7d0a89eb493922c37d343b607bc1b5da7f5be7e383740b4753ad8943e90/httpcore-1.0.7.tar.gz", hash = "sha256:8551cb62a169ec7162ac7be8d4817d561f60e08eaa485234898414bb5a8a0b4c", size = 85196 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/87/f5/72347bc88306acb359581ac4d52f23c0ef445b57157adedb9aee0cd689d2/httpcore-1.0.7-py3-none-any.whl", hash = "sha256:a3fff8f43dc260d5bd363d9f9cf1830fa3a458b332856f34282de498ed420edd", size = 78551 }, +] + +[[package]] +name = "httpx" +version = "0.28.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "anyio" }, + { name = "certifi" }, + { name = "httpcore" }, + { name = "idna" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/b1/df/48c586a5fe32a0f01324ee087459e112ebb7224f646c0b5023f5e79e9956/httpx-0.28.1.tar.gz", hash = "sha256:75e98c5f16b0f35b567856f597f06ff2270a374470a5c2392242528e3e3e42fc", size = 141406 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2a/39/e50c7c3a983047577ee07d2a9e53faf5a69493943ec3f6a384bdc792deb2/httpx-0.28.1-py3-none-any.whl", hash = "sha256:d909fcccc110f8c7faf814ca82a9a4d816bc5a6dbfea25d6591d6985b8ba59ad", size = 73517 }, +] + [[package]] name = "id" version = "1.5.0" @@ -1229,6 +1372,31 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/ef/a6/62565a6e1cf69e10f5727360368e451d4b7f58beeac6173dc9db836a5b46/iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374", size = 5892 }, ] +[[package]] +name = "ipykernel" +version = "6.29.5" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "appnope", marker = "sys_platform == 'darwin'" }, + { name = "comm" }, + { name = "debugpy" }, + { name = "ipython", version = "8.18.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.10'" }, + { name = "ipython", version = "8.32.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.10'" }, + { name = "jupyter-client" }, + { name = "jupyter-core" }, + { name = "matplotlib-inline" }, + { name = "nest-asyncio" }, + { name = "packaging" }, + { name = "psutil" }, + { name = "pyzmq" }, + { name = "tornado" }, + { name = "traitlets" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/e9/5c/67594cb0c7055dc50814b21731c22a601101ea3b1b50a9a1b090e11f5d0f/ipykernel-6.29.5.tar.gz", hash = "sha256:f093a22c4a40f8828f8e330a9c297cb93dcab13bd9678ded6de8e5cf81c56215", size = 163367 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/94/5c/368ae6c01c7628438358e6d337c19b05425727fbb221d2a3c4303c372f42/ipykernel-6.29.5-py3-none-any.whl", hash = "sha256:afdb66ba5aa354b09b91379bac28ae4afebbb30e8b39510c9690afb7a10421b5", size = 117173 }, +] + [[package]] name = "ipython" version = "8.18.1" @@ -1300,6 +1468,18 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/22/2d/9c0b76f2f9cc0ebede1b9371b6f317243028ed60b90705863d493bae622e/ipywidgets-8.1.5-py3-none-any.whl", hash = "sha256:3290f526f87ae6e77655555baba4f36681c555b8bdbbff430b70e52c34c86245", size = 139767 }, ] +[[package]] +name = "isoduration" +version = "20.11.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "arrow" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/7c/1a/3c8edc664e06e6bd06cce40c6b22da5f1429aa4224d0c590f3be21c91ead/isoduration-20.11.0.tar.gz", hash = "sha256:ac2f9015137935279eac671f94f89eb00584f940f5dc49462a0c4ee692ba1bd9", size = 11649 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7b/55/e5326141505c5d5e34c5e0935d2908a74e4561eca44108fbfb9c13d2911a/isoduration-20.11.0-py3-none-any.whl", hash = "sha256:b2904c2a4228c3d44f409c8ae8e2370eb21a26f7ac2ec5446df141dde3452042", size = 11321 }, +] + [[package]] name = "jaraco-classes" version = "3.4.0" @@ -1378,6 +1558,24 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/91/29/df4b9b42f2be0b623cbd5e2140cafcaa2bef0759a00b7b70104dcfe2fb51/joblib-1.4.2-py3-none-any.whl", hash = "sha256:06d478d5674cbc267e7496a410ee875abd68e4340feff4490bcb7afb88060ae6", size = 301817 }, ] +[[package]] +name = "json5" +version = "0.10.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/85/3d/bbe62f3d0c05a689c711cff57b2e3ac3d3e526380adb7c781989f075115c/json5-0.10.0.tar.gz", hash = "sha256:e66941c8f0a02026943c52c2eb34ebeb2a6f819a0be05920a6f5243cd30fd559", size = 48202 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/aa/42/797895b952b682c3dafe23b1834507ee7f02f4d6299b65aaa61425763278/json5-0.10.0-py3-none-any.whl", hash = "sha256:19b23410220a7271e8377f81ba8aacba2fdd56947fbb137ee5977cbe1f5e8dfa", size = 34049 }, +] + +[[package]] +name = "jsonpointer" +version = "3.0.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/6a/0a/eebeb1fa92507ea94016a2a790b93c2ae41a7e18778f85471dc54475ed25/jsonpointer-3.0.0.tar.gz", hash = "sha256:2b2d729f2091522d61c3b31f82e11870f60b68f43fbc705cb76bf4b832af59ef", size = 9114 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/71/92/5e77f98553e9e75130c78900d000368476aed74276eb8ae8796f65f00918/jsonpointer-3.0.0-py2.py3-none-any.whl", hash = "sha256:13e088adc14fca8b6aa8177c044e12701e6ad4b28ff10e65f2267a90109c9942", size = 7595 }, +] + [[package]] name = "jsonschema" version = "4.23.0" @@ -1393,6 +1591,18 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/69/4a/4f9dbeb84e8850557c02365a0eee0649abe5eb1d84af92a25731c6c0f922/jsonschema-4.23.0-py3-none-any.whl", hash = "sha256:fbadb6f8b144a8f8cf9f0b89ba94501d143e50411a1278633f56a7acf7fd5566", size = 88462 }, ] +[package.optional-dependencies] +format-nongpl = [ + { name = "fqdn" }, + { name = "idna" }, + { name = "isoduration" }, + { name = "jsonpointer" }, + { name = "rfc3339-validator" }, + { name = "rfc3986-validator" }, + { name = "uri-template" }, + { name = "webcolors" }, +] + [[package]] name = "jsonschema-specifications" version = "2024.10.1" @@ -1436,6 +1646,107 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/c9/fb/108ecd1fe961941959ad0ee4e12ee7b8b1477247f30b1fdfd83ceaf017f0/jupyter_core-5.7.2-py3-none-any.whl", hash = "sha256:4f7315d2f6b4bcf2e3e7cb6e46772eba760ae459cd1f59d29eb57b0a01bd7409", size = 28965 }, ] +[[package]] +name = "jupyter-events" +version = "0.12.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "jsonschema", extra = ["format-nongpl"] }, + { name = "packaging" }, + { name = "python-json-logger" }, + { name = "pyyaml" }, + { name = "referencing" }, + { name = "rfc3339-validator" }, + { name = "rfc3986-validator" }, + { name = "traitlets" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/9d/c3/306d090461e4cf3cd91eceaff84bede12a8e52cd821c2d20c9a4fd728385/jupyter_events-0.12.0.tar.gz", hash = "sha256:fc3fce98865f6784c9cd0a56a20644fc6098f21c8c33834a8d9fe383c17e554b", size = 62196 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e2/48/577993f1f99c552f18a0428731a755e06171f9902fa118c379eb7c04ea22/jupyter_events-0.12.0-py3-none-any.whl", hash = "sha256:6464b2fa5ad10451c3d35fabc75eab39556ae1e2853ad0c0cc31b656731a97fb", size = 19430 }, +] + +[[package]] +name = "jupyter-lsp" +version = "2.2.5" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "importlib-metadata", marker = "python_full_version < '3.10'" }, + { name = "jupyter-server" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/85/b4/3200b0b09c12bc3b72d943d923323c398eff382d1dcc7c0dbc8b74630e40/jupyter-lsp-2.2.5.tar.gz", hash = "sha256:793147a05ad446f809fd53ef1cd19a9f5256fd0a2d6b7ce943a982cb4f545001", size = 48741 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/07/e0/7bd7cff65594fd9936e2f9385701e44574fc7d721331ff676ce440b14100/jupyter_lsp-2.2.5-py3-none-any.whl", hash = "sha256:45fbddbd505f3fbfb0b6cb2f1bc5e15e83ab7c79cd6e89416b248cb3c00c11da", size = 69146 }, +] + +[[package]] +name = "jupyter-server" +version = "2.15.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "anyio" }, + { name = "argon2-cffi" }, + { name = "jinja2" }, + { name = "jupyter-client" }, + { name = "jupyter-core" }, + { name = "jupyter-events" }, + { name = "jupyter-server-terminals" }, + { name = "nbconvert" }, + { name = "nbformat" }, + { name = "overrides" }, + { name = "packaging" }, + { name = "prometheus-client" }, + { name = "pywinpty", marker = "os_name == 'nt' and sys_platform != 'linux'" }, + { name = "pyzmq" }, + { name = "send2trash" }, + { name = "terminado" }, + { name = "tornado" }, + { name = "traitlets" }, + { name = "websocket-client" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/61/8c/df09d4ab646141f130f9977b32b206ba8615d1969b2eba6a2e84b7f89137/jupyter_server-2.15.0.tar.gz", hash = "sha256:9d446b8697b4f7337a1b7cdcac40778babdd93ba614b6d68ab1c0c918f1c4084", size = 725227 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e2/a2/89eeaf0bb954a123a909859fa507fa86f96eb61b62dc30667b60dbd5fdaf/jupyter_server-2.15.0-py3-none-any.whl", hash = "sha256:872d989becf83517012ee669f09604aa4a28097c0bd90b2f424310156c2cdae3", size = 385826 }, +] + +[[package]] +name = "jupyter-server-terminals" +version = "0.5.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "pywinpty", marker = "os_name == 'nt' and sys_platform != 'linux'" }, + { name = "terminado" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/fc/d5/562469734f476159e99a55426d697cbf8e7eb5efe89fb0e0b4f83a3d3459/jupyter_server_terminals-0.5.3.tar.gz", hash = "sha256:5ae0295167220e9ace0edcfdb212afd2b01ee8d179fe6f23c899590e9b8a5269", size = 31430 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/07/2d/2b32cdbe8d2a602f697a649798554e4f072115438e92249624e532e8aca6/jupyter_server_terminals-0.5.3-py3-none-any.whl", hash = "sha256:41ee0d7dc0ebf2809c668e0fc726dfaf258fcd3e769568996ca731b6194ae9aa", size = 13656 }, +] + +[[package]] +name = "jupyterlab" +version = "4.3.5" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "async-lru" }, + { name = "httpx" }, + { name = "importlib-metadata", marker = "python_full_version < '3.10'" }, + { name = "ipykernel" }, + { name = "jinja2" }, + { name = "jupyter-core" }, + { name = "jupyter-lsp" }, + { name = "jupyter-server" }, + { name = "jupyterlab-server" }, + { name = "notebook-shim" }, + { name = "packaging" }, + { name = "setuptools" }, + { name = "tomli", marker = "python_full_version < '3.11'" }, + { name = "tornado" }, + { name = "traitlets" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/19/17/6f3d73c3e54b71bbaf03edcc4a54b0aa6328e0a134755f297ea87d425711/jupyterlab-4.3.5.tar.gz", hash = "sha256:c779bf72ced007d7d29d5bcef128e7fdda96ea69299e19b04a43635a7d641f9d", size = 21800023 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/73/6f/94d4c879b3e2b7b9bca1913ea6fbbef180f8b1ed065b46ade40d651ec54d/jupyterlab-4.3.5-py3-none-any.whl", hash = "sha256:571bbdee20e4c5321ab5195bc41cf92a75a5cff886be5e57ce78dfa37a5e9fdb", size = 11666944 }, +] + [[package]] name = "jupyterlab-pygments" version = "0.3.0" @@ -1445,6 +1756,25 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/b1/dd/ead9d8ea85bf202d90cc513b533f9c363121c7792674f78e0d8a854b63b4/jupyterlab_pygments-0.3.0-py3-none-any.whl", hash = "sha256:841a89020971da1d8693f1a99997aefc5dc424bb1b251fd6322462a1b8842780", size = 15884 }, ] +[[package]] +name = "jupyterlab-server" +version = "2.27.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "babel" }, + { name = "importlib-metadata", marker = "python_full_version < '3.10'" }, + { name = "jinja2" }, + { name = "json5" }, + { name = "jsonschema" }, + { name = "jupyter-server" }, + { name = "packaging" }, + { name = "requests" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/0a/c9/a883ce65eb27905ce77ace410d83587c82ea64dc85a48d1f7ed52bcfa68d/jupyterlab_server-2.27.3.tar.gz", hash = "sha256:eb36caca59e74471988f0ae25c77945610b887f777255aa21f8065def9e51ed4", size = 76173 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/54/09/2032e7d15c544a0e3cd831c51d77a8ca57f7555b2e1b2922142eddb02a84/jupyterlab_server-2.27.3-py3-none-any.whl", hash = "sha256:e697488f66c3db49df675158a77b3b017520d772c6e1548c7d9bcc5df7944ee4", size = 59700 }, +] + [[package]] name = "jupyterlab-widgets" version = "3.0.13" @@ -2157,6 +2487,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/6a/8a/5dc4c8794053572a89f5c44437ef4e870f88903a6b6734500af1286f9018/nbsphinx-0.9.6-py3-none-any.whl", hash = "sha256:336b0b557945a7678ec7449b16449f854bc852a435bb53b8a72e6b5dc740d992", size = 31582 }, ] +[[package]] +name = "nest-asyncio" +version = "1.6.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/83/f8/51569ac65d696c8ecbee95938f89d4abf00f47d58d48f6fbabfe8f0baefe/nest_asyncio-1.6.0.tar.gz", hash = "sha256:6f172d5449aca15afd6c646851f4e31e02c598d553a667e38cafa997cfec55fe", size = 7418 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a0/c4/c2971a3ba4c6103a3d10c4b0f24f461ddc027f0f09763220cf35ca1401b3/nest_asyncio-1.6.0-py3-none-any.whl", hash = "sha256:87af6efd6b5e897c81050477ef65c62e2b2f35d51703cae01aff2905b1852e1c", size = 5195 }, +] + [[package]] name = "networkx" version = "3.2.1" @@ -2225,6 +2564,34 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/d2/1d/1b658dbd2b9fa9c4c9f32accbfc0205d532c8c6194dc0f2a4c0428e7128a/nodeenv-1.9.1-py2.py3-none-any.whl", hash = "sha256:ba11c9782d29c27c70ffbdda2d7415098754709be8a7056d79a737cd901155c9", size = 22314 }, ] +[[package]] +name = "notebook" +version = "7.3.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "jupyter-server" }, + { name = "jupyterlab" }, + { name = "jupyterlab-server" }, + { name = "notebook-shim" }, + { name = "tornado" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/ea/04/ac488379d5afef43402b3fb4be2857db1a09804fecf98b9b714c741b225b/notebook-7.3.2.tar.gz", hash = "sha256:705e83a1785f45b383bf3ee13cb76680b92d24f56fb0c7d2136fe1d850cd3ca8", size = 12781804 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/22/9b/76e50ee18f183ea5fe1784a9eeaa50f2c71802e4740d6e959592b0993298/notebook-7.3.2-py3-none-any.whl", hash = "sha256:e5f85fc59b69d3618d73cf27544418193ff8e8058d5bf61d315ce4f473556288", size = 13163630 }, +] + +[[package]] +name = "notebook-shim" +version = "0.2.4" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "jupyter-server" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/54/d2/92fa3243712b9a3e8bafaf60aac366da1cada3639ca767ff4b5b3654ec28/notebook_shim-0.2.4.tar.gz", hash = "sha256:b4b2cfa1b65d98307ca24361f5b30fe785b53c3fd07b7a47e89acb5e6ac638cb", size = 13167 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f9/33/bd5b9137445ea4b680023eb0469b2bb969d61303dedb2aac6560ff3d14a1/notebook_shim-0.2.4-py3-none-any.whl", hash = "sha256:411a5be4e9dc882a074ccbcae671eda64cceb068767e9a3419096986560e1cef", size = 13307 }, +] + [[package]] name = "numpy" version = "2.0.2" @@ -2490,6 +2857,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/8d/4c/e0370709aaf9d7ceb68f975cac559751e75954429a77e83202e680606560/opt_einsum_fx-0.1.4-py3-none-any.whl", hash = "sha256:85f489f4c7c31fd88d5faf9669c09e61ec37a30098809fdcfe2a08a9e42f23c9", size = 13213 }, ] +[[package]] +name = "overrides" +version = "7.7.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/36/86/b585f53236dec60aba864e050778b25045f857e17f6e5ea0ae95fe80edd2/overrides-7.7.0.tar.gz", hash = "sha256:55158fa3d93b98cc75299b1e67078ad9003ca27945c76162c1c0766d6f91820a", size = 22812 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2c/ab/fc8290c6a4c722e5514d80f62b2dc4c4df1a68a41d1364e625c35990fcf3/overrides-7.7.0-py3-none-any.whl", hash = "sha256:c7ed9d062f78b8e4c1a7b70bd8796b35ead4d9f510227ef9c5dc7626c60d7e49", size = 17832 }, +] + [[package]] name = "packaging" version = "24.2" @@ -2625,6 +3001,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/88/5f/e351af9a41f866ac3f1fac4ca0613908d9a41741cfcf2228f4ad853b697d/pluggy-1.5.0-py3-none-any.whl", hash = "sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669", size = 20556 }, ] +[[package]] +name = "prometheus-client" +version = "0.21.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/62/14/7d0f567991f3a9af8d1cd4f619040c93b68f09a02b6d0b6ab1b2d1ded5fe/prometheus_client-0.21.1.tar.gz", hash = "sha256:252505a722ac04b0456be05c05f75f45d760c2911ffc45f2a06bcaed9f3ae3fb", size = 78551 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ff/c2/ab7d37426c179ceb9aeb109a85cda8948bb269b7561a0be870cc656eefe4/prometheus_client-0.21.1-py3-none-any.whl", hash = "sha256:594b45c410d6f4f8888940fe80b5cc2521b305a1fafe1c58609ef715a001f301", size = 54682 }, +] + [[package]] name = "prompt-toolkit" version = "3.0.50" @@ -2977,6 +3362,18 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/ec/57/56b9bcc3c9c6a792fcbaf139543cee77261f3651ca9da0c93f5c1221264b/python_dateutil-2.9.0.post0-py2.py3-none-any.whl", hash = "sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427", size = 229892 }, ] +[[package]] +name = "python-json-logger" +version = "3.2.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "typing-extensions", marker = "python_full_version < '3.10'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/e3/c4/358cd13daa1d912ef795010897a483ab2f0b41c9ea1b35235a8b2f7d15a7/python_json_logger-3.2.1.tar.gz", hash = "sha256:8eb0554ea17cb75b05d2848bc14fb02fbdbd9d6972120781b974380bfa162008", size = 16287 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/4b/72/2f30cf26664fcfa0bd8ec5ee62ec90c03bd485e4a294d92aabc76c5203a5/python_json_logger-3.2.1-py3-none-any.whl", hash = "sha256:cdc17047eb5374bd311e748b42f99d71223f3b0e186f4206cc5d52aefe85b090", size = 14924 }, +] + [[package]] name = "pytorch-lightning" version = "2.5.0.post0" @@ -3026,6 +3423,20 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/de/3d/8161f7711c017e01ac9f008dfddd9410dff3674334c233bde66e7ba65bbf/pywin32_ctypes-0.2.3-py3-none-any.whl", hash = "sha256:8a1513379d709975552d202d942d9837758905c8d01eb82b8bcc30918929e7b8", size = 30756 }, ] +[[package]] +name = "pywinpty" +version = "2.0.15" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/2d/7c/917f9c4681bb8d34bfbe0b79d36bbcd902651aeab48790df3d30ba0202fb/pywinpty-2.0.15.tar.gz", hash = "sha256:312cf39153a8736c617d45ce8b6ad6cd2107de121df91c455b10ce6bba7a39b2", size = 29017 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a6/b7/855db919ae526d2628f3f2e6c281c4cdff7a9a8af51bb84659a9f07b1861/pywinpty-2.0.15-cp310-cp310-win_amd64.whl", hash = "sha256:8e7f5de756a615a38b96cd86fa3cd65f901ce54ce147a3179c45907fa11b4c4e", size = 1405161 }, + { url = "https://files.pythonhosted.org/packages/5e/ac/6884dcb7108af66ad53f73ef4dad096e768c9203a6e6ce5e6b0c4a46e238/pywinpty-2.0.15-cp311-cp311-win_amd64.whl", hash = "sha256:9a6bcec2df2707aaa9d08b86071970ee32c5026e10bcc3cc5f6f391d85baf7ca", size = 1405249 }, + { url = "https://files.pythonhosted.org/packages/88/e5/9714def18c3a411809771a3fbcec70bffa764b9675afb00048a620fca604/pywinpty-2.0.15-cp312-cp312-win_amd64.whl", hash = "sha256:83a8f20b430bbc5d8957249f875341a60219a4e971580f2ba694fbfb54a45ebc", size = 1405243 }, + { url = "https://files.pythonhosted.org/packages/fb/16/2ab7b3b7f55f3c6929e5f629e1a68362981e4e5fed592a2ed1cb4b4914a5/pywinpty-2.0.15-cp313-cp313-win_amd64.whl", hash = "sha256:ab5920877dd632c124b4ed17bc6dd6ef3b9f86cd492b963ffdb1a67b85b0f408", size = 1405020 }, + { url = "https://files.pythonhosted.org/packages/7c/16/edef3515dd2030db2795dbfbe392232c7a0f3dc41b98e92b38b42ba497c7/pywinpty-2.0.15-cp313-cp313t-win_amd64.whl", hash = "sha256:a4560ad8c01e537708d2790dbe7da7d986791de805d89dd0d3697ca59e9e4901", size = 1404151 }, + { url = "https://files.pythonhosted.org/packages/47/96/90fa02f19b1eff7469ad7bf0ef8efca248025de9f1d0a0b25682d2aacf68/pywinpty-2.0.15-cp39-cp39-win_amd64.whl", hash = "sha256:d261cd88fcd358cfb48a7ca0700db3e1c088c9c10403c9ebc0d8a8b57aa6a117", size = 1405302 }, +] + [[package]] name = "pyyaml" version = "6.0.2" @@ -3224,6 +3635,18 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/3f/51/d4db610ef29373b879047326cbf6fa98b6c1969d6f6dc423279de2b1be2c/requests_toolbelt-1.0.0-py2.py3-none-any.whl", hash = "sha256:cccfdd665f0a24fcf4726e690f65639d272bb0637b9b92dfd91a5568ccf6bd06", size = 54481 }, ] +[[package]] +name = "rfc3339-validator" +version = "0.1.4" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "six" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/28/ea/a9387748e2d111c3c2b275ba970b735e04e15cdb1eb30693b6b5708c4dbd/rfc3339_validator-0.1.4.tar.gz", hash = "sha256:138a2abdf93304ad60530167e51d2dfb9549521a836871b88d7f4695d0022f6b", size = 5513 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7b/44/4e421b96b67b2daff264473f7465db72fbdf36a07e05494f50300cc7b0c6/rfc3339_validator-0.1.4-py2.py3-none-any.whl", hash = "sha256:24f6ec1eda14ef823da9e36ec7113124b39c04d50a4d3d3a3c2859577e7791fa", size = 3490 }, +] + [[package]] name = "rfc3986" version = "2.0.0" @@ -3233,6 +3656,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/ff/9a/9afaade874b2fa6c752c36f1548f718b5b83af81ed9b76628329dab81c1b/rfc3986-2.0.0-py2.py3-none-any.whl", hash = "sha256:50b1502b60e289cb37883f3dfd34532b8873c7de9f49bb546641ce9cbd256ebd", size = 31326 }, ] +[[package]] +name = "rfc3986-validator" +version = "0.1.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/da/88/f270de456dd7d11dcc808abfa291ecdd3f45ff44e3b549ffa01b126464d0/rfc3986_validator-0.1.1.tar.gz", hash = "sha256:3d44bde7921b3b9ec3ae4e3adca370438eccebc676456449b145d533b240d055", size = 6760 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/9e/51/17023c0f8f1869d8806b979a2bffa3f861f26a3f1a66b094288323fba52f/rfc3986_validator-0.1.1-py2.py3-none-any.whl", hash = "sha256:2f235c432ef459970b4306369336b9d5dbdda31b510ca1e327636e01f528bfa9", size = 4242 }, +] + [[package]] name = "rich" version = "13.9.4" @@ -3535,6 +3967,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/54/24/b4293291fa1dd830f353d2cb163295742fa87f179fcc8a20a306a81978b7/SecretStorage-3.3.3-py3-none-any.whl", hash = "sha256:f356e6628222568e3af06f2eba8df495efa13b3b63081dafd4f7d9a7b7bc9f99", size = 15221 }, ] +[[package]] +name = "send2trash" +version = "1.8.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/fd/3a/aec9b02217bb79b87bbc1a21bc6abc51e3d5dcf65c30487ac96c0908c722/Send2Trash-1.8.3.tar.gz", hash = "sha256:b18e7a3966d99871aefeb00cfbcfdced55ce4871194810fc71f4aa484b953abf", size = 17394 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/40/b0/4562db6223154aa4e22f939003cb92514c79f3d4dccca3444253fd17f902/Send2Trash-1.8.3-py3-none-any.whl", hash = "sha256:0c31227e0bd08961c7665474a3d1ef7193929fedda4233843689baa056be46c9", size = 18072 }, +] + [[package]] name = "sentry-sdk" version = "2.21.0" @@ -3908,6 +4349,20 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/b2/fe/81695a1aa331a842b582453b605175f419fe8540355886031328089d840a/sympy-1.13.1-py3-none-any.whl", hash = "sha256:db36cdc64bf61b9b24578b6f7bab1ecdd2452cf008f34faa33776680c26d66f8", size = 6189177 }, ] +[[package]] +name = "terminado" +version = "0.18.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "ptyprocess", marker = "os_name != 'nt'" }, + { name = "pywinpty", marker = "os_name == 'nt' and sys_platform != 'linux'" }, + { name = "tornado" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/8a/11/965c6fd8e5cc254f1fe142d547387da17a8ebfd75a3455f637c663fb38a0/terminado-0.18.1.tar.gz", hash = "sha256:de09f2c4b85de4765f7714688fff57d3e75bad1f909b589fde880460c753fd2e", size = 32701 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/6a/9e/2064975477fdc887e47ad42157e214526dcad8f317a948dee17e1659a62f/terminado-0.18.1-py3-none-any.whl", hash = "sha256:a4468e1b37bb318f8a86514f65814e1afc977cf29b3992a4500d9dd305dcceb0", size = 14154 }, +] + [[package]] name = "threadpoolctl" version = "3.5.0" @@ -4107,6 +4562,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/7c/b6/74e927715a285743351233f33ea3c684528a0d374d2e43ff9ce9585b73fe/twine-6.1.0-py3-none-any.whl", hash = "sha256:a47f973caf122930bf0fbbf17f80b83bc1602c9ce393c7845f289a3001dc5384", size = 40791 }, ] +[[package]] +name = "types-python-dateutil" +version = "2.9.0.20241206" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/a9/60/47d92293d9bc521cd2301e423a358abfac0ad409b3a1606d8fbae1321961/types_python_dateutil-2.9.0.20241206.tar.gz", hash = "sha256:18f493414c26ffba692a72369fea7a154c502646301ebfe3d56a04b3767284cb", size = 13802 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/0f/b3/ca41df24db5eb99b00d97f89d7674a90cb6b3134c52fb8121b6d8d30f15c/types_python_dateutil-2.9.0.20241206-py3-none-any.whl", hash = "sha256:e248a4bc70a486d3e3ec84d0dc30eec3a5f979d6e7ee4123ae043eedbb987f53", size = 14384 }, +] + [[package]] name = "typing-extensions" version = "4.12.2" @@ -4116,6 +4580,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/26/9f/ad63fc0248c5379346306f8668cda6e2e2e9c95e01216d2b8ffd9ff037d0/typing_extensions-4.12.2-py3-none-any.whl", hash = "sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d", size = 37438 }, ] +[[package]] +name = "uri-template" +version = "1.3.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/31/c7/0336f2bd0bcbada6ccef7aaa25e443c118a704f828a0620c6fa0207c1b64/uri-template-1.3.0.tar.gz", hash = "sha256:0e00f8eb65e18c7de20d595a14336e9f337ead580c70934141624b6d1ffdacc7", size = 21678 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e7/00/3fca040d7cf8a32776d3d81a00c8ee7457e00f80c649f1e4a863c8321ae9/uri_template-1.3.0-py3-none-any.whl", hash = "sha256:a44a133ea12d44a0c0f06d7d42a52d71282e77e2f937d8abd5655b8d56fc1363", size = 11140 }, +] + [[package]] name = "urllib3" version = "2.3.0" @@ -4139,6 +4612,23 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/61/14/33a3a1352cfa71812a3a21e8c9bfb83f60b0011f5e36f2b1399d51928209/uvicorn-0.34.0-py3-none-any.whl", hash = "sha256:023dc038422502fa28a09c7a30bf2b6991512da7dcdb8fd35fe57cfc154126f4", size = 62315 }, ] +[[package]] +name = "vesin" +version = "0.3.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "numpy", version = "2.0.2", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.10'" }, + { name = "numpy", version = "2.2.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.10'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/1c/df/14ea62b8fe455dfe2a99c2401471af8b65a6e9b1806045b3484f7fd01c94/vesin-0.3.2.tar.gz", hash = "sha256:7fc156d2475eca763534a08f7e91d153c707c209bc10e8d081276b4338eb2d5a", size = 27741 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/8b/63/37244a53cd97430c6c920c0f79f83170d8c65d2f83ef6ff3643651cfa8f8/vesin-0.3.2-py3-none-macosx_10_13_x86_64.whl", hash = "sha256:635d905905e52d145dd26ac55ff896d28d1de871bc418310dfbe30c4eb1b7e1c", size = 22163 }, + { url = "https://files.pythonhosted.org/packages/ec/d5/cdf7f4b3bebfa1c20e7309fbdaf789a3fa5b0642b75bfe736508d4ec4a5c/vesin-0.3.2-py3-none-macosx_11_0_arm64.whl", hash = "sha256:629e2b772969b67d44ccd32a6dd0c67da2fa8f4ea057c85ff70e03db7dde6bb6", size = 22280 }, + { url = "https://files.pythonhosted.org/packages/45/d6/3e8c62308e2a9d7dbe35ed2f8afa1218c8cdf2fa437f2338e78f8ef05efe/vesin-0.3.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e7e1c266ed674d1503f1de198a3aa67dcdf932e4245aeb02a8800595423ec755", size = 50876 }, + { url = "https://files.pythonhosted.org/packages/77/d6/fc1e5d46ad1be762f716723db32827c73a67dddab8c8a12e28ff14d934f5/vesin-0.3.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ecf93d8e02c8ef128bd5bb50403fa9ddf1be4f23178e04e6f7137ca2b36ca8af", size = 52208 }, + { url = "https://files.pythonhosted.org/packages/05/cc/6a2300581d0f41eb39088ebf4189ce7c618f5c3eab71415092bff3a1c744/vesin-0.3.2-py3-none-win_amd64.whl", hash = "sha256:cb6a5594a950dca6490d83ae78a876395e9cc9b5e3b30b5d76f467664aa10e3f", size = 52880 }, +] + [[package]] name = "wandb" version = "0.19.6" @@ -4263,6 +4753,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/fd/84/fd2ba7aafacbad3c4201d395674fc6348826569da3c0937e75505ead3528/wcwidth-0.2.13-py2.py3-none-any.whl", hash = "sha256:3da69048e4540d84af32131829ff948f1e022c1c6bdb8d6102117aac784f6859", size = 34166 }, ] +[[package]] +name = "webcolors" +version = "24.11.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/7b/29/061ec845fb58521848f3739e466efd8250b4b7b98c1b6c5bf4d40b419b7e/webcolors-24.11.1.tar.gz", hash = "sha256:ecb3d768f32202af770477b8b65f318fa4f566c22948673a977b00d589dd80f6", size = 45064 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/60/e8/c0e05e4684d13459f93d312077a9a2efbe04d59c393bc2b8802248c908d4/webcolors-24.11.1-py3-none-any.whl", hash = "sha256:515291393b4cdf0eb19c155749a096f779f7d909f7cceea072791cb9095b92e9", size = 14934 }, +] + [[package]] name = "webencodings" version = "0.5.1" @@ -4272,6 +4771,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/f4/24/2a3e3df732393fed8b3ebf2ec078f05546de641fe1b667ee316ec1dcf3b7/webencodings-0.5.1-py2.py3-none-any.whl", hash = "sha256:a0af1213f3c2226497a97e2b3aa01a7e4bee4f403f95be16fc9acd2947514a78", size = 11774 }, ] +[[package]] +name = "websocket-client" +version = "1.8.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/e6/30/fba0d96b4b5fbf5948ed3f4681f7da2f9f64512e1d303f94b4cc174c24a5/websocket_client-1.8.0.tar.gz", hash = "sha256:3239df9f44da632f96012472805d40a23281a991027ce11d2f45a6f24ac4c3da", size = 54648 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/5a/84/44687a29792a70e111c5c477230a72c4b957d88d16141199bf9acb7537a3/websocket_client-1.8.0-py3-none-any.whl", hash = "sha256:17b44cc997f5c498e809b22cdf2d9c7a9e71c02c8cc2b6c56e7c2d1239bfa526", size = 58826 }, +] + [[package]] name = "websockets" version = "14.2"